diff --git a/boot.php b/boot.php index 56fb054358..504a524ed7 100644 --- a/boot.php +++ b/boot.php @@ -430,6 +430,17 @@ define('PRIORITY_LOW', 40); define('PRIORITY_NEGLIGIBLE',50); /* @}*/ +/** + * @name Social Relay settings + * + * See here: https://github.com/jaywink/social-relay + * and here: https://wiki.diasporafoundation.org/Relay_servers_for_public_posts + * @{ + */ +define('SR_SCOPE_NONE', ''); +define('SR_SCOPE_ALL', 'all'); +define('SR_SCOPE_TAGS', 'tags'); +/* @}*/ // Normally this constant is defined - but not if "pcntl" isn't installed if (!defined("SIGTERM")) @@ -1404,6 +1415,53 @@ class App { proc_close(proc_open($cmdline." &",array(),$foo,dirname(__FILE__))); } + + /** + * @brief Returns the system user that is executing the script + * + * This mostly returns something like "www-data". + * + * @return string system username + */ + static function systemuser() { + if (!function_exists('posix_getpwuid') OR !function_exists('posix_geteuid')) { + return ''; + } + + $processUser = posix_getpwuid(posix_geteuid()); + return $processUser['name']; + } + + /** + * @brief Checks if a given directory is usable for the system + * + * @return boolean the directory is usable + */ + static function directory_usable($directory) { + + if ($directory == '') { + logger("Directory is empty. This shouldn't happen.", LOGGER_DEBUG); + return false; + } + + if (!file_exists($directory)) { + logger('Path "'.$directory.'" does not exist for user '.self::systemuser(), LOGGER_DEBUG); + return false; + } + if (is_file($directory)) { + logger('Path "'.$directory.'" is a file for user '.self::systemuser(), LOGGER_DEBUG); + return false; + } + if (!is_dir($directory)) { + logger('Path "'.$directory.'" is not a directory for user '.self::systemuser(), LOGGER_DEBUG); + return false; + } + if (!is_writable($directory)) { + logger('Path "'.$temppath.'" is not writable for user '.self::systemuser(), LOGGER_DEBUG); + return false; + } + return true; + } } /** @@ -2308,8 +2366,9 @@ function get_itemcachepath() { return ""; $itemcache = get_config('system','itemcache'); - if (($itemcache != "") AND is_dir($itemcache) AND is_writable($itemcache)) + if (($itemcache != "") AND App::directory_usable($itemcache)) { return($itemcache); + } $temppath = get_temppath(); @@ -2319,7 +2378,7 @@ function get_itemcachepath() { mkdir($itemcache); } - if (is_dir($itemcache) AND is_writable($itemcache)) { + if (App::directory_usable($itemcache)) { set_config("system", "itemcache", $itemcache); return($itemcache); } @@ -2329,20 +2388,22 @@ function get_itemcachepath() { function get_lockpath() { $lockpath = get_config('system','lockpath'); - if (($lockpath != "") AND is_dir($lockpath) AND is_writable($lockpath)) + if (($lockpath != "") AND App::directory_usable($lockpath)) { return($lockpath); + } $temppath = get_temppath(); if ($temppath != "") { $lockpath = $temppath."/lock"; - if (!is_dir($lockpath)) + if (!is_dir($lockpath)) { mkdir($lockpath); - elseif (!is_writable($lockpath)) + } elseif (!App::directory_usable($lockpath)) { $lockpath = $temppath; + } - if (is_dir($lockpath) AND is_writable($lockpath)) { + if (App::directory_usable($lockpath)) { set_config("system", "lockpath", $lockpath); return($lockpath); } @@ -2357,7 +2418,7 @@ function get_lockpath() { */ function get_spoolpath() { $spoolpath = get_config('system','spoolpath'); - if (($spoolpath != "") AND is_dir($spoolpath) AND is_writable($spoolpath)) { + if (($spoolpath != "") AND App::directory_usable($spoolpath)) { return($spoolpath); } @@ -2368,11 +2429,11 @@ function get_spoolpath() { if (!is_dir($spoolpath)) { mkdir($spoolpath); - } elseif (!is_writable($spoolpath)) { + } elseif (!App::directory_usable($spoolpath)) { $spoolpath = $temppath; } - if (is_dir($spoolpath) AND is_writable($spoolpath)) { + if (App::directory_usable($spoolpath)) { set_config("system", "spoolpath", $spoolpath); return($spoolpath); } @@ -2384,16 +2445,18 @@ function get_temppath() { $a = get_app(); $temppath = get_config("system","temppath"); - if (($temppath != "") AND is_dir($temppath) AND is_writable($temppath)) + + if (($temppath != "") AND App::directory_usable($temppath)) { return($temppath); + } $temppath = sys_get_temp_dir(); - if (($temppath != "") AND is_dir($temppath) AND is_writable($temppath)) { + if (($temppath != "") AND App::directory_usable($temppath)) { $temppath .= "/".$a->get_hostname(); if (!is_dir($temppath)) mkdir($temppath); - if (is_dir($temppath) AND is_writable($temppath)) { + if (App::directory_usable($temppath)) { set_config("system", "temppath", $temppath); return($temppath); } diff --git a/include/Contact.php b/include/Contact.php index 956e8e2919..2aab828f8a 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -730,6 +730,10 @@ function posts_from_contact_url(App $a, $contact_url) { $sql = "`item`.`uid` = %d"; } + if (!dbm::is_result($r)) { + return ''; + } + $author_id = intval($r[0]["author-id"]); if (get_config('system', 'old_pager')) { diff --git a/include/api.php b/include/api.php index ce76103129..d7fa1d5875 100644 --- a/include/api.php +++ b/include/api.php @@ -626,7 +626,7 @@ use \Friendica\Core\Config; // count friends $r = q("SELECT count(*) as `count` FROM `contact` WHERE `uid` = %d AND `rel` IN ( %d, %d ) - AND `self`=0 AND NOT `blocked` AND `hidden`=0", + AND `self`=0 AND NOT `blocked` AND NOT `pending` AND `hidden`=0", intval($uinfo[0]['uid']), intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND) @@ -635,7 +635,7 @@ use \Friendica\Core\Config; $r = q("SELECT count(*) as `count` FROM `contact` WHERE `uid` = %d AND `rel` IN ( %d, %d ) - AND `self`=0 AND NOT `blocked` AND `hidden`=0", + AND `self`=0 AND NOT `blocked` AND NOT `pending` AND `hidden`=0", intval($uinfo[0]['uid']), intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND) diff --git a/include/diaspora.php b/include/diaspora.php index fdbc0479f9..eca22092d8 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -8,6 +8,8 @@ * This will change in the future. */ +use \Friendica\Core\Config; + require_once("include/items.php"); require_once("include/bb2diaspora.php"); require_once("include/Scrape.php"); @@ -309,10 +311,6 @@ class Diaspora { return false; } - // Use a dummy importer to import the data for the public copy - $importer = array("uid" => 0, "page-flags" => PAGE_FREELOVE); - $message_id = self::dispatch($importer,$msg); - // Now distribute it to the followers $r = q("SELECT `user`.* FROM `user` WHERE `user`.`uid` IN (SELECT `contact`.`uid` FROM `contact` WHERE `contact`.`network` = '%s' AND `contact`.`addr` = '%s') @@ -320,13 +318,22 @@ class Diaspora { dbesc(NETWORK_DIASPORA), dbesc($msg["author"]) ); - if ($r) { + + if (dbm::is_result($r)) { foreach ($r as $rr) { logger("delivering to: ".$rr["username"]); self::dispatch($rr,$msg); } } else { - logger("No subscribers for ".$msg["author"]." ".print_r($msg, true), LOGGER_DEBUG); + $social_relay = (bool)Config::get('system', 'relay_subscribe', false); + + // Use a dummy importer to import the data for the public copy + if ($social_relay) { + $importer = array("uid" => 0, "page-flags" => PAGE_FREELOVE); + $message_id = self::dispatch($importer,$msg); + } else { + logger("Unwanted message from ".$msg["author"]." send by ".$_SERVER["REMOTE_ADDR"]." with ".$_SERVER["HTTP_USER_AGENT"].": ".print_r($msg, true), LOGGER_DEBUG); + } } return $message_id; diff --git a/include/identity.php b/include/identity.php index d3852b2c2c..ab80c71cea 100644 --- a/include/identity.php +++ b/include/identity.php @@ -374,7 +374,10 @@ function profile_sidebar($profile, $block = 0) { if (dbm::is_result($r)) $updated = date("c", strtotime($r[0]['updated'])); - $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `hidden` AND NOT `archive` + $r = q("SELECT COUNT(*) AS `total` FROM `contact` + WHERE `uid` = %d + AND NOT `self` AND NOT `blocked` AND NOT `pending` + AND NOT `hidden` AND NOT `archive` AND `network` IN ('%s', '%s', '%s', '')", intval($profile['uid']), dbesc(NETWORK_DFRN), diff --git a/include/spool_post.php b/include/spool_post.php index d55b100eda..d2c94881bd 100644 --- a/include/spool_post.php +++ b/include/spool_post.php @@ -35,7 +35,19 @@ function spool_post_run($argv, $argc) { continue; } $arr = json_decode(file_get_contents($fullfile), true); + + // If it isn't an array then it is no spool file + if (!is_array($arr)) { + continue; + } + + // Skip if it doesn't seem to be an item array + if (!isset($arr['uid']) AND !isset($arr['uri']) AND !isset($arr['network'])) { + continue; + } + $result = item_store($arr); + logger("Spool file ".$file." stored: ".$result, LOGGER_DEBUG); unlink($fullfile); } diff --git a/include/text.php b/include/text.php index f77a4dec2c..11248902ba 100644 --- a/include/text.php +++ b/include/text.php @@ -875,7 +875,7 @@ function contact_block() { return $o; $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` - AND NOT `hidden` AND NOT `archive` + AND NOT `pending` AND NOT `hidden` AND NOT `archive` AND `network` IN ('%s', '%s', '%s')", intval($a->profile['uid']), dbesc(NETWORK_DFRN), @@ -893,8 +893,9 @@ function contact_block() { // Splitting the query in two parts makes it much faster $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` - AND NOT `hidden` AND NOT `archive` - AND `network` IN ('%s', '%s', '%s') ORDER BY RAND() LIMIT %d", + AND NOT `pending` AND NOT `hidden` AND NOT `archive` + AND `network` IN ('%s', '%s', '%s') + ORDER BY RAND() LIMIT %d", intval($a->profile['uid']), dbesc(NETWORK_DFRN), dbesc(NETWORK_OSTATUS), diff --git a/mod/_well_known.php b/mod/_well_known.php index 75948a0088..622d7fd93f 100644 --- a/mod/_well_known.php +++ b/mod/_well_known.php @@ -1,67 +1,68 @@ -argc > 1) { - switch($a->argv[1]) { - case "host-meta": - hostxrd_init($a); - break; - case "x-social-relay": - wk_social_relay($a); - break; - case "nodeinfo": - nodeinfo_wellknown($a); - break; - } - } - http_status_exit(404); - killme(); -} - -function wk_social_relay(App $a) { - - define('SR_SCOPE_ALL', 'all'); - define('SR_SCOPE_TAGS', 'tags'); - - $subscribe = (bool)get_config('system', 'relay_subscribe'); - - if ($subscribe) - $scope = get_config('system', 'relay_scope'); - else - $scope = ""; - - $tags = array(); - - if ($scope == SR_SCOPE_TAGS) { - - $server_tags = get_config('system', 'relay_server_tags'); - $tagitems = explode(",", $server_tags); - - foreach($tagitems AS $tag) - $tags[trim($tag, "# ")] = trim($tag, "# "); - - if (get_config('system', 'relay_user_tags')) { - $terms = q("SELECT DISTINCT(`term`) FROM `search`"); - - foreach($terms AS $term) { - $tag = trim($term["term"], "#"); - $tags[$tag] = $tag; - } - } - } - - $taglist = array(); - foreach($tags AS $tag) - $taglist[] = $tag; - - $relay = array("subscribe" => $subscribe, - "scope" => $scope, - "tags" => $taglist); - - header('Content-type: application/json; charset=utf-8'); - echo json_encode($relay, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES); - exit; -} +argc > 1) { + switch($a->argv[1]) { + case "host-meta": + hostxrd_init($a); + break; + case "x-social-relay": + wk_social_relay($a); + break; + case "nodeinfo": + nodeinfo_wellknown($a); + break; + } + } + http_status_exit(404); + killme(); +} + +function wk_social_relay(App $a) { + + $subscribe = (bool)Config::get('system', 'relay_subscribe', false); + + if ($subscribe) { + $scope = Config::get('system', 'relay_scope', SR_SCOPE_ALL); + } else { + $scope = SR_SCOPE_NONE; + } + + $tags = array(); + + if ($scope == SR_SCOPE_TAGS) { + $server_tags = Config::get('system', 'relay_server_tags'); + $tagitems = explode(",", $server_tags); + + foreach($tagitems AS $tag) { + $tags[trim($tag, "# ")] = trim($tag, "# "); + } + + if (Config::get('system', 'relay_user_tags')) { + $terms = q("SELECT DISTINCT(`term`) FROM `search`"); + + foreach($terms AS $term) { + $tag = trim($term["term"], "#"); + $tags[$tag] = $tag; + } + } + } + + $taglist = array(); + foreach($tags AS $tag) { + $taglist[] = $tag; + } + + $relay = array("subscribe" => $subscribe, + "scope" => $scope, + "tags" => $taglist); + + header('Content-type: application/json; charset=utf-8'); + echo json_encode($relay, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES); + exit; +} diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php index 55afda9b63..5912f6cc77 100644 --- a/mod/viewcontacts.php +++ b/mod/viewcontacts.php @@ -48,7 +48,8 @@ function viewcontacts_content(App $a) { } $r = q("SELECT COUNT(*) AS `total` FROM `contact` - WHERE `uid` = %d AND (NOT `blocked` OR `pending`) AND NOT `hidden` AND NOT `archive` + WHERE `uid` = %d AND NOT `blocked` AND NOT `pending` + AND NOT `hidden` AND NOT `archive` AND `network` IN ('%s', '%s', '%s')", intval($a->profile['uid']), dbesc(NETWORK_DFRN), @@ -59,7 +60,8 @@ function viewcontacts_content(App $a) { $a->set_pager_total($r[0]['total']); $r = q("SELECT * FROM `contact` - WHERE `uid` = %d AND (NOT `blocked` OR `pending`) AND NOT `hidden` AND NOT `archive` + WHERE `uid` = %d AND NOT `blocked` AND NOT `pending` + AND NOT `hidden` AND NOT `archive` AND `network` IN ('%s', '%s', '%s') ORDER BY `name` ASC LIMIT %d, %d", intval($a->profile['uid']), diff --git a/view/lang/sv/messages.po b/view/lang/sv/messages.po index f3c7868444..16d4ba89f0 100644 --- a/view/lang/sv/messages.po +++ b/view/lang/sv/messages.po @@ -3,14 +3,15 @@ # This file is distributed under the same license as the Friendica package. # # Translators: +# Jonatan Nyberg , 2017 # Mike Macgirvin, 2010 msgid "" msgstr "" "Project-Id-Version: friendica\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-12-19 07:46+0100\n" -"PO-Revision-Date: 2016-12-19 10:01+0000\n" -"Last-Translator: fabrixxm \n" +"PO-Revision-Date: 2017-02-13 20:15+0000\n" +"Last-Translator: Jonatan Nyberg \n" "Language-Team: Swedish (http://www.transifex.com/Friendica/friendica/language/sv/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -20,7 +21,7 @@ msgstr "" #: include/contact_widgets.php:6 msgid "Add New Contact" -msgstr "" +msgstr "Lägg till kontakt" #: include/contact_widgets.php:7 msgid "Enter address or web location" diff --git a/view/lang/sv/strings.php b/view/lang/sv/strings.php index 6a789c0611..499ed92003 100644 --- a/view/lang/sv/strings.php +++ b/view/lang/sv/strings.php @@ -5,7 +5,7 @@ function string_plural_select_sv($n){ return ($n != 1);; }} ; -$a->strings["Add New Contact"] = ""; +$a->strings["Add New Contact"] = "Lägg till kontakt"; $a->strings["Enter address or web location"] = ""; $a->strings["Example: bob@example.com, http://example.com/barbara"] = "Exempel: adam@exempel.com, http://exempel.com/bertil"; $a->strings["Connect"] = "Skicka kontaktförfrågan"; diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 8102e7ac95..b51d6b39dd 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -256,40 +256,30 @@ $(document).ready(function(){ input.val(val); }); + // Set the padding for input elements with inline buttons + // + // In Frio we use some input elements where the submit button is visually + // inside the the input field (through css). We need to set a padding-right + // to the input element where the padding value would be at least the width + // of the button. Otherwise long user input would be invisible because it is + // behind the button. + $("body").on('click', '.form-group-search > input', function() { + // Get the width of the button (if the button isn't available + // buttonWidth will be null + var buttonWidth = $(this).next('.form-button-search').outerWidth(); + + if (buttonWidth) { + // Take the width of the button and ad 5px + var newWidth = buttonWidth + 5; + // Set the padding of the input element according + // to the width of the button + $(this).css('padding-right', newWidth); + } + + }); + + }); -//function commentOpenUI(obj, id) { -// $(document).unbind( "click.commentOpen", handler ); -// -// var handler = function() { -// if(obj.value == '{{$comment}}') { -// obj.value = ''; -// $("#comment-edit-text-" + id).addClass("comment-edit-text-full").removeClass("comment-edit-text-empty"); -// // Choose an arbitrary tab index that's greater than what we're using in jot (3 of them) -// // The submit button gets tabindex + 1 -// $("#comment-edit-text-" + id).attr('tabindex','9'); -// $("#comment-edit-submit-" + id).attr('tabindex','10'); -// $("#comment-edit-submit-wrapper-" + id).show(); -// } -// }; -// -// $(document).bind( "click.commentOpen", handler ); -//} -// -//function commentCloseUI(obj, id) { -// $(document).unbind( "click.commentClose", handler ); -// -// var handler = function() { -// if(obj.value === '') { -// obj.value = '{{$comment}}'; -// $("#comment-edit-text-" + id).removeClass("comment-edit-text-full").addClass("comment-edit-text-empty"); -// $("#comment-edit-text-" + id).removeAttr('tabindex'); -// $("#comment-edit-submit-" + id).removeAttr('tabindex'); -// $("#comment-edit-submit-wrapper-" + id).hide(); -// } -// }; -// -// $(document).bind( "click.commentClose", handler ); -//} function openClose(theID) { var elem = document.getElementById(theID); diff --git a/view/theme/quattro/dark/style.css b/view/theme/quattro/dark/style.css index 4a1f77881d..3e8fe754b8 100644 --- a/view/theme/quattro/dark/style.css +++ b/view/theme/quattro/dark/style.css @@ -1210,7 +1210,7 @@ section { .wall-item-container .wall-item-actions-social a { margin-right: 3em; } -.wall-item-container .wall-item-actions-social a .active { +.wall-item-container .wall-item-actions-social a.active { font-weight: bold; } .wall-item-container .wall-item-actions-tools { diff --git a/view/theme/quattro/green/style.css b/view/theme/quattro/green/style.css index 11fff105da..8eba0e4cf7 100644 --- a/view/theme/quattro/green/style.css +++ b/view/theme/quattro/green/style.css @@ -1210,7 +1210,7 @@ section { .wall-item-container .wall-item-actions-social a { margin-right: 3em; } -.wall-item-container .wall-item-actions-social a .active { +.wall-item-container .wall-item-actions-social a.active { font-weight: bold; } .wall-item-container .wall-item-actions-tools { diff --git a/view/theme/quattro/lilac/style.css b/view/theme/quattro/lilac/style.css index 81564a0d26..b424534206 100644 --- a/view/theme/quattro/lilac/style.css +++ b/view/theme/quattro/lilac/style.css @@ -1210,7 +1210,7 @@ section { .wall-item-container .wall-item-actions-social a { margin-right: 3em; } -.wall-item-container .wall-item-actions-social a .active { +.wall-item-container .wall-item-actions-social a.active { font-weight: bold; } .wall-item-container .wall-item-actions-tools { diff --git a/view/theme/quattro/quattro.less b/view/theme/quattro/quattro.less index 469c075c41..6c01986888 100644 --- a/view/theme/quattro/quattro.less +++ b/view/theme/quattro/quattro.less @@ -576,7 +576,7 @@ section { } .wall-item-actions-social { float: left; margin-top: 0.5em; a { margin-right: 3em; - .active { font-weight: bold;} + &.active { font-weight: bold;} } } .wall-item-actions-tools { float: right; width: 15%;