• 30-06-2015, 14:24:15
    #1
    Merhaba aşağıda kodunu verdiğim bot $varmi değişkeni ile daha önce wp ye eklenen başlık ve açıklamaları kontrol etmektedir.

    Şuan bot başlık ve açıklama ikisinide kontrolunu sağlıyor. başlık yada açıklama ikisinden biri tutmuyosa ekliyor. olması gereken ikisinden biri tutuyosa eklemesin. yardımcı olabilecek arkadaşlara şimdiden teşekürler.

    ?>
    	<?php $i = 0;
    foreach($haberler as $haber)
    {
    	if(stristr($title,"request")){
    }else{
    $Baglan = Baglan($haber);
    $Baglan = iconv("ISO-8859-9","UTF-8",$Baglan);
    preg_match('#<title>(.*?)</title>#',$Baglan,$title);
    $title = @$title[1];
    $title = strip_tags($title);
    /////////////
     ##Bold##
    preg_match('#<!--\#SOSYAL MEDYA -->(.*?)<!--YAZI -->#',$Baglan,$bold);
    $bold = strip_tags($bold[1],"<b><p><br>");
    ##Bold##
    ##İcerik##
    preg_match('#<!--YAZI -->(.*?)<!--\#YAZI -->#',$Baglan,$content);
    $content = strip_tags($content[1],"<b><p><br>");
    $content = "<h2>".$bold."</h2><br /><br />".$content;
    // echo $content;
    ##İcerik##
    /////////////
    
    if($ozgunlestirme == 1){
    		$title = replace($title);
    		$content = replace($content);
    }
    $title = addslashes($title);
    $content = addslashes($content);
    	 if($title){
    		 /////
    		$varmi = count($wpdb->get_results( 'SELECT * FROM wp_posts WHERE post_title = "'.$title.'" AND post_content = "'.$content.'"', OBJECT ));
    if($varmi == 0){
     
     
    
    if($yayinla == 1){
    	$yayin = "publish";
    }else{
    	$yayin = "draft";
    }
    $title = stripslashes($title);
    $content = stripslashes($content);
     ///
      $my_post = array();
      $my_post['post_title'] = $title;
      $my_post['post_content'] = $content;
      $my_post['post_status'] = $yayin;
      $my_post['post_author'] = $userid;
      $my_post['post_category'] = array(kat("yurt"));
       $post_id = wp_insert_post( $my_post );
     ///
     preg_match('#<meta property="og:image" content="(.*?)"/>#',$Baglan,$img);
    $img = $img[1];
     $file_headers = @get_headers($img);
    
    if($file_headers[0] != 'HTTP/1.1 404 Not Found') {
    
    
    if($resimcevir == 1){
    	// echo "evet";
        $r = rand(1,999999999);
        copy($img,"upload/".$r.".jpg");
      
        $image = new Upload("upload/".$r.".jpg");
      $image->image_flip = "v";
        if ( $image->uploaded ) {
            $image->Process('upload/');
            if ( $image->processed ){
               $img =  "http://".$_SERVER['HTTP_HOST']."/bot/auto/crons/upload/".$image->file_dst_name;
            } else {
                print 'Bir sorun oluştu: '.$image->error;
            }
    
        }
    }
    echo $img."<br />";
    $image_url = $img;
    $upload_dir = wp_upload_dir();
    $image_data = file_get_contents($image_url);
    $filename = basename($image_url);
    if(wp_mkdir_p($upload_dir['path']))
        $file = $upload_dir['path'] . '/' . $filename;
    else
        $file = $upload_dir['basedir'] . '/' . $filename;
    file_put_contents($file, $image_data);
    
    $wp_filetype = wp_check_filetype($filename, null );
    $attachment = array(
        'post_mime_type' => $wp_filetype['type'],
        'post_title' => sanitize_file_name($filename),
        'post_content' => '',
        'post_status' => 'inherit'
    );
    $attach_id = wp_insert_attachment( $attachment, $file, $post_id );
    require_once(ABSPATH . 'wp-admin/includes/image.php');
    $attach_data = wp_generate_attachment_metadata( $attach_id, $file );
    wp_update_attachment_metadata( $attach_id, $attach_data );
    
    set_post_thumbnail( $post_id, $attach_id );
    
    
    
    }
     ///
    }
    		 /////
    	 }
    }
    }
    	?>
  • 30-06-2015, 14:48:13
    #2
    $varmi = count($wpdb->get_results( 'SELECT * FROM wp_posts WHERE post_title = "'.$title.'" AND post_content = "'.$content.'"', OBJECT ));
    yerine

    $varmi = count($wpdb->get_results( 'SELECT * FROM wp_posts WHERE post_title = "'.$title.'" OR post_content = "'.$content.'"', OBJECT ));
  • 30-06-2015, 14:49:47
    #3
    evet hocam onu o şekilde denedim ama malesef sonuç alamadım. biyerde bi eksiklik hata var ama ne