예제 #1
0
 public function postPublish()
 {
     $msg = 'Report Successfully Published';
     $inputs = Input::except('notify');
     foreach (Input::all() as $key => $single_input) {
         if (empty($single_input) && (stristr($key, 'state') || stristr($key, 'city'))) {
             unset($inputs[$key]);
         }
     }
     $inputs['dob'] = GlobalFunc::set_date_format(Input::get('dob'));
     $inputs['found_date'] = GlobalFunc::set_date_format(Input::get('found_date'));
     if (!Input::hasFile('kid_image')) {
         unset($inputs['kid_image']);
     } else {
         $file = Input::file('kid_image');
         $destination_path = 'admin/images/upload/';
         $filename = str_random(15) . '.' . $file->getClientOriginalExtension();
         $file->move($destination_path, $filename);
         $inputs['kid_image'] = $destination_path . $filename;
     }
     if (Input::get('clicked') == 'Success') {
         // if the report is marked as a success
         $inputs['status'] = 9;
         $msg = 'Report Successfully Marked As Success';
     } else {
         //if the report is updated or published
         $inputs['status'] = 1;
     }
     unset($inputs['clicked']);
     Found::where('id', '=', Input::get('id'))->update($inputs);
     return Redirect::to('admin/found/published')->with('success', $msg);
 }
예제 #2
0
 public static function getPlanets()
 {
     $Config = ConfigManager::declareConfigValue();
     //get overview page html
     $overview = GlobalFunc::httpGet($Config['OVERVIEW_URL'], $Config['COOKIE_FILE']);
     $ov_dom = GlobalFunc::loadHtml($overview);
     $planet_list_dom = $ov_dom->getElementById("planetList");
     $pList = $planet_list_dom;
     if (!is_object($pList)) {
         echo "Error occur, Planet List not found, return empty planet list.\n";
         return array();
     }
     //list 下 每個div都是一個星球
     //每個div下都有兩個span
     //<span class="planet-name  ">jones4</span>
     //<span class="planet-koords  ">[1:83:6]</span>
     $planets_dom = $pList->getElementsByTagName('div');
     //echo "There ". $planets_dom->length . " Planet(s).";
     //存放月亮的起始編號(最後一顆星球之後就是月亮)
     $moon_num = $planets_dom->length + 1;
     //create planets
     $planets = array();
     for ($i = 0; $i < $planets_dom->length; $i++) {
         //get planet link
         $a_list = $planets_dom->item($i)->getElementsByTagName('a');
         $a_dom = $a_list->item(0);
         //產生星球
         $planet = Planet::createPlanetObj($a_dom, $planets_dom, $i);
         //將星球obj 加入list
         $planets[$i] = $planet;
         //確認是否有月球
         $has_moon = false;
         $moon_href = "";
         $moon_coord = array();
         $a_count = $a_list->length;
         $moon_obj = array();
         Planet::updateMoonInfo($a_list, $a_count, $planet, $has_moon, $moon_href, $moon_coord);
         if ($has_moon == true) {
             //有月亮則加到清單最後面
             $moon_obj = new Planet("月亮", $moon_coord, null, $moon_href, $moon_num);
             //將月亮obj 加入list
             //idx為編號-1
             $planets[$moon_num - 1] = $moon_obj;
             $moon_num++;
             //月亮編號+1
         }
     }
     return $planets;
 }
예제 #3
0
 public function postPublish()
 {
     $states = Input::get('notify');
     if ($states[0] == 'All') {
         $temp_states = Cities::distinct()->select('city_state')->get();
         unset($states);
         foreach ($temp_states as $state) {
             $states[] = $state->city_state;
         }
     }
     $users = DB::table('users')->OrwhereIn('state', $states)->select('uid', 'email', 'fname', 'username');
     $organizations = DB::table('other_users')->OrwhereIn('state', $states)->select('uid', 'email', 'fname', 'username');
     $combined = $users->union($organizations)->get();
     $msg = 'Report Published Successfully';
     $inputs = Input::except('notify');
     foreach (Input::all() as $key => $single_input) {
         if (empty($single_input) && (stristr($key, 'state') || stristr($key, 'city'))) {
             unset($inputs[$key]);
         }
     }
     $inputs['dob'] = GlobalFunc::set_date_format(Input::get('dob'));
     $inputs['missing_since'] = GlobalFunc::set_date_format(Input::get('missing_since'));
     if (!Input::hasFile('kid_image')) {
         unset($inputs['kid_image']);
     } else {
         $file = Input::file('kid_image');
         $destination_path = 'admin/images/upload/';
         $filename = str_random(15) . '.' . $file->getClientOriginalExtension();
         $file->move($destination_path, $filename);
         $inputs['kid_image'] = $destination_path . $filename;
     }
     if (Input::get('clicked') == 'Success') {
         $inputs['status'] = 9;
         $msg = 'Report Successfully Marked As Success';
     } else {
         $inputs['status'] = 1;
     }
     unset($inputs['clicked']);
     Missing::where('id', '=', Input::get('id'))->update($inputs);
     $title = 'New Report Published';
     $message = 'Hello';
     foreach ($combined as $email_chunk) {
         $insert = array('user_id' => $email_chunk->uid, 'message' => $message, 'title' => $title);
         Notifications::create($insert);
     }
     return Redirect::to('admin/missing/published')->with('success', $msg);
 }
예제 #4
0
 public function cache($file)
 {
     $tplfile = $this->_getTplFile($file);
     if (!is_readable($tplfile)) {
         $this->_throwException("throwException \"{$tplfile}\" throwException");
     }
     $template = file_get_contents($tplfile);
     for ($i = 1; $i <= 3; $i++) {
         if (GlobalFunc::strexists($template, '{subtemplate')) {
             $template = preg_replace("/[\n\r\t]*\\{subtemplate\\s+([a-z0-9_]+)\\}[\n\r\t]*/ies", "loadsubtemplate('\\1')", $template);
         }
     }
     $template = preg_replace("/\\<\\!\\-\\-\\{(.+?)\\}\\-\\-\\>/s", "{\\1}", $template);
     $template = str_replace("{LF}", "<?=\"\\n\"?>", $template);
     $varRegexp = "((\\\$[a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*)" . "(\\[[a-zA-Z0-9_\\-\\.\"\\'\\[\\]\$-ÿ]+\\])*)";
     $template = preg_replace("/\\{(\\\$[a-zA-Z0-9_\\[\\]\\'\"\$\\.-ÿ]+)\\}/s", "<?=\\1?>", $template);
     $template = preg_replace("/{$varRegexp}/es", "addquote('<?=\\1?>')", $template);
     $template = preg_replace("/\\<\\?\\=\\<\\?\\={$varRegexp}\\?\\>\\?\\>/es", "addquote('<?=\\1?>')", $template);
     $template = preg_replace("/[\n\r\t]*\\{template\\s+([a-z0-9_]+)\\}[\n\r\t]*/is", "\r\n<? include(\$template->getfile('\\1')); ?>\r\n", $template);
     $template = preg_replace("/[\n\r\t]*\\{template\\s+(.+?)\\}[\n\r\t]*/is", "\r\n<? include(\$template->getfile(\\1)); ?>\r\n", $template);
     $template = preg_replace("/[\n\r\t]*\\{eval\\s+(.+?)\\}[\n\r\t]*/ies", "stripvtags('<? \\1 ?>','')", $template);
     $template = preg_replace("/[\n\r\t]*\\{echo\\s+(.+?)\\}[\n\r\t]*/ies", "stripvtags('<? echo \\1; ?>','')", $template);
     $template = preg_replace("/([\n\r\t]*)\\{elseif\\s+(.+?)\\}([\n\r\t]*)/ies", "stripvtags('\\1<? } elseif(\\2) { ?>\\3','')", $template);
     $template = preg_replace("/([\n\r\t]*)\\{else\\}([\n\r\t]*)/is", "\\1<? } else { ?>\\2", $template);
     $nest = 5;
     for ($i = 0; $i < $nest; $i++) {
         $template = preg_replace("/[\n\r\t]*\\{loop\\s+(\\S+)\\s+(\\S+)\\}[\n\r]*(.+?)[\n\r]*\\{\\/loop\\}[\n\r\t]*/ies", "stripvtags('<? if(is_array(\\1)) { foreach(\\1 as \\2) { ?>','\\3<? } } ?>')", $template);
         $template = preg_replace("/[\n\r\t]*\\{loop\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\}[\n\r\t]*(.+?)[\n\r\t]*\\{\\/loop\\}[\n\r\t]*/ies", "stripvtags('<? if(is_array(\\1)) { foreach(\\1 as \\2 => \\3) { ?>','\\4<? } } ?>')", $template);
         $template = preg_replace("/([\n\r\t]*)\\{if\\s+(.+?)\\}([\n\r]*)(.+?)([\n\r]*)\\{\\/if\\}([\n\r\t]*)/ies", "stripvtags('\\1<? if(\\2) { ?>\\3','\\4\\5<? } ?>\\6')", $template);
     }
     $template = preg_replace("/\\{([a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*)\\}/s", "<?=\\1?>", $template);
     $template = preg_replace("/ \\?\\>[\n\r]*\\<\\? /s", " ", $template);
     $template = preg_replace("/\"(http)?[\\w\\.\\/:]+\\?[^\"]+?&[^\"]+?\"/e", "transamp('\\0')", $template);
     $template = preg_replace("/\\<script[^\\>]*?src=\"(.+?)\".*?\\>\\s*\\<\\/script\\>/ise", "stripscriptamp('\\1')", $template);
     $template = preg_replace("/[\n\r\t]*\\{block\\s+([a-zA-Z0-9_]+)\\}(.+?)\\{\\/block\\}/ies", "stripblock('\\1', '\\2')", $template);
     $md5data = md5_file($tplfile);
     $expireTime = time();
     $template = "<? if (!class_exists('template')) die('Access Denied');" . "\$template->getInstance()->check('{$file}', '{$md5data}', {$expireTime});" . "?>\r\n{$template}";
     $cachefile = $this->_getCacheFile($file);
     $makepath = $this->_makepath($cachefile);
     if ($makepath !== true) {
         $this->_throwException("throwException \"{$makepath}\"");
     }
     file_put_contents($cachefile, $template);
 }
예제 #5
0
 public function postFound()
 {
     $input = Input::all();
     $logged_in_data = Auth::org()->get();
     $rules = array('name' => 'required|alpha_spaces', 'dob' => 'date_format:m/d/Y', 'family_name' => 'alpha_spaces', 'phone_number' => 'numeric', 'police_station_number' => 'numeric', 'enquiry_office_number' => 'numeric', 'found_date' => 'date_format:m/d/Y', 'gender' => 'required');
     $v = Validator::make(Input::all(), $rules);
     if ($v->fails()) {
         return Redirect::back()->withInput(Input::all())->withErrors($v);
     }
     $input = $this->check_images_and_upload($input);
     $input['dob'] = GlobalFunc::set_date_format(Input::get('dob'));
     $input['found_date'] = GlobalFunc::set_date_format(Input::get('found_date'));
     $input['report_type'] = 'Found';
     $input['created_by'] = $logged_in_data->uid;
     $uid = strtoupper(Str::random(3)) . '_' . time();
     $input['uid'] = $uid;
     Found::create($input);
     return Redirect::back()->with('success', 'Record Successfully Inserted');
 }
예제 #6
0
 private function getFleetsAmount($f1_page)
 {
     $f1 = GlobalFunc::loadHTML($f1_page);
     $military = $f1->getElementById("military");
     $civil = $f1->getElementById("civil");
     $this->fleets = null;
     if (!isset($military)) {
         echo "Error occur, military is not found. return & as uri.\n";
         echo iconv("UTF-8", "big5", "船隊撤退失敗 請檢查星球上是否有可移動船隻\n");
         return '&';
     }
     if (!isset($civil)) {
         echo "Error occur, civil is not found. return & as uri.\n";
         return '&';
     }
     $result_uri = "";
     $result_uri .= $this->getFleetAmountByCategory($military);
     $result_uri .= $this->getFleetAmountByCategory($civil);
     echo "Sent fleet result uri = " . $result_uri . "\n";
     //var_dump($this->fleets);
     return $result_uri;
 }
예제 #7
0
 function sendBuildRequest($but_dom, $resource_item_name)
 {
     if (isset($but_dom)) {
         echo "Resource Item: " . $resource_item_name . " is found!\n";
         $but_class = $but_dom->getAttribute('class');
         echo "but_class: " . $but_class . "\n";
         if (strstr($but_class, "disabled")) {
             //不能蓋 (可能是資源不足 或 其他正在建)
             echo iconv("UTF-8", "big5", "不能蓋") . "\n";
             return -1;
         } else {
             if (strstr($but_class, "off")) {
                 echo iconv("UTF-8", "big5", "but_class = off, not able to build return 1 to skip.\n") . "\n";
                 return 1;
             }
         }
         //可以蓋
         //若正在該的就是此項目 則class為on 仍不為disable
         //要確定是否真的可以蓋 找過所有div 確定沒有class名為 construction 的子div
         $isThisBuilding = false;
         $divs = $but_dom->getElementsByTagName('div');
         for ($dIdx = 0; $dIdx < $divs->length; $dIdx++) {
             $div = $divs->item($dIdx);
             $div_class = $div->getAttribute('class');
             if ($div_class == "construction") {
                 $isThisBuilding = true;
                 break;
             }
         }
         if ($isThisBuilding == true) {
             echo iconv("UTF-8", "big5", "此項目正在建造中") . "\n";
             return -1;
         }
         echo iconv("UTF-8", "big5", "可以蓋") . "\n";
         //找正確的tag_a
         $tag_a = $but_dom->getElementsByTagName('a')->item(0);
         $onclick_str = $tag_a->getAttribute('onclick');
         if (strlen($onclick_str) < 10) {
             $tag_a = $but_dom->getElementsByTagName('a')->item(1);
             $onclick_str = $tag_a->getAttribute('onclick');
         }
         //從onclick string中找到網址
         //網址應為 'http://....'
         $onclick_str = substr($onclick_str, strpos($onclick_str, "http://"));
         $onclick_str = substr($onclick_str, 0, strpos($onclick_str, "'"));
         echo "onclick_str: " . $onclick_str . "\n";
         //送出http request
         $this->onclickStr = $onclick_str;
         $result_page = GlobalFunc::synExecute("Sent build resource request", function () {
             echo "onclick_str: " . $this->onclickStr . "\n";
             $result_page = GlobalFunc::httpGet($this->onclickStr, $this->Config['COOKIE_FILE']);
             return $result_page;
         });
         $resultLen = strlen($result_page);
         if ($resultLen > $this->Config['AskPageLeastStrLen']) {
             return 1;
         } else {
             file_put_contents($this->Config['FailInfo'], $result_page);
             echo "ResourceManager: Sent build resource request result len " . $resultLen . " too few, content has written into FailInfo file, return 0.\n";
             return 0;
             //發送的請求可能失敗了
         }
     } else {
         echo "Resource Item: " . $resource_item_name . " is not found!\n";
         return 0;
         //發送的請求可能失敗了 所以找不到該item
     }
 }
예제 #8
0
<?php

ini_set('display_errors', 0);
include "../include/config.inc.php";
include "../library/global.func.php";
$tid = $_REQUEST['tid'];
$tNo = intval($_REQUEST['tno']);
$mid = $_REQUEST['mid'];
$os = intval($_REQUEST['os']);
$c_stream_file = false;
if (preg_match('/^[a-fA-F0-9]{32}$/', $mid)) {
    $c_stream_file = $repo_path . 'bin/' . $mid . '.' . $os;
} elseif (preg_match('/^[a-zA-Z0-9]{32}$/', $tid)) {
    $c_stream_file = GlobalFunc::get_stream_path($tid, false);
    $c_stream_file .= "{$tid}" . '.UP.' . "{$tNo}";
}
if ($c_stream_file and file_exists($c_stream_file)) {
    $a = file_get_contents($c_stream_file);
    $totalSize = strlen($a);
    header("Content-Length: " . $totalSize);
    exit($a);
}
exit;
예제 #9
0
                ob_flush();
                flush();
                $waitSeconds = 0;
                $chunk_output++;
            }
            if ($totalSize > 0 and $chunked_size >= $totalSize) {
                $end_status = STREAM_TASK_END_COMPLISHED;
                break;
            }
            if (0 !== connection_status()) {
                $end_status = STREAM_TASK_END_BROWSERBROKE;
                break;
            }
            $db->close();
            sleep($waitSecPer);
            $db = GlobalFunc::connect_db($mysql_ini);
            if (!$db) {
                $lasterror[] = $language['fail_db'] . ' StreamLoop';
                $end_status = STREAM_TASK_END_CONNMYSQL;
            }
            $waitSeconds += $waitSecPer;
            if ($waitSeconds > $streamWaitExpire) {
                $lasterror[] = 'connect over time';
                $end_status = STREAM_TASK_END_OVERTIME;
                break;
            }
        }
    }
}
if ($lasterror and !$header_show) {
    include $template->getfile('tips.htm');
예제 #10
0
 } else {
     $new_comment = $_POST['new_comment'];
     $query = "select token,comment from " . $mysql_ini['prefix'] . "token";
 }
 $result = $db->query("{$query}");
 $i = mysqli_num_rows($result);
 $max_token -= $i;
 for (; $i > 0; $i--) {
     $r = $result->fetch_assoc();
     $r['comment'] = htmlspecialchars($r['comment']);
     $r['remark'] = explode(',', $r['comment']);
     $c_token[] = $r;
 }
 if ($new_comment) {
     if ($max_token > 0) {
         $new_token = GlobalFunc::random(32);
         $query = "insert into " . $mysql_ini['prefix'] . "token values (NULL,?,?,0)";
         $stmt = $db->prepare($query);
         $stmt->bind_param("ss", $new_token, $new_comment);
         if (!$stmt->execute()) {
             $lasterror[] = $language['create_token_fail'];
         } else {
             $max_token--;
             $r['token'] = $new_token;
             $r['comment'] = htmlspecialchars($new_comment);
             $r['remark'] = explode(',', $r['comment']);
             $c_token[] = $r;
         }
         $stmt->close();
     } else {
         $lasterror[] = $language['no_more_token'];
예제 #11
0
                $tmp = $result->fetch_assoc();
                $tmp['os'] = explode(',', $tmp['os']);
                $total_modules_array[$tmp['module']] = $tmp;
            }
            foreach ($c_modules_array as $a) {
                if (isset($total_modules_array[$a])) {
                    $root_installed[$total_modules_array[$a]['root']] = true;
                    $total_modules_array[$a]['installed'] = true;
                }
            }
            foreach ($total_modules_array as $a => $b) {
                if ($b['version'] === $b['latest_version']) {
                    $tmp_array[$a] = $b;
                    if (true === $root_installed[$b['root']]) {
                        $tmp_array[$a]['root_installed'] = true;
                    }
                }
            }
            foreach ($tmp_array as $a => $b) {
                $tmp_array[$a] += GlobalFunc::get_mod_name($b['module'], $language_choosed);
            }
            foreach ($tmp_array as $b) {
                foreach ($b['os'] as $c) {
                    $result_modules_array[$c][] = $b;
                }
            }
        }
    }
}
include $template->getfile('mod_manage.htm');
exit;
예제 #12
0
 public static function KeepAlive()
 {
     global $srv_block_ini;
     global $mysql_ini;
     global $clientId;
     global $mac_num;
     $breath_delay = 0;
     $db_timer = time();
     $active_offline = false;
     // Drone 主动下线
     while (true) {
         usleep($srv_block_ini['sleep'] * 1000000);
         $db = GlobalFunc::connect_db($mysql_ini);
         if ($db) {
             $c_status = connection_status();
             if ($active_offline or $c_status != 0) {
                 //client offline
                 $query = 'delete from ' . $mysql_ini['prefix'] . "online_mac where cid={$clientId} limit {$mac_num}";
                 $db->query($query);
                 $module_num = 0;
                 $query = 'select mod_num from ' . $mysql_ini['prefix'] . "online_clients where cid={$clientId} limit 1";
                 $result = $db->query($query);
                 if (1 === mysqli_num_rows($result)) {
                     $result = $result->fetch_assoc();
                     $module_num = $result['mod_num'];
                     $module_num++;
                     // add sys remain mid Number
                     if ($module_num) {
                         $query = 'delete from ' . $mysql_ini['prefix'] . "online_module where cid={$clientId} limit {$module_num}";
                         $db->query($query);
                     }
                     $query = 'delete from ' . $mysql_ini['prefix'] . "online_clients where cid={$clientId} limit 1";
                     $db->query($query);
                 }
                 break;
             } else {
                 $query = 'select rid,tid,module from ' . $mysql_ini['prefix'] . 'online_task  where cid = ' . $clientId . ' and status = 0';
                 $result = $db->query($query);
                 $i = mysqli_num_rows($result);
                 for (; $i > 0; $i--) {
                     $request_data = '';
                     $error = false;
                     $tmp = $result->fetch_assoc();
                     if (!empty($tmp['rid'])) {
                         if (32 === strlen($tmp['rid'])) {
                             $query = 'select data from ' . $mysql_ini['prefix'] . 'data_request where rid = \'' . $tmp['rid'] . '\' limit 1';
                         } else {
                             $query = 'select data from ' . $mysql_ini['prefix'] . 'shortcuts where sid = \'' . $tmp['rid'] . '\' limit 1';
                         }
                         $res = $db->query($query);
                         if (1 == mysqli_num_rows($res)) {
                             $a = $res->fetch_assoc();
                             $request_data = $a['data'];
                         } else {
                             //出错找不到request Data,写入返回
                             $error = true;
                             $query = 'update ' . $mysql_ini['prefix'] . 'online_task set status = -101 where tid = \'' . $tmp['tid'] . '\' and cid=' . $clientId . ' limit 1';
                             $db->query($query);
                         }
                     }
                     if (false === $error) {
                         $len = strlen($request_data);
                         $out = pack("H32CA32CV", $tmp['module'], 255, $tmp['tid'], 255, $len);
                         echo "" . "{$out}" . $request_data;
                         //."\x00";
                         echo "";
                         ob_flush();
                         flush();
                         $query = 'update ' . $mysql_ini['prefix'] . 'online_task set status = 1 where tid = \'' . $tmp['tid'] . '\' and cid=' . $clientId . ' limit 1';
                         $db->query($query);
                         //reset breath delay
                         $breath_delay = $srv_block_ini['breath_delay'];
                     }
                 }
                 if ($breath_delay < 0) {
                     echo "";
                     ob_flush();
                     flush();
                     //reset breath delay
                     $breath_delay = $srv_block_ini['breath_delay'];
                 } else {
                     $breath_delay -= $srv_block_ini['sleep'];
                 }
                 //db.living
                 $c_time = time();
                 if ($c_time - $db_timer > $srv_block_ini['db_living']) {
                     $db_timer = $c_time;
                     $query = "update " . $mysql_ini['prefix'] . "online_clients set lastliving = {$db_timer} where cid={$clientId} and status = 1 limit 1";
                     $db->query($query);
                     if (1 != $db->affected_rows) {
                         GlobalFunc::errorlog('db.living update 失败,疑似Drone主动下线...', 2);
                         $active_offline = true;
                     }
                 }
             }
             $db->close();
         } else {
         }
     }
 }
예제 #13
0
 public static function filterAttackByEventFleetStr($event_fleets_str, $th_list, &$isThreaten)
 {
     //傳入Event Fleet String
     if (!isset($event_fleets_str) || $event_fleets_str == "") {
         echo "Error, filterAttackByEventFleetStr(): event_fleets_str empty, return 0\n";
         return 0;
     }
     $fleet_dom = GlobalFunc::loadHtml('<?xml encoding="UTF-8">' . $event_fleets_str);
     $fleet_tds = $fleet_dom->getElementsByTagName('td');
     $fleet_td_count = $fleet_tds->length;
     echo "event_fleets_str len: " . strlen($event_fleets_str) . "\n";
     echo "filterAttackByEventFleetStr(): fleet_td_count = {$fleet_td_count}\n";
     for ($f_idx = 0; $f_idx < $fleet_td_count; $f_idx++) {
         //取得UTF-8編碼下的characters
         $text_got = $fleet_tds->item($f_idx)->textContent;
         $text_got = trim($text_got, ":");
         //echo "[$f_idx]: " . $text_got . "\n";
         if (isset($th_list[$text_got])) {
             //若是船艦 idx+1 即為船艦數量
             $ship_count = $fleet_tds->item($f_idx + 1)->textContent;
             $ship_count = GlobalFunc::strToIntByTakeCommaOff($ship_count);
             //跳躍讀取船艦數量 idx要自動加1
             $f_idx++;
         } else {
             //不在過濾的船艦清單中
             echo iconv("UTF-8", "big5//IGNORE", "[{$f_idx}]{$text_got} 此項目不在清單中\n");
             continue;
         }
         //echo iconv("UTF-8", "big5//IGNORE", "$text_got 數量:$ship_count\n");
         //比對清單 看是否有威脅性
         echo iconv("UTF-8", "big5//IGNORE", "[{$f_idx}]text_got 門檻:" . $th_list[$text_got] . " 判斷運算子(<=) 攻擊數量:{$ship_count}\n");
         if ($th_list[$text_got] <= $ship_count) {
             //有威脅性
             echo iconv("UTF-8", "big5//IGNORE", "此項目已超過門檻 具有威脅性.\n");
             $isThreaten = true;
             //不用再偵測了 已經確定此工及具有威脅性
             break;
         }
     }
     return 1;
 }
예제 #14
0
 function run()
 {
     /*
     			船隊ID:1026133
     			抵達時間 - 飛行長度 = 出發時間 fleetInfo["starttime"]
     			現在時間 - 出發時間 = 回來所需時間
     
     			#攻擊到達時間 = 所有針對該星球的攻擊 最近的那個 但如果攻擊之間只相距不到1分鐘 則視為同一個攻擊事件
     			#不用定期抓event list 因為defender反應的時候攻擊就已經快要到達了
     
     			現在時間 + 回來所需時間 - 攻擊到達時間 > 10 秒
     			召回
     */
     /*
     	以下三個重要的動作要做失敗判斷
     	1.$AttackDetector->detectAttack();
     	2.$this->defendAttack()
     	3.Withdraw fleets
     */
     while (1 == 1) {
         //<These code should be sychronized>
         //echo "Defender[".$this->p_coord[0].":".$this->p_coord[1].":".$this->p_coord[2]."]: ask for key.\n";
         $resultlen = GlobalFunc::synExecute("Defender[" . $this->p_coord[0] . ":" . $this->p_coord[1] . ":" . $this->p_coord[2] . "](" . $this->p_coord[3] . "):", function () {
             date_default_timezone_set('Asia/Taipei');
             $last_update_time = file_get_contents($this->Config['DLastUpt'], true);
             echo " last update time: " . date('H:i:s', $last_update_time) . "\n";
             $nowTime = time();
             if ($nowTime - $last_update_time <= 5) {
                 //5秒內更新過的 可以直接使用
                 echo "Last update time: " . date('H:i:s', $last_update_time) . "; File is updated within 5 second.\n";
                 //確保通知外面 已經拿到想要的東西了
                 return $this->Config['AskPageLeastStrLen'] + 1;
             } else {
                 echo "Last update time: " . date('H:i:s', $last_update_time) . "; File is not updated ask for overview page\n";
                 //更新overview string的內容
                 $overview_string = "";
                 $overview_string = GlobalFunc::getOverviewPage();
                 //echo "\noverview result strlen: " .strlen($overview_string) . "\n";
                 if (strlen($overview_string) < $this->Config['AskPageLeastStrLen']) {
                     //access failed;
                     echo "Defender ask for overview page failed, return 0\n";
                     return 0;
                 }
                 $event_list = GlobalFunc::getEventList();
                 //update overview page and event list info
                 $put1 = file_put_contents($this->Config['ADOverview'], $overview_string);
                 $put2 = file_put_contents($this->Config['ADEventList'], $event_list);
                 //update last update time that other threads can check
                 $put3 = file_put_contents($this->Config['DLastUpt'], time());
                 echo " Put1={$put1}, Put2={$put2}, Put3={$put2}\n";
             }
             //成功取得頁面
             return strlen($overview_string);
         });
         echo "Defend read overview page result length: {$resultlen}\n";
         if ($resultlen < $this->Config['AskPageLeastStrLen']) {
             echo "Defender: Error occur, failed to update overview page. login in again, resltlen: " . $resultlen . "\n";
             $LoginManager = new LoginManager();
             continue;
             //登入後 重跑回圈
         }
         //</These code should be sychronized>
         //偵測攻擊
         $AttackDetector = new AttackDetector($this->p_coord);
         $arrivetime = $AttackDetector->detectAttack();
         //$arrivetime == 0表示不需要做任何事
         //$arrivetime == "xx:xx:xx" 表示在這個時間攻擊會到達
         $fleet_already_withdraw = false;
         $withdraw_arr_time = 0;
         //偵測到攻擊則開始抵禦
         //不是數字 就表示有攻擊
         echo "Defender: get returned arrivetime: ";
         var_dump($arrivetime);
         if (strcmp($arrivetime, "0") != 0) {
             echo "[" . $this->p_coord[0] . ":" . $this->p_coord[1] . ":" . $this->p_coord[2] . "](" . $this->p_coord[3] . ") start defese.\n";
             $this->fleetInfo = $this->defendAttack();
             //會更新fleet info
             if ($this->fleetInfo == 0) {
                 $halt_period = $this->Config["sendFleetFailHaltPeriod"];
                 echo "Defender: fleetInfo return 0, error occur.\n";
                 echo "Defender: No withdraw link to withdraw fleets.\n";
                 echo "Ignore withdraw command. Sleep " . $halt_period . " second.\n";
                 if (strlen($halt_period) == 0) {
                     $halt_period = 10;
                 }
                 sleep($halt_period);
                 continue;
             }
             echo "Fleet Start Time: " . date('H:i:s', $this->fleetInfo["starttime"]) . "\n";
             echo "Fleet Withdraw link: " . $this->fleetInfo["withdraw_link"] . "\n";
             while (1 == 1) {
                 //算出回來所需時間 每個loop更新一次
                 $withdraw_arr_left_sec = time() - $this->fleetInfo["starttime"];
                 $attack_arr_left_sec = GlobalFunc::timeFromNowInSecond($arrivetime, false);
                 if ($withdraw_arr_left_sec - $attack_arr_left_sec >= 60 && $fleet_already_withdraw == false) {
                     //撤退回到星球所需時間 > 攻擊到達剩餘時間
                     //可以撤退船隊了
                     //要發送撤回船隊的指令
                     //Syn start
                     $result = GlobalFunc::synExecute("Fleet Withdraw", function () {
                         // start time為預估時間 取不到實際值 因此很可能會有誤差
                         $result = GlobalFunc::httpGet($this->fleetInfo["withdraw_link"], $this->Config['COOKIE_FILE']);
                         echo "Withdraw Link: " . $this->fleetInfo["withdraw_link"] . "\n";
                         return $result;
                     });
                     if (strlen($result) < $this->Config['AskPageLeastStrLen']) {
                         echo "Error occur, Fleet Withdraw result page len < AskPageLeastStrLen, may login in again.\n";
                         $LoginManager = new LoginManager();
                         continue;
                     }
                     //Syn end
                     //標記船隊已經在回程途中
                     //取得艦隊會到家的時間
                     $fleet_already_withdraw = true;
                     $withdraw_arr_time = $withdraw_arr_left_sec + time();
                     echo "Defender: [" . $this->p_coord[0] . ":" . $this->p_coord[1] . ":" . $this->p_coord[2] . "](" . $this->p_coord[3] . ") ";
                     echo "withdraw fleets. result len: " . strlen($result) . ".\n";
                 } else {
                     if ($fleet_already_withdraw == false) {
                         echo "Defender: [" . $this->p_coord[0] . ":" . $this->p_coord[1] . ":" . $this->p_coord[2] . "](" . $this->p_coord[3] . ") ";
                         echo "if " . ($withdraw_arr_left_sec - $attack_arr_left_sec) . " >= 60, withdraw fleets.\n";
                     } else {
                         if ($withdraw_arr_time - time() < 0) {
                             //船隊順利回到家
                             $idle_sec = $this->Config['idlePeriod'];
                             echo "Defender: [" . $this->p_coord[0] . ":" . $this->p_coord[1] . ":" . $this->p_coord[2] . "](" . $this->p_coord[3] . ") ";
                             echo "Fleets got home, lose defending ability for next 5 seconds.\n";
                             sleep($idle_sec);
                             // prevent wrong prediction of the time that fleets arrive
                             break;
                             //break以後馬上會重跑回圈 若無sleep很可能因為誤差 船還沒到家
                             //若有下一輪攻擊 很可能造成程式失效
                             //因此當抵達的 $idle_sec 秒將沒有抵禦能力
                             //(船通常會晚個10~30秒到家,依據目前設定是10秒)
                         } else {
                             echo "Defender: [" . $this->p_coord[0] . ":" . $this->p_coord[1] . ":" . $this->p_coord[2] . "](" . $this->p_coord[3] . ") ";
                             echo "Fleets will get home after " . ($withdraw_arr_time - time()) . " second.\n";
                         }
                     }
                 }
                 sleep(2);
             }
         } else {
             echo "Defender: [" . $this->p_coord[0] . ":" . $this->p_coord[1] . ":" . $this->p_coord[2] . "](" . $this->p_coord[3] . ") ";
             //$detect_period = $this->Config['DetectPeriod'];
             $detect_period = rand($this->Config['DetectPeriod'] / 2, $this->Config['DetectPeriod']);
             echo "sleep " . $detect_period . " second.\n";
             sleep($detect_period);
             //sleep(60);
         }
     }
     echo "Defend loop out\n";
 }
예제 #15
0
 function hasAttack()
 {
     $isAttacked = false;
     //get overview page
     //$over_page = GlobalFunc::getOverviewPage();
     //read over_page string from file
     $last_update_time = file_get_contents($this->Config['DLastUpt'], true);
     echo "\n===== Detect if has attack file path =====\n";
     echo "AttackDetector: [" . $this->PLANET[0] . ":" . $this->PLANET[1] . ":" . $this->PLANET[2] . "](" . $this->PLANET[3] . "):\n";
     echo "File last updated time: " . date('H:i:s', $last_update_time) . "\n";
     echo "ADOverview Path: " . $this->Config['ADOverview'] . "\n";
     echo "ADEventList Path: " . $this->Config['ADEventList'] . "\n";
     echo "====================================\n";
     $over_page = file_get_contents($this->Config['ADOverview'], true);
     //read over_page string from file
     //echo "over_page result strlen: " . strlen($over_page) . "\n";
     if (strlen($over_page) < $this->Config['AskPageLeastStrLen']) {
         echo "Request overview page failed, strlen: " . strlen($over_page) . ". may be attacked.\n";
         return 1;
         // maybe has attacked but call latter program to check
     }
     $doc = GlobalFunc::loadHTML($over_page);
     //get body
     //$body = $doc->getElementsByTagName('body')->item(0);
     //get attack alert dom
     $attack_alert_dom = $doc->getElementById('attack_alert');
     if (!is_object($attack_alert_dom)) {
         echo "Error occur, Attack Alert not found. return 1.\n";
         return 1;
     }
     if ($attack_alert_dom->hasAttribute('class')) {
         $attack_alert_class = $attack_alert_dom->getAttribute('class');
         //目前沒有人攻擊
         if (strstr($attack_alert_class, "noAttack")) {
             $isAttacked = false;
         } else {
             $isAttacked = true;
         }
     }
     return $isAttacked;
 }
예제 #16
0
 /**
  * 获取子目录的名称
  * @param file $file
  * @return string
  */
 private function getSubName($file)
 {
     switch ($this->subType) {
         case 'date':
             $dir = date($this->dateFormat, time());
             break;
         case 'hash':
         default:
             $dir = md5($file['name']);
             break;
     }
     if (!is_dir($file['savepath'] . $dir)) {
         GlobalFunc::mk_dir($file['savepath'] . $dir);
     }
     return $dir;
 }
예제 #17
0
 $db = GlobalFunc::connect_db($mysql_ini);
 if (!$db) {
     $lasterror[] = $language['fail_db'];
 }
 if (!$lasterror) {
     if ('group_list' === $_POST['act']) {
         $group_list[23]['name'] = '我的群,啦啦啦';
         $group_list[23]['online'] = '12/100';
         include $template->getfile('group_list.htm');
         exit;
     } elseif ('client_panel' === $_POST['act']) {
         $clientId = intval($_POST['cid']);
         $new_alias = $_POST['new_alias'];
         if ($clientId) {
             if ($new_alias) {
                 $dummy_id = GlobalFunc::get_dummy_from_cid($uid, $clientId, $db, $mysql_ini);
                 if ($dummy_id) {
                     $query = 'update ' . $mysql_ini['prefix'] . 'dummy set alias=? where dummy=' . $dummy_id . ' limit 1';
                     $stmt = $db->prepare($query);
                     $stmt->bind_param("s", $new_alias);
                     $stmt->execute();
                     if ($stmt->affected_rows) {
                         $lastsuccess[] = $language['success_set_alias'];
                     } else {
                         $lasterror[] = $language['fail_set_alias'];
                     }
                     $stmt->close();
                 } else {
                     $lasterror[] = $language['fail_set_alias'];
                 }
             }
예제 #18
0
 /**
  * 等待应答
  *
  * @param  integer $timeout   请求超时时间(毫秒)
  * @param  boolean $autofetch 是否自动获取结果
  * @param  boolean $keep      是否保留结果
  * @return integer            未收到应答的请求数
  */
 public function wait_for_replies($timeout = -1, $autofetch = TRUE, $keep = FALSE)
 {
     //页面清除cache
     //是否开启页面清除cache
     $open_clear_page_cache = APF::get_instance()->get_config('open_clear_page_cache');
     //要接受的getkey
     $clear_page_cache_key = APF::get_instance()->get_config('clear_page_cache_key');
     //要接受的getval
     $clear_page_cache_val = APF::get_instance()->get_config('clear_page_cache_val');
     if ($open_clear_page_cache) {
         //如果接受设定的get方法中有值不为空,则清空当前cache
         if (APF::get_instance()->get_request()) {
             $isclearcache = APF::get_instance()->get_request()->get_parameter($clear_page_cache_key);
             if ($isclearcache == $clear_page_cache_val) {
                 apf_require_class('GlobalFunc');
                 //判断ip段
                 if (GlobalFunc::is_allow_debug()) {
                     $timeout = -1;
                 }
             }
         }
     }
     try {
         if (APS::get_instance()->get_zmq_enabled()) {
             $poll = new ZMQPoll();
             //            foreach (self::$sockets as $socket) {
             //                $poll->add($socket, ZMQ::POLL_IN);
             //            }
             $poll->add($this->socket, ZMQ::POLL_IN);
             $start = APS_Functions::aps_millitime();
             $pending = count($this->requests);
             $readable = $writeable = array();
             while ($pending > 0 && $timeout > 0) {
                 $events = $poll->poll($readable, $writeable, $timeout);
                 if ($events == 0) {
                     break;
                 }
                 foreach ($readable as $socket) {
                     $this->process_reply($socket);
                     --$pending;
                 }
                 $millitime = APS_Functions::aps_millitime();
                 $timeout -= $millitime - $start;
                 if ($timeout <= 0) {
                     break;
                 }
                 $start = $millitime;
             }
         }
         if ($autofetch) {
             $this->fetch_all_replies($keep);
             $pending = 0;
         }
     } catch (Exception $e) {
         error_log(print_r('Caught exception: ' . $e->getMessage() . "\n", 1), 3, '/tmp/replaceWords.log');
     }
     return $pending;
 }
예제 #19
0
?>
" style="width: 192px;height: 256px;" class="img-responsive" alt="<?php 
echo $row['name'];
?>
">
            <div>
                <a href="<?php 
echo $this->img . $row['l_url'];
?>
"
                   class="btn btn-default fancybox-button">大图</a>
                <a href="/product/detail?&id=<?php 
echo $row['product_id'];
?>
" data-fancybox-type="ajax" class="btn btn-default fancybox-fast-view">预览</a>
            </div>
        </div>
        <h3><a href="/product.html?id=<?php 
echo $row['product_id'];
?>
" target="_blank"><?php 
echo GlobalFunc::globalSubstr($row['name'], 10);
?>
</a></h3>
        <div class="pi-price">¥<?php 
echo $row['price'];
?>
</div>
        <a href="#" class="btn btn-default add2cart">加入购物车</a>
    </div>
</li>
예제 #20
0
 public static function KeepAlive()
 {
     global $srv_block_ini;
     global $mysql_ini;
     global $clientId;
     global $mac_num;
     global $stream_path;
     //global $client_pipe_prefix;
     $fifo_file = $stream_path . self::$_client_pipe_prefix . "{$clientId}";
     $mac_record_cleared = false;
     $active_offline = false;
     // Drone 主动下线
     if (file_exists($fifo_file)) {
         unlink($fifo_file);
     }
     $success = posix_mkfifo($fifo_file, 0700);
     if (!$success) {
         GlobalFunc::errorlog('Error: Could not create a named pipe: ' . posix_strerror(posix_errno()));
     } else {
         $pipe = @fopen($fifo_file, 'r+b');
         if ($pipe) {
             stream_set_blocking($pipe, false);
             $off_line = false;
             while (1) {
                 $read = array($pipe);
                 $write = NULL;
                 $except = NULL;
                 if (false === ($num_changed_streams = stream_select($read, $write, $except, $srv_block_ini['breath_delay']))) {
                     break;
                 } elseif ($num_changed_streams > 0) {
                     while (1) {
                         $a = fread($pipe, 1);
                         if (0 == strlen($a)) {
                             break;
                         } else {
                             echo "{$a}";
                         }
                     }
                     ob_flush();
                     flush();
                 } else {
                     if ($off_line) {
                         break;
                     } else {
                         echo "";
                         ob_flush();
                         flush();
                     }
                 }
                 if ($active_offline or !$off_line and 0 != connection_status()) {
                     $off_line = true;
                     $db = GlobalFunc::connect_db($mysql_ini);
                     if ($db) {
                         $query = 'delete from ' . $mysql_ini['prefix'] . "online_mac where cid={$clientId} limit {$mac_num}";
                         $db->query($query);
                         $mac_record_cleared = true;
                         $query = 'update ' . $mysql_ini['prefix'] . "online_clients set status=0 where cid={$clientId} limit 1";
                         $db->query($query);
                         $db->close();
                     }
                 } else {
                     //db.living
                     $c_time = time();
                     if ($c_time - $db_timer > $srv_block_ini['db_living']) {
                         $db_timer = $c_time;
                         $db = GlobalFunc::connect_db($mysql_ini);
                         if ($db) {
                             $query = "update " . $mysql_ini['prefix'] . "online_clients set lastliving = {$db_timer} where cid={$clientId} and status = 1 limit 1";
                             $db->query($query);
                             if (1 != $db->affected_rows) {
                                 GlobalFunc::errorlog('db.living update 失败 (namepipe),疑似Drone主动下线...cid:' . "{$clientId}", 2);
                                 $active_offline = true;
                             }
                             $db->close();
                         }
                     }
                 }
             }
             fclose($pipe);
         } else {
             GlobalFunc::errorlog('Error: fopen fifo_file : ' . $fifo_file);
         }
         $db = GlobalFunc::connect_db($mysql_ini);
         if ($db) {
             if (!$mac_record_cleared) {
                 $query = 'delete from ' . $mysql_ini['prefix'] . "online_mac where cid={$clientId} limit {$mac_num}";
                 $db->query($query);
             }
             $module_num = 0;
             $query = 'select mod_num from ' . $mysql_ini['prefix'] . "online_clients where cid={$clientId} limit 1";
             $result = $db->query($query);
             if (1 === mysqli_num_rows($result)) {
                 $result = $result->fetch_assoc();
                 $module_num = $result['mod_num'];
                 $module_num++;
                 // add sys remain mid Number
                 if ($module_num) {
                     $query = 'delete from ' . $mysql_ini['prefix'] . "online_module where cid={$clientId} limit {$module_num}";
                     $db->query($query);
                 }
             }
             $query = 'delete from ' . $mysql_ini['prefix'] . "online_clients where cid={$clientId} limit 1";
             $db->query($query);
             $db->close();
         }
         unlink($fifo_file);
     }
     GlobalFunc::errorlog('namepipe.keeplive 结束返回...cid:' . "{$clientId}", 2);
 }
예제 #21
0
 function extractSeesion($script)
 {
     $doc = GlobalFunc::loadHtml($script);
     //print_r($doc);
     $value = $doc->textContent;
     //print_r("Value: ".$value."\n\r");
     $s_key = "http://";
     $e_key = "'";
     $s_pos = strrpos($value, $s_key, 0);
     $e_pos = strrpos($value, $e_key, -1);
     $len = $e_pos - $s_pos;
     $location = substr($value, $s_pos, $len);
     //print_r("s_pos: ".$s_pos);
     //print_r("e_pos: ".$e_pos);
     //print_r("len: ".$len);
     //print_r("Location: ".$location);
     $session_s_key = "PHPSESSID=";
     $session_pos = strrpos($location, $session_s_key);
     $session = substr($location, $session_pos);
     //print_r("session: ".$session);
     return $session;
     //return $location;
 }
예제 #22
0
     $query = 'update ' . $mysql_ini['prefix'] . 'online_task set status = ' . $status . ' where tid=\'' . $tid . '\' and status=1 and cid=' . $cid . ' limit 1';
     $db->query($query);
     HYP_IPC::task_response($tid, $cid . ':' . $status, ':', "");
     //mylog($query);
 } else {
     $query = 'select chunk,status,size,module from ' . $mysql_ini['prefix'] . 'online_task where tid=\'' . $tid . '\' and cid=' . $cid . ' limit 1';
     $result = $db->query($query);
     if (1 === mysqli_num_rows($result)) {
         $result = $result->fetch_assoc();
         if ($result['chunk']) {
             //stream
             if (1 == $result['status'] or 2 == $result['status']) {
                 $data = @file_get_contents('php://input');
                 $c_size = strlen($data);
                 if ($c_size) {
                     $c_stream_file = GlobalFunc::get_stream_path($tid);
                     if ($c_size === file_put_contents($c_stream_file . $tid . '.DOWN.' . $result['chunk'], $data)) {
                         $query = 'update ' . $mysql_ini['prefix'] . 'online_task set status = 2,chunk=chunk+1';
                         if ($stream_size and 0 == $result['size']) {
                             //以控制端请求长度为准
                             $query .= ',size= ' . $stream_size;
                         }
                         $query .= ' where tid=\'' . $tid . '\' and cid=' . $cid . ' limit 1';
                         $db->query($query);
                         $ret = 1;
                     }
                 }
             }
         } else {
             //normal
             if (1 == $result['status']) {
예제 #23
0
$mac_num = count($mac);
if (!preg_match('/^[a-zA-Z0-9]{32}$/', $token) or !$mac_num or (!is_numeric($flag) or $flag <= 0 or $flag > 2147483647)) {
    repond_breath(1);
}
foreach ($mac as $a) {
    if (!preg_match('/^[a-fA-F0-9]{12}$/', $a)) {
        repond_breath(1);
    }
}
$module_num = 0;
$tmp = $module;
foreach ($tmp as $a) {
    if (!preg_match('/^[a-fA-F0-9]{32}$/', $a)) {
        repond_breath(1);
    } else {
        if (GlobalFunc::is_sys_module_id($a)) {
            unset($module[$a]);
            continue;
        }
    }
    $module_num++;
}
if (!$module_num) {
    repond_breath(1);
}
$query = 'select tid from ' . $mysql_ini['prefix'] . 'token where token = \'' . $token . '\' limit 1';
$result = $db->query($query);
if (1 === mysqli_num_rows($result)) {
    $result = $result->fetch_assoc();
    $tid = $result['tid'];
} else {
예제 #24
0
 $shortcuts_num = $result['shortcuts_num'];
 $same_mod_filter = array();
 $auto_hide_warning = false;
 $app_array_id = 0;
 if ($mod_num) {
     $query = 'select a.module,a.version,a.latest_version,a.root from ' . $mysql_ini['prefix'] . 'modules as a,' . $mysql_ini['prefix'] . 'online_module as b where b.cid=' . $clientId . ' and b.module = a.module limit ' . $mod_num;
     $result = $db->query($query);
     $i = mysqli_num_rows($result);
     if ($mod_num > $i) {
         $tmp = $mod_num - $i;
         $lastwarning[] = $tmp . $language['some_unsupport_mod'];
     }
     for (; $i > 0; $i--) {
         $tmp = $result->fetch_assoc();
         $mod_name_array = GlobalFunc::get_mod_name($tmp['module'], $language_choosed);
         $tmp['title'] = GlobalFunc::clip_str_width($mod_name_array['name']);
         $tmp['name'] = $mod_name_array['name'];
         if (isset($same_mod_filter[$tmp['root']])) {
             if ($same_mod_filter[$tmp['root']]['ver'] > $tmp['version']) {
                 $auto_hide_warning .= $tmp['name'] . ' ver.' . $tmp['version'] . ',';
                 continue;
             } else {
                 $auto_hide_warning .= $same_mod_filter[$tmp['root']]['name'] . ' ver.' . $same_mod_filter[$tmp['root']]['ver'] . ',';
                 unset($app_array[$same_mod_filter[$tmp['root']]['id']]);
             }
         }
         $same_mod_filter[$tmp['root']]['id'] = $app_array_id;
         $same_mod_filter[$tmp['root']]['ver'] = $tmp['version'];
         $same_mod_filter[$tmp['root']]['name'] = $tmp['name'];
         $app_array[$app_array_id] = $tmp;
         $app_array_id++;
예제 #25
0
     $lasterror[] = $language['login_fail_password'];
 }
 if (!$lasterror) {
     $md5_username = md5($hash_salt . "{$username}");
     $lasterror[] = $language['login_fail_password'];
     $query = 'select * from ' . $mysql_ini['prefix'] . 'members where username = \'' . $md5_username . '\' limit 1';
     $result = $db->query("{$query}");
     if (mysqli_num_rows($result) === 1) {
         $result = $result->fetch_assoc();
         $md5_password = md5("{$username}" . "{$hash_salt}" . "{$password}" . $result['reg_time']);
         if ($md5_password === $result['password']) {
             $query = 'update ' . $mysql_ini['prefix'] . 'members set lastact_time = null where uid = \'' . $result['uid'] . '\'limit 1';
             $db->query("{$query}");
             unset($lasterror);
             $result['uid'] = 999;
             GlobalFunc::set_member_session($result, $cookiepre, $username);
             include "./include/gc.inc.php";
             Header("Location:" . "./cpanel.php");
             exit;
         }
     }
 }
 if ($lasterror) {
     $fail_login_time++;
     if ($fail_login_time == 1) {
         $query = 'insert into ' . $mysql_ini['prefix'] . 'spam_members values (\'' . $userIP . '\',1,' . $currenTime . ')';
     } else {
         if ($fail_login_time >= 3) {
             $fail_login_time = 3;
             $is_need_seccode = true;
         }
예제 #26
0
 public static function getOGameServerTime($overview_str)
 {
     //若找不到的話 回傳值會是0
     $overview_dom = GlobalFunc::loadHTML($overview_str);
     $div_dom = $overview_dom->getElementById("bar");
     if (!is_object($div_dom)) {
         echo "\nGlobalFunc::getOGameServerTime(): error, ogame_clock not found!!\n";
         return false;
     }
     $li_doms = $div_dom->getELementsByTagName('li');
     $li_doms_len = $li_doms->length;
     $ogame_clock = 0;
     for ($liIdx = 0; $liIdx < $li_doms_len; $liIdx++) {
         $li_dom = $li_doms->item($liIdx);
         $class_text = "";
         $li_dom_class = $li_dom->attributes->getNamedItem('class');
         // to avoid notice message
         if (isset($li_dom_class)) {
             $class_text = $li_dom_class->nodeValue;
         }
         if ($class_text == "OGameClock") {
             $span_dom = $li_dom->getELementsByTagName('span')->item(0);
             $ogame_clock = $span_dom->textContent;
             break;
         }
     }
     return $ogame_clock;
 }
예제 #27
0
function get_all_module_array($db)
{
    global $mysql_ini;
    global $repo_path;
    global $language_choosed;
    $ret = array();
    $query = "select module,root,version,latest_version from " . $mysql_ini['prefix'] . "modules";
    $result = $db->query($query);
    $i = mysqli_num_rows($result);
    for (; $i > 0; $i--) {
        $tmp = $result->fetch_assoc();
        $root = $tmp['root'];
        $mid = $tmp['module'];
        $ver = $tmp['version'];
        $ret['index'][$root][$ver] = $mid;
        $ret['latest_version'][$root] = $tmp['latest_version'];
        $ret['content'][$mid]['root'] = $root;
        $ret['content'][$mid]['version'] = $ver;
        $a = GlobalFunc::get_mod_name($mid, $language_choosed);
        $ret['content'][$mid]['name'] = $a['name'];
    }
    return $ret;
}
예제 #28
0
 $db = GlobalFunc::connect_db($mysql_ini);
 if (!$db) {
     $lasterror[] = $language['fail_db'];
 } else {
     if (false !== $sid) {
         $query = 'select a.data from ' . $mysql_ini['prefix'] . 'shortcuts as a left join ' . $mysql_ini['prefix'] . 'dummy as b on b.dummy = a.dummy where a.sid=' . $sid . ' limit 1';
         $result = $db->query($query);
         if (1 == mysqli_num_rows($result)) {
             $result = $result->fetch_assoc();
             $data = $result['data'];
         } else {
             $lasterror[] = $language['invalid_sid'];
         }
     }
     if (!$lasterror) {
         $dummy = GlobalFunc::get_dummy_from_cid($uid, $cid, $db, $mysql_ini);
         if (false === $dummy) {
             $lasterror[] = $language['client_off_line'];
         }
     }
     if (!$lasterror) {
         $query = 'insert into ' . $mysql_ini['prefix'] . 'shortcuts values (NULL,?,0,?,?,?,NULL)';
         $stmt = $db->prepare($query);
         $stmt->bind_param('isss', $dummy, $shortcut_name, $mid, $data);
         if ($stmt->execute()) {
             $query = 'update ' . $mysql_ini['prefix'] . 'dummy set shortcuts_num = shortcuts_num + 1 where dummy = ' . $dummy . ' limit 1';
             $db->query($query);
         } else {
             $lasterror[] = $language['insert_db_fail'];
         }
     }
예제 #29
0
 private static function batch_mysql_query($qHead, $key, $array, $db, $maxSize = 1024)
 {
     $ret = true;
     $sub = $array;
     while (!empty($sub)) {
         $units = 0;
         $remain = $sub;
         $c_len = $maxSize;
         $query = '';
         foreach ($array as $a) {
             $q = "{$key}" . '=' . $a . ' or ';
             $b = strlen($q);
             if ($c_len > $b) {
                 $c_len -= $b;
                 $query .= $q;
                 unset($sub[$a]);
                 $units++;
             } else {
                 break;
             }
         }
         $query = substr($query, 0, strlen($query) - 4);
         $query = $qHead . $query . ') limit ' . $units;
         if (!$db->query($query)) {
             $ret = false;
             GlobalFunc::errorlog("[batch_mysql_query fail]" . $query);
         }
     }
     return $ret;
 }
예제 #30
0
 /**
  * 购物车商品列表
  */
 public function CartGoodsCache($goods_list)
 {
     if (!$goods_list) {
         return array();
     }
     $goods_list_new = array();
     foreach ($goods_list as $v) {
         $goods_list_new[$v['product_id']] = $v;
         $product_ids[] = $v['product_id'];
         $goods_ids[] = $v['goods_id'];
     }
     if (!isset($product_ids) || isset($product_ids) && !$product_ids) {
         return false;
     }
     $product_ids = implode(',', $product_ids);
     $goods_ids = implode(',', $goods_ids);
     $result = array();
     if ($product_ids) {
         $product_sql = "SELECT * FROM {{b2c_products}} WHERE product_id IN ({$product_ids})";
         $product_list = GlobalFunc::ArrayListByKey($this->ModelQueryAll($product_sql), 'product_id');
         $image_list = $this->GoodsDefaultImage($goods_ids);
         foreach ($goods_list_new as $v) {
             if (!isset($product_list[$v['product_id']])) {
                 continue;
             }
             $item = $v;
             $item['product_name'] = $product_list[$v['product_id']]['name'];
             $item['price'] = isset($promotion_pro[$v['product_id']]) && $promotion_pro[$v['product_id']] ? $promotion_pro[$v['product_id']] : sprintf('%.2f', $product_list[$v['product_id']]['price']);
             $item['mktprice'] = sprintf('%.2f', $product_list[$v['product_id']]['mktprice']);
             $spec = str_replace(array(' ', '、'), ' ', $product_list[$v['product_id']]['spec_info']);
             $item['spec'] = explode(' ', $spec);
             if (isset($image_list[$v['goods_id']])) {
                 $item['image'] = $image_list[$v['goods_id']]['s_url'];
             } else {
                 $item['image'] = '';
             }
             $result['item'][] = $item;
         }
     }
     return $result;
 }