Exemplo n.º 1
0
function stupidbot_update_db_check()
{
    global $stupidbot_db_version;
    if (get_option('stupidbot_db_version') != $stupidbot_db_version) {
        Stupidbot_Campaign::create_table();
    }
}
Exemplo n.º 2
0
<?php

$campaigns = Stupidbot_Campaign::all();
$campaigns_count = Stupidbot_Campaign::count();
?>
 <div class="bootstrap-wpadmin">
  <h2>StupidBot</h2>
    <div class="row">
      <div class="span12">
        <?php 
if ($this->alert) {
    ?>
          <div class="alert alert-success">
            <?php 
    echo $this->alert;
    ?>
          </div>
        <?php 
}
?>
        <?php 
if ($campaigns_count < 1) {
    ?>
          <div class="alert alert-warning">
            No campaign, please make a <a data-toggle="modal" href="#new_campaign" class="">new campaign</a>.
          </div>
        <?php 
}
?>
      </div>
    </div>
Exemplo n.º 3
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.";
     }
 }