<?php
defined('PHP168_PATH') or die();

/**
* 推送数据,只提供AJAX POST调用
**/
$this_system->check_manager($ACTION) or message('no_privilege');

if(REQUEST_METHOD == 'GET'){
    
	$stop = &$this_system->load_module('stop');

	$json = $core->CACHE->read($this_system->name .'/modules/', $stop->name, 'json');
	exit('{"json":'. $json['json'] .',"path":'. $json['path'] .'}');
	
}if(REQUEST_METHOD == 'POST'){

	$id = isset($_POST['id']) ? filter_int($_POST['id']) : array();
	$id or exit('[]');
	$cid = isset($_POST['cid']) ? intval($_POST['cid']) : 0;
	$send_time_type = isset($_POST['send_time_type']) ? intval($_POST['send_time_type']) : 0;
	$send_time = isset($_POST['send_time']) ? trim($_POST['send_time']) : 0;
	//$cid or exit('[]');
	
	$stop = &$this_system->load_module('stop');
	
	//生成数据
	$data = $this_module->cluster_data($id, $cid, $send_time_type, $send_time);
	
	//上推数据
	$count = $stop->push($data, true);
	$this_system->log(array(
		'title' => $P8LANG['_module_cluster_push_admin_log'],
		'request' => $_POST,
	));
	exit($count > 0 ? jsonencode($id) : '[]');
}
exit('[]');
