<?php /* * */ include_once(SERVER_ROOT."/model/mBase.php"); class qTool extends mBase { /** * 加入重试日志 * @param unknown $type * @param unknown $id */ public function addRetryLog($type, $id) { return error_log($id."\n", 3, PAPER_UPFAIL_PATH); } /** * 跟踪日志 * @param int $type * @param string $log * @return boolean */ public function trackLog($type, $log, $log_path='') { if(empty($log_path)) $log_path = sprintf(LOG_TRACK_SAVE_PATH, date('Y-m-d'), $type); $log_dir = dirname($log_path); $isfirst = false; if(!is_dir($log_dir)) { mkdir($log_dir, 0775, true); chown($log_dir, 'nobody'); chgrp($log_dir, 'nobody'); $isfirst = true; } error_log(date('H:i:s').'|'.$log."\r\n", 3, $log_path); chown($log_path, 'nobody'); chgrp($log_path, 'nobody'); return true; } public function trackApiLog($type, $log) { $priv_data = array( '_uid' => 143, '_token' => '3073e44edb118b3f5d8014ac7d17d73a', 'log' => $log ); $url = KUAILELUNWEN_API_URL.'/track_log?type='.$type; $serobj = new mService(); $is_jd = $serobj->isJingDong(); if($is_jd) $url = KUAILELUNWEN_API_URL_JD.'/track_log?type='.$type; for($i=0;$i<3;$i++) { $inf = $this->postCUrl($url, $priv_data, 60); $inf = json_decode(trim($inf,chr(239).chr(187).chr(191)),true); if($inf['status']) return true; } return true; } }