1. index.php
<?php include "inc/conn.php";?><?php include "inc/excel.php";?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<title><?php echo $title;?></title>
<script type="text/javascript" src="inc/js/ajax_wap.js"></script>
<link href="inc/css/wap.css" rel="stylesheet" type="text/css" />
<body onLoad="inst();">
<p class="sub_bod"></p>
<p class="sub_top">
<p class="title"><?php echo $title;?></p>
<p class="back" id="pageback"><a href="index.php" class="d">返回</a></p>
<!---<p class="menu" id="topmenus"><a href="admin/" class="d">后台</a></p>--->
</p><p class="main">
<?php
$stime=microtime(true);
$codes = trim($_POST['code']);
$shujus = trim($_POST['time']);
$shuru1 = trim($_POST['name']);
if(!$shujus){
?>
<form name="queryForm" method="post" class="" action="" onsubmit="return startRequest(0);">
<p class="select" id="10">
<select name="time" id="time" onBlur="startRequest(1)" />
<?php traverse($UpDir."/",$filephp);?></select>
</p>
<p class="so_box" id="11">
<input name="name" type="text" class="txts" id="name" value="" onfocus="this.value=''" onBlur="startRequest(2)" />
</p>
<p class="so_box" id="33">
<input name="code" type="text" class="txts" id="code" onfocus="this.value=''" onBlur="startRequest(3)" />
<p class="more" id="clearkey">
<img src="inc/code.php?t=<?php echo date("Y-m-d-H-i-s",time());? alt="php+excel通用成绩查询系统 手机网页sae版" >" id="Codes" onClick="this.src='inc/code.php?t='+new Date();"/>
</p></p>
<p class="so_boxes">
<input type="submit" name="button" class="buts" id="sub" value="立即查询" />
</p>
<p class="so_boxed" id="tishi">说明:【<?php echo $tiaojian1;?>+验证码】都输入正确才显示相应结果。</p>
<p id="tishi1" style="display:none;">请认真输入你的<?php echo $tiaojian1;?></p>
<p id="tishi4" style="display:none;">认真输入4数字验证码</p>
</form>
<?php
}else{
session_start();
if($codes!=$_SESSION['PHP_M2T']){
webalert("请正确输入验证码!");
}
if(!$shuru1){
webalert("请输入$tiaojian1!");
}
$files = charaget($UpDir."/".$shujus.$filephp);
if(!file_exists($files)){
webalert('请检查数据库文件');
}else{
echo '<p align="center"> ';
echo $shujus;
echo '</p>';
}
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('UTF-8');
$data->read($files);
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
if($i=="1"){
$iaa="";
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
$taba = ''.$data->sheets[0]['cells'][$i][$j].'';
$io++;
if($taba==$tiaojian1){
$iaa=$io-1;
}
}
}else{
$Excelx=$data->sheets[0]['cells'][$i][$iaa+1];
if("_".$shuru1=="_".$Excelx){
$iae++;
echo '<!--startprint--><table cellspacing="0">';
echo '<caption align="center">查询结果' . $iae . '</caption>';
echo '';
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
$tabe = ''.$data->sheets[0]['cells']['1'][$j].'';
$tabu = ''.$data->sheets[0]['cells'][$i][$j].'';
echo '<tr>';
echo '<td class="r">'.$tabe.'</td>';
echo '<td class="span">'.$tabu.'</td>';
echo '</tr>';
}
echo '';
echo '</table>';
}
}
}
if($iae<1){
echo '<table cellspacing="0"><tr>';
echo "<td colspan=2>没有查询到 $shujus 中 $shuru1 相关信息哦</td>";
echo '</tr></table>';
}
echo '<!--endprint-->';
fclose($filer);
?><p class="so_boxes"><input type="button" value="返 回" class="buts" onclick="location.href='index.php';" id="reset"></p>
<?PHP
}
$etime=microtime(true);//获取程序执行结束的时间
$total=$etime-$stime; //计算差值
echo "<!----页面执行时间:{$total} ]秒--->";
?></p>
<p class="foot">
<p class="title">
<span>©<?php echo date('Y');?> <a href="http://aiyaha.taobao.com/" target="_blank">技术支持</a> <a href="<?php echo $copyu;?>" target="_blank"><?php echo $copyr;?></a></span>
</p>
</p>
</body>
</html>2. conn.php
<?php
error_reporting(0);
header("content-Type: text/html; charset=UTF-8"); //输出编码GBK
//设置好以下三项查询条件,得都输入
$tiaojian1="姓名"; //查询条件1列标题,跟excel列头一致,注意无空格;
$UpDir="shujukufangzheli"; //设置数据库所在目录(文件夹名称)请修改,修改后更名对应文件夹。
$title="某某中学成绩查询系统"; //设置查询标题,相信你懂的。
$copyr="某某中学"; //设置底部版权文字,相信你懂的。
$copyu="http://www.96448.cn/"; //设置底部版权连接,相信你懂的。
/*
// 「SAE」免费注册地址:http://t.cn/R4QorPE (免费空间,免费二级域名,免备案)
// *************************
// 作者主页:http://12391.net
// 作者邮箱:admin@ewuyi.net
// 作者网店:https://aiyaha.taobao.com/
// 本店宝贝导航
// 成绩工资水电费通用查询系统解决方案:
// 方案3(荐):微信公众号一对一绑定才可以查询工资、成绩、水电费等
// 自助开通试用:http://add.96cha.com/
// 代码购买:https://item.taobao.com/item.htm?id=44248394675
// 整体服务:https://item.taobao.com/item.htm?id=528187132312
// 方案2(荐):用户在线登录查询工资成绩水电费等,可自助修改密码
// 自助开通试用:http://add.dbcha.com/
// 代码购买:https://item.taobao.com/item.htm?id=43193387085
// 整体服务:https://item.taobao.com/item.htm?id=528108807297
// 方案1:直接通过设定的(1-3个)查询条件查询
// 自助开通试用:http://add.12391.net/ (免费)
// 代码购买:https://item.taobao.com/item.htm?id=528692002051
// 整体服务:https://item.taobao.com/item.htm?id=520023732507
// 成绩工资水电费通用查询系统其他方案:
// asp无需后台版(12款): https://item.taobao.com/item.htm?id=45703415332
// PHP无需后台版(12款):https://item.taobao.com/item.htm?id=45808268273
// PHP多级下拉版(8款):https://item.taobao.com/item.htm?id=43263796985
// 公众号回复简易版: https://item.taobao.com/item.htm?id=520496908275
// 公众号回复后台简易版即时开通体验: http://new.12391.net
// 模糊查询系统解决方案(超过8款):
// https://item.taobao.com/item.htm?id=520167788658
// 网店发货查询系统后台导入通用版网页版加微信自动回复机器人查询
// 即时开通试用:http://add.mabida.cn:1111/
// 整体服务:https://item.taobao.com/item.htm?id=528166721835
// 源码购买:https://item.taobao.com/item.htm?id=44194950836
// 农产品质量溯源查询系统 二维码防伪查询微信防伪查询
// 即时开通试用:http://add.mabida.cn/
// 整体服务:https://item.taobao.com/item.htm?id=43525422046
// 源码购买:https://item.taobao.com/item.htm?id=43525422046
// #####以上无需修改但有用注意查看哦######
*/
$filephp=".xls"; //数据库文件后缀不要修改
function charaget($data){
if(!empty($data) ){
$fileType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5')) ;
if( $fileType != 'UTF-8'){
$data = mb_convert_encoding($data ,'utf-8' , $fileType);
}
}
return $data;
}
// 方案1:直接通过设定的(1-3个)查询条件查询
// 自助开通试用:http://add.12391.net/
// 代码购买:https://item.taobao.com/item.htm?id=528692002051
// 整体服务:https://item.taobao.com/item.htm?id=520023732507
function characet($data){
if(!empty($data) ){
$fileType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5')) ;
if( $fileType != 'GBK'){
$data = mb_convert_encoding($data ,'GBK' , $fileType);
}
}
return $data;
}
function webalert($Key){
$html="<script>
";
$html.="alert('".$Key."');
";
$html.="history.go(-1);
";
$html.="</script>";
exit($html);
}
function traverse($path = '.',$filephp) {
$current_dir = opendir($path); //opendir()返回一个目录句柄,失败返回false
while(($file = readdir($current_dir)) !== false) { //readdir()返回打开目录句柄中的一个条目
$sub_dir = $path . DIRECTORY_SEPARATOR . $file; //构建子目录路径
if($file == '.' || $file == '..') {
//continue;
} else if(is_dir($sub_dir)) { //如果是目录,进行递归
//echo 'Directory ' . $file . ':<br>';
//traverse($sub_dir);
} else { //如果是文件,直接输出
// echo 'File in Directory ' . $path . ': ' . $file . '<br>';
$file = str_replace($filephp,"",$file); //文件名除了后缀,不要包含.php
echo '<option value="'.charaget($file).'">' . charaget($file) . '</option>';
}
}
}
function fileline1($path = '.') {
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('UTF-8');
$data->read($path);
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
$str .= ''.$data->sheets[0]['cells']['1'][$j].'';
}
$str = iconv('UTF-8', 'GB2312', $str);
return $str;
}
function get_file_line( $file_name, $line ){
$n = 0;
$handle = fopen($file_name,'r');
if ($handle) {
while (!feof($handle)) {
++$n;
$out = fgets($handle, 4096);
if($line==$n) break;
}
fclose($handle);
}
if( $line==$n) return $out;
return false;
}
?>3. excel.php
Shop7z网上购物系统支持电脑版+手机版+支付宝及微信支付,支持QQ和微信一键登陆,系统集众家之所长,大气超美观页面+手机版+商品组合套餐+限时抢购秒杀+图片批量上传+淘宝数据包导入+弹出式分类菜单+不同规格不同价格+新订单邮件通知+销售报表打印与Excel输出+物流跟踪打印查询+会员积分及优惠券+邮件群发+图片在线管理+销售统计报表+五种价格体系+礼品礼券+微信公众号支付+扫码支付等等等。
2
<?php
define('NUM_BIG_BLOCK_DEPOT_BLOCKS_POS', 0x2c);
define('SMALL_BLOCK_DEPOT_BLOCK_POS', 0x3c);
define('ROOT_START_BLOCK_POS', 0x30);
define('BIG_BLOCK_SIZE', 0x200);
define('SMALL_BLOCK_SIZE', 0x40);
define('EXTENSION_BLOCK_POS', 0x44);
define('NUM_EXTENSION_BLOCK_POS', 0x48);
define('PROPERTY_STORAGE_BLOCK_SIZE', 0x80);
define('BIG_BLOCK_DEPOT_BLOCKS_POS', 0x4c);
define('SMALL_BLOCK_THRESHOLD', 0x1000);
// property storage offsets
define('SIZE_OF_NAME_POS', 0x40);
define('TYPE_POS', 0x42);
define('START_BLOCK_POS', 0x74);
define('SIZE_POS', 0x78);
define('IDENTIFIER_OLE', pack("CCCCCCCC",0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1));
function GetInt4d($data, $pos) {
$value = ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24);
if ($value>=4294967294) {
$value=-2;
}
return $value;
}
function gmgetdate($ts = null){
$k = array('seconds','minutes','hours','mday','wday','mon','year','yday','weekday','month',0);
return(array_comb($k,split(":",gmdate('s:i:G:j:w:n:Y:z:l:F:U',is_null($ts)?time():$ts))));
}
// Added for PHP4 compatibility
function array_comb($array1, $array2) {
$out = array();
foreach ($array1 as $key => $value) {
$out[$value] = $array2[$key];
}
return $out;
}
function v($data,$pos) {
return ord($data[$pos]) | ord($data[$pos+1])<<8;
}
class OLERead {
var $data = '';
function OLERead(){ }
function read($sFileName){
// check if file exist and is readable (Darko Miljanovic)
if(!is_readable($sFileName)) {
$this->error = 1;
return false;
}
$this->data = @file_get_contents($sFileName);
if (!$this->data) {
$this->error = 1;
return false;
}
if (substr($this->data, 0, 8) != IDENTIFIER_OLE) {
$this->error = 1;
return false;
}
$this->numBigBlockDepotBlocks = GetInt4d($this->data, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS);
$this->sbdStartBlock = GetInt4d($this->data, SMALL_BLOCK_DEPOT_BLOCK_POS);
$this->rootStartBlock = GetInt4d($this->data, ROOT_START_BLOCK_POS);
$this->extensionBlock = GetInt4d($this->data, EXTENSION_BLOCK_POS);
$this->numExtensionBlocks = GetInt4d($this->data, NUM_EXTENSION_BLOCK_POS);
$bigBlockDepotBlocks = array();
$pos = BIG_BLOCK_DEPOT_BLOCKS_POS;
$bbdBlocks = $this->numBigBlockDepotBlocks;
if ($this->numExtensionBlocks != 0) {
$bbdBlocks = (BIG_BLOCK_SIZE - BIG_BLOCK_DEPOT_BLOCKS_POS)/4;
}
for ($i = 0; $i < $bbdBlocks; $i++) {
$bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
$pos += 4;
}
for ($j = 0; $j < $this->numExtensionBlocks; $j++) {
$pos = ($this->extensionBlock + 1) * BIG_BLOCK_SIZE;
$blocksToRead = min($this->numBigBlockDepotBlocks - $bbdBlocks, BIG_BLOCK_SIZE / 4 - 1);
for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; $i++) {
$bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
$pos += 4;
}
$bbdBlocks += $blocksToRead;
if ($bbdBlocks < $this->numBigBlockDepotBlocks) {
$this->extensionBlock = GetInt4d($this->data, $pos);
}
}
// readBigBlockDepot
$pos = 0;
$index = 0;
$this->bigBlockChain = array();
for ($i = 0; $i < $this->numBigBlockDepotBlocks; $i++) {
$pos = ($bigBlockDepotBlocks[$i] + 1) * BIG_BLOCK_SIZE;
//echo "pos = $pos";
for ($j = 0 ; $j < BIG_BLOCK_SIZE / 4; $j++) {
$this->bigBlockChain[$index] = GetInt4d($this->data, $pos);
$pos += 4 ;
$index++;
}
}
// readSmallBlockDepot();
$pos = 0;
$index = 0;
$sbdBlock = $this->sbdStartBlock;
$this->smallBlockChain = array();
while ($sbdBlock != -2) {
$pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE;
for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) {
$this->smallBlockChain[$index] = GetInt4d($this->data, $pos);
$pos += 4;
$index++;
}
$sbdBlock = $this->bigBlockChain[$sbdBlock];
}
// readData(rootStartBlock)
$block = $this->rootStartBlock;
$pos = 0;
$this->entry = $this->__readData($block);
$this->__readPropertySets();
}
function __readData($bl) {
$block = $bl;
$pos = 0;
$data = '';
while ($block != -2) {
$pos = ($block + 1) * BIG_BLOCK_SIZE;
$data = $data.substr($this->data, $pos, BIG_BLOCK_SIZE);
$block = $this->bigBlockChain[$block];
}
return $data;
}
function __readPropertySets(){
$offset = 0;
while ($offset < strlen($this->entry)) {
$d = substr($this->entry, $offset, PROPERTY_STORAGE_BLOCK_SIZE);
$nameSize = ord($d[SIZE_OF_NAME_POS]) | (ord($d[SIZE_OF_NAME_POS+1]) << 8);
$type = ord($d[TYPE_POS]);
$startBlock = GetInt4d($d, START_BLOCK_POS);
$size = GetInt4d($d, SIZE_POS);
$name = '';
for ($i = 0; $i < $nameSize ; $i++) {
$name .= $d[$i];
}
$name = str_replace("