more javascript

i bet the jews did this
This commit is contained in:
MallocNull 2014-07-14 17:02:46 -05:00
parent 2cfef93e01
commit e72cdf0fcf
10 changed files with 282 additions and 116 deletions

View file

@ -7,9 +7,6 @@ using OpenQA.Selenium.Firefox;
using OpenQA.Selenium; using OpenQA.Selenium;
using OpenQA.Selenium.Internal; using OpenQA.Selenium.Internal;
using OpenQA.Selenium.Support.UI; using OpenQA.Selenium.Support.UI;
using SuperSocket;
using SuperSocket.SocketBase;
using SuperWebSocket;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using System.Threading; using System.Threading;
@ -81,6 +78,11 @@ namespace bot {
_G.driver = new FirefoxDriver(); _G.driver = new FirefoxDriver();
foreach(NavigationNode node in navigationList) foreach(NavigationNode node in navigationList)
node.performNavigation(_G.driver); node.performNavigation(_G.driver);
try {
(new WebDriverWait(_G.driver, new TimeSpan(0, 0, 300))).Until(ExpectedConditions.ElementExists(By.Id("inputField")));
} catch(Exception e) {
_G.criticalError("Navigation to chat failed! Fix instructions.", true);
}
_G.startThread(Pulse.pulseThread); _G.startThread(Pulse.pulseThread);

View file

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bot {
class ConditionHolder {
public ConditionHolder(string conditions) {
}
}
}

View file

@ -7,9 +7,6 @@ using OpenQA.Selenium.Firefox;
using OpenQA.Selenium; using OpenQA.Selenium;
using OpenQA.Selenium.Internal; using OpenQA.Selenium.Internal;
using OpenQA.Selenium.Support.UI; using OpenQA.Selenium.Support.UI;
using SuperSocket;
using SuperSocket.SocketBase;
using SuperWebSocket;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using System.Threading; using System.Threading;

View file

@ -8,14 +8,14 @@ using MySql.Data.MySqlClient;
namespace bot { namespace bot {
class Response { class Response {
public string conditions; public ConditionHolder conditions;
public Type responseType; public Type responseType;
public string parameters; public string parameters;
public int cooldown; public int cooldown;
public int lastCall; public int lastCall;
public Response(string conditions, string responseType, string parameters, int cooldown) { public Response(string conditions, string responseType, string parameters, int cooldown) {
this.conditions = conditions; this.conditions = new ConditionHolder(conditions);
this.responseType = Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "bot.responses", StringComparison.Ordinal) && String.Equals(t.Name, responseType, StringComparison.Ordinal)).ToArray()[0]; this.responseType = Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "bot.responses", StringComparison.Ordinal) && String.Equals(t.Name, responseType, StringComparison.Ordinal)).ToArray()[0];
this.parameters = parameters; this.parameters = parameters;
this.cooldown = cooldown; this.cooldown = cooldown;
@ -23,7 +23,7 @@ namespace bot {
} }
public Response(string conditions, int responseId, string parameters, int cooldown) { public Response(string conditions, int responseId, string parameters, int cooldown) {
this.conditions = conditions; this.conditions = new ConditionHolder(conditions);
string typeName = (string)(new MySqlCommand("SELECT `name` FROM `resptypes` WHERE `id`=" + responseId, _G.conn)).ExecuteScalar(); string typeName = (string)(new MySqlCommand("SELECT `name` FROM `resptypes` WHERE `id`=" + responseId, _G.conn)).ExecuteScalar();
this.responseType = Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "bot.responses", StringComparison.Ordinal) && String.Equals(t.Name, typeName, StringComparison.Ordinal)).ToArray()[0]; this.responseType = Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "bot.responses", StringComparison.Ordinal) && String.Equals(t.Name, typeName, StringComparison.Ordinal)).ToArray()[0];
this.parameters = parameters; this.parameters = parameters;

View file

@ -7,9 +7,6 @@ using OpenQA.Selenium.Firefox;
using OpenQA.Selenium; using OpenQA.Selenium;
using OpenQA.Selenium.Internal; using OpenQA.Selenium.Internal;
using OpenQA.Selenium.Support.UI; using OpenQA.Selenium.Support.UI;
using SuperSocket;
using SuperSocket.SocketBase;
using SuperWebSocket;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using System.Threading; using System.Threading;
@ -40,12 +37,21 @@ namespace bot {
for(int i = 0; i < 4; i++) for(int i = 0; i < 4; i++)
dbinfo[i] = r.ReadLine(); dbinfo[i] = r.ReadLine();
} catch(Exception e) { } catch(Exception e) {
Environment.FailFast("Error attempting to read from dbinfo.txt: "+e.Message+"\n\nProper format:\nSERVER ADDRESS\nUSERNAME\nPASSWORD\nDATABASE_NAME"); criticalError("Error attempting to read from dbinfo.txt: " + e.Message + "\n\nProper format:\nSERVER ADDRESS\nUSERNAME\nPASSWORD\nDATABASE_NAME");
return false; return false;
} }
return true; return true;
} }
public static void criticalError(string err, bool log = false) {
if(log)
logError(err);
Console.WriteLine(err);
Console.WriteLine("Press any key to quit.");
Console.ReadKey();
Environment.FailFast(err);
}
public static bool isDaylightSavings() { public static bool isDaylightSavings() {
return (observeDST) ? TimeZoneInfo.GetSystemTimeZones().First(o => o.DisplayName.ToLower().Contains("central time")).IsDaylightSavingTime(DateTime.UtcNow) : false; return (observeDST) ? TimeZoneInfo.GetSystemTimeZones().First(o => o.DisplayName.ToLower().Contains("central time")).IsDaylightSavingTime(DateTime.UtcNow) : false;
} }
@ -76,14 +82,14 @@ namespace bot {
tmp = new MySqlConnection("SERVER=" + dbinfo[0] + ";DATABASE=" + dbinfo[3] + ";UID=" + dbinfo[1] + ";PASSWORD=" + dbinfo[2] + ";"); tmp = new MySqlConnection("SERVER=" + dbinfo[0] + ";DATABASE=" + dbinfo[3] + ";UID=" + dbinfo[1] + ";PASSWORD=" + dbinfo[2] + ";");
tmp.Open(); tmp.Open();
} catch(Exception e) { } catch(Exception e) {
Environment.FailFast("Could not open database connection!"); criticalError("Could not open database connection!");
return null; return null;
} }
return tmp; return tmp;
} }
public static void logError(string err) { public static void logError(string err) {
(new MySqlCommand("INSERT INTO `error` (`time`,`msg`) VALUES ('"+ getLocalTimeFromUTC() +" UTC"+ timezone +"','"+err+"')", errconn)).ExecuteNonQuery(); Query.Quiet("INSERT INTO `error` (`time`,`msg`) VALUES ('"+ getLocalTimeFromUTC() +" UTC"+ timezone +"','"+err+"')", errconn);
} }
public delegate void threadFunc(); public delegate void threadFunc();

View file

@ -53,24 +53,6 @@
<Reference Include="Selenium.WebDriverBackedSelenium"> <Reference Include="Selenium.WebDriverBackedSelenium">
<HintPath>dll\Selenium.WebDriverBackedSelenium.dll</HintPath> <HintPath>dll\Selenium.WebDriverBackedSelenium.dll</HintPath>
</Reference> </Reference>
<Reference Include="SuperSocket.Common">
<HintPath>dll\SuperSocket.Common.dll</HintPath>
</Reference>
<Reference Include="SuperSocket.Dlr">
<HintPath>dll\SuperSocket.Dlr.dll</HintPath>
</Reference>
<Reference Include="SuperSocket.Facility">
<HintPath>dll\SuperSocket.Facility.dll</HintPath>
</Reference>
<Reference Include="SuperSocket.SocketBase">
<HintPath>dll\SuperSocket.SocketBase.dll</HintPath>
</Reference>
<Reference Include="SuperSocket.SocketEngine">
<HintPath>dll\SuperSocket.SocketEngine.dll</HintPath>
</Reference>
<Reference Include="SuperWebSocket">
<HintPath>dll\SuperWebSocket.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />

View file

@ -248,8 +248,8 @@ include("header.php"); ?>
<input type="text" name="tzMins" maxlength="2" value="<?php echo substr($config->timezone, 4); ?>" style="width:20px;" /> <input type="text" name="tzMins" maxlength="2" value="<?php echo substr($config->timezone, 4); ?>" style="width:20px;" />
<br /><abbr title="Daylight Savings Time?">DST?</abbr> <input type="checkbox" name="dst"<?php if($config->dst) { ?> checked="checked"<?php } ?> /> <br /><abbr title="Daylight Savings Time?">DST?</abbr> <input type="checkbox" name="dst"<?php if($config->dst) { ?> checked="checked"<?php } ?> />
</td></tr> </td></tr>
<tr><td style="text-align: right;">Chat Username:</td><td><input type="text" name="username" value="<?php echo $config->username; ?>" /></td></tr> <tr><td style="text-align: right;">Chat Username:</td><td><input type="text" name="username" value="<?php echo escapeDoubleQuotes($config->username); ?>" /></td></tr>
<tr><td style="text-align: right;">Bot Name:</td><td><input type="text" name="name" value="<?php echo $config->name; ?>" /></td></tr> <tr><td style="text-align: right;">Bot Name:</td><td><input type="text" name="name" value="<?php echo escapeDoubleQuotes($config->name); ?>" /></td></tr>
<tr><td></td><td><input type="submit" name="changeConfig" value="Modify" /></td></tr> <tr><td></td><td><input type="submit" name="changeConfig" value="Modify" /></td></tr>
</table> </table>
</form> </form>
@ -274,14 +274,14 @@ include("header.php"); ?>
<option value='4' <?php if($row->findtype == 4) select(); ?>>Find element by class</option> <option value='4' <?php if($row->findtype == 4) select(); ?>>Find element by class</option>
<option value='5' <?php if($row->findtype == 5) select(); ?>>Find element by tag name</option> <option value='5' <?php if($row->findtype == 5) select(); ?>>Find element by tag name</option>
</select> </select>
<input type='text' name='r<?php echo $row->id; ?>c2' id='r<?php echo $row->id; ?>c2' value="<?php echo $row->locator; ?>" /> <input type='text' name='r<?php echo $row->id; ?>c2' id='r<?php echo $row->id; ?>c2' value="<?php echo escapeDoubleQuotes($row->locator); ?>" />
<select name='r<?php echo $row->id; ?>c3' id='r<?php echo $row->id; ?>c3' onchange='handleColumnChange(<?php echo $row->id; ?>,3);' <?php if($row->findtype == 0) { ?>style='display: none;'<?php } ?>> <select name='r<?php echo $row->id; ?>c3' id='r<?php echo $row->id; ?>c3' onchange='handleColumnChange(<?php echo $row->id; ?>,3);' <?php if($row->findtype == 0) { ?>style='display: none;'<?php } ?>>
<option value='0' <?php if($row->action == 0) select(); ?>>and click it.</option> <option value='0' <?php if($row->action == 0) select(); ?>>and click it.</option>
<option value='1' <?php if($row->action == 1) select(); ?>>and type</option> <option value='1' <?php if($row->action == 1) select(); ?>>and type</option>
<option value='2' <?php if($row->action == 2) select(); ?>>and select the value</option> <option value='2' <?php if($row->action == 2) select(); ?>>and select the value</option>
<option value='3' <?php if($row->action == 3) select(); ?>>and select the index</option> <option value='3' <?php if($row->action == 3) select(); ?>>and select the index</option>
</select> </select>
<input type='text' name='r<?php echo $row->id; ?>c4' id='r<?php echo $row->id; ?>c4' <?php if($row->findtype == 0 || $row->action == 0) { ?>style='display: none;'<?php } ?> value="<?php echo $row->parameter; ?>" /> <input type='text' name='r<?php echo $row->id; ?>c4' id='r<?php echo $row->id; ?>c4' <?php if($row->findtype == 0 || $row->action == 0) { ?>style='display: none;'<?php } ?> value="<?php echo escapeDoubleQuotes($row->parameter); ?>" />
<img src='img/arrow_up.png' class='fakelink' style='vertical-align: text-bottom;' onclick='' /> <img src='img/arrow_up.png' class='fakelink' style='vertical-align: text-bottom;' onclick='' />
<img src='img/arrow_down.png' class='fakelink' style='vertical-align: text-bottom;' onclick='' /> <img src='img/arrow_down.png' class='fakelink' style='vertical-align: text-bottom;' onclick='' />
<img src='img/delete.png' class='fakelink' style='vertical-align: text-bottom;' onclick='' /> <img src='img/delete.png' class='fakelink' style='vertical-align: text-bottom;' onclick='' />

View file

@ -5,6 +5,14 @@ session_start();
$config = mysql_fetch_object(mysql_query("SELECT * FROM `config` WHERE `id`=1")); $config = mysql_fetch_object(mysql_query("SELECT * FROM `config` WHERE `id`=1"));
function escapeDoubleQuotes($str) {
return str_replace('"','\\"',$str);
}
function escapeSingleQuotes($str) {
return str_replace("'","\\'",$str);
}
function checkIfLoggedIn() { function checkIfLoggedIn() {
if(mysql_num_rows(mysql_query("SELECT * FROM `admin` WHERE `username`='". mysql_real_escape_string($_SESSION['user']) ."' AND `password`='". $_SESSION['pwd'] ."'")) > 0) if(mysql_num_rows(mysql_query("SELECT * FROM `admin` WHERE `username`='". mysql_real_escape_string($_SESSION['user']) ."' AND `password`='". $_SESSION['pwd'] ."'")) > 0)
return true; return true;

View file

@ -1,6 +1,8 @@
<?php <?php
include("conn.php"); include("conn.php");
var_dump($config);
$err = $_GET["err"]; $err = $_GET["err"];
if($_POST["loginAttempt"]) { if($_POST["loginAttempt"]) {

View file

@ -1,43 +1,122 @@
<?php include("conn.php"); <?php include("conn.php");
include("header.php"); ?>
$condtypes = array();
$resptypes = array();
$q = mysql_query("SELECT * FROM `conditions`");
while($cond = mysql_fetch_object($q)) {
$condtypes[$cond->id] = array();
}
if($_POST["resptype"]) {
$c = "";
for($i=1;;$i++) {
if(!isset($_POST["if". $i ."group"])) break;
$c .= $_POST['if'.$i.'group'] .",".$_POST['if'.$i.'not'].",".$_POST['if'.$i.'cond'].",".$_POST['if'.$i.'param'].";";
if(isset($_POST["op".$i])) $c .= $_POST["op".$i] .";";
}
mysql_query("INSERT INTO `responses` (`conditions`,`respid`,`parameters`,`cooldown`) VALUES ('". mysql_real_escape_string($c) ."',". $_POST['resptype'] .",'". mysql_real_escape_string($_POST['parameters']) ."',". (($_POST['ccd']==0)?-1:$_POST['cooldown']) .")") or die(mysql_error());
header("Location: resp.php");
}
include("header.php");
?>
<script type="text/javascript"> <script type="text/javascript">
var defaultCool = <?php echo $config->cooldown; ?>;
function handleRespChange() { function handleRespChange() {
document.getElementById("respDesc").innerHTML = document.getElementById(""+document.getElementById("resptype").selectedIndex).innerHTML; document.getElementById("respDesc").innerHTML = document.getElementById(""+document.getElementById("resptype").selectedIndex).innerHTML;
} }
function coolChange() {
if(document.getElementById("cdd").selectedIndex == 0) {
document.getElementById("cooldown").disabled = true;
document.getElementById("cooldown").value = defaultCool;
} else
document.getElementById("cooldown").disabled = false;
}
function redrawList() { function redrawList() {
var selectedValues = Array(); var selectedValues = Array();
var tmpr = document.getElementById("ifholder").children; var tmpr = document.getElementById("ifholder").children;
if(tmpr[0].children.length < 3) {
document.getElementById("ifholder").removeChild(tmpr[0]);
tmpr = document.getElementById("ifholder").children;
}
var tmp = Array(); var tmp = Array();
for(i = 0; i < tmpr.length; i++) { for(i = 0; i < tmpr.length; i++) {
selectedValues[i*4] = tmpr[i].children[0].selectedIndex; if(tmpr[i].children.length > 3) {
selectedValues[i*4+1] = tmpr[i].children[1].selectedIndex; selectedValues[i*4] = tmpr[i].children[0].selectedIndex;
selectedValues[i*4+2] = tmpr[i].children[2].value; selectedValues[i*4+1] = tmpr[i].children[1].selectedIndex;
if(tmpr[i].children.length == 7) selectedValues[i*4+2] = tmpr[i].children[2].selectedIndex;
selectedValues[i*4+3] = tmpr[i].children[3].selectedIndex; selectedValues[i*4+3] = tmpr[i].children[3].value;
else } else {
selectedValues[i*4+3] = -1; selectedValues[i*4] = tmpr[i].children[0].selectedIndex;
selectedValues[i*4+1] = "operator";
}
tmp[i] = tmpr[i].cloneNode(true); tmp[i] = tmpr[i].cloneNode(true);
} }
document.getElementById("ifholder").innerHTML = ""; document.getElementById("ifholder").innerHTML = "";
var j = 1;
for(i = 0; i < tmp.length; i++) { for(i = 0; i < tmp.length; i++) {
tmp[i].setAttribute("id","if"+(i+1)); if(selectedValues[i*4+1] != "operator") {
var tmpc = tmp[i].children; tmp[i].setAttribute("id","if"+j);
tmpc[0].name = "if"+ (i+1) +"group"; var tmpc = tmp[i].children;
tmpc[0].selectedIndex = selectedValues[0]; tmpc[0].name = "if"+ j +"group";
tmpc[1].name = "if1" tmpc[0].selectedIndex = selectedValues[i*4];
document.getElementById("navContainer").appendChild(tmp[i]); tmpc[1].name = "if"+ j +"not";
tmpc[1].selectedIndex = selectedValues[i*4+1];
tmpc[2].name = "if"+ j +"cond";
tmpc[2].selectedIndex = selectedValues[i*4+2];
tmpc[3].name = "if"+ j +"param";
tmpc[3].value = selectedValues[i*4+3];
tmpc[4].setAttribute("onclick","handleRowUp("+ j +");");
tmpc[5].setAttribute("onclick","handleRowDown("+ j +");");
tmpc[6].setAttribute("onclick","handleRowDelete("+ j +");");
if(i%2==1) {
if(document.getElementById("op"+ (j-1)) == null) {
var op = document.createElement("span");
op.setAttribute("id","op"+(j-1));
op.setAttribute("class","block");
op.innerHTML = "<select name='op"+ (j-1) +"'><option value='0'>and</option><option value='1'>or</option></select>";
document.getElementById("ifholder").appendChild(op);
}
}
j++;
document.getElementById("ifholder").appendChild(tmp[i]);
/*if(i != tmp.length)
tmp.innerHTML += "<br />";*/
} else {
if(i != tmp.length-1 && i != 0) {
if(selectedValues[(i-1)*4+1] != "operator") {
tmp[i].setAttribute("id","op"+(j-1));
tmp[i].children[0].selectedIndex = selectedValues[i*4];
document.getElementById("ifholder").appendChild(tmp[i]);
}
}
}
}
var childs = document.getElementById("ifholder").children;
for(i = 0; i < childs.length; i++) {
if((i%2==0 && childs[i].children.length < 3) || (i%2==1 && childs[i].children.length > 3)) {
redrawList();
break;
}
} }
} }
function addCondition() { function addCondition() {
var cond = document.createElement("span"); var cond = document.createElement("span");
cond.setAttribute("id","if1"); cond.setAttribute("id","if1");
cond.setAttribute("class","block") cond.setAttribute("class","block");
cond.innerHTML = '<select name="if1group">' + cond.innerHTML = '<select name="if1group">' +
'<?php for($i = 1; $i < 10; $i++) echo "<option value=\"$i\">$i</option>"; ?>' + '<?php for($i = 1; $i < 10; $i++) echo "<option value=\"$i\">$i</option>"; ?>' +
'</select>' + '</select>' +
' <select name="if1not"><option value="0"></option><option value="1">not</option></select>' +
' <select name="if1cond">' + ' <select name="if1cond">' +
'<?php $q = mysql_query("SELECT * FROM `conditions`"); while($cond = mysql_fetch_object($q)) { echo "<option value=\"". $cond->id ."\">". $cond->friendlyname ."</option>"; } ?>' + '<?php $q = mysql_query("SELECT * FROM `conditions`"); while($cond = mysql_fetch_object($q)) { echo "<option value=\"". $cond->id ."\">". $cond->friendlyname ."</option>"; } ?>' +
'</select>' + '</select>' +
@ -46,7 +125,70 @@ include("header.php"); ?>
' <img src="img/arrow_down.png" class="fakelink" style="vertical-align: text-bottom;" onclick="handleRowDown(1);" />' + ' <img src="img/arrow_down.png" class="fakelink" style="vertical-align: text-bottom;" onclick="handleRowDown(1);" />' +
' <img src="img/delete.png" class="fakelink" style="vertical-align: text-bottom;" onclick="handleRowDelete(1);" />' ' <img src="img/delete.png" class="fakelink" style="vertical-align: text-bottom;" onclick="handleRowDelete(1);" />'
document.getElementById("ifholder").appendChild(cond); document.getElementById("ifholder").appendChild(cond);
//redrawList(); redrawList();
}
function handleRowUp(r) {
if(r != 1) {
var child = document.getElementById("if"+r);
var clone = child.cloneNode(true);
clone.children[0].selectedIndex = child.children[0].selectedIndex;
clone.children[1].value = child.children[1].value;
clone.children[2].selectedIndex = child.children[2].selectedIndex;
clone.children[3].value = child.children[3].value;
document.getElementById("ifholder").removeChild(child);
document.getElementById("ifholder").insertBefore(clone, document.getElementById("if"+(r-1)));
redrawList();
}
}
function handleRowDown(r) {
if(r != (document.getElementById("ifholder").children.length+1)/2) {
var child = document.getElementById("if"+r);
var clone = child.cloneNode(true);
clone.children[0].selectedIndex = child.children[0].selectedIndex;
clone.children[1].value = child.children[1].value;
clone.children[2].selectedIndex = child.children[2].selectedIndex;
clone.children[3].value = child.children[3].value;
document.getElementById("ifholder").removeChild(child);
document.getElementById("ifholder").insertBefore(clone, document.getElementById("if"+(r+2)));
/*if(r+2 != (document.getElementById("ifholder").children.length+1)/2) {
var opchild = document.getElementById("op"+r);
var opclone = opchild.cloneNode(true);
opclone.children[0].selectedIndex = opchild.children[0].selectedIndex;
document.getElementById("ifholder").removeChild(opchild);
document.getElementById("ifholder").insertBefore(opclone, document.getElementById("if"+(r+2)));
}*/
redrawList();
}
}
function evaluateCondition() {
var childs = document.getElementById("ifholder").children;
for(i = 0; i < childs.length; i+=2) {
if(childs[i].children[3].value.trim() == "") {
alert("Condition parameters cannot be empty!");
return;
}
}
if(document.getElementById("cdd").selectedIndex == 1 && (document.getElementById("cooldown").value.trim() == "" || isNaN(document.getElementById("cooldown").value))) {
alert("Custom cooldown must not be empty and must be a number!");
return;
}
document.getElementById("resp").submit();
}
function handleRowDelete(r) {
if(document.getElementById("ifholder").children.length > 1) {
document.getElementById("ifholder").removeChild(document.getElementById("if"+r));
var oper = document.getElementById("op"+r);
if(oper != null) document.getElementById("ifholder").removeChild(oper);
redrawList();
} else {
alert("You need at least one condition!");
}
} }
</script> </script>
<center> <center>
@ -57,70 +199,84 @@ include("header.php"); ?>
<?php } else if($_GET["do"]=="new") { ?> <?php } else if($_GET["do"]=="new") { ?>
<legend>Create New Response</legend> <legend>Create New Response</legend>
<p> <form method="post" action="" id="resp">
If <p>
<span id="ifholder"> If
<span id="if1" class="block"> <span id="ifholder">
<select name="if1group"> <span id="if1" class="block">
<?php <select name="if1group">
for($i = 1; $i < 10; $i++) <?php
echo "<option value=\"$i\">$i</option>"; for($i = 1; $i < 10; $i++)
?> echo "<option value=\"$i\">$i</option>";
</select> ?>
<select name="if1cond"> </select>
<?php <select name="if1not">
$q = mysql_query("SELECT * FROM `conditions`"); <option value="0"></option>
while($cond = mysql_fetch_object($q)) { <option value="1">not</option>
echo "<option value='". $cond->id ."'>". $cond->friendlyname ."</option>"; </select>
} <select name="if1cond">
?> <?php
</select> $q = mysql_query("SELECT * FROM `conditions`");
<input type="text" name="if1param" /> while($cond = mysql_fetch_object($q)) {
<img src='img/arrow_up.png' class='fakelink' style='vertical-align: text-bottom;' onclick='handleRowUp(1);' /> echo "<option value='". $cond->id ."'>". $cond->friendlyname ."</option>";
<img src='img/arrow_down.png' class='fakelink' style='vertical-align: text-bottom;' onclick='handleRowDown(1);' /> }
<img src='img/delete.png' class='fakelink' style='vertical-align: text-bottom;' onclick='handleRowDelete(1);' /> ?>
</select>
<input type="text" name="if1param" />
<img src='img/arrow_up.png' class='fakelink' style='vertical-align: text-bottom;' onclick='handleRowUp(1);' />
<img src='img/arrow_down.png' class='fakelink' style='vertical-align: text-bottom;' onclick='handleRowDown(1);' />
<img src='img/delete.png' class='fakelink' style='vertical-align: text-bottom;' onclick='handleRowDelete(1);' />
</span>
</span> </span>
</span> <span class="block">
<span class="block"> <a href="javascript:addCondition();">Add Condition</a>
<a href="javascript:addCondition();">Add Condition</a> </span>
</span> </p>
</p> <p>
<p> then
then <select name="resptype" id="resptype" onchange="handleRespChange();">
<select name="resptype" id="resptype" onchange="handleRespChange();"> <?php
<?php $q = mysql_query("SELECT * FROM `resptypes`");
$q = mysql_query("SELECT * FROM `resptypes`"); $descarr = array();
$descarr = array(); for($i = 0;;$i++) {
for($i = 0;;$i++) { $type = mysql_fetch_object($q);
$type = mysql_fetch_object($q); if(!$type) break;
if(!$type) break; echo "<option value='". $type->id ."'>". $type->friendlyname ."</option>";
echo "<option value='". $type->id ."'>". $type->friendlyname ."</option>"; $descarr[$i] = $type->description;
$descarr[$i] = $type->description; }
} ?>
?> </select>
</select> <?php
<?php $i = 0;
$i = 0; foreach($descarr as $desc) {
foreach($descarr as $desc) { echo "<p style='display:none;' id='$i'>". $desc ."</p>";
echo "<p style='display:none;' id='$i'>". $desc ."</p>"; $i++;
$i++; }
} ?>
?> </p>
</p> <p>
<p> <span class="block" id="respDesc">
<span class="block" id="respDesc"> <?php echo $descarr[0]; ?>
<?php echo $descarr[0]; ?> </span>
</span> <span class="block">Parameters:
<span class="block">Parameters: <center>
<center> <textarea name="parameters" rows="8" style="width:95%;"></textarea>
<textarea name="parameters" rows="8" style="width:95%;"></textarea> </center></span>
</center></span> </p>
</p> <p>
<p> Cooldown:
<input type="submit" name="addResponse" value="Add Response" /> <select name="cdd" id="cdd" onchange="coolChange();">
&nbsp;&nbsp;&nbsp;&nbsp; <option value="0">Default</option>
<input type="button" value="Cancel" onclick="window.location.href = 'resp.php';" /> <option value="1">Custom</option>
</p> </select>
<input type="textbox" name="cooldown" id="cooldown" size="6" value="<?php echo $config->cooldown; ?>" disabled="disabled" /> seconds
</p>
<p>
<input type="button" name="addResponse" value="Add Response" onclick="evaluateCondition();" />
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" value="Cancel" onclick="window.location.href = 'resp.php';" />
</p>
</form>
<?php } else if($_GET["do"]=="edit") { ?> <?php } else if($_GET["do"]=="edit") { ?>
<legend>Edit Response</legend> <legend>Edit Response</legend>
<?php } ?> <?php } ?>