Cell phone number attribution to query
Require (' function.php '); $pwd = "Xiaolin"; Password, please modify if (!isset ($_get["Action"])) { Header ("Location:manage.php?action=login");
} if ($_get["action"]== "login") { ?>
}elseif ($_get["action"]== "Loginin") { $repwd =$_post["pwd"]; if ($repwd! = $pwd) { echo "Sorry, Password wrong ~"; }else { $_session["Flag"]=true; LeftNav (); }
}elseif ($_get["action"]== "info") { LeftNav (); GetInfo (); ?>
}elseif ($_get["Action"]== "edit") { LeftNav (); ?>
}elseif ($_get["action"]== "Loginout") { if (Isset ($_session["flag"])) { unset ($_session["flag"]); Session_destroy (); } echo " Log out Return "; }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 (); } ?>
index.php
Cell phone number attribution to query
if (Isset ($_get["Action"])) { if ("Search" ==$_get["action"]) { Require (' function.php '); $phone = (Isset ($_post["Phone"]))? $_post["Phone"]:d ie ("please return"); echo "The phone number you are inquiring about". $phone. " Belongs to ". Getphone ($phone)."; } } ?>
function.php function Session_Start (); function Update ($num, $info) { $dbpath = "xiaolin/"; $len =strlen ($num); if ($len < 7) { Return "mobile phone number minimum 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 digital"; } } $sunum =scandir ($dbpath); Get supported mobile number prefixes Array_splice ($sunum, 0, 1); Cancel the current directory Array_splice ($sunum, 0, 1); Get rid of the top-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 has been updated"; }else{ Die ("Temporarily does not support $sub"); } } function Getphone ($phone) { $dbpath = "xiaolin/"; $len =strlen ($phone); if ($len < 7) { Return "mobile phone number minimum 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 digital"; } } $sunum =scandir ($dbpath); Get supported mobile number prefixes Array_splice ($sunum, 0, 1); Cancel the current directory Array_splice ($sunum, 0, 1); Get rid of the top-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 (" Please login! "); }elseif ($_session["flag"] = True) { Die ("Please login! "); } }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<> $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 "; } echo "Total $counts";} function LeftNav () { Check (); ?>
} function Showabout () { echo " Cell phone number attribution to query "; } ?> |