View Single Post
  #5  
Old 06-19-2008, 06:26 AM
 
Pilnik Pilnik is offline
 

Member
  
Join Date: Jul 2007
Posts: 18
 

Default Re: Problem with installing link exchange script

I hope it's not too long:


$now = time();
$t24h = 60 * 60 * 24;
$lfname = "linkor.txt";
$refferer = $_SERVER['HTTP_HOST'];
$VER = "1.7.5 STATIC";
$p_linkor = '';

while(!is_file($p_linkor . 'linkor.txt') && $catd < 20) {
$p_linkor .= '../';
$catd++;
}

$lfname = $p_linkor . $lfname;

if(@file_exists($lfname)) {
if((filemtime($lfname) + $t24h < $now) || (filesize($lfname) == 0)) {
if(is_writable($lfname))
{
$newlinks = getpage ("http://get.linkor.pl/download_links.php?linkor=".
urlencode($lfname).
"&VER=".urlencode($VER).
"&referer=".urlencode($refferer), $refferer) ;

if ($newlinks) {

} else {
$newlinks = '';
for ($i = 0; $i < 10; $i++) {
$newlinks .= '<a id="L'. $i .'" href="#" title="#'. $i .'" >Linkor.pl</a> 1130882242' . "\n";
}
}

$lp = @fopen($lfname,'r+');
@flock($lp, LOCK_EX|LOCK_NB);
@fwrite($lp, $newlinks);
@ftruncate($lp, @ftell($lp));
@fclose($lp);
}
else
{
// Blad zapisu do pliku
$linkor_links[0][0] = "WE";
$linkor_links[1][0] = "WE";
$linkor_links[2][0] = "WE";
$linkor_links[3][0] = "WE";
$linkor_links[4][0] = "WE";
}
}
else
{

}

}
else
{
// Nie odnaleziono pliku linkor.txt
$linkor_links[0][0] = "FnF";
$linkor_links[1][0] = "FnF";
$linkor_links[2][0] = "FnF";
$linkor_links[3][0] = "FnF";
$linkor_links[4][0] = "FnF";
}

if (is_file($lfname)) {
if (is_readable($lfname)) {
$alllinks = file($lfname);
$i = 0;
$linkor_links = array();

while( $i < 3) {
$numlinks = count($alllinks)-1;
//$rand = mt_rand(0, ($numlinks)) ;
$rand = lnk_Rand($numlinks);
$newlink = explode("\t", trim($alllinks[$rand]) );

if ($utf8 == 1) {
$newlink = ISO88592_2_UTF8($newlink);
}

if ($noweokno == 1) {
$newlink = str_replace(' >', " target=\"_blank\" >", $newlink);
}

if ($css != "") {
$newlink = str_replace(' >', " class=\"$css\" >", $newlink);
}

$linkor_links[] = $newlink;

unset($alllinks[$rand]);
foreach ($alllinks as $onelink) {
$newalllinks[] = $onelink;
}

$alllinks = $newalllinks;
$i++;
}

$i = 0;

while( $i < 2) {
$numlinks = count($alllinks)-1;
$rand = mt_rand(0, ($numlinks)) ;
$newlink = explode("\t", trim($alllinks[$rand]) );

if ($utf8 == 1) {
$newlink = ISO88592_2_UTF8($newlink);
}

if ($noweokno == 1) {
$newlink = str_replace(' >', " target=\"_blank\" >", $newlink);
}

if ($css != "") {
$newlink = str_replace(' >', " class=\"$css\" >", $newlink);
}

$linkor_links[] = $newlink;

unset($alllinks[$rand]);
foreach ($alllinks as $onelink) {
$newalllinks[] = $onelink;
}

$alllinks = $newalllinks;
$i++;
}
}
}

function getpage ($pageSpec, $refferer)
{
$pageSpec = urldecode($pageSpec);

if (function_exists('curl_init')) {
if (!$agent) $agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";

$ch = curl_init($pageSpec);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_REFERER, $refferer);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
$tmp = curl_exec ($ch);
curl_close ($ch);
unset($ch);
}
else
{
$tmp = @file_get_contents($pageSpec);
}

return $tmp;
}

if (!function_exists('file_get_contents')) {
function file_get_contents($url) {
$handle = fopen($url, 'r');
if (!$handle)
{
return 0;
}
$string = fread($handle, 4096000);
fclose($handle);
return $string;
}
}

function linkor_wyswietl_poz($separator=' ')
{
global $linkor_links;

echo $linkor_links[0][0] . $separator .
$linkor_links[1][0] . $separator .
$linkor_links[2][0] . $separator .
$linkor_links[3][0] . $separator .
$linkor_links[4][0];
}

function linkor_wyswietl_pion()
{
global $linkor_links;

echo $linkor_links[0][0]."<br>".
$linkor_links[1][0]."<br>".
$linkor_links[2][0]."<br>".
$linkor_links[3][0]."<br>".
$linkor_links[4][0];
}

function iso2utf()
{
$tabela = Array(
"\xb1" => "\xc4\x85", "\xa1" => "\xc4\x84", "\xe6" => "\xc4\x87", "\xc6" => "\xc4\x86",
"\xea" => "\xc4\x99", "\xca" => "\xc4\x98", "\xb3" => "\xc5\x82", "\xa3" => "\xc5\x81",
"\xf3" => "\xc3\xb3", "\xd3" => "\xc3\x93", "\xb6" => "\xc5\x9b", "\xa6" => "\xc5\x9a",
"\xbc" => "\xc5\xbc", "\xac" => "\xc5\xbb", "\xbf" => "\xc5\xba", "\xaf" => "\xc5\xb9",
"\xf1" => "\xc5\x84", "\xd1" => "\xc5\x83");

return $tabela;
}

function ISO88592_2_UTF8($tekst) {
return strtr($tekst, iso2utf());
}

function lnk_Rand($numlinks)
{
$lnk_UserUrl = $_SERVER['REQUEST_URI'];
if ($lnk_UserUrl == "")
{
$lnk_UserUrl = $_SERVER['SCRIPT_NAME'];
if (!$_SERVER['QUERY_STRING'] == "")
{
$lnk_UserUrl = $lnk_UserUrl . "?" . $_SERVER['QUERY_STRING'];
}
}

$lnk_Seed = hexdec(substr(md5($lnk_UserUrl), -) & 0x7fffffff;
srand($lnk_Seed);
$lnk_RandStart = rand(0, $numlinks);

return $lnk_RandStart;
}


?>
__________________
X-Cart 4.1.8

africanartstall.com - an online store for african art
Reply With Quote