summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0832d30)
raw | patch | inline | side by side (parent: 0832d30)
author | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 3 Jun 2005 12:51:23 +0000 (12:51 +0000) | ||
committer | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 3 Jun 2005 12:51:23 +0000 (12:51 +0000) |
html/index.php | patch | blob | history | |
include/functions.inc | patch | blob | history |
diff --git a/html/index.php b/html/index.php
index 0c500192130002e8bd4cb53bc76beec4a0801f27..6ce9e7f49bd9c313fee174d76f428c80f8cd3b15 100644 (file)
--- a/html/index.php
+++ b/html/index.php
exit();
}
+/* Check for old files in compile directory */
+clean_smarty_compile_dir($smarty->compile_dir);
/* Language setup */
if ($config->data['MAIN']['LANG'] == ""){
diff --git a/include/functions.inc b/include/functions.inc
index ea9bed49ebccfbec02fade4d62f1d2fc63f8ff87..8aaf46b9b050dbac53d2cdc9649a79a0e2dc6e1f 100644 (file)
--- a/include/functions.inc
+++ b/include/functions.inc
define ("CONFIG_DIR", "/etc/gosa");
define ("CONFIG_TEMPLATE_DIR", "../contrib/");
+/* Define globals for revision comparing */
+$svn_path = '$HeadURL$';
+$svn_revision = '$Revision$';
+
/* Include required files */
require_once ("class_ldap.inc");
require_once ("class_config.inc");
function get_gosa_version()
{
- /* Variables filled in by subversion */
- $svn_path = '$HeadURL$';
- $svn_revision = '$Revision$';
+ global $svn_revision, $svn_path;
/* Extract informations */
$revision= preg_replace('/^[^0-9]*([0-9]+)[^0-9]*$/', '\1', $svn_revision);
function clean_smarty_compile_dir($directory)
{
- $svn_revision = '$Revision$';
+ global $svn_revision;
+
+ if(is_dir($directory) && is_readable($directory)) {
+ // Set revision filename to REVISION
+ $revision_file= $directory."/REVISION";
- /* Is there a stamp containing the current revision? */
- # check for "$config->...['CONFIG']/revision" and the
- # contents should match the revision number
+ /* Is there a stamp containing the current revision? */
+ if(!file_exists($revision_file)) {
+ // create revision file
+ create_revision($revision_file, $svn_revision);
+ } else {
+ # check for "$config->...['CONFIG']/revision" and the
+ # contents should match the revision number
+ if(!compare_revision($revision_file, $svn_revision)){
+ // If revision differs, clean compile directory
+ foreach(scandir($directory) as $file) {
+ if(!is_link($file) && is_writable($file)) {
+ // delete file
+ if(!unlink($file)) {
+ // This should never be reached
+ }
+ }
+ }
+ }
+ }
+ }
+
/* No, the revision has changed - and possibly the templates/translations.
Drop the contents of $directory now... */
- if (true){
+ //if (true){
+
+ // foreach($files as $file) {
+ // if(!is_link($file) && is_writable($file)) {
+ // // Delete File
+ // if(!unlink($file)){
+ // // File could not be deleted
+ // }
+ // }
+ // }
# Recursively delete contents "$config->...['CONFIG']". and create
# new revision file. NO folow symlinks!!!
- ;
- }
+ // ;
+ //}
+
+}
+
+function create_revision($revision_file, $revision)
+{
+ $result= false;
+ if(is_dir(dirname($revision_file)) && is_writable(dirname($revision_file))) {
+ if($fh= fopen($revision_file, "w")) {
+ if(fwrite($fh, $revision)) {
+ $result= true;
+ }
+ }
+ fclose($fh);
+ } else {
+ // Can not write to file
+ }
+
+ return $result;
}
+function compare_revision($revision_file, $revision)
+{
+ // false means revision differs
+ $result= false;
+
+ if(file_exists($revision_file) && is_readable($revision_file)) {
+ // Open file
+ if($fh= fopen($revision_file, "r")) {
+ // Compare File contents with current revision
+ if($revision == fread($fh, filesize($revision_file))) {
+ $result= true;
+ }
+ } else {
+ print_red("Can not open revision file");
+ }
+ // Close file
+ fclose($fh);
+ }
+
+ return $result;
+}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>