note 69948 added to function.is-writable

From: Date: Wed, 27 Sep 2006 15:40:12 +0000
Subject: note 69948 added to function.is-writable
Groups: php.notes 
Request: Send a blank email to php-notes+get-117737@lists.php.net to get a copy of this message
People using IIS reported serious problems with activeCollab (http://www.activecollab.com/) because of http://bugs.php.net/bug.php?id=27609. Installer said that folders are writable and than they received a bunch of write errors when they tried to upload something. Solution this two simple functions: <?php function folder_is_writable($path) { if(!is_dir($path)) { return false; } do { $test_file = $path . '/' . sha1(uniqid(rand(), true)); } while(is_file($test_file)); $put = @file_put_contents($test_file, 'test'); if($put === false) { return false; } @unlink($test_file); return true; } function file_is_writable($path) { if(!is_file($path)) { return false; } $open = @fopen($path, 'a+'); if($open === false) { return false; } @fclose($open); return true; } ?> ---- Server IP: 66.163.161.117 Probable Submitter: 87.116.136.224 ---- Manual Page -- http://www.php.net/manual/en/function.is-writable.php Edit -- https://master.php.net/note/edit/69948 Del: integrated -- https://master.php.net/note/delete/69948/integrated Del: useless -- https://master.php.net/note/delete/69948/useless Del: bad code -- https://master.php.net/note/delete/69948/bad+code Del: spam -- https://master.php.net/note/delete/69948/spam Del: non-english -- https://master.php.net/note/delete/69948/non-english Del: in docs -- https://master.php.net/note/delete/69948/in+docs Del: other reasons-- https://master.php.net/note/delete/69948 Reject -- https://master.php.net/note/reject/69948 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117737) next »