aboutsummaryrefslogtreecommitdiffstats
path: root/boot.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-01-28 13:29:25 +0000
committerMario <mario@mariovavti.com>2022-01-28 13:29:25 +0000
commit4c82952b580f8fc93c4cea4648372368464724ed (patch)
tree155a9acc6c849ff0f94b5ba4283e546d67a0d580 /boot.php
parent0da69cb9c772dce33496a9ea642fab89195277a3 (diff)
downloadvolse-hubzilla-4c82952b580f8fc93c4cea4648372368464724ed.tar.gz
volse-hubzilla-4c82952b580f8fc93c4cea4648372368464724ed.tar.bz2
volse-hubzilla-4c82952b580f8fc93c4cea4648372368464724ed.zip
formatting and unused variables
Diffstat (limited to 'boot.php')
-rw-r--r--boot.php1621
1 files changed, 814 insertions, 807 deletions
diff --git a/boot.php b/boot.php
index a5afc3ad4..15c68f875 100644
--- a/boot.php
+++ b/boot.php
@@ -28,7 +28,12 @@
*/
// composer autoloader for all namespaced Classes
-use Zotlabs\Lib\Crypto;
+
+use Zotlabs\Access\PermissionLimits;
+use Zotlabs\Access\PermissionRoles;
+use Zotlabs\Access\Permissions;
+use Zotlabs\Daemon\Master;
+use Zotlabs\Lib\DB_Upgrade;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Config;
@@ -54,13 +59,13 @@ require_once('include/attach.php');
require_once('include/bbcode.php');
require_once('include/items.php');
-define ( 'PLATFORM_NAME', 'hubzilla' );
-define ( 'STD_VERSION', '7.1' );
-define ( 'ZOT_REVISION', '6.0' );
+define('PLATFORM_NAME', 'hubzilla');
+define('STD_VERSION', '7.1');
+define('ZOT_REVISION', '6.0');
-define ( 'DB_UPDATE_VERSION', 1252 );
+define('DB_UPDATE_VERSION', 1252);
-define ( 'PROJECT_BASE', __DIR__ );
+define('PROJECT_BASE', __DIR__);
/**
* @brief Constant with a HTML line break.
@@ -69,23 +74,23 @@ define ( 'PROJECT_BASE', __DIR__ );
* feed for the source.
* This can be used in HTML and JavaScript where needed a line break.
*/
-define ( 'EOL', '<br>' . "\r\n" );
-define ( 'EMPTY_STR', '' );
-define ( 'ATOM_TIME', 'Y-m-d\\TH:i:s\\Z' ); // aka ISO 8601 "Zulu"
-define ( 'TEMPLATE_BUILD_PATH', 'store/[data]/smarty3' );
+define('EOL', '<br>' . "\r\n");
+define('EMPTY_STR', '');
+define('ATOM_TIME', 'Y-m-d\\TH:i:s\\Z'); // aka ISO 8601 "Zulu"
+define('TEMPLATE_BUILD_PATH', 'store/[data]/smarty3');
-define ( 'DIRECTORY_MODE_NORMAL', 0x0000); // A directory client
-define ( 'DIRECTORY_MODE_PRIMARY', 0x0001); // There can only be *one* primary directory server in a directory_realm.
-define ( 'DIRECTORY_MODE_SECONDARY', 0x0002); // All other mirror directory servers
-define ( 'DIRECTORY_MODE_STANDALONE', 0x0100); // A detached (off the grid) hub with itself as directory server.
+define('DIRECTORY_MODE_NORMAL', 0x0000); // A directory client
+define('DIRECTORY_MODE_PRIMARY', 0x0001); // There can only be *one* primary directory server in a directory_realm.
+define('DIRECTORY_MODE_SECONDARY', 0x0002); // All other mirror directory servers
+define('DIRECTORY_MODE_STANDALONE', 0x0100); // A detached (off the grid) hub with itself as directory server.
// We will look for upstream directories whenever me make contact
// with other sites, but if this is a new installation and isn't
// a standalone hub, we need to seed the service with a starting
// point to go out and find the rest of the world.
-define ( 'DIRECTORY_REALM', 'RED_GLOBAL');
-define ( 'DIRECTORY_FALLBACK_MASTER', 'https://hub.netzgemeinde.eu');
+define('DIRECTORY_REALM', 'RED_GLOBAL');
+define('DIRECTORY_FALLBACK_MASTER', 'https://hub.netzgemeinde.eu');
function get_directory_fallback_servers() {
@@ -107,23 +112,23 @@ function get_directory_fallback_servers() {
* in .htconfig.php, where n is netween 1 and 100, and with very poor results
* below about 50
*/
-define ( 'JPEG_QUALITY', 100 );
+define('JPEG_QUALITY', 100);
/**
* App::$config['system']['png_quality'] from 0 (uncompressed) to 9
*/
-define ( 'PNG_QUALITY', 8 );
+define('PNG_QUALITY', 8);
/**
* App::$config['system']['webp_quality'] from 1 (maximum compressed) to 100 (uncompressed)
*/
-define ( 'WEBP_QUALITY', 80 );
+define('WEBP_QUALITY', 80);
/**
* Language detection parameters
*/
-define ( 'LANGUAGE_DETECT_MIN_LENGTH', 128 );
-define ( 'LANGUAGE_DETECT_MIN_CONFIDENCE', 0.01 );
+define('LANGUAGE_DETECT_MIN_LENGTH', 128);
+define('LANGUAGE_DETECT_MIN_CONFIDENCE', 0.01);
/**
@@ -138,8 +143,8 @@ define ( 'LANGUAGE_DETECT_MIN_CONFIDENCE', 0.01 );
* either more or less restrictive.
*/
-if(! defined('STORAGE_DEFAULT_PERMISSIONS')) {
- define ( 'STORAGE_DEFAULT_PERMISSIONS', 0770 );
+if (!defined('STORAGE_DEFAULT_PERMISSIONS')) {
+ define('STORAGE_DEFAULT_PERMISSIONS', 0770);
}
@@ -159,49 +164,49 @@ if(! defined('STORAGE_DEFAULT_PERMISSIONS')) {
* defined by 'MAX_IMAGE_LENGTH' below.
*
*/
-define ( 'MAX_IMAGE_LENGTH', -1 );
+define('MAX_IMAGE_LENGTH', -1);
/**
* log levels
*/
-define ( 'LOGGER_NORMAL', 0 );
-define ( 'LOGGER_TRACE', 1 );
-define ( 'LOGGER_DEBUG', 2 );
-define ( 'LOGGER_DATA', 3 );
-define ( 'LOGGER_ALL', 4 );
+define('LOGGER_NORMAL', 0);
+define('LOGGER_TRACE', 1);
+define('LOGGER_DEBUG', 2);
+define('LOGGER_DATA', 3);
+define('LOGGER_ALL', 4);
/**
* registration policies
*/
-define ( 'REGISTER_CLOSED', 0 );
-define ( 'REGISTER_APPROVE', 1 );
-define ( 'REGISTER_OPEN', 2 );
+define('REGISTER_CLOSED', 0);
+define('REGISTER_APPROVE', 1);
+define('REGISTER_OPEN', 2);
/**
* site access policy
*/
-define ( 'ACCESS_PRIVATE', 0 );
-define ( 'ACCESS_PAID', 1 );
-define ( 'ACCESS_FREE', 2 );
-define ( 'ACCESS_TIERED', 3 );
+define('ACCESS_PRIVATE', 0);
+define('ACCESS_PAID', 1);
+define('ACCESS_FREE', 2);
+define('ACCESS_TIERED', 3);
/**
* DB update return values
*/
-define ( 'UPDATE_SUCCESS', 0);
-define ( 'UPDATE_FAILED', 1);
+define('UPDATE_SUCCESS', 0);
+define('UPDATE_FAILED', 1);
-define ( 'CLIENT_MODE_NORMAL', 0x0000);
-define ( 'CLIENT_MODE_LOAD', 0x0001);
-define ( 'CLIENT_MODE_UPDATE', 0x0002);
+define('CLIENT_MODE_NORMAL', 0x0000);
+define('CLIENT_MODE_LOAD', 0x0001);
+define('CLIENT_MODE_UPDATE', 0x0002);
/**
@@ -210,269 +215,267 @@ define ( 'CLIENT_MODE_UPDATE', 0x0002);
*
*/
-define ( 'PAGE_NORMAL', 0x0000 );
-define ( 'PAGE_HIDDEN', 0x0001 );
-define ( 'PAGE_AUTOCONNECT', 0x0002 );
-define ( 'PAGE_APPLICATION', 0x0004 );
-define ( 'PAGE_ALLOWCODE', 0x0008 );
-define ( 'PAGE_PREMIUM', 0x0010 );
-define ( 'PAGE_ADULT', 0x0020 );
-define ( 'PAGE_CENSORED', 0x0040 ); // Site admin has blocked this channel from appearing in casual search results and site feeds
-define ( 'PAGE_SYSTEM', 0x1000 );
-define ( 'PAGE_HUBADMIN', 0x2000 ); // set this to indicate a preferred admin channel rather than the
- // default channel of any accounts with the admin role.
-define ( 'PAGE_REMOVED', 0x8000 );
+define('PAGE_NORMAL', 0x0000);
+define('PAGE_HIDDEN', 0x0001);
+define('PAGE_AUTOCONNECT', 0x0002);
+define('PAGE_APPLICATION', 0x0004);
+define('PAGE_ALLOWCODE', 0x0008);
+define('PAGE_PREMIUM', 0x0010);
+define('PAGE_ADULT', 0x0020);
+define('PAGE_CENSORED', 0x0040); // Site admin has blocked this channel from appearing in casual search results and site feeds
+define('PAGE_SYSTEM', 0x1000);
+define('PAGE_HUBADMIN', 0x2000); // set this to indicate a preferred admin channel rather than the
+// default channel of any accounts with the admin role.
+define('PAGE_REMOVED', 0x8000);
/**
* Photo usage types
*/
-define ( 'PHOTO_NORMAL', 0x0000 );
-define ( 'PHOTO_PROFILE', 0x0001 );
-define ( 'PHOTO_XCHAN', 0x0002 );
-define ( 'PHOTO_THING', 0x0004 );
-define ( 'PHOTO_COVER', 0x0010 );
-define ( 'PHOTO_CACHE', 0x0020 );
+define('PHOTO_NORMAL', 0x0000);
+define('PHOTO_PROFILE', 0x0001);
+define('PHOTO_XCHAN', 0x0002);
+define('PHOTO_THING', 0x0004);
+define('PHOTO_COVER', 0x0010);
+define('PHOTO_CACHE', 0x0020);
-define ( 'PHOTO_ADULT', 0x0008 );
-define ( 'PHOTO_FLAG_OS', 0x4000 );
+define('PHOTO_ADULT', 0x0008);
+define('PHOTO_FLAG_OS', 0x4000);
-define ( 'PHOTO_RES_ORIG', 0 );
-define ( 'PHOTO_RES_1024', 1 ); // rectangular 1024 max width or height, floating height if not (4:3)
-define ( 'PHOTO_RES_640', 2 ); // to accomodate SMBC vertical comic strips without scrunching the width
-define ( 'PHOTO_RES_320', 3 ); // accordingly
+define('PHOTO_RES_ORIG', 0);
+define('PHOTO_RES_1024', 1); // rectangular 1024 max width or height, floating height if not (4:3)
+define('PHOTO_RES_640', 2); // to accomodate SMBC vertical comic strips without scrunching the width
+define('PHOTO_RES_320', 3); // accordingly
-define ( 'PHOTO_RES_PROFILE_300', 4 ); // square 300 px
-define ( 'PHOTO_RES_PROFILE_80', 5 ); // square 80 px
-define ( 'PHOTO_RES_PROFILE_48', 6 ); // square 48 px
+define('PHOTO_RES_PROFILE_300', 4); // square 300 px
+define('PHOTO_RES_PROFILE_80', 5); // square 80 px
+define('PHOTO_RES_PROFILE_48', 6); // square 48 px
-define ( 'PHOTO_RES_COVER_1200', 7 ); // 1200w x 435h (2.75:1)
-define ( 'PHOTO_RES_COVER_850', 8 ); // 850w x 310h
-define ( 'PHOTO_RES_COVER_425', 9 ); // 425w x 160h
+define('PHOTO_RES_COVER_1200', 7); // 1200w x 435h (2.75:1)
+define('PHOTO_RES_COVER_850', 8); // 850w x 310h
+define('PHOTO_RES_COVER_425', 9); // 425w x 160h
/**
* Menu types
*/
-define ( 'MENU_SYSTEM', 0x0001 );
-define ( 'MENU_BOOKMARK', 0x0002 );
+define('MENU_SYSTEM', 0x0001);
+define('MENU_BOOKMARK', 0x0002);
/**
* Network and protocol family types
*/
-define ( 'NETWORK_FRND', 'friendica-over-diaspora'); // Friendica, Mistpark, other DFRN implementations
-define ( 'NETWORK_DFRN', 'dfrn'); // Friendica, Mistpark, other DFRN implementations
-define ( 'NETWORK_ZOT', 'zot'); // Zot!
-define ( 'NETWORK_OSTATUS', 'stat'); // status.net, identi.ca, GNU-social, other OStatus implementations
-define ( 'NETWORK_GNUSOCIAL', 'gnusoc'); // status.net, identi.ca, GNU-social, other OStatus implementations
-define ( 'NETWORK_FEED', 'rss'); // RSS/Atom feeds with no known "post/notify" protocol
-define ( 'NETWORK_DIASPORA', 'diaspora'); // Diaspora
-define ( 'NETWORK_ACTIVITYPUB', 'activitypub');
-define ( 'NETWORK_MAIL', 'mail'); // IMAP/POP
-define ( 'NETWORK_MAIL2', 'mai2'); // extended IMAP/POP
-define ( 'NETWORK_FACEBOOK', 'face'); // Facebook API
-define ( 'NETWORK_LINKEDIN', 'lnkd'); // LinkedIn
-define ( 'NETWORK_XMPP', 'xmpp'); // XMPP
-define ( 'NETWORK_MYSPACE', 'mysp'); // MySpace
-define ( 'NETWORK_GPLUS', 'goog'); // Google+
-define ( 'NETWORK_PHANTOM', 'unkn'); // Place holder
+define('NETWORK_FRND', 'friendica-over-diaspora'); // Friendica, Mistpark, other DFRN implementations
+define('NETWORK_DFRN', 'dfrn'); // Friendica, Mistpark, other DFRN implementations
+define('NETWORK_ZOT', 'zot'); // Zot!
+define('NETWORK_OSTATUS', 'stat'); // status.net, identi.ca, GNU-social, other OStatus implementations
+define('NETWORK_GNUSOCIAL', 'gnusoc'); // status.net, identi.ca, GNU-social, other OStatus implementations
+define('NETWORK_FEED', 'rss'); // RSS/Atom feeds with no known "post/notify" protocol
+define('NETWORK_DIASPORA', 'diaspora'); // Diaspora
+define('NETWORK_ACTIVITYPUB', 'activitypub');
+define('NETWORK_MAIL', 'mail'); // IMAP/POP
+define('NETWORK_MAIL2', 'mai2'); // extended IMAP/POP
+define('NETWORK_FACEBOOK', 'face'); // Facebook API
+define('NETWORK_LINKEDIN', 'lnkd'); // LinkedIn
+define('NETWORK_XMPP', 'xmpp'); // XMPP
+define('NETWORK_MYSPACE', 'mysp'); // MySpace
+define('NETWORK_GPLUS', 'goog'); // Google+
+define('NETWORK_PHANTOM', 'unkn'); // Place holder
/**
* Permissions
*/
-define ( 'PERMS_R_STREAM', 0x00001);
-define ( 'PERMS_R_PROFILE', 0x00002);
-define ( 'PERMS_R_PHOTOS', 0x00004);
-define ( 'PERMS_R_ABOOK', 0x00008);
+define('PERMS_R_STREAM', 0x00001);
+define('PERMS_R_PROFILE', 0x00002);
+define('PERMS_R_PHOTOS', 0x00004);
+define('PERMS_R_ABOOK', 0x00008);
-define ( 'PERMS_W_STREAM', 0x00010);
-define ( 'PERMS_W_WALL', 0x00020);
-define ( 'PERMS_W_TAGWALL', 0x00040);
-define ( 'PERMS_W_COMMENT', 0x00080);
-define ( 'PERMS_W_MAIL', 0x00100);
-define ( 'PERMS_W_PHOTOS', 0x00200);
-define ( 'PERMS_W_CHAT', 0x00400);
-define ( 'PERMS_A_DELEGATE', 0x00800);
+define('PERMS_W_STREAM', 0x00010);
+define('PERMS_W_WALL', 0x00020);
+define('PERMS_W_TAGWALL', 0x00040);
+define('PERMS_W_COMMENT', 0x00080);
+define('PERMS_W_MAIL', 0x00100);
+define('PERMS_W_PHOTOS', 0x00200);
+define('PERMS_W_CHAT', 0x00400);
+define('PERMS_A_DELEGATE', 0x00800);
-define ( 'PERMS_R_STORAGE', 0x01000);
-define ( 'PERMS_W_STORAGE', 0x02000);
-define ( 'PERMS_R_PAGES', 0x04000);
-define ( 'PERMS_W_PAGES', 0x08000);
-define ( 'PERMS_A_REPUBLISH', 0x10000);
-define ( 'PERMS_W_LIKE', 0x20000);
+define('PERMS_R_STORAGE', 0x01000);
+define('PERMS_W_STORAGE', 0x02000);
+define('PERMS_R_PAGES', 0x04000);
+define('PERMS_W_PAGES', 0x08000);
+define('PERMS_A_REPUBLISH', 0x10000);
+define('PERMS_W_LIKE', 0x20000);
// General channel permissions
- // 0 = Only you
-define ( 'PERMS_PUBLIC' , 0x0001 ); // anybody
-define ( 'PERMS_NETWORK' , 0x0002 ); // anybody in this network
-define ( 'PERMS_SITE' , 0x0004 ); // anybody on this site
-define ( 'PERMS_CONTACTS' , 0x0008 ); // any of my connections
-define ( 'PERMS_SPECIFIC' , 0x0080 ); // only specific connections
-define ( 'PERMS_AUTHED' , 0x0100 ); // anybody authenticated (could include visitors from other networks)
-define ( 'PERMS_PENDING' , 0x0200 ); // any connections including those who haven't yet been approved
+// 0 = Only you
+define('PERMS_PUBLIC', 0x0001); // anybody
+define('PERMS_NETWORK', 0x0002); // anybody in this network
+define('PERMS_SITE', 0x0004); // anybody on this site
+define('PERMS_CONTACTS', 0x0008); // any of my connections
+define('PERMS_SPECIFIC', 0x0080); // only specific connections
+define('PERMS_AUTHED', 0x0100); // anybody authenticated (could include visitors from other networks)
+define('PERMS_PENDING', 0x0200); // any connections including those who haven't yet been approved
// Address book flags
-define ( 'ABOOK_FLAG_BLOCKED' , 0x0001);
-define ( 'ABOOK_FLAG_IGNORED' , 0x0002);
-define ( 'ABOOK_FLAG_HIDDEN' , 0x0004);
-define ( 'ABOOK_FLAG_ARCHIVED' , 0x0008);
-define ( 'ABOOK_FLAG_PENDING' , 0x0010);
-define ( 'ABOOK_FLAG_UNCONNECTED', 0x0020);
-define ( 'ABOOK_FLAG_SELF' , 0x0080);
-define ( 'ABOOK_FLAG_FEED' , 0x0100);
-
+define('ABOOK_FLAG_BLOCKED', 0x0001);
+define('ABOOK_FLAG_IGNORED', 0x0002);
+define('ABOOK_FLAG_HIDDEN', 0x0004);
+define('ABOOK_FLAG_ARCHIVED', 0x0008);
+define('ABOOK_FLAG_PENDING', 0x0010);
+define('ABOOK_FLAG_UNCONNECTED', 0x0020);
+define('ABOOK_FLAG_SELF', 0x0080);
+define('ABOOK_FLAG_FEED', 0x0100);
-define ( 'MAIL_DELETED', 0x0001);
-define ( 'MAIL_REPLIED', 0x0002);
-define ( 'MAIL_ISREPLY', 0x0004);
-define ( 'MAIL_SEEN', 0x0008);
-define ( 'MAIL_RECALLED', 0x0010);
-define ( 'MAIL_OBSCURED', 0x0020);
+define('MAIL_DELETED', 0x0001);
+define('MAIL_REPLIED', 0x0002);
+define('MAIL_ISREPLY', 0x0004);
+define('MAIL_SEEN', 0x0008);
+define('MAIL_RECALLED', 0x0010);
+define('MAIL_OBSCURED', 0x0020);
-define ( 'ATTACH_FLAG_DIR', 0x0001);
-define ( 'ATTACH_FLAG_OS', 0x0002);
+define('ATTACH_FLAG_DIR', 0x0001);
+define('ATTACH_FLAG_OS', 0x0002);
-define ( 'MENU_ITEM_ZID', 0x0001);
-define ( 'MENU_ITEM_NEWWIN', 0x0002);
-define ( 'MENU_ITEM_CHATROOM', 0x0004);
+define('MENU_ITEM_ZID', 0x0001);
+define('MENU_ITEM_NEWWIN', 0x0002);
+define('MENU_ITEM_CHATROOM', 0x0004);
-define ( 'SITE_TYPE_ZOT', 0);
-define ( 'SITE_TYPE_NOTZOT', 1);
-define ( 'SITE_TYPE_UNKNOWN', 2);
+define('SITE_TYPE_ZOT', 0);
+define('SITE_TYPE_NOTZOT', 1);
+define('SITE_TYPE_UNKNOWN', 2);
/**
* Poll/Survey types
*/
-define ( 'POLL_SIMPLE_RATING', 0x0001); // 1-5
-define ( 'POLL_TENSCALE', 0x0002); // 1-10
-define ( 'POLL_MULTIPLE_CHOICE', 0x0004);
-define ( 'POLL_OVERWRITE', 0x8000); // If you vote twice remove the prior entry
+define('POLL_SIMPLE_RATING', 0x0001); // 1-5
+define('POLL_TENSCALE', 0x0002); // 1-10
+define('POLL_MULTIPLE_CHOICE', 0x0004);
+define('POLL_OVERWRITE', 0x8000); // If you vote twice remove the prior entry
-define ( 'UPDATE_FLAGS_UPDATED', 0x0001);
-define ( 'UPDATE_FLAGS_FORCED', 0x0002);
-define ( 'UPDATE_FLAGS_DELETED', 0x1000);
+define('UPDATE_FLAGS_UPDATED', 0x0001);
+define('UPDATE_FLAGS_FORCED', 0x0002);
+define('UPDATE_FLAGS_DELETED', 0x1000);
-define ( 'HUBLOC_OFFLINE', 0x0001);
+define('HUBLOC_OFFLINE', 0x0001);
-define ( 'DROPITEM_NORMAL', 0);
-define ( 'DROPITEM_PHASE1', 1);
-define ( 'DROPITEM_PHASE2', 2);
+define('DROPITEM_NORMAL', 0);
+define('DROPITEM_PHASE1', 1);
+define('DROPITEM_PHASE2', 2);
/**
* Maximum number of "people who like (or don't like) this" that we will list by name
*/
-define ( 'MAX_LIKERS', 10);
+define('MAX_LIKERS', 10);
/**
* Communication timeout
*/
-define ( 'ZCURL_TIMEOUT' , (-1));
+define('ZCURL_TIMEOUT', (-1));
/**
* email notification options
*/
-define ( 'NOTIFY_INTRO', 0x0001 );
-define ( 'NOTIFY_CONFIRM', 0x0002 );
-define ( 'NOTIFY_WALL', 0x0004 );
-define ( 'NOTIFY_COMMENT', 0x0008 );
-define ( 'NOTIFY_MAIL', 0x0010 );
-define ( 'NOTIFY_SUGGEST', 0x0020 );
-define ( 'NOTIFY_PROFILE', 0x0040 );
-define ( 'NOTIFY_TAGSELF', 0x0080 );
-define ( 'NOTIFY_TAGSHARE', 0x0100 );
-define ( 'NOTIFY_POKE', 0x0200 );
-define ( 'NOTIFY_LIKE', 0x0400 );
+define('NOTIFY_INTRO', 0x0001);
+define('NOTIFY_CONFIRM', 0x0002);
+define('NOTIFY_WALL', 0x0004);
+define('NOTIFY_COMMENT', 0x0008);
+define('NOTIFY_MAIL', 0x0010);
+define('NOTIFY_SUGGEST', 0x0020);
+define('NOTIFY_PROFILE', 0x0040);
+define('NOTIFY_TAGSELF', 0x0080);
+define('NOTIFY_TAGSHARE', 0x0100);
+define('NOTIFY_POKE', 0x0200);
+define('NOTIFY_LIKE', 0x0400);
-define ( 'NOTIFY_SYSTEM', 0x8000 );
+define('NOTIFY_SYSTEM', 0x8000);
/**
* visual notification options
*/
-define ( 'VNOTIFY_NETWORK', 0x0001 );
-define ( 'VNOTIFY_CHANNEL', 0x0002 );
-define ( 'VNOTIFY_MAIL', 0x0004 );
-define ( 'VNOTIFY_EVENT', 0x0008 );
-define ( 'VNOTIFY_EVENTTODAY', 0x0010 );
-define ( 'VNOTIFY_BIRTHDAY', 0x0020 );
-define ( 'VNOTIFY_SYSTEM', 0x0040 );
-define ( 'VNOTIFY_INFO', 0x0080 );
-define ( 'VNOTIFY_ALERT', 0x0100 );
-define ( 'VNOTIFY_INTRO', 0x0200 );
-define ( 'VNOTIFY_REGISTER', 0x0400 );
-define ( 'VNOTIFY_FILES', 0x0800 );
-define ( 'VNOTIFY_PUBS', 0x1000 );
-define ( 'VNOTIFY_LIKE', 0x2000 );
-define ( 'VNOTIFY_FORUMS', 0x4000 );
-
+define('VNOTIFY_NETWORK', 0x0001);
+define('VNOTIFY_CHANNEL', 0x0002);
+define('VNOTIFY_MAIL', 0x0004);
+define('VNOTIFY_EVENT', 0x0008);
+define('VNOTIFY_EVENTTODAY', 0x0010);
+define('VNOTIFY_BIRTHDAY', 0x0020);
+define('VNOTIFY_SYSTEM', 0x0040);
+define('VNOTIFY_INFO', 0x0080);
+define('VNOTIFY_ALERT', 0x0100);
+define('VNOTIFY_INTRO', 0x0200);
+define('VNOTIFY_REGISTER', 0x0400);
+define('VNOTIFY_FILES', 0x0800);
+define('VNOTIFY_PUBS', 0x1000);
+define('VNOTIFY_LIKE', 0x2000);
+define('VNOTIFY_FORUMS', 0x4000);
/**
* Tag/term types
*/
-define ( 'TERM_UNKNOWN', 0 );
-define ( 'TERM_HASHTAG', 1 );
-define ( 'TERM_MENTION', 2 );
-define ( 'TERM_CATEGORY', 3 );
-define ( 'TERM_PCATEGORY', 4 );
-define ( 'TERM_FILE', 5 );
-define ( 'TERM_SAVEDSEARCH', 6 );
-define ( 'TERM_THING', 7 );
-define ( 'TERM_BOOKMARK', 8 );
-define ( 'TERM_HIERARCHY', 9 );
-define ( 'TERM_COMMUNITYTAG', 10 );
-define ( 'TERM_FORUM', 11 );
-define ( 'TERM_EMOJI', 12 );
+define('TERM_UNKNOWN', 0);
+define('TERM_HASHTAG', 1);
+define('TERM_MENTION', 2);
+define('TERM_CATEGORY', 3);
+define('TERM_PCATEGORY', 4);
+define('TERM_FILE', 5);
+define('TERM_SAVEDSEARCH', 6);
+define('TERM_THING', 7);
+define('TERM_BOOKMARK', 8);
+define('TERM_HIERARCHY', 9);
+define('TERM_COMMUNITYTAG', 10);
+define('TERM_FORUM', 11);
+define('TERM_EMOJI', 12);
-define ( 'TERM_OBJ_POST', 1 );
-define ( 'TERM_OBJ_FILE', 2 );
-define ( 'TERM_OBJ_PROFILE', 3 );
-define ( 'TERM_OBJ_CHANNEL', 4 );
-define ( 'TERM_OBJ_OBJECT', 5 );
-define ( 'TERM_OBJ_THING', 6 );
-define ( 'TERM_OBJ_APP', 7 );
+define('TERM_OBJ_POST', 1);
+define('TERM_OBJ_FILE', 2);
+define('TERM_OBJ_PROFILE', 3);
+define('TERM_OBJ_CHANNEL', 4);
+define('TERM_OBJ_OBJECT', 5);
+define('TERM_OBJ_THING', 6);
+define('TERM_OBJ_APP', 7);
/**
* various namespaces we may need to parse
*/
-define ( 'PROTOCOL_ZOT', 'http://purl.org/zot/protocol' );
-define ( 'PROTOCOL_ZOT6', 'http://purl.org/zot/protocol/6.0' );
-define ( 'NAMESPACE_ZOT', 'http://purl.org/zot' );
-define ( 'NAMESPACE_DFRN' , 'http://purl.org/macgirvin/dfrn/1.0' );
-define ( 'NAMESPACE_THREAD' , 'http://purl.org/syndication/thread/1.0' );
-define ( 'NAMESPACE_TOMB' , 'http://purl.org/atompub/tombstones/1.0' );
-define ( 'NAMESPACE_ACTIVITY', 'http://activitystrea.ms/spec/1.0/' );
-define ( 'NAMESPACE_ACTIVITY_SCHEMA', 'http://activitystrea.ms/schema/1.0/' );
-define ( 'NAMESPACE_MEDIA', 'http://purl.org/syndication/atommedia' );
-define ( 'NAMESPACE_SALMON_ME', 'http://salmon-protocol.org/ns/magic-env' );
-define ( 'NAMESPACE_OSTATUSSUB', 'http://ostatus.org/schema/1.0/subscribe' );
-define ( 'NAMESPACE_GEORSS', 'http://www.georss.org/georss' );
-define ( 'NAMESPACE_POCO', 'http://portablecontacts.net/spec/1.0' );
-define ( 'NAMESPACE_FEED', 'http://schemas.google.com/g/2010#updates-from' );
-define ( 'NAMESPACE_OSTATUS', 'http://ostatus.org/schema/1.0' );
-define ( 'NAMESPACE_STATUSNET', 'http://status.net/schema/api/1/' );
-define ( 'NAMESPACE_ATOM1', 'http://www.w3.org/2005/Atom' );
-define ( 'NAMESPACE_YMEDIA', 'http://search.yahoo.com/mrss/' );
+define('PROTOCOL_ZOT', 'http://purl.org/zot/protocol');
+define('PROTOCOL_ZOT6', 'http://purl.org/zot/protocol/6.0');
+define('NAMESPACE_ZOT', 'http://purl.org/zot');
+define('NAMESPACE_DFRN', 'http://purl.org/macgirvin/dfrn/1.0');
+define('NAMESPACE_THREAD', 'http://purl.org/syndication/thread/1.0');
+define('NAMESPACE_TOMB', 'http://purl.org/atompub/tombstones/1.0');
+define('NAMESPACE_ACTIVITY', 'http://activitystrea.ms/spec/1.0/');
+define('NAMESPACE_ACTIVITY_SCHEMA', 'http://activitystrea.ms/schema/1.0/');
+define('NAMESPACE_MEDIA', 'http://purl.org/syndication/atommedia');
+define('NAMESPACE_SALMON_ME', 'http://salmon-protocol.org/ns/magic-env');
+define('NAMESPACE_OSTATUSSUB', 'http://ostatus.org/schema/1.0/subscribe');
+define('NAMESPACE_GEORSS', 'http://www.georss.org/georss');
+define('NAMESPACE_POCO', 'http://portablecontacts.net/spec/1.0');
+define('NAMESPACE_FEED', 'http://schemas.google.com/g/2010#updates-from');
+define('NAMESPACE_OSTATUS', 'http://ostatus.org/schema/1.0');
+define('NAMESPACE_STATUSNET', 'http://status.net/schema/api/1/');
+define('NAMESPACE_ATOM1', 'http://www.w3.org/2005/Atom');
+define('NAMESPACE_YMEDIA', 'http://search.yahoo.com/mrss/');
// We should be using versioned jsonld contexts so that signatures will be slightly more reliable.
// Why signatures are unreliable by design is a problem nobody seems to care about
@@ -482,126 +485,126 @@ define ( 'NAMESPACE_YMEDIA', 'http://search.yahoo.com/mrss/' );
// the reason for the dependency but for the current time, use the standard non-versioned context.
//define ( 'ACTIVITYSTREAMS_JSONLD_REV', 'https://www.w3.org/ns/activitystreams-history/v1.8.jsonld' );
-define ( 'ACTIVITYSTREAMS_JSONLD_REV', 'https://www.w3.org/ns/activitystreams' );
+define('ACTIVITYSTREAMS_JSONLD_REV', 'https://www.w3.org/ns/activitystreams');
-define ( 'ZOT_APSCHEMA_REV', '/apschema/v1.10' );
+define('ZOT_APSCHEMA_REV', '/apschema/v1.10');
/**
* activity stream defines
*/
-define ( 'ACTIVITY_PUBLIC_INBOX', 'https://www.w3.org/ns/activitystreams#Public' );
-
-define ( 'ACTIVITY_REACT', NAMESPACE_ZOT . '/activity/react' );
-define ( 'ACTIVITY_LIKE', NAMESPACE_ACTIVITY_SCHEMA . 'like' );
-define ( 'ACTIVITY_DISLIKE', NAMESPACE_ZOT . '/activity/dislike' );
-define ( 'ACTIVITY_AGREE', NAMESPACE_ZOT . '/activity/agree' );
-define ( 'ACTIVITY_DISAGREE', NAMESPACE_ZOT . '/activity/disagree' );
-define ( 'ACTIVITY_ABSTAIN', NAMESPACE_ZOT . '/activity/abstain' );
-define ( 'ACTIVITY_ATTEND', NAMESPACE_ZOT . '/activity/attendyes' );
-define ( 'ACTIVITY_ATTENDNO', NAMESPACE_ZOT . '/activity/attendno' );
-define ( 'ACTIVITY_ATTENDMAYBE', NAMESPACE_ZOT . '/activity/attendmaybe' );
-define ( 'ACTIVITY_POLLRESPONSE', NAMESPACE_ZOT . '/activity/pollresponse' );
-
-define ( 'ACTIVITY_OBJ_HEART', NAMESPACE_ZOT . '/activity/heart' );
-
-define ( 'ACTIVITY_FRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'make-friend' );
-define ( 'ACTIVITY_REQ_FRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'request-friend' );
-define ( 'ACTIVITY_UNFRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'remove-friend' );
-define ( 'ACTIVITY_FOLLOW', NAMESPACE_ACTIVITY_SCHEMA . 'follow' );
-define ( 'ACTIVITY_UNFOLLOW', NAMESPACE_ACTIVITY_SCHEMA . 'stop-following' );
-define ( 'ACTIVITY_JOIN', NAMESPACE_ACTIVITY_SCHEMA . 'join' );
-
-define ( 'ACTIVITY_POST', NAMESPACE_ACTIVITY_SCHEMA . 'post' );
-define ( 'ACTIVITY_UPDATE', NAMESPACE_ACTIVITY_SCHEMA . 'update' );
-define ( 'ACTIVITY_TAG', NAMESPACE_ACTIVITY_SCHEMA . 'tag' );
-define ( 'ACTIVITY_SHARE', NAMESPACE_ACTIVITY_SCHEMA . 'share' );
-define ( 'ACTIVITY_FAVORITE', NAMESPACE_ACTIVITY_SCHEMA . 'favorite' );
-define ( 'ACTIVITY_CREATE', NAMESPACE_ACTIVITY_SCHEMA . 'create' );
-define ( 'ACTIVITY_DELETE', NAMESPACE_ACTIVITY_SCHEMA . 'delete' );
-define ( 'ACTIVITY_WIN', NAMESPACE_ACTIVITY_SCHEMA . 'win' );
-define ( 'ACTIVITY_LOSE', NAMESPACE_ACTIVITY_SCHEMA . 'lose' );
-define ( 'ACTIVITY_TIE', NAMESPACE_ACTIVITY_SCHEMA . 'tie' );
-define ( 'ACTIVITY_COMPLETE', NAMESPACE_ACTIVITY_SCHEMA . 'complete' );
-
-define ( 'ACTIVITY_POKE', NAMESPACE_ZOT . '/activity/poke' );
-define ( 'ACTIVITY_MOOD', NAMESPACE_ZOT . '/activity/mood' );
-
-define ( 'ACTIVITY_OBJ_COMMENT', NAMESPACE_ACTIVITY_SCHEMA . 'comment' );
-define ( 'ACTIVITY_OBJ_ACTIVITY',NAMESPACE_ACTIVITY_SCHEMA . 'activity' );
-define ( 'ACTIVITY_OBJ_NOTE', NAMESPACE_ACTIVITY_SCHEMA . 'note' );
-define ( 'ACTIVITY_OBJ_ARTICLE', NAMESPACE_ACTIVITY_SCHEMA . 'article' );
-define ( 'ACTIVITY_OBJ_PERSON', NAMESPACE_ACTIVITY_SCHEMA . 'person' );
-define ( 'ACTIVITY_OBJ_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'photo' );
-define ( 'ACTIVITY_OBJ_P_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'profile-photo' );
-define ( 'ACTIVITY_OBJ_ALBUM', NAMESPACE_ACTIVITY_SCHEMA . 'photo-album' );
-define ( 'ACTIVITY_OBJ_EVENT', NAMESPACE_ACTIVITY_SCHEMA . 'event' );
-define ( 'ACTIVITY_OBJ_GROUP', NAMESPACE_ACTIVITY_SCHEMA . 'group' );
-define ( 'ACTIVITY_OBJ_GAME', NAMESPACE_ACTIVITY_SCHEMA . 'game' );
-define ( 'ACTIVITY_OBJ_WIKI', NAMESPACE_ACTIVITY_SCHEMA . 'wiki' );
-define ( 'ACTIVITY_OBJ_TAGTERM', NAMESPACE_ZOT . '/activity/tagterm' );
-define ( 'ACTIVITY_OBJ_PROFILE', NAMESPACE_ZOT . '/activity/profile' );
-define ( 'ACTIVITY_OBJ_THING', NAMESPACE_ZOT . '/activity/thing' );
-define ( 'ACTIVITY_OBJ_LOCATION',NAMESPACE_ZOT . '/activity/location' );
-define ( 'ACTIVITY_OBJ_FILE', NAMESPACE_ZOT . '/activity/file' );
-define ( 'ACTIVITY_OBJ_CARD', NAMESPACE_ZOT . '/activity/card' );
+define('ACTIVITY_PUBLIC_INBOX', 'https://www.w3.org/ns/activitystreams#Public');
+
+define('ACTIVITY_REACT', NAMESPACE_ZOT . '/activity/react');
+define('ACTIVITY_LIKE', NAMESPACE_ACTIVITY_SCHEMA . 'like');
+define('ACTIVITY_DISLIKE', NAMESPACE_ZOT . '/activity/dislike');
+define('ACTIVITY_AGREE', NAMESPACE_ZOT . '/activity/agree');
+define('ACTIVITY_DISAGREE', NAMESPACE_ZOT . '/activity/disagree');
+define('ACTIVITY_ABSTAIN', NAMESPACE_ZOT . '/activity/abstain');
+define('ACTIVITY_ATTEND', NAMESPACE_ZOT . '/activity/attendyes');
+define('ACTIVITY_ATTENDNO', NAMESPACE_ZOT . '/activity/attendno');
+define('ACTIVITY_ATTENDMAYBE', NAMESPACE_ZOT . '/activity/attendmaybe');
+define('ACTIVITY_POLLRESPONSE', NAMESPACE_ZOT . '/activity/pollresponse');
+
+define('ACTIVITY_OBJ_HEART', NAMESPACE_ZOT . '/activity/heart');
+
+define('ACTIVITY_FRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'make-friend');
+define('ACTIVITY_REQ_FRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'request-friend');
+define('ACTIVITY_UNFRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'remove-friend');
+define('ACTIVITY_FOLLOW', NAMESPACE_ACTIVITY_SCHEMA . 'follow');
+define('ACTIVITY_UNFOLLOW', NAMESPACE_ACTIVITY_SCHEMA . 'stop-following');
+define('ACTIVITY_JOIN', NAMESPACE_ACTIVITY_SCHEMA . 'join');
+
+define('ACTIVITY_POST', NAMESPACE_ACTIVITY_SCHEMA . 'post');
+define('ACTIVITY_UPDATE', NAMESPACE_ACTIVITY_SCHEMA . 'update');
+define('ACTIVITY_TAG', NAMESPACE_ACTIVITY_SCHEMA . 'tag');
+define('ACTIVITY_SHARE', NAMESPACE_ACTIVITY_SCHEMA . 'share');
+define('ACTIVITY_FAVORITE', NAMESPACE_ACTIVITY_SCHEMA . 'favorite');
+define('ACTIVITY_CREATE', NAMESPACE_ACTIVITY_SCHEMA . 'create');
+define('ACTIVITY_DELETE', NAMESPACE_ACTIVITY_SCHEMA . 'delete');
+define('ACTIVITY_WIN', NAMESPACE_ACTIVITY_SCHEMA . 'win');
+define('ACTIVITY_LOSE', NAMESPACE_ACTIVITY_SCHEMA . 'lose');
+define('ACTIVITY_TIE', NAMESPACE_ACTIVITY_SCHEMA . 'tie');
+define('ACTIVITY_COMPLETE', NAMESPACE_ACTIVITY_SCHEMA . 'complete');
+
+define('ACTIVITY_POKE', NAMESPACE_ZOT . '/activity/poke');
+define('ACTIVITY_MOOD', NAMESPACE_ZOT . '/activity/mood');
+
+define('ACTIVITY_OBJ_COMMENT', NAMESPACE_ACTIVITY_SCHEMA . 'comment');
+define('ACTIVITY_OBJ_ACTIVITY', NAMESPACE_ACTIVITY_SCHEMA . 'activity');
+define('ACTIVITY_OBJ_NOTE', NAMESPACE_ACTIVITY_SCHEMA . 'note');
+define('ACTIVITY_OBJ_ARTICLE', NAMESPACE_ACTIVITY_SCHEMA . 'article');
+define('ACTIVITY_OBJ_PERSON', NAMESPACE_ACTIVITY_SCHEMA . 'person');
+define('ACTIVITY_OBJ_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'photo');
+define('ACTIVITY_OBJ_P_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'profile-photo');
+define('ACTIVITY_OBJ_ALBUM', NAMESPACE_ACTIVITY_SCHEMA . 'photo-album');
+define('ACTIVITY_OBJ_EVENT', NAMESPACE_ACTIVITY_SCHEMA . 'event');
+define('ACTIVITY_OBJ_GROUP', NAMESPACE_ACTIVITY_SCHEMA . 'group');
+define('ACTIVITY_OBJ_GAME', NAMESPACE_ACTIVITY_SCHEMA . 'game');
+define('ACTIVITY_OBJ_WIKI', NAMESPACE_ACTIVITY_SCHEMA . 'wiki');
+define('ACTIVITY_OBJ_TAGTERM', NAMESPACE_ZOT . '/activity/tagterm');
+define('ACTIVITY_OBJ_PROFILE', NAMESPACE_ZOT . '/activity/profile');
+define('ACTIVITY_OBJ_THING', NAMESPACE_ZOT . '/activity/thing');
+define('ACTIVITY_OBJ_LOCATION', NAMESPACE_ZOT . '/activity/location');
+define('ACTIVITY_OBJ_FILE', NAMESPACE_ZOT . '/activity/file');
+define('ACTIVITY_OBJ_CARD', NAMESPACE_ZOT . '/activity/card');
/**
* Account Flags
*/
-define ( 'ACCOUNT_OK', 0x0000 );
-define ( 'ACCOUNT_UNVERIFIED', 0x0001 );
-define ( 'ACCOUNT_BLOCKED', 0x0002 );
-define ( 'ACCOUNT_EXPIRED', 0x0004 );
-define ( 'ACCOUNT_REMOVED', 0x0008 );
-define ( 'ACCOUNT_PENDING', 0x0010 );
+define('ACCOUNT_OK', 0x0000);
+define('ACCOUNT_UNVERIFIED', 0x0001);
+define('ACCOUNT_BLOCKED', 0x0002);
+define('ACCOUNT_EXPIRED', 0x0004);
+define('ACCOUNT_REMOVED', 0x0008);
+define('ACCOUNT_PENDING', 0x0010);
/**
* Account roles
*/
-define ( 'ACCOUNT_ROLE_SYSTEM', 0x0002 );
-define ( 'ACCOUNT_ROLE_DEVELOPER', 0x0004 );
-define ( 'ACCOUNT_ROLE_ADMIN', 0x1000 );
+define('ACCOUNT_ROLE_SYSTEM', 0x0002);
+define('ACCOUNT_ROLE_DEVELOPER', 0x0004);
+define('ACCOUNT_ROLE_ADMIN', 0x1000);
/**
* Item visibility
*/
-define ( 'ITEM_VISIBLE', 0x0000);
-define ( 'ITEM_HIDDEN', 0x0001);
-define ( 'ITEM_BLOCKED', 0x0002);
-define ( 'ITEM_MODERATED', 0x0004);
-define ( 'ITEM_SPAM', 0x0008);
-define ( 'ITEM_DELETED', 0x0010);
-define ( 'ITEM_UNPUBLISHED', 0x0020);
-define ( 'ITEM_WEBPAGE', 0x0040); // is a static web page, not a conversational item
-define ( 'ITEM_DELAYED_PUBLISH', 0x0080);
-define ( 'ITEM_BUILDBLOCK', 0x0100); // Named thusly to make sure nobody confuses this with ITEM_BLOCKED
-define ( 'ITEM_PDL', 0x0200); // Page Description Language - e.g. Comanche
-define ( 'ITEM_BUG', 0x0400); // Is a bug, can be used by the internal bug tracker
-define ( 'ITEM_PENDING_REMOVE', 0x0800); // deleted, notification period has lapsed
-define ( 'ITEM_DOC', 0x1000); // hubzilla only, define here so that item import does the right thing
-define ( 'ITEM_CARD', 0x2000);
-define ( 'ITEM_ARTICLE', 0x4000);
-
-
-define ( 'ITEM_TYPE_POST', 0 );
-define ( 'ITEM_TYPE_BLOCK', 1 );
-define ( 'ITEM_TYPE_PDL', 2 );
-define ( 'ITEM_TYPE_WEBPAGE', 3 );
-define ( 'ITEM_TYPE_BUG', 4 );
-define ( 'ITEM_TYPE_DOC', 5 );
-define ( 'ITEM_TYPE_CARD', 6 );
-define ( 'ITEM_TYPE_ARTICLE', 7 );
+define('ITEM_VISIBLE', 0x0000);
+define('ITEM_HIDDEN', 0x0001);
+define('ITEM_BLOCKED', 0x0002);
+define('ITEM_MODERATED', 0x0004);
+define('ITEM_SPAM', 0x0008);
+define('ITEM_DELETED', 0x0010);
+define('ITEM_UNPUBLISHED', 0x0020);
+define('ITEM_WEBPAGE', 0x0040); // is a static web page, not a conversational item
+define('ITEM_DELAYED_PUBLISH', 0x0080);
+define('ITEM_BUILDBLOCK', 0x0100); // Named thusly to make sure nobody confuses this with ITEM_BLOCKED
+define('ITEM_PDL', 0x0200); // Page Description Language - e.g. Comanche
+define('ITEM_BUG', 0x0400); // Is a bug, can be used by the internal bug tracker
+define('ITEM_PENDING_REMOVE', 0x0800); // deleted, notification period has lapsed
+define('ITEM_DOC', 0x1000); // hubzilla only, define here so that item import does the right thing
+define('ITEM_CARD', 0x2000);
+define('ITEM_ARTICLE', 0x4000);
+
+
+define('ITEM_TYPE_POST', 0);
+define('ITEM_TYPE_BLOCK', 1);
+define('ITEM_TYPE_PDL', 2);
+define('ITEM_TYPE_WEBPAGE', 3);
+define('ITEM_TYPE_BUG', 4);
+define('ITEM_TYPE_DOC', 5);
+define('ITEM_TYPE_CARD', 6);
+define('ITEM_TYPE_ARTICLE', 7);
//OSADA ITEM_TYPE_MAIL = 8
-define ( 'ITEM_TYPE_CUSTOM', 9 );
+define('ITEM_TYPE_CUSTOM', 9);
-define ( 'ITEM_IS_STICKY', 1000 );
+define('ITEM_IS_STICKY', 1000);
-define ( 'DBTYPE_MYSQL', 0 );
-define ( 'DBTYPE_POSTGRES', 1 );
+define('DBTYPE_MYSQL', 0);
+define('DBTYPE_POSTGRES', 1);
function sys_boot() {
@@ -629,10 +632,10 @@ function sys_boot() {
// allow somebody to set some initial settings just in case they can't
// install without special fiddling
- if(App::$install && file_exists('.htpreconfig.php'))
+ if (App::$install && file_exists('.htpreconfig.php'))
@include('.htpreconfig.php');
- if(array_key_exists('default_timezone',get_defined_vars())) {
+ if (array_key_exists('default_timezone', get_defined_vars())) {
App::$config['system']['timezone'] = $default_timezone;
}
@@ -644,12 +647,12 @@ function sys_boot() {
date_default_timezone_set(App::$timezone);
- if(! defined('DEFAULT_PLATFORM_ICON')) {
- define( 'DEFAULT_PLATFORM_ICON', '/images/hz-32.png' );
+ if (!defined('DEFAULT_PLATFORM_ICON')) {
+ define('DEFAULT_PLATFORM_ICON', '/images/hz-32.png');
}
- if(! defined('DEFAULT_NOTIFY_ICON')) {
- define( 'DEFAULT_NOTIFY_ICON', '/images/hz-white-64.png' );
+ if (!defined('DEFAULT_NOTIFY_ICON')) {
+ define('DEFAULT_NOTIFY_ICON', '/images/hz-white-64.png');
}
App::head_set_icon(DEFAULT_PLATFORM_ICON);
@@ -660,9 +663,9 @@ function sys_boot() {
require_once('include/dba/dba_driver.php');
- if(! App::$install) {
+ if (!App::$install) {
DBA::dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, App::$install);
- if(! DBA::$dba->connected) {
+ if (!DBA::$dba->connected) {
system_unavailable();
}
@@ -696,7 +699,7 @@ function startup() {
// Some hosting providers block/disable this
@set_time_limit(0);
- if(function_exists ('ini_set')) {
+ if (function_exists('ini_set')) {
// This has to be quite large to deal with embedded private photos
//@ini_set('pcre.backtrack_limit', 500000);
@@ -704,7 +707,7 @@ function startup() {
@ini_set('session.use_only_cookies', 1);
// Disable transparent Session ID support
- @ini_set('session.use_trans_sid', 0);
+ @ini_set('session.use_trans_sid', 0);
}
}
@@ -718,11 +721,11 @@ function startup() {
* 'system' config settings.
*/
class miniApp {
- public $config = array('system' => array());
+ public $config = ['system' => []];
public function convert() {
- if($this->config['system']) {
- foreach($this->config['system'] as $k => $v)
+ if ($this->config['system']) {
+ foreach ($this->config['system'] as $k => $v)
App::$config['system'][$k] = $v;
}
}
@@ -743,77 +746,77 @@ class miniApp {
*/
class App {
- public static $install = false; // true if we are installing the software
- public static $account = null; // account record of the logged-in account
- public static $channel = null; // channel record of the current channel of the logged-in account
- public static $observer = null; // xchan record of the page observer
- public static $profile_uid = 0; // If applicable, the channel_id of the "page owner"
- public static $poi = null; // "person of interest", generally a referenced connection
- private static $oauth_key = null; // consumer_id of oauth request, if used
- public static $layout = array(); // Comanche parsed template
- public static $pdl = null; // Comanche page description
- private static $perms = null; // observer permissions
- private static $widgets = array(); // widgets for this page
- public static $config = array(); // config cache
- public static $override_intltext_templates = array();
- public static $override_markup_templates = array();
- public static $override_templateroot = null;
- public static $override_helproot = null;
- public static $override_helpfiles = array();
-
- public static $session = null;
- public static $groups;
- public static $language;
- public static $langsave;
- public static $rtl = false;
- public static $plugins_admin;
- public static $module_loaded = false;
- public static $query_string;
- public static $page;
- public static $profile;
- public static $user;
- public static $cid;
- public static $contact;
- public static $contacts;
- public static $content;
- public static $data = array();
- public static $error = false;
- public static $emojitab = false;
- public static $cmd;
- public static $argv;
- public static $argc;
- public static $module;
- public static $pager;
- public static $strings;
- public static $stringsave; // used in push_lang() and pop_lang()
- public static $hooks;
- public static $timezone;
- public static $interactive = true;
- public static $plugins;
- private static $apps = array();
- public static $identities;
- public static $css_sources = array();
- public static $js_sources = array();
- public static $linkrel = array();
- public static $theme_info = array();
- public static $is_sys = false;
- public static $nav_sel;
- public static $comanche;
+ public static $install = false; // true if we are installing the software
+ public static $account = null; // account record of the logged-in account
+ public static $channel = null; // channel record of the current channel of the logged-in account
+ public static $observer = null; // xchan record of the page observer
+ public static $profile_uid = 0; // If applicable, the channel_id of the "page owner"
+ public static $poi = null; // "person of interest", generally a referenced connection
+ private static $oauth_key = null; // consumer_id of oauth request, if used
+ public static $layout = []; // Comanche parsed template
+ public static $pdl = null; // Comanche page description
+ private static $perms = null; // observer permissions
+ private static $widgets = []; // widgets for this page
+ public static $config = []; // config cache
+ public static $override_intltext_templates = [];
+ public static $override_markup_templates = [];
+ public static $override_templateroot = null;
+ public static $override_helproot = null;
+ public static $override_helpfiles = [];
+
+ public static $session = null;
+ public static $groups;
+ public static $language;
+ public static $langsave;
+ public static $rtl = false;
+ public static $plugins_admin;
+ public static $module_loaded = false;
+ public static $query_string;
+ public static $page;
+ public static $profile;
+ public static $user;
+ public static $cid;
+ public static $contact;
+ public static $contacts;
+ public static $content;
+ public static $data = [];
+ public static $error = false;
+ public static $emojitab = false;
+ public static $cmd;
+ public static $argv;
+ public static $argc;
+ public static $module;
+ public static $pager;
+ public static $strings;
+ public static $stringsave; // used in push_lang() and pop_lang()
+ public static $hooks;
+ public static $timezone;
+ public static $interactive = true;
+ public static $plugins;
+ private static $apps = [];
+ public static $identities;
+ public static $css_sources = [];
+ public static $js_sources = [];
+ public static $linkrel = [];
+ public static $theme_info = [];
+ public static $is_sys = false;
+ public static $nav_sel;
+ public static $comanche;
public static $channel_links;
- public static $category;
+ public static $category;
// Allow themes to control internal parameters
// by changing App values in theme.php
- public static $sourcename = '';
- public static $videowidth = 425;
- public static $videoheight = 350;
- public static $force_max_items = 0;
- public static $theme_thread_allow = true;
+ public static $sourcename = '';
+ public static $videowidth = 425;
+ public static $videoheight = 350;
+ public static $force_max_items = 0;
+ public static $theme_thread_allow = true;
/**
* @brief An array for all theme-controllable parameters
@@ -821,33 +824,33 @@ class App {
* Mostly unimplemented yet. Only options 'template_engine' and
* beyond are used.
*/
- private static $theme = array(
- 'sourcename' => '',
- 'videowidth' => 425,
- 'videoheight' => 350,
+ private static $theme = [
+ 'sourcename' => '',
+ 'videowidth' => 425,
+ 'videoheight' => 350,
'force_max_items' => 0,
- 'thread_allow' => true,
- 'stylesheet' => '',
+ 'thread_allow' => true,
+ 'stylesheet' => '',
'template_engine' => 'smarty3',
- );
+ ];
/**
* @brief An array of registered template engines ('name'=>'class name')
*/
- public static $template_engines = array();
+ public static $template_engines = [];
/**
* @brief An array of instanced template engines ('name'=>'instance')
*/
- public static $template_engine_instance = array();
+ public static $template_engine_instance = [];
- private static $ldelim = array(
+ private static $ldelim = [
'internal' => '',
- 'smarty3' => '{{'
- );
- private static $rdelim = array(
+ 'smarty3' => '{{'
+ ];
+ private static $rdelim = [
'internal' => '',
- 'smarty3' => '}}'
- );
+ 'smarty3' => '}}'
+ ];
// These represent the URL which was used to access the page
@@ -869,9 +872,9 @@ class App {
// we'll reset this after we read our config file
date_default_timezone_set('UTC');
- self::$config = array('system'=>array());
- self::$page = array();
- self::$pager= array();
+ self::$config = ['system' => []];
+ self::$page = [];
+ self::$pager = [];
self::$query_string = '';
@@ -882,89 +885,89 @@ class App {
'include' . PATH_SEPARATOR
. 'library' . PATH_SEPARATOR
. 'library/langdet' . PATH_SEPARATOR
- . '.' );
+ . '.');
self::$scheme = 'http';
- if(x($_SERVER,'HTTPS') && $_SERVER['HTTPS'])
+ if (x($_SERVER, 'HTTPS') && $_SERVER['HTTPS'])
self::$scheme = 'https';
- elseif(x($_SERVER,'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443))
+ elseif (x($_SERVER, 'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443))
self::$scheme = 'https';
- if(x($_SERVER,'SERVER_NAME')) {
+ if (x($_SERVER, 'SERVER_NAME')) {
self::$hostname = punify($_SERVER['SERVER_NAME']);
- if(x($_SERVER,'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443)
+ if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443)
self::$hostname .= ':' . $_SERVER['SERVER_PORT'];
/*
* Figure out if we are running at the top of a domain
* or in a sub-directory and adjust accordingly
*/
- $path = trim(dirname($_SERVER['SCRIPT_NAME']),'/\\');
- if(isset($path) && strlen($path) && ($path != self::$path))
+ $path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
+ if (isset($path) && strlen($path) && ($path != self::$path))
self::$path = $path;
}
- if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
- self::$query_string = str_replace(['<','>'],['&lt;','&gt;'],substr($_SERVER['QUERY_STRING'], 2));
+ if ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
+ self::$query_string = str_replace(['<', '>'], ['&lt;', '&gt;'], substr($_SERVER['QUERY_STRING'], 2));
// removing trailing / - maybe a nginx problem
if (substr(self::$query_string, 0, 1) == "/")
self::$query_string = substr(self::$query_string, 1);
// change the first & to ?
- self::$query_string = preg_replace('/&/','?',self::$query_string,1);
+ self::$query_string = preg_replace('/&/', '?', self::$query_string, 1);
}
- if(x($_GET,'q'))
- self::$cmd = escape_tags(trim($_GET['q'],'/\\'));
-
- // Serve raw files from the file system in certain cases.
- $filext = pathinfo(self::$cmd, PATHINFO_EXTENSION);
-
- $serve_rawfiles = [
- 'jpg'=>'image/jpeg',
- 'jpeg'=>'image/jpeg',
- 'gif'=>'image/gif',
- 'png'=>'image/png',
- 'webp'=>'image/webp',
- 'ico'=>'image/vnd.microsoft.icon',
- 'css'=>'text/css',
- 'js'=>'text/javascript',
- 'htm'=>'text/html',
- 'html'=>'text/html',
- 'map'=>'application/octet-stream',
- 'ttf'=>'font/ttf',
- 'woff'=>'font/woff',
- 'woff2'=>'font/woff2',
- 'svg'=>'image/svg+xml'
+ if (x($_GET, 'q'))
+ self::$cmd = escape_tags(trim($_GET['q'], '/\\'));
+
+ // Serve raw files from the file system in certain cases.
+ $filext = pathinfo(self::$cmd, PATHINFO_EXTENSION);
+
+ $serve_rawfiles = [
+ 'jpg' => 'image/jpeg',
+ 'jpeg' => 'image/jpeg',
+ 'gif' => 'image/gif',
+ 'png' => 'image/png',
+ 'webp' => 'image/webp',
+ 'ico' => 'image/vnd.microsoft.icon',
+ 'css' => 'text/css',
+ 'js' => 'text/javascript',
+ 'htm' => 'text/html',
+ 'html' => 'text/html',
+ 'map' => 'application/octet-stream',
+ 'ttf' => 'font/ttf',
+ 'woff' => 'font/woff',
+ 'woff2' => 'font/woff2',
+ 'svg' => 'image/svg+xml'
];
- if (array_key_exists($filext, $serve_rawfiles) && file_exists(self::$cmd)) {
- $staticfilecwd = getcwd();
+ if (array_key_exists($filext, $serve_rawfiles) && file_exists(self::$cmd)) {
+ $staticfilecwd = getcwd();
$staticfilerealpath = realpath(self::$cmd);
- if(strpos($staticfilerealpath,$staticfilecwd) !== 0) {
- http_status_exit(404,'not found');
+ if (strpos($staticfilerealpath, $staticfilecwd) !== 0) {
+ http_status_exit(404, 'not found');
}
- $staticfileetag = '"'.md5($staticfilerealpath.filemtime(self::$cmd)).'"';
- header("ETag: ".$staticfileetag);
- header("Cache-control: max-age=2592000");
- if(isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
+ $staticfileetag = '"' . md5($staticfilerealpath . filemtime(self::$cmd)) . '"';
+ header("ETag: " . $staticfileetag);
+ header("Cache-control: max-age=2592000");
+ if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
// If HTTP_IF_NONE_MATCH is same as the generated ETag => content is the same as browser cache
// So send a 304 Not Modified response header and exit
- if($_SERVER['HTTP_IF_NONE_MATCH'] == $staticfileetag) {
- http_status_exit(304,'not modified');
+ if ($_SERVER['HTTP_IF_NONE_MATCH'] == $staticfileetag) {
+ http_status_exit(304, 'not modified');
}
}
- header("Content-type: ".$serve_rawfiles[$filext]);
- $handle = fopen(self::$cmd, "rb");
- fpassthru($handle);
- fclose($handle);
- killme();
- }
+ header("Content-type: " . $serve_rawfiles[$filext]);
+ $handle = fopen(self::$cmd, "rb");
+ fpassthru($handle);
+ fclose($handle);
+ killme();
+ }
// unix style "homedir"
- if((substr(self::$cmd, 0, 1) === '~') || (substr(self::$cmd, 0, 1) === '@'))
+ if ((substr(self::$cmd, 0, 1) === '~') || (substr(self::$cmd, 0, 1) === '@'))
self::$cmd = 'channel/' . substr(self::$cmd, 1);
/*
@@ -986,18 +989,19 @@ class App {
self::$argc = count(self::$argv);
if ((array_key_exists('0', self::$argv)) && strlen(self::$argv[0])) {
- if(strpos(self::$argv[0],'.')) {
- $_REQUEST['module_format'] = substr(self::$argv[0],strpos(self::$argv[0],'.')+1);
- self::$argv[0] = substr(self::$argv[0],0,strpos(self::$argv[0],'.'));
+ if (strpos(self::$argv[0], '.')) {
+ $_REQUEST['module_format'] = substr(self::$argv[0], strpos(self::$argv[0], '.') + 1);
+ self::$argv[0] = substr(self::$argv[0], 0, strpos(self::$argv[0], '.'));
}
self::$module = str_replace(".", "_", self::$argv[0]);
self::$module = str_replace("-", "_", self::$module);
- if(strpos(self::$module,'_') === 0)
- self::$module = substr(self::$module,1);
- } else {
- self::$argc = 1;
- self::$argv = array('home');
+ if (strpos(self::$module, '_') === 0)
+ self::$module = substr(self::$module, 1);
+ }
+ else {
+ self::$argc = 1;
+ self::$argv = ['home'];
self::$module = 'home';
}
@@ -1007,10 +1011,10 @@ class App {
* pagination
*/
- self::$pager['page'] = ((x($_GET,'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1);
+ self::$pager['page'] = ((x($_GET, 'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1);
self::$pager['itemspage'] = 60;
- self::$pager['start'] = (self::$pager['page'] * self::$pager['itemspage']) - self::$pager['itemspage'];
- if(self::$pager['start'] < 0)
+ self::$pager['start'] = (self::$pager['page'] * self::$pager['itemspage']) - self::$pager['itemspage'];
+ if (self::$pager['start'] < 0)
self::$pager['start'] = 0;
self::$pager['total'] = 0;
@@ -1018,7 +1022,7 @@ class App {
* register template engines
*/
- self::$meta= new Zotlabs\Web\HttpMeta();
+ self::$meta = new Zotlabs\Web\HttpMeta();
// create an instance of the smarty template engine so we can register it.
@@ -1029,48 +1033,48 @@ class App {
}
public static function get_baseurl($ssl = false) {
- if(is_array(self::$config)
- && array_key_exists('system',self::$config)
+ if (is_array(self::$config)
+ && array_key_exists('system', self::$config)
&& is_array(self::$config['system'])
- && array_key_exists('baseurl',self::$config['system'])
+ && array_key_exists('baseurl', self::$config['system'])
&& strlen(self::$config['system']['baseurl'])) {
// get_baseurl() is a heavily used function.
// Do not use punify() here until we find a library that performs better than what we have now.
//$url = punify(self::$config['system']['baseurl']);
$url = self::$config['system']['baseurl'];
- $url = trim($url,'\\/');
+ $url = trim($url, '\\/');
return $url;
}
$scheme = self::$scheme;
- self::$baseurl = $scheme . "://" . punify(self::$hostname) . ((isset(self::$path) && strlen(self::$path)) ? '/' . self::$path : '' );
+ self::$baseurl = $scheme . "://" . punify(self::$hostname) . ((isset(self::$path) && strlen(self::$path)) ? '/' . self::$path : '');
return self::$baseurl;
}
public static function set_baseurl($url) {
- if(is_array(self::$config)
- && array_key_exists('system',self::$config)
+ if (is_array(self::$config)
+ && array_key_exists('system', self::$config)
&& is_array(self::$config['system'])
- && array_key_exists('baseurl',self::$config['system'])
+ && array_key_exists('baseurl', self::$config['system'])
&& strlen(self::$config['system']['baseurl'])) {
$url = punify(self::$config['system']['baseurl']);
- $url = trim($url,'\\/');
+ $url = trim($url, '\\/');
}
$parsed = @parse_url($url);
self::$baseurl = $url;
- if($parsed !== false) {
+ if ($parsed !== false) {
self::$scheme = $parsed['scheme'];
self::$hostname = punify($parsed['host']);
- if(x($parsed,'port'))
+ if (x($parsed, 'port'))
self::$hostname .= ':' . $parsed['port'];
- if(x($parsed,'path'))
- self::$path = trim($parsed['path'],'\\/');
+ if (x($parsed, 'path'))
+ self::$path = trim($parsed['path'], '\\/');
}
}
@@ -1097,9 +1101,9 @@ class App {
public static function get_channel_links() {
$s = '';
$x = self::$channel_links;
- if($x && is_array($x) && count($x)) {
- foreach($x as $y) {
- if($s) {
+ if ($x && is_array($x) && count($x)) {
+ foreach ($x as $y) {
+ if ($s) {
$s .= ',';
}
$s .= '<' . $y['url'] . '>; rel="' . $y['rel'] . '"; type="' . $y['type'] . '"';
@@ -1107,6 +1111,7 @@ class App {
}
return $s;
}
+
public static function set_account($acct) {
self::$account = $acct;
}
@@ -1169,21 +1174,21 @@ class App {
public static function set_pager_itemspage($n) {
self::$pager['itemspage'] = ((intval($n) > 0) ? intval($n) : 0);
- self::$pager['start'] = (self::$pager['page'] * self::$pager['itemspage']) - self::$pager['itemspage'];
+ self::$pager['start'] = (self::$pager['page'] * self::$pager['itemspage']) - self::$pager['itemspage'];
}
public static function build_pagehead() {
- $user_scalable = ((local_channel()) ? get_pconfig(local_channel(),'system','user_scalable') : 0);
+ $user_scalable = ((local_channel()) ? get_pconfig(local_channel(), 'system', 'user_scalable') : 0);
if ($user_scalable === false)
$user_scalable = 0;
- $preload_images = ((local_channel()) ? get_pconfig(local_channel(),'system','preload_images') : 0);
+ $preload_images = ((local_channel()) ? get_pconfig(local_channel(), 'system', 'preload_images') : 0);
if ($preload_images === false)
$preload_images = 0;
- $interval = ((local_channel()) ? get_pconfig(local_channel(),'system','update_interval') : 80000);
- if($interval < 10000)
+ $interval = ((local_channel()) ? get_pconfig(local_channel(), 'system', 'update_interval') : 80000);
+ if ($interval < 10000)
$interval = 80000;
$theme_color = ((local_channel()) ? get_pconfig(local_channel(), 'redbasic', 'nav_bg') : App::$theme_info['theme_color']);
@@ -1191,17 +1196,17 @@ class App {
$theme_color = App::$theme_info['theme_color'];
}
- if(! isset(self::$page['title']) && isset(self::$config['system']['sitename']))
+ if (!isset(self::$page['title']) && isset(self::$config['system']['sitename']))
self::$page['title'] = self::$config['system']['sitename'];
- if(isset(self::$page['title']))
- $pagemeta = [ 'og:title' => self::$page['title'] ];
+ if (isset(self::$page['title']))
+ $pagemeta = ['og:title' => self::$page['title']];
- call_hooks('page_meta',$pagemeta);
+ call_hooks('page_meta', $pagemeta);
- if($pagemeta) {
+ if ($pagemeta) {
foreach ($pagemeta as $metaproperty => $metavalue) {
- self::$meta->set($metaproperty,$metavalue);
+ self::$meta->set($metaproperty, $metavalue);
}
}
@@ -1217,7 +1222,7 @@ class App {
head_add_link(['rel' => 'apple-touch-icon', 'href' => '/images/app/hz-192.png']);
- $x = [ 'header' => '' ];
+ $x = ['header' => ''];
/**
* @hooks build_pagehead
* Called when creating the HTML page header.
@@ -1231,47 +1236,47 @@ class App {
*/
self::$page['htmlhead'] = replace_macros(get_markup_template('head.tpl'),
- [
- '$preload_images' => $preload_images,
- '$user_scalable' => $user_scalable,
- '$query' => urlencode(self::$query_string),
- '$baseurl' => self::get_baseurl(),
- '$local_channel' => local_channel(),
- '$metas' => self::$meta->get(),
- '$plugins' => $x['header'],
- '$update_interval' => $interval,
- '$sse_enabled' => get_config('system', 'sse_enabled', 0),
- '$head_css' => head_get_css(),
- '$head_js' => head_get_js(),
- '$linkrel' => head_get_links(),
- '$js_strings' => js_strings(),
- '$zid' => get_my_address(),
- '$channel_id' => self::$profile['uid'] ?? 0,
- '$auto_save_draft' => ((isset(self::$profile['uid']) && feature_enabled(self::$profile['uid'], 'auto_save_draft')) ? "true" : "false"),
- '$module' => App::$module
- ]
- ) . ((isset(self::$page['htmlhead'])) ? self::$page['htmlhead'] : '');
+ [
+ '$preload_images' => $preload_images,
+ '$user_scalable' => $user_scalable,
+ '$query' => urlencode(self::$query_string),
+ '$baseurl' => self::get_baseurl(),
+ '$local_channel' => local_channel(),
+ '$metas' => self::$meta->get(),
+ '$plugins' => $x['header'],
+ '$update_interval' => $interval,
+ '$sse_enabled' => get_config('system', 'sse_enabled', 0),
+ '$head_css' => head_get_css(),
+ '$head_js' => head_get_js(),
+ '$linkrel' => head_get_links(),
+ '$js_strings' => js_strings(),
+ '$zid' => get_my_address(),
+ '$channel_id' => self::$profile['uid'] ?? 0,
+ '$auto_save_draft' => ((isset(self::$profile['uid']) && feature_enabled(self::$profile['uid'], 'auto_save_draft')) ? "true" : "false"),
+ '$module' => App::$module
+ ]
+ ) . ((isset(self::$page['htmlhead'])) ? self::$page['htmlhead'] : '');
// always put main.js at the end
self::$page['htmlhead'] .= head_get_main_js();
}
/**
- * @brief Register template engine class.
- *
- * If $name is "", is used class static property $class::$name.
- *
- * @param string $class
- * @param string $name
- */
+ * @brief Register template engine class.
+ *
+ * If $name is "", is used class static property $class::$name.
+ *
+ * @param string $class
+ * @param string $name
+ */
public static function register_template_engine($class, $name = '') {
- if(! $name) {
+ if (!$name) {
$v = get_class_vars($class);
- if(x($v, "name")) {
+ if (x($v, "name")) {
$name = $v['name'];
}
}
- if (! $name) {
+ if (!$name) {
echo "template engine <tt>$class</tt> cannot be registered without a name.\n";
killme();
}
@@ -1279,32 +1284,32 @@ class App {
}
/**
- * @brief Return template engine instance.
- *
- * If $name is not defined, return engine defined by theme, or default.
- *
- * @param string $name Template engine name
- *
- * @return object Template Engine instance
- */
- public static function template_engine($name = ''){
- if($name !== '') {
+ * @brief Return template engine instance.
+ *
+ * If $name is not defined, return engine defined by theme, or default.
+ *
+ * @param string $name Template engine name
+ *
+ * @return object Template Engine instance
+ */
+ public static function template_engine($name = '') {
+ if ($name !== '') {
$template_engine = $name;
}
else {
$template_engine = 'smarty3';
- if(x(self::$theme, 'template_engine')) {
+ if (x(self::$theme, 'template_engine')) {
$template_engine = self::$theme['template_engine'];
}
}
- if(isset(self::$template_engines[$template_engine])){
- if(isset(self::$template_engine_instance[$template_engine])){
+ if (isset(self::$template_engines[$template_engine])) {
+ if (isset(self::$template_engine_instance[$template_engine])) {
return self::$template_engine_instance[$template_engine];
}
else {
- $class = self::$template_engines[$template_engine];
- $obj = new $class;
+ $class = self::$template_engines[$template_engine];
+ $obj = new $class;
self::$template_engine_instance[$template_engine] = $obj;
return $obj;
}
@@ -1341,7 +1346,7 @@ class App {
public static function head_get_icon() {
$icon = self::$data['pageicon'];
- if(! strpos($icon,'://'))
+ if (!strpos($icon, '://'))
$icon = z_root() . $icon;
return $icon;
}
@@ -1364,20 +1369,20 @@ class App {
* @return bool|int
*/
function x($s, $k = null) {
- if($k != null) {
- if((is_array($s)) && (array_key_exists($k, $s))) {
- if($s[$k])
- return (int) 1;
- return (int) 0;
+ if ($k != null) {
+ if ((is_array($s)) && (array_key_exists($k, $s))) {
+ if ($s[$k])
+ return (int)1;
+ return (int)0;
}
return false;
}
else {
- if(isset($s)) {
- if($s) {
- return (int) 1;
+ if (isset($s)) {
+ if ($s) {
+ return (int)1;
}
- return (int) 0;
+ return (int)0;
}
return false;
}
@@ -1405,7 +1410,7 @@ function clean_urls() {
function z_path() {
$base = z_root();
- if(! clean_urls())
+ if (!clean_urls())
$base .= '/?q=';
return $base;
@@ -1414,9 +1419,9 @@ function z_path() {
/**
* @brief Returns the baseurl.
*
+ * @return string
* @see App::get_baseurl()
*
- * @return string
*/
function z_root() {
return App::get_baseurl();
@@ -1430,7 +1435,7 @@ function z_root() {
* @return string
*/
function absurl($path) {
- if(strpos($path, '/') === 0)
+ if (strpos($path, '/') === 0)
return z_path() . $path;
return $path;
@@ -1438,7 +1443,7 @@ function absurl($path) {
function os_mkdir($path, $mode = 0777, $recursive = false) {
$oldumask = @umask(0);
- $result = @mkdir($path, $mode, $recursive);
+ $result = @mkdir($path, $mode, $recursive);
@umask($oldumask);
return $result;
}
@@ -1451,17 +1456,17 @@ function os_mkdir($path, $mode = 0777, $recursive = false) {
* @return boolean
*/
function rrmdir($path) {
- if(is_dir($path) === true) {
+ if (is_dir($path) === true) {
$dir_entries = scandir($path);
if (is_array($dir_entries)) {
- $files = array_diff($dir_entries, array('.', '..'));
- foreach($files as $file) {
+ $files = array_diff($dir_entries, ['.', '..']);
+ foreach ($files as $file) {
rrmdir(realpath($path) . '/' . $file);
}
}
return rmdir($path);
}
- elseif(is_file($path) === true) {
+ elseif (is_file($path) === true) {
return unlink($path);
}
@@ -1486,24 +1491,24 @@ function is_ajax() {
*/
function check_config() {
- $saved = get_config('system','urlverify');
- if(! $saved)
- set_config('system','urlverify',bin2hex(z_root()));
+ $saved = get_config('system', 'urlverify');
+ if (!$saved)
+ set_config('system', 'urlverify', bin2hex(z_root()));
- if(($saved) && ($saved != bin2hex(z_root()))) {
+ if (($saved) && ($saved != bin2hex(z_root()))) {
// our URL changed. Do something.
$oldurl = hex2bin($saved);
logger('Baseurl changed!');
$oldhost = substr($oldurl, strpos($oldurl, '//') + 2);
- $host = substr(z_root(), strpos(z_root(), '//') + 2);
+ $host = substr(z_root(), strpos(z_root(), '//') + 2);
- $is_ip_addr = ((preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$host)) ? true : false);
- $was_ip_addr = ((preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$oldhost)) ? true : false);
+ $is_ip_addr = ((preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $host)) ? true : false);
+ $was_ip_addr = ((preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $oldhost)) ? true : false);
// only change the url to an ip address if it was already an ip and not a dns name
- if((! $is_ip_addr) || ($is_ip_addr && $was_ip_addr)) {
- fix_system_urls($oldurl,z_root());
+ if ((!$is_ip_addr) || ($is_ip_addr && $was_ip_addr)) {
+ fix_system_urls($oldurl, z_root());
set_config('system', 'urlverify', bin2hex(z_root()));
}
else
@@ -1519,11 +1524,10 @@ function check_config() {
// so we just need to keep this around a couple of weeks until the hubs that
// already exist have one
$syschan_exists = get_sys_channel();
- if (! $syschan_exists)
+ if (!$syschan_exists)
create_sys_channel();
- $x = new \Zotlabs\Lib\DB_Upgrade(DB_UPDATE_VERSION);
-
+ new DB_Upgrade(DB_UPDATE_VERSION);
plugins_sync();
@@ -1551,27 +1555,27 @@ function fix_system_urls($oldurl, $newurl) {
dbesc($oldurl . '%')
);
- if($r) {
- foreach($r as $rv) {
- $channel_address = substr($rv['hubloc_addr'],0,strpos($rv['hubloc_addr'],'@'));
+ if ($r) {
+ foreach ($r as $rv) {
+ $channel_address = substr($rv['hubloc_addr'], 0, strpos($rv['hubloc_addr'], '@'));
// get the associated channel. If we don't have a local channel, do nothing for this entry.
$c = q("select * from channel where channel_hash = '%s' limit 1",
dbesc($rv['hubloc_hash'])
);
- if(! $c)
+ if (!$c)
continue;
$parsed = @parse_url($newurl);
- if(! $parsed)
+ if (!$parsed)
continue;
$newhost = $parsed['host'];
// sometimes parse_url returns unexpected results.
- if(strpos($newhost,'/') !== false)
- $newhost = substr($newhost,0,strpos($newhost,'/'));
+ if (strpos($newhost, '/') !== false)
+ $newhost = substr($newhost, 0, strpos($newhost, '/'));
$rhs = $newhost . (($parsed['port']) ? ':' . $parsed['port'] : '');
@@ -1580,36 +1584,36 @@ function fix_system_urls($oldurl, $newurl) {
// The xchan_url might point to another nomadic identity clone
- $replace_xchan_url = ((strpos($rv['xchan_url'],$oldurl) !== false) ? true : false);
+ $replace_xchan_url = ((strpos($rv['xchan_url'], $oldurl) !== false) ? true : false);
- $x = q("update xchan set xchan_addr = '%s', xchan_url = '%s', xchan_connurl = '%s', xchan_follow = '%s', xchan_connpage = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_date = '%s' where xchan_hash = '%s'",
+ q("update xchan set xchan_addr = '%s', xchan_url = '%s', xchan_connurl = '%s', xchan_follow = '%s', xchan_connpage = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_date = '%s' where xchan_hash = '%s'",
dbesc($channel_address . '@' . $rhs),
- dbesc(($replace_xchan_url) ? str_replace($oldurl,$newurl,$rv['xchan_url']) : $rv['xchan_url']),
- dbesc(str_replace($oldurl,$newurl,$rv['xchan_connurl'])),
- dbesc(str_replace($oldurl,$newurl,$rv['xchan_follow'])),
- dbesc(str_replace($oldurl,$newurl,$rv['xchan_connpage'])),
- dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_l'])),
- dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_m'])),
- dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_s'])),
+ dbesc(($replace_xchan_url) ? str_replace($oldurl, $newurl, $rv['xchan_url']) : $rv['xchan_url']),
+ dbesc(str_replace($oldurl, $newurl, $rv['xchan_connurl'])),
+ dbesc(str_replace($oldurl, $newurl, $rv['xchan_follow'])),
+ dbesc(str_replace($oldurl, $newurl, $rv['xchan_connpage'])),
+ dbesc(str_replace($oldurl, $newurl, $rv['xchan_photo_l'])),
+ dbesc(str_replace($oldurl, $newurl, $rv['xchan_photo_m'])),
+ dbesc(str_replace($oldurl, $newurl, $rv['xchan_photo_s'])),
dbesc(datetime_convert()),
dbesc($rv['xchan_hash'])
);
- $y = q("update hubloc set hubloc_addr = '%s', hubloc_url = '%s', hubloc_id_url = '%s', hubloc_url_sig = '%s', hubloc_site_id = '%s', hubloc_host = '%s', hubloc_callback = '%s' where hubloc_hash = '%s' and hubloc_url = '%s'",
+ q("update hubloc set hubloc_addr = '%s', hubloc_url = '%s', hubloc_id_url = '%s', hubloc_url_sig = '%s', hubloc_site_id = '%s', hubloc_host = '%s', hubloc_callback = '%s' where hubloc_hash = '%s' and hubloc_url = '%s'",
dbesc($channel_address . '@' . $rhs),
dbesc($newurl),
- dbesc(str_replace($oldurl, $newurl,$rv['hubloc_id_url'])),
+ dbesc(str_replace($oldurl, $newurl, $rv['hubloc_id_url'])),
dbesc(Libzot::sign($newurl, $c[0]['channel_prvkey'])),
- dbesc(Libzot::make_xchan_hash($newurl, Config::Get('system','pubkey'))),
+ dbesc(Libzot::make_xchan_hash($newurl, Config::Get('system', 'pubkey'))),
dbesc($newhost),
dbesc($newurl . '/zot'),
dbesc($rv['xchan_hash']),
dbesc($oldurl)
);
- $z = q("update profile set photo = '%s', thumb = '%s' where uid = %d",
- dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_l'])),
- dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_m'])),
+ q("update profile set photo = '%s', thumb = '%s' where uid = %d",
+ dbesc(str_replace($oldurl, $newurl, $rv['xchan_photo_l'])),
+ dbesc(str_replace($oldurl, $newurl, $rv['xchan_photo_m'])),
intval($c[0]['channel_id'])
);
@@ -1617,16 +1621,16 @@ function fix_system_urls($oldurl, $newurl) {
dbesc('%' . $oldurl . '%'),
intval($c[0]['channel_id'])
);
- if($m) {
- foreach($m as $mm) {
+ if ($m) {
+ foreach ($m as $mm) {
q("update abook set abook_instance = '%s' where abook_id = %d",
- dbesc(str_replace($oldurl,$newurl,$mm['abook_instance'])),
+ dbesc(str_replace($oldurl, $newurl, $mm['abook_instance'])),
intval($mm['abook_id'])
);
}
}
- Zotlabs\Daemon\Master::Summon(array('Notifier', 'refresh_all', $c[0]['channel_id']));
+ Zotlabs\Daemon\Master::Summon(['Notifier', 'refresh_all', $c[0]['channel_id']]);
}
}
@@ -1636,11 +1640,11 @@ function fix_system_urls($oldurl, $newurl) {
dbesc('%' . $oldurl . '%'),
dbesc('%' . $oldurl . '%')
);
- if($a) {
- foreach($a as $aa) {
+ if ($a) {
+ foreach ($a as $aa) {
q("update app set app_url = '%s', app_photo = '%s' where id = %d",
- dbesc(str_replace($oldurl,$newurl,$aa['app_url'])),
- dbesc(str_replace($oldurl,$newurl,$aa['app_photo'])),
+ dbesc(str_replace($oldurl, $newurl, $aa['app_url'])),
+ dbesc(str_replace($oldurl, $newurl, $aa['app_photo'])),
intval($aa['id'])
);
}
@@ -1652,12 +1656,12 @@ function fix_system_urls($oldurl, $newurl) {
dbesc($oldurl . '%')
);
- if($r) {
- foreach($r as $rv) {
- $x = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s' where xchan_hash = '%s'",
- dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_l'])),
- dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_m'])),
- dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_s'])),
+ if ($r) {
+ foreach ($r as $rv) {
+ q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s' where xchan_hash = '%s'",
+ dbesc(str_replace($oldurl, $newurl, $rv['xchan_photo_l'])),
+ dbesc(str_replace($oldurl, $newurl, $rv['xchan_photo_m'])),
+ dbesc(str_replace($oldurl, $newurl, $rv['xchan_photo_s'])),
dbesc($rv['xchan_hash'])
);
}
@@ -1680,7 +1684,7 @@ function fix_system_urls($oldurl, $newurl) {
*/
function login($register = false, $form_id = 'main-login', $hiddens = false, $login_page = true) {
- $o = '';
+ $o = '';
$reg = null;
// Here's the current description of how the register link works (2018-05-15)
@@ -1705,11 +1709,11 @@ function login($register = false, $form_id = 'main-login', $hiddens = false, $lo
// your site.
- $register_policy = get_config('system','register_policy');
+ $register_policy = get_config('system', 'register_policy');
$reglink = get_config('system', 'register_link', z_root() . '/' . ((intval($register_policy) === REGISTER_CLOSED) ? 'pubsites' : 'register'));
- if($reglink !== 'none') {
+ if ($reglink !== 'none') {
$reg = [
'title' => t('Create an account to access services and applications'),
'desc' => t('Register'),
@@ -1719,17 +1723,17 @@ function login($register = false, $form_id = 'main-login', $hiddens = false, $lo
$dest_url = z_root() . '/' . App::$query_string;
- if(local_channel()) {
+ if (local_channel()) {
$tpl = get_markup_template("logout.tpl");
}
else {
$tpl = get_markup_template("login.tpl");
- if(strlen(App::$query_string))
+ if (strlen(App::$query_string))
$_SESSION['login_return_url'] = App::$query_string;
}
$email_required = get_config('system', 'verify_email');
- $lname_label = (($email_required) ? t('Email or nickname') : t('Nickname'));
+ $lname_label = (($email_required) ? t('Email or nickname') : t('Nickname'));
$o .= replace_macros($tpl, [
'$dest_url' => $dest_url,
@@ -1740,7 +1744,7 @@ function login($register = false, $form_id = 'main-login', $hiddens = false, $lo
'$form_id' => $form_id,
'$lname' => ['username', $lname_label],
'$lpassword' => ['password', t('Password')],
- '$remember_me' => [(($login_page) ? 'remember' : 'remember_me'), t('Remember me'), '', '', [t('No'),t('Yes')]],
+ '$remember_me' => [(($login_page) ? 'remember' : 'remember_me'), t('Remember me'), '', '', [t('No'), t('Yes')]],
'$hiddens' => $hiddens,
'$register' => $reg,
'$lostpass' => t('Forgot your password?'),
@@ -1789,10 +1793,10 @@ function shutdown() {
*/
function get_account_id() {
- if(isset($_SESSION['account_id']))
+ if (isset($_SESSION['account_id']))
return intval($_SESSION['account_id']);
- if(App::$account)
+ if (App::$account)
return intval(App::$account['account_id']);
return false;
@@ -1806,13 +1810,13 @@ function get_account_id() {
*
* Before 2.1 this function was called local_user().
*
- * @since 2.1
* @return int|bool channel_id or false
+ * @since 2.1
*/
function local_channel() {
- if(session_id()
- && array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated']
- && array_key_exists('uid',$_SESSION) && intval($_SESSION['uid']))
+ if (session_id()
+ && array_key_exists('authenticated', $_SESSION) && $_SESSION['authenticated']
+ && array_key_exists('uid', $_SESSION) && intval($_SESSION['uid']))
return intval($_SESSION['uid']);
return false;
@@ -1827,13 +1831,13 @@ function local_channel() {
*
* Before 2.1 this function was called remote_user().
*
- * @since 2.1
* @return string|bool visitor_id or false
+ * @since 2.1
*/
function remote_channel() {
- if(session_id()
- && array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated']
- && array_key_exists('visitor_id',$_SESSION) && $_SESSION['visitor_id'])
+ if (session_id()
+ && array_key_exists('authenticated', $_SESSION) && $_SESSION['authenticated']
+ && array_key_exists('visitor_id', $_SESSION) && $_SESSION['visitor_id'])
return $_SESSION['visitor_id'];
return false;
@@ -1842,20 +1846,20 @@ function remote_channel() {
function can_view_public_stream() {
- if(observer_prohibited(true)) {
+ if (observer_prohibited(true)) {
return false;
}
- if(! (intval(get_config('system','open_pubstream',1)))) {
- if(! get_observer_hash()) {
+ if (!(intval(get_config('system', 'open_pubstream', 1)))) {
+ if (!get_observer_hash()) {
return false;
}
}
- $site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false);
- $net_firehose = ((get_config('system','disable_discover_tab',1)) ? false : true);
+ $site_firehose = ((intval(get_config('system', 'site_firehose', 0))) ? true : false);
+ $net_firehose = ((get_config('system', 'disable_discover_tab', 1)) ? false : true);
- if(! ($site_firehose || $net_firehose)) {
+ if (!($site_firehose || $net_firehose)) {
return false;
}
@@ -1876,31 +1880,31 @@ function can_view_public_stream() {
*/
function notice($s) {
-/*
- if(! session_id())
- return;
+ /*
+ if(! session_id())
+ return;
- if(! x($_SESSION, 'sysmsg')) $_SESSION['sysmsg'] = array();
+ if(! x($_SESSION, 'sysmsg')) $_SESSION['sysmsg'] = array();
- // ignore duplicated error messages which haven't yet been displayed
- // - typically seen as multiple 'permission denied' messages
- // as a result of auto-reloading a protected page with &JS=1
+ // ignore duplicated error messages which haven't yet been displayed
+ // - typically seen as multiple 'permission denied' messages
+ // as a result of auto-reloading a protected page with &JS=1
- if(in_array($s, $_SESSION['sysmsg']))
- return;
+ if(in_array($s, $_SESSION['sysmsg']))
+ return;
- if(App::$interactive) {
- $_SESSION['sysmsg'][] = $s;
- }
-*/
+ if(App::$interactive) {
+ $_SESSION['sysmsg'][] = $s;
+ }
+ */
- $hash = get_observer_hash();
+ $hash = get_observer_hash();
$sse_id = false;
- if(! $hash) {
- if(session_id()) {
+ if (!$hash) {
+ if (session_id()) {
$sse_id = true;
- $hash = 'sse_id.' . session_id();
+ $hash = 'sse_id.' . session_id();
}
else {
return;
@@ -1909,7 +1913,7 @@ function notice($s) {
$t = get_xconfig($hash, 'sse', 'timestamp', NULL_DATE);
- if(datetime_convert('UTC', 'UTC', $t) < datetime_convert('UTC', 'UTC', '- 30 seconds')) {
+ if (datetime_convert('UTC', 'UTC', $t) < datetime_convert('UTC', 'UTC', '- 30 seconds')) {
set_xconfig($hash, 'sse', 'notifications', []);
}
@@ -1940,27 +1944,27 @@ function notice($s) {
*/
function info($s) {
-/*
- if(! session_id())
- return;
+ /*
+ if(! session_id())
+ return;
- if(! x($_SESSION, 'sysmsg_info'))
- $_SESSION['sysmsg_info'] = array();
+ if(! x($_SESSION, 'sysmsg_info'))
+ $_SESSION['sysmsg_info'] = array();
- if(in_array($s, $_SESSION['sysmsg_info']))
- return;
+ if(in_array($s, $_SESSION['sysmsg_info']))
+ return;
- if(App::$interactive)
- $_SESSION['sysmsg_info'][] = $s;
-*/
+ if(App::$interactive)
+ $_SESSION['sysmsg_info'][] = $s;
+ */
- $hash = get_observer_hash();
+ $hash = get_observer_hash();
$sse_id = false;
- if(! $hash) {
- if(session_id()) {
+ if (!$hash) {
+ if (session_id()) {
$sse_id = true;
- $hash = 'sse_id.' . session_id();
+ $hash = 'sse_id.' . session_id();
}
else {
return;
@@ -1969,19 +1973,19 @@ function info($s) {
$t = get_xconfig($hash, 'sse', 'timestamp', NULL_DATE);
- if(datetime_convert('UTC', 'UTC', $t) < datetime_convert('UTC', 'UTC', '- 30 seconds')) {
+ if (datetime_convert('UTC', 'UTC', $t) < datetime_convert('UTC', 'UTC', '- 30 seconds')) {
set_xconfig($hash, 'sse', 'notifications', []);
}
$x = get_xconfig($hash, 'sse', 'notifications');
- if($x === false)
+ if ($x === false)
$x = [];
- if(isset($x['info']) && in_array($s, $x['info']['notifications']))
+ if (isset($x['info']) && in_array($s, $x['info']['notifications']))
return;
- if(App::$interactive) {
+ if (App::$interactive) {
$x['info']['notifications'][] = $s;
set_xconfig($hash, 'sse', 'notifications', $x);
}
@@ -1994,7 +1998,7 @@ function info($s) {
* @return int
*/
function get_max_import_size() {
- return(intval(get_config('system', 'max_import_size')));
+ return (intval(get_config('system', 'max_import_size')));
}
@@ -2011,18 +2015,18 @@ function get_max_import_size() {
*
* $cmd and string args are surrounded with ""
*/
-function proc_run(){
+function proc_run() {
$args = func_get_args();
- if(! count($args))
+ if (!count($args))
return;
$args = flatten_array_recursive($args);
- $arr = [
- 'args' => $args,
- 'run_cmd' => true
+ $arr = [
+ 'args' => $args,
+ 'run_cmd' => true
];
/**
* @hooks proc_run
@@ -2032,40 +2036,40 @@ function proc_run(){
*/
call_hooks('proc_run', $arr);
- if(! $arr['run_cmd'])
+ if (!$arr['run_cmd'])
return;
- if(count($args) && $args[0] === 'php')
- $args[0] = ((x(App::$config,'system')) && (x(App::$config['system'],'php_path')) && (strlen(App::$config['system']['php_path'])) ? App::$config['system']['php_path'] : 'php');
+ if (count($args) && $args[0] === 'php')
+ $args[0] = ((x(App::$config, 'system')) && (x(App::$config['system'], 'php_path')) && (strlen(App::$config['system']['php_path'])) ? App::$config['system']['php_path'] : 'php');
// redirect proc_run statements of legacy daemon processes to the newer Daemon Master object class
// We will keep this interface until everybody has transitioned. (2016-05-20)
- if(strstr($args[1],'include/')) {
+ if (strstr($args[1], 'include/')) {
// convert 'include/foo.php' to 'Foo'
- $orig = substr(ucfirst(substr($args[1],8)),0,-4);
+ $orig = substr(ucfirst(substr($args[1], 8)), 0, -4);
logger('proc_run_redirect: ' . $orig);
- if(file_exists('Zotlabs/Daemon/' . $orig . '.php')) {
+ if (file_exists('Zotlabs/Daemon/' . $orig . '.php')) {
array_shift($args); // daemons are all run by php, pop it off the top of the array
$args[0] = $orig; // replace with the new daemon name
- logger('Redirecting old proc_run interface: ' . print_r($args,true), LOGGER_DEBUG, LOG_DEBUG);
- \Zotlabs\Daemon\Master::Summon($args); // summon the daemon
+ logger('Redirecting old proc_run interface: ' . print_r($args, true), LOGGER_DEBUG, LOG_DEBUG);
+ Master::Summon($args); // summon the daemon
return;
}
}
- $args = array_map('escapeshellarg',$args);
+ $args = array_map('escapeshellarg', $args);
$cmdline = implode(' ', $args);
- if(is_windows()) {
+ if (is_windows()) {
$cwd = getcwd();
$cmd = "cmd /c start \"title\" /D \"$cwd\" /b $cmdline";
- proc_close(proc_open($cmd, array(), $foo));
+ proc_close(proc_open($cmd, [], $foo));
}
else {
- if(get_config('system','use_proc_open'))
- proc_close(proc_open($cmdline ." &", array(), $foo));
+ if (get_config('system', 'use_proc_open'))
+ proc_close(proc_open($cmdline . " &", [], $foo));
else
exec($cmdline . ' > /dev/null &');
}
@@ -2093,13 +2097,13 @@ function is_windows() {
*/
function is_site_admin() {
- if(! session_id())
+ if (!session_id())
return false;
- if(isset($_SESSION['delegate']))
+ if (isset($_SESSION['delegate']))
return false;
- if(isset($_SESSION['authenticated']) && is_array(App::$account) && (App::$account['account_roles'] & ACCOUNT_ROLE_ADMIN))
+ if (isset($_SESSION['authenticated']) && is_array(App::$account) && (App::$account['account_roles'] & ACCOUNT_ROLE_ADMIN))
return true;
return false;
@@ -2114,10 +2118,10 @@ function is_site_admin() {
*/
function is_developer() {
- if(! session_id())
+ if (!session_id())
return false;
- if((intval($_SESSION['authenticated']))
+ if ((intval($_SESSION['authenticated']))
&& (is_array(App::$account))
&& (App::$account['account_roles'] & ACCOUNT_ROLE_DEVELOPER))
return true;
@@ -2128,9 +2132,9 @@ function is_developer() {
function load_contact_links($uid) {
- $ret = array();
+ $ret = [];
- if(! $uid || x(App::$contacts,'empty'))
+ if (!$uid || x(App::$contacts, 'empty'))
return;
// logger('load_contact_links');
@@ -2138,8 +2142,8 @@ function load_contact_links($uid) {
$r = q("SELECT abook_id, abook_flags, abook_my_perms, abook_their_perms, xchan_hash, xchan_photo_m, xchan_name, xchan_url, xchan_network from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and xchan_deleted = 0",
intval($uid)
);
- if($r) {
- foreach($r as $rv){
+ if ($r) {
+ foreach ($r as $rv) {
$ret[$rv['xchan_hash']] = $rv;
}
}
@@ -2160,18 +2164,21 @@ function load_contact_links($uid) {
*/
function build_querystring($params, $name = null) {
$ret = '';
- foreach($params as $key => $val) {
- if(is_array($val)) {
- if($name === null) {
+ foreach ($params as $key => $val) {
+ if (is_array($val)) {
+ if ($name === null) {
$ret .= build_querystring($val, $key);
- } else {
+ }
+ else {
$ret .= build_querystring($val, $name . "[$key]");
}
- } else {
+ }
+ else {
$val = urlencode($val);
- if($name != null) {
+ if ($name != null) {
$ret .= $name . "[$key]" . "=$val&";
- } else {
+ }
+ else {
$ret .= "$key=$val&";
}
}
@@ -2189,7 +2196,7 @@ function argc() {
}
function argv($x) {
- if(array_key_exists($x,App::$argv))
+ if (array_key_exists($x, App::$argv))
return App::$argv[$x];
return '';
@@ -2208,7 +2215,7 @@ function dba_timer() {
*/
function get_observer_hash() {
$observer = App::get_observer();
- if(is_array($observer))
+ if (is_array($observer))
return $observer['xchan_hash'];
return '';
@@ -2228,9 +2235,10 @@ function curPageURL() {
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443") {
- $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
- } else {
- $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
+ $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
+ }
+ else {
+ $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
}
return $pageURL;
@@ -2241,14 +2249,14 @@ function curPageURL() {
*
* If no $navname provided load default page['nav']
*
- * @todo not fully implemented yet
- *
* @param string $navname
*
* @return mixed
+ * @todo not fully implemented yet
+ *
*/
function get_custom_nav($navname) {
- if (! $navname)
+ if (!$navname)
return App::$page['nav'];
// load custom nav menu by name here
}
@@ -2264,7 +2272,7 @@ function load_pdl() {
App::$comanche = new Zotlabs\Render\Comanche();
- if (! count(App::$layout)) {
+ if (!count(App::$layout)) {
$arr = [
'module' => App::$module,
@@ -2279,28 +2287,28 @@ function load_pdl() {
call_hooks('load_pdl', $arr);
$layout = $arr['layout'];
- $n = 'mod_' . App::$module . '.pdl' ;
+ $n = 'mod_' . App::$module . '.pdl';
$u = App::$comanche->get_channel_id();
$s = '';
- if($u)
+ if ($u)
$s = get_pconfig($u, 'system', $n);
- if(! $s)
+ if (!$s)
$s = $layout;
- if((! $s) && (($p = theme_include($n)) != ''))
+ if ((!$s) && (($p = theme_include($n)) != ''))
$s = @file_get_contents($p);
- elseif(file_exists('addon/'. App::$module . '/' . $n))
- $s = @file_get_contents('addon/'. App::$module . '/' . $n);
+ elseif (file_exists('addon/' . App::$module . '/' . $n))
+ $s = @file_get_contents('addon/' . App::$module . '/' . $n);
$arr = [
'module' => App::$module,
'layout' => $s
];
- call_hooks('alter_pdl',$arr);
+ call_hooks('alter_pdl', $arr);
$s = $arr['layout'];
- if($s) {
+ if ($s) {
App::$comanche->parse($s);
App::$pdl = $s;
}
@@ -2309,8 +2317,8 @@ function load_pdl() {
function exec_pdl() {
- if(App::$pdl) {
- App::$comanche->parse(App::$pdl,1);
+ if (App::$pdl) {
+ App::$comanche->parse(App::$pdl, 1);
}
}
@@ -2333,12 +2341,12 @@ function construct_page() {
$uid = ((App::$profile_uid) ? App::$profile_uid : local_channel());
- $navbar = get_config('system','navbar','default');
- if($uid) {
- $navbar = get_pconfig($uid,'system','navbar',$navbar);
+ $navbar = get_config('system', 'navbar', 'default');
+ if ($uid) {
+ $navbar = get_pconfig($uid, 'system', 'navbar', $navbar);
}
- if($comanche && isset(App::$layout['navbar'])) {
+ if ($comanche && isset(App::$layout['navbar'])) {
$navbar = App::$layout['navbar'];
}
@@ -2365,7 +2373,7 @@ function construct_page() {
if (x(App::$page, 'template_style'))
head_add_css(App::$page['template_style'] . '.css');
else
- head_add_css(((x(App::$page, 'template')) ? App::$page['template'] : 'default' ) . '.css');
+ head_add_css(((x(App::$page, 'template')) ? App::$page['template'] : 'default') . '.css');
if (($p = theme_include('mod_' . App::$module . '.css')) != '')
head_add_css('mod_' . App::$module . '.css');
@@ -2377,7 +2385,7 @@ function construct_page() {
App::build_pagehead();
- if(isset(App::$page['pdl_content'])) {
+ if (isset(App::$page['pdl_content'])) {
App::$page['content'] = App::$comanche->region(App::$page['content']);
}
@@ -2390,10 +2398,10 @@ function construct_page() {
// This way the Comanche layout can include any existing content, alter the layout by adding stuff around it or changing the
// layout completely with a new layout definition, or replace/remove existing content.
- if($comanche) {
+ if ($comanche) {
$arr = [
- 'module' => App::$module,
- 'layout' => App::$layout
+ 'module' => App::$module,
+ 'layout' => App::$layout
];
/**
* @hooks construct_page
@@ -2406,20 +2414,20 @@ function construct_page() {
App::$layout = $arr['layout'];
- foreach(App::$layout as $k => $v) {
- if((strpos($k, 'region_') === 0) && strlen($v)) {
- if(strpos($v, '$region_') !== false) {
- $v = preg_replace_callback('/\$region_([a-zA-Z0-9]+)/ism', array(App::$comanche,'replace_region'), $v);
+ foreach (App::$layout as $k => $v) {
+ if ((strpos($k, 'region_') === 0) && strlen($v)) {
+ if (strpos($v, '$region_') !== false) {
+ $v = preg_replace_callback('/\$region_([a-zA-Z0-9]+)/ism', [App::$comanche, 'replace_region'], $v);
}
// And a couple of convenience macros
- if(strpos($v, '$htmlhead') !== false) {
+ if (strpos($v, '$htmlhead') !== false) {
$v = str_replace('$htmlhead', App::$page['htmlhead'], $v);
}
- if(strpos($v, '$nav') !== false) {
+ if (strpos($v, '$nav') !== false) {
$v = str_replace('$nav', App::$page['nav'], $v);
}
- if(strpos($v, '$content') !== false) {
+ if (strpos($v, '$content') !== false) {
$v = str_replace('$content', App::$page['content'], $v);
}
@@ -2429,7 +2437,6 @@ function construct_page() {
}
$page = App::$page;
- $profile = App::$profile;
// There's some experimental support for right-to-left text in the view/php/default.php page template.
// In v1.9 we started providing direction preference in the per language hstrings.php file
@@ -2441,41 +2448,41 @@ function construct_page() {
// security headers - see https://securityheaders.io
- if(App::get_scheme() === 'https' && isset(App::$config['system']['transport_security_header']) && intval(App::$config['system']['transport_security_header']) == 1)
+ if (App::get_scheme() === 'https' && isset(App::$config['system']['transport_security_header']) && intval(App::$config['system']['transport_security_header']) == 1)
header("Strict-Transport-Security: max-age=31536000");
- if(isset(App::$config['system']['content_security_policy']) && intval(App::$config['system']['content_security_policy']) == 1) {
+ if (isset(App::$config['system']['content_security_policy']) && intval(App::$config['system']['content_security_policy']) == 1) {
$cspsettings = [
- 'script-src' => [ "'self'", "'unsafe-inline'", "'unsafe-eval'" ],
- 'style-src' => [ "'self'", "'unsafe-inline'" ],
- 'frame-src' => [ "'self'" ]
+ 'script-src' => ["'self'", "'unsafe-inline'", "'unsafe-eval'"],
+ 'style-src' => ["'self'", "'unsafe-inline'"],
+ 'frame-src' => ["'self'"]
];
- call_hooks('content_security_policy',$cspsettings);
+ call_hooks('content_security_policy', $cspsettings);
// Legitimate CSP directives (cxref: https://content-security-policy.com/)
- $validcspdirectives=Array(
+ $validcspdirectives = [
"default-src", "script-src", "style-src",
"img-src", "connect-src", "font-src",
"object-src", "media-src", 'frame-src',
'sandbox', 'report-uri', 'child-src',
'form-action', 'frame-ancestors', 'plugin-types'
- );
- $cspheader = "Content-Security-Policy:";
+ ];
+ $cspheader = "Content-Security-Policy:";
foreach ($cspsettings as $cspdirective => $csp) {
- if (!in_array($cspdirective,$validcspdirectives)) {
- logger("INVALID CSP DIRECTIVE: ".$cspdirective,LOGGER_DEBUG);
+ if (!in_array($cspdirective, $validcspdirectives)) {
+ logger("INVALID CSP DIRECTIVE: " . $cspdirective, LOGGER_DEBUG);
continue;
}
- $cspsettingsarray=array_unique($cspsettings[$cspdirective]);
- $cspsetpolicy = implode(' ',$cspsettingsarray);
+ $cspsettingsarray = array_unique($cspsettings[$cspdirective]);
+ $cspsetpolicy = implode(' ', $cspsettingsarray);
if ($cspsetpolicy) {
- $cspheader .= " ".$cspdirective." ".$cspsetpolicy.";";
+ $cspheader .= " " . $cspdirective . " " . $cspsetpolicy . ";";
}
}
header($cspheader);
}
- if(isset(App::$config['system']['x_security_headers'])) {
+ if (isset(App::$config['system']['x_security_headers'])) {
header("X-Frame-Options: SAMEORIGIN");
header("X-Xss-Protection: 1; mode=block;");
header("X-Content-Type-Options: nosniff");
@@ -2489,12 +2496,12 @@ function construct_page() {
header("Permissions-Policy: interest-cohort=()");
}
- if(isset(App::$config['system']['public_key_pins'])) {
+ if (isset(App::$config['system']['public_key_pins'])) {
header("Public-Key-Pins: " . App::$config['system']['public_key_pins']);
}
require_once(theme_include(
- ((x(App::$page, 'template')) ? App::$page['template'] : 'default' ) . '.php' )
+ ((x(App::$page, 'template')) ? App::$page['template'] : 'default') . '.php')
);
}
@@ -2526,7 +2533,7 @@ function head_set_icon($icon) {
function head_get_icon() {
$icon = App::$data['pageicon'];
- if(! strpos($icon, '://'))
+ if (!strpos($icon, '://'))
$icon = z_root() . $icon;
return $icon;
@@ -2538,7 +2545,7 @@ function head_get_icon() {
* @return string
*/
function get_directory_realm() {
- if($x = get_config('system', 'directory_realm'))
+ if ($x = get_config('system', 'directory_realm'))
return $x;
return DIRECTORY_REALM;
@@ -2551,13 +2558,13 @@ function get_directory_realm() {
*/
function get_directory_primary() {
- $dirmode = intval(get_config('system','directory_mode'));
+ $dirmode = intval(get_config('system', 'directory_mode'));
- if($dirmode == DIRECTORY_MODE_STANDALONE || $dirmode == DIRECTORY_MODE_PRIMARY) {
+ if ($dirmode == DIRECTORY_MODE_STANDALONE || $dirmode == DIRECTORY_MODE_PRIMARY) {
return z_root();
}
- if($x = get_config('system', 'directory_primary'))
+ if ($x = get_config('system', 'directory_primary'))
return $x;
return DIRECTORY_FALLBACK_MASTER;
@@ -2576,18 +2583,18 @@ function get_poller_runtime() {
}
function z_get_upload_dir() {
- $upload_dir = get_config('system','uploaddir');
- if(! $upload_dir)
+ $upload_dir = get_config('system', 'uploaddir');
+ if (!$upload_dir)
$upload_dir = ini_get('upload_tmp_dir');
- if(! $upload_dir)
+ if (!$upload_dir)
$upload_dir = sys_get_temp_dir();
return $upload_dir;
}
function z_get_temp_dir() {
- $temp_dir = get_config('system','tempdir');
- if(! $temp_dir)
+ $temp_dir = get_config('system', 'tempdir');
+ if (!$temp_dir)
$temp_dir = sys_get_temp_dir();
return $temp_dir;
@@ -2600,12 +2607,12 @@ function z_get_temp_dir() {
* Notify admin if not.
*/
function z_check_cert() {
- if(strpos(z_root(), 'https://') !== false) {
+ if (strpos(z_root(), 'https://') !== false) {
$x = z_fetch_url(z_root() . '/siteinfo.json');
- if(! $x['success']) {
+ if (!$x['success']) {
$recurse = 0;
- $y = z_fetch_url(z_root() . '/siteinfo.json', false, $recurse, ['novalidate' => true]);
- if($y['success'])
+ $y = z_fetch_url(z_root() . '/siteinfo.json', false, $recurse, ['novalidate' => true]);
+ if ($y['success'])
cert_bad_email();
}
}
@@ -2620,7 +2627,7 @@ function z_check_cert() {
function cert_bad_email() {
return z_mail(
[
- 'toEmail' => \App::$config['system']['admin_email'],
+ 'toEmail' => App::$config['system']['admin_email'],
'messageSubject' => sprintf(t('[$Projectname] Website SSL error for %s'), App::get_hostname()),
'textVersion' => replace_macros(get_intltext_template('cert_bad_eml.tpl'),
[
@@ -2639,59 +2646,59 @@ function check_for_new_perms() {
// Do not execute if we are in the middle of a git update and the relevant versions don't match
- if( \Zotlabs\Access\Permissions::version() != \Zotlabs\Access\PermissionRoles::version())
+ if (Permissions::version() != PermissionRoles::version())
return;
- $pregistered = get_config('system','perms');
+ $pregistered = get_config('system', 'perms');
- $pcurrent = array_keys(\Zotlabs\Access\Permissions::Perms());
+ $pcurrent = array_keys(Permissions::Perms());
- if(! $pregistered) {
- set_config('system','perms',$pcurrent);
+ if (!$pregistered) {
+ set_config('system', 'perms', $pcurrent);
return;
}
$found_new_perm = false;
- foreach($pcurrent as $p) {
- if(! in_array($p,$pregistered)) {
+ foreach ($pcurrent as $p) {
+ if (!in_array($p, $pregistered)) {
$found_new_perm = true;
// for all channels
$c = q("select channel_id from channel where true");
- if($c) {
- foreach($c as $cc) {
+ if ($c) {
+ foreach ($c as $cc) {
// get the permission role
$r = q("select v from pconfig where uid = %d and cat = 'system' and k = 'permissions_role'",
intval($cc['channel_id'])
);
- if($r) {
+ if ($r) {
// get a list of connections
$x = q("select abook_xchan from abook where abook_channel = %d and abook_self = 0",
intval($cc['channel_id'])
);
// get the permissions role details
- $rp = \Zotlabs\Access\PermissionRoles::role_perms($r[0]['v']);
- if($rp) {
+ $rp = PermissionRoles::role_perms($r[0]['v']);
+ if ($rp) {
// for custom permission roles we need to customise how we initiate this new permission
- if(array_key_exists('role',$rp) && ($rp['role'] === 'custom' || $rp['role'] === '')) {
- \Zotlabs\Access\PermissionRoles::new_custom_perms($cc['channel_id'],$p,$x);
+ if (array_key_exists('role', $rp) && ($rp['role'] === 'custom' || $rp['role'] === '')) {
+ PermissionRoles::new_custom_perms($cc['channel_id'], $p, $x);
}
else {
// set the channel limits if appropriate or 0
- if(array_key_exists('limits',$rp) && array_key_exists($p,$rp['limits'])) {
- \Zotlabs\Access\PermissionLimits::Set($cc['channel_id'],$p,$rp['limits'][$p]);
+ if (array_key_exists('limits', $rp) && array_key_exists($p, $rp['limits'])) {
+ PermissionLimits::Set($cc['channel_id'], $p, $rp['limits'][$p]);
}
else {
- \Zotlabs\Access\PermissionLimits::Set($cc['channel_id'],$p,0);
+ PermissionLimits::Set($cc['channel_id'], $p, 0);
}
- $set = ((array_key_exists('perms_connect',$rp) && in_array($p,$rp['perms_connect'])) ? 1 : 0);
+ $set = ((array_key_exists('perms_connect', $rp) && in_array($p, $rp['perms_connect'])) ? 1 : 0);
// foreach connection set to the perms_connect value
- if($x) {
- foreach($x as $xx) {
- set_abconfig($cc['channel_id'],$xx['abook_xchan'],'my_perms',$p,intval($set));
+ if ($x) {
+ foreach ($x as $xx) {
+ set_abconfig($cc['channel_id'], $xx['abook_xchan'], 'my_perms', $p, intval($set));
}
}
}
@@ -2703,8 +2710,8 @@ function check_for_new_perms() {
}
// We should probably call perms_refresh here, but this should get pushed in 24 hours and there is no urgency
- if($found_new_perm)
- set_config('system','perms',$pcurrent);
+ if ($found_new_perm)
+ set_config('system', 'perms', $pcurrent);
}
@@ -2713,42 +2720,42 @@ function check_for_new_perms() {
*/
function check_cron_broken() {
- $d = get_config('system','lastcron');
+ $d = get_config('system', 'lastcron');
- if((! $d) || ($d < datetime_convert('UTC','UTC','now - 4 hours'))) {
- Zotlabs\Daemon\Master::Summon(array('Cron'));
- set_config('system','lastcron',datetime_convert());
+ if ((!$d) || ($d < datetime_convert('UTC', 'UTC', 'now - 4 hours'))) {
+ Zotlabs\Daemon\Master::Summon(['Cron']);
+ set_config('system', 'lastcron', datetime_convert());
}
- $t = get_config('system','lastcroncheck');
- if(! $t) {
+ $t = get_config('system', 'lastcroncheck');
+ if (!$t) {
// never checked before. Start the timer.
- set_config('system','lastcroncheck',datetime_convert());
+ set_config('system', 'lastcroncheck', datetime_convert());
return;
}
- if($t > datetime_convert('UTC','UTC','now - 3 days')) {
+ if ($t > datetime_convert('UTC', 'UTC', 'now - 3 days')) {
// Wait for 3 days before we do anything so as not to swamp the admin with messages
return;
}
- set_config('system','lastcroncheck',datetime_convert());
+ set_config('system', 'lastcroncheck', datetime_convert());
- if(($d) && ($d > datetime_convert('UTC','UTC','now - 3 days'))) {
+ if (($d) && ($d > datetime_convert('UTC', 'UTC', 'now - 3 days'))) {
// Scheduled tasks have run successfully in the last 3 days.
return;
}
return z_mail(
[
- 'toEmail' => \App::$config['system']['admin_email'],
+ 'toEmail' => App::$config['system']['admin_email'],
'messageSubject' => sprintf(t('[$Projectname] Cron tasks not running on %s'), App::get_hostname()),
'textVersion' => replace_macros(get_intltext_template('cron_bad_eml.tpl'),
[
'$sitename' => App::$config['system']['sitename'],
- '$siteurl' => z_root(),
+ '$siteurl' => z_root(),
'$error' => t('Cron/Scheduled tasks not running.'),
- '$lastdate' => (($d)? $d : t('never'))
+ '$lastdate' => (($d) ? $d : t('never'))
]
)
]
@@ -2763,8 +2770,8 @@ function check_cron_broken() {
* @return boolean
*/
function observer_prohibited($allow_account = false) {
- if($allow_account) {
- return (((get_config('system', 'block_public')) && (! get_account_id()) && (! remote_channel())) ? true : false );
+ if ($allow_account) {
+ return (((get_config('system', 'block_public')) && (!get_account_id()) && (!remote_channel())) ? true : false);
}
- return (((get_config('system', 'block_public')) && (! local_channel()) && (! remote_channel())) ? true : false );
+ return (((get_config('system', 'block_public')) && (!local_channel()) && (!remote_channel())) ? true : false);
}