diff --git a/INSTALL.txt b/INSTALL.txt index 81dfdfd27..c42c08971 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -71,9 +71,14 @@ write or create files in your web directory, create an empty file called .htconfig.php and make it writable by the web server. 5. Visit your website with a web browser and follow the instructions. Please -note any error messages and correct these before continuing. If you are using -SSL with a known signature authority (recommended), use the https: link to your -website. If you are using a self-signed cert or no cert, use the http: link. +note any error messages and correct these before continuing. + +If you are using SSL with a known signature authority (recommended), use the +https: link to your website. If you are using a self-signed cert or no cert, +use the http: link. + +If you need to specify a port for the connection to the database, you can do +so in the host name setting for the database. 6. *If* the automated installation fails for any reason, check the following: diff --git a/boot.php b/boot.php index 2ad057d4c..fe1ee63e0 100644 --- a/boot.php +++ b/boot.php @@ -993,7 +993,7 @@ function notice($s) { function info($s) { $a = get_app(); - if (local_user() AND get_pconfig(local_user(), 'system', 'ignore_info')) { + if (local_user() && get_pconfig(local_user(), 'system', 'ignore_info')) { return; } @@ -1063,7 +1063,7 @@ function proc_run($cmd) { $arr = array('args' => $args, 'run_cmd' => true); call_hooks("proc_run", $arr); - if (!$arr['run_cmd'] OR ! count($args)) { + if (!$arr['run_cmd'] || ! count($args)) { return; } @@ -1411,7 +1411,7 @@ function clear_cache($basepath = "", $path = "") { $path = $basepath; } - if (($path == "") OR (!is_dir($path))) { + if (($path == "") || (!is_dir($path))) { return; } @@ -1428,10 +1428,10 @@ function clear_cache($basepath = "", $path = "") { if ($dh = opendir($path)) { while (($file = readdir($dh)) !== false) { $fullpath = $path . "/" . $file; - if ((filetype($fullpath) == "dir") and ($file != ".") and ($file != "..")) { + if ((filetype($fullpath) == "dir") && ($file != ".") && ($file != "..")) { clear_cache($basepath, $fullpath); } - if ((filetype($fullpath) == "file") and (filectime($fullpath) < (time() - $cachetime))) { + if ((filetype($fullpath) == "file") && (filectime($fullpath) < (time() - $cachetime))) { unlink($fullpath); } } @@ -1448,7 +1448,7 @@ function get_itemcachepath() { } $itemcache = get_config('system', 'itemcache'); - if (($itemcache != "") AND App::directory_usable($itemcache)) { + if (($itemcache != "") && App::directory_usable($itemcache)) { return $itemcache; } @@ -1475,7 +1475,7 @@ function get_itemcachepath() { */ function get_spoolpath() { $spoolpath = get_config('system', 'spoolpath'); - if (($spoolpath != "") AND App::directory_usable($spoolpath)) { + if (($spoolpath != "") && App::directory_usable($spoolpath)) { // We have a spool path and it is usable return $spoolpath; } @@ -1510,7 +1510,7 @@ function get_temppath() { $temppath = get_config("system", "temppath"); - if (($temppath != "") AND App::directory_usable($temppath)) { + if (($temppath != "") && App::directory_usable($temppath)) { // We have a temp path and it is usable return $temppath; } @@ -1519,7 +1519,7 @@ function get_temppath() { $temppath = sys_get_temp_dir(); // Check if it is usable - if (($temppath != "") AND App::directory_usable($temppath)) { + if (($temppath != "") && App::directory_usable($temppath)) { // To avoid any interferences with other systems we create our own directory $new_temppath = $temppath . "/" . $a->get_hostname(); if (!is_dir($new_temppath)) { @@ -1642,7 +1642,7 @@ function argv($x) { function infinite_scroll_data($module) { if (get_pconfig(local_user(), 'system', 'infinite_scroll') - AND ($module == "network") AND ($_GET["mode"] != "minimal")) { + && ($module == "network") && ($_GET["mode"] != "minimal")) { // get the page number if (is_string($_GET["page"])) { @@ -1655,12 +1655,12 @@ function infinite_scroll_data($module) { // try to get the uri from which we load the content foreach ($_GET AS $param => $value) { - if (($param != "page") AND ($param != "q")) { + if (($param != "page") && ($param != "q")) { $reload_uri .= "&" . $param . "=" . urlencode($value); } } - if (($a->page_offset != "") AND ! strstr($reload_uri, "&offset=")) { + if (($a->page_offset != "") && ! strstr($reload_uri, "&offset=")) { $reload_uri .= "&offset=" . urlencode($a->page_offset); } diff --git a/doc/Developers-Intro.md b/doc/Developers-Intro.md index 3cda8ab46..137e5aaf5 100644 --- a/doc/Developers-Intro.md +++ b/doc/Developers-Intro.md @@ -64,6 +64,7 @@ Here's a few primers if you are new to Friendica or to the PSR-2 coding standard * By default, strings are enclosed in single quotes, but feel free to use double quotes if it makes more sense (SQL queries, adding tabs and line feeds). * Operators are wrapped by spaces, e.g. `$var === true`, `$var = 1 + 2` and `'string' . $concat . 'enation'` * Braces are mandatory in conditions + * Boolean operators are `&&` and `||` for PHP conditions, `AND` and `OR` for SQL queries * No closing PHP tag * No trailing spaces diff --git a/doc/Install.md b/doc/Install.md index a8ea2c050..53df55be0 100644 --- a/doc/Install.md +++ b/doc/Install.md @@ -82,6 +82,8 @@ Restart mysql and you should be fine. Point your web browser to the new site and follow the instructions. Please note any error messages and correct these before continuing. +If you need to specify a port for the connection to the database, you can do so in the host name setting for the database. + *If* the automated installation fails for any reason, check the following: * Does ".htconfig.php" exist? If not, edit htconfig.php and change the system settings. Rename to .htconfig.php diff --git a/doc/htconfig.md b/doc/htconfig.md index 5fbd6e0cb..ec961c200 100644 --- a/doc/htconfig.md +++ b/doc/htconfig.md @@ -118,3 +118,10 @@ If more then one account should be able to access the admin panel, seperate the If you want to have a more personalized closing line for the notification emails you can set a variable for the admin_name. $a->config['admin_name'] = "Marvin"; + +## Database Settings + +The configuration variables db_host, db_user, db_pass and db_data are holding your credentials for the database connection. +If you need to specify a port to access the database, you can do so by appending ":portnumber" to the db_host variable. + + $db_host = 'your.mysqlhost.com:123456'; diff --git a/include/Contact.php b/include/Contact.php index bb6d8c198..0aeabc972 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -262,33 +262,33 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) { $profile = $default; } - if (($profile["photo"] == "") AND isset($default["photo"])) { + if (($profile["photo"] == "") && isset($default["photo"])) { $profile["photo"] = $default["photo"]; } - if (($profile["name"] == "") AND isset($default["name"])) { + if (($profile["name"] == "") && isset($default["name"])) { $profile["name"] = $default["name"]; } - if (($profile["network"] == "") AND isset($default["network"])) { + if (($profile["network"] == "") && isset($default["network"])) { $profile["network"] = $default["network"]; } - if (($profile["thumb"] == "") AND isset($profile["photo"])) { + if (($profile["thumb"] == "") && isset($profile["photo"])) { $profile["thumb"] = $profile["photo"]; } - if (($profile["micro"] == "") AND isset($profile["thumb"])) { + if (($profile["micro"] == "") && isset($profile["thumb"])) { $profile["micro"] = $profile["thumb"]; } - if ((($profile["addr"] == "") OR ($profile["name"] == "")) AND ($profile["gid"] != 0) AND + if ((($profile["addr"] == "") || ($profile["name"] == "")) && ($profile["gid"] != 0) && in_array($profile["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) { proc_run(PRIORITY_LOW, "include/update_gcontact.php", $profile["gid"]); } // Show contact details of Diaspora contacts only if connected - if (($profile["cid"] == 0) AND ($profile["network"] == NETWORK_DIASPORA)) { + if (($profile["cid"] == 0) && ($profile["network"] == NETWORK_DIASPORA)) { $profile["location"] = ""; $profile["about"] = ""; $profile["gender"] = ""; @@ -559,7 +559,7 @@ function get_contact($url, $uid = 0, $no_update = false) { // Update the contact every 7 days $update_photo = ($contacts[0]['avatar-date'] < datetime_convert('','','now -7 days')); - if (!$update_photo OR $no_update) { + if (!$update_photo || $no_update) { return $contact_id; } } elseif ($uid != 0) { @@ -636,7 +636,7 @@ function get_contact($url, $uid = 0, $no_update = false) { } } - if (count($contacts) > 1 AND $uid == 0 AND $contact_id != 0 AND $url != "") { + if (count($contacts) > 1 && $uid == 0 && $contact_id != 0 && $url != "") { q("DELETE FROM `contact` WHERE `nurl` = '%s' AND `id` != %d AND NOT `self`", dbesc(normalise_link($url)), intval($contact_id)); @@ -654,9 +654,9 @@ function get_contact($url, $uid = 0, $no_update = false) { } // Only update if there had something been changed - if ($data["addr"] != $contacts[0]["addr"] OR - $data["alias"] != $contacts[0]["alias"] OR - $data["name"] != $contacts[0]["name"] OR + if ($data["addr"] != $contacts[0]["addr"] || + $data["alias"] != $contacts[0]["alias"] || + $data["name"] != $contacts[0]["name"] || $data["nick"] != $contacts[0]["nick"]) { q("UPDATE `contact` SET `addr` = '%s', `alias` = '%s', `name` = '%s', `nick` = '%s', `name-date` = '%s', `uri-date` = '%s' WHERE `id` = %d", @@ -769,7 +769,7 @@ function formatted_location($profile) { if($profile['locality']) $location .= $profile['locality']; - if($profile['region'] AND ($profile['locality'] != $profile['region'])) { + if($profile['region'] && ($profile['locality'] != $profile['region'])) { if($location) $location .= ', '; diff --git a/include/NotificationsManager.php b/include/NotificationsManager.php index ad0ede6db..57c315c9d 100644 --- a/include/NotificationsManager.php +++ b/include/NotificationsManager.php @@ -512,7 +512,7 @@ class NotificationsManager { $myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); $diasp_url = str_replace('/profile/','/u/',$myurl); - $sql_extra = sprintf(" AND ( `item`.`author-link` regexp '%s' or `item`.`tag` regexp '%s' or `item`.`tag` regexp '%s' ) ", + $sql_extra = sprintf(" AND ( `item`.`author-link` regexp '%s' OR `item`.`tag` regexp '%s' OR `item`.`tag` regexp '%s' ) ", dbesc($myurl . '$'), dbesc($myurl . '\\]'), dbesc($diasp_url . '\\]') @@ -829,11 +829,11 @@ class NotificationsManager { } /** - * @brief Check for missing contact data and try to fetch the data from + * @brief Check for missing contact data and try to fetch the data from * from other sources - * + * * @param array $arr The input array with the intro data - * + * * @return array The array with the intro data */ private function getMissingIntroData($arr) { diff --git a/include/Photo.php b/include/Photo.php index 5920f80b3..5c3a52ffd 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -785,7 +785,7 @@ function update_contact_avatar($avatar, $uid, $cid, $force = false) { $data = array($r[0]["photo"], $r[0]["thumb"], $r[0]["micro"]); } - if (($r[0]["avatar"] != $avatar) OR $force) { + if (($r[0]["avatar"] != $avatar) || $force) { $photos = import_profile_photo($avatar, $uid, $cid, true); if ($photos) { @@ -825,7 +825,7 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) { $filename = basename($photo); $img_str = fetch_url($photo, true); - if ($quit_on_error AND ($img_str == "")) { + if ($quit_on_error && ($img_str == "")) { return false; } @@ -883,7 +883,7 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) { $photo_failure = true; } - if ($photo_failure AND $quit_on_error) { + if ($photo_failure && $quit_on_error) { return false; } @@ -902,7 +902,7 @@ function get_photo_info($url) { $data = Cache::get($url); - if (is_null($data) OR !$data OR !is_array($data)) { + if (is_null($data) || !$data || !is_array($data)) { $img_str = fetch_url($url, true, $redirects, 4); $filesize = strlen($img_str); @@ -996,7 +996,7 @@ function store_photo(App $a, $uid, $imagedata = "", $url = "") { /// $default_cid = $r[0]['id']; /// $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false); - if ((strlen($imagedata) == 0) AND ($url == "")) { + if ((strlen($imagedata) == 0) && ($url == "")) { logger("No image data and no url provided", LOGGER_DEBUG); return(array()); } elseif (strlen($imagedata) == 0) { @@ -1102,7 +1102,7 @@ function store_photo(App $a, $uid, $imagedata = "", $url = "") { } } - if ($width > 160 AND $height > 160) { + if ($width > 160 && $height > 160) { $x = 0; $y = 0; diff --git a/include/acl_selectors.php b/include/acl_selectors.php index c7c6bb206..6f08523ca 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -209,7 +209,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $tabindex = ($tabindex > 0 ? "tabindex=\"$tabindex\"" : ""); - if ($privmail AND $preselected) { + if ($privmail && $preselected) { $sql_extra .= " AND `id` IN (".implode(",", $preselected).")"; $hidepreselected = ' style="display: none;"'; } else { @@ -261,7 +261,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $o .= "\r\n"; - if ($privmail AND $preselected) { + if ($privmail && $preselected) { $o .= implode(", ", $receiverlist); } @@ -388,6 +388,9 @@ function populate_acl($user = null, $show_jotnets = false) { } function construct_acl_data(App $a, $user) { + // This function is now deactivated. It seems as if the generated data isn't used anywhere. + /// @todo Remove this function and all function calls before releasing Friendica 3.5.3 + return; // Get group and contact information for html ACL selector $acl_data = acl_lookup($a, 'html'); diff --git a/include/api.php b/include/api.php index 5d962ecd0..16ff0f4a0 100644 --- a/include/api.php +++ b/include/api.php @@ -483,7 +483,7 @@ $called_api = null; logger("api_get_user: Fetching user data for user ".$contact_id, LOGGER_DEBUG); // Searching for contact URL - if (!is_null($contact_id) AND (intval($contact_id) == 0)) { + if (!is_null($contact_id) && (intval($contact_id) == 0)) { $user = dbesc(normalise_link($contact_id)); $url = $user; $extra_query = "AND `contact`.`nurl` = '%s' "; @@ -493,7 +493,7 @@ $called_api = null; } // Searching for contact id with uid = 0 - if (!is_null($contact_id) AND (intval($contact_id) != 0)) { + if (!is_null($contact_id) && (intval($contact_id) != 0)) { $user = dbesc(api_unique_id_to_url($contact_id)); if ($user == "") { @@ -538,7 +538,7 @@ $called_api = null; } } - if (is_null($user) AND ($a->argc > (count($called_api) - 1)) AND (count($called_api) > 0)) { + if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) { $argid = count($called_api); list($user, $null) = explode(".", $a->argv[$argid]); if (is_numeric($user)) { @@ -600,7 +600,7 @@ $called_api = null; $network_name = network_to_name($r[0]['network'], $r[0]['url']); // If no nick where given, extract it from the address - if (($r[0]['nick'] == "") OR ($r[0]['name'] == $r[0]['nick'])) { + if (($r[0]['nick'] == "") || ($r[0]['name'] == $r[0]['nick'])) { $r[0]['nick'] = api_get_nick($r[0]["url"]); } @@ -716,7 +716,7 @@ $called_api = null; $starred = 0; // Add a nick if it isn't present there - if (($uinfo[0]['nick'] == "") OR ($uinfo[0]['name'] == $uinfo[0]['nick'])) { + if (($uinfo[0]['nick'] == "") || ($uinfo[0]['name'] == $uinfo[0]['nick'])) { $uinfo[0]['nick'] = api_get_nick($uinfo[0]["url"]); } @@ -749,7 +749,7 @@ $called_api = null; 'contributors_enabled' => false, 'is_translator' => false, 'is_translation_enabled' => false, - 'following' => (($uinfo[0]['rel'] == CONTACT_IS_FOLLOWER) OR ($uinfo[0]['rel'] == CONTACT_IS_FRIEND)), + 'following' => (($uinfo[0]['rel'] == CONTACT_IS_FOLLOWER) || ($uinfo[0]['rel'] == CONTACT_IS_FRIEND)), 'follow_request_sent' => false, 'statusnet_blocking' => false, 'notifications' => false, @@ -777,10 +777,10 @@ $called_api = null; $status_user = api_get_user($a, $item["author-link"]); - $status_user["protected"] = (($item["allow_cid"] != "") OR - ($item["allow_gid"] != "") OR - ($item["deny_cid"] != "") OR - ($item["deny_gid"] != "") OR + $status_user["protected"] = (($item["allow_cid"] != "") || + ($item["allow_gid"] != "") || + ($item["deny_cid"] != "") || + ($item["deny_gid"] != "") || $item["private"]); if ($item['thr-parent'] == $item['uri']) { @@ -1305,9 +1305,9 @@ $called_api = null; $status_info["entities"] = $converted["entities"]; } - if (($lastwall['item_network'] != "") AND ($status["source"] == 'web')) { + if (($lastwall['item_network'] != "") && ($status["source"] == 'web')) { $status_info["source"] = network_to_name($lastwall['item_network'], $user_info['url']); - } elseif (($lastwall['item_network'] != "") AND (network_to_name($lastwall['item_network'], $user_info['url']) != $status_info["source"])) { + } elseif (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $status_info["source"])) { $status_info["source"] = trim($status_info["source"].' ('.network_to_name($lastwall['item_network'], $user_info['url']).')'); } @@ -1393,11 +1393,11 @@ $called_api = null; $user_info["status"]["entities"] = $converted["entities"]; } - if (($lastwall['item_network'] != "") AND ($user_info["status"]["source"] == 'web')) { + if (($lastwall['item_network'] != "") && ($user_info["status"]["source"] == 'web')) { $user_info["status"]["source"] = network_to_name($lastwall['item_network'], $user_info['url']); } - if (($lastwall['item_network'] != "") AND (network_to_name($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) { + if (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) { $user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . network_to_name($lastwall['item_network'], $user_info['url']) . ')'); } @@ -2178,7 +2178,7 @@ $called_api = null; `contact`.`id` AS `cid` FROM `item`, `contact` WHERE `item`.`uid` = %d - AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0 + AND `item`.`visible` = 1 AND `item`.`moderated` = 0 AND `item`.`deleted` = 0 AND `item`.`starred` = 1 AND `contact`.`id` = `item`.`contact-id` AND (NOT `contact`.`blocked` OR `contact`.`pending`) @@ -2263,13 +2263,13 @@ $called_api = null; $statustitle = trim($item['title']); - if (($statustitle != '') and (strpos($statusbody, $statustitle) !== false)) { + if (($statustitle != '') && (strpos($statusbody, $statustitle) !== false)) { $statustext = trim($statusbody); } else { $statustext = trim($statustitle."\n\n".$statusbody); } - if (($item["network"] == NETWORK_FEED) and (strlen($statustext)> 1000)) { + if (($item["network"] == NETWORK_FEED) && (strlen($statustext)> 1000)) { $statustext = substr($statustext, 0, 1000)."... \n".$item["plink"]; } @@ -2289,11 +2289,11 @@ $called_api = null; $statushtml = "