1 | <?php |
---|
2 | class floOS |
---|
3 | { |
---|
4 | var $is_nutd = array(); |
---|
5 | function floOS_version_compare($a, $b) |
---|
6 | { |
---|
7 | $pattern = array('/([a-z])/ei', '/\.+/', '/\.\Z|\A\./'); |
---|
8 | $replacement = array( "'.'.intval('\\1', 36).'.'", '.', ''); |
---|
9 | |
---|
10 | $array = preg_replace($pattern, $replacement, array($a, $b)); |
---|
11 | |
---|
12 | return version_compare($array[0], $array[1], '>='); |
---|
13 | } |
---|
14 | function theme_version_search($dir) |
---|
15 | { |
---|
16 | global $template, $page; |
---|
17 | load_language('template.lang', PHPWG_ROOT_PATH.'template/floOS/tools/'); |
---|
18 | $header_msgs = array(); |
---|
19 | $dh = opendir ($dir); |
---|
20 | while (($file = readdir ($dh)) !== false ) { |
---|
21 | if ($file !== '.' && $file !== '..' && $file !== '.svn') { // enleve svn |
---|
22 | $path =$dir.'/'.$file; |
---|
23 | if (is_dir($path)) { |
---|
24 | $this->theme_version_search($path); |
---|
25 | } |
---|
26 | else |
---|
27 | { |
---|
28 | $page = explode('.', $file); |
---|
29 | $nb = count($page); |
---|
30 | $nom_fichier = $page[0]; |
---|
31 | for ($i = 1; $i < $nb-1; $i++){ |
---|
32 | $nom_fichier .= '.'.$page[$i]; |
---|
33 | } |
---|
34 | if(isset($page[1])){ |
---|
35 | $ext_fichier = $page[$nb-1]; |
---|
36 | } |
---|
37 | else { |
---|
38 | $ext_fichier = ''; |
---|
39 | } |
---|
40 | if($nom_fichier == 'themeconf.inc' and $ext_fichier == 'php') { |
---|
41 | include($path); |
---|
42 | if (isset($themeconf['eid'])) |
---|
43 | { |
---|
44 | if($this->is_not_up_to_date($themeconf['version'],$themeconf['eid']) ) |
---|
45 | { |
---|
46 | |
---|
47 | $msg=l10n('theme_update_needed_1').$themeconf['theme'].l10n('theme_update_needed_2').$themeconf['eid'].l10n('theme_update_needed_3').$themeconf['theme'].l10n('theme_update_needed_4'); |
---|
48 | $template->append('header_notes', $msg); |
---|
49 | $this->is_nutd[$themeconf['theme']]=$themeconf['version']; |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | } |
---|
54 | } |
---|
55 | } |
---|
56 | } |
---|
57 | closedir ($dh); // on ferme le repertoire courant |
---|
58 | } |
---|
59 | function is_not_up_to_date($v_local, $eid) |
---|
60 | { |
---|
61 | |
---|
62 | global $template, $user, $page; |
---|
63 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
64 | load_language('template.lang', PHPWG_ROOT_PATH.'template/floOS/tools/'); |
---|
65 | |
---|
66 | // Retrieve PEM versions |
---|
67 | $version = PHPWG_VERSION; |
---|
68 | $versions_to_check = array(); |
---|
69 | $url = PEM_URL . '/api/get_version_list.php?category_id=12&format=php'; |
---|
70 | if (fetchRemote($url, $result) and $pem_versions = @unserialize($result)) |
---|
71 | { |
---|
72 | if (!preg_match('/^\d+\.\d+\.\d+/', $version)) |
---|
73 | { |
---|
74 | $version = $pem_versions[0]['name']; |
---|
75 | } |
---|
76 | $branch = substr($version, 0, strrpos($version, '.')); |
---|
77 | foreach ($pem_versions as $pem_version) |
---|
78 | { |
---|
79 | if (strpos($pem_version['name'], $branch) === 0) |
---|
80 | { |
---|
81 | $versions_to_check[] = $pem_version['id']; |
---|
82 | } |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | // Retrieve PEM template infos |
---|
87 | $url = PEM_URL . '/api/get_revision_list.php?format=php&last_revision_only=true'; |
---|
88 | $url .= '&version=' . implode(',', $versions_to_check); |
---|
89 | //$url .= '&lang=' . substr($user['language'], 0, 2); |
---|
90 | $url .= '&extension_include='.$eid; |
---|
91 | fetchRemote($url, $result); |
---|
92 | $pem_res = @unserialize($result); |
---|
93 | foreach($pem_res as $pem_floOS) |
---|
94 | { |
---|
95 | if (!is_array($pem_floOS)) |
---|
96 | { |
---|
97 | $template->assign( |
---|
98 | array( |
---|
99 | 'erreur' => 'erreur url : '.$url, |
---|
100 | ) |
---|
101 | ); |
---|
102 | } |
---|
103 | if (!$this->floOS_version_compare($v_local, $pem_floOS['revision_name'])) |
---|
104 | { |
---|
105 | return true; |
---|
106 | } |
---|
107 | else |
---|
108 | { |
---|
109 | return false; |
---|
110 | } |
---|
111 | } |
---|
112 | } |
---|
113 | function display($names) |
---|
114 | { |
---|
115 | if (!is_array($names)) |
---|
116 | { |
---|
117 | global $template; |
---|
118 | $template->assign( |
---|
119 | array( |
---|
120 | 'erreur' => 'erreur get session var not array', |
---|
121 | ) |
---|
122 | ); |
---|
123 | } |
---|
124 | else |
---|
125 | { |
---|
126 | global $template, $user; |
---|
127 | load_language('template.lang', PHPWG_ROOT_PATH.'template/floOS/tools/'); |
---|
128 | $r_names=$names; |
---|
129 | foreach($names as $name => $version) |
---|
130 | { |
---|
131 | if ($name=='floOS') |
---|
132 | { |
---|
133 | include(PHPWG_ROOT_PATH.'template/floOS/tools/version.conf.php'); |
---|
134 | if ($this->floOS_version_compare($version, $floOS_conf['version'])) |
---|
135 | { |
---|
136 | $template->append('header_notes', l10n('floOS_update_needed')); |
---|
137 | } |
---|
138 | else |
---|
139 | { |
---|
140 | $p=array_search($name,array_keys($r_names)); |
---|
141 | array_splice ($r_names,$p,1); |
---|
142 | } |
---|
143 | |
---|
144 | } |
---|
145 | else |
---|
146 | { |
---|
147 | if ( is_dir(PHPWG_ROOT_PATH.'template/floOS/theme/'.$name) and is_file(PHPWG_ROOT_PATH.'template/floOS/theme/'.$name.'/themeconf.inc.php') ) |
---|
148 | { |
---|
149 | include(PHPWG_ROOT_PATH.'template/floOS/theme/'.$name.'/themeconf.inc.php'); |
---|
150 | if ($this->floOS_version_compare($version, $themeconf['version'])) |
---|
151 | { |
---|
152 | $msg=l10n('theme_update_needed_1').$themeconf['theme'].l10n('theme_update_needed_2').$themeconf['eid'].l10n('theme_update_needed_3').$themeconf['theme'].l10n('theme_update_needed_4'); |
---|
153 | $template->append('header_notes', $msg); |
---|
154 | } |
---|
155 | else |
---|
156 | { |
---|
157 | $p=array_search($name,array_keys($r_names)); |
---|
158 | array_splice ($r_names,$p,1); |
---|
159 | } |
---|
160 | } |
---|
161 | } |
---|
162 | } |
---|
163 | }//else |
---|
164 | |
---|
165 | pwg_set_session_var('floOS_array_version',$r_names); |
---|
166 | } |
---|
167 | } |
---|
168 | ?> |
---|