escape(trim($ext_data['extension']['uninstall'])).'\'' : 'NULL'; // Is there an uninstall note to store in the db? $uninstall_note = 'NULL'; foreach ($ext_data['extension']['note'] as $cur_note) { if ($cur_note['attributes']['type'] == 'uninstall' && trim($cur_note['content']) != '') $uninstall_note = '\''.$pun_db->escape(trim($cur_note['content'])).'\''; } $notices = array(); // Is this a fresh install or an upgrade? $query = array( 'SELECT' => 'e.version', 'FROM' => 'extensions AS e', 'WHERE' => 'e.id=\''.$pun_db->escape($id).'\'' ); ($hook = get_hook('aex_qr_get_current_ext_version')) ? eval($hook) : null; $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); if ($pun_db->num_rows($result)) { // EXT_CUR_VERSION will be available to the extension install routine (to facilitate extension upgrades) define('EXT_CUR_VERSION', $pun_db->result($result)); // Run the author supplied install code if (isset($ext_data['extension']['install']) && trim($ext_data['extension']['install']) != '') eval($ext_data['extension']['install']); // Update the existing extension $query = array( 'UPDATE' => 'extensions', 'SET' => 'title=\''.$pun_db->escape($ext_data['extension']['title']).'\', version=\''.$pun_db->escape($ext_data['extension']['version']).'\', description=\''.$pun_db->escape($ext_data['extension']['description']).'\', author=\''.$pun_db->escape($ext_data['extension']['author']).'\', uninstall='.$uninstall_code.', uninstall_note='.$uninstall_note, 'WHERE' => 'id=\''.$pun_db->escape($id).'\'' ); ($hook = get_hook('aex_qr_update_ext')) ? eval($hook) : null; $pun_db->query_build($query) or error(__FILE__, __LINE__); // Delete the old hooks $query = array( 'DELETE' => 'extension_hooks', 'WHERE' => 'extension_id=\''.$pun_db->escape($id).'\'' ); ($hook = get_hook('aex_qr_update_ext_delete_hooks')) ? eval($hook) : null; $pun_db->query_build($query) or error(__FILE__, __LINE__); } else { // Run the author supplied install code if (isset($ext_data['extension']['install']) && trim($ext_data['extension']['install']) != '') eval($ext_data['extension']['install']); // Add the new extension $query = array( 'INSERT' => 'id, title, version, description, author, uninstall, uninstall_note', 'INTO' => 'extensions', 'VALUES' => '\''.$pun_db->escape($ext_data['extension']['id']).'\', \''.$pun_db->escape($ext_data['extension']['title']).'\', \''.$pun_db->escape($ext_data['extension']['version']).'\', \''.$pun_db->escape($ext_data['extension']['description']).'\', \''.$pun_db->escape($ext_data['extension']['author']).'\', '.$uninstall_code.', '.$uninstall_note ); ($hook = get_hook('aex_qr_add_ext')) ? eval($hook) : null; $pun_db->query_build($query) or error(__FILE__, __LINE__); } // Now insert the hooks foreach ($ext_data['extension']['hooks']['hook'] as $hook) { $query = array( 'INSERT' => 'id, extension_id, code, installed', 'INTO' => 'extension_hooks', 'VALUES' => '\''.$pun_db->escape(trim($hook['attributes']['id'])).'\', \''.$pun_db->escape($id).'\', \''.$pun_db->escape(trim($hook['content'])).'\', '.time() ); ($hook = get_hook('aex_qr_add_hook')) ? eval($hook) : null; $pun_db->query_build($query) or error(__FILE__, __LINE__); } // Empty the PHP cache $d = dir(PUN_CACHE_DIR); while (($entry = $d->read()) !== false) { if (substr($entry, strlen($entry)-4) == '.php') @unlink(PUN_CACHE_DIR.$entry); } $d->close(); // Regenerate the hooks cache require_once PUN_ROOT.'include/cache.php'; generate_hooks_cache(); // Display notices if there are any if (!empty($notices)) { ($hook = get_hook('aex_install_notices_pre_header_load')) ? eval($hook) : null; define('PUN_PAGE_SECTION', 'extensions'); define('PUN_PAGE', 'admin-extensions-install'); require PUN_ROOT.'header.php'; ?>

{ }

""

    '.$cur_notice.''."\n"; ?>

{ }

""


'.++$pun_page['num_items'].'. '.pun_htmlencode($cur_note['content']).'

'; } if (version_compare(clean_version($pun_config['o_cur_version']), clean_version($ext_data['extension']['maxtestedon']), '>')) $form_warnings[] = '

'.++$pun_page['num_items'].'. '.$lang_admin['Maxtestedon warning'].'

'; if (!empty($form_warnings)) { ?>

'e.title, e.version, e.description, e.author, e.uninstall, e.uninstall_note', 'FROM' => 'extensions AS e', 'WHERE' => 'e.id=\''.$pun_db->escape($id).'\'' ); ($hook = get_hook('aex_qr_get_extension')) ? eval($hook) : null; $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); if (!$pun_db->num_rows($result)) message($lang_common['Bad request']); $ext_data = $pun_db->fetch_assoc($result); // Setup breadcrumbs $pun_page['crumbs'] = array( array($pun_config['o_board_title'], pun_link($pun_url['index'])), array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])), array($lang_admin['Manage extensions'], pun_link($pun_url['admin_extensions_manage'])), $lang_admin['Uninstall extension'] ); // If the user has confirmed the uninstall if (isset($_POST['uninstall_comply'])) { ($hook = get_hook('aex_uninstall_comply_form_submitted')) ? eval($hook) : null; $notices = array(); // Run uninstall code eval($ext_data['uninstall']); // Now delete the extension and its hooks from the db $query = array( 'DELETE' => 'extension_hooks', 'WHERE' => 'extension_id=\''.$pun_db->escape($id).'\'' ); ($hook = get_hook('aex_qr_uninstall_delete_hooks')) ? eval($hook) : null; $pun_db->query_build($query) or error(__FILE__, __LINE__); $query = array( 'DELETE' => 'extensions', 'WHERE' => 'id=\''.$pun_db->escape($id).'\'' ); ($hook = get_hook('aex_qr_delete_extension')) ? eval($hook) : null; $pun_db->query_build($query) or error(__FILE__, __LINE__); // Empty the PHP cache $d = dir(PUN_CACHE_DIR); while (($entry = $d->read()) !== false) { if (substr($entry, strlen($entry)-4) == '.php') @unlink(PUN_CACHE_DIR.$entry); } $d->close(); // Regenerate the hooks cache require_once PUN_ROOT.'include/cache.php'; generate_hooks_cache(); // Display notices if there are any if (!empty($notices)) { ($hook = get_hook('aex_uninstall_notices_pre_header_load')) ? eval($hook) : null; define('PUN_PAGE_SECTION', 'extensions'); define('PUN_PAGE', 'admin-extensions-manage'); require PUN_ROOT.'header.php'; ?>

{ }

""

    '.$cur_notice.''."\n"; ?>

{ }

""


'e.disabled', 'FROM' => 'extensions AS e', 'WHERE' => 'e.id=\''.$pun_db->escape($id).'\'' ); ($hook = get_hook('aex_qr_get_disabled_status')) ? eval($hook) : null; $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); if (!$pun_db->num_rows($result)) message($lang_common['Bad request']); // Are we disabling or enabling? $disable = $pun_db->result($result) == '0'; $query = array( 'UPDATE' => 'extensions', 'SET' => 'disabled='.($disable ? '1' : '0'), 'WHERE' => 'id=\''.$pun_db->escape($id).'\'' ); ($hook = get_hook('aex_qr_update_disabled_status')) ? eval($hook) : null; $pun_db->query_build($query) or error(__FILE__, __LINE__); // Regenerate the hooks cache require_once PUN_ROOT.'include/cache.php'; generate_hooks_cache(); redirect(pun_link($pun_url['admin_extensions_manage']), ($disable ? $lang_admin['Extension disabled'] : $lang_admin['Extension enabled']).' '.$lang_admin['Redirect']); } ($hook = get_hook('aex_new_action')) ? eval($hook) : null; // Generate an array of installed extensions $inst_exts = array(); $query = array( 'SELECT' => 'e.*', 'FROM' => 'extensions AS e', 'ORDER BY' => 'e.title' ); ($hook = get_hook('aex_qr_get_all_extensions')) ? eval($hook) : null; $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); while ($cur_ext = $pun_db->fetch_assoc($result)) $inst_exts[$cur_ext['id']] = $cur_ext; if ($section == 'install') { // Setup breadcrumbs $pun_page['crumbs'] = array( array($pun_config['o_board_title'], pun_link($pun_url['index'])), array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])), $lang_admin['Install extensions'] ); ($hook = get_hook('aex_section_install_pre_header_load')) ? eval($hook) : null; define('PUN_PAGE_SECTION', 'extensions'); define('PUN_PAGE', 'admin-extensions-install'); require PUN_ROOT.'header.php'; ?>

{ }

'."\n\t\t\t".'

'.pun_htmlencode($hotfix['content']).'

'."\n\t\t\t".'

'.sprintf($lang_admin['Extension by'], 'PunBB').'
'.$lang_admin['Hotfix description'].'

'."\n\t\t\t".'

'.$lang_admin['Install hotfix'].'

'."\n\t\t".'
'; ++$num_exts; } } } $d = dir(PUN_ROOT.'extensions'); while (($entry = $d->read()) !== false) { if ($entry{0} != '.' && is_dir(PUN_ROOT.'extensions/'.$entry)) { if (preg_match('/[^0-9a-z_]/', $entry)) { $pun_page['ext_error'][] = '
'."\n\t\t\t\t".'

'.sprintf($lang_admin['Extension loading error'], pun_htmlencode($entry)).'

'."\n\t\t\t\t".'

'.$lang_admin['Illegal ID'].'

'."\n\t\t\t".'
'; ++$num_failed; continue; } else if (!file_exists(PUN_ROOT.'extensions/'.$entry.'/manifest.xml')) { $pun_page['ext_error'][] = '
'."\n\t\t\t\t".'

'.sprintf($lang_admin['Extension loading error'], pun_htmlencode($entry)).'

'."\n\t\t\t\t".'

'.$lang_admin['Missing manifest'].'

'."\n\t\t\t".'
'; ++$num_failed; continue; } // Parse manifest.xml into an array $ext_data = xml_to_array(@file_get_contents(PUN_ROOT.'extensions/'.$entry.'/manifest.xml')); if (empty($ext_data)) { $pun_page['ext_error'][] = '
'."\n\t\t\t\t".'

'.sprintf($lang_admin['Extension loading error'], pun_htmlencode($entry)).'

'."\n\t\t\t\t".'

'.$lang_admin['Failed parse manifest'].'

'."\n\t\t\t".'
'; ++$num_failed; continue; } // Validate manifest $errors = validate_manifest($ext_data, $entry); if (!empty($errors)) { $pun_page['ext_error'][] = '
'."\n\t\t\t\t".'

'.sprintf($lang_admin['Extension loading error'], pun_htmlencode($entry)).'

'."\n\t\t\t\t".'

'.implode(' ', $errors).'

'."\n\t\t\t".'
'; ++$num_failed; } else { if (!array_key_exists($entry, $inst_exts) || version_compare($inst_exts[$entry]['version'], $ext_data['extension']['version'], '!=')) { $pun_page['ext_item'][] = '
'."\n\t\t\t".'

'.pun_htmlencode($ext_data['extension']['title']).' v'.$ext_data['extension']['version'].'

'."\n\t\t\t".'

'.sprintf($lang_admin['Extension by'], pun_htmlencode($ext_data['extension']['author'])).''.(($ext_data['extension']['description'] != '') ? '
'.pun_htmlencode($ext_data['extension']['description']).'' : '').'

'."\n\t\t\t".'

'.$lang_admin['Install extension'].'

'."\n\t\t".'
'; ++$num_exts; } } } } $d->close(); ($hook = get_hook('aex_section_install_pre_display_ext_list')) ? eval($hook) : null; if ($num_exts) echo "\t\t".implode("\n\t\t", $pun_page['ext_item'])."\n"; else { ?>

{ }

'.($ext['disabled'] != '1' ? $lang_admin['Disable'] : $lang_admin['Enable']).'', ''.$lang_admin['Uninstall'].'' ); ($hook = get_hook('aex_section_manage_pre_ext_actions')) ? eval($hook) : null; ?>

'.$lang_admin['Extension disabled'].' )' ?>