Location: PHPKode > projects > PunBB > punbb-1.3.4/extensions/pun_repository/manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE extension SYSTEM "ext-1.0.dtd">

<!--
/**
 * PunBB Repository extension main file
 *
 * @copyright Copyright (C) 2008 PunBB, partially based on code copyright (C) 2008 FluxBB.org
 * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
 * @package pun_repository
 */
-->

<extension engine="1.0">
	<id>pun_repository</id>
	<title>PunBB Repository</title>
	<version>1.2.3</version>
	<description>Feel free to download and install extensions from PunBB repository.</description>
	<author>PunBB Development Team</author>

	<minversion>1.3dev</minversion>
	<maxtestedon>1.3.4</maxtestedon>

	<note type="install" timing="pre">Warning: web server should have write access to your extensions directory.</note>

	<install><![CDATA[
if (version_compare($forum_config['o_cur_version'], '1.3', '<') && strpos($forum_config['o_cur_version'], 'dev') === false)
	message('This version of the PunBB Repository extension can not be installed on versions lower than PunBB 1.3 final. Please, update your forum.');

if (defined('EXT_CUR_VERSION') && version_compare(EXT_CUR_VERSION, '1.0b', '<='))
	// Removing the file generated by old version
	@unlink(FORUM_CACHE_DIR.'pun_repository.xml');
	]]></install>

	<hooks>
		<hook id="aex_section_manage_end"><![CDATA[
if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/pun_repository.php'))
	include $ext_info['path'].'/lang/'.$forum_user['language'].'/pun_repository.php';
else
	include $ext_info['path'].'/lang/English/pun_repository.php';

require_once $ext_info['path'].'/pun_repository.php';

($hook = get_hook('pun_repository_pre_display_ext_list')) ? eval($hook) : null;

?>
	<div class="main-subhead">
		<h2 class="hn"><span><?php echo $lang_pun_repository['PunBB Repository'] ?></span></h2>
	</div>
	<div class="main-content main-extensions">
		<p class="content-options options"><a href="<?php echo $base_url ?>/admin/extensions.php?pun_repository_update&amp;csrf_token=<?php echo generate_form_token('pun_repository_update') ?>"><?php echo $lang_pun_repository['Clear cache'] ?></a></p>
<?php

if (!defined('PUN_REPOSITORY_EXTENSIONS_LOADED') && file_exists(FORUM_CACHE_DIR.'cache_pun_repository.php'))
	include FORUM_CACHE_DIR.'cache_pun_repository.php';

if (!defined('FORUM_EXT_VERSIONS_LOADED') && file_exists(FORUM_CACHE_DIR.'cache_ext_version_notifications.php'))
	include FORUM_CACHE_DIR.'cache_ext_version_notifications.php';

// Regenerate cache only if automatic updates are enabled and if the cache is more than 12 hours old
if (!defined('PUN_REPOSITORY_EXTENSIONS_LOADED') || !defined('FORUM_EXT_VERSIONS_LOADED') || ($pun_repository_extensions_timestamp < $forum_ext_versions_update_cache))
{
	$pun_repository_error = '';

	if (pun_repository_generate_cache($pun_repository_error))
	{
		require FORUM_CACHE_DIR.'cache_pun_repository.php';
	}
	else
	{

		?>
		<div class="ct-box warn-box">
			<p class="warn"><?php echo $pun_repository_error ?></p>
		</div>
		<?php

		// Stop processing hook
		return;
	}
}

$pun_repository_parsed = array();
$pun_repository_skipped = array();

// Display information about extensions in repository
foreach ($pun_repository_extensions as $pun_repository_ext)
{
	// Skip installed extensions
	if (isset($inst_exts[$pun_repository_ext['id']]))
	{
		$pun_repository_skipped['installed'][] = $pun_repository_ext['id'];
		continue;
	}

	// Skip uploaded extensions (including incorrect ones)
	if (is_dir(FORUM_ROOT.'extensions/'.$pun_repository_ext['id']))
	{
		$pun_repository_skipped['has_dir'][] = $pun_repository_ext['id'];
		continue;
	}

	// Check for unresolved dependencies
	if (isset($pun_repository_ext['dependencies']))
		$pun_repository_ext['dependencies'] = pun_repository_check_dependencies($inst_exts, $pun_repository_ext['dependencies']);

	if (empty($pun_repository_ext['dependencies']['unresolved']))
	{
		// 'Download and install' link
		$pun_repository_ext['options'] = array('<a href="'.$base_url.'/admin/extensions.php?pun_repository_download_and_install='.$pun_repository_ext['id'].'&amp;csrf_token='.generate_form_token('pun_repository_download_and_install_'.$pun_repository_ext['id']).'">'.$lang_pun_repository['Download and install'].'</a>');
	}
	else
		$pun_repository_ext['options'] = array();

	$pun_repository_parsed[] = $pun_repository_ext['id'];

	// Direct links to archives
	$pun_repository_ext['download_links'] = array();
	foreach (array('zip', 'tgz', '7z') as $pun_repository_archive_type)
		$pun_repository_ext['download_links'][] = '<a href="'.PUN_REPOSITORY_URL.'/'.$pun_repository_ext['id'].'/'.$pun_repository_ext['id'].'.'.$pun_repository_archive_type.'">'.$pun_repository_archive_type.'</a>';

	($hook = get_hook('pun_repository_pre_display_ext_info')) ? eval($hook) : null;

	// Let's ptint it all out
?>
		<div class="ct-box info-box extension available" id="<?php echo $pun_repository_ext['id'] ?>">
			<h3 class="ct-legend hn"><span><?php echo forum_htmlencode($pun_repository_ext['title']).' '.$pun_repository_ext['version'] ?></span></h3>
			<p><?php echo forum_htmlencode($pun_repository_ext['description']) ?></p>
<?php

	// List extension dependencies
	if (!empty($pun_repository_ext['dependencies']['dependency']))
		echo '
			<p>', $lang_pun_repository['Dependencies:'], ' ', implode(', ', $pun_repository_ext['dependencies']['dependency']), '</p>';

?>
			<p><?php echo $lang_pun_repository['Direct download links:'], ' ', implode(' ', $pun_repository_ext['download_links']) ?></p>
<?php

	// List unresolved dependencies
	if (!empty($pun_repository_ext['dependencies']['unresolved']))
		echo '
			<div class="ct-box warn-box">
				<p class="warn">', $lang_pun_repository['Resolve dependencies:'], ' ', implode(', ', array_map(create_function('$dep', 'return \'<a href="#\'.$dep.\'">\'.$dep.\'</a>\';'), $pun_repository_ext['dependencies']['unresolved'])), '</p>
			</div>';

	// Actions
	if (!empty($pun_repository_ext['options']))
		echo '
			<p class="options">', implode(' ', $pun_repository_ext['options']), '</p>';

?>
		</div>
<?php

}

?>
		<div class="ct-box warn-box">
			<p class="warn"><?php echo $lang_pun_repository['Files mode and owner'] ?></p>
		</div>
<?php

if (empty($pun_repository_parsed) && (count($pun_repository_skipped['installed']) > 0 || count($pun_repository_skipped['has_dir']) > 0))
{
	($hook = get_hook('pun_repository_no_extensions')) ? eval($hook) : null;

	?>
		<div class="ct-box info-box">
			<p class="warn"><?php echo $lang_pun_repository['All installed or downloaded'] ?></p>
		</div>
	<?php

}

($hook = get_hook('pun_repository_after_ext_list')) ? eval($hook) : null;

?>
	</div>
<?php
		]]></hook>

		<hook id="aex_new_action"><![CDATA[
// Clear pun_repository cache
if (isset($_GET['pun_repository_update']))
{
	// Validate CSRF token
	if (!isset($_POST['csrf_token']) && (!isset($_GET['csrf_token']) || $_GET['csrf_token'] !== generate_form_token('pun_repository_update')))
		csrf_confirm_form();

	if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/pun_repository.php'))
		include $ext_info['path'].'/lang/'.$forum_user['language'].'/pun_repository.php';
	else
		include $ext_info['path'].'/lang/English/pun_repository.php';

	@unlink(FORUM_CACHE_DIR.'cache_pun_repository.php');
	if (file_exists(FORUM_CACHE_DIR.'cache_pun_repository.php'))
		message($lang_pun_repository['Unable to remove cached file'], '', $lang_pun_repository['PunBB Repository']);

	redirect($base_url.'/admin/extensions.php?section=manage', $lang_pun_repository['Cache has been successfully cleared']);
}

if (isset($_GET['pun_repository_download_and_install']))
{
	$ext_id = preg_replace('/[^0-9a-z_]/', '', $_GET['pun_repository_download_and_install']);

	// Validate CSRF token
	if (!isset($_POST['csrf_token']) && (!isset($_GET['csrf_token']) || $_GET['csrf_token'] !== generate_form_token('pun_repository_download_and_install_'.$ext_id)))
		csrf_confirm_form();

	// TODO: Should we check again for unresolved dependencies here?

	if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/pun_repository.php'))
		include $ext_info['path'].'/lang/'.$forum_user['language'].'/pun_repository.php';
	else
		include $ext_info['path'].'/lang/English/pun_repository.php';

	require_once $ext_info['path'].'/pun_repository.php';

	($hook = get_hook('pun_repository_download_and_install_start')) ? eval($hook) : null;

	// Download extension
	$pun_repository_error = pun_repository_download_extension($ext_id, $ext_data);

	if ($pun_repository_error == '')
	{
		if (empty($ext_data))
			redirect($base_url.'/admin/extensions.php?section=manage', $lang_pun_repository['Incorrect manifest.xml']);

		// Validate manifest
		$errors = validate_manifest($ext_data, $ext_id);
		if (!empty($errors))
			redirect($base_url.'/admin/extensions.php?section=manage', $lang_pun_repository['Incorrect manifest.xml']);

		// Everything is OK. Start installation.
		redirect($base_url.'/admin/extensions.php?install='.urlencode($ext_id), $lang_pun_repository['Download successful']);
	}

	($hook = get_hook('pun_repository_download_and_install_end')) ? eval($hook) : null;
}

// Handling the download and update extension action
if (isset($_GET['pun_repository_download_and_update']))
{
	$ext_id = preg_replace('/[^0-9a-z_]/', '', $_GET['pun_repository_download_and_update']);

	// Validate CSRF token
	if (!isset($_POST['csrf_token']) && (!isset($_GET['csrf_token']) || $_GET['csrf_token'] !== generate_form_token('pun_repository_download_and_update_'.$ext_id)))
		csrf_confirm_form();

	if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/pun_repository.php'))
		include $ext_info['path'].'/lang/'.$forum_user['language'].'/pun_repository.php';
	else
		include $ext_info['path'].'/lang/English/pun_repository.php';

	require_once $ext_info['path'].'/pun_repository.php';

	$pun_repository_error = '';

	($hook = get_hook('pun_repository_download_and_update_start')) ? eval($hook) : null;

	@pun_repository_rm_recursive(FORUM_ROOT.'extensions/'.$ext_id.'.old');

	// Check dependancies
	$query = array(
		'SELECT'	=> 'e.id',
		'FROM'		=> 'extensions AS e',
		'WHERE'		=> 'e.disabled=0 AND e.dependencies LIKE \'%|'.$forum_db->escape($ext_id).'|%\''
	);

	($hook = get_hook('aex_qr_get_disable_dependencies')) ? eval($hook) : null;
	$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);

	if ($forum_db->num_rows($result) != 0)
	{
		$dependency = $forum_db->fetch_assoc($result);
		$pun_repository_error = sprintf($lang_admin['Disable dependency'], $dependency['id']);
	}

	if ($pun_repository_error == '' && ($ext_id != $ext_info['id']))
	{
		// Disable extension
		$query = array(
			'UPDATE'	=> 'extensions',
			'SET'		=> 'disabled=1',
			'WHERE'		=> 'id=\''.$forum_db->escape($ext_id).'\''
		);

		($hook = get_hook('aex_qr_update_disabled_status')) ? eval($hook) : null;
		$forum_db->query_build($query) or error(__FILE__, __LINE__);

		// Regenerate the hooks cache
		require_once FORUM_ROOT.'include/cache.php';
		generate_hooks_cache();
	}

	if ($pun_repository_error == '')
	{
		if ($ext_id == $ext_info['id'])
		{
			// Hey! That's me!
			// All the necessary files should be included before renaming old directory
			// NOTE: Self-updating is to be tested more in real-life conditions
			if (!defined('PUN_REPOSITORY_TAR_EXTRACT_INCLUDED'))
				require $ext_info['path'].'/pun_repository_tar_extract.php';
		}

		$pun_repository_error = pun_repository_download_extension($ext_id, $ext_data, FORUM_ROOT.'extensions/'.$ext_id.'.new'); // Download the extension

		if ($pun_repository_error == '')
		{
			if (is_writable(FORUM_ROOT.'extensions/'.$ext_id))
				pun_repository_dir_copy(FORUM_ROOT.'extensions/'.$ext_id.'.new/'.$ext_id, FORUM_ROOT.'extensions/'.$ext_id);
			else
				$pun_repository_error = sprintf($lang_pun_repository['Copy fail'], FORUM_ROOT.'extensions/'.$ext_id);
		}
	}

	if ($pun_repository_error == '')
	{
		// Do we have extension data at all? :-)
		if (empty($ext_data))
			$errors = array(true);

		// Validate manifest
		if (empty($errors))
			$errors = validate_manifest($ext_data, $ext_id);

		if (!empty($errors))
			$pun_repository_error = $lang_pun_repository['Incorrect manifest.xml'];
	}

	if ($pun_repository_error == '')
	{
		($hook = get_hook('pun_repository_download_and_update_ok')) ? eval($hook) : null;

		// Everything is OK. Start installation.
		pun_repository_rm_recursive(FORUM_ROOT.'extensions/'.$ext_id.'.new');
		redirect($base_url.'/admin/extensions.php?install='.urlencode($ext_id), $lang_pun_repository['Download successful']);
	}

	($hook = get_hook('pun_repository_download_and_update_error')) ? eval($hook) : null;

	// Enable extension
	$query = array(
		'UPDATE'	=> 'extensions',
		'SET'		=> 'disabled=0',
		'WHERE'		=> 'id=\''.$forum_db->escape($ext_id).'\''
	);

	($hook = get_hook('aex_qr_update_enabled_status')) ? eval($hook) : null;
	$forum_db->query_build($query) or error(__FILE__, __LINE__);

	// Regenerate the hooks cache
	require_once FORUM_ROOT.'include/cache.php';
	generate_hooks_cache();

	($hook = get_hook('pun_repository_download_and_update_end')) ? eval($hook) : null;
}

// Do we have some error?
if (!empty($pun_repository_error))
{
	// Setup breadcrumbs
	$forum_page['crumbs'] = array(
		array($forum_config['o_board_title'], forum_link($forum_url['index'])),
		array($lang_admin_common['Forum administration'], forum_link($forum_url['admin_index'])),
		array($lang_admin_common['Extensions'], forum_link($forum_url['admin_extensions_manage'])),
		array($lang_admin_common['Manage extensions'], forum_link($forum_url['admin_extensions_manage'])),
		$lang_pun_repository['PunBB Repository']
	);

	($hook = get_hook('pun_repository__pre_header_load')) ? eval($hook) : null;

	define('FORUM_PAGE_SECTION', 'extensions');
	define('FORUM_PAGE', 'admin-extensions-pun-repository');
	require FORUM_ROOT.'header.php';

	// START SUBST - <!-- forum_main -->
	ob_start();

	($hook = get_hook('pun_repository_display_error_output_start')) ? eval($hook) : null;

?>
	<div class="main-subhead">
		<h2 class="hn"><span><?php echo $lang_pun_repository['PunBB Repository'] ?></span></h2>
	</div>
	<div class="main-content">
		<div class="ct-box warn-box">
			<p class="warn"><?php echo $pun_repository_error ?></p>
		</div>
	</div>
<?php

	($hook = get_hook('pun_repository_display_error_pre_ob_end')) ? eval($hook) : null;

	$tpl_temp = trim(ob_get_contents());
	$tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
	ob_end_clean();
	// END SUBST - <!-- forum_main -->

	require FORUM_ROOT.'footer.php';
}
		]]></hook>

		<hook id="aex_section_manage_pre_header_load"><![CDATA[
if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/pun_repository.php'))
	include $ext_info['path'].'/lang/'.$forum_user['language'].'/pun_repository.php';
else
	include $ext_info['path'].'/lang/English/pun_repository.php';

require_once $ext_info['path'].'/pun_repository.php';

if (!defined('PUN_REPOSITORY_EXTENSIONS_LOADED') && file_exists(FORUM_CACHE_DIR.'cache_pun_repository.php'))
	include FORUM_CACHE_DIR.'cache_pun_repository.php';

if (!defined('FORUM_EXT_VERSIONS_LOADED') && file_exists(FORUM_CACHE_DIR.'cache_ext_version_notifications.php'))
	include FORUM_CACHE_DIR.'cache_ext_version_notifications.php';

// Regenerate cache only if automatic updates are enabled and if the cache is more than 12 hours old
if (!defined('PUN_REPOSITORY_EXTENSIONS_LOADED') || !defined('FORUM_EXT_VERSIONS_LOADED') || ($pun_repository_extensions_timestamp < $forum_ext_versions_update_cache))
{
	if (pun_repository_generate_cache($pun_repository_error))
		require FORUM_CACHE_DIR.'cache_pun_repository.php';
}
		]]></hook>

		<hook id="aex_section_manage_pre_ext_actions"><![CDATA[
if (defined('PUN_REPOSITORY_EXTENSIONS_LOADED') && isset($pun_repository_extensions[$id]) && version_compare($ext['version'], $pun_repository_extensions[$id]['version'], '<') && is_writable(FORUM_ROOT.'extensions/'.$id))
{
	// Check for unresolved dependencies
	if (isset($pun_repository_extensions[$id]['dependencies']))
		$pun_repository_extensions[$id]['dependencies'] = pun_repository_check_dependencies($inst_exts, $pun_repository_extensions[$id]['dependencies']);

	if (empty($pun_repository_extensions[$id]['dependencies']['unresolved']))
		$forum_page['ext_actions'][] = '<span><a href="'.$base_url.'/admin/extensions.php?pun_repository_download_and_update='.$id.'&amp;csrf_token='.generate_form_token('pun_repository_download_and_update_'.$id).'">'.$lang_pun_repository['Download and update'].'</a></span>';
}
		]]></hook>

		<hook id="co_common"><![CDATA[
$pun_extensions_used = array_merge(isset($pun_extensions_used) ? $pun_extensions_used : array(), array($ext_info['id']));
		]]></hook>
		<hook id="ft_about_end" priority="9"><![CDATA[
if (!defined('PUN_EXTENSIONS_USED') && !empty($pun_extensions_used))
{
	define('PUN_EXTENSIONS_USED', 1);
	if (count($pun_extensions_used) == 1)
		echo '<p style="clear: both; ">The '.$pun_extensions_used[0].' official extension is installed. Copyright &copy; 2003&ndash;2009 <a href="http://punbb.informer.com/">PunBB</a>.</p>';
	else
		echo '<p style="clear: both; ">Currently installed <span id="extensions-used" title="'.implode(', ', $pun_extensions_used).'.">'.count($pun_extensions_used).' official extensions</span>. Copyright &copy; 2003&ndash;2009 <a href="http://punbb.informer.com/">PunBB</a>.</p>';
}
		]]></hook>
	</hooks>

</extension>
Return current item: PunBB