More fixes, missing js.php added
[mailer.git] / inc / modules / guest / what-mediadata.php
index 5d7439a7a59dbc978143df6dfab13bd9bade4e15..36a08cea700b88bbef4781045b01e321d86c08cd 100644 (file)
@@ -35,7 +35,7 @@
  ************************************************************************/
 
 // Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+if (!defined('__SECURITY')) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
 } elseif (!EXT_IS_ACTIVE("mediadata")) {
@@ -44,11 +44,11 @@ if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
 }
 
 // Add description as navigation point
-ADD_DESCR("guest", basename(__FILE__));
+ADD_DESCR("guest", __FILE__);
 
-define('value', 'value');
-define('lang', 'lang');
-define('rows', 'rows');
+define('value', "value");
+define('lang', "lang");
+define('rows', "rows");
 
 // Get total confirmed user IDs...
 define('user_confirmed'  , round(GET_TOTAL_DATA("CONFIRMED"  , "user_data", "userid", "status", true)));
@@ -89,42 +89,36 @@ SQL_FREERESULT($result_rec);
 define('user_max_rec', $dummy);
 
 // Max mails per day
-$result_max = SQL_QUERY("SELECT SUM(max_mails) FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED' AND max_mails > 0", __FILE__, __LINE__);
-list($dmy) = SQL_FETCHROW($result_max);
-SQL_FREERESULT($result_max);
-define('max', $dmy);
+define('max', GET_TOTAL_DATA("CONFIRMED", "user_data", "max_mails", "status", false, " AND `max_mails` > 0"));
 
 // Max mails for this day
-$result_rec = SQL_QUERY("SELECT SUM(receive_mails) FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED' AND receive_mails > 0", __FILE__, __LINE__);
-list($dummy) = SQL_FETCHROW($result_rec);
-define('rec', $dummy);
-SQL_FREERESULT($result_rec);
+define('rec', GET_TOTAL_DATA("CONFIRMED", "user_data", "receive_mails", "status", false, " AND `receive_mails` > 0"));
 
 // Initial lots of variables
-$bmails = "0"; $sent = "0"; $max = "0"; $rec = "0"; $clicks = "0";
+$bmails = 0; $sent = 0; $max = 0; $rec = 0; $clicks = 0;
 
 // Mail orders (only current)
 $nmails = MEDIA_GET_ENTRY("normal_orders");
-if (empty($nmails)) $nmails = "0";
+if (empty($nmails)) $nmails = 0;
 
 // Mails sent so far
 $clicks = MEDIA_GET_ENTRY("normal_clicks");
 $sent   = MEDIA_GET_ENTRY("normal_send");
-if (empty($sent))   $sent   = "0";
-if (empty($clicks)) $clicks = "0";
+if (empty($sent))   $sent   = 0;
+if (empty($clicks)) $clicks = 0;
 
 // Bonus mails
 if (EXT_IS_ACTIVE("bonus")) {
        $bmails = MEDIA_GET_ENTRY("bonus_orders");
-       if (empty($bmails)) $bmails = "0";
+       if (empty($bmails)) $bmails = 0;
 
        // Count bonus mails clicks / sent mails
        $dmy  = MEDIA_GET_ENTRY("bonus_clicks");
        $dmy2 = MEDIA_GET_ENTRY("bonus_send");
-       if (empty($dmy))  $dmy  = "0";
-       if (empty($dmy2)) $dmy2 = "0";
+       if (empty($dmy))  $dmy  = 0;
+       if (empty($dmy2)) $dmy2 = 0;
        $sent += $dmy2; $clicks += $dmy;
-}
+} // END - if
 
 define('user_stats', ($nmails + $bmails));
 define('sent'      , $sent);
@@ -140,10 +134,10 @@ define('_clr', TRANSLATE_COMMA($clr)."%");
 $result = SQL_QUERY("SELECT points FROM "._MYSQL_PREFIX."_jackpot WHERE ok='ok' LIMIT 1", __FILE__, __LINE__);
 list($jackpot) = SQL_FETCHROW($result);
 SQL_FREERESULT($result);
-if (empty($jackpot)) $jackpot = "0";
+if (empty($jackpot)) $jackpot = 0;
 define('jackpot', TRANSLATE_COMMA($jackpot));
 
-// Total referral link clicks, total logins
+// Total referal link clicks, total logins
 $result = SQL_QUERY("SELECT DISTINCT SUM(d.ref_clicks), SUM(d.total_logins)
 FROM "._MYSQL_PREFIX."_user_data AS d", __FILE__, __LINE__);
 list($ref, $logins) = SQL_FETCHROW($result);
@@ -152,15 +146,15 @@ SQL_FREERESULT($result);
 // Get total points
 $points = MEDIA_GET_ENTRY("total_points");
 
-if (empty($points)) $points = "0";
-if (empty($ref))    $ref    = "0";
-if (empty($logins)) $logins = "0";
+if (empty($points)) $points = 0;
+if (empty($ref))    $ref    = 0;
+if (empty($logins)) $logins = 0;
 
 define('__TOTAL_POINTS'   , TRANSLATE_COMMA($points));
 define('__TOTAL_REFCLICKS', $ref);
 define('__TOTAL_LOGINS'   , $logins);
 
-// Referral banner
+// Referal banner
 $result = SQL_QUERY("SELECT COUNT(id) FROM "._MYSQL_PREFIX."_refbanner WHERE visible='Y'", __FILE__, __LINE__);
 list($total) = SQL_FETCHROW($result);
 SQL_FREERESULT($result);
@@ -168,9 +162,9 @@ $result = SQL_QUERY("SELECT SUM(counter), SUM(clicks) FROM "._MYSQL_PREFIX."_ref
 list($views, $clicks) = SQL_FETCHROW($result);
 SQL_FREERESULT($result);
 
-if (empty($total))  $total  = "0";
-if (empty($views))  $views  = "0";
-if (empty($clicks)) $clicks = "0";
+if (empty($total))  $total  = 0;
+if (empty($views))  $views  = 0;
+if (empty($clicks)) $clicks = 0;
 
 define('__REF_TOTAL' , $total);
 define('__REF_VIEWS' , $views);
@@ -191,7 +185,7 @@ if (EXT_IS_ACTIVE("beg")) {
        $result = SQL_QUERY("SELECT SUM(beg_clicks) FROM "._MYSQL_PREFIX."_user_data WHERE beg_clicks>0", __FILE__, __LINE__);
        list($extra) = SQL_FETCHROW($result);
        SQL_FREERESULT($result);
-       if (empty($extra)) $extra = "0";
+       if (empty($extra)) $extra = 0;
        $content = array(
                'lang'  => MEDIA_BEG_CLICKS,
                'value' => $extra
@@ -209,10 +203,10 @@ if (EXT_IS_ACTIVE("doubler")) {
        list($count2, $points2) = SQL_FETCHROW($result);
        SQL_FREERESULT($result);
 
-       if (empty($count1))  $count1  = "0";
-       if (empty($count2))  $count2  = "0";
-       if (empty($points1)) $points1 = "0";
-       if (empty($points2)) $points2 = "0";
+       if (empty($count1))  $count1  = 0;
+       if (empty($count2))  $count2  = 0;
+       if (empty($points1)) $points1 = 0;
+       if (empty($points2)) $points2 = 0;
 
        // Add header
        $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_hrow", true, MEDIA_DOUBLER_HEADER);
@@ -251,7 +245,7 @@ ON h.userid=d.userid
 WHERE d.holiday_active='Y'",
  __FILE__, __LINE__);
        list($holiday) = SQL_FETCHROW($result);
-       if (empty($holiday)) $holiday = "0";
+       if (empty($holiday)) $holiday = 0;
        $content = array(
                'lang'  => MEDIA_HOLIDAY_COUNT,
                'value' => $holiday
@@ -268,8 +262,8 @@ LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
 ON t.userid=d.userid",
  __FILE__, __LINE__);
        list($count_in, $points_in) = SQL_FETCHROW($result);
-       if (empty($count_in))  $count_in  = "0";
-       if (empty($points_in)) $points_in = "0";
+       if (empty($count_in))  $count_in  = 0;
+       if (empty($points_in)) $points_in = 0;
 
        $result = SQL_QUERY("SELECT DISTINCT COUNT(t.id), SUM(t.points)
 FROM "._MYSQL_PREFIX."_user_transfers_out AS t
@@ -277,8 +271,8 @@ LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
 ON t.userid=d.userid",
  __FILE__, __LINE__);
        list($count_out, $points_out) = SQL_FETCHROW($result);
-       if (empty($count_out))  $count_out  = "0";
-       if (empty($points_out)) $points_out = "0";
+       if (empty($count_out))  $count_out  = 0;
+       if (empty($points_out)) $points_out = 0;
 
        // Add header
        $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_hrow", true, MEDIA_TRANSFER_HEADER);