Página 1 de 1

Ayuda MOD Advanced BBCode Box 3.3.0.9.3

Publicado: 29 Nov 2011, 15:21
por RoX-GD
Datos
URL: http://sekaiwissen.org/foros
Versión phpBB: 3.0.9
MODs Instalados: Advanced BBCode Box 3.3.0.9.3
Plantilla(s) usada(s): 610nm
Servidor: Linux, de pago, 1&1
Actualización desde otra versión: No
Conversión desde otro sistema de foros: No
URL del MOD:: http://www.phpbb-es.com/foro/descarga-m ... 24855.html
¡Saludos!

El problema que tengo es que estoy instalando un foro phpbb3 y tocaba empezar a instalar MODificaciones. Empecé por el Advanced BBCode Box 3, seguí los pasos de instalación que vienen con la descarga, sustituí y edité lo necesario, pero el problema viene que cuando entro al ACP de mi foro, en la sección Mensajes, me sale el siguiente error:

Código: Seleccionar todo

Parse error: syntax error, unexpected T_STRING in /homepages/36/d392069853/htdocs/foros/includes/acp/acp_bbcodes.php on line 62
Éste es mi archivo includes/acp/acp_bbcodes.php:
SPOILER_SHOW

Código: Seleccionar todo

<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

/**
* @package acp
*/
class acp_bbcodes
{
	var $u_action;

	function main($id, $mode)
	{
		global $db, $user, $auth, $template, $cache;
		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;

		$user->add_lang('acp/posting');

		// Set up general vars
		$action	= request_var('action', '');
		$bbcode_id = request_var('bbcode', 0);

		$this->tpl_name = 'acp_bbcodes';
		$this->page_title = 'ACP_BBCODES';
		$form_key = 'acp_bbcodes';

		add_form_key($form_key);

		// Set up mode-specific vars
		switch ($action)
		{
			case 'add':
				$bbcode_match = $bbcode_tpl = $bbcode_helpline = '';
				$display_on_posting = 0;
			break;

			case 'edit':
				$sql = 'SELECT bbcode_match, bbcode_tpl, display_on_posting, bbcode_helpline, abbcode 
					FROM ' . BBCODES_TABLE . '
				    WHERE bbcode_id = ' . $bbcode_id. ' and abbcode = 0;
					 $bbcode_id;
				$result = $db->sql_query($sql);
				$row = $db->sql_fetchrow($result);
				$db->sql_freeresult($result);

				if (!$row)
				{
					trigger_error($user->lang['BBCODE_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
				}

				$bbcode_match = $row['bbcode_match'];
				$bbcode_tpl = htmlspecialchars($row['bbcode_tpl']);
				$display_on_posting = $row['display_on_posting'];
				$bbcode_helpline = $row['bbcode_helpline'];
			break;

			case 'modify':
				$sql = 'SELECT bbcode_id, bbcode_tag, abbcode 
					FROM ' . BBCODES_TABLE . '
					WHERE bbcode_id = '  . ' and abbcode = 0' . $bbcode_id;
				$result = $db->sql_query($sql);
				$row = $db->sql_fetchrow($result);
				$db->sql_freeresult($result);

				if (!$row)
				{
					trigger_error($user->lang['BBCODE_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
				}

			// No break here

			case 'create':
				$display_on_posting = request_var('display_on_posting', 0);

				$bbcode_match = request_var('bbcode_match', '');
				$bbcode_tpl = htmlspecialchars_decode(utf8_normalize_nfc(request_var('bbcode_tpl', '', true)));
				$bbcode_helpline = utf8_normalize_nfc(request_var('bbcode_helpline', '', true));
			break;
		}

		// Do major work
		switch ($action)
		{
			case 'edit':
			case 'add':

				$template->assign_vars(array(
					'S_EDIT_BBCODE'		=> true,
					'U_BACK'			=> $this->u_action,
					'U_ACTION'			=> $this->u_action . '&action=' . (($action == 'add') ? 'create' : 'modify') . (($bbcode_id) ? "&bbcode=$bbcode_id" : ''),

					'L_BBCODE_USAGE_EXPLAIN'=> sprintf($user->lang['BBCODE_USAGE_EXPLAIN'], '<a href="#down">', '</a>'),
					'BBCODE_MATCH'			=> $bbcode_match,
					'BBCODE_TPL'			=> $bbcode_tpl,
					'BBCODE_HELPLINE'		=> $bbcode_helpline,
					'DISPLAY_ON_POSTING'	=> $display_on_posting)
				);

				foreach ($user->lang['tokens'] as $token => $token_explain)
				{
					$template->assign_block_vars('token', array(
						'TOKEN'		=> '{' . $token . '}',
						'EXPLAIN'	=> $token_explain)
					);
				}

				return;

			break;

			case 'modify':
			case 'create':

				$warn_text = preg_match('%<[^>]*\{text[\d]*\}[^>]*>%i', $bbcode_tpl);
				if (!$warn_text || confirm_box(true))
				{
					$data = $this->build_regexp($bbcode_match, $bbcode_tpl);

					// Make sure the user didn't pick a "bad" name for the BBCode tag.
					$hard_coded = array('code', 'quote', 'quote=', 'attachment', 'attachment=', 'b', 'i', 'url', 'url=', 'img', 'size', 'size=', 'color', 'color=', 'u', 'list', 'list=', 'email', 'email=', 'flash', 'flash=');

					if (($action == 'modify' && strtolower($data['bbcode_tag']) !== strtolower($row['bbcode_tag'])) || ($action == 'create'))
					{
						$sql = 'SELECT 1 as test
							FROM ' . BBCODES_TABLE . "
							WHERE LOWER(bbcode_tag) = '" . $db->sql_escape(strtolower($data['bbcode_tag'])) . "'";
						$result = $db->sql_query($sql);
						$info = $db->sql_fetchrow($result);
						$db->sql_freeresult($result);

						// Grab the end, interrogate the last closing tag
						if ($info['test'] === '1' || in_array(strtolower($data['bbcode_tag']), $hard_coded) || (preg_match('#\[/([^[]*)]$#', $bbcode_match, $regs) && in_array(strtolower($regs[1]), $hard_coded)))
						{
							trigger_error($user->lang['BBCODE_INVALID_TAG_NAME'] . adm_back_link($this->u_action), E_USER_WARNING);
						}
					}

					if (substr($data['bbcode_tag'], -1) === '=')
					{
						$test = substr($data['bbcode_tag'], 0, -1);
					}
					else
					{
						$test = $data['bbcode_tag'];
					}

					if (!preg_match('%\\[' . $test . '[^]]*].*?\\[/' . $test . ']%s', $bbcode_match))
					{
						trigger_error($user->lang['BBCODE_OPEN_ENDED_TAG'] . adm_back_link($this->u_action), E_USER_WARNING);
					}

					if (strlen($data['bbcode_tag']) > 16)
					{
						trigger_error($user->lang['BBCODE_TAG_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);
					}

					if (strlen($bbcode_match) > 4000)
					{
						trigger_error($user->lang['BBCODE_TAG_DEF_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);
					}


					if (strlen($bbcode_helpline) > 255)
					{
						trigger_error($user->lang['BBCODE_HELPLINE_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);
					}

					$sql_ary = array(
						'bbcode_tag'				=> $data['bbcode_tag'],
						'bbcode_match'				=> $bbcode_match,
						'bbcode_tpl'				=> $bbcode_tpl,
						'display_on_posting'		=> $display_on_posting,
						'bbcode_helpline'			=> $bbcode_helpline,
						'first_pass_match'			=> $data['first_pass_match'],
						'first_pass_replace'		=> $data['first_pass_replace'],
						'second_pass_match'			=> $data['second_pass_match'],
						'second_pass_replace'		=> $data['second_pass_replace']
					);

					if ($action == 'create')
					{
						$sql = 'SELECT MAX(bbcode_id) as max_bbcode_id
							FROM ' . BBCODES_TABLE;
						$result = $db->sql_query($sql);
						$row = $db->sql_fetchrow($result);
						$db->sql_freeresult($result);

						if ($row)
						{
							$bbcode_id = $row['max_bbcode_id'] + 1;

							// Make sure it is greater than the core bbcode ids...
							if ($bbcode_id <= NUM_CORE_BBCODES)
							{
								$bbcode_id = NUM_CORE_BBCODES + 1;
							}
						}
						else
						{
							$bbcode_id = NUM_CORE_BBCODES + 1;
						}

						if ($bbcode_id > BBCODE_LIMIT)
						{
							trigger_error($user->lang['TOO_MANY_BBCODES'] . adm_back_link($this->u_action), E_USER_WARNING);
						}

						$sql_ary['bbcode_id'] = (int) $bbcode_id;
// MOD : MSSTI ABBC3 - Start
						$sql = 'SELECT MAX(bbcode_order) as max_bbcode_order
							FROM ' . BBCODES_TABLE;
						$result = $db->sql_query($sql);
						$row = $db->sql_fetchrow($result);
						$db->sql_freeresult($result);
						$bbcode_order = $row['max_bbcode_order'] + 1;
						$sql_ary['bbcode_order'] = (int) $bbcode_order;
// MOD : MSSTI ABBC3 - End

						$db->sql_query('INSERT INTO ' . BBCODES_TABLE . $db->sql_build_array('INSERT', $sql_ary));
						$cache->destroy('sql', BBCODES_TABLE);

						$lang = 'BBCODE_ADDED';
						$log_action = 'LOG_BBCODE_ADD';
					}
					else
					{
						$sql = 'UPDATE ' . BBCODES_TABLE . '
							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
							WHERE bbcode_id = ' . $bbcode_id;
						$db->sql_query($sql);
						$cache->destroy('sql', BBCODES_TABLE);

						$lang = 'BBCODE_EDITED';
						$log_action = 'LOG_BBCODE_EDIT';
					}

					add_log('admin', $log_action, $data['bbcode_tag']);

					trigger_error($user->lang[$lang] . adm_back_link($this->u_action));
				}
				else
				{
					confirm_box(false, $user->lang['BBCODE_DANGER'], build_hidden_fields(array(
						'action'				=> $action,
						'bbcode'				=> $bbcode_id,
						'bbcode_match'			=> $bbcode_match,
						'bbcode_tpl'			=> htmlspecialchars($bbcode_tpl),
						'bbcode_helpline'		=> $bbcode_helpline,
						'display_on_posting'	=> $display_on_posting,
						))
					, 'confirm_bbcode.html');
				}

			break;

			case 'delete':

				$sql = 'SELECT bbcode_tag, abbcode 
					FROM ' . BBCODES_TABLE . "
					WHERE bbcode_id =  . ' and abbcode = 0' $bbcode_id";
				$result = $db->sql_query($sql);
				$row = $db->sql_fetchrow($result);
				$db->sql_freeresult($result);

				if ($row)
				{
					if (confirm_box(true))
					{
						$db->sql_query('DELETE FROM ' . BBCODES_TABLE . " WHERE bbcode_id = $bbcode_id");
						$cache->destroy('sql', BBCODES_TABLE);
						add_log('admin', 'LOG_BBCODE_DELETE', $row['bbcode_tag']);
					}
					else
					{
						confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
							'bbcode'	=> $bbcode_id,
							'i'			=> $id,
							'mode'		=> $mode,
							'action'	=> $action))
						);
					}
				}

			break;
		}

		$template->assign_vars(array(
			'U_ACTION'		=> $this->u_action . '&action=add')
		);

		$sql = 'SELECT *
			FROM ' . BBCODES_TABLE . '
			WHERE abbcode = 0 ORDER BY bbcode_tag';
		$result = $db->sql_query($sql);

		while ($row = $db->sql_fetchrow($result))
		{
			$template->assign_block_vars('bbcodes', array(
				'BBCODE_TAG'		=> $row['bbcode_tag'],
				'U_EDIT'			=> $this->u_action . '&action=edit&bbcode=' . $row['bbcode_id'],
				'U_DELETE'			=> $this->u_action . '&action=delete&bbcode=' . $row['bbcode_id'])
			);
		}
		$db->sql_freeresult($result);
	}

	/*
	* Build regular expression for custom bbcode
	*/
	function build_regexp(&$bbcode_match, &$bbcode_tpl)
	{
		$bbcode_match = trim($bbcode_match);
		$bbcode_tpl = trim($bbcode_tpl);
		$utf8 = strpos($bbcode_match, 'INTTEXT') !== false;

		// make sure we have utf8 support
		$utf8_pcre_properties = false;
		if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>=')))
		{
			// While this is the proper range of PHP versions, PHP may not be linked with the bundled PCRE lib and instead with an older version
			if (@preg_match('/\p{L}/u', 'a') !== false)
			{
				$utf8_pcre_properties = true;
			}
		}

		$fp_match = preg_quote($bbcode_match, '!');
		$fp_replace = preg_replace('#^\[(.*?)\]#', '[$1:$uid]', $bbcode_match);
		$fp_replace = preg_replace('#\[/(.*?)\]$#', '[/$1:$uid]', $fp_replace);

		$sp_match = preg_quote($bbcode_match, '!');
		$sp_match = preg_replace('#^\\\\\[(.*?)\\\\\]#', '\[$1:$uid\]', $sp_match);
		$sp_match = preg_replace('#\\\\\[/(.*?)\\\\\]$#', '\[/$1:$uid\]', $sp_match);
		$sp_replace = $bbcode_tpl;

		// @todo Make sure to change this too if something changed in message parsing
		$tokens = array(
			'URL'	 => array(
				'!(?:(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('url')) . ')|(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('www_url')) . '))!ie'	=>	"\$this->bbcode_specialchars(('\$1') ? '\$1' : 'http://\$2')"
			),
			'LOCAL_URL'	 => array(
				'!(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')!e'	=>	"\$this->bbcode_specialchars('$1')"
			),
			'EMAIL' => array(
				'!(' . get_preg_expression('email') . ')!ie'	=>	"\$this->bbcode_specialchars('$1')"
			),
			'TEXT' => array(
				'!(.*?)!es'	 =>	"str_replace(array(\"\\r\\n\", '\\\"', '\\'', '(', ')'), array(\"\\n\", '\"', ''', '&#40;', '&#41;'), trim('\$1'))"
			),
			'SIMPLETEXT' => array(
				'!([a-zA-Z0-9-+.,_ ]+)!'	 =>	"$1"
			),
			'INTTEXT' => array(
				($utf8_pcre_properties) ? '!([\p{L}\p{N}\-+,_. ]+)!u' : '!([a-zA-Z0-9\-+,_. ]+)!u'	 =>	"$1"
			),
			'IDENTIFIER' => array(
				'!([a-zA-Z0-9-_]+)!'	 =>	"$1"
			),
			'COLOR' => array(
				'!([a-z]+|#[0-9abcdef]+)!i'	=>	'$1'
			),
			'NUMBER' => array(
				'!([0-9]+)!'	=>	'$1'
			)
		);

		$sp_tokens = array(
			'URL'	 => '(?i)((?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('url')) . ')|(?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('www_url')) . '))(?-i)',
			'LOCAL_URL'	 => '(?i)(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')(?-i)',
			'EMAIL' => '(' . get_preg_expression('email') . ')',
			'TEXT' => '(.*?)',
			'SIMPLETEXT' => '([a-zA-Z0-9-+.,_ ]+)',
			'INTTEXT' => ($utf8_pcre_properties) ? '([\p{L}\p{N}\-+,_. ]+)' : '([a-zA-Z0-9\-+,_. ]+)',
			'IDENTIFIER' => '([a-zA-Z0-9-_]+)',
			'COLOR' => '([a-zA-Z]+|#[0-9abcdefABCDEF]+)',
			'NUMBER' => '([0-9]+)',
		);

		$pad = 0;
		$modifiers = 'i';
		$modifiers .= ($utf8 && $utf8_pcre_properties) ? 'u' : '';

		if (preg_match_all('/\{(' . implode('|', array_keys($tokens)) . ')[0-9]*\}/i', $bbcode_match, $m))
		{
			foreach ($m[0] as $n => $token)
			{
				$token_type = $m[1][$n];

				reset($tokens[strtoupper($token_type)]);
				list($match, $replace) = each($tokens[strtoupper($token_type)]);

				// Pad backreference numbers from tokens
				if (preg_match_all('/(?<!\\\\)\$([0-9]+)/', $replace, $repad))
				{
					$repad = $pad + sizeof(array_unique($repad[0]));
					$replace = preg_replace('/(?<!\\\\)\$([0-9]+)/e', "'\${' . (\$1 + \$pad) . '}'", $replace);
					$pad = $repad;
				}

				// Obtain pattern modifiers to use and alter the regex accordingly
				$regex = preg_replace('/!(.*)!([a-z]*)/', '$1', $match);
				$regex_modifiers = preg_replace('/!(.*)!([a-z]*)/', '$2', $match);

				for ($i = 0, $size = strlen($regex_modifiers); $i < $size; ++$i)
				{
					if (strpos($modifiers, $regex_modifiers[$i]) === false)
					{
						$modifiers .= $regex_modifiers[$i];

						if ($regex_modifiers[$i] == 'e')
						{
							$fp_replace = "'" . str_replace("'", "\\'", $fp_replace) . "'";
						}
					}

					if ($regex_modifiers[$i] == 'e')
					{
						$replace = "'.$replace.'";
					}
				}

				$fp_match = str_replace(preg_quote($token, '!'), $regex, $fp_match);
				$fp_replace = str_replace($token, $replace, $fp_replace);

				$sp_match = str_replace(preg_quote($token, '!'), $sp_tokens[$token_type], $sp_match);
				$sp_replace = str_replace($token, '${' . ($n + 1) . '}', $sp_replace);
			}

			$fp_match = '!' . $fp_match . '!' . $modifiers;
			$sp_match = '!' . $sp_match . '!s' . (($utf8) ? 'u' : '');

			if (strpos($fp_match, 'e') !== false)
			{
				$fp_replace = str_replace("'.'", '', $fp_replace);
				$fp_replace = str_replace(".''.", '.', $fp_replace);
			}
		}
		else
		{
			// No replacement is present, no need for a second-pass pattern replacement
			// A simple str_replace will suffice
			$fp_match = '!' . $fp_match . '!' . $modifiers;
			$sp_match = $fp_replace;
			$sp_replace = '';
		}

		// Lowercase tags
		$bbcode_tag = preg_replace('/.*?\[([a-z0-9_-]+=?).*/i', '$1', $bbcode_match);
		$bbcode_search = preg_replace('/.*?\[([a-z0-9_-]+)=?.*/i', '$1', $bbcode_match);

		if (!preg_match('/^[a-zA-Z0-9_-]+=?$/', $bbcode_tag))
		{
			global $user;
			trigger_error($user->lang['BBCODE_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
		}

		$fp_match = preg_replace('#\[/?' . $bbcode_search . '#ie', "strtolower('\$0')", $fp_match);
		$fp_replace = preg_replace('#\[/?' . $bbcode_search . '#ie', "strtolower('\$0')", $fp_replace);
		$sp_match = preg_replace('#\[/?' . $bbcode_search . '#ie', "strtolower('\$0')", $sp_match);
		$sp_replace = preg_replace('#\[/?' . $bbcode_search . '#ie', "strtolower('\$0')", $sp_replace);

		return array(
			'bbcode_tag'				=> $bbcode_tag,
			'first_pass_match'			=> $fp_match,
			'first_pass_replace'		=> $fp_replace,
			'second_pass_match'			=> $sp_match,
			'second_pass_replace'		=> $sp_replace
		);
	}
}

?>
No encuentro como solucionar el error, espero que me puedan ayudar. Muchas gracias.

Re: Ayuda MOD Advanced BBCode Box 3.3.0.9.3

Publicado: 29 Nov 2011, 15:46
por Megabyte
Creo que aqui va el asunto, mas o menos en la linea 53....

Revisar:

Código: Seleccionar todo

				    WHERE bbcode_id = ' . $bbcode_id. ' and abbcode = 0;
					 $bbcode_id;
				$result = $db->sql_query($sql);
creo q deberia de quedar asi:

Código: Seleccionar todo

					WHERE bbcode_id = ' . $bbcode_id . ' and abbcode = 0';
				$result = $db->sql_query($sql);

Re: Ayuda MOD Advanced BBCode Box 3.3.0.9.3  Tema Solucionado

Publicado: 29 Nov 2011, 17:21
por Alorse
Se debe a una mala instalación del MOD a la hora de editar los archivos correspondientes, por otro lado este tema debería estar en http://www.phpbb-es.com/titania/mod/mss ... 3/support/ que es para el soporte de dicho MOD.

Re: Ayuda MOD Advanced BBCode Box 3.3.0.9.3

Publicado: 29 Nov 2011, 23:54
por RoX-GD
¡Muchísimas gracias Megabyte !

Sí, ese era el problema, pero ahora han aparecido dos más.
  1. Los carácteres acentuados (y carácteres similares) no se ven (salen rombos), pero atención, solo ocurre en el ACP.
  2. Cuando intento acceder a[anchor=problema2 goto=imagenabbc3]ABBC3 BBCodes[/anchor] me da otro error que es el siguiente:

Código: Seleccionar todo

[phpBB Debug] PHP Warning: in file /includes/acp/acp_abbcodes.php on line 38: require(./../includes/abbcode.phpphp) [function.require]: failed to open stream: No such file or directory

Fatal error: require() [function.require]: Failed opening required './../includes/abbcode.phpphp' (include_path='.:/usr/lib/php5') in /homepages/36/d392069853/htdocs/foros/includes/acp/acp_abbcodes.php on line 38
Y bien, mi archivo includes/acp/acp_abbcodes.php es:
SPOILER_SHOW

Código: Seleccionar todo

<?php
/**
* @package: phpBB 3.0.9 :: Advanced BBCode box 3 -> root/includes/acp
* @version: $Id: acp_abbcode.php, v 3.0.9.3 2011/08/04 03:33:24 leviatan21 Exp $
* @copyright: leviatan21 < info@mssti.com > (Gabriel) http://www.mssti.com/phpbb3/
* @license: http://opensource.org/licenses/gpl-license.php GNU Public License
* @author: leviatan21 - http://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=345763
* @co-author: VSE - http://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=868795
**/

/**
* @ignore
**/
if (!defined('IN_PHPBB'))
{
	exit;
}

/**
* @package acp
**/
class acp_abbcodes
{
	var $u_action;
	var $u_back;
	var $new_config;
	var $submit;
	var $dir;
	
	function main($id, $mode)
	{
		global $db, $user, $auth, $template, $cache;
		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
		
		$user->add_lang(array('acp/styles', 'mods/acp_abbcodes', 'mods/abbcode'));

		// Include files
		require($phpbb_root_path . 'includes/abbcode.php' . $phpEx);

		$radio_ary = array(1 => 'ORDER_ALLOW_DENY', 0 => 'ORDER_DENY_ALLOW');

		/** Set some default values so the user havn't to run any install - Start **/
		// Same default values as root/install_abbc3.php -> abbc3_308()
		$config['ABBC3_VERSION']			= (isset($config['ABBC3_VERSION']))			? $config['ABBC3_VERSION']			: '3.0.9.3';
		$config['ABBC3_MOD']				= (isset($config['ABBC3_MOD']))				? $config['ABBC3_MOD']				: true;
//		$config['ABBC3_PATH']				= (isset($config['ABBC3_PATH']))			? $config['ABBC3_PATH']				: 'styles/abbcode';
		$config['ABBC3_BG']					= (isset($config['ABBC3_BG']))				? $config['ABBC3_BG']				: 'bg_abbc3.gif';
		$config['ABBC3_TAB']				= (isset($config['ABBC3_TAB']))				? $config['ABBC3_TAB']				: 1;

		$config['ABBC3_BOXRESIZE']			= (isset($config['ABBC3_BOXRESIZE']))		? $config['ABBC3_BOXRESIZE']		: 1;
		$config['ABBC3_RESIZE']				= (isset($config['ABBC3_RESIZE']))			? $config['ABBC3_RESIZE']			: 1;
		$config['ABBC3_RESIZE_METHOD']		= (isset($config['ABBC3_RESIZE_METHOD']))	? $config['ABBC3_RESIZE_METHOD']	: 'AdvancedBox';
		$config['ABBC3_RESIZE_BAR']			= (isset($config['ABBC3_RESIZE_BAR']))		? $config['ABBC3_RESIZE_BAR']		: 1;
		$config['ABBC3_MAX_IMG_WIDTH']		= (isset($config['ABBC3_MAX_IMG_WIDTH']))	? $config['ABBC3_MAX_IMG_WIDTH']	: ($config['img_max_width']	? $config['img_max_width'] : 500);
		$config['ABBC3_MAX_IMG_HEIGHT']		= (isset($config['ABBC3_MAX_IMG_HEIGHT']))	? $config['ABBC3_MAX_IMG_HEIGHT']	: ($config['img_max_height'] ? $config['img_max_height'] : 0);
		$config['ABBC3_RESIZE_SIGNATURE']	= (isset($config['ABBC3_RESIZE_SIGNATURE']))? $config['ABBC3_RESIZE_SIGNATURE']	: 0;
		$config['ABBC3_MAX_SIG_WIDTH']		= (isset($config['ABBC3_MAX_SIG_WIDTH']))	? $config['ABBC3_MAX_SIG_WIDTH']	: ($config['max_sig_img_width'] ? $config['max_sig_img_width'] : 200);
		$config['ABBC3_MAX_SIG_HEIGHT']		= (isset($config['ABBC3_MAX_SIG_HEIGHT']))	? $config['ABBC3_MAX_SIG_HEIGHT']	: 0;
		$config['ABBC3_MAX_THUM_WIDTH']		= (isset($config['ABBC3_MAX_THUM_WIDTH']))	? $config['ABBC3_MAX_THUM_WIDTH']	: ($config['img_max_thumb_width'] ? $config['img_max_thumb_width']/2 : 200);

		$config['ABBC3_COLOR_MODE']			= (isset($config['ABBC3_COLOR_MODE']))		? $config['ABBC3_COLOR_MODE']		: 'phpbb';
		$config['ABBC3_HIGHLIGHT_MODE']		= (isset($config['ABBC3_HIGHLIGHT_MODE']))	? $config['ABBC3_HIGHLIGHT_MODE']	: 'dropdown';

		$config['ABBC3_WIZARD_MODE']		= (isset($config['ABBC3_WIZARD_MODE']))		? $config['ABBC3_WIZARD_MODE']		: 1;
		$config['ABBC3_WIZARD_width']		= (isset($config['ABBC3_WIZARD_width']))	? $config['ABBC3_WIZARD_width']		: 700;
		$config['ABBC3_WIZARD_height']		= (isset($config['ABBC3_WIZARD_height']))	? $config['ABBC3_WIZARD_height']	: 400;

		$config['ABBC3_VIDEO_width']		= (isset($config['ABBC3_VIDEO_width']))		? $config['ABBC3_VIDEO_width']		: 425;
		$config['ABBC3_VIDEO_height']		= (isset($config['ABBC3_VIDEO_height']))	? $config['ABBC3_VIDEO_height']		: 350;
		$config['ABBC3_VIDEO_OPTIONS']		= (isset($config['ABBC3_VIDEO_OPTIONS']))	? $config['ABBC3_VIDEO_OPTIONS']	: '1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31;32;33;34;35;36;37;38;39;40;41;42;43;44;45;46;47;48;49;50;201;202;203;204;205;206;207;208;';

		$config['ABBC3_UCP_MODE']			= (isset($config['ABBC3_UCP_MODE']))		? $config['ABBC3_UCP_MODE']			: 1;
		/** Set some default values so the user havn't to run any install - End **/

		// Set up general vars
		$action				= request_var('action', '');
		$bbcode_id			= request_var('bbcode_id', 0);

		$this->tpl_name		= 'acp_abbcodes';
		$this->page_title	= 'ACP_ABBCODES';
		$form_key			= 'acp_abbcodes';

		add_form_key($form_key);

		$this->u_back 		= $this->u_action;
		$this->submit		= (isset($_POST['submit'])) ? true : false;
		$abbc3_root_path	= ($phpbb_admin_path) ? $phpbb_admin_path : $phpbb_root_path ;
		$this->dir 			= $phpbb_root_path . 'styles/abbcode' ;

		// Execute overall actions
		switch ($mode)
		{
			case 'settings':
				$this->abbc3_details();
				break;

			case 'bbcodes'	:
				switch ($action)
				{
					case 'sync':
						$this->resync_abbcodes();

					// no break;
					case 'newdlb':
						$this->add_division	= (isset($_POST['add_division'])) ? true : false;
						$this->add_linebreak= (isset($_POST['add_linebreak'])) ? true : false;
						$this->add_new_division_or_linebreak($this->add_division, $this->add_linebreak);

					// no break;
					case 'move_up':
					case 'move_down':
						// Get current order id...
						$sql = "SELECT bbcode_order as current_order
							FROM " . BBCODES_TABLE . "
							WHERE bbcode_id = $bbcode_id";
						$result = $db->sql_query($sql);

						$current_order = (int) $db->sql_fetchfield('current_order');
						$db->sql_freeresult($result);

						if (($current_order == 0 && $action == 'move_up') || ($current_order <= 5 && $action == 'move_up'))
						{
							$bbcode_id = null;
							break;
						}

						// on move_down, switch position with next order_id...
						// on move_up, switch position with previous order_id...
						$switch_order_id = ($action == 'move_down') ? $current_order + 1 : $current_order - 1;

						$sql = "UPDATE " . BBCODES_TABLE . "
							SET bbcode_order = $current_order
							WHERE bbcode_order = $switch_order_id
								AND bbcode_id <> $bbcode_id";
						$db->sql_query($sql);

						// Only update the other entry too if the previous entry got updated
						if ($db->sql_affectedrows())
						{
							$sql = "UPDATE " . BBCODES_TABLE . "
								SET bbcode_order = $switch_order_id
								WHERE bbcode_order = $current_order
									AND bbcode_id = $bbcode_id";
							$db->sql_query($sql);
						}
						$bbcode_id = null;
					// no break;

				}
				$this->bbcodes_edit($id, $mode, $action, $bbcode_id);
				break;
		}
	}

	/**
	* Build Frontend with supplied options
	* @version 3.0.7
	**/
	function abbc3_details()
	{
		global $user, $template, $cache, $config, $phpbb_root_path;

		$this->page_title = 'ABBCODES_SETINGS';

	//	$isfounder = ($user->data['user_type'] == USER_FOUNDER) ? true : false;

		$display_vars = array(
			'title'	=> 'ABBCODES_SETINGS',
			'lang'	=> array('mods/abbcode', 'mods/acp_abbcodes'),
			'vars'	=> array(
				'legend1'				=> 'GENERAL_OPTIONS',
				'ABBC3_MOD'				=> array('lang' => 'ABBCODES_DISABLE',			'validate' => 'bool',	'type' => 'radio:yes_no',	'explain'	=> true),
		//		'ABBC3_PATH'			=> array('lang'	=> 'ABBCODES_PATH',				'validate' => 'path',	'type' => 'text::255',		'explain'	=> true),
				'ABBC3_BG'				=> array('lang' => 'ABBCODES_BG',				'validate' => 'string',	'type' => 'custom',			'function'	=> 'image_select', 'params' => array($this->dir . '/images/bg', '{CONFIG_VALUE}', 'config[ABBC3_BG]', true, $this->u_action, 'ABBC3_BG'), 'explain' => true),
				'ABBC3_TAB'				=> array('lang' => 'ABBCODES_TAB',				'validate' => 'bool',	'type' => 'radio:yes_no',	'explain'	=> true, 'append' => '&nbsp;&nbsp;<span>[ <img src="' . $this->dir . '/images/dots.gif" alt="" /> ]</span>'),
				'ABBC3_BOXRESIZE'		=> array('lang' => 'ABBCODES_BOXRESIZE',		'validate' => 'bool',	'type' => 'radio:yes_no',	'explain'	=> true),
				'ABBC3_UCP_MODE'		=> array('lang' => 'ABBCODES_UCP_MODE',			'validate' => 'bool',	'type' => 'radio:yes_no',	'explain'	=> true),

				'legend2'				=> 'ABBCODES_WIZARD',
				'ABBC3_WIZARD_width'	=> false,
				'ABBC3_WIZARD_height'	=> false,
				'ABBC3_WIZARD'			=> array('lang' => 'ABBCODES_WIZARD_SIZE',		'validate' => 'int',	'type' => 'dimension:3:4',	'explain'	=> true,  'append'  => ' ' . $user->lang['PIXEL']),
				'ABBC3_WIZARD_MODE'		=> array('lang'	=> 'ABBCODES_WIZARD_MODE',		'validate' => 'int',	'type' => 'custom',			'function'	=> 'get_radio', 'params' => array('config[ABBC3_WIZARD_MODE]', $user->lang['ABBCODES_WIZARD_SELECTOR'], $config['ABBC3_WIZARD_MODE'], 'ABBC3_WIZARD_MODE'), 'explain' => false),

				'legend3'				=> 'ABBCODES_RESIZER',
				'ABBC3_RESIZE'			=> array('lang' => 'ABBCODES_RESIZE',									'type' => 'string',			'explain'	=> true, 'append' => ' <span id="ABBC3_RESIZE">' . $user->lang['ABBCODES_JAVASCRIPT_EXPLAIN'] . '</span>'),
				'ABBC3_RESIZE_METHOD'	=> array('lang' => 'ABBCODES_RESIZE_METHOD',	'validate' => 'string',	'type' => 'custom',			'function'	=> 'method_select', 'params' => array('{CONFIG_VALUE}', 'config[ABBC3_RESIZE_METHOD]', 'ABBC3_RESIZE_METHOD'), 'explain' => true),
				'ABBC3_RESIZE_BAR'		=> array('lang' => 'ABBCODES_RESIZE_BAR',		'validate' => 'bool',	'type' => 'radio:yes_no',	'explain'	=> true),
				'ABBC3_MAX_IMG_WIDTH'	=> array('lang' => 'ABBCODES_MAX_IMAGE_WIDTH',	'validate' => 'int',	'type' => 'text:7:15',		'explain'	=> true, 'append' => ' ' . $user->lang['PIXEL']),
				'ABBC3_MAX_IMG_HEIGHT'	=> array('lang' => 'ABBCODES_MAX_IMAGE_HEIGHT',	'validate' => 'int',	'type' => 'text:7:15',		'explain'	=> true, 'append' => ' ' . $user->lang['PIXEL']),
				'ABBC3_MAX_THUM_WIDTH'	=> array('lang' => 'ABBCODES_MAX_THUMB_WIDTH',	'validate' => 'int',	'type' => 'text:7:15',		'explain'	=> true, 'append' => ' ' . $user->lang['PIXEL']),
				'ABBC3_RESIZE_SIGNATURE'=> array('lang' => 'ABBCODES_RESIZE_SIGNATURE',	'validate' => 'bool',	'type' => 'radio:yes_no',	'explain'	=> true),
				'ABBC3_MAX_SIG_WIDTH'	=> array('lang' => 'ABBCODES_SIG_IMAGE_WIDTH',	'validate' => 'int',	'type' => 'text:7:15',		'explain'	=> true, 'append' => ' ' . $user->lang['PIXEL']),
				'ABBC3_MAX_SIG_HEIGHT'	=> array('lang' => 'ABBCODES_SIG_IMAGE_HEIGHT',	'validate' => 'int',	'type' => 'text:7:15',		'explain'	=> true, 'append' => ' ' . $user->lang['PIXEL']),

				'legend4'				=> 'ABBC3_BBVIDEO_TAG',
				'ABBC3_VIDEO'			=> array('lang' => 'ABBCODES_VIDEO_SIZE',		'validate' => 'int',	'type' => 'dimension:3:4',	'explain'	=> true, 'append' => ' ' . $user->lang['PIXEL']),
				'ABBC3_VIDEO_width'		=> false,
				'ABBC3_VIDEO_height'	=> false,
				'ABBC3_VIDEO_OPTIONS'	=> array('lang' => 'ABBCODES_VIDEO_ALLOWED',	'validate' => 'string',	'type' => 'custom',			'function'	=> 'video_select', 'params' => array('{CONFIG_VALUE}', 'allowed_videos[]', $this->u_action, 'ABBC3_VIDEO_OPTIONS'), 'explain' => true),
			)
		);

		if (isset($display_vars['lang']))
		{
			$user->add_lang($display_vars['lang']);
		}

		$this->new_config = $config;
		$cfg_array = (isset($_REQUEST['config'])) ? request_var('config', array('' => '')) : $this->new_config;
		$error = array();

		// We validate the complete config if whished
		validate_config_vars($display_vars['vars'], $cfg_array, $error);

		// Do not write values if there is an error
		if (sizeof($error))
		{
			$this->submit = false;
		}

		// Grab global variables, re-cache if necessary
		if ($this->submit)
		{
			$config = $cache->obtain_config();
		}

		// We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
		foreach ($display_vars['vars'] as $config_name => $null)
		{
			if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)
			{
				continue;
			}
			$this->new_config[$config_name] = $config_value = $cfg_array[$config_name];

			if ($this->submit)
			{
				set_config($config_name, $config_value);
			}
		}

		if ($this->submit)
		{
			$allowed_videos	= request_var('allowed_videos', array(0));
			set_config('ABBC3_VIDEO_OPTIONS', video_serialize($allowed_videos, true));

			add_log('admin', 'LOG_CONFIG_ABBCODES');

			if (!sizeof($error))
			{
				trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
			}
			else
			{
				trigger_error($user->lang['LOG_CONFIG_ABBCODES_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING);
			}
		}

		// Output relevant page
		foreach ($display_vars['vars'] as $config_key => $vars)
		{
			if (!is_array($vars) && strpos($config_key, 'legend') === false)
			{
				continue;
			}

			if (strpos($config_key, 'legend') !== false)
			{
				$template->assign_block_vars('options', array(
					'S_LEGEND'		=> true,
					'LEGEND'		=> (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars)
				);

				continue;
			}

			$type = explode(':', $vars['type']);

			$l_explain = '';
			if ($vars['explain'] && isset($vars['lang_explain']))
			{
				$l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
			}
			else if ($vars['explain'])
			{
				$l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
			}

			$template->assign_block_vars('options', array(
				'KEY'			=> $config_key,
				'TITLE'			=> (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
				'S_EXPLAIN'		=> $vars['explain'],
				'TITLE_EXPLAIN'	=> $l_explain,
				'CONTENT'		=> build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars),
				)
			);
			unset($display_vars['vars'][$config_key]);
		}

		$board_path = generate_board_url() . '/' . str_replace($phpbb_root_path, '', $this->dir) . '/';
	
		$template->assign_vars(array(
			'S_EDIT'			=> true,

			'L_TITLE_EDIT'		=> $user->lang['ABBCODES_SETINGS'],
			'L_TITLE_EXPLAIN'	=> $user->lang['ABBCODES_SETINGS_EXPLAIN'],
			'ICON_BASEDIR'		=> $this->dir . '/images/bg/',

			'S_ERROR'			=> (sizeof($error)) ? true : false,
			'ERROR_MSG'			=> implode('<br />', $error),

			'S_FOUNDER'			=> ($user->data['user_type'] == USER_FOUNDER) ? true : false,
			'NO_FOUNDER'		=> $user->lang['NO_AUTH_OPERATION'],

			'U_ABBC3'			=> $user->lang['ABBC3_HELP_ABOUT'],
			'U_ACTION'			=> $this->u_action,

			'ABBC3_VERSION'				=> $config['ABBC3_VERSION'],
			'S_VERSION_UP_TO_DATE'		=> $this->abbc3_version_compare($config['ABBC3_VERSION']),

			// Check which options can be used for the resize method
			'ADVANCEDBOX_EXIST'					=> (@file_exists("$this->dir/AdvancedBox.js")) ? 1 : 0,
			'L_NO_EXIST_EXPLAIN_ADVANCEDBOX'	=> sprintf($user->lang['NO_EXIST_EXPLAIN_ADVANCEDBOX'], $board_path),

			'HIGHSLIDE_EXIST'					=> (@file_exists("$this->dir/highslide/highslide-full.js")) ? 1 : 0,
			'L_NO_EXIST_EXPLAIN_HIGHSLIDE'		=> sprintf($user->lang['NO_EXIST_EXPLAIN_OTHERS'], "highslide-full.js", "4.1.12", "{$board_path}highslide/", "Highslide JS", "http://highslide.com/download.php"),

			'LITEBOX_EXIST'						=> (@file_exists("$this->dir/lightbox/lightbox.js")) ? 1 : 0,
			'L_NO_EXIST_EXPLAIN_LITEBOX'		=> sprintf($user->lang['NO_EXIST_EXPLAIN_OTHERS'], "lightbox.js", "2.05", "{$board_path}lightbox/", "Lightbox2 JS", "http://www.lokeshdhakar.com/projects/lightbox2/#download"),

			'GREYBOX_EXIST'						=> (@file_exists("$this->dir/greybox/gb_scripts.js")) ? 1 : 0,
			'L_NO_EXIST_EXPLAIN_GREYBOX'		=> sprintf($user->lang['NO_EXIST_EXPLAIN_OTHERS'], "gb_scripts.js", "5.53", "{$board_path}greybox/", "GreyBox", "http://orangoo.com/labs/uploads/GreyBox_v5_53.zip"),

			'LIGHTVIEW_EXIST'					=> (@file_exists("$this->dir/lightview/js/lightview.js")) ? 1 : 0,
			'L_NO_EXIST_EXPLAIN_LIHTVIEW'		=> sprintf($user->lang['NO_EXIST_EXPLAIN_OTHERS'], "lightview.js", "2.7.4", "{$board_path}lightview/js/", "Lightview", "http://www.nickstakenburg.com/projects/lightview/"),

			'SHADOWBOX_EXIST'					=> (@file_exists("$this->dir/shadowbox/shadowbox.js")) ? 1 : 0,
			'L_NO_EXIST_EXPLAIN_SHADOWBOX'		=> sprintf($user->lang['NO_EXIST_EXPLAIN_OTHERS'], "shadowbox.js", "3.0.3", "{$board_path}shadowbox/", "Shadowbox", "http://www.shadowbox-js.com/download.html"),

			'POPBOX_EXIST'						=> (@file_exists("$this->dir/PopBox/PopBox.js")) ? 1 : 0,
			'L_NO_EXIST_EXPLAIN_POPBOX'			=> sprintf($user->lang['NO_EXIST_EXPLAIN_OTHERS'], "PopBox.js", "2.7a", "{$board_path}PopBox/", "PopBox", "http://www.c6software.com/Products/PopBox/"),
		));

	}

	/**
	* Add a new division or breack line
	**/
	function add_new_division_or_linebreak($add_division, $add_linebreak)
	{
		global $user, $db, $template, $config, $cache;

		// get last bbcode id - Start
		$sql = 'SELECT MIN(bbcode_id) as min_bbcode_id
			FROM ' . BBCODES_TABLE;
		$result = $db->sql_query($sql);
		$row = $db->sql_fetchrow($result);
		$db->sql_freeresult($result);
		if ($row)
		{
			$next_bbcode_id = $row['min_bbcode_id'];
		}
		else
		{
			$next_bbcode_id = 0;
		}
		$next_bbcode_id = $next_bbcode_id-1;
		// get last bbcode id - End

		// get last order - Start
		$sql = 'SELECT MAX(bbcode_order) as max_bbcode_order
			FROM ' . BBCODES_TABLE;
		$result = $db->sql_query($sql);
		$row = $db->sql_fetchrow($result);
		$db->sql_freeresult($result);
		$next_bbcode_order = (int) $row['max_bbcode_order'] + 1;
		// get last order - End

		$sql = "SELECT *
				FROM " . BBCODES_TABLE . "
				WHERE bbcode_helpline = '" . ($add_linebreak ? 'ABBC3_BREAK' : 'ABBC3_DIVISION') . "'
				ORDER BY bbcode_order DESC";
		$result = $db->sql_query_limit($sql, 1);
		while ($row = $db->sql_fetchrow($result))
		{
			$bbcode = $row['bbcode_tag'];
		}
		$db->sql_freeresult($result);

		// get the value of current tag
		$number = preg_replace('#(break|division)(\d+)#s', '$2', $bbcode);
		$next_bbcode_number = (int) $number + 1;

		$sql_ary = array(
			'bbcode_id'					=> $next_bbcode_id,
			'bbcode_tag'				=> (($add_linebreak) ? 'break' : 'division') . $next_bbcode_number,
			'bbcode_helpline'			=> ($add_linebreak) ? 'ABBC3_BREAK' : 'ABBC3_DIVISION',
			'display_on_posting'		=> true,
			'display_on_pm'				=> false,
			'display_on_sig'			=> false,
			'bbcode_match'				=> '.',
			'bbcode_tpl'				=> '.',
			'first_pass_match'			=> '.',
			'first_pass_replace'		=> '.',
			'second_pass_match'			=> '.',
			'second_pass_replace'		=> '.',
			'abbcode'					=> true,
			'bbcode_image'				=> ($add_linebreak) ? 'spacer.gif' : 'dots.gif',
			'bbcode_order'				=> $next_bbcode_order,
		);
		$db->sql_query('INSERT INTO ' . BBCODES_TABLE . $db->sql_build_array('INSERT', $sql_ary));

		$cache->destroy('sql', BBCODES_TABLE);

		$user->add_lang('acp/posting');
		add_log('admin', 'LOG_BBCODE_ADD', $sql_ary['bbcode_tag']);

		trigger_error($user->lang['BBCODE_ADDED'] . adm_back_link($this->u_action));
	}

	/**
	* Synchronise order
	**/
	function resync_abbcodes()
	{
		global $user, $db;

		$user->add_lang('mods/acp_abbcodes');

		// This pseodo-bbcode should not change the position order
		$bbcode_tag_ary =  array('font=', 'size', 'highlight=', 'color');
		$next_bbcode_order = sizeof($bbcode_tag_ary)+1;

		$sql = 'SELECT bbcode_id, bbcode_tag, bbcode_order 
				FROM ' . BBCODES_TABLE . ' 
				WHERE ' . $db->sql_in_set('bbcode_tag', $bbcode_tag_ary, true) . ' 
				ORDER BY bbcode_order';
		$result = $db->sql_query($sql);

		while ($row = $db->sql_fetchrow($result))
		{
			$sql = 'UPDATE ' . BBCODES_TABLE . " 
					SET bbcode_order = $next_bbcode_order 
					WHERE bbcode_id = {$row['bbcode_id']}";
			$db->sql_query($sql);

			$next_bbcode_order++;
		}
		$db->sql_freeresult($result);

		trigger_error($user->lang['ABBCODES_RESYNC_SUCCESS'] . adm_back_link($this->u_action));
	}

	/**
	* Show/edit bbcodes
	* @version 1.0.12
	**/
	function bbcodes_edit($id, $mode, $action, $bbcode = '')
	{
		global $user, $db, $cache, $template, $config;

		$user->add_lang(array('acp/posting', 'mods/acp_abbcodes', 'mods/abbcode'));

		// Is this ABBC3 is disabled
		if (!isset($config['ABBC3_MOD']))
		{
			trigger_error($user->lang['ABBCODES_MOD_DISABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
		}

		$img_spacer = 'spacer.gif';
		$img_noimg  = 'no_image.png';

		if ($this->submit && $bbcode)
		{
			// Get items to create/modify
			$abbcode_name		= (isset($_POST['name'])) ? request_var('name', array('' => '')) : array();
			$display_on_posting = (isset($_POST['display_on_posting'])) ? request_var('display_on_posting', array('' => 0)) : array();
			$display_on_pm		= (isset($_POST['display_on_pm'])) ? request_var('display_on_pm', array('' => 0)) : array();
			$display_on_sig		= (isset($_POST['display_on_sig'])) ? request_var('display_on_sig', array('' => 0)) : array();
			$bbcode_image		= utf8_normalize_nfc(request_var('image', array('' => ''), true));
			$group_ids			= implode(',', request_var('group_id', array(0)));

			$bbcode_sql = array(
				'display_on_posting'	=> (isset($display_on_posting[$bbcode])) ? 1 : 0,
				'display_on_pm'			=> (isset($display_on_pm[$bbcode])) ? 1 : 0,
				'display_on_sig'		=> (isset($display_on_sig[$bbcode])) ? 1 : 0,
				'bbcode_image'			=> (isset($bbcode_image[$bbcode])) ? $bbcode_image[$bbcode] : '',
				'bbcode_group'			=> (isset($group_ids) && trim($group_ids) != '') ? $group_ids : 0,
			);

			// Fix for breack line?
			if (substr($abbcode_name[$bbcode],0,14) == 'ABBCODES_BREAK')
			{
				$bbcode_sql['bbcode_image'] = $img_spacer;
			}

			if ($abbcode_name[$bbcode] == 'ABBC3_COLOR' || $abbcode_name[$bbcode] == 'ABBC3_HIGHLIGHT')
			{
				if ($abbc3_color_mode = request_var('abbc3_color', ''))
				{
					set_config('ABBC3_COLOR_MODE', $abbc3_color_mode);
				}

				if ($abbc3_highlight_mode = request_var('abbc3_highlight', ''))
				{
					set_config('ABBC3_HIGHLIGHT_MODE', $abbc3_highlight_mode);
				}
			}

			$sql = "UPDATE " . BBCODES_TABLE . "
				SET " . $db->sql_build_array('UPDATE', $bbcode_sql) . "
				WHERE bbcode_id = " . $bbcode;
			$result = $db->sql_query($sql);

			if ($result)
			{
				trigger_error($user->lang['LOG_CONFIG_ABBCODES'] . adm_back_link($this->u_action . "&last_id=$bbcode"));
			}
			else
			{
				trigger_error($user->lang['LOG_CONFIG_ABBCODES_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING);
			}
			$bbcode = '';
		}

		$error = array();

		// Exclude bots
		$sql = 'SELECT group_id
			FROM ' . GROUPS_TABLE . "
			WHERE group_name IN ('BOTS')";
		$result = $db->sql_query($sql);

		$exclude = array();
		while ($row = $db->sql_fetchrow($result))
		{
			$exclude[] = $row['group_id'];
		}
		$db->sql_freeresult($result);

		$sql = "SELECT abbcode, bbcode_order, bbcode_id, bbcode_group, bbcode_tag, bbcode_helpline, bbcode_image, display_on_posting, display_on_pm, display_on_sig 
				FROM " . BBCODES_TABLE . " 
				ORDER BY bbcode_order";
		$result = $db->sql_query($sql);

		$bbcode_id	= request_var('bbcode_id', 0);

		$template->assign_vars(array(
			'S_BBCODES'			=> true,
			'LAST_ID'			=> request_var('last_id', $bbcode_id),

			'L_TITLE_BBCODES'	=> $user->lang['ABBCODES_CONFIG'],
			'L_EXPLAIN_BBCODES'	=> $user->lang['ABBCODES_CONFIG_EXPLAIN'],

			'S_BBCODE_EDIT'		=> ($bbcode) ? true :false,

			'ICON_BASEDIR'		=> $this->dir . '/images/',

			'S_ERROR'			=> (sizeof($error)) ? true : false,
			'ERROR_MSG'			=> implode('<br />', $error),

			'U_ABBC3'			=> $user->lang['ABBC3_HELP_ABOUT'],
			'U_ACTION'			=> $this->u_action,
			'F_ACTION'			=> ($bbcode) ? $this->u_action . '&mode=bbcodes&action=edit&bbcode_id=' . $bbcode : null,
			'A_ACTION'			=> (!$bbcode) ? $this->u_action . '&mode=bbcodes&action=newdlb' : null,
			'U_SYNC'			=> (!$bbcode) ? $this->u_action . '&mode=bbcodes&action=sync' : null,
			'U_BACK'			=> ($bbcode) ? $this->u_back : null,
		));

		$no_move = array('ABBC3_FONT', 'ABBC3_SIZE', 'ABBC3_HIGHLIGHT', 'ABBC3_COLOR');
		$first_row_to_move = 0;
		while ($row = $db->sql_fetchrow($result))
		{
			/** Some fixes **/
			$bbcode_id		= $row['bbcode_id'];
			$abbcode		= $row['abbcode'];
			$abbcode_name	= (($row['abbcode']) ? 'ABBC3_' : '') . strtoupper(str_replace('=', '', trim($row['bbcode_tag'])));
			$abbcode_name	= ($row['bbcode_helpline'] == 'ABBC3_ED2K_TIP') ? 'ABBC3_ED2K' : $abbcode_name;
			$abbcode_image	= trim($row['bbcode_image']);
			$abbcode_tag	= str_replace('=', '', trim($row['bbcode_tag']));

			$is_a_bbcode	= true;
			// is a breack line or division ?
			if ((strpos($abbcode_name, 'ABBC3_DIVISION') !== false) || (strpos($abbcode_name, 'ABBC3_BREAK') !== false) || in_array($row['bbcode_tag'], array('imgshack', 'cut', 'copy', 'paste', 'plain')))
			{
				$is_a_bbcode	= false;
				if (strpos($abbcode_name, 'ABBC3_DIVISION') !== false)
				{
					if ($config['ABBC3_TAB'])
					{
						$abbcode_name = 'ABBCODES_DIVISION';
					}
					else
					{
						continue;
					}
				}
				else if (strpos($abbcode_name, 'ABBC3_BREAK') !== false)
				{
						$abbcode_name = 'ABBCODES_BREAK';
				}
			}

			if ($abbcode_name == 'ABBC3_COLOR')
			{
				$first_row_to_move = $row['bbcode_order'] + 1;
			}

			$abbcode_explain = '';
			$bbcode_tagname = '';
			if (!$abbcode)
			{
				$bbcode_tagname = '[' . $abbcode_tag . ']';
				$abbcode_explain = $user->lang['ABBCODES_CUSTOM'] . '&nbsp;<strong>' . $bbcode_tagname . '</strong>'; //$row['bbcode_helpline'];
			}
			else
			{
				$bbcode_tagname  = (!$is_a_bbcode) ? '' : '[' . str_replace(array('listo', 'listb', 'listitem'), array('list=', 'list', '*'), $abbcode_tag) .']';
				$abbcode_explain = (isset($user->lang[$abbcode_name . '_MOVER'])) ? $user->lang[$abbcode_name . '_MOVER'] : '';
				$abbcode_explain.= (isset($user->lang[$abbcode_name . '_EXPLAIN'])) ? '<br />' . $user->lang[$abbcode_name . '_EXPLAIN'] : '';
			}

			if ($action != 'edit')
			{
				$template->assign_block_vars('items', array(
					'ID'				=> $bbcode_id,
					'ORDER'				=> $row['bbcode_order'],
					'NAME'				=> str_replace('=', '', trim($row['bbcode_tag'])),
					'TAG_NAME'			=> $bbcode_tagname,
					'TAG_EXPLAIN'		=> $abbcode_explain,
					'IMG_SRC'			=> ($abbcode_image && $abbcode_image != $img_spacer) ? $this->dir . '/images/' . $abbcode_image : '',

					'ON_POST'			=> ($row['display_on_posting'])	? $user->lang['ENABLED'] : $user->lang['DISABLED'],
					'ON_PM'				=> ($row['display_on_pm'])		? $user->lang['ENABLED'] : $user->lang['DISABLED'],
					'ON_SIG'			=> ($row['display_on_sig'])		? $user->lang['ENABLED'] : $user->lang['DISABLED'],

					'S_NOMOVE'			=> (in_array($abbcode_name, $no_move)) ? true : false,
					'S_FIRST_ROW'		=> ($row['bbcode_order'] == $first_row_to_move) ? true : false,

					'U_EDIT'			=> $this->u_action . '&mode=bbcodes&action=edit&bbcode_id=' . $row['bbcode_id'],
					'U_MOVE_UP'			=> $this->u_action . '&mode=bbcodes&action=move_up&bbcode_id=' . $row['bbcode_id'],
					'U_MOVE_DOWN'		=> $this->u_action . '&mode=bbcodes&action=move_down&bbcode_id=' . $row['bbcode_id'],
				));
			}
			else if ($action == 'edit' && $row['bbcode_id'] == $bbcode)
			{
				$radio = '';
				if ($abbcode_name == 'ABBC3_COLOR' || $abbcode_name == 'ABBC3_HIGHLIGHT')
				{
					$radio = get_radio(strtolower($abbcode_name), $user->lang['ABBCODES_COLOUR_SELECTOR'], $config[$abbcode_name . '_MODE'], $abbcode_name);
				}

				$template->assign_block_vars('items', array(
					'ID'				=> $bbcode_id,
					'NAME'				=> $abbcode_name,
					'TAG_NAME'			=> $bbcode_tagname,
					'TAG_EXPLAIN'		=> ($abbcode) ? $abbcode_explain : $row['bbcode_helpline'],
					'IMG_SRC'			=> ($abbcode_image) ? ($abbcode_image != $img_spacer) ? $this->dir . '/images/' . $abbcode_image : '' : $this->dir . '/images/' . $img_noimg,

 					'S_NOMOVE'			=> (in_array($abbcode_name, $no_move)) ? true : null,
					'S_NEW_IMG'			=> image_select($this->dir . '/images', $abbcode_image, 'image[' . $bbcode_id . ']', false, $this->u_action),
					'POSTING_CHECKED'	=> ($row['display_on_posting']) ? ' checked="checked"' : '',
					'PM_CHECKED'		=> ($row['display_on_pm'])		? ' checked="checked"' : '',
					'SIG_CHECKED'		=> ($row['display_on_sig'])		? ' checked="checked"' : '',

					'S_GROUP_OPTIONS'	=> groups_select_options(explode(',', $row['bbcode_group']), $exclude),
					'S_RADIO_BUTTONS'	=> ($radio) ? $radio : '',
				));
			}
		}
	}

	/**
	* Obtains the latest version information
	* @param string 	$current_version 	version information
	* @param int 		$ttl 				Cache version information for $ttl seconds. Defaults to 86400 (24 hours).
	* 
	* @return bool 		false on failure.
	**/
	function abbc3_version_compare($current_version = '', $version_up_to_date = true, $ttl = 86400)
	{
		global $cache, $template;
		
		$info = $cache->get('abbc3_versioncheck');

		if ($info === false)
		{
			$errstr = '';
			$errno = 0;

			$info = get_remote_file('www.mssti.com', '/phpbb3/store/updatecheck', 'abbc3.txt', $errstr, $errno);
			if ($info === false)
			{
				$template->assign_var('S_VERSIONCHECK_FAIL', true);
				$cache->destroy('abbc3_versioncheck');
			}
		}

		if ($info !== false)
		{
			$cache->put('abbc3_versioncheck', $info, $ttl);
			$latest_version_info = explode("\n", $info);

			$latest_version = strtolower(trim($latest_version_info[0]));
			$current_version = strtolower(trim($current_version));
			$version_up_to_date = version_compare($current_version, $latest_version, '<') ? false : true;

			$template->assign_vars(array(
				'U_VERSIONCHECK'	=> ($version_up_to_date) ? false : $latest_version_info[1],
			));
		}

		return $version_up_to_date;
	}
}

	/**
	* Select list of images in current style folder
	**/
	function image_select($dir, $current, $name, $show = false, $u_action, $ide = 'ABBC3_BG')
	{
		global $user, $config, $phpbb_admin_path, $phpbb_root_path, $phpEx;

		// Read the folder and get images
		$dp = @opendir($dir);
		$count = 0;

		if ($dp)
		{
			while (($file = readdir($dp)) !== false)
			{
				if (preg_match('#\.(?:gif|jpg|png)$#', $file))
				{
					$imagesetlist[$count] = $file;
					$count++;
				}
			}
			closedir($dp);
		}
		else
		{
			trigger_error($user->lang['NO_IMAGESET'] . adm_back_link($u_action), E_USER_WARNING);
		}

		if (sizeof($imagesetlist))
		{
			// Make sure the list of possible images is sorted alphabetically
			sort($imagesetlist);

			$icons_list = '<select id="' .$ide .'" name="' . $name . '" onchange="update_image(this.options[selectedIndex].value);">' . "\n";
			$icons_list .= '<option value="" ' . (($current == '') ? ' selected="selected"' : ''). '>' . $user->lang['NO_IMAGE'] . '</option>' . "\n";

			for($i = 0; $i < count($imagesetlist); $i++)
			{
				$selected = ($imagesetlist[$i] == $current) ? ' selected="selected"' : '';
				$icons_list .= '<option value="' . $imagesetlist[$i] . '"' . $selected . '>' . $imagesetlist[$i] . '</option>' . "\n";
			}
			$icons_list .= '</select>'. (($show) ? '&nbsp; <label>' . $user->lang['CURRENT_IMAGE'] . '</label><span><img src="' . $dir . '/' . $current .'" id="newimg" alt="" width="80" height="30" /></span>' : '');
		}
		return $icons_list;
	}

	/**
	* Select list of BBvideos
	**/
	function video_select($current, $name, $u_action, $ide = 'ABBC3_VIDEO_OPTIONS')
	{
		global $user, $config, $phpbb_admin_path, $phpbb_root_path, $phpEx;

		$abbcode_video_ary = abbcode::video_init();
		// The video_serialize function is at root/includes/abbcode.php after the abbcode class
		$allowed_videos = (!$current) ? array() : video_serialize($current, false);

		if (sizeof($abbcode_video_ary))
		{
			$video_options = '';
			$video_optgroup = false;

			foreach ($abbcode_video_ary as $video_name => $video_data)
			{
				$video_name = stripslashes($video_name);
			
				if ($video_name == 'video' || $video_name == 'external' || $video_name == 'file')
				{
					$video_options .= ($video_optgroup) ? '</optgroup>' . "\n" : '';
					$video_options .= '<optgroup label="-- ' . $user->lang['ABBC3_BBVIDEO_' . strtoupper($video_name)] . ' --">' . "\n";
					$video_optgroup = true;
				}
				// Now check that this video is has data for search and replace
				else if ((isset($video_data['match']) && $video_data['match'] != '') && (isset($video_data['replace']) && $video_data['replace'] != ''))
				{
					$selected = (in_array($video_data['id'], $allowed_videos)) ? ' selected="selected"' : '';
					$video_options .= '<option value="' . $video_data['id'] . '"' . $selected . '>' . $video_name . '</option>' . "\n";
				}
				else
				{
					continue;
				}
			}
			$video_options .= ($video_optgroup) ? '</optgroup>' . "\n" : '';
		}
		
		return '<select id="' . $ide .'" name="' . $name . '" multiple="multiple" size="10">' . "\n" . $video_options . '</select>
		<br /><a href="#" onclick="selector(true, \'' . $ide . '\'); return false;">' . $user->lang['ABBCODES_SELECT_ALL'] . '</a> :: <a href="#" onclick="selector(false, \'' . $ide . '\'); return false;">' . $user->lang['ABBCODES_DESELECT_ALL'] . '</a>
		<br /><br />' . $user->lang['ABBCODES_VIDEO_ALLOWED_NOTE'];
	}

	/**
	* Select list of display full size image
	**/
	function method_select($selected_method = 'AdvancedBox', $name, $ide)
	{
		global $user;

		$method_options = $user->lang['ABBCODES_RESIZE_METHODS'];

		$s_method_options = '<select id="' . $ide . '" name="' . $name . '">';
		foreach($method_options as $method_name => $method_value)
		{
			$selected = ($selected_method == $method_name) ? ' selected="selected"' : '';
			$s_method_options .= '<option value="' . $method_name . '"' . $selected . ' >' . $method_value . '</option>';
		}
		$s_method_options.= '</select>';

		return $s_method_options;
	}

	/**
	* Select list of display color picker
	**/
	function get_radio($name, $input_ary, $input_default = false, $id = false, $key = false)
	{
		global $user;

		// destroy a single element of an array
		if ($name == "abbc3_highlight")
		{
			unset($input_ary['phpbb']);
		}

		$html = '';
		$id_assigned = false;
		foreach ($input_ary as $value => $title)
		{
			$value = strtolower($value);
			
			$selected = ($input_default !== false && $value == $input_default) ? ' checked="checked"' : '';
			$html .= ' <label><input class="radio" type="radio" name="' . $name . '"' . (($id && !$id_assigned) ? ' id="' . $id . '"' : '') . ' value="' . $value . '"' . $selected . (($key) ? ' accesskey="' . $key . '"' : '') . ' />&nbsp;' . $title . '&nbsp;</label>';
			$id_assigned = true;
		}

		return $html;
	}

	function groups_select_options($select_id = false, $exclude_ids = false)
	{
		global $user, $db;

		$sql = 'SELECT group_id, group_name, group_type
				FROM ' . GROUPS_TABLE . '
				WHERE ' . $db->sql_in_set('group_id', array_map('intval', $exclude_ids), true) .' 
				ORDER BY group_type DESC, group_name ASC';
		$result = $db->sql_query($sql);

		$group_options = '';
		while ($row = $db->sql_fetchrow($result))
		{
			$selected = (is_array($select_id)) ? ((in_array($row['group_id'], $select_id)) ? ' selected="selected"' : '') : (($row['group_id'] == $select_id) ? ' selected="selected"' : '');
			$group_options .= '<option value="' . $row['group_id'] . '"' . $selected . '>' . ucfirst(strtolower((($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']))) . '</option>';
		}
		$db->sql_freeresult($result);
		return $group_options;
	}

?>
¿Sabéis por qué puede ser?

¿Debería reinstalar el MOD? :S Espero que no, tardé mucho en instalarlo. Si he puesto en un lugar no adecuado el post, ¿algún mod me haría el favor de moverlo?

Gracias.

[anchor=imagenabbc3 goto=problema2]Volver arriba[/anchor]
Accediendo a ABBC3 (imagen):
SPOILER_SHOW
Imagen

Re: Ayuda MOD Advanced BBCode Box 3.3.0.9.3

Publicado: 29 Nov 2011, 23:58
por nextgen
RoX-GD ya te dijieron donde tenes que postear tus dudas sobre MOD's validados. :dormido:

aqui te lo recuerdo. --> ‹ Base de modificaciones ‹ Advanced BBCode Box 3 ‹ Discusión/Soporte

Re: Ayuda MOD Advanced BBCode Box 3.3.0.9.3

Publicado: 29 Nov 2011, 23:58
por leviatan21
RoX-GD Por favor lee lo que se te indica :
Alorse escribió:por otro lado este tema debería estar en http://www.phpbb-es.com/titania/mod/mss ... 3/support/ que es para el soporte de dicho MOD.
Cierro tema :!: