<?php 
/*
　* @$Id
　* @
　* @Ver: 2.0
　* @Create: 2009-11-18 8:10
　* @Modify: 
　* @Author: CPWEB http://www.cpweb.net.cn
　* @Copyright (C) 2008 www.cpweb.net.cn. All Rights Reserved.
　* @License CPWEB is free software and use is subject to license terms
　*/
class IndexAction extends GlobalAction{
	public function main(){
		/*$Article=M('Article');
		$Member=D('MembermegroupsView');
		$Job=M('Job');
		$Feedback=M('Feedback');
		$ArticleC=$Article->count();
		$MemberC=$Member->where($map)->count();
		$JobC=$Job->count();
		$FeedbackC=$Feedback->count();
		$this->assign(array('ArticleC'=>$ArticleC,
					'MemberC'=>$MemberC,
					'JobC'=>$JobC,
					'FeedbackC'=>$FeedbackC
		));*/
		//获取系统信息
		$config=new model();
		$array=array();
		$serverinfo = PHP_OS.' / PHP v'.PHP_VERSION;
		$serverinfo .= @ini_get('safe_mode') ? ' Safe Mode' : NULL;
		$dbversion = $config->query("SELECT VERSION()");
		$fileupload = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : '<font color="red">不支持上传</font>';
		$dbsize = 0;
		$tablepre = C('DB_PREFIX');
		$query = $tables = $config->query("SHOW TABLE STATUS LIKE '$tablepre%'");
		//dump($query);
		foreach($tables as $table) {
			$dbsize += $table['Data_length'] + $table['Index_length'];
		}
		$dbsize = $dbsize ? RealSize($dbsize) : '未知大小';
		$dbversion = $config->query("SELECT VERSION()");
		$magic_quote_gpc = get_magic_quotes_gpc() ? 'On' : 'Off';
		
		$array['serverinfo']=$serverinfo;
		$array['dbversion']=$dbversion;
		$array['fileupload']=$fileupload;
		$array['dbsize']=$dbsize;
		$array['dbversion']=$dbversion[0]['VERSION()'];
		$array['magic_quote_gpc']=$magic_quote_gpc;
		$this->assign($array);
		$this->display("Public:main");
	}	
	public function modify(){
		$id=intval($_REQUEST["id"]);
		if (!$id) $this->error(L('CPWEB_SELECT_NOT_EXIST'));
		$Member=M("Member")->find($id);
		if (!$Member) $this->error(L('CPWEB_SELECT_NOT_EXIST'));
		$this->assign('vo',$Member);
		$this->display();
		
		
	}
	public function modifys()
	{
		$password=$_POST['password'];
		$opassword=$_POST['opassword'];
		$id=intval($_POST['id']);
		if (!$id) $this->error(L('CPWEB_SELECT_NOT_EXIST'));
		$Member=M("Member");
		if($Member->create()) { 
			if($password!=''){
				$Member->password=md5($password);
			}else{
				$Member->password=$opassword;
			}
            if($Member->save()){ 
            	$this->assign('jumpUrl',__URL__/modify);
				$this->success(L('CPWEB_SUCCESS_EDIT'));
            }else{ 
                $this->error(L('CPWEB_ERROR_EDIT')); 
            } 
        }else{ 
            $this->error($Member->getError()); 
        } 
	}
} 
?>