|
<title> mobile phone number attribution to the query </title>
<style type= "Text/css" >
#main {
height:100%;
}
#left {
Float:left;
height:100%;
width:10%;
Float:left;
}
#right {
Float:left;
height:100%;
width:100$;
}
</style>
<body>
<?php
Require (' function.php ');
$pwd = "Xiaolin"; Password, please modify
if (!isset ($_get["action")) {
Header ("Location:manage.php?action=login");
}
if ($_get["action"]== "login") {
?>
<form action= "Manage.php?action=loginin" method= "POST" >
<p> Please enter the password:</p>
<p><input type= "Password" value= "name=" pwd "></p>
<p><input type= "Submit" value= "Login" ></p>
</form>
<?php
}elseif ($_get["action"]== "Loginin") {
$repwd =$_post["pwd"];
if ($repwd!= $pwd) {
echo "Sorry, password error ~!";
}else {
$_session["Flag"]=true;
LeftNav ();
}
}elseif ($_get["action"]== "info") {
LeftNav ();
GetInfo ();
?>
</div>
</div>
<?php
}elseif ($_get["Action"]== "edit") {
LeftNav ();
?>
<form action= "MANAGE.PHP?ACTION=EDITP" method= "POST" >
<p> Mobile Number: <input type= "text" name= "num" > (at least 7 digits) </p>
<p> Detailed information: <input type= "text" name= "info" ></p>
<input type= "Submit" value= "Update" >
</form>
<?php
}elseif ($_get["action"]== "Loginout") {
if (Isset ($_session["flag"])) {
unset ($_session["flag"]);
Session_destroy ();
}
echo "<p><a> logout </a></p><p><a href= ' manage.php ' > Return </a></p>";
}elseif ($_get["action"]== "EDITP") {
LeftNav ();
$num =$_post["num"];
$info =$_post[' info '];
if (!empty ($num) &&!empty ($info) && strlen ($num) >=7) {
Update ($num, $info);
}else{
Die ("must not be empty!") ");
}
}elseif ("About" ==$_get["action"]) {
LeftNav ();
Showabout ();
}
?>
</body>
index.php
<title> mobile phone number attribution to the query </title>
<body>
<form action= "Index.php?action=search" method= "POST" >
<p> Please input the mobile number you want to inquire: <input type= "text" name= "Phone" ></p>
<p><input type= "Submit" value= "Search mobile number Attribution" ></p></p>
</form>
<?php
if (Isset ($_get["action")) {
if ("Search" ==$_get["action"]) {
Require (' function.php ');
$phone = (Isset ($_post["Phone"])? $_post["Phone"]:d ie ("please return");
echo "The cell phone number you queried <font color=red>". $phone. " </font> belongs to <font color=red> ". Getphone ($phone)." </font> ";
}
}
?>
</body>
function.php function
<?php
Session_Start ();
function Update ($num, $info) {
$dbpath = "xiaolin/";
$len =strlen ($num);
if ($len < 7) {
Return "mobile phone number of the lowest 7-bit Oh";
}
$par = "[0-9]";
for ($i =0; $i < $len; $i + +) {
if (!ereg ($par, substr ($num, $i, 1)) {
Return "mobile phone number can only be a number";
}
}
$sunum =scandir ($dbpath); Get supported phone number prefix
Array_splice ($sunum, 0, 1); Cancel the current directory
Array_splice ($sunum, 0, 1); Get rid of the upper level catalogue
$sub =substr ($num, 0, 3); Get the first three digits of the number
if (In_array ($sub, $sunum)) {
$num 1=ltrim (substr ($num, 3,4), "0");
$search =file ($dbpath. $sub);
$tmp = $search [$num 1];
$search [$num 1]= $num 1.] = '. $info. " n ";
$FP 1=fopen ($dbpath. $sub. ' 1 ', ' wb+ ');
For ($i =0 $i <10000; $i + +) {
$phone =str_pad ($i, 4, "0", str_pad_left);
$phoneinfo = "";
$phoneinfo. = $phone. " =";
$phoneinfo = (Isset ($search [$i]))? $search [$i]: "";
$phoneinfo. = "n";
Fwrite ($fp 1, $search [$i]);
}
Fclose ($fp 1);
echo "$num updated";
}else{
Die ("Temporarily does not support $sub");
}
}
function Getphone ($phone) {
$dbpath = "xiaolin/";
$len =strlen ($phone);
if ($len < 7) {
Return "mobile phone number of the lowest 7-bit Oh";
}
$par = "[0-9]";
for ($i =0; $i < $len; $i + +) {
if (!ereg ($par, substr ($phone, $i, 1)) {
Return "mobile phone number can only be a number";
}
}
$sunum =scandir ($dbpath); Get supported phone number prefix
Array_splice ($sunum, 0, 1); Cancel the current directory
Array_splice ($sunum, 0, 1); Get rid of the upper level catalogue
$sub =substr ($phone, 0, 3); Get the first three digits of the number
if (In_array ($sub, $sunum)) {
$num =ltrim (substr ($phone, 3,4), "0");
$search =file ($dbpath. $sub);
$tmp = $search [$num];
$result =substr ($tmp, Strpos ($tmp, "=") +1,strlen ($tmp)-strpos ($tmp, "=")-2); Working with Data
Return (strlen ($result) >1)? $result: "No data";
}else{
Return "temporarily does not support $sub";
}
}
function Check () {
if (!isset ($_session["flag"])) {
Die ("<p> please <a href= ' manage.php?action=login ' > Login!</a></p>");
}elseif ($_session["flag"]!= true) {
Die ("<p> please <a href= ' manage.php?action=login ' > Login!</a></p>");
}
}
function GetInfo () {
Check ();
$nums =array ("130", "131", "" 132 "," 133 "," 134 "," 135 "," 136 "," 137 "," 138 "," 139 "," 150 "," 151 "," 153 "," 155 "," 156 "," 157, "" 158 "," 159 ");
$counts = "";
for ($j =0; $j <count ($nums); $j + +) {
$id = $j;
if ($id >= count ($nums)) {die ("over");}
$nownum = $nums [$id]; The current number segment
$dbpath = "xiaolin/";
$FP =fopen ("xiaolin/$nownum", ' R ');
while (!feof ($fp)) {
$line =fgets ($FP);
$tmp =explode ("=", $line);
$num 1[$tmp [0]]=substr ($line, Strpos ($line, "=") +1,strlen ($line)-strpos ($line, "=")-2);
}
Fclose ($FP);
$flag = 0;
For ($i =0 $i <10000; $i + +) {
$ser =str_pad ($i, 4, "0", str_pad_left);
if (!strlen ($num 1[$ser]) ==0) {
+ + $flag;
}
}
$counts + + $flag;
echo "$nownum: Segment record $flag</p>";
}
echo "Total $counts";}
function LeftNav () {
Check ();
?>
<div>
<div id= "Right" >
<?php
}
function Showabout () {
echo <p> mobile phone number attribution to the query </p>
";
}
?>
|