diff options
author | Thomas Citharel <tcit@tcit.fr> | 2015-02-13 17:14:08 +0100 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2015-02-13 17:14:08 +0100 |
commit | 57068585c0a1164f1ae7ae399f3d5a68a4e9d46d (patch) | |
tree | 479969a1a9888c34285e0f84a8186561ebe980e7 /install/install_functions.php | |
parent | 1be071f9f0fba7c93f114a886ff19199955a3f02 (diff) | |
parent | af13787e74ea45d7edc1005810f15a8baa428a77 (diff) | |
download | wallabag-57068585c0a1164f1ae7ae399f3d5a68a4e9d46d.tar.gz wallabag-57068585c0a1164f1ae7ae399f3d5a68a4e9d46d.tar.zst wallabag-57068585c0a1164f1ae7ae399f3d5a68a4e9d46d.zip |
Merge branch 'dev' into sendmailatregistration
Diffstat (limited to 'install/install_functions.php')
-rw-r--r-- | install/install_functions.php | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/install/install_functions.php b/install/install_functions.php new file mode 100644 index 00000000..a4830569 --- /dev/null +++ b/install/install_functions.php | |||
@@ -0,0 +1,107 @@ | |||
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 = pdoDrivers(); | ||
30 | $pdo_drivers_passing = $pdo_drivers['sqlite'] || $pdo_drivers['mysql'] || $pdo_drivers['postgres']; | ||
31 | $urlfetching = $curl_ok || $allow_url_fopen_ok; | ||
32 | |||
33 | |||
34 | |||
35 | if (extension_loaded('xmlreader')) { | ||
36 | $xml_ok = true; | ||
37 | } elseif (extension_loaded('xml')) { | ||
38 | $parser_check = xml_parser_create(); | ||
39 | xml_parse_into_struct($parser_check, '<foo>&</foo>', $values); | ||
40 | xml_parser_free($parser_check); | ||
41 | $xml_ok = isset($values[0]['value']); | ||
42 | } else { | ||
43 | $xml_ok = false; | ||
44 | } | ||
45 | |||
46 | $status = array('app_name' => $app_name, 'php' => $php_ok, 'pdo' => $pdo_ok, | ||
47 | 'pdo_drivers_passing' => $pdo_drivers_passing, 'xml' => $xml_ok, 'pcre' => $pcre_ok, | ||
48 | 'zlib' => $zlib_ok, 'mbstring' => $mbstring_ok, 'dom' => $dom_ok, 'iconv' => $iconv_ok, 'tidy' => $tidy_ok, 'curl' => $curl_ok, | ||
49 | 'parse_ini' => $parse_ini_ok, 'parallel' => $parallel_ok, 'allow_url_fopen' => $allow_url_fopen_ok, 'filter' => $filter_ok, | ||
50 | 'gettext' => $gettext_ok, 'gd' => $gd_ok, 'urlfetching' => $urlfetching); | ||
51 | |||
52 | return $status; | ||
53 | } | ||
54 | function isOkay() { | ||
55 | return !in_array(false, status()); | ||
56 | } | ||
57 | |||
58 | function isPassing() { | ||
59 | $status = status(); | ||
60 | unset($status['curl'], $status['parallel'], $status['tidy'], $status['gd'], $status['filter'], $status['allow_url_fopen']); | ||
61 | return !in_array(false, $status); | ||
62 | } | ||
63 | |||
64 | function pdoDrivers() { | ||
65 | $pdo_driver_sqlite = extension_loaded('pdo_sqlite'); | ||
66 | $pdo_driver_mysql = extension_loaded('pdo_mysql'); | ||
67 | $pdo_driver_postgres = extension_loaded('pdo_pgsql'); | ||
68 | |||
69 | $pdo_drivers = array('sqlite' => $pdo_driver_sqlite, 'mysql' => $pdo_driver_mysql, | ||
70 | 'postgres' => $pdo_driver_postgres); | ||
71 | |||
72 | return $pdo_drivers; | ||
73 | } | ||
74 | |||
75 | /* Function taken from at http://php.net/manual/en/function.rmdir.php#110489 | ||
76 | * Idea : nbari at dalmp dot com | ||
77 | * Rights unknown | ||
78 | * Here in case of .gitignore files | ||
79 | */ | ||
80 | |||
81 | function delTree($dir) { | ||
82 | $files = array_diff(scandir($dir), array('.','..')); | ||
83 | foreach ($files as $file) { | ||
84 | (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file"); | ||
85 | } | ||
86 | return rmdir($dir); | ||
87 | } | ||
88 | |||
89 | function generate_salt() { | ||
90 | mt_srand(microtime(true)*100000 + memory_get_usage(true)); | ||
91 | return md5(uniqid(mt_rand(), true)); | ||
92 | } | ||
93 | |||
94 | function executeQuery($handle, $sql, $params) { | ||
95 | try | ||
96 | { | ||
97 | $query = $handle->prepare($sql); | ||
98 | $query->execute($params); | ||
99 | return $query->fetchAll(); | ||
100 | } | ||
101 | catch (Exception $e) | ||
102 | { | ||
103 | return FALSE; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | ?> \ No newline at end of file | ||