Mobile phone number attribution query
Require ('function. php '); $ Pwd = "xiaolin"; // password. change it. 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, incorrect password ~! "; } 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"Logout 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 ("cannot be blank! "); } } Elseif ("about" ==$ _ GET ["action"]) { Leftnav (); Showabout (); } ?>
Index. php
Mobile phone number attribution query
If (isset ($ _ GET ["action"]) { If ("search" ==$ _ GET ["action"]) { Require ('function. php '); $ Phone = (isset ($ _ POST ["phone"])? $ _ POST ["phone"]: die ("Please return "); Echo "your phone number". $ phone. "belongs to". getphone ($ phone ).""; } } ?>
Function. php functions Session_start (); Function update ($ num, $ info ){ $ Dbpath = "xiaolin /"; $ Len = strlen ($ num ); If ($ len <7 ){ Return "the minimum mobile phone number is 7 characters "; } $ Par = "[0-9]"; For ($ I = 0; $ I <$ len; $ I ++ ){ If (! Ereg ($ par, substr ($ num, $ I, 1 ))){ Return "the mobile phone number can only be a number "; } } $ Sunum = scandir ($ dbpath); // Get the supported mobile phone number prefix Array_splice ($ sunum,); // cancel the current directory Array_splice ($ sunum,); // remove the upper-level Directory $ Sub = substr ($ num,); // obtain the first three digits of the number. If (in_array ($ sub, $ sunum )){ $ Num1 = ltrim (substr ($ num, 3, 4), "0 "); $ Search = file ($ dbpath. $ sub ); $ Tmp = $ search [$ num1]; $ Search [$ num1] = $ num1. '='. $ info. "n "; $ Fp1 = fopen ($ dbpath. $ sub. '1', 'WB + '); For ($ I = 0; I I <10000; $ I ++ ){ // $ Phone = str_pad ($ I, 4, "0", STR_PAD_LEFT ); // $ Phoneinfo = ""; // $ Phoneinfo. = $ phone. "= "; // $ Phoneinfo = (isset ($ search [$ I])? $ Search [$ I]: ""; // $ Phoneinfo. = "n "; Fwrite ($ fp1, $ search [$ I]); } Fclose ($ fp1 ); Echo "$ num updated "; } Else { Die ("$ sub is not supported currently "); } } Function getphone ($ phone ){ $ Dbpath = "xiaolin /"; $ Len = strlen ($ phone ); If ($ len <7 ){ Return "the minimum mobile phone number is 7 characters "; } $ Par = "[0-9]"; For ($ I = 0; $ I <$ len; $ I ++ ){ If (! Ereg ($ par, substr ($ phone, $ I, 1 ))){ Return "the mobile phone number can only be a number "; } } $ Sunum = scandir ($ dbpath); // Get the supported mobile phone number prefix Array_splice ($ sunum,); // cancel the current directory Array_splice ($ sunum,); // remove the upper-level Directory $ Sub = substr ($ phone,); // obtain 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 ); // process data Return (strlen ($ result)> 1 )? $ Result: "No data "; } Else { Return "$ sub" is not supported Currently "; } } Function check (){ If (! Isset ($ _ SESSION ["flag"]) { Die (" Please log on! "); } Elseif ($ _ SESSION ["flag"]! = True ){ Die ("Please log on! "); } }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 ); $ Num1 [$ tmp [0] = substr ($ line, strpos ($ line, "=") + 1, strlen ($ line)-strpos ($ line, "=")-2 ); } Fclose ($ fp ); $ Flag = 0; For ($ I = 0; I I <10000; $ I ++ ){ $ Ser = str_pad ($ I, 4, "0", STR_PAD_LEFT ); If (! Strlen ($ num1 [$ ser]) = 0 ){ ++ $ Flag; } } $ Counts + = $ flag; Echo "$ nownum: Segment record $ flag "; } Echo "total $ counts ";} Function leftnav (){ Check (); ?>
} Function showabout (){ Echo" Mobile phone number attribution query "; } ?> |