예제 #1
0
function applet_config()
{
    // получаем оригинальный конфиг
    $config = cmsConfig::getDefaultConfig();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/config', $adminAccess)) {
        cpAccessDenied();
    }
    cmsCore::c('page')->setTitle($_LANG['AD_SITE_SETTING']);
    cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config');
    $do = cmsCore::request('do', 'str', 'list');
    if ($do == 'save') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $newCFG = cmsCore::getArrayFromRequest(array('scheme' => array('scheme', array('http', 'https'), ''), 'sitename' => array('sitename', 'str', ''), 'title_and_sitename' => array('title_and_sitename', 'int', 0), 'title_and_page' => array('title_and_page', 'int', 0), 'hometitle' => array('hometitle', 'str', ''), 'homecom' => array('homecom', 'str', ''), 'com_without_name_in_url' => array('com_without_name_in_url', 'str', ''), 'siteoff' => array('siteoff', 'int', 0), 'only_authorized' => array('only_authorized', 'int', 0), 'debug' => array('debug', 'int', 0), 'offtext' => array('offtext', 'str', ''), 'keywords' => array('keywords', 'str', ''), 'metadesc' => array('metadesc', 'str', ''), 'seourl' => array('seourl', 'int', 0), 'lang' => array('lang', 'str', 'ru'), 'is_change_lang' => array('is_change_lang', 'int', 0), 'sitemail' => array('sitemail', 'str', ''), 'sitemail_name' => array('sitemail_name', 'str', ''), 'wmark' => array('wmark', 'str', ''), 'template' => array('template', 'str', ''), 'admin_template' => array('admin_template', 'str', ''), 'cache' => array('cache', 'int', 0), 'cache_type' => array('cache_type', array('file', 'memcached'), ''), 'memcached_host' => array('memcached_host', 'str', ''), 'memcached_port' => array('memcached_port', 'int', 0), 'combine_css_enable' => array('combine_css_enable', 'int', 0), 'combine_css' => array('combine_css', 'html', ''), 'combine_js_enable' => array('combine_js_enable', 'int', 0), 'combine_js' => array('combine_js', 'html', ''), 'splash' => array('splash', 'int', 0), 'slight' => array('slight', 'int', 0), 'show_pw' => array('show_pw', 'int', 0), 'last_item_pw' => array('last_item_pw', 'int', 0), 'index_pw' => array('index_pw', 'int', 0), 'fastcfg' => array('fastcfg', 'int', 0), 'mailer' => array('mailer', 'str', ''), 'smtpsecure' => array('smtpsecure', 'str', ''), 'smtpauth' => array('smtpauth', 'int', 0), 'smtpuser' => array('smtpuser', 'str', $config['smtpuser']), 'smtppass' => array('smtppass', 'str', $config['smtppass']), 'smtphost' => array('smtphost', 'str', ''), 'smtpport' => array('smtpport', 'int', '25'), 'timezone' => array('timezone', 'str', $config['timezone']), 'user_stats' => array('user_stats', 'int', 0), 'seo_url_count' => array('seo_url_count', 'int', 0), 'max_pagebar_links' => array('max_pagebar_links', 'int', 0), 'allow_ip' => array('allow_ip', 'str', ''), 'iframe_enable' => array('iframe_enable', 'int', 0), 'vk_enable' => array('vk_enable', 'int', 0), 'vk_id' => array('vk_id', 'str', ''), 'vk_private_key' => array('vk_private_key', 'str', '')));
        $newCFG['sitename'] = stripslashes($newCFG['sitename']);
        $newCFG['hometitle'] = stripslashes($newCFG['hometitle']);
        $newCFG['offtext'] = htmlspecialchars($newCFG['offtext'], ENT_QUOTES);
        $newCFG['db_host'] = $config['db_host'];
        $newCFG['db_base'] = $config['db_base'];
        $newCFG['db_user'] = $config['db_user'];
        $newCFG['db_pass'] = $config['db_pass'];
        $newCFG['db_prefix'] = $config['db_prefix'];
        if (cmsConfig::saveToFile($newCFG)) {
            cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success');
        } else {
            cmsCore::addSessionMessage($_LANG['AD_CONFIG_SITE_ERROR'], 'error');
        }
        cmsCore::clearCache();
        cmsCore::redirect('index.php?view=config');
    }
    cpCheckWritable('/includes/config/config.inc.json');
    $result = cmsCore::c('db')->query("SELECT (sum(data_length)+sum(index_length))/1024/1024 as size FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '" . $config['db_base'] . "'", true);
    if (!cmsCore::c('db')->error()) {
        $s = cmsCore::c('db')->fetch_assoc($result);
    } else {
        $s['size'] = 0;
    }
    cmsCore::c('page')->initTemplate('applets', 'config')->assign('config', $config)->assign('timezone_opt', cmsCore::getTimeZonesOptions($config['timezone']))->assign('admin_templates', cmsCore::getDirsList('/templates/admin'))->assign('templates', cmsCore::getDirsList('/templates'))->assign('tpl_info', cmsCore::c('page')->getTplInfo(cmsCore::c('page')->template))->assign('components_opt', cmsCore::getListItems('cms_components', $config['com_without_name_in_url'], 'title', 'ASC', 'internal=0', 'link'))->assign('homecom_opt', cmsCore::getListItems('cms_components', $config['homecom'], 'title', 'ASC', 'internal=0', 'link'))->assign('langs', cmsCore::getDirsList('/languages'))->assign('db_size', round($s['size'], 2))->display();
}
예제 #2
0
function applet_userbanlist()
{
    $inCore = cmsCore::getInstance();
    $inDB = cmsDatabase::getInstance();
    $inUser = cmsUser::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/users', $adminAccess)) {
        cpAccessDenied();
    }
    $GLOBALS['cp_page_title'] = $_LANG['AD_BANLIST'];
    cpAddPathway($_LANG['AD_USERS'], 'index.php?view=users');
    cpAddPathway($_LANG['AD_BANLIST'], 'index.php?view=userbanlist');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    $to = cmsCore::request('to', 'int', 0);
    // для редиректа обратно в профиль на сайт
    if ($to) {
        cmsUser::sessionPut('back_url', cmsCore::getBackURL());
    }
    if ($do == 'list') {
        $toolmenu[] = array('icon' => 'useradd.gif', 'title' => $_LANG['AD_TO_BANLIST_ADD'], 'link' => '?view=userbanlist&do=add');
        $toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=userbanlist&do=edit&multiple=1');");
        $toolmenu[] = array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=userbanlist&do=delete&multiple=1');");
        cpToolMenu($toolmenu);
        $fields[] = array('title' => 'id', 'field' => 'id', 'width' => '30');
        $fields[] = array('title' => $_LANG['AD_IS_ACTIVE'], 'field' => 'status', 'width' => '55', 'prc' => 'cpYesNo');
        $fields[] = array('title' => $_LANG['AD_BANLIST_USER'], 'field' => 'user_id', 'width' => '120', 'filter' => '12', 'prc' => 'cpUserNick');
        $fields[] = array('title' => $_LANG['AD_BANLIST_IP'], 'field' => 'ip', 'width' => '100', 'link' => '?view=userbanlist&do=edit&id=%id%', 'filter' => '12');
        $fields[] = array('title' => $_LANG['DATE'], 'field' => 'bandate', 'width' => '', 'fdate' => '%d/%m/%Y %H:%i:%s', 'filter' => '12');
        $fields[] = array('title' => $_LANG['AD_BANLIST_TIME'], 'field' => 'int_num', 'width' => '55');
        $fields[] = array('title' => '', 'field' => 'int_period', 'width' => '70');
        $fields[] = array('title' => $_LANG['AD_AUTOREMOVE'], 'field' => 'autodelete', 'width' => '90', 'prc' => 'cpYesNo');
        $actions[] = array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=userbanlist&do=edit&id=%id%');
        $actions[] = array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_REMOVE_RULE'], 'link' => '?view=userbanlist&do=delete&id=%id%');
        cpListTable('cms_banlist', $fields, $actions, '1=1', 'ip DESC');
    }
    if ($do == 'delete') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbDelete('cms_banlist', $id);
            }
        } else {
            dbDeleteList('cms_banlist', cmsCore::request('item', 'array_int', array()));
        }
        cmsCore::redirect('?view=userbanlist');
    }
    if ($do == 'submit' || $do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $types = array('user_id' => array('user_id', 'int', 0), 'ip' => array('ip', 'str', ''), 'cause' => array('cause', 'str', ''), 'autodelete' => array('autodelete', 'int', 0), 'int_num' => array('int_num', 'int', 0), 'int_period' => array('int_period', 'str', '', create_function('$p', 'if(!in_array($p, array("MONTH","DAY","HOUR","MINUTE"))){ $p = "MINUTE"; } return $p;')));
        $items = cmsCore::getArrayFromRequest($types);
        $error = false;
        if (!$items['ip']) {
            $error = true;
            cmsCore::addSessionMessage($_LANG['AD_NEED_IP'], 'error');
        }
        if ($items['ip'] == $_SERVER['REMOTE_ADDR'] || $items['user_id'] == $inUser->id) {
            $error = true;
            cmsCore::addSessionMessage($_LANG['AD_ITS_YOUR_IP'], 'error');
        }
        if (cmsUser::userIsAdmin($items['user_id'])) {
            $error = true;
            cmsCore::addSessionMessage($_LANG['AD_ITS_ADMIN'], 'error');
        }
        if ($error) {
            cmsCore::redirectBack();
        }
        if ($do == 'update') {
            $inDB->update('cms_banlist', $items, $id);
            if (empty($_SESSION['editlist'])) {
                cmsCore::redirect('?view=userbanlist');
            } else {
                cmsCore::redirect('?view=userbanlist&do=edit');
            }
        }
        $inDB->insert('cms_banlist', $items);
        $back_url = cmsUser::sessionGet('back_url');
        cmsUser::sessionDel('back_url');
        cmsCore::redirect($back_url ? $back_url : '?view=userbanlist');
    }
    if ($do == 'add' || $do == 'edit') {
        $GLOBALS['cp_page_head'][] = '<script language="JavaScript" type="text/javascript" src="/admin/js/banlist.js"></script>';
        $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();');
        $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);');
        cpToolMenu($toolmenu);
        if ($do == 'add') {
            echo '<h3>' . $_LANG['AD_TO_BANLIST_ADD'] . '</h3>';
            cpAddPathway($_LANG['AD_TO_BANLIST_ADD']);
        } else {
            if (isset($_REQUEST['multiple'])) {
                if (isset($_REQUEST['item'])) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (sizeof($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }
            $mod = $inDB->get_fields('cms_banlist', "id = '{$item_id}'", '*');
            if (!$mod) {
                cmsCore::error404();
            }
            echo '<h3>' . $_LANG['AD_EDIT_RULE'] . ' ' . $ostatok . '</h3>';
            cpAddPathway($_LANG['AD_EDIT_RULE']);
        }
        ?>
	  <div style="margin-top:2px;padding:10px;border:dotted 1px silver; width:508px;background:#FFFFCC">
	  	<div style="font-weight:bold"><?php 
        echo $_LANG['ATTENTION'];
        ?>
!</div>
		<div><?php 
        echo $_LANG['AD_CAUTION_INFO_0'];
        ?>
</div>
		<div><?php 
        echo $_LANG['AD_CAUTION_INFO_1'];
        ?>
</div>
	  </div>
      <form id="addform" name="addform" method="post" action="index.php?view=userbanlist">
        <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
        <table width="530" border="0" cellspacing="5" class="proptable">
          <tr>
            <td width="150" valign="top"><div><strong><?php 
        echo $_LANG['AD_BANLIST_USER'];
        ?>
: </strong></div></td>
			<?php 
        if ($do == 'add' && $to) {
            $mod['user_id'] = $to;
            $mod['ip'] = $inDB->get_field('cms_users', 'id=' . $to, 'last_ip');
        }
        ?>
            <td valign="top">
				<select name="user_id" id="user_id" onchange="loadUserIp()" style="width: 250px;">
                    <option value="0" <?php 
        if (@(!$mod['user_id'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_WHITHOUT_USER'];
        ?>
</option>
                    <?php 
        if (isset($mod['user_id'])) {
            echo $inCore->getListItems('cms_users', $mod['user_id'], 'nickname', 'ASC', 'is_deleted=0 AND is_locked=0', 'id', 'nickname');
        } else {
            echo $inCore->getListItems('cms_users', 0, 'nickname', 'ASC', 'is_deleted=0 AND is_locked=0', 'id', 'nickname');
        }
        ?>
				</select>
            </td>
          </tr>
          <tr>
            <td valign="top"><strong><?php 
        echo $_LANG['AD_BANLIST_IP'];
        ?>
:</strong></td>
            <td valign="top"><input name="ip" type="text" id="ip" style="width: 244px;" value="<?php 
        echo @$mod['ip'];
        ?>
"/></td>
          </tr>
          <tr>
            <td valign="top"><strong><?php 
        echo $_LANG['AD_BANLIST_CAUSE'];
        ?>
:</strong></td>
            <td valign="top">
                <textarea name="cause" style="width:240px" rows="5"><?php 
        echo @$mod['cause'];
        ?>
</textarea>
            </td>
          </tr>
		  <?php 
        $forever = false;
        if (!@$mod['int_num']) {
            $forever = true;
        }
        ?>
          <tr>
            <td valign="top"><strong><?php 
        echo $_LANG['AD_BAN_FOREVER'];
        ?>
</strong></td>
            <td valign="top"><input type="checkbox" name="forever" value="1" <?php 
        if ($forever) {
            echo 'checked="checked"';
        }
        ?>
 onclick="$('tr.bantime').toggle();"/></td>
          </tr>
          <tr class="bantime">
            <td valign="top"><strong><?php 
        echo $_LANG['AD_BAN_FOR_TIME'];
        ?>
</strong> </td>

            <td valign="top"><p>
            <input name="int_num" type="text" id="int_num" size="5" value="<?php 
        echo @(int) $mod['int_num'];
        ?>
"/>
              <select name="int_period" id="int_period">
                <option value="MINUTE"  <?php 
        if (@mb_strstr($mod['int_period'], 'MINUTE')) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['MINUTE10'];
        ?>
</option>]
                <option value="HOUR"  <?php 
        if (@mb_strstr($mod['int_period'], 'HOUR')) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['HOUR10'];
        ?>
</option>
                <option value="DAY" <?php 
        if (@mb_strstr($mod['int_period'], 'DAY')) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['DAY10'];
        ?>
</option>
                <option value="MONTH" <?php 
        if (@mb_strstr($mod['int_period'], 'MONTH')) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['MONTH10'];
        ?>
</option>
              </select>
            </p>
            <p><label><input name="autodelete" type="checkbox" id="autodelete" value="1" <?php 
        if ($mod['autodelete']) {
            echo 'checked="checked"';
        }
        ?>
 /> <?php 
        echo $_LANG['AD_REMOVE_BAN'];
        ?>
</label></p>
            </td>
          </tr>
		  <?php 
        if ($forever) {
            ?>
<script type="text/javascript">$('tr.bantime').hide();</script><?php 
        }
        ?>
        </table>
        <p>
          <label>
          <input name="add_mod" type="submit" id="add_mod" <?php 
        if ($do == 'add') {
            echo 'value="' . $_LANG['AD_TO_BANLIST_ADD'] . '"';
        } else {
            echo 'value="' . $_LANG['SAVE'] . '"';
        }
        ?>
 />
          </label>
          <label><span style="margin-top:15px">
          <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.history.back();"/>
          </span></label>
          <input name="do" type="hidden" id="do" <?php 
        if ($do == 'add') {
            echo 'value="submit"';
        } else {
            echo 'value="update"';
        }
        ?>
 />
          <?php 
        if ($do == 'edit') {
            echo '<input name="id" type="hidden" value="' . $mod['id'] . '" />';
        }
        ?>
        </p>
      </form>
	<?php 
    }
}
예제 #3
0
파일: users.php 프로젝트: Acsac/CMS-RuDi
function applet_users() {
    $inCore = cmsCore::getInstance();
    cmsCore::loadClass('actions');
    cmsCore::loadModel('users');
    $model = new cms_model_users();

    // подключаем язык компонента регистрации
    cmsCore::loadLanguage('components/registration');

    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/users', $adminAccess)) { cpAccessDenied(); }

    cmsCore::c('page')->setTitle($_LANG['AD_USERS']);
    cpAddPathway($_LANG['AD_USERS'], 'index.php?view=users');

    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', 0);

    if ($do == 'list') {
        $toolmenu = array(
            array( 'icon' => 'useradd.gif', 'title' => $_LANG['AD_USER_ADD'], 'link' => '?view=users&do=add' ),
            array( 'icon' => 'useredit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=users&do=edit&multiple=1');" ),
            array( 'icon' => 'userdelete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:if(confirm('". $_LANG['AD_IF_USERS_SELECT_REMOVE'] ."')) { checkSel('?view=users&do=delete&multiple=1'); }" ),
            array( 'icon' => 'usergroup.gif', 'title' => $_LANG['AD_USERS_GROUP'], 'link' => '?view=usergroups' ),
            array( 'icon' => 'userbanlist.gif', 'title' => $_LANG['AD_BANLIST'], 'link' => '?view=userbanlist' ),
            array( 'icon' => 'user_go.png', 'title' => $_LANG['AD_USERS_SELECT_ACTIVATE'], 'link' => "javascript:if(confirm('". $_LANG['AD_IF_USERS_SELECT_ACTIVATE'] ."')) { checkSel('?view=users&do=activate&multiple=1'); }" ),
            array( 'icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=users' )
        );
        
        cpToolMenu($toolmenu);
        
        $fields = array(
            array( 'title' => 'id', 'field' => 'id', 'width' => '40'  ),
            array( 'title' => $_LANG['LOGIN'], 'field' => 'login', 'width' => '100', 'link' => '?view=users&do=edit&id=%id%', 'filter' => 12 ),
            array( 'title' => $_LANG['NICKNAME'], 'field' => 'nickname', 'width' => '', 'link' => '?view=users&do=edit&id=%id%', 'filter' => 12 ),
            array( 'title' => $_LANG['AD_RATING'], 'field' => array( 'rating', 'id' ), 'width' => '70', 'prc' => 'setRating' ),
            array( 'title' => $_LANG['AD_GROUP'], 'field' => 'group_id', 'width' => '110', 'prc' => 'cpGroupById', 'filter' => 1, 'filterlist' => cpGetList('cms_user_groups') ),
            array( 'title' => $_LANG['EMAIL'], 'field' => 'email', 'width' => '120' ),
            array( 'title' => $_LANG['AD_REGISTRATION_DATE'], 'field' => 'regdate', 'width' => '100' ),
            array( 'title' => $_LANG['AD_LAST_LOGIN'], 'field' => 'logdate', 'width' => '100' ),
            array( 'title' => $_LANG['AD_LAST_IP'], 'field' => 'last_ip', 'width' => '90', 'prc' => 'getIpLink' ),
            array( 'title' => $_LANG['AD_IS_LOCKED'], 'field' => 'is_locked', 'width' => '110', 'prc' => 'viewAct' ),
            array( 'title' => $_LANG['AD_IS_DELETED'], 'field' => 'is_deleted', 'width' => '80', 'prc' => 'viewDel' )
        );
        
        $actions = array(
            array( 'title' => $_LANG['AD_PROFILE'], 'icon' => 'profile.gif', 'link' => '/users/%login%' ),
            array( 'title' => $_LANG['AD_BANNED'], 'icon' => 'ban.gif', 'link' => '?view=userbanlist&do=add&to=%id%' ),
            array( 'title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_IS_USER_DELETE'], 'link' => '?view=users&do=delete&id=%id%' ),
            array( 'title' => $_LANG['AD_FOREVER_USER_DELETE'], 'icon' => 'off.gif', 'confirm' => $_LANG['AD_IF_FOREVER_USER_DELETE'], 'link' => '?view=users&do=delete_full&id=%id%' )
        );
        
        cpListTable('cms_users', $fields, $actions, '1=1', 'regdate DESC');
    }
    
    if ($do == 'rerating') {
        $user_id = cmsCore::request('user_id', 'int');
        if (!$user_id) { cmsCore::redirectBack(); }
        
        $rating = cmsUser::getRating($user_id);

        $user_sql = "UPDATE cms_users
                     SET rating = ". $rating ."
                     WHERE id = '". $user_id ."'";

        cmsCore::c('db')->query($user_sql);
        
        cmsCore::redirectBack();
    }
    
    if ($do == 'activate') {
        $user_ids = cmsCore::request('item', 'array_int');
        if (!$user_ids) { cmsCore::redirectBack(); }

        foreach ($user_ids as $user_id) {
            $code = cmsCore::c('db')->get_field('cms_users_activate', "user_id = '". $user_id ."'", 'code');

            $sql = "UPDATE cms_users SET is_locked = 0 WHERE id = '". $user_id ."'";
            cmsCore::c('db')->query($sql);

            $sql = "DELETE FROM cms_users_activate WHERE code = '". $code ."'";
            cmsCore::c('db')->query($sql);

            cmsCore::callEvent('USER_ACTIVATED', $user_id);

            // Регистрируем событие
            cmsActions::log(
                'add_user',
                array(
                    'object' => '',
                    'user_id' => $user_id,
                    'object_url' => '',
                    'object_id' => $user_id,
                    'target' => '',
                    'target_url' => '',
                    'target_id' => 0,
                    'description' => ''
                )
            );
        }
        
        cmsCore::redirectBack();
    }
    
    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) {
                $model->deleteUser($id);
            }
        } else {
            $model->deleteUsers(cmsCore::request('item', 'array_int', array()));
        }
        
        cmsCore::redirectBack();
    }

    if ($do == 'delete_full') {
        $model->deleteUser($id, true);
        cmsCore::redirectBack();
    }

    if ($do == 'submit' || $do == 'update') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }

        $types = array(
            'login' => array( 'login', 'str', '' ),
            'nickname' => array( 'nickname', 'str', '', 'htmlspecialchars' ),
            'email' => array( 'email', 'email', '' ),
            'group_id' => array( 'group_id', 'int', 1 ),
            'is_locked' => array( 'is_locked', 'int', 0 ),
            'password' => array( 'pass', 'str', '', 'stripslashes' ),
            'pass2' => array( 'pass2', 'str', '', 'stripslashes' )
        );

        $items = cmsCore::getArrayFromRequest($types);

        $errors = false;

        // проверяем логин
        if (mb_strlen($items['login']) < 2 ||
                mb_strlen($items['login']) > 15 ||
                is_numeric($items['login']) ||
                !preg_match("/^([a-zA-Z0-9])+$/ui", $items['login'])) {
            cmsCore::addSessionMessage($_LANG['ERR_LOGIN'], 'error');
            $errors = true;
        }

        // проверяем пароль
        if ($do == 'submit') {
            if (!$items['password']) {
                cmsCore::addSessionMessage($_LANG['TYPE_PASS'], 'error');
                $errors = true;
            }
        }
        
        if ($items['password'] && !$items['pass2']) {
            cmsCore::addSessionMessage($_LANG['TYPE_PASS_TWICE'], 'error');
            $errors = true;
        }
        
        if ($items['password'] && $items['pass2'] && mb_strlen($items['password']) < 6) {
            cmsCore::addSessionMessage($_LANG['PASS_SHORT'], 'error');
            $errors = true;
        }
        
        if ($items['password'] && $items['pass2'] && $items['password'] != $items['pass2']) {
            cmsCore::addSessionMessage($_LANG['WRONG_PASS'], 'error');
            $errors = true;
        }

        // никнейм
        if (mb_strlen($items['nickname']) < 2) {
            cmsCore::addSessionMessage($_LANG['SHORT_NICKNAME'], 'error');
            $errors = true;
        }
        
        // Проверяем email
        if (!$items['email']) {
            cmsCore::addSessionMessage($_LANG['ERR_EMAIL'], 'error');
            $errors = true;
        }

        // проверяем есть ли такой пользователь
        if ($do == 'submit') {
            $user_exist = cmsCore::c('db')->get_fields('cms_users', "(login LIKE '". $items['login'] ."' OR email LIKE '". $items['email'] ."') AND is_deleted = 0", 'login');
            if ($user_exist) {
                if ($user_exist['login'] == $items['login']) {
                    cmsCore::addSessionMessage($_LANG['LOGIN'] .' "'. $items['login'] .'" '. $_LANG['IS_BUSY'], 'error');
                    $errors = true;
                } else {
                    cmsCore::addSessionMessage($_LANG['EMAIL_IS_BUSY'], 'error');
                    $errors = true;
                }
            }
        }

        if ($errors) {
            if ($do == 'submit') {
                cmsUser::sessionPut('items', $items);
            }
            cmsCore::redirectBack();
        }

        if ($do == 'submit') {
            $items['regdate']  = date('Y-m-d H:i:s');
            $items['logdate']  = date('Y-m-d H:i:s');
            $items['password'] = md5($items['password']);

            $items['user_id'] = cmsCore::c('db')->insert('cms_users', $items);
            if (!$items['user_id']) { cmsCore::error404(); }

            cmsCore::c('db')->insert('cms_user_profiles', $items);

            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            cmsCore::redirect('?view=users');
        } else {
            // главного админа может редактировать только он сам
            if ($id == 1 && cmsCore::c('user')->id != $id) {
                cmsCore::error404();
            }
            
            if ($id == 1) {
                unset($items['group_id']);
                unset($items['is_locked']);
            }

            if (!$items['password']) {
                unset($items['password']);
            } else {
                $items['password'] = md5($items['password']);
            }

            cmsCore::c('db')->update('cms_users', $items, $id);

            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            if (empty($_SESSION['editlist'])) {
                cmsCore::redirect('index.php?view=users');
            } else {
                cmsCore::redirect('index.php?view=users&do=edit');
            }
        }
    }

    if ($do == 'edit' || $do == 'add') {
        $toolmenu = array(
            array( 'icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();' ),
            array( 'icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);' )
        );

        cpToolMenu($toolmenu);

        if ($do == 'edit') {
            if (cmsCore::inRequest('multiple')){
                if (cmsCore::inRequest('item')){
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }

            $ostatok = '';

            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (count($_SESSION['editlist']) == 0) {
                   unset($_SESSION['editlist']);
                } else {
                    $ostatok = '('. $_LANG['AD_NEXT_IN'] . count($_SESSION['editlist']) .')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }

            $mod = cmsCore::c('db')->get_fields('cms_users', "id = '". $item_id ."'", '*');
            if (!$mod) { cmsCore::error404(); }

            echo '<h3>'. $_LANG['AD_USER_EDIT'] .' '. $ostatok .'</h3>';
            cpAddPathway($mod['nickname']);

        } else {
            $mod = cmsUser::sessionGet('items');
            if ($mod) { cmsUser::sessionDel('items'); }
            cpAddPathway($_LANG['AD_USER_ADD']);
        }
        
        cmsCore::c('page')->addHeadJS('components/registration/js/check.js');
?>
<form action="index.php?view=users" method="post" enctype="multipart/form-data" name="addform" id="addform">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
    
    <div style="width:500px;">
        <div class="form-group">
            <label><?php echo $_LANG['LOGIN']; ?>:</label>
            <input type="text" id="logininput" class="form-control" name="login" value="<?php echo cmsCore::getArrVal($mod, 'login', ''); ?>" onchange="checkLogin()" />
            <?php if ($do == 'edit') { echo '<div class="help-block" style="text-align:right;"><a target="_blank" href="/users/'. $mod['login'] .'" title="'. $_LANG['AD_USER_PROFILE'] .'">'. $_LANG['AD_USER_PROFILE'] .'</a></div>'; } ?>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['NICKNAME']; ?>:</label>
            <input type="text" id="login" class="form-control" name="nickname" value="<?php echo htmlspecialchars(cmsCore::getArrVal($mod, 'nickname', '')); ?>" />
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['EMAIL']; ?>:</label>
            <input type="text" id="nickname" class="form-control" name="email" value="<?php echo cmsCore::getArrVal($mod, 'email', ''); ?>" />
        </div>
        
        <div class="form-group">
            <label><?php if ($do == 'edit') { echo $_LANG['AD_NEW_PASS']; } else { echo $_LANG['PASS']; } ?></label>
            <input type="password" id="pass" class="form-control" name="pass" />
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['REPEAT_PASS']; ?>:</label>
            <input type="password" id="pass2" class="form-control" name="pass2" />
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_GROUP']; ?>:</label>
            <select id="group_id" class="form-control" name="group_id">
                <?php
                    echo $inCore->getListItems('cms_user_groups', cmsCore::getArrVal($mod, 'group_id', 0));
                ?>
            </select>
            <?php if ($do == 'edit') { echo '<div class="help-block" style="text-align:right;"><a target="_blank" href="?view=usergroups&do=edit&id='. $mod['group_id'] .'">'. $_LANG['EDIT'] .'</a></div>'; } ?>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_IF_ACCAUNT_LOCK']; ?></label>
            <div class="btn-group" data-toggle="buttons" style="float:right;">
                <label class="btn btn-default <?php if ($mod['is_locked']) { echo 'active'; } ?>">
                    <input type="radio" name="is_locked" <?php if ($mod['is_locked']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                </label>
                <label class="btn btn-default <?php if (!$mod['is_locked']) { echo 'active'; } ?>">
                    <input type="radio" name="is_locked" <?php if (!$mod['is_locked']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                </label>
            </div>
        </div>
    </div>

    <div>
        <?php if ($do == 'edit') { ?>
            <input type="hidden" name="do" value="update" />
            <input type="submit" class="btn btn-primary" name="add_mod" value="<?php echo $_LANG['SAVE']; ?>" />
        <?php } else { ?>
            <input type="hidden" name="do" value="submit" />
            <input type="submit" class="btn btn-primary" name="add_mod" value="<?php echo $_LANG['AD_USER_ADD']; ?>" />
        <?php } ?>
        <input type="button" class="btn btn-default" name="back2" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.history.back();" />

        <?php
            if ($do == 'edit') {
                echo '<input type="hidden" name="id" value="'. $mod['id'] .'" />';
            }
        ?>
    </div>
</form>
<?php
   }
}
예제 #4
0
function applet_usergroups()
{
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/users', $adminAccess)) {
        cpAccessDenied();
    }
    $GLOBALS['cp_page_title'] = $_LANG['AD_USERS_GROUP'];
    cpAddPathway($_LANG['AD_USERS'], 'index.php?view=users');
    cpAddPathway($_LANG['AD_USERS_GROUP'], 'index.php?view=usergroups');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    cmsCore::loadModel('users');
    $model = new cms_model_users();
    if ($do == 'list') {
        $toolmenu[] = array('icon' => 'usergroupadd.gif', 'title' => $_LANG['AD_CREATE_GROUP'], 'link' => '?view=usergroups&do=add');
        $toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=usergroups&do=edit&multiple=1');");
        $toolmenu[] = array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:if(confirm('{$_LANG['AD_REMOVE_GROUP']}')) { checkSel('?view=users&do=delete&multiple=1'); }");
        cpToolMenu($toolmenu);
        $fields[] = array('title' => 'id', 'field' => 'id', 'width' => '30');
        $fields[] = array('title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '', 'link' => '?view=usergroups&do=edit&id=%id%', 'filter' => '12');
        $fields[] = array('title' => $_LANG['AD_FROM_USERS'], 'field' => 'id', 'width' => '100', 'prc' => 'getCountUsers');
        $fields[] = array('title' => $_LANG['AD_IF_ADMIN'], 'field' => 'is_admin', 'width' => '110', 'prc' => 'cpYesNo');
        $fields[] = array('title' => $_LANG['AD_ALIAS'], 'field' => 'alias', 'width' => '75', 'filter' => '12');
        $actions[] = array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=usergroups&do=edit&id=%id%');
        $actions[] = array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_REMOVE_GROUP'], 'link' => '?view=usergroups&do=delete&id=%id%');
        cpListTable('cms_user_groups', $fields, $actions);
    }
    if ($do == 'delete') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                $model->deleteGroup($id);
            }
        } else {
            $model->deleteGroups(cmsCore::request('item', 'array_int', array()));
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirect('index.php?view=usergroups');
    }
    if ($do == 'submit' || $do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $types = array('title' => array('title', 'str', ''), 'alias' => array('alias', 'str', ''), 'is_admin' => array('is_admin', 'int', 0), 'access' => array('access', 'array_str', array(), create_function('$a_list', 'return implode(\',\', $a_list);')));
        $items = cmsCore::getArrayFromRequest($types);
        if ($do == 'submit') {
            $inDB->insert('cms_user_groups', $items);
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            cmsCore::redirect('index.php?view=usergroups');
        } else {
            $inDB->update('cms_user_groups', $items, $id);
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            if (empty($_SESSION['editlist'])) {
                cmsCore::redirect('index.php?view=usergroups');
            } else {
                cmsCore::redirect('index.php?view=usergroups&do=edit');
            }
        }
    }
    if ($do == 'add' || $do == 'edit') {
        $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();');
        $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);');
        cpToolMenu($toolmenu);
        if ($do == 'add') {
            cpAddPathway($_LANG['AD_CREATE_GROUP']);
        } else {
            if (isset($_REQUEST['multiple'])) {
                if (isset($_REQUEST['item'])) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (sizeof($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }
            $mod = $inDB->get_fields('cms_user_groups', "id = '{$item_id}'", '*');
            if (!$mod) {
                cmsCore::error404();
            }
            echo '<h3>' . $_LANG['AD_EDIT_GROUP'] . ' ' . $ostatok . '</h3>';
            cpAddPathway($_LANG['AD_EDIT_GROUP'] . ' ' . $mod['title']);
        }
        if (isset($mod['access'])) {
            $mod['access'] = str_replace(', ', ',', $mod['access']);
            $mod['access'] = explode(',', $mod['access']);
        }
        ?>
	<form id="addform" name="addform" method="post" action="index.php?view=usergroups">
        <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
		<table width="660" border="0" cellspacing="5" class="proptable">
			<tr>
				<td width="198" valign="top"><div><strong><?php 
        echo $_LANG['AD_GROUP_NAME'];
        ?>
: </strong></div><span class="hinttext"><?php 
        echo $_LANG['AD_VIEW_SITE'];
        ?>
</span></td>
				<td width="475" valign="top"><input name="title" type="text" id="title" size="30" value="<?php 
        echo htmlspecialchars($mod['title']);
        ?>
"/></td>
			</tr>
			<tr>
				<td valign="top"><div><strong><?php 
        echo $_LANG['AD_ALIAS'];
        ?>
:</strong></div><?php 
        if ($do == 'edit') {
            ?>
<span class="hinttext"><?php 
            echo $_LANG['AD_DONT_CHANGE'];
            ?>
</span><?php 
        }
        ?>
</td>
    <td valign="top"><input name="alias" type="text" id="title3" <?php 
        if (@$mod['alias'] == 'guest') {
            ?>
readonly="readonly"<?php 
        }
        ?>
 size="30" value="<?php 
        echo @$mod['alias'];
        ?>
"/></td>
			</tr>
			<tr>
				<td><strong><?php 
        echo $_LANG['AD_IF_ADMIN'];
        ?>
</strong></td>
				<td>
					<label><input name="is_admin" type="radio" value="1" <?php 
        if (@$mod['is_admin']) {
            echo 'checked="checked"';
        }
        ?>
 onclick="$('#accesstable').hide();$('#admin_accesstable').show();"/> <?php 
        echo $_LANG['YES'];
        ?>
 </label>
					<label><input name="is_admin" type="radio" value="0"  <?php 
        if (@(!$mod['is_admin'])) {
            echo 'checked="checked"';
        }
        ?>
 onclick="$('#accesstable').show();$('#admin_accesstable').hide();"/> <?php 
        echo $_LANG['NO'];
        ?>
</label>
				</td>
			</tr>
		</table>

		<!--------------------------------------------------------------------------------------------------------------------------------------------->

		<table width="660" border="0" cellspacing="5" class="proptable" id="admin_accesstable" style="<?php 
        if (@(!$mod['is_admin'])) {
            echo 'display:none;';
        }
        ?>
">
			<tr>
				<td width="191" valign="top">
					<div><strong><?php 
        echo $_LANG['AD_AVAILABLE_SECTIONS'];
        ?>
 </strong></div>
					<span class="hinttext"><?php 
        echo $_LANG['AD_ALL_SECTIONS'];
        ?>
</span>
				</td>
				<td width="475" valign="top">
					<table width="100%" border="0" cellspacing="2" cellpadding="0">
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_menu" value="admin/menu" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/menu', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_menu"><?php 
        echo $_LANG['AD_MENU_CONTROL'];
        ?>
</label></td>
						</tr>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_modules" value="admin/modules" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/modules', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_modules"><?php 
        echo $_LANG['AD_MODULES_CONTROL'];
        ?>
</label></td>
						</tr>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_content" value="admin/content" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/content', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_content"><?php 
        echo $_LANG['AD_CONTENTS_CONTROL'];
        ?>
</label></td>
						</tr>
                        <tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_plugins" value="admin/plugins" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/filters', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_plugins"><?php 
        echo $_LANG['AD_PLUGINS_CONTROL'];
        ?>
</label></td>
						</tr>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_filters" value="admin/filters" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/filters', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_filters"><?php 
        echo $_LANG['AD_FILTERS_CONTROL'];
        ?>
</label></td>
						</tr>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_components" value="admin/components" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/components', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_components"><?php 
        echo $_LANG['AD_COMPONENTS_CONTROL'];
        ?>
</label></td>
						</tr>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_users" value="admin/users" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/users', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_users"><?php 
        echo $_LANG['AD_USERS_CONTROL'];
        ?>
</label></td>
						</tr>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_config" value="admin/config" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/config', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_config"><?php 
        echo $_LANG['AD_SETTINGS_CONTROL'];
        ?>
</label></td>
						</tr>
					</table>
                </td>
			</tr>
			<tr>
			  <td valign="top">
			  	<div><strong><?php 
        echo $_LANG['AD_COMPONENTS_SETTINGS_FREE'];
        ?>
 </strong></div>
				<span class="hinttext"><?php 
        echo $_LANG['AD_COMPONENTS_SETTINGS_ON'];
        ?>
</span>
			  </td>
			  <td valign="top">
				  <table width="100%" border="0" cellspacing="2" cellpadding="0">

						<?php 
        $coms = cmsCore::getInstance()->getAllComponents();
        foreach ($coms as $com) {
            if (!file_exists(PATH . '/admin/components/' . $com['link'] . '/backend.php')) {
                continue;
            }
            ?>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_com_<?php 
            echo $com['link'];
            ?>
" value="admin/com_<?php 
            echo $com['link'];
            ?>
" <?php 
            if (isset($mod['access'])) {
                if (in_array('admin/com_' . $com['link'], $mod['access'])) {
                    echo 'checked="checked"';
                }
            }
            ?>
 /></td>
							<td><label for="admin_com_<?php 
            echo $com['link'];
            ?>
"><?php 
            echo $com['title'];
            ?>
</label></td>
						</tr>
						<?php 
        }
        ?>

				  </table>
			  </td>
		  </tr>
		</table>

		<!--------------------------------------------------------------------------------------------------------------------------------------------->

		<table width="660" border="0" cellspacing="5" class="proptable" id="accesstable" style="<?php 
        if (@$mod['is_admin']) {
            echo 'display:none;';
        }
        ?>
">
			<tr>
				<td width="191" valign="top"><strong><?php 
        echo $_LANG['AD_GROUP_RULE'];
        ?>
 </strong></td>
				<td width="475" valign="top">
					<table width="100%" border="0" cellspacing="2" cellpadding="0">

					<?php 
        $sql = "SELECT * FROM cms_user_groups_access ORDER BY access_type";
        $res = $inDB->query($sql);
        while ($ga = $inDB->fetch_assoc($res)) {
            if ($mod['alias'] == 'guest' && $ga['hide_for_guest']) {
                continue;
            }
            ?>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="<?php 
            echo str_replace('/', '_', $ga['access_type']);
            ?>
" value="<?php 
            echo $ga['access_type'];
            ?>
" <?php 
            if (isset($mod['access'])) {
                if (in_array($ga['access_type'], $mod['access'])) {
                    echo 'checked="checked"';
                }
            }
            ?>
></td>
							<td><label for="<?php 
            echo str_replace('/', '_', $ga['access_type']);
            ?>
"><?php 
            echo $ga['access_name'];
            ?>
</label></td>
						</tr>
                    <?php 
        }
        ?>
					</table>
				</td>
			</tr>
		</table>

		<!--------------------------------------------------------------------------------------------------------------------------------------------->

		<p>
			<input name="add_mod" type="submit" id="add_mod" <?php 
        if ($do == 'add') {
            echo 'value="' . $_LANG['AD_CREATE_GROUP'] . '"';
        } else {
            echo 'value="' . $_LANG['SAVE'] . '"';
        }
        ?>
 />
			<span style="margin-top:15px"><input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.history.back();"/></span>
			<input name="do" type="hidden" id="do" <?php 
        if ($do == 'add') {
            echo 'value="submit"';
        } else {
            echo 'value="update"';
        }
        ?>
 />
			<?php 
        if ($do == 'edit') {
            echo '<input name="id" type="hidden" value="' . $mod['id'] . '" />';
        }
        ?>
		</p>
	</form>
	<?php 
    }
}
예제 #5
0
파일: backend.php 프로젝트: deltas1/icms1
    $actions[] = array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_DELETE_POLL'], 'link' => '?view=components&do=config&id=' . $id . '&opt=delete&poll_id=%id%');
    cpListTable('cms_polls', $fields, $actions);
}
if ($opt == 'submit') {
    function setupAnswers($answers_title)
    {
        $answers = array();
        foreach ($answers_title as $answer) {
            if ($answer) {
                $answers[$answer] = 0;
            }
        }
        return cmsCore::arrayToYaml($answers);
    }
    $types = array('title' => array('title', 'str', ''), 'answers' => array('answers', 'array_str', array(), 'setupAnswers'));
    $items = cmsCore::getArrayFromRequest($types);
    $inDB->insert('cms_polls', $items);
    cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
    cmsCore::redirect('?view=components&do=config&id=' . $id);
}
if ($opt == 'delete') {
    $model->deletePoll(cmsCore::request('poll_id', 'int'));
    cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
    cmsCore::redirect('?view=components&do=config&id=' . $id);
}
if ($opt == 'update') {
    $poll_id = cmsCore::request('poll_id', 'int');
    $item['title'] = cmsCore::request('title', 'str', '');
    $answers_title = cmsCore::request('answers', 'array_str');
    $nums = cmsCore::request('num', 'array_int');
    $is_clear = cmsCore::request('is_clear', 'int');
예제 #6
0
function applet_userbanlist()
{
    $inCore = cmsCore::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/users', $adminAccess)) {
        cpAccessDenied();
    }
    cmsCore::c('page')->setTitle($_LANG['AD_BANLIST']);
    cpAddPathway($_LANG['AD_USERS'], 'index.php?view=users');
    cpAddPathway($_LANG['AD_BANLIST'], 'index.php?view=userbanlist');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    $to = cmsCore::request('to', 'int', 0);
    // для редиректа обратно в профиль на сайт
    if ($to) {
        cmsUser::sessionPut('back_url', cmsCore::getBackURL());
    }
    if ($do == 'list') {
        $toolmenu = array(array('icon' => 'useradd.gif', 'title' => $_LANG['AD_TO_BANLIST_ADD'], 'link' => '?view=userbanlist&do=add'), array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=userbanlist&do=edit&multiple=1');"), array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=userbanlist&do=delete&multiple=1');"));
        cpToolMenu($toolmenu);
        $fields = array(array('title' => 'id', 'field' => 'id', 'width' => '40'), array('title' => $_LANG['AD_IS_ACTIVE'], 'field' => 'status', 'width' => '65', 'prc' => 'cpYesNo'), array('title' => $_LANG['AD_BANLIST_USER'], 'field' => 'user_id', 'width' => '120', 'filter' => '12', 'prc' => 'cpUserNick'), array('title' => $_LANG['AD_BANLIST_IP'], 'field' => 'ip', 'width' => '100', 'link' => '?view=userbanlist&do=edit&id=%id%', 'filter' => '12'), array('title' => $_LANG['DATE'], 'field' => 'bandate', 'width' => '', 'fdate' => '%d/%m/%Y %H:%i:%s', 'filter' => '12'), array('title' => $_LANG['AD_BANLIST_TIME'], 'field' => 'int_num', 'width' => '55'), array('title' => '', 'field' => 'int_period', 'width' => '70'), array('title' => $_LANG['AD_AUTOREMOVE'], 'field' => 'autodelete', 'width' => '100', 'prc' => 'cpYesNo'));
        $actions = array(array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=userbanlist&do=edit&id=%id%'), array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_REMOVE_RULE'], 'link' => '?view=userbanlist&do=delete&id=%id%'));
        cpListTable('cms_banlist', $fields, $actions, '1=1', 'ip DESC');
    }
    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) {
                dbDelete('cms_banlist', $id);
            }
        } else {
            dbDeleteList('cms_banlist', cmsCore::request('item', 'array_int', array()));
        }
        cmsCore::redirect('?view=userbanlist');
    }
    if ($do == 'submit' || $do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $types = array('user_id' => array('user_id', 'int', 0), 'ip' => array('ip', 'str', ''), 'cause' => array('cause', 'str', ''), 'autodelete' => array('autodelete', 'int', 0), 'int_num' => array('int_num', 'int', 0), 'int_period' => array('int_period', 'str', '', create_function('$p', 'if(!in_array($p, array("MONTH","DAY","HOUR","MINUTE"))){ $p = "MINUTE"; } return $p;')));
        $items = cmsCore::getArrayFromRequest($types);
        $error = false;
        if (!$items['ip']) {
            $error = true;
            cmsCore::addSessionMessage($_LANG['AD_NEED_IP'], 'error');
        }
        if ($items['ip'] == $_SERVER['REMOTE_ADDR'] || $items['user_id'] == cmsCore::c('user')->id) {
            $error = true;
            cmsCore::addSessionMessage($_LANG['AD_ITS_YOUR_IP'], 'error');
        }
        if (cmsUser::userIsAdmin($items['user_id'])) {
            $error = true;
            cmsCore::addSessionMessage($_LANG['AD_ITS_ADMIN'], 'error');
        }
        if ($error) {
            cmsCore::redirectBack();
        }
        if ($do == 'update') {
            cmsCore::c('db')->update('cms_banlist', $items, $id);
            if (empty($_SESSION['editlist'])) {
                cmsCore::redirect('?view=userbanlist');
            } else {
                cmsCore::redirect('?view=userbanlist&do=edit');
            }
        }
        cmsCore::c('db')->insert('cms_banlist', $items);
        $back_url = cmsUser::sessionGet('back_url');
        cmsUser::sessionDel('back_url');
        cmsCore::redirect($back_url ? $back_url : '?view=userbanlist');
    }
    if ($do == 'add' || $do == 'edit') {
        cmsCore::c('page')->addHeadJS('admin/js/banlist.js');
        $toolmenu = array(array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();'), array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);'));
        cpToolMenu($toolmenu);
        if ($do == 'add') {
            echo '<h3>' . $_LANG['AD_TO_BANLIST_ADD'] . '</h3>';
            cpAddPathway($_LANG['AD_TO_BANLIST_ADD']);
        } else {
            if (cmsCore::inRequest('multiple')) {
                if (cmsCore::inRequest('item')) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (count($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . count($_SESSION['editlist']) . ')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }
            $mod = cmsCore::c('db')->get_fields('cms_banlist', "id = '" . $item_id . "'", '*');
            if (!$mod) {
                cmsCore::error404();
            }
            echo '<h3>' . $_LANG['AD_EDIT_RULE'] . ' ' . $ostatok . '</h3>';
            cpAddPathway($_LANG['AD_EDIT_RULE']);
        }
        if ($do == 'add' && $to) {
            $mod['user_id'] = $to;
            $mod['ip'] = cmsCore::c('db')->get_field('cms_users', 'id=' . $to, 'last_ip');
        }
        cmsCore::c('page')->initTemplate('applets', 'userbanlist_add')->assign('do', $do)->assign('mod', $mod)->assign('users_opt', $inCore->getListItems('cms_users', cmsCore::getArrVal($mod, 'user_id', 0), 'nickname', 'ASC', 'is_deleted=0 AND is_locked=0', 'id', 'nickname'))->display();
    }
}
예제 #7
0
function applet_usergroups() {
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/users', $adminAccess)) { cpAccessDenied(); }

    cmsCore::c('page')->setTitle($_LANG['AD_USERS_GROUP']);
    cpAddPathway($_LANG['AD_USERS'], 'index.php?view=users');
    cpAddPathway($_LANG['AD_USERS_GROUP'], 'index.php?view=usergroups');

    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);

    cmsCore::loadModel('users');
    $model = new cms_model_users();

    if ($do == 'list') {
        $toolmenu = array(
            array( 'icon' => 'usergroupadd.gif', 'title' => $_LANG['AD_CREATE_GROUP'], 'link' => '?view=usergroups&do=add' ),
            array( 'icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=usergroups&do=edit&multiple=1');" ),
            array( 'icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:if(confirm('". $_LANG['AD_REMOVE_GROUP'] ."')) { checkSel('?view=users&do=delete&multiple=1'); }" )
        );
        
        cpToolMenu($toolmenu);
        
        $fields = array(
            array( 'title' => 'id', 'field' => 'id', 'width' => '40' ),
            array( 'title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '', 'link' => '?view=usergroups&do=edit&id=%id%', 'filter' => '12' ),
            array( 'title' => $_LANG['AD_FROM_USERS'], 'field' => 'id', 'width' => '110', 'prc' => 'getCountUsers' ),
            array( 'title' => $_LANG['AD_IF_ADMIN'], 'field' => 'is_admin', 'width' => '120', 'prc' => 'cpYesNo' ),
            array( 'title' => $_LANG['AD_ALIAS'], 'field' => 'alias', 'width' => '85', 'filter' => '12' )
        );
        
        $actions = array(
            array( 'title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=usergroups&do=edit&id=%id%' ),
            array( 'title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_REMOVE_GROUP'], 'link' => '?view=usergroups&do=delete&id=%id%' )
        );
        
        cpListTable('cms_user_groups', $fields, $actions);
    }
    
    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')){
            if ($id >= 0){
                $model->deleteGroup($id);
            }
        } else {
            $model->deleteGroups(cmsCore::request('item', 'array_int', array()));
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirect('index.php?view=usergroups');
    }

    if ($do == 'submit' || $do == 'update') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }

        $types = array(
            'title' => array( 'title', 'str', '' ),
            'alias' => array( 'alias', 'str', '' ),
            'is_admin' => array( 'is_admin', 'int', 0 ),
            'access' => array( 'access', 'array_str', array(), create_function('$a_list', 'return implode(\',\', $a_list);') )
        );

        $items = cmsCore::getArrayFromRequest($types);

        if ($do == 'submit') {
            cmsCore::c('db')->insert('cms_user_groups', $items);
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            cmsCore::redirect('index.php?view=usergroups');
        } else {
            cmsCore::c('db')->update('cms_user_groups', $items, $id);
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            if (empty($_SESSION['editlist'])) {
                cmsCore::redirect('index.php?view=usergroups');
            } else {
                cmsCore::redirect('index.php?view=usergroups&do=edit');
            }
        }
    }

    if ($do == 'add' || $do == 'edit') {
        $toolmenu = array(
            array( 'icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();' ),
            array( 'icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);' )
        );
        
        cpToolMenu($toolmenu);

        if ($do == 'add') {
            cpAddPathway($_LANG['AD_CREATE_GROUP']);
            $mod = array();
        } else {
            if(cmsCore::inRequest('multiple')){
                if (cmsCore::inRequest('item')){
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }

            $ostatok = '';

            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (count($_SESSION['editlist']) == 0) {
                   unset($_SESSION['editlist']);
                } else {
                    $ostatok = '('. $_LANG['AD_NEXT_IN'] . count($_SESSION['editlist']) .')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }

            $mod = cmsCore::c('db')->get_fields('cms_user_groups', "id = '". $item_id ."'", '*');
            if (!$mod){ cmsCore::error404(); }

            echo '<h3>'. $_LANG['AD_EDIT_GROUP'] .' '. $ostatok .'</h3>';

            cpAddPathway($_LANG['AD_EDIT_GROUP'] .' '. $mod['title']);
        }

        if (isset($mod['access'])) {
            $mod['access'] = str_replace(', ', ',', $mod['access']);
            $mod['access'] = explode(',', $mod['access']);
        }
?>
<form id="addform" name="addform" method="post" action="index.php?view=usergroups">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
    
    <div style="width:650px;">
        <div class="form-group">
            <label><?php echo $_LANG['AD_GROUP_NAME'];?>:</label>
            <input type="text" class="form-control" name="title" size="30" value="<?php echo htmlspecialchars(cmsCore::getArrVal($mod, 'title', '')); ?>" />
            <div class="help-block"><?php echo $_LANG['AD_VIEW_SITE']; ?></div>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_ALIAS'];?>:</label>
            <input type="text" class="form-control" name="alias" size="30" <?php if (cmsCore::getArrVal($mod, 'alias', '') == 'guest') { echo 'readonly="readonly"'; } ?> value="<?php echo cmsCore::getArrVal($mod, 'alias', ''); ?>" />
            <?php if ($do == 'edit') { ?>
                <div class="help-block"><?php echo $_LANG['AD_DONT_CHANGE']; ?></div>
            <?php } ?>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_IF_ADMIN'];?>:</label>
            <div class="btn-group" data-toggle="buttons" style="float:right;">
                <label class="btn btn-default <?php if (cmsCore::getArrVal($mod, 'is_admin')) { echo 'active'; } ?>" onclick="$('#accesstable').hide();$('#admin_accesstable').show();">
                    <input type="radio" name="is_admin" <?php if (cmsCore::getArrVal($mod, 'is_admin')) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                </label>
                <label class="btn btn-default <?php if (!cmsCore::getArrVal($mod, 'is_admin')) { echo 'active'; } ?>" onclick="$('#accesstable').show();$('#admin_accesstable').hide();">
                    <input type="radio" name="is_admin" <?php if (!cmsCore::getArrVal($mod, 'is_admin')) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                </label>
            </div>
        </div>
        
        <hr>
        
        <div id="admin_accesstable" <?php if (!cmsCore::getArrVal($mod, 'is_admin')) { echo 'style="display:none;"'; } ?>>
            <div class="form-group">
                <label><?php echo $_LANG['AD_AVAILABLE_SECTIONS']; ?></label>
                
                <div style="margin-left:50px;">
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_menu" name="access[]" value="admin/menu" <?php if (isset($mod['access'])) { if (in_array('admin/menu', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_MENU_CONTROL']; ?>
                        </label>
                    </div>

                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_modules" name="access[]" value="admin/modules" <?php if (isset($mod['access'])) { if (in_array('admin/modules', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_MODULES_CONTROL']; ?>
                        </label>
                    </div>

                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_content" name="access[]" value="admin/content" <?php if (isset($mod['access'])) { if (in_array('admin/content', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_CONTENTS_CONTROL']; ?>
                        </label>
                    </div>

                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_plugins" name="access[]" value="admin/plugins" <?php if (isset($mod['access'])) { if (in_array('admin/filters', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_CONTENTS_CONTROL']; ?>
                        </label>
                    </div>

                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_filters" name="access[]" value="admin/filters" <?php if (isset($mod['access'])) { if (in_array('admin/filters', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_FILTERS_CONTROL']; ?>
                        </label>
                    </div>

                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_components" name="access[]" value="admin/components" <?php if (isset($mod['access'])) { if (in_array('admin/components', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_COMPONENTS_CONTROL']; ?>
                        </label>
                    </div>

                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_users" name="access[]" value="admin/users" <?php if (isset($mod['access'])) { if (in_array('admin/users', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_USERS_CONTROL']; ?>
                        </label>
                    </div>

                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_config" name="access[]" value="admin/config" <?php if (isset($mod['access'])) { if (in_array('admin/config', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_SETTINGS_CONTROL']; ?>
                        </label>
                    </div>
                    
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_config" name="access[]" value="admin/tickets" <?php if (isset($mod['access'])) { if (in_array('admin/tickets', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_TICKETS_CONTROL']; ?>
                        </label>
                    </div>
                    
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_config" name="access[]" value="admin/checksystem" <?php if (isset($mod['access'])) { if (in_array('admin/checksystem', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_CHECKSYSTEM_CONTROL']; ?>
                        </label>
                    </div>
                </div>
                
                <div class="help-block"><?php echo $_LANG['AD_ALL_SECTIONS']; ?></div>
            </div>
            
            <div class="form-group">
                <label><?php echo $_LANG['AD_COMPONENTS_SETTINGS_FREE']; ?></label>
                
                <div style="margin-left:50px;">
                    <?php
                        $coms = cmsCore::getInstance()->getAllComponents();
                        foreach ($coms as $com) {
                            if (!file_exists(PATH.'/admin/components/'. $com['link'] .'/backend.php')) { continue; }
                    ?>

                        <div class="checkbox">
                            <label>
                                <input type="checkbox" id="admin_com_<?php echo $com['link']; ?>" name="access[]" value="admin/com_<?php echo $com['link']; ?>" <?php if (isset($mod['access'])) { if (in_array('admin/com_'. $com['link'], $mod['access'])) { echo 'checked="checked"'; } } ?> />
                                <?php echo $com['title']; ?>
                            </label>
                        </div>
                    <?php } ?>
                </div>
                
                <div class="help-block"><?php echo $_LANG['AD_COMPONENTS_SETTINGS_ON']; ?></div>
            </div>
        </div>
        
        <div id="accesstable" <?php if (cmsCore::getArrVal($mod, 'is_admin')) { echo 'style="display:none;"'; } ?>>
            <div class="form-group">
                <label><?php echo $_LANG['AD_GROUP_RULE'];?></label>
                
                <div style="margin-left:50px;">
                    <?php
                        $sql = "SELECT * FROM cms_user_groups_access ORDER BY access_type";
                        $res = cmsCore::c('db')->query($sql);

                        while ($ga = cmsCore::c('db')->fetch_assoc($res)) {
                            if ($mod['alias'] == 'guest' && $ga['hide_for_guest']) { continue; }
                    ?>
                        <div class="checkbox">
                            <label>
                                <input type="checkbox" id="<?php echo str_replace('/', '_', $ga['access_type']); ?>" name="access[]" value="<?php echo $ga['access_type']; ?>" <?php if (isset($mod['access'])) { if (in_array($ga['access_type'], $mod['access'])) { echo 'checked="checked"'; } } ?> />
                                <?php echo $ga['access_name']; ?>
                            </label>
                        </div>
                    <?php } ?>
                </div>
            </div>
        </div>
    </div>
    
    <div>
        <input type="submit" class="btn btn-primary" name="add_mod" value="<?php if ($do == 'add') { echo $_LANG['AD_CREATE_GROUP']; } else { echo $_LANG['SAVE']; } ?>" />
        <input type="button" class="btn btn-default" name="back" value="<?php echo $_LANG['CANCEL'];?>" onclick="window.history.back();"/>
        
        <input type="hidden" name="do" value="<?php if ($do == 'add') { echo 'submit'; } else { echo 'update'; } ?>" />
        <?php
            if ($do == 'edit') {
                echo '<input name="id" type="hidden" value="'. $mod['id'] .'" />';
            }
        ?>
    </div>
</form>
<?php
   }
}
예제 #8
0
function applet_userbanlist() {
    $inCore = cmsCore::getInstance();
    
    global $_LANG;
    global $adminAccess;
    
    if (!cmsUser::isAdminCan('admin/users', $adminAccess)) { cpAccessDenied(); }

    cmsCore::c('page')->setTitle($_LANG['AD_BANLIST']);
    cpAddPathway($_LANG['AD_USERS'], 'index.php?view=users');
    cpAddPathway($_LANG['AD_BANLIST'], 'index.php?view=userbanlist');

    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    $to = cmsCore::request('to', 'int', 0);
    
    // для редиректа обратно в профиль на сайт
    if ($to) {
        cmsUser::sessionPut('back_url', cmsCore::getBackURL());
    }

    if ($do == 'list') {
        $toolmenu = array(
            array( 'icon' => 'useradd.gif', 'title' => $_LANG['AD_TO_BANLIST_ADD'], 'link' => '?view=userbanlist&do=add' ),
            array( 'icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=userbanlist&do=edit&multiple=1');" ),
            array( 'icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=userbanlist&do=delete&multiple=1');" )
        );

        cpToolMenu($toolmenu);

        $fields = array(
            array( 'title' => 'id', 'field' => 'id', 'width' => '40' ),
            array( 'title' => $_LANG['AD_IS_ACTIVE'], 'field' => 'status', 'width' => '65', 'prc' => 'cpYesNo' ),
            array( 'title' => $_LANG['AD_BANLIST_USER'], 'field' => 'user_id', 'width' => '120', 'filter' => '12', 'prc' => 'cpUserNick' ),
            array( 'title' => $_LANG['AD_BANLIST_IP'], 'field' => 'ip', 'width' => '100', 'link' => '?view=userbanlist&do=edit&id=%id%', 'filter' => '12' ),
            array( 'title' => $_LANG['DATE'], 'field' => 'bandate', 'width' => '', 'fdate' => '%d/%m/%Y %H:%i:%s', 'filter' => '12' ),
            array( 'title' => $_LANG['AD_BANLIST_TIME'], 'field' => 'int_num', 'width' => '55' ),
            array( 'title' => '', 'field' => 'int_period', 'width' => '70' ),
            array( 'title' => $_LANG['AD_AUTOREMOVE'], 'field' => 'autodelete', 'width' => '100', 'prc' => 'cpYesNo' )
        );
        
        $actions = array(
            array( 'title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=userbanlist&do=edit&id=%id%' ),
            array( 'title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_REMOVE_RULE'], 'link' => '?view=userbanlist&do=delete&id=%id%' )
        );

        cpListTable('cms_banlist', $fields, $actions, '1=1', 'ip DESC');
    }

    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) { dbDelete('cms_banlist', $id); }
        } else {
            dbDeleteList('cms_banlist', cmsCore::request('item', 'array_int', array()));
        }
        cmsCore::redirect('?view=userbanlist');
    }

    if ($do == 'submit' || $do == 'update') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }

        $types = array(
            'user_id' => array( 'user_id', 'int', 0 ),
            'ip' => array( 'ip', 'str', '' ),
            'cause' => array( 'cause', 'str', '' ),
            'autodelete' => array( 'autodelete', 'int', 0 ),
            'int_num' => array( 'int_num', 'int', 0 ),
            'int_period' => array( 'int_period', 'str', '', create_function('$p', 'if(!in_array($p, array("MONTH","DAY","HOUR","MINUTE"))){ $p = "MINUTE"; } return $p;') )
        );

        $items = cmsCore::getArrayFromRequest($types);

        $error = false;

        if (!$items['ip']) {
            $error = true;
            cmsCore::addSessionMessage($_LANG['AD_NEED_IP'], 'error');
        }
        
        if ($items['ip'] == $_SERVER['REMOTE_ADDR'] ||
            $items['user_id'] == cmsCore::c('user')->id) {
            $error = true;
            cmsCore::addSessionMessage($_LANG['AD_ITS_YOUR_IP'], 'error');
        }

        if (cmsUser::userIsAdmin($items['user_id'])) {
            $error = true;
            cmsCore::addSessionMessage($_LANG['AD_ITS_ADMIN'], 'error');
        }

        if ($error) {
            cmsCore::redirectBack();
        }

        if ($do == 'update') {
            cmsCore::c('db')->update('cms_banlist', $items, $id);

            if (empty($_SESSION['editlist'])) {
                cmsCore::redirect('?view=userbanlist');
            } else {
                cmsCore::redirect('?view=userbanlist&do=edit');
            }
        }

        cmsCore::c('db')->insert('cms_banlist', $items);
        $back_url = cmsUser::sessionGet('back_url');
        cmsUser::sessionDel('back_url');
        cmsCore::redirect($back_url ? $back_url : '?view=userbanlist');
    }

    if ($do == 'add' || $do == 'edit') {
        cmsCore::c('page')->addHeadJS('admin/js/banlist.js');

        $toolmenu = array(
            array( 'icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();' ),
            array( 'icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);' )
        );

        cpToolMenu($toolmenu);

        if ($do == 'add') {
            echo '<h3>'. $_LANG['AD_TO_BANLIST_ADD'] .'</h3>';
            cpAddPathway($_LANG['AD_TO_BANLIST_ADD']);
        } else {
            if (cmsCore::inRequest('multiple')) {
                if (cmsCore::inRequest('item')) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }

            $ostatok = '';

            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (count($_SESSION['editlist']) == 0) {
                   unset($_SESSION['editlist']);
                } else {
                    $ostatok = '('. $_LANG['AD_NEXT_IN'] . count($_SESSION['editlist']) .')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }

            $mod = cmsCore::c('db')->get_fields('cms_banlist', "id = '". $item_id ."'", '*');
            if (!$mod) { cmsCore::error404(); }

            echo '<h3>'. $_LANG['AD_EDIT_RULE'] .' '. $ostatok .'</h3>';

            cpAddPathway($_LANG['AD_EDIT_RULE']);
        }
?>
<form id="addform" name="addform" method="post" action="index.php?view=userbanlist">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
    
    <div style="width:500px;">
        <div class="alert alert-warning">
            <strong><?php echo $_LANG['ATTENTION'];?>!</strong>
            <div><?php echo $_LANG['AD_CAUTION_INFO_0'];?></div>
            <div><?php echo $_LANG['AD_CAUTION_INFO_1'];?></div>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_BANLIST_USER'];?>:</label>
            <?php if ($do == 'add' && $to) { $mod['user_id'] = $to; $mod['ip'] = cmsCore::c('db')->get_field('cms_users', 'id='. $to, 'last_ip'); } ?>
            <select id="user_id" class="form-control" name="user_id" onchange="loadUserIp()">
                <option value="0" <?php if (!cmsCore::getArrVal($mod, 'user_id')){ echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_WHITHOUT_USER']; ?></option>
                <?php
                    echo $inCore->getListItems('cms_users', cmsCore::getArrVal($mod, 'user_id', 0), 'nickname', 'ASC', 'is_deleted=0 AND is_locked=0', 'id', 'nickname');
                ?>
            </select>
        </div>

        <div class="form-group">
            <label><?php echo $_LANG['AD_BANLIST_IP'];?>:</label>
            <input type="text" id="ip" class="form-control" name="ip" value="<?php echo cmsCore::getArrVal($mod, 'ip', ''); ?>"/>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_BANLIST_CAUSE'];?>:</label>
            <textarea class="form-control" name="cause" rows="5"><?php echo cmsCore::getArrVal($mod, 'cause', ''); ?></textarea>
        </div>
        
        <?php $forever = false; if (!cmsCore::getArrVal($mod, 'int_num')) { $forever = true; } ?>
        
        <div class="form-group">
            <label>
                <?php echo $_LANG['AD_BAN_FOREVER'];?>
                <input type="checkbox" name="forever" value="1" <?php if ($forever){ echo 'checked="checked"'; } ?> onclick="$('#bantime').toggle();" />
            </label>
        </div>
        
        <div id="bantime" class="form-group">
            <label><?php echo $_LANG['AD_BAN_FOR_TIME'];?></label>
            <input type="number" id="int_num" class="form-control" name="int_num" min="0" value="<?php echo cmsCore::getArrVal($mod, 'int_num', 0); ?>" />
            <select id="int_period" class="form-control" name="int_period">
                <option value="MINUTE"  <?php if (mb_strstr(cmsCore::getArrVal($mod, 'int_period', ''), 'MINUTE')) { echo 'selected="selected"'; } ?>><?php echo $_LANG['MINUTE10']; ?></option>]
                <option value="HOUR"  <?php if (mb_strstr(cmsCore::getArrVal($mod, 'int_period', ''), 'HOUR')) { echo 'selected="selected"'; } ?>><?php echo $_LANG['HOUR10']; ?></option>
                <option value="DAY" <?php if (mb_strstr(cmsCore::getArrVal($mod, 'int_period', ''), 'DAY')) { echo 'selected="selected"'; } ?>><?php echo $_LANG['DAY10']; ?></option>
                <option value="MONTH" <?php if (mb_strstr(cmsCore::getArrVal($mod, 'int_period', ''), 'MONTH')) { echo 'selected="selected"'; } ?>><?php echo $_LANG['MONTH10']; ?></option>
            </select>
            <div class="checkbox">
                <label><input type="checkbox" id="autodelete" name="autodelete" value="1" <?php if($mod['autodelete']) { echo 'checked="checked"'; } ?> /> <?php echo $_LANG['AD_REMOVE_BAN'];?></label>
            </div>
            <?php if ($forever) { ?><script type="text/javascript">$('#bantime').hide();</script><?php } ?>
        </div>
    </div>

    <div>
        <input type="submit" class="btn btn-primary" name="add_mod" value="<?php if ($do == 'add') { echo $_LANG['AD_TO_BANLIST_ADD']; } else { echo $_LANG['SAVE']; } ?>" />
        <input type="button" class="btn btn-default" name="back" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.history.back();"/>

        <input name="do" type="hidden" value="<?php if ($do == 'add') { echo 'submit'; } else { echo 'update'; } ?>" />
        <?php
            if ($do == 'edit') {
                echo '<input type="hidden" name="id" value="'. $mod['id'] .'" />';
            }
        ?>
    </div>
</form>
<?php
   }
}
예제 #9
0
function applet_usergroups()
{
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/users', $adminAccess)) {
        cpAccessDenied();
    }
    cmsCore::c('page')->setTitle($_LANG['AD_USERS_GROUP']);
    cpAddPathway($_LANG['AD_USERS'], 'index.php?view=users');
    cpAddPathway($_LANG['AD_USERS_GROUP'], 'index.php?view=usergroups');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    cmsCore::loadModel('users');
    $model = new cms_model_users();
    if ($do == 'list') {
        $toolmenu = array(array('icon' => 'usergroupadd.gif', 'title' => $_LANG['AD_CREATE_GROUP'], 'link' => '?view=usergroups&do=add'), array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=usergroups&do=edit&multiple=1');"), array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:if(confirm('" . $_LANG['AD_REMOVE_GROUP'] . "')) { checkSel('?view=users&do=delete&multiple=1'); }"));
        cpToolMenu($toolmenu);
        $fields = array(array('title' => 'id', 'field' => 'id', 'width' => '40'), array('title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '', 'link' => '?view=usergroups&do=edit&id=%id%', 'filter' => '12'), array('title' => $_LANG['AD_FROM_USERS'], 'field' => 'id', 'width' => '110', 'prc' => 'getCountUsers'), array('title' => $_LANG['AD_IF_ADMIN'], 'field' => 'is_admin', 'width' => '120', 'prc' => 'cpYesNo'), array('title' => $_LANG['AD_ALIAS'], 'field' => 'alias', 'width' => '85', 'filter' => '12'));
        $actions = array(array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=usergroups&do=edit&id=%id%'), array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_REMOVE_GROUP'], 'link' => '?view=usergroups&do=delete&id=%id%'));
        cpListTable('cms_user_groups', $fields, $actions);
    }
    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) {
                $model->deleteGroup($id);
            }
        } else {
            $model->deleteGroups(cmsCore::request('item', 'array_int', array()));
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirect('index.php?view=usergroups');
    }
    if ($do == 'submit' || $do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $types = array('title' => array('title', 'str', ''), 'alias' => array('alias', 'str', ''), 'is_admin' => array('is_admin', 'int', 0), 'access' => array('access', 'array_str', array(), create_function('$a_list', 'return implode(\',\', $a_list);')));
        $items = cmsCore::getArrayFromRequest($types);
        if ($do == 'submit') {
            cmsCore::c('db')->insert('cms_user_groups', $items);
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            cmsCore::redirect('index.php?view=usergroups');
        } else {
            cmsCore::c('db')->update('cms_user_groups', $items, $id);
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            if (empty($_SESSION['editlist'])) {
                cmsCore::redirect('index.php?view=usergroups');
            } else {
                cmsCore::redirect('index.php?view=usergroups&do=edit');
            }
        }
    }
    if ($do == 'add' || $do == 'edit') {
        $toolmenu = array(array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();'), array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);'));
        cpToolMenu($toolmenu);
        if ($do == 'add') {
            cpAddPathway($_LANG['AD_CREATE_GROUP']);
            $mod = array();
        } else {
            if (cmsCore::inRequest('multiple')) {
                if (cmsCore::inRequest('item')) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (count($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . count($_SESSION['editlist']) . ')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }
            $mod = cmsCore::c('db')->get_fields('cms_user_groups', "id = '" . $item_id . "'", '*');
            if (!$mod) {
                cmsCore::error404();
            }
            echo '<h3>' . $_LANG['AD_EDIT_GROUP'] . ' ' . $ostatok . '</h3>';
            cpAddPathway($_LANG['AD_EDIT_GROUP'] . ' ' . $mod['title']);
        }
        if (isset($mod['access'])) {
            $mod['access'] = str_replace(', ', ',', $mod['access']);
            $mod['access'] = explode(',', $mod['access']);
        }
        $gas = array();
        $sql = "SELECT * FROM cms_user_groups_access ORDER BY access_type";
        $res = cmsCore::c('db')->query($sql);
        while ($ga = cmsCore::c('db')->fetch_assoc($res)) {
            $gas[] = $ga;
        }
        cmsCore::c('page')->initTemplate('applets', 'usergroups_add')->assign('do', $do)->assign('coms', cmsCore::getInstance()->getAllComponents())->assign('gas', $gas)->assign('mod', $mod)->display();
    }
}
예제 #10
0
파일: config.php 프로젝트: Acsac/CMS-RuDi
function applet_config() {
    // получаем оригинальный конфиг
    $config = cmsConfig::getDefaultConfig();
    
    global $_LANG;
    
    global $adminAccess;
    
    if (!cmsUser::isAdminCan('admin/config', $adminAccess)) { cpAccessDenied(); }
    
    cmsCore::c('page')->setTitle($_LANG['AD_SITE_SETTING']);

    cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config');

    $do = cmsCore::request('do', 'str', 'list');

    if ($do == 'save') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }

        $newCFG = cmsCore::getArrayFromRequest(array(
            'scheme'                  => array('scheme', array('http', 'https'), ''),
            'sitename'                => array('sitename', 'str', ''),
            'title_and_sitename'      => array('title_and_sitename', 'int', 0),
            'title_and_page'          => array('title_and_page', 'int', 0),
            'hometitle'               => array('hometitle', 'str', ''),
            'homecom'                 => array('homecom', 'str', ''),
            'com_without_name_in_url' => array('com_without_name_in_url', 'str', ''),
            'siteoff'                 => array('siteoff', 'int', 0),
            'only_authorized'         => array('only_authorized', 'int', 0),
            'debug'                   => array('debug', 'int', 0),
            'offtext'                 => array('offtext', 'str', ''),
            'keywords'                => array('keywords', 'str', ''),
            'metadesc'                => array('metadesc', 'str', ''),
            'seourl'                  => array('seourl', 'int', 0),
            'lang'                    => array('lang', 'str', 'ru'),
            'is_change_lang'          => array('is_change_lang', 'int', 0),
            'sitemail'                => array('sitemail', 'str', ''),
            'sitemail_name'           => array('sitemail_name', 'str', ''),
            'wmark'                   => array('wmark', 'str', ''),
            'template'                => array('template', 'str', ''),
            'cache'                   => array('cache', 'int', 0),
            'cache_type'              => array('cache_type', array('file', 'memcached'), ''),
            'memcached_host'          => array('memcached_host', 'str', ''),
            'memcached_port'          => array('memcached_port', 'int', 0),
            'combine_css_enable'      => array('combine_css_enable', 'int', 0),
            'combine_css'             => array('combine_css', 'html', ''),
            'combine_js_enable'       => array('combine_js_enable', 'int', 0),
            'combine_js'              => array('combine_js', 'html', ''),
            'splash'                  => array('splash', 'int', 0),
            'slight'                  => array('slight', 'int', 0),
            'show_pw'                 => array('show_pw', 'int', 0),
            'last_item_pw'            => array('last_item_pw', 'int', 0),
            'index_pw'                => array('index_pw', 'int', 0),
            'fastcfg'                 => array('fastcfg', 'int', 0),
            'mailer'                  => array('mailer', 'str', ''),
            'smtpsecure'              => array('smtpsecure', 'str', ''),
            'smtpauth'                => array('smtpauth', 'int', 0),
            'smtpuser'                => array('smtpuser', 'str', $config['smtpuser']),
            'smtppass'                => array('smtppass', 'str', $config['smtppass']),
            'smtphost'                => array('smtphost', 'str', ''),
            'smtpport'                => array('smtpport', 'int', '25'),
            'timezone'                => array('timezone', 'str', $config['timezone']),
            'user_stats'              => array('user_stats', 'int', 0),
            'seo_url_count'           => array('seo_url_count', 'int', 0),
            'max_pagebar_links'       => array('max_pagebar_links', 'int', 0),
            'allow_ip'                => array('allow_ip', 'str', ''),
            'iframe_enable'           => array('iframe_enable', 'int', 0),
            'vk_enable'               => array('vk_enable', 'int', 0),
            'vk_id'                   => array('vk_id', 'str', ''),
            'vk_private_key'          => array('vk_private_key', 'str', ''),
        ));
        
        $newCFG['sitename']  = stripslashes($newCFG['sitename']);
        $newCFG['hometitle'] = stripslashes($newCFG['hometitle']);
        $newCFG['offtext']   = htmlspecialchars($newCFG['offtext'], ENT_QUOTES);
        $newCFG['db_host']   = $config['db_host'];
        $newCFG['db_base']   = $config['db_base'];
        $newCFG['db_user']   = $config['db_user'];
        $newCFG['db_pass']   = $config['db_pass'];
        $newCFG['db_prefix'] = $config['db_prefix'];
        
        if (cmsConfig::saveToFile($newCFG)) {
            cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'] , 'success');
        } else {
            cmsCore::addSessionMessage($_LANG['AD_CONFIG_SITE_ERROR'], 'error');
        }

        cmsCore::clearCache();
        cmsCore::redirect('index.php?view=config');
    }

    cpCheckWritable('/includes/config/config.inc.json');
?>
<form class="form-horizontal" role="form" action="/admin/index.php?view=config" method="post" name="CFGform" target="_self" id="CFGform" style="margin-bottom:30px">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
    
    <div class="uitabs">
        <ul id="tabs">
            <li><a href="#basic"><span><?php echo $_LANG['AD_SITE']; ?></span></a></li>
            <li><a href="#home"><span><?php echo $_LANG['AD_MAIN']; ?></span></a></li>
            <li><a href="#cache"><span><?php echo $_LANG['AD_CACHE']; ?></span></a></li>
            <li><a href="#database"><span><?php echo $_LANG['AD_DB'] ; ?></span></a></li>
            <li><a href="#mail"><span><?php echo $_LANG['AD_POST']; ?></span></a></li>
            <li><a href="#other"><span><?php echo $_LANG['AD_PATHWAY']; ?></span></a></li>
            <li><a href="#seq"><span><?php echo $_LANG['AD_SECURITY']; ?></span></a></li>
            <li><a href="#soc_apps"><span><?php echo $_LANG['AD_SOC_APPS']; ?></span></a></li>
        </ul>
        
        <div id="basic">
            <div style="width:750px;">
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SCHEME_TYPE']; ?></label>
                    <div class="col-sm-7">
                        <select id="scheme" class="form-control" name="scheme">
                            <option value=""><?php echo $_LANG['AD_SCHEME_ANY']; ?></option>
                            <option value="http" <?php if ($config['scheme'] == 'http') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_SCHEME_http']; ?></option>
                            <option value="https" <?php if ($config['scheme'] == 'https') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_SCHEME_https']; ?></option>
                        </select>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_TIME_ARREA']; ?></label>
                    <div class="col-sm-7">
                        <select id="timezone" class="form-control" name="timezone">
                            <?php echo cmsCore::getTimeZonesOptions($config['timezone']); ?>
                        </select>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SITENAME']; ?></label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" name="sitename" value="<?php echo htmlspecialchars($config['sitename']);?>" />
                        <div class="help-block"><?php echo $_LANG['AD_USE_HEADER']; ?></div>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['TEMPLATE']; ?></label>
                    <div class="col-sm-7">
                        <select id="template" class="form-control" name="template" onchange="document.CFGform.submit();">
                        <?php
                            $templates = cmsCore::getDirsList('/templates');
                            foreach ($templates as $template) {
                                if ($template == 'admin') { continue; }
                                echo '<option value="'. $template .'" '. ($config['template'] == $template ? 'selected="selected"' : '') .'>'. $template .'</option>';
                            }

                            $tpl_info = cmsCore::c('page')->getCurrentTplInfo();
                        ?>
                        </select>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SEARCH_RESULT']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if ($config['slight']) { echo 'active'; } ?>">
                            <input type="radio" name="slight" <?php if ($config['slight']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['SHOW']; ?>
                        </label>
                        <label class="btn btn-default <?php if (!$config['slight']) { echo 'active'; } ?>">
                            <input type="radio" name="slight" <?php if (!$config['slight']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['HIDE']; ?>
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_TAGE_ADD']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if ($config['title_and_sitename']) { echo 'active'; } ?>">
                            <input type="radio" name="title_and_sitename" <?php if ($config['title_and_sitename']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                        </label>
                        <label class="btn btn-default <?php if (!$config['title_and_sitename']) { echo 'active'; } ?>">
                            <input type="radio" name="title_and_sitename" <?php if (!$config['title_and_sitename']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_TAGE_ADD_PAGINATION']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if ($config['title_and_page']) { echo 'active'; } ?>">
                            <input type="radio" name="title_and_page" <?php if ($config['title_and_page']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                        </label>
                        <label class="btn btn-default <?php if (!$config['title_and_page']) { echo 'active'; } ?>">
                            <input type="radio" name="title_and_page" <?php if (!$config['title_and_page']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                        </label>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_COM_WITHOUT_NAME_IN_URL']; ?></label>
                    <div class="col-sm-7">
                        <select class="form-control" name="com_without_name_in_url">
                            <?php echo cmsCore::getListItems('cms_components', $config['com_without_name_in_url'], 'title', 'ASC', 'internal=0', 'link'); ?>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['TEMPLATE_INTERFACE_LANG']; ?></label>
                    <div class="col-sm-7">
                        <select class="form-control" name="lang">
                        <?php
                            $langs = cmsCore::getDirsList('/languages');
                            foreach ($langs as $lng) {
                                echo '<option value="'. $lng .'" '. ($config['lang'] == $lng ? 'selected="selected"' : '') .'>'. $lng .'</option>';
                            }
                        ?>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SITE_LANGUAGE_CHANGE']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if ($config['is_change_lang']) { echo 'active'; } ?>">
                            <input type="radio" name="is_change_lang" <?php if ($config['is_change_lang']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                        </label>
                        <label class="btn btn-default <?php if (!$config['is_change_lang']) { echo 'active'; } ?>">
                            <input type="radio" name="is_change_lang" <?php if (!$config['is_change_lang']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                        </label>
                        <div style="clear:both;"></div>
                        <div class="help-block"><?php echo $_LANG['AD_VIEW_FORM_LANGUAGE_CHANGE']; ?></div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SITE_ON']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if (!$config['siteoff']) { echo 'active'; } ?>">
                            <input type="radio" name="siteoff" <?php if (!$config['siteoff']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['YES']; ?>
                        </label>
                        <label class="btn btn-default <?php if ($config['siteoff']) { echo 'active'; } ?>">
                            <input type="radio" name="siteoff" <?php if ($config['siteoff']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['NO']; ?>
                        </label>
                        <div style="clear:both;"></div>
                        <div class="help-block"><?php echo $_LANG['AD_ONLY_ADMINS']; ?></div>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SITE_ONLY_AUTHORIZED']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if ($config['only_authorized']) { echo 'active'; } ?>">
                            <input type="radio" name="only_authorized" <?php if ($config['only_authorized']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                        </label>
                        <label class="btn btn-default <?php if (!$config['only_authorized']) { echo 'active'; } ?>">
                            <input type="radio" name="only_authorized" <?php if (!$config['only_authorized']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                        </label>
                        <div style="clear:both;"></div>
                        <div class="help-block"><?php echo $_LANG['AD_SITE_ONLY_AUTHORIZED_INFO']; ?></div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_DEBUG_ON']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if ($config['debug']) { echo 'active'; } ?>">
                            <input type="radio" name="debug" <?php if ($config['debug']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                        </label>
                        <label class="btn btn-default <?php if (!$config['debug']) { echo 'active'; } ?>">
                            <input type="radio" name="debug" <?php if (!$config['debug']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                        </label>
                        <div style="clear:both;"></div>
                        <div class="help-block"><?php echo $_LANG['AD_WIEW_DB_ERRORS']; ?></div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_WHY_STOP']; ?></label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" name="offtext" value="<?php echo htmlspecialchars($config['offtext']); ?>" />
                        <div class="help-block"><?php echo $_LANG['AD_VIEW_WHY_STOP']; ?></div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_WATERMARK']; ?></label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" name="wmark" value="<?php echo $config['wmark']; ?>" />
                        <div class="help-block"><?php echo $_LANG['AD_WATERMARK_NAME']; ?></div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_QUICK_CONFIG']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if ($config['fastcfg']) { echo 'active'; } ?>">
                            <input type="radio" name="fastcfg" <?php if ($config['fastcfg']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                        </label>
                        <label class="btn btn-default <?php if (!$config['fastcfg']) { echo 'active'; } ?>">
                            <input type="radio" name="fastcfg" <?php if (!$config['fastcfg']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                        </label>
                        <div style="clear:both;"></div>
                        <div class="help-block"><?php echo $_LANG['AD_MODULE_CONFIG']; ?></div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_ONLINESTATS']; ?></label>
                    <div class="col-sm-7">
                        <select class="form-control" name="user_stats">
                            <option value="0" <?php if (!$config['user_stats']) { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_NO_ONLINESTATS']; ?></option>
                            <option value="1" <?php if ($config['user_stats'] == 1) { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_YES_ONLINESTATS']; ?></option>
                            <option value="2" <?php if ($config['user_stats'] == 2) { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_CRON_ONLINESTATS']; ?></option>
                        </select>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SEO_URL_COUNT']; ?></label>
                    <div class="col-sm-7">
                        <input type="number" class="form-control" name="seo_url_count" value="<?php echo $config['seo_url_count']; ?>" />
                        <div class="help-block"><?php echo $_LANG['AD_SEO_URL_COUNT_HINT']; ?></div>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_PAGEBAR_MAX_LINKS']; ?></label>
                    <div class="col-sm-7">
                        <input type="number" class="form-control" name="max_pagebar_links" value="<?php echo $config['max_pagebar_links']; ?>" />
                    </div>
                </div>
            </div>
        </div>
        
        <div id="home">
            <div style="width:750px;">
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MAIN_PAGE']; ?></label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" name="hometitle" value="<?php echo htmlspecialchars($config['hometitle']); ?>" />
                        <div class="help-block"><?php echo $_LANG['AD_MAIN_SITENAME']; ?></div>
                        <div class="help-block"><?php echo $_LANG['AD_BROWSER_TITLE']; ?></div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_KEY_WORDS']; ?></label>
                    <div class="col-sm-7">
                        <textarea class="form-control" name="keywords" rows="3"><?php echo $config['keywords']; ?></textarea>
                        <div class="help-block"><?php echo $_LANG['AD_FROM_COMMA']; ?></div>
                        <div class="help-block"><a style="color:#09C" href="http://tutorial.semonitor.ru/#5" target="_blank"><?php echo $_LANG['AD_WHAT_KEY_WORDS']; ?></a></div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_DESCRIPTION']; ?></label>
                    <div class="col-sm-7">
                        <textarea class="form-control" name="metadesc" rows="3"><?php echo $config['metadesc']; ?></textarea>
                        <div class="help-block"><?php echo $_LANG['AD_LESS_THAN']; ?></div>
                        <div class="help-block"><a style="color:#09C" href="http://tutorial.semonitor.ru/#219" target="_blank"><?php echo $_LANG['AD_WHAT_DESCRIPTION']; ?></a></div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MAIN_PAGE_COMPONENT']; ?></label>
                    <div class="col-sm-7">
                        <select class="form-control" name="homecom">
                            <option value="" <?php if (!$config['homecom']) { ?>selected="selected"<?php } ?>><?php echo $_LANG['AD_ONLY_MODULES']; ?></option>
                            <?php echo cmsCore::getListItems('cms_components', $config['homecom'], 'title', 'ASC', 'internal=0', 'link'); ?>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_GATE_PAGE']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if ($config['splash']) { echo 'active'; } ?>">
                            <input type="radio" name="splash" <?php if ($config['splash']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['SHOW']; ?>
                        </label>
                        <label class="btn btn-default <?php if (!$config['splash']) { echo 'active'; } ?>">
                            <input type="radio" name="splash" <?php if (!$config['splash']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['HIDE']; ?>
                        </label>
                        <div style="clear:both;"></div>
                        <div class="help-block"><?php echo $_LANG['AD_FIRST_VISIT']; ?></div>
                        <div class="help-block"><?php echo $_LANG['AD_FIRST_VISIT_TEMPLATE']; ?></div>
                    </div>
                </div>
            </div>
        </div>
        
        <div id="cache">
            <div style="width:750px;">
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_CACHE']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if ($config['cache']) { echo 'active'; } ?>">
                            <input type="radio" name="cache" <?php if ($config['cache']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                        </label>
                        <label class="btn btn-default <?php if (!$config['cache']) { echo 'active'; } ?>">
                            <input type="radio" name="cache" <?php if (!$config['cache']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                        </label>
                        <div style="clear:both;"></div>
                        <div class="help-block">
                            <?php echo $_LANG['AD_CACHE_INFO']; ?>
                        </div>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_CACHE_TYPE']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <select class="form-control" name="cache_type" onchange="if ($(this).val() == 'memcached'){$('.memcached').show();}else{$('.memcached').hide();}">
                            <option value="file" <?php if ($config['cache_type'] == 'file') { echo 'selected="selected"'; } ?>>File</option>
                            <?php if (class_exists('Memcached')) { ?>
                                <option value="memcached" <?php if ($config['cache_type'] == 'memcached') { echo 'selected="selected"'; } ?>>Memcached</option>
                            <?php } ?>
                        </select>
                        <div class="help-block">
                            <?php echo $_LANG['AD_CACHE_TYPE_INFO']; ?>
                        </div>
                    </div>
                </div>
                
                <div class="form-group memcached" <?php if ($config['cache_type'] != 'memcached'){ ?>style="display:none;"<?php } ?>>
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MEMCACHED_HOST']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <input type="text" class="form-control" name="memcached_host" value="<?php echo $config['memcached_host']; ?>" />
                        <div class="help-block">
                            <?php echo $_LANG['AD_MEMCACHED_HOST_INFO']; ?>
                        </div>
                    </div>
                </div>
                
                <div class="form-group memcached" <?php if ($config['cache_type'] != 'memcached'){ ?>style="display:none;"<?php } ?>>
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MEMCACHED_PORT']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <input type="number" class="form-control" name="memcached_port" value="<?php echo $config['memcached_port']; ?>" />
                        <div class="help-block">
                            <?php echo $_LANG['AD_MEMCACHED_PORT_INFO']; ?>
                        </div>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-sm-5 control-label">
                        <?php echo $_LANG['AD_COLLECT_CSS']; ?><br/>
                        <input type="checkbox" name="combine_css_enable" value="1" <?php if ($config['combine_css_enable']) { ?>checked="checked"<?php } ?> />
                        <?php echo $_LANG['AD_DO_ENABLE']; ?>
                    </label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <textarea class="form-control" style="height:150px;" name="combine_css"><?php echo cmsCore::getArrVal($config, 'combine_css', ''); ?></textarea>
                        <div class="help-block">
                            <?php echo $_LANG['AD_COLLECT_CSS_INFO']; ?>
                        </div>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-sm-5 control-label">
                        <?php echo $_LANG['AD_COLLECT_JS']; ?>
                        <br/>
                        <input type="checkbox" name="combine_js_enable" value="1" <?php if ($config['combine_js_enable']) { ?>checked="checked"<?php } ?> />
                        <?php echo $_LANG['AD_DO_ENABLE']; ?>
                    </label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <textarea class="form-control" style="height:150px;" name="combine_js"><?php echo cmsCore::getArrVal($config, 'combine_js', ''); ?></textarea>
                        <div class="help-block">
                            <?php echo $_LANG['AD_COLLECT_JS_INFO']; ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <div id="database">
            <div style="width:750px;">
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_DB_SIZE']; ?></label>
                    <div class="col-sm-7">
                        <?php
                            $result = cmsCore::c('db')->query("SELECT (sum(data_length)+sum(index_length))/1024/1024 as size FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '". $config['db_base'] ."'", true);
                            if (!cmsCore::c('db')->error()) {
                                $s = cmsCore::c('db')->fetch_assoc($result);
                                echo round($s['size'], 2) .' '. $_LANG['SIZE_MB'];
                            } else {
                                echo $_LANG['AD_DB_SIZE_ERROR'];
                            }
                        ?>
                        <div class="help-block"><?php echo $_LANG['AD_MYSQL_CONFIG']; ?></div>
                    </div>
                </div>
            </div>
        </div>
        
        <div id="mail">
            <div style="width:750px;">
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SITE_EMAIL']; ?></label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" name="sitemail" value="<?php echo $config['sitemail']; ?>" />
                        <div class="help-block"><?php echo $_LANG['AD_SITE_EMAIL_POST']; ?></div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SENDER_EMAIL']; ?></label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" name="sitemail_name" value="<?php echo $config['sitemail_name']; ?>" />
                        <div class="help-block"><?php echo $_LANG['AD_IF_NOT_HANDLER']; ?></div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SEND_METHOD']; ?></label>
                    <div class="col-sm-7">
                        <select class="form-control" name="mailer">
                            <option value="mail" <?php if ($config['mailer'] == 'mail') { echo 'selected="selected"'; } ?>><?php echo  $_LANG['AD_PHP_MAILER']; ?></option>
                            <option value="sendmail" <?php if ($config['mailer'] == 'sendmail') { echo 'selected="selected"'; } ?>><?php echo  $_LANG['AD_SEND_MAILER']; ?></option>
                            <option value="smtp" <?php if ($config['mailer'] == 'smtp') { echo 'selected="selected"'; } ?>><?php echo  $_LANG['AD_SMTP_MAILER']; ?></option>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_ENCRYPTING']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if (!$config['smtpsecure']) { echo 'active'; } ?>">
                            <input type="radio" name="smtpsecure" <?php if (!$config['smtpsecure']) { echo 'checked="checked"'; } ?> value="" /> <?php echo $_LANG['NO']; ?>
                        </label>

                        <label class="btn btn-default <?php if ($config['smtpsecure'] == 'tls') { echo 'active'; } ?>">
                            <input type="radio" name="smtpsecure" <?php if ($config['smtpsecure'] == 'tls') { echo 'checked="checked"'; } ?> value="tls" /> tls
                        </label>

                        <label class="btn btn-default <?php if ($config['smtpsecure'] == 'ssl') { echo 'active'; } ?>">
                            <input type="radio" name="smtpsecure" <?php if ($config['smtpsecure'] == 'ssl') { echo 'checked="checked"'; } ?> value="ssl" /> ssl
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SMTP_LOGIN']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if ($config['smtpauth']) { echo 'active'; } ?>">
                            <input type="radio" name="smtpauth" <?php if ($config['smtpauth']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                        </label>
                        <label class="btn btn-default <?php if (!$config['smtpauth']) { echo 'active'; } ?>">
                            <input type="radio" name="smtpauth" <?php if (!$config['smtpauth']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SMTP_USER']; ?></label>
                    <div class="col-sm-7">
                        <?php if (!$config['smtpuser']) { ?>
                            <input type="text" class="form-control" name="smtpuser" value="<?php echo $config['smtpuser']; ?>" />
                        <?php } else { ?>
                            <div class="help-block"><?php echo $_LANG['AD_IF_CHANGE_USER']; ?></div>
                        <?php } ?>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SMTP_PASS']; ?></label>
                    <div class="col-sm-7">
                        <?php if (!$config['smtppass']) { ?>
                            <input type="text" class="form-control" name="smtppass" value="<?php echo $config['smtppass']; ?>" />
                        <?php } else { ?>
                            <div class="help-block"><?php echo $_LANG['AD_IF_CHANGE_PASS']; ?></div>
                        <?php } ?>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SMTP_HOST']; ?></label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" name="smtphost" value="<?php echo $config['smtphost']; ?>" />
                        <div class="help-block"><?php echo $_LANG['AD_SOME_HOST']; ?></div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SMTP_PORT']; ?></label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" name="smtpport" value="<?php echo $config['smtpport']; ?>" />
                    </div>
                </div>
            </div>
        </div>
        
        <div id="other">
            <div style="width:750px;">
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_VIEW_PATHWAY']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if ($config['show_pw']) { echo 'active'; } ?>">
                            <input type="radio" name="show_pw" <?php if ($config['show_pw']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                        </label>
                        <label class="btn btn-default <?php if (!$config['show_pw']) { echo 'active'; } ?>">
                            <input type="radio" name="show_pw" <?php if (!$config['show_pw']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                        </label>
                        <div style="clear:both;"></div>
                        <div class="help-block"><?php echo $_LANG['AD_PATH_TO_CATEGORY']; ?></div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MAINPAGE_PATHWAY']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if ($config['index_pw']) { echo 'active'; } ?>">
                            <input type="radio" name="index_pw" <?php if ($config['index_pw']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                        </label>
                        <label class="btn btn-default <?php if (!$config['index_pw']) { echo 'active'; } ?>">
                            <input type="radio" name="index_pw" <?php if (!$config['index_pw']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_PAGE_PATHWAY']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if (!$config['last_item_pw']) { echo 'active'; } ?>">
                            <input type="radio" name="last_item_pw" <?php if (!$config['last_item_pw']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['HIDE']; ?>
                        </label>

                        <label class="btn btn-default <?php if ($config['last_item_pw'] == 1) { echo 'active'; } ?>">
                            <input type="radio" name="last_item_pw" <?php if (!$config['last_item_pw'] == 1) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['AD_PAGE_PATHWAY_LINK']; ?>
                        </label>

                        <label class="btn btn-default <?php if ($config['last_item_pw'] == 2) { echo 'active'; } ?>">
                            <input type="radio" name="last_item_pw" <?php if (!$config['last_item_pw'] == 2) { echo 'checked="checked"'; } ?> value="2" /> <?php echo $_LANG['AD_PAGE_PATHWAY_TEXT']; ?>
                        </label>
                    </div>
                </div>
            </div>
        </div>
        
        <div id="seq">
            <div style="width:750px;">
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_IP_ADMIN']; ?></label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" name="allow_ip" value="<?php echo htmlspecialchars($config['allow_ip']); ?>" />
                        <div class="help-block"><?php echo $_LANG['AD_IP_COMMA']; ?></div>
                    </div>
                </div>

                <p style="color:#900"><?php echo $_LANG['AD_ATTENTION']; ?></p>
            </div>
        </div>     
    
        <div id="soc_apps">
            <div style="width:750px;">
                <div class="form-group">
                    <label class="col-sm-5 control-label"><?php echo $_LANG['AD_IFRAME_ENABLE']; ?></label>
                    <div class="col-sm-7 btn-group" data-toggle="buttons">
                        <label class="btn btn-default <?php if (cmsCore::getArrVal($config, 'iframe_enable')) { echo 'active'; } ?>">
                            <input type="radio" name="iframe_enable" <?php if (cmsCore::getArrVal($config, 'iframe_enable')) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                        </label>
                        <label class="btn btn-default <?php if (!cmsCore::getArrVal($config, 'iframe_enable')) { echo 'active'; } ?>">
                            <input type="radio" name="iframe_enable" <?php if (!cmsCore::getArrVal($config, 'iframe_enable')) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                        </label>
                    </div>
                </div>

                <fieldset>
                    <legend>VK.COM</legend>
                    
                    <div class="form-group">
                        <label class="col-sm-5 control-label"><?php echo $_LANG['AD_ENABLE']; ?></label>
                        <div class="col-sm-7 btn-group" data-toggle="buttons">
                            <label class="btn btn-default <?php if ($config['vk_enable']) { echo 'active'; } ?>">
                                <input type="radio" name="vk_enable" <?php if ($config['vk_enable']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                            </label>
                            <label class="btn btn-default <?php if (!$config['vk_enable']) { echo 'active'; } ?>">
                                <input type="radio" name="vk_enable" <?php if (!$config['vk_enable']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                            </label>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label class="col-sm-5 control-label"><?php echo $_LANG['AD_IFRAME_APP_ID']; ?></label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" name="vk_id" value="<?php echo $config['vk_id']; ?>" />
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label class="col-sm-5 control-label"><?php echo $_LANG['AD_IFRAME_APP_PRIVATE_KEY']; ?></label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" name="vk_private_key" value="<?php echo $config['vk_private_key']; ?>" />
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
    </div>
    
    <div>
        <input type="hidden" name="do" value="save" />
        
        <input type="submit" class="btn btn-primary" name="save" value="<?php echo $_LANG['SAVE']; ?>" />
        <input type="button" class="btn btn-default" name="back" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.history.back();" />
    </div>
</form>
<?php
}