(no commit message)
[mailer.git] / 0.2.1 / inc / extensions / ext-newsletter.php
1 <?php\r
2 /************************************************************************\r
3  * MXChange v0.2.1                                    Start: 02/26/2005 *\r
4  * ================                             Last change: 02/26/2005 *\r
5  *                                                                      *\r
6  * -------------------------------------------------------------------- *\r
7  * File              : ext-newsletter.php                               *\r
8  * -------------------------------------------------------------------- *\r
9  * Short description : Extension for sending newsletters                *\r
10  * -------------------------------------------------------------------- *\r
11  * Kurzbeschreibung  : Erweiterung zum Versenden von Newslettern        *\r
12  * -------------------------------------------------------------------- *\r
13  *                                                                      *\r
14  * -------------------------------------------------------------------- *\r
15  * Copyright (c) 2003 - 2007 by Roland Haeder                           *\r
16  * For more information visit: http://www.mxchange.org                  *\r
17  *                                                                      *\r
18  * This program is free software; you can redistribute it and/or modify *\r
19  * it under the terms of the GNU General Public License as published by *\r
20  * the Free Software Foundation; either version 2 of the License, or    *\r
21  * (at your option) any later version.                                  *\r
22  *                                                                      *\r
23  * This program is distributed in the hope that it will be useful,      *\r
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *\r
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *\r
26  * GNU General Public License for more details.                         *\r
27  *                                                                      *\r
28  * You should have received a copy of the GNU General Public License    *\r
29  * along with this program; if not, write to the Free Software          *\r
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *\r
31  * MA  02110-1301  USA                                                  *\r
32  ************************************************************************/\r
33 \r
34 // Some security stuff...\r
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])))\r
36 {\r
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";\r
38         require($INC);\r
39 }\r
40 \r
41 // Version number\r
42 $EXT_VERSION = "0.1.2";\r
43 \r
44 // Auto-set extension version\r
45 if (empty($EXT_VER)) $EXT_VER = $EXT_VERSION;\r
46 \r
47 // Version history array (add more with , "0.1" and so on)\r
48 $EXT_VER_HISTORY = array("0.0", "0.0.1", "0.0.2", "0.0.3", "0.0.4", "0.0.5", "0.0.6", "0.0.7", "0.0.8", "0.0.9", "0.1.0", "0.1.1", "0.1.2");\r
49 \r
50 switch ($EXT_LOAD_MODE)\r
51 {\r
52 case "register": // Do stuff when installtion is running (modules.php?module=admin&action=login is called)\r
53         // SQL commands to run\r
54         $SQLs[] = "";\r
55         break;\r
56 \r
57 case "remove": // Do stuff when removing extension\r
58         // SQL commands to run\r
59         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE action='newsletter' AND what != 'send_newsletter' LIMIT 3";\r
60         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_member_menu WHERE what='newsletter' LIMIT 1";\r
61         break;\r
62 \r
63 case "activate": // Do stuff when admin activates this extension\r
64         // SQL commands to run\r
65         $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET locked='N', visible='Y' WHERE what='newsletter' LIMIT 1";\r
66         break;\r
67 \r
68 case "deactivate": // Do stuff when admin deactivates this extension\r
69         // SQL commands to run\r
70         $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET locked='Y', visible='N' WHERE what='newsletter' LIMIT 1";\r
71         break;\r
72 \r
73 case "update": // Update an extension\r
74         switch ($EXT_VER)\r
75         {\r
76         case "0.0.1": // SQL queries for v0.0.1\r
77                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('newsletter', '', 'Newsletter', 'Einstellungen am Newsletter, Newsletter versenden, Abbestellungen auflisten usw.', 3)";\r
78                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('newsletter', 'list_newsletter', 'Abbestellungen', 'Alle Abbestellungen auflisten und bearbeiten.', 2)";\r
79                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('newsletter', 'config_newsletter', 'Einstellungen', 'Geb&uuml;hr zum Abbestellen des Newsletters usw. sind hier einstellbar.', 3)";\r
80                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_admin_menu SET action='newsletter', what='send_newsletter', title='Versenden', sort='1' WHERE what='newsletter' LIMIT 1";\r
81                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('main', 'newsletter', 'Newsletter-Empfang', 'N', 'Y', 10)";\r
82                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD nl_charge float(10,2) not null default '5.00'";\r
83                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD nl_receive enum('Y', 'N') not null default 'Y'";\r
84                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD nl_until varchar(10) not null default '0'";\r
85                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD nl_timespan varchar(10) not null default '0'";\r
86 \r
87                 // Update notes (these will be set as task text!)\r
88                 $UPDATE_NOTES = "Vor der eigentlichen Freigabe dieser Erweiterungen habe ich sie versehendlich im Archiv mit auf den Server hochgeladen. Diese Version f&uuml;gt die bereits angek&uuml;ndigte Funktionalit&auml;ten, wie zum Beispiel das Einstellen der Abschaltgeb&uuml;hr.";\r
89                 break;\r
90 \r
91         case "0.0.2": // SQL queries for v0.0.2\r
92                 // Update notes (these will be set as task text!)\r
93                 $UPDATE_NOTES = "URL im Versendeformular und Option <I>Immer aktiv</I> f&uuml;r diese Erweiterung deaktiviert.";\r
94                 break;\r
95 \r
96         case "0.0.3": // SQL queries for v0.0.3\r
97                 // Update notes (these will be set as task text!)\r
98                 $UPDATE_NOTES = "W&ouml;rter <STRONG>Mailtausch</STRONG>, <STRONG>Mailtausches</STRONG> und <STRONG>Mailtauscher</STRONG> sind austauschbar.";\r
99                 break;\r
100 \r
101         case "0.0.4": // SQL queries for v0.0.4\r
102                 // Update notes (these will be set as task text!)\r
103                 $UPDATE_NOTES = "HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.";\r
104                 break;\r
105 \r
106         case "0.0.5": // SQL queries for v0.0.5\r
107                 // Update notes (these will be set as task text!)\r
108                 $UPDATE_NOTES = "Abspeichern von Einstellungen repariert.";\r
109                 break;\r
110 \r
111         case "0.0.6": // SQL queries for v0.0.6\r
112                 // Update notes (these will be set as task text!)\r
113                 $UPDATE_NOTES = "Bitte Script inc/monthly_newsletter.php l&ouml;schen!";\r
114                 break;\r
115 \r
116         case "0.0.7": // SQL queries for v0.0.7\r
117                 // Update notes (these will be set as task text!)\r
118                 $UPDATE_NOTES = "Script <STRONG>inc/monthly/monthly_newsletter.php</STRONG> wird nicht mehr ausgef&uuml;hrt, wenn die Erweiterung nicht aktiviert ist.";\r
119                 break;\r
120 \r
121         case "0.0.8": // SQL queries for v0.0.8\r
122                 // Update notes (these will be set as task text!)\r
123                 $UPDATE_NOTES = "Sicherheitsupdate f&uuml;r die Include-Befehle.";\r
124                 break;\r
125 \r
126         case "0.0.9": // SQL queries for v0.0.9\r
127                 // Update notes (these will be set as task text!)\r
128                 $UPDATE_NOTES = "Nur bei installierter Erweiterung <STRONG>html_mail</STRONG> k&ouml;nnen Sie auch HTML-Mails versenden.";\r
129                 break;\r
130 \r
131         case "0.1.0": // SQL queries for v0.1.0\r
132                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD nl_month char(2) not null default '".date("m", time())."'";\r
133 \r
134                 // Update notes (these will be set as task text!)\r
135                 $UPDATE_NOTES = "Nur bei installierter Erweiterung <STRONG>html_mail</STRONG> k&ouml;nnen Sie auch HTML-Mails versenden.";\r
136                 break;\r
137 \r
138         case "0.1.1": // SQL queries for v0.1.1\r
139                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config DROP nl_currency";\r
140 \r
141                 // Update notes (these will be set as task text!)\r
142                 $UPDATE_NOTES = "W&auml;hrung auf die Erweiterung <A href=\"".SERVER_URL."/extensions/ext-other.zip\"><STRONG>ext-other.zip</STRONG></A> verlagert. Bitte auch diese aktualisieren.";\r
143                 break;\r
144 \r
145         case "0.1.2": // SQL queries for v0.1.2\r
146                 // Update notes (these will be set as task text!)\r
147                 $UPDATE_NOTES = "Fehlerhinweis bei deaktivierter Erweiterung verbessert.";\r
148                 break;\r
149         }\r
150         break;\r
151 \r
152 default: // Do stuff when extension is loaded\r
153         $DUMMY = LOAD_CONFIG("0");\r
154         $CONFIG['nl_charge']   = $DUMMY['nl_charge'];   // Charge for your members to switch off the newsletter\r
155         $CONFIG['nl_month']    = $DUMMY['nl_month'];    // Last month of check interval\r
156         unset($DUMMY);\r
157 \r
158         // URL ends which are used to indentify the end of an URL or email link\r
159         // Don't use these chars in links... ;-)\r
160         //\r
161         $URL_ENDS = array(\r
162                 " ",\r
163                 "\n",\r
164                 "\r",\r
165                 ")",\r
166         );\r
167 \r
168         // Valid email chars (without @, or do you want to have another @ inside your email addy?)\r
169         $VALID_EMAIL_CHARS = array(\r
170                 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',\r
171                 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',\r
172                 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',   '-', '.', '_', '0', '1',\r
173                 '2', '3', '4', '5', '6', '7', '8', '9'\r
174         );\r
175 \r
176         if (defined('__DAILY_RESET') && (!DEBUG_MODE) && ($CSS != 1))\r
177         {\r
178                 // Daily reset was run so let's check out for expired newsletter orders\r
179                 $INC_POOL[] = PATH."inc/monthly/monthly_newsletter.php";\r
180         }\r
181         break;\r
182 }\r
183 \r
184 // Language file prefix\r
185 $EXT_LANG_PREFIX = "newsletter";\r
186 \r
187 // Extension is always active?\r
188 $EXT_ALWAYS_ACTIVE = "N";\r
189 \r
190 //\r
191 ?>\r