public
Description: Git mirror of the CMS Made Simple 2.0 rewrite
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsmadesimple-2-0.git
Search Repo:
[#1424] Resolved install page incorrect php.ini settings detection - try 
get_cfg_var when ini_get fails and, if it returns anything, show a message 
that the value originally set in the configuration file is being shown 
(which may not be accurate), see 
http://dev.cmsmadesimple.org/tracker/index.php?func=detail&aid=1424&group_
id=6&atid=103

git-svn-id: http://svn.cmsmadesimple.org/svn/cmsmadesimple/trunk@3844 
3d254a34-79dc-0310-9e5f-be208747d8a0
dittmann (author)
Wed Mar 28 18:49:40 -0700 2007
commit  85083d2724d302b267180254adf6a934ed7c3e75
tree    a6e1bb143bad96e1ba88b5d287c562d5651aef24
parent  3a0569e6ff3da10876b3e2281e2021878c2b220a
...
27
28
29
 
30
31
32
...
62
63
64
 
 
 
65
66
67
...
71
72
73
 
74
75
76
77
78
 
79
80
81
...
27
28
29
30
31
32
33
...
63
64
65
66
67
68
69
70
71
...
75
76
77
78
79
80
81
82
83
84
85
86
87
0
@@ -27,6 +27,7 @@ p {
0
   font-size: 1em;
0
   font-family: Verdana, serif;
0
   background-color: white;
0
+ margin: 0;
0
 }
0
 
0
 h1 {
0
@@ -62,6 +63,9 @@ h3 {
0
   border-bottom: 1px solid #e7ab0b;
0
   border-left: 1.3em solid #e7ab0b; }
0
 
0
+form {
0
+ margin: .5em 0 .8em 0;
0
+}
0
 
0
 td, th {
0
   padding: 0.4em;
0
@@ -71,11 +75,13 @@ td, th {
0
 .success {
0
   color: #0C7A14;
0
   font-weight: bold;
0
+ margin-bottom: .5em;
0
 }
0
 
0
 .failure {
0
   color: #990000;
0
   font-weight: bold;
0
+ margin-bottom: .5em;
0
 }
0
 
0
 table {
...
18
19
20
21
 
22
23
24
25
26
 
27
28
29
30
31
 
 
32
33
34
35
 
 
36
37
38
39
 
 
40
41
42
43
 
 
44
45
46
47
48
 
49
50
51
...
58
59
60
61
 
62
63
64
...
87
88
89
90
 
 
91
92
93
...
97
98
99
100
 
101
102
103
...
106
107
108
 
 
 
109
110
111
...
119
120
121
122
123
124
125
126
127
...
142
143
144
145
 
146
147
148
...
18
19
20
 
21
22
23
24
25
 
26
27
28
29
 
 
30
31
32
33
 
 
34
35
36
37
 
 
38
39
40
41
 
 
42
43
44
45
46
47
 
48
49
50
51
...
58
59
60
 
61
62
63
64
...
87
88
89
 
90
91
92
93
94
...
98
99
100
 
101
102
103
104
...
107
108
109
110
111
112
113
114
115
...
123
124
125
 
 
 
126
127
128
...
143
144
145
 
146
147
148
149
0
@@ -18,34 +18,34 @@
0
 
0
 /**
0
  * Uses the CMSInstallerPage class
0
-*/
0
+ */
0
 require_once cms_join_path(CMS_INSTALL_BASE, 'lib', 'classes', 'CMSInstallerPage.class.php');
0
 
0
 /**
0
  * CMS Made Simple Installer
0
-*/
0
+ */
0
 class CMSInstaller
0
 {
0
   /**
0
- * @var int the total number of installer pages
0
- */
0
+ * @var int the total number of installer pages
0
+ */
0
   var $numberOfPages;
0
   /**
0
- * @var int the current page
0
- */
0
+ * @var int the current page
0
+ */
0
   var $currentPage;
0
   /**
0
- * @var object the Smarty object
0
- */
0
+ * @var object the Smarty object
0
+ */
0
   var $smarty;
0
   /**
0
- * @var array Errors to be shown
0
- */
0
+ * @var array errors to be shown
0
+ */
0
   var $errors;
0
   
0
   /**
0
    * Class constructor
0
- */
0
+ */
0
   function CMSInstaller()
0
   {
0
     $this->numberOfPages = 5;
0
@@ -58,7 +58,7 @@ class CMSInstaller
0
   /**
0
    * Loads smarty
0
    * @return boolean whether loading succeeded
0
- */
0
+ */
0
   function loadSmarty()
0
   {
0
     if (! is_readable(cms_join_path(CMS_BASE, 'lib', 'smarty', 'Smarty.class.php')))
0
@@ -87,7 +87,8 @@ class CMSInstaller
0
   
0
   /**
0
    * Shows an error page (without use of Smarty)
0
- */
0
+ * @var string $error
0
+ */
0
   function showErrorPage($error)
0
   {
0
     include cms_join_path(CMS_INSTALL_BASE, 'templates', 'installer_start.tpl');
0
@@ -97,7 +98,7 @@ class CMSInstaller
0
   
0
   /**
0
    * Runs the installer
0
- */
0
+ */
0
   function run()
0
   {
0
     // Load smarty, exit if failed
0
@@ -106,6 +107,9 @@ class CMSInstaller
0
       return;
0
     }
0
     
0
+ // Process submitted data
0
+ $db = $this->processSubmit();
0
+
0
     // Test for sessions on the first page
0
     if ($this->currentPage == 1)
0
     {
0
@@ -119,9 +123,6 @@ class CMSInstaller
0
       }
0
     }
0
     
0
- // Process submitted data
0
- $db = $this->processSubmit();
0
-
0
     // Create the (current) page object
0
     require_once cms_join_path(CMS_INSTALL_BASE, 'lib', 'classes', 'CMSInstallerPage' . $this->currentPage . '.class.php');
0
     $classname = 'CMSInstallerPage' . $this->currentPage;
0
@@ -142,7 +143,7 @@ class CMSInstaller
0
   /**
0
    * Processes submitted forms, redirects to previous page if needed
0
    * @return mixed Returns a ADOdb Connection object (for re-use) if created
0
- */
0
+ */
0
   function processSubmit()
0
   {
0
     switch ($this->currentPage)
...
18
19
20
21
22
23
24
25
26
27
28
 
 
 
29
30
31
32
33
34
35
36
37
 
 
 
38
39
 
40
41
42
...
54
55
56
57
 
58
59
60
 
 
61
62
63
...
69
70
71
72
 
73
74
75
...
78
79
80
81
 
 
 
 
 
 
 
 
82
83
84
85
 
86
87
88
89
90
91
92
93
94
95
 
 
 
96
97
98
99
100
101
102
 
103
104
105
106
 
107
108
109
110
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
113
114
115
 
116
117
118
 
119
120
121
...
125
126
127
128
 
129
130
131
...
136
137
138
139
 
140
141
142
...
144
145
146
147
148
149
150
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
152
153
154
155
156
157
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
160
 
161
162
163
...
18
19
20
 
21
22
23
24
25
26
 
27
28
29
30
31
32
33
34
35
 
 
 
36
37
38
39
 
40
41
42
43
...
55
56
57
 
58
59
 
 
60
61
62
63
64
...
70
71
72
 
73
74
75
76
...
79
80
81
 
82
83
84
85
86
87
88
89
90
91
92
 
93
94
 
 
 
 
 
 
 
 
 
95
96
97
98
99
100
 
 
 
 
101
102
103
104
 
105
106
107
108
109
 
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
 
138
139
140
141
 
142
143
144
145
...
149
150
151
 
152
153
154
155
...
160
161
162
 
163
164
165
166
...
168
169
170
 
 
 
 
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
 
 
 
 
 
 
 
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
 
222
223
224
225
0
@@ -18,25 +18,26 @@
0
 
0
 class CMSInstallerPage1 extends CMSInstallerPage
0
 {
0
-
0
   var $continueon;
0
   var $special_failed;
0
   var $images;
0
   
0
   /**
0
    * Class constructor
0
- */
0
+ * @var object $smarty
0
+ * @var array $errors
0
+ */
0
   function CMSInstallerPage1(&$smarty, $errors)
0
   {
0
     $this->CMSInstallerPage(1, $smarty, $errors);
0
     $this->continueon = true;
0
     $this->special_failed = false;
0
     $this->images = array();
0
- $this->images['true'] = '<img src="images/true.gif" alt="Success" height="16" width="16" border="0" />';
0
- $this->images['false'] = '<img src="images/false.gif" alt="Failure" height="16" width="16" border="0" />';
0
- $this->images['red'] = '<img src="images/red.gif" alt="Failure" height="16" width="16" border="0" />';
0
+ $this->images['true'] = '<img src="images/true.gif" alt="Success" height="16" width="16" border="0" />';
0
+ $this->images['false'] = '<img src="images/false.gif" alt="Failure" height="16" width="16" border="0" />';
0
+ $this->images['red'] = '<img src="images/red.gif" alt="Failure" height="16" width="16" border="0" />';
0
     $this->images['yellow'] = '<img src="images/yellow.gif" alt="Caution" height="16" width="16" border="0" />';
0
- $this->images['green'] = '<img src="images/green.gif" alt="Success" height="16" width="16" border="0" />';
0
+ $this->images['green'] = '<img src="images/green.gif" alt="Success" height="16" width="16" border="0" />';
0
   }
0
   
0
   function assignVariables()
0
@@ -54,10 +55,10 @@ class CMSInstallerPage1 extends CMSInstallerPage
0
     }
0
     
0
     $settings['recommended'][] = $this->testBoolean(0, 'Checking for basic XML (expat) support', function_exists('xml_parser_create'), 'XML support is not compiled into your php install. You can still use the system, but will not be able to use any of the remote module installation functions.');
0
- $settings['recommended'][] = $this->testBoolean(0, 'Checking file uploads', ini_get('file_uploads'), 'You will not be able to use any of the file uploading facilities included in CMS Made Simple. If possible, this restriction should be lifted by your system admin to properly use all file management features of the system. Proceed with caution.');
0
+ $settings['recommended'][] = $this->testIniBoolean(0, 'Checking file uploads', 'file_uploads', 'When file uploads are disabled you will not be able to use any of the file uploading facilities included in CMS Made Simple. If possible, this restriction should be lifted by your system admin to properly use all file management features of the system. Proceed with caution.');
0
     
0
- $settings['recommended'][] = $this->testRange('Checking PHP memory limit', ini_get('memory_limit'), '8M', '128M', 'You may not have enough memory to run CMSMS correctly. If possible, you should try to get your system admin to raise this value to 128M or greater. Proceed with caution.', true);
0
- $settings['recommended'][] = $this->testRange('Checking max upload file size', ini_get('upload_max_filesize'), '2M', '10M', 'You will probably not be able to upload larger files using the included file management functions. Please be aware of this restriction.', true);
0
+ $settings['recommended'][] = $this->testIniRange(0, 'Checking PHP memory limit', 'memory_limit', '8M', '128M', 'You may not have enough memory to run CMSMS correctly. If possible, you should try to get your system admin to raise this value. Proceed with caution.');
0
+ $settings['recommended'][] = $this->testIniRange(0, 'Checking max upload file size', 'upload_max_filesize', '2M', '10M', 'You will probably not be able to upload (larger) files using the included file management functions. Please be aware of this restriction.');
0
     $f = cms_join_path(CMS_BASE, 'uploads');
0
     $settings['recommended'][] = $this->testBoolean(0, "Checking if $f is writable", is_writable($f), 'The uploads folder is not writable. You can still install the system, but you will not be able to upload files via the Admin Panel.');
0
     $f = cms_join_path(CMS_BASE, 'modules');
0
@@ -69,7 +70,7 @@ class CMSInstallerPage1 extends CMSInstallerPage
0
     $settings['recommended'][] = $this->testBoolean(0, 'Checking if ini_set works', $result, 'Although the ability to override php ini settings is not mandatory, some addon (optional) functionality uses ini_set to extend timeouts, and allow uploading of larger files, etc. You may have difficulty with some addon functionality without this capability.');
0
     $settings['recommended'][] = $this->testBoolean(0, 'Checking if sessions are enabled', isset($_GET['sessiontest']) && isset($_SESSION['test']), 'Although the PHP support for sessions is not mandatory, it is highly recommended. Logins and other things may slow down and you may have difficulty with some addon functionality without this capability.');
0
     $settings['recommended'][] = $this->testBoolean(0, 'Checking for tokenizer functions', function_exists('token_get_all'), 'Not having the tokenizer could cause pages to render as purely white. We recommend you have this installed, but your website may work fine without it.');
0
- $settings['recommended'][] = $this->testBoolean(0, 'Checking for Safe mode', (! (bool) ini_get('safe_mode')), 'PHP Safe mode could create some problems with uploading files and other functions. It all depends on how strict your server safe mode settings are.');
0
+ $settings['recommended'][] = $this->testIniBoolean(0, 'Checking for Safe mode', 'safe_mode', 'PHP Safe mode could create some problems with uploading files and other functions. It all depends on how strict your server safe mode settings are.', true);
0
     
0
     // assign settings
0
     $this->smarty->assign('images', $this->images);
0
@@ -78,44 +79,67 @@ class CMSInstallerPage1 extends CMSInstallerPage
0
     $this->smarty->assign('special_failed', $this->special_failed);
0
   }
0
   
0
- function & testBoolean($required, $title, $result, $message = NULL)
0
+ /**
0
+ * @return object
0
+ * @var boolean $required
0
+ * @var string $title
0
+ * @var boolean $result
0
+ * @var string $message
0
+ */
0
+ function & testBoolean($required, $title, $result, $message = '')
0
   {
0
     $test =&new StdClass();
0
     $test->title = $title;
0
- if ($result == false)
0
+ if ((bool) $result == false)
0
     {
0
- if ($required)
0
- {
0
- $this->continueon = false;
0
- }
0
- else
0
- {
0
- $this->special_failed = true;
0
- }
0
- if ($message)
0
+ $required == true ? $this->continueon = false : $this->special_failed = true;
0
+
0
+ if (trim($message) != '')
0
       {
0
         $test->message = $message;
0
       }
0
- }
0
- if ($result == true)
0
- {
0
- $test->resultimage = $required ? $this->images['true'] : $this->images['green'];
0
+ $test->resultimage = $required ? $this->images['false'] : $this->images['yellow'];
0
     }
0
     else
0
     {
0
- $test->resultimage = $required ? $this->images['false'] : $this->images['yellow'];
0
+ $test->resultimage = $required ? $this->images['true'] : $this->images['green'];
0
     }
0
     return $test;
0
   }
0
   
0
- function & testRange($title, $value, $minimum, $recommended, $message = NULL, $compare_as_bytes = false)
0
+ /**
0
+ * @return object
0
+ * @var boolean $required
0
+ * @var string $title
0
+ * @var boolean $result
0
+ * @var string $message
0
+ * @var boolean $negative_test
0
+ */
0
+ function & testIniBoolean($required, $title, $varname, $message = '', $negative_test = false)
0
+ {
0
+ $str = ini_get($varname);
0
+ $result = $negative_test ? (! (bool) $str) : (bool) $str;
0
+ return $this->testBoolean($required, $title, $result, $message);
0
+ }
0
+
0
+ /**
0
+ * @return object
0
+ * @var boolean $required
0
+ * @var string $title
0
+ * @var mixed $value
0
+ * @var mixed $minimum
0
+ * @var mixed $recommended
0
+ * @var string $message
0
+ * @var boolean $test_as_bytes
0
+ */
0
+ function & testRange($required, $title, $value, $minimum, $recommended, $message = '', $test_as_bytes = false)
0
   {
0
     $test =& new StdClass();
0
- $test->title = $title . " (min $minimum, recommend $recommended)";
0
     
0
+ $test->title = $title . " (min $minimum, recommend $recommended)";
0
     $test->value = $value;
0
     
0
- if (! is_int($minimum) && ! is_int($recommended) && $compare_as_bytes == TRUE)
0
+ if ($test_as_bytes)
0
     {
0
       $value = $this->returnBytes($value);
0
       $minimum = $this->returnBytes($minimum);
0
@@ -125,7 +149,7 @@ class CMSInstallerPage1 extends CMSInstallerPage
0
     if ($value < $minimum)
0
     {
0
       $test->resultimage = $this->images['red'];
0
- $this->special_failed = true;
0
+ $required == true ? $this->continueon = false : $this->special_failed = true;
0
     }
0
     elseif ($value < $recommended)
0
     {
0
@@ -136,7 +160,7 @@ class CMSInstallerPage1 extends CMSInstallerPage
0
       $test->resultimage = $this->images['green'];
0
     }
0
     
0
- if ($value < $recommended)
0
+ if ($value < $recommended && trim($message) != '')
0
     {
0
       $test->message = $message;
0
     }
0
@@ -144,20 +168,58 @@ class CMSInstallerPage1 extends CMSInstallerPage
0
     return $test;
0
   }
0
   
0
- function returnBytes($val) {
0
- $val = trim($val);
0
- $last = strtolower($val{strlen($val)-1});
0
- switch($last)
0
+ /**
0
+ * @return object
0
+ * @var boolean $required
0
+ * @var string $title
0
+ * @var string $varname
0
+ * @var string $minimum
0
+ * @var string $recommended
0
+ * @var string $message
0
+ * @var boolean $test_as_bytes
0
+ */
0
+ function & testIniRange($required, $title, $varname, $minimum, $recommended, $message = '', $test_as_bytes = true)
0
+ {
0
+ $str = ini_get($varname);
0
+ if ($str == '')
0
+ {
0
+ $error = 'Could not retrieve a value.... passing anyways.';
0
+ $required = false;
0
+ if ((string) get_cfg_var($varname) != '')
0
+ {
0
+ $str = (string) get_cfg_var($varname);
0
+ $error .= '<br />Displaying the value originally set in the config file (this may not be accurate).';
0
+ }
0
+ }
0
+ $test =& $this->testRange($required, $title, $str, $minimum, $recommended, $message, $test_as_bytes);
0
+ if (isset($error))
0
     {
0
- // The 'G' modifier is available since PHP 5.1.0
0
- case 'g':
0
- $val *= 1024;
0
- case 'm':
0
- $val *= 1024;
0
- case 'k':
0
- $val *= 1024;
0
+ $test->error = $error;
0
+ }
0
+ return $test;
0
+ }
0
+
0
+ /**
0
+ * @var string $val
0
+ * @return int
0
+ */
0
+ function returnBytes($val)
0
+ {
0
+ if (is_string($val) && $val != '')
0
+ {
0
+ $val = trim($val);
0
+ $last = strtolower($val{strlen($val)-1});
0
+ switch($last)
0
+ {
0
+ case 'g':
0
+ $val *= 1024;
0
+ case 'm':
0
+ $val *= 1024;
0
+ case 'k':
0
+ $val *= 1024;
0
+ }
0
     }
0
- return $val;
0
+ return (int) $val;
0
   }
0
 }
0
 
...
33
34
35
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
38
39
...
82
83
84
85
 
86
87
 
88
89
90
91
 
 
 
92
93
94
...
33
34
35
 
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
...
95
96
97
 
98
99
 
100
101
 
 
 
102
103
104
105
106
107
0
@@ -33,7 +33,20 @@
0
   <tbody>
0
 {foreach from=$settings.recommended item=test}
0
     <tr class="{cycle values='row1,row2'}">
0
- <td>{if isset($test->value)}<span class="have">You have {$test->value}</span>{/if}{$test->title}{if isset($test->message)}<br /><br /><em>{$test->message}</em>{/if}</td>
0
+ <td>
0
+{if isset($test->value) && $test->value != ''}
0
+ <span class="have">You have {$test->value}</span>
0
+{/if}
0
+ {$test->title}
0
+{if isset($test->error)}
0
+ <p class="error">{$test->error}</p>
0
+{/if}
0
+{if isset($test->message)}
0
+ <p>
0
+ <em>{$test->message}</em>
0
+ <p>
0
+{/if}
0
+ </td>
0
       <td class="col2">{$test->resultimage}</td>
0
     </tr>
0
 {/foreach}
0
@@ -82,13 +95,13 @@
0
 {else}
0
   <p class="success" align="center">All tests passed (at least at a minimum level). Please click the Continue button.</p>
0
 {/if}
0
-<p class="continue" align="center">
0
+ <p class="continue" align="center">
0
 {if $special_failed}
0
- <input type="Submit" name="recheck" value="Try Again" />
0
+ <input type="Submit" name="recheck" value="Try Again" />
0
 {/if}
0
- <input type="submit" value="Continue" />
0
- <input type="hidden" name="page" value="2" />
0
-</p>
0
+ <input type="submit" value="Continue" />
0
+ <input type="hidden" name="page" value="2" />
0
+ </p>
0
 {else}
0
   <p class="failure" align="center">One or more tests have failed. Please correct the problem and click the button below to recheck.</p>
0
   <p class="continue" align="center"><input type="Submit" value="Try Again" /></p>

Comments

    No one has commented yet.