author | Dan Fuhry <dan@enanocms.org> |
Fri, 19 Nov 2010 03:30:35 -0500 | |
changeset 1329 | 61d87ee12e80 |
parent 1227 | bdac73ed481e |
permissions | -rw-r--r-- |
191
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
1 |
<?php |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
2 |
|
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
3 |
/* |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
4 |
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between |
1081
745200a9cc2a
Fixed some upgrade bugs; added support for choosing one's own date/time formats; rebrand as 1.1.7
Dan
parents:
945
diff
changeset
|
5 |
* Copyright (C) 2006-2009 Dan Fuhry |
191
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
6 |
* |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
7 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
8 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
9 |
* |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
11 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
12 |
*/ |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
13 |
|
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
14 |
// |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
15 |
// cron.php - Maintenance tasks that should be run periodically |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
16 |
// |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
17 |
|
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
18 |
// The cron script is triggered by way of an image. This is a 1x1px transparent GIF. |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
19 |
define('ENANO_GIF_SPACER', base64_decode('R0lGODlhAQABAIAAAP///////yH+FUNyZWF0ZWQgd2l0aCBUaGUgR0lNUAAh+QQBCgABACwAAAAAAQABAAACAkwBADs=')); |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
20 |
|
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
21 |
// Don't need a page to load, all we should need is the Enano API |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
22 |
require('includes/common.php'); |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
23 |
|
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
24 |
global $db, $session, $paths, $template, $plugins; // Common objects |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
25 |
|
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
26 |
// Hope now that plugins are loaded :-) |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
27 |
global $cron_tasks; |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
28 |
|
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
29 |
foreach ( $cron_tasks as $interval => $tasks ) |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
30 |
{ |
1227
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
31 |
$interval = doubleval($interval); |
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
32 |
$last_run = intval(getConfig("cron_lastrun_ivl_$interval")); |
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
33 |
$last_run_threshold = doubleval(time()) - ( 3600.0 * $interval ); |
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
34 |
if ( $last_run_threshold >= $last_run ) |
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
35 |
{ |
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
36 |
foreach ( $tasks as $task ) |
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
37 |
{ |
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
38 |
call_user_func($task); |
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
39 |
} |
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
40 |
setConfig("cron_lastrun_ivl_$interval", strval(time())); |
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
41 |
} |
191
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
42 |
} |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
43 |
|
542
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
44 |
$expiry_date = date('r', get_cron_next_run()); |
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
45 |
|
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
46 |
$etag = sha1($expiry_date); |
672
08a7875258b4
Added tab-based interface to userpage UI. Yes, it is plugin expansible, and yes, it breaks existing plugins that add code to the userpage (but that can be fixed with a "colspan=4")
Dan
parents:
542
diff
changeset
|
47 |
|
542
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
48 |
if ( isset($_SERVER['HTTP_IF_NONE_MATCH']) ) |
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
49 |
{ |
1227
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
50 |
if ( "\"$etag\"" == $_SERVER['HTTP_IF_NONE_MATCH'] ) |
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
51 |
{ |
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
52 |
header('HTTP/1.1 304 Not Modified'); |
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
53 |
exit(); |
bdac73ed481e
Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents:
1081
diff
changeset
|
54 |
} |
542
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
55 |
} |
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
56 |
|
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
57 |
header("ETag: $etag"); |
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
58 |
|
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
59 |
header('Expires: ' . $expiry_date); |
191
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
60 |
header('Content-type: image/gif'); |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
61 |
|
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
62 |
echo ENANO_GIF_SPACER; |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
63 |
|
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
diff
changeset
|
64 |
?> |