In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the example analysis of the existence of Bug in the is_writeable () function in PHP, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
Bug exists in the is_writeable () function of PHP, so it is impossible to accurately judge whether a directory / file is writable. Please write a function to determine whether a directory / file is absolutely writable.
A: there are two aspects of bug
1) in windowns, the is_writeable () function returns false when the file has only read-only attributes, and when true is returned, the file is not necessarily writable.
If it is a directory, create a new file in the directory and determine by opening the file
If it is a file, you can test whether the file is writable by opening the file (fopen).
2) in Unix, when safe_mode is enabled in the php configuration file (safe_mode=on), is_writeable () is also not available.
Read whether the configuration file is enabled or not safe_mode.
/ * * Tests for file writability** is_writable () returns TRUE on Windows servers when you really can't write to* the file, based on the read-only attribute. Is_writable () is also unreliable* on Unix servers if safe_mode is on.** @ access private* @ return void*/if (! Function_exists ('is_really_writable') {function is_really_writable ($file) {/ / If we're on a Unix server with safe_mode off we call is_writable if (DIRECTORY_SEPARATOR = =' / 'AND @ ini_get ("safe_mode") = = FALSE) {return is_writable ($file);} / / For windows servers and safe_mode "on" installations we'll actually / / write a file then read it. Bah... If (is_dir ($file)) {$file = rtrim ($file,'/'). / '.md5 (mt_rand (1100). Mt_rand (1100)); if (($fp = @ fopen ($file, FOPEN_WRITE_CREATE)) = = FALSE) {return FALSE;} fclose ($fp); @ chmod ($file, DIR_WRITE_MODE); @ unlink ($file) Return TRUE;} elseif (! Is_file ($file) OR ($fp = @ fopen ($file, FOPEN_WRITE_CREATE)) = FALSE) {return FALSE;} fclose ($fp); return TRUE }} Thank you for reading this article carefully. I hope the article "sample Analysis of the existence of Bug in the is_writeable () function in PHP" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.