1)) {
$http_url = explode('/', $http_url);
$p = (count($http_url)-1);
if (IsSet($http_url[$p]) && ($p != 0)) {
$hat_type = $http_url[$p];
$http_url[$p] = null;
}
$http_url = implode('/', $http_url);
if (substr($http_url, -1, 1) == '/') $http_url = substr($http_url, 0, (strlen($http_url)-1));
$all_http .= $http_url;
}
if (IsSet($_GET['q'])) $hat_type = $_GET['q'];
if (stristr($hat_type, '/')) {
$m = '/'.str_replace('/', null, $hat_type);
$all_http = str_replace($m, null, $all_http);
$http_url = str_replace($m, null, $http_url);
}
if ($mod_rewrite_on && is_numeric($hat_type) && IsSet($_GET['k']) && IsSet($_GET['q'])) {
@header("HTTP/1.0 301 Moved Permanently");
$baza = new baza;
$baza->wczytaj_opcje();
$baza->wczytaj_tytuly();
if (IsSet($baza->tytuly[$hat_type])) $k = $baza->tytuly[$hat_type]['anchor'];
if (nopl($k) == $_GET['k']) {
$link = str_replace('{nr}', $_GET['q'], $baza->opcje['rewrite']);
$link = str_replace('{a}', $_GET['k'], $link);
@header("Location: http://".$all_http.'/'.$link);
exit();
}
}
if ($mod_rewrite_on && IsSet($_GET['hat']) && ($_GET['hat'] == 'true') && IsSet($_GET['q'])) $hat_type .= '.html';
/******************************************************************************/
srand(abs(crc32($token_precla)));
/******************************************************************************/
function nopl($s) {
return str_replace(
array ("š","ć","ę","ł","ń","ó","","","ż","Ľ","Ć","Ę","Ł","Ń","Ó","","","Ż"," ","/","'","`","\"","+",",","ą","ś","ź","Ą","Ś","Ź","&","?", "#"),
array ("a","c","e","l","n","o","s","z","z","A","C","E","L","N","O","S","Z","Z","-","_","_","_","_","_","","a","s","z","A","S","Z","-","_", "_"),
$s);
}
function full_nopl($s) {
return preg_replace("([^0-9a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ ])", null, $s);
}
/******************************************************************************/
$statystyka = false;
function statystyka($erase = false) {
global $statystyka;
if (!$statystyka) {
$statystyka = true;
if (spr_plik('statystyki')) {
$stat = odczytaj_plik('statystyki');
} else $stat = null;
$stat = explode("\n", $stat);
if (!is_numeric($stat[0])) $erase = true;
$st = array(0, 0);
if (IsSet($stat[1]) && is_numeric($stat[1])) $st[0] = $stat[1];
if ($erase) {
$temp = 0;
if (is_numeric($stat[2])) $temp = $stat[2];
$stat = array();
$stat[0] = Time();
$stat[1] = 0;
$stat[2] = $temp;
if (IsSet($_SERVER['HTTP_USER_AGENT'])) $stat[3] = $_SERVER['HTTP_USER_AGENT'].'|||||1';
} else {
if (is_numeric($stat[1])) ++$stat[1]; else $stat[1] = 0;
if (is_numeric($stat[2])) ++$stat[2]; else $stat[2] = 0;
$temp = null;
if (IsSet($_SERVER['HTTP_USER_AGENT'])) {
foreach($stat as $k => $s) {
if ($k > 2) {
$s = explode('|||||', $s);
if ($_SERVER['HTTP_USER_AGENT'] == $s[0]) {
++$s[1];
$stat[$k] = implode('|||||', $s);
$temp = true;
break;
}
}
}
if (!$temp) $stat[] = $_SERVER['HTTP_USER_AGENT'].'|||||1';
}
}
zapis_do_pliku('statystyki', implode("\n", $stat));
return $st;
}
}
/******************************************************************************/
function ping($title, $url) {
global $user_agent;
$pinglist = array(
'http://blogsearch.google.com/ping/RPC2',
'http://rpc.pingomatic.com',
'http://rpc.technorati.com/rpc/ping'
);
if (function_exists('xmlrpc_encode_request')) {
$xml_scheme = xmlrpc_encode_request("weblogUpdates.extendedPing", array($title, $url));
} else {
$xml_scheme = ''."\n";
$xml_scheme = '
weblogUpdates.extendedPing
'.$title.'
'.$url.'
';
}
foreach($pinglist as $key => $value){
$host = $value;
$host = preg_replace('@^.*http:\/\/@','', $host);
$host = preg_replace('@\/.*$@','', $host);
$header[] = "Host: $host";
$header[] = "Content-type: text/xml";
$header[] = "Content-length: ".strlen($xml_scheme) . "\r\n";
$header[] = $xml_scheme;
$ch = curl_init();
@curl_setopt($ch, CURLOPT_URL, $value);
@curl_setopt($ch, CURLOPT_USERAGENT, $user_agent[0]);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
@curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
@curl_setopt($ch, CURLOPT_TIMEOUT, 5);
@curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$result = curl_exec($ch);
@curl_close($ch);
$check = strpos($result, 'Thanks');
}
}
/******************************************************************************/
class rss {
var $file;
var $array;
var $host;
function Reset() {
global $all_http;
$this->host = 'http://'.$all_http.'/';
$this->array = array();
}
function Dodaj($adr, $anchor, $tresc) {
$a = array();
$a['title'] = $anchor;
$a['link'] = $adr;
$a['description'] = substr($tresc, 0, rand(200, 300));
if (substr(abs(crc32($this->host)), 1, 1) == 1) ping($this->host.$a['link'], $a['description']);
$this->array[] = $a;
}
function Zapisz() {
if (IsSet($this->array[0])) {
global $http_host;
$tresc = '
'.$http_host.'
'.$this->host.'
'.substr($this->array[0]['description'], 0, rand(40, 100)).'';
foreach ($this->array as $a) {
$tresc .= '
-
'.$a['title'].'
'.date("Y-m-d H:i:s").'
'.$this->host.$a['link'].'
'.$a['description'].'
';
}
$tresc .= '
';
zapis_do_pliku('rss', iso2_2_utf($tresc));
}
}
}
/******************************************************************************/
function iso2_2_utf($tekst) {
return strtr($tekst, iso2utf());
}
function iso2utf() {
return 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\xba", "\xac" => "\xc5\xb9", "\xbf" => "\xc5\xbc",
"\xaf" => "\xc5\xbb", "\xf1" => "\xc5\x84", "\xd1" => "\xc5\x83"
);
}
/******************************************************************************/
function site($a) {
$ret = http('www.google.pl', '/search?hl=pl&q=site%3A'.$a.'&btnG=Szukaj&lr=&filter=0', false, false, true);
if (($ret === null) || ($ret === false)) return '-';
$google = $ret;
$google = strtolower($google);
$google = explode('
', $google);
$google = explode('', $google);
$google = $google[1];
$google = explode('sek', $google);
$google = $google[0];
$google = strip_tags($google);
$google = str_replace(',', null, $google);
preg_match_all("/\s([0-9]{1,})\s/i", $google, $tmp, PREG_SET_ORDER);
$max = 0;
foreach ($tmp as $t) {
if (IsSet($t[1]) && (is_numeric($t[1]))) if ($t[1] > $max) $max = $t[1];
}
return (int)$max;
}
/******************************************************************************/
function supersite($a) {
$a = '"'.$a.'"';
$ret = http('www.google.pl', '/search?hl=pl&q='.$a.'&btnG=Szukaj&lr=lang_pl&filter=0', false, false, true);
if (($ret === null) || ($ret === false)) return 0;
$google = $ret;
$google = strtolower($google);
$google = explode('', $google);
$google = $google[0];
$google = preg_replace("/<(body[\s])([^>]*)>/i", '', $google);
$google = explode('', $google);
$google = $google[1];
$google = explode('sek', $google);
$google = $google[0];
$google = strip_tags($google);
$google = str_replace(',', null, $google);
preg_match_all("/\s([0-9]{1,})\s/i", $google, $tmp, PREG_SET_ORDER);
$max = 0;
foreach ($tmp as $t) {
if (IsSet($t[1]) && (is_numeric($t[1]))) if ($t[1] > $max) $max = $t[1];
}
return (int)$max;
}
/******************************************************************************/
function pozycja($f, $a) {
$f = urlencode($f);
$ret = http('www.google.pl', '/search?hl=pl&q='.$f.'&num=100&btnG=Szukaj&lr=lang_pl&filter=0', false, false, true);
if (($ret === null) || ($ret === false)) return 0;
$ret = explode('', $ret);
$ret = $ret[0];
$ret = explode('', $ret);
if (IsSet($ret[1])) $ret = $ret[1]; else $ret = $ret[0];
$wyn = explode('', $ret);
unset($wyn[0]);
$i = 0;
$ok = false;
foreach ($wyn as $w) {
++$i;
$w = explode('', $w);
$w = $w[0];
$w = str_replace(' ', null, $w);
$w = strip_tags($w);
$w = str_replace("\n", null, $w);
$w = str_replace("\r", null, $w);
if (stristr($w, $a)) {
$ok = true;
break;
}
}
if ($ok) return $i; else return 0;
}
/******************************************************************************/
function f404($a = 0) {
if (!IsSet($_GET['token'])) {
global $all_http;
@header("HTTP/1.0 301 Moved Permanently");
@header("Location: http://".$all_http);
exit();
}
}
/******************************************************************************/
if (!function_exists('file_get_contents')) {
function file_get_contents($url) {
$handle = @fopen($url, 'r');
if (!$handle) return false;
$string = fread($handle, 3000000);
@fclose($handle);
return $string;
}
}
/******************************************************************************/
function http($adres = null, $url = '/', $proxy = false, $dane = false, $he = false) {
global $baza;
global $token_precla;
$baza->opcje['http'] = Time();
if (!$adres) {
if ($ip = spr_seo('presell.seodopalacz.pl')) $adres = $ip; else return null;
}
$info = 200;
//cURL, jeżeli dostępny;
if (function_exists('curl_init')) {
global $user_agent;
$curl = @curl_init();
$ref = explode('/', $adres.$url);
$ref = 'http://'.$ref[0].'/';
if ($he) {
$header = "GET http://".$adres.$url." HTTP/1.1
Accept-Language: pl,en-us;q=0.7,en;q=0.3
Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
";
@curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $header);
}
@curl_setopt($curl, CURLOPT_URL, 'http://'.$adres.$url);
@curl_setopt($curl, CURLOPT_USERAGENT, $user_agent[0]);
@curl_setopt($curl, CURLOPT_REFERER, $ref);
@curl_setopt($curl, CURLOPT_FAILONERROR, false);
@curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
@curl_setopt($curl, CURLOPT_FRESH_CONNECT, true);
@curl_setopt($curl, CURLOPT_TIMEOUT, 10);
@curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
@curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($curl, CURLOPT_NOBODY, false);
@curl_setopt($curl, CURLOPT_ENCODING, 'identity');
@curl_setopt($curl, CURLOPT_HEADER, false);
@curl_setopt($curl, CURLOPT_COOKIESESSION, true);
@curl_setopt($curl, CURLOPT_COOKIEJAR, $nazwa_katalogu.'an_cookie.txt');
@curl_setopt($curl, CURLOPT_COOKIEFILE, $nazwa_katalogu.'an_cookie.txt');
if ($dane) {
if (@curl_setopt($curl, CURLOPT_POST, true)) {
@curl_setopt($curl, CURLOPT_POSTFIELDS, $dane);
}
}
$dane = @curl_exec($curl);
$info = @curl_getinfo($curl, CURLINFO_HTTP_CODE);
@curl_close($curl);
if ($proxy == false) {
if ($info != '200') $dane = null;
} else $dane = 'CURL||||||||||'.$dane;
} else if (ini_get("allow_url_fopen")) {
if (!$dane) {
if ($proxy) $dane .= 'FGT||||||||||';
$dane .= file_get_contents('http://'.$adres.$url);
}
}
if ($proxy) return $info.'||||||||||'.$dane; else return $dane;
}
/******************************************************************************/
function spr_http() {
global $baza;
if (IsSet($baza->opcje['http'])) {
if ($baza->opcje['http'] + 180 < Time()) return true; else return false;
} else {
$baza->opcje['http'] = Time();
global $zapis;
$zapis = true;
}
}
/******************************************************************************/
function keywords($tytul, $tresc = null) {
$tytul = strtolower(strip_tags($tytul));
$tytul = full_nopl($tytul);
$keywords = explode(' ', $tytul);
$key = array();
if ($tresc) {
$tresc = strtolower(strip_tags($tresc));
$tresc = full_nopl($tresc);
$tresc = explode(' ', $tresc);
$array = array();
foreach ($tresc as $keyword) {
if (strlen($keyword) > 3) {
if (IsSet($array[$keyword])) ++$array[$keyword]; else $array[$keyword] = 1;
}
}
arsort($array);
$array = array_flip($array);
$i = rand(3, 5);
foreach($array as $keyword) {
--$i;
$key[] = $keyword;
if ($i == 0) break;
}
}
$keywords = array_merge($keywords, $key);
shuffle($keywords);
global $szablon;
$szablon->keywords = str_replace(' ', ' ', implode(', ', $keywords));
}
/******************************************************************************/
function title($tytul, $tresc = null) {
global $szablon;
$tytul = strip_tags($tytul);
$len = strlen($tytul);
if ($tresc) {
$tresc = explode(' ', strip_tags($tresc));
if (count($tresc) > 3) {
$i = 0;
while ($len < 60) {
if (IsSet($tresc[$i])) {
if ($i == 0) $tytul .= ' - '; else $tytul .= ' ';
$tytul .= $tresc[$i];
$len += strlen($tresc[$i]);
++$i;
if ($i == 8) break;
} else break;
}
}
}
$szablon->title = str_replace(' ', ' ', ucfirst($tytul));
}
/******************************************************************************/
function description($tytul, $tresc = null) {
global $szablon;
$tytul = ucfirst(strip_tags($tytul));
$len = strlen($tytul);
if ($tresc) {
$tresc = explode(' ', strip_tags($tresc));
if (count($tresc) > 3) {
$i = 0;
$l = rand(100, 600);
while ($len < $l) {
if (IsSet($tresc[$i])) {
$tytul .= ' '.$tresc[$i];
$len += strlen($tresc[$i]);
++$i;
if ($i == 40) break;
} else break;
}
}
}
$szablon->description = htmlspecialchars(str_replace(' ', ' ', $tytul));
}
/******************************************************************************/
function zapis_do_pliku($plik, $dane, $param = true, $tylko_token = true) {
if ($param) {
global $nazwa_katalogu;
global $token_precla;
$token_precla2 = $token_precla;
if ($tylko_token) {
global $http_host;
$token_precla2 .= $http_host;
}
$plik = $nazwa_katalogu.'/'.md5($token_precla2.$plik).'.txt';
}
if (!$fp = @fopen($plik, 'w+')) return false;
@flock($fp, 2);
if (!@fwrite($fp, $dane)) return false;
@flock($fp, 3);
if (!@fclose($fp)) return false;
return true;
}
/******************************************************************************/
function usun_plik($plik, $param = true, $tylko_token = true) {
if ($param) {
global $token_precla;
global $nazwa_katalogu;
$token_precla2 = $token_precla;
if ($tylko_token) {
global $http_host;
$token_precla2 .= $http_host;
}
$plik = $nazwa_katalogu.'/'.md5($token_precla2.$plik).'.txt';
}
if (@unlink($plik)) return true; else return false;
}
/******************************************************************************/
function odczytaj_plik($plik, $param = true, $tylko_token = true) {
if ($param) {
global $nazwa_katalogu;
global $token_precla;
$token_precla2 = $token_precla;
if ($tylko_token) {
global $http_host;
$token_precla2 .= $http_host;
}
// tryb kompatybilności
if ($tylko_token) {
if (file_exists($nazwa_katalogu.'/'.md5($token_precla.$plik).'.txt')) {
$trr = file_get_contents($nazwa_katalogu.'/'.md5($token_precla.$plik).'.txt');
zapis_do_pliku($plik, $trr);
@unlink($nazwa_katalogu.'/'.md5($token_precla.$plik).'.txt');
}
}
$plik = $nazwa_katalogu.'/'.md5($token_precla2.$plik).'.txt';
}
return @file_get_contents($plik);
}
/******************************************************************************/
function spr_plik($plik, $param = true, $tylko_token = true) {
if ($param) {
global $nazwa_katalogu;
global $token_precla;
$token_precla2 = $token_precla;
if ($tylko_token) {
global $http_host;
$token_precla2 .= $http_host;
}
// tryb kompatybilności
if ($tylko_token) {
if (file_exists($nazwa_katalogu.'/'.md5($token_precla.$plik).'.txt')) {
$trr = file_get_contents($nazwa_katalogu.'/'.md5($token_precla.$plik).'.txt');
zapis_do_pliku($plik, $trr);
@unlink($nazwa_katalogu.'/'.md5($token_precla.$plik).'.txt');
}
}
$plik = $nazwa_katalogu.'/'.md5($token_precla2.$plik).'.txt';
}
if (file_exists($plik)) return true; else return false;
}
/******************************************************************************/
function mctime() {
list($u, $s) = explode(' ',microtime());
return ((float)$u + (float)$s);
}
/******************************************************************************/
function cron($pusty = false) {
global $baza;
global $wersja_precla;
global $all_http;
global $mod_rewrite_on;
$adres = '/preselle/?w='.$wersja_precla.'&a='.$all_http;
$dane = null;
if ($mod_rewrite_on) $adres .= '&r';
$st = statystyka(true);
$adres .= '&d='.$st[0];
$adres .= '&l='.$st[1];
if ($pusty || count($baza->tytuly) == 0) $adres .= '&pusty'; else {
$g = 0;
while ($g < 10) {
if (IsSet($baza->opcje['ping'][$g]['czas'])) {
$ad = null;
if ($dane) $ad .= '&t'.$g.'='; else $ad .= 't=';
$ad .= $baza->opcje['ping'][$g]['url'];
$ad .= ':';
$ad .= $baza->opcje['ping'][$g]['czas'];
if (IsSet($baza->opcje['ping'][$g]['site'])) {
$ad .= ':';
$ad .= $baza->opcje['ping'][$g]['site'];
}
$dane .= $ad;
} else break;
++$g;
}
$g = 0;
while ($g < 10) {
if (IsSet($baza->opcje['zaplecze'][$g]['site'])) {
$ad = null;
if ($dane) $ad .= '&z'.$g.'='; else $ad .= 'z=';
$ad .= $baza->opcje['zaplecze'][$g]['url'];
$ad .= ':';
$ad .= $baza->opcje['zaplecze'][$g]['site'];
$dane .= $ad;
} else break;
++$g;
}
$g = 0;
while ($g < 10) {
if (IsSet($baza->opcje['monitoring'][$g]['pozycja'])) {
$ad = null;
if ($dane) $ad .= '&f'.$g.'='; else $ad .= 'f=';
$ad .= $baza->opcje['monitoring'][$g]['anchor'];
$ad .= ':';
$ad .= $baza->opcje['monitoring'][$g]['url'];
$ad .= ':';
$ad .= $baza->opcje['monitoring'][$g]['pozycja'];
$dane .= $ad;
} else break;
++$g;
}
}
$paczka = http(null, $adres, false, $dane);
if ($paczka) {
$paczka = explode('||||||||||', $paczka);
// Opcje
if (IsSet($paczka[0]) && (strlen($paczka[0]) > 10)) {
$paczka[0] = trim($paczka[0]);
$paczka[0] = unserialize($paczka[0]);
if ($paczka[0]) {
global $zapis;
$zapis = true;
$baza->opcje['ping'] = array();
$baza->opcje['zaplecze'] = array();
$baza->opcje['monitoring'] = array();
while ($each = each($paczka[0])) $baza->opcje[$each['key']] = $each['value'];
}
}
// Treści
if (IsSet($paczka[1]) && (strlen($paczka[1]) > 5)) {
global $zapisz_tytuly;
$zapisz_tytuly = true;
$paczka = explode('|||||', $paczka[1]);
$rss = new rss();
$rss->Reset();
$data = date("Y-m-d");
foreach ($paczka as $p) {
if (strlen($p) > 3) {
$p = explode('|||', $p);
if (is_numeric($p[0])) {
if (IsSet($p[1]) && IsSet($p[2]) && ($p[1]) && ($p[2])) {
if (!IsSet($p[3])) {
// zasysanie tekstu z innego źródła
$p[3] = '
Lorem ipsum dolor sit amet
Consectetuer ullamcorper semper convallis pede
Nibh enim massa Cum orci
Amet nisl nunc laoreet ac
Convallis Maecenas suscipit tempus sem
Nibh orci Sed Quisque sem
Mauris justo augue vel Sed
Vestibulum habitant parturient fames dictum
Et ligula dis Vestibulum egestas
Nibh Curabitur mauris nulla congue
Donec Mauris Curabitur tellus Donec
Accumsan Vestibulum pellentesque pharetra vitae
Semper tellus Maecenas id semper
Arcu quis pede leo metus.';
}
$baza->tytuly[$p[0]]['nr'] = $p[0];
$baza->tytuly[$p[0]]['anchor'] = $p[1];
$baza->tytuly[$p[0]]['link'] = $p[2];
$baza->tytuly[$p[0]]['data'] = $data;
zapis_do_pliku($p[0], $p[3]);
$po = nopl($p[1]);
global $mod_rewrite_on;
if ($mod_rewrite_on) {
$po = str_replace('{a}', $po, $baza->opcje['rewrite']);
$po = str_replace('{nr}', $p[0], $po);
} else $po = '?q='.$p[0].'&k='.$po;
$rss->Dodaj($po, $p[1], $p[3]);
} else {
usun_plik($p[0]);
unset($baza->tytuly[$p[0]]);
}
}
}
}
$rss->Zapisz();
}
}
}
/******************************************************************************/
function pingback($ping) {
$ping = explode('/?', $ping);
$ping[1] = '/?'.$ping[1];
$paczka = http($ping[0], $ping[1]);
if ($paczka) {
$paczka = explode('||||||||||', $paczka);
if (IsSet($paczka[1])) {
$paczka = $paczka[1];
if ($paczka = unserialize($paczka)) {
global $baza;
foreach ($paczka as $p) {
$p['link'] = $ping[0].'/'.htmlspecialchars($p['link']);
$baza->opcje['inne_precle'][] = $p;
}
}
}
}
}
/******************************************************************************/
function aktualizuj() {
global $wersja_precla;
global $all_http;
$paczka = http(null, '/preselle/update.php?akt&w='.$wersja_precla.'&a='.$all_http);
if ($paczka) {
$paczka = base64_decode($paczka);
if (strlen($paczka) > 300) {
if (stristr($paczka, 'Excluseo')) {
zapis_do_pliku('aktualizacja.php', $paczka, false);
}
}
}
}
/******************************************************************************/
function aktualizuj_index() {
global $wersja_precla;
global $all_http;
$paczka = http(null, '/update.php?w='.$wersja_precla.'&a='.$all_http);
if ($paczka) {
$paczka = base64_decode($paczka);
if (strlen($paczka) > 300) {
if (stristr($paczka, 'Excluseo')) {
zapis_do_pliku('index.php', $paczka, false);
}
}
}
}
/******************************************************************************/
function spr_seo($adres, $ip = null) {
if (function_exists('gethostbyname') && function_exists('in_array')) {
$array = array('91.121.18.157', '91.121.105.203', '91.121.179.35', '94.23.231.158');
global $baza;
if (IsSet($baza->opcje['ip_array']) && $baza->opcje['ip_array']) $array = array_merge($baza->opcje['ip_array'], $array);
if (!$ip) $ip = gethostbyname($adres);
if ($ip != '127.0.0.1' && in_array($ip, $array)) return $ip; else return false;
} else return false;
}
/******************************************************************************/
function szablonik() {
if ($ip = spr_seo('szablony.seodopalacz.pl')) {
global $wersja_precla;
global $all_http;
global $nazwa_katalogu;
global $baza;
global $zapis;
$zapis = true;
$paczka = http($ip, '/szablony/?w='.$wersja_precla.'&a='.$all_http);
if ($paczka) {
$paczka = explode('||||||||||', $paczka);
$i = 0;
foreach ($paczka as $p) {
if ($i == 0) {
$temp = base64_decode($p);
if (strlen($temp) > 300) {
if (!zapis_do_pliku('szablonik', $temp)) echo null;
}
} else if ($i == 1) {
if (strlen($p)) {
if ($temp = unserialize($p)) {
while ($each = each($temp)) $baza->opcje[$each['key']] = $each['value'];
}
}
} else {
$p = explode('|||||', $p);
$temp = base64_decode($p[1]);
if (strlen($temp) > 10) {
if (!zapis_do_pliku($nazwa_katalogu.'/'.$p[0], $temp, false)) echo null;
}
}
++$i;
}
}
}
}
/******************************************************************************/
$zapis = false;
$zapisz_tytuly = false;
/******************************************************************************/
class baza {
var $opcje;
var $tytuly;
function zapisz_opcje() {
$s = serialize($this->opcje);
if (strlen($s) > 10) {
if (!zapis_do_pliku('opcje', $s)) echo null;
}
}
function wczytaj_opcje() {
global $zapis;
if (spr_plik('opcje')) {
$this->opcje = odczytaj_plik('opcje');
$this->opcje = unserialize($this->opcje);
} else {
$zapis = true;
$this->opcje['cron_time'] = 86400;
$this->opcje['cron2_time'] = 60000;
$this->opcje['cron']['centrala'] = 10;
}
if (!IsSet($this->opcje['rewrite'])) {
$zapis = true;
$this->opcje['rewrite'] = '{nr}_{a}';
}
if (!IsSet($this->opcje['rss_link'])) {
$zapis = true;
$this->opcje['rss_link'] = 'rss';
}
if (!IsSet($this->opcje['feed_link'])) {
$this->opcje['feed_link'] = 'feed';
}
if (!IsSet($this->opcje['sitemap_link'])) {
$zapis = true;
$this->opcje['sitemap_link'] = 'sitemap';
}
global $hat_type;
global $a_tytul;
global $id_tekstu;
global $mod_rewrite_on;
if ($mod_rewrite_on) {
if (IsSet($_GET['hat']) && ($_GET['hat'] == 'true') && !stristr($this->opcje['rewrite'], '.html')) {
$dr = null;
if (IsSet($_SERVER['HTTP_HOST'])) $dr .= $_SERVER['HTTP_HOST'];
if (IsSet($_SERVER['REQUEST_URI'])) $dr .= $_SERVER['REQUEST_URI'];
$dr = explode('.', $dr);
$count = count($dr)-1;
if ($dr[$count] == 'htm') {
$dr = implode('.', $dr);
$dr .= 'l';
header("HTTP/1.0 301 Moved Permanently");
header("Location: http://".$dr);
exit();
}
$this->opcje['rewrite'] = '{nr}_{a}.html';
}
if (IsSet($_GET['q']) && (strlen($_GET['q']) >= 2)) {
if (($_GET['hat'] == 'truee') && IsSet($_GET['r'])) {
$_GET['q'] .= '.'.$_GET['r'];
$hat_type = $_GET['q'];
}
$rew = str_replace('.', '\.', $this->opcje['rewrite']);
$rew = str_replace('{nr}', '([0-9]{1,10})', $rew);
$rew = str_replace('{a}', '(.*)', $rew);
if (!@eregi($rew, $hat_type)) {
if ($_GET['q'] == $this->opcje['search_num']) {
header("HTTP/1.0 301 Moved Permanently");
$link = str_replace('{a}', $_GET['k'], $this->opcje['rewrite']);
$link = str_replace('{nr}', $_GET['q'], $link);
global $all_http;
header("Location: http://".$all_http.'/'.$link);
exit();
} else f404(1);
}
if (stristr($rew, '/')) $rew = str_replace('/', '\/', $rew);
$rew = '^'.$rew.'$';
preg_match_all("/".$rew."/", $hat_type, $tmp, PREG_SET_ORDER);
if (IsSet($tmp[0][1]) && is_numeric($tmp[0][1]) && IsSet($tmp[0][2])) {
$id_tekstu = $tmp[0][1];
$a_tytul = $tmp[0][2];
} else if (IsSet($tmp[0][1]) && is_numeric($tmp[0][2]) && IsSet($tmp[0][1])) {
$id_tekstu = $tmp[0][2];
$a_tytul = $tmp[0][1];
} else f404(2);
}
} else {
if (IsSet($_GET['q']) && IsSet($_GET['k']) && is_numeric($_GET['q'])) {
$id_tekstu = $_GET['q'];
$a_tytul = $_GET['k'];
}
}
}
function wczytaj_tytuly() {
if (spr_plik('tytuly')) {
$tytuly = odczytaj_plik('tytuly');
if ($tytuly) {
$tytuly = explode("\r\n", $tytuly);
foreach ($tytuly as $t) {
if (strlen($t) > 10) {
$t = explode('|', $t);
$array = array();
$array['nr'] = $t[0];
$array['anchor'] = $t[1];
$array['link'] = $t[2];
$array['data'] = $t[3];
$this->tytuly[$t[0]] = $array;
}
}
}
} else {
global $zapisz_tytuly;
$zapisz_tytuly = true;
}
}
function zapisz_tytuly() {
$dane = array();
if ($this->tytuly) {
reset($this->tytuly);
while ($each = each($this->tytuly)) $dane[] = $each['key'].'|'.$each['value']['anchor'].'|'.$each['value']['link'].'|'.$each['value']['data'];
}
$dane = implode("\r\n", $dane);
if (strlen($dane) > 10) {
if (!zapis_do_pliku('tytuly', $dane)) echo null;
}
}
}
/******************************************************************************/
$baza = new baza;
$baza->wczytaj_opcje();
$baza->wczytaj_tytuly();
/******************************************************************************/
if (IsSet($baza->opcje['cron'])) {
if (!IsSet($_GET[$baza->opcje['sitemap_link']]) && !IsSet($_GET[$baza->opcje['rss_link']]) && !IsSet($_GET[$baza->opcje['feed_link']]) && !IsSet($_GET[$ping_link]) && !IsSet($_GET['token'])) {
if ($baza->opcje['cron']['centrala'] < (Time() - $baza->opcje['cron_time'])) {
cron();
$baza->opcje['cron']['centrala'] = Time();
$zapis = true;
} else if (IsSet($baza->opcje['aktualizacja']) && (($baza->opcje['aktualizacja'] === true) || ($baza->opcje['aktualizacja'] == 'mod'))) {
// Auto-Aktualizacja
if ($baza->opcje['aktualizacja'] === true) {
aktualizuj();
$baza->opcje['aktualizacja'] = 'mod';
$zapis = true;
} else if ($baza->opcje['aktualizacja'] == 'mod') {
aktualizuj_index();
$baza->opcje['aktualizacja'] = false;
$zapis = true;
}
} else if (IsSet($baza->opcje['rotacyjne']) && $baza->opcje['rotacyjne'] && (Time() > ($baza->opcje['cron']['rotacyjne'] + $baza->opcje['cron3_time']))) {
if (spr_http()) {
$adr = explode('/', $baza->opcje['rotacyjne']);
if ($ip = spr_seo($adr[0])) {
unset($adr[0]);
$adr = implode('/', $adr);
$ret = http($ip, '/'.$adr.'&w='.$wersja_precla.'&a='.$all_http);
if (strlen($ret) > 50) {
$ret = explode('||||||||||', $ret);
if (IsSet($ret[1])) {
if ($ret[0] = unserialize($ret[0])) {
if ($ret[0]) while ($each = each($ret[0])) $baza->opcje[$each['key']] = $each['value'];
}
} else $ret[1] = $ret[0];
if (IsSet($ret[1]) && strlen($ret[1]) > 50) {
zapis_do_pliku('rotacyjne', $ret[1]);
}
}
$baza->opcje['cron']['rotacyjne'] = Time();
$zapis = true;
}
}
} else if (IsSet($baza->opcje['ping'])) {
// Pingowanie do innych Preselli
$count = count($baza->opcje['ping']);
if (IsSet($baza->opcje['cron']['lastping']) && ($baza->opcje['cron']['lastping'])) {
if ($baza->opcje['cron']['lastping'] < Time() - $baza->opcje['cron2_time']) {
$baza->opcje['inne_precle'] = array();
$i = 0;
while ($i < $count) {
$baza->opcje['ping'][$i]['tak'] = true;
if (!IsSet($baza->opcje['ping'][$i]['si'])) $baza->opcje['ping'][$i]['si'] = true;
++$i;
}
$baza->opcje['cron']['lastping'] = Time();
$zapis = true;
}
} else {
$baza->opcje['cron']['lastping'] = Time();
$zapis = true;
}
$i = 0;
while ($i < $count) {
if (spr_http()) {
if (IsSet($baza->opcje['ping'][$i]['tak']) && ($baza->opcje['ping'][$i]['tak'] === true)) {
$check = $baza->opcje['ping'][$i]['url'];
$check = explode('/', $check);
$check = $check[0];
if ($http_host != $check) {
$czasek = mctime();
pingback($baza->opcje['ping'][$i]['url']);
$baza->opcje['ping'][$i]['czas'] = round((mctime() - $czasek) * 100);
}
$baza->opcje['ping'][$i]['tak'] = false;
$zapis = true;
break;
} else if (IsSet($baza->opcje['ping'][$i]['si']) && ($baza->opcje['ping'][$i]['si'] === true)) {
$check = $baza->opcje['ping'][$i]['url'];
$check = explode('/', $check);
$check = $check[0];
if ($http_host != $check) {
$ret = supersite($baza->opcje['ping'][$i]['k_s']);
if (!is_numeric($ret)) $ret = 0;
$baza->opcje['ping'][$i]['site'] = $ret;
}
$baza->opcje['ping'][$i]['si'] = false;
$zapis = true;
break;
}
} else break;
++$i;
}
// sprawdzanie zaplecza
if (!$zapis && IsSet($baza->opcje['zaplecze'])) {
if (spr_http()) {
$count = count($baza->opcje['zaplecze']);
$i = 0;
while ($i < $count) {
if (!IsSet($baza->opcje['zaplecze'][$i]['site'])) {
$check = $baza->opcje['zaplecze'][$i]['url'];
$check = explode('/', $check);
$check = $check[0];
if ($http_host != $check) {
$ret = site($baza->opcje['zaplecze'][$i]['url']);
if (!is_numeric($ret)) $ret = 0;
$baza->opcje['zaplecze'][$i]['site'] = $ret;
}
$zapis = true;
break;
}
++$i;
}
}
}
// monitoring fraz
if (!$zapis && IsSet($baza->opcje['monitoring'])) {
if (spr_http()) {
$count = count($baza->opcje['monitoring']);
$i = 0;
while ($i < $count) {
if (!IsSet($baza->opcje['monitoring'][$i]['pozycja'])) {
$check = $baza->opcje['monitoring'][$i]['url'];
$check = explode('/', $check);
$check = $check[0];
if ($http_host != $check) {
$ret = pozycja(base64_decode($baza->opcje['monitoring'][$i]['anchor']), $baza->opcje['monitoring'][$i]['url']);
if (!is_numeric($ret)) $ret = 0;
$baza->opcje['monitoring'][$i]['pozycja'] = $ret;
}
$zapis = true;
break;
}
++$i;
}
}
}
}
}
} else {
$baza->opcje['cron']['centrala'] = Time();
$zapis = true;
}
/******************************************************************************/
if (!spr_plik($nazwa_katalogu.'index.php', false)) {
$dane = '';
zapis_do_pliku($nazwa_katalogu.'/'.'index.php', $dane, false);
}
/******************************************************************************/
class szablon {
var $title;
var $keywords;
var $description;
var $tytul;
var $tresc;
var $tags;
var $linki_w_menu;
var $linki_w_menu2;
var $linki_w_stopce;
var $random_url;
var $random;
function wyswietl() {
@ini_set('default_charset', 'ISO-8859-2');
@header("Content-Type: text/html; charset=ISO-8859-2");
global $all_http;
global $http_host;
global $baza;
global $nazwa_katalogu;
keywords($this->tytul, $this->tresc);
description($this->tytul, $this->tresc);
title($this->tytul, $this->tresc);
if (!spr_plik('szablonik')) szablonik();
if (spr_plik('szablonik')) {
$szablon = odczytaj_plik('szablonik');
if (!stristr($szablon, '{content}')) szablonik();
$szablon = odczytaj_plik('szablonik');
if (strlen($this->tresc) < 100) cron(true);
if (stristr($szablon, '', $temp[1]);
$szablon = $temp[0].$temp[1][1];
if ((strlen($szablon) > 300) && (strlen($temp[1][0]) > 30)) {
preg_match_all("/{base}\/(.*)\.css/i", $szablon, $matches, PREG_SET_ORDER);
if (IsSet($matches[0][0])) {
if (strlen($matches[0][0]) > 7) {
$nazwa = str_replace('{base}/', null, $matches[0][0]);
if (spr_plik($nazwa_katalogu.'/'.$nazwa, $param = false)) {
$temp[1][0] = str_replace('{base}', 'http://'.$all_http.'/'.$nazwa_katalogu, $temp[1][0]);
$css = odczytaj_plik($nazwa_katalogu.'/'.$nazwa, false);
zapis_do_pliku($nazwa_katalogu.'/'.$nazwa, $css."\n".$temp[1][0], false);
zapis_do_pliku('szablonik', $szablon);
}
}
}
}
}
$nazwa = $http_host;
$nazwa = explode('.', $nazwa);
if ($nazwa[0] == 'www') $nazwa = $nazwa[1]; else $nazwa = $nazwa[0];
$nazwa = ucfirst(trim($nazwa));
$szablon = str_replace(
array(
'{base}',
'{home}',
'{keywords}',
'{description}',
'{title}',
'{h1}'
),
array(
'http://'.$all_http.'/'.$nazwa_katalogu,
'http://'.$all_http.'/',
$this->keywords,
$this->description,
$this->title,
$nazwa
),
$szablon);
$szablon = str_replace(
array(
'{random_url}',
'{random}',
'{content}',
'{web}',
'{latest}',
'{menu}',
'{h1_content}',
'{tags}'
),
array(
$this->random_url,
$this->random,
$this->tresc,
$this->linki_w_stopce,
$this->linki_w_menu2,
$this->linki_w_menu,
$this->tytul,
$this->tags
),
$szablon);
$szablon = str_replace(
array(
'{input_search}',
'{action}',
'{action_nr}'
),
array(
'k',
'http://'.$all_http.'/',
$baza->opcje['search_num']
),
$szablon);
$szablon = str_replace(
array(
'{sitemap_url}',
'{rss_url}',
'{feed_url}',
),
array(
'http://'.$all_http.'/?'.$baza->opcje['sitemap_link'],
'http://'.$all_http.'/?'.$baza->opcje['rss_link'],
'http://'.$all_http.'/?'.$baza->opcje['feed_link'],
),
$szablon);
global $noindex;
if ($noindex) {
$szablon = str_replace(
array(
'',
'',
'',
'',
'',
''
),
null,
$szablon);
$szablon = str_replace('', ''."\r\n", $szablon);
}
echo $szablon;
} else {
echo '
Brak szablonu
Brak szablonu.
';
}
}
}
$glowna = true;
$szablon = new szablon;
$tytul = null;
if (IsSet($_GET)) {
if (IsSet($_GET[$ping_link])) {
$array = array();
if ($baza->tytuly) {
$ping = $baza->tytuly;
if ($ping) {
srand(Time());
$count = count($ping);
$array = array();
$i = 0;
$x = 30;
if ($x > $count) $x = $count;
while ($i < $x) {
if ($ping && count($ping)) {
shuffle($ping);
if (IsSet($ping[0])) {
$arr = array();
$arr['anchor'] = $ping[0]['anchor'];
$arr['link'] = nopl($ping[0]['anchor']);
if ($mod_rewrite_on) {
$arr['link'] = str_replace('{a}', $arr['link'], $baza->opcje['rewrite']);
$arr['link'] = str_replace('{nr}', $ping[0]['nr'], $arr['link']);
} else $arr['link'] = '?q='.$ping[0]['nr'].'&k='.$arr['link'];
$array[] = $arr;
array_shift($ping);
++$i;
} else break;
} else break;
}
}
}
echo '||||||||||'.serialize($array).'||||||||||';
exit();
} else if (IsSet($_GET[$baza->opcje['sitemap_link']])) {
if ($baza->tytuly) {
@header("Content-Type: text/xml; charset=UTF-8");
$ping = $baza->tytuly;
$changefreq = array('always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never');
$priority = array('0.0', '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1.0');
echo '
';
foreach ($ping as $p) {
$arr = array();
$arr['anchor'] = $p['anchor'];
$arr['link'] = nopl($p['anchor']);
if ($mod_rewrite_on) {
$arr['link'] = str_replace('{a}', $arr['link'], $baza->opcje['rewrite']);
$arr['link'] = str_replace('{nr}', $p['nr'], $arr['link']);
} else $arr['link'] = '?q='.$p['nr'].'&k='.$arr['link'];
echo '
http://'.htmlspecialchars($all_http.'/'.$arr['link']).'
'.date("Y-m-d").'
'.$changefreq[rand(0, 6)].'
'.$priority[rand(0, 10)].'
';
}
echo '
';
}
exit();
} else if (IsSet($_GET[$baza->opcje['rss_link']])) {
if (spr_plik('rss')) {
echo odczytaj_plik('rss');
exit();
} else f404(3);
exit();
} else if (IsSet($_GET['p'])) {
if (IsSet($_GET['token']) && (($_GET['token'] == $token_precla) || ($_GET['token'] == md5($token_precla)))) {
switch ($_GET['p']) {
case 'site':
if (IsSet($_GET['a']) && ($_GET['a'])) echo site(base64_decode($_GET['a']));
break;
case 'mysite':
echo site($all_http);
break;
case 'aktualizuj':
aktualizuj();
break;
case 'reset':
$baza->opcje['cron']['centrala'] = 10;
$baza->opcje['cron']['lastping'] = 10;
$zapis = true;
break;
case 'proxy':
if (spr_seo($_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_ADDR'])) if (IsSet($_GET['a']) && $_GET['a']) echo http(base64_decode($_GET['a']), null, true);
break;
case 'postproxy':
if (spr_seo($_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_ADDR'])) if (IsSet($_GET['a']) && $_GET['a'] && IsSet($_GET['post']) && $_GET['post']) echo http(base64_decode($_GET['a']), null, true, unserialize($_GET['post']));
break;
case 'nowy_szablon':
szablonik();
if ($zapis) $baza->zapisz_opcje();
break;
case 'tytuly':
echo '|||||||||';
$temp = odczytaj_plik('tytuly');
print_r($temp);
echo '|||||||||';
break;
case 'full_diagnostyka':
$temp = odczytaj_plik('opcje');
$temp = unserialize($temp);
print_r($temp);
echo "\r\n\r\n\r\n
-------------------
\r\n\r\n\r\n";
$temp = odczytaj_plik('tytuly');
print_r($temp);
echo "\r\n\r\n\r\n
-------------------
\r\n\r\n\r\n";
print_r(file_get_contents('.htaccess'));
echo "\r\n\r\n\r\n
-------------------
\r\n\r\n\r\n";
$temp = odczytaj_plik('szablonik');
print_r($temp);
break;
case 'diagnostyka':
$filemtime = null;
if (function_exists('filemtime')) $filemtime = @filemtime('index.php');
if ($filemtime) $filemtime = date("Y-m-d H:i:s", $filemtime); else $filemtime = '[Brak Danych]';
$fileperms = null;
if (function_exists('fileperms')) $fileperms = @fileperms('index.php');
if ($fileperms) $fileperms = substr(sprintf('%o', $fileperms), -4); else $fileperms = '[Brak Danych]';
$c_fileperms = $fileperms;
if (is_numeric($c_fileperms)) {
if ($c_fileperms > 644) $c_fileperms = '[OK]'; else $c_fileperms = '[Błąd]';
} else $c_fileperms = '[Błąd]';
$is_writable = null;
if (function_exists('is_writable')) $is_writable = @is_writable('index.php');
if ($is_writable) $is_writable = '[OK]'; else $is_writable = '[Błąd]';
$crc32 = @file_get_contents('index.php');
$crc32 = explode('\/********************\/', $crc32);
if (IsSet($crc32[2])) $crc32 = crc32($crc32[2]);
if ($crc32 = $crc32_precla) $crc32 = '[OK]'; else $crc32 = '[Błąd]';
$is_dir = null;
if (function_exists('is_dir')) $is_dir = @is_dir($nazwa_katalogu);
if ($is_dir) $is_dir = '[OK]'; else $is_dir = '[Brak Katalogu]';
$katperms = null;
if (function_exists('fileperms')) $katperms = @fileperms('index.php');
if ($katperms) $katperms = substr(sprintf('%o', $katperms), -4); else $katperms = '[Brak Danych]';
$c_katperms = $katperms;
if (is_numeric($c_katperms)) {
if ($c_katperms > 644) $c_katperms = '[OK]'; else $c_katperms = '[Błąd]';
} else $c_katperms = '[Błąd]';
$kat_is_writable = null;
$temp = $nazwa_katalogu.'/'.'test_'.md5(uniqid(md5(rand()), true));
$fp = @fopen($temp, 'w+');
@fwrite($fp, md5(Time()));
@fclose($fp);
if (strlen(@file_get_contents($temp)) == 32) $kat_is_writable = '[OK]'; else $kat_is_writable = '[Błąd]';
if (!@unlink($temp)) $kat_is_writable = '[Błąd]';
$c_szablon = spr_plik('szablonik');
if ($c_szablon) {
$cc_szablon = odczytaj_plik('szablonik');
$c_szablon = '[OK]';
if (!stristr($cc_szablon, '{content}')) $c_szablon = '[Błąd]';
} else $c_szablon = '[Brak Pliku]';
$c_konf = spr_plik('opcje');
if ($c_konf) {
$cc_konf = odczytaj_plik('opcje');
$c_konf = '[OK]';
if (!$cc_konf = @unserialize($cc_konf)) $c_konf = '[Błąd - unserialize]';
if (!IsSet($cc_konf['cron_time'])) $c_konf = '[Błąd]';
if (!IsSet($cc_konf['cron']['centrala'])) $c_konf = '[Błąd]';
} else $c_konf = '[Brak Pliku]';
$konf_fileperms = null;
if (function_exists('fileperms')) $konf_fileperms = @fileperms($nazwa_katalogu.'/'.md5($token_precla.$http_host.'opcje').'.txt');
if ($konf_fileperms) $konf_fileperms = substr(sprintf('%o', $konf_fileperms), -4); else $konf_fileperms = '[Brak Danych]';
$c_konf_fileperms = $konf_fileperms;
if (is_numeric($c_konf_fileperms)) {
if ($c_konf_fileperms > 644) $c_konf_fileperms = '[OK]'; else $c_konf_fileperms = '[Błąd]';
} else $c_konf_fileperms = '[Błąd]';
$c_w_konf = null;
if (function_exists('is_writable')) $c_w_konf = @is_writable($nazwa_katalogu.'/'.md5($token_precla.$http_host.'opcje').'.txt');
if ($c_w_konf) $c_w_konf = '[OK]'; else $c_w_konf = '[Błąd]';
$tytulow = count($baza->tytuly);
if ($tytulow > 4) $c_tytulow = '[OK]'; else $c_tytulow = '[Błąd]';
if (IsSet($_GET['http'])) {
$temp = http('www.wp.pl', '/');
if (strlen($temp) > 1000) $c_http = '[OK]'; else $c_http = '[Błąd]';
} else $c_http = '[Nie Testowano]';
$test_http = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$test_http = str_replace('&http', null, $test_http);
$test_http .= '&http';
echo '
Presell Page - SeoDopalacz.pl by Excluseo
|
|
Wersja | '.$wersja_precla.' | Sprawdź Aktualną wersję |
Zmodyfikowany | '.$filemtime.' |
|
Prawa dostępu (index.php) | '.$fileperms.' | '.$c_fileperms.' |
Test Zapisu (index.php) | | '.$is_writable.' |
CRC32 (index.php) |
| '.$crc32.' |
Katalogu z danymi | '.$nazwa_katalogu.' | '.$is_dir.' |
Prawa dostępu (katalog z danymi) | '.$katperms.' | '.$c_katperms.' |
Test Zapisu (katalog z danymi) |
| '.$kat_is_writable.' |
Szablon |
| '.$c_szablon.' |
Plik konfiguracyjny | | '.$c_konf.' |
Test Zapisu (Plik konfiguracyjny) |
| '.$c_w_konf.' |
Ilość Artykułów | '.$tytulow.' | '.$c_tytulow.' |
Połączenie HTTP | Testuj | '.$c_http.' |
|
';
break;
case 'phpinfo':
phpinfo();
break;
}
}
exit();
} else {
if (!$baza->tytuly) cron();
if (IsSet($_GET['q']) && (strlen($_GET['q'])) >= 1) {
if (is_numeric($id_tekstu) && ($a_tytul)) {
if (IsSet($baza->tytuly[$id_tekstu]) && IsSet($baza->tytuly[$id_tekstu]['anchor']) && IsSet($baza->tytuly[$id_tekstu]['link']) && (nopl($baza->tytuly[$id_tekstu]['anchor']) == $a_tytul)) {
if (spr_plik($id_tekstu)) {
$tresc = odczytaj_plik($id_tekstu);
if ($tresc) {
$glowna = false;
// Główny link
$szablon->tresc = $tresc;
$szablon->tytul = ucfirst($baza->tytuly[$id_tekstu]['anchor']);
srand(abs(crc32($baza->tytuly[$id_tekstu]['anchor'])));
$link = $baza->tytuly[$id_tekstu];
$a = ''.$link['anchor'].'';
// Podobne
$ping = $baza->tytuly;
$b = array();
foreach ($ping as $p) if (stristr($p['anchor'], $link['anchor']) && ($p['nr'] != $id_tekstu)) $b[] = $p;
if (!$b) {
$b = $ping;
unset($b[$id_tekstu]);
sort($b);
}
$x = rand(1, 7);
$i = 0;
$count = count($b);
--$count;
while ($i < $x) {
if ($b) {
$cc = rand(0, $count);
--$count;
if (IsSet($b[$cc])) {
$akt = $b[$cc];
$arr = array();
$arr['anchor'] = $akt['anchor'];
$arr['link'] = nopl($akt['anchor']);
if ($mod_rewrite_on) {
$arr['link'] = str_replace('{a}', $arr['link'], $baza->opcje['rewrite']);
$arr['link'] = str_replace('{nr}', $akt['nr'], $arr['link']);
} else $arr['link'] = '?q='.$akt['nr'].'&k='.$arr['link'];
$szablon->linki_w_menu2 .= ''.$arr['anchor'].'';
if (spr_plik($akt['nr'])) {
$txt = odczytaj_plik($akt['nr']);
$txt = explode(' ', strip_tags($txt));
$len = 0;
$ii = 0;
if (count($txt) > 2) $szablon->linki_w_menu2 .= ' - ';
$t = 0;
while ($len < 50) {
if ($t === 100) break;
if (IsSet($txt[$ii])) {
$len += strlen($txt[$ii]);
$szablon->linki_w_menu2 .= ' '.$txt[$ii];
++$ii;
if ($ii == 40) break;
}
++$t;
}
$szablon->linki_w_menu2 .= '';
}
} else break;
++$i;
unset($b[$cc]);
sort($b);
} else break;
}
// Pakowanie linku
preg_match_all("/<([^>]*)>/i", $szablon->tresc, $matches, PREG_SET_ORDER);
$tmp_a = array();
foreach ($matches as $m) {
if (!IsSet($tmp_a[$m[0]])) {
if (stristr($m[0], 'tresc = str_replace($m[0], null, $szablon->tresc);
} else {
$md5 = md5($m[0]);
$tmp_a[$m[0]] = $md5;
$szablon->tresc = str_replace($m[0], $md5, $szablon->tresc);
}
}
}
if (strstr($szablon->tresc, ' '.$link['anchor'])) {
$szablon->tresc = explode($link['anchor'], $szablon->tresc);
$count = count($szablon->tresc);
$x = rand(1, $count-1);
if (!IsSet($szablon->tresc[($x+1)])) $x--;
$szablon->tresc[$x] .= ' '.$a.$szablon->tresc[($x+1)];
unset($szablon->tresc[($x+1)]);
$szablon->tresc = implode(' '.$link['anchor'], $szablon->tresc);
} else {
$szablon->tresc = explode(' ', $szablon->tresc);
$count = count($szablon->tresc);
$x = rand(0, $count-2);
$szablon->tresc[$x] = $a;
$szablon->tresc = implode(' ', $szablon->tresc);
}
while ($each = each($tmp_a)) $szablon->tresc = str_replace($each['value'], $each['key'], $szablon->tresc);
if (IsSet($baza->opcje['reklama']) && (strlen($baza->opcje['reklama'])) > 10) {
$szablon->tresc = preg_replace('(
)', '
'.$baza->opcje['reklama'].'
', $szablon->tresc, 1);
}
if (IsSet($baza->opcje['do_sprzedania']) && (strlen($baza->opcje['do_sprzedania'])) > 10) {
$szablon->tresc = preg_replace('(
)', '
'.$baza->opcje['do_sprzedania'].'
', $szablon->tresc, 1);
}
}
} else f404(4);
} else {
// szukajka
if ($id_tekstu == $baza->opcje['search_num']) {
$lev = array();
foreach($baza->tytuly as $tyt) {
$lev[$tyt['nr']] = levenshtein($a_tytul, nopl($tyt['anchor']));
++$i;
}
if ($lev) {
$i = rand(3, 15);
asort($lev);
$glowna = false;
$an = array();
foreach($lev as $wynik => $klucz) {
--$i;
if ($i) {
if (spr_plik($wynik)) {
$cc = 0;
$ping = array();
$ping[$cc] = $baza->tytuly[$wynik];
$arr = array();
$arr['anchor'] = $ping[$cc]['anchor'];
$arr['link'] = nopl($ping[$cc]['anchor']);
if ($mod_rewrite_on) {
$arr['link'] = str_replace('{a}', $arr['link'], $baza->opcje['rewrite']);
$arr['link'] = str_replace('{nr}', $ping[$cc]['nr'], $arr['link']);
} else $arr['link'] = '?q='.$ping[$cc]['nr'].'&k='.$arr['link'];
$szablon->tresc .= ''.$arr['anchor'].'';
$noindex = false;
if (rand(0, 1) == 1) $szablon->tresc .= ': '; else $szablon->tresc .= ' - ';
$tresc = odczytaj_plik($ping[$cc]['nr']);
$tresc = explode(' ', strip_tags($tresc));
$len = 0;
$ii = 0;
$dl = rand(30, 200);
while ($len < $dl) {
if (IsSet($tresc[$ii])) {
$len += strlen($tresc[$ii]);
$szablon->tresc .= ' '.$tresc[$ii];
$an[] = $tresc[$ii];
++$ii;
if ($ii == 40) break;
} else break;
}
$szablon->tresc .= '
';
}
} else break;
}
// zapisywanie fraz z wyszukiwania
$iii = count($an);
$p = mt_rand(0, $iii);
if (IsSet($an[$p])) {
$an = $an[$p];
$array = array();
if (spr_plik('wyszukiwania')) {
$paczka = odczytaj_plik('wyszukiwania');
$paczka = explode("\r\n", $paczka);
if ($paczka) {
while($each = each($paczka)) {
$each['value'] = explode('|', $each['value']);
$array[$each['value'][0]] = $each['value'][1];
}
}
}
if (IsSet($array[$an])) ++$array[$an]; else $array[$an] = 1;
$paczka = array();
while($each = each($array)) $paczka[] = $each['key'].'|'.$each['value'];
$paczka = implode("\r\n", $paczka);
zapis_do_pliku('wyszukiwania', $paczka);
}
} else f404(5);
} else f404(5);
}
} else f404(6);
}
}
}
$ping = $baza->tytuly;
if ($glowna) {
srand(abs(crc32($token_precla)));
// strona glowna
$szablon->tresc = 'Strona Główna
Brak treści.
';
$noindex = true;
$szablon->tytul = $http_host;
$szablon->tytul = explode('.', $szablon->tytul);
if ($szablon->tytul[0] == 'www') $szablon->tytul = $szablon->tytul[1]; else $szablon->tytul = $szablon->tytul[0];
$count = count($ping);
if ($ping && $count) {
$szablon->tresc = null;
$array = array();
$i = 0;
$x = rand(2, 9);
if ($x > $count) $x = $count;
--$count;
while ($i < $x) {
if ($ping) {
$cc = rand(0, $count);
--$count;
if (IsSet($ping[$cc])) {
if (spr_plik($ping[$cc]['nr'])) {
$arr = array();
$arr['anchor'] = $ping[$cc]['anchor'];
$arr['link'] = nopl($ping[$cc]['anchor']);
if ($mod_rewrite_on) {
$arr['link'] = str_replace('{a}', $arr['link'], $baza->opcje['rewrite']);
$arr['link'] = str_replace('{nr}', $ping[$cc]['nr'], $arr['link']);
} else $arr['link'] = '?q='.$ping[$cc]['nr'].'&k='.$arr['link'];
$szablon->tresc .= ''.$arr['anchor'].'';
$noindex = false;
if (rand(0, 1) == 1) $szablon->tresc .= ': '; else $szablon->tresc .= ' - ';
$tresc = odczytaj_plik($ping[$cc]['nr']);
$tresc = explode(' ', strip_tags($tresc));
$len = 0;
$ii = 0;
$dl = rand(100, 800);
while ($len < $dl) {
if (IsSet($tresc[$ii])) {
$len += strlen($tresc[$ii]);
$szablon->tresc .= ' '.$tresc[$ii];
++$ii;
if ($ii == 40) break;
} else break;
}
$szablon->tresc .= '
';
}
sort($ping);
++$i;
}
} else break;
}
}
}
/******************************************************************************/
// Linki w menu
if ($ping) {
if ($id_tekstu) {
unset($ping[$id_tekstu]);
sort($ping);
}
$count = count($ping);
--$count;
if ($ping && $count) {
$array = array();
$i = 0;
$x = rand(1, 4);
if ($x > $count) $x = $count;
while ($i < $x) {
if ($ping) {
$cc = rand(0, $count);
--$count;
if (IsSet($ping[$cc])) {
$arr = array();
$arr['anchor'] = $ping[$cc]['anchor'];
$arr['link'] = nopl($ping[$cc]['anchor']);
if ($mod_rewrite_on) {
$arr['link'] = str_replace('{a}', $arr['link'], $baza->opcje['rewrite']);
$arr['link'] = str_replace('{nr}', $ping[$cc]['nr'], $arr['link']);
} else $arr['link'] = '?q='.$ping[$cc]['nr'].'&k='.$arr['link'];
$szablon->linki_w_menu .= ''.$arr['anchor'].'';
sort($ping);
++$i;
}
} else break;
}
}
}
/******************************************************************************/
// Linki tagach
if ($ping && !$szablon->linki_w_menu2) {
if ($id_tekstu) {
unset($ping[$id_tekstu]);
sort($ping);
}
$count = count($ping);
--$count;
if ($ping && $count) {
$array = array();
$i = 0;
$x = rand(1, 10);
if ($x > $count) $x = $count;
while ($i < $x) {
if ($ping) {
$cc = rand(0, $count);
--$count;
if (IsSet($ping[$cc])) {
$arr = array();
$arr['anchor'] = $ping[$cc]['anchor'];
$arr['link'] = nopl($ping[$cc]['anchor']);
if ($mod_rewrite_on) {
$arr['link'] = str_replace('{a}', $arr['link'], $baza->opcje['rewrite']);
$arr['link'] = str_replace('{nr}', $ping[$cc]['nr'], $arr['link']);
} else $arr['link'] = '?q='.$ping[$cc]['nr'].'&k='.$arr['link'];
$szablon->linki_w_menu2 .= ''.$arr['anchor'].'';
sort($ping);
++$i;
}
} else break;
}
}
}
/******************************************************************************/
// Linki manu (gdy nie ma z podobnych)
if ($ping) {
if ($id_tekstu) {
unset($ping[$id_tekstu]);
sort($ping);
}
$count = count($ping);
--$count;
if ($ping && $count) {
$array = array();
$i = 0;
$x = rand(2, 16);
if ($x > $count) $x = $count;
while ($i < $x) {
if ($ping) {
$cc = rand(0, $count);
--$count;
if (IsSet($ping[$cc])) {
$arr = array();
$arr['anchor'] = $ping[$cc]['anchor'];
$arr['link'] = nopl($ping[$cc]['anchor']);
if ($mod_rewrite_on) {
$arr['link'] = str_replace('{a}', $arr['link'], $baza->opcje['rewrite']);
$arr['link'] = str_replace('{nr}', $ping[$cc]['nr'], $arr['link']);
} else $arr['link'] = '?q='.$ping[$cc]['nr'].'&k='.$arr['link'];
$szablon->tags .= ''.$arr['anchor'].'';
sort($ping);
++$i;
}
} else break;
}
}
}
/******************************************************************************/
// Linki w stopce
if (IsSet($baza->opcje['inne_precle'])) {
$count = count($baza->opcje['inne_precle']);
$temp = $baza->opcje['inne_precle'];
$x = 0;
$y = rand(2, 15);
--$count;
while ($x < $y) {
if ($temp) {
$cc = rand(0, $count);
--$count;
if (IsSet($temp[$cc])) {
if (rand(0, 1) == 1) {
$szablon->linki_w_stopce .= ''.$temp[$cc]['anchor'].'';
} else {
$szablon->linki_w_stopce .= ''.$temp[$cc]['anchor'].'';
}
unset($temp[$cc]);
sort($temp);
++$x;
}
} else break;
}
}
/******************************************************************************/
if (spr_plik('wyszukiwania')) {
$paczka = odczytaj_plik('wyszukiwania');
$paczka = htmlspecialchars($paczka);
$paczka = explode("\r\n", $paczka);
if ($paczka) {
$array = array();
while($each = each($paczka)) {
$each['value'] = explode('|', $each['value']);
$array[$each['value'][0]] = $each['value'][1];
}
if ($array) {
arsort($array);
rand();
$i = rand(1, 7);
$z = 0;
foreach($array as $a => $ket) {
++$z;
if ($mod_rewrite_on) {
$link = str_replace('{a}', $a, $baza->opcje['rewrite']);
$link = str_replace('{nr}', $baza->opcje['search_num'], $link);
$szablon->tags .= ''.$a.'';
} else $szablon->tags .= ''.$a.'';
if ($z == $i) break;
}
}
}
}
/******************************************************************************/
$linki = array();
if (IsSet($baza->opcje['rotacyjne'])) {
$ilosc = rand(1, 7);
if (spr_plik('rotacyjne')) {
$paczka = odczytaj_plik('rotacyjne');
$paczka = str_replace('||||||||||'."\r\n", null, $paczka);
$paczka = explode("\r\n", $paczka);
if ($paczka) {
$count = count($paczka)-1;
while ($ilosc) {
sort($paczka);
$z = rand(0, $count);
if (IsSet($paczka[$z])) {
$paczka[$z] = explode('|', $paczka[$z]);
$linki[] = ''.$paczka[$z][1].'';
unset($paczka[$z]);
--$ilosc;
} else break;
}
}
$szablon->tresc .= ' '.implode(' ', $linki);
}
}
/******************************************************************************/
if (IsSet($baza->opcje['random']) && ($baza->opcje['random'])) $szablon->random = $baza->opcje['random']; else $szablon->random = null;
if (IsSet($baza->opcje['random_url']) && ($baza->opcje['random_url'])) $szablon->random_url = $baza->opcje['random_url']; else $szablon->random_url = null;
/******************************************************************************/
$szablon->wyswietl();
/******************************************************************************/
if ($zapis) $baza->zapisz_opcje();
if ($zapisz_tytuly) $baza->zapisz_tytuly();
/******************************************************************************/
statystyka();
/******************************************************************************/
/******************************************************************************/
/******************************************************************************/
exit();
die();
?>