Announcement

Collapse
No announcement yet.

how do i cron....

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • how do i cron....

    I want VB to do the update counters/update forum info
    once a day! how can i do this?
    from the scheduled operations page maybe! but what do I call?? I cant call a function from there!

  • #2
    Have you browsed through the online manual > Scheduled Tasks

    Introduction to Scheduled Tasks
    Managing Scheduled Tasks
    Adding or Editing a Scheduled Task
    Scheduled Task Log

    Comment


    • #3
      yes i have!
      in this case i knew I had to put something here.
      but in the field: filename I dont know what file to put? as far as i know to run the updateCounters I have to run the functions_databuild.php file, function "build_forum_counters()"

      there is probably another script i can call, but from the scheduled operations i cant tell it to run a function. i can tell it to run a php file....or am i wrong?

      Comment


      • #4
        Here is untested, unofficial script that you could try.

        Make a new file counter.php and place it in the cron directory.

        PHP Code:
        <?php
        /* ----- vb301 cron script to auto update counters ------
            unofficial and untested
        */
        require_once('./includes/functions_databuild.php');
        build_forum_counters();
        log_cron_action('Counters Updated'$nextitem);
        ?>

        Comment


        • #5
          unofficial and untested
          sound ominous!!

          ok, i'll try this script and see if it works or not? thank you!

          Comment


          • #6
            Good luck testing.

            I just thought I'd mention it to avoid the script being called or viewed by users as 'official jelsoft script that went through beta testing'.

            Comment


            • #7
              well i tried...
              no, it doesnt work, the function "build_forum_counters();" takes the forumid as a parameter....
              i'll see if i can modify it to get the forum id!

              also
              "log_cron_action" gives an error... 'call to undefined function'
              there is probably an include needed to run this!

              Comment


              • #8
                alternative:
                is it possible to do an add scheduled task, and tell it to run this file..

                admincp/misc.php?do=updateforum&startat=0&perpage=100

                think this might work?

                Comment


                • #9
                  Originally posted by pussySniper
                  well i tried...
                  no, it doesnt work, the function "build_forum_counters();" takes the forumid as a parameter....
                  i'll see if i can modify it to get the forum id!

                  also
                  "log_cron_action" gives an error... 'call to undefined function'
                  there is probably an include needed to run this!
                  Uhm, oh well - we tried. Maybe the 'hackers' on vbulletin.org know the proper coding for this

                  Comment


                  • #10
                    Why do you want to update counters every hour anyway?

                    Comment


                    • #11
                      ok, i got it done, hacked the code from misc.php
                      in my own script and it works!
                      would anyone like to see the code???

                      Comment


                      • #12
                        Well, the question still stands why you would want to update the counters manually every day. There is no need for that unless you hacked your board or you delete posts from within the database.

                        Comment


                        • #13
                          I don't mind seeing what code you currently use.
                          I am happy you got it working!

                          Comment


                          • #14
                            Well, the question still stands why you would want to update the counters manually every day. There is no need for that unless you hacked your board or you delete posts from within the database.
                            well because i dont create the forums from VB3, they are created for another part of the website, and then imported to VB3 automatically! and i need to update the counters everytime i import something, else it wont show!

                            Comment


                            • #15
                              Its basically the misc.php/ do=updateforum with a few modifications to it to make it work!

                              PHP Code:
                              <?php
                              /*
                                updateCounters.php
                              */
                              require_once ('./global.php');
                              require_once(
                              './includes/functions_databuild.php');
                                
                              $finishat $startat $perpage;
                               if (empty(
                              $perpage))
                               {
                                
                              $perpage 100;
                                
                              $startat 0;
                                
                              $finishat $startat $perpage;
                               }
                               echo 
                              '<p>' $vbphrase['updating_forums'] . '</p>';
                               
                              $forums $DB_site->query("
                                SELECT forumid
                                FROM " 
                              TABLE_PREFIX "forum
                                WHERE forumid >= 
                              $startat AND
                                 forumid < 
                              $finishat
                                ORDER BY forumid DESC
                               "
                              );
                               while(
                              $forum $DB_site->fetch_array($forums))
                               {
                                
                              build_forum_counters($forum['forumid']);
                                echo 
                              construct_phrase($vbphrase['processing_x'], $forum['forumid']) . "<br />\n";
                                
                              flush();
                               }
                               if (
                              $checkmore $DB_site->query_first("SELECT forumid FROM " TABLE_PREFIX "forum WHERE forumid >= $finishat LIMIT 1"))
                               {
                                
                              $finishat $startat $perpage;
                                
                              print_cp_redirect("updateCounters.php?$session[sessionurl]do=updateforum&startat=$finishat&perpage=$perpage");
                                echo 
                              "<p><a href=\"updateCounters.php?$session[sessionurl]do=updateforum&amp;startat=$finishat&amp;perpage=$perpage\">" $vbphrase['click_here_to_continue_processing'] . "</a></p>";
                               }
                               else
                               {
                                
                              // get rid of "ghost" moderators who are not attached to a valid forum
                                
                              $deadmods $DB_site->query("
                                 SELECT moderatorid
                                 FROM " 
                              TABLE_PREFIX "moderator AS moderator
                                 LEFT JOIN " 
                              TABLE_PREFIX "forum AS forum USING (forumid)
                                 WHERE forum.forumid IS NULL
                                "
                              );
                                
                              $mods '';
                                while (
                              $mod $DB_site->fetch_array($deadmods))
                                {
                                 if (!empty(
                              $mods))
                                 {
                                  
                              $mods .= ' , ';
                                 }
                                 
                              $mods .= $mod['moderatorid'];
                                }
                                if (!empty(
                              $mods))
                                {
                                 
                              $DB_site->query("DELETE FROM " TABLE_PREFIX "moderator WHERE moderatorid IN (" $mods ")");
                                }
                                
                              // and finally rebuild the forumcache
                                
                              unset($forumarraycache$forumcache);
                                
                              build_forum_permissions();
                                
                              define('CP_REDIRECT''index.php');
                                
                              print_stop_message('updated_forum_successfully');
                               }
                               
                              ?>

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...
                              X