Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Oops.. Now I cannot delete templates_c

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup
View previous topic :: View next topic  
Author Message
pavlov
Smarty n00b


Joined: 27 Feb 2004
Posts: 2

PostPosted: Fri Feb 27, 2004 11:46 pm    Post subject: Oops.. Now I cannot delete templates_c Reply with quote

I got Smarty working fine, but "nobody" wrote the compiled templates in subdirectories of templates_c, with permissions 755, owned by nobody:nobody. Unfortunately, this is on a hosted account, where I do not have root access.

I can get the hosting company to remove that directory THIS time, but what can I do to keep my diskspace from filling up with compiled templates? Is there a way to change the permissions of the subdirectories and files that "nobody" writes?

Richard


Last edited by pavlov on Sat Feb 28, 2004 3:58 am; edited 1 time in total
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sat Feb 28, 2004 12:11 am    Post subject: Reply with quote

Try writing a script to remove the files/directories -- if they can be created using PHP, surely it can be remove that way as well.
Back to top
View user's profile Send private message
pavlov
Smarty n00b


Joined: 27 Feb 2004
Posts: 2

PostPosted: Sat Feb 28, 2004 3:56 am    Post subject: Reply with quote

Excellent observation. I did just that. Below is a function that recursively sets permissions to 777, to allow me to delete everything. I didn't use glob() because the target system doesn't have it yet.
I also discovered what to change, in order for the directories/files to be created in the first place such that I have write permissions: First, in Smarty.class.php set var $_file_perms=0666 and set var $_dir_perms = 0777; Second, in both core.write_file.php and core.create_dir_structure.php you must add umask(0) in the function. Without this, php will still not create directories with mode 777 or files with mode 666. I'm still considering what the security implications of this change might be...

To use this function, just put this in the html body of your php file:

<?php
$basedir='.';
echo "starting in $basedir <br>\n";
chmod_recurse($basedir);
?>

<?php
function chmod_recurse($basedir) {
echo "<br><br> Entering directory: $basedir\n";
if ( $handle = opendir($basedir)) {
while (false !== ($file = readdir($handle))) {
$fullname= $basedir . "/" . $file ;
if (!strcmp($file, '.') OR !strcmp($file,'..')) {
}
elseif (is_dir($fullname)) {
chmod($fullname , 0777);
echo "<br> chmod: $fullname\n";
chmod_recurse($fullname);
}
else {
chmod($fullname , 0777);
echo "<br> chmod: $fullname\n";
}
}
}
closedir($handle);
}
?>


Richard
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP