Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Change Permission With Php Code


6 replies to this topic

#1 snlildude87

    Moderator

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 2,325 posts
  • Location:Mawson, Antarctica

Posted 10 April 2005 - 08:55 PM

As everyone know, there two ways (that I can think of) to change files' and directories' permissions. One is to change it in your cPanel's Disk Manager and the other is with an FTP client that supports chmod.

Well, I'm doing something for my site that requires files to have full permissions (Execute, Write, and Read on all three groups). At first, I thought that if I made the directory 777, then every file created in that directory will be 777 as well. I'm wrong. An alternative to doing this is to change each file permission myself, but that would be too much work.

So my question is: is there a way to change file permission with PHP? Like a code in PHP that would change the files' permission?

Thanks in advance! :)

#2 no9t9

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 773 posts

Posted 10 April 2005 - 09:13 PM

you can make a php script to change all the file permissions. It is pretty easy, you just have to cycle through every file in a directory and use the chmod command. See http://us3.php.net/chmod for details on the codes for chmod.

$path="yourdirectory";
$dh = opendir($path);
while ($temp = readdir($dh)) {
if ($temp!='.' && $temp!='..' && $temp!='.htaccess') chmod($temp,777); }

you can even make a php page that has a form so you can enter the directory name via a text input field. But, that might be a security risk though...

#3 farsiscript

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 357 posts
  • Interests:... No More !

Posted 20 November 2006 - 07:30 AM

Hi Dear snlildude87 in some servers this fucn is close , you must use ftp or filemanager . this fuc run at global_register ,
Your can find this fucn at php.net
http://ir.php.net/ma...ction.chmod.php
ITs Like CHOMD !

#4 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 24 January 2008 - 05:51 AM

a php script
Change Permission With Php Code

Replying to no9t9
Can you share your solution or php script that changes permission? Also, is there a way that I can make a php script that changes ownership of files and folders.

If so, can you help me by sending or pasting the php script code that I can upload to server and try. Thank you.

Sumyabazar

-reply by Sumyabazar

#5 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 10 February 2010 - 12:48 PM

how to parse through a website? Change Permission With Php Code

I have been given a website and I need to parse through the site and get the hyperlinks in it and then go through that link and get the contents. I am planning to do the work with curl and some preg_match function and then get thehyperlinks. Now I need to save the contents in a file and then get the file and parse it separately and do the task I need. Can I anyone help me in this? I need the source code. Please do mail me tell me or get the reply here.

Thank you

-question by Sudarsan

#6 discomatt

    Newbie

  • Kontributors
  • Pip
  • 7 posts

Posted 06 March 2010 - 09:31 AM

I'd suggest starting a new thread about that and at least showing you made an attempt to do this yourself.

I don't tihnk many people here want to be your personal coder.

#7 Guest_kusuma_*

  • Guests

Posted 24 June 2011 - 07:34 AM

To create a folder and to give the permissions
am sure it wil help u


$oldumask = umask(0);
mkdir($folder, 0766);
umask($oldumask);




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users