Ejemplo n.º 1
0
function applet_filters() {
    global $_LANG;
    
    global $adminAccess;
    
    if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) { cpAccessDenied(); }
    if (!cmsUser::isAdminCan('admin/filters', $adminAccess)) { cpAccessDenied(); }
    
    cmsCore::c('page')->setTitle($_LANG['AD_FILTERS']);
    cpAddPathway($_LANG['AD_FILTERS'], 'index.php?view=filters');

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

    if ($do == 'hide') {
        cmsCore::c('db')->setFlag('cms_filters', $id, 'published', '0');
        cmsCore::halt('1');
    }

    if ($do == 'show') {
        cmsCore::c('db')->setFlag('cms_filters', $id, 'published', '1');
        cmsCore::halt('1');
    }

    if ($do == 'list') {
        $fields = array(
            array( 'title' =>  'id', 'field' => 'id', 'width' => '40' ),
            array( 'title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '250' ),
            array( 'title' => $_LANG['DESCRIPTION'], 'field' => 'description', 'width' => '' ),
            array( 'title' => $_LANG['AD_ENABLE'], 'field' => 'published', 'width' => '100' )
        );

        cpListTable('cms_filters', $fields, array());
    }
}
Ejemplo n.º 2
0
function applet_noaccess()
{
    global $_LANG;
    cmsCore::c('page')->setTitle($_LANG['ACCESS_DENIED']);
    cpAddPathway($_LANG['ACCESS_DENIED'], 'index.php?view=noaccess');
    cmsCore::c('page')->initTemplate('applets', 'noaccess')->display();
}
Ejemplo n.º 3
0
function applet_filters()
{
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) {
        cpAccessDenied();
    }
    if (!cmsUser::isAdminCan('admin/filters', $adminAccess)) {
        cpAccessDenied();
    }
    $GLOBALS['cp_page_title'] = $_LANG['AD_FILTERS'];
    cpAddPathway($_LANG['AD_FILTERS'], 'index.php?view=filters');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    if ($do == 'hide') {
        dbHide('cms_filters', $id);
        echo '1';
        exit;
    }
    if ($do == 'show') {
        dbShow('cms_filters', $id);
        echo '1';
        exit;
    }
    if ($do == 'list') {
        $fields[] = array('title' => 'id', 'field' => 'id', 'width' => '30');
        $fields[] = array('title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '250');
        $fields[] = array('title' => $_LANG['DESCRIPTION'], 'field' => 'description', 'width' => '');
        $fields[] = array('title' => $_LANG['AD_ENABLE'], 'field' => 'published', 'width' => '100');
        $actions = array();
        cpListTable('cms_filters', $fields, $actions);
    }
}
Ejemplo n.º 4
0
function applet_robots()
{
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/robots', $adminAccess)) {
        cpAccessDenied();
    }
    cmsCore::c('page')->setTitle($_LANG['ROBOTS_TITLE']);
    cpAddPathway($_LANG['ROBOTS_TITLE']);
    $do = cmsCore::request('do', array('edit', 'save'), 'edit');
    if (!file_exists(PATH . '/robots.txt')) {
        $fp = fopen(PATH . '/robots.txt', 'w');
        fwrite($fp, str_replace(array('%domen%', '%host%'), array(str_replace(array('https://', 'http://'), '', cmsCore::c('config')->host), cmsCore::c('config')->host), file_get_contents(PATH . '/includes/default_robots.txt')));
        fclose($fp);
        chmod(PATH . '/robots.txt', 0777);
    }
    if ($do == 'save') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $data = cmsCore::request('robots', 'str');
        $fp = fopen(PATH . '/robots.txt', 'w');
        fwrite($fp, stripcslashes($data) . "\n");
        fclose($fp);
    }
    $robots = file_get_contents(PATH . '/robots.txt');
    cmsCore::c('page')->initTemplate('applets', 'robots')->assign('robots', $robots)->display();
}
Ejemplo n.º 5
0
function applet_noaccess()
{
    global $_LANG;
    $GLOBALS['cp_page_title'] = $_LANG['ACCESS_DENIED'];
    cpAddPathway($_LANG['ACCESS_DENIED'], 'index.php?view=noaccess');
    echo '<h3>' . $_LANG['ACCESS_DENIED'] . '</h3>';
    echo '<p>' . $_LANG['AD_ACCESS_DENIED_TEXT'] . '</p>';
    echo '<p><a href="javascript:void(0)" onclick="window.history.go(-1)">' . $_LANG['BACK'] . '</a></p>';
}
Ejemplo n.º 6
0
function applet_noaccess(){
    global $_LANG;

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

    echo '<h3>'. $_LANG['ACCESS_DENIED'] .'</h3>';
    echo '<p>'. $_LANG['AD_ACCESS_DENIED_TEXT'] .'</p>';
    echo '<p><a href="javascript:void(0)" onclick="window.history.go(-1)">'. $_LANG['BACK'] .'</a></p>';
}
Ejemplo n.º 7
0
function applet_templates()
{
    global $adminAccess;
    global $_LANG;
    if (!cmsUser::isAdminCan('admin/config', $adminAccess)) {
        cpAccessDenied();
    }
    $do = cmsCore::request('do', array('config', 'save_config'), 'main');
    cmsCore::c('page')->setTitle($_LANG['AD_TEMPLATES_SETTING']);
    cpAddPathway($_LANG['AD_TEMPLATES_SETTING'], 'index.php?view=templates');
    if ($do == 'main') {
        cmsCore::c('page')->initTemplate('applets', 'templates')->assign('templates', cmsCore::getDirsList('/templates'))->display();
    }
    if ($do == 'config') {
        $template = cmsCore::request('template', 'str', '');
        cpAddPathway($_LANG['AD_TEMPLATE'] . ': ' . $template, 'index.php?view=templates&do=config&template=' . $template);
        if (!file_exists(PATH . '/templates/' . $template) || !file_exists(PATH . '/templates/' . $template . '/config.php')) {
            cmsCore::error404();
        }
        include PATH . '/templates/' . $template . '/config.php';
        if (function_exists('get_template_cfg_fields')) {
            $tpl_cfgs = get_template_cfg_fields();
            if (!empty($tpl_cfgs)) {
                $tpl_cfgs_val = cmsCore::getTplCfg($template);
                cmsCore::c('page')->initTemplate('applets', 'templates')->assign('template', $template)->assign('form_gen_form', cmsCore::c('form_gen')->generateForm($tpl_cfgs, $tpl_cfgs_val))->display();
            } else {
                cmsCore::addSessionMessage($_LANG['AD_TEMPLATE_NO_CONFIG'], 'error');
                cmsCore::redirectBack();
            }
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TEMPLATE_CFG_ERROR'], 'error');
            cmsCore::redirectBack();
        }
    }
    if ($do == 'save_config') {
        $template = cmsCore::request('template', 'str', '');
        if (!file_exists(PATH . '/templates/' . $template) || !file_exists(PATH . '/templates/' . $template . '/config.php') || !cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        include PATH . '/templates/' . $template . '/config.php';
        if (function_exists('get_template_cfg_fields')) {
            $tpl_cfgs = get_template_cfg_fields();
            if (!empty($tpl_cfgs)) {
                $tpl_cfgs = cmsCore::c('form_gen')->requestForm($tpl_cfgs);
                cmsCore::saveTplCfg($tpl_cfgs, $template);
                cmsCore::addSessionMessage($_LANG['AD_TEMPLATE_CFG_SAVED'], 'success');
                cmsCore::redirect('/admin/index.php?view=templates');
            } else {
                cmsCore::error404();
            }
        } else {
            cmsCore::error404();
        }
    }
}
Ejemplo n.º 8
0
function applet_arhive()
{
    $inCore = cmsCore::getInstance();
    global $_LANG;
    cmsCore::c('page')->setTitle($_LANG['AD_ARTICLES_ARCHIVE']);
    $cfg = $inCore->loadComponentConfig('content');
    $cfg_arhive = $inCore->loadComponentConfig('arhive');
    cpAddPathway($_LANG['AD_ARTICLE_SITE'], 'index.php?view=tree');
    cpAddPathway($_LANG['AD_ARTICLES_ARCHIVE'], 'index.php?view=arhive');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    if ($do == 'saveconfig') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $cfg['source'] = cmsCore::request('source', 'str', '');
        $inCore->saveComponentConfig('arhive', $cfg);
        cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success');
        cmsCore::redirect('?view=arhive&do=config');
    }
    if ($do == 'config') {
        $toolmenu = array(array('icon' => 'folders.gif', 'title' => $_LANG['AD_LIST_OF_ARTICLES'], 'link' => '?view=arhive'));
        cpToolMenu($toolmenu);
        cpAddPathway($_LANG['AD_SETTINGS'], 'index.php?view=arhive&do=config');
        cmsCore::c('page')->initTemplate('applets', 'arhive')->assign('cfg_arhive', $cfg_arhive)->display();
    }
    if ($do == 'list') {
        $toolmenu = array(array('icon' => 'config.gif', 'title' => $_LANG['AD_SETTINGS'], 'link' => '?view=arhive&do=config'), array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=arhive&do=delete&multiple=1');"));
        cpToolMenu($toolmenu);
        //TABLE COLUMNS
        $fields = array(array('title' => 'id', 'field' => 'id', 'width' => '40'), array('title' => $_LANG['AD_CREATE'], 'field' => 'pubdate', 'width' => '80', 'filter' => 15, 'fdate' => '%d/%m/%Y'), array('title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '', 'link' => '?view=content&do=edit&id=%id%', 'filter' => 15), array('title' => $_LANG['AD_PARTITION'], 'field' => 'category_id', 'width' => '150', 'filter' => 1, 'prc' => 'cpCatById', 'filterlist' => cpGetList('cms_category')));
        //ACTIONS
        $actions = array(array('title' => $_LANG['AD_TO_ARTICLES_CATALOG'], 'icon' => 'arhive_off.gif', 'link' => '?view=arhive&do=arhive_off&id=%id%'), array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'link' => '?view=content&do=delete&id=%id%', 'confirm' => $_LANG['AD_DELETE_MATERIALS']));
        //Print table
        cpListTable('cms_content', $fields, $actions, 'is_arhive=1');
    }
    if ($do == 'arhive_off') {
        if (cmsCore::inRequest('id')) {
            cmsCore::c('db')->setFlag('cms_content', $id, 'is_arhive', '0');
            cmsCore::redirect('?view=arhive');
        }
    }
    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) {
                cmsCore::m('content')->deleteArticle($id, $cfg['af_delete']);
            }
        } else {
            cmsCore::m('content')->deleteArticles(cmsCore::request('item', 'array_int'), $cfg['af_delete']);
        }
        cmsCore::redirect('?view=arhive');
    }
}
Ejemplo n.º 9
0
function applet_phpinfo()
{
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/config', $adminAccess)) {
        cpAccessDenied();
    }
    cmsCore::c('page')->setTitle($_LANG['AD_PHP_INFO']);
    cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config');
    cpAddPathway($_LANG['AD_PHP_INFO'], 'index.php?view=phpinfo');
    ob_start();
    phpinfo();
    cmsCore::c('page')->initTemplate()->assign('phpinfo', ob_get_clean())->display();
}
Ejemplo n.º 10
0
function applet_robots() {
    global $_LANG;
    global $adminAccess;
    
    if (!cmsUser::isAdminCan('admin/robots', $adminAccess)) { cpAccessDenied(); }
    
    cmsCore::c('page')->setTitle($_LANG['ROBOTS_TITLE']);

    cpAddPathway($_LANG['ROBOTS_TITLE']);

    $do = cmsCore::request('do', array('edit', 'save'), 'edit');

    if (!file_exists(PATH .'/robots.txt')) {
        $fp = fopen(PATH .'/robots.txt', 'w');
        fwrite($fp, str_replace(array('%domen%', '%host%'), array(str_replace(array('https://', 'http://'), '', cmsCore::c('config')->host), cmsCore::c('config')->host), file_get_contents(PATH .'/includes/default_robots.txt')));
        fclose ($fp);
        chmod(PATH .'/robots.txt', 0777);
    }

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

        $data = cmsCore::request('robots', 'str');
        
        $fp = fopen(PATH .'/robots.txt', 'w');
        fwrite($fp, stripcslashes($data) ."\n");
        fclose ($fp);
    }

    $robots = file_get_contents(PATH .'/robots.txt');
?>
<form action="" method="post">
    <div style="width:650px;">
        <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
        
        <div class="form-group">
            <label><?php echo $_LANG['ROBOTS_TXT_DATA']; ?></label>
            <textarea name="robots" class="form-control" style="height: 400px;"><?php echo $robots; ?></textarea>
            <div class="help-block"><?php echo $_LANG['ROBOTS_TXT_INFO']; ?></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
}
Ejemplo n.º 11
0
function applet_tree()
{
    $inCore = cmsCore::getInstance();
    cmsCore::loadLib('tags');
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/content', $adminAccess)) {
        cpAccessDenied();
    }
    cmsCore::c('page')->setTitle($_LANG['AD_ARTICLES']);
    cpAddPathway($_LANG['AD_ARTICLES'], 'index.php?view=tree');
    cmsCore::c('page')->addHeadJS('admin/js/content.js');
    echo '<script>';
    echo cmsPage::getLangJS('AD_NO_SELECTED_ARTICLES');
    echo cmsPage::getLangJS('AD_DELETE_SELECTED_ARTICLES');
    echo cmsPage::getLangJS('AD_PIECES');
    echo cmsPage::getLangJS('AD_CATEGORY_DELETE');
    echo cmsPage::getLangJS('AD_AND_SUB_CATS');
    echo cmsPage::getLangJS('AD_DELETE_SUB_ARTICLES');
    echo '</script>';
    $do = cmsCore::request('do', 'str', 'tree');
    if ($do == 'tree') {
        $toolmenu = array(array('icon' => 'config.gif', 'title' => $_LANG['AD_SETUP_CATEGORY'], 'link' => '?view=components&do=config&link=content'), array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=components&do=config&link=content'));
        cpToolMenu($toolmenu);
        $only_hidden = cmsCore::request('only_hidden', 'int', 0);
        $category_id = cmsCore::request('cat_id', 'int', 0);
        $base_uri = 'index.php?view=tree';
        $title_part = cmsCore::request('title', 'str', '');
        $def_order = $category_id ? 'con.ordering' : 'pubdate';
        $orderby = cmsCore::request('orderby', 'str', $def_order);
        $orderto = cmsCore::request('orderto', 'str', 'asc');
        $page = cmsCore::request('page', 'int', 1);
        $perpage = 20;
        if ($category_id) {
            cmsCore::m('content')->whereCatIs($category_id);
        }
        if ($title_part) {
            cmsCore::c('db')->where('LOWER(con.title) LIKE \'%' . mb_strtolower($title_part) . '%\'');
        }
        if ($only_hidden) {
            cmsCore::c('db')->where('con.published = 0');
        }
        cmsCore::c('db')->orderBy($orderby, $orderto);
        cmsCore::c('db')->limitPage($page, $perpage);
        $total = cmsCore::m('content')->getArticlesCount(false);
        cmsCore::c('page')->initTemplate('applets', 'tree')->assign('hide_cats', cmsCore::request('hide_cats', 'int', 0))->assign('only_hidden', $only_hidden)->assign('base_uri', $base_uri)->assign('category_id', $category_id)->assign('cats', cmsCore::m('content')->getCatsTree())->assign('orderto', $orderto)->assign('orderby', $orderby)->assign('title_part', $title_part)->assign('category_opt', $inCore->getListItemsNS('cms_category', $category_id))->assign('page', $page)->assign('total', $total)->assign('perpage', $perpage)->assign('pages', ceil($total / $perpage))->assign('items', cmsCore::m('content')->getArticlesList(false))->display();
    }
}
Ejemplo n.º 12
0
function applet_phpinfo() {
    global $_LANG;
	global $adminAccess;
	if (!cmsUser::isAdminCan('admin/config', $adminAccess)) { cpAccessDenied(); }

	cmsCore::c('page')->setTitle($_LANG['AD_PHP_INFO']);

	cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config');
	cpAddPathway($_LANG['AD_PHP_INFO'], 'index.php?view=phpinfo');
?>
<div>
	<h3><?php echo $_LANG['AD_PHP_INFO']; ?></h3>
    <iframe src="/admin/includes/phpinfo.php" style="border:none;width:100%;height:600px" />
</div>
<?php
}
Ejemplo n.º 13
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();
}
Ejemplo n.º 14
0
function applet_plugins()
{
    global $_LANG;
    $inCore = cmsCore::getInstance();
    $GLOBALS['cp_page_title'] = $_LANG['AD_PLUGINS'];
    cpAddPathway($_LANG['AD_PLUGINS'], 'index.php?view=plugins');
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) {
        cpAccessDenied();
    }
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    // ===================================================================================== //
    if ($do == 'hide') {
        dbHide('cms_plugins', $id);
        echo '1';
        exit;
    }
    // ===================================================================================== //
    if ($do == 'show') {
        dbShow('cms_plugins', $id);
        echo '1';
        exit;
    }
    // ===================================================================================== //
    if ($do == 'list') {
        $toolmenu = array();
        $toolmenu[1]['icon'] = 'install.gif';
        $toolmenu[1]['title'] = $_LANG['AD_INSTALL_PLUGINS'];
        $toolmenu[1]['link'] = '?view=install&do=plugin';
        cpToolMenu($toolmenu);
        $plugin_id = cmsCore::request('installed', 'str', '');
        if ($plugin_id) {
            $task = cmsCore::request('task', 'str', 'install');
            if ($task == 'install' || $task == 'upgrade') {
                $plugin = $inCore->loadPlugin($plugin_id);
                $task_str = $task == 'install' ? $_LANG['AD_IS_INSTALL'] : $_LANG['AD_IS_UPDATE'];
                echo '<div style="color:green;margin-top:12px;margin-bottom:5px;">' . $_LANG['AD_PLUGIN'] . ' <strong>"' . $plugin->info['title'] . '"</strong> ' . $task_str . '. ' . $_LANG['AD_ENABLE_PLUGIN'] . '.</div>';
            }
            if ($task == 'remove') {
                echo '<div style="color:green;margin-top:12px;margin-bottom:5px;">' . $_LANG['AD_REMOVE_PLUGIN_OK'] . '.</div>';
            }
        }
        $fields = array();
        $fields[0]['title'] = 'id';
        $fields[0]['field'] = 'id';
        $fields[0]['width'] = '20';
        $fields[1]['title'] = $_LANG['TITLE'];
        $fields[1]['field'] = 'title';
        $fields[1]['width'] = '250';
        $fields[2]['title'] = $_LANG['DESCRIPTION'];
        $fields[2]['field'] = 'description';
        $fields[2]['width'] = '';
        $fields[3]['title'] = $_LANG['AD_AUTHOR'];
        $fields[3]['field'] = 'author';
        $fields[3]['width'] = '160';
        $fields[4]['title'] = $_LANG['AD_VERSION'];
        $fields[4]['field'] = 'version';
        $fields[4]['width'] = '50';
        $fields[5]['title'] = $_LANG['AD_FOLDER'];
        $fields[5]['field'] = 'plugin';
        $fields[5]['width'] = '100';
        $fields[6]['title'] = $_LANG['AD_ENABLE'];
        $fields[6]['field'] = 'published';
        $fields[6]['width'] = '60';
        $actions = array();
        $actions[0]['title'] = $_LANG['AD_CONFIG'];
        $actions[0]['icon'] = 'config.gif';
        $actions[0]['link'] = '?view=plugins&do=config&id=%id%';
        $actions[1]['title'] = $_LANG['DELETE'];
        $actions[1]['icon'] = 'delete.gif';
        $actions[1]['confirm'] = $_LANG['AD_REMOVE_PLUGIN_FROM'];
        $actions[1]['link'] = '?view=install&do=remove_plugin&id=%id%';
        cpListTable('cms_plugins', $fields, $actions);
    }
    // ===================================================================================== //
    if ($do == 'save_config') {
        if (!cmsCore::validateForm()) {
            cmsCore::error404();
        }
        $plugin_name = cmsCore::request('plugin', 'str', 0);
        $config = cmsCore::request('config', 'array_str');
        if (!$config || !$plugin_name) {
            cmsCore::redirectBack();
        }
        $inCore->savePluginConfig($plugin_name, $config);
        cmsUser::clearCsrfToken();
        cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success');
        cmsCore::redirect('index.php?view=plugins');
    }
    // ===================================================================================== //
    if ($do == 'config') {
        $plugin_name = $inCore->getPluginById($id);
        if (!$plugin_name) {
            cmsCore::error404();
        }
        $plugin = $inCore->loadPlugin($plugin_name);
        $config = $inCore->loadPluginConfig($plugin_name);
        $GLOBALS['cp_page_title'] = $plugin->info['title'];
        cpAddPathway($plugin->info['title'], 'index.php?view=plugins&do=config&id=' . $id);
        echo '<h3>' . $plugin->info['title'] . '</h3>';
        if (!$config) {
            echo '<p>' . $_LANG['AD_PLUGIN_DISABLE'] . '.</p>';
            echo '<p><a href="javascript:window.history.go(-1);">' . $_LANG['BACK'] . '</a></p>';
            return;
        }
        echo '<form action="index.php?view=plugins&do=save_config&plugin=' . $plugin_name . '" method="POST">';
        echo '<input type="hidden" name="csrf_token" value="' . cmsUser::getCsrfToken() . '" />';
        echo '<table class="proptable" width="605" cellpadding="8" cellspacing="0" border="0">';
        foreach ($config as $field => $value) {
            echo '<tr>';
            echo '<td width="150"><strong>' . (isset($_LANG[mb_strtoupper($field)]) ? $_LANG[mb_strtoupper($field)] : $field) . ':</strong></td>';
            echo '<td><input type="text" style="width:90%" name="config[' . $field . ']" value="' . htmlspecialchars($value) . '" /></td>';
            echo '</tr>';
        }
        echo '</table>';
        echo '<div style="margin-top:6px;">';
        echo '<input type="submit" name="save" value="' . $_LANG['SAVE'] . '" /> ';
        echo '<input type="button" name="back" value="' . $_LANG['CANCEL'] . '" onclick="window.history.go(-1)" />';
        echo '</div>';
        echo '</form>';
    }
    // ===================================================================================== //
}
Ejemplo n.º 15
0
if (!defined('VALID_CMS_ADMIN')) {
    die('ACCESS DENIED');
}
/******************************************************************************/
//                                                                            //
//                             InstantCMS v1.9                                //
//                        http://www.instantcms.ru/                           //
//                                                                            //
//                   written by InstantCMS Team, 2007-2011                    //
//                produced by InstantSoft, (www.instantsoft.ru)               //
//                                                                            //
//                        LICENSED BY GNU/GPL v2                              //
//                                                                            //
/******************************************************************************/
cpAddPathway('Регистрация', '?view=components&do=config&id=' . $_REQUEST['id']);
echo '<h3>Регистрация</h3>';
if (isset($_REQUEST['opt'])) {
    $opt = $_REQUEST['opt'];
} else {
    $opt = 'list';
}
$toolmenu = array();
$toolmenu[0]['icon'] = 'save.gif';
$toolmenu[0]['title'] = 'Сохранить';
$toolmenu[0]['link'] = 'javascript:document.optform.submit();';
$toolmenu[1]['icon'] = 'cancel.gif';
$toolmenu[1]['title'] = 'Отмена';
$toolmenu[1]['link'] = '?view=components';
cpToolMenu($toolmenu);
$GLOBALS['cp_page_head'][] = '<script type="text/javascript" src="/includes/jquery/jquery.form.js"></script>';
Ejemplo n.º 16
0
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
   }
}
Ejemplo n.º 17
0
function applet_install() {
    $inCore = cmsCore::getInstance();
    global $_LANG;
    
    cmsCore::c('page')->setTitle($_LANG['AD_SETUP_EXTENSION']);

    $do = cmsCore::request('do', 'str', 'list');
    
    global $adminAccess;
    
    //-------------------------------- Модули ----------------------------------
    //----------- Список модулей готовых к установке или обновлению ------------
    if ($do == 'module') {
        if (!cmsUser::isAdminCan('admin/modules', $adminAccess)) { cpAccessDenied(); }

      	cpAddPathway($_LANG['AD_SETUP_MODULES'], 'index.php?view=install&do=module');

        $new_modules = $inCore->getNewModules();
        $upd_modules = $inCore->getUpdatedModules();

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

        if (!$new_modules && !$upd_modules) {
            echo '<p>'. $_LANG['AD_NO_SEARCH_MODULES'] .'</p>';
            echo '<p>'. $_LANG['AD_IF_WANT_SETUP_MODULES'] .'</p>';
            echo '<p><a class="btn btn-default" href="javascript:window.history.go(-1);">'. $_LANG['BACK'] .'</a></p>';
            return;
        }

        if ($new_modules) {
            echo '<div class="panel panel-default"><div class="panel-heading">'. $_LANG['AD_SEARCH_MODULES'] .'</div><div class="panel-body">';
                modulesList($new_modules, $_LANG['AD_SETUP'], 'install_module');
            echo '</div></div>';
        }

        if ($upd_modules) {
            echo '<div class="panel panel-default"><div class="panel-heading">'. $_LANG['AD_MODULES_UPDATE'] .'</div><div class="panel-body">';
                modulesList($upd_modules, $_LANG['AD_UPDATE'], 'upgrade_module');
            echo '</div></div>';
        }

        echo '<p><a class="btn btn-default" href="javascript:window.history.go(-1);">'. $_LANG['BACK'] .'</a></p>';
    }
    
    //--------------------------- Установка модуля -----------------------------
    if ($do == 'install_module') {

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

        $error = '';

        $module_id = cmsCore::request('id', 'str', '');

        if(!$module_id){ cmsCore::redirectBack(); }

        if ($inCore->loadModuleInstaller($module_id)){
            $_module = call_user_func('info_module_'.$module_id);
            //////////////////////////////////////
            $error   = call_user_func('install_module_'.$module_id);
        } else {
            $error = $_LANG['AD_MODULE_WIZARD_FAILURE'];
        }

        if ($error === true) {
            $inCore->installModule($_module, $_module['config']);
            cmsCore::addSessionMessage($_LANG['AD_MODULE'].' <strong>"'.$_module['title'].'"</strong> '.$_LANG['AD_SUCCESS'].$_LANG['AD_IS_INSTALL'], 'success');
            cmsCore::redirect('/admin/index.php?view=modules');
        } else {
            cmsCore::addSessionMessage($error , 'error');
            cmsCore::redirectBack();
        }

    }
    
    //--------------------------- Обновление модуля ----------------------------
    if ($do == 'upgrade_module') {
	if (!cmsUser::isAdminCan('admin/modules', $adminAccess)) { cpAccessDenied(); }

        $error = '';

        $module_id = cmsCore::request('id', 'str', '');

        if(!$module_id){ cmsCore::redirectBack(); }

        if ($inCore->loadModuleInstaller($module_id)) {
            $_module = call_user_func('info_module_'.$module_id);
            if (isset($_module['link'])) {
                $_module['content'] = $_module['link'];
            }
            $error = call_user_func('upgrade_module_'.$module_id);
        } else {
            $error = $_LANG['AD_SETUP_WIZARD_FAILURE'];
        }

        if ($error === true) {
            $inCore->upgradeModule($_module, $_module['config']);
            cmsCore::addSessionMessage($_LANG['AD_MODULE'].' <strong>"'.$_module['title'].'"</strong> '.$_LANG['AD_SUCCESS'].$_LANG['AD_IS_UPDATE'], 'success');
            cmsCore::redirect('/admin/index.php?view=modules');
        } else {
            cmsCore::addSessionMessage($error , 'error');
            cmsCore::redirectBack();
        }

    }
    //==========================================================================
    
    //------------------------------ Компоненты --------------------------------
    //--------- Список компонентов готовых к установке или обновлению ----------
    if ($do == 'component') {
        if (!cmsUser::isAdminCan('admin/components', $adminAccess)) { cpAccessDenied(); }

      	cpAddPathway($_LANG['AD_SETUP_COMPONENTS'], 'index.php?view=install&do=component');

        $new_components = $inCore->getNewComponents();
        $upd_components = $inCore->getUpdatedComponents();

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

        if (!$new_components && !$upd_components) {
            echo '<p>'. $_LANG['AD_NO_SEARCH_COMPONENTS'] .'</p>';
            echo '<p>'. $_LANG['AD_IF_WANT_SETUP_COMPONENTS'] .'</p>';
            echo '<p><a href="javascript:window.history.go(-1);" class="btn btn-default">'. $_LANG['BACK'] .'</a></p>';
            return;
        }

        if ($new_components) {
            echo '<div class="panel panel-default"><div class="panel-heading">'. $_LANG['AD_COMPONENTS_SETUP'] .'</div><div class="panel-body">';
                componentsList($new_components, $_LANG['AD_SETUP'], 'install_component');
            echo '</div></div>';
        }

        if ($upd_components) {
            echo '<div class="panel panel-default"><div class="panel-heading">'. $_LANG['AD_COMPONENTS_UPDATE'] .'</div><div class="panel-body">';
                componentsList($upd_components, $_LANG['AD_UPDATE'], 'upgrade_component');
            echo '</div></div>';

        }

        echo '<p><a href="javascript:window.history.go(-1);" class="btn btn-default">'. $_LANG['BACK'] .'</a></p>';
    }

    //------------------------- Установка компонента ---------------------------
    if ($do == 'install_component') {
        $error = '';

        $component = cmsCore::request('id', 'str', '');
        if (!$component) { cmsCore::redirectBack(); }

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

        if ($inCore->loadComponentInstaller($component)) {
            $_component = call_user_func('info_component_'.$component);
            $error      = call_user_func('install_component_'.$component);
        } else {
            $error = $_LANG['AD_COMPONENT_WIZARD_FAILURE'];
        }

        if ($error === true) {
            $inCore->installComponent($_component, $_component['config']);

            $info_text = '<p>'. $_LANG['AD_COMPONENT'] .' <strong>"'. $_component['title'] .'"</strong> '. $_LANG['AD_SUCCESS'] . $_LANG['AD_IS_INSTALL'] .'</p>';
            if (isset($_component['modules'])){
                if (is_array($_component['modules'])) {
                    $info_text .= '<p>'. $_LANG['AD_OPT_INSTALL_MODULES'] .':</p>';
                    $info_text .= '<ul>';
                        foreach ($_component['modules'] as $module => $title) {
                            $info_text .= '<li>'. $title .'</li>';
                        }
                    $info_text .= '</ul>';
                }
            }
            if (isset($_component['plugins'])){
                if(is_array($_component['plugins'])){
                    $info_text .= '<p>'. $_LANG['AD_OPT_INSTALL_PLUGINS'] .':</p>';
                    $info_text .= '<ul>';
                        foreach($_component['plugins'] as $module=>$title){
                            $info_text .= '<li>'. $title .'</li>';
                        }
                    $info_text .= '</ul>';
                }
            }

            cmsCore::addSessionMessage($info_text, 'success');
            cmsCore::redirect('/admin/index.php?view=components');
        } else {
            cmsCore::addSessionMessage($error , 'error');
            cmsCore::redirectBack();
        }

    }

    //------------------------- Обновление компонента --------------------------
    if ($do == 'upgrade_component') {
        cpAddPathway($_LANG['AD_UPDATE_COMPONENTS'], 'index.php?view=install&do=component');

        $error = '';

        $component = cmsCore::request('id', 'str', '');
        if (!$component) { cmsCore::redirectBack(); }

		if (!cmsUser::isAdminCan('admin/components', $adminAccess)) { cpAccessDenied(); }
		if (!cmsUser::isAdminCan('admin/com_'.$component, $adminAccess)) { cpAccessDenied(); }

        if ($inCore->loadComponentInstaller($component)) {
            $_component = call_user_func('info_component_'.$component);
            $error      = call_user_func('upgrade_component_'.$component);
        } else {
            $error = $_LANG['AD_COMPONENT_WIZARD_FAILURE'];
        }

        if ($error === true) {
            $inCore->upgradeComponent($_component, $_component['config']);
            $info_text = $_LANG['AD_COMPONENT'].' <strong>"'.$_component['title'].'"</strong> '.$_LANG['AD_SUCCESS'].$_LANG['AD_IS_UPDATE'];
            cmsCore::addSessionMessage($info_text, 'success');
            cmsCore::redirect('/admin/index.php?view=components');
        } else {
            cmsCore::addSessionMessage($error , 'error');
            cmsCore::redirectBack();
        }

    }

    //-------------------------- Удаление компонента ---------------------------
    if ($do == 'remove_component') {
        $component_id = cmsCore::request('id', 'int', '');

        if (!$component_id) { cmsCore::redirectBack(); }
        
        $com = $inCore->getComponentById($component_id);
        if (!cmsUser::isAdminCan('admin/components', $adminAccess)) { cpAccessDenied(); }
        if (!cmsUser::isAdminCan('admin/com_'.$com, $adminAccess)) { cpAccessDenied(); }

        if ($inCore->loadComponentInstaller($com)) {
            if (function_exists('remove_component_'. $com)) {
            	call_user_func('remove_component_'. $com);
            }
        }

        $inCore->removeComponent($component_id);

        cmsCore::addSessionMessage($_LANG['AD_COMPONENT_IS_DELETED'], 'success');
        cmsCore::redirect('/admin/index.php?view=components');
    }
    //==========================================================================

    //------------------------------- Плагины ----------------------------------
    //---------- Список плагинов готовых к установке или обновлению ------------
    if ($do == 'plugin') {
        if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) { cpAccessDenied(); }

      	cpAddPathway($_LANG['AD_SETUP_PLUGINS']	, 'index.php?view=install&do=plugin');

        $new_plugins = $inCore->getNewPlugins();
        $upd_plugins = $inCore->getUpdatedPlugins();

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

        if (!$new_plugins && !$upd_plugins) {
            echo '<p>'. $_LANG['AD_NO_SEARCH_PLUGINS'] .'</p>';
            echo '<p>'. $_LANG['AD_IF_WANT_SETUP_PLUGINS'] .'</p>';
            echo '<p><a href="javascript:window.history.go(-1);" class="btn btn-default">'. $_LANG['BACK'] .'</a></p>';
            return;
        }

        if ($new_plugins) {
            echo '<div class="panel panel-default"><div class="panel-heading">'. $_LANG['AD_PLUGINS_SETUP'] .'</div><div class="panel-body">';
                pluginsList($new_plugins, $_LANG['AD_SETUP'], 'install_plugin');
            echo '</div></div>';
        }

        if ($upd_plugins) {
            echo '<div class="panel panel-default"><div class="panel-heading">'. $_LANG['AD_PLUGINS_UPDATE'] .'</div><div class="panel-body">';
                pluginsList($upd_plugins, $_LANG['AD_UPDATE'], 'upgrade_plugin');
            echo '</div></div>';
        }

        echo '<p><a href="javascript:window.history.go(-1);" class="btn btn-default">'. $_LANG['BACK'] .'</a></p>';
    }

    //--------------------------- Установка плагина ----------------------------
    if ($do == 'install_plugin') {
        if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) { cpAccessDenied(); }

        cpAddPathway($_LANG['AD_SETUP_PLUGIN']	, 'index.php?view=install&do=plugin');

        $error = '';

        $plugin_id = cmsCore::request('id', 'str', '');

        if (!$plugin_id) { cmsCore::redirectBack(); }

        $plugin = $inCore->loadPlugin($plugin_id);

        if (!$plugin) { $error = $_LANG['AD_PLUGIN_FAILURE']	; }

        if (!$error && $plugin->install()) {
            cmsCore::addSessionMessage($_LANG['AD_PLUGIN'] .' <strong>"'. $plugin->info['title'] .'"</strong> '. $_LANG['AD_SUCCESS'] . $_LANG['AD_IS_INSTALL'] .'. '. $_LANG['AD_ENABLE_PLUGIN'], 'success');
            cmsCore::redirect('/admin/index.php?view=plugins');
        }

        if ($error) { echo '<p style="color:red">'. $error .'</p>'; }

        echo '<p><a href="index.php?view=install&do=plugin">'. $_LANG['BACK'] .'</a></p>';
    }

    //-------------------------- Обновление плагина ----------------------------
    if ($do == 'upgrade_plugin') {
        if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) { cpAccessDenied(); }

        cpAddPathway($_LANG['AD_UPDATE_PLUGIN'], 'index.php?view=install&do=plugin');

        $error = '';

        $plugin_id = cmsCore::request('id', 'str', '');

        if (empty($plugin_id)) { cmsCore::redirectBack(); }

        $plugin = $inCore->loadPlugin($plugin_id);

        if (!$plugin) { $error = $_LANG['AD_PLUGIN_FAILURE']; }

        if (!$error && $plugin->upgrade()) {
            cmsCore::addSessionMessage($_LANG['AD_PLUGIN'] .' <strong>"'. $plugin->info['title'] .'"</strong> '. $_LANG['AD_SUCCESS'] . $_LANG['AD_IS_UPDATE'], 'success');
            cmsCore::redirect('/admin/index.php?view=plugins');
        }

        if ($error) { echo '<p style="color:red">'. $error .'</p>'; }

        echo '<p><a href="index.php?view=install&do=plugin">'. $_LANG['BACK'] .'</a></p>';
    }

    //--------------------------- Удаление плагина -----------------------------
    if ($do == 'remove_plugin') {
        if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) { cpAccessDenied(); }
        
        $plugin_name = $inCore->getPluginById(cmsCore::request('id', 'int', 0));

        if (!$plugin_name) { cmsCore::redirectBack(); }
        
        $plugin = $inCore->loadPlugin($plugin_name);

        if (!$plugin) { $error = $_LANG['AD_PLUGIN_FAILURE']; }
        
        $plugin->uninstall();
        
        cmsCore::addSessionMessage($_LANG['AD_REMOVE_PLUGIN_OK'], 'success');
        cmsCore::redirect('/admin/index.php?view=plugins');
    }
    //==========================================================================
}
Ejemplo n.º 18
0
function applet_menu()
{
    $inCore = cmsCore::getInstance();
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/menu', $adminAccess)) {
        cpAccessDenied();
    }
    $GLOBALS['cp_page_title'] = $_LANG['AD_MENU'];
    cpAddPathway($_LANG['AD_MENU'], 'index.php?view=menu');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    if ($do == 'list') {
        $toolmenu[] = array('icon' => 'new.gif', 'title' => $_LANG['AD_MENU_POINT_ADD'], 'link' => '?view=menu&do=add');
        $toolmenu[] = array('icon' => 'newmenu.gif', 'title' => $_LANG['AD_MENU_ADD'], 'link' => '?view=menu&do=addmenu');
        $toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=edit&multiple=1');");
        $toolmenu[] = array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=delete&multiple=1');");
        $toolmenu[] = array('icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=show&multiple=1');");
        $toolmenu[] = array('icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=hide&multiple=1');");
        $toolmenu[] = array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=menu');
        cpToolMenu($toolmenu);
        $fields[] = array('title' => 'Lt', 'field' => 'NSLeft', 'width' => '30');
        $fields[] = array('title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '', 'link' => '?view=menu&do=edit&id=%id%');
        $fields[] = array('title' => $_LANG['SHOW'], 'field' => 'published', 'width' => '60');
        $fields[] = array('title' => $_LANG['AD_ORDER'], 'field' => 'ordering', 'width' => '100');
        $fields[] = array('title' => $_LANG['AD_LINK'], 'field' => array('linktype', 'linkid', 'link'), 'width' => '240', 'prc' => 'cpMenutypeById');
        $fields[] = array('title' => $_LANG['AD_MENU'], 'field' => 'menu', 'width' => '70', 'filter' => '10', 'filterlist' => cpGetList('menu'), 'prc' => 'list_menu');
        $fields[] = array('title' => $_LANG['TEMPLATE'], 'field' => 'template', 'width' => '70', 'prc' => 'cpTemplateById');
        $actions[] = array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=menu&do=edit&id=%id%');
        $actions[] = array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_MENU_POINT_CONFIRM'], 'link' => '?view=menu&do=delete&id=%id%');
        cpListTable('cms_menu', $fields, $actions, 'parent_id>0', 'NSLeft, ordering');
    } else {
        $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();');
        $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=menu');
        cpToolMenu($toolmenu);
    }
    if ($do == 'move_up') {
        $inDB->moveNsCategory('cms_menu', $id, 'up');
        cmsCore::redirectBack();
    }
    if ($do == 'move_down') {
        $inDB->moveNsCategory('cms_menu', $id, 'down');
        cmsCore::redirectBack();
    }
    if ($do == 'show') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbShow('cms_menu', $id);
            }
            echo '1';
            exit;
        } else {
            dbShowList('cms_menu', $_REQUEST['item']);
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            cmsCore::redirectBack();
        }
    }
    if ($do == 'hide') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbHide('cms_menu', $id);
            }
            echo '1';
            exit;
        } else {
            dbHideList('cms_menu', cmsCore::request('item', 'array_int', array()));
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            cmsCore::redirectBack();
        }
    }
    if ($do == 'delete') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                $inDB->deleteNS('cms_menu', (int) $id);
            }
        } else {
            $items = cmsCore::request('item', 'array_int', array());
            foreach ($items as $item_id) {
                $inDB->deleteNS('cms_menu', $item_id);
            }
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirectBack();
    }
    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $id = cmsCore::request('id', 'int', 0);
        if (!$id) {
            cmsCore::redirectBack();
        }
        $title = cmsCore::request('title', 'str', '');
        $menu = cmsCore::arrayToYaml(cmsCore::request('menu', 'array_str', ''));
        $linktype = cmsCore::request('mode', 'str', '');
        $linkid = cmsCore::request($linktype, 'str', '');
        $link = $inCore->getMenuLink($linktype, $linkid);
        $target = cmsCore::request('target', 'str', '');
        $published = cmsCore::request('published', 'int', 0);
        $template = cmsCore::request('template', 'str', '');
        $iconurl = cmsCore::request('iconurl', 'str', '');
        $parent_id = cmsCore::request('parent_id', 'int', 0);
        $oldparent = cmsCore::request('oldparent', 'int', 0);
        $is_lax = cmsCore::request('is_lax', 'int', 0);
        $css_class = cmsCore::request('css_class', 'str', '');
        $is_public = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int'));
        }
        $ns = $inCore->nestedSetsInit('cms_menu');
        if ($oldparent != $parent_id) {
            $ns->MoveNode($id, $parent_id);
        }
        $sql = "UPDATE cms_menu\n                SET title='{$title}',\n                    css_class='{$css_class}',\n                    menu='{$menu}',\n                    link='{$link}',\n                    linktype='{$linktype}',\n                    linkid='{$linkid}',\n                    target='{$target}',\n                    published='{$published}',\n                    template='{$template}',\n                    access_list='{$access_list}',\n                    is_lax='{$is_lax}',\n                    iconurl='{$iconurl}'\n                WHERE id = '{$id}'\n                LIMIT 1";
        $inDB->query($sql);
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        if (!isset($_SESSION['editlist']) || @sizeof($_SESSION['editlist']) == 0) {
            cmsCore::redirect('?view=menu');
        } else {
            cmsCore::redirect('?view=menu&do=edit');
        }
    }
    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $title = cmsCore::request('title', 'str', '');
        $menu = cmsCore::arrayToYaml(cmsCore::request('menu', 'array_str', ''));
        $linktype = cmsCore::request('mode', 'str', '');
        $linkid = cmsCore::request($linktype, 'str', '');
        $link = $inCore->getMenuLink($linktype, $linkid);
        $target = cmsCore::request('target', 'str', '');
        $published = cmsCore::request('published', 'int', 0);
        $template = cmsCore::request('template', 'str', '');
        $iconurl = cmsCore::request('iconurl', 'str', '');
        $parent_id = cmsCore::request('parent_id', 'int', 0);
        $css_class = cmsCore::request('css_class', 'str', '');
        $is_public = cmsCore::request('is_public', 'int', '');
        $is_lax = cmsCore::request('is_lax', 'int', 0);
        if (!$is_public) {
            $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int'));
        }
        $ns = $inCore->nestedSetsInit('cms_menu');
        $myid = $ns->AddNode($parent_id);
        $sql = "UPDATE cms_menu\n\t\t\t\tSET menu='{$menu}',\n\t\t\t\t\ttitle='{$title}',\n                    css_class='{$css_class}',\n\t\t\t\t\tlink='{$link}',\n\t\t\t\t\tlinktype='{$linktype}',\n\t\t\t\t\tlinkid='{$linkid}',\n\t\t\t\t\ttarget='{$target}',\n\t\t\t\t\tpublished='{$published}',\n\t\t\t\t\ttemplate='{$template}',\n\t\t\t\t\taccess_list='{$access_list}',\n\t\t\t\t\tis_lax='{$is_lax}',\n\t\t\t\t\ticonurl='{$iconurl}'\n\t\t\t\tWHERE id = '{$myid}'";
        $inDB->query($sql);
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirect('?view=menu');
    }
    if ($do == 'submitmenu') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $sql = "SELECT ordering as max_o FROM cms_modules ORDER BY ordering DESC LIMIT 1";
        $result = $inDB->query($sql);
        $row = $inDB->fetch_assoc($result);
        $maxorder = $row['max_o'] + 1;
        $menu = cmsCore::request('menu', 'str', '');
        $title = cmsCore::request('title', 'str', '');
        $position = cmsCore::request('position', 'str', '');
        $published = cmsCore::request('published', 'int', 0);
        $css_prefix = cmsCore::request('css_prefix', 'str', '');
        $is_public = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $access_list = $inCore->arrayToYaml(cmsCore::request('allow_group', 'array_int'));
        }
        $cfg['menu'] = $menu;
        $cfg_str = cmsCore::arrayToYaml($cfg);
        $sql = "INSERT INTO cms_modules (position, name, title, is_external, content, ordering, showtitle, published, user, config, css_prefix, access_list)\n                VALUES ('{$position}', '{$_LANG['AD_MENU']}', '{$title}', 1, 'mod_menu', {$maxorder}, 1, {$published}, 0, '{$cfg_str}', '{$css_prefix}', '{$access_list}')";
        $inDB->query($sql);
        $newid = $inDB->get_last_id('cms_modules');
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirect('?view=modules&do=edit&id=' . $newid);
    }
    if ($do == 'addmenu' || $do == 'add' || $do == 'edit') {
        $GLOBALS['cp_page_head'][] = '<script language="JavaScript" type="text/javascript" src="js/menu.js"></script>';
        echo '<script>';
        echo cmsPage::getLangJS('AD_SPECIFY_LINK_MENU');
        echo '</script>';
    }
    if ($do == 'addmenu') {
        $GLOBALS['cp_page_title'] = $_LANG['AD_MENU_ADD'];
        cpAddPathway($_LANG['AD_MENU_ADD']);
        $menu_list = cpGetList('menu');
        ?>
         <form id="addform" name="addform" action="index.php?view=menu&do=submitmenu" method="post">
             <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
             <table class="proptable" width="650" cellspacing="10" cellpadding="10">
                 <tr>
                     <td width="300" valign="top">
                         <strong><?php 
        echo $_LANG['AD_MODULE_MENU_TITLE'];
        ?>
</strong>
                     </td>
                     <td valign="top">
                         <input name="title" type="text" id="title2" style="width:99%" value=""/>
                     </td>
                 </tr>
                 <tr>
                     <td valign="top">
                         <strong><?php 
        echo $_LANG['AD_MENU_TO_VIEW'];
        ?>
</strong><br/>
                         <span class="hinttext"><?php 
        echo $_LANG['AD_TO_CREATE_NEW_POINT'];
        ?>
</span>
                     </td>
                     <td valign="top">
                         <select name="menu" id="menu" style="width:99%">
                             <?php 
        foreach ($menu_list as $menu) {
            ?>
                                 <option value="<?php 
            echo $menu['id'];
            ?>
">
                                     <?php 
            echo $menu['title'];
            ?>
                                 </option>
                             <?php 
        }
        ?>
                         </select>
                     </td>
                 </tr>
                 <tr>
                     <td valign="top">
                         <strong><?php 
        echo $_LANG['AD_POSITION_TO_VIEW'];
        ?>
</strong><br />
                         <span class="hinttext"><?php 
        echo $_LANG['AD_POSITION_MUST_BE'];
        ?>
</span>
                     </td>
                     <td valign="top">
                         <?php 
        $pos = cpModulePositions(cmsConfig::getConfig('template'));
        ?>
                         <select name="position" id="position" style="width:99%">
                             <?php 
        if ($pos) {
            foreach ($pos as $key => $position) {
                if (@$mod['position'] == $position) {
                    echo '<option value="' . $position . '" selected>' . $position . '</option>';
                } else {
                    echo '<option value="' . $position . '">' . $position . '</option>';
                }
            }
        }
        ?>
                         </select>
                         <input name="is_external" type="hidden" id="is_external" value="0" />
                     </td>
                 </tr>
                 <tr>
                     <td valign="top"><strong><?php 
        echo $_LANG['AD_MENU_PUBLIC'];
        ?>
</strong></td>
                     <td valign="top">
                         <label><input name="published" type="radio" value="1" checked="checked" <?php 
        if (@$mod['published']) {
            echo 'checked="checked"';
        }
        ?>
 /> <?php 
        echo $_LANG['YES'];
        ?>
</label>
                         <label><input name="published" type="radio" value="0"  <?php 
        if (@(!$mod['published'])) {
            echo 'checked="checked"';
        }
        ?>
 /> <?php 
        echo $_LANG['NO'];
        ?>
</label>
                     </td>
                 </tr>
                 <tr>
                     <td valign="top"><strong><?php 
        echo $_LANG['AD_PREFIX_CSS'];
        ?>
</strong></td>
                     <td valign="top">
                         <input name="css_prefix" type="text" id="css_prefix" value="<?php 
        echo @$mod['css_prefix'];
        ?>
" style="width:99%" />
                     </td>
                 </tr>
                 <tr>
                     <td valign="top">
                         <strong><?php 
        echo $_LANG['AD_TAB_ACCESS'];
        ?>
:</strong><br />
                         <span class="hinttext"><?php 
        echo $_LANG['AD_GROUP_ACCESS'];
        ?>
</span>
                     </td>
                     <td valign="top">
                     <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                         <tr>
                             <td width="20">
                                 <?php 
        $groups = cmsUser::getGroups();
        $style = 'disabled="disabled"';
        $public = 'checked="checked"';
        if ($do == 'edit') {
            if ($mod['access_list']) {
                $public = '';
                $style = '';
                $access_list = $inCore->yamlToArray($mod['access_list']);
            }
        }
        ?>
                                 <input name="is_public" type="checkbox" id="is_public" onclick="checkAccesList()" value="1" <?php 
        echo $public;
        ?>
 />
                             </td>
                             <td><label for="is_public"><strong><?php 
        echo $_LANG['AD_SHARE'];
        ?>
</strong></label></td>
                         </tr>
                     </table>
                     <div style="padding:5px">
                         <span class="hinttext">
                             <?php 
        echo $_LANG['AD_VIEW_IF_CHECK'];
        ?>
                         </span>
                     </div>

                     <div style="margin-top:10px;padding:5px;padding-right:0px;" id="grp">
                         <div>
                             <strong><?php 
        echo $_LANG['AD_GROUPS_VIEW'];
        ?>
</strong><br />
                             <span class="hinttext">
                                  <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                             </span>
                         </div>
                         <div>
                             <?php 
        echo '<select style="width: 99%" name="allow_group[]" id="allow_group" size="6" multiple="multiple" ' . $style . '>';
        if ($groups) {
            foreach ($groups as $group) {
                echo '<option value="' . $group['id'] . '"';
                if ($do == 'edit') {
                    if (inArray($access_list, $group['id'])) {
                        echo 'selected="selected"';
                    }
                }
                echo '>';
                echo $group['title'] . '</option>';
            }
        }
        echo '</select>';
        ?>
                         </div>
                     </div>
                     </td>
                 </tr>
                 <tr>
                     <td colspan="2" valign="top">
                         <div style="padding:10px;margin:4px;background-color:#EBEBEB;border:solid 1px gray">
                             <?php 
        echo $_LANG['AD_NEW_MENU_NEW_MODULE'];
        ?>
                         </div>
                     </td>
                 </tr>
             </table>
             <div style="margin-top:5px">
                 <input name="save" type="submit" id="save" value="<?php 
        echo $_LANG['AD_MENU_ADD'];
        ?>
" />
                 <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.location.href='index.php?view=menu';" />
             </div>
         </form>
         <?php 
    }
    if ($do == 'add' || $do == 'edit') {
        require '../includes/jwtabs.php';
        $GLOBALS['cp_page_head'][] = jwHeader();
        $menu_list = cpGetList('menu');
        if ($do == 'add') {
            cpAddPathway($_LANG['AD_MENU_POINT_ADD']);
            $mod['menu'] = array('mainmenu');
        } 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_menu', "id = '{$item_id}'", '*');
            if (!$mod) {
                cmsCore::error404();
            }
            $mod['menu'] = cmsCore::yamlToArray($mod['menu']);
            cpAddPathway($_LANG['AD_MENU_POINT_EDIT'] . $ostatok . ' "' . $mod['title'] . '"');
        }
        ?>
    <form id="addform" name="addform" method="post" action="index.php">
        <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
        <input type="hidden" name="view" value="menu" />

        <table class="proptable" width="100%" cellpadding="15" cellspacing="2">
            <tr>

                <td valign="top">

                    <div><strong><?php 
        echo $_LANG['AD_MENU_POINT_TITLE'];
        ?>
</strong> <span class="hinttext">&mdash; <?php 
        echo $_LANG['AD_VIEW_IN_SITE'];
        ?>
</span></div>
                    <div><input name="title" type="text" id="title" style="width:100%" value="<?php 
        echo htmlspecialchars($mod['title']);
        ?>
" /></div>
                    <div><strong><?php 
        echo $_LANG['AD_PARENT_POINT'];
        ?>
</strong></div>
                    <div>
                        <?php 
        $rootid = $inDB->get_field('cms_menu', 'parent_id=0', 'id');
        ?>
                        <select name="parent_id" size="10" id="parent_id" style="width:100%">
                            <option value="<?php 
        echo $rootid;
        ?>
" <?php 
        if (@$mod['parent_id'] == $rootid || !isset($mod['parent_id'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_MENU_ROOT'];
        ?>
</option>
                            <?php 
        if (isset($mod['parent_id'])) {
            echo $inCore->getListItemsNS('cms_menu', $mod['parent_id']);
        } else {
            echo $inCore->getListItemsNS('cms_menu');
        }
        ?>
                        </select>
                        <input type="hidden" name="oldparent" value="<?php 
        echo @$mod['parent_id'];
        ?>
" />
                    </div>

                    <div><strong><?php 
        echo $_LANG['AD_MENU_POINT_ACTION'];
        ?>
</strong></div>
                    <div>
                        <select name="mode" id="linktype" style="width:100%" onchange="showMenuTarget()">
                            <option value="link" <?php 
        if (@$mod['linktype'] == 'link' || !isset($mod['mode'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_LINK'];
        ?>
</option>
                            <option value="content" <?php 
        if (@$mod['linktype'] == 'content') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_ARTICLE'];
        ?>
</option>
                            <option value="category" <?php 
        if (@$mod['linktype'] == 'category') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_PARTITION'];
        ?>
</option>
                            <?php 
        if ($inCore->isComponentInstalled('video')) {
            ?>
                            <option value="video_cat" <?php 
            if (@$mod['linktype'] == 'video_cat') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo $_LANG['AD_OPEN_VIDEO_PARTITION'];
            ?>
</option>
                            <?php 
        }
        ?>
                            <option value="component" <?php 
        if (@$mod['linktype'] == 'component') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_COMPONENT'];
        ?>
</option>
                            <option value="blog" <?php 
        if (@$mod['linktype'] == 'blog') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_BLOG'];
        ?>
</option>
                            <option value="uccat" <?php 
        if (@$mod['linktype'] == 'uccat') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_CATEGORY'];
        ?>
</option>
                            <option value="photoalbum" <?php 
        if (@$mod['linktype'] == 'photoalbum') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_ALBUM'];
        ?>
</option>
                        </select>
                    </div>

                    <div id="t_link" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'link' || $mod['linktype'] == 'ext' || !$mod['linktype']) {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_LINK'];
        ?>
</strong> <span class="hinttext">&mdash; <?php 
        echo $_LANG['AD_LINK_HINT'];
        ?>
 <b>http://</b></span>
                        </div>
                        <div>
                            <input name="link" type="text" id="link" size="50" style="width:100%" <?php 
        if (@$mod['linktype'] == 'link' || @$mod['linktype'] == 'ext') {
            echo 'value="' . $mod['link'] . '"';
        }
        ?>
/>
                        </div>
                    </div>

                    <div id="t_content" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'content') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_ARTICLE'];
        ?>
</strong>
                        </div>
                        <div>
                            <select name="content" id="content" style="width:100%">
                                <?php 
        if (@$mod['linktype'] == 'content') {
            echo $inCore->getListItems('cms_content', $mod['linkid']);
        } else {
            echo $inCore->getListItems('cms_content');
        }
        ?>
                            </select>
                        </div>
                    </div>

                    <?php 
        if ($inCore->isComponentInstalled('video')) {
            ?>
                    <div id="t_video_cat" class="menu_target" style="display:<?php 
            if ($mod['linktype'] == 'video_cat') {
                echo 'block';
            } else {
                echo 'none';
            }
            ?>
">
                        <div>
                            <strong><?php 
            echo $_LANG['AD_CHECK_PARTITION'];
            ?>
</strong>
                        </div>
                        <div>
                            <select name="video_cat" id="video_cat" style="width:100%">
                                    <?php 
            if (@$mod['linktype'] == 'video_cat') {
                echo $inCore->getListItemsNS('cms_video_category', $mod['linkid']);
            } else {
                echo $inCore->getListItemsNS('cms_video_category');
            }
            ?>
                            </select>
                        </div>
                    </div>
                    <?php 
        }
        ?>

                    <div id="t_category" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'category') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_PARTITION'];
        ?>
</strong>
                        </div>
                        <div>
                            <select name="category" id="category" style="width:100%">
                                    <?php 
        if (@$mod['linktype'] == 'category') {
            echo $inCore->getListItemsNS('cms_category', $mod['linkid']);
        } else {
            echo $inCore->getListItemsNS('cms_category');
        }
        ?>
                            </select>
                        </div>
                    </div>

                    <div id="t_component" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'component') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_COMPONENT'];
        ?>
</strong>
                        </div>
                        <div>
                           <select name="component" id="component" style="width:100%">
                                <?php 
        if (@$mod['linktype'] == 'component') {
            echo $inCore->getListItems('cms_components', $mod['linkid'], 'title', 'asc', 'internal=0', 'link');
        } else {
            echo $inCore->getListItems('cms_components', 0, 'title', 'asc', 'internal=0', 'link');
        }
        ?>
                            </select>
                        </div>
                    </div>

                    <div id="t_blog" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'blog') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_BLOG'];
        ?>
</strong>
                        </div>
                        <div>
                           <select name="blog" id="blog" style="width:100%">
                                <?php 
        if (@$mod['linktype'] == 'blog') {
            echo $inCore->getListItems('cms_blogs', $mod['linkid'], 'title', 'asc', "owner='user'");
        } else {
            echo $inCore->getListItems('cms_blogs', 0, 'title', 'asc', "owner='user'");
        }
        ?>
                            </select>
                        </div>
                    </div>

                    <div id="t_uccat" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'uccat') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_CATEGORY'];
        ?>
</strong>
                        </div>
                        <div>
                           <select name="uccat" id="uccat" style="width:100%">
                                <?php 
        if (@$mod['linktype'] == 'uccat') {
            echo $inCore->getListItems('cms_uc_cats', $mod['linkid']);
        } else {
            echo $inCore->getListItems('cms_uc_cats');
        }
        ?>
                            </select>
                        </div>
                    </div>

                    <div id="t_photoalbum" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'photoalbum') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_ALBUM'];
        ?>
</strong>
                        </div>
                        <div>
                           <select name="photoalbum" id="photoalbum" style="width:100%">
                                <?php 
        if (@$mod['linktype'] == 'photoalbum') {
            echo $inCore->getListItems('cms_photo_albums', $mod['linkid'], 'id', 'ASC', 'NSDiffer = ""');
        } else {
            echo $inCore->getListItems('cms_photo_albums', 0, 'id', 'ASC', 'NSDiffer = ""');
        }
        ?>
                            </select>
                        </div>
                    </div>

                </td>

                <td width="300" valign="top" style="background:#ECECEC;">

                    <?php 
        ob_start();
        ?>

                    {tab=<?php 
        echo $_LANG['AD_TAB_PUBLISH'];
        ?>
}

                        <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                            <tr>
                                <td width="20"><input type="checkbox" name="published" id="published" value="1" <?php 
        if ($mod['published'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                                <td><label for="published"><strong><?php 
        echo $_LANG['AD_MENU_POINT_PUBLIC'];
        ?>
</strong></label></td>
                            </tr>
                        </table>

                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['AD_OPEN_POINT'];
        ?>
</strong>
                        </div>
                        <div>
                            <select name="target" id="target" style="width:100%">
                                <option value="_self" <?php 
        if (@$mod['target'] == '_self') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_SELF'];
        ?>
</option>
                                <option value="_parent"><?php 
        echo $_LANG['AD_PARENT'];
        ?>
</option>
                                <option value="_blank" <?php 
        if (@$mod['target'] == '_blank') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BLANK'];
        ?>
</option>
                                <option value="_top" <?php 
        if (@$mod['target'] == '_top') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_TOP'];
        ?>
</option>
                            </select>
                        </div>

                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['TEMPLATE'];
        ?>
</strong><br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_DESIGN_CHANGE'];
        ?>
</span>
                        </div>
                        <div>
                            <select name="template" id="template" style="width:100%">
                                <option value="0" <?php 
        if (@$mod['template'] == 0 || !$mod['template']) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_DEFAULT'];
        ?>
</option>
                                <?php 
        $templates = cmsCore::getDirsList('/templates');
        foreach ($templates as $template) {
            echo '<option value="' . $template . '" ' . (@$mod['template'] == $template ? 'selected="selected"' : '') . '>' . $template . '</option>';
        }
        ?>
                            </select>
                        </div>

                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['AD_ICON_PICTURE'];
        ?>
</strong><br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_ICON_FILENAME'];
        ?>
</span>
                        </div>
                        <div>
                            <input name="iconurl" type="text" id="iconurl" size="30" value="<?php 
        echo @$mod['iconurl'];
        ?>
" style="width:100%"/>
                            <div>
                                <a id="iconlink" style="display:block;" href="javascript:showIcons()"><?php 
        echo $_LANG['AD_CHECK_ICON'];
        ?>
</a>
                                <div id="icondiv" style="display:none; padding:6px;border:solid 1px gray;background:#FFF">
                                    <div><?php 
        iconList();
        ?>
</div>
                                </div>
                            </div>
                        </div>
                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['AD_CSS_CLASS'];
        ?>
</strong>
                        </div>
                        <div>
                            <input name="css_class" type="text" size="30" value="<?php 
        echo @$mod['css_class'];
        ?>
" style="width:100%"/>
                        </div>

                    {tab=<?php 
        echo $_LANG['AD_TAB_ACCESS'];
        ?>
}
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                        <tr>
                            <td width="20">
                                <?php 
        $groups = cmsUser::getGroups();
        $style = 'disabled="disabled"';
        $public = 'checked="checked"';
        if ($do == 'edit') {
            if ($mod['access_list']) {
                $public = '';
                $style = '';
                $access_list = $inCore->yamlToArray($mod['access_list']);
            }
        }
        ?>
                                <input name="is_public" type="checkbox" id="is_public" onclick="checkAccesList()" value="1" <?php 
        echo $public;
        ?>
 />
                            </td>
                            <td><label for="is_public"><strong><?php 
        echo $_LANG['AD_SHARE'];
        ?>
</strong></label></td>
                        </tr>
                    </table>
                    <div style="padding:5px">
                        <span class="hinttext">
                            <?php 
        echo $_LANG['AD_VIEW_IF_CHECK'];
        ?>
                        </span>
                    </div>

                    <div style="margin-top:10px;padding:5px;padding-right:0px;" id="grp">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_GROUPS_VIEW'];
        ?>
</strong><br />
                            <span class="hinttext">
                                <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                            </span>
                        </div>
                        <div>
                            <?php 
        echo '<select style="width: 99%" name="allow_group[]" id="allow_group" size="6" multiple="multiple" ' . $style . '>';
        if ($groups) {
            foreach ($groups as $group) {
                echo '<option value="' . $group['id'] . '"';
                if ($do == 'edit' && $mod['access_list']) {
                    if (inArray($access_list, $group['id'])) {
                        echo 'selected="selected"';
                    }
                }
                echo '>';
                echo $group['title'] . '</option>';
            }
        }
        echo '</select>';
        ?>
                        </div>
                    </div>
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                        <tr>
                            <td width="20">
                                <input name="is_lax" type="checkbox" id="is_lax" value="1" <?php 
        if (@$mod['is_lax']) {
            ?>
checked="checked"<?php 
        }
        ?>
 />
                            </td>
                            <td><label for="is_lax"><strong><?php 
        echo $_LANG['AD_ONLY_CHILD_ITEM'];
        ?>
</strong></label></td>
                        </tr>
                    </table>
                    {tab=<?php 
        echo $_LANG['AD_MENU'];
        ?>
}
                    <div style="padding:5px;padding-right:0px;">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_MENU_TO_VIEW'];
        ?>
</strong><br />
                            <span class="hinttext">
                                <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                            </span>
                        </div>
                        <div>
                        <select style="width: 99%" name="menu[]" size="9" multiple="multiple">
                            <?php 
        foreach ($menu_list as $menu) {
            ?>
                                <option value="<?php 
            echo $menu['id'];
            ?>
" <?php 
            if (@in_array($menu['id'], @$mod['menu'])) {
                echo 'selected="selected"';
            }
            ?>
>
                                    <?php 
            echo $menu['title'];
            ?>
                                </option>
                            <?php 
        }
        ?>
                        </select>
                        </div>
                    </div>
                    {/tabs}

                    <?php 
        echo jwTabs(ob_get_clean());
        ?>

                </td>

            </tr>
        </table>

        <p>
            <input name="add_mod" type="button" onclick="submitItem()" id="add_mod" value="<?php 
        echo $_LANG['SAVE'];
        ?>
 " />
            <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.location.href='index.php?view=menu';" />
            <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 
    }
}
Ejemplo n.º 19
0
function applet_content()
{
    $inCore = cmsCore::getInstance();
    $inUser = cmsUser::getInstance();
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    //check access
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/content', $adminAccess)) {
        cpAccessDenied();
    }
    $cfg = $inCore->loadComponentConfig('content');
    cmsCore::loadModel('content');
    $model = new cms_model_content();
    $GLOBALS['cp_page_title'] = $_LANG['AD_ARTICLES'];
    cpAddPathway($_LANG['AD_ARTICLES'], 'index.php?view=tree');
    $do = cmsCore::request('do', 'str', 'add');
    $id = cmsCore::request('id', 'int', -1);
    if ($do == 'arhive_on') {
        $inDB->query("UPDATE cms_content SET is_arhive = 1 WHERE id = '{$id}'");
        cmsCore::addSessionMessage($_LANG['AD_ARTICLES_TO_ARHIVE'], 'success');
        cmsCore::redirectBack();
    }
    if ($do == 'move') {
        $item_id = cmsCore::request('id', 'int', 0);
        $cat_id = cmsCore::request('cat_id', 'int', 0);
        $dir = $_REQUEST['dir'];
        $step = 1;
        $model->moveItem($item_id, $cat_id, $dir, $step);
        echo '1';
        exit;
    }
    if ($do == 'move_to_cat') {
        $items = cmsCore::request('item', 'array_int');
        $to_cat_id = cmsCore::request('obj_id', 'int', 0);
        if ($items && $to_cat_id) {
            $last_ordering = (int) $inDB->get_field('cms_content', "category_id = '{$to_cat_id}' ORDER BY ordering DESC", 'ordering');
            foreach ($items as $item_id) {
                $article = $model->getArticle($item_id);
                if (!$article) {
                    continue;
                }
                $last_ordering++;
                $model->updateArticle($article['id'], array('category_id' => $to_cat_id, 'ordering' => $last_ordering, 'url' => $article['url'], 'title' => $inDB->escape_string($article['title']), 'id' => $article['id'], 'user_id' => $article['user_id']));
            }
            cmsCore::addSessionMessage($_LANG['AD_ARTICLES_TO'], 'success');
        }
        cmsCore::redirect('?view=tree&cat_id=' . $to_cat_id);
    }
    if ($do == 'show') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbShow('cms_content', $id);
            }
            echo '1';
            exit;
        } else {
            dbShowList('cms_content', cmsCore::request('item', 'array_int'));
            cmsCore::redirectBack();
        }
    }
    if ($do == 'hide') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbHide('cms_content', $id);
            }
            echo '1';
            exit;
        } else {
            dbHideList('cms_content', cmsCore::request('item', 'array_int'));
            cmsCore::redirectBack();
        }
    }
    if ($do == 'delete') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                $model->deleteArticle($id);
                cmsCore::addSessionMessage($_LANG['AD_ARTICLE_REMOVE'], 'success');
            }
        } else {
            $model->deleteArticles(cmsCore::request('item', 'array_int'));
            cmsCore::addSessionMessage($_LANG['AD_ARTICLES_REMOVE'], 'success');
        }
        cmsCore::redirectBack();
    }
    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        if (isset($_REQUEST['id'])) {
            $id = cmsCore::request('id', 'int', 0);
            $article['category_id'] = cmsCore::request('category_id', 'int', 1);
            $article['title'] = cmsCore::request('title', 'str');
            $article['url'] = cmsCore::request('url', 'str');
            $article['showtitle'] = cmsCore::request('showtitle', 'int', 0);
            $article['description'] = cmsCore::request('description', 'html', '');
            $article['description'] = $inDB->escape_string($article['description']);
            $article['content'] = cmsCore::request('content', 'html', '');
            $article['content'] = $inDB->escape_string($article['content']);
            $article['for_img'] = cmsCore::request('for_img', 'html', '');
            $article['for_img'] = $inDB->escape_string($article['for_img']);
            $article['published'] = cmsCore::request('published', 'int', 0);
            $article['showdate'] = cmsCore::request('showdate', 'int', 0);
            $article['showlatest'] = cmsCore::request('showlatest', 'int', 0);
            $article['show_in_new'] = cmsCore::request('show_in_new', 'int', 0);
            //new
            $article['show_in_footer'] = cmsCore::request('show_in_footer', 'int', 0);
            //new
            $article['showpath'] = cmsCore::request('showpath', 'int', 0);
            $article['comments'] = cmsCore::request('comments', 'int', 0);
            $article['canrate'] = cmsCore::request('canrate', 'int', 0);
            $article['add_text'] = cmsCore::request('add_text', 'str');
            $enddate = explode('.', cmsCore::request('enddate', 'str'));
            $article['enddate'] = $enddate[2] . '-' . $enddate[1] . '-' . $enddate[0];
            $article['is_end'] = cmsCore::request('is_end', 'int', 0);
            $article['pagetitle'] = cmsCore::request('pagetitle', 'str', '');
            $article['tags'] = cmsCore::request('tags', 'str');
            $olddate = cmsCore::request('olddate', 'str', '');
            $pubdate = cmsCore::request('pubdate', 'str', '');
            $article['user_id'] = cmsCore::request('user_id', 'int', $inUser->id);
            $article['tpl'] = cmsCore::request('tpl', 'str', 'com_content_read.tpl');
            $date = explode('.', $pubdate);
            $article['pubdate'] = $date[2] . '-' . $date[1] . '-' . $date[0] . ' ' . date('H:i');
            $autokeys = cmsCore::request('autokeys', 'int');
            switch ($autokeys) {
                case 1:
                    $article['meta_keys'] = $inCore->getKeywords($article['content']);
                    $article['meta_desc'] = $article['title'];
                    break;
                case 2:
                    $article['meta_desc'] = strip_tags($article['description']);
                    $article['meta_keys'] = $article['tags'];
                    break;
                case 3:
                    $article['meta_desc'] = cmsCore::request('meta_desc', 'str');
                    $article['meta_keys'] = cmsCore::request('meta_keys', 'str');
                    break;
            }
            $model->updateArticle($id, $article);
            if (!cmsCore::request('is_public', 'int', 0)) {
                $showfor = $_REQUEST['showfor'];
                cmsCore::setAccess($id, $showfor, 'material');
            } else {
                cmsCore::clearAccess($id, 'material');
            }
            if (isset($_SESSION['lang']) && $_SESSION['lang'] != 'ru') {
                $file = 'article' . $id . '_' . $_SESSION['lang'] . '.jpg';
            } else {
                $file = 'article' . $id . '.jpg';
            }
            //$file = 'article'.$id.'.jpg';
            if (cmsCore::request('delete_image', 'int', 0)) {
                @unlink(PATH . "/images/photos/small/{$file}");
                @unlink(PATH . "/images/photos/medium/{$file}");
            } else {
                // Загружаем класс загрузки фото
                cmsCore::loadClass('upload_photo');
                $inUploadPhoto = cmsUploadPhoto::getInstance();
                // Выставляем конфигурационные параметры
                $inUploadPhoto->upload_dir = PATH . '/images/photos/';
                $inUploadPhoto->small_size_w = $model->config['img_small_w'];
                $inUploadPhoto->medium_size_w = $model->config['img_big_w'];
                $inUploadPhoto->thumbsqr = $model->config['img_sqr'];
                $inUploadPhoto->is_watermark = $model->config['watermark'];
                $inUploadPhoto->input_name = 'picture';
                $inUploadPhoto->filename = $file;
                // Процесс загрузки фото
                $inUploadPhoto->uploadPhoto();
            }
            cmsCore::addSessionMessage($_LANG['AD_ARTICLE_SAVE'], 'success');
            if (!isset($_SESSION['editlist']) || @sizeof($_SESSION['editlist']) == 0) {
                cmsCore::redirect('?view=tree&cat_id=' . $article['category_id']);
            } else {
                cmsCore::redirect('?view=content&do=edit');
            }
        }
    }
    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $article['category_id'] = cmsCore::request('category_id', 'int', 1);
        $article['title'] = cmsCore::request('title', 'str');
        $article['url'] = cmsCore::request('url', 'str');
        $article['showtitle'] = cmsCore::request('showtitle', 'int', 0);
        $article['description'] = cmsCore::request('description', 'html', '');
        $article['description'] = $inDB->escape_string($article['description']);
        $article['content'] = cmsCore::request('content', 'html', '');
        $article['content'] = $inDB->escape_string($article['content']);
        $article['for_img'] = cmsCore::request('for_img', 'html', '');
        $article['for_img'] = $inDB->escape_string($article['for_img']);
        $article['published'] = cmsCore::request('published', 'int', 0);
        $article['showdate'] = cmsCore::request('showdate', 'int', 0);
        $article['showlatest'] = cmsCore::request('showlatest', 'int', 0);
        $article['show_in_new'] = cmsCore::request('show_in_new', 'int', 0);
        //new
        $article['show_in_footer'] = cmsCore::request('show_in_footer', 'int', 0);
        //new
        $article['showpath'] = cmsCore::request('showpath', 'int', 0);
        $article['comments'] = cmsCore::request('comments', 'int', 0);
        $article['canrate'] = cmsCore::request('canrate', 'int', 0);
        $article['add_text'] = cmsCore::request('add_text', 'str');
        $enddate = explode('.', cmsCore::request('enddate', 'str'));
        $article['enddate'] = $enddate[2] . '-' . $enddate[1] . '-' . $enddate[0];
        $article['is_end'] = cmsCore::request('is_end', 'int', 0);
        $article['pagetitle'] = cmsCore::request('pagetitle', 'str', '');
        $article['tags'] = cmsCore::request('tags', 'str');
        $article['pubdate'] = $_REQUEST['pubdate'];
        $date = explode('.', $article['pubdate']);
        $article['pubdate'] = $date[2] . '-' . $date[1] . '-' . $date[0] . ' ' . date('H:i');
        $article['user_id'] = cmsCore::request('user_id', 'int', $inUser->id);
        $article['tpl'] = cmsCore::request('tpl', 'str', 'com_content_read.tpl');
        $autokeys = cmsCore::request('autokeys', 'int');
        switch ($autokeys) {
            case 1:
                $article['meta_keys'] = $inCore->getKeywords($article['content']);
                $article['meta_desc'] = $article['title'];
                break;
            case 2:
                $article['meta_desc'] = strip_tags($article['description']);
                $article['meta_keys'] = $article['tags'];
                break;
            case 3:
                $article['meta_desc'] = cmsCore::request('meta_desc', 'str');
                $article['meta_keys'] = cmsCore::request('meta_keys', 'str');
                break;
        }
        $article['id'] = $model->addArticle($article);
        if (!cmsCore::request('is_public', 'int', 0)) {
            $showfor = $_REQUEST['showfor'];
            if (sizeof($showfor) > 0 && !cmsCore::request('is_public', 'int', 0)) {
                cmsCore::setAccess($article['id'], $showfor, 'material');
            }
        }
        $inmenu = cmsCore::request('createmenu', 'str', '');
        if ($inmenu) {
            createMenuItem($inmenu, $article['id'], $article['title']);
        }
        // Загружаем класс загрузки фото
        cmsCore::loadClass('upload_photo');
        $inUploadPhoto = cmsUploadPhoto::getInstance();
        // Выставляем конфигурационные параметры
        $inUploadPhoto->upload_dir = PATH . '/images/photos/';
        $inUploadPhoto->small_size_w = $model->config['img_small_w'];
        $inUploadPhoto->medium_size_w = $model->config['img_big_w'];
        $inUploadPhoto->thumbsqr = $model->config['img_sqr'];
        $inUploadPhoto->is_watermark = $model->config['watermark'];
        $inUploadPhoto->input_name = 'picture';
        $inUploadPhoto->filename = 'article' . $article['id'] . '.jpg';
        // Процесс загрузки фото
        $inUploadPhoto->uploadPhoto();
        cmsCore::addSessionMessage($_LANG['AD_ARTICLE_ADD'], 'success');
        cmsCore::redirect('?view=tree&cat_id=' . $article['category_id']);
    }
    if ($do == 'add' || $do == 'edit') {
        require '../includes/jwtabs.php';
        $GLOBALS['cp_page_head'][] = jwHeader();
        $toolmenu = array();
        $toolmenu[0]['icon'] = 'save.gif';
        $toolmenu[0]['title'] = $_LANG['SAVE'];
        $toolmenu[0]['link'] = 'javascript:document.addform.submit();';
        $toolmenu[1]['icon'] = 'cancel.gif';
        $toolmenu[1]['title'] = $_LANG['CANCEL'];
        $toolmenu[1]['link'] = 'javascript:history.go(-1);';
        cpToolMenu($toolmenu);
        $menu_list = cpGetList('menu');
        if ($do == 'add') {
            echo '<h3>' . $_LANG['AD_CREATE_ARTICLE'] . '</h3>';
            cpAddPathway($_LANG['AD_CREATE_ARTICLE'], 'index.php?view=content&do=add');
            $mod['category_id'] = (int) $_REQUEST['to'];
            $mod['showpath'] = 1;
            $mod['tpl'] = 'com_content_read.tpl';
        } else {
            if (isset($_REQUEST['item'])) {
                $_SESSION['editlist'] = $_REQUEST['item'];
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $id = array_shift($_SESSION['editlist']);
                if (sizeof($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')';
                }
            } else {
                $id = (int) $_REQUEST['id'];
            }
            $sql = "SELECT *, (TO_DAYS(enddate) - TO_DAYS(CURDATE())) as daysleft, DATE_FORMAT(pubdate, '%d.%m.%Y') as pubdate, DATE_FORMAT(enddate, '%d.%m.%Y') as enddate\n\t\t\t\t\t FROM cms_content\n\t\t\t\t\t WHERE id = {$id} LIMIT 1";
            $result = $inDB->query($sql);
            if ($inDB->num_rows($result)) {
                $mod = $inDB->fetch_assoc($result);
            }
            echo '<h3>' . $_LANG['AD_EDIT_ARTICLE'] . $ostatok . '</h3>';
            cpAddPathway($mod['title'], 'index.php?view=content&do=edit&id=' . $mod['id']);
        }
        ?>
    <form id="addform" name="addform" method="post" action="index.php" enctype="multipart/form-data">
        <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
        <input type="hidden" name="view" value="content" />

        <table class="proptable" width="100%" cellpadding="5" cellspacing="2">
            <tr>

                <!-- главная ячейка -->
                <td valign="top">

                    <table width="100%" cellpadding="0" cellspacing="4" border="0">
                        <tr>
                            <td valign="top">
                                <div><strong><?php 
        echo $_LANG['AD_ARTICLE_NAME'];
        ?>
</strong></div>
                                <div>
                                    <table width="100%" cellpadding="0" cellspacing="0" border="0">
                                        <tr>
                                            <td><input name="title" type="text" id="title" style="width:100%" value="<?php 
        echo htmlspecialchars($mod['title']);
        ?>
" /></td>
                                            <td style="width:15px;padding-left:10px;padding-right:10px;">
                                                <input type="checkbox" title="<?php 
        echo $_LANG['AD_VIEW_TITLE'];
        ?>
" name="showtitle" <?php 
        if ($mod['showtitle'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
 value="1">
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </td>
                            <td width="130" valign="top">
                                <div><strong><?php 
        echo $_LANG['AD_PUBLIC_DATE'];
        ?>
</strong></div>
                                <div>
                                    <input name="pubdate" type="text" id="pubdate" style="width:100px" <?php 
        if (@(!$mod['pubdate'])) {
            echo 'value="' . date('d.m.Y') . '"';
        } else {
            echo 'value="' . $mod['pubdate'] . '"';
        }
        ?>
/>

                                    <input type="hidden" name="olddate" value="<?php 
        echo @$mod['pubdate'];
        ?>
" />
                                </div>
                            </td>
                            <td width="16" valign="bottom" style="padding-bottom:10px">
                                <input type="checkbox" name="showdate" id="showdate" title="<?php 
        echo $_LANG['AD_VIEW_DATE_AND_AUTHOR'];
        ?>
" value="1" <?php 
        if ($mod['showdate'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/>
                            </td>
<!--                             <td width="160" valign="top">
                                <div><strong><?php 
        echo $_LANG['AD_ARTICLE_TEMPLATE'];
        ?>
</strong></div>
                                <div><input name="tpl" type="text" style="width:160px" value="<?php 
        echo @$mod['tpl'];
        ?>
"></div>
                            </td> -->
							  <td width="160" valign="top">
                                <div><strong>Шаблон статьи</strong></div>
								<?php 
        $inConf = cmsConfig::getInstance();
        //задаём имя директории
        $directory = PATH . "/templates/" . $inConf->template . "/components";
        $scan_dir = scandir($directory);
        if (is_dir($directory)) {
            //проверяем наличие директории
            //директория существует
            echo '<select name="tpl">';
            $scan_dir = scandir($directory);
            //сканируем (получаем массив файлов)
            array_shift($scan_dir);
            // удаляем из массива '.'
            array_shift($scan_dir);
            // удаляем из массива '..'
            for ($i = 0; $i < sizeof($scan_dir); $i++) {
                $tpl = explode("_", $scan_dir[$i]);
                if ($_GET['view'] == $tpl['1']) {
                    if ($_GET['view']) {
                        //выводим все файлы
                        if (@$mod["tpl"] == $scan_dir[$i]) {
                            echo '<option selected>' . $scan_dir[$i] . '</option>';
                        } else {
                            echo '<option>' . $scan_dir[$i] . '</option>';
                        }
                    }
                }
            }
            echo '</select>';
        } else {
            echo '<input name="tpl" type="text" style="width:160px" value="' . @$mod["tpl"] . '">';
        }
        ?>
                            </td>

                        </tr>
                    </table>

                    <div><strong><?php 
        echo $_LANG['AD_ARTICLE_NOTICE'];
        ?>
</strong></div>
                    <div><?php 
        $inCore->insertEditor('description', $mod['description'], '200', '100%');
        ?>
</div>

                    <div><strong><?php 
        echo $_LANG['AD_ARTICLE_TEXT'];
        ?>
</strong></div>
                    <?php 
        insertPanel();
        ?>
                    <div><?php 
        $inCore->insertEditor('content', $mod['content'], '400', '100%');
        ?>
</div><!--Editor text in articles-->

                    <div><strong><?php 
        echo $_LANG['AD_ARTICLE_IMG'];
        ?>
</strong></div>
                    <div><?php 
        $inCore->insertEditor('for_img', $mod['for_img'], '200', '100%');
        ?>
</div>

                    <div><strong><?php 
        echo $_LANG['AD_ARTICLE_ADD_TEXT'];
        ?>
</strong></div>
                    <div><input name="add_text" type="text" id="add_text" style="width:99%" value="<?php 
        echo htmlspecialchars($mod['add_text']);
        ?>
" /></div>


                    <div><strong><?php 
        echo $_LANG['AD_ARTICLE_TAGS'];
        ?>
</strong></div>
                    <div><input name="tags" type="text" id="tags" style="width:99%" value="<?php 
        if (isset($mod['id'])) {
            echo cmsTagLine('content', $mod['id'], false);
        }
        ?>
" /></div>

                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <tr>
                            <td width="20">
                                <input type="radio" name="autokeys" id="autokeys1" <?php 
        if ($do == 'add' && $cfg['autokeys']) {
            ?>
checked="checked"<?php 
        }
        ?>
 value="1"/>
                            </td>
                            <td>
                                <label for="autokeys1"><strong><?php 
        echo $_LANG['AD_AUTO_GEN_KEY'];
        ?>
</strong></label>
                            </td>
                        </tr>
                        <tr>
                            <td width="20">
                                <input type="radio" name="autokeys" id="autokeys2" value="2"/>
                            </td>
                            <td>
                                <label for="autokeys2"><strong><?php 
        echo $_LANG['AD_TAGS_AS_KEY'];
        ?>
</strong></label>
                            </td>
                        </tr>
                        <tr>
                            <td width="20">
                                <input type="radio" name="autokeys" id="autokeys3" value="3" <?php 
        if ($do == 'edit' || !$cfg['autokeys']) {
            ?>
checked="checked"<?php 
        }
        ?>
/>
                            </td>
                            <td>
                                <label for="autokeys3"><strong><?php 
        echo $_LANG['AD_MANUAL_KEY'];
        ?>
</strong></label>
                            </td>
                        </tr>

                        <?php 
        if ($cfg['af_on'] && $do == 'add') {
            ?>
                        <tr>
                            <td width="20"><input type="checkbox" name="noforum" id="noforum" value="1" /> </td>
                            <td><label for="noforum"><strong><?php 
            echo $_LANG['AD_NO_CREATE_THEME'];
            ?>
</strong></label></td>
                        </tr>
                        <?php 
        }
        ?>
                    </table>

                </td>

                <!-- боковая ячейка -->
                <td width="300" valign="top" style="background:#ECECEC;">

                    <?php 
        ob_start();
        ?>

                    {tab=<?php 
        echo $_LANG['AD_TAB_PUBLISH'];
        ?>
}

                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <tr>
                            <td width="20"><input type="checkbox" name="published" id="published" value="1" <?php 
        if ($mod['published'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="published"><strong><?php 
        echo $_LANG['AD_PUBLIC_ARTICLE'];
        ?>
</strong></label></td>
                        </tr>
                    </table>

                    <div style="margin-top:7px">
                        <select name="category_id" size="10" id="category_id" style="width:99%;height:200px">
                            <option value="1" <?php 
        if (@$mod['category_id'] == 1 || !isset($mod['category_id'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_ROOT_CATEGORY'];
        ?>
</option>
                            <?php 
        if (isset($mod['category_id'])) {
            echo $inCore->getListItemsNS('cms_category', $mod['category_id']);
        } else {
            echo $inCore->getListItemsNS('cms_category');
        }
        ?>
                        </select>
                    </div>

                    <div style="margin-bottom:10px">
                        <select name="showpath" id="showpath" style="width:99%">
                            <option value="0" <?php 
        if (@(!$mod['showpath'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_PATHWAY_NAME_ONLY'];
        ?>
</option>
                            <option value="1" <?php 
        if (@$mod['showpath']) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_PATHWAY_FULL'];
        ?>
</option>
                        </select>
                    </div>

                    <div style="margin-top:15px">
                        <strong><?php 
        echo $_LANG['AD_ARTICLE_URL'];
        ?>
</strong><br/>
                        <div style="color:gray"><?php 
        echo $_LANG['AD_IF_UNKNOWN'];
        ?>
</div>
                    </div>
                    <div>
                        <table border="0" cellpadding="0" cellspacing="0" width="100%">
                            <tr>
                                <td><input type="text" name="url" value="<?php 
        echo $mod['url'];
        ?>
" style="width:100%"/></td>
                                <td width="40" align="center">.html</td>
                            </tr>
                        </table>
                    </div>

                    <div style="margin-top:10px">
                        <strong><?php 
        echo $_LANG['AD_ARTICLE_AUTHOR'];
        ?>
</strong>
                    </div>
                    <div>
                        <select name="user_id" id="user_id" style="width:99%">
                          <?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', $inUser->id, 'nickname', 'ASC', 'is_deleted=0 AND is_locked=0', 'id', 'nickname');
        }
        ?>
                        </select>
                    </div>

                    <div style="margin-top:12px"><strong><?php 
        echo $_LANG['AD_PHOTO'];
        ?>
</strong></div>
                    <div style="margin-bottom:10px">
                        <?php 
        if ($do == 'edit') {
            if (isset($_SESSION['lang']) && $_SESSION['lang'] != 'ru') {
                $mod_id = $mod['id'] . '_' . $_SESSION['lang'];
                $id_art = $mod['id'] . '_' . $_SESSION['lang'];
            } else {
                $mod_id = $mod['id'];
                $id_art = $id;
            }
            //if (file_exists(PATH.'/images/photos/small/article'.$mod['id'].'.jpg')){
            if (file_exists(PATH . '/images/photos/small/article' . $mod_id . '.jpg')) {
                ?>
                        <div style="margin-top:3px;margin-bottom:3px;padding:10px;border:solid 1px gray;text-align:center">
                            <?/*php<img src="/images/photos/small/article<?php 
                echo $id;
                ?>
.jpg" border="0" />*/?>
                            <img src="/images/photos/small/article<?php 
                echo $id_art;
                ?>
.jpg" border="0" />
                        </div>
                        <table cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <td width="16"><input type="checkbox" id="delete_image" name="delete_image" value="1" /></td>
                                <td><label for="delete_image"><?php 
                echo $_LANG['AD_PHOTO_REMOVE'];
                ?>
</label></td>
                            </tr>
                        </table>
                        <?php 
            }
        }
        ?>
                        <input type="file" name="picture" style="width:100%" />
                    </div>

                    <div style="margin-top:25px"><strong><?php 
        echo $_LANG['AD_PUBLIC_PARAMETRS'];
        ?>
</strong></div>
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <tr>
                            <td width="20"><input type="checkbox" name="show_in_new" id="show_in_new" value="1" <?php 
        if ($mod['show_in_new'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="show_in_new"><?php 
        echo $_LANG['AD_VIEW_NEW_CATS'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="show_in_footer" id="show_in_footer" value="1" <?php 
        if ($mod['show_in_footer'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="show_in_footer"><?php 
        echo $_LANG['AD_VIEW_FOOTER'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="showlatest" id="showlatest" value="1" <?php 
        if ($mod['showlatest'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="showlatest"><?php 
        echo $_LANG['AD_VIEW_NEW_ARTICLES'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="comments" id="comments" value="1" <?php 
        if ($mod['comments'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="comments"><?php 
        echo $_LANG['AD_ENABLE_COMMENTS'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="canrate" id="canrate" value="1" <?php 
        if ($mod['canrate']) {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="canrate"><?php 
        echo $_LANG['AD_ENABLE_RATING'];
        ?>
</label></td>
                        </tr>
                    </table>

                    <?php 
        if ($do == 'add') {
            ?>
                        <div style="margin-top:25px">
                            <strong><?php 
            echo $_LANG['AD_CREATE_LINK'];
            ?>
</strong>
                        </div>
                        <div>
                            <select name="createmenu" id="createmenu" style="width:99%">
                                <option value="0" selected="selected"><?php 
            echo $_LANG['AD_DONT_CREATE_LINK'];
            ?>
</option>
                            <?php 
            foreach ($menu_list as $menu) {
                ?>
                                <option value="<?php 
                echo $menu['id'];
                ?>
">
                                    <?php 
                echo $menu['title'];
                ?>
                                </option>
                            <?php 
            }
            ?>
                            </select>
                        </div>
                    <?php 
        }
        ?>

                    {tab=<?php 
        echo $_LANG['AD_DATE'];
        ?>
}

                    <div style="margin-top:5px">
                        <strong><?php 
        echo $_LANG['AD_ARTICLE_TIME'];
        ?>
</strong>
                    </div>
                    <div>
                        <select name="is_end" id="is_end" style="width:99%" onchange="if($(this).val() == 1){ $('#final_time').show(); }else {$('#final_time').hide();}">
                            <option value="0" <?php 
        if (@(!$mod['is_end'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_UNLIMITED'];
        ?>
</option>
                            <option value="1" <?php 
        if (@$mod['is_end']) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_TO_FINAL_TIME'];
        ?>
</option>
                        </select>
                    </div>

                    <div id="final_time" <?php 
        if (@(!$mod['is_end'])) {
            echo 'style="display: none"';
        }
        ?>
>
                    <div style="margin-top:20px">
                        <strong><?php 
        echo $_LANG['AD_FINAL_TIME'];
        ?>
</strong><br/>
                        <span class="hinttext"><?php 
        echo $_LANG['AD_CALENDAR_FORMAT'];
        ?>
</span>
                    </div>
                    <div><input name="enddate" type="text" style="width:80%" <?php 
        if (@(!$mod['is_end'])) {
            echo 'value="' . date('d.m.Y') . '"';
        } else {
            echo 'value="' . $mod['enddate'] . '"';
        }
        ?>
id="enddate" /></div></div>


                    {tab=SEO}

                    <div style="margin-top:5px">
                        <strong><?php 
        echo $_LANG['AD_PAGE_TITLE'];
        ?>
</strong><br/>
                        <span class="hinttext"><?php 
        echo $_LANG['AD_IF_UNKNOWN_PAGETITLE'];
        ?>
</span>
                    </div>
                    <div>
                        <input name="pagetitle" type="text" id="pagetitle" style="width:99%" value="<?php 
        if (isset($mod['pagetitle'])) {
            echo htmlspecialchars($mod['pagetitle']);
        }
        ?>
" />
                    </div>

                    <div style="margin-top:20px">
                        <strong><?php 
        echo $_LANG['KEYWORDS'];
        ?>
</strong><br/>
                        <span class="hinttext"><?php 
        echo $_LANG['AD_FROM_COMMA'];
        ?>
</span>
                    </div>
                    <div>
                         <textarea name="meta_keys" style="width:97%" rows="4" id="meta_keys"><?php 
        echo htmlspecialchars($mod['meta_keys']);
        ?>
</textarea>
                    </div>

                    <div style="margin-top:20px">
                        <strong><?php 
        echo $_LANG['DESCRIPTION'];
        ?>
</strong><br/>
                        <span class="hinttext"><?php 
        echo $_LANG['AD_LESS_THAN'];
        ?>
</span>
                    </div>
                    <div>
                         <textarea name="meta_desc" style="width:97%" rows="6" id="meta_desc"><?php 
        echo htmlspecialchars($mod['meta_desc']);
        ?>
</textarea>
                    </div>

                    {tab=<?php 
        echo $_LANG['AD_TAB_ACCESS'];
        ?>
}

                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                        <tr>
                            <td width="20">
                                <?php 
        $sql = "SELECT * FROM cms_user_groups";
        $result = $inDB->query($sql);
        $style = 'disabled="disabled"';
        $public = 'checked="checked"';
        if ($do == 'edit') {
            $sql2 = "SELECT * FROM cms_content_access WHERE content_id = " . $mod['id'] . " AND content_type = 'material'";
            $result2 = $inDB->query($sql2);
            $ord = array();
            if ($inDB->num_rows($result2)) {
                $public = '';
                $style = '';
                while ($r = $inDB->fetch_assoc($result2)) {
                    $ord[] = $r['group_id'];
                }
            }
        }
        ?>
                                <input name="is_public" type="checkbox" id="is_public" onclick="checkGroupList()" value="1" <?php 
        echo $public;
        ?>
 />
                            </td>
                            <td><label for="is_public"><strong><?php 
        echo $_LANG['AD_SHARE'];
        ?>
</strong></label></td>
                        </tr>
                    </table>
                    <div style="padding:5px">
                        <span class="hinttext">
                            <?php 
        echo $_LANG['AD_IF_NOTED'];
        ?>
                        </span>
                    </div>

                    <div style="margin-top:10px;padding:5px;padding-right:0px;" id="grp">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_GROUPS_VIEW'];
        ?>
</strong><br />
                            <span class="hinttext">
                                <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                            </span>
                        </div>
                        <div>
                            <?php 
        echo '<select style="width: 99%" name="showfor[]" id="showin" size="6" multiple="multiple" ' . $style . '>';
        if ($inDB->num_rows($result)) {
            while ($item = $inDB->fetch_assoc($result)) {
                echo '<option value="' . $item['id'] . '"';
                if ($do == 'edit') {
                    if (inArray($ord, $item['id'])) {
                        echo 'selected="selected"';
                    }
                }
                echo '>';
                echo $item['title'] . '</option>';
            }
        }
        echo '</select>';
        ?>
                        </div>
                    </div>

                    {/tabs}

                    <?php 
        echo jwTabs(ob_get_clean());
        ?>

                </td>

            </tr>
        </table>

        <p>
            <input name="add_mod" type="submit" id="add_mod" <?php 
        if ($do == 'add') {
            echo 'value="' . $_LANG['AD_CREATE_CONTENT'] . '"';
        } else {
            echo 'value="' . $_LANG['AD_SAVE_CONTENT'] . '"';
        }
        ?>
 />
            <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.history.back();"/>
            <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 
    }
}
Ejemplo n.º 20
0
    <div>
        <input type="submit" class="btn btn-primary" name="add_mod" value="<?php echo $_LANG['SAVE']; ?>" />
        <input type="button" class="btn btn-default" name="back3" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.location.href='index.php?view=components';"/>
        <input type="hidden" name="opt" value="<?php if ($opt == 'add') { echo 'submit'; } else { echo 'update'; } ?>" />
        <?php
        if ($opt == 'edit') {
            echo '<input name="item_id" type="hidden" value="'. $mod['id'] .'" />';
        }
        ?>
    </div>
</form>
<?php
}

if ($opt == 'config') {
    cpAddPathway($_LANG['AD_SETTINGS']);
?>
<form id="addform" name="addform" class="form-horizontal" role="form" action="index.php?view=components&do=config&id=<?php echo $id;?>" method="post">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
    
    <div style="width:650px;" class="uitabs">
        <ul>
            <li><a href="#basic"><span><?php echo $_LANG['AD_OVERALL']; ?></span></a></li>
            <li><a href="#limits"><span><?php echo $_LANG['AD_LISTS_LIMIT']; ?></span></a></li>
            <li><a href="#photos"><span><?php echo $_LANG['AD_FOTO']; ?></span></a></li>
            <li><a href="#restrict"><span><?php echo $_LANG['LIMITS']; ?></span></a></li>
            <li><a href="#tab_seo"><span><?php echo $_LANG['AD_SEO']; ?></span></a></li>
        </ul>

        <div id="basic">
            <div class="form-group">
Ejemplo n.º 21
0
function applet_config()
{
    // получаем оригинальный конфиг
    $config = cmsConfig::getDefaultConfig();
    $inPage = cmsPage::getInstance();
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/config', $adminAccess)) {
        cpAccessDenied();
    }
    $GLOBALS['cp_page_title'] = $_LANG['AD_SITE_SETTING'];
    cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config');
    $do = cmsCore::request('do', 'str', 'list');
    if ($do == 'save') {
        if (!cmsCore::validateForm()) {
            cmsCore::error404();
        }
        $newCFG = array();
        $newCFG['sitename'] = stripslashes(cmsCore::request('sitename', 'str', ''));
        $newCFG['title_and_sitename'] = cmsCore::request('title_and_sitename', 'int', 0);
        $newCFG['title_and_page'] = cmsCore::request('title_and_page', 'int', 0);
        $newCFG['hometitle'] = stripslashes(cmsCore::request('hometitle', 'str', ''));
        $newCFG['homecom'] = cmsCore::request('homecom', 'str', '');
        $newCFG['siteoff'] = cmsCore::request('siteoff', 'int', 0);
        $newCFG['debug'] = cmsCore::request('debug', 'int', 0);
        $newCFG['offtext'] = htmlspecialchars(cmsCore::request('offtext', 'str', ''), ENT_QUOTES);
        $newCFG['keywords'] = cmsCore::request('keywords', 'str', '');
        $newCFG['metadesc'] = cmsCore::request('metadesc', 'str', '');
        $newCFG['seourl'] = cmsCore::request('seourl', 'int', 0);
        $newCFG['lang'] = cmsCore::request('lang', 'str', 'ru');
        $newCFG['is_change_lang'] = cmsCore::request('is_change_lang', 'int', 0);
        $newCFG['sitemail'] = cmsCore::request('sitemail', 'str', '');
        $newCFG['sitemail_name'] = cmsCore::request('sitemail_name', 'str', '');
        $newCFG['wmark'] = cmsCore::request('wmark', 'str', '');
        $newCFG['template'] = cmsCore::request('template', 'str', '');
        $newCFG['splash'] = cmsCore::request('splash', 'int', 0);
        $newCFG['slight'] = cmsCore::request('slight', 'int', 0);
        $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'];
        $newCFG['show_pw'] = cmsCore::request('show_pw', 'int', 0);
        $newCFG['last_item_pw'] = cmsCore::request('last_item_pw', 'int', 0);
        $newCFG['index_pw'] = cmsCore::request('index_pw', 'int', 0);
        $newCFG['fastcfg'] = cmsCore::request('fastcfg', 'int', 0);
        $newCFG['mailer'] = cmsCore::request('mailer', 'str', '');
        $newCFG['smtpsecure'] = cmsCore::request('smtpsecure', 'str', '');
        $newCFG['smtpauth'] = cmsCore::request('smtpauth', 'int', 0);
        $newCFG['smtpuser'] = cmsCore::inRequest('smtpuser') ? cmsCore::request('smtpuser', 'str', '') : $config['smtpuser'];
        $newCFG['smtppass'] = cmsCore::inRequest('smtppass') ? cmsCore::request('smtppass', 'str', '') : $config['smtppass'];
        $newCFG['smtphost'] = cmsCore::request('smtphost', 'str', '');
        $newCFG['smtpport'] = cmsCore::request('smtpport', 'int', '25');
        $newCFG['timezone'] = cmsCore::request('timezone', 'str', '');
        $newCFG['timediff'] = cmsCore::request('timediff', 'str', '');
        $newCFG['user_stats'] = cmsCore::request('user_stats', 'int', 0);
        $newCFG['allow_ip'] = cmsCore::request('allow_ip', 'str', '');
        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');
    }
    ?>
<div>

      <?php 
    cpCheckWritable('/includes/config.inc.php');
    ?>

<div id="config_tabs" 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="#design"><span><?php 
    echo $_LANG['AD_DESIGN'];
    ?>
</span></a></li>
		<li><a href="#time"><span><?php 
    echo $_LANG['AD_TIME'];
    ?>
</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>
  </ul>

	<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 id="basic">
			<table width="720" border="0" cellpadding="5">
				<tr>
					<td>
                        <strong><?php 
    echo $_LANG['AD_SITENAME'];
    ?>
</strong><br/>
						<span class="hinttext"><?php 
    echo $_LANG['AD_USE_HEADER'];
    ?>
</span>
                    </td>
					<td width="350" valign="top">
                        <input name="sitename" type="text" id="sitename" value="<?php 
    echo htmlspecialchars($config['sitename']);
    ?>
" style="width:358px" />
                    </td>
				</tr>
				<tr>
					<td>
                        <strong><?php 
    echo $_LANG['AD_TAGE_ADD'];
    ?>
</strong>
                    </td>
					<td valign="top">
						<label><input name="title_and_sitename" type="radio" value="1" <?php 
    if ($config['title_and_sitename']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['YES'];
    ?>
</label>
						<label><input name="title_and_sitename" type="radio" value="0" <?php 
    if (!$config['title_and_sitename']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['NO'];
    ?>
</label>
                    </td>
				</tr>
				<tr>
					<td>
                        <strong><?php 
    echo $_LANG['AD_TAGE_ADD_PAGINATION'];
    ?>
</strong>
                    </td>
					<td valign="top">
						<label><input name="title_and_page" type="radio" value="1" <?php 
    if ($config['title_and_page']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['YES'];
    ?>
</label>
						<label><input name="title_and_page" type="radio" value="0" <?php 
    if (!$config['title_and_page']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['NO'];
    ?>
</label>
                    </td>
				</tr>
				<tr>
					<td>
                        <strong><?php 
    echo $_LANG['TEMPLATE_INTERFACE_LANG'];
    ?>
:</strong>
                    </td>
					<td width="350" valign="top">
                        <select name="lang" id="lang" style="width:364px">
                            <?php 
    $langs = cmsCore::getDirsList('/languages');
    foreach ($langs as $lng) {
        echo '<option value="' . $lng . '" ' . ($config['lang'] == $lng ? 'selected="selected"' : '') . '>' . $lng . '</option>';
    }
    ?>
                        </select>
                    </td>
				</tr>
				<tr>
					<td>
                        <strong><?php 
    echo $_LANG['AD_SITE_LANGUAGE_CHANGE'];
    ?>
</strong><br/>
                        <span class="hinttext"><?php 
    echo $_LANG['AD_VIEW_FORM_LANGUAGE_CHANGE'];
    ?>
</span>
                    </td>
					<td valign="top">
						<label><input name="is_change_lang" type="radio" value="1" <?php 
    if ($config['is_change_lang']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['YES'];
    ?>
</label>
						<label><input name="is_change_lang" type="radio" value="0" <?php 
    if (!$config['is_change_lang']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['NO'];
    ?>
</label>
                    </td>
				</tr>
				<tr>
					<td>
                        <strong><?php 
    echo $_LANG['AD_SITE_ON'];
    ?>
</strong><br/>
                        <span class="hinttext"><?php 
    echo $_LANG['AD_ONLY_ADMINS'];
    ?>
</span>
                    </td>
					<td valign="top">
                        <label><input name="siteoff" type="radio" value="0" <?php 
    if (!$config['siteoff']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['YES'];
    ?>
</label>
                        <label><input name="siteoff" type="radio" value="1" <?php 
    if ($config['siteoff']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['NO'];
    ?>
</label>
                    </td>
                </tr>
				<tr>
					<td>
                        <strong><?php 
    echo $_LANG['AD_DEBUG_ON'];
    ?>
</strong><br/>
						<span class="hinttext"><?php 
    echo $_LANG['AD_WIEW_DB_ERRORS'];
    ?>
</span>
                    </td>
					<td valign="top">
						<label><input name="debug" type="radio" value="1" <?php 
    if ($config['debug']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['YES'];
    ?>
</label>
						<label><input name="debug" type="radio" value="0" <?php 
    if (!$config['debug']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['NO'];
    ?>
</label>
                    </td>
				</tr>
				<tr>
					<td valign="middle">
                        <strong><?php 
    echo $_LANG['AD_WHY_STOP'];
    ?>
</strong><br />
						<span class="hinttext"><?php 
    echo $_LANG['AD_VIEW_WHY_STOP'];
    ?>
</span>

                    </td>
					<td valign="top"><input name="offtext" type="text" id="offtext" value="<?php 
    echo htmlspecialchars($config['offtext']);
    ?>
" style="width:358px" /></td>
				</tr>
				<tr>
					<td>
                        <strong><?php 
    echo $_LANG['AD_WATERMARK'];
    ?>
 </strong><br/>
						<span class="hinttext"><?php 
    echo $_LANG['AD_WATERMARK_NAME'];
    ?>
</span>
                    </td>
					<td>
						<input name="wmark" type="text" id="wmark" value="<?php 
    echo $config['wmark'];
    ?>
" style="width:358px" />
                    </td>
				</tr>
				<tr>
					<td>
						<strong><?php 
    echo $_LANG['AD_QUICK_CONFIG'];
    ?>
</strong> <br />
						<span class="hinttext"><?php 
    echo $_LANG['AD_MODULE_CONFIG'];
    ?>
</span>
                    </td>
                    <td valign="top">
                        <label><input name="fastcfg" type="radio" value="1" <?php 
    if ($config['fastcfg']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['YES'];
    ?>
</label>
                        <label><input name="fastcfg" type="radio" value="0" <?php 
    if (!$config['fastcfg']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['NO'];
    ?>
</label>
                    </td>
				</tr>
				<tr>
					<td>
						<strong><?php 
    echo $_LANG['AD_ONLINESTATS'];
    ?>
</strong>
                    </td>
                    <td valign="top">
                        <label><input name="user_stats" type="radio" value="0" <?php 
    if (!$config['user_stats']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['AD_NO_ONLINESTATS'];
    ?>
</label><br>
                        <label><input name="user_stats" type="radio" value="1" <?php 
    if ($config['user_stats'] == 1) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['AD_YES_ONLINESTATS'];
    ?>
</label><br>
                        <label><input name="user_stats" type="radio" value="2" <?php 
    if ($config['user_stats'] == 2) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['AD_CRON_ONLINESTATS'];
    ?>
</label>
                    </td>
				</tr>
			</table>
        </div>
        <div id="home">
			<table width="720" border="0" cellpadding="5">
                <tr>
    				<td>
                        <strong><?php 
    echo $_LANG['AD_MAIN_PAGE'];
    ?>
</strong><br />
						<span class="hinttext"><?php 
    echo $_LANG['AD_MAIN_SITENAME'];
    ?>
</span><br/>
                        <span class="hinttext"><?php 
    echo $_LANG['AD_BROWSER_TITLE'];
    ?>
</span>
                    </td>
                    <td width="350" valign="top">
                        <input name="hometitle" type="text" id="hometitle" value="<?php 
    echo htmlspecialchars($config['hometitle']);
    ?>
" style="width:358px" />
                    </td>
			    </tr>
				<tr>
					<td valign="top">
						<strong><?php 
    echo $_LANG['AD_KEY_WORDS'];
    ?>
</strong><br />
						<span class="hinttext"><?php 
    echo $_LANG['AD_FROM_COMMA'];
    ?>
</span>
						<div class="hinttext" style="margin-top:4px"><a style="color:#09C" href="http://tutorial.semonitor.ru/#5" target="_blank"><?php 
    echo $_LANG['AD_WHAT_KEY_WORDS'];
    ?>
</a></div>
                    </td>
					<td>
						<textarea name="keywords" style="width:350px" rows="3" id="keywords"><?php 
    echo $config['keywords'];
    ?>
</textarea>					</td>
				</tr>
				<tr>
					<td valign="top">
						<strong><?php 
    echo $_LANG['AD_DESCRIPTION'];
    ?>
</strong><br />
						<span class="hinttext"><?php 
    echo $_LANG['AD_LESS_THAN'];
    ?>
</span>
						<div class="hinttext" style="margin-top:4px"><a style="color:#09C" href="http://tutorial.semonitor.ru/#219" target="_blank"><?php 
    echo $_LANG['AD_WHAT_DESCRIPTION'];
    ?>
</a></div>
                    </td>
					<td>
						<textarea name="metadesc" style="width:350px" rows="3" id="metadesc"><?php 
    echo $config['metadesc'];
    ?>
</textarea>
                    </td>
				</tr>
                <tr>
    				<td>
                        <strong><?php 
    echo $_LANG['AD_MAIN_PAGE_COMPONENT'];
    ?>
</strong>
                    </td>
                    <td width="350" valign="top">
                        <select name="homecom" style="width:358px">
                            <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>
                    </td>
			    </tr>
				<tr>
					<td>
						<strong><?php 
    echo $_LANG['AD_GATE_PAGE'];
    ?>
</strong> <br/>
						<span class="hinttext"><?php 
    echo $_LANG['AD_FIRST_VISIT'];
    ?>
</span> <br/>
                        <span class="hinttext"><?php 
    echo $_LANG['AD_FIRST_VISIT_TEMPLATE'];
    ?>
</strong></span>
					</td>
					<td valign="top">
						<label><input name="splash" type="radio" value="0" <?php 
    if (!$config['splash']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['HIDE'];
    ?>
</label>
						<label><input name="splash" type="radio" value="1" <?php 
    if ($config['splash']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['SHOW'];
    ?>
</label>
					</td>
				</tr>
			</table>
        </div>
		<div id="design">
			<table width="720" border="0" cellpadding="5">
				<tr>
					<td valign="top">
                        <div style="margin-top:2px">
                            <strong><?php 
    echo $_LANG['TEMPLATE'];
    ?>
:</strong><br />
                            <span class="hinttext"><?php 
    echo $_LANG['AD_TEMPLATE_FOLDER'];
    ?>
 </span>
                        </div>
					</td>
					<td>
                        <select name="template" id="template" style="width:350px" onchange="document.CFGform.submit();">
                            <?php 
    $templates = cmsCore::getDirsList('/templates');
    foreach ($templates as $template) {
        echo '<option value="' . $template . '" ' . ($config['template'] == $template ? 'selected="selected"' : '') . '>' . $template . '</option>';
    }
    $tpl_info = $inPage->getCurrentTplInfo();
    ?>
                        </select>
                            <?php 
    if (file_exists(PATH . '/templates/' . TEMPLATE . '/positions.jpg')) {
        ?>
                            <script>
                            $(function() {
                                $('#pos').dialog({modal: true, autoOpen: false, closeText: LANG_CLOSE, width: 'auto'});
                            });
                            </script>
                            <a onclick="$('#pos').dialog('open');return false;" href="#" class="ajaxlink"><?php 
        echo $_LANG['AD_TPL_POS'];
        ?>
</a>
                                <div id="pos" title="<?php 
        echo $_LANG['AD_TPL_POS'];
        ?>
"><img src="/templates/<?php 
        echo TEMPLATE;
        ?>
/positions.jpg" alt="<?php 
        echo $_LANG['AD_TPL_POS'];
        ?>
" /></div>
                            <?php 
    }
    ?>
                        <div style="margin-top:5px" class="hinttext">
                            <?php 
    echo sprintf($_LANG['AD_TEMPLATE_INFO'], $tpl_info['author'], $tpl_info['renderer'], $tpl_info['ext']);
    ?>
                        </div>
					</td>
				</tr>
				<tr>
					<td><strong><?php 
    echo $_LANG['AD_SEARCH_RESULT'];
    ?>
</strong></td>
					<td valign="top">
						<label><input name="slight" type="radio" value="1" <?php 
    if ($config['slight']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['YES'];
    ?>
</label>
						<label><input name="slight" type="radio" value="0" <?php 
    if (!$config['slight']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['NO'];
    ?>
</label>
					</td>
				</tr>
			</table>
		</div>
		<div id="time">
			<table width="720" border="0" cellpadding="5">
				<tr>
					<td valign="top" width="100">
                        <div style="margin-top:2px">
                            <strong><?php 
    echo $_LANG['AD_TIME_ARREA'];
    ?>
</strong>
                        </div>
					</td>
					<td>
                        <select name="timezone" id="timezone" style="width:350px">
                            <?php 
    include PATH . '/admin/includes/timezones.php';
    ?>
                            <?php 
    foreach ($timezones as $tz) {
        ?>
                            <option value="<?php 
        echo $tz;
        ?>
" <?php 
        if ($tz == $config['timezone']) {
            ?>
selected="selected"<?php 
        }
        ?>
><?php 
        echo $tz;
        ?>
</option>
                            <?php 
    }
    ?>
                        </select>
					</td>
				</tr>
				<tr>
					<td>
						<strong><?php 
    echo $_LANG['AD_TIME_SLIP'];
    ?>
</strong>
					</td>
					<td width="350">
                        <select name="timediff" id="timediff" style="width:60px">
                            <?php 
    for ($h = -12; $h <= 12; $h++) {
        ?>
                                <option value="<?php 
        echo $h;
        ?>
" <?php 
        if ($h == $config['timediff']) {
            ?>
selected="selected"<?php 
        }
        ?>
><?php 
        echo $h > 0 ? '+' . $h : $h;
        ?>
</option>
                            <?php 
    }
    ?>
                        </select>
					</td>
				</tr>
			</table>
		</div>
		<div id="database">
			<table width="720" border="0" cellpadding="5" style="margin-top:15px;">
				<tr>
					<td>
						<strong><?php 
    echo $_LANG['AD_DB_SIZE'];
    ?>
</strong>
					</td>
					<td width="350">
                        <?php 
    $result = $inDB->query("SELECT (sum(data_length)+sum(index_length))/1024/1024 as size FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '{$config['db_base']}'", true);
    if (!$inDB->error()) {
        $s = $inDB->fetch_assoc($result);
        echo round($s['size'], 2) . ' ' . $_LANG['SIZE_MB'];
    } else {
        echo $_LANG['AD_DB_SIZE_ERROR'];
    }
    ?>
					</td>
				</tr>
				<tr>
					<td colspan="2"><span class="hinttext"><?php 
    echo $_LANG['AD_MYSQL_CONFIG'];
    ?>
</span></td>
				</tr>
			</table>
        </div>
		<div id="mail">
			<table width="720" border="0" cellpadding="5" style="margin-top:15px;">
				<tr>
					<td width="250">
                        <strong><?php 
    echo $_LANG['AD_SITE_EMAIL'];
    ?>
 </strong><br/>
						<span class="hinttext"><?php 
    echo $_LANG['AD_SITE_EMAIL_POST'];
    ?>
</span>
                    </td>
					<td>
						<input name="sitemail" type="text" id="sitemail" value="<?php 
    echo $config['sitemail'];
    ?>
" style="width:358px" />
                    </td>
				</tr>
				<tr>
					<td width="250">
                        <strong><?php 
    echo $_LANG['AD_SENDER_EMAIL'];
    ?>
</strong><br/>
						<span class="hinttext"><?php 
    echo $_LANG['AD_IF_NOT_HANDLER'];
    ?>
</span>
                    </td>
					<td>
						<input name="sitemail_name" type="text" id="sitemail_name" value="<?php 
    echo $config['sitemail_name'];
    ?>
" style="width:358px" />
                    </td>
				</tr>
				<tr>
					<td>
						<strong><?php 
    echo $_LANG['AD_SEND_METHOD'];
    ?>
</strong>
					</td>
					<td>
						<select name="mailer" style="width:354px">
							<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>
					</td>
				</tr>
				<tr>
					<td>
						<strong><?php 
    echo $_LANG['AD_ENCRYPTING'];
    ?>
</strong>
					</td>
					<td>
						<label><input name="smtpsecure" type="radio" value="" <?php 
    if (!$config['smtpsecure']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['NO'];
    ?>
</label>
						<label><input name="smtpsecure" type="radio" value="tls" <?php 
    if ($config['smtpsecure'] == 'tls') {
        echo 'checked="checked"';
    }
    ?>
/> tls</label>
						<label><input name="smtpsecure" type="radio" value="ssl" <?php 
    if ($config['smtpsecure'] == 'ssl') {
        echo 'checked="checked"';
    }
    ?>
/> ssl</label>
					</td>
				</tr>
				<tr>
					<td>
						<strong><?php 
    echo $_LANG['AD_SMTP_LOGIN'];
    ?>
</strong>
					</td>
					<td>
						<label><input name="smtpauth" type="radio" value="1" <?php 
    if ($config['smtpauth']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['YES'];
    ?>
</label>
						<label><input name="smtpauth" type="radio" value="0" <?php 
    if (!$config['smtpauth']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['NO'];
    ?>
</label>
					</td>
				</tr>
				<tr>
					<td>
						<strong><?php 
    echo $_LANG['AD_SMTP_USER'];
    ?>
</strong>
					</td>
					<td>
                        <?php 
    if (!$config['smtpuser']) {
        ?>
                            <input name="smtpuser" type="text" id="smtpuser" value="<?php 
        echo $config['smtpuser'];
        ?>
" style="width:350px" />
                        <?php 
    } else {
        ?>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_IF_CHANGE_USER'];
        ?>
</span>
                        <?php 
    }
    ?>
					</td>
				</tr>
				<tr>
					<td>
						<strong><?php 
    echo $_LANG['AD_SMTP_PASS'];
    ?>
</strong>
					</td>
					<td>
                        <?php 
    if (!$config['smtppass']) {
        ?>
                            <input name="smtppass" type="password" id="smtppass" value="<?php 
        echo $config['smtppass'];
        ?>
" style="width:350px" />
                        <?php 
    } else {
        ?>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_IF_CHANGE_PASS'];
        ?>
</span>
                        <?php 
    }
    ?>
					</td>
				</tr>
				<tr>
					<td>
						<strong><?php 
    echo $_LANG['AD_SMTP_HOST'];
    ?>
</strong><br>
                        <span class="hinttext"><?php 
    echo $_LANG['AD_SOME_HOST'];
    ?>
</span>
					</td>
					<td>
						<input name="smtphost" type="text" id="smtphost" value="<?php 
    echo $config['smtphost'];
    ?>
" style="width:350px" />
					</td>
				</tr>
				<tr>
					<td>
						<strong><?php 
    echo $_LANG['AD_SMTP_PORT'];
    ?>
</strong>
					</td>
					<td>
						<input name="smtpport" type="text" id="smtpport" value="<?php 
    echo $config['smtpport'];
    ?>
" style="width:350px" />
					</td>
				</tr>
			</table>
		</div>
		<div id="other">
			<table width="720" border="0" cellpadding="5">
				<tr>
					<td>
						<strong><?php 
    echo $_LANG['AD_VIEW_PATHWAY'];
    ?>
</strong><br />
						<span class="hinttext">
                            <?php 
    echo $_LANG['AD_PATH_TO_CATEGORY'];
    ?>
                        </span>
					</td>
					<td>
						<label><input name="show_pw" type="radio" value="1" <?php 
    if ($config['show_pw']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['YES'];
    ?>
</label>
						<label><input name="show_pw" type="radio" value="0" <?php 
    if (!$config['show_pw']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['NO'];
    ?>
</label>
					</td>
				</tr>
				<tr>
					<td><strong><?php 
    echo $_LANG['AD_MAINPAGE_PATHWAY'];
    ?>
</strong></td>
					<td>
						<label><input name="index_pw" type="radio" value="1" <?php 
    if ($config['index_pw']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['YES'];
    ?>
</label>
						<label><input name="index_pw" type="radio" value="0" <?php 
    if (!$config['index_pw']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['NO'];
    ?>
</label>
					</td>
				</tr>
				<tr>
					<td><strong><?php 
    echo $_LANG['AD_PAGE_PATHWAY'];
    ?>
</strong></td>
					<td>
						<label><input name="last_item_pw" type="radio" value="0" <?php 
    if (!$config['last_item_pw']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['HIDE'];
    ?>
</label>
						<label><input name="last_item_pw" type="radio" value="1" <?php 
    if ($config['last_item_pw'] == 1) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['AD_PAGE_PATHWAY_LINK'];
    ?>
</label>
						<label><input name="last_item_pw" type="radio" value="2" <?php 
    if ($config['last_item_pw'] == 2) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    echo $_LANG['AD_PAGE_PATHWAY_TEXT'];
    ?>
</label>
					</td>
				</tr>
			</table>
        </div>
        <div id="seq">
			<table width="720" border="0" cellpadding="5">
				<tr>
					<td>
						<strong><?php 
    echo $_LANG['AD_IP_ADMIN'];
    ?>
</strong> <br />
						<span class="hinttext"><?php 
    echo $_LANG['AD_IP_COMMA'];
    ?>
</span></td>
				<td valign="top">
					<input name="allow_ip" type="text" id="allow_ip" value="<?php 
    echo htmlspecialchars($config['allow_ip']);
    ?>
" style="width:358px" /></td>
				</tr>
			</table>
    <p style="color:#900"><?php 
    echo $_LANG['AD_ATTENTION'];
    ?>
</p>
        </div>

	<div align="left">
		<input name="do" type="hidden" id="do" value="save" />
		<input name="save" type="submit" id="save" value="<?php 
    echo $_LANG['SAVE'];
    ?>
" />
        <input name="back" type="button" id="back" value="<?php 
    echo $_LANG['CANCEL'];
    ?>
" onclick="window.history.back();" />
	</div>
</form>
</div></div>
<?php 
}
Ejemplo n.º 22
0
function applet_arhive() {
    $inCore = cmsCore::getInstance();
    
    global $_LANG;
    
    cmsCore::c('page')->setTitle($_LANG['AD_ARTICLES_ARCHIVE']);
    
    $cfg = $inCore->loadComponentConfig('content');
    $cfg_arhive = $inCore->loadComponentConfig('arhive');

    cpAddPathway($_LANG['AD_ARTICLE_SITE'], 'index.php?view=tree');
    cpAddPathway($_LANG['AD_ARTICLES_ARCHIVE'], 'index.php?view=arhive');

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

    if ($do == 'saveconfig') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }
        
        $cfg['source'] = cmsCore::request('source', 'str', '');
        $inCore->saveComponentConfig('arhive', $cfg);
        
        cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'] , 'success');
        cmsCore::redirect('?view=arhive&do=config');
    }
    
    if ($do == 'config') {
        $toolmenu = array(
            array( 'icon' => 'folders.gif', 'title' => $_LANG['AD_LIST_OF_ARTICLES'], 'link' => '?view=arhive' )
        );
        
        cpToolMenu($toolmenu);
        cpAddPathway($_LANG['AD_SETTINGS'], 'index.php?view=arhive&do=config');
?>
<form action="index.php?view=arhive&do=saveconfig" method="post" name="optform" target="_self" id="form1">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
    
    <div style="width:550px">
        <div class="form-group">
            <label><?php echo $_LANG['AD_SOURCE_MATERIALS']; ?></label>
            <select class="form-control" name="source">
                <option value="content" <?php if ($cfg_arhive['source'] == 'content') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_ARTICLE_SITE']; ?></option>
                <option value="arhive" <?php if ($cfg_arhive['source'] == 'arhive') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_ARTICLES_ARCHIVE']; ?></option>
                <option value="both" <?php if ($cfg_arhive['source'] == 'both') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_CATALOG_AND_ARCHIVE']; ?></option>
            </select>
        </div>
    </div>
    
    <div>
        <input type="hidden" name="opt" value="saveconfig" />
        <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.location.href='index.php?view=arhive';" />
    </div>
</form>
<?php
    }

    if ($do == 'list') {
        $toolmenu = array(
            array( 'icon' => 'config.gif', 'title' => $_LANG['AD_SETTINGS'], 'link' => '?view=arhive&do=config' ),
            array( 'icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=arhive&do=delete&multiple=1');" )
        );

        cpToolMenu($toolmenu);

        //TABLE COLUMNS
        $fields = array(
            array( 'title' => 'id', 'field' => 'id', 'width' => '40' ),
            array( 'title' => $_LANG['AD_CREATE'], 'field' => 'pubdate', 'width' => '80', 'filter' => 15, 'fdate' => '%d/%m/%Y' ),
            array( 'title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '', 'link' => '?view=content&do=edit&id=%id%', 'filter' => 15 ),
            array( 'title' => $_LANG['AD_PARTITION'], 'field' => 'category_id', 'width' => '150', 'filter' => 1, 'prc' => 'cpCatById', 'filterlist' => cpGetList('cms_category') )
        );

        //ACTIONS
        $actions = array(
            array( 'title' => $_LANG['AD_TO_ARTICLES_CATALOG'], 'icon' => 'arhive_off.gif', 'link' => '?view=arhive&do=arhive_off&id=%id%' ),
            array( 'title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'link' => '?view=content&do=delete&id=%id%', 'confirm' => $_LANG['AD_DELETE_MATERIALS'] )
        );

        //Print table
        cpListTable('cms_content', $fields, $actions, 'is_arhive=1');
    }
    
    if ($do == 'arhive_off') {
        if (cmsCore::inRequest('id')) {
            cmsCore::c('db')->setFlag('cms_content', $id, 'is_arhive', '0');
            cmsCore::redirect('?view=arhive');
        }
    }

    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) {
                cmsCore::m('content')->deleteArticle($id, $cfg['af_delete']);
            }
        } else {
            cmsCore::m('content')->deleteArticles(cmsCore::request('item', 'array_int'), $cfg['af_delete']);
        }
        cmsCore::redirect('?view=arhive');
    }
}
Ejemplo n.º 23
0
Archivo: tree.php Proyecto: r2git/icms1
function applet_tree()
{
    $inCore = cmsCore::getInstance();
    $inUser = cmsUser::getInstance();
    $inDB = cmsDatabase::getInstance();
    $inPage = cmsPage::getInstance();
    cmsCore::loadLib('tags');
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/content', $adminAccess)) {
        cpAccessDenied();
    }
    $cfg = $inCore->loadComponentConfig('content');
    cmsCore::loadModel('content');
    $model = new cms_model_content();
    $GLOBALS['cp_page_title'] = $_LANG['AD_ARTICLES'];
    cpAddPathway($_LANG['AD_ARTICLES'], 'index.php?view=tree');
    $GLOBALS['cp_page_head'][] = '<script language="JavaScript" type="text/javascript" src="js/content.js"></script>';
    echo '<script>';
    echo cmsPage::getLangJS('AD_NO_SELECTED_ARTICLES');
    echo cmsPage::getLangJS('AD_DELETE_SELECTED_ARTICLES');
    echo cmsPage::getLangJS('AD_PIECES');
    echo cmsPage::getLangJS('AD_CATEGORY_DELETE');
    echo cmsPage::getLangJS('AD_AND_SUB_CATS');
    echo cmsPage::getLangJS('AD_DELETE_SUB_ARTICLES');
    echo '</script>';
    $do = cmsCore::request('do', 'str', 'tree');
    //============================================================================//
    //============================================================================//
    if ($do == 'tree') {
        $toolmenu[] = array('icon' => 'config.gif', 'title' => $_LANG['AD_SETUP_CATEGORY'], 'link' => '?view=components&do=config&link=content');
        $toolmenu[] = array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=components&do=config&link=content');
        cpToolMenu($toolmenu);
        $only_hidden = cmsCore::request('only_hidden', 'int', 0);
        $category_id = cmsCore::request('cat_id', 'int', 0);
        $base_uri = 'index.php?view=tree';
        $title_part = cmsCore::request('title', 'str', '');
        $def_order = $category_id ? 'con.ordering' : 'pubdate';
        $orderby = cmsCore::request('orderby', 'str', $def_order);
        $orderto = cmsCore::request('orderto', 'str', 'asc');
        $page = cmsCore::request('page', 'int', 1);
        $perpage = 20;
        $hide_cats = cmsCore::request('hide_cats', 'int', 0);
        $cats = $model->getCatsTree();
        if ($category_id) {
            $model->whereCatIs($category_id);
        }
        if ($title_part) {
            $inDB->where('LOWER(con.title) LIKE \'%' . mb_strtolower($title_part) . '%\'');
        }
        if ($only_hidden) {
            $inDB->where('con.published = 0');
        }
        $inDB->orderBy($orderby, $orderto);
        $inDB->limitPage($page, $perpage);
        $total = $model->getArticlesCount(false);
        $items = $model->getArticlesList(false);
        $pages = ceil($total / $perpage);
        $tpl_file = 'admin/content.php';
        $tpl_dir = file_exists(TEMPLATE_DIR . $tpl_file) ? TEMPLATE_DIR : DEFAULT_TEMPLATE_DIR;
        include $tpl_dir . $tpl_file;
    }
}
Ejemplo n.º 24
0
            } else {
                $answers[$answer] = 0;
            }
        }
    }
    $item['answers'] = cmsCore::arrayToYaml($answers);
    $inDB->update('cms_polls', $item, $poll_id);
    cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
    cmsCore::redirect('?view=components&do=config&id=' . $id);
}
if ($opt == 'add' || $opt == 'edit') {
    if ($opt == 'add') {
        cpAddPathway($_LANG['AD_ADD_POLL']);
    } else {
        $mod = $model->getPoll(cmsCore::request('poll_id', 'int'));
        cpAddPathway($_LANG['AD_EDIT_POLL']);
        $answers_title = array();
        $answers_num = array();
        $item = 1;
        foreach ($mod['answers'] as $answer => $num) {
            $answers_title[$item] = htmlspecialchars($answer);
            $answers_num[$item] = $num;
            $item++;
        }
    }
    ?>
    <form id="addform" name="addform" method="post" action="index.php?view=components&do=config&id=<?php 
    echo $id;
    ?>
">
      <table width="600" border="0" cellspacing="5" class="proptable">
Ejemplo n.º 25
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 
    }
}
Ejemplo n.º 26
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 
    }
}
Ejemplo n.º 27
0
function applet_install()
{
    $inCore = cmsCore::getInstance();
    global $_LANG;
    $GLOBALS['cp_page_title'] = $_LANG['AD_SETUP_EXTENSION'];
    $do = cmsCore::request('do', 'str', 'list');
    global $adminAccess;
    // ========================================================================== //
    if ($do == 'module') {
        if (!cmsUser::isAdminCan('admin/modules', $adminAccess)) {
            cpAccessDenied();
        }
        cpAddPathway($_LANG['AD_SETUP_MODULES'], 'index.php?view=install&do=module');
        $new_modules = $inCore->getNewModules();
        $upd_modules = $inCore->getUpdatedModules();
        echo '<h3>' . $_LANG['AD_SETUP_MODULES'] . '</h3>';
        if (!$new_modules && !$upd_modules) {
            echo '<p>' . $_LANG['AD_NO_SEARCH_MODULES'] . '</p>';
            echo '<p>' . $_LANG['AD_IF_WANT_SETUP_MODULES'] . '</p>';
            echo '<p><a href="javascript:window.history.go(-1);">' . $_LANG['BACK'] . '</a></p>';
            return;
        }
        if ($new_modules) {
            echo '<p><strong>' . $_LANG['AD_SEARCH_MODULES'] . '</strong></p>';
            modulesList($new_modules, $_LANG['AD_SETUP'], 'install_module');
        }
        if ($upd_modules) {
            echo '<p><strong>' . $_LANG['AD_MODULES_UPDATE'] . '</strong></p>';
            modulesList($upd_modules, $_LANG['AD_UPDATE'], 'upgrade_module');
        }
        echo '<p>' . $_LANG['AD_CLICK_TO_CONTINUE_MODULE'] . '</p>';
        echo '<p><a href="javascript:window.history.go(-1);">' . $_LANG['BACK'] . '</a></p>';
    }
    // ========================================================================== //
    if ($do == 'install_module') {
        if (!cmsUser::isAdminCan('admin/modules', $adminAccess)) {
            cpAccessDenied();
        }
        $error = '';
        $module_id = cmsCore::request('id', 'str', '');
        if (!$module_id) {
            cmsCore::redirectBack();
        }
        if ($inCore->loadModuleInstaller($module_id)) {
            $_module = call_user_func('info_module_' . $module_id);
            //////////////////////////////////////
            $error = call_user_func('install_module_' . $module_id);
        } else {
            $error = $_LANG['AD_MODULE_WIZARD_FAILURE'];
        }
        if ($error === true) {
            $inCore->installModule($_module, $_module['config']);
            cmsCore::addSessionMessage($_LANG['AD_MODULE'] . ' <strong>"' . $_module['title'] . '"</strong> ' . $_LANG['AD_SUCCESS'] . $_LANG['AD_IS_INSTALL'], 'success');
            cmsCore::redirect('/admin/index.php?view=modules');
        } else {
            cmsCore::addSessionMessage($error, 'error');
            cmsCore::redirectBack();
        }
    }
    // ========================================================================== //
    if ($do == 'upgrade_module') {
        if (!cmsUser::isAdminCan('admin/modules', $adminAccess)) {
            cpAccessDenied();
        }
        $error = '';
        $module_id = cmsCore::request('id', 'str', '');
        if (!$module_id) {
            cmsCore::redirectBack();
        }
        if ($inCore->loadModuleInstaller($module_id)) {
            $_module = call_user_func('info_module_' . $module_id);
            if (isset($_module['link'])) {
                $_module['content'] = $_module['link'];
            }
            $error = call_user_func('upgrade_module_' . $module_id);
        } else {
            $error = $_LANG['AD_SETUP_WIZARD_FAILURE'];
        }
        if ($error === true) {
            $inCore->upgradeModule($_module, $_module['config']);
            cmsCore::addSessionMessage($_LANG['AD_MODULE'] . ' <strong>"' . $_module['title'] . '"</strong> ' . $_LANG['AD_SUCCESS'] . $_LANG['AD_IS_UPDATE'], 'success');
            cmsCore::redirect('/admin/index.php?view=modules');
        } else {
            cmsCore::addSessionMessage($error, 'error');
            cmsCore::redirectBack();
        }
    }
    // ========================================================================== //
    if ($do == 'component') {
        if (!cmsUser::isAdminCan('admin/components', $adminAccess)) {
            cpAccessDenied();
        }
        cpAddPathway($_LANG['AD_SETUP_COMPONENTS'], 'index.php?view=install&do=component');
        $new_components = $inCore->getNewComponents();
        $upd_components = $inCore->getUpdatedComponents();
        echo '<h3>' . $_LANG['AD_SETUP_COMPONENTS'] . '</h3>';
        if (!$new_components && !$upd_components) {
            echo '<p>' . $_LANG['AD_NO_SEARCH_COMPONENTS'] . '</p>';
            echo '<p>' . $_LANG['AD_IF_WANT_SETUP_COMPONENTS'] . '</p>';
            ?>
            <h3><?php 
            echo $_LANG['AD_TRY_PREMIUM'];
            ?>
</h3>
            <div class="advert_iaudio"><a href="http://www.instantvideo.ru/software/iaudio.html"><strong>iAudio</strong></a> &mdash; <?php 
            echo $_LANG['AD_AUDIO_GALERY'];
            ?>
</div>
            <div class="advert_billing"><a href="http://www.cms.vadyus.com/billing/about.html"><strong><?php 
            echo $_LANG['AD_BILLING'];
            ?>
</strong></a> &mdash; <?php 
            echo $_LANG['AD_GAIN'];
            ?>
</div>
            <div class="advert_inmaps"><a href="http://www.instantmaps.ru/"><strong>InstantMaps</strong></a> &mdash; <?php 
            echo $_LANG['AD_OBJECT_TO_MAP'];
            ?>
</div>
            <div class="advert_inshop"><a href="http://www.cms.vadyus.com/blogs/InstantSoft/professionalnyi-magazin-dlja-vadyus.html"><strong>InstantShop</strong></a> &mdash; <?php 
            echo $_LANG['AD_SHOP'];
            ?>
</div>
            <div class="advert_invideo"><a href="http://www.instantvideo.ru/software/instantvideo.html"><strong>InstantVideo</strong></a> &mdash; <?php 
            echo $_LANG['AD_VIDEO_GALERY'];
            ?>
</div>
        <?php 
            return;
        }
        if ($new_components) {
            echo '<p><strong>' . $_LANG['AD_COMPONENTS_SETUP'] . '</strong></p>';
            componentsList($new_components, $_LANG['AD_SETUP'], 'install_component');
        }
        if ($upd_components) {
            echo '<p><strong>' . $_LANG['AD_COMPONENTS_UPDATE'] . '</strong></p>';
            componentsList($upd_components, $_LANG['AD_UPDATE'], 'upgrade_component');
        }
        echo '<p>' . $_LANG['AD_CLICK_TO_CONTINUE_COMPONENT'] . '</p>';
        echo '<p><a href="javascript:window.history.go(-1);">' . $_LANG['BACK'] . '</a></p>';
    }
    // ========================================================================== //
    if ($do == 'install_component') {
        $error = '';
        $component = cmsCore::request('id', 'str', '');
        if (!$component) {
            cmsCore::redirectBack();
        }
        if (!cmsUser::isAdminCan('admin/components', $adminAccess)) {
            cpAccessDenied();
        }
        if ($inCore->loadComponentInstaller($component)) {
            $_component = call_user_func('info_component_' . $component);
            $error = call_user_func('install_component_' . $component);
        } else {
            $error = $_LANG['AD_COMPONENT_WIZARD_FAILURE'];
        }
        if ($error === true) {
            $inCore->installComponent($_component, $_component['config']);
            $info_text = '<p>' . $_LANG['AD_COMPONENT'] . ' <strong>"' . $_component['title'] . '"</strong> ' . $_LANG['AD_SUCCESS'] . $_LANG['AD_IS_INSTALL'] . '</p>';
            if (isset($_component['modules'])) {
                if (is_array($_component['modules'])) {
                    $info_text .= '<p>' . $_LANG['AD_OPT_INSTALL_MODULES'] . ':</p>';
                    $info_text .= '<ul>';
                    foreach ($_component['modules'] as $module => $title) {
                        $info_text .= '<li>' . $title . '</li>';
                    }
                    $info_text .= '</ul>';
                }
            }
            if (isset($_component['plugins'])) {
                if (is_array($_component['plugins'])) {
                    $info_text .= '<p>' . $_LANG['AD_OPT_INSTALL_PLUGINS'] . ':</p>';
                    $info_text .= '<ul>';
                    foreach ($_component['plugins'] as $module => $title) {
                        $info_text .= '<li>' . $title . '</li>';
                    }
                    $info_text .= '</ul>';
                }
            }
            cmsCore::addSessionMessage($info_text, 'success');
            cmsCore::redirect('/admin/index.php?view=components');
        } else {
            cmsCore::addSessionMessage($error, 'error');
            cmsCore::redirectBack();
        }
    }
    // ========================================================================== //
    if ($do == 'upgrade_component') {
        cpAddPathway($_LANG['AD_UPDATE_COMPONENTS'], 'index.php?view=install&do=component');
        $error = '';
        $component = cmsCore::request('id', 'str', '');
        if (!$component) {
            cmsCore::redirectBack();
        }
        if (!cmsUser::isAdminCan('admin/components', $adminAccess)) {
            cpAccessDenied();
        }
        if (!cmsUser::isAdminCan('admin/com_' . $component, $adminAccess)) {
            cpAccessDenied();
        }
        if ($inCore->loadComponentInstaller($component)) {
            $_component = call_user_func('info_component_' . $component);
            $error = call_user_func('upgrade_component_' . $component);
        } else {
            $error = $_LANG['AD_COMPONENT_WIZARD_FAILURE'];
        }
        if ($error === true) {
            $inCore->upgradeComponent($_component, $_component['config']);
            $info_text = $_LANG['AD_COMPONENT'] . ' <strong>"' . $_component['title'] . '"</strong> ' . $_LANG['AD_SUCCESS'] . $_LANG['AD_IS_UPDATE'];
            cmsCore::addSessionMessage($info_text, 'success');
            cmsCore::redirect('/admin/index.php?view=components');
        } else {
            cmsCore::addSessionMessage($error, 'error');
            cmsCore::redirectBack();
        }
    }
    // ========================================================================== //
    if ($do == 'remove_component') {
        $component_id = cmsCore::request('id', 'int', '');
        if (!$component_id) {
            cmsCore::redirectBack();
        }
        $com = $inCore->getComponentById($component_id);
        if (!cmsUser::isAdminCan('admin/components', $adminAccess)) {
            cpAccessDenied();
        }
        if (!cmsUser::isAdminCan('admin/com_' . $com, $adminAccess)) {
            cpAccessDenied();
        }
        if ($inCore->loadComponentInstaller($com)) {
            if (function_exists('remove_component_' . $com)) {
                call_user_func('remove_component_' . $com);
            }
        }
        $inCore->removeComponent($component_id);
        cmsCore::addSessionMessage($_LANG['AD_COMPONENT_IS_DELETED'], 'success');
        cmsCore::redirect('/admin/index.php?view=components');
    }
    // ========================================================================== //
    if ($do == 'plugin') {
        if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) {
            cpAccessDenied();
        }
        cpAddPathway($_LANG['AD_SETUP_PLUGINS'], 'index.php?view=install&do=plugin');
        $new_plugins = $inCore->getNewPlugins();
        $upd_plugins = $inCore->getUpdatedPlugins();
        echo '<h3>' . $_LANG['AD_SETUP_PLUGINS'] . '</h3>';
        if (!$new_plugins && !$upd_plugins) {
            echo '<p>' . $_LANG['AD_NO_SEARCH_PLUGINS'] . '</p>';
            echo '<p>' . $_LANG['AD_IF_WANT_SETUP_PLUGINS'] . '</p>';
            echo '<p><a href="javascript:window.history.go(-1);">' . $_LANG['BACK'] . '</a></p>';
            return;
        }
        if ($new_plugins) {
            echo '<p><strong>' . $_LANG['AD_PLUGINS_SETUP'] . '</strong></p>';
            pluginsList($new_plugins, $_LANG['AD_SETUP'], 'install_plugin');
        }
        if ($upd_plugins) {
            echo '<p><strong>' . $_LANG['AD_PLUGINS_UPDATE'] . '</strong></p>';
            pluginsList($upd_plugins, $_LANG['AD_UPDATE'], 'upgrade_plugin');
        }
        echo '<p>' . $_LANG['AD_CLICK_TO_CONTINUE_PLUGIN'] . '</p>';
        echo '<p><a href="javascript:window.history.go(-1);">' . $_LANG['BACK'] . '</a></p>';
    }
    // ========================================================================== //
    if ($do == 'install_plugin') {
        if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) {
            cpAccessDenied();
        }
        cpAddPathway($_LANG['AD_SETUP_PLUGIN'], 'index.php?view=install&do=plugin');
        $error = '';
        $plugin_id = cmsCore::request('id', 'str', '');
        if (!$plugin_id) {
            cmsCore::redirectBack();
        }
        $plugin = $inCore->loadPlugin($plugin_id);
        if (!$plugin) {
            $error = $_LANG['AD_PLUGIN_FAILURE'];
        }
        if (!$error && $plugin->install()) {
            cmsCore::addSessionMessage($_LANG['AD_PLUGIN'] . ' <strong>"' . $plugin->info['title'] . '"</strong> ' . $_LANG['AD_SUCCESS'] . $_LANG['AD_IS_INSTALL'] . '. ' . $_LANG['AD_ENABLE_PLUGIN'], 'success');
            cmsCore::redirect('/admin/index.php?view=plugins');
        }
        if ($error) {
            echo '<p style="color:red">' . $error . '</p>';
        }
        echo '<p><a href="index.php?view=install&do=plugin">' . $_LANG['BACK'] . '</a></p>';
    }
    // ========================================================================== //
    if ($do == 'upgrade_plugin') {
        if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) {
            cpAccessDenied();
        }
        cpAddPathway($_LANG['AD_UPDATE_PLUGIN'], 'index.php?view=install&do=plugin');
        $error = '';
        $plugin_id = cmsCore::request('id', 'str', '');
        if (!$plugin_id) {
            cmsCore::redirectBack();
        }
        $plugin = $inCore->loadPlugin($plugin_id);
        if (!$plugin) {
            $error = $_LANG['AD_PLUGIN_FAILURE'];
        }
        if (!$error && $plugin->upgrade()) {
            cmsCore::addSessionMessage($_LANG['AD_PLUGIN'] . ' <strong>"' . $plugin->info['title'] . '"</strong> ' . $_LANG['AD_SUCCESS'] . $_LANG['AD_IS_UPDATE'], 'success');
            cmsCore::redirect('/admin/index.php?view=plugins');
        }
        if ($error) {
            echo '<p style="color:red">' . $error . '</p>';
        }
        echo '<p><a href="index.php?view=install&do=plugin">' . $_LANG['BACK'] . '</a></p>';
    }
    // ========================================================================== //
    if ($do == 'remove_plugin') {
        if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) {
            cpAccessDenied();
        }
        $plugin_id = cmsCore::request('id', 'str', '');
        if (!$plugin_id) {
            cmsCore::redirectBack();
        }
        $inCore->removePlugin($plugin_id);
        cmsCore::addSessionMessage($_LANG['AD_REMOVE_PLUGIN_OK'], 'success');
        cmsCore::redirect('/admin/index.php?view=plugins');
    }
}
Ejemplo n.º 28
0
	</form>	
	
	<?php 
}
if ($opt == 'add_color_ok') {
    $title = $_REQUEST['title'];
    $color = $_REQUEST['color'];
    $font_color_title = $_REQUEST['font_color_title'];
    $font_color = $_REQUEST['font_color'];
    $sql = "INSERT INTO `cms_notes_color` (\n`id` ,\n`color` ,\n`published` ,\n`title` ,\n`font_color_title` ,\n`font_color` \n)\nVALUES (\nNULL , '" . $color . "', '1', '" . $title . "', '" . $font_color_title . "', '" . $font_color . "'\n);";
    $inDB->query($sql);
    header('location:?view=components&do=config&id=' . (int) $_REQUEST['id'] . '&opt=list_color');
}
if ($opt == 'add_color') {
    echo '<h3>Добавление цвета</h3>';
    cpAddPathway('Добавление цвета', '?view=components&do=config&id=' . (int) $_REQUEST['id'] . '&opt=list_cats');
    ?>
		<form id="addform" name="addform" method="post" action="index.php?view=components&amp;do=config&amp;id=<?php 
    echo (int) $_REQUEST['id'];
    ?>
">
			<table width="620" border="0" cellpadding="0" cellspacing="10" class="proptable">
			  <tr>
				<td><strong>Название цвета: </strong></td>
				<td width="220"><input name="title" type="text" id="title" style="width:220px" value=""/></td>
			  </tr>
			  <tr>
				<td><strong>цвет: </strong></td>
				<td width="220"><input name="color" type="text" id="title" style="width:220px" value="#"/></td>
			  </tr>
			  <tr>
Ejemplo n.º 29
0
     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('item_id', 'int', 0);
     }
     $mod = cms_model_banners::getBanner($item_id);
     if (!$mod) {
         cmsCore::error404();
     }
     echo '<h3>' . $mod['title'] . ' ' . $ostatok . '</h3>';
     cpAddPathway($mod['title']);
 }
 ?>
 <?php 
 if ($opt == 'edit') {
     ?>
     <table width="625" border="0" cellspacing="5" class="proptable">
           <tr>
             <td align="center">
                 <?php 
     echo cms_model_banners::getBannerById($item_id);
     ?>
             </td>
          </tr>
     </table>
 <?php 
Ejemplo n.º 30
0
function applet_tickets()
{
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/tickets', $adminAccess)) {
        cpAccessDenied();
    }
    global $_LANG;
    cmsUser::sessionDel('ticket_cat');
    $do = cmsCore::request('do', 'str', 'list');
    $super_user = cmsCore::c('user')->id == 1;
    $toolmenu = array(array('icon' => 'new.gif', 'title' => $_LANG['AD_TICKET_CREATE'], 'link' => '?view=tickets&do=add'), array('icon' => 'liststuff.gif', 'title' => $_LANG['AD_TICKET_LIST'], 'link' => '?view=tickets&do=list'));
    cpToolMenu($toolmenu, 'list', 'do');
    cmsCore::c('page')->setTitle($_LANG['AD_TICKETS']);
    cpAddPathway($_LANG['AD_TICKETS'], 'index.php?view=tickets');
    if ($do == 'list') {
        $fields = array(array('title' => 'id', 'field' => 'id', 'width' => '40'), array('title' => $_LANG['AD_TICKET_STATUS'], 'field' => 'status', 'width' => '100', 'filter' => 1, 'prc' => 'cpTicketStatus', 'filterlist' => cpGetTicketStatusList()), array('title' => $_LANG['AD_TICKET_DATE'], 'field' => 'pubdate', 'width' => '80'), array('title' => $_LANG['AD_TICKET_TITLE'], 'field' => 'title', 'width' => '', 'filter' => 32, 'link' => 'index.php?view=tickets&do=view&id=%id%'), array('title' => $_LANG['AD_TICKET_LAST_MSG_DATE'], 'field' => 'last_msg_date', 'width' => '80'), array('title' => $_LANG['AD_TICKET_CAT'], 'field' => 'cat_id', 'width' => '150', 'filter' => 1, 'prc' => 'cpTicketCategory', 'filter' => 1, 'filterlist' => cpGetTicketCats()), array('title' => $_LANG['AD_TICKET_PRIORITY'], 'field' => 'priority', 'width' => '100', 'filter' => 1, 'prc' => 'cpTicketPriority', 'filterlist' => cpGetTicketPriorityList()));
        if ($super_user) {
            $fields[] = array('title' => $_LANG['AD_TICKET_USER'], 'field' => 'user_id', 'width' => '110', 'prc' => 'cpTicketAuthor');
        }
        $actions = array(array('title' => $_LANG['AD_TICKET_CLOSE'], 'icon' => 'off.gif', 'link' => '?view=tickets&do=close_ticket&id=%id%', 'condition' => 'cpCheckTicketClose'), array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'link' => '?view=tickets&do=delete&id=%id%', 'confirm' => $_LANG['AD_TICKET_DELETE']));
        cpListTable('cms_ticket', $fields, $actions, $super_user ? '' : 'user_id=' . cmsCore::c('user')->id, 'last_msg_date DESC', 30);
    }
    if ($do == 'delete') {
        $id = cmsCore::request('id', 'int', 0);
        $item = cmsCore::c('db')->get_fields('cms_ticket', 'id=' . $id, '*');
        if (!empty($item)) {
            $server = cmsCore::c('db')->get_field('cms_ticket_cat', 'id=' . $item['cat_id'], 'server');
            if (empty($server)) {
                $server = 'http://ds-soft.ru/tickets.api.php';
            }
            //Удаляем сам тиккет
            cmsCore::c('db')->delete('cms_ticket', 'id=' . $item['id']);
            //Удаляем все сообщения тиккета
            cmsCore::c('db')->delete('cms_ticket_msg', 'ticket_id=' . $item['id']);
            //Удаляем все прикрепленные изображения тиккета
            cmsCore::deleteUploadImages($item['id'], 'ticket');
            if ($item['status'] != '3') {
                //Отправляем сообщение на сервер техподдержки что тикет удален
                cmsCore::c('curl')->ajax()->request('post', $server . '?do=ticket_deleted', array('ticket_id' => $item['id'], 'ticket_secret_key' => $item['secret_key'], 'host' => cmsCore::c('config')->host));
            }
            cmsCore::addSessionMessage($_LANG['AD_TICKET_DELETE_SUCCESS'], 'success');
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR'], 'error');
        }
        cmsCore::redirect('index.php?view=tickets');
    }
    if ($do == 'close_ticket') {
        $id = cmsCore::request('id', 'int', 0);
        $item = cmsCore::c('db')->get_fields('cms_ticket', 'id=' . $id, '*');
        if (!empty($item)) {
            cmsCore::c('db')->setFlag('cms_ticket', $item['id'], 'status', '3');
            $server = cmsCore::c('db')->get_field('cms_ticket_cat', 'id=' . $item['cat_id'], 'server');
            if (empty($server)) {
                $server = 'http://ds-soft.ru/tickets.api.php';
            }
            //Отправляем сообщение на сервер техподдержки что тикет закрыт
            cmsCore::c('curl')->ajax()->request('post', $server . '?do=ticket_closed', array('ticket_id' => $item['id'], 'ticket_secret_key' => $item['secret_key'], 'host' => cmsCore::c('config')->host));
            cmsCore::addSessionMessage($_LANG['AD_TICKET_CLOSE_SUCCESS'], 'success');
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR'], 'error');
        }
        cmsCore::redirect('index.php?view=tickets');
    }
    if ($do == 'add') {
        cpAddPathway($_LANG['AD_TICKET_CREATE'], 'index.php?view=tickets&do=add');
        cmsCore::c('page')->initTemplate('applets', 'tickets_add')->assign('cats', cpGetTicketCats())->display();
    }
    if ($do == 'submit') {
        $cats = cpGetTicketCats();
        $item = array('cat_id' => cmsCore::request('cat_id', 'int', 0), 'priority' => cmsCore::request('priority', array(0, 1, 2, 3), 0), 'title' => cmsCore::request('title', 'str', ''), 'msg' => cmsCore::request('msg', 'str', ''));
        if (!isset($cats[$item['cat_id']])) {
            $item['cat_id'] = 0;
        }
        if (!empty($item['title']) && !empty($item['msg'])) {
            $item['msg'] = cmsCore::c('db')->escape_string($item['msg']);
            $item['msg_count'] = 1;
            $item['pubdate'] = date('Y-m-d H:i:s');
            $item['last_msg_date'] = $item['pubdate'];
            $item['user_id'] = cmsCore::c('user')->id;
            $item['id'] = cmsCore::c('db')->insert('cms_ticket', $item);
            cmsCore::addSessionMessage($_LANG['AD_TICKET_CREATED'], 'success');
            $do = 'send';
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR_2'], 'error');
            cmsCore::redirect('index.php?view=tickets&do=add');
        }
    }
    if ($do == 'send') {
        if (empty($item)) {
            $id = cmsCore::request('id', 'int', 0);
            $item = cmsCore::c('db')->get_fields('cms_ticket', 'id=' . $id, '*');
        }
        if (!empty($item)) {
            $cat = cmsCore::c('db')->get_fields('cms_ticket_cat', 'id=' . $item['cat_id'], '*');
            $server = !empty($cat['server']) ? $cat['server'] : 'http://ds-soft.ru/tickets.api.php';
            $ticket = array('ticket_id' => $item['id'], 'cat_id' => $item['cat_id'], 'priority' => $item['priority'], 'title' => $item['title'], 'msg' => $item['msg'], 'host' => cmsCore::c('config')->host, 'module' => $cat['module']);
            if ($ticket['cat_id'] > 0 && !empty($cat['module'])) {
                $ticket['module'] = $cat['module'];
            }
            //Отправляем тикет на сервер техподдержки
            $result = cmsCore::c('curl')->ajax()->request('post', $server . '?do=add_ticket', $ticket)->json();
            if (!empty($result['error'])) {
                cmsCore::clearSessionMessages();
                cmsCore::addSessionMessage($result['error'], 'error');
                cmsCore::c('db')->delete('cms_ticket', 'id=' . $item['id']);
            } else {
                if (isset($result['secret_key'])) {
                    cmsCore::c('db')->update('cms_ticket', array('status' => 1, 'secret_key' => $result['secret_key']), $item['id']);
                    cmsCore::addSessionMessage($_LANG['AD_TICKET_SENDED'], 'success');
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_TICKET_UNKNOWN_ERROR'], 'error');
                    cmsCore::c('db')->delete('cms_ticket', 'id=' . $item['id']);
                }
            }
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR'], 'error');
        }
        cmsCore::redirect('index.php?view=tickets');
    }
    if ($do == 'view') {
        $id = cmsCore::request('id', 'int', 0);
        $item = cmsCore::c('db')->get_fields('cms_ticket', 'id=' . $id, '*');
        if (empty($item) || $item['user_id'] != cmsCore::c('user')->id && !$super_user) {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR'], 'error');
            cmsCore::redirect('index.php?view=tickets');
        }
        cpAddPathway($item['title'], 'index.php?view=tickets&do=view&id=' . $item['id']);
        if ($item['msg_count'] > 1) {
            $item['msgs'] = array();
            $results = cmsCore::c('db')->query("SELECT * FROM cms_ticket_msg WHERE ticket_id=" . $item['id'] . " ORDER BY pubdate ASC");
            if (cmsCore::c('db')->num_rows($results)) {
                while ($msg = cmsCore::c('db')->fetch_assoc($results)) {
                    $msg['pubdate'] = cmsCore::dateFormat($msg['pubdate']);
                    $item['msgs'][] = $msg;
                }
            }
        }
        if ($item['status'] != 3) {
            switch ($item['priority']) {
                case 0:
                    $class = 'info';
                    break;
                case 1:
                    $class = 'success';
                    break;
                case 2:
                    $class = 'primary';
                    break;
                case 3:
                    $class = 'danger';
                    break;
            }
        } else {
            $class = 'default';
        }
        cmsCore::c('page')->initTemplate('applets', 'tickets_view')->assign('item', $item)->display();
    }
    if ($do == 'submit_msg') {
        $id = cmsCore::request('id', 'int', 0);
        $item = cmsCore::c('db')->get_fields('cms_ticket', 'id=' . $id, '*');
        if (empty($item) || $item['user_id'] != cmsCore::c('user')->id && !$super_user) {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR'], 'error');
            cmsCore::redirect('index.php?view=tickets');
        }
        $msg = cmsCore::request('msg', 'str', '');
        $date = date('Y-m-d H:i:s');
        cmsCore::c('db')->insert('cms_ticket_msg', array('msg' => cmsCore::c('db')->escape_string($msg), 'ticket_id' => $item['id'], 'pubdate' => $date));
        cmsCore::c('db')->query("UPDATE `cms_tickets` SET `last_msg_date` = '" . $date . "', `msg_count` = `msg_count`+1 WHERE `id` = '" . $item['id'] . "'");
        $server = cmsCore::c('db')->get_field('cms_ticket_cat', 'id=' . $item['cat_id'], 'server');
        if (empty($server)) {
            $server = 'http://ds-soft.ru/tickets.api.php';
        }
        //Отправляем тикет на сервер техподдержки
        $result = cmsCore::c('curl')->ajax()->request('post', $server . '?do=add_ticket_msg', array('msg' => $msg, 'ticket_id' => $item['id'], 'secret_key' => $item['secret_key'], 'host' => cmsCore::c('config')->host))->json();
        if (!empty($result['error'])) {
            cmsCore::addSessionMessage($result['error'], 'error');
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_MSG_SENDED'], 'success');
        }
        cmsCore::redirect('index.php?view=tickets&do=view&id=' . $item['id']);
    }
}