/Quản lý website đọc truyện online PHP/horoscope/func.php
PHP | 207 lines | 44 code | 0 blank | 163 comment | 9 complexity | 786d1910d73fcbfa387c477dab91c776 MD5 | raw file
- <?php
- // Khai báo trình duyệt nhận lấy nội dung
- function userAgent() {
- $userAgent = 'Opera/9.80 (J2ME/MIDP; Opera Mini/4.3.24214/25.685; U; vi) Presto/2.5.25 Version/10.54';
- }
- // Khởi Tạo CURL
- function grab_link($url,$cookie='',$user_agent='',$header='') {
- if(function_exists('curl_init')){
- $ch = curl_init();
- $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
- $headers[] = 'Accept-Language: en-us,en;q=0.5';
- $headers[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7';
- $headers[] = 'Keep-Alive: 300';
- $headers[] = 'Connection: Keep-Alive';
- $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
- curl_setopt($ch, CURLOPT_URL, $url);
- if($user_agent) curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
- else curl_setopt($ch, CURLOPT_USERAGENT, userAgent());
- if($header)
- curl_setopt($ch, CURLOPT_HEADER, 1);
- else
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($ch, CURLOPT_REFERER, 'http://www.google.com.vn/search?hl=vi&client=firefox-a&rls=org.mozilla:en-US:official&hs=hKS&q=video+clip&start=20&sa=N');
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
- if(strncmp($url, 'https', 6)) curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- if($cookie) curl_setopt($ch, CURLOPT_COOKIE, $cookie);
- curl_setopt($ch, CURLOPT_TIMEOUT, 100);
- $html = curl_exec($ch);
- $mess_error = curl_error($ch);
- curl_close($ch);
- }
- else {
- $matches = parse_url($url);
- $host = $matches['host'];
- $link = (isset($matches['path'])?$matches['path']:'/').(isset($matches['query'])?'?'.$matches['query']:'').(isset($matches['fragment'])?'#'.$matches['fragment']:'');
- $port = !empty($matches['port']) ? $matches['port'] : 80;
- $fp=@fsockopen($host,$port,$errno,$errval,30);
- if (!$fp) {
- $html = "$errval ($errno)<br />\n";
- } else {
- $rand_ip = rand(1,254).".".rand(1,254).".".rand(1,254).".".rand(1,254);
- $out = "GET $link HTTP/1.1\r\n".
- "Host: $host\r\n".
- "Referer: http://www.google.com.vn/search?hl=vi&client=firefox-a&rls=org.mozilla:en-US:official&hs=hKS&q=video+clip&start=20&sa=N\r\n".
- "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n";
- if($cookie) $out .= "Cookie: $cookie\r\n";
- if($user_agent) $out .= "User-Agent: ".$user_agent."\r\n";
- else $out .= "User-Agent: ".userAgent()."\r\n";
- $out .= "X-Forwarded-For: $rand_ip\r\n".
- "Via: CB-Prx\r\n".
- "Connection: Close\r\n\r\n";
- fwrite($fp,$out);
- while (!feof($fp)) {
- $html .= fgets($fp,4096);
- }
- fclose($fp);
- }
- }
- return $html;
- }
- // Lấy nội dung
- function laynoidung($noidung, $start, $stop) {
- $bd = strpos($noidung, $start);
- $kt = strpos(substr($noidung, $bd), $stop) + $bd;
- $content = substr($noidung, $bd, $kt - $bd);
- return $content;
- }
- // Thay kí tự
- function trangkute($trang9x) {
- $trang9x = str_replace('Đ', 'Đ', $trang9x);
- $trang9x = str_replace('đ', 'đ', $trang9x);
- $trang9x = str_replace('Á', 'Á', $trang9x);
- $trang9x = str_replace('á', 'á', $trang9x);
- $trang9x = str_replace('À', 'À', $trang9x);
- $trang9x = str_replace('à', 'à', $trang9x);
- $trang9x = str_replace('Ã', 'Ã', $trang9x);
- $trang9x = str_replace('ã', 'ã', $trang9x);
- $trang9x = str_replace('Ả', 'Ả', $trang9x);
- $trang9x = str_replace('ả', 'ả', $trang9x);
- $trang9x = str_replace('Ạ', 'Ạ', $trang9x);
- $trang9x = str_replace('ạ', 'ạ', $trang9x);
- $trang9x = str_replace('Â', 'Â', $trang9x);
- $trang9x = str_replace('â', 'â', $trang9x);
- $trang9x = str_replace('Ấ', 'Ấ', $trang9x);
- $trang9x = str_replace('ấ', 'ấ', $trang9x);
- $trang9x = str_replace('Ầ', 'Ầ', $trang9x);
- $trang9x = str_replace('ầ', 'ầ', $trang9x);
- $trang9x = str_replace('Ẫ', 'Ẫ', $trang9x);
- $trang9x = str_replace('ẫ', 'ẫ', $trang9x);
- $trang9x = str_replace('Ẩ', 'Ẩ', $trang9x);
- $trang9x = str_replace('ẩ', 'ẩ', $trang9x);
- $trang9x = str_replace('Ậ', 'Ậ', $trang9x);
- $trang9x = str_replace('ậ', 'ậ', $trang9x);
- $trang9x = str_replace('Ă', 'Ă', $trang9x);
- $trang9x = str_replace('ă', 'ă', $trang9x);
- $trang9x = str_replace('Ắ', 'Ắ', $trang9x);
- $trang9x = str_replace('ắ', 'ắ', $trang9x);
- $trang9x = str_replace('Ằ', 'Ằ', $trang9x);
- $trang9x = str_replace('ằ', 'ằ', $trang9x);
- $trang9x = str_replace('Ẵ', 'Ẵ', $trang9x);
- $trang9x = str_replace('ẵ', 'ẵ', $trang9x);
- $trang9x = str_replace('Ẳ', 'Ẳ', $trang9x);
- $trang9x = str_replace('ẳ', 'ẳ', $trang9x);
- $trang9x = str_replace('Ặ', 'Ặ', $trang9x);
- $trang9x = str_replace('ặ', 'ặ', $trang9x);
- $trang9x = str_replace('É', 'É', $trang9x);
- $trang9x = str_replace('é', 'ß', $trang9x);
- $trang9x = str_replace('È', 'È', $trang9x);
- $trang9x = str_replace('è', 'è', $trang9x);
- $trang9x = str_replace('Ẽ', 'Ẽ', $trang9x);
- $trang9x = str_replace('ẽ', 'ẽ', $trang9x);
- $trang9x = str_replace('Ẻ', 'Ẻ', $trang9x);
- $trang9x = str_replace('ẻ', 'ẻ', $trang9x);
- $trang9x = str_replace('Ẹ', 'Ẹ', $trang9x);
- $trang9x = str_replace('ẹ', 'ẹ', $trang9x);
- $trang9x = str_replace('Ê', 'Ê', $trang9x);
- $trang9x = str_replace('ê', 'ê', $trang9x);
- $trang9x = str_replace('Ế', 'Ế', $trang9x);
- $trang9x = str_replace('ế', 'ế', $trang9x);
- $trang9x = str_replace('Ề', 'Ề', $trang9x);
- $trang9x = str_replace('ề', 'ề', $trang9x);
- $trang9x = str_replace('Ễ', 'Ễ', $trang9x);
- $trang9x = str_replace('ễ', 'ễ', $trang9x);
- $trang9x = str_replace('Ể', 'Ể', $trang9x);
- $trang9x = str_replace('ể', 'ể', $trang9x);
- $trang9x = str_replace('Ệ', 'Ệ', $trang9x);
- $trang9x = str_replace('ệ', 'ệ', $trang9x);
- $trang9x = str_replace('Í', 'Í', $trang9x);
- $trang9x = str_replace('í', 'í', $trang9x);
- $trang9x = str_replace('Ì', 'Ì', $trang9x);
- $trang9x = str_replace('ì', 'ì', $trang9x);
- $trang9x = str_replace('Ĩ', 'Ĩ', $trang9x);
- $trang9x = str_replace('ĩ', 'ĩ', $trang9x);
- $trang9x = str_replace('Ỉ', 'Ỉ', $trang9x);
- $trang9x = str_replace('ỉ', 'ỉ', $trang9x);
- $trang9x = str_replace('Ị', 'Ị', $trang9x);
- $trang9x = str_replace('ị', 'ị', $trang9x);
- $trang9x = str_replace('Ó', 'Ý', $trang9x);
- $trang9x = str_replace('ó', 'ó', $trang9x);
- $trang9x = str_replace('Ò', 'Ò', $trang9x);
- $trang9x = str_replace('ò', 'ò', $trang9x);
- $trang9x = str_replace('Õ', 'Õ', $trang9x);
- $trang9x = str_replace('õ', 'õ', $trang9x);
- $trang9x = str_replace('Ỏ', 'Ỏ', $trang9x);
- $trang9x = str_replace('ỏ', 'ỏ', $trang9x);
- $trang9x = str_replace('Ọ', 'Ọ', $trang9x);
- $trang9x = str_replace('ọ', 'ọ', $trang9x);
- $trang9x = str_replace('Ô', 'Ô', $trang9x);
- $trang9x = str_replace('ô', 'ô', $trang9x);
- $trang9x = str_replace('Ố', 'Ố', $trang9x);
- $trang9x = str_replace('ố', 'ố', $trang9x);
- $trang9x = str_replace('Ồ', 'Ồ', $trang9x);
- $trang9x = str_replace('ồ', 'ồ', $trang9x);
- $trang9x = str_replace('Ỗ', 'Ỗ', $trang9x);
- $trang9x = str_replace('ỗ', 'ỗ', $trang9x);
- $trang9x = str_replace('Ổ', 'Ổ', $trang9x);
- $trang9x = str_replace('ổ', 'ổ', $trang9x);
- $trang9x = str_replace('Ộ', 'Ộ', $trang9x);
- $trang9x = str_replace('ộ', 'ộ', $trang9x);
- $trang9x = str_replace('Ơ', 'Ơ', $trang9x);
- $trang9x = str_replace('ơ', 'ơ', $trang9x);
- $trang9x = str_replace('Ớ', 'Ớ', $trang9x);
- $trang9x = str_replace('ớ', 'ớ', $trang9x);
- $trang9x = str_replace('Ờ', 'Ờ', $trang9x);
- $trang9x = str_replace('ờ', 'ờ', $trang9x);
- $trang9x = str_replace('Ỡ', 'Ỡ', $trang9x);
- $trang9x = str_replace('ỡ', 'ỡ', $trang9x);
- $trang9x = str_replace('Ở', 'Ở', $trang9x);
- $trang9x = str_replace('ở', 'ở', $trang9x);
- $trang9x = str_replace('Ợ', 'Ợ', $trang9x);
- $trang9x = str_replace('ợ', 'ợ', $trang9x);
- $trang9x = str_replace('Ú', 'Ú', $trang9x);
- $trang9x = str_replace('ú', 'ú', $trang9x);
- $trang9x = str_replace('Ù', 'Ù', $trang9x);
- $trang9x = str_replace('ù', 'ù', $trang9x);
- $trang9x = str_replace('Ũ', 'Ũ', $trang9x);
- $trang9x = str_replace('ũ', 'ũ', $trang9x);
- $trang9x = str_replace('Ủ', 'Ủ', $trang9x);
- $trang9x = str_replace('ủ', 'ủ', $trang9x);
- $trang9x = str_replace('Ụ', 'Ụ', $trang9x);
- $trang9x = str_replace('ụ', 'ụ', $trang9x);
- $trang9x = str_replace('Ư', 'Ư', $trang9x);
- $trang9x = str_replace('ư', 'ư', $trang9x);
- $trang9x = str_replace('Ứ', 'Ứ', $trang9x);
- $trang9x = str_replace('ứ', 'ứ', $trang9x);
- $trang9x = str_replace('Ừ', 'Ừ', $trang9x);
- $trang9x = str_replace('ừ', 'ừ', $trang9x);
- $trang9x = str_replace('Ữ', 'Ữ', $trang9x);
- $trang9x = str_replace('ữ', 'ữ', $trang9x);
- $trang9x = str_replace('Ử', 'Ử', $trang9x);
- $trang9x = str_replace('ử', 'ử', $trang9x);
- $trang9x = str_replace('Ự', 'Ự', $trang9x);
- $trang9x = str_replace('ự', 'ự', $trang9x);
- $trang9x = str_replace('Ý', 'Ý', $trang9x);
- $trang9x = str_replace('ý', 'ý', $trang9x);
- $trang9x = str_replace('Ỳ', 'Ỳ', $trang9x);
- $trang9x = str_replace('ỳ', 'ỳ', $trang9x);
- $trang9x = str_replace('Ỹ', 'Ỹ', $trang9x);
- $trang9x = str_replace('ỹ', 'ỹ', $trang9x);
- $trang9x = str_replace('Ỷ', 'Ỷ', $trang9x);
- $trang9x = str_replace('ỷ', 'ỷ', $trang9x);
- $trang9x = str_replace('Ỵ', 'Ỵ', $trang9x);
- $trang9x = str_replace('ỵ', 'ỵ', $trang9x);
- return $trang9x;
- }
- ?>