1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WPRobot v2 cron job fix

Discussion in 'Blogging' started by CyberGlitch, May 19, 2010.

  1. CyberGlitch

    CyberGlitch Junior Member

    Joined:
    May 27, 2009
    Messages:
    149
    Likes Received:
    43
    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));?>
     
    • Thanks Thanks x 15
  2. CyberGlitch

    CyberGlitch Junior Member

    Joined:
    May 27, 2009
    Messages:
    149
    Likes Received:
    43
    wow, no one cares. Ok, will keep the rest of my hacks to myself then.
     
  3. bokon

    bokon Newbie

    Joined:
    Jun 14, 2009
    Messages:
    46
    Likes Received:
    2
    I care. Hostgaytor froze all of my WProbots. This helps a lot. Thanks!
     
  4. deakanutz

    deakanutz Newbie

    Joined:
    Jan 11, 2010
    Messages:
    8
    Likes Received:
    1
    How do you like V3? I have hostgator will it kill my account?
     
  5. CyberGlitch

    CyberGlitch Junior Member

    Joined:
    May 27, 2009
    Messages:
    149
    Likes Received:
    43
    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.
     
  6. zorroplateado

    zorroplateado Newbie

    Joined:
    Feb 27, 2008
    Messages:
    1
    Likes Received:
    0
    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.
     
  7. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    788
    Likes Received:
    3,127
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    search this forum for wprobot3 and read the complaints. they didn't test this script and it has problems.
     
  8. Triads

    Triads Newbie

    Joined:
    Jan 16, 2010
    Messages:
    5
    Likes Received:
    3
    stiil confuse to add datetime default value. :(
    heres the picture. please let me know the correct input.

    [​IMG]
     
  9. CyberGlitch

    CyberGlitch Junior Member

    Joined:
    May 27, 2009
    Messages:
    149
    Likes Received:
    43
    Looks good.
     
  10. safety101

    safety101 Newbie

    Joined:
    May 25, 2010
    Messages:
    24
    Likes Received:
    0
    Can someone explain this? It's hard for me to understand
     
  11. icoon

    icoon Newbie

    Joined:
    May 22, 2010
    Messages:
    7
    Likes Received:
    0
    Oh my!!

    Thank you A LOTTTTTTTTT

    What a perfect fix!! :rocketwho
     
  12. Triads

    Triads Newbie

    Joined:
    Jan 16, 2010
    Messages:
    5
    Likes Received:
    3
    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.
     
  13. Triads

    Triads Newbie

    Joined:
    Jan 16, 2010
    Messages:
    5
    Likes Received:
    3
    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
    [​IMG]

    Fill its like below

    [​IMG]

    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.
     
    • Thanks Thanks x 3
    Last edited: May 28, 2010
  14. muggs101

    muggs101 Registered Member

    Joined:
    Apr 10, 2010
    Messages:
    59
    Likes Received:
    12
    Thanks for this, its a real life saver since going on two weeks without a resolution until now.
     
  15. TrafficTiger

    TrafficTiger Newbie

    Joined:
    Jan 16, 2010
    Messages:
    28
    Likes Received:
    2
    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
     
  16. CyberGlitch

    CyberGlitch Junior Member

    Joined:
    May 27, 2009
    Messages:
    149
    Likes Received:
    43
    None of the lines of code or files are going to match up with your plugin. It's all going to be different.
     
  17. johnsmith

    johnsmith Newbie

    Joined:
    Mar 31, 2009
    Messages:
    29
    Likes Received:
    1
    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?
     
  18. skindu26

    skindu26 Junior Member

    Joined:
    Dec 4, 2007
    Messages:
    167
    Likes Received:
    31
    Home Page:
    does this code effective for wp robot v3. too.

    i'll be glad if you could share a hack for cron job in wprobot v3.1
     
  19. linkchamp

    linkchamp Regular Member

    Joined:
    Mar 3, 2010
    Messages:
    256
    Likes Received:
    32
    Occupation:
    SEO Consultant
    Location:
    BHW
    I am using V3 on hostgator on many sites i do not have any problem yet.
     
  20. kevin09

    kevin09 Jr. VIP Jr. VIP Premium Member

    Joined:
    Sep 15, 2008
    Messages:
    131
    Likes Received:
    58
    Location:
    St.Pete , FL
    Great Post Thanks