Hi all. I'm trying to write a small script that will chmod a file or dir for me, but I'm running into some problems.
I know that unless a file or dir was created by PHP itself, the chmod() function won't work since PHP is neither the owner of the file, nor is it running as root.
Some time ago I remember coming across a script which purported to be able to chmod files/dirs by using fsockopen() and fputs().
I can't find the script, so I've attempted to recreate as best as I can from memory, but while it's not giving me any errors, it's not chmodding the file either. Here's the script, which is running in the same directory as the file I'm attempting to chmod:
$noftp = fsockopen("gpu.unbc.ca", 21, $errno, $errstr, 60);
socket_set_blocking($noftp, false);
fputs($noftp, "USER $********\n");
fputs($noftp, "PASS $***************\n");
sleep(1);
fputs($noftp, "gpu.unbc.ca chmod 0755 index.html\n");
sleep(1);
fclose($noftp);
As I said, it's not giving any erros, but the file index.html is not being affected either.
Can anyone give me an idea what the problem could be, or if what I'm trying to accomplish is even possible?
Thanks in advance,
Pablo