function server_query_frontlines($ip, $port, $q_port, $request) { global $server_timeout; $q_port = empty($q_port) ? 5478 : $q_port; @set_time_limit(2); $fp = @fsockopen("udp://" . $ip, $q_port, $errno, $errstr, $server_timeout); if ($request == "players") { fwrite($fp, "ÿÿÿÿW"); $challenge_packet = fread($fp, 4096); if (!$challenge_packet) { return FALSE; } $challenge_code = substr($challenge_packet, 5, 4); } if ($request == "players") { fwrite($fp, "ÿÿÿÿU{$challenge_code}"); } else { fwrite($fp, "ÿÿÿÿFLSQ"); } $buffer = fread($fp, 4096); if (!$buffer) { return FALSE; } if ($request == "info") { $buffer = substr($buffer, 6); // REMOVE PACKET HEADER $data['hostname'] = cut_string($buffer); $data['mapname'] = cut_string($buffer); $data['gamemod'] = strtolower(cut_string($buffer)); $data['gametype'] = cut_string($buffer); $data['players'] = _unpack(cut_byte($buffer, 1), "C"); $data['maxplayers'] = _unpack(cut_byte($buffer, 1), "C"); return $data; } if ($request == "players") { $buffer = substr($buffer, 4); // REMOVE PACKET HEADER $response_type = cut_byte($buffer, 1); $returned = ord(cut_byte($buffer, 1)); $player = array(); $player_key = 0; while ($buffer) { $player[$player_key]['pid'] = ord(cut_byte($buffer, 1)); $player[$player_key]['name'] = cut_string($buffer); $player[$player_key]['score'] = _unpack(cut_byte($buffer, 4), "N"); $player[$player_key]['time'] = _time(_unpack(strrev(cut_byte($buffer, 4)), "f")); $player[$player_key]['ping'] = _unpack(cut_byte($buffer, 2), "n"); $player[$player_key]['uid'] = _unpack(cut_byte($buffer, 4), "N"); $player[$player_key]['team'] = ord(cut_byte($buffer, 1)); $player_key++; } $player = array_reverse($player); return $player; } }
function server_query_halflife2($ip, $port, $q_port, $request) { global $server_timeout; $q_port = empty($q_port) ? $port : $q_port; $fp = @fsockopen("udp://{$ip}", $port, $errno, $errstr, $server_timeout); if (!$fp) { return FALSE; } stream_set_timeout($fp, 1, 0); stream_set_blocking($fp, true); if ($request == "players") { fwrite($fp, "ÿÿÿÿU"); $tmp = fread($fp, 4096); if (!$tmp) { fclose($fp); return FALSE; } $challengenumber = substr($tmp, 5, 4); } if ($request == "info") { $challenge = "ÿÿÿÿTSource Engine Query"; } if ($request == "players") { $challenge = "ÿÿÿÿU" . $challengenumber; } fwrite($fp, $challenge); $buffer = fread($fp, 4096); fclose($fp); $buffer = trim(substr($buffer, 4)); if (!trim($buffer)) { return FALSE; } if ($request == "info") { $tmp = substr($buffer, 2); $tmp = explode("", $tmp); $place = strlen($tmp[0] . $tmp[1] . $tmp[2] . $tmp[3]) + 8; $data['gamemod'] = $tmp[2]; $data['hostname'] = $tmp[0]; $data['mapname'] = $tmp[1]; $data['players'] = ord($buffer[$place]); $data['maxplayers'] = ord($buffer[$place + 1]); $data['password'] = ord($buffer[$place + 5]); $data['datatype'] = $buffer[0]; $data['version'] = ord($buffer[1]); $data['description'] = $tmp[3]; $data['botplayers'] = ord($buffer[$place + 2]); $data['server_type'] = $buffer[$place + 3]; $data['server_os'] = $buffer[$place + 4]; $data['server_bots'] = ord($buffer[$place + 2]); $data['server_secure'] = ord($buffer[$place + 6]); return $data; } if ($request == "players") { unset($player_key); $buffer = substr($buffer, 2); $player_key = 0; while ($buffer) { $player[$player_key]['id'] = ord(cut_byte($buffer, 1)); $player[$player_key]['name'] = cut_string($buffer); $player[$player_key]['score'] = @_unpack(cut_byte($buffer, 4), "l"); $player[$player_key]['time'] = _time(@_unpack(cut_byte($buffer, 4), "f")); $player_key++; } return $player; } }
function printSQLResult($result, $dataType = "json", $params = array(), $msg = "", $autoLing = true, $maxTextLength = 0) { if ($result == null || is_bool($result)) { $responce->MSG = $msg; header("Content-type: application/json"); echo json_encode($responce); return; } if ($dataType == "json") { if (isset($params["page"])) { $responce->page = intval($params["page"]); } if (isset($params["total"])) { $responce->total = intval($params["total"]); } if (isset($params["records"])) { $responce->records = intval($params["records"]); } //if(isset($params["limit"])) $responce->limit =intval($params["limit"]); $i = 0; //while($row = mysql_fetch_array($result,MYSQL_NUM)) {//MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH mysql_fetch_array while ($row = _db()->fetchData($result, "array", MYSQL_NUM)) { //MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH $responce->rows[$i]['id'] = $row[0]; $responce->rows[$i]['cell'] = array(); $c = 0; foreach ($row as $a => $b) { //if(is_numeric($a)) continue; if :: MYSQL_BOTH $type = mysql_field_type($result, $c); if (strlen($b) > 0) { if ($type == "date") { $df = str_replace("yy", "Y", getConfig("DATE_FORMAT")); $b = _date($b, "Y/m/d", $df); $bT = _date("0000-00-00", "Y/m/d", $df); if ($b == $bT) { $b = ""; } } elseif ($type == "time") { $dt = str_replace("m", "i", getConfig("TIME_FORMAT")); $b = _time($b); $bT = _time("00:00:00", "H:i:s", $dt); if ($b == $bT) { $b = ""; } } elseif ($type == "datetime") { $df = str_replace("yy", "Y", getConfig("DATE_FORMAT")); $dt = str_replace("m", "i", getConfig("TIME_FORMAT")); $ss = explode(" ", $b); $s0 = _date($ss[0], "Y/m/d", $df); if (isset($ss[1])) { $s1 = _time($ss[1]); } else { $s1 = ""; } $b = "{$s0} {$s1}"; $bT = _date("0000-00-00", "Y/m/d", $df); $bT .= " " . _time("00:00:00", "H:i:s", $dt); if ($b == $bT) { $b = ""; } } elseif ($type == "blob") { if ($maxTextLength > 0 && strlen($b) > $maxTextLength) { $b = substr($b, 0, 200) . "..."; } else { $b = stripslashes($b); } $b = htmlentities($b); //str_replace('"',"\\'",$b)); } else { if ($autoLing) { $b = _ling($b, true); } } } array_push($responce->rows[$i]['cell'], $b); $c++; } $i++; } $responce->MSG = $msg; header("Content-type: application/json"); echo json_encode($responce); } elseif ($dataType == "xml") { if (stristr($GLOBALS['LOGIKS']["_SERVER"]["HTTP_ACCEPT"], "application/xhtml+xml")) { header("Content-type: application/xhtml+xml;charset=utf-8"); } else { header("Content-type: text/xml;charset=utf-8"); } $et = ">"; $s = "<?xml version='1.0' encoding='utf-8'?{$et}\n"; $s .= "<rows>"; $s .= "<page>" . $page . "</page>"; $s .= "<total>" . $total_pages . "</total>"; $s .= "<records>" . $count . "</records>"; //while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { while ($row = _db()->fetchData($result)) { $s .= "<row id='" . $row[id] . "'>"; $i = 0; foreach ($row as $a => $b) { $type = mysql_field_type($result, $i); $length = mysql_field_len($result, $i); if ($type == "date") { if (strlen($b) > 0) { $df = str_replace("yy", "Y", getConfig("DATE_FORMAT")); $b = _date($b, "Y/m/d", $df); $bT = _date("0000-00-00", "Y/m/d", $df); if ($b == $bT) { $b = ""; } } if (strlen($b) > 0) { $s .= "<cell><![CDATA[" . $b . "]]></cell>"; } } elseif ($type == "string" && $length > 5) { if ($autoLing) { $b = _ling($b); } if (strlen($b) > 0) { $s .= "<cell><![CDATA[" . $b . "]]></cell>"; } else { $s .= "<cell></cell>"; } } else { if ($autoLing) { $b = _ling($b); } $s .= "<cell>" . $b . "</cell>"; } $i++; } $s .= "</row>"; } $s .= "</rows>"; echo $s; } elseif ($dataType == "html") { if (isset($params["withheader"])) { $withheader = $params["withheader"]; } else { $withheader = "false"; } if (isset($params["multiselect"])) { $multiselect = $params["multiselect"]; } else { $multiselect = "false"; } if ($withheader == "true" || $withheader == 1) { $withheader = true; } else { $withheader = false; } if ($multiselect == "true" || $multiselect == 1) { $multiselect = true; } else { $multiselect = false; } $header = ""; $body = ""; if ($withheader) { $header .= "<thead>"; $header .= "<tr class='tblheader'>"; if ($multiselect) { $header .= "<td width=40px> -- </td>"; } while ($i < mysql_num_fields($result)) { $meta = mysql_fetch_field($result, $i); if ($meta) { $t = str_replace("_", " ", $meta->name); $t = ucwords($t); $header .= "<td align=center>{$t}</td>"; } else { $header .= "<td> </td>"; } $i++; } $header .= "</tr>"; $header .= "</thead>"; } $body .= "<tbody>"; //while($row = mysql_fetch_array($result,MYSQL_NUM)) {//MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH while ($row = _db()->fetchData($result, "array", MYSQL_NUM)) { //MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH $body .= "<tr id='ROW_" . $row[0] . "'>"; if ($multiselect) { $body .= "<td align=center><input type='checkbox' rel='" . $row[0] . "' row='ROW_" . $row[0] . "' /></td>"; } $c = 0; foreach ($row as $a => $b) { $meta = mysql_fetch_field($result, $c); $type = $meta->type; $name = $meta->name; $tbl = $meta->table; if ($type == "date") { if (strlen($b) > 0) { $df = str_replace("yy", "Y", getConfig("DATE_FORMAT")); $b = _date($b, "Y/m/d", $df); $bT = _date("0000-00-00", "Y/m/d", $df); if ($b == $bT) { $b = ""; } } } elseif ($autoLing) { $b = _ling($b); } if ($meta->primary_key) { $body .= "<td col='{$name}' class='serial_col'>{$b}</td>"; } else { if ($type == "date") { if ($b == "NA") { $body .= "<td col='{$name}' class='calerroricon' > </td>"; } else { $body .= "<td col='{$name}' align=center>{$b}</td>"; } } elseif ($type == "int" || $type == "float" || $type == "double") { $body .= "<td col='{$name}' align=right>{$b}</td>"; } elseif ($type == "bool" || $type == "boolean") { $body .= "<td col='{$name}' align=center>{$b}</td>"; } elseif ($type == "blob") { $body .= "<td col='{$name}' class='blobicon' onclick=\"viewBlobData('{$name}','{$tbl}')\"> </td>"; } else { $body .= "<td col='{$name}'>{$b}</td>"; } } $c++; } $body .= "</tr>"; } $body .= "</tbody>"; echo "<table width=100%>{$header} {$body}</table>"; } else { printArray($data); } }
<?php /** *2012-8-22 By:NaV! */ //防止恶意调用 if (!defined('IN_GM')) { exit('Access Defined!'); } $end_time = _time(); ?> <div id="footer">执行耗时:<span><?php echo round($end_time - $start_time, 4); ?> </span>s<br>©安徽工业大学计算机学院</div> </div>
require ROOT_PATH . 'includes/mysql.func.php'; //数据库连接 define('DB_HOST', 'localhost'); //地址 define('DB_USER', 'root'); //用户名 define('DB_PWD', 'admin'); //密码 define('DB_NAME', 'gmanage'); //数据库名 //初始化数据库 _connect(); _select_db(); _set_names(); //执行耗时 $start_time = _time(); ////系统设置----若未调用该文件,需要把$_system数组申明为全局变量 //$_system=array(); ////网站标题 //$_system['webname'] = "计算机学院研究生档案管理"; ////是否开启注册,1开,0关 //$_system['register'] = 1; ////是否需要验证码,1要,0不要 //$_system['needcode'] = 0; ////登陆界面的提示信息 //$_system['help_login'] = "******"; ////user_date页面分页类型及每页数据数 //$_system['user_date_page']=2; //$_system['user_date_pagesize']=10; ////stu_active页面分页类型及每页数据数 //$_system['stu_active_page']=1;
<div class="comment_author"> <img src="face/face10.jpg"> <span> hua1995116 </span> </div> <div class="comment_d"> <div class="comment_top"> <?php echo $_html['content']; ?> </div> <div class="comment_bottom"> <div class="comment_bottom_left"> <?php _time($_html['time']); ?> </div> <div class="comment_bottom_right"> 回复 <span id="<?php echo $_zan; ?> "> <?php if (!!isset($_SESSION['email'])) { $_is_zan = _fetch_array("SELECT zan_user,comment_id FROM comment_zan WHERE zan_user='******'email']}' AND comment_id='{$_html['id']}' "); if ($_is_zan['zan_user'] == $_SESSION['email']) { ?> <img src="img/zan_yes.jpg"> <?php
function caption_times($t_start, $t_end) { return _time($t_start) . ' --> ' . _time($t_end); }
function _pDate($date = null, $outFormat = null) { if ($date == null || strlen($date) <= 0) { $date = ""; } //date("Y/m/d"); $date = explode(" ", $date); if (!isset($date[1])) { $date[1] = ""; } if ($outFormat == null) { return trim(_date($date[0], "Y/m/d", getConfig("DATE_FORMAT")) . " " . _time($date[1], "H:i:s", getConfig("TIME_FORMAT"))); } else { $outFormat = explode(" ", $outFormat); if (!isset($outFormat[1])) { $outFormat[1] = ""; } return trim(_date($date[0], "Y/m/d", $outFormat[0]) . " " . _time($date[1], "H:i:s", $outFormat[1])); } }
function getData($s, $type) { if (is_array($s)) { $s = implode(",", $s); } $s = urldecode($s); //$s=str_replace("'","`",$s); $s = mysql_real_escape_string($s); if ($type == "int" || $type == "float" || $type == "bool") { if (strlen($s) <= 0) { return "0"; } else { return "{$s}"; } } elseif ($type == "date") { $s = _date($s); return "'{$s}'"; } elseif ($type == "time") { $s = _time($s); return "'{$s}'"; } elseif ($type == "datetime") { $ss = explode(" ", $s); $s0 = _date($ss[0]); if (isset($ss[1])) { $s1 = _time($ss[1]); } else { $s1 = ""; } return "'{$s0} {$s1}'"; } else { return "'{$s}'"; } }