<?php
if(!defined('MOD'))  die("access die");
if($admin_info['groupid'] > 3 ) qbase::purviewCheckDie();
$action = $_GET['action'] ? $_GET['action'] : "modify";
qbase::checkAction( $action);
$a = AC_P.$action.".php";
if(file_exists( $a)){
	require_once( $a);
	if( is_dir( C_P."/content")){
		qbase::deletedir( C_P."/content");
	}
	include qbase::template($path . 'channel');
}else{
	qbase::showmsg("error request d");
}

function createChannelTable($id, $channelid)
{
	global $_SET;
	$param = qdb::queryFirst("select * from ".TABLEPRE."module where id = '{$id}' ");
	if($param['pid'] > 0 ){
		$param = qdb::queryFirst("select * from ".TABLEPRE."module where id = '{$param[pid]}' ");
	}
	$sql = array();
	require_once(A_P . "/module/{$param['table_name']}/action/sql.php");
	if(empty($sql) || !is_array($sql)){
		qbase::showmsg("some wrong with the system");
	}
	$_SET['dbcharset'] = str_replace("-", "", $_SET['def_charset']);
	$myisamtype = qdb::version()>'4.1' ? ( empty($_SET['dbcharset']) ? '' : " DEFAULT CHARSET={$_SET[dbcharset]} " ) : " ";
	foreach($sql['add'] as $val){
		$val = str_replace("__channelid__", '_'.$channelid, $val);
		qdb::query( str_replace("ENGINE=MyISAM", " ENGINE=MyISAM {$myisamtype} ", trim($val)));
	}
	return true;
}
function clearSpecialChars($str){
	$p = "/\'|\"|\\|\||\/|\~|\@|\#|\$|\%|\^|\&|\*|\(|\)| |\\t|\\n|\\r|\<|\>|\?|\;/";
	return preg_replace($p, "", $str);
}
?>
