WPRobot v2 cron job fix

CyberGlitch

Junior Member
Joined
May 27, 2009
Messages
149
Reaction score
44
As some of you may know the autopost feature in WPRobot v2 can be flaky and on top of that some hosts are turning on wp-cron which is what WPRobot uses to post on a schedule. This ultimately makes WPRobot useless.

I've also got WPRobot V3 and it has a new feature where you can use true cron jobs to trigger the postings and it works a lot better and more reliable. Well I didn't want to go back and ugprade all my older autoblogs so I can up with a patch so V2 can also use regular cron jobs. This requires a couple changes and new files and also a change to the database so if you are not familar with PHP and mySQL then tread lightly.

First lets setup the database to work with this fix.
- Use something like phpMyAdmin to login to your database.
- Find the table ***_wprobot
- Edit the structure and add a new column called nextrun and set it as a DATETIME Default value of 0000-00-00 00:00:00 and not null

Pretty simple and basic. This new column will hold the information for each keyword and when the next trigger will be.

New cron file.
- Copy and paste the below code into a new file called cron.php in the root of your WPRobot directory.
Code:
<?php
 
 require_once(dirname(__FILE__) . '/../../../wp-config.php');
 
 nocache_headers();
 
 if(isset($_REQUEST['code']) && $_REQUEST['code'] == '12345') {
 
  require_once( dirname(__FILE__) . '/general.php' );  
 
  $records = $wpdb->get_results("SELECT * FROM " . $ma_dbtable . " ORDER BY id ASC"); 
  if ($records) {
   foreach ($records as $record) { 
    $time = ma_get_string_between($record->postspan, "MA_", "_");
      $pos = strpos($record->postspan, 'days');
      if ($pos === false) {
       $span = "hours";
      } else {
       $time = $time*24;
       $span = "days";
      } 
    $today = date("Y-m-d H:m:s");
 
    $nextrun = date("Y-m-d H:m:s",strtotime($record->nextrun));
 
    //print('// '.$today.' -- '. $nextrun);
 
    if($today > $nextrun) {
 
     $newdate = date("Y-m-d H:m:s",strtotime('+'.$time.' hour'));
     //print('//'.$record->id.'  ' .$today.' --'.$time.'  '.$newdate);
     $sql = "UPDATE " . $ma_dbtable . " SET `nextrun` = '$newdate' WHERE id = '$record->id'";
     $update = $wpdb->query($sql);
 
     ma_post($record->id);
    }
   }
  }
 }

- change 12345 to be whatever secret code you want to use.


Now you can create a hourly cron job to point at this file.
- Set a cron job to run hourly
- Run the command wget 'http:///YOURDOMAIN.COM/wp-content/plugins/WPRobot/cron.php?code=12345
- Change 12345 to be whatever code you put in the above file.
- The code is so only you can trigger the file and prevents someone else from triggering your file every minute and getting your account suspended.


That's it! Now every hour that cron job will trigger the above script. The script will check when each keyword needs to be triggered. It'll autopost ones that are up for a post and then update the next run to be x hours/days in the future.


If you want the admin panel to reflect this new feature you can also change the following in your wprobot.php file.
Aprox line 862 will have some different date information that no longer works. Replace it with this code instead.
Code:
<?php echo date("Y-m-d H:m:s",strtotime($record->nextrun));?>
 
wow, no one cares. Ok, will keep the rest of my hacks to myself then.
 
I care. Hostgaytor froze all of my WProbots. This helps a lot. Thanks!
 
I like v3, just takes some time to learn the new templates and campaigns.

Won't kill your account on hostgator, they will just disable wp-cron. So then you have to use the normal cron job that comes with v3 or if you have v2 use my above hack.
 
This is so important !!!!, and I think this problem is similar to the famous "MISSED SCHEDULE" that have been around in all versions of wordpress and nobody even wp.org have come out with a reasonable solution to the cronjob.
 
stiil confuse to add datetime default value. :(
heres the picture. please let me know the correct input.

7fx1tijwo8nc0a3ze3b.jpg
 
Oh my!!

Thank you A LOTTTTTTTTT

What a perfect fix!! :rocketwho
 
after first try, i failed to its. After looking your post again, than i know whats wrong with its. Now the cron job doing nicely.
 
Step by step:
1. Login into your cpanel

2. Open PHPmyAdmin search your WP database something like this yourusername_wrdp1 open its, open wp_wprobot table, click structure. add new column see picture
1dxc8le57ifrwjl7tbqn.jpg


Fill its like below

xn99x2flcas61bl0cjb1.jpg


3. Now create Cyberglith cron.php scripts and upload its with ftp into following folder
wp-content/plugins/WPRobot/

4. Open Cpanel, click cron job. Add new cron job like in picture. in command place line like this wget
Code:
http://YOURDOMAIN.COM/wp-content/plugins/WPRobot/cron.php?code=12345[code] [/COLOR][/B] *remove [B][COLOR="red"][code][/COLOR][/B]

[IMG]http://imagesboom.com/images/p3hii161qieh6hdh54g9.jpg[/IMG]

Thanks to Cyberglitch for this.
 
Last edited:
Thanks for this, its a real life saver since going on two weeks without a resolution until now.
 
Due to CPU overloads, I'm about ready to quit autoblogging. This patch might make the difference, and I'd like to try it. My problem is I'm using WPInsider, a free clone of WPRobot, and I'm afraid my programming skills won't make the switch.

Modifying the db table didn't seem to be a problem; mine is called wp_wpinsder. I don't see in the script where the table is identified.

I suspect changes would have to be made in the script, but I'm not sure. For example, I don't see a general.php; is that part of WPRobot?

Finally, you refer to a line 862, and the comparable file in WPInsider has only 123 lines. It has lots of "includes" which probably accounts for the difference. It also makes me think I'd better quit fiddling with the code!

TT
 
None of the lines of code or files are going to match up with your plugin. It's all going to be different.
 
Ok, here it comes guys! I see you all are so advanced users and auto-bloggers, So, my question is how many full loaded, with all plugins activated, auto-blogs can you run in a regular hosting account without overload it? As I see it every plugin counts, every tweet counts, every keyword that has problem in creating a post is delaying or even stops the account from working properly. So, Can anyone tell what are the best requirements for successful auto-blogging?
 
Back
Top