Note that there are some explanatory texts on larger screens.

plurals
  1. POdisabling/enabling access/download for user but allow php to edit - using chown and chmod
    text
    copied!<p>I want ...</p> <ul> <li><code>move_uploaded_files</code> to some folder (lets say <code>http://localhost/myproject/protected</code>). (and PHP should be able to <code>rm</code>, <code>mv</code>, <code>cp</code>, ... everything inside <code>protected</code>)</li> <li>enable/disable access/download for user for any file, for example <code>http://my.ip.add.ress/myproject/protected/foo.bar</code> (and <code>http://localhost/myproject/protected/foo.bar</code> is not exception !)</li> </ul> <p>... using <code>chmod</code> and <code>chown</code>. <strong>I wonder if this is possible ?!</strong></p> <hr> <p>P.S. I have an idea :</p> <pre><code>// firstly chown -R www-data:www-data /var/www &lt;?php //file : localhost/myproject/foo.php //use following when access for user is disabled shell_exec("chmod -R 0777 protected"); // edit the folder ... // edit the folder ... // edit the folder ... shell_exec("chmod -R 0000 protected"); ?&gt; </code></pre> <p>But I don't think it is secure enough :-{|)</p> <p>O.M.T. (One More Thing) I did following :</p> <ul> <li><code>chown -R www-data:www-data /var/www</code></li> <li><code>chmod -R 0700 /var/www/myproject/protected</code></li> </ul> <p>PHP can access the files, but user can also access them.</p> <hr> <p><strong>EDIT 1</strong> : Output for <code>ps aux | egrep '(apache|httpd)'</code> :</p> <pre><code>root 12748 0.0 0.2 39984 8256 ? Ss 01:54 0:00 /usr/sbin/apache2 -k start www-data 12755 0.0 0.1 40208 6008 ? S 01:54 0:00 /usr/sbin/apache2 -k start www-data 12756 0.0 0.1 40008 4324 ? S 01:54 0:00 /usr/sbin/apache2 -k start www-data 12757 0.0 0.1 40008 4324 ? S 01:54 0:00 /usr/sbin/apache2 -k start www-data 12758 0.0 0.1 40008 4324 ? S 01:54 0:00 /usr/sbin/apache2 -k start www-data 12759 0.0 0.1 40008 4324 ? S 01:54 0:00 /usr/sbin/apache2 -k start sylap 12896 0.0 0.0 5904 860 pts/1 S+ 02:25 0:00 egrep --color=auto (apache|httpd) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload