2 /************************************************************************
3 * MXChange v0.2.1 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 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Some security stuff...
35 if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
42 function REGISTER_ADMIN ($user, $md5, $email=WEBMASTER)
45 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
46 array($user), __FILE__, __LINE__);
47 if (SQL_NUMROWS($result) == 0) {
48 // Ok, let's create the admin login
49 $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_admins (login, password, email) VALUES('%s', '%s', '%s')",
50 array($user, $md5, $email), __FILE__, __LINE__);
54 SQL_FREERESULT($result);
56 // Login does already exist
61 // Only be executed on login procedure!
62 function CHECK_ADMIN_LOGIN ($admin_login, $password)
64 global $cacheArray, $_CONFIG, $cacheInstance;
65 $ret = "404"; $pass = "";
66 if (!empty($cacheArray['admins']['aid'][$admin_login])) {
67 // Get password from cache
68 $pass = $cacheArray['admins']['password'][$admin_login];
70 $_CONFIG['cache_hits']++;
72 // Get password from DB
73 $result = SQL_QUERY_ESC("SELECT password FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
74 array($admin_login), __FILE__, __LINE__);
75 if (SQL_NUMROWS($result) == 1) {
77 list($pass) = SQL_FETCHROW($result);
78 SQL_FREERESULT($result);
82 //* DEBUG: */ echo "*".$pass."/".md5($password)."/".$ret."<br />";
83 if ((strlen($pass) == 32) && ($pass == md5($password))) {
85 $pass = generateHash($password);
87 // Is the sql_patches not installed, than we cannot have a valid hashed password here!
88 if (($ret == "pass") && ((GET_EXT_VERSION("sql_patches") < "0.3.6") || (GET_EXT_VERSION("sql_patches") == ""))) $ret = "done";
89 } elseif ((GET_EXT_VERSION("sql_patches") < "0.3.6") || (GET_EXT_VERSION("sql_patches") == "")) {
94 // Generate salt of password
95 define('__SALT', substr($pass, 0, -40));
98 // Check if password is same
99 if (($ret == "pass") && ($pass == generateHash($password, $salt)) && (!empty($salt))) {
101 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_admins SET password='%s' WHERE login='%s' LIMIT 1",
102 array($pass, $admin_login), __FILE__, __LINE__);
104 // Shall I remove the cache file?
105 if ((EXT_IS_ACTIVE("cache")) && ($cacheInstance != false)) {
106 if ($cacheInstance->cache_file("admins", true)) $cacheInstance->cache_destroy();
111 } elseif ((empty($salt)) && ($ret == "pass")) {
112 // Something bad went wrong
118 // Only be executed on cookie checking
119 function CHECK_ADMIN_COOKIES ($admin_login, $password) {
120 global $cacheArray, $_CONFIG;
121 $ret = "404"; $pass = "";
122 if (!empty($cacheArray['admins']['aid'][$admin_login])) {
123 // Get password from cache
124 $pass = $cacheArray['admins']['password'][$admin_login];
126 $_CONFIG['cache_hits']++;
128 // Get password from DB
129 $result = SQL_QUERY_ESC("SELECT password FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
130 array($admin_login), __FILE__, __LINE__);
131 if (SQL_NUMROWS($result) == 1) {
136 list($pass) = SQL_FETCHROW($result);
140 SQL_FREERESULT($result);
143 //* DEBUG: */ echo __FUNCTION__.":".$pass."(".strlen($pass).")/".$password."(".strlen($password).")<br />\n";
145 // Check if password matches
146 if (($ret == "pass") && ((generatePassString($pass) == $password) || ($pass == $password) || ((strlen($pass) == 32) && (md5($password) == $pass)))) {
147 // Passwords matches!
155 function admin_WriteData ($file, $comment, $prefix, $suffix, $DATA, $seek=0) {
156 // Initialize some variables
161 // Is the file there and read-/write-able?
162 if ((file_exists($file)) && (is_readable($file)) && (is_writeable($file))) {
163 $search = "CFG: ".$comment;
166 // Open the source file
167 $fp = @fopen($file, 'r') or OUTPUT_HTML("<STRONG>READ:</STRONG> ".$file."<br />");
169 // Is the resource valid?
170 if (is_resource($fp)) {
171 // Open temporary file
172 $fp_tmp = @fopen($tmp, 'w') or OUTPUT_HTML("<STRONG>WRITE:</STRONG> ".$tmp."<br />");
174 // Is the resource again valid?
175 if (is_resource($fp_tmp)) {
177 // Read from source file
178 $line = fgets ($fp, 1024);
180 if (strpos($line, $search) > -1) { $next = 0; $found = true; }
183 if ($next == $seek) {
185 $line = $prefix . $DATA . $suffix."\n";
191 // Write to temp file
192 fputs($fp_tmp, $line);
198 // Finished writing tmp file
205 if (($done) && ($found)) {
206 // Copy back tmp file and delete tmp :-)
209 define('_FATAL', false);
211 OUTPUT_HTML("<STRONG>CHANGE:</STRONG> 404!");
212 define('_FATAL', true);
214 OUTPUT_HTML("<STRONG>TMP:</STRONG> UNDONE!");
215 define('_FATAL', true);
219 // File not found, not readable or writeable
220 OUTPUT_HTML("<STRONG>404:</STRONG> ".$file."<br />");
225 function ADMIN_DO_ACTION($wht)
227 global $menuDesription, $menuTitle, $_CONFIG, $cacheArray, $link, $DATA, $DEPTH;
228 //* DEBUG: */ echo __LINE__."*".$wht."/".$GLOBALS['module']."/".$GLOBALS['action']."/".$GLOBALS['what']."*<br />\n";
229 if (EXT_IS_ACTIVE("cache"))
231 // Include cache instance
232 global $cacheInstance;
235 // Remove any spaces from variable
238 // Default admin action is the overview page
243 // Compile out some chars
244 $wht = COMPILE_CODE($wht, false, false, false);
248 $act = GET_ACTION($GLOBALS['module'], $wht);
250 // Define admin login name and ID number
251 define('__ADMIN_LOGIN', SQL_ESCAPE(get_session('admin_login')));
252 define('__ADMIN_ID' , GET_ADMIN_ID(get_session('admin_login')));
255 if (EXT_IS_ACTIVE("admins")) {
256 define('__ADMIN_WELCOME', LOAD_TEMPLATE("admin_welcome_admins", true));
258 define('__ADMIN_WELCOME', LOAD_TEMPLATE("admin_welcome", true));
260 define('__ADMIN_FOOTER' , LOAD_TEMPLATE("admin_footer" , true));
261 define('__ADMIN_MENU' , ADD_ADMIN_MENU($act, $wht, true));
264 LOAD_TEMPLATE("admin_main_header");
266 // Check if action/what pair is valid
267 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_admin_menu
268 WHERE action='%s' AND ((what='%s' AND what != 'overview') OR (what='' AND '%s'='overview'))
269 LIMIT 1", array($act, $wht, $wht), __FILE__, __LINE__);
270 if (SQL_NUMROWS($result) == 1)
273 SQL_FREERESULT($result);
275 // Is valid but does the inlcude file exists?
276 $INC = sprintf(PATH."inc/modules/admin/action-%s.php", $act);
277 if ((file_exists($INC)) && (is_readable($INC)) && (VALIDATE_MENU_ACTION("admin", $act, $wht)) && (__ACL_ALLOW == true))
279 // Ok, we finally load the admin action module
282 elseif (__ACL_ALLOW == false)
285 LOAD_TEMPLATE("admin_menu_failed", false, ADMINS_ACCESS_DENIED);
286 ADD_FATAL(ADMINS_ACCESS_DENIED);
290 // Include file not found! :-(
291 LOAD_TEMPLATE("admin_menu_failed", false, ADMIN_404_ACTION);
292 ADD_FATAL(ADMIN_404_ACTION_1.$act.ADMIN_404_ACTION_2);
295 // Invalid action/what pair found!
296 LOAD_TEMPLATE("admin_menu_failed", false, ADMIN_INVALID_ACTION);
297 ADD_FATAL(ADMIN_INVALID_ACTION_1.$act."/".$wht.ADMIN_INVALID_ACTION_2);
301 LOAD_TEMPLATE("admin_main_footer");
304 function ADD_ADMIN_MENU($act, $wht,$return=false)
306 global $menuDesription, $menuTitle, $link;
310 $menuDesription = array();
311 $menuTitle = array();
314 $result_main = SQL_QUERY("SELECT action, title, descr FROM "._MYSQL_PREFIX."_admin_menu WHERE what='' ORDER BY sort, id DESC", __FILE__, __LINE__);
316 if (SQL_NUMROWS($result_main) > 0)
318 $OUT = "<TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"admin_menu_main\">
319 <TR><TD colspan=\"2\" height=\"7\" class=\"seperator\"> </TD></TR>\n";
320 while (list($menu, $title, $descr) = SQL_FETCHROW($result_main))
322 if ((EXT_IS_ACTIVE("admins")) && (GET_EXT_VERSION("admins") > "0.2"))
324 $ACL = ADMINS_CHECK_ACL($menu, "");
328 // ACL is "allow"... hmmm
335 // Insert compiled menu title and description
336 $menuTitle[$menu] = $title;
337 $menuDesription[$menu] = $descr;
340 <TD class=\"admin_menu\" colspan=\"2\">
341 <NOBR> <STRONG>·</STRONG> ";
342 if (($menu == $act) && (empty($wht)))
348 $OUT .= "[ <A href=\"".URL."/modules.php?module=admin&action=".$menu."\">";
351 if (($menu == $act) && (empty($wht)))
357 $OUT .= "</A> ]";
359 $OUT .= "</NOBR></TD>
361 $result_what = SQL_QUERY_ESC("SELECT what, title, descr FROM "._MYSQL_PREFIX."_admin_menu WHERE action='%s' AND what != '' ORDER BY sort, id DESC",
362 array($menu), __FILE__, __LINE__);
363 if ((SQL_NUMROWS($result_what) > 0) && ($act == $menu))
365 $menuDesription = array();
366 $menuTitle = array(); $SUB = true;
368 <TD width=\"10\" class=\"seperator\"> </TD>
369 <TD class=\"admin_menu\">
370 <TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"admin_menu_sub\">\n";
371 while (list($wht_sub, $title_what, $desc_what) = SQL_FETCHROW($result_what))
374 $INC = sprintf(PATH."inc/modules/admin/what-%s.php", $wht_sub);
375 if ((EXT_IS_ACTIVE("admins")) && (GET_EXT_VERSION("admins") > "0.2"))
377 $ACL = ADMINS_CHECK_ACL("", $wht_sub);
381 // ACL is "allow"... hmmm
384 $readable = ((file_exists($INC)) && (is_readable($INC)));
387 // Insert compiled title and description
388 $menuTitle[$wht_sub] = $title_what;
389 $menuDesription[$wht_sub] = $desc_what;
391 <TD class=\"admin_menu\" colspan=\"2\">
392 <NOBR> <STRONG>--></STRONG> ";
395 if ($wht == $wht_sub)
401 $OUT .= "[ <A href=\"".URL."/modules.php?module=admin&what=".$wht_sub."\">";
406 $OUT .= "<I class=\"admin_note\">";
411 if ($wht == $wht_sub)
417 $OUT .= "</A> ]";
424 $OUT .= "</NOBR></TD>
430 SQL_FREERESULT($result_what);
435 $OUT .= "<TR><TD height=\"7\" colspan=\"2\"></TD></TR>\n";
440 SQL_FREERESULT($result_main);
441 $OUT .= "</TABLE>\n";
444 // Compile and run the code here. This inserts all constants into the
445 // HTML output. Costs me some time to figure this out... *sigh* Quix0r
446 $eval = "\$OUT = \"".COMPILE_CODE(addslashes($OUT))."\";";
449 // Return or output content?
457 function ADD_MEMBER_SELECTION_BOX($add_all = false, $return = false, $none = false, $def = "0")
459 // Output selection form with all confirmed user accounts listed
460 $result = SQL_QUERY("SELECT userid, surname, family FROM "._MYSQL_PREFIX."_user_data ORDER BY userid", __FILE__, __LINE__);
463 // USe this only for adding points (e.g. adding refs really makes no sence ;-) )
464 if ($add_all) $OUT = " <OPTION value=\"all\">".ALL_MEMBERS."</OPTION>\n";
465 elseif ($none) $OUT = " <OPTION value=\"0\">".SELECT_NONE."</OPTION>\n";
466 while (list($id, $sname, $fname) = SQL_FETCHROW($result))
468 $OUT .= " <OPTION value=\"".$id."\"";
469 if ($def == $id) $OUT .= " selected=\"selected\"";
470 $OUT .= ">".$sname." ".$fname." (".$id.")</OPTION>\n";
474 SQL_FREERESULT($result);
476 // Remeber options in constant
477 define('_MEMBER_SELECTION', $OUT);
480 // Display selection box
481 define('__LANG_VALUE', GET_LANGUAGE());
484 LOAD_TEMPLATE("admin_member_selection_box", false, $GLOBALS['what']);
488 function ADMIN_MENU_SELECTION($MODE, $default="", $defid="") {
490 if ($MODE == "action") $wht = "what='' AND action !='login'";
491 $result = SQL_QUERY_ESC("SELECT %s, title FROM "._MYSQL_PREFIX."_admin_menu WHERE ".$wht." ORDER BY sort",
492 array($MODE), __FILE__, __LINE__);
493 if (SQL_NUMROWS($result) > 0)
495 // Load menu as selection
496 $OUT = "<SELECT name=\"".$MODE."_menu";
497 if ((!empty($defid)) || ($defid == "0")) $OUT .= "[".$defid."]";
498 $OUT .= "\" size=\"1\" class=\"admin_select\">
499 <OPTION value=\"\">".SELECT_NONE."</OPTION>\n";
500 while (list($menu, $title) = SQL_FETCHROW($result))
502 $OUT .= " <OPTION value=\"".$menu."\"";
503 if ((!empty($default)) && ($default == $menu)) $OUT .= " selected=\"selected\"";
504 $OUT .= ">".$title."</OPTION>\n";
508 SQL_FREERESULT($result);
509 $OUT .= "</SELECT>\n";
514 $OUT = ADMIN_PROBLEM_NO_MENU;
521 function ADMIN_SAVE_SETTINGS (&$POST, $tableName="_config", $whereStatement="config=0", $translateComma = array(), $alwaysAdd=false)
523 global $_CONFIG, $cacheArray, $cacheInstance;
525 $skip = false; $TEST2 = "";
526 foreach ($POST as $id=>$val) {
527 // Process only formular field but not submit buttons ;)
529 // Do not save the ok value
530 $TEST = substr($id, -3);
531 if ((($TEST == "_ye") || ($TEST == "_mo") || ($TEST == "_we") || ($TEST == "_da") || ($TEST == "_ho") || ($TEST == "_mi") || ($TEST == "_se")) && (isset($val))) {
532 // Found a multi-selection for timings?
533 $TEST = substr($id, 0, -3);
534 if ((isset($POST[$TEST."_ye"])) && (isset($POST[$TEST."_mo"])) && (isset($POST[$TEST."_we"])) && (isset($POST[$TEST."_da"])) && (isset($POST[$TEST."_ho"])) && (isset($POST[$TEST."_mi"])) && (isset($POST[$TEST."_se"])) && ($TEST != $TEST2)) {
535 // Generate timestamp
536 $POST[$TEST] = CREATE_TIMESTAMP_FROM_SELECTIONS($TEST, $POST);
537 $DATA[] = "$TEST='".$POST[$TEST]."'";
539 // Remove data from array
540 unset($POST[$TEST."_ye"]);
541 unset($POST[$TEST."_mo"]);
542 unset($POST[$TEST."_we"]);
543 unset($POST[$TEST."_da"]);
544 unset($POST[$TEST."_ho"]);
545 unset($POST[$TEST."_mi"]);
546 unset($POST[$TEST."_se"]);
549 unset($id); $skip = true; $TEST2 = $TEST;
552 // Process this entry
553 $skip = false; $TEST2 = "";
556 // Shall we process this ID? It muss not be empty, of course
557 if ((!$skip) && (!empty($id))) {
559 $val = COMPILE_CODE($val);
561 // Translate the value? (comma to dot!)
562 if ((is_array($translateComma)) && (in_array($id, $translateComma))) {
563 // Then do it here... :)
564 $val = str_replace(",", ".", $val);
567 // Shall we add numbers or strings?
569 if ("".$val."" == "".$test."") {
571 $DATA[] = $id."=".$val."";
574 $DATA[] = $id."='".trim($val)."'";
577 // Update current configuration
578 $_CONFIG[$id] = $val;
583 // Check if entry does exist
586 if (!empty($whereStatement)) {
587 $result = SQL_QUERY("SELECT * FROM "._MYSQL_PREFIX.$tableName." WHERE ".$whereStatement." LIMIT 1", __FILE__, __LINE__);
589 $result = SQL_QUERY("SELECT * FROM "._MYSQL_PREFIX.$tableName." LIMIT 1", __FILE__, __LINE__);
593 if (SQL_NUMROWS($result) == 1) {
594 // "Implode" all data to single string
595 $DATA_UPDATE = implode(", ", $DATA);
597 // Generate SQL string
598 $SQL = "UPDATE "._MYSQL_PREFIX.$tableName." SET ".$DATA_UPDATE." WHERE ".$whereStatement." LIMIT 1";
600 // Add Line (does only work with auto_increment!
601 $KEYs = array(); $VALUEs = array();
602 foreach ($DATA as $entry) {
604 $line = explode("=", $entry);
605 $KEYs[] = $line[0]; $VALUEs[] = $line[1];
608 // Add both in one line
609 $KEYs = implode(", ", $KEYs);
610 $VALUEs = implode(", ", $VALUEs);
612 // Generate SQL string
613 $SQL = "INSERT INTO "._MYSQL_PREFIX.$tableName." (".$KEYs.") VALUES(".$VALUEs.")";
617 SQL_FREERESULT($result);
619 // Simply run generated SQL string
620 $result = SQL_QUERY($SQL, __FILE__, __LINE__);
622 // Is the config table updated and the cache extension installed?
623 if ((GET_EXT_VERSION("cache") >= "0.1.2") && ($tableName == "_config")) {
625 if ($cacheInstance->cache_file("config", true)) $cacheInstance->cache_destroy();
630 LOAD_TEMPLATE("admin_settings_saved", false, "<STRONG class=\"admin_done\">".SETTINGS_SAVED."</STRONG>");
633 function ADMIN_MAKE_MENU_SELECTION($menu, $type, $name, $default="") {
634 // Init the selection box
635 $OUT = "<SELECT name=\"".$name."\" class=\"admin_select\" size=\"1\">\n <OPTION value=\"\">".IS_TOP_MENU."</OPTION>\n";
637 // Open the requested menu directory
638 $handle = opendir(PATH."inc/modules/".$menu."/") or mxchange_die("Cannot load menu ".$menu."!");
639 while ($file = readdir($handle)) {
640 // Is this a PHP script?
641 if (($file != ".") && ($file != "..") && ($file != "lost+found") && (strpos($file, "".$type."-") > -1) && (strpos($file, ".php") > 0)) {
642 // Then test if the file is readable
643 $test = PATH."inc/modules/".$menu."/".$file;
644 if (is_readable($test)) {
645 // Extract the value for what=xxx
646 $part = substr($file, (strlen($type) + 1)); $part = substr($part, 0, strpos($part, ".php"));
648 // Is that part different from the overview?
649 if ($part != "overview") {
650 $OUT .= " <OPTION value=\"".$part."\"";
651 if ($part == $default) $OUT .= "selected";
652 $OUT .= ">".$part."</OPTION>\n";
658 $OUT .= "</SELECT>\n";
662 function ADMIN_USER_PROFILE_LINK($uid, $title="", $wht="list_user")
664 if (($title == "") && ($title != "0")) { $title = $uid; }
665 if (($title == "0") && ($wht == "list_refs"))
667 // Return title again
671 //* DEBUG: */ echo "A:".$title."<br />";
673 return "<A href=\"".URL."/modules.php?module=admin&what=".$wht."&u_id=".$uid."\" title=\"".ADMIN_USER_PROFILE_TITLE."\">".$title."</A>";
676 function ADMIN_CHECK_MENU_MODE()
678 global $_CONFIG, $cacheArray;
680 // Set the global mode as the mode for all admins
681 $MODE = $_CONFIG['admin_menu']; $ADMIN = $MODE;
683 // Check individual settings of current admin
684 if (isset($cacheArray['admins']['la_mode'][get_session('admin_login')]))
687 $ADMIN = $cacheArray['admins']['la_mode'][get_session('admin_login')];
688 $_CONFIG['cache_hits']++;
690 elseif (GET_EXT_VERSION("admins") >= "0.6.7")
692 // Load from database when version of "admins" is enough
693 $result = SQL_QUERY_ESC("SELECT la_mode FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
694 array(get_session('admin_login')), __FILE__, __LINE__);
695 if (SQL_NUMROWS($result) == 1)
698 list($ADMIN) = SQL_FETCHROW($result);
702 SQL_FREERESULT($result);
705 // Check what the admin wants and set it when it's not the global mode
706 if ($ADMIN != "global") $MODE = $ADMIN;
708 // Return admin-menu's mode
711 // Change activation status
712 function ADMIN_CHANGE_ACTIVATION_STATUS ($IDs, $table, $row, $idRow = "id") {
714 $cnt = 0; $newStatus = 'Y';
715 if ((is_array($IDs)) && (count($IDs) > 0)) {
716 // "Walk" all through and count them
717 foreach ($IDs as $id=>$selected) {
718 // Secure the ID number
719 $id = bigintval($id);
721 // Should always be 1 ;-)
722 if ($selected == 1) {
723 // Determine new status
724 $result = SQL_QUERY_ESC("SELECT %s FROM "._MYSQL_PREFIX."_%s WHERE %s=%d LIMIT 1",
725 array($row, $table, $idRow, $id), __FILE__, __LINE__);
728 if (SQL_NUMROWS($result) == 1) {
730 list($currStatus) = SQL_FETCHROW($result);
731 if ($currStatus == 'Y') $newStatus='N'; else $newStatus = 'Y';
733 // Change this status
734 SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_%s SET %s='%s' WHERE %s=%d LIMIT 1",
735 array($table, $row, $newStatus, $idRow, $id), __FILE__, __LINE__);
737 // Count up affected rows
738 $cnt += SQL_AFFECTEDROWS();
742 SQL_FREERESULT($result);
747 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_STATUS_CHANGED_1.$cnt.ADMIN_STATUS_CHANGED_2.count($IDs).ADMIN_STATUS_CHANGED_3);
750 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NOTHING_SELECTED_CHANGE);
753 // Delete rows by given ID numbers
754 function ADMIN_DELETE_ENTRIES_CONFIRM ($IDs, $table, $row, $columns = array(), $filterFunctions = array(), $deleteNow=false, $idRow="id") {
757 if ((is_array($IDs)) && (count($IDs) > 0)) {
758 // "Walk" through all entries and count them
762 // List for confirmation
763 foreach ($IDs as $id=>$selected) {
765 $id = bigintval($id);
767 // Will always be 1 ;-)
768 if ($selected == 1) {
769 // Get result from a given column array and table name
770 $result = SQL_RESULT_FROM_ARRAY($table, $columns, $idRow, $id);
772 // Is there one entry?
773 if (SQL_NUMROWS($result) == 1) {
775 $content = SQL_FETCHARRAY($result);
778 foreach ($content as $key=>$value) {
779 // Is a filter function set?
780 $idx = array_search($key, $columns, true);
781 if (!empty($filterFunctions[$idx])) {
783 $content[$key] = call_user_func($filterFunctions[$idx], $value);
787 // Add color switching
788 $content['sw'] = $SW;
790 // Then list it again...
791 $OUT .= LOAD_TEMPLATE("admin_del_".$table."_row", true, $content);
796 SQL_FREERESULT($result);
800 // Load master template
801 LOAD_TEMPLATE("admin_del_".$table."", false, $OUT);