outputRawCode($HTML);
// That's why you don't need any \n at the end of your HTML code... :-)
- if ($newLine) echo "\n";
+ if ($newLine) print("\n");
} else {
// Render mode for old or lame servers...
$OUTPUT .= $HTML;
// The same as above... ^
outputRawCode($HTML);
- if ($newLine) echo "\n";
+ if ($newLine) print("\n");
break;
default:
sendHeader('Connection: Close');
// Extension 'rewrite' installed?
- if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != '1') && ($GLOBALS['output_mode'] != '-1')) {
+ if ((EXT_IS_ACTIVE('rewrite')) && (getOutputMode() != '1') && (getOutputMode() != '-1')) {
$OUTPUT = rewriteLinksInCode($OUTPUT);
} // END - if
// Compile and run finished rendered HTML code
while (strpos($OUTPUT, '{!') > 0) {
+ // Replace _MYSQL_PREFIX
+ $OUTPUT = str_replace("{!_MYSQL_PREFIX!}", getConfig('_MYSQL_PREFIX'), $OUTPUT);
+
// Prepare the content and eval() it...
$newContent = '';
$eval = "\$newContent = \"".COMPILE_CODE(smartAddSlashes($OUTPUT))."\";";
// Was that eval okay?
if (empty($newContent)) {
// Something went wrong!
- app_die(__FUNCTION__, __LINE__, "Evaluation error:<pre>".htmlentities($eval)."</pre>");
+ app_die(__FUNCTION__, __LINE__, 'Evaluation error:<pre>' . htmlentities($eval) . '</pre>');
} // END - if
$OUTPUT = $newContent;
} // END - while
outputRawCode($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')) && (getOutputMode() != '1') && (getOutputMode() != '-1')) {
$OUTPUT = rewriteLinksInCode($OUTPUT);
} // END - if
// Output the raw HTML code
function outputRawCode ($HTML) {
// Output stripped HTML code to avoid broken JavaScript code, etc.
- echo stripslashes(stripslashes($HTML));
+ print(stripslashes(stripslashes($HTML)));
// Flush the output if only constant('_OB_CACHING') is not 'on'
if (constant('_OB_CACHING') != 'on') {
// @DEPRECATED Try to rewrite the if() condition
if ($template == 'member_support_form') {
// Support request of a member
- $result = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT `userid`, `gender`, `surname`, `family`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
array(getUserId()), __FUNCTION__, __LINE__);
// Is content an array?
$content['gender'] = translateGender($content['gender']);
} else {
// @DEPRECATED
- // @TODO Fine all templates which are using these direct variables and rewrite them.
+ // @TODO Find all templates which are using these direct variables and rewrite them.
// @TODO After this step is done, this else-block is history
list($gender, $surname, $family, $email) = SQL_FETCHROW($result);
// Translate gender
$gender = translateGender($gender);
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("DEPRECATION-WARNING: content is not array (%s).", gettype($content)));
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("DEPRECATION-WARNING: content is not array [%s], template=%s.", gettype($content), $template));
}
// Free result
} elseif (strpos($template, 'la_') > -1) {
// 'Logical-area' template found
$mode = 'la/';
+ } elseif (strpos($template, 'js_') > -1) {
+ // JavaScript template found
+ $mode = 'js/';
} else {
// Test for extension
$test = substr($template, 0, strpos($template, '_'));
if (EXT_IS_ACTIVE($test)) {
// Set extra path to extension's name
- $mode = $test.'/';
- }
+ $mode = $test . '/';
+ } // END - if
}
////////////////////////
////////////////////////
$FQFN = $basePath . $mode . $template . '.tpl';
- if ((!empty($GLOBALS['what'])) && ((strpos($template, '_header') > 0) || (strpos($template, '_footer') > 0)) && (($mode == 'guest/') || ($mode == 'member/') || ($mode == 'admin/'))) {
+ if ((isWhatSet()) && ((strpos($template, '_header') > 0) || (strpos($template, '_footer') > 0)) && (($mode == 'guest/') || ($mode == 'member/') || ($mode == 'admin/'))) {
// Select what depended header/footer template file for admin/guest/member area
$file2 = sprintf("%s%s%s_%s.tpl",
$basePath,
$mode,
$template,
- SQL_ESCAPE($GLOBALS['what'])
+ getWhat()
);
// Probe for it...
$ret = $tmpl_file;
}
- // Add surrounding HTML comments to help finding bugs faster
- $ret = "<!-- Template " . $template . " - Start -->\n" . $ret . "<!-- Template " . $template . " - End -->\n";
+ // Normal HTML output?
+ if ($GLOBALS['output_mode'] == 0) {
+ // Add surrounding HTML comments to help finding bugs faster
+ $ret = "<!-- Template " . $template . " - Start -->\n" . $ret . "<!-- Template " . $template . " - End -->\n";
+ } // END - if
} 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 />
// Send mail out to an email address
function sendEmail ($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '') {
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):TO={$toEmail},SUBJECT={$subject}<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):TO={$toEmail},SUBJECT={$subject}<br />");
// Compile subject line (for POINTS constant etc.)
$eval = "\$subject = decodeEntities(\"".COMPILE_CODE(smartAddSlashes($subject))."\");";
eval($eval);
// Set from header
- if ((!eregi("@", $toEmail)) && ($toEmail > 0)) {
+ if ((!eregi('@', $toEmail)) && ($toEmail > 0)) {
// Value detected, is the message extension installed?
- if (EXT_IS_ACTIVE("msg")) {
+ // @TODO Extension 'msg' does not exist
+ if (EXT_IS_ACTIVE('msg')) {
ADD_MESSAGE_TO_BOX($toEmail, $subject, $message, $HTML);
return;
} else {
// Load email address
- $result_email = SQL_QUERY_ESC("SELECT email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", array(bigintval($toEmail)), __FUNCTION__, __LINE__);
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):numRows=".SQL_NUMROWS($result_email)."<br />\n";
+ $result_email = SQL_QUERY_ESC("SELECT `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+ array(bigintval($toEmail)), __FUNCTION__, __LINE__);
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):numRows=".SQL_NUMROWS($result_email)."<br />");
// Does the user exist?
if (SQL_NUMROWS($result_email)) {
// Is the webmaster!
$toEmail = constant('WEBMASTER');
}
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):TO={$toEmail}<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):TO={$toEmail}<br />");
// Check for PHPMailer or debug-mode
if (!checkPhpMailerUsage()) {
}
// Generate a password in a specified length or use default password length
-function generatePassword ($LEN = 0) {
+function generatePassword ($length = 0) {
// Auto-fix invalid length of zero
- if ($LEN == 0) $LEN = getConfig('pass_len');
+ if ($length == 0) $length = getConfig('pass_len');
// Initialize array with all allowed chars
- $ABC = explode(',', 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9,-,+,_,/');
+ $ABC = explode(',', 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9,-,+,_,/,.');
// Start creating password
$PASS = '';
- for ($i = 0; $i < $LEN; $i++) {
+ for ($i = 0; $i < $length; $i++) {
$PASS .= $ABC[mt_rand(0, count($ABC) -1)];
} // END - for
// Loads an email template and compiles it
function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
- global $DATA, $_CONFIG;
+ global $DATA;
+
+ // Our configuration is kept non-global here
+ $_CONFIG = getConfigArray();
// Make sure all template names are lowercase!
$template = strtolower($template);
} // END - if
// Load user's data
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):UID={$UID},template={$template},content[]=".gettype($content)."<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):UID={$UID},template={$template},content[]=".gettype($content)."<br />");
if (($UID > 0) && (is_array($content))) {
// If nickname extension is installed, fetch nickname as well
if (EXT_IS_ACTIVE('nickname')) {
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NICKNAME!<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NICKNAME!<br />");
// Load nickname
- $result = SQL_QUERY_ESC("SELECT surname, family, gender, email, nickname FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array(bigintval($UID)), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `gender`, `email`, `nickname` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+ array(bigintval($UID)), __FUNCTION__, __LINE__);
} else {
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NO-NICK!<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NO-NICK!<br />");
/// Load normal data
- $result = SQL_QUERY_ESC("SELECT surname, family, gender, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array(bigintval($UID)), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `gender`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+ array(bigintval($UID)), __FUNCTION__, __LINE__);
}
// Fetch and merge data
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):content()=".count($content)." - PRE<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):content()=".count($content)." - PRE<br />");
$content = merge_array($content, SQL_FETCHARRAY($result));
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):content()=".count($content)." - AFTER<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):content()=".count($content)." - AFTER<br />");
// Free result
SQL_FREERESULT($result);
$test = substr($found, 0, strlen($match));
// Does this entry exist?
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):found={$found},match={$match},set={$set}<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):found={$found},match={$match},set={$set}<br />");
if ($test == $match) {
// Match found!
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):fuzzyFound!<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):fuzzyFound!<br />");
$fuzzyFound = true;
break;
} // END - if
// Take all string elements
if ((is_string($matches[4][$key])) && (!isset($matchesFound[$match])) && (!isset($matchesFound[$key."_" . $matches[4][$key]]))) {
// Replace it in the code
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):key={$key},match={$match}<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):key={$key},match={$match}<br />");
$newMatch = str_replace("[" . $matches[4][$key]."]", "['" . $matches[4][$key]."']", $match);
$code = str_replace($match, "\"." . $newMatch.".\"", $code);
$matchesFound[$key."_" . $matches[4][$key]] = 1;
$matchesFound[$match] = 1;
} elseif (!isset($matchesFound[$match])) {
// Not yet replaced!
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):match={$match}<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):match={$match}<br />");
$code = str_replace($match, "\"." . $match.".\"", $code);
$matchesFound[$match] = 1;
}
$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')));
+ $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
// Has the whole value changed?
// @TODO Remove this if() block if all is working fine
- if ("" . $ret."" != '' . $num."") {
+ if ('' . $ret . '' != '' . $num . '') {
// Log the values
- debug_report_bug("{$ret}<>{$num}");
+ //debug_report_bug("{$ret}<>{$num}");
} // END - if
// Return result
// First of all years...
$Y = abs(floor($timestamp / (31536000 + $SWITCH)));
- //* DEBUG: */ print("Y={$Y}<br />\n");
+ //* DEBUG: */ print("Y={$Y}<br />");
// Next months...
$M = abs(floor($timestamp / 2628000 - $Y * 12));
- //* DEBUG: */ print("M={$M}<br />\n");
+ //* DEBUG: */ print("M={$M}<br />");
// Next weeks
$W = abs(floor($timestamp / 604800 - $Y * ((365 + $SWITCH / getConfig('one_day')) / 7) - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) / 7)));
- //* DEBUG: */ print("W={$W}<br />\n");
+ //* DEBUG: */ print("W={$W}<br />");
// Next days...
$D = abs(floor($timestamp / 86400 - $Y * (365 + $SWITCH / getConfig('one_day')) - ($M / 12 * (365 + $SWITCH / getConfig('one_day'))) - $W * 7));
- //* DEBUG: */ print("D={$D}<br />\n");
+ //* DEBUG: */ print("D={$D}<br />");
// Next hours...
$h = abs(floor($timestamp / 3600 - $Y * (365 + $SWITCH / getConfig('one_day')) * 24 - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) * 24) - $W * 7 * 24 - $D * 24));
- //* DEBUG: */ print("h={$h}<br />\n");
+ //* DEBUG: */ print("h={$h}<br />");
// Next minutes..
$m = abs(floor($timestamp / 60 - $Y * (365 + $SWITCH / getConfig('one_day')) * 24 * 60 - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) * 24 * 60) - $W * 7 * 24 * 60 - $D * 24 * 60 - $h * 60));
- //* DEBUG: */ print("m={$m}<br />\n");
+ //* DEBUG: */ print("m={$m}<br />");
// And at last seconds...
$s = abs(floor($timestamp - $Y * (365 + $SWITCH / getConfig('one_day')) * 24 * 3600 - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) * 24 * 3600) - $W * 7 * 24 * 3600 - $D * 24 * 3600 - $h * 3600 - $m * 60));
- //* DEBUG: */ print("s={$s}<br />\n");
+ //* DEBUG: */ print("s={$s}<br />");
// Is seconds zero and time is < 60 seconds?
if (($s == 0) && ($timestamp < 60)) {
$OUT .= " <td align=\"center\" class=\"admin_title bottom\"><div class=\"tiny\">{--_YEARS--}</strong></td>\n";
}
- if (ereg("M", $display) || (empty($display))) {
+ if (ereg('M', $display) || (empty($display))) {
$OUT .= " <td align=\"center\" class=\"admin_title bottom\"><div class=\"tiny\">{--_MONTHS--}</strong></td>\n";
}
$OUT .= "<INPUT type=\"hidden\" name=\"" . $prefix."_ye\" value=\"0\" />\n";
}
- if (ereg("M", $display) || (empty($display))) {
+ if (ereg('M', $display) || (empty($display))) {
// Generate month selection
$OUT .= " <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix."_mo\" size=\"1\">\n";
for ($idx = 0; $idx <= 11; $idx++)
$NAV .= "<strong>-";
} else {
// Open anchor tag and add base URL
- $NAV .= "<a href=\"{!URL!}/modules.php?module=admin&what=" . $GLOBALS['what']."&page=" . $page."&offset=" . $offset;
+ $NAV .= "<a href=\"{!URL!}/modules.php?module=admin&what=" . getWhat()."&page=" . $page."&offset=" . $offset;
// Add userid when we shall show all mails from a single member
if ((REQUEST_ISSET_GET('uid')) && (bigintval(REQUEST_GET('uid')) > 0)) $NAV .= "&uid=".bigintval(REQUEST_GET('uid'));
if (ereg('/', $host)) $host = substr($host, 0, strpos($host, '/'));
// Generate relative URL
- //* DEBUG: */ print("SCRIPT=" . $script."<br />\n");
+ //* DEBUG: */ print("SCRIPT=" . $script."<br />");
if (substr(strtolower($script), 0, 7) == 'http://') {
// But only if http:// is in front!
$script = substr($script, (strlen($url) + 7));
$script = substr($script, (strlen($url) + 8));
}
- //* DEBUG: */ print("SCRIPT=" . $script."<br />\n");
+ //* DEBUG: */ print("SCRIPT=" . $script."<br />");
if (substr($script, 0, 1) == '/') $script = substr($script, 1);
// Return host name
} // END - if
// Open connection
- //* DEBUG: */ die("SCRIPT=" . $script."<br />\n");
+ //* DEBUG: */ die("SCRIPT=" . $script."<br />");
if ($useProxy === true) {
// Connect to host through proxy connection
$fp = @fsockopen(COMPILE_CODE(getConfig('proxy_host')), bigintval(getConfig('proxy_port')), $errno, $errdesc, 30);
$regex = '@^' . $first . '\@' . $domain . '$@iU';
// Return check result
- // @NOTE altered the regex-pattern and added modificator i (match both upper and lower case letters) and U (PCRE_UNGREEDY) to work with preg_match the same way as eregi
return preg_match($regex, $email);
}
function isUrlValid ($URL, $compile=true) {
// Trim URL a little
$URL = trim(urldecode($URL));
- //* DEBUG: */ echo $URL."<br />";
+ //* DEBUG: */ OUTPUT_HTML($URL."<br />");
// Compile some chars out...
if ($compile === true) $URL = compileUriCode($URL, false, false, false);
- //* DEBUG: */ echo $URL."<br />";
+ //* DEBUG: */ OUTPUT_HTML($URL."<br />");
// Check for the extension filter
if (EXT_IS_ACTIVE('filter')) {
foreach ($TARGETS as $tar) {
$eval .= "<span class=\\\"admin_user_link\\\"><a href=\\\"{!URL!}/modules.php?module=admin&what=" . $tar."&uid=" . $uid."\\\" title=\\\"{--ADMIN_LINK_";
- //* DEBUG: */ echo "*" . $tar.'/' . $status."*<br />\n";
+ //* DEBUG: */ OUTPUT_HTML("*" . $tar.'/' . $status."*<br />");
if (($tar == "lock_user") && ($status == 'LOCKED')) {
// Locked accounts shall be unlocked
$eval .= "UNLOCK_USER";
}
// Generate an email link
-function generateMemberEmailLink ($email, $table = 'admins') {
+function generateEmailLink ($email, $table = 'admins') {
// Default email link (INSECURE! Spammer can read this by harvester programs)
$EMAIL = 'mailto:' . $email;
// Check for several extensions
if ((EXT_IS_ACTIVE('admins')) && ($table == 'admins')) {
// Create email link for contacting admin in guest area
- $EMAIL = adminsCreateEmailLink($email);
+ $EMAIL = generateAdminEmailLink($email);
} elseif ((EXT_IS_ACTIVE('user')) && (GET_EXT_VERSION('user') >= '0.3.3') && ($table == 'user_data')) {
// Create email link for contacting a member within admin area (or later in other areas, too?)
- $EMAIL = USER_generateMemberEmailLink($email);
+ $EMAIL = generateUserEmailLink($email, 'admin');
} elseif ((EXT_IS_ACTIVE('sponsor')) && ($table == 'sponsor_data')) {
// Create email link to contact sponsor within admin area (or like the link above?)
- $EMAIL = SPONSOR_generateMemberEmailLink($email);
+ $EMAIL = generateSponsorEmailLink($email, 'sponsor_data');
}
// Shall I close the link when there is no admin?
$server = $_SERVER['PHP_SELF'].getConfig('ENCRYPT_SEPERATOR').detectUserAgent().getConfig('ENCRYPT_SEPERATOR').getenv('SERVER_SOFTWARE').getConfig('ENCRYPT_SEPERATOR').detectRemoteAddr();
// Build key string
- $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');
+ $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.getConfig('ENCRYPT_SEPERATOR').uniqid(mt_rand(), true).getConfig('ENCRYPT_SEPERATOR').time();
// Generate SHA1 sum from modula of number and the prime number
$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 />";
+ //* DEBUG: */ OUTPUT_HTML("SHA1=" . $sha1." (".strlen($sha1).")<br />");
$sha1 = scrambleString($sha1);
- //* DEBUG: */ echo "Scrambled=" . $sha1." (".strlen($sha1).")<br />";
+ //* DEBUG: */ OUTPUT_HTML("Scrambled=" . $sha1." (".strlen($sha1).")<br />");
//* DEBUG: */ $sha1b = descrambleString($sha1);
- //* DEBUG: */ echo "Descrambled=" . $sha1b." (".strlen($sha1b).")<br />";
+ //* DEBUG: */ OUTPUT_HTML("Descrambled=" . $sha1b." (".strlen($sha1b).")<br />");
// Generate the password salt string
$salt = substr($sha1, 0, getConfig('salt_length'));
- //* DEBUG: */ echo $salt." (".strlen($salt).")<br />";
+ //* DEBUG: */ OUTPUT_HTML($salt." (".strlen($salt).")<br />");
} else {
// Use given salt
$salt = substr($salt, 0, getConfig('salt_length'));
- //* DEBUG: */ echo "GIVEN={$salt}<br />\n";
+ //* DEBUG: */ OUTPUT_HTML("GIVEN={$salt}<br />");
}
// Return hash
}
// Scramble string here
- //* DEBUG: */ echo "***Original=" . $str."***<br />";
+ //* DEBUG: */ OUTPUT_HTML("***Original=" . $str."***<br />");
for ($idx = 0; $idx < strlen($str); $idx++) {
// Get char on scrambled position
$char = substr($str, $scrambleNums[$idx], 1);
} // END - for
// Return scrambled string
- //* DEBUG: */ echo "***Scrambled=" . $scrambled."***<br />";
+ //* DEBUG: */ OUTPUT_HTML("***Scrambled=" . $scrambled."***<br />");
return $scrambled;
}
if (count($scrambleNums) != 40) return $str;
// Begin descrambling
- $orig = str_repeat(" ", 40);
- //* DEBUG: */ echo "+++Scrambled=" . $str."+++<br />";
+ $orig = str_repeat(' ', 40);
+ //* DEBUG: */ OUTPUT_HTML("+++Scrambled=" . $str."+++<br />");
for ($idx = 0; $idx < 40; $idx++) {
$char = substr($str, $idx, 1);
$orig = substr_replace($orig, $char, $scrambleNums[$idx], 1);
} // END - for
// Return scrambled string
- //* DEBUG: */ echo "+++Original=" . $orig."+++<br />";
+ //* DEBUG: */ OUTPUT_HTML("+++Original=" . $orig."+++<br />");
return $orig;
}
}
$mod = substr(round($mod), 0, 4);
$mod = str_repeat('0', 4-strlen($mod)) . $mod;
- //* DEBUG: */ echo "*" . $start.'=' . $mod."*<br />";
+ //* DEBUG: */ OUTPUT_HTML("*" . $start.'=' . $mod."*<br />");
$start += 4;
$newHash .= $mod;
} // END - for
//* DEBUG: */ print($passHash."<br />" . $newHash." (".strlen($newHash).')');
$ret = generateHash($newHash, getConfig('master_salt'));
- //* DEBUG: */ print($ret."<br />\n");
+ //* DEBUG: */ print($ret."<br />");
} else {
// Hash it simple
- //* DEBUG: */ echo "--" . $passHash."--<br />\n";
+ //* DEBUG: */ OUTPUT_HTML("--" . $passHash."--<br />");
$ret = md5($passHash);
- //* DEBUG: */ echo "++" . $ret."++<br />\n";
+ //* DEBUG: */ OUTPUT_HTML("++" . $ret."++<br />");
}
// Return result
// Load header
loadIncludeOnce('inc/header.php');
- // Prepare message for output
+ // Rewrite message for output
$message = sprintf(getMessage('MXCHANGE_HAS_DIED'), basename($F), $L, $message);
+ // Better log this message away
+ DEBUG_LOG($F, $L, $message);
+
// Load the message template
LOAD_TEMPLATE('admin_settings_saved', false, $message);
// In cache?
if (isset($GLOBALS['cache_array']['const'][$constName])) {
// Use cache
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): " . $constName."-CACHE!<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): " . $constName."-CACHE!<br />");
$res = ($GLOBALS['cache_array']['const'][$constName] === true);
} else {
// Check constant
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): " . $constName."-RESOLVE!<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): " . $constName."-RESOLVE!<br />");
if (defined($constName)) {
// Found!
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): " . $constName."-FOUND!<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): " . $constName."-FOUND!<br />");
$res = (constant($constName) === true);
} // END - if
// Fix it to default
$ret = 'default';
} // END - if
- } elseif ((!isInstalled()) && ((isInstalling()) || ($GLOBALS['output_mode'] == true)) && ((REQUEST_ISSET_GET('theme')) || (REQUEST_ISSET_POST('theme')))) {
+ } elseif ((!isInstalled()) && ((isInstalling()) || (getOutputMode() == true)) && ((REQUEST_ISSET_GET('theme')) || (REQUEST_ISSET_POST('theme')))) {
// Prepare FQFN for checking
$theme = sprintf("%stheme/%s/theme.php", constant('PATH'), REQUEST_GET('theme'));
// Generates an error code from given account status
function generateErrorCodeFromUserStatus ($status) {
+ // @TODO The status should never be empty
+ if (empty($status)) {
+ // Something really bad happend here
+ debug_report_bug(__FUNCTION__ . ': status is empty.');
+ } // END - if
+
// Default error code if unknown account status
$errorCode = getCode('UNKNOWN_STATUS');
// Function to search for the last modifified file
function searchDirsRecursive ($dir, &$last_changed) {
// Get dir as array
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):dir=" . $dir."<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):dir=" . $dir."<br />");
// Does it match what we are looking for? (We skip a lot files already!)
// RegexPattern to exclude ., .., .revision, .svn, debug.log or .cache in the filenames
- $excludePattern = '@(\.|\.\.|\.revision|\.svn|debug\.log|\.cache|config\.php)$@';
- $ds = getArrayFromDirectory($dir, '', true, false, $excludePattern);
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):ds[]=".count($ds)."<br />\n";
+ $excludePattern = '@(\.revision|debug\.log|\.cache|config\.php)$@';
+ $ds = getArrayFromDirectory($dir, '', true, false, array(), '.php', $excludePattern);
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):ds[]=".count($ds)."<br />");
// Walk through all entries
foreach ($ds as $d) {
// Generate proper FQFN
- $FQFN = str_replace("//", '/', constant('PATH') . $dir. '/'. $d);
+ $FQFN = str_replace('//', '/', constant('PATH') . $dir. '/'. $d);
// Is it a file and readable?
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):FQFN={$FQFN}<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):FQFN={$FQFN}<br />");
if (isDirectory($FQFN)) {
// $FQFN is a directory so also crawl into this directory
$newDir = $d;
if (!empty($dir)) $newDir = $dir . '/'. $d;
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):DESCENT: " . $newDir."<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):DESCENT: " . $newDir."<br />");
searchDirsRecursive($newDir, $last_changed);
} elseif (isFileReadable($FQFN)) {
// $FQFN is a filename and no directory
$time = filemtime($FQFN);
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):File: " . $d." found. (".($last_changed['time'] - $time).")<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):File: " . $d." found. (".($last_changed['time'] - $time).")<br />");
if ($last_changed['time'] < $time) {
// This file is newer as the file before
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>) - NEWER!<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>) - NEWER!<br />");
$last_changed['path_name'] = $FQFN;
$last_changed['time'] = $time;
} // END - if
if (EXT_IS_ACTIVE('cache')) {
// Check if REQUEST_GET('check_revision_data') is setted (switch for manually rewrite the .revision-File)
- if (REQUEST_ISSET_GET('check_revision_data') && REQUEST_GET('check_revision_data') == 'yes') $new = true;
- if (!isset($GLOBALS['cache_array']['revision'][$type])
- || count($GLOBALS['cache_array']['revision']) < 3
- || !$GLOBALS['cache_instance']->loadCacheFile('revision')) $new = true;
+ if (REQUEST_ISSET_GET('check_revision_data') && REQUEST_GET('check_revision_data') == 'yes') {
+ // Force rebuild by URL parameter
+ $new = true;
+ } elseif ((
+ !isset($GLOBALS['cache_array']['revision'][$type])
+ ) || (
+ count($GLOBALS['cache_array']['revision']) < 3
+ ) || (
+ !$GLOBALS['cache_instance']->loadCacheFile('revision')
+ )) {
+ // Out-dated cache
+ $new = true;
+ } // END - if
// Is the cache file outdated/invalid?
- if ($new === true){
- $GLOBALS['cache_instance']->destroyCacheFile(); // @TODO isn't it better to do $GLOBALS['cache_instance']->destroyCacheFile('revision')?
+ if ($new === true) {
+ // Reload the cache file
+ $GLOBALS['cache_instance']->loadCacheFile('revision');
+
+ // Destroy cache file
+ $GLOBALS['cache_instance']->destroyCacheFile(false, true);
// @TODO shouldn't do the unset and the reloading $GLOBALS['cache_instance']->destroyCacheFile() Or a new methode like forceCacheReload('revision')?
unset($GLOBALS['cache_array']['revision']);
// Reload load_cach-revison.php
loadInclude('inc/loader/load_cache-revision.php');
+
+ // Abort here
+ return;
} // END - if
// Return found value
return $GLOBALS['cache_array']['revision'][$type][0];
-
} else {
// Old Version without ext-cache active (deprecated ?)
// Check if REQUEST_GET('check_revision_data') is setted (switch for manually rewrite the .revision-File)
if ((REQUEST_ISSET_GET('check_revision_data')) && (REQUEST_GET('check_revision_data') == 'yes')) {
- // Has changed!
+ // Forced rebuild of .revision file
$new = true;
} else {
// Check for revision file
// @TODO Please describe this function
function getArrayFromActualVersion () {
// Init variables
- $next_dir = ''; // Directory to start with search
+ $next_dir = '';
+
+ // Directory to start with search
$last_changed = array(
'path_name' => '',
'time' => 0
);
- $akt_vers = array(); // Init return array
- $res = 0; // Init value for counting the founded keywords
+
+ // Init return array
+ $akt_vers = array();
+
+ // Init value for counting the founded keywords
+ $res = 0;
// Searches all Files and there date of the last modifikation and puts the newest File in $last_changed.
searchDirsRecursive($next_dir, $last_changed); // @TODO small change to API to $last_changed = searchDirsRecursive($next_dir, $time);
if (!empty($message)) {
// Use and log it
$debug = sprintf("Note: %s<br />\n",
- $message
+ $message
);
// @TODO Add a little more infos here
} // END - if
// Add output
- $debug .= "Please report this bug at <a title=\"Direct link to the bug-tracker\" href=\"http://bugs.mxchange.org\" rel=\"external\" target=\"_blank\">bugs.mxchange.org</a> and include the logfile from <strong>inc/cache/debug.log</strong> in your report (you cannot attach files!):<pre>";
+ $debug .= "Please report this bug at <a title=\"Direct link to the bug-tracker\" href=\"http://bugs.mxchange.org\" rel=\"external\" target=\"_blank\">bugs.mxchange.org</a> and include the logfile from <strong>inc/cache/debug.log</strong> in your report (you can now attach files):<pre>";
$debug .= debug_get_printable_backtrace();
$debug .= "</pre>\nRequest-URI: " . $_SERVER['REQUEST_URI']."<br />\n";
$debug .= "Thank you for finding bugs.";
// Generates a ***weak*** seed (taken from de.php.net/mt_srand)
function generateSeed () {
- list($usec, $sec) = explode(" ", microtime());
- return ((float)$sec + (float)$usec);
+ list($usec, $sec) = explode(' ', microtime());
+ $microTime = (((float)$sec + (float)$usec)) * 100000;
+ return $microTime;
}
// Converts a message code to a human-readable message
// Is the extension there?
if (EXT_IS_ACTIVE('admins')) {
// Admin found
- $admin = "<a href=\"".adminsCreateEmailLink(getAdminEmail($aid))."\">" . $login."</a>";
+ $admin = "<a href=\"".generateEmailLink(getAdminEmail($aid), 'admins')."\">" . $login."</a>";
} else {
// Extension not found
$admin = sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), 'admins');
}
// Compile characters which are allowed in URLs
-function compileUriCode ($code, $simple=true) {
+function compileUriCode ($code, $simple = true) {
// Compile constants
if (!$simple) $code = str_replace('{--', '".', str_replace('--}', '."', $code));
// @TODO Are these convertions still required?
$pat = str_replace('.', "\.", $pat);
$pat = str_replace('@', "\@", $pat);
- echo $key."= " . $pat . "<br />";
+ //* DEBUG: */ OUTPUT_HTML($key."= " . $pat . "<br />");
} // END - if
// Check if expression matches
$tmp = $FQFN . '.tmp';
// Open the source file
- $fp = fopen($FQFN, 'r') or OUTPUT_HTML('<strong>READ:</strong> ' . $FQFN . "<br />\n");
+ $fp = fopen($FQFN, 'r') or OUTPUT_HTML('<strong>READ:</strong> ' . $FQFN . '<br />');
// Is the resource valid?
if (is_resource($fp)) {
// Open temporary file
- $fp_tmp = fopen($tmp, 'w') or OUTPUT_HTML('<strong>WRITE:</strong> ' . $tmp . "<br />\n");
+ $fp_tmp = fopen($tmp, 'w') or OUTPUT_HTML('<strong>WRITE:</strong> ' . $tmp . '<br />');
// Is the resource again valid?
if (is_resource($fp_tmp)) {
} else {
$next++;
}
- }
+ } // END - if
// Write to temp file
fputs($fp_tmp, $line);
// Remove CRLF
$message = str_replace("\r", '', str_replace("\n", '', $message));
- // Log this message away
- $fp = fopen(constant('PATH')."inc/cache/debug.log", 'a') or app_die(__FUNCTION__, __LINE__, "Cannot write logfile debug.log!");
- fwrite($fp, date("d.m.Y|H:i:s", time())."|" . $GLOBALS['module']."|".basename($funcFile)."|" . $line."|".strip_tags($message)."\n");
+ // Log this message away, we better don't call app_die() here to prevent an endless loop
+ $fp = fopen(constant('PATH') . 'inc/cache/debug.log', 'a') or die(__FUNCTION__.'['.__LINE__.']: Cannot write logfile debug.log!');
+ fwrite($fp, date('d.m.Y|H:i:s', time()) . '|' . getModule() . '|' . basename($funcFile) . '|' . $line . '|' . strip_tags($message) . "\n");
fclose($fp);
} // END - if
}
// Is the reset set or old sql_patches?
if ((!isResetModeEnabled()) || (EXT_VERSION_IS_OLDER('sql_patches', '0.4.5'))) {
// Then abort here
- DEBUG_LOG(__FUNCTION__, __LINE__, "Cannot run reset! Please report this bug. Thanks");
+ DEBUG_LOG(__FUNCTION__, __LINE__, 'Cannot run reset! Please report this bug. Thanks');
} // END - if
// Get more daily reset scripts
// Ignore zero values
if (getSession('mxchange_' . $accessLevel.'_failures') > 0) {
// Non-guest has login failures found, get both data and prepare it for template
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):accessLevel={$accessLevel}<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):accessLevel={$accessLevel}<br />");
$content = array(
'login_failures' => getSession('mxchange_' . $accessLevel.'_failures'),
'last_failure' => generateDateTime(getSession('mxchange_' . $accessLevel.'_last_fail'), '2')
// Is the include there?
if (isIncludeReadable($INC)) {
// And rebuild it from scratch
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): inc={$inc} - LOADED!<br />\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): inc={$inc} - LOADED!<br />");
loadInclude($INC);
} else {
// Include not found!
return false;
} elseif (!isCacheInstanceValid()) {
// No cache instance!
- DEBUG_LOG(__FUNCTION__, __LINE__, " No cache instance found.");
+ DEBUG_LOG(__FUNCTION__, __LINE__, 'No cache instance found.');
return false;
} elseif ((!isConfigEntrySet('cache_admin_menu')) || (getConfig('cache_admin_menu') != 'Y')) {
// Caching disabled (currently experiemental!)
LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_MORE_SELECTED'));
} else {
// Debug log
- DEBUG_LOG(__FUNCTION__, __LINE__, " cat={$data['cat']},receiver={$data['receiver']},data=".base64_encode(serialize($data))." More selected, than available!");
+ DEBUG_LOG(__FUNCTION__, __LINE__, "cat={$data['cat']},receiver={$data['receiver']},data=".base64_encode(serialize($data))." More selected, than available!");
}
}
} elseif ((isSessionVariableSet('refid')) && (getSession('refid') != 0)) {
// Set session refid als global
$GLOBALS['refid'] = bigintval(getSession('refid'));
- } elseif ((GET_EXT_VERSION('sql_patches') != '') && (getConfig('def_refid') > 0)) {
- // Set default refid as refid in URL
- $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'] = determineRandomReferalId();
+ } elseif ((GET_EXT_VERSION('sql_patches') != '') && (getConfig('def_refid') > 0)) {
+ // Set default refid as refid in URL
+ $GLOBALS['refid'] = getConfig('def_refid');
} else {
// No default ID when sql_patches is not installed or none set
$GLOBALS['refid'] = 0;
// Handle message codes from URL
function handleCodeMessage () {
if (REQUEST_ISSET_GET('msg')) {
- // Default extension is "unknown"
+ // Default extension is 'unknown'
$ext = 'unknown';
// Is extension given?
return $message;
}
+// Reads a directory recursively by default and searches for files not matching
+// an exclusion pattern. You can now keep the exclusion pattern empty for reading
+// a whole directory.
+function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $addBaseDir = true, $excludeArray = array(), $extension = '.php', $excludePattern = '@(\.|\.\.)$@', $recursive = true) {
+ // Add default entries we should exclude
+ $excludeArray[] = '.';
+ $excludeArray[] = '..';
+ $excludeArray[] = '.svn';
+ $excludeArray[] = '.htaccess';
+
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "baseDir={$baseDir},prefix={$prefix} - Entered!");
+ // Init includes
+ $files = array();
+
+ // Open directory
+ $dirPointer = opendir(constant('PATH') . $baseDir) or app_die(__FUNCTION__, __LINE__, 'Cannot read directory ' . basename($baseDir) . '.');
+
+ // Read all entries
+ while ($baseFile = readdir($dirPointer)) {
+ // Exclude '.', '..' and entries in $excludeArray automatically
+ if (in_array($baseFile, $excludeArray, true)) {
+ // Exclude them
+ //* DEBUG: */ OUTPUT_HTML('excluded=' . $baseFile . "<br />");
+ continue;
+ } // END - if
+
+ // Construct include filename and FQFN
+ $fileName = $baseDir . '/' . $baseFile;
+ $FQFN = constant('PATH') . $fileName;
+
+ // Remove double slashes
+ $FQFN = str_replace('//', '/', $FQFN);
+
+ // Check if the base filename matches an exclusion pattern and if the pattern is not empty
+ if ((!empty($excludePattern)) && (preg_match($excludePattern, $baseFile, $match))) {
+ // These Lines are only for debugging!!
+ //* DEBUG: */ OUTPUT_HTML('baseDir:' . $baseDir . "<br />");
+ //* DEBUG: */ OUTPUT_HTML('baseFile:' . $baseFile . "<br />");
+ //* DEBUG: */ OUTPUT_HTML('FQFN:' . $FQFN . "<br />");
+
+ // Exclude this one
+ continue;
+ } // END - if
+
+ // Skip also files with non-matching prefix genericly
+ if (($recursive === true) && (isDirectory($FQFN))) {
+ // Is a redirectory so read it as well
+ $files = merge_array($files, getArrayFromDirectory ($baseDir . $baseFile . '/', $prefix, $fileIncludeDirs, $addBaseDir, $excludeArray, $extension, $excludePattern, $recursive));
+
+ // And skip further processing
+ continue;
+ } elseif (substr($baseFile, 0, strlen($prefix)) != $prefix) {
+ // Skip this file
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Invalid prefix in file " . $baseFile . ", prefix=" . $prefix);
+ continue;
+ } elseif (!isFileReadable($FQFN)) {
+ // Not readable so skip it
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "File " . $FQFN . " is not readable!");
+ continue;
+ }
+
+ // Is the file a PHP script or other?
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}");
+ if ((substr($baseFile, -4, 4) == '.php') || (($fileIncludeDirs === true) && (isDirectory($FQFN)))) {
+ // Is this a valid include file?
+ if ($extension == '.php') {
+ // Remove both for extension name
+ $extName = substr($baseFile, strlen($prefix), -4);
+
+ // Try to find it
+ $extId = GET_EXT_ID($extName);
+
+ // Is the extension valid and active?
+ if (($extId > 0) && (EXT_IS_ACTIVE($extName))) {
+ // Then add this file
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'Extension entry ' . $baseFile . ' added.');
+ $files[] = $fileName;
+ } elseif ($extId == 0) {
+ // Add non-extension files as well
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'Regular entry ' . $baseFile . ' added.');
+ if ($addBaseDir === true) {
+ $files[] = $fileName;
+ } else {
+ $files[] = $baseFile;
+ }
+ }
+ } else {
+ // We found .php file but should not search for them, why?
+ debug_report_bug('We should find files with extension=' . $extension . ', but we found a PHP script.');
+ }
+ } else {
+ // Other, generic file found
+ $files[] = $fileName;
+ }
+ } // END - while
+
+ // Close directory
+ closedir($dirPointer);
+
+ // Sort array
+ asort($files);
+
+ // Return array with include files
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, '- Left!');
+ return $files;
+}
+
//////////////////////////////////////////////////
// AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS //
//////////////////////////////////////////////////