X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fgen_refback.php;h=449edcaa1d77044a626981ba759ffe62c5ef7f9a;hb=af59daf6541b279989547829c95adc5bee8ca11d;hp=be1a3a768967ce01de2acce01c79c00b7a711b27;hpb=dfaa8c1675da4071ea451406a6f6fedd4c568416;p=mailer.git diff --git a/inc/gen_refback.php b/inc/gen_refback.php index be1a3a7689..449edcaa1d 100644 --- a/inc/gen_refback.php +++ b/inc/gen_refback.php @@ -38,35 +38,42 @@ if (!defined('__SECURITY')) { } // Make sure our functions are there -require_once(PATH."inc/libs/refback_functions.php"); +LOAD_INC_ONCE("inc/libs/refback_functions.php"); // Sanity-check: Do we have ref level 0? -$result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_refsystem WHERE level=0", __FILE__, __LINE__); +$result = SQL_QUERY("SELECT id FROM `{!_MYSQL_PREFIX!}_refsystem` WHERE level=0", __FILE__, __LINE__); if (SQL_NUMROWS($result) > 0) { + // Remove index temporaly + SQL_ALTER_TABLE("ALTER TABLE `{!_MYSQL_PREFIX!}_refsystem` DROP INDEX `userid_level`", __FILE__, __LINE__); + // Upgrade refsystem, ref-level 0 is silly here - SQL_QUERY("UPDATE "._MYSQL_PREFIX."_refsystem SET level=level+1", __FILE__, __LINE__); + SQL_QUERY("UPDATE `{!_MYSQL_PREFIX!}_refsystem` SET level=level+1", __FILE__, __LINE__); + + // Add it again + SQL_ALTER_TABLE("ALTER TABLE `{!_MYSQL_PREFIX!}_refsystem` ADD UNIQUE `userid_level` ( `userid` , `level` )", __FILE__, __LINE__); + + // Rebuild cache + REBUILD_CACHE("refsystem", "refsystem"); } // END - if // Free result SQL_FREERESULT($result); // Reset the table -SQL_QUERY("TRUNCATE TABLE "._MYSQL_PREFIX."_user_refs", __FILE__, __LINE__); +SQL_QUERY("TRUNCATE TABLE `{!_MYSQL_PREFIX!}_user_refs`", __FILE__, __LINE__); // Begin with all users in level one $result_direct = SQL_QUERY("SELECT u.userid -FROM "._MYSQL_PREFIX."_user_data AS u +FROM `{!_MYSQL_PREFIX!}_user_data` AS u WHERE u.refid=0 ORDER BY u.userid ASC", __FILE__, __LINE__); // Do we have entries? if (SQL_NUMROWS($result_direct) > 0) { - global $cacheArray; - // When "walk" through all users while (list($uid) = SQL_FETCHROW($result_direct)) { // Init level - $cacheArray['back_level'] = 1; + $GLOBALS['cache_array']['back_level'] = 1; // Update refback table //* DEBUG: */ echo "uid={$uid}
\n";