Reset rewritten, SQL fixed, zeros are now numeric
[mailer.git] / inc / modules / guest / what-mediadata.php
index 994a48fab85a4f48846b64d217c4aeddee9d5094..e73614e2f447011a5f8a294cb2b0f232f4f7c90e 100644 (file)
  ************************************************************************/
 
 // Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
-{
+if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
-}
- elseif (!EXT_IS_ACTIVE("mediadata"))
-{
+} elseif (!EXT_IS_ACTIVE("mediadata")) {
        ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "mediadata");
        return;
 }
@@ -66,15 +63,16 @@ define('__MT_START', MAKE_DATETIME($_CONFIG['mt_start'], "3"));
 define('__MT_STAGE', $_CONFIG['mt_stage']);
 
 // Project timestamp when number of members are reached
-$PROJECTED = round((time() - $_CONFIG['mt_start']) / user_count * $_CONFIG['mt_stage'] + $_CONFIG['mt_start']);
+$PROJECTED = 0;
+if (user_count > 0) {
+       $PROJECTED = round((time() - $_CONFIG['mt_start']) / user_count * $_CONFIG['mt_stage'] + $_CONFIG['mt_start']);
+}
+
 $YEAR = date('Y', $PROJECTED); $MONTH = date("m", $PROJECTED); $DAY = date("d", $PROJECTED);
 $TEST = mktime(0, 0, 0, $MONTH, $DAY, $YEAR);
-if ($TEST > time())
-{
+if ($TEST > time()) {
        define('__MT_PROJECTED', MAKE_DATETIME($PROJECTED, "3"));
-}
- else
-{
+} else {
        define('__MT_PROJECTED', USER_PROJECTION_UNKNOWN);
 }
 
@@ -103,29 +101,28 @@ define('rec', $dummy);
 SQL_FREERESULT($result_rec);
 
 // 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"))
-{
+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;
 }
 
@@ -133,7 +130,7 @@ define('user_stats', ($nmails + $bmails));
 define('sent'      , $sent);
 
 // All clicks
-define ('user_links', abs($sent - $clicks));
+define('user_links', abs($sent - $clicks));
 
 $clr = "0.00000";
 if ($sent > 0) $clr = $clicks / $sent * 100;
@@ -143,7 +140,7 @@ 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
@@ -155,9 +152,9 @@ 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);
@@ -171,9 +168,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);
@@ -189,13 +186,12 @@ $OUT_POINTS  = ""; $rowNameS_POINTS  = 2;
 $OUT_USER    = ""; $rowNameS_USER    = 6;
 $OUT_SPECIAL = ""; // We don't need row count here
 
-if (EXT_IS_ACTIVE("beg"))
-{
+if (EXT_IS_ACTIVE("beg")) {
        // Clicks on beg links
        $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
@@ -203,8 +199,8 @@ if (EXT_IS_ACTIVE("beg"))
        $OUT_EXTRA .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
        $rowNameS_EXTRA++;
 }
-if (EXT_IS_ACTIVE("doubler"))
-{
+
+if (EXT_IS_ACTIVE("doubler")) {
        // Total payed points
        $result = SQL_QUERY("SELECT COUNT(id), SUM(points) FROM "._MYSQL_PREFIX."_doubler WHERE completed='Y' AND points > 0", __FILE__, __LINE__);
        list($count1, $points1) = SQL_FETCHROW($result);
@@ -213,10 +209,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);
@@ -246,8 +242,7 @@ if (EXT_IS_ACTIVE("doubler"))
        $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
 }
 
-if (EXT_IS_ACTIVE("holiday"))
-{
+if (EXT_IS_ACTIVE("holiday")) {
        // Total holiday requests
        $result = SQL_QUERY("SELECT DISTINCT COUNT(h.userid)
 FROM "._MYSQL_PREFIX."_user_holidays AS h
@@ -256,7 +251,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
@@ -265,8 +260,7 @@ WHERE d.holiday_active='Y'",
        $rowNameS_USER++;
 }
 
-if (EXT_IS_ACTIVE("transfer"))
-{
+if (EXT_IS_ACTIVE("transfer")) {
        // Statistics for points transfers
        $result = SQL_QUERY("SELECT DISTINCT COUNT(t.id), SUM(t.points)
 FROM "._MYSQL_PREFIX."_user_transfers_in AS t
@@ -274,8 +268,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
@@ -283,8 +277,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);
@@ -324,9 +318,7 @@ define('__PATCH_LEVEL', $_CONFIG['patch_level']);
 define('__PATCH_CTIME', MAKE_DATETIME($_CONFIG['patch_ctime'], "2"));
 
 // Load template
-OPEN_TABLE("100%", "guest_content", "center", "top");
 LOAD_TEMPLATE("mediadata");
-CLOSE_TABLE();
 
 //
 ?>