* @file bin/worker.php
* @brief Starts the background processing
*/
-
use Friendica\App;
-use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\Worker;
-use Friendica\Core\L10n;
// Get options
$shortopts = 'sn';
if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
$directory = dirname($_SERVER["argv"][0]);
- if (substr($directory, 0, 1) != "/") {
- $directory = $_SERVER["PWD"]."/".$directory;
+ if (substr($directory, 0, 1) != '/') {
+ $directory = $_SERVER["PWD"] . '/' . $directory;
}
- $directory = realpath($directory."/..");
+ $directory = realpath($directory . '/..');
chdir($directory);
}
$a = new App(dirname(__DIR__));
-Config::load();
-
-$lang = L10n::getBrowserLanguage();
-L10n::loadTranslationTable($lang);
-
// Check the database structure and possibly fixes it
check_db(true);
// Quit when in maintenance
-if (Config::get('system', 'maintenance', false, true)) {
+if (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED)) {
return;
}
$a->setBaseURL(Config::get('system', 'url'));
-Addon::loadHooks();
-
$spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options);
if ($spawn) {
Worker::unclaimProcess();
Worker::endProcess();
-
-killme();
define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily');
define('FRIENDICA_VERSION', '2018.12-dev');
define('DFRN_PROTOCOL_VERSION', '2.23');
-define('DB_UPDATE_VERSION', 1287);
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
/**
define('LOGGER_ALL', 5);
/* @}*/
-/**
- * @name Cache
- * @deprecated since version 3.6
- * @see Cache
- *
- * Cache levels
- * @{
- */
-define('CACHE_MONTH', Cache::MONTH);
-define('CACHE_WEEK', Cache::WEEK);
-define('CACHE_DAY', Cache::DAY);
-define('CACHE_HOUR', Cache::HOUR);
-define('CACHE_HALF_HOUR', Cache::HALF_HOUR);
-define('CACHE_QUARTER_HOUR', Cache::QUARTER_HOUR);
-define('CACHE_FIVE_MINUTES', Cache::FIVE_MINUTES);
-define('CACHE_MINUTE', Cache::MINUTE);
-/* @}*/
-
/**
* @name Register
*
*/
define('MAX_LIKERS', 75);
-/**
- * Communication timeout
- */
-define('ZCURL_TIMEOUT', (-1));
-
/**
* @name Notify
*
define('SR_SCOPE_TAGS', 'tags');
/* @}*/
-/**
- * Lowest possible date time value
- */
-define('NULL_DATE', '0001-01-01 00:00:00');
-
// Normally this constant is defined - but not if "pcntl" isn't installed
if (!defined("SIGTERM")) {
define("SIGTERM", 15);
}
}
-/**
- * Sets the base url for use in cmdline programs which don't have
- * $_SERVER variables
- *
- * @param object $a App
- */
-function check_url(App $a)
-{
- $url = Config::get('system', 'url');
-
- // if the url isn't set or the stored url is radically different
- // than the currently visited url, store the current value accordingly.
- // "Radically different" ignores common variations such as http vs https
- // and www.example.com vs example.com.
- // We will only change the url to an ip address if there is no existing setting
-
- if (empty($url) || (!link_compare($url, System::baseUrl())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $a->getHostName()))) {
- Config::set('system', 'url', System::baseUrl());
- }
-
- return;
-}
-
/**
* @brief Automatic database updates
* @param object $a App
exit();
}
-/**
- * @brief Redirect to another URL and terminate this process.
- */
-function goaway($path)
-{
- if (strstr(normalise_link($path), 'http://')) {
- $url = $path;
- } else {
- $url = System::baseUrl() . '/' . ltrim($path, '/');
- }
-
- header("Location: $url");
- killme();
-}
-
/**
* @brief Returns the user id of locally logged in user or false.
*
; dbclean_expire_conversation (Integer)
; When DBClean is enabled, any entry in the conversation table will be deleted after this many days.
-; These data are normally needed only for debugging purposes and they are safe to delete.
+: This data is used for ActivityPub, so it shouldn't be lower than the average duration of a discussion.
dbclean_expire_conversation = 90
+; dbclean-expire-limit (Integer)
+; This defines the number of items that are to be deleted in a single call.
+; Reduce this value when you are getting memory issues.
+dbclean-expire-limit = 1000
+
; diaspora_test (Boolean)
; For development only. Disables the message transfer.
diaspora_test = false
; Disable the exposition check against the remote haveibeenpwned API on password change.
disable_password_exposed = false
+; disable_polling (Boolean)
+; Disable the polling of DFRN and OStatus contacts through onepoll.php.
+disable_polling = false
+
; dlogfile (Path)
; location of the developer log file.
dlogfile =
; For instance if your URL is 'http://example.com/directory/subdirectory', set urlpath to 'directory/subdirectory'.
urlpath =
+; username_min_length (Integer)
+; The minimum character length a username can be.
+; This length is check once the username has been trimmed and multiple spaces have been collapsed into one.
+; Minimum for this config value is 1. Maximum is 64 as the resulting profile URL mustn't be longer than 255 chars.
+username_min_length = 3
+
+; username_max_length (Integer)
+; The maximum character length a username can be.
+; This length is check once the username has been trimmed and multiple spaces have been collapsed into one.
+; Minimum for this config value is 1. Maximum is 64 as the resulting profile URL mustn't be longer than 255 chars.
+username_max_length = 48
+
; worker_cooldown (Integer)
; Cooldown period in seconds after each worker function call.
worker_cooldown = 0
+++ /dev/null
-{
- "addon": {
- "comment": "registered addons",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": ""},
- "name": {"type": "varchar(50)", "not null": "1", "default": "", "comment": "addon base (file)name"},
- "version": {"type": "varchar(50)", "not null": "1", "default": "", "comment": "currently unused"},
- "installed": {"type": "boolean", "not null": "1", "default": "0", "comment": "currently always 1"},
- "hidden": {"type": "boolean", "not null": "1", "default": "0", "comment": "currently unused"},
- "timestamp": {"type": "int unsigned", "not null": "1", "default": "0", "comment": "file timestamp to check for reloads"},
- "plugin_admin": {"type": "boolean", "not null": "1", "default": "0", "comment": "1 = has admin config, 0 = has no admin config"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "name": ["UNIQUE", "name"]
- }
- },
- "apcontact": {
- "comment": "ActivityPub compatible contacts - used in the ActivityPub implementation",
- "fields": {
- "url": {"type": "varbinary(255)", "not null": "1", "primary": "1", "comment": "URL of the contact"},
- "uuid": {"type": "varchar(255)", "comment": ""},
- "type": {"type": "varchar(20)", "not null": "1", "comment": ""},
- "following": {"type": "varchar(255)", "comment": ""},
- "followers": {"type": "varchar(255)", "comment": ""},
- "inbox": {"type": "varchar(255)", "not null": "1", "comment": ""},
- "outbox": {"type": "varchar(255)", "comment": ""},
- "sharedinbox": {"type": "varchar(255)", "comment": ""},
- "nick": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "name": {"type": "varchar(255)", "comment": ""},
- "about": {"type": "text", "comment": ""},
- "photo": {"type": "varchar(255)", "comment": ""},
- "addr": {"type": "varchar(255)", "comment": ""},
- "alias": {"type": "varchar(255)", "comment": ""},
- "pubkey": {"type": "text", "comment": ""},
- "baseurl": {"type": "varchar(255)", "comment": "baseurl of the ap contact"},
- "updated": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""}
-
- },
- "indexes": {
- "PRIMARY": ["url"],
- "addr": ["addr(32)"],
- "url": ["followers(190)"]
- }
- },
- "attach": {
- "comment": "file attachments",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "generated index"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "Owner User id"},
- "hash": {"type": "varchar(64)", "not null": "1", "default": "", "comment": "hash"},
- "filename": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "filename of original"},
- "filetype": {"type": "varchar(64)", "not null": "1", "default": "", "comment": "mimetype"},
- "filesize": {"type": "int unsigned", "not null": "1", "default": "0", "comment": "size in bytes"},
- "data": {"type": "longblob", "not null": "1", "comment": "file data"},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "creation time"},
- "edited": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "last edit time"},
- "allow_cid": {"type": "mediumtext", "comment": "Access Control - list of allowed contact.id '<19><78>"},
- "allow_gid": {"type": "mediumtext", "comment": "Access Control - list of allowed groups"},
- "deny_cid": {"type": "mediumtext", "comment": "Access Control - list of denied contact.id"},
- "deny_gid": {"type": "mediumtext", "comment": "Access Control - list of denied groups"}
- },
- "indexes": {
- "PRIMARY": ["id"]
- }
- },
- "auth_codes": {
- "comment": "OAuth usage",
- "fields": {
- "id": {"type": "varchar(40)", "not null": "1", "primary": "1", "comment": ""},
- "client_id": {"type": "varchar(20)", "not null": "1", "default": "", "relation": {"clients": "client_id"}, "comment": ""},
- "redirect_uri": {"type": "varchar(200)", "not null": "1", "default": "", "comment": ""},
- "expires": {"type": "int", "not null": "1", "default": "0", "comment": ""},
- "scope": {"type": "varchar(250)", "not null": "1", "default": "", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"]
- }
- },
- "cache": {
- "comment": "Stores temporary data",
- "fields": {
- "k": {"type": "varbinary(255)", "not null": "1", "primary": "1", "comment": "cache key"},
- "v": {"type": "mediumtext", "comment": "cached serialized value"},
- "expires": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "datetime of cache expiration"},
- "updated": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "datetime of cache insertion"}
- },
- "indexes": {
- "PRIMARY": ["k"],
- "k_expires": ["k", "expires"]
- }
- },
- "challenge": {
- "comment": "",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "challenge": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "dfrn-id": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "expire": {"type": "int unsigned", "not null": "1", "default": "0", "comment": ""},
- "type": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "last_update": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"]
- }
- },
- "clients": {
- "comment": "OAuth usage",
- "fields": {
- "client_id": {"type": "varchar(20)", "not null": "1", "primary": "1", "comment": ""},
- "pw": {"type": "varchar(20)", "not null": "1", "default": "", "comment": ""},
- "redirect_uri": {"type": "varchar(200)", "not null": "1", "default": "", "comment": ""},
- "name": {"type": "text", "comment": ""},
- "icon": {"type": "text", "comment": ""},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"}
- },
- "indexes": {
- "PRIMARY": ["client_id"]
- }
- },
- "config": {
- "comment": "main configuration storage",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": ""},
- "cat": {"type": "varbinary(50)", "not null": "1", "default": "", "comment": ""},
- "k": {"type": "varbinary(50)", "not null": "1", "default": "", "comment": ""},
- "v": {"type": "mediumtext", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "cat_k": ["UNIQUE", "cat", "k"]
- }
- },
- "contact": {
- "comment": "contact table",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "Owner User id"},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "self": {"type": "boolean", "not null": "1", "default": "0", "comment": "1 if the contact is the user him/her self"},
- "remote_self": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "rel": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": "The kind of the relation between the user and the contact"},
- "duplex": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "network": {"type": "char(4)", "not null": "1", "default": "", "comment": "Network protocol of the contact"},
- "name": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "Name that this contact is known by"},
- "nick": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "Nick- and user name of the contact"},
- "location": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "about": {"type": "text", "comment": ""},
- "keywords": {"type": "text", "comment": "public keywords (interests) of the contact"},
- "gender": {"type": "varchar(32)", "not null": "1", "default": "", "comment": ""},
- "xmpp": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "attag": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "avatar": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "photo": {"type": "varchar(255)", "default": "", "comment": "Link to the profile photo of the contact"},
- "thumb": {"type": "varchar(255)", "default": "", "comment": "Link to the profile photo (thumb size)"},
- "micro": {"type": "varchar(255)", "default": "", "comment": "Link to the profile photo (micro size)"},
- "site-pubkey": {"type": "text", "comment": ""},
- "issued-id": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "dfrn-id": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "url": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "nurl": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "addr": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "alias": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "pubkey": {"type": "text", "comment": "RSA public key 4096 bit"},
- "prvkey": {"type": "text", "comment": "RSA private key 4096 bit"},
- "batch": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "request": {"type": "varchar(255)", "comment": ""},
- "notify": {"type": "varchar(255)", "comment": ""},
- "poll": {"type": "varchar(255)", "comment": ""},
- "confirm": {"type": "varchar(255)", "comment": ""},
- "poco": {"type": "varchar(255)", "comment": ""},
- "aes_allow": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "ret-aes": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "usehub": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "subhub": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "hub-verify": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "last-update": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Date of the last try to update the contact info"},
- "success_update": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Date of the last successful contact update"},
- "failure_update": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Date of the last failed update"},
- "name-date": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "uri-date": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "avatar-date": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "term-date": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "last-item": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "date of the last post"},
- "priority": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": ""},
- "blocked": {"type": "boolean", "not null": "1", "default": "1", "comment": ""},
- "readonly": {"type": "boolean", "not null": "1", "default": "0", "comment": "posts of the contact are readonly"},
- "writable": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "forum": {"type": "boolean", "not null": "1", "default": "0", "comment": "contact is a forum"},
- "prv": {"type": "boolean", "not null": "1", "default": "0", "comment": "contact is a private group"},
- "contact-type": {"type": "tinyint", "not null": "1", "default": "0", "comment": ""},
- "hidden": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "archive": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "pending": {"type": "boolean", "not null": "1", "default": "1", "comment": ""},
- "deleted": {"type": "boolean", "not null": "1", "default": "0", "comment": "Contact has been deleted"},
- "rating": {"type": "tinyint", "not null": "1", "default": "0", "comment": ""},
- "reason": {"type": "text", "comment": ""},
- "closeness": {"type": "tinyint unsigned", "not null": "1", "default": "99", "comment": ""},
- "info": {"type": "mediumtext", "comment": ""},
- "profile-id": {"type": "int unsigned", "not null": "1", "default": "0", "comment": ""},
- "bdyear": {"type": "varchar(4)", "not null": "1", "default": "", "comment": ""},
- "bd": {"type": "date", "not null": "1", "default": "0001-01-01", "comment": ""},
- "notify_new_posts": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "fetch_further_information": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": ""},
- "ffi_keyword_blacklist": {"type": "text", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "uid_name": ["uid", "name(190)"],
- "self_uid": ["self", "uid"],
- "alias_uid": ["alias(32)", "uid"],
- "pending_uid": ["pending", "uid"],
- "blocked_uid": ["blocked", "uid"],
- "uid_rel_network_poll": ["uid", "rel", "network", "poll(64)", "archive"],
- "uid_network_batch": ["uid", "network", "batch(64)"],
- "addr_uid": ["addr(32)", "uid"],
- "nurl_uid": ["nurl(32)", "uid"],
- "nick_uid": ["nick(32)", "uid"],
- "dfrn-id": ["dfrn-id(64)"],
- "issued-id": ["issued-id(64)"]
- }
- },
- "conv": {
- "comment": "private messages",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "guid": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "A unique identifier for this conversation"},
- "recips": {"type": "text", "comment": "sender_handle;recipient_handle"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "Owner User id"},
- "creator": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "handle of creator"},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "creation timestamp"},
- "updated": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "edited timestamp"},
- "subject": {"type": "text", "comment": "subject of initial message"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "uid": ["uid"]
- }
- },
- "conversation": {
- "comment": "Raw data and structure information for messages",
- "fields": {
- "item-uri": {"type": "varbinary(255)", "not null": "1", "primary": "1", "comment": "Original URI of the item - unrelated to the table with the same name"},
- "reply-to-uri": {"type": "varbinary(255)", "not null": "1", "default": "", "comment": "URI to which this item is a reply"},
- "conversation-uri": {"type": "varbinary(255)", "not null": "1", "default": "", "comment": "GNU Social conversation URI"},
- "conversation-href": {"type": "varbinary(255)", "not null": "1", "default": "", "comment": "GNU Social conversation link"},
- "protocol": {"type": "tinyint unsigned", "not null": "1", "default": "255", "comment": "The protocol of the item"},
- "source": {"type": "mediumtext", "comment": "Original source"},
- "received": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Receiving date"}
- },
- "indexes": {
- "PRIMARY": ["item-uri"],
- "conversation-uri": ["conversation-uri"],
- "received": ["received"]
- }
- },
- "diaspora-interaction": {
- "comment": "Signed Diaspora Interaction",
- "fields": {
- "uri-id": {"type": "int unsigned", "not null": "1", "primary": "1", "relation": {"item-uri": "id"}, "comment": "Id of the item-uri table entry that contains the item uri"},
- "interaction": {"type": "mediumtext", "comment": "The Diaspora interaction"}
- },
- "indexes": {
- "PRIMARY": ["uri-id"]
- }
- },
- "event": {
- "comment": "Events",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "guid": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "Owner User id"},
- "cid": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"contact": "id"}, "comment": "contact_id (ID of the contact in contact table)"},
- "uri": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "creation time"},
- "edited": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "last edit time"},
- "start": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "event start time"},
- "finish": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "event end time"},
- "summary": {"type": "text", "comment": "short description or title of the event"},
- "desc": {"type": "text", "comment": "event description"},
- "location": {"type": "text", "comment": "event location"},
- "type": {"type": "varchar(20)", "not null": "1", "default": "", "comment": "event or birthday"},
- "nofinish": {"type": "boolean", "not null": "1", "default": "0", "comment": "if event does have no end this is 1"},
- "adjust": {"type": "boolean", "not null": "1", "default": "1", "comment": "adjust to timezone of the recipient (0 or 1)"},
- "ignore": {"type": "boolean", "not null": "1", "default": "0", "comment": "0 or 1"},
- "allow_cid": {"type": "mediumtext", "comment": "Access Control - list of allowed contact.id '<19><78>'"},
- "allow_gid": {"type": "mediumtext", "comment": "Access Control - list of allowed groups"},
- "deny_cid": {"type": "mediumtext", "comment": "Access Control - list of denied contact.id"},
- "deny_gid": {"type": "mediumtext", "comment": "Access Control - list of denied groups"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "uid_start": ["uid", "start"]
- }
- },
- "fcontact": {
- "comment": "Diaspora compatible contacts - used in the Diaspora implementation",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "guid": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "unique id"},
- "url": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "name": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "photo": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "request": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "nick": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "addr": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "batch": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "notify": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "poll": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "confirm": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "priority": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": ""},
- "network": {"type": "char(4)", "not null": "1", "default": "", "comment": ""},
- "alias": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "pubkey": {"type": "text", "comment": ""},
- "updated": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "addr": ["addr(32)"],
- "url": ["UNIQUE", "url(190)"]
- }
- },
- "fsuggest": {
- "comment": "friend suggestion stuff",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": ""},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"},
- "cid": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"contact": "id"}, "comment": ""},
- "name": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "url": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "request": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "photo": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "note": {"type": "text", "comment": ""},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"]
- }
- },
- "gcign": {
- "comment": "contacts ignored by friend suggestions",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "Local User id"},
- "gcid": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"gcontact": "id"}, "comment": "gcontact.id of ignored contact"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "uid": ["uid"],
- "gcid": ["gcid"]
- }
- },
- "gcontact": {
- "comment": "global contacts",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "name": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "Name that this contact is known by"},
- "nick": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "Nick- and user name of the contact"},
- "url": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "Link to the contacts profile page"},
- "nurl": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "photo": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "Link to the profile photo"},
- "connect": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "updated": {"type": "datetime", "default": "0001-01-01 00:00:00", "comment": ""},
- "last_contact": {"type": "datetime", "default": "0001-01-01 00:00:00", "comment": ""},
- "last_failure": {"type": "datetime", "default": "0001-01-01 00:00:00", "comment": ""},
- "location": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "about": {"type": "text", "comment": ""},
- "keywords": {"type": "text", "comment": "puplic keywords (interests)"},
- "gender": {"type": "varchar(32)", "not null": "1", "default": "", "comment": ""},
- "birthday": {"type": "varchar(32)", "not null": "1", "default": "0001-01-01", "comment": ""},
- "community": {"type": "boolean", "not null": "1", "default": "0", "comment": "1 if contact is forum account"},
- "contact-type": {"type": "tinyint", "not null": "1", "default": "-1", "comment": ""},
- "hide": {"type": "boolean", "not null": "1", "default": "0", "comment": "1 = should be hidden from search"},
- "nsfw": {"type": "boolean", "not null": "1", "default": "0", "comment": "1 = contact posts nsfw content"},
- "network": {"type": "char(4)", "not null": "1", "default": "", "comment": "social network protocol"},
- "addr": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "notify": {"type": "varchar(255)", "comment": ""},
- "alias": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "generation": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": ""},
- "server_url": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "baseurl of the contacts server"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "nurl": ["UNIQUE", "nurl(190)"],
- "name": ["name(64)"],
- "nick": ["nick(32)"],
- "addr": ["addr(64)"],
- "hide_network_updated": ["hide", "network", "updated"],
- "updated": ["updated"]
- }
- },
- "glink": {
- "comment": "'friends of friends' linkages derived from poco",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "cid": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"contact": "id"}, "comment": ""},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"},
- "gcid": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"gcontact": "id"}, "comment": ""},
- "zcid": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"gcontact": "id"}, "comment": ""},
- "updated": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "cid_uid_gcid_zcid": ["UNIQUE", "cid", "uid", "gcid", "zcid"],
- "gcid": ["gcid"]
- }
- },
- "group": {
- "comment": "privacy groups, group info",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "Owner User id"},
- "visible": {"type": "boolean", "not null": "1", "default": "0", "comment": "1 indicates the member list is not private"},
- "deleted": {"type": "boolean", "not null": "1", "default": "0", "comment": "1 indicates the group has been deleted"},
- "name": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "human readable name of group"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "uid": ["uid"]
- }
- },
- "group_member": {
- "comment": "privacy groups, member info",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "gid": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"group": "id"}, "comment": "groups.id of the associated group"},
- "contact-id": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"contact": "id"}, "comment": "contact.id of the member assigned to the associated group"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "contactid": ["contact-id"],
- "gid_contactid": ["UNIQUE", "gid", "contact-id"]
- }
- },
- "gserver": {
- "comment": "Global servers",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "url": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "nurl": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "version": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "site_name": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "info": {"type": "text", "comment": ""},
- "register_policy": {"type": "tinyint", "not null": "1", "default": "0", "comment": ""},
- "registered-users": {"type": "int unsigned", "not null": "1", "default": "0", "comment": "Number of registered users"},
- "poco": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "noscrape": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "network": {"type": "char(4)", "not null": "1", "default": "", "comment": ""},
- "platform": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "relay-subscribe": {"type": "boolean", "not null": "1", "default": "0", "comment": "Has the server subscribed to the relay system"},
- "relay-scope": {"type": "varchar(10)", "not null": "1", "default": "", "comment": "The scope of messages that the server wants to get"},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "last_poco_query": {"type": "datetime", "default": "0001-01-01 00:00:00", "comment": ""},
- "last_contact": {"type": "datetime", "default": "0001-01-01 00:00:00", "comment": ""},
- "last_failure": {"type": "datetime", "default": "0001-01-01 00:00:00", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "nurl": ["UNIQUE", "nurl(190)"]
- }
- },
- "gserver-tag": {
- "comment": "Tags that the server has subscribed",
- "fields": {
- "gserver-id": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"gserver": "id"}, "primary": "1", "comment": "The id of the gserver"},
- "tag": {"type": "varchar(100)", "not null": "1", "default": "", "primary": "1", "comment": "Tag that the server has subscribed"}
- },
- "indexes": {
- "PRIMARY": ["gserver-id", "tag"],
- "tag": ["tag"]
- }
- },
- "hook": {
- "comment": "addon hook registry",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "hook": {"type": "varbinary(100)", "not null": "1", "default": "", "comment": "name of hook"},
- "file": {"type": "varbinary(200)", "not null": "1", "default": "", "comment": "relative filename of hook handler"},
- "function": {"type": "varbinary(200)", "not null": "1", "default": "", "comment": "function name of hook handler"},
- "priority": {"type": "smallint unsigned", "not null": "1", "default": "0", "comment": "not yet implemented - can be used to sort conflicts in hook handling by calling handlers in priority order"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "hook_file_function": ["UNIQUE", "hook", "file", "function"]
- }
- },
- "intro": {
- "comment": "",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"},
- "fid": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"fcontact": "id"}, "comment": ""},
- "contact-id": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"contact": "id"}, "comment": ""},
- "knowyou": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "duplex": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "note": {"type": "text", "comment": ""},
- "hash": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "datetime": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "blocked": {"type": "boolean", "not null": "1", "default": "1", "comment": ""},
- "ignore": {"type": "boolean", "not null": "1", "default": "0", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"]
- }
- },
- "item": {
- "comment": "Structure for all posts",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "relation": {"thread": "iid"}},
- "guid": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "A unique identifier for this item"},
- "uri": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "uri-id": {"type": "int unsigned", "relation": {"item-uri": "id"}, "comment": "Id of the item-uri table entry that contains the item uri"},
- "uri-hash": {"type": "varchar(80)", "not null": "1", "default": "", "comment": "RIPEMD-128 hash from uri"},
- "parent": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"item": "id"}, "comment": "item.id of the parent to this item if it is a reply of some form; otherwise this must be set to the id of this item"},
- "parent-uri": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "uri of the parent to this item"},
- "parent-uri-id": {"type": "int unsigned", "relation": {"item-uri": "id"}, "comment": "Id of the item-uri table that contains the parent uri"},
- "thr-parent": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "If the parent of this item is not the top-level item in the conversation, the uri of the immediate parent; otherwise set to parent-uri"},
- "thr-parent-id": {"type": "int unsigned", "relation": {"item-uri": "id"}, "comment": "Id of the item-uri table that contains the thread parent uri"},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Creation timestamp."},
- "edited": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Date of last edit (default is created)"},
- "commented": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Date of last comment/reply to this item"},
- "received": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "datetime"},
- "changed": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Date that something in the conversation changed, indicating clients should fetch the conversation again"},
- "gravity": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": ""},
- "network": {"type": "char(4)", "not null": "1", "default": "", "comment": "Network from where the item comes from"},
- "owner-id": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"contact": "id"}, "comment": "Link to the contact table with uid=0 of the owner of this item"},
- "author-id": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"contact": "id"}, "comment": "Link to the contact table with uid=0 of the author of this item"},
- "icid": {"type": "int unsigned", "relation": {"item-content": "id"}, "comment": "Id of the item-content table entry that contains the whole item content"},
- "iaid": {"type": "int unsigned", "relation": {"item-activity": "id"}, "comment": "Id of the item-activity table entry that contains the activity data"},
- "extid": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "post-type": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": "Post type (personal note, bookmark, ...)"},
- "global": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "private": {"type": "boolean", "not null": "1", "default": "0", "comment": "distribution is restricted"},
- "visible": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "moderated": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "deleted": {"type": "boolean", "not null": "1", "default": "0", "comment": "item has been deleted"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "Owner id which owns this copy of the item"},
- "contact-id": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"contact": "id"}, "comment": "contact.id"},
- "wall": {"type": "boolean", "not null": "1", "default": "0", "comment": "This item was posted to the wall of uid"},
- "origin": {"type": "boolean", "not null": "1", "default": "0", "comment": "item originated at this site"},
- "pubmail": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "starred": {"type": "boolean", "not null": "1", "default": "0", "comment": "item has been favourited"},
- "unseen": {"type": "boolean", "not null": "1", "default": "1", "comment": "item has not been seen"},
- "mention": {"type": "boolean", "not null": "1", "default": "0", "comment": "The owner of this item was mentioned in it"},
- "forum_mode": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": ""},
- "psid": {"type": "int unsigned", "relation": {"permissionset": "id"}, "comment": "ID of the permission set of this post"},
- "resource-id": {"type": "varchar(32)", "not null": "1", "default": "", "comment": "Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type"},
- "event-id": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"event": "id"}, "comment": "Used to link to the event.id"},
- "attach": {"type": "mediumtext", "comment": "JSON structure representing attachments to this item"},
- "allow_cid": {"type": "mediumtext", "comment": "Deprecated"},
- "allow_gid": {"type": "mediumtext", "comment": "Deprecated"},
- "deny_cid": {"type": "mediumtext", "comment": "Deprecated"},
- "deny_gid": {"type": "mediumtext", "comment": "Deprecated"},
- "postopts": {"type": "text", "comment": "Deprecated"},
- "inform": {"type": "mediumtext", "comment": "Deprecated"},
- "type": {"type": "varchar(20)", "comment": "Deprecated"},
- "bookmark": {"type": "boolean", "comment": "Deprecated"},
- "file": {"type": "mediumtext", "comment": "Deprecated"},
- "location": {"type": "varchar(255)", "comment": "Deprecated"},
- "coord": {"type": "varchar(255)", "comment": "Deprecated"},
- "tag": {"type": "mediumtext", "comment": "Deprecated"},
- "plink": {"type": "varchar(255)", "comment": "Deprecated"},
- "title": {"type": "varchar(255)", "comment": "Deprecated"},
- "content-warning": {"type": "varchar(255)", "comment": "Deprecated"},
- "body": {"type": "mediumtext", "comment": "Deprecated"},
- "app": {"type": "varchar(255)", "comment": "Deprecated"},
- "verb": {"type": "varchar(100)", "comment": "Deprecated"},
- "object-type": {"type": "varchar(100)", "comment": "Deprecated"},
- "object": {"type": "text", "comment": "Deprecated"},
- "target-type": {"type": "varchar(100)", "comment": "Deprecated"},
- "target": {"type": "text", "comment": "Deprecated"},
- "author-name": {"type": "varchar(255)", "comment": "Deprecated"},
- "author-link": {"type": "varchar(255)", "comment": "Deprecated"},
- "author-avatar": {"type": "varchar(255)", "comment": "Deprecated"},
- "owner-name": {"type": "varchar(255)", "comment": "Deprecated"},
- "owner-link": {"type": "varchar(255)", "comment": "Deprecated"},
- "owner-avatar": {"type": "varchar(255)", "comment": "Deprecated"},
- "rendered-hash": {"type": "varchar(32)", "comment": "Deprecated"},
- "rendered-html": {"type": "mediumtext", "comment": "Deprecated"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "guid": ["guid(191)"],
- "uri": ["uri(191)"],
- "parent": ["parent"],
- "parent-uri": ["parent-uri(191)"],
- "extid": ["extid(191)"],
- "uid_id": ["uid", "id"],
- "uid_contactid_id": ["uid", "contact-id", "id"],
- "uid_created": ["uid", "created"],
- "uid_commented": ["uid", "commented"],
- "uid_unseen_contactid": ["uid", "unseen", "contact-id"],
- "uid_network_received": ["uid", "network", "received"],
- "uid_network_commented": ["uid", "network", "commented"],
- "uid_thrparent": ["uid", "thr-parent(190)"],
- "uid_parenturi": ["uid", "parent-uri(190)"],
- "uid_contactid_created": ["uid", "contact-id", "created"],
- "authorid_created": ["author-id", "created"],
- "ownerid": ["owner-id"],
- "uid_uri": ["uid", "uri(190)"],
- "resource-id": ["resource-id"],
- "deleted_changed": ["deleted", "changed"],
- "uid_wall_changed": ["uid", "wall", "changed"],
- "uid_eventid": ["uid", "event-id"],
- "icid": ["icid"],
- "iaid": ["iaid"],
- "psid_wall": ["psid", "wall"]
- }
- },
- "item-activity": {
- "comment": "Activities for items",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "relation": {"thread": "iid"}},
- "uri": {"type": "varchar(255)", "comment": ""},
- "uri-id": {"type": "int unsigned", "relation": {"item-uri": "id"}, "comment": "Id of the item-uri table entry that contains the item uri"},
- "uri-hash": {"type": "varchar(80)", "not null": "1", "default": "", "comment": "RIPEMD-128 hash from uri"},
- "activity": {"type": "smallint unsigned", "not null": "1", "default": "0", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "uri-hash": ["UNIQUE", "uri-hash"],
- "uri": ["uri(191)"]
- }
- },
- "item-content": {
- "comment": "Content for all posts",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "relation": {"thread": "iid"}},
- "uri": {"type": "varchar(255)", "comment": ""},
- "uri-id": {"type": "int unsigned", "relation": {"item-uri": "id"}, "comment": "Id of the item-uri table entry that contains the item uri"},
- "uri-plink-hash": {"type": "varchar(80)", "not null": "1", "default": "", "comment": "RIPEMD-128 hash from uri"},
- "title": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "item title"},
- "content-warning": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "body": {"type": "mediumtext", "comment": "item body content"},
- "location": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "text location where this item originated"},
- "coord": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "longitude/latitude pair representing location where this item originated"},
- "language": {"type": "text", "comment": "Language information about this post"},
- "app": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "application which generated this item"},
- "rendered-hash": {"type": "varchar(32)", "not null": "1", "default": "", "comment": ""},
- "rendered-html": {"type": "mediumtext", "comment": "item.body converted to html"},
- "object-type": {"type": "varchar(100)", "not null": "1", "default": "", "comment": "ActivityStreams object type"},
- "object": {"type": "text", "comment": "JSON encoded object structure unless it is an implied object (normal post)"},
- "target-type": {"type": "varchar(100)", "not null": "1", "default": "", "comment": "ActivityStreams target type if applicable (URI)"},
- "target": {"type": "text", "comment": "JSON encoded target structure if used"},
- "plink": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "permalink or URL to a displayable copy of the message at its source"},
- "verb": {"type": "varchar(100)", "not null": "1", "default": "", "comment": "ActivityStreams verb"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "uri-plink-hash": ["UNIQUE", "uri-plink-hash"],
- "uri": ["uri(191)"]
- }
- },
- "item-delivery-data": {
- "comment": "Delivery data for items",
- "fields": {
- "iid": {"type": "int unsigned", "not null": "1", "primary": "1", "relation": {"item": "id"}, "comment": "Item id"},
- "postopts": {"type": "text", "comment": "External post connectors add their network name to this comma-separated string to identify that they should be delivered to these networks during delivery"},
- "inform": {"type": "mediumtext", "comment": "Additional receivers of the linked item"}
- },
- "indexes": {
- "PRIMARY": ["iid"]
- }
- },
- "item-uri": {
- "comment": "URI and GUID for items",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1"},
- "uri": {"type": "varbinary(255)", "not null": "1", "comment": "URI of an item"},
- "guid": {"type": "varbinary(255)", "comment": "A unique identifier for an item"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "uri": ["UNIQUE", "uri"],
- "guid": ["guid"]
- }
- },
- "locks": {
- "comment": "",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "name": {"type": "varchar(128)", "not null": "1", "default": "", "comment": ""},
- "locked": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "pid": {"type": "int unsigned", "not null": "1", "default": "0", "comment": "Process ID"},
- "expires": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "datetime of cache expiration"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "name_expires": ["name", "expires"]
- }
- },
- "mail": {
- "comment": "private messages",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "Owner User id"},
- "guid": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "A unique identifier for this private message"},
- "from-name": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "name of the sender"},
- "from-photo": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "contact photo link of the sender"},
- "from-url": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "profile linke of the sender"},
- "contact-id": {"type": "varchar(255)", "not null": "1", "default": "", "relation": {"contact": "id"}, "comment": "contact.id"},
- "convid": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"conv": "id"}, "comment": "conv.id"},
- "title": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "body": {"type": "mediumtext", "comment": ""},
- "seen": {"type": "boolean", "not null": "1", "default": "0", "comment": "if message visited it is 1"},
- "reply": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "replied": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "unknown": {"type": "boolean", "not null": "1", "default": "0", "comment": "if sender not in the contact table this is 1"},
- "uri": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "parent-uri": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "creation time of the private message"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "uid_seen": ["uid", "seen"],
- "convid": ["convid"],
- "uri": ["uri(64)"],
- "parent-uri": ["parent-uri(64)"],
- "contactid": ["contact-id(32)"]
- }
- },
- "mailacct": {
- "comment": "Mail account data for fetching mails",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"},
- "server": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "port": {"type": "smallint unsigned", "not null": "1", "default": "0", "comment": ""},
- "ssltype": {"type": "varchar(16)", "not null": "1", "default": "", "comment": ""},
- "mailbox": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "user": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "pass": {"type": "text", "comment": ""},
- "reply_to": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "action": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": ""},
- "movetofolder": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "pubmail": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "last_check": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"]
- }
- },
- "manage": {
- "comment": "table of accounts that can manage each other",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"},
- "mid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "uid_mid": ["UNIQUE", "uid", "mid"]
- }
- },
- "notify": {
- "comment": "notifications",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "hash": {"type": "varchar(64)", "not null": "1", "default": "", "comment": ""},
- "type": {"type": "smallint unsigned", "not null": "1", "default": "0", "comment": ""},
- "name": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "url": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "photo": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "date": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "msg": {"type": "mediumtext", "comment": ""},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "Owner User id"},
- "link": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "iid": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"item": "id"}, "comment": "item.id"},
- "parent": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"item": "id"}, "comment": ""},
- "seen": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "verb": {"type": "varchar(100)", "not null": "1", "default": "", "comment": ""},
- "otype": {"type": "varchar(10)", "not null": "1", "default": "", "comment": ""},
- "name_cache": {"type": "tinytext", "comment": "Cached bbcode parsing of name"},
- "msg_cache": {"type": "mediumtext", "comment": "Cached bbcode parsing of msg"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "hash_uid": ["hash", "uid"],
- "seen_uid_date": ["seen", "uid", "date"],
- "uid_date": ["uid", "date"],
- "uid_type_link": ["uid", "type", "link(190)"]
- }
- },
- "notify-threads": {
- "comment": "",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "notify-id": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"notify": "id"}, "comment": ""},
- "master-parent-item": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"item": "id"}, "comment": ""},
- "parent-item": {"type": "int unsigned", "not null": "1", "default": "0", "comment": ""},
- "receiver-uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"}
- },
- "indexes": {
- "PRIMARY": ["id"]
- }
- },
- "oembed": {
- "comment": "cache for OEmbed queries",
- "fields": {
- "url": {"type": "varbinary(255)", "not null": "1", "primary": "1", "comment": "page url"},
- "maxwidth": {"type": "mediumint unsigned", "not null": "1", "primary": "1", "comment": "Maximum width passed to Oembed"},
- "content": {"type": "mediumtext", "comment": "OEmbed data of the page"},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "datetime of creation"}
- },
- "indexes": {
- "PRIMARY": ["url", "maxwidth"],
- "created": ["created"]
- }
- },
- "openwebauth-token": {
- "comment": "Store OpenWebAuth token to verify contacts",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"},
- "type": {"type": "varchar(32)", "not null": "1", "default": "", "comment": "Verify type"},
- "token": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "A generated token"},
- "meta": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "datetime of creation"}
- },
- "indexes": {
- "PRIMARY": ["id"]
- }
- },
- "parsed_url": {
- "comment": "cache for 'parse_url' queries",
- "fields": {
- "url": {"type": "varbinary(255)", "not null": "1", "primary": "1", "comment": "page url"},
- "guessing": {"type": "boolean", "not null": "1", "default": "0", "primary": "1", "comment": "is the 'guessing' mode active?"},
- "oembed": {"type": "boolean", "not null": "1", "default": "0", "primary": "1", "comment": "is the data the result of oembed?"},
- "content": {"type": "mediumtext", "comment": "page data"},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "datetime of creation"}
- },
- "indexes": {
- "PRIMARY": ["url", "guessing", "oembed"],
- "created": ["created"]
- }
- },
- "participation": {
- "comment": "Storage for participation messages from Diaspora",
- "fields": {
- "iid": {"type": "int unsigned", "not null": "1", "primary": "1", "relation": {"item": "id"}, "comment": ""},
- "server": {"type": "varchar(60)", "not null": "1", "primary": "1", "comment": ""},
- "cid": {"type": "int unsigned", "not null": "1", "relation": {"contact": "id"}, "comment": ""},
- "fid": {"type": "int unsigned", "not null": "1", "relation": {"fcontact": "id"}, "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["iid", "server"]
- }
- },
- "pconfig": {
- "comment": "personal (per user) configuration storage",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": ""},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"},
- "cat": {"type": "varbinary(50)", "not null": "1", "default": "", "comment": ""},
- "k": {"type": "varbinary(100)", "not null": "1", "default": "", "comment": ""},
- "v": {"type": "mediumtext", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "uid_cat_k": ["UNIQUE", "uid", "cat", "k"]
- }
- },
- "permissionset": {
- "comment": "",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "Owner id of this permission set"},
- "allow_cid": {"type": "mediumtext", "comment": "Access Control - list of allowed contact.id '<19><78>'"},
- "allow_gid": {"type": "mediumtext", "comment": "Access Control - list of allowed groups"},
- "deny_cid": {"type": "mediumtext", "comment": "Access Control - list of denied contact.id"},
- "deny_gid": {"type": "mediumtext", "comment": "Access Control - list of denied groups"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "uid_allow_cid_allow_gid_deny_cid_deny_gid": ["allow_cid(50)", "allow_gid(30)", "deny_cid(50)", "deny_gid(30)"]
- }
- },
- "photo": {
- "comment": "photo storage",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "Owner User id"},
- "contact-id": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"contact": "id"}, "comment": "contact.id"},
- "guid": {"type": "char(16)", "not null": "1", "default": "", "comment": "A unique identifier for this photo"},
- "resource-id": {"type": "char(32)", "not null": "1", "default": "", "comment": ""},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "creation date"},
- "edited": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "last edited date"},
- "title": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "desc": {"type": "text", "comment": ""},
- "album": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "The name of the album to which the photo belongs"},
- "filename": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "type": {"type": "varchar(30)", "not null": "1", "default": "image/jpeg"},
- "height": {"type": "smallint unsigned", "not null": "1", "default": "0", "comment": ""},
- "width": {"type": "smallint unsigned", "not null": "1", "default": "0", "comment": ""},
- "datasize": {"type": "int unsigned", "not null": "1", "default": "0", "comment": ""},
- "data": {"type": "mediumblob", "not null": "1", "comment": ""},
- "scale": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": ""},
- "profile": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "allow_cid": {"type": "mediumtext", "comment": "Access Control - list of allowed contact.id '<19><78>'"},
- "allow_gid": {"type": "mediumtext", "comment": "Access Control - list of allowed groups"},
- "deny_cid": {"type": "mediumtext", "comment": "Access Control - list of denied contact.id"},
- "deny_gid": {"type": "mediumtext", "comment": "Access Control - list of denied groups"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "contactid": ["contact-id"],
- "uid_contactid": ["uid", "contact-id"],
- "uid_profile": ["uid", "profile"],
- "uid_album_scale_created": ["uid", "album(32)", "scale", "created"],
- "uid_album_resource-id_created": ["uid", "album(32)", "resource-id", "created"],
- "resource-id": ["resource-id"]
- }
- },
- "poll": {
- "comment": "Currently unused table for storing poll results",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": ""},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"},
- "q0": {"type": "text", "comment": ""},
- "q1": {"type": "text", "comment": ""},
- "q2": {"type": "text", "comment": ""},
- "q3": {"type": "text", "comment": ""},
- "q4": {"type": "text", "comment": ""},
- "q5": {"type": "text", "comment": ""},
- "q6": {"type": "text", "comment": ""},
- "q7": {"type": "text", "comment": ""},
- "q8": {"type": "text", "comment": ""},
- "q9": {"type": "text", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "uid": ["uid"]
- }
- },
- "poll_result": {
- "comment": "data for polls - currently unused",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "poll_id": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"poll": "id"}},
- "choice": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "poll_id": ["poll_id"]
- }
- },
- "process": {
- "comment": "Currently running system processes",
- "fields": {
- "pid": {"type": "int unsigned", "not null": "1", "primary": "1", "comment": ""},
- "command": {"type": "varbinary(32)", "not null": "1", "default": "", "comment": ""},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["pid"],
- "command": ["command"]
- }
- },
- "profile": {
- "comment": "user profiles data",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "Owner User id"},
- "profile-name": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "Name of the profile"},
- "is-default": {"type": "boolean", "not null": "1", "default": "0", "comment": "Mark this profile as default profile"},
- "hide-friends": {"type": "boolean", "not null": "1", "default": "0", "comment": "Hide friend list from viewers of this profile"},
- "name": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "pdesc": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "Title or description"},
- "dob": {"type": "varchar(32)", "not null": "1", "default": "0000-00-00", "comment": "Day of birth"},
- "address": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "locality": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "region": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "postal-code": {"type": "varchar(32)", "not null": "1", "default": "", "comment": ""},
- "country-name": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "hometown": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "gender": {"type": "varchar(32)", "not null": "1", "default": "", "comment": ""},
- "marital": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "with": {"type": "text", "comment": ""},
- "howlong": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "sexual": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "politic": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "religion": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "pub_keywords": {"type": "text", "comment": ""},
- "prv_keywords": {"type": "text", "comment": ""},
- "likes": {"type": "text", "comment": ""},
- "dislikes": {"type": "text", "comment": ""},
- "about": {"type": "text", "comment": ""},
- "summary": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "music": {"type": "text", "comment": ""},
- "book": {"type": "text", "comment": ""},
- "tv": {"type": "text", "comment": ""},
- "film": {"type": "text", "comment": ""},
- "interest": {"type": "text", "comment": ""},
- "romance": {"type": "text", "comment": ""},
- "work": {"type": "text", "comment": ""},
- "education": {"type": "text", "comment": ""},
- "contact": {"type": "text", "comment": ""},
- "homepage": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "xmpp": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "photo": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "thumb": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "publish": {"type": "boolean", "not null": "1", "default": "0", "comment": "publish default profile in local directory"},
- "net-publish": {"type": "boolean", "not null": "1", "default": "0", "comment": "publish profile in global directory"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "uid_is-default": ["uid", "is-default"]
- }
- },
- "profile_check": {
- "comment": "DFRN remote auth use",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"},
- "cid": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"contact": "id"}, "comment": "contact.id"},
- "dfrn_id": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "sec": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "expire": {"type": "int unsigned", "not null": "1", "default": "0", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"]
- }
- },
- "push_subscriber": {
- "comment": "Used for OStatus: Contains feed subscribers",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"},
- "callback_url": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "topic": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "nickname": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "push": {"type": "tinyint", "not null": "1", "default": "0", "comment": "Retrial counter"},
- "last_update": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Date of last successful trial"},
- "next_try": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Next retrial date"},
- "renewed": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Date of last subscription renewal"},
- "secret": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "next_try": ["next_try"]
- }
- },
- "queue": {
- "comment": "Queue for messages that couldn't be delivered",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "cid": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"contact": "id"}, "comment": "Message receiver"},
- "network": {"type": "char(4)", "not null": "1", "default": "", "comment": "Receiver's network"},
- "guid": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "Unique GUID of the message"},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Date, when the message was created"},
- "last": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Date of last trial"},
- "next": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Next retrial date"},
- "retrial": {"type": "tinyint", "not null": "1", "default": "0", "comment": "Retrial counter"},
- "content": {"type": "mediumtext", "comment": ""},
- "batch": {"type": "boolean", "not null": "1", "default": "0", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "last": ["last"],
- "next": ["next"]
- }
- },
- "register": {
- "comment": "registrations requiring admin approval",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "hash": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"},
- "password": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "language": {"type": "varchar(16)", "not null": "1", "default": "", "comment": ""},
- "note": {"type": "text", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"]
- }
- },
- "search": {
- "comment": "",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"},
- "term": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "uid": ["uid"]
- }
- },
- "session": {
- "comment": "web session storage",
- "fields": {
- "id": {"type": "bigint unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "sid": {"type": "varbinary(255)", "not null": "1", "default": "", "comment": ""},
- "data": {"type": "text", "comment": ""},
- "expire": {"type": "int unsigned", "not null": "1", "default": "0", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "sid": ["sid(64)"],
- "expire": ["expire"]
- }
- },
- "sign": {
- "comment": "Diaspora signatures",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "iid": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"item": "id"}, "comment": "item.id"},
- "signed_text": {"type": "mediumtext", "comment": ""},
- "signature": {"type": "text", "comment": ""},
- "signer": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "iid": ["UNIQUE", "iid"]
- }
- },
- "term": {
- "comment": "item taxonomy (categories, tags, etc.) table",
- "fields": {
- "tid": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": ""},
- "oid": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"item": "id"}, "comment": ""},
- "otype": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": ""},
- "type": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": ""},
- "term": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "url": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "guid": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "received": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "global": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"}
- },
- "indexes": {
- "PRIMARY": ["tid"],
- "oid_otype_type_term": ["oid", "otype", "type", "term(32)"],
- "uid_otype_type_term_global_created": ["uid", "otype", "type", "term(32)", "global", "created"],
- "uid_otype_type_url": ["uid", "otype", "type", "url(64)"],
- "guid": ["guid(64)"]
- }
- },
- "thread": {
- "comment": "Thread related data",
- "fields": {
- "iid": {"type": "int unsigned", "not null": "1", "default": "0", "primary": "1", "relation": {"item": "id"}, "comment": "sequential ID"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"},
- "contact-id": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"contact": "id"}, "comment": ""},
- "owner-id": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"contact": "id"}, "comment": "Item owner"},
- "author-id": {"type": "int unsigned", "not null": "1", "default": "0", "relation": {"contact": "id"}, "comment": "Item author"},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "edited": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "commented": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "received": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "changed": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""},
- "wall": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "private": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "pubmail": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "moderated": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "visible": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "starred": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "ignored": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "post-type": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": "Post type (personal note, bookmark, ...)"},
- "unseen": {"type": "boolean", "not null": "1", "default": "1", "comment": ""},
- "deleted": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "origin": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "forum_mode": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": ""},
- "mention": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "network": {"type": "char(4)", "not null": "1", "default": "", "comment": ""},
- "bookmark": {"type": "boolean", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["iid"],
- "uid_network_commented": ["uid", "network", "commented"],
- "uid_network_created": ["uid", "network", "created"],
- "uid_contactid_commented": ["uid", "contact-id", "commented"],
- "uid_contactid_created": ["uid", "contact-id", "created"],
- "contactid": ["contact-id"],
- "ownerid": ["owner-id"],
- "authorid": ["author-id"],
- "uid_created": ["uid", "created"],
- "uid_commented": ["uid", "commented"],
- "uid_wall_created": ["uid", "wall", "created"],
- "private_wall_origin_commented": ["private", "wall", "origin", "commented"]
- }
- },
- "tokens": {
- "comment": "OAuth usage",
- "fields": {
- "id": {"type": "varchar(40)", "not null": "1", "primary": "1", "comment": ""},
- "secret": {"type": "text", "comment": ""},
- "client_id": {"type": "varchar(20)", "not null": "1", "default": "", "relation": {"clients": "client_id"}},
- "expires": {"type": "int", "not null": "1", "default": "0", "comment": ""},
- "scope": {"type": "varchar(200)", "not null": "1", "default": "", "comment": ""},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "User id"}
- },
- "indexes": {
- "PRIMARY": ["id"]
- }
- },
- "user": {
- "comment": "The local users",
- "fields": {
- "uid": {"type": "mediumint unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "parent-uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "relation": {"user": "uid"}, "comment": "The parent user that has full control about this user"},
- "guid": {"type": "varchar(64)", "not null": "1", "default": "", "comment": "A unique identifier for this user"},
- "username": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "Name that this user is known by"},
- "password": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "encrypted password"},
- "legacy_password": {"type": "boolean", "not null": "1", "default": "0", "comment": "Is the password hash double-hashed?"},
- "nickname": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "nick- and user name"},
- "email": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "the users email address"},
- "openid": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
- "timezone": {"type": "varchar(128)", "not null": "1", "default": "", "comment": "PHP-legal timezone"},
- "language": {"type": "varchar(32)", "not null": "1", "default": "en", "comment": "default language"},
- "register_date": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "timestamp of registration"},
- "login_date": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "timestamp of last login"},
- "default-location": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "Default for item.location"},
- "allow_location": {"type": "boolean", "not null": "1", "default": "0", "comment": "1 allows to display the location"},
- "theme": {"type": "varchar(255)", "not null": "1", "default": "", "comment": "user theme preference"},
- "pubkey": {"type": "text", "comment": "RSA public key 4096 bit"},
- "prvkey": {"type": "text", "comment": "RSA private key 4096 bit"},
- "spubkey": {"type": "text", "comment": ""},
- "sprvkey": {"type": "text", "comment": ""},
- "verified": {"type": "boolean", "not null": "1", "default": "0", "comment": "user is verified through email"},
- "blocked": {"type": "boolean", "not null": "1", "default": "0", "comment": "1 for user is blocked"},
- "blockwall": {"type": "boolean", "not null": "1", "default": "0", "comment": "Prohibit contacts to post to the profile page of the user"},
- "hidewall": {"type": "boolean", "not null": "1", "default": "0", "comment": "Hide profile details from unkown viewers"},
- "blocktags": {"type": "boolean", "not null": "1", "default": "0", "comment": "Prohibit contacts to tag the post of this user"},
- "unkmail": {"type": "boolean", "not null": "1", "default": "0", "comment": "Permit unknown people to send private mails to this user"},
- "cntunkmail": {"type": "int unsigned", "not null": "1", "default": "10", "comment": ""},
- "notify-flags": {"type": "smallint unsigned", "not null": "1", "default": "65535", "comment": "email notification options"},
- "page-flags": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": "page/profile type"},
- "account-type": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": ""},
- "prvnets": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "pwdreset": {"type": "varchar(255)", "comment": "Password reset request token"},
- "pwdreset_time": {"type": "datetime", "comment": "Timestamp of the last password reset request"},
- "maxreq": {"type": "int unsigned", "not null": "1", "default": "10", "comment": ""},
- "expire": {"type": "int unsigned", "not null": "1", "default": "0", "comment": ""},
- "account_removed": {"type": "boolean", "not null": "1", "default": "0", "comment": "if 1 the account is removed"},
- "account_expired": {"type": "boolean", "not null": "1", "default": "0", "comment": ""},
- "account_expires_on": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "timestamp when account expires and will be deleted"},
- "expire_notification_sent": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "timestamp of last warning of account expiration"},
- "def_gid": {"type": "int unsigned", "not null": "1", "default": "0", "comment": ""},
- "allow_cid": {"type": "mediumtext", "comment": "default permission for this user"},
- "allow_gid": {"type": "mediumtext", "comment": "default permission for this user"},
- "deny_cid": {"type": "mediumtext", "comment": "default permission for this user"},
- "deny_gid": {"type": "mediumtext", "comment": "default permission for this user"},
- "openidserver": {"type": "text", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["uid"],
- "nickname": ["nickname(32)"]
- }
- },
- "userd": {
- "comment": "Deleted usernames",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "sequential ID"},
- "username": {"type": "varchar(255)", "not null": "1", "comment": ""}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "username": ["username(32)"]
- }
- },
- "user-contact": {
- "comment": "User specific public contact data",
- "fields": {
- "cid": {"type": "int unsigned", "not null": "1", "default": "0", "primary": "1", "relation": {"contact": "id"}, "comment": "Contact id of the linked public contact"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "primary": "1", "relation": {"user": "uid"}, "comment": "User id"},
- "blocked": {"type": "boolean", "comment": "Contact is completely blocked for this user"},
- "ignored": {"type": "boolean", "comment": "Posts from this contact are ignored"},
- "collapsed": {"type": "boolean", "comment": "Posts from this contact are collapsed"}
- },
- "indexes": {
- "PRIMARY": ["uid", "cid"]
- }
- },
- "user-item": {
- "comment": "User specific item data",
- "fields": {
- "iid": {"type": "int unsigned", "not null": "1", "default": "0", "primary": "1", "relation": {"item": "id"}, "comment": "Item id"},
- "uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "primary": "1", "relation": {"user": "uid"}, "comment": "User id"},
- "hidden": {"type": "boolean", "not null": "1", "default": "0", "comment": "Marker to hide an item from the user"},
- "ignored": {"type": "boolean", "comment": "Ignore this thread if set"}
- },
- "indexes": {
- "PRIMARY": ["uid", "iid"]
- }
- },
- "worker-ipc": {
- "comment": "Inter process communication between the frontend and the worker",
- "fields": {
- "key": {"type": "int", "not null": "1", "primary": "1", "comment": ""},
- "jobs": {"type": "boolean", "comment": "Flag for outstanding jobs"}
- },
- "indexes": {
- "PRIMARY": ["key"]
- },
- "engine": "MEMORY"
- },
- "workerqueue": {
- "comment": "Background tasks queue entries",
- "fields": {
- "id": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "Auto incremented worker task id"},
- "parameter": {"type": "mediumblob", "comment": "Task command"},
- "priority": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": "Task priority"},
- "created": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Creation date"},
- "pid": {"type": "int unsigned", "not null": "1", "default": "0", "comment": "Process id of the worker"},
- "executed": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Execution date"},
- "next_try": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Next retrial date"},
- "retrial": {"type": "tinyint", "not null": "1", "default": "0", "comment": "Retrial counter"},
- "done": {"type": "boolean", "not null": "1", "default": "0", "comment": "Marked 1 when the task was done - will be deleted later"}
- },
- "indexes": {
- "PRIMARY": ["id"],
- "pid": ["pid"],
- "parameter": ["parameter(64)"],
- "priority_created_next_try": ["priority", "created", "next_try"],
- "done_executed_next_try": ["done", "executed", "next_try"]
- }
- }
-}
--- /dev/null
+<?php
+
+/* Main database structure configuration file.
+ *
+ * Here are described all the tables, fields and indexes Friendica needs to work.
+ *
+ * Syntax (braces indicate optionale values):
+ * "<table name>" => [
+ * "comment" => "Description of the table",
+ * "fields" => [
+ * "<field name>" => [
+ * "type" => "<field type>{(<field size>)} <unsigned>",
+ * "not null" => 0|1,
+ * {"extra" => "auto_increment",}
+ * {"default" => "<default value>",}
+ * {"default" => NULL_DATE,} (for datetime fields)
+ * {"primary" => "1",}
+ * {"relation" => ["<foreign key table name>" => "<foreign key field name>"],}
+ * "comment" => "Description of the fields"
+ * ],
+ * ...
+ * ],
+ * "indexes" => [
+ * "PRIMARY" => ["<primary key field name>", ...],
+ * "<index name>" => [{"UNIQUE",} "<field name>{(<key size>)}", ...]
+ * ...
+ * ],
+ * ],
+ *
+ * If you need to make any change, make sure to increment the DB_UPDATE_VERSION constant value below.
+ *
+ */
+
+use Friendica\Database\DBA;
+
+if (!defined('DB_UPDATE_VERSION')) {
+ define('DB_UPDATE_VERSION', 1289);
+}
+
+return [
+ "addon" => [
+ "comment" => "registered addons",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
+ "name" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => "addon base (file)name"],
+ "version" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => "currently unused"],
+ "installed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "currently always 1"],
+ "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "currently unused"],
+ "timestamp" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "file timestamp to check for reloads"],
+ "plugin_admin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = has admin config, 0 = has no admin config"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "name" => ["UNIQUE", "name"],
+ ]
+ ],
+ "apcontact" => [
+ "comment" => "ActivityPub compatible contacts - used in the ActivityPub implementation",
+ "fields" => [
+ "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "URL of the contact"],
+ "uuid" => ["type" => "varchar(255)", "comment" => ""],
+ "type" => ["type" => "varchar(20)", "not null" => "1", "comment" => ""],
+ "following" => ["type" => "varchar(255)", "comment" => ""],
+ "followers" => ["type" => "varchar(255)", "comment" => ""],
+ "inbox" => ["type" => "varchar(255)", "not null" => "1", "comment" => ""],
+ "outbox" => ["type" => "varchar(255)", "comment" => ""],
+ "sharedinbox" => ["type" => "varchar(255)", "comment" => ""],
+ "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "name" => ["type" => "varchar(255)", "comment" => ""],
+ "about" => ["type" => "text", "comment" => ""],
+ "photo" => ["type" => "varchar(255)", "comment" => ""],
+ "addr" => ["type" => "varchar(255)", "comment" => ""],
+ "alias" => ["type" => "varchar(255)", "comment" => ""],
+ "pubkey" => ["type" => "text", "comment" => ""],
+ "baseurl" => ["type" => "varchar(255)", "comment" => "baseurl of the ap contact"],
+ "updated" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""]
+ ],
+ "indexes" => [
+ "PRIMARY" => ["url"],
+ "addr" => ["addr(32)"],
+ "alias" => ["alias(190)"],
+ "url" => ["followers(190)"]
+ ]
+ ],
+ "attach" => [
+ "comment" => "file attachments",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "generated index"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
+ "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "hash"],
+ "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "filename of original"],
+ "filetype" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "mimetype"],
+ "filesize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "size in bytes"],
+ "data" => ["type" => "longblob", "not null" => "1", "comment" => "file data"],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "creation time"],
+ "edited" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "last edit time"],
+ "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>"],
+ "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
+ "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
+ "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ ]
+ ],
+ "auth_codes" => [
+ "comment" => "OAuth usage",
+ "fields" => [
+ "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
+ "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"],
+ "comment" => ""],
+ "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
+ "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
+ "scope" => ["type" => "varchar(250)", "not null" => "1", "default" => "", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ ]
+ ],
+ "cache" => [
+ "comment" => "Stores temporary data",
+ "fields" => [
+ "k" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "cache key"],
+ "v" => ["type" => "mediumtext", "comment" => "cached serialized value"],
+ "expires" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "datetime of cache expiration"],
+ "updated" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "datetime of cache insertion"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["k"],
+ "k_expires" => ["k", "expires"],
+ ]
+ ],
+ "challenge" => [
+ "comment" => "",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "challenge" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "type" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "last_update" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ ]
+ ],
+ "clients" => [
+ "comment" => "OAuth usage",
+ "fields" => [
+ "client_id" => ["type" => "varchar(20)", "not null" => "1", "primary" => "1", "comment" => ""],
+ "pw" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""],
+ "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
+ "name" => ["type" => "text", "comment" => ""],
+ "icon" => ["type" => "text", "comment" => ""],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["client_id"],
+ ]
+ ],
+ "config" => [
+ "comment" => "main configuration storage",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
+ "cat" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
+ "k" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
+ "v" => ["type" => "mediumtext", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "cat_k" => ["UNIQUE", "cat", "k"],
+ ]
+ ],
+ "contact" => [
+ "comment" => "contact table",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 if the contact is the user him/her self"],
+ "remote_self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "rel" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "The kind of the relation between the user and the contact"],
+ "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network protocol of the contact"],
+ "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this contact is known by"],
+ "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Nick- and user name of the contact"],
+ "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "about" => ["type" => "text", "comment" => ""],
+ "keywords" => ["type" => "text", "comment" => "public keywords (interests) of the contact"],
+ "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
+ "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "attag" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "photo" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo of the contact"],
+ "thumb" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (thumb size)"],
+ "micro" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (micro size)"],
+ "site-pubkey" => ["type" => "text", "comment" => ""],
+ "issued-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "pubkey" => ["type" => "text", "comment" => "RSA public key 4096 bit"],
+ "prvkey" => ["type" => "text", "comment" => "RSA private key 4096 bit"],
+ "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "request" => ["type" => "varchar(255)", "comment" => ""],
+ "notify" => ["type" => "varchar(255)", "comment" => ""],
+ "poll" => ["type" => "varchar(255)", "comment" => ""],
+ "confirm" => ["type" => "varchar(255)", "comment" => ""],
+ "poco" => ["type" => "varchar(255)", "comment" => ""],
+ "aes_allow" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "ret-aes" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "usehub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "subhub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "hub-verify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "last-update" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last try to update the contact info"],
+ "success_update" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last successful contact update"],
+ "failure_update" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last failed update"],
+ "name-date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "uri-date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "avatar-date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "term-date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "last-item" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "date of the last post"],
+ "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
+ "readonly" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "posts of the contact are readonly"],
+ "writable" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "forum" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a forum"],
+ "prv" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a private group"],
+ "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
+ "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "archive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "pending" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
+ "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Contact has been deleted"],
+ "rating" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
+ "reason" => ["type" => "text", "comment" => ""],
+ "closeness" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "99", "comment" => ""],
+ "info" => ["type" => "mediumtext", "comment" => ""],
+ "profile-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "bdyear" => ["type" => "varchar(4)", "not null" => "1", "default" => "", "comment" => ""],
+ "bd" => ["type" => "date", "not null" => "1", "default" => DBA::NULL_DATE, "comment" => ""],
+ "notify_new_posts" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "fetch_further_information" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "ffi_keyword_blacklist" => ["type" => "text", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "uid_name" => ["uid", "name(190)"],
+ "self_uid" => ["self", "uid"],
+ "alias_uid" => ["alias(32)", "uid"],
+ "pending_uid" => ["pending", "uid"],
+ "blocked_uid" => ["blocked", "uid"],
+ "uid_rel_network_poll" => ["uid", "rel", "network", "poll(64)", "archive"],
+ "uid_network_batch" => ["uid", "network", "batch(64)"],
+ "addr_uid" => ["addr(32)", "uid"],
+ "nurl_uid" => ["nurl(32)", "uid"],
+ "nick_uid" => ["nick(32)", "uid"],
+ "dfrn-id" => ["dfrn-id(64)"],
+ "issued-id" => ["issued-id(64)"],
+ ]
+ ],
+ "conv" => [
+ "comment" => "private messages",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this conversation"],
+ "recips" => ["type" => "text", "comment" => "sender_handle;recipient_handle"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
+ "creator" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "handle of creator"],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "creation timestamp"],
+ "updated" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "edited timestamp"],
+ "subject" => ["type" => "text", "comment" => "subject of initial message"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "uid" => ["uid"],
+ ]
+ ],
+ "conversation" => [
+ "comment" => "Raw data and structure information for messages",
+ "fields" => [
+ "item-uri" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "Original URI of the item - unrelated to the table with the same name"],
+ "reply-to-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "URI to which this item is a reply"],
+ "conversation-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "GNU Social conversation URI"],
+ "conversation-href" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "GNU Social conversation link"],
+ "protocol" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "255", "comment" => "The protocol of the item"],
+ "source" => ["type" => "mediumtext", "comment" => "Original source"],
+ "received" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Receiving date"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["item-uri"],
+ "conversation-uri" => ["conversation-uri"],
+ "received" => ["received"],
+ ]
+ ],
+ "diaspora-interaction" => [
+ "comment" => "Signed Diaspora Interaction",
+ "fields" => [
+ "uri-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"],
+ "interaction" => ["type" => "mediumtext", "comment" => "The Diaspora interaction"]
+ ],
+ "indexes" => [
+ "PRIMARY" => ["uri-id"]
+ ]
+ ],
+ "event" => [
+ "comment" => "Events",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
+ "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact_id (ID of the contact in contact table)"],
+ "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "creation time"],
+ "edited" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "last edit time"],
+ "start" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "event start time"],
+ "finish" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "event end time"],
+ "summary" => ["type" => "text", "comment" => "short description or title of the event"],
+ "desc" => ["type" => "text", "comment" => "event description"],
+ "location" => ["type" => "text", "comment" => "event location"],
+ "type" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => "event or birthday"],
+ "nofinish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if event does have no end this is 1"],
+ "adjust" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "adjust to timezone of the recipient (0 or 1)"],
+ "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "0 or 1"],
+ "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
+ "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
+ "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
+ "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "uid_start" => ["uid", "start"],
+ ]
+ ],
+ "fcontact" => [
+ "comment" => "Diaspora compatible contacts - used in the Diaspora implementation",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "unique id"],
+ "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "notify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "poll" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "confirm" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
+ "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "pubkey" => ["type" => "text", "comment" => ""],
+ "updated" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "addr" => ["addr(32)"],
+ "url" => ["UNIQUE", "url(190)"],
+ ]
+ ],
+ "fsuggest" => [
+ "comment" => "friend suggestion stuff",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
+ "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "note" => ["type" => "text", "comment" => ""],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ ]
+ ],
+ "gcign" => [
+ "comment" => "contacts ignored by friend suggestions",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Local User id"],
+ "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => "gcontact.id of ignored contact"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "uid" => ["uid"],
+ "gcid" => ["gcid"],
+ ]
+ ],
+ "gcontact" => [
+ "comment" => "global contacts",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this contact is known by"],
+ "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Nick- and user name of the contact"],
+ "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the contacts profile page"],
+ "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the profile photo"],
+ "connect" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "updated" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "last_contact" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "last_failure" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "about" => ["type" => "text", "comment" => ""],
+ "keywords" => ["type" => "text", "comment" => "puplic keywords (interests)"],
+ "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
+ "birthday" => ["type" => "varchar(32)", "not null" => "1", "default" => DBA::NULL_DATE, "comment" => ""],
+ "community" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 if contact is forum account"],
+ "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "-1", "comment" => ""],
+ "hide" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = should be hidden from search"],
+ "nsfw" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = contact posts nsfw content"],
+ "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "social network protocol"],
+ "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "notify" => ["type" => "varchar(255)", "comment" => ""],
+ "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "generation" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "server_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "baseurl of the contacts server"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "nurl" => ["UNIQUE", "nurl(190)"],
+ "name" => ["name(64)"],
+ "nick" => ["nick(32)"],
+ "addr" => ["addr(64)"],
+ "hide_network_updated" => ["hide", "network", "updated"],
+ "updated" => ["updated"],
+ ]
+ ],
+ "glink" => [
+ "comment" => "'friends of friends' linkages derived from poco",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
+ "zcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
+ "updated" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "cid_uid_gcid_zcid" => ["UNIQUE", "cid", "uid", "gcid", "zcid"],
+ "gcid" => ["gcid"],
+ ]
+ ],
+ "group" => [
+ "comment" => "privacy groups, group info",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
+ "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 indicates the member list is not private"],
+ "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 indicates the group has been deleted"],
+ "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "human readable name of group"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "uid" => ["uid"],
+ ]
+ ],
+ "group_member" => [
+ "comment" => "privacy groups, member info",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["group" => "id"], "comment" => "groups.id of the associated group"],
+ "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id of the member assigned to the associated group"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "contactid" => ["contact-id"],
+ "gid_contactid" => ["UNIQUE", "gid", "contact-id"],
+ ]
+ ],
+ "gserver" => [
+ "comment" => "Global servers",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "version" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "site_name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "info" => ["type" => "text", "comment" => ""],
+ "register_policy" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
+ "registered-users" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Number of registered users"],
+ "poco" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "noscrape" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
+ "platform" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "relay-subscribe" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Has the server subscribed to the relay system"],
+ "relay-scope" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => "The scope of messages that the server wants to get"],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "last_poco_query" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "last_contact" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "last_failure" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "nurl" => ["UNIQUE", "nurl(190)"],
+ ]
+ ],
+ "gserver-tag" => [
+ "comment" => "Tags that the server has subscribed",
+ "fields" => [
+ "gserver-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gserver" => "id"], "primary" => "1",
+ "comment" => "The id of the gserver"],
+ "tag" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "primary" => "1", "comment" => "Tag that the server has subscribed"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["gserver-id", "tag"],
+ "tag" => ["tag"],
+ ]
+ ],
+ "hook" => [
+ "comment" => "addon hook registry",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "hook" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => "name of hook"],
+ "file" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => "relative filename of hook handler"],
+ "function" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => "function name of hook handler"],
+ "priority" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => "not yet implemented - can be used to sort conflicts in hook handling by calling handlers in priority order"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "hook_file_function" => ["UNIQUE", "hook", "file", "function"],
+ ]
+ ],
+ "intro" => [
+ "comment" => "",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "fid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["fcontact" => "id"], "comment" => ""],
+ "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
+ "knowyou" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "note" => ["type" => "text", "comment" => ""],
+ "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "datetime" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
+ "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ ]
+ ],
+ "item" => [
+ "comment" => "Structure for all posts",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
+ "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this item"],
+ "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "uri-id" => ["type" => "int unsigned", "relation" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"],
+ "uri-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"],
+ "parent" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => "item.id of the parent to this item if it is a reply of some form; otherwise this must be set to the id of this item"],
+ "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "uri of the parent to this item"],
+ "parent-uri-id" => ["type" => "int unsigned", "relation" => ["item-uri" => "id"], "comment" => "Id of the item-uri table that contains the parent uri"],
+ "thr-parent" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "If the parent of this item is not the top-level item in the conversation, the uri of the immediate parent; otherwise set to parent-uri"],
+ "thr-parent-id" => ["type" => "int unsigned", "relation" => ["item-uri" => "id"], "comment" => "Id of the item-uri table that contains the thread parent uri"],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Creation timestamp."],
+ "edited" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of last edit (default is created)"],
+ "commented" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of last comment/reply to this item"],
+ "received" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "datetime"],
+ "changed" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date that something in the conversation changed, indicating clients should fetch the conversation again"],
+ "gravity" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network from where the item comes from"],
+ "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Link to the contact table with uid=0 of the owner of this item"],
+ "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Link to the contact table with uid=0 of the author of this item"],
+ "icid" => ["type" => "int unsigned", "relation" => ["item-content" => "id"], "comment" => "Id of the item-content table entry that contains the whole item content"],
+ "iaid" => ["type" => "int unsigned", "relation" => ["item-activity" => "id"], "comment" => "Id of the item-activity table entry that contains the activity data"],
+ "extid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "post-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Post type (personal note, bookmark, ...)"],
+ "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "distribution is restricted"],
+ "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been deleted"],
+ // User specific fields. Eventually they will move to user-item
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner id which owns this copy of the item"],
+ "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"],
+ "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "This item was posted to the wall of uid"],
+ "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item originated at this site"],
+ "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been favourited"],
+ "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "item has not been seen"],
+ "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "The owner of this item was mentioned in it"],
+ "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "psid" => ["type" => "int unsigned", "relation" => ["permissionset" => "id"], "comment" => "ID of the permission set of this post"],
+ // It has to be decided whether these fields belong to the user or the structure
+ "resource-id" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => "Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type"],
+ "event-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["event" => "id"], "comment" => "Used to link to the event.id"],
+ // Could possibly be replaced by the "attach" table?
+ "attach" => ["type" => "mediumtext", "comment" => "JSON structure representing attachments to this item"],
+ // Deprecated fields. Will be removed in upcoming versions
+ "allow_cid" => ["type" => "mediumtext", "comment" => "Deprecated"],
+ "allow_gid" => ["type" => "mediumtext", "comment" => "Deprecated"],
+ "deny_cid" => ["type" => "mediumtext", "comment" => "Deprecated"],
+ "deny_gid" => ["type" => "mediumtext", "comment" => "Deprecated"],
+ "postopts" => ["type" => "text", "comment" => "Deprecated"],
+ "inform" => ["type" => "mediumtext", "comment" => "Deprecated"],
+ "type" => ["type" => "varchar(20)", "comment" => "Deprecated"],
+ "bookmark" => ["type" => "boolean", "comment" => "Deprecated"],
+ "file" => ["type" => "mediumtext", "comment" => "Deprecated"],
+ "location" => ["type" => "varchar(255)", "comment" => "Deprecated"],
+ "coord" => ["type" => "varchar(255)", "comment" => "Deprecated"],
+ "tag" => ["type" => "mediumtext", "comment" => "Deprecated"],
+ "plink" => ["type" => "varchar(255)", "comment" => "Deprecated"],
+ "title" => ["type" => "varchar(255)", "comment" => "Deprecated"],
+ "content-warning" => ["type" => "varchar(255)", "comment" => "Deprecated"],
+ "body" => ["type" => "mediumtext", "comment" => "Deprecated"],
+ "app" => ["type" => "varchar(255)", "comment" => "Deprecated"],
+ "verb" => ["type" => "varchar(100)", "comment" => "Deprecated"],
+ "object-type" => ["type" => "varchar(100)", "comment" => "Deprecated"],
+ "object" => ["type" => "text", "comment" => "Deprecated"],
+ "target-type" => ["type" => "varchar(100)", "comment" => "Deprecated"],
+ "target" => ["type" => "text", "comment" => "Deprecated"],
+ "author-name" => ["type" => "varchar(255)", "comment" => "Deprecated"],
+ "author-link" => ["type" => "varchar(255)", "comment" => "Deprecated"],
+ "author-avatar" => ["type" => "varchar(255)", "comment" => "Deprecated"],
+ "owner-name" => ["type" => "varchar(255)", "comment" => "Deprecated"],
+ "owner-link" => ["type" => "varchar(255)", "comment" => "Deprecated"],
+ "owner-avatar" => ["type" => "varchar(255)", "comment" => "Deprecated"],
+ "rendered-hash" => ["type" => "varchar(32)", "comment" => "Deprecated"],
+ "rendered-html" => ["type" => "mediumtext", "comment" => "Deprecated"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "guid" => ["guid(191)"],
+ "uri" => ["uri(191)"],
+ "parent" => ["parent"],
+ "parent-uri" => ["parent-uri(191)"],
+ "extid" => ["extid(191)"],
+ "uid_id" => ["uid", "id"],
+ "uid_contactid_id" => ["uid", "contact-id", "id"],
+ "uid_created" => ["uid", "created"],
+ "uid_commented" => ["uid", "commented"],
+ "uid_unseen_contactid" => ["uid", "unseen", "contact-id"],
+ "uid_network_received" => ["uid", "network", "received"],
+ "uid_network_commented" => ["uid", "network", "commented"],
+ "uid_thrparent" => ["uid", "thr-parent(190)"],
+ "uid_parenturi" => ["uid", "parent-uri(190)"],
+ "uid_contactid_created" => ["uid", "contact-id", "created"],
+ "authorid_created" => ["author-id", "created"],
+ "ownerid" => ["owner-id"],
+ "uid_uri" => ["uid", "uri(190)"],
+ "resource-id" => ["resource-id"],
+ "deleted_changed" => ["deleted", "changed"],
+ "uid_wall_changed" => ["uid", "wall", "changed"],
+ "uid_eventid" => ["uid", "event-id"],
+ "icid" => ["icid"],
+ "iaid" => ["iaid"],
+ "psid_wall" => ["psid", "wall"],
+ ]
+ ],
+ "item-activity" => [
+ "comment" => "Activities for items",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
+ "uri" => ["type" => "varchar(255)", "comment" => ""],
+ "uri-id" => ["type" => "int unsigned", "relation" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"],
+ "uri-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"],
+ "activity" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""]
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "uri-hash" => ["UNIQUE", "uri-hash"],
+ "uri" => ["uri(191)"],
+ "uri-id" => ["uri-id"]
+ ]
+ ],
+ "item-content" => [
+ "comment" => "Content for all posts",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
+ "uri" => ["type" => "varchar(255)", "comment" => ""],
+ "uri-id" => ["type" => "int unsigned", "relation" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"],
+ "uri-plink-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"],
+ "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "item title"],
+ "content-warning" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "body" => ["type" => "mediumtext", "comment" => "item body content"],
+ "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "text location where this item originated"],
+ "coord" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "longitude/latitude pair representing location where this item originated"],
+ "language" => ["type" => "text", "comment" => "Language information about this post"],
+ "app" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "application which generated this item"],
+ "rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
+ "rendered-html" => ["type" => "mediumtext", "comment" => "item.body converted to html"],
+ "object-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams object type"],
+ "object" => ["type" => "text", "comment" => "JSON encoded object structure unless it is an implied object (normal post)"],
+ "target-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams target type if applicable (URI)"],
+ "target" => ["type" => "text", "comment" => "JSON encoded target structure if used"],
+ "plink" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "permalink or URL to a displayable copy of the message at its source"],
+ "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams verb"]
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "uri-plink-hash" => ["UNIQUE", "uri-plink-hash"],
+ "uri" => ["uri(191)"],
+ "uri-id" => ["uri-id"]
+ ]
+ ],
+ "item-delivery-data" => [
+ "comment" => "Delivery data for items",
+ "fields" => [
+ "iid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item" => "id"], "comment" => "Item id"],
+ "postopts" => ["type" => "text", "comment" => "External post connectors add their network name to this comma-separated string to identify that they should be delivered to these networks during delivery"],
+ "inform" => ["type" => "mediumtext", "comment" => "Additional receivers of the linked item"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["iid"],
+ ]
+ ],
+ "item-uri" => [
+ "comment" => "URI and GUID for items",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"],
+ "uri" => ["type" => "varbinary(255)", "not null" => "1", "comment" => "URI of an item"],
+ "guid" => ["type" => "varbinary(255)", "comment" => "A unique identifier for an item"]
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "uri" => ["UNIQUE", "uri"],
+ "guid" => ["guid"]
+ ]
+ ],
+ "locks" => [
+ "comment" => "",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "name" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""],
+ "locked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Process ID"],
+ "expires" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "datetime of cache expiration"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "name_expires" => ["name", "expires"]
+ ]
+ ],
+ "mail" => [
+ "comment" => "private messages",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
+ "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this private message"],
+ "from-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "name of the sender"],
+ "from-photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "contact photo link of the sender"],
+ "from-url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "profile linke of the sender"],
+ "contact-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => ["contact" => "id"], "comment" => "contact.id"],
+ "convid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["conv" => "id"], "comment" => "conv.id"],
+ "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "body" => ["type" => "mediumtext", "comment" => ""],
+ "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if message visited it is 1"],
+ "reply" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "replied" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "unknown" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if sender not in the contact table this is 1"],
+ "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "creation time of the private message"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "uid_seen" => ["uid", "seen"],
+ "convid" => ["convid"],
+ "uri" => ["uri(64)"],
+ "parent-uri" => ["parent-uri(64)"],
+ "contactid" => ["contact-id(32)"],
+ ]
+ ],
+ "mailacct" => [
+ "comment" => "Mail account data for fetching mails",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "server" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "port" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "ssltype" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
+ "mailbox" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "user" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "pass" => ["type" => "text", "comment" => ""],
+ "reply_to" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "action" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "movetofolder" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "last_check" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ ]
+ ],
+ "manage" => [
+ "comment" => "table of accounts that can manage each other",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "mid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "uid_mid" => ["UNIQUE", "uid", "mid"],
+ ]
+ ],
+ "notify" => [
+ "comment" => "notifications",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
+ "type" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "msg" => ["type" => "mediumtext", "comment" => ""],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
+ "link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => "item.id"],
+ "parent" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
+ "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
+ "otype" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => ""],
+ "name_cache" => ["type" => "tinytext", "comment" => "Cached bbcode parsing of name"],
+ "msg_cache" => ["type" => "mediumtext", "comment" => "Cached bbcode parsing of msg"]
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "hash_uid" => ["hash", "uid"],
+ "seen_uid_date" => ["seen", "uid", "date"],
+ "uid_date" => ["uid", "date"],
+ "uid_type_link" => ["uid", "type", "link(190)"],
+ ]
+ ],
+ "notify-threads" => [
+ "comment" => "",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "notify-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["notify" => "id"], "comment" => ""],
+ "master-parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"],
+ "comment" => ""],
+ "parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "receiver-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"],
+ "comment" => "User id"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ ]
+ ],
+ "oembed" => [
+ "comment" => "cache for OEmbed queries",
+ "fields" => [
+ "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "page url"],
+ "maxwidth" => ["type" => "mediumint unsigned", "not null" => "1", "primary" => "1", "comment" => "Maximum width passed to Oembed"],
+ "content" => ["type" => "mediumtext", "comment" => "OEmbed data of the page"],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "datetime of creation"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["url", "maxwidth"],
+ "created" => ["created"],
+ ]
+ ],
+ "openwebauth-token" => [
+ "comment" => "Store OpenWebAuth token to verify contacts",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "type" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => "Verify type"],
+ "token" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A generated token"],
+ "meta" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "datetime of creation"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ ]
+ ],
+ "parsed_url" => [
+ "comment" => "cache for 'parse_url' queries",
+ "fields" => [
+ "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "page url"],
+ "guessing" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the 'guessing' mode active?"],
+ "oembed" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the data the result of oembed?"],
+ "content" => ["type" => "mediumtext", "comment" => "page data"],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "datetime of creation"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["url", "guessing", "oembed"],
+ "created" => ["created"],
+ ]
+ ],
+ "participation" => [
+ "comment" => "Storage for participation messages from Diaspora",
+ "fields" => [
+ "iid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item" => "id"], "comment" => ""],
+ "server" => ["type" => "varchar(60)", "not null" => "1", "primary" => "1", "comment" => ""],
+ "cid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["contact" => "id"], "comment" => ""],
+ "fid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["fcontact" => "id"], "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["iid", "server"]
+ ]
+ ],
+ "pconfig" => [
+ "comment" => "personal (per user) configuration storage",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "cat" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
+ "k" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => ""],
+ "v" => ["type" => "mediumtext", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "uid_cat_k" => ["UNIQUE", "uid", "cat", "k"],
+ ]
+ ],
+ "permissionset" => [
+ "comment" => "",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner id of this permission set"],
+ "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
+ "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
+ "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
+ "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "uid_allow_cid_allow_gid_deny_cid_deny_gid" => ["allow_cid(50)", "allow_gid(30)", "deny_cid(50)", "deny_gid(30)"],
+ ]
+ ],
+ "photo" => [
+ "comment" => "photo storage",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
+ "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"],
+ "guid" => ["type" => "char(16)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this photo"],
+ "resource-id" => ["type" => "char(32)", "not null" => "1", "default" => "", "comment" => ""],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "creation date"],
+ "edited" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "last edited date"],
+ "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "desc" => ["type" => "text", "comment" => ""],
+ "album" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "The name of the album to which the photo belongs"],
+ "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "type" => ["type" => "varchar(30)", "not null" => "1", "default" => "image/jpeg"],
+ "height" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "width" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "datasize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "data" => ["type" => "mediumblob", "not null" => "1", "comment" => ""],
+ "scale" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "profile" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
+ "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
+ "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
+ "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "contactid" => ["contact-id"],
+ "uid_contactid" => ["uid", "contact-id"],
+ "uid_profile" => ["uid", "profile"],
+ "uid_album_scale_created" => ["uid", "album(32)", "scale", "created"],
+ "uid_album_resource-id_created" => ["uid", "album(32)", "resource-id", "created"],
+ "resource-id" => ["resource-id"],
+ ]
+ ],
+ "poll" => [
+ "comment" => "Currently unused table for storing poll results",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "q0" => ["type" => "text", "comment" => ""],
+ "q1" => ["type" => "text", "comment" => ""],
+ "q2" => ["type" => "text", "comment" => ""],
+ "q3" => ["type" => "text", "comment" => ""],
+ "q4" => ["type" => "text", "comment" => ""],
+ "q5" => ["type" => "text", "comment" => ""],
+ "q6" => ["type" => "text", "comment" => ""],
+ "q7" => ["type" => "text", "comment" => ""],
+ "q8" => ["type" => "text", "comment" => ""],
+ "q9" => ["type" => "text", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "uid" => ["uid"],
+ ]
+ ],
+ "poll_result" => [
+ "comment" => "data for polls - currently unused",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "poll_id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["poll" => "id"]],
+ "choice" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "poll_id" => ["poll_id"],
+ ]
+ ],
+ "process" => [
+ "comment" => "Currently running system processes",
+ "fields" => [
+ "pid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "comment" => ""],
+ "command" => ["type" => "varbinary(32)", "not null" => "1", "default" => "", "comment" => ""],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["pid"],
+ "command" => ["command"],
+ ]
+ ],
+ "profile" => [
+ "comment" => "user profiles data",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
+ "profile-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name of the profile"],
+ "is-default" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Mark this profile as default profile"],
+ "hide-friends" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide friend list from viewers of this profile"],
+ "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "pdesc" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Title or description"],
+ "dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00", "comment" => "Day of birth"],
+ "address" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "locality" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "region" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "postal-code" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
+ "country-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "hometown" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
+ "marital" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "with" => ["type" => "text", "comment" => ""],
+ "howlong" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "sexual" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "politic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "religion" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "pub_keywords" => ["type" => "text", "comment" => ""],
+ "prv_keywords" => ["type" => "text", "comment" => ""],
+ "likes" => ["type" => "text", "comment" => ""],
+ "dislikes" => ["type" => "text", "comment" => ""],
+ "about" => ["type" => "text", "comment" => ""],
+ "summary" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "music" => ["type" => "text", "comment" => ""],
+ "book" => ["type" => "text", "comment" => ""],
+ "tv" => ["type" => "text", "comment" => ""],
+ "film" => ["type" => "text", "comment" => ""],
+ "interest" => ["type" => "text", "comment" => ""],
+ "romance" => ["type" => "text", "comment" => ""],
+ "work" => ["type" => "text", "comment" => ""],
+ "education" => ["type" => "text", "comment" => ""],
+ "contact" => ["type" => "text", "comment" => ""],
+ "homepage" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "thumb" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "publish default profile in local directory"],
+ "net-publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "publish profile in global directory"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "uid_is-default" => ["uid", "is-default"],
+ ]
+ ],
+ "profile_check" => [
+ "comment" => "DFRN remote auth use",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"],
+ "dfrn_id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "sec" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ ]
+ ],
+ "push_subscriber" => [
+ "comment" => "Used for OStatus: Contains feed subscribers",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "callback_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "topic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "push" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
+ "last_update" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of last successful trial"],
+ "next_try" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Next retrial date"],
+ "renewed" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of last subscription renewal"],
+ "secret" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "next_try" => ["next_try"],
+ ]
+ ],
+ "queue" => [
+ "comment" => "Queue for messages that couldn't be delivered",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Message receiver"],
+ "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Receiver's network"],
+ "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Unique GUID of the message"],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date, when the message was created"],
+ "last" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of last trial"],
+ "next" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Next retrial date"],
+ "retrial" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
+ "content" => ["type" => "mediumtext", "comment" => ""],
+ "batch" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "last" => ["last"],
+ "next" => ["next"],
+ ]
+ ],
+ "register" => [
+ "comment" => "registrations requiring admin approval",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "language" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
+ "note" => ["type" => "text", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ ]
+ ],
+ "search" => [
+ "comment" => "",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "uid" => ["uid"],
+ ]
+ ],
+ "session" => [
+ "comment" => "web session storage",
+ "fields" => [
+ "id" => ["type" => "bigint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "sid" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "data" => ["type" => "text", "comment" => ""],
+ "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "sid" => ["sid(64)"],
+ "expire" => ["expire"],
+ ]
+ ],
+ "sign" => [
+ "comment" => "Diaspora signatures",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => "item.id"],
+ "signed_text" => ["type" => "mediumtext", "comment" => ""],
+ "signature" => ["type" => "text", "comment" => ""],
+ "signer" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "iid" => ["UNIQUE", "iid"],
+ ]
+ ],
+ "term" => [
+ "comment" => "item taxonomy (categories, tags, etc.) table",
+ "fields" => [
+ "tid" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
+ "oid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
+ "otype" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "received" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["tid"],
+ "oid_otype_type_term" => ["oid", "otype", "type", "term(32)"],
+ "uid_otype_type_term_global_created" => ["uid", "otype", "type", "term(32)", "global", "created"],
+ "uid_otype_type_url" => ["uid", "otype", "type", "url(64)"],
+ "guid" => ["guid(64)"],
+ ]
+ ],
+ "thread" => [
+ "comment" => "Thread related data",
+ "fields" => [
+ "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"],
+ "comment" => "sequential ID"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
+ "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Item owner"],
+ "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Item author"],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "edited" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "commented" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "received" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "changed" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+ "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "ignored" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "post-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Post type (personal note, bookmark, ...)"],
+ "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
+ "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
+ "bookmark" => ["type" => "boolean", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["iid"],
+ "uid_network_commented" => ["uid", "network", "commented"],
+ "uid_network_created" => ["uid", "network", "created"],
+ "uid_contactid_commented" => ["uid", "contact-id", "commented"],
+ "uid_contactid_created" => ["uid", "contact-id", "created"],
+ "contactid" => ["contact-id"],
+ "ownerid" => ["owner-id"],
+ "authorid" => ["author-id"],
+ "uid_created" => ["uid", "created"],
+ "uid_commented" => ["uid", "commented"],
+ "uid_wall_created" => ["uid", "wall", "created"],
+ "private_wall_origin_commented" => ["private", "wall", "origin", "commented"],
+ ]
+ ],
+ "tokens" => [
+ "comment" => "OAuth usage",
+ "fields" => [
+ "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
+ "secret" => ["type" => "text", "comment" => ""],
+ "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"]],
+ "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
+ "scope" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ ]
+ ],
+ "user" => [
+ "comment" => "The local users",
+ "fields" => [
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"],
+ "comment" => "The parent user that has full control about this user"],
+ "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this user"],
+ "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this user is known by"],
+ "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "encrypted password"],
+ "legacy_password" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Is the password hash double-hashed?"],
+ "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "nick- and user name"],
+ "email" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "the users email address"],
+ "openid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "timezone" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => "PHP-legal timezone"],
+ "language" => ["type" => "varchar(32)", "not null" => "1", "default" => "en", "comment" => "default language"],
+ "register_date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "timestamp of registration"],
+ "login_date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "timestamp of last login"],
+ "default-location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Default for item.location"],
+ "allow_location" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 allows to display the location"],
+ "theme" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "user theme preference"],
+ "pubkey" => ["type" => "text", "comment" => "RSA public key 4096 bit"],
+ "prvkey" => ["type" => "text", "comment" => "RSA private key 4096 bit"],
+ "spubkey" => ["type" => "text", "comment" => ""],
+ "sprvkey" => ["type" => "text", "comment" => ""],
+ "verified" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "user is verified through email"],
+ "blocked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 for user is blocked"],
+ "blockwall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to post to the profile page of the user"],
+ "hidewall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide profile details from unkown viewers"],
+ "blocktags" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to tag the post of this user"],
+ "unkmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Permit unknown people to send private mails to this user"],
+ "cntunkmail" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
+ "notify-flags" => ["type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => "email notification options"],
+ "page-flags" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "page/profile type"],
+ "account-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "prvnets" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "pwdreset" => ["type" => "varchar(255)", "comment" => "Password reset request token"],
+ "pwdreset_time" => ["type" => "datetime", "comment" => "Timestamp of the last password reset request"],
+ "maxreq" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
+ "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "account_removed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if 1 the account is removed"],
+ "account_expired" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "account_expires_on" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "timestamp when account expires and will be deleted"],
+ "expire_notification_sent" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "timestamp of last warning of account expiration"],
+ "def_gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
+ "allow_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
+ "allow_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
+ "deny_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
+ "deny_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
+ "openidserver" => ["type" => "text", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["uid"],
+ "nickname" => ["nickname(32)"],
+ ]
+ ],
+ "userd" => [
+ "comment" => "Deleted usernames",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
+ "username" => ["type" => "varchar(255)", "not null" => "1", "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "username" => ["username(32)"],
+ ]
+ ],
+ "user-contact" => [
+ "comment" => "User specific public contact data",
+ "fields" => [
+ "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["contact" => "id"], "comment" => "Contact id of the linked public contact"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "blocked" => ["type" => "boolean", "comment" => "Contact is completely blocked for this user"],
+ "ignored" => ["type" => "boolean", "comment" => "Posts from this contact are ignored"],
+ "collapsed" => ["type" => "boolean", "comment" => "Posts from this contact are collapsed"]
+ ],
+ "indexes" => [
+ "PRIMARY" => ["uid", "cid"]
+ ]
+ ],
+ "user-item" => [
+ "comment" => "User specific item data",
+ "fields" => [
+ "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => "Item id"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marker to hide an item from the user"],
+ "ignored" => ["type" => "boolean", "comment" => "Ignore this thread if set"]
+ ],
+ "indexes" => [
+ "PRIMARY" => ["uid", "iid"]
+ ]
+ ],
+ "worker-ipc" => [
+ "comment" => "Inter process communication between the frontend and the worker",
+ "fields" => [
+ "key" => ["type" => "int", "not null" => "1", "primary" => "1", "comment" => ""],
+ "jobs" => ["type" => "boolean", "comment" => "Flag for outstanding jobs"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["key"],
+ ],
+ "engine" => "MEMORY",
+ ],
+ "workerqueue" => [
+ "comment" => "Background tasks queue entries",
+ "fields" => [
+ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "Auto incremented worker task id"],
+ "parameter" => ["type" => "mediumblob", "comment" => "Task command"],
+ "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Task priority"],
+ "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Creation date"],
+ "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Process id of the worker"],
+ "executed" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Execution date"],
+ "next_try" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Next retrial date"],
+ "retrial" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
+ "done" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marked 1 when the task was done - will be deleted later"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["id"],
+ "pid" => ["pid"],
+ "parameter" => ["parameter(64)"],
+ "priority_created_next_try" => ["priority", "created", "next_try"],
+ "done_executed_next_try" => ["done", "executed", "next_try"]
+ ]
+ ]
+];
; Set to 0 to disable, 2 to enable, 1 is deprecated but wont need mcrypt.
rino_encrypt = 2
+; temppath (String)
+; Custom temporary file directory
+temppath =
+
; theme (String)
; System theme name.
theme = vier
Addon::callHooks('item_photo_menu', $args);
Addon::callHooks('jot_tool', $jotplugins);
-### include/security.php
-
- Addon::callHooks('logged_in', $a->user);
-
### include/text.php
Addon::callHooks('contact_block_end', $arr);
Addon::callHooks($a->module.'_post_'.$selname, $o);
Addon::callHooks('jot_networks', $jotnets);
+### src/Core/Authentication.php
+
+ Addon::callHooks('logged_in', $a->user);
+
+
### src/Core/Worker.php
Addon::callHooks("proc_run", $arr);
Furthermore there are several client projects, especially for use with Friendica.
If you are interested in improving those clients, please contact the developers of the clients directly.
-* Android / LinageOS: **Friendiqa** [src](https://github.com/LubuWest/Friendiqa) developed by [Marco R](https://freunde.ma-nic.de/profile/marco)
+* Android / LinageOS: **Friendiqa** [src](https://git.friendi.ca/lubuwest/Friendiqa)/[Google Play](https://play.google.com/store/apps/details?id=org.qtproject.friendiqa) developed by [Marco R](https://freunde.ma-nic.de/profile/marco)
* iOS: *currently no client*
* SailfishOS: **Friendiy** [src](https://kirgroup.com/projects/fabrixxm/harbour-friendly) - developed by [Fabio](https://kirgroup.com/profile/fabrixxm/?tab=profile)
* Windows: **Friendica Mobile** for Windows versions [before 8.1](http://windowsphone.com/s?appid=e3257730-c9cf-4935-9620-5261e3505c67) and [Windows 10](https://www.microsoft.com/store/apps/9nblggh0fhmn) - developed by [Gerhard Seeber](http://mozartweg.dyndns.org/friendica/profile/gerhard/?tab=profile)
* 1: image with or height at <= 640
* 2: image with or height at <= 320
* 3: thumbnail 160x160
-* 4: Profile image at 175x175
+* 4: Profile image at 300x300
* 5: Profile image at 80x80
* 6: Profile image at 48x48
Addon::callHooks('item_photo_menu', $args);
Addon::callHooks('jot_tool', $jotplugins);
-### include/security.php
-
- Addon::callHooks('logged_in', $a->user);
-
### include/text.php
Addon::callHooks('contact_block_end', $arr);
Addon::callHooks('page_header', $a->page['nav']);
Addon::callHooks('nav_info', $nav);
+### src/Core/Authentication.php
+
+ Addon::callHooks('logged_in', $a->user);
+
### src/Worker/Directory.php
Addon::callHooks('globaldir_update', $arr);
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
+use Friendica\Core\Authentication;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\NotificationsManager;
require_once 'include/conversation.php';
require_once 'mod/share.php';
require_once 'mod/item.php';
-require_once 'include/security.php';
require_once 'mod/wall_upload.php';
define('API_METHOD_ANY', '*');
throw new UnauthorizedException("This API requires login");
}
- authenticate_success($record);
+ Authentication::setAuthenticatedSessionForUser($record);
$_SESSION["allow_api"] = true;
}
if ($status_info["source"] == 'web') {
- $status_info["source"] = ContactSelector::networkToName($lastwall['network'], $user_info['url']);
- } elseif (ContactSelector::networkToName($lastwall['network'], $user_info['url']) != $status_info["source"]) {
- $status_info["source"] = trim($status_info["source"].' ('.ContactSelector::networkToName($lastwall['network'], $user_info['url']).')');
+ $status_info["source"] = ContactSelector::networkToName($lastwall['network'], $lastwall['author-link']);
+ } elseif (ContactSelector::networkToName($lastwall['network'], $lastwall['author-link']) != $status_info["source"]) {
+ $status_info["source"] = trim($status_info["source"].' ('.ContactSelector::networkToName($lastwall['network'], $lastwall['author-link']).')');
}
// "uid" and "self" are only needed for some internal stuff, so remove it from here
}
if ($user_info["status"]["source"] == 'web') {
- $user_info["status"]["source"] = ContactSelector::networkToName($lastwall['network'], $user_info['url']);
+ $user_info["status"]["source"] = ContactSelector::networkToName($lastwall['network'], $lastwall['author-link']);
}
if (ContactSelector::networkToName($lastwall['network'], $user_info['url']) != $user_info["status"]["source"]) {
- $user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . ContactSelector::networkToName($lastwall['network'], $user_info['url']) . ')');
+ $user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . ContactSelector::networkToName($lastwall['network'], $lastwall['author-link']) . ')');
}
}
}
if ($status["source"] == 'web') {
- $status["source"] = ContactSelector::networkToName($item['network'], $user_info['url']);
- } elseif (ContactSelector::networkToName($item['network'], $user_info['url']) != $status["source"]) {
- $status["source"] = trim($status["source"].' ('.ContactSelector::networkToName($item['network'], $user_info['url']).')');
+ $status["source"] = ContactSelector::networkToName($item['network'], $item['author-link']);
+ } elseif (ContactSelector::networkToName($item['network'], $item['author-link']) != $status["source"]) {
+ $status["source"] = trim($status["source"].' ('.ContactSelector::networkToName($item['network'], $item['author-link']).')');
}
if ($item["id"] == $item["parent"]) {
// upload profile image (scales 4, 5, 6)
logger("photo upload: starting new profile image upload", LOGGER_DEBUG);
- if ($width > 175 || $height > 175) {
- $Image->scaleDown(175);
+ if ($width > 300 || $height > 300) {
+ $Image->scaleDown(300);
$r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 4, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if (!$r) {
- logger("photo upload: profile image upload with scale 4 (175x175) failed");
+ logger("photo upload: profile image upload with scale 4 (300x300) failed");
}
}
logger($contact['name'] . ' ' . $sec, LOGGER_DEBUG);
$dest = ($url ? '&destination_url=' . $url : '');
- goaway(
+
+ System::externalRedirect(
$contact['poll'] . '?dfrn_id=' . $dfrn_id
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION
. '&type=profile&sec=' . $sec . $dest
$author = ['uid' => 0, 'id' => $item['author-id'],
'network' => $item['author-network'], 'url' => $item['author-link']];
- if (!empty($item['plink'])) {
+ // Only create a redirection to a magic link when logged in
+ if (!empty($item['plink']) && (local_user() || remote_user())) {
$item['plink'] = Contact::magicLinkbyContact($author, $item['plink']);
}
}
$page_dropping = ((local_user() && local_user() == $profile_owner) ? true : false);
if (!$update) {
- $_SESSION['return_url'] = $a->query_string;
+ $_SESSION['return_path'] = $a->query_string;
}
$cb = ['items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview];
if ($cid && !$item['self']) {
$poke_link = 'poke/?f=&c=' . $cid;
- $contact_url = 'contacts/' . $cid;
- $posts_link = 'contacts/' . $cid . '/posts';
+ $contact_url = 'contact/' . $cid;
+ $posts_link = 'contact/' . $cid . '/posts';
if (in_array($network, [Protocol::DFRN, Protocol::DIASPORA])) {
$pm_url = 'message/new/' . $cid;
// with $params['show_in_notification_page'] == false, the notification isn't inserted into
// the database, and an email is sent if applicable.
// default, if not specified: true
- $show_in_notification_page = ((x($params, 'show_in_notification_page')) ? $params['show_in_notification_page']:true);
+ $show_in_notification_page = isset($params['show_in_notification_page']) ? $params['show_in_notification_page'] : true;
$additional_mail_header = "";
$additional_mail_header .= "Precedence: list\n";
$thread = Item::selectFirstThreadForUser($params['uid'] ,['ignored'], ['iid' => $parent_id]);
if (DBA::isResult($thread) && $thread["ignored"]) {
logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
+ L10n::popLang();
return;
}
'$content_allowed' => $content_allowed,
]);
+ L10n::popLang();
// use the Emailer class to send the message
return Emailer::send(
[
);
}
+ L10n::popLang();
return false;
}
if (!DBA::isResult($item)) {
notice(L10n::t('Item not found.') . EOL);
- goaway('/network');
+ $a->internalRedirect('network');
}
if ($item['deleted']) {
}
// Now check how the user responded to the confirmation query
if (!empty($_REQUEST['canceled'])) {
- goaway('/display/' . $item['guid']);
+ $a->internalRedirect('display/' . $item['guid']);
}
// delete the item
Item::deleteForUser(['id' => $item['id']], local_user());
- goaway('/network');
+ $a->internalRedirect('network');
//NOTREACHED
} else {
notice(L10n::t('Permission denied.') . EOL);
- goaway('/display/' . $item['guid']);
+ $a->internalRedirect('display/' . $item['guid']);
//NOTREACHED
}
}
+++ /dev/null
-<?php
-/**
- * @file include/security.php
- */
-
-use Friendica\Core\Addon;
-use Friendica\Core\Config;
-use Friendica\Core\L10n;
-use Friendica\Core\PConfig;
-use Friendica\Core\System;
-use Friendica\Database\DBA;
-use Friendica\Model\Contact;
-use Friendica\Model\Group;
-use Friendica\Util\DateTimeFormat;
-use Friendica\Model\PermissionSet;
-
-/**
- * @brief Calculate the hash that is needed for the "Friendica" cookie
- *
- * @param array $user Record from "user" table
- *
- * @return string Hashed data
- */
-function cookie_hash($user)
-{
- return(hash("sha256", Config::get("system", "site_prvkey") .
- $user["prvkey"] .
- $user["password"]));
-}
-
-/**
- * @brief Set the "Friendica" cookie
- *
- * @param int $time
- * @param array $user Record from "user" table
- */
-function new_cookie($time, $user = [])
-{
- if ($time != 0) {
- $time = $time + time();
- }
-
- if ($user) {
- $value = json_encode(["uid" => $user["uid"],
- "hash" => cookie_hash($user),
- "ip" => defaults($_SERVER, 'REMOTE_ADDR', '0.0.0.0')]);
- } else {
- $value = "";
- }
-
- setcookie("Friendica", $value, $time, "/", "", (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL), true);
-}
-
-/**
- * @brief Sets the provided user's authenticated session
- *
- * @todo Should be moved to Friendica\Core\Session once it's created
- *
- * @param type $user_record
- * @param type $login_initial
- * @param type $interactive
- * @param type $login_refresh
- */
-function authenticate_success($user_record, $login_initial = false, $interactive = false, $login_refresh = false)
-{
- $a = get_app();
-
- $_SESSION['uid'] = $user_record['uid'];
- $_SESSION['theme'] = $user_record['theme'];
- $_SESSION['mobile-theme'] = PConfig::get($user_record['uid'], 'system', 'mobile_theme');
- $_SESSION['authenticated'] = 1;
- $_SESSION['page_flags'] = $user_record['page-flags'];
- $_SESSION['my_url'] = System::baseUrl() . '/profile/' . $user_record['nickname'];
- $_SESSION['my_address'] = $user_record['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);
- $_SESSION['addr'] = defaults($_SERVER, 'REMOTE_ADDR', '0.0.0.0');
-
- $a->user = $user_record;
-
- if ($interactive) {
- if ($a->user['login_date'] <= NULL_DATE) {
- $_SESSION['return_url'] = 'profile_photo/new';
- $a->module = 'profile_photo';
- info(L10n::t("Welcome ") . $a->user['username'] . EOL);
- info(L10n::t('Please upload a profile photo.') . EOL);
- } else {
- info(L10n::t("Welcome back ") . $a->user['username'] . EOL);
- }
- }
-
- $member_since = strtotime($a->user['register_date']);
- if (time() < ($member_since + ( 60 * 60 * 24 * 14))) {
- $_SESSION['new_member'] = true;
- } else {
- $_SESSION['new_member'] = false;
- }
- if (strlen($a->user['timezone'])) {
- date_default_timezone_set($a->user['timezone']);
- $a->timezone = $a->user['timezone'];
- }
-
- $master_record = $a->user;
-
- if ((x($_SESSION, 'submanage')) && intval($_SESSION['submanage'])) {
- $user = DBA::selectFirst('user', [], ['uid' => $_SESSION['submanage']]);
- if (DBA::isResult($user)) {
- $master_record = $user;
- }
- }
-
- if ($master_record['parent-uid'] == 0) {
- // First add our own entry
- $a->identities = [['uid' => $master_record['uid'],
- 'username' => $master_record['username'],
- 'nickname' => $master_record['nickname']]];
-
- // Then add all the children
- $r = DBA::select('user', ['uid', 'username', 'nickname'],
- ['parent-uid' => $master_record['uid'], 'account_removed' => false]);
- if (DBA::isResult($r)) {
- $a->identities = array_merge($a->identities, DBA::toArray($r));
- }
- } else {
- // Just ensure that the array is always defined
- $a->identities = [];
-
- // First entry is our parent
- $r = DBA::select('user', ['uid', 'username', 'nickname'],
- ['uid' => $master_record['parent-uid'], 'account_removed' => false]);
- if (DBA::isResult($r)) {
- $a->identities = DBA::toArray($r);
- }
-
- // Then add all siblings
- $r = DBA::select('user', ['uid', 'username', 'nickname'],
- ['parent-uid' => $master_record['parent-uid'], 'account_removed' => false]);
- if (DBA::isResult($r)) {
- $a->identities = array_merge($a->identities, DBA::toArray($r));
- }
- }
-
- $r = DBA::p("SELECT `user`.`uid`, `user`.`username`, `user`.`nickname`
- FROM `manage`
- INNER JOIN `user` ON `manage`.`mid` = `user`.`uid`
- WHERE `user`.`account_removed` = 0 AND `manage`.`uid` = ?",
- $master_record['uid']
- );
- if (DBA::isResult($r)) {
- $a->identities = array_merge($a->identities, DBA::toArray($r));
- }
-
- if ($login_initial) {
- logger('auth_identities: ' . print_r($a->identities, true), LOGGER_DEBUG);
- }
- if ($login_refresh) {
- logger('auth_identities refresh: ' . print_r($a->identities, true), LOGGER_DEBUG);
- }
-
- $contact = DBA::selectFirst('contact', [], ['uid' => $_SESSION['uid'], 'self' => true]);
- if (DBA::isResult($contact)) {
- $a->contact = $contact;
- $a->cid = $contact['id'];
- $_SESSION['cid'] = $a->cid;
- }
-
- header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] . '"');
-
- if ($login_initial || $login_refresh) {
- DBA::update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $_SESSION['uid']]);
-
- // Set the login date for all identities of the user
- DBA::update('user', ['login_date' => DateTimeFormat::utcNow()],
- ['parent-uid' => $master_record['uid'], 'account_removed' => false]);
- }
-
- if ($login_initial) {
- /*
- * If the user specified to remember the authentication, then set a cookie
- * that expires after one week (the default is when the browser is closed).
- * The cookie will be renewed automatically.
- * The week ensures that sessions will expire after some inactivity.
- */
- if (!empty($_SESSION['remember'])) {
- logger('Injecting cookie for remembered user ' . $a->user['nickname']);
- new_cookie(604800, $user_record);
- unset($_SESSION['remember']);
- }
- }
-
- if ($login_initial) {
- Addon::callHooks('logged_in', $a->user);
-
- if (($a->module !== 'home') && isset($_SESSION['return_url'])) {
- goaway(System::baseUrl() . '/' . $_SESSION['return_url']);
- }
- }
-}
-
-function can_write_wall($owner)
-{
- static $verified = 0;
-
- if (!local_user() && !remote_user()) {
- return false;
- }
-
- $uid = local_user();
- if ($uid == $owner) {
- return true;
- }
-
- if (local_user() && ($owner == 0)) {
- return true;
- }
-
- if (remote_user()) {
- // use remembered decision and avoid a DB lookup for each and every display item
- // DO NOT use this function if there are going to be multiple owners
- // We have a contact-id for an authenticated remote user, this block determines if the contact
- // belongs to this page owner, and has the necessary permissions to post content
-
- if ($verified === 2) {
- return true;
- } elseif ($verified === 1) {
- return false;
- } else {
- $cid = 0;
-
- if (!empty($_SESSION['remote'])) {
- foreach ($_SESSION['remote'] as $visitor) {
- if ($visitor['uid'] == $owner) {
- $cid = $visitor['cid'];
- break;
- }
- }
- }
-
- if (!$cid) {
- return false;
- }
-
- $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `user`.`uid` = `contact`.`uid`
- WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- AND `user`.`blockwall` = 0 AND `readonly` = 0 AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page-flags` = %d ) LIMIT 1",
- intval($owner),
- intval($cid),
- intval(Contact::SHARING),
- intval(Contact::FRIEND),
- intval(Contact::PAGE_COMMUNITY)
- );
-
- if (DBA::isResult($r)) {
- $verified = 2;
- return true;
- } else {
- $verified = 1;
- }
- }
- }
-
- return false;
-}
-
-/// @TODO $groups should be array
-function permissions_sql($owner_id, $remote_verified = false, $groups = null)
-{
- $local_user = local_user();
- $remote_user = remote_user();
-
- /**
- * Construct permissions
- *
- * default permissions - anonymous user
- */
- $sql = " AND allow_cid = ''
- AND allow_gid = ''
- AND deny_cid = ''
- AND deny_gid = ''
- ";
-
- /**
- * Profile owner - everything is visible
- */
- if ($local_user && $local_user == $owner_id) {
- $sql = '';
- /**
- * Authenticated visitor. Unless pre-verified,
- * check that the contact belongs to this $owner_id
- * and load the groups the visitor belongs to.
- * If pre-verified, the caller is expected to have already
- * done this and passed the groups into this function.
- */
- } elseif ($remote_user) {
- /*
- * Authenticated visitor. Unless pre-verified,
- * check that the contact belongs to this $owner_id
- * and load the groups the visitor belongs to.
- * If pre-verified, the caller is expected to have already
- * done this and passed the groups into this function.
- */
-
- if (!$remote_verified) {
- if (DBA::exists('contact', ['id' => $remote_user, 'uid' => $owner_id, 'blocked' => false])) {
- $remote_verified = true;
- $groups = Group::getIdsByContactId($remote_user);
- }
- }
-
- if ($remote_verified) {
- $gs = '<<>>'; // should be impossible to match
-
- if (is_array($groups)) {
- foreach ($groups as $g) {
- $gs .= '|<' . intval($g) . '>';
- }
- }
-
- $sql = sprintf(
- " AND ( NOT (deny_cid REGEXP '<%d>' OR deny_gid REGEXP '%s')
- AND ( allow_cid REGEXP '<%d>' OR allow_gid REGEXP '%s' OR ( allow_cid = '' AND allow_gid = '') )
- )
- ",
- intval($remote_user),
- DBA::escape($gs),
- intval($remote_user),
- DBA::escape($gs)
- );
- }
- }
- return $sql;
-}
-
-function item_permissions_sql($owner_id, $remote_verified = false, $groups = null)
-{
- $local_user = local_user();
- $remote_user = remote_user();
-
- /*
- * Construct permissions
- *
- * default permissions - anonymous user
- */
- $sql = " AND NOT `item`.`private`";
-
- // Profile owner - everything is visible
- if ($local_user && ($local_user == $owner_id)) {
- $sql = '';
- } elseif ($remote_user) {
- /*
- * Authenticated visitor. Unless pre-verified,
- * check that the contact belongs to this $owner_id
- * and load the groups the visitor belongs to.
- * If pre-verified, the caller is expected to have already
- * done this and passed the groups into this function.
- */
- $set = PermissionSet::get($owner_id, $remote_user, $groups);
-
- if (!empty($set)) {
- $sql_set = " OR (`item`.`private` IN (1,2) AND `item`.`wall` AND `item`.`psid` IN (" . implode(',', $set) . "))";
- } else {
- $sql_set = '';
- }
-
- $sql = " AND (NOT `item`.`private`" . $sql_set . ")";
- }
-
- return $sql;
-}
-
-/*
- * Functions used to protect against Cross-Site Request Forgery
- * The security token has to base on at least one value that an attacker can't know - here it's the session ID and the private key.
- * In this implementation, a security token is reusable (if the user submits a form, goes back and resubmits the form, maybe with small changes;
- * or if the security token is used for ajax-calls that happen several times), but only valid for a certain amout of time (3hours).
- * The "typename" seperates the security tokens of different types of forms. This could be relevant in the following case:
- * A security token is used to protekt a link from CSRF (e.g. the "delete this profile"-link).
- * If the new page contains by any chance external elements, then the used security token is exposed by the referrer.
- * Actually, important actions should not be triggered by Links / GET-Requests at all, but somethimes they still are,
- * so this mechanism brings in some damage control (the attacker would be able to forge a request to a form of this type, but not to forms of other types).
- */
-function get_form_security_token($typename = '')
-{
- $a = get_app();
-
- $timestamp = time();
- $sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $timestamp . $typename);
-
- return $timestamp . '.' . $sec_hash;
-}
-
-function check_form_security_token($typename = '', $formname = 'form_security_token')
-{
- $hash = null;
-
- if (!empty($_REQUEST[$formname])) {
- /// @TODO Careful, not secured!
- $hash = $_REQUEST[$formname];
- }
-
- if (!empty($_SERVER['HTTP_X_CSRF_TOKEN'])) {
- /// @TODO Careful, not secured!
- $hash = $_SERVER['HTTP_X_CSRF_TOKEN'];
- }
-
- if (empty($hash)) {
- return false;
- }
-
- $max_livetime = 10800; // 3 hours
-
- $a = get_app();
-
- $x = explode('.', $hash);
- if (time() > (IntVal($x[0]) + $max_livetime)) {
- return false;
- }
-
- $sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $x[0] . $typename);
-
- return ($sec_hash == $x[1]);
-}
-
-function check_form_security_std_err_msg()
-{
- return L10n::t("The form security token was not correct. This probably happened because the form has been opened for too long \x28>3 hours\x29 before submitting it.") . EOL;
-}
-
-function check_form_security_token_redirectOnErr($err_redirect, $typename = '', $formname = 'form_security_token')
-{
- if (!check_form_security_token($typename, $formname)) {
- $a = get_app();
- logger('check_form_security_token failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
- logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA);
- notice(check_form_security_std_err_msg());
- goaway(System::baseUrl() . $err_redirect);
- }
-}
-
-function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token')
-{
- if (!check_form_security_token($typename, $formname)) {
- $a = get_app();
- logger('check_form_security_token failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
- logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA);
- header('HTTP/1.1 403 Forbidden');
- killme();
- }
-}
-
-/**
- * @brief Kills the "Friendica" cookie and all session data
- */
-function nuke_session()
-{
- new_cookie(-3600); // make sure cookie is deleted on browser close, as a security measure
- session_unset();
- session_destroy();
-}
* Friendica
*/
-/**
- * Bootstrap the application
- */
-
use Friendica\App;
-use Friendica\Content\Nav;
-use Friendica\Core\Addon;
-use Friendica\Core\Config;
-use Friendica\Core\L10n;
-use Friendica\Core\Session;
-use Friendica\Core\System;
-use Friendica\Core\Theme;
-use Friendica\Core\Worker;
-use Friendica\Database\DBA;
-use Friendica\Model\Profile;
-use Friendica\Module\Login;
require_once 'boot.php';
// We assume that the index.php is called by a frontend process
-// The value is set to "true" by default in boot.php
+// The value is set to "true" by default in App
$a = new App(__DIR__, false);
-/**
- * Try to open the database;
- */
-
-require_once "include/dba.php";
-
-// Missing DB connection: ERROR
-if ($a->getMode()->has(App\Mode::LOCALCONFIGPRESENT) && !$a->getMode()->has(App\Mode::DBAVAILABLE)) {
- System::httpExit(500, ['title' => 'Error 500 - Internal Server Error', 'description' => 'Apologies but the website is unavailable at the moment.']);
-}
-
-// Max Load Average reached: ERROR
-if ($a->isMaxProcessesReached() || $a->isMaxLoadReached()) {
- header('Retry-After: 120');
- header('Refresh: 120; url=' . System::baseUrl() . "/" . $a->query_string);
-
- System::httpExit(503, ['title' => 'Error 503 - Service Temporarily Unavailable', 'description' => 'System is currently overloaded. Please try again later.']);
-}
-
-if (strstr($a->query_string, '.well-known/host-meta') && ($a->query_string != '.well-known/host-meta')) {
- System::httpExit(404);
-}
-
-if (!$a->getMode()->isInstall()) {
- if (Config::get('system', 'force_ssl') && ($a->getScheme() == "http")
- && (intval(Config::get('system', 'ssl_policy')) == SSL_POLICY_FULL)
- && (substr(System::baseUrl(), 0, 8) == "https://")
- && ($_SERVER['REQUEST_METHOD'] == 'GET')) {
- header("HTTP/1.1 302 Moved Temporarily");
- header("Location: " . System::baseUrl() . "/" . $a->query_string);
- exit();
- }
-
- Config::init();
- Session::init();
- Addon::loadHooks();
- Addon::callHooks('init_1');
-}
-
-$lang = L10n::getBrowserLanguage();
-
-L10n::loadTranslationTable($lang);
-
-/**
- * Important stuff we always need to do.
- *
- * The order of these may be important so use caution if you think they're all
- * intertwingled with no logical order and decide to sort it out. Some of the
- * dependencies have changed, but at least at one time in the recent past - the
- * order was critical to everything working properly
- */
-
-// Exclude the backend processes from the session management
-if (!$a->isBackend()) {
- $stamp1 = microtime(true);
- session_start();
- $a->saveTimestamp($stamp1, "parser");
-} else {
- $_SESSION = [];
- Worker::executeIfIdle();
-}
-
-/**
- * Language was set earlier, but we can over-ride it in the session.
- * We have to do it here because the session was just now opened.
- */
-if (!empty($_SESSION['authenticated']) && empty($_SESSION['language'])) {
- $_SESSION['language'] = $lang;
- // we haven't loaded user data yet, but we need user language
- if (!empty($_SESSION['uid'])) {
- $user = DBA::selectFirst('user', ['language'], ['uid' => $_SESSION['uid']]);
- if (DBA::isResult($user)) {
- $_SESSION['language'] = $user['language'];
- }
- }
-}
-
-if (!empty($_SESSION['language']) && $_SESSION['language'] !== $lang) {
- $lang = $_SESSION['language'];
- L10n::loadTranslationTable($lang);
-}
-
-if (!empty($_GET['zrl']) && $a->getMode()->isNormal()) {
- $a->query_string = Profile::stripZrls($a->query_string);
- if (!local_user()) {
- // Only continue when the given profile link seems valid
- // Valid profile links contain a path with "/profile/" and no query parameters
- if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "") &&
- strstr(parse_url($_GET['zrl'], PHP_URL_PATH), "/profile/")) {
- if (defaults($_SESSION, "visitor_home", "") != $_GET["zrl"]) {
- $_SESSION['my_url'] = $_GET['zrl'];
- $_SESSION['authenticated'] = 0;
- }
- Profile::zrlInit($a);
- } else {
- // Someone came with an invalid parameter, maybe as a DDoS attempt
- // We simply stop processing here
- logger("Invalid ZRL parameter " . $_GET['zrl'], LOGGER_DEBUG);
- header('HTTP/1.1 403 Forbidden');
- echo "<h1>403 Forbidden</h1>";
- exit();
- }
- }
-}
-
-if (!empty($_GET['owt']) && $a->getMode()->isNormal()) {
- $token = $_GET['owt'];
- $a->query_string = Profile::stripQueryParam($a->query_string, 'owt');
- Profile::openWebAuthInit($token);
-}
-
-/**
- * For Mozilla auth manager - still needs sorting, and this might conflict with LRDD header.
- * Apache/PHP lumps the Link: headers into one - and other services might not be able to parse it
- * this way. There's a PHP flag to link the headers because by default this will over-write any other
- * link header.
- *
- * What we really need to do is output the raw headers ourselves so we can keep them separate.
- */
-
-// header('Link: <' . System::baseUrl() . '/amcd>; rel="acct-mgmt";');
-
-Login::sessionAuth();
-
-if (empty($_SESSION['authenticated'])) {
- header('X-Account-Management-Status: none');
-}
-
-$_SESSION['sysmsg'] = defaults($_SESSION, 'sysmsg' , []);
-$_SESSION['sysmsg_info'] = defaults($_SESSION, 'sysmsg_info' , []);
-$_SESSION['last_updated'] = defaults($_SESSION, 'last_updated', []);
-
-/*
- * check_config() is responsible for running update scripts. These automatically
- * update the DB schema whenever we push a new one out. It also checks to see if
- * any addons have been added or removed and reacts accordingly.
- */
-
-// in install mode, any url loads install module
-// but we need "view" module for stylesheet
-if ($a->getMode()->isInstall() && $a->module != 'view') {
- $a->module = 'install';
-} elseif (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED) && $a->module != 'view') {
- $a->module = 'maintenance';
-} else {
- check_url($a);
- check_db(false);
- Addon::check();
-}
-
-Nav::setSelected('nothing');
-
-//Don't populate apps_menu if apps are private
-$privateapps = Config::get('config', 'private_addons');
-if ((local_user()) || (! $privateapps === "1")) {
- $arr = ['app_menu' => $a->apps];
-
- Addon::callHooks('app_menu', $arr);
-
- $a->apps = $arr['app_menu'];
-}
-
-/**
- * We have already parsed the server path into $a->argc and $a->argv
- *
- * $a->argv[0] is our module name. We will load the file mod/{$a->argv[0]}.php
- * and use it for handling our URL request.
- * The module file contains a few functions that we call in various circumstances
- * and in the following order:
- *
- * "module"_init
- * "module"_post (only called if there are $_POST variables)
- * "module"_afterpost
- * "module"_content - the string return of this function contains our page body
- *
- * Modules which emit other serialisations besides HTML (XML,JSON, etc.) should do
- * so within the module init and/or post functions and then invoke killme() to terminate
- * further processing.
- */
-if (strlen($a->module)) {
-
- /**
- * We will always have a module name.
- * First see if we have an addon which is masquerading as a module.
- */
-
- // Compatibility with the Android Diaspora client
- if ($a->module == 'stream') {
- goaway('network?f=&order=post');
- }
-
- if ($a->module == 'conversations') {
- goaway('message');
- }
-
- if ($a->module == 'commented') {
- goaway('network?f=&order=comment');
- }
-
- if ($a->module == 'liked') {
- goaway('network?f=&order=comment');
- }
-
- if ($a->module == 'activity') {
- goaway('network/?f=&conv=1');
- }
-
- if (($a->module == 'status_messages') && ($a->cmd == 'status_messages/new')) {
- goaway('bookmarklet');
- }
-
- if (($a->module == 'user') && ($a->cmd == 'user/edit')) {
- goaway('settings');
- }
-
- if (($a->module == 'tag_followings') && ($a->cmd == 'tag_followings/manage')) {
- goaway('search');
- }
-
- // Compatibility with the Firefox App
- if (($a->module == "users") && ($a->cmd == "users/sign_in")) {
- $a->module = "login";
- }
-
- $privateapps = Config::get('config', 'private_addons');
-
- if (is_array($a->addons) && in_array($a->module, $a->addons) && file_exists("addon/{$a->module}/{$a->module}.php")) {
- //Check if module is an app and if public access to apps is allowed or not
- if ((!local_user()) && Addon::isApp($a->module) && $privateapps === "1") {
- info(L10n::t("You must be logged in to use addons. "));
- } else {
- include_once "addon/{$a->module}/{$a->module}.php";
- if (function_exists($a->module . '_module')) {
- $a->module_loaded = true;
- }
- }
- }
-
- // Controller class routing
- if (! $a->module_loaded && class_exists('Friendica\\Module\\' . ucfirst($a->module))) {
- $a->module_class = 'Friendica\\Module\\' . ucfirst($a->module);
- $a->module_loaded = true;
- }
-
- /**
- * If not, next look for a 'standard' program module in the 'mod' directory
- */
-
- if (! $a->module_loaded && file_exists("mod/{$a->module}.php")) {
- include_once "mod/{$a->module}.php";
- $a->module_loaded = true;
- }
-
- /**
- * The URL provided does not resolve to a valid module.
- *
- * On Dreamhost sites, quite often things go wrong for no apparent reason and they send us to '/internal_error.html'.
- * We don't like doing this, but as it occasionally accounts for 10-20% or more of all site traffic -
- * we are going to trap this and redirect back to the requested page. As long as you don't have a critical error on your page
- * this will often succeed and eventually do the right thing.
- *
- * Otherwise we are going to emit a 404 not found.
- */
-
- if (! $a->module_loaded) {
- // Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit.
- if (!empty($_SERVER['QUERY_STRING']) && preg_match('/{[0-9]}/', $_SERVER['QUERY_STRING']) !== 0) {
- killme();
- }
-
- if (!empty($_SERVER['QUERY_STRING']) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
- logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']);
- goaway(System::baseUrl() . $_SERVER['REQUEST_URI']);
- }
-
- logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG);
- header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . L10n::t('Not Found'));
- $tpl = get_markup_template("404.tpl");
- $a->page['content'] = replace_macros($tpl, [
- '$message' => L10n::t('Page not found.')
- ]);
- }
-}
-
-/**
- * Load current theme info
- */
-$theme_info_file = 'view/theme/' . $a->getCurrentTheme() . '/theme.php';
-if (file_exists($theme_info_file)) {
- require_once $theme_info_file;
-}
-
-
-/* initialise content region */
-
-if ($a->getMode()->isNormal()) {
- Addon::callHooks('page_content_top', $a->page['content']);
-}
-
-/**
- * Call module functions
- */
-
-if ($a->module_loaded) {
- $a->page['page_title'] = $a->module;
- $placeholder = '';
-
- Addon::callHooks($a->module . '_mod_init', $placeholder);
-
- if ($a->module_class) {
- call_user_func([$a->module_class, 'init']);
- } else if (function_exists($a->module . '_init')) {
- $func = $a->module . '_init';
- $func($a);
- }
-
- // "rawContent" is especially meant for technical endpoints.
- // This endpoint doesn't need any theme initialization or other comparable stuff.
- if (!$a->error && $a->module_class) {
- call_user_func([$a->module_class, 'rawContent']);
- }
-
- if (function_exists(str_replace('-', '_', $a->getCurrentTheme()) . '_init')) {
- $func = str_replace('-', '_', $a->getCurrentTheme()) . '_init';
- $func($a);
- }
-
- if (! $a->error && $_SERVER['REQUEST_METHOD'] === 'POST') {
- Addon::callHooks($a->module . '_mod_post', $_POST);
- if ($a->module_class) {
- call_user_func([$a->module_class, 'post']);
- } else if (function_exists($a->module . '_post')) {
- $func = $a->module . '_post';
- $func($a);
- }
- }
-
- if (! $a->error) {
- Addon::callHooks($a->module . '_mod_afterpost', $placeholder);
- if ($a->module_class) {
- call_user_func([$a->module_class, 'afterpost']);
- } else if (function_exists($a->module . '_afterpost')) {
- $func = $a->module . '_afterpost';
- $func($a);
- }
- }
-
- if (! $a->error) {
- $arr = ['content' => $a->page['content']];
- Addon::callHooks($a->module . '_mod_content', $arr);
- $a->page['content'] = $arr['content'];
- if ($a->module_class) {
- $arr = ['content' => call_user_func([$a->module_class, 'content'])];
- } else if (function_exists($a->module . '_content')) {
- $func = $a->module . '_content';
- $arr = ['content' => $func($a)];
- }
- Addon::callHooks($a->module . '_mod_aftercontent', $arr);
- $a->page['content'] .= $arr['content'];
- }
-
- if (function_exists(str_replace('-', '_', $a->getCurrentTheme()) . '_content_loaded')) {
- $func = str_replace('-', '_', $a->getCurrentTheme()) . '_content_loaded';
- $func($a);
- }
-}
-
-/*
- * Create the page head after setting the language
- * and getting any auth credentials.
- *
- * Moved init_pagehead() and init_page_end() to after
- * all the module functions have executed so that all
- * theme choices made by the modules can take effect.
- */
-
-$a->initHead();
-
-/*
- * Build the page ending -- this is stuff that goes right before
- * the closing </body> tag
- */
-$a->initFooter();
-
-/*
- * now that we've been through the module content, see if the page reported
- * a permission problem and if so, a 403 response would seem to be in order.
- */
-if (stristr(implode("", $_SESSION['sysmsg']), L10n::t('Permission denied'))) {
- header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . L10n::t('Permission denied.'));
-}
-
-/*
- * Report anything which needs to be communicated in the notification area (before the main body)
- */
-Addon::callHooks('page_end', $a->page['content']);
-
-/*
- * Add the navigation (menu) template
- */
-if ($a->module != 'install' && $a->module != 'maintenance') {
- Nav::build($a);
-}
-
-/**
- * Build the page - now that we have all the components
- */
-if (isset($_GET["mode"]) && (($_GET["mode"] == "raw") || ($_GET["mode"] == "minimal"))) {
- $doc = new DOMDocument();
-
- $target = new DOMDocument();
- $target->loadXML("<root></root>");
-
- $content = mb_convert_encoding($a->page["content"], 'HTML-ENTITIES', "UTF-8");
-
- /// @TODO one day, kill those error-surpressing @ stuff, or PHP should ban it
- @$doc->loadHTML($content);
-
- $xpath = new DOMXPath($doc);
-
- $list = $xpath->query("//*[contains(@id,'tread-wrapper-')]"); /* */
-
- foreach ($list as $item) {
- $item = $target->importNode($item, true);
-
- // And then append it to the target
- $target->documentElement->appendChild($item);
- }
-}
-
-if (isset($_GET["mode"]) && ($_GET["mode"] == "raw")) {
- header("Content-type: text/html; charset=utf-8");
-
- echo substr($target->saveHTML(), 6, -8);
-
- exit();
-}
-
-$page = $a->page;
-$profile = $a->profile;
-
-header("X-Friendica-Version: " . FRIENDICA_VERSION);
-header("Content-type: text/html; charset=utf-8");
-
-if (Config::get('system', 'hsts') && (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL)) {
- header("Strict-Transport-Security: max-age=31536000");
-}
-
-// Some security stuff
-header('X-Content-Type-Options: nosniff');
-header('X-XSS-Protection: 1; mode=block');
-header('X-Permitted-Cross-Domain-Policies: none');
-header('X-Frame-Options: sameorigin');
-
-// Things like embedded OSM maps don't work, when this is enabled
-// header("Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' https: data:; media-src 'self' https:; child-src 'self' https:; object-src 'none'");
-
-/*
- * We use $_GET["mode"] for special page templates. So we will check if we have
- * to load another page template than the default one.
- * The page templates are located in /view/php/ or in the theme directory.
- */
-if (isset($_GET["mode"])) {
- $template = Theme::getPathForFile($_GET["mode"] . '.php');
-}
-
-// If there is no page template use the default page template
-if (empty($template)) {
- $template = Theme::getPathForFile("default.php");
-}
-
-/// @TODO Looks unsafe (remote-inclusion), is maybe not but Theme::getPathForFile() uses file_exists() but does not escape anything
-require_once $template;
+$a->runFrontend();
*/
use Friendica\App;
+use Friendica\BaseModule;
use Friendica\Content\Feature;
use Friendica\Content\Text\Markdown;
use Friendica\Core\Addon;
use Friendica\Database\DBStructure;
use Friendica\Model\Contact;
use Friendica\Model\Item;
+use Friendica\Model\Register;
use Friendica\Model\User;
use Friendica\Module\Login;
use Friendica\Module\Tos;
use Friendica\Util\Arrays;
use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Temporal;
use Friendica\Util\Network;
+use Friendica\Util\Temporal;
require_once 'include/enotify.php';
require_once 'include/text.php';
/**
* @brief Process send data from the admin panels subpages
*
- * This function acts as relais for processing the data send from the subpages
+ * This function acts as relay for processing the data send from the subpages
* of the admin panel. Depending on the 1st parameter of the url (argv[1])
* specialized functions are called to process the data from the subpages.
*
- * The function itself does not return anything, but the subsequencely function
+ * The function itself does not return anything, but the subsequently function
* return the HTML for the pages of the admin panel.
*
* @param App $a
if ($a->isAjax()) {
return;
}
- goaway('admin/');
+ $a->internalRedirect('admin/');
return;
}
}
}
- goaway($return_path);
+ $a->internalRedirect($return_path);
return; // NOTREACHED
}
// array(url, name, extra css classes)
// not part of $aside to make the template more adjustable
$aside_sub = [
- 'information' => [ L10n::t('Information'), [
- "overview" => ["admin/", L10n::t("Overview"), "overview" ],
- 'federation' => ["admin/federation/" , L10n::t('Federation Statistics'), "federation"] ]],
- 'configuration' => [ L10n::t('Configuration'), [
- 'site' => ["admin/site/" , L10n::t("Site") , "site"],
- 'users' => ["admin/users/" , L10n::t("Users") , "users"],
- 'addons' => ["admin/addons/" , L10n::t("Addons") , "addons"],
- 'themes' => ["admin/themes/" , L10n::t("Themes") , "themes"],
- 'features' => ["admin/features/" , L10n::t("Additional features") , "features"],
- 'tos' => ["admin/tos/" , L10n::t("Terms of Service") , "tos"] ]],
- 'database' => [ L10n::t('Database'), [
- 'dbsync' => ["admin/dbsync/" , L10n::t('DB updates') , "dbsync"],
- 'queue' => ["admin/queue/" , L10n::t('Inspect Queue') , "queue"],
- 'workerqueue' => ["admin/workerqueue/" , L10n::t('Inspect worker Queue') , "workerqueue"] ]],
- 'tools' => [ L10n::t('Tools'), [
- 'contactblock' => ["admin/contactblock/", L10n::t('Contact Blocklist') , "contactblock"],
- 'blocklist' => ["admin/blocklist/" , L10n::t('Server Blocklist') , "blocklist"],
- 'deleteitem' => ["admin/deleteitem/" , L10n::t('Delete Item') , 'deleteitem'], ]],
- "logs" => [ L10n::t("Logs"), [
- "logsconfig" => ["admin/logs/", L10n::t("Logs"), "logs"],
- "logsview" => ["admin/viewlogs/", L10n::t("View Logs"), 'viewlogs']
+ 'information' => [L10n::t('Information'), [
+ 'overview' => ['admin/', L10n::t('Overview'), 'overview'],
+ 'federation' => ['admin/federation/' , L10n::t('Federation Statistics'), 'federation']]],
+ 'configuration' => [L10n::t('Configuration'), [
+ 'site' => ['admin/site/' , L10n::t('Site') , 'site'],
+ 'users' => ['admin/users/' , L10n::t('Users') , 'users'],
+ 'addons' => ['admin/addons/' , L10n::t('Addons') , 'addons'],
+ 'themes' => ['admin/themes/' , L10n::t('Themes') , 'themes'],
+ 'features' => ['admin/features/' , L10n::t('Additional features') , 'features'],
+ 'tos' => ['admin/tos/' , L10n::t('Terms of Service') , 'tos']]],
+ 'database' => [L10n::t('Database'), [
+ 'dbsync' => ['admin/dbsync/' , L10n::t('DB updates') , 'dbsync'],
+ 'queue' => ['admin/queue/' , L10n::t('Inspect Queue') , 'queue'],
+ 'deferred' => ['admin/deferred/' , L10n::t('Inspect Deferred Workers'), 'deferred'],
+ 'workerqueue' => ['admin/workerqueue/' , L10n::t('Inspect worker Queue') , 'workerqueue']]],
+ 'tools' => [L10n::t('Tools'), [
+ 'contactblock' => ['admin/contactblock/', L10n::t('Contact Blocklist') , 'contactblock'],
+ 'blocklist' => ['admin/blocklist/' , L10n::t('Server Blocklist') , 'blocklist'],
+ 'deleteitem' => ['admin/deleteitem/' , L10n::t('Delete Item') , 'deleteitem'],]],
+ 'logs' => [L10n::t('Logs'), [
+ 'logsconfig' => ['admin/logs/', L10n::t('Logs'), 'logs'],
+ 'logsview' => ['admin/viewlogs/', L10n::t('View Logs'), 'viewlogs']
]],
- "diagnostics" => [ L10n::t("Diagnostics"), [
- "phpinfo" => ['phpinfo/', L10n::t('PHP Info'), 'phpinfo'],
- "probe" => ['probe/', L10n::t('probe address'), 'probe'],
- "webfinger" =>['webfinger/', L10n::t('check webfinger'), 'webfinger']
+ 'diagnostics' => [L10n::t('Diagnostics'), [
+ 'phpinfo' => ['phpinfo/', L10n::t('PHP Info'), 'phpinfo'],
+ 'probe' => ['probe/', L10n::t('probe address'), 'probe'],
+ 'webfinger' =>['webfinger/', L10n::t('check webfinger'), 'webfinger']
]]
];
$r = q("SELECT `name` FROM `addon` WHERE `plugin_admin` = 1 ORDER BY `name`");
$aside_tools['addons_admin'] = [];
+ $addons_admin = [];
foreach ($r as $h) {
$addon = $h['name'];
$aside_tools['addons_admin'][] = ["admin/addons/" . $addon, $addon, "addon"];
// temp addons with admin
- $a->addons_admin[] = $addon;
+ $addons_admin[] = $addon;
}
$t = get_markup_template('admin/aside.tpl');
$o = admin_page_users($a);
break;
case 'addons':
- $o = admin_page_addons($a);
+ $o = admin_page_addons($a, $addons_admin);
break;
case 'themes':
$o = admin_page_themes($a);
case 'queue':
$o = admin_page_queue($a);
break;
+ case 'deferred':
+ $o = admin_page_workerqueue($a, true);
+ break;
case 'workerqueue':
- $o = admin_page_workerqueue($a);
+ $o = admin_page_workerqueue($a, false);
break;
case 'federation':
$o = admin_page_federation($a);
'$preview' => L10n::t('Privacy Statement Preview'),
'$privtext' => $tos->privacy_complete,
'$tostext' => ['tostext', L10n::t('The Terms of Service'), Config::get('system', 'tostext'), L10n::t('Enter the Terms of Service for your node here. You can use BBCode. Headers of sections should be [h2] and below.')],
- '$form_security_token' => get_form_security_token("admin_tos"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_tos"),
'$submit' => L10n::t('Save Settings'),
]);
}
*/
function admin_page_tos_post(App $a)
{
- check_form_security_token_redirectOnErr('/admin/tos', 'admin_tos');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/tos', 'admin_tos');
if (!x($_POST, "page_tos")) {
return;
Config::set('system', 'tosprivstatement', $displayprivstatement);
Config::set('system', 'tostext', $tostext);
- goaway('admin/tos');
+ $a->internalRedirect('admin/tos');
return; // NOTREACHED
}
'$entries' => $blocklistform,
'$baseurl' => System::baseUrl(true),
'$confirm_delete' => L10n::t('Delete entry from blocklist?'),
- '$form_security_token' => get_form_security_token("admin_blocklist")
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_blocklist")
]);
}
return;
}
- check_form_security_token_redirectOnErr('/admin/blocklist', 'admin_blocklist');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/blocklist', 'admin_blocklist');
if (x($_POST['page_blocklist_save'])) {
// Add new item to blocklist
Config::set('system', 'blocklist', $blocklist);
info(L10n::t('Site blocklist updated.') . EOL);
}
- goaway('admin/blocklist');
+ $a->internalRedirect('admin/blocklist');
return; // NOTREACHED
}
$contact_url = x($_POST, 'contact_url') ? $_POST['contact_url'] : '';
$contacts = x($_POST, 'contacts') ? $_POST['contacts'] : [];
- check_form_security_token_redirectOnErr('/admin/contactblock', 'admin_contactblock');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/contactblock', 'admin_contactblock');
if (x($_POST, 'page_contactblock_block')) {
$contact_id = Contact::getIdForURL($contact_url);
}
notice(L10n::tt("%s contact unblocked", "%s contacts unblocked", count($contacts)));
}
- goaway('admin/contactblock');
+ $a->internalRedirect('admin/contactblock');
return; // NOTREACHED
}
'$h_newblock' => L10n::t('Block New Remote Contact'),
'$th_contacts' => [L10n::t('Photo'), L10n::t('Name'), L10n::t('Address'), L10n::t('Profile URL')],
- '$form_security_token' => get_form_security_token("admin_contactblock"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_contactblock"),
// values //
'$baseurl' => System::baseUrl(true),
'$intro2' => L10n::t('You need to know the GUID of the item. You can find it e.g. by looking at the display URL. The last part of http://example.com/display/123456 is the GUID, here 123456.'),
'$deleteitemguid' => ['deleteitemguid', L10n::t("GUID"), '', L10n::t("The GUID of the item you want to delete."), 'required', 'autofocus'],
'$baseurl' => System::baseUrl(),
- '$form_security_token' => get_form_security_token("admin_deleteitem")
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_deleteitem")
]);
}
return;
}
- check_form_security_token_redirectOnErr('/admin/deleteitem/', 'admin_deleteitem');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/deleteitem/', 'admin_deleteitem');
if (x($_POST['page_deleteitem_submit'])) {
$guid = trim(notags($_POST['deleteitemguid']));
}
info(L10n::t('Item marked for deletion.') . EOL);
- goaway('admin/deleteitem');
+ $a->internalRedirect('admin/deleteitem');
return; // NOTREACHED
}
* @param App $a
* @return string
*/
-function admin_page_workerqueue(App $a)
+function admin_page_workerqueue(App $a, $deferred)
{
// get jobs from the workerqueue table
- $entries = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], ['done' => 0], ['order'=> ['priority']]);
+ if ($deferred) {
+ $condition = ["NOT `done` AND `next_try` > ?", DateTimeFormat::utcNow()];
+ $sub_title = L10n::t('Inspect Deferred Worker Queue');
+ $info = L10n::t("This page lists the deferred worker jobs. This are jobs that couldn't be executed at the first time.");
+ } else {
+ $condition = ["NOT `done` AND `next_try` < ?", DateTimeFormat::utcNow()];
+ $sub_title = L10n::t('Inspect Worker Queue');
+ $info = L10n::t('This page lists the currently queued worker jobs. These jobs are handled by the worker cronjob you\'ve set up during install.');
+ }
+
+ $entries = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], $condition, ['order'=> ['priority']]);
$r = [];
while ($entry = DBA::fetch($entries)) {
$t = get_markup_template('admin/workerqueue.tpl');
return replace_macros($t, [
'$title' => L10n::t('Administration'),
- '$page' => L10n::t('Inspect Worker Queue'),
+ '$page' => $sub_title,
'$count' => count($r),
'$id_header' => L10n::t('ID'),
'$param_header' => L10n::t('Job Parameters'),
'$created_header' => L10n::t('Created'),
'$prio_header' => L10n::t('Priority'),
- '$info' => L10n::t('This page lists the currently queued worker jobs. These jobs are handled by the worker cronjob you\'ve set up during install.'),
+ '$info' => $info,
'$entries' => $r,
]);
}
logger('accounts: ' . print_r($accounts, true), LOGGER_DATA);
- $r = q("SELECT COUNT(`id`) AS `count` FROM `register`");
- $pending = $r[0]['count'];
+ $pending = Register::getPendingCount();
- $r = q("SELECT COUNT(*) AS `total` FROM `queue` WHERE 1");
- $queue = (($r) ? $r[0]['total'] : 0);
+ $queue = DBA::count('queue', []);
- $r = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE NOT `done`");
- $workerqueue = (($r) ? $r[0]['total'] : 0);
+ $deferred = DBA::count('workerqueue', ["`executed` <= ? AND NOT `done` AND `next_try` > ?",
+ DBA::NULL_DATETIME, DateTimeFormat::utcNow()]);
+
+ $workerqueue = DBA::count('workerqueue', ["`executed` <= ? AND NOT `done` AND `next_try` < ?",
+ DBA::NULL_DATETIME, DateTimeFormat::utcNow()]);
// We can do better, but this is a quick queue status
- $queues = ['label' => L10n::t('Message queues'), 'queue' => $queue, 'workerq' => $workerqueue];
+ $queues = ['label' => L10n::t('Message queues'), 'queue' => $queue, 'deferred' => $deferred, 'workerq' => $workerqueue];
$r = q("SHOW variables LIKE 'max_allowed_packet'");
$max_allowed_packet = (($r) ? $r[0]['Value'] : 0);
- $server_settings = ['label' => L10n::t('Server Settings'),
- 'php' => ['upload_max_filesize' => ini_get('upload_max_filesize'),
- 'post_max_size' => ini_get('post_max_size'),
- 'memory_limit' => ini_get('memory_limit')],
+ $server_settings = ['label' => L10n::t('Server Settings'),
+ 'php' => ['upload_max_filesize' => ini_get('upload_max_filesize'),
+ 'post_max_size' => ini_get('post_max_size'),
+ 'memory_limit' => ini_get('memory_limit')],
'mysql' => ['max_allowed_packet' => $max_allowed_packet]];
$t = get_markup_template('admin/summary.tpl');
'$platform' => FRIENDICA_PLATFORM,
'$codename' => FRIENDICA_CODENAME,
'$build' => Config::get('system', 'build'),
- '$addons' => [L10n::t('Active addons'), $a->addons],
+ '$addons' => [L10n::t('Active addons'), Addon::getEnabledList()],
'$serversettings' => $server_settings,
'$showwarning' => $showwarning,
'$warningtext' => $warningtext
*/
function admin_page_site_post(App $a)
{
- check_form_security_token_redirectOnErr('/admin/site', 'admin_site');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/site', 'admin_site');
if (!empty($_POST['republish_directory'])) {
Worker::add(PRIORITY_LOW, 'Directory');
$parsed = @parse_url($new_url);
if (!is_array($parsed) || !x($parsed, 'host') || !x($parsed, 'scheme')) {
notice(L10n::t("Can not parse base url. Must have at least <scheme>://<domain>"));
- goaway('admin/site');
+ $a->internalRedirect('admin/site');
}
/* steps:
* send relocate for every local user
* */
- $old_url = System::baseUrl(true);
+ $old_url = $a->getBaseURL(true);
// Generate host names for relocation the addresses in the format user@address.tld
$new_host = str_replace("http://", "@", normalise_link($new_url));
$old_host = str_replace("http://", "@", normalise_link($old_url));
- function update_table($table_name, $fields, $old_url, $new_url)
+ function update_table(App $a, $table_name, $fields, $old_url, $new_url)
{
$dbold = DBA::escape($old_url);
$dbnew = DBA::escape($new_url);
if (!DBA::isResult($r)) {
notice("Failed updating '$table_name': " . DBA::errorMessage());
- goaway('admin/site');
+ $a->internalRedirect('admin/site');
}
}
// update tables
// update profile links in the format "http://server.tld"
- update_table("profile", ['photo', 'thumb'], $old_url, $new_url);
- update_table("term", ['url'], $old_url, $new_url);
- update_table("contact", ['photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'], $old_url, $new_url);
- update_table("gcontact", ['url', 'nurl', 'photo', 'server_url', 'notify', 'alias'], $old_url, $new_url);
- update_table("item", ['owner-link', 'author-link', 'body', 'plink', 'tag'], $old_url, $new_url);
+ update_table($a, "profile", ['photo', 'thumb'], $old_url, $new_url);
+ update_table($a, "term", ['url'], $old_url, $new_url);
+ update_table($a, "contact", ['photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'], $old_url, $new_url);
+ update_table($a, "gcontact", ['url', 'nurl', 'photo', 'server_url', 'notify', 'alias'], $old_url, $new_url);
+ update_table($a, "item", ['owner-link', 'author-link', 'body', 'plink', 'tag'], $old_url, $new_url);
// update profile addresses in the format "user@server.tld"
- update_table("contact", ['addr'], $old_host, $new_host);
- update_table("gcontact", ['connect', 'addr'], $old_host, $new_host);
+ update_table($a, "contact", ['addr'], $old_host, $new_host);
+ update_table($a, "gcontact", ['connect', 'addr'], $old_host, $new_host);
// update config
Config::set('system', 'hostname', parse_url($new_url, PHP_URL_HOST));
info("Relocation started. Could take a while to complete.");
- goaway('admin/site');
+ $a->internalRedirect('admin/site');
}
// end relocate
Config::set('system', 'rino_encrypt', $rino);
info(L10n::t('Site settings updated.') . EOL);
- goaway('admin/site');
+ $a->internalRedirect('admin/site');
return; // NOTREACHED
}
'$relay_server_tags' => ['relay_server_tags', L10n::t("Server tags"), Config::get('system','relay_server_tags'), L10n::t("Comma separated list of tags for the 'tags' subscription.")],
'$relay_user_tags' => ['relay_user_tags', L10n::t("Allow user tags"), Config::get('system', 'relay_user_tags', true), L10n::t("If enabled, the tags from the saved searches will used for the 'tags' subscription in addition to the 'relay_server_tags'.")],
- '$form_security_token' => get_form_security_token("admin_site"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_site"),
'$relocate_button' => L10n::t('Start Relocation'),
]);
}
Config::set('system', 'build', intval($curr) + 1);
}
info(L10n::t('Update has been marked successful') . EOL);
- goaway('admin/dbsync');
+ $a->internalRedirect('admin/dbsync');
}
if (($a->argc > 2) && (intval($a->argv[2]) || ($a->argv[2] === 'check'))) {
$nu_email = defaults($_POST, 'new_user_email' , '');
$nu_language = Config::get('system', 'language');
- check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/users', 'admin_users');
if (!($nu_name === "") && !($nu_email === "") && !($nu_nickname === "")) {
try {
user_deny($hash);
}
}
- goaway('admin/users');
+ $a->internalRedirect('admin/users');
return; // NOTREACHED
}
$user = DBA::selectFirst('user', ['username', 'blocked'], ['uid' => $uid]);
if (!DBA::isResult($user)) {
notice('User not found' . EOL);
- goaway('admin/users');
+ $a->internalRedirect('admin/users');
return ''; // NOTREACHED
}
switch ($a->argv[2]) {
case "delete":
- check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/users', 'admin_users', 't');
// delete user
User::remove($uid);
notice(L10n::t("User '%s' deleted", $user['username']) . EOL);
break;
case "block":
- check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/users', 'admin_users', 't');
q("UPDATE `user` SET `blocked` = %d WHERE `uid` = %s",
intval(1 - $user['blocked']),
intval($uid)
notice(sprintf(($user['blocked'] ? L10n::t("User '%s' unblocked") : L10n::t("User '%s' blocked")), $user['username']) . EOL);
break;
}
- goaway('admin/users');
+ $a->internalRedirect('admin/users');
return ''; // NOTREACHED
}
/* get pending */
- $pending = q("SELECT `register`.*, `contact`.`name`, `user`.`email`
- FROM `register`
- INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
- INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;");
-
+ $pending = Register::getPending();
/* get users */
$total = q("SELECT COUNT(*) AS `total` FROM `user` WHERE 1");
'$confirm_delete_multi' => L10n::t('Selected users will be deleted!\n\nEverything these users had posted on this site will be permanently deleted!\n\nAre you sure?'),
'$confirm_delete' => L10n::t('The user {0} will be deleted!\n\nEverything this user has posted on this site will be permanently deleted!\n\nAre you sure?'),
- '$form_security_token' => get_form_security_token("admin_users"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_users"),
// values //
'$baseurl' => System::baseUrl(true),
*
* The returned string returned hulds the HTML code of the page.
*
- * @param App $a
+ * @param App $a
+ * @param array $addons_admin A list of admin addon names
* @return string
*/
-function admin_page_addons(App $a)
+function admin_page_addons(App $a, array $addons_admin)
{
/*
* Single addon
return '';
}
- if (x($_GET, "a") && $_GET['a'] == "t") {
- check_form_security_token_redirectOnErr('/admin/addons', 'admin_themes', 't');
+ if (defaults($_GET, 'a', '') == "t") {
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_themes', 't');
// Toggle addon status
- $idx = array_search($addon, $a->addons);
- if ($idx !== false) {
- unset($a->addons[$idx]);
+ if (Addon::isEnabled($addon)) {
Addon::uninstall($addon);
info(L10n::t("Addon %s disabled.", $addon));
} else {
- $a->addons[] = $addon;
Addon::install($addon);
info(L10n::t("Addon %s enabled.", $addon));
}
- Config::set("system", "addon", implode(", ", $a->addons));
- goaway('admin/addons');
+
+ Addon::saveEnabledList();
+ $a->internalRedirect('admin/addons');
return ''; // NOTREACHED
}
// display addon details
- if (in_array($addon, $a->addons)) {
+ if (Addon::isEnabled($addon)) {
$status = "on";
$action = L10n::t("Disable");
} else {
}
$admin_form = "";
- if (in_array($addon, $a->addons_admin)) {
+ if (in_array($addon, $addons_admin)) {
require_once "addon/$addon/$addon.php";
$func = $addon . '_addon_admin';
$func($a, $admin_form);
'$page' => L10n::t('Addons'),
'$toggle' => L10n::t('Toggle'),
'$settings' => L10n::t('Settings'),
- '$baseurl' => System::baseUrl(true),
+ '$baseurl' => $a->getBaseURL(true),
'$addon' => $addon,
'$status' => $status,
'$screenshot' => '',
'$readme' => $readme,
- '$form_security_token' => get_form_security_token("admin_themes"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_themes"),
]);
}
* List addons
*/
if (x($_GET, "a") && $_GET['a'] == "r") {
- check_form_security_token_redirectOnErr(System::baseUrl() . '/admin/addons', 'admin_themes', 't');
+ BaseModule::checkFormSecurityTokenRedirectOnError($a->getBaseURL() . '/admin/addons', 'admin_themes', 't');
Addon::reload();
info("Addons reloaded");
- goaway(System::baseUrl() . '/admin/addons');
+ $a->internalRedirect('admin/addons');
}
$addons = [];
$show_addon = true;
// If the addon is unsupported, then only show it, when it is enabled
- if ((strtolower($info["status"]) == "unsupported") && !in_array($id, $a->addons)) {
+ if ((strtolower($info["status"]) == "unsupported") && !Addon::isEnabled($id)) {
$show_addon = false;
}
}
if ($show_addon) {
- $addons[] = [$id, (in_array($id, $a->addons) ? "on" : "off"), $info];
+ $addons[] = [$id, (Addon::isEnabled($id) ? "on" : "off"), $info];
}
}
}
'$addons' => $addons,
'$pcount' => count($addons),
'$noplugshint' => L10n::t('There are currently no addons available on your node. You can find the official addon repository at %1$s and might find other interesting addons in the open addon registry at %2$s', 'https://github.com/friendica/friendica-addons', 'http://addons.friendi.ca'),
- '$form_security_token' => get_form_security_token("admin_themes"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_themes"),
]);
}
}
if (x($_GET, "a") && $_GET['a'] == "t") {
- check_form_security_token_redirectOnErr('/admin/themes', 'admin_themes', 't');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/themes', 'admin_themes', 't');
// Toggle theme status
}
Config::set('system', 'allowed_themes', $s);
- goaway('admin/themes');
+ $a->internalRedirect('admin/themes');
return ''; // NOTREACHED
}
'$screenshot' => $screenshot,
'$readme' => $readme,
- '$form_security_token' => get_form_security_token("admin_themes"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_themes"),
]);
}
// reload active themes
if (x($_GET, "a") && $_GET['a'] == "r") {
- check_form_security_token_redirectOnErr(System::baseUrl() . '/admin/themes', 'admin_themes', 't');
+ BaseModule::checkFormSecurityTokenRedirectOnError(System::baseUrl() . '/admin/themes', 'admin_themes', 't');
foreach ($themes as $th) {
if ($th['allowed']) {
Theme::uninstall($th['name']);
}
}
info("Themes reloaded");
- goaway(System::baseUrl() . '/admin/themes');
+ $a->internalRedirect('admin/themes');
}
/*
'$noplugshint' => L10n::t('No themes found on the system. They should be placed in %1$s', '<code>/view/themes</code>'),
'$experimental' => L10n::t('[Experimental]'),
'$unsupported' => L10n::t('[Unsupported]'),
- '$form_security_token' => get_form_security_token("admin_themes"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_themes"),
]);
}
function admin_page_logs_post(App $a)
{
if (x($_POST, "page_logs")) {
- check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/logs', 'admin_logs');
$logfile = ((x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : '');
$debugging = ((x($_POST,'debugging')) ? true : false);
}
info(L10n::t("Log settings updated."));
- goaway('admin/logs');
+ $a->internalRedirect('admin/logs');
return; // NOTREACHED
}
'$debugging' => ['debugging', L10n::t("Enable Debugging"), Config::get('system', 'debugging'), ""],
'$logfile' => ['logfile', L10n::t("Log file"), Config::get('system', 'logfile'), L10n::t("Must be writable by web server. Relative to your Friendica top-level directory.")],
'$loglevel' => ['loglevel', L10n::t("Log level"), Config::get('system', 'loglevel'), "", $log_choices],
- '$form_security_token' => get_form_security_token("admin_logs"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_logs"),
'$phpheader' => L10n::t("PHP logging"),
'$phphint' => L10n::t("To temporarily enable logging of PHP errors and warnings you can prepend the following to the index.php file of your installation. The filename set in the 'error_log' line is relative to the friendica top-level directory and must be writeable by the web server. The option '1' for 'log_errors' and 'display_errors' is to enable these options, set to '0' to disable them."),
'$phplogcode' => "error_reporting(E_ERROR | E_WARNING | E_PARSE);\nini_set('error_log','php.out');\nini_set('log_errors','1');\nini_set('display_errors', '1');",
*/
function admin_page_features_post(App $a)
{
- check_form_security_token_redirectOnErr('/admin/features', 'admin_manage_features');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/admin/features', 'admin_manage_features');
logger('postvars: ' . print_r($_POST, true), LOGGER_DATA);
}
}
- goaway('admin/features');
+ $a->internalRedirect('admin/features');
return; // NOTREACHED
}
$tpl = get_markup_template('admin/settings_features.tpl');
$o = replace_macros($tpl, [
- '$form_security_token' => get_form_security_token("admin_manage_features"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("admin_manage_features"),
'$title' => L10n::t('Manage Additional Features'),
'$features' => $arr,
'$submit' => L10n::t('Save Settings'),
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
+use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Module\Login;
if (strstr($consumer->callback_url, $glue)) {
$glue = "?";
}
- goaway($consumer->callback_url . $glue . "oauth_token=" . OAuthUtil::urlencode_rfc3986($params['oauth_token']) . "&oauth_verifier=" . OAuthUtil::urlencode_rfc3986($verifier));
+ $a->internalRedirect($consumer->callback_url . $glue . 'oauth_token=' . OAuthUtil::urlencode_rfc3986($params['oauth_token']) . '&oauth_verifier=' . OAuthUtil::urlencode_rfc3986($verifier));
killme();
}
/**
* @file mod/apps.php
*/
-use Friendica\App;
+use Friendica\Content\Nav;
use Friendica\Core\Config;
use Friendica\Core\L10n;
-function apps_content(App $a)
+function apps_content()
{
$privateaddons = Config::get('config', 'private_addons');
if ($privateaddons === "1") {
$title = L10n::t('Applications');
- if (count($a->apps) == 0) {
+ $apps = Nav::getAppMenu();
+
+ if (count($apps) == 0) {
notice(L10n::t('No installed applications.') . EOL);
}
$tpl = get_markup_template('apps.tpl');
return replace_macros($tpl, [
'$title' => $title,
- '$apps' => $a->apps,
+ '$apps' => $apps,
]);
}
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Database\DBA;
+use Friendica\Util\Security;
require_once 'include/dba.php';
-require_once 'include/security.php';
function attach_init(App $a)
{
return;
}
- $sql_extra = permissions_sql($r['uid']);
+ $sql_extra = Security::getPermissionsSQLByUserId($r['uid']);
// Now we'll see if we can access the attachment
use Friendica\Model\Contact;
use Friendica\Model\Event;
use Friendica\Model\Group;
+use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Protocol\DFRN;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
+use Friendica\Util\Security;
function cal_init(App $a)
{
}
// get the permissions
- $sql_perms = item_permissions_sql($owner_uid, $remote_contact, $groups);
+ $sql_perms = Item::getPermissionsSQLByUserId($owner_uid, $remote_contact, $groups);
// we only want to have the events of the profile owner
$sql_extra = " AND `event`.`cid` = 0 " . $sql_perms;
// Respect the export feature setting for all other /cal pages if it's not the own profile
if ((local_user() !== intval($owner_uid)) && !Feature::isEnabled($owner_uid, "export_calendar")) {
notice(L10n::t('Permission denied.') . EOL);
- goaway('cal/' . $nick);
+ $a->internalRedirect('cal/' . $nick);
}
// Get the export data by uid
$return_path = "cal/" . $nick;
}
- goaway($return_path);
+ $a->internalRedirect($return_path);
}
// If nothing went wrong we can echo the export content
if (DBA::isResult($contact)) {
$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), [
- '$name' => htmlentities($contact['name']),
+ '$name' => htmlentities($contact['name']),
'$photo' => $contact['photo'],
- 'url' => 'contacts/' . $cid
+ 'url' => 'contact/' . $cid
]);
if (!x($a->page, 'aside')) {
use Friendica\Core\PConfig;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
+use Friendica\Model\Item;
function community_init(App $a)
{
}
}
- require_once 'include/security.php';
require_once 'include/conversation.php';
if (!$update) {
return DBA::toArray($r);
} elseif ($content == 'global') {
if (!is_null($accounttype)) {
- $sql_accounttype = " AND `owner`.`contact-type` = ?";
- $values = [$accounttype, $start, $itemspage];
+ $condition = ["`uid` = ? AND `owner`.`contact-type` = ?", 0, $accounttype];
} else {
- $sql_accounttype = "";
- $values = [$start, $itemspage];
+ $condition = ['uid' => 0];
}
- $r = DBA::p("SELECT `uri` FROM `thread`
- INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
- INNER JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id`
- INNER JOIN `contact` AS `owner` ON `owner`.`id`=`item`.`owner-id`
- WHERE `thread`.`uid` = 0 AND NOT `author`.`hidden` AND NOT `author`.`blocked` $sql_accounttype
- ORDER BY `thread`.`commented` DESC LIMIT ?, ?", $values);
+ $r = Item::selectThreadForUser(0, ['uri'], $condition, ['order' => ['commented' => true], 'limit' => [$start, $itemspage]]);
return DBA::toArray($r);
}
$warning = L10n::t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
$info = L10n::t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
- $returnaddr = "contacts/$cid";
+ $returnaddr = "contact/$cid";
$allow_remote_self = Config::get('system', 'allow_users_remote_self');
*/
use Friendica\App;
+use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\User;
+use Friendica\Util\Security;
require_once 'mod/settings.php';
return;
}
- check_form_security_token_redirectOnErr('/delegate', 'delegate');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/delegate', 'delegate');
$parent_uid = defaults($_POST, 'parent_user', 0);
$parent_password = defaults($_POST, 'parent_password', '');
if ($a->argc > 2 && $a->argv[1] === 'add' && intval($a->argv[2])) {
// delegated admins can view but not change delegation permissions
if (x($_SESSION, 'submanage')) {
- goaway(System::baseUrl() . '/delegate');
+ $a->internalRedirect('delegate');
}
$user_id = $a->argv[2];
DBA::insert('manage', ['uid' => $user_id, 'mid' => local_user()]);
}
}
- goaway(System::baseUrl() . '/delegate');
+ $a->internalRedirect('delegate');
}
if ($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) {
// delegated admins can view but not change delegation permissions
if (x($_SESSION, 'submanage')) {
- goaway(System::baseUrl() . '/delegate');
+ $a->internalRedirect('delegate');
}
DBA::delete('manage', ['uid' => $a->argv[2], 'mid' => local_user()]);
- goaway(System::baseUrl() . '/delegate');
+ $a->internalRedirect('delegate');
}
// find everybody that currently has delegated management to this account/page
}
$o = replace_macros(get_markup_template('delegate.tpl'), [
- '$form_security_token' => get_form_security_token('delegate'),
+ '$form_security_token' => BaseModule::getFormSecurityToken('delegate'),
'$parent_header' => L10n::t('Parent User'),
'$parent_user' => $parent_user,
'$parent_password' => $parent_password,
// Let's send our user to the contact editor in case they want to
// do anything special with this new friend.
if ($handsfree === null) {
- goaway(System::baseUrl() . '/contact/' . intval($contact_id));
+ $a->internalRedirect('contact/' . intval($contact_id));
} else {
return;
}
if (DBA::isResult($contact)) {
$photo = $contact['photo'];
} else {
- $photo = System::baseUrl() . '/images/person-175.jpg';
+ $photo = System::baseUrl() . '/images/person-300.jpg';
}
Contact::updateAvatar($photo, $local_uid, $dfrn_record);
}
// somebody arrived here by mistake or they are fishing. Send them to the homepage.
- goaway(System::baseUrl());
+ $a->internalRedirect();
// NOTREACHED
}
$my_id = '0:' . $dfrn_id;
break;
default:
- goaway(System::baseUrl());
+ $a->internalRedirect();
break; // NOTREACHED
}
if (strlen($s)) {
$xml = XML::parseString($s);
- if ((int) $xml->status === 1) {
+ if ((int)$xml->status === 1) {
$_SESSION['authenticated'] = 1;
if (!x($_SESSION, 'remote')) {
$_SESSION['remote'] = [];
);
}
}
- $profile = $r[0]['nickname'];
- goaway((strlen($destination_url)) ? $destination_url : System::baseUrl() . '/profile/' . $profile);
+
+ $profile = (count($r) > 0 && isset($r[0]['nickname']) ? $r[0]['nickname'] : '');
+ if (!empty($destination_url)) {
+ System::externalRedirect($destination_url);
+ } else {
+ $a->internalRedirect('profile/' . $profile);
+ }
}
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
if ($type === 'profile-check' && $dfrn_version < 2.2) {
$my_id = '0:' . $dfrn_id;
break;
default:
- goaway(System::baseUrl());
+ $a->internalRedirect();
break; // NOTREACHED
}
$my_id = '0:' . $dfrn_id;
break;
default:
- goaway(System::baseUrl());
+ $a->internalRedirect();
break; // NOTREACHED
}
])->getBody();
}
- $profile = ((DBA::isResult($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname);
-
- switch ($destination_url) {
- case 'profile':
- $dest = System::baseUrl() . '/profile/' . $profile . '?f=&tab=profile';
- break;
- case 'photos':
- $dest = System::baseUrl() . '/photos/' . $profile;
- break;
- case 'status':
- case '':
- $dest = System::baseUrl() . '/profile/' . $profile;
- break;
- default:
- $appendix = (strstr($destination_url, '?') ? '&f=&redir=1' : '?f=&redir=1');
- $dest = $destination_url . $appendix;
- break;
- }
-
logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA);
if (strlen($s) && strstr($s, '<?xml')) {
DBA::escape($session_id)
);
}
+ }
+
+ $profile = ((DBA::isResult($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname);
- goaway($dest);
+ switch ($destination_url) {
+ case 'profile':
+ $a->internalRedirect('profile/' . $profile . '?f=&tab=profile');
+ break;
+ case 'photos':
+ $a->internalRedirect('photos/' . $profile);
+ break;
+ case 'status':
+ case '':
+ $a->internalRedirect('profile/' . $profile);
+ break;
+ default:
+ $appendix = (strstr($destination_url, '?') ? '&f=&redir=1' : '?f=&redir=1');
+ System::externalRedirect($destination_url . $appendix);
+ break;
}
- goaway($dest);
// NOTREACHED
} else {
// XML reply
}
if (x($_POST, 'cancel')) {
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
/*
Contact::updateAvatar($photo, local_user(), $r[0]["id"], true);
}
- $forwardurl = System::baseUrl() . "/contact/" . $r[0]['id'];
+ $forward_path = "contact/" . $r[0]['id'];
} else {
- $forwardurl = System::baseUrl() . "/contact";
+ $forward_path = "contact";
}
// Allow the blocked remote notification to complete
}
// (ignore reply, nothing we can do it failed)
- goaway($forwardurl);
+ $a->internalRedirect($forward_path);
return; // NOTREACHED
}
}
// invalid/bogus request
notice(L10n::t('Unrecoverable protocol error.') . EOL);
- goaway(System::baseUrl());
+ $a->internalRedirect();
return; // NOTREACHED
}
$url = Network::isUrlValid($url);
if (!$url) {
notice(L10n::t('Invalid profile URL.') . EOL);
- goaway(System::baseUrl() . '/' . $a->cmd);
+ $a->internalRedirect($a->cmd);
return; // NOTREACHED
}
if (!Network::isUrlAllowed($url)) {
notice(L10n::t('Disallowed profile URL.') . EOL);
- goaway(System::baseUrl() . '/' . $a->cmd);
+ $a->internalRedirect($a->cmd);
return; // NOTREACHED
}
if (Network::isUrlBlocked($url)) {
notice(L10n::t('Blocked domain') . EOL);
- goaway(System::baseUrl() . '/' . $a->cmd);
+ $a->internalRedirect($a->cmd);
return; // NOTREACHED
}
if (!count($parms)) {
notice(L10n::t('Profile location is not valid or does not contain profile information.') . EOL);
- goaway(System::baseUrl() . '/' . $a->cmd);
+ $a->internalRedirect($a->cmd);
} else {
if (!x($parms, 'fn')) {
notice(L10n::t('Warning: profile location has no identifiable owner name.') . EOL);
}
// "Homecoming" - send the requestor back to their site to record the introduction.
- $dfrn_url = bin2hex(System::baseUrl() . '/profile/' . $nickname);
+ $dfrn_url = bin2hex($a->getBaseURL() . '/profile/' . $nickname);
$aes_allow = ((function_exists('openssl_encrypt')) ? 1 : 0);
- goaway($parms['dfrn-request'] . "?dfrn_url=$dfrn_url"
+ System::externalRedirect($parms['dfrn-request'] . "?dfrn_url=$dfrn_url"
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION
. '&confirm_key=' . $hash
. (($aes_allow) ? "&aes_allow=1" : "")
$uri = urlencode($uri);
} else {
- $uri = System::baseUrl() . '/profile/' . $nickname;
+ $uri = 'profile/' . $nickname;
}
$url = str_replace('{uri}', $uri, $url);
- goaway($url);
+ System::externalRedirect($url);
// NOTREACHED
// END $network != Protocol::PHANTOM
} else {
use Friendica\Model\Profile;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\ActivityPub;
+use Friendica\Util\Security;
function display_init(App $a)
{
}
if (ActivityPub::isRequest()) {
- goaway(str_replace('display/', 'objects/', $a->query_string));
+ $a->internalRedirect(str_replace('display/', 'objects/', $a->query_string));
}
if ($item["id"] != $item["parent"]) {
return;
}
- require_once 'include/security.php';
require_once 'include/conversation.php';
$o = '';
$o .= status_editor($a, $x, 0, true);
}
- $sql_extra = item_permissions_sql($a->profile['uid'], $is_remote_contact, $groups);
+ $sql_extra = Item::getPermissionsSQLByUserId($a->profile['uid'], $is_remote_contact, $groups);
if (local_user() && (local_user() == $a->profile['uid'])) {
$condition = ['parent-uri' => $item_parent_uri, 'uid' => local_user(), 'unseen' => true];
}
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
- $return_url = (($a->argc > 2) ? base64_decode($a->argv[2]) : '');
if (!$post_id) {
notice(L10n::t('Item not found') . EOL);
return;
}
- // Fallback to SESSION return_path
- if (empty($return_url)) {
- $return_url = $_SESSION['return_url'];
- }
-
$fields = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
- 'type', 'body', 'title', 'file', 'wall', 'post-type'];
+ 'type', 'body', 'title', 'file', 'wall', 'post-type', 'guid'];
$item = Item::selectFirstForUser(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]);
$o .= replace_macros($tpl, [
'$is_edit' => true,
- '$return_path' => $return_url,
+ '$return_path' => '/display/' . $item['guid'],
'$action' => 'item',
'$share' => L10n::t('Save'),
'$upload' => L10n::t('Upload photo'),
use Friendica\Model\Event;
use Friendica\Model\Item;
use Friendica\Model\Profile;
+use Friendica\Module\Login;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
-use Friendica\Module\Login;
require_once 'include/items.php';
// The default setting for the `private` field in event_store() is false, so mirror that
$private_event = false;
- $start = NULL_DATE;
- $finish = NULL_DATE;
+ $start = DBA::NULL_DATETIME;
+ $finish = DBA::NULL_DATETIME;
if ($start_text) {
$start = $start_text;
$type = 'event';
$action = ($event_id == '') ? 'new' : "event/" . $event_id;
- $onerror_url = System::baseUrl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish";
+ $onerror_path = "events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish";
if (strcmp($finish, $start) < 0 && !$nofinish) {
notice(L10n::t('Event can not end before it has started.') . EOL);
echo L10n::t('Event can not end before it has started.');
killme();
}
- goaway($onerror_url);
+ $a->internalRedirect($onerror_path);
}
- if (!$summary || ($start === NULL_DATE)) {
+ if (!$summary || ($start === DBA::NULL_DATETIME)) {
notice(L10n::t('Event title and start time are required.') . EOL);
if (intval($_REQUEST['preview'])) {
echo L10n::t('Event title and start time are required.');
killme();
}
- goaway($onerror_url);
+ $a->internalRedirect($onerror_path);
}
$share = intval(defaults($_POST, 'share', 0));
Worker::add(PRIORITY_HIGH, "Notifier", "event", $item_id);
}
- goaway('/events');
+ $a->internalRedirect('events');
}
function events_content(App $a)
}
if ($a->argc == 1) {
- $_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd;
+ $_SESSION['return_path'] = $a->cmd;
}
if (($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) {
info(L10n::t('Event removed') . EOL);
}
- goaway(System::baseUrl() . '/events');
+ $a->internalRedirect('events');
}
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
-require_once 'include/security.php';
require_once 'include/items.php';
function filer_content(App $a)
file_tag_unsave_file(local_user(),$item_id,$term, $category);
}
- //goaway('/network');
+ //$a->internalRedirect('network');
killme();
}
}
if (isset($_REQUEST['cancel'])) {
- goaway('contacts');
+ $a->internalRedirect('contacts');
}
$uid = local_user();
$url = notags(trim($_REQUEST['url']));
- $return_url = 'contacts';
+ $return_path = 'contacts';
// Makes the connection request for friendica contacts easier
// This is just a precaution if maybe this page is called somewhere directly via POST
if ($result['message']) {
notice($result['message']);
}
- goaway($return_url);
+ $a->internalRedirect($return_path);
} elseif ($result['cid']) {
- goaway('contacts/' . $result['cid']);
+ $a->internalRedirect('contact/' . $result['cid']);
}
info(L10n::t('The contact could not be added.'));
- goaway($return_url);
+ $a->internalRedirect($return_path);
// NOTREACHED
}
function follow_content(App $a)
{
- $return_url = 'contacts';
+ $return_path = 'contacts';
if (!local_user()) {
notice(L10n::t('Permission denied.'));
- goaway($return_url);
+ $a->internalRedirect($return_path);
// NOTREACHED
}
if ($r[0]['pending']) {
notice(L10n::t('You already added this contact.'));
$submit = '';
- //goaway($_SESSION['return_url']);
+ //$a->internalRedirect($_SESSION['return_path']);
// NOTREACHED
}
}
if (($ret['network'] == Protocol::DIASPORA) && !Config::get('system', 'diaspora_enabled')) {
notice(L10n::t("Diaspora support isn't enabled. Contact can't be added."));
$submit = '';
- //goaway($_SESSION['return_url']);
+ //$a->internalRedirect($_SESSION['return_path']);
// NOTREACHED
}
if (($ret['network'] == Protocol::OSTATUS) && Config::get('system', 'ostatus_disabled')) {
notice(L10n::t("OStatus support is disabled. Contact can't be added."));
$submit = '';
- //goaway($_SESSION['return_url']);
+ //$a->internalRedirect($_SESSION['return_path']);
// NOTREACHED
}
if ($ret['network'] == Protocol::PHANTOM) {
notice(L10n::t("The network type couldn't be detected. Contact can't be added."));
$submit = '';
- //goaway($_SESSION['return_url']);
+ //$a->internalRedirect($_SESSION['return_path']);
// NOTREACHED
}
if (!$r) {
notice(L10n::t('Permission denied.'));
- goaway($return_url);
+ $a->internalRedirect($return_path);
// NOTREACHED
}
$admin = false;
}
- $visible_addons = [];
- if (is_array($a->addons) && count($a->addons)) {
- $r = q("SELECT * FROM `addon` WHERE `hidden` = 0");
- if (DBA::isResult($r)) {
- foreach ($r as $rr) {
- $visible_addons[] = $rr['name'];
- }
- }
- }
+ $visible_addons = Addon::getVisibleList();
Config::load('feature_lock');
$locked_features = [];
$o .= L10n::t('Suggestions, praise, etc. - please email "info" at "friendi - dot - ca');
$o .= '</p>' . PHP_EOL;
- $visible_addons = [];
- if (is_array($a->addons) && count($a->addons)) {
- $r = q("SELECT * FROM `addon` WHERE `hidden` = 0");
- if (DBA::isResult($r)) {
- foreach ($r as $rr) {
- $visible_addons[] = $rr['name'];
- }
- }
- }
-
+ $visible_addons = Addon::getVisibleList();
if (count($visible_addons)) {
$o .= '<p>' . L10n::t('Installed addons/apps:') . '</p>' . PHP_EOL;
$sorted = $visible_addons;
*/
use Friendica\App;
+use Friendica\BaseModule;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Database\DBA;
use Friendica\Model;
use Friendica\Module;
+use Friendica\Util\Security;
function group_init(App $a) {
if (local_user()) {
}
if (($a->argc == 2) && ($a->argv[1] === 'new')) {
- check_form_security_token_redirectOnErr('/group/new', 'group_edit');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/group/new', 'group_edit');
$name = notags(trim($_POST['groupname']));
$r = Model\Group::create(local_user(), $name);
info(L10n::t('Group created.') . EOL);
$r = Model\Group::getIdByName(local_user(), $name);
if ($r) {
- goaway(System::baseUrl() . '/group/' . $r);
+ $a->internalRedirect('group/' . $r);
}
} else {
notice(L10n::t('Could not create group.') . EOL);
}
- goaway(System::baseUrl() . '/group');
+ $a->internalRedirect('group');
return; // NOTREACHED
}
if (($a->argc == 2) && intval($a->argv[1])) {
- check_form_security_token_redirectOnErr('/group', 'group_edit');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_edit');
$r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]),
);
if (!DBA::isResult($r)) {
notice(L10n::t('Group not found.') . EOL);
- goaway(System::baseUrl() . '/contact');
+ $a->internalRedirect('contact');
return; // NOTREACHED
}
$group = $r[0];
// With no group number provided we jump to the unassigned contacts as a starting point
if ($a->argc == 1) {
- goaway('group/none');
+ $a->internalRedirect('group/none');
}
// Switch to text mode interface if we have more than 'n' contacts or group members
'$title' => L10n::t('Create a group of contacts/friends.'),
'$gname' => ['groupname', L10n::t('Group Name: '), '', ''],
'$gid' => 'new',
- '$form_security_token' => get_form_security_token("group_edit"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("group_edit"),
]);
if (($a->argc == 3) && ($a->argv[1] === 'drop')) {
- check_form_security_token_redirectOnErr('/group', 'group_drop', 't');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_drop', 't');
if (intval($a->argv[2])) {
$r = q("SELECT `name` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
notice(L10n::t('Unable to remove group.') . EOL);
}
}
- goaway(System::baseUrl() . '/group');
+ $a->internalRedirect('group');
// NOTREACHED
}
if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
- check_form_security_token_ForbiddenOnErr('group_member_change', 't');
+ BaseModule::checkFormSecurityTokenForbiddenOnError('group_member_change', 't');
$r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1",
intval($a->argv[2]),
if (!DBA::isResult($r)) {
notice(L10n::t('Group not found.') . EOL);
- goaway(System::baseUrl() . '/contact');
+ $a->internalRedirect('contact');
}
$group = $r[0];
$drop_txt = replace_macros($drop_tpl, [
'$id' => $group['id'],
'$delete' => L10n::t('Delete Group'),
- '$form_security_token' => get_form_security_token("group_drop"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("group_drop"),
]);
'$gname' => ['groupname', L10n::t('Group Name: '), $group['name'], ''],
'$gid' => $group['id'],
'$drop' => $drop_txt,
- '$form_security_token' => get_form_security_token('group_edit'),
+ '$form_security_token' => BaseModule::getFormSecurityToken('group_edit'),
'$edit_name' => L10n::t('Edit Group Name'),
'$editable' => 1,
];
'contacts' => [],
];
- $sec_token = addslashes(get_form_security_token('group_member_change'));
+ $sec_token = addslashes(BaseModule::getFormSecurityToken('group_member_change'));
// Format the data of the group members
foreach ($members as $member) {
Addon::callHooks('home_init',$ret);
if (local_user() && ($a->user['nickname'])) {
- goaway(System::baseUrl()."/network");
+ $a->internalRedirect('network');
}
if (strlen(Config::get('system','singleuser'))) {
- goaway(System::baseUrl()."/profile/" . Config::get('system','singleuser'));
+ $a->internalRedirect('profile/' . Config::get('system','singleuser'));
}
}}
$rand = "?$rand";
}
- goaway(System::baseUrl() . "/" . $return_path . $rand);
+ $a->internalRedirect($return_path . $rand);
}
// the json doesn't really matter, it will either be 0 or 1
*/
use Friendica\App;
+use Friendica\BaseModule;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Database\DBA;
use Friendica\Protocol\Email;
use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Security;
function invite_post(App $a)
{
return;
}
- check_form_security_token_redirectOnErr('/', 'send_invite');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/', 'send_invite');
$max_invites = intval(Config::get('system', 'max_invites'));
if (! $max_invites) {
}
if ($invitation_only && ($invites_remaining || is_site_admin())) {
- $code = autoname(8) . srand(1000, 9999);
+ $code = Friendica\Model\Register::createForInvitation();
$nmessage = str_replace('$invite_code', $code, $message);
- $r = q("INSERT INTO `register` (`hash`,`created`) VALUES ('%s', '%s') ",
- DBA::escape($code),
- DBA::escape(DateTimeFormat::utcNow())
- );
-
if (! is_site_admin()) {
$invites_remaining --;
if ($invites_remaining >= 0) {
}
$o = replace_macros($tpl, [
- '$form_security_token' => get_form_security_token("send_invite"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("send_invite"),
'$title' => L10n::t('Send invitations'),
'$recipients' => ['recipients', L10n::t('Enter email addresses, one per line:')],
'$message' => ['message', L10n::t('Your message:'),L10n::t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n"
use Friendica\Protocol\Email;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Emailer;
+use Friendica\Util\Security;
require_once 'include/enotify.php';
require_once 'include/text.php';
return 0;
}
- require_once 'include/security.php';
-
$uid = local_user();
if (!empty($_REQUEST['dropitems'])) {
if (!DBA::isResult($parent_item)) {
notice(L10n::t('Unable to locate original post.') . EOL);
if (!empty($_REQUEST['return'])) {
- goaway($return_path);
+ $a->internalRedirect($return_path);
}
killme();
}
$allow_comment = local_user() && ($profile_uid == 0) && $parent && in_array($parent_item['network'], [Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
// Now check that valid personal details have been provided
- if (!can_write_wall($profile_uid) && !$allow_comment) {
+ if (!Security::canWriteToUserWall($profile_uid) && !$allow_comment) {
notice(L10n::t('Permission denied.') . EOL) ;
if (!empty($_REQUEST['return'])) {
- goaway($return_path);
+ $a->internalRedirect($return_path);
}
killme();
}
info(L10n::t('Empty post discarded.') . EOL);
if (!empty($_REQUEST['return'])) {
- goaway($return_path);
+ $a->internalRedirect($return_path);
}
killme();
}
if (!empty($datarray['cancel'])) {
logger('mod_item: post cancelled by addon.');
if ($return_path) {
- goaway($return_path);
+ $a->internalRedirect($return_path);
}
$json = ['cancel' => 1];
if (!empty($_REQUEST['return']) && strlen($return_path)) {
logger('return: ' . $return_path);
- goaway($return_path);
+ $a->internalRedirect($return_path);
}
killme();
} else {
if (!$post_id) {
logger("Item wasn't stored.");
- goaway($return_path);
+ $a->internalRedirect($return_path);
}
$datarray = Item::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]);
if (!DBA::isResult($datarray)) {
logger("Item with id ".$post_id." couldn't be fetched.");
- goaway($return_path);
+ $a->internalRedirect($return_path);
}
// update filetags in pconfig
function item_post_return($baseurl, $api_source, $return_path)
{
// figure out how to return, depending on from whence we came
+ $a = get_app();
if ($api_source) {
return;
}
if ($return_path) {
- goaway($return_path);
+ $a->internalRedirect($return_path);
}
$json = ['success' => 1];
return;
}
- require_once 'include/security.php';
-
$o = '';
if (($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) {
$profile = $contact["url"];
$alias = $contact["alias"];
- $newname = $contact["nick"];
-
- if (($newname == "") || !in_array($contact["network"], [Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::TWITTER, Protocol::STATUSNET])) {
- $newname = $contact["name"];
- }
+ $newname = defaults($contact, "name", $contact["nick"]);
}
//if there is an url for this persons profile
use Friendica\Core\System;
use Friendica\Model\Item;
-require_once 'include/security.php';
require_once 'include/items.php';
function like_content(App $a) {
// See if we've been passed a return path to redirect to
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
- like_content_return(System::baseUrl(), $return_path);
+ like_content_return($a, $return_path);
killme(); // NOTREACHED
}
// Decide how to return. If we were called with a 'return' argument,
// then redirect back to the calling page. If not, just quietly end
-function like_content_return($baseurl, $return_path) {
+function like_content_return(App $a, $return_path) {
if ($return_path) {
$rand = '_=' . time();
if (strpos($return_path, '?')) {
$rand = "?$rand";
}
- goaway($baseurl . "/" . $return_path . $rand);
+ $a->internalRedirect($return_path . $rand);
}
killme();
{
$loginame = notags(trim($_POST['login-name']));
if (!$loginame) {
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
$condition = ['(`email` = ? OR `nickname` = ?) AND `verified` = 1 AND `blocked` = 0', $loginame, $loginame];
$user = DBA::selectFirst('user', ['uid', 'username', 'email', 'language'], $condition);
if (!DBA::isResult($user)) {
notice(L10n::t('No valid account found.') . EOL);
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
$pwdreset_token = autoname(12) . mt_rand(1000, 9999);
'body' => $body
]);
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
function lostpass_content(App $a)
* @file mod/manage.php
*/
use Friendica\App;
+use Friendica\Core\Authentication;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\System;
unset($_SESSION['theme']);
unset($_SESSION['mobile-theme']);
unset($_SESSION['page_flags']);
- unset($_SESSION['return_url']);
+ unset($_SESSION['return_path']);
if (x($_SESSION, 'submanage')) {
unset($_SESSION['submanage']);
}
unset($_SESSION['sysmsg_info']);
}
- require_once('include/security.php');
- authenticate_success($r[0], true, true);
+ Authentication::setAuthenticatedSessionForUser($r[0], true, true);
if ($limited_id) {
$_SESSION['submanage'] = $original_id;
$ret = [];
Addon::callHooks('home_init',$ret);
- goaway( System::baseUrl() . "/profile/" . $a->user['nickname'] );
+ $a->internalRedirect('profile/' . $a->user['nickname'] );
// NOTREACHED
}
$a->page['aside'] .= Widget::findPeople();
$a->page['aside'] .= Widget::follow();
- $_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd;
+ $_SESSION['return_path'] = $a->cmd;
$r = q(
"SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
$a->argc = 2;
$a->argv[1] = 'new';
} else {
- goaway($a->cmd . '/' . $ret);
+ $a->internalRedirect($a->cmd . '/' . $ret);
}
}
// Now check how the user responded to the confirmation query
if (!empty($_REQUEST['canceled'])) {
- goaway('/message');
+ $a->internalRedirect('message');
}
$cmd = $a->argv[1];
$message = DBA::selectFirst('mail', ['convid'], ['id' => $a->argv[2], 'uid' => local_user()]);
if(!DBA::isResult($message)){
info(L10n::t('Conversation not found.') . EOL);
- goaway('/message');
+ $a->internalRedirect('message');
}
if (DBA::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) {
$conversation = DBA::selectFirst('mail', ['id'], ['convid' => $message['convid'], 'uid' => local_user()]);
if(!DBA::isResult($conversation)){
info(L10n::t('Conversation removed.') . EOL);
- goaway('/message');
+ $a->internalRedirect('message');
}
- goaway('/message/' . $conversation['id'] );
+ $a->internalRedirect('message/' . $conversation['id'] );
} else {
$r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[2]),
info(L10n::t('Conversation removed.') . EOL);
}
}
- goaway('/message' );
+ $a->internalRedirect('message');
}
}
}
- $_SESSION['return_url'] = $a->query_string;
+ $_SESSION['return_path'] = $a->query_string;
if ($a->argc == 1) {
$search = (x($_GET, 'search') ? escape_tags($_GET['search']) : '');
if (($search != '') && !empty($_GET['submit'])) {
- goaway('search?search=' . urlencode($search));
+ $a->internalRedirect('search?search=' . urlencode($search));
}
if (x($_GET, 'save')) {
$redir_url = ($net_queries ? $net_baseurl . '?' . $net_queries : $net_baseurl);
- goaway(System::baseUrl() . $redir_url);
+ $a->internalRedirect($redir_url);
}
}
killme();
}
notice(L10n::t('No such group') . EOL);
- goaway('network/0');
+ $a->internalRedirect('network/0');
// NOTREACHED
}
}
} else {
notice(L10n::t('Invalid contact.') . EOL);
- goaway('network');
+ $a->internalRedirect('network');
// NOTREACHED
}
}
return '';
}
- goaway(System::baseUrl() . '/group/none');
+ $a->internalRedirect('group/none');
}
return;
}
- require_once 'include/security.php';
require_once 'include/conversation.php';
$o = Profile::getTabs($a, true);
$r = q("SELECT `user`.`nickname` FROM `user` LEFT JOIN `item` ON `item`.`uid` = `user`.`uid` WHERE `item`.`id` = %d", intval($id));
if (DBA::isResult($r)) {
$nick = $r[0]['nickname'];
- $url = System::baseUrl() . "/display/$nick/$id";
- goaway($url);
+ $a->internalRedirect('display/' . $nick . '/' . $id);
} else {
$a->error = 404;
notice(L10n::t('Item not found.') . EOL);
function notifications_post(App $a)
{
if (!local_user()) {
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
$request_id = (($a->argc > 1) ? $a->argv[1] : 0);
'self' => false, 'blocked' => true, 'pending' => true];
DBA::delete('contact', $condition);
}
- goaway('notifications/intros');
+ $a->internalRedirect('notifications/intros');
}
if ($_POST['submit'] == L10n::t('Ignore')) {
DBA::update('intro', ['ignore' => true], ['id' => $intro_id]);
- goaway('notifications/intros');
+ $a->internalRedirect('notifications/intros');
}
}
}
}
}
- goaway($note['link']);
+ System::externalRedirect($note['link']);
}
- goaway(System::baseUrl(true));
+ $a->internalRedirect();
}
if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
*/
use Friendica\App;
+use Friendica\Core\Authentication;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
$noid = Config::get('system','no_openid');
if($noid)
- goaway(System::baseUrl());
+ $a->internalRedirect();
logger('mod_openid ' . print_r($_REQUEST,true), LOGGER_DATA);
if(! strlen($authid)) {
logger(L10n::t('OpenID protocol error. No ID returned.') . EOL);
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
// NOTE: we search both for normalised and non-normalised form of $authid
unset($_SESSION['openid']);
- require_once('include/security.php');
- authenticate_success($r[0],true,true);
+ Authentication::setAuthenticatedSessionForUser($r[0],true,true);
// just in case there was no return url set
// and we fell through
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
// Successful OpenID login - but we can't match it to an existing account.
if (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED) {
notice(L10n::t('Account not found and OpenID registration is not permitted on this site.') . EOL);
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
unset($_SESSION['register']);
$args .= '&openid_url=' . urlencode(notags(trim($authid)));
- goaway(System::baseUrl() . '/register?' . $args);
+ $a->internalRedirect('register?' . $args);
// NOTREACHED
}
}
notice(L10n::t('Login failed.') . EOL);
- goaway(System::baseUrl());
+ $a->internalRedirect();
// NOTREACHED
}
if (! local_user()) {
notice(L10n::t('Permission denied.') . EOL);
- goaway('/ostatus_subscribe');
+ $a->internalRedirect('ostatus_subscribe');
// NOTREACHED
}
$hdrs[$k] = $v;
}
}
+ $type = null;
if (array_key_exists('Content-Type', $hdrs)) {
$type = $hdrs['Content-Type'];
}
use Friendica\App;
use Friendica\Database\DBA;
use Friendica\Object\Image;
-
-require_once 'include/security.php';
+use Friendica\Util\Security;
function photo_init(App $a)
{
exit;
}
- $default = 'images/person-175.jpg';
+ $default = 'images/person-300.jpg';
$public = true;
if (isset($type)) {
intval($resolution)
);
if (DBA::isResult($r)) {
- $sql_extra = permissions_sql($r[0]['uid']);
+ $sql_extra = Security::getPermissionsSQLByUserId($r[0]['uid']);
// Now we'll see if we can access the photo
$r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `scale` <= %d $sql_extra ORDER BY scale DESC LIMIT 1",
if (isset($resolution)) {
switch ($resolution) {
case 4:
- $data = file_get_contents('images/person-175.jpg');
+ $data = file_get_contents('images/person-300.jpg');
$mimetype = 'image/jpeg';
break;
case 5:
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map;
use Friendica\Util\Temporal;
+use Friendica\Util\Security;
require_once 'include/items.php';
-require_once 'include/security.php';
function photos_init(App $a) {
$album = hex2bin($a->argv[3]);
if ($album === L10n::t('Profile Photos') || $album === 'Contact Photos' || $album === L10n::t('Contact Photos')) {
- goaway($_SESSION['photo_return']);
+ $a->internalRedirect($_SESSION['photo_return']);
return; // NOTREACHED
}
if (!DBA::isResult($r)) {
notice(L10n::t('Album not found.') . EOL);
- goaway($_SESSION['photo_return']);
+ $a->internalRedirect($_SESSION['photo_return']);
return; // NOTREACHED
}
// Check if the user has responded to a delete confirmation query
if (!empty($_REQUEST['canceled'])) {
- goaway($_SESSION['photo_return']);
+ $a->internalRedirect($_SESSION['photo_return']);
}
// RENAME photo album
// Update the photo albums cache
Photo::clearAlbumCache($page_owner_uid);
- $newurl = System::baseUrl() . '/photos/' . $a->user['nickname'] . '/album/' . bin2hex($newalbum);
- goaway($newurl);
+ $a->internalRedirect('photos/' . $a->user['nickname'] . '/album/' . bin2hex($newalbum));
return; // NOTREACHED
}
$res[] = "'" . DBA::escape($rr['rid']) . "'" ;
}
} else {
- goaway($_SESSION['photo_return']);
+ $a->internalRedirect($_SESSION['photo_return']);
return; // NOTREACHED
}
Photo::clearAlbumCache($page_owner_uid);
}
- goaway('photos/' . $a->data['user']['nickname']);
+ $a->internalRedirect('photos/' . $a->data['user']['nickname']);
return; // NOTREACHED
}
// Check if the user has responded to a delete confirmation query for a single photo
if ($a->argc > 2 && !empty($_REQUEST['canceled'])) {
- goaway($_SESSION['photo_return']);
+ $a->internalRedirect($_SESSION['photo_return']);
}
if ($a->argc > 2 && defaults($_POST, 'delete', '') === L10n::t('Delete Photo')) {
Photo::clearAlbumCache($page_owner_uid);
}
- goaway('photos/' . $a->data['user']['nickname']);
+ $a->internalRedirect('photos/' . $a->data['user']['nickname']);
return; // NOTREACHED
}
}
}
}
- goaway($_SESSION['photo_return']);
+ $a->internalRedirect($_SESSION['photo_return']);
return; // NOTREACHED
}
// addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook
// if they do not wish to be redirected
- goaway($_SESSION['photo_return']);
+ $a->internalRedirect($_SESSION['photo_return']);
// NOTREACHED
}
return;
}
- require_once 'include/security.php';
require_once 'include/conversation.php';
if (empty($a->data['user'])) {
return;
}
- $sql_extra = permissions_sql($owner_uid, $remote_contact, $groups);
+ $sql_extra = Security::getPermissionsSQLByUserId($owner_uid, $remote_contact, $groups);
$o = "";
if (count($linked_items)) {
$cmnt_tpl = get_markup_template('comment_item.tpl');
$tpl = get_markup_template('photo_item.tpl');
- $return_url = $a->cmd;
+ $return_path = $a->cmd;
- if ($can_post || can_write_wall($owner_uid)) {
+ if ($can_post || Security::canWriteToUserWall($owner_uid)) {
$like_tpl = get_markup_template('like_noshare.tpl');
$likebuttons = replace_macros($like_tpl, [
'$id' => $link_item['id'],
}
if (!DBA::isResult($items)) {
- if (($can_post || can_write_wall($owner_uid))) {
+ if (($can_post || Security::canWriteToUserWall($owner_uid))) {
$comments .= replace_macros($cmnt_tpl, [
'$return_path' => '',
- '$jsreload' => $return_url,
+ '$jsreload' => $return_path,
'$id' => $link_item['id'],
'$parent' => $link_item['id'],
'$profile_uid' => $owner_uid,
$dislike = format_like($conv_responses['dislike'][$link_item['uri']], $conv_responses['dislike'][$link_item['uri'] . '-l'], 'dislike', $link_item['id']);
}
- if (($can_post || can_write_wall($owner_uid))) {
+ if (($can_post || Security::canWriteToUserWall($owner_uid))) {
$comments .= replace_macros($cmnt_tpl,[
'$return_path' => '',
- '$jsreload' => $return_url,
+ '$jsreload' => $return_path,
'$id' => $link_item['id'],
'$parent' => $link_item['id'],
'$profile_uid' => $owner_uid,
'$comment' => $comment
]);
- if (($can_post || can_write_wall($owner_uid))) {
+ if (($can_post || Security::canWriteToUserWall($owner_uid))) {
$comments .= replace_macros($cmnt_tpl, [
'$return_path' => '',
- '$jsreload' => $return_url,
+ '$jsreload' => $return_path,
'$id' => $item['item_id'],
'$parent' => $item['parent'],
'$profile_uid' => $owner_uid,
$mail_count = count($mails);
if (intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE && is_site_admin()) {
- $regs = q(
- "SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`
- FROM `contact` RIGHT JOIN `register` ON `register`.`uid` = `contact`.`uid`
- WHERE `contact`.`self` = 1"
- );
+ $regs = Friendica\Model\Register::getPending();
if (DBA::isResult($regs)) {
$register_count = count($regs);
DBA::escape(DateTimeFormat::utcNow())
);
if (DBA::isResult($ev)) {
- Cache::set($cachekey, $ev, CACHE_HOUR);
+ Cache::set($cachekey, $ev, Cache::HOUR);
}
}
use Friendica\Database\DBA;
use Friendica\Model\Item;
-require_once 'include/security.php';
require_once 'include/items.php';
function poke_init(App $a)
use Friendica\Module\Login;
use Friendica\Protocol\DFRN;
use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Security;
use Friendica\Protocol\ActivityPub;
function profile_init(App $a)
} else {
$r = q("SELECT `nickname` FROM `user` WHERE `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 ORDER BY RAND() LIMIT 1");
if (DBA::isResult($r)) {
- goaway(System::baseUrl() . '/profile/' . $r[0]['nickname']);
+ $a->internalRedirect('profile/' . $r[0]['nickname']);
} else {
logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG);
notice(L10n::t('Requested profile is not available.') . EOL);
return Login::form();
}
- require_once 'include/security.php';
require_once 'include/conversation.php';
require_once 'include/items.php';
$a->page['aside'] .= Widget::categories(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], (!empty($category) ? xmlify($category) : ''));
$a->page['aside'] .= Widget::tagCloud();
- if (can_write_wall($a->profile['profile_uid'])) {
+ if (Security::canWriteToUserWall($a->profile['profile_uid'])) {
$x = [
'is_owner' => $is_owner,
'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'],
// Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
- $sql_extra = item_permissions_sql($a->profile['profile_uid'], $remote_contact, $groups);
+ $sql_extra = Item::getPermissionsSQLByUserId($a->profile['profile_uid'], $remote_contact, $groups);
$sql_extra2 = '';
if ($update) {
*/
use Friendica\App;
+use Friendica\BaseModule;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Model\Photo;
use Friendica\Model\Profile;
use Friendica\Object\Image;
+use Friendica\Util\Security;
function profile_photo_init(App $a)
{
return;
}
- check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/profile_photo', 'profile_photo');
if (!empty($_POST['cropfinal']) && $_POST['cropfinal'] == 1) {
$r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d AND `scale` = %d LIMIT 1", DBA::escape($image_id),
DBA::escape(local_user()), intval($scale));
- $url = System::baseUrl() . '/profile/' . $a->user['nickname'];
+ $path = 'profile/' . $a->user['nickname'];
if (DBA::isResult($r)) {
$base_image = $r[0];
$Image = new Image($base_image['data'], $base_image['type']);
if ($Image->isValid()) {
- $Image->crop(175, $srcX, $srcY, $srcW, $srcH);
+ $Image->crop(300, $srcX, $srcY, $srcW, $srcH);
$r = Photo::store($Image, local_user(), 0, $base_image['resource-id'], $base_image['filename'],
L10n::t('Profile Photos'), 4, $is_default_profile);
if ($r === false) {
- notice(L10n::t('Image size reduction [%s] failed.', "175") . EOL);
+ notice(L10n::t('Image size reduction [%s] failed.', "300") . EOL);
}
$Image->scaleDown(80);
info(L10n::t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL);
// Update global directory in background
- if ($url && strlen(Config::get('system', 'directory'))) {
- Worker::add(PRIORITY_LOW, "Directory", $url);
+ if ($path && strlen(Config::get('system', 'directory'))) {
+ Worker::add(PRIORITY_LOW, "Directory", $a->getBaseURL() . '/' . $path);
}
Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());
}
}
- goaway($url);
+ $a->internalRedirect($path);
return; // NOTREACHED
}
@unlink($src);
$imagecrop = profile_photo_crop_ui_head($a, $ph);
- goaway(System::baseUrl() . '/profile_photo/use/' . $imagecrop['hash']);
+ $a->internalRedirect('profile_photo/use/' . $imagecrop['hash']);
}
function profile_photo_content(App $a)
$imagecrop = [];
if (isset($a->argv[1]) && $a->argv[1] == 'use' && $a->argc >= 3) {
- // check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo');
+ // BaseModule::checkFormSecurityTokenRedirectOnError('/profile_photo', 'profile_photo');
$resource_id = $a->argv[2];
//die(":".local_user());
Worker::add(PRIORITY_LOW, "Directory", $url);
}
- goaway(System::baseUrl() . '/profile/' . $a->user['nickname']);
+ $a->internalRedirect('profile/' . $a->user['nickname']);
return; // NOTREACHED
}
$ph = new Image($r[0]['data'], $r[0]['type']);
'$title' => L10n::t('Upload Profile Photo'),
'$submit' => L10n::t('Upload'),
'$profiles' => $profiles,
- '$form_security_token' => get_form_security_token("profile_photo"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("profile_photo"),
'$select' => sprintf('%s %s', L10n::t('or'),
($newuser) ? '<a href="' . System::baseUrl() . '">' . L10n::t('skip this step') . '</a>' : '<a href="' . System::baseUrl() . '/photos/' . $a->user['nickname'] . '">' . L10n::t('select a photo from your photo albums') . '</a>')
]);
'$image_url' => System::baseUrl() . '/photo/' . $filename,
'$title' => L10n::t('Crop Image'),
'$desc' => L10n::t('Please adjust the image cropping for optimum viewing.'),
- '$form_security_token' => get_form_security_token("profile_photo"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("profile_photo"),
'$done' => L10n::t('Done Editing')
]);
return $o;
$height = $image->getHeight();
if ($width < 175 || $height < 175) {
- $image->scaleUp(200);
+ $image->scaleUp(300);
$width = $image->getWidth();
$height = $image->getHeight();
}
*/
use Friendica\App;
+use Friendica\BaseModule;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Model\Profile;
+use Friendica\Module\Login;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
-use Friendica\Module\Login;
function profiles_init(App $a) {
);
if (! DBA::isResult($r)) {
notice(L10n::t('Profile not found.') . EOL);
- goaway('profiles');
+ $a->internalRedirect('profiles');
return; // NOTREACHED
}
- check_form_security_token_redirectOnErr('/profiles', 'profile_drop', 't');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_drop', 't');
// move every contact using this profile as their default to the user default
info(L10n::t('Profile deleted.').EOL);
}
- goaway('profiles');
+ $a->internalRedirect('profiles');
return; // NOTREACHED
}
if (($a->argc > 1) && ($a->argv[1] === 'new')) {
- check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_new', 't');
$r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
intval(local_user()));
info(L10n::t('New profile created.') . EOL);
if (DBA::isResult($r3) && count($r3) == 1) {
- goaway('profiles/' . $r3[0]['id']);
+ $a->internalRedirect('profiles/' . $r3[0]['id']);
}
- goaway('profiles');
+ $a->internalRedirect('profiles');
}
if (($a->argc > 2) && ($a->argv[1] === 'clone')) {
- check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_clone', 't');
$r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
intval(local_user()));
);
info(L10n::t('New profile created.') . EOL);
if ((DBA::isResult($r3)) && (count($r3) == 1)) {
- goaway('profiles/'.$r3[0]['id']);
+ $a->internalRedirect('profiles/'.$r3[0]['id']);
}
- goaway('profiles');
+ $a->internalRedirect('profiles');
return; // NOTREACHED
}
return;
}
- check_form_security_token_redirectOnErr('/profiles', 'profile_edit');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_edit');
$is_default = (($orig[0]['is-default']) ? 1 : 0);
$with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : '');
if (! strlen($howlong)) {
- $howlong = NULL_DATE;
+ $howlong = DBA::NULL_DATETIME;
} else {
$howlong = DateTimeFormat::convert($howlong, 'UTC', date_default_timezone_get());
}
],
'$multi_profiles' => Feature::isEnabled(local_user(), 'multi_profiles'),
- '$form_security_token' => get_form_security_token("profile_edit"),
- '$form_security_token_photo' => get_form_security_token("profile_photo"),
- '$profile_clone_link' => ((Feature::isEnabled(local_user(), 'multi_profiles')) ? 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone") : ""),
- '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("profile_edit"),
+ '$form_security_token_photo' => BaseModule::getFormSecurityToken("profile_photo"),
+ '$profile_clone_link' => ((Feature::isEnabled(local_user(), 'multi_profiles')) ? 'profiles/clone/' . $r[0]['id'] . '?t=' . BaseModule::getFormSecurityToken("profile_clone") : ""),
+ '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . BaseModule::getFormSecurityToken("profile_drop"),
'$profile_action' => L10n::t('Profile Actions'),
'$banner' => L10n::t('Edit Profile Details'),
'$gender' => ContactSelector::gender($r[0]['gender']),
'$marital' => ['selector' => ContactSelector::maritalStatus($r[0]['marital']), 'value' => $r[0]['marital']],
'$with' => ['with', L10n::t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), L10n::t('Examples: cathy123, Cathy Williams, cathy@example.com')],
- '$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : DateTimeFormat::local($r[0]['howlong']))],
+ '$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= DBA::NULL_DATETIME ? '' : DateTimeFormat::local($r[0]['howlong']))],
'$sexual' => ['selector' => ContactSelector::sexualPreference($r[0]['sexual']), 'value' => $r[0]['sexual']],
'$about' => ['about', L10n::t('Tell us about yourself...'), $r[0]['about']],
'$xmpp' => ['xmpp', L10n::t("XMPP \x28Jabber\x29 address:"), $r[0]['xmpp'], L10n::t("The XMPP address will be propagated to your contacts so that they can follow you.")],
);
if (DBA::isResult($r)) {
//Go to the default profile.
- goaway('profiles/' . $r[0]['id']);
+ $a->internalRedirect('profiles/' . $r[0]['id']);
}
}
'$header' => L10n::t('Edit/Manage Profiles'),
'$chg_photo' => L10n::t('Change profile photo'),
'$cr_new' => L10n::t('Create New Profile'),
- '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"),
+ '$cr_new_link' => 'profiles/new?t=' . BaseModule::getFormSecurityToken("profile_new"),
'$profiles' => $profiles
]);
}
use Friendica\Model\Contact;
use Friendica\Protocol\OStatus;
-require_once('include/security.php');
-require_once('include/items.php');
+require_once 'include/items.php';
function hub_return($valid, $body)
{
$x = GContact::getRandomUrl();
if ($x) {
- goaway(Contact::magicLink($x));
+ $link = Contact::magicLink($x);
+ // @TODO making the return of magicLink save to use either externalRedirect or internalRedirect
+ if (filter_var($link, FILTER_VALIDATE_URL)) {
+ System::externalRedirect($link);
+ } else {
+ $a->internalRedirect($link);
+ }
}
- goaway(System::baseUrl() . '/profile');
+ $a->internalRedirect('profile');
}
$contact = DBA::selectFirst('contact', $fields, ['id' => $cid, 'uid' => [0, local_user()]]);
if (!DBA::isResult($contact)) {
notice(L10n::t('Contact not found.'));
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
$contact_url = $contact['url'];
|| (!local_user() && !remote_user()) // Visitors (not logged in or not remotes) can't authenticate.
|| (!empty($a->contact['id']) && $a->contact['id'] == $cid)) // Local user is already authenticated.
{
- goaway($url != '' ? $url : $contact_url);
+ System::externalRedirect(defaults($url, $contact_url));
}
if ($contact['uid'] == 0 && local_user()) {
if (!empty($a->contact['id']) && $a->contact['id'] == $cid) {
// Local user is already authenticated.
- $target_url = $url != '' ? $url : $contact_url;
+ $target_url = defaults($url, $contact_url);
logger($contact['name'] . " is already authenticated. Redirecting to " . $target_url, LOGGER_DEBUG);
- goaway($target_url);
+ System::externalRedirect($target_url);
}
}
if (remote_user()) {
- $host = substr(System::baseUrl() . ($a->getURLPath() ? '/' . $a->getURLPath() : ''), strpos(System::baseUrl(), '://') + 3);
+ $host = substr($a->getBaseURL() . ($a->getURLPath() ? '/' . $a->getURLPath() : ''), strpos($a->getBaseURL(), '://') + 3);
$remotehost = substr($contact['addr'], strpos($contact['addr'], '@') + 1);
// On a local instance we have to check if the local user has already authenticated
foreach ($_SESSION['remote'] as $v) {
if ($v['uid'] == $_SESSION['visitor_visiting'] && $v['cid'] == $_SESSION['visitor_id']) {
// Remote user is already authenticated.
- $target_url = $url != '' ? $url : $contact_url;
+ $target_url = defaults($url, $contact_url);
logger($contact['name'] . " is already authenticated. Redirecting to " . $target_url, LOGGER_DEBUG);
- goaway($target_url);
+ System::externalRedirect($target_url);
}
}
}
$dest = (!empty($url) ? '&destination_url=' . $url : '');
- goaway($contact['poll'] . '?dfrn_id=' . $dfrn_id
+ System::externalRedirect($contact['poll'] . '?dfrn_id=' . $dfrn_id
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest . $quiet);
}
- $url = $url != '' ? $url : $contact_url;
+ $url = defaults($url, $contact_url);
}
// If we don't have a connected contact, redirect with
}
logger('redirecting to ' . $url, LOGGER_DEBUG);
- goaway($url);
+ System::externalRedirect($url);
}
notice(L10n::t('Contact not found.'));
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
*/
use Friendica\App;
+use Friendica\BaseModule;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\DBA;
-use Friendica\Model\User;
+use Friendica\Model;
use Friendica\Module\Tos;
-use Friendica\Util\DateTimeFormat;
require_once 'include/enotify.php';
function register_post(App $a)
{
- check_form_security_token_redirectOnErr('/register', 'register');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/register', 'register');
$verified = 0;
$blocked = 1;
$arr['blocked'] = $blocked;
$arr['verified'] = $verified;
- $arr['language'] = L10n::getBrowserLanguage();
+ $arr['language'] = L10n::detectLanguage();
try {
- $result = User::create($arr);
+ $result = Model\User::create($arr);
} catch (Exception $e) {
notice($e->getMessage());
return;
$user = $result['user'];
if ($netpublish && intval(Config::get('config', 'register_policy')) !== REGISTER_APPROVE) {
- $url = System::baseUrl() . '/profile/' . $user['nickname'];
+ $url = $a->getBaseUrl() . '/profile/' . $user['nickname'];
Worker::add(PRIORITY_LOW, "Directory", $url);
}
if (intval(Config::get('config', 'register_policy')) === REGISTER_OPEN) {
if ($using_invites && $invite_id) {
- q("delete * from register where hash = '%s' limit 1", DBA::escape($invite_id));
+ Model\Register::deleteByHash($invite_id);
PConfig::set($user['uid'], 'system', 'invites_remaining', $num_invites);
}
// Only send a password mail when the password wasn't manually provided
if (!x($_POST, 'password1') || !x($_POST, 'confirm')) {
- $res = User::sendRegisterOpenEmail(
- $user['email'], Config::get('config', 'sitename'), System::baseUrl(), $user['username'], $result['password'], $user);
+ $res = Model\User::sendRegisterOpenEmail(
+ $user,
+ Config::get('config', 'sitename'),
+ $a->getBaseUrl(),
+ $result['password']
+ );
if ($res) {
info(L10n::t('Registration successful. Please check your email for further instructions.') . EOL);
- goaway(System::baseUrl());
+ $a->internalRedirect();
} else {
notice(
L10n::t('Failed to send email message. Here your accout details:<br> login: %s<br> password: %s<br><br>You can change your password after login.',
}
} else {
info(L10n::t('Registration successful.') . EOL);
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
} elseif (intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE) {
if (!strlen(Config::get('config', 'admin_email'))) {
notice(L10n::t('Your registration can not be processed.') . EOL);
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
- $hash = random_string();
- $r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language`, `note` ) VALUES ( '%s', '%s', %d, '%s', '%s', '%s' ) ",
- DBA::escape($hash),
- DBA::escape(DateTimeFormat::utcNow()),
- intval($user['uid']),
- DBA::escape($result['password']),
- DBA::escape(Config::get('system', 'language')),
- DBA::escape($_POST['permonlybox'])
- );
+ Model\Register::createForApproval($user['uid'], Config::get('system', 'language'), $_POST['permonlybox']);
// invite system
if ($using_invites && $invite_id) {
- q("DELETE * FROM `register` WHERE `hash` = '%s' LIMIT 1", DBA::escape($invite_id));
+ Model\Register::deleteByHash($invite_id);
PConfig::set($user['uid'], 'system', 'invites_remaining', $num_invites);
}
'source_name' => $user['username'],
'source_mail' => $user['email'],
'source_nick' => $user['nickname'],
- 'source_link' => System::baseUrl() . "/admin/users/",
- 'link' => System::baseUrl() . "/admin/users/",
- 'source_photo' => System::baseUrl() . "/photo/avatar/" . $user['uid'] . ".jpg",
+ 'source_link' => $a->getBaseUrl() . "/admin/users/",
+ 'link' => $a->getBaseUrl() . "/admin/users/",
+ 'source_photo' => $a->getBaseUrl() . "/photo/avatar/" . $user['uid'] . ".jpg",
'to_email' => $admin['email'],
'uid' => $admin['uid'],
'language' => $admin['language'] ? $admin['language'] : 'en',
]);
}
// send notification to the user, that the registration is pending
- User::sendRegisterPendingEmail(
- $user['email'], Config::get('config', 'sitename'), $user['username']);
+ Model\User::sendRegisterPendingEmail(
+ $user,
+ Config::get('config', 'sitename'),
+ $a->getBaseURL(),
+ $result['password']
+ );
info(L10n::t('Your registration is pending approval by the site owner.') . EOL);
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
return;
'$showprivstatement' => Config::get('system', 'tosprivstatement'),
'$privstatement' => $tos->privacy_complete,
'$baseurl' => System::baseurl(),
- '$form_security_token' => get_form_security_token("register"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("register"),
'$explicit_content' => Config::get('system', 'explicit_content', false),
'$explicit_content_note' => L10n::t('Note: This node explicitly contains adult content')
]);
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
+use Friendica\Model\Register;
use Friendica\Model\User;
use Friendica\Module\Login;
{
$a = get_app();
- $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
- DBA::escape($hash)
- );
-
-
+ $register = Register::getByHash($hash);
if (!DBA::isResult($register)) {
return false;
}
- $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
- intval($register[0]['uid'])
- );
-
+ $user = User::getById($register['uid']);
if (!DBA::isResult($user)) {
- killme();
+ exit();
}
- $r = q("DELETE FROM `register` WHERE `hash` = '%s'",
- DBA::escape($register[0]['hash'])
- );
+ Register::deleteByHash($hash);
+ DBA::update('user', ['blocked' => false, 'verified' => true], ['uid' => $register['uid']]);
- $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d",
- intval($register[0]['uid'])
- );
+ $profile = DBA::selectFirst('profile', ['net-publish'], ['uid' => $register['uid'], 'is-default' => true]);
- $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
- intval($user[0]['uid'])
- );
- if (DBA::isResult($r) && $r[0]['net-publish']) {
- $url = System::baseUrl() . '/profile/' . $user[0]['nickname'];
- if ($url && strlen(Config::get('system', 'directory'))) {
- Worker::add(PRIORITY_LOW, "Directory", $url);
- }
+ if (DBA::isResult($profile) && $profile['net-publish'] && Config::get('system', 'directory')) {
+ $url = System::baseUrl() . '/profile/' . $user['nickname'];
+ Worker::add(PRIORITY_LOW, "Directory", $url);
}
- L10n::pushLang($register[0]['language']);
+ L10n::pushLang($register['language']);
$res = User::sendRegisterOpenEmail(
- $user[0]['email'],
+ $user,
Config::get('config', 'sitename'),
- System::baseUrl(),
- $user[0]['username'],
- $register[0]['password'],
- $user[0]);
+ $a->getBaseUrl(),
+ defaults($register, 'password', 'Sent in a previous email')
+ );
L10n::popLang();
// allowed to have friends on this system
function user_deny($hash)
{
- $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
- DBA::escape($hash)
- );
-
+ $register = Register::getByHash($hash);
if (!DBA::isResult($register)) {
return false;
}
- $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
- intval($register[0]['uid'])
- );
+ $user = User::getById($register['uid']);
+ if (!DBA::isResult($user)) {
+ exit();
+ }
+
+ DBA::delete('user', ['uid' => $register['uid']]);
- DBA::delete('user', ['uid' => $register[0]['uid']]);
- DBA::delete('register', ['hash' => $register[0]['hash']]);
+ Register::deleteByHash($register['hash']);
- notice(L10n::t('Registration revoked for %s', $user[0]['username']) . EOL);
+ notice(L10n::t('Registration revoked for %s', $user['username']) . EOL);
return true;
}
{
if (!local_user()) {
info(L10n::t('Please login.') . EOL);
- $o = '<br /><br />' . Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1);
- return $o;
+ return Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1);
}
- if ((!is_site_admin()) || (x($_SESSION, 'submanage') && intval($_SESSION['submanage']))) {
+ if (!is_site_admin() || !empty($_SESSION['submanage'])) {
notice(L10n::t('Permission denied.') . EOL);
return '';
}
if ($a->argc != 3) {
- killme();
+ exit();
}
$cmd = $a->argv[1];
if ($cmd === 'deny') {
user_deny($hash);
- goaway(System::baseUrl() . "/admin/users/");
- killme();
+ $a->internalRedirect('admin/users/');
}
if ($cmd === 'allow') {
user_allow($hash);
- goaway(System::baseUrl() . "/admin/users/");
- killme();
+ $a->internalRedirect('admin/users/');
}
}
function removeme_content(App $a)
{
if (!local_user()) {
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
$hash = random_string();
$tpl = get_markup_template('removeme.tpl');
$o = replace_macros($tpl, [
- '$basedir' => System::baseUrl(),
+ '$basedir' => $a->getBaseURL(),
'$hash' => $hash,
'$title' => L10n::t('Remove My Account'),
'$desc' => L10n::t('This will completely remove your account. Once this has been done it is not recoverable.'),
if (! local_user()) {
notice(L10n::t('Permission denied.') . EOL);
- goaway('/ostatus_repair');
+ $a->internalRedirect('ostatus_repair');
// NOTREACHED
}
use Friendica\Database\DBA;
use Friendica\Model\Item;
-require_once 'include/security.php';
require_once 'include/conversation.php';
require_once 'mod/dirfind.php';
"description" => L10n::t("Only one search per minute is permitted for not logged in users.")]);
killme();
}
- Cache::set("remote_search:".$remote, json_encode(["time" => time(), "accesses" => $resultdata->accesses + 1]), CACHE_HOUR);
+ Cache::set("remote_search:".$remote, json_encode(["time" => time(), "accesses" => $resultdata->accesses + 1]), Cache::HOUR);
} else
- Cache::set("remote_search:".$remote, json_encode(["time" => time(), "accesses" => 1]), CACHE_HOUR);
+ Cache::set("remote_search:".$remote, json_encode(["time" => time(), "accesses" => 1]), Cache::HOUR);
}
Nav::setSelected('search');
*/
use Friendica\App;
+use Friendica\BaseModule;
use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Core\ACL;
use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\User;
+use Friendica\Module\Login;
use Friendica\Protocol\Email;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
-use Friendica\Module\Login;
function get_theme_config_file($theme)
{
$old_page_flags = $a->user['page-flags'];
if (($a->argc > 1) && ($a->argv[1] === 'oauth') && x($_POST, 'remove')) {
- check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/settings/oauth', 'settings_oauth');
$key = $_POST['remove'];
DBA::delete('tokens', ['id' => $key, 'uid' => local_user()]);
- goaway(System::baseUrl(true)."/settings/oauth/");
+ $a->internalRedirect('settings/oauth/', true);
return;
}
if (($a->argc > 2) && ($a->argv[1] === 'oauth') && ($a->argv[2] === 'edit'||($a->argv[2] === 'add')) && x($_POST, 'submit')) {
- check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/settings/oauth', 'settings_oauth');
$name = defaults($_POST, 'name' , '');
$key = defaults($_POST, 'key' , '');
);
}
}
- goaway(System::baseUrl(true)."/settings/oauth/");
+ $a->internalRedirect('settings/oauth/', true);
return;
}
if (($a->argc > 1) && ($a->argv[1] == 'addon')) {
- check_form_security_token_redirectOnErr('/settings/addon', 'settings_addon');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/settings/addon', 'settings_addon');
Addon::callHooks('addon_settings_post', $_POST);
return;
}
if (($a->argc > 1) && ($a->argv[1] == 'connectors')) {
- check_form_security_token_redirectOnErr('/settings/connectors', 'settings_connectors');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/settings/connectors', 'settings_connectors');
if (x($_POST, 'general-submit')) {
PConfig::set(local_user(), 'system', 'disable_cw', intval($_POST['disable_cw']));
}
if (($a->argc > 1) && ($a->argv[1] === 'features')) {
- check_form_security_token_redirectOnErr('/settings/features', 'settings_features');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/settings/features', 'settings_features');
foreach ($_POST as $k => $v) {
if (strpos($k, 'feature_') === 0) {
PConfig::set(local_user(), 'feature', substr($k, 8), ((intval($v)) ? 1 : 0));
}
if (($a->argc > 1) && ($a->argv[1] === 'display')) {
- check_form_security_token_redirectOnErr('/settings/display', 'settings_display');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/settings/display', 'settings_display');
$theme = x($_POST, 'theme') ? notags(trim($_POST['theme'])) : $a->user['theme'];
$mobile_theme = x($_POST, 'mobile_theme') ? notags(trim($_POST['mobile_theme'])) : '';
);
Addon::callHooks('display_settings_post', $_POST);
- goaway('settings/display');
+ $a->internalRedirect('settings/display');
return; // NOTREACHED
}
- check_form_security_token_redirectOnErr('/settings', 'settings');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/settings', 'settings');
if (x($_POST,'resend_relocate')) {
Worker::add(PRIORITY_HIGH, 'Notifier', 'relocate', local_user());
info(L10n::t("Relocate message has been send to your contacts"));
- goaway('settings');
+ $a->internalRedirect('settings');
}
Addon::callHooks('settings_post', $_POST);
// Update the global contact for the user
GContact::updateForUser(local_user());
- goaway('settings');
+ $a->internalRedirect('settings');
return; // NOTREACHED
}
if (($a->argc > 2) && ($a->argv[2] === 'add')) {
$tpl = get_markup_template('settings/oauth_edit.tpl');
$o .= replace_macros($tpl, [
- '$form_security_token' => get_form_security_token("settings_oauth"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("settings_oauth"),
'$title' => L10n::t('Add application'),
'$submit' => L10n::t('Save Settings'),
'$cancel' => L10n::t('Cancel'),
$tpl = get_markup_template('settings/oauth_edit.tpl');
$o .= replace_macros($tpl, [
- '$form_security_token' => get_form_security_token("settings_oauth"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("settings_oauth"),
'$title' => L10n::t('Add application'),
'$submit' => L10n::t('Update'),
'$cancel' => L10n::t('Cancel'),
}
if (($a->argc > 3) && ($a->argv[2] === 'delete')) {
- check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't');
+ BaseModule::checkFormSecurityTokenRedirectOnError('/settings/oauth', 'settings_oauth', 't');
DBA::delete('clients', ['client_id' => $a->argv[3], 'uid' => local_user()]);
- goaway(System::baseUrl(true)."/settings/oauth/");
+ $a->internalRedirect('settings/oauth/', true);
return;
}
$tpl = get_markup_template('settings/oauth.tpl');
$o .= replace_macros($tpl, [
- '$form_security_token' => get_form_security_token("settings_oauth"),
- '$baseurl' => System::baseUrl(true),
+ '$form_security_token' => BaseModule::getFormSecurityToken("settings_oauth"),
+ '$baseurl' => $a->getBaseURL(true),
'$title' => L10n::t('Connected Apps'),
'$add' => L10n::t('Add application'),
'$edit' => L10n::t('Edit'),
$tpl = get_markup_template('settings/addons.tpl');
$o .= replace_macros($tpl, [
- '$form_security_token' => get_form_security_token("settings_addon"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("settings_addon"),
'$title' => L10n::t('Addon Settings'),
'$settings_addons' => $settings_addons
]);
$tpl = get_markup_template('settings/features.tpl');
$o .= replace_macros($tpl, [
- '$form_security_token' => get_form_security_token("settings_features"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("settings_features"),
'$title' => L10n::t('Additional Features'),
'$features' => $arr,
'$submit' => L10n::t('Save Settings'),
$legacy_contact = PConfig::get(local_user(), 'ostatus', 'legacy_contact');
if (x($legacy_contact)) {
- /// @todo Isn't it supposed to be a goaway() call?
+ /// @todo Isn't it supposed to be a $a->internalRedirect() call?
$a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . System::baseUrl().'/ostatus_subscribe?url=' . urlencode($legacy_contact) . '">';
}
$mail_pubmail = ((DBA::isResult($r)) ? $r[0]['pubmail'] : 0);
$mail_action = ((DBA::isResult($r)) ? $r[0]['action'] : 0);
$mail_movetofolder = ((DBA::isResult($r)) ? $r[0]['movetofolder'] : '');
- $mail_chk = ((DBA::isResult($r)) ? $r[0]['last_check'] : NULL_DATE);
+ $mail_chk = ((DBA::isResult($r)) ? $r[0]['last_check'] : DBA::NULL_DATETIME);
$tpl = get_markup_template('settings/connectors.tpl');
$mail_disabled_message = (($mail_disabled) ? L10n::t('Email access is disabled on this site.') : '');
$o .= replace_macros($tpl, [
- '$form_security_token' => get_form_security_token("settings_connectors"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("settings_connectors"),
'$title' => L10n::t('Social Networks'),
$tpl = get_markup_template('settings/display.tpl');
$o = replace_macros($tpl, [
'$ptitle' => L10n::t('Display Settings'),
- '$form_security_token' => get_form_security_token("settings_display"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("settings_display"),
'$submit' => L10n::t('Save Settings'),
'$baseurl' => System::baseUrl(true),
'$uid' => local_user(),
'$submit' => L10n::t('Save Settings'),
'$baseurl' => System::baseUrl(true),
'$uid' => local_user(),
- '$form_security_token' => get_form_security_token("settings"),
+ '$form_security_token' => BaseModule::getFormSecurityToken("settings"),
'$nickname_block' => $prof_addr,
'$h_pass' => L10n::t('Password Settings'),
$rand = "?$rand";
}
- goaway(System::baseUrl() . "/" . $return_path . $rand);
+ $a->internalRedirect($return_path . $rand);
}
// the json doesn't really matter, it will either be 0 or 1
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Item;
+use Friendica\Util\Security;
-require_once 'include/security.php';
require_once 'include/items.php';
function subthread_content(App $a) {
$owner_uid = $item['uid'];
- if (!can_write_wall($owner_uid)) {
+ if (!Security::canWriteToUserWall($owner_uid)) {
return;
}
return;
}
- $_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd;
+ $_SESSION['return_path'] = $a->cmd;
$a->page['aside'] .= Widget::findPeople();
$a->page['aside'] .= Widget::follow();
use Friendica\Database\DBA;
use Friendica\Model\Item;
-require_once 'include/security.php';
require_once 'include/items.php';
function tagger_content(App $a) {
function tagrm_post(App $a)
{
if (!local_user()) {
- goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+ $a->internalRedirect($_SESSION['photo_return']);
}
if (x($_POST,'submit') && ($_POST['submit'] === L10n::t('Cancel'))) {
- goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+ $a->internalRedirect($_SESSION['photo_return']);
}
$tag = (x($_POST,'tag') ? hex2bin(notags(trim($_POST['tag']))) : '');
$item = Item::selectFirst(['tag'], ['id' => $item_id, 'uid' => local_user()]);
if (!DBA::isResult($item)) {
- goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+ $a->internalRedirect($_SESSION['photo_return']);
}
$arr = explode(',', $item['tag']);
Item::update(['tag' => $tag_str], ['id' => $item_id]);
info(L10n::t('Tag removed') . EOL );
- goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+ $a->internalRedirect($_SESSION['photo_return']);
// NOTREACHED
}
$o = '';
if (!local_user()) {
- goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+ $a->internalRedirect($_SESSION['photo_return']);
// NOTREACHED
}
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
if (!$item_id) {
- goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+ $a->internalRedirect($_SESSION['photo_return']);
// NOTREACHED
}
$item = Item::selectFirst(['tag'], ['id' => $item_id, 'uid' => local_user()]);
if (!DBA::isResult($item)) {
- goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+ $a->internalRedirect($_SESSION['photo_return']);
}
$arr = explode(',', $item['tag']);
if (!count($arr)) {
- goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
+ $a->internalRedirect($_SESSION['photo_return']);
}
$o .= '<h3>' . L10n::t('Remove Item Tag') . '</h3>';
if (isset($_GET['address'])) {
$address = $_GET['address'];
} else {
- $address = System::baseUrl();
+ $address = '';
}
- goaway($address);
+ System::externalRedirect($address);
}
use Friendica\Model\Profile;
use Friendica\Model\User;
-function unfollow_post()
+function unfollow_post(App $a)
{
- $return_url = 'contacts';
+ $return_path = 'contacts';
if (!local_user()) {
notice(L10n::t('Permission denied.'));
- goaway('/login');
+ $a->internalRedirect('login');
// NOTREACHED
}
if (!DBA::isResult($contact)) {
notice(L10n::t("You aren't following this contact."));
- goaway($return_url);
+ $a->internalRedirect($return_path);
// NOTREACHED
}
if (!empty($_REQUEST['cancel'])) {
- goaway($return_url . '/' . $contact['id']);
+ $a->internalRedirect($return_path . '/' . $contact['id']);
}
if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
notice(L10n::t('Unfollowing is currently not supported by your network.'));
- goaway($return_url . '/' . $contact['id']);
+ $a->internalRedirect($return_path . '/' . $contact['id']);
// NOTREACHED
}
$return_path = 'contacts';
} else {
DBA::update('contact', ['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
- $return_path = 'contacts/' . $contact['id'];
+ $return_path = 'contact/' . $contact['id'];
}
info(L10n::t('Contact unfollowed'));
- goaway($return_path);
+ $a->internalRedirect($return_path);
// NOTREACHED
}
function unfollow_content(App $a)
{
- $return_url = 'contacts';
+ $return_path = 'contacts';
if (!local_user()) {
notice(L10n::t('Permission denied.'));
- goaway('/login');
+ $a->internalRedirect('login');
// NOTREACHED
}
if (!DBA::isResult($contact)) {
notice(L10n::t("You aren't following this contact."));
- goaway($return_url);
+ $a->internalRedirect($return_path);
// NOTREACHED
}
if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
notice(L10n::t('Unfollowing is currently not supported by your network.'));
- goaway('contacts/' . $contact['id']);
+ $a->internalRedirect('contact/' . $contact['id']);
// NOTREACHED
}
if (!DBA::isResult($self)) {
notice(L10n::t('Permission denied.'));
- goaway($return_url);
+ $a->internalRedirect($return_path);
// NOTREACHED
}
use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Protocol\DFRN;
+use Friendica\Util\Security;
require_once 'include/items.php';
-require_once 'include/security.php';
function videos_init(App $a)
{
]);
/// @TODO Old-lost code?
- /*$sql_extra = permissions_sql($a->data['user']['uid']);
+ /*$sql_extra = Security::getPermissionsSQLByUserId($a->data['user']['uid']);
$albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d $sql_extra order by created desc",
intval($a->data['user']['uid'])
$owner_uid = $a->data['user']['uid'];
if (local_user() != $owner_uid) {
- goaway(System::baseUrl() . '/videos/' . $a->data['user']['nickname']);
+ $a->internalRedirect('videos/' . $a->data['user']['nickname']);
}
if (($a->argc == 2) && !empty($_POST['delete']) && !empty($_POST['id'])) {
// Check if we should do HTML-based delete confirmation
if (empty($_REQUEST['confirm'])) {
if (!empty($_REQUEST['canceled'])) {
- goaway(System::baseUrl() . '/videos/' . $a->data['user']['nickname']);
+ $a->internalRedirect('videos/' . $a->data['user']['nickname']);
}
$drop_url = $a->query_string;
}
}
- goaway(System::baseUrl() . '/videos/' . $a->data['user']['nickname']);
+ $a->internalRedirect('videos/' . $a->data['user']['nickname']);
return; // NOTREACHED
}
- goaway(System::baseUrl() . '/videos/' . $a->data['user']['nickname']);
+ $a->internalRedirect('videos/' . $a->data['user']['nickname']);
}
function videos_content(App $a)
return;
}
- require_once 'include/security.php';
require_once 'include/conversation.php';
if (empty($a->data['user'])) {
return;
}
- $sql_extra = permissions_sql($owner_uid, $remote_contact, $groups);
+ $sql_extra = Security::getPermissionsSQLByUserId($owner_uid, $remote_contact, $groups);
$o = "";
info(L10n::t('Message sent.') . EOL);
}
- goaway('profile/'.$user['nickname']);
+ $a->internalRedirect('profile/'.$user['nickname']);
}
namespace Friendica;
use Detection\MobileDetect;
+use DOMDocument;
+use DOMXPath;
use Exception;
-use Friendica\Core\Config;
-use Friendica\Core\L10n;
-use Friendica\Core\PConfig;
-use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Network\HTTPException\InternalServerErrorException;
require_once 'boot.php';
-require_once 'include/dba.php';
require_once 'include/text.php';
/**
public $argv;
public $argc;
public $module;
- public $strings;
- public $hooks = [];
public $timezone;
public $interactive = true;
- public $addons;
- public $addons_admin = [];
- public $apps = [];
public $identities;
public $is_mobile = false;
public $is_tablet = false;
public $performance = [];
public $callstack = [];
public $theme_info = [];
- public $nav_sel;
public $category;
// Allow themes to control internal parameters
// by changing App values in theme.php
* Inclusion is done in App->initHead().
* The path can be absolute or relative to the Friendica installation base folder.
*
- * @see App->initHead()
+ * @see initHead()
*
* @param string $path
*/
* Inclusion is done in App->initFooter().
* The path can be absolute or relative to the Friendica installation base folder.
*
- * @see App->initFooter()
+ * @see initFooter()
*
* @param string $path
*/
/**
* @brief App constructor.
*
- * @param string $basePath Path to the app base folder
- * @param bool $backend true, if the call is from backend, otherwise set to true (Default true)
+ * @param string $basePath Path to the app base folder
+ * @param bool $isBackend Whether it is used for backend or frontend (Default true=backend)
*
* @throws Exception if the Basepath is not usable
*/
- public function __construct($basePath, $backend = true)
+ public function __construct($basePath, $isBackend = true)
{
if (!static::isDirectoryUsable($basePath, false)) {
throw new Exception('Basepath ' . $basePath . ' isn\'t usable.');
BaseObject::setApp($this);
$this->basePath = rtrim($basePath, DIRECTORY_SEPARATOR);
- $this->checkBackend($backend);
+ $this->checkBackend($isBackend);
$this->checkFriendicaApp();
$this->performance['start'] = microtime(true);
$this->scheme = 'http';
- if ((x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) ||
- (x($_SERVER, 'HTTP_FORWARDED') && preg_match('/proto=https/', $_SERVER['HTTP_FORWARDED'])) ||
- (x($_SERVER, 'HTTP_X_FORWARDED_PROTO') && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||
- (x($_SERVER, 'HTTP_X_FORWARDED_SSL') && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') ||
- (x($_SERVER, 'FRONT_END_HTTPS') && $_SERVER['FRONT_END_HTTPS'] == 'on') ||
- (x($_SERVER, 'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) // XXX: reasonable assumption, but isn't this hardcoding too much?
+ if (!empty($_SERVER['HTTPS']) ||
+ !empty($_SERVER['HTTP_FORWARDED']) && preg_match('/proto=https/', $_SERVER['HTTP_FORWARDED']) ||
+ !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ||
+ !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on' ||
+ !empty($_SERVER['FRONT_END_HTTPS']) && $_SERVER['FRONT_END_HTTPS'] == 'on' ||
+ !empty($_SERVER['SERVER_PORT']) && (intval($_SERVER['SERVER_PORT']) == 443) // XXX: reasonable assumption, but isn't this hardcoding too much?
) {
$this->scheme = 'https';
}
- if (x($_SERVER, 'SERVER_NAME')) {
+ if (!empty($_SERVER['SERVER_NAME'])) {
$this->hostname = $_SERVER['SERVER_NAME'];
- if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
+ if (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
$this->hostname .= ':' . $_SERVER['SERVER_PORT'];
}
}
. $this->getBasePath(). DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR
. $this->getBasePath());
- if ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 9) === 'pagename=') {
+ if (!empty($_SERVER['QUERY_STRING']) && strpos($_SERVER['QUERY_STRING'], 'pagename=') === 0) {
$this->query_string = substr($_SERVER['QUERY_STRING'], 9);
- } elseif ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === 'q=') {
+ } elseif (!empty($_SERVER['QUERY_STRING']) && strpos($_SERVER['QUERY_STRING'], 'q=') === 0) {
$this->query_string = substr($_SERVER['QUERY_STRING'], 2);
}
}
// See if there is any page number information, and initialise pagination
- $this->pager['page'] = ((x($_GET, 'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1);
+ $this->pager['page'] = !empty($_GET['page']) && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
$this->pager['itemspage'] = 50;
$this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
$this->determineURLPath();
- Config::load();
+ Core\Config::load();
if ($this->getMode()->has(App\Mode::DBAVAILABLE)) {
- Core\Addon::loadHooks();
+ Core\Hook::loadHooks();
$this->loadAddonConfig();
}
$this->loadDefaultTimezone();
- $this->page = [
- 'aside' => '',
- 'bottom' => '',
- 'content' => '',
- 'footer' => '',
- 'htmlhead' => '',
- 'nav' => '',
- 'page_title' => '',
- 'right_aside' => '',
- 'template' => '',
- 'title' => ''
- ];
+ Core\L10n::init();
- $this->process_id = System::processID('log');
+ $this->process_id = Core\System::processID('log');
}
/**
$stamp1 = microtime(true);
- DBA::connect($db_host, $db_user, $db_pass, $db_data, $charset);
+ if (DBA::connect($db_host, $db_user, $db_pass, $db_data, $charset)) {
+ // Loads DB_UPDATE_VERSION constant
+ Database\DBStructure::definition(false);
+ }
+
unset($db_host, $db_user, $db_pass, $db_data, $charset);
$this->saveTimestamp($stamp1, 'network');
$basepath = $this->basePath;
if (!$basepath) {
- $basepath = Config::get('system', 'basepath');
+ $basepath = Core\Config::get('system', 'basepath');
}
- if (!$basepath && x($_SERVER, 'DOCUMENT_ROOT')) {
+ if (!$basepath && !empty($_SERVER['DOCUMENT_ROOT'])) {
$basepath = $_SERVER['DOCUMENT_ROOT'];
}
- if (!$basepath && x($_SERVER, 'PWD')) {
+ if (!$basepath && !empty($_SERVER['PWD'])) {
$basepath = $_SERVER['PWD'];
}
{
$scheme = $this->scheme;
- if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) {
+ if (Core\Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) {
$scheme = 'https';
}
// Basically, we have $ssl = true on any links which can only be seen by a logged in user
// (and also the login link). Anything seen by an outsider will have it turned off.
- if (Config::get('system', 'ssl_policy') == SSL_POLICY_SELFSIGN) {
+ if (Core\Config::get('system', 'ssl_policy') == SSL_POLICY_SELFSIGN) {
if ($ssl) {
$scheme = 'https';
} else {
}
}
- if (Config::get('config', 'hostname') != '') {
- $this->hostname = Config::get('config', 'hostname');
+ if (Core\Config::get('config', 'hostname') != '') {
+ $this->hostname = Core\Config::get('config', 'hostname');
}
return $scheme . '://' . $this->hostname . (!empty($this->getURLPath()) ? '/' . $this->getURLPath() : '' );
$parsed = @parse_url($url);
$hostname = '';
- if (x($parsed)) {
+ if (!empty($parsed)) {
if (!empty($parsed['scheme'])) {
$this->scheme = $parsed['scheme'];
}
$hostname = $parsed['host'];
}
- if (x($parsed, 'port')) {
+ if (!empty($parsed['port'])) {
$hostname .= ':' . $parsed['port'];
}
- if (x($parsed, 'path')) {
+ if (!empty($parsed['path'])) {
$this->urlPath = trim($parsed['path'], '\\/');
}
include $this->getBasePath() . DIRECTORY_SEPARATOR . '.htpreconfig.php';
}
- if (Config::get('config', 'hostname') != '') {
- $this->hostname = Config::get('config', 'hostname');
+ if (Core\Config::get('config', 'hostname') != '') {
+ $this->hostname = Core\Config::get('config', 'hostname');
}
if (!isset($this->hostname) || ($this->hostname == '')) {
public function getHostName()
{
- if (Config::get('config', 'hostname') != '') {
- $this->hostname = Config::get('config', 'hostname');
+ if (Core\Config::get('config', 'hostname') != '') {
+ $this->hostname = Core\Config::get('config', 'hostname');
}
return $this->hostname;
*/
public function initHead()
{
- $interval = ((local_user()) ? PConfig::get(local_user(), 'system', 'update_interval') : 40000);
+ $interval = ((local_user()) ? Core\PConfig::get(local_user(), 'system', 'update_interval') : 40000);
// If the update is 'deactivated' set it to the highest integer number (~24 days)
if ($interval < 0) {
$this->registerStylesheet($stylesheet);
- $shortcut_icon = Config::get('system', 'shortcut_icon');
+ $shortcut_icon = Core\Config::get('system', 'shortcut_icon');
if ($shortcut_icon == '') {
$shortcut_icon = 'images/friendica-32.png';
}
- $touch_icon = Config::get('system', 'touch_icon');
+ $touch_icon = Core\Config::get('system', 'touch_icon');
if ($touch_icon == '') {
$touch_icon = 'images/friendica-128.png';
}
'$baseurl' => $this->getBaseURL(),
'$local_user' => local_user(),
'$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION,
- '$delitem' => L10n::t('Delete this item?'),
- '$showmore' => L10n::t('show more'),
- '$showfewer' => L10n::t('show fewer'),
+ '$delitem' => Core\L10n::t('Delete this item?'),
+ '$showmore' => Core\L10n::t('show more'),
+ '$showfewer' => Core\L10n::t('show fewer'),
'$update_interval' => $interval,
'$shortcut_icon' => $shortcut_icon,
'$touch_icon' => $touch_icon,
'$infinite_scroll' => $infinite_scroll,
- '$block_public' => intval(Config::get('system', 'block_public')),
+ '$block_public' => intval(Core\Config::get('system', 'block_public')),
'$stylesheets' => $this->stylesheets,
]) . $this->page['htmlhead'];
}
private function registerTemplateEngine($class)
{
$v = get_class_vars($class);
- if (x($v, 'name')) {
+ if (!empty($v['name'])) {
$name = $v['name'];
$this->template_engines[$name] = $class;
} else {
*/
public function getTemplateEngine()
{
- $template_engine = 'smarty3';
- if (x($this->theme, 'template_engine')) {
- $template_engine = $this->theme['template_engine'];
- }
+ $template_engine = defaults($this->theme, 'template_engine', 'smarty3');
if (isset($this->template_engines[$template_engine])) {
if (isset($this->template_engine_instance[$template_engine])) {
}
echo "template engine <tt>$template_engine</tt> is not registered!\n";
- killme();
+ exit();
}
/**
$this->performance[$value] += (float) $duration;
$this->performance['marktime'] += (float) $duration;
- $callstack = System::callstack();
+ $callstack = Core\System::callstack();
if (!isset($this->callstack[$value][$callstack])) {
// Prevent ugly E_NOTICE
*
if ($this->is_backend()) {
$process = 'backend';
- $max_processes = Config::get('system', 'max_processes_backend');
+ $max_processes = Core\Config::get('system', 'max_processes_backend');
if (intval($max_processes) == 0) {
$max_processes = 5;
}
} else {
$process = 'frontend';
- $max_processes = Config::get('system', 'max_processes_frontend');
+ $max_processes = Core\Config::get('system', 'max_processes_frontend');
if (intval($max_processes) == 0) {
$max_processes = 20;
}
*/
public function isMinMemoryReached()
{
- $min_memory = Config::get('system', 'min_memory', 0);
+ $min_memory = Core\Config::get('system', 'min_memory', 0);
if ($min_memory == 0) {
return false;
}
{
if ($this->isBackend()) {
$process = 'backend';
- $maxsysload = intval(Config::get('system', 'maxloadavg'));
+ $maxsysload = intval(Core\Config::get('system', 'maxloadavg'));
if ($maxsysload < 1) {
$maxsysload = 50;
}
} else {
$process = 'frontend';
- $maxsysload = intval(Config::get('system', 'maxloadavg_frontend'));
+ $maxsysload = intval(Core\Config::get('system', 'maxloadavg_frontend'));
if ($maxsysload < 1) {
$maxsysload = 50;
}
}
- $load = System::currentLoad();
+ $load = Core\System::currentLoad();
if ($load) {
if (intval($load) > $maxsysload) {
logger('system: load ' . $load . ' for ' . $process . ' tasks (' . $maxsysload . ') too high.');
*/
public function getSenderEmailAddress()
{
- $sender_email = Config::get('config', 'sender_email');
+ $sender_email = Core\Config::get('config', 'sender_email');
if (empty($sender_email)) {
$hostname = $this->getHostName();
if (strpos($hostname, ':')) {
*/
private function computeCurrentTheme()
{
- $system_theme = Config::get('system', 'theme');
+ $system_theme = Core\Config::get('system', 'theme');
if (!$system_theme) {
- throw new Exception(L10n::t('No system theme config value set.'));
+ throw new Exception(Core\L10n::t('No system theme config value set.'));
}
// Sane default
$this->currentTheme = $system_theme;
- $allowed_themes = explode(',', Config::get('system', 'allowed_themes', $system_theme));
+ $allowed_themes = explode(',', Core\Config::get('system', 'allowed_themes', $system_theme));
$page_theme = null;
// Find the theme that belongs to the user whose stuff we are looking at
// Allow folks to override user themes and always use their own on their own site.
// This works only if the user is on the same server
$user = DBA::selectFirst('user', ['theme'], ['uid' => $this->profile_uid]);
- if (DBA::isResult($user) && !PConfig::get(local_user(), 'system', 'always_my_theme')) {
+ if (DBA::isResult($user) && !Core\PConfig::get(local_user(), 'system', 'always_my_theme')) {
$page_theme = $user['theme'];
}
}
// Specific mobile theme override
if (($this->is_mobile || $this->is_tablet) && Core\Session::get('show-mobile', true)) {
- $system_mobile_theme = Config::get('system', 'mobile-theme');
+ $system_mobile_theme = Core\Config::get('system', 'mobile-theme');
$user_mobile_theme = Core\Session::get('mobile-theme', $system_mobile_theme);
// --- means same mobile theme as desktop
return $default;
}
+
+ /**
+ * Sets the base url for use in cmdline programs which don't have
+ * $_SERVER variables
+ */
+ public function checkURL()
+ {
+ $url = Core\Config::get('system', 'url');
+
+ // if the url isn't set or the stored url is radically different
+ // than the currently visited url, store the current value accordingly.
+ // "Radically different" ignores common variations such as http vs https
+ // and www.example.com vs example.com.
+ // We will only change the url to an ip address if there is no existing setting
+
+ if (empty($url) || (!link_compare($url, $this->getBaseURL())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $this->getHostName()))) {
+ Core\Config::set('system', 'url', $this->getBaseURL());
+ }
+ }
+
+ /**
+ * Frontend App script
+ *
+ * The App object behaves like a container and a dispatcher at the same time, including a representation of the
+ * request and a representation of the response.
+ *
+ * This probably should change to limit the size of this monster method.
+ */
+ public function runFrontend()
+ {
+ // Missing DB connection: ERROR
+ if ($this->getMode()->has(App\Mode::LOCALCONFIGPRESENT) && !$this->getMode()->has(App\Mode::DBAVAILABLE)) {
+ Core\System::httpExit(500, ['title' => 'Error 500 - Internal Server Error', 'description' => 'Apologies but the website is unavailable at the moment.']);
+ }
+
+ // Max Load Average reached: ERROR
+ if ($this->isMaxProcessesReached() || $this->isMaxLoadReached()) {
+ header('Retry-After: 120');
+ header('Refresh: 120; url=' . $this->getBaseURL() . "/" . $this->query_string);
+
+ Core\System::httpExit(503, ['title' => 'Error 503 - Service Temporarily Unavailable', 'description' => 'Core\System is currently overloaded. Please try again later.']);
+ }
+
+ if (strstr($this->query_string, '.well-known/host-meta') && ($this->query_string != '.well-known/host-meta')) {
+ Core\System::httpExit(404);
+ }
+
+ if (!$this->getMode()->isInstall()) {
+ // Force SSL redirection
+ if (Core\Config::get('system', 'force_ssl') && ($this->getScheme() == "http")
+ && intval(Core\Config::get('system', 'ssl_policy')) == SSL_POLICY_FULL
+ && strpos($this->getBaseURL(), 'https://') === 0
+ && $_SERVER['REQUEST_METHOD'] == 'GET') {
+ header('HTTP/1.1 302 Moved Temporarily');
+ header('Location: ' . $this->getBaseURL() . '/' . $this->query_string);
+ exit();
+ }
+
+ Core\Session::init();
+ Core\Addon::callHooks('init_1');
+ }
+
+ // Exclude the backend processes from the session management
+ if (!$this->isBackend()) {
+ $stamp1 = microtime(true);
+ session_start();
+ $this->saveTimestamp($stamp1, 'parser');
+ Core\L10n::setSessionVariable();
+ Core\L10n::setLangFromSession();
+ } else {
+ $_SESSION = [];
+ Core\Worker::executeIfIdle();
+ }
+
+ // ZRL
+ if (!empty($_GET['zrl']) && $this->getMode()->isNormal()) {
+ $this->query_string = Model\Profile::stripZrls($this->query_string);
+ if (!local_user()) {
+ // Only continue when the given profile link seems valid
+ // Valid profile links contain a path with "/profile/" and no query parameters
+ if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "") &&
+ strstr(parse_url($_GET['zrl'], PHP_URL_PATH), "/profile/")) {
+ if (defaults($_SESSION, "visitor_home", "") != $_GET["zrl"]) {
+ $_SESSION['my_url'] = $_GET['zrl'];
+ $_SESSION['authenticated'] = 0;
+ }
+ Model\Profile::zrlInit($this);
+ } else {
+ // Someone came with an invalid parameter, maybe as a DDoS attempt
+ // We simply stop processing here
+ logger("Invalid ZRL parameter " . $_GET['zrl'], LOGGER_DEBUG);
+ Core\System::httpExit(403, ['title' => '403 Forbidden']);
+ }
+ }
+ }
+
+ if (!empty($_GET['owt']) && $this->getMode()->isNormal()) {
+ $token = $_GET['owt'];
+ $this->query_string = Model\Profile::stripQueryParam($this->query_string, 'owt');
+ Model\Profile::openWebAuthInit($token);
+ }
+
+ Module\Login::sessionAuth();
+
+ if (empty($_SESSION['authenticated'])) {
+ header('X-Account-Management-Status: none');
+ }
+
+ $_SESSION['sysmsg'] = defaults($_SESSION, 'sysmsg' , []);
+ $_SESSION['sysmsg_info'] = defaults($_SESSION, 'sysmsg_info' , []);
+ $_SESSION['last_updated'] = defaults($_SESSION, 'last_updated', []);
+
+ /*
+ * check_config() is responsible for running update scripts. These automatically
+ * update the DB schema whenever we push a new one out. It also checks to see if
+ * any addons have been added or removed and reacts accordingly.
+ */
+
+ // in install mode, any url loads install module
+ // but we need "view" module for stylesheet
+ if ($this->getMode()->isInstall() && $this->module != 'view') {
+ $this->module = 'install';
+ } elseif (!$this->getMode()->has(App\Mode::MAINTENANCEDISABLED) && $this->module != 'view') {
+ $this->module = 'maintenance';
+ } else {
+ $this->checkURL();
+ check_db(false);
+ Core\Addon::loadAddons();
+ Core\Hook::loadHooks();
+ }
+
+ $this->page = [
+ 'aside' => '',
+ 'bottom' => '',
+ 'content' => '',
+ 'footer' => '',
+ 'htmlhead' => '',
+ 'nav' => '',
+ 'page_title' => '',
+ 'right_aside' => '',
+ 'template' => '',
+ 'title' => ''
+ ];
+
+ if (strlen($this->module)) {
+ // Compatibility with the Android Diaspora client
+ if ($this->module == 'stream') {
+ $this->internalRedirect('network?f=&order=post');
+ }
+
+ if ($this->module == 'conversations') {
+ $this->internalRedirect('message');
+ }
+
+ if ($this->module == 'commented') {
+ $this->internalRedirect('network?f=&order=comment');
+ }
+
+ if ($this->module == 'liked') {
+ $this->internalRedirect('network?f=&order=comment');
+ }
+
+ if ($this->module == 'activity') {
+ $this->internalRedirect('network/?f=&conv=1');
+ }
+
+ if (($this->module == 'status_messages') && ($this->cmd == 'status_messages/new')) {
+ $this->internalRedirect('bookmarklet');
+ }
+
+ if (($this->module == 'user') && ($this->cmd == 'user/edit')) {
+ $this->internalRedirect('settings');
+ }
+
+ if (($this->module == 'tag_followings') && ($this->cmd == 'tag_followings/manage')) {
+ $this->internalRedirect('search');
+ }
+
+ // Compatibility with the Firefox App
+ if (($this->module == "users") && ($this->cmd == "users/sign_in")) {
+ $this->module = "login";
+ }
+
+ $privateapps = Core\Config::get('config', 'private_addons', false);
+ if (Core\Addon::isEnabled($this->module) && file_exists("addon/{$this->module}/{$this->module}.php")) {
+ //Check if module is an app and if public access to apps is allowed or not
+ if ((!local_user()) && Core\Hook::isAddonApp($this->module) && $privateapps) {
+ info(Core\L10n::t("You must be logged in to use addons. "));
+ } else {
+ include_once "addon/{$this->module}/{$this->module}.php";
+ if (function_exists($this->module . '_module')) {
+ LegacyModule::setModuleFile("addon/{$this->module}/{$this->module}.php");
+ $this->module_class = 'Friendica\\LegacyModule';
+ $this->module_loaded = true;
+ }
+ }
+ }
+
+ // Controller class routing
+ if (! $this->module_loaded && class_exists('Friendica\\Module\\' . ucfirst($this->module))) {
+ $this->module_class = 'Friendica\\Module\\' . ucfirst($this->module);
+ $this->module_loaded = true;
+ }
+
+ /* If not, next look for a 'standard' program module in the 'mod' directory
+ * We emulate a Module class through the LegacyModule class
+ */
+ if (! $this->module_loaded && file_exists("mod/{$this->module}.php")) {
+ LegacyModule::setModuleFile("mod/{$this->module}.php");
+ $this->module_class = 'Friendica\\LegacyModule';
+ $this->module_loaded = true;
+ }
+
+ /* The URL provided does not resolve to a valid module.
+ *
+ * On Dreamhost sites, quite often things go wrong for no apparent reason and they send us to '/internal_error.html'.
+ * We don't like doing this, but as it occasionally accounts for 10-20% or more of all site traffic -
+ * we are going to trap this and redirect back to the requested page. As long as you don't have a critical error on your page
+ * this will often succeed and eventually do the right thing.
+ *
+ * Otherwise we are going to emit a 404 not found.
+ */
+ if (! $this->module_loaded) {
+ // Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit.
+ if (!empty($_SERVER['QUERY_STRING']) && preg_match('/{[0-9]}/', $_SERVER['QUERY_STRING']) !== 0) {
+ exit();
+ }
+
+ if (!empty($_SERVER['QUERY_STRING']) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
+ logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']);
+ $this->internalRedirect($_SERVER['REQUEST_URI']);
+ }
+
+ logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG);
+
+ header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . Core\L10n::t('Not Found'));
+ $tpl = get_markup_template("404.tpl");
+ $this->page['content'] = replace_macros($tpl, [
+ '$message' => Core\L10n::t('Page not found.')
+ ]);
+ }
+ }
+
+ // Load current theme info
+ $theme_info_file = 'view/theme/' . $this->getCurrentTheme() . '/theme.php';
+ if (file_exists($theme_info_file)) {
+ require_once $theme_info_file;
+ }
+
+ // initialise content region
+ if ($this->getMode()->isNormal()) {
+ Core\Addon::callHooks('page_content_top', $this->page['content']);
+ }
+
+ // Call module functions
+ if ($this->module_loaded) {
+ $this->page['page_title'] = $this->module;
+ $placeholder = '';
+
+ Core\Addon::callHooks($this->module . '_mod_init', $placeholder);
+
+ call_user_func([$this->module_class, 'init']);
+
+ // "rawContent" is especially meant for technical endpoints.
+ // This endpoint doesn't need any theme initialization or other comparable stuff.
+ if (!$this->error) {
+ call_user_func([$this->module_class, 'rawContent']);
+ }
+
+ if (function_exists(str_replace('-', '_', $this->getCurrentTheme()) . '_init')) {
+ $func = str_replace('-', '_', $this->getCurrentTheme()) . '_init';
+ $func($this);
+ }
+
+ if (! $this->error && $_SERVER['REQUEST_METHOD'] === 'POST') {
+ Core\Addon::callHooks($this->module . '_mod_post', $_POST);
+ call_user_func([$this->module_class, 'post']);
+ }
+
+ if (! $this->error) {
+ Core\Addon::callHooks($this->module . '_mod_afterpost', $placeholder);
+ call_user_func([$this->module_class, 'afterpost']);
+ }
+
+ if (! $this->error) {
+ $arr = ['content' => $this->page['content']];
+ Core\Addon::callHooks($this->module . '_mod_content', $arr);
+ $this->page['content'] = $arr['content'];
+ $arr = ['content' => call_user_func([$this->module_class, 'content'])];
+ Core\Addon::callHooks($this->module . '_mod_aftercontent', $arr);
+ $this->page['content'] .= $arr['content'];
+ }
+
+ if (function_exists(str_replace('-', '_', $this->getCurrentTheme()) . '_content_loaded')) {
+ $func = str_replace('-', '_', $this->getCurrentTheme()) . '_content_loaded';
+ $func($this);
+ }
+ }
+
+ /* Create the page head after setting the language
+ * and getting any auth credentials.
+ *
+ * Moved initHead() and initFooter() to after
+ * all the module functions have executed so that all
+ * theme choices made by the modules can take effect.
+ */
+ $this->initHead();
+
+ /* Build the page ending -- this is stuff that goes right before
+ * the closing </body> tag
+ */
+ $this->initFooter();
+
+ /* now that we've been through the module content, see if the page reported
+ * a permission problem and if so, a 403 response would seem to be in order.
+ */
+ if (stristr(implode("", $_SESSION['sysmsg']), Core\L10n::t('Permission denied'))) {
+ header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . Core\L10n::t('Permission denied.'));
+ }
+
+ // Report anything which needs to be communicated in the notification area (before the main body)
+ Core\Addon::callHooks('page_end', $this->page['content']);
+
+ // Add the navigation (menu) template
+ if ($this->module != 'install' && $this->module != 'maintenance') {
+ $this->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), []);
+ $this->page['nav'] = Content\Nav::build($this);
+ }
+
+ // Build the page - now that we have all the components
+ if (isset($_GET["mode"]) && (($_GET["mode"] == "raw") || ($_GET["mode"] == "minimal"))) {
+ $doc = new DOMDocument();
+
+ $target = new DOMDocument();
+ $target->loadXML("<root></root>");
+
+ $content = mb_convert_encoding($this->page["content"], 'HTML-ENTITIES', "UTF-8");
+
+ /// @TODO one day, kill those error-surpressing @ stuff, or PHP should ban it
+ @$doc->loadHTML($content);
+
+ $xpath = new DOMXPath($doc);
+
+ $list = $xpath->query("//*[contains(@id,'tread-wrapper-')]"); /* */
+
+ foreach ($list as $item) {
+ $item = $target->importNode($item, true);
+
+ // And then append it to the target
+ $target->documentElement->appendChild($item);
+ }
+ }
+
+ if (isset($_GET["mode"]) && ($_GET["mode"] == "raw")) {
+ header("Content-type: text/html; charset=utf-8");
+
+ echo substr($target->saveHTML(), 6, -8);
+
+ exit();
+ }
+
+ $page = $this->page;
+ $profile = $this->profile;
+
+ header("X-Friendica-Version: " . FRIENDICA_VERSION);
+ header("Content-type: text/html; charset=utf-8");
+
+ if (Core\Config::get('system', 'hsts') && (Core\Config::get('system', 'ssl_policy') == SSL_POLICY_FULL)) {
+ header("Strict-Transport-Security: max-age=31536000");
+ }
+
+ // Some security stuff
+ header('X-Content-Type-Options: nosniff');
+ header('X-XSS-Protection: 1; mode=block');
+ header('X-Permitted-Cross-Domain-Policies: none');
+ header('X-Frame-Options: sameorigin');
+
+ // Things like embedded OSM maps don't work, when this is enabled
+ // header("Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' https: data:; media-src 'self' https:; child-src 'self' https:; object-src 'none'");
+
+ /* We use $_GET["mode"] for special page templates. So we will check if we have
+ * to load another page template than the default one.
+ * The page templates are located in /view/php/ or in the theme directory.
+ */
+ if (isset($_GET["mode"])) {
+ $template = Core\Theme::getPathForFile($_GET["mode"] . '.php');
+ }
+
+ // If there is no page template use the default page template
+ if (empty($template)) {
+ $template = Core\Theme::getPathForFile("default.php");
+ }
+
+ // Theme templates expect $a as an App instance
+ $a = $this;
+
+ /// @TODO Looks unsafe (remote-inclusion), is maybe not but Core\Theme::getPathForFile() uses file_exists() but does not escape anything
+ require_once $template;
+ }
+
+ /**
+ * Redirects to another module relative to the current Friendica base.
+ * If you want to redirect to a external URL, use System::externalRedirectTo()
+ *
+ * @param string $toUrl The destination URL (Default is empty, which is the default page of the Friendica node)
+ * @param bool $ssl if true, base URL will try to get called with https:// (works just for relative paths)
+ *
+ * @throws InternalServerErrorException In Case the given URL is not relative to the Friendica node
+ */
+ public function internalRedirect($toUrl = '', $ssl = false)
+ {
+ if (filter_var($toUrl, FILTER_VALIDATE_URL)) {
+ throw new InternalServerErrorException("'$toUrl is not a relative path, please use System::externalRedirectTo");
+ }
+
+ $redirectTo = $this->getBaseURL($ssl) . '/' . ltrim($toUrl, '/');
+ Core\System::externalRedirect($redirectTo);
+ }
}
namespace Friendica;
+use Friendica\Core\L10n;
+use Friendica\Core\System;
+
/**
* All modules in Friendica should extend BaseModule, although not all modules
* need to extend all the methods described here
*/
public static function post()
{
- // goaway('module');
+ // $a = self::getApp();
+ // $a->internalRedirect('module');
}
/**
{
}
+
+ /*
+ * Functions used to protect against Cross-Site Request Forgery
+ * The security token has to base on at least one value that an attacker can't know - here it's the session ID and the private key.
+ * In this implementation, a security token is reusable (if the user submits a form, goes back and resubmits the form, maybe with small changes;
+ * or if the security token is used for ajax-calls that happen several times), but only valid for a certain amout of time (3hours).
+ * The "typename" seperates the security tokens of different types of forms. This could be relevant in the following case:
+ * A security token is used to protekt a link from CSRF (e.g. the "delete this profile"-link).
+ * If the new page contains by any chance external elements, then the used security token is exposed by the referrer.
+ * Actually, important actions should not be triggered by Links / GET-Requests at all, but somethimes they still are,
+ * so this mechanism brings in some damage control (the attacker would be able to forge a request to a form of this type, but not to forms of other types).
+ */
+ public static function getFormSecurityToken($typename = '')
+ {
+ $a = get_app();
+
+ $timestamp = time();
+ $sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $timestamp . $typename);
+
+ return $timestamp . '.' . $sec_hash;
+ }
+
+ public static function checkFormSecurityToken($typename = '', $formname = 'form_security_token')
+ {
+ $hash = null;
+
+ if (!empty($_REQUEST[$formname])) {
+ /// @TODO Careful, not secured!
+ $hash = $_REQUEST[$formname];
+ }
+
+ if (!empty($_SERVER['HTTP_X_CSRF_TOKEN'])) {
+ /// @TODO Careful, not secured!
+ $hash = $_SERVER['HTTP_X_CSRF_TOKEN'];
+ }
+
+ if (empty($hash)) {
+ return false;
+ }
+
+ $max_livetime = 10800; // 3 hours
+
+ $a = get_app();
+
+ $x = explode('.', $hash);
+ if (time() > (IntVal($x[0]) + $max_livetime)) {
+ return false;
+ }
+
+ $sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $x[0] . $typename);
+
+ return ($sec_hash == $x[1]);
+ }
+
+ public static function getFormSecurityStandardErrorMessage()
+ {
+ return L10n::t("The form security token was not correct. This probably happened because the form has been opened for too long \x28>3 hours\x29 before submitting it.") . EOL;
+ }
+
+ public static function checkFormSecurityTokenRedirectOnError($err_redirect, $typename = '', $formname = 'form_security_token')
+ {
+ if (!self::checkFormSecurityToken($typename, $formname)) {
+ $a = get_app();
+ logger('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
+ logger('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA);
+ notice(self::getFormSecurityStandardErrorMessage());
+ $a->internalRedirect($err_redirect);
+ }
+ }
+
+ public static function checkFormSecurityTokenForbiddenOnError($typename = '', $formname = 'form_security_token')
+ {
+ if (!self::checkFormSecurityToken($typename, $formname)) {
+ $a = get_app();
+ logger('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
+ logger('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA);
+ header('HTTP/1.1 403 Forbidden');
+ killme();
+ }
+ }
}
use Friendica\Model\Profile;
require_once 'boot.php';
-require_once 'dba.php';
require_once 'include/text.php';
class Nav
{
+ private static $selected = [
+ 'global' => null,
+ 'community' => null,
+ 'network' => null,
+ 'home' => null,
+ 'profiles' => null,
+ 'introductions' => null,
+ 'notifications' => null,
+ 'messages' => null,
+ 'directory' => null,
+ 'settings' => null,
+ 'contacts' => null,
+ 'manage' => null,
+ 'events' => null,
+ 'register' => null
+ ];
+
+ /**
+ * An array of HTML links provided by addons providing a module via the app_menu hook
+ *
+ * @var array
+ */
+ private static $app_menu = null;
+
+ /**
+ * Set a menu item in navbar as selected
+ */
+ public static function setSelected($item)
+ {
+ self::$selected[$item] = 'selected';
+ }
+
/**
* Build page header and site navigation bars
*/
public static function build(App $a)
{
- if (!(x($a->page, 'nav'))) {
- $a->page['nav'] = '';
- }
-
- $a->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), []);
-
- /*
- * Placeholder div for popup panel
- */
-
- $a->page['nav'] .= '<div id="panel" style="display: none;"></div>' ;
+ // Placeholder div for popup panel
+ $nav = '<div id="panel" style="display: none;"></div>' ;
$nav_info = self::getInfo($a);
- /*
- * Build the page
- */
-
$tpl = get_markup_template('nav.tpl');
- $a->page['nav'] .= replace_macros($tpl, [
- '$baseurl' => System::baseUrl(),
+ $nav .= replace_macros($tpl, [
+ '$baseurl' => System::baseUrl(),
'$sitelocation' => $nav_info['sitelocation'],
- '$nav' => $nav_info['nav'],
- '$banner' => $nav_info['banner'],
+ '$nav' => $nav_info['nav'],
+ '$banner' => $nav_info['banner'],
'$emptynotifications' => L10n::t('Nothing new here'),
- '$userinfo' => $nav_info['userinfo'],
- '$sel' => $a->nav_sel,
- '$apps' => $a->apps,
+ '$userinfo' => $nav_info['userinfo'],
+ '$sel' => self::$selected,
+ '$apps' => self::getAppMenu(),
'$clear_notifs' => L10n::t('Clear notifications'),
- '$search_hint' => L10n::t('@name, !forum, #tags, content')
+ '$search_hint' => L10n::t('@name, !forum, #tags, content')
]);
- Addon::callHooks('page_header', $a->page['nav']);
+ Addon::callHooks('page_header', $nav);
+
+ return $nav;
+ }
+
+ /**
+ * Returns the addon app menu
+ *
+ * @return array
+ */
+ public static function getAppMenu()
+ {
+ if (is_null(self::$app_menu)) {
+ self::populateAppMenu();
+ }
+
+ return self::$app_menu;
+ }
+
+ /**
+ * Fills the apps static variable with apps that require a menu
+ */
+ private static function populateAppMenu()
+ {
+ self::$app_menu = [];
+
+ //Don't populate apps_menu if apps are private
+ $privateapps = Config::get('config', 'private_addons', false);
+ if (local_user() || !$privateapps) {
+ $arr = ['app_menu' => self::$app_menu];
+
+ Addon::callHooks('app_menu', $arr);
+
+ self::$app_menu = $arr['app_menu'];
+ }
}
/**
$nav['help'] = [$help_url, L10n::t('Help'), '', L10n::t('Help and documentation')];
}
- if (count($a->apps) > 0) {
+ if (count(self::getAppMenu()) > 0) {
$nav['apps'] = ['apps', L10n::t('Apps'), '', L10n::t('Addon applications, utilities, games')];
}
'userinfo' => $userinfo,
];
}
-
- /**
- * Set a menu item in navbar as selected
- */
- public static function setSelected($item)
- {
- $a = get_app();
- $a->nav_sel = [
- 'global' => null,
- 'community' => null,
- 'network' => null,
- 'home' => null,
- 'profiles' => null,
- 'introductions' => null,
- 'notifications' => null,
- 'messages' => null,
- 'directory' => null,
- 'settings' => null,
- 'contacts' => null,
- 'manage' => null,
- 'events' => null,
- 'register' => null
- ];
- $a->nav_sel[$item] = 'selected';
- }
}
'content' => $json_string,
'created' => DateTimeFormat::utcNow()
], true);
- $cache_ttl = CACHE_DAY;
+ $cache_ttl = Cache::DAY;
} else {
- $cache_ttl = CACHE_FIVE_MINUTES;
+ $cache_ttl = Cache::FIVE_MINUTES;
}
Cache::set($cache_key, $json_string, $cache_ttl);
}
/**
- * Processes [share] tags
+ * This function converts a [share] block to text according to a provided callback function whose signature is:
*
- * Note: Can produce a [bookmark] tag in the output
+ * function(array $attributes, array $author_contact, string $content, boolean $is_quote_share): string
*
- * @brief Processes [share] tags
- * @param array $share preg_match_callback result array
- * @param bool|int $simplehtml
- * @return string
+ * Where:
+ * - $attributes is an array of attributes of the [share] block itself. Missing keys will be completed by the contact
+ * data lookup
+ * - $author_contact is a contact record array
+ * - $content is the inner content of the [share] block
+ * - $is_quote_share indicates whether there's any content before the [share] block
+ * - Return value is the string that should replace the [share] block in the provided text
+ *
+ * This function is intended to be used by addon connector to format a share block like the target network is expecting it.
+ *
+ * @param string $text A BBCode string
+ * @param callable $callback
+ * @return string The BBCode string with all [share] blocks replaced
*/
- private static function convertShare($share, $simplehtml)
+ public static function convertShare($text, callable $callback)
{
- $attributes = $share[2];
-
- $author = "";
- preg_match("/author='(.*?)'/ism", $attributes, $matches);
- if (x($matches, 1)) {
- $author = html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8');
- }
-
- preg_match('/author="(.*?)"/ism', $attributes, $matches);
- if (x($matches, 1)) {
- $author = $matches[1];
- }
-
- $profile = "";
- preg_match("/profile='(.*?)'/ism", $attributes, $matches);
- if (x($matches, 1)) {
- $profile = $matches[1];
- }
-
- preg_match('/profile="(.*?)"/ism', $attributes, $matches);
- if (x($matches, 1)) {
- $profile = $matches[1];
- }
-
- $avatar = "";
- preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
- if (x($matches, 1)) {
- $avatar = $matches[1];
- }
-
- preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
- if (x($matches, 1)) {
- $avatar = $matches[1];
- }
-
- $link = "";
- preg_match("/link='(.*?)'/ism", $attributes, $matches);
- if (x($matches, 1)) {
- $link = $matches[1];
- }
-
- preg_match('/link="(.*?)"/ism', $attributes, $matches);
- if (x($matches, 1)) {
- $link = $matches[1];
- }
-
- $posted = "";
-
- preg_match("/posted='(.*?)'/ism", $attributes, $matches);
- if (x($matches, 1)) {
- $posted = $matches[1];
- }
-
- preg_match('/posted="(.*?)"/ism', $attributes, $matches);
- if (x($matches, 1)) {
- $posted = $matches[1];
- }
+ $return = preg_replace_callback(
+ "/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism",
+ function ($match) use ($callback) {
+ $attribute_string = $match[2];
+
+ $attributes = [];
+ foreach(['author', 'profile', 'avatar', 'link', 'posted'] as $field) {
+ preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches);
+ $attributes[$field] = html_entity_decode(defaults($matches, 2, ''), ENT_QUOTES, 'UTF-8');
+ }
- // We only call this so that a previously unknown contact can be added.
- // This is important for the function "Model\Contact::getDetailsByURL()".
- // This function then can fetch an entry from the contact table.
- Contact::getIdForURL($profile, 0, true);
+ // We only call this so that a previously unknown contact can be added.
+ // This is important for the function "Model\Contact::getDetailsByURL()".
+ // This function then can fetch an entry from the contact table.
+ Contact::getIdForURL($attributes['profile'], 0, true);
- $data = Contact::getDetailsByURL($profile);
+ $author_contact = Contact::getDetailsByURL($attributes['profile']);
+ $author_contact['addr'] = defaults($author_contact, 'addr' , Protocol::getAddrFromProfileUrl($attributes['profile']));
- if (x($data, "name") && x($data, "addr")) {
- $userid_compact = $data["name"] . " (" . $data["addr"] . ")";
- } else {
- $userid_compact = Protocol::getAddrFromProfileUrl($profile, $author);
- }
+ $attributes['author'] = defaults($author_contact, 'name' , $attributes['author']);
+ $attributes['avatar'] = defaults($author_contact, 'micro', $attributes['avatar']);
+ $attributes['profile'] = defaults($author_contact, 'url' , $attributes['profile']);
- if (x($data, "addr")) {
- $userid = $data["addr"];
- } else {
- $userid = Protocol::formatMention($profile, $author);
- }
+ if ($attributes['avatar']) {
+ $attributes['avatar'] = ProxyUtils::proxifyUrl($attributes['avatar'], false, ProxyUtils::SIZE_THUMB);
+ }
- if (x($data, "name")) {
- $author = $data["name"];
- }
+ return $match[1] . $callback($attributes, $author_contact, $match[3], trim($match[1]) != '');
+ },
+ $text
+ );
- if (x($data, "micro")) {
- $avatar = $data["micro"];
- }
+ return $return;
+ }
- $preshare = trim($share[1]);
- if ($preshare != "") {
- $preshare .= "<br />";
- }
+ /**
+ * Default [share] tag conversion callback
+ *
+ * Note: Can produce a [bookmark] tag in the output
+ *
+ * @see BBCode::convertShare()
+ * @param array $attributes [share] block attribute values
+ * @param array $author_contact Contact row of the shared author
+ * @param string $content Inner content of the [share] block
+ * @param boolean $is_quote_share Whether there is content before the [share] block
+ * @param integer $simplehtml Mysterious integer value depending on the target network/formatting style
+ * @return string
+ */
+ private static function convertShareCallback(array $attributes, array $author_contact, $content, $is_quote_share, $simplehtml)
+ {
+ $mention = Protocol::formatMention($attributes['profile'], $attributes['author']);
switch ($simplehtml) {
case 1:
- $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . ' <a href="' . $profile . '">' . $userid . "</a>: <br />»" . $share[3] . "«";
+ $text = ($is_quote_share? '<br />' : '') . '<p>' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8') . ' <a href="' . $attributes['profile'] . '">' . $mention . '</a>: </p>' . "\n" . '«' . $content . '»';
break;
case 2:
- $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . ' ' . $userid_compact . ": <br />" . $share[3];
+ $text = ($is_quote_share? '<br />' : '') . '<p>' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8') . ' ' . $author_contact['addr'] . ': </p>' . "\n" . $content;
break;
case 3: // Diaspora
- $headline = '<b>' . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . $userid . ':</b><br />';
-
- $text = trim($share[1]);
-
- if ($text != "") {
- $text .= "<hr />";
- }
+ $headline = '<p><b>' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8') . $mention . ':</b></p>' . "\n";
- if (stripos(normalise_link($link), 'http://twitter.com/') === 0) {
- $text .= '<br /><a href="' . $link . '">' . $link . '</a>';
+ if (stripos(normalise_link($attributes['link']), 'http://twitter.com/') === 0) {
+ $text = ($is_quote_share? '<hr />' : '') . '<p><a href="' . $attributes['link'] . '">' . $attributes['link'] . '</a></p>' . "\n";
} else {
- $text .= $headline . '<blockquote>' . trim($share[3]) . "</blockquote><br />";
+ $text = ($is_quote_share? '<hr />' : '') . $headline . '<blockquote>' . trim($content) . '</blockquote>' . "\n";
- if ($link != "") {
- $text .= '<br /><a href="' . $link . '">[l]</a>';
+ if ($attributes['link'] != '') {
+ $text .= '<p><a href="' . $attributes['link'] . '">[l]</a></p>' . "\n";
}
}
break;
case 4:
- $headline = '<br /><b>' . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
- $headline .= L10n::t('<a href="%1$s" target="_blank">%2$s</a> %3$s', $link, $userid, $posted);
- $headline .= ":</b><br />";
+ $headline = '<p><b>' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8');
+ $headline .= L10n::t('<a href="%1$s" target="_blank">%2$s</a> %3$s', $attributes['link'], $mention, $attributes['posted']);
+ $headline .= ':</b></p>' . "\n";
- $text = trim($share[1]);
-
- if ($text != "") {
- $text .= "<hr />";
- }
-
- $text .= $headline . '<blockquote class="shared_content">' . trim($share[3]) . "</blockquote><br />";
+ $text = ($is_quote_share? '<hr />' : '') . $headline . '<blockquote class="shared_content">' . trim($content) . '</blockquote>' . "\n";
break;
case 5:
- $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . ' ' . $userid_compact . ": <br />" . $share[3];
+ $text = ($is_quote_share? '<br />' : '') . '<p>' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8') . ' ' . $author_contact['addr'] . ': </p>' . "\n" . $content;
break;
case 7: // statusnet/GNU Social
- $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . " @" . $userid_compact . ": " . $share[3];
- break;
- case 8: // twitter
- $text = $preshare . "RT @" . $userid_compact . ": " . $share[3];
+ $text = ($is_quote_share? '<br />' : '') . '<p>' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8') . ' @' . $author_contact['addr'] . ': ' . $content . '</p>' . "\n";
break;
case 9: // Google+
- $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . ' ' . $userid_compact . ": <br />" . $share[3];
+ $text = ($is_quote_share? '<br />' : '') . '<p>' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8') . ' ' . $author_contact['addr'] . ': </p>' . "\n";
+ $text .= '<p>' . $content . '</p>' . "\n";
- if ($link != "") {
- $text .= "<br /><br />" . $link;
+ if ($attributes['link'] != '') {
+ $text .= '<p>' . $attributes['link'] . '</p>';
}
break;
default:
// Transforms quoted tweets in rich attachments to avoid nested tweets
- if (stripos(normalise_link($link), 'http://twitter.com/') === 0 && OEmbed::isAllowedURL($link)) {
+ if (stripos(normalise_link($attributes['link']), 'http://twitter.com/') === 0 && OEmbed::isAllowedURL($attributes['link'])) {
try {
- $oembed = OEmbed::getHTML($link, $preshare);
+ $text = ($is_quote_share? '<br />' : '') . OEmbed::getHTML($attributes['link']);
} catch (Exception $e) {
- $oembed = sprintf('[bookmark=%s]%s[/bookmark]', $link, $preshare);
+ $text = ($is_quote_share? '<br />' : '') . sprintf('[bookmark=%s]%s[/bookmark]', $attributes['link'], $content);
}
-
- $text = $preshare . $oembed;
} else {
- $text = trim($share[1]) . "\n";
-
- $avatar = ProxyUtils::proxifyUrl($avatar, false, ProxyUtils::SIZE_THUMB);
+ $text = ($is_quote_share? "\n" : '');
$tpl = get_markup_template('shared_content.tpl');
$text .= replace_macros($tpl, [
- '$profile' => $profile,
- '$avatar' => $avatar,
- '$author' => $author,
- '$link' => $link,
- '$posted' => $posted,
- '$content' => trim($share[3])
+ '$profile' => $attributes['profile'],
+ '$avatar' => $attributes['avatar'],
+ '$author' => $attributes['author'],
+ '$link' => $attributes['link'],
+ '$posted' => $attributes['posted'],
+ '$content' => trim($content)
]);
}
break;
// Handle Diaspora posts
$text = preg_replace_callback(
- "&\[url=/posts/([^\[\]]*)\](.*)\[\/url\]&Usi",
+ "&\[url=/?posts/([^\[\]]*)\](.*)\[\/url\]&Usi",
function ($match) {
return "[url=" . System::baseUrl() . "/display/" . $match[1] . "]" . $match[2] . "[/url]";
}, $text
$text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img src="$1" alt="' . L10n::t('Image/photo') . '" />', $text);
// Shared content
- $text = preg_replace_callback("/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism",
- function ($match) use ($simple_html) {
- return self::convertShare($match, $simple_html);
- }, $text);
+ $text = self::convertShare(
+ $text,
+ function (array $attributes, array $author_contact, $content, $is_quote_share) use ($simple_html) {
+ return self::convertShareCallback($attributes, $author_contact, $content, $is_quote_share, $simple_html);
+ }
+ );
$text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism", '<br/><img src="' .System::baseUrl() . '/images/lock_icon.gif" alt="' . L10n::t('Encrypted content') . '" title="' . L10n::t('Encrypted content') . '" /><br />', $text);
$text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism", '<br/><img src="' .System::baseUrl() . '/images/lock_icon.gif" alt="' . L10n::t('Encrypted content') . '" title="' . '$1' . ' ' . L10n::t('Encrypted content') . '" /><br />', $text);
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
+use Friendica\Model\Item;
+use Friendica\Util\Security;
require_once 'include/dba.php';
-require_once 'include/security.php';
/**
* TagCloud widget
*/
private static function tagadelic($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HASHTAG)
{
- $sql_options = item_permissions_sql($uid);
+ $sql_options = Item::getPermissionsSQLByUserId($uid);
$limit = $count ? sprintf('LIMIT %d', intval($count)) : '';
if ($flags) {
use Friendica\BaseObject;
use Friendica\Database\DBA;
-require_once 'include/dba.php';
-
/**
* Some functions to handle addons
*/
class Addon extends BaseObject
{
/**
- * @brief Synchronise addons:
+ * List of the names of enabled addons
+ *
+ * @var array
+ */
+ private static $addons = [];
+
+ /**
+ * @brief Synchronize addons:
*
* system.addon contains a comma-separated list of names
* of addons which are used on this system.
* call the install procedure and add it to the database.
*
*/
- public static function check()
+ public static function loadAddons()
{
- $a = self::getApp();
+ $installed_addons = [];
$r = DBA::select('addon', [], ['installed' => 1]);
if (DBA::isResult($r)) {
- $installed = DBA::toArray($r);
- } else {
- $installed = [];
+ $installed_addons = DBA::toArray($r);
}
$addons = Config::get('system', 'addon');
$addons_arr = explode(',', str_replace(' ', '', $addons));
}
- $a->addons = $addons_arr;
+ self::$addons = $addons_arr;
$installed_arr = [];
- if (count($installed)) {
- foreach ($installed as $i) {
- if (!in_array($i['name'], $addons_arr)) {
- self::uninstall($i['name']);
- } else {
- $installed_arr[] = $i['name'];
- }
+ foreach ($installed_addons as $addon) {
+ if (!self::isEnabled($addon['name'])) {
+ self::uninstall($addon['name']);
+ } else {
+ $installed_arr[] = $addon['name'];
}
}
- if (count($addons_arr)) {
- foreach ($addons_arr as $p) {
- if (!in_array($p, $installed_arr)) {
- self::install($p);
- }
+ foreach (self::$addons as $p) {
+ if (!in_array($p, $installed_arr)) {
+ self::install($p);
}
}
-
- self::loadHooks();
-
- return;
}
/**
$func = $addon . '_uninstall';
$func();
}
+
+ unset(self::$addons[$idx]);
}
/**
$func = $addon . '_install';
$func();
- $addon_admin = (function_exists($addon."_addon_admin") ? 1 : 0);
+ $addon_admin = (function_exists($addon . "_addon_admin") ? 1 : 0);
DBA::insert('addon', ['name' => $addon, 'installed' => true,
- 'timestamp' => $t, 'plugin_admin' => $addon_admin]);
+ 'timestamp' => $t, 'plugin_admin' => $addon_admin]);
// we can add the following with the previous SQL
// once most site tables have been updated.
if (file_exists('addon/' . $addon . '/.hidden')) {
DBA::update('addon', ['hidden' => true], ['name' => $addon]);
}
+
+ if (!self::isEnabled($addon)) {
+ self::$addons[] = $addon;
+ }
return true;
} else {
logger("Addons: FAILED installing " . $addon);
}
}
- /**
- * @brief check if addon is enabled
- *
- * @param string $addon
- * @return boolean
- */
- public static function isEnabled($addon)
- {
- return DBA::exists('addon', ['installed' => true, 'name' => $addon]);
- }
-
-
- /**
- * @brief registers a hook.
- *
- * @param string $hook the name of the hook
- * @param string $file the name of the file that hooks into
- * @param string $function the name of the function that the hook will call
- * @param int $priority A priority (defaults to 0)
- * @return mixed|bool
- */
- public static function registerHook($hook, $file, $function, $priority = 0)
- {
- $file = str_replace(self::getApp()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
-
- $condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
- $exists = DBA::exists('hook', $condition);
- if ($exists) {
- return true;
- }
-
- $r = DBA::insert('hook', ['hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority]);
-
- return $r;
- }
-
- /**
- * @brief unregisters a hook.
- *
- * @param string $hook the name of the hook
- * @param string $file the name of the file that hooks into
- * @param string $function the name of the function that the hook called
- * @return array
- */
- public static function unregisterHook($hook, $file, $function)
- {
- $relative_file = str_replace(self::getApp()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
-
- // This here is only needed for fixing a problem that existed on the develop branch
- $condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
- DBA::delete('hook', $condition);
-
- $condition = ['hook' => $hook, 'file' => $relative_file, 'function' => $function];
- $r = DBA::delete('hook', $condition);
- return $r;
- }
-
- /**
- * Load hooks
- */
- public static function loadHooks()
- {
- $a = self::getApp();
- $a->hooks = [];
- $r = DBA::select('hook', ['hook', 'file', 'function'], [], ['order' => ['priority' => 'desc', 'file']]);
-
- while ($rr = DBA::fetch($r)) {
- if (! array_key_exists($rr['hook'], $a->hooks)) {
- $a->hooks[$rr['hook']] = [];
- }
- $a->hooks[$rr['hook']][] = [$rr['file'],$rr['function']];
- }
- DBA::close($r);
- }
-
- /**
- * @brief Forks a hook.
- *
- * Use this function when you want to fork a hook via the worker.
- *
- * @param string $name of the hook to call
- * @param string|array $data to transmit to the callback handler
- */
- public static function forkHooks($priority, $name, $data = null)
- {
- $a = self::getApp();
-
- if (is_array($a->hooks) && array_key_exists($name, $a->hooks)) {
- foreach ($a->hooks[$name] as $hook) {
- Worker::add($priority, 'ForkHook', $name, $hook, $data);
- }
- }
- }
-
- /**
- * @brief Calls a hook.
- *
- * Use this function when you want to be able to allow a hook to manipulate
- * the provided data.
- *
- * @param string $name of the hook to call
- * @param string|array &$data to transmit to the callback handler
- */
- public static function callHooks($name, &$data = null)
- {
- $a = self::getApp();
-
- if (is_array($a->hooks) && array_key_exists($name, $a->hooks)) {
- foreach ($a->hooks[$name] as $hook) {
- self::callSingleHook($a, $name, $hook, $data);
- }
- }
- }
-
- /**
- * @brief Calls a single hook.
- *
- * @param App $a
- * @param string $name of the hook to call
- * @param array $hook Hook data
- * @param string|array &$data to transmit to the callback handler
- */
- public static function callSingleHook(App $a, $name, $hook, &$data = null)
- {
- // Don't run a theme's hook if the user isn't using the theme
- if (strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/' . $a->getCurrentTheme()) === false) {
- return;
- }
-
- @include_once($hook[0]);
- if (function_exists($hook[1])) {
- $func = $hook[1];
- $func($a, $data);
- } else {
- // remove orphan hooks
- $condition = ['hook' => $name, 'file' => $hook[0], 'function' => $hook[1]];
- DBA::delete('hook', $condition, ['cascade' => false]);
- }
- }
-
- /**
- * check if an app_menu hook exist for addon $name.
- * Return true if the addon is an app
- */
- public static function isApp($name)
- {
- $a = self::getApp();
-
- if (is_array($a->hooks) && (array_key_exists('app_menu', $a->hooks))) {
- foreach ($a->hooks['app_menu'] as $hook) {
- if ($hook[0] == 'addon/'.$name.'/'.$name.'.php') {
- return true;
- }
- }
- }
-
- return false;
- }
-
/**
* @brief Parse addon comment in search of addon infos.
*
}
return $info;
}
+
+ /**
+ * Checks if the provided addon is enabled
+ *
+ * @param string $addon
+ * @return boolean
+ */
+ public static function isEnabled($addon)
+ {
+ return in_array($addon, self::$addons);
+ }
+
+ /**
+ * Returns a list of the enabled addon names
+ *
+ * @return array
+ */
+ public static function getEnabledList()
+ {
+ return self::$addons;
+ }
+
+ /**
+ * Saves the current enabled addon list in the system.addon config key
+ *
+ * @return boolean
+ */
+ public static function saveEnabledList()
+ {
+ return Config::set("system", "addon", implode(", ", self::$addons));
+ }
+
+ /**
+ * Returns the list of non-hidden enabled addon names
+ *
+ * @return array
+ */
+ public static function getVisibleList()
+ {
+ $visible_addons = [];
+ $stmt = DBA::select('addon', ['name'], ['hidden' => false, 'installed' => true]);
+ if (DBA::isResult($stmt)) {
+ foreach (DBA::toArray($stmt) as $addon) {
+ $visible_addons[] = $addon['name'];
+ }
+ }
+
+ return $visible_addons;
+ }
+
+ /**
+ * Shim of Hook::register left for backward compatibility purpose.
+ *
+ * @see Hook::register
+ * @deprecated since version 2018.12
+ * @param string $hook the name of the hook
+ * @param string $file the name of the file that hooks into
+ * @param string $function the name of the function that the hook will call
+ * @param int $priority A priority (defaults to 0)
+ * @return mixed|bool
+ */
+ public static function registerHook($hook, $file, $function, $priority = 0)
+ {
+ return Hook::register($hook, $file, $function, $priority);
+ }
+
+ /**
+ * Shim of Hook::unregister left for backward compatibility purpose.
+ *
+ * @see Hook::unregister
+ * @deprecated since version 2018.12
+ * @param string $hook the name of the hook
+ * @param string $file the name of the file that hooks into
+ * @param string $function the name of the function that the hook called
+ * @return boolean
+ */
+ public static function unregisterHook($hook, $file, $function)
+ {
+ return Hook::unregister($hook, $file, $function);
+ }
+
+ /**
+ * Shim of Hook::callAll left for backward-compatibility purpose.
+ *
+ * @see Hook::callAll
+ * @deprecated since version 2018.12
+ * @param string $name of the hook to call
+ * @param string|array &$data to transmit to the callback handler
+ */
+ public static function callHooks($name, &$data = null)
+ {
+ Hook::callAll($name, $data);
+ }
}
--- /dev/null
+<?php
+/**
+ * @file /src/Core/Authentication.php
+ */
+
+namespace Friendica\Core;
+
+use Friendica\BaseObject;
+use Friendica\Core\Addon;
+use Friendica\Core\Config;
+use Friendica\Core\L10n;
+use Friendica\Core\PConfig;
+use Friendica\Database\DBA;
+use Friendica\Util\DateTimeFormat;
+
+/**
+* Handle Authentification, Session and Cookies
+*/
+class Authentication extends BaseObject
+{
+ /**
+ * @brief Calculate the hash that is needed for the "Friendica" cookie
+ *
+ * @param array $user Record from "user" table
+ *
+ * @return string Hashed data
+ */
+ public static function getCookieHashForUser($user)
+ {
+ return(hash("sha256", Config::get("system", "site_prvkey") .
+ $user["prvkey"] .
+ $user["password"]));
+ }
+
+ /**
+ * @brief Set the "Friendica" cookie
+ *
+ * @param int $time
+ * @param array $user Record from "user" table
+ */
+ public static function setCookie($time, $user = [])
+ {
+ if ($time != 0) {
+ $time = $time + time();
+ }
+
+ if ($user) {
+ $value = json_encode(["uid" => $user["uid"],
+ "hash" => self::getCookieHashForUser($user),
+ "ip" => defaults($_SERVER, 'REMOTE_ADDR', '0.0.0.0')]);
+ } else {
+ $value = "";
+ }
+
+ setcookie("Friendica", $value, $time, "/", "", (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL), true);
+ }
+
+ /**
+ * @brief Sets the provided user's authenticated session
+ *
+ * @todo Should be moved to Friendica\Core\Session once it's created
+ *
+ * @param type $user_record
+ * @param type $login_initial
+ * @param type $interactive
+ * @param type $login_refresh
+ */
+ public static function setAuthenticatedSessionForUser($user_record, $login_initial = false, $interactive = false, $login_refresh = false)
+ {
+ $a = self::getApp();
+
+ $_SESSION['uid'] = $user_record['uid'];
+ $_SESSION['theme'] = $user_record['theme'];
+ $_SESSION['mobile-theme'] = PConfig::get($user_record['uid'], 'system', 'mobile_theme');
+ $_SESSION['authenticated'] = 1;
+ $_SESSION['page_flags'] = $user_record['page-flags'];
+ $_SESSION['my_url'] = $a->getbaseUrl() . '/profile/' . $user_record['nickname'];
+ $_SESSION['my_address'] = $user_record['nickname'] . '@' . substr($a->getbaseUrl(), strpos($a->getbaseUrl(), '://') + 3);
+ $_SESSION['addr'] = defaults($_SERVER, 'REMOTE_ADDR', '0.0.0.0');
+
+ $a->user = $user_record;
+
+ if ($interactive) {
+ if ($a->user['login_date'] <= DBA::NULL_DATETIME) {
+ $_SESSION['return_path'] = 'profile_photo/new';
+ $a->module = 'profile_photo';
+ info(L10n::t("Welcome ") . $a->user['username'] . EOL);
+ info(L10n::t('Please upload a profile photo.') . EOL);
+ } else {
+ info(L10n::t("Welcome back ") . $a->user['username'] . EOL);
+ }
+ }
+
+ $member_since = strtotime($a->user['register_date']);
+ if (time() < ($member_since + ( 60 * 60 * 24 * 14))) {
+ $_SESSION['new_member'] = true;
+ } else {
+ $_SESSION['new_member'] = false;
+ }
+ if (strlen($a->user['timezone'])) {
+ date_default_timezone_set($a->user['timezone']);
+ $a->timezone = $a->user['timezone'];
+ }
+
+ $master_record = $a->user;
+
+ if ((x($_SESSION, 'submanage')) && intval($_SESSION['submanage'])) {
+ $user = DBA::selectFirst('user', [], ['uid' => $_SESSION['submanage']]);
+ if (DBA::isResult($user)) {
+ $master_record = $user;
+ }
+ }
+
+ if ($master_record['parent-uid'] == 0) {
+ // First add our own entry
+ $a->identities = [['uid' => $master_record['uid'],
+ 'username' => $master_record['username'],
+ 'nickname' => $master_record['nickname']]];
+
+ // Then add all the children
+ $r = DBA::select('user', ['uid', 'username', 'nickname'],
+ ['parent-uid' => $master_record['uid'], 'account_removed' => false]);
+ if (DBA::isResult($r)) {
+ $a->identities = array_merge($a->identities, DBA::toArray($r));
+ }
+ } else {
+ // Just ensure that the array is always defined
+ $a->identities = [];
+
+ // First entry is our parent
+ $r = DBA::select('user', ['uid', 'username', 'nickname'],
+ ['uid' => $master_record['parent-uid'], 'account_removed' => false]);
+ if (DBA::isResult($r)) {
+ $a->identities = DBA::toArray($r);
+ }
+
+ // Then add all siblings
+ $r = DBA::select('user', ['uid', 'username', 'nickname'],
+ ['parent-uid' => $master_record['parent-uid'], 'account_removed' => false]);
+ if (DBA::isResult($r)) {
+ $a->identities = array_merge($a->identities, DBA::toArray($r));
+ }
+ }
+
+ $r = DBA::p("SELECT `user`.`uid`, `user`.`username`, `user`.`nickname`
+ FROM `manage`
+ INNER JOIN `user` ON `manage`.`mid` = `user`.`uid`
+ WHERE `user`.`account_removed` = 0 AND `manage`.`uid` = ?",
+ $master_record['uid']
+ );
+ if (DBA::isResult($r)) {
+ $a->identities = array_merge($a->identities, DBA::toArray($r));
+ }
+
+ if ($login_initial) {
+ logger('auth_identities: ' . print_r($a->identities, true), LOGGER_DEBUG);
+ }
+ if ($login_refresh) {
+ logger('auth_identities refresh: ' . print_r($a->identities, true), LOGGER_DEBUG);
+ }
+
+ $contact = DBA::selectFirst('contact', [], ['uid' => $_SESSION['uid'], 'self' => true]);
+ if (DBA::isResult($contact)) {
+ $a->contact = $contact;
+ $a->cid = $contact['id'];
+ $_SESSION['cid'] = $a->cid;
+ }
+
+ header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] . '"');
+
+ if ($login_initial || $login_refresh) {
+ DBA::update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $_SESSION['uid']]);
+
+ // Set the login date for all identities of the user
+ DBA::update('user', ['login_date' => DateTimeFormat::utcNow()],
+ ['parent-uid' => $master_record['uid'], 'account_removed' => false]);
+ }
+
+ if ($login_initial) {
+ /*
+ * If the user specified to remember the authentication, then set a cookie
+ * that expires after one week (the default is when the browser is closed).
+ * The cookie will be renewed automatically.
+ * The week ensures that sessions will expire after some inactivity.
+ */
+ if (!empty($_SESSION['remember'])) {
+ logger('Injecting cookie for remembered user ' . $a->user['nickname']);
+ self::setCookie(604800, $user_record);
+ unset($_SESSION['remember']);
+ }
+ }
+
+ if ($login_initial) {
+ Addon::callHooks('logged_in', $a->user);
+
+ if (($a->module !== 'home') && isset($_SESSION['return_path'])) {
+ $a->internalRedirect($_SESSION['return_path']);
+ }
+ }
+ }
+
+ /**
+ * @brief Kills the "Friendica" cookie and all session data
+ */
+ public static function deleteSession()
+ {
+ self::setCookie(-3600); // make sure cookie is deleted on browser close, as a security measure
+ session_unset();
+ session_destroy();
+ }
+}
+
throw new \RuntimeException('Database isn\'t ready or populated yet');
}
- Core\Config::load();
-
- $lang = Core\L10n::getBrowserLanguage();
- Core\L10n::loadTranslationTable($lang);
-
$enabled = intval($this->getArgument(0));
Core\Config::set('system', 'maintenance', $enabled);
--- /dev/null
+<?php
+/**
+ * @file src/Core/Hook.php
+ */
+namespace Friendica\Core;
+
+use Friendica\App;
+use Friendica\BaseObject;
+use Friendica\Database\DBA;
+
+/**
+ * Some functions to handle hooks
+ */
+class Hook extends BaseObject
+{
+ /**
+ * Array of registered hooks
+ *
+ * Format:
+ * [
+ * ["<hook name>"] => [
+ * 0 => "<hook file>",
+ * 1 => "<hook function name>"
+ * ],
+ * ...
+ * ]
+ *
+ * @var array
+ */
+ private static $hooks = [];
+
+ /**
+ * Load hooks
+ */
+ public static function loadHooks()
+ {
+ self::$hooks = [];
+ $stmt = DBA::select('hook', ['hook', 'file', 'function'], [], ['order' => ['priority' => 'desc', 'file']]);
+
+ while ($hook = DBA::fetch($stmt)) {
+ if (!array_key_exists($hook['hook'], self::$hooks)) {
+ self::$hooks[$hook['hook']] = [];
+ }
+ self::$hooks[$hook['hook']][] = [$hook['file'], $hook['function']];
+ }
+ DBA::close($stmt);
+ }
+
+ /**
+ * Registers a hook.
+ *
+ * @param string $hook the name of the hook
+ * @param string $file the name of the file that hooks into
+ * @param string $function the name of the function that the hook will call
+ * @param int $priority A priority (defaults to 0)
+ * @return mixed|bool
+ */
+ public static function register($hook, $file, $function, $priority = 0)
+ {
+ $file = str_replace(self::getApp()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
+
+ $condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
+ if (DBA::exists('hook', $condition)) {
+ return true;
+ }
+
+ $result = DBA::insert('hook', ['hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority]);
+
+ return $result;
+ }
+
+ /**
+ * Unregisters a hook.
+ *
+ * @param string $hook the name of the hook
+ * @param string $file the name of the file that hooks into
+ * @param string $function the name of the function that the hook called
+ * @return boolean
+ */
+ public static function unregister($hook, $file, $function)
+ {
+ $relative_file = str_replace(self::getApp()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
+
+ // This here is only needed for fixing a problem that existed on the develop branch
+ $condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
+ DBA::delete('hook', $condition);
+
+ $condition = ['hook' => $hook, 'file' => $relative_file, 'function' => $function];
+ $result = DBA::delete('hook', $condition);
+ return $result;
+ }
+
+ /**
+ * Returns the list of callbacks for a single hook
+ *
+ * @param string $name Name of the hook
+ * @return array
+ */
+ public static function getByName($name)
+ {
+ $return = [];
+
+ if (isset(self::$hooks[$name])) {
+ $return = self::$hooks[$name];
+ }
+
+ return $return;
+ }
+
+ /**
+ * @brief Forks a hook.
+ *
+ * Use this function when you want to fork a hook via the worker.
+ *
+ * @param integer $priority of the hook
+ * @param string $name of the hook to call
+ * @param mixed $data to transmit to the callback handler
+ */
+ public static function fork($priority, $name, $data = null)
+ {
+ if (array_key_exists($name, self::$hooks)) {
+ foreach (self::$hooks[$name] as $hook) {
+ Worker::add($priority, 'ForkHook', $name, $hook, $data);
+ }
+ }
+ }
+
+ /**
+ * @brief Calls a hook.
+ *
+ * Use this function when you want to be able to allow a hook to manipulate
+ * the provided data.
+ *
+ * @param string $name of the hook to call
+ * @param string|array &$data to transmit to the callback handler
+ */
+ public static function callAll($name, &$data = null)
+ {
+ if (array_key_exists($name, self::$hooks)) {
+ foreach (self::$hooks[$name] as $hook) {
+ self::callSingle(self::getApp(), $name, $hook, $data);
+ }
+ }
+ }
+
+ /**
+ * @brief Calls a single hook.
+ *
+ * @param App $a
+ * @param string $name of the hook to call
+ * @param array $hook Hook data
+ * @param string|array &$data to transmit to the callback handler
+ */
+ public static function callSingle(App $a, $name, $hook, &$data = null)
+ {
+ // Don't run a theme's hook if the user isn't using the theme
+ if (strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/' . $a->getCurrentTheme()) === false) {
+ return;
+ }
+
+ @include_once($hook[0]);
+ if (function_exists($hook[1])) {
+ $func = $hook[1];
+ $func($a, $data);
+ } else {
+ // remove orphan hooks
+ $condition = ['hook' => $name, 'file' => $hook[0], 'function' => $hook[1]];
+ DBA::delete('hook', $condition, ['cascade' => false]);
+ }
+ }
+
+ /**
+ * Checks if an app_menu hook exist for the provided addon name.
+ * Return true if the addon is an app
+ *
+ * @param string $name Name of the addon
+ * @return boolean
+ */
+ public static function isAddonApp($name)
+ {
+ if (array_key_exists('app_menu', self::$hooks)) {
+ foreach (self::$hooks['app_menu'] as $hook) {
+ if ($hook[0] == 'addon/' . $name . '/' . $name . '.php') {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+}
* - Creates `config/local.ini.php`
* - Installs Database Structure
*
+ * @param string $phppath Path to the PHP-Binary (optional, if not set e.g. 'php' or '/usr/bin/php')
* @param string $urlpath Path based on the URL of Friendica (e.g. '/friendica')
* @param string $dbhost Hostname/IP of the Friendica Database
* @param string $dbuser Username of the Database connection credentials
* @param string $language 2-letter ISO 639-1 code (eg. 'en')
* @param string $adminmail Mail-Adress of the administrator
* @param string $basepath The basepath of Friendica
- * @param string $phpath Path to the PHP-Binary (optional, if not set e.g. 'php' or '/usr/bin/php')
*
* @return bool|string true if the config was created, the text if something went wrong
*/
require_once 'include/dba.php';
/**
- * Provide Languange, Translation, and Localisation functions to the application
- * Localisation can be referred to by the numeronym L10N (as in: "L", followed by ten more letters, and then "N").
+ * Provide Language, Translation, and Localization functions to the application
+ * Localization can be referred to by the numeronym L10N (as in: "L", followed by ten more letters, and then "N").
*/
class L10n extends BaseObject
{
/**
- * @brief get the prefered language from the HTTP_ACCEPT_LANGUAGE header
+ * A string indicating the current language used for translation:
+ * - Two-letter ISO 639-1 code.
+ * - Two-letter ISO 639-1 code + dash + Two-letter ISO 3166-1 alpha-2 country code.
+ * @var string
*/
- public static function getBrowserLanguage()
+ private static $lang = '';
+ /**
+ * A language code saved for later after pushLang() has been called.
+ *
+ * @var string
+ */
+ private static $langSave = '';
+
+ /**
+ * An array of translation strings whose key is the neutral english message.
+ *
+ * @var array
+ */
+ private static $strings = [];
+ /**
+ * An array of translation strings saved for later after pushLang() has been called.
+ *
+ * @var array
+ */
+ private static $stringsSave = [];
+
+ /**
+ * Detects the language and sets the translation table
+ */
+ public static function init()
+ {
+ $lang = self::detectLanguage();
+ self::loadTranslationTable($lang);
+ }
+
+ /**
+ * Returns the current language code
+ *
+ * @return string Language code
+ */
+ public static function getCurrentLang()
+ {
+ return self::$lang;
+ }
+
+ /**
+ * Sets the language session variable
+ */
+ public static function setSessionVariable()
+ {
+ if (!empty($_SESSION['authenticated']) && empty($_SESSION['language'])) {
+ $_SESSION['language'] = self::$lang;
+ // we haven't loaded user data yet, but we need user language
+ if (!empty($_SESSION['uid'])) {
+ $user = DBA::selectFirst('user', ['language'], ['uid' => $_SESSION['uid']]);
+ if (DBA::isResult($user)) {
+ $_SESSION['language'] = $user['language'];
+ }
+ }
+ }
+ }
+
+ public static function setLangFromSession()
+ {
+ if (!empty($_SESSION['language']) && $_SESSION['language'] !== self::$lang) {
+ self::loadTranslationTable($_SESSION['language']);
+ }
+ }
+
+ /**
+ * @brief Returns the preferred language from the HTTP_ACCEPT_LANGUAGE header
+ * @return string The two-letter language code
+ */
+ public static function detectLanguage()
{
$lang_list = [];
- if (x($_SERVER, 'HTTP_ACCEPT_LANGUAGE')) {
+ if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
// break up string into pieces (languages and q factors)
preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse);
}
/**
- * @param string $language language
+ * This function should be called before formatting messages in a specific target language
+ * different from the current user/system language.
+ *
+ * It saves the current translation strings in a separate variable and loads new translations strings.
+ *
+ * If called repeatedly, it won't save the translation strings again, just load the new ones.
+ *
+ * @see popLang()
+ * @brief Stores the current language strings and load a different language.
+ * @param string $lang Language code
*/
- public static function pushLang($language)
+ public static function pushLang($lang)
{
- $a = self::getApp();
-
- $a->langsave = Config::get('system', 'language');
+ if (!self::$lang) {
+ self::init();
+ }
- if ($language === $a->langsave) {
+ if ($lang === self::$lang) {
return;
}
- if (isset($a->strings) && count($a->strings)) {
- $a->stringsave = $a->strings;
+ if (!self::$langSave) {
+ self::$langSave = self::$lang;
+ self::$stringsSave = self::$strings;
}
- $a->strings = [];
- self::loadTranslationTable($language);
- Config::set('system', 'language', $language);
+
+ self::loadTranslationTable($lang);
}
/**
- * Pop language off the top of the stack
+ * Restores the original user/system language after having used pushLang()
*/
public static function popLang()
{
- $a = self::getApp();
-
- if (Config::get('system', 'language') === $a->langsave) {
+ if (!self::$langSave) {
return;
}
- if (isset($a->stringsave)) {
- $a->strings = $a->stringsave;
- } else {
- $a->strings = [];
- }
+ self::$strings = self::$stringsSave;
+ self::$lang = self::$langSave;
- Config::set('system', 'language', $a->langsave);
+ self::$stringsSave = [];
+ self::$langSave = '';
}
/**
- * load string translation table for alternate language
+ * Loads string translation table
+ *
+ * First addon strings are loaded, then globals
*
- * first addon strings are loaded, then globals
+ * Uses an App object shim since all the strings files refer to $a->strings
*
* @param string $lang language code to load
*/
- public static function loadTranslationTable($lang)
+ private static function loadTranslationTable($lang)
{
- $a = self::getApp();
+ if ($lang === self::$lang) {
+ return;
+ }
+ $a = new \stdClass();
$a->strings = [];
+
// load enabled addons strings
$addons = DBA::select('addon', ['name'], ['installed' => true]);
while ($p = DBA::fetch($addons)) {
if (file_exists("view/lang/$lang/strings.php")) {
include "view/lang/$lang/strings.php";
}
+
+ self::$lang = $lang;
+ self::$strings = $a->strings;
+
+ unset($a);
}
/**
*/
public static function t($s, ...$vars)
{
- $a = self::getApp();
-
if (empty($s)) {
return '';
}
- if (x($a->strings, $s)) {
- $t = $a->strings[$s];
+ if (!self::$lang) {
+ self::init();
+ }
+
+ if (!empty(self::$strings[$s])) {
+ $t = self::$strings[$s];
$s = is_array($t) ? $t[0] : $t;
}
*/
public static function tt($singular, $plural, $count)
{
- $a = self::getApp();
-
if (!is_numeric($count)) {
logger('Non numeric count called by ' . System::callstack(20));
}
- $lang = Config::get('system', 'language');
+ if (!self::$lang) {
+ self::init();
+ }
- if (!empty($a->strings[$singular])) {
- $t = $a->strings[$singular];
+ if (!empty(self::$strings[$singular])) {
+ $t = self::$strings[$singular];
if (is_array($t)) {
- $plural_function = 'string_plural_select_' . str_replace('-', '_', $lang);
+ $plural_function = 'string_plural_select_' . str_replace('-', '_', self::$lang);
if (function_exists($plural_function)) {
$i = $plural_function($count);
} else {
return $n != 1;
}
-
-
/**
* @brief Return installed languages codes as associative array
*
'madeby_zrl' => Contact::magicLink($it['url']),
'madeby_addr' => $it['addr'],
'contact_id' => $it['contact-id'],
- 'photo' => ((x($it, 'fphoto')) ? ProxyUtils::proxifyUrl($it['fphoto'], false, ProxyUtils::SIZE_SMALL) : "images/person-175.jpg"),
+ 'photo' => ((x($it, 'fphoto')) ? ProxyUtils::proxifyUrl($it['fphoto'], false, ProxyUtils::SIZE_SMALL) : "images/person-300.jpg"),
'name' => $it['fname'],
'url' => $it['furl'],
'zrl' => Contact::magicLink($it['furl']),
'uid' => $_SESSION['uid'],
'intro_id' => $it['intro_id'],
'contact_id' => $it['contact-id'],
- 'photo' => ((x($it, 'photo')) ? ProxyUtils::proxifyUrl($it['photo'], false, ProxyUtils::SIZE_SMALL) : "images/person-175.jpg"),
+ 'photo' => ((x($it, 'photo')) ? ProxyUtils::proxifyUrl($it['photo'], false, ProxyUtils::SIZE_SMALL) : "images/person-300.jpg"),
'name' => $it['name'],
'location' => BBCode::convert($it['glocation'], false),
'about' => BBCode::convert($it['gabout'], false),
}
}
+ // Mastodon, Pleroma
+ if (preg_match('=https?://(.+?)/users/(.+)=ism', $profile_url, $matches)
+ || preg_match('=https?://(.+?)/@(.+)=ism', $profile_url, $matches)
+ ) {
+ return self::ACTIVITYPUB;
+ }
+
// pumpio (http://host.name/user)
if (preg_match('=https?://([\.\w]+)/([\.\w]+)$=ism', $profile_url, $matches)) {
return self::PUMPIO;
namespace Friendica\Core;
use Friendica\BaseObject;
+use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Util\XML;
/**
'$description' => defaults($description, 'description', '')]);
}
- killme();
+ exit();
}
/**
return max($load_arr[0], $load_arr[1]);
}
+ /**
+ * Redirects to an external URL (fully qualified URL)
+ * If you want to route relative to the current Friendica base, use App->internalRedirect()
+ *
+ * @param string $url The new Location to redirect
+ * @throws InternalServerErrorException If the URL is not fully qualified
+ */
+ public static function externalRedirect($url)
+ {
+ if (!filter_var($url, FILTER_VALIDATE_URL)) {
+ throw new InternalServerErrorException("'$url' is not a fully qualified URL, please use App->internalRedirect() instead");
+ }
+
+ header("Location: $url");
+ exit();
+ }
+
/// @todo Move the following functions from boot.php
/*
function killme()
- function goaway($s)
function local_user()
function public_contact()
function remote_user()
}
if ($contact['uid'] == $olduid && $contact['self'] == '0') {
// set contacts 'avatar-date' to NULL_DATE to let worker to update urls
- $contact["avatar-date"] = NULL_DATE;
+ $contact["avatar-date"] = DBA::NULL_DATETIME;
switch ($contact['network']) {
case Protocol::DFRN:
Worker::add(PRIORITY_HIGH, 'Notifier', 'relocate', $newuid);
info(L10n::t("Done. You can now login with your username and password"));
- goaway(System::baseUrl() . "/login");
+ $a->internalRedirect('login');
}
}
*/
namespace Friendica\Core;
+use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\Model\Process;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
-use Friendica\BaseObject;
require_once 'include/dba.php';
logger("Couldn't select a workerqueue entry, quitting process " . getmypid() . ".", LOGGER_DEBUG);
}
+ /**
+ * @brief Returns the number of deferred entries in the worker queue
+ *
+ * @return integer Number of deferred entries in the worker queue
+ */
+ private static function deferredEntries()
+ {
+ return DBA::count('workerqueue', ["`executed` <= ? AND NOT `done` AND `next_try` > ?",
+ DBA::NULL_DATETIME, DateTimeFormat::utcNow()]);
+ }
+
/**
* @brief Returns the number of non executed entries in the worker queue
*
private static function totalEntries()
{
return DBA::count('workerqueue', ["`executed` <= ? AND NOT `done` AND `next_try` < ?",
- NULL_DATE, DateTimeFormat::utcNow()]);
+ DBA::NULL_DATETIME, DateTimeFormat::utcNow()]);
}
/**
*/
private static function highestPriority()
{
- $condition = ["`executed` <= ? AND NOT `done` AND `next_try` < ?", NULL_DATE, DateTimeFormat::utcNow()];
+ $condition = ["`executed` <= ? AND NOT `done` AND `next_try` < ?", DBA::NULL_DATETIME, DateTimeFormat::utcNow()];
$workerqueue = DBA::selectFirst('workerqueue', ['priority'], $condition, ['order' => ['priority']]);
if (DBA::isResult($workerqueue)) {
return $workerqueue["priority"];
private static function processWithPriorityActive($priority)
{
$condition = ["`priority` <= ? AND `executed` > ? AND NOT `done` AND `next_try` < ?",
- $priority, NULL_DATE, DateTimeFormat::utcNow()];
+ $priority, DBA::NULL_DATETIME, DateTimeFormat::utcNow()];
return DBA::exists('workerqueue', $condition);
}
self::execFunction($queue, $include, $argv, true);
$stamp = (float)microtime(true);
- if (DBA::update('workerqueue', ['done' => true], ['id' => $queue['id']])) {
+
+ $condition = ["`id` = ? AND `next_try` < ?", $queue['id'], DateTimeFormat::utcNow()];
+ if (DBA::update('workerqueue', ['done' => true], $condition)) {
Config::set('system', 'last_worker_execution', DateTimeFormat::utcNow());
}
self::$db_duration = (microtime(true) - $stamp);
$entries = DBA::select(
'workerqueue',
['id', 'pid', 'executed', 'priority', 'parameter'],
- ['`executed` > ? AND NOT `done` AND `pid` != 0', NULL_DATE],
+ ['`executed` > ? AND NOT `done` AND `pid` != 0', DBA::NULL_DATETIME],
['order' => ['priority', 'created']]
);
if (!posix_kill($entry["pid"], 0)) {
DBA::update(
'workerqueue',
- ['executed' => NULL_DATE, 'pid' => 0],
+ ['executed' => DBA::NULL_DATETIME, 'pid' => 0],
['id' => $entry["id"]]
);
} else {
}
DBA::update(
'workerqueue',
- ['executed' => NULL_DATE, 'created' => DateTimeFormat::utcNow(), 'priority' => $new_priority, 'pid' => 0],
+ ['executed' => DBA::NULL_DATETIME, 'created' => DateTimeFormat::utcNow(), 'priority' => $new_priority, 'pid' => 0],
['id' => $entry["id"]]
);
} else {
}
$entries = self::totalEntries();
+ $deferred = self::deferredEntries();
if (Config::get("system", "worker_fastlane", false) && ($queues > 0) && ($entries > 0) && ($active >= $queues)) {
$top_priority = self::highestPriority();
}
}
- logger("Load: ".$load."/".$maxsysload." - processes: ".$active."/".$entries.$processlist." - maximum: ".$queues."/".$maxqueues, LOGGER_DEBUG);
+ logger("Load: " . $load ."/" . $maxsysload . " - processes: " . $deferred . "/" . $active . "/" . $entries . $processlist . " - maximum: " . $queues . "/" . $maxqueues, LOGGER_DEBUG);
// Are there fewer workers running as possible? Then fork a new one.
if (!Config::get("system", "worker_dont_fork", false) && ($queues > ($active + 1)) && ($entries > 1)) {
$queue_length = Config::get('system', 'worker_fetch_limit', 1);
$lower_job_limit = $worker_queues * $queue_length * 2;
$jobs = self::totalEntries();
+ $deferred = self::deferredEntries();
// Now do some magic
$exponent = 2;
$slope = $queue_length / pow($lower_job_limit, $exponent);
$limit = min($queue_length, ceil($slope * pow($jobs, $exponent)));
- logger('Total: '.$jobs.' - Maximum: '.$queue_length.' - jobs per queue: '.$limit, LOGGER_DEBUG);
+ logger('Deferred: ' . $deferred . ' - Total: ' . $jobs . ' - Maximum: ' . $queue_length . ' - jobs per queue: ' . $limit, LOGGER_DEBUG);
$ids = [];
if (self::passingSlow($highest_priority)) {
// Are there waiting processes with a higher priority than the currently highest?
'workerqueue',
['id'],
["`executed` <= ? AND `priority` < ? AND NOT `done` AND `next_try` < ?",
- NULL_DATE, $highest_priority, DateTimeFormat::utcNow()],
+ DBA::NULL_DATETIME, $highest_priority, DateTimeFormat::utcNow()],
['limit' => $limit, 'order' => ['priority', 'created']]
);
'workerqueue',
['id'],
["`executed` <= ? AND `priority` > ? AND NOT `done` AND `next_try` < ?",
- NULL_DATE, $highest_priority, DateTimeFormat::utcNow()],
+ DBA::NULL_DATETIME, $highest_priority, DateTimeFormat::utcNow()],
['limit' => $limit, 'order' => ['priority', 'created']]
);
'workerqueue',
['id'],
["`executed` <= ? AND NOT `done` AND `next_try` < ?",
- NULL_DATE, DateTimeFormat::utcNow()],
+ DBA::NULL_DATETIME, DateTimeFormat::utcNow()],
['limit' => $limit, 'order' => ['priority', 'created']]
);
{
$mypid = getmypid();
- DBA::update('workerqueue', ['executed' => NULL_DATE, 'pid' => 0], ['pid' => $mypid, 'done' => false]);
+ DBA::update('workerqueue', ['executed' => DBA::NULL_DATETIME, 'pid' => 0], ['pid' => $mypid, 'done' => false]);
}
/**
$id = $queue['id'];
if ($retrial > 14) {
- logger('Id ' . $id . ' had been tried 14 times, it will be deleted now.', LOGGER_DEBUG);
- DBA::delete('workerqueue', ['id' => $id]);
+ logger('Id ' . $id . ' had been tried 14 times. We stop now.', LOGGER_DEBUG);
+ return;
}
// Calculate the delay until the next trial
logger('Defer execution ' . $retrial . ' of id ' . $id . ' to ' . $next, LOGGER_DEBUG);
- $fields = ['retrial' => $retrial + 1, 'next_try' => $next, 'executed' => NULL_DATE, 'pid' => 0];
+ $fields = ['retrial' => $retrial + 1, 'next_try' => $next, 'executed' => DBA::NULL_DATETIME, 'pid' => 0];
DBA::update('workerqueue', $fields, ['id' => $id]);
}
*/
class DBA
{
+ /**
+ * Lowest possible date value
+ */
+ const NULL_DATE = '0001-01-01';
+ /**
+ * Lowest possible datetime value
+ */
+ const NULL_DATETIME = '0001-01-01 00:00:00';
+
public static $connected = false;
private static $server_info = '';
* @param array $param parameter array
* @param bool $on_duplicate_update Do an update on a duplicate entry
*
- * @return boolean was the insert successfull?
+ * @return boolean was the insert successful?
*/
public static function insert($table, $param, $on_duplicate_update = false) {
namespace Friendica\Database;
use Exception;
-use Friendica\Core\Addon;
use Friendica\Core\Config;
+use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Util\DateTimeFormat;
*/
class DBStructure
{
+ /**
+ * Database structure definition loaded from config/dbstructure.php
+ *
+ * @var array
+ */
+ private static $definition = [];
+
/*
* Converts all tables from MyISAM to InnoDB
*/
The friendica developers released update %s recently,
but when I tried to install it, something went terribly wrong.
This needs to be fixed soon and I can't do it alone. Please contact a
- friendica developer if you can not help me on your own. My database might be invalid."));
- $body = L10n::t("The error message is\n[pre]%s[/pre]");
- $preamble = sprintf($preamble, $update_id);
- $body = sprintf($body, $error_message);
+ friendica developer if you can not help me on your own. My database might be invalid.",
+ $update_id));
+ $body = L10n::t("The error message is\n[pre]%s[/pre]", $error_message);
notification([
'uid' => $admin['uid'],
'body' => $body,
'language' => $lang]
);
+ L10n::popLang();
}
//try the logger
}
public static function printStructure() {
- $database = self::definition();
+ $database = self::definition(false);
echo "-- ------------------------------------------\n";
echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
}
/**
- * Loads the database structure definition from the /config/dbstructure.json file
- *
- * Expected format:
- * "table_name": {
- * "comment": "meaningful table comment",
- * "fields": {
- * "field_name1": {"type": "int unsigned", "not null": "1", "extra": "auto_increment", "primary": "1", "comment": "meaningful field comment"},
- * "field_name2": {"type": "varchar(50)", "not null": "1", "default": "", "comment": "meaningful field comment"},
- * },
- * "indexes": {
- * "PRIMARY": ["field_name1"],
- * "name": ["UNIQUE", "field_name2"]
- * }
- * }
+ * Loads the database structure definition from the config/dbstructure.php file.
+ * On first pass, defines DB_UPDATE_VERSION constant.
*
+ * @see config/dbstructure.php
+ * @param boolean $with_addons_structure Whether to tack on addons additional tables
* @return array
* @throws Exception
*/
- public static function definition() {
- $a = \Friendica\BaseObject::getApp();
+ public static function definition($with_addons_structure = true)
+ {
+ if (!self::$definition) {
+ $a = \Friendica\BaseObject::getApp();
- $filename = $a->getBasePath() . '/config/dbstructure.json';
+ $filename = $a->getBasePath() . '/config/dbstructure.php';
- if (!is_readable($filename)) {
- throw new Exception('Missing database structure config file config/dbstructure.json');
- }
+ if (!is_readable($filename)) {
+ throw new Exception('Missing database structure config file config/dbstructure.php');
+ }
- $json = file_get_contents($filename);
+ $definition = require $filename;
- $database = json_decode($json, true);
+ if (!$definition) {
+ throw new Exception('Corrupted database structure config file config/dbstructure.php');
+ }
- if (!$database) {
- throw new Exception('Corrupted database structure config file config/dbstructure.json');
+ self::$definition = $definition;
+ } else {
+ $definition = self::$definition;
}
- Addon::callHooks('dbstructure_definition', $database);
+ if ($with_addons_structure) {
+ Hook::callAll('dbstructure_definition', $definition);
+ }
- return $database;
+ return $definition;
}
}
--- /dev/null
+<?php
+
+namespace Friendica;
+
+/**
+ * This mock module enable class encapsulation of legacy global function modules.
+ * After having provided the module file name, all the methods will behave like a normal Module class.
+ *
+ * @author Hypolite Petovan <mrpetovan@gmail.com>
+ */
+class LegacyModule extends BaseModule
+{
+ /**
+ * The module name, which is the name of the file (without the .php suffix)
+ * It's used to check for existence of the module functions.
+ *
+ * @var string
+ */
+ private static $moduleName = '';
+
+ /**
+ * The only method that needs to be called, with the module/addon file name.
+ *
+ * @param string $file_path
+ */
+ public static function setModuleFile($file_path)
+ {
+ if (!is_readable($file_path)) {
+ throw new Exception(Core\L10n::t('Legacy module file not found: %s', $file_path));
+ }
+
+ self::$moduleName = basename($file_path, '.php');
+
+ require_once $file_path;
+ }
+
+ public static function init()
+ {
+ self::runModuleFunction('init');
+ }
+
+ public static function content()
+ {
+ return self::runModuleFunction('content');
+ }
+
+ public static function post()
+ {
+ self::runModuleFunction('post');
+ }
+
+ public static function afterpost()
+ {
+ self::runModuleFunction('afterpost');
+ }
+
+ /**
+ * Runs the module function designated by the provided suffix if it exists, the BaseModule method otherwise
+ *
+ * @param string $function_suffix
+ * @return string
+ */
+ private static function runModuleFunction($function_suffix)
+ {
+ $function_name = static::$moduleName . '_' . $function_suffix;
+
+ if (\function_exists($function_name)) {
+ return $function_name(self::getApp());
+ } else {
+ return parent::{$function_suffix}();
+ }
+ }
+}
}
$data = ActivityPub::fetchContent($url);
-
- if (empty($data) || empty($data['id']) || empty($data['inbox'])) {
+ if (empty($data)) {
return false;
}
+ $compacted = JsonLD::compact($data);
+
$apcontact = [];
- $apcontact['url'] = $data['id'];
- $apcontact['uuid'] = defaults($data, 'diaspora:guid', null);
- $apcontact['type'] = defaults($data, 'type', null);
- $apcontact['following'] = defaults($data, 'following', null);
- $apcontact['followers'] = defaults($data, 'followers', null);
- $apcontact['inbox'] = defaults($data, 'inbox', null);
- $apcontact['outbox'] = defaults($data, 'outbox', null);
- $apcontact['sharedinbox'] = JsonLD::fetchElement($data, 'endpoints', 'sharedInbox');
- $apcontact['nick'] = defaults($data, 'preferredUsername', null);
- $apcontact['name'] = defaults($data, 'name', $apcontact['nick']);
- $apcontact['about'] = HTML::toBBCode(defaults($data, 'summary', ''));
- $apcontact['photo'] = JsonLD::fetchElement($data, 'icon', 'url');
- $apcontact['alias'] = JsonLD::fetchElement($data, 'url', 'href');
+ $apcontact['url'] = $compacted['@id'];
+ $apcontact['uuid'] = JsonLD::fetchElement($compacted, 'diaspora:guid');
+ $apcontact['type'] = str_replace('as:', '', JsonLD::fetchElement($compacted, '@type'));
+ $apcontact['following'] = JsonLD::fetchElement($compacted, 'as:following', '@id');
+ $apcontact['followers'] = JsonLD::fetchElement($compacted, 'as:followers', '@id');
+ $apcontact['inbox'] = JsonLD::fetchElement($compacted, 'ldp:inbox', '@id');
+ $apcontact['outbox'] = JsonLD::fetchElement($compacted, 'as:outbox', '@id');
+
+ $apcontact['sharedinbox'] = '';
+ if (!empty($compacted['as:endpoints'])) {
+ $apcontact['sharedinbox'] = JsonLD::fetchElement($compacted['as:endpoints'], 'as:sharedInbox', '@id');
+ }
+
+ $apcontact['nick'] = JsonLD::fetchElement($compacted, 'as:preferredUsername');
+ $apcontact['name'] = JsonLD::fetchElement($compacted, 'as:name');
+
+ if (empty($apcontact['name'])) {
+ $apcontact['name'] = $apcontact['nick'];
+ }
+
+ $apcontact['about'] = HTML::toBBCode(JsonLD::fetchElement($compacted, 'as:summary'));
+
+ $apcontact['photo'] = JsonLD::fetchElement($compacted, 'as:icon', '@id');
+ if (is_array($apcontact['photo'])) {
+ $apcontact['photo'] = JsonLD::fetchElement($compacted['as:icon'], 'as:url', '@id');
+ }
+
+ $apcontact['alias'] = JsonLD::fetchElement($compacted, 'as:url', '@id');
+ if (is_array($apcontact['alias'])) {
+ $apcontact['alias'] = JsonLD::fetchElement($compacted['as:url'], 'as:href', '@id');
+ }
+
+ if (empty($apcontact['url']) || empty($apcontact['inbox'])) {
+ return false;
+ }
$parts = parse_url($apcontact['url']);
unset($parts['scheme']);
unset($parts['path']);
$apcontact['addr'] = $apcontact['nick'] . '@' . str_replace('//', '', Network::unparseURL($parts));
- $apcontact['pubkey'] = trim(JsonLD::fetchElement($data, 'publicKey', 'publicKeyPem'));
+ $apcontact['pubkey'] = trim(JsonLD::fetchElement($compacted, 'w3id:publicKey', 'w3id:publicKeyPem'));
// To-Do
// manuallyApprovesFollowers
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
-use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\ActivityPub;
-use Friendica\Protocol\Diaspora;
use Friendica\Protocol\DFRN;
+use Friendica\Protocol\Diaspora;
use Friendica\Protocol\OStatus;
use Friendica\Protocol\PortableContact;
use Friendica\Protocol\Salmon;
$fields['micro'] = $prefix . '6' . $suffix;
} else {
// We hadn't found a photo entry, so we use the default avatar
- $fields['photo'] = System::baseUrl() . '/images/person-175.jpg';
+ $fields['photo'] = System::baseUrl() . '/images/person-300.jpg';
$fields['thumb'] = System::baseUrl() . '/images/person-80.jpg';
$fields['micro'] = System::baseUrl() . '/images/person-48.jpg';
}
return;
}
- if ($contact['term-date'] <= NULL_DATE) {
+ if ($contact['term-date'] <= DBA::NULL_DATETIME) {
DBA::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
- DBA::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
+ DBA::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), DBA::NULL_DATETIME]);
} else {
/* @todo
* We really should send a notification to the owner after 2-3 weeks
*/
public static function unmarkForArchival(array $contact)
{
- $condition = ['`id` = ? AND (`term-date` > ? OR `archive`)', $contact['id'], NULL_DATE];
+ $condition = ['`id` = ? AND (`term-date` > ? OR `archive`)', $contact['id'], DBA::NULL_DATETIME];
$exists = DBA::exists('contact', $condition);
// We don't need to update, we never marked this contact for archival
}
// It's a miracle. Our dead contact has inexplicably come back to life.
- $fields = ['term-date' => NULL_DATE, 'archive' => false];
+ $fields = ['term-date' => DBA::NULL_DATETIME, 'archive' => false];
DBA::update('contact', $fields, ['id' => $contact['id']]);
DBA::update('contact', $fields, ['nurl' => normalise_link($contact['url'])]);
* @param integer $uid The user id for the contact (0 = public contact)
* @param boolean $no_update Don't update the contact
* @param array $default Default value for creating the contact when every else fails
+ * @param boolean $in_loop Internally used variable to prevent an endless loop
*
* @return integer Contact ID
*/
- public static function getIdForURL($url, $uid = 0, $no_update = false, $default = [])
+ public static function getIdForURL($url, $uid = 0, $no_update = false, $default = [], $in_loop = false)
{
logger("Get contact data for url " . $url . " and user " . $uid . " - " . System::callstack(), LOGGER_DEBUG);
}
}
- if (!$contact_id && ($data["alias"] != '') && ($data["alias"] != $url)) {
- $contact_id = self::getIdForURL($data["alias"], $uid, true);
+ if (!$contact_id && ($data["alias"] != '') && ($data["alias"] != $url) && !$in_loop) {
+ $contact_id = self::getIdForURL($data["alias"], $uid, true, $default, true);
}
$url = $data["url"];
$myaddr = bin2hex($a->user['nickname'] . '@' . $a->getHostName());
}
- goaway($ret['request'] . "&addr=$myaddr");
+ $a->internalRedirect($ret['request'] . "&addr=$myaddr");
// NOTREACHED
}
/**
* @brief Returns a magic link to authenticate remote visitors
*
+ * @todo check if the return is either a fully qualified URL or a relative path to Friendica basedir
+ *
* @param string $contact_url The address of the target contact profile
- * @param integer $url An url that we will be redirected to after the authentication
+ * @param string $url An url that we will be redirected to after the authentication
*
* @return string with "redir" link
*/
* @brief Returns a magic link to authenticate remote visitors
*
* @param array $contact The contact array with "uid", "network" and "url"
- * @param integer $url An url that we will be redirected to after the authentication
+ * @param string $url An url that we will be redirected to after the authentication
*
* @return string with "redir" link
*/
const PARCEL_TWITTER = 67;
const PARCEL_UNKNOWN = 255;
+ public static function getByItemUri($item_uri)
+ {
+ return DBA::selectFirst('conversation', [], ['item-uri' => $item_uri]);
+ }
+
/**
* @brief Store the conversation data
*
$event['created'] = DateTimeFormat::utc(defaults($arr, 'created' , 'now'));
$event['edited'] = DateTimeFormat::utc(defaults($arr, 'edited' , 'now'));
- $event['start'] = DateTimeFormat::utc(defaults($arr, 'start' , NULL_DATE));
- $event['finish'] = DateTimeFormat::utc(defaults($arr, 'finish' , NULL_DATE));
- if ($event['finish'] < NULL_DATE) {
- $event['finish'] = NULL_DATE;
+ $event['start'] = DateTimeFormat::utc(defaults($arr, 'start' , DBA::NULL_DATETIME));
+ $event['finish'] = DateTimeFormat::utc(defaults($arr, 'finish' , DBA::NULL_DATETIME));
+ if ($event['finish'] < DBA::NULL_DATETIME) {
+ $event['finish'] = DBA::NULL_DATETIME;
}
$private = intval(defaults($arr, 'private', 0));
if (!isset($gcontact['network']) && ($gcnt["network"] != Protocol::STATUSNET)) {
$gcontact['network'] = $gcnt["network"];
}
- if ($gcontact['updated'] <= NULL_DATE) {
+ if ($gcontact['updated'] <= DBA::NULL_DATETIME) {
$gcontact['updated'] = $gcnt["updated"];
}
if (!isset($gcontact['server_url']) && (normalise_link($gcnt["server_url"]) != normalise_link($gcnt["url"]))) {
intval($uid),
intval($uid),
intval($uid),
- DBA::escape(NULL_DATE),
+ DBA::NULL_DATETIME,
$sql_network,
intval($start),
intval($limit)
* Uncommented because the result of the queries are to big to store it in the cache.
* We need to decide if we want to change the db column type or if we want to delete it.
*/
- //Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $r, CACHE_FIVE_MINUTES);
+ //Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $r, Cache::FIVE_MINUTES);
return $r;
}
intval($uid),
intval($uid),
intval($uid),
- DBA::escape(NULL_DATE),
+ DBA::NULL_DATETIME,
$sql_network,
intval($start),
intval($limit)
* Uncommented because the result of the queries are to big to store it in the cache.
* We need to decide if we want to change the db column type or if we want to delete it.
*/
- //Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $list, CACHE_FIVE_MINUTES);
+ //Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $list, Cache::FIVE_MINUTES);
return $list;
}
"addr" => $user->nickname."@".$hostname,
"nick" => $user->nickname,
"network" => Protocol::OSTATUS,
- "photo" => System::baseUrl()."/images/person-175.jpg"];
+ "photo" => System::baseUrl()."/images/person-300.jpg"];
if (isset($user->bio)) {
$contact["about"] = $user->bio;
*/
namespace Friendica\Model;
+use Friendica\BaseModule;
use Friendica\BaseObject;
use Friendica\Core\L10n;
use Friendica\Database\DBA;
+use Friendica\Util\Security;
require_once 'boot.php';
require_once 'include/dba.php';
'$createtext' => L10n::t('Create a new group'),
'$creategroup' => L10n::t('Group Name: '),
'$editgroupstext' => L10n::t('Edit groups'),
- '$form_security_token' => get_form_security_token('group_edit'),
+ '$form_security_token' => BaseModule::getFormSecurityToken('group_edit'),
]);
use Friendica\Protocol\OStatus;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\XML;
+use Friendica\Util\Security;
use Text_LanguageDetect;
require_once 'boot.php';
// All fields in the item table
const ITEM_FIELDLIST = ['id', 'uid', 'parent', 'uri', 'parent-uri', 'thr-parent', 'guid',
'contact-id', 'type', 'wall', 'gravity', 'extid', 'icid', 'iaid', 'psid',
- 'uri-hash', 'created', 'edited', 'commented', 'received', 'changed', 'verb',
+ 'created', 'edited', 'commented', 'received', 'changed', 'verb',
'postopts', 'plink', 'resource-id', 'event-id', 'tag', 'attach', 'inform',
'file', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'post-type',
'private', 'pubmail', 'moderated', 'visible', 'starred', 'bookmark',
$usermode = true;
}
- $fields = self::fieldlist($selected, $usermode);
+ $fields = self::fieldlist($usermode);
$select_fields = self::constructSelectFields($fields, $selected);
$usermode = true;
}
- $fields = self::fieldlist($selected, $usermode);
+ $fields = self::fieldlist($usermode);
$fields['thread'] = ['mention', 'ignored', 'iid'];
*
* @return array field list
*/
- private static function fieldlist($selected, $usermode)
+ private static function fieldlist($usermode)
{
$fields = [];
$fields['item'] = ['id', 'uid', 'parent', 'uri', 'parent-uri', 'thr-parent', 'guid',
'contact-id', 'owner-id', 'author-id', 'type', 'wall', 'gravity', 'extid',
- 'created', 'edited', 'commented', 'received', 'changed', 'psid', 'uri-hash',
+ 'created', 'edited', 'commented', 'received', 'changed', 'psid',
'resource-id', 'event-id', 'tag', 'attach', 'post-type', 'file',
'private', 'pubmail', 'moderated', 'visible', 'starred', 'bookmark',
'unseen', 'deleted', 'origin', 'forum_mode', 'mention', 'global',
}
if (strpos($sql_commands, "`item-activity`.") !== false) {
- $joins .= " LEFT JOIN `item-activity` ON `item-activity`.`id` = `item`.`iaid`";
+ $joins .= " LEFT JOIN `item-activity` ON `item-activity`.`uri-id` = `item`.`uri-id`";
}
if (strpos($sql_commands, "`item-content`.") !== false) {
- $joins .= " LEFT JOIN `item-content` ON `item-content`.`id` = `item`.`icid`";
+ $joins .= " LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`";
}
if (strpos($sql_commands, "`item-delivery-data`.") !== false) {
return $query;
}
- /**
- * @brief Generate a server unique item hash for linking between the item tables
- *
- * @param string $uri Item URI
- * @param date $created Item creation date
- *
- * @return string the item hash
- */
- private static function itemHash($uri, $created)
- {
- return round(strtotime($created) / 100) . hash('ripemd128', $uri);
- }
-
/**
* @brief Update existing item entries
*
// We cannot simply expand the condition to check for origin entries
// The condition needn't to be a simple array but could be a complex condition.
// And we have to execute this query before the update to ensure to fetch the same data.
- $items = DBA::select('item', ['id', 'origin', 'uri', 'created', 'uri-hash', 'iaid', 'icid', 'tag', 'file'], $condition);
+ $items = DBA::select('item', ['id', 'origin', 'uri', 'uri-id', 'iaid', 'icid', 'tag', 'file'], $condition);
$content_fields = [];
foreach (array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST) as $field) {
$rows = DBA::affectedRows();
while ($item = DBA::fetch($items)) {
-
- // This part here can safely be removed when the legacy fields in the item had been removed
- if (empty($item['uri-hash']) && !empty($item['uri']) && !empty($item['created'])) {
-
- // Fetch the uri-hash from an existing item entry if there is one
- $item_condition = ["`uri` = ? AND `uri-hash` != ''", $item['uri']];
- $existing = DBA::selectfirst('item', ['uri-hash'], $item_condition);
- if (DBA::isResult($existing)) {
- $item['uri-hash'] = $existing['uri-hash'];
- } else {
- $item['uri-hash'] = self::itemHash($item['uri'], $item['created']);
- }
-
- DBA::update('item', ['uri-hash' => $item['uri-hash']], ['id' => $item['id']]);
- DBA::update('item-activity', ['uri-hash' => $item['uri-hash']], ["`uri` = ? AND `uri-hash` = ''", $item['uri']]);
- DBA::update('item-content', ['uri-plink-hash' => $item['uri-hash']], ["`uri` = ? AND `uri-plink-hash` = ''", $item['uri']]);
- }
-
if (!empty($item['iaid']) || (!empty($content_fields['verb']) && (self::activityToIndex($content_fields['verb']) >= 0))) {
- if (!empty($item['iaid'])) {
- $update_condition = ['id' => $item['iaid']];
- } else {
- $update_condition = ['uri-hash' => $item['uri-hash']];
- }
- self::updateActivity($content_fields, $update_condition);
+ self::updateActivity($content_fields, ['uri-id' => $item['uri-id']]);
if (empty($item['iaid'])) {
- $item_activity = DBA::selectFirst('item-activity', ['id'], ['uri-hash' => $item['uri-hash']]);
+ $item_activity = DBA::selectFirst('item-activity', ['id'], ['uri-id' => $item['uri-id']]);
if (DBA::isResult($item_activity)) {
$item_fields = ['iaid' => $item_activity['id'], 'icid' => null];
foreach (self::MIXED_CONTENT_FIELDLIST as $field) {
}
}
} else {
- if (!empty($item['icid'])) {
- $update_condition = ['id' => $item['icid']];
- } else {
- $update_condition = ['uri-plink-hash' => $item['uri-hash']];
- }
- self::updateContent($content_fields, $update_condition);
+ self::updateContent($content_fields, ['uri-id' => $item['uri-id']]);
if (empty($item['icid'])) {
- $item_content = DBA::selectFirst('item-content', [], ['uri-plink-hash' => $item['uri-hash']]);
+ $item_content = DBA::selectFirst('item-content', [], ['uri-id' => $item['uri-id']]);
if (DBA::isResult($item_content)) {
$item_fields = ['icid' => $item_content['id']];
// Clear all fields in the item table that have a content in the item-content table
}
}
- // Ensure to always have the same creation date.
- $existing = self::selectfirst(['created', 'uri-hash'], ['uri' => $item['uri']]);
- if (DBA::isResult($existing)) {
- $item['created'] = $existing['created'];
- $item['uri-hash'] = $existing['uri-hash'];
- }
-
$item['wall'] = intval(defaults($item, 'wall', 0));
$item['extid'] = trim(defaults($item, 'extid', ''));
$item['author-name'] = trim(defaults($item, 'author-name', ''));
$item['inform'] = trim(defaults($item, 'inform', ''));
$item['file'] = trim(defaults($item, 'file', ''));
- // Unique identifier to be linked against item-activities and item-content
- $item['uri-hash'] = defaults($item, 'uri-hash', self::itemHash($item['uri'], $item['created']));
-
// When there is no content then we don't post it
if ($item['body'].$item['title'] == '') {
logger('No body, no title.');
return false;
}
- $fields = ['uri' => $item['uri'], 'activity' => $activity_index,
- 'uri-hash' => $item['uri-hash'], 'uri-id' => $item['uri-id']];
+ $fields = ['activity' => $activity_index, 'uri-hash' => (string)$item['uri-id'], 'uri-id' => $item['uri-id']];
// We just remove everything that is content
foreach (array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST) as $field) {
}
// Do we already have this content?
- $item_activity = DBA::selectFirst('item-activity', ['id'], ['uri-hash' => $item['uri-hash']]);
+ $item_activity = DBA::selectFirst('item-activity', ['id'], ['uri-id' => $item['uri-id']]);
if (DBA::isResult($item_activity)) {
$item['iaid'] = $item_activity['id'];
logger('Fetched activity for URI ' . $item['uri'] . ' (' . $item['iaid'] . ')');
*/
private static function insertContent(&$item)
{
- $fields = ['uri' => $item['uri'], 'uri-plink-hash' => $item['uri-hash'],
- 'uri-id' => $item['uri-id']];
+ $fields = ['uri-plink-hash' => (string)$item['uri-id'], 'uri-id' => $item['uri-id']];
foreach (array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST) as $field) {
if (isset($item[$field])) {
}
// Do we already have this content?
- $item_content = DBA::selectFirst('item-content', ['id'], ['uri-plink-hash' => $item['uri-hash']]);
+ $item_content = DBA::selectFirst('item-content', ['id'], ['uri-id' => $item['uri-id']]);
if (DBA::isResult($item_content)) {
$item['icid'] = $item_content['id'];
logger('Fetched content for URI ' . $item['uri'] . ' (' . $item['icid'] . ')');
$uid = local_user();
}
- if (!can_write_wall($uid)) {
+ if (!Security::canWriteToUserWall($uid)) {
logger('like: unable to write on wall ' . $uid);
return false;
}
}
}
}
+
+ public static function getPermissionsSQLByUserId($owner_id, $remote_verified = false, $groups = null)
+ {
+ $local_user = local_user();
+ $remote_user = remote_user();
+
+ /*
+ * Construct permissions
+ *
+ * default permissions - anonymous user
+ */
+ $sql = " AND NOT `item`.`private`";
+
+ // Profile owner - everything is visible
+ if ($local_user && ($local_user == $owner_id)) {
+ $sql = '';
+ } elseif ($remote_user) {
+ /*
+ * Authenticated visitor. Unless pre-verified,
+ * check that the contact belongs to this $owner_id
+ * and load the groups the visitor belongs to.
+ * If pre-verified, the caller is expected to have already
+ * done this and passed the groups into this function.
+ */
+ $set = PermissionSet::get($owner_id, $remote_user, $groups);
+
+ if (!empty($set)) {
+ $sql_set = " OR (`item`.`private` IN (1,2) AND `item`.`wall` AND `item`.`psid` IN (" . implode(',', $set) . "))";
+ } else {
+ $sql_set = '';
+ }
+
+ $sql = " AND (NOT `item`.`private`" . $sql_set . ")";
+ }
+
+ return $sql;
+ }
}
use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
+use Friendica\Util\Security;
require_once 'include/dba.php';
$type = Image::guessType($image_url, true);
$Image = new Image($img_str, $type);
if ($Image->isValid()) {
- $Image->scaleToSquare(175);
+ $Image->scaleToSquare(300);
$r = self::store($Image, $uid, $cid, $hash, $filename, 'Contact Photos', 4);
}
if ($photo_failure) {
- $image_url = System::baseUrl() . '/images/person-175.jpg';
+ $image_url = System::baseUrl() . '/images/person-300.jpg';
$thumb = System::baseUrl() . '/images/person-80.jpg';
$micro = System::baseUrl() . '/images/person-48.jpg';
}
*/
public static function getAlbums($uid, $update = false)
{
- $sql_extra = permissions_sql($uid);
+ $sql_extra = Security::getPermissionsSQLByUserId($uid);
$key = "photo_albums:".$uid.":".local_user().":".remote_user();
$albums = Cache::get($key);
DBA::escape(L10n::t('Contact Photos'))
);
}
- Cache::set($key, $albums, CACHE_DAY);
+ Cache::set($key, $albums, Cache::DAY);
}
return $albums;
}
public static function clearAlbumCache($uid)
{
$key = "photo_albums:".$uid.":".local_user().":".remote_user();
- Cache::set($key, null, CACHE_DAY);
+ Cache::set($key, null, Cache::DAY);
}
/**
);
if (DBA::isResult($s)) {
$r = DBA::toArray($s);
- Cache::set($cachekey, $r, CACHE_HOUR);
+ Cache::set($cachekey, $r, Cache::HOUR);
}
}
$profile['marital']['with'] = $a->profile['with'];
}
- if (strlen($a->profile['howlong']) && $a->profile['howlong'] >= NULL_DATE) {
+ if (strlen($a->profile['howlong']) && $a->profile['howlong'] >= DBA::NULL_DATETIME) {
$profile['howlong'] = Temporal::getRelativeDate($a->profile['howlong'], L10n::t('for %1$d %2$s'));
}
logger('URL ' . $my_url . ' already tried to authenticate.', LOGGER_DEBUG);
return;
} else {
- Cache::set($cachekey, true, CACHE_MINUTE);
+ Cache::set($cachekey, true, Cache::MINUTE);
}
logger('Not authenticated. Invoking reverse magic-auth for ' . $my_url, LOGGER_DEBUG);
// Try to avoid recursion - but send them home to do a proper magic auth.
$query = str_replace(array('?zrl=', '&zid='), array('?rzrl=', '&rzrl='), $a->query_string);
// The other instance needs to know where to redirect.
- $dest = urlencode(System::baseUrl() . '/' . $query);
+ $dest = urlencode($a->getBaseURL() . '/' . $query);
// We need to extract the basebath from the profile url
// to redirect the visitors '/magic' module.
$urlarr = explode('/profile/', $contact['url']);
$basepath = $urlarr[0];
- if ($basepath != System::baseUrl() && !strstr($dest, '/magic') && !strstr($dest, '/rmagic')) {
+ if ($basepath != $a->getBaseURL() && !strstr($dest, '/magic') && !strstr($dest, '/rmagic')) {
$magic_path = $basepath . '/magic' . '?f=&owa=1&dest=' . $dest;
// We have to check if the remote server does understand /magic without invoking something
$serverret = Network::curl($basepath . '/magic');
if ($serverret->isSuccess()) {
logger('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path, LOGGER_DEBUG);
- goaway($magic_path);
+ System::externalRedirect($magic_path);
}
}
}
public static function publishFeed($uid, $default_priority = PRIORITY_HIGH)
{
$condition = ['push' => 0, 'uid' => $uid];
- DBA::update('push_subscriber', ['push' => 1, 'next_try' => NULL_DATE], $condition);
+ DBA::update('push_subscriber', ['push' => 1, 'next_try' => DBA::NULL_DATETIME], $condition);
self::requeue($default_priority);
}
$days = round((time() - strtotime($subscriber['renewed'])) / (60 * 60 * 24));
if ($days > 60) {
- DBA::update('push_subscriber', ['push' => -1, 'next_try' => NULL_DATE], ['id' => $id]);
+ DBA::update('push_subscriber', ['push' => -1, 'next_try' => DBA::NULL_DATETIME], ['id' => $id]);
logger('Delivery error: Subscription ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as ended.', LOGGER_DEBUG);
} else {
- DBA::update('push_subscriber', ['push' => 0, 'next_try' => NULL_DATE], ['id' => $id]);
+ DBA::update('push_subscriber', ['push' => 0, 'next_try' => DBA::NULL_DATETIME], ['id' => $id]);
logger('Delivery error: Giving up ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' for now.', LOGGER_DEBUG);
}
} else {
}
// set last_update to the 'created' date of the last item, and reset push=0
- $fields = ['push' => 0, 'next_try' => NULL_DATE, 'last_update' => $last_update];
+ $fields = ['push' => 0, 'next_try' => DBA::NULL_DATETIME, 'last_update' => $last_update];
DBA::update('push_subscriber', $fields, ['id' => $id]);
logger('Subscriber ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as vital', LOGGER_DEBUG);
}
--- /dev/null
+<?php
+
+/**
+ * @file src/Model/Register.php
+ */
+namespace Friendica\Model;
+
+use Friendica\Database\DBA;
+use Friendica\Util\DateTimeFormat;
+
+/**
+ * Class interacting with the register database table
+ *
+ * @author Hypolite Petovan <mrpetovan@gmail.com>
+ */
+class Register
+{
+ /**
+ * Return the list of pending registrations
+ *
+ * @return array
+ */
+ public static function getPending()
+ {
+ $stmt = DBA::p(
+ "SELECT `register`.*, `contact`.`name`, `user`.`email`
+ FROM `register`
+ INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
+ INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
+ );
+
+ return DBA::toArray($stmt);
+ }
+
+ /**
+ * Returns the pending registration count
+ *
+ * @return int
+ */
+ public static function getPendingCount()
+ {
+ $register = DBA::fetchFirst(
+ "SELECT COUNT(*) AS `count`
+ FROM `register`
+ INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid` AND `contact`.`self`"
+ );
+
+ return $register['count'];
+ }
+
+ /**
+ * Returns the register record associated with the provided hash
+ *
+ * @param string $hash
+ * @return array
+ */
+ public static function getByHash($hash)
+ {
+ return DBA::selectFirst('register', [], ['hash' => $hash]);
+ }
+
+ /**
+ * Returns true if a register record exists with the provided hash
+ *
+ * @param string $hash
+ * @return boolean
+ */
+ public static function existsByHash($hash)
+ {
+ return DBA::exists('register', ['hash' => $hash]);
+ }
+
+ /**
+ * Creates a register record for an invitation and returns the auto-generated code for it
+ *
+ * @return string
+ */
+ public static function createForInvitation()
+ {
+ $code = autoname(8) . srand(1000, 9999);
+
+ $fields = [
+ 'hash' => $code,
+ 'created' => DateTimeFormat::utcNow()
+ ];
+
+ DBA::insert('register', $fields);
+
+ return $code;
+ }
+
+ /**
+ * Creates a register record for approval and returns the success of the database insert
+ * Checks for the existence of the provided user id
+ *
+ * @param integer $uid The ID of the user needing approval
+ * @param string $language The registration language
+ * @param string $note An additional message from the user
+ * @return boolean
+ */
+ public static function createForApproval($uid, $language, $note = '')
+ {
+ $hash = random_string();
+
+ if (!User::exists($uid)) {
+ return false;
+ }
+
+ $fields = [
+ 'hash' => $hash,
+ 'created' => DateTimeFormat::utcNow(),
+ 'uid' => $uid,
+ 'password' => '', // Obsolete, slated for deletion
+ 'language' => $language,
+ 'note' => $note
+ ];
+
+ return DBA::insert('register', $fields);
+ }
+
+ /**
+ * Deletes a register record by the provided hash and returns the success of the database deletion
+ *
+ * @param string $hash
+ * @return boolean
+ */
+ public static function deleteByHash($hash)
+ {
+ return DBA::delete('register', ['hash' => $hash]);
+ }
+}
*/
namespace Friendica\Model;
-use DivineOmega\PasswordExposed\PasswordStatus;
+use DivineOmega\PasswordExposed;
use Exception;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use LightOpenID;
-use function password_exposed;
require_once 'boot.php';
require_once 'include/dba.php';
class User
{
/**
- * @brief Returns the user id of a given profile url
+ * Returns true if a user record exists with the provided id
*
- * @param string $profile
+ * @param integer $uid
+ * @return boolean
+ */
+ public static function exists($uid)
+ {
+ return DBA::exists('user', ['uid' => $uid]);
+ }
+
+ /**
+ * @param integer $uid
+ * @return array|boolean User record if it exists, false otherwise
+ */
+ public static function getById($uid)
+ {
+ return DBA::selectFirst('user', [], ['uid' => $uid]);
+ }
+
+ /**
+ * @brief Returns the user id of a given profile URL
+ *
+ * @param string $url
*
* @return integer user id
*/
*/
public static function isPasswordExposed($password)
{
- return password_exposed($password) === PasswordStatus::EXPOSED;
+ $cache = new \DivineOmega\DOFileCachePSR6\CacheItemPool();
+ $cache->changeConfig([
+ 'cacheDirectory' => get_temppath() . '/password-exposed-cache/',
+ ]);
+
+ $PasswordExposedCHecker = new PasswordExposed\PasswordExposedChecker(null, $cache);
+
+ return $PasswordExposedCHecker->passwordExposed($password) === PasswordExposed\PasswordStatus::EXPOSED;
}
/**
throw new Exception(L10n::t('An invitation is required.'));
}
- if (!DBA::exists('register', ['hash' => $invite_id])) {
+ if (!Register::existsByHash($invite_id)) {
throw new Exception(L10n::t('Invitation could not be verified.'));
}
}
} catch (Exception $e) {
throw new Exception(L10n::t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.') . EOL . EOL . L10n::t('The error message was:') . $e->getMessage(), 0, $e);
}
- goaway($authurl);
+ System::externalRedirect($authurl);
// NOTREACHED
}
// collapse multiple spaces in name
$username = preg_replace('/ +/', ' ', $username);
- if (mb_strlen($username) > 48) {
- throw new Exception(L10n::t('Please use a shorter name.'));
+ $username_min_length = max(1, min(64, intval(Config::get('system', 'username_min_length', 3))));
+ $username_max_length = max(1, min(64, intval(Config::get('system', 'username_max_length', 48))));
+
+ if ($username_min_length > $username_max_length) {
+ logger(L10n::t('system.username_min_length (%s) and system.username_max_length (%s) are excluding each other, swapping values.', $username_min_length, $username_max_length), LOGGER_WARNING);
+ $tmp = $username_min_length;
+ $username_min_length = $username_max_length;
+ $username_max_length = $tmp;
+ }
+
+ if (mb_strlen($username) < $username_min_length) {
+ throw new Exception(L10n::tt('Username should be at least %s character.', 'Username should be at least %s characters.', $username_min_length));
}
- if (mb_strlen($username) < 3) {
- throw new Exception(L10n::t('Name too short.'));
+
+ if (mb_strlen($username) > $username_max_length) {
+ throw new Exception(L10n::tt('Username should be at most %s character.', 'Username should be at most %s characters.', $username_max_length));
}
// So now we are just looking for a space in the full name.
$loose_reg = Config::get('system', 'no_regfullname');
if (!$loose_reg) {
$username = mb_convert_case($username, MB_CASE_TITLE, 'UTF-8');
- if (!strpos($username, ' ')) {
- throw new Exception(L10n::t("That doesn't appear to be your full \x28First Last\x29 name."));
+ if (strpos($username, ' ') === false) {
+ throw new Exception(L10n::t("That doesn't appear to be your full (First Last) name."));
}
}
$Image = new Image($img_str, $type);
if ($Image->isValid()) {
- $Image->scaleToSquare(175);
+ $Image->scaleToSquare(300);
$hash = Photo::newResource();
}
/**
- * @brief Sends pending registration confiŕmation email
+ * @brief Sends pending registration confirmation email
*
- * @param string $email
+ * @param array $user User record array
* @param string $sitename
- * @param string $username
+ * @param string $siteurl
+ * @param string $password Plaintext password
* @return NULL|boolean from notification() and email() inherited
*/
- public static function sendRegisterPendingEmail($email, $sitename, $username)
+ public static function sendRegisterPendingEmail($user, $sitename, $siteurl, $password)
{
$body = deindent(L10n::t('
Dear %1$s,
Thank you for registering at %2$s. Your account is pending for approval by the administrator.
- '));
- $body = sprintf($body, $username, $sitename);
+ Your login details are as follows:
+
+ Site Location: %3$s
+ Login Name: %4$s
+ Password: %5$s
+ ',
+ $user['username'], $sitename, $siteurl, $user['nickname'], $password
+ ));
return notification([
- 'type' => SYSTEM_EMAIL,
- 'to_email' => $email,
- 'subject'=> L10n::t('Registration at %s', $sitename),
- 'body' => $body]);
+ 'type' => SYSTEM_EMAIL,
+ 'uid' => $user['uid'],
+ 'to_email' => $user['email'],
+ 'subject' => L10n::t('Registration at %s', $sitename),
+ 'body' => $body
+ ]);
}
/**
*
* It's here as a function because the mail is sent from different parts
*
- * @param string $email
+ * @param array $user User record array
* @param string $sitename
* @param string $siteurl
- * @param string $username
- * @param string $password
+ * @param string $password Plaintext password
* @return NULL|boolean from notification() and email() inherited
*/
- public static function sendRegisterOpenEmail($email, $sitename, $siteurl, $username, $password, $user)
+ public static function sendRegisterOpenEmail($user, $sitename, $siteurl, $password)
{
$preamble = deindent(L10n::t('
Dear %1$s,
Thank you for registering at %2$s. Your account has been created.
- '));
+ ',
+ $preamble, $user['username'], $sitename
+ ));
$body = deindent(L10n::t('
The login details are as follows:
If you ever want to delete your account, you can do so at %3$s/removeme
- Thank you and welcome to %2$s.'));
-
- $preamble = sprintf($preamble, $username, $sitename);
- $body = sprintf($body, $email, $sitename, $siteurl, $username, $password);
+ Thank you and welcome to %2$s.',
+ $user['email'], $sitename, $siteurl, $user['username'], $password
+ ));
return notification([
- 'uid' => $user['uid'],
+ 'uid' => $user['uid'],
'language' => $user['language'],
- 'type' => SYSTEM_EMAIL,
- 'to_email' => $email,
- 'subject'=> L10n::t('Registration details for %s', $sitename),
- 'preamble'=> $preamble,
- 'body' => $body]);
+ 'type' => SYSTEM_EMAIL,
+ 'to_email' => $user['email'],
+ 'subject' => L10n::t('Registration details for %s', $sitename),
+ 'preamble' => $preamble,
+ 'body' => $body
+ ]);
}
/**
return;
}
+ $a = get_app();
+
logger('Removing user: ' . $uid);
$user = DBA::selectFirst('user', [], ['uid' => $uid]);
if ($uid == local_user()) {
unset($_SESSION['authenticated']);
unset($_SESSION['uid']);
- goaway(System::baseUrl());
+ $a->internalRedirect();
}
}
}
use Friendica\BaseModule;
use Friendica\Network\Probe;
+use Friendica\Core\System;
/**
* Redirects to another URL based on the parameter 'addr'
$url = defaults(Probe::uri(trim($addr)), 'url', false);
if ($url) {
- goaway($url);
+ System::externalRedirect($url);
exit();
}
}
use Friendica\Content\Nav;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Widget;
+use Friendica\Core\ACL;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model;
+use Friendica\Module\Login;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Proxy as ProxyUtils;
-use Friendica\Core\ACL;
-use Friendica\Module\Login;
/**
* Manages and show Contacts and their content
if (DBA::isResult($contact)) {
if ($contact['self']) {
if (($a->argc == 3) && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations'])) {
- goaway('profile/' . $contact['nick']);
+ $a->internalRedirect('profile/' . $contact['nick']);
} else {
- goaway('profile/' . $contact['nick'] . '?tab=profile');
+ $a->internalRedirect('profile/' . $contact['nick'] . '?tab=profile');
}
}
info(L10n::tt('%d contact edited.', '%d contacts edited.', $count_actions));
}
- goaway('contact');
+ $a->internalRedirect('contact');
}
public static function post()
if (!DBA::exists('contact', ['id' => $contact_id, 'uid' => local_user()])) {
notice(L10n::t('Could not access contact record.') . EOL);
- goaway('contact');
+ $a->internalRedirect('contact');
return; // NOTREACHED
}
$orig_record = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => [0, local_user()], 'self' => false]);
if (!DBA::isResult($orig_record)) {
notice(L10n::t('Could not access contact record.') . EOL);
- goaway('contact');
+ $a->internalRedirect('contact');
return; // NOTREACHED
}
if ($cmd === 'update' && ($orig_record['uid'] != 0)) {
self::updateContactFromPoll($contact_id);
- goaway('contact/' . $contact_id);
+ $a->internalRedirect('contact/' . $contact_id);
// NOTREACHED
}
if ($cmd === 'updateprofile' && ($orig_record['uid'] != 0)) {
self::updateContactFromProbe($contact_id);
- goaway('crepair/' . $contact_id);
+ $a->internalRedirect('crepair/' . $contact_id);
// NOTREACHED
}
$blocked = Model\Contact::isBlockedByUser($contact_id, local_user());
info(($blocked ? L10n::t('Contact has been blocked') : L10n::t('Contact has been unblocked')) . EOL);
- goaway('contact/' . $contact_id);
+ $a->internalRedirect('contact/' . $contact_id);
return; // NOTREACHED
}
$ignored = Model\Contact::isIgnoredByUser($contact_id, local_user());
info(($ignored ? L10n::t('Contact has been ignored') : L10n::t('Contact has been unignored')) . EOL);
- goaway('contact/' . $contact_id);
+ $a->internalRedirect('contact/' . $contact_id);
return; // NOTREACHED
}
info((($archived) ? L10n::t('Contact has been archived') : L10n::t('Contact has been unarchived')) . EOL);
}
- goaway('contact/' . $contact_id);
+ $a->internalRedirect('contact/' . $contact_id);
return; // NOTREACHED
}
}
// Now check how the user responded to the confirmation query
if (!empty($_REQUEST['canceled'])) {
- goaway('contact');
+ $a->internalRedirect('contact');
}
self::dropContact($orig_record);
info(L10n::t('Contact has been removed.') . EOL);
- goaway('contact');
+ $a->internalRedirect('contact');
return; // NOTREACHED
}
if ($cmd === 'posts') {
}
}
- $_SESSION['return_url'] = $a->query_string;
+ $_SESSION['return_path'] = $a->query_string;
if (!empty($a->data['contact']) && is_array($a->data['contact'])) {
$contact_id = $a->data['contact']['id'];
$insecure = L10n::t('Private communications are not available for this contact.');
- $last_update = (($contact['last-update'] <= NULL_DATE) ? L10n::t('Never') : DateTimeFormat::local($contact['last-update'], 'D, j M Y, g:i A'));
+ $last_update = (($contact['last-update'] <= DBA::NULL_DATETIME) ? L10n::t('Never') : DateTimeFormat::local($contact['last-update'], 'D, j M Y, g:i A'));
- if ($contact['last-update'] > NULL_DATE) {
+ if ($contact['last-update'] > DBA::NULL_DATETIME) {
$last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? L10n::t('(Update was successful)') : L10n::t('(Update was not successful)'));
}
$lblsuggest = (($contact['network'] === Protocol::DFRN) ? L10n::t('Suggest friends') : '');
// tabs
$tab_str = self::getTabsHTML($a, $contact, 3);
- $lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < DateTimeFormat::utcNow()) ? L10n::t('Communications lost with this contact!') : '');
+ $lost_contact = (($contact['archive'] && $contact['term-date'] > DBA::NULL_DATETIME && $contact['term-date'] < DateTimeFormat::utcNow()) ? L10n::t('Communications lost with this contact!') : '');
$fetch_further_information = null;
if ($contact['network'] == Protocol::FEED) {
--- /dev/null
+<?php
+
+namespace Friendica\Module;
+
+use Friendica\Core\L10n;
+use Friendica\Model;
+
+/**
+ * @author Hypolite Petovan <mrpetovan@gmail.com>
+ */
+class Itemsource extends \Friendica\BaseModule
+{
+ public static function content()
+ {
+ if (!is_site_admin()) {
+ return;
+ }
+
+ $source = '';
+ $item_uri = '';
+ if (!empty($_REQUEST['guid'])) {
+ $item = Model\Item::selectFirst([], ['guid' => $_REQUEST['guid']]);
+
+ $conversation = Model\Conversation::getByItemUri($item['uri']);
+
+ $item_uri = $item['uri'];
+ $source = htmlspecialchars($conversation['source']);
+ }
+
+ $tpl = get_markup_template('debug/itemsource.tpl');
+ $o = replace_macros($tpl, [
+ '$guid' => ['guid', L10n::t('Item Guid'), htmlentities(defaults($_REQUEST, 'guid', '')), ''],
+ '$source' => $source,
+ '$item_uri' => $item_uri
+ ]);
+
+ return $o;
+ }
+}
use Exception;
use Friendica\BaseModule;
use Friendica\Core\Addon;
+use Friendica\Core\Authentication;
use Friendica\Core\Config;
use Friendica\Core\L10n;
+use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
use LightOpenID;
require_once 'boot.php';
-require_once 'include/security.php';
require_once 'include/text.php';
/**
}
if (local_user()) {
- goaway(self::getApp()->getBaseURL());
+ $a->internalRedirect();
}
- return self::form($_SESSION['return_url'], intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED);
+ return self::form($_SESSION['return_path'], intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED);
}
public static function post()
{
- $return_url = $_SESSION['return_url'];
+ $return_path = $_SESSION['return_path'];
session_unset();
- $_SESSION['return_url'] = $return_url;
+ $_SESSION['return_path'] = $return_path;
// OpenId Login
if (
{
$noid = Config::get('system', 'no_openid');
+ $a = self::getApp();
+
// if it's an email address or doesn't resolve to a URL, fail.
if ($noid || strpos($openid_url, '@') || !Network::isUrlValid($openid_url)) {
notice(L10n::t('Login failed.') . EOL);
- goaway(self::getApp()->getBaseURL());
+ $a->internalRedirect();
// NOTREACHED
}
// Otherwise it's probably an openid.
try {
- $a = get_app();
$openid = new LightOpenID($a->getHostName());
$openid->identity = $openid_url;
$_SESSION['openid'] = $openid_url;
$_SESSION['remember'] = $remember;
- $openid->returnUrl = self::getApp()->getBaseURL(true) . '/openid';
- goaway($openid->authUrl());
+ $openid->returnUrl = $a->getBaseURL(true) . '/openid';
+ System::externalRedirect($openid->authUrl());
} catch (Exception $e) {
notice(L10n::t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.') . '<br /><br >' . L10n::t('The error message was:') . ' ' . $e->getMessage());
}
'user_record' => null
];
+ $a = self::getApp();
+
/*
* An addon indicates successful login by setting 'authenticated' to non-zero value and returning a user record
* Addons should never set 'authenticated' except to indicate success - as hooks may be chained
} catch (Exception $e) {
logger('authenticate: failed login attempt: ' . notags($username) . ' from IP ' . $_SERVER['REMOTE_ADDR']);
info('Login failed. Please check your credentials.' . EOL);
- goaway('/');
+ $a->internalRedirect();
}
if (!$remember) {
- new_cookie(0); // 0 means delete on browser exit
+ Authentication::setCookie(0); // 0 means delete on browser exit
}
// if we haven't failed up this point, log them in.
$_SESSION['remember'] = $remember;
$_SESSION['last_login_date'] = DateTimeFormat::utcNow();
- authenticate_success($record, true, true);
+ Authentication::setAuthenticatedSessionForUser($record, true, true);
- if (x($_SESSION, 'return_url')) {
- $return_url = $_SESSION['return_url'];
- unset($_SESSION['return_url']);
+ if (x($_SESSION, 'return_path')) {
+ $return_path = $_SESSION['return_path'];
+ unset($_SESSION['return_path']);
} else {
- $return_url = '';
+ $return_path = '';
}
- goaway($return_url);
+ $a->internalRedirect($return_path);
}
/**
*/
public static function sessionAuth()
{
+ $a = self::getApp();
+
// When the "Friendica" cookie is set, take the value to authenticate and renew the cookie.
if (isset($_COOKIE["Friendica"])) {
$data = json_decode($_COOKIE["Friendica"]);
]
);
if (DBA::isResult($user)) {
- if ($data->hash != cookie_hash($user)) {
+ if ($data->hash != Authentication::getCookieHashForUser($user)) {
logger("Hash for user " . $data->uid . " doesn't fit.");
- nuke_session();
- goaway(self::getApp()->getBaseURL());
+ Authentication::deleteSession();
+ $a->internalRedirect();
}
// Renew the cookie
// Expires after 7 days by default,
// can be set via system.auth_cookie_lifetime
$authcookiedays = Config::get('system', 'auth_cookie_lifetime', 7);
- new_cookie($authcookiedays * 24 * 60 * 60, $user);
+ Authentication::setCookie($authcookiedays * 24 * 60 * 60, $user);
// Do the authentification if not done by now
if (!isset($_SESSION) || !isset($_SESSION['authenticated'])) {
- authenticate_success($user);
+ Authentication::setAuthenticatedSessionForUser($user);
if (Config::get('system', 'paranoia')) {
$_SESSION['addr'] = $data->ip;
if ($check && ($_SESSION['addr'] != $_SERVER['REMOTE_ADDR'])) {
logger('Session address changed. Paranoid setting in effect, blocking session. ' .
$_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']);
- nuke_session();
- goaway(self::getApp()->getBaseURL());
+ Authentication::deleteSession();
+ $a->internalRedirect();
}
$user = DBA::selectFirst('user', [],
]
);
if (!DBA::isResult($user)) {
- nuke_session();
- goaway(self::getApp()->getBaseURL());
+ Authentication::deleteSession();
+ $a->internalRedirect();
}
// Make sure to refresh the last login time for the user if the user
$_SESSION['last_login_date'] = DateTimeFormat::utcNow();
$login_refresh = true;
}
- authenticate_success($user, false, false, $login_refresh);
+ Authentication::setAuthenticatedSessionForUser($user, false, false, $login_refresh);
}
}
}
/**
* @brief Wrapper for adding a login box.
*
- * @param string $return_url The url relative to the base the user should be sent
+ * @param string $return_path The path relative to the base the user should be sent
* back to after login completes
* @param bool $register If $register == true provide a registration link.
* This will most always depend on the value of config.register_policy.
*
* @hooks 'login_hook' string $o
*/
- public static function form($return_url = null, $register = false, $hiddens = [])
+ public static function form($return_path = null, $register = false, $hiddens = [])
{
$a = self::getApp();
$o = '';
$noid = Config::get('system', 'no_openid');
- if (is_null($return_url)) {
- $return_url = $a->query_string;
+ if (is_null($return_path)) {
+ $return_path = $a->query_string;
}
if (local_user()) {
);
$tpl = get_markup_template('login.tpl');
- $_SESSION['return_url'] = $return_url;
+ $_SESSION['return_path'] = $return_path;
}
$o .= replace_macros(
use Friendica\BaseModule;
use Friendica\Core\Addon;
+use Friendica\Core\Authentication;
use Friendica\Core\L10n;
+use Friendica\Core\System;
require_once 'boot.php';
-require_once 'include/security.php';
/**
* Logout module
public static function init()
{
Addon::callHooks("logging_out");
- nuke_session();
+ Authentication::deleteSession();
info(L10n::t('Logged out.') . EOL);
- goaway(self::getApp()->getBaseURL());
+ self::getApp()->internalRedirect();
}
}
use Friendica\BaseModule;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
+use Friendica\Core\System;
use Friendica\Util\HTTPSignature;
use Friendica\Util\Network;
if (!$cid) {
logger('No contact record found: ' . print_r($_REQUEST, true), LOGGER_DEBUG);
- goaway($dest);
+ // @TODO Finding a more elegant possibility to redirect to either internal or external URL
+ if (filter_var($dest, FILTER_VALIDATE_URL)) {
+ System::externalRedirect($dest);
+ } else {
+ $a->internalRedirect($dest);
+ }
}
-
$contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
// Redirect if the contact is already authenticated on this site.
}
logger('Contact is already authenticated', LOGGER_DEBUG);
- goaway($dest);
+ System::externalRedirect($dest);
}
if (local_user()) {
$x = strpbrk($dest, '?&');
$args = (($x) ? '&owt=' . $token : '?f=&owt=' . $token);
- goaway($dest . $args);
+ System::externalRedirect($dest . $args);
}
}
- goaway($dest);
+ System::externalRedirect($dest);
}
}
return $ret;
}
- goaway($dest);
+ // @TODO Finding a more elegant possibility to redirect to either internal or external URL
+ if (filter_var($dest, FILTER_VALIDATE_URL)) {
+ System::externalRedirect($dest);
+ } else {
+ $a->internalRedirect($dest);
+ }
}
}
}
if (!ActivityPub::isRequest()) {
- goaway(str_replace('objects/', 'display/', $a->query_string));
+ $a->internalRedirect(str_replace('objects/', 'display/', $a->query_string));
}
$item = Item::selectFirst(['id'], ['guid' => $a->argv[1], 'wall' => true, 'private' => false]);
use Friendica\Util\Network;
use Friendica\Util\Proxy as ProxyUtils;
-require_once 'include/security.php';
-
/**
* @brief Module Proxy
*/
$sizetype = ':thumb';
$url = substr($url, 0, -6);
} elseif (substr($url, -6) == ':small') {
- $size = 175;
+ $size = 300;
$url = substr($url, 0, -6);
$sizetype = ':small';
} elseif (substr($url, -7) == ':medium') {
public static function init()
{
if (strlen(Config::get('system','singleuser'))) {
- goaway(System::baseUrl()."/profile/" . Config::get('system','singleuser'));
+ self::getApp()->internalRedirect('profile/' . Config::get('system','singleuser'));
}
}
/**
if (x($data, "photo")) {
$data["baseurl"] = Network::getUrlMatch(normalise_link(defaults($data, "baseurl", "")), normalise_link($data["photo"]));
} else {
- $data["photo"] = System::baseUrl().'/images/person-175.jpg';
+ $data["photo"] = System::baseUrl().'/images/person-300.jpg';
}
if (empty($data["name"])) {
// Only store into the cache if the value seems to be valid
if (!in_array($data['network'], [Protocol::PHANTOM, Protocol::MAIL])) {
- Cache::set("Probe::uri:".$network.":".$uri, $data, CACHE_DAY);
+ Cache::set("Probe::uri:".$network.":".$uri, $data, Cache::DAY);
/// @todo temporary fix - we need a real contact update function that updates only changing fields
/// The biggest problem is the avatar picture that could have a reduced image size.
use Friendica\BaseObject;
use Friendica\Core\Protocol;
use Friendica\Object\Post;
+use Friendica\Util\Security;
require_once 'boot.php';
require_once 'include/text.php';
break;
case 'profile':
$this->profile_owner = $a->profile['profile_uid'];
- $this->writable = can_write_wall($this->profile_owner);
+ $this->writable = Security::canWriteToUserWall($this->profile_owner);
break;
case 'display':
$this->profile_owner = $a->profile['uid'];
- $this->writable = can_write_wall($this->profile_owner) || $writable;
+ $this->writable = Security::canWriteToUserWall($this->profile_owner) || $writable;
break;
case 'community':
$this->profile_owner = 0;
return false;
}
- return json_decode($curlResult->getBody(), true);
+ $content = json_decode($curlResult->getBody(), true);
+
+ if (empty($content) || !is_array($content)) {
+ return false;
+ }
+
+ return $content;
}
/**
use Friendica\Protocol\ActivityPub;
/**
- * ActivityPub Protocol class
- *
- * To-Do:
- * - Store Diaspora signature
+ * ActivityPub Processor Protocol class
*/
class Processor
{
$activity['cc'] = defaults($object, 'cc', []);
$activity['actor'] = $child['author'];
$activity['object'] = $object;
- $activity['published'] = $object['published'];
+ $activity['published'] = defaults($object, 'published', $child['published']);
$activity['type'] = 'Create';
$ldactivity = JsonLD::compact($activity);
}
if (in_array($receiver, [$followers, self::PUBLIC_COLLECTION]) && !empty($actor)) {
+ $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
$condition = ['nurl' => normalise_link($actor), 'rel' => [Contact::SHARING, Contact::FRIEND],
- 'network' => Protocol::ACTIVITYPUB, 'archive' => false, 'pending' => false];
+ 'network' => $networks, 'archive' => false, 'pending' => false];
$contacts = DBA::select('contact', ['uid'], $condition);
while ($contact = DBA::fetch($contacts)) {
if ($contact['uid'] != 0) {
logger('Switch contact ' . $cid . ' (' . $profile['url'] . ') for user ' . $uid . ' to ActivityPub');
- $photo = $profile['photo'];
+ $photo = defaults($profile, 'photo', null);
unset($profile['photo']);
unset($profile['baseurl']);
}
/**
- *
+ *
*
* @param $receivers
* @param $actor
}
/**
- *
+ *
*
* @param $object_data
* @param array $activity
*
- * @return
+ * @return
*/
private static function addActivityFields($object_data, $activity)
{
*
* Complicated object types:
* - Undo Announce
- *
- * General:
- * - Queueing unsucessful deliveries
*/
class Transmitter
{
foreach ($activity[$element] as $receiver) {
if ($receiver == $profile['followers'] && !empty($item_profile['followers'])) {
- $receiver = $item_profile['followers'];
+ $permissions[$element][] = $item_profile['followers'];
}
if (!in_array($receiver, $exclude)) {
$permissions[$element][] = $receiver;
*/
private static function createPermissionBlockForItem($item)
{
+ // Will be activated in a later step
+ // $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
+
+ // For now only send to these contacts:
+ $networks = [Protocol::ACTIVITYPUB, Protocol::OSTATUS];
+
$data = ['to' => [], 'cc' => []];
$data = array_merge($data, self::fetchPermissionBlockFromConversation($item));
$terms = Term::tagArrayFromItemId($item['id'], TERM_MENTION);
- $contacts[$item['author-link']] = $item['author-link'];
-
if (!$item['private']) {
$data['to'][] = ActivityPub::PUBLIC_COLLECTION;
if (!empty($actor_profile['followers'])) {
foreach ($terms as $term) {
$profile = APContact::getByURL($term['url'], false);
- if (!empty($profile) && empty($contacts[$profile['url']])) {
+ if (!empty($profile)) {
$data['to'][] = $profile['url'];
- $contacts[$profile['url']] = $profile['url'];
-
- if (($key = array_search($profile['url'], $data['cc'])) !== false) {
- unset($data['cc'][$key]);
- }
}
}
} else {
foreach ($terms as $term) {
$cid = Contact::getIdForURL($term['url'], $item['uid']);
if (!empty($cid) && in_array($cid, $receiver_list)) {
- $contact = DBA::selectFirst('contact', ['url'], ['id' => $cid, 'network' => Protocol::ACTIVITYPUB]);
- $data['to'][] = $contact['url'];
- $contacts[$contact['url']] = $contact['url'];
-
- if (($key = array_search($profile['url'], $data['cc'])) !== false) {
- unset($data['cc'][$key]);
+ $contact = DBA::selectFirst('contact', ['url'], ['id' => $cid, 'network' => $networks]);
+ if (DBA::isResult($contact) && !empty($profile = APContact::getByURL($contact['url'], false))) {
+ $data['to'][] = $profile['url'];
}
}
}
foreach ($receiver_list as $receiver) {
- $contact = DBA::selectFirst('contact', ['url'], ['id' => $receiver, 'network' => Protocol::ACTIVITYPUB]);
- if (empty($contacts[$contact['url']])) {
- $data['cc'][] = $contact['url'];
- $contacts[$contact['url']] = $contact['url'];
+ $contact = DBA::selectFirst('contact', ['url'], ['id' => $receiver, 'network' => $networks]);
+ if (DBA::isResult($contact) && !empty($profile = APContact::getByURL($contact['url'], false))) {
+ $data['cc'][] = $profile['url'];
}
}
}
}
$profile = APContact::getByURL($parent['author-link'], false);
- if (!empty($profile) && ($parent['uri'] == $item['thr-parent'])) {
- $data['to'][] = $profile['url'];
- $contacts[$profile['url']] = $profile['url'];
-
- if (($key = array_search($profile['url'], $data['cc'])) !== false) {
- unset($data['cc'][$key]);
+ if (!empty($profile)) {
+ if ($parent['uri'] == $item['thr-parent']) {
+ $data['to'][] = $profile['url'];
+ } else {
+ $data['cc'][] = $profile['url'];
}
}
- if (!empty($profile) && empty($contacts[$profile['url']])) {
- $data['cc'][] = $profile['url'];
- $contacts[$profile['url']] = $profile['url'];
- }
-
if ($item['gravity'] != GRAVITY_PARENT) {
continue;
}
$profile = APContact::getByURL($parent['owner-link'], false);
- if (!empty($profile) && empty($contacts[$profile['url']])) {
+ if (!empty($profile)) {
$data['cc'][] = $profile['url'];
- $contacts[$profile['url']] = $profile['url'];
}
}
DBA::close($parents);
+ $data['to'] = array_unique($data['to']);
+ $data['cc'] = array_unique($data['cc']);
+
if (($key = array_search($item['author-link'], $data['to'])) !== false) {
unset($data['to'][$key]);
}
unset($data['cc'][$key]);
}
- return ['to' => array_values(array_unique($data['to'])), 'cc' => array_values(array_unique($data['cc']))];
+ foreach ($data['to'] as $to) {
+ if (($key = array_search($to, $data['cc'])) !== false) {
+ unset($data['cc'][$key]);
+ }
+ }
+
+ return ['to' => array_values($data['to']), 'cc' => array_values($data['cc'])];
}
/**
* Fetches a list of inboxes of followers of a given user
*
* @param integer $uid User ID
+ * @param boolean $personal fetch personal inboxes
*
* @return array of follower inboxes
*/
- public static function fetchTargetInboxesforUser($uid)
+ public static function fetchTargetInboxesforUser($uid, $personal = false)
{
$inboxes = [];
- $condition = ['uid' => $uid, 'network' => Protocol::ACTIVITYPUB, 'archive' => false, 'pending' => false];
+ // Will be activated in a later step
+ // $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
+
+ // For now only send to these contacts:
+ $networks = [Protocol::ACTIVITYPUB, Protocol::OSTATUS];
+
+ $condition = ['uid' => $uid, 'network' => $networks, 'archive' => false, 'pending' => false];
if (!empty($uid)) {
$condition['rel'] = [Contact::FOLLOWER, Contact::FRIEND];
}
- $contacts = DBA::select('contact', ['notify', 'batch'], $condition);
+ $contacts = DBA::select('contact', ['url'], $condition);
while ($contact = DBA::fetch($contacts)) {
- $contact = defaults($contact, 'batch', $contact['notify']);
- $inboxes[$contact] = $contact;
+ $profile = APContact::getByURL($contact['url'], false);
+ if (!empty($profile)) {
+ if (empty($profile['sharedinbox']) || $personal) {
+ $target = $profile['inbox'];
+ } else {
+ $target = $profile['sharedinbox'];
+ }
+ $inboxes[$target] = $target;
+ }
}
DBA::close($contacts);
*
* @param array $item
* @param integer $uid User ID
+ * @param boolean $personal fetch personal inboxes
*
* @return array with inboxes
*/
- public static function fetchTargetInboxes($item, $uid)
+ public static function fetchTargetInboxes($item, $uid, $personal = false)
{
$permissions = self::createPermissionBlockForItem($item);
if (empty($permissions)) {
$inboxes = [];
if ($item['gravity'] == GRAVITY_ACTIVITY) {
- $item_profile = APContact::getByURL($item['author-link']);
+ $item_profile = APContact::getByURL($item['author-link'], false);
} else {
- $item_profile = APContact::getByURL($item['owner-link']);
+ $item_profile = APContact::getByURL($item['owner-link'], false);
}
foreach (['to', 'cc', 'bto', 'bcc'] as $element) {
foreach ($permissions[$element] as $receiver) {
if ($receiver == $item_profile['followers']) {
- $inboxes = self::fetchTargetInboxesforUser($uid);
+ $inboxes = array_merge($inboxes, self::fetchTargetInboxesforUser($uid, $personal));
} else {
- $profile = APContact::getByURL($receiver);
+ $profile = APContact::getByURL($receiver, false);
if (!empty($profile)) {
- $target = defaults($profile, 'sharedinbox', $profile['inbox']);
+ if (empty($profile['sharedinbox']) || $personal) {
+ $target = $profile['inbox'];
+ } else {
+ $target = $profile['sharedinbox'];
+ }
$inboxes[$target] = $target;
}
}
$data = ActivityPub\Transmitter::createActivityFromItem($item_id);
- Cache::set($cachekey, $data, CACHE_QUARTER_HOUR);
+ Cache::set($cachekey, $data, Cache::QUARTER_HOUR);
return $data;
}
return $attachments;
}
+ /**
+ * @brief Callback function to replace a Friendica style mention in a mention that is used on AP
+ *
+ * @param array $match Matching values for the callback
+ * @return string Replaced mention
+ */
+ private static function mentionCallback($match)
+ {
+ if (empty($match[1])) {
+ return;
+ }
+
+ $data = Contact::getDetailsByURL($match[1]);
+ if (empty($data) || empty($data['nick'])) {
+ return;
+ }
+
+ return '@[url=' . $data['url'] . ']' . $data['nick'] . '[/url]';
+ }
+
/**
* Remove image elements and replaces them with links to the image
*
$body = self::removePictures($body);
}
+ $regexp = "/[@!]\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
+ $body = preg_replace_callback($regexp, ['self', 'mentionCallback'], $body);
+
$data['content'] = BBCode::convert($body, false, 7);
$data['source'] = ['content' => $item['body'], 'mediaType' => "text/bbcode"];
* @param integer $uid User ID
* @param string $inbox Target inbox
* @param integer $suggestion_id Suggestion ID
+ *
+ * @return boolean was the transmission successful?
*/
public static function sendContactSuggestion($uid, $inbox, $suggestion_id)
{
$signed = LDSignature::sign($data, $owner);
logger('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG);
- HTTPSignature::transmit($signed, $inbox, $uid);
+ return HTTPSignature::transmit($signed, $inbox, $uid);
}
/**
*
* @param integer $uid User ID
* @param string $inbox Target inbox
+ *
+ * @return boolean was the transmission successful?
*/
public static function sendProfileDeletion($uid, $inbox)
{
$signed = LDSignature::sign($data, $owner);
logger('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG);
- HTTPSignature::transmit($signed, $inbox, $uid);
+ return HTTPSignature::transmit($signed, $inbox, $uid);
}
/**
*
* @param integer $uid User ID
* @param string $inbox Target inbox
+ *
+ * @return boolean was the transmission successful?
*/
public static function sendProfileUpdate($uid, $inbox)
{
$signed = LDSignature::sign($data, $owner);
logger('Deliver profile update for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG);
- HTTPSignature::transmit($signed, $inbox, $uid);
+ return HTTPSignature::transmit($signed, $inbox, $uid);
}
/**
}
$contact = $r[0];
- include_once 'include/security.php';
$set = PermissionSet::get($owner_id, $contact['id']);
XML::addElement($doc, $author, "dfrn:handle", $owner["addr"], $attributes);
$attributes = ["rel" => "photo", "type" => "image/jpeg",
- "media:width" => 175, "media:height" => 175, "href" => $owner['photo']];
+ "media:width" => 300, "media:height" => 300, "href" => $owner['photo']];
if (!$public || !$hidewall) {
$attributes["dfrn:updated"] = $picdate;
logger('auto_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG);
$dest = (($url) ? '&destination_url=' . $url : '');
- goaway($r[0]['poll'] . '?dfrn_id=' . $dfrn_id
+ System::externalRedirect($r[0]['poll'] . '?dfrn_id=' . $dfrn_id
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest);
}
$person = DBA::selectFirst('fcontact', [], ['network' => Protocol::DIASPORA, 'addr' => $handle]);
if (!DBA::isResult($person)) {
$person = $r;
+ $person['id'] = 0;
}
}
}
);
preg_replace_callback(
- "&\[url=/posts/([^\[\]]*)\](.*)\[\/url\]&Usi",
+ "&\[url=/?posts/([^\[\]]*)\](.*)\[\/url\]&Usi",
function ($match) use ($item) {
self::fetchGuidSub($match, $item);
},
logger("Send participation for ".$item["guid"]." by ".$author, LOGGER_DEBUG);
// It doesn't matter what we store, we only want to avoid sending repeated notifications for the same item
- Cache::set($cachekey, $item["guid"], CACHE_QUARTER_HOUR);
+ Cache::set($cachekey, $item["guid"], Cache::QUARTER_HOUR);
return self::buildAndTransmit($owner, $contact, "participation", $message);
}
/// @todo - establish "all day" events in Friendica
$eventdata["all_day"] = "false";
- if (!$event['adjust']) {
+ $eventdata['timezone'] = 'UTC';
+ if (!$event['adjust'] && $user['timezone']) {
$eventdata['timezone'] = $user['timezone'];
-
- if ($eventdata['timezone'] == "") {
- $eventdata['timezone'] = 'UTC';
- }
}
if ($event['start']) {
$msg = ["type" => $type, "message" => $message];
- Cache::set($cachekey, $msg, CACHE_QUARTER_HOUR);
+ Cache::set($cachekey, $msg, Cache::QUARTER_HOUR);
return $msg;
}
$comment['thread_parent_guid'] = self::getGuidFromUri($item['thr-parent'], $item['uid']);
}
- Cache::set($cachekey, $comment, CACHE_QUARTER_HOUR);
+ Cache::set($cachekey, $comment, Cache::QUARTER_HOUR);
return($comment);
}
$attributes = [
"rel" => "avatar",
"type" => "image/jpeg", // To-Do?
- "media:width" => 175,
- "media:height" => 175,
+ "media:width" => 300,
+ "media:height" => 300,
"href" => $owner["photo"]];
XML::addElement($doc, $author, "link", "", $attributes);
$attributes = [
"rel" => "avatar",
"type" => "image/jpeg", // To-Do?
- "media:width" => 175,
- "media:height" => 175,
+ "media:width" => 300,
+ "media:height" => 300,
"href" => $contact["photo"]];
XML::addElement($doc, $object, "link", "", $attributes);
$feeddata = trim($doc->saveXML());
$msg = ['feed' => $feeddata, 'last_update' => $last_update];
- Cache::set($cachekey, $msg, CACHE_QUARTER_HOUR);
+ Cache::set($cachekey, $msg, Cache::QUARTER_HOUR);
logger('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created, LOGGER_DEBUG);
$connect_url = '';
$name = '';
$network = '';
- $updated = NULL_DATE;
+ $updated = DBA::NULL_DATETIME;
$location = '';
$about = '';
$keywords = '';
$contact = ["url" => $profile];
- if ($gcontacts[0]["created"] <= NULL_DATE) {
+ if ($gcontacts[0]["created"] <= DBA::NULL_DATETIME) {
$contact['created'] = DateTimeFormat::utcNow();
}
// Maybe there aren't any entries. Then check if it is a valid feed
if ($last_updated == "") {
if ($xpath->query('/atom:feed')->length > 0) {
- $last_updated = NULL_DATE;
+ $last_updated = DBA::NULL_DATETIME;
}
}
$gserver = DBA::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]);
if (DBA::isResult($gserver)) {
- if ($gserver["created"] <= NULL_DATE) {
+ if ($gserver["created"] <= DBA::NULL_DATETIME) {
$fields = ['created' => DateTimeFormat::utcNow()];
$condition = ['nurl' => normalise_link($server_url)];
DBA::update('gserver', $fields, $condition);
// See discussion under https://forum.friendi.ca/display/0b6b25a8135aabc37a5a0f5684081633
// It can happen that a zero date is in the database, but storing it again is forbidden.
- if ($last_contact < NULL_DATE) {
- $last_contact = NULL_DATE;
+ if ($last_contact < DBA::NULL_DATETIME) {
+ $last_contact = DBA::NULL_DATETIME;
}
- if ($last_failure < NULL_DATE) {
- $last_failure = NULL_DATE;
+ if ($last_failure < DBA::NULL_DATETIME) {
+ $last_failure = DBA::NULL_DATETIME;
}
if (!$force && !self::updateNeeded($gserver["created"], "", $last_failure, $last_contact)) {
$register_policy = -1;
$registered_users = 0;
- $last_contact = NULL_DATE;
- $last_failure = NULL_DATE;
+ $last_contact = DBA::NULL_DATETIME;
+ $last_failure = DBA::NULL_DATETIME;
}
logger("Server ".$server_url." is outdated or unknown. Start discovery. Force: ".$force." Created: ".$gserver["created"]." Failure: ".$last_failure." Contact: ".$last_contact, LOGGER_DEBUG);
$connect_url = '';
$name = '';
$network = '';
- $updated = NULL_DATE;
+ $updated = DBA::NULL_DATETIME;
$location = '';
$about = '';
$keywords = '';
/**
* @brief Transmit given data to a target for a user
*
- * @param $data
- * @param $target
- * @param $uid
+ * @param array $data Data that is about to be send
+ * @param string $target The URL of the inbox
+ * @param integer $uid User id of the sender
+ *
+ * @return boolean Was the transmission successful?
*/
public static function transmit($data, $target, $uid)
{
$headers[] = 'Content-Type: application/activity+json';
$postResult = Network::post($target, $content, $headers);
+ $return_code = $postResult->getReturnCode();
+
+ logger('Transmit to ' . $target . ' returned ' . $return_code);
- logger('Transmit to ' . $target . ' returned ' . $postResult->getReturnCode());
+ return ($return_code >= 200) && ($return_code <= 299);
}
/**
}
$data = jsonld_default_document_loader($url);
- Cache::set('documentLoader:' . $url, $data, CACHE_DAY);
+ Cache::set('documentLoader:' . $url, $data, Cache::DAY);
return $data;
}
'ostatus' => (object)['@id' => 'http://ostatus.org#', '@type' => '@id'],
'diaspora' => (object)['@id' => 'https://diasporafoundation.org/ns/', '@type' => '@id'],
'dc' => (object)['@id' => 'http://purl.org/dc/terms/', '@type' => '@id'],
- 'uuid' => (object)['@id' => 'http://schema.org/identifier', '@type' => '@id']];
+ 'ldp' => (object)['@id' => 'http://www.w3.org/ns/ldp#', '@type' => '@id']];
$jsonobj = json_decode(json_encode($json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
public static function lookupAvatarByEmail($email)
{
- $avatar['size'] = 175;
+ $avatar['size'] = 300;
$avatar['email'] = $email;
$avatar['url'] = '';
$avatar['success'] = false;
Addon::callHooks('avatar_lookup', $avatar);
if (! $avatar['success']) {
- $avatar['url'] = System::baseUrl() . '/images/person-175.jpg';
+ $avatar['url'] = System::baseUrl() . '/images/person-300.jpg';
}
logger('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], LOGGER_DEBUG);
}
// If the file is too large then exit
- if ($curlResult->getInfo()['download_content_length'] > 1000000) {
+ if (defaults($curlResult->getInfo(), 'download_content_length', 0) > 1000000) {
return $siteinfo;
}
use Friendica\Core\Config;
use Friendica\Core\System;
-require_once 'include/security.php';
-
/**
* @brief Proxy utilities class
*/
--- /dev/null
+<?php
+/**
+ * @file /src/Util/Security.php
+ */
+
+namespace Friendica\Util;
+
+use Friendica\BaseObject;
+use Friendica\Database\DBA;
+use Friendica\Model\Contact;
+use Friendica\Model\Group;
+use Friendica\Core\L10n;
+use Friendica\Model\PermissionSet;
+use Friendica\Core\System;
+
+/**
+ * Secures that User is allow to do requests
+ */
+class Security extends BaseObject
+{
+ public static function canWriteToUserWall($owner)
+ {
+ static $verified = 0;
+
+ if (!local_user() && !remote_user()) {
+ return false;
+ }
+
+ $uid = local_user();
+ if ($uid == $owner) {
+ return true;
+ }
+
+ if (local_user() && ($owner == 0)) {
+ return true;
+ }
+
+ if (remote_user()) {
+ // use remembered decision and avoid a DB lookup for each and every display item
+ // DO NOT use this function if there are going to be multiple owners
+ // We have a contact-id for an authenticated remote user, this block determines if the contact
+ // belongs to this page owner, and has the necessary permissions to post content
+
+ if ($verified === 2) {
+ return true;
+ } elseif ($verified === 1) {
+ return false;
+ } else {
+ $cid = 0;
+
+ if (!empty($_SESSION['remote'])) {
+ foreach ($_SESSION['remote'] as $visitor) {
+ if ($visitor['uid'] == $owner) {
+ $cid = $visitor['cid'];
+ break;
+ }
+ }
+ }
+
+ if (!$cid) {
+ return false;
+ }
+
+ $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `user`.`uid` = `contact`.`uid`
+ WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ AND `user`.`blockwall` = 0 AND `readonly` = 0 AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page-flags` = %d ) LIMIT 1",
+ intval($owner),
+ intval($cid),
+ intval(Contact::SHARING),
+ intval(Contact::FRIEND),
+ intval(Contact::PAGE_COMMUNITY)
+ );
+
+ if (DBA::isResult($r)) {
+ $verified = 2;
+ return true;
+ } else {
+ $verified = 1;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /// @TODO $groups should be array
+ public static function getPermissionsSQLByUserId($owner_id, $remote_verified = false, $groups = null)
+ {
+ $local_user = local_user();
+ $remote_user = remote_user();
+
+ /*
+ * Construct permissions
+ *
+ * default permissions - anonymous user
+ */
+ $sql = " AND allow_cid = ''
+ AND allow_gid = ''
+ AND deny_cid = ''
+ AND deny_gid = ''
+ ";
+
+ /*
+ * Profile owner - everything is visible
+ */
+ if ($local_user && $local_user == $owner_id) {
+ $sql = '';
+ /*
+ * Authenticated visitor. Unless pre-verified,
+ * check that the contact belongs to this $owner_id
+ * and load the groups the visitor belongs to.
+ * If pre-verified, the caller is expected to have already
+ * done this and passed the groups into this function.
+ */
+ } elseif ($remote_user) {
+ /*
+ * Authenticated visitor. Unless pre-verified,
+ * check that the contact belongs to this $owner_id
+ * and load the groups the visitor belongs to.
+ * If pre-verified, the caller is expected to have already
+ * done this and passed the groups into this function.
+ */
+
+ if (!$remote_verified) {
+ if (DBA::exists('contact', ['id' => $remote_user, 'uid' => $owner_id, 'blocked' => false])) {
+ $remote_verified = true;
+ $groups = Group::getIdsByContactId($remote_user);
+ }
+ }
+
+ if ($remote_verified) {
+ $gs = '<<>>'; // should be impossible to match
+
+ if (is_array($groups)) {
+ foreach ($groups as $g) {
+ $gs .= '|<' . intval($g) . '>';
+ }
+ }
+
+ $sql = sprintf(
+ " AND ( NOT (deny_cid REGEXP '<%d>' OR deny_gid REGEXP '%s')
+ AND ( allow_cid REGEXP '<%d>' OR allow_gid REGEXP '%s' OR ( allow_cid = '' AND allow_gid = '') )
+ )
+ ",
+ intval($remote_user),
+ DBA::escape($gs),
+ intval($remote_user),
+ DBA::escape($gs)
+ );
+ }
+ }
+ return $sql;
+ }
+
+}
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Database\DBA;
require_once 'boot.php';
require_once 'include/text.php';
// First day of the week (0 = Sunday)
$firstDay = PConfig::get(local_user(), 'system', 'first_day_of_week', 0);
- $lang = substr(L10n::getBrowserLanguage(), 0, 2);
+ $lang = substr(L10n::getCurrentLang(), 0, 2);
// Check if the detected language is supported by the picker
if (!in_array($lang,
["ar", "ro", "id", "bg", "fa", "ru", "uk", "en", "el", "de", "nl", "tr", "fr", "es", "th", "pl", "pt", "ch", "se", "kr",
"it", "da", "no", "ja", "vi", "sl", "cs", "hu"])) {
- $lang = Config::get('system', 'language', 'en');
+ $lang = 'en';
}
$o = '';
$abs = strtotime($localtime);
- if (is_null($posted_date) || $posted_date <= NULL_DATE || $abs === false) {
+ if (is_null($posted_date) || $posted_date <= DBA::NULL_DATETIME || $abs === false) {
return L10n::t('never');
}
use Friendica\BaseObject;
use Friendica\Protocol\ActivityPub;
use Friendica\Model\Item;
+use Friendica\Core\Worker;
use Friendica\Util\HTTPSignature;
class APDelivery extends BaseObject
{
logger('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $inbox, LOGGER_DEBUG);
+ $success = true;
+
if ($cmd == Delivery::MAIL) {
} elseif ($cmd == Delivery::SUGGESTION) {
- ActivityPub\Transmitter::sendContactSuggestion($uid, $inbox, $item_id);
+ $success = ActivityPub\Transmitter::sendContactSuggestion($uid, $inbox, $item_id);
} elseif ($cmd == Delivery::RELOCATION) {
} elseif ($cmd == Delivery::REMOVAL) {
- ActivityPub\Transmitter::sendProfileDeletion($uid, $inbox);
+ $success = ActivityPub\Transmitter::sendProfileDeletion($uid, $inbox);
} elseif ($cmd == Delivery::PROFILEUPDATE) {
- ActivityPub\Transmitter::sendProfileUpdate($uid, $inbox);
+ $success = ActivityPub\Transmitter::sendProfileUpdate($uid, $inbox);
} else {
$data = ActivityPub\Transmitter::createCachedActivityFromItem($item_id);
if (!empty($data)) {
- HTTPSignature::transmit($data, $inbox, $uid);
+ $success = HTTPSignature::transmit($data, $inbox, $uid);
}
}
+
+ if (!$success) {
+ Worker::defer();
+ }
}
}
use Friendica\BaseObject;
use Friendica\Core\Addon;
use Friendica\Core\Config;
+use Friendica\Core\Hook;
use Friendica\Core\Protocol;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
logger('cron: start');
// Fork the cron jobs in separate parts to avoid problems when one of them is crashing
- Addon::forkHooks($a->queue['priority'], "cron");
+ Hook::fork($a->queue['priority'], "cron");
// run queue delivery process in the background
Worker::add(PRIORITY_NEGLIGIBLE, "Queue");
foreach ($contacts as $contact) {
if ($manual_id) {
- $contact['last-update'] = NULL_DATE;
+ $contact['last-update'] = DBA::NULL_DATETIME;
}
// Friendica and OStatus are checked once a day
private static function expireAndRemoveUsers()
{
// expire any expired regular accounts. Don't expire forums.
- $condition = ["NOT `account_expired` AND `account_expires_on` > ? AND `account_expires_on` < UTC_TIMESTAMP() AND `page-flags` = 0", NULL_DATE];
+ $condition = ["NOT `account_expired` AND `account_expires_on` > ? AND `account_expires_on` < UTC_TIMESTAMP() AND `page-flags` = 0", DBA::NULL_DATETIME];
DBA::update('user', ['account_expired' => true], $condition);
// Remove any freshly expired account
$count = 0;
// We split the deletion in many small tasks
- $limit = 1000;
+ $limit = Config::get('system', 'dbclean-expire-limit', 1000);
// Get the expire days for step 8 and 9
$days = Config::get('system', 'dbclean-expire-days', 0);
OR (`item`.`file` != '') OR (`item`.`event-id` != '')
OR (`item`.`attach` != '') OR `item`.`wall` OR `item`.`origin`)
AND `item`.`parent` = `thread`.`iid`)
- ORDER BY `thread`.`iid` LIMIT 1000", $days, $last_id);
+ ORDER BY `thread`.`iid` LIMIT ?", $days, $last_id, $limit);
$count = DBA::numRows($r);
if ($count > 0) {
logger("found expired threads: ".$count);
$followup = false;
$public_message = false;
+ $items = [];
if ($cmd == self::MAIL) {
$target_item = DBA::selectFirst('mail', [], ['id' => $item_id]);
if (!DBA::isResult($target_item)) {
return;
}
$uid = $target_item['uid'];
- $items = [];
} elseif ($cmd == self::SUGGESTION) {
$target_item = DBA::selectFirst('fsuggest', [], ['id' => $item_id]);
if (!DBA::isResult($target_item)) {
$uid = $target_item['uid'];
} elseif ($cmd == self::RELOCATION) {
$uid = $item_id;
+ $target_item = [];
} else {
$item = Item::selectFirst(['parent'], ['id' => $item_id]);
if (!DBA::isResult($item) || empty($item['parent'])) {
$params = ['order' => ['id']];
$itemdata = Item::select([], $condition, $params);
- $items = [];
while ($item = Item::fetch($itemdata)) {
if ($item['id'] == $parent_id) {
$parent = $item;
}
}
}
- Cache::set("dirsearch:".$search, time(), CACHE_DAY);
+ Cache::set("dirsearch:".$search, time(), Cache::DAY);
}
/**
namespace Friendica\Worker;
use Friendica\BaseObject;
-use Friendica\Core\Addon;
use Friendica\Core\Config;
+use Friendica\Core\Hook;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model\Item;
class Expire
{
- public static function execute($param = '', $hook_name = '')
+ public static function execute($param = '', $hook_function = '')
{
$a = BaseObject::getApp();
require_once 'include/items.php';
- Addon::loadHooks();
+ Hook::loadHooks();
if ($param == 'delete') {
logger('Delete expired items', LOGGER_DEBUG);
logger('Expire items for user '.$user['uid'].' ('.$user['username'].') - done ', LOGGER_DEBUG);
}
return;
- } elseif (!empty($hook_name) && ($param == 'hook') && is_array($a->hooks) && array_key_exists("expire", $a->hooks)) {
- foreach ($a->hooks["expire"] as $hook) {
- if ($hook[1] == $hook_name) {
+ } elseif ($param == 'hook' && !empty($hook_function)) {
+ foreach (Hook::getByName('expire') as $hook) {
+ if ($hook[1] == $hook_function) {
logger("Calling expire hook '" . $hook[1] . "'", LOGGER_DEBUG);
- Addon::callSingleHook($a, $hook_name, $hook, $data);
+ Hook::callSingle($a, 'expire', $hook, $data);
}
}
return;
DBA::close($r);
logger('expire: calling hooks');
-
- if (is_array($a->hooks) && array_key_exists('expire', $a->hooks)) {
- foreach ($a->hooks['expire'] as $hook) {
- logger("Calling expire hook for '" . $hook[1] . "'", LOGGER_DEBUG);
- Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
- 'Expire', 'hook', $hook[1]);
- }
+ foreach (Hook::getByName('expire') as $hook) {
+ logger("Calling expire hook for '" . $hook[1] . "'", LOGGER_DEBUG);
+ Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
+ 'Expire', 'hook', $hook[1]);
}
logger('expire: end');
namespace Friendica\Worker;
-use Friendica\Core\Addon;
+use Friendica\Core\Hook;
Class ForkHook
{
{
$a = \Friendica\BaseObject::getApp();
- Addon::callSingleHook($a, $name, $hook, $data);
+ Hook::callSingle($a, $name, $hook, $data);
}
}
use Friendica\BaseObject;
use Friendica\Core\Addon;
use Friendica\Core\Config;
+use Friendica\Core\Hook;
use Friendica\Core\Protocol;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
+use Friendica\Model\Conversation;
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\PushSubscriber;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\OStatus;
use Friendica\Protocol\Salmon;
-use Friendica\Model\Conversation;
require_once 'include/dba.php';
require_once 'include/items.php';
logger('notifier: calling hooks for ' . $cmd . ' ' . $item_id, LOGGER_DEBUG);
if ($normal_mode) {
- Addon::forkHooks($a->queue['priority'], 'notifier_normal', $target_item);
+ Hook::fork($a->queue['priority'], 'notifier_normal', $target_item);
}
Addon::callHooks('notifier_end',$target_item);
private static function activityPubDelivery($a, $cmd, $item_id, $uid, $target_item, $parent)
{
$inboxes = [];
+ $personal = false;
if ($target_item['origin']) {
$inboxes = ActivityPub\Transmitter::fetchTargetInboxes($target_item, $uid);
logger('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' is no AP post. It will not be distributed.', LOGGER_DEBUG);
return;
} else {
+ // Remote items are transmitted via the personal inboxes.
+ // Doing so ensures that the dedicated receiver will get the message.
+ $personal = true;
logger('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' will be distributed.', LOGGER_DEBUG);
}
if ($parent['origin']) {
- $parent_inboxes = ActivityPub\Transmitter::fetchTargetInboxes($parent, $uid);
+ $parent_inboxes = ActivityPub\Transmitter::fetchTargetInboxes($parent, $uid, $personal);
$inboxes = array_merge($inboxes, $parent_inboxes);
}
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Item;
-use Friendica\Protocol\Email;
use Friendica\Protocol\ActivityPub;
+use Friendica\Protocol\Email;
use Friendica\Protocol\PortableContact;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
$hub_update = false;
}
- $last_update = (($contact['last-update'] <= NULL_DATE)
+ $last_update = (($contact['last-update'] <= DBA::NULL_DATETIME)
? DateTimeFormat::utc('now - 7 days', DateTimeFormat::ATOM)
: DateTimeFormat::utc($contact['last-update'], DateTimeFormat::ATOM)
);
}
}
+ if (!in_array($contact['network'], [Protocol::FEED, Protocol::MAIL]) && Config::get('system', 'disable_polling')) {
+ return;
+ }
+
if ($importer_uid == 0) {
logger('Ignore public contacts');
self::updateContact($contact, $fields);
Contact::markForArchival($contact);
- } elseif ($contact['term-date'] > NULL_DATE) {
+ } elseif ($contact['term-date'] > DBA::NULL_DATETIME) {
logger("$url back from the dead - removing mark for death");
Contact::unmarkForArchival($contact);
}
} elseif ($contact['network'] === Protocol::MAIL) {
logger("Mail: Fetching for ".$contact['addr'], LOGGER_DEBUG);
- $mail_disabled = ((function_exists('imap_open') && (! Config::get('system', 'imap_disabled'))) ? 0 : 1);
+ $mail_disabled = ((function_exists('imap_open') && !Config::get('system', 'imap_disabled')) ? 0 : 1);
if ($mail_disabled) {
// set the last-update so we don't keep polling
DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
if ($datarray['parent-uri'] === $datarray['uri']) {
$datarray['private'] = 1;
}
- if (($contact['network'] === Protocol::MAIL) && (!PConfig::get($importer_uid, 'system', 'allow_public_email_replies'))) {
+ if (($contact['network'] === Protocol::MAIL) && !PConfig::get($importer_uid, 'system', 'allow_public_email_replies')) {
$datarray['private'] = 1;
$datarray['allow_cid'] = '<' . $contact['id'] . '>';
}
logger("Check server " . $server . " (" . $contact["network"] . ")");
$vital = PortableContact::checkServer($server, $contact["network"], true);
- Cache::set($cachekey_server . $server, $vital, CACHE_MINUTE);
+ Cache::set($cachekey_server . $server, $vital, Cache::MINUTE);
}
if (!is_null($vital) && !$vital) {
QueueModel::removeItem($q_item['id']);
} else {
QueueModel::updateTime($q_item['id']);
- Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_MINUTE);
+ Cache::set($cachekey_deadguy . $contact['notify'], true, Cache::MINUTE);
}
break;
if ($deliver_status == -1) {
QueueModel::updateTime($q_item['id']);
- Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_MINUTE);
+ Cache::set($cachekey_deadguy . $contact['notify'], true, Cache::MINUTE);
} else {
QueueModel::removeItem($q_item['id']);
}
QueueModel::removeItem($q_item['id']);
} else {
QueueModel::updateTime($q_item['id']);
- Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_MINUTE);
+ Cache::set($cachekey_deadguy . $contact['notify'], true, Cache::MINUTE);
}
break;
use Friendica\Database\DBA;
use Friendica\Core\Protocol;
+use Friendica\Model\Item;
require_once 'include/dba.php';
// Only delete if the contact is to be deleted
$condition = ['network' => Protocol::PHANTOM, 'id' => $id];
- $r = DBA::exists('contact', $condition);
- if (!DBA::isResult($r)) {
+ $contact = DBA::selectFirst('contact', ['uid'], $condition);
+ if (!DBA::isResult($contact)) {
return;
}
// Now we delete the contact and all depending tables
+ $condition = ['uid' => $contact['uid'], 'contact-id' => $id];
+ do {
+ $items = Item::select(['id'], $condition, ['limit' => 100]);
+ while ($item = Item::fetch($items)) {
+ DBA::delete('item', ['id' => $item['id']]);
+ }
+ DBA::close($items);
+ } while (Item::exists($condition));
+
DBA::delete('contact', ['id' => $id]);
}
}
}
// Now we delete all user items
- Item::delete(['uid' => $uid], PRIORITY_LOW);
+ $condition = ['uid' => $uid, 'deleted' => false];
+ do {
+ $items = Item::select(['id'], $condition, ['limit' => 100]);
+ while ($item = Item::fetch($items)) {
+ Item::deleteById($item['id'], PRIORITY_LOW);
+ }
+ DBA::close($items);
+ } while (Item::exists($condition));
}
}
use Friendica\Core\System;
use Friendica\Network\HTTPException;
+require_once __DIR__ . '/../include/api.php';
+
/**
* Tests for the API functions.
*
*/
class ApiTest extends DatabaseTest
{
-
/**
* Create variables used by tests.
*/
{
parent::setUp();
- require_once __DIR__.'/../include/api.php';
+ $this->app = BaseObject::getApp();
// User data that the test database is populated with
$this->selfUser = [
'uid' => $this->selfUser['id']
];
+ Config::set('system', 'url', 'http://localhost');
+ Config::set('system', 'hostname', 'localhost');
+ Config::set('system', 'worker_dont_fork', true);
+
// Default config
Config::set('config', 'hostname', 'localhost');
Config::set('system', 'throttle_limit_day', 100);
*/
public function testApiFriendicaRemoteauthWithCorrectUrl()
{
- $this->markTestIncomplete("We can't use an assertion here because of goaway().");
+ $this->markTestIncomplete("We can't use an assertion here because of App->redirect().");
$_GET['url'] = 'url';
$_GET['c_url'] = $this->selfUser['nurl'];
api_friendica_remoteauth();
use PHPUnit\Framework\TestCase;
use PHPUnit_Extensions_Database_DB_IDatabaseConnection;
+require_once __DIR__ . '/../boot.php';
+
/**
* Abstract class used by tests that need a database.
*/
{
use TestCaseTrait;
- /**
- * @var App The Friendica App
- */
- protected $app;
-
- protected function setUp()
- {
- // Reusable App object
- $this->app = BaseObject::getApp();
-
- Config::set('system', 'url', 'http://localhost');
- Config::set('system', 'hostname', 'localhost');
- Config::set('system', 'worker_dont_fork', true);
- }
-
/**
* Get database connection.
*
$this->markTestSkipped('Please set the MYSQL_* environment variables to your test database credentials.');
}
+ DBA::connect(getenv('MYSQL_HOST'),
+ getenv('MYSQL_USERNAME'),
+ getenv('MYSQL_PASSWORD'),
+ getenv('MYSQL_DATABASE'));
+
if (!DBA::connected()) {
$this->markTestSkipped('Could not connect to the database.');
}
$this->setConfigFile('config.ini.php');
$this->setConfigFile('settings.ini.php');
$this->setConfigFile('local.ini.php');
- $this->setConfigFile('dbstructure.json');
+ $this->setConfigFile('dbstructure.php');
}
protected function setConfigFile($filename)
$this->assertConfig('database', 'database', $this->db_data);
$this->assertConfig('config', 'admin_email', 'admin@friendica.local');
$this->assertConfig('system', 'default_timezone', 'Europe/Berlin');
- $this->assertConfig('system', 'language', 'de');
+ // TODO language changes back to en
+ //$this->assertConfig('system', 'language', 'de');
}
-
/**
* @medium
*/
$this->assertConfig('database', 'database', '');
$this->assertConfig('config', 'admin_email', 'admin@friendica.local');
$this->assertConfig('system', 'default_timezone', 'Europe/Berlin');
- $this->assertConfig('system', 'language', 'de');
$this->assertConfig('system', 'urlpath', '/friendica');
+ // TODO language changes back to en
+ //$this->assertConfig('system', 'language', 'de');
}
/**
$this->assertConfig('database', 'database', $this->db_data);
$this->assertConfig('config', 'admin_email', 'admin@friendica.local');
$this->assertConfig('system', 'default_timezone', 'Europe/Berlin');
- $this->assertConfig('system', 'language', 'de');
$this->assertConfig('system', 'urlpath', '/friendica');
+ // TODO language changes back to en
+ //$this->assertConfig('system', 'language', 'de');
}
/**
* @runTestsInSeparateProcesses
+ * @preserveGlobalState disabled
*/
public function testNoDatabaseConnection()
{
+ // TODO DBA mocking for whole console tests make this test work again
+ $this->markTestSkipped('DBA is already loaded, we have to mock the whole App to make it work');
+
$dbaMock = \Mockery::mock('alias:Friendica\Database\DBA');
$dbaMock
->shouldReceive('connected')
use Friendica\Test\Util\VFSTrait;
use PHPUnit\Framework\TestCase;
+/**
+ * @runTestsInSeparateProcesses
+ * @preserveGlobalState disabled
+ */
class InstallTest extends TestCase
{
use VFSTrait;
};
}
+ /**
+ * Replaces class_exist results with given mocks
+ *
+ * @param array $classes a list from class names and their results
+ */
+ private function setClasses($classes)
+ {
+ global $phpMock;
+ $phpMock['class_exists'] = function($class) use ($classes) {
+ foreach ($classes as $name => $value) {
+ if ($class == $name) {
+ return $value;
+ }
+ }
+ return '__phpunit_continue__';
+ };
+ }
+
/**
* @small
- * @runInSeparateProcess
*/
public function testCheckKeys()
{
/**
* @small
- * @runInSeparateProcess
*/
public function testCheckFunctions()
{
/**
* @small
- * @runInSeparateProcess
*/
public function testCheckLocalIni()
{
/**
* @small
- * @runInSeparateProcess
*/
public function testCheckHtAccessFail()
{
/**
* @small
- * @runInSeparateProcess
*/
public function testCheckHtAccessWork()
{
/**
* @small
- * @runInSeparateProcess
*/
public function testImagick()
{
->shouldReceive('supportedTypes')
->andReturn(['image/gif' => 'gif']);
+ $this->setClasses(['Imagick' => true]);
+
$install = new Install();
// even there is no supported type, Imagick should return true (because it is not required)
$this->assertTrue($install->checkImagick());
+
$this->assertCheckExist(1,
L10n::t('ImageMagick supports GIF'),
'',
/**
* @small
- * @runInSeparateProcess
*/
public function testImagickNotFound()
{
->shouldReceive('supportedTypes')
->andReturn([]);
+ $this->setClasses(['Imagick' => true]);
+
$install = new Install();
// even there is no supported type, Imagick should return true (because it is not required)
false,
$install->getChecks());
}
+
+ public function testImagickNotInstalled()
+ {
+ $this->setClasses(['Imagick' => false]);
+
+ $install = new Install();
+
+ // even there is no supported type, Imagick should return true (because it is not required)
+ $this->assertTrue($install->checkImagick());
+ $this->assertCheckExist(0,
+ L10n::t('ImageMagick PHP extension is not installed'),
+ '',
+ false,
+ false,
+ $install->getChecks());
+ }
}
/**
}
return call_user_func_array('\function_exists', func_get_args());
}
+
+function class_exists($class_name)
+{
+ global $phpMock;
+ if (isset($phpMock['class_exists'])) {
+ $result = call_user_func_array($phpMock['class_exists'], func_get_args());
+ if ($result !== '__phpunit_continue__') {
+ return $result;
+ }
+ }
+ return call_user_func_array('\class_exists', func_get_args());
+}
$guid = System::createGUID(23, 'test');
$this->assertGuid($guid, 23, 'test');
}
-}
\ No newline at end of file
+}
* This function is responsible for doing post update changes to the data
* (not the structure) in the database.
*
- * Database structure changes are done in src/Database/DBStructure.php
+ * Database structure changes are done in config/dbstructure.php
*
* If there is a need for a post process to a structure change, update this file
* by adding a new function at the end with the number of the new DB_UPDATE_VERSION.
* You are currently on version 4711 and you are preparing changes that demand an update script.
*
* 1. Create a function "update_4712()" here in the update.php
- * 2. Apply the needed structural changes in src/Database/DBStructure.php
- * 3. Set DB_UPDATE_VERSION in boot.php to 4712.
+ * 2. Apply the needed structural changes in config/dbStructure.php
+ * 3. Set DB_UPDATE_VERSION in config/dbstructure.php to 4712.
*
* If you need to run a script before the database update, name the function "pre_update_4712()"
*/
return UPDATE_SUCCESS;
}
+
+function update_1288() {
+ // Updates missing `uri-id` values
+
+ DBA::e("UPDATE `item-activity` INNER JOIN `item` ON `item`.`iaid` = `item-activity`.`id` SET `item-activity`.`uri-id` = `item`.`uri-id` WHERE `item-activity`.`uri-id` IS NULL OR `item-activity`.`uri-id` = 0");
+ DBA::e("UPDATE `item-content` INNER JOIN `item` ON `item`.`icid` = `item-content`.`id` SET `item-content`.`uri-id` = `item`.`uri-id` WHERE `item-content`.`uri-id` IS NULL OR `item-content`.`uri-id` = 0");
+
+ return UPDATE_SUCCESS;
+}
<dl>
<dt>{{$queues.label}}</dt>
- <dd><a href="{{$baseurl}}/admin/queue">{{$queues.queue}}</a> - <a href="{{$baseurl}}/admin/workerqueue">{{$queues.workerq}}</a></dd>
+ <dd><a href="{{$baseurl}}/admin/queue">{{$queues.queue}}</a> - <a href="{{$baseurl}}/admin/deferred">{{$queues.deferred}} - <a href="{{$baseurl}}/admin/workerqueue">{{$queues.workerq}}</a></dd>
</dl>
<dl>
<dt>{{$pending.0}}</dt>
<div id="contact-edit-nav-wrapper" >
- <form action="contacts/{{$contact_id}}" method="post" >
+ <form action="contact/{{$contact_id}}" method="post" >
<div id="contact-edit-links">
<div id="contact-edit-status-wrapper">
<span id="contact-edit-contact-status">{{$contact_status}}</span>
--- /dev/null
+<h2>Item Source</h2>
+<form action="itemsource" method="get" class="panel panel-default">
+ <div class="panel-body">
+ <div class="form-group">
+ {{include file="field_input.tpl" field=$guid}}
+ </div>
+ <p><button type="submit" class="btn btn-primary">Submit</button></p>
+ </div>
+</form>
+
+{{if $source}}
+<div class="itemsource-results">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h3 class="panel-title">Item URI</h3>
+ </div>
+ <div class="panel-body">
+ {{$item_uri}}
+ </div>
+ </div>
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h3 class="panel-title">Source</h3>
+ </div>
+ <pre><code class="language-php">{{$source}}</code></pre>
+ </div>
+</div>
+{{/if}}
.fbrowser.image .photo-album-image-wrapper {
box-shadow: 2px 2px 5px 0px rgba(0, 0, 0, 0.2);
}
+.fbrowser.image .photo-album-image-wrapper .caption {
+ pointer-events: none;
+}
.fbrowser .profile-rotator-wrapper {
min-height: 200px;
}
{{* The work queues short statistic. *}}
<div id="admin-summary-queues" class="col-lg-12 col-md-12 col-sm-12 col-xs-12 admin-summary">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12 admin-summary-label-name text-muted">{{$queues.label}}</div>
- <div class="col-lg-8 col-md-8 col-sm-8 col-xs-12 admin-summary-entry"><a href="{{$baseurl}}/admin/queue">{{$queues.queue}}</a> - <a href="{{$baseurl}}/admin/workerqueue">{{$queues.workerq}}</a></div>
+ <div class="col-lg-8 col-md-8 col-sm-8 col-xs-12 admin-summary-entry"><a href="{{$baseurl}}/admin/queue">{{$queues.queue}}</a> - <a href="{{$baseurl}}/admin/deferred">{{$queues.deferred}} - <a href="{{$baseurl}}/admin/workerqueue">{{$queues.workerq}}</a></div>
</div>
{{* Number of pending registrations. *}}
<div id="contact-edit-content-wrapper">
- <form action="contacts/{{$contact_id}}" method="post" >
+ <form action="contact/{{$contact_id}}" method="post" >
{{* This is the Action menu where contact related actions like 'ignore', 'hide' can be performed *}}
<ul id="contact-edit-actions" class="nav nav-pills preferences">
--- /dev/null
+<div id="credits" class="generic-page-wrapper">
+ {{include file="section_title.tpl"}}
+ <p>{{$thanks}}</p>
+
+ <ul class="credits">
+ {{foreach $names as $name}}
+ <li>{{$name}}</li>
+ {{/foreach}}
+ </ul>
+ <div class="clear"></div>
+</div>
<div id="contact-edit-nav-wrapper" >
- <form action="contacts/{{$contact_id}}" method="post" >
+ <form action="contact/{{$contact_id}}" method="post" >
<div id="contact-edit-links">
<div id="contact-edit-status-wrapper">
<span id="contact-edit-contact-status">{{$contact_status}}</span>