]> git.mxchange.org Git - mailer.git/blobdiff - inc/extensions/ext-bonus.php
- Concept of a safe for collected points added
[mailer.git] / inc / extensions / ext-bonus.php
index 2d83afcc55d8e03b64cedc04e13512c48cd3a0a9..7adaf2f7d572aa265c936126c7faf5664117cdbc 100644 (file)
@@ -55,37 +55,37 @@ case "register": // Do stuff when installtion is running (modules.php?module=adm
        $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu VALUES (NULL,'main','bonus','Bonuspunkte',7,'Y','Y', '', 0)";
        $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bonus";
        $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_bonus (
-id BIGINT(20) NOT NULL AUTO_INCREMENT,
-cat_id BIGINT(20) NOT NULL DEFAULT '0',
+id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+cat_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
 subject VARCHAR(255) NOT NULL DEFAULT '',
 text LONGBLOB NOT NULL,
 receivers LONGBLOB NOT NULL,
-points BIGINT(20) NOT NULL DEFAULT '0',
-time TINYINT(3) NOT NULL DEFAULT '0',
+points BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
+time TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
 data_type ENUM('NEW','QUEUE','SEND') NOT NULL DEFAULT 'NEW',
 timestamp VARCHAR(10) NOT NULL DEFAULT '0',
 url VARCHAR(255) NOT NULL DEFAULT '',
-target_send BIGINT(20) NOT NULL DEFAULT '0',
-clicks BIGINT(20) NOT NULL DEFAULT '0',
-mails_sent BIGINT(20) NOT NULL DEFAULT '0',
+target_send BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
+clicks BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
+mails_sent BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
 KEY(cat_id),
 PRIMARY KEY  (id)
 )TYPE=MyISAM";
-       $SQLs[] = "alter table "._MYSQL_PREFIX."_user_links modify link_type ENUM('NORMAL','BONUS') NOT NULL DEFAULT 'NORMAL'";
-       $SQLs[] = "alter table "._MYSQL_PREFIX."_user_links ADD bonus_id BIGINT(20) NOT NULL DEFAULT '0'";
+       $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_links MODIFY link_type ENUM('NORMAL','BONUS') NOT NULL DEFAULT 'NORMAL'";
+       $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_links ADD bonus_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'";
        $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_links ADD INDEX (bonus_id)";
 
        // Run this SQL when html or html_mail extension is installed
-       if (EXT_IS_ACTIVE("html_mail")) $SQLs[] = "alter table "._MYSQL_PREFIX."_bonus add html_msg ENUM('Y','N') NOT NULL DEFAULT 'N'";
+       if (EXT_IS_ACTIVE("html_mail")) $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_bonus add html_msg ENUM('Y','N') NOT NULL DEFAULT 'N'";
        break;
 
 case "remove": // Do stuff when removing extension
        // SQL commands to run
-       $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE what='bonus' OR what='config_bonus' OR what='send_bonus' OR what='list_bonus' LIMIT 4";
+       $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE what IN ('bonus','config_bonus','send_bonus','list_bonus') LIMIT 4";
        $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_member_menu WHERE what='bonus' LIMIT 1";
        $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_guest_menu WHERE action='bonus' LIMIT 1";
-       $SQLs[] = "alter table "._MYSQL_PREFIX."_user_links modify link_type ENUM('NORMAL') NOT NULL DEFAULT 'NORMAL'";
-       $SQLs[] = "alter table "._MYSQL_PREFIX."_user_links drop bonus_id";
+       $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_links MODIFY link_type ENUM('NORMAL') NOT NULL DEFAULT 'NORMAL'";
+       $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_links DROP bonus_id";
        $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bonus";
        $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bonus_urls";
        $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bonus_customer";
@@ -126,11 +126,10 @@ case "update": // Update an extension
                $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu VALUES (NULL,'setup','config_bonus','Bonus-{!POINTS!}',8,'Richten Sie Bonus-{!POINTS!} ein, die beim x'ten Klick auf die Mail verbucht werden sollen. Beispiele: Der 1. Klick sollte mehr {!POINTS!} zusätzlich bekommen, als der 10. Klick.')";
                $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD login_bonus DOUBLE(20,3) NOT NULL DEFAULT '10.000'";
                $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD turbo_bonus DOUBLE(20,3) NOT NULL DEFAULT '100.000'";
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD login_timeout BIGINT(20) NOT NULL DEFAULT '86400'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD login_timeout BIGINT(20) UNSIGNED NOT NULL DEFAULT '86400'";
                $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD turbo_rates VARCHAR(255) NOT NULL DEFAULT '50;20;10'";
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_ranks TINYINT(3) NOT NULL DEFAULT '10'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_ranks TINYINT(3) UNSIGNED NOT NULL DEFAULT '10'";
                // Use actual month for this update
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD last_bonus_month CHAR(2) NOT NULL DEFAULT '".date("m", time())."'";
                $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD login_bonus DOUBLE(20,3) NOT NULL DEFAULT '0.000'";
                $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD turbo_bonus DOUBLE(20,3) NOT NULL DEFAULT '0.000'";
                $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_stats ADD bonus_stats ENUM('Y', 'N') NOT NULL DEFAULT 'N'";
@@ -143,11 +142,11 @@ case "update": // Update an extension
        case "0.2.2": // SQL queries for v0.2.2
                $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_bonus_turbo";
                $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_bonus_turbo (
-id BIGINT(20) NOT NULL AUTO_INCREMENT,
-userid BIGINT(20) NOT NULL DEFAULT '0',
-mail_id BIGINT(20) NOT NULL DEFAULT '0',
-bonus_id BIGINT(20) NOT NULL DEFAULT '0',
-level BIGINT(20) NOT NULL DEFAULT '0',
+id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+userid BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
+mail_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
+bonus_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
+level BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
 points DOUBLE(20,3) NOT NULL DEFAULT '0.000',
 timemark VARCHAR(32) NOT NULL DEFAULT '0',
 PRIMARY KEY(id),
@@ -225,7 +224,7 @@ KEY userid (userid)
 
        case "0.3.3": // SQL queries for v0.3.3
                // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Seit <A href=\"".SERVER_URL."/patches/340-Gast_Mitgliedsmenue_Deaktivieren.zip\">Patch 340</A> &uuml;berfl&uuml;ssige HTML-Tags entfernt.";
+               $UPDATE_NOTES = "Seit <A href=\"#\">Patch 340</A> &uuml;berfl&uuml;ssige HTML-Tags entfernt.";
                break;
 
        case "0.3.4": // SQL queries for v0.3.4
@@ -237,7 +236,7 @@ KEY userid (userid)
 
        case "0.3.5": // SQL queries for v0.3.5
                $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_mode ENUM('UID', 'JACKPOT', 'ADD') NOT NULL DEFAULT 'ADD'";
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_uid BIGINT(20) NOT NULL DEFAULT '0'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_uid BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'";
 
                // Update notes (these will be set as task text!)
                $UPDATE_NOTES = "Der Login-Bonus Aktiv-Bonus (= Klick-Bonus) k&ouml;nnen nun zuerst von einem Mitgliederaccount (das sollte Ihres sein!), vom Jackpot abgezogen oder einfach dazuadiert werden.";
@@ -264,8 +263,8 @@ KEY userid (userid)
                break;
 
        case "0.4.0": // SQL queries for v0.4.0
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_timeout BIGINT(20) NOT NULL DEFAULT '".(ONE_DAY * 7)."'";
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_lines BIGINT(20) NOT NULL DEFAULT '10'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_timeout BIGINT(20) UNSIGNED NOT NULL DEFAULT '".(ONE_DAY * 7)."'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_lines BIGINT(20) UNSIGNED NOT NULL DEFAULT '10'";
 
                // Update notes (these will be set as task text!)
                $UPDATE_NOTES = "Automatisches L&ouml;schen von Turbo-Bonus-Zeilen ("._MYSQL_PREFIX."_bonus_turbo) und begrenzte Anzahl von Eintr&auml;gen hinzugef&uuml;gt.";
@@ -287,13 +286,13 @@ KEY userid (userid)
                break;
 
        case "0.4.4": // SQL queries for v0.4.4
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_order DOUBLE(20,5) NOT NULL DEFAULT '15.00000'";
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_ref DOUBLE(20,5) NOT NULL DEFAULT '100.00000'";
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_stats DOUBLE(20,5) NOT NULL DEFAULT '5.00000'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_order DOUBLE(20,5) UNSIGNED NOT NULL DEFAULT '15.00000'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_ref DOUBLE(20,5) UNSIGNED NOT NULL DEFAULT '100.00000'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_stats DOUBLE(20,5) UNSIGNED NOT NULL DEFAULT '5.00000'";
                $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_active ENUM('Y', 'N') NOT NULL DEFAULT 'Y'";
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD bonus_order DOUBLE(20,5) NOT NULL DEFAULT '0.00000'";
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD bonus_ref DOUBLE(20,5) NOT NULL DEFAULT '0.00000'";
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD bonus_stats DOUBLE(20,5) NOT NULL DEFAULT '0.00000'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD bonus_order DOUBLE(20,5) UNSIGNED NOT NULL DEFAULT '0.00000'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD bonus_ref DOUBLE(20,5) UNSIGNED NOT NULL DEFAULT '0.00000'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD bonus_stats DOUBLE(20,5) UNSIGNED NOT NULL DEFAULT '0.00000'";
                $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_stats ADD is_stats ENUM('Y', 'N') NOT NULL DEFAULT 'N'";
 
                // Update notes (these will be set as task text!)
@@ -353,14 +352,6 @@ KEY userid (userid)
                break;
 
        case "0.5.5": // SQL queries for v0.5.5
-               // Get previous month
-               $prev = date("m", time()) - 1;
-               if (strlen($prev) == 1) $prev = "0".$prev;
-               if ($prev == "00") $prev = "12";
-
-               // Reset monthly active rallye
-               $SQLs[] = "UPDATE "._MYSQL_PREFIX."_config SET last_bonus_month='".$prev."' WHERE config=0 LIMIT 1";
-
                // Update notes (these will be set as task text!)
                $UPDATE_NOTES = "Weitere Variablenfehler in <STRONG>inc/monthly_bonus.php</STRONG> haben daf&uuml;r gesorgt, dass die monatliche Aktiv-Rallye nicht ausgesch&uuml;ttet wurde. Mit diesem Update wurde die Aussch&uuml;ttung initialisiert. Ihre Mitglieder bekommen voraussichtlicht nichts doppelt verg&uuml;tet.";
                break;
@@ -483,11 +474,11 @@ WHERE last_online < ".$mark." ORDER BY userid";
                $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_en_notify ENUM('Y', 'N') NOT NULL DEFAULT 'N'";
                $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_di_notify ENUM('Y', 'N') NOT NULL DEFAULT 'N'";
                $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_new_mem_notify ENUM('Y', 'N') NOT NULL DEFAULT 'N'";
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_notify_points DOUBLE(20,5) NOT NULL DEFAULT '0.00000'";
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_notify_wait BIGINT(20) NOT NULL DEFAULT '30'";
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD bonus_ral_notify BIGINT(20) NOT NULL DEFAULT '0'";
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD bonus_ral_en_notify BIGINT(20) NOT NULL DEFAULT '0'";
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD bonus_ral_di_notify BIGINT(20) NOT NULL DEFAULT '0'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_notify_points DOUBLE(20,5) UNSIGNED NOT NULL DEFAULT '0.00000'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD bonus_notify_wait BIGINT(20) UNSIGNED NOT NULL DEFAULT '30'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD bonus_ral_notify BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD bonus_ral_en_notify BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD bonus_ral_di_notify BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'";
 
                // Update notes (these will be set as task text!)
                $UPDATE_NOTES = "Optionale automatische Benachrichtigung &uuml;ber aktivierte und/oder deaktivierte Aktiv-Rallye einstellbar.";
@@ -540,23 +531,19 @@ WHERE last_online < ".$mark." ORDER BY userid";
        break;
 
 default: // Do stuff when extension is loaded
-       $dummy = LOAD_CONFIG();
-       $_CONFIG = array_merge($_CONFIG, $dummy);
-       unset($dummy);
-
-       if (defined('__DAILY_RESET') && (!DEBUG_MODE) && ($CSS != 1))
+       if (isBooleanConstantAndTrue('__DAILY_RESET') && (!DEBUG_MODE) && ($CSS != 1))
        {
                // Daily reset was run so let's check if active rallye is activated
                if ($_CONFIG['bonus_active'] == "Y")
                {
                        // Run active rallye
-                       if($_CONFIG['bonus_stats'] > 0) $INC_POOL[] = PATH."inc/stats_bonus.php";
-                       $INC_POOL[] = PATH."inc/monthly/monthly_bonus.php";
+                       if($_CONFIG['bonus_stats'] > 0) $INC_POOL[] = sprintf("%sinc/stats_bonus.php", PATH);
+                       $INC_POOL[] = sprintf("%sinc/monthly/monthly_bonus.php", PATH);
                }
                 else
                {
                        // Reset points
-                       $INC_POOL[] = PATH."inc/reset/reset_bonus.php";
+                       $INC_POOL[] = sprintf("%sinc/reset/reset_bonus.php", PATH);
                }
        }
 
@@ -564,7 +551,7 @@ default: // Do stuff when extension is loaded
        if (($_CONFIG['bonus_active'] == "Y") && ($_CONFIG['bonus_new_mem_notify'] == "Y"))
        {
                // Include file for sending out mails
-               $INC_POOL[] = PATH."inc/mails/bonus_mails.php";
+               $INC_POOL[] = sprintf("%sinc/mails/bonus_mails.php", PATH);
        }
        break;
 }