@@ -33,32 +33,254 @@ class FireGento_Debug_Block_Diagnostic_CheckSystem
3333 extends Mage_Adminhtml_Block_Template
3434{
3535 /**
36- * Checks if one or more caches are active
37- *
38- * @return string Cache Message
36+ * @var Varien_Object
3937 */
40- public function checkCaches ()
38+ protected $ _system ;
39+
40+ /**
41+ * @return FireGento_Debug_Helper_Firegento
42+ */
43+ protected function _getHelper ()
44+ {
45+ return Mage::helper ('firegento/firegento ' );
46+ }
47+
48+ /**
49+ * @return Varien_Db_Adapter_Pdo_Mysql
50+ */
51+ protected function _getDb ()
52+ {
53+ return Mage::getSingleton ('core/resource ' )->getConnection ('core_read ' );
54+ }
55+
56+ /**
57+ * @return void
58+ */
59+ protected function _construct ()
60+ {
61+ $ system = new Varien_Object ();
62+
63+ /*
64+ * MAGENTO
65+ */
66+ $ magento = array (
67+ 'edition ' => Mage::getEdition (),
68+ 'version ' => Mage::getVersion (),
69+ 'developer_mode ' => Mage::getIsDeveloperMode (),
70+ 'secret_key ' => Mage::getStoreConfigFlag ('admin/security/use_form_key ' ),
71+ 'flat_catalog_category ' => Mage::getStoreConfigFlag ('catalog/frontend/flat_catalog_category ' ),
72+ 'flat_catalog_product ' => Mage::getStoreConfigFlag ('catalog/frontend/flat_catalog_product ' ),
73+ 'cache_status ' => $ this ->_getHelper ()->checkCaches (),
74+ 'index_status ' => $ this ->_getHelper ()->checkIndizes ()
75+ );
76+ $ system ->setData ('magento ' , new Varien_Object ($ magento ));
77+
78+ /*
79+ * SERVER
80+ */
81+
82+ $ server = array (
83+ 'domain ' => isset ($ _SERVER ['HTTP_HOST ' ]) ? str_replace ('www. ' , '' , $ _SERVER ['HTTP_HOST ' ]) : null ,
84+ 'ip ' => $ _SERVER ['SERVER_ADDR ' ],
85+ 'dir ' => Mage::getBaseDir (),
86+ 'info ' => php_uname (),
87+
88+ );
89+ $ system ->setData ('server ' , new Varien_Object ($ server ));
90+
91+ /*
92+ * PHP
93+ */
94+
95+ $ php = array (
96+ 'version ' => @phpversion (),
97+ 'server_api ' => @php_sapi_name (),
98+ 'memory_limit ' => @ini_get ('memory_limit ' ),
99+ 'max_execution_time ' => @ini_get ('max_execution_time ' )
100+ );
101+ $ system ->setData ('php ' , new Varien_Object ($ php ));
102+
103+ /*
104+ * MySQL
105+ */
106+
107+ // Get MySQL Server API
108+ $ connection = $ this ->_getDb ()->getConnection ();
109+ if ($ connection instanceof PDO ) {
110+ $ mysqlServerApi = $ connection ->getAttribute (PDO ::ATTR_CLIENT_VERSION );
111+ } else {
112+ $ mysqlServerApi = 'n/a ' ;
113+ }
114+
115+ // Get table prefix
116+ $ tablePrefix = (string ) Mage::getConfig ()->getTablePrefix ();
117+ if (empty ($ tablePrefix )) {
118+ $ tablePrefix = $ this ->__ ('Disabled ' );
119+ }
120+
121+ // Get MySQL vars
122+ $ sqlQuery = "SHOW VARIABLES WHERE `Variable_name` IN ('connect_timeout','wait_timeout') " ;
123+ $ sqlResult = $ this ->_getDb ()->fetchAll ($ sqlQuery );
124+ $ mysqlVars = array ();
125+ foreach ($ sqlResult as $ mysqlVar ) {
126+ $ mysqlVars [$ mysqlVar ['Variable_name ' ]] = $ mysqlVar ['Value ' ];
127+ }
128+
129+ $ mysql = array (
130+ 'version ' => $ this ->_getDb ()->getServerVersion (),
131+ 'server_api ' => $ mysqlServerApi ,
132+ 'database_name ' => (string ) Mage::getConfig ()->getNode ('global/resources/default_setup/connection/dbname ' ),
133+ 'database_tables ' => count ($ this ->_getDb ()->listTables ()),
134+ 'table_prefix ' => $ tablePrefix ,
135+ 'connection_timeout ' => $ mysqlVars ['connect_timeout ' ].' sec. ' ,
136+ 'wait_timeout ' => $ mysqlVars ['wait_timeout ' ].' sec. '
137+ );
138+ $ system ->setData ('mysql ' , new Varien_Object ($ mysql ));
139+
140+ /*
141+ * System Requirements
142+ */
143+
144+ $ safeMode = (@ini_get ('safe_mode ' )) ? true : false ;
145+ $ memoryLimit = $ php ['memory_limit ' ];
146+ $ memoryLimit = substr ($ memoryLimit , 0 , strlen ($ memoryLimit ) -1 );
147+ $ phpCurl = @extension_loaded ('curl ' );
148+ $ phpDom = @extension_loaded ('dom ' );
149+ $ phpGd = @extension_loaded ('gd ' );
150+ $ phpHash = @extension_loaded ('hash ' );
151+ $ phpIconv = @extension_loaded ('iconv ' );
152+ $ phpMcrypt = @extension_loaded ('mcrypt ' );
153+ $ phpPcre = @extension_loaded ('pcre ' );
154+ $ phpPdo = @extension_loaded ('pdo ' );
155+ $ phpPdoMysql = @extension_loaded ('pdo_mysql ' );
156+ $ phpSimplexml = @extension_loaded ('simplexml ' );
157+
158+ $ requirements = array (
159+ 'php_version ' => array (
160+ 'label ' => 'PHP Version: ' ,
161+ 'recommended_value ' => '>= 5.3.0 ' ,
162+ 'current_value ' => $ php ['version ' ],
163+ 'result ' => version_compare ($ php ['version ' ], '5.3.0 ' , '>= ' )
164+ ),
165+ 'mysql_version ' => array (
166+ 'label ' => 'MySQL Version: ' ,
167+ 'recommended_value ' => '>= 4.1.20 ' ,
168+ 'current_value ' => $ mysql ['version ' ],
169+ 'result ' => version_compare ($ mysql ['version ' ], '4.1.20 ' , '>= ' ),
170+ ),
171+ 'safe_mode ' => array (
172+ 'label ' => 'Safe Mode: ' ,
173+ 'recommended_value ' => $ this ->renderBooleanField (false ),
174+ 'current_value ' => $ this ->renderBooleanField ($ safeMode ),
175+ 'result ' => !$ safeMode ,
176+ ),
177+ 'memory_limit ' => array (
178+ 'label ' => 'Memory Limit: ' ,
179+ 'recommended_value ' => '>= 256M ' ,
180+ 'current_value ' => $ php ['memory_limit ' ],
181+ 'result ' => ($ memoryLimit >= 256 ),
182+ ),
183+ 'max_execution_time ' => array (
184+ 'label ' => 'Max. Execution Time: ' ,
185+ 'recommended_value ' => '>= 360 sec. ' ,
186+ 'current_value ' => $ php ['max_execution_time ' ],
187+ 'result ' => ($ php ['max_execution_time ' ] >= 360 ),
188+ ),
189+ 'curl ' => array (
190+ 'label ' => 'curl ' ,
191+ 'recommended_value ' => $ this ->renderBooleanField (true ),
192+ 'current_value ' => $ this ->renderBooleanField ($ phpCurl ),
193+ 'result ' => $ phpCurl ,
194+ ),
195+ 'dom ' => array (
196+ 'label ' => 'dom ' ,
197+ 'recommended_value ' => $ this ->renderBooleanField (true ),
198+ 'current_value ' => $ this ->renderBooleanField ($ phpDom ),
199+ 'result ' => $ phpDom ,
200+ ),
201+ 'gd ' => array (
202+ 'label ' => 'gd ' ,
203+ 'recommended_value ' => $ this ->renderBooleanField (true ),
204+ 'current_value ' => $ this ->renderBooleanField ($ phpGd ),
205+ 'result ' => $ phpGd ,
206+ ),
207+ 'hash ' => array (
208+ 'label ' => 'hash ' ,
209+ 'recommended_value ' => $ this ->renderBooleanField (true ),
210+ 'current_value ' => $ this ->renderBooleanField ($ phpHash ),
211+ 'result ' => $ phpHash ,
212+ ),
213+ 'iconv ' => array (
214+ 'label ' => 'iconv ' ,
215+ 'recommended_value ' => $ this ->renderBooleanField (true ),
216+ 'current_value ' => $ this ->renderBooleanField ($ phpIconv ),
217+ 'result ' => $ phpIconv ,
218+ ),
219+ 'mcrypt ' => array (
220+ 'label ' => 'mcrypt ' ,
221+ 'recommended_value ' => $ this ->renderBooleanField (true ),
222+ 'current_value ' => $ this ->renderBooleanField ($ phpMcrypt ),
223+ 'result ' => $ phpMcrypt ,
224+ ),
225+ 'pcre ' => array (
226+ 'label ' => 'pcre ' ,
227+ 'recommended_value ' => $ this ->renderBooleanField (true ),
228+ 'current_value ' => $ this ->renderBooleanField ($ phpPcre ),
229+ 'result ' => $ phpPcre ,
230+ ),
231+ 'pdo ' => array (
232+ 'label ' => 'pdo ' ,
233+ 'recommended_value ' => $ this ->renderBooleanField (true ),
234+ 'current_value ' => $ this ->renderBooleanField ($ phpPdo ),
235+ 'result ' => $ phpPdo ,
236+ ),
237+ 'pdo_mysql ' => array (
238+ 'label ' => 'pdo_mysql ' ,
239+ 'recommended_value ' => $ this ->renderBooleanField (true ),
240+ 'current_value ' => $ this ->renderBooleanField ($ phpPdoMysql ),
241+ 'result ' => $ phpPdoMysql ,
242+ ),
243+ 'simplexml ' => array (
244+ 'label ' => 'simplexml ' ,
245+ 'recommended_value ' => $ this ->renderBooleanField (true ),
246+ 'current_value ' => $ this ->renderBooleanField ($ phpSimplexml ),
247+ 'result ' => $ phpSimplexml ,
248+ )
249+ );
250+ $ system ->setData ('requirements ' , new Varien_Object ($ requirements ));
251+
252+ $ this ->_system = $ system ;
253+ }
254+
255+ /**
256+ * @return Varien_Object
257+ */
258+ public function getSystem ()
41259 {
42- return Mage:: helper ( ' firegento/firegento ' )-> checkCaches () ;
260+ return $ this -> _system ;
43261 }
44262
45263 /**
46- * Checks if all indexes are up-to-date
47- *
48- * @return string Indexes Message
264+ * @param boolen $value
265+ * @return string
49266 */
50- public function checkIndizes ( )
267+ public function renderBooleanField ( $ value )
51268 {
52- return Mage::helper ('firegento/firegento ' )->checkIndizes ();
269+ if ($ value ) {
270+ return $ this ->__ ('Enabled ' );
271+ }
272+ return $ this ->__ ('Disabled ' );
53273 }
54274
55275 /**
56- * Returns a small system check report with some essential properties
57- *
58- * @return array Extension Check Result
276+ * @param $result
277+ * @return string
59278 */
60- public function checkSystem ( )
279+ public function renderRequirementValue ( $ result )
61280 {
62- return Mage::helper ('firegento/firegento ' )->checkSystem ();
281+ if ($ result ) {
282+ return 'requirement-passed ' ;
283+ }
284+ return 'requirement-failed ' ;
63285 }
64286}
0 commit comments