Skip to content

Commit

Permalink
Added COM_isDemoMode()
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Aug 26, 2019
1 parent 0ac32ab commit c8ecfb8
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion plugins/recaptcha/autoinstall.php
Expand Up @@ -45,7 +45,7 @@ function plugin_autoinstall_recaptcha($pi_name)
global $_CONF, $_RECAPTCHA_CONF;

// IF demo mode (since GL 2.2.0) is in effect, return no valid information
if (isset($_CONF['demo_mode']) && $_CONF['demo_mode']) {
if (COM_isDemoMode()) {
return [];
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/staticpages/services.inc.php
Expand Up @@ -75,7 +75,7 @@ function service_submit_staticpages($args, &$output, &$svc_msg)
return PLG_RET_AUTH_FAILED;
}

if (isset($_CONF['demo_mode']) && $_CONF['demo_mode']) {
if (COM_isDemoMode()) {
$output .= COM_showMessageText($LANG_ACCESS['demo_mode_denied_msg'], $LANG_ACCESS['accessdenied']);
$output = COM_createHTMLDocument($output, array('pagetitle' => $LANG_ACCESS['accessdenied']));

Expand Down
2 changes: 1 addition & 1 deletion plugins/xmlsitemap/functions.inc
Expand Up @@ -333,7 +333,7 @@ function XMLSMAP_update($type = null, $include = null, $exclude = null)
$pingTargets[] = 'bing';
}

if ((isset($_CONF['demo_mode']) && !$_CONF['demo_mode']) || !isset($_CONF['demo_mode'])) {
if (!COM_isDemoMode()) {
if (count($pingTargets) > 0) {
$sitemap->sendPing($pingTargets);
}
Expand Down
2 changes: 1 addition & 1 deletion public_html/admin/envcheck.php
Expand Up @@ -659,7 +659,7 @@ function _checkEnvironment()
'lang_showhide_phpinfo' => $LANG_ENVCHECK['showhide_phpinfo'],
));

if (!(isset($_CONF['demo_mode']) && $_CONF['demo_mode'])) {
if (!COM_isDemoMode()) {
_phpinfo($T);
}

Expand Down
2 changes: 1 addition & 1 deletion public_html/admin/mail.php
Expand Up @@ -262,7 +262,7 @@ function send_messages(array $vars)

$tempTo = is_array($to) ? implode('', array_keys($to)) : $to;

if (isset($_CONF['demo_mode']) && $_CONF['demo_mode']) {
if (COM_isDemoMode()) {
$successes[] = htmlspecialchars ($tempTo);
} else {
if (! COM_mail($to, $subject, $message, $from, $html, $priority)) {
Expand Down
2 changes: 1 addition & 1 deletion public_html/admin/plugins.php
Expand Up @@ -599,7 +599,7 @@ function plugin_upload_enabled()
// and the plugin directories are writable by the web server.
$errors = array();

if (isset($_CONF['demo_mode']) && $_CONF['demo_mode']) {
if (COM_isDemoMode()) {
$errors[] = $LANG32[69];
}
if (!ini_get('file_uploads')) {
Expand Down
2 changes: 1 addition & 1 deletion public_html/filemanager/connectors/php/filemanager.php
Expand Up @@ -40,7 +40,7 @@ function fm_authenticate()
{
global $_CONF;

if (isset($_CONF['demo_mode']) && $_CONF['demo_mode']) {
if (COM_isDemoMode()) {
return false;
} else {
return SEC_inGroup('Root') || (!$_CONF['filemanager_disabled'] && (SEC_inGroup('Filemanager Admin') || SEC_hasRights('filemanager.admin')));
Expand Down
2 changes: 1 addition & 1 deletion public_html/filemanager/index.php
Expand Up @@ -44,7 +44,7 @@
COM_accessLog("User {$_USER['username']} tried to illegally access the Filemanager.");
COM_output($display);
exit;
} elseif (isset($_CONF['demo_mode']) && $_CONF['demo_mode']) {
} elseif (COM_isDemoMode()) {
$content = COM_showMessageText($LANG_ACCESS['demo_mode_denied_msg'], $LANG_ACCESS['accessdenied']);
$display = COM_createHTMLDocument($content, ['pagetitle' => $LANG_ACCESS['accessdenied']]);
COM_output($display);
Expand Down
15 changes: 14 additions & 1 deletion public_html/lib-common.php
Expand Up @@ -8583,7 +8583,7 @@ function COM_setupAdvancedEditor($custom, $permissions = 'story.edit', $myEditor
// Check if the current user has access to Filemanager
$geeklogFileManager = "false";
if (!$_CONF['filemanager_disabled'] && (SEC_inGroup('Root') || (SEC_inGroup('Filemanager Admin') || SEC_hasRights('filemanager.admin')))) {
if ((isset($_CONF['demo_mode']) && !$_CONF['demo_mode']) || !isset($_CONF['demo_mode'])) {
if (!COM_isDemoMode()) {
$geeklogFileManager = "true";
}
}
Expand Down Expand Up @@ -8705,6 +8705,19 @@ function COM_isEnableDeveloperModeLog($type)
return $retval;
}

/**
* Return if we are in demo mode
*
* @return bool true if we are in demo mode, false otherwise
* @since Geeklog 2.2.1
*/
function COM_isDemoMode()
{
global $_CONF;

return isset($_CONF['demo_mode']) && $_CONF['demo_mode'];
}

// Now include all plugin functions
foreach ($_PLUGINS as $pi_name) {
require_once $_CONF['path'] . 'plugins/' . $pi_name . '/functions.inc';
Expand Down
2 changes: 1 addition & 1 deletion system/classes/config.class.php
Expand Up @@ -998,7 +998,7 @@ public function get_ui($grp, $sg = '0', $change_result = null)
$table_flag = false;
//print_r($params);
foreach ($params as $name => $e) {
if (isset($_CONF['demo_mode']) && $_CONF['demo_mode']) {
if (COM_isDemoMode()) {
if ( in_array($name,array(
'site_url','site_admin_url'
,'url_routing'
Expand Down
2 changes: 1 addition & 1 deletion system/lib-security.php
Expand Up @@ -1435,7 +1435,7 @@ function SEC_createToken($ttl = 1200)
DB_query($sql);

/* Destroy tokens for this user/url combination. Since anonymous user share same id do not delete */
if (!(isset($_CONF['demo_mode']) && $_CONF['demo_mode'])) {
if (!COM_isDemoMode()) {
if ($uid != 1) {
$sql = "DELETE FROM {$_TABLES['tokens']} WHERE owner_id = '{$uid}' AND urlfor= '$pageURL'";
DB_query($sql);
Expand Down
2 changes: 1 addition & 1 deletion system/lib-sessions.php
Expand Up @@ -336,7 +336,7 @@ function SESS_endUserSession($userId)

$userId = (int) $userId;

if (!(isset($_CONF['demo_mode']) && $_CONF['demo_mode'])) {
if (!COM_isDemoMode()) {
DB_delete($_TABLES['sessions'], 'uid', $userId);
Session::setUid(Session::ANON_USER_ID);
}
Expand Down

0 comments on commit c8ecfb8

Please sign in to comment.