<?php
require('top.php');
require(R_P.'require/page.php');
require(R_P.'require/f_channel.php');

InitGP(array('action','g_id'));

$dbtable_arr = array('g_names','g_channel','g_charset','g_page','g_url','g_chk','g_p_rules','g_list','g_url_chk','g_clearhtml','g_title','g_content','g_source',);
//添加,修改,删除采集规则
/***************************************************************************************/

if ($action == 'add') {
	$g_channel = showGatherChannel();
	require PrintEot($self_template,'A');
}
elseif ($action == 'add_gather_id') {
	InitGP($dbtable_arr,'P',false);
	
	$sql_1 = '';
	$sql_2 = '';
	foreach ($dbtable_arr as $value){
		$sql_1 .= $value.",";
		$sql_2 .= "'".addslashes(serialize($$value))."',";
	}
	$sql_1 = substr($sql_1,0,strrpos($sql_1,','));
	$sql_2 = substr($sql_2,0,strrpos($sql_2,','));

	$sql = "INSERT INTO ".$db_tablepre."gather (".$sql_1.") VALUES(".$sql_2.")";
	sql_return($sql) && Showmsg('post_Success') ;
}

elseif ($action == 'up') {
	InitGP($dbtable_arr,'P',false);
	$sql_1 = '';
	foreach ($dbtable_arr as $value){
		$sql_1 .= $value."='".addslashes(serialize($$value))."',";
	}
	$sql_1 = substr($sql_1,0,strrpos($sql_1,','));

	$sql = "UPDATE ".$db_tablepre."gather  SET ".$sql_1." WHERE g_id=".$g_id;
	sql_return($sql) && Showmsg('post_Success');

}
elseif ($action == 'del_t'){
	$sql = "DELETE FROM ".$db_tablepre."gather  WHERE  g_id=".$g_id;
	sql_return($sql) && Showmsg('post_Success');
}
elseif ($action == 'mon'){
	$sql = "SELECT * FROM ".$db_tablepre."gather WHERE g_id=".$g_id;
	$query = sql_return($sql,2);
	foreach ($dbtable_arr as $value){
		$$value = stripslashes(unserialize($query[$value]));
	}
	
	$g_channel = showGatherChannel($g_channel);
	$type_up = 'up';
	require PrintEot($self_template,'A');
}
?>