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)
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)
49 // Ok, let's create the admin login
50 $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_admins (login, password, email) VALUES('%s', '%s', '".WEBMASTER."')",
51 array($user, $md5), __FILE__, __LINE__);
57 SQL_FREERESULT($result);
59 // Login does already exist
64 // Only be executed on login procedure!
65 function CHECK_ADMIN_LOGIN ($admin_login, $password)
67 global $cacheArray, $_CONFIG, $cacheInstance;
68 $ret = "404"; $pass = "";
69 if (!empty($cacheArray['admins']['aid'][$admin_login]))
71 // Get password from cache
72 $pass = $cacheArray['admins']['password'][$admin_login];
74 $_CONFIG['cache_hits']++;
78 // Get password from DB
79 $result = SQL_QUERY_ESC("SELECT password FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
80 array($admin_login), __FILE__, __LINE__);
81 if (SQL_NUMROWS($result) == 1)
84 list($pass) = SQL_FETCHROW($result);
85 SQL_FREERESULT($result);
89 //* DEBUG: */ echo "*".$pass."/".$password."/".$ret."<br />";
90 if ((strlen($pass) == 32) && ($pass == md5($password)))
93 $pass = generateHash($password);
94 if (($ret == "pass") && (GET_EXT_VERSION("sql_patches") < "0.3.6")) $ret = "done";
96 elseif ((GET_EXT_VERSION("sql_patches") < "0.3.6") || (GET_EXT_VERSION("sql_patches") == ""))
102 // Generate salt of password
103 define('__SALT', substr($pass, 0, -40));
106 // Check if password is same
107 if (($ret == "pass") && ($pass == generateHash($password, $salt)) && (!empty($salt)))
110 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_admins SET password='%s' WHERE login='%s' LIMIT 1",
111 array($pass, $admin_login), __FILE__, __LINE__);
113 // Shall I remove the cache file?
114 if ((EXT_IS_ACTIVE("cache")) && ($cacheInstance != false))
116 if ($cacheInstance->cache_file("admins", true)) $cacheInstance->cache_destroy();
122 elseif ((empty($salt)) && ($ret == "pass"))
124 // Something bad went wrong
129 // Only be executed on cookie checking
130 function CHECK_ADMIN_COOKIES ($admin_login, $password) {
131 global $cacheArray, $_CONFIG;
133 // Get login and password hash
134 $admin_login = SQL_ESCAPE(get_session($admin_login));
135 $password = SQL_ESCAPE(get_session($password));
137 $ret = "404"; $pass = "";
138 if (!empty($cacheArray['admins']['aid'][$admin_login])) {
139 // Get password from cache
140 $pass = $cacheArray['admins']['password'][$admin_login];
142 $_CONFIG['cache_hits']++;
144 // Get password from DB
145 $result = SQL_QUERY_ESC("SELECT password FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
146 array($admin_login), __FILE__, __LINE__);
147 if (SQL_NUMROWS($result) == 1) {
149 list($pass) = SQL_FETCHROW($result);
150 SQL_FREERESULT($result);
154 //* DEBUG: */ echo "*".$pass."/".$password."<br />";
156 // Check if password matches
157 if (($ret == "pass") && ((generatePassString($pass) == $password) || ($pass == $password))) {
158 // Passwords matches!
166 function admin_WriteData ($file, $comment, $prefix, $suffix, $DATA, $seek=0)
168 $done = false; $seek++; $found = false;
169 if (file_exists($file))
171 $search = "CFG: ".$comment;
173 $fp = fopen($file, 'r') or OUTPUT_HTML("<STRONG>READ:</STRONG> ".$file."<br />");
176 $fp_tmp = fopen($tmp, 'w') or OUTPUT_HTML("<STRONG>WRITE:</STRONG> ".$tmp."<br />");
181 $line = fgets ($fp, 1024);
182 if (strpos($line, $search) > -1) { $next = 0; $found = true; }
188 $line = $prefix . $DATA . $suffix."\n";
195 fputs($fp_tmp, $line);
198 // Finished writing tmp file
202 if (($done) && ($found))
204 // Copy back tmp file and delete tmp :-)
207 define ('_FATAL', false);
211 OUTPUT_HTML("<STRONG>CHANGE:</STRONG> 404!");
212 define ('_FATAL', true);
216 OUTPUT_HTML("<STRONG>TMP:</STRONG> UNDONE!");
217 define ('_FATAL', true);
223 OUTPUT_HTML("<STRONG>404:</STRONG> ".$file."<br />");
227 function ADMIN_DO_ACTION($wht)
229 global $menuDesription, $menuTitle, $_CONFIG, $cacheArray, $link, $DATA;
230 //* DEBUG: */ echo __LINE__."*".$wht."/".$GLOBALS['module']."/".$GLOBALS['action']."/".$GLOBALS['what']."*<br />\n";
231 if (EXT_IS_ACTIVE("cache"))
233 // Include cache instance
234 global $cacheInstance;
237 // Remove any spaces from variable
240 // Default admin action is the overview page
245 // Compile out some chars
246 $wht = COMPILE_CODE($wht, false, false, false);
250 $act = GET_ACTION($GLOBALS['module'], $wht);
252 // Define admin login name and ID number
253 define('__ADMIN_LOGIN', SQL_ESCAPE(get_session('admin_login')));
254 define('__ADMIN_ID' , GET_ADMIN_ID(get_session('admin_login')));
257 if (EXT_IS_ACTIVE("admins")) {
258 define('__ADMIN_WELCOME', LOAD_TEMPLATE("admin_welcome_admins", true));
260 define('__ADMIN_WELCOME', LOAD_TEMPLATE("admin_welcome", true));
262 define('__ADMIN_FOOTER' , LOAD_TEMPLATE("admin_footer" , true));
263 define('__ADMIN_MENU' , ADD_ADMIN_MENU($act, $wht, true));
266 LOAD_TEMPLATE("admin_main_header");
268 // Check if action/what pair is valid
269 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_admin_menu
270 WHERE action='%s' AND ((what='%s' AND what != 'overview') OR (what='' AND '%s'='overview'))
271 LIMIT 1", array($act, $wht, $wht), __FILE__, __LINE__);
272 if (SQL_NUMROWS($result) == 1)
275 SQL_FREERESULT($result);
277 // Is valid but does the inlcude file exists?
278 $INC = sprintf(PATH."inc/modules/admin/action-%s.php", $act);
279 if ((file_exists($INC)) && (is_readable($INC)) && (VALIDATE_MENU_ACTION("admin", $act, $wht)) && (__ACL_ALLOW == true))
281 // Ok, we finally load the admin action module
284 elseif (__ACL_ALLOW == false)
287 LOAD_TEMPLATE("admin_menu_failed", false, ADMINS_ACCESS_DENIED);
288 ADD_FATAL(ADMINS_ACCESS_DENIED);
292 // Include file not found! :-(
293 LOAD_TEMPLATE("admin_menu_failed", false, ADMIN_404_ACTION);
294 ADD_FATAL(ADMIN_404_ACTION_1.$act.ADMIN_404_ACTION_2);
297 // Invalid action/what pair found!
298 LOAD_TEMPLATE("admin_menu_failed", false, ADMIN_INVALID_ACTION);
299 ADD_FATAL(ADMIN_INVALID_ACTION_1.$act."/".$wht.ADMIN_INVALID_ACTION_2);
303 LOAD_TEMPLATE("admin_main_footer");
306 function ADD_ADMIN_MENU($act, $wht,$return=false)
308 global $menuDesription, $menuTitle, $link;
312 $menuDesription = array();
313 $menuTitle = array();
316 $result_main = SQL_QUERY("SELECT action, title, descr FROM "._MYSQL_PREFIX."_admin_menu WHERE what='' ORDER BY sort, id DESC", __FILE__, __LINE__);
318 if (SQL_NUMROWS($result_main) > 0)
320 $OUT = "<TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"admin_menu_main\">
321 <TR><TD colspan=\"2\" height=\"7\" class=\"seperator\"> </TD></TR>\n";
322 while (list($menu, $title, $descr) = SQL_FETCHROW($result_main))
324 if ((EXT_IS_ACTIVE("admins")) && (GET_EXT_VERSION("admins") > "0.2"))
326 $ACL = ADMINS_CHECK_ACL($menu, "");
330 // ACL is "allow"... hmmm
337 // Insert compiled menu title and description
338 $menuTitle[$menu] = $title;
339 $menuDesription[$menu] = $descr;
342 <TD class=\"admin_menu\" colspan=\"2\">
343 <NOBR> <STRONG>·</STRONG> ";
344 if (($menu == $act) && (empty($wht)))
350 $OUT .= "[ <A href=\"".URL."/modules.php?module=admin&action=".$menu."\">";
353 if (($menu == $act) && (empty($wht)))
359 $OUT .= "</A> ]";
361 $OUT .= "</NOBR></TD>
363 $result_what = SQL_QUERY_ESC("SELECT what, title, descr FROM "._MYSQL_PREFIX."_admin_menu WHERE action='%s' AND what != '' ORDER BY sort, id DESC",
364 array($menu), __FILE__, __LINE__);
365 if ((SQL_NUMROWS($result_what) > 0) && ($act == $menu))
367 $menuDesription = array();
368 $menuTitle = array(); $SUB = true;
370 <TD width=\"10\" class=\"seperator\"> </TD>
371 <TD class=\"admin_menu\">
372 <TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"admin_menu_sub\">\n";
373 while (list($wht_sub, $title_what, $desc_what) = SQL_FETCHROW($result_what))
376 $INC = sprintf(PATH."inc/modules/admin/what-%s.php", $wht_sub);
377 if ((EXT_IS_ACTIVE("admins")) && (GET_EXT_VERSION("admins") > "0.2"))
379 $ACL = ADMINS_CHECK_ACL("", $wht_sub);
383 // ACL is "allow"... hmmm
386 $readable = ((file_exists($INC)) && (is_readable($INC)));
389 // Insert compiled title and description
390 $menuTitle[$wht_sub] = $title_what;
391 $menuDesription[$wht_sub] = $desc_what;
393 <TD class=\"admin_menu\" colspan=\"2\">
394 <NOBR> <STRONG>--></STRONG> ";
397 if ($wht == $wht_sub)
403 $OUT .= "[ <A href=\"".URL."/modules.php?module=admin&what=".$wht_sub."\">";
408 $OUT .= "<I class=\"admin_note\">";
413 if ($wht == $wht_sub)
419 $OUT .= "</A> ]";
426 $OUT .= "</NOBR></TD>
432 SQL_FREERESULT($result_what);
437 $OUT .= "<TR><TD height=\"7\" colspan=\"2\"></TD></TR>\n";
442 SQL_FREERESULT($result_main);
443 $OUT .= "</TABLE>\n";
446 // Compile and run the code here. This inserts all constants into the
447 // HTML output. Costs me some time to figure this out... *sigh* Quix0r
448 $eval = "\$OUT = \"".COMPILE_CODE(addslashes($OUT))."\";";
451 // Return or output content?
459 function ADD_MEMBER_SELECTION_BOX($add_all = false, $return = false, $none = false, $def = "0")
461 // Output selection form with all confirmed user accounts listed
462 $result = SQL_QUERY("SELECT userid, surname, family FROM "._MYSQL_PREFIX."_user_data ORDER BY userid", __FILE__, __LINE__);
465 // USe this only for adding points (e.g. adding refs really makes no sence ;-) )
466 if ($add_all) $OUT = " <OPTION value=\"all\">".ALL_MEMBERS."</OPTION>\n";
467 elseif ($none) $OUT = " <OPTION value=\"0\">".SELECT_NONE."</OPTION>\n";
468 while (list($id, $sname, $fname) = SQL_FETCHROW($result))
470 $OUT .= " <OPTION value=\"".$id."\"";
471 if ($def == $id) $OUT .= " selected=\"selected\"";
472 $OUT .= ">".$sname." ".$fname." (".$id.")</OPTION>\n";
476 SQL_FREERESULT($result);
478 // Remeber options in constant
479 define('_MEMBER_SELECTION', $OUT);
482 // Display selection box
483 define('__LANG_VALUE', GET_LANGUAGE());
486 LOAD_TEMPLATE("admin_member_selection_box", false, $GLOBALS['what']);
490 function ADMIN_MENU_SELECTION($MODE, $default="", $defid="") {
492 if ($MODE == "action") $wht = "what='' AND action !='login'";
493 $result = SQL_QUERY_ESC("SELECT %s, title FROM "._MYSQL_PREFIX."_admin_menu WHERE ".$wht." ORDER BY sort",
494 array($MODE), __FILE__, __LINE__);
495 if (SQL_NUMROWS($result) > 0)
497 // Load menu as selection
498 $OUT = "<SELECT name=\"".$MODE."_menu";
499 if ((!empty($defid)) || ($defid == "0")) $OUT .= "[".$defid."]";
500 $OUT .= "\" size=\"1\" class=\"admin_select\">
501 <OPTION value=\"\">".SELECT_NONE."</OPTION>\n";
502 while (list($menu, $title) = SQL_FETCHROW($result))
504 $OUT .= " <OPTION value=\"".$menu."\"";
505 if ((!empty($default)) && ($default == $menu)) $OUT .= " selected=\"selected\"";
506 $OUT .= ">".$title."</OPTION>\n";
510 SQL_FREERESULT($result);
511 $OUT .= "</SELECT>\n";
516 $OUT = ADMIN_PROBLEM_NO_MENU;
523 function ADMIN_SAVE_SETTINGS (&$POST, $tableName="_config", $whereStatement="config=0", $translateComma = array(), $alwaysAdd=false)
525 global $_CONFIG, $cacheArray, $cacheInstance;
527 $skip = false; $TEST2 = "";
528 foreach ($POST as $id=>$val) {
529 // Process only formular field but not submit buttons ;)
531 // Do not save the ok value
532 $TEST = substr($id, -3);
533 if ((($TEST == "_ye") || ($TEST == "_mo") || ($TEST == "_we") || ($TEST == "_da") || ($TEST == "_ho") || ($TEST == "_mi") || ($TEST == "_se")) && (isset($val))) {
534 // Found a multi-selection for timings?
535 $TEST = substr($id, 0, -3);
536 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)) {
537 // Generate timestamp
538 $POST[$TEST] = CREATE_TIMESTAMP_FROM_SELECTIONS($TEST, $POST);
539 $DATA[] = "$TEST='".$POST[$TEST]."'";
541 // Remove data from array
542 unset($POST[$TEST."_ye"]);
543 unset($POST[$TEST."_mo"]);
544 unset($POST[$TEST."_we"]);
545 unset($POST[$TEST."_da"]);
546 unset($POST[$TEST."_ho"]);
547 unset($POST[$TEST."_mi"]);
548 unset($POST[$TEST."_se"]);
551 unset($id); $skip = true; $TEST2 = $TEST;
554 // Process this entry
555 $skip = false; $TEST2 = "";
558 // Shall we process this ID? It muss not be empty, of course
559 if ((!$skip) && (!empty($id))) {
561 $val = COMPILE_CODE($val);
563 // Translate the value? (comma to dot!)
564 if ((is_array($translateComma)) && (in_array($id, $translateComma))) {
565 // Then do it here... :)
566 $val = str_replace(",", ".", $val);
569 // Shall we add numbers or strings?
571 if ("".$val."" == "".$test."") {
573 $DATA[] = $id."=".$val."";
576 $DATA[] = $id."='".trim($val)."'";
579 // Update current configuration
580 $_CONFIG[$id] = $val;
585 // Check if entry does exist
588 if (!empty($whereStatement)) {
589 $result = SQL_QUERY("SELECT * FROM "._MYSQL_PREFIX.$tableName." WHERE ".$whereStatement." LIMIT 1", __FILE__, __LINE__);
591 $result = SQL_QUERY("SELECT * FROM "._MYSQL_PREFIX.$tableName." LIMIT 1", __FILE__, __LINE__);
595 if (SQL_NUMROWS($result) == 1) {
596 // "Implode" all data to single string
597 $DATA_UPDATE = implode(", ", $DATA);
599 // Generate SQL string
600 $SQL = "UPDATE "._MYSQL_PREFIX.$tableName." SET ".$DATA_UPDATE." WHERE ".$whereStatement." LIMIT 1";
602 // Add Line (does only work with auto_increment!
603 $KEYs = array(); $VALUEs = array();
604 foreach ($DATA as $entry) {
606 $line = explode("=", $entry);
607 $KEYs[] = $line[0]; $VALUEs[] = $line[1];
610 // Add both in one line
611 $KEYs = implode(", ", $KEYs);
612 $VALUEs = implode(", ", $VALUEs);
614 // Generate SQL string
615 $SQL = "INSERT INTO "._MYSQL_PREFIX.$tableName." (".$KEYs.") VALUES(".$VALUEs.")";
619 SQL_FREERESULT($result);
621 // Simply run generated SQL string
622 $result = SQL_QUERY($SQL, __FILE__, __LINE__);
624 // Is the config table updated and the cache extension installed?
625 if ((GET_EXT_VERSION("cache") >= "0.1.2") && ($tableName == "_config")) {
627 if ($cacheInstance->cache_file("config", true)) $cacheInstance->cache_destroy();
632 LOAD_TEMPLATE("admin_settings_saved", false, "<STRONG class=\"admin_done\">".SETTINGS_SAVED."</STRONG>");
635 function ADMIN_MAKE_MENU_SELECTION($menu, $type, $name, $default="") {
636 // Init the selection box
637 $OUT = "<SELECT name=\"".$name."\" class=\"admin_select\" size=\"1\">\n <OPTION value=\"\">".IS_TOP_MENU."</OPTION>\n";
639 // Open the requested menu directory
640 $handle = opendir(PATH."inc/modules/".$menu."/") or mxchange_die("Cannot load menu ".$menu."!");
641 while ($file = readdir($handle)) {
642 // Is this a PHP script?
643 if (($file != ".") && ($file != "..") && ($file != "lost+found") && (strpos($file, "".$type."-") > -1) && (strpos($file, ".php") > 0)) {
644 // Then test if the file is readable
645 $test = PATH."inc/modules/".$menu."/".$file;
646 if (is_readable($test)) {
647 // Extract the value for what=xxx
648 $part = substr($file, (strlen($type) + 1)); $part = substr($part, 0, strpos($part, ".php"));
650 // Is that part different from the overview?
651 if ($part != "overview") {
652 $OUT .= " <OPTION value=\"".$part."\"";
653 if ($part == $default) $OUT .= "selected";
654 $OUT .= ">".$part."</OPTION>\n";
660 $OUT .= "</SELECT>\n";
664 function ADMIN_USER_PROFILE_LINK($uid, $title="", $wht="list_user")
666 if (($title == "") && ($title != "0")) { $title = $uid; }
667 if (($title == "0") && ($wht == "list_refs"))
669 // Return title again
673 //* DEBUG: */ echo "A:".$title."<br />";
675 return "<A href=\"".URL."/modules.php?module=admin&what=".$wht."&u_id=".$uid."\" title=\"".ADMIN_USER_PROFILE_TITLE."\">".$title."</A>";
678 function ADMIN_CHECK_MENU_MODE()
680 global $_CONFIG, $cacheArray;
682 // Set the global mode as the mode for all admins
683 $MODE = $_CONFIG['admin_menu']; $ADMIN = $MODE;
685 // Check individual settings of current admin
686 if (isset($cacheArray['admins']['la_mode'][get_session('admin_login')]))
689 $ADMIN = $cacheArray['admins']['la_mode'][get_session('admin_login')];
690 $_CONFIG['cache_hits']++;
692 elseif (GET_EXT_VERSION("admins") >= "0.6.7")
694 // Load from database when version of "admins" is enough
695 $result = SQL_QUERY_ESC("SELECT la_mode FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
696 array(get_session('admin_login')), __FILE__, __LINE__);
697 if (SQL_NUMROWS($result) == 1)
700 list($ADMIN) = SQL_FETCHROW($result);
704 SQL_FREERESULT($result);
707 // Check what the admin wants and set it when it's not the global mode
708 if ($ADMIN != "global") $MODE = $ADMIN;
710 // Return admin-menu's mode
713 // Change activation status
714 function ADMIN_CHANGE_ACTIVATION_STATUS ($IDs, $table, $row, $idRow = "id") {
716 $cnt = 0; $newStatus = 'Y';
717 if ((is_array($IDs)) && (count($IDs) > 0)) {
718 // "Walk" all through and count them
719 foreach ($IDs as $id=>$selected) {
720 // Secure the ID number
721 $id = bigintval($id);
723 // Should always be 1 ;-)
724 if ($selected == 1) {
725 // Determine new status
726 $result = SQL_QUERY_ESC("SELECT %s FROM "._MYSQL_PREFIX."_%s WHERE %s=%d LIMIT 1",
727 array($row, $table, $idRow, $id), __FILE__, __LINE__);
730 if (SQL_NUMROWS($result) == 1) {
732 list($currStatus) = SQL_FETCHROW($result);
733 if ($currStatus == 'Y') $newStatus='N'; else $newStatus = 'Y';
735 // Change this status
736 SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_%s SET %s='%s' WHERE %s=%d LIMIT 1",
737 array($table, $row, $newStatus, $idRow, $id), __FILE__, __LINE__);
739 // Count up affected rows
740 $cnt += SQL_AFFECTEDROWS();
744 SQL_FREERESULT($result);
749 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_STATUS_CHANGED_1.$cnt.ADMIN_STATUS_CHANGED_2.count($IDs).ADMIN_STATUS_CHANGED_3);
752 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NOTHING_SELECTED_CHANGE);
755 // Delete rows by given ID numbers
756 function ADMIN_DELETE_ENTRIES_CONFIRM ($IDs, $table, $row, $columns = array(), $filterFunctions = array(), $deleteNow=false, $idRow="id") {
759 if ((is_array($IDs)) && (count($IDs) > 0)) {
760 // "Walk" through all entries and count them
764 // List for confirmation
765 foreach ($IDs as $id=>$selected) {
767 $id = bigintval($id);
769 // Will always be 1 ;-)
770 if ($selected == 1) {
771 // Get result from a given column array and table name
772 $result = SQL_RESULT_FROM_ARRAY($table, $columns, $idRow, $id);
774 // Is there one entry?
775 if (SQL_NUMROWS($result) == 1) {
777 $content = SQL_FETCHARRAY($result);
780 foreach ($content as $key=>$value) {
781 // Is a filter function set?
782 $idx = array_search($key, $columns, true);
783 if (!empty($filterFunctions[$idx])) {
785 $content[$key] = call_user_func($filterFunctions[$idx], $value);
789 // Add color switching
790 $content['sw'] = $SW;
792 // Then list it again...
793 $OUT .= LOAD_TEMPLATE("admin_del_".$table."_row", true, $content);
798 SQL_FREERESULT($result);
802 // Load master template
803 LOAD_TEMPLATE("admin_del_".$table."", false, $OUT);