Changeset 2243 for trunk/admin
- Timestamp:
- Mar 2, 2008, 7:56:05 PM (16 years ago)
- Location:
- trunk/admin
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions_plugins.inc.php
r2242 r2243 183 183 // we search main.inc.php in archive 184 184 if (basename($file['filename']) == 'main.inc.php' 185 and (!isset($main_filepath) or strlen($file['filename']) < strlen($main_filepath))) 185 and (!isset($main_filepath) 186 or strlen($file['filename']) < strlen($main_filepath))) 186 187 { 187 188 $main_filepath = $file['filename']; 188 189 } 189 190 } 190 191 191 if (isset($main_filepath)) 192 192 { 193 193 $root = dirname($main_filepath); // main.inc.php path in archive 194 if ($action == 'upgrade') $extract_path = PHPWG_PLUGINS_PATH . $dest; 195 else $extract_path = PHPWG_PLUGINS_PATH . ($root == '.' ? 'extension_' . $dest : basename($root)); 196 194 if ($action == 'upgrade') 195 { 196 $extract_path = PHPWG_PLUGINS_PATH.$dest; 197 } 198 else 199 { 200 $extract_path = PHPWG_PLUGINS_PATH 201 . ($root == '.' ? 'extension_' . $dest : basename($root)); 202 } 197 203 if($result = $zip->extract(PCLZIP_OPT_PATH, $extract_path, 198 204 PCLZIP_OPT_REMOVE_PATH, $root, … … 227 233 * @param string - path 228 234 */ 229 function pm_deltree($path)235 function deltree($path) 230 236 { 231 237 if (is_dir($path)) … … 237 243 { 238 244 $pathfile = $path . '/' . $file; 239 if (is_dir($pathfile)) pm_deltree($pathfile); 240 else @unlink($pathfile); 245 if (is_dir($pathfile)) 246 { 247 deltree($pathfile); 248 } 249 else 250 { 251 @unlink($pathfile); 252 } 241 253 } 242 254 } … … 251 263 * @param string - path 252 264 */ 253 function send_ pm_trash($path)265 function send_to_trash($path) 254 266 { 255 267 $trash_path = PHPWG_PLUGINS_PATH . 'trash'; -
trunk/admin/plugins.php
r2242 r2243 152 152 } 153 153 break; 154 154 155 155 case 'delete': 156 if (!pm_deltree(PHPWG_PLUGINS_PATH . $plugin_id))157 { 158 send_ pm_trash(PHPWG_PLUGINS_PATH . $plugin_id);156 if (!deltree(PHPWG_PLUGINS_PATH . $plugin_id)) 157 { 158 send_to_trash(PHPWG_PLUGINS_PATH . $plugin_id); 159 159 } 160 160 break; 161 161 } 162 162 if (empty($errors)) 163 164 163 { 164 $my_base_url .= isset($_GET['upgrade']) ? 165 165 '&plugin='.$plugin_id.'&upgrade='.$_GET['upgrade'].'&reactivate=true':''; 166 166 167 167 $my_base_url .= isset($_GET['upgradestatus']) ? 168 168 '&plugin='.$plugin_id.'&upgradestatus='.$_GET['upgradestatus']:''; 169 169 170 170 redirect($my_base_url); 171 171 } 172 173 172 else 173 { 174 174 $page['errors'] = array_merge($page['errors'], $errors); 175 175 } -
trunk/admin/plugins_list.php
r2242 r2243 81 81 'DESCRIPTION' => $desc); 82 82 83 83 $action_url = htmlentities($my_base_url) . '&plugin=' . $plugin_id; 84 84 85 85 if (isset($db_plugins_by_id[$plugin_id])) … … 110 110 'L_ACTION' => l10n('Install'), 111 111 'CONFIRM' => l10n('Are you sure?')); 112 112 $tpl_plugin['actions'][] = 113 113 array('U_ACTION' => $action_url . '&action=delete', 114 114 'L_ACTION' => l10n('plugins_delete'), -
trunk/admin/plugins_new.php
r2242 r2243 35 35 if (isset($_GET['install']) and isset($_GET['extension']) and !is_adviser()) 36 36 { 37 37 include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); 38 38 39 40 41 39 $install_status = extract_plugin_files('install', 40 $_GET['install'], 41 $_GET['extension']); 42 42 43 43 redirect($my_base_url . '&installstatus=' . $install_status); 44 44 } 45 45 … … 48 48 if (isset($_GET['installstatus'])) 49 49 { 50 51 52 53 54 55 56 57 array_push($page['errors'], l10n('plugins_temp_path_error')); 58 59 60 61 array_push($page['errors'], l10n('plugins_dl_archive_error')); 62 50 switch ($_GET['installstatus']) 51 { 52 case 'ok': 53 array_push($page['infos'], l10n('plugins_install_ok'), l10n('plugins_install_need_activate')); 54 break; 55 56 case 'temp_path_error': 57 array_push($page['errors'], l10n('plugins_temp_path_error')); 58 break; 59 60 case 'dl_archive_error': 61 array_push($page['errors'], l10n('plugins_dl_archive_error')); 62 break; 63 63 64 65 array_push($page['errors'], l10n('plugins_archive_error')); 66 64 case 'archive_error': 65 array_push($page['errors'], l10n('plugins_archive_error')); 66 break; 67 67 68 69 array_push($page['errors'], sprintf(l10n('plugins_extract_error'), $_GET['installstatus']), l10n('plugins_check_chmod')); 70 68 default: 69 array_push($page['errors'], sprintf(l10n('plugins_extract_error'), $_GET['installstatus']), l10n('plugins_check_chmod')); 70 } 71 71 } 72 72 … … 89 89 if ($plugins_infos !== false) 90 90 { 91 92 93 94 95 96 91 if ($order == 'date') krsort($plugins_infos); 92 else uasort($plugins_infos, 'extension_'.$order.'_compare'); 93 94 foreach($plugins_infos as $plugin) 95 { 96 $ext_desc = nl2br(htmlspecialchars(strip_tags( 97 97 utf8_encode($plugin['ext_description'])))); 98 99 100 101 102 98 99 $ver_desc = sprintf(l10n('plugins_description'), 100 $plugin['version'], 101 date('Y-m-d', $plugin['date']), 102 nl2br(htmlspecialchars(strip_tags( 103 103 utf8_encode($plugin['description']))))); 104 105 106 107 108 104 105 $url_auto_install = htmlentities($my_base_url) 106 . '&extension=' . $plugin['id_extension'] 107 . '&install=%2Fupload%2Fextension-' . $plugin['id_extension'] 108 . '%2Frevision-' . $plugin['id_revision'] . '%2F' 109 109 . str_replace(' ', '%20',$plugin['url']); 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 110 111 $url_download = PEM_URL .'/upload/extension-'.$plugin['id_extension'] 112 . '/revision-' . $plugin['id_revision'] 113 . '/' . $plugin['url']; 114 115 $template->append('plugins', 116 array('EXT_NAME' => $plugin['ext_name'], 117 'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$plugin['id_extension'], 118 'EXT_DESC' => $ext_desc, 119 'VERSION' => $plugin['version'], 120 'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin['id_revision'], 121 'VER_DESC' => $ver_desc, 122 'AUTHOR' => $plugin['author'], 123 'URL_INSTALL' => $url_auto_install, 124 'URL_DOWNLOAD' => $url_download)); 125 } 126 126 } 127 127 else 128 128 { 129 129 array_push($page['errors'], l10n('plugins_server_error')); 130 130 } 131 131 -
trunk/admin/plugins_update.php
r2242 r2243 35 35 if (isset($_GET['upgrade']) and isset($_GET['plugin']) and !is_adviser()) 36 36 { 37 37 include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); 38 38 39 40 41 39 $upgrade_status = extract_plugin_files('upgrade', 40 $_GET['upgrade'], 41 $_GET['plugin']); 42 42 43 43 $my_base_url .= isset($_GET['reactivate']) ? '&action=activate' : ''; 44 44 45 45 redirect($my_base_url.'&plugin='.$_GET['plugin'].'&upgradestatus='.$upgrade_status); 46 46 } 47 47 … … 50 50 if (isset($_GET['upgradestatus']) and isset($_GET['plugin'])) 51 51 { 52 53 54 55 52 switch ($_GET['upgradestatus']) 53 { 54 case 'ok': 55 array_push($page['infos'], 56 56 sprintf(l10n('plugins_upgrade_ok'), 57 57 $fs_plugins[$_GET['plugin']]['name'])); 58 58 break; 59 59 60 61 array_push($page['errors'], l10n('plugins_temp_path_error')); 62 63 64 65 array_push($page['errors'], l10n('plugins_dl_archive_error')); 66 60 case 'temp_path_error': 61 array_push($page['errors'], l10n('plugins_temp_path_error')); 62 break; 63 64 case 'dl_archive_error': 65 array_push($page['errors'], l10n('plugins_dl_archive_error')); 66 break; 67 67 68 69 array_push($page['errors'], l10n('plugins_archive_error')); 70 68 case 'archive_error': 69 array_push($page['errors'], l10n('plugins_archive_error')); 70 break; 71 71 72 73 72 default: 73 array_push($page['errors'], 74 74 sprintf(l10n('plugins_extract_error'), 75 $_GET['upgradestatus'])); 76 75 $_GET['upgradestatus'])); 76 } 77 77 } 78 78 … … 85 85 if ($plugins_infos !== false) 86 86 { 87 88 89 87 foreach($fs_plugins as $plugin_id => $fs_plugin) 88 { 89 if (isset($fs_plugin['extension']) 90 90 and isset($plugins_infos[$fs_plugin['extension']])) 91 92 93 94 91 { 92 $plugin_info = $plugins_infos[$fs_plugin['extension']]; 93 94 $ext_desc = nl2br(htmlspecialchars(strip_tags( 95 95 utf8_encode($plugin_info['ext_description'])))); 96 97 98 99 100 96 97 $ver_desc = sprintf(l10n('plugins_description'), 98 $plugin_info['version'], 99 date('Y-m-d', $plugin_info['date']), 100 nl2br(htmlspecialchars(strip_tags( 101 101 utf8_encode($plugin_info['description']))))); 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 102 103 if ($plugin_info['version'] == $fs_plugin['version']) 104 { 105 // Plugin is up to date 106 $template->append('plugins_uptodate', 107 array('URL' => $fs_plugin['uri'], 108 'NAME' => $fs_plugin['name'], 109 'EXT_DESC' => $ext_desc, 110 'VERSION' => $fs_plugin['version'], 111 'VER_DESC' => $ver_desc)); 112 } 113 else 114 { 115 // Plugin need upgrade 116 $url_auto_update = htmlentities($my_base_url) 117 . '&plugin=' . $plugin_id 118 . ( 119 119 (isset($db_plugins_by_id[$plugin_id]) 120 120 and $db_plugins_by_id[$plugin_id]['state'] == 'active' … … 122 122 '&action=deactivate' : '' 123 123 ) 124 125 124 . '&upgrade=%2Fupload%2Fextension-' . $fs_plugin['extension'] 125 . '%2Frevision-' . $plugin_info['id_revision'] 126 126 . '%2F' . $plugin_info['url']; 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 127 128 $url_download = PEM_URL.'/upload/extension-'. $fs_plugin['extension'] 129 . '/revision-' . $plugin_info['id_revision'] 130 . '/' . $plugin_info['url']; 131 132 $template->append('plugins_not_uptodate', 133 array('EXT_NAME' => $fs_plugin['name'], 134 'EXT_URL' => $fs_plugin['uri'], 135 'EXT_DESC' => $ext_desc, 136 'VERSION' => $fs_plugin['version'], 137 'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin_info['id_revision'], 138 'NEW_VERSION' => $plugin_info['version'], 139 'NEW_VER_DESC' => $ver_desc, 140 'URL_UPDATE' => $url_auto_update, 141 'URL_DOWNLOAD' => $url_download)); 142 } 143 } 144 else 145 { 146 // Can't check plugin 147 $template->append('plugins_cant_check', 148 array('NAME' => $fs_plugin['name'], 149 'VERSION' => $fs_plugin['version'])); 150 } 151 } 152 152 } 153 153 else 154 154 { 155 155 array_push($page['errors'], l10n('plugins_server_error')); 156 156 } 157 157
Note: See TracChangeset
for help on using the changeset viewer.