From 15a857e4117a5e1e6e092709b3c07614934b09fb Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 9 Feb 2018 03:49:49 +0000 Subject: [PATCH] Line endings are converted to unix style --- composer.json | 134 ++--- src/BaseModule.php | 120 ++-- src/Content/Text/Markdown.php | 78 +-- src/Content/Widget/TagCloud.php | 324 +++++------ src/Core/Session.php | 114 ++-- src/Core/Session/DatabaseSessionHandler.php | 190 +++--- src/Core/Session/MemcacheSessionHandler.php | 204 +++---- src/Core/Theme.php | 378 ++++++------ src/Database/PostUpdate.php | 546 +++++++++--------- src/Module/Feed.php | 120 ++-- src/Module/Logout.php | 62 +- src/Module/Oembed.php | 106 ++-- src/Network/HTTPException.php | 54 +- .../HTTPException/BadGatewayException.php | 20 +- .../HTTPException/BadRequestException.php | 20 +- .../HTTPException/ConflictException.php | 20 +- .../ExpectationFailedException.php | 20 +- .../HTTPException/ForbiddenException.php | 18 +- .../HTTPException/GatewayTimeoutException.php | 20 +- src/Network/HTTPException/GoneException.php | 20 +- .../HTTPException/ImATeapotException.php | 22 +- .../InternalServerErrorException.php | 20 +- .../HTTPException/LenghtRequiredException.php | 20 +- .../MethodNotAllowedException.php | 20 +- .../HTTPException/NonAcceptableException.php | 20 +- .../HTTPException/NotFoundException.php | 18 +- .../HTTPException/NotImplementedException.php | 20 +- .../PreconditionFailedException.php | 20 +- .../ServiceUnavaiableException.php | 20 +- .../TooManyRequestsException.php | 20 +- .../HTTPException/UnauthorizedException.php | 20 +- .../UnprocessableEntityException.php | 20 +- .../UnsupportedMediaTypeException.php | 20 +- src/Render/FriendicaSmarty.php | 110 ++-- src/Render/ITemplateEngine.php | 30 +- 35 files changed, 1484 insertions(+), 1484 deletions(-) diff --git a/composer.json b/composer.json index 1cf58db55..7bdba4cf0 100644 --- a/composer.json +++ b/composer.json @@ -1,67 +1,67 @@ -{ - "name": "friendica/friendica", - "description": "A decentralized social network part of The Federation", - "type": "project", - "keywords": [ - "social network", - "dfrn", - "ostatus", - "diaspora" - ], - "license": "AGPL-3.0+", - "support": { - "issues": "https://github.com/friendica/friendica/issues" - }, - "require": { - "php": ">5.6", - "ext-xml": "*", - "ezyang/htmlpurifier": "~4.7.0", - "league/html-to-markdown": "~4.4.1", - "lightopenid/lightopenid": "dev-master", - "michelf/php-markdown": "^1.7", - "mobiledetect/mobiledetectlib": "2.8.*", - "paragonie/random_compat": "^2.0", - "pear/Text_LanguageDetect": "1.*", - "pear/Text_Highlighter": "dev-master", - "smarty/smarty": "^3.1", - "fxp/composer-asset-plugin": "~1.3", - "bower-asset/base64": "^1.0", - "bower-asset/Chart-js": "^2.7", - "bower-asset/perfect-scrollbar": "^0.6", - "npm-asset/jquery": "^2.0", - "npm-asset/jquery-colorbox": "^1.6", - "npm-asset/jquery-datetimepicker": "^2.4.0", - "npm-asset/jgrowl": "^1.4", - "npm-asset/fullcalendar": "^3.0.1" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/pear/Text_Highlighter" - } - ], - "autoload": { - "psr-4": { - "Friendica\\": "src/" - }, - "psr-0": { - "": "library/" - } - }, - "config": { - "autoloader-suffix": "Friendica", - "optimize-autoloader": true, - "preferred-install": "dist", - "fxp-asset": { - "installer-paths": { - "npm-asset-library": "vendor/asset", - "bower-asset-library": "vendor/asset" - } - } - }, - "archive": { - "exclude": [ - "log", "cache", "/photo", "/proxy" - ] - } -} +{ + "name": "friendica/friendica", + "description": "A decentralized social network part of The Federation", + "type": "project", + "keywords": [ + "social network", + "dfrn", + "ostatus", + "diaspora" + ], + "license": "AGPL-3.0+", + "support": { + "issues": "https://github.com/friendica/friendica/issues" + }, + "require": { + "php": ">5.6", + "ext-xml": "*", + "ezyang/htmlpurifier": "~4.7.0", + "league/html-to-markdown": "~4.4.1", + "lightopenid/lightopenid": "dev-master", + "michelf/php-markdown": "^1.7", + "mobiledetect/mobiledetectlib": "2.8.*", + "paragonie/random_compat": "^2.0", + "pear/Text_LanguageDetect": "1.*", + "pear/Text_Highlighter": "dev-master", + "smarty/smarty": "^3.1", + "fxp/composer-asset-plugin": "~1.3", + "bower-asset/base64": "^1.0", + "bower-asset/Chart-js": "^2.7", + "bower-asset/perfect-scrollbar": "^0.6", + "npm-asset/jquery": "^2.0", + "npm-asset/jquery-colorbox": "^1.6", + "npm-asset/jquery-datetimepicker": "^2.4.0", + "npm-asset/jgrowl": "^1.4", + "npm-asset/fullcalendar": "^3.0.1" + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/pear/Text_Highlighter" + } + ], + "autoload": { + "psr-4": { + "Friendica\\": "src/" + }, + "psr-0": { + "": "library/" + } + }, + "config": { + "autoloader-suffix": "Friendica", + "optimize-autoloader": true, + "preferred-install": "dist", + "fxp-asset": { + "installer-paths": { + "npm-asset-library": "vendor/asset", + "bower-asset-library": "vendor/asset" + } + } + }, + "archive": { + "exclude": [ + "log", "cache", "/photo", "/proxy" + ] + } +} diff --git a/src/BaseModule.php b/src/BaseModule.php index 08f775554..aad4e6fb0 100644 --- a/src/BaseModule.php +++ b/src/BaseModule.php @@ -1,60 +1,60 @@ - - */ -class Markdown extends BaseObject -{ - /** - * Converts a Markdown string into HTML. The hardwrap parameter maximizes - * compatibility with Diaspora in spite of the Markdown standard. - * - * @brief Converts a Markdown string into HTML - * @param string $text - * @param bool $hardwrap - * @return string - */ - public static function convert($text, $hardwrap = true) { - $stamp1 = microtime(true); - - $MarkdownParser = new MarkdownExtra(); - $MarkdownParser->hard_wrap = $hardwrap; - $html = $MarkdownParser->transform($text); - - self::getApp()->save_timestamp($stamp1, "parser"); - - return $html; - } -} + + */ +class Markdown extends BaseObject +{ + /** + * Converts a Markdown string into HTML. The hardwrap parameter maximizes + * compatibility with Diaspora in spite of the Markdown standard. + * + * @brief Converts a Markdown string into HTML + * @param string $text + * @param bool $hardwrap + * @return string + */ + public static function convert($text, $hardwrap = true) { + $stamp1 = microtime(true); + + $MarkdownParser = new MarkdownExtra(); + $MarkdownParser->hard_wrap = $hardwrap; + $html = $MarkdownParser->transform($text); + + self::getApp()->save_timestamp($stamp1, "parser"); + + return $html; + } +} diff --git a/src/Content/Widget/TagCloud.php b/src/Content/Widget/TagCloud.php index 6d53ca995..19ea3eea0 100644 --- a/src/Content/Widget/TagCloud.php +++ b/src/Content/Widget/TagCloud.php @@ -1,162 +1,162 @@ - $uid, 'self' => true]); - $url = System::removedBaseUrl($contact['url']); - - foreach ($r as $rr) { - $tag['level'] = $rr[2]; - $tag['url'] = $url . '?tag=' . urlencode($rr[0]); - $tag['name'] = $rr[0]; - - $tags[] = $tag; - } - - $tpl = get_markup_template('tagblock_widget.tpl'); - $o = replace_macros($tpl, [ - '$title' => L10n::t('Tags'), - '$tags' => $tags - ]); - } - return $o; - } - - /** - * Get alphabetical sorted array of used tags/terms of an user including - * a weighting by frequency of use. - * - * @brief Get alphabetical sorted array of used tags/terms of an user including - * a weighting by frequency of use. - * @param int $uid The user ID. - * @param int $count Max number of displayed tags/terms. - * @param int $owner_id The contact id of the owner of the tagged items. - * @param string $flags Special item flags. - * @param int $type The tag/term type. - * - * @return arr Alphabetical sorted array of used tags of an user. - */ - private static function tagadelic($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HASHTAG) - { - $item_condition = item_condition(); - $sql_options = item_permissions_sql($uid); - $limit = $count ? sprintf('LIMIT %d', intval($count)) : ''; - - if ($flags) { - if ($flags === 'wall') { - $sql_options .= ' AND `item`.`wall` '; - } - } - - if ($owner_id) { - $sql_options .= ' AND `item`.`owner-id` = ' . intval($owner_id) . ' '; - } - - // Fetch tags - $r = dba::p("SELECT `term`, COUNT(`term`) AS `total` FROM `term` - LEFT JOIN `item` ON `term`.`oid` = `item`.`id` - WHERE `term`.`uid` = ? AND `term`.`type` = ? - AND `term`.`otype` = ? - AND $item_condition $sql_options - GROUP BY `term` ORDER BY `total` DESC $limit", - $uid, - $type, - TERM_OBJ_POST - ); - if (!DBM::is_result($r)) { - return []; - } - - return self::tagCalc($r); - } - - /** - * Calculate weighting of tags according to the frequency of use. - * - * @brief Calculate weighting of tags according to the frequency of use. - * @param array $arr Array of tags/terms with tag/term name and total count of use. - * @return array Alphabetical sorted array of used tags/terms of an user. - */ - private static function tagCalc($arr) - { - $tags = []; - $min = 1e9; - $max = -1e9; - $x = 0; - - if (!$arr) { - return []; - } - - foreach ($arr as $rr) { - $tags[$x][0] = $rr['term']; - $tags[$x][1] = log($rr['total']); - $tags[$x][2] = 0; - $min = min($min, $tags[$x][1]); - $max = max($max, $tags[$x][1]); - $x ++; - } - - usort($tags, 'self::tagsSort'); - $range = max(.01, $max - $min) * 1.0001; - - for ($x = 0; $x < count($tags); $x ++) { - $tags[$x][2] = 1 + floor(9 * ($tags[$x][1] - $min) / $range); - } - - return $tags; - } - - /** - * Compare function to sort tags/terms alphabetically. - * - * @brief Compare function to sort tags/terms alphabetically. - * @param type $a - * @param type $b - * - * @return int - */ - private static function tagsSort($a, $b) - { - if (strtolower($a[0]) == strtolower($b[0])) { - return 0; - } - return ((strtolower($a[0]) < strtolower($b[0])) ? -1 : 1); - } -} + $uid, 'self' => true]); + $url = System::removedBaseUrl($contact['url']); + + foreach ($r as $rr) { + $tag['level'] = $rr[2]; + $tag['url'] = $url . '?tag=' . urlencode($rr[0]); + $tag['name'] = $rr[0]; + + $tags[] = $tag; + } + + $tpl = get_markup_template('tagblock_widget.tpl'); + $o = replace_macros($tpl, [ + '$title' => L10n::t('Tags'), + '$tags' => $tags + ]); + } + return $o; + } + + /** + * Get alphabetical sorted array of used tags/terms of an user including + * a weighting by frequency of use. + * + * @brief Get alphabetical sorted array of used tags/terms of an user including + * a weighting by frequency of use. + * @param int $uid The user ID. + * @param int $count Max number of displayed tags/terms. + * @param int $owner_id The contact id of the owner of the tagged items. + * @param string $flags Special item flags. + * @param int $type The tag/term type. + * + * @return arr Alphabetical sorted array of used tags of an user. + */ + private static function tagadelic($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HASHTAG) + { + $item_condition = item_condition(); + $sql_options = item_permissions_sql($uid); + $limit = $count ? sprintf('LIMIT %d', intval($count)) : ''; + + if ($flags) { + if ($flags === 'wall') { + $sql_options .= ' AND `item`.`wall` '; + } + } + + if ($owner_id) { + $sql_options .= ' AND `item`.`owner-id` = ' . intval($owner_id) . ' '; + } + + // Fetch tags + $r = dba::p("SELECT `term`, COUNT(`term`) AS `total` FROM `term` + LEFT JOIN `item` ON `term`.`oid` = `item`.`id` + WHERE `term`.`uid` = ? AND `term`.`type` = ? + AND `term`.`otype` = ? + AND $item_condition $sql_options + GROUP BY `term` ORDER BY `total` DESC $limit", + $uid, + $type, + TERM_OBJ_POST + ); + if (!DBM::is_result($r)) { + return []; + } + + return self::tagCalc($r); + } + + /** + * Calculate weighting of tags according to the frequency of use. + * + * @brief Calculate weighting of tags according to the frequency of use. + * @param array $arr Array of tags/terms with tag/term name and total count of use. + * @return array Alphabetical sorted array of used tags/terms of an user. + */ + private static function tagCalc($arr) + { + $tags = []; + $min = 1e9; + $max = -1e9; + $x = 0; + + if (!$arr) { + return []; + } + + foreach ($arr as $rr) { + $tags[$x][0] = $rr['term']; + $tags[$x][1] = log($rr['total']); + $tags[$x][2] = 0; + $min = min($min, $tags[$x][1]); + $max = max($max, $tags[$x][1]); + $x ++; + } + + usort($tags, 'self::tagsSort'); + $range = max(.01, $max - $min) * 1.0001; + + for ($x = 0; $x < count($tags); $x ++) { + $tags[$x][2] = 1 + floor(9 * ($tags[$x][1] - $min) / $range); + } + + return $tags; + } + + /** + * Compare function to sort tags/terms alphabetically. + * + * @brief Compare function to sort tags/terms alphabetically. + * @param type $a + * @param type $b + * + * @return int + */ + private static function tagsSort($a, $b) + { + if (strtolower($a[0]) == strtolower($b[0])) { + return 0; + } + return ((strtolower($a[0]) < strtolower($b[0])) ? -1 : 1); + } +} diff --git a/src/Core/Session.php b/src/Core/Session.php index b5c09f745..20d1e9ef7 100644 --- a/src/Core/Session.php +++ b/src/Core/Session.php @@ -1,57 +1,57 @@ - - */ -class Session -{ - public static $exists = false; - public static $expire = 180000; - - public static function init() - { - ini_set('session.gc_probability', 50); - ini_set('session.use_only_cookies', 1); - ini_set('session.cookie_httponly', 1); - - if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) { - ini_set('session.cookie_secure', 1); - } - - if (!Config::get('system', 'disable_database_session')) { - $memcache = Cache::memcache(); - if (is_object($memcache)) { - $SessionHandler = new MemcacheSessionHandler($memcache); - } else { - $SessionHandler = new DatabaseSessionHandler(); - } - - session_set_save_handler($SessionHandler); - } - } - - public static function exists($name) - { - return isset($_SESSION[$name]); - } - - public static function get($name) - { - return defaults($_SESSION, $name, null); - } - - public static function set($name, $value) - { - $_SESSION[$name] = $value; - } -} + + */ +class Session +{ + public static $exists = false; + public static $expire = 180000; + + public static function init() + { + ini_set('session.gc_probability', 50); + ini_set('session.use_only_cookies', 1); + ini_set('session.cookie_httponly', 1); + + if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) { + ini_set('session.cookie_secure', 1); + } + + if (!Config::get('system', 'disable_database_session')) { + $memcache = Cache::memcache(); + if (is_object($memcache)) { + $SessionHandler = new MemcacheSessionHandler($memcache); + } else { + $SessionHandler = new DatabaseSessionHandler(); + } + + session_set_save_handler($SessionHandler); + } + } + + public static function exists($name) + { + return isset($_SESSION[$name]); + } + + public static function get($name) + { + return defaults($_SESSION, $name, null); + } + + public static function set($name, $value) + { + $_SESSION[$name] = $value; + } +} diff --git a/src/Core/Session/DatabaseSessionHandler.php b/src/Core/Session/DatabaseSessionHandler.php index d017e2edd..f69531a88 100644 --- a/src/Core/Session/DatabaseSessionHandler.php +++ b/src/Core/Session/DatabaseSessionHandler.php @@ -1,95 +1,95 @@ - - */ -class DatabaseSessionHandler extends BaseObject implements SessionHandlerInterface -{ - public function open($save_path, $session_name) - { - return true; - } - - public function read($session_id) - { - if (!x($session_id)) { - return ''; - } - - $session = dba::selectFirst('session', ['data'], ['sid' => $session_id]); - if (DBM::is_result($session)) { - Session::$exists = true; - return $session['data']; - } - logger("no data for session $session_id", LOGGER_TRACE); - - return ''; - } - - /** - * @brief Standard PHP session write callback - * - * This callback updates the DB-stored session data and/or the expiration depending - * on the case. Uses the Session::expire global for existing session, 5 minutes - * for newly created session. - * - * @param string $session_id Session ID with format: [a-z0-9]{26} - * @param string $session_data Serialized session data - * @return boolean Returns false if parameters are missing, true otherwise - */ - public function write($session_id, $session_data) - { - if (!$session_id) { - return false; - } - - if (!$session_data) { - return true; - } - - $expire = time() + Session::$expire; - $default_expire = time() + 300; - - if (Session::$exists) { - $fields = ['data' => $session_data, 'expire' => $expire]; - $condition = ["`sid` = ? AND (`data` != ? OR `expire` != ?)", $session_id, $session_data, $expire]; - dba::update('session', $fields, $condition); - } else { - $fields = ['sid' => $session_id, 'expire' => $default_expire, 'data' => $session_data]; - dba::insert('session', $fields); - } - - return true; - } - - public function close() - { - return true; - } - - public function destroy($id) - { - dba::delete('session', ['sid' => $id]); - return true; - } - - public function gc($maxlifetime) - { - dba::delete('session', ["`expire` < ?", time()]); - return true; - } -} + + */ +class DatabaseSessionHandler extends BaseObject implements SessionHandlerInterface +{ + public function open($save_path, $session_name) + { + return true; + } + + public function read($session_id) + { + if (!x($session_id)) { + return ''; + } + + $session = dba::selectFirst('session', ['data'], ['sid' => $session_id]); + if (DBM::is_result($session)) { + Session::$exists = true; + return $session['data']; + } + logger("no data for session $session_id", LOGGER_TRACE); + + return ''; + } + + /** + * @brief Standard PHP session write callback + * + * This callback updates the DB-stored session data and/or the expiration depending + * on the case. Uses the Session::expire global for existing session, 5 minutes + * for newly created session. + * + * @param string $session_id Session ID with format: [a-z0-9]{26} + * @param string $session_data Serialized session data + * @return boolean Returns false if parameters are missing, true otherwise + */ + public function write($session_id, $session_data) + { + if (!$session_id) { + return false; + } + + if (!$session_data) { + return true; + } + + $expire = time() + Session::$expire; + $default_expire = time() + 300; + + if (Session::$exists) { + $fields = ['data' => $session_data, 'expire' => $expire]; + $condition = ["`sid` = ? AND (`data` != ? OR `expire` != ?)", $session_id, $session_data, $expire]; + dba::update('session', $fields, $condition); + } else { + $fields = ['sid' => $session_id, 'expire' => $default_expire, 'data' => $session_data]; + dba::insert('session', $fields); + } + + return true; + } + + public function close() + { + return true; + } + + public function destroy($id) + { + dba::delete('session', ['sid' => $id]); + return true; + } + + public function gc($maxlifetime) + { + dba::delete('session', ["`expire` < ?", time()]); + return true; + } +} diff --git a/src/Core/Session/MemcacheSessionHandler.php b/src/Core/Session/MemcacheSessionHandler.php index dce206e64..0bc5e8bfe 100644 --- a/src/Core/Session/MemcacheSessionHandler.php +++ b/src/Core/Session/MemcacheSessionHandler.php @@ -1,102 +1,102 @@ - - */ -class MemcacheSessionHandler extends BaseObject implements SessionHandlerInterface -{ - /** - * @var Memcache - */ - private $memcache = null; - - /** - * - * @param Memcache $memcache - */ - public function __construct(Memcache $memcache) - { - $this->memcache = $memcache; - } - - public function open($save_path, $session_name) - { - return true; - } - - public function read($session_id) - { - if (!x($session_id)) { - return ''; - } - - $data = $this->memcache->get(self::getApp()->get_hostname() . ":session:" . $session_id); - if (!is_bool($data)) { - Session::$exists = true; - return $data; - } - logger("no data for session $session_id", LOGGER_TRACE); - return ''; - } - - /** - * @brief Standard PHP session write callback - * - * This callback updates the stored session data and/or the expiration depending - * on the case. Uses the Session::expire for existing session, 5 minutes - * for newly created session. - * - * @param string $session_id Session ID with format: [a-z0-9]{26} - * @param string $session_data Serialized session data - * @return boolean Returns false if parameters are missing, true otherwise - */ - public function write($session_id, $session_data) - { - if (!$session_id) { - return false; - } - - if (!$session_data) { - return true; - } - - $expire = time() + Session::$expire; - - $this->memcache->set( - self::getApp()->get_hostname() . ":session:" . $session_id, - $session_data, - MEMCACHE_COMPRESSED, - $expire - ); - - return true; - } - - public function close() - { - return true; - } - - public function destroy($id) - { - $this->memcache->delete(self::getApp()->get_hostname() . ":session:" . $id); - return true; - } - - public function gc($maxlifetime) - { - return true; - } -} + + */ +class MemcacheSessionHandler extends BaseObject implements SessionHandlerInterface +{ + /** + * @var Memcache + */ + private $memcache = null; + + /** + * + * @param Memcache $memcache + */ + public function __construct(Memcache $memcache) + { + $this->memcache = $memcache; + } + + public function open($save_path, $session_name) + { + return true; + } + + public function read($session_id) + { + if (!x($session_id)) { + return ''; + } + + $data = $this->memcache->get(self::getApp()->get_hostname() . ":session:" . $session_id); + if (!is_bool($data)) { + Session::$exists = true; + return $data; + } + logger("no data for session $session_id", LOGGER_TRACE); + return ''; + } + + /** + * @brief Standard PHP session write callback + * + * This callback updates the stored session data and/or the expiration depending + * on the case. Uses the Session::expire for existing session, 5 minutes + * for newly created session. + * + * @param string $session_id Session ID with format: [a-z0-9]{26} + * @param string $session_data Serialized session data + * @return boolean Returns false if parameters are missing, true otherwise + */ + public function write($session_id, $session_data) + { + if (!$session_id) { + return false; + } + + if (!$session_data) { + return true; + } + + $expire = time() + Session::$expire; + + $this->memcache->set( + self::getApp()->get_hostname() . ":session:" . $session_id, + $session_data, + MEMCACHE_COMPRESSED, + $expire + ); + + return true; + } + + public function close() + { + return true; + } + + public function destroy($id) + { + $this->memcache->delete(self::getApp()->get_hostname() . ":session:" . $id); + return true; + } + + public function gc($maxlifetime) + { + return true; + } +} diff --git a/src/Core/Theme.php b/src/Core/Theme.php index 9e7c63298..9133eae18 100644 --- a/src/Core/Theme.php +++ b/src/Core/Theme.php @@ -1,189 +1,189 @@ - - * * Maintainer: Jane - * * - * \endcode - * @param string $theme the name of the theme - * @return array - */ - - public static function getInfo($theme) - { - $info=[ - 'name' => $theme, - 'description' => "", - 'author' => [], - 'maintainer' => [], - 'version' => "", - 'credits' => "", - 'experimental' => false, - 'unsupported' => false - ]; - - if (file_exists("view/theme/$theme/experimental")) - $info['experimental'] = true; - if (file_exists("view/theme/$theme/unsupported")) - $info['unsupported'] = true; - - if (!is_file("view/theme/$theme/theme.php")) return $info; - - $a = get_app(); - $stamp1 = microtime(true); - $f = file_get_contents("view/theme/$theme/theme.php"); - $a->save_timestamp($stamp1, "file"); - - $r = preg_match("|/\*.*\*/|msU", $f, $m); - - if ($r) { - $ll = explode("\n", $m[0]); - foreach ( $ll as $l ) { - $l = trim($l,"\t\n\r */"); - if ($l != "") { - list($k, $v) = array_map("trim", explode(":", $l, 2)); - $k= strtolower($k); - if ($k == "author") { - - $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m); - if ($r) { - $info['author'][] = ['name'=>$m[1], 'link'=>$m[2]]; - } else { - $info['author'][] = ['name'=>$v]; - } - } elseif ($k == "maintainer") { - $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m); - if ($r) { - $info['maintainer'][] = ['name'=>$m[1], 'link'=>$m[2]]; - } else { - $info['maintainer'][] = ['name'=>$v]; - } - } else { - if (array_key_exists($k, $info)) { - $info[$k] = $v; - } - } - } - } - } - return $info; - } - - /** - * @brief Returns the theme's screenshot. - * - * The screenshot is expected as view/theme/$theme/screenshot.[png|jpg]. - * - * @param sring $theme The name of the theme - * @return string - */ - public static function getScreenshot($theme) - { - $exts = ['.png','.jpg']; - foreach ($exts as $ext) { - if (file_exists('view/theme/' . $theme . '/screenshot' . $ext)) { - return(System::baseUrl() . '/view/theme/' . $theme . '/screenshot' . $ext); - } - } - return(System::baseUrl() . '/images/blank.png'); - } - - // install and uninstall theme - public static function uninstall($theme) - { - logger("Addons: uninstalling theme " . $theme); - - include_once("view/theme/$theme/theme.php"); - if (function_exists("{$theme}_uninstall")) { - $func = "{$theme}_uninstall"; - $func(); - } - } - - public static function install($theme) - { - // silently fail if theme was removed - - if (! file_exists("view/theme/$theme/theme.php")) { - return false; - } - - logger("Addons: installing theme $theme"); - - include_once("view/theme/$theme/theme.php"); - - if (function_exists("{$theme}_install")) { - $func = "{$theme}_install"; - $func(); - return true; - } else { - logger("Addons: FAILED installing theme $theme"); - return false; - } - - } - - /** - * @brief Get the full path to relevant theme files by filename - * - * This function search in the theme directory (and if not present in global theme directory) - * if there is a directory with the file extension and for a file with the given - * filename. - * - * @param string $file Filename - * @param string $root Full root path - * @return string Path to the file or empty string if the file isn't found - */ - public static function getPathForFile($file, $root = '') - { - $file = basename($file); - - // Make sure $root ends with a slash / if it's not blank - if ($root !== '' && $root[strlen($root)-1] !== '/') { - $root = $root . '/'; - } - $theme_info = get_app()->theme_info; - if (is_array($theme_info) && array_key_exists('extends',$theme_info)) { - $parent = $theme_info['extends']; - } else { - $parent = 'NOPATH'; - } - $theme = current_theme(); - $thname = $theme; - $ext = substr($file,strrpos($file,'.')+1); - $paths = [ - "{$root}view/theme/$thname/$ext/$file", - "{$root}view/theme/$parent/$ext/$file", - "{$root}view/$ext/$file", - ]; - foreach ($paths as $p) { - // strpos() is faster than strstr when checking if one string is in another (http://php.net/manual/en/function.strstr.php) - if (strpos($p,'NOPATH') !== false) { - continue; - } elseif (file_exists($p)) { - return $p; - } - } - return ''; - } -} + + * * Maintainer: Jane + * * + * \endcode + * @param string $theme the name of the theme + * @return array + */ + + public static function getInfo($theme) + { + $info=[ + 'name' => $theme, + 'description' => "", + 'author' => [], + 'maintainer' => [], + 'version' => "", + 'credits' => "", + 'experimental' => false, + 'unsupported' => false + ]; + + if (file_exists("view/theme/$theme/experimental")) + $info['experimental'] = true; + if (file_exists("view/theme/$theme/unsupported")) + $info['unsupported'] = true; + + if (!is_file("view/theme/$theme/theme.php")) return $info; + + $a = get_app(); + $stamp1 = microtime(true); + $f = file_get_contents("view/theme/$theme/theme.php"); + $a->save_timestamp($stamp1, "file"); + + $r = preg_match("|/\*.*\*/|msU", $f, $m); + + if ($r) { + $ll = explode("\n", $m[0]); + foreach ( $ll as $l ) { + $l = trim($l,"\t\n\r */"); + if ($l != "") { + list($k, $v) = array_map("trim", explode(":", $l, 2)); + $k= strtolower($k); + if ($k == "author") { + + $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m); + if ($r) { + $info['author'][] = ['name'=>$m[1], 'link'=>$m[2]]; + } else { + $info['author'][] = ['name'=>$v]; + } + } elseif ($k == "maintainer") { + $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m); + if ($r) { + $info['maintainer'][] = ['name'=>$m[1], 'link'=>$m[2]]; + } else { + $info['maintainer'][] = ['name'=>$v]; + } + } else { + if (array_key_exists($k, $info)) { + $info[$k] = $v; + } + } + } + } + } + return $info; + } + + /** + * @brief Returns the theme's screenshot. + * + * The screenshot is expected as view/theme/$theme/screenshot.[png|jpg]. + * + * @param sring $theme The name of the theme + * @return string + */ + public static function getScreenshot($theme) + { + $exts = ['.png','.jpg']; + foreach ($exts as $ext) { + if (file_exists('view/theme/' . $theme . '/screenshot' . $ext)) { + return(System::baseUrl() . '/view/theme/' . $theme . '/screenshot' . $ext); + } + } + return(System::baseUrl() . '/images/blank.png'); + } + + // install and uninstall theme + public static function uninstall($theme) + { + logger("Addons: uninstalling theme " . $theme); + + include_once("view/theme/$theme/theme.php"); + if (function_exists("{$theme}_uninstall")) { + $func = "{$theme}_uninstall"; + $func(); + } + } + + public static function install($theme) + { + // silently fail if theme was removed + + if (! file_exists("view/theme/$theme/theme.php")) { + return false; + } + + logger("Addons: installing theme $theme"); + + include_once("view/theme/$theme/theme.php"); + + if (function_exists("{$theme}_install")) { + $func = "{$theme}_install"; + $func(); + return true; + } else { + logger("Addons: FAILED installing theme $theme"); + return false; + } + + } + + /** + * @brief Get the full path to relevant theme files by filename + * + * This function search in the theme directory (and if not present in global theme directory) + * if there is a directory with the file extension and for a file with the given + * filename. + * + * @param string $file Filename + * @param string $root Full root path + * @return string Path to the file or empty string if the file isn't found + */ + public static function getPathForFile($file, $root = '') + { + $file = basename($file); + + // Make sure $root ends with a slash / if it's not blank + if ($root !== '' && $root[strlen($root)-1] !== '/') { + $root = $root . '/'; + } + $theme_info = get_app()->theme_info; + if (is_array($theme_info) && array_key_exists('extends',$theme_info)) { + $parent = $theme_info['extends']; + } else { + $parent = 'NOPATH'; + } + $theme = current_theme(); + $thname = $theme; + $ext = substr($file,strrpos($file,'.')+1); + $paths = [ + "{$root}view/theme/$thname/$ext/$file", + "{$root}view/theme/$parent/$ext/$file", + "{$root}view/$ext/$file", + ]; + foreach ($paths as $p) { + // strpos() is faster than strstr when checking if one string is in another (http://php.net/manual/en/function.strstr.php) + if (strpos($p,'NOPATH') !== false) { + continue; + } elseif (file_exists($p)) { + return $p; + } + } + return ''; + } +} diff --git a/src/Database/PostUpdate.php b/src/Database/PostUpdate.php index dba2b3212..0b9321b34 100644 --- a/src/Database/PostUpdate.php +++ b/src/Database/PostUpdate.php @@ -1,273 +1,273 @@ -= 1192) { - return true; - } - - // Check if the first step is done (Setting "gcontact-id" in the item table) - $r = dba::select('item', ['author-link', 'author-name', 'author-avatar', 'uid', 'network'], ['gcontact-id' => 0], ['limit' => 1000]); - if (!$r) { - // Are there unfinished entries in the thread table? - $r = q("SELECT COUNT(*) AS `total` FROM `thread` - INNER JOIN `item` ON `item`.`id` =`thread`.`iid` - WHERE `thread`.`gcontact-id` = 0 AND - (`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)"); - - if ($r && ($r[0]["total"] == 0)) { - Config::set("system", "post_update_version", 1192); - return true; - } - - // Update the thread table from the item table - q("UPDATE `thread` INNER JOIN `item` ON `item`.`id`=`thread`.`iid` - SET `thread`.`gcontact-id` = `item`.`gcontact-id` - WHERE `thread`.`gcontact-id` = 0 AND - (`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)"); - - return false; - } - - $item_arr = []; - foreach ($r as $item) { - $index = $item["author-link"]."-".$item["uid"]; - $item_arr[$index] = ["author-link" => $item["author-link"], - "uid" => $item["uid"], - "network" => $item["network"]]; - } - - // Set the "gcontact-id" in the item table and add a new gcontact entry if needed - foreach ($item_arr as $item) { - $gcontact_id = GContact::getId(["url" => $item['author-link'], "network" => $item['network'], - "photo" => $item['author-avatar'], "name" => $item['author-name']]); - dba::update('item', ['gcontact-id' => $gcontact_id], ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'gcontact-id' => 0]); - } - return false; - } - - /** - * @brief Updates the "global" field in the item table - * - * @return bool "true" when the job is done - */ - private static function update1194() - { - // Was the script completed? - if (Config::get("system", "post_update_version") >= 1194) { - return true; - } - - logger("Start", LOGGER_DEBUG); - - $end_id = Config::get("system", "post_update_1194_end"); - if (!$end_id) { - $r = q("SELECT `id` FROM `item` WHERE `uid` != 0 ORDER BY `id` DESC LIMIT 1"); - if ($r) { - Config::set("system", "post_update_1194_end", $r[0]["id"]); - $end_id = Config::get("system", "post_update_1194_end"); - } - } - - logger("End ID: ".$end_id, LOGGER_DEBUG); - - $start_id = Config::get("system", "post_update_1194_start"); - - $query1 = "SELECT `item`.`id` FROM `item` "; - - $query2 = "INNER JOIN `item` AS `shadow` ON `item`.`uri` = `shadow`.`uri` AND `shadow`.`uid` = 0 "; - - $query3 = "WHERE `item`.`uid` != 0 AND `item`.`id` >= %d AND `item`.`id` <= %d - AND `item`.`visible` AND NOT `item`.`private` - AND NOT `item`.`deleted` AND NOT `item`.`moderated` - AND `item`.`network` IN ('%s', '%s', '%s', '') - AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' - AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' - AND NOT `item`.`global`"; - - $r = q($query1.$query2.$query3." ORDER BY `item`.`id` LIMIT 1", - intval($start_id), intval($end_id), - dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS)); - if (!$r) { - Config::set("system", "post_update_version", 1194); - logger("Update is done", LOGGER_DEBUG); - return true; - } else { - Config::set("system", "post_update_1194_start", $r[0]["id"]); - $start_id = Config::get("system", "post_update_1194_start"); - } - - logger("Start ID: ".$start_id, LOGGER_DEBUG); - - $r = q($query1.$query2.$query3." ORDER BY `item`.`id` LIMIT 1000,1", - intval($start_id), intval($end_id), - dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS)); - if ($r) - $pos_id = $r[0]["id"]; - else - $pos_id = $end_id; - - logger("Progress: Start: ".$start_id." position: ".$pos_id." end: ".$end_id, LOGGER_DEBUG); - - q("UPDATE `item` ".$query2." SET `item`.`global` = 1 ".$query3, - intval($start_id), intval($pos_id), - dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS)); - - logger("Done", LOGGER_DEBUG); - } - - /** - * @brief set the author-id and owner-id in all item entries - * - * This job has to be started multiple times until all entries are set. - * It isn't started in the update function since it would consume too much time and can be done in the background. - * - * @return bool "true" when the job is done - */ - private static function update1198() - { - // Was the script completed? - if (Config::get("system", "post_update_version") >= 1198) { - return true; - } - - logger("Start", LOGGER_DEBUG); - - // Check if the first step is done (Setting "author-id" and "owner-id" in the item table) - $r = dba::select('item', ['author-link', 'owner-link', 'uid'], ['author-id' => 0, 'owner-id' => 0], ['limit' => 1000]); - if (!$r) { - // Are there unfinished entries in the thread table? - $r = q("SELECT COUNT(*) AS `total` FROM `thread` - INNER JOIN `item` ON `item`.`id` =`thread`.`iid` - WHERE `thread`.`author-id` = 0 AND `thread`.`owner-id` = 0 AND - (`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)"); - - if ($r && ($r[0]["total"] == 0)) { - Config::set("system", "post_update_version", 1198); - logger("Done", LOGGER_DEBUG); - return true; - } - - // Update the thread table from the item table - $r = q("UPDATE `thread` INNER JOIN `item` ON `item`.`id`=`thread`.`iid` - SET `thread`.`author-id` = `item`.`author-id`, - `thread`.`owner-id` = `item`.`owner-id` - WHERE `thread`.`author-id` = 0 AND `thread`.`owner-id` = 0 AND - (`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)"); - - logger("Updated threads", LOGGER_DEBUG); - if (DBM::is_result($r)) { - Config::set("system", "post_update_version", 1198); - logger("Done", LOGGER_DEBUG); - return true; - } - return false; - } - - logger("Query done", LOGGER_DEBUG); - - $item_arr = []; - foreach ($r as $item) { - $index = $item["author-link"]."-".$item["owner-link"]."-".$item["uid"]; - $item_arr[$index] = ["author-link" => $item["author-link"], - "owner-link" => $item["owner-link"], - "uid" => $item["uid"]]; - } - - // Set the "gcontact-id" in the item table and add a new gcontact entry if needed - foreach ($item_arr as $item) { - $author_id = Contact::getIdForURL($item["author-link"], 0); - $owner_id = Contact::getIdForURL($item["owner-link"], 0); - - if ($author_id == 0) - $author_id = -1; - - if ($owner_id == 0) - $owner_id = -1; - - dba::update('item', ['author-id' => $author_id, 'owner-id' => $owner_id], ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'owner-link' => $item['owner-link'], 'author-id' => 0, 'owner-id' => 0]); - } - - logger("Updated items", LOGGER_DEBUG); - return false; - } - - /** - * @brief update the "last-item" field in the "self" contact - * - * This field avoids cost intensive calls in the admin panel and in "nodeinfo" - * - * @return bool "true" when the job is done - */ - private static function update1206() - { - // Was the script completed? - if (Config::get("system", "post_update_version") >= 1206) { - return true; - } - - logger("Start", LOGGER_DEBUG); - $r = q("SELECT `contact`.`id`, `contact`.`last-item`, - (SELECT MAX(`changed`) FROM `item` USE INDEX (`uid_wall_changed`) WHERE `wall` AND `uid` = `user`.`uid`) AS `lastitem_date` - FROM `user` - INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`"); - - if (!DBM::is_result($r)) { - return false; - } - foreach ($r as $user) { - if (!empty($user["lastitem_date"]) && ($user["lastitem_date"] > $user["last-item"])) { - dba::update('contact', ['last-item' => $user['lastitem_date']], ['id' => $user['id']]); - } - } - - Config::set("system", "post_update_version", 1206); - logger("Done", LOGGER_DEBUG); - return true; - } -} += 1192) { + return true; + } + + // Check if the first step is done (Setting "gcontact-id" in the item table) + $r = dba::select('item', ['author-link', 'author-name', 'author-avatar', 'uid', 'network'], ['gcontact-id' => 0], ['limit' => 1000]); + if (!$r) { + // Are there unfinished entries in the thread table? + $r = q("SELECT COUNT(*) AS `total` FROM `thread` + INNER JOIN `item` ON `item`.`id` =`thread`.`iid` + WHERE `thread`.`gcontact-id` = 0 AND + (`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)"); + + if ($r && ($r[0]["total"] == 0)) { + Config::set("system", "post_update_version", 1192); + return true; + } + + // Update the thread table from the item table + q("UPDATE `thread` INNER JOIN `item` ON `item`.`id`=`thread`.`iid` + SET `thread`.`gcontact-id` = `item`.`gcontact-id` + WHERE `thread`.`gcontact-id` = 0 AND + (`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)"); + + return false; + } + + $item_arr = []; + foreach ($r as $item) { + $index = $item["author-link"]."-".$item["uid"]; + $item_arr[$index] = ["author-link" => $item["author-link"], + "uid" => $item["uid"], + "network" => $item["network"]]; + } + + // Set the "gcontact-id" in the item table and add a new gcontact entry if needed + foreach ($item_arr as $item) { + $gcontact_id = GContact::getId(["url" => $item['author-link'], "network" => $item['network'], + "photo" => $item['author-avatar'], "name" => $item['author-name']]); + dba::update('item', ['gcontact-id' => $gcontact_id], ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'gcontact-id' => 0]); + } + return false; + } + + /** + * @brief Updates the "global" field in the item table + * + * @return bool "true" when the job is done + */ + private static function update1194() + { + // Was the script completed? + if (Config::get("system", "post_update_version") >= 1194) { + return true; + } + + logger("Start", LOGGER_DEBUG); + + $end_id = Config::get("system", "post_update_1194_end"); + if (!$end_id) { + $r = q("SELECT `id` FROM `item` WHERE `uid` != 0 ORDER BY `id` DESC LIMIT 1"); + if ($r) { + Config::set("system", "post_update_1194_end", $r[0]["id"]); + $end_id = Config::get("system", "post_update_1194_end"); + } + } + + logger("End ID: ".$end_id, LOGGER_DEBUG); + + $start_id = Config::get("system", "post_update_1194_start"); + + $query1 = "SELECT `item`.`id` FROM `item` "; + + $query2 = "INNER JOIN `item` AS `shadow` ON `item`.`uri` = `shadow`.`uri` AND `shadow`.`uid` = 0 "; + + $query3 = "WHERE `item`.`uid` != 0 AND `item`.`id` >= %d AND `item`.`id` <= %d + AND `item`.`visible` AND NOT `item`.`private` + AND NOT `item`.`deleted` AND NOT `item`.`moderated` + AND `item`.`network` IN ('%s', '%s', '%s', '') + AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' + AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' + AND NOT `item`.`global`"; + + $r = q($query1.$query2.$query3." ORDER BY `item`.`id` LIMIT 1", + intval($start_id), intval($end_id), + dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS)); + if (!$r) { + Config::set("system", "post_update_version", 1194); + logger("Update is done", LOGGER_DEBUG); + return true; + } else { + Config::set("system", "post_update_1194_start", $r[0]["id"]); + $start_id = Config::get("system", "post_update_1194_start"); + } + + logger("Start ID: ".$start_id, LOGGER_DEBUG); + + $r = q($query1.$query2.$query3." ORDER BY `item`.`id` LIMIT 1000,1", + intval($start_id), intval($end_id), + dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS)); + if ($r) + $pos_id = $r[0]["id"]; + else + $pos_id = $end_id; + + logger("Progress: Start: ".$start_id." position: ".$pos_id." end: ".$end_id, LOGGER_DEBUG); + + q("UPDATE `item` ".$query2." SET `item`.`global` = 1 ".$query3, + intval($start_id), intval($pos_id), + dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS)); + + logger("Done", LOGGER_DEBUG); + } + + /** + * @brief set the author-id and owner-id in all item entries + * + * This job has to be started multiple times until all entries are set. + * It isn't started in the update function since it would consume too much time and can be done in the background. + * + * @return bool "true" when the job is done + */ + private static function update1198() + { + // Was the script completed? + if (Config::get("system", "post_update_version") >= 1198) { + return true; + } + + logger("Start", LOGGER_DEBUG); + + // Check if the first step is done (Setting "author-id" and "owner-id" in the item table) + $r = dba::select('item', ['author-link', 'owner-link', 'uid'], ['author-id' => 0, 'owner-id' => 0], ['limit' => 1000]); + if (!$r) { + // Are there unfinished entries in the thread table? + $r = q("SELECT COUNT(*) AS `total` FROM `thread` + INNER JOIN `item` ON `item`.`id` =`thread`.`iid` + WHERE `thread`.`author-id` = 0 AND `thread`.`owner-id` = 0 AND + (`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)"); + + if ($r && ($r[0]["total"] == 0)) { + Config::set("system", "post_update_version", 1198); + logger("Done", LOGGER_DEBUG); + return true; + } + + // Update the thread table from the item table + $r = q("UPDATE `thread` INNER JOIN `item` ON `item`.`id`=`thread`.`iid` + SET `thread`.`author-id` = `item`.`author-id`, + `thread`.`owner-id` = `item`.`owner-id` + WHERE `thread`.`author-id` = 0 AND `thread`.`owner-id` = 0 AND + (`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)"); + + logger("Updated threads", LOGGER_DEBUG); + if (DBM::is_result($r)) { + Config::set("system", "post_update_version", 1198); + logger("Done", LOGGER_DEBUG); + return true; + } + return false; + } + + logger("Query done", LOGGER_DEBUG); + + $item_arr = []; + foreach ($r as $item) { + $index = $item["author-link"]."-".$item["owner-link"]."-".$item["uid"]; + $item_arr[$index] = ["author-link" => $item["author-link"], + "owner-link" => $item["owner-link"], + "uid" => $item["uid"]]; + } + + // Set the "gcontact-id" in the item table and add a new gcontact entry if needed + foreach ($item_arr as $item) { + $author_id = Contact::getIdForURL($item["author-link"], 0); + $owner_id = Contact::getIdForURL($item["owner-link"], 0); + + if ($author_id == 0) + $author_id = -1; + + if ($owner_id == 0) + $owner_id = -1; + + dba::update('item', ['author-id' => $author_id, 'owner-id' => $owner_id], ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'owner-link' => $item['owner-link'], 'author-id' => 0, 'owner-id' => 0]); + } + + logger("Updated items", LOGGER_DEBUG); + return false; + } + + /** + * @brief update the "last-item" field in the "self" contact + * + * This field avoids cost intensive calls in the admin panel and in "nodeinfo" + * + * @return bool "true" when the job is done + */ + private static function update1206() + { + // Was the script completed? + if (Config::get("system", "post_update_version") >= 1206) { + return true; + } + + logger("Start", LOGGER_DEBUG); + $r = q("SELECT `contact`.`id`, `contact`.`last-item`, + (SELECT MAX(`changed`) FROM `item` USE INDEX (`uid_wall_changed`) WHERE `wall` AND `uid` = `user`.`uid`) AS `lastitem_date` + FROM `user` + INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`"); + + if (!DBM::is_result($r)) { + return false; + } + foreach ($r as $user) { + if (!empty($user["lastitem_date"]) && ($user["lastitem_date"] > $user["last-item"])) { + dba::update('contact', ['last-item' => $user['lastitem_date']], ['id' => $user['id']]); + } + } + + Config::set("system", "post_update_version", 1206); + logger("Done", LOGGER_DEBUG); + return true; + } +} diff --git a/src/Module/Feed.php b/src/Module/Feed.php index 485d070e3..2be12f13e 100644 --- a/src/Module/Feed.php +++ b/src/Module/Feed.php @@ -1,60 +1,60 @@ - posts - * - /feed/[nickname]/posts => posts - * - /feed/[nickname]/comments => comments - * - /feed/[nickname]/replies => comments - * - /feed/[nickname]/activity => activity - * - * The nocache GET parameter is provided mainly for debug purposes, requires auth - * - * @brief Provides public Atom feeds - * - * @author Hypolite Petovan - */ -class Feed extends BaseModule -{ - public static function content() - { - $a = self::getApp(); - - $last_update = x($_GET, 'last_update') ? $_GET['last_update'] : ''; - $nocache = x($_GET, 'nocache') && local_user(); - - if ($a->argc < 2) { - System::httpExit(400); - } - - $type = null; - if ($a->argc > 2) { - $type = $a->argv[2]; - } - - switch ($type) { - case 'posts': - case 'comments': - case 'activity': - break; - case 'replies': - $type = 'comments'; - break; - default: - $type = 'posts'; - } - - $nickname = $a->argv[1]; - header("Content-type: application/atom+xml"); - echo OStatus::feed($nickname, $last_update, 10, $type, $nocache); - killme(); - } -} + posts + * - /feed/[nickname]/posts => posts + * - /feed/[nickname]/comments => comments + * - /feed/[nickname]/replies => comments + * - /feed/[nickname]/activity => activity + * + * The nocache GET parameter is provided mainly for debug purposes, requires auth + * + * @brief Provides public Atom feeds + * + * @author Hypolite Petovan + */ +class Feed extends BaseModule +{ + public static function content() + { + $a = self::getApp(); + + $last_update = x($_GET, 'last_update') ? $_GET['last_update'] : ''; + $nocache = x($_GET, 'nocache') && local_user(); + + if ($a->argc < 2) { + System::httpExit(400); + } + + $type = null; + if ($a->argc > 2) { + $type = $a->argv[2]; + } + + switch ($type) { + case 'posts': + case 'comments': + case 'activity': + break; + case 'replies': + $type = 'comments'; + break; + default: + $type = 'posts'; + } + + $nickname = $a->argv[1]; + header("Content-type: application/atom+xml"); + echo OStatus::feed($nickname, $last_update, 10, $type, $nocache); + killme(); + } +} diff --git a/src/Module/Logout.php b/src/Module/Logout.php index a03ef05c2..7c5391a6b 100644 --- a/src/Module/Logout.php +++ b/src/Module/Logout.php @@ -1,31 +1,31 @@ -get_baseurl()); - } -} +get_baseurl()); + } +} diff --git a/src/Module/Oembed.php b/src/Module/Oembed.php index e5f3941bb..570e28124 100644 --- a/src/Module/Oembed.php +++ b/src/Module/Oembed.php @@ -1,53 +1,53 @@ - - */ -class Oembed extends BaseModule -{ - public static function content() - { - $a = self::getApp(); - - // Unused form: /oembed/b2h?url=... - if ($a->argv[1] == 'b2h') { - $url = ["", trim(hex2bin($_REQUEST['url']))]; - echo Content\OEmbed::replaceCallback($url); - killme(); - } - - // Unused form: /oembed/h2b?text=... - if ($a->argv[1] == 'h2b') { - $text = trim(hex2bin($_REQUEST['text'])); - echo Content\OEmbed::HTML2BBCode($text); - killme(); - } - - if ($a->argc == 2) { - echo ''; - $url = base64url_decode($a->argv[1]); - $j = Content\OEmbed::fetchURL($url); - - // workaround for media.ccc.de (and any other endpoint that return size 0) - if (substr($j->html, 0, 7) == "html, 'width="0"')) { - $j->html = '' . $j->html; - $j->html = str_replace('width="0"', '', $j->html); - $j->html = str_replace('height="0"', '', $j->html); - } - echo $j->html; - echo ''; - } - killme(); - } -} + + */ +class Oembed extends BaseModule +{ + public static function content() + { + $a = self::getApp(); + + // Unused form: /oembed/b2h?url=... + if ($a->argv[1] == 'b2h') { + $url = ["", trim(hex2bin($_REQUEST['url']))]; + echo Content\OEmbed::replaceCallback($url); + killme(); + } + + // Unused form: /oembed/h2b?text=... + if ($a->argv[1] == 'h2b') { + $text = trim(hex2bin($_REQUEST['text'])); + echo Content\OEmbed::HTML2BBCode($text); + killme(); + } + + if ($a->argc == 2) { + echo ''; + $url = base64url_decode($a->argv[1]); + $j = Content\OEmbed::fetchURL($url); + + // workaround for media.ccc.de (and any other endpoint that return size 0) + if (substr($j->html, 0, 7) == "html, 'width="0"')) { + $j->html = '' . $j->html; + $j->html = str_replace('width="0"', '', $j->html); + $j->html = str_replace('height="0"', '', $j->html); + } + echo $j->html; + echo ''; + } + killme(); + } +} diff --git a/src/Network/HTTPException.php b/src/Network/HTTPException.php index 7602290c2..b9bad457d 100644 --- a/src/Network/HTTPException.php +++ b/src/Network/HTTPException.php @@ -1,27 +1,27 @@ -httpdesc == '') { - $classname = str_replace('Exception', '', str_replace('Friendica\Network\HTTPException\\', '', get_class($this))); - $this->httpdesc = preg_replace("|([a-z])([A-Z])|",'$1 $2', $classname); - } - parent::__construct($message, $code, $previous); - } -} +httpdesc == '') { + $classname = str_replace('Exception', '', str_replace('Friendica\Network\HTTPException\\', '', get_class($this))); + $this->httpdesc = preg_replace("|([a-z])([A-Z])|",'$1 $2', $classname); + } + parent::__construct($message, $code, $previous); + } +} diff --git a/src/Network/HTTPException/BadGatewayException.php b/src/Network/HTTPException/BadGatewayException.php index 1bb8b29e9..6fc80c909 100644 --- a/src/Network/HTTPException/BadGatewayException.php +++ b/src/Network/HTTPException/BadGatewayException.php @@ -1,10 +1,10 @@ - - */ -class FriendicaSmarty extends Smarty -{ - const SMARTY3_TEMPLATE_FOLDER = 'templates'; - - public $filename; - - function __construct() - { - parent::__construct(); - - $a = get_app(); - $theme = current_theme(); - - // setTemplateDir can be set to an array, which Smarty will parse in order. - // The order is thus very important here - $template_dirs = ['theme' => "view/theme/$theme/" . self::SMARTY3_TEMPLATE_FOLDER . "/"]; - if (x($a->theme_info, "extends")) { - $template_dirs = $template_dirs + ['extends' => "view/theme/" . $a->theme_info["extends"] . "/" . self::SMARTY3_TEMPLATE_FOLDER . "/"]; - } - - $template_dirs = $template_dirs + ['base' => "view/" . self::SMARTY3_TEMPLATE_FOLDER . "/"]; - $this->setTemplateDir($template_dirs); - - $this->setCompileDir('view/smarty3/compiled/'); - $this->setConfigDir('view/smarty3/config/'); - $this->setCacheDir('view/smarty3/cache/'); - - $this->left_delimiter = $a->get_template_ldelim('smarty3'); - $this->right_delimiter = $a->get_template_rdelim('smarty3'); - - // Don't report errors so verbosely - $this->error_reporting = E_ALL & ~E_NOTICE; - } - - function parsed($template = '') - { - if ($template) { - return $this->fetch('string:' . $template); - } - return $this->fetch('file:' . $this->filename); - } - + + */ +class FriendicaSmarty extends Smarty +{ + const SMARTY3_TEMPLATE_FOLDER = 'templates'; + + public $filename; + + function __construct() + { + parent::__construct(); + + $a = get_app(); + $theme = current_theme(); + + // setTemplateDir can be set to an array, which Smarty will parse in order. + // The order is thus very important here + $template_dirs = ['theme' => "view/theme/$theme/" . self::SMARTY3_TEMPLATE_FOLDER . "/"]; + if (x($a->theme_info, "extends")) { + $template_dirs = $template_dirs + ['extends' => "view/theme/" . $a->theme_info["extends"] . "/" . self::SMARTY3_TEMPLATE_FOLDER . "/"]; + } + + $template_dirs = $template_dirs + ['base' => "view/" . self::SMARTY3_TEMPLATE_FOLDER . "/"]; + $this->setTemplateDir($template_dirs); + + $this->setCompileDir('view/smarty3/compiled/'); + $this->setConfigDir('view/smarty3/config/'); + $this->setCacheDir('view/smarty3/cache/'); + + $this->left_delimiter = $a->get_template_ldelim('smarty3'); + $this->right_delimiter = $a->get_template_rdelim('smarty3'); + + // Don't report errors so verbosely + $this->error_reporting = E_ALL & ~E_NOTICE; + } + + function parsed($template = '') + { + if ($template) { + return $this->fetch('string:' . $template); + } + return $this->fetch('file:' . $this->filename); + } + } \ No newline at end of file diff --git a/src/Render/ITemplateEngine.php b/src/Render/ITemplateEngine.php index d59248119..cf19e2065 100644 --- a/src/Render/ITemplateEngine.php +++ b/src/Render/ITemplateEngine.php @@ -1,15 +1,15 @@ -