Changeset 29773
- Timestamp:
- Sep 24, 2014, 7:30:08 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/plugins.class.php
r28969 r29773 90 90 $classname = $plugin_id.'_maintain'; 91 91 92 // 2.7 pattern (OO only) 92 93 if (file_exists($file_to_include.'.class.php')) 93 94 { … … 96 97 } 97 98 99 // before 2.7 pattern (OO or procedural) 98 100 if (file_exists($file_to_include.'.inc.php')) 99 101 { … … 115 117 * @param array - errors 116 118 */ 117 function perform_action($action, $plugin_id )119 function perform_action($action, $plugin_id, $options=array()) 118 120 { 119 121 if (isset($this->db_plugins_by_id[$plugin_id])) … … 144 146 pwg_query($query); 145 147 } 148 break; 149 150 case 'update': 151 $previous_version = $this->fs_plugins[$plugin_id]['version']; 152 $upgrade_status = $this->extract_plugin_files('upgrade', $options['revision'], $plugin_id); 153 154 if ($upgrade_status === 'ok') 155 { 156 $this->get_fs_plugin($plugin_id); // refresh plugins list 157 $plugin_maintain->update($previous_version, $this->fs_plugins[$plugin_id]['version']); 158 } 159 160 return $upgrade_status; 146 161 break; 147 162 … … 243 258 if ($file!='.' and $file!='..') 244 259 { 245 $path = PHPWG_PLUGINS_PATH.$file; 246 if (is_dir($path) and !is_link($path) 247 and preg_match('/^[a-zA-Z0-9-_]+$/', $file ) 248 and file_exists($path.'/main.inc.php') 249 ) 250 { 251 $plugin = array( 252 'name'=>$file, 253 'version'=>'0', 254 'uri'=>'', 255 'description'=>'', 256 'author'=>'', 257 ); 258 $plg_data = file_get_contents($path.'/main.inc.php', null, null, 0, 2048); 259 260 if (preg_match("|Plugin Name:\\s*(.+)|", $plg_data, $val)) 261 { 262 $plugin['name'] = trim( $val[1] ); 263 } 264 if (preg_match("|Version:\\s*([\\w.-]+)|", $plg_data, $val)) 265 { 266 $plugin['version'] = trim($val[1]); 267 } 268 if (preg_match("|Plugin URI:\\s*(https?:\\/\\/.+)|", $plg_data, $val)) 269 { 270 $plugin['uri'] = trim($val[1]); 271 } 272 if ($desc = load_language('description.txt', $path.'/', array('return' => true))) 273 { 274 $plugin['description'] = trim($desc); 275 } 276 elseif (preg_match("|Description:\\s*(.+)|", $plg_data, $val)) 277 { 278 $plugin['description'] = trim($val[1]); 279 } 280 if (preg_match("|Author:\\s*(.+)|", $plg_data, $val)) 281 { 282 $plugin['author'] = trim($val[1]); 283 } 284 if (preg_match("|Author URI:\\s*(https?:\\/\\/.+)|", $plg_data, $val)) 285 { 286 $plugin['author uri'] = trim($val[1]); 287 } 288 if (!empty($plugin['uri']) and strpos($plugin['uri'] , 'extension_view.php?eid=')) 289 { 290 list( , $extension) = explode('extension_view.php?eid=', $plugin['uri']); 291 if (is_numeric($extension)) $plugin['extension'] = $extension; 292 } 293 294 // IMPORTANT SECURITY ! 295 $plugin = array_map('htmlspecialchars', $plugin); 296 $this->fs_plugins[$file] = $plugin; 260 if (preg_match('/^[a-zA-Z0-9-_]+$/', $file)) 261 { 262 $this->get_fs_plugin($file); 297 263 } 298 264 } 299 265 } 300 266 closedir($dir); 267 } 268 269 /** 270 * Load metadata of a plugin in `fs_plugins` array 271 * @from 2.7 272 * @param $plugin_id 273 * @return false|array 274 */ 275 function get_fs_plugin($plugin_id) 276 { 277 $path = PHPWG_PLUGINS_PATH.$plugin_id; 278 279 if (is_dir($path) and !is_link($path) 280 and file_exists($path.'/main.inc.php') 281 ) 282 { 283 $plugin = array( 284 'name'=>$plugin_id, 285 'version'=>'0', 286 'uri'=>'', 287 'description'=>'', 288 'author'=>'', 289 ); 290 $plg_data = file_get_contents($path.'/main.inc.php', null, null, 0, 2048); 291 292 if (preg_match("|Plugin Name:\\s*(.+)|", $plg_data, $val)) 293 { 294 $plugin['name'] = trim( $val[1] ); 295 } 296 if (preg_match("|Version:\\s*([\\w.-]+)|", $plg_data, $val)) 297 { 298 $plugin['version'] = trim($val[1]); 299 } 300 if (preg_match("|Plugin URI:\\s*(https?:\\/\\/.+)|", $plg_data, $val)) 301 { 302 $plugin['uri'] = trim($val[1]); 303 } 304 if ($desc = load_language('description.txt', $path.'/', array('return' => true))) 305 { 306 $plugin['description'] = trim($desc); 307 } 308 elseif (preg_match("|Description:\\s*(.+)|", $plg_data, $val)) 309 { 310 $plugin['description'] = trim($val[1]); 311 } 312 if (preg_match("|Author:\\s*(.+)|", $plg_data, $val)) 313 { 314 $plugin['author'] = trim($val[1]); 315 } 316 if (preg_match("|Author URI:\\s*(https?:\\/\\/.+)|", $plg_data, $val)) 317 { 318 $plugin['author uri'] = trim($val[1]); 319 } 320 if (!empty($plugin['uri']) and strpos($plugin['uri'] , 'extension_view.php?eid=')) 321 { 322 list( , $extension) = explode('extension_view.php?eid=', $plugin['uri']); 323 if (is_numeric($extension)) $plugin['extension'] = $extension; 324 } 325 326 // IMPORTANT SECURITY ! 327 $plugin = array_map('htmlspecialchars', $plugin); 328 $this->fs_plugins[$plugin_id] = $plugin; 329 330 return $plugin; 331 } 332 333 return false; 301 334 } 302 335 -
trunk/include/ws_functions/pwg.extensions.php
r27694 r29773 189 189 } 190 190 191 $upgrade_status = $extension-> extract_plugin_files('upgrade', $revision, $extension_id);191 $upgrade_status = $extension->perform_action('update', $extension_id, array('revision'=>$revision)); 192 192 $extension_name = $extension->fs_plugins[$extension_id]['name']; 193 193
Note: See TracChangeset
for help on using the changeset viewer.