function getDataJson() { if (isset($_GET['sfrom'])) { $jordanGUID = $_GET['jordanGUID']; $domain = $_GET['domain']; $protocol = $_GET['protocol']; $path = $_GET['path']; $location = $protocol . $domain . $path; $sfrom = $_GET['sfrom']; initConnection($db_config); //redis 使用 require '../Predis/Autoloader.php'; Predis\Autoloader::register(); $redis = new Predis\Client(array('database' => '0', 'host' => '49.4.129.122', 'port' => 6379)); $datestr = date("Y_m_d_H"); $tableName = "request_" . $datestr; if ($redis->get("tableName") != $tableName) { create_request($tableName); $redis->set("tableName", $tableName); } $request_datetime = date('Y-m-d H:i:s', time()); writeLog('../logs/' . $tableName . '.log', "{$jordanGUID}\t{$domain}\t{$location}\t{$request_datetime}\n", "a"); insert_request_entry($jordanGUID, $domain, $location, $sfrom, $request_datetime, $tableName); insert_request_entry($jordanGUID, $domain, $location, $sfrom, $request_datetime, "request"); //echo "success"; } else { //echo "failure"; } }
/** * Save the revieved XML to file * * @param string $xml The xml recieved * @return boolean True on success or false */ function saveFile($xml) { global $db; //In your database, log that you have received new xml data $db->query("INSERT INTO saved_xml () VALUES ()") or $db->raise_error('Failed saving xml'); // Will use the message we give it + the SQL $id = $db->insert_id(); //Save the data in a file, and name it using the autoincrement id from your database $filename = "files/{$id}.xml.gz"; if (move_uploaded_file($xml, $filename)) { $unzipped_file = 'files/' . $id . '.xml'; system("gunzip {$filename} 2>&1"); if (file_exists($unzipped_file)) { //file is ready to parse } else { writeLog(array(), "Failed to gunzip file " . $filename); $db->query("DELETE FROM saved_xml WHERE id=" . $id) or $db->raise_error('Failed deleting XML row'); // Will use the message we give it + the SQL return false; } //echo "The file $filename has been uploaded"; } else { //echo "There was an error uploading the file, please try again!"; $db->query("DELETE FROM saved_xml WHERE id=" . $id) or $db->raise_error('Failed deleting XML row'); // Will use the message we give it + the SQL return false; } return true; }
/** * 清除数据表 * @author Mr.Cong <*****@*****.**> */ public function clear(Request $request) { /** * 简单的判断,防止恶意执行 */ $pass = $request->input('auth', '0'); if (md5($pass) != 'ceb8ecf822745c53f78a10c05cf01919') { echo "Auth failed."; exit; } /* * 每天定时清空数据库指定的表和日志、标注文件 */ $dir = './log/'; if ($od = opendir($dir)) { while (($file = readdir($od)) !== false) { //跳过当前目录和上一级目录 if (in_array($file, array(".", ".."))) { continue; } if (preg_match('/\\.lock/', $file) || preg_match('/(\\w+)\\.html/', $file)) { unlink($dir . $file); } } } DB::table('news')->truncate(); DB::table('forums')->truncate(); writeLog(date('Y-m-d H:i:s') . " Clear table and log file."); /* * 退出 */ print 0; exit; }
/** \brief Updates database ticket with stored image url * \param picture_url Part of URL to the image * \param upload_dir Directory in which the images are stored * \param interaction_id Ticket identifier for updated image * \returns Successful database update or unsuccessful */ function updatePicture($picture_url, $upload_dir, $interaction_id) { try { require "/var/database_config.php"; $pdo = new PDO('mysql:host=' . $db_config['host'] . ';dbname=' . $db_config['dbname'], $db_config['username'], $db_config['password']); $sql_str = "SELECT image from tickets WHERE interaction_id = ?"; $statement = $pdo->prepare($sql_str); $statement->execute(array($interaction_id)); $picture = $statement->fetch(PDO::FETCH_ASSOC); if ($picture['image'] !== NULL) { $temp = explode("/", $picture['image']); $file = end($temp); $picture_path = $upload_dir . $file; if (file_exists($picture_path)) { if (unlink($picture_path)) { //return array('status' => 'File deleted'); } } } $sql_str = "UPDATE tickets SET image = ? WHERE interaction_id = ?"; $statement = $pdo->prepare($sql_str); $statement->execute(array($picture_url, $interaction_id)); $logs = array(); $logs[] = "Image added to ticket."; require "../log.php"; writeLog($interaction_id, $logs); return array('status' => 'Successful image update'); } catch (PDOException $e) { return array('error' => 'Error updating the image in the database'); } }
/** * replace internal katadebug-function */ function kataDebugOutput($var = null, $isTable = false) { if (!$isTable) { writeLog(var_export($var, true), 'boot'); } else { $widths = array(); foreach ($var as $line) { $cellNo = 0; foreach ($line as $cell) { if (!isset($widths[$cellNo])) { $widths[$cellNo] = 0; } $widths[$cellNo] = max($widths[$cellNo], strlen($cell)); $cellNo++; } } $output = "\n"; foreach ($var as $line) { $s = ''; $cellNo = 0; foreach ($line as $cell) { $s .= $cell . str_repeat(' ', $widths[$cellNo] - strlen($cell)) . ' | '; $cellNo++; } $output .= $s . "\n"; } writeLog($output, 'boot'); } }
/** * RatePAY action method handles payment request */ public function RatepayRequestAction() { include_once dirname(__FILE__) . '/../../Views/Frontend/Ratenrechner/php/pi_ratepay_xml_service.php'; Shopware()->Session()->pi_ratepay_Confirm = false; $user = $this->getUser(); $payName = $this->getPaymentShortName(); $ratepay = new pi_ratepay_xml_service(); $ratepay->live = checkSandboxMode($payName); $request = $ratepay->getXMLObject(); setRatepayHead($request, 'PAYMENT_REQUEST', $user); if ($payName == 'RatePAYInvoice') $content = setRatepayContent($request, 'rechnung'); elseif ($payName == 'RatePAYDebit') $content = setRatepayContent($request, 'directDebit'); else $content = setRatepayContent($request, 'ratenzahlung'); $customer = $user['billingaddress']['firstname'] . ' ' . $user['billingaddress']['lastname']; $response = $ratepay->paymentOperation($request); if($payName == 'RatePAYDebit' ||($payName == 'RatePAYRate' && Shopware()->Session()->RatepayDirectDebit)) $request = checkBankDataSave($request, $user); writeLog("", Shopware()->Session()->pi_ratepay_transactionID, "PAYMENT_REQUEST", "", $request, $response, $customer, $payName); if ($response && (string) $response->head->processing->status->attributes()->code == "OK" && (string) $response->head->processing->result->attributes()->code == "402" ) { Shopware()->Session()->pi_ratepay_rechnung_descriptor = (string) $response->content->payment->descriptor; return $this->forward('end'); } else { Shopware()->Session()->pi_ratepay_no_ratepay = true; $sql = "SELECT `userID` FROM `s_user_billingaddress` WHERE `id` = ?"; $userID = Shopware()->Db()->fetchOne($sql, array((int)$user['billingaddress']['userID'])); $sql = "UPDATE `s_user` SET `paymentID` = ? WHERE `id` = ?"; Shopware()->Db()->query($sql, array((int)Shopware()->Config()->Defaultpayment, (int)$userID)); $this->saveStats(false); return $this->redirect(array('controller' => 'account', 'action' => 'payment', 'sTarget' => 'checkout', 'forceSecure' => true)); } }
public function addEntry($data, $program) { $entry = new Entry(); $entry->fromData($data, $program); array_push($this->entries, $entry); writeLog('Loaded entry for program ' . $program->id . ' (', $program->year . ')'); return $entry; }
/** * * @param type $file_path */ function displayChunk($file_path) { writeLog($file_path); if (is_file($file_path)) { readfile($file_path); } else { writeLog("ERROR ! Invalid path " . $file_path); } }
function check_for_configfile() { if (!file_exists(absolute_path('config.xml'))) { if (file_exists(absolute_path('cofig.xml-dist'))) { writeLog('Vor der Nutzung »config.xml-dist« in »config.xml« umbennen und anpassen.', FAIL); die; } else { writeLog('Konfigurationsdatei »config.xml« nicht vorhanden.', FAIL); die; } } }
/** * 使用SDK执行接口请求 * @param unknown $request * @param string $token * @return Ambigous <boolean, mixed> */ function aopclient_request_execute($request, $token = NULL) { require 'config.php'; $aop = new AopClient(); $aop->gatewayUrl = $config['gatewayUrl']; $aop->appId = $config['app_id']; $aop->rsaPrivateKeyFilePath = $config['merchant_private_key_file']; $aop->apiVersion = "1.0"; $result = $aop->execute($request, $token); writeLog("response: " . var_export($result, true)); return $result; }
public function execute($query_str, $params = []) { if ($this->mysql === false) { return false; } $query = $this->getQuerySTR($query_str, $params); $this->last_query = $query; if (!$this->mysql->real_query($query)) { $this->last_error = $this->mysql->error; writeLog("SQL Error:\n\t" . $this->last_error . "\n\tQuery: " . $this->last_query); return false; } return true; }
function EmailErrorHandler($FXErrorObj) { //if error not written to log if (checkLog() == false) { //send email to admins EmailError($FXErrorObj->message); } //write it writeLog($FXErrorObj->message); if (DISPLAY_ERROR_MESSAGES) { echo $FXErrorObj->message; } return true; }
/** * 保存数据进数据库 * @param $data * @author Mr.Cong <*****@*****.**> */ public function saveData($data) { DB::table('news')->truncate(); foreach ($data['items'] as $key => $item) { $News = new News(); $News->title = $item->get_title(); $News->tag = $this->tag; $News->link = $item->get_link(); $News->description = html_entity_decode($item->get_description(), ENT_COMPAT); $News->category = $item->get_category()->get_term(); $News->author = $item->get_author()->get_name(); $News->pubDate = strtotime($item->get_date()); $News->content = html_entity_decode($item->get_content(), ENT_COMPAT); $News->save(); } writeLog('Save data to database.'); }
function readResp() { //freadで応答が無いと止まってしまうので非同期モードにする stream_set_blocking($this->pipes[1], 0); $read_str = fread($this->pipes[1], 8192); if ($read_str === FALSE) { $this->close(FALSE); $info_msg = 'ERROR: SSH fread failed.'; writeLog(0, "59Y", $info_msg); return FALSE; } if ($this->stdout) { //デバッグ用 echo $read_str, "\n"; } return $read_str; }
function processMessage($msg) { global $messageCounter; echo "Processing Message Number = {$messageCounter}. Press CTRL+C to stop processing\n"; $messageCounter++; if (isset($msg)) { $dataArray = json_decode($msg->body, true); if (is_array($dataArray)) { writeLog($dataArray, LOG_SMS_FOR_NON_PAUSE); $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); } else { writeLog('Invalid JSON', LOG_PROCESS_INCOMING); } } else { writeLog('Invalid Message Parameter in Callback', LOG_PROCESS_INCOMING); } }
function __construct() { /* we should not always load the feed ... */ if (OpenBHConf::get('xmlfeed') == true) { if (!function_exists('simplexml_load_file')) { writeLog("SimpleXML support missing"); return false; } $this->fmap = OpenBHConf::get('xmlfeedmapping'); } else { $this->fmap = OpenBHConf::get('feedmapping'); } if (!array_key_exists('keyword', $this->fmap)) { writeLog("Missing 'keyword' in 'feedmapping' (see config..php)"); return false; // ... missing keyword mapping } }
function checkCache($ip, $mac, $group) { global $mc; if ($mc) { $key = "{$ip}||{$mac}||{$group}"; $un = $mc->get($key); if ($un !== false) { writeLog("Retrieved from cache: {$key} => " . ($un ? $un : "NOT AUTHORISED"), true); if (!is_null($un)) { writeReply("OK user={$un}"); } else { writeReply("ERR"); } return true; } } return false; }
function counter() { $count_fp = fopen(COUNT_FILE, 'r+'); // アクセス数ファイルをopen if (flock($count_fp, LOCK_EX)) { // アクセス数ファイルをLock $countData = fgets($count_fp); // アクセス数データを$countに読み込む $count = explode(',', $countData); // $countDataを,で区切って [0]日付 [1]累計 [2]今日 [3]昨日 $count[1] += 1; // 累計アクセス数を1増やす // タイムゾーンを日本標準時に(WordPress対策) date_default_timezone_set('Asia/Tokyo'); $now = date('Ymd'); //今日の日付を8桁で取得 date_default_timezone_set('UTC'); if ($now === $count[0]) { // 日付が一致したら,今日アクセス数を1増やす $count[2] += 1; } else { // 日付が変わった場合 writeLog($count[0], $count[2]); // ログに書き込む $count[3] = $count[2]; // 今日を昨日に $count[2] = 1; // 今日をリセット } ftruncate($count_fp, 0); // 中身をリセット rewind($count_fp); // アクセス数ファイルのファイルポインタを先頭へ fwrite($count_fp, $now . ',' . $count[1] . ',' . $count[2] . ',' . $count[3]); // アクセス数ファイルに新たな値を書き込む flock($count_fp, LOCK_UN); // アクセス数ファイルをunLock } fclose($count_fp); // アクセス数ファイルをclose // アクセス数を json 形式にして出力 $counts = array('total' => $count[1], 'today' => $count[2], 'yesterday' => $count[3]); echo json_encode($counts); }
/** \brief Creates new feedback to be put in the database * \param feedback Data required to make new feedback * \returns A json encoded 'success' array on success, null in event of error */ function createFeedback($feedback) { try { require "/var/database_config.php"; $pdo = new PDO('mysql:host=' . $db_config['host'] . ';dbname=' . $db_config['dbname'], $db_config['username'], $db_config['password']); $statement = $pdo->prepare("INSERT INTO feedback (interaction_id, admin_gm_id, stars, comments) VALUES (:interaction_id, :admin_gm_id, :stars, :comments)"); $statement->bindParam(':interaction_id', $feedback['interaction_id']); $statement->bindParam(':admin_gm_id', $feedback['admin_gm_id']); $statement->bindParam(':stars', $feedback['stars']); $statement->bindParam(':comments', $feedback['comments']); $statement->execute(); $log = array("Feedback left on ticket."); require "../log.php"; writeLog($feedback['interaction_id'], $log); return array('status' => 'Successfully left feedback'); } catch (PDOException $e) { return array('error' => 'Error leaving feedback!'); } }
function processMessage($msg) { global $messageCounter, $objSwiftMailer; echo "Processing Message Number = {$messageCounter}. Press CTRL+C to stop processing\n"; $messageCounter++; if (isset($msg)) { $dataArray = json_decode($msg->body, true); if (is_array($dataArray)) { if ($dataArray['type'] == 'email') { // Create a message $message = Swift_Message::newInstance('Sample Subject')->setFrom(array($dataArray['from']))->setTo($dataArray['recipients'])->setBody($dataArray['html'], 'multipart/alternative')->addPart($dataArray['html'], 'text/html')->addPart($dataArray['text'], 'text/plain'); // Send the message $objSwiftMailer->send($message); //writeLog($result, LOG_FOR_EMAIL_SENT); } else { if ($dataArray['type'] = 'sms') { $pauseTimeArray = getPauseTimings(PAUSE_START_TIME, PAUSE_END_TIME); if (is_array($pauseTimeArray)) { $pauseStartTime = strtotime($pauseTimeArray['pause_start_time']); $pauseEndTime = strtotime($pauseTimeArray['pause_end_time']); $presentTime = strtotime(date('Y-m-d H:i:s')); if ($presentTime > $pauseStartTime && $presentTime < $pauseEndTime) { global $objRabbitMQ; //Add this SMS to the custom SMS queue, to be processed at the perfect time $objRabbitMQ->declareQueue('sms_queue'); $objRabbitMQ->publish($msg->body, array('delivery_mode' => 2)); } else { writeLog($dataArray, LOG_SMS_FOR_NON_PAUSE); } } else { writeLog('Invalid Pause timings', LOG_PROCESS_INCOMING); } } } $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); } else { writeLog('Invalid JSON', LOG_PROCESS_INCOMING); } } else { writeLog('Invalid Message Parameter in Callback', LOG_PROCESS_INCOMING); } }
public function verifygw($is_sign_success, $merchant_public_key_file, $merchant_private_key_file, $charset) { $biz_content = HttpRequest::getRequest("biz_content"); $as = new AlipaySign(); $xml = simplexml_load_string($biz_content); // print_r($xml); $EventType = (string) $xml->EventType; // echo $EventType; if ($EventType == "verifygw") { if ($is_sign_success) { $response_xml = "<success>true</success><biz_content>" . $as->getPublicKeyStr($merchant_public_key_file) . "</biz_content>"; } else { // echo $response_xml; $response_xml = "<success>false</success><error_code>VERIFY_FAILED</error_code><biz_content>" . $as->getPublicKeyStr($merchant_public_key_file) . "</biz_content>"; } $return_xml = $as->sign_response($response_xml, $charset, $merchant_private_key_file); writeLog("response_xml: " . $return_xml); echo $return_xml; exit; } }
function sendNotification($notification, $end, $lastday) { $text = getMessageText($notification->how, $notification->what, $notification->when, $end); switch ($notification->how) { case 'mail': if (!isset($notification->target) || empty($notification->target)) { writeLog("Cannot send mail. Target ist missing."); break; } mail($notification->target, "Bald ist Ende", $text); writeLog("Mail sent to '" . $notification->target . "'"); break; case 'sms': break; case 'iphone': break; default: writeLog("Found unsupported notification type '" . $notification->how . "'. Exiting..."); return; } }
function kataXhprofShutdown() { $xhprof_data = xhprof_disable(); $xhprof_runs = new XHProfRuns_Default(); $run_id = $xhprof_runs->save_run($xhprof_data, CACHE_IDENTIFIER); if (!defined('XHPROF_URL')) { die('you need to set XHPROF_URL to the absolute path of the xhprof_html directory'); } $profiler_url = sprintf('%s?run=%s&source=%s', XHPROF_URL, $run_id, CACHE_IDENTIFIER); switch (DEBUG) { case 2: case 3: echo '<div style="padding:10px;border:5px solid red;z-index:2000;position:absolute;top:0;left:0;background-color:white;">' . '<a href="' . $profiler_url . '">xhprof report</a></div>'; break; case 1: debug('xhprof report: ' . $profiler_url); break; case 0: writeLog('xhprof report: ' . $profiler_url . ' ' . env('QUERY_STRING'), 2); break; } }
/** * Save the revieved XML to file * * @param string $xml The xml recieved * @return boolean True on success or false */ function saveFile($xml) { global $db; //In your database, log that you have received new xml data $db->query("INSERT INTO saved_xml () VALUES ()") or $db->raise_error('Failed saving xml'); // Will use the message we give it + the SQL $id = $db->insert_id(); //Save the data in a file, and name it using the autoincrement id from your database $filename = "files/{$id}.xml"; if (!($handle = fopen($filename, 'w'))) { writeLog("Failed to open file", $filename); $db->query("DELETE FROM saved_xml WHERE id=" . $id) or $db->raise_error('Failed deleting XML row'); // Will use the message we give it + the SQL return false; } if (fwrite($handle, $xml) === FALSE) { writeLog("Failed to save file content", $filename); $db->query("DELETE FROM saved_xml WHERE id=" . $id) or $db->raise_error('Failed deleting XML row'); // Will use the message we give it + the SQL return false; } fclose($handle); return true; }
<BODY> <BODY BGCOLOR=#FFFFFF BACKGROUND="/images/gif/webpic/back4.gif"> <H1> <IMG SRC="/images/gif/dragon.gif"> Admin User <?php echo $_REQUEST["char"]; ?> </H1> <?php include $_SERVER['DOCUMENT_ROOT'] . "/scripts/admin_authorize.php"; if ($_COOKIE["karchanadminname"] != "Karn") { error_message("This administration option is only available to Karn."); } $result = mysql_query("update mm_admin set validuntil = date_add(validuntil,\n\tinterval 1 month) where name = \"" . quote_smart($_REQUEST["char"]) . "\" and \n\tvaliduntil >= now()", $dbhandle) or error_message("Query failed : " . mysql_error()); $result = mysql_query("update mm_admin set validuntil = date_add(now(),\n\tinterval 1 month) where name = \"" . quote_smart($_REQUEST["char"]) . "\" and \n\tvaliduntil < now()", $dbhandle) or error_message("Query failed : " . mysql_error()); $result = mysql_query("select validuntil from mm_admin \n\twhere name = \"" . quote_smart($_REQUEST["char"]) . "\"", $dbhandle) or error_message("Query failed : " . mysql_error()); while ($myrow = mysql_fetch_array($result)) { writeLog($dbhandle, "Expiration date for " . $_REQUEST["char"] . " changed to " . $myrow["validuntil"] . "."); printf("Expiration date for " . $_REQUEST["char"] . " changed to " . $myrow["validuntil"] . ".<P>\r\n"); } mysql_close($dbhandle); ?> <a HREF="/karchan/admin/extend_period.html"> <img SRC="/images/gif/webpic/buttono.gif" BORDER="0"></a><p> </BODY> </HTML>
error_reporting(0); require_once './config/config.php'; $mobiquo_config = get_mobiquo_config(); if (isset($mobiquo_config['mod_function']) && !empty($mobiquo_config['mod_function'])) { foreach ($mobiquo_config['mod_function'] as $mod_function) { if (!function_exists($mod_function)) { eval("function {$mod_function}(){}"); } } } if (file_exists($forum_root . '/SSI.php')) { require_once $forum_root . '/SSI.php'; } else { die('SSI.php not found, could not initialize'); } writeLog(); // Call Susb-Mobiquo.php, we need this for major assitance require_once './Subs-Mobiquo.php'; require_once './database.php'; $server_data = array(); $user_info['id'] = $ID_MEMBER; require_once './Mobiquo-Functions.php'; require_once './Mobiquo-Templates.php'; require_once './lib/xmlrpc.inc'; require_once './lib/xmlrpcs.inc'; require_once './method_define.php'; require_once './api/forum.php'; require_once './api/topic.php'; require_once './api/subscription.php'; require_once './api/search.php'; require_once './api/user.php';
} $sql = "SELECT CONTENTS\n FROM tweet_list"; $query = $con->prepare($sql); $query->execute(); $rows = $query->fetchAll(); //print_r($rows); if (shuffle($rows)) { $message = $rows[0]; //print_r($message[0]); //print($message[0]); } // ツイート //$Bot->Post($message[0], $sid); } catch (PDOException $e) { print $e->getMessage() . "\n"; writeLog($fp, "Caught Exception -> " . $e); continue; } catch (Exception $e) { print $e->getMessage() . "\n"; writeLog($fp, "Caught Exception -> " . $e); continue; } finally { // 最後に呟きのIDを保存して終わり //$Bot->End($sid); fclose($fp); } function writeLog($fp, $msg) { fprintf($fp, date('Y:m:d H:i:s') . "\n"); fprintf($fp, "{$msg}" . "\n"); }
/** * 写入接口日志 * @param array $arr 接收的参数数组 * @param string $returnStr 接口返回值 * @return void 无返回 * */ function writeInterFaceLog($arr = array(), $returnStr) { $method = $arr['method']; $para = arrToStr($arr, '&'); writeLog($method, $para, $returnStr); }
$ch1 = curl_init(); $now_date = date('Ymd') . '0000'; // writelog($now_date); $lastId = mysql_query("SELECT MAX(killID) id FROM `kills` WHERE characterID={$urlid}") or die(writeLog(mysql_error())); if ($lastId = mysql_fetch_assoc($lastId)) { $lastId = $lastId === "" ? "" : $lastId['id']; } // writelog($lastId); curl_setopt($ch1, CURLOPT_URL, "https://zkillboard.com/api/characterID/{$urlid}/afterkillID/{$lastId}/no-items/xml/"); // curl_setopt ($ch1, CURLOPT_URL,"https://zkillboard.com/api/corporationID/604035876/xml/no-items/" ); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch1, CURLOPT_HEADER, 0); $data = curl_exec($ch1); curl_close($ch1); $xmlKills = simplexml_load_string($data); if (is_object($xmlKills)) { foreach ($xmlKills->result->rowset->row as $kill) { $urlkill = urlencode($kill['killid']); $_chid = $kill->victim['characterID']; if ($kill->victim['corporationID'] == $corpid_m or $kill->victim['corporationID'] == $corpid_a or $kill->victim['corporationID'] == $corpid_g) { @mysql_query("INSERT INTO kills (`killID`,`characterID`,`attackerID`,`killTime`,`killInternalID`,`victimID`)\n VALUES ({$kill['killID']},{$_chid},{$_chid},'{$kill['killTime']}',{$kill['killID']},{$_chid})\n ON DUPLICATE KEY UPDATE killID={$kill['killID']},characterID={$_chid}") or die(writeLog(mysql_error())); } foreach ($kill->rowset->row as $attack) { if ($attack['corporationID'] == $corpid_m or $attack['corporationID'] == $corpid_a or $attack['corporationID'] == $corpid_g) { @mysql_query("INSERT INTO kills (`killID`,`characterID`,`attackerID`,`killTime`,`killInternalID`,`victimID`)\n VALUES ({$kill['killID']},{$attack['characterID']},{$attack['characterID']},'{$kill['killTime']}',{$kill['killID']},{$_chid})\n ON DUPLICATE KEY UPDATE killID={$kill['killID']},characterID={$attack['characterID']}") or die(writeLog(mysql_error())); } } } } } mysql_close($conn);
/** * 保存数据进数据库 * @param $data * @author Mr.Cong <*****@*****.**> */ public function saveData($data) { Forums::where('fid', $this->fid)->delete(); foreach ($data['items'] as $key => $item) { $forums = new Forums(); $forums->fid = $this->fid; $forums->title = $item->get_title(); $forums->link = $item->get_link(); $forums->description = html_entity_decode($item->get_description(), ENT_COMPAT); $forums->category = $item->get_category()->get_term(); $forums->author = $item->get_author()->get_email(); $forums->pubDate = strtotime($item->get_date()); $forums->save(); $all_link[$forums->id] = $item->get_link(); } /* * 异步采集内容 */ $index = 0; foreach ($all_link as $kyeId => $link) { $index++; $threadId = preg_split('/[\\/\\-]/', $link); $get_url = sprintf('https://gsee.tuiyue.org/Spider/reptile/%s/%s', $threadId[4], $kyeId); sock_get($get_url); unset($get_url); if ($index == 5) { sleep(10); $index = 0; } } writeLog('Save data to database.'); }