]> git.immae.eu Git - github/wallabag/wallabag.git/blob - install/wallabag_compatibility_test.php
view improvements & check if at least one pdo driver is available
[github/wallabag/wallabag.git] / install / wallabag_compatibility_test.php
1 <?php
2 /**
3 * wallabag, self hostable application allowing you to not miss any content anymore
4 *
5 * @category wallabag
6 * @author Nicolas LÅ“uillet <nicolas@loeuillet.org>
7 * @copyright 2013
8 * @license http://opensource.org/licenses/MIT see COPYING file
9 */
10
11 function status() {
12 $app_name = 'wallabag';
13
14 $php_ok = (function_exists('version_compare') && version_compare(phpversion(), '5.3.3', '>='));
15 $pdo_ok = class_exists('PDO');
16 $pcre_ok = extension_loaded('pcre');
17 $zlib_ok = extension_loaded('zlib');
18 $mbstring_ok = extension_loaded('mbstring');
19 $dom_ok = extension_loaded('DOM');
20 $iconv_ok = extension_loaded('iconv');
21 $tidy_ok = function_exists('tidy_parse_string');
22 $curl_ok = function_exists('curl_exec');
23 $parse_ini_ok = function_exists('parse_ini_file');
24 $parallel_ok = ((extension_loaded('http') && class_exists('HttpRequestPool')) || ($curl_ok && function_exists('curl_multi_init')));
25 $allow_url_fopen_ok = (bool)ini_get('allow_url_fopen');
26 $filter_ok = extension_loaded('filter');
27 $gettext_ok = function_exists("gettext");
28 $gd_ok = extension_loaded('gd');
29 $pdo_drivers_passing = extension_loaded('pdo_sqlite') || extension_loaded('pdo_mysql') || extension_loaded('pdo_pgsql');
30
31 if (extension_loaded('xmlreader')) {
32 $xml_ok = true;
33 } elseif (extension_loaded('xml')) {
34 $parser_check = xml_parser_create();
35 xml_parse_into_struct($parser_check, '<foo>&amp;</foo>', $values);
36 xml_parser_free($parser_check);
37 $xml_ok = isset($values[0]['value']);
38 } else {
39 $xml_ok = false;
40 }
41
42 $status = array('app_name' => $app_name, 'php' => $php_ok, 'pdo' => $pdo_ok, 'pdo_drivers_passing' => $pdo_drivers_passing, 'xml' => $xml_ok, 'pcre' => $pcre_ok, 'zlib' => $zlib_ok, 'mbstring' => $mbstring_ok, 'dom' => $dom_ok, 'iconv' => $iconv_ok, 'tidy' => $tidy_ok, 'curl' => $curl_ok, 'parse_ini' => $parse_ini_ok, 'parallel' => $parallel_ok, 'allow_url_fopen' => $allow_url_fopen_ok, 'filter' => $filter_ok, 'gettext' => $gettext_ok, 'gd' => $gd_ok);
43
44 return $status;
45 }
46 function isOkay() {
47 return !in_array(false, status());
48 }
49
50 function isPassing() {
51 $status = status();
52 unset($status['curl'], $status['parallel'], $status['tidy'], $status['gd'], $status['filter']);
53 return !in_array(false, $status);
54 }
55
56 /* Function taken from at http://php.net/manual/en/function.rmdir.php#110489
57 * Idea : nbari at dalmp dot com
58 * Rights unknown
59 * Here in case of .gitignore files
60 */
61
62 function delTree($dir) {
63 $files = array_diff(scandir($dir), array('.','..'));
64 foreach ($files as $file) {
65 (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
66 }
67 return rmdir($dir);
68 }
69
70 function generate_salt() {
71 mt_srand(microtime(true)*100000 + memory_get_usage(true));
72 return md5(uniqid(mt_rand(), true));
73 }
74
75 function executeQuery($handle, $sql, $params) {
76 try
77 {
78 $query = $handle->prepare($sql);
79 $query->execute($params);
80 return $query->fetchAll();
81 }
82 catch (Exception $e)
83 {
84 return FALSE;
85 }
86 }
87
88 ?>