CyberGlitch
Junior Member
- May 27, 2009
- 149
- 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.
- 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.
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));?>