|
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 |
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Wed Feb 18, 2009 4:24 pm Post subject: Remove compiled files |
|
|
Some servers do not allow to remove the files created by php/apache or www or httpd like users, if in Linux machines.
In your smarty compiles, smarty will make the files. So, you may be unable to remove them using FTP, because of restrictions in file permissions.
In this case, if you still need to remove the compiled files, you should ask a php script do it for you.
(In linux, the user who creates files may have high control, and thus can remove them too).
Use the following code in a different file, configure it to say, where is the location of your compiles directory is, and then run it.
If will try to emtpy anything inside this directory.
In a good environment, it does not matter anything significant to remove all your compiled file. However, removing the compiles files can be important for a developer.
WARNING: Use the script responsibly. It is dangerous, unless you know what you are going to do.
Code: | <?php
/**
* File: remove_compiles.php
* Used to remove the compliled files of smarty.
* WARNING: IF YOU DO NOT SET YOUR SMARTY COMPILES DIRECTROY CORRECTLY,
* THEN YOU MAY LOSE YOUR SCRIPTS.
* I AM NOT RESPONSIBLE FOR THE LOSS, IF YOU CAN NOT USE IT CORRECTLY.
*
* @author Bimal Poudel <smarty @ bimal.org.np>
*/
function cleanup_compiled_files()
{
$dir = './application/templates_c'; # Set it correctly.
if($handle = opendir($dir))
{
while (false !== ($file = readdir($handle)))
{
if(!in_array($file, array('.', '..')))
{
$f = "{$dir}/{$file}";
echo("<br>{$f}");
unlink($f);
}
}
closedir($handle);
}
}
cleanup_compiled_files();
?> |
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
|
Back to top |
|
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Wed Feb 18, 2009 5:00 pm Post subject: Conditional clearance only |
|
|
Thanks for this API.
But will it try to clear the compiled files everytime a page is browsed? Won't this force to recompile the scripts everytime?
If so, this API would be highly useful to make admin tools. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Feb 18, 2009 5:18 pm Post subject: |
|
|
It clears the directory each time $smarty->clear_compiled_tpl() is called. This is not something you would want to do on every page load. |
|
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
|