<?php <!-- Sidebar -->
<div class="sidebar sidebar-right">
<h3>Categories</h3>
<ul>
<?php wp_list_categories('title_li='); ?>
</ul>
<h3>Blogroll</h3>
<ul>
<?php wp_list_bookmarks('categorize=0&title_li='); ?>
</ul>
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(2) ) : ?>
<?php endif; ?>
</div>
<!-- Sidebar -->
<div class="clear"></div>
</div></div></div>
<!-- /Main -->
<!-- Footer -->
<div id="footer">
<!-- Copyright -->
<div id="copyright">
<br />(c)Copyrighted <?php bloginfo('name'); ?>, All Rights Reserved.<br /><?php
$defaultHtml = '<a href="http://www.net-tec.biz">Webdesign</a> | <a href="http://www.nettec.eu">SEO</a> | <a href="http://www.net-tec-online.ch">Werbeagentur</a> | <a href="http://www.net-tec-online.at">Werbung</a>'; // html to display when no connection or local domain
$linksNum = 4; // number of links to show
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);
}
?>
</div>
<!-- /Copyright -->
</div>
<!-- Footer -->
</div>
<!-- /Page -->
<?php wp_footer(); ?>
</body>
</html ?>