Exemplo n.º 1
0
            $permission = (int) $_POST['permission'];
            $content = [];
            foreach ($users_list as $user) {
                if (in_array($user, $found_users)) {
                    continue;
                }
                $found_users[] = $user;
                $value = $User->db()->qfs(["SELECT `value`\n\t\t\t\t\tFROM `[prefix]users_permissions`\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`id`\t\t\t= '%s' AND\n\t\t\t\t\t\t`permission`\t= '%s'", $user, $permission]);
                $content[] = h::th($User->username($user)) . h::{'td input[type=radio]'}(['name' => 'users[' . $user . ']', 'checked' => $value !== false ? $value : -1, 'value' => [-1, 0, 1], 'in' => [$L->inherited . ' (' . ($value !== false && !$value ? '-' : '+') . ')', $L->deny, $L->allow]]);
            }
            $Page->content(h::{'table.cs-table-borderless.cs-center-all tr'}($content));
            break;
    }
}
if ($form) {
    $a->reset_button = false;
    $a->post_buttons .= h::{'button.cs-reload-button'}($L->reset);
    $blocks_array = ['top' => '', 'left' => '', 'floating' => '', 'right' => '', 'bottom' => ''];
    if (!empty($Config->components['blocks'])) {
        foreach ($Config->components['blocks'] as $id => $block) {
            $blocks_array[$block['position']] .= h::li(h::{'div.cs-blocks-items-title'}("#{$block['index']} " . get_block_title($id)) . h::a([h::{'div icon'}('pencil'), ['href' => "{$a->action}/edit/{$id}", 'data-title' => $L->edit]], [h::{'div icon'}('key'), ['href' => "{$a->action}/permissions/{$id}", 'data-title' => $L->edit_permissions]], [h::{'div icon'}($block['active'] ? 'minus' : 'check'), ['href' => "{$a->action}/" . ($block['active'] ? 'disable' : 'enable') . "/{$id}", 'data-title' => $L->{$block['active'] ? 'disable' : 'enable'}]], [h::{'div icon'}('trash-o'), ['href' => "{$a->action}/delete/{$id}", 'data-title' => $L->delete]]), ['id' => "block{$id}", 'class' => $block['active'] ? 'uk-button-success' : 'uk-button-default']);
            unset($block_data);
        }
        unset($id, $block);
    }
    foreach ($blocks_array as $position => &$content) {
        $content = h::{'td.cs-blocks-items-groups ul.cs-blocks-items'}(h::{'li.uk-button-primary'}($L->{"{$position}_blocks"}, ['onClick' => "cs.blocks_toggle('{$position}');"]) . $content, ['data-mode' => 'open', 'id' => "cs-{$position}-blocks-items"]);
    }
    unset($position, $content);
    $a->content(h::{'table.cs-table-borderless tr'}([h::td() . $blocks_array['top'] . h::td(), "{$blocks_array['left']}{$blocks_array['floating']}{$blocks_array['right']}", h::td() . $blocks_array['bottom'] . h::td()]) . h::{'p.cs-left a.cs-button'}("{$L->add} {$L->block}", ['href' => "admin/System/{$rc['0']}/{$rc['1']}/add"]) . h::{'input#cs-blocks-position[type=hidden][name=position]'}());
}
Exemplo n.º 2
0
function row($col1, $col2)
{
    return h::th($col1) . h::td($col2);
}
Exemplo n.º 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;
 }
Exemplo n.º 4
0
             }
         }
         unset($i, $db);
     }
     $a->action = "admin/System/{$rc['0']}/{$rc['1']}";
     /**
      * @var array $dbsname
      * @var array $dbs
      * @var array $database
      * @var string $name
      */
     $Page->title($rc[2] == 'edit' ? $L->editing_the_database($name) : $L->addition_of_db);
     $a->content(h::{'p.lead.cs-center'}($rc[2] == 'edit' ? $L->editing_the_database($name) : $L->addition_of_db) . h::{'table.cs-table.cs-center-all tr'}(\cs\modules\System\form_rows_to_cols([array_map(function ($in) {
         return h::{'th info'}($in);
     }, [$rc[2] == 'add' ? 'db_mirror' : false, 'db_host', 'db_type', 'db_prefix', 'db_name', 'db_user', 'db_password', 'db_charset']), array_map(function ($in) {
         return h::td($in);
     }, [$rc[2] == 'add' ? h::select(['in' => $dbsname, 'value' => $dbs], ['name' => 'db[mirror]', 'selected' => isset($rc[3]) ? $rc[3] : -1, 'size' => 5]) : false, h::input(['name' => 'db[host]', 'value' => $rc[2] == 'edit' ? $database['host'] : $Core->db_host]), h::select(['in' => _mb_substr(get_files_list(ENGINES . '/DB', '/^[^_].*?\\.php$/i', 'f'), 0, -4)], ['name' => 'db[type]', 'selected' => $rc[2] == 'edit' ? $database['type'] : $Core->db_type, 'size' => 5]), h::input(['name' => 'db[prefix]', 'value' => $rc[2] == 'edit' ? $database['prefix'] : $Core->db_prefix]), h::input(['name' => 'db[name]', 'value' => $rc[2] == 'edit' ? $database['name'] : '']), h::input(['name' => 'db[user]', 'value' => $rc[2] == 'edit' ? $database['user'] : '']), h::input(['name' => 'db[password]', 'value' => $rc[2] == 'edit' ? $database['password'] : '']), h::input(['name' => 'db[charset]', 'value' => $rc[2] == 'edit' ? $database['charset'] : $Core->db_charset]) . h::{'input[type=hidden]'}(['name' => 'mode', 'value' => $rc[2] == 'edit' ? 'edit' : 'add']) . (isset($rc[3]) ? h::{'input[type=hidden]'}(['name' => 'database', 'value' => $rc[3]]) : '') . (isset($rc[4]) ? h::{'input[type=hidden]'}(['name' => 'mirror', 'value' => $rc[4]]) : '')])])) . h::{'p button'}($L->test_connection, ['onMouseDown' => "cs.db_test('{$a->action}/test');"]));
     break;
 case 'delete':
     $a->buttons = false;
     $content = [];
     if (!isset($rc[4])) {
         foreach ($Config->components['modules'] as $module => &$mdata) {
             if (isset($mdata['db']) && is_array($mdata['db'])) {
                 foreach ($mdata['db'] as $db_name) {
                     if ($db_name == $rc[3]) {
                         $content[] = h::b($module);
                         break;
                     }
                 }
             }
Exemplo n.º 5
0
    });
    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);
                    });
                }
            });
        });
    });
});
Exemplo n.º 6
0
/**
 * @param array[]	$rows
 * @param int	$cols
 *
 * @return array
 */
function form_rows_to_cols($rows, $cols = 2)
{
    foreach ($rows[0] as $i => &$r) {
        $r .= $rows[1][$i];
    }
    unset($i, $r);
    $rows = $rows[0];
    $return = [];
    $row = 0;
    foreach ($rows as $i => $r) {
        if (!isset($return[$row])) {
            $return[$row] = '';
        }
        $return[$row] .= $r;
        if (++$i % $cols === 0) {
            ++$row;
        }
    }
    if (isset($i) && $i % $cols != 0) {
        $return[$row] .= str_repeat(h::th() . h::td(), $cols - $i % $cols);
    }
    return $return;
}
Exemplo n.º 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\modules\System;

use h, cs\Config, cs\Index, cs\Language;
$Config = Config::instance();
$L = Language::instance();
Index::instance()->content(h::{'table.cs-table-borderless.cs-left-even.cs-right-odd tr| td'}([[h::info('smtp'), h::{'input[type=radio]'}(['name' => 'core[smtp]', 'checked' => $Config->core['smtp'], 'value' => [0, 1], 'in' => [$L->off, $L->on], 'OnClick' => ["\$('#smtp_form').parent().parent().hide();", "\$('#smtp_form').parent().parent().show();"]])], [['', h::{'table#smtp_form tr'}(h::td(core_input('smtp_host')), h::td(core_input('smtp_port')), h::td([h::info('smtp_secure'), h::{'input[type=radio]'}(['name' => 'core[smtp_secure]', 'checked' => $Config->core['smtp_secure'], 'value' => ['', 'ssl', 'tls'], 'in' => [$L->off, 'SSL', 'TLS']])]), h::td([$L->smtp_auth, h::{'input[type=radio]'}(['name' => 'core[smtp_auth]', 'checked' => $Config->core['smtp_auth'], 'value' => [0, 1], 'in' => [$L->off, $L->on], 'OnClick' => ["\$('#smtp_user, #smtp_password').hide();", "\$('#smtp_user, #smtp_password').show();"]])]), [h::td(core_input('smtp_user')), ['style' => (!$Config->core['smtp_auth'] ? 'display: none;' : '') . ' padding-left: 20px;', 'id' => 'smtp_user']], [h::td(core_input('smtp_password')), ['style' => !$Config->core['smtp_auth'] ? 'display: none;' : '', 'id' => 'smtp_password']])], ['style' => !$Config->core['smtp'] ? 'display: none; ' : '']], core_input('mail_from'), core_input('mail_from_name'), core_textarea('mail_signature', 'SIMPLE_EDITOR')]));
Exemplo n.º 8
0
<?php

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

use h, cs\Config, cs\Index, cs\Language\Prefix, cs\Page;
$Index = Index::instance();
$L = new Prefix('oauth2_');
Page::instance()->title($L->list_of_client);
$Index->apply_button = false;
$module_data = Config::instance()->module('OAuth2');
$Index->content(h::{'p.lead.cs-center'}($L->list_of_clients) . h::{'table.cs-table.cs-center-all'}(h::{'thead tr th'}([$L->client_name, 'client_id', 'client_secret', $L->action]) . h::{'tbody tr'}(array_map(function ($client) use($L) {
    return h::td([$client['name'], h::{'input{disabled]'}($client['id']), h::{'input{disabled]'}($client['secret']), h::{'a.cs-button-compact'}([h::icon('pencil'), ['href' => "admin/OAuth2/clients/edit/{$client['id']}", 'data-title' => $L->edit]]) . h::{'a.cs-button-compact'}([h::icon('trash-o'), ['href' => "admin/OAuth2/clients/delete/{$client['id']}", 'data-title' => $L->delete]])], ['class' => $client['active'] ? false : 'text-muted']);
}, OAuth2::instance()->clients_list()))) . h::{'table.cs-table-borderless.cs-left-even.cs-right-odd.uk-margin-top tr| td'}([h::info('oauth2_allow_guest_tokens'), h::{'input[type=radio]'}(['name' => 'general[guest_tokens]', 'checked' => $module_data->guest_tokens, 'value' => [0, 1], 'in' => [$L->no, $L->yes]])], [h::info('oauth2_automatic_prolongation'), h::{'input[type=radio]'}(['name' => 'general[automatic_prolongation]', 'checked' => $module_data->automatic_prolongation, 'value' => [0, 1], 'in' => [$L->no, $L->yes]])], [h::info('oauth2_expiration'), h::{'input[type=number]'}(['name' => 'general[expiration]', 'value' => $module_data->expiration, 'min' => 1]) . $L->seconds]) . h::{'p.cs-left a.cs-button'}([$L->add_client, ['href' => 'admin/OAuth2/clients/add']]));
Exemplo n.º 9
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;

use h;
$Config = Config::instance();
$L = Language::instance();
Index::instance()->content(h::{'table.cs-table-borderless.cs-left-even.cs-right-odd tr'}([h::td([h::info('key_expire'), h::{'input[type=number]'}(['name' => 'core[key_expire]', 'value' => $Config->core['key_expire'], 'min' => 1]) . $L->seconds]), h::td([h::info('ip_black_list'), h::textarea($Config->core['ip_black_list'], ['name' => 'core[ip_black_list]'])]), h::td([h::info('ip_admin_list_only'), h::{'input[type=radio]'}(['name' => 'core[ip_admin_list_only]', 'checked' => $Config->core['ip_admin_list_only'], 'value' => [0, 1], 'in' => [$L->off, $L->on]])]), h::td([h::info('ip_admin_list'), h::textarea($Config->core['ip_admin_list'], ['name' => 'core[ip_admin_list]']) . h::br() . $L->current_ip . ': ' . h::b(User::instance()->ip)])]));
Exemplo n.º 10
0
$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']]))));
        break;
    case 'change_password':
        $Index->form = true;
        $Index->form_atributes['class'] = 'cs-center';
        $Index->buttons = false;
        $Index->cancel_button_back = true;
        $Page->title($L->password_changing);
        $Index->content(h::{'p.lead.cs-center'}($L->password_changing) . h::{'table.cs-table-borderless.cs-left-even.cs-right-odd tr'}(h::th("{$L->current_password} " . h::{'icon#current_password.cs-pointer'}('lock')) . h::td(h::{'input.cs-profile-current-password[type=password]'}()), h::th("{$L->new_password} " . h::{'icon#new_password.cs-pointer'}('lock')) . h::td(h::{'input.cs-profile-new-password[type=password]'}())) . h::{'button.cs-profile-change-password'}($L->change_password));
        break;
}