<?php
if(IN_IQQOL){
    if($_COOKIE['iQQol_Administrator']!=IQQOL_SPPASS)
    {
        $style->assign("state",'COOKIE失效');
        $style->display('admin/index.html');exit();
    }
    else {
        if(isset($_POST['defaultnew'])){
            if(isset($_POST['checked'])){
                $state= "<form action='admin.php?action=styles&certain=ok' method='post' ><h2>是否删除？</h2><br>";
                foreach($_POST['checked'] as $key){
                    $state.= $key.'<br>';
                    $state.="<input type=hidden name='unset[]' value='{$key}'>";
                }
                $state.= "<br><input type=hidden name='defaultnew' value='{$_POST['defaultnew']}'><input type=hidden name='certain' value='ok'><input type=submit value='删除'></form>";
                $style->display('admin/status.html');
                exit();
            }
            elseif($_POST['certain']=='ok'){
            foreach($_POST['unset'] as $k){
                $path="template/$k";
               $r=iqqol_parameter::delDir($path);
                if($r){
                    $state.="模板".$k."删除成功<br>";
                }
                else{
                    $state.="模板".$k."删除失败<br>";
                }
            }
            $set = mysql_query("UPDATE ".IQQOL_SQLTABLE."config
 SET style='{$_POST['defaultnew']}' 
 WHERE id = '1'",$con);
            if($set) {$state.='<br>模板默认修改完成';}
            else {$state.='<br>模板默认修改失败';}
            if($_POST['csssubmit']){
                $path="libs/cache";
                $r=iqqol_parameter::delDir($path);
                $state.='<br>缓存已经更新！';
            }
            }
            else {
            $set = mysql_query("UPDATE ".IQQOL_SQLTABLE."config
 SET style='{$_POST['defaultnew']}' 
 WHERE id = '1'",$con);
            if($set) {$state.='<br>模板默认修改完成';}
            else {$state.='<br>模板默认修改失败';}
                if($_POST['csssubmit']){
                    $path="libs/cache";
                    $r=iqqol_parameter::delDir($path);
                    $state.='<br>缓存已经更新！';
                }
            }
             $style->display('admin/status.html');
        }
        else{
            $style->display('admin/styles/template.html');
        }
    }
}
?>