Example #1
0
 public function __call($method, $arguments)
 {
     if ($method === 'index' || array_key_exists($method, Column::$TYPES)) {
         if (count($arguments) <= 0) {
             throw new MissingArgumentException($method, __CLASS__);
         }
         $column = $arguments[0];
         $options = !empty($arguments[1]) ? $arguments[1] : array();
         if ($method === 'index') {
             if (!is_array($column)) {
                 $column = array($column);
             }
             $this->indexes = array_merge($this->indexes, array(array('name' => Index::instance()->getName($column, $options), 'keys' => '`' . implode('`,`', $column) . '`')));
         } else {
             $options['id'] = $column;
             $options['type'] = $method;
             $this->columns = array_merge($this->columns, array(Column::instance()->parseToDatabase($options)));
         }
     } else {
         if ($method === 'timestamps') {
             $this->columns = array_merge($this->columns, array(Column::instance()->parseToDatabase(array('id' => 'created_at', 'type' => 'datetime'))));
             $this->columns = array_merge($this->columns, array(Column::instance()->parseToDatabase(array('id' => 'updated_at', 'type' => 'datetime'))));
         } else {
             throw new UndefinedMethodException($method, __CLASS__);
         }
     }
 }
Example #2
0
 /**
  * Is used as error handler
  *
  * @param int			$level	Error level
  * @param null|string	$string	Error message
  */
 function trigger($level, $string = null)
 {
     if (!$this->error) {
         return;
     }
     $string = xap($string);
     $dump = 'null';
     $debug_backtrace = debug_backtrace();
     if (isset($debug_backtrace[0]['file'], $debug_backtrace[0]['file'])) {
         $file = $debug_backtrace[0]['file'];
         $line = $debug_backtrace[0]['line'];
     } else {
         $file = $debug_backtrace[1]['file'];
         $line = $debug_backtrace[1]['line'];
     }
     if (DEBUG) {
         $dump = _json_encode($debug_backtrace);
     }
     unset($debug_backtrace);
     $log_file = LOGS . '/' . date('d-m-Y') . '_' . strtr(date_default_timezone_get(), '/', '_');
     $time = date('d-m-Y h:i:s') . ' [' . microtime(true) . ']';
     switch ($level) {
         case E_USER_ERROR:
         case E_ERROR:
             ++$this->num;
             file_put_contents($log_file, "E {$time} {$string} Occurred: {$file}:{$line} Dump: {$dump}\n", LOCK_EX | FILE_APPEND);
             unset($dump);
             $this->errors_list[] = "E {$time} {$string} Occurred: {$file}:{$line}";
             error_code(500);
             /**
              * If Index instance exists - execution will be stopped there, otherwise in Page instance
              */
             Index::instance(true)->__finish();
             Page::instance()->error();
             break;
         case E_USER_WARNING:
         case E_WARNING:
             ++$this->num;
             file_put_contents($log_file, "W {$time} {$string} Occurred: {$file}:{$line} Dump: {$dump}\n", LOCK_EX | FILE_APPEND);
             unset($dump);
             $this->errors_list[] = "W {$time} {$string} Occurred: {$file}:{$line}";
             break;
         default:
             file_put_contents($log_file, "N {$time} {$string} Occurred: {$file}:{$line} Dump: {$dump}\n", LOCK_EX | FILE_APPEND);
             unset($dump);
             $this->errors_list[] = "N {$time} {$string} Occurred: {$file}:{$line}";
             break;
     }
     /**
      * If too many non-critical errors - also stop execution
      */
     if ($this->num >= 100) {
         /**
          * If Index instance exists - execution will be stopped there, otherwise in Page instance
          */
         Index::instance(true)->__finish();
         Page::instance()->error();
     }
 }
Example #3
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;

if (!isset($_POST['mode'])) {
    return;
}
$Index = Index::instance();
$Config = Config::instance();
$update = false;
if ($_POST['mode'] == 'add') {
    foreach ($_POST['db'] as $item => $value) {
        $_POST['db'][$item] = $value;
    }
    unset($item, $value);
    $_POST['db']['mirrors'] = [];
    if ($_POST['db']['mirror'] == -1) {
        $Config->db[] = $_POST['db'];
    } else {
        $Config->db[$_POST['db']['mirror']]['mirrors'][] = $_POST['db'];
    }
    $update = true;
} elseif ($_POST['mode'] == 'edit') {
Example #4
0
 *  ['name'	=> <i>module_name</i>]<br>
 *
 *  admin/System/components/modules/storage/process<br>
 *  ['name'	=> <i>module_name</i>]
 */
namespace cs;

$Cache = Cache::instance();
$Config = Config::instance();
$Core = Core::instance();
$db = DB::instance();
$L = Language::instance();
$Page = Page::instance();
$User = User::instance();
$Permission = Permission::instance();
$a = Index::instance();
if (isset($_POST['update_modules_list'])) {
    /**
     * List of currently presented modules in file system
     */
    $modules_list = array_fill_keys($new_modules = get_files_list(MODULES, false, 'd'), ['active' => -1, 'db' => [], 'storage' => []]);
    /**
     * Already known modules
     */
    $modules =& $Config->components['modules'];
    $old_modules = array_keys($modules);
    /**
     * Deletion of undefined modules permissions
     */
    if ($new_modules != $old_modules) {
        $permissions_ids = [];
Example #5
0
<?php

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

Index::instance()->main_sub_menu_auto = true;
Example #6
0
<?php

/**
 * @package		HybridAuth
 * @category	modules
 * @author		HybridAuth authors
 * @author		Nazar Mokrynskyi <*****@*****.**> (integration with CleverStyle CMS)
 * @copyright	HybridAuth authors
 * @license		MIT License, see license.txt
 */
namespace cs;

if (!isset($_POST['edit_settings'])) {
    return;
}
switch ($_POST['edit_settings']) {
    case 'save':
        Index::instance()->save(Config::instance()->module('HybridAuth')->set(['providers' => $_POST['providers'], 'enable_contacts_detection' => $_POST['enable_contacts_detection']]));
        break;
}
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;

Index::instance()->stop = !User::instance()->admin();
Example #8
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 #9
0
 * @license		MIT License, see license.txt
 */
namespace cs;

if (!isset($_POST['mode'])) {
    return;
}
$Config = Config::instance();
$update = false;
if ($_POST['mode'] == 'add') {
    foreach ($_POST['storage'] as $item => $value) {
        $_POST['storage'][$item] = $value;
    }
    $Config->storage[] = $_POST['storage'];
    unset($item, $value);
    $update = true;
} elseif ($_POST['mode'] == 'edit' && $_POST['storage_id'] > 0) {
    $cstorage =& $Config->storage[$_POST['storage_id']];
    foreach ($_POST['storage'] as $item => $value) {
        $cstorage[$item] = $value;
    }
    unset($cstorage, $item, $value);
    $update = true;
} elseif ($_POST['mode'] == 'delete' && isset($_POST['storage']) && $_POST['storage'] > 0) {
    unset($Config->storage[$_POST['storage']]);
    $update = true;
}
if ($update) {
    Index::instance()->save();
}
unset($update);
Example #10
0
<?php

/**
 * @package        Download
 * @category       modules
 * @author         Nazar Mokrynskyi <*****@*****.**>
 * @copyright      Copyright (c) 2014, Nazar Mokrynskyi
 * @license        MIT License, see license.txt
 */
namespace cs;

if (!file_exists(DIR . '/downloads')) {
    $downloads = 0;
} else {
    $downloads = file_get_json(DIR . '/downloads');
}
$downloads++;
file_put_json(DIR . '/downloads', $downloads);
header('Location: https://opir.org/storage/public/opir.org.apk', true, 301);
interface_off();
Index::instance()->stop = true;
Example #11
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;

$L = Language::instance();
Index::instance()->title_auto = false;
$rc =& Config::instance()->route;
if (!isset($rc[0])) {
    return;
}
switch ($rc[0]) {
    case path($L->profile):
        $rc[0] = 'profile';
}
if (!isset($rc[1])) {
    return;
}
switch ($rc[1]) {
    case path($L->settings):
        $rc[1] = 'settings';
}
if (!isset($rc[2])) {
    return;