]> git.mxchange.org Git - friendica.git/blob - include/spool_post.php
diaspora - add braces
[friendica.git] / include / spool_post.php
1 <?php
2 /**
3  * @file include/spool_post.php
4  * @brief Posts items that wer spooled because they couldn't be posted.
5  */
6 require_once("boot.php");
7 require_once("include/items.php");
8
9 function spool_post_run($argv, $argc) {
10         global $a, $db;
11
12         if (is_null($a)) {
13                 $a = new App;
14         }
15
16         if (is_null($db)) {
17                 @include(".htconfig.php");
18                 require_once("include/dba.php");
19                 $db = new dba($db_host, $db_user, $db_pass, $db_data);
20                 unset($db_host, $db_user, $db_pass, $db_data);
21         }
22
23         load_config('config');
24         load_config('system');
25
26         $path = get_spoolpath();
27
28         if (is_writable($path)){
29                 if ($dh = opendir($path)) {
30                         while (($file = readdir($dh)) !== false) {
31                                 $fullfile = $path."/".$file;
32                                 if (filetype($fullfile) != "file") {
33                                         continue;
34                                 }
35                                 $arr = json_decode(file_get_contents($fullfile), true);
36                                 $result = item_store($arr);
37                                 logger("Spool file ".$file." stored: ".$result, LOGGER_DEBUG);
38                                 unlink($fullfile);
39                         }
40                         closedir($dh);
41                 }
42         }
43 }
44
45 if (array_search(__file__, get_included_files()) === 0) {
46         spool_post_run($_SERVER["argv"], $_SERVER["argc"]);
47         killme();
48 }
49 ?>