note 71485 added to function.chmod
| From: | imoldgreg at o2 dot co dot uk | Date: | Fri, 01 Dec 2006 01:32:33 +0000 |
| Subject: | note 71485 added to function.chmod | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120209@lists.php.net to get a copy of this message | ||
an update to 'neil at 11 out of 10's code for changing mode using FTP.
changes: proper array added within the function (better for those of us who only need to connect to
one ftp server) so only the mode and directory name need to be passed.
the octal added, for completeness and predictable stability.
function changemode($xcite)
{
$ftp_details = array(
ftp_user_name => 'username',
ftp_user_pass => 'password',
ftp_user_root => '/public_html/',
ftp_server => 'ftp.something.org'
);
$path = "public";
$mod = intval($xcite, 8);
// extract ftp details (array keys as variable names)
extract ($ftp_details);
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// try to chmod $path directory
if (ftp_site($conn_id, 'CHMOD '.$mod.' '.$ftp_root.$path) !== false) {
$success=TRUE;
}
else {
$success=FALSE;
}
// close the connection
ftp_close($conn_id);
return $success;
}
then call it where required, an example:
changemode(777, directory);
if (@copy("$tempname", "$fullfilename")) $done = "yes";
changemode(755, directory);
for those of you, like me, who were looking for a way to make an 'un-hackable' uploader,
here's the closest i got, now for a field test, good luck!
----
Server IP: 83.138.144.80
Probable Submitter: 62.254.32.17 (proxied: 82.16.118.135)
----
Manual Page -- http://www.php.net/manual/en/function.chmod.php
Edit -- https://master.php.net/note/edit/71485
Del: integrated -- https://master.php.net/note/delete/71485/integrated
Del: useless -- https://master.php.net/note/delete/71485/useless
Del: bad code -- https://master.php.net/note/delete/71485/bad+code
Del: spam -- https://master.php.net/note/delete/71485/spam
Del: non-english -- https://master.php.net/note/delete/71485/non-english
Del: in docs -- https://master.php.net/note/delete/71485/in+docs
Del: other reasons-- https://master.php.net/note/delete/71485
Reject -- https://master.php.net/note/reject/71485
Search -- https://master.php.net/manage/user-notes.php