Three first page press release, make your update easier (next)
-----Last talk, we have achieved the basic function of the homepage press release. In this talk, we give it a building block, so that its function more powerful. (a good software, in fact, is the basic function plus a group of ancillary functions, these ancillary functions are mainly drawing a convenient just, hehe)
-----First, let's be clear about what we want to get. We do not want a few 10 days ago things we forgot to delete, and the results were released as news on the homepage (very humiliating Oh ^&^). If we embed a piece of code in a basic implementation, such as using Filectime ($filename), then, under UNIX, we get the time from January 1, 1970, in seconds to the last file changed (the date time the file was generated under Windows), And from January 1, 1970 onwards in seconds to the current number of seconds can be obtained by $mynow=mktime (), subtraction, judgment, IF > The time we expect, hehe, Sorry,unlink ($newspath. $filename) ... What the?! Where do you want to put this code? You say, hehe.
Perhaps, you are not often on a machine on the Internet, when you get a new news but not next to your love machine, how to do? The ideal thing is to upload files on the homepage. You may have a page (Admin?) Need to use a password to enter (if you still cherish their own website, this is necessary, it is best not to let others know the filename, hehe). Here is a section of code that is visible everywhere:
?
if (Isset ($upfile))
{
?>
The uploaded file information is as follows:
File Store path: <?echo $upfile;? >
Original filename: <?echo $upfile _name;? >
File Size (bytes): <?echo $upfile _size;? >
File type: <?echo $upfile _type;? >
-----Here we have seen a combination of PHP and HTML form, you can learn from. File uploads, while convenient, always give people a sense of insecurity. Once the leaks are compromised, your server's system security is compromised because the uploaded file may be a destructive execution file (that is, a virus or hacker program) it is prudent to write an online edited file, here is an example:
〈? Php
function Mywritefile ($filename, $contents) {
if ($fp =fopen ($filename, "w")) {
Fwrite ($fp, Strpslashes ($contents));
Fclose ($FP);
return 1;
}
else {return 0;};
};
Determine the variables returned by the form
if ($submitButton = = "complete") {
$rs =mywritefile ("$page", "$test");
echo "<a href =" $page "> $page </a><br>";
}
ElseIf ($action = = "page")//The case where the variable action value is "page"
{$contents = "$page";
$fp = @fopen ($content, "w+") or Die (' could not open file! ');
$contents =htmlspecialchars ($contents);
Fclose ($FP);
echo "<form action=" admin.php?page= $page "method=" POST "wrap=soft>";
echo "$contents";
echo "</textarea>";
echo "<input type=" Submit "Name=" Submitbutton "value=" complete ">";
echo "</form>";
}
Else
{echo "<form action=" basename ($PHP _self).? Action=page "method=" POST ">", or the way to refer to variables within the program.
echo "<input type=text size=20 name=page>";
echo "<input type=" submit "name=" Send "value=" selected ">";
echo "</form>";
}
?>
-----to this point, the home page news release of the implementation has been able to come to an ending. We can see that any one feature (comparison) of the powerful Chen program is composed of some simple functions. The third part of the function of the whole perfect process using the superposition of enhanced methods, and software engineering Top-down, layered analysis of the development method is not the same. This is a suitable for learning methods, write their own writing is very useful, hehe.
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