|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
pavlov Smarty n00b
Joined: 27 Feb 2004 Posts: 2
|
Posted: Fri Feb 27, 2004 11:46 pm Post subject: Oops.. Now I cannot delete templates_c |
|
|
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 |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat Feb 28, 2004 12:11 am Post subject: |
|
|
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 |
|
pavlov Smarty n00b
Joined: 27 Feb 2004 Posts: 2
|
Posted: Sat Feb 28, 2004 3:56 am Post subject: |
|
|
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 |
|
|
|
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
|