-ADD_DESCR("admin", __FILE__);
-
-if (((!REQUEST_ISSET_POST(('t_wait'))) || (!REQUEST_ISSET_POST(('payment')))) && (REQUEST_ISSET_GET(('do'))) && (REQUEST_GET('do') == "add")) {
- REQUEST_UNSET_POST('ok');
-}
-
-if (IS_FORM_SENT()) {
- switch (REQUEST_GET('do')) {
- case "add":
- ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_payments` (time, payment, mail_title, price) VALUES ('".REQUEST_POST('t_wait')."','".REQUEST_POST('payment')."','".REQUEST_POST('title')."','".REQUEST_POST('price')."')");
- $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_payments` WHERE time='%s' LIMIT 1",
- array(REQUEST_POST('t_wait')), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
- // Re-init the array here
- INIT_SQLS();
-
- // Free memory
- SQL_FREERESULT($result);
- }
- break;
-
- case "edit":
- foreach (REQUEST_POST('time') as $id => $value) {
- ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_payments` SET time='".$value."', payment='".REQUEST_POST('pay', $id)."', price='".REQUEST_POST('price', $id)."', mail_title='".REQUEST_POST('title', $id)."' WHERE id='".$id."' LIMIT 1");
- }
- break;
-
- case "del":
- foreach (REQUEST_POST('id') as $id => $value) {
- ADD_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_payments` WHERE id='".$id."' LIMIT 1");
- }
- break;
- }
+addYouAreHereLink('admin', __FILE__);
+
+if (((!isPostRequestElementSet('t_wait')) || (!isPostRequestElementSet('payment'))) && (isGetRequestElementSet('do')) && (getRequestElement('do') == 'add')) {
+ unsetPostRequestElement('ok');
+} // END - if
+
+if (isFormSent()) {
+ switch (getRequestElement('do')) {
+ case 'add':
+ addSql("INSERT INTO `{?_MYSQL_PREFIX?}_payments` (`time`,`payment`,`mail_title`,`price`) VALUES ('".postRequestElement('t_wait')."','".postRequestElement('payment')."','".postRequestElement('title')."','".postRequestElement('price')."')");
+ if (countSumTotalData(postRequestElement('t_wait'), 'payments', 'id', 'time', true) == 1) {
+ // Re-init the array here
+ initSqls();
+ } // END - if
+ break;
+
+ case 'edit':
+ foreach (postRequestElement('time') as $id => $value) {
+ addSql("UPDATE `{?_MYSQL_PREFIX?}_payments` SET `time`='" . $value . "',`payment`='".postRequestElement('payment', $id)."', price='".postRequestElement('price', $id)."', mail_title='".postRequestElement('mail_title', $id)."' WHERE `id`='".$id."' LIMIT 1");
+ } // END - foreach
+ break;
+
+ case 'delete':
+ foreach (postRequestElement('id') as $id => $value) {
+ addSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=" . bigintval($id) . " LIMIT 1");
+ } // END - foreach
+ break;
+ } // END - switch