]> git.mxchange.org Git - friendica.git/blob - include/expire.php
Make sure that we only quit when we are sure we can
[friendica.git] / include / expire.php
1 <?php
2
3 use \Friendica\Core\Config;
4
5 require_once("boot.php");
6
7 function expire_run(&$argv, &$argc){
8         global $a, $db;
9
10         if(is_null($a)) {
11                 $a = new App;
12         }
13
14         if(is_null($db)) {
15                 @include(".htconfig.php");
16                 require_once("include/dba.php");
17                 $db = new dba($db_host, $db_user, $db_pass, $db_data);
18                 unset($db_host, $db_user, $db_pass, $db_data);
19         };
20
21         require_once('include/session.php');
22         require_once('include/datetime.php');
23         require_once('include/items.php');
24         require_once('include/Contact.php');
25
26         Config::load();
27
28         $a->set_baseurl(get_config('system','url'));
29
30
31         // physically remove anything that has been deleted for more than two months
32
33         $r = q("delete from item where deleted = 1 and changed < UTC_TIMESTAMP() - INTERVAL 60 DAY");
34
35         // make this optional as it could have a performance impact on large sites
36
37         if(intval(get_config('system','optimize_items')))
38                 q("optimize table item");
39
40         logger('expire: start');
41
42         $r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
43         if (dbm::is_result($r)) {
44                 foreach ($r as $rr) {
45                         logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
46                         item_expire($rr['uid'],$rr['expire']);
47                 }
48         }
49
50         load_hooks();
51
52         call_hooks('expire');
53
54         return;
55 }
56
57 if (array_search(__file__,get_included_files())===0){
58   expire_run($_SERVER["argv"],$_SERVER["argc"]);
59   killme();
60 }