command parsing
jesus christ
This commit is contained in:
parent
5b9da768f8
commit
c74eb2eb4e
6 changed files with 339 additions and 36 deletions
|
@ -19,7 +19,7 @@ namespace bot {
|
||||||
|
|
||||||
public static void loadNavigationList() {
|
public static void loadNavigationList() {
|
||||||
navigationList = new List<NavigationNode>();
|
navigationList = new List<NavigationNode>();
|
||||||
var r = Query.Reader("SELECT * FROM `navigate`", _G.conn);
|
var r = Query.Reader("SELECT * FROM `navigate`", _G.spawnNewConnection());
|
||||||
while(r.Read()) {
|
while(r.Read()) {
|
||||||
navigationList.Add(new NavigationNode(
|
navigationList.Add(new NavigationNode(
|
||||||
r.GetInt32("findtype"),
|
r.GetInt32("findtype"),
|
||||||
|
@ -32,7 +32,7 @@ namespace bot {
|
||||||
|
|
||||||
public static void loadResponseList() {
|
public static void loadResponseList() {
|
||||||
responseList = new List<Response>();
|
responseList = new List<Response>();
|
||||||
var r = Query.Reader("SELECT * FROM `responses`", _G.conn);
|
var r = Query.Reader("SELECT * FROM `responses`", _G.spawnNewConnection());
|
||||||
while(r.Read()) {
|
while(r.Read()) {
|
||||||
responseList.Add(new Response(
|
responseList.Add(new Response(
|
||||||
r.GetString("conditions"),
|
r.GetString("conditions"),
|
||||||
|
|
|
@ -3,10 +3,33 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using OpenQA.Selenium.Firefox;
|
||||||
|
using OpenQA.Selenium;
|
||||||
|
using OpenQA.Selenium.Internal;
|
||||||
|
using OpenQA.Selenium.Support.UI;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
using System.Threading;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace bot {
|
namespace bot {
|
||||||
class Condition {
|
class Condition {
|
||||||
|
public bool not;
|
||||||
|
public Type conditionType;
|
||||||
|
public string parameter;
|
||||||
|
|
||||||
|
public Condition() { }
|
||||||
|
|
||||||
|
public Condition(bool n, Type c, string p) {
|
||||||
|
not = n;
|
||||||
|
conditionType = c;
|
||||||
|
parameter = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Condition(bool n, int c, string p) {
|
||||||
|
not = n;
|
||||||
|
string typeName = (string)(new MySqlCommand("SELECT `name` FROM `conditions` WHERE `id`=" + c, _G.conn)).ExecuteScalar();
|
||||||
|
conditionType = Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "bot.conditions", StringComparison.Ordinal) && String.Equals(t.Name, typeName, StringComparison.Ordinal)).ToArray()[0];
|
||||||
|
parameter = p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,46 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace bot {
|
namespace bot {
|
||||||
class ConditionHolder {
|
class ConditionHolder {
|
||||||
|
List<Condition> conditions = new List<Condition>();
|
||||||
|
List<ConditionHolder> sequence = new List<ConditionHolder>();
|
||||||
|
|
||||||
|
public ConditionHolder(string condstring, bool baselvl = true) {
|
||||||
|
List<string> c = condstring.Split(';').ToList();
|
||||||
|
c.RemoveAt(c.Count - 1);
|
||||||
|
int i = 0, searching = -1;
|
||||||
|
int[] pair = { -1, -1 };
|
||||||
|
for(int on = 0; on < c.Count; on++) {
|
||||||
|
string cond = c[on];
|
||||||
|
List<string> tk = cond.Split(',').ToList();
|
||||||
|
if(tk.Count > 2) {
|
||||||
|
if(Int32.Parse(tk[0]) > 0 && searching == -1) {
|
||||||
|
searching = 0;
|
||||||
|
pair[0] = i;
|
||||||
|
}
|
||||||
|
if(searching != -1)
|
||||||
|
searching += Int32.Parse(tk[0]) - Int32.Parse(tk[4]);
|
||||||
|
if(searching == 0) {
|
||||||
|
searching = -1;
|
||||||
|
pair[1] = i;
|
||||||
|
string str = "", tmp = "";
|
||||||
|
|
||||||
public ConditionHolder(string condstring) {
|
if(pair[0] != 0) {
|
||||||
|
//tmp = condstring.Substring(0,
|
||||||
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
str = condstring.Substring((pair[0] == 0) ? 0 : _G.indexOfNth(condstring, ';', pair[0] + 1) + 1, _G.indexOfNth(condstring, ';', pair[1] + 2) + 1);
|
||||||
|
str = Int32.Parse(str.Substring(0, str.IndexOf(','))) - 1 + str.Substring(str.IndexOf(','));
|
||||||
|
|
||||||
|
sequence.Add(new ConditionHolder(str, false));
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool calculateValue(Message msg) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,6 +92,15 @@ namespace bot {
|
||||||
Query.Quiet("INSERT INTO `error` (`time`,`msg`) VALUES ('"+ getLocalTimeFromUTC() +" UTC"+ timezone +"','"+err+"')", errconn);
|
Query.Quiet("INSERT INTO `error` (`time`,`msg`) VALUES ('"+ getLocalTimeFromUTC() +" UTC"+ timezone +"','"+err+"')", errconn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int indexOfNth(string str, char c, int index) {
|
||||||
|
int fcount = 0;
|
||||||
|
for(int i = 0; i < str.Length; i++) {
|
||||||
|
if(str[i] == c) fcount++;
|
||||||
|
if(fcount == index) return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
public delegate void threadFunc();
|
public delegate void threadFunc();
|
||||||
public static void startThread(threadFunc t) {
|
public static void startThread(threadFunc t) {
|
||||||
runningThreads.Add((new Thread(new ThreadStart(t))));
|
runningThreads.Add((new Thread(new ThreadStart(t))));
|
||||||
|
|
BIN
www/img/edit.png
Normal file
BIN
www/img/edit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 450 B |
291
www/resp.php
291
www/resp.php
|
@ -1,17 +1,57 @@
|
||||||
<?php include("conn.php");
|
<?php include("conn.php");
|
||||||
|
|
||||||
|
function parseConditionString($str, $resptype) {
|
||||||
$condtypes = array();
|
$condtypes = array();
|
||||||
|
|
||||||
$q = mysql_query("SELECT * FROM `conditions`");
|
$q = mysql_query("SELECT * FROM `conditions`");
|
||||||
while($cond = mysql_fetch_object($q)) {
|
while($cond = mysql_fetch_object($q)) {
|
||||||
$condtypes[$cond->id] = $cond->friendlyname;
|
$condtypes[$cond->id] = $cond->friendlyname;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_POST["resptype"]) {
|
$ret = "IF ";
|
||||||
|
$conds = explode(";",$str);
|
||||||
|
$conds = array_slice($conds, 0, count($conds)-1);
|
||||||
|
foreach($conds as $cond) {
|
||||||
|
$tk = explode(",",$cond);
|
||||||
|
if(count($tk) > 3) {
|
||||||
|
for($i = 0; $i < intval($tk[0]); $i++)
|
||||||
|
$ret .= "(";
|
||||||
|
if($tk[1] == "1")
|
||||||
|
$ret .= "not ";
|
||||||
|
$ret .= "<b>". $condtypes[intval($tk[2])] ."</b> ". $tk[3];
|
||||||
|
for($i = 0; $i < intval($tk[4]); $i++)
|
||||||
|
$ret .= ")";
|
||||||
|
$ret .= " ";
|
||||||
|
} else {
|
||||||
|
if($tk[0] == 0) $ret .= "AND ";
|
||||||
|
else if($tk[0] == 1) $ret .= "OR ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$ret .= "THEN <i>". strtolower($resptype) ."</i>";
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($_GET['del']) {
|
||||||
|
mysql_query("DELETE FROM `responses` WHERE `id`=".$_GET['del']);
|
||||||
|
header("Location: resp.php");
|
||||||
|
}
|
||||||
|
|
||||||
|
if($_POST["editId"]) {
|
||||||
$c = "";
|
$c = "";
|
||||||
for($i=1;;$i++) {
|
for($i=1;;$i++) {
|
||||||
if(!isset($_POST["if". $i ."group"])) break;
|
if(!isset($_POST["if". $i ."param"])) break;
|
||||||
$c .= $_POST['if'.$i.'group'] .",".$_POST['if'.$i.'not'].",".$_POST['if'.$i.'cond'].",".$_POST['if'.$i.'param'].";";
|
$c .= $_POST['if'.$i.'lpar'].",".$_POST['if'.$i.'not'].",".$_POST['if'.$i.'cond'].",".$_POST['if'.$i.'param'].",".$_POST['if'.$i.'rpar'].";";
|
||||||
|
if(isset($_POST["op".$i])) $c .= $_POST["op".$i] .";";
|
||||||
|
}
|
||||||
|
|
||||||
|
mysql_query("UPDATE `responses` SET `conditions`='". mysql_real_escape_string($c) ."', `respid`=". $_POST['resptype'] .", `parameters`='". mysql_real_escape_string($_POST['parameters']) ."', `cooldown`=". (($_POST['cdd']==0)?-1:$_POST['cooldown']) ." WHERE `id`=". $_POST['editId']) or die(mysql_error());
|
||||||
|
header("Location: resp.php");
|
||||||
|
}
|
||||||
|
|
||||||
|
if($_POST["resptype"] && !$_POST["editId"]) {
|
||||||
|
$c = "";
|
||||||
|
for($i=1;;$i++) {
|
||||||
|
if(!isset($_POST["if". $i ."param"])) break;
|
||||||
|
$c .= $_POST['if'.$i.'lpar'].",".$_POST['if'.$i.'not'].",".$_POST['if'.$i.'cond'].",".$_POST['if'.$i.'param'].",".$_POST['if'.$i.'rpar'].";";
|
||||||
if(isset($_POST["op".$i])) $c .= $_POST["op".$i] .";";
|
if(isset($_POST["op".$i])) $c .= $_POST["op".$i] .";";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +64,11 @@ include("header.php");
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var defaultCool = <?php echo $config->cooldown; ?>;
|
var defaultCool = <?php echo $config->cooldown; ?>;
|
||||||
|
|
||||||
|
function confirmDeletion(id) {
|
||||||
|
var q = confirm("Are you sure you want to delete this response?");
|
||||||
|
if(q) window.location.href = "resp.php?del="+id;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -46,13 +91,14 @@ include("header.php");
|
||||||
var tmp = Array();
|
var tmp = Array();
|
||||||
for(i = 0; i < tmpr.length; i++) {
|
for(i = 0; i < tmpr.length; i++) {
|
||||||
if(tmpr[i].children.length > 3) {
|
if(tmpr[i].children.length > 3) {
|
||||||
selectedValues[i*4] = tmpr[i].children[0].selectedIndex;
|
selectedValues[i*5] = tmpr[i].children[0].selectedIndex;
|
||||||
selectedValues[i*4+1] = tmpr[i].children[1].selectedIndex;
|
selectedValues[i*5+1] = tmpr[i].children[1].selectedIndex;
|
||||||
selectedValues[i*4+2] = tmpr[i].children[2].selectedIndex;
|
selectedValues[i*5+2] = tmpr[i].children[2].selectedIndex;
|
||||||
selectedValues[i*4+3] = tmpr[i].children[3].value;
|
selectedValues[i*5+3] = tmpr[i].children[3].value;
|
||||||
|
selectedValues[i*5+4] = tmpr[i].children[4].selectedIndex;
|
||||||
} else {
|
} else {
|
||||||
selectedValues[i*4] = tmpr[i].children[0].selectedIndex;
|
selectedValues[i*5] = tmpr[i].children[0].selectedIndex;
|
||||||
selectedValues[i*4+1] = "operator";
|
selectedValues[i*5+1] = "operator";
|
||||||
}
|
}
|
||||||
tmp[i] = tmpr[i].cloneNode(true);
|
tmp[i] = tmpr[i].cloneNode(true);
|
||||||
}
|
}
|
||||||
|
@ -60,20 +106,22 @@ include("header.php");
|
||||||
|
|
||||||
var j = 1;
|
var j = 1;
|
||||||
for(i = 0; i < tmp.length; i++) {
|
for(i = 0; i < tmp.length; i++) {
|
||||||
if(selectedValues[i*4+1] != "operator") {
|
if(selectedValues[i*5+1] != "operator") {
|
||||||
tmp[i].setAttribute("id","if"+j);
|
tmp[i].setAttribute("id","if"+j);
|
||||||
var tmpc = tmp[i].children;
|
var tmpc = tmp[i].children;
|
||||||
tmpc[0].name = "if"+ j +"group";
|
tmpc[0].name = "if"+ j +"lpar";
|
||||||
tmpc[0].selectedIndex = selectedValues[i*4];
|
tmpc[0].selectedIndex = selectedValues[i*5];
|
||||||
tmpc[1].name = "if"+ j +"not";
|
tmpc[1].name = "if"+ j +"not";
|
||||||
tmpc[1].selectedIndex = selectedValues[i*4+1];
|
tmpc[1].selectedIndex = selectedValues[i*5+1];
|
||||||
tmpc[2].name = "if"+ j +"cond";
|
tmpc[2].name = "if"+ j +"cond";
|
||||||
tmpc[2].selectedIndex = selectedValues[i*4+2];
|
tmpc[2].selectedIndex = selectedValues[i*5+2];
|
||||||
tmpc[3].name = "if"+ j +"param";
|
tmpc[3].name = "if"+ j +"param";
|
||||||
tmpc[3].value = selectedValues[i*4+3];
|
tmpc[3].value = selectedValues[i*5+3];
|
||||||
tmpc[4].setAttribute("onclick","handleRowUp("+ j +");");
|
tmpc[4].name = "if"+ j +"rpar";
|
||||||
tmpc[5].setAttribute("onclick","handleRowDown("+ j +");");
|
tmpc[4].selectedIndex = selectedValues[i*5+4];
|
||||||
tmpc[6].setAttribute("onclick","handleRowDelete("+ j +");");
|
tmpc[5].setAttribute("onclick","handleRowUp("+ j +");");
|
||||||
|
tmpc[6].setAttribute("onclick","handleRowDown("+ j +");");
|
||||||
|
tmpc[7].setAttribute("onclick","handleRowDelete("+ j +");");
|
||||||
if(i%2==1) {
|
if(i%2==1) {
|
||||||
if(document.getElementById("op"+ (j-1)) == null) {
|
if(document.getElementById("op"+ (j-1)) == null) {
|
||||||
var op = document.createElement("span");
|
var op = document.createElement("span");
|
||||||
|
@ -90,9 +138,10 @@ include("header.php");
|
||||||
tmp.innerHTML += "<br />";*/
|
tmp.innerHTML += "<br />";*/
|
||||||
} else {
|
} else {
|
||||||
if(i != tmp.length-1 && i != 0) {
|
if(i != tmp.length-1 && i != 0) {
|
||||||
if(selectedValues[(i-1)*4+1] != "operator") {
|
if(selectedValues[(i-1)*5+1] != "operator") {
|
||||||
tmp[i].setAttribute("id","op"+(j-1));
|
tmp[i].setAttribute("id","op"+(j-1));
|
||||||
tmp[i].children[0].selectedIndex = selectedValues[i*4];
|
tmp[i].children[0].name = "op"+(j-1);
|
||||||
|
tmp[i].children[0].selectedIndex = selectedValues[i*5];
|
||||||
document.getElementById("ifholder").appendChild(tmp[i]);
|
document.getElementById("ifholder").appendChild(tmp[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,14 +161,17 @@ include("header.php");
|
||||||
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="if1lpar">' +
|
||||||
'<?php for($i = 1; $i < 10; $i++) echo "<option value=\"$i\">$i</option>"; ?>' +
|
'<?php for($i = 0; $i < 6; $i++) { echo "<option value=\"$i\">"; for($j = 0; $j < $i; $j++) echo "("; echo "</option>"; } ?>' +
|
||||||
'</select>' +
|
'</select>' +
|
||||||
' <select name="if1not"><option value="0"></option><option value="1">not</option></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>' +
|
||||||
' <input type="text" name="if1param" />' +
|
' <input type="text" name="if1param" />' +
|
||||||
|
' <select name="if1rpar">' +
|
||||||
|
'<?php for($i = 0; $i < 6; $i++) { echo "<option value=\"$i\">"; for($j = 0; $j < $i; $j++) echo ")"; echo "</option>"; } ?>' +
|
||||||
|
'</select>' +
|
||||||
' <img src="img/arrow_up.png" class="fakelink" style="vertical-align: text-bottom;" onclick="handleRowUp(1);" />' +
|
' <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/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);" />'
|
||||||
|
@ -135,6 +187,7 @@ include("header.php");
|
||||||
clone.children[1].value = child.children[1].value;
|
clone.children[1].value = child.children[1].value;
|
||||||
clone.children[2].selectedIndex = child.children[2].selectedIndex;
|
clone.children[2].selectedIndex = child.children[2].selectedIndex;
|
||||||
clone.children[3].value = child.children[3].value;
|
clone.children[3].value = child.children[3].value;
|
||||||
|
clone.children[4].selectedIndex = child.children[4].selectedIndex;
|
||||||
document.getElementById("ifholder").removeChild(child);
|
document.getElementById("ifholder").removeChild(child);
|
||||||
document.getElementById("ifholder").insertBefore(clone, document.getElementById("if"+(r-1)));
|
document.getElementById("ifholder").insertBefore(clone, document.getElementById("if"+(r-1)));
|
||||||
redrawList();
|
redrawList();
|
||||||
|
@ -149,6 +202,7 @@ include("header.php");
|
||||||
clone.children[1].value = child.children[1].value;
|
clone.children[1].value = child.children[1].value;
|
||||||
clone.children[2].selectedIndex = child.children[2].selectedIndex;
|
clone.children[2].selectedIndex = child.children[2].selectedIndex;
|
||||||
clone.children[3].value = child.children[3].value;
|
clone.children[3].value = child.children[3].value;
|
||||||
|
clone.children[4].selectedIndex = child.children[4].selectedIndex;
|
||||||
document.getElementById("ifholder").removeChild(child);
|
document.getElementById("ifholder").removeChild(child);
|
||||||
document.getElementById("ifholder").insertBefore(clone, document.getElementById("if"+(r+2)));
|
document.getElementById("ifholder").insertBefore(clone, document.getElementById("if"+(r+2)));
|
||||||
|
|
||||||
|
@ -166,11 +220,21 @@ include("header.php");
|
||||||
|
|
||||||
function evaluateCondition() {
|
function evaluateCondition() {
|
||||||
var childs = document.getElementById("ifholder").children;
|
var childs = document.getElementById("ifholder").children;
|
||||||
|
var parens = 0;
|
||||||
for(i = 0; i < childs.length; i+=2) {
|
for(i = 0; i < childs.length; i+=2) {
|
||||||
if(childs[i].children[3].value.trim() == "") {
|
if(childs[i].children[3].value.trim() == "") {
|
||||||
alert("Condition parameters cannot be empty!");
|
alert("Condition parameters cannot be empty!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
parens += childs[i].children[0].selectedIndex - childs[i].children[4].selectedIndex;
|
||||||
|
if(parens < 0) {
|
||||||
|
alert("There are mismatched parentheses!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(parens != 0) {
|
||||||
|
alert("There are mismatched parentheses!");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if(document.getElementById("cdd").selectedIndex == 1 && (document.getElementById("cooldown").value.trim() == "" || isNaN(document.getElementById("cooldown").value))) {
|
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!");
|
alert("Custom cooldown must not be empty and must be a number!");
|
||||||
|
@ -195,7 +259,25 @@ include("header.php");
|
||||||
<?php if(!$_GET["do"]) { ?>
|
<?php if(!$_GET["do"]) { ?>
|
||||||
<legend>Response List</legend>
|
<legend>Response List</legend>
|
||||||
<p style="margin-top: 0;"><a href="resp.php?do=new">New Response</a></p>
|
<p style="margin-top: 0;"><a href="resp.php?do=new">New Response</a></p>
|
||||||
|
<center>
|
||||||
|
<?php
|
||||||
|
$q = mysql_query("SELECT * FROM `responses`");
|
||||||
|
while($resp = mysql_fetch_object($q)) {
|
||||||
|
echo "
|
||||||
|
<table border='0' style='width:790px;border:1px solid black;margin:5px;'>
|
||||||
|
<tr>
|
||||||
|
<td style='width:50px;text-align:center;verticle-align:middle;'>
|
||||||
|
<a href='resp.php?do=edit&id=". $resp->id ."' style='verticle-align: middle;'><img src='img/edit.png' border='0' /></a>
|
||||||
|
<img src='img/delete.png' border='0' class='fakelink' onclick='confirmDeletion(". $resp->id .");' />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
". parseConditionString($resp->conditions, mysql_fetch_object(mysql_query("SELECT * FROM `resptypes` WHERE `id`=". $resp->respid))->friendlyname) ."
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</center>
|
||||||
<?php } else if($_GET["do"]=="new") { ?>
|
<?php } else if($_GET["do"]=="new") { ?>
|
||||||
<legend>Create New Response</legend>
|
<legend>Create New Response</legend>
|
||||||
<form method="post" action="" id="resp">
|
<form method="post" action="" id="resp">
|
||||||
|
@ -203,10 +285,14 @@ include("header.php");
|
||||||
If
|
If
|
||||||
<span id="ifholder">
|
<span id="ifholder">
|
||||||
<span id="if1" class="block">
|
<span id="if1" class="block">
|
||||||
<select name="if1group">
|
<select name="if1lpar">
|
||||||
<?php
|
<?php
|
||||||
for($i = 1; $i < 10; $i++)
|
for($i = 0; $i < 6; $i++) {
|
||||||
echo "<option value=\"$i\">$i</option>";
|
echo "<option value=\"$i\">";
|
||||||
|
for($j = 0; $j < $i; $j++)
|
||||||
|
echo "(";
|
||||||
|
echo "</option>";
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
<select name="if1not">
|
<select name="if1not">
|
||||||
|
@ -222,6 +308,16 @@ include("header.php");
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
<input type="text" name="if1param" />
|
<input type="text" name="if1param" />
|
||||||
|
<select name="if1rpar">
|
||||||
|
<?php
|
||||||
|
for($i = 0; $i < 6; $i++) {
|
||||||
|
echo "<option value=\"$i\">";
|
||||||
|
for($j = 0; $j < $i; $j++)
|
||||||
|
echo ")";
|
||||||
|
echo "</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
<img src='img/arrow_up.png' class='fakelink' style='vertical-align: text-bottom;' onclick='handleRowUp(1);' />
|
<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/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);' />
|
||||||
|
@ -276,8 +372,147 @@ include("header.php");
|
||||||
<input type="button" value="Cancel" onclick="window.location.href = 'resp.php';" />
|
<input type="button" value="Cancel" onclick="window.location.href = 'resp.php';" />
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
<?php } else if($_GET["do"]=="edit") { ?>
|
<?php } else if($_GET["do"]=="edit") {
|
||||||
|
$response = mysql_fetch_object(mysql_query("SELECT * FROM `responses` WHERE `id`=".$_GET['id']));
|
||||||
|
?>
|
||||||
<legend>Edit Response</legend>
|
<legend>Edit Response</legend>
|
||||||
|
<form method="post" action="" id="resp">
|
||||||
|
<p>
|
||||||
|
If
|
||||||
|
<span id="ifholder">
|
||||||
|
<?php
|
||||||
|
$conds = mysql_fetch_object(mysql_query("SELECT * FROM `responses` WHERE `id`=". $_GET['id']))->conditions;
|
||||||
|
$conds = explode(";",$conds);
|
||||||
|
$conds = array_slice($conds, 0, count($conds)-1);
|
||||||
|
$on = 1;
|
||||||
|
foreach($conds as $cond) {
|
||||||
|
$tk = explode(",",$cond);
|
||||||
|
if(count($tk) > 3) { ?>
|
||||||
|
<span id="if<?php echo $on; ?>" class="block">
|
||||||
|
<select name="if<?php echo $on; ?>lpar">
|
||||||
|
<?php
|
||||||
|
for($i = 0; $i < 6; $i++) {
|
||||||
|
echo "<option value=\"$i\"";
|
||||||
|
if($i==intval($tk[0]))
|
||||||
|
echo " selected='selected'";
|
||||||
|
echo ">";
|
||||||
|
for($j = 0; $j < $i; $j++)
|
||||||
|
echo "(";
|
||||||
|
echo "</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
<select name="if<?php echo $on; ?>not">
|
||||||
|
<option value="0"></option>
|
||||||
|
<option value="1"<?php if(intval($tk[1])==1) { ?> selected="selected"<?php } ?>>not</option>
|
||||||
|
</select>
|
||||||
|
<select name="if<?php echo $on; ?>cond">
|
||||||
|
<?php
|
||||||
|
$q = mysql_query("SELECT * FROM `conditions`");
|
||||||
|
while($cond = mysql_fetch_object($q)) {
|
||||||
|
echo "<option value='". $cond->id ."'";
|
||||||
|
if($cond->id == intval($tk[2]))
|
||||||
|
echo " selected='selected'";
|
||||||
|
echo ">". $cond->friendlyname ."</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
<input type="text" name="if<?php echo $on; ?>param" value="<?php echo escapeDoubleQuotes($tk[3]); ?>" />
|
||||||
|
<select name="if<?php echo $on; ?>rpar">
|
||||||
|
<?php
|
||||||
|
for($i = 0; $i < 6; $i++) {
|
||||||
|
echo "<option value=\"$i\"";
|
||||||
|
if($i==intval($tk[4]))
|
||||||
|
echo " selected='selected'";
|
||||||
|
echo ">";
|
||||||
|
for($j = 0; $j < $i; $j++)
|
||||||
|
echo ")";
|
||||||
|
echo "</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
<img src='img/arrow_up.png' class='fakelink' style='vertical-align: text-bottom;' onclick='handleRowUp(<?php echo $on; ?>);' />
|
||||||
|
<img src='img/arrow_down.png' class='fakelink' style='vertical-align: text-bottom;' onclick='handleRowDown(<?php echo $on; ?>);' />
|
||||||
|
<img src='img/delete.png' class='fakelink' style='vertical-align: text-bottom;' onclick='handleRowDelete(<?php echo $on; ?>);' />
|
||||||
|
</span>
|
||||||
|
<?php for($i = 0; $i < intval($tk[0]); $i++)
|
||||||
|
$ret .= "(";
|
||||||
|
if($tk[1] == "1")
|
||||||
|
$ret .= "not ";
|
||||||
|
$ret .= $condtypes[intval($tk[2])] ." ". $tk[3];
|
||||||
|
for($i = 0; $i < intval($tk[4]); $i++)
|
||||||
|
$ret .= ")";
|
||||||
|
$ret .= " ";
|
||||||
|
$i++;
|
||||||
|
} else { ?>
|
||||||
|
<span id="op<?php echo $i; ?>">
|
||||||
|
<select name='op<?php echo $i; ?>'>
|
||||||
|
<option value='0'>and</option>
|
||||||
|
<option value='1'<?php if(intval($tk[0]==1)) { ?> selected="selected" <?php } ?>>or</option>
|
||||||
|
</select>
|
||||||
|
</span>
|
||||||
|
<?php }
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</span>
|
||||||
|
<span class="block">
|
||||||
|
<a href="javascript:addCondition();">Add Condition</a>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
then
|
||||||
|
<select name="resptype" id="resptype" onchange="handleRespChange();">
|
||||||
|
<?php
|
||||||
|
$q = mysql_query("SELECT * FROM `resptypes`");
|
||||||
|
$descarr = array();
|
||||||
|
for($i = 0;;$i++) {
|
||||||
|
$type = mysql_fetch_object($q);
|
||||||
|
if(!$type) break;
|
||||||
|
echo "<option value='". $type->id ."'";
|
||||||
|
if($type->id==$response->respid)
|
||||||
|
echo " selected='selected'";
|
||||||
|
echo ">". $type->friendlyname ."</option>";
|
||||||
|
$descarr[$i] = $type->description;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
<?php
|
||||||
|
$i = 0;
|
||||||
|
foreach($descarr as $desc) {
|
||||||
|
echo "<p style='display:none;' id='$i'>". $desc ."</p>";
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<span class="block" id="respDesc">
|
||||||
|
<?php
|
||||||
|
echo $d = mysql_fetch_object(mysql_query("SELECT * FROM `resptypes` WHERE `id`=". $response->respid))->description;
|
||||||
|
?>
|
||||||
|
</span>
|
||||||
|
<span class="block">Parameters:
|
||||||
|
<center>
|
||||||
|
<textarea name="parameters" rows="8" style="width:95%;"><?php echo $response->parameters; ?></textarea>
|
||||||
|
</center></span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Cooldown:
|
||||||
|
<select name="cdd" id="cdd" onchange="coolChange();">
|
||||||
|
<option value="0">Default</option>
|
||||||
|
<option value="1"<?php if($response->cooldown != -1) { ?> selected="selected"<?php } ?>>Custom</option>
|
||||||
|
</select>
|
||||||
|
<input type="textbox" name="cooldown" id="cooldown" size="6" value="<?php if($response->cooldown == -1) echo $config->cooldown; else echo $response->cooldown; ?>"<?php if($response->cooldown == -1) { ?> disabled="disabled"<?php } ?> /> seconds
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<input type="button" name="editResponse" value="Edit Response" onclick="evaluateCondition();" />
|
||||||
|
<input type="hidden" name="editId" value="<?php echo $_GET['id']; ?>" />
|
||||||
|
|
||||||
|
<input type="button" value="Cancel" onclick="window.location.href = 'resp.php';" />
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
<script type="text/javascript">
|
||||||
|
redrawList();
|
||||||
|
</script>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</center>
|
</center>
|
||||||
|
|
Loading…
Reference in a new issue