Post Creator 2.3 Plugin Not Working Properly In Word Press?
Hi I am working in word press plugin, that plugin name is post creator 2.3, using this we have to post several post at a time..the problem is its posting only 150 posts instead of 1000 posts..also i referred lot of things, i don't know to solve..


![enter image description here][2]


![enter image description here][3]


  [2]: http://i.stack.imgur.com/l1uk0.png
  [3]: http://i.stack.imgur.com/fycv2.png

i am new to word press, i don't know how to solve this problem, anybody help to solve this problem.




    <?php



    function get_da_date(){

	switch(get_option('wpbh_pc_date')){

		case 0:
			$date = (int)rand (strtotime("now"), strtotime("-5 years"));
			break;
		case 1:
			$date = (int)rand (strtotime("now"), strtotime("-3 years"));
			break;
		case 2:
			$date = (int)rand (strtotime("now"), strtotime("-2 years"));
			break;
		case 3:
			$date = (int)rand (strtotime("now"), strtotime("-1 year"));
			break;
		case 4:
			$date = (int)rand (strtotime("now"), strtotime("-6 months"));
			break;
		case 5:
			$date = (int)rand (strtotime("now"), strtotime("-3 months"));
			break;
		case 6:
			$date = (int)rand (strtotime("now"), strtotime("-2 months"));
			break;
		case 7:
			$date = (int)rand (strtotime("now"), strtotime("-1 month"));
			break;
		case 8:
			$date = (int)rand (strtotime("now"), strtotime("-3 weeks"));
			break;
		case 9:
			$date = (int)rand (strtotime("now"), strtotime("-2 weeks"));
			break;
		case 10:
			$date = (int)rand (strtotime("now"), strtotime("-1 week"));
			break;
		case 11:
			$date = strtotime("now");
			break;
		case 12:
			$date = (int)rand (strtotime("now"), strtotime("+1 week"));
			break;
		case 13:
			$date = (int)rand (strtotime("now"), strtotime("+2 weeks"));
			break;
		case 14:
			$date = (int)rand (strtotime("now"), strtotime("+3 weeks"));
			break;
		case 15:
			$date = (int)rand (strtotime("now"), strtotime("+1 month"));
			break;
		case 16:
			$date = (int)rand (strtotime("now"), strtotime("+2 months"));
			break;
		case 17:
			$date = (int)rand (strtotime("now"), strtotime("+3 months"));
			break;
		case 18:
			$date = (int)rand (strtotime("now"), strtotime("+6 months"));
			break;
		case 19:
			$date = (int)rand (strtotime("now"), strtotime("+1 year"));
			break;
		case 20:
			$date = (int)rand (strtotime("now"), strtotime("+2 year"));
			break;		
	}

	return $date;

    }

    function get_da_size(){
	switch(get_option('wpbh_pc_artsize')){
		case 0:
			$size = rand(1500, 2000);
			break;
		case 1:
			$size = rand(2500, 4500);
			break;
		case 2:
			$size = rand (5500, 7000);
			break;
		case 3:
			$size = rand (8000, 10000);
			break;
		case 4:
			$size = rand(1500, 3500);
			break;
		case 5:
			$size = rand(1500, 5500);
			break;
		case 6:
			$size = rand(2500, 5500);
			break;
		case 7:
			$size = rand(2500, 10000);
			break;
		case 8:
			$size = rand(5500, 10000);
			break;		
	}
	return $size;
    }

    function pc_spun($s,$arr){
        preg_match('#\{(.+?)\}#is',$s,$m);
        if(empty($m)) {
                array_push($arr,$s);

                return $arr;
        }

        $t = $m[1];

        if(strpos($t,'{')!==false){
                $t = substr($t, strrpos($t,'{') + 1);
        }

        $parts = explode("|", $t);
        for($i=0;$i<count($parts);$i++){
                $vv=$s;
                $vv = preg_replace("+\{".preg_quote($t)."\}+is", $parts[$i], $vv, 1);
                $arr=pc_spun($vv,$arr);
        }
        return($arr);
    }

    function wpbh_pc_gen_posts(){

	global $wpdb;
	$post = array();		
	$post['post_status'] = 'publish';
	$keyarray = array();
	$keyarray = explode("\n", get_option('wpbh_pc_keywords'));

	
	$filename = dirname(__FILE__). "/files/" . get_option('wpbh_pc_arts');

	$fp = fopen($filename, 'r'); 
	$content = fread($fp, filesize($filename)); 
	fclose($fp); 
    $content = utf8_encode(preg_replace("/[^A-Za-z0-9�������������\s\s+\.\-----\:\-\/%+\(\)\*\<\>\=\_\/\^\{\}\[\]\~\&\$\?\#\!\@\"\'\;\n\t\r]/","",utf8_decode($content)));
	$content = str_replace("<br />&#8212;&#8211;<br />", "", $content);
	$content = $wpdb->escape($content);
	$table = generate_markov_table($content, 7);

	echo "Posts created:<br><br>";

	foreach ($keyarray as $key) {

			if (trim($key)=="") continue;

			$k_array = Array();

			$k_array = pc_spun($key, 	$k_array);

			foreach ($k_array as $key_spun) {

				$key = $key_spun;

				$date = time();

				$post['post_date'] = date('Y-m-d H:i:s', get_da_date());

				$keyword = trim($key);
	

				$output = wpbh_pc_getcontent($key, $table);

				$post['post_content'] = $output;
	
				$post['post_title'] =     ucwords(wpbh_pc_parse_text($keyword));	
	
				$post['post_title'] = $wpdb->escape($post['post_title']);
	
				$post['post_category'] = array(get_option('wpbh_pc_cat'));	
				$post['post_terms'] = array(get_option('wpbh_pc_cat'));	
				$pid = wp_insert_post($post);
				do_action('publish_post', $pid);
				add_post_meta($pid, 'spost', 'yes'); 
				if($pid) echo 	$post['post_title'] . "<br>";
			}	
			
	}
	echo '<br><form method="post">';

	echo '<input type="submit" value="Finish" style="height: 5.5em; width: 10em" />';

	echo '</form>';

	exit();
    }


    function wpbh_pc_handle_parenthesis($string)
	{
		$phrases = explode('|', trim($string[0], '{}'));
		return $phrases[array_rand($phrases)];
	}	
    function wpbh_pc_parse_text($text)
	{

		while (preg_match_all('~\{[^\}\{]+\}~s', $text, $matches))
		{
			$pattern = sprintf('~%s~', preg_quote(end($matches[0]), '~'));
			$text = preg_replace_callback($pattern, 'wpbh_pc_handle_parenthesis', $text, 1);
		}
		
		return $text;
	}
    function wpbh_get_ytnum(){

		$num = 0;
		switch(get_option('wpbh_pc_yt_num')){
		case 0:
			$num = 0;
			break;
		case 1:
			$num = rand(0, 1);
			break;
		case 2:
			$num = rand (0, 2);
			break;
		case 3:
			$num = rand (1, 2);
			break;
		case 4:
			$num = rand(1, 3);
			break;			
	}
	return $num;
    }

    function wpbh_get_imagenum(){

		$num = 0;
		switch(get_option('wpbh_pc_images_num')){
		case 0:
			$num = 0;
			break;
		case 1:
			$num = rand(0, 1);
			break;
		case 2:
			$num = rand (0, 2);
			break;
		case 3:
			$num = rand (1, 2);
			break;
		case 4:
			$num = rand(1, 3);
			break;			
	}
	return $num;
    }

    function wpbh_get_elsnum(){

		$num = 0;
		switch(get_option('wpbh_pc_els_num')){
		case 0:
			$num = 0;
			break;
		case 1:
			$num = rand(0, 1);
			break;
		case 2:
			$num = rand (0, 2);
			break;
		case 3:
			$num = rand (0, 3);
			break;
		case 4:
			$num = rand(1, 2);
			break;			
		case 5:
			$num = rand(1, 3);
			break;
		case 6:
			$num = rand (1, 4);
			break;
		case 7:
			$num = rand (2, 5);
			break;		
	}
	return $num;
    }

    function wpbh_pc_getcontent($key, $table){

	global $wpdb;

	$content = stripslashes(wpbh_pc_carticle($table, 7));

	$content = wpbh_pc_gen_links($content);

	$b = wpbh_get_ytnum();
	for($i=0; $i<$b; $i++)
		$content = wpbh_pc_add_youtube($content);

	$b = wpbh_get_imagenum();
	for($i=0; $i<$b; $i++)
		$content = wpbh_pc_add_image($content);

	$content = add_keyword($key, $content);

	return $content . getllinks();
    }

    function wpbh_pc_add_image($content){

	if(get_option('wpbh_pc_imgs') == "No File") return $content;

	$filename = dirname(__FILE__). "/files/" . get_option('wpbh_pc_imgs');

	$fp = fopen($filename, 'r'); 
	$imgs = fread($fp, filesize($filename)); 
	fclose($fp); 

	$arr_imgs = explode("\n", $imgs);
	$img = trim($arr_imgs[array_rand($arr_imgs)]);
	$content = add_element($img, $content);
	return $content;
    }

    function wpbh_pc_add_youtube($content){

	if(get_option('wpbh_pc_ytv') == "No File") return $content;

	$filename = dirname(__FILE__). "/files/" . get_option('wpbh_pc_ytv');

	$fp = fopen($filename, 'r'); 
	$vids = fread($fp, filesize($filename)); 
	fclose($fp); 

	$arr_vids = explode("-----", $vids);
	$vid = trim($arr_vids[array_rand($arr_vids)]);
	$content = add_element($vid, $content);
	return $content;
    }

    function add_element($element, $source){	

	$rndn = rand(0, strlen($source));

	while($source[$rndn]!=" " && $rndn>1){
			$rndn = $rndn - 1;
	}

	$prefix = substr($source, 0, $rndn); 

	$suffix = substr($source, $rndn); 	

	$del1 = ""; $del2 = "";

	if (rand(1,2)==1) { $del1 = "<br>"; $del2 = "<br>"; }

	else if(rand(1,2)==1) { $del1 = "<br><br>"; $del2 = "<br><br>"; }

	$source = $prefix. " " . $del1 . "<br>" .$element . "<br>" . $del2 . " " .$suffix; 
	return $source;
    }


    function add_keyword($keyword, $source){	

	for($i=rand(1,5); $i >0; $i--) {

		$rndn = rand(0, strlen($source));

		while($source[$rndn]!=" " && $rndn>1){

			$rndn = $rndn - 1;

		}

		$prefix = substr($source, 0, $rndn); 

		$suffix = substr($source, $rndn); 	

		$del1 = ""; $del2 = "";

		if (get_option('wpbh_pc_r_bi') == 1) { 
			if(rand(1,2)==1) {$del1 = "<b>"; $del2 = "</b>";}
			else { $del1 = "<i>"; $del2 = "</i>";} 
		}

		else if(rand(1,2)==1) { $del1 = " "; $del2 = " "; }

		$source = $prefix. " " . $del1 . trim(wpbh_pc_parse_text($keyword)) . $del2 . " " .$suffix; 

	}

	return $source;

    }

    function pc_get_i(){
	global $wpdb; 

    $time_difference = get_settings('gmt_offset'); 

     $now = gmdate("Y-m-d H:i:s",time()); 

    $request = "SELECT ID, post_title, post_excerpt FROM $wpdb->posts WHERE post_status = 'publish' ";  

     $request .= "AND post_date_gmt < '$now' ORDER BY RAND() LIMIT 1"; 

    $posts = $wpdb->get_results($request); 

        $links = ""; 

		$i = 0;

    if($posts) { 

                foreach ($posts as $post) { 

                        $permalink = get_permalink($post->ID); 

                        $links = $permalink;
                      

                } 
	}

	return $links;
    }

    function wpbh_pc_gen_links($content){

	if(get_option('wpbh_pc_els') == "No File") return $content;

	$num = wpbh_get_elsnum();

	if($num==0) return $content;

	$filename = dirname(__FILE__). "/files/" . get_option('wpbh_pc_els');

	$fp = fopen($filename, 'r'); 
	$links = fread($fp, filesize($filename)); 
	fclose($fp); 

	$arr_links = explode("\n", $links);

	if (count($arr_links)>5) {
			$link = array_rand($arr_links, $num);		
			if( strlen($content) > 100 ){						
						$content = wpbh_pc_add_links($link , $content, 	$arr_links);
			}
	}

	return $content;
    }

    function wpbh_pc_add_links($links,$article, $arr_links){

	if (count($links)>15)
    
 		$links = array_splice($links, rand(3, 5));

    $num=count($links);

    if($num==0)return($article);
    $n=strlen($article)/$num+1;

    for($i=0;$i<$n;$i++){
        if($i==$n-1)
            $b[$i]=substr($article,$i*$n);
        else
            $b[$i]=substr($article,$i*$n,$n);
    }

    for($i=0;$i<$num;$i++){
	
		if(rand(1,2)==1)	
        	$url=trim($arr_links[$links[$i]]);
		else
			$url = pc_get_i();

        $n=strlen($b[$i])/2;
        $m=rand()%50;

        $f1=substr($b[$i],0,$n-$m);
        $f2=substr($b[$i],$n-$m);

        $keynum=rand()%6+1;
        $rs="/\s(";
        for($j=0;$j<$keynum;$j++){
            if($j==0)
                $rs.="\w+";
            else
                $rs.="\s+\w+";
        }
        $rs.=")\s/i";
        $f2=preg_replace($rs," <a href=${url}>$1</a> ",$f2,1);
        $b[$i]=$f1.$f2;
    }
    $article="";
    for($i=0;$i<$num;$i++)
        $article.=$b[$i];
    return $article;
    }

    function wpbh_pc_carticle($table, $look_forward){

	$char = array_rand($table);
    $o = $char;
	$length = get_da_size();
    for ($i = 0; $i < ($length / $look_forward); $i++) {

        $newchar = return_weighted_char($table[$char]);            
        if ($newchar) {
            $char = $newchar;

            $o .= $newchar;

        } else {       
            $char = array_rand($table);
        }
    }

    $pos = strpos($o,".");
    $o = substr($o, $pos+1, strlen($o));
    $pos = strrpos($o,".");
    $o = substr($o, 1, $pos);
  	$output = explode(".", 	$o);	
	$o="";
	$sc = 0;
	$bulls = "\r\n \r\n" . get_bulls($table, $look_forward) . "\r\n \r\n";
	$bullsflag = TRUE;
	foreach($output as $line) {

		$line = ucfirst(trim($line));

		if (strlen($line)>25 && (ctype_alpha($line[0])) ) { $o .= trim($line) . ". "; $sc++; }
	
		if(rand(1,3)==1 && ($sc>2)) { $o = trim($o) . " \r\n \r\n"; $sc = 0; }	

		if($bullsflag && rand(1,3)==2 && $sc==0 ) { $bullsflag=FALSE; if($bulls !="") $o .= $bulls; }

	}
    if($bullsflag && $bulls !="") return trim($o) .  $bulls;
	else return trim($o);
    }

    function get_bulls($table, $look_forward){

		$lflag = FALSE;

	switch(get_option('wpbh_pc_bpoints')){
		case 0:
			$lflag = FALSE;
			break;
		case 1:
			if(rand(1,5)<2) $lflag = TRUE;
			break;
		case 2:
			if(rand(1,5)<3) $lflag = TRUE;
			break;
		case 3:
			if(rand(1,5)<4) $lflag = TRUE;
			break;
		case 4:
			if(rand(1,5)<5) $lflag = TRUE;
			break;
		case 5:
			$lflag = TRUE;
			break;
	}
	if(!$lflag) return;

	$char = array_rand($table);
    $o = $char;
	$length = rand(450, 700);
    for ($i = 0; $i < ($length / $look_forward); $i++) {

        $newchar = return_weighted_char($table[$char]);            
        if ($newchar) {
            $char = $newchar;

            $o .= $newchar;

        } else {       
            $char = array_rand($table);
        }
    }

    $pos = strpos($o,".");
    $o = substr($o, $pos+1, strlen($o));
    $pos = strrpos($o,".");
    $o = substr($o, 1, $pos);
  	$output = explode(".", 	$o);	
	$o="";
	$bflag = FALSE;
	$thebull = "<ul>";
	foreach($output as $line) {
		$line = ucfirst(trim($line));
		if (strlen($line)>20 && (ctype_alpha($line[0])) ) { 	$thebull .= "<li>" . ucfirst($line) . ";" . "</li>"; $bflag = TRUE; }		
	}
	$thebull .= "</ul>";
	if ($bflag) return $thebull;
    }

    function getllinks(){

	$lflag = FALSE;

	switch(get_option('wpbh_pc_linklist')){
		case 0:
			$lflag = FALSE;
			break;
		case 1:
			if(rand(1,5)<2) $lflag = TRUE;
			break;
		case 2:
			if(rand(1,5)<3) $lflag = TRUE;
			break;
		case 3:
			if(rand(1,5)<4) $lflag = TRUE;
			break;
		case 4:
			if(rand(1,5)<5) $lflag = TRUE;
			break;
		case 5:
			$lflag = TRUE;
				break;
	}
	
	if($lflag) {
		if(get_option('wpbh_pc_els') == "No File") return;
		$llist = "\r\n\r\n" . get_option('wpbh_pc_rellinks') . "\r\n\r\n";
		$filename = dirname(__FILE__). "/files/" . get_option('wpbh_pc_els');
		$fp = fopen($filename, 'r'); 
		$links = fread($fp, filesize($filename)); 
		fclose($fp); 
		$arr_links = explode("\n", $links);

		if (count($arr_links)>10) {
			$links = array_rand($arr_links, rand(4, 8));		

			foreach($links as $link) {	
				if(rand(1,2)==1)
					$url = 	$arr_links[$link];
				else
					$url =  pc_get_i();
				$llist .= 	'<a href="' . $url . '">' . $url . '</a>' . "\r\n";
			}
			return $llist;
		}

	}
     }


    function return_weighted_char($array) {

    if (!$array) return false;
    $total = array_sum($array);
    $rand  = mt_rand(1, $total);
    foreach ($array as $item => $weight) {
        if ($rand <= $weight) return $item;
        $rand -= $weight;
    }
    }


    function generate_markov_table($text, $look_forward) {

    $table = array();

    for ($i = 0; $i < strlen($text); $i++) {

        $char = substr($text, $i, $look_forward);

        if (!isset($table[$char])) $table[$char] = array();
    }              

    for ($i = 0; $i < (strlen($text) - $look_forward); $i++) {

        $char_index = substr($text, $i, $look_forward);

        $char_count = substr($text, $i+$look_forward, $look_forward);
       
        if (isset($table[$char_index][$char_count])) {
            $table[$char_index][$char_count]++;
        } else {
            $table[$char_index][$char_count] = 1;
        }                
    } 
    return $table;
    }

    function wpbh_pc_editor() {

	if(isset($_POST['update']) ){	

		update_option('wpbh_pc_keywords', $_POST['keywords']);
		update_option('wpbh_pc_cat', $_POST['wpbh_cat']);
		update_option('wpbh_pc_els', $_POST['wpbh_els']);
		update_option('wpbh_pc_imgs', $_POST['wpbh_imgs']);
		update_option('wpbh_pc_arts', $_POST['wpbh_arts']);
		update_option('wpbh_pc_ytv', $_POST['wpbh_ytv']);
		update_option('wpbh_pc_date', $_POST['date']);
		update_option('wpbh_pc_artsize', $_POST['artsize']);
		update_option('wpbh_pc_els_num', $_POST['els_num']);
		update_option('wpbh_pc_yt_num', $_POST['yt_num']);
		update_option('wpbh_pc_images_num', $_POST['images_num']);
		update_option('wpbh_pc_rellinks', $_POST['rellinks']);
		update_option('wpbh_pc_linklist', $_POST['linklist']);
		update_option('wpbh_pc_bpoints', $_POST['bpoints']);
		update_option('wpbh_pc_r_bi', $_POST['r_bi']);
		wpbh_pc_gen_posts();
	}

	$path = dirname(__FILE__). "/files/";
	$cats = array();
	$cats = get_categories('hide_empty=0');

	echo '<div id="wpbody">';
	echo '<div class="wrap">';
	echo '<h2>Post Creator 2.3</h2>';
	echo '<form method="post" >';		
	echo '<table class="form-table">';

	echo '<tr><th scope="row"><label for="cgrade">Categoy: </label></th><td><select name="wpbh_cat">';	
		foreach($cats as $category) { 
			echo '<option value="' . $category->cat_ID . '"' . ((get_option('wpbh_pc_cat') == $category->cat_ID)?' selected':'') .   ' />' . $category->cat_name;   	 
		} 
		echo '</select></td></tr> ';	



	echo '<tr><th scope="row">Date: </label></th>';

	echo '<td><select name="date">';

	echo '<option value="0"' . ((get_option('wpbh_pc_date') == 0)?' selected':'') .   ' />-5 Years';

	echo '<option value="1"' . ((get_option('wpbh_pc_date') == 1)?' selected':'') .   ' />-3 Years';

	echo '<option value="2"' . ((get_option('wpbh_pc_date') == 2)?' selected':'') .   ' />-2 Years';

	echo '<option value="3"' . ((get_option('wpbh_pc_date') == 3)?' selected':'') .   ' />-1 Year';

	echo '<option value="4"' . ((get_option('wpbh_pc_date') == 4)?' selected':'') .   ' />-6 Months';

	echo '<option value="5"' . ((get_option('wpbh_pc_date') == 5)?' selected':'') .   ' />-3 Months';

	echo '<option value="6"' . ((get_option('wpbh_pc_date') == 6)?' selected':'') .   ' />-2 Months';

	echo '<option value="7"' . ((get_option('wpbh_pc_date') == 7)?' selected':'') .   ' />-1 Month';

	echo '<option value="8"' . ((get_option('wpbh_pc_date') == 8)?' selected':'') .   ' />-3 Weeks';

	echo '<option value="9"' . ((get_option('wpbh_pc_date') == 9)?' selected':'') .   ' />-2 Weeks';

	echo '<option value="10"' . ((get_option('wpbh_pc_date') == 10)?' selected':'') .   ' />-1 Week';

	echo '<option value="11"' . ((get_option('wpbh_pc_date') == 11)?' selected':'') .   ' />Today';

	echo '<option value="12"' . ((get_option('wpbh_pc_date') == 12)?' selected':'') .   ' />+1 Week';

	echo '<option value="13"' . ((get_option('wpbh_pc_date') == 13)?' selected':'') .   ' />+2 Weeks';

	echo '<option value="14"' . ((get_option('wpbh_pc_date') == 14)?' selected':'') .   ' />+3 Weeks';

	echo '<option value="15"' . ((get_option('wpbh_pc_date') == 15)?' selected':'') .   ' />+1 Month';

	echo '<option value="16"' . ((get_option('wpbh_pc_date') == 16)?' selected':'') .   ' />+2 Months';

	echo '<option value="17"' . ((get_option('wpbh_pc_date') == 17)?' selected':'') .   ' />+3 Months ';

	echo '<option value="18"' . ((get_option('wpbh_pc_date') == 18)?' selected':'') .   ' />+6 Months';

	echo '<option value="19"' . ((get_option('wpbh_pc_date') == 19)?' selected':'') .   ' />+1 Year';

	echo '<option value="20"' . ((get_option('wpbh_pc_date') == 20)?' selected':'') .   ' />+2 Years';

	echo '</select></td></tr>';


	echo '<tr><th scope="row"><label for="cgrade">Random Bolding/Italics of Keywords:</label></th><td>';
	echo '<select name="r_bi">';
	echo '<option value="0"' . ((get_option('wpbh_pc_r_bi') == 0)?' selected':'') .   ' />No';
	echo '<option value="1"' . ((get_option('wpbh_pc_r_bi') == 1)?' selected':'') .   ' />Yes';
	echo '</select></td></tr>';


	$dir_handle = @opendir($path) or die("Unable to open $path");
	$folders = '<option  value="No File" ' . ((get_option('wpbh_pc_els') == "No File")?' selected':'') .   '  >No File</option><br>';
	while ($file = readdir($dir_handle))
		{
			if (get_option('wpbh_pc_els')==$file) $selected="selected";
			else $selected="";
			if($file!='.' && $file!='..')
			$folders .= '<option value="' . $file . '"' . $selected .   '>' . $file . '</option><br>';
		}
	closedir($dir_handle);
	$thebox = '<select  name="wpbh_els">' . $folders . '</select>';	
	echo '<tr><th scope="row"><label for="cgrade">Internal/External Links: </label></th><td>';	
	echo $thebox;		
	echo '';
	echo ' Number of Internal/External Links to Add to Posts:';
	echo '<select name="els_num">';
	echo '<option value="0"' . ((get_option('wpbh_pc_els_num') == 0)?' selected':'') .   ' />0';
	echo '<option value="1"' . ((get_option('wpbh_pc_els_num') == 1)?' selected':'') .   ' />0 to 1';
	echo '<option value="2"' . ((get_option('wpbh_pc_els_num') == 2)?' selected':'') .   ' />0 to 2';
	echo '<option value="3"' . ((get_option('wpbh_pc_els_num') == 3)?' selected':'') .   ' />0 to 3';
	echo '<option value="4"' . ((get_option('wpbh_pc_els_num') == 4)?' selected':'') .   ' />1 to 2';
	echo '<option value="5"' . ((get_option('wpbh_pc_els_num') == 5)?' selected':'') .   ' />1 to 3';
	echo '<option value="6"' . ((get_option('wpbh_pc_els_num') == 6)?' selected':'') .   ' />1 to 4';
	echo '<option value="7"' . ((get_option('wpbh_pc_els_num') == 7)?' selected':'') .   ' />2 to 5';;
	echo '</select></td></tr>';

		$dir_handle = @opendir($path) or die("Unable to open $path");
	$folders = '<option  value="No File" ' . ((get_option('wpbh_pc_ytv') == "No File")?' selected':'') .   '  >No File</option><br>';
	while ($file = readdir($dir_handle))
		{
			if (get_option('wpbh_pc_ytv')==$file) $selected="selected";
			else $selected="";
			if($file!='.' && $file!='..')
			$folders .= '<option value="' . $file . '"' . $selected .   '>' . $file . '</option><br>';
		}
	closedir($dir_handle);
	$thebox = '<select  name="wpbh_ytv">' . $folders . '</select>';	
	echo '<tr><th scope="row"><label for="cgrade">Youtube Videos: </label></th><td>';	
	echo $thebox;		
	echo '';
	echo ' Number of Youtube Videos to Add to Posts:';
	echo '<select name="yt_num">';
	echo '<option value="0"' . ((get_option('wpbh_pc_yt_num') == 0)?' selected':'') .   ' />0';
	echo '<option value="1"' . ((get_option('wpbh_pc_yt_num') == 1)?' selected':'') .   ' />0 to 1';
	echo '<option value="2"' . ((get_option('wpbh_pc_yt_num') == 2)?' selected':'') .   ' />0 to 2';
	echo '<option value="3"' . ((get_option('wpbh_pc_yt_num') == 3)?' selected':'') .   ' />1 to 2';
	echo '<option value="4"' . ((get_option('wpbh_pc_yt_num') == 4)?' selected':'') .   ' />1 to 3';
	echo '</select></td></tr>';


	$dir_handle = @opendir($path) or die("Unable to open $path");
	$folders = '<option  value="No File" ' . ((get_option('wpbh_pc_imgs') == "No File")?' selected':'') .   '  >No File</option><br>';
	while ($file = readdir($dir_handle))
		{
			if (get_option('wpbh_pc_imgs')==$file) $selected="selected";
			else $selected="";
			if($file!='.' && $file!='..')
			$folders .= '<option value="' . $file . '"' . $selected .   '>' . $file . '</option><br>';
		}
	closedir($dir_handle);
	$thebox = '<select  name="wpbh_imgs">' . $folders . '</select>';	
	echo '<tr><th scope="row"><label for="cgrade">Images: </label></th><td>';	
	echo $thebox;		
	echo '';
	echo ' Number of Images to Add to Posts:';
	echo '<select name="images_num">';
	echo '<option value="0"' . ((get_option('wpbh_pc_images_num') == 0)?' selected':'') .   ' />0';
	echo '<option value="1"' . ((get_option('wpbh_pc_images_num') == 1)?' selected':'') .   ' />0 to 1';
	echo '<option value="2"' . ((get_option('wpbh_pc_images_num') == 2)?' selected':'') .   ' />0 to 2';
	echo '<option value="3"' . ((get_option('wpbh_pc_images_num') == 3)?' selected':'') .   ' />1 to 2';
	echo '<option value="4"' . ((get_option('wpbh_pc_images_num') == 4)?' selected':'') .   ' />1 to 3';
	echo '</select></td></tr>';



	$dir_handle = @opendir($path) or die("Unable to open $path");
	$folders = '';
	while ($file = readdir($dir_handle))
		{
			if (get_option('wpbh_pc_arts')==$file) $selected="selected";
			else $selected="";
			if($file!='.' && $file!='..')
			$folders .= '<option value="' . $file . '"' . $selected .   '>' . $file . '</option><br>';
		}
	closedir($dir_handle);
	$thebox = '<select  name="wpbh_arts">' . $folders . '</select>';	
	echo '<tr><th scope="row"><label for="cgrade">Articles : </label></th><td>';	
	echo $thebox;		
	echo '</td></tr> ';

	echo '<tr><th scope="row">Article Size: </label></th>';
	echo '<td><select name="artsize">';
	echo '<option value="0"' . ((get_option('wpbh_pc_artsize') == 0)?' selected':'') .   ' />small';
	echo '<option value="1"' . ((get_option('wpbh_pc_artsize') == 1)?' selected':'') .   ' />medium';
	echo '<option value="2"' . ((get_option('wpbh_pc_artsize') == 2)?' selected':'') .   ' />large';
	echo '<option value="3"' . ((get_option('wpbh_pc_artsize') == 3)?' selected':'') .   ' />very large';
	echo '<option value="4"' . ((get_option('wpbh_pc_artsize') == 4)?' selected':'') .   ' />small to medium';
	echo '<option value="5"' . ((get_option('wpbh_pc_artsize') == 5)?' selected':'') .   ' />small to large';
	echo '<option value="6"' . ((get_option('wpbh_pc_artsize') == 6)?' selected':'') .   ' />medium to large';
	echo '<option value="7"' . ((get_option('wpbh_pc_artsize') == 7)?' selected':'') .   ' />medium to very large';
	echo '<option value="8"' . ((get_option('wpbh_pc_artsize') == 8)?' selected':'') .   ' />large to very large';
	echo '</select></td></tr>';

	echo '<tr><th scope="row">Add a List of Links to Posts: </label></th>';
	echo '<td><select name="linklist">';
	echo '<option value="0"' . ((get_option('wpbh_pc_linklist') == 0)?' selected':'') .   ' />0% of the time';
	echo '<option value="1"' . ((get_option('wpbh_pc_linklist') == 1)?' selected':'') .   ' />20% of the time';
	echo '<option value="2"' . ((get_option('wpbh_pc_linklist') == 2)?' selected':'') .   ' />40% of the time';
	echo '<option value="3"' . ((get_option('wpbh_pc_linklist') == 3)?' selected':'') .   ' />60% of the time';
	echo '<option value="4"' . ((get_option('wpbh_pc_linklist') == 4)?' selected':'') .   ' />80% of the time';
	echo '<option value="5"' . ((get_option('wpbh_pc_linklist') == 5)?' selected':'') .   ' />100% of the time';
	echo '</select>';


	echo ' Related Links Title:';
	echo '<input name="rellinks" type="text" value="' . get_option('wpbh_pc_rellinks')  . '" size="40" />';
	echo '</td></tr>';

	echo '<tr><th scope="row">Add Bullet Points to Posts: </label></th>';
	echo '<td><select name="bpoints">';
	echo '<option value="0"' . ((get_option('wpbh_pc_bpoints') == 0)?' selected':'') .   ' />0% of the time';
	echo '<option value="1"' . ((get_option('wpbh_pc_bpoints') == 1)?' selected':'') .   ' />10% of the time';
	echo '<option value="2"' . ((get_option('wpbh_pc_bpoints') == 2)?' selected':'') .   ' />40% of the time';
	echo '<option value="3"' . ((get_option('wpbh_pc_bpoints') == 3)?' selected':'') .   ' />60% of the time';
	echo '<option value="4"' . ((get_option('wpbh_pc_bpoints') == 4)?' selected':'') .   ' />80% of the time';
	echo '<option value="5"' . ((get_option('wpbh_pc_bpoints') == 5)?' selected':'') .   ' />100% of the time';
	echo '</select></td></tr>';

	echo '<tr><th scope="row">Spinnable Titles:</th>';
	echo '<td><textarea name="keywords" rows="11" style="width:60%;">' . stripslashes(get_option('wpbh_pc_keywords')) . '</textarea>';
	echo '<br><br></td>';

	echo '</tr>';
	
	echo '<input type="hidden" name="update" value="yes" />';

	echo ' </table>';

	echo '<br><form method="post">';

	echo '<input type="submit" value="Generate Posts" style="height: 5.5em; width: 10em" />';

	echo '</form>';	

	echo '<br><br><center><br><b>Copyright 2011 <a href="http://wpblackhat.com/">WPBlackhat</a> - All Rights Reseverved! Distribution Strictly Forbidden!</b></center></div></div></center>';

    }


    function _to_admin() { 
	add_menu_page('Page title', 'Post Creator', 'manage_options', 'Post Creator', 'wpbh_pc_editor');
    }



    if (function_exists('add_action')) {
	add_action('admin_menu', '_to_admin');
    }

    ?>



this code i downloaded from the net..

Post Creator 2.3 Plugin Not Working Properly In Word Press?
===

Hi I am working in word press plugin, that plugin name is post creator 2.3, using this we have to post several post at a time..the problem is its posting only 150 posts instead of 1000 posts..also i referred lot of things, i don't know to solve..


![enter image description here][2]


![enter image description here][3]


  [2]: http://i.stack.imgur.com/l1uk0.png
  [3]: http://i.stack.imgur.com/fycv2.png

i am new to word press, i don't know how to solve this problem, anybody help to solve this problem.




    <?php



    function get_da_date(){

	switch(get_option('wpbh_pc_date')){

		case 0:
			$date = (int)rand (strtotime("now"), strtotime("-5 years"));
			break;
		case 1:
			$date = (int)rand (strtotime("now"), strtotime("-3 years"));
			break;
		case 2:
			$date = (int)rand (strtotime("now"), strtotime("-2 years"));
			break;
		case 3:
			$date = (int)rand (strtotime("now"), strtotime("-1 year"));
			break;
		case 4:
			$date = (int)rand (strtotime("now"), strtotime("-6 months"));
			break;
		case 5:
			$date = (int)rand (strtotime("now"), strtotime("-3 months"));
			break;
		case 6:
			$date = (int)rand (strtotime("now"), strtotime("-2 months"));
			break;
		case 7:
			$date = (int)rand (strtotime("now"), strtotime("-1 month"));
			break;
		case 8:
			$date = (int)rand (strtotime("now"), strtotime("-3 weeks"));
			break;
		case 9:
			$date = (int)rand (strtotime("now"), strtotime("-2 weeks"));
			break;
		case 10:
			$date = (int)rand (strtotime("now"), strtotime("-1 week"));
			break;
		case 11:
			$date = strtotime("now");
			break;
		case 12:
			$date = (int)rand (strtotime("now"), strtotime("+1 week"));
			break;
		case 13:
			$date = (int)rand (strtotime("now"), strtotime("+2 weeks"));
			break;
		case 14:
			$date = (int)rand (strtotime("now"), strtotime("+3 weeks"));
			break;
		case 15:
			$date = (int)rand (strtotime("now"), strtotime("+1 month"));
			break;
		case 16:
			$date = (int)rand (strtotime("now"), strtotime("+2 months"));
			break;
		case 17:
			$date = (int)rand (strtotime("now"), strtotime("+3 months"));
			break;
		case 18:
			$date = (int)rand (strtotime("now"), strtotime("+6 months"));
			break;
		case 19:
			$date = (int)rand (strtotime("now"), strtotime("+1 year"));
			break;
		case 20:
			$date = (int)rand (strtotime("now"), strtotime("+2 year"));
			break;		
	}

	return $date;

    }

    function get_da_size(){
	switch(get_option('wpbh_pc_artsize')){
		case 0:
			$size = rand(1500, 2000);
			break;
		case 1:
			$size = rand(2500, 4500);
			break;
		case 2:
			$size = rand (5500, 7000);
			break;
		case 3:
			$size = rand (8000, 10000);
			break;
		case 4:
			$size = rand(1500, 3500);
			break;
		case 5:
			$size = rand(1500, 5500);
			break;
		case 6:
			$size = rand(2500, 5500);
			break;
		case 7:
			$size = rand(2500, 10000);
			break;
		case 8:
			$size = rand(5500, 10000);
			break;		
	}
	return $size;
    }

    function pc_spun($s,$arr){
        preg_match('#\{(.+?)\}#is',$s,$m);
        if(empty($m)) {
                array_push($arr,$s);

                return $arr;
        }

        $t = $m[1];

        if(strpos($t,'{')!==false){
                $t = substr($t, strrpos($t,'{') + 1);
        }

        $parts = explode("|", $t);
        for($i=0;$i<count($parts);$i++){
                $vv=$s;
                $vv = preg_replace("+\{".preg_quote($t)."\}+is", $parts[$i], $vv, 1);
                $arr=pc_spun($vv,$arr);
        }
        return($arr);
    }

    function wpbh_pc_gen_posts(){

	global $wpdb;
	$post = array();		
	$post['post_status'] = 'publish';
	$keyarray = array();
	$keyarray = explode("\n", get_option('wpbh_pc_keywords'));

	
	$filename = dirname(__FILE__). "/files/" . get_option('wpbh_pc_arts');

	$fp = fopen($filename, 'r'); 
	$content = fread($fp, filesize($filename)); 
	fclose($fp); 
    $content = utf8_encode(preg_replace("/[^A-Za-z0-9�������������\s\s+\.\-----\:\-\/%+\(\)\*\<\>\=\_\/\^\{\}\[\]\~\&\$\?\#\!\@\"\'\;\n\t\r]/","",utf8_decode($content)));
	$content = str_replace("<br />&#8212;&#8211;<br />", "", $content);
	$content = $wpdb->escape($content);
	$table = generate_markov_table($content, 7);

	echo "Posts created:<br><br>";

	foreach ($keyarray as $key) {

			if (trim($key)=="") continue;

			$k_array = Array();

			$k_array = pc_spun($key, 	$k_array);

			foreach ($k_array as $key_spun) {

				$key = $key_spun;

				$date = time();

				$post['post_date'] = date('Y-m-d H:i:s', get_da_date());

				$keyword = trim($key);
	

				$output = wpbh_pc_getcontent($key, $table);

				$post['post_content'] = $output;
	
				$post['post_title'] =     ucwords(wpbh_pc_parse_text($keyword));	
	
				$post['post_title'] = $wpdb->escape($post['post_title']);
	
				$post['post_category'] = array(get_option('wpbh_pc_cat'));	
				$post['post_terms'] = array(get_option('wpbh_pc_cat'));	
				$pid = wp_insert_post($post);
				do_action('publish_post', $pid);
				add_post_meta($pid, 'spost', 'yes'); 
				if($pid) echo 	$post['post_title'] . "<br>";
			}	
			
	}
	echo '<br><form method="post">';

	echo '<input type="submit" value="Finish" style="height: 5.5em; width: 10em" />';

	echo '</form>';

	exit();
    }


    function wpbh_pc_handle_parenthesis($string)
	{
		$phrases = explode('|', trim($string[0], '{}'));
		return $phrases[array_rand($phrases)];
	}	
    function wpbh_pc_parse_text($text)
	{

		while (preg_match_all('~\{[^\}\{]+\}~s', $text, $matches))
		{
			$pattern = sprintf('~%s~', preg_quote(end($matches[0]), '~'));
			$text = preg_replace_callback($pattern, 'wpbh_pc_handle_parenthesis', $text, 1);
		}
		
		return $text;
	}
    function wpbh_get_ytnum(){

		$num = 0;
		switch(get_option('wpbh_pc_yt_num')){
		case 0:
			$num = 0;
			break;
		case 1:
			$num = rand(0, 1);
			break;
		case 2:
			$num = rand (0, 2);
			break;
		case 3:
			$num = rand (1, 2);
			break;
		case 4:
			$num = rand(1, 3);
			break;			
	}
	return $num;
    }

    function wpbh_get_imagenum(){

		$num = 0;
		switch(get_option('wpbh_pc_images_num')){
		case 0:
			$num = 0;
			break;
		case 1:
			$num = rand(0, 1);
			break;
		case 2:
			$num = rand (0, 2);
			break;
		case 3:
			$num = rand (1, 2);
			break;
		case 4:
			$num = rand(1, 3);
			break;			
	}
	return $num;
    }

    function wpbh_get_elsnum(){

		$num = 0;
		switch(get_option('wpbh_pc_els_num')){
		case 0:
			$num = 0;
			break;
		case 1:
			$num = rand(0, 1);
			break;
		case 2:
			$num = rand (0, 2);
			break;
		case 3:
			$num = rand (0, 3);
			break;
		case 4:
			$num = rand(1, 2);
			break;			
		case 5:
			$num = rand(1, 3);
			break;
		case 6:
			$num = rand (1, 4);
			break;
		case 7:
			$num = rand (2, 5);
			break;		
	}
	return $num;
    }

    function wpbh_pc_getcontent($key, $table){

	global $wpdb;

	$content = stripslashes(wpbh_pc_carticle($table, 7));

	$content = wpbh_pc_gen_links($content);

	$b = wpbh_get_ytnum();
	for($i=0; $i<$b; $i++)
		$content = wpbh_pc_add_youtube($content);

	$b = wpbh_get_imagenum();
	for($i=0; $i<$b; $i++)
		$content = wpbh_pc_add_image($content);

	$content = add_keyword($key, $content);

	return $content . getllinks();
    }

    function wpbh_pc_add_image($content){

	if(get_option('wpbh_pc_imgs') == "No File") return $content;

	$filename = dirname(__FILE__). "/files/" . get_option('wpbh_pc_imgs');

	$fp = fopen($filename, 'r'); 
	$imgs = fread($fp, filesize($filename)); 
	fclose($fp); 

	$arr_imgs = explode("\n", $imgs);
	$img = trim($arr_imgs[array_rand($arr_imgs)]);
	$content = add_element($img, $content);
	return $content;
    }

    function wpbh_pc_add_youtube($content){

	if(get_option('wpbh_pc_ytv') == "No File") return $content;

	$filename = dirname(__FILE__). "/files/" . get_option('wpbh_pc_ytv');

	$fp = fopen($filename, 'r'); 
	$vids = fread($fp, filesize($filename)); 
	fclose($fp); 

	$arr_vids = explode("-----", $vids);
	$vid = trim($arr_vids[array_rand($arr_vids)]);
	$content = add_element($vid, $content);
	return $content;
    }

    function add_element($element, $source){	

	$rndn = rand(0, strlen($source));

	while($source[$rndn]!=" " && $rndn>1){
			$rndn = $rndn - 1;
	}

	$prefix = substr($source, 0, $rndn); 

	$suffix = substr($source, $rndn); 	

	$del1 = ""; $del2 = "";

	if (rand(1,2)==1) { $del1 = "<br>"; $del2 = "<br>"; }

	else if(rand(1,2)==1) { $del1 = "<br><br>"; $del2 = "<br><br>"; }

	$source = $prefix. " " . $del1 . "<br>" .$element . "<br>" . $del2 . " " .$suffix; 
	return $source;
    }


    function add_keyword($keyword, $source){	

	for($i=rand(1,5); $i >0; $i--) {

		$rndn = rand(0, strlen($source));

		while($source[$rndn]!=" " && $rndn>1){

			$rndn = $rndn - 1;

		}

		$prefix = substr($source, 0, $rndn); 

		$suffix = substr($source, $rndn); 	

		$del1 = ""; $del2 = "";

		if (get_option('wpbh_pc_r_bi') == 1) { 
			if(rand(1,2)==1) {$del1 = "<b>"; $del2 = "</b>";}
			else { $del1 = "<i>"; $del2 = "</i>";} 
		}

		else if(rand(1,2)==1) { $del1 = " "; $del2 = " "; }

		$source = $prefix. " " . $del1 . trim(wpbh_pc_parse_text($keyword)) . $del2 . " " .$suffix; 

	}

	return $source;

    }

    function pc_get_i(){
	global $wpdb; 

    $time_difference = get_settings('gmt_offset'); 

     $now = gmdate("Y-m-d H:i:s",time()); 

    $request = "SELECT ID, post_title, post_excerpt FROM $wpdb->posts WHERE post_status = 'publish' ";  

     $request .= "AND post_date_gmt < '$now' ORDER BY RAND() LIMIT 1"; 

    $posts = $wpdb->get_results($request); 

        $links = ""; 

		$i = 0;

    if($posts) { 

                foreach ($posts as $post) { 

                        $permalink = get_permalink($post->ID); 

                        $links = $permalink;
                      

                } 
	}

	return $links;
    }

    function wpbh_pc_gen_links($content){

	if(get_option('wpbh_pc_els') == "No File") return $content;

	$num = wpbh_get_elsnum();

	if($num==0) return $content;

	$filename = dirname(__FILE__). "/files/" . get_option('wpbh_pc_els');

	$fp = fopen($filename, 'r'); 
	$links = fread($fp, filesize($filename)); 
	fclose($fp); 

	$arr_links = explode("\n", $links);

	if (count($arr_links)>5) {
			$link = array_rand($arr_links, $num);		
			if( strlen($content) > 100 ){						
						$content = wpbh_pc_add_links($link , $content, 	$arr_links);
			}
	}

	return $content;
    }

    function wpbh_pc_add_links($links,$article, $arr_links){

	if (count($links)>15)
    
 		$links = array_splice($links, rand(3, 5));

    $num=count($links);

    if($num==0)return($article);
    $n=strlen($article)/$num+1;

    for($i=0;$i<$n;$i++){
        if($i==$n-1)
            $b[$i]=substr($article,$i*$n);
        else
            $b[$i]=substr($article,$i*$n,$n);
    }

    for($i=0;$i<$num;$i++){
	
		if(rand(1,2)==1)	
        	$url=trim($arr_links[$links[$i]]);
		else
			$url = pc_get_i();

        $n=strlen($b[$i])/2;
        $m=rand()%50;

        $f1=substr($b[$i],0,$n-$m);
        $f2=substr($b[$i],$n-$m);

        $keynum=rand()%6+1;
        $rs="/\s(";
        for($j=0;$j<$keynum;$j++){
            if($j==0)
                $rs.="\w+";
            else
                $rs.="\s+\w+";
        }
        $rs.=")\s/i";
        $f2=preg_replace($rs," <a href=${url}>$1</a> ",$f2,1);
        $b[$i]=$f1.$f2;
    }
    $article="";
    for($i=0;$i<$num;$i++)
        $article.=$b[$i];
    return $article;
    }

    function wpbh_pc_carticle($table, $look_forward){

	$char = array_rand($table);
    $o = $char;
	$length = get_da_size();
    for ($i = 0; $i < ($length / $look_forward); $i++) {

        $newchar = return_weighted_char($table[$char]);            
        if ($newchar) {
            $char = $newchar;

            $o .= $newchar;

        } else {       
            $char = array_rand($table);
        }
    }

    $pos = strpos($o,".");
    $o = substr($o, $pos+1, strlen($o));
    $pos = strrpos($o,".");
    $o = substr($o, 1, $pos);
  	$output = explode(".", 	$o);	
	$o="";
	$sc = 0;
	$bulls = "\r\n \r\n" . get_bulls($table, $look_forward) . "\r\n \r\n";
	$bullsflag = TRUE;
	foreach($output as $line) {

		$line = ucfirst(trim($line));

		if (strlen($line)>25 && (ctype_alpha($line[0])) ) { $o .= trim($line) . ". "; $sc++; }
	
		if(rand(1,3)==1 && ($sc>2)) { $o = trim($o) . " \r\n \r\n"; $sc = 0; }	

		if($bullsflag && rand(1,3)==2 && $sc==0 ) { $bullsflag=FALSE; if($bulls !="") $o .= $bulls; }

	}
    if($bullsflag && $bulls !="") return trim($o) .  $bulls;
	else return trim($o);
    }

    function get_bulls($table, $look_forward){

		$lflag = FALSE;

	switch(get_option('wpbh_pc_bpoints')){
		case 0:
			$lflag = FALSE;
			break;
		case 1:
			if(rand(1,5)<2) $lflag = TRUE;
			break;
		case 2:
			if(rand(1,5)<3) $lflag = TRUE;
			break;
		case 3:
			if(rand(1,5)<4) $lflag = TRUE;
			break;
		case 4:
			if(rand(1,5)<5) $lflag = TRUE;
			break;
		case 5:
			$lflag = TRUE;
			break;
	}
	if(!$lflag) return;

	$char = array_rand($table);
    $o = $char;
	$length = rand(450, 700);
    for ($i = 0; $i < ($length / $look_forward); $i++) {

        $newchar = return_weighted_char($table[$char]);            
        if ($newchar) {
            $char = $newchar;

            $o .= $newchar;

        } else {       
            $char = array_rand($table);
        }
    }

    $pos = strpos($o,".");
    $o = substr($o, $pos+1, strlen($o));
    $pos = strrpos($o,".");
    $o = substr($o, 1, $pos);
  	$output = explode(".", 	$o);	
	$o="";
	$bflag = FALSE;
	$thebull = "<ul>";
	foreach($output as $line) {
		$line = ucfirst(trim($line));
		if (strlen($line)>20 && (ctype_alpha($line[0])) ) { 	$thebull .= "<li>" . ucfirst($line) . ";" . "</li>"; $bflag = TRUE; }		
	}
	$thebull .= "</ul>";
	if ($bflag) return $thebull;
    }

    function getllinks(){

	$lflag = FALSE;

	switch(get_option('wpbh_pc_linklist')){
		case 0:
			$lflag = FALSE;
			break;
		case 1:
			if(rand(1,5)<2) $lflag = TRUE;
			break;
		case 2:
			if(rand(1,5)<3) $lflag = TRUE;
			break;
		case 3:
			if(rand(1,5)<4) $lflag = TRUE;
			break;
		case 4:
			if(rand(1,5)<5) $lflag = TRUE;
			break;
		case 5:
			$lflag = TRUE;
				break;
	}
	
	if($lflag) {
		if(get_option('wpbh_pc_els') == "No File") return;
		$llist = "\r\n\r\n" . get_option('wpbh_pc_rellinks') . "\r\n\r\n";
		$filename = dirname(__FILE__). "/files/" . get_option('wpbh_pc_els');
		$fp = fopen($filename, 'r'); 
		$links = fread($fp, filesize($filename)); 
		fclose($fp); 
		$arr_links = explode("\n", $links);

		if (count($arr_links)>10) {
			$links = array_rand($arr_links, rand(4, 8));		

			foreach($links as $link) {	
				if(rand(1,2)==1)
					$url = 	$arr_links[$link];
				else
					$url =  pc_get_i();
				$llist .= 	'<a href="' . $url . '">' . $url . '</a>' . "\r\n";
			}
			return $llist;
		}

	}
     }


    function return_weighted_char($array) {

    if (!$array) return false;
    $total = array_sum($array);
    $rand  = mt_rand(1, $total);
    foreach ($array as $item => $weight) {
        if ($rand <= $weight) return $item;
        $rand -= $weight;
    }
    }


    function generate_markov_table($text, $look_forward) {

    $table = array();

    for ($i = 0; $i < strlen($text); $i++) {

        $char = substr($text, $i, $look_forward);

        if (!isset($table[$char])) $table[$char] = array();
    }              

    for ($i = 0; $i < (strlen($text) - $look_forward); $i++) {

        $char_index = substr($text, $i, $look_forward);

        $char_count = substr($text, $i+$look_forward, $look_forward);
       
        if (isset($table[$char_index][$char_count])) {
            $table[$char_index][$char_count]++;
        } else {
            $table[$char_index][$char_count] = 1;
        }                
    } 
    return $table;
    }

    function wpbh_pc_editor() {

	if(isset($_POST['update']) ){	

		update_option('wpbh_pc_keywords', $_POST['keywords']);
		update_option('wpbh_pc_cat', $_POST['wpbh_cat']);
		update_option('wpbh_pc_els', $_POST['wpbh_els']);
		update_option('wpbh_pc_imgs', $_POST['wpbh_imgs']);
		update_option('wpbh_pc_arts', $_POST['wpbh_arts']);
		update_option('wpbh_pc_ytv', $_POST['wpbh_ytv']);
		update_option('wpbh_pc_date', $_POST['date']);
		update_option('wpbh_pc_artsize', $_POST['artsize']);
		update_option('wpbh_pc_els_num', $_POST['els_num']);
		update_option('wpbh_pc_yt_num', $_POST['yt_num']);
		update_option('wpbh_pc_images_num', $_POST['images_num']);
		update_option('wpbh_pc_rellinks', $_POST['rellinks']);
		update_option('wpbh_pc_linklist', $_POST['linklist']);
		update_option('wpbh_pc_bpoints', $_POST['bpoints']);
		update_option('wpbh_pc_r_bi', $_POST['r_bi']);
		wpbh_pc_gen_posts();
	}

	$path = dirname(__FILE__). "/files/";
	$cats = array();
	$cats = get_categories('hide_empty=0');

	echo '<div id="wpbody">';
	echo '<div class="wrap">';
	echo '<h2>Post Creator 2.3</h2>';
	echo '<form method="post" >';		
	echo '<table class="form-table">';

	echo '<tr><th scope="row"><label for="cgrade">Categoy: </label></th><td><select name="wpbh_cat">';	
		foreach($cats as $category) { 
			echo '<option value="' . $category->cat_ID . '"' . ((get_option('wpbh_pc_cat') == $category->cat_ID)?' selected':'') .   ' />' . $category->cat_name;   	 
		} 
		echo '</select></td></tr> ';	



	echo '<tr><th scope="row">Date: </label></th>';

	echo '<td><select name="date">';

	echo '<option value="0"' . ((get_option('wpbh_pc_date') == 0)?' selected':'') .   ' />-5 Years';

	echo '<option value="1"' . ((get_option('wpbh_pc_date') == 1)?' selected':'') .   ' />-3 Years';

	echo '<option value="2"' . ((get_option('wpbh_pc_date') == 2)?' selected':'') .   ' />-2 Years';

	echo '<option value="3"' . ((get_option('wpbh_pc_date') == 3)?' selected':'') .   ' />-1 Year';

	echo '<option value="4"' . ((get_option('wpbh_pc_date') == 4)?' selected':'') .   ' />-6 Months';

	echo '<option value="5"' . ((get_option('wpbh_pc_date') == 5)?' selected':'') .   ' />-3 Months';

	echo '<option value="6"' . ((get_option('wpbh_pc_date') == 6)?' selected':'') .   ' />-2 Months';

	echo '<option value="7"' . ((get_option('wpbh_pc_date') == 7)?' selected':'') .   ' />-1 Month';

	echo '<option value="8"' . ((get_option('wpbh_pc_date') == 8)?' selected':'') .   ' />-3 Weeks';

	echo '<option value="9"' . ((get_option('wpbh_pc_date') == 9)?' selected':'') .   ' />-2 Weeks';

	echo '<option value="10"' . ((get_option('wpbh_pc_date') == 10)?' selected':'') .   ' />-1 Week';

	echo '<option value="11"' . ((get_option('wpbh_pc_date') == 11)?' selected':'') .   ' />Today';

	echo '<option value="12"' . ((get_option('wpbh_pc_date') == 12)?' selected':'') .   ' />+1 Week';

	echo '<option value="13"' . ((get_option('wpbh_pc_date') == 13)?' selected':'') .   ' />+2 Weeks';

	echo '<option value="14"' . ((get_option('wpbh_pc_date') == 14)?' selected':'') .   ' />+3 Weeks';

	echo '<option value="15"' . ((get_option('wpbh_pc_date') == 15)?' selected':'') .   ' />+1 Month';

	echo '<option value="16"' . ((get_option('wpbh_pc_date') == 16)?' selected':'') .   ' />+2 Months';

	echo '<option value="17"' . ((get_option('wpbh_pc_date') == 17)?' selected':'') .   ' />+3 Months ';

	echo '<option value="18"' . ((get_option('wpbh_pc_date') == 18)?' selected':'') .   ' />+6 Months';

	echo '<option value="19"' . ((get_option('wpbh_pc_date') == 19)?' selected':'') .   ' />+1 Year';

	echo '<option value="20"' . ((get_option('wpbh_pc_date') == 20)?' selected':'') .   ' />+2 Years';

	echo '</select></td></tr>';


	echo '<tr><th scope="row"><label for="cgrade">Random Bolding/Italics of Keywords:</label></th><td>';
	echo '<select name="r_bi">';
	echo '<option value="0"' . ((get_option('wpbh_pc_r_bi') == 0)?' selected':'') .   ' />No';
	echo '<option value="1"' . ((get_option('wpbh_pc_r_bi') == 1)?' selected':'') .   ' />Yes';
	echo '</select></td></tr>';


	$dir_handle = @opendir($path) or die("Unable to open $path");
	$folders = '<option  value="No File" ' . ((get_option('wpbh_pc_els') == "No File")?' selected':'') .   '  >No File</option><br>';
	while ($file = readdir($dir_handle))
		{
			if (get_option('wpbh_pc_els')==$file) $selected="selected";
			else $selected="";
			if($file!='.' && $file!='..')
			$folders .= '<option value="' . $file . '"' . $selected .   '>' . $file . '</option><br>';
		}
	closedir($dir_handle);
	$thebox = '<select  name="wpbh_els">' . $folders . '</select>';	
	echo '<tr><th scope="row"><label for="cgrade">Internal/External Links: </label></th><td>';	
	echo $thebox;		
	echo '';
	echo ' Number of Internal/External Links to Add to Posts:';
	echo '<select name="els_num">';
	echo '<option value="0"' . ((get_option('wpbh_pc_els_num') == 0)?' selected':'') .   ' />0';
	echo '<option value="1"' . ((get_option('wpbh_pc_els_num') == 1)?' selected':'') .   ' />0 to 1';
	echo '<option value="2"' . ((get_option('wpbh_pc_els_num') == 2)?' selected':'') .   ' />0 to 2';
	echo '<option value="3"' . ((get_option('wpbh_pc_els_num') == 3)?' selected':'') .   ' />0 to 3';
	echo '<option value="4"' . ((get_option('wpbh_pc_els_num') == 4)?' selected':'') .   ' />1 to 2';
	echo '<option value="5"' . ((get_option('wpbh_pc_els_num') == 5)?' selected':'') .   ' />1 to 3';
	echo '<option value="6"' . ((get_option('wpbh_pc_els_num') == 6)?' selected':'') .   ' />1 to 4';
	echo '<option value="7"' . ((get_option('wpbh_pc_els_num') == 7)?' selected':'') .   ' />2 to 5';;
	echo '</select></td></tr>';

		$dir_handle = @opendir($path) or die("Unable to open $path");
	$folders = '<option  value="No File" ' . ((get_option('wpbh_pc_ytv') == "No File")?' selected':'') .   '  >No File</option><br>';
	while ($file = readdir($dir_handle))
		{
			if (get_option('wpbh_pc_ytv')==$file) $selected="selected";
			else $selected="";
			if($file!='.' && $file!='..')
			$folders .= '<option value="' . $file . '"' . $selected .   '>' . $file . '</option><br>';
		}
	closedir($dir_handle);
	$thebox = '<select  name="wpbh_ytv">' . $folders . '</select>';	
	echo '<tr><th scope="row"><label for="cgrade">Youtube Videos: </label></th><td>';	
	echo $thebox;		
	echo '';
	echo ' Number of Youtube Videos to Add to Posts:';
	echo '<select name="yt_num">';
	echo '<option value="0"' . ((get_option('wpbh_pc_yt_num') == 0)?' selected':'') .   ' />0';
	echo '<option value="1"' . ((get_option('wpbh_pc_yt_num') == 1)?' selected':'') .   ' />0 to 1';
	echo '<option value="2"' . ((get_option('wpbh_pc_yt_num') == 2)?' selected':'') .   ' />0 to 2';
	echo '<option value="3"' . ((get_option('wpbh_pc_yt_num') == 3)?' selected':'') .   ' />1 to 2';
	echo '<option value="4"' . ((get_option('wpbh_pc_yt_num') == 4)?' selected':'') .   ' />1 to 3';
	echo '</select></td></tr>';


	$dir_handle = @opendir($path) or die("Unable to open $path");
	$folders = '<option  value="No File" ' . ((get_option('wpbh_pc_imgs') == "No File")?' selected':'') .   '  >No File</option><br>';
	while ($file = readdir($dir_handle))
		{
			if (get_option('wpbh_pc_imgs')==$file) $selected="selected";
			else $selected="";
			if($file!='.' && $file!='..')
			$folders .= '<option value="' . $file . '"' . $selected .   '>' . $file . '</option><br>';
		}
	closedir($dir_handle);
	$thebox = '<select  name="wpbh_imgs">' . $folders . '</select>';	
	echo '<tr><th scope="row"><label for="cgrade">Images: </label></th><td>';	
	echo $thebox;		
	echo '';
	echo ' Number of Images to Add to Posts:';
	echo '<select name="images_num">';
	echo '<option value="0"' . ((get_option('wpbh_pc_images_num') == 0)?' selected':'') .   ' />0';
	echo '<option value="1"' . ((get_option('wpbh_pc_images_num') == 1)?' selected':'') .   ' />0 to 1';
	echo '<option value="2"' . ((get_option('wpbh_pc_images_num') == 2)?' selected':'') .   ' />0 to 2';
	echo '<option value="3"' . ((get_option('wpbh_pc_images_num') == 3)?' selected':'') .   ' />1 to 2';
	echo '<option value="4"' . ((get_option('wpbh_pc_images_num') == 4)?' selected':'') .   ' />1 to 3';
	echo '</select></td></tr>';



	$dir_handle = @opendir($path) or die("Unable to open $path");
	$folders = '';
	while ($file = readdir($dir_handle))
		{
			if (get_option('wpbh_pc_arts')==$file) $selected="selected";
			else $selected="";
			if($file!='.' && $file!='..')
			$folders .= '<option value="' . $file . '"' . $selected .   '>' . $file . '</option><br>';
		}
	closedir($dir_handle);
	$thebox = '<select  name="wpbh_arts">' . $folders . '</select>';	
	echo '<tr><th scope="row"><label for="cgrade">Articles : </label></th><td>';	
	echo $thebox;		
	echo '</td></tr> ';

	echo '<tr><th scope="row">Article Size: </label></th>';
	echo '<td><select name="artsize">';
	echo '<option value="0"' . ((get_option('wpbh_pc_artsize') == 0)?' selected':'') .   ' />small';
	echo '<option value="1"' . ((get_option('wpbh_pc_artsize') == 1)?' selected':'') .   ' />medium';
	echo '<option value="2"' . ((get_option('wpbh_pc_artsize') == 2)?' selected':'') .   ' />large';
	echo '<option value="3"' . ((get_option('wpbh_pc_artsize') == 3)?' selected':'') .   ' />very large';
	echo '<option value="4"' . ((get_option('wpbh_pc_artsize') == 4)?' selected':'') .   ' />small to medium';
	echo '<option value="5"' . ((get_option('wpbh_pc_artsize') == 5)?' selected':'') .   ' />small to large';
	echo '<option value="6"' . ((get_option('wpbh_pc_artsize') == 6)?' selected':'') .   ' />medium to large';
	echo '<option value="7"' . ((get_option('wpbh_pc_artsize') == 7)?' selected':'') .   ' />medium to very large';
	echo '<option value="8"' . ((get_option('wpbh_pc_artsize') == 8)?' selected':'') .   ' />large to very large';
	echo '</select></td></tr>';

	echo '<tr><th scope="row">Add a List of Links to Posts: </label></th>';
	echo '<td><select name="linklist">';
	echo '<option value="0"' . ((get_option('wpbh_pc_linklist') == 0)?' selected':'') .   ' />0% of the time';
	echo '<option value="1"' . ((get_option('wpbh_pc_linklist') == 1)?' selected':'') .   ' />20% of the time';
	echo '<option value="2"' . ((get_option('wpbh_pc_linklist') == 2)?' selected':'') .   ' />40% of the time';
	echo '<option value="3"' . ((get_option('wpbh_pc_linklist') == 3)?' selected':'') .   ' />60% of the time';
	echo '<option value="4"' . ((get_option('wpbh_pc_linklist') == 4)?' selected':'') .   ' />80% of the time';
	echo '<option value="5"' . ((get_option('wpbh_pc_linklist') == 5)?' selected':'') .   ' />100% of the time';
	echo '</select>';


	echo ' Related Links Title:';
	echo '<input name="rellinks" type="text" value="' . get_option('wpbh_pc_rellinks')  . '" size="40" />';
	echo '</td></tr>';

	echo '<tr><th scope="row">Add Bullet Points to Posts: </label></th>';
	echo '<td><select name="bpoints">';
	echo '<option value="0"' . ((get_option('wpbh_pc_bpoints') == 0)?' selected':'') .   ' />0% of the time';
	echo '<option value="1"' . ((get_option('wpbh_pc_bpoints') == 1)?' selected':'') .   ' />10% of the time';
	echo '<option value="2"' . ((get_option('wpbh_pc_bpoints') == 2)?' selected':'') .   ' />40% of the time';
	echo '<option value="3"' . ((get_option('wpbh_pc_bpoints') == 3)?' selected':'') .   ' />60% of the time';
	echo '<option value="4"' . ((get_option('wpbh_pc_bpoints') == 4)?' selected':'') .   ' />80% of the time';
	echo '<option value="5"' . ((get_option('wpbh_pc_bpoints') == 5)?' selected':'') .   ' />100% of the time';
	echo '</select></td></tr>';

	echo '<tr><th scope="row">Spinnable Titles:</th>';
	echo '<td><textarea name="keywords" rows="11" style="width:60%;">' . stripslashes(get_option('wpbh_pc_keywords')) . '</textarea>';
	echo '<br><br></td>';

	echo '</tr>';
	
	echo '<input type="hidden" name="update" value="yes" />';

	echo ' </table>';

	echo '<br><form method="post">';

	echo '<input type="submit" value="Generate Posts" style="height: 5.5em; width: 10em" />';

	echo '</form>';	

	echo '<br><br><center><br><b>Copyright 2011 <a href="http://wpblackhat.com/">WPBlackhat</a> - All Rights Reseverved! Distribution Strictly Forbidden!</b></center></div></div></center>';

    }


    function _to_admin() { 
	add_menu_page('Page title', 'Post Creator', 'manage_options', 'Post Creator', 'wpbh_pc_editor');
    }



    if (function_exists('add_action')) {
	add_action('admin_menu', '_to_admin');
    }

    ?>



this code i downloaded from the net..
