diff --git a/include/api.php b/include/api.php index d54e540f7..55e39e358 100644 --- a/include/api.php +++ b/include/api.php @@ -161,10 +161,7 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) { logger('API_login: ' . print_r($_SERVER,true), LOGGER_DEBUG); header('WWW-Authenticate: Basic realm="Friendica"'); - header('HTTP/1.0 401 Unauthorized'); - die((api_error($a, 'json', "This api requires login"))); - - //die('This api requires login'); + throw new UnauthorizedException("This API requires login"); } $user = $_SERVER['PHP_AUTH_USER']; @@ -216,8 +213,9 @@ if((! $record) || (! count($record))) { logger('API_login failure: ' . print_r($_SERVER,true), LOGGER_DEBUG); header('WWW-Authenticate: Basic realm="Friendica"'); - header('HTTP/1.0 401 Unauthorized'); - die('This api requires login'); + #header('HTTP/1.0 401 Unauthorized'); + #die('This api requires login'); + throw new UnauthorizedException("This API requires login"); } authenticate_success($record); $_SESSION["allow_api"] = true; @@ -331,7 +329,8 @@ * * @param Api $a * @param string $type Return type (xml, json, rss, as) - * @param string $error Error message + * @param HTTPException $error Error object + * @return strin error message formatted as $type */ function api_error(&$a, $type, $e) { $error = ($e->getMessage()!==""?$e->getMessage():$e->httpdesc); @@ -903,7 +902,8 @@ if ($posts_day > $throttle_day) { logger('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG); - die(api_error($a, $type, sprintf(t("Daily posting limit of %d posts reached. The post was rejected."), $throttle_day))); + #die(api_error($a, $type, sprintf(t("Daily posting limit of %d posts reached. The post was rejected."), $throttle_day))); + throw new TooManyRequestsException(sprintf(t("Daily posting limit of %d posts reached. The post was rejected."), $throttle_day)); } } @@ -922,7 +922,9 @@ if ($posts_week > $throttle_week) { logger('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG); - die(api_error($a, $type, sprintf(t("Weekly posting limit of %d posts reached. The post was rejected."), $throttle_week))); + #die(api_error($a, $type, sprintf(t("Weekly posting limit of %d posts reached. The post was rejected."), $throttle_week))); + throw new TooManyRequestsException(sprintf(t("Weekly posting limit of %d posts reached. The post was rejected."), $throttle_week)); + } } @@ -941,7 +943,8 @@ if ($posts_month > $throttle_month) { logger('Monthly posting limit reached for user '.api_user(), LOGGER_DEBUG); - die(api_error($a, $type, sprintf(t("Monthly posting limit of %d posts reached. The post was rejected."), $throttle_month))); + #die(api_error($a, $type, sprintf(t("Monthly posting limit of %d posts reached. The post was rejected."), $throttle_month))); + throw new TooManyRequestsException(sprintf(t("Monthly posting limit of %d posts reached. The post was rejected."), $throttle_month)); } } @@ -1809,7 +1812,7 @@ $action_argv_id=2; if ($a->argv[1]=="1.1") $action_argv_id=3; - if ($a->argc<=$action_argv_id) die(api_error($a, $type, t("Invalid request."))); + if ($a->argc<=$action_argv_id) throw new BadRequestException("Invalid request."); $action = str_replace(".".$type,"",$a->argv[$action_argv_id]); if ($a->argc==$action_argv_id+2) { $itemid = intval($a->argv[$action_argv_id+1]); diff --git a/include/socgraph.php b/include/socgraph.php index bd5b1817f..186326f42 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -438,44 +438,47 @@ function poco_last_updated($profile, $force = false) { $noscrape = json_decode($noscraperet["body"], true); - $contact = array("url" => $profile, - "network" => $server[0]["network"], - "generation" => $gcontacts[0]["generation"]); + if (is_array($noscrape)) { + $contact = array("url" => $profile, + "network" => $server[0]["network"], + "generation" => $gcontacts[0]["generation"]); - $contact["name"] = $noscrape["fn"]; - $contact["community"] = $noscrape["comm"]; + $contact["name"] = $noscrape["fn"]; + $contact["community"] = $noscrape["comm"]; - if (isset($noscrape["tags"])) { - $keywords = implode(" ", $noscrape["tags"]); - if ($keywords != "") - $contact["keywords"] = $keywords; + if (isset($noscrape["tags"])) { + $keywords = implode(" ", $noscrape["tags"]); + if ($keywords != "") + $contact["keywords"] = $keywords; + } + + $location = formatted_location($noscrape); + if ($location) + $contact["location"] = $location; + + $contact["notify"] = $noscrape["dfrn-notify"]; + + // Remove all fields that are not present in the gcontact table + unset($noscrape["fn"]); + unset($noscrape["key"]); + unset($noscrape["homepage"]); + unset($noscrape["comm"]); + unset($noscrape["tags"]); + unset($noscrape["locality"]); + unset($noscrape["region"]); + unset($noscrape["country-name"]); + unset($noscrape["contacts"]); + unset($noscrape["dfrn-request"]); + unset($noscrape["dfrn-confirm"]); + unset($noscrape["dfrn-notify"]); + unset($noscrape["dfrn-poll"]); + + $contact = array_merge($contact, $noscrape); + + update_gcontact($contact); + + return $noscrape["updated"]; } - - $location = formatted_location($noscrape); - if ($location) - $contact["location"] = $location; - - $contact["notify"] = $noscrape["dfrn-notify"]; - - // Remove all fields that are not present in the gcontact table - unset($noscrape["fn"]); - unset($noscrape["key"]); - unset($noscrape["homepage"]); - unset($noscrape["comm"]); - unset($noscrape["tags"]); - unset($noscrape["locality"]); - unset($noscrape["region"]); - unset($noscrape["country-name"]); - unset($noscrape["contacts"]); - unset($noscrape["dfrn-request"]); - unset($noscrape["dfrn-confirm"]); - unset($noscrape["dfrn-notify"]); - unset($noscrape["dfrn-poll"]); - - $contact = array_merge($contact, $noscrape); - update_gcontact($contact); - - return $noscrape["updated"]; } } } diff --git a/view/it/messages.po b/view/it/messages.po index b2b88bc72..a9df298ca 100644 --- a/view/it/messages.po +++ b/view/it/messages.po @@ -16,7 +16,7 @@ msgstr "" "Project-Id-Version: friendica\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-01-24 06:49+0100\n" -"PO-Revision-Date: 2016-01-30 08:43+0000\n" +"PO-Revision-Date: 2016-02-16 10:29+0000\n" "Last-Translator: Sandro Santilli \n" "Language-Team: Italian (http://www.transifex.com/Friendica/friendica/language/it/)\n" "MIME-Version: 1.0\n" @@ -41,8 +41,8 @@ msgstr "Forum" #, php-format msgid "%d contact edited." msgid_plural "%d contacts edited." -msgstr[0] "" -msgstr[1] "" +msgstr[0] "%d contatto modificato." +msgstr[1] "%d contatti modificati" #: mod/contacts.php:159 mod/contacts.php:383 msgid "Could not access contact record." @@ -887,7 +887,7 @@ msgstr "Rimuovi" #: mod/ostatus_subscribe.php:14 msgid "Subscribing to OStatus contacts" -msgstr "" +msgstr "Iscrizione a contatti OStatus" #: mod/ostatus_subscribe.php:25 msgid "No contact provided." @@ -1943,7 +1943,7 @@ msgstr "Ispeziona Coda di invio" #: mod/admin.php:163 mod/admin.php:354 msgid "Federation Statistics" -msgstr "" +msgstr "Statistiche sulla Federazione" #: mod/admin.php:177 mod/admin.php:188 mod/admin.php:1792 msgid "Logs" @@ -1951,7 +1951,7 @@ msgstr "Log" #: mod/admin.php:178 mod/admin.php:1859 msgid "View Logs" -msgstr "" +msgstr "Vedi i log" #: mod/admin.php:179 msgid "probe address" @@ -1982,7 +1982,7 @@ msgid "" "This page offers you some numbers to the known part of the federated social " "network your Friendica node is part of. These numbers are not complete but " "only reflect the part of the network your node is aware of." -msgstr "" +msgstr "Questa pagina offre alcuni numeri riguardo la porzione del social network federato di cui il tuo nodo Friendica fa parte. Questi numeri non sono completi ma riflettono esclusivamente la porzione di rete di cui il tuo nodo e' a conoscenza." #: mod/admin.php:348 msgid "" diff --git a/view/it/strings.php b/view/it/strings.php index 606ae1e16..131e03080 100644 --- a/view/it/strings.php +++ b/view/it/strings.php @@ -8,8 +8,8 @@ function string_plural_select_it($n){ $a->strings["Network:"] = "Rete:"; $a->strings["Forum"] = "Forum"; $a->strings["%d contact edited."] = array( - 0 => "", - 1 => "", + 0 => "%d contatto modificato.", + 1 => "%d contatti modificati", ); $a->strings["Could not access contact record."] = "Non è possibile accedere al contatto."; $a->strings["Could not locate selected profile."] = "Non riesco a trovare il profilo selezionato."; @@ -186,7 +186,7 @@ $a->strings["Tag removed"] = "Tag rimosso"; $a->strings["Remove Item Tag"] = "Rimuovi il tag"; $a->strings["Select a tag to remove: "] = "Seleziona un tag da rimuovere: "; $a->strings["Remove"] = "Rimuovi"; -$a->strings["Subscribing to OStatus contacts"] = ""; +$a->strings["Subscribing to OStatus contacts"] = "Iscrizione a contatti OStatus"; $a->strings["No contact provided."] = "Nessun contatto disponibile."; $a->strings["Couldn't fetch information for contact."] = "Non è stato possibile recuperare le informazioni del contatto."; $a->strings["Couldn't fetch friends for contact."] = "Non è stato possibile recuperare gli amici del contatto."; @@ -419,16 +419,16 @@ $a->strings["Themes"] = "Temi"; $a->strings["Additional features"] = "Funzionalità aggiuntive"; $a->strings["DB updates"] = "Aggiornamenti Database"; $a->strings["Inspect Queue"] = "Ispeziona Coda di invio"; -$a->strings["Federation Statistics"] = ""; +$a->strings["Federation Statistics"] = "Statistiche sulla Federazione"; $a->strings["Logs"] = "Log"; -$a->strings["View Logs"] = ""; +$a->strings["View Logs"] = "Vedi i log"; $a->strings["probe address"] = "controlla indirizzo"; $a->strings["check webfinger"] = "verifica webfinger"; $a->strings["Admin"] = "Amministrazione"; $a->strings["Plugin Features"] = "Impostazioni Plugins"; $a->strings["diagnostics"] = "diagnostiche"; $a->strings["User registrations waiting for confirmation"] = "Utenti registrati in attesa di conferma"; -$a->strings["This page offers you some numbers to the known part of the federated social network your Friendica node is part of. These numbers are not complete but only reflect the part of the network your node is aware of."] = ""; +$a->strings["This page offers you some numbers to the known part of the federated social network your Friendica node is part of. These numbers are not complete but only reflect the part of the network your node is aware of."] = "Questa pagina offre alcuni numeri riguardo la porzione del social network federato di cui il tuo nodo Friendica fa parte. Questi numeri non sono completi ma riflettono esclusivamente la porzione di rete di cui il tuo nodo e' a conoscenza."; $a->strings["The Auto Discovered Contact Directory feature is not enabled, it will improve the data displayed here."] = ""; $a->strings["Administration"] = "Amministrazione"; $a->strings["Currently this node is aware of %d nodes from the following platforms:"] = "";