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, 2010 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
78 // Get admin id from login
79 $adminId = getAdminId($adminLogin);
81 // Continue only with found admin ids
83 // Then we need to lookup the login name by getting the admin hash
84 $adminHash = getAdminHash($adminId);
86 // If this is fine, we can continue
87 if ($adminHash != '-1') {
88 // Get admin id and set it as current
89 setCurrentAdminId($adminId);
91 // Now, we need to encode the password in the same way the one is encoded in database
92 $testHash = generateHash($adminPassword, $adminHash);
94 // If they both match, the login data is valid
95 if ($testHash == $adminHash) {
105 // Prepare data array
108 'login' => $adminLogin,
109 'plain_pass' => $adminPassword,
110 'pass_hash' => $adminHash
113 // Run a special filter
114 runFilterChain('do_admin_login_' . $ret, $data);
120 // Only be executed on cookie checking
121 function ifAdminCookiesAreValid ($adminLogin, $passHash) {
122 // First of all, no admin login is found
125 // Then we need to lookup the login name by getting the admin hash
126 $adminHash = getAdminHash($adminLogin);
128 // If this is fine, we can continue
129 if ($adminHash != '-1') {
130 // Now, we need to encode the password in the same way the one is encoded in database
131 $testHash = encodeHashForCookie($adminHash);
132 //* DEBUG: */ debugOutput('adminLogin=' . $adminLogin . ',passHash='.$passHash.',adminHash='.$adminHash.',testHash='.$testHash);
134 // If they both match, the login data is valid
135 if ($testHash == $passHash) {
145 //* DEBUG: */ debugOutput('ret='.$ret);
149 // Do an admin action
150 function doAdminAction () {
154 //* DEBUG: */ debugOutput(__LINE__.'*'.$what.'/'.getModule().'/'.getAction().'/'.getWhat().'*');
156 // Remove any spaces from variable
158 // Default admin action is the overview page
162 $what = secureString($what);
166 $action = getActionFromModuleWhat(getModule(), $what);
168 // Load welcome template
169 if (isExtensionActive('admins')) {
170 // @TODO This and the next getCurrentAdminId() call might be moved into the templates?
171 $content['welcome'] = loadTemplate('admin_welcome_admins', true, getCurrentAdminId());
173 $content['welcome'] = loadTemplate('admin_welcome', true, getCurrentAdminId());
176 // Load header, footer, render menu
177 $content['header'] = loadTemplate('admin_header' , true, $content);
178 $content['footer'] = loadTemplate('admin_footer' , true, $content);
179 $content['menu'] = addAdminMenu($action, $what, true);
182 loadTemplate('admin_main_header', false, $content);
184 // Check if action/what pair is valid
185 $result_action = SQL_QUERY_ESC("SELECT
188 `{?_MYSQL_PREFIX?}_admin_menu`
193 `what`='%s' AND `what` != 'overview'
196 `what`='' OR `what` IS NULL
207 ), __FUNCTION__, __LINE__);
209 // Do we have an entry?
210 if (SQL_NUMROWS($result_action) == 1) {
211 // Is valid but does the inlcude file exists?
212 $inc = sprintf("inc/modules/admin/action-%s.php", $action);
213 if ((isIncludeReadable($inc)) && (isMenuActionValid('admin', $action, $what)) && ($GLOBALS['acl_allow'] === true)) {
214 // Ok, we finally load the admin action module
216 } elseif ($GLOBALS['acl_allow'] === false) {
218 loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACCESS_DENIED', $what));
220 // Include file not found! :-(
221 loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACTION_404', $action));
224 // Invalid action/what pair found!
225 loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACTION_INVALID', $action . '/' . $what));
229 SQL_FREERESULT($result_action);
232 loadTemplate('admin_main_footer', false, $content);
235 // Adds an admin menu
236 function addAdminMenu ($action, $what, $return=false) {
242 $GLOBALS['menu']['description'] = array();
243 $GLOBALS['menu']['title'] = array();
246 $result_main = SQL_QUERY("SELECT
247 `action`, `title`, `descr`
249 `{?_MYSQL_PREFIX?}_admin_menu`
251 (`what`='' OR `what` IS NULL)
254 `id` DESC", __FUNCTION__, __LINE__);
256 // Do we have entries?
257 if (!SQL_HASZERONUMS($result_main)) {
258 $OUT .= '<ul class="admin_menu_main">';
259 // @TODO Rewrite this to $content = SQL_FETCHARRAY()
260 while (list($menu, $title, $descr) = SQL_FETCHROW($result_main)) {
261 if (isExtensionInstalledAndNewer('admins', '0.2.0')) {
262 $ACL = adminsCheckAdminAcl($menu, '');
264 // @TODO ACL is 'allow'... hmmm
269 $inc = sprintf("inc/modules/admin/action-%s.php", $menu);
271 // Is the file readable?
272 $readable = isIncludeReadable($inc);
275 if ($SUB === false) {
276 // Insert compiled menu title and description
277 $GLOBALS['menu']['title'][$menu] = $title;
278 $GLOBALS['menu']['description'][$menu] = $descr;
280 $OUT .= '<li class="admin_menu">
281 <div class="nobr"><strong>·</strong> ';
283 if ($readable === true) {
284 if (($menu == $action) && (empty($what))) {
287 $OUT .= '[<a href="{%url=modules.php?module=admin&action=' . $menu . '%}">';
290 $OUT .= '<em style="cursor:help" class="notice" title="{%message,MENU_ACTION_404=' . $menu . '}">';
295 if ($readable === true) {
296 if (($menu == $action) && (empty($what))) {
308 // Check for menu entries
309 $result_what = SQL_QUERY_ESC("SELECT
310 `what`, `title`, `descr`
312 `{?_MYSQL_PREFIX?}_admin_menu`
320 array($menu), __FUNCTION__, __LINE__);
322 // Remember the count for later checks
323 setAdminMenuHasEntries($menu, ((!SQL_HASZERONUMS($result_what)) && ($action == $menu)));
325 // Do we have entries?
326 if ((ifAdminMenuHasEntries($menu)) && (!SQL_HASZERONUMS($result_what))) {
327 $GLOBALS['menu']['description'] = array();
328 $GLOBALS['menu']['title'] = array(); $SUB = true;
329 $OUT .= '<li class="admin_menu_sub"><ul class="admin_menu_sub">';
330 // @TODO Rewrite this to $content = SQL_FETCHARRAY()
331 while (list($what_sub, $title_what, $desc_what) = SQL_FETCHROW($result_what)) {
332 // Check for access level
333 if (isExtensionInstalledAndNewer('admins', '0.2.0')) {
334 $ACL = adminsCheckAdminAcl('', $what_sub);
336 // @TODO ACL is 'allow'... hmmm
341 $inc = sprintf("inc/modules/admin/what-%s.php", $what_sub);
343 // Is the file readable?
344 $readable = isIncludeReadable($inc);
348 // Insert compiled title and description
349 $GLOBALS['menu']['title'][$what_sub] = $title_what;
350 $GLOBALS['menu']['description'][$what_sub] = $desc_what;
351 $OUT .= '<li class="admin_menu">
352 <div class="nobr"><strong>--></strong> ';
353 if ($readable === true) {
354 if ($what == $what_sub) {
357 $OUT .= '[<a href="{%url=modules.php?module=admin&what=' . $what_sub . '%}">';
360 $OUT .= '<em style="cursor:help" class="notice" title="{%message,MENU_WHAT_404=' . $what_sub . '%}">';
365 if ($readable === true) {
366 if ($what == $what_sub) {
380 SQL_FREERESULT($result_what);
388 SQL_FREERESULT($result_main);
392 // Is there a cache instance again?
393 // Return or output content?
394 if ($return === true) {
401 // Create member selection box
402 function addMemberSelectionBox ($def = 0, $add_all = false, $return = false, $none = false, $field = 'userid') {
403 // Output selection form with all confirmed user accounts listed
404 $result = SQL_QUERY("SELECT `userid`, `surname`, `family` FROM `{?_MYSQL_PREFIX?}_user_data` ORDER BY `userid` ASC", __FUNCTION__, __LINE__);
409 // USe this only for adding points (e.g. adding refs really makes no sence ;-) )
410 if ($add_all === true) $OUT = ' <option value="all">{--ALL_MEMBERS--}</option>';
411 elseif ($none === true) $OUT = ' <option value="0">{--SELECT_NONE--}</option>';
413 while ($content = SQL_FETCHARRAY($result)) {
414 $OUT .= '<option value="' . bigintval($content['userid']) . '"';
415 if ($def == $content['userid']) $OUT .= ' selected="selected"';
416 $OUT .= '>' . $content['surname'] . ' ' . $content['family'] . ' (' . bigintval($content['userid']) . ')</option>';
420 SQL_FREERESULT($result);
422 if ($return === false) {
423 // Remeber options in constant
424 $content['form_selection'] = $OUT;
425 $content['what'] = getWhat();
428 loadTemplate('admin_form_selection_box', false, $content);
430 // Return content in selection frame
431 return '<select class="form_select" name="' . handleFieldWithBraces($field) . '" size="1">' . $OUT . '</select>';
435 // Create a menu selection box for given menu system
436 // @TODO Try to rewrite this to adminAddMenuSelectionBox()
438 function adminMenuSelectionBox_DEPRECATED ($mode, $default = '', $defid = '') {
439 $what = "`what` != ''";
440 if ($mode == 'action') $what = "(`what`='' OR `what` IS NULL) AND `action` !='login'";
442 $result = SQL_QUERY_ESC("SELECT `%s` AS `menu`, `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$what." ORDER BY `sort` ASC",
443 array($mode), __FUNCTION__, __LINE__);
444 if (!SQL_HASZERONUMS($result)) {
445 // Load menu as selection
446 $OUT = '<select name="' . $mode . '_menu';
447 if ((!empty($defid)) || ($defid == '0')) $OUT .= '[' . $defid . ']';
448 $OUT .= '" size="1" class="form_select">
449 <option value="">{--SELECT_NONE--}</option>';
451 while ($content = SQL_FETCHARRAY($result)) {
452 $OUT .= '<option value="' . $content['menu'] . '"';
453 if ((!empty($default)) && ($default == $content['menu'])) $OUT .= ' selected="selected"';
454 $OUT .= '>' . $content['title'] . '</option>';
458 SQL_FREERESULT($result);
460 // Add closing select-tag
464 $OUT = '{--ADMIN_PROBLEM_NO_MENU--}';
471 // Wrapper for $_POST and adminSaveSettings
472 function adminSaveSettingsFromPostData ($tableName = '_config', $whereStatement = '`config`=0', $translateComma = array(), $alwaysAdd = false, $displayMessage = true) {
474 $postData = postRequestArray();
476 // Call the lower function
477 adminSaveSettings($postData, $tableName, $whereStatement, $translateComma, $alwaysAdd, $displayMessage);
480 // Save settings to the database
481 function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement = '`config`=0', $translateComma = array(), $alwaysAdd = false, $displayMessage = true) {
482 // Prepare all arrays, variables
483 $tableData = array();
486 // Now, walk through all entries and prepare them for saving
487 foreach ($postData as $id => $val) {
488 // Process only formular field but not submit buttons ;)
490 // Do not save the ok value
491 convertSelectionsToTimestamp($postData, $tableData, $id, $skip);
493 // Shall we process this id? It muss not be empty, of course
494 if (($skip === false) && (!empty($id)) && ((!isset($GLOBALS['skip_config'][$id]))) || ($tableName != '_config')) {
495 // Translate the value? (comma to dot!)
496 if ((is_array($translateComma)) && (in_array($id, $translateComma))) {
497 // Then do it here... :)
498 $val = convertCommaToDot($val);
501 // Shall we add numbers or strings?
502 $test = (float) $val;
503 if ('' . $val . '' == '' . $test . '') {
505 $tableData[] = sprintf("`%s`=%s", $id, $test);
506 } elseif (is_null($val)) {
508 $tableData[] = sprintf("`%s`=NULL", $id);
511 $tableData[] = sprintf("`%s`='%s'", $id, trim($val));
514 // Do not add a config entry twice
515 $GLOBALS['skip_config'][$id] = true;
517 // Update current configuration
518 setConfigEntry($id, $val);
523 // Check if entry does exist
525 if ($alwaysAdd === false) {
526 if (!empty($whereStatement)) {
527 $result = SQL_QUERY("SELECT * FROM `{?_MYSQL_PREFIX?}" . $tableName . "` WHERE " . $whereStatement . " LIMIT 1", __FUNCTION__, __LINE__);
529 $result = SQL_QUERY("SELECT * FROM `{?_MYSQL_PREFIX?}" . $tableName . "` LIMIT 1", __FUNCTION__, __LINE__);
533 if (SQL_NUMROWS($result) == 1) {
534 // "Implode" all data to single string
535 $updatedData = implode(', ', $tableData);
537 // Generate SQL string
538 $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}%s` SET %s WHERE %s LIMIT 1",
544 // Add Line (does only work with auto_increment!
545 $keys = array(); $values = array();
546 foreach ($tableData as $entry) {
548 $line = explode('=', $entry);
550 $values[] = $line[1];
553 // Add both in one line
554 $keys = implode('`, `', $keys);
555 $values = implode(', ', $values);
557 // Generate SQL string
558 $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}%s` (%s) VALUES (%s)",
566 SQL_FREERESULT($result);
568 // Simply run generated SQL string
569 SQL_QUERY($sql, __FUNCTION__, __LINE__);
571 // Remember affected rows
572 $affected = SQL_AFFECTEDROWS();
575 rebuildCache('config', 'config');
577 // Settings saved, so display message?
578 if ($displayMessage === true) loadTemplate('admin_settings_saved', false, '{--SETTINGS_SAVED--}');
580 // Return affected rows
584 // Generate a selection box
585 function adminAddMenuSelectionBox ($menu, $type, $name, $default = '') {
586 // Open the requested menu directory
587 $menuArray = getArrayFromDirectory(sprintf("inc/modules/%s/", $menu), $type . '-', false, false);
589 // Init the selection box
590 $OUT = '<select name="' . $name . '" class="form_select" size="1"><option value="">{--ADMIN_IS_TOP_MENU--}</option>';
592 // Walk through all files
593 foreach ($menuArray as $file) {
594 // Is this a PHP script?
595 if ((!isDirectory($file)) && (strpos($file, '' . $type . '-') > -1) && (strpos($file, '.php') > 0)) {
596 // Then test if the file is readable
597 $test = sprintf("inc/modules/%s/%s", $menu, $file);
599 // Is the file there?
600 if (isIncludeReadable($test)) {
601 // Extract the value for what=xxx
602 $part = substr($file, (strlen($type) + 1));
603 $part = substr($part, 0, -4);
605 // Is that part different from the overview?
606 if ($part != 'overview') {
607 $OUT .= '<option value="' . $part . '"';
608 if ($part == $default) $OUT .= ' selected="selected"';
609 $OUT .= '>' . $part . '</option>';
615 // Close selection box
622 // Creates a user-profile link for the admin. This function can also be used for many other purposes
623 function generateUserProfileLink ($userid, $title = '', $what = 'list_user') {
624 if (($title == '') && (isValidUserId($userid))) {
625 // Set userid as title
627 } elseif ($userid == 0) {
628 // User id zero is invalid
629 return '<strong>' . $userid . '</strong>';
632 if (($title == '0') && ($what == 'list_refs')) {
633 // Return title again
635 } elseif (isExtensionActive('nickname')) {
637 $nick = getNickname($userid);
639 // Is it not empty, use it as title else the userid
640 if (!empty($nick)) $title = $nick . '(' . $userid . ')'; else $title = $userid;
644 return '[<a href="{%url=modules.php?module=admin&what=' . $what . '&userid=' . $userid . '%}" title="{--ADMIN_USER_PROFILE_TITLE--}">' . $title . '</a>]';
647 // Check "logical-area-mode"
648 function adminGetMenuMode () {
649 // Set the default menu mode as the mode for all admins
650 $mode = getAdminMenu();
654 $adminId = getCurrentAdminId();
656 // Check individual settings of current admin
657 if (isset($GLOBALS['cache_array']['admin']['la_mode'][$adminId])) {
659 $adminMode = $GLOBALS['cache_array']['admin']['la_mode'][$adminId];
660 incrementStatsEntry('cache_hits');
661 } elseif (isExtensionInstalledAndNewer('admins', '0.6.7')) {
662 // Load from database when version of 'admins' is enough
663 $result = SQL_QUERY_ESC("SELECT `la_mode` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
664 array($adminId), __FUNCTION__, __LINE__);
666 // Do we have an entry?
667 if (SQL_NUMROWS($result) == 1) {
669 list($adminMode) = SQL_FETCHROW($result);
673 SQL_FREERESULT($result);
676 // Check what the admin wants and set it when it's not the default mode
677 if ($adminMode != 'global') {
681 // Return admin-menu's mode
685 // Change activation status
686 function adminChangeActivationStatus ($IDs, $table, $row, $idRow = 'id') {
687 $count = '0'; $newStatus = 'Y';
688 if ((is_array($IDs)) && (count($IDs) > 0)) {
689 // "Walk" all through and count them
690 foreach ($IDs as $id => $selected) {
691 // Secure the id number
692 $id = bigintval($id);
694 // Should always be set... ;-)
695 if (!empty($selected)) {
696 // Determine new status
697 $result = SQL_QUERY_ESC("SELECT %s FROM `{?_MYSQL_PREFIX?}_%s` WHERE %s=%s LIMIT 1",
698 array($row, $table, $idRow, $id), __FUNCTION__, __LINE__);
701 if (SQL_NUMROWS($result) == 1) {
703 list($currStatus) = SQL_FETCHROW($result);
705 // And switch it N<->Y
706 if ($currStatus == 'Y') $newStatus = 'N'; else $newStatus = 'Y';
708 // Change this status
709 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s` SET %s='%s' WHERE %s=%s LIMIT 1",
710 array($table, $row, $newStatus, $idRow, $id), __FUNCTION__, __LINE__);
712 // Count up affected rows
713 $count += SQL_AFFECTEDROWS();
717 SQL_FREERESULT($result);
722 loadTemplate('admin_settings_saved', false, sprintf(getMessage('ADMIN_STATUS_CHANGED'), $count, count($IDs)));
725 loadTemplate('admin_settings_saved', false, '{--ADMIN_NOTHING_SELECTED_CHANGE--}');
729 // Send mails for del/edit/lock build modes
730 function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '', $userid = 'userid') {
731 // Default subject is the subject part
732 $subject = $subjectPart;
734 // Is the subject part not set?
735 if (empty($subjectPart)) {
736 // Then use it from the mode
737 $subject = strtoupper($mode);
740 // Is the raw userid set?
741 if (postRequestParameter($userid, $id) > 0) {
742 // Load email template
743 if (!empty($subjectPart)) {
744 $mail = loadEmailTemplate('member_' . $mode . '_' . strtolower($subjectPart) . '_' . $table, $content);
746 $mail = loadEmailTemplate('member_' . $mode . '_' . $table, $content);
750 sendEmail(postRequestParameter($userid, $id), strtoupper('{--MEMBER_' . $subject . '_' . $table . '_SUBJECT--}'), $mail);
754 $subject = strtoupper('{--ADMIN_' . $subject . '_' . $table . '_SUBJECT--}');
756 // Send admin notification out
757 if (!empty($subjectPart)) {
758 sendAdminNotification($subject, 'admin_' . $mode . '_' . strtolower($subjectPart) . '_' . $table, $content, postRequestParameter($userid, $id));
760 sendAdminNotification($subject, 'admin_' . $mode . '_' . $table, $content, postRequestParameter($userid, $id));
764 // Build a special template list
765 function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $userid = 'userid') {
768 // "Walk"Â through all entries
769 foreach ($IDs as $id => $selected) {
771 $id = bigintval($id);
773 // Get result from a given column array and table name
774 $result = SQL_RESULT_FROM_ARRAY($table, $columns, $idColumn, $id, __FUNCTION__, __LINE__);
776 // Is there one entry?
777 if (SQL_NUMROWS($result) == 1) {
779 $content = SQL_FETCHARRAY($result);
782 foreach ($content as $key => $value) {
784 $idx = array_search($key, $columns, true);
786 //Â Do we have a userid?
787 if ($key == $userIdColumn) {
788 // Add it again as raw id
789 $content[$userIdColumn] = bigintval($value);
790 $content[$userIdColumn . '_raw'] = $content[$userIdColumn];
793 // If the key matches the idColumn variable, we need to temporary remember it
794 //* DEBUG: */ debugOutput('key=' . $key . ',idColumn=' . $idColumn . ',value=' . $value);
795 if ($key == $idColumn) {
796 // Found, so remember it
797 $GLOBALS['admin_list_builder_id_value'] = $value;
800 // Handle the call in external function
801 //* DEBUG: */ debugOutput('key=' . $key . ',fucntion=' . $filterFunctions[$idx] . ',value=' . $value);
802 $content[$key] = handleExtraValues($filterFunctions[$idx], $value, $extraValues[$idx]);
806 $OUT .= loadTemplate(sprintf("admin_%s_%s_row",
814 SQL_FREERESULT($result);
817 // Load master template
818 loadTemplate(sprintf("admin_%s_%s",
825 // Change status of "build" list
826 function adminBuilderStatusHandler ($mode, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray, $userid = 'userid') {
827 // All valid entries? (We hope so here!)
828 if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues)) && (count($statusArray) > 0)) {
829 // "Walk" through all entries
830 foreach ($IDs as $id => $sel) {
831 // Construct SQL query
832 $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}_%s` SET", SQL_ESCAPE($table));
834 // Load data of entry
835 $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
836 array($table, $idColumn, $id), __FUNCTION__, __LINE__);
839 $content = SQL_FETCHARRAY($result);
842 SQL_FREERESULT($result);
844 // Add all status entries (e.g. status column last_updated or so)
845 $newStatus = 'UNKNOWN';
846 $oldStatus = 'UNKNOWN';
847 $statusColumn = 'unknown';
848 foreach ($statusArray as $column => $statusInfo) {
849 // Does the entry exist?
850 if ((isset($content[$column])) && (isset($statusInfo[$content[$column]]))) {
851 // Add these entries for update
852 $sql .= sprintf(" %s='%s',", SQL_ESCAPE($column), SQL_ESCAPE($statusInfo[$content[$column]]));
855 if ($statusColumn == 'unknown') {
856 // Always (!!!) change status column first!
857 $oldStatus = $content[$column];
858 $newStatus = $statusInfo[$oldStatus];
859 $statusColumn = $column;
861 } elseif (isset($content[$column])) {
863 debug_report_bug(__FUNCTION__, __LINE__, ':UNFINISHED: id=' . $id . ',column=' . $column . '[' . gettype($statusInfo) . '] = ' . $content[$column]);
867 // Add other columns as well
868 foreach (postRequestArray() as $key => $entries) {
870 logDebugMessage(__FUNCTION__, __LINE__, 'Found entry: ' . $key);
872 // Skip id, raw userid and 'do_$mode'
873 if (!in_array($key, array($idColumn, $userid, ('do_' . $mode)))) {
874 // Are there brackets () at the end?
875 if (substr($entries[$id], -2, 2) == '()') {
876 // Direct SQL command found
877 $sql .= sprintf(" %s=%s,", SQL_ESCAPE($key), SQL_ESCAPE($entries[$id]));
880 $sql .= sprintf(" %s='%s',", SQL_ESCAPE($key), SQL_ESCAPE($entries[$id]));
883 $content[$key] = $entries[$id];
887 logDebugMessage(__FUNCTION__, __LINE__, 'Skipped: ' . $key);
891 // Finish SQL statement
892 $sql = substr($sql, 0, -1) . sprintf(" WHERE `%s`=%s AND `%s`='%s' LIMIT 1",
900 SQL_QUERY($sql, __FUNCTION__, __LINE__);
902 // Do we have an URL?
903 if (isset($content['url'])) {
904 // Then add a framekiller test as well
905 $content['frametester'] = generateFrametesterUrl($content['url']);
908 // Send "build mails" out
909 sendAdminBuildMails($mode, $table, $content, $id, $statusInfo[$content[$column]]);
914 // Delete rows by given id numbers
915 function adminDeleteEntriesConfirm ($IDs, $table, $columns = array(), $filterFunctions = array(), $extraValues = array(), $deleteNow = false, $idColumn = 'id', $userIdColumn = 'userid', $userid = 'userid') {
916 // All valid entries? (We hope so here!)
917 if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues))) {
918 // Shall we delete here or list for deletion?
919 if ($deleteNow === true) {
920 // The base SQL command:
921 $sql = "DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s` IN (%s)";
925 foreach ($IDs as $id => $sel) {
926 // Is there a userid?
927 if (isPostRequestParameterSet($userid, $id)) {
928 // Load all data from that id
929 $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
934 ), __FUNCTION__, __LINE__);
937 $content = SQL_FETCHARRAY($result);
940 SQL_FREERESULT($result);
942 // Send "build mails" out
943 sendAdminBuildMails('delete', $table, $content, $id);
947 $idList .= $id . ',';
951 SQL_QUERY_ESC($sql, array($table, $idColumn, substr($idList, 0, -1)), __FUNCTION__, __LINE__);
954 if (SQL_AFFECTEDROWS() == count($IDs)) {
956 loadTemplate('admin_settings_saved', false, '{--ADMIN_ALL_ENTRIES_REMOVED--}');
958 // Some are still there :(
959 loadTemplate('admin_settings_saved', false, sprintf(getMessage('ADMIN_SOME_ENTRIES_NOT_DELETED'), SQL_AFFECTEDROWS(), count($IDs)));
962 // List for deletion confirmation
963 adminListBuilder('delete', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
968 // Edit rows by given id numbers
969 function adminEditEntriesConfirm ($IDs, $table, $columns = array(), $filterFunctions = array(), $extraValues = array(), $editNow = false, $idColumn = 'id', $userIdColumn = 'userid', $userid = 'userid') {
970 // All valid entries? (We hope so here!)
971 if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues))) {
972 // Shall we change here or list for editing?
973 if ($editNow === true) {
976 foreach ($IDs as $id => $sel) {
977 // Prepare content array (new values)
980 // Prepare SQL for this row
981 $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}_%s` SET",
984 foreach (postRequestArray() as $key => $entries) {
985 // Skip raw userid which is always invalid
986 if ($key == $userid) {
987 // Continue with next field
991 // Is entries an array?
992 if (($key != $idColumn) && (is_array($entries)) && (isset($entries[$id]))) {
993 // Add this entry to content
994 $content[$key] = $entries[$id];
996 // Send data through the filter function if found
997 if ((isset($filterFunctions[$key])) && (isset($extraValues[$key]))) {
998 // Filter function set!
999 $entries[$id] = handleExtraValues($filterFunctions[$key], $entries[$id], $extraValues[$key]);
1002 // Then add this value
1003 $sql .= sprintf(" `%s`='%s',",
1005 SQL_ESCAPE($entries[$id])
1007 } elseif (($key != $idColumn) && (!is_array($entries))) {
1008 // Add normal entries as well!
1009 $content[$key] = $entries;
1012 // Do we have an URL?
1013 if ($key == 'url') {
1014 // Then add a framekiller test as well
1015 $content['frametester'] = generateFrametesterUrl($content[$key]);
1019 // Finish SQL command
1020 $sql = substr($sql, 0, -1) . " WHERE `" . $idColumn . "`=" . bigintval($id) . " LIMIT 1";
1023 SQL_QUERY($sql, __FUNCTION__, __LINE__);
1025 // Add affected rows
1026 $affected += SQL_AFFECTEDROWS();
1028 // Load all data from that id
1029 $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
1030 array($table, $idColumn, $id), __FUNCTION__, __LINE__);
1032 // Fetch the data and merge it into $content
1033 $content = merge_array($content, SQL_FETCHARRAY($result));
1036 SQL_FREERESULT($result);
1038 // Send "build mails" out
1039 sendAdminBuildMails('edit', $table, $content, $id);
1043 if ($affected == count($IDs)) {
1045 loadTemplate('admin_settings_saved', false, '{--ADMIN_ALL_ENTRIES_EDITED--}');
1047 // Some are still there :(
1048 loadTemplate('admin_settings_saved', false, sprintf(getMessage('ADMIN_SOME_ENTRIES_NOT_EDITED'), $affected, count($IDs)));
1052 adminListBuilder('edit', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
1057 // Un-/lock rows by given id numbers
1058 function adminLockEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctions=array(), $extraValues=array(), $statusArray=array(), $lockNow=false, $idColumn='id', $userIdColumn='userid') {
1059 // All valid entries? (We hope so here!)
1060 if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues)) && (($lockNow === false) || (count($statusArray) == 1))) {
1061 // Shall we un-/lock here or list for locking?
1062 if ($lockNow === true) {
1064 adminBuilderStatusHandler('lock', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray);
1067 adminListBuilder('lock', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
1072 // Undelete rows by given id numbers
1073 function adminUndeleteEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctions=array(), $extraValues=array(), $statusArray=array(), $undeleteNow=false, $idColumn='id', $userIdColumn='userid') {
1074 // All valid entries? (We hope so here!)
1075 if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues)) && (($undeleteNow === false) || (count($statusArray) == 1))) {
1076 // Shall we un-/lock here or list for locking?
1077 if ($undeleteNow === true) {
1079 adminBuilderStatusHandler('undelete', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray);
1082 adminListBuilder('undelete', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
1087 // Checks proxy settins by fetching check-updates3.php from www.mxchange.org
1088 function adminTestProxySettings ($settingsArray) {
1089 // Set temporary the new settings
1090 mergeConfig($settingsArray);
1092 // Now get the test URL
1093 $content = sendGetRequest('check-updates3.php');
1095 // Is the first line with "200 OK"?
1096 $valid = (strpos($content[0], '200 OK') !== false);
1102 // Sends out a link to the given email adress so the admin can reset his/her password
1103 function sendAdminPasswordResetLink ($email) {
1107 //Â Look up administator login
1108 $result = SQL_QUERY_ESC("SELECT `id`, `login`, `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `email`='%s' LIMIT 1",
1109 array($email), __FUNCTION__, __LINE__);
1111 // Is there an account?
1112 if (SQL_HASZERONUMS($result)) {
1113 // No account found!
1114 return '{--ADMIN_NO_LOGIN_WITH_EMAIL--}';
1118 $content = SQL_FETCHARRAY($result);
1121 SQL_FREERESULT($result);
1123 // Generate hash for reset link
1124 $content['hash'] = generateHash(getUrl() . ':' . $content['id'] . ':' . $content['login'] . ':' . $content['password'], substr($content['password'], 10));
1127 unset($content['id']);
1128 unset($content['password']);
1131 $mailText = loadEmailTemplate('form_reset_password', $content);
1134 sendEmail($email, '{--ADMIN_RESET_PASS_LINK_SUBJECT--}', $mailText);
1137 return '{--ADMIN_RESET_LINK_SENT--}';
1140 // Validate hash and login for password reset
1141 function adminResetValidateHashLogin ($hash, $login) {
1142 // By default nothing validates... ;)
1145 // Then try to find that user
1146 $result = SQL_QUERY_ESC("SELECT `id`, `password`, `email` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
1147 array($login), __FUNCTION__, __LINE__);
1149 // Is an account here?
1150 if (SQL_NUMROWS($result) == 1) {
1152 $content = SQL_FETCHARRAY($result);
1154 // Generate hash again
1155 $hashFromData = generateHash(getUrl() . ':' . $content['id'] . ':' . $login . ':' . $content['password'], substr($content['password'], 10));
1158 $valid = ($hash == $hashFromData);
1162 SQL_FREERESULT($result);
1168 // Reset the password for the login. Do NOT call this function without calling above function first!
1169 function doResetAdminPassword ($login, $password) {
1170 // Generate hash (we already check for sql_patches in generateHash())
1171 $passHash = generateHash($password);
1174 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `password`='%s' WHERE `login`='%s' LIMIT 1",
1175 array($passHash, $login), __FUNCTION__, __LINE__);
1178 runFilterChain('post_form_reset_pass', array('login' => $login, 'hash' => $passHash));
1181 return '{--ADMIN_PASSWORD_RESET_DONE--}';
1184 // Solves a task by given id number
1185 function adminSolveTask ($id) {
1186 // Update the task data
1187 adminUpdateTaskData($id, 'status', 'SOLVED');
1190 // Marks a given task as deleted
1191 function adminDeleteTask ($id) {
1192 // Update the task data
1193 adminUpdateTaskData($id, 'status', 'DELETED');
1196 // Function to update task data
1197 function adminUpdateTaskData ($id, $row, $data) {
1200 // Not an admin so redirect better
1201 redirectToUrl('modules.php?module=index');
1204 // Is the id not set, then we need a backtrace here... :(
1206 // Initiate backtrace
1207 debug_report_bug(__FUNCTION__, __LINE__, sprintf("id is invalid: %s. row=%s, data=%s",
1215 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `%s`='%s' WHERE `id`=%s LIMIT 1",
1220 ), __FUNCTION__, __LINE__);
1223 // Checks wether if the admin menu has entries
1224 function ifAdminMenuHasEntries ($action) {
1227 // Is the entry set?
1228 isset($GLOBALS['admin_menu_has_entries'][$action])
1230 // And do we have a menu for this action?
1231 $GLOBALS['admin_menu_has_entries'][$action] === true
1233 // Login has always a menu
1239 // Setter for 'admin_menu_has_entries'
1240 function setAdminMenuHasEntries ($action, $hasEntries) {
1241 $GLOBALS['admin_menu_has_entries'][$action] = (bool) $hasEntries;
1244 // Creates a link to the user's admin-profile
1245 function adminCreateUserLink ($userid) {
1246 // Is the userid set correctly?
1247 if (isValidUserId($userid)) {
1248 // Create a link to that profile
1249 return '{%url=modules.php?module=admin&what=list_user&userid=' . bigintval($userid) . '%}';
1252 // Return a link to the user list
1253 return '{%url=modules.php?module=admin&what=list_user%}';
1256 // Generate a "link" for the given admin id (admin_id)
1257 function generateAdminLink ($adminId) {
1258 // No assigned admin is default
1259 $adminLink = '<span class="notice">{--ADMIN_NO_ADMIN_ASSIGNED--}</span>';
1261 // Zero? = Not assigned
1262 if (bigintval($adminId) > 0) {
1263 // Load admin's login
1264 $login = getAdminLogin($adminId);
1266 // Is the login valid?
1267 if ($login != '***') {
1268 // Is the extension there?
1269 if (isExtensionActive('admins')) {
1271 $adminLink = '<a href="' . generateEmailLink(getAdminEmail($adminId), 'admins') . '" title="{--ADMIN_CONTACT_LINK_TITLE--}">' . $login . '</a>';
1273 // Extension not found
1274 $adminLink = getMaskedMessage('ADMIN_TASK_ROW_EXTENSION_NOT_INSTALLED', 'admins');
1278 $adminLink = '<div class="notice">' . getMaskedMessage('ADMIN_ID_404', $adminId) . '</div>';
1286 // Verifies if the current admin has confirmed to alter expert settings
1289 // 'failed' = Something goes wrong (default)
1290 // 'agreed' = Has verified and and confirmed it to see them
1291 // 'forbidden' = Has not the proper right to alter them
1292 // 'update' = Need to update extension 'admins'
1293 // 'ask' = A form was send to the admin
1294 function doVerifyExpertSettings () {
1295 // Default return status is failed
1298 // Is the extension installed and recent?
1299 if (isExtensionInstalledAndNewer('admins', '0.7.3')) {
1300 // Okay, load the status
1301 $expertSettings = getAminsExpertSettings();
1304 if ($expertSettings == 'Y') {
1305 // Okay, does he want to see them?
1306 if (getAminsExpertWarning() == 'Y') {
1309 // Is the element set, then we need to change the admin
1310 if (isPostRequestParameterSet('expert_settings')) {
1311 // Get it and prepare final post data array
1312 $postData['login'][getCurrentAdminId()] = getCurrentAdminLogin();
1313 $postData['expert_warning'][getCurrentAdminId()] = 'N';
1315 // Change it in the admin
1316 adminsChangeAdminAccount($postData, 'expert_warning');
1319 unsetPostRequestParameter('ok');
1326 loadTemplate('admin_expert_settings_form');
1337 $return = 'forbidden';
1340 // Out-dated extension or not installed
1344 // Output message for other status than ask/agreed
1345 if (($return != 'ask') && ($return != 'agreed')) {
1347 loadTemplate('admin_settings_saved', false, '{--ADMIN_EXPERT_SETTINGS_STATUS_' . strtoupper($return) . '--}');
1354 // Generate link to unconfirmed mails for admin
1355 function generateUnconfirmedAdminLink ($id, $unconfirmed, $type = 'bid') {
1357 $OUT = $unconfirmed;
1359 // Do we have unconfirmed mails?
1360 if ($unconfirmed > 0) {
1361 // Add link to list_unconfirmed what-file
1362 $OUT = '<a href="{%url=modules.php?module=admin&what=list_unconfirmed&' . $type . '=' . $id . '%}">{%pipe,translateComma=' . $unconfirmed . '%}</a>';
1369 // Generates a navigation row for listing emails
1370 function addEmailNavigation ($numPages, $offset, $show_form, $colspan, $return=false) {
1371 // Don't do anything if $numPages is 1
1372 if ($numPages == 1) {
1373 // Abort here with empty content
1378 if ($show_form === false) {
1383 for ($page = 1; $page <= $numPages; $page++) {
1384 // Is the page currently selected or shall we generate a link to it?
1385 if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
1386 // Is currently selected, so only highlight it
1387 $NAV .= '<strong>-';
1389 // Open anchor tag and add base URL
1390 $NAV .= '<a href="{%url=modules.php?module=admin&what=' . getWhat() . '&page=' . $page . '&offset=' . $offset;
1392 // Add userid when we shall show all mails from a single member
1393 if ((isGetRequestParameterSet('userid')) && (isValidUserId(getRequestParameter('userid')))) $NAV .= '&userid=' . bigintval(getRequestParameter('userid'));
1395 // Close open anchor tag
1399 if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
1400 // Is currently selected, so only highlight it
1401 $NAV .= '-</strong>';
1407 // Add seperator if we have not yet reached total pages
1408 if ($page < $numPages) {
1414 // Define constants only once
1415 $content['nav'] = $NAV;
1416 $content['span'] = $colspan;
1417 $content['top'] = $TOP;
1419 // Load navigation template
1420 $OUT = loadTemplate('admin_email_nav_row', true, $content);
1422 if ($return === true) {
1423 // Return generated HTML-Code
1431 // Process menu editing form
1432 function adminProcessMenuEditForm ($type, $subMenu) {
1433 // An action is done...
1434 foreach (postRequestParameter('sel') as $sel => $menu) {
1435 $AND = "(`what` = '' OR `what` IS NULL)";
1437 $sel = bigintval($sel);
1439 if (!empty($subMenu)) {
1440 $AND = "`action`='" . $subMenu . "'";
1443 switch (postRequestParameter('ok')) {
1444 case 'edit': // Edit menu
1445 if (postRequestParameter('sel_what', $sel) == '') {
1446 // Update with 'what'=null
1447 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s', `action`='%s', `what`=NULL WHERE ".$AND." AND `id`=%s LIMIT 1",
1451 postRequestParameter('sel_action', $sel),
1453 ), __FILE__, __LINE__);
1455 // Update with selected 'what'
1456 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s', `action`='%s', `what`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
1460 postRequestParameter('sel_action', $sel),
1461 postRequestParameter('sel_what', $sel),
1463 ), __FILE__, __LINE__);
1467 case 'delete': // Delete menu
1468 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
1469 array($type, $sel), __FILE__, __LINE__);
1472 case 'status': // Change status of menus
1473 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `visible`='%s', `locked`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
1474 array($type, postRequestParameter('visible', $sel), postRequestParameter('locked', $sel), $sel), __FILE__, __LINE__);
1477 default: // Unexpected action
1478 logDebugMessage(__FILE__, __LINE__, sprintf("Unsupported action %s detected.", postRequestParameter('ok')));
1479 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_UNKNOWN_OKAY', postRequestParameter('ok')));
1485 loadTemplate('admin_settings_saved', false, '{--SETTINGS_SAVED--}');
1488 // Handle weightning
1489 function doAdminProcessMenuWeightning ($type) {
1490 // Are there all required (generalized) GET parameter?
1491 if ((isGetRequestParameterSet('act')) && (isGetRequestParameterSet('tid')) && (isGetRequestParameterSet('fid'))) {
1493 $tid = ''; $fid = '';
1496 if (isGetRequestParameterSet('w')) {
1497 // Sub menus selected
1498 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
1501 getRequestParameter('act'),
1502 bigintval(getRequestParameter('tid'))
1503 ), __FILE__, __LINE__);
1504 list($tid) = SQL_FETCHROW($result);
1505 SQL_FREERESULT($result);
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('fid'))
1511 ), __FILE__, __LINE__);
1512 list($fid) = SQL_FETCHROW($result);
1513 SQL_FREERESULT($result);
1515 // Main menu selected
1516 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
1519 bigintval(getRequestParameter('tid'))
1520 ), __FILE__, __LINE__);
1521 list($tid) = SQL_FETCHROW($result);
1522 SQL_FREERESULT($result);
1523 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
1526 bigintval(getRequestParameter('fid'))
1527 ), __FILE__, __LINE__);
1528 list($fid) = SQL_FETCHROW($result);
1529 SQL_FREERESULT($result);
1532 if ((!empty($tid)) && (!empty($fid))) {
1534 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
1537 bigintval(getRequestParameter('tid')),
1539 ), __FILE__, __LINE__);
1540 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
1543 bigintval(getRequestParameter('fid')),
1545 ), __FILE__, __LINE__);