Hola a todos, tengo un acortador de URL, pero no sé como crear un bookmarklet, he tratado con muchos que he visto en internet, pero ninguna me funciona. Me podrían dar una mano?
Acá el códifo de mi sitio:
Código:
<?php
require_once 'includes/conf.php';
require_once 'includes/surll.php';
$surll = new surll();
$msg = '<p class="success"> </p>';
$ejemplo = strlen($longurl);
$hasta = strlen($url);
$urlcount = $surll->CountUrls();
if ( $urlcount == '0')
$msgurl = "| No links acortados |";
elseif ($urlcount == '1')
$msgurl = "$urlcount urls acortados // ccl.cl - acortador de url";
else
$msgurl = "$urlcount urls acortados // ccl.cl - acortador de url";
if ( isset($_POST['longurl']) )
{
$longurl = trim(mysql_escape_string($_POST['longurl']));
$protocol_ok = false;
if ( count($allowed_protocols) )
{
foreach ( $allowed_protocols as $ap )
{
if ( strtolower(substr($longurl, 0, strlen($ap))) == strtolower($ap) )
{
$protocol_ok = true;
break;
}
}
}
else
{
$protocol_ok = true;
}
if ( $protocol_ok && $surll->add_url($longurl) )
{
if ( REWRITE )
{
$url = 'http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']).''.$surll->get_id($longurl);
}
else
{
$url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'].'?id='.$surll->get_id($longurl);
}
$hasta = strlen($url);
$ejemplo = strlen($longurl);
$resta = $ejemplo-$hasta;
$por = round(($resta / $ejemplo)*100,0);
$msg = '
<p align="left"> </p>
Tu URL corta es: <input type="text" name="nombre" style="background-color:#FFF; font-size:14pt; color: #0099CC; border: 2px solid #0099CC" onclick=this.select(); value="'.$url.'"> - <a href="index.php" target="_self"> acortar otro link</a><h3>(Haz click sobre la url y luego "Ctrl+C" para copiarla, o simplemente "copiar" con el mouse)</h3>
</label></p>
<a href="http://twitter.com/home?status='.$url.'" target="_blank">Twittear esta URL</a> | <a href="'.$url.'" target="_blank">[Probar esta URL corta en una nueva ventana]</a> </p>
<p align="left"> </p>' ;
}
elseif ( !$protocol_ok )
{
$msg = '<p class="error">Url incorrecta, por favor revisa bien la que ingresaste!</p>';
}
else
{
$msg = '<p class="error">La creación de'.SITE_NAME.' falló por alguna razón.</p>';
}
}
else
{
if ( isset($_GET['id']) )
{
$id = mysql_escape_string($_GET['id']);
}
elseif ( REWRITE )
{
$explodo = explode('/', $_SERVER['REQUEST_URI']);
$id = mysql_escape_string($explodo[count($explodo)-1]);
}
else
{
$id = '';
}
if ( $id != '' && $id != basename($_SERVER['PHP_SELF']) )
{
$location = $surll->get_url($id);
if ( $location != -1 )
{
header('Location: '.$location);
}
else
{
$msg = '<p class="error">Disculpa, pero '.SITE_NAME.' no está en nuestra base de datos.</p>';
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head profile="http://www.w3.org/2005/10/profile">
<title><?php echo PAGE_TITLE; ?></title>
<meta name="description" content="<?php echo SITE_DESC;?>" />
<meta name="keywords" content="<?php echo SITE_KEYS;?>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="templates/<?php echo STYLE ?>.css" />
<link rel="icon" type="image/png" href="favicon.png" />
<style type="text/css">
<!--
body {
background-color: #002F4A;
background-image: url();
background-repeat: repeat;
}
#apDiv1 {
position:absolute;
width:91px;
height:70px;
z-index:1;
left: 15px;
top: 19px;
}
-->
</style>
</head>
<body onload="document.getElementById('longurl').focus()">
<div style="margin: 0 auto; width: 700px;">
<h3>
<p> </p>
</h3>
<div id="apDiv1"> <iframe src="http://www.facebook.com/plugins/like.php?href=http%253A%252F%252Fccl.cl%252F&layout=button_count" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px;" allowTransparency="true"></iframe>
</div>
<h3>
<p>
<style type="text/css">
.boton{
font-size:15px;
font-family:Arial,Helvetica;
color:white;
background:#0099CC;
border:0px;
width:140px;
height:28px;
}
</style>
</p>
</h3>
<p>
<style type="text/css">
.boton3{
font-size:12px;
font-family:Arial,Helvetica;
color:white;
background:#0099CC;
border:0px;
width:70px;
height:23px;
}
</style>
<a href="index.php" target="_self"><img src="acortadordeurl.jpg" alt="ccl.cl - acortador de url" width="202" height="53" border="0" /></a>
</p>
<p>Comparte en Twitter, tus laaargos enlaces a YouTube, Facebook, Noticias, Blogs o lo que quieras!</p>
<form action="index.php" method="post" name=frm1>
<fieldset>
<div align="left">Ingresa o pega la URL que quieres acortar: </div>
</label>
<div align="left">
<input name="longurl" type="text" class="text" id="longurl" style="background-color:#FFF; border: 5px solid #0099CC; font-size:14pt; color: #0099CC" onchange=javascript:filterHTTP(); onkeyup=javascript:filterHTTP(); value="http://www."/>
</div>
<div align="left">
<button type="submit" class="boton" ><?php echo SUBMIT_TEXT; ?></button>
<?php echo $msg; ?> </div>
</fieldset>
</form>
<p align="left"> <BR> <BR>
<form method="get" action="http://search.twitter.com/search">
<div align="center"></div>
</form>
>
<p align="left"> </p>
<p align="left"> </p>
<p align="left"><script type="text/javascript">
$(document).ready(function(){
$("input.txturl").click(function(event){
$("input.txturl").attr('value','');
$("input.txturl").unbind("click");
});
gettwits("ir.pe", "home");});
</script>
</p>
<p align="left"> </p>
<h3>
<a href="javascript:void(location.href='http://ccl.cl/?url='+encodeURIComponent(location.href))" class="bkm">ir!</a>
</h3>
<h3 align="center">
<p align="center"> | <a href="http://search.twitter.com/search?q=ccl.cl" target="_self">Gente usando ccl.cl</a> | <a href="http://twitter.com/acortador" target="_self">twitter</a> | </p>
</h3>
<h3 align="center">
<h3><p> <?php echo $msgurl; ?></p></h3>
</h3>
<h3 align="center"> </h3>
</p>
</div>
<SCRIPT type=text/javascript>
function filterHTTP() {
if( document.forms && document.forms['frm1'] ) {
var f = document.forms['frm1'];
if( f.elements['longurl'] && f.elements['longurl'].value != "" && f.elements['longurl'].value.length > 14 ) {
if( f.elements['longurl'].value.substring( 0, 14 ).toLowerCase() == "http://http://" ) f.elements['longurl'].value = f.elements['longurl'].value.substring( 7 );
}
}
}
</SCRIPT>
<SCRIPT type=text/javascript>
if( document.forms && document.forms['frm1'] ) {
var f = document.forms['frm1'];
if( f.elements['longurl'] ) {
f.elements['longurl'].focus();
f.elements['longurl'].value = f.elements['longurl'].value + "";
}
}
</SCRIPT>
<script language=javascript>
function ventanaSecundaria (URL){
window.open(URL,"ventana1","width=500,height=180,scrollbars=NO")
}
</script>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-1441050-6");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
y algunos bookmarklet que he visto son los siguientes:
Código:
<a onclick="return false" onmouseover="window.status='';return true" href="javascript:void(location.href='http://li.co.ve/create.php?url='+encodeURIComponent(location.href))">
Código:
<a href="javascript:url=document.location='http://saf.li/en/create?url='+document.location.href.replace(/^\s+|\s+$/g,'').replace(/\x2E/g,'%2E');" class="style2Inactive" title="Shorten with saf.li!" onmouseover="showBookmark()" onmouseout="hideBookmark()">bookmarklet</a>
Muchas gracias por sus ayudas!!