Windows 7 Support
Become a Fan of PCHF on Facebook!
User Reviews - Add Yours!
The PCHF Lounge
Go Back   PC Help Forum » Web & Networking » Web Design
Register for a Free Account

Web Design - File owned by 'nobody' posted in the Web & Networking forums; Im building a website, but i run into a problem files created by the cms im using is giving file ownership to 'nobody' Now i already asked my host to ...

Advertisement
Advertisement

Reply
Recommended Driver Scanner
Old 06-03-2009   #1
Tech Member
 
malcomhfc's Avatar
 
Join Date: Sep 2008
Location: Scotland
Posts: 751
PC Experience: Experienced
Cool File owned by 'nobody'

Im building a website, but i run into a problem files created by the cms im using is giving file ownership to 'nobody' Now i already asked my host to return ownership of a few files to me but theres many more still not under me.

Ive started using ftp as away of uploading my files to make sure i own them but for files i still dont own i cant delete or edit of which i need to.

So i have this php script to remove them, found it when googling (Not 'bing'ing) :P

PHP Code:
<?PHP 
// Deletes the entire thumb directory created by PHP script 
// Rename this file delete.php, save it in the same directory 
// as script and then run it via your web browser. 


//    $thumbdir = "com_comment"; 
    
$thumbdir "com_comment"


    
    
$dir opendir($thumbdir); 
    while( 
$file readdir$dir ) ) { 
       if (
$file == "." or $file == "..") { 
          continue; 
       } 
       echo 
"Deleting $thumbdir/$file ... "
       if (
unlink("$thumbdir/$file")) { 
          echo 
"Done.<BR>"
       } else { 
          echo 
"Not done.<BR>"
       } 
    } 

    if (
rmdir($thumbdir)) { 
       echo 
"<BR>Directory $thumb was completely deleted.<BR>"
    } else { 
       echo 
"<BR>Directory $thumb could not be completely deleted.  Check permissions."
    } 
   
?>
Up at the top 'com_comment' is the folder i wish to remove. Sadly inside it, cotains folders and files not owned by me too.

I got this error while executing the script.

Deleting com_comment/plugin ...
Warning: unlink(com_comment/plugin) [function.unlink]: Is a directory in /home/*******/public_html/administrator/components/delete.php on line 18
Not done.

Warning: rmdir(com_comment) [function.rmdir]: Directory not empty in /home/*******/public_html/administrator/components/delete.php on line 25

Directory could not be completely deleted. Check permissions.
where ****** is, thats my username ofc, just replaced it with little cute stars

Any help would be great.

Malcom
__________________
My network of Websites : Tvsmash | Gamerznews | Robbiek



Freelance web developer: http://dev.blind-summit.com
malcomhfc is offline   Reply With Quote
Old 06-03-2009   #2
Tech Support Team
 
upgrader's Avatar
 
Join Date: Jul 2006
Location: /home/upgrader/
Posts: 7,313
PC Experience: Some Experience
Default Re: File owned by 'nobody'

Hi Malcom,

The first error occurs because unlink() can only delete files, not directories, that warning displays because it can't delete the /plugin directory. The second error occurs because unlink couldn't delete that directory therefore the directory is not empty.

Try out the script below, I made it quite quickly so it's a bit messy but it should do the trick. You may get this error:
Code:
Warning: rmdir(com_comment) [function.rmdir]: Directory not empty
Just run the script again if you do and it should remove the directory.

I've also changed the output so that it tells you which files are removed and directories etc.

PHP Code:
<?PHP 
// Deletes the entire thumb directory created by PHP script 
// Rename this file delete.php, save it in the same directory 
// as script and then run it via your web browser. 


//    $thumbdir = "com_comment"; 
    
$thumbdir "com_comment"


    
    
$dir opendir($thumbdir); 
    while( 
$file readdir$dir ) ) { 
       if (
$file == "." or $file == "..") { 
          continue; 
       } 
       
       
// Check if file is a directory.
       
if (is_dir("$thumbdir/$file")) {
               
// if file is a directory, delete all files in directory.
               
$inside_dir opendir("$thumbdir/$file");
               while( 
$inside_file readdir$inside_dir ) ) { 
               if (
$inside_file == "." or $inside_file == "..") { 
                  continue; 
               }
               if (
unlink("$thumbdir/$file/$inside_file")) { 
                  echo 
"$thumbdir/$file/$inside_file"." deleted.<br />"
               } else { 
                  echo 
"$thumbdir/$file/$inside_file"." not deleted (error).<br />"
               }
            }   
            
// remove the directory inside
               
if (rmdir("$thumbdir/$file")) {
                       echo 
$file." directory deleted.<br />";
                   } else {
                       echo 
$file." directory was not deleted.<br />";
                   }
       
// if file is not a directory delete it            
       
} else {       
           if (
unlink("$thumbdir/$file")) { 
              echo 
$file." deleted.<br />"
           } else { 
              echo 
$file." not deleted (error).<br />"
           } 
       }
    } 

    if (
rmdir($thumbdir)) { 
       echo 
"<BR>Directory $thumb was completely deleted.<BR>"
    } else { 
       echo 
"<BR>Directory $thumb could not be completely deleted.  Check permissions."
    } 
   
?>
__________________
PCHF Rules--PCHF Prework--PCHF Downloads
upgrader is online now   Reply With Quote
Old 06-04-2009   #3
Tech Member
 
malcomhfc's Avatar
 
Join Date: Sep 2008
Location: Scotland
Posts: 751
PC Experience: Experienced
Default Re: File owned by 'nobody'

Ah thanks shall try it out later. Thanks for your time Upgrader.
__________________
My network of Websites : Tvsmash | Gamerznews | Robbiek



Freelance web developer: http://dev.blind-summit.com
malcomhfc is offline   Reply With Quote
Old 06-06-2009   #4
Tech Support Team
 
upgrader's Avatar
 
Join Date: Jul 2006
Location: /home/upgrader/
Posts: 7,313
PC Experience: Some Experience
Default Re: File owned by 'nobody'

Any luck Malcom?
__________________
PCHF Rules--PCHF Prework--PCHF Downloads
upgrader is online now   Reply With Quote
Old 06-11-2009   #5
Tech Member
 
malcomhfc's Avatar
 
Join Date: Sep 2008
Location: Scotland
Posts: 751
PC Experience: Experienced
Default Re: File owned by 'nobody'

Hm, i think the directory needs to be chmodded to 777 to be deleted. Ive seen the php line to do this but didn't know where to add
__________________
My network of Websites : Tvsmash | Gamerznews | Robbiek



Freelance web developer: http://dev.blind-summit.com
malcomhfc is offline   Reply With Quote
Old 06-11-2009   #6
Tech Support Team
 
upgrader's Avatar
 
Join Date: Jul 2006
Location: /home/upgrader/
Posts: 7,313
PC Experience: Some Experience
Default Re: File owned by 'nobody'

Hi malcom,

I don't have time to write a chmod script right now, but there would be no point anyway - plenty of people have already done it!

Try running this function first:
Recursive chmod in PHP - PHP - Snipplr

Let us know if you need any help
__________________
PCHF Rules--PCHF Prework--PCHF Downloads
upgrader is online now   Reply With Quote
Old 06-11-2009   #7
Tech Member
 
malcomhfc's Avatar
 
Join Date: Sep 2008
Location: Scotland
Posts: 751
PC Experience: Experienced
Default Re: File owned by 'nobody'

Oki thanks
__________________
My network of Websites : Tvsmash | Gamerznews | Robbiek



Freelance web developer: http://dev.blind-summit.com
malcomhfc is offline   Reply With Quote

Reply

Bookmarks

Tags
file, owned, Resolved:
Similar discussions...
Thread Thread Starter Forum Replies Last Post
File sorting with DOS batch file (XP) Bowzerbro Programming 5 04-04-2009 10:13 PM
converting txt file into html file TKIRBYAUTO General Software 2 01-21-2008 07:50 PM
Owned by my anti-spyware software.. HazzLewis Windows XP/2000 6 10-30-2007 04:17 PM
.CDT file(PrintShop20) won't install from CD- how do I copy .cdt file to hard drive? mtndirtbikegal General Software 1 11-06-2006 08:20 PM
[File of the Day] Personal File Server Newsie IT News 0 10-20-2005 08:31 PM

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On




All times are GMT. The time now is 08:53 AM.
Powered by vBulletin
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2