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;
132 $ret = "404"; $pass = "";
133 if (!empty($cacheArray['admins']['aid'][$admin_login])) {
134 // Get password from cache
135 $pass = $cacheArray['admins']['password'][$admin_login];
137 $_CONFIG['cache_hits']++;
139 // Get password from DB
140 $result = SQL_QUERY_ESC("SELECT password FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
141 array($admin_login), __FILE__, __LINE__);
142 if (SQL_NUMROWS($result) == 1) {
144 list($pass) = SQL_FETCHROW($result);
145 SQL_FREERESULT($result);
149 //* DEBUG: */ echo "*".$pass."/".$password."<br />";
151 // Check if password matches
152 if (($ret == "pass") && ((generatePassString($pass) == $password) || ($pass == $password))) {
153 // Passwords matches!
161 function admin_WriteData ($file, $comment, $prefix, $suffix, $DATA, $seek=0)
163 $done = false; $seek++; $found = false;
164 if (file_exists($file))
166 $search = "CFG: ".$comment;
168 $fp = fopen($file, 'r') or OUTPUT_HTML("<STRONG>READ:</STRONG> ".$file."<br />");
171 $fp_tmp = fopen($tmp, 'w') or OUTPUT_HTML("<STRONG>WRITE:</STRONG> ".$tmp."<br />");
176 $line = fgets ($fp, 1024);
177 if (strpos($line, $search) > -1) { $next = 0; $found = true; }
183 $line = $prefix . $DATA . $suffix."\n";
190 fputs($fp_tmp, $line);
193 // Finished writing tmp file
197 if (($done) && ($found))
199 // Copy back tmp file and delete tmp :-)
202 define ('_FATAL', false);
206 OUTPUT_HTML("<STRONG>CHANGE:</STRONG> 404!");
207 define ('_FATAL', true);
211 OUTPUT_HTML("<STRONG>TMP:</STRONG> UNDONE!");
212 define ('_FATAL', true);
218 OUTPUT_HTML("<STRONG>404:</STRONG> ".$file."<br />");
222 function ADMIN_DO_ACTION($wht)
224 global $menuDesription, $menuTitle, $_CONFIG, $cacheArray, $link, $DATA;
225 //* DEBUG: */ echo __LINE__."*".$wht."/".$GLOBALS['module']."/".$GLOBALS['action']."/".$GLOBALS['what']."*<br />\n";
226 if (EXT_IS_ACTIVE("cache"))
228 // Include cache instance
229 global $cacheInstance;
232 // Remove any spaces from variable
235 // Default admin action is the overview page
240 // Compile out some chars
241 $wht = COMPILE_CODE($wht, false, false, false);
245 $act = GET_ACTION($GLOBALS['module'], $wht);
247 // Define admin login name and ID number
248 define('__ADMIN_LOGIN', SQL_ESCAPE($_SESSION['admin_login']));
249 define('__ADMIN_ID' , GET_ADMIN_ID($_SESSION['admin_login']));
252 if (EXT_IS_ACTIVE("admins")) {
253 define('__ADMIN_WELCOME', LOAD_TEMPLATE("admin_welcome_admins", true));
255 define('__ADMIN_WELCOME', LOAD_TEMPLATE("admin_welcome", true));
257 define('__ADMIN_FOOTER' , LOAD_TEMPLATE("admin_footer" , true));
258 define('__ADMIN_MENU' , ADD_ADMIN_MENU($act, $wht, true));
261 LOAD_TEMPLATE("admin_main_header");
263 // Check if action/what pair is valid
264 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_admin_menu
265 WHERE action='%s' AND ((what='%s' AND what != 'overview') OR (what='' AND '%s'='overview'))
266 LIMIT 1", array($act, $wht, $wht), __FILE__, __LINE__);
267 if (SQL_NUMROWS($result) == 1)
270 SQL_FREERESULT($result);
272 // Is valid but does the inlcude file exists?
273 $INC = sprintf(PATH."inc/modules/admin/action-%s.php", $act);
274 if ((file_exists($INC)) && (is_readable($INC)) && (VALIDATE_MENU_ACTION("admin", $act, $wht)) && (__ACL_ALLOW == true))
276 // Ok, we finally load the admin action module
279 elseif (__ACL_ALLOW == false)
282 LOAD_TEMPLATE("admin_menu_failed", false, ADMINS_ACCESS_DENIED);
283 ADD_FATAL(ADMINS_ACCESS_DENIED);
287 // Include file not found! :-(
288 LOAD_TEMPLATE("admin_menu_failed", false, ADMIN_404_ACTION);
289 ADD_FATAL(ADMIN_404_ACTION_1.$act.ADMIN_404_ACTION_2);
292 // Invalid action/what pair found!
293 LOAD_TEMPLATE("admin_menu_failed", false, ADMIN_INVALID_ACTION);
294 ADD_FATAL(ADMIN_INVALID_ACTION_1.$act."/".$wht.ADMIN_INVALID_ACTION_2);
298 LOAD_TEMPLATE("admin_main_footer");
301 function ADD_ADMIN_MENU($act, $wht,$return=false)
303 global $menuDesription, $menuTitle, $link;
307 $menuDesription = array();
308 $menuTitle = array();
311 $result_main = SQL_QUERY("SELECT action, title, descr FROM "._MYSQL_PREFIX."_admin_menu WHERE what='' ORDER BY sort, id DESC", __FILE__, __LINE__);
313 if (SQL_NUMROWS($result_main) > 0)
315 $OUT = "<TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"admin_menu_main\">
316 <TR><TD colspan=\"2\" height=\"7\" class=\"seperator\"> </TD></TR>\n";
317 while (list($menu, $title, $descr) = SQL_FETCHROW($result_main))
319 if ((EXT_IS_ACTIVE("admins")) && (GET_EXT_VERSION("admins") > "0.2"))
321 $ACL = ADMINS_CHECK_ACL($menu, "");
325 // ACL is "allow"... hmmm
332 // Insert compiled menu title and description
333 $menuTitle[$menu] = $title;
334 $menuDesription[$menu] = $descr;
337 <TD class=\"admin_menu\" colspan=\"2\">
338 <NOBR> <STRONG>·</STRONG> ";
339 if (($menu == $act) && (empty($wht)))
345 $OUT .= "[ <A href=\"".URL."/modules.php?module=admin&action=".$menu."\">";
348 if (($menu == $act) && (empty($wht)))
354 $OUT .= "</A> ]";
356 $OUT .= "</NOBR></TD>
358 $result_what = SQL_QUERY_ESC("SELECT what, title, descr FROM "._MYSQL_PREFIX."_admin_menu WHERE action='%s' AND what != '' ORDER BY sort, id DESC",
359 array($menu), __FILE__, __LINE__);
360 if ((SQL_NUMROWS($result_what) > 0) && ($act == $menu))
362 $menuDesription = array();
363 $menuTitle = array(); $SUB = true;
365 <TD width=\"10\" class=\"seperator\"> </TD>
366 <TD class=\"admin_menu\">
367 <TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"admin_menu_sub\">\n";
368 while (list($wht_sub, $title_what, $desc_what) = SQL_FETCHROW($result_what))
371 $INC = sprintf(PATH."inc/modules/admin/what-%s.php", $wht_sub);
372 if ((EXT_IS_ACTIVE("admins")) && (GET_EXT_VERSION("admins") > "0.2"))
374 $ACL = ADMINS_CHECK_ACL("", $wht_sub);
378 // ACL is "allow"... hmmm
381 $readable = ((file_exists($INC)) && (is_readable($INC)));
384 // Insert compiled title and description
385 $menuTitle[$wht_sub] = $title_what;
386 $menuDesription[$wht_sub] = $desc_what;
388 <TD class=\"admin_menu\" colspan=\"2\">
389 <NOBR> <STRONG>--></STRONG> ";
392 if ($wht == $wht_sub)
398 $OUT .= "[ <A href=\"".URL."/modules.php?module=admin&what=".$wht_sub."\">";
403 $OUT .= "<I class=\"admin_note\">";
408 if ($wht == $wht_sub)
414 $OUT .= "</A> ]";
421 $OUT .= "</NOBR></TD>
427 SQL_FREERESULT($result_what);
432 $OUT .= "<TR><TD height=\"7\" colspan=\"2\"></TD></TR>\n";
437 SQL_FREERESULT($result_main);
438 $OUT .= "</TABLE>\n";
441 // Compile and run the code here. This inserts all constants into the
442 // HTML output. Costs me some time to figure this out... *sigh* Quix0r
443 $eval = "\$OUT = \"".COMPILE_CODE(addslashes($OUT))."\";";
446 // Return or output content?
454 function ADD_MEMBER_SELECTION_BOX($add_all = false, $return = false, $none = false, $def = "0")
456 // Output selection form with all confirmed user accounts listed
457 $result = SQL_QUERY("SELECT userid, surname, family FROM "._MYSQL_PREFIX."_user_data ORDER BY userid", __FILE__, __LINE__);
460 // USe this only for adding points (e.g. adding refs really makes no sence ;-) )
461 if ($add_all) $OUT = " <OPTION value=\"all\">".ALL_MEMBERS."</OPTION>\n";
462 elseif ($none) $OUT = " <OPTION value=\"0\">".SELECT_NONE."</OPTION>\n";
463 while (list($id, $sname, $fname) = SQL_FETCHROW($result))
465 $OUT .= " <OPTION value=\"".$id."\"";
466 if ($def == $id) $OUT .= " selected=\"selected\"";
467 $OUT .= ">".$sname." ".$fname." (".$id.")</OPTION>\n";
471 SQL_FREERESULT($result);
473 // Remeber options in constant
474 define('_MEMBER_SELECTION', $OUT);
478 // Display selection box
479 define('__LANG_VALUE', GET_LANGUAGE());
482 LOAD_TEMPLATE("admin_member_selection_box", false, $GLOBALS['what']);
486 function ADMIN_MENU_SELECTION($MODE, $default="", $defid="")
489 if ($MODE == "action") $wht = "what='' AND action !='login'";
490 $result = SQL_QUERY_ESC("SELECT %s, title FROM "._MYSQL_PREFIX."_admin_menu WHERE ".$wht." ORDER BY sort",
491 array($MODE), __FILE__, __LINE__);
492 if (SQL_NUMROWS($result) > 0)
494 // Load menu as selection
495 $OUT = "<SELECT name=\"".$MODE."_menu";
496 if ((!empty($defid)) || ($defid == "0")) $OUT .= "[".$defid."]";
497 $OUT .= "\" size=\"1\" class=\"admin_select\">
498 <OPTION value=\"\">".SELECT_NONE."</OPTION>\n";
499 while (list($menu, $title) = SQL_FETCHROW($result))
501 $OUT .= " <OPTION value=\"".$menu."\"";
502 if ((!empty($default)) && ($default == $menu)) $OUT .= " selected=\"selected\"";
503 $OUT .= ">".$title."</OPTION>\n";
507 SQL_FREERESULT($result);
508 $OUT .= "</SELECT>\n";
513 $OUT = ADMIN_PROBLEM_NO_MENU;
520 function ADMIN_SAVE_SETTINGS (&$POST, $tableName="_config", $whereStatement="config=0", $translateComma = array(), $alwaysAdd=false)
522 global $_CONFIG, $cacheArray, $cacheInstance;
524 $skip = false; $TEST2 = "";
525 foreach ($POST as $id=>$val) {
526 // Process only formular field but not submit buttons ;)
528 // Do not save the ok value
529 $TEST = substr($id, -3);
530 if ((($TEST == "_ye") || ($TEST == "_mo") || ($TEST == "_we") || ($TEST == "_da") || ($TEST == "_ho") || ($TEST == "_mi") || ($TEST == "_se")) && (isset($val))) {
531 // Found a multi-selection for timings?
532 $TEST = substr($id, 0, -3);
533 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)) {
534 // Generate timestamp
535 $POST[$TEST] = CREATE_TIMESTAMP_FROM_SELECTIONS($TEST, $POST);
536 $DATA[] = "$TEST='".$POST[$TEST]."'";
538 // Remove data from array
539 unset($POST[$TEST."_ye"]);
540 unset($POST[$TEST."_mo"]);
541 unset($POST[$TEST."_we"]);
542 unset($POST[$TEST."_da"]);
543 unset($POST[$TEST."_ho"]);
544 unset($POST[$TEST."_mi"]);
545 unset($POST[$TEST."_se"]);
548 unset($id); $skip = true; $TEST2 = $TEST;
551 // Process this entry
552 $skip = false; $TEST2 = "";
555 // Shall we process this ID? It muss not be empty, of course
556 if ((!$skip) && (!empty($id))) {
558 $val = COMPILE_CODE($val);
560 // Translate the value? (comma to dot!)
561 if ((is_array($translateComma)) && (in_array($id, $translateComma))) {
562 // Then do it here... :)
563 $val = str_replace(",", ".", $val);
566 // Shall we add numbers or strings?
568 if ("".$val."" == "".$test."") {
570 $DATA[] = $id."=".$val."";
573 $DATA[] = $id."='".trim($val)."'";
576 // Update current configuration
577 $_CONFIG[$id] = $val;
582 // Check if entry does exist
585 if (!empty($whereStatement)) {
586 $result = SQL_QUERY("SELECT * FROM "._MYSQL_PREFIX.$tableName." WHERE ".$whereStatement." LIMIT 1", __FILE__, __LINE__);
588 $result = SQL_QUERY("SELECT * FROM "._MYSQL_PREFIX.$tableName." LIMIT 1", __FILE__, __LINE__);
592 if (SQL_NUMROWS($result) == 1) {
593 // "Implode" all data to single string
594 $DATA_UPDATE = implode(", ", $DATA);
596 // Generate SQL string
597 $SQL = "UPDATE "._MYSQL_PREFIX.$tableName." SET ".$DATA_UPDATE." WHERE ".$whereStatement." LIMIT 1";
599 // Add Line (does only work with auto_increment!
600 $KEYs = array(); $VALUEs = array();
601 foreach ($DATA as $entry) {
603 $line = explode("=", $entry);
604 $KEYs[] = $line[0]; $VALUEs[] = $line[1];
607 // Add both in one line
608 $KEYs = implode(", ", $KEYs);
609 $VALUEs = implode(", ", $VALUEs);
611 // Generate SQL string
612 $SQL = "INSERT INTO "._MYSQL_PREFIX.$tableName." (".$KEYs.") VALUES(".$VALUEs.")";
616 SQL_FREERESULT($result);
618 // Simply run generated SQL string
619 $result = SQL_QUERY($SQL, __FILE__, __LINE__);
621 // Is the config table updated and the cache extension installed?
622 if ((GET_EXT_VERSION("cache") >= "0.1.2") && ($tableName == "_config")) {
624 if ($cacheInstance->cache_file("config", true)) $cacheInstance->cache_destroy();
629 LOAD_TEMPLATE("admin_settings_saved", false, "<STRONG class=\"admin_done\">".SETTINGS_SAVED."</STRONG>");
632 function ADMIN_MAKE_MENU_SELECTION($menu, $type, $name, $default="") {
633 // Init the selection box
634 $OUT = "<SELECT name=\"".$name."\" class=\"admin_select\" size=\"1\">\n <OPTION value=\"\">".IS_TOP_MENU."</OPTION>\n";
636 // Open the requested menu directory
637 $handle = opendir(PATH."inc/modules/".$menu."/") or mxchange_die("Cannot load menu ".$menu."!");
638 while ($file = readdir($handle)) {
639 // Is this a PHP script?
640 if (($file != ".") && ($file != "..") && ($file != "lost+found") && (strpos($file, "".$type."-") > -1) && (strpos($file, ".php") > 0)) {
641 // Then test if the file is readable
642 $test = PATH."inc/modules/".$menu."/".$file;
643 if (is_readable($test)) {
644 // Extract the value for what=xxx
645 $part = substr($file, (strlen($type) + 1)); $part = substr($part, 0, strpos($part, ".php"));
647 // Is that part different from the overview?
648 if ($part != "overview") {
649 $OUT .= " <OPTION value=\"".$part."\"";
650 if ($part == $default) $OUT .= "selected";
651 $OUT .= ">".$part."</OPTION>\n";
657 $OUT .= "</SELECT>\n";
661 function ADMIN_USER_PROFILE_LINK($uid, $title="", $wht="list_user")
663 if (($title == "") && ($title != "0")) { $title = $uid; }
664 if (($title == "0") && ($wht == "list_refs"))
666 // Return title again
670 //* DEBUG: */ echo "A:".$title."<br />";
672 return "<A href=\"".URL."/modules.php?module=admin&what=".$wht."&u_id=".$uid."\" title=\"".ADMIN_USER_PROFILE_TITLE."\">".$title."</A>";
675 function ADMIN_CHECK_MENU_MODE()
677 global $_CONFIG, $cacheArray;
679 // Set the global mode as the mode for all admins
680 $MODE = $_CONFIG['admin_menu']; $ADMIN = $MODE;
682 // Check individual settings of current admin
683 if (isset($cacheArray['admins']['la_mode'][$_SESSION['admin_login']]))
686 $ADMIN = $cacheArray['admins']['la_mode'][$_SESSION['admin_login']];
687 $_CONFIG['cache_hits']++;
689 elseif (GET_EXT_VERSION("admins") >= "0.6.7")
691 // Load from database when version of "admins" is enough
692 $result = SQL_QUERY_ESC("SELECT la_mode FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
693 array($_SESSION['admin_login']), __FILE__, __LINE__);
694 if (SQL_NUMROWS($result) == 1)
697 list($ADMIN) = SQL_FETCHROW($result);
701 SQL_FREERESULT($result);
704 // Check what the admin wants and set it when it's not the global mode
705 if ($ADMIN != "global") $MODE = $ADMIN;
707 // Return admin-menu's mode
710 // Change activation status
711 function ADMIN_CHANGE_ACTIVATION_STATUS ($IDs, $table, $row, $idRow = "id") {
713 $cnt = 0; $newStatus = 'Y';
714 if ((is_array($IDs)) && (count($IDs) > 0)) {
715 // "Walk" all through and count them
716 foreach ($IDs as $id=>$selected) {
717 // Secure the ID number
718 $id = bigintval($id);
720 // Should always be 1 ;-)
721 if ($selected == 1) {
722 // Determine new status
723 $result = SQL_QUERY_ESC("SELECT %s FROM "._MYSQL_PREFIX."_%s WHERE %s=%d LIMIT 1",
724 array($row, $table, $idRow, $id), __FILE__, __LINE__);
727 if (SQL_NUMROWS($result) == 1) {
729 list($currStatus) = SQL_FETCHROW($result);
730 if ($currStatus == 'Y') $newStatus='N'; else $newStatus = 'Y';
732 // Change this status
733 SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_%s SET %s='%s' WHERE %s=%d LIMIT 1",
734 array($table, $row, $newStatus, $idRow, $id), __FILE__, __LINE__);
736 // Count up affected rows
737 $cnt += SQL_AFFECTEDROWS();
741 SQL_FREERESULT($result);
746 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_STATUS_CHANGED_1.$cnt.ADMIN_STATUS_CHANGED_2.count($IDs).ADMIN_STATUS_CHANGED_3);
749 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NOTHING_SELECTED_CHANGE);
752 // Delete rows by given ID numbers
753 function ADMIN_DELETE_ENTRIES_CONFIRM ($IDs, $table, $row, $columns = array(), $filterFunctions = array(), $deleteNow=false, $idRow="id") {
756 if ((is_array($IDs)) && (count($IDs) > 0)) {
757 // "Walk" through all entries and count them
761 // List for confirmation
762 foreach ($IDs as $id=>$selected) {
764 $id = bigintval($id);
766 // Will always be 1 ;-)
767 if ($selected == 1) {
768 // Get result from a given column array and table name
769 $result = SQL_RESULT_FROM_ARRAY($table, $columns, $idRow, $id);
771 // Is there one entry?
772 if (SQL_NUMROWS($result) == 1) {
774 $content = SQL_FETCHARRAY($result);
777 foreach ($content as $key=>$value) {
778 // Is a filter function set?
779 $idx = array_search($key, $columns, true);
780 if (!empty($filterFunctions[$idx])) {
782 $content[$key] = call_user_func($filterFunctions[$idx], $value);
786 // Add color switching
787 $content['sw'] = $SW;
789 // Then list it again...
790 $OUT .= LOAD_TEMPLATE("admin_del_".$table."_row", true, $content);
795 SQL_FREERESULT($result);
799 // Load master template
800 LOAD_TEMPLATE("admin_del_".$table."", false, $OUT);