// Probe for referal ID
if (!empty($_GET['refid'])) $GLOBALS['refid'] = SQL_ESCAPE($_GET['refid']);
- // Probe for nickname extension and if a nickname was supplied by URL
- $probe_nickname = ((EXT_IS_ACTIVE("nickname")) && (("".round($GLOBALS['refid'])."") != $GLOBALS['refid']));
- if ($probe_nickname) {
- // Nickname in URL, so load the ID
- $result = SQL_QUERY_ESC("SELECT userid, status FROM `"._MYSQL_PREFIX."_user_data` WHERE nickname='%s' LIMIT 1",
- array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__);
- } else {
- // Direct userid entered
- $result = SQL_QUERY_ESC("SELECT userid, status FROM `"._MYSQL_PREFIX."_user_data` WHERE userid=%s LIMIT 1",
- array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__);
- }
+ // Only check this if refid is provided!
+ if ($GLOBALS['refid'] > 0) {
+ // Probe for nickname extension and if a nickname was supplied by URL
+ $probe_nickname = ((EXT_IS_ACTIVE("nickname")) && (("".round($GLOBALS['refid'])."") != $GLOBALS['refid']));
+
+ // Do we have nickname or userid set?
+ if ($probe_nickname) {
+ // Nickname in URL, so load the ID
+ $result = SQL_QUERY_ESC("SELECT userid, status FROM `"._MYSQL_PREFIX."_user_data` WHERE nickname='%s' LIMIT 1",
+ array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__);
+ } else {
+ // Direct userid entered
+ $result = SQL_QUERY_ESC("SELECT userid, status FROM `"._MYSQL_PREFIX."_user_data` WHERE userid=%s LIMIT 1",
+ array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__);
+ }
- // Load data
- list($rid, $status_ref) = SQL_FETCHROW($result);
- $GLOBALS['refid'] = bigintval($rid);
+ // Load data
+ list($rid, $status_ref) = SQL_FETCHROW($result);
+ $GLOBALS['refid'] = bigintval($rid);
+
+ // Free memory
+ SQL_FREERESULT($result);
+ } // END - if
- // Free memory
- SQL_FREERESULT($result);
+ // Init userid
$uid = 0;
// If no account was found set default refid and status to CONFIRMED
if ($probe_nickname) {
// Nickname in URL, so load the ID
$result = SQL_QUERY_ESC("SELECT userid, status, password FROM `"._MYSQL_PREFIX."_user_data` WHERE nickname='%s' LIMIT 1",
- array($_POST['userid']), __FILE__, __LINE__);
+ array($_POST['userid']), __FILE__, __LINE__);
} else {
// Direct userid entered
$result = SQL_QUERY_ESC("SELECT userid, status, password FROM `"._MYSQL_PREFIX."_user_data` WHERE userid=%s LIMIT 1",
- array(bigintval($_POST['userid'])), __FILE__, __LINE__);
+ array(bigintval($_POST['userid'])), __FILE__, __LINE__);
}
// Load data
// Enough points are left so let's continue with the doubling process
// Create doubling "account" width *DOUBLED* points
$result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_doubler (userid, refid, points, remote_ip, timemark, completed, is_ref) VALUES ('%s','%s','%s','".GET_REMOTE_ADDR()."', UNIX_TIMESTAMP(), 'N','N')",
- array($uid, bigintval($GLOBALS['refid']), bigintval($_POST['points'] * 2)), __FILE__, __LINE__);
+ array($uid, bigintval($GLOBALS['refid']), bigintval($_POST['points'] * 2)), __FILE__, __LINE__);
// Subtract entered points
SUB_POINTS("doubler", $uid, $_POST['points']);
} // END - if
// System-wide return codes
-define('CODE_WRONG_PASS' , 1);
-define('CODE_WRONG_ID' , 2);
-define('CODE_ID_LOCKED' , 3);
-define('CODE_ID_UNCONFIRMED' , 4);
-define('CODE_UNKNOWN_STATUS' , 5);
-define('CODE_NO_COOKIES' , 6);
-define('CODE_CNTR_FAILED' , 8);
-define('CODE_LOGOUT_DONE' , 8);
-define('CODE_LOGOUT_FAILED' , 9);
-define('CODE_URL_TLOCK' , 10);
-define('CODE_URL_FOUND' , 11);
-define('CODE_OVERLENGTH' , 12);
-define('CODE_SUBJ_URL' , 13);
-define('CODE_BLIST_URL' , 14);
-define('CODE_NO_RECS_LEFT' , 15);
-define('CODE_INVALID_TAGS' , 16);
-define('CODE_MORE_POINTS' , 18);
-define('CODE_COOKIES_DISABLED' , 18);
-define('CODE_DATA_INVALID' , 19);
-define('CODE_POSSIBLE_INVALID' , 20);
-define('CODE_ACCOUNT_LOCKED' , 21);
-define('CODE_USER_404' , 22);
-define('CODE_STATS_404' , 23);
-define('CODE_ALREADY_CONFIRMED', 24);
-define('CODE_ERROR_MAILID' , 25);
-define('CODE_EXTENSION_PROBLEM', 26);
-define('CODE_MORE_RECEIVERS1' , 28);
-define('CODE_MORE_RECEIVERS2' , 28);
-define('CODE_MORE_RECEIVERS3' , 29);
-define('CODE_INVALID_URL' , 30);
-define('CODE_MENU_NOT_VALID' , 31);
-define('CODE_LOGIN_FAILED' , 32);
-define('CODE_BEG_SAME_AS_OWN' , 33);
+define('CODE_WRONG_PASS' , 0x001);
+define('CODE_WRONG_ID' , 0x002);
+define('CODE_ID_LOCKED' , 0x003);
+define('CODE_ID_UNCONFIRMED' , 0x004);
+define('CODE_UNKNOWN_STATUS' , 0x005);
+define('CODE_NO_COOKIES' , 0x006);
+define('CODE_CNTR_FAILED' , 0x008);
+define('CODE_LOGOUT_DONE' , 0x008);
+define('CODE_LOGOUT_FAILED' , 0x009);
+define('CODE_URL_TLOCK' , 0x00A);
+define('CODE_URL_FOUND' , 0x00B);
+define('CODE_OVERLENGTH' , 0x00C);
+define('CODE_SUBJ_URL' , 0x00D);
+define('CODE_BLIST_URL' , 0x00E);
+define('CODE_NO_RECS_LEFT' , 0x00F);
+define('CODE_INVALID_TAGS' , 0x010);
+define('CODE_MORE_POINTS' , 0x011);
+define('CODE_COOKIES_DISABLED' , 0x012);
+define('CODE_DATA_INVALID' , 0x013);
+define('CODE_POSSIBLE_INVALID' , 0x014);
+define('CODE_ACCOUNT_LOCKED' , 0x015);
+define('CODE_USER_404' , 0x016);
+define('CODE_STATS_404' , 0x017);
+define('CODE_ALREADY_CONFIRMED', 0x018);
+define('CODE_ERROR_MAILID' , 0x019);
+define('CODE_EXTENSION_PROBLEM', 0x01A);
+define('CODE_MORE_RECEIVERS1' , 0x01B);
+define('CODE_MORE_RECEIVERS2' , 0x01C);
+define('CODE_MORE_RECEIVERS3' , 0x01D);
+define('CODE_INVALID_URL' , 0x01E);
+define('CODE_MENU_NOT_VALID' , 0x01F);
+define('CODE_LOGIN_FAILED' , 0x020);
+define('CODE_BEG_SAME_AS_OWN' , 0x020);
+define('CODE_UNHANDLED_STATUS' , 0x020);
// Full version string: /([0-9]){1}\.([0-9]){1}\.([0-9]){1}(-(alpha|beta|pre|rc([1-3]))([0-9]+))?/
// If you understand regular expressions ^^^ you may know how I versionize... ;-)
define('SERVER_URL', "http://www.mxchange.org");
// Current SVN revision
-define('CURR_SVN_REVISION', "658");
+define('CURR_SVN_REVISION', "659");
// Take a prime number which is long (if you know a longer one please try it out!)
define('_PRIME', 591623);
$NOTES = "";
$INC_POOL = array();
- // By default the language prefix is the extension's name
- // @TODO: Do we really need this one anymore? Can't we just take $ext_name and done?
// By default we have no failtures
$EXT_REPORTS_FAILURE = false;
return $value;
}
+// @TODO Rewrite all language constants to the function getLanguage().
+// "Getter" for language strings
+function getMessage ($messageId) {
+ // Default is not found!
+ $return = "!".$messageId."!";
+
+ // Is the language string found?
+ if (isset($GLOBALS['msg'][$messageId])) {
+ // Language array element found
+ $return = $GLOBALS['msg'][$messageId];
+ } elseif (defined($messageId)) {
+ // @DEPRECATED Deprecated constant found
+ $return = constant($messageId);
+ } else {
+ // Missing language constant
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Missing message string %s detected.", $messageId));
+ }
+
+ // Return the string
+ return $return;
+}
+
//////////////////////////////////////////////////
// //
// AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS //
define('SCRIPT', "Script");
define('ADMIN_NEW_ACCOUNT', "Neue Anmeldung zu Ihrem {!MT_WORD!}");
define('REGISTRATION_DONE', "Vielen Dank für die Anmeldung. Ein Bestätigungslink ist zur angemeldeten EMail-Adresse unterwegs!");
-define('GUEST_404_ACTION_1', "Das angegeben Aktionsmodul <U>");
-define('GUEST_404_ACTION_2', "</U> existiert leider nicht, oder dieses Script hat einen Fehler gemacht!");
-define('GUEST_LOCKED_ACTION', "Aktionsmodul wurde gesperrt!");
+define('GUEST_404_ACTION', "Das angegeben Aktionsmodul <u>%s</u> existiert leider nicht, oder dieses Script hat einen Fehler gemacht!");
+define('GUEST_LOCKED_ACTION', "Aktionsmodul <u>%s</u> wurde gesperrt!");
define('FATAL_REPORT_ERRORS', "Es wurde ein Problem während der Abarbeitung von Anweisungen festgestellt. Wenn ein Modul gesperrt sein sollte, so wird vermutlich gerade dran gearbeitet, anderfalls melden Sie sich bitte bei uns!");
define('TEMPLATE_404', "Template nicht gefunden!");
define('EDIT_GUEST_MENU', "Gästemenü bearbeiten");
define('SCRIPT', "Script");
define('ADMIN_NEW_ACCOUNT', "New registration for your email exchange");
define('REGISTRATION_DONE', "Registration is done. An email is on its way to you.");
-define('GUEST_404_ACTION_1', "The action module <U>");
-define('GUEST_404_ACTION_2', "</U> does not exist or this script makes a boo-boo!");
+define('GUEST_404_ACTION', "The action module <u>%s</u> does not exist or this script makes a boo-boo!");
define('GUEST_LOCKED_ACTION', "Action module is locked.");
define('FATAL_REPORT_ERRORS', "A fatal error ocurs while runtime. If a module is locked we are working on it othervice please contact us!");
define('TEMPLATE_404', "Template not found.");
if (FILE_READABLE($INC)) {
// Ok, we finally load the guest action module
include($INC);
+} elseif ($IS_VALID) {
+ ADD_FATAL(sprintf(getMessage('GUEST_404_ACTION'), SQL_ESCAPE($GLOBALS['what'])));
} else {
- ADD_FATAL(GUEST_404_ACTION_1.$GLOBALS['what'].GUEST_404_ACTION_2);
+ ADD_FATAL(sprintf(getMessage('GUEST_LOCKED_ACTION'), SQL_ESCAPE($GLOBALS['what'])));
}
//
return;
}
-if (GET_ACTION("guest", $GLOBALS['what']) == "admin") {
- // Only when one admin link is clicked...
- $INC = sprintf("%sinc/modules/guest/what-%s.php", PATH, SQL_ESCAPE($GLOBALS['what']));
- if (FILE_READABLE($INC)) {
- // Ok, we finally load the guest action module
- include($INC);
- } else {
- ADD_FATAL(GUEST_404_ACTION_1.$GLOBALS['what'].GUEST_404_ACTION_2);
- }
-} // END - if
+// Only when one admin link is clicked...
+$INC = sprintf("%sinc/modules/guest/what-%s.php", PATH, SQL_ESCAPE($GLOBALS['what']));
+if (FILE_READABLE($INC)) {
+ // Ok, we finally load the guest action module
+ include($INC);
+} elseif ($IS_VALID) {
+ ADD_FATAL(sprintf(getMessage('GUEST_404_ACTION'), SQL_ESCAPE($GLOBALS['what'])));
+} else {
+ ADD_FATAL(sprintf(getMessage('GUEST_LOCKED_ACTION'), SQL_ESCAPE($GLOBALS['what'])));
+}
//
?>
// Load the include file
$INC = sprintf("%sinc/modules/guest/what-%s.php", PATH, SQL_ESCAPE($GLOBALS['what']));
-$IS_VALID = WHAT_IS_VALID(GET_ACTION("guest", $GLOBALS['what']), $GLOBALS['what'], "guest");
+$IS_VALID = WHAT_IS_VALID($GLOBALS['action'], $GLOBALS['what'], "guest");
if ((FILE_READABLE($INC)) && ($IS_VALID)) {
// Ok, we finally load the guest action module
require_once($INC);
} elseif ($IS_VALID) {
- ADD_FATAL(GUEST_404_ACTION_1.$GLOBALS['what'].GUEST_404_ACTION_2);
+ ADD_FATAL(sprintf(getMessage('GUEST_404_ACTION'), SQL_ESCAPE($GLOBALS['what'])));
} else {
- ADD_FATAL(GUEST_LOCKED_ACTION);
+ ADD_FATAL(sprintf(getMessage('GUEST_LOCKED_ACTION'), SQL_ESCAPE($GLOBALS['what'])));
}
//
if (FILE_READABLE($INC)) {
// Ok, we finally load the guest action module
include($INC);
+} elseif ($IS_VALID) {
+ ADD_FATAL(sprintf(getMessage('GUEST_404_ACTION'), SQL_ESCAPE($GLOBALS['what'])));
} else {
- ADD_FATAL(GUEST_404_ACTION_1.$GLOBALS['what'].GUEST_404_ACTION_2);
+ ADD_FATAL(sprintf(getMessage('GUEST_LOCKED_ACTION'), SQL_ESCAPE($GLOBALS['what'])));
}
//
if (FILE_READABLE($INC)) {
// Ok, we finally load the guest action module
include($INC);
+} elseif ($IS_VALID) {
+ ADD_FATAL(sprintf(getMessage('GUEST_404_ACTION'), SQL_ESCAPE($GLOBALS['what'])));
} else {
- ADD_FATAL(GUEST_404_ACTION_1.$GLOBALS['what'].GUEST_404_ACTION_2);
+ ADD_FATAL(sprintf(getMessage('GUEST_LOCKED_ACTION'), SQL_ESCAPE($GLOBALS['what'])));
}
//
// Set ID number when left empty
if (empty($_POST['id'])) $_POST['id'] = 0;
+ // Init result
+ $result = false;
+
// Probe userid/nickname
- $probe_nickname = ((EXT_IS_ACTIVE("nickname")) && (("".round($_POST['id'])."") != $_POST['id']));
- if ($probe_nickname) {
+ if ((EXT_IS_ACTIVE("nickname")) && (("".round($_POST['id'])."") != $_POST['id'])) {
// Nickname entered
$result = SQL_QUERY_ESC("SELECT userid, status FROM `"._MYSQL_PREFIX."_user_data` WHERE nickname='%s' OR email='%s' LIMIT 1",
array($uid, $_POST['email']), __FILE__, __LINE__);
- } else {
+ } elseif (($uid > 0) && (empty($_POST['email']))) {
// Direct userid entered
- $result = SQL_QUERY_ESC("SELECT userid, status FROM `"._MYSQL_PREFIX."_user_data` WHERE userid=%s OR email='%s' LIMIT 1",
- array(bigintval($uid), $_POST['email']), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT userid, status FROM `"._MYSQL_PREFIX."_user_data` WHERE userid=%s LIMIT 1",
+ array(bigintval($uid)), __FILE__, __LINE__);
+ } elseif (!empty($_POST['email'])) {
+ // Email entered
+ $result = SQL_QUERY_ESC("SELECT userid, status FROM `"._MYSQL_PREFIX."_user_data` WHERE email='%s' LIMIT 1",
+ array($_POST['email']), __FILE__, __LINE__);
+ } else {
+ // Userid not set!
+ DEBUG_LOG(__FILE__, __LINE__, "Userid is not set! BUG!");
+ $ERROR = CODE_WRONG_ID;
}
// Any entry found?
} else {
// Account is locked or unconfirmed
switch ($status) {
- case "LOCKED" : $MSG = CODE_ID_LOCKED; break;
- case "UNCONFIRMED": $MSG = CODE_ID_UNCONFIRMED; break;
+ case "LOCKED" : $ERROR = CODE_ID_LOCKED; break;
+ case "UNCONFIRMED": $ERROR = CODE_ID_UNCONFIRMED; break;
+ default: // Unhandled account status!
+ $ERROR = CODE_UNHANDLED_STATUS;
+ DEBUG_LOG(__FILE__, __LINE__, sprintf("Undhandled account status %s detected.", $status));
+ break;
}
// Load URL
// Adding the main content module here
if (empty($GLOBALS['action'])) {
// Get action value from what value
- $act = GET_ACTION("guest", $GLOBALS['what']);
-} else {
- // Get action value directly from URL
- $act = COMPILE_CODE($GLOBALS['action']);
-}
+ $GLOBALS['action'] = GET_ACTION("guest", $GLOBALS['what']);
+} // END - if
+
+// Get action value directly from URL
+$act = COMPILE_CODE($GLOBALS['action']);
// Add the guest's menu here...
if ((getConfig('guest_menu') == "Y") || (!EXT_IS_ACTIVE("sql_patches", true))) {
define('__MIN_VALUE', getConfig('order_min'));
// Count unconfirmed mails
-$result_links = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_links WHERE userid=%s",
- array($GLOBALS['userid']), __FILE__, __LINE__);
-$links = SQL_NUMROWS($result_links);
-SQL_FREERESULT($result_links);
+$links = GET_TOTAL_DATA($GLOBALS['userid'], "user_links", "id", "userid", true);
// Does the user has more than 0 mails per day set?
-$HOLIDAY="userid";
+$HOLIDAY = "userid";
if (GET_EXT_VERSION("holiday") >= "0.1.3") {
// Fetch also holiday activation data
$HOLIDAY = "holiday_active";
$result_mmails = SQL_QUERY_ESC("SELECT userid, receive_mails, mail_orders, ".$HOLIDAY."
FROM "._MYSQL_PREFIX."_user_data
WHERE userid=%s AND max_mails > 0 LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array($GLOBALS['userid']), __FILE__, __LINE__);
$mmails = SQL_NUMROWS($result_mmails);
list($DMY, $MAXI, $ORDERS, $HOLIDAY) = SQL_FETCHROW($result_mmails);
if (getConfig('order_max_full') == "MAX") $ALLOWED = $MAXI;
// Now check his points amount
-$TOTAL = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points");
-
-if ($TOTAL > 0) {
- // And subtract his used points...
- $TOTAL -= GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
-
- // Add (maybe) missing three zeros
- if (!ereg(".", $TOTAL)) $TOTAL .= ".00000";
-} // END - if
+$TOTAL = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points") - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");;
if (($HOLIDAY == "Y") && (GET_EXT_VERSION("holiday") >= "0.1.3")) {
// Holiday is active!
- SQL_FREERESULT($result_p);
LOAD_TEMPLATE("admin_settings_saved", false, HOLIDAY_ORDER_NOT_POSSIBLE);
} elseif ((!empty($_POST['frametester'])) && ($ALLOWED > 0) && ($_POST['receiver'] > 0)) {
// Continue with the frametester, we first need to store the data temporary in the pool
$result = SQL_QUERY_ESC("SELECT id, data_type
FROM "._MYSQL_PREFIX."_pool
WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
- array($GLOBALS['userid'], $_POST['url'], getConfig('url_tlock')), __FILE__, __LINE__);
+ array($GLOBALS['userid'], $_POST['url'], getConfig('url_tlock')), __FILE__, __LINE__);
$type = "TEMP"; $id = 0;
if (SQL_NUMROWS($result) == 1) {
+ // Load id and mail type
list($id, $type) = SQL_FETCHROW($result);
- }
+ } // END - if
// Free result
SQL_FREERESULT($result);