/** * 实例化对像 * * @return class */ public static function factory() { if (!isset(self::$_class)) { $className = __CLASS__; self::$_class = new $className(); } return self::$_class; }
/** * 功能号:13051 * 导出点击量数据 */ function export_counter() { $boxmac = new COMGetmac(); $clientmac = 'M' . $boxmac->getmac(); $clientbox = new Boxs(); $one = $clientbox->getOne("mac=?", $clientmac); if (empty($one)) { Core::json_error('Null'); } $host = $this->_host; $clientboxid = intval($one->id); if ($clientboxid > 0) { $stat = new Traffic_statistics(); $sql = "update traffic_statistics set box_id={$clientboxid} where box_id = 0"; $flag = Core::$_mdb->execute($sql); $dir = COMFile::createFolder("download/statis"); $filename = $dir . "/box_{$clientboxid}.txt"; $data = $stat->getList("status=1"); if ($data) { $flag = file_put_contents($filename, serialize($data)); if ($flag) { foreach ($data as $item) { $item->status = 0; $item->save(); } $network = Core::connect_check($host); if ($network) { $host = $this->_host; $param = array("m" => 14050); $sign = Core::get_signature($param); $param["file"] = "@" . ROOT . $filename; $param["sign"] = $sign; $url = "http://{$host}/tvmv/?m=14050"; $temp = Core::request_url($url, $param, 1, 1); $return = json_decode($temp); if ($return->status === 1) { Core::json_result("", "finish ok"); } } } } } Core::json_result("", "ok"); }