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();
339 $OUT .= '<li class="admin_menu_sub"><ul class="admin_menu_sub">';
340 // @TODO Rewrite this to $content = SQL_FETCHARRAY()
341 while (list($what_sub, $title_what, $desc_what) = SQL_FETCHROW($result_what)) {
343 $inc = sprintf("inc/modules/admin/what-%s.php", $what_sub);
345 // Is the file readable?
346 $readable = isIncludeReadable($inc);
348 // Is the current admin allowed to access this 'what' menu?
349 if (isAdminAllowedAccessMenu(null, $what_sub)) {
350 // Insert compiled title and description
351 $GLOBALS['menu']['title'][$what_sub] = $title_what;
352 $GLOBALS['menu']['description'][$what_sub] = $desc_what;
353 $OUT .= '<li class="admin_menu">
354 <div class="nobr"><strong>--></strong> ';
355 if ($readable === true) {
356 if ($what == $what_sub) {
359 $OUT .= '[<a href="{%url=modules.php?module=admin&what=' . $what_sub . '%}">';
362 $OUT .= '<em style="cursor:help" class="notice" title="{%message,ADMIN_MENU_WHAT_404=' . $what_sub . '%}">';
367 if ($readable === true) {
368 if ($what == $what_sub) {
382 SQL_FREERESULT($result_what);
390 SQL_FREERESULT($result_main);
394 // Is there a cache instance again?
395 // Return or output content?
396 if ($return === true) {
403 // Create member selection box
404 function addMemberSelectionBox ($def = 0, $add_all = false, $return = false, $none = false, $field = 'userid') {
405 // Output selection form with all confirmed user accounts listed
406 $result = SQL_QUERY("SELECT `userid`, `surname`, `family` FROM `{?_MYSQL_PREFIX?}_user_data` ORDER BY `userid` ASC", __FUNCTION__, __LINE__);
411 // USe this only for adding points (e.g. adding refs really makes no sence ;-) )
412 if ($add_all === true) $OUT = ' <option value="all">{--ALL_MEMBERS--}</option>';
413 elseif ($none === true) $OUT = ' <option value="0">{--SELECT_NONE--}</option>';
415 while ($content = SQL_FETCHARRAY($result)) {
416 $OUT .= '<option value="' . bigintval($content['userid']) . '"';
417 if ($def == $content['userid']) $OUT .= ' selected="selected"';
418 $OUT .= '>' . $content['surname'] . ' ' . $content['family'] . ' (' . bigintval($content['userid']) . ')</option>';
422 SQL_FREERESULT($result);
424 if ($return === false) {
425 // Remeber options in constant
426 $content['form_selection'] = $OUT;
427 $content['what'] = getWhat();
430 loadTemplate('admin_form_selection_box', false, $content);
432 // Return content in selection frame
433 return '<select class="form_select" name="' . handleFieldWithBraces($field) . '" size="1">' . $OUT . '</select>';
437 // Create a menu selection box for given menu system
438 // @TODO Try to rewrite this to adminAddMenuSelectionBox()
440 function adminMenuSelectionBox_DEPRECATED ($mode, $default = '', $defid = '') {
441 $what = "`what` != ''";
442 if ($mode == 'action') $what = "(`what`='' OR `what` IS NULL) AND `action` !='login'";
444 $result = SQL_QUERY_ESC("SELECT `%s` AS `menu`, `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$what." ORDER BY `sort` ASC",
445 array($mode), __FUNCTION__, __LINE__);
446 if (!SQL_HASZERONUMS($result)) {
447 // Load menu as selection
448 $OUT = '<select name="' . $mode . '_menu';
449 if ((!empty($defid)) || ($defid == '0')) $OUT .= '[' . $defid . ']';
450 $OUT .= '" size="1" class="form_select">
451 <option value="">{--SELECT_NONE--}</option>';
453 while ($content = SQL_FETCHARRAY($result)) {
454 $OUT .= '<option value="' . $content['menu'] . '"';
455 if ((!empty($default)) && ($default == $content['menu'])) $OUT .= ' selected="selected"';
456 $OUT .= '>' . $content['title'] . '</option>';
460 SQL_FREERESULT($result);
462 // Add closing select-tag
466 $OUT = '{--ADMIN_PROBLEM_NO_MENU--}';
473 // Wrapper for $_POST and adminSaveSettings
474 function adminSaveSettingsFromPostData ($tableName = '_config', $whereStatement = '`config`=0', $translateComma = array(), $alwaysAdd = false, $displayMessage = true) {
476 $postData = postRequestArray();
478 // Call the lower function
479 adminSaveSettings($postData, $tableName, $whereStatement, $translateComma, $alwaysAdd, $displayMessage);
482 // Save settings to the database
483 function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement = '`config`=0', $translateComma = array(), $alwaysAdd = false, $displayMessage = true) {
484 // Prepare all arrays, variables
485 $tableData = array();
488 // Now, walk through all entries and prepare them for saving
489 foreach ($postData as $id => $val) {
490 // Process only formular field but not submit buttons ;)
492 // Do not save the ok value
493 convertSelectionsToEpocheTime($postData, $tableData, $id, $skip);
495 // Shall we process this id? It muss not be empty, of course
496 if (($skip === false) && (!empty($id)) && ((!isset($GLOBALS['skip_config'][$id]))) || ($tableName != '_config')) {
497 // Translate the value? (comma to dot!)
498 if ((is_array($translateComma)) && (in_array($id, $translateComma))) {
499 // Then do it here... :)
500 $val = convertCommaToDot($val);
503 // Shall we add numbers or strings?
504 $test = (float) $val;
505 if ('' . $val . '' == '' . $test . '') {
507 $tableData[] = sprintf("`%s`=%s", $id, $test);
508 } elseif (is_null($val)) {
510 $tableData[] = sprintf("`%s`=NULL", $id);
513 $tableData[] = sprintf("`%s`='%s'", $id, trim($val));
516 // Do not add a config entry twice
517 $GLOBALS['skip_config'][$id] = true;
519 // Update current configuration
520 setConfigEntry($id, $val);
525 // Check if entry does exist
527 if ($alwaysAdd === false) {
528 if (!empty($whereStatement)) {
529 $result = SQL_QUERY("SELECT * FROM `{?_MYSQL_PREFIX?}" . $tableName . "` WHERE " . $whereStatement . " LIMIT 1", __FUNCTION__, __LINE__);
531 $result = SQL_QUERY("SELECT * FROM `{?_MYSQL_PREFIX?}" . $tableName . "` LIMIT 1", __FUNCTION__, __LINE__);
535 if (SQL_NUMROWS($result) == 1) {
536 // "Implode" all data to single string
537 $updatedData = implode(', ', $tableData);
539 // Generate SQL string
540 $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}%s` SET %s WHERE %s LIMIT 1",
546 // Add Line (does only work with auto_increment!
547 $keys = array(); $values = array();
548 foreach ($tableData as $entry) {
550 $line = explode('=', $entry);
552 $values[] = $line[1];
555 // Add both in one line
556 $keys = implode('`, `', $keys);
557 $values = implode(', ', $values);
559 // Generate SQL string
560 $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}%s` (%s) VALUES (%s)",
568 SQL_FREERESULT($result);
570 // Simply run generated SQL string
571 SQL_QUERY($sql, __FUNCTION__, __LINE__);
573 // Remember affected rows
574 $affected = SQL_AFFECTEDROWS();
577 rebuildCache('config', 'config');
579 // Settings saved, so display message?
580 if ($displayMessage === true) displayMessage('{--SETTINGS_SAVED--}');
582 // Return affected rows
586 // Generate a selection box
587 function adminAddMenuSelectionBox ($menu, $type, $name, $default = '') {
588 // Open the requested menu directory
589 $menuArray = getArrayFromDirectory(sprintf("inc/modules/%s/", $menu), $type . '-', false, false);
591 // Init the selection box
592 $OUT = '<select name="' . $name . '" class="form_select" size="1"><option value="">{--ADMIN_IS_TOP_MENU--}</option>';
594 // Walk through all files
595 foreach ($menuArray as $file) {
596 // Is this a PHP script?
597 if ((!isDirectory($file)) && (strpos($file, '' . $type . '-') > -1) && (strpos($file, '.php') > 0)) {
598 // Then test if the file is readable
599 $test = sprintf("inc/modules/%s/%s", $menu, $file);
601 // Is the file there?
602 if (isIncludeReadable($test)) {
603 // Extract the value for what=xxx
604 $part = substr($file, (strlen($type) + 1));
605 $part = substr($part, 0, -4);
607 // Is that part different from the overview?
608 if ($part != 'overview') {
609 $OUT .= '<option value="' . $part . '"';
610 if ($part == $default) $OUT .= ' selected="selected"';
611 $OUT .= '>' . $part . '</option>';
617 // Close selection box
624 // Creates a user-profile link for the admin. This function can also be used for many other purposes
625 function generateUserProfileLink ($userid, $title = '', $what = 'list_user') {
626 if (($title == '') && (isValidUserId($userid))) {
627 // Set userid as title
629 } elseif ($userid == 0) {
630 // User id zero is invalid
631 return '<strong>' . $userid . '</strong>';
634 if (($title == '0') && ($what == 'list_refs')) {
635 // Return title again
637 } elseif (isExtensionActive('nickname')) {
639 $nick = getNickname($userid);
641 // Is it not empty, use it as title else the userid
643 $title = $nick . '(' . $userid . ')';
650 return '[<a href="{%url=modules.php?module=admin&what=' . $what . '&userid=' . $userid . '%}" title="{--ADMIN_USER_PROFILE_TITLE--}">' . $title . '</a>]';
653 // Check "logical-area-mode"
654 function adminGetMenuMode () {
655 // Set the default menu mode as the mode for all admins
658 // If sql_patches is up-to-date enough, use the configuration
659 if (isExtensionInstalledAndNewer('sql_patches', '0.3.2')) {
660 $mode = getAdminMenu();
667 $adminId = getCurrentAdminId();
669 // Check individual settings of current admin
670 if (isset($GLOBALS['cache_array']['admin']['la_mode'][$adminId])) {
672 $adminMode = $GLOBALS['cache_array']['admin']['la_mode'][$adminId];
673 incrementStatsEntry('cache_hits');
674 } elseif (isExtensionInstalledAndNewer('admins', '0.6.7')) {
675 // Load from database when version of 'admins' is enough
676 $result = SQL_QUERY_ESC("SELECT `la_mode` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
677 array($adminId), __FUNCTION__, __LINE__);
679 // Do we have an entry?
680 if (SQL_NUMROWS($result) == 1) {
682 list($adminMode) = SQL_FETCHROW($result);
686 SQL_FREERESULT($result);
689 // Check what the admin wants and set it when it's not the default mode
690 if ($adminMode != 'global') {
694 // Return admin-menu's mode
698 // Change activation status
699 function adminChangeActivationStatus ($IDs, $table, $row, $idRow = 'id') {
700 $count = '0'; $newStatus = 'Y';
701 if ((is_array($IDs)) && (count($IDs) > 0)) {
702 // "Walk" all through and count them
703 foreach ($IDs as $id => $selected) {
704 // Secure the id number
705 $id = bigintval($id);
707 // Should always be set... ;-)
708 if (!empty($selected)) {
709 // Determine new status
710 $result = SQL_QUERY_ESC("SELECT %s FROM `{?_MYSQL_PREFIX?}_%s` WHERE %s=%s LIMIT 1",
711 array($row, $table, $idRow, $id), __FUNCTION__, __LINE__);
714 if (SQL_NUMROWS($result) == 1) {
716 list($currStatus) = SQL_FETCHROW($result);
718 // And switch it N<->Y
719 if ($currStatus == 'Y') $newStatus = 'N'; else $newStatus = 'Y';
721 // Change this status
722 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s` SET %s='%s' WHERE %s=%s LIMIT 1",
723 array($table, $row, $newStatus, $idRow, $id), __FUNCTION__, __LINE__);
725 // Count up affected rows
726 $count += SQL_AFFECTEDROWS();
730 SQL_FREERESULT($result);
735 displayMessage(sprintf(getMessage('ADMIN_STATUS_CHANGED'), $count, count($IDs)));
738 displayMessage('{--ADMIN_NOTHING_SELECTED_CHANGE--}');
742 // Send mails for del/edit/lock build modes
743 function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '', $userid = 'userid') {
744 // Default subject is the subject part
745 $subject = $subjectPart;
747 // Is the subject part not set?
748 if (empty($subjectPart)) {
749 // Then use it from the mode
750 $subject = strtoupper($mode);
753 // Is the raw userid set?
754 if (postRequestParameter($userid, $id) > 0) {
755 // Load email template
756 if (!empty($subjectPart)) {
757 $mail = loadEmailTemplate('member_' . $mode . '_' . strtolower($subjectPart) . '_' . $table, $content);
759 $mail = loadEmailTemplate('member_' . $mode . '_' . $table, $content);
763 sendEmail(postRequestParameter($userid, $id), strtoupper('{--MEMBER_' . $subject . '_' . $table . '_SUBJECT--}'), $mail);
767 $subject = strtoupper('{--ADMIN_' . $subject . '_' . $table . '_SUBJECT--}');
769 // Send admin notification out
770 if (!empty($subjectPart)) {
771 sendAdminNotification($subject, 'admin_' . $mode . '_' . strtolower($subjectPart) . '_' . $table, $content, postRequestParameter($userid, $id));
773 sendAdminNotification($subject, 'admin_' . $mode . '_' . $table, $content, postRequestParameter($userid, $id));
777 // Build a special template list
778 function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $userid = 'userid') {
781 // "Walk"Â through all entries
782 foreach ($IDs as $id => $selected) {
784 $id = bigintval($id);
786 // Get result from a given column array and table name
787 $result = SQL_RESULT_FROM_ARRAY($table, $columns, $idColumn, $id, __FUNCTION__, __LINE__);
789 // Is there one entry?
790 if (SQL_NUMROWS($result) == 1) {
792 $content = SQL_FETCHARRAY($result);
795 foreach ($content as $key => $value) {
797 $idx = array_search($key, $columns, true);
799 //Â Do we have a userid?
800 if ($key == $userIdColumn) {
801 // Add it again as raw id
802 $content[$userIdColumn] = bigintval($value);
803 $content[$userIdColumn . '_raw'] = $content[$userIdColumn];
806 // If the key matches the idColumn variable, we need to temporary remember it
807 //* DEBUG: */ debugOutput('key=' . $key . ',idColumn=' . $idColumn . ',value=' . $value);
808 if ($key == $idColumn) {
809 // Found, so remember it
810 $GLOBALS['admin_list_builder_id_value'] = $value;
813 // Handle the call in external function
814 //* DEBUG: */ debugOutput('key=' . $key . ',fucntion=' . $filterFunctions[$idx] . ',value=' . $value);
815 $content[$key] = handleExtraValues($filterFunctions[$idx], $value, $extraValues[$idx]);
819 $OUT .= loadTemplate(sprintf("admin_%s_%s_row",
827 SQL_FREERESULT($result);
830 // Load master template
831 loadTemplate(sprintf("admin_%s_%s",
838 // Change status of "build" list
839 function adminBuilderStatusHandler ($mode, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray, $userid = 'userid') {
840 // All valid entries? (We hope so here!)
841 if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues)) && (count($statusArray) > 0)) {
842 // "Walk" through all entries
843 foreach ($IDs as $id => $sel) {
844 // Construct SQL query
845 $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}_%s` SET", SQL_ESCAPE($table));
847 // Load data of entry
848 $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
849 array($table, $idColumn, $id), __FUNCTION__, __LINE__);
852 $content = SQL_FETCHARRAY($result);
855 SQL_FREERESULT($result);
857 // Add all status entries (e.g. status column last_updated or so)
858 $newStatus = 'UNKNOWN';
859 $oldStatus = 'UNKNOWN';
860 $statusColumn = 'unknown';
861 foreach ($statusArray as $column => $statusInfo) {
862 // Does the entry exist?
863 if ((isset($content[$column])) && (isset($statusInfo[$content[$column]]))) {
864 // Add these entries for update
865 $sql .= sprintf(" %s='%s',", SQL_ESCAPE($column), SQL_ESCAPE($statusInfo[$content[$column]]));
868 if ($statusColumn == 'unknown') {
869 // Always (!!!) change status column first!
870 $oldStatus = $content[$column];
871 $newStatus = $statusInfo[$oldStatus];
872 $statusColumn = $column;
874 } elseif (isset($content[$column])) {
876 debug_report_bug(__FUNCTION__, __LINE__, ':UNFINISHED: id=' . $id . ',column=' . $column . '[' . gettype($statusInfo) . '] = ' . $content[$column]);
880 // Add other columns as well
881 foreach (postRequestArray() as $key => $entries) {
883 logDebugMessage(__FUNCTION__, __LINE__, 'Found entry: ' . $key);
885 // Skip id, raw userid and 'do_$mode'
886 if (!in_array($key, array($idColumn, $userid, ('do_' . $mode)))) {
887 // Are there brackets () at the end?
888 if (substr($entries[$id], -2, 2) == '()') {
889 // Direct SQL command found
890 $sql .= sprintf(" %s=%s,", SQL_ESCAPE($key), SQL_ESCAPE($entries[$id]));
893 $sql .= sprintf(" %s='%s',", SQL_ESCAPE($key), SQL_ESCAPE($entries[$id]));
896 $content[$key] = $entries[$id];
900 logDebugMessage(__FUNCTION__, __LINE__, 'Skipped: ' . $key);
904 // Finish SQL statement
905 $sql = substr($sql, 0, -1) . sprintf(" WHERE `%s`=%s AND `%s`='%s' LIMIT 1",
913 SQL_QUERY($sql, __FUNCTION__, __LINE__);
915 // Do we have an URL?
916 if (isset($content['url'])) {
917 // Then add a framekiller test as well
918 $content['frametester'] = generateFrametesterUrl($content['url']);
921 // Send "build mails" out
922 sendAdminBuildMails($mode, $table, $content, $id, $statusInfo[$content[$column]]);
927 // Delete rows by given id numbers
928 function adminDeleteEntriesConfirm ($IDs, $table, $columns = array(), $filterFunctions = array(), $extraValues = array(), $deleteNow = false, $idColumn = 'id', $userIdColumn = 'userid', $userid = 'userid') {
929 // All valid entries? (We hope so here!)
930 if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues))) {
931 // Shall we delete here or list for deletion?
932 if ($deleteNow === true) {
933 // The base SQL command:
934 $sql = "DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s` IN (%s)";
938 foreach ($IDs as $id => $sel) {
939 // Is there a userid?
940 if (isPostRequestParameterSet($userid, $id)) {
941 // Load all data from that id
942 $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
947 ), __FUNCTION__, __LINE__);
950 $content = SQL_FETCHARRAY($result);
953 SQL_FREERESULT($result);
955 // Send "build mails" out
956 sendAdminBuildMails('delete', $table, $content, $id);
960 $idList .= $id . ',';
964 SQL_QUERY_ESC($sql, array($table, $idColumn, substr($idList, 0, -1)), __FUNCTION__, __LINE__);
967 if (SQL_AFFECTEDROWS() == count($IDs)) {
969 displayMessage('{--ADMIN_ALL_ENTRIES_REMOVED--}');
971 // Some are still there :(
972 displayMessage(sprintf(getMessage('ADMIN_SOME_ENTRIES_NOT_DELETED'), SQL_AFFECTEDROWS(), count($IDs)));
975 // List for deletion confirmation
976 adminListBuilder('delete', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
981 // Edit rows by given id numbers
982 function adminEditEntriesConfirm ($IDs, $table, $columns = array(), $filterFunctions = array(), $extraValues = array(), $editNow = false, $idColumn = 'id', $userIdColumn = 'userid', $userid = 'userid') {
983 // All valid entries? (We hope so here!)
984 if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues))) {
985 // Shall we change here or list for editing?
986 if ($editNow === true) {
989 foreach ($IDs as $id => $sel) {
990 // Prepare content array (new values)
993 // Prepare SQL for this row
994 $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}_%s` SET",
997 foreach (postRequestArray() as $key => $entries) {
998 // Skip raw userid which is always invalid
999 if ($key == $userid) {
1000 // Continue with next field
1004 // Is entries an array?
1005 if (($key != $idColumn) && (is_array($entries)) && (isset($entries[$id]))) {
1006 // Add this entry to content
1007 $content[$key] = $entries[$id];
1009 // Send data through the filter function if found
1010 if ((isset($filterFunctions[$key])) && (isset($extraValues[$key]))) {
1011 // Filter function set!
1012 $entries[$id] = handleExtraValues($filterFunctions[$key], $entries[$id], $extraValues[$key]);
1015 // Then add this value
1016 $sql .= sprintf(" `%s`='%s',",
1018 SQL_ESCAPE($entries[$id])
1020 } elseif (($key != $idColumn) && (!is_array($entries))) {
1021 // Add normal entries as well!
1022 $content[$key] = $entries;
1025 // Do we have an URL?
1026 if ($key == 'url') {
1027 // Then add a framekiller test as well
1028 $content['frametester'] = generateFrametesterUrl($content[$key]);
1032 // Finish SQL command
1033 $sql = substr($sql, 0, -1) . " WHERE `" . $idColumn . "`=" . bigintval($id) . " LIMIT 1";
1036 SQL_QUERY($sql, __FUNCTION__, __LINE__);
1038 // Add affected rows
1039 $affected += SQL_AFFECTEDROWS();
1041 // Load all data from that id
1042 $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
1043 array($table, $idColumn, $id), __FUNCTION__, __LINE__);
1045 // Fetch the data and merge it into $content
1046 $content = merge_array($content, SQL_FETCHARRAY($result));
1049 SQL_FREERESULT($result);
1051 // Send "build mails" out
1052 sendAdminBuildMails('edit', $table, $content, $id);
1056 if ($affected == count($IDs)) {
1058 displayMessage('{--ADMIN_ALL_ENTRIES_EDITED--}');
1060 // Some are still there :(
1061 displayMessage(sprintf(getMessage('ADMIN_SOME_ENTRIES_NOT_EDITED'), $affected, count($IDs)));
1065 adminListBuilder('edit', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
1070 // Un-/lock rows by given id numbers
1071 function adminLockEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctions=array(), $extraValues=array(), $statusArray=array(), $lockNow=false, $idColumn='id', $userIdColumn='userid') {
1072 // All valid entries? (We hope so here!)
1073 if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues)) && (($lockNow === false) || (count($statusArray) == 1))) {
1074 // Shall we un-/lock here or list for locking?
1075 if ($lockNow === true) {
1077 adminBuilderStatusHandler('lock', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray);
1080 adminListBuilder('lock', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
1085 // Undelete rows by given id numbers
1086 function adminUndeleteEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctions=array(), $extraValues=array(), $statusArray=array(), $undeleteNow=false, $idColumn='id', $userIdColumn='userid') {
1087 // All valid entries? (We hope so here!)
1088 if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues)) && (($undeleteNow === false) || (count($statusArray) == 1))) {
1089 // Shall we un-/lock here or list for locking?
1090 if ($undeleteNow === true) {
1092 adminBuilderStatusHandler('undelete', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray);
1095 adminListBuilder('undelete', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
1100 // Checks proxy settins by fetching check-updates3.php from www.mxchange.org
1101 function adminTestProxySettings ($settingsArray) {
1102 // Set temporary the new settings
1103 mergeConfig($settingsArray);
1105 // Now get the test URL
1106 $content = sendGetRequest('check-updates3.php');
1108 // Is the first line with "200 OK"?
1109 $valid = (strpos($content[0], '200 OK') !== false);
1115 // Sends out a link to the given email adress so the admin can reset his/her password
1116 function sendAdminPasswordResetLink ($email) {
1120 //Â Look up administator login
1121 $result = SQL_QUERY_ESC("SELECT `id`, `login`, `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `email`='%s' LIMIT 1",
1122 array($email), __FUNCTION__, __LINE__);
1124 // Is there an account?
1125 if (SQL_HASZERONUMS($result)) {
1127 return '{--ADMIN_NO_LOGIN_WITH_EMAIL--}';
1131 $content = SQL_FETCHARRAY($result);
1134 SQL_FREERESULT($result);
1136 // Generate hash for reset link
1137 $content['hash'] = generateHash(getUrl() . getEncryptSeperator() . $content['id'] . getEncryptSeperator() . $content['login'] . getEncryptSeperator() . $content['password'], substr($content['password'], getSaltLength()));
1140 unset($content['id']);
1141 unset($content['password']);
1144 $mailText = loadEmailTemplate('admin_reset_password', $content);
1147 sendEmail($email, '{--ADMIN_RESET_PASSWORD_LINK_SUBJECT--}', $mailText);
1150 return '{--ADMIN_RESET_PASSWORD_LINK_SENT--}';
1153 // Validate hash and login for password reset
1154 function adminResetValidateHashLogin ($hash, $login) {
1155 // By default nothing validates... ;)
1158 // Then try to find that user
1159 $result = SQL_QUERY_ESC("SELECT `id`, `password`, `email` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
1160 array($login), __FUNCTION__, __LINE__);
1162 // Is an account here?
1163 if (SQL_NUMROWS($result) == 1) {
1165 $content = SQL_FETCHARRAY($result);
1167 // Generate hash again
1168 $hashFromData = generateHash(getUrl() . getEncryptSeperator() . $content['id'] . getEncryptSeperator() . $login . getEncryptSeperator() . $content['password'], substr($content['password'], getSaltLength()));
1171 $valid = ($hash == $hashFromData);
1175 SQL_FREERESULT($result);
1181 // Reset the password for the login. Do NOT call this function without calling above function first!
1182 function doResetAdminPassword ($login, $password) {
1183 // Generate hash (we already check for sql_patches in generateHash())
1184 $passHash = generateHash($password);
1187 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `password`='%s' WHERE `login`='%s' LIMIT 1",
1188 array($passHash, $login), __FUNCTION__, __LINE__);
1191 runFilterChain('post_form_reset_pass', array('login' => $login, 'hash' => $passHash));
1194 return '{--ADMIN_PASSWORD_RESET_DONE--}';
1197 // Solves a task by given id number
1198 function adminSolveTask ($id) {
1199 // Update the task data
1200 adminUpdateTaskData($id, 'status', 'SOLVED');
1203 // Marks a given task as deleted
1204 function adminDeleteTask ($id) {
1205 // Update the task data
1206 adminUpdateTaskData($id, 'status', 'DELETED');
1209 // Function to update task data
1210 function adminUpdateTaskData ($id, $row, $data) {
1213 // Not an admin so redirect better
1214 redirectToUrl('modules.php?module=index');
1217 // Is the id not set, then we need a backtrace here... :(
1219 // Initiate backtrace
1220 debug_report_bug(__FUNCTION__, __LINE__, sprintf("id is invalid: %s. row=%s, data=%s",
1228 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `%s`='%s' WHERE `id`=%s LIMIT 1",
1233 ), __FUNCTION__, __LINE__);
1236 // Checks wether if the admin menu has entries
1237 function ifAdminMenuHasEntries ($action) {
1240 // Is the entry set?
1241 isset($GLOBALS['admin_menu_has_entries'][$action])
1243 // And do we have a menu for this action?
1244 $GLOBALS['admin_menu_has_entries'][$action] === true
1246 // Login has always a menu
1252 // Setter for 'admin_menu_has_entries'
1253 function setAdminMenuHasEntries ($action, $hasEntries) {
1254 $GLOBALS['admin_menu_has_entries'][$action] = (bool) $hasEntries;
1257 // Creates a link to the user's admin-profile
1258 function adminCreateUserLink ($userid) {
1259 // Is the userid set correctly?
1260 if (isValidUserId($userid)) {
1261 // Create a link to that profile
1262 return '{%url=modules.php?module=admin&what=list_user&userid=' . bigintval($userid) . '%}';
1265 // Return a link to the user list
1266 return '{%url=modules.php?module=admin&what=list_user%}';
1269 // Generate a "link" for the given admin id (admin_id)
1270 function generateAdminLink ($adminId) {
1271 // No assigned admin is default
1272 $adminLink = '<span class="notice">{--ADMIN_NO_ADMIN_ASSIGNED--}</span>';
1274 // Zero? = Not assigned
1275 if (bigintval($adminId) > 0) {
1276 // Load admin's login
1277 $login = getAdminLogin($adminId);
1279 // Is the login valid?
1280 if ($login != '***') {
1281 // Is the extension there?
1282 if (isExtensionActive('admins')) {
1284 $adminLink = '<a href="' . generateEmailLink(getAdminEmail($adminId), 'admins') . '" title="{--ADMIN_CONTACT_LINK_TITLE--}">' . $login . '</a>';
1286 // Extension not found
1287 $adminLink = getMaskedMessage('ADMIN_TASK_ROW_EXTENSION_NOT_INSTALLED', 'admins');
1291 $adminLink = '<div class="notice">' . getMaskedMessage('ADMIN_ID_404', $adminId) . '</div>';
1299 // Verifies if the current admin has confirmed to alter expert settings
1302 // 'failed' = Something goes wrong (default)
1303 // 'agreed' = Has verified and and confirmed it to see them
1304 // 'forbidden' = Has not the proper right to alter them
1305 // 'update' = Need to update extension 'admins'
1306 // 'ask' = A form was send to the admin
1307 function doVerifyExpertSettings () {
1308 // Default return status is failed
1311 // Is the extension installed and recent?
1312 if (isExtensionInstalledAndNewer('admins', '0.7.3')) {
1313 // Okay, load the status
1314 $expertSettings = getAminsExpertSettings();
1317 if ($expertSettings == 'Y') {
1318 // Okay, does he want to see them?
1319 if (isAdminsExpertWarningEnabled()) {
1322 // Is the element set, then we need to change the admin
1323 if (isPostRequestParameterSet('expert_settings')) {
1324 // Get it and prepare final post data array
1325 $postData['login'][getCurrentAdminId()] = getCurrentAdminLogin();
1326 $postData['expert_warning'][getCurrentAdminId()] = 'N';
1328 // Change it in the admin
1329 adminsChangeAdminAccount($postData, 'expert_warning');
1332 unsetPostRequestParameter('ok');
1339 loadTemplate('admin_expert_settings_form');
1350 $return = 'forbidden';
1353 // Out-dated extension or not installed
1357 // Output message for other status than ask/agreed
1358 if (($return != 'ask') && ($return != 'agreed')) {
1360 displayMessage('{--ADMIN_EXPERT_SETTINGS_STATUS_' . strtoupper($return) . '--}');
1367 // Generate link to unconfirmed mails for admin
1368 function generateUnconfirmedAdminLink ($id, $unconfirmed, $type = 'bid') {
1370 $OUT = $unconfirmed;
1372 // Do we have unconfirmed mails?
1373 if ($unconfirmed > 0) {
1374 // Add link to list_unconfirmed what-file
1375 $OUT = '<a href="{%url=modules.php?module=admin&what=list_unconfirmed&' . $type . '=' . $id . '%}">{%pipe,translateComma=' . $unconfirmed . '%}</a>';
1382 // Generates a navigation row for listing emails
1383 function addEmailNavigation ($numPages, $offset, $show_form, $colspan, $return=false) {
1384 // Don't do anything if $numPages is 1
1385 if ($numPages == 1) {
1386 // Abort here with empty content
1391 if ($show_form === false) {
1396 for ($page = 1; $page <= $numPages; $page++) {
1397 // Is the page currently selected or shall we generate a link to it?
1398 if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
1399 // Is currently selected, so only highlight it
1400 $NAV .= '<strong>-';
1402 // Open anchor tag and add base URL
1403 $NAV .= '<a href="{%url=modules.php?module=admin&what=' . getWhat() . '&page=' . $page . '&offset=' . $offset;
1405 // Add userid when we shall show all mails from a single member
1406 if ((isGetRequestParameterSet('userid')) && (isValidUserId(getRequestParameter('userid')))) $NAV .= '&userid=' . bigintval(getRequestParameter('userid'));
1408 // Close open anchor tag
1412 if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
1413 // Is currently selected, so only highlight it
1414 $NAV .= '-</strong>';
1420 // Add seperator if we have not yet reached total pages
1421 if ($page < $numPages) {
1427 // Define constants only once
1428 $content['nav'] = $NAV;
1429 $content['span'] = $colspan;
1430 $content['top'] = $TOP;
1432 // Load navigation template
1433 $OUT = loadTemplate('admin_email_nav_row', true, $content);
1435 if ($return === true) {
1436 // Return generated HTML-Code
1444 // Process menu editing form
1445 function adminProcessMenuEditForm ($type, $subMenu) {
1446 // An action is done...
1447 foreach (postRequestParameter('sel') as $sel => $menu) {
1448 $AND = "(`what` = '' OR `what` IS NULL)";
1450 $sel = bigintval($sel);
1452 if (!empty($subMenu)) {
1453 $AND = "`action`='" . $subMenu . "'";
1456 switch (postRequestParameter('ok')) {
1457 case 'edit': // Edit menu
1458 if (postRequestParameter('sel_what', $sel) == '') {
1459 // Update with 'what'=null
1460 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s', `action`='%s', `what`=NULL WHERE ".$AND." AND `id`=%s LIMIT 1",
1464 postRequestParameter('sel_action', $sel),
1466 ), __FILE__, __LINE__);
1468 // Update with selected 'what'
1469 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s', `action`='%s', `what`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
1473 postRequestParameter('sel_action', $sel),
1474 postRequestParameter('sel_what', $sel),
1476 ), __FILE__, __LINE__);
1480 case 'delete': // Delete menu
1481 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
1482 array($type, $sel), __FILE__, __LINE__);
1485 case 'status': // Change status of menus
1486 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `visible`='%s', `locked`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
1487 array($type, postRequestParameter('visible', $sel), postRequestParameter('locked', $sel), $sel), __FILE__, __LINE__);
1490 default: // Unexpected action
1491 logDebugMessage(__FILE__, __LINE__, sprintf("Unsupported action %s detected.", postRequestParameter('ok')));
1492 displayMessage(getMaskedMessage('ADMIN_UNKNOWN_OKAY', postRequestParameter('ok')));
1498 displayMessage('{--SETTINGS_SAVED--}');
1501 // Handle weightning
1502 function doAdminProcessMenuWeightning ($type, $AND) {
1503 // Are there all required (generalized) GET parameter?
1504 if ((isGetRequestParameterSet('act')) && (isGetRequestParameterSet('tid')) && (isGetRequestParameterSet('fid'))) {
1506 $tid = ''; $fid = '';
1509 if (isGetRequestParameterSet('w')) {
1510 // Sub menus selected
1511 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
1514 getRequestParameter('act'),
1515 bigintval(getRequestParameter('tid'))
1516 ), __FILE__, __LINE__);
1517 list($tid) = SQL_FETCHROW($result);
1518 SQL_FREERESULT($result);
1519 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
1522 getRequestParameter('act'),
1523 bigintval(getRequestParameter('fid'))
1524 ), __FILE__, __LINE__);
1525 list($fid) = SQL_FETCHROW($result);
1526 SQL_FREERESULT($result);
1528 // Main menu selected
1529 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
1532 bigintval(getRequestParameter('tid'))
1533 ), __FILE__, __LINE__);
1534 list($tid) = SQL_FETCHROW($result);
1535 SQL_FREERESULT($result);
1536 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
1539 bigintval(getRequestParameter('fid'))
1540 ), __FILE__, __LINE__);
1541 list($fid) = SQL_FETCHROW($result);
1542 SQL_FREERESULT($result);
1545 if ((!empty($tid)) && (!empty($fid))) {
1547 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
1550 bigintval(getRequestParameter('tid')),
1552 ), __FILE__, __LINE__);
1553 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
1556 bigintval(getRequestParameter('fid')),
1558 ), __FILE__, __LINE__);