GIF89a;
Direktori : /home/serb/public_html/admin/ |
Current File : /home/serb/public_html/admin/cron.php |
<?php /*$to="santanubera6@gmail.com"; $subject="Test mail from Sex-finder"; $from="santanubera6@yahoo.com"; $body="Test Body"; mail($to, $subject, $body, $from);*/ ob_start(); include("lib/globals.php"); include("lib/common.php"); require_once("lib/library.php"); include('lib/parse.php'); $cityid=rand(3,370); $sql3="SELECT * FROM citys WHERE scrap_status='a'"; $res3=execute_query($sql3); while($row3=mysql_fetch_array($res3)){ if($row3['name']=='San Francisco') { $location='sf'; } else { $location=strtolower($row3['name']); $location=str_replace(' ','',$location); } $status = 'a'; $host_domain='backpage.com'; $no_ads=100; $q = "select * from scrape_settings"; $result=execute_query($q); if($result && mysql_num_rows($result)>0) { $record=mysql_fetch_array($result); $backpage_mode = $record['backpage_mode']; $backpage_show_source = $record['backpage_show_source']; $clickable_link = $record['clickable_link']; if($backpage_mode) { $cities_query = "select * from backpage_urls order by id"; $cities_result = execute_query($cities_query); if($cities_result && mysql_num_rows($cities_result) > 0) { while($cities_record = mysql_fetch_array($cities_result)) { $location_alias = $location; $category_alias = $cities_record["category_alias"]; if($status) { for($m=0;$m<=8; $m++) { if($m==0) { echo $main_url = "http://{$location_alias}.{$host_domain}/{$category_alias}/"; echo "Main URL: $main_url<br/>"; } else { echo $main_url = "http://{$location_alias}.{$host_domain}/{$category_alias}/?page=".$m; echo "Main URL: $main_url<br/>"; } //echo "----------------------------------------------------------<br/>"; $title = ""; $body_content = ""; $image_source = ""; $image_contents = ""; $upload_directory = "scrapping_temp_images/"; $uploadDir = "avtar/"; $widthmax = "600"; $heightmax = "600"; $temp_file = array(); $date = time(); $ch = curl_init($main_url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $html = curl_exec($ch); if (!$html) { echo "cURL [$main_url] error number:" .curl_errno($ch)."<br />"; echo "cURL [$main_url] error:" . curl_error($ch)."<br />"; } curl_close($ch); $dom = new DOMDocument(); @$dom->loadHTML($html); $xpath = new DOMXPath($dom); $hrefs = $xpath->evaluate("/html/body//a"); $ad_iterate_index = 0; for ($ind = 0, $j = 0; ($ind < $hrefs->length) && ($j < $no_ads); $ind++) { $href = $hrefs->item($ind); $link = $href->getAttribute('href'); $cur_page = basename($link); if (preg_match('/(?<!\S)\d++(?!\S)/', $cur_page)) { if(($ad_iterate_index < $no_ads) ) { $matched_url[] = $cur_page; $backpage_ad_id = $cur_page; $exist_query = "select * from recent_backpage_scrapped_pages where page_id='$backpage_ad_id'"; $exist_result = execute_query($exist_query); if($exist_result && mysql_num_rows($exist_result)>0) { continue; } else { execute_query("insert recent_backpage_scrapped_pages set page_id='$backpage_ad_id',scrappedon='$date' "); } $j++; $ad_iterate_index++; $sub_url = $link; //echo "Sub URL: $sub_url<br/>"; $ch2 = curl_init($sub_url); curl_setopt($ch2, CURLOPT_HEADER, 0); curl_setopt($ch2, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1); curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1); $html2 = curl_exec($ch2); if (!$html2) { echo "cURL2 [$sub_url] error number:" .curl_errno($ch2)."<br />"; echo "cURL2 [$sub_url] error:" . curl_error($ch2)."<br />"; //exit; } curl_close($ch2); $dom2 = new DOMDocument(); @$dom2->loadHTML($html2); $xpath2 = new DOMXPath($dom2); /* Ad title */ $title = $xpath2->query("//title")->item(0)->nodeValue; $title = str_replace("- backpage.com", "", $title); $title_cut_offset = strrpos($title,"-"); if($title_cut_offset === false) { $title = str_replace("- ".$location_alias." escorts", "", $title); } else { $title = substr($title,0,$title_cut_offset); } //echo "Title: ".$title;echo "<br>"; /* Body content */ echo $html; if (preg_match('/<div\s*class="postingBody"\s*>(.*?)<\/div>/sx', $html, $arr_match)) { $body_content = $arr_match[1]; echo "Body: ".htmlspecialchars($body_content);echo "<br>"; } /* Images */ $images = $xpath2->evaluate("/html/body//img"); for ($i = 0, $kk=0; ($i < $images->length) && ($kk < 4); $i++) { $image = $images->item($i); $image_source = $image->getAttribute('src'); //echo $image_source."<br/>"; if (preg_match('/medium/s', $image_source)) { $image_source = str_replace("/medium/","/large/", $image_source); //echo $image_source."<br/>"; $ext = substr(strrchr($image_source, "."), 1); $filepath = md5(rand() * time()) . ".$ext"; while(file_exists($upload_directory.$filepath)) { $filepath = md5(rand() * time()) . ".$ext"; } /* Read Image contents */ $ch = curl_init($image_source); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $image_contents = curl_exec($ch); if (!$image_contents) { echo "<br />cURL3 [$image_source] error number:" .curl_errno($ch); echo "<br />cURL3 [$image_source] error:" . curl_error($ch); //exit; } curl_close($ch); /* Write Image contents */ $fp = fopen($upload_directory.$filepath, 'wb'); if($fp) { if (fwrite($fp, $image_contents) === FALSE) { echo "Cannot write to file ($filepath)"; exit; } else { ;//echo "File write to $upload_directory.$filepath"; } } fclose($fp); /* Resize and move to ads direcoty */ if(file_exists($upload_directory.$filepath)) { $img_size = getimagesize($upload_directory.$filepath); if( ($img_size[0]>$widthmax) || ($img_size[1]>$heightmax) ) { $width = $img_size[0]/1.2; $height = $img_size[1]/1.2; while(($width>$widthmax) || ($height>$heightmax)) { $width = $width/1.2; $height = $height/1.2; } if(createThumbnail($upload_directory.$filepath, $uploadDir.$filepath, $width, $height)) { //$temp_file[$kk++] = $filepath; } } else { if(rename($upload_directory.$filepath, $uploadDir.$filepath)) { //$temp_file[$kk++] = $filepath; } } $temp_file[$kk++] = $filepath; } } } /* End Images */ /* files query statements */ $file_queries = ""; for ($zz = 0; ($zz < count($temp_file)) && ($zz < 4); $zz++) { if($zz==0) { $file_queries = ", esc_file_name='".$temp_file[$zz]."'"; } else { $file_queries .= ", esc_file_name".($zz+1)."='".$temp_file[$zz]."'"; } } $desc=$body_content; preg_match('/\(?\b[0-9]{3}\)?[-. ]?[0-9]{3}[-. ]?[0-9]{4}\b/', $desc, $matches); $phone=str_replace('-', '', $matches[0]); $phone=str_replace('(', '', $phone); $phone=str_replace(')', '', $phone); $phone=str_replace('.', '', $phone); $phone=str_replace(' ', '', $phone); $sql5="SELECT * FROM escorts WHERE esc_phone='".$matches[0]."'"; $res5=execute_query($sql5); $num5=mysql_num_rows($res5); if($num5<=0) { echo $query="insert escorts set esc_title='".mysql_escape_string($title)."', esc_desc='".mysql_escape_string($body_content)."', esc_location='".$row3['id']."', esc_display_days='20', esc_post_time='$date', esc_status='a', esc_show_source='$backpage_show_source', esc_source_name='backpage.com', esc_source_link='$sub_url', esc_clickable_link='$clickable_link' $file_queries, esc_phone='".$matches[0]."', esc_phone1='".$phone."'"; execute_query($query); $id2=mysql_insert_id(); $sql9="SELECT * FROM escorts WHERE esc_id='$id2'"; $res9=execute_query($sql9); $row9=mysql_fetch_array($res9); $info = getimagesize('avtar/'.$row9['esc_file_name']); if(($info[0]<=0)||($info[1]<=0)) { $del="DELETE FROM escorts WHERE esc_id='$id2'"; execute_query($del); } //echo $query; exit; } } } } }//echo "----------------------------------------------------------<br/>"; } } } } } } ob_end_flush(); ?>