<?php
if(!defined('MOD'))  die("access die");
purviewCheck('seo', 'plugin');
$action = $_GET['action'];
$action = $action ? $action : 'manage';
if($_POST['myFormAc'] == 'update'){
	$cid = intval($_GET['cid']);
	$domain = $_GET['domain'];
	$page = intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
	$limit = intval($_GET['limit']) ? intval($_GET['limit']) : 500;
	$type = intval($_GET['type']);
	$allow = array('g');
	if(!in_array($domain, $allow) || !$channel[$cid]) qbase::showmsg("error request");
	switch($domain){
		case 'g':
			require_once("google_xml.php");
			$obj = new google_xml;
		break;
	}

	if($type == 0 && $page == 1){
		$obj->clear();
	}
	$obj->build();
	$table = $obj->get_table($cid);
	if(!$table) qbase::showmsg("error request");
	$offset = ($page - 1) * $limit; 
	$temp = qdb::fetchAll("select id from " . $table . " order by id asc limit {$offset}, {$limit}");
	$ids = array();
	foreach($temp as $val){
		$ids[] = $val['id'];
	}
	$obj-> add($ids, $cid);

	$data = array('status'=>200, 'num'=>count($ids));
	echo qbase::xmlPrint(qbase::jsonencode($data));
	exit();
}
include qbase::template($path . 'plugin/seo');
?>