id] = $cond->friendlyname; } $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 .= "". $condtypes[intval($tk[2])] ." ". $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 ". strtolower($resptype) .""; return $ret; } if($_GET['del']) { mysql_query("DELETE FROM `responses` WHERE `id`=".$_GET['del']); header("Location: resp.php"); } if($_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] .";"; } 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']) .", `independent`=". (($_POST['indie'])?"1":"0") ." WHERE `id`=". $_POST['editId']) or die(mysql_error()); mysql_query("UPDATE `updater` SET `responses`=1 WHERE `id`=1"); 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] .";"; } mysql_query("INSERT INTO `responses` (`conditions`,`respid`,`parameters`,`cooldown`,`independent`) VALUES ('". mysql_real_escape_string($c) ."',". $_POST['resptype'] .",'". mysql_real_escape_string($_POST['parameters']) ."',". (($_POST['ccd']==0)?-1:$_POST['cooldown']) .",". (($_POST['indie'])?"1":"0") .")") or die(mysql_error()); mysql_query("UPDATE `updater` SET `responses`=1 WHERE `id`=1"); header("Location: resp.php"); } include("header.php"); ?>