Página 2 de 2

Re: BBCODE para Jdownloader Clic N Load 2

Publicado: 30 May 2014, 19:32
por joanllm
Después de un tiempo mirando como hacerlo, e podido hacer que se puedan añadir múltiples enlaces sin tener que añadir comas ni ningún otro carácter entre cada enlace.
Las ediciones a hacer son estas:

Abrir /includes/bbcode.php

Buscar:

Código: Seleccionar todo

				case 12:
					$this->bbcode_cache[$bbcode_id] = array(
						'str'	=> array(
							'[/attachment:$uid]'	=> $this->bbcode_tpl('inline_attachment_close', $bbcode_id)
						),
						'preg'	=> array(
							'#\[attachment=([0-9]+):$uid\]#'	=> $this->bbcode_tpl('inline_attachment_open', $bbcode_id)
						)
					);
				break;
Agregar despues:

Código: Seleccionar todo

                         
				case 1000:
					$this->bbcode_cache[$bbcode_id] = array(
						'preg' => array(
							'#\[jdmp(?:=([a-z]+))?:$uid\](.*?)\[/jdmp:$uid\]#ise'	=> "\$this->bbcode_second_pass_jd2('\$1', '\$2')",

						)
					);
				break;

Buscar:

Código: Seleccionar todo

		$code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close');


		return $code;
	}
Agregar despues:

Código: Seleccionar todo

	function bbcode_second_pass_jd2($type, $jd2)
	{
		$jd2 = str_replace('\"', '"', $jd2);

		switch ($type)
		{
			case 'php':
				if (strpos($jd2, '<span class="syntaxdefault"><br /></span>') === 0)
				{
					$jd2 = substr($jd2, 41);
				}

			default:
				$jd2 = str_replace("\t", '&nbsp; &nbsp;', $jd2);
				$jd2 = str_replace('  ', '&nbsp; ', $jd2);
				$jd2 = str_replace('  ', ' &nbsp;', $jd2);
				$jd2 = str_replace("\n ", "\n&nbsp;", $jd2);

				if (!empty($jd2) && $jd2[0] == ' ')
				{
					$jd2 = '&nbsp;' . substr($jd2, 1);
				}

				if (!empty($jd2) && $jd2[0] == "\n")
				{
					$jd2 = substr($jd2, 1);
				}
			break;
		}

		$crypted = $jd2;

		$key="1234567890987654";
		$transmitKey = base_convert($key, 16, 2);
		$cp = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', '');
		@mcrypt_generic_init($cp, $key,$key);
		$enc = mcrypt_generic($cp, $crypted);  
		$crypted2=base64_encode($enc);

		$jdmp = $this->bbcode_tpl('jd_open') . $crypted2 . $this->bbcode_tpl('jd_close');


		return $jdmp;
	}


Abrir /includes/message_parser.php

Buscar:

Código: Seleccionar todo

			'code'			=> array('bbcode_id' => 8,	'regexp' => array('#\[code(?:=([a-z]+))?\](.+\[/code\])#uise' => "\$this->bbcode_code('\$1', '\$2')")),
Agregar después:

Código: Seleccionar todo

			'jdmp'			=> array('bbcode_id' => 1000,	'regexp' => array('#\[jdmp(?:=([a-z]+))?\](.+\[/jdmp\])#uise' => "\$this->bbcode_jd('\$1', '\$2')")),

Buscar:

Código: Seleccionar todo

		// if now $code_block has contents we need to parse the remaining code while removing the last closing tag to match up.
		if ($code_block)
		{
			$code_block = substr($code_block, 0, -7);
			$code_block = preg_replace($htm_match, $htm_replace, $code_block);

			$out .= $this->bbcode_parse_code($stx, $code_block);
		}

		return $out;
	}
Agregar despues:

Código: Seleccionar todo

	function bbcode_parse_jd($stx, &$jd)
	{
		switch (strtolower($stx))
		{
			case 'php':

				$remove_tags = false;

				$str_from = array('<', '>', '&#91;', '&#93;', '&#46;', '&#58;', '&#058;');
				$str_to = array('<', '>', '[', ']', '.', ':', ':');
				$jd = str_replace($str_from, $str_to, $jd);

				if (!preg_match('/\<\?.*?\?\>/is', $jd))
				{
					$remove_tags = true;
					$jd = "<?php $jd ?>";
				}

				$conf = array('highlight.bg', 'highlight.comment', 'highlight.default', 'highlight.html', 'highlight.keyword', 'highlight.string');
				foreach ($conf as $ini_var)
				{
					@ini_set($ini_var, str_replace('highlight.', 'syntax', $ini_var));
				}

				$jd = htmlspecialchars_decode($jd);
				$jd = highlight_string($jd, true);

				$str_from = array('<span style="color: ', '<font color="syntax', '</font>', '<code>', '</code>','[', ']', '.', ':');
				$str_to = array('<span class="', '<span class="syntax', '</span>', '', '', '&#91;', '&#93;', '&#46;', '&#58;');

				if ($remove_tags)
				{
					$str_from[] = '<span class="syntaxdefault"><?php </span>';
					$str_to[] = '';
					$str_from[] = '<span class="syntaxdefault"><?php&nbsp;';
					$str_to[] = '<span class="syntaxdefault">';
				}

				$jd = str_replace($str_from, $str_to, $jd);
				$jd = preg_replace('#^(<span class="[a-z_]+">)\n?(.*?)\n?(</span>)$#is', '$1$2$3', $jd);

				if ($remove_tags)
				{
					$jd = preg_replace('#(<span class="[a-z]+">)?\?>(</span>)#', '$1&nbsp;$2', $jd);
				}

				$jd = preg_replace('#^<span class="[a-z]+"><span class="([a-z]+)">(.*)</span></span>#s', '<span class="$1">$2</span>', $jd);
				$jd = preg_replace('#(?:\s++|&nbsp;)*+</span>$#u', '</span>', $jd);

				if (!empty($jd) && substr($jd, -1) == "\n")
				{
					$jd = substr($jd, 0, -1);
				}

				return "[jdmp=$stx:" . $this->bbcode_uid . ']' . $jd . '[/jdmp:' . $this->bbcode_uid . ']';
			break;

			default:
				return '[jdmp:' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($jd) . '[/jdmp:' . $this->bbcode_uid . ']';
			break;
		}
	}


	function bbcode_jd($stx, $in)
	{
		if (!$this->check_bbcode('jdmp', $in))
		{
			return $in;
		}

		$htm_match = get_preg_expression('bbcode_htm');
		unset($htm_match[4], $htm_match[5]);
		$htm_replace = array('\1', '\1', '\2', '\1');

		$out = $jd_block = '';
		$open = 1;

		while ($in)
		{
			preg_match('#(.*?)(\[jdmp(?:=([a-z]+))?\])(.+)#is', $in, $buffer);
			$pos = (isset($buffer[1])) ? strlen($buffer[1]) : false;
			$tag_length = (isset($buffer[2])) ? strlen($buffer[2]) : false;

			$pos2 = stripos($in, '[/jdmp]');

			if ($pos !== false && $pos < $pos2)
			{
				// Open new block
				if (!$open)
				{
					$out .= substr($in, 0, $pos);
					$in = substr($in, $pos);
					$stx = (isset($buffer[3])) ? $buffer[3] : '';
					$jd_block = '';
				}
				else
				{
					$jd_block .= substr($in, 0, $pos) . ((isset($buffer[2])) ? $buffer[2] : '');
					$in = substr($in, $pos);
				}

				$in = substr($in, $tag_length);
				$open++;
			}
			else
			{
				if ($open == 1)
				{
					$jd_block .= substr($in, 0, $pos2);
					$jd_block = preg_replace($htm_match, $htm_replace, $jd_block);

					$out .= $this->bbcode_parse_jd($stx, $jd_block);
					$jd_block = '';
					$open--;
				}
				else if ($open)
				{
					$jd_block .= substr($in, 0, $pos2 + 7);
					$open--;
				}
				else
				{
					$out .= substr($in, 0, $pos2 + 7);
				}

				$in = substr($in, $pos2 + 7);
			}
		}

		if ($jd_block)
		{
			$jd_block = substr($jd_block, 0, -7);
			$jd_block = preg_replace($htm_match, $htm_replace, $jd_block);

			$out .= $this->bbcode_parse_jd($stx, $jd_block);
		}

		return $out;
	}


Abrir: /styles/tu_estilo/template/bbcode.html

Buscar:

Código: Seleccionar todo

<!-- BEGIN code_close --></code></dd></dl><!-- END code_close -->
Agregar despues:

Código: Seleccionar todo

<!-- BEGIN jd_open --><o><FORM title="A&#241;adir enlaces a JDownloader y MiPony" style="position: relative;" target="ventana" ACTION="http://127.0.0.1:9666/flash/addcrypted2" target="hidden" METHOD="POST"><INPUT TYPE="hidden" NAME="passwords" VALUE="myPassword"> <INPUT TYPE="hidden" NAME="source" VALUE="http://jdownloader.org/spielwiese">  <INPUT TYPE="hidden" NAME="jk" VALUE="function f(){ return '31323334353637383930393837363534';}"><INPUT TYPE="hidden" NAME="crypted" VALUE="<!-- END jd_open -->
<!-- BEGIN jd_close -->"><INPUT TYPE="SUBMIT" onclick="$(this).val('Listo! Los links se agregaran en breve...'); $(this).addClass('ui-button-positive');" NAME="submit" VALUE="A&#241;adir enlaces a JDownloader y MiPony"></FORM><iframe style="display: none;" name=ventana></iframe></o><!-- END jd_close -->


Abrir: /styles/tu_estilo/template/posting_buttons.html

Buscar:

Código: Seleccionar todo

	<input type="button" class="button2" name="bbpalette" id="bbpalette" value="{L_FONT_COLOR}" onclick="change_palette();" title="{L_BBCODE_S_HELP}" />
Agregar despues:

Código: Seleccionar todo

	<input type="button" class="button2" name="addbbcode22" value="jdmp" onclick="bbfontstyle('[jdmp]','[/jdmp]')" title="Agrega un boton que oculta los enlaces y los añade a JDownloader y MiPony usando click'N'load: [jdmp]Url's[/jdmp]">

Abrir: /styles/tu_estilo/template/posting_layout.html

Buscar y borrar:

Código: Seleccionar todo

<form id="postform" method="post" action="{S_POST_ACTION}"{S_FORM_ENCTYPE}>
Buscar:

Código: Seleccionar todo

<!-- IF S_DISPLAY_PREVIEW --><!-- INCLUDE posting_preview.html --><!-- ENDIF -->
Agregar despues:

Código: Seleccionar todo

<form id="postform" method="post" action="{S_POST_ACTION}"{S_FORM_ENCTYPE}>

Abrir: posting.php

Buscar:

Código: Seleccionar todo

	$message_parser->message = &$post_data['post_text'];
Agregar despues:

Código: Seleccionar todo

	$uid = $post_data['bbcode_uid'];
				if ($mode == 'edit')
	{
		$message_parser->message = $message_parser->message;
	}
	else
	{
		$message_parser->message = preg_replace("#\[jdmp:$uid\].*?\[/jdmp:$uid\]#ise", "\$user->lang['HIDDEN_LINKS']", $message_parser->message);
	}

Abrir: /language/es/common.php

Buscar:

Código: Seleccionar todo

	'HIDDEN_USER_TOTAL_AND'	=> '%d oculto y ',
Agregar despues:

Código: Seleccionar todo

	'HIDDEN_LINKS'	=> 'Enlaces ocultos',
Espero que te sirva ;) ,saludos.

Re: BBCODE para Jdownloader Clic N Load 2

Publicado: 30 May 2014, 22:28
por andares
Gracias joanllm, funciona bien...aunque en el DEBUG me aparece este error en el momento de encriptar los enlaces:

[phpBB Debug] PHP Notice: in file [ROOT]/includes/message_parser.php on line 199: Undefined index: jd

La linea 199:

Código: Seleccionar todo

 		$this->parsed_items[$bbcode]++;
...que esta englobada en esta parte:

Código: Seleccionar todo

	/**
	* Making some pre-checks for bbcodes as well as increasing the number of parsed items
	*/
	function check_bbcode($bbcode, &$in)
	{
		// when using the /e modifier, preg_replace slashes double-quotes but does not
		// seem to slash anything else
		$in = str_replace("\r\n", "\n", str_replace('\"', '"', $in));

		// Trimming here to make sure no empty bbcodes are parsed accidently
		if (trim($in) == '')
		{
			return false;
		}

		$this->parsed_items[$bbcode]++;

		return true;
	}
EDITADO: Solucionado con el nuevo código Gracias ;-)

Re: BBCODE para Jdownloader Clic N Load 2

Publicado: 30 May 2014, 23:22
por joanllm
Gracias por el aviso andares, fallo mio, solo tienes que hacer esta edición para solucionarlo.

abrir /includes/message_parser.php


Buscar:

Código: Seleccionar todo

		if (!$this->check_bbcode('jd', $in))
Remplazar:

Código: Seleccionar todo

		if (!$this->check_bbcode('jdmp', $in))

Re: BBCODE para Jdownloader Clic N Load 2

Publicado: 31 May 2014, 11:04
por joanllm
Añado estas ediciones para que no se vean los enlaces al enviar MP desde el tema, ni tampoco en la opción de citar que ay cuando se respondes a un tema.


Abrir: /includes/functions_posting.php

Buscar:

Código: Seleccionar todo

			$decoded_message = $message;
Agregar despues:

Código: Seleccionar todo

			$uid = censor_text($row['bbcode_uid']);
			$decoded_message = preg_replace("#\[jdmp:$uid\].*?\[/jdmp:$uid\]#ise", "\$user->lang['HIDDEN_LINKS']", $decoded_message);


Abrir: /includes/ucp/ucp_pm_compose.php

Buscar:

Código: Seleccionar todo

		if ($action == 'quotepost')
		{
			// Decode text for message display
Agregar despues:

Código: Seleccionar todo

			$uid = $post['bbcode_uid'];
			$message_text = preg_replace("#\[jdmp:$uid\].*?\[/jdmp:$uid\]#ise", "\$user->lang['HIDDEN_LINKS']", $message_text);

Re: BBCODE para Jdownloader Clic N Load 2

Publicado: 02 Jun 2014, 09:15
por joanllm
Si ay algún problema o algún fallo con el bbcode por favor comentenlo aquí para que pueda solucionarlo, saludos.

Re: BBCODE para Jdownloader Clic N Load 2

Publicado: 11 Sep 2014, 13:42
por okawa
No me funciona

Aqui podeis ver como se ve

http://www.nuevamierda.es/viewtopic.php?f=78&t=624

He limpiado la cache pero nada, se muestra el mensaje tal cual con el bbcode.

He hecho todo, para multiples enlaces

Re: BBCODE para Jdownloader Clic N Load 2

Publicado: 11 Sep 2014, 14:34
por okawa
Me funciona ya, pero me muestra los siguientes errores:

Código: Seleccionar todo

[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 666: mcrypt_generic(): An empty string was passed
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4825: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3911)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4827: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3911)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4828: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3911)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4829: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3911)

Re: BBCODE para Jdownloader Clic N Load 2

Publicado: 02 Nov 2014, 12:25
por enigmaelectronica
para eso entonces desactiva la opción de "Convertir enlaces automaticamente" desde el panel de usuario

Re: BBCODE para Jdownloader Clic N Load 2

Publicado: 19 Dic 2014, 03:22
por andares
Para que sea mas fácil su instalación he empaquetado, adaptado y perfilado un poco el código de "Joamlin" para su instalación con AutoMOD :
[phpBB30X] BBCODE para Jdownloader Clic N Load 2.zip
Para instalar con phpBB 3.0.X
(36.11 KiB) Descargado 417 veces

Re: BBCODE para Jdownloader Clic-N-Load 2, Funcionando

Publicado: 27 Abr 2015, 19:10
por enigmaelectronica
Ya me di cuenta, lástima los íconos, de Jdownloader... por eso del MOD. Pero creo que se puede solucionar si se lograse integrar en los botones de edición de texto en el post.
¿Sabe alguien como agregarlo para poner uno personalizado?