+
+function fromgplus_cron($a,$b) {
+ $last = get_config('fromgplus','last_poll');
+
+ $poll_interval = intval(get_config('fromgplus','poll_interval'));
+ if(! $poll_interval)
+ $poll_interval = FROMGPLUS_DEFAULT_POLL_INTERVAL;
+
+ if($last) {
+ $next = $last + ($poll_interval * 60);
+ if($next > time()) {
+ logger('fromgplus: poll intervall not reached');
+ return;
+ }
+ }
+
+ logger('fromgplus: cron_start');
+
+ $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'fromgplus' AND `k` = 'enable' AND `v` = '1' ORDER BY RAND() ");
+ if(count($r)) {
+ foreach($r as $rr) {
+ $account = get_pconfig($rr['uid'],'fromgplus','account');
+ if ($account) {
+ logger('fromgplus: fetching for user '.$rr['uid']);
+ fromgplus_fetch($a, $rr['uid']);
+ }
+ }
+ }
+
+ logger('fromgplus: cron_end');
+
+ set_config('fromgplus','last_poll', time());
+}
+
+function fromgplus_post($a, $uid, $source, $body, $location) {
+
+ //$uid = 2;
+
+ // Don't know what it is. Maybe some trash from the mobile client
+ $trash = html_entity_decode("", ENT_QUOTES, 'UTF-8');
+ $body = str_replace($trash, "", $body);
+
+ $body = trim($body);
+
+ if (substr($body, 0, 3) == "[b]") {
+ $pos = strpos($body, "[/b]");
+ $title = substr($body, 3, $pos-3);
+ $body = trim(substr($body, $pos+4));
+ } else
+ $title = "";
+
+ $_SESSION['authenticated'] = true;
+ $_SESSION['uid'] = $uid;
+
+ unset($_REQUEST);
+ $_REQUEST['type'] = 'wall';
+ $_REQUEST['api_source'] = true;
+
+ $_REQUEST['profile_uid'] = $uid;
+ $_REQUEST['source'] = $source;
+
+ // $_REQUEST['verb']
+ // $_REQUEST['parent']
+ // $_REQUEST['parent_uri']
+
+ $_REQUEST['title'] = $title;
+ $_REQUEST['body'] = $body;
+ $_REQUEST['location'] = $location;
+
+ if (($_REQUEST['title'] == "") AND ($_REQUEST['body'] == "")) {
+ logger('fromgplus: empty post for user '.$uid." ".print_r($_REQUEST, true));
+ return;
+ }
+
+ require_once('mod/item.php');
+ //print_r($_REQUEST);
+ logger('fromgplus: posting for user '.$uid." ".print_r($_REQUEST, true));
+ item_post($a);
+ logger('fromgplus: done for user '.$uid);
+}
+
+function fromgplus_html2bbcode($html) {