// "Runs" the given filters, data is optional and can be any type of data
function runFilterChain ($filterName, $data = null) {
// Is that filter chain there?
- if (!isset($GLOBALS['cache_array']['filter']['chains'][$filterName])) {
+ if ((!isset($GLOBALS['cache_array']['filter']['chains'][$filterName])) && (isDebugModeEnabled())) {
// We should find all these non-existing filter chains
//* Only for tracking: */ if ($filterName != 'sql_admin_extra_data') {
//* Only for tracking: */ debug_report_bug('Filter chain <strong>' . $filterName . '</strong> not found!');
// 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');
//* 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
//* 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);
} // END - if
// Write to temp file
- fputs($fp_tmp, $line);
+ fwrite($fp_tmp, $line);
} // END - while
// Close temp file
'EXTENSION_PROBLEM_EXT_INACTIVE' => "Kann nicht fortfahren! Fehler: Erweiterung <span class=\"data\">%s</span> deaktiviert.",
'ADMIN_EXTENSION_PROBLEM_EXT_INACTIVE' => "Die Erweiterung <span class=\"data\">%s</span> ist derzeit deaktiviert. <a href=\"{%url=modules.php?module=admin&what=extensions%}\">Hier</a> können Sie diese aktivieren.",
'EXTENSION_PROBLEM_EXT_NOT_INSTALLED' => "Kann nicht fortfahren! Fehler: Erweiterung <span class=\"data\">%s</span> nicht installiert.",
- 'ADMIN_EXTENSION_PROBLEM_EXT_NOT_INSTALLED' => "Die Erweiterung <span class=\"data\">%s</span> ist derzeit nicht installiert. <a href=\"{%url=modules.php?module=admin&what=extensions%}\">Hier</a> können Sie diese aktivieren.",
+ 'ADMIN_EXTENSION_PROBLEM_EXT_NOT_INSTALLED' => "Die Erweiterung <span class=\"data\">%s</span> ist derzeit nicht installiert. <a href=\"{%%url=modules.php?module=admin&what=extensions%%}\">Hier</a> können Sie diese aktivieren.",
'EXTENSION_PROBLEM_NOT_INSTALLED' => "Erweiterung <span class=\"data\">%s</span> nicht installiert.",
'EXTENSION_PROBLEM_UNSET_EXT' => "Skriptfehler: Parameter <strong>ext</strong> nicht gesetzt.",
'EXTENSION_WARNING_EXT_INACTIVE' => "Die Erweiterung <span class=\"data\">%s</span> ist nicht aktiv. Dies kann zu Störungen führen.<br />\nBitte aktivieren Sie diese unter <em>Verschiedenes->Erweiterungen</em>.",
// Some security stuff...
if (!defined('__SECURITY')) {
die();
+} // END - if
+
+// Queries the given Yoo!Media API 2.0 script
+function YOOMEDIA_QUERY_API ($script, $countQuery = true) {
+ // Init response array
+ $response = array();
+
+ // Enougth queries left?
+ if ((getConfig('yoomedia_requests_remain') > 0) || ($countQuery === false)) {
+ // Prepare the low-level request
+ $requestString = sprintf("http://www.yoomedia.de/interface_2.0/%s?id=%s&sid=%s&pw=%s&reload=%s&ma=%s&uebrig=%s&verguetung=%s&erotik=%s",
+ $script,
+ getConfig('yoomedia_id'),
+ getConfig('yoomedia_sid'),
+ getConfig('yoomedia_passwd'),
+ getConfig('yoomedia_tm_max_reload'),
+ getConfig('yoomedia_tm_min_wait'),
+ getConfig('yoomedia_tm_clicks_remain'),
+ getConfig('yoomedia_tm_min_pay'),
+ getConfig('yoomedia_erotic_allowed')
+ );
+
+ // Run the query
+ $response = sendGetRequest($requestString);
+
+ // Convert from ISO to UTF-8 only if count is > 3 because <= 3 means timeout
+ if (count($response) > 3) {
+ // Convert all lines to UTF-8
+ foreach ($response as $k => $v) {
+ // Convert the line
+ $response[$k] = iconv('windows-1252', 'UTF-8//TRANSLIT', $v);
+ /*
+ // iconv()-less ISO-8859-1 -> UTF-8
+ $response[$k] = preg_replace(
+ "/([\x80-\xFF])/e",
+ "chr(0xC0|ord('\\1')>>6).chr(0x80|ord('\\1')&0x3F)",
+ $v
+ );
+ */
+ } // END - foreach
+ } // END - if
+
+ // Shall we count the query as used?
+ if ($countQuery === true) {
+ // Then update the config!
+ updateConfiguration('yoomedia_requests_remain', 1, '-');
+ } // END - if
+ } // END - if
+
+ // Return the data
+ return $response;
}
// Test if the extension settings did work
return ($errorCode == '0');
}
-// Queries the given Yoo!Media API 2.0 script
-function YOOMEDIA_QUERY_API ($script, $countQuery = true) {
- // Init response array
- $response = array();
-
- // Enougth queries left?
- if ((getConfig('yoomedia_requests_remain') > 0) || ($countQuery === false)) {
- // Prepare the low-level request
- $requestString = sprintf("http://www.yoomedia.de/interface_2.0/%s?id=%s&sid=%s&pw=%s&reload=%s&ma=%s&uebrig=%s&verguetung=%s&erotik=%s",
- $script,
- getConfig('yoomedia_id'),
- getConfig('yoomedia_sid'),
- getConfig('yoomedia_passwd'),
- getConfig('yoomedia_tm_max_reload'),
- getConfig('yoomedia_tm_min_wait'),
- getConfig('yoomedia_tm_clicks_remain'),
- getConfig('yoomedia_tm_min_pay'),
- getConfig('yoomedia_erotic_allowed')
- );
-
- // Run the query
- $response = sendGetRequest($requestString);
-
- // Convert from ISO to UTF-8
- foreach ($response as $k => $v) {
- $response[$k] = iconv('windows-1252', 'UTF-8//TRANSLIT', $v);
- /*
- // iconv()-less ISO-8859-1 -> UTF-8
- $response[$k] = preg_replace(
- "/([\x80-\xFF])/e",
- "chr(0xC0|ord('\\1')>>6).chr(0x80|ord('\\1')&0x3F)",
- $v
- );
- */
- } // END - if
-
- // Shall we count the query as used?
- if ($countQuery === true) {
- // Then update the config!
- updateConfiguration('yoomedia_requests_remain', 1, '-');
- } // END - if
- } // END - if
-
- // Return the data
- return $response;
-}
-
// "Getter" for a parsed result for all text mails. This means an array without
// the header lines will be returned
function YOOMEDIA_GET_PARSED_RESULT_TEXTMAILS () {