Logger Levels

update logger levels
pull/765/head
Adam Magness 2018-10-30 09:48:09 -04:00
parent 49eff56e5d
commit c9a8974165
17 changed files with 123 additions and 123 deletions

View File

@ -203,12 +203,12 @@ function blogger_send(App $a, array &$b)
EOT; EOT;
Logger::log('blogger: data: ' . $xml, LOGGER_DATA); Logger::log('blogger: data: ' . $xml, Logger::DATA);
if ($bl_blog !== 'test') { if ($bl_blog !== 'test') {
$x = Network::post($bl_blog, $xml)->getBody(); $x = Network::post($bl_blog, $xml)->getBody();
} }
Logger::log('posted to blogger: ' . (($x) ? $x : ''), LOGGER_DEBUG); Logger::log('posted to blogger: ' . (($x) ? $x : ''), Logger::DEBUG);
} }
} }

View File

@ -299,7 +299,7 @@ function buffer_send(App $a, array &$b)
$profiles = $buffer->go('/profiles'); $profiles = $buffer->go('/profiles');
if (is_array($profiles)) { if (is_array($profiles)) {
Logger::log("Will send these parameter ".print_r($b, true), LOGGER_DEBUG); Logger::log("Will send these parameter ".print_r($b, true), Logger::DEBUG);
foreach ($profiles as $profile) { foreach ($profiles as $profile) {
if (!$profile->default) if (!$profile->default)
@ -358,7 +358,7 @@ function buffer_send(App $a, array &$b)
} }
$post = ItemContent::getPlaintextPost($item, $limit, $includedlinks, $htmlmode); $post = ItemContent::getPlaintextPost($item, $limit, $includedlinks, $htmlmode);
Logger::log("buffer_send: converted message ".$b["id"]." result: ".print_r($post, true), LOGGER_DEBUG); Logger::log("buffer_send: converted message ".$b["id"]." result: ".print_r($post, true), Logger::DEBUG);
// The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures // The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures
if (isset($post["image"])) { if (isset($post["image"])) {
@ -408,9 +408,9 @@ function buffer_send(App $a, array &$b)
} }
//print_r($message); //print_r($message);
Logger::log("buffer_send: data for message " . $b["id"] . ": " . print_r($message, true), LOGGER_DEBUG); Logger::log("buffer_send: data for message " . $b["id"] . ": " . print_r($message, true), Logger::DEBUG);
$ret = $buffer->go('/updates/create', $message); $ret = $buffer->go('/updates/create', $message);
Logger::log("buffer_send: send message " . $b["id"] . " result: " . print_r($ret, true), LOGGER_DEBUG); Logger::log("buffer_send: send message " . $b["id"] . " result: " . print_r($ret, true), Logger::DEBUG);
} }
} }
} }

View File

@ -99,27 +99,27 @@ function diaspora_queue_hook(App $a, &$b) {
$post = $z['post']; $post = $z['post'];
Logger::log('diaspora_queue: post: '.$post, LOGGER_DATA); Logger::log('diaspora_queue: post: '.$post, Logger::DATA);
try { try {
Logger::log('diaspora_queue: prepare', LOGGER_DEBUG); Logger::log('diaspora_queue: prepare', Logger::DEBUG);
$conn = new Diaspora_Connection($handle, $password); $conn = new Diaspora_Connection($handle, $password);
Logger::log('diaspora_queue: try to log in '.$handle, LOGGER_DEBUG); Logger::log('diaspora_queue: try to log in '.$handle, Logger::DEBUG);
$conn->logIn(); $conn->logIn();
Logger::log('diaspora_queue: try to send '.$body, LOGGER_DEBUG); Logger::log('diaspora_queue: try to send '.$body, Logger::DEBUG);
$conn->provider = $hostname; $conn->provider = $hostname;
$conn->postStatusMessage($post, $aspect); $conn->postStatusMessage($post, $aspect);
Logger::log('diaspora_queue: send '.$userdata['uid'].' success', LOGGER_DEBUG); Logger::log('diaspora_queue: send '.$userdata['uid'].' success', Logger::DEBUG);
$success = true; $success = true;
Queue::removeItem($x['id']); Queue::removeItem($x['id']);
} catch (Exception $e) { } catch (Exception $e) {
Logger::log("diaspora_queue: Send ".$userdata['uid']." failed: ".$e->getMessage(), LOGGER_DEBUG); Logger::log("diaspora_queue: Send ".$userdata['uid']." failed: ".$e->getMessage(), Logger::DEBUG);
} }
} else { } else {
Logger::log('diaspora_queue: send '.$userdata['uid'].' missing username or password', LOGGER_DEBUG); Logger::log('diaspora_queue: send '.$userdata['uid'].' missing username or password', Logger::DEBUG);
} }
if (!$success) { if (!$success) {
@ -312,14 +312,14 @@ function diaspora_send(App $a, array &$b)
return; return;
} }
Logger::log('diaspora_send: prepare posting', LOGGER_DEBUG); Logger::log('diaspora_send: prepare posting', Logger::DEBUG);
$handle = PConfig::get($b['uid'],'diaspora','handle'); $handle = PConfig::get($b['uid'],'diaspora','handle');
$password = PConfig::get($b['uid'],'diaspora','password'); $password = PConfig::get($b['uid'],'diaspora','password');
$aspect = PConfig::get($b['uid'],'diaspora','aspect'); $aspect = PConfig::get($b['uid'],'diaspora','aspect');
if ($handle && $password) { if ($handle && $password) {
Logger::log('diaspora_send: all values seem to be okay', LOGGER_DEBUG); Logger::log('diaspora_send: all values seem to be okay', Logger::DEBUG);
$tag_arr = []; $tag_arr = [];
$tags = ''; $tags = '';
@ -364,11 +364,11 @@ function diaspora_send(App $a, array &$b)
require_once "addon/diaspora/diasphp.php"; require_once "addon/diaspora/diasphp.php";
try { try {
Logger::log('diaspora_send: prepare', LOGGER_DEBUG); Logger::log('diaspora_send: prepare', Logger::DEBUG);
$conn = new Diaspora_Connection($handle, $password); $conn = new Diaspora_Connection($handle, $password);
Logger::log('diaspora_send: try to log in '.$handle, LOGGER_DEBUG); Logger::log('diaspora_send: try to log in '.$handle, Logger::DEBUG);
$conn->logIn(); $conn->logIn();
Logger::log('diaspora_send: try to send '.$body, LOGGER_DEBUG); Logger::log('diaspora_send: try to send '.$body, Logger::DEBUG);
$conn->provider = $hostname; $conn->provider = $hostname;
$conn->postStatusMessage($body, $aspect); $conn->postStatusMessage($body, $aspect);
@ -377,7 +377,7 @@ function diaspora_send(App $a, array &$b)
} catch (Exception $e) { } catch (Exception $e) {
Logger::log("diaspora_send: Error submitting the post: " . $e->getMessage()); Logger::log("diaspora_send: Error submitting the post: " . $e->getMessage());
Logger::log('diaspora_send: requeueing '.$b['uid'], LOGGER_DEBUG); Logger::log('diaspora_send: requeueing '.$b['uid'], Logger::DEBUG);
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']); $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']);
if (count($r)) if (count($r))

View File

@ -226,13 +226,13 @@ function dwpost_send(App $a, array &$b)
EOT; EOT;
Logger::log('dwpost: data: ' . $xml, LOGGER_DATA); Logger::log('dwpost: data: ' . $xml, Logger::DATA);
if ($dw_blog !== 'test') { if ($dw_blog !== 'test') {
$x = Network::post($dw_blog, $xml, ["Content-Type: text/xml"])->getBody(); $x = Network::post($dw_blog, $xml, ["Content-Type: text/xml"])->getBody();
} }
Logger::log('posted to dreamwidth: ' . ($x) ? $x : '', LOGGER_DEBUG); Logger::log('posted to dreamwidth: ' . ($x) ? $x : '', Logger::DEBUG);
} }
} }

View File

@ -55,25 +55,25 @@ function geocoordinates_resolve_item(&$item)
$s = Network::fetchUrl("https://api.opencagedata.com/geocode/v1/json?q=".$coords[0].",".$coords[1]."&key=".$key."&language=".$language); $s = Network::fetchUrl("https://api.opencagedata.com/geocode/v1/json?q=".$coords[0].",".$coords[1]."&key=".$key."&language=".$language);
if (!$s) { if (!$s) {
Logger::log("API could not be queried", LOGGER_DEBUG); Logger::log("API could not be queried", Logger::DEBUG);
return; return;
} }
$data = json_decode($s); $data = json_decode($s);
if ($data->status->code != "200") { if ($data->status->code != "200") {
Logger::log("API returned error ".$data->status->code." ".$data->status->message, LOGGER_DEBUG); Logger::log("API returned error ".$data->status->code." ".$data->status->message, Logger::DEBUG);
return; return;
} }
if (($data->total_results == 0) || (count($data->results) == 0)) { if (($data->total_results == 0) || (count($data->results) == 0)) {
Logger::log("No results found for coordinates ".$item["coord"], LOGGER_DEBUG); Logger::log("No results found for coordinates ".$item["coord"], Logger::DEBUG);
return; return;
} }
$item["location"] = $data->results[0]->formatted; $item["location"] = $data->results[0]->formatted;
Logger::log("Got location for coordinates ".$coords[0]."-".$coords[1].": ".$item["location"], LOGGER_DEBUG); Logger::log("Got location for coordinates ".$coords[0]."-".$coords[1].": ".$item["location"], Logger::DEBUG);
if ($item["location"] != "") if ($item["location"] != "")
Cache::set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]); Cache::set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]);

View File

@ -133,7 +133,7 @@ function geonames_post_hook($a, &$item) {
$item['location'] = $xml->geoname->name . ', ' . $xml->geoname->countryName; $item['location'] = $xml->geoname->name . ', ' . $xml->geoname->countryName;
// Logger::log('geonames : ' . print_r($xml,true), LOGGER_DATA); // Logger::log('geonames : ' . print_r($xml,true), Logger::DATA);
return; return;
} }

View File

@ -104,13 +104,13 @@ function ifttt_post(App $a)
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]); $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]);
if (!DBA::isResult($user)) { if (!DBA::isResult($user)) {
Logger::log('User ' . $nickname . ' not found.', LOGGER_DEBUG); Logger::log('User ' . $nickname . ' not found.', Logger::DEBUG);
return; return;
} }
$uid = $user['uid']; $uid = $user['uid'];
Logger::log('Received a post for user ' . $uid . ' from ifttt ' . print_r($_REQUEST, true), LOGGER_DEBUG); Logger::log('Received a post for user ' . $uid . ' from ifttt ' . print_r($_REQUEST, true), Logger::DEBUG);
if (!isset($_REQUEST['key'])) { if (!isset($_REQUEST['key'])) {
Logger::log('No key found.'); Logger::log('No key found.');
@ -121,7 +121,7 @@ function ifttt_post(App $a)
// Check the key // Check the key
if ($key != PConfig::get($uid, 'ifttt', 'key')) { if ($key != PConfig::get($uid, 'ifttt', 'key')) {
Logger::log('Invalid key for user ' . $uid, LOGGER_DEBUG); Logger::log('Invalid key for user ' . $uid, Logger::DEBUG);
return; return;
} }
@ -132,7 +132,7 @@ function ifttt_post(App $a)
} }
if (!in_array($item['type'], ['status', 'link', 'photo'])) { if (!in_array($item['type'], ['status', 'link', 'photo'])) {
Logger::log('Unknown item type ' . $item['type'], LOGGER_DEBUG); Logger::log('Unknown item type ' . $item['type'], Logger::DEBUG);
return; return;
} }

View File

@ -222,12 +222,12 @@ function ijpost_send(&$a, &$b)
EOT; EOT;
Logger::log('ijpost: data: ' . $xml, LOGGER_DATA); Logger::log('ijpost: data: ' . $xml, Logger::DATA);
if ($ij_blog !== 'test') { if ($ij_blog !== 'test') {
$x = Network::post($ij_blog, $xml, ["Content-Type: text/xml"])->getBody(); $x = Network::post($ij_blog, $xml, ["Content-Type: text/xml"])->getBody();
} }
Logger::log('posted to insanejournal: ' . $x ? $x : '', LOGGER_DEBUG); Logger::log('posted to insanejournal: ' . $x ? $x : '', Logger::DEBUG);
} }
} }

View File

@ -160,7 +160,7 @@ function js_upload_post_init(&$a,&$b) {
$a->data['upload_jsonresponse'] = htmlspecialchars(json_encode($result), ENT_NOQUOTES); $a->data['upload_jsonresponse'] = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
if(isset($result['error'])) { if(isset($result['error'])) {
Logger::log('mod/photos.php: photos_post(): error uploading photo: ' . $result['error'] , 'LOGGER_DEBUG'); Logger::log('mod/photos.php: photos_post(): error uploading photo: ' . $result['error'] , Logger::DEBUG);
echo json_encode($result); echo json_encode($result);
killme(); killme();
} }

View File

@ -232,12 +232,12 @@ function ljpost_send(&$a,&$b) {
EOT; EOT;
Logger::log('ljpost: data: ' . $xml, LOGGER_DATA); Logger::log('ljpost: data: ' . $xml, Logger::DATA);
if ($lj_blog !== 'test') { if ($lj_blog !== 'test') {
$x = Network::post($lj_blog, $xml, ["Content-Type: text/xml"])->getBody(); $x = Network::post($lj_blog, $xml, ["Content-Type: text/xml"])->getBody();
} }
Logger::log('posted to livejournal: ' . ($x) ? $x : '', LOGGER_DEBUG); Logger::log('posted to livejournal: ' . ($x) ? $x : '', Logger::DEBUG);
} }
} }

View File

@ -95,7 +95,7 @@ function mailstream_generate_id($a, $uri) {
$host = $a->getHostName(); $host = $a->getHostName();
$resource = hash('md5', $uri); $resource = hash('md5', $uri);
$message_id = "<" . $resource . "@" . $host . ">"; $message_id = "<" . $resource . "@" . $host . ">";
Logger::log('mailstream: Generated message ID ' . $message_id . ' for URI ' . $uri, LOGGER_DEBUG); Logger::log('mailstream: Generated message ID ' . $message_id . ' for URI ' . $uri, Logger::DEBUG);
return $message_id; return $message_id;
} }
@ -124,16 +124,16 @@ function mailstream_post_hook(&$a, &$item) {
intval($item['contact-id']), DBA::escape($item['uri']), DBA::escape($message_id)); intval($item['contact-id']), DBA::escape($item['uri']), DBA::escape($message_id));
$r = q('SELECT * FROM `mailstream_item` WHERE `uid` = %d AND `contact-id` = %d AND `uri` = "%s"', intval($item['uid']), intval($item['contact-id']), DBA::escape($item['uri'])); $r = q('SELECT * FROM `mailstream_item` WHERE `uid` = %d AND `contact-id` = %d AND `uri` = "%s"', intval($item['uid']), intval($item['contact-id']), DBA::escape($item['uri']));
if (count($r) != 1) { if (count($r) != 1) {
Logger::log('mailstream_post_remote_hook: Unexpected number of items returned from mailstream_item', LOGGER_INFO); Logger::log('mailstream_post_remote_hook: Unexpected number of items returned from mailstream_item', Logger::INFO);
return; return;
} }
$ms_item = $r[0]; $ms_item = $r[0];
Logger::log('mailstream_post_remote_hook: created mailstream_item ' Logger::log('mailstream_post_remote_hook: created mailstream_item '
. $ms_item['id'] . ' for item ' . $item['uri'] . ' ' . $ms_item['id'] . ' for item ' . $item['uri'] . ' '
. $item['uid'] . ' ' . $item['contact-id'], LOGGER_DATA); . $item['uid'] . ' ' . $item['contact-id'], Logger::DATA);
$user = mailstream_get_user($item['uid']); $user = mailstream_get_user($item['uid']);
if (!$user) { if (!$user) {
Logger::log('mailstream_post_remote_hook: no user ' . $item['uid'], LOGGER_INFO); Logger::log('mailstream_post_remote_hook: no user ' . $item['uid'], Logger::INFO);
return; return;
} }
mailstream_send($a, $ms_item['message-id'], $item, $user); mailstream_send($a, $ms_item['message-id'], $item, $user);
@ -142,7 +142,7 @@ function mailstream_post_hook(&$a, &$item) {
function mailstream_get_user($uid) { function mailstream_get_user($uid) {
$r = q('SELECT * FROM `user` WHERE `uid` = %d', intval($uid)); $r = q('SELECT * FROM `user` WHERE `uid` = %d', intval($uid));
if (count($r) != 1) { if (count($r) != 1) {
Logger::log('mailstream_post_remote_hook: Unexpected number of users returned', LOGGER_INFO); Logger::log('mailstream_post_remote_hook: Unexpected number of users returned', Logger::INFO);
return; return;
} }
return $r[0]; return $r[0];
@ -299,11 +299,11 @@ function mailstream_send($a, $message_id, $item, $user) {
if (!$mail->Send()) { if (!$mail->Send()) {
throw new Exception($mail->ErrorInfo); throw new Exception($mail->ErrorInfo);
} }
Logger::log('mailstream_send sent message ' . $mail->MessageID . ' ' . $mail->Subject, LOGGER_DEBUG); Logger::log('mailstream_send sent message ' . $mail->MessageID . ' ' . $mail->Subject, Logger::DEBUG);
} catch (phpmailerException $e) { } catch (phpmailerException $e) {
Logger::log('mailstream_send PHPMailer exception sending message ' . $message_id . ': ' . $e->errorMessage(), LOGGER_INFO); Logger::log('mailstream_send PHPMailer exception sending message ' . $message_id . ': ' . $e->errorMessage(), Logger::INFO);
} catch (Exception $e) { } catch (Exception $e) {
Logger::log('mailstream_send exception sending message ' . $message_id . ': ' . $e->getMessage(), LOGGER_INFO); Logger::log('mailstream_send exception sending message ' . $message_id . ': ' . $e->getMessage(), Logger::INFO);
} }
// In case of failure, still set the item to completed. Otherwise // In case of failure, still set the item to completed. Otherwise
// we'll just try to send it over and over again and it'll fail // we'll just try to send it over and over again and it'll fail
@ -332,10 +332,10 @@ function mailstream_cron($a, $b) {
// mailstream_post_remote_hook fails for some reason will this get // mailstream_post_remote_hook fails for some reason will this get
// used, and in that case it's worth holding off a bit anyway. // used, and in that case it's worth holding off a bit anyway.
$ms_item_ids = q("SELECT `mailstream_item`.`message-id`, `mailstream_item`.`uri`, `item`.`id` FROM `mailstream_item` JOIN `item` ON (`mailstream_item`.`uid` = `item`.`uid` AND `mailstream_item`.`uri` = `item`.`uri` AND `mailstream_item`.`contact-id` = `item`.`contact-id`) WHERE `mailstream_item`.`completed` IS NULL AND `mailstream_item`.`created` < DATE_SUB(NOW(), INTERVAL 1 HOUR) AND `item`.`visible` = 1 ORDER BY `mailstream_item`.`created` LIMIT 100"); $ms_item_ids = q("SELECT `mailstream_item`.`message-id`, `mailstream_item`.`uri`, `item`.`id` FROM `mailstream_item` JOIN `item` ON (`mailstream_item`.`uid` = `item`.`uid` AND `mailstream_item`.`uri` = `item`.`uri` AND `mailstream_item`.`contact-id` = `item`.`contact-id`) WHERE `mailstream_item`.`completed` IS NULL AND `mailstream_item`.`created` < DATE_SUB(NOW(), INTERVAL 1 HOUR) AND `item`.`visible` = 1 ORDER BY `mailstream_item`.`created` LIMIT 100");
Logger::log('mailstream_cron processing ' . count($ms_item_ids) . ' items', LOGGER_DEBUG); Logger::log('mailstream_cron processing ' . count($ms_item_ids) . ' items', Logger::DEBUG);
foreach ($ms_item_ids as $ms_item_id) { foreach ($ms_item_ids as $ms_item_id) {
if (!$ms_item_id['message-id'] || !strlen($ms_item_id['message-id'])) { if (!$ms_item_id['message-id'] || !strlen($ms_item_id['message-id'])) {
Logger::log('mailstream_cron: Item ' . $ms_item_id['id'] . ' URI ' . $ms_item_id['uri'] . ' has no message-id', LOGGER_INFO); Logger::log('mailstream_cron: Item ' . $ms_item_id['id'] . ' URI ' . $ms_item_id['uri'] . ' has no message-id', Logger::INFO);
} }
$item = Item::selectFirst([], ['id' => $ms_item_id['id']]); $item = Item::selectFirst([], ['id' => $ms_item_id['id']]);
$users = q("SELECT * FROM `user` WHERE `uid` = %d", intval($item['uid'])); $users = q("SELECT * FROM `user` WHERE `uid` = %d", intval($item['uid']));
@ -344,7 +344,7 @@ function mailstream_cron($a, $b) {
mailstream_send($a, $ms_item_id['message-id'], $item, $user); mailstream_send($a, $ms_item_id['message-id'], $item, $user);
} }
else { else {
Logger::log('mailstream_cron: Unable to find item ' . $ms_item_id['id'], LOGGER_INFO); Logger::log('mailstream_cron: Unable to find item ' . $ms_item_id['id'], Logger::INFO);
q("UPDATE `mailstream_item` SET `completed` = now() WHERE `message-id` = %d", intval($ms_item['message-id'])); q("UPDATE `mailstream_item` SET `completed` = now() WHERE `message-id` = %d", intval($ms_item['message-id']));
} }
} }
@ -413,5 +413,5 @@ function mailstream_tidy() {
foreach ($r as $rr) { foreach ($r as $rr) {
q('DELETE FROM mailstream_item WHERE id = %d', intval($rr['id'])); q('DELETE FROM mailstream_item WHERE id = %d', intval($rr['id']));
} }
Logger::log('mailstream_tidy: deleted ' . count($r) . ' old items', LOGGER_DEBUG); Logger::log('mailstream_tidy: deleted ' . count($r) . ' old items', Logger::DEBUG);
} }

View File

@ -166,8 +166,8 @@ function openstreetmap_generate_map(&$a, &$b)
$lat = $b['lat']; // round($b['lat'], 5); $lat = $b['lat']; // round($b['lat'], 5);
$lon = $b['lon']; // round($b['lon'], 5); $lon = $b['lon']; // round($b['lon'], 5);
Logger::log('lat: ' . $lat, LOGGER_DATA); Logger::log('lat: ' . $lat, Logger::DATA);
Logger::log('lon: ' . $lon, LOGGER_DATA); Logger::log('lon: ' . $lon, Logger::DATA);
$cardlink = '<a href="' . $tmsserver; $cardlink = '<a href="' . $tmsserver;
@ -185,7 +185,7 @@ function openstreetmap_generate_map(&$a, &$b)
$b['html'] .= '<br/>' . $cardlink; $b['html'] .= '<br/>' . $cardlink;
} }
Logger::log('generate_map: ' . $b['html'], LOGGER_DATA); Logger::log('generate_map: ' . $b['html'], Logger::DATA);
} }
function openstreetmap_addon_admin(&$a, &$o) function openstreetmap_addon_admin(&$a, &$o)

View File

@ -115,7 +115,7 @@ function pumpio_registerclient(App $a, $host)
$params["logo_url"] = $a->getBaseURL()."/images/friendica-256.png"; $params["logo_url"] = $a->getBaseURL()."/images/friendica-256.png";
$params["redirect_uris"] = $a->getBaseURL()."/pumpio/connect"; $params["redirect_uris"] = $a->getBaseURL()."/pumpio/connect";
Logger::log("pumpio_registerclient: ".$url." parameters ".print_r($params, true), LOGGER_DEBUG); Logger::log("pumpio_registerclient: ".$url." parameters ".print_r($params, true), Logger::DEBUG);
$ch = curl_init($url); $ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_HEADER, false);
@ -129,10 +129,10 @@ function pumpio_registerclient(App $a, $host)
if ($curl_info["http_code"] == "200") { if ($curl_info["http_code"] == "200") {
$values = json_decode($s); $values = json_decode($s);
Logger::log("pumpio_registerclient: success ".print_r($values, true), LOGGER_DEBUG); Logger::log("pumpio_registerclient: success ".print_r($values, true), Logger::DEBUG);
return $values; return $values;
} }
Logger::log("pumpio_registerclient: failed: ".print_r($curl_info, true), LOGGER_DEBUG); Logger::log("pumpio_registerclient: failed: ".print_r($curl_info, true), Logger::DEBUG);
return false; return false;
} }
@ -153,7 +153,7 @@ function pumpio_connect(App $a)
$consumer_key = PConfig::get(local_user(), 'pumpio', 'consumer_key'); $consumer_key = PConfig::get(local_user(), 'pumpio', 'consumer_key');
$consumer_secret = PConfig::get(local_user(), 'pumpio', 'consumer_secret'); $consumer_secret = PConfig::get(local_user(), 'pumpio', 'consumer_secret');
Logger::log("pumpio_connect: ckey: ".$consumer_key." csecrect: ".$consumer_secret, LOGGER_DEBUG); Logger::log("pumpio_connect: ckey: ".$consumer_key." csecrect: ".$consumer_secret, Logger::DEBUG);
} }
if (($consumer_key == "") || ($consumer_secret == "")) { if (($consumer_key == "") || ($consumer_secret == "")) {
@ -187,7 +187,7 @@ function pumpio_connect(App $a)
if (($success = $client->Initialize())) { if (($success = $client->Initialize())) {
if (($success = $client->Process())) { if (($success = $client->Process())) {
if (strlen($client->access_token)) { if (strlen($client->access_token)) {
Logger::log("pumpio_connect: otoken: ".$client->access_token." osecrect: ".$client->access_token_secret, LOGGER_DEBUG); Logger::log("pumpio_connect: otoken: ".$client->access_token." osecrect: ".$client->access_token_secret, Logger::DEBUG);
PConfig::set(local_user(), "pumpio", "oauth_token", $client->access_token); PConfig::set(local_user(), "pumpio", "oauth_token", $client->access_token);
PConfig::set(local_user(), "pumpio", "oauth_token_secret", $client->access_token_secret); PConfig::set(local_user(), "pumpio", "oauth_token_secret", $client->access_token_secret);
} }
@ -410,7 +410,7 @@ function pumpio_send(App $a, array &$b)
return; return;
} }
Logger::log("pumpio_send: parameter ".print_r($b, true), LOGGER_DATA); Logger::log("pumpio_send: parameter ".print_r($b, true), Logger::DATA);
if ($b['parent'] != $b['id']) { if ($b['parent'] != $b['id']) {
// Looking if its a reply to a pumpio post // Looking if its a reply to a pumpio post
@ -908,7 +908,7 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
require_once('include/items.php'); require_once('include/items.php');
if (empty($post->object->id)) { if (empty($post->object->id)) {
Logger::log('Got empty like: '.print_r($post, true), LOGGER_DEBUG); Logger::log('Got empty like: '.print_r($post, true), Logger::DEBUG);
return; return;
} }

View File

@ -430,7 +430,7 @@ function statusnet_action(App $a, $uid, $pid, $action)
$connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
Logger::log("statusnet_action '" . $action . "' ID: " . $pid, LOGGER_DATA); Logger::log("statusnet_action '" . $action . "' ID: " . $pid, Logger::DATA);
switch ($action) { switch ($action) {
case "delete": case "delete":
@ -443,7 +443,7 @@ function statusnet_action(App $a, $uid, $pid, $action)
$result = $connection->post("favorites/destroy/" . $pid); $result = $connection->post("favorites/destroy/" . $pid);
break; break;
} }
Logger::log("statusnet_action '" . $action . "' send, result: " . print_r($result, true), LOGGER_DEBUG); Logger::log("statusnet_action '" . $action . "' send, result: " . print_r($result, true), Logger::DEBUG);
} }
function statusnet_post_hook(App $a, &$b) function statusnet_post_hook(App $a, &$b)
@ -460,7 +460,7 @@ function statusnet_post_hook(App $a, &$b)
$hostname = preg_replace("=https?://([\w\.]*)/.*=ism", "$1", $api); $hostname = preg_replace("=https?://([\w\.]*)/.*=ism", "$1", $api);
if ($b['parent'] != $b['id']) { if ($b['parent'] != $b['id']) {
Logger::log("statusnet_post_hook: parameter " . print_r($b, true), LOGGER_DATA); Logger::log("statusnet_post_hook: parameter " . print_r($b, true), Logger::DATA);
// Looking if its a reply to a GNU Social post // Looking if its a reply to a GNU Social post
$hostlength = strlen($hostname) + 2; $hostlength = strlen($hostname) + 2;
@ -483,12 +483,12 @@ function statusnet_post_hook(App $a, &$b)
$nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]"; $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]";
$nicknameplain = "@" . $nick; $nicknameplain = "@" . $nick;
Logger::log("statusnet_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], LOGGER_DEBUG); Logger::log("statusnet_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], Logger::DEBUG);
if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false)) { if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false)) {
$b["body"] = $nickname . " " . $b["body"]; $b["body"] = $nickname . " " . $b["body"];
} }
Logger::log("statusnet_post_hook: parent found " . print_r($orig_post, true), LOGGER_DEBUG); Logger::log("statusnet_post_hook: parent found " . print_r($orig_post, true), Logger::DEBUG);
} else { } else {
$iscomment = false; $iscomment = false;
@ -509,7 +509,7 @@ function statusnet_post_hook(App $a, &$b)
} }
if ($b['verb'] == ACTIVITY_LIKE) { if ($b['verb'] == ACTIVITY_LIKE) {
Logger::log("statusnet_post_hook: parameter 2 " . substr($b["thr-parent"], $hostlength), LOGGER_DEBUG); Logger::log("statusnet_post_hook: parameter 2 " . substr($b["thr-parent"], $hostlength), Logger::DEBUG);
if ($b['deleted']) if ($b['deleted'])
statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "unlike"); statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "unlike");
else else
@ -579,7 +579,7 @@ function statusnet_post_hook(App $a, &$b)
if (strlen($msg)) { if (strlen($msg)) {
if ($iscomment) { if ($iscomment) {
$postdata["in_reply_to_status_id"] = substr($orig_post["uri"], $hostlength); $postdata["in_reply_to_status_id"] = substr($orig_post["uri"], $hostlength);
Logger::log('statusnet_post send reply ' . print_r($postdata, true), LOGGER_DEBUG); Logger::log('statusnet_post send reply ' . print_r($postdata, true), Logger::DEBUG);
} }
// New code that is able to post pictures // New code that is able to post pictures
@ -591,7 +591,7 @@ function statusnet_post_hook(App $a, &$b)
$result = $cb->statuses_update($postdata); $result = $cb->statuses_update($postdata);
//$result = $dent->post('statuses/update', $postdata); //$result = $dent->post('statuses/update', $postdata);
Logger::log('statusnet_post send, result: ' . print_r($result, true) . Logger::log('statusnet_post send, result: ' . print_r($result, true) .
"\nmessage: " . $msg . "\nOriginal post: " . print_r($b, true) . "\nPost Data: " . print_r($postdata, true), LOGGER_DEBUG); "\nmessage: " . $msg . "\nOriginal post: " . print_r($b, true) . "\nPost Data: " . print_r($postdata, true), Logger::DEBUG);
if (!empty($result->source)) { if (!empty($result->source)) {
PConfig::set($b["uid"], "statusnet", "application_name", strip_tags($result->source)); PConfig::set($b["uid"], "statusnet", "application_name", strip_tags($result->source));
@ -913,7 +913,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
} }
if (DBA::isResult($r) && ($r[0]["readonly"] || $r[0]["blocked"])) { if (DBA::isResult($r) && ($r[0]["readonly"] || $r[0]["blocked"])) {
Logger::log("statusnet_fetch_contact: Contact '" . $r[0]["nick"] . "' is blocked or readonly.", LOGGER_DEBUG); Logger::log("statusnet_fetch_contact: Contact '" . $r[0]["nick"] . "' is blocked or readonly.", Logger::DEBUG);
return -1; return -1;
} }
@ -975,7 +975,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
// check that we have all the photos, this has been known to fail on occasion // check that we have all the photos, this has been known to fail on occasion
if ((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) { if ((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) {
Logger::log("statusnet_fetch_contact: Updating contact " . $contact->screen_name, LOGGER_DEBUG); Logger::log("statusnet_fetch_contact: Updating contact " . $contact->screen_name, Logger::DEBUG);
$photos = Photo::importProfilePhoto($contact->profile_image_url, $uid, $r[0]['id']); $photos = Photo::importProfilePhoto($contact->profile_image_url, $uid, $r[0]['id']);
@ -1061,7 +1061,7 @@ function statusnet_fetchuser(App $a, $uid, $screen_name = "", $user_id = "")
function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_existing_contact) function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_existing_contact)
{ {
Logger::log("statusnet_createpost: start", LOGGER_DEBUG); Logger::log("statusnet_createpost: start", Logger::DEBUG);
$api = PConfig::get($uid, 'statusnet', 'baseapi'); $api = PConfig::get($uid, 'statusnet', 'baseapi');
$hostname = preg_replace("=https?://([\w\.]*)/.*=ism", "$1", $api); $hostname = preg_replace("=https?://([\w\.]*)/.*=ism", "$1", $api);
@ -1188,7 +1188,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
$postarray["coord"] = $content->coordinates->coordinates[1] . " " . $content->coordinates->coordinates[0]; $postarray["coord"] = $content->coordinates->coordinates[1] . " " . $content->coordinates->coordinates[0];
} }
Logger::log("statusnet_createpost: end", LOGGER_DEBUG); Logger::log("statusnet_createpost: end", Logger::DEBUG);
return $postarray; return $postarray;
} }
@ -1207,7 +1207,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
// "create_user" is deactivated, since currently you cannot add users manually by now // "create_user" is deactivated, since currently you cannot add users manually by now
$create_user = true; $create_user = true;
Logger::log("statusnet_fetchhometimeline: Fetching for user " . $uid, LOGGER_DEBUG); Logger::log("statusnet_fetchhometimeline: Fetching for user " . $uid, Logger::DEBUG);
require_once 'include/items.php'; require_once 'include/items.php';
@ -1222,7 +1222,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
if (DBA::isResult($r)) { if (DBA::isResult($r)) {
$nick = $r[0]["nick"]; $nick = $r[0]["nick"];
} else { } else {
Logger::log("statusnet_fetchhometimeline: Own GNU Social contact not found for user " . $uid, LOGGER_DEBUG); Logger::log("statusnet_fetchhometimeline: Own GNU Social contact not found for user " . $uid, Logger::DEBUG);
return; return;
} }
@ -1232,14 +1232,14 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
if (DBA::isResult($r)) { if (DBA::isResult($r)) {
$self = $r[0]; $self = $r[0];
} else { } else {
Logger::log("statusnet_fetchhometimeline: Own contact not found for user " . $uid, LOGGER_DEBUG); Logger::log("statusnet_fetchhometimeline: Own contact not found for user " . $uid, Logger::DEBUG);
return; return;
} }
$u = q("SELECT * FROM user WHERE uid = %d LIMIT 1", $u = q("SELECT * FROM user WHERE uid = %d LIMIT 1",
intval($uid)); intval($uid));
if (!DBA::isResult($u)) { if (!DBA::isResult($u)) {
Logger::log("statusnet_fetchhometimeline: Own user not found for user " . $uid, LOGGER_DEBUG); Logger::log("statusnet_fetchhometimeline: Own user not found for user " . $uid, Logger::DEBUG);
return; return;
} }
@ -1270,13 +1270,13 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
$errormsg = "Unknown error"; $errormsg = "Unknown error";
} }
Logger::log("statusnet_fetchhometimeline: Error fetching home timeline: " . $errormsg, LOGGER_DEBUG); Logger::log("statusnet_fetchhometimeline: Error fetching home timeline: " . $errormsg, Logger::DEBUG);
return; return;
} }
$posts = array_reverse($items); $posts = array_reverse($items);
Logger::log("statusnet_fetchhometimeline: Fetching timeline for user " . $uid . " " . sizeof($posts) . " items", LOGGER_DEBUG); Logger::log("statusnet_fetchhometimeline: Fetching timeline for user " . $uid . " " . sizeof($posts) . " items", Logger::DEBUG);
if (count($posts)) { if (count($posts)) {
foreach ($posts as $post) { foreach ($posts as $post) {
@ -1322,13 +1322,13 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
$items = $connection->get('statuses/mentions_timeline', $parameters); $items = $connection->get('statuses/mentions_timeline', $parameters);
if (!is_array($items)) { if (!is_array($items)) {
Logger::log("statusnet_fetchhometimeline: Error fetching mentions: " . print_r($items, true), LOGGER_DEBUG); Logger::log("statusnet_fetchhometimeline: Error fetching mentions: " . print_r($items, true), Logger::DEBUG);
return; return;
} }
$posts = array_reverse($items); $posts = array_reverse($items);
Logger::log("statusnet_fetchhometimeline: Fetching mentions for user " . $uid . " " . sizeof($posts) . " items", LOGGER_DEBUG); Logger::log("statusnet_fetchhometimeline: Fetching mentions for user " . $uid . " " . sizeof($posts) . " items", Logger::DEBUG);
if (count($posts)) { if (count($posts)) {
foreach ($posts as $post) { foreach ($posts as $post) {
@ -1412,15 +1412,15 @@ function statusnet_convertmsg(App $a, $body, $no_tags = false)
foreach ($matches AS $match) { foreach ($matches AS $match) {
$search = "[url=" . $match[1] . "]" . $match[2] . "[/url]"; $search = "[url=" . $match[1] . "]" . $match[2] . "[/url]";
Logger::log("statusnet_convertmsg: expanding url " . $match[1], LOGGER_DEBUG); Logger::log("statusnet_convertmsg: expanding url " . $match[1], Logger::DEBUG);
$expanded_url = Network::finalUrl($match[1]); $expanded_url = Network::finalUrl($match[1]);
Logger::log("statusnet_convertmsg: fetching data for " . $expanded_url, LOGGER_DEBUG); Logger::log("statusnet_convertmsg: fetching data for " . $expanded_url, Logger::DEBUG);
$oembed_data = OEmbed::fetchURL($expanded_url, true); $oembed_data = OEmbed::fetchURL($expanded_url, true);
Logger::log("statusnet_convertmsg: fetching data: done", LOGGER_DEBUG); Logger::log("statusnet_convertmsg: fetching data: done", Logger::DEBUG);
if ($type == "") { if ($type == "") {
$type = $oembed_data->type; $type = $oembed_data->type;
@ -1582,13 +1582,13 @@ function statusnet_is_retweet(App $a, $uid, $body)
return false; return false;
} }
Logger::log('statusnet_is_retweet: Retweeting id ' . $id . ' for user ' . $uid, LOGGER_DEBUG); Logger::log('statusnet_is_retweet: Retweeting id ' . $id . ' for user ' . $uid, Logger::DEBUG);
$connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
$result = $connection->post('statuses/retweet/' . $id); $result = $connection->post('statuses/retweet/' . $id);
Logger::log('statusnet_is_retweet: result ' . print_r($result, true), LOGGER_DEBUG); Logger::log('statusnet_is_retweet: result ' . print_r($result, true), Logger::DEBUG);
return isset($result->id); return isset($result->id);
} }

View File

@ -155,7 +155,7 @@ function twitter_check_item_notification(App $a, array &$notification_data)
function twitter_follow(App $a, array &$contact) function twitter_follow(App $a, array &$contact)
{ {
Logger::log("twitter_follow: Check if contact is twitter contact. " . $contact["url"], LOGGER_DEBUG); Logger::log("twitter_follow: Check if contact is twitter contact. " . $contact["url"], Logger::DEBUG);
if (!strstr($contact["url"], "://twitter.com") && !strstr($contact["url"], "@twitter.com")) { if (!strstr($contact["url"], "://twitter.com") && !strstr($contact["url"], "@twitter.com")) {
return; return;
@ -428,7 +428,7 @@ function twitter_action(App $a, $uid, $pid, $action)
$post = ['id' => $pid]; $post = ['id' => $pid];
Logger::log("twitter_action '" . $action . "' ID: " . $pid . " data: " . print_r($post, true), LOGGER_DATA); Logger::log("twitter_action '" . $action . "' ID: " . $pid . " data: " . print_r($post, true), Logger::DATA);
switch ($action) { switch ($action) {
case "delete": case "delete":
@ -442,10 +442,10 @@ function twitter_action(App $a, $uid, $pid, $action)
$result = $connection->post('favorites/destroy', $post); $result = $connection->post('favorites/destroy', $post);
break; break;
default: default:
Logger::log('Unhandled action ' . $action, LOGGER_DEBUG); Logger::log('Unhandled action ' . $action, Logger::DEBUG);
$result = []; $result = [];
} }
Logger::log("twitter_action '" . $action . "' send, result: " . print_r($result, true), LOGGER_DEBUG); Logger::log("twitter_action '" . $action . "' send, result: " . print_r($result, true), Logger::DEBUG);
} }
function twitter_post_hook(App $a, array &$b) function twitter_post_hook(App $a, array &$b)
@ -457,7 +457,7 @@ function twitter_post_hook(App $a, array &$b)
} }
if ($b['parent'] != $b['id']) { if ($b['parent'] != $b['id']) {
Logger::log("twitter_post_hook: parameter " . print_r($b, true), LOGGER_DATA); Logger::log("twitter_post_hook: parameter " . print_r($b, true), Logger::DATA);
// Looking if its a reply to a twitter post // Looking if its a reply to a twitter post
if ((substr($b["parent-uri"], 0, 9) != "twitter::") if ((substr($b["parent-uri"], 0, 9) != "twitter::")
@ -482,12 +482,12 @@ function twitter_post_hook(App $a, array &$b)
$nickname = "@[url=" . $orig_post["author-link"] . "]" . $nicknameplain . "[/url]"; $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nicknameplain . "[/url]";
$nicknameplain = "@" . $nicknameplain; $nicknameplain = "@" . $nicknameplain;
Logger::log("twitter_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], LOGGER_DEBUG); Logger::log("twitter_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], Logger::DEBUG);
if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false)) { if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false)) {
$b["body"] = $nickname . " " . $b["body"]; $b["body"] = $nickname . " " . $b["body"];
} }
Logger::log("twitter_post_hook: parent found " . print_r($orig_post, true), LOGGER_DATA); Logger::log("twitter_post_hook: parent found " . print_r($orig_post, true), Logger::DATA);
} else { } else {
$iscomment = false; $iscomment = false;
@ -508,7 +508,7 @@ function twitter_post_hook(App $a, array &$b)
} }
if ($b['verb'] == ACTIVITY_LIKE) { if ($b['verb'] == ACTIVITY_LIKE) {
Logger::log("twitter_post_hook: parameter 2 " . substr($b["thr-parent"], 9), LOGGER_DEBUG); Logger::log("twitter_post_hook: parameter 2 " . substr($b["thr-parent"], 9), Logger::DEBUG);
if ($b['deleted']) { if ($b['deleted']) {
twitter_action($a, $b["uid"], substr($b["thr-parent"], 9), "unlike"); twitter_action($a, $b["uid"], substr($b["thr-parent"], 9), "unlike");
} else { } else {
@ -541,7 +541,7 @@ function twitter_post_hook(App $a, array &$b)
$osecret = PConfig::get($b['uid'], 'twitter', 'oauthsecret'); $osecret = PConfig::get($b['uid'], 'twitter', 'oauthsecret');
if ($ckey && $csecret && $otoken && $osecret) { if ($ckey && $csecret && $otoken && $osecret) {
Logger::log('twitter: we have customer key and oauth stuff, going to send.', LOGGER_DEBUG); Logger::log('twitter: we have customer key and oauth stuff, going to send.', Logger::DEBUG);
// If it's a repeated message from twitter then do a native retweet and exit // If it's a repeated message from twitter then do a native retweet and exit
if (twitter_is_retweet($a, $b['uid'], $b['body'])) { if (twitter_is_retweet($a, $b['uid'], $b['body'])) {
@ -629,7 +629,7 @@ function twitter_post_hook(App $a, array &$b)
$url = 'statuses/update'; $url = 'statuses/update';
$result = $connection->post($url, $post); $result = $connection->post($url, $post);
Logger::log('twitter_post send, result: ' . print_r($result, true), LOGGER_DEBUG); Logger::log('twitter_post send, result: ' . print_r($result, true), Logger::DEBUG);
if (!empty($result->source)) { if (!empty($result->source)) {
Config::set("twitter", "application_name", strip_tags($result->source)); Config::set("twitter", "application_name", strip_tags($result->source));
@ -909,13 +909,13 @@ function twitter_fetchtimeline(App $a, $uid)
} }
if (!is_array($items)) { if (!is_array($items)) {
Logger::log('No items for user ' . $uid, LOGGER_INFO); Logger::log('No items for user ' . $uid, Logger::INFO);
return; return;
} }
$posts = array_reverse($items); $posts = array_reverse($items);
Logger::log('Starting from ID ' . $lastid . ' for user ' . $uid, LOGGER_DEBUG); Logger::log('Starting from ID ' . $lastid . ' for user ' . $uid, Logger::DEBUG);
if (count($posts)) { if (count($posts)) {
foreach ($posts as $post) { foreach ($posts as $post) {
@ -932,7 +932,7 @@ function twitter_fetchtimeline(App $a, $uid)
$_SESSION["authenticated"] = true; $_SESSION["authenticated"] = true;
$_SESSION["uid"] = $uid; $_SESSION["uid"] = $uid;
Logger::log('Preparing Twitter ID ' . $post->id_str . ' for user ' . $uid, LOGGER_DEBUG); Logger::log('Preparing Twitter ID ' . $post->id_str . ' for user ' . $uid, Logger::DEBUG);
$_REQUEST = twitter_do_mirrorpost($a, $uid, $post); $_REQUEST = twitter_do_mirrorpost($a, $uid, $post);
@ -947,7 +947,7 @@ function twitter_fetchtimeline(App $a, $uid)
} }
} }
PConfig::set($uid, 'twitter', 'lastid', $lastid); PConfig::set($uid, 'twitter', 'lastid', $lastid);
Logger::log('Last ID for user ' . $uid . ' is now ' . $lastid, LOGGER_DEBUG); Logger::log('Last ID for user ' . $uid . ' is now ' . $lastid, Logger::DEBUG);
} }
function twitter_queue_hook(App $a) function twitter_queue_hook(App $a)
@ -991,7 +991,7 @@ function twitter_queue_hook(App $a)
$connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret); $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
$result = $connection->post($z['url'], $z['post']); $result = $connection->post($z['url'], $z['post']);
Logger::log('twitter_queue: post result: ' . print_r($result, true), LOGGER_DEBUG); Logger::log('twitter_queue: post result: ' . print_r($result, true), Logger::DEBUG);
if ($result->errors) { if ($result->errors) {
Logger::log('twitter_queue: Send to Twitter failed: "' . print_r($result->errors, true) . '"'); Logger::log('twitter_queue: Send to Twitter failed: "' . print_r($result->errors, true) . '"');
@ -1078,7 +1078,7 @@ function twitter_fetch_contact($uid, $data, $create_user)
Contact::updateAvatar($avatar, $uid, $contact_id); Contact::updateAvatar($avatar, $uid, $contact_id);
} else { } else {
if ($contact["readonly"] || $contact["blocked"]) { if ($contact["readonly"] || $contact["blocked"]) {
Logger::log("twitter_fetch_contact: Contact '" . $contact["nick"] . "' is blocked or readonly.", LOGGER_DEBUG); Logger::log("twitter_fetch_contact: Contact '" . $contact["nick"] . "' is blocked or readonly.", Logger::DEBUG);
return -1; return -1;
} }
@ -1089,7 +1089,7 @@ function twitter_fetch_contact($uid, $data, $create_user)
// check that we have all the photos, this has been known to fail on occasion // check that we have all the photos, this has been known to fail on occasion
if (empty($contact['photo']) || empty($contact['thumb']) || empty($contact['micro']) || $update_photo) { if (empty($contact['photo']) || empty($contact['thumb']) || empty($contact['micro']) || $update_photo) {
Logger::log("twitter_fetch_contact: Updating contact " . $data->screen_name, LOGGER_DEBUG); Logger::log("twitter_fetch_contact: Updating contact " . $data->screen_name, Logger::DEBUG);
Contact::updateAvatar($avatar, $uid, $contact['id']); Contact::updateAvatar($avatar, $uid, $contact['id']);
@ -1388,7 +1388,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
// Don't import our own comments // Don't import our own comments
if (Item::exists(['extid' => $postarray['uri'], 'uid' => $uid])) { if (Item::exists(['extid' => $postarray['uri'], 'uid' => $uid])) {
Logger::log("Item with extid " . $postarray['uri'] . " found.", LOGGER_DEBUG); Logger::log("Item with extid " . $postarray['uri'] . " found.", Logger::DEBUG);
return []; return [];
} }
@ -1428,7 +1428,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
$postarray['owner-link'] = $r[0]["url"]; $postarray['owner-link'] = $r[0]["url"];
$postarray['owner-avatar'] = $r[0]["photo"]; $postarray['owner-avatar'] = $r[0]["photo"];
} else { } else {
Logger::log("No self contact for user " . $uid, LOGGER_DEBUG); Logger::log("No self contact for user " . $uid, Logger::DEBUG);
return []; return [];
} }
} }
@ -1450,7 +1450,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
if (($contactid == 0) && !$only_existing_contact) { if (($contactid == 0) && !$only_existing_contact) {
$contactid = $self['id']; $contactid = $self['id'];
} elseif ($contactid <= 0) { } elseif ($contactid <= 0) {
Logger::log("Contact ID is zero or less than zero.", LOGGER_DEBUG); Logger::log("Contact ID is zero or less than zero.", Logger::DEBUG);
return []; return [];
} }
@ -1547,7 +1547,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection, array $self) function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection, array $self)
{ {
Logger::log("twitter_fetchparentposts: Fetching for user " . $uid . " and post " . $post->id_str, LOGGER_DEBUG); Logger::log("twitter_fetchparentposts: Fetching for user " . $uid . " and post " . $post->id_str, Logger::DEBUG);
$posts = []; $posts = [];
@ -1562,12 +1562,12 @@ function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection,
} }
if (empty($post)) { if (empty($post)) {
Logger::log("twitter_fetchparentposts: Can't fetch post " . $parameters->id, LOGGER_DEBUG); Logger::log("twitter_fetchparentposts: Can't fetch post " . $parameters->id, Logger::DEBUG);
break; break;
} }
if (empty($post->id_str)) { if (empty($post->id_str)) {
Logger::log("twitter_fetchparentposts: This is not a post " . json_encode($post), LOGGER_DEBUG); Logger::log("twitter_fetchparentposts: This is not a post " . json_encode($post), Logger::DEBUG);
break; break;
} }
@ -1578,7 +1578,7 @@ function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection,
$posts[] = $post; $posts[] = $post;
} }
Logger::log("twitter_fetchparentposts: Fetching " . count($posts) . " parents", LOGGER_DEBUG); Logger::log("twitter_fetchparentposts: Fetching " . count($posts) . " parents", Logger::DEBUG);
$posts = array_reverse($posts); $posts = array_reverse($posts);
@ -1608,7 +1608,7 @@ function twitter_fetchhometimeline(App $a, $uid)
$create_user = PConfig::get($uid, 'twitter', 'create_user'); $create_user = PConfig::get($uid, 'twitter', 'create_user');
$mirror_posts = PConfig::get($uid, 'twitter', 'mirror_posts'); $mirror_posts = PConfig::get($uid, 'twitter', 'mirror_posts');
Logger::log("Fetching timeline for user " . $uid, LOGGER_DEBUG); Logger::log("Fetching timeline for user " . $uid, Logger::DEBUG);
$application_name = Config::get('twitter', 'application_name'); $application_name = Config::get('twitter', 'application_name');
@ -1668,13 +1668,13 @@ function twitter_fetchhometimeline(App $a, $uid)
} }
if (empty($items)) { if (empty($items)) {
Logger::log('No new timeline content for user ' . $uid, LOGGER_INFO); Logger::log('No new timeline content for user ' . $uid, Logger::INFO);
return; return;
} }
$posts = array_reverse($items); $posts = array_reverse($items);
Logger::log('Fetching timeline from ID ' . $lastid . ' for user ' . $uid . ' ' . sizeof($posts) . ' items', LOGGER_DEBUG); Logger::log('Fetching timeline from ID ' . $lastid . ' for user ' . $uid . ' ' . sizeof($posts) . ' items', Logger::DEBUG);
if (count($posts)) { if (count($posts)) {
foreach ($posts as $post) { foreach ($posts as $post) {
@ -1688,12 +1688,12 @@ function twitter_fetchhometimeline(App $a, $uid)
} }
if (stristr($post->source, $application_name) && $post->user->screen_name == $own_id) { if (stristr($post->source, $application_name) && $post->user->screen_name == $own_id) {
Logger::log("Skip previously sent post", LOGGER_DEBUG); Logger::log("Skip previously sent post", Logger::DEBUG);
continue; continue;
} }
if ($mirror_posts && $post->user->screen_name == $own_id && $post->in_reply_to_status_id_str == "") { if ($mirror_posts && $post->user->screen_name == $own_id && $post->in_reply_to_status_id_str == "") {
Logger::log("Skip post that will be mirrored", LOGGER_DEBUG); Logger::log("Skip post that will be mirrored", Logger::DEBUG);
continue; continue;
} }
@ -1701,12 +1701,12 @@ function twitter_fetchhometimeline(App $a, $uid)
twitter_fetchparentposts($a, $uid, $post, $connection, $self); twitter_fetchparentposts($a, $uid, $post, $connection, $self);
} }
Logger::log('Preparing post ' . $post->id_str . ' for user ' . $uid, LOGGER_DEBUG); Logger::log('Preparing post ' . $post->id_str . ' for user ' . $uid, Logger::DEBUG);
$postarray = twitter_createpost($a, $uid, $post, $self, $create_user, true, false); $postarray = twitter_createpost($a, $uid, $post, $self, $create_user, true, false);
if (empty($postarray['body']) || trim($postarray['body']) == "") { if (empty($postarray['body']) || trim($postarray['body']) == "") {
Logger::log('Empty body for post ' . $post->id_str . ' and user ' . $uid, LOGGER_DEBUG); Logger::log('Empty body for post ' . $post->id_str . ' and user ' . $uid, Logger::DEBUG);
continue; continue;
} }
@ -1727,7 +1727,7 @@ function twitter_fetchhometimeline(App $a, $uid)
} }
PConfig::set($uid, 'twitter', 'lasthometimelineid', $lastid); PConfig::set($uid, 'twitter', 'lasthometimelineid', $lastid);
Logger::log('Last timeline ID for user ' . $uid . ' is now ' . $lastid, LOGGER_DEBUG); Logger::log('Last timeline ID for user ' . $uid . ' is now ' . $lastid, Logger::DEBUG);
// Fetching mentions // Fetching mentions
$lastid = PConfig::get($uid, 'twitter', 'lastmentionid'); $lastid = PConfig::get($uid, 'twitter', 'lastmentionid');
@ -1746,13 +1746,13 @@ function twitter_fetchhometimeline(App $a, $uid)
} }
if (!is_array($items)) { if (!is_array($items)) {
Logger::log("Error fetching mentions: " . print_r($items, true), LOGGER_DEBUG); Logger::log("Error fetching mentions: " . print_r($items, true), Logger::DEBUG);
return; return;
} }
$posts = array_reverse($items); $posts = array_reverse($items);
Logger::log("Fetching mentions for user " . $uid . " " . sizeof($posts) . " items", LOGGER_DEBUG); Logger::log("Fetching mentions for user " . $uid . " " . sizeof($posts) . " items", Logger::DEBUG);
if (count($posts)) { if (count($posts)) {
foreach ($posts as $post) { foreach ($posts as $post) {
@ -1782,7 +1782,7 @@ function twitter_fetchhometimeline(App $a, $uid)
PConfig::set($uid, 'twitter', 'lastmentionid', $lastid); PConfig::set($uid, 'twitter', 'lastmentionid', $lastid);
Logger::log('Last mentions ID for user ' . $uid . ' is now ' . $lastid, LOGGER_DEBUG); Logger::log('Last mentions ID for user ' . $uid . ' is now ' . $lastid, Logger::DEBUG);
} }
function twitter_fetch_own_contact(App $a, $uid) function twitter_fetch_own_contact(App $a, $uid)
@ -1857,7 +1857,7 @@ function twitter_is_retweet(App $a, $uid, $body)
return false; return false;
} }
Logger::log('twitter_is_retweet: Retweeting id ' . $id . ' for user ' . $uid, LOGGER_DEBUG); Logger::log('twitter_is_retweet: Retweeting id ' . $id . ' for user ' . $uid, Logger::DEBUG);
$ckey = Config::get('twitter', 'consumerkey'); $ckey = Config::get('twitter', 'consumerkey');
$csecret = Config::get('twitter', 'consumersecret'); $csecret = Config::get('twitter', 'consumersecret');
@ -1867,7 +1867,7 @@ function twitter_is_retweet(App $a, $uid, $body)
$connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret); $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
$result = $connection->post('statuses/retweet/' . $id); $result = $connection->post('statuses/retweet/' . $id);
Logger::log('twitter_is_retweet: result ' . print_r($result, true), LOGGER_DEBUG); Logger::log('twitter_is_retweet: result ' . print_r($result, true), Logger::DEBUG);
return !isset($result->errors); return !isset($result->errors);
} }

View File

@ -456,7 +456,7 @@ function windowsphonepush_updatecounterunseen()
function windowsphonepush_login(App $a) function windowsphonepush_login(App $a)
{ {
if (!isset($_SERVER['PHP_AUTH_USER'])) { if (!isset($_SERVER['PHP_AUTH_USER'])) {
Logger::log('API_login: ' . print_r($_SERVER, true), LOGGER_DEBUG); Logger::log('API_login: ' . print_r($_SERVER, true), Logger::DEBUG);
header('WWW-Authenticate: Basic realm="Friendica"'); header('WWW-Authenticate: Basic realm="Friendica"');
header('HTTP/1.0 401 Unauthorized'); header('HTTP/1.0 401 Unauthorized');
die('This api requires login'); die('This api requires login');
@ -467,7 +467,7 @@ function windowsphonepush_login(App $a)
if ($user_id) { if ($user_id) {
$record = DBA::selectFirst('user', [], ['uid' => $user_id]); $record = DBA::selectFirst('user', [], ['uid' => $user_id]);
} else { } else {
Logger::log('API_login failure: ' . print_r($_SERVER, true), LOGGER_DEBUG); Logger::log('API_login failure: ' . print_r($_SERVER, true), Logger::DEBUG);
header('WWW-Authenticate: Basic realm="Friendica"'); header('WWW-Authenticate: Basic realm="Friendica"');
header('HTTP/1.0 401 Unauthorized'); header('HTTP/1.0 401 Unauthorized');
die('This api requires login'); die('This api requires login');

View File

@ -313,11 +313,11 @@ function wppost_send(&$a,&$b) {
EOT; EOT;
Logger::log('wppost: data: ' . $xml, LOGGER_DATA); Logger::log('wppost: data: ' . $xml, Logger::DATA);
if ($wp_blog !== 'test') { if ($wp_blog !== 'test') {
$x = Network::post($wp_blog, $xml)->getBody(); $x = Network::post($wp_blog, $xml)->getBody();
} }
Logger::log('posted to wordpress: ' . (($x) ? $x : ''), LOGGER_DEBUG); Logger::log('posted to wordpress: ' . (($x) ? $x : ''), Logger::DEBUG);
} }
} }