-<?php\r
-/************************************************************************\r
- * MXChange v0.2.1 Start: 05/23/2004 *\r
- * =============== Last change: 11/22/2005 *\r
- * *\r
- * -------------------------------------------------------------------- *\r
- * File : birthday_mails.php *\r
- * -------------------------------------------------------------------- *\r
- * Short description : Sends out birthday mails *\r
- * -------------------------------------------------------------------- *\r
- * Kurzbeschreibung : Versendet Geburtstagsmails *\r
- * -------------------------------------------------------------------- *\r
- * *\r
- * -------------------------------------------------------------------- *\r
- * Copyright (c) 2003 - 2008 by Roland Haeder *\r
- * For more information visit: http://www.mxchange.org *\r
- * *\r
- * This program is free software; you can redistribute it and/or modify *\r
- * it under the terms of the GNU General Public License as published by *\r
- * the Free Software Foundation; either version 2 of the License, or *\r
- * (at your option) any later version. *\r
- * *\r
- * This program is distributed in the hope that it will be useful, *\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *\r
- * GNU General Public License for more details. *\r
- * *\r
- * You should have received a copy of the GNU General Public License *\r
- * along with this program; if not, write to the Free Software *\r
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *\r
- * MA 02110-1301 USA *\r
- ************************************************************************/\r
-\r
-// Some security stuff...\r
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))\r
-{\r
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";\r
- require($INC);\r
-}\r
- elseif ((!EXT_IS_ACTIVE("birthday")) && (!IS_ADMIN()))\r
-{\r
- ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "birthday");\r
- return;\r
-}\r
-\r
-// Do not execute when script is in CSS mode\r
-if ($CSS == 1) return;\r
-\r
-// Get current day (01 to 31), month (01 to 12) and year (4-digits year)\r
-$DAY = date("d", time());\r
-$MONTH = date("m", time());\r
-$YEAR = date("Y", time());\r
-\r
-// Shall I include only active members?\r
-$ADD = "%s"; $VALUE = "";\r
-if (($CONFIG['birthday_active']) && (EXT_IS_ACTIVE("autopurge")) && ($CONFIG['ap_in_since'] > 0) && ($CONFIG['ap_inactive'] == "Y"))\r
-{\r
- $ADD = " AND last_online >= %d";\r
- $VALUE = bigintval(time() - $CONFIG['ap_in_since']);\r
-}\r
-\r
-// Only confirmed members shall receive birthday mails...\r
-$result_birthday = SQL_QUERY_ESC("SELECT userid, email, birth_year\r
-FROM "._MYSQL_PREFIX."_user_data\r
-WHERE status='CONFIRMED' AND birth_day=%d AND birth_month=%d AND birthday_sent < ".(time() - (ONE_DAY*364)).$ADD."\r
-ORDER BY userid",\r
- array($DAY, $MONTH, $VALUE), __FILE__, __LINE__);\r
-\r
-if (SQL_NUMROWS($result_birthday) > 0)\r
-{\r
- // Start sending out birthday mails\r
- while (list($uid, $email, $byear) = SQL_FETCHROW($result_birthday))\r
- {\r
- // Calculate own timestamp for birthday and today\r
- $BD = $byear + 12*$MONTH + 365*$DAY;\r
- $NOW = $YEAR + 12*$MONTH + 365*$DAY;\r
-\r
- // Simply subtract both values and you got the age... :)\r
- $AGE = $NOW - $BD;\r
-\r
- if ($CONFIG['birthday_points'] > 0)\r
- {\r
- // Prepare array for loading template\r
- $content = array(\r
- 'age' => $AGE,\r
- 'points' => $CONFIG['birthday_points'],\r
- 'check' => "",\r
- );\r
- for ($idx = 0; $idx < 4; $idx++)\r
- {\r
- $content['check'] .= GEN_RANDOM_CODE("8", rand(0, "$MONTH$DAY"), $uid, ($AGE*($idx+1)));\r
- }\r
-\r
- // Insert row into database\r
- $result_insert = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_birthday (userid, points, chk_value) VALUES ('%s', '%s', '%s' )",\r
- array(bigintval($uid), $CONFIG['birthday_points'], $content['check']), __FILE__, __LINE__);\r
-\r
- // Load email template with confirmation link\r
- $msg = LOAD_EMAIL_TEMPLATE("member_birthday_confirm", $content, bigintval($uid));\r
- }\r
- else\r
- {\r
- // Load default email template and fill in the age\r
- $msg = LOAD_EMAIL_TEMPLATE("member_birthday", $AGE, $uid);\r
- }\r
-\r
- // Send email\r
- SEND_EMAIL($email, HAPPY_BIRTHDAY, $msg);\r
-\r
- // Remember him that he has received a birthday mail\r
- $result_bd = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET birthday_sent=UNIX_TIMESTAMP() WHERE userid=%d LIMIT 1",\r
- array(bigintval($uid)), __FILE__, __LINE__);\r
- }\r
-\r
- // Free memory\r
- SQL_FREERESULT($result);\r
-}\r
-\r
-//\r
-?>\r
+<?php
+/************************************************************************
+ * MXChange v0.2.1 Start: 05/23/2004 *
+ * =============== Last change: 11/22/2005 *
+ * *
+ * -------------------------------------------------------------------- *
+ * File : birthday_mails.php *
+ * -------------------------------------------------------------------- *
+ * Short description : Sends out birthday mails *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung : Versendet Geburtstagsmails *
+ * -------------------------------------------------------------------- *
+ * *
+ * -------------------------------------------------------------------- *
+ * 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);
+}
+ elseif ((!EXT_IS_ACTIVE("birthday")) && (!IS_ADMIN()))
+{
+ ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "birthday");
+ return;
+}
+
+// Do not execute when script is in CSS mode
+if ($CSS == 1) return;
+
+// Get current day (01 to 31), month (01 to 12) and year (4-digits year)
+$DAY = date("d", time());
+$MONTH = date("m", time());
+$YEAR = date("Y", time());
+
+// Shall I include only active members?
+$ADD = "%s"; $VALUE = "";
+if (($CONFIG['birthday_active']) && (EXT_IS_ACTIVE("autopurge")) && ($CONFIG['ap_in_since'] > 0) && ($CONFIG['ap_inactive'] == "Y"))
+{
+ $ADD = " AND last_online >= %d";
+ $VALUE = bigintval(time() - $CONFIG['ap_in_since']);
+}
+
+// Only confirmed members shall receive birthday mails...
+$result_birthday = SQL_QUERY_ESC("SELECT userid, email, birth_year
+FROM "._MYSQL_PREFIX."_user_data
+WHERE status='CONFIRMED' AND birth_day=%d AND birth_month=%d AND birthday_sent < ".(time() - (ONE_DAY*364)).$ADD."
+ORDER BY userid",
+ array($DAY, $MONTH, $VALUE), __FILE__, __LINE__);
+
+if (SQL_NUMROWS($result_birthday) > 0)
+{
+ // Start sending out birthday mails
+ while (list($uid, $email, $byear) = SQL_FETCHROW($result_birthday))
+ {
+ // Calculate own timestamp for birthday and today
+ $BD = $byear + 12*$MONTH + 365*$DAY;
+ $NOW = $YEAR + 12*$MONTH + 365*$DAY;
+
+ // Simply subtract both values and you got the age... :)
+ $AGE = $NOW - $BD;
+
+ if ($CONFIG['birthday_points'] > 0)
+ {
+ // Prepare array for loading template
+ $content = array(
+ 'age' => $AGE,
+ 'points' => $CONFIG['birthday_points'],
+ 'check' => "",
+ );
+ for ($idx = 0; $idx < 4; $idx++)
+ {
+ $content['check'] .= GEN_RANDOM_CODE("8", rand(0, "$MONTH$DAY"), $uid, ($AGE*($idx+1)));
+ }
+
+ // Insert row into database
+ $result_insert = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_birthday (userid, points, chk_value) VALUES ('%s', '%s', '%s' )",
+ array(bigintval($uid), $CONFIG['birthday_points'], $content['check']), __FILE__, __LINE__);
+
+ // Load email template with confirmation link
+ $msg = LOAD_EMAIL_TEMPLATE("member_birthday_confirm", $content, bigintval($uid));
+ }
+ else
+ {
+ // Load default email template and fill in the age
+ $msg = LOAD_EMAIL_TEMPLATE("member_birthday", $AGE, $uid);
+ }
+
+ // Send email
+ SEND_EMAIL($email, HAPPY_BIRTHDAY, $msg);
+
+ // Remember him that he has received a birthday mail
+ $result_bd = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET birthday_sent=UNIX_TIMESTAMP() WHERE userid=%d LIMIT 1",
+ array(bigintval($uid)), __FILE__, __LINE__);
+ }
+
+ // Free memory
+ SQL_FREERESULT($result);
+}
+
+//
+?>