WordPress codeproject.com BOT

http://www.codeproject.com/Tags/PHP buradaki makaleleri alır TAGS/ASP yaparsanız asp deki makaleleri alır.

 <?php  
 set_time_limit(0);  
  // require wp-load.php to use built-in WordPress functions  
  require_once("wp-load.php");  
  /*******************************************************  
  ** POST VARIABLES  
  *******************************************************/  
 function getData($data,$startTag,$finishTag){  
  $data= explode($startTag,$data);  
  $data= $data[1];  
  $data= explode($finishTag,$data);  
  $data= $data[0];  
  return $data;  
  }  
 $site = "http://www.codeproject.com/Tags/PHP";  
 $data = file_get_contents($site);  
 preg_match_all('/<div class="content-list-item">.*?>.*?<\/table>/si', $data, $download);   
 foreach($download as $d)  
  {  
   $toplam = count ($d);  
  for ($i = 0; $i <= $toplam; $i++) {  
  $sitegelen= getData($d[$i],'href="','"');   
  $sitegelen='http://www.codeproject.com'.$sitegelen;  
 $verim = file_get_contents($sitegelen);  
  $demo= getData($verim,'<div id="contentdiv" class="text">','<h2>Share</h2>');    
   $baslik= getData($verim,'<title>','</title>');   
 $detay = strip_tags($demo);  
  $detay = nl2br($detay);  
 $detay = str_replace('<br />', '', $detay);  
  $postType = 'post'; // set to post or page  
  $userID = 1; // set to user id  
  $categoryID = '1'; // set to category id.  
  $postStatus = 'publish'; // set to future, draft, or publish  
  $leadTitle = $baslik;  
  $leadContent = $detay;  
  //$leadContent .= ' <!--more--> <p>Expensive they are, but they are totally worth it.</p>';  
  /*******************************************************  
  ** TIME VARIABLES / CALCULATIONS  
  *******************************************************/  
  // VARIABLES  
  $timeStamp = $minuteCounter = 0; // set all timers to 0;  
  $iCounter = 1; // number use to multiply by minute increment;  
  $minuteIncrement = 1; // increment which to increase each post time for future schedule  
  $adjustClockMinutes = 0; // add 1 hour or 60 minutes - daylight savings  
  // CALCULATIONS  
  $minuteCounter = $iCounter * $minuteIncrement; // setting how far out in time to post if future.  
  $minuteCounter = $minuteCounter + $adjustClockMinutes; // adjusting for server timezone  
  $timeStamp = date('Y-m-d H:i:s', strtotime("+$minuteCounter min")); // format needed for WordPress  
  /*******************************************************  
  ** WordPress Array and Variables for posting  
  *******************************************************/  
  $new_post = array(  
  'post_title' => wp_strip_all_tags($leadTitle),  
  'post_content' => $leadContent,  
  'post_status' => $postStatus,  
  'post_date' => $timeStamp,  
  'post_author' => $userID,  
  'post_type' => $postType,  
  'tags_input' =>$taglar,  
  'post_category' => array($categoryID)  
  );  
  /*******************************************************  
  ** WordPress Post Function  
  *******************************************************/  
  $post_id = wp_insert_post($new_post);  
  /*******************************************************  
  ** SIMPLE ERROR CHECKING  
  *******************************************************/  
  // Add Featured Image to Post  
 $image_url    = $resim; // Define the image URL here  
 $image_name    = $resim_adi;  
 $upload_dir    = wp_upload_dir(); // Set upload folder  
 $image_data    = file_get_contents($image_url); // Get image data  
 $unique_file_name = wp_unique_filename( $upload_dir['path'], $image_name ); // Generate unique name  
 $filename     = basename( $unique_file_name ); // Create image file name  
 // Check folder permission and define file location  
 if( wp_mkdir_p( $upload_dir['path'] ) ) {  
   $file = $upload_dir['path'] . '/' . $filename;  
 } else {  
   $file = $upload_dir['basedir'] . '/' . $filename;  
 }  
 // Create the image file on the server  
 file_put_contents( $file, $image_data );  
 // Check image file type  
 $wp_filetype = wp_check_filetype( $filename, null );  
 // Set attachment data  
 $attachment = array(  
   'post_mime_type' => $wp_filetype['type'],  
   'post_title'   => sanitize_file_name( $filename ),  
   'post_content'  => '',  
   'post_status'  => 'inherit'  
 );  
 // Create the attachment  
 $attach_id = wp_insert_attachment( $attachment, $file, $post_id );  
 // Include image.php  
 require_once(ABSPATH . 'wp-admin/includes/image.php');  
 // Define attachment metadata  
 $attach_data = wp_generate_attachment_metadata( $attach_id, $file );  
 // Assign metadata to attachment  
 wp_update_attachment_metadata( $attach_id, $attach_data );  
 // And finally assign featured image to post  
 set_post_thumbnail( $post_id, $attach_id );  
  }  
 }  
  $finaltext = '';  
  if($post_id){  
  $finaltext .= 'Bot Çalıştı.<br>';  
  } else{  
  $finaltext .= 'Bot Çalışmadı Bazı Sorunlar Var.<br>';  
  }  
  echo $finaltext;  

Yorumlar

Bu blogdaki popüler yayınlar

Stormfall: Saga of Survival Hile

Php ile Windows Uygulama Yapmak Başlangıç (PHP Desktop)

Rise Of Civilizations