<?PHP
$DB->Connect();
$DB->EscapeHash($_GET);
$trigger = $DB->Row("SELECT * FROM topsites_Triggers WHERE Unique_ID='{$_GET['ID']}'");
$operators = array("+" => "Add",
"-" => "Subtract",
"=" => "Assign");
$fields = array("Current_In" => "Hits In",
"Current_Out" => "Hits Out",
"Total_In" => "Total Hits In",
"Total_Out" => "Total Hits Out",
"Current_Prod" => "Productivity",
"Total_Prod" => "Total Productivity");
#"Num_Ratings" => "Number of Ratings",
#"Rating_Total" => "Rating Total");
$types = array("PreRerank" => "Before a Rerank",
"PostRerank" => "After a Rerank",
"PreReset" => "Before a Reset",
"PostReset" => "After a Reset",
"PreTotalReset" => "Before a Total Reset",
"PostTotalReset" => "After a Total Reset");
#"PreRatingReset" => "Before a Rating Reset",
#"PostRatingReset" => "After a Rating Reset");
list($field, $operation) = explode('=', $trigger['Action']);
$operator = '=';
$amount = $operation;
$to = 'to';
if( preg_match("/$operand([\-+])(.*)/", $operation, $matches) )
{
$operator = $matches[1];
$amount = $matches[2];
}
if( $operator == '-' )
{
$to = 'from';
}
?>
<script type="text/javascript">
function changeTo(operator)
{
var to = document.getElementById('to');
if( operator.selectedIndex == 1 )
{
to.innerHTML = 'from';
}
else
{
to.innerHTML = 'to';
}
}
function checkForm(form)
{
if( !form.Operand.value || !form.Username.value )
{
alert('All fields must be filled in');
return false;
}
}
</script>
<form name="form" action="newwin.php?page=edittrigger" method="post" onSubmit="return checkForm(this);">
<table>
<tr>
<td>
Edit a Trigger
</td>
</tr>
<tr>
<td>
<b>Type</b>
</td>
<td>
<select name="Type">
<?PHP
foreach($types as $key => $value)
{
echo "<option value=\"$key\"" .
($key == $trigger['Type'] ? ' selected' : '') .
">$value</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td>
<b>Account</b>
</td>
<td>
<input type="text" name="Username" size="20" value="<?PHP echo $trigger['Username']; ?>">
</td>
</tr>
<tr>
<td>
<b>Action</b>
</td>
<td>
<select name="Operator" onChange="changeTo(this)">
<?PHP
foreach($operators as $key => $value)
{
echo "<option value=\"$key\"" .
($key == $operator ? ' selected' : '') .
">$value</option>\n";
}
?>
</select>
<input type="text" name="Operand" size="10" value="<?PHP echo $amount; ?>">
<b id="to"><?PHP echo $to; ?></b>
<select name="Field">
<?PHP
foreach($fields as $key => $value)
{
echo "<option value=\"$key\"" .
($key == $field ? ' selected' : '') .
">$value</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Update Trigger">
</td>
</tr>
</table>
<input type="hidden" name="Run" value="UpdateTrigger">
<input type="hidden" name="ID" value="<?PHP echo $trigger['Unique_ID']; ?>">
</form>