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'; ?>
'.sprintf($lang_admin['Extension by'], 'PunBB').'
'.$lang_admin['Hotfix description'].'
'.$lang_admin['Illegal ID'].'
'."\n\t\t\t".''.$lang_admin['Missing manifest'].'
'."\n\t\t\t".''.$lang_admin['Failed parse manifest'].'
'."\n\t\t\t".''.implode(' ', $errors).'
'."\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']).'' : '').'