2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 08/31/2003 *
4 * =================== Last change: 11/23/2004 *
6 * -------------------------------------------------------------------- *
7 * File : admin-inc.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Administrative related functions *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Fuer die Administration benoetigte Funktionen *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://www.mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
43 // Register an administrator account
44 function addAdminAccount ($adminLogin, $passHash, $adminEmail) {
45 // Login does already exist
49 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
50 array($adminLogin), __FUNCTION__, __LINE__);
52 // Is the entry there?
53 if (SQL_HASZERONUMS($result)) {
54 // Ok, let's create the admin login
55 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`, `password`, `email`) VALUES ('%s', '%s', '%s')",
60 ), __FUNCTION__, __LINE__);
67 SQL_FREERESULT($result);
73 // This function will be executed when the admin is not logged in and has submitted his login data
74 function ifAdminLoginDataIsValid ($adminLogin, $adminPassword) {
75 // First of all, no admin login is found, so the admin hash is null
79 // Get admin id from login
80 $adminId = getAdminId($adminLogin);
82 // Continue only with found admin ids
84 // Then we need to lookup the login name by getting the admin hash
85 $adminHash = getAdminHash($adminId);
87 // If this is fine, we can continue
88 if ($adminHash != '-1') {
89 // Get admin id and set it as current
90 setCurrentAdminId($adminId);
92 // Now, we need to encode the password in the same way the one is encoded in database
93 $testHash = generateHash($adminPassword, $adminHash);
95 // If they both match, the login data is valid
96 if ($testHash == $adminHash) {
106 // Prepare data array
109 'login' => $adminLogin,
110 'plain_pass' => $adminPassword,
111 'pass_hash' => $adminHash
114 // Run a special filter
115 runFilterChain('do_admin_login_' . $ret, $data);
121 // Only be executed on cookie checking
122 function ifAdminCookiesAreValid ($adminLogin, $passHash) {
123 // First of all, no admin login is found
126 // Then we need to lookup the login name by getting the admin hash
127 $adminHash = getAdminHash($adminLogin);
129 // If this is fine, we can continue
130 if ($adminHash != '-1') {
131 // Now, we need to encode the password in the same way the one is encoded in database
132 $testHash = encodeHashForCookie($adminHash);
133 //* DEBUG: */ debugOutput('adminLogin=' . $adminLogin . ',passHash='.$passHash.',adminHash='.$adminHash.',testHash='.$testHash);
135 // If they both match, the login data is valid
136 if ($testHash == $passHash) {
146 //* DEBUG: */ debugOutput('ret='.$ret);
150 // Do an admin action
151 function doAdminAction () {
155 //* DEBUG: */ debugOutput(__LINE__.'*'.$what.'/'.getModule().'/'.getAction().'/'.getWhat().'*');
157 // Remove any spaces from variable
159 // Default admin action is the overview page
163 $what = secureString($what);
167 $action = getActionFromModuleWhat(getModule(), $what);
169 // Load welcome template
170 if (isExtensionActive('admins')) {
171 // @TODO This and the next getCurrentAdminId() call might be moved into the templates?
172 $content['welcome'] = loadTemplate('admin_welcome_admins', true, getCurrentAdminId());
174 $content['welcome'] = loadTemplate('admin_welcome', true, getCurrentAdminId());
177 // Load header, footer, render menu
178 $content['header'] = loadTemplate('admin_header' , true, $content);
179 $content['footer'] = loadTemplate('admin_footer' , true, $content);
180 $content['menu'] = addAdminMenu($action, $what, true);
183 loadTemplate('admin_main_header', false, $content);
185 // Check if action/what pair is valid
186 $result_action = SQL_QUERY_ESC("SELECT
189 `{?_MYSQL_PREFIX?}_admin_menu`
194 `what`='%s' AND `what` != 'overview'
197 `what`='' OR `what` IS NULL
208 ), __FUNCTION__, __LINE__);
210 // Do we have an entry?
211 if (SQL_NUMROWS($result_action) == 1) {
212 // Is valid but does the inlcude file exists?
213 $inc = sprintf("inc/modules/admin/action-%s.php", $action);
214 if ((isIncludeReadable($inc)) && (isMenuActionValid('admin', $action, $what)) && ($GLOBALS['acl_allow'] === true)) {
215 // Ok, we finally load the admin action module
217 } elseif ($GLOBALS['acl_allow'] === false) {
219 loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACCESS_DENIED', $what));
221 // Include file not found :-(
222 loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACTION_404', $action));
225 // Invalid action/what pair found
226 loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACTION_INVALID', $action . '/' . $what));
230 SQL_FREERESULT($result_action);
233 loadTemplate('admin_main_footer', false, $content);
236 // Checks wether current admin is allowed to access given action/what combination
237 // (only one is allowed to be null!)
238 function isAdminAllowedAccessMenu ($action, $what = null) {
240 if (!isset($GLOBALS[__FUNCTION__][$action][$what])) {
241 // ACL is always 'allow' when no ext-admins is installed
242 // @TODO This can be rewritten into a filter
243 $GLOBALS[__FUNCTION__][$action][$what] = ((!isExtensionInstalledAndNewer('admins', '0.2.0')) || (adminsCheckAdminAcl($action, $what)));
246 // Return the cached value
247 return $GLOBALS[__FUNCTION__][$action][$what];
250 // Adds an admin menu
251 function addAdminMenu ($action, $what, $return = false) {
257 $GLOBALS['menu']['description'] = array();
258 $GLOBALS['menu']['title'] = array();
261 $result_main = SQL_QUERY("SELECT
262 `action`, `title`, `descr`
264 `{?_MYSQL_PREFIX?}_admin_menu`
266 (`what`='' OR `what` IS NULL)
269 `id` DESC", __FUNCTION__, __LINE__);
271 // Do we have entries?
272 if (!SQL_HASZERONUMS($result_main)) {
273 $OUT .= '<ul class="admin_menu_main">';
274 // @TODO Rewrite this to $content = SQL_FETCHARRAY()
275 while (list($menu, $title, $descr) = SQL_FETCHROW($result_main)) {
277 $inc = sprintf("inc/modules/admin/action-%s.php", $menu);
279 // Is the file readable?
280 $readable = isIncludeReadable($inc);
282 // Is the current admin allowed to access this 'action' menu?
283 if (isAdminAllowedAccessMenu($menu)) {
284 if ($SUB === false) {
285 // Insert compiled menu title and description
286 $GLOBALS['menu']['title'][$menu] = $title;
287 $GLOBALS['menu']['description'][$menu] = $descr;
289 $OUT .= '<li class="admin_menu">
290 <div class="nobr"><strong>·</strong> ';
292 if ($readable === true) {
293 if (($menu == $action) && (empty($what))) {
296 $OUT .= '[<a href="{%url=modules.php?module=admin&action=' . $menu . '%}">';
299 $OUT .= '<em style="cursor:help" class="notice" title="{%message,ADMIN_MENU_ACTION_404=' . $menu . '%}">';
304 if ($readable === true) {
305 if (($menu == $action) && (empty($what))) {
317 // Check for menu entries
318 $result_what = SQL_QUERY_ESC("SELECT
319 `what`, `title`, `descr`
321 `{?_MYSQL_PREFIX?}_admin_menu`
329 array($menu), __FUNCTION__, __LINE__);
331 // Remember the count for later checks
332 setAdminMenuHasEntries($menu, ((!SQL_HASZERONUMS($result_what)) && ($action == $menu)));
334 // Do we have entries?
335 if ((ifAdminMenuHasEntries($menu)) && (!SQL_HASZERONUMS($result_what))) {
336 $GLOBALS['menu']['description'] = array();
337 $GLOBALS['menu']['title'] = array(); $SUB = true;
338 $OUT .= '<li class="admin_menu_sub"><ul class="admin_menu_sub">';
339 // @TODO Rewrite this to $content = SQL_FETCHARRAY()
340 while (list($what_sub, $title_what, $desc_what) = SQL_FETCHROW($result_what)) {
342 $inc = sprintf("inc/modules/admin/what-%s.php", $what_sub);
344 // Is the file readable?
345 $readable = isIncludeReadable($inc);
347 // Is the current admin allowed to access this 'what' menu?
348 if (isAdminAllowedAccessMenu(null, $what_sub)) {
349 // Insert compiled title and description
350 $GLOBALS['menu']['title'][$what_sub] = $title_what;
351 $GLOBALS['menu']['description'][$what_sub] = $desc_what;
352 $OUT .= '<li class="admin_menu">
353 <div class="nobr"><strong>--></strong> ';
354 if ($readable === true) {
355 if ($what == $what_sub) {
358 $OUT .= '[<a href="{%url=modules.php?module=admin&what=' . $what_sub . '%}">';
361 $OUT .= '<em style="cursor:help" class="notice" title="{%message,ADMIN_MENU_WHAT_404=' . $what_sub . '%}">';
366 if ($readable === true) {
367 if ($what == $what_sub) {
381 SQL_FREERESULT($result_what);
389 SQL_FREERESULT($result_main);
393 // Is there a cache instance again?
394 // Return or output content?
395 if ($return === true) {
402 // Create member selection box
403 function addMemberSelectionBox ($def = 0, $add_all = false, $return = false, $none = false, $field = 'userid') {
404 // Output selection form with all confirmed user accounts listed
405 $result = SQL_QUERY("SELECT `userid`, `surname`, `family` FROM `{?_MYSQL_PREFIX?}_user_data` ORDER BY `userid` ASC", __FUNCTION__, __LINE__);
410 // USe this only for adding points (e.g. adding refs really makes no sence ;-) )
411 if ($add_all === true) $OUT = ' <option value="all">{--ALL_MEMBERS--}</option>';
412 elseif ($none === true) $OUT = ' <option value="0">{--SELECT_NONE--}</option>';
414 while ($content = SQL_FETCHARRAY($result)) {
415 $OUT .= '<option value="' . bigintval($content['userid']) . '"';
416 if ($def == $content['userid']) $OUT .= ' selected="selected"';
417 $OUT .= '>' . $content['surname'] . ' ' . $content['family'] . ' (' . bigintval($content['userid']) . ')</option>';
421 SQL_FREERESULT($result);
423 if ($return === false) {
424 // Remeber options in constant
425 $content['form_selection'] = $OUT;
426 $content['what'] = getWhat();
429 loadTemplate('admin_form_selection_box', false, $content);
431 // Return content in selection frame
432 return '<select class="form_select" name="' . handleFieldWithBraces($field) . '" size="1">' . $OUT . '</select>';
436 // Create a menu selection box for given menu system
437 // @TODO Try to rewrite this to adminAddMenuSelectionBox()
439 function adminMenuSelectionBox_DEPRECATED ($mode, $default = '', $defid = '') {
440 $what = "`what` != ''";
441 if ($mode == 'action') $what = "(`what`='' OR `what` IS NULL) AND `action` !='login'";
443 $result = SQL_QUERY_ESC("SELECT `%s` AS `menu`, `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$what." ORDER BY `sort` ASC",
444 array($mode), __FUNCTION__, __LINE__);
445 if (!SQL_HASZERONUMS($result)) {
446 // Load menu as selection
447 $OUT = '<select name="' . $mode . '_menu';
448 if ((!empty($defid)) || ($defid == '0')) $OUT .= '[' . $defid . ']';
449 $OUT .= '" size="1" class="form_select">
450 <option value="">{--SELECT_NONE--}</option>';
452 while ($content = SQL_FETCHARRAY($result)) {
453 $OUT .= '<option value="' . $content['menu'] . '"';
454 if ((!empty($default)) && ($default == $content['menu'])) $OUT .= ' selected="selected"';
455 $OUT .= '>' . $content['title'] . '</option>';
459 SQL_FREERESULT($result);
461 // Add closing select-tag
465 $OUT = '{--ADMIN_PROBLEM_NO_MENU--}';
472 // Wrapper for $_POST and adminSaveSettings
473 function adminSaveSettingsFromPostData ($tableName = '_config', $whereStatement = '`config`=0', $translateComma = array(), $alwaysAdd = false, $displayMessage = true) {
475 $postData = postRequestArray();
477 // Call the lower function
478 adminSaveSettings($postData, $tableName, $whereStatement, $translateComma, $alwaysAdd, $displayMessage);
481 // Save settings to the database
482 function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement = '`config`=0', $translateComma = array(), $alwaysAdd = false, $displayMessage = true) {
483 // Prepare all arrays, variables
484 $tableData = array();
487 // Now, walk through all entries and prepare them for saving
488 foreach ($postData as $id => $val) {
489 // Process only formular field but not submit buttons ;)
491 // Do not save the ok value
492 convertSelectionsToEpocheTime($postData, $tableData, $id, $skip);
494 // Shall we process this id? It muss not be empty, of course
495 if (($skip === false) && (!empty($id)) && ((!isset($GLOBALS['skip_config'][$id]))) || ($tableName != '_config')) {
496 // Translate the value? (comma to dot!)
497 if ((is_array($translateComma)) && (in_array($id, $translateComma))) {
498 // Then do it here... :)
499 $val = convertCommaToDot($val);
502 // Shall we add numbers or strings?
503 $test = (float) $val;
504 if ('' . $val . '' == '' . $test . '') {
506 $tableData[] = sprintf("`%s`=%s", $id, $test);
507 } elseif (is_null($val)) {
509 $tableData[] = sprintf("`%s`=NULL", $id);
512 $tableData[] = sprintf("`%s`='%s'", $id, trim($val));
515 // Do not add a config entry twice
516 $GLOBALS['skip_config'][$id] = true;
518 // Update current configuration
519 setConfigEntry($id, $val);
524 // Check if entry does exist
526 if ($alwaysAdd === false) {
527 if (!empty($whereStatement)) {
528 $result = SQL_QUERY("SELECT * FROM `{?_MYSQL_PREFIX?}" . $tableName . "` WHERE " . $whereStatement . " LIMIT 1", __FUNCTION__, __LINE__);
530 $result = SQL_QUERY("SELECT * FROM `{?_MYSQL_PREFIX?}" . $tableName . "` LIMIT 1", __FUNCTION__, __LINE__);
534 if (SQL_NUMROWS($result) == 1) {
535 // "Implode" all data to single string
536 $updatedData = implode(', ', $tableData);
538 // Generate SQL string
539 $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}%s` SET %s WHERE %s LIMIT 1",
545 // Add Line (does only work with auto_increment!
546 $keys = array(); $values = array();
547 foreach ($tableData as $entry) {
549 $line = explode('=', $entry);
551 $values[] = $line[1];
554 // Add both in one line
555 $keys = implode('`, `', $keys);
556 $values = implode(', ', $values);
558 // Generate SQL string
559 $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}%s` (%s) VALUES (%s)",
567 SQL_FREERESULT($result);
569 // Simply run generated SQL string
570 SQL_QUERY($sql, __FUNCTION__, __LINE__);
572 // Remember affected rows
573 $affected = SQL_AFFECTEDROWS();
576 rebuildCache('config', 'config');
578 // Settings saved, so display message?
579 if ($displayMessage === true) displayMessage('{--SETTINGS_SAVED--}');
581 // Return affected rows
585 // Generate a selection box
586 function adminAddMenuSelectionBox ($menu, $type, $name, $default = '') {
587 // Open the requested menu directory
588 $menuArray = getArrayFromDirectory(sprintf("inc/modules/%s/", $menu), $type . '-', false, false);
590 // Init the selection box
591 $OUT = '<select name="' . $name . '" class="form_select" size="1"><option value="">{--ADMIN_IS_TOP_MENU--}</option>';
593 // Walk through all files
594 foreach ($menuArray as $file) {
595 // Is this a PHP script?
596 if ((!isDirectory($file)) && (strpos($file, '' . $type . '-') > -1) && (strpos($file, '.php') > 0)) {
597 // Then test if the file is readable
598 $test = sprintf("inc/modules/%s/%s", $menu, $file);
600 // Is the file there?
601 if (isIncludeReadable($test)) {
602 // Extract the value for what=xxx
603 $part = substr($file, (strlen($type) + 1));
604 $part = substr($part, 0, -4);
606 // Is that part different from the overview?
607 if ($part != 'overview') {
608 $OUT .= '<option value="' . $part . '"';
609 if ($part == $default) $OUT .= ' selected="selected"';
610 $OUT .= '>' . $part . '</option>';
616 // Close selection box
623 // Creates a user-profile link for the admin. This function can also be used for many other purposes
624 function generateUserProfileLink ($userid, $title = '', $what = 'list_user') {
625 if (($title == '') && (isValidUserId($userid))) {
626 // Set userid as title
628 } elseif ($userid == 0) {
629 // User id zero is invalid
630 return '<strong>' . $userid . '</strong>';
633 if (($title == '0') && ($what == 'list_refs')) {
634 // Return title again
636 } elseif (isExtensionActive('nickname')) {
638 $nick = getNickname($userid);
640 // Is it not empty, use it as title else the userid
641 if (!empty($nick)) $title = $nick . '(' . $userid . ')'; else $title = $userid;
645 return '[<a href="{%url=modules.php?module=admin&what=' . $what . '&userid=' . $userid . '%}" title="{--ADMIN_USER_PROFILE_TITLE--}">' . $title . '</a>]';
648 // Check "logical-area-mode"
649 function adminGetMenuMode () {
650 // Set the default menu mode as the mode for all admins
653 // If sql_patches is up-to-date enough, use the configuration
654 if (isExtensionInstalledAndNewer('sql_patches', '0.3.2')) {
655 $mode = getAdminMenu();
662 $adminId = getCurrentAdminId();
664 // Check individual settings of current admin
665 if (isset($GLOBALS['cache_array']['admin']['la_mode'][$adminId])) {
667 $adminMode = $GLOBALS['cache_array']['admin']['la_mode'][$adminId];
668 incrementStatsEntry('cache_hits');
669 } elseif (isExtensionInstalledAndNewer('admins', '0.6.7')) {
670 // Load from database when version of 'admins' is enough
671 $result = SQL_QUERY_ESC("SELECT `la_mode` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
672 array($adminId), __FUNCTION__, __LINE__);
674 // Do we have an entry?
675 if (SQL_NUMROWS($result) == 1) {
677 list($adminMode) = SQL_FETCHROW($result);
681 SQL_FREERESULT($result);
684 // Check what the admin wants and set it when it's not the default mode
685 if ($adminMode != 'global') {
689 // Return admin-menu's mode
693 // Change activation status
694 function adminChangeActivationStatus ($IDs, $table, $row, $idRow = 'id') {
695 $count = '0'; $newStatus = 'Y';
696 if ((is_array($IDs)) && (count($IDs) > 0)) {
697 // "Walk" all through and count them
698 foreach ($IDs as $id => $selected) {
699 // Secure the id number
700 $id = bigintval($id);
702 // Should always be set... ;-)
703 if (!empty($selected)) {
704 // Determine new status
705 $result = SQL_QUERY_ESC("SELECT %s FROM `{?_MYSQL_PREFIX?}_%s` WHERE %s=%s LIMIT 1",
706 array($row, $table, $idRow, $id), __FUNCTION__, __LINE__);
709 if (SQL_NUMROWS($result) == 1) {
711 list($currStatus) = SQL_FETCHROW($result);
713 // And switch it N<->Y
714 if ($currStatus == 'Y') $newStatus = 'N'; else $newStatus = 'Y';
716 // Change this status
717 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s` SET %s='%s' WHERE %s=%s LIMIT 1",
718 array($table, $row, $newStatus, $idRow, $id), __FUNCTION__, __LINE__);
720 // Count up affected rows
721 $count += SQL_AFFECTEDROWS();
725 SQL_FREERESULT($result);
730 displayMessage(sprintf(getMessage('ADMIN_STATUS_CHANGED'), $count, count($IDs)));
733 displayMessage('{--ADMIN_NOTHING_SELECTED_CHANGE--}');
737 // Send mails for del/edit/lock build modes
738 function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '', $userid = 'userid') {
739 // Default subject is the subject part
740 $subject = $subjectPart;
742 // Is the subject part not set?
743 if (empty($subjectPart)) {
744 // Then use it from the mode
745 $subject = strtoupper($mode);
748 // Is the raw userid set?
749 if (postRequestParameter($userid, $id) > 0) {
750 // Load email template
751 if (!empty($subjectPart)) {
752 $mail = loadEmailTemplate('member_' . $mode . '_' . strtolower($subjectPart) . '_' . $table, $content);
754 $mail = loadEmailTemplate('member_' . $mode . '_' . $table, $content);
758 sendEmail(postRequestParameter($userid, $id), strtoupper('{--MEMBER_' . $subject . '_' . $table . '_SUBJECT--}'), $mail);
762 $subject = strtoupper('{--ADMIN_' . $subject . '_' . $table . '_SUBJECT--}');
764 // Send admin notification out
765 if (!empty($subjectPart)) {
766 sendAdminNotification($subject, 'admin_' . $mode . '_' . strtolower($subjectPart) . '_' . $table, $content, postRequestParameter($userid, $id));
768 sendAdminNotification($subject, 'admin_' . $mode . '_' . $table, $content, postRequestParameter($userid, $id));
772 // Build a special template list
773 function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $userid = 'userid') {
776 // "Walk"Â through all entries
777 foreach ($IDs as $id => $selected) {
779 $id = bigintval($id);
781 // Get result from a given column array and table name
782 $result = SQL_RESULT_FROM_ARRAY($table, $columns, $idColumn, $id, __FUNCTION__, __LINE__);
784 // Is there one entry?
785 if (SQL_NUMROWS($result) == 1) {
787 $content = SQL_FETCHARRAY($result);
790 foreach ($content as $key => $value) {
792 $idx = array_search($key, $columns, true);
794 //Â Do we have a userid?
795 if ($key == $userIdColumn) {
796 // Add it again as raw id
797 $content[$userIdColumn] = bigintval($value);
798 $content[$userIdColumn . '_raw'] = $content[$userIdColumn];
801 // If the key matches the idColumn variable, we need to temporary remember it
802 //* DEBUG: */ debugOutput('key=' . $key . ',idColumn=' . $idColumn . ',value=' . $value);
803 if ($key == $idColumn) {
804 // Found, so remember it
805 $GLOBALS['admin_list_builder_id_value'] = $value;
808 // Handle the call in external function
809 //* DEBUG: */ debugOutput('key=' . $key . ',fucntion=' . $filterFunctions[$idx] . ',value=' . $value);
810 $content[$key] = handleExtraValues($filterFunctions[$idx], $value, $extraValues[$idx]);
814 $OUT .= loadTemplate(sprintf("admin_%s_%s_row",
822 SQL_FREERESULT($result);
825 // Load master template
826 loadTemplate(sprintf("admin_%s_%s",
833 // Change status of "build" list
834 function adminBuilderStatusHandler ($mode, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray, $userid = 'userid') {
835 // All valid entries? (We hope so here!)
836 if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues)) && (count($statusArray) > 0)) {
837 // "Walk" through all entries
838 foreach ($IDs as $id => $sel) {
839 // Construct SQL query
840 $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}_%s` SET", SQL_ESCAPE($table));
842 // Load data of entry
843 $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
844 array($table, $idColumn, $id), __FUNCTION__, __LINE__);
847 $content = SQL_FETCHARRAY($result);
850 SQL_FREERESULT($result);
852 // Add all status entries (e.g. status column last_updated or so)
853 $newStatus = 'UNKNOWN';
854 $oldStatus = 'UNKNOWN';
855 $statusColumn = 'unknown';
856 foreach ($statusArray as $column => $statusInfo) {
857 // Does the entry exist?
858 if ((isset($content[$column])) && (isset($statusInfo[$content[$column]]))) {
859 // Add these entries for update
860 $sql .= sprintf(" %s='%s',", SQL_ESCAPE($column), SQL_ESCAPE($statusInfo[$content[$column]]));
863 if ($statusColumn == 'unknown') {
864 // Always (!!!) change status column first!
865 $oldStatus = $content[$column];
866 $newStatus = $statusInfo[$oldStatus];
867 $statusColumn = $column;
869 } elseif (isset($content[$column])) {
871 debug_report_bug(__FUNCTION__, __LINE__, ':UNFINISHED: id=' . $id . ',column=' . $column . '[' . gettype($statusInfo) . '] = ' . $content[$column]);
875 // Add other columns as well
876 foreach (postRequestArray() as $key => $entries) {
878 logDebugMessage(__FUNCTION__, __LINE__, 'Found entry: ' . $key);
880 // Skip id, raw userid and 'do_$mode'
881 if (!in_array($key, array($idColumn, $userid, ('do_' . $mode)))) {
882 // Are there brackets () at the end?
883 if (substr($entries[$id], -2, 2) == '()') {
884 // Direct SQL command found
885 $sql .= sprintf(" %s=%s,", SQL_ESCAPE($key), SQL_ESCAPE($entries[$id]));
888 $sql .= sprintf(" %s='%s',", SQL_ESCAPE($key), SQL_ESCAPE($entries[$id]));
891 $content[$key] = $entries[$id];
895 logDebugMessage(__FUNCTION__, __LINE__, 'Skipped: ' . $key);
899 // Finish SQL statement
900 $sql = substr($sql, 0, -1) . sprintf(" WHERE `%s`=%s AND `%s`='%s' LIMIT 1",
908 SQL_QUERY($sql, __FUNCTION__, __LINE__);
910 // Do we have an URL?
911 if (isset($content['url'])) {
912 // Then add a framekiller test as well
913 $content['frametester'] = generateFrametesterUrl($content['url']);
916 // Send "build mails" out
917 sendAdminBuildMails($mode, $table, $content, $id, $statusInfo[$content[$column]]);
922 // Delete rows by given id numbers
923 function adminDeleteEntriesConfirm ($IDs, $table, $columns = array(), $filterFunctions = array(), $extraValues = array(), $deleteNow = false, $idColumn = 'id', $userIdColumn = 'userid', $userid = 'userid') {
924 // All valid entries? (We hope so here!)
925 if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues))) {
926 // Shall we delete here or list for deletion?
927 if ($deleteNow === true) {
928 // The base SQL command:
929 $sql = "DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s` IN (%s)";
933 foreach ($IDs as $id => $sel) {
934 // Is there a userid?
935 if (isPostRequestParameterSet($userid, $id)) {
936 // Load all data from that id
937 $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
942 ), __FUNCTION__, __LINE__);
945 $content = SQL_FETCHARRAY($result);
948 SQL_FREERESULT($result);
950 // Send "build mails" out
951 sendAdminBuildMails('delete', $table, $content, $id);
955 $idList .= $id . ',';
959 SQL_QUERY_ESC($sql, array($table, $idColumn, substr($idList, 0, -1)), __FUNCTION__, __LINE__);
962 if (SQL_AFFECTEDROWS() == count($IDs)) {
964 displayMessage('{--ADMIN_ALL_ENTRIES_REMOVED--}');
966 // Some are still there :(
967 displayMessage(sprintf(getMessage('ADMIN_SOME_ENTRIES_NOT_DELETED'), SQL_AFFECTEDROWS(), count($IDs)));
970 // List for deletion confirmation
971 adminListBuilder('delete', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
976 // Edit rows by given id numbers
977 function adminEditEntriesConfirm ($IDs, $table, $columns = array(), $filterFunctions = array(), $extraValues = array(), $editNow = false, $idColumn = 'id', $userIdColumn = 'userid', $userid = 'userid') {
978 // All valid entries? (We hope so here!)
979 if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues))) {
980 // Shall we change here or list for editing?
981 if ($editNow === true) {
984 foreach ($IDs as $id => $sel) {
985 // Prepare content array (new values)
988 // Prepare SQL for this row
989 $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}_%s` SET",
992 foreach (postRequestArray() as $key => $entries) {
993 // Skip raw userid which is always invalid
994 if ($key == $userid) {
995 // Continue with next field
999 // Is entries an array?
1000 if (($key != $idColumn) && (is_array($entries)) && (isset($entries[$id]))) {
1001 // Add this entry to content
1002 $content[$key] = $entries[$id];
1004 // Send data through the filter function if found
1005 if ((isset($filterFunctions[$key])) && (isset($extraValues[$key]))) {
1006 // Filter function set!
1007 $entries[$id] = handleExtraValues($filterFunctions[$key], $entries[$id], $extraValues[$key]);
1010 // Then add this value
1011 $sql .= sprintf(" `%s`='%s',",
1013 SQL_ESCAPE($entries[$id])
1015 } elseif (($key != $idColumn) && (!is_array($entries))) {
1016 // Add normal entries as well!
1017 $content[$key] = $entries;
1020 // Do we have an URL?
1021 if ($key == 'url') {
1022 // Then add a framekiller test as well
1023 $content['frametester'] = generateFrametesterUrl($content[$key]);
1027 // Finish SQL command
1028 $sql = substr($sql, 0, -1) . " WHERE `" . $idColumn . "`=" . bigintval($id) . " LIMIT 1";
1031 SQL_QUERY($sql, __FUNCTION__, __LINE__);
1033 // Add affected rows
1034 $affected += SQL_AFFECTEDROWS();
1036 // Load all data from that id
1037 $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
1038 array($table, $idColumn, $id), __FUNCTION__, __LINE__);
1040 // Fetch the data and merge it into $content
1041 $content = merge_array($content, SQL_FETCHARRAY($result));
1044 SQL_FREERESULT($result);
1046 // Send "build mails" out
1047 sendAdminBuildMails('edit', $table, $content, $id);
1051 if ($affected == count($IDs)) {
1053 displayMessage('{--ADMIN_ALL_ENTRIES_EDITED--}');
1055 // Some are still there :(
1056 displayMessage(sprintf(getMessage('ADMIN_SOME_ENTRIES_NOT_EDITED'), $affected, count($IDs)));
1060 adminListBuilder('edit', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
1065 // Un-/lock rows by given id numbers
1066 function adminLockEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctions=array(), $extraValues=array(), $statusArray=array(), $lockNow=false, $idColumn='id', $userIdColumn='userid') {
1067 // All valid entries? (We hope so here!)
1068 if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues)) && (($lockNow === false) || (count($statusArray) == 1))) {
1069 // Shall we un-/lock here or list for locking?
1070 if ($lockNow === true) {
1072 adminBuilderStatusHandler('lock', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray);
1075 adminListBuilder('lock', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
1080 // Undelete rows by given id numbers
1081 function adminUndeleteEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctions=array(), $extraValues=array(), $statusArray=array(), $undeleteNow=false, $idColumn='id', $userIdColumn='userid') {
1082 // All valid entries? (We hope so here!)
1083 if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues)) && (($undeleteNow === false) || (count($statusArray) == 1))) {
1084 // Shall we un-/lock here or list for locking?
1085 if ($undeleteNow === true) {
1087 adminBuilderStatusHandler('undelete', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray);
1090 adminListBuilder('undelete', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
1095 // Checks proxy settins by fetching check-updates3.php from www.mxchange.org
1096 function adminTestProxySettings ($settingsArray) {
1097 // Set temporary the new settings
1098 mergeConfig($settingsArray);
1100 // Now get the test URL
1101 $content = sendGetRequest('check-updates3.php');
1103 // Is the first line with "200 OK"?
1104 $valid = (strpos($content[0], '200 OK') !== false);
1110 // Sends out a link to the given email adress so the admin can reset his/her password
1111 function sendAdminPasswordResetLink ($email) {
1115 //Â Look up administator login
1116 $result = SQL_QUERY_ESC("SELECT `id`, `login`, `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `email`='%s' LIMIT 1",
1117 array($email), __FUNCTION__, __LINE__);
1119 // Is there an account?
1120 if (SQL_HASZERONUMS($result)) {
1122 return '{--ADMIN_NO_LOGIN_WITH_EMAIL--}';
1126 $content = SQL_FETCHARRAY($result);
1129 SQL_FREERESULT($result);
1131 // Generate hash for reset link
1132 $content['hash'] = generateHash(getUrl() . getEncryptSeperator() . $content['id'] . getEncryptSeperator() . $content['login'] . getEncryptSeperator() . $content['password'], substr($content['password'], getSaltLength()));
1135 unset($content['id']);
1136 unset($content['password']);
1139 $mailText = loadEmailTemplate('admin_reset_password', $content);
1142 sendEmail($email, '{--ADMIN_RESET_PASSWORD_LINK_SUBJECT--}', $mailText);
1145 return '{--ADMIN_RESET_PASSWORD_LINK_SENT--}';
1148 // Validate hash and login for password reset
1149 function adminResetValidateHashLogin ($hash, $login) {
1150 // By default nothing validates... ;)
1153 // Then try to find that user
1154 $result = SQL_QUERY_ESC("SELECT `id`, `password`, `email` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
1155 array($login), __FUNCTION__, __LINE__);
1157 // Is an account here?
1158 if (SQL_NUMROWS($result) == 1) {
1160 $content = SQL_FETCHARRAY($result);
1162 // Generate hash again
1163 $hashFromData = generateHash(getUrl() . getEncryptSeperator() . $content['id'] . getEncryptSeperator() . $login . getEncryptSeperator() . $content['password'], substr($content['password'], getSaltLength()));
1166 $valid = ($hash == $hashFromData);
1170 SQL_FREERESULT($result);
1176 // Reset the password for the login. Do NOT call this function without calling above function first!
1177 function doResetAdminPassword ($login, $password) {
1178 // Generate hash (we already check for sql_patches in generateHash())
1179 $passHash = generateHash($password);
1182 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `password`='%s' WHERE `login`='%s' LIMIT 1",
1183 array($passHash, $login), __FUNCTION__, __LINE__);
1186 runFilterChain('post_form_reset_pass', array('login' => $login, 'hash' => $passHash));
1189 return '{--ADMIN_PASSWORD_RESET_DONE--}';
1192 // Solves a task by given id number
1193 function adminSolveTask ($id) {
1194 // Update the task data
1195 adminUpdateTaskData($id, 'status', 'SOLVED');
1198 // Marks a given task as deleted
1199 function adminDeleteTask ($id) {
1200 // Update the task data
1201 adminUpdateTaskData($id, 'status', 'DELETED');
1204 // Function to update task data
1205 function adminUpdateTaskData ($id, $row, $data) {
1208 // Not an admin so redirect better
1209 redirectToUrl('modules.php?module=index');
1212 // Is the id not set, then we need a backtrace here... :(
1214 // Initiate backtrace
1215 debug_report_bug(__FUNCTION__, __LINE__, sprintf("id is invalid: %s. row=%s, data=%s",
1223 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `%s`='%s' WHERE `id`=%s LIMIT 1",
1228 ), __FUNCTION__, __LINE__);
1231 // Checks wether if the admin menu has entries
1232 function ifAdminMenuHasEntries ($action) {
1235 // Is the entry set?
1236 isset($GLOBALS['admin_menu_has_entries'][$action])
1238 // And do we have a menu for this action?
1239 $GLOBALS['admin_menu_has_entries'][$action] === true
1241 // Login has always a menu
1247 // Setter for 'admin_menu_has_entries'
1248 function setAdminMenuHasEntries ($action, $hasEntries) {
1249 $GLOBALS['admin_menu_has_entries'][$action] = (bool) $hasEntries;
1252 // Creates a link to the user's admin-profile
1253 function adminCreateUserLink ($userid) {
1254 // Is the userid set correctly?
1255 if (isValidUserId($userid)) {
1256 // Create a link to that profile
1257 return '{%url=modules.php?module=admin&what=list_user&userid=' . bigintval($userid) . '%}';
1260 // Return a link to the user list
1261 return '{%url=modules.php?module=admin&what=list_user%}';
1264 // Generate a "link" for the given admin id (admin_id)
1265 function generateAdminLink ($adminId) {
1266 // No assigned admin is default
1267 $adminLink = '<span class="notice">{--ADMIN_NO_ADMIN_ASSIGNED--}</span>';
1269 // Zero? = Not assigned
1270 if (bigintval($adminId) > 0) {
1271 // Load admin's login
1272 $login = getAdminLogin($adminId);
1274 // Is the login valid?
1275 if ($login != '***') {
1276 // Is the extension there?
1277 if (isExtensionActive('admins')) {
1279 $adminLink = '<a href="' . generateEmailLink(getAdminEmail($adminId), 'admins') . '" title="{--ADMIN_CONTACT_LINK_TITLE--}">' . $login . '</a>';
1281 // Extension not found
1282 $adminLink = getMaskedMessage('ADMIN_TASK_ROW_EXTENSION_NOT_INSTALLED', 'admins');
1286 $adminLink = '<div class="notice">' . getMaskedMessage('ADMIN_ID_404', $adminId) . '</div>';
1294 // Verifies if the current admin has confirmed to alter expert settings
1297 // 'failed' = Something goes wrong (default)
1298 // 'agreed' = Has verified and and confirmed it to see them
1299 // 'forbidden' = Has not the proper right to alter them
1300 // 'update' = Need to update extension 'admins'
1301 // 'ask' = A form was send to the admin
1302 function doVerifyExpertSettings () {
1303 // Default return status is failed
1306 // Is the extension installed and recent?
1307 if (isExtensionInstalledAndNewer('admins', '0.7.3')) {
1308 // Okay, load the status
1309 $expertSettings = getAminsExpertSettings();
1312 if ($expertSettings == 'Y') {
1313 // Okay, does he want to see them?
1314 if (isAdminsExpertWarningEnabled()) {
1317 // Is the element set, then we need to change the admin
1318 if (isPostRequestParameterSet('expert_settings')) {
1319 // Get it and prepare final post data array
1320 $postData['login'][getCurrentAdminId()] = getCurrentAdminLogin();
1321 $postData['expert_warning'][getCurrentAdminId()] = 'N';
1323 // Change it in the admin
1324 adminsChangeAdminAccount($postData, 'expert_warning');
1327 unsetPostRequestParameter('ok');
1334 loadTemplate('admin_expert_settings_form');
1345 $return = 'forbidden';
1348 // Out-dated extension or not installed
1352 // Output message for other status than ask/agreed
1353 if (($return != 'ask') && ($return != 'agreed')) {
1355 displayMessage('{--ADMIN_EXPERT_SETTINGS_STATUS_' . strtoupper($return) . '--}');
1362 // Generate link to unconfirmed mails for admin
1363 function generateUnconfirmedAdminLink ($id, $unconfirmed, $type = 'bid') {
1365 $OUT = $unconfirmed;
1367 // Do we have unconfirmed mails?
1368 if ($unconfirmed > 0) {
1369 // Add link to list_unconfirmed what-file
1370 $OUT = '<a href="{%url=modules.php?module=admin&what=list_unconfirmed&' . $type . '=' . $id . '%}">{%pipe,translateComma=' . $unconfirmed . '%}</a>';
1377 // Generates a navigation row for listing emails
1378 function addEmailNavigation ($numPages, $offset, $show_form, $colspan, $return=false) {
1379 // Don't do anything if $numPages is 1
1380 if ($numPages == 1) {
1381 // Abort here with empty content
1386 if ($show_form === false) {
1391 for ($page = 1; $page <= $numPages; $page++) {
1392 // Is the page currently selected or shall we generate a link to it?
1393 if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
1394 // Is currently selected, so only highlight it
1395 $NAV .= '<strong>-';
1397 // Open anchor tag and add base URL
1398 $NAV .= '<a href="{%url=modules.php?module=admin&what=' . getWhat() . '&page=' . $page . '&offset=' . $offset;
1400 // Add userid when we shall show all mails from a single member
1401 if ((isGetRequestParameterSet('userid')) && (isValidUserId(getRequestParameter('userid')))) $NAV .= '&userid=' . bigintval(getRequestParameter('userid'));
1403 // Close open anchor tag
1407 if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
1408 // Is currently selected, so only highlight it
1409 $NAV .= '-</strong>';
1415 // Add seperator if we have not yet reached total pages
1416 if ($page < $numPages) {
1422 // Define constants only once
1423 $content['nav'] = $NAV;
1424 $content['span'] = $colspan;
1425 $content['top'] = $TOP;
1427 // Load navigation template
1428 $OUT = loadTemplate('admin_email_nav_row', true, $content);
1430 if ($return === true) {
1431 // Return generated HTML-Code
1439 // Process menu editing form
1440 function adminProcessMenuEditForm ($type, $subMenu) {
1441 // An action is done...
1442 foreach (postRequestParameter('sel') as $sel => $menu) {
1443 $AND = "(`what` = '' OR `what` IS NULL)";
1445 $sel = bigintval($sel);
1447 if (!empty($subMenu)) {
1448 $AND = "`action`='" . $subMenu . "'";
1451 switch (postRequestParameter('ok')) {
1452 case 'edit': // Edit menu
1453 if (postRequestParameter('sel_what', $sel) == '') {
1454 // Update with 'what'=null
1455 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s', `action`='%s', `what`=NULL WHERE ".$AND." AND `id`=%s LIMIT 1",
1459 postRequestParameter('sel_action', $sel),
1461 ), __FILE__, __LINE__);
1463 // Update with selected 'what'
1464 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s', `action`='%s', `what`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
1468 postRequestParameter('sel_action', $sel),
1469 postRequestParameter('sel_what', $sel),
1471 ), __FILE__, __LINE__);
1475 case 'delete': // Delete menu
1476 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
1477 array($type, $sel), __FILE__, __LINE__);
1480 case 'status': // Change status of menus
1481 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `visible`='%s', `locked`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
1482 array($type, postRequestParameter('visible', $sel), postRequestParameter('locked', $sel), $sel), __FILE__, __LINE__);
1485 default: // Unexpected action
1486 logDebugMessage(__FILE__, __LINE__, sprintf("Unsupported action %s detected.", postRequestParameter('ok')));
1487 displayMessage(getMaskedMessage('ADMIN_UNKNOWN_OKAY', postRequestParameter('ok')));
1493 displayMessage('{--SETTINGS_SAVED--}');
1496 // Handle weightning
1497 function doAdminProcessMenuWeightning ($type, $AND) {
1498 // Are there all required (generalized) GET parameter?
1499 if ((isGetRequestParameterSet('act')) && (isGetRequestParameterSet('tid')) && (isGetRequestParameterSet('fid'))) {
1501 $tid = ''; $fid = '';
1504 if (isGetRequestParameterSet('w')) {
1505 // Sub menus selected
1506 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
1509 getRequestParameter('act'),
1510 bigintval(getRequestParameter('tid'))
1511 ), __FILE__, __LINE__);
1512 list($tid) = SQL_FETCHROW($result);
1513 SQL_FREERESULT($result);
1514 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
1517 getRequestParameter('act'),
1518 bigintval(getRequestParameter('fid'))
1519 ), __FILE__, __LINE__);
1520 list($fid) = SQL_FETCHROW($result);
1521 SQL_FREERESULT($result);
1523 // Main menu selected
1524 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
1527 bigintval(getRequestParameter('tid'))
1528 ), __FILE__, __LINE__);
1529 list($tid) = SQL_FETCHROW($result);
1530 SQL_FREERESULT($result);
1531 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
1534 bigintval(getRequestParameter('fid'))
1535 ), __FILE__, __LINE__);
1536 list($fid) = SQL_FETCHROW($result);
1537 SQL_FREERESULT($result);
1540 if ((!empty($tid)) && (!empty($fid))) {
1542 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
1545 bigintval(getRequestParameter('tid')),
1547 ), __FILE__, __LINE__);
1548 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
1551 bigintval(getRequestParameter('fid')),
1553 ), __FILE__, __LINE__);