From 7065f8bbf8b530b09de76e5af61be37bd54ed7c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 25 Aug 2008 16:31:28 +0000 Subject: [PATCH] Fix for division by zero in mediadata --- inc/modules/guest/what-mediadata.php | 38 +++++++++++----------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/inc/modules/guest/what-mediadata.php b/inc/modules/guest/what-mediadata.php index b6c41f637b..5d7439a7a5 100644 --- a/inc/modules/guest/what-mediadata.php +++ b/inc/modules/guest/what-mediadata.php @@ -35,13 +35,10 @@ ************************************************************************/ // 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); } @@ -116,8 +114,7 @@ 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"; @@ -189,8 +186,7 @@ $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); @@ -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); @@ -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 @@ -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 @@ -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(); // ?> -- 2.39.5