]> git.mxchange.org Git - mailer.git/blobdiff - 0.2.1/inc/libs/bonus_functions.php
branched
[mailer.git] / 0.2.1 / inc / libs / bonus_functions.php
diff --git a/0.2.1/inc/libs/bonus_functions.php b/0.2.1/inc/libs/bonus_functions.php
deleted file mode 100644 (file)
index 888ecab..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-<?php
-/************************************************************************
- * MXChange v0.2.1                                    Start: 11/10/2004 *
- * ===============                              Last change: 03/18/2005 *
- *                                                                      *
- * -------------------------------------------------------------------- *
- * File              : bonus_functions.php                              *
- * -------------------------------------------------------------------- *
- * Short description : Special functions for bonus extension            *
- * -------------------------------------------------------------------- *
- * Kurzbeschreibung  : Spezielle Funktion fuer bonus-Erweiterung        *
- * -------------------------------------------------------------------- *
- *                                                                      *
- * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
- * For more information visit: http://www.mxchange.org                  *
- *                                                                      *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or    *
- * (at your option) any later version.                                  *
- *                                                                      *
- * This program is distributed in the hope that it will be useful,      *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
- * GNU General Public License for more details.                         *
- *                                                                      *
- * You should have received a copy of the GNU General Public License    *
- * along with this program; if not, write to the Free Software          *
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
- * MA  02110-1301  USA                                                  *
- ************************************************************************/
-
-// Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
-{
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
-}
-// This function must be run *BEFORE* a link is removed from table 'mxchange_user_links' !
-function BONUS_ADD_TURBO_POINTS($mid, $uid, $type)
-{
-       global $CONFIG;
-
-       // Shall we add bonus points?
-       if ($CONFIG['bonus_active'] == "N") return;
-
-       // Select SQL command
-       $SQL = "";
-       switch ($type)
-       {
-       case "bonusid":
-               $result = SQL_QUERY_ESC("SELECT clicks FROM "._MYSQL_PREFIX."_bonus WHERE id=%d LIMIT 1",
-                array($mid), __FILE__, __LINE__);
-               $bonus = $mid; $mail = "0";
-               break;
-
-       case "mailid" :
-               $result = SQL_QUERY_ESC("SELECT clicks FROM "._MYSQL_PREFIX."_user_stats WHERE id=%d LIMIT 1",
-                array($mid), __FILE__, __LINE__);
-               $bonus = "0"; $mail = $mid;
-               break;
-       }
-
-       // Load clicks from table as current rank
-       list($rank) = SQL_FETCHROW($result);
-
-       if ($rank == 1)
-       {
-               // First rank!
-               $rank = 1;
-               $points = $CONFIG['turbo_bonus'];
-       }
-        else
-       {
-               // Anything else so let's explode all entered rank points
-               $test = explode(";", $CONFIG['bonus_rates']);
-               if (!empty($test[$rank - 2]))
-               {
-                       // Level found
-                       $points = $test[$rank - 2];
-               }
-                else
-               {
-                       // Level not found!
-                       $points = "0.00000";
-               }
-       }
-
-       // Add points to his account directly
-       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET turbo_bonus=turbo_bonus+".$points." WHERE userid=%d LIMIT 1",
-        array(bigintval($uid)), __FILE__, __LINE__);
-
-       // Rember this whole data for displaying ranking list
-       $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_bonus_turbo (userid, mail_id, bonus_id, level, points, timemark) VALUES ('%s', '%s', '%s', '".$rank."', '".$points."', UNIX_TIMESTAMP())",
-        array(bigintval($uid), bigintval($mail), bigintval($bonus)), __FILE__, __LINE__);
-
-       if ((GET_EXT_VERSION("bonus") >= "0.3.5") && ($CONFIG['bonus_mode'] != "ADD") && ($points > 0)) BONUS_POINTS_HANDLER($points);
-}
-//
-function BONUS_MAKE_RANK_ROWS($data, $type, $uid)
-{
-       global $CONFIG;
-       $self = false; $OUT = "";
-
-       // How many ranks do we have?
-       $ranks = sizeof(explode(";", $CONFIG['bonus_rates'])) + 1;
-
-       // Load current user's data
-       $result = SQL_QUERY_ESC("SELECT level, points, timemark FROM "._MYSQL_PREFIX."_bonus_turbo WHERE %s=%s AND userid=%d LIMIT 1",
-        array($type, $data, $uid), __FILE__, __LINE__);
-       if (SQL_NUMROWS($result) == 1)
-       {
-               // Load data
-               list($rank, $points, $mark) = SQL_FETCHROW($result);
-
-               // Remember all values for later use
-               $self  = true; $points = TRANSLATE_COMMA($points);
-
-               // Transfer data to template
-               define('__YR_LEVEL' , $rank);
-               define('__YR_POINTS', $points);
-               define('__YR_TMARK' , MAKE_DATETIME($mark, "1"));
-
-               // Load template
-               define('__YOUR_RANKING_LINE', LOAD_TEMPLATE("show_bonus_yr", true));
-       }
-
-       // Load rankings
-       $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_bonus_turbo WHERE %s=%s ORDER BY level LIMIT %s",
-        array($type, $data, $CONFIG['bonus_lines']), __FILE__, __LINE__);
-       if (SQL_NUMROWS($result) > 0)
-       {
-               // Start generating the ranking list
-               $max = SQL_NUMROWS($result);
-
-               $SW = 2;
-               for ($rank = 1; $rank <= $max; $rank++)
-               {
-                       // Load data
-                       $result_users = SQL_QUERY_ESC("SELECT userid, points, timemark FROM "._MYSQL_PREFIX."_bonus_turbo WHERE %s=%s AND level='%s' LIMIT 1",
-                        array($type, $data, $rank), __FILE__, __LINE__);
-                       list($userid, $points, $mark) = SQL_FETCHROW($result_users);
-
-                       // Are you one of them?
-                       if (empty($userid))
-                       {
-                               // Nothing found
-                               $userid = "---"; $points = "---";
-                       }
-                        else
-                       {
-                               // Translate comma
-                               $points = TRANSLATE_COMMA($points);
-                       }
-
-                       // Output row
-                       $OUT .= "<TR>
-  <TD class=\"bonus_rank_".$rank." bottom2 switch_sw".$SW."\">&nbsp;".$rank.".</TD>
-  <TD class=\"bonus_rank_".$rank." bottom2 switch_sw".$SW."\" align=\"center\">".$userid."</TD>
-  <TD class=\"bonus_rank_".$rank." bottom2 switch_sw".$SW."\" align=\"center\">".$points."</TD>
-</TR>\n";
-                       $SW = 3 - $SW;
-               }
-               if (!$self)
-               {
-                       // If current user was not found set constant
-                       define('__YOUR_RANKING_LINE', BONUS_RANK_YOU_ARE_NOT_FOUND);
-               }
-       }
-        else
-       {
-               // No entries found!
-               $OUT = "<TR>
-  <TD colspan=\"3\" align=\"center\" height=\"30\" class=\"bottom2\">
-    <STRONG class=\"guest_failed\">".BONUS_NO_RANKS_1.$data.BONUS_NO_RANKS_2."</STRONG>
-  </TD>
-</TR>\n";
-               define('__YOUR_RANKING_LINE', "");
-       }
-       return $OUT;
-}
-//
-function BONUS_POINTS_HANDLER($MODE)
-{
-       global $CONFIG;
-
-       // Shall we add bonus points?
-       if ($CONFIG['bonus_active'] == "N") return;
-
-       // Switch to jackpot-mode when no UID is supplied but userid-mode is selected
-       if (($CONFIG['bonus_mode'] == "UID") && ($CONFIG['bonus_uid'] == "0")) $CONFIG['bonus_mode'] = "JACKPOT";
-
-       if ($MODE == "login_bonus")
-       {
-               // Login bonus detected
-               $POINTS = $CONFIG['login_bonus'];
-       }
-        else
-       {
-               // Direct points supplied
-               $POINTS = $MODE;
-       }
-
-       // Subtract points from...
-       switch ($CONFIG['bonus_mode'])
-       {
-       case "JACKPOT": // ... jackpot
-               if ((SUB_JACKPOT($POINTS) == -1) && ($CONFIG['bonus_uid'] > 0))
-               {
-                       // Check points amount first...
-                       $TOTAL = GET_TOTAL_DATA($CONFIG['bonus_uid'], "user_points", "points") - GET_TOTAL_DATA($CONFIG['bonus_uid'], "user_data", "used_points");
-                       if ($TOTAL >= $POINTS)
-                       {
-                               // Subtract points from userid's account
-                               $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET used_points=used_points+%s WHERE userid=%d LIMIT 1",
-                                array(bigintval($POINTS), bigintval($CONFIG['bonus_uid'])), __FILE__, __LINE__);
-
-                               // Update mediadata as well
-                               if (GET_EXT_VERSION("mediadata") >= "0.0.4")
-                               {
-                                       // Update database
-                                       MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $POINTS);
-                               }
-                       }
-               }
-               break;
-
-       case "UID": // ... userid's account
-               // Check his amount first
-               $TOTAL = GET_TOTAL_DATA($CONFIG['bonus_uid'], "user_points", "points") - GET_TOTAL_DATA($CONFIG['bonus_uid'], "user_data", "used_points");
-               if ($TOTAL >= $POINTS)
-               {
-                       // Subtract points from userid's account
-                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET used_points=used_points+%s WHERE userid=%d LIMIT 1",
-                        array(bigintval($POINTS), bigintval($CONFIG['bonus_uid'])),  __FILE__, __LINE__);
-
-                       // Update mediadata as well
-                       if (GET_EXT_VERSION("mediadata") >= "0.0.4")
-                       {
-                               // Update database
-                               MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $POINTS);
-                       }
-               }
-                else
-               {
-                       // Try to subtract from jackpot
-                       $DUMMY = SUB_JACKPOT($POINTS);
-               }
-               break;
-       }
-}
-//
-function BONUS_PURGE_EXPIRED_TURBO_BONUS()
-{
-       global $CONFIG;
-       // Remove entries
-       $result = SQL_QUERY("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_bonus_turbo WHERE timemark < ".(time() - $CONFIG['bonus_timeout']), __FILE__, __LINE__);
-       $DELETED = SQL_AFFECTEDROWS($result);
-       if ($DELETED > 0)
-       {
-               // Send out email to admin
-               if (GET_EXT_VERSION("admins") >= "0.4.1")
-               {
-                       SEND_ADMIN_EMAILS_PRO(AUTOPURGE_ADMIN_TURBO_SUBJECT, "admin_autopurge_turbo", $DELETED, "");
-               }
-                else
-               {
-                       $msg = LOAD_EMAIL_TEMPLATE("admin_autopurge_turbo", $DELETED, "");
-                       SEND_ADMIN_EMAILS(AUTOPURGE_ADMIN_TURBO_SUBJECT, $msg);
-               }
-       }
-}
-//
-?>