]> git.mxchange.org Git - mailer.git/blobdiff - 0.2.1/inc/modules/admin/admin-inc.php
branched
[mailer.git] / 0.2.1 / inc / modules / admin / admin-inc.php
diff --git a/0.2.1/inc/modules/admin/admin-inc.php b/0.2.1/inc/modules/admin/admin-inc.php
deleted file mode 100644 (file)
index 0ac0175..0000000
+++ /dev/null
@@ -1,810 +0,0 @@
-<?php
-/************************************************************************
- * MXChange v0.2.1                                    Start: 08/31/2003 *
- * ===============                              Last change: 11/23/2004 *
- *                                                                      *
- * -------------------------------------------------------------------- *
- * File              : admin-inc.php                                    *
- * -------------------------------------------------------------------- *
- * Short description : Administrative related functions                 *
- * -------------------------------------------------------------------- *
- * Kurzbeschreibung  : Fuer die Administration benoetigte Funktionen    *
- * -------------------------------------------------------------------- *
- *                                                                      *
- * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
- * For more information visit: http://www.mxchange.org                  *
- *                                                                      *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or    *
- * (at your option) any later version.                                  *
- *                                                                      *
- * This program is distributed in the hope that it will be useful,      *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
- * GNU General Public License for more details.                         *
- *                                                                      *
- * You should have received a copy of the GNU General Public License    *
- * along with this program; if not, write to the Free Software          *
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
- * MA  02110-1301  USA                                                  *
- ************************************************************************/
-
-// Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
-{
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
-}
-
-//
-function REGISTER_ADMIN ($user, $md5)
-{
-       $ret = "failed";
-       $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
-        array($user), __FILE__, __LINE__);
-       if (SQL_NUMROWS($result) == 0)
-       {
-               // Ok, let's create the admin login
-               $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_admins (login, password, email) VALUES('%s', '%s', '".WEBMASTER."')",
-                array($user, $md5), __FILE__, __LINE__);
-               $ret = "done";
-       }
-        else
-       {
-               // Free memory
-               SQL_FREERESULT($result);
-
-               // Login does already exist
-               $ret = "already";
-       }
-       return $ret;
-}
-// Only be executed on login procedure!
-function CHECK_ADMIN_LOGIN ($admin_login, $password)
-{
-       global $ADMINS, $CONFIG, $CACHE;
-       $ret = "404"; $pass = "";
-       if (!empty($ADMINS['aid'][$admin_login]))
-       {
-               // Get password from cache
-               $pass = $ADMINS['password'][$admin_login];
-               $ret = "pass";
-               $CONFIG['cache_hits']++;
-       }
-        else
-       {
-               // Get password from DB
-               $result = SQL_QUERY_ESC("SELECT password FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
-                array($admin_login), __FILE__, __LINE__);
-               if (SQL_NUMROWS($result) == 1)
-               {
-                       $ret = "pass";
-                       list($pass) = SQL_FETCHROW($result);
-                       SQL_FREERESULT($result);
-               }
-       }
-
-       //* DEBUG: */ echo "*".$pass."/".$password."/".$ret."<BR>";
-       if ((strlen($pass) == 32) && ($pass == md5($password)))
-       {
-               // Generate new hash
-               $pass = generateHash($password);
-               if (($ret == "pass") && (GET_EXT_VERSION("sql_patches") < "0.3.6")) $ret = "done";
-       }
-        elseif ((GET_EXT_VERSION("sql_patches") < "0.3.6") || (GET_EXT_VERSION("sql_patches") == ""))
-       {
-               // Old hashing way
-               return $ret;
-       }
-
-       // Generate salt of password
-       define('__SALT', substr($pass, 0, -40));
-       $salt = __SALT;
-
-       // Check if password is same
-       if (($ret == "pass") && ($pass == generateHash($password, $salt)) && (!empty($salt)))
-       {
-               // Update password
-               $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_admins SET password='%s' WHERE login='%s' LIMIT 1",
-                array($pass, $admin_login), __FILE__, __LINE__);
-
-               // Shall I remove the cache file?
-               if ((EXT_IS_ACTIVE("cache")) && ($CACHE != false))
-               {
-                       if ($CACHE->cache_file("admins", true)) $CACHE->cache_destroy();
-               }
-
-               // Password matches!
-               $ret = "done";
-       }
-        elseif ((empty($salt)) && ($ret == "pass"))
-       {
-               // Something bad went wrong
-               $ret = "failed";
-       }
-       return $ret;
-}
-// Only be executed on cookie checking
-function CHECK_ADMIN_COOKIES ($admin_login, $password)
-{
-       global $ADMINS, $CONFIG;
-       $ret = "404"; $pass = "";
-       if (!empty($ADMINS['aid'][$admin_login]))
-       {
-               // Get password from cache
-               $pass = $ADMINS['password'][$admin_login];
-               $ret = "pass";
-               $CONFIG['cache_hits']++;
-       }
-        else
-       {
-               // Get password from DB
-               $result = SQL_QUERY_ESC("SELECT password FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
-                array($admin_login), __FILE__, __LINE__);
-               if (SQL_NUMROWS($result) == 1)
-               {
-                       $ret = "pass";
-                       list($pass) = SQL_FETCHROW($result);
-                       SQL_FREERESULT($result);
-               }
-       }
-
-       //* DEBUG: */ echo "*".$pass."/".$password."<BR>";
-
-       // Check if password matches
-       if (($ret == "pass") && ((generatePassString($pass) == $password) || ($pass == $password)))
-       {
-               // Passwords matches!
-               $ret = "done";
-       }
-       return $ret;
-}
-//
-function admin_WriteData ($FILE, $COMMENT, $PREFIX, $SUFFIX, $DATA, $SEEK=0)
-{
-       $DONE = false;  $SEEK++; $found = false;
-       if (file_exists($FILE))
-       {
-               $SEARCH = "CFG: ".$COMMENT;
-               $TMP = $FILE.".tmp";
-               $fp = fopen($FILE, 'r') or OUTPUT_HTML ("<STRONG>READ:</STRONG> ".$FILE."<BR>");
-               if ($fp)
-               {
-                       $fp_tmp = fopen($TMP, 'w') or OUTPUT_HTML ("<STRONG>WRITE:</STRONG> ".$TMP."<BR>");
-                       if ($fp_tmp)
-                       {
-                               while (! feof($fp))
-                               {
-                                       $line = fgets ($fp, 1024);
-                                       if (strpos($line, $SEARCH) > -1) { $next = 0; $found = true; }
-                                       if ($next > -1)
-                                       {
-                                               if ($next == $SEEK)
-                                               {
-                                                       $next = -1;
-                                                       $line = $PREFIX.$DATA.$SUFFIX."\n";
-                                               }
-                                                else
-                                               {
-                                                       $next++;
-                                               }
-                                       }
-                                       fputs($fp_tmp, $line);
-                               }
-                               fclose($fp_tmp);
-                               // Finished writing tmp file
-                               $DONE = true;
-                       }
-                       fclose($fp);
-                       if (($DONE) && ($found))
-                       {
-                               // Copy back tmp file and delete tmp :-)
-                               @copy($TMP, $FILE);
-                               @unlink($TMP);
-                               define ('_FATAL', false);
-                       }
-                        elseif (!$found)
-                       {
-                               OUTPUT_HTML ("<STRONG>CHANGE:</STRONG> 404!");
-                               define ('_FATAL', true);
-                       }
-                        else
-                       {
-                               OUTPUT_HTML ("<STRONG>TMP:</STRONG> UNDONE!");
-                               define ('_FATAL', true);
-                       }
-               }
-       }
-        else
-       {
-               OUTPUT_HTML ("<STRONG>404:</STRONG> ".$FILE."<BR>");
-       }
-}
-//
-function ADMIN_DO_ACTION($wht)
-{
-       global $menuDesription, $MTITLE, $CONFIG, $EXTENSIONS, $link, $DATA;
-       //* DEBUG: */ echo __LINE__."*".$wht."/".$GLOBALS['module']."/".$GLOBALS['action']."/".$GLOBALS['what']."*<br />\n";
-       if (EXT_IS_ACTIVE("cache"))
-       {
-               // Include cache instance
-               global $CACHE;
-       }
-
-       // Remove any spaces from variable
-       if (empty($wht))
-       {
-               // Default admin action is the overview page
-               $wht = "overview";
-       }
-        else
-       {
-               // Compile out some chars
-               $wht = COMPILE_CODE($wht, false, false, false);
-       }
-
-       // Get action value
-       $act = GET_ACTION($GLOBALS['module'], $wht);
-
-       // Define admin login name and ID number
-       define('__ADMIN_LOGIN', SQL_ESCAPE($_COOKIE['admin_login']));
-       define('__ADMIN_ID'   , GET_ADMIN_ID($_COOKIE['admin_login']));
-
-       // Preload templates
-       if (EXT_IS_ACTIVE("admins")) {
-               define('__ADMIN_WELCOME', LOAD_TEMPLATE("admin_welcome_admins", true));
-       } else {
-               define('__ADMIN_WELCOME', LOAD_TEMPLATE("admin_welcome", true));
-       }
-       define('__ADMIN_FOOTER' , LOAD_TEMPLATE("admin_footer" , true));
-       define('__ADMIN_MENU'   , ADD_ADMIN_MENU($act, $wht, true));
-
-       // Tableset header
-       LOAD_TEMPLATE("admin_main_header");
-
-       // Check if action/what pair is valid
-       $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_admin_menu
-WHERE action='%s' AND ((what='%s' AND what != 'overview') OR (what='' AND '%s'='overview'))
-LIMIT 1", array($act, $wht, $wht), __FILE__, __LINE__);
-       if (SQL_NUMROWS($result) == 1)
-       {
-               // Free memory
-               SQL_FREERESULT($result);
-
-               // Is valid but does the inlcude file exists?
-               $INC = sprintf(PATH."inc/modules/admin/action-%s.php", $act);
-               if ((file_exists($INC)) && (is_readable($INC)) && (VALIDATE_MENU_ACTION("admin", $act, $wht)) && (__ACL_ALLOW == true))
-               {
-                       // Ok, we finally load the admin action module
-                       include($INC);
-               }
-                elseif (__ACL_ALLOW == false)
-               {
-                       // Access denied
-                       LOAD_TEMPLATE("admin_menu_failed", false, ADMINS_ACCESS_DENIED);
-                       ADD_FATAL(ADMINS_ACCESS_DENIED);
-               }
-                else
-               {
-                       // Include file not found! :-(
-                       LOAD_TEMPLATE("admin_menu_failed", false, ADMIN_404_ACTION);
-                       ADD_FATAL(ADMIN_404_ACTION_1.$act.ADMIN_404_ACTION_2);
-               }
-       } else {
-               // Invalid action/what pair found!
-               LOAD_TEMPLATE("admin_menu_failed", false, ADMIN_INVALID_ACTION);
-               ADD_FATAL(ADMIN_INVALID_ACTION_1.$act."/".$wht.ADMIN_INVALID_ACTION_2);
-       }
-
-       // Tableset footer
-       LOAD_TEMPLATE("admin_main_footer");
-}
-//
-function ADD_ADMIN_MENU($act, $wht,$return=false)
-{
-       global $_GET, $menuDesription, $MTITLE, $link;
-       $SUB = false;
-
-       // Menu descriptions
-       $menuDesription = array();
-       $MTITLE = array();
-
-       // Build main menu
-       $result_main = SQL_QUERY("SELECT action, title, descr FROM "._MYSQL_PREFIX."_admin_menu WHERE what='' ORDER BY sort, id DESC", __FILE__, __LINE__);
-       $OUT = "";
-       if (SQL_NUMROWS($result_main) > 0)
-       {
-               $OUT = "<TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"admin_menu_main\">
-<TR><TD colspan=\"2\" height=\"7\" class=\"seperator\">&nbsp;</TD></TR>\n";
-               while (list($menu, $title, $descr) = SQL_FETCHROW($result_main))
-               {
-                       if ((EXT_IS_ACTIVE("admins")) && (GET_EXT_VERSION("admins") > "0.2"))
-                       {
-                               $ACL = ADMINS_CHECK_ACL($menu, "");
-                       }
-                        else
-                       {
-                               // ACL is "allow"... hmmm
-                               $ACL = true;
-                       }
-                       if ($ACL)
-                       {
-                               if (!$SUB)
-                               {
-                                       // Insert compiled menu title and description
-                                       $MTITLE[$menu]        = $title;
-                                       $menuDesription[$menu] = $descr;
-                               }
-                               $OUT .= "<TR>
-  <TD class=\"admin_menu\" colspan=\"2\">
-    <NOBR>&nbsp;<STRONG>&middot;</STRONG>&nbsp;";
-                               if (($menu == $act) && (empty($wht)))
-                               {
-                                       $OUT .= "<STRONG>";
-                               }
-                                else
-                               {
-                                       $OUT .= "[&nbsp;<A href=\"".URL."/modules.php?module=admin&amp;action=".$menu."\">";
-                               }
-                               $OUT .= $title;
-                               if (($menu == $act) && (empty($wht)))
-                               {
-                                       $OUT .= "</STRONG>";
-                               }
-                                else
-                               {
-                                       $OUT .= "</A>&nbsp;]";
-                               }
-                               $OUT .= "</NOBR></TD>
-</TR>\n";
-                               $result_what = SQL_QUERY_ESC("SELECT what, title, descr FROM "._MYSQL_PREFIX."_admin_menu WHERE action='%s' AND what != '' ORDER BY sort, id DESC",
-                                array($menu), __FILE__, __LINE__);
-                               if ((SQL_NUMROWS($result_what) > 0) && ($act == $menu))
-                               {
-                                       $menuDesription = array();
-                                       $MTITLE = array(); $SUB = true;
-                                       $OUT .= "<TR>
-  <TD width=\"10\" class=\"seperator\">&nbsp;</TD>
-  <TD class=\"admin_menu\">
-    <TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"admin_menu_sub\">\n";
-                                       while (list($wht_sub, $title_what, $desc_what) = SQL_FETCHROW($result_what))
-                                       {
-                                               // Filename
-                                               $INC = sprintf(PATH."inc/modules/admin/what-%s.php", $wht_sub);
-                                               if ((EXT_IS_ACTIVE("admins")) && (GET_EXT_VERSION("admins") > "0.2"))
-                                               {
-                                                       $ACL = ADMINS_CHECK_ACL("", $wht_sub);
-                                               }
-                                                else
-                                               {
-                                                       // ACL is "allow"... hmmm
-                                                       $ACL = true;
-                                               }
-                                               $readable = ((file_exists($INC)) && (is_readable($INC)));
-                                               if ($ACL)
-                                               {
-                                                       // Insert compiled title and description
-                                                       $MTITLE[$wht_sub]        = $title_what;
-                                                       $menuDesription[$wht_sub] = $desc_what;
-                                                       $OUT .= "<TR>
-  <TD class=\"admin_menu\" colspan=\"2\">
-    <NOBR>&nbsp;<STRONG>--&gt;</STRONG>&nbsp;";
-                                                       if ($readable)
-                                                       {
-                                                               if ($wht == $wht_sub)
-                                                               {
-                                                                       $OUT .= "<STRONG>";
-                                                               }
-                                                                else
-                                                               {
-                                                                       $OUT .= "[&nbsp;<A href=\"".URL."/modules.php?module=admin&amp;what=".$wht_sub."\">";
-                                                               }
-                                                       }
-                                                        else
-                                                       {
-                                                               $OUT .= "<I class=\"admin_note\">";
-                                                       }
-                                                       $OUT .= $title_what;
-                                                       if ($readable)
-                                                       {
-                                                               if ($wht == $wht_sub)
-                                                               {
-                                                                       $OUT .= "</STRONG>";
-                                                               }
-                                                                else
-                                                               {
-                                                                       $OUT .= "</A>&nbsp;]";
-                                                               }
-                                                       }
-                                                        else
-                                                       {
-                                                               $OUT .= "</I>";
-                                                       }
-                                                       $OUT .= "</NOBR></TD>
-</TR>\n";
-                                               }
-                                       }
-
-                                       // Free memory
-                                       SQL_FREERESULT($result_what);
-                                       $OUT .= "    </TABLE>
-  </TD>
-</TR>\n";
-                               }
-                               $OUT .= "<TR><TD height=\"7\" colspan=\"2\"></TD></TR>\n";
-                       }
-               }
-
-               // Free memory
-               SQL_FREERESULT($result_main);
-               $OUT .= "</TABLE>\n";
-       }
-
-       // Compile and run the code here. This inserts all constants into the
-       // HTML output. Costs me some time to figure this out... *sigh* Quix0r
-       $eval = "\$OUT = \"".COMPILE_CODE(addslashes($OUT))."\";";
-       eval($eval);
-
-       // Return or output content?
-       if ($return) {
-               return $OUT;
-       } else {
-               OUTPUT_HTML ($OUT);
-       }
-}
-//
-function ADD_MEMBER_SELECTION_BOX($add_all = false, $return = false, $none = false, $def = "0")
-{
-       global $_GET;
-       // Output selection form with all confirmed user accounts listed
-       $result = SQL_QUERY("SELECT userid, surname, family FROM "._MYSQL_PREFIX."_user_data ORDER BY userid", __FILE__, __LINE__);
-       $OUT = "";
-
-       // USe this only for adding points (e.g. adding refs really makes no sence ;-) )
-       if ($add_all) $OUT = "      <OPTION value=\"all\">".ALL_MEMBERS."</OPTION>\n";
-        elseif ($none) $OUT = "      <OPTION value=\"0\">".SELECT_NONE."</OPTION>\n";
-       while (list($id, $sname, $fname) = SQL_FETCHROW($result))
-       {
-               $OUT .= "      <OPTION value=\"".$id."\"";
-               if ($def == $id) $OUT .= " selected=\"selected\"";
-               $OUT .= ">".$sname." ".$fname." (".$id.")</OPTION>\n";
-       }
-
-       // Free memory
-       SQL_FREERESULT($result);
-
-       // Remeber options in constant
-       define('_MEMBER_SELECTION', $OUT);
-
-       if (!$return)
-       {
-               // Display selection box
-               define('__LANG_VALUE', GET_LANGUAGE());
-
-               // Load template
-               LOAD_TEMPLATE("admin_member_selection_box", false, $GLOBALS['what']);
-       }
-}
-//
-function ADMIN_MENU_SELECTION($MODE, $default="", $defid="")
-{
-       $wht = "what != ''";
-       if ($MODE == "action") $wht = "what='' AND action !='login'";
-       $result = SQL_QUERY_ESC("SELECT %s, title FROM "._MYSQL_PREFIX."_admin_menu WHERE ".$wht." ORDER BY sort",
-        array($MODE), __FILE__, __LINE__);
-       if (SQL_NUMROWS($result) > 0)
-       {
-               // Load menu as selection
-               $OUT = "<SELECT name=\"".$MODE."_menu";
-               if ((!empty($defid)) || ($defid == "0")) $OUT .= "[".$defid."]";
-               $OUT .= "\" size=\"1\" class=\"admin_select\">
-  <OPTION value=\"\">".SELECT_NONE."</OPTION>\n";
-               while (list($menu, $title) = SQL_FETCHROW($result))
-               {
-                       $OUT .= "  <OPTION value=\"".$menu."\"";
-                       if ((!empty($default)) && ($default == $menu)) $OUT .= " selected=\"selected\"";
-                       $OUT .= ">".$title."</OPTION>\n";
-               }
-
-               // Free memory
-               SQL_FREERESULT($result);
-               $OUT .= "</SELECT>\n";
-       }
-        else
-       {
-               // No menus???
-               $OUT = ADMIN_PROBLEM_NO_MENU;
-       }
-
-       // Return output
-       return $OUT;
-}
-//
-function ADMIN_SAVE_SETTINGS (&$POST, $TABLE, $WHERE="config='1'", $translateComma = array(), $alwaysAdd=false)
-{
-       global $CONFIG, $CFG_CACHE, $CACHE;
-       $DATA = array();
-       $skip = false; $TEST2 = "";
-       foreach ($POST as $id=>$val) {
-               // Process only formular field but not submit buttons ;)
-               if ($id != "ok") {
-                       // Do not save the ok value
-                       $TEST = substr($id, -3);
-                       if ((($TEST == "_ye") || ($TEST == "_mo") || ($TEST == "_we") || ($TEST == "_da") || ($TEST == "_ho") || ($TEST == "_mi") || ($TEST == "_se")) && (isset($val))) {
-                               // Found a multi-selection for timings?
-                               $TEST = substr($id, 0, -3);
-                               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)) {
-                                       // Generate timestamp
-                                       $POST[$TEST] = CREATE_TIMESTAMP_FROM_SELECTIONS($TEST, $POST);
-                                       $DATA[] = "$TEST='".$POST[$TEST]."'";
-
-                                       // Remove data from array
-                                       unset($POST[$TEST."_ye"]);
-                                       unset($POST[$TEST."_mo"]);
-                                       unset($POST[$TEST."_we"]);
-                                       unset($POST[$TEST."_da"]);
-                                       unset($POST[$TEST."_ho"]);
-                                       unset($POST[$TEST."_mi"]);
-                                       unset($POST[$TEST."_se"]);
-
-                                       // Skip adding
-                                       unset($id); $skip = true; $TEST2 = $TEST;
-                               }
-                       } else {
-                               // Process this entry
-                               $skip = false; $TEST2 = "";
-                       }
-
-                       // Shall we process this ID? It muss not be empty, of course
-                       if ((!$skip) && (!empty($id))) {
-                               // Save this entry
-                               $val = COMPILE_CODE($val);
-
-                               // Translate the value? (comma to dot!)
-                               if ((is_array($translateComma)) && (in_array($id, $translateComma))) {
-                                       // Then do it here... :)
-                                       $val = str_replace(",", ".", $val);
-                               }
-
-                               // Shall we add numbers or strings?
-                               $test = (float)$val;
-                               if ("".$val."" == "".$test."") {
-                                       // Add numbers
-                                       $DATA[] = $id."=".$val."";
-                               } else {
-                                       // Add strings
-                                       $DATA[] = $id."='".trim($val)."'";
-                               }
-
-                               // Update current configuration
-                               $CONFIG[$id] = $val;
-                       }
-               }
-       }
-
-       // Check if entry does exist
-       $result = false;
-       if (!$alwaysAdd) {
-               if (!empty($WHERE)) {
-                       $result = SQL_QUERY("SELECT * FROM "._MYSQL_PREFIX.$TABLE." WHERE ".$WHERE." LIMIT 1", __FILE__, __LINE__);
-               } else {
-                       $result = SQL_QUERY("SELECT * FROM "._MYSQL_PREFIX.$TABLE." LIMIT 1", __FILE__, __LINE__);
-               }
-       }
-
-       if (SQL_NUMROWS($result) == 1) {
-               // "Implode" all data to single string
-               $DATA_UPDATE = implode(", ", $DATA);
-
-               // Generate SQL string
-               $SQL = "UPDATE "._MYSQL_PREFIX.$TABLE." SET ".$DATA_UPDATE." WHERE ".$WHERE." LIMIT 1";
-       } else {
-               // Add Line (does only work with auto_increment!
-               $KEYs = array(); $VALUEs = array();
-               foreach ($DATA as $entry) {
-                       // Split up
-                       $line = explode("=", $entry);
-                       $KEYs[] = $line[0]; $VALUEs[] = $line[1];
-               }
-
-               // Add both in one line
-               $KEYs = implode(", ", $KEYs);
-               $VALUEs = implode(", ", $VALUEs);
-
-               // Generate SQL string
-               $SQL = "INSERT INTO "._MYSQL_PREFIX.$TABLE." (".$KEYs.") VALUES(".$VALUEs.")";
-       }
-
-       // Free memory
-       SQL_FREERESULT($result);
-
-       // Simply run generated SQL string
-       $result = SQL_QUERY($SQL, __FILE__, __LINE__);
-
-       // Is the config table updated and the cache extension installed?
-       if ((GET_EXT_VERSION("cache") >= "0.1.2") && ($TABLE == "_config")) {
-               // Remove it here...
-               if ($CACHE->cache_file("config", true)) $CACHE->cache_destroy();
-               unset($CFG_CACHE);
-       }
-
-       // Settings saved
-       LOAD_TEMPLATE("admin_settings_saved", false, "<STRONG class=\"admin_done\">".SETTINGS_SAVED."</STRONG>");
-}
-//
-function ADMIN_MAKE_MENU_SELECTION($menu, $type, $name, $default="") {
-       // Init the selection box
-       $OUT = "<SELECT name=\"".$name."\" class=\"admin_select\" size=\"1\">\n <OPTION value=\"\">".IS_TOP_MENU."</OPTION>\n";
-
-       // Open the requested menu directory
-       $handle = opendir(PATH."inc/modules/".$menu."/") or mxchange_die("Cannot load menu ".$menu."!");
-       while ($file = readdir($handle)) {
-               // Is this a PHP script?
-               if (($file != ".") && ($file != "..") && ($file != "lost+found") && (strpos($file, "".$type."-") > -1) && (strpos($file, ".php") > 0)) {
-                       // Then test if the file is readable
-                       $test = PATH."inc/modules/".$menu."/".$file;
-                       if (is_readable($test)) {
-                               // Extract the value for what=xxx
-                               $part = substr($file, (strlen($type) + 1)); $part = substr($part, 0, strpos($part, ".php"));
-
-                               // Is that part different from the overview?
-                               if ($part != "overview") {
-                                       $OUT .= "       <OPTION value=\"".$part."\"";
-                                       if ($part == $default) $OUT .= "selected";
-                                       $OUT .= ">".$part."</OPTION>\n";
-                               }
-                       }
-               }
-       }
-       closedir($handle);
-       $OUT .= "</SELECT>\n";
-       return $OUT;
-}
-//
-function ADMIN_USER_PROFILE_LINK($uid, $title="", $wht="list_user")
-{
-       if (($title == "") && ($title != "0")) { $title = $uid; }
-       if (($title == "0") && ($wht == "list_refs"))
-       {
-               // Return title again
-               return $title;
-       }
-
-       //* DEBUG: */ echo "A:".$title."<BR>";
-       // Return link
-       return "<A href=\"".URL."/modules.php?module=admin&amp;what=".$wht."&amp;u_id=".$uid."\" title=\"".ADMIN_USER_PROFILE_TITLE."\">".$title."</A>";
-}
-//
-function ADMIN_CHECK_MENU_MODE()
-{
-       global $CONFIG, $ADMINS, $_COOKIE;
-
-       // Set the global mode as the mode for all admins
-       $MODE = $CONFIG['admin_menu']; $ADMIN = $MODE;
-
-       // Check individual settings of current admin
-       if (isset($ADMINS['la_mode'][$_COOKIE['admin_login']]))
-       {
-               // Load from cache
-               $ADMIN = $ADMINS['la_mode'][$_COOKIE['admin_login']];
-               $CONFIG['cache_hits']++;
-       }
-        elseif (GET_EXT_VERSION("admins") >= "0.6.7")
-       {
-               // Load from database when version of "admins" is enough
-               $result = SQL_QUERY_ESC("SELECT la_mode FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
-                array($_COOKIE['admin_login']), __FILE__, __LINE__);
-               if (SQL_NUMROWS($result) == 1)
-               {
-                       // Load data
-                       list($ADMIN) = SQL_FETCHROW($result);
-               }
-
-               // Free memory
-               SQL_FREERESULT($result);
-       }
-
-       // Check what the admin wants and set it when it's not the global mode
-       if ($ADMIN != "global") $MODE = $ADMIN;
-
-       // Return admin-menu's mode
-       return $MODE;
-}
-// Change activation status
-function ADMIN_CHANGE_ACTIVATION_STATUS ($IDs, $table, $row, $idRow = "id") {
-       global $CONFIG;
-       $cnt = 0; $newStatus = "Y";
-       if ((is_array($IDs)) && (count($IDs) > 0)) {
-               // "Walk" all through and count them
-               foreach ($IDs as $id=>$selected) {
-                       // Secure the ID number
-                       $id = bigintval($id);
-
-                       // Should always be 1 ;-)
-                       if ($selected == 1) {
-                               // Determine new status
-                               $result = SQL_QUERY_ESC("SELECT %s FROM "._MYSQL_PREFIX."_%s WHERE %s=%d LIMIT 1",
-                                       array($row, $table, $idRow, $id), __FILE__, __LINE__);
-
-                               // Row found?
-                               if (SQL_NUMROWS($result) == 1) {
-                                       // Load the status
-                                       list($currStatus) = SQL_FETCHROW($result);
-                                       if ($currStatus == "Y") $newStatus="N"; else $newStatus = "Y";
-
-                                       // Change this status
-                                       SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_%s SET %s='%s' WHERE %s=%d LIMIT 1",
-                                               array($table, $row, $newStatus, $idRow, $id), __FILE__, __LINE__);
-
-                                       // Count up affected rows
-                                       $cnt += SQL_AFFECTEDROWS();
-                               }
-
-                               // Free the result
-                               SQL_FREERESULT($result);
-                       }
-               }
-
-               // Output status
-               LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_STATUS_CHANGED_1.$cnt.ADMIN_STATUS_CHANGED_2.count($IDs).ADMIN_STATUS_CHANGED_3);
-       } else {
-               // Nothing selected!
-               LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NOTHING_SELECTED_CHANGE);
-       }
-}
-// Delete rows by given ID numbers
-function ADMIN_DELETE_ENTRIES_CONFIRM ($IDs, $table, $row, $columns = array(), $filterFunctions = array(), $deleteNow=false, $idRow="id") {
-       global $CONFIG;
-       $OUT = ""; $SW = 2;
-       if ((is_array($IDs)) && (count($IDs) > 0)) {
-               // "Walk" through all entries and count them
-               if ($deleteNow) {
-                       // Delete them
-               } else {
-                       // List for confirmation
-                       foreach ($IDs as $id=>$selected) {
-                               // Secure ID number
-                               $id = bigintval($id);
-
-                               // Will always be 1 ;-)
-                               if ($selected == 1) {
-                                       // Get result from a given column array and table name
-                                       $result = SQL_RESULT_FROM_ARRAY($table, $columns, $idRow, $id);
-
-                                       // Is there one entry?
-                                       if (SQL_NUMROWS($result) == 1) {
-                                               // Load all data
-                                               $content = SQL_FETCHARRAY($result);
-
-                                               // Filter all data
-                                               foreach ($content as $key=>$value) {
-                                                       // Is a filter function set?
-                                                       $idx = array_search($key, $columns, true);
-                                                       if (!empty($filterFunctions[$idx])) {
-                                                               // Then call it!
-                                                               $content[$key] = call_user_func($filterFunctions[$idx], $value);
-                                                       }
-                                               }
-
-                                               // Add color switching
-                                               $content['sw'] = $SW;
-
-                                               // Then list it again...
-                                               $OUT .= LOAD_TEMPLATE("admin_del_".$table."_row", true, $content);
-                                               $SW = 3 - $SW;
-                                       }
-
-                                       // Free the result
-                                       SQL_FREERESULT($result);
-                               }
-                       }
-
-                       // Load master template
-                       LOAD_TEMPLATE("admin_del_".$table."", false, $OUT);
-               }
-       }
-}
-//
-?>