Example #1
0
        unset($tag, $file);
        /**
         * License
         */
        if (file_exists($file = PLUGINS . "/{$plugin}/license.txt") || file_exists($file = PLUGINS . "/{$plugin}/license.html")) {
            if (substr($file, -3) == 'txt') {
                $tag = 'pre';
            } else {
                $tag = 'div';
            }
            $addition_state .= h::{'div.uk-modal.cs-left'}(h::{"{$tag}.uk-modal-dialog-large"}($tag == 'pre' ? prepare_attr_value(file_get_contents($file)) : file_get_contents($file)), ['id' => "{$plugin}_license", 'title' => "{$plugin} -> {$L->license}"]) . h::{'icon.cs-pointer'}('legal', ['data-title' => $L->license . h::br() . $L->click_to_view_details, 'onClick' => "\$('#{$plugin}_license').cs().modal('show');"]);
        }
        unset($tag, $file);
        $state = in_array($plugin, $Config->components['plugins']);
        $action .= h::{'a.cs-button-compact'}(h::icon($state ? 'minus' : 'check'), ['href' => $a->action . ($state ? '/disable/' : '/enable/') . $plugin, 'data-title' => $state ? $L->disable : $L->enable]);
        $plugin_info = false;
        if (file_exists(PLUGINS . "/{$plugin}/meta.json")) {
            $plugin_meta = file_get_json(PLUGINS . "/{$plugin}/meta.json");
            $plugin_info = $L->plugin_info($plugin_meta['package'], $plugin_meta['version'], $plugin_meta['description'], $plugin_meta['author'], isset($plugin_meta['website']) ? $plugin_meta['website'] : $L->none, $plugin_meta['license'], isset($plugin_meta['provide']) ? implode(', ', (array) $plugin_meta['provide']) : $L->none, isset($plugin_meta['require']) ? implode(', ', (array) $plugin_meta['require']) : $L->none, isset($plugin_meta['conflict']) ? implode(', ', (array) $plugin_meta['conflict']) : $L->none, isset($plugin_meta['optional']) ? implode(', ', (array) $plugin_meta['optional']) : $L->none, isset($plugin_meta['multilingual']) && in_array('interface', $plugin_meta['multilingual']) ? $L->yes : $L->no, isset($plugin_meta['multilingual']) && in_array('content', $plugin_meta['multilingual']) ? $L->yes : $L->no, isset($plugin_meta['languages']) ? implode(', ', $plugin_meta['languages']) : $L->none);
        }
        unset($plugin_meta);
        $plugins_list[] = [h::span($L->{$plugin}, ['data-title' => $plugin_info]), h::icon($state ? 'check' : 'minus', ['data-title' => $state ? $L->enabled : $L->disabled]) . $addition_state, $action];
        unset($plugin_info);
    }
    unset($plugin, $state, $addition_state, $action);
}
$plugins_for_removal = array_values(array_filter($plugins, function ($plugin) use($Config) {
    return !in_array($plugin, $Config->components['plugins']);
}));
$a->content(h::{'table.cs-table.cs-center-all'}(h::{'thead tr th'}($L->plugin_name, $L->state, $L->action) . h::{'tbody tr| td'}([$plugins_list ?: false])) . h::p(h::{'input[type=file][name=upload_plugin]'}(['style' => 'position: relative;']) . h::{'button[type=submit]'}(h::icon('upload') . $L->upload_and_install_update_plugin, ['formaction' => "{$a->action}/enable/upload"])) . ($plugins_for_removal ? h::p(h::{'select[name=remove_plugin]'}($plugins_for_removal) . h::{'button[type=submit]'}(h::icon('trash-o') . $L->complete_plugin_removal, ['formaction' => "{$a->action}/remove"])) : ''));
Example #2
0
            /**
             * Link to the module admin page
             */
            if (file_exists(MODULES . "/{$module_name}/admin/index.php") || file_exists(MODULES . "/{$module_name}/admin/index.json")) {
                $action .= h::{'a.cs-button-compact'}(h::icon('wrench'), ['href' => "admin/{$module_name}", 'data-title' => $L->module_admin_page]);
                $admin_link = true;
            }
            if ($module_name != $Config->core['default_module']) {
                $action .= h::{'a.cs-button-compact'}(h::icon($module_data['active'] == 1 ? 'minus' : 'check'), ['href' => $a->action . ($module_data['active'] == 1 ? '/disable/' : '/enable/') . $module_name, 'data-title' => $module_data['active'] == 1 ? $L->disable : $L->enable]) . h::{'a.cs-button-compact'}(h::icon('trash-o'), ['href' => "{$a->action}/uninstall/{$module_name}", 'data-title' => $L->uninstall]);
            }
        }
        /**
         * If module uninstalled or not installed yet
         */
    } else {
        $action .= h::{'a.cs-button-compact'}(h::icon('download'), ['href' => "{$a->action}/install/{$module_name}", 'data-title' => $L->install]);
    }
    $module_info = false;
    if (file_exists(MODULES . "/{$module_name}/meta.json")) {
        $module_meta = file_get_json(MODULES . "/{$module_name}/meta.json");
        $module_info = $L->module_info($module_meta['package'], $module_meta['version'], $module_meta['description'], $module_meta['author'], isset($module_meta['website']) ? $module_meta['website'] : $L->none, $module_meta['license'], isset($module_meta['db_support']) ? implode(', ', $module_meta['db_support']) : $L->none, isset($module_meta['storage_support']) ? implode(', ', $module_meta['storage_support']) : $L->none, isset($module_meta['provide']) ? implode(', ', (array) $module_meta['provide']) : $L->none, isset($module_meta['require']) ? implode(', ', (array) $module_meta['require']) : $L->none, isset($module_meta['conflict']) ? implode(', ', (array) $module_meta['conflict']) : $L->none, isset($module_meta['optional']) ? implode(', ', (array) $module_meta['optional']) : $L->none, isset($module_meta['multilingual']) && in_array('interface', $module_meta['multilingual']) ? $L->yes : $L->no, isset($module_meta['multilingual']) && in_array('content', $module_meta['multilingual']) ? $L->yes : $L->no, isset($module_meta['languages']) ? implode(', ', $module_meta['languages']) : $L->none);
    }
    unset($module_meta);
    $modules_list[] = [h::a($L->{$module_name}, ['href' => $admin_link ? "admin/{$module_name}" : false, 'data-title' => $module_info]), h::icon($module_data['active'] == 1 ? $module_name == $Config->core['default_module'] ? 'home' : 'check' : ($module_data['active'] == 0 ? 'minus' : 'times'), ['data-title' => $module_data['active'] == 1 ? $module_name == $Config->core['default_module'] ? $L->default_module : $L->enabled : ($module_data['active'] == 0 ? $L->disabled : "{$L->uninstalled} ({$L->not_installed})")]) . $addition_state, [$action, ['class' => 'cs-left-all']]];
    unset($module_info);
}
$modules_for_removal = array_keys(array_filter($Config->components['modules'], function ($module_data) {
    return $module_data['active'] == '-1';
}));
$a->content(h::{'table.cs-table.cs-center-all'}(h::{'thead tr th'}($L->module_name, $L->state, $L->action) . h::{'tbody tr| td'}([$modules_list])) . h::p(h::{'input[type=file][name=upload_module]'}() . h::{'button[type=submit]'}(h::icon('upload') . $L->upload_and_install_update_module, ['formaction' => "{$a->action}/install/upload"])) . h::p(h::{'input[type=file][name=upload_system]'}() . h::{'button[type=submit]'}(h::icon('upload') . $L->upload_and_update_system, ['formaction' => "{$a->action}/update_system"])) . ($modules_for_removal ? h::p(h::{'select[name=remove_module]'}($modules_for_removal) . h::{'button[type=submit]'}(h::icon('trash-o') . $L->complete_module_removal, ['formaction' => "{$a->action}/remove"])) : '') . h::{'button[type=submit]'}(h::icon('refresh') . $L->update_modules_list, ['data-title' => $L->update_modules_list_info, 'name' => 'update_modules_list']));
Example #3
0
 /**
  * Getting of debug information
  *
  * @return Page
  */
 protected function get_debug_info()
 {
     $Config = Config::instance();
     $db = DB::instance();
     $L = Language::instance();
     $debug_tabs = [];
     $debug_tabs_content = '';
     /**
      * DB queries
      */
     if ($Config->core['show_db_queries']) {
         $debug_tabs[] = $L->db_queries;
         $tmp = '';
         foreach ($db->get_connections_list() as $name => $database) {
             $queries = $database->queries();
             $tmp .= h::{'p.cs-padding-left'}($L->debug_db_info($name != 0 ? $L->db . ' ' . $database->database() : $L->core_db . ' (' . $database->database() . ')', format_time(round($database->connecting_time(), 5)), $queries['num'], format_time(round($database->time(), 5))));
             foreach ($queries['text'] as $i => $text) {
                 $tmp .= h::code($text . h::br(2) . '#' . h::i(format_time(round($queries['time'][$i], 5))), ['class' => ($queries['time'][$i] > 0.1 ? 'uk-alert-danger ' : '') . 'uk-alert']);
             }
         }
         unset($error, $name, $database, $i, $text);
         $debug_tabs_content .= h::div(h::p($L->debug_db_total($db->queries, format_time(round($db->time, 5))), $L->failed_connections . ': ' . h::b(implode(', ', $db->get_connections_list(false)) ?: $L->no), $L->successful_connections . ': ' . h::b(implode(', ', $db->get_connections_list(true)) ?: $L->no), $L->mirrors_connections . ': ' . h::b(implode(', ', $db->get_connections_list('mirror')) ?: $L->no), $L->active_connections . ': ' . (count($db->get_connections_list()) ? '' : h::b($L->no))) . $tmp);
         unset($tmp);
     }
     /**
      * Cookies
      */
     if ($Config->core['show_cookies']) {
         $debug_tabs[] = $L->cookies;
         $tmp = [h::td($L->key . ':', ['style' => 'width: 20%;']) . h::td($L->value)];
         foreach ($_COOKIE as $i => $v) {
             $tmp[] = h::td($i . ':', ['style' => 'width: 20%;']) . h::td(xap($v));
         }
         unset($i, $v);
         $debug_tabs_content .= h::{'table.cs-padding-left tr'}($tmp);
         unset($tmp);
     }
     $this->debug_info = $this->process_replacing(h::{'ul.cs-tabs li'}($debug_tabs) . h::div($debug_tabs_content));
     return $this;
 }
Example #4
0
            $Index->content(h::{'button[type=submit][name=action][value=remove_confirmed]'}($L->yes) . h::{'input[type=hidden]'}(['name' => 'remove_theme_confirmed', 'value' => $_POST['remove_theme']]));
            return;
            break;
        case 'remove_confirmed':
            $theme = $_POST['remove_theme_confirmed'];
            if ($theme == 'CleverStyle' || $theme == $Config->core['theme']) {
                break;
            }
            $ok = true;
            get_files_list(THEMES . "/{$theme}", false, 'fd', true, true, false, false, true, function ($item) use(&$ok) {
                if (is_writable($item)) {
                    is_dir($item) ? @rmdir($item) : @unlink($item);
                } else {
                    $ok = false;
                }
            });
            if ($ok && @rmdir(THEMES . "/{$theme}")) {
                $Index->save();
            } else {
                $Index->save(false);
            }
            break;
    }
}
$Config->reload_themes();
$themes_for_removal = array_values(array_filter(get_files_list(THEMES, '/[^CleverStyle)]/', 'd'), function ($theme) use($Config) {
    return $theme != $Config->core['theme'];
}));
$Index->file_upload = true;
$Index->content(h::{'table.cs-table-borderless.cs-left-even.cs-right-odd tr| td'}(core_select($Config->core['themes'], 'theme', 'change_theme', 'current_theme'), core_select($Config->core['color_schemes'][$Config->core['theme']], 'color_scheme', 'change_color_scheme')) . h::p(h::{'input[type=file][name=upload_theme]'}() . h::{'button[type=submit][name=action][value=upload]'}(h::icon('upload') . $L->upload_and_install_update_theme, ['formaction' => $Index->action])) . ($themes_for_removal ? h::p(h::{'select[name=remove_theme]'}($themes_for_removal) . h::{'button[type=submit][name=action][value=remove]'}(h::icon('trash-o') . $L->complete_theme_removal, ['formaction' => $Index->action])) : ''));
Example #5
0
     h::meta(array("charset" => "UTF-8"));
     h::link(array("rel" => "stylesheet", "type" => "text/css", "href" => "global.css"));
 });
 h::body(function () {
     h::div(array("id" => "wrapper"), function () {
         h::h1("Hello, World", array("class" => "title"));
         h::comment("navigation");
         h::ul(array("class" => "links"), function () {
             foreach (array(1, 2, 3) as $x) {
                 h::li(function () use($x) {
                     h::a("Link {$x}", "#{$x}");
                 });
             }
         });
         h::comment("let's see some text");
         h::p("Lorem ipsum dolor sit amet, consectetur adipisicing elit...");
         h::comment("now for a table");
         h::table(function () {
             $table_data = h::get_variable('table_data', array());
             h::tr(array("class" => "header"), function () {
                 h::th("key");
                 h::th("value");
             });
             foreach ($table_data as $k => $v) {
                 h::tr(array("class" => h::cycle(array("odd", "even"))), function () use($k, $v) {
                     h::td($k);
                     h::td($v);
                 });
             }
         });
     });
Example #6
0
     /**
      * If email is already registered
      */
 } elseif ($result == 'exists') {
     /**
      * Send merging confirmation mail
      */
     $id = $User->get_id(hash('sha224', strtolower($_POST['email'])));
     $HybridAuth_data['id'] = $id;
     $HybridAuth_data['referer'] = _getcookie('HybridAuth_referer') ?: $Config->base_url();
     _setcookie('HybridAuth_referer', '');
     $confirm_key = $Key->add($db_id, false, $HybridAuth_data, TIME + $Config->core['registration_confirmation_time'] * 86400);
     $body = $L->hybridauth_merge_confirmation_mail_body($User->username($id) ?: strstr($_POST['email'], '@', true), get_core_ml_text('name'), $L->{$rc[0]}, $Config->core_url() . '/HybridAuth/merge_confirmation/' . $confirm_key, $L->time($Config->core['registration_confirmation_time'], 'd'));
     if ($Mail->send_to($_POST['email'], $L->hybridauth_merge_confirmation_mail_title(get_core_ml_text('name')), $body)) {
         _setcookie('HybridAuth_referer', '');
         $Index->content(h::p($L->hybridauth_merge_confirmation($L->{$rc[0]})));
     } else {
         $User->registration_cancel();
         $Page->title($L->sending_reg_mail_error_title);
         $Page->warning($L->sending_reg_mail_error);
         header('Refresh: 5; url=' . $HybridAuth_data['referer']);
     }
     return;
     /**
      * Registration is successful and confirmation is not required
      */
 } elseif ($result['reg_key'] === true) {
     $User->del_session_data('HybridAuth');
     $db->{$db_id}()->q("INSERT INTO `[prefix]users_social_integration`\n\t\t\t\t\t(\n\t\t\t\t\t\t`id`,\n\t\t\t\t\t\t`provider`,\n\t\t\t\t\t\t`identifier`,\n\t\t\t\t\t\t`profile`\n\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t'%s',\n\t\t\t\t\t\t'%s',\n\t\t\t\t\t\t'%s',\n\t\t\t\t\t\t'%s'\n\t\t\t\t\t)", $result['id'], $rc[0], $HybridAuth_data['identifier'], $HybridAuth_data['profile']);
     $profile_info = $HybridAuth_data['profile_info'];
     $contacts = $HybridAuth_data['contacts'];
Example #7
0
 * @category	modules
 * @author		Nazar Mokrynskyi <*****@*****.**>
 * @copyright	Copyright (c) 2014, Nazar Mokrynskyi
 * @license		MIT License, see license.txt
 */
namespace cs;

use h;
$Group = Group::instance();
$Index = Index::instance();
$User = User::instance();
if (isset($_POST['group'], $_POST['count'])) {
    $group = $Group->get($_POST['group']);
    $count = (int) $_POST['count'];
    while ($count--) {
        for ($i = 100; $User->get_id(hash('sha224', $login = mb_strtolower($group['title']) . '_' . $i)); ++$i) {
        }
        $new_user = $User->registration("{$login}@" . DOMAIN, false, false);
        $User->set_groups([2, $group['id']], $new_user['id']);
        $Index->content(h::p("Логін: {$login} Пароль: {$new_user['password']}"));
    }
}
$groups = array_filter($Group->get_all(), function ($group) {
    return $group['id'] > 3;
});
Index::instance()->buttons = false;
$Index->content(h::{'p.cs-center'}(h::span('Група') . h::{'select[name=group]'}(['in' => array_values(array_map(function ($group) {
    return $group['description'];
}, $groups)), 'value' => array_values(array_map(function ($group) {
    return $group['id'];
}, $groups))])) . h::{'p.cs-center'}(h::span('Кількість') . h::{'input[name=count][type=number][min=1][value=1]'}()) . h::{'p.cs-center button[type=submit]'}('Додати користувачів'));
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
    }
    if (!(isset($user_data['login']) && $user_data['login'] && $user_data['login'] != $User->get('login') && (!filter_var($user_data['login'], FILTER_VALIDATE_EMAIL) && $User->get_id(hash('sha224', $user_data['login'])) === false || $user_data['login'] == $User->get('email')))) {
        if ($user_data['login'] != $User->get('login')) {
            $Page->warning($L->login_occupied_or_is_not_valid);
        }
        unset($user_data['login']);
    }
    $Index->save($User->set($user_data));
    unset($user_data);
}
$Page->title($L->my_profile);
$Page->title($L->settings);
$Index->action = path($L->profile) . '/' . path($L->settings);
switch (isset($Config->route[2]) ? $Config->route[2] : '') {
    default:
        $Index->content(h::p(h::{'a.cs-button'}($L->general, ['href' => "{$Index->action}/" . path($L->general)]) . h::{'a.cs-button'}($L->change_password, ['href' => "{$Index->action}/" . path($L->change_password)])));
        Trigger::instance()->run('System/profile/settings');
        break;
    case 'general':
        $user_data = $User->get($columns);
        unset($columns);
        $timezones = get_timezones_list();
        $row = function ($col1, $col2) {
            return h::th($col1) . h::td($col2);
        };
        $Index->form = true;
        $Index->form_atributes['class'] = 'cs-center';
        $Index->apply_button = false;
        $Index->cancel_button_back = true;
        $Page->title($L->general);
        $Index->content(h::{'p.lead.cs-center'}($L->general_settings) . h::{'table.cs-table-borderless.cs-left-even.cs-right-odd tr'}($row($L->login, h::input(['name' => 'user[login]', 'value' => $user_data['login']])), $row($L->username, h::input(['name' => 'user[username]', 'value' => $user_data['username']])), $row($L->language, h::select(['in' => array_merge([$L->system_default], $Config->core['active_languages']), 'value' => array_merge([''], $Config->core['active_languages'])], ['name' => 'user[language]', 'selected' => $user_data['language'], 'size' => 5])), $row($L->timezone, h::select(['in' => array_merge(["{$L->system_default} ({$Config->core['timezone']})"], array_keys($timezones)), 'value' => array_merge([''], array_values($timezones))], ['name' => 'user[timezone]', 'selected' => $user_data['timezone'], 'size' => 5])), $row($L->avatar, h::input(['name' => 'user[avatar]', 'value' => $user_data['avatar']]))));