]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #4103 from Rudloff/feature/profile_colors
authorHypolite Petovan <mrpetovan@gmail.com>
Tue, 19 Dec 2017 10:35:36 +0000 (05:35 -0500)
committerGitHub <noreply@github.com>
Tue, 19 Dec 2017 10:35:36 +0000 (05:35 -0500)
Add support for profile_*_color in API

49 files changed:
boot.php
composer.json
doc/Developers-Intro.md
doc/api.md
include/api.php
include/session.php
include/text.php
src/App.php
src/Content/ForumManager.php
src/Core/Cache.php
src/Core/Config.php
src/Core/NotificationsManager.php
src/Core/PConfig.php
src/Core/Worker.php
src/Database/DBM.php
src/Database/DBStructure.php
src/Model/Contact.php
src/Model/GContact.php
src/Model/Group.php
src/Model/Photo.php
src/Model/User.php
src/Network/FKOAuthDataStore.php
src/Network/Probe.php
src/Object/Image.php
src/Object/Post.php
src/ParseUrl.php
src/Protocol/DFRN.php
src/Protocol/Diaspora.php
src/Protocol/Feed.php
src/Protocol/OStatus.php
src/Protocol/PortableContact.php
src/Util/ExAuth.php
src/Util/Lock.php
src/Util/Pidfile.php
src/Util/XML.php
src/Worker/Cron.php
src/Worker/CronHooks.php
src/Worker/CronJobs.php
src/Worker/DBClean.php
src/Worker/Delivery.php
src/Worker/Directory.php
src/Worker/DiscoverPoCo.php
src/Worker/Expire.php
src/Worker/Notifier.php
src/Worker/OnePoll.php
src/Worker/Queue.php
src/Worker/RemoveContact.php
vendor/composer/autoload_classmap.php
vendor/composer/autoload_static.php

index 695f9e85c5b3519d83f01ff7080762e50bf5f41d..0dd8e03f254bbb96a02c1422509987c256a5b16a 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -524,6 +524,8 @@ function startup()
  * @brief Retrieve the App structure
  *
  * Useful in functions which require it but don't get it passed to them
+ *
+ * @return App
  */
 function get_app()
 {
@@ -926,14 +928,8 @@ function login($register = false, $hiddens = false)
  */
 function killme()
 {
-       global $session_exists;
-
        if (!get_app()->is_backend()) {
-               if (!$session_exists) {
-                       session_abort();
-               } else {
-                       session_write_close();
-               }
+               session_write_close();
        }
 
        exit();
index d0014aee13f8b876f716f3e45f9945ce2156975b..695d68e7616ae52879747ab1cabecb39a1f35628 100644 (file)
@@ -8,7 +8,7 @@
                "ostatus",\r
                "diaspora"\r
        ],\r
-       "licence": "GNU-Affero",\r
+       "license": "AGPL-3.0+",
        "support": {\r
                "issues": "https://github.com/friendica/friendica/issues"\r
        },\r
index 0707d5ba51cadd9cb293424b45ddb8669e92bd9d..f40186f1da91f6d5cfb2bc00ed7e543ef89e5d82 100644 (file)
@@ -56,7 +56,7 @@ It's a command-line tool that downloads required libraries into the `vendor` fol
 * [Using Composer](help/Composer)
 * [How To Move Classes to `src`](help/Developer-How-To-Move-Classes-to-src)
 
-###Coding standards
+### Coding standards
 
 For the sake of consistency between contribution and general code readability, Friendica follows the widespread [PSR-2 coding standards](http://www.php-fig.org/psr/psr-2/) to the exception of a few rules.
 Here's a few primers if you are new to Friendica or to the PSR-2 coding standards:
@@ -73,7 +73,7 @@ There are a few tools you can use to check or fix your files before you commit.
 
 For documentation we use the standard of *one sentence per line* for the `md` files in the `/doc` and `/doc/$lng` subdirectories.
 
-####Check with [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer)
+#### Check with [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer)
 
 This tool checks your files against a variety of coding standards, including PSR-2, and ouputs a report of all the standard violations.
 You can simply install it through PEAR: `pear install PHP_CodeSniffer`
@@ -84,7 +84,7 @@ Once it is installed and available in your PATH, here's the command to run befor
 The output is a list of all the coding standards violations that you should fix before committing your work.
 Additionally, `phpcs` integrates with a few IDEs (Eclipse, Netbeans, PHPStorm...) so that you don't have to fiddle with the command line.
 
-####Fix with PHP Code Beautifier and Fixer (phpbcf) included in PHP Code Sniffer
+#### Fix with PHP Code Beautifier and Fixer (phpbcf) included in PHP Code Sniffer
 
 If you're getting a massive list of standards violations when running `phpcs`, it can be annoying to fix all the violations by hand.
 Thankfully, PHP Code Sniffer is shipped with an automatic code fixer that can take care of the tedious task for you.
@@ -94,7 +94,7 @@ Here's the command to automatically fix the files you created/modified:
 
 If the command-line tools `diff` and `patch` are unavailabe for you, `phpcbf` can use slightly slower PHP equivalents by using the `--no-patch` argument.
 
-###Code documentation
+### Code documentation
 
 If you are interested in having the documentation of the Friendica code outside of the code files, you can use [Doxygen](http://doxygen.org) to generate it.
 The configuration file for Doxygen is located in the `util` directory of the project sources.
@@ -107,7 +107,7 @@ You can browse these files with any browser.
 
 If you find missing documentation, don't hesitate to contact us and write it down to enhance the code documentation.
 
-###Issues
+### Issues
 
 Have a look at our [issue tracker](https://github.com/friendica/friendica) on github!
 
@@ -117,7 +117,7 @@ Have a look at our [issue tracker](https://github.com/friendica/friendica) on gi
  * There is a *Junior Job* label for issues we think might be a good point to start with.
    But you don't have to limit yourself to those issues.
 
-###Web interface
+### Web interface
 
 The thing many people want most is a better interface, preferably a responsive Friendica theme.
 This is a piece of work!
@@ -129,7 +129,7 @@ Ask us to find out whom to talk to about their experiences.
 * Let us know about your plans [in the dev forum](https://forum.friendi.ca/profile/developers) or the [theme developer forum](https://friendica.eu/profile/ftdevs).
 Do not worry about cross-posting.
 
-###Client software
+### Client software
 
 As Friendica is using a [Twitter/GNU Social compatible API](help/api) any of the clients for those platforms should work with Friendica as well.
 Furthermore there are several client projects, especially for use with Friendica.
index 159bc6991449d2060434a84795b2cd9a945a7ded..9dfd39ae2759d011b1dea66f52f883691c12823e 100644 (file)
@@ -278,6 +278,19 @@ Friendica doesn't allow showing the friends of other users.
 
 * include_entities: "true" shows entities for pictures and links (Default: false)
 
+---
+### blocks/list (*; AUTH)
+
+#### Parameters
+
+* include_entities: "true" shows entities for pictures and links (Default: false)
+* count: Items per page (default: 20).
+* page: page number
+
+#### Unsupported parameters
+* cursor
+* skip_status
+
 ---
 ### statuses/friends_timeline (*; AUTH)
 #### Parameters
@@ -449,6 +462,24 @@ It shows all direct answers (excluding the original post) to a given id.
 
 Friendica doesn't allow showing followers of other users.
 
+---
+### search (*; AUTH)
+#### Parameters
+* q: search query
+* page: the page number (starting at 1) to return
+* rpp: the number of statuses to return per page
+* count: alias for the rpp parameter
+* since_id: returns statuses with ids greater than the given id
+* max_id: returns statuses with ids lower or equal to the given id
+
+#### Unsupported parameters
+* geocode
+* lang
+* locale
+* result_type
+* until
+* include_entities
+
 ---
 ### users/search (*)
 #### Parameters
@@ -941,7 +972,6 @@ The following API calls from the Twitter API are not implemented in either Frien
 * account/update_delivery_device
 * account/update_profile
 * account/update_profile_background_image
-* blocks/list
 * blocks/ids
 * users/lookup
 * users/show
index 7b1fee733c59eac1208c02e856b88d7a972343b5..c4f6b6422bd81aff643bc20d2d8f6302b9686ef0 100644 (file)
@@ -1517,6 +1517,65 @@ function api_users_search($type)
 /// @TODO move to top of file or somewhere better
 api_register_func('api/users/search', 'api_users_search');
 
+/**
+ * Returns statuses that match a specified query.
+ *
+ * @see https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets
+ *
+ * @param string $type Return format: json, xml, atom, rss
+ *
+ * @return array|string
+ * @throws UnauthorizedException
+ * @throws BadRequestException
+ */
+function api_search($type)
+{
+       $data = array();
+
+       if (!x($_REQUEST, 'q')) {
+               throw new BadRequestException("q parameter is required.");
+       }
+
+       if (x($_REQUEST, 'rpp')) {
+               $count = $_REQUEST['rpp'];
+       } elseif (x($_REQUEST, 'count')) {
+               $count = $_REQUEST['count'];
+       } else {
+               $count = 15;
+       }
+
+       $since_id = (x($_REQUEST, 'since_id') ? $_REQUEST['since_id'] : 0);
+       $max_id = (x($_REQUEST, 'max_id') ? $_REQUEST['max_id'] : 0);
+       $page = (x($_REQUEST, 'page') ? $_REQUEST['page'] - 1 : 0);
+
+       $start = $page * $count;
+
+       if ($max_id > 0) {
+               $sql_extra .= ' AND `item`.`id` <= ' . intval($max_id);
+       }
+
+       $r = dba::p(
+               "SELECT ".item_fieldlists()."
+               FROM `item` ".item_joins()."
+               WHERE ".item_condition()." AND (`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`))
+               AND `item`.`body` LIKE CONCAT('%',?,'%')
+               $sql_extra
+               AND `item`.`id`>?
+               ORDER BY `item`.`id` DESC LIMIT ".intval($start)." ,".intval($count)." ",
+               api_user(),
+               $_REQUEST['q'],
+               $since_id
+       );
+
+       $data['status'] = api_format_items(dba::inArray($r), api_get_user(get_app()));
+
+       return api_format_data("statuses", $type, $data);
+}
+
+/// @TODO move to top of file or somewhere better
+api_register_func('api/search/tweets', 'api_search', true);
+api_register_func('api/search', 'api_search', true);
+
 /**
  *
  * http://developer.twitter.com/doc/get/statuses/home_timeline
@@ -3087,12 +3146,19 @@ function api_statuses_f($qtype)
                $sql_extra = " AND false ";
        }
 
+       if ($qtype == 'blocks') {
+               $sql_blocked = 'AND `blocked`';
+       } else {
+               $sql_blocked = 'AND NOT `blocked`';
+       }
+
        $r = q(
                "SELECT `nurl`
                FROM `contact`
                WHERE `uid` = %d
                AND NOT `self`
-               AND (NOT `blocked` OR `pending`)
+               $sql_blocked
+               AND NOT `pending`
                $sql_extra
                ORDER BY `nick`
                LIMIT %d, %d",
@@ -3155,6 +3221,28 @@ function api_statuses_followers($type)
 api_register_func('api/statuses/friends', 'api_statuses_friends', true);
 api_register_func('api/statuses/followers', 'api_statuses_followers', true);
 
+/**
+ * Returns the list of blocked users
+ *
+ * @see https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/get-blocks-list
+ *
+ * @param string $type Either "json" or "xml"
+ *
+ * @return boolean|string|array
+ * @throws UnauthorizedException
+ */
+function api_blocks_list($type)
+{
+       $data =  api_statuses_f('blocks');
+       if ($data === false) {
+               return false;
+       }
+       return api_format_data("users", $type, $data);
+}
+
+/// @TODO move to top of file or somewhere better
+api_register_func('api/blocks/list', 'api_blocks_list', true);
+
 function api_statusnet_config($type)
 {
        $a = get_app();
index 54c17e3754ed6a04ada656c92b0a1a0c93bf1271..66df498fe076d11d54bf86783d547c5aeaccb5db 100644 (file)
@@ -61,10 +61,14 @@ function ref_session_write($id, $data)
 {
        global $session_exists, $session_expire;
 
-       if (!$id || !$data) {
+       if (!$id) {
                return false;
        }
 
+       if (!$data) {
+               return true;
+       }
+
        $expire = time() + $session_expire;
        $default_expire = time() + 300;
 
index 5cc573697dac656f1c97df0e211815dc4a44a24e..cbba8d0c5b501065c3ff451e14706be4ec9704a9 100644 (file)
@@ -1701,7 +1701,7 @@ function array_xmlify($val){
 
 
 /**
- * transorm link href and img src from relative to absolute
+ * transform link href and img src from relative to absolute
  *
  * @param string $text
  * @param string $base base url
index 53abc15f12acf60d6a6a5c334e369f51ff0e1242..c32cf79d98e4363860c3d194719263fac9271158 100644 (file)
@@ -14,6 +14,9 @@ use Detection\MobileDetect;
 
 use Exception;
 
+require_once 'boot.php';
+require_once 'include/dba.php';
+
 /**
  *
  * class: App
@@ -310,10 +313,8 @@ class App {
         *
         * @return string
         */
-       public static function get_basepath() {
-               if (isset($this)) {
-                       $basepath = $this->basepath;
-               }
+       public function get_basepath() {
+               $basepath = $this->basepath;
 
                if (! $basepath) {
                        $basepath = Config::get('system', 'basepath');
@@ -617,7 +618,7 @@ class App {
         * If $name is not defined, return engine defined by theme,
         * or default
         *
-        * @param strin $name Template engine name
+        * @param string $name Template engine name
         * @return object Template Engine instance
         */
        function template_engine($name = '') {
index d619db42b21cd9c774390ab0f797064b864d9843..3a564e328df228e99537728436d676952d03b5ab 100644 (file)
@@ -11,6 +11,8 @@ use Friendica\Core\System;
 use Friendica\Database\DBM;
 use dba;
 
+require_once 'include/dba.php';
+
 /**
  * @brief This class handles methods related to the forum functionality
  */
@@ -158,7 +160,7 @@ class ForumManager
                $contacts = self::getList($uid, $lastitem, false, false);
 
                $total_shown = 0;
-
+               $forumlist = '';
                foreach ($contacts as $contact) {
                        $forumlist .= micropro($contact, false, 'forumlist-profile-advanced');
                        $total_shown ++;
index eb58811e2c9d9e5c3ea9896a74290754d3d2c736..e2673595c1e100e3fb41f2d68cdaab72d1211a49 100644 (file)
@@ -9,6 +9,8 @@ use Friendica\Core\PConfig;
 use Friendica\Database\DBM;
 use dba;
 
+require_once 'include/dba.php';
+
 /**
  * @brief Class for storing data for a short time
  */
@@ -32,7 +34,7 @@ class Cache
                $memcache_host = Config::get('system', 'memcache_host', '127.0.0.1');
                $memcache_port = Config::get('system', 'memcache_port', 11211);
 
-               $memcache = new Memcache;
+               $memcache = new \Memcache;
 
                if (!$memcache->connect($memcache_host, $memcache_port)) {
                        return false;
@@ -105,7 +107,7 @@ class Cache
                }
 
                // Frequently clear cache
-               self::clear($duration);
+               self::clear();
 
                $r = dba::select('cache', array('v'), array('k' => $key), array('limit' => 1));
 
index d3daece159e1863c94357692409e1fef76bb5a65..2515116a9bdef7b01be4bea1eec18b0949047fe5 100644 (file)
@@ -11,6 +11,8 @@ namespace Friendica\Core;
 use Friendica\Database\DBM;
 use dba;
 
+require_once 'include/dba.php';
+
 /**
  * @brief Arbitrary sytem configuration storage
  *
index 9adac10c921b6b98af1c0b7922ba318c2a44609e..9839f7147c975d27db5606232df75f920a9641b5 100644 (file)
@@ -6,11 +6,12 @@
  */
 namespace Friendica\Core;
 
-use Friendica\Core\Pconfig;
+use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 
+require_once 'include/dba.php';
 require_once 'include/html2plain.php';
 require_once 'include/datetime.php';
 require_once 'include/bbcode.php';
@@ -766,7 +767,7 @@ class NotificationsManager
        public function introNotifs($all = false, $start = 0, $limit = 80)
        {
                $ident = 'introductions';
-               $total = $this->introTotal($seen);
+               $total = $this->introTotal($all);
                $notifs = array();
                $sql_extra = "";
 
index 3467032fa2ce6ddb46d71443bb66ce4c3bd020c0..4bc7193a0ab06c1f679778efd64ad741bab26f01 100644 (file)
@@ -7,6 +7,8 @@ namespace Friendica\Core;
 use Friendica\Database\DBM;
 use dba;
 
+require_once 'include/dba.php';
+
 /**
  * @file include/Core/PConfig.php
  * @brief contains the class with methods for the management
@@ -138,7 +140,7 @@ class PConfig
                // manage array value
                $dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
 
-               dba::update('pconfig', array('v' => $dbvalue), array('uid' => $uid, 'cat' => $family, 'k' => $key), true);
+               $ret = dba::update('pconfig', array('v' => $dbvalue), array('uid' => $uid, 'cat' => $family, 'k' => $key), true);
 
                if ($ret) {
                        self::$in_db[$uid][$family][$key] = true;
index 2e7bb483e8a170813cc7e017c3550338334804e5..760b40b1d30eb19adb742d85b8077fe385d5e730 100644 (file)
@@ -13,6 +13,8 @@ use Friendica\Util\Lock;
 
 use dba;
 
+require_once 'include/dba.php';
+
 /**
  * @file src/Core/Worker.php
  *
index 7b52c0a552c4817d3b39e23d9ddb261839f461f0..e59249e1b9b266b66429949930361229e9e7b415 100644 (file)
@@ -6,6 +6,8 @@ namespace Friendica\Database;
 
 use dba;
 
+require_once 'include/dba.php';
+
 /**
  * @brief This class contain functions for the database management
  *
index 7a6c3eaa70487b9c11ea9535761df9e060fd1b2c..c5bd3e99bc59c64d6d37c8a13e94abf7e45ce7bf 100644 (file)
@@ -9,6 +9,8 @@ use Friendica\Database\DBM;
 use dba;
 
 require_once "boot.php";
+require_once 'include/dba.php';
+require_once 'include/enotify.php';
 require_once "include/text.php";
 
 /**
@@ -565,7 +567,7 @@ class DBStructure {
        private static function createIndex($indexname, $fieldnames, $method = "ADD") {
                $method = strtoupper(trim($method));
                if ($method!="" && $method!="ADD") {
-                       throw new Exception("Invalid parameter 'method' in self::createIndex(): '$method'");
+                       throw new \Exception("Invalid parameter 'method' in self::createIndex(): '$method'");
                }
 
                if ($fieldnames[0] == "UNIQUE") {
index 2203b62162372e482e084e5eb0607a4a41b8720f..1b15f1c76d89faafa38bae7187a7184552962ecd 100644 (file)
@@ -20,6 +20,7 @@ use Friendica\Protocol\Salmon;
 use dba;
 
 require_once 'boot.php';
+require_once 'include/dba.php';
 require_once 'include/text.php';
 
 /**
@@ -196,7 +197,7 @@ class Contact extends BaseObject
         * up or some other transient event and that there's a possibility we could recover from it.
         *
         * @param array $contact contact to mark for archival
-        * @return type
+        * @return null
         */
        public static function markForArchival(array $contact)
        {
index 1b846b31716c04600e3576557205febb4a4b2184..6c13c03b1eaa9b0a78d390fd5cd1ed278a57b1a7 100644 (file)
@@ -17,6 +17,7 @@ use dba;
 use Exception;
 
 require_once 'include/datetime.php';
+require_once 'include/dba.php';
 require_once 'include/network.php';
 require_once 'include/html2bbcode.php';
 
@@ -635,7 +636,7 @@ class GContact
        /**
         * @brief Replace alternate OStatus user format with the primary one
         *
-        * @param arr $contact contact array (called by reference)
+        * @param array $contact contact array (called by reference)
         * @return void
         */
        public static function fixAlternateContactAddress(&$contact)
@@ -655,7 +656,7 @@ class GContact
        /**
         * @brief Fetch the gcontact id, add an entry if not existed
         *
-        * @param arr $contact contact array
+        * @param array $contact contact array
         *
         * @return bool|int Returns false if not found, integer if contact was found
         */
@@ -746,7 +747,7 @@ class GContact
        /**
         * @brief Updates the gcontact table from a given array
         *
-        * @param arr $contact contact array
+        * @param array $contact contact array
         *
         * @return bool|int Returns false if not found, integer if contact was found
         */
@@ -907,7 +908,7 @@ class GContact
        /**
         * @brief Updates the gcontact entry from probe
         *
-        * @param str $url profile link
+        * @param string $url profile link
         * @return void
         */
        public static function updateFromProbe($url)
@@ -973,7 +974,7 @@ class GContact
         *
         * If the "Statistics" plugin is enabled (See http://gstools.org/ for details) we query user data with this.
         *
-        * @param str $server Server address
+        * @param string $server Server address
         * @return void
         */
        public static function fetchGsUsers($server)
index 9251bc49ded9c6dba29b23b90cd134b0e74d141d..a23b417cc933dd5ff9004d654f3e1c1c95c20b79 100644 (file)
@@ -11,6 +11,7 @@ use Friendica\Database\DBM;
 use dba;
 
 require_once 'boot.php';
+require_once 'include/dba.php';
 require_once 'include/text.php';
 
 /**
@@ -130,7 +131,7 @@ class Group extends BaseObject
        /**
         * @brief Mark a group as deleted
         *
-        * @param type $gid
+        * @param int $gid
         * @return boolean
         */
        public static function remove($gid) {
@@ -138,8 +139,13 @@ class Group extends BaseObject
                        return false;
                }
 
+               $group = dba::select('group', ['uid'], ['gid' => $gid], ['limit' => 1]);
+               if (!DBM::is_result($group)) {
+                       return false;
+               }
+
                // remove group from default posting lists
-               $user = dba::select('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $uid], ['limit' => 1]);
+               $user = dba::select('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $group['uid']], ['limit' => 1]);
                if (DBM::is_result($user)) {
                        $change = false;
 
@@ -157,7 +163,7 @@ class Group extends BaseObject
                        }
 
                        if ($change) {
-                               dba::update('user', $user, ['uid' => $uid]);
+                               dba::update('user', $user, ['uid' => $group['uid']]);
                        }
                }
 
@@ -175,9 +181,9 @@ class Group extends BaseObject
         *
         * @deprecated Use Group::remove instead
         *
-        * @param type $uid
-        * @param type $name
-        * @return type
+        * @param int $uid
+        * @param string $name
+        * @return bool
         */
        public static function removeByName($uid, $name) {
                $return = false;
index 229f22107717c268a9a60328c1748a92d2a081e2..0fbeb66cbb06c74739eeed1c976adb4d1acab358 100644 (file)
@@ -12,7 +12,9 @@ use Friendica\Database\DBM;
 use Friendica\Object\Image;
 use dba;
 
+require_once 'include/dba.php';
 require_once "include/photos.php";
+
 /**
  * Class to handle photo dabatase table
  */
index d09d670a4bffffb5b85dbcfb560962e1c31145de..f487de7661821b72af445d27b676935d342cf652 100644 (file)
@@ -21,6 +21,7 @@ use Exception;
 
 require_once 'boot.php';
 require_once 'include/crypto.php';
+require_once 'include/dba.php';
 require_once 'include/enotify.php';
 require_once 'include/network.php';
 require_once 'library/openid.php';
@@ -32,6 +33,37 @@ require_once 'include/text.php';
  */
 class User
 {
+       /**
+        * @brief Get owner data by user id
+        *
+        * @param int $uid
+        * @return boolean|array
+        */
+       public static function getOwnerDataById($uid) {
+               $r = dba::fetch_first("SELECT
+                       `contact`.*,
+                       `user`.`prvkey` AS `uprvkey`,
+                       `user`.`timezone`,
+                       `user`.`nickname`,
+                       `user`.`sprvkey`,
+                       `user`.`spubkey`,
+                       `user`.`page-flags`,
+                       `user`.`account-type`,
+                       `user`.`prvnets`
+                       FROM `contact`
+                       INNER JOIN `user`
+                               ON `user`.`uid` = `contact`.`uid`
+                       WHERE `contact`.`uid` = ?
+                       AND `contact`.`self`
+                       LIMIT 1",
+                       $uid
+               );
+               if (!DBM::is_result($r)) {
+                       return false;
+               }
+               return $r;
+       }
+
        /**
         * @brief Returns the default group for a given user and network
         *
@@ -186,7 +218,7 @@ class User
                                $_SESSION['register'] = 1;
                                $_SESSION['openid'] = $openid_url;
 
-                               $openid = new LightOpenID;
+                               $openid = new \LightOpenID;
                                $openid->identity = $openid_url;
                                $openid->returnUrl = System::baseUrl() . '/openid';
                                $openid->required = array('namePerson/friendly', 'contact/email', 'namePerson');
index d7fa14518903b981bb8cbf0f470ee13faf5a8f19..424b6391ee619c11a714c27ebcade1462a9fdc75 100644 (file)
@@ -1,10 +1,12 @@
 <?php
+
 /**
  * @file src/Protocol/FKOAuthDataStore.php
  * OAuth server
  * Based on oauth2-php <http://code.google.com/p/oauth2-php/>
  *
  */
+
 namespace Friendica\Network;
 
 use Friendica\App;
@@ -17,6 +19,8 @@ use OAuthDataStore;
 define('REQUEST_TOKEN_DURATION', 300);
 define('ACCESS_TOKEN_DURATION', 31536000);
 
+require_once 'include/dba.php';
+
 require_once "library/OAuth1.php";
 require_once "library/oauth2-php/lib/OAuth2.inc";
 
@@ -39,13 +43,13 @@ class FKOAuthDataStore extends OAuthDataStore
         */
        public function lookup_consumer($consumer_key)
        {
-               logger(__function__.":".$consumer_key);
-               
+               logger(__function__ . ":" . $consumer_key);
+
                $s = dba::select('clients', array('client_id', 'pw', 'redirect_uri'), array('client_id' => $consumer_key));
-               $r = dba::inArray($r);
+               $r = dba::inArray($s);
 
                if (DBM::is_result($r)) {
-                       return new OAuthConsumer($r[0]['client_id'], $r[0]['pw'], $r[0]['redirect_uri']);
+                       return new \OAuthConsumer($r[0]['client_id'], $r[0]['pw'], $r[0]['redirect_uri']);
                }
 
                return null;
@@ -59,13 +63,13 @@ class FKOAuthDataStore extends OAuthDataStore
         */
        public function lookup_token($consumer, $token_type, $token)
        {
-               logger(__function__.":".$consumer.", ". $token_type.", ".$token);
-               
+               logger(__function__ . ":" . $consumer . ", " . $token_type . ", " . $token);
+
                $s = dba::select('tokens', array('id', 'secret', 'scope', 'expires', 'uid'), array('client_id' => $consumer->key, 'scope' => $token_type, 'id' => $token));
                $r = dba::inArray($s);
 
                if (DBM::is_result($r)) {
-                       $ot=new OAuthToken($r[0]['id'], $r[0]['secret']);
+                       $ot = new \OAuthToken($r[0]['id'], $r[0]['secret']);
                        $ot->scope = $r[0]['scope'];
                        $ot->expires = $r[0]['expires'];
                        $ot->uid = $r[0]['uid'];
@@ -85,9 +89,9 @@ class FKOAuthDataStore extends OAuthDataStore
        public function lookup_nonce($consumer, $token, $nonce, $timestamp)
        {
                $r = dba::select('tokens', ['id', 'secret'], ['client_id' => $consumer->key, 'id' => $nonce, 'expires' => $timestamp], ['limit' => 1]);
-                               
+
                if (DBM::is_result($r)) {
-                       return new OAuthToken($r['id'], $r['secret']);
+                       return new \OAuthToken($r['id'], $r['secret']);
                }
 
                return null;
@@ -100,7 +104,7 @@ class FKOAuthDataStore extends OAuthDataStore
         */
        public function new_request_token($consumer, $callback = null)
        {
-               logger(__function__.":".$consumer.", ". $callback);
+               logger(__function__ . ":" . $consumer . ", " . $callback);
                $key = self::genToken();
                $sec = self::genToken();
 
@@ -117,14 +121,14 @@ class FKOAuthDataStore extends OAuthDataStore
                                'secret' => $sec,
                                'client_id' => $k,
                                'scope' => 'request',
-                               'expires' => UNIX_TIMESTAMP() + REQUEST_TOKEN_DURATION)
+                               'expires' => time() + REQUEST_TOKEN_DURATION)
                );
 
                if (!$r) {
                        return null;
                }
 
-               return new OAuthToken($key, $sec);
+               return new \OAuthToken($key, $sec);
        }
 
        /**
@@ -135,7 +139,7 @@ class FKOAuthDataStore extends OAuthDataStore
         */
        public function new_access_token($token, $consumer, $verifier = null)
        {
-               logger(__function__.":".$token.", ". $consumer.", ". $verifier);
+               logger(__function__ . ":" . $token . ", " . $consumer . ", " . $verifier);
 
                // return a new access token attached to this consumer
                // for the user associated with this token if the request token
@@ -146,9 +150,9 @@ class FKOAuthDataStore extends OAuthDataStore
 
                // get user for this verifier
                $uverifier = Config::get("oauth", $verifier);
-               logger(__function__.":".$verifier.",".$uverifier);
+               logger(__function__ . ":" . $verifier . "," . $uverifier);
 
-               if (is_null($verifier) || ($uverifier!==false)) {
+               if (is_null($verifier) || ($uverifier !== false)) {
                        $key = self::genToken();
                        $sec = self::genToken();
                        $r = dba::insert(
@@ -158,19 +162,17 @@ class FKOAuthDataStore extends OAuthDataStore
                                        'secret' => $sec,
                                        'client_id' => $consumer->key,
                                        'scope' => 'access',
-                                       'expires' => UNIX_TIMESTAMP() + ACCESS_TOKEN_DURATION,
+                                       'expires' => time() + ACCESS_TOKEN_DURATION,
                                        'uid' => $uverifier)
                        );
 
                        if ($r) {
-                               $ret = new OAuthToken($key, $sec);
+                               $ret = new \OAuthToken($key, $sec);
                        }
                }
 
-
                dba::delete('tokens', array('id' => $token->key));
 
-
                if (!is_null($ret) && !is_null($uverifier)) {
                        Config::delete("oauth", $verifier);
                }
index 7955961838f08001d33483296bb42b78fbe869bf..56abbb7fdc3905d8edbeb96b828bd92fd2426c75 100644 (file)
@@ -20,9 +20,10 @@ use Friendica\Protocol\Feed;
 use Friendica\Util\XML;
 
 use dba;
-use DomXPath;
+use DOMXPath;
 use DOMDocument;
 
+require_once 'include/dba.php';
 require_once 'include/network.php';
 require_once "include/crypto.php";
 
index b39945ede691756e757d702278a4b86d0279f53a..7cbc2432d995ecf2f4352b4eb80bcdc3c6d7349d 100644 (file)
@@ -111,7 +111,7 @@ class Image
 
        /**
         * @brief Maps Mime types to Imagick formats
-        * @return arr With with image formats (mime type as key)
+        * @return array With with image formats (mime type as key)
         */
        public static function getFormatsMap()
        {
@@ -142,7 +142,7 @@ class Image
                         * Setup the image to the format it will be saved to
                         */
                        $map = self::getFormatsMap();
-                       $format = $map[$type];
+                       $format = $map[$this->type];
                        $this->image->setFormat($format);
 
                        // Always coalesce, if it is not a multi-frame image it won't hurt anyway
@@ -338,42 +338,7 @@ class Image
                        }
                }
 
-
-               if ($this->isImagick()) {
-                       /*
-                        * If it is not animated, there will be only one iteration here,
-                        * so don't bother checking
-                        */
-                       // Don't forget to go back to the first frame
-                       $this->image->setFirstIterator();
-                       do {
-                               // FIXME - implement horizantal bias for scaling as in followin GD functions
-                               // to allow very tall images to be constrained only horizontally.
-
-                               $this->image->scaleImage($dest_width, $dest_height);
-                       } while ($this->image->nextImage());
-
-                       // These may not be necessary any more
-                       $this->width  = $this->image->getImageWidth();
-                       $this->height = $this->image->getImageHeight();
-
-                       return;
-               }
-
-
-               $dest = imagecreatetruecolor($dest_width, $dest_height);
-               imagealphablending($dest, false);
-               imagesavealpha($dest, true);
-               if ($this->type=='image/png') {
-                       imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
-               }
-               imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
-               if ($this->image) {
-                       imagedestroy($this->image);
-               }
-               $this->image = $dest;
-               $this->width  = imagesx($this->image);
-               $this->height = imagesy($this->image);
+               return $this->scale($dest_width, $dest_height);
        }
 
        /**
@@ -562,23 +527,7 @@ class Image
                        }
                }
 
-               if ($this->isImagick()) {
-                       return $this->scaleDown($dest_width, $dest_height);
-               }
-
-               $dest = imagecreatetruecolor($dest_width, $dest_height);
-               imagealphablending($dest, false);
-               imagesavealpha($dest, true);
-               if ($this->type=='image/png') {
-                       imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
-               }
-               imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
-               if ($this->image) {
-                       imagedestroy($this->image);
-               }
-               $this->image = $dest;
-               $this->width  = imagesx($this->image);
-               $this->height = imagesy($this->image);
+               return $this->scale($dest_width, $dest_height);
        }
 
        /**
@@ -591,27 +540,59 @@ class Image
                        return false;
                }
 
+               return $this->scale($dim, $dim);
+       }
+
+       /**
+        * @brief Scale image to target dimensions
+        *
+        * @param int $dest_width
+        * @param int $dest_height
+        * @return boolean
+        */
+       private function scale($dest_width, $dest_height)
+       {
+               if (!$this->isValid()) {
+                       return false;
+               }
+
                if ($this->isImagick()) {
+                       /*
+                        * If it is not animated, there will be only one iteration here,
+                        * so don't bother checking
+                        */
+                       // Don't forget to go back to the first frame
                        $this->image->setFirstIterator();
                        do {
-                               $this->image->scaleImage($dim, $dim);
+                               // FIXME - implement horizontal bias for scaling as in following GD functions
+                               // to allow very tall images to be constrained only horizontally.
+                               $this->image->scaleImage($dest_width, $dest_height);
                        } while ($this->image->nextImage());
-                       return;
-               }
 
-               $dest = imagecreatetruecolor($dim, $dim);
-               imagealphablending($dest, false);
-               imagesavealpha($dest, true);
-               if ($this->type=='image/png') {
-                       imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
-               }
-               imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dim, $dim, $this->width, $this->height);
-               if ($this->image) {
-                       imagedestroy($this->image);
+                       // These may not be necessary anymore
+                       $this->width  = $this->image->getImageWidth();
+                       $this->height = $this->image->getImageHeight();
+               } else {
+                       $dest = imagecreatetruecolor($dest_width, $dest_height);
+                       imagealphablending($dest, false);
+                       imagesavealpha($dest, true);
+
+                       if ($this->type=='image/png') {
+                               imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
+                       }
+
+                       imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $this->width, $this->height);
+
+                       if ($this->image) {
+                               imagedestroy($this->image);
+                       }
+
+                       $this->image = $dest;
+                       $this->width  = imagesx($this->image);
+                       $this->height = imagesy($this->image);
                }
-               $this->image = $dest;
-               $this->width  = imagesx($this->image);
-               $this->height = imagesy($this->image);
+
+               return true;
        }
 
        /**
index 902435b513a004056bf3d7c0b6c73f710fd3bc08..f3315388735a9210635ae7f534a061737d6d6bef 100644 (file)
@@ -11,6 +11,7 @@ use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use dba;
 
+require_once 'include/dba.php';
 require_once 'include/text.php';
 require_once 'boot.php';
 require_once 'include/conversation.php';
index 35557067d7474ca4d7d85d522c0b1847fc33977a..9e46281ec91a73ec6d159be72dc84068c91aaeb1 100644 (file)
@@ -10,9 +10,10 @@ use Friendica\Object\Image;
 use Friendica\Util\XML;
 
 use dba;
-use DomXPath;
+use DOMXPath;
 use DOMDocument;
 
+require_once 'include/dba.php';
 require_once "include/network.php";
 require_once "include/oembed.php";
 
@@ -24,10 +25,10 @@ class ParseUrl
        /**
         * @brief Search for chached embeddable data of an url otherwise fetch it
         *
-        * @param type $url         The url of the page which should be scraped
-        * @param type $no_guessing If true the parse doens't search for
+        * @param string $url         The url of the page which should be scraped
+        * @param bool $no_guessing If true the parse doens't search for
         *                          preview pictures
-        * @param type $do_oembed   The false option is used by the function fetch_oembed()
+        * @param bool $do_oembed   The false option is used by the function fetch_oembed()
         *                          to avoid endless loops
         *
         * @return array which contains needed data for embedding
@@ -88,12 +89,12 @@ class ParseUrl
         * like \<title\>Awesome Title\</title\> or
         * \<meta name="description" content="An awesome description"\>
         *
-        * @param type $url         The url of the page which should be scraped
-        * @param type $no_guessing If true the parse doens't search for
+        * @param string $url         The url of the page which should be scraped
+        * @param bool $no_guessing If true the parse doens't search for
         *                          preview pictures
-        * @param type $do_oembed   The false option is used by the function fetch_oembed()
+        * @param bool $do_oembed   The false option is used by the function fetch_oembed()
         *                          to avoid endless loops
-        * @param type $count       Internal counter to avoid endless loops
+        * @param int $count       Internal counter to avoid endless loops
         *
         * @return array which contains needed data for embedding
         *    string 'url' => The url of the parsed page
@@ -215,7 +216,7 @@ class ParseUrl
                XML::deleteNode($doc, "ol");
                XML::deleteNode($doc, "ul");
 
-               $xpath = new DomXPath($doc);
+               $xpath = new DOMXPath($doc);
 
                $list = $xpath->query("//meta[@content]");
                foreach ($list as $node) {
index 62ada9620ae902f7214dceaac15a840b593449fa..fd37a810c3d134f8256156f9162e0e81d03bfaff 100644 (file)
@@ -8,7 +8,6 @@
  */
 namespace Friendica\Protocol;
 
-use Friendica\App;
 use Friendica\Core\Config;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
@@ -22,8 +21,10 @@ use Friendica\Util\XML;
 
 use dba;
 use DOMDocument;
-use DomXPath;
+use DOMXPath;
 
+require_once 'boot.php';
+require_once 'include/dba.php';
 require_once "include/enotify.php";
 require_once "include/threads.php";
 require_once "include/items.php";
@@ -1298,7 +1299,7 @@ class DFRN
                                case 2:
                                        // RINO 2 based on php-encryption
                                        try {
-                                               $key = \Crypto::createNewRandomKey();
+                                               $key = \Crypto::CreateNewRandomKey();
                                        } catch (\CryptoTestFailedException $ex) {
                                                logger('Cannot safely create a key');
                                                return -4;
@@ -1307,7 +1308,7 @@ class DFRN
                                                return -5;
                                        }
                                        try {
-                                               $data = \Crypto::encrypt($postvars['data'], $key);
+                                               $data = \Crypto::Encrypt($postvars['data'], $key);
                                        } catch (\CryptoTestFailedException $ex) {
                                                logger('Cannot safely perform encryption');
                                                return -6;
@@ -1442,7 +1443,7 @@ class DFRN
         * @param bool   $onlyfetch Should the data only be fetched or should it update the contact record as well
         * @param string $xml       optional, default empty
         *
-        * @return Returns an array with relevant data of the author
+        * @return array Relevant data of the author
         * @todo Find good type-hints for all parameter
         */
        private static function fetchauthor($xpath, $context, $importer, $element, $onlyfetch, $xml = "")
@@ -1691,7 +1692,7 @@ class DFRN
         *
         * @param object $xpath    XPath object
         * @param object $activity Activity object
-        * @param text   $element  element name
+        * @param string $element  element name
         *
         * @return string XML string
         * @todo Find good type-hints for all parameter
@@ -2499,19 +2500,20 @@ class DFRN
 
                /// @todo Do we really need this check for HTML elements? (It was copied from the old function)
                if ((strpos($item['body'], '<') !== false) && (strpos($item['body'], '>') !== false)) {
+                       $base_url = get_app()->get_baseurl();
                        $item['body'] = reltoabs($item['body'], $base_url);
 
                        $item['body'] = html2bb_video($item['body']);
 
                        $item['body'] = oembed_html2bbcode($item['body']);
 
-                       $config = HTMLPurifier_Config::createDefault();
+                       $config = \HTMLPurifier_Config::createDefault();
                        $config->set('Cache.DefinitionImpl', null);
 
                        // we shouldn't need a whitelist, because the bbcode converter
                        // will strip out any unsupported tags.
 
-                       $purifier = new HTMLPurifier($config);
+                       $purifier = new \HTMLPurifier($config);
                        $item['body'] = $purifier->purify($item['body']);
 
                        $item['body'] = @html2bbcode($item['body']);
@@ -2962,9 +2964,9 @@ class DFRN
        /**
         * @brief Imports a DFRN message
         *
-        * @param text  $xml          The DFRN message
-        * @param array $importer     Record of the importer user mixed with contact of the content
-        * @param bool  $sort_by_date Is used when feeds are polled
+        * @param string $xml          The DFRN message
+        * @param array  $importer     Record of the importer user mixed with contact of the content
+        * @param bool   $sort_by_date Is used when feeds are polled
         * @return integer Import status
         * @todo set proper type-hints
         */
@@ -2977,7 +2979,7 @@ class DFRN
                $doc = new DOMDocument();
                @$doc->loadXML($xml);
 
-               $xpath = new DomXPath($doc);
+               $xpath = new DOMXPath($doc);
                $xpath->registerNamespace("atom", NAMESPACE_ATOM1);
                $xpath->registerNamespace("thr", NAMESPACE_THREAD);
                $xpath->registerNamespace("at", NAMESPACE_TOMB);
@@ -3013,7 +3015,7 @@ class DFRN
 
                // The account type is new since 3.5.1
                if ($xpath->query("/atom:feed/dfrn:account_type")->length > 0) {
-                       $accounttype = intval($xpath->evaluate("/atom:feed/dfrn:account_type/text()", $context)->item(0)->nodeValue);
+                       $accounttype = intval($xpath->evaluate("/atom:feed/dfrn:account_type/text()")->item(0)->nodeValue);
 
                        if ($accounttype != $importer["contact-type"]) {
                                dba::update('contact', array('contact-type' => $accounttype), array('id' => $importer["id"]));
@@ -3022,7 +3024,7 @@ class DFRN
 
                // is it a public forum? Private forums aren't supported with this method
                // This is deprecated since 3.5.1
-               $forum = intval($xpath->evaluate("/atom:feed/dfrn:community/text()", $context)->item(0)->nodeValue);
+               $forum = intval($xpath->evaluate("/atom:feed/dfrn:community/text()")->item(0)->nodeValue);
 
                if ($forum != $importer["forum"]) {
                        $condition = array('`forum` != ? AND `id` = ?', $forum, $importer["id"]);
index 5c6d1a2c0699552936d6540f3b23b14f930284b0..8828324c541feecf6310ba19ae6aa75d5f03d02f 100644 (file)
@@ -27,6 +27,7 @@ use Friendica\Util\XML;
 use dba;
 use SimpleXMLElement;
 
+require_once 'include/dba.php';
 require_once 'include/items.php';
 require_once 'include/bb2diaspora.php';
 require_once 'include/datetime.php';
@@ -664,7 +665,6 @@ class Diaspora
                        } elseif (!in_array($fieldname, array("author_signature", "parent_author_signature", "target_author_signature"))) {
                                if ($signed_data != "") {
                                        $signed_data .= ";";
-                                       $signed_data_parent .= ";";
                                }
 
                                $signed_data .= $entry;
@@ -927,10 +927,12 @@ class Diaspora
        /**
         * @brief Get a contact id for a given handle
         *
+        * @todo Move to Friendica\Model\Contact
+        *
         * @param int    $uid    The user id
         * @param string $handle The handle in the format user@domain.tld
         *
-        * @return The contact id
+        * @return int Contact id
         */
        private static function contactByHandle($uid, $handle)
        {
@@ -1091,7 +1093,7 @@ class Diaspora
                preg_replace_callback(
                        $expression,
                        function ($match) use ($item) {
-                               return self::fetchGuidSub($match, $item);
+                               self::fetchGuidSub($match, $item);
                        },
                        $item["body"]
                );
@@ -1099,7 +1101,7 @@ class Diaspora
                preg_replace_callback(
                        "&\[url=/posts/([^\[\]]*)\](.*)\[\/url\]&Usi",
                        function ($match) use ($item) {
-                               return self::fetchGuidSub($match, $item);
+                               self::fetchGuidSub($match, $item);
                        },
                        $item["body"]
                );
@@ -1112,7 +1114,7 @@ class Diaspora
         * @param string $body        The item body to replace links from
         * @param string $author_link The author link for missing local contact fallback
         *
-        * @return the replaced string
+        * @return string the replaced string
         */
        public static function replacePeopleGuid($body, $author_link)
        {
@@ -2308,16 +2310,18 @@ class Diaspora
                                $A = "[url=".$self[0]["url"]."]".$self[0]["name"]."[/url]";
                                $B = "[url=".$contact["url"]."]".$contact["name"]."[/url]";
                                $BPhoto = "[url=".$contact["url"]."][img]".$contact["thumb"]."[/img][/url]";
-                               $arr["body"] = sprintf(t("%1$s is now friends with %2$s"), $A, $B)."\n\n\n".$Bphoto;
+                               $arr["body"] = sprintf(t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$BPhoto;
 
                                $arr["object"] = self::constructNewFriendObject($contact);
 
                                $arr["last-child"] = 1;
 
-                               $arr["allow_cid"] = $user[0]["allow_cid"];
-                               $arr["allow_gid"] = $user[0]["allow_gid"];
-                               $arr["deny_cid"]  = $user[0]["deny_cid"];
-                               $arr["deny_gid"]  = $user[0]["deny_gid"];
+                               $user = dba::select('user', ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'], ['uid' => $importer["uid"]], ['limit' => 1]);
+
+                               $arr["allow_cid"] = $user["allow_cid"];
+                               $arr["allow_gid"] = $user["allow_gid"];
+                               $arr["deny_cid"]  = $user["deny_cid"];
+                               $arr["deny_gid"]  = $user["deny_gid"];
 
                                $i = item_store($arr);
                                if ($i) {
@@ -3206,7 +3210,7 @@ class Diaspora
                        $return_code = self::transmit($owner, $contact, $envelope, $public_batch, false, $guid);
                }
 
-               logger("guid: ".$item["guid"]." result ".$return_code, LOGGER_DEBUG);
+               logger("guid: ".$guid." result ".$return_code, LOGGER_DEBUG);
 
                return $return_code;
        }
@@ -4047,6 +4051,11 @@ class Diaspora
                        return;
                }
 
+               $owner = User::getOwnerDataById($uid);
+               if (!$owner) {
+                       return;
+               }
+
                if (!$recips) {
                        $recips = q(
                                "SELECT `id`,`name`,`network`,`pubkey`,`notify` FROM `contact` WHERE `network` = '%s'
@@ -4065,7 +4074,7 @@ class Diaspora
 
                foreach ($recips as $recip) {
                        logger("Send updated profile data for user ".$uid." to contact ".$recip["id"], LOGGER_DEBUG);
-                       self::buildAndTransmit($profile, $recip, "profile", $message, false, "", true);
+                       self::buildAndTransmit($owner, $recip, "profile", $message, false, "", true);
                }
        }
 
index c33852a7d5c70a263f1f7f1cdc2b605eb0d8b7eb..b12b5c93293a31fb8081ebd6aff0eed4086df42e 100644 (file)
@@ -10,10 +10,11 @@ use Friendica\Database\DBM;
 use Friendica\Core\System;
 use dba;
 use DOMDocument;
-use DomXPath;
+use DOMXPath;
 
-require_once("include/html2bbcode.php");
-require_once("include/items.php");
+require_once 'include/dba.php';
+require_once 'include/html2bbcode.php';
+require_once 'include/items.php';
 
 /**
  * @brief This class contain functions to import feeds
@@ -31,7 +32,7 @@ class Feed {
         *
         * @return array In simulation mode it returns the header and the first item
         */
-       function import($xml, $importer, &$contact, &$hub, $simulate = false) {
+       public static function import($xml, $importer, &$contact, &$hub, $simulate = false) {
 
                $a = get_app();
 
@@ -55,7 +56,7 @@ class Feed {
 
                $doc = new DOMDocument();
                @$doc->loadXML(trim($xml));
-               $xpath = new DomXPath($doc);
+               $xpath = new DOMXPath($doc);
                $xpath->registerNamespace('atom', NAMESPACE_ATOM1);
                $xpath->registerNamespace('dc', "http://purl.org/dc/elements/1.1/");
                $xpath->registerNamespace('content', "http://purl.org/rss/1.0/modules/content/");
@@ -126,7 +127,7 @@ class Feed {
                                if ($value != "") {
                                        $author["author-nick"] = $value;
                                }
-                               $value = $xpath->evaluate('atom:author/poco:address/poco:formatted/text()', $context)->item(0)->nodeValue;
+                               $value = $xpath->evaluate('atom:author/poco:address/poco:formatted/text()')->item(0)->nodeValue;
                                if ($value != "") {
                                        $author["author-location"] = $value;
                                }
@@ -298,9 +299,6 @@ class Feed {
                        if ($creator != "") {
                                $item["author-name"] = $creator;
                        }
-                       if ($pubDate != "") {
-                               $item["edited"] = $item["created"] = $pubDate;
-                       }
                        $creator = $xpath->query('dc:creator/text()', $entry)->item(0)->nodeValue;
 
                        if ($creator != "") {
index 2a021c89e9a3dac70fdb5cd42d857c1b6725a697..757c525f96b81c1c7a8fe3d264fb69f25325a6ca 100644 (file)
@@ -17,8 +17,9 @@ use Friendica\Util\Lock;
 use Friendica\Util\XML;
 use dba;
 use DOMDocument;
-use DomXPath;
+use DOMXPath;
 
+require_once 'include/dba.php';
 require_once 'include/threads.php';
 require_once 'include/html2bbcode.php';
 require_once 'include/bbcode.php';
@@ -251,7 +252,7 @@ class OStatus
                $doc = new DOMDocument();
                @$doc->loadXML($xml);
 
-               $xpath = new DomXPath($doc);
+               $xpath = new DOMXPath($doc);
                $xpath->registerNamespace('atom', NAMESPACE_ATOM1);
                $xpath->registerNamespace('thr', NAMESPACE_THREAD);
                $xpath->registerNamespace('georss', NAMESPACE_GEORSS);
@@ -329,7 +330,7 @@ class OStatus
                $doc = new DOMDocument();
                @$doc->loadXML($xml);
 
-               $xpath = new DomXPath($doc);
+               $xpath = new DOMXPath($doc);
                $xpath->registerNamespace('atom', NAMESPACE_ATOM1);
                $xpath->registerNamespace('thr', NAMESPACE_THREAD);
                $xpath->registerNamespace('georss', NAMESPACE_GEORSS);
@@ -739,7 +740,7 @@ class OStatus
                        if (!@$doc->loadHTML($conversation_data['body'])) {
                                return;
                        }
-                       $xpath = new DomXPath($doc);
+                       $xpath = new DOMXPath($doc);
 
                        $links = $xpath->query('//link');
                        if ($links) {
@@ -779,7 +780,7 @@ class OStatus
                $doc = new DOMDocument();
                @$doc->loadXML($xml);
 
-               $xpath = new DomXPath($doc);
+               $xpath = new DOMXPath($doc);
                $xpath->registerNamespace('atom', NAMESPACE_ATOM1);
                $xpath->registerNamespace('thr', NAMESPACE_THREAD);
                $xpath->registerNamespace('ostatus', NAMESPACE_OSTATUS);
@@ -929,7 +930,7 @@ class OStatus
                        if (!@$doc->loadHTML($related_data['body'])) {
                                return;
                        }
-                       $xpath = new DomXPath($doc);
+                       $xpath = new DOMXPath($doc);
 
                        $atom_file = '';
 
@@ -1023,8 +1024,7 @@ class OStatus
                $orig_created = $xpath->query('atom:published/text()', $activityobjects)->item(0)->nodeValue;
                $orig_edited = $xpath->query('atom:updated/text()', $activityobjects)->item(0)->nodeValue;
 
-               $orig_contact = $contact;
-               $orig_author = self::fetchAuthor($xpath, $activityobjects, $importer, $orig_contact, false);
+               $orig_author = self::fetchAuthor($xpath, $activityobjects, $importer, $dummy, false);
 
                $item["author-name"] = $orig_author["author-name"];
                $item["author-link"] = $orig_author["author-link"];
index 2b37a99624dab2cd5e5fe897697aefa065b6e9a8..04b16a72db6b341adcbdfedba96726e6af120212 100644 (file)
@@ -17,9 +17,10 @@ use Friendica\Model\Profile;
 use Friendica\Network\Probe;
 use dba;
 use DOMDocument;
-use DomXPath;
+use DOMXPath;
 use Exception;
 
+require_once 'include/dba.php';
 require_once 'include/datetime.php';
 require_once 'include/network.php';
 require_once 'include/html2bbcode.php';
@@ -512,7 +513,7 @@ class PortableContact
                $doc = new DOMDocument();
                @$doc->loadXML($feedret["body"]);
 
-               $xpath = new DomXPath($doc);
+               $xpath = new DOMXPath($doc);
                $xpath->registerNamespace('atom', "http://www.w3.org/2005/Atom");
 
                $entries = $xpath->query('/atom:feed/atom:entry');
@@ -768,7 +769,7 @@ class PortableContact
 
                $doc = new DOMDocument();
                @$doc->loadHTML($body);
-               $xpath = new DomXPath($doc);
+               $xpath = new DOMXPath($doc);
 
                $list = $xpath->query("//meta[@name]");
 
@@ -815,7 +816,7 @@ class PortableContact
                        return false;
                }
 
-               $server["site_name"] = $xpath->evaluate($element."//head/title/text()", $context)->item(0)->nodeValue;
+               $server["site_name"] = $xpath->evaluate("//head/title/text()")->item(0)->nodeValue;
                return $server;
        }
 
index f83901e98974e527041c7af0b1aa169ddcb5752b..054b87aad4d6dafb66447f8c01053d2b35733156 100644 (file)
@@ -40,6 +40,7 @@ use Friendica\Database\DBM;
 use Friendica\Model\User;
 use dba;
 
+require_once 'include/dba.php';
 require_once 'include/dba.php';
 
 class ExAuth
@@ -313,7 +314,7 @@ class ExAuth
                }
 
                $file = $lockpath . DIRECTORY_SEPARATOR . $host;
-               if (Pidfile::isRunningProcess($file)) {
+               if (PidFile::isRunningProcess($file)) {
                        if (PidFile::killProcess($file)) {
                                $this->writeLog(LOG_INFO, 'Old process was successfully killed');
                        } else {
@@ -323,7 +324,7 @@ class ExAuth
                }
 
                // Now it is safe to create the pid file
-               Pidfile::create($file);
+               PidFile::create($file);
        }
 
        /**
index 9c449844597c56620bb90106ce67bd19fe4772c8..87590c295b3d35097cab147ace3b2570429b5dfb 100644 (file)
@@ -14,6 +14,8 @@ use Friendica\Database\DBM;
 use Memcache;
 use dba;
 
+require_once 'include/dba.php';
+
 /**
  * @brief This class contain Functions for preventing parallel execution of functions
  */
@@ -62,7 +64,7 @@ class Lock
                $file = $temp.'/'.$fn_name.'.sem';
 
                if (!file_exists($file)) {
-                       file_put_contents($file, $function);
+                       file_put_contents($file, $fn_name);
                }
 
                return ftok($file, 'f');
index 9d12b0bd25232e15df2589977b691bca0cce34eb..00a67d872e62b90bf0e6d285517c29436748babc 100644 (file)
@@ -7,7 +7,7 @@ namespace Friendica\Util;
 /**
  * @brief Pidfile class
  */
-class Pidfile
+class PidFile
 {
        /**
         * @brief Read the pid from a given pid file
index a3cf758da5871a5c3b4952156eae9a4ce71af99a..70af4cad53d42a963b33a8f1636a4a28ee528c1c 100644 (file)
@@ -4,7 +4,7 @@
  */
 namespace Friendica\Util;
 
-use DomXPath;
+use DOMXPath;
 use SimpleXMLElement;
 
 /**
@@ -176,7 +176,7 @@ class XML
         * @param integer $recursion_depth recursion counter for internal use - default 0
         *                                 internal use, recursion counter
         *
-        * @return array | sring The array from the xml element or the string
+        * @return array | string The array from the xml element or the string
         */
        public static function elementToArray($xml_element, &$recursion_depth = 0)
        {
@@ -292,11 +292,11 @@ class XML
                // Go through the tags.
                $repeated_tag_index = array(); // Multiple tags with same name will be turned into an array
                foreach ($xml_values as $data) {
-                       unset($attributes, $value); // Remove existing values, or there will be trouble
-
-                       // This command will extract these variables into the foreach scope
-                       // tag(string), type(string), level(int), attributes(array).
-                       extract($data); // We could use the array by itself, but this cooler.
+                       $tag        = $data['tag'];
+                       $type       = $data['type'];
+                       $level      = $data['level'];
+                       $attributes = isset($data['attributes']) ? $data['attributes'] : null;
+                       $value      = isset($data['value']) ? $data['value'] : null;
 
                        $result = array();
                        $attributes_data = array();
@@ -407,7 +407,7 @@ class XML
         */
        public static function deleteNode(&$doc, $node)
        {
-               $xpath = new DomXPath($doc);
+               $xpath = new DOMXPath($doc);
                $list = $xpath->query("//".$node);
                foreach ($list as $child) {
                        $child->parentNode->removeChild($child);
index db0d518cc3612bd40d71ada7e492a8aab82ed5b6..6afa61601623c81ae07feb43b2dad782e86e532b 100644 (file)
@@ -9,6 +9,8 @@ use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 use dba;
 
+require_once 'include/dba.php';
+
 Class Cron {
        public static function execute($parameter = '', $generation = 0) {
                global $a;
index 22109931feb75703215573ed36b6c5dd6f94fc26..fed65b2291e757d484dd8a963456a981c1a14eb6 100644 (file)
@@ -18,7 +18,7 @@ Class CronHooks {
                        foreach ($a->hooks["cron"] as $single_hook) {
                                if ($single_hook[1] == $hook) {
                                        logger("Calling cron hook '" . $hook . "'", LOGGER_DEBUG);
-                                       call_single_hook($a, $name, $single_hook, $data);
+                                       call_single_hook($a, $hook, $single_hook);
                                }
                        }
                        return;
index b59f096d7de3fcf8ea0e8aa9f5d9bb8a8c3d6e91..93f1e3a03a33bbab4d566b72f1b4ec80d3c5211e 100644 (file)
@@ -16,6 +16,10 @@ use Friendica\Network\Probe;
 use Friendica\Protocol\PortableContact;
 use dba;
 
+require_once 'include/dba.php';
+require_once 'include/post_update.php';
+require_once 'mod/nodeinfo.php';
+
 class CronJobs
 {
        public static function execute($command = '')
index 45a080400ed095325d6deec4ee71014933375f22..8d1228f018b2dbcc699260203fa3321c2e0bf4f6 100644 (file)
@@ -10,6 +10,8 @@ use Friendica\Core\Config;
 use Friendica\Core\Worker;
 use dba;
 
+require_once 'include/dba.php';
+
 class DBClean {
        public static function execute($stage = 0) {
 
index 9ed9a06c17b8a06987fff2bb2df5dfe9f61f200e..b3d3ecc1409e8c46439708ed40d81ae80170db4d 100644 (file)
@@ -10,6 +10,7 @@ use Friendica\Core\System;
 use Friendica\Core\Config;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
+use Friendica\Model\User;
 use Friendica\Protocol\Diaspora;
 use Friendica\Protocol\DFRN;
 use Friendica\Protocol\Email;
@@ -140,20 +141,11 @@ class Delivery {
                        }
                }
 
-               $r = q("SELECT `contact`.*, `user`.`prvkey` AS `uprvkey`,
-                       `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
-                       `user`.`page-flags`, `user`.`account-type`, `user`.`prvnets`
-                       FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
-                       WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
-                       intval($uid)
-               );
-
-               if (!DBM::is_result($r)) {
+               $owner = User::getOwnerDataById($uid);
+               if (!$owner) {
                        return;
                }
 
-               $owner = $r[0];
-
                $walltowall = (($top_level && ($owner['id'] != $items[0]['contact-id'])) ? true : false);
 
                $public_message = true;
index 8e5383ac0c9b7e807ffe8fb82380fb9203de0eb8..8dafbfaaa5efd0ff10738d4c16176dd4c563b9ff 100644 (file)
@@ -25,7 +25,7 @@ class Directory {
 
                $dir .= "/submit";
 
-               $arr = array('url' => $argv[1]);
+               $arr = array('url' => $url);
 
                call_hooks('globaldir_update', $arr);
 
index b3c03e905054b8c03c1d743fcdb4cd3365045281..b7b7f0a31c79bb192a8a36f6069a16cee17ae86d 100644 (file)
@@ -268,7 +268,7 @@ class DiscoverPoCo {
        /**
         * @brief Search for GNU Social user with gstools.org
         *
-        * @param str $search User name
+        * @param string $search User name
         */
        private static function gsSearchUser($search) {
 
index 61326fa88e552d66e673022ecb1fca70247b2e00..e963d6d3519d43ae6e278ae26de6b0793ac3fe7c 100644 (file)
@@ -11,6 +11,8 @@ use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 use dba;
 
+require_once 'include/dba.php';
+
 class Expire {
        public static function execute($param = '', $hook_name = '') {
                global $a;
@@ -48,7 +50,7 @@ class Expire {
                        foreach ($a->hooks["expire"] as $hook) {
                                if ($hook[1] == $hook_name) {
                                        logger("Calling expire hook '" . $hook[1] . "'", LOGGER_DEBUG);
-                                       call_single_hook($a, $name, $hook, $data);
+                                       call_single_hook($a, $hook_name, $hook, $data);
                                }
                        }
                        return;
index 749478044410a337d18455b44e2154cd2f905de5..e3eb6810a3c418915a0d57e5c5ee3ad038cfd80f 100644 (file)
@@ -15,6 +15,7 @@ use Friendica\Protocol\OStatus;
 use Friendica\Protocol\Salmon;
 use dba;
 
+require_once 'include/dba.php';
 require_once 'include/queue_fn.php';
 require_once 'include/html2plain.php';
 require_once 'include/datetime.php';
index 9024d0d4c9008be47ec9eae5071efe9046febe2a..9cb33c471b0c68cacf4d8ae3d150dfff258161e7 100644 (file)
@@ -12,6 +12,7 @@ use Friendica\Protocol\Email;
 use Friendica\Protocol\PortableContact;
 use dba;
 
+require_once 'include/dba.php';
 require_once 'include/follow.php';
 
 Class OnePoll
@@ -65,7 +66,7 @@ Class OnePoll
 
                // Diaspora users, archived users and followers are only checked if they still exist.
                if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
-                       $last_updated = PortableContact::lastUpdated($contact["url"]);
+                       $last_updated = PortableContact::lastUpdated($contact["url"], true);
                        $updated = datetime_convert();
                        if ($last_updated) {
                                logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
@@ -630,6 +631,7 @@ Class OnePoll
                        dba::update('gcontact', array('last_failure' => $updated), array('nurl' => $contact['nurl']));
                        Contact::markForArchival($contact);
                } else {
+                       $updated = datetime_convert();
                        dba::update('contact', array('last-update' => $updated), array('id' => $contact['id']));
                }
 
index cb00addc9497d823bbdd0f55094f7a924d6bcea6..179e37c0770bc7bd501a0866adc281f21e98b0f8 100644 (file)
@@ -14,6 +14,7 @@ use Friendica\Protocol\PortableContact;
 use Friendica\Protocol\Salmon;
 use dba;
 
+require_once 'include/dba.php';
 require_once 'include/queue_fn.php';
 require_once 'include/datetime.php';
 require_once 'include/items.php';
@@ -54,7 +55,7 @@ class Queue
                         */
                        $r = q("SELECT `id` FROM `queue` WHERE ((`created` > UTC_TIMESTAMP() - INTERVAL 12 HOUR AND `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE) OR (`last` < UTC_TIMESTAMP() - INTERVAL 1 HOUR)) ORDER BY `cid`, `created`");
 
-                       call_hooks('queue_predeliver', $a, $r);
+                       call_hooks('queue_predeliver', $r);
 
                        if (DBM::is_result($r)) {
                                foreach ($r as $q_item) {
@@ -165,7 +166,7 @@ class Queue
 
                        default:
                                $params = array('owner' => $owner, 'contact' => $contact, 'queue' => $q_item, 'result' => false);
-                               call_hooks('queue_deliver', $a, $params);
+                               call_hooks('queue_deliver', $params);
 
                                if ($params['result']) {
                                        remove_queue_item($q_item['id']);
index 811b0295fb460f3bdea67f60cf4375d7ab3fcccd..4098d66bc59648c227fc170b187356c76209b5d7 100644 (file)
@@ -8,6 +8,8 @@ namespace Friendica\Worker;
 use Friendica\Core\Config;
 use dba;
 
+require_once 'include/dba.php';
+
 class RemoveContact {
        public static function execute($id) {
 
index 6404d6a9fe447afeb78359a42082dc6702a1bda6..020533182effef20ff42b1d8823cce7d33ab2085 100644 (file)
@@ -10,7 +10,6 @@ return array(
     'Console_Getopt' => $vendorDir . '/pear-pear.php.net/Console_Getopt/Console/Getopt.php',
     'Detection\\MobileDetect' => $vendorDir . '/mobiledetect/mobiledetectlib/namespaced/Detection/MobileDetect.php',
     'Friendica\\App' => $baseDir . '/src/App.php',
-    'Friendica\\BaseModule' => $baseDir . '/src/BaseModule.php',
     'Friendica\\BaseObject' => $baseDir . '/src/BaseObject.php',
     'Friendica\\Content\\Feature' => $baseDir . '/src/Content/Feature.php',
     'Friendica\\Content\\ForumManager' => $baseDir . '/src/Content/ForumManager.php',
@@ -29,7 +28,6 @@ return array(
     'Friendica\\Model\\Photo' => $baseDir . '/src/Model/Photo.php',
     'Friendica\\Model\\Profile' => $baseDir . '/src/Model/Profile.php',
     'Friendica\\Model\\User' => $baseDir . '/src/Model/User.php',
-    'Friendica\\Module\\Login' => $baseDir . '/src/Module/Login.php',
     'Friendica\\Network\\FKOAuth1' => $baseDir . '/src/Network/FKOAuth1.php',
     'Friendica\\Network\\FKOAuthDataStore' => $baseDir . '/src/Network/FKOAuthDataStore.php',
     'Friendica\\Network\\HTTPException' => $baseDir . '/src/Network/HTTPException.php',
@@ -70,7 +68,7 @@ return array(
     'Friendica\\Util\\ExAuth' => $baseDir . '/src/Util/ExAuth.php',
     'Friendica\\Util\\Lock' => $baseDir . '/src/Util/Lock.php',
     'Friendica\\Util\\Map' => $baseDir . '/src/Util/Map.php',
-    'Friendica\\Util\\Pidfile' => $baseDir . '/src/Util/Pidfile.php',
+    'Friendica\\Util\\PidFile' => $baseDir . '/src/Util/Pidfile.php',
     'Friendica\\Util\\XML' => $baseDir . '/src/Util/XML.php',
     'Friendica\\Worker\\CheckVersion' => $baseDir . '/src/Worker/CheckVersion.php',
     'Friendica\\Worker\\CreateShadowEntry' => $baseDir . '/src/Worker/CreateShadowEntry.php',
index 5d6fae0838fc2026444aea7f6b702ec8e91b75cf..64eb2948aa3f41855db0be34246b3d994a089374 100644 (file)
@@ -63,7 +63,6 @@ class ComposerStaticInitFriendica
         'Console_Getopt' => __DIR__ . '/..' . '/pear-pear.php.net/Console_Getopt/Console/Getopt.php',
         'Detection\\MobileDetect' => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/namespaced/Detection/MobileDetect.php',
         'Friendica\\App' => __DIR__ . '/../..' . '/src/App.php',
-        'Friendica\\BaseModule' => __DIR__ . '/../..' . '/src/BaseModule.php',
         'Friendica\\BaseObject' => __DIR__ . '/../..' . '/src/BaseObject.php',
         'Friendica\\Content\\Feature' => __DIR__ . '/../..' . '/src/Content/Feature.php',
         'Friendica\\Content\\ForumManager' => __DIR__ . '/../..' . '/src/Content/ForumManager.php',
@@ -82,7 +81,6 @@ class ComposerStaticInitFriendica
         'Friendica\\Model\\Photo' => __DIR__ . '/../..' . '/src/Model/Photo.php',
         'Friendica\\Model\\Profile' => __DIR__ . '/../..' . '/src/Model/Profile.php',
         'Friendica\\Model\\User' => __DIR__ . '/../..' . '/src/Model/User.php',
-        'Friendica\\Module\\Login' => __DIR__ . '/../..' . '/src/Module/Login.php',
         'Friendica\\Network\\FKOAuth1' => __DIR__ . '/../..' . '/src/Network/FKOAuth1.php',
         'Friendica\\Network\\FKOAuthDataStore' => __DIR__ . '/../..' . '/src/Network/FKOAuthDataStore.php',
         'Friendica\\Network\\HTTPException' => __DIR__ . '/../..' . '/src/Network/HTTPException.php',
@@ -123,7 +121,7 @@ class ComposerStaticInitFriendica
         'Friendica\\Util\\ExAuth' => __DIR__ . '/../..' . '/src/Util/ExAuth.php',
         'Friendica\\Util\\Lock' => __DIR__ . '/../..' . '/src/Util/Lock.php',
         'Friendica\\Util\\Map' => __DIR__ . '/../..' . '/src/Util/Map.php',
-        'Friendica\\Util\\Pidfile' => __DIR__ . '/../..' . '/src/Util/Pidfile.php',
+        'Friendica\\Util\\PidFile' => __DIR__ . '/../..' . '/src/Util/Pidfile.php',
         'Friendica\\Util\\XML' => __DIR__ . '/../..' . '/src/Util/XML.php',
         'Friendica\\Worker\\CheckVersion' => __DIR__ . '/../..' . '/src/Worker/CheckVersion.php',
         'Friendica\\Worker\\CreateShadowEntry' => __DIR__ . '/../..' . '/src/Worker/CreateShadowEntry.php',