Mobile phone number attribution to query

Source: Internet
Author: User
Tags ereg php file php tutorial strlen

<!--This is a free phone number attribution Query program is written in the PHP tutorial, including query instance and instance code-->
<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 file
<?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. " ";
$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. = "";
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= "Left" >

</div>
<div id= "Right" >

<?php
}
function Showabout () {
echo <p> mobile phone number attribution to the query </p>
";
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.