Completed
Push — develop ( ddb47a...769270 )
by Agel_Nash
09:22
created
manager/processors/save_settings.processor.php 1 patch
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('settings')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 $data = $_POST;
9 9
 // lose the POST now, gets rid of quirky issue with Safari 3 - see FS#972
@@ -11,41 +11,41 @@  discard block
 block discarded – undo
11 11
 
12 12
 if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false)
13 13
 {
14
-	$htaccess        = $modx->config['base_path'] . '.htaccess';
15
-	$sample_htaccess = $modx->config['base_path'] . 'ht.access';
16
-	$dir = '/' . trim($modx->config['base_url'],'/');
17
-	if(is_file($htaccess))
18
-	{
19
-		$_ = file_get_contents($htaccess);
20
-		if(strpos($_,'RewriteBase')===false)
21
-		{
22
-			$warnings[] = $_lang["settings_friendlyurls_alert2"];
23
-		}
24
-		elseif(is_writable($htaccess))
25
-		{
26
-			$_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_);
27
-			if(!@file_put_contents($htaccess,$_))
28
-			{
29
-				$warnings[] = $_lang["settings_friendlyurls_alert2"];
30
-			}
31
-		}
32
-	}
33
-	elseif(is_file($sample_htaccess))
34
-	{
35
-		if(!@rename($sample_htaccess,$htaccess))
14
+    $htaccess        = $modx->config['base_path'] . '.htaccess';
15
+    $sample_htaccess = $modx->config['base_path'] . 'ht.access';
16
+    $dir = '/' . trim($modx->config['base_url'],'/');
17
+    if(is_file($htaccess))
18
+    {
19
+        $_ = file_get_contents($htaccess);
20
+        if(strpos($_,'RewriteBase')===false)
36 21
         {
37
-        	$warnings[] = $_lang["settings_friendlyurls_alert"];
38
-		}
39
-		elseif($modx->config['base_url']!=='/')
40
-		{
41
-			$_ = file_get_contents($htaccess);
42
-			$_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_);
43
-			if(!@file_put_contents($htaccess,$_))
44
-			{
45
-				$warnings[] = $_lang["settings_friendlyurls_alert2"];
46
-			}
47
-		}
48
-	}
22
+            $warnings[] = $_lang["settings_friendlyurls_alert2"];
23
+        }
24
+        elseif(is_writable($htaccess))
25
+        {
26
+            $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_);
27
+            if(!@file_put_contents($htaccess,$_))
28
+            {
29
+                $warnings[] = $_lang["settings_friendlyurls_alert2"];
30
+            }
31
+        }
32
+    }
33
+    elseif(is_file($sample_htaccess))
34
+    {
35
+        if(!@rename($sample_htaccess,$htaccess))
36
+        {
37
+            $warnings[] = $_lang["settings_friendlyurls_alert"];
38
+        }
39
+        elseif($modx->config['base_url']!=='/')
40
+        {
41
+            $_ = file_get_contents($htaccess);
42
+            $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_);
43
+            if(!@file_put_contents($htaccess,$_))
44
+            {
45
+                $warnings[] = $_lang["settings_friendlyurls_alert2"];
46
+            }
47
+        }
48
+    }
49 49
 }
50 50
 
51 51
 if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) {
@@ -56,22 +56,22 @@  discard block
 block discarded – undo
56 56
 $data['rb_base_dir']      = str_replace('[(base_path)]',MODX_BASE_PATH,$data['rb_base_dir']);
57 57
 
58 58
 if (isset($data) && count($data) > 0) {
59
-	if(isset($data['manager_language'])) {
60
-		$lang_path = MODX_MANAGER_PATH . 'includes/lang/' . $data['manager_language'] . '.inc.php';
61
-		if(is_file($lang_path)) {
62
-			include($lang_path);
59
+    if(isset($data['manager_language'])) {
60
+        $lang_path = MODX_MANAGER_PATH . 'includes/lang/' . $data['manager_language'] . '.inc.php';
61
+        if(is_file($lang_path)) {
62
+            include($lang_path);
63 63
             global $modx_lang_attribute;
64 64
             $data['lang_code'] = !$modx_lang_attribute ? 'en' : $modx_lang_attribute;
65
-		}
66
-	}
67
-	$savethese = array();
68
-	$data['sys_files_checksum'] = $modx->manager->getSystemChecksum($data['check_files_onlogin']);
69
-	$data['mail_check_timeperiod'] = (int)$data['mail_check_timeperiod'] < 60 ? 60 : $data['mail_check_timeperiod']; // updateMail() in mainMenu no faster than every minute
70
-	foreach ($data as $k => $v) {
71
-		switch ($k) {
72
-			case 'site_name':
73
-				$v = htmlspecialchars($v);
74
-				break;
65
+        }
66
+    }
67
+    $savethese = array();
68
+    $data['sys_files_checksum'] = $modx->manager->getSystemChecksum($data['check_files_onlogin']);
69
+    $data['mail_check_timeperiod'] = (int)$data['mail_check_timeperiod'] < 60 ? 60 : $data['mail_check_timeperiod']; // updateMail() in mainMenu no faster than every minute
70
+    foreach ($data as $k => $v) {
71
+        switch ($k) {
72
+            case 'site_name':
73
+                $v = htmlspecialchars($v);
74
+                break;
75 75
             case 'settings_version':{
76 76
                 if($modx->getVersionData('version')!=$data['settings_version']){
77 77
                     $modx->logEvent(17,2,'<pre>'.var_export($data['settings_version'],true).'</pre>','fake settings_version');
@@ -79,24 +79,24 @@  discard block
 block discarded – undo
79 79
                 }
80 80
                 break;
81 81
             }
82
-			case 'error_page':
83
-			case 'unauthorized_page':
84
-			if (trim($v) == '' || !is_numeric($v)) {
85
-				$v = $data['site_start'];
86
-			}
87
-			break;
82
+            case 'error_page':
83
+            case 'unauthorized_page':
84
+            if (trim($v) == '' || !is_numeric($v)) {
85
+                $v = $data['site_start'];
86
+            }
87
+            break;
88 88
 
89
-			case 'lst_custom_contenttype':
90
-			case 'txt_custom_contenttype':
91
-				// Skip these
92
-				$k = '';
93
-				break;
94
-			case 'rb_base_dir':
95
-			case 'rb_base_url':
96
-			case 'filemanager_path':
97
-				$v = trim($v);
98
-				$v = rtrim($v,'/') . '/';
99
-				break;
89
+            case 'lst_custom_contenttype':
90
+            case 'txt_custom_contenttype':
91
+                // Skip these
92
+                $k = '';
93
+                break;
94
+            case 'rb_base_dir':
95
+            case 'rb_base_url':
96
+            case 'filemanager_path':
97
+                $v = trim($v);
98
+                $v = rtrim($v,'/') . '/';
99
+                break;
100 100
             case 'manager_language':
101 101
                 $langDir = realpath(MODX_MANAGER_PATH . 'includes/lang');
102 102
                 $langFile = realpath(MODX_MANAGER_PATH . 'includes/lang/' . $v . '.inc.php');
@@ -104,56 +104,56 @@  discard block
 block discarded – undo
104 104
                 if($langDir !== $langFileDir || !file_exists($langFile)) {
105 105
                     $v = 'english';
106 106
                 }
107
-				break;
108
-			case 'smtppw':
109
-				if ($v !== '********************' && $v !== '') {
110
-					$v = trim($v);
111
-					$v = base64_encode($v) . substr(str_shuffle('abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'), 0, 7);
112
-					$v = str_replace('=','%',$v);
113
-				} elseif ($v === '********************') {
114
-					$k = '';
115
-				}
116
-				break;
107
+                break;
108
+            case 'smtppw':
109
+                if ($v !== '********************' && $v !== '') {
110
+                    $v = trim($v);
111
+                    $v = base64_encode($v) . substr(str_shuffle('abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'), 0, 7);
112
+                    $v = str_replace('=','%',$v);
113
+                } elseif ($v === '********************') {
114
+                    $k = '';
115
+                }
116
+                break;
117 117
             case 'valid_hostnames':
118
-				$v = str_replace(array(' ,', ', '), ',', $v);
119
-				if ($v !== ',') {
120
-					$v = ($v != 'MODX_SITE_HOSTNAMES') ? $v : '';
121
-					$configString = '<?php' . "\n" . 'define(\'MODX_SITE_HOSTNAMES\', \'' . $v . '\');' . "\n";
122
-					@file_put_contents(MODX_BASE_PATH . 'assets/cache/siteHostnames.php', $configString);
123
-				}
124
-				$k = '';
125
-				break;
126
-			case 'session_timeout':
127
-				$mail_check_timeperiod = $data['mail_check_timeperiod'];
128
-				$v = (int)$v < ($data['mail_check_timeperiod']/60+1) ? ($data['mail_check_timeperiod']/60+1) : $v; // updateMail() in mainMenu pings as per mail_check_timeperiod, so +1min is minimum
129
-				break;
130
-			default:
131
-			break;
132
-		}
133
-		$v = is_array($v) ? implode(",", $v) : $v;
118
+                $v = str_replace(array(' ,', ', '), ',', $v);
119
+                if ($v !== ',') {
120
+                    $v = ($v != 'MODX_SITE_HOSTNAMES') ? $v : '';
121
+                    $configString = '<?php' . "\n" . 'define(\'MODX_SITE_HOSTNAMES\', \'' . $v . '\');' . "\n";
122
+                    @file_put_contents(MODX_BASE_PATH . 'assets/cache/siteHostnames.php', $configString);
123
+                }
124
+                $k = '';
125
+                break;
126
+            case 'session_timeout':
127
+                $mail_check_timeperiod = $data['mail_check_timeperiod'];
128
+                $v = (int)$v < ($data['mail_check_timeperiod']/60+1) ? ($data['mail_check_timeperiod']/60+1) : $v; // updateMail() in mainMenu pings as per mail_check_timeperiod, so +1min is minimum
129
+                break;
130
+            default:
131
+            break;
132
+        }
133
+        $v = is_array($v) ? implode(",", $v) : $v;
134 134
 
135
-		$modx->config[$k] = $v;
135
+        $modx->config[$k] = $v;
136 136
 
137
-		if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')';
138
-	}
137
+        if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')';
138
+    }
139 139
 
140
-	// Run a single query to save all the values
141
-	$sql = "REPLACE INTO ".$modx->getFullTableName("system_settings")." (setting_name, setting_value)
140
+    // Run a single query to save all the values
141
+    $sql = "REPLACE INTO ".$modx->getFullTableName("system_settings")." (setting_name, setting_value)
142 142
 		VALUES ".implode(', ', $savethese);
143
-	$modx->db->query($sql);
143
+    $modx->db->query($sql);
144 144
 
145
-	// Reset Template Pages
146
-	if (isset($data['reset_template'])) {
147
-		$newtemplate = (int)$data['default_template'];
148
-		$oldtemplate = (int)$data['old_template'];
149
-		$tbl = $modx->getFullTableName('site_content');
150
-		$reset = $data['reset_template'];
151
-		if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'");
152
-		else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'");
153
-	}
145
+    // Reset Template Pages
146
+    if (isset($data['reset_template'])) {
147
+        $newtemplate = (int)$data['default_template'];
148
+        $oldtemplate = (int)$data['old_template'];
149
+        $tbl = $modx->getFullTableName('site_content');
150
+        $reset = $data['reset_template'];
151
+        if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'");
152
+        else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'");
153
+    }
154 154
 
155
-	// empty cache
156
-	$modx->clearCache('full');
155
+    // empty cache
156
+    $modx->clearCache('full');
157 157
 }
158 158
 $header="Location: index.php?a=7&r=10";
159 159
 header($header);
Please login to merge, or discard this patch.