aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Admin
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module/Admin')
-rw-r--r--Zotlabs/Module/Admin/Account_edit.php11
-rw-r--r--Zotlabs/Module/Admin/Accounts.php260
-rw-r--r--Zotlabs/Module/Admin/Addons.php290
-rw-r--r--Zotlabs/Module/Admin/Channels.php54
-rw-r--r--Zotlabs/Module/Admin/Dbsync.php14
-rw-r--r--Zotlabs/Module/Admin/Features.php47
-rw-r--r--Zotlabs/Module/Admin/Logs.php49
-rw-r--r--Zotlabs/Module/Admin/Profs.php57
-rw-r--r--Zotlabs/Module/Admin/Queueworker.php17
-rw-r--r--Zotlabs/Module/Admin/Security.php73
-rw-r--r--Zotlabs/Module/Admin/Site.php258
-rw-r--r--Zotlabs/Module/Admin/Themes.php7
12 files changed, 464 insertions, 673 deletions
diff --git a/Zotlabs/Module/Admin/Account_edit.php b/Zotlabs/Module/Admin/Account_edit.php
index 0300fb10c..35a15133f 100644
--- a/Zotlabs/Module/Admin/Account_edit.php
+++ b/Zotlabs/Module/Admin/Account_edit.php
@@ -8,6 +8,11 @@ class Account_edit {
function post() {
+ // Validate CSRF token
+ //
+ // We terminate with a 403 Forbidden status if the check fails.
+ check_form_security_token_ForbiddenOnErr('admin_account_edit', 'security');
+
$account_id = $_REQUEST['aid'];
if(! $account_id)
@@ -18,7 +23,7 @@ class Account_edit {
if($pass1 && $pass2 && ($pass1 === $pass2)) {
$salt = random_string(32);
$password_encoded = hash('whirlpool', $salt . $pass1);
- $r = q("update account set account_salt = '%s', account_password = '%s',
+ $r = q("update account set account_salt = '%s', account_password = '%s',
account_password_changed = '%s' where account_id = %d",
dbesc($salt),
dbesc($password_encoded),
@@ -34,7 +39,7 @@ class Account_edit {
$account_level = 5;
$account_language = trim($_REQUEST['account_language']);
- $r = q("update account set account_service_class = '%s', account_level = %d, account_language = '%s'
+ $r = q("update account set account_service_class = '%s', account_level = %d, account_language = '%s'
where account_id = %d",
dbesc($service_class),
intval($account_level),
@@ -62,8 +67,8 @@ class Account_edit {
return '';
}
-
$a = replace_macros(get_markup_template('admin_account_edit.tpl'), [
+ '$security' => get_form_security_token('admin_account_edit'),
'$account' => $x[0],
'$title' => t('Account Edit'),
'$pass1' => [ 'pass1', t('New Password'), ' ','' ],
diff --git a/Zotlabs/Module/Admin/Accounts.php b/Zotlabs/Module/Admin/Accounts.php
index b067b4bf6..108231d7d 100644
--- a/Zotlabs/Module/Admin/Accounts.php
+++ b/Zotlabs/Module/Admin/Accounts.php
@@ -2,137 +2,37 @@
namespace Zotlabs\Module\Admin;
-
+use Zotlabs\Lib\Config;
class Accounts {
- /**
- * @brief Handle POST actions on accounts admin page.
- *
- * This function is called when on the admin user/account page the form was
- * submitted to handle multiple operations at once. If one of the icons next
- * to an entry are pressed the function admin_page_accounts() will handle this.
- *
- */
const MYP = 'ZAR'; // ZAR2x
const VERSION = '2.0.0';
- function post() {
+ /**
+ * Handle POST actions on accounts admin page.
+ */
+ public function post() {
- $pending = ( x($_POST, 'pending') ? $_POST['pending'] : array() );
- $users = ( x($_POST, 'user') ? $_POST['user'] : array() );
- $blocked = ( x($_POST, 'blocked') ? $_POST['blocked'] : array() );
+ $pending = x($_POST, 'pending') ? $_POST['pending'] : array();
check_form_security_token_redirectOnErr('/admin/accounts', 'admin_accounts');
- $isajax = is_ajax();
- $rc = 0;
-
- If (!is_site_admin()) {
- if ($isajax) {
- killme();
- exit;
- }
- goaway(z_root() . '/');
- }
-
- if ($isajax) {
- //$debug = print_r($_SESSION[self::MYP],true);
- $zarop = (x($_POST['zardo']) && preg_match('/^[ad]{1,1}$/', $_POST['zardo']) )
- ? $_POST['zardo'] : '';
- // zarat arrives with leading underscore _n
- $zarat = (x($_POST['zarat']) && preg_match('/^_{1,1}[0-9]{1,6}$/', $_POST['zarat']) )
- ? substr($_POST['zarat'],1) : '';
- $zarse = (x($_POST['zarse']) && preg_match('/^[0-9a-f]{8,8}$/', $_POST['zarse']) )
- ? hex2bin($_POST['zarse']) : '';
-
- if ($zarop && $zarat >= 0 && $zarse && $zarse == $_SESSION[self::MYP]['h'][$zarat]) {
-
- //
- if ($zarop == 'd') {
- $rd = q("UPDATE register SET reg_vital = 0 WHERE reg_id = %d AND SUBSTR(reg_hash,1,4) = '%s' ",
- intval($_SESSION[self::MYP]['i'][$zarat]),
- dbesc($_SESSION[self::MYP]['h'][$zarat])
- );
- $rc = '×';
- }
- elseif ($zarop == 'a') {
- // approval, REGISTER_DENIED by user 0x0040, REGISTER_AGREED by user 0x0020 @Regate
- $rd = q("UPDATE register SET reg_flags = (reg_flags & ~ 16), "
- . " reg_vital = (CASE (reg_flags & ~ 48) WHEN 0 THEN 0 ELSE 1 END) "
- . " WHERE reg_vital = 1 AND reg_id = %d AND SUBSTR(reg_hash,1,4) = '%s' ",
- intval($_SESSION[self::MYP]['i'][$zarat]),
- dbesc($_SESSION[self::MYP]['h'][$zarat])
- );
- $rc = 0;
- $rs = q("SELECT * from register WHERE reg_id = %d ",
- intval($_SESSION[self::MYP]['i'][$zarat])
- );
- if ($rs && ($rs[0]['reg_flags'] & ~ 48) == 0) {
- // create account
- $rc = 'ok'.$rs[0]['reg_id'];
- $ac = create_account_from_register($rs[0]);
- if ( $ac['success'] ) {
- $rc .= '✔';
-
- $auto_create = get_config('system','auto_channel_create',1);
-
- if($auto_create) {
- $reonar = json_decode($rs[0]['reg_stuff'], true);
- // prepare channel creation
- if($reonar['chan.name'])
- set_aconfig($ac['account']['account_id'], 'register', 'channel_name', $reonar['chan.name']);
-
- if($reonar['chan.did1'])
- set_aconfig($ac['account']['account_id'], 'register', 'channel_address', $reonar['chan.did1']);
-
- $permissions_role = get_config('system','default_permissions_role');
- if($permissions_role)
- set_aconfig($ac['account']['account_id'], 'register', 'permissions_role', $permissions_role);
-
- // create channel
- $new_channel = auto_channel_create($ac['account']['account_id']);
-
- if($new_channel['success']) {
- $rc .= ' c,ok' . $new_channel['channel']['channel_id'] . '✔';
- }
- else {
- $rc .= ' c ×';
- }
- }
-
-
- }
- } else {
- $rc='oh ×';
- }
- }
- echo json_encode(array('re' => $zarop, 'at' => '_' . $zarat, 'rc' => $rc));
- }
+ if (is_ajax()) {
+ $this->handle_ajax_request();
killme();
- exit;
}
// change to switch structure?
// account block/unblock button was submitted
if (x($_POST, 'page_accounts_block')) {
- for ($i = 0; $i < count($users); $i++) {
- // if account is blocked remove blocked bit-flag, otherwise add blocked bit-flag
- $op = ($blocked[$i]) ? '& ~' : '| ';
- q("UPDATE account SET account_flags = (account_flags $op%d) WHERE account_id = %d",
- intval(ACCOUNT_BLOCKED),
- intval($users[$i])
- );
- }
- notice( sprintf( tt("%s account blocked/unblocked", "%s account blocked/unblocked", count($users)), count($users)) );
+ $this->block_unblock_accounts();
}
+
// account delete button was submitted
if (x($_POST, 'page_accounts_delete')) {
- foreach ($users as $uid){
- account_remove($uid, true, false);
- }
- notice( sprintf( tt("%s account deleted", "%s accounts deleted", count($users)), count($users)) );
+ $this->delete_accounts();
}
// registration approved button was submitted
if (x($_POST, 'page_accounts_approve')) {
@@ -351,5 +251,143 @@ class Accounts {
return $o;
}
+ private function handle_ajax_request(): void {
+ //$debug = print_r($_SESSION[self::MYP],true);
+ $zarop = (x($_POST['zardo']) && preg_match('/^[ad]{1,1}$/', $_POST['zardo']) )
+ ? $_POST['zardo'] : '';
+ // zarat arrives with leading underscore _n
+ $zarat = (x($_POST['zarat']) && preg_match('/^_{1,1}[0-9]{1,6}$/', $_POST['zarat']) )
+ ? substr($_POST['zarat'],1) : '';
+ $zarse = (x($_POST['zarse']) && preg_match('/^[0-9a-f]{8,8}$/', $_POST['zarse']) )
+ ? hex2bin($_POST['zarse']) : '';
+
+ if ($zarop && $zarat >= 0 && $zarse && $zarse == $_SESSION[self::MYP]['h'][$zarat]) {
+
+ //
+ if ($zarop == 'd') {
+ $rd = q("UPDATE register SET reg_vital = 0 WHERE reg_id = %d AND SUBSTR(reg_hash,1,4) = '%s' ",
+ intval($_SESSION[self::MYP]['i'][$zarat]),
+ dbesc($_SESSION[self::MYP]['h'][$zarat])
+ );
+ $rc = '×';
+ }
+ elseif ($zarop == 'a') {
+ // approval, REGISTER_DENIED by user 0x0040, REGISTER_AGREED by user 0x0020 @Regate
+ $rd = q("UPDATE register SET reg_flags = (reg_flags & ~ 16), "
+ . " reg_vital = (CASE (reg_flags & ~ 48) WHEN 0 THEN 0 ELSE 1 END) "
+ . " WHERE reg_vital = 1 AND reg_id = %d AND SUBSTR(reg_hash,1,4) = '%s' ",
+ intval($_SESSION[self::MYP]['i'][$zarat]),
+ dbesc($_SESSION[self::MYP]['h'][$zarat])
+ );
+ $rc = 0;
+ $rs = q("SELECT * from register WHERE reg_id = %d ",
+ intval($_SESSION[self::MYP]['i'][$zarat])
+ );
+ if ($rs && ($rs[0]['reg_flags'] & ~ 48) == 0) {
+ // create account
+ $rc = 'ok'.$rs[0]['reg_id'];
+ $ac = create_account_from_register($rs[0]);
+ if ( $ac['success'] ) {
+ $rc .= '✔';
+
+ $auto_create = Config::Get('system','auto_channel_create',1);
+
+ if($auto_create) {
+ $reonar = json_decode($rs[0]['reg_stuff'], true);
+ // prepare channel creation
+ if($reonar['chan.name'])
+ set_aconfig($ac['account']['account_id'], 'register', 'channel_name', $reonar['chan.name']);
+
+ if($reonar['chan.did1'])
+ set_aconfig($ac['account']['account_id'], 'register', 'channel_address', $reonar['chan.did1']);
+
+ $permissions_role = Config::Get('system','default_permissions_role');
+ if($permissions_role)
+ set_aconfig($ac['account']['account_id'], 'register', 'permissions_role', $permissions_role);
+
+ // create channel
+ $new_channel = auto_channel_create($ac['account']['account_id']);
+
+ if($new_channel['success']) {
+ $rc .= ' c,ok' . $new_channel['channel']['channel_id'] . '✔';
+ }
+ else {
+ $rc .= ' c ×';
+ }
+ }
+
+
+ }
+ } else {
+ $rc='oh ×';
+ }
+ }
+ echo json_encode(array('re' => $zarop, 'at' => '_' . $zarat, 'rc' => $rc));
+ }
+ }
+
+ /**
+ * Block or unblock accounts given by the `user` and `blocked` POST params.
+ *
+ * The post params `user` and `blocked` must be present and arrays of equal
+ * lengths. The `user` array should contain account id's or the accounts to
+ * process, and the `blocked` array holds a corresponding boolean value to
+ * indicate that the account at the same offset in the `user` array is or is
+ * not blocked.
+ *
+ * An account that is _not_ blocked will be blocked, and accounts that _are_
+ * blocked will be unblocked.
+ *
+ * @SuppressWarnings(PHPMD.ShortVariable)
+ */
+ private function block_unblock_accounts(): void {
+ if (!isset($_POST['user']) || !isset($_POST['blocked'])) {
+ return;
+ }
+
+ $users = $_POST['user'];
+ $blocked = $_POST['blocked'];
+
+ if (!is_array($users) || !is_array($blocked)) {
+ return;
+ }
+
+ foreach($users as $i => $id) {
+ // if account is blocked remove blocked bit-flag, otherwise add blocked bit-flag
+ $op = $blocked[$i] ? '& ~' : '| ';
+
+ q("UPDATE account SET account_flags = (account_flags $op%d) WHERE account_id = %d",
+ intval(ACCOUNT_BLOCKED),
+ intval($id)
+ );
+ }
+
+ $count = count($users);
+ $fmt = tt("%s account blocked/unblocked", "%s account blocked/unblocked", $count);
+ notice(sprintf($fmt, $count));
+ }
+
+ /**
+ * Delete multiple accounts given by the `user` POST param.
+ */
+ private function delete_accounts(): void {
+ if (!isset($_POST['user'])) {
+ return;
+ }
+
+ $users = $_POST['user'];
+
+ if (!is_array($users)) {
+ return;
+ }
+
+ foreach ($users as $uid){
+ account_remove($uid, true, false);
+ }
+
+ $count = count($users);
+ $fmt = tt("%s account deleted", "%s accounts deleted", $count);
+ notice(sprintf($fmt, $count));
+ }
}
diff --git a/Zotlabs/Module/Admin/Addons.php b/Zotlabs/Module/Admin/Addons.php
index e088353e3..0cb173e7c 100644
--- a/Zotlabs/Module/Admin/Addons.php
+++ b/Zotlabs/Module/Admin/Addons.php
@@ -3,8 +3,8 @@
namespace Zotlabs\Module\Admin;
use App;
-use \Zotlabs\Storage\GitRepo;
-use \Michelf\MarkdownExtra;
+use Zotlabs\Lib\Config;
+use Michelf\MarkdownExtra;
class Addons {
@@ -23,227 +23,6 @@ class Addons {
goaway(z_root() . '/admin/addons/' . argv(2) );
}
- elseif(argc() > 2) {
- switch(argv(2)) {
- case 'updaterepo':
- if (array_key_exists('repoName', $_REQUEST)) {
- $repoName = $_REQUEST['repoName'];
- }
- else {
- json_return_and_die(array('message' => 'No repo name provided.', 'success' => false));
- }
- $extendDir = 'store/[data]/git/sys/extend';
- $addonDir = $extendDir . '/addon';
- if (!file_exists($extendDir)) {
- if (!mkdir($extendDir, 0770, true)) {
- logger('Error creating extend folder: ' . $extendDir);
- json_return_and_die(array('message' => 'Error creating extend folder: ' . $extendDir, 'success' => false));
- }
- else {
- if (!symlink(realpath('extend/addon'), $addonDir)) {
- logger('Error creating symlink to addon folder: ' . $addonDir);
- json_return_and_die(array('message' => 'Error creating symlink to addon folder: ' . $addonDir, 'success' => false));
- }
- }
- }
- $repoDir = 'store/[data]/git/sys/extend/addon/' . $repoName;
- if (!is_dir($repoDir)) {
- logger('Repo directory does not exist: ' . $repoDir);
- json_return_and_die(array('message' => 'Invalid addon repo.', 'success' => false));
- }
- if (!is_writable($repoDir)) {
- logger('Repo directory not writable to web server: ' . $repoDir);
- json_return_and_die(array('message' => 'Repo directory not writable to web server.', 'success' => false));
- }
- $git = new GitRepo('sys', null, false, $repoName, $repoDir);
- try {
- if ($git->pull()) {
- $files = array_diff(scandir($repoDir), array('.', '..'));
- foreach ($files as $file) {
- if (is_dir($repoDir . '/' . $file) && $file !== '.git') {
- $source = '../extend/addon/' . $repoName . '/' . $file;
- $target = realpath('addon/') . '/' . $file;
- unlink($target);
- if (!symlink($source, $target)) {
- logger('Error linking addons to /addon');
- json_return_and_die(array('message' => 'Error linking addons to /addon', 'success' => false));
- }
- }
- }
- json_return_and_die(array('message' => 'Repo updated.', 'success' => true));
- } else {
- json_return_and_die(array('message' => 'Error updating addon repo.', 'success' => false));
- }
- } catch (\PHPGit\Exception\GitException $e) {
- json_return_and_die(array('message' => 'Error updating addon repo.', 'success' => false));
- }
- break;
- case 'removerepo':
- if (array_key_exists('repoName', $_REQUEST)) {
- $repoName = $_REQUEST['repoName'];
- } else {
- json_return_and_die(array('message' => 'No repo name provided.', 'success' => false));
- }
- $extendDir = 'store/[data]/git/sys/extend';
- $addonDir = $extendDir . '/addon';
- if (!file_exists($extendDir)) {
- if (!mkdir($extendDir, 0770, true)) {
- logger('Error creating extend folder: ' . $extendDir);
- json_return_and_die(array('message' => 'Error creating extend folder: ' . $extendDir, 'success' => false));
- } else {
- if (!symlink(realpath('extend/addon'), $addonDir)) {
- logger('Error creating symlink to addon folder: ' . $addonDir);
- json_return_and_die(array('message' => 'Error creating symlink to addon folder: ' . $addonDir, 'success' => false));
- }
- }
- }
- $repoDir = 'store/[data]/git/sys/extend/addon/' . $repoName;
- if (!is_dir($repoDir)) {
- logger('Repo directory does not exist: ' . $repoDir);
- json_return_and_die(array('message' => 'Invalid addon repo.', 'success' => false));
- }
- if (!is_writable($repoDir)) {
- logger('Repo directory not writable to web server: ' . $repoDir);
- json_return_and_die(array('message' => 'Repo directory not writable to web server.', 'success' => false));
- }
- /// @TODO remove directory and unlink /addon/files
- if (rrmdir($repoDir)) {
- json_return_and_die(array('message' => 'Repo deleted.', 'success' => true));
- } else {
- json_return_and_die(array('message' => 'Error deleting addon repo.', 'success' => false));
- }
- break;
- case 'installrepo':
- if (array_key_exists('repoURL', $_REQUEST)) {
- require_once('library/PHPGit.autoload.php'); // Load PHPGit dependencies
- $repoURL = $_REQUEST['repoURL'];
- $extendDir = 'store/[data]/git/sys/extend';
- $addonDir = $extendDir . '/addon';
- if (!file_exists($extendDir)) {
- if (!mkdir($extendDir, 0770, true)) {
- logger('Error creating extend folder: ' . $extendDir);
- json_return_and_die(array('message' => 'Error creating extend folder: ' . $extendDir, 'success' => false));
- } else {
- if (!symlink(realpath('extend/addon'), $addonDir)) {
- logger('Error creating symlink to addon folder: ' . $addonDir);
- json_return_and_die(array('message' => 'Error creating symlink to addon folder: ' . $addonDir, 'success' => false));
- }
- }
- }
- if (!is_writable($extendDir)) {
- logger('Directory not writable to web server: ' . $extendDir);
- json_return_and_die(array('message' => 'Directory not writable to web server.', 'success' => false));
- }
- $repoName = null;
- if (array_key_exists('repoName', $_REQUEST) && $_REQUEST['repoName'] !== '') {
- $repoName = $_REQUEST['repoName'];
- } else {
- $repoName = GitRepo::getRepoNameFromURL($repoURL);
- }
- if (!$repoName) {
- logger('Invalid git repo');
- json_return_and_die(array('message' => 'Invalid git repo', 'success' => false));
- }
- $repoDir = $addonDir . '/' . $repoName;
- $tempRepoBaseDir = 'store/[data]/git/sys/temp/';
- $tempAddonDir = $tempRepoBaseDir . $repoName;
-
- if (!is_writable($addonDir) || !is_writable($tempAddonDir)) {
- logger('Temp repo directory or /extend/addon not writable to web server: ' . $tempAddonDir);
- json_return_and_die(array('message' => 'Temp repo directory not writable to web server.', 'success' => false));
- }
- rename($tempAddonDir, $repoDir);
-
- if (!is_writable(realpath('addon/'))) {
- logger('/addon directory not writable to web server: ' . $tempAddonDir);
- json_return_and_die(array('message' => '/addon directory not writable to web server.', 'success' => false));
- }
- $files = array_diff(scandir($repoDir), array('.', '..'));
- foreach ($files as $file) {
- if (is_dir($repoDir . '/' . $file) && $file !== '.git') {
- $source = '../extend/addon/' . $repoName . '/' . $file;
- $target = realpath('addon/') . '/' . $file;
- unlink($target);
- if (!symlink($source, $target)) {
- logger('Error linking addons to /addon');
- json_return_and_die(array('message' => 'Error linking addons to /addon', 'success' => false));
- }
- }
- }
- $git = new GitRepo('sys', $repoURL, false, $repoName, $repoDir);
- $repo = $git->probeRepo();
- json_return_and_die(array('repo' => $repo, 'message' => '', 'success' => true));
- }
- break;
- case 'addrepo':
- if (array_key_exists('repoURL', $_REQUEST)) {
- require_once('library/PHPGit.autoload.php'); // Load PHPGit dependencies
- $repoURL = $_REQUEST['repoURL'];
- $extendDir = 'store/[data]/git/sys/extend';
- $addonDir = $extendDir . '/addon';
- $tempAddonDir = realpath('store/[data]') . '/git/sys/temp';
- if (!file_exists($extendDir)) {
- if (!mkdir($extendDir, 0770, true)) {
- logger('Error creating extend folder: ' . $extendDir);
- json_return_and_die(array('message' => 'Error creating extend folder: ' . $extendDir, 'success' => false));
- } else {
- if (!symlink(realpath('extend/addon'), $addonDir)) {
- logger('Error creating symlink to addon folder: ' . $addonDir);
- json_return_and_die(array('message' => 'Error creating symlink to addon folder: ' . $addonDir, 'success' => false));
- }
- }
- }
- if (!is_dir($tempAddonDir)) {
- if (!mkdir($tempAddonDir, 0770, true)) {
- logger('Error creating temp plugin repo folder: ' . $tempAddonDir);
- json_return_and_die(array('message' => 'Error creating temp plugin repo folder: ' . $tempAddonDir, 'success' => false));
- }
- }
- $repoName = null;
- if (array_key_exists('repoName', $_REQUEST) && $_REQUEST['repoName'] !== '') {
- $repoName = $_REQUEST['repoName'];
- } else {
- $repoName = GitRepo::getRepoNameFromURL($repoURL);
- }
- if (!$repoName) {
- logger('Invalid git repo');
- json_return_and_die(array('message' => 'Invalid git repo: ' . $repoName, 'success' => false));
- }
- $repoDir = $tempAddonDir . '/' . $repoName;
- if (!is_writable($tempAddonDir)) {
- logger('Temporary directory for new addon repo is not writable to web server: ' . $tempAddonDir);
- json_return_and_die(array('message' => 'Temporary directory for new addon repo is not writable to web server.', 'success' => false));
- }
- // clone the repo if new automatically
- $git = new GitRepo('sys', $repoURL, true, $repoName, $repoDir);
-
- $remotes = $git->git->remote();
- $fetchURL = $remotes['origin']['fetch'];
- if ($fetchURL !== $git->url) {
- if (rrmdir($repoDir)) {
- $git = new GitRepo('sys', $repoURL, true, $repoName, $repoDir);
- } else {
- json_return_and_die(array('message' => 'Error deleting existing addon repo.', 'success' => false));
- }
- }
- $repo = $git->probeRepo();
- $repo['readme'] = $repo['manifest'] = null;
- foreach ($git->git->tree('master') as $object) {
- if ($object['type'] == 'blob' && (strtolower($object['file']) === 'readme.md' || strtolower($object['file']) === 'readme')) {
- $repo['readme'] = MarkdownExtra::defaultTransform($git->git->cat->blob($object['hash']));
- } else if ($object['type'] == 'blob' && strtolower($object['file']) === 'manifest.json') {
- $repo['manifest'] = $git->git->cat->blob($object['hash']);
- }
- }
- json_return_and_die(array('repo' => $repo, 'message' => '', 'success' => true));
- } else {
- json_return_and_die(array('message' => 'No repo URL provided', 'success' => false));
- }
- break;
- default:
- break;
- }
- }
}
/**
@@ -276,7 +55,7 @@ class Addons {
if ($idz !== false) {
unset(App::$plugins[$idz]);
uninstall_plugin($plugin);
- set_config("system","addon", implode(", ",App::$plugins));
+ Config::Set("system","addon", implode(", ",App::$plugins));
}
}
$info['disabled'] = 1-intval($x);
@@ -297,7 +76,7 @@ class Addons {
$pinstalled = true;
info( sprintf( t("Plugin %s enabled."), $plugin ) );
}
- set_config("system","addon", implode(", ",App::$plugins));
+ Config::Set("system","addon", implode(", ",App::$plugins));
if($pinstalled) {
@require_once("addon/$plugin/$plugin.php");
@@ -395,7 +174,7 @@ class Addons {
if ($idz !== false) {
unset(App::$plugins[$idz]);
uninstall_plugin($id);
- set_config("system","addon", implode(", ",App::$plugins));
+ Config::Set("system","addon", implode(", ",App::$plugins));
}
}
$info['disabled'] = 1-intval($x);
@@ -407,37 +186,6 @@ class Addons {
usort($plugins,'self::plugin_sort');
- $allowManageRepos = false;
- if(is_writable('extend/addon') && is_writable('store/[data]')) {
- $allowManageRepos = true;
- }
-
- $admin_plugins_add_repo_form= replace_macros(
- get_markup_template('admin_plugins_addrepo.tpl'), array(
- '$post' => 'admin/addons/addrepo',
- '$desc' => t('Enter the public git repository URL of the addon repo.'),
- '$repoURL' => array('repoURL', t('Addon repo git URL'), '', ''),
- '$repoName' => array('repoName', t('Custom repo name'), '', '', t('(optional)')),
- '$submit' => t('Download Addon Repo')
- )
- );
- $newRepoModalID = random_string(3);
- $newRepoModal = replace_macros(
- get_markup_template('generic_modal.tpl'), array(
- '$id' => $newRepoModalID,
- '$title' => t('Install new repo'),
- '$ok' => t('Install'),
- '$cancel' => t('Cancel')
- )
- );
-
- $reponames = $this->listAddonRepos();
- $addonrepos = [];
- foreach($reponames as $repo) {
- $addonrepos[] = array('name' => $repo, 'description' => '');
- /// @TODO Parse repo info to provide more information about repos
- }
-
$t = get_markup_template('admin_plugins.tpl');
return replace_macros($t, array(
'$title' => t('Administration'),
@@ -448,37 +196,9 @@ class Addons {
'$plugins' => $plugins,
'$disabled' => t('Disabled - version incompatibility'),
'$form_security_token' => get_form_security_token('admin_addons'),
- '$allowManageRepos' => $allowManageRepos,
- '$managerepos' => t('Manage Repos'),
- '$installedtitle' => t('Installed Addon Repositories'),
- '$addnewrepotitle' => t('Install a New Addon Repository'),
- '$expandform' => false,
- '$form' => $admin_plugins_add_repo_form,
- '$newRepoModal' => $newRepoModal,
- '$newRepoModalID' => $newRepoModalID,
- '$addonrepos' => $addonrepos,
- '$repoUpdateButton' => t('Update'),
- '$repoBranchButton' => t('Switch branch'),
- '$repoRemoveButton' => t('Remove')
));
}
- function listAddonRepos() {
- $addonrepos = [];
- $addonDir = 'extend/addon/';
- if(is_dir($addonDir)) {
- if ($handle = opendir($addonDir)) {
- while (false !== ($entry = readdir($handle))) {
- if ($entry != "." && $entry != "..") {
- $addonrepos[] = $entry;
- }
- }
- closedir($handle);
- }
- }
- return $addonrepos;
- }
-
static public function plugin_sort($a,$b) {
return(strcmp(strtolower($a[2]['name']),strtolower($b[2]['name'])));
}
diff --git a/Zotlabs/Module/Admin/Channels.php b/Zotlabs/Module/Admin/Channels.php
index c6b7ad17a..cd1d2b6fe 100644
--- a/Zotlabs/Module/Admin/Channels.php
+++ b/Zotlabs/Module/Admin/Channels.php
@@ -14,7 +14,7 @@ class Channels {
*/
function post() {
- $channels = ( x($_POST, 'channel') ? $_POST['channel'] : Array() );
+ $channels = (x($_POST, 'channel') ? $_POST['channel'] : []);
check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels');
@@ -22,11 +22,28 @@ class Channels {
if(x($_POST, 'page_channels_block')) {
foreach($channels as $uid) {
- q("UPDATE channel SET channel_pageflags = ( channel_pageflags $xor %d ) where channel_id = %d",
- intval(PAGE_CENSORED),
- intval( $uid )
+ $channel = channelx_by_n($uid);
+
+ if (!$channel) {
+ notice( t('Channel not found') . EOL);
+ continue;
+ }
+
+ $pflags = $channel['channel_pageflags'] ^ PAGE_CENSORED;
+
+ q("UPDATE channel SET channel_pageflags = %d where channel_id = %d",
+ intval($pflags),
+ intval($uid)
);
+
\Zotlabs\Daemon\Master::Summon(array('Directory', $uid, 'nopush'));
+
+ $censored = (($pflags & PAGE_CENSORED) ? 1 : 0);
+
+ q("UPDATE xchan SET xchan_censored = %d WHERE xchan_hash = '%s'",
+ intval($censored),
+ dbesc($channel['channel_hash'])
+ );
}
notice( sprintf( tt("%s channel censored/uncensored", "%s channels censored/uncensored", count($channels)), count($channels)) );
}
@@ -57,11 +74,9 @@ class Channels {
function get() {
if(argc() > 2) {
$uid = argv(3);
- $channel = q("SELECT * FROM channel WHERE channel_id = %d",
- intval($uid)
- );
+ $channel = channelx_by_n($uid);
- if(! $channel) {
+ if(!$channel) {
notice( t('Channel not found') . EOL);
goaway(z_root() . '/admin/channels' );
}
@@ -72,30 +87,37 @@ class Channels {
// delete channel
channel_remove($uid,true);
- notice( sprintf(t("Channel '%s' deleted"), $channel[0]['channel_name']) . EOL);
+ notice( sprintf(t("Channel '%s' deleted"), $channel['channel_name']) . EOL);
}; break;
case "block":{
check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels', 't');
- $pflags = $channel[0]['channel_pageflags'] ^ PAGE_CENSORED;
+ $pflags = $channel['channel_pageflags'] ^ PAGE_CENSORED;
q("UPDATE channel SET channel_pageflags = %d where channel_id = %d",
intval($pflags),
- intval( $uid )
+ intval($uid)
);
\Zotlabs\Daemon\Master::Summon(array('Directory',$uid,'nopush'));
- notice( sprintf( (($pflags & PAGE_CENSORED) ? t("Channel '%s' censored"): t("Channel '%s' uncensored")) , $channel[0]['channel_name'] . ' (' . $channel[0]['channel_address'] . ')' ) . EOL);
+ $censored = (($pflags & PAGE_CENSORED) ? 1 : 0);
+
+ q("UPDATE xchan SET xchan_censored = %d WHERE xchan_hash = '%s'",
+ intval($censored),
+ dbesc($channel['channel_hash'])
+ );
+
+ notice( sprintf( (($censored) ? t("Channel '%s' censored"): t("Channel '%s' uncensored")) , $channel['channel_name'] . ' (' . $channel['channel_address'] . ')' ) . EOL);
}; break;
case "code":{
check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels', 't');
- $pflags = $channel[0]['channel_pageflags'] ^ PAGE_ALLOWCODE;
+ $pflags = $channel['channel_pageflags'] ^ PAGE_ALLOWCODE;
q("UPDATE channel SET channel_pageflags = %d where channel_id = %d",
intval($pflags),
- intval( $uid )
+ intval($uid)
);
- notice( sprintf( (($pflags & PAGE_ALLOWCODE) ? t("Channel '%s' code allowed"): t("Channel '%s' code disallowed")) , $channel[0]['channel_name'] . ' (' . $channel[0]['channel_address'] . ')' ) . EOL);
+ notice( sprintf( (($pflags & PAGE_ALLOWCODE) ? t("Channel '%s' code allowed"): t("Channel '%s' code disallowed")) , $channel['channel_name'] . ' (' . $channel['channel_address'] . ')' ) . EOL);
}; break;
default:
@@ -104,7 +126,7 @@ class Channels {
goaway(z_root() . '/admin/channels' );
}
- $key = (($_REQUEST['key']) ? dbesc($_REQUEST['key']) : 'channel_id');
+ $key = ((isset($_REQUEST['key']) && $_REQUEST['key']) ? dbesc($_REQUEST['key']) : 'channel_id');
$dir = 'asc';
if(array_key_exists('dir',$_REQUEST))
$dir = ((intval($_REQUEST['dir'])) ? 'asc' : 'desc');
diff --git a/Zotlabs/Module/Admin/Dbsync.php b/Zotlabs/Module/Admin/Dbsync.php
index b68e7bbc2..9f202993d 100644
--- a/Zotlabs/Module/Admin/Dbsync.php
+++ b/Zotlabs/Module/Admin/Dbsync.php
@@ -2,7 +2,7 @@
namespace Zotlabs\Module\Admin;
-
+use Zotlabs\Lib\Config;
class Dbsync {
@@ -12,10 +12,10 @@ class Dbsync {
if(argc() > 3 && intval(argv(3)) && argv(2) === 'mark') {
// remove the old style config if it exists
- del_config('database', 'update_r' . intval(argv(3)));
- set_config('database', '_' . intval(argv(3)), 'success');
- if(intval(get_config('system','db_version')) < intval(argv(3)))
- set_config('system','db_version',intval(argv(3)));
+ Config::Delete('database', 'update_r' . intval(argv(3)));
+ Config::Set('database', '_' . intval(argv(3)), 'success');
+ if(intval(Config::Get('system','db_version')) < intval(argv(3)))
+ Config::Set('system','db_version',intval(argv(3)));
info( t('Update has been marked successful') . EOL);
goaway(z_root() . '/admin/dbsync');
}
@@ -33,7 +33,7 @@ class Dbsync {
}
elseif($retval === UPDATE_SUCCESS) {
$o .= sprintf( t('Update %s was successfully applied.'), $s);
- set_config('database',$s, 'success');
+ Config::Set('database',$s, 'success');
}
else
$o .= sprintf( t('Verifying update %s did not return a status. Unknown if it succeeded.'), $s);
@@ -60,7 +60,7 @@ class Dbsync {
}
elseif($retval === UPDATE_SUCCESS) {
$o .= sprintf( t('Update %s was successfully applied.'), $s);
- set_config('database',$s, 'success');
+ Config::Set('database',$s, 'success');
}
else
$o .= sprintf( t('Update %s did not return a status. It cannot be determined if it was successful.'), $s);
diff --git a/Zotlabs/Module/Admin/Features.php b/Zotlabs/Module/Admin/Features.php
index 504caae79..eb82ae1ff 100644
--- a/Zotlabs/Module/Admin/Features.php
+++ b/Zotlabs/Module/Admin/Features.php
@@ -2,53 +2,53 @@
namespace Zotlabs\Module\Admin;
-
+use Zotlabs\Lib\Config;
class Features {
-
+
function post() {
-
+
check_form_security_token_redirectOnErr('/admin/features', 'admin_manage_features');
-
+
logger('postvars: ' . print_r($_POST,true));
-
+
$arr = array();
$features = get_features(false);
-
+
foreach($features as $fname => $fdata) {
foreach(array_slice($fdata,1) as $f) {
$feature = $f[0];
-
+
if(array_key_exists('feature_' . $feature,$_POST))
$val = intval($_POST['feature_' . $feature]);
else
$val = 0;
- set_config('feature',$feature,$val);
-
+ Config::Set('feature',$feature,$val);
+
if(array_key_exists('featurelock_' . $feature,$_POST))
- set_config('feature_lock',$feature,$val);
+ Config::Set('feature_lock',$feature,$val);
else
- del_config('feature_lock',$feature);
+ Config::Delete('feature_lock',$feature);
}
}
-
+
goaway(z_root() . '/admin/features' );
-
+
}
-
+
function get() {
-
+
if((argc() > 1) && (argv(1) === 'features')) {
$arr = array();
$features = get_features(false);
-
+
foreach($features as $fname => $fdata) {
$arr[$fname] = array();
$arr[$fname][0] = $fdata[0];
foreach(array_slice($fdata,1) as $f) {
-
- $set = get_config('feature',$f[0]);
+
+ $set = Config::Get('feature',$f[0]);
if($set === false)
$set = $f[3];
$arr[$fname][1][] = array(
@@ -57,18 +57,17 @@ class Features {
);
}
}
-
+
$tpl = get_markup_template("admin_settings_features.tpl");
- $o .= replace_macros($tpl, array(
+
+ return replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("admin_manage_features"),
'$title' => t('Manage Additional Features'),
'$features' => $arr,
'$submit' => t('Submit'),
));
-
- return $o;
}
}
-
-} \ No newline at end of file
+
+}
diff --git a/Zotlabs/Module/Admin/Logs.php b/Zotlabs/Module/Admin/Logs.php
index c83fc6a9a..73c890e26 100644
--- a/Zotlabs/Module/Admin/Logs.php
+++ b/Zotlabs/Module/Admin/Logs.php
@@ -2,11 +2,12 @@
namespace Zotlabs\Module\Admin;
+use Zotlabs\Lib\Config;
class Logs {
-
+
/**
* @brief POST handler for logs admin page.
*
@@ -15,20 +16,20 @@ class Logs {
function post() {
if (x($_POST, 'page_logs')) {
check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
-
+
$logfile = ((x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : '');
$debugging = ((x($_POST,'debugging')) ? true : false);
$loglevel = ((x($_POST,'loglevel')) ? intval(trim($_POST['loglevel'])) : 0);
-
- set_config('system','logfile', $logfile);
- set_config('system','debugging', $debugging);
- set_config('system','loglevel', $loglevel);
+
+ Config::Set('system','logfile', $logfile);
+ Config::Set('system','debugging', $debugging);
+ Config::Set('system','loglevel', $loglevel);
}
-
+
info( t('Log settings updated.') );
goaway(z_root() . '/admin/logs' );
}
-
+
/**
* @brief Logs admin page.
*
@@ -36,7 +37,7 @@ class Logs {
*/
function get() {
-
+
$log_choices = Array(
LOGGER_NORMAL => 'Normal',
LOGGER_TRACE => 'Trace',
@@ -44,15 +45,15 @@ class Logs {
LOGGER_DATA => 'Data',
LOGGER_ALL => 'All'
);
-
+
$t = get_markup_template('admin_logs.tpl');
-
- $f = get_config('system', 'logfile');
-
+
+ $f = Config::Get('system', 'logfile');
+
$data = '';
-
+
if(!file_exists($f)) {
- $data = t("Error trying to open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f exist and is
+ $data = t("Error trying to open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f exist and is
readable.");
}
else {
@@ -77,7 +78,7 @@ class Logs {
fclose($fp);
}
}
-
+
return replace_macros($t, array(
'$title' => t('Administration'),
'$page' => t('Logs'),
@@ -85,17 +86,17 @@ class Logs {
'$clear' => t('Clear'),
'$data' => $data,
'$baseurl' => z_root(),
- '$logname' => get_config('system','logfile'),
-
+ '$logname' => Config::Get('system','logfile'),
+
// name, label, value, help string, extra data...
- '$debugging' => array('debugging', t("Debugging"),get_config('system','debugging'), ""),
- '$logfile' => array('logfile', t("Log file"), get_config('system','logfile'), t("Must be writable by web server. Relative to your top-level webserver directory.")),
- '$loglevel' => array('loglevel', t("Log level"), get_config('system','loglevel'), "", $log_choices),
-
+ '$debugging' => array('debugging', t("Debugging"),Config::Get('system','debugging'), ""),
+ '$logfile' => array('logfile', t("Log file"), Config::Get('system','logfile'), t("Must be writable by web server. Relative to your top-level webserver directory.")),
+ '$loglevel' => array('loglevel', t("Log level"), Config::Get('system','loglevel'), "", $log_choices),
+
'$form_security_token' => get_form_security_token('admin_logs'),
));
}
-
-} \ No newline at end of file
+
+}
diff --git a/Zotlabs/Module/Admin/Profs.php b/Zotlabs/Module/Admin/Profs.php
index eb2501d43..9965cab19 100644
--- a/Zotlabs/Module/Admin/Profs.php
+++ b/Zotlabs/Module/Admin/Profs.php
@@ -2,11 +2,12 @@
namespace Zotlabs\Module\Admin;
+use Zotlabs\Lib\Config;
class Profs {
function post() {
-
+
if(array_key_exists('basic',$_REQUEST)) {
$arr = explode(',',$_REQUEST['basic']);
array_walk($arr,'array_trim');
@@ -19,9 +20,9 @@ class Profs {
}
}
if(! $narr)
- del_config('system','profile_fields_basic');
+ Config::Delete('system','profile_fields_basic');
else
- set_config('system','profile_fields_basic',$narr);
+ Config::Set('system','profile_fields_basic',$narr);
if(array_key_exists('advanced',$_REQUEST)) {
@@ -36,15 +37,15 @@ class Profs {
}
}
if(! $narr)
- del_config('system','profile_fields_advanced');
+ Config::Delete('system','profile_fields_advanced');
else
- set_config('system','profile_fields_advanced',$narr);
+ Config::Set('system','profile_fields_advanced',$narr);
}
goaway(z_root() . '/admin/profs');
}
-
-
+
+
if(array_key_exists('field_name',$_REQUEST)) {
if($_REQUEST['id']) {
$r = q("update profdef set field_name = '%s', field_type = '%s', field_desc = '%s' field_help = '%s', field_inputs = '%s' where id = %d",
@@ -66,24 +67,24 @@ class Profs {
);
}
}
-
-
+
+
// add to chosen array basic or advanced
-
+
goaway(z_root() . '/admin/profs');
}
-
+
function get() {
-
+
if((argc() > 3) && argv(2) == 'drop' && intval(argv(3))) {
$r = q("delete from profdef where id = %d",
intval(argv(3))
);
// remove from allowed fields
-
- goaway(z_root() . '/admin/profs');
+
+ goaway(z_root() . '/admin/profs');
}
-
+
if((argc() > 2) && argv(2) === 'new') {
return replace_macros(get_markup_template('profdef_edit.tpl'),array(
'$header' => t('New Profile Field'),
@@ -94,7 +95,7 @@ class Profs {
'$submit' => t('Save')
));
}
-
+
if((argc() > 2) && intval(argv(2))) {
$r = q("select * from profdef where id = %d limit 1",
intval(argv(2))
@@ -103,7 +104,7 @@ class Profs {
notice( t('Field definition not found') . EOL);
goaway(z_root() . '/admin/profs');
}
-
+
return replace_macros(get_markup_template('profdef_edit.tpl'),array(
'$id' => intval($r[0]['id']),
'$header' => t('Edit Profile Field'),
@@ -114,7 +115,7 @@ class Profs {
'$submit' => t('Save')
));
}
-
+
$basic = '';
$barr = array();
$fields = get_profile_fields_basic();
@@ -129,7 +130,7 @@ class Profs {
$barr[] = trim($k);
}
}
-
+
$advanced = '';
$fields = get_profile_fields_advanced();
if(! $fields)
@@ -143,7 +144,7 @@ class Profs {
$advanced .= trim($k);
}
}
-
+
$all = '';
$fields = get_profile_fields_advanced(1);
if($fields) {
@@ -153,7 +154,7 @@ class Profs {
$all .= trim($k);
}
}
-
+
$r = q("select * from profdef where true");
if($r) {
foreach($r as $rr) {
@@ -162,8 +163,8 @@ class Profs {
$all .= $rr['field_name'];
}
}
-
-
+
+
$o = replace_macros(get_markup_template('admin_profiles.tpl'),array(
'$title' => t('Profile Fields'),
'$basic' => array('basic',t('Basic Profile Fields'),$basic,''),
@@ -174,17 +175,17 @@ class Profs {
'$cust_fields' => $r,
'$edit' => t('Edit'),
'$drop' => t('Delete'),
- '$new' => t('Create Custom Field'),
+ '$new' => t('Create Custom Field'),
'$submit' => t('Submit')
));
-
+
return $o;
-
-
+
+
}
-} \ No newline at end of file
+}
diff --git a/Zotlabs/Module/Admin/Queueworker.php b/Zotlabs/Module/Admin/Queueworker.php
index a4f38d07c..c98df6ac0 100644
--- a/Zotlabs/Module/Admin/Queueworker.php
+++ b/Zotlabs/Module/Admin/Queueworker.php
@@ -3,6 +3,7 @@
namespace Zotlabs\Module\Admin;
use App;
+use Zotlabs\Lib\Config;
use Zotlabs\Web\Controller;
class Queueworker extends Controller {
@@ -17,18 +18,18 @@ class Queueworker extends Controller {
$maxqueueworkers = intval($_POST['queueworker_maxworkers']);
$maxqueueworkers = ($maxqueueworkers > 3) ? $maxqueueworkers : 4;
- set_config('queueworker', 'max_queueworkers', $maxqueueworkers);
+ Config::Set('queueworker', 'max_queueworkers', $maxqueueworkers);
$maxworkerage = intval($_POST['queueworker_max_age']);
$maxworkerage = ($maxworkerage >= 120) ? $maxworkerage : 300;
- set_config('queueworker', 'queueworker_max_age', $maxworkerage);
+ Config::Set('queueworker', 'queueworker_max_age', $maxworkerage);
$queueworkersleep = intval($_POST['queue_worker_sleep']);
$queueworkersleep = ($queueworkersleep > 100) ? $queueworkersleep : 100;
- set_config('queueworker', 'queue_worker_sleep', $queueworkersleep);
+ Config::Set('queueworker', 'queue_worker_sleep', $queueworkersleep);
$auto_queue_worker_sleep = intval($_POST['auto_queue_worker_sleep']);
- set_config('queueworker', 'auto_queue_worker_sleep', $auto_queue_worker_sleep);
+ Config::Set('queueworker', 'auto_queue_worker_sleep', $auto_queue_worker_sleep);
goaway(z_root() . '/admin/queueworker');
}
@@ -54,7 +55,7 @@ class Queueworker extends Controller {
}
}
- $maxqueueworkers = get_config('queueworker', 'max_queueworkers', 4);
+ $maxqueueworkers = Config::Get('queueworker', 'max_queueworkers', 4);
$maxqueueworkers = ($maxqueueworkers > 3) ? $maxqueueworkers : 4;
$sc = '';
@@ -68,7 +69,7 @@ class Queueworker extends Controller {
]
]);
- $workermaxage = get_config('queueworker', 'queueworker_max_age');
+ $workermaxage = Config::Get('queueworker', 'queueworker_max_age');
$workermaxage = ($workermaxage >= 120) ? $workermaxage : 300;
$sc .= replace_macros(get_markup_template('field_input.tpl'), [
@@ -80,10 +81,10 @@ class Queueworker extends Controller {
]
]);
- $queueworkersleep = get_config('queueworker', 'queue_worker_sleep');
+ $queueworkersleep = Config::Get('queueworker', 'queue_worker_sleep');
$queueworkersleep = ($queueworkersleep > 100) ? $queueworkersleep : 100;
- $auto_queue_worker_sleep = get_config('queueworker', 'auto_queue_worker_sleep', 0);
+ $auto_queue_worker_sleep = Config::Get('queueworker', 'auto_queue_worker_sleep', 0);
$sc .= replace_macros(get_markup_template('field_input.tpl'), [
'$field' => [
diff --git a/Zotlabs/Module/Admin/Security.php b/Zotlabs/Module/Admin/Security.php
index 499572170..559097df2 100644
--- a/Zotlabs/Module/Admin/Security.php
+++ b/Zotlabs/Module/Admin/Security.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Module\Admin;
+use Zotlabs\Lib\Config;
class Security {
@@ -11,53 +12,53 @@ class Security {
$allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : '');
$not_allowed_email = ((x($_POST,'not_allowed_email')) ? notags(trim($_POST['not_allowed_email'])) : '');
- set_config('system','allowed_email', $allowed_email);
- set_config('system','not_allowed_email', $not_allowed_email);
+ Config::Set('system','allowed_email', $allowed_email);
+ Config::Set('system','not_allowed_email', $not_allowed_email);
$block_public = ((x($_POST,'block_public')) ? True : False);
- set_config('system','block_public',$block_public);
+ Config::Set('system','block_public',$block_public);
$cloud_noroot = ((x($_POST,'cloud_noroot')) ? 1 : 0);
- set_config('system','cloud_disable_siteroot',1 - $cloud_noroot);
+ Config::Set('system','cloud_disable_siteroot',1 - $cloud_noroot);
$cloud_disksize = ((x($_POST,'cloud_disksize')) ? 1 : 0);
- set_config('system','cloud_report_disksize',$cloud_disksize);
+ Config::Set('system','cloud_report_disksize',$cloud_disksize);
$ws = $this->trim_array_elems(explode("\n",$_POST['whitelisted_sites']));
- set_config('system','whitelisted_sites',$ws);
+ Config::Set('system','whitelisted_sites',$ws);
$bs = $this->trim_array_elems(explode("\n",$_POST['blacklisted_sites']));
- set_config('system','blacklisted_sites',$bs);
+ Config::Set('system','blacklisted_sites',$bs);
$wc = $this->trim_array_elems(explode("\n",$_POST['whitelisted_channels']));
- set_config('system','whitelisted_channels',$wc);
+ Config::Set('system','whitelisted_channels',$wc);
$bc = $this->trim_array_elems(explode("\n",$_POST['blacklisted_channels']));
- set_config('system','blacklisted_channels',$bc);
+ Config::Set('system','blacklisted_channels',$bc);
$embed_sslonly = ((x($_POST,'embed_sslonly')) ? True : False);
- set_config('system','embed_sslonly',$embed_sslonly);
+ Config::Set('system','embed_sslonly',$embed_sslonly);
$we = $this->trim_array_elems(explode("\n",$_POST['embed_allow']));
- set_config('system','embed_allow',$we);
+ Config::Set('system','embed_allow',$we);
$be = $this->trim_array_elems(explode("\n",$_POST['embed_deny']));
- set_config('system','embed_deny',$be);
+ Config::Set('system','embed_deny',$be);
$thumbnail_security = ((x($_POST,'thumbnail_security')) ? intval($_POST['thumbnail_security']) : 0);
- set_config('system', 'thumbnail_security' , $thumbnail_security);
+ Config::Set('system', 'thumbnail_security' , $thumbnail_security);
$inline_pdf = ((x($_POST,'inline_pdf')) ? intval($_POST['inline_pdf']) : 0);
- set_config('system', 'inline_pdf' , $inline_pdf);
+ Config::Set('system', 'inline_pdf' , $inline_pdf);
$ts = ((x($_POST,'transport_security')) ? True : False);
- set_config('system','transport_security_header',$ts);
+ Config::Set('system','transport_security_header',$ts);
$cs = ((x($_POST,'content_security')) ? True : False);
- set_config('system','content_security_policy',$cs);
+ Config::Set('system','content_security_policy',$cs);
$trusted_directory_servers = $this->trim_array_elems(explode("\n", $_POST['trusted_directory_servers']));
- set_config('system', 'trusted_directory_servers', $trusted_directory_servers);
+ Config::Set('system', 'trusted_directory_servers', $trusted_directory_servers);
goaway(z_root() . '/admin/security');
}
@@ -66,31 +67,31 @@ class Security {
function get() {
- $whitesites = get_config('system','whitelisted_sites');
+ $whitesites = Config::Get('system','whitelisted_sites');
$whitesites_str = ((is_array($whitesites)) ? implode("\n",$whitesites) : '');
- $blacksites = get_config('system','blacklisted_sites');
+ $blacksites = Config::Get('system','blacklisted_sites');
$blacksites_str = ((is_array($blacksites)) ? implode("\n",$blacksites) : '');
- $whitechannels = get_config('system','whitelisted_channels');
+ $whitechannels = Config::Get('system','whitelisted_channels');
$whitechannels_str = ((is_array($whitechannels)) ? implode("\n",$whitechannels) : '');
- $blackchannels = get_config('system','blacklisted_channels');
+ $blackchannels = Config::Get('system','blacklisted_channels');
$blackchannels_str = ((is_array($blackchannels)) ? implode("\n",$blackchannels) : '');
- $whiteembeds = get_config('system','embed_allow');
+ $whiteembeds = Config::Get('system','embed_allow');
$whiteembeds_str = ((is_array($whiteembeds)) ? implode("\n",$whiteembeds) : '');
- $blackembeds = get_config('system','embed_deny');
+ $blackembeds = Config::Get('system','embed_deny');
$blackembeds_str = ((is_array($blackembeds)) ? implode("\n",$blackembeds) : '');
- $trusted_directory_servers = get_config('system', 'trusted_directory_servers');
+ $trusted_directory_servers = Config::Get('system', 'trusted_directory_servers');
$trusted_directory_servers_str = ((is_array($trusted_directory_servers)) ? implode("\n", $trusted_directory_servers) : '');
- $is_dir = (intval(get_config('system', 'directory_mode', DIRECTORY_MODE_NORMAL)) !== DIRECTORY_MODE_NORMAL);
+ $is_dir = (intval(Config::Get('system', 'directory_mode', DIRECTORY_MODE_NORMAL)) !== DIRECTORY_MODE_NORMAL);
- $embed_coop = intval(get_config('system','embed_coop'));
+ $embed_coop = intval(Config::Get('system','embed_coop'));
if((! $whiteembeds) && (! $blackembeds)) {
$embedhelp1 = t("By default, unfiltered HTML is allowed in embedded media. This is inherently insecure.");
@@ -105,22 +106,22 @@ class Security {
'$title' => t('Administration'),
'$page' => t('Security'),
'$form_security_token' => get_form_security_token('admin_security'),
- '$block_public' => array('block_public', t("Block public"), get_config('system','block_public'), t("Check to block public access to all otherwise public personal pages on this site unless you are currently authenticated.")),
- '$cloud_noroot' => [ 'cloud_noroot', t('Provide a cloud root directory'), 1 - intval(get_config('system','cloud_disable_siteroot')), t('The cloud root directory lists all channel names which provide public files') ],
- '$cloud_disksize' => [ 'cloud_disksize', t('Show total disk space available to cloud uploads'), intval(get_config('system','cloud_report_disksize')), '' ],
- '$transport_security' => array('transport_security', t('Set "Transport Security" HTTP header'),intval(get_config('system','transport_security_header')),''),
- '$content_security' => array('content_security', t('Set "Content Security Policy" HTTP header'),intval(get_config('system','content_security_policy')),''),
- '$allowed_email' => array('allowed_email', t("Allowed email domains"), get_config('system','allowed_email'), t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")),
- '$not_allowed_email' => array('not_allowed_email', t("Not allowed email domains"), get_config('system','not_allowed_email'), t("Comma separated list of domains which are not allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains, unless allowed domains have been defined.")),
+ '$block_public' => array('block_public', t("Block public"), Config::Get('system','block_public'), t("Check to block public access to all otherwise public personal pages on this site unless you are currently authenticated.")),
+ '$cloud_noroot' => [ 'cloud_noroot', t('Provide a cloud root directory'), 1 - intval(Config::Get('system','cloud_disable_siteroot')), t('The cloud root directory lists all channel names which provide public files') ],
+ '$cloud_disksize' => [ 'cloud_disksize', t('Show total disk space available to cloud uploads'), intval(Config::Get('system','cloud_report_disksize')), '' ],
+ '$transport_security' => array('transport_security', t('Set "Transport Security" HTTP header'),intval(Config::Get('system','transport_security_header')),''),
+ '$content_security' => array('content_security', t('Set "Content Security Policy" HTTP header'),intval(Config::Get('system','content_security_policy')),''),
+ '$allowed_email' => array('allowed_email', t("Allowed email domains"), Config::Get('system','allowed_email'), t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")),
+ '$not_allowed_email' => array('not_allowed_email', t("Not allowed email domains"), Config::Get('system','not_allowed_email'), t("Comma separated list of domains which are not allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains, unless allowed domains have been defined.")),
'$whitelisted_sites' => array('whitelisted_sites', t('Allow communications only from these sites'), $whitesites_str, t('One site per line. Leave empty to allow communication from anywhere by default')),
'$blacklisted_sites' => array('blacklisted_sites', t('Block communications from these sites'), $blacksites_str, ''),
'$whitelisted_channels' => array('whitelisted_channels', t('Allow communications only from these channels'), $whitechannels_str, t('One channel (hash) per line. Leave empty to allow from any channel by default')),
'$blacklisted_channels' => array('blacklisted_channels', t('Block communications from these channels'), $blackchannels_str, ''),
- '$embed_sslonly' => array('embed_sslonly',t('Only allow embeds from secure (SSL) websites and links.'), intval(get_config('system','embed_sslonly')),''),
+ '$embed_sslonly' => array('embed_sslonly',t('Only allow embeds from secure (SSL) websites and links.'), intval(Config::Get('system','embed_sslonly')),''),
'$embed_allow' => array('embed_allow', t('Allow unfiltered embedded HTML content only from these domains'), $whiteembeds_str, t('One site per line. By default embedded content is filtered.')),
'$embed_deny' => array('embed_deny', t('Block embedded HTML from these domains'), $blackembeds_str, ''),
- '$thumbnail_security' => [ 'thumbnail_security', t("Allow SVG thumbnails in file browser"), get_config('system','thumbnail_security',0), t("WARNING: SVG images may contain malicious code.") ],
- '$inline_pdf' => [ 'inline_pdf', t("Allow embedded (inline) PDF files"), get_config('system','inline_pdf',0), '' ],
+ '$thumbnail_security' => [ 'thumbnail_security', t("Allow SVG thumbnails in file browser"), Config::Get('system','thumbnail_security',0), t("WARNING: SVG images may contain malicious code.") ],
+ '$inline_pdf' => [ 'inline_pdf', t("Allow embedded (inline) PDF files"), Config::Get('system','inline_pdf',0), '' ],
'$trusted_directory_servers' => (($is_dir) ? ['trusted_directory_servers', t('Additional trusted directory server URLs'), $trusted_directory_servers_str, t('Accept directory flags (spam, nsfw) from those servers. One per line like https://example.tld')] : ''),
diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php
index dae5e7c77..9ef5dc20f 100644
--- a/Zotlabs/Module/Admin/Site.php
+++ b/Zotlabs/Module/Admin/Site.php
@@ -2,9 +2,12 @@
namespace Zotlabs\Module\Admin;
+use Zotlabs\Lib\Config;
class Site {
+ private string $eol;
+ private string $joo;
/**
* @brief POST handler for Admin Site Page.
@@ -125,8 +128,8 @@ class Site {
//logger( print_r( $this->msgbg, true) );
//logger( print_r( $this->joo, true) );
if ($this->error === 0) {
- set_config('system', 'register_duty', $this->register_duty);
- set_config('system', 'register_duty_jso', $this->joo);
+ Config::Set('system', 'register_duty', $this->register_duty);
+ Config::Set('system', 'register_duty_jso', $this->joo);
} else {
notice('ZAR0130E,' . t('Errors') . ': ' . $this->error . EOL . $this->msgfg . EOL);
}
@@ -134,87 +137,86 @@ class Site {
}
// <-hilmar]
- set_config('system', 'feed_contacts', $feed_contacts);
- set_config('system', 'delivery_interval', $delivery_interval);
- set_config('system', 'delivery_batch_count', $delivery_batch_count);
- set_config('system', 'poll_interval', $poll_interval);
- set_config('system', 'maxloadavg', $maxloadavg);
- set_config('system', 'frontpage', $frontpage);
- set_config('system', 'sellpage', $site_sellpage);
- set_config('system', 'workflow_channel_next', $first_page);
- set_config('system', 'site_location', $site_location);
- set_config('system', 'mirror_frontpage', $mirror_frontpage);
- set_config('system', 'sitename', $sitename);
- set_config('system', 'login_on_homepage', $login_on_homepage);
- set_config('system', 'enable_context_help', $enable_context_help);
- set_config('system', 'verify_email', $verify_email);
- set_config('system', 'max_daily_registrations', $register_perday);
- set_config('system', 'register_sameip', $register_sameip);
- set_config('system', 'register_delay', $reg_delay);
- set_config('system', 'register_expire', $reg_expire);
- set_config('system', 'default_expire_days', $default_expire_days);
- set_config('system', 'active_expire_days', $active_expire_days);
- set_config('system', 'reply_address', $reply_address);
- set_config('system', 'from_email', $from_email);
- set_config('system', 'from_email_name' , $from_email_name);
- set_config('system', 'imagick_convert_path' , $imagick_path);
- set_config('system', 'default_permissions_role', $permissions_role);
- set_config('system', 'pubstream_incl',$pub_incl);
- set_config('system', 'pubstream_excl',$pub_excl);
+ Config::Set('system', 'feed_contacts', $feed_contacts);
+ Config::Set('system', 'delivery_interval', $delivery_interval);
+ Config::Set('system', 'delivery_batch_count', $delivery_batch_count);
+ Config::Set('system', 'poll_interval', $poll_interval);
+ Config::Set('system', 'maxloadavg', $maxloadavg);
+ Config::Set('system', 'frontpage', $frontpage);
+ Config::Set('system', 'sellpage', $site_sellpage);
+ Config::Set('system', 'workflow_channel_next', $first_page);
+ Config::Set('system', 'site_location', $site_location);
+ Config::Set('system', 'mirror_frontpage', $mirror_frontpage);
+ Config::Set('system', 'sitename', $sitename);
+ Config::Set('system', 'login_on_homepage', $login_on_homepage);
+ Config::Set('system', 'enable_context_help', $enable_context_help);
+ Config::Set('system', 'verify_email', $verify_email);
+ Config::Set('system', 'max_daily_registrations', $register_perday);
+ Config::Set('system', 'register_sameip', $register_sameip);
+ Config::Set('system', 'register_delay', $reg_delay);
+ Config::Set('system', 'register_expire', $reg_expire);
+ Config::Set('system', 'default_expire_days', $default_expire_days);
+ Config::Set('system', 'active_expire_days', $active_expire_days);
+ Config::Set('system', 'reply_address', $reply_address);
+ Config::Set('system', 'from_email', $from_email);
+ Config::Set('system', 'from_email_name' , $from_email_name);
+ Config::Set('system', 'imagick_convert_path' , $imagick_path);
+ Config::Set('system', 'default_permissions_role', $permissions_role);
+ Config::Set('system', 'pubstream_incl',$pub_incl);
+ Config::Set('system', 'pubstream_excl',$pub_excl);
if($directory_server)
- set_config('system','directory_server',$directory_server);
+ Config::Set('system','directory_server',$directory_server);
if ($banner == '') {
- del_config('system', 'banner');
+ Config::Delete('system', 'banner');
} else {
- set_config('system', 'banner', $banner);
+ Config::Set('system', 'banner', $banner);
}
if ($admininfo == ''){
- del_config('system', 'admininfo');
+ Config::Delete('system', 'admininfo');
} else {
require_once('include/text.php');
linkify_tags($admininfo, local_channel());
- set_config('system', 'admininfo', $admininfo);
+ Config::Set('system', 'admininfo', $admininfo);
}
- set_config('system','siteinfo',$siteinfo);
- //set_config('system', 'language', $language);
- set_config('system', 'theme', $theme);
+ Config::Set('system','siteinfo',$siteinfo);
+ //Config::Set('system', 'language', $language);
+ Config::Set('system', 'theme', $theme);
// if ( $theme_mobile === '---' ) {
- // del_config('system', 'mobile_theme');
+ // Config::Delete('system', 'mobile_theme');
// } else {
- // set_config('system', 'mobile_theme', $theme_mobile);
+ // Config::Set('system', 'mobile_theme', $theme_mobile);
// }
- // set_config('system','site_channel', $site_channel);
- set_config('system','maximagesize', $maximagesize);
-
- set_config('system','register_policy', $register_policy);
- set_config('system','register_wo_email', $register_wo_email);
- set_config('system','minimum_age', $minimum_age);
- set_config('system','auto_channel_create', $reg_autochannel);
- set_config('system', 'invitation_only', $invitation_only);
- set_config('system', 'invitation_also', $invitation_also);
- set_config('system','access_policy', $access_policy);
- set_config('system','account_abandon_days', $abandon_days);
- set_config('system','register_text', $register_text);
- set_config('system','allowed_sites', $allowed_sites);
- set_config('system','publish_all', $force_publish);
- set_config('system','disable_discover_tab', $disable_discover_tab);
- set_config('system','site_firehose', $site_firehose);
- set_config('system','open_pubstream', $open_pubstream);
- //set_config('system','force_queue_threshold', $force_queue);
-
- set_config('system','no_community_page', $no_community_page);
- set_config('system','no_utf', $no_utf);
-
- set_config('system','sse_enabled', $sse_enabled);
-
- set_config('system','verifyssl', $verifyssl);
- set_config('system','proxyuser', $proxyuser);
- set_config('system','proxy', $proxy);
- set_config('system','curl_timeout', $timeout);
+ // Config::Set('system','site_channel', $site_channel);
+ Config::Set('system','maximagesize', $maximagesize);
+
+ Config::Set('system','register_policy', $register_policy);
+ Config::Set('system','register_wo_email', $register_wo_email);
+ Config::Set('system','minimum_age', $minimum_age);
+ Config::Set('system','auto_channel_create', $reg_autochannel);
+ Config::Set('system', 'invitation_only', $invitation_only);
+ Config::Set('system', 'invitation_also', $invitation_also);
+ Config::Set('system','access_policy', $access_policy);
+ Config::Set('system','account_abandon_days', $abandon_days);
+ Config::Set('system','register_text', $register_text);
+ Config::Set('system','allowed_sites', $allowed_sites);
+ Config::Set('system','publish_all', $force_publish);
+ Config::Set('system','disable_discover_tab', $disable_discover_tab);
+ Config::Set('system','site_firehose', $site_firehose);
+ Config::Set('system','open_pubstream', $open_pubstream);
+ //Config::Set('system','force_queue_threshold', $force_queue);
+
+ Config::Set('system','no_community_page', $no_community_page);
+
+ Config::Set('system','sse_enabled', $sse_enabled);
+
+ Config::Set('system','verifyssl', $verifyssl);
+ Config::Set('system','proxyuser', $proxyuser);
+ Config::Set('system','proxy', $proxy);
+ Config::Set('system','curl_timeout', $timeout);
info( t('Site settings updated.') . EOL);
goaway(z_root() . '/admin/site' );
@@ -263,7 +265,7 @@ class Site {
}
$dir_choices = null;
- $dirmode = get_config('system', 'directory_mode', DIRECTORY_MODE_NORMAL);
+ $dirmode = Config::Get('system', 'directory_mode', DIRECTORY_MODE_NORMAL);
$realm = get_directory_realm();
// directory server should not be set or settable unless we are a directory client
@@ -291,14 +293,14 @@ class Site {
/* Banner */
- $banner = get_config('system', 'banner');
+ $banner = Config::Get('system', 'banner');
if($banner === false)
- $banner = get_config('system','sitename');
+ $banner = Config::Get('system','sitename');
$banner = htmlspecialchars($banner);
/* Admin Info */
- $admininfo = get_config('system', 'admininfo');
+ $admininfo = Config::Get('system', 'admininfo');
/* Register policy */
$register_choices = Array(
@@ -306,8 +308,8 @@ class Site {
REGISTER_APPROVE => t("Yes - with approval"),
REGISTER_OPEN => t("Yes")
);
- $this->register_duty = get_config('system', 'register_duty', '-:-');
- $register_perday = get_config('system','max_daily_registrations', 50);
+ $this->register_duty = Config::Get('system', 'register_duty', '-:-');
+ $register_perday = Config::Get('system','max_daily_registrations', 50);
/* Acess policy */
$access_choices = Array(
@@ -317,7 +319,7 @@ class Site {
ACCESS_TIERED => t("My site offers free accounts with optional paid upgrades")
);
- $discover_tab = get_config('system','disable_discover_tab');
+ $discover_tab = Config::Get('system','disable_discover_tab');
// $disable public streams by default
if($discover_tab === false)
@@ -326,7 +328,7 @@ class Site {
$discover_tab = (1 - $discover_tab);
$perm_roles = \Zotlabs\Access\PermissionRoles::channel_roles();
- $default_role = get_config('system', 'default_permissions_role', 'personal');
+ $default_role = Config::Get('system', 'default_permissions_role', 'personal');
if (!in_array($default_role, array_keys($perm_roles))) {
$default_role = 'personal';
@@ -334,8 +336,8 @@ class Site {
$role = array('permissions_role' , t('Default permission role for new accounts'), $default_role, t('This role will be used for the first channel created after registration.'),$perm_roles);
- $homelogin = get_config('system','login_on_homepage');
- $enable_context_help = get_config('system','enable_context_help');
+ $homelogin = Config::Get('system','login_on_homepage');
+ $enable_context_help = Config::Get('system','enable_context_help');
// for reuse reg_delay and reg_expire
$reg_rabots = array(
@@ -347,7 +349,7 @@ class Site {
'y' => t('Year(s)')
);
$regdelay_n = $regdelay_u = false;
- $regdelay = get_config('system','register_delay');
+ $regdelay = Config::Get('system','register_delay');
if ($regdelay)
list($regdelay_n, $regdelay_u) = array(substr($regdelay,0,-1),substr($regdelay,-1));
$reg_delay = replace_macros(get_markup_template('field_duration.qmc.tpl'),
@@ -369,7 +371,7 @@ class Site {
)
);
$regexpire_n = $regexpire_u = false;
- $regexpire = get_config('system','register_expire');
+ $regexpire = Config::Get('system','register_expire');
if ($regexpire)
list($regexpire_n, $regexpire_u) = array(substr($regexpire,0,-1),substr($regexpire,-1));
$reg_expire = replace_macros(get_markup_template('field_duration.qmc.tpl'),
@@ -406,38 +408,38 @@ class Site {
'$baseurl' => z_root(),
// name, label, value, help string, extra data...
- '$sitename' => array('sitename', t("Site name"), htmlspecialchars(get_config('system','sitename'), ENT_QUOTES, 'UTF-8'),''),
+ '$sitename' => array('sitename', t("Site name"), htmlspecialchars(Config::Get('system','sitename'), ENT_QUOTES, 'UTF-8'),''),
'$banner' => array('banner', t("Banner/Logo"), $banner, t('Unfiltered HTML/CSS/JS is allowed')),
'$admininfo' => array('admininfo', t("Administrator Information"), $admininfo, t("Contact information for site administrators. Displayed on siteinfo page. BBCode can be used here")),
- '$siteinfo' => array('siteinfo', t('Site Information'), get_config('system','siteinfo'), t("Publicly visible description of this site. Displayed on siteinfo page. BBCode can be used here")),
- '$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices),
- // '$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile_theme'), t("Theme for mobile devices"), $theme_choices_mobile),
- // '$site_channel' => array('site_channel', t("Channel to use for this website's static pages"), get_config('system','site_channel'), t("Site Channel")),
- '$feed_contacts' => array('feed_contacts', t('Allow Feeds as Connections'),get_config('system','feed_contacts'),t('(Heavy system resource usage)')),
- '$maximagesize' => array('maximagesize', t("Maximum image size"), intval(get_config('system','maximagesize')), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")),
- '$minimum_age' => array('minimum_age', t("Minimum age"), (x(get_config('system','minimum_age'))?get_config('system','minimum_age'):13), t("Minimum age (in years) for who may register on this site.")),
- '$access_policy' => array('access_policy', t("Which best describes the types of account offered by this hub?"), get_config('system','access_policy'), t("This is displayed on the public server site list."), $access_choices),
+ '$siteinfo' => array('siteinfo', t('Site Information'), Config::Get('system','siteinfo'), t("Publicly visible description of this site. Displayed on siteinfo page. BBCode can be used here")),
+ '$theme' => array('theme', t("System theme"), Config::Get('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices),
+ // '$theme_mobile' => array('theme_mobile', t("Mobile system theme"), Config::Get('system','mobile_theme'), t("Theme for mobile devices"), $theme_choices_mobile),
+ // '$site_channel' => array('site_channel', t("Channel to use for this website's static pages"), Config::Get('system','site_channel'), t("Site Channel")),
+ '$feed_contacts' => array('feed_contacts', t('Allow Feeds as Connections'),Config::Get('system','feed_contacts'),t('(Heavy system resource usage)')),
+ '$maximagesize' => array('maximagesize', t("Maximum image size"), intval(Config::Get('system','maximagesize')), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")),
+ '$minimum_age' => array('minimum_age', t("Minimum age"), (x(Config::Get('system','minimum_age'))?Config::Get('system','minimum_age'):13), t("Minimum age (in years) for who may register on this site.")),
+ '$access_policy' => array('access_policy', t("Which best describes the types of account offered by this hub?"), Config::Get('system','access_policy'), t("This is displayed on the public server site list."), $access_choices),
// Register
// [hilmar->
'$register_text' => [
'register_text',
t("Register text"),
- htmlspecialchars(get_config('system','register_text'), ENT_QUOTES, 'UTF-8'),
+ htmlspecialchars(Config::Get('system','register_text'), ENT_QUOTES, 'UTF-8'),
t("This text will be displayed prominently at the registration page")
],
'$register_policy' => [
'register_policy',
t("Does this site allow new member registration?"),
- get_config('system','register_policy'),
+ Config::Get('system','register_policy'),
"",
$register_choices,
],
'$register_duty' => [
'register_duty',
t('Configure the registration open days/hours'),
- get_config('system', 'register_duty', '-:-'),
+ Config::Get('system', 'register_duty', '-:-'),
t('Empty or \'-:-\' value will keep registration open 24/7 (default)') . EOL .
t('Weekdays and hours must be separated by colon \':\', From-To ranges with a dash `-` example: 1:800-1200') . EOL .
t('Weekday:Hour pairs must be separated by space \' \' example: 1:900-1700 2:900-1700') . EOL .
@@ -448,13 +450,13 @@ class Site {
'$register_perday' => [
'register_perday',
t('Max account registrations per day'),
- get_config('system', 'max_daily_registrations', 50),
+ Config::Get('system', 'max_daily_registrations', 50),
t('Unlimited if zero or no value - default 50')
],
'$register_sameip' => [
'register_sameip',
t('Max account registrations from same IP'),
- get_config('system', 'register_sameip', 3),
+ Config::Get('system', 'register_sameip', 3),
t('Unlimited if zero or no value - default 3')
],
'$reg_delay' => $reg_delay,
@@ -462,70 +464,70 @@ class Site {
'$reg_autochannel' => [
'auto_channel_create',
t("Auto channel create"),
- get_config('system','auto_channel_create', 1),
+ Config::Get('system','auto_channel_create', 1),
t("If disabled the channel will be created in a separate step during the registration process")
],
'$invitation_only' => [
'invitation_only',
t("Require invite code"),
- get_config('system', 'invitation_only', 0)
+ Config::Get('system', 'invitation_only', 0)
],
'$invitation_also' => [
'invitation_also',
t("Allow invite code"),
- get_config('system', 'invitation_also', 0)
+ Config::Get('system', 'invitation_also', 0)
],
'$verify_email' => [
'verify_email',
t("Require email address"),
- get_config('system','verify_email'),
+ Config::Get('system','verify_email'),
t("The provided email address will be verified (recommended)")
],
'$abandon_days' => [
'abandon_days',
t('Abandon account after x days'),
- get_config('system','account_abandon_days'),
+ Config::Get('system','account_abandon_days'),
t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')
],
// <-hilmar]
'$role' => $role,
- '$frontpage' => array('frontpage', t("Site homepage to show visitors (default: login box)"), get_config('system','frontpage'), t("example: 'pubstream' to show public stream, 'page/sys/home' to show a system webpage called 'home' or 'include:home.html' to include a file.")),
- '$mirror_frontpage' => array('mirror_frontpage', t("Preserve site homepage URL"), get_config('system','mirror_frontpage'), t('Present the site homepage in a frame at the original location instead of redirecting')),
- '$allowed_sites' => array('allowed_sites', t("Allowed friend domains"), get_config('system','allowed_sites'), t("Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains")),
- '$force_publish' => array('publish_all', t("Force publish"), get_config('system','publish_all'), t("Check to force all profiles on this site to be listed in the site directory")),
+ '$frontpage' => array('frontpage', t("Site homepage to show visitors (default: login box)"), Config::Get('system','frontpage'), t("example: 'pubstream' to show public stream, 'page/sys/home' to show a system webpage called 'home' or 'include:home.html' to include a file.")),
+ '$mirror_frontpage' => array('mirror_frontpage', t("Preserve site homepage URL"), Config::Get('system','mirror_frontpage'), t('Present the site homepage in a frame at the original location instead of redirecting')),
+ '$allowed_sites' => array('allowed_sites', t("Allowed friend domains"), Config::Get('system','allowed_sites'), t("Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains")),
+ '$force_publish' => array('publish_all', t("Force publish"), Config::Get('system','publish_all'), t("Check to force all profiles on this site to be listed in the site directory")),
'$disable_discover_tab' => array('disable_discover_tab', t('Enable public stream'), $discover_tab, t('Enable the public stream. Warning: this content is unmoderated')),
- '$site_firehose' => array('site_firehose', t('Site only public stream'), get_config('system','site_firehose'), t('Restrict the public stream to content originating at this site')),
- '$open_pubstream' => array('open_pubstream', t('Allow anybody on the internet to access the public streams'), get_config('system','open_pubstream',1), t('Disable to require authentication before viewing')),
- '$incl' => array('pub_incl',t('Only import Public stream posts with this text'), get_config('system','pubstream_incl'),t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')),
- '$excl' => array('pub_excl',t('Do not import Public stream posts with this text'), get_config('system','pubstream_excl'),t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')),
+ '$site_firehose' => array('site_firehose', t('Site only public stream'), Config::Get('system','site_firehose'), t('Restrict the public stream to content originating at this site')),
+ '$open_pubstream' => array('open_pubstream', t('Allow anybody on the internet to access the public streams'), Config::Get('system','open_pubstream',1), t('Disable to require authentication before viewing')),
+ '$incl' => array('pub_incl',t('Only import Public stream posts with this text'), Config::Get('system','pubstream_incl'),t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')),
+ '$excl' => array('pub_excl',t('Do not import Public stream posts with this text'), Config::Get('system','pubstream_excl'),t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')),
'$login_on_homepage' => array('login_on_homepage', t("Login on Homepage"),((intval($homelogin) || $homelogin === false) ? 1 : '') , t("Present a login box to visitors on the home page if no other content has been configured.")),
'$enable_context_help' => array('enable_context_help', t("Enable context help"),((intval($enable_context_help) === 1 || $enable_context_help === false) ? 1 : 0) , t("Display contextual help for the current page when the help button is pressed.")),
- '$reply_address' => [ 'reply_address', t('Reply-to email address for system generated email.'), get_config('system','reply_address','noreply@' . \App::get_hostname()),'' ],
- '$from_email' => [ 'from_email', t('Sender (From) email address for system generated email.'), get_config('system','from_email','Administrator@' . \App::get_hostname()),'' ],
- '$from_email_name' => [ 'from_email_name', t('Name of email sender for system generated email.'), get_config('system','from_email_name',\Zotlabs\Lib\System::get_site_name()),'' ],
-
- '$directory_server' => (($dir_choices) ? array('directory_server', t("Directory Server URL"), get_config('system','directory_server'), t("Default directory server"), $dir_choices) : null),
-
- '$sse_enabled' => array('sse_enabled', t('Enable SSE Notifications'), get_config('system', 'sse_enabled', 0), t('If disabled, traditional polling will be used. Warning: this setting might not be suited for shared hosting')),
-
- '$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""),
- '$proxy' => array('proxy', t("Proxy URL"), get_config('system','proxy'), ""),
- '$timeout' => array('timeout', t("Network timeout"), (x(get_config('system','curl_timeout'))?get_config('system','curl_timeout'):60), t("Value is in seconds. Set to 0 for unlimited (not recommended).")),
- '$delivery_interval' => array('delivery_interval', t("Delivery interval"), (x(get_config('system','delivery_interval'))?get_config('system','delivery_interval'):2), t("Delay background delivery processes by this many seconds to reduce system load. Recommend: 4-5 for shared hosts, 2-3 for virtual private servers. 0-1 for large dedicated servers.")),
- '$delivery_batch_count' => array('delivery_batch_count', t('Deliveries per process'),(x(get_config('system','delivery_batch_count'))?get_config('system','delivery_batch_count'):1), t("Number of deliveries to attempt in a single operating system process. Adjust if necessary to tune system performance. Recommend: 1-5.")),
- //'$force_queue' => array('force_queue', t("Queue Threshold"), get_config('system','force_queue_threshold',3000), t("Always defer immediate delivery if queue contains more than this number of entries.")),
- '$poll_interval' => array('poll_interval', t("Poll interval"), (x(get_config('system','poll_interval'))?get_config('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")),
- '$imagick_path' => array('imagick_path', t("Path to ImageMagick convert program"), get_config('system','imagick_convert_path'), t("If set, use this program to generate photo thumbnails for huge images ( > 4000 pixels in either dimension), otherwise memory exhaustion may occur. Example: /usr/bin/convert")),
- '$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")),
- '$default_expire_days' => array('default_expire_days', t('Expiration period in days for imported (grid/network) content'), intval(get_config('system','default_expire_days', 30)), t('0 for no expiration of imported content')),
- '$active_expire_days' => array('active_expire_days', t('Do not expire any posts which have comments less than this many days ago'), intval(get_config('system','active_expire_days',7)), ''),
- '$sellpage' => array('site_sellpage', t('Public servers: Optional landing (marketing) webpage for new registrants'), get_config('system','sellpage',''), sprintf( t('Create this page first. Default is %s/register'),z_root())),
- '$first_page' => array('first_page', t('Page to display after creating a new channel'), get_config('system','workflow_channel_next','profiles'), t('Default: profiles')),
- '$location' => array('site_location', t('Optional: site location'), get_config('system','site_location',''), t('Region or country')),
+ '$reply_address' => [ 'reply_address', t('Reply-to email address for system generated email.'), Config::Get('system','reply_address','noreply@' . \App::get_hostname()),'' ],
+ '$from_email' => [ 'from_email', t('Sender (From) email address for system generated email.'), Config::Get('system','from_email','Administrator@' . \App::get_hostname()),'' ],
+ '$from_email_name' => [ 'from_email_name', t('Name of email sender for system generated email.'), Config::Get('system','from_email_name',\Zotlabs\Lib\System::get_site_name()),'' ],
+
+ '$directory_server' => (($dir_choices) ? array('directory_server', t("Directory Server URL"), Config::Get('system','directory_server'), t("Default directory server"), $dir_choices) : null),
+
+ '$sse_enabled' => array('sse_enabled', t('Enable SSE Notifications'), Config::Get('system', 'sse_enabled', 0), t('If disabled, traditional polling will be used. Warning: this setting might not be suited for shared hosting')),
+
+ '$proxyuser' => array('proxyuser', t("Proxy user"), Config::Get('system','proxyuser'), ""),
+ '$proxy' => array('proxy', t("Proxy URL"), Config::Get('system','proxy'), ""),
+ '$timeout' => array('timeout', t("Network timeout"), (x(Config::Get('system','curl_timeout'))?Config::Get('system','curl_timeout'):60), t("Value is in seconds. Set to 0 for unlimited (not recommended).")),
+ '$delivery_interval' => array('delivery_interval', t("Delivery interval"), (x(Config::Get('system','delivery_interval'))?Config::Get('system','delivery_interval'):2), t("Delay background delivery processes by this many seconds to reduce system load. Recommend: 4-5 for shared hosts, 2-3 for virtual private servers. 0-1 for large dedicated servers.")),
+ '$delivery_batch_count' => array('delivery_batch_count', t('Deliveries per process'),(x(Config::Get('system','delivery_batch_count'))?Config::Get('system','delivery_batch_count'):1), t("Number of deliveries to attempt in a single operating system process. Adjust if necessary to tune system performance. Recommend: 1-5.")),
+ //'$force_queue' => array('force_queue', t("Queue Threshold"), Config::Get('system','force_queue_threshold',3000), t("Always defer immediate delivery if queue contains more than this number of entries.")),
+ '$poll_interval' => array('poll_interval', t("Poll interval"), (x(Config::Get('system','poll_interval'))?Config::Get('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")),
+ '$imagick_path' => array('imagick_path', t("Path to ImageMagick convert program"), Config::Get('system','imagick_convert_path'), t("If set, use this program to generate photo thumbnails for huge images ( > 4000 pixels in either dimension), otherwise memory exhaustion may occur. Example: /usr/bin/convert")),
+ '$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(Config::Get('system','maxloadavg')) > 0)?Config::Get('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")),
+ '$default_expire_days' => array('default_expire_days', t('Expiration period in days for imported (grid/network) content'), intval(Config::Get('system','default_expire_days', 30)), t('0 for no expiration of imported content')),
+ '$active_expire_days' => array('active_expire_days', t('Do not expire any posts which have comments less than this many days ago'), intval(Config::Get('system','active_expire_days',7)), ''),
+ '$sellpage' => array('site_sellpage', t('Public servers: Optional landing (marketing) webpage for new registrants'), Config::Get('system','sellpage',''), sprintf( t('Create this page first. Default is %s/register'),z_root())),
+ '$first_page' => array('first_page', t('Page to display after creating a new channel'), Config::Get('system','workflow_channel_next','profiles'), t('Default: profiles')),
+ '$location' => array('site_location', t('Optional: site location'), Config::Get('system','site_location',''), t('Region or country')),
'$form_security_token' => get_form_security_token("admin_site"),
));
}
diff --git a/Zotlabs/Module/Admin/Themes.php b/Zotlabs/Module/Admin/Themes.php
index 7f615afa8..09fec9725 100644
--- a/Zotlabs/Module/Admin/Themes.php
+++ b/Zotlabs/Module/Admin/Themes.php
@@ -2,7 +2,8 @@
namespace Zotlabs\Module\Admin;
-use \Michelf\MarkdownExtra;
+use Michelf\MarkdownExtra;
+use Zotlabs\Lib\Config;
/**
* @brief Admin area theme settings.
@@ -37,7 +38,7 @@ class Themes {
* @return string with parsed HTML
*/
function get(){
- $allowed_themes_str = get_config('system', 'allowed_themes');
+ $allowed_themes_str = Config::Get('system', 'allowed_themes');
$allowed_themes_raw = explode(',', $allowed_themes_str);
$allowed_themes = array();
if(count($allowed_themes_raw))
@@ -100,7 +101,7 @@ class Themes {
info(sprintf('Theme %s disabled.', $theme));
}
- set_config('system', 'allowed_themes', $s);
+ Config::Set('system', 'allowed_themes', $s);
goaway(z_root() . '/admin/themes' );
}