-ADD_DESCR("admin", __FILE__);
-
-if (empty($_GET['do'])) unset($_GET['do']);
-
-if (((empty($_POST['t_wait'])) || (empty($_POST['payment']))) && (!empty($_GET['do'])) && ($_GET['do'] == "add")) {
- unset($_POST['ok']);
-}
-
-if (isset($_POST['ok'])) {
- $SQL = array();
- switch ($_GET['do']) {
- case "add":
- $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_payments (time, payment, mail_title, price) VALUES ('".$_POST['t_wait']."','".$_POST['payment']."','".$_POST['title']."','".$_POST['price']."')";
- $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_payments WHERE time='%s' LIMIT 1",
- array($_POST['t_wait']), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
- // Free memory
- $SQLs[0] = "";
- SQL_FREERESULT($result);
- }
- break;
-
- case "edit":
- foreach ($_POST['time'] as $id => $value) {
- $SQLs[] = "UPDATE "._MYSQL_PREFIX."_payments SET time='".$value."', payment='".$_POST['pay'][$id]."', price='".$_POST['price'][$id]."', mail_title='".$_POST['title'][$id]."' WHERE id='".$id."' LIMIT 1";
- }
- break;
-
- case "del":
- foreach ($_POST['id'] as $id => $value) {
- $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_payments WHERE id='".$id."' LIMIT 1";
- }
- break;
- }
+addYouAreHereLink('admin', __FILE__);
+
+if (((!isPostRequestParameterSet('t_wait')) || (!isPostRequestParameterSet('payment'))) && (isGetRequestParameterSet('do')) && (getRequestParameter('do') == 'add')) {
+ unsetPostRequestParameter('ok');
+} // END - if
+
+if (isFormSent()) {
+ switch (getRequestParameter('do')) {
+ case 'add':
+ addSql("INSERT INTO `{?_MYSQL_PREFIX?}_payments` (`time`,`payment`,`mail_title`,`price`) VALUES ('".postRequestParameter('t_wait')."','".postRequestParameter('payment')."','".postRequestParameter('title')."','".postRequestParameter('price')."')");
+ if (countSumTotalData(postRequestParameter('t_wait'), 'payments', 'id', 'time', true) == 1) {
+ // Re-init the array here
+ initSqls();
+ } // END - if
+ break;
+
+ case 'edit':
+ foreach (postRequestParameter('time') as $id => $value) {
+ addSql("UPDATE `{?_MYSQL_PREFIX?}_payments` SET `time`='" . $value . "', `payment`='".postRequestParameter('payment', $id)."', price='".postRequestParameter('price', $id)."', mail_title='".postRequestParameter('mail_title', $id)."' WHERE `id`='".$id."' LIMIT 1");
+ } // END - foreach
+ break;
+
+ case 'delete':
+ foreach (postRequestParameter('id') as $id => $value) {
+ addSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=" . bigintval($id) . " LIMIT 1");
+ } // END - foreach
+ break;
+ } // END - switch