<?php

/*
*	Copyright VeryIDE,2007-2010
*	http://www.veryide.com/
*
*	$Id: veryide.index.php,v3 8:07 2010-09-10 Leilei $
*/

/*
require("config/config.php");
require("config/licence.php");
require("config/setting.php");
require("config/version.php");
require("function/library.php");
require("function/compat.php");
require("function/system.php");
require("function/cache.php");
require("function/hocker.php");
*/

header("location:start.php");

//载入依赖库以及配置
require("include/global.php");

//载入 MySQL 类
require_once("class/mysql.php");

//载入 日历转换 类
require_once("class/lunar.php");

//系统测试
checker_system();	

//载入缓存
/*
require("include/cache.setting.php");
require("include/cache.admins.php");
require("include/cache.groups.php");
*/
	
//登录状态
if( $Global["login"]=="hide" ){
	checker_login(false);
}
				
//载入菜单缓存
//require("include/cache.menus.php");

//载入模块缓存
//require("include/cache.modules.php");

//缓存所有Hock
hocker_push();
				
//读取当前用户偏好设置
if( $_SESSION["Manager"]["id"] ){

	$config = $VICACHE["sys.admin"][$_SESSION["Manager"]["id"]]["config"];
	
	if( $config ){
		$Custom = json_decode($config,true);	
	}

}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html id="wrapper" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $Project["charset"];?>" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<link rel="shortcut icon" href="image/favicon.png" type="image/png" />
<link rel="icon" href="image/favicon.png" type="image/png" />
<?php 
echo '<title>'.$Project["product"].'</title>
<meta name="robots" content="noindex, nofollow" />
';

html_meta();

echo loader_style("style/layout.css","utf-8",$Project["version"]);

echo loader_script(array("js/core.js","js/library.js","js/manager.js","js/drag.js","js/ajax.js","js/effect.js"),$Project["charset"],$Project["version"]);
?>

<script type="text/javascript">
<?php
//site config
reader_config();

//user config
echo '
Mo.Manager.id="'.$_SESSION["Manager"]["id"].'";
Mo.Manager.name="'.$_SESSION["Manager"]["account"].'";
Mo.Manager.avatar="'.$_SESSION["Manager"]["avatar"].'";
Mo.Manager.group="";
Mo.Manager.interval='.($Global["interval"]?($Global["interval"]*1000):30000).';
';
//Mo.Manager.group="'.$VICACHE["sys.group"][$_SESSION["Manager"]["gid"]]["name"].'";
?>

/*

if(!getCookie("__sale1221")){
	if(confirm("VeryIDE Apps 优惠促销中，需要查看相关活动资讯吗？")){
		window.open("http://www.veryide.com/buy.php");
	}
	setCookie('__sale1221','true',2);
}
*/
</script>

<?php
//3天后提醒升级浏览器
/*
if( !$_SESSION["Manager"]["id"] && eregi("MSIE 6.0", $_SERVER["HTTP_USER_AGENT"]) && time() - VI_START > 259200 ){
	echo '<!--[if lte IE 6]><script src="source/browser/warning.js" charset="'.$Project["charset"].'"></script><script>window.onload=function(){e("source/browser/");}</script><![endif]-->';
}
*/
?>

<script type="text/javascript">
var xxx = ''; //xxx
var xxx = "";//xxx
var xxx = 0; //xxx
var xxx = 0;//xxx
var xxx = 0x00FFAA;//xxx
var xxx = {}; //xxxx

var xxx = (""); //xxxx
var xxx = { //xxxx

};
/*测试保留
*/

Mo.reader(Mo.Manager.fwLoad);

Mo.reader(
<?php
require("include/veryide.loader.php");
?>
);

Mo.testFun=function(s){
  switch(s){
    case "warning":
      Mo.Alert('warning','VeryIDE Error','Mo.Manager.loginBox',false);
    break;
    
    case "window":
      Mo.Window('window','VeryIDE Browse','veryide.login.php?action=logout','800','285',false,true);
    break;
    
    case "":
    
    break;
  }
};

//Konami Code
var k=[];
document.onkeyup = function(e){
	var e = e || event;
	k.push(e.keyCode);
	if(k.toString().indexOf("38,38,40,40,37,39,37,39,66,65")>=0){
		alert("Konami Code Activated");
	}
}

</script>

</head>

<body>
    
    <?php
        echo hocker_slice('veryide:start');		
    ?>

	<!--header start-->
	<div id="header">	
        
        <?php
		//圣诞节（共5天）
		if( date("m")==12 && date("d")>20 && date("d")<30 ){
			
			//圣诞帽
			echo '<div id="newyear"><img id="lanternPoint" src="image/hat.png" alt="圣诞节快乐！" /></div>';
			
			if( $Custom["ui-effect"] != "close" ){
			
				//下雪花
				echo '<script src="source/snow/jsized.snow.min.js" type="text/javascript"></script>        
				<script type="text/javascript">createSnow("source/snow/", 60);</script>';
				
				//积雪
				echo '<div id="snow"></div>';
				
			}
			
		}
		
		/***********************/
		
		//农历春节（共30天）
		$lunar = new Lunar();
		
		//得到今年春节的日期
		$date = $lunar->getLar(date("Y").'-12-31',1);
		
		//15天
		$day15 = 3600*24*10;
		
		//前后15天，共30天
		if( $date - $day15 <= time() && $date + $day15 >= time() ){
				
			//圣诞帽
			echo '<div id="newyear" class="spring"><img id="lanternPoint" src="image/spring.png" alt="农历春节！" /></div>';
			
		}
		
		?>
        
        <div id="header-logo">
            <?php
                echo hocker_slice('veryide:logo-start');
            ?>
            <script type="text/javascript">Mo.Manager.showSite();</script>            
            <?php
                echo hocker_slice('veryide:logo-close');
            ?>
        </div>
        
        <!--info start-->
        <div id="header-info">
        	<?php
			echo hocker_slice('veryide:info-start');
			
			//gravatar
			if( $Global["avatar"] == 'gravatar' && $_SESSION["Manager"]["email"] ){
				$avatar = "http://www.gravatar.com/avatar.php?gravatar_id=".md5( strtolower($_SESSION["Manager"]["email"]) )."&default=&size=40";
			}else{
				$avatar = 'image/'.($_SESSION["Manager"]["avatar"]?'avatar/'.$_SESSION["Manager"]["avatar"]:'avatar.jpg');
			}
			
			?>
        	<a rel="veryide.avatar.php" onclick="Mo.Manager.fwMenu(this,this.rel);"><img id="header-avatar" src="<?php echo $avatar;?>" alt="修改头像" /></a>
        
        	<div id="header-status">
				<?
                if ($_SESSION["Manager"]["account"]!=""){
                    echo '<span>Checking...</span> | <a href="javascript:Mo.Manager.exitLogin();">退出</a> ';
                }else{
					echo (isset($_GET["T"])?"已退出:".$_GET["T"]:"未登录:".GetIP());                   
                }
                ?>
            
            </div>
            
            <!--a rel="veryide.start.php" id="header-sidebar" onclick="VeryIDE_Sidebar();">&laquo;侧边栏</a-->
            <a rel="veryide.start.php" onclick="Mo.Manager.fwMenu(this,this.rel);">开始</a>
            - <a rel="veryide.avatar.php" onclick="Mo.Manager.fwMenu(this,this.rel);">头像</a>
            - <a rel="veryide.custom.php" onclick="Mo.Manager.fwMenu(this,this.rel);">偏好</a>
			- <a rel="veryide.sitemap.php" onclick="Mo.Manager.fwMenu(this,this.rel);">地图</a>
            <?php
			
				//AdobeAIR
				if( strpos($_SERVER["HTTP_USER_AGENT"],"AdobeAIR") !== false ){
					echo '- <a onclick="javascript:location.reload(true);">刷新</a>';
				}
			
                echo hocker_slice('veryide:info-close');
            ?>
		</div>
		<!--info end-->
    
		<!--tool start-->
        <div id="header-tool">
            
            <?php
           	echo hocker_slice('veryide:tool-start');
           
			
			//右侧菜单
            if( $Global["topmenu"] && $_SESSION["Manager"]["account"]){
				echo $Global["topmenu"];
            }else{
                echo '
				<a href="http://site.mopland.com/?from='.$Product["appname"].'" target="_blank">网址导航</a>
				 | 
				<a href="http://www.google.com/" target="_blank">Google</a>
				<a href="http://adsense.google.com/" target="_blank">Adsense</a>
				<a href="http://www.gmail.com/" target="_blank">Gmail</a>
                 | 
				<a href="http://www.baidu.com/" target="_blank">百度</a> 
				';
			}
            ?>
            <br>
			<?php
			
			//搜索表单
			echo '
				<div id="header-search">
					<form action="#" onsubmit="$(\'q\').value=($(\'q\').defaultValue==$(\'q\').value?\'\':$(\'q\').value); Mo.Manager.fwMenu(this,\'veryide.search.php?q=\'+($(\'q\').value));return false;">
						<input type="text" class="text" class="text" maxlength="12" name="q" id="q" value="输入关键字并回车.." onfocus="this.value=(this.defaultValue==this.value?\'\':this.value);this.className=\'active\';" />
					</form>
				</div>
				';
			 echo hocker_slice('veryide:tool-close');
            ?>
		</div>
        <!--tool end-->
    </div>
    <!--header end-->

	<!--control start-->
    <div id="control" onclick="Mo.Sidebar( null , true );" title="显示/隐藏侧边栏"></div>
    <!--control end-->
    
    <!--sidebar start-->
    <div id="sidebar">
		<?php
		echo hocker_slice('veryide:sidebar-start');
		
        //菜单控制
        if ($_SESSION["Manager"]["account"]!=""){						
			//loader
			loader_setting("sidebar.search");			
        }
        ?>
        
        <div id="sidebar-menu">
            
            <?php
            echo hocker_slice('veryide:menu-start');
            
            //菜单控制
            if ($_SESSION["Manager"]["account"]==""){
                echo '
                <div id="menu-powered">
                    <p></p>
					  <p align="center"><a href="http://www.veryide.com/buy.php" target="_blank"><img src="image/models/'.$Licence["type"].'.gif" alt="'.$Version[$Licence["type"]]["name"].'" /></a></p>
                    <p align="center" class="text-key">VeryIDE '.$Version[$Licence["type"]]["name"].'用户</p>
                    <p align="center">- 登录后菜单可见 -</p>
                    <p align="center">'.$Project["powered"].'</p>
                </div>
                ';
				
            }else{
			
				echo '
				<div id="menu-title">
					<span onclick="Mo.Manager.allMenu(this);" title="展开菜单"></span>
					<span class="custom" onclick="Mo.Manager.fwMenu(this,\'veryide.custom.php\');" title="偏好设置"></span>
					<strong>VeryIDE '.$Product["appname"].'</strong>
				</div>';

				//菜单缓存
				echo '<div id="menu-link">';
				
				//当前用户组权限设置
				$permit = $VICACHE["sys.group"][$_SESSION["Manager"]["gid"]]["config"];
				
				//模块菜单
				foreach($VICACHE["sys.module"] as $key){
					
					//exit($key["config"]);
					
					//判断模块状态、是否有菜单、是否设置偏好、当前用户是否有权限
					// && strpos($permit,'mod-'.$key["appid"].'-') !== false
					if( isset($key["config"]) && $key["config"] && $key["status"] && $Custom['mod-'.$key["appid"]] != "N" ){

						//config
						$file = $Project["module"].$key["config"];
						if( file_exists($file) ) require_once($file);
						
						if( is_array($Modules[$key["appid"]]["menu"]) ){
							
							$icon = '<img src="'.$Project["module"].$key["appid"].'/icon.png" />';
						
							echo '<div onclick=\'Mo.Manager.setMenu("MU-'.$key["appid"].'",this);\' title="'.$key["name"].'"><span>'.$icon.$key["name"].'</span></div>';
							echo '<ul id="MU-'.$key["appid"].'">';
							
								foreach( $Modules[$key["appid"]]["menu"] as $name => $link ){
										
										echo '<li><a onclick="Mo.Manager.fwMenu(this,this.rel,true)" href="javascript:void(0);" rel="module/'.$key["appid"]."/".$link.'" title="'.$name.'">'.$name.'</a></li>';
								}
							
							echo '</ul>';
						}
						
					}
				
				}
				
				//自定义菜单
				foreach($VICACHE["sys.menus"] as $key){
					// && ( $key["appid"] &&  $VICACHE['sys.modules'][$key["appid"]]["status"] )
					if($key["parent"]=="0" && $key["status"]=="1" ){
						
						$icon = '<img src="'.$Project["image"].'/favicon.png" />';
						
						echo '<div onclick=\'Mo.Manager.setMenu("MU-'.$key["id"].'",this);\'><span>'.$icon.$key["name"].'</span></div>';
						echo '<ul id="MU-'.$key["id"].'">';
						
							foreach($VICACHE["sys.menus"] as $item){
								if($item["parent"]==$key["id"] && $item["status"]=="1"){
									
									echo '<li><a onclick="Mo.Manager.fwMenu(this,this.rel,true)" href="javascript:void(0);" rel="'.$item["link"].'">'.$item["name"].'</a></li>';
									
								}
							}
						
						echo '</ul>';
						
					}
				}
				
				echo '</div>';
				
			}
			
			echo hocker_slice('veryide:menu-close');
			?>
        
        </div>
    
		<?php
            echo hocker_slice('veryide:sidebar-close');
        ?>
    </div>
    <!--sidebar end-->
    
    <!--container start-->
    <div id="container">
		<?php
            echo hocker_slice('veryide:container-start');
			//about:blank
        ?>
    	<div>
            <iframe frameborder="0" id="column" allowtransparency="true" name="column" src="source/dialog/blank.html"></iframe>
        </div>
		<?php
            echo hocker_slice('veryide:container-close');
        ?>
    </div>
    <!--container end-->
    
    <!--div id="push">
    
    	<dl>
        	<dt>
            	<a href="#" title="关闭"></a>
            	<strong>王磊</strong>
            </dt>
            
            <dd>
            
            	<ul>
                	<li>
                    	<a href="#"><img src="image/avatar/Casper-icon.jpg" /></a>
                        <strong><a href="#">这里标题。。</a></strong><br />
                        <a href="#">这是内容。。。这是内容。。。这是内容。。。这是内容。。。</a>
                    </li>
                </ul>
                
                <div><a href="#" class="prev"></a> <span>1 / 5</span> <a href="#" class="next"></a></div>
            
            </dd>
        </dl>
    </div-->
    
    <script>
	
	/*
	var dl = $("push");	

	var doc=Mo.getDocument();

	dl.style.left=doc.clientWidth-335-40+"px";
	dl.style.top=doc.clientHeight-120-20+"px";
		
	
	//拖动支持
	Drag.init(dl.firstChild,dl);

	//开始拖动
	dl.onStart = function() {
		this.style.filter="alpha(opacity=60)";
		this.style.opacity=0.6;				
	}

	//结束拖动
	dl.onEnd = function(x, y){		
		this.style.filter="alpha(opacity=100)";
		this.style.opacity=1;				
	}
	
	/*
	
		var html = '<h2><span title="关闭"></span>文件浏览器</h2>'+
				   '<div id="explore-upload">'+upload.Extra+'</div><ul id="explore-files"></ul><ol id="explore-pages"></ol>';

		dl.innerHTML=html;

	document.body.appendChild(dl);	
	
	*/
	
	</script>
    
    <?php
        echo hocker_slice('veryide:close');
    ?>

</body>
</html>