More misc fixes and rewrites (sorry, lame description)
[mailer.git] / inc / modules / guest / what-mediadata.php
index 2d6d3c0..ac1b450 100644 (file)
@@ -80,16 +80,10 @@ if ($TEST > time()) {
 }
 
 // User who can receive mails
 }
 
 // User who can receive mails
-$result_max = SQL_QUERY("SELECT COUNT(max_mails) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `status`='CONFIRMED' AND max_mails > 0", __FILE__, __LINE__);
-list($dummy) = SQL_FETCHROW($result_max);
-SQL_FREERESULT($result_max);
-define('user_max_mails', $dummy);
+define('user_max_mails', GET_TOTAL_DATA('CONFIRMED', 'user_data' 'max_mails', 'status', true, " AND `max_mails` > 0"));
 
 // Users who can receive mails today
 
 // Users who can receive mails today
-$result_rec = SQL_QUERY("SELECT COUNT(receive_mails) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `status`='CONFIRMED' AND receive_mails > 0", __FILE__, __LINE__);
-list($dummy) = SQL_FETCHROW($result_rec);
-SQL_FREERESULT($result_rec);
-define('user_max_rec', $dummy);
+define('user_max_rec', GET_TOTAL_DATA('CONFIRMED', 'user_data', 'receive_mails', 'status', true, " AND `receive_mails` > 0"));
 
 // Max mails per day
 define('max', GET_TOTAL_DATA('CONFIRMED', 'user_data', 'max_mails', 'status', false, " AND `max_mails` > 0"));
 
 // Max mails per day
 define('max', GET_TOTAL_DATA('CONFIRMED', 'user_data', 'max_mails', 'status', false, " AND `max_mails` > 0"));
@@ -134,7 +128,7 @@ if ($sent > 0) $clr = $clicks / $sent * 100;
 define('_clr', translateComma($clr).'%');
 
 // Load jackpot
 define('_clr', translateComma($clr).'%');
 
 // Load jackpot
-$result = SQL_QUERY("SELECT points FROM `{!_MYSQL_PREFIX!}_jackpot` WHERE ok='ok' LIMIT 1", __FILE__, __LINE__);
+$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;
 list($jackpot) = SQL_FETCHROW($result);
 SQL_FREERESULT($result);
 if (empty($jackpot)) $jackpot = 0;
@@ -158,10 +152,10 @@ define('__TOTAL_REFCLICKS', $ref);
 define('__TOTAL_LOGINS'   , $logins);
 
 // Referal banner
 define('__TOTAL_LOGINS'   , $logins);
 
 // 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);
-$result = SQL_QUERY("SELECT SUM(counter), SUM(clicks) FROM `{!_MYSQL_PREFIX!}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__);
+$total = GET_TOTAL_DATA('Y', 'refbanner', 'id', 'visible', true);
+
+// Total views and clicks
+$result = SQL_QUERY("SELECT SUM(`counter`) AS cnt, SUM(`clicks`) AS clx FROM `{!_MYSQL_PREFIX!}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__);
 list($views, $clicks) = SQL_FETCHROW($result);
 SQL_FREERESULT($result);
 
 list($views, $clicks) = SQL_FETCHROW($result);
 SQL_FREERESULT($result);
 
@@ -220,24 +214,25 @@ if (EXT_IS_ACTIVE('doubler')) {
                'lang'  => getMessage('MEDIA_DOUBLER_COUNT'),
                'value' => $count1,
                'rows'  => '4'
                'lang'  => getMessage('MEDIA_DOUBLER_COUNT'),
                'value' => $count1,
                'rows'  => '4'
-               );
-               // Add points
-               $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row2', true, $content);
-               $content = array(
+       );
+
+       // Add points
+       $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row2', true, $content);
+       $content = array(
                'lang'  => getMessage('MEDIA_DOUBLER_CPOINTS'),
                'value' => translateComma($points1)
                'lang'  => getMessage('MEDIA_DOUBLER_CPOINTS'),
                'value' => translateComma($points1)
-               );
-               $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
-               $content = array(
+       );
+       $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
+       $content = array(
                'lang'  => getMessage('MEDIA_DOUBLER_WAITING'),
                'value' => translateComma($count2)
                'lang'  => getMessage('MEDIA_DOUBLER_WAITING'),
                'value' => translateComma($count2)
-               );
-               $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
+       );
+       $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
                $content = array(
                'lang'  => getMessage('MEDIA_DOUBLER_WPOINTS'),
                'value' => translateComma($points2)
                $content = array(
                'lang'  => getMessage('MEDIA_DOUBLER_WPOINTS'),
                'value' => translateComma($points2)
-               );
-               $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
+       );
+       $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
 }
 
 if (EXT_IS_ACTIVE('holiday')) {
 }
 
 if (EXT_IS_ACTIVE('holiday')) {
@@ -249,6 +244,7 @@ ON h.userid=d.userid
 WHERE d.`holiday_active`='Y'",
        __FILE__, __LINE__);
        list($holiday) = SQL_FETCHROW($result);
 WHERE d.`holiday_active`='Y'",
        __FILE__, __LINE__);
        list($holiday) = SQL_FETCHROW($result);
+       SQL_FREERESULT($result);
        if (empty($holiday)) $holiday = 0;
        $content = array(
                'lang'  => getMessage('MEDIA_HOLIDAY_COUNT'),
        if (empty($holiday)) $holiday = 0;
        $content = array(
                'lang'  => getMessage('MEDIA_HOLIDAY_COUNT'),
@@ -266,6 +262,7 @@ LEFT JOIN `{!_MYSQL_PREFIX!}_user_data` AS d
 ON t.userid=d.userid",
        __FILE__, __LINE__);
        list($count_in, $points_in) = SQL_FETCHROW($result);
 ON t.userid=d.userid",
        __FILE__, __LINE__);
        list($count_in, $points_in) = SQL_FETCHROW($result);
+       SQL_FREERESULT($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;
 
@@ -275,6 +272,7 @@ LEFT JOIN `{!_MYSQL_PREFIX!}_user_data` AS d
 ON t.userid=d.userid",
        __FILE__, __LINE__);
        list($count_out, $points_out) = SQL_FETCHROW($result);
 ON t.userid=d.userid",
        __FILE__, __LINE__);
        list($count_out, $points_out) = SQL_FETCHROW($result);
+       SQL_FREERESULT($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;
 
@@ -284,24 +282,24 @@ ON t.userid=d.userid",
                'lang'  => getMessage('MEDIA_TRANSFER_IN_COUNT'),
                'value' => $count_in,
                'rows'  => '4'
                'lang'  => getMessage('MEDIA_TRANSFER_IN_COUNT'),
                'value' => $count_in,
                'rows'  => '4'
-               );
-               $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row2', true, $content);
-               $content = array(
+       );
+       $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row2', true, $content);
+       $content = array(
                'lang'  => getMessage('MEDIA_TRANSFER_IN_POINTS'),
                'value' => translateComma($points_in)
                'lang'  => getMessage('MEDIA_TRANSFER_IN_POINTS'),
                'value' => translateComma($points_in)
-               );
-               $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
-               $content = array(
+       );
+       $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
+       $content = array(
                'lang'  => getMessage('MEDIA_TRANSFER_OUT_COUNT'),
                'value' => $count_out
                'lang'  => getMessage('MEDIA_TRANSFER_OUT_COUNT'),
                'value' => $count_out
-               );
-               $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
-               $content = array(
+       );
+       $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
+       $content = array(
                'lang'  => getMessage('MEDIA_TRANSFER_OUT_POINTS'),
                'value' => translateComma($points_out)
                'lang'  => getMessage('MEDIA_TRANSFER_OUT_POINTS'),
                'value' => translateComma($points_out)
-               );
-               $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
-}
+       );
+       $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
+} // END - if
 
 define('__EXTRA_MEDIADATA'  , $OUT_EXTRA);
 define('__POINTS_MEDIADATA' , $OUT_POINTS);
 
 define('__EXTRA_MEDIADATA'  , $OUT_EXTRA);
 define('__POINTS_MEDIADATA' , $OUT_POINTS);