function Session_begin () {
Global $userid, $sid, $ip, $session, $db, $islogin;
$ip = GetIP ();
/* In the short term, the system needs to support cookies by default. */
if (!isset ($_cookie[' userid ')) return false;
else $userid = $_cookie[' userid '];
if (!isset ($_cookie[' Sid ')) return false;
else $sid = $_cookie[' sid '];
/* Above return false means that the user does not login, the page will jump to the first page (landing pages). */
$query = "SELECT * from user WHERE nickname = ' $userid '";
$result = $db->sql_query ($query);
if ($row = $db->sql_fetchrow ($result)) {
if ($row [' Sid ']!= $sid) return false; /* Cookie delivery SID and database save not match * *
if ($row [' Lastloginip ']!= $ip) return false; /* IP does not match * *
/* Do you want to consider expiration of session? */
}
else return false; * * without this userid * *
$session = $row;
$session ['] = $row ['];
Unset ($row);
echo "<td><a href= ' delete.php?nickname= ' onclick=" return confirm (' OK delete? RN This operation cannot be recovered ') "><font color=red > Delete the user </font></a></td> ";
7. To do a text processing for colleagues, two documents one has 70,000 records, start with nested loops, PHP dead, followed by an array to solve the problem
<?php
if (($fp =fopen ("1.txt", "A +")) ===false)
{
Die ("Open file Failed");
}
$data 1=file ("Old.txt") or Die ("Open file Failed");
$data 2=file ("Sports.txt") or Die ("Open file Failed");
foreach ($data 1 as $data)
{
$x = Split ("[./]", $data);
$name = $x [Count ($x)-2];
$a [$name] [' MD5 ']= $data;
}
foreach ($data 2 as $data)
{
$x = Split ("[,./]", $data);
$name = $x [Count ($x)-2];
if (isset ($a [$name]))
$a [$name] [' name ']= $x [0];
}
foreach ($a as $value)
{
$STR = $value [' MD5 ']. $value [' name '];
Fwrite ($fp, $STR);
echo $value [' MD5 ']. ', '. $value [' name ']. " <br> ";
Fwrite ($fp, $STR);
}
?>
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