// Init counter
$cnt = '0';
+ // Add page header and footer
+ addPageHeaderFooter();
+
// Compile all out
while (((strpos($GLOBALS['output'], '{--') > 0) || (strpos($GLOBALS['output'], '{!') > 0) || (strpos($GLOBALS['output'], '{?') > 0)) && ($cnt < 3)) {
// Init common variables
$NAV = '';
for ($page = 1; $page <= $PAGES; $page++) {
// Is the page currently selected or shall we generate a link to it?
- if (($page == getRequestElement('page')) || ((!isGetRequestElementSet('page')) && ($page == 1))) {
+ if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
// Is currently selected, so only highlight it
$NAV .= '<strong>-';
} else {
$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 ((isGetRequestElementSet('userid')) && (bigintval(getRequestElement('userid')) > 0)) $NAV .= '&userid=' . bigintval(getRequestElement('userid'));
+ if ((isGetRequestParameterSet('userid')) && (bigintval(getRequestParameter('userid')) > 0)) $NAV .= '&userid=' . bigintval(getRequestParameter('userid'));
// Close open anchor tag
$NAV .= '%}">';
}
$NAV .= $page;
- if (($page == getRequestElement('page')) || ((!isGetRequestElementSet('page')) && ($page == 1))) {
+ if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
// Is currently selected, so only highlight it
$NAV .= '-</strong>';
} else {
// Add script data
$script .= $body;
+ // Remove trailed & to make it more conform
+ if (substr($script, -1, 1) == '&') $script = substr($script, 0, -1);
+
// Generate GET request header
$request = 'GET /' . trim($script) . ' HTTP/1.1' . getConfig('HTTP_EOL');
$request .= 'Host: ' . $host . getConfig('HTTP_EOL');
$request .= 'Accept-Charset: UTF-8,*' . getConfig('HTTP_EOL');
$request .= 'Cache-Control: no-cache' . getConfig('HTTP_EOL');
$request .= 'Content-Type: text/plain' . getConfig('HTTP_EOL');
- $request .= 'Content-Length: '.strlen($body) . getConfig('HTTP_EOL');
- $request .= 'Connection: close' . getConfig('HTTP_EOL') . getConfig('HTTP_EOL');
+ $request .= 'Content-Length: 0' . getConfig('HTTP_EOL');
+ $request .= 'Connection: close' . getConfig('HTTP_EOL');
+ $request .= getConfig('HTTP_EOL');
// Send the raw request
$response = sendRawRequest($host, $request);
$request .= 'User-Agent: ' . getConfig('TITLE') . '/' . getConfig('FULL_VERSION') . getConfig('HTTP_EOL');
$request .= 'Cache-Control: no-cache' . getConfig('HTTP_EOL');
$request .= 'Content-Type: application/x-www-form-urlencoded' . getConfig('HTTP_EOL');
- $request .= 'Connection: close' . getConfig('HTTP_EOL') . getConfig('HTTP_EOL');
+ $request .= 'Connection: close' . getConfig('HTTP_EOL');
+ $request .= getConfig('HTTP_EOL');
+
+ // Add body
$request .= $body;
// Send the raw request
//* DEBUG: */ die("SCRIPT=" . $script.'<br />');
if ($useProxy === true) {
// Connect to host through proxy connection
- $fp = @fsockopen(compileRawCode(getConfig('proxy_host')), bigintval(getConfig('proxy_port')), $errno, $errdesc, 30);
+ $fp = fsockopen(compileRawCode(getConfig('proxy_host')), bigintval(getConfig('proxy_port')), $errno, $errdesc, 30);
} else {
// Connect to host directly
- $fp = @fsockopen($host, 80, $errno, $errdesc, 30);
+ $fp = fsockopen($host, 80, $errno, $errdesc, 30);
}
// Is there a link?
if (!is_resource($fp)) {
// Failed!
+ logDebugMessage(__FUNCTION__, __LINE__, $errdesc . ' (' . $errno . ')');
return $response;
- } // END - if
+ } elseif ((!stream_set_blocking($fp, 0)) || (!stream_set_timeout($fp, 1))) {
+ // Cannot set non-blocking mode or timeout
+ logDebugMessage(__FUNCTION__, __LINE__, socket_strerror(socket_last_error()));
+ return $response;
+ }
// Do we use proxy?
if ($useProxy === true) {
//* DEBUG: */ print('<strong>proxyTunnel=</strong><pre>' . $proxyTunnel.'</pre>');
// Write request
- fputs($fp, $proxyTunnel);
+ fwrite($fp, $proxyTunnel);
// Got response?
if (feof($fp)) {
} // END - if
// Write request
- fputs($fp, $request);
+ fwrite($fp, $request);
+
+ // Start counting
+ $start = microtime(true);
// Read response
while (!feof($fp)) {
- $response[] = trim(fgets($fp, 1024));
+ // Get info from stream
+ $info = stream_get_meta_data($fp);
+
+ // Is it timed out? 15 seconds is a really patient...
+ if (($info['timed_out'] == true) || (microtime(true) - $start) > 15) {
+ // Timeout
+ logDebugMessage(__FUNCTION__, __LINE__, 'Timed out to get data from host ' . $host);
+
+ // Abort here
+ break;
+ } // END - if
+
+ // Get line from stream
+ $line = fgets($fp, 128);
+
+ // Ignore empty lines because of non-blocking mode
+ if (empty($line)) {
+ // uslepp a little to avoid 100% CPU load
+ usleep(10);
+
+ // Skip this
+ continue;
+ } // END - if
+
+ // Add it to response
+ $response[] = trim($line);
} // END - while
// Close socket
fclose($fp);
+ // Time request if debug-mode is enabled
+ if (isDebugModeEnabled()) {
+ // Add debug message...
+ logDebugMessage(__FUNCTION__, __LINE__, 'Request took ' . (microtime(true) - $start) . ' seconds.');
+ } // END - if
+
// Skip first empty lines
$resp = $response;
foreach ($resp as $idx => $line) {
//* DEBUG: */ print('<strong>Response:</strong><pre>'.print_r($response, true).'</pre>');
- // Proxy agent found?
- if ((substr(strtolower($response[0]), 0, 11) == 'proxy-agent') && ($useProxy === true)) {
+ // Proxy agent found or something went wrong?
+ if (!isset($response[0])) {
+ // No response, maybe timeout
+ $response = array('', '', '');
+ } elseif ((substr(strtolower($response[0]), 0, 11) == 'proxy-agent') && ($useProxy === true)) {
// Proxy header detected, so remove two lines
array_shift($response);
array_shift($response);
);
// Load the template
- loadTemplate('show_timings', false, $content);
+ $GLOBALS['page_footer'] .= loadTemplate('show_timings', true, $content);
}
// Check wether a boolean constant is set
$FQFN = sprintf("%s/.revision", getConfig('CACHE_PATH'));
// Check if 'check_revision_data' is setted (switch for manually rewrite the .revision-File)
- if ((isGetRequestElementSet('check_revision_data')) && (getRequestElement('check_revision_data') == 'yes')) {
+ if ((isGetRequestParameterSet('check_revision_data')) && (getRequestParameter('check_revision_data') == 'yes')) {
// Forced rebuild of .revision file
$new = true;
} else {
case getCode('COOKIES_DISABLED') : $message = getMessage('LOGIN_COOKIES_DISABLED'); break;
case getCode('BEG_SAME_AS_OWN') : $message = getMessage('BEG_SAME_UID_AS_OWN'); break;
case getCode('LOGIN_FAILED') : $message = getMessage('LOGIN_FAILED_GENERAL'); break;
- case getCode('MODULE_MEM_ONLY') : $message = getMaskedMessage('MODULE_MEM_ONLY', getRequestElement('mod')); break;
+ case getCode('MODULE_MEM_ONLY') : $message = getMaskedMessage('MODULE_MEM_ONLY', getRequestParameter('mod')); break;
case getCode('OVERLENGTH') : $message = getMessage('MEMBER_TEXT_OVERLENGTH'); break;
case getCode('URL_FOUND') : $message = getMessage('MEMBER_TEXT_CONTAINS_URL'); break;
case getCode('SUBJ_URL') : $message = getMessage('MEMBER_SUBJ_CONTAINS_URL'); break;
- case getCode('BLIST_URL') : $message = "{--MEMBER_URL_BLACK_LISTED--}<br />\n{--MEMBER_BLIST_TIME--}: ".generateDateTime(getRequestElement('blist'), 0); break;
+ case getCode('BLIST_URL') : $message = "{--MEMBER_URL_BLACK_LISTED--}<br />\n{--MEMBER_BLIST_TIME--}: ".generateDateTime(getRequestParameter('blist'), 0); break;
case getCode('NO_RECS_LEFT') : $message = getMessage('MEMBER_SELECTED_MORE_RECS'); break;
case getCode('INVALID_TAGS') : $message = getMessage('MEMBER_HTML_INVALID_TAGS'); break;
case getCode('MORE_POINTS') : $message = getMessage('MEMBER_MORE_POINTS_NEEDED'); break;
break;
case getCode('EXTENSION_PROBLEM'):
- if (isGetRequestElementSet('ext')) {
- $message = generateExtensionInactiveNotInstalledMessage(getRequestElement('ext'));
+ if (isGetRequestParameterSet('ext')) {
+ $message = generateExtensionInactiveNotInstalledMessage(getRequestParameter('ext'));
} else {
$message = getMessage('EXTENSION_PROBLEM_UNSET_EXT');
}
case getCode('URL_TLOCK'):
// @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ?
$result = SQL_QUERY_ESC("SELECT `timestamp` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1",
- array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
+ array(bigintval(getRequestParameter('id'))), __FILE__, __LINE__);
// Load timestamp from last order
list($timestamp) = SQL_FETCHROW($result);
} // END - if
// Write to temp file
- fputs($fp_tmp, $line);
+ fwrite($fp_tmp, $line);
} // END - while
// Close temp file
// Check if refid is set
if ((isset($GLOBALS['refid'])) && ($GLOBALS['refid'] > 0)) {
// This is fine...
- } elseif ((isGetRequestElementSet('user')) && (basename($_SERVER['PHP_SELF']) == 'click.php')) {
+ } elseif ((isGetRequestParameterSet('user')) && (basename($_SERVER['PHP_SELF']) == 'click.php')) {
// The variable user comes from the click-counter script click.php and we only accept this here
- $GLOBALS['refid'] = bigintval(getRequestElement('user'));
- } elseif (isPostRequestElementSet('refid')) {
+ $GLOBALS['refid'] = bigintval(getRequestParameter('user'));
+ } elseif (isPostRequestParameterSet('refid')) {
// Get referal id from variable refid (so I hope this makes my script more compatible to other scripts)
- $GLOBALS['refid'] = secureString(postRequestElement('refid'));
- } elseif (isGetRequestElementSet('refid')) {
+ $GLOBALS['refid'] = secureString(postRequestParameter('refid'));
+ } elseif (isGetRequestParameterSet('refid')) {
// Get referal id from variable refid (so I hope this makes my script more compatible to other scripts)
- $GLOBALS['refid'] = secureString(getRequestElement('refid'));
- } elseif (isGetRequestElementSet('ref')) {
+ $GLOBALS['refid'] = secureString(getRequestParameter('refid'));
+ } elseif (isGetRequestParameterSet('ref')) {
// Set refid=ref (the referal link uses such variable)
- $GLOBALS['refid'] = secureString(getRequestElement('ref'));
+ $GLOBALS['refid'] = secureString(getRequestParameter('ref'));
} elseif ((isSessionVariableSet('refid')) && (getSession('refid') != 0)) {
// Set session refid als global
$GLOBALS['refid'] = bigintval(getSession('refid'));
// Handle message codes from URL
function handleCodeMessage () {
- if (isGetRequestElementSet('code')) {
+ if (isGetRequestParameterSet('code')) {
// Default extension is 'unknown'
$ext = 'unknown';
// Is extension given?
- if (isGetRequestElementSet('ext')) $ext = getRequestElement('ext');
+ if (isGetRequestParameterSet('ext')) $ext = getRequestParameter('ext');
// Convert the 'code' parameter from URL to a human-readable message
- $message = getMessageFromErrorCode(getRequestElement('code'));
+ $message = getMessageFromErrorCode(getRequestParameter('code'));
// Load message template
loadTemplate('message', false, $message);
$hash = generatePassString(getUserData('password'));
// Does the hash match or should we change it?
- if (($hash == getSession('u_hash')) || (postRequestElement('pass1') == postRequestElement('pass2'))) {
+ if (($hash == getSession('u_hash')) || (postRequestParameter('pass1') == postRequestParameter('pass2'))) {
// Load the data
$content = getUserDataArray();
switch ($mode) {
case 'normal': break; // Do not add any special lines
case 'email': // Email was changed!
- $content['message'] = getMessage('MEMBER_CHANGED_EMAIL').": ".postRequestElement('old_email')."\n";
+ $content['message'] = getMessage('MEMBER_CHANGED_EMAIL').": ".postRequestParameter('old_email')."\n";
break;
case 'pass': // Password was changed
if (isExtensionActive('country')) {
// Replace code with description
- $content['country'] = generateCountryInfo(postRequestElement('country_code'));
+ $content['country'] = generateCountryInfo(postRequestParameter('country_code'));
} // END - if
// Merge content with data from POST
return ((strpos($userAgent, 'spider') !== false) || (strpos($userAgent, 'slurp') !== false) || (strpos($userAgent, 'bot') !== false));
}
+// Prepares the header for HTML output
+function loadHtmlHeader () {
+ // Determine the page title
+ $content['header_title'] = determinePageTitle();
+
+ // Output page header code
+ $GLOBALS['page_header'] = loadTemplate('page_header', true, $content);
+
+ // Include meta data in 'guest' module
+ if (getModule() == 'index') {
+ // Load meta data template
+ $GLOBALS['page_header'] .= loadTemplate('metadata', true);
+
+ // Add meta description to header
+ if ((isInstalled()) && (isAdminRegistered()) && (SQL_IS_LINK_UP())) {
+ // Add meta description not in admin and login module and when the script is installed
+ generateMetaDescriptionCode();
+ } // END - if
+ } // END - if
+
+ // Include more header data here
+ $GLOBALS['page_header'] .= loadTemplate('header', true);
+
+ // Include stylesheet
+ loadIncludeOnce('inc/stylesheet.php');
+
+ // Closing HEAD tag
+ $GLOBALS['page_header'] .= '</head>';
+}
+
+// Adds page header and footer to output array element
+function addPageHeaderFooter () {
+ // Add them all together. This is maybe to simple
+ $GLOBALS['output'] = $GLOBALS['page_header'] . $GLOBALS['output'] . $GLOBALS['page_footer'];
+}
+
+// Generates meta description for current module and 'what' value
+function generateMetaDescriptionCode () {
+ // Only include from guest area
+ if (getModule() == 'index') {
+ // Construct dynamic description
+ $DESCR = '{?MAIN_TITLE?} '.trim(getConfig('title_middle')) . ' ' . getTitleFromMenu('guest', getWhat());
+
+ // Output it directly
+ $GLOBALS['page_header'] .= '<meta name="description" content="' . $DESCR . '" />';
+ } // END - if
+
+ // Remove depth
+ unset($GLOBALS['ref_level']);
+}
+
//////////////////////////////////////////////////
// AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS //
//////////////////////////////////////////////////