<?php
if($operation == 'getmessage') {
	$discuz_tablepre = $xc->config['db']['discuz_dbname'].'.'.$xc->config['db']['discuz_tablepre'];
	$uc_tablepre = $xc->config['db']['uc_dbname'].'.'.$xc->config['db']['uc_tablepre'];
	$uch_tablepre = $xc->config['db']['uch_dbname'].'.'.$xc->config['db']['uch_tablepre'];
	$flag = $xc->config['db']['discuz_type'] == 'x' ? true : false;
	$handlekey = 'check';
	$returnmessage = $s;

	if($s == "dzconfig") {
		$t_tablename = $xc->config['db']['discuz_type'] == 'x' ? 'forum_thread' : 'threads';
		if(!$tableinfo = loadtable($t_tablename)) {
			showmessage('config_error');
		} else {
			showmessage('config_success');
		}
	} elseif($s == "ucconfig") {
		if(!empty($xc->config['db']['is_uc']) && $xc->config['db']['is_uc'] == 1){
			if(!$tableinfo = loadtable_uc('settings')) {
				showmessage('config_error');
			} else {
				showmessage('config_success');
			}
		} else {
			showmessage('lack_uc');
		}
	} elseif($s == "uchconfig") {
		if(!empty($xc->config['db']['is_uch']) && $xc->config['db']['is_uch'] == 1){
			if(!$tableinfo = loadtable_uch('usergroup')) {
				showmessage('config_error');
			} else {
				showmessage('config_success');
			}
		} else {
			showmessage('lack_uch');
		}
	} elseif($s == "timeoffset") {
		$discuzsql = "UPDATE {$discuz_tablepre}".($flag ? "common_setting" : "settings")." SET ".($flag ? "s" : "")."value='".$xc->config['db']['source_timeoffset']."' WHERE ".($flag ? "skey" : "variable")."='timeoffset'";
		$xc->db['discuz']->query($discuzsql);
		if(!empty($xc->config['db']['is_uc']) && $xc->config['db']['is_uc'] == 1){
			$xc->db['uc']->query("UPDATE {$uc_tablepre}settings SET v='".$xc->config['db']['source_timeoffset']."' WHERE k='timeoffset'");
		}
		showmessage('config_success');
	} elseif($s == "reporttable") {
		creatreporttable();
		showmessage('config_success');
	} elseif($s == "uniquekey") {
		$discuzsql =  "SELECT ".($flag ? "s" : "")."value FROM {$discuz_tablepre}".($flag ? "common_setting" : "settings")." WHERE ".($flag ? "skey" : "variable")."='siteuniqueid'";
		$uniquekey = $xc->db['discuz']->result($xc->db['discuz']->query($discuzsql), 0);

		writeconfig2("uniquekey", $uniquekey);
		$extrajs_begin = '<script type="text/javascript" src="http://www.comsenz.com/xconvert/receive.php?code='.urlencode(xconvert_encrypt('childselect='.$xc->config['info']['child'].'&ip='.$_SERVER['REMOTE_ADDR'].'&url='.$_SERVER['HTTP_HOST']."&uniquekey=".$uniquekey."&source_bbsurl=".$source_bbsurl."&begin=1&end=0&time=".time(), 'comsenzxconvert')).'" reload="1"></script>';
		showmessage('config_success', '', array(), array('extrajs'=>$extrajs_begin));
	} elseif($s == "exec") {
		if(function_exists("exec")) {
			showmessage('config_success');
		} else {
			showmessage('config_error');
		}
	}
} else {
	include_once template('check');
}
?>