Mahor rewrite:
[mailer.git] / inc / libs / surfbar_functions.php
index 9cc7e7e9959f2daaa632c53d133876b345daf735..434ce4f15c55cb459335868f7e3da2b6e63ce063 100644 (file)
@@ -246,7 +246,7 @@ function SURFBAR_MEMBER_DO_FORM ($formData, $URLs) {
                $URLs[$formData['id']]['new_status'] = $SURFBAR_CACHE['new_status'];
 
                // Extract URL data for call-back
-               $urlData = array(array_merge($URLs[$formData['id']], array($action => $formData)));
+               $urlData = array(merge_array($URLs[$formData['id']], array($action => $formData)));
 
                // Action found so execute it
                $performed = call_user_func_array($functionName, $urlData);
@@ -485,19 +485,19 @@ function SURFBAR_HANDLE_LOW_POINTS () {
        global $_CONFIG;
 
        // Get all userids
-       $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS($_CONFIG['surfbar_warn_low_points']);
+       $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS(getConfig('surfbar_warn_low_points'));
 
        // "Walk" through all URLs
        foreach ($UIDs['uid'] as $uid => $dummy) {
                // Is the last notification far enougth away to notify again?
-               if ((time() - $UIDs['notified'][$uid]) >= $_CONFIG['surfbar_low_interval']) {
+               if ((time() - $UIDs['notified'][$uid]) >= getConfig('surfbar_low_interval')) {
                        // Prepare content
                        $content = array(
                                'uid'      => $uid,
-                               'low'      => TRANSLATE_COMMA($_CONFIG['surfbar_warn_low_points']),
+                               'low'      => TRANSLATE_COMMA(getConfig('surfbar_warn_low_points')),
                                'points'   => TRANSLATE_COMMA($UIDs['points'][$uid]),
                                'notified' => MAKE_DATETIME($UIDs['notified'][$uid]),
-                               'interval' => CREATE_FANCY_TIME($_CONFIG['surfbar_low_interval'])
+                               'interval' => CREATE_FANCY_TIME(getConfig('surfbar_low_interval'))
                        );
 
                        // Notify this user
@@ -578,7 +578,7 @@ function SURFBAR_REGISTER_URL ($url, $uid, $status="PENDING", $addMode="reg", $e
        if ($addMode == "reg") $status = "PENDING";
 
        // Prepare content
-       $content = array_merge($extraFields, array(
+       $content = merge_array($extraFields, array(
                'url'         => $url,
                'frametester' => FRAMETESTER($url),
                'uid'         => $uid,
@@ -602,7 +602,7 @@ function SURFBAR_REGISTER_URL ($url, $uid, $status="PENDING", $addMode="reg", $e
        $content['limit'] = SURFBAR_TRANSLATE_LIMIT($content['limit']);
 
        // If in reg-mode we notify admin
-       if (($addMode == "reg") || ($_CONFIG['surfbar_notify_admin_unlock'] == "Y")) {
+       if (($addMode == "reg") || (getConfig('surfbar_notify_admin_unlock') == "Y")) {
                // Notify admin even when he as unlocked an email
                SURFBAR_NOTIFY_ADMIN("url_{$addMode}", $content);
        } // END - if
@@ -742,10 +742,10 @@ function SURFBAR_DETERMINE_REWARD ($onlyMin=false) {
        global $_CONFIG;
 
        // Static values are default
-       $reward = $_CONFIG['surfbar_static_reward'];
+       $reward = getConfig('surfbar_static_reward');
 
        // Do we have static or dynamic?
-       if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") {
+       if (getConfig('surfbar_pay_model') == "DYNAMIC") {
                // "Calculate" dynamic reward
                if ($onlyMin) {
                        $reward += SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE();
@@ -762,10 +762,10 @@ function SURFBAR_DETERMINE_COSTS ($onlyMin=false) {
        global $_CONFIG;
 
        // Static costs is default
-       $costs  = $_CONFIG['surfbar_static_costs'];
+       $costs  = getConfig('surfbar_static_costs');
 
        // Do we have static or dynamic?
-       if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") {
+       if (getConfig('surfbar_pay_model') == "DYNAMIC") {
                // "Calculate" dynamic costs
                if ($onlyMin) {
                        $costs += SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE();
@@ -811,11 +811,11 @@ function SURFBAR_CHECK_RELOAD_FULL() {
        $isFull = true;
 
        // Cache static reload lock
-       $SURFBAR_CACHE['surf_lock'] = $_CONFIG['surfbar_static_lock'];
-       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Fixed surf lock is ".$_CONFIG['surfbar_static_lock']."", false);
+       $SURFBAR_CACHE['surf_lock'] = getConfig('surfbar_static_lock');
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Fixed surf lock is ".getConfig('surfbar_static_lock')."", false);
 
        // Do we have dynamic model?
-       if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") {
+       if (getConfig('surfbar_pay_model') == "DYNAMIC") {
                // "Calculate" dynamic lock
                $SURFBAR_CACHE['surf_lock'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
        } // END - if
@@ -883,7 +883,7 @@ function SURFBAR_IF_USER_BOOK_MORE_URLS ($uid=0) {
        global $_CONFIG;
 
        // Is this admin and userid is zero or does the user has some URLs left to book?
-       return ((($uid == 0) && (IS_ADMIN())) || (SURFBAR_GET_TOTAL_USER_URLS($uid, "", array("REJECTED")) < $_CONFIG['surfbar_max_order']));
+       return ((($uid == 0) && (IS_ADMIN())) || (SURFBAR_GET_TOTAL_USER_URLS($uid, "", array("REJECTED")) < getConfig('surfbar_max_order')));
 }
 // Get total amount of URLs of given status for current user
 function SURFBAR_GET_TOTAL_USER_URLS ($uid=0, $status="",$exclude="") {
@@ -895,7 +895,7 @@ function SURFBAR_GET_TOTAL_USER_URLS ($uid=0, $status="",$exclude="") {
                $uid = $GLOBALS['userid'];
        } elseif ($uid == 0) {
                // Error!
-               return ($_CONFIG['surfbar_max_order'] + 1);
+               return (getConfig('surfbar_max_order') + 1);
        }
 
        // Default is all URLs
@@ -921,7 +921,7 @@ function SURFBAR_GET_TOTAL_USER_URLS ($uid=0, $status="",$exclude="") {
 FROM "._MYSQL_PREFIX."_surfbar_urls
 WHERE userid=%s".$ADD."
 LIMIT %s",
-               array($uid, $_CONFIG['surfbar_max_order']), __FILE__, __LINE__
+               array($uid, getConfig('surfbar_max_order')), __FILE__, __LINE__
        );
 
        // Fetch row
@@ -941,7 +941,7 @@ function SURFBAR_GENERATE_VALIDATION_CODE ($urlId, $salt="") {
        $SURFBAR_CACHE['salt'] = "INVALID";
 
        // Get code length from config
-       $length = $_CONFIG['code_length'];
+       $length = getConfig('code_length');
 
        // Fix length to 10
        if ($length == 0) $length = 10;
@@ -1009,12 +1009,12 @@ function SURFBAR_PAY_POINTS () {
        // Remove it from the URL owner
        //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid=".SURFBAR_GET_USERID().",costs=".SURFBAR_GET_COSTS()."", false);
        if (SURFBAR_GET_USERID() > 0) {
-               SUB_POINTS(sprintf("surfbar_%s", $_CONFIG['surfbar_pay_model']), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
+               SUB_POINTS(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
        } // END - if
 
        // Book it to the user
        //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid=".$GLOBALS['userid'].",reward=".SURFBAR_GET_REWARD()."", false);
-       ADD_POINTS_REFSYSTEM(sprintf("surfbar_%s", $_CONFIG['surfbar_pay_model']), $GLOBALS['userid'], SURFBAR_GET_DATA('reward'));
+       ADD_POINTS_REFSYSTEM(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), $GLOBALS['userid'], SURFBAR_GET_DATA('reward'));
 }
 // Updates the statistics of current URL/userid
 function SURFBAR_UPDATE_INSERT_STATS_RECORD () {
@@ -1173,7 +1173,7 @@ function SURFBAR_DETERMINE_TOTAL_ONLINE () {
 FROM "._MYSQL_PREFIX."_surfbar_stats
 WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_online)) <= %s
 GROUP BY userid",
-               array($_CONFIG['online_timeout']), __FILE__, __LINE__);
+               array(getConfig('online_timeout')), __FILE__, __LINE__);
 
        // Fetch count
        $cnt = SQL_NUMROWS($result);
@@ -1186,8 +1186,6 @@ GROUP BY userid",
 }
 // Determine waiting time for one URL 
 function SURFBAR_DETERMINE_WAIT_TIME () {
-       global $_CONFIG;
-
        // Get fixed reload lock
        $fixed = SURFBAR_GET_FIXED_RELOAD();
 
@@ -1198,10 +1196,10 @@ function SURFBAR_DETERMINE_WAIT_TIME () {
        } // END - if
 
        // Static time is default
-       $time = $_CONFIG['surfbar_static_time'];
+       $time = getConfig('surfbar_static_time');
 
        // Which payment model do we have?
-       if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") {
+       if (getConfig('surfbar_pay_model') == "DYNAMIC") {
                // "Calculate" dynamic time
                $time += SURFBAR_CALCULATE_DYNAMIC_ADD();
        } // END - if
@@ -1250,10 +1248,10 @@ function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array())
        // Prepare content for notification routines
        $data[$urlId]['uid']         = $data[$urlId]['userid'];
        $data[$urlId]['frametester'] = FRAMETESTER($data[$urlId]['url']);
-       $data[$urlId]['reward']      = TRANSLATE_COMMA($_CONFIG['surfbar_static_reward']);
-       $data[$urlId]['costs']       = TRANSLATE_COMMA($_CONFIG['surfbar_static_costs']);
+       $data[$urlId]['reward']      = TRANSLATE_COMMA(getConfig('surfbar_static_reward'));
+       $data[$urlId]['costs']       = TRANSLATE_COMMA(getConfig('surfbar_static_costs'));
 
-       // Do some dirt fixing here:
+       // Do some dirty fixing here:
        if (($data[$urlId]['status'] == "STOPPED") && ($newStatus == "pending")) {
                // Fix for template change
                $newStatus = "continued";
@@ -1276,7 +1274,7 @@ function SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE () {
        $addon = 0;
 
        // Percentage part
-       $percent = abs(log($_CONFIG['surfbar_dynamic_percent'] / 100 + 1));
+       $percent = abs(log(getConfig('surfbar_dynamic_percent') / 100 + 1));
 
        // Get total users
        $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true);
@@ -1314,7 +1312,7 @@ function SURFBAR_CALCULATE_DYNAMIC_MAX_VALUE () {
        $max = log(2);
 
        // Percentage part
-       $percent = abs(log($_CONFIG['surfbar_dynamic_percent'] / 100 + 1));
+       $percent = abs(log(getConfig('surfbar_dynamic_percent') / 100 + 1));
 
        // Get total users
        $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true);
@@ -1414,7 +1412,7 @@ WHERE sbu.userid NOT IN (".implode(",", $UIDs).") AND (sbu.views_allowed=0 OR (s
 GROUP BY sbu.id", __FILE__, __LINE__);
 
        // Log last query
-       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "lastQuery=".$_CONFIG['db_last_query']."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "lastQuery=".getConfig('db_last_query')."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."", false);
 
        // Fetch max rand
        $maxRand = SQL_NUMROWS($result);
@@ -1477,15 +1475,13 @@ function SURFBAR_GET_ACTION_ARRAY ($status) {
 }
 // Reload to configured stop page
 function SURFBAR_RELOAD_TO_STOP_PAGE($page="stop") {
-       global $_CONFIG;
-
        // Internal or external?
-       if (($_CONFIG['surfbar_pause_mode'] == "INTERNAL") || (empty($_CONFIG['surfbar_pause_url']))) {
+       if ((getConfig('surfbar_pause_mode') == "INTERNAL") || (getConfig('surfbar_pause_url') == "")) {
                // Reload to internal page
                LOAD_URL("surfbar.php?frame=".$page);
        } else {
                // Reload to external page
-               LOAD_URL($_CONFIG['surfbar_pause_url']);
+               LOAD_URL(getConfig('surfbar_pause_url'));
        }
 }
 
@@ -1558,7 +1554,7 @@ LIMIT 1",
        }
 
        // Is there an id number?
-       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "lastQuery=".$_CONFIG['db_last_query']."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "lastQuery=".getConfig('db_last_query')."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."", false);
        if (SQL_NUMROWS($result) == 1) {
                // Load/cache data
                //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "count(".count($SURFBAR_CACHE).") - BEFORE", false);
@@ -1588,7 +1584,7 @@ LIMIT 1",
                //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "BASE/STATIC - reward=".SURFBAR_GET_REWARD()."|costs=".SURFBAR_GET_COSTS()."", false);
 
                // Only in dynamic model add the dynamic bonus!
-               if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") {
+               if (getConfig('surfbar_pay_model') == "DYNAMIC") {
                        // Calculate dynamic reward/costs and add it
                        $SURFBAR_CACHE['reward'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
                        $SURFBAR_CACHE['costs']  += SURFBAR_CALCULATE_DYNAMIC_ADD();