@@ -750,6 +750,55 @@ function is_ispconfig_ssl_enabled() {
750750 }
751751}
752752
753+ /**
754+ Function to find the hash file for timezone detection
755+ (c) 2012 Marius Cramer, pixcept KG, m.cramer@pixcept.de
756+ */
757+ function find_hash_file ($ hash , $ dir , $ basedir = '' ) {
758+ $ res = opendir ($ dir );
759+ if (!$ res ) return false ;
760+
761+ if (substr ($ dir , -1 ) === '/ ' ) $ dir = substr ($ dir , 0 , strlen ($ dir ) - 1 );
762+ if ($ basedir === '' ) $ basedir = $ dir ;
763+
764+ while ($ cur = readdir ($ res )) {
765+ if ($ cur == '. ' || $ cur == '.. ' ) continue ;
766+ $ entry = $ dir .'/ ' .$ cur ;
767+ if (is_dir ($ entry )) {
768+ $ result = find_hash_file ($ hash , $ entry , $ basedir );
769+ if ($ result !== false ) return $ result ;
770+ } elseif (md5_file ($ entry ) === $ hash ) {
771+ $ entry = substr ($ entry , strlen ($ basedir ));
772+ if (substr ($ entry , 0 , 7 ) === '/posix/ ' ) $ entry = substr ($ entry , 7 );
773+ return $ entry ;
774+ }
775+ }
776+ closedir ($ res );
777+ return false ;
778+ }
779+
780+ /**
781+ Function to get the timezone of the Linux system
782+ (c) 2012 Marius Cramer, pixcept KG, m.cramer@pixcept.de
783+ */
784+ function get_system_timezone () {
785+ if (is_link ('/etc/localtime ' )) {
786+ $ timezone = readlink ('/etc/localtime ' );
787+ $ timezone = str_replace ('/usr/share/zoneinfo/ ' , '' , $ timezone );
788+ if (substr ($ timezone , 0 , 6 ) === 'posix/ ' ) $ timezone = substr ($ timezone , 6 );
789+ } else {
790+ $ hash = md5_file ('/etc/localtime ' );
791+ $ timezone = find_hash_file ($ hash , '/usr/share/zoneinfo ' );
792+ }
793+
794+ if (!$ timezone ) {
795+ exec ('date +%Z ' , $ tzinfo );
796+ $ timezone = $ tzinfo [0 ];
797+ }
798+
799+ return $ timezone ;
800+ }
801+
753802
754803
755804?>
0 commit comments