]> git.mxchange.org Git - friendica.git/commitdiff
Merge remote-tracking branch 'upstream/develop' into develop
authorRalf Thees <ralf@herrthees.de>
Thu, 23 Aug 2018 14:58:18 +0000 (16:58 +0200)
committerRalf Thees <ralf@herrthees.de>
Thu, 23 Aug 2018 14:58:18 +0000 (16:58 +0200)
41 files changed:
doc/api.md
include/api.php
include/conversation.php
include/dba.php
include/enotify.php
include/items.php
mod/community.php
mod/dfrn_notify.php
mod/dfrn_poll.php
mod/display.php
mod/follow.php
mod/install.php
mod/notes.php
mod/photos.php
mod/profile.php
mod/redir.php
src/App.php
src/Core/Console/AutomaticInstallation.php
src/Core/Install.php
src/Core/NotificationsManager.php
src/Core/System.php
src/Database/DBA.php
src/Model/Contact.php
src/Model/Group.php
src/Network/Probe.php
src/Protocol/Diaspora.php
src/Util/Network.php
src/Worker/DBClean.php
src/Worker/DiscoverPoCo.php
view/js/ajaxupload.js
view/templates/profile_edit.tpl
view/theme/frio/config.php
view/theme/frio/css/style.css
view/theme/frio/js/modal.js
view/theme/frio/php/default.php
view/theme/frio/templates/like_noshare.tpl
view/theme/frio/templates/photo_view.tpl
view/theme/frio/templates/photos_default_uploader_box.tpl [new file with mode: 0644]
view/theme/frio/templates/photos_default_uploader_submit.tpl [new file with mode: 0644]
view/theme/frio/templates/photos_upload.tpl
view/theme/vier/templates/profile_edit.tpl

index 08fca74fa443e1bff940f2b745dc19a109e9ad9c..07813b6a7715c243f91f06cd4dc19e974e88552d 100644 (file)
@@ -634,6 +634,73 @@ Friendica doesn't allow showing the friends of other users.
 * trim_user
 * contributor_details
 
+---
+
+### Return values for statuses/* api calls
+
+Returned status object is conform to GNU Social/Twitter api.
+
+Friendica adds some addictional fields:
+
+- owner: a user object, it's the owner of the item.
+- private: boolean, true if the item is marked as private
+- activities: map with activities related to the item. Every activity is a list of user objects.
+
+This properties are prefixed with "friendica_" in JSON responses and namespaced under "http://friendi.ca/schema/api/1/" in XML responses
+
+JSON:
+
+```json
+[
+       {
+               // ...
+               'friendica_owner' : {
+                       // user object
+               },
+               'friendica_private' : true,
+               'friendica_activities': {
+                       'like': [
+                               {
+                                       // user object 
+                               },
+                               // ...
+                       ],
+                       'dislike': [],
+                       'attendyes': [],
+                       'attendno': [],
+                       'attendmaybe': []
+               }
+       },
+       // ...
+]
+```
+
+XML:
+
+```xml
+<statuses xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" xmlns:friendica="http://friendi.ca/schema/api/1/" xmlns:georss="http://www.georss.org/georss">
+  <status>
+       <!-- ... -->
+       <friendica:owner><!-- user object --></friendica:owner>
+       <friendica:private>true</friendica:private>
+       <friendica:activities>
+               <friendica:like>
+               <user>
+                       <!-- user object -->
+               </user>
+               <!-- ... --->
+               </friendica:like>
+               <friendica:dislike/>
+               <friendica:attendyes/>
+               <friendica:attendno/>
+               <friendica:attendmaybe/>
+       </friendica:activities> 
+       </status>
+       <!-- ... -->
+</statuses>
+```
+
+
 ---
 
 ### statusnet/config (*)
index 7450d650eb4f90ed7b31d0aaa4dba261e400815d..f40674b8941968a3e351dcc43981f98deed32b95 100644 (file)
@@ -2888,6 +2888,7 @@ function api_format_items($r, $user_info, $filter_user = false, $type = "json")
                        'favorited' => $item['starred'] ? true : false,
                        'user' =>  $status_user ,
                        'friendica_owner' => $owner_user,
+                       'friendica_private' => $item['private'] == 1,
                        //'entities' => NULL,
                        'statusnet_html' => $converted["html"],
                        'statusnet_conversation_id' => $item['parent'],
index 665d9d48316484d2e03cae9ef37405bb2797b0bf..5a26700fd7e1c8378eaa85523b0eff5df2c5937a 100644 (file)
@@ -471,6 +471,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                                . "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
                }
        } elseif ($mode === 'profile') {
+               $items = conversation_add_children($items, false, $order, $uid);
                $profile_owner = $a->profile['profile_uid'];
 
                if (!$update) {
@@ -490,6 +491,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                        }
                }
        } elseif ($mode === 'notes') {
+               $items = conversation_add_children($items, false, $order, $uid);
                $profile_owner = local_user();
 
                if (!$update) {
@@ -498,6 +500,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                                . "; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
                }
        } elseif ($mode === 'display') {
+               $items = conversation_add_children($items, false, $order, $uid);
                $profile_owner = $a->profile['uid'];
 
                if (!$update) {
index 6480b28ed2feaeaac517d0f6e0debdf291d4ae70..9e168eac799c36e6a53eefdd8ab68e9e99313405 100644 (file)
@@ -5,9 +5,9 @@ use Friendica\Database\DBA;
 /**
  * @brief execute SQL query with printf style args - deprecated
  *
- * Please use the dba:: functions instead:
- * dba::select, dba::exists, dba::insert
- * dba::delete, dba::update, dba::p, dba::e
+ * Please use the DBA:: functions instead:
+ * DBA::select, DBA::exists, DBA::insert
+ * DBA::delete, DBA::update, DBA::p, DBA::e
  *
  * @param $args Query parameters (1 to N parameters of different types)
  * @return array|bool Query array
index 0ef3c56765e413610a0d1542cb4bcf2c48502e60..70abce584547ea3986a25b2d6f89029dc0c99408 100644 (file)
@@ -32,6 +32,20 @@ function notification($params)
                logger('Missing parameters.' . System::callstack());
        }
 
+       // Ensure that the important fields are set at any time
+       $fields = ['notify-flags', 'language', 'username', 'email'];
+       $user = DBA::selectFirst('user', $fields, ['uid' => $params['uid']]);
+
+       if (!DBA::isResult($user)) {
+               logger('Unknown user ' . $params['uid']);
+               return;
+       }
+
+       $params['notify_flags'] = defaults($params, 'notify_flags', $user['notify-flags']);
+       $params['language'] = defaults($params, 'language', $user['language']);
+       $params['to_name'] = defaults($params, 'to_name', $user['username']);
+       $params['to_email'] = defaults($params, 'to_email', $user['email']);
+
        // from here on everything is in the recipients language
        L10n::pushLang($params['language']);
 
@@ -510,7 +524,7 @@ function notification($params)
        }
 
        // send email notification if notification preferences permit
-       if ((!empty($params['notify_flags']) & intval($params['type']))
+       if ((intval($params['notify_flags']) & intval($params['type']))
                || $params['type'] == NOTIFY_SYSTEM
                || $params['type'] == SYSTEM_EMAIL) {
 
@@ -661,7 +675,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
 
        $profiles = $notification_data["profiles"];
 
-       $fields = ['notify-flags', 'language', 'username', 'email', 'nickname'];
+       $fields = ['nickname'];
        $user = DBA::selectFirst('user', $fields, ['uid' => $uid]);
        if (!DBA::isResult($user)) {
                return false;
@@ -724,10 +738,6 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
        // Generate the notification array
        $params = [];
        $params["uid"] = $uid;
-       $params["notify_flags"] = $user["notify-flags"];
-       $params["language"] = $user["language"];
-       $params["to_name"] = $user["username"];
-       $params["to_email"] = $user["email"];
        $params["item"] = $item;
        $params["parent"] = $item["parent"];
        $params["link"] = System::baseUrl().'/display/'.urlencode($item["guid"]);
index 9922c447f009daf7002c20d23dcadbd6e7d505ba..08858682e60cefc5844370e0d408f987782a504b 100644 (file)
@@ -371,7 +371,7 @@ function drop_item($id)
 
        if ((local_user() == $item['uid']) || $contact_id) {
                // Check if we should do HTML-based delete confirmation
-               if ($_REQUEST['confirm']) {
+               if (!empty($_REQUEST['confirm'])) {
                        // <form> can't take arguments in its "action" parameter
                        // so add any arguments as hidden inputs
                        $query = explode_querystring($a->query_string);
@@ -395,7 +395,7 @@ function drop_item($id)
                        ]);
                }
                // Now check how the user responded to the confirmation query
-               if ($_REQUEST['canceled']) {
+               if (!empty($_REQUEST['canceled'])) {
                        goaway(System::baseUrl() . '/' . $_SESSION['return_url']);
                }
 
index cb4f69c9173c8e87158d1a8cb0adaa0a9380acc3..9c9fb4390038fed56110a1465f73e176f31c5c0f 100644 (file)
@@ -10,6 +10,7 @@ use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
 use Friendica\Database\DBA;
+use Friendica\Model\Contact;
 
 function community_init(App $a)
 {
@@ -35,6 +36,25 @@ function community_content(App $a, $update = 0)
                return;
        }
 
+       $accounttype = null;
+
+       if ($a->argc > 2) {
+               switch ($a->argv[2]) {
+                       case 'person':
+                               $accounttype = Contact::ACCOUNT_TYPE_PERSON;
+                               break;
+                       case 'organisation':
+                               $accounttype = Contact::ACCOUNT_TYPE_ORGANISATION;
+                               break;
+                       case 'news':
+                               $accounttype = Contact::ACCOUNT_TYPE_NEWS;
+                               break;
+                       case 'community':
+                               $accounttype = Contact::ACCOUNT_TYPE_COMMUNITY;
+                               break;
+               }
+       }
+
        if ($a->argc > 1) {
                $content = $a->argv[1];
        } else {
@@ -135,7 +155,7 @@ function community_content(App $a, $update = 0)
 
        $a->set_pager_itemspage($itemspage_network);
 
-       $r = community_getitems($a->pager['start'], $a->pager['itemspage'], $content);
+       $r = community_getitems($a->pager['start'], $a->pager['itemspage'], $content, $accounttype);
 
        if (!DBA::isResult($r)) {
                info(L10n::t('No results.') . EOL);
@@ -164,7 +184,7 @@ function community_content(App $a, $update = 0)
                                }
                        }
                        if (count($s) < $a->pager['itemspage']) {
-                               $r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage'], $content);
+                               $r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage'], $content, $accounttype);
                        }
                } while ((count($s) < $a->pager['itemspage']) && ( ++$count < 50) && (count($r) > 0));
        } else {
@@ -186,24 +206,40 @@ function community_content(App $a, $update = 0)
        ]);
 }
 
-function community_getitems($start, $itemspage, $content)
+function community_getitems($start, $itemspage, $content, $accounttype)
 {
        if ($content == 'local') {
+               if (!is_null($accounttype)) {
+                       $sql_accounttype = " AND `user`.`account-type` = ?";
+                       $values = [$accounttype, $start, $itemspage];
+               } else {
+                       $sql_accounttype = "";
+                       $values = [$start, $itemspage];
+               }
+
                $r = DBA::p("SELECT `item`.`uri`, `author`.`url` AS `author-link` FROM `thread`
                        INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
                        INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
                        INNER JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id`
                        WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
-                       AND NOT `thread`.`private` AND `thread`.`wall` AND `thread`.`origin`
-                       ORDER BY `thread`.`commented` DESC LIMIT " . intval($start) . ", " . intval($itemspage)
-               );
+                       AND NOT `thread`.`private` AND `thread`.`wall` AND `thread`.`origin` $sql_accounttype
+                       ORDER BY `thread`.`commented` DESC LIMIT ?, ?", $values);
                return DBA::toArray($r);
        } elseif ($content == 'global') {
+               if (!is_null($accounttype)) {
+                       $sql_accounttype = " AND `owner`.`contact-type` = ?";
+                       $values = [$accounttype, $start, $itemspage];
+               } else {
+                       $sql_accounttype = "";
+                       $values = [$start, $itemspage];
+               }
+
                $r = DBA::p("SELECT `uri` FROM `thread`
                                INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
                                INNER JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id`
-                               WHERE `thread`.`uid` = 0 AND NOT `author`.`hidden` AND NOT `author`.`blocked`
-                               ORDER BY `thread`.`commented` DESC LIMIT " . intval($start) . ", " . intval($itemspage));
+                               INNER JOIN `contact` AS `owner` ON `owner`.`id`=`item`.`owner-id`
+                               WHERE `thread`.`uid` = 0 AND NOT `author`.`hidden` AND NOT `author`.`blocked` $sql_accounttype
+                               ORDER BY `thread`.`commented` DESC LIMIT ?, ?", $values);
                return DBA::toArray($r);
        }
 
index f107e12984ae40f1c695bf43822345363d4e19ec..88f706385baa3d6f7878b816a42b4bf60d71eb3e 100644 (file)
@@ -71,7 +71,7 @@ function dfrn_notify_post(App $a) {
 
        $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
        if (!DBA::isResult($user)) {
-               logger('User not found for nickname ' . $$a->argv[1]);
+               logger('User not found for nickname ' . $a->argv[1]);
                System::xmlExit(3, 'User not found');
        }
 
@@ -280,7 +280,7 @@ function dfrn_notify_content(App $a) {
 
                $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
                if (!DBA::isResult($user)) {
-                       logger('User not found for nickname ' . $$a->argv[1]);
+                       logger('User not found for nickname ' . $a->argv[1]);
                        killme();
                }
 
index 5e5540be140a65db3a28e51e25362347f9563370..54539ee03d7bd4cc580bb7845b9fa34b59734488 100644 (file)
@@ -480,6 +480,12 @@ function dfrn_poll_content(App $a)
                }
 
                if (($type === 'profile') && (strlen($sec))) {
+                       // heluecht: I don't know why we don't fail immediately when the user or contact hadn't been found.
+                       // Since it doesn't make sense to continue from this point on, we now fail here. This should be safe.
+                       if (!DBA::isResult($r)) {
+                               System::httpExit(404, ["title" => L10n::t('Page not found.')]);
+                       }
+
                        // URL reply
                        if ($dfrn_version < 2.2) {
                                $s = Network::fetchUrl($r[0]['poll']
index 2d32eed5eb504018f39cab567e920227fca5240f..907bf8ebba50d16b54ff34e341fe56c9e3da9408 100644 (file)
@@ -333,35 +333,34 @@ function display_content(App $a, $update = false, $update_uid = 0)
                return '';
        }
 
-       $condition = ["`item`.`parent-uri` = (SELECT `parent-uri` FROM `item` WHERE `id` = ?)
-               AND `item`.`uid` IN (0, ?) " . $sql_extra, $item_id, local_user()];
-       $params = ['order' => ['uid', 'parent' => true, 'gravity', 'id']];
-       $items_obj = Item::selectForUser(local_user(), [], $condition, $params);
+       $condition = ["`id` = ? AND `item`.`uid` IN (0, ?) " . $sql_extra, $item_id, local_user()];
+       $fields = ['parent-uri', 'body', 'title', 'author-name', 'author-avatar', 'plink'];
+       $item = Item::selectFirstForUser(local_user(), $fields, $condition);
 
-       if (!DBA::isResult($items_obj)) {
+       if (!DBA::isResult($item)) {
                notice(L10n::t('Item not found.') . EOL);
                return $o;
        }
 
+       $item['uri'] = $item['parent-uri'];
+
        if ($unseen) {
                $condition = ['parent-uri' => $item_parent_uri, 'uid' => local_user(), 'unseen' => true];
                Item::update(['unseen' => false], $condition);
        }
 
-       $items = Item::inArray($items_obj);
-       $conversation_items = conv_sort($items, "`commented`");
-
        if (!$update) {
                $o .= "<script> var netargs = '?f=&item_id=" . $item_id . "'; </script>";
        }
-       $o .= conversation($a, $conversation_items, 'display', $update_uid, false, 'commented', local_user());
+
+       $o .= conversation($a, [$item], 'display', $update_uid, false, 'commented', local_user());
 
        // Preparing the meta header
-       $description = trim(HTML::toPlaintext(BBCode::convert($items[0]["body"], false), 0, true));
-       $title = trim(HTML::toPlaintext(BBCode::convert($items[0]["title"], false), 0, true));
-       $author_name = $items[0]["author-name"];
+       $description = trim(HTML::toPlaintext(BBCode::convert($item["body"], false), 0, true));
+       $title = trim(HTML::toPlaintext(BBCode::convert($item["title"], false), 0, true));
+       $author_name = $item["author-name"];
 
-       $image = $a->remove_baseurl($items[0]["author-avatar"]);
+       $image = $a->remove_baseurl($item["author-avatar"]);
 
        if ($title == "") {
                $title = $author_name;
@@ -393,7 +392,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
        $a->page['htmlhead'] .= '<meta name="twitter:title" content="'.$title.'" />'."\n";
        $a->page['htmlhead'] .= '<meta name="twitter:description" content="'.$description.'" />'."\n";
        $a->page['htmlhead'] .= '<meta name="twitter:image" content="'.System::baseUrl().'/'.$image.'" />'."\n";
-       $a->page['htmlhead'] .= '<meta name="twitter:url" content="'.$items[0]["plink"].'" />'."\n";
+       $a->page['htmlhead'] .= '<meta name="twitter:url" content="'.$item["plink"].'" />'."\n";
 
        // Dublin Core
        $a->page['htmlhead'] .= '<meta name="DC.title" content="'.$title.'" />'."\n";
@@ -403,7 +402,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
        $a->page['htmlhead'] .= '<meta property="og:type" content="website" />'."\n";
        $a->page['htmlhead'] .= '<meta property="og:title" content="'.$title.'" />'."\n";
        $a->page['htmlhead'] .= '<meta property="og:image" content="'.System::baseUrl().'/'.$image.'" />'."\n";
-       $a->page['htmlhead'] .= '<meta property="og:url" content="'.$items[0]["plink"].'" />'."\n";
+       $a->page['htmlhead'] .= '<meta property="og:url" content="'.$item["plink"].'" />'."\n";
        $a->page['htmlhead'] .= '<meta property="og:description" content="'.$description.'" />'."\n";
        $a->page['htmlhead'] .= '<meta name="og:article:author" content="'.$author_name.'" />'."\n";
        // article:tag
index ef2325ad03d3d7ae0a599297ca525373f08057a1..627ab52033049065a9d737fdf8c725068215c121 100644 (file)
@@ -16,9 +16,7 @@ use Friendica\Util\Proxy as ProxyUtils;
 function follow_post(App $a)
 {
        if (!local_user()) {
-               notice(L10n::t('Permission denied.'));
-               goaway($_SESSION['return_url']);
-               // NOTREACHED
+               System::httpExit(403, ['title' => L10n::t('Access denied.')]);
        }
 
        if (isset($_REQUEST['cancel'])) {
index 11031acf460b1f0a82ffa00856628c73ca23fb8d..fa20fd76cbeda3cb25f731c000f5efdecfaffe53 100644 (file)
@@ -72,7 +72,20 @@ function install_post(App $a) {
                        // connect to db
                        DBA::connect($dbhost, $dbuser, $dbpass, $dbdata);
 
-                       Install::install($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail);
+                       $errors = Install::createConfig($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail);
+
+                       if ($errors) {
+                               $a->data['db_failed'] = $errors;
+                               return;
+                       }
+
+                       $errors = Install::installDatabaseStructure();
+
+                       if ($errors) {
+                               $a->data['db_failed'] = $errors;
+                       } else {
+                               $a->data['db_installed'] = true;
+                       }
 
                        return;
                break;
index 608d01cf8c63fbf1ed718788ab0eba5f5ffd3db6..68a870e9d689f282aa4c1a93444bb1d1a3fa68c4 100644 (file)
@@ -65,26 +65,13 @@ function notes_content(App $a, $update = false)
 
        $params = ['order' => ['created' => true],
                'limit' => [$a->pager['start'], $a->pager['itemspage']]];
-       $r = Item::selectForUser(local_user(), ['id'], $condition, $params);
+       $r = Item::selectThreadForUser(local_user(), ['uri'], $condition, $params);
 
        $count = 0;
 
        if (DBA::isResult($r)) {
                $count = count($r);
-               $parents_arr = [];
-
-               while ($rr = Item::fetch($r)) {
-                       $parents_arr[] = $rr['id'];
-               }
-               DBA::close($r);
-
-               $condition = ['uid' => local_user(), 'parent' => $parents_arr];
-               $result = Item::selectForUser(local_user(), [], $condition);
-
-               if (DBA::isResult($result)) {
-                       $items = conv_sort(Item::inArray($result), 'commented');
-                       $o .= conversation($a, $items, 'notes', $update);
-               }
+               $o .= conversation($a, DBA::toArray($r), 'notes', $update);
        }
 
        $o .= alt_pager($a, $count);
index e2682498be68496734abd80f872e5b9c99f7aec6..e246c98c3d84ccf2712c5acd621a476c908fb34b 100644 (file)
@@ -1093,6 +1093,12 @@ function photos_content(App $a)
                        '$albumselect' => $albumselect,
                        '$permissions' => L10n::t('Permissions'),
                        '$aclselect' => $aclselect_e,
+                       '$lockstate' => is_array($a->user)
+                                       && (strlen($a->user['allow_cid'])
+                                               || strlen($a->user['allow_gid'])
+                                               || strlen($a->user['deny_cid'])
+                                               || strlen($a->user['deny_gid'])
+                                       ) ? 'lock' : 'unlock',
                        '$alt_uploader' => $ret['addon_text'],
                        '$default_upload_box' => ($ret['default_upload'] ? $default_upload_box : ''),
                        '$default_upload_submit' => ($ret['default_upload'] ? $default_upload_submit : ''),
index 5d7489ebb4159aaaae337fa5ab884ebf0a01641c..4f2e22d67464b3e6190ae2d97502ea82f15cd8cc 100644 (file)
@@ -23,7 +23,7 @@ use Friendica\Util\DateTimeFormat;
 
 function profile_init(App $a)
 {
-       if (!x($a->page, 'aside')) {
+       if (empty($a->page['aside'])) {
                $a->page['aside'] = '';
        }
 
@@ -54,15 +54,15 @@ function profile_init(App $a)
        $blocked   = !local_user() && !remote_user() && Config::get('system', 'block_public');
        $userblock = !local_user() && !remote_user() && $a->profile['hidewall'];
 
-       if (x($a->profile, 'page-flags') && $a->profile['page-flags'] == Contact::PAGE_COMMUNITY) {
+       if (!empty($a->profile['page-flags']) && $a->profile['page-flags'] == Contact::PAGE_COMMUNITY) {
                $a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
        }
 
-       if (x($a->profile, 'openidserver')) {
+       if (!empty($a->profile['openidserver'])) {
                $a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
        }
 
-       if (x($a->profile, 'openid')) {
+       if (!empty($a->profile['openid'])) {
                $delegate = strstr($a->profile['openid'], '://') ? $a->profile['openid'] : 'https://' . $a->profile['openid'];
                $a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
        }
@@ -109,7 +109,7 @@ function profile_content(App $a, $update = 0)
                }
        }
 
-       if (!x($category)) {
+       if (empty($category)) {
                $category = defaults($_GET, 'category', '');
        }
 
@@ -140,7 +140,7 @@ function profile_content(App $a, $update = 0)
 
        $contact_id = 0;
 
-       if (x($_SESSION, 'remote') && is_array($_SESSION['remote'])) {
+       if (!empty($_SESSION['remote'])) {
                foreach ($_SESSION['remote'] as $v) {
                        if ($v['uid'] == $a->profile['profile_uid']) {
                                $contact_id = $v['cid'];
@@ -171,14 +171,14 @@ function profile_content(App $a, $update = 0)
        $is_owner = local_user() == $a->profile['profile_uid'];
        $last_updated_key = "profile:" . $a->profile['profile_uid'] . ":" . local_user() . ":" . remote_user();
 
-       if (x($a->profile, 'hidewall') && !$is_owner && !$remote_contact) {
+       if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact) {
                notice(L10n::t('Access to this profile has been restricted.') . EOL);
                return;
        }
 
        if (!$update) {
                $tab = false;
-               if (x($_GET, 'tab')) {
+               if (!empty($_GET['tab'])) {
                        $tab = notags(trim($_GET['tab']));
                }
 
@@ -196,7 +196,7 @@ function profile_content(App $a, $update = 0)
                $commvisitor = $commpage && $remote_contact;
 
                $a->page['aside'] .= posted_date_widget(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'], true);
-               $a->page['aside'] .= Widget::categories(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], (x($category) ? xmlify($category) : ''));
+               $a->page['aside'] .= Widget::categories(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], (!empty($category) ? xmlify($category) : ''));
                $a->page['aside'] .= Widget::tagCloud();
 
                if (can_write_wall($a->profile['profile_uid'])) {
@@ -227,7 +227,7 @@ function profile_content(App $a, $update = 0)
        $sql_extra2 = '';
 
        if ($update) {
-               $last_updated = (x($_SESSION['last_updated'], $last_updated_key) ? $_SESSION['last_updated'][$last_updated_key] : 0);
+               $last_updated = (!empty($_SESSION['last_updated'][$last_updated_key]) ? $_SESSION['last_updated'][$last_updated_key] : 0);
 
                // If the page user is the owner of the page we should query for unseen
                // items. Otherwise use a timestamp of the last succesful update request.
@@ -238,7 +238,7 @@ function profile_content(App $a, $update = 0)
                        $sql_extra4 = " AND `item`.`received` > '" . $gmupdate . "'";
                }
 
-               $r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`, `item`.`created`
+               $items = q("SELECT DISTINCT(`parent-uri`) AS `uri`
                        FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
                        AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
                        WHERE `item`.`uid` = %d AND `item`.`visible` AND
@@ -250,38 +250,33 @@ function profile_content(App $a, $update = 0)
                        intval($a->profile['profile_uid']), intval(GRAVITY_ACTIVITY)
                );
 
-               if (!DBA::isResult($r)) {
+               if (!DBA::isResult($items)) {
                        return '';
                }
        } else {
                $sql_post_table = "";
 
-               if (x($category)) {
+               if (!empty($category)) {
                        $sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
                                DBA::escape(protect_sprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($a->profile['profile_uid']));
                }
 
-               if (x($hashtags)) {
+               if (!empty($hashtags)) {
                        $sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
                                DBA::escape(protect_sprintf($hashtags)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval($a->profile['profile_uid']));
                }
 
-               if ($datequery) {
+               if (!empty($datequery)) {
                        $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", DBA::escape(DateTimeFormat::convert($datequery, 'UTC', date_default_timezone_get()))));
                }
-               if ($datequery2) {
+               if (!empty($datequery2)) {
                        $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", DBA::escape(DateTimeFormat::convert($datequery2, 'UTC', date_default_timezone_get()))));
                }
 
-               // Belongs the profile page to a forum?
+               // Does the profile page belong to a forum?
                // If not then we can improve the performance with an additional condition
-               $r = q("SELECT `uid` FROM `user` WHERE `uid` = %d AND `page-flags` IN (%d, %d)",
-                       intval($a->profile['profile_uid']),
-                       intval(Contact::PAGE_COMMUNITY),
-                       intval(Contact::PAGE_PRVGROUP)
-               );
-
-               if (!DBA::isResult($r)) {
+               $condition = ['uid' => $a->profile['profile_uid'], 'page-flags' => [Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP]];
+               if (!DBA::exists('user', $condition)) {
                        $sql_extra3 = sprintf(" AND `thread`.`contact-id` = %d ", intval(intval($a->profile['contact_id'])));
                } else {
                        $sql_extra3 = "";
@@ -305,7 +300,7 @@ function profile_content(App $a, $update = 0)
 
                $pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
 
-               $r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`
+               $items = q("SELECT `item`.`uri`
                        FROM `thread`
                        STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
                        $sql_post_table
@@ -321,31 +316,15 @@ function profile_content(App $a, $update = 0)
                );
        }
 
-       $parents_arr = [];
-       $parents_str = '';
-
        // Set a time stamp for this page. We will make use of it when we
        // search for new items (update routine)
        $_SESSION['last_updated'][$last_updated_key] = time();
 
-       if (DBA::isResult($r)) {
-               foreach ($r as $rr) {
-                       $parents_arr[] = $rr['item_id'];
-               }
-
-               $condition = ['uid' => $a->profile['profile_uid'], 'parent' => $parents_arr];
-               $result = Item::selectForUser($a->profile['profile_uid'], [], $condition);
-               $items = conv_sort(Item::inArray($result), 'created');
-       } else {
-               $items = [];
-       }
-
        if ($is_owner && !$update && !Config::get('theme', 'hide_eventlist')) {
                $o .= Profile::getBirthdays();
                $o .= Profile::getEventsReminderHTML();
        }
 
-
        if ($is_owner) {
                $unseen = Item::exists(['wall' => true, 'unseen' => true, 'uid' => local_user()]);
                if ($unseen) {
index 727b70d660b17242b269327ddc8a803ea87ab8ee..3acf960dab7b2556218dd2ed7a2a52d1501ff4fe 100644 (file)
@@ -23,7 +23,7 @@ function redir_init(App $a) {
        }
 
        if (!empty($cid)) {
-               $fields = ['id', 'uid', 'nurl', 'url', 'addr', 'name', 'network', 'poll', 'issued-id', 'dfrn-id', 'duplex'];
+               $fields = ['id', 'uid', 'nurl', 'url', 'addr', 'name', 'network', 'poll', 'issued-id', 'dfrn-id', 'duplex', 'pending'];
                $contact = DBA::selectFirst('contact', $fields, ['id' => $cid, 'uid' => [0, local_user()]]);
                if (!DBA::isResult($contact)) {
                        notice(L10n::t('Contact not found.'));
@@ -80,7 +80,7 @@ function redir_init(App $a) {
                }
 
                // Doing remote auth with dfrn.
-               if (local_user()&& (!empty($contact['dfrn-id']) || !empty($contact['issued-id']))) {
+               if (local_user() && (!empty($contact['dfrn-id']) || !empty($contact['issued-id'])) && empty($contact['pending'])) {
                        $dfrn_id = $orig_id = (($contact['issued-id']) ? $contact['issued-id'] : $contact['dfrn-id']);
 
                        if ($contact['duplex'] && $contact['issued-id']) {
index d02ea73ca46de28dd984ef69803b36d22a19e35e..55fa517342c131fc0ce15862b9aba1aad899ffc0 100644 (file)
@@ -140,6 +140,8 @@ class App
         * @brief App constructor.
         *
         * @param string $basepath Path to the app base folder
+        *
+        * @throws Exception if the Basepath is not usable
         */
        public function __construct($basepath)
        {
index 43c79bfb5712d5c3847c2537ba8e11615d20c05f..a8489e7c8d7c8e8044392bc6222e19e9f99c13a8 100644 (file)
@@ -4,6 +4,7 @@ namespace Friendica\Core\Console;
 
 use Asika\SimpleConsole\Console;
 use Friendica\App;
+use Friendica\BaseObject;
 use Friendica\Core\Config;
 use Friendica\Core\Install;
 use Friendica\Core\Theme;
@@ -20,19 +21,51 @@ class AutomaticInstallation extends Console
                return <<<HELP
 Installation - Install Friendica automatically
 Synopsis
-       bin/console autoinstall [-h|--help|-?] [-v] [-a]
+       bin/console autoinstall [-h|--help|-?] [-v] [-a] [-f]
 
 Description
-    Installs Friendica with data based on the htconfig.php file
+    Installs Friendica with data based on the local.ini.php file or environment variables
 
-Notes:
+Notes
     Not checking .htaccess/URL-Rewrite during CLI installation.
 
 Options
-    -h|--help|-? Show help information
-    -v           Show more debug information.
-    -a           All setup checks are required (except .htaccess)
-    -f           prepared config file (e.g. ".htconfig.php" itself)
+    -h|--help|-?           Show help information
+    -v                     Show more debug information.
+    -a                     All setup checks are required (except .htaccess)
+    -f|--file <config>     prepared config file (e.g. "config/local.ini.php" itself) which will override every other config option - except the environment variables)
+    -s|--savedb            Save the DB credentials to the file (if environment variables is used)
+    -h|--dbhost <host>     The host of the mysql database (env MYSQL_HOST)
+    -p|--dbport <port>     The port of the mysql database (env MYSQL_PORT)
+    -d|--dbdata <database> The name of the mysql database (env MYSQL_DATABASE)
+    -U|--dbuser <username> The username of the mysql database login (env MYSQL_USER or MYSQL_USERNAME)
+    -P|--dbpass <password> The password of the mysql database login (env MYSQL_PASSWORD)
+    -b|--phppath <path>    The path of the PHP binary (env FRIENDICA_PHP_PATH) 
+    -A|--admin <mail>      The admin email address of Friendica (env FRIENDICA_ADMIN_MAIL)
+    -T|--tz <timezone>     The timezone of Friendica (env FRIENDICA_TZ)
+    -L|--lang <language>   The language of Friendica (env FRIENDICA_LANG)
+Environment variables
+   MYSQL_HOST                  The host of the mysql database (mandatory if mysql and environment is used)
+   MYSQL_PORT                  The port of the mysql database
+   MYSQL_USERNAME|MYSQL_USER   The username of the mysql database login (MYSQL_USERNAME is for mysql, MYSQL_USER for mariadb)
+   MYSQL_PASSWORD              The password of the mysql database login
+   MYSQL_DATABASE              The name of the mysql database
+   FRIENDICA_PHP_PATH          The path of the PHP binary
+   FRIENDICA_ADMIN_MAIL        The admin email address of Friendica
+   FRIENDICA_TZ                The timezone of Friendica
+   FRIENDICA_LANG              The langauge of Friendica
+   
+Examples
+       bin/console autoinstall -f 'input.ini.php
+               Installs Friendica with the prepared 'input.ini.php' file
+
+       bin/console autoinstall --savedb
+               Installs Friendica with environment variables and saves them to the 'config/local.ini.php' file
+
+       bin/console autoinstall -h localhost -p 3365 -U user -P passwort1234 -d friendica
+               Installs Friendica with a local mysql database with credentials 
+   
 HELP;
        }
 
@@ -41,18 +74,59 @@ HELP;
                // Initialise the app
                $this->out("Initializing setup...\n");
 
-               $a = get_app();
-               $db_host = '';
-               $db_user = '';
-               $db_pass = '';
-               $db_data = '';
+               // if a config file is set,
+               $config_file = $this->getOption(['f', 'file']);
 
-               $config_file = $this->getOption('f', 'htconfig.php');
+               if (!empty($config_file)) {
+                       if ($config_file != 'config/local.ini.php') {
+                               // Copy config file
+                               $this->out("Copying config file...\n");
+                               if (!copy($config_file, 'config/local.ini.php')) {
+                                       throw new RuntimeException("ERROR: Saving config file failed. Please copy '$config_file' to 'config/local.ini.php' manually.\n");
+                               }
+                       }
 
-               $this->out("Using config $config_file...\n");
-               require_once $config_file;
+                       // load the app after copying the file
+                       $a = BaseObject::getApp();
 
-               Install::setInstallMode();
+                       $db_host = $a->getConfigValue('database', 'hostname');
+                       $db_user = $a->getConfigValue('database', 'username');
+                       $db_pass = $a->getConfigValue('database', 'password');
+                       $db_data = $a->getConfigValue('database', 'database');
+               } else {
+                       // Creating config file
+                       $this->out("Creating config file...\n");
+
+                       // load the app first (for the template engine)
+                       $a = BaseObject::getApp();
+
+                       $save_db = $this->getOption(['s', 'savedb'], false);
+
+                       $db_host = $this->getOption(['h', 'dbhost'], ($save_db) ? getenv('MYSQL_HOST') : '');
+                       $db_port = $this->getOption(['p', 'dbport'], ($save_db) ? getenv('MYSQL_PORT') : null);
+                       $db_data = $this->getOption(['d', 'dbdata'], ($save_db) ? getenv('MYSQL_DATABASE') : '');
+                       $db_user = $this->getOption(['U', 'dbuser'], ($save_db) ? getenv('MYSQL_USER') . getenv('MYSQL_USERNAME') : '');
+                       $db_pass = $this->getOption(['P', 'dbpass'], ($save_db) ? getenv('MYSQL_PASSWORD') : '');
+                       $php_path = $this->getOption(['b', 'phppath'], (!empty('FRIENDICA_PHP_PATH')) ? getenv('FRIENDICA_PHP_PATH') : '');
+                       $admin_mail = $this->getOption(['A', 'admin'], (!empty('FRIENDICA_ADMIN_MAIL')) ? getenv('FRIENDICA_ADMIN_MAIL') : '');
+                       $tz = $this->getOption(['T', 'tz'], (!empty('FRIENDICA_TZ')) ? getenv('FRIENDICA_TZ') : '');
+                       $lang = $this->getOption(['L', 'lang'], (!empty('FRIENDICA_LANG')) ? getenv('FRIENDICA_LANG') : '');
+
+                       // creating config file
+                       $this->out("Creating config file...\n");
+
+                       Install::createConfig(
+                               $php_path,
+                               $db_host,
+                               $db_user,
+                               $db_pass,
+                               $db_data,
+                               $php_path,
+                               $tz,
+                               $lang,
+                               $admin_mail
+                       );
+               }
 
                $this->out(" Complete!\n\n");
 
@@ -99,15 +173,9 @@ HELP;
                        Theme::install(Config::get('system', 'theme'));
                        $this->out(" Complete\n\n");
                } else {
-                       $this->out(" Theme setting is empty. Please check the file htconfig.php\n\n");
+                       $this->out(" Theme setting is empty. Please check the file 'config/local.ini.php'\n\n");
                }
 
-               // Copy config file
-               $this->out("Saving config file...\n");
-               if ($config_file != '.htconfig.php' && !copy($config_file, '.htconfig.php')) {
-                       throw new RuntimeException("ERROR: Saving config file failed. Please copy '$config_file' to '.htconfig.php' manually.\n");
-               }
-               $this->out(" Complete!\n\n");
                $this->out("\nInstallation is finished\n");
 
                return 0;
index ec33ef9634d77c0440dc74a4aac4b7111f263435..e8f014618d652c51e193db3b9c16a64a3da61c1e 100644 (file)
-<?php\r
-/**\r
- * @file src/Core/Install.php\r
- */\r
-namespace Friendica\Core;\r
-\r
-use Friendica\BaseObject;\r
-use Friendica\App;\r
-use Friendica\Database\DBStructure;\r
-use Friendica\Object\Image;\r
-use Friendica\Util\Network;\r
-\r
-use Exception;\r
-use DOMDocument;\r
-\r
-/**\r
- * Contains methods for installation purpose of Friendica\r
- */\r
-class Install extends BaseObject\r
-{\r
-       /**\r
-        * Sets the install-mode for further methods\r
-        */\r
-       public static function setInstallMode()\r
-       {\r
-               self::getApp()->mode = App::MODE_INSTALL;\r
-       }\r
-\r
-       /**\r
-        * Checks the current installation environment. There are optional and mandatory checks.\r
-        *\r
-        * @param string $phpath Optional path to the PHP binary (Default is 'php')\r
-        *\r
-        * @return array First element is a list of all checks and their results,\r
-        *               the second element is a list of passed checks\r
-        */\r
-       public static function check($phpath = 'php')\r
-       {\r
-               $checks = [];\r
-\r
-               self::checkFunctions($checks);\r
-\r
-               self::checkImagick($checks);\r
-\r
-               self::checkLocalIni($checks);\r
-\r
-               self::checkSmarty3($checks);\r
-\r
-               self::checkKeys($checks);\r
-\r
-               self::checkPHP($phpath, $checks);\r
-\r
-               self::checkHtAccess($checks);\r
-\r
-               $checkspassed = array_reduce($checks,\r
-                       function ($v, $c) {\r
-                               if (!empty($c['require'])) {\r
-                                       $v = $v && $c['status'];\r
-                               }\r
-                               return $v;\r
-                       },\r
-                       true);\r
-\r
-               return array($checks, $checkspassed);\r
-       }\r
-\r
-       /**\r
-        * Executes the installation of Friendica in the given environment.\r
-        * - Creates `config/local.ini.php`\r
-        * - Installs Database Structure\r
-        *\r
-        * @param string        $urlpath        Path based on the URL of Friendica (e.g. '/friendica')\r
-        * @param string        $dbhost         Hostname/IP of the Friendica Database\r
-        * @param string        $dbuser         Username of the Database connection credentials\r
-        * @param string        $dbpass         Password of the Database connection credentials\r
-        * @param string        $dbdata         Name of the Database\r
-        * @param string        $phpath         Path to the PHP-Binary (e.g. 'php' or '/usr/bin/php')\r
-        * @param string        $timezone       Timezone of the Friendica Installaton (e.g. 'Europe/Berlin')\r
-        * @param string        $language       2-letter ISO 639-1 code (eg. 'en')\r
-        * @param string        $adminmail      Mail-Adress of the administrator\r
-        * @param int           $rino           Rino-enabled (1 = true, 0 = false)\r
-        */\r
-       public static function install($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail)\r
-       {\r
-               $tpl = get_markup_template('local.ini.tpl');\r
-               $txt = replace_macros($tpl,[\r
-                       '$dbhost' => $dbhost,\r
-                       '$dbuser' => $dbuser,\r
-                       '$dbpass' => $dbpass,\r
-                       '$dbdata' => $dbdata,\r
-                       '$timezone' => $timezone,\r
-                       '$language' => $language,\r
-                       '$urlpath' => $urlpath,\r
-                       '$phpath' => $phpath,\r
-                       '$adminmail' => $adminmail,\r
-               ]);\r
-\r
-               $result = file_put_contents('config/local.ini.php', $txt);\r
-               if (! $result) {\r
-                       self::getApp()->data['txt'] = $txt;\r
-               }\r
-\r
-               $errors = self::installDatabaseStructure();\r
-\r
-               if ($errors) {\r
-                       self::getApp()->data['db_failed'] = $errors;\r
-               } else {\r
-                       self::getApp()->data['db_installed'] = true;\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Adds new checks to the array $checks\r
-        *\r
-        * @param array $checks The list of all checks (by-ref parameter!)\r
-        * @param string $title The title of the current check\r
-        * @param bool $status 1 = check passed, 0 = check not passed\r
-        * @param bool $required 1 = check is mandatory, 0 = check is optional\r
-        * @param string $help A help-string for the current check\r
-        * @param string $error_msg Optional. A error message, if the current check failed\r
-        */\r
-       private static function addCheck(&$checks, $title, $status, $required, $help, $error_msg = "")\r
-       {\r
-               $checks[] = [\r
-                       'title' => $title,\r
-                       'status' => $status,\r
-                       'required' => $required,\r
-                       'help' => $help,\r
-                       'error_msg' => $error_msg,\r
-               ];\r
-       }\r
-\r
-       /**\r
-        * PHP Check\r
-        *\r
-        * Checks the PHP environment.\r
-        *\r
-        * - Checks if a PHP binary is available\r
-        * - Checks if it is the CLI version\r
-        * - Checks if "register_argc_argv" is enabled\r
-        *\r
-        * @param string $phpath Optional. The Path to the PHP-Binary\r
-        * @param array $checks The list of all checks (by-ref parameter!)\r
-        */\r
-       public static function checkPHP(&$phpath, &$checks)\r
-       {\r
-               $passed = $passed2 = $passed3 = false;\r
-               if (strlen($phpath)) {\r
-                       $passed = file_exists($phpath);\r
-               } else {\r
-                       $phpath = trim(shell_exec('which php'));\r
-                       $passed = strlen($phpath);\r
-               }\r
-               $help = "";\r
-               if (!$passed) {\r
-                       $help .= L10n::t('Could not find a command line version of PHP in the web server PATH.') . EOL;\r
-                       $help .= L10n::t("If you don't have a command line version of PHP installed on your server, you will not be able to run the background processing. See <a href='https://github.com/friendica/friendica/blob/master/doc/Install.md#set-up-the-worker'>'Setup the worker'</a>") . EOL;\r
-                       $help .= EOL . EOL;\r
-                       $tpl = get_markup_template('field_input.tpl');\r
-                       $help .= replace_macros($tpl, [\r
-                               '$field' => ['phpath', L10n::t('PHP executable path'), $phpath, L10n::t('Enter full path to php executable. You can leave this blank to continue the installation.')],\r
-                       ]);\r
-                       $phpath = "";\r
-               }\r
-\r
-               self::addCheck($checks, L10n::t('Command line PHP').($passed?" (<tt>$phpath</tt>)":""), $passed, false, $help);\r
-\r
-               if ($passed) {\r
-                       $cmd = "$phpath -v";\r
-                       $result = trim(shell_exec($cmd));\r
-                       $passed2 = (strpos($result, "(cli)") !== false);\r
-                       list($result) = explode("\n", $result);\r
-                       $help = "";\r
-                       if (!$passed2) {\r
-                               $help .= L10n::t("PHP executable is not the php cli binary \x28could be cgi-fgci version\x29") . EOL;\r
-                               $help .= L10n::t('Found PHP version: ') . "<tt>$result</tt>";\r
-                       }\r
-                       self::addCheck($checks, L10n::t('PHP cli binary'), $passed2, true, $help);\r
-               }\r
-\r
-               if ($passed2) {\r
-                       $str = autoname(8);\r
-                       $cmd = "$phpath testargs.php $str";\r
-                       $result = trim(shell_exec($cmd));\r
-                       $passed3 = $result == $str;\r
-                       $help = "";\r
-                       if (!$passed3) {\r
-                               $help .= L10n::t('The command line version of PHP on your system does not have "register_argc_argv" enabled.') . EOL;\r
-                               $help .= L10n::t('This is required for message delivery to work.');\r
-                       }\r
-                       self::addCheck($checks, L10n::t('PHP register_argc_argv'), $passed3, true, $help);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * OpenSSL Check\r
-        *\r
-        * Checks the OpenSSL Environment\r
-        *\r
-        * - Checks, if the command "openssl_pkey_new" is available\r
-        *\r
-        * @param array $checks The list of all checks (by-ref parameter!)\r
-        */\r
-       public static function checkKeys(&$checks)\r
-       {\r
-               $help = '';\r
-               $res = false;\r
-\r
-               if (function_exists('openssl_pkey_new')) {\r
-                       $res = openssl_pkey_new([\r
-                               'digest_alg' => 'sha1',\r
-                               'private_key_bits' => 4096,\r
-                               'encrypt_key' => false\r
-                       ]);\r
-               }\r
-\r
-               // Get private key\r
-               if (!$res) {\r
-                       $help .= L10n::t('Error: the "openssl_pkey_new" function on this system is not able to generate encryption keys') . EOL;\r
-                       $help .= L10n::t('If running under Windows, please see "http://www.php.net/manual/en/openssl.installation.php".');\r
-               }\r
-               self::addCheck($checks, L10n::t('Generate encryption keys'), $res, true, $help);\r
-       }\r
-\r
-       /**\r
-        * PHP functions Check\r
-        *\r
-        * Checks the following PHP functions\r
-        * - libCurl\r
-        * - GD Graphics\r
-        * - OpenSSL\r
-        * - PDO or MySQLi\r
-        * - mb_string\r
-        * - XML\r
-        * - iconv\r
-        * - POSIX\r
-        *\r
-        * @param array $checks The list of all checks (by-ref parameter!)\r
-        */\r
-       public static function checkFunctions(&$checks)\r
-       {\r
-               $ck_funcs = [];\r
-               self::addCheck($ck_funcs, L10n::t('libCurl PHP module'), true, true, "");\r
-               self::addCheck($ck_funcs, L10n::t('GD graphics PHP module'), true, true, "");\r
-               self::addCheck($ck_funcs, L10n::t('OpenSSL PHP module'), true, true, "");\r
-               self::addCheck($ck_funcs, L10n::t('PDO or MySQLi PHP module'), true, true, "");\r
-               self::addCheck($ck_funcs, L10n::t('mb_string PHP module'), true, true, "");\r
-               self::addCheck($ck_funcs, L10n::t('XML PHP module'), true, true, "");\r
-               self::addCheck($ck_funcs, L10n::t('iconv PHP module'), true, true, "");\r
-               self::addCheck($ck_funcs, L10n::t('POSIX PHP module'), true, true, "");\r
-\r
-               if (function_exists('apache_get_modules')) {\r
-                       if (! in_array('mod_rewrite',apache_get_modules())) {\r
-                               self::addCheck($ck_funcs, L10n::t('Apache mod_rewrite module'), false, true, L10n::t('Error: Apache webserver mod-rewrite module is required but not installed.'));\r
-                       } else {\r
-                               self::addCheck($ck_funcs, L10n::t('Apache mod_rewrite module'), true, true, "");\r
-                       }\r
-               }\r
-\r
-               if (!function_exists('curl_init')) {\r
-                       $ck_funcs[0]['status'] = false;\r
-                       $ck_funcs[0]['help'] = L10n::t('Error: libCURL PHP module required but not installed.');\r
-               }\r
-               if (!function_exists('imagecreatefromjpeg')) {\r
-                       $ck_funcs[1]['status'] = false;\r
-                       $ck_funcs[1]['help'] = L10n::t('Error: GD graphics PHP module with JPEG support required but not installed.');\r
-               }\r
-               if (!function_exists('openssl_public_encrypt')) {\r
-                       $ck_funcs[2]['status'] = false;\r
-                       $ck_funcs[2]['help'] = L10n::t('Error: openssl PHP module required but not installed.');\r
-               }\r
-               if (!function_exists('mysqli_connect') && !class_exists('pdo')) {\r
-                       $ck_funcs[3]['status'] = false;\r
-                       $ck_funcs[3]['help'] = L10n::t('Error: PDO or MySQLi PHP module required but not installed.');\r
-               }\r
-               if (!function_exists('mysqli_connect') && class_exists('pdo') && !in_array('mysql', \PDO::getAvailableDrivers())) {\r
-                       $ck_funcs[3]['status'] = false;\r
-                       $ck_funcs[3]['help'] = L10n::t('Error: The MySQL driver for PDO is not installed.');\r
-               }\r
-               if (!function_exists('mb_strlen')) {\r
-                       $ck_funcs[4]['status'] = false;\r
-                       $ck_funcs[4]['help'] = L10n::t('Error: mb_string PHP module required but not installed.');\r
-               }\r
-               if (!function_exists('iconv_strlen')) {\r
-                       $ck_funcs[6]['status'] = false;\r
-                       $ck_funcs[6]['help'] = L10n::t('Error: iconv PHP module required but not installed.');\r
-               }\r
-               if (!function_exists('posix_kill')) {\r
-                       $ck_funcs[7]['status'] = false;\r
-                       $ck_funcs[7]['help'] = L10n::t('Error: POSIX PHP module required but not installed.');\r
-               }\r
-\r
-               $checks = array_merge($checks, $ck_funcs);\r
-\r
-               // check for XML DOM Documents being able to be generated\r
-               try {\r
-                       $xml = new DOMDocument();\r
-               } catch (Exception $e) {\r
-                       $ck_funcs[5]['status'] = false;\r
-                       $ck_funcs[5]['help'] = L10n::t('Error, XML PHP module required but not installed.');\r
-               }\r
-       }\r
-\r
-       /**\r
-        * "config/local.ini.php" - Check\r
-        *\r
-        * Checks if it's possible to create the "config/local.ini.php"\r
-        *\r
-        * @param array $checks The list of all checks (by-ref parameter!)\r
-        */\r
-       public static function checkLocalIni(&$checks)\r
-       {\r
-               $status = true;\r
-               $help = "";\r
-               if ((file_exists('config/local.ini.php') && !is_writable('config/local.ini.php')) ||\r
-                       (!file_exists('config/local.ini.php') && !is_writable('.'))) {\r
-\r
-                       $status = false;\r
-                       $help = L10n::t('The web installer needs to be able to create a file called "local.ini.php" in the "config" folder of your web server and it is unable to do so.') . EOL;\r
-                       $help .= L10n::t('This is most often a permission setting, as the web server may not be able to write files in your folder - even if you can.') . EOL;\r
-                       $help .= L10n::t('At the end of this procedure, we will give you a text to save in a file named local.ini.php in your Friendica "config" folder.') . EOL;\r
-                       $help .= L10n::t('You can alternatively skip this procedure and perform a manual installation. Please see the file "INSTALL.txt" for instructions.') . EOL;\r
-               }\r
-\r
-               self::addCheck($checks, L10n::t('config/local.ini.php is writable'), $status, false, $help);\r
-\r
-       }\r
-\r
-       /**\r
-        * Smarty3 Template Check\r
-        *\r
-        * Checks, if the directory of Smarty3 is writable\r
-        *\r
-        * @param array $checks The list of all checks (by-ref parameter!)\r
-        */\r
-       public static function checkSmarty3(&$checks)\r
-       {\r
-               $status = true;\r
-               $help = "";\r
-               if (!is_writable('view/smarty3')) {\r
-\r
-                       $status = false;\r
-                       $help = L10n::t('Friendica uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') . EOL;\r
-                       $help .= L10n::t('In order to store these compiled templates, the web server needs to have write access to the directory view/smarty3/ under the Friendica top level folder.') . EOL;\r
-                       $help .= L10n::t("Please ensure that the user that your web server runs as \x28e.g. www-data\x29 has write access to this folder.") . EOL;\r
-                       $help .= L10n::t("Note: as a security measure, you should give the web server write access to view/smarty3/ only--not the template files \x28.tpl\x29 that it contains.") . EOL;\r
-               }\r
-\r
-               self::addCheck($checks, L10n::t('view/smarty3 is writable'), $status, true, $help);\r
-       }\r
-\r
-       /**\r
-        * ".htaccess" - Check\r
-        *\r
-        * Checks, if "url_rewrite" is enabled in the ".htaccess" file\r
-        *\r
-        * @param array $checks The list of all checks (by-ref parameter!)\r
-        */\r
-       public static function checkHtAccess(&$checks)\r
-       {\r
-               $status = true;\r
-               $help = "";\r
-               $error_msg = "";\r
-               if (function_exists('curl_init')) {\r
-                       $test = Network::fetchUrlFull(System::baseUrl() . "/install/testrewrite");\r
-\r
-                       $url = normalise_link(System::baseUrl() . "/install/testrewrite");\r
-                       if ($test['body'] != "ok") {\r
-                               $test = Network::fetchUrlFull($url);\r
-                       }\r
-\r
-                       if ($test['body'] != "ok") {\r
-                               $status = false;\r
-                               $help = L10n::t('Url rewrite in .htaccess is not working. Check your server configuration.');\r
-                               $error_msg = [];\r
-                               $error_msg['head'] = L10n::t('Error message from Curl when fetching');\r
-                               $error_msg['url'] = $test['redirect_url'];\r
-                               $error_msg['msg'] = defaults($test, 'error', '');\r
-                       }\r
-                       self::addCheck($checks, L10n::t('Url rewrite is working'), $status, true, $help, $error_msg);\r
-               } else {\r
-                       // cannot check modrewrite if libcurl is not installed\r
-                       /// @TODO Maybe issue warning here?\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Imagick Check\r
-        *\r
-        * Checks, if the imagick module is available\r
-        *\r
-        * @param array $checks The list of all checks (by-ref parameter!)\r
-        */\r
-       public static function checkImagick(&$checks)\r
-       {\r
-               $imagick = false;\r
-               $gif = false;\r
-\r
-               if (class_exists('Imagick')) {\r
-                       $imagick = true;\r
-                       $supported = Image::supportedTypes();\r
-                       if (array_key_exists('image/gif', $supported)) {\r
-                               $gif = true;\r
-                       }\r
-               }\r
-               if ($imagick == false) {\r
-                       self::addCheck($checks, L10n::t('ImageMagick PHP extension is not installed'), $imagick, false, "");\r
-               } else {\r
-                       self::addCheck($checks, L10n::t('ImageMagick PHP extension is installed'), $imagick, false, "");\r
-                       if ($imagick) {\r
-                               self::addCheck($checks, L10n::t('ImageMagick supports GIF'), $gif, false, "");\r
-                       }\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Installs the Database structure\r
-        *\r
-        * @return string A possible error\r
-        */\r
-       public static function installDatabaseStructure()\r
-       {\r
-               $errors = DBStructure::update(false, true, true);\r
-\r
-               return $errors;\r
-       }\r
-}\r
+<?php
+/**
+ * @file src/Core/Install.php
+ */
+namespace Friendica\Core;
+
+use DOMDocument;
+use Exception;
+use Friendica\BaseObject;
+use Friendica\Database\DBStructure;
+use Friendica\Object\Image;
+use Friendica\Util\Network;
+
+/**
+ * Contains methods for installation purpose of Friendica
+ */
+class Install extends BaseObject
+{
+       /**
+        * Checks the current installation environment. There are optional and mandatory checks.
+        *
+        * @param string $phpath Optional path to the PHP binary (Default is 'php')
+        *
+        * @return array First element is a list of all checks and their results,
+        *               the second element is a list of passed checks
+        */
+       public static function check($phpath = 'php')
+       {
+               $checks = [];
+
+               self::checkFunctions($checks);
+
+               self::checkImagick($checks);
+
+               self::checkLocalIni($checks);
+
+               self::checkSmarty3($checks);
+
+               self::checkKeys($checks);
+
+               self::checkPHP($phpath, $checks);
+
+               self::checkHtAccess($checks);
+
+               $checkspassed = array_reduce($checks,
+                       function ($v, $c) {
+                               if (!empty($c['require'])) {
+                                       $v = $v && $c['status'];
+                               }
+                               return $v;
+                       },
+                       true);
+
+               return array($checks, $checkspassed);
+       }
+
+       /**
+        * Executes the installation of Friendica in the given environment.
+        * - Creates `config/local.ini.php`
+        * - Installs Database Structure
+        *
+        * @param string        $urlpath        Path based on the URL of Friendica (e.g. '/friendica')
+        * @param string        $dbhost         Hostname/IP of the Friendica Database
+        * @param string        $dbuser         Username of the Database connection credentials
+        * @param string        $dbpass         Password of the Database connection credentials
+        * @param string        $dbdata         Name of the Database
+        * @param string        $phpath         Path to the PHP-Binary (e.g. 'php' or '/usr/bin/php')
+        * @param string        $timezone       Timezone of the Friendica Installaton (e.g. 'Europe/Berlin')
+        * @param string        $language       2-letter ISO 639-1 code (eg. 'en')
+        * @param string        $adminmail      Mail-Adress of the administrator
+        */
+       public static function createConfig($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail)
+       {
+               $tpl = get_markup_template('local.ini.tpl');
+               $txt = replace_macros($tpl,[
+                       '$dbhost' => $dbhost,
+                       '$dbuser' => $dbuser,
+                       '$dbpass' => $dbpass,
+                       '$dbdata' => $dbdata,
+                       '$timezone' => $timezone,
+                       '$language' => $language,
+                       '$urlpath' => $urlpath,
+                       '$phpath' => $phpath,
+                       '$adminmail' => $adminmail,
+               ]);
+
+               $result = file_put_contents('config/local.ini.php', $txt);
+               if (!$result) {
+                       self::getApp()->data['txt'] = $txt;
+               }
+
+       }
+
+       /**
+        * Adds new checks to the array $checks
+        *
+        * @param array $checks The list of all checks (by-ref parameter!)
+        * @param string $title The title of the current check
+        * @param bool $status 1 = check passed, 0 = check not passed
+        * @param bool $required 1 = check is mandatory, 0 = check is optional
+        * @param string $help A help-string for the current check
+        * @param string $error_msg Optional. A error message, if the current check failed
+        */
+       private static function addCheck(&$checks, $title, $status, $required, $help, $error_msg = "")
+       {
+               $checks[] = [
+                       'title' => $title,
+                       'status' => $status,
+                       'required' => $required,
+                       'help' => $help,
+                       'error_msg' => $error_msg,
+               ];
+       }
+
+       /**
+        * PHP Check
+        *
+        * Checks the PHP environment.
+        *
+        * - Checks if a PHP binary is available
+        * - Checks if it is the CLI version
+        * - Checks if "register_argc_argv" is enabled
+        *
+        * @param string $phpath Optional. The Path to the PHP-Binary
+        * @param array $checks The list of all checks (by-ref parameter!)
+        */
+       public static function checkPHP($phpath, &$checks)
+       {
+               $passed = $passed2 = $passed3 = false;
+               if (strlen($phpath)) {
+                       $passed = file_exists($phpath);
+               } else {
+                       $phpath = trim(shell_exec('which php'));
+                       $passed = strlen($phpath);
+               }
+               $help = "";
+               if (!$passed) {
+                       $help .= L10n::t('Could not find a command line version of PHP in the web server PATH.') . EOL;
+                       $help .= L10n::t("If you don't have a command line version of PHP installed on your server, you will not be able to run the background processing. See <a href='https://github.com/friendica/friendica/blob/master/doc/Install.md#set-up-the-worker'>'Setup the worker'</a>") . EOL;
+                       $help .= EOL . EOL;
+                       $tpl = get_markup_template('field_input.tpl');
+                       $help .= replace_macros($tpl, [
+                               '$field' => ['phpath', L10n::t('PHP executable path'), $phpath, L10n::t('Enter full path to php executable. You can leave this blank to continue the installation.')],
+                       ]);
+                       $phpath = "";
+               }
+
+               self::addCheck($checks, L10n::t('Command line PHP').($passed?" (<tt>$phpath</tt>)":""), $passed, false, $help);
+
+               if ($passed) {
+                       $cmd = "$phpath -v";
+                       $result = trim(shell_exec($cmd));
+                       $passed2 = (strpos($result, "(cli)") !== false);
+                       list($result) = explode("\n", $result);
+                       $help = "";
+                       if (!$passed2) {
+                               $help .= L10n::t("PHP executable is not the php cli binary \x28could be cgi-fgci version\x29") . EOL;
+                               $help .= L10n::t('Found PHP version: ') . "<tt>$result</tt>";
+                       }
+                       self::addCheck($checks, L10n::t('PHP cli binary'), $passed2, true, $help);
+               }
+
+               if ($passed2) {
+                       $str = autoname(8);
+                       $cmd = "$phpath testargs.php $str";
+                       $result = trim(shell_exec($cmd));
+                       $passed3 = $result == $str;
+                       $help = "";
+                       if (!$passed3) {
+                               $help .= L10n::t('The command line version of PHP on your system does not have "register_argc_argv" enabled.') . EOL;
+                               $help .= L10n::t('This is required for message delivery to work.');
+                       }
+                       self::addCheck($checks, L10n::t('PHP register_argc_argv'), $passed3, true, $help);
+               }
+       }
+
+       /**
+        * OpenSSL Check
+        *
+        * Checks the OpenSSL Environment
+        *
+        * - Checks, if the command "openssl_pkey_new" is available
+        *
+        * @param array $checks The list of all checks (by-ref parameter!)
+        */
+       public static function checkKeys(&$checks)
+       {
+               $help = '';
+               $res = false;
+
+               if (function_exists('openssl_pkey_new')) {
+                       $res = openssl_pkey_new([
+                               'digest_alg' => 'sha1',
+                               'private_key_bits' => 4096,
+                               'encrypt_key' => false
+                       ]);
+               }
+
+               // Get private key
+               if (!$res) {
+                       $help .= L10n::t('Error: the "openssl_pkey_new" function on this system is not able to generate encryption keys') . EOL;
+                       $help .= L10n::t('If running under Windows, please see "http://www.php.net/manual/en/openssl.installation.php".');
+               }
+               self::addCheck($checks, L10n::t('Generate encryption keys'), $res, true, $help);
+       }
+
+       /**
+        * PHP functions Check
+        *
+        * Checks the following PHP functions
+        * - libCurl
+        * - GD Graphics
+        * - OpenSSL
+        * - PDO or MySQLi
+        * - mb_string
+        * - XML
+        * - iconv
+        * - POSIX
+        *
+        * @param array $checks The list of all checks (by-ref parameter!)
+        */
+       public static function checkFunctions(&$checks)
+       {
+               $ck_funcs = [];
+               self::addCheck($ck_funcs, L10n::t('libCurl PHP module'), true, true, "");
+               self::addCheck($ck_funcs, L10n::t('GD graphics PHP module'), true, true, "");
+               self::addCheck($ck_funcs, L10n::t('OpenSSL PHP module'), true, true, "");
+               self::addCheck($ck_funcs, L10n::t('PDO or MySQLi PHP module'), true, true, "");
+               self::addCheck($ck_funcs, L10n::t('mb_string PHP module'), true, true, "");
+               self::addCheck($ck_funcs, L10n::t('XML PHP module'), true, true, "");
+               self::addCheck($ck_funcs, L10n::t('iconv PHP module'), true, true, "");
+               self::addCheck($ck_funcs, L10n::t('POSIX PHP module'), true, true, "");
+
+               if (function_exists('apache_get_modules')) {
+                       if (! in_array('mod_rewrite',apache_get_modules())) {
+                               self::addCheck($ck_funcs, L10n::t('Apache mod_rewrite module'), false, true, L10n::t('Error: Apache webserver mod-rewrite module is required but not installed.'));
+                       } else {
+                               self::addCheck($ck_funcs, L10n::t('Apache mod_rewrite module'), true, true, "");
+                       }
+               }
+
+               if (!function_exists('curl_init')) {
+                       $ck_funcs[0]['status'] = false;
+                       $ck_funcs[0]['help'] = L10n::t('Error: libCURL PHP module required but not installed.');
+               }
+               if (!function_exists('imagecreatefromjpeg')) {
+                       $ck_funcs[1]['status'] = false;
+                       $ck_funcs[1]['help'] = L10n::t('Error: GD graphics PHP module with JPEG support required but not installed.');
+               }
+               if (!function_exists('openssl_public_encrypt')) {
+                       $ck_funcs[2]['status'] = false;
+                       $ck_funcs[2]['help'] = L10n::t('Error: openssl PHP module required but not installed.');
+               }
+               if (!function_exists('mysqli_connect') && !class_exists('pdo')) {
+                       $ck_funcs[3]['status'] = false;
+                       $ck_funcs[3]['help'] = L10n::t('Error: PDO or MySQLi PHP module required but not installed.');
+               }
+               if (!function_exists('mysqli_connect') && class_exists('pdo') && !in_array('mysql', \PDO::getAvailableDrivers())) {
+                       $ck_funcs[3]['status'] = false;
+                       $ck_funcs[3]['help'] = L10n::t('Error: The MySQL driver for PDO is not installed.');
+               }
+               if (!function_exists('mb_strlen')) {
+                       $ck_funcs[4]['status'] = false;
+                       $ck_funcs[4]['help'] = L10n::t('Error: mb_string PHP module required but not installed.');
+               }
+               if (!function_exists('iconv_strlen')) {
+                       $ck_funcs[6]['status'] = false;
+                       $ck_funcs[6]['help'] = L10n::t('Error: iconv PHP module required but not installed.');
+               }
+               if (!function_exists('posix_kill')) {
+                       $ck_funcs[7]['status'] = false;
+                       $ck_funcs[7]['help'] = L10n::t('Error: POSIX PHP module required but not installed.');
+               }
+
+               $checks = array_merge($checks, $ck_funcs);
+
+               // check for XML DOM Documents being able to be generated
+               try {
+                       $xml = new DOMDocument();
+               } catch (Exception $e) {
+                       $ck_funcs[5]['status'] = false;
+                       $ck_funcs[5]['help'] = L10n::t('Error, XML PHP module required but not installed.');
+               }
+       }
+
+       /**
+        * "config/local.ini.php" - Check
+        *
+        * Checks if it's possible to create the "config/local.ini.php"
+        *
+        * @param array $checks The list of all checks (by-ref parameter!)
+        */
+       public static function checkLocalIni(&$checks)
+       {
+               $status = true;
+               $help = "";
+               if ((file_exists('config/local.ini.php') && !is_writable('config/local.ini.php')) ||
+                       (!file_exists('config/local.ini.php') && !is_writable('.'))) {
+
+                       $status = false;
+                       $help = L10n::t('The web installer needs to be able to create a file called "local.ini.php" in the "config" folder of your web server and it is unable to do so.') . EOL;
+                       $help .= L10n::t('This is most often a permission setting, as the web server may not be able to write files in your folder - even if you can.') . EOL;
+                       $help .= L10n::t('At the end of this procedure, we will give you a text to save in a file named local.ini.php in your Friendica "config" folder.') . EOL;
+                       $help .= L10n::t('You can alternatively skip this procedure and perform a manual installation. Please see the file "INSTALL.txt" for instructions.') . EOL;
+               }
+
+               self::addCheck($checks, L10n::t('config/local.ini.php is writable'), $status, false, $help);
+
+       }
+
+       /**
+        * Smarty3 Template Check
+        *
+        * Checks, if the directory of Smarty3 is writable
+        *
+        * @param array $checks The list of all checks (by-ref parameter!)
+        */
+       public static function checkSmarty3(&$checks)
+       {
+               $status = true;
+               $help = "";
+               if (!is_writable('view/smarty3')) {
+
+                       $status = false;
+                       $help = L10n::t('Friendica uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') . EOL;
+                       $help .= L10n::t('In order to store these compiled templates, the web server needs to have write access to the directory view/smarty3/ under the Friendica top level folder.') . EOL;
+                       $help .= L10n::t("Please ensure that the user that your web server runs as \x28e.g. www-data\x29 has write access to this folder.") . EOL;
+                       $help .= L10n::t("Note: as a security measure, you should give the web server write access to view/smarty3/ only--not the template files \x28.tpl\x29 that it contains.") . EOL;
+               }
+
+               self::addCheck($checks, L10n::t('view/smarty3 is writable'), $status, true, $help);
+       }
+
+       /**
+        * ".htaccess" - Check
+        *
+        * Checks, if "url_rewrite" is enabled in the ".htaccess" file
+        *
+        * @param array $checks The list of all checks (by-ref parameter!)
+        */
+       public static function checkHtAccess(&$checks)
+       {
+               $status = true;
+               $help = "";
+               $error_msg = "";
+               if (function_exists('curl_init')) {
+                       $test = Network::fetchUrlFull(System::baseUrl() . "/install/testrewrite");
+
+                       $url = normalise_link(System::baseUrl() . "/install/testrewrite");
+                       if ($test['body'] != "ok") {
+                               $test = Network::fetchUrlFull($url);
+                       }
+
+                       if ($test['body'] != "ok") {
+                               $status = false;
+                               $help = L10n::t('Url rewrite in .htaccess is not working. Check your server configuration.');
+                               $error_msg = [];
+                               $error_msg['head'] = L10n::t('Error message from Curl when fetching');
+                               $error_msg['url'] = $test['redirect_url'];
+                               $error_msg['msg'] = defaults($test, 'error', '');
+                       }
+                       self::addCheck($checks, L10n::t('Url rewrite is working'), $status, true, $help, $error_msg);
+               } else {
+                       // cannot check modrewrite if libcurl is not installed
+                       /// @TODO Maybe issue warning here?
+               }
+       }
+
+       /**
+        * Imagick Check
+        *
+        * Checks, if the imagick module is available
+        *
+        * @param array $checks The list of all checks (by-ref parameter!)
+        */
+       public static function checkImagick(&$checks)
+       {
+               $imagick = false;
+               $gif = false;
+
+               if (class_exists('Imagick')) {
+                       $imagick = true;
+                       $supported = Image::supportedTypes();
+                       if (array_key_exists('image/gif', $supported)) {
+                               $gif = true;
+                       }
+               }
+               if ($imagick == false) {
+                       self::addCheck($checks, L10n::t('ImageMagick PHP extension is not installed'), $imagick, false, "");
+               } else {
+                       self::addCheck($checks, L10n::t('ImageMagick PHP extension is installed'), $imagick, false, "");
+                       if ($imagick) {
+                               self::addCheck($checks, L10n::t('ImageMagick supports GIF'), $gif, false, "");
+                       }
+               }
+       }
+
+       /**
+        * Installs the Database structure
+        *
+        * @return string A possible error
+        */
+       public static function installDatabaseStructure()
+       {
+               $errors = DBStructure::update(false, true, true);
+
+               return $errors;
+       }
+}
index c994755e7a231cd3f54d552a4f7c31f5f79cd83b..d256b9adc1b0f0ba52a6f9f54124d22fe5dab7d7 100644 (file)
@@ -344,6 +344,10 @@ class NotificationsManager extends BaseObject
                                                break;
 
                                        case ACTIVITY_FRIEND:
+                                               if (!isset($it['object'])) {
+                                                       logger('Incomplete data: ' . json_encode($it) . ' - ' . System::callstack(20), LOGGER_DEBUG);
+                                               }
+
                                                $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
                                                $obj = XML::parseString($xmlhead . $it['object']);
                                                $it['fname'] = $obj->title;
index 4e2b63f044bbb2ae30ee374924671bf37c3f040e..88b89cda27ac60189375854ecca2a103439ff4d2 100644 (file)
@@ -65,7 +65,7 @@ class System extends BaseObject
                while ($func = array_pop($trace)) {
                        if (!empty($func['class'])) {
                                // Don't show multiple calls from the "dba" class to show the essential parts of the callstack
-                               if ((($previous['class'] != $func['class']) || ($func['class'] != 'dba')) && ($previous['function'] != 'q')) {
+                               if ((($previous['class'] != $func['class']) || ($func['class'] != 'Friendica\Database\DBA')) && ($previous['function'] != 'q')) {
                                        $classparts = explode("\\", $func['class']);
                                        $callstack[] = array_pop($classparts).'::'.$func['function'];
                                        $previous = $func;
index c0b783c29dccc6e8101b94e080c992a5cfa73083..bf480dad2c769ce0dce42c2f22878958c25536f5 100644 (file)
@@ -372,7 +372,7 @@ class DBA
         * @usage Example: $r = p("SELECT * FROM `item` WHERE `guid` = ?", $guid);
         *
         * Please only use it with complicated queries.
-        * For all regular queries please use dba::select or dba::exists
+        * For all regular queries please use DBA::select or DBA::exists
         *
         * @param string $sql SQL statement
         * @return bool|object statement object or result object
@@ -590,7 +590,7 @@ class DBA
        /**
         * @brief Executes a prepared statement like UPDATE or INSERT that doesn't return data
         *
-        * Please use dba::delete, dba::insert, dba::update, ... instead
+        * Please use DBA::delete, DBA::insert, DBA::update, ... instead
         *
         * @param string $sql SQL statement
         * @return boolean Was the query successfull? False is returned only if an error occurred
@@ -685,7 +685,7 @@ class DBA
        /**
         * Fetches the first row
         *
-        * Please use dba::selectFirst or dba::exists whenever this is possible.
+        * Please use DBA::selectFirst or DBA::exists whenever this is possible.
         *
         * @brief Fetches the first row
         * @param string $sql SQL statement
@@ -1303,7 +1303,7 @@ class DBA
         *
         * $params = array("order" => array("id", "received" => true), "limit" => 10);
         *
-        * $data = dba::select($table, $fields, $condition, $params);
+        * $data = DBA::select($table, $fields, $condition, $params);
         */
        public static function select($table, array $fields = [], array $condition = [], array $params = [])
        {
@@ -1345,7 +1345,7 @@ class DBA
         * or:
         * $condition = ["`uid` = ? AND `network` IN (?, ?)", 1, 'dfrn', 'dspr'];
         *
-        * $count = dba::count($table, $condition);
+        * $count = DBA::count($table, $condition);
         */
        public static function count($table, array $condition = [])
        {
@@ -1399,7 +1399,7 @@ class DBA
                                                /* Workaround for MySQL Bug #64791.
                                                 * Never mix data types inside any IN() condition.
                                                 * In case of mixed types, cast all as string.
-                                                * Logic needs to be consistent with dba::p() data types.
+                                                * Logic needs to be consistent with DBA::p() data types.
                                                 */
                                                $is_int = false;
                                                $is_alpha = false;
@@ -1459,7 +1459,7 @@ class DBA
 
                $limit_string = '';
                if (isset($params['limit']) && is_int($params['limit'])) {
-                       $limit_string = " LIMIT " . $params['limit'];
+                       $limit_string = " LIMIT " . intval($params['limit']);
                }
 
                if (isset($params['limit']) && is_array($params['limit'])) {
@@ -1530,7 +1530,7 @@ class DBA
                        case 'mysqli':
                                // MySQLi offers both a mysqli_stmt and a mysqli_result class.
                                // We should be careful not to assume the object type of $stmt
-                               // because dba::p() has been able to return both types.
+                               // because DBA::p() has been able to return both types.
                                if ($stmt instanceof mysqli_stmt) {
                                        $stmt->free_result();
                                        $ret = $stmt->close();
index f8bfe3f0b8132af619446cfb5e21380ca30628ab..4c41fdc3fedb3042d218ad338bb5999d1602020d 100644 (file)
@@ -364,8 +364,13 @@ class Contact extends BaseObject
         */
        public static function markForArchival(array $contact)
        {
-
-               if (!isset($contact['url'])) {
+               if (!isset($contact['url']) && !empty($contact['id'])) {
+                       $fields = ['id', 'url', 'archive', 'self', 'term-date'];
+                       $contact = DBA::selectFirst('contact', [], ['id' => $contact['id']]);
+                       if (!DBA::isResult($contact)) {
+                               return;
+                       }
+               } elseif (!isset($contact['url'])) {
                        logger('Empty contact: ' . json_encode($contact) . ' - ' . System::callstack(20), LOGGER_DEBUG);
                }
 
@@ -376,10 +381,7 @@ class Contact extends BaseObject
 
                if ($contact['term-date'] <= NULL_DATE) {
                        DBA::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
-
-                       if ($contact['url'] != '') {
-                               DBA::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
-                       }
+                       DBA::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
                } else {
                        /* @todo
                         * We really should send a notification to the owner after 2-3 weeks
@@ -397,10 +399,7 @@ class Contact extends BaseObject
                                 * the whole process over again.
                                 */
                                DBA::update('contact', ['archive' => 1], ['id' => $contact['id']]);
-
-                               if ($contact['url'] != '') {
-                                       DBA::update('contact', ['archive' => 1], ['nurl' => normalise_link($contact['url']), 'self' => false]);
-                               }
+                               DBA::update('contact', ['archive' => 1], ['nurl' => normalise_link($contact['url']), 'self' => false]);
                        }
                }
        }
@@ -423,13 +422,18 @@ class Contact extends BaseObject
                        return;
                }
 
+               if (!isset($contact['url']) && !empty($contact['id'])) {
+                       $fields = ['id', 'url', 'batch'];
+                       $contact = DBA::selectFirst('contact', [], ['id' => $contact['id']]);
+                       if (!DBA::isResult($contact)) {
+                               return;
+                       }
+               }
+
                // It's a miracle. Our dead contact has inexplicably come back to life.
                $fields = ['term-date' => NULL_DATE, 'archive' => false];
                DBA::update('contact', $fields, ['id' => $contact['id']]);
-
-               if (!empty($contact['url'])) {
-                       DBA::update('contact', $fields, ['nurl' => normalise_link($contact['url'])]);
-               }
+               DBA::update('contact', $fields, ['nurl' => normalise_link($contact['url'])]);
 
                if (!empty($contact['batch'])) {
                        $condition = ['batch' => $contact['batch'], 'contact-type' => self::ACCOUNT_TYPE_RELAY];
index b01fc197014ad2ce9684ce4b05d39cc6bd1afc94..71f794118940f2032bdf59fac3e1cb44c2c7043b 100644 (file)
@@ -273,36 +273,25 @@ class Group extends BaseObject
         *
         * @param array $group_ids
         * @param boolean $check_dead
-        * @param boolean $use_gcontact
         * @return array
         */
-       public static function expand($group_ids, $check_dead = false, $use_gcontact = false)
+       public static function expand($group_ids, $check_dead = false)
        {
                if (!is_array($group_ids) || !count($group_ids)) {
                        return [];
                }
 
-               $condition = '`gid` IN (' . substr(str_repeat("?, ", count($group_ids)), 0, -2) . ')';
-               if ($use_gcontact) {
-                       $sql = 'SELECT `gcontact`.`id` AS `contact-id` FROM `group_member`
-                                       INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
-                                       INNER JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl`
-                               WHERE ' . $condition;
-                       $param_arr = array_merge([$sql], $group_ids);
-                       $stmt = call_user_func_array('dba::p', $param_arr);
-               } else {
-                       $condition_array = array_merge([$condition], $group_ids);
-                       $stmt = DBA::select('group_member', ['contact-id'], $condition_array);
-               }
+               $stmt = DBA::select('group_member', ['contact-id'], ['gid' => $group_ids]);
 
                $return = [];
                while($group_member = DBA::fetch($stmt)) {
                        $return[] = $group_member['contact-id'];
                }
 
-               if ($check_dead && !$use_gcontact) {
+               if ($check_dead) {
                        Contact::pruneUnavailable($return);
                }
+
                return $return;
        }
 
index 6e4996de54e54398a1f72bdf457a973364ad15c1..5bbdf7c4e03f675347c1d0a442eea7573e62443e 100644 (file)
@@ -933,7 +933,12 @@ class Probe
                }
 
                $prof_data = [];
-               $prof_data["addr"]         = $data["addr"];
+
+               // The "addr" is not always part of the fetched data
+               if (!empty($data["addr"])) {
+                       $prof_data["addr"] = $data["addr"];
+               }
+
                $prof_data["nick"]         = $data["nick"];
                $prof_data["dfrn-request"] = $data["request"];
                $prof_data["dfrn-confirm"] = $data["confirm"];
index 8decec0d024feeb5833f56dca94fe6363b679898..a7f34b7a6dc8b43496fd6b1c2b3534a98b829fce 100644 (file)
@@ -1050,7 +1050,7 @@ class Diaspora
                        return false;
                }
 
-               $contact = dba::selectFirst('contact', [], ['id' => $cid]);
+               $contact = DBA::selectFirst('contact', [], ['id' => $cid]);
                if (!DBA::isResult($contact)) {
                        // This here shouldn't happen at all
                        logger("Haven't found a contact for user " . $uid . " and handle " . $handle, LOGGER_DEBUG);
@@ -1079,7 +1079,7 @@ class Diaspora
                // It is deactivated by now, due to side effects. See issue https://github.com/friendica/friendica/pull/4033
                // It is not removed by now. Possibly the code is needed?
                //if (!$is_comment && $contact["rel"] == Contact::FOLLOWER && in_array($importer["page-flags"], array(Contact::PAGE_FREELOVE))) {
-               //      dba::update(
+               //      DBA::update(
                //              'contact',
                //              array('rel' => Contact::FRIEND, 'writable' => true),
                //              array('id' => $contact["id"], 'uid' => $contact["uid"])
@@ -1821,10 +1821,10 @@ class Diaspora
                        "to_name" => $importer["username"],
                        "to_email" => $importer["email"],
                        "uid" =>$importer["uid"],
-                       "item" => ["subject" => $subject, "body" => $body],
+                       "item" => ["id" => $conversation["id"], "title" => $subject, "subject" => $subject, "body" => $body],
                        "source_name" => $person["name"],
                        "source_link" => $person["url"],
-                       "source_photo" => $person["thumb"],
+                       "source_photo" => $person["photo"],
                        "verb" => ACTIVITY_POST,
                        "otype" => "mail"]
                );
@@ -3075,7 +3075,7 @@ class Diaspora
                logger("transmit: ".$logid."-".$guid." to ".$dest_url." returns: ".$return_code);
 
                if (!$return_code || (($return_code == 503) && (stristr($a->get_curl_headers(), "retry-after")))) {
-                       if (!$no_queue && ($contact['contact-type'] != Contact::ACCOUNT_TYPE_RELAY)) {
+                       if (!$no_queue && !empty($contact['contact-type']) && ($contact['contact-type'] != Contact::ACCOUNT_TYPE_RELAY)) {
                                logger("queue message");
                                // queue message for redelivery
                                Queue::add($contact["id"], Protocol::DIASPORA, $envelope, $public_batch, $guid);
index e3b640fa777a42045554d5295c9330cbab4c6b12..49ed03dc3ec57c1d50e4931202c4de2a91e8ad1e 100644 (file)
@@ -716,7 +716,7 @@ class Network
                $url = self::stripTrackingQueryParams($url);
 
                if ($depth > 10) {
-                       return($url);
+                       return $url;
                }
 
                $url = trim($url, "'");
@@ -739,16 +739,14 @@ class Network
                $a->save_timestamp($stamp1, "network");
 
                if ($http_code == 0) {
-                       return($url);
+                       return $url;
                }
 
-               if ((($curl_info['http_code'] == "301") || ($curl_info['http_code'] == "302"))
-                       && (($curl_info['redirect_url'] != "") || ($curl_info['location'] != ""))
-               ) {
-                       if ($curl_info['redirect_url'] != "") {
-                               return(self::finalUrl($curl_info['redirect_url'], ++$depth, $fetchbody));
-                       } else {
-                               return(self::finalUrl($curl_info['location'], ++$depth, $fetchbody));
+               if (in_array($http_code, ['301', '302'])) {
+                       if (!empty($curl_info['redirect_url'])) {
+                               return self::finalUrl($curl_info['redirect_url'], ++$depth, $fetchbody);
+                       } elseif (!empty($curl_info['location'])) {
+                               return self::finalUrl($curl_info['location'], ++$depth, $fetchbody);
                        }
                }
 
@@ -759,12 +757,12 @@ class Network
 
                // if the file is too large then exit
                if ($curl_info["download_content_length"] > 1000000) {
-                       return($url);
+                       return $url;
                }
 
                // if it isn't a HTML file then exit
-               if (($curl_info["content_type"] != "") && !strstr(strtolower($curl_info["content_type"]), "html")) {
-                       return($url);
+               if (!empty($curl_info["content_type"]) && !strstr(strtolower($curl_info["content_type"]), "html")) {
+                       return $url;
                }
 
                $stamp1 = microtime(true);
@@ -783,7 +781,7 @@ class Network
                $a->save_timestamp($stamp1, "network");
 
                if (trim($body) == "") {
-                       return($url);
+                       return $url;
                }
 
                // Check for redirect in meta elements
@@ -806,7 +804,7 @@ class Network
                                $pathinfo = explode(";", $path);
                                foreach ($pathinfo as $value) {
                                        if (substr(strtolower($value), 0, 4) == "url=") {
-                                               return(self::finalUrl(substr($value, 4), ++$depth));
+                                               return self::finalUrl(substr($value, 4), ++$depth);
                                        }
                                }
                        }
index c839bced195dc0827bd13cc1a6d54ca986f89fec..ca0da954c010ff08c51f3e1876ae13383b2ba620 100644 (file)
@@ -84,7 +84,7 @@ class DBClean {
                        $r = DBA::p("SELECT `id` FROM `item` WHERE `uid` = 0 AND
                                                NOT EXISTS (SELECT `guid` FROM `item` AS `i` WHERE `item`.`guid` = `i`.`guid` AND `i`.`uid` != 0) AND
                                                `received` < UTC_TIMESTAMP() - INTERVAL ? DAY AND `id` >= ?
-                                       ORDER BY `id` LIMIT ".intval($limit), $days_unclaimed, $last_id);
+                                       ORDER BY `id` LIMIT ?", $days_unclaimed, $last_id, $limit);
                        $count = DBA::numRows($r);
                        if ($count > 0) {
                                logger("found global item orphans: ".$count);
@@ -106,7 +106,7 @@ class DBClean {
                        logger("Deleting items without parents. Last ID: ".$last_id);
                        $r = DBA::p("SELECT `id` FROM `item`
                                        WHERE NOT EXISTS (SELECT `id` FROM `item` AS `i` WHERE `item`.`parent` = `i`.`id`)
-                                       AND `id` >= ? ORDER BY `id` LIMIT ".intval($limit), $last_id);
+                                       AND `id` >= ? ORDER BY `id` LIMIT ?", $last_id, $limit);
                        $count = DBA::numRows($r);
                        if ($count > 0) {
                                logger("found item orphans without parents: ".$count);
@@ -132,7 +132,7 @@ class DBClean {
                        logger("Deleting orphaned data from thread table. Last ID: ".$last_id);
                        $r = DBA::p("SELECT `iid` FROM `thread`
                                        WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `thread`.`iid`) AND `iid` >= ?
-                                       ORDER BY `iid` LIMIT ".intval($limit), $last_id);
+                                       ORDER BY `iid` LIMIT ?", $last_id, $limit);
                        $count = DBA::numRows($r);
                        if ($count > 0) {
                                logger("found thread orphans: ".$count);
@@ -158,7 +158,7 @@ class DBClean {
                        logger("Deleting orphaned data from notify table. Last ID: ".$last_id);
                        $r = DBA::p("SELECT `iid`, `id` FROM `notify`
                                        WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `notify`.`iid`) AND `id` >= ?
-                                       ORDER BY `id` LIMIT ".intval($limit), $last_id);
+                                       ORDER BY `id` LIMIT ?", $last_id, $limit);
                        $count = DBA::numRows($r);
                        if ($count > 0) {
                                logger("found notify orphans: ".$count);
@@ -184,7 +184,7 @@ class DBClean {
                        logger("Deleting orphaned data from notify-threads table. Last ID: ".$last_id);
                        $r = DBA::p("SELECT `id` FROM `notify-threads`
                                        WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `notify-threads`.`master-parent-item`) AND `id` >= ?
-                                       ORDER BY `id` LIMIT ".intval($limit), $last_id);
+                                       ORDER BY `id` LIMIT ?", $last_id, $limit);
                        $count = DBA::numRows($r);
                        if ($count > 0) {
                                logger("found notify-threads orphans: ".$count);
@@ -210,7 +210,7 @@ class DBClean {
                        logger("Deleting orphaned data from sign table. Last ID: ".$last_id);
                        $r = DBA::p("SELECT `iid`, `id` FROM `sign`
                                        WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `sign`.`iid`) AND `id` >= ?
-                                       ORDER BY `id` LIMIT ".intval($limit), $last_id);
+                                       ORDER BY `id` LIMIT ?", $last_id, $limit);
                        $count = DBA::numRows($r);
                        if ($count > 0) {
                                logger("found sign orphans: ".$count);
@@ -236,7 +236,7 @@ class DBClean {
                        logger("Deleting orphaned data from term table. Last ID: ".$last_id);
                        $r = DBA::p("SELECT `oid`, `tid` FROM `term`
                                        WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `term`.`oid`) AND `tid` >= ?
-                                       ORDER BY `tid` LIMIT ".intval($limit), $last_id);
+                                       ORDER BY `tid` LIMIT ?", $last_id, $limit);
                        $count = DBA::numRows($r);
                        if ($count > 0) {
                                logger("found term orphans: ".$count);
@@ -303,7 +303,7 @@ class DBClean {
                        $r = DBA::p("SELECT `id` FROM `item` WHERE `uid` = 0 AND
                                                NOT EXISTS (SELECT `guid` FROM `item` AS `i` WHERE `item`.`guid` = `i`.`guid` AND `i`.`uid` != 0) AND
                                                `received` < UTC_TIMESTAMP() - INTERVAL 90 DAY AND `id` >= ? AND `id` <= ?
-                                       ORDER BY `id` LIMIT ".intval($limit), $last_id, $till_id);
+                                       ORDER BY `id` LIMIT ?", $last_id, $till_id, $limit);
                        $count = DBA::numRows($r);
                        if ($count > 0) {
                                logger("found global item entries from expired threads: ".$count);
@@ -326,7 +326,7 @@ class DBClean {
                        logger("Deleting old conversations. Last created: ".$last_id);
                        $r = DBA::p("SELECT `received`, `item-uri` FROM `conversation`
                                        WHERE `received` < UTC_TIMESTAMP() - INTERVAL ? DAY
-                                       ORDER BY `received` LIMIT ".intval($limit), $days);
+                                       ORDER BY `received` LIMIT ?", $days, $limit);
                        $count = DBA::numRows($r);
                        if ($count > 0) {
                                logger("found old conversations: ".$count);
index bf1c2a64a718806c5626354993c5b900ff975b6e..e6fc8391ffa044d686c59f1b47e84dfcd125b7f7 100644 (file)
@@ -216,7 +216,7 @@ class DiscoverPoCo
                $x = Network::fetchUrl(get_server()."/lsearch?p=1&n=500&search=".urlencode($search));
                $j = json_decode($x);
 
-               if (count($j->results)) {
+               if (!empty($j->results)) {
                        foreach ($j->results as $jj) {
                                // Check if the contact already exists
                                $exists = q("SELECT `id`, `last_contact`, `last_failure`, `updated` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url));
index 1c34b11b9ed87483669acd2faa0c6c62936da49d..131ab078e68f54bcc7ff49acfa92c597c93ba9af 100644 (file)
                 'cursor' : 'pointer'
             });            
 
-            var div = document.createElement("div");                        
+            var div = document.createElement("div");
+            div.setAttribute('class', 'ajaxbutton-wrapper');
             addStyles(div, {
                 'display' : 'block',
                 'position' : 'absolute',
index a25945c689b2f70d78fdcdd03172cec06cbbf85d..2363bd3f060b3d74d1933e3f91173788dd43219e 100644 (file)
         <input type="hidden" name="religion" id="profile-edit-religion" value="{{$religion.2}}" />
         <input type="hidden" id="likes-jot-text" name="likes" value="{{$likes.2}}" />
         <input type="hidden" id="dislikes-jot-text" name="dislikes" value="{{$dislikes.2}}" />
+        <input type="hidden" name="marital" id="profile-edit-marital" value="{{$marital.2}}" />
         <input type="hidden" name="with" id="profile-edit-with" value="{{$with.2}}" />
         <input type="hidden" name="howlong" id="profile-edit-howlong" value="{{$howlong.2}}" />
+        <input type="hidden" name="sexual" id="profile-edit-sexual" value="{{$sexual.2}}" />
         <input type="hidden" id="romance-jot-text" name="romance" value="{{$romance.2}}" />
         <input type="hidden" id="work-jot-text" name="work" value="{{$work.2}}" />
         <input type="hidden" id="education-jot-text" name="education" value="{{$education.2}}" />
index 13ab78477c11b6f2dd891f220d3b2e8480036b6f..8bab362ff92812cf5183b1da737a13aa16c58438 100644 (file)
@@ -15,14 +15,14 @@ function theme_post(App $a)
        }
 
        if (isset($_POST['frio-settings-submit'])) {
-               PConfig::set(local_user(), 'frio', 'scheme',           defaults($_POST, 'frio_scheme'));
-               PConfig::set(local_user(), 'frio', 'nav_bg',           defaults($_POST, 'frio_nav_bg'));
-               PConfig::set(local_user(), 'frio', 'nav_icon_color',   defaults($_POST, 'frio_nav_icon_color'));
-               PConfig::set(local_user(), 'frio', 'link_color',       defaults($_POST, 'frio_link_color'));
-               PConfig::set(local_user(), 'frio', 'background_color', defaults($_POST, 'frio_background_color'));
-               PConfig::set(local_user(), 'frio', 'contentbg_transp', defaults($_POST, 'frio_contentbg_transp'));
-               PConfig::set(local_user(), 'frio', 'background_image', defaults($_POST, 'frio_background_image'));
-               PConfig::set(local_user(), 'frio', 'bg_image_option',  defaults($_POST, 'frio_bg_image_option'));
+               PConfig::set(local_user(), 'frio', 'scheme',           defaults($_POST, 'frio_scheme', ''));
+               PConfig::set(local_user(), 'frio', 'nav_bg',           defaults($_POST, 'frio_nav_bg', ''));
+               PConfig::set(local_user(), 'frio', 'nav_icon_color',   defaults($_POST, 'frio_nav_icon_color', ''));
+               PConfig::set(local_user(), 'frio', 'link_color',       defaults($_POST, 'frio_link_color', ''));
+               PConfig::set(local_user(), 'frio', 'background_color', defaults($_POST, 'frio_background_color', ''));
+               PConfig::set(local_user(), 'frio', 'contentbg_transp', defaults($_POST, 'frio_contentbg_transp', ''));
+               PConfig::set(local_user(), 'frio', 'background_image', defaults($_POST, 'frio_background_image', ''));
+               PConfig::set(local_user(), 'frio', 'bg_image_option',  defaults($_POST, 'frio_bg_image_option', ''));
                PConfig::set(local_user(), 'frio', 'css_modified',     time());
        }
 }
index 61974381797ab18b0f8e7d3b4ec6170c28baea71..b96e53fa1a008a0bcdc0f4b951ae105cdda5600e 100644 (file)
@@ -958,6 +958,10 @@ nav.navbar a, nav.navbar .btn-link {
     color: #fff!important;
     background-color: $menu_background_hover_color !important;
 }
+#photo-edit-link-wrap {
+    color: #555;
+    margin-bottom: 15px;
+}
 .nav-pills.preferences .dropdown .dropdown-toggle,
 .nav-pills.preferences > li > .btn {
     color: #bebebe;
@@ -1418,6 +1422,15 @@ section #jotOpen {
     color: #fff;
 }
 
+.fa.lock:before {
+    font-family: FontAwesome;
+    content: "\f023";
+}
+.fa.unlock:before {
+    font-family: FontAwesome;
+    content: "\f09c";
+}
+
 /* Filebrowser */
 .fbrowser .breadcrumb {
     margin-bottom: 0px;
index 46bb1e5143819306de62c3d93c60a81487bb8928..2b3059eaf1693fd3acf9fe38a13ea6cbfefe0db4 100644 (file)
@@ -12,7 +12,7 @@ $(document).ready(function(){
                // with AjaxUpload.
                $(".fbrowser").remove();
                // Remove the AjaxUpload element.
-               $("[name=userfile]").parent().remove();
+               $(".ajaxbutton-wrapper").remove();
        });
 
        // Clear bs modal on close.
index 28f44504b69527ea3b2655f6c354d9f0f84cc6df..cb683285313c04fb9546d27f49ceefaed0d38e7c 100644 (file)
@@ -44,7 +44,7 @@ if (!isset($minimal)) {
                        $uid = Profile::getThemeUid();
                }
                $scheme = PConfig::get($uid, 'frio', 'scheme', PConfig::get($uid, 'frio', 'schema'));
-               if (($scheme) && ($scheme != '---')) {
+               if ($scheme && ($scheme != '---')) {
                        if (file_exists('view/theme/frio/scheme/' . $scheme . '.php')) {
                                $schemefile = 'view/theme/frio/scheme/' . $scheme . '.php';
                                require_once $schemefile;
@@ -52,7 +52,7 @@ if (!isset($minimal)) {
                } else {
                        $nav_bg = PConfig::get($uid, 'frio', 'nav_bg');
                }
-               if (!$nav_bg) {
+               if (empty($nav_bg)) {
                        $nav_bg = "#708fa0";
                }
                echo '
index d22804dcda1fd79ebd6c304375c1df2f8702bd20..deb2383f4badd624d9d06ef52caa6050fa04339e 100644 (file)
@@ -1,8 +1,13 @@
 
 <div class="wall-item-actions" id="wall-item-like-buttons-{{$id}}">
-       <button type="button" class="btn-link button-likes" id="like-{{$id}}" title="{{$likethis}}" onclick="dolike({{$id}},'like'); return false;" data-toggle="button"><i class="fa fa-thumbs-up" aria-hidden="true"></i>&nbsp;</button>
+       <button type="button" class="btn-link button-likes" id="like-{{$id}}" title="{{$likethis}}" onclick="dolike({{$id}},'like'); return false;" data-toggle="button">
+               <i class="faded-icon page-action fa fa-thumbs-up" aria-hidden="true"></i>
+       </button>
        {{if $nolike}}
-       <button type="button" class="btn-link button-likes" id="dislike-{{$id}}" title="{{$nolike}}" onclick="dolike({{$id}},'dislike'); return false;" data-toggle="button"><i class="fa fa-thumbs-down" aria-hidden="true"></i>&nbsp;</button>
+       <span class="icon-padding"> </span>
+       <button type="button" class="btn-link button-likes" id="dislike-{{$id}}" title="{{$nolike}}" onclick="dolike({{$id}},'dislike'); return false;" data-toggle="button">
+               <i class="faded-icon page-action fa fa-thumbs-down" aria-hidden="true"></i>
+       </button>
        {{/if}}
        <img id="like-rotator-{{$id}}" class="like-rotator" src="images/rotator.gif" alt="{{$wait}}" title="{{$wait}}" style="display: none;" />
 </div>
index ce058f507e994ff38b684d01f86bcab1ed0a04e0..e610926d4cbf3550683f54bcca423c1550821a83 100644 (file)
@@ -4,16 +4,30 @@
 <div id="live-photos"></div>
 
 <div id="photo-view-{{$id}}" class="generic-page-wrapper">
-       <h3><a href="{{$album.0}}">{{$album.1}}</a></h3>
-
-       <div id="photo-edit-link-wrap">
+       <div class="pull-left" id="photo-edit-link-wrap">
+               <a class="page-action faded-icon" id="photo-album-link" href="{{$album.0}}" title="{{$album.1}}" data-toggle="tooltip">
+                       <i class="fa fa-folder-open"></i>&nbsp;{{$album.1}}
+               </a>
+       </div>
+       <div class="pull-right" id="photo-edit-link-wrap">
                {{if $tools}}
-               <a id="photo-edit-link" href="{{$tools.edit.0}}">{{$tools.edit.1}}</a>
-               |
-               <a id="photo-toprofile-link" href="{{$tools.profile.0}}">{{$tools.profile.1}}</a>
+               <span class="icon-padding"> </span>
+               <a id="photo-edit-link" href="{{$tools.edit.0}}" title="{{$tools.edit.1}}" data-toggle="tooltip">
+                       <i class="page-action faded-icon fa fa-pencil"></i>
+               </a>
+               <span class="icon-padding"> </span>
+               <a id="photo-toprofile-link" href="{{$tools.profile.0}}" title="{{$tools.profile.1}}" data-toggle="tooltip">
+                       <i class="page-action faded-icon fa fa-user"></i>
+               </a>
+               {{/if}}
+               {{if $lock}}
+               <span class="icon-padding"> </span>
+               <a id="photo-lock-link" onclick="lockview(event,'photo/{{$id}}');" title="{{$lock}}" data-toggle="tooltip">
+                       <i class="page-action faded-icon fa fa-lock"></i>
+               </a>
                {{/if}}
-               {{if $lock}} | <img src="images/lock_icon.gif" class="lockview" alt="{{$lock}}" onclick="lockview(event,'photo/{{$id}}');" /> {{/if}}
        </div>
+       <div class="clear"></div>
 
        <div id="photo-view-wrapper">
                <div id="photo-photo">
diff --git a/view/theme/frio/templates/photos_default_uploader_box.tpl b/view/theme/frio/templates/photos_default_uploader_box.tpl
new file mode 100644 (file)
index 0000000..2f1f69a
--- /dev/null
@@ -0,0 +1 @@
+<input id="photos-upload-choose" type="file" name="userfile" />
diff --git a/view/theme/frio/templates/photos_default_uploader_submit.tpl b/view/theme/frio/templates/photos_default_uploader_submit.tpl
new file mode 100644 (file)
index 0000000..73d5e50
--- /dev/null
@@ -0,0 +1,2 @@
+
+<button id="photos-upload-submit" class="btn btn-primary">{{$submit|escape:'html'}}</button>
index 1162dc3ac686c2f48179fce565f4af60a3a722bd..f02246c5c785a0c6b6e4f5bfd3c898b2a4140d58 100644 (file)
@@ -5,49 +5,68 @@
        <div id="photos-usage-message">{{$usage}}</div>
 
        <form action="photos/{{$nickname}}" enctype="multipart/form-data" method="post" name="photos-upload-form" id="photos-upload-form">
-               <div id="photos-upload-new-wrapper" >
-                       <div id="photos-upload-newalbum-div">
-                               <label id="photos-upload-newalbum-text" for="photos-upload-newalbum" >{{$newalbum}}</label>
-                       </div>
-                       <input class="form-control" id="photos-upload-newalbum" type="text" name="newalbum" />
-               </div>
-               <div id="photos-upload-new-end"></div>
+               <div id="photos-upload-div" class="form-group">
+                       <label id="photos-upload-text" for="photos-upload-newalbum" >{{$newalbum}}</label>
 
-               <div id="photos-upload-exist-wrapper">
-                       <div id="photos-upload-existing-album-div">
-                               <label id="photos-upload-existing-album-text" for="photos-upload-album-select">{{$existalbumtext}}</label>
-                       </div>
-                       <select class="form-control" id="photos-upload-album-select" name="album" size="4">
-                               {{$albumselect}}
-                       </select>
+                       <input id="photos-upload-album-select" class="form-control" placeholder="{{$existalbumtext}}" list="dl-photo-upload" type="text" name="album" size="4">
+                       <datalist id="dl-photo-upload">{{$albumselect}}</datalist>
                </div>
-               <div id="photos-upload-exist-end"></div>
+               <div id="photos-upload-end" class="clearfix"></div>
 
-               <div id="photos-upload-noshare-div" class="photos-upload-noshare-div pull-left" >
+               <div id="photos-upload-noshare-div" class="photos-upload-noshare-div checkbox pull-left" >
                        <input id="photos-upload-noshare" type="checkbox" name="not_visible" value="1" checked/>
                        <label id="photos-upload-noshare-text" for="photos-upload-noshare" >{{$nosharetext}}</label>
                </div>
 
-               <div id="photos-upload-perms" class="photos-upload-perms pull-right" >
-                       <a href="#photos-upload-permissions-wrapper" id="photos-upload-perms-menu" class="button popupbox" />
-                               <span id="jot-perms-icon" class="icon {{$lockstate}}" ></span>{{$permissions}}
-                       </a>
-               </div>
-               <div id="photos-upload-perms-end" class="clear"></div>
-
-               <div style="display: none;">
-                       <div id="photos-upload-permissions-wrapper">
-                               {{$aclselect}}
+               {{if $alt_uploader}}
+                       <div id="photos-upload-perms" class="pull-right">
+                               <button class="btn btn-default btn-sm" data-toggle="modal" data-target="#aclModal" onclick="return false;">
+                                       <i id="jot-perms-icon" class="fa {{$lockstate}}"></i> {{$permissions}}
+                               </button>
                        </div>
-               </div>
+                       <div class="clearfix"></div>
+
+                       <div id="photos-upload-spacer"></div>
 
-               <div id="photos-upload-spacer"></div>
+                       {{$alt_uploader}}
+               {{/if}}
 
-               {{$alt_uploader}}
 
-               {{$default_upload_box}}
-               {{$default_upload_submit}}
+               {{if $default_upload_submit}}
+                       <div class="clearfix"></div>
 
-               <div class="photos-upload-end" ></div>
+                       <div id="photos-upload-spacer"></div>
+
+                       <div class="photos-upload-wrapper">
+                               <div id="photos-upload-perms" class="btn-group pull-right">
+                                       <button class="btn btn-default" data-toggle="modal" data-target="#aclModal" onclick="return false;">
+                                               <i id="jot-perms-icon" class="fa {{$lockstate}}"></i> 
+                                       </button>
+
+                                       {{$default_upload_submit}}
+                               </div>
+                               {{$default_upload_box}}
+                       </div>
+                       <div class="clearfix"></div>
+               {{/if}}
+
+               <div class="photos-upload-end" class="clearfix"></div>
+
+               {{* The modal for advanced-expire *}}
+               <div id="aclModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
+                       <div class="modal-dialog">
+                               <div class="modal-content">
+                                       <div class="modal-header" class="modal-header">
+                                               <button id="modal-close" type="button" class="close" data-dismiss="modal" aria-hidden="true">
+                                                       &times;
+                                               </button>
+                                               <h4 id="modal-title" class="modal-title">{{$permissions}}</h4>
+                                       </div>
+                                       <div id="photos-upload-permissions-wrapper" class="modal-body">
+                                               {{$aclselect}}
+                                       </div>
+                               </div>
+                       </div>
+               </div>
        </form>
 </div>
index f1280f41c8b6d11589a92ee9dd6a9db9ab6136f3..0951847b0a018321e72d9e2061eb2ef0159f67ec 100644 (file)
         <input type="hidden" name="religion" id="profile-edit-religion" value="{{$religion.2}}" />
         <input type="hidden" id="likes-jot-text" name="likes" value="{{$likes.2}}" />
         <input type="hidden" id="dislikes-jot-text" name="dislikes" value="{{$dislikes.2}}" />
+        <input type="hidden" name="marital" id="profile-edit-marital" value="{{$marital.2}}" />
         <input type="hidden" name="with" id="profile-edit-with" value="{{$with.2}}" />
         <input type="hidden" name="howlong" id="profile-edit-howlong" value="{{$howlong.2}}" />
+        <input type="hidden" name="sexual" id="profile-edit-sexual" value="{{$sexual.2}}" />
         <input type="hidden" id="romance-jot-text" name="romance" value="{{$romance.2}}" />
         <input type="hidden" id="work-jot-text" name="work" value="{{$work.2}}" />
         <input type="hidden" id="education-jot-text" name="education" value="{{$education.2}}" />