root/devel/cron.php

Revision 1447, 1.9 kB (checked in by rho, 1 year ago)

fixed multiple issues

  • walledgarden access on some pages
  • empty comment on commentwall
  • added community profile permission check
  • corrected paths on templates edit
  • blog widget display issue

Signed-off: Rolando Espinoza La fuente <rho@prosoftpeople.com>

  • Property svn:eol-style set to native
Line 
1 <?php
2
3 // very basic cron functionality.
4 // later this will go through /mod
5 // and things like auth plugins
6 // but we don't have those yet, so...
7
8 define('context','external');
9
10 $starttime = microtime();
11
12 require_once(dirname(__FILE__)."/includes.php");
13
14 $timenow  = time();
15
16 mtrace("<pre>");
17 mtrace("Server Time: ".date('r',$timenow)."\n\n");
18
19 $lastcron = $CFG->lastcron;
20 if (empty($lastcron)) {
21     $lastcron = 0;
22 }
23
24 // we only want to do this once a day because it could take awhile...
25 if ($timenow - (60*60*24) > $lastcron) {
26     mtrace('Cleaning up old incoming files... ','');
27     // clean up the lms incoming files
28     delete_records_select('files_incoming','intentiondate < ?',array(time()-60*60*24));
29
30     $dirtocheck = $CFG->dataroot.'temp/lms/';   
31     $cmd = "find $dirtocheck -type d -cmin 1440 -print0 | xargs -0 -r rm -rf";
32     exec($cmd);
33     
34     $dirtocheck = $CFG->dataroot.'lms/incoming';
35     // this is not going to work unless this script is running as either the owner of these files
36     // or root.
37     $cmd = "find $dirtocheck -type d -cmin 1440 -print0 | xargs -0 -r rm -rf";
38     exec($cmd);
39
40     mtrace('done');
41 }
42
43 // module cron
44 if ($mods = get_list_of_plugins()) {
45     foreach ($mods as $mod) {
46         $libfile = $CFG->dirroot.'mod/'.$mod.'/lib.php';
47         if (!file_exists($libfile)) {
48             continue;
49         }
50         require_once($libfile);
51         $cronfunction = $mod.'_cron';
52         if (!function_exists($cronfunction)) {
53             continue;
54         }
55         // each module is responsible for checking their last runtime and not running again if it's too soon.
56         mtrace('Running cron for '.$mod.'...','');
57         $cronfunction();
58         mtrace('Done');
59     }
60 }
61
62
63 if (!set_config('lastcron',$timenow)) {
64     mtrace('Could not update last cron time to now!');
65 }
66
67 mtrace("Cron script completed correctly");
68
69 $difftime = microtime_diff($starttime, microtime());
70 mtrace("Execution took ".$difftime." seconds");
71
72 ?>
Note: See TracBrowser for help on using the browser.