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, $DEPTH;
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(get_session('admin_login')));
249 define('__ADMIN_ID' , GET_ADMIN_ID(get_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);
477 // Display selection box
478 define('__LANG_VALUE', GET_LANGUAGE());
481 LOAD_TEMPLATE("admin_member_selection_box", false, $GLOBALS['what']);
485 function ADMIN_MENU_SELECTION($MODE, $default="", $defid="") {
487 if ($MODE == "action") $wht = "what='' AND action !='login'";
488 $result = SQL_QUERY_ESC("SELECT %s, title FROM "._MYSQL_PREFIX."_admin_menu WHERE ".$wht." ORDER BY sort",
489 array($MODE), __FILE__, __LINE__);
490 if (SQL_NUMROWS($result) > 0)
492 // Load menu as selection
493 $OUT = "<SELECT name=\"".$MODE."_menu";
494 if ((!empty($defid)) || ($defid == "0")) $OUT .= "[".$defid."]";
495 $OUT .= "\" size=\"1\" class=\"admin_select\">
496 <OPTION value=\"\">".SELECT_NONE."</OPTION>\n";
497 while (list($menu, $title) = SQL_FETCHROW($result))
499 $OUT .= " <OPTION value=\"".$menu."\"";
500 if ((!empty($default)) && ($default == $menu)) $OUT .= " selected=\"selected\"";
501 $OUT .= ">".$title."</OPTION>\n";
505 SQL_FREERESULT($result);
506 $OUT .= "</SELECT>\n";
511 $OUT = ADMIN_PROBLEM_NO_MENU;
518 function ADMIN_SAVE_SETTINGS (&$POST, $tableName="_config", $whereStatement="config=0", $translateComma = array(), $alwaysAdd=false)
520 global $_CONFIG, $cacheArray, $cacheInstance;
522 $skip = false; $TEST2 = "";
523 foreach ($POST as $id=>$val) {
524 // Process only formular field but not submit buttons ;)
526 // Do not save the ok value
527 $TEST = substr($id, -3);
528 if ((($TEST == "_ye") || ($TEST == "_mo") || ($TEST == "_we") || ($TEST == "_da") || ($TEST == "_ho") || ($TEST == "_mi") || ($TEST == "_se")) && (isset($val))) {
529 // Found a multi-selection for timings?
530 $TEST = substr($id, 0, -3);
531 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)) {
532 // Generate timestamp
533 $POST[$TEST] = CREATE_TIMESTAMP_FROM_SELECTIONS($TEST, $POST);
534 $DATA[] = "$TEST='".$POST[$TEST]."'";
536 // Remove data from array
537 unset($POST[$TEST."_ye"]);
538 unset($POST[$TEST."_mo"]);
539 unset($POST[$TEST."_we"]);
540 unset($POST[$TEST."_da"]);
541 unset($POST[$TEST."_ho"]);
542 unset($POST[$TEST."_mi"]);
543 unset($POST[$TEST."_se"]);
546 unset($id); $skip = true; $TEST2 = $TEST;
549 // Process this entry
550 $skip = false; $TEST2 = "";
553 // Shall we process this ID? It muss not be empty, of course
554 if ((!$skip) && (!empty($id))) {
556 $val = COMPILE_CODE($val);
558 // Translate the value? (comma to dot!)
559 if ((is_array($translateComma)) && (in_array($id, $translateComma))) {
560 // Then do it here... :)
561 $val = str_replace(",", ".", $val);
564 // Shall we add numbers or strings?
566 if ("".$val."" == "".$test."") {
568 $DATA[] = $id."=".$val."";
571 $DATA[] = $id."='".trim($val)."'";
574 // Update current configuration
575 $_CONFIG[$id] = $val;
580 // Check if entry does exist
583 if (!empty($whereStatement)) {
584 $result = SQL_QUERY("SELECT * FROM "._MYSQL_PREFIX.$tableName." WHERE ".$whereStatement." LIMIT 1", __FILE__, __LINE__);
586 $result = SQL_QUERY("SELECT * FROM "._MYSQL_PREFIX.$tableName." LIMIT 1", __FILE__, __LINE__);
590 if (SQL_NUMROWS($result) == 1) {
591 // "Implode" all data to single string
592 $DATA_UPDATE = implode(", ", $DATA);
594 // Generate SQL string
595 $SQL = "UPDATE "._MYSQL_PREFIX.$tableName." SET ".$DATA_UPDATE." WHERE ".$whereStatement." LIMIT 1";
597 // Add Line (does only work with auto_increment!
598 $KEYs = array(); $VALUEs = array();
599 foreach ($DATA as $entry) {
601 $line = explode("=", $entry);
602 $KEYs[] = $line[0]; $VALUEs[] = $line[1];
605 // Add both in one line
606 $KEYs = implode(", ", $KEYs);
607 $VALUEs = implode(", ", $VALUEs);
609 // Generate SQL string
610 $SQL = "INSERT INTO "._MYSQL_PREFIX.$tableName." (".$KEYs.") VALUES(".$VALUEs.")";
614 SQL_FREERESULT($result);
616 // Simply run generated SQL string
617 $result = SQL_QUERY($SQL, __FILE__, __LINE__);
619 // Is the config table updated and the cache extension installed?
620 if ((GET_EXT_VERSION("cache") >= "0.1.2") && ($tableName == "_config")) {
622 if ($cacheInstance->cache_file("config", true)) $cacheInstance->cache_destroy();
627 LOAD_TEMPLATE("admin_settings_saved", false, "<STRONG class=\"admin_done\">".SETTINGS_SAVED."</STRONG>");
630 function ADMIN_MAKE_MENU_SELECTION($menu, $type, $name, $default="") {
631 // Init the selection box
632 $OUT = "<SELECT name=\"".$name."\" class=\"admin_select\" size=\"1\">\n <OPTION value=\"\">".IS_TOP_MENU."</OPTION>\n";
634 // Open the requested menu directory
635 $handle = opendir(PATH."inc/modules/".$menu."/") or mxchange_die("Cannot load menu ".$menu."!");
636 while ($file = readdir($handle)) {
637 // Is this a PHP script?
638 if (($file != ".") && ($file != "..") && ($file != "lost+found") && (strpos($file, "".$type."-") > -1) && (strpos($file, ".php") > 0)) {
639 // Then test if the file is readable
640 $test = PATH."inc/modules/".$menu."/".$file;
641 if (is_readable($test)) {
642 // Extract the value for what=xxx
643 $part = substr($file, (strlen($type) + 1)); $part = substr($part, 0, strpos($part, ".php"));
645 // Is that part different from the overview?
646 if ($part != "overview") {
647 $OUT .= " <OPTION value=\"".$part."\"";
648 if ($part == $default) $OUT .= "selected";
649 $OUT .= ">".$part."</OPTION>\n";
655 $OUT .= "</SELECT>\n";
659 function ADMIN_USER_PROFILE_LINK($uid, $title="", $wht="list_user")
661 if (($title == "") && ($title != "0")) { $title = $uid; }
662 if (($title == "0") && ($wht == "list_refs"))
664 // Return title again
668 //* DEBUG: */ echo "A:".$title."<br />";
670 return "<A href=\"".URL."/modules.php?module=admin&what=".$wht."&u_id=".$uid."\" title=\"".ADMIN_USER_PROFILE_TITLE."\">".$title."</A>";
673 function ADMIN_CHECK_MENU_MODE()
675 global $_CONFIG, $cacheArray;
677 // Set the global mode as the mode for all admins
678 $MODE = $_CONFIG['admin_menu']; $ADMIN = $MODE;
680 // Check individual settings of current admin
681 if (isset($cacheArray['admins']['la_mode'][get_session('admin_login')]))
684 $ADMIN = $cacheArray['admins']['la_mode'][get_session('admin_login')];
685 $_CONFIG['cache_hits']++;
687 elseif (GET_EXT_VERSION("admins") >= "0.6.7")
689 // Load from database when version of "admins" is enough
690 $result = SQL_QUERY_ESC("SELECT la_mode FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
691 array(get_session('admin_login')), __FILE__, __LINE__);
692 if (SQL_NUMROWS($result) == 1)
695 list($ADMIN) = SQL_FETCHROW($result);
699 SQL_FREERESULT($result);
702 // Check what the admin wants and set it when it's not the global mode
703 if ($ADMIN != "global") $MODE = $ADMIN;
705 // Return admin-menu's mode
708 // Change activation status
709 function ADMIN_CHANGE_ACTIVATION_STATUS ($IDs, $table, $row, $idRow = "id") {
711 $cnt = 0; $newStatus = 'Y';
712 if ((is_array($IDs)) && (count($IDs) > 0)) {
713 // "Walk" all through and count them
714 foreach ($IDs as $id=>$selected) {
715 // Secure the ID number
716 $id = bigintval($id);
718 // Should always be 1 ;-)
719 if ($selected == 1) {
720 // Determine new status
721 $result = SQL_QUERY_ESC("SELECT %s FROM "._MYSQL_PREFIX."_%s WHERE %s=%d LIMIT 1",
722 array($row, $table, $idRow, $id), __FILE__, __LINE__);
725 if (SQL_NUMROWS($result) == 1) {
727 list($currStatus) = SQL_FETCHROW($result);
728 if ($currStatus == 'Y') $newStatus='N'; else $newStatus = 'Y';
730 // Change this status
731 SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_%s SET %s='%s' WHERE %s=%d LIMIT 1",
732 array($table, $row, $newStatus, $idRow, $id), __FILE__, __LINE__);
734 // Count up affected rows
735 $cnt += SQL_AFFECTEDROWS();
739 SQL_FREERESULT($result);
744 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_STATUS_CHANGED_1.$cnt.ADMIN_STATUS_CHANGED_2.count($IDs).ADMIN_STATUS_CHANGED_3);
747 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NOTHING_SELECTED_CHANGE);
750 // Delete rows by given ID numbers
751 function ADMIN_DELETE_ENTRIES_CONFIRM ($IDs, $table, $row, $columns = array(), $filterFunctions = array(), $deleteNow=false, $idRow="id") {
754 if ((is_array($IDs)) && (count($IDs) > 0)) {
755 // "Walk" through all entries and count them
759 // List for confirmation
760 foreach ($IDs as $id=>$selected) {
762 $id = bigintval($id);
764 // Will always be 1 ;-)
765 if ($selected == 1) {
766 // Get result from a given column array and table name
767 $result = SQL_RESULT_FROM_ARRAY($table, $columns, $idRow, $id);
769 // Is there one entry?
770 if (SQL_NUMROWS($result) == 1) {
772 $content = SQL_FETCHARRAY($result);
775 foreach ($content as $key=>$value) {
776 // Is a filter function set?
777 $idx = array_search($key, $columns, true);
778 if (!empty($filterFunctions[$idx])) {
780 $content[$key] = call_user_func($filterFunctions[$idx], $value);
784 // Add color switching
785 $content['sw'] = $SW;
787 // Then list it again...
788 $OUT .= LOAD_TEMPLATE("admin_del_".$table."_row", true, $content);
793 SQL_FREERESULT($result);
797 // Load master template
798 LOAD_TEMPLATE("admin_del_".$table."", false, $OUT);