|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
学习如何将PHP与HTML结合起来完成简单动态页面查询体系 <LI class=content id=pre_1152190392>头几天做了个大学英语四六级成就查询体系,一个 phprpc 版本,一个 wap 版本。它们的中心代码都是不异的。上面就是从 etang.cet 获得大学英语四六级成就的中心代码:
下载: cetquery.php<LI class=hl-firstline>function query($examid, $examtype) {
- $examid = trim($examid);
- $examtype = trim($examtype);
- if (!is_numeric($examid)) {
- return '准考据号码必需是数字';
- }
- if (strlen($examid) != 15) {
- return '准考据号码不准确';
- }
- if ($examtype == '1') {
- if ((substr($examid, 6, 4) != '0521') &&
- (substr($examid, 6, 4) != '1052')) {
- return '准考据号码与测验类型不符';
- }
- }
- if ($examtype == '2') {
- if ((substr($examid, 6, 4) != '0512') &&
- (substr($examid, 6, 4) != '0522') &&
- (substr($examid, 6, 4) != '2052')) {
- return '准考据号码与测验类型不符';
- }
- }
- $examid1 = substr($examid, 0, 6) . $examtype . '052' . substr($examid, 10, 5);
- $request = "examtype=$examtype&examid=$examid&image.x=23&image.y=32";
- $content_len = strlen($request);
- $handle = @fsockopen('cet.etang.com', 80, $errno, $errstr, 10);
- $buf = '';
- $id = base_convert(mt_rand().mt_rand(), 10, 36);
- if ($handle) {
- $http_request =
- "POST /dog/cet HTTP/1.0\r\n" .
- "Accept: */*\r\n" .
- "Referer: http://cet.etang.com/cet_girldemand_$id.htm\r\n" .
- "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Alexa Toolbar)\r\n" .
- "Host: cet.etang.com\r\n" .
- "Content-Type: application/x-www-form-urlencoded\r\n" .
- "Content-Length: $content_len\r\n" .
- "Cache-Control: no-cache\r\n" .
- "Cookie: zi=A; examid1=$examid; examtype1=$examtype; sex=girl; examid=$examid1; examtype=$examtype\r\n" .
- "\r\n" .
- $request;
- fputs($handle, $http_request, strlen($http_request));
- while (!feof($handle)) {
- $buf .= fgets($handle, 128);
- }
- fclose($handle);
- }
- else {
- return "查询办事器临时没法毗连";
- }
- $buf = explode("\r\n", $buf);
- $buf = $buf[11];
- $score = "";
- if (substr($buf, 0, 18) == 'Set-Cookie: score=') {
- $score = substr($buf, 18, strpos($buf, ';') - 18);
- }
- if (($score != '') and ($score != 'error')) {
- $score = explode(',', $score);
- }
- else {
- return '你所查询的准考据号码不存在';
- }
- return $score;
- }
熟悉HTML/CSS/JS等网页基本元素,完成阶段可自行制作完整的网页,对元素属性达到熟悉程度 |
|