00001 <?PHP
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 $page_author = $creator_name;
00018 $page_author_email = $creator_email;
00019 $page_menu = 1;
00020 $page_date = formatTime( time() );
00021 $page_title = i18n("System options");
00022
00026 function recurse_chown_chgrp($mypath, $uid, $gid)
00027 {
00028 $d = opendir ($mypath) ;
00029 while(($file = readdir($d)) !== false)
00030 {
00031 if ($file != "." && $file != "..")
00032 {
00033 $typepath = $mypath . "/" . $file;
00034
00035
00036 if (filetype ($typepath) == 'dir')
00037 recurse_chown_chgrp ($typepath, $uid, $gid);
00038
00039 chown($typepath, $uid);
00040 chgrp($typepath, $gid);
00041 }
00042 }
00043
00044 }
00045
00046 function chmodRecursive($mypath, $filePermission, $dirPermission)
00047 {
00048 $d = opendir( $mypath );
00049 while( ( $file = readdir( $d ) ) !== false )
00050 {
00051 if( $file != "." && $file != ".." )
00052 {
00053 $typepath = $mypath . "/" . $file;
00054
00055
00056 if (filetype ($typepath) == 'dir')
00057 {
00058 chmod( $typepath, $dirPermission );
00059 chmodRecursive( $typepath, $filePermission, $dirPermission );
00060 }
00061 else
00062 chmod( $typepath, $filePermission );
00063 }
00064 }
00065
00066 }
00067
00068 function systemOptionsLockdownUnlock()
00069 {
00070 global $systemOptions, $setup_folder;
00071
00072 if( $systemOptions["locked"] == 1 )
00073 {
00074 $filePermission = 0600;
00075 $dirPermission = 0700;
00076 }
00077 else
00078 {
00079 $filePermission = 0666;
00080 $dirPermission = 0777;
00081 }
00082
00083
00084 recurse_chown_chgrp( $setup_folder, posix_getuid(), posix_getgid() );
00085
00086
00087 chmodRecursive( $setup_folder, $filePermission, $dirPermission );
00088 }
00089
00090 function saveSystemOptions()
00091 {
00092 global $setup_folder, $systemOptions;
00093
00094 if( file_exists( "$setup_folder/systemOptions.php" ) )
00095 unlink( "$setup_folder/systemOptions.php" );
00096
00097 file_put_contents( "$setup_folder/systemOptions.php", array_export( $systemOptions, "systemOptions" ) );
00098 }
00099
00100 if( ! isAllowed("global_admin") )
00101 $page_content = loginform($language, globalIDtoURL( "setup/options" ), $auth_messages);
00102 else
00103 {
00104
00105
00106 if( $_POST["saveOptions"] )
00107 {
00108 $newLocked = $_POST["options"]["locked"] ? 1 : 0;
00109 $systemOptions["timeformat"] = $_POST["options"]["timeformat"];
00110 $systemOptions["rewrite"] = $_POST["options"]["rewrite"] ? 1 : 0;
00111 $systemOptions["humanurls"] = $_POST["options"]["humanurls"] ? 1 : 0;
00112 $systemOptions["permissionmessages"] = $_POST["options"]["permissionmessages"] ? 1 : 0;
00113
00114 saveSystemOptions();
00115
00116 if( $systemOptions["locked"] != $newLocked )
00117 {
00118 $systemOptions["locked"] = $newLocked;
00119 saveSystemOptions();
00120 systemOptionsLockdownUnlock();
00121 }
00122
00123 }
00124
00125 $systemOptionsPanel = new optionsPanel( "options" );
00126
00127 $systemOptionsPanel->addOption(
00128 i18n("Locked down"),
00129 i18n("Check this to lock the system down. This is the default option. If you unlock the system, it means that everybody on the server can view the files. Locked down gives only owner read/write rights, while unlocked means that the files are read and write enabled for all. Use this for site migration and emergencies only!"),
00130 $systemOptions["locked"],
00131 "locked",
00132 "checkbox"
00133 );
00134 $systemOptionsPanel->addOption(
00135 i18n("Default time format"),
00136 i18n("The format used by Travelsized to format dates, if the user has not set one manually. Set this using the format found in ##0##date section of the PHP manual##1##", array( "<a href=\"http://php.net/date\" target=\"_top\">", "</a>" ) ),
00137 $systemOptions["timeformat"],
00138 "timeformat",
00139 "text"
00140 );
00141 $systemOptionsPanel->addOption(
00142 i18n("Enable pretty URLs"),
00143 i18n("Use pretty URLs for links on the website"),
00144 $systemOptions["rewrite"],
00145 "rewrite",
00146 "checkbox"
00147 );
00148 $systemOptionsPanel->addOption(
00149 i18n("Human readable URLs"),
00150 i18n("If using pretty URLs, the addresses will be shown with their full human readable name in stead of the page ID."),
00151 $systemOptions["humanurls"],
00152 "humanurls",
00153 "checkbox"
00154 );
00155 $systemOptionsPanel->addOption(
00156 i18n("Permission messages"),
00157 i18n("Show a message describing why a user is unable to perform a certain action."),
00158 $systemOptions["permissionmessages"],
00159 "permissionmessages",
00160 "checkbox"
00161 );
00162
00163 $setupPage = new setupPage;
00164 $setupPage->addBreadcrumb( i18n("System options"), globalIDtoURL( "setup/options" ) );
00165 $setupPage->contents = $systemOptionsPanel->render();
00166 $page_content = "<form action=\"" . thisPageURL() . "\" method=\"POST\">" . $setupPage->render() . "</form>";
00167 }
00168 ?>