require($INC);
}
-// Output HTML code directly or "render" it. You addionally switch the new-line character off
+// Output HTML code directly or 'render' it. You addionally switch the new-line character off
function OUTPUT_HTML ($HTML, $newLine = true) {
// Some global variables
global $OUTPUT;
// Do we have HTML-Code here?
if (!empty($HTML)) {
// Yes, so we handle it as you have configured
- switch (constant('OUTPUT_MODE'))
+ switch (getConfig('OUTPUT_MODE'))
{
- case "render":
+ case 'render':
// That's why you don't need any \n at the end of your HTML code... :-)
- if (constant('_OB_CACHING') == "on") {
+ if (constant('_OB_CACHING') == 'on') {
// Output into PHP's internal buffer
outputRawCode($HTML);
case 'direct':
// If we are switching from render to direct output rendered code
- if ((!empty($OUTPUT)) && (constant('_OB_CACHING') != "on")) { outputRawCode($OUTPUT); $OUTPUT = ''; }
+ if ((!empty($OUTPUT)) && (constant('_OB_CACHING') != 'on')) { outputRawCode($OUTPUT); $OUTPUT = ''; }
// The same as above... ^
outputRawCode($HTML);
default:
// Huh, something goes wrong or maybe you have edited config.php ???
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid renderer %s detected.", constant('OUTPUT_MODE')));
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid renderer %s detected.", getConfig('OUTPUT_MODE')));
app_die(__FUNCTION__, __LINE__, "<strong>{--FATAL_ERROR--}:</strong> {--LANG_NO_RENDER_DIRECT--}");
break;
}
- } elseif ((constant('_OB_CACHING') == "on") && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) {
+ } elseif ((constant('_OB_CACHING') == 'on') && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) {
// Headers already sent?
if (headers_sent()) {
// Log this error
} // END - if
// Send HTTP header
- header("HTTP/1.1 200");
+ sendHeader('HTTP/1.1 200');
// Used later
$now = gmdate('D, d M Y H:i:s') . ' GMT';
// General headers for no caching
- header("Expired: " . $now); // RFC2616 - Section 14.21
- header("Last-Modified: " . $now);
- header("Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0"); // HTTP/1.1
- header("Pragma: no-cache"); // HTTP/1.0
- header("Connection: Close");
+ sendHeader('Expired: ' . $now); // RFC2616 - Section 14.21
+ sendHeader('Last-Modified: ' . $now);
+ sendHeader('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
+ sendHeader('Pragma: no-cache'); // HTTP/1.0
+ sendHeader('Connection: Close');
// Extension 'rewrite' installed?
- if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != "1") && ($GLOBALS['output_mode'] != "-1")) {
+ if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != '1') && ($GLOBALS['output_mode'] != '-1')) {
$OUTPUT = rewriteLinksInCode($OUTPUT);
} // END - if
// Output code here, DO NOT REMOVE! ;-)
outputRawCode($OUTPUT);
- } elseif ((constant('OUTPUT_MODE') == "render") && (!empty($OUTPUT))) {
+ } elseif ((getConfig('OUTPUT_MODE') == 'render') && (!empty($OUTPUT))) {
// Rewrite links when rewrite extension is active
- if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != "1") && ($GLOBALS['output_mode'] != "-1")) {
+ if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != '1') && ($GLOBALS['output_mode'] != '-1')) {
$OUTPUT = rewriteLinksInCode($OUTPUT);
} // END - if
// Output stripped HTML code to avoid broken JavaScript code, etc.
echo stripslashes(stripslashes($HTML));
- // Flush the output if only constant('_OB_CACHING') is not "on"
- if (constant('_OB_CACHING') != "on") {
+ // Flush the output if only constant('_OB_CACHING') is not 'on'
+ if (constant('_OB_CACHING') != 'on') {
// Flush it
flush();
} // END - if
} // END - if
// Generate date/time string
- $date_time = generateDateTime(time(), "1");
+ $date_time = generateDateTime(time(), '1');
// Base directory
$basePath = sprintf("%stemplates/%s/html/", constant('PATH'), getLanguage());
$ret = "<!-- Template ".$template." - Start -->\n".$ret."<!-- Template ".$template." - End -->\n";
} elseif ((IS_ADMIN()) || ((isInstalling()) && (!isInstalled()))) {
// Only admins shall see this warning or when installation mode is active
- $ret = "<br /><span class=\"guest_failed\">".TEMPLATE_404."</span><br />
+ $ret = "<br /><span class=\"guest_failed\">{--TEMPLATE_404--}</span><br />
(".basename($FQFN).")<br />
<br />
-".TEMPLATE_CONTENT."
+{--TEMPLATE_CONTENT--}
<pre>".print_r($content, true)."</pre>
-".TEMPLATE_DATA."
+{--TEMPLATE_DATA--}
<pre>".print_r($DATA, true)."</pre>
<br /><br />";
}
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):TO={$toEmail}<br />\n";
// Check for PHPMailer or debug-mode
- if (!CHECK_PHPMAILER_USAGE()) {
+ if (!checkPhpMailerUsage()) {
// Not in PHPMailer-Mode
if (empty($mailHeader)) {
// Load email header template
</pre>\n");
} elseif (($HTML == 'Y') && (EXT_IS_ACTIVE('html_mail'))) {
// Send mail as HTML away
- SEND_HTML_EMAIL($toEmail, $subject, $message, $mailHeader);
+ sendHtmlEmail($toEmail, $subject, $message, $mailHeader);
} elseif (!empty($toEmail)) {
// Send Mail away
- SEND_RAW_EMAIL($toEmail, $subject, $message, $mailHeader);
+ sendRawEmail($toEmail, $subject, $message, $mailHeader);
} elseif ($HTML == 'N') {
// Problem found!
- SEND_RAW_EMAIL(constant('WEBMASTER'), "[PROBLEM:]".$subject, $message, $mailHeader);
+ sendRawEmail(constant('WEBMASTER'), '[PROBLEM:]' . $subject, $message, $mailHeader);
}
}
// Check if legacy or PHPMailer command
// @TODO Rewrite this to an extension 'smtp'
// @private
-function CHECK_PHPMAILER_USAGE() {
- return ((defined('SMTP_HOSTNAME')) && (defined('SMTP_USER')) && (defined('SMTP_PASSWORD')) && (constant('SMTP_HOSTNAME') != '') && (constant('SMTP_USER') != ''));
+function checkPhpMailerUsage() {
+ return ((getConfig('SMTP_HOSTNAME') != '') && (getConfig('SMTP_USER') != ''));
}
-/*
- * Send out a raw email with PHPMailer class or legacy mail() command
- */
-function SEND_RAW_EMAIL ($toEmail, $subject, $msg, $from) {
+// Send out a raw email with PHPMailer class or legacy mail() command
+function sendRawEmail ($toEmail, $subject, $msg, $from) {
// Shall we use PHPMailer class or legacy mode?
- if (CHECK_PHPMAILER_USAGE()) {
+ if (checkPhpMailerUsage()) {
// Use PHPMailer class with SMTP enabled
- loadIncludeOnce("inc/phpmailer/class.phpmailer.php");
- loadIncludeOnce("inc/phpmailer/class.smtp.php");
+ loadIncludeOnce('inc/phpmailer/class.phpmailer.php');
+ loadIncludeOnce('inc/phpmailer/class.smtp.php');
// get new instance
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
- $mail->Host = constant('SMTP_HOSTNAME');
+ $mail->Host = getConfig('SMTP_HOSTNAME');
$mail->Port = 25;
- $mail->Username = constant('SMTP_USER');
- $mail->Password = constant('SMTP_PASSWORD');
+ $mail->Username = getConfig('SMTP_USER');
+ $mail->Password = getConfig('SMTP_PASSWORD');
if (empty($from)) {
$mail->From = constant('WEBMASTER');
} else {
$mail->Subject = $subject;
if ((EXT_IS_ACTIVE('html_mail')) && (strip_tags($msg) != $msg)) {
$mail->Body = $msg;
- $mail->AltBody = "Your mail program required HTML support to read this mail!";
+ $mail->AltBody = 'Your mail program required HTML support to read this mail!';
$mail->WordWrap = 70;
$mail->IsHTML(true);
} else {
}
$mail->AddAddress($toEmail, '');
$mail->AddReplyTo(constant('WEBMASTER'), constant('MAIN_TITLE'));
- $mail->AddCustomHeader("Errors-To:".constant('WEBMASTER'));
- $mail->AddCustomHeader("X-Loop:".constant('WEBMASTER'));
+ $mail->AddCustomHeader('Errors-To:' . constant('WEBMASTER'));
+ $mail->AddCustomHeader('X-Loop:' . constant('WEBMASTER'));
$mail->Send();
} else {
// Use legacy mail() command
// Translates Y/N to yes/no
function translateYesNo ($yn) {
// Default
- $translated = "??? (".$yn.")";
+ $translated = "??? (".$yn.')';
switch ($yn) {
case 'Y': $translated = getMessage('YES'); break;
case 'N': $translated = getMessage('NO'); break;
return $ret;
}
-// Wrapper for $_POST['sel']
-function countPostSelection () {
- return countSelection(REQUEST_POST('sel'));
-}
-
// Generate XHTML code for the CAPTCHA
function generateCaptchaCode ($code, $type, $DATA, $uid) {
return '<IMG border="0" alt="Code" src="{!URL!}/mailid_top.php?uid=' . $uid . '&' . $type . '=' . $DATA . '&mode=img&code=' . $code . '" />';
// "Getter" for language
function getLanguage () {
// Set default return value to default language from config
- $ret = constant('DEFAULT_LANG');
+ $ret = getConfig('DEFAULT_LANG');
// Init variable
$lang = '';
// Is the variable set
- if (REQUEST_ISSET_GET(('mx_lang'))) {
+ if (REQUEST_ISSET_GET('mx_lang')) {
// Accept only first 2 chars
$lang = substr(REQUEST_GET('mx_lang'), 0, 2);
} elseif (isset($GLOBALS['cache_array']['language'])) {
$ret = $GLOBALS['cache_array']['language'];
} elseif (!empty($lang)) {
// Check if main language file does exist
- if (isFileReadable(constant('PATH').'inc/language/'.$lang.'.php')) {
+ if (isFileReadable(constant('PATH') . 'inc/language/'.$lang.'.php')) {
// Okay found, so let's update cookies
setLanguage($lang);
- }
- } elseif (!isSessionVariableSet('mx_lang')) {
+ } // END - if
+ } elseif (isSessionVariableSet('mx_lang')) {
// Return stored value from cookie
$ret = getSession('mx_lang');
// Fixes a warning before the session has the mx_lang constant
- if (empty($ret)) $ret = constant('DEFAULT_LANG');
+ if (empty($ret)) $ret = getConfig('DEFAULT_LANG');
}
// Cache entry
return COMPILE_CODE($newContent);
}
-// Generates a timestamp (wrapper for mktime())
+// Generates a timestamp (some wrapper for mktime())
function makeTime ($H, $M, $S, $stamp) {
// Extract day, month and year from given timestamp
$day = date('d', $stamp);
}
// Redirects to an URL and if neccessarry extends it with own base URL
-function redirectToUrl ($URL, $addUrlData=true) {
+function redirectToUrl ($URL) {
// Compile out URI codes
$URL = compileUriCode($URL);
} // END - if
// Three different debug ways...
- //* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
+ /* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, $URL);
//* DEBUG: */ die($URL);
clearOutputBuffer();
} // END - if
- // Add some data to URL if cookies are not accepted
- if ((!isBooleanConstantAndTrue('__COOKIES')) && ($addUrlData === true)) $URL = addUrlData($URL);
-
// Secure the URL against bad things such als HTML insertions and so on...
$URL = htmlentities(strip_tags($URL), ENT_QUOTES);
} elseif (!headers_sent()) {
// Load URL when headers are not sent
//* DEBUG: */ debug_report_bug("URL={$URL}");
- header ('Location: '.str_replace('&', '&', $URL));
+ sendHeader('Location: '.str_replace('&', '&', $URL));
} else {
// Output error message
loadInclude('inc/header.php');
}
// Wrapper for redirectToUrl but URL comes from a configuration entry
-function LOAD_CONFIGURED_URL ($configEntry) {
+function redirectToConfiguredUrl ($configEntry) {
// Get the URL
$URL = getConfig($configEntry);
if (!defined('_MAX')) define('_MAX', 15235);
// Build server string
- $server = $_SERVER['PHP_SELF'].constant('ENCRYPT_SEPERATOR').detectUserAgent().constant('ENCRYPT_SEPERATOR').getenv('SERVER_SOFTWARE').constant('ENCRYPT_SEPERATOR').detectRemoteAddr().":'.':".filemtime(constant('PATH')."inc/databases.php");
+ $server = $_SERVER['PHP_SELF'].getConfig('ENCRYPT_SEPERATOR').detectUserAgent().getConfig('ENCRYPT_SEPERATOR').getenv('SERVER_SOFTWARE').getConfig('ENCRYPT_SEPERATOR').detectRemoteAddr().":'.':".filemtime(constant('PATH').'inc/databases.php');
// Build key string
- $keys = constant('SITE_KEY').constant('ENCRYPT_SEPERATOR').constant('DATE_KEY');
- if (isConfigEntrySet('secret_key')) $keys .= constant('ENCRYPT_SEPERATOR').getConfig('secret_key');
- if (isConfigEntrySet('file_hash')) $keys .= constant('ENCRYPT_SEPERATOR').getConfig('file_hash');
- $keys .= constant('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", getConfig(('patch_ctime')));
- if (isConfigEntrySet('master_salt')) $keys .= constant('ENCRYPT_SEPERATOR').getConfig('master_salt');
+ $keys = getConfig('SITE_KEY').getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY');
+ if (isConfigEntrySet('secret_key')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('secret_key');
+ if (isConfigEntrySet('file_hash')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('file_hash');
+ $keys .= getConfig('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", getConfig(('patch_ctime')));
+ if (isConfigEntrySet('master_salt')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('master_salt');
// Build string from misc data
- $data = $code.constant('ENCRYPT_SEPERATOR').$uid.constant('ENCRYPT_SEPERATOR').$DATA;
+ $data = $code.getConfig('ENCRYPT_SEPERATOR').$uid.getConfig('ENCRYPT_SEPERATOR').$DATA;
// Add more additional data
- if (isSessionVariableSet('u_hash')) $data .= constant('ENCRYPT_SEPERATOR').getSession('u_hash');
- if (isUserIdSet()) $data .= constant('ENCRYPT_SEPERATOR').getUserId();
- if (isSessionVariableSet('mxchange_theme')) $data .= constant('ENCRYPT_SEPERATOR').getSession('mxchange_theme');
- if (isSessionVariableSet('mx_lang')) $data .= constant('ENCRYPT_SEPERATOR').getLanguage();
- if (isset($GLOBALS['refid'])) $data .= constant('ENCRYPT_SEPERATOR').$GLOBALS['refid'];
+ if (isSessionVariableSet('u_hash')) $data .= getConfig('ENCRYPT_SEPERATOR').getSession('u_hash');
+ if (isUserIdSet()) $data .= getConfig('ENCRYPT_SEPERATOR').getUserId();
+ if (isSessionVariableSet('mxchange_theme')) $data .= getConfig('ENCRYPT_SEPERATOR').getSession('mxchange_theme');
+ if (isSessionVariableSet('mx_lang')) $data .= getConfig('ENCRYPT_SEPERATOR').getLanguage();
+ if (isset($GLOBALS['refid'])) $data .= getConfig('ENCRYPT_SEPERATOR').$GLOBALS['refid'];
// Calculate number for generating the code
- $a = $code + constant('_ADD') - 1;
+ $a = $code + getConfig('_ADD') - 1;
if (isConfigEntrySet('master_hash')) {
// Generate hash with master salt from modula of number with the prime number and other data
- $saltedHash = generateHash(($a % constant('_PRIME')).constant('ENCRYPT_SEPERATOR').$server.constant('ENCRYPT_SEPERATOR').$keys.constant('ENCRYPT_SEPERATOR').$data.constant('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", time()).constant('ENCRYPT_SEPERATOR').$a, getConfig('master_salt'));
+ $saltedHash = generateHash(($a % getConfig('_PRIME')).getConfig('ENCRYPT_SEPERATOR').$server.getConfig('ENCRYPT_SEPERATOR').$keys.getConfig('ENCRYPT_SEPERATOR').$data.getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY').getConfig('ENCRYPT_SEPERATOR').$a, getConfig('master_salt'));
// Create number from hash
- $rcode = hexdec(substr($saltedHash, strlen(getConfig('master_salt')), 9)) / abs(constant('_MAX') - $a + sqrt(constant('_ADD'))) / pi();
+ $rcode = hexdec(substr($saltedHash, strlen(getConfig('master_salt')), 9)) / abs(constant('_MAX') - $a + sqrt(getConfig('_ADD'))) / pi();
} else {
// Generate hash with "hash of site key" from modula of number with the prime number and other data
- $saltedHash = generateHash(($a % constant('_PRIME')).constant('ENCRYPT_SEPERATOR').$server.constant('ENCRYPT_SEPERATOR').$keys.constant('ENCRYPT_SEPERATOR').$data.constant('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", time()).constant('ENCRYPT_SEPERATOR').$a, substr(sha1(constant('SITE_KEY')), 0, 8));
+ $saltedHash = generateHash(($a % getConfig('_PRIME')).getConfig('ENCRYPT_SEPERATOR').$server.getConfig('ENCRYPT_SEPERATOR').$keys.getConfig('ENCRYPT_SEPERATOR').$data.getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY').getConfig('ENCRYPT_SEPERATOR').$a, substr(sha1(getConfig('SITE_KEY')), 0, 8));
// Create number from hash
- $rcode = hexdec(substr($saltedHash, 8, 9)) / abs(constant('_MAX') - $a + sqrt(constant('_ADD'))) / pi();
+ $rcode = hexdec(substr($saltedHash, 8, 9)) / abs(constant('_MAX') - $a + sqrt(getConfig('_ADD'))) / pi();
}
// At least 10 numbers shall be secure enought!
// Switch image type
switch (getConfig('img_type'))
{
- case "jpg":
+ case 'jpg':
// Okay, load image and hide all errors
$image = @imagecreatefromjpeg($img);
break;
- case "png":
+ case 'png':
// Okay, load image and hide all errors
$image = @imagecreatefrompng($img);
break;
imagestring($image, 5, 14, 2, $img_code, $text_color);
// Return to browser
- header ("Content-Type: image/".getConfig('img_type'));
+ sendHeader('Content-Type: image/' . getConfig('img_type'));
// Output image with matching image factory
switch (getConfig('img_type')) {
- case "jpg": imagejpeg($image); break;
- case "png": imagepng($image); break;
+ case 'jpg': imagejpeg($image); break;
+ case 'png': imagepng($image); break;
}
// Remove image from memory
imagedestroy($image);
}
// Create selection box or array of splitted timestamp
-function createTimeSelections ($timestamp, $prefix = '', $display = '', $align="center", $return_array=false) {
+function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = 'center', $return_array=false) {
// Calculate 2-seconds timestamp
$stamp = round($timestamp);
//* DEBUG: */ print("*".$stamp.'/'.$timestamp."*<br />");
$result = false;
// "implode" IDs and query string
- $aid = implode(",", $adminIds);
- if ($aid == "-1") {
+ $aid = implode(',', $adminIds);
+ if ($aid == '-1') {
if (EXT_IS_ACTIVE('events')) {
// Add line to user events
EVENTS_ADD_LINE($subj, $msg, $UID);
$NAV = '';
for ($page = 1; $page <= $PAGES; $page++) {
// Is the page currently selected or shall we generate a link to it?
- if (($page == REQUEST_GET('page')) || ((!REQUEST_ISSET_GET('page')) && ($page == "1"))) {
+ if (($page == REQUEST_GET('page')) || ((!REQUEST_ISSET_GET('page')) && ($page == '1'))) {
// Is currently selected, so only highlight it
$NAV .= "<strong>-";
} else {
$NAV .= "\">";
}
$NAV .= $page;
- if (($page == REQUEST_GET('page')) || ((!REQUEST_ISSET_GET('page')) && ($page == "1"))) {
+ if (($page == REQUEST_GET('page')) || ((!REQUEST_ISSET_GET('page')) && ($page == '1'))) {
// Is currently selected, so only highlight it
$NAV .= "-</strong>";
} else {
// Use login data to proxy? (username at least!)
if (getConfig('proxy_username') != '') {
// Add it as well
- $encodedAuth = base64_encode(COMPILE_CODE(getConfig('proxy_username')).constant('ENCRYPT_SEPERATOR').COMPILE_CODE(getConfig('proxy_password')));
+ $encodedAuth = base64_encode(COMPILE_CODE(getConfig('proxy_username')).getConfig('ENCRYPT_SEPERATOR').COMPILE_CODE(getConfig('proxy_password')));
$proxyTunnel .= "Proxy-Authorization: Basic ".$encodedAuth."\r\n";
} // END - if
// When the salt is empty build a new one, else use the first x configured characters as the salt
if (empty($salt)) {
// Build server string (inc/databases.php is no longer updated with every commit)
- $server = $_SERVER['PHP_SELF'].constant('ENCRYPT_SEPERATOR').detectUserAgent().constant('ENCRYPT_SEPERATOR').getenv('SERVER_SOFTWARE').constant('ENCRYPT_SEPERATOR').detectRemoteAddr();
+ $server = $_SERVER['PHP_SELF'].getConfig('ENCRYPT_SEPERATOR').detectUserAgent().getConfig('ENCRYPT_SEPERATOR').getenv('SERVER_SOFTWARE').getConfig('ENCRYPT_SEPERATOR').detectRemoteAddr();
// Build key string
- $keys = constant('SITE_KEY').constant('ENCRYPT_SEPERATOR').constant('DATE_KEY').constant('ENCRYPT_SEPERATOR').getConfig('secret_key').constant('ENCRYPT_SEPERATOR').getConfig('file_hash').constant('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", getConfig(('patch_ctime'))).constant('ENCRYPT_SEPERATOR').getConfig('master_salt');
+ $keys = getConfig('SITE_KEY').getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY').getConfig('ENCRYPT_SEPERATOR').getConfig('secret_key').getConfig('ENCRYPT_SEPERATOR').getConfig('file_hash').getConfig('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", getConfig(('patch_ctime'))).getConfig('ENCRYPT_SEPERATOR').getConfig('master_salt');
// Additional data
- $data = $plainText.constant('ENCRYPT_SEPERATOR').uniqid(mt_rand(), true).constant('ENCRYPT_SEPERATOR').time();
+ $data = $plainText.getConfig('ENCRYPT_SEPERATOR').uniqid(mt_rand(), true).getConfig('ENCRYPT_SEPERATOR').time();
// Calculate number for generating the code
- $a = time() + constant('_ADD') - 1;
+ $a = time() + getConfig('_ADD') - 1;
// Generate SHA1 sum from modula of number and the prime number
- $sha1 = sha1(($a % constant('_PRIME')).$server.constant('ENCRYPT_SEPERATOR').$keys.constant('ENCRYPT_SEPERATOR').$data.constant('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", time()).constant('ENCRYPT_SEPERATOR').$a);
+ $sha1 = sha1(($a % getConfig('_PRIME')).$server.getConfig('ENCRYPT_SEPERATOR').$keys.getConfig('ENCRYPT_SEPERATOR').$data.getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY').getConfig('ENCRYPT_SEPERATOR').$a);
//* DEBUG: */ echo "SHA1=".$sha1." (".strlen($sha1).")<br />";
$sha1 = scrambleString($sha1);
//* DEBUG: */ echo "Scrambled=".$sha1." (".strlen($sha1).")<br />";
return $scrambleString;
}
-// Append data like session ID or referal ID to the given URL which would
-// normally be stored in cookies
-function addUrlData ($URL) {
- // Init add
- $add = '';
-
- // Determine URL binder
- $BIND = '?';
- if (strpos($URL, '?') !== false) $BIND = '&';
-
- if ((!defined('__COOKIES')) || ((!constant('__COOKIES')))) {
- // Cookies are not accepted
- if ((REQUEST_ISSET_GET(('refid'))) && (strpos($URL, "refid=") == 0)) {
- // Cookie found in URL
- $add .= $BIND."refid=".bigintval(REQUEST_GET('refid'));
- } elseif ((GET_EXT_VERSION('sql_patches') != '') && (getConfig('def_refid') > 0)) {
- // Not found! So let's set default here
- $add .= $BIND."refid=".getConfig('def_refid');
- }
- } // END - if
-
- // Add all together and return it
- return $URL . $add;
-}
-
// Generate an PGP-like encrypted hash of given hash for e.g. cookies
function generatePassString ($passHash) {
// Return vanilla password hash
$part2 = hexdec(substr(getConfig('secret_key'), $start, 4));
$mod = dechex($idx);
if ($part1 > $part2) {
- $mod = dechex(sqrt(($part1 - $part2) * constant('_PRIME') / pi()));
+ $mod = dechex(sqrt(($part1 - $part2) * getConfig('_PRIME') / pi()));
} elseif ($part2 > $part1) {
- $mod = dechex(sqrt(($part2 - $part1) * constant('_PRIME') / pi()));
+ $mod = dechex(sqrt(($part2 - $part1) * getConfig('_PRIME') / pi()));
}
$mod = substr(round($mod), 0, 4);
$mod = str_repeat('0', 4-strlen($mod)).$mod;
$newHash .= $mod;
} // END - for
- //* DEBUG: */ print($passHash."<br />".$newHash." (".strlen($newHash).")");
+ //* DEBUG: */ print($passHash."<br />".$newHash." (".strlen($newHash).')');
$ret = generateHash($newHash, getConfig('master_salt'));
//* DEBUG: */ print($ret."<br />\n");
} else {
return $id;
}
-// Read a given file
-function readFromFile ($FQFN, $sqlPrepare = false) {
- // Load the file
- if (function_exists('file_get_contents')) {
- // Use new function
- $content = file_get_contents($FQFN);
- } else {
- // Fall-back to implode-file chain
- $content = implode('', file($FQFN));
- }
-
- // Prepare SQL queries?
- if ($sqlPrepare === true) {
- // Remove some unwanted chars
- $content = str_replace("\r", '', $content);
- $content = str_replace("\n\n", "\n", $content);
- } // END - if
-
- // Return the content
- return $content;
-}
-
-// Writes content to a file
-function writeToFile ($FQFN, $content) {
- // Is the file writeable?
- if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!chmod($FQFN, 0644))) {
- // Not writeable!
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("File %s not writeable.", basename($FQFN)));
-
- // Failed! :(
- return false;
- } // END - if
-
- // By default all is failed...
- $return = false;
-
- // Is the function there?
- if (function_exists('file_put_contents')) {
- // Write it directly
- $return = file_put_contents($FQFN, $content);
- } else {
- // Write it with fopen
- $fp = fopen($FQFN, 'w') or app_die(__FUNCTION__, __LINE__, "Cannot write file ".basename($FQFN).'!');
- fwrite($fp, $content);
- fclose($fp);
-
- // Set CHMOD rights
- $return = chmod($FQFN, 0644);
- }
-
- // Return status
- return $return;
-}
-
// Generates an error code from given account status
function generateErrorCodeFromUserStatus ($status) {
// Default error code if unknown account status
return $errorCode;
}
-// Clears the output buffer. This function does *NOT* backup sent content.
-function clearOutputBuffer () {
- // Trigger an error on failure
- if (!ob_end_clean()) {
- // Failed!
- debug_report_bug(__FUNCTION__.': Failed to clean output buffer.');
- } // END - if
-}
-
// Function to search for the last modifified file
function searchDirsRecursive ($dir, &$last_changed) {
// Get dir as array
return $akt_vers;
}
-
-// Loads an include file and logs any missing files for debug purposes
-function loadInclude ($INC) {
- // Add the path. This is why we need a trailing slash in config.php
- $FQFN = constant('PATH') . $INC;
-
- // Is the include file there?
- if (!isIncludeReadable($INC)) {
- // Not there so log it
- debug_report_bug(sprintf("Include file %s not found.", $INC));
- return false;
- } // END - if
-
- // Try to load it
- require($FQFN);
-}
-
-// Loads an include file once
-function loadIncludeOnce ($INC) {
- // Is it not loaded?
- if (!isset($GLOBALS['load_once'][$INC])) {
- // Then try to load it
- loadInclude($INC);
-
- // And mark it as loaded
- $GLOBALS['load_once'][$INC] = "loaded";
- } // END - if
-}
-
// Back-ported from the new ship-simu engine. :-)
function debug_get_printable_backtrace () {
// Init variable
if (!isset($trace['file'])) $trace['file'] = __FUNCTION__;
if (!isset($trace['line'])) $trace['line'] = __LINE__;
if (!isset($trace['args'])) $trace['args'] = array();
- $backtrace .= "<li class=\"debug_list\"><span class=\"backtrace_file\">".basename($trace['file'])."</span>:".$trace['line'].", <span class=\"backtrace_function\">".$trace['function']."(".count($trace['args']).")</span></li>\n";
+ $backtrace .= "<li class=\"debug_list\"><span class=\"backtrace_file\">".basename($trace['file'])."</span>:".$trace['line'].", <span class=\"backtrace_function\">".$trace['function'].'('.count($trace['args']).")</span></li>\n";
} // END - foreach
// Close it
// Add output
$debug .= "Please report this bug at <a href=\"http://bugs.mxchange.org\" rel=\"external\" target=\"_blank\">bugs.mxchange.org</a>:<pre>";
$debug .= debug_get_printable_backtrace();
- $debug .= "</pre>Request-URI: ".$_SERVER['REQUEST_URI']."<br />\n";
+ $debug .= "</pre>\nRequest-URI: ".$_SERVER['REQUEST_URI']."<br />\n";
$debug .= "Thank you for finding bugs.";
// And abort here
break;
case getCode('EXTENSION_PROBLEM'):
- if (REQUEST_ISSET_GET(('ext'))) {
- $msg = sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), REQUEST_GET(('ext')));
+ if (REQUEST_ISSET_GET('ext')) {
+ $msg = sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), REQUEST_GET('ext'));
} else {
$msg = getMessage('EXTENSION_PROBLEM_UNSET_EXT');
}
return $admin;
}
-// Checks wether an include file (non-FQFN better) is readable
-function isIncludeReadable ($INC) {
- // Construct FQFN
- $FQFN = constant('PATH') . $INC;
-
- // Is it readable?
- return isFileReadable($FQFN);
-}
-
-// Encode strings
-// @TODO Implement $compress
-function encodeString ($str, $compress=true) {
- $str = urlencode(base64_encode(compileUriCode($str)));
- return $str;
-}
-
-// Decode strings encoded with encodeString()
-// @TODO Implement $decompress
-function decodeString ($str, $decompress=true) {
- $str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
- return $str;
-}
-
// Compile characters which are allowed in URLs
function compileUriCode ($code, $simple=true) {
// Compile constants
return $reg;
}
-// Smartly adds slashes
-function smartAddSlashes ($unquoted) {
- $unquoted = str_replace("\\", '', $unquoted);
- return addslashes($unquoted);
-}
-
-// Decode entities in a nicer way
-function decodeEntities ($str) {
- // Decode the entities to UTF-8 now
- $decodedString = html_entity_decode($str, ENT_NOQUOTES, "UTF-8");
-
- // Return decoded string
- return $decodedString;
-}
-
// Wtites data to a config.php-style file
// @TODO Rewrite this function to use readFromFile() and writeToFile()
function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
}
}
-// Merges an array together but only if both are arrays
-function merge_array ($array1, $array2) {
- // Are both an array?
- if ((is_array($array1)) && (is_array($array2))) {
- // Merge all together
- return array_merge($array1, $array2);
- } elseif (is_array($array1)) {
- // Return left array
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
- return $array1;
- } elseif (is_array($array2)) {
- // Return right array
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
- return $array2;
- }
-
- // Both are not arrays
- debug_report_bug(__FUNCTION__.": No arrays provided!");
-}
-
// Debug message logger
function DEBUG_LOG ($funcFile, $line, $message, $force=true) {
// Is debug mode enabled?
SET_INC_POOL(getArrayFromDirectory('inc/reset/', 'reset_'));
// Update database
- if (!defined('DEBUG_RESET')) updateConfiguration('last_update', time());
+ if (getConfig('DEBUG_RESET') != 'Y') updateConfiguration('last_update', time());
// Is the config entry set?
if (GET_EXT_VERSION('sql_patches') >= '0.4.2') {
MERGE_INC_POOL(getArrayFromDirectory('inc/weekly/', 'weekly_'));
// Update config
- if (!defined('DEBUG_WEEKLY')) updateConfiguration('last_week', $currWeek);
+ if (getConfig('DEBUG_WEEKLY') != 'Y') updateConfiguration('last_week', $currWeek);
} // END - if
// Create current month mark
MERGE_INC_POOL(getArrayFromDirectory('inc/monthly/', 'monthly_'));
// Update config
- if (!defined('DEBUG_MONTHLY')) updateConfiguration('last_month', $currMonth);
+ if (getConfig('DEBUG_MONTHLY') != 'Y') updateConfiguration('last_month', $currMonth);
} // END - if
} // END - if
return $ret;
}
-// Check if given FQFN is a readable file
-function isFileReadable ($FQFN) {
- // Check all...
- return ((file_exists($FQFN)) && (is_file($FQFN)) && (is_readable($FQFN)));
-}
-
// Converts timestamp selections into a timestamp
function convertSelectionsToTimestamp (&$POST, &$DATA, &$id, &$skip) {
// Init test variable
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):accessLevel={$accessLevel}<br />\n";
$content = array(
'login_failures' => getSession('mxchange_'.$accessLevel.'_failures'),
- 'last_failure' => generateDateTime(getSession('mxchange_'.$accessLevel.'_last_fail'), "2")
+ 'last_failure' => generateDateTime(getSession('mxchange_'.$accessLevel.'_last_fail'), '2')
);
// Load template
}
// This strips out the real address from proxy output
- if (strstr($address, ",")){
- $addressArray = explode(",", $address);
+ if (strstr($address, ',')){
+ $addressArray = explode(',', $address);
$address = $addressArray[0];
} // END - if
return $address;
}
-// "Getter" for remote IP number
-function detectRemoteAddr () {
- // Get remote ip from environment
- $remoteAddr = determineRealRemoteAddress();
-
- // Is removeip installed?
- if (EXT_IS_ACTIVE('removeip')) {
- // Then anonymize it
- $remoteAddr = GET_ANONYMOUS_REMOTE_ADDR($remoteAddr);
- } // END - if
-
- // Return it
- return $remoteAddr;
-}
-
-// "Getter" for remote hostname
-function detectRemoteHostname () {
- // Get remote ip from environment
- $remoteHost = getenv('REMOTE_HOST');
-
- // Is removeip installed?
- if (EXT_IS_ACTIVE('removeip')) {
- // Then anonymize it
- $remoteHost = GET_ANONYMOUS_REMOTE_HOST($remoteHost);
- } // END - if
-
- // Return it
- return $remoteHost;
-}
-
-// "Getter" for user agent
-function detectUserAgent () {
- // Get remote ip from environment
- $userAgent = getenv('HTTP_USER_AGENT');
-
- // Is removeip installed?
- if (EXT_IS_ACTIVE('removeip')) {
- // Then anonymize it
- $userAgent = GET_ANONYMOUS_USER_AGENT($userAgent);
- } // END - if
-
- // Return it
- return $userAgent;
-}
-
-// "Getter" for referer
-function detectReferer () {
- // Get remote ip from environment
- $referer = getenv('HTTP_REFERER');
-
- // Is removeip installed?
- if (EXT_IS_ACTIVE('removeip')) {
- // Then anonymize it
- $referer = GET_ANONYMOUS_REFERER($referer);
- } // END - if
-
- // Return it
- return $referer;
-}
-
// Adds a bonus mail to the queue
// This is a high-level function!
function addNewBonusMail ($data, $mode = '', $output=true) {
$GLOBALS['refid'] = getConfig(('def_refid'));
} elseif ((GET_EXT_VERSION('user') >= '0.3.4') && (getConfig('select_user_zero_refid')) == 'Y') {
// Select a random user which has confirmed enougth mails
- $GLOBALS['refid'] = SELECT_RANDOM_REFID();
+ $GLOBALS['refid'] = determineRandomReferalId();
} else {
// No default ID when sql_patches is not installed or none set
$GLOBALS['refid'] = 0;
return $GLOBALS['refid'];
}
-// Check wether we are installing
-function isInstalling () {
- $installing = ((isset($GLOBALS['mxchange_installing'])) || (REQUEST_ISSET_GET('installing')));
- //* DEBUG: */ var_dump($installing);
- return $installing;
-}
-
-// Check wether this script is installed
-function isInstalled () {
- return isBooleanConstantAndTrue('mxchange_installed');
-}
-
-// Check wether an admin is registered
-function isAdminRegistered () {
- return isBooleanConstantAndTrue('admin_registered');
-}
-
// Enables the reset mode. Only call this function if you really want the
// reset to be run!
function enableResetMode () {
runFilterChain('reset_enabled');
}
-// Checks wether the reset mode is active
-function isResetModeEnabled () {
- // Now simply check it
- return ((isset($GLOBALS['reset_enabled'])) && ($GLOBALS['reset_enabled'] === true));
-}
-
-// Checks wether the debug mode is enabled
-function isDebugModeEnabled () {
- // Simply check it
- return isBooleanConstantAndTrue('DEBUG_MODE');
-}
-
-// Checks wether the cache instance is valid
-function isCacheInstanceValid () {
- return ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
-}
-
// Our shutdown-function
function shutdown () {
// Call the filter chain 'shutdown'
return (isset($GLOBALS['userid']));
}
-// Checks wether the given FQFN is a directory and not .,.. or .svn
-function isDirectory ($FQFN) {
- // Generate baseName
- $baseName = basename($FQFN);
-
- // Check it
- $isDirectory = ((is_dir($FQFN)) && ($baseName != '.') && ($baseName != '..') && ($baseName != ".svn"));
-
- // Return the result
- return $isDirectory;
-}
-
// Handle message codes from URL
function handleCodeMessage () {
- if (REQUEST_ISSET_GET(('msg'))) {
+ if (REQUEST_ISSET_GET('msg')) {
// Default extension is "unknown"
- $ext = "unknown";
+ $ext = 'unknown';
// Is extension given?
- if (REQUEST_ISSET_GET(('ext'))) $ext = REQUEST_GET(('ext'));
+ if (REQUEST_ISSET_GET('ext')) $ext = REQUEST_GET('ext');
// Convert the 'msg' parameter from URL to a human-readable message
$msg = convertCodeToMessage(REQUEST_GET('msg'));
// Load message template
- LOAD_TEMPLATE("message", false, $msg);
+ LOAD_TEMPLATE('message', false, $msg);
+ } // END - if
+}
+
+// Setter for extra title
+function setExtraTitle ($extraTitle) {
+ $GLOBALS['extra_title'] = $extraTitle;
+}
+
+// Getter for extra title
+function getExtraTitle () {
+ // Is the extra title set?
+ if (!isExtraTitleSet()) {
+ // No, then abort here
+ debug_report_bug('extra_title is not set!');
} // END - if
+
+ // Return it
+ return $GLOBALS['extra_title'];
+}
+
+// Checks if the extra title is set
+function isExtraTitleSet () {
+ return ((isset($GLOBALS['extra_title'])) && (!empty($GLOBALS['extra_title'])));
}
//////////////////////////////////////////////////