<?php
define('THIS_SCRIPT', 'qihoo');
include_once 'global.php';
include_once INC_PATH.'general_funcs.php';
define('QIHOOCONFIGPATH', CACHE_PATH.'qihoo.config.php');
if(!file_exists(QIHOOCONFIGPATH)){
	if($fp=fopen(QIHOOCONFIGPATH,'wb'))fclose($fp);
}
include_once QIHOOCONFIGPATH;

$lang = load_lang($lang,'qihoo');
head();
checklogin();
if ( strpos($sysinfo['flag'],'59,') === false ){
	show_msg($lang['readme_tit'],$lang['qihoo.err1'],0,'','','','');
	exit;
}


PageLoad();
function Pageload(){
	global $lang,$action,$reaction,$qihoo;
	if($action=="reg"||$action=="edit"){
		if(!$fp=fopen(QIHOOCONFIGPATH,"wb")){
			show_msg("{$lang["qihoo.save"]}","{$lang["qihoo.save"]}{$lang["qihoo.fail"]}
			<BR>{$lang["qihoo.fail_case"]}",0,'','',"?","{$lang["qihoo.back"]}");
		}else{
			if(!$qihoo=$_POST['qihoo']){
				show_msg("{$lang["qihoo.save"]}","{$lang["qihoo.save"]}{$lang["qihoo.fail"]}
			    <BR>{$lang["qihoo.fail_errpost"]}",0,'','',"?","{$lang["qihoo.back"]}");
			}else{
				$qihoo['code']=authcode("ofmt=json&sname={$qihoo['sname']}&surl={$qihoo['surl']}&slogo={$qihoo['slogo']}&stype={$qihoo['stype']}&semail={$qihoo['semail']}&scharset=gbk&pjt=dvbbs_php",'ENCODE',$qihoo['skey']);
				$content="<?php\n".varstoscript("qihoo",$qihoo).";\n?>";
				fputs($fp,$content);
				@fclose($fp);
				show_msg("{$lang["qihoo.save"]}","{$lang["qihoo.save"]}{$lang["qihoo.ok"]}",1,'',''
				,"?","{$lang["qihoo.back"]}");
			}
		}
		exit;
	}
	$forum_info=$GLOBALS['forum_info'];
	include printout('qihoo');
}
footer();
