-{\r
- "name": "friendica/friendica",\r
- "description": "A decentralized social network part of The Federation",\r
- "type": "project",\r
- "keywords": [\r
- "social network",\r
- "dfrn",\r
- "ostatus",\r
- "diaspora"\r
- ],\r
- "license": "AGPL-3.0+",\r
- "support": {\r
- "issues": "https://github.com/friendica/friendica/issues"\r
- },\r
- "require": {\r
- "php": ">5.6",\r
- "ext-xml": "*",\r
- "ezyang/htmlpurifier": "~4.7.0",\r
- "league/html-to-markdown": "~4.4.1",\r
- "lightopenid/lightopenid": "dev-master",\r
- "michelf/php-markdown": "^1.7",\r
- "mobiledetect/mobiledetectlib": "2.8.*",\r
- "paragonie/random_compat": "^2.0",\r
- "pear/Text_LanguageDetect": "1.*",\r
- "pear/Text_Highlighter": "dev-master",\r
- "smarty/smarty": "^3.1",\r
- "fxp/composer-asset-plugin": "~1.3",\r
- "bower-asset/base64": "^1.0",\r
- "bower-asset/Chart-js": "^2.7",\r
- "bower-asset/perfect-scrollbar": "^0.6",\r
- "npm-asset/jquery": "^2.0",\r
- "npm-asset/jquery-colorbox": "^1.6",\r
- "npm-asset/jquery-datetimepicker": "^2.4.0",\r
- "npm-asset/jgrowl": "^1.4",\r
- "npm-asset/fullcalendar": "^3.0.1"\r
- },\r
- "repositories": [\r
- {\r
- "type": "vcs",\r
- "url": "https://github.com/pear/Text_Highlighter"\r
- }\r
- ],\r
- "autoload": {\r
- "psr-4": {\r
- "Friendica\\": "src/"\r
- },\r
- "psr-0": {\r
- "": "library/"\r
- }\r
- },\r
- "config": {\r
- "autoloader-suffix": "Friendica",\r
- "optimize-autoloader": true,\r
- "preferred-install": "dist",\r
- "fxp-asset": {\r
- "installer-paths": {\r
- "npm-asset-library": "vendor/asset",\r
- "bower-asset-library": "vendor/asset"\r
- }\r
- }\r
- },\r
- "archive": {\r
- "exclude": [\r
- "log", "cache", "/photo", "/proxy"\r
- ]\r
- }\r
-}\r
+{
+ "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"
+ ]
+ }
+}
-<?php\r
-\r
-namespace Friendica;\r
-\r
-/**\r
- * All modules in Friendica should extend BaseModule, although not all modules\r
- * need to extend all the methods described here\r
- *\r
- * @author Hypolite Petovan mrpetovan@gmail.com\r
- */\r
-abstract class BaseModule extends BaseObject\r
-{\r
- /**\r
- * @brief Initialization method common to both content() and post()\r
- *\r
- * Extend this method if you need to do any shared processing before both\r
- * content() or post()\r
- */\r
- public static function init()\r
- {\r
-\r
- }\r
-\r
- /**\r
- * @brief Module GET method to display any content\r
- *\r
- * Extend this method if the module is supposed to return any display\r
- * through a GET request. It can be an HTML page through templating or a\r
- * XML feed or a JSON output.\r
- *\r
- * @return string\r
- */\r
- public static function content()\r
- {\r
- $o = '';\r
-\r
- return $o;\r
- }\r
-\r
- /**\r
- * @brief Module POST method to process submitted data\r
- *\r
- * Extend this method if the module is supposed to process POST requests.\r
- * Doesn't display any content\r
- */\r
- public static function post()\r
- {\r
- // goaway('module');\r
- }\r
-\r
- /**\r
- * @brief Called after post()\r
- *\r
- * Unknown purpose\r
- */\r
- public static function afterpost()\r
- {\r
-\r
- }\r
-}\r
+<?php
+
+namespace Friendica;
+
+/**
+ * All modules in Friendica should extend BaseModule, although not all modules
+ * need to extend all the methods described here
+ *
+ * @author Hypolite Petovan mrpetovan@gmail.com
+ */
+abstract class BaseModule extends BaseObject
+{
+ /**
+ * @brief Initialization method common to both content() and post()
+ *
+ * Extend this method if you need to do any shared processing before both
+ * content() or post()
+ */
+ public static function init()
+ {
+
+ }
+
+ /**
+ * @brief Module GET method to display any content
+ *
+ * Extend this method if the module is supposed to return any display
+ * through a GET request. It can be an HTML page through templating or a
+ * XML feed or a JSON output.
+ *
+ * @return string
+ */
+ public static function content()
+ {
+ $o = '';
+
+ return $o;
+ }
+
+ /**
+ * @brief Module POST method to process submitted data
+ *
+ * Extend this method if the module is supposed to process POST requests.
+ * Doesn't display any content
+ */
+ public static function post()
+ {
+ // goaway('module');
+ }
+
+ /**
+ * @brief Called after post()
+ *
+ * Unknown purpose
+ */
+ public static function afterpost()
+ {
+
+ }
+}
-<?php\r
-\r
-/**\r
- * @file src/Content/Text/Markdown.php\r
- */\r
-\r
-namespace Friendica\Content\Text;\r
-\r
-use Friendica\BaseObject;\r
-use Michelf\MarkdownExtra;\r
-\r
-/**\r
- * Friendica-specific usage of Markdown\r
- *\r
- * @author Hypolite Petovan <mrpetovan@gmail.com>\r
- */\r
-class Markdown extends BaseObject\r
-{\r
- /**\r
- * Converts a Markdown string into HTML. The hardwrap parameter maximizes\r
- * compatibility with Diaspora in spite of the Markdown standard.\r
- *\r
- * @brief Converts a Markdown string into HTML\r
- * @param string $text\r
- * @param bool $hardwrap\r
- * @return string\r
- */\r
- public static function convert($text, $hardwrap = true) {\r
- $stamp1 = microtime(true);\r
-\r
- $MarkdownParser = new MarkdownExtra();\r
- $MarkdownParser->hard_wrap = $hardwrap;\r
- $html = $MarkdownParser->transform($text);\r
-\r
- self::getApp()->save_timestamp($stamp1, "parser");\r
-\r
- return $html;\r
- }\r
-}\r
+<?php
+
+/**
+ * @file src/Content/Text/Markdown.php
+ */
+
+namespace Friendica\Content\Text;
+
+use Friendica\BaseObject;
+use Michelf\MarkdownExtra;
+
+/**
+ * Friendica-specific usage of Markdown
+ *
+ * @author Hypolite Petovan <mrpetovan@gmail.com>
+ */
+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;
+ }
+}
-<?php\r
-\r
-/*\r
- * @file src/Content/Widget/TagCloud.php\r
- */\r
-\r
-namespace Friendica\Content\Widget;\r
-\r
-use dba;\r
-use Friendica\Core\L10n;\r
-use Friendica\Core\System;\r
-use Friendica\Database\DBM;\r
-\r
-require_once 'include/dba.php';\r
-require_once 'include/security.php';\r
-\r
-/**\r
- * TagCloud widget\r
- *\r
- * @author Rabuzarus\r
- */\r
-class TagCloud\r
-{\r
- /**\r
- * Construct a tag/term cloud block for an user.\r
- *\r
- * @brief Construct a tag/term cloud block for an user.\r
- * @param int $uid The user ID.\r
- * @param int $count Max number of displayed tags/terms.\r
- * @param int $owner_id The contact ID of the owner of the tagged items.\r
- * @param string $flags Special item flags.\r
- * @param int $type The tag/term type.\r
- *\r
- * @return string HTML formatted output.\r
- */\r
- public static function getHTML($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HASHTAG)\r
- {\r
- $o = '';\r
- $r = self::tagadelic($uid, $count, $owner_id, $flags, $type);\r
- if (count($r)) {\r
- $contact = dba::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]);\r
- $url = System::removedBaseUrl($contact['url']);\r
-\r
- foreach ($r as $rr) {\r
- $tag['level'] = $rr[2];\r
- $tag['url'] = $url . '?tag=' . urlencode($rr[0]);\r
- $tag['name'] = $rr[0];\r
-\r
- $tags[] = $tag;\r
- }\r
-\r
- $tpl = get_markup_template('tagblock_widget.tpl');\r
- $o = replace_macros($tpl, [\r
- '$title' => L10n::t('Tags'),\r
- '$tags' => $tags\r
- ]);\r
- }\r
- return $o;\r
- }\r
-\r
- /**\r
- * Get alphabetical sorted array of used tags/terms of an user including\r
- * a weighting by frequency of use.\r
- *\r
- * @brief Get alphabetical sorted array of used tags/terms of an user including\r
- * a weighting by frequency of use.\r
- * @param int $uid The user ID.\r
- * @param int $count Max number of displayed tags/terms.\r
- * @param int $owner_id The contact id of the owner of the tagged items.\r
- * @param string $flags Special item flags.\r
- * @param int $type The tag/term type.\r
- *\r
- * @return arr Alphabetical sorted array of used tags of an user.\r
- */\r
- private static function tagadelic($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HASHTAG)\r
- {\r
- $item_condition = item_condition();\r
- $sql_options = item_permissions_sql($uid);\r
- $limit = $count ? sprintf('LIMIT %d', intval($count)) : '';\r
-\r
- if ($flags) {\r
- if ($flags === 'wall') {\r
- $sql_options .= ' AND `item`.`wall` ';\r
- }\r
- }\r
-\r
- if ($owner_id) {\r
- $sql_options .= ' AND `item`.`owner-id` = ' . intval($owner_id) . ' ';\r
- }\r
-\r
- // Fetch tags\r
- $r = dba::p("SELECT `term`, COUNT(`term`) AS `total` FROM `term`\r
- LEFT JOIN `item` ON `term`.`oid` = `item`.`id`\r
- WHERE `term`.`uid` = ? AND `term`.`type` = ?\r
- AND `term`.`otype` = ?\r
- AND $item_condition $sql_options\r
- GROUP BY `term` ORDER BY `total` DESC $limit",\r
- $uid,\r
- $type,\r
- TERM_OBJ_POST\r
- );\r
- if (!DBM::is_result($r)) {\r
- return [];\r
- }\r
-\r
- return self::tagCalc($r);\r
- }\r
-\r
- /**\r
- * Calculate weighting of tags according to the frequency of use.\r
- *\r
- * @brief Calculate weighting of tags according to the frequency of use.\r
- * @param array $arr Array of tags/terms with tag/term name and total count of use.\r
- * @return array Alphabetical sorted array of used tags/terms of an user.\r
- */\r
- private static function tagCalc($arr)\r
- {\r
- $tags = [];\r
- $min = 1e9;\r
- $max = -1e9;\r
- $x = 0;\r
-\r
- if (!$arr) {\r
- return [];\r
- }\r
-\r
- foreach ($arr as $rr) {\r
- $tags[$x][0] = $rr['term'];\r
- $tags[$x][1] = log($rr['total']);\r
- $tags[$x][2] = 0;\r
- $min = min($min, $tags[$x][1]);\r
- $max = max($max, $tags[$x][1]);\r
- $x ++;\r
- }\r
-\r
- usort($tags, 'self::tagsSort');\r
- $range = max(.01, $max - $min) * 1.0001;\r
-\r
- for ($x = 0; $x < count($tags); $x ++) {\r
- $tags[$x][2] = 1 + floor(9 * ($tags[$x][1] - $min) / $range);\r
- }\r
-\r
- return $tags;\r
- }\r
-\r
- /**\r
- * Compare function to sort tags/terms alphabetically.\r
- *\r
- * @brief Compare function to sort tags/terms alphabetically.\r
- * @param type $a\r
- * @param type $b\r
- *\r
- * @return int\r
- */\r
- private static function tagsSort($a, $b)\r
- {\r
- if (strtolower($a[0]) == strtolower($b[0])) {\r
- return 0;\r
- }\r
- return ((strtolower($a[0]) < strtolower($b[0])) ? -1 : 1);\r
- }\r
-}\r
+<?php
+
+/*
+ * @file src/Content/Widget/TagCloud.php
+ */
+
+namespace Friendica\Content\Widget;
+
+use dba;
+use Friendica\Core\L10n;
+use Friendica\Core\System;
+use Friendica\Database\DBM;
+
+require_once 'include/dba.php';
+require_once 'include/security.php';
+
+/**
+ * TagCloud widget
+ *
+ * @author Rabuzarus
+ */
+class TagCloud
+{
+ /**
+ * Construct a tag/term cloud block for an user.
+ *
+ * @brief Construct a tag/term cloud block for an user.
+ * @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 string HTML formatted output.
+ */
+ public static function getHTML($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HASHTAG)
+ {
+ $o = '';
+ $r = self::tagadelic($uid, $count, $owner_id, $flags, $type);
+ if (count($r)) {
+ $contact = dba::selectFirst('contact', ['url'], ['uid' => $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);
+ }
+}
-<?php\r
-\r
-/**\r
- * @file src/Core/Session.php\r
- */\r
-namespace Friendica\Core;\r
-\r
-use Friendica\Core\Session\DatabaseSessionHandler;\r
-use Friendica\Core\Session\MemcacheSessionHandler;\r
-\r
-/**\r
- * High-level Session service class\r
- *\r
- * @author Hypolite Petovan <mrpetovan@gmail.com>\r
- */\r
-class Session\r
-{\r
- public static $exists = false;\r
- public static $expire = 180000;\r
-\r
- public static function init()\r
- {\r
- ini_set('session.gc_probability', 50);\r
- ini_set('session.use_only_cookies', 1);\r
- ini_set('session.cookie_httponly', 1);\r
-\r
- if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) {\r
- ini_set('session.cookie_secure', 1);\r
- }\r
-\r
- if (!Config::get('system', 'disable_database_session')) {\r
- $memcache = Cache::memcache();\r
- if (is_object($memcache)) {\r
- $SessionHandler = new MemcacheSessionHandler($memcache);\r
- } else {\r
- $SessionHandler = new DatabaseSessionHandler();\r
- }\r
-\r
- session_set_save_handler($SessionHandler);\r
- }\r
- }\r
-\r
- public static function exists($name)\r
- {\r
- return isset($_SESSION[$name]);\r
- }\r
-\r
- public static function get($name)\r
- {\r
- return defaults($_SESSION, $name, null);\r
- }\r
-\r
- public static function set($name, $value)\r
- {\r
- $_SESSION[$name] = $value;\r
- }\r
-}\r
+<?php
+
+/**
+ * @file src/Core/Session.php
+ */
+namespace Friendica\Core;
+
+use Friendica\Core\Session\DatabaseSessionHandler;
+use Friendica\Core\Session\MemcacheSessionHandler;
+
+/**
+ * High-level Session service class
+ *
+ * @author Hypolite Petovan <mrpetovan@gmail.com>
+ */
+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;
+ }
+}
-<?php\r
-\r
-namespace Friendica\Core\Session;\r
-\r
-use Friendica\BaseObject;\r
-use Friendica\Core\Session;\r
-use Friendica\Database\DBM;\r
-use SessionHandlerInterface;\r
-use dba;\r
-\r
-require_once 'boot.php';\r
-require_once 'include/dba.php';\r
-require_once 'include/text.php';\r
-\r
-/**\r
- * SessionHandler using database\r
- *\r
- * @author Hypolite Petovan <mrpetovan@gmail.com>\r
- */\r
-class DatabaseSessionHandler extends BaseObject implements SessionHandlerInterface\r
-{\r
- public function open($save_path, $session_name)\r
- {\r
- return true;\r
- }\r
-\r
- public function read($session_id)\r
- {\r
- if (!x($session_id)) {\r
- return '';\r
- }\r
-\r
- $session = dba::selectFirst('session', ['data'], ['sid' => $session_id]);\r
- if (DBM::is_result($session)) {\r
- Session::$exists = true;\r
- return $session['data'];\r
- }\r
- logger("no data for session $session_id", LOGGER_TRACE);\r
-\r
- return '';\r
- }\r
-\r
- /**\r
- * @brief Standard PHP session write callback\r
- *\r
- * This callback updates the DB-stored session data and/or the expiration depending\r
- * on the case. Uses the Session::expire global for existing session, 5 minutes\r
- * for newly created session.\r
- *\r
- * @param string $session_id Session ID with format: [a-z0-9]{26}\r
- * @param string $session_data Serialized session data\r
- * @return boolean Returns false if parameters are missing, true otherwise\r
- */\r
- public function write($session_id, $session_data)\r
- {\r
- if (!$session_id) {\r
- return false;\r
- }\r
-\r
- if (!$session_data) {\r
- return true;\r
- }\r
-\r
- $expire = time() + Session::$expire;\r
- $default_expire = time() + 300;\r
-\r
- if (Session::$exists) {\r
- $fields = ['data' => $session_data, 'expire' => $expire];\r
- $condition = ["`sid` = ? AND (`data` != ? OR `expire` != ?)", $session_id, $session_data, $expire];\r
- dba::update('session', $fields, $condition);\r
- } else {\r
- $fields = ['sid' => $session_id, 'expire' => $default_expire, 'data' => $session_data];\r
- dba::insert('session', $fields);\r
- }\r
-\r
- return true;\r
- }\r
-\r
- public function close()\r
- {\r
- return true;\r
- }\r
-\r
- public function destroy($id)\r
- {\r
- dba::delete('session', ['sid' => $id]);\r
- return true;\r
- }\r
-\r
- public function gc($maxlifetime)\r
- {\r
- dba::delete('session', ["`expire` < ?", time()]);\r
- return true;\r
- }\r
-}\r
+<?php
+
+namespace Friendica\Core\Session;
+
+use Friendica\BaseObject;
+use Friendica\Core\Session;
+use Friendica\Database\DBM;
+use SessionHandlerInterface;
+use dba;
+
+require_once 'boot.php';
+require_once 'include/dba.php';
+require_once 'include/text.php';
+
+/**
+ * SessionHandler using database
+ *
+ * @author Hypolite Petovan <mrpetovan@gmail.com>
+ */
+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;
+ }
+}
-<?php\r
-\r
-namespace Friendica\Core\Session;\r
-\r
-use Friendica\BaseObject;\r
-use Friendica\Core\Session;\r
-use SessionHandlerInterface;\r
-use Memcache;\r
-\r
-require_once 'boot.php';\r
-require_once 'include/text.php';\r
-\r
-/**\r
- * SessionHandler using Memcache\r
- *\r
- * @author Hypolite Petovan <mrpetovan@gmail.com>\r
- */\r
-class MemcacheSessionHandler extends BaseObject implements SessionHandlerInterface\r
-{\r
- /**\r
- * @var Memcache\r
- */\r
- private $memcache = null;\r
-\r
- /**\r
- *\r
- * @param Memcache $memcache\r
- */\r
- public function __construct(Memcache $memcache)\r
- {\r
- $this->memcache = $memcache;\r
- }\r
-\r
- public function open($save_path, $session_name)\r
- {\r
- return true;\r
- }\r
-\r
- public function read($session_id)\r
- {\r
- if (!x($session_id)) {\r
- return '';\r
- }\r
-\r
- $data = $this->memcache->get(self::getApp()->get_hostname() . ":session:" . $session_id);\r
- if (!is_bool($data)) {\r
- Session::$exists = true;\r
- return $data;\r
- }\r
- logger("no data for session $session_id", LOGGER_TRACE);\r
- return '';\r
- }\r
-\r
- /**\r
- * @brief Standard PHP session write callback\r
- *\r
- * This callback updates the stored session data and/or the expiration depending\r
- * on the case. Uses the Session::expire for existing session, 5 minutes\r
- * for newly created session.\r
- *\r
- * @param string $session_id Session ID with format: [a-z0-9]{26}\r
- * @param string $session_data Serialized session data\r
- * @return boolean Returns false if parameters are missing, true otherwise\r
- */\r
- public function write($session_id, $session_data)\r
- {\r
- if (!$session_id) {\r
- return false;\r
- }\r
-\r
- if (!$session_data) {\r
- return true;\r
- }\r
-\r
- $expire = time() + Session::$expire;\r
-\r
- $this->memcache->set(\r
- self::getApp()->get_hostname() . ":session:" . $session_id,\r
- $session_data,\r
- MEMCACHE_COMPRESSED,\r
- $expire\r
- );\r
-\r
- return true;\r
- }\r
-\r
- public function close()\r
- {\r
- return true;\r
- }\r
-\r
- public function destroy($id)\r
- {\r
- $this->memcache->delete(self::getApp()->get_hostname() . ":session:" . $id);\r
- return true;\r
- }\r
-\r
- public function gc($maxlifetime)\r
- {\r
- return true;\r
- }\r
-}\r
+<?php
+
+namespace Friendica\Core\Session;
+
+use Friendica\BaseObject;
+use Friendica\Core\Session;
+use SessionHandlerInterface;
+use Memcache;
+
+require_once 'boot.php';
+require_once 'include/text.php';
+
+/**
+ * SessionHandler using Memcache
+ *
+ * @author Hypolite Petovan <mrpetovan@gmail.com>
+ */
+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;
+ }
+}
-<?php\r
-/**\r
- * @file src/Core/Theme.php\r
- */\r
-namespace Friendica\Core;\r
-\r
-use Friendica\Core\System;\r
-\r
-require_once 'boot.php';\r
-\r
-/**\r
- * Some functions to handle themes\r
- */\r
-class Theme\r
-{\r
- /**\r
- * @brief Parse theme comment in search of theme infos.\r
- *\r
- * like\r
- * \code\r
- * ..* Name: My Theme\r
- * * Description: My Cool Theme\r
- * . * Version: 1.2.3\r
- * * Author: John <profile url>\r
- * * Maintainer: Jane <profile url>\r
- * *\r
- * \endcode\r
- * @param string $theme the name of the theme\r
- * @return array\r
- */\r
-\r
- public static function getInfo($theme)\r
- {\r
- $info=[\r
- 'name' => $theme,\r
- 'description' => "",\r
- 'author' => [],\r
- 'maintainer' => [],\r
- 'version' => "",\r
- 'credits' => "",\r
- 'experimental' => false,\r
- 'unsupported' => false\r
- ];\r
-\r
- if (file_exists("view/theme/$theme/experimental"))\r
- $info['experimental'] = true;\r
- if (file_exists("view/theme/$theme/unsupported"))\r
- $info['unsupported'] = true;\r
-\r
- if (!is_file("view/theme/$theme/theme.php")) return $info;\r
-\r
- $a = get_app();\r
- $stamp1 = microtime(true);\r
- $f = file_get_contents("view/theme/$theme/theme.php");\r
- $a->save_timestamp($stamp1, "file");\r
-\r
- $r = preg_match("|/\*.*\*/|msU", $f, $m);\r
-\r
- if ($r) {\r
- $ll = explode("\n", $m[0]);\r
- foreach ( $ll as $l ) {\r
- $l = trim($l,"\t\n\r */");\r
- if ($l != "") {\r
- list($k, $v) = array_map("trim", explode(":", $l, 2));\r
- $k= strtolower($k);\r
- if ($k == "author") {\r
-\r
- $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);\r
- if ($r) {\r
- $info['author'][] = ['name'=>$m[1], 'link'=>$m[2]];\r
- } else {\r
- $info['author'][] = ['name'=>$v];\r
- }\r
- } elseif ($k == "maintainer") {\r
- $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);\r
- if ($r) {\r
- $info['maintainer'][] = ['name'=>$m[1], 'link'=>$m[2]];\r
- } else {\r
- $info['maintainer'][] = ['name'=>$v];\r
- }\r
- } else {\r
- if (array_key_exists($k, $info)) {\r
- $info[$k] = $v;\r
- }\r
- }\r
- }\r
- }\r
- }\r
- return $info;\r
- }\r
-\r
- /**\r
- * @brief Returns the theme's screenshot.\r
- *\r
- * The screenshot is expected as view/theme/$theme/screenshot.[png|jpg].\r
- *\r
- * @param sring $theme The name of the theme\r
- * @return string\r
- */\r
- public static function getScreenshot($theme)\r
- {\r
- $exts = ['.png','.jpg'];\r
- foreach ($exts as $ext) {\r
- if (file_exists('view/theme/' . $theme . '/screenshot' . $ext)) {\r
- return(System::baseUrl() . '/view/theme/' . $theme . '/screenshot' . $ext);\r
- }\r
- }\r
- return(System::baseUrl() . '/images/blank.png');\r
- }\r
-\r
- // install and uninstall theme\r
- public static function uninstall($theme)\r
- {\r
- logger("Addons: uninstalling theme " . $theme);\r
-\r
- include_once("view/theme/$theme/theme.php");\r
- if (function_exists("{$theme}_uninstall")) {\r
- $func = "{$theme}_uninstall";\r
- $func();\r
- }\r
- }\r
-\r
- public static function install($theme)\r
- {\r
- // silently fail if theme was removed\r
-\r
- if (! file_exists("view/theme/$theme/theme.php")) {\r
- return false;\r
- }\r
-\r
- logger("Addons: installing theme $theme");\r
-\r
- include_once("view/theme/$theme/theme.php");\r
-\r
- if (function_exists("{$theme}_install")) {\r
- $func = "{$theme}_install";\r
- $func();\r
- return true;\r
- } else {\r
- logger("Addons: FAILED installing theme $theme");\r
- return false;\r
- }\r
-\r
- }\r
-\r
- /**\r
- * @brief Get the full path to relevant theme files by filename\r
- *\r
- * This function search in the theme directory (and if not present in global theme directory)\r
- * if there is a directory with the file extension and for a file with the given\r
- * filename.\r
- *\r
- * @param string $file Filename\r
- * @param string $root Full root path\r
- * @return string Path to the file or empty string if the file isn't found\r
- */\r
- public static function getPathForFile($file, $root = '')\r
- {\r
- $file = basename($file);\r
-\r
- // Make sure $root ends with a slash / if it's not blank\r
- if ($root !== '' && $root[strlen($root)-1] !== '/') {\r
- $root = $root . '/';\r
- }\r
- $theme_info = get_app()->theme_info;\r
- if (is_array($theme_info) && array_key_exists('extends',$theme_info)) {\r
- $parent = $theme_info['extends'];\r
- } else {\r
- $parent = 'NOPATH';\r
- }\r
- $theme = current_theme();\r
- $thname = $theme;\r
- $ext = substr($file,strrpos($file,'.')+1);\r
- $paths = [\r
- "{$root}view/theme/$thname/$ext/$file",\r
- "{$root}view/theme/$parent/$ext/$file",\r
- "{$root}view/$ext/$file",\r
- ];\r
- foreach ($paths as $p) {\r
- // strpos() is faster than strstr when checking if one string is in another (http://php.net/manual/en/function.strstr.php)\r
- if (strpos($p,'NOPATH') !== false) {\r
- continue;\r
- } elseif (file_exists($p)) {\r
- return $p;\r
- }\r
- }\r
- return '';\r
- }\r
-}\r
+<?php
+/**
+ * @file src/Core/Theme.php
+ */
+namespace Friendica\Core;
+
+use Friendica\Core\System;
+
+require_once 'boot.php';
+
+/**
+ * Some functions to handle themes
+ */
+class Theme
+{
+ /**
+ * @brief Parse theme comment in search of theme infos.
+ *
+ * like
+ * \code
+ * ..* Name: My Theme
+ * * Description: My Cool Theme
+ * . * Version: 1.2.3
+ * * Author: John <profile url>
+ * * Maintainer: Jane <profile url>
+ * *
+ * \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 '';
+ }
+}
-<?php\r
-/**\r
- * @file src/Database/PostUpdate.php\r
- */\r
-namespace Friendica\Database;\r
-\r
-use Friendica\Core\Config;\r
-use Friendica\Database\DBM;\r
-use Friendica\Model\Contact;\r
-use Friendica\Model\GContact;\r
-use dba;\r
-\r
-require_once 'include/dba.php';\r
-\r
-/**\r
- * Post update functions\r
- */\r
-class PostUpdate\r
-{\r
- /**\r
- * @brief Calls the post update functions\r
- */\r
- public static function update()\r
- {\r
- if (!self::update1192()) {\r
- return;\r
- }\r
- if (!self::update1194()) {\r
- return;\r
- }\r
- if (!self::update1198()) {\r
- return;\r
- }\r
- if (!self::update1206()) {\r
- return;\r
- }\r
- }\r
-\r
- /**\r
- * @brief set the gcontact-id in all item entries\r
- *\r
- * This job has to be started multiple times until all entries are set.\r
- * It isn't started in the update function since it would consume too much time and can be done in the background.\r
- *\r
- * @return bool "true" when the job is done\r
- */\r
- private static function update1192()\r
- {\r
- // Was the script completed?\r
- if (Config::get("system", "post_update_version") >= 1192) {\r
- return true;\r
- }\r
-\r
- // Check if the first step is done (Setting "gcontact-id" in the item table)\r
- $r = dba::select('item', ['author-link', 'author-name', 'author-avatar', 'uid', 'network'], ['gcontact-id' => 0], ['limit' => 1000]);\r
- if (!$r) {\r
- // Are there unfinished entries in the thread table?\r
- $r = q("SELECT COUNT(*) AS `total` FROM `thread`\r
- INNER JOIN `item` ON `item`.`id` =`thread`.`iid`\r
- WHERE `thread`.`gcontact-id` = 0 AND\r
- (`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)");\r
-\r
- if ($r && ($r[0]["total"] == 0)) {\r
- Config::set("system", "post_update_version", 1192);\r
- return true;\r
- }\r
-\r
- // Update the thread table from the item table\r
- q("UPDATE `thread` INNER JOIN `item` ON `item`.`id`=`thread`.`iid`\r
- SET `thread`.`gcontact-id` = `item`.`gcontact-id`\r
- WHERE `thread`.`gcontact-id` = 0 AND\r
- (`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)");\r
-\r
- return false;\r
- }\r
-\r
- $item_arr = [];\r
- foreach ($r as $item) {\r
- $index = $item["author-link"]."-".$item["uid"];\r
- $item_arr[$index] = ["author-link" => $item["author-link"],\r
- "uid" => $item["uid"],\r
- "network" => $item["network"]];\r
- }\r
-\r
- // Set the "gcontact-id" in the item table and add a new gcontact entry if needed\r
- foreach ($item_arr as $item) {\r
- $gcontact_id = GContact::getId(["url" => $item['author-link'], "network" => $item['network'],\r
- "photo" => $item['author-avatar'], "name" => $item['author-name']]);\r
- dba::update('item', ['gcontact-id' => $gcontact_id], ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'gcontact-id' => 0]);\r
- }\r
- return false;\r
- }\r
-\r
- /**\r
- * @brief Updates the "global" field in the item table\r
- *\r
- * @return bool "true" when the job is done\r
- */\r
- private static function update1194()\r
- {\r
- // Was the script completed?\r
- if (Config::get("system", "post_update_version") >= 1194) {\r
- return true;\r
- }\r
-\r
- logger("Start", LOGGER_DEBUG);\r
-\r
- $end_id = Config::get("system", "post_update_1194_end");\r
- if (!$end_id) {\r
- $r = q("SELECT `id` FROM `item` WHERE `uid` != 0 ORDER BY `id` DESC LIMIT 1");\r
- if ($r) {\r
- Config::set("system", "post_update_1194_end", $r[0]["id"]);\r
- $end_id = Config::get("system", "post_update_1194_end");\r
- }\r
- }\r
-\r
- logger("End ID: ".$end_id, LOGGER_DEBUG);\r
-\r
- $start_id = Config::get("system", "post_update_1194_start");\r
-\r
- $query1 = "SELECT `item`.`id` FROM `item` ";\r
-\r
- $query2 = "INNER JOIN `item` AS `shadow` ON `item`.`uri` = `shadow`.`uri` AND `shadow`.`uid` = 0 ";\r
-\r
- $query3 = "WHERE `item`.`uid` != 0 AND `item`.`id` >= %d AND `item`.`id` <= %d\r
- AND `item`.`visible` AND NOT `item`.`private`\r
- AND NOT `item`.`deleted` AND NOT `item`.`moderated`\r
- AND `item`.`network` IN ('%s', '%s', '%s', '')\r
- AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''\r
- AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''\r
- AND NOT `item`.`global`";\r
-\r
- $r = q($query1.$query2.$query3." ORDER BY `item`.`id` LIMIT 1",\r
- intval($start_id), intval($end_id),\r
- dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS));\r
- if (!$r) {\r
- Config::set("system", "post_update_version", 1194);\r
- logger("Update is done", LOGGER_DEBUG);\r
- return true;\r
- } else {\r
- Config::set("system", "post_update_1194_start", $r[0]["id"]);\r
- $start_id = Config::get("system", "post_update_1194_start");\r
- }\r
-\r
- logger("Start ID: ".$start_id, LOGGER_DEBUG);\r
-\r
- $r = q($query1.$query2.$query3." ORDER BY `item`.`id` LIMIT 1000,1",\r
- intval($start_id), intval($end_id),\r
- dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS));\r
- if ($r)\r
- $pos_id = $r[0]["id"];\r
- else\r
- $pos_id = $end_id;\r
-\r
- logger("Progress: Start: ".$start_id." position: ".$pos_id." end: ".$end_id, LOGGER_DEBUG);\r
-\r
- q("UPDATE `item` ".$query2." SET `item`.`global` = 1 ".$query3,\r
- intval($start_id), intval($pos_id),\r
- dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS));\r
-\r
- logger("Done", LOGGER_DEBUG);\r
- }\r
-\r
- /**\r
- * @brief set the author-id and owner-id in all item entries\r
- *\r
- * This job has to be started multiple times until all entries are set.\r
- * It isn't started in the update function since it would consume too much time and can be done in the background.\r
- *\r
- * @return bool "true" when the job is done\r
- */\r
- private static function update1198()\r
- {\r
- // Was the script completed?\r
- if (Config::get("system", "post_update_version") >= 1198) {\r
- return true;\r
- }\r
-\r
- logger("Start", LOGGER_DEBUG);\r
-\r
- // Check if the first step is done (Setting "author-id" and "owner-id" in the item table)\r
- $r = dba::select('item', ['author-link', 'owner-link', 'uid'], ['author-id' => 0, 'owner-id' => 0], ['limit' => 1000]);\r
- if (!$r) {\r
- // Are there unfinished entries in the thread table?\r
- $r = q("SELECT COUNT(*) AS `total` FROM `thread`\r
- INNER JOIN `item` ON `item`.`id` =`thread`.`iid`\r
- WHERE `thread`.`author-id` = 0 AND `thread`.`owner-id` = 0 AND\r
- (`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)");\r
-\r
- if ($r && ($r[0]["total"] == 0)) {\r
- Config::set("system", "post_update_version", 1198);\r
- logger("Done", LOGGER_DEBUG);\r
- return true;\r
- }\r
-\r
- // Update the thread table from the item table\r
- $r = q("UPDATE `thread` INNER JOIN `item` ON `item`.`id`=`thread`.`iid`\r
- SET `thread`.`author-id` = `item`.`author-id`,\r
- `thread`.`owner-id` = `item`.`owner-id`\r
- WHERE `thread`.`author-id` = 0 AND `thread`.`owner-id` = 0 AND\r
- (`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)");\r
-\r
- logger("Updated threads", LOGGER_DEBUG);\r
- if (DBM::is_result($r)) {\r
- Config::set("system", "post_update_version", 1198);\r
- logger("Done", LOGGER_DEBUG);\r
- return true;\r
- }\r
- return false;\r
- }\r
-\r
- logger("Query done", LOGGER_DEBUG);\r
-\r
- $item_arr = [];\r
- foreach ($r as $item) {\r
- $index = $item["author-link"]."-".$item["owner-link"]."-".$item["uid"];\r
- $item_arr[$index] = ["author-link" => $item["author-link"],\r
- "owner-link" => $item["owner-link"],\r
- "uid" => $item["uid"]];\r
- }\r
-\r
- // Set the "gcontact-id" in the item table and add a new gcontact entry if needed\r
- foreach ($item_arr as $item) {\r
- $author_id = Contact::getIdForURL($item["author-link"], 0);\r
- $owner_id = Contact::getIdForURL($item["owner-link"], 0);\r
-\r
- if ($author_id == 0)\r
- $author_id = -1;\r
-\r
- if ($owner_id == 0)\r
- $owner_id = -1;\r
-\r
- 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]);\r
- }\r
-\r
- logger("Updated items", LOGGER_DEBUG);\r
- return false;\r
- }\r
-\r
- /**\r
- * @brief update the "last-item" field in the "self" contact\r
- *\r
- * This field avoids cost intensive calls in the admin panel and in "nodeinfo"\r
- *\r
- * @return bool "true" when the job is done\r
- */\r
- private static function update1206()\r
- {\r
- // Was the script completed?\r
- if (Config::get("system", "post_update_version") >= 1206) {\r
- return true;\r
- }\r
-\r
- logger("Start", LOGGER_DEBUG);\r
- $r = q("SELECT `contact`.`id`, `contact`.`last-item`,\r
- (SELECT MAX(`changed`) FROM `item` USE INDEX (`uid_wall_changed`) WHERE `wall` AND `uid` = `user`.`uid`) AS `lastitem_date`\r
- FROM `user`\r
- INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`");\r
-\r
- if (!DBM::is_result($r)) {\r
- return false;\r
- }\r
- foreach ($r as $user) {\r
- if (!empty($user["lastitem_date"]) && ($user["lastitem_date"] > $user["last-item"])) {\r
- dba::update('contact', ['last-item' => $user['lastitem_date']], ['id' => $user['id']]);\r
- }\r
- }\r
-\r
- Config::set("system", "post_update_version", 1206);\r
- logger("Done", LOGGER_DEBUG);\r
- return true;\r
- }\r
-}\r
+<?php
+/**
+ * @file src/Database/PostUpdate.php
+ */
+namespace Friendica\Database;
+
+use Friendica\Core\Config;
+use Friendica\Database\DBM;
+use Friendica\Model\Contact;
+use Friendica\Model\GContact;
+use dba;
+
+require_once 'include/dba.php';
+
+/**
+ * Post update functions
+ */
+class PostUpdate
+{
+ /**
+ * @brief Calls the post update functions
+ */
+ public static function update()
+ {
+ if (!self::update1192()) {
+ return;
+ }
+ if (!self::update1194()) {
+ return;
+ }
+ if (!self::update1198()) {
+ return;
+ }
+ if (!self::update1206()) {
+ return;
+ }
+ }
+
+ /**
+ * @brief set the gcontact-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 update1192()
+ {
+ // Was the script completed?
+ if (Config::get("system", "post_update_version") >= 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;
+ }
+}
-<?php\r
-\r
-namespace Friendica\Module;\r
-\r
-use Friendica\BaseModule;\r
-use Friendica\Core\System;\r
-use Friendica\Protocol\OStatus;\r
-\r
-/**\r
- * Provides public Atom feeds\r
- *\r
- * Currently supported:\r
- * - /feed/[nickname]/ => posts\r
- * - /feed/[nickname]/posts => posts\r
- * - /feed/[nickname]/comments => comments\r
- * - /feed/[nickname]/replies => comments\r
- * - /feed/[nickname]/activity => activity\r
- *\r
- * The nocache GET parameter is provided mainly for debug purposes, requires auth\r
- *\r
- * @brief Provides public Atom feeds\r
- *\r
- * @author Hypolite Petovan <mrpetovan@gmail.com>\r
- */\r
-class Feed extends BaseModule\r
-{\r
- public static function content()\r
- {\r
- $a = self::getApp();\r
-\r
- $last_update = x($_GET, 'last_update') ? $_GET['last_update'] : '';\r
- $nocache = x($_GET, 'nocache') && local_user();\r
-\r
- if ($a->argc < 2) {\r
- System::httpExit(400);\r
- }\r
-\r
- $type = null;\r
- if ($a->argc > 2) {\r
- $type = $a->argv[2];\r
- }\r
-\r
- switch ($type) {\r
- case 'posts':\r
- case 'comments':\r
- case 'activity':\r
- break;\r
- case 'replies':\r
- $type = 'comments';\r
- break;\r
- default:\r
- $type = 'posts';\r
- }\r
-\r
- $nickname = $a->argv[1];\r
- header("Content-type: application/atom+xml");\r
- echo OStatus::feed($nickname, $last_update, 10, $type, $nocache);\r
- killme();\r
- }\r
-}\r
+<?php
+
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Core\System;
+use Friendica\Protocol\OStatus;
+
+/**
+ * Provides public Atom feeds
+ *
+ * Currently supported:
+ * - /feed/[nickname]/ => 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 <mrpetovan@gmail.com>
+ */
+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();
+ }
+}
-<?php\r
-/**\r
- * @file src/Module/Logout.php\r
- */\r
-namespace Friendica\Module;\r
-\r
-use Friendica\BaseModule;\r
-use Friendica\Core\Addon;\r
-use Friendica\Core\L10n;\r
-\r
-require_once 'boot.php';\r
-require_once 'include/security.php';\r
-\r
-/**\r
- * Logout module\r
- *\r
- * @author Hypolite Petovan mrpetovan@gmail.com\r
- */\r
-class Logout extends BaseModule\r
-{\r
- /**\r
- * @brief Process logout requests\r
- */\r
- public static function init()\r
- {\r
- Addon::callHooks("logging_out");\r
- nuke_session();\r
- info(L10n::t('Logged out.') . EOL);\r
- goaway(self::getApp()->get_baseurl());\r
- }\r
-}\r
+<?php
+/**
+ * @file src/Module/Logout.php
+ */
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Core\Addon;
+use Friendica\Core\L10n;
+
+require_once 'boot.php';
+require_once 'include/security.php';
+
+/**
+ * Logout module
+ *
+ * @author Hypolite Petovan mrpetovan@gmail.com
+ */
+class Logout extends BaseModule
+{
+ /**
+ * @brief Process logout requests
+ */
+ public static function init()
+ {
+ Addon::callHooks("logging_out");
+ nuke_session();
+ info(L10n::t('Logged out.') . EOL);
+ goaway(self::getApp()->get_baseurl());
+ }
+}
-<?php\r
-\r
-namespace Friendica\Module;\r
-\r
-use Friendica\BaseModule;\r
-use Friendica\Content;\r
-\r
-/**\r
- * Oembed module\r
- *\r
- * Displays stored embed content based on a base64 hash of a remote URL\r
- *\r
- * Example: /oembed/aHR0cHM6Ly9...\r
- *\r
- * @author Hypolite Petovan <mrpetovan@gmail.com>\r
- */\r
-class Oembed extends BaseModule\r
-{\r
- public static function content()\r
- {\r
- $a = self::getApp();\r
-\r
- // Unused form: /oembed/b2h?url=...\r
- if ($a->argv[1] == 'b2h') {\r
- $url = ["", trim(hex2bin($_REQUEST['url']))];\r
- echo Content\OEmbed::replaceCallback($url);\r
- killme();\r
- }\r
-\r
- // Unused form: /oembed/h2b?text=...\r
- if ($a->argv[1] == 'h2b') {\r
- $text = trim(hex2bin($_REQUEST['text']));\r
- echo Content\OEmbed::HTML2BBCode($text);\r
- killme();\r
- }\r
-\r
- if ($a->argc == 2) {\r
- echo '<html><body>';\r
- $url = base64url_decode($a->argv[1]);\r
- $j = Content\OEmbed::fetchURL($url);\r
-\r
- // workaround for media.ccc.de (and any other endpoint that return size 0)\r
- if (substr($j->html, 0, 7) == "<iframe" && strstr($j->html, 'width="0"')) {\r
- $j->html = '<style>html,body{margin:0;padding:0;} iframe{width:100%;height:100%;}</style>' . $j->html;\r
- $j->html = str_replace('width="0"', '', $j->html);\r
- $j->html = str_replace('height="0"', '', $j->html);\r
- }\r
- echo $j->html;\r
- echo '</body></html>';\r
- }\r
- killme();\r
- }\r
-}\r
+<?php
+
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Content;
+
+/**
+ * Oembed module
+ *
+ * Displays stored embed content based on a base64 hash of a remote URL
+ *
+ * Example: /oembed/aHR0cHM6Ly9...
+ *
+ * @author Hypolite Petovan <mrpetovan@gmail.com>
+ */
+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 '<html><body>';
+ $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) == "<iframe" && strstr($j->html, 'width="0"')) {
+ $j->html = '<style>html,body{margin:0;padding:0;} iframe{width:100%;height:100%;}</style>' . $j->html;
+ $j->html = str_replace('width="0"', '', $j->html);
+ $j->html = str_replace('height="0"', '', $j->html);
+ }
+ echo $j->html;
+ echo '</body></html>';
+ }
+ killme();
+ }
+}
-<?php\r
-\r
-/**\r
- * Throwable exceptions to return HTTP status code\r
- *\r
- * This list of Exception has be extracted from\r
- * here http://racksburg.com/choosing-an-http-status-code/\r
- */\r
-\r
-namespace Friendica\Network;\r
-\r
-use Exception;\r
-\r
-class HTTPException extends Exception\r
-{\r
- var $httpcode = 200;\r
- var $httpdesc = "";\r
-\r
- public function __construct($message = '', $code = 0, Exception $previous = null)\r
- {\r
- if ($this->httpdesc == '') {\r
- $classname = str_replace('Exception', '', str_replace('Friendica\Network\HTTPException\\', '', get_class($this)));\r
- $this->httpdesc = preg_replace("|([a-z])([A-Z])|",'$1 $2', $classname);\r
- }\r
- parent::__construct($message, $code, $previous);\r
- }\r
-}\r
+<?php
+
+/**
+ * Throwable exceptions to return HTTP status code
+ *
+ * This list of Exception has be extracted from
+ * here http://racksburg.com/choosing-an-http-status-code/
+ */
+
+namespace Friendica\Network;
+
+use Exception;
+
+class HTTPException extends Exception
+{
+ var $httpcode = 200;
+ var $httpdesc = "";
+
+ public function __construct($message = '', $code = 0, Exception $previous = null)
+ {
+ if ($this->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);
+ }
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class BadGatewayException extends HTTPException\r
-{\r
- var $httpcode = 502;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class BadGatewayException extends HTTPException
+{
+ var $httpcode = 502;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class BadRequestException extends HTTPException\r
-{\r
- var $httpcode = 400;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class BadRequestException extends HTTPException
+{
+ var $httpcode = 400;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class ConflictException extends HTTPException\r
-{\r
- var $httpcode = 409;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class ConflictException extends HTTPException
+{
+ var $httpcode = 409;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class ExpectationFailedException extends HTTPException\r
-{\r
- var $httpcode = 417;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class ExpectationFailedException extends HTTPException
+{
+ var $httpcode = 417;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class ForbiddenException extends HTTPException\r
-{\r
- var $httpcode = 403;\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class ForbiddenException extends HTTPException
+{
+ var $httpcode = 403;
}
\ No newline at end of file
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class GatewayTimeoutException extends HTTPException\r
-{\r
- var $httpcode = 504;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class GatewayTimeoutException extends HTTPException
+{
+ var $httpcode = 504;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class GoneException extends HTTPException\r
-{\r
- var $httpcode = 410;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class GoneException extends HTTPException
+{
+ var $httpcode = 410;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class ImATeapotException extends HTTPException\r
-{\r
- var $httpcode = 418;\r
- var $httpdesc = "I'm A Teapot";\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class ImATeapotException extends HTTPException
+{
+ var $httpcode = 418;
+ var $httpdesc = "I'm A Teapot";
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class InternalServerErrorException extends HTTPException\r
-{\r
- var $httpcode = 500;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class InternalServerErrorException extends HTTPException
+{
+ var $httpcode = 500;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class LenghtRequiredException extends HTTPException\r
-{\r
- var $httpcode = 411;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class LenghtRequiredException extends HTTPException
+{
+ var $httpcode = 411;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class MethodNotAllowedException extends HTTPException\r
-{\r
- var $httpcode = 405;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class MethodNotAllowedException extends HTTPException
+{
+ var $httpcode = 405;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class NonAcceptableException extends HTTPException\r
-{\r
- var $httpcode = 406;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class NonAcceptableException extends HTTPException
+{
+ var $httpcode = 406;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class NotFoundException extends HTTPException {\r
- var $httpcode = 404;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class NotFoundException extends HTTPException {
+ var $httpcode = 404;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class NotImplementedException extends HTTPException\r
-{\r
- var $httpcode = 501;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class NotImplementedException extends HTTPException
+{
+ var $httpcode = 501;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class PreconditionFailedException extends HTTPException\r
-{\r
- var $httpcode = 412;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class PreconditionFailedException extends HTTPException
+{
+ var $httpcode = 412;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class ServiceUnavaiableException extends HTTPException\r
-{\r
- var $httpcode = 503;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class ServiceUnavaiableException extends HTTPException
+{
+ var $httpcode = 503;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class TooManyRequestsException extends HTTPException\r
-{\r
- var $httpcode = 429;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class TooManyRequestsException extends HTTPException
+{
+ var $httpcode = 429;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class UnauthorizedException extends HTTPException\r
-{\r
- var $httpcode = 401;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class UnauthorizedException extends HTTPException
+{
+ var $httpcode = 401;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class UnprocessableEntityException extends HTTPException\r
-{\r
- var $httpcode = 422;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class UnprocessableEntityException extends HTTPException
+{
+ var $httpcode = 422;
+}
-<?php\r
-\r
-namespace Friendica\Network\HTTPException;\r
-\r
-use Friendica\Network\HTTPException;\r
-\r
-class UnsupportedMediaTypeException extends HTTPException\r
-{\r
- var $httpcode = 415;\r
-}\r
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class UnsupportedMediaTypeException extends HTTPException
+{
+ var $httpcode = 415;
+}
-<?php\r
-/**\r
- * @file src/Render/FriendicaSmarty.php\r
- */\r
-namespace Friendica\Render;\r
-\r
-use Smarty;\r
-\r
-/**\r
- * Friendica extension of the Smarty3 template engine\r
- *\r
- * @author Hypolite Petovan <mrpetovan@gmail.com>\r
- */\r
-class FriendicaSmarty extends Smarty\r
-{\r
- const SMARTY3_TEMPLATE_FOLDER = 'templates';\r
-\r
- public $filename;\r
-\r
- function __construct()\r
- {\r
- parent::__construct();\r
-\r
- $a = get_app();\r
- $theme = current_theme();\r
-\r
- // setTemplateDir can be set to an array, which Smarty will parse in order.\r
- // The order is thus very important here\r
- $template_dirs = ['theme' => "view/theme/$theme/" . self::SMARTY3_TEMPLATE_FOLDER . "/"];\r
- if (x($a->theme_info, "extends")) {\r
- $template_dirs = $template_dirs + ['extends' => "view/theme/" . $a->theme_info["extends"] . "/" . self::SMARTY3_TEMPLATE_FOLDER . "/"];\r
- }\r
-\r
- $template_dirs = $template_dirs + ['base' => "view/" . self::SMARTY3_TEMPLATE_FOLDER . "/"];\r
- $this->setTemplateDir($template_dirs);\r
-\r
- $this->setCompileDir('view/smarty3/compiled/');\r
- $this->setConfigDir('view/smarty3/config/');\r
- $this->setCacheDir('view/smarty3/cache/');\r
-\r
- $this->left_delimiter = $a->get_template_ldelim('smarty3');\r
- $this->right_delimiter = $a->get_template_rdelim('smarty3');\r
-\r
- // Don't report errors so verbosely\r
- $this->error_reporting = E_ALL & ~E_NOTICE;\r
- }\r
-\r
- function parsed($template = '')\r
- {\r
- if ($template) {\r
- return $this->fetch('string:' . $template);\r
- }\r
- return $this->fetch('file:' . $this->filename);\r
- }\r
-\r
+<?php
+/**
+ * @file src/Render/FriendicaSmarty.php
+ */
+namespace Friendica\Render;
+
+use Smarty;
+
+/**
+ * Friendica extension of the Smarty3 template engine
+ *
+ * @author Hypolite Petovan <mrpetovan@gmail.com>
+ */
+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
-<?php\r
-/**\r
- * @file src/Render/ITemplateEngine.php\r
- */\r
-\r
-namespace Friendica\Render;\r
-\r
-/**\r
- * Interface for template engines\r
- */\r
-interface ITemplateEngine\r
-{\r
- public function replaceMacros($s, $v);\r
- public function getTemplateFile($file, $root = '');\r
-}\r
+<?php
+/**
+ * @file src/Render/ITemplateEngine.php
+ */
+
+namespace Friendica\Render;
+
+/**
+ * Interface for template engines
+ */
+interface ITemplateEngine
+{
+ public function replaceMacros($s, $v);
+ public function getTemplateFile($file, $root = '');
+}