]> git.mxchange.org Git - friendica.git/blob - include/dsprphotoq.php
Merge pull request #2185 from tobiasd/20151214-translations
[friendica.git] / include / dsprphotoq.php
1 <?php
2 require_once("boot.php");
3 require_once('include/diaspora.php');
4
5 function dsprphotoq_run($argv, $argc){
6         global $a, $db;
7
8         if(is_null($a)){
9                 $a = new App;
10         }
11
12         if(is_null($db)){
13                 @include(".htconfig.php");
14                 require_once("include/dba.php");
15                 $db = new dba($db_host, $db_user, $db_pass, $db_data);
16                 unset($db_host, $db_user, $db_pass, $db_data);
17         };
18
19         logger("diaspora photo queue: running", LOGGER_DEBUG);
20
21         $r = q("SELECT * FROM dsprphotoq");
22         if(!$r)
23                 return;
24
25         $dphotos = $r;
26
27         logger("diaspora photo queue: processing " . count($dphotos) . " photos");
28
29         foreach($dphotos as $dphoto) {
30
31                 $r = array();
32
33                 if ($dphoto['uid'] == 0)
34                         $r[0] = array("uid" => 0, "page-flags" => PAGE_FREELOVE);
35                 else
36                         $r = q("SELECT * FROM user WHERE uid = %d",
37                                 intval($dphoto['uid']));
38
39                 if(!$r) {
40                         logger("diaspora photo queue: user " . $dphoto['uid'] . " not found");
41                         return;
42                 }
43
44                 $ret = diaspora_dispatch($r[0],unserialize($dphoto['msg']),$dphoto['attempt']);
45                 q("DELETE FROM dsprphotoq WHERE id = %d",
46                    intval($dphoto['id'])
47                 );
48         }
49 }
50
51
52 if (array_search(__file__,get_included_files())===0){
53   dsprphotoq_run($_SERVER["argv"],$_SERVER["argc"]);
54   killme();
55 }