Ajuda com um paste

  • Autor Autor ZeroDesj
  • Data de início Data de início
Tradução em andamento: em alguns minutos este tópico estará em português. Por enquanto, o conteúdo está no original em espanhol. Ver original
Z

ZeroDesj

Eta
SEO
Usuário com poucas negociações! Use sempre o saldo do ForoBeta!
Necesito una pequeña ayuda con esto, no se absolutamente nada de programacion. u.u

estoy utilizando el script open source SnipsManager que pueden conseguirlo desde aqui: Enlace eliminado

Es un script paste.

Lo que quisiera es hacer que los links que esten en el paste se puedan abrir y no sean un simple texto .-.

Mi sitio de prueba:
Enlace eliminado

como quisiera que quedaran los links:
Enlace eliminado

[MENTION=9679]cicklow[/MENTION]

Por favor necesito ayuda T_T, tengo 2 horas y no logro nada .-.
 
Foi útil? Participe da conversa

Com sua conta grátis você pode responder, mandar mensagem privada ao autor e comprar com Saldo retido: o pagamento é liberado quando você recebe o combinado.

Leva 30 segundos · você volta a este tópico ao terminar
hay muchos codigos de PHP para pasar links de texto a clikeables...
php - Replace URLs in text with HTML links - Stack Overflow
en tu caso editas show.php y tienes:
PHP:
<center><div class='textbox2' id="snippet"><?php if($found) { echo $geshi->parse_code(); } ?></div></center>
Entoces cambias ese $geshi->parse_code() por la de cambiar los links...
PHP:
<?php
$rexProtocol = '(https?://)?';
$rexDomain   = '((?:[-a-zA-Z0-9]{1,63}\.)+[-a-zA-Z0-9]{2,63}|(?:[0-9]{1,3}\.){3}[0-9]{1,3})';
$rexPort     = '(:[0-9]{1,5})?';
$rexPath     = '(/[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]*?)?';
$rexQuery    = '(\?[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?';
$rexFragment = '(#[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?';

function callback($match)
{
    // Prepend http:// if no protocol specified
    $completeUrl = $match[1] ? $match[0] : "http://{$match[0]}";

    return '<a href="' . $completeUrl . '" target="_blank">'. $match[2] . $match[3] . $match[4] . '</a>';
}
?>
<center><div class='textbox2' id="snippet"><?php if($found) { echo preg_replace_callback("&\\b$rexProtocol$rexDomain$rexPort$rexPath$rexQuery$rexFragment(?=[?.!,;:\"]?(\s|$))&",'callback', htmlspecialchars($geshi->parse_code())); } ?></div></center>
 
hay muchos codigos de PHP para pasar links de texto a clikeables...
php - Replace URLs in text with HTML links - Stack Overflow
en tu caso editas show.php y tienes:
PHP:
<center><div class='textbox2' id="snippet"><?php if($found) { echo $geshi->parse_code(); } ?></div></center>
Entoces cambias ese $geshi->parse_code() por la de cambiar los links...
PHP:
<?php
$rexProtocol = '(https?://)?';
$rexDomain   = '((?:[-a-zA-Z0-9]{1,63}\.)+[-a-zA-Z0-9]{2,63}|(?:[0-9]{1,3}\.){3}[0-9]{1,3})';
$rexPort     = '(:[0-9]{1,5})?';
$rexPath     = '(/[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]*?)?';
$rexQuery    = '(\?[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?';
$rexFragment = '(#[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?';

function callback($match)
{
    // Prepend http:// if no protocol specified
    $completeUrl = $match[1] ? $match[0] : "http://{$match[0]}";

    return '<a href="' . $completeUrl . '" target="_blank">'. $match[2] . $match[3] . $match[4] . '</a>';
}
?>
<center><div class='textbox2' id="snippet"><?php if($found) { echo preg_replace_callback("&\\b$rexProtocol$rexDomain$rexPort$rexPath$rexQuery$rexFragment(?=[?.!,;:\"]?(\s|$))&",'callback', htmlspecialchars($geshi->parse_code())); } ?></div></center>

Gracias por responder.

Sale con algunas cosas .-.

Enlace eliminado
 
Gracias por responder.

Sale con algunas cosas .-.

Enlace eliminado

es por el htmlspecialchars($geshi->parse_code())... tendria que quedar sin htmlspecialchars...
 
es por el htmlspecialchars($geshi->parse_code())... tendria que quedar sin htmlspecialchars...

si le quito el htmlspecialchars, vuelve a estar como antes el paste: Enlace eliminado
 
si le quito el htmlspecialchars, vuelve a estar como antes el paste: Enlace eliminado

PHP:
html_entity_decode(htmlspecialchars($geshi->parse_code()))
html_entity_decode vuelve a convertir el HTML
 
PHP:
html_entity_decode(htmlspecialchars($geshi->parse_code()))
html_entity_decode vuelve a convertir el HTML

me sigue saliendo igual, te dejo el codigo de show haber si lo puse bien

PHP:
<?php
session_start();
include('config.php');
include('includes/functions.php');
connect();

if(!empty($_GET['id'])) {
	$id = mysql_real_escape_string(htmlspecialchars(strip_tags($_GET['id'])));
} else {
	$id = 0;
}

if(ch_codeexists($id)) {
	if(ch_getcodepassword($id) != NULL) {
		if($_SESSION['pages']!=$id)	{
			echo '<script type="text/javascript">window.location="login.php?id='.$id.'";</script>';
		}
	}
	elseif(ch_getcodecaptcha($id)) {
		if($_SESSION['pages']!=$id) {
			header('location:captcha.php?id=' . $id);
		}
	}

	$type = ch_gettype(ch_getcodetype($id), false);

	include_once 'includes/geshi.php';
	$source = ch_formatCodeForDisplaying(ch_getcode($id));

	$geshi = new GeSHi($source, $type);
	$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
	$geshi->set_line_style('background: #fcfcfc;', 'background: #f0f0f0;');
	$geshi->set_header_type(GESHI_HEADER_DIV);
	$geshi->set_tab_width(5);
	$geshi->enable_classes();
	$geshi->set_overall_id('mycode');

	$found=true;

	$additional_script_tags = '<style type="text/css">' . $geshi->get_stylesheet() . '</style>';
}
else {
    $found=false;
}

include('header.php');
?>


<div class='work'>
    <div class='sub'>
	<?php if($found) { ?>
        <span>Type: <?php echo ch_gettype(ch_getcodetype($id), true);?></span>
           Viewing #<?php echo $id;?>
	<?php } ?>
    </div>
<div class='body'>

	<?php
		if(!$found) {
			echo "<div id='error' style='display:block;'>Error! That code ID does not exist!</div>";
		}
		else {
	?>

	<div id='error'></div>
	<div class='top3'></div>
    <center><div class="textbox1"><?php echo ch_getcodetitle($id); // $row['codetitle']; ?></div></center>
    <div class='bottom3'></div>

	<br />

	<div class='top'></div>
	<?php
$rexProtocol = '(https?://)?';
$rexDomain   = '((?:[-a-zA-Z0-9]{1,63}\.)+[-a-zA-Z0-9]{2,63}|(?:[0-9]{1,3}\.){3}[0-9]{1,3})';
$rexPort     = '(:[0-9]{1,5})?';
$rexPath     = '(/[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]*?)?';
$rexQuery    = '(\?[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?';
$rexFragment = '(#[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?';

function callback($match)
{
    // Prepend http:// if no protocol specified
    $completeUrl = $match[1] ? $match[0] : "http://{$match[0]}";

    return '<a href="' . $completeUrl . '" target="_blank">'. $match[2] . $match[3] . $match[4] . '</a>';
}
?>
<center><div class='textbox2' id="snippet"><?php if($found) { echo preg_replace_callback("&\\b$rexProtocol$rexDomain$rexPort$rexPath$rexQuery$rexFragment(?=[?.!,;:\"]?(\s|$))&",'callback', html_entity_decode(htmlspecialchars($geshi->parse_code()))); } ?></div></center>
	<div class='bottom'></div>

    <div class='bot2'>
<script type="text/javascript">
	function fnSelect(objId) {
		fnDeSelect();
		if (document.selection) {
		var range = document.body.createTextRange();
 	        range.moveToElementText(document.getElementById(objId));
		range.select();
		}
		else if (window.getSelection) {
		var range = document.createRange();
		range.selectNode(document.getElementById(objId));
		window.getSelection().addRange(range);
		}
	}

	function fnDeSelect() {
		if (document.selection) document.selection.empty();
		else if (window.getSelection)
                window.getSelection().removeAllRanges();
	}
</script>
        <form method="post" name="download" action="includes/download.php">
            <input type="hidden" value="<?=$id;?>" name="id"  />
            <input type="hidden" value="<?= ch_getcodepassword($id)?>" name="passwd"  />
            <input type="image" style="padding-left:10px;" src="images/source.png" alt="Download Source" title="Download snippet in a text file" />
			<a href="javascript:fnSelect('snippet');">
				<img src="images/selectall.png" alt="Select Snippet" title="Select the snippet" />
			</a>
	        <div style="float:right; padding-right:10px; text-align:right; width:185px;">
				<!-- AddThis Button BEGIN -->
				<div class="addthis_toolbox addthis_default_style addthis_32x32_style">
				<a class="addthis_button_preferred_1"></a>
				<a class="addthis_button_preferred_2"></a>
				<a class="addthis_button_preferred_3"></a>
				<a class="addthis_button_preferred_4"></a>
				<a class="addthis_button_compact"></a>
				</div>
				<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>
				<!-- AddThis Button END -->
			</div>
        </form>
    </div>

<?php
	}
include("footer.php"); ?>
 
me sigue saliendo igual, te dejo el codigo de show haber si lo puse bien

PHP:
...

PHP:
<center><div class='textbox2' id="snippet"><?php if($found) { echo html_entity_decode(preg_replace_callback("&\\b$rexProtocol$rexDomain$rexPort$rexPath$rexQuery$rexFragment(?=[?.!,;:\"]?(\s|$))&",'callback', htmlspecialchars($geshi->parse_code()))); } ?></div></center>

intenta asi!
 
PHP:
<center><div class='textbox2' id="snippet"><?php if($found) { echo html_entity_decode(preg_replace_callback("&\\b$rexProtocol$rexDomain$rexPort$rexPath$rexQuery$rexFragment(?=[?.!,;:\"]?(\s|$))&",'callback', htmlspecialchars($geshi->parse_code()))); } ?></div></center>

intenta asi!

CASIII!!!!!

lo unico que falla es que le agrega un div y li al final de las urls

Enlace eliminado
 
CASIII!!!!!

lo unico que falla es que le agrega un div y li al final de las urls

Enlace eliminado

si veo... eso es porque el div esta pegado a la url... se podria testear con otras funciones de convertir los links a HTML... o buscar dentro de geshi.php (el cual es ree grande) donde mete los links y convertirlos desde ahi... por ahi se te hace mas facil buscar otra funcion...

otra opcion es no tocar el code PHP y convertir los links a HTML desde JS...
Enlace eliminado
https://github.com/gregjacobs/Autolinker.js
 
si veo... eso es porque el div esta pegado a la url... se podria testear con otras funciones de convertir los links a HTML... o buscar dentro de geshi.php (el cual es ree grande) donde mete los links y convertirlos desde ahi... por ahi se te hace mas facil buscar otra funcion...

otra opcion es no tocar el code PHP y convertir los links a HTML desde JS...
Enlace eliminado
https://github.com/gregjacobs/Autolinker.js

si, mejor usar js .-.
[MENTION=9679]cicklow[/MENTION] como podria poner uno de los dos para que funcionara en el paste?

- - - Actualizado - - -
[MENTION=9679]cicklow[/MENTION] estoy muy agradecido contigo por intentar ayudarme anoche, pero no pude resolver el problema :v, asi que decidi comprar un script que ya lo hacia todo [MENTION=6960]kj2[/MENTION] excelente script paste C:
 
Última edição:
Voltar
Topo