Exemplo n.º 1
0
 public function run($id)
 {
     $campaign = (array) Stupidbot_Campaign::find($id);
     require_once ABSPATH . "wp-includes" . '/pluggable.php';
     require_once ABSPATH . "wp-admin" . '/includes/image.php';
     require_once ABSPATH . "wp-admin" . '/includes/file.php';
     require_once ABSPATH . "wp-admin" . '/includes/media.php';
     if (!class_exists('h2o')) {
         require_once SPP_PATH . '/templates/h2o/h2o.php';
         foreach (glob(SPP_PATH . "/includes/*.php") as $filename) {
             require $filename;
         }
     }
     $settings = $this->stupidbot->get_settings();
     if ($campaign['id']) {
         $keywords = explode("\n", $campaign['keywords']);
         //print_r($keywords);
         if (count($keywords > 0)) {
             shuffle($keywords);
             $keywords = array_slice($keywords, 0, $campaign['count']);
         } else {
             $alert = "got empty keyword, aborting";
             return $alert;
         }
         $posted = "";
         foreach ($keywords as $keyword) {
             $stupidbot_settings = $this->stupidbot->get_settings();
             $title = $stupidbot_settings['clean_title'] ? ucwords($keyword) : $keyword;
             $this->stupidbot->alert .= $this->post_exist($title) ? $title . ' exist, not posting.<br>' : $title . ' not exists, posting.<br>';
             if ($this->post_exist($title) < 1) {
                 $catnow = $campaign['category_id'];
                 $my_post = array('post_title' => $title, 'post_content' => spp($keyword, $campaign['template'], $campaign['hack']), 'post_status' => 'publish', 'post_author' => 1, 'post_category' => array($catnow));
                 $mypost_id = wp_insert_post($my_post);
                 $posted .= $title . ' posted! <a href="' . get_permalink($mypost_id) . '" target="_blank">View Post</a><br>';
             }
             $campaign['counter']++;
         }
         Stupidbot_Campaign::update($campaign);
         $this->stupidbot->alert .= "<br>" . $posted;
     } else {
         $this->stupidbot->alert .= "Error: Campaign not found.";
     }
 }