Example #1
0
 /**
  * Running triggers for some actions
  *
  * @param string	$trigger	For example <i>admin/System/components/plugins/disable</i>
  * @param mixed		$data		For example ['name'	=> <i>plugin_name</i>]
  *
  * @return bool
  */
 function run($trigger, $data = null)
 {
     if (!is_string($trigger)) {
         return true;
     }
     if (!$this->initialized) {
         $modules = array_keys(Config::instance()->components['modules']);
         foreach ($modules as $module) {
             _include_once(MODULES . '/' . $module . '/trigger.php', false);
         }
         unset($modules, $module);
         $plugins = get_files_list(PLUGINS, false, 'd');
         if (!empty($plugins)) {
             foreach ($plugins as $plugin) {
                 _include_once(PLUGINS . '/' . $plugin . '/trigger.php', false);
             }
         }
         unset($plugins, $plugin);
         $this->initialized = true;
     }
     if (!isset($this->triggers[$trigger]) || empty($this->triggers[$trigger])) {
         return true;
     }
     $return = true;
     foreach ($this->triggers[$trigger] as $closure) {
         if ($data === null) {
             $return = $return && ($closure() === false ? false : true);
         } else {
             $return = $return && ($closure($data) === false ? false : true);
         }
     }
     return $return;
 }
Example #2
0
File: index.php Project: gtyd/jira
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <?php 
echo _asset('@web/AmazeUI/assets/css/amazeui.min.css');
?>
    <?php 
echo _asset('@web/js/base_new.min.js');
?>
    <?php 
echo _asset('@web/js/mysoft.js');
?>
    <?php 
echo _include_once("@common/components/dialog/index.php");
?>
    <style>
        .header {
            text-align: center;
        }

        .header h1 {
            font-size: 200%;
            color: #333;
            margin-top: 30px;
        }

        .header p {
            font-size: 14px;
        }
Example #3
0
        $Config->db[] = $_POST['db'];
    } else {
        $Config->db[$_POST['db']['mirror']]['mirrors'][] = $_POST['db'];
    }
    $update = true;
} elseif ($_POST['mode'] == 'edit') {
    if (isset($_POST['mirror'])) {
        $cdb =& $Config->db[$_POST['database']]['mirrors'][$_POST['mirror']];
    } elseif ($_POST['database'] > 0) {
        $cdb =& $Config->db[$_POST['database']];
    }
    foreach ($_POST['db'] as $item => $value) {
        $cdb[$item] = $value;
    }
    unset($cdb, $item, $value);
    $update = true;
} elseif ($_POST['mode'] == 'delete' && isset($_POST['database'])) {
    if (isset($_POST['mirror'])) {
        unset($Config->db[$_POST['database']]['mirrors'][$_POST['mirror']]);
        $update = true;
    } elseif ($_POST['database'] > 0) {
        unset($Config->db[$_POST['database']]);
        $update = true;
    }
} elseif ($_POST['mode'] == 'config') {
    _include_once(MFOLDER . '/' . $Index->savefile . '.php', false);
}
if ($update) {
    $Index->save();
}
unset($update);
Example #4
0
<?php

/**
 * @package		CleverStyle CMS
 * @subpackage	System module
 * @category	modules
 * @author		Nazar Mokrynskyi <*****@*****.**>
 * @copyright	Copyright (c) 2011-2014, Nazar Mokrynskyi
 * @license		MIT License, see license.txt
 */
namespace cs;

$rc = Config::instance()->route;
if (isset($rc[1])) {
    _include_once(MFOLDER . "/{$rc['0']}/save.{$rc['1']}.php", false);
}
Example #5
0
 /**
  * Error pages processing
  *
  * @param null|string|string[]	$custom_text	Custom error text instead of text like "404 Not Found",
  * 												or array with two elements: [error, error_description]
  * @param bool					$json			Force JSON return format
  */
 function error($custom_text = null, $json = false)
 {
     static $error_showed = false;
     if ($error_showed) {
         return;
     }
     $error_showed = true;
     if (!defined('ERROR_CODE')) {
         error_code(500);
     }
     if (defined('API') && !API && ERROR_CODE == 403 && _getcookie('sign_out')) {
         header('Location: ' . Config::instance()->base_url(), true, 302);
         $this->Content = '';
         exit;
     }
     interface_off();
     $error = code_header(ERROR_CODE);
     if (is_array($custom_text)) {
         $error = $custom_text[0];
         $error_description = $custom_text[1];
     } else {
         $error_description = $custom_text ?: $error;
     }
     if (defined('API') && API || $json) {
         if ($json) {
             header('Content-Type: application/json; charset=utf-8', true);
             interface_off();
         }
         $this->json(['error' => $error, 'error_description' => $error_description]);
     } else {
         ob_start();
         if (!_include_once(THEMES . "/{$this->theme}/error.html", false) && !_include_once(THEMES . "/{$this->theme}/error.php", false)) {
             echo "<!doctype html>\n" . h::title(code_header($error)) . ($error_description ?: $error);
         }
         $this->Content = ob_get_clean();
     }
     $this->__finish();
     exit;
 }
Example #6
0
 /**
  * Initialization: loading of module structure, including of necessary module files, inclusion of save file
  */
 protected function init()
 {
     $Config = Config::instance();
     $L = Language::instance();
     $Page = Page::instance();
     $User = User::instance();
     /**
      * Some routing preparations
      */
     $rc_path =& $this->route_path;
     $rc_ids =& $this->route_ids;
     foreach ($Config->route as &$item) {
         if (is_numeric($item)) {
             $rc_ids[] =& $item;
         } else {
             $rc_path[] =& $item;
         }
     }
     unset($item, $rc_path, $rc_ids);
     $rc =& $this->route_path;
     if ($Config->core['simple_admin_mode'] && file_exists(MFOLDER . '/index_simple.json')) {
         $structure_file = 'index_simple.json';
     } else {
         $structure_file = 'index.json';
     }
     if (file_exists(MFOLDER . "/{$structure_file}")) {
         $this->structure = file_get_json(MFOLDER . "/{$structure_file}");
         if (is_array($this->structure)) {
             foreach ($this->structure as $item => $value) {
                 if (!is_array($value)) {
                     $item = $value;
                 }
                 if ($User->get_permission($this->permission_group, $item)) {
                     $this->parts[] = $item;
                     if (isset($rc[0]) && $item == $rc[0] && is_array($value)) {
                         foreach ($value as $subpart) {
                             if ($User->get_permission($this->permission_group, "{$item}/{$subpart}")) {
                                 $this->subparts[] = $subpart;
                             } elseif (isset($rc[1]) && $rc[1] == $subpart) {
                                 error_code(403);
                                 return;
                             }
                         }
                     }
                 } elseif ($rc[0] == $item) {
                     error_code(403);
                     return;
                 }
             }
             unset($item, $value, $subpart);
         }
     } elseif (API && !file_exists(MFOLDER . '/index.php') && !file_exists(MFOLDER . "/index.{$this->request_method}.php")) {
         error_code(404);
         return;
     }
     unset($structure_file);
     _include_once(MFOLDER . '/index.php', false);
     if (API && $this->request_method) {
         _include_once(MFOLDER . "/index.{$this->request_method}.php", false);
     }
     if ($this->stop || defined('ERROR_CODE')) {
         return;
     }
     if ($this->parts) {
         if (!isset($rc[0]) || $rc[0] == '') {
             if (API) {
                 return;
             }
             $rc[0] = $this->parts[0];
             if (isset($this->structure[$rc[0]]) && is_array($this->structure[$rc[0]])) {
                 $this->subparts = $this->structure[$rc[0]];
             }
         } elseif ($rc[0] != '' && !empty($this->parts) && !in_array($rc[0], $this->parts)) {
             error_code(404);
             return;
         }
         /**
          * Saving of changes
          */
         if (IN_ADMIN && !_include_once(MFOLDER . "/{$rc['0']}/{$this->savefile}.php", false)) {
             _include_once(MFOLDER . "/{$this->savefile}.php", false);
         }
         IN_ADMIN && $this->title_auto && $Page->title($L->administration);
         if (!$this->api && $this->title_auto) {
             $Page->title($L->{HOME ? 'home' : MODULE});
         }
         if (!$this->api) {
             if (!HOME && $this->title_auto) {
                 $Page->title($L->{$rc}[0]);
             }
         }
         /**
          * Warning if site is closed
          */
         if (!$Config->core['site_mode']) {
             $Page->warning(get_core_ml_text('closed_title'));
         }
         _include_once(MFOLDER . "/{$rc['0']}.php", false);
         if (API && $this->request_method) {
             _include_once(MFOLDER . "/{$rc['0']}.{$this->request_method}.php", false);
         }
         if ($this->stop || defined('ERROR_CODE')) {
             return;
         }
         if ($this->subparts) {
             if (!isset($rc[1]) || $rc[1] == '' && !empty($this->subparts)) {
                 if (API) {
                     return;
                 }
                 $rc[1] = $this->subparts[0];
             } elseif ($rc[1] != '' && !empty($this->subparts) && !in_array($rc[1], $this->subparts)) {
                 error_code(404);
                 return;
             }
             if (!$this->api) {
                 if (!HOME && $this->title_auto) {
                     $Page->title($L->{$rc}[1]);
                 }
                 if ($this->action === null) {
                     $this->action = (IN_ADMIN ? 'admin/' : '') . MODULE . "/{$rc['0']}/{$rc['1']}";
                 }
             }
             _include_once(MFOLDER . "/{$rc['0']}/{$rc['1']}.php", false);
             if (API && $this->request_method) {
                 _include_once(MFOLDER . "/{$rc['0']}/{$rc['1']}.{$this->request_method}.php", false);
             }
             if ($this->stop || defined('ERROR_CODE')) {
                 return;
             }
         } elseif (!$this->api && $this->action === null) {
             $this->action = (IN_ADMIN ? 'admin/' : '') . MODULE . "/{$rc['0']}";
         }
         unset($rc);
         if ($this->post_title && $this->title_auto) {
             $Page->title($this->post_title);
         }
     } elseif (!$this->api) {
         IN_ADMIN && $Page->title($L->administration);
         if (!$this->api && $this->title_auto) {
             $Page->title($L->{HOME ? 'home' : MODULE});
         }
         if ($this->action === null) {
             $this->action = $Config->server['relative_address'];
         }
         _include_once(MFOLDER . "/{$this->savefile}.php", false);
     }
 }
Example #7
0
<?php

/**
 * @package		CleverStyle CMS
 * @subpackage	System module
 * @category	modules
 * @author		Nazar Mokrynskyi <*****@*****.**>
 * @copyright	Copyright (c) 2011-2014, Nazar Mokrynskyi
 * @license		MIT License, see license.txt
 */
namespace cs;

_include_once(MFOLDER . '/' . Index::instance()->savefile . '.php', false);
Example #8
0
    /**
     * Loading of base system configuration, creating of missing directories
     */
    protected function construct()
    {
        if (!file_exists(CONFIG . '/main.json')) {
            error_code(500);
            Page::instance()->error(h::p('Config file not found, is system installed properly?') . h::a('How to install CleverStyle CMS', ['href' => 'https://github.com/nazar-pc/CleverStyle-CMS/wiki/Installation']));
            exit;
        }
        $this->config = file_get_json_nocomments(CONFIG . '/main.json');
        _include_once(CONFIG . '/main.php', false);
        defined('DEBUG') || define('DEBUG', false);
        define('DOMAIN', $this->config['domain']);
        date_default_timezone_set($this->config['timezone']);
        if ($clangs = Cache::instance()->{'languages/clangs'}) {
            if (is_array($clangs) && !empty($clangs)) {
                $clang = explode('/', trim($_SERVER['REQUEST_URI'], '/'), 2)[0];
                if (in_array($clang, $clangs)) {
                    $this->set('language', array_flip($clangs)[$clang]);
                    define('FIXED_LANGUAGE', true);
                }
                unset($clang);
            }
        }
        unset($clangs);
        if (!is_dir(STORAGE)) {
            @mkdir(STORAGE, 0755);
            file_put_contents(STORAGE . '/.htaccess', 'Allow From All');
        }
        if (!is_dir(CACHE)) {
            @mkdir(CACHE, 0700);
        }
        if (!is_dir(PCACHE)) {
            @mkdir(PCACHE, 0755);
            file_put_contents(PCACHE . '/.htaccess', '<FilesMatch "\\.(css|js)$">
	Allow From All
</FilesMatch>
<ifModule mod_expires.c>
	ExpiresActive On
	ExpiresDefault "access plus 1 month"
</ifModule>
<ifModule mod_headers.c>
	Header set Cache-Control "max-age=2592000, public"
</ifModule>
AddEncoding gzip .js
AddEncoding gzip .css
');
        }
        if (!is_dir(LOGS)) {
            @mkdir(LOGS, 0700);
        }
        if (!is_dir(TEMP)) {
            @mkdir(TEMP, 0755);
            file_put_contents(TEMP . '/.htaccess', 'Allow From All');
        }
        if (isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'application/json') === 0) {
            $_POST = _json_decode(@file_get_contents('php://input')) ?: [];
            $_REQUEST = array_merge($_REQUEST, $_POST);
        } elseif (in_array(strtolower($_SERVER['REQUEST_METHOD']), ['head', 'put', 'delete'])) {
            if (isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'application/x-www-form-urlencoded') === 0) {
                @parse_str(file_get_contents('php://input'), $_POST);
                $_REQUEST = array_merge($_REQUEST, $_POST);
            }
        }
        $this->constructed = true;
    }
Example #9
0
File: main.php Project: gtyd/jira
use yii\helpers\Html;
/* @var $this \yii\web\View */
/* @var $content string */
$this->beginPage();
?>
<!DOCTYPE html>
<html lang="<?php 
echo Yii::$app->language;
?>
">
<head>
    <?php 
echo _include_once("@common/views/meta.php");
?>
    <?php 
echo _include_once("@common/views/meta.php");
?>
    <?php 
echo Html::csrfMetaTags();
?>
    <title><?php 
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
    <?php 
echo _asset('@static/css/base.min.css');
?>
    <script type="text/javascript">