function jsondb_logger($priority, $msg_title, $msg_data = null) { global $log_db_name, $log_table_name, $log_apikey, $log_ident, $log_facility; global $log_host, $log_domain, $log_port; $invalid = false; empty($log_db_name) && empty($log_table_name) && ($invalid = true); if ($invalid) { return 'null'; } $log_url = 'http://' . $log_host . ':' . $log_port . '/service/log/write.php'; $headers = array('Content-Type: multipart/form-data; charset=utf-8'); $headers[] = 'Host: ' . $log_domain; $data = array('db_name' => $log_db_name, 'table_name' => $log_table_name, 'apikey' => $log_apikey, 'data' => array('general' => array('ID' => '', 'TIME' => gm_date(time()), 'CREATE' => gm_date(time())), 'log' => array('ident' => $log_ident, 'facility' => $log_facility, 'priority' => $priority, 'title' => $msg_title, 'data' => $msg_data))); http_build_query_for_curl($data, $post_data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $log_url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_TIMEOUT, 3); $res = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $err = curl_errno($ch); curl_close($ch); return $err == 0 ? $httpcode == 200 ? $res : null : null; }
function format_time($time_str) { return gm_date(__strtotime($time_str)); }
foreach ($oneboxs as $onebox) { $url = $onebox['url']; if (empty($url)) { continue; } $res_obj = get_onebox_url($url); if (!isset($onebox['time'])) { $onebox['time'] = gm_date(time()); } $ctime_str = @$onebox['ctime']; if (empty($ctime_str)) { $ctime_str = $onebox['time']; } $new_ctime = __strtotime($res_obj['create_time']); $ori_ctime = __strtotime($ctime_str); $ctime = gm_date(min($new_ctime, $ori_ctime)); $new_onebox = array(); $new_onebox['title'] = $res_obj['title']; $new_onebox['desc'] = $res_obj['description']; $new_onebox['image'] = $res_obj['image']; $new_onebox['url'] = $res_obj['ori_url']; $new_onebox['id'] = $res_obj['ID']; $new_onebox['time'] = $res_obj['update_time']; $new_onebox['ctime'] = $ctime; $new_oneboxs[] = $new_onebox; $same_onebox = true; foreach ($new_onebox as $key => $val) { if ($val !== @$onebox[$key]) { $same_onebox = false; break; }