2011-11-30 17:41:02 +00:00
<! DOCTYPE HTML PUBLIC " -//W3C//DTD HTML 4.01//EN "
" http://www.w3.org/TR/html4/strict.dtd " >
2011-04-19 19:45:10 +01:00
< ? php
// Start YOURLS engine
require_once ( dirname ( __FILE__ ) . '/includes/load-yourls.php' );
2011-09-02 15:14:13 +01:00
2011-11-27 16:33:47 +00:00
// Ask for Infinity Squared settings
2011-11-30 17:41:02 +00:00
require_once ( dirname ( __FILE__ ) . '/public/config.php' );
class ISQ { public static $general = array (), $links = array (), $social = array (); }
// Settings definitions
$ISQtitle = ISQ :: $general [ 'name' ];
$ISQname_1 = ISQ :: $links [ 'name_1' ];
2011-11-30 18:41:10 +00:00
$ISQurl_1 = ISQ :: $links [ 'url_1' ];
2011-11-30 17:41:02 +00:00
$ISQname_2 = ISQ :: $links [ 'name_2' ];
2011-11-30 18:41:10 +00:00
$ISQurl_2 = ISQ :: $links [ 'url_2' ];
2011-11-30 17:41:02 +00:00
$ISQname_3 = ISQ :: $links [ 'name_3' ];
2011-11-30 18:41:10 +00:00
$ISQurl_3 = ISQ :: $links [ 'url_3' ];
2011-11-30 17:41:02 +00:00
$ISQname_4 = ISQ :: $links [ 'name_4' ];
2011-11-30 18:41:10 +00:00
$ISQurl_4 = ISQ :: $links [ 'url_4' ];
2011-11-30 17:41:02 +00:00
$ISQname_5 = ISQ :: $links [ 'name_5' ];
2011-11-30 18:41:10 +00:00
$ISQurl_5 = ISQ :: $links [ 'url_5' ];
2011-11-30 17:41:02 +00:00
$ISQname_6 = ISQ :: $links [ 'name_6' ];
2011-11-30 18:41:10 +00:00
$ISQurl_6 = ISQ :: $links [ 'url_6' ];
2011-11-30 17:41:02 +00:00
$ISQname_7 = ISQ :: $links [ 'name_7' ];
2011-11-30 18:41:10 +00:00
$ISQurl_7 = ISQ :: $links [ 'url_7' ];
2011-11-30 17:41:02 +00:00
$ISQname_8 = ISQ :: $links [ 'name_8' ];
2011-11-30 18:41:10 +00:00
$ISQurl_8 = ISQ :: $links [ 'url_8' ];
2011-11-30 17:41:02 +00:00
$ISQname_9 = ISQ :: $links [ 'name_9' ];
2011-11-30 18:41:10 +00:00
$ISQurl_9 = ISQ :: $links [ 'url_9' ];
2011-11-30 17:41:02 +00:00
$ISQname_10 = ISQ :: $links [ 'name_10' ];
2011-11-30 18:41:10 +00:00
$ISQurl_10 = ISQ :: $links [ 'url_10' ];
2011-11-30 17:41:02 +00:00
// Error definitions
if ( $message = $url . " added to database " ) {
$error = " <h2>URL shortened successfully</h2> \n <p>View the details of your short URL below.</p> " ;
} elseif ( $message = $url . " already exists in database " ) {
$error = " <h2 class='error'>An error has occured :(</h2> \n <p class='error'>This URL already exists in this database. This website does not allow a single URL to have multiple short links.</p> " ;
} elseif ( $message = " Short URL " . $url . " already exists in database or is reserved " ) {
$error = " <h2 class='error'>An error has occured :(</h2> \n <p class='error'>This short URL already exists in this database or is reserved. This website does not allow a single URL to have multiple short links. It could've also been reserved by the admin.</p> " ;
} elseif ( $message = " Missing URL input " ) {
$error = " <h2 class='error'>An error has occured :(</h2> \n <p class='error'>You did not enter the URL you want to shorten or the server lost it. Please try again.</p> " ;
} elseif ( $message = " URL is a short URL " ) {
$error = " <h2 class='error'>An error has occured :(</h2> \n <p class='error'>You cannot shorten a short URL!</p> " ;
}
2011-04-19 19:45:10 +01:00
?>
2011-11-30 17:41:02 +00:00
2011-04-19 19:45:10 +01:00
< html >
< head >
2012-08-29 14:55:08 +01:00
< ? php if ( ! empty ( ISQ :: $general [ 'mobile' ])) { echo " <script type='text/javascript'>if (screen.width <= 720) { document.location = 'mobile.php'; }</script> " ; } ?>
2011-11-30 17:41:02 +00:00
< title >< ? php echo $ISQtitle ; ?> </title>
< meta http - equiv = " Content-Type " content = " text/html;charset=utf-8 " >
2011-05-07 12:44:45 +01:00
< script src = " <?php echo YOURLS_SITE; ?>/js/jquery-1.4.3.min.js " type = " text/javascript " ></ script >
< link rel = " stylesheet " href = " <?php echo YOURLS_SITE; ?>/public/formalize.css " />
< script src = " <?php echo YOURLS_SITE; ?>/public/js/jquery.formalize.min.js " type = " text/javascript " ></ script >
2012-08-29 14:55:08 +01:00
< link href = " http://fonts.googleapis.com/css?family=Ubuntu:regular,italic,bold,bolditalic " rel = " stylesheet " type = " text/css " >
2011-05-07 12:44:45 +01:00
< script src = " <?php echo YOURLS_SITE; ?>/public/js/jquery.qtip.min.js " type = " text/javascript " ></ script >
< link rel = " stylesheet " href = " <?php echo YOURLS_SITE; ?>/public/jquery.qtip.min.css " />
2012-08-29 14:55:08 +01:00
< link rel = " stylesheet " href = " <?php echo YOURLS_SITE; ?>/public/normal.css " type = " text/css " />
< script type = " text/javascript " src = " https://apis.google.com/js/plusone.js " >
{ lang : " en-GB " }
</ script >
2011-05-07 12:44:45 +01:00
< script >
$ ( document ) . ready ( function ()
{
2011-11-30 17:41:02 +00:00
// Match all labels with a title tag and use it as the content
$ ( 'label[title]' ) . qtip ();
2011-05-07 12:44:45 +01:00
});
</ script >
2011-04-19 19:45:10 +01:00
</ head >
< body >
< div id = " container " >
2012-08-29 14:55:08 +01:00
< div class = " header " >
2011-11-30 17:41:02 +00:00
< h1 >< a href = " <?php echo YOURLS_SITE; ?> " >< ? php echo $ISQtitle ; ?> </a></h1>
2011-04-19 19:45:10 +01:00
< ul class = " menu " >
2011-11-30 17:41:02 +00:00
< li >< a href = " <?php echo $ISQurl_1 ; ?> " >< ? php echo $ISQname_1 ; ?> </a></li>
< li >< a href = " <?php echo $ISQurl_2 ; ?> " >< ? php echo $ISQname_2 ; ?> </a></li>
< li >< a href = " <?php echo $ISQurl_3 ; ?> " >< ? php echo $ISQname_3 ; ?> </a></li>
< li >< a href = " <?php echo $ISQurl_4 ; ?> " >< ? php echo $ISQname_4 ; ?> </a></li>
< li >< a href = " <?php echo $ISQurl_5 ; ?> " >< ? php echo $ISQname_5 ; ?> </a></li>
< li >< a href = " <?php echo $ISQurl_6 ; ?> " >< ? php echo $ISQname_6 ; ?> </a></li>
< li >< a href = " <?php echo $ISQurl_7 ; ?> " >< ? php echo $ISQname_7 ; ?> </a></li>
< li >< a href = " <?php echo $ISQurl_8 ; ?> " >< ? php echo $ISQname_8 ; ?> </a></li>
< li >< a href = " <?php echo $ISQurl_9 ; ?> " >< ? php echo $ISQname_9 ; ?> </a></li>
< li >< a href = " <?php echo $ISQurl_10 ; ?> " >< ? php echo $ISQname_10 ; ?> </a></li>
2011-04-19 19:45:10 +01:00
</ ul >
2012-08-29 14:55:08 +01:00
</ div >
< div class = " paragraph " >
2011-04-19 19:45:10 +01:00
< ? php
// Part to be executed if FORM has been submitted
if ( isset ( $_REQUEST [ 'url' ]) ) {
$url = yourls_sanitize_url ( $_REQUEST [ 'url' ] );
$keyword = isset ( $_REQUEST [ 'keyword' ] ) ? yourls_sanitize_keyword ( $_REQUEST [ 'keyword' ] ) : '' ;
$title = isset ( $_REQUEST [ 'title' ] ) ? yourls_sanitize_title ( $_REQUEST [ 'title' ] ) : '' ;
$return = yourls_add_new_link ( $url , $keyword , $title );
$shorturl = isset ( $return [ 'shorturl' ] ) ? $return [ 'shorturl' ] : '' ;
$message = isset ( $return [ 'message' ] ) ? $return [ 'message' ] : '' ;
$title = isset ( $return [ 'title' ] ) ? $return [ 'title' ] : '' ;
2012-01-15 16:27:49 +00:00
if ( ! empty ( ISQ :: $social [ 'facebook' ])) { $ISQfacebook = " <a href='http://facebook.com/sharer.php?u= $shorturl ' class='share-button' target='_blank'><img src='public/img/facebook.png' alt='Share on Facebook' /></a> " ; }
if ( ! empty ( ISQ :: $social [ 'twitter' ])) { $ISQtwitter = " <a href='http://twitter.com/share' class='twitter-share-button' data-url=' $shorturl ' data-text=' $title ' data-count='vertical'>Tweet</a><script type='text/javascript' src='http://platform.twitter.com/widgets.js'></script> " ; }
2012-08-29 14:55:08 +01:00
if ( ! empty ( ISQ :: $social [ 'plus' ])) { $ISQplus = " <div class='g-plus' data-action='share' data-annotation='vertical-bubble' data-height='62' data-href=' $shorturl '></div> " ; }
2012-01-15 16:27:49 +00:00
if ( ! empty ( ISQ :: $social [ 'linkedin' ])) { $ISQlinkedin = " <script src='http://platform.linkedin.com/in.js' type='text/javascript'></script><script type='IN/Share' data-url=' $shorturl ' data-counter='top'></script> " ; }
if ( ! empty ( ISQ :: $general [ 'qr' ])) { $ISQqr = " <h2>QR code</h2> \n <p>Share your code with external devices</p> \n <img class='qr' src='https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl= $shorturl &chld=L|0' alt='QR code' /> " ; }
2011-04-19 19:45:10 +01:00
echo <<< RESULT
2011-11-30 17:41:02 +00:00
$error
2011-05-07 12:44:45 +01:00
< div class = " output " >
< p > Original URL : < a href = " $url " > $url </ a ></ p >
< p > Short URL : < a href = " $shorturl " > $shorturl </ a ></ p >
< p > Stats : < a href = " $shorturl + " > $shorturl +</ a ></ p >
</ div >
2011-11-30 17:41:02 +00:00
$ISQqr
2011-05-07 12:44:45 +01:00
< h2 > Share </ h2 >
< p > Share your short URL </ p >
2011-11-30 17:41:02 +00:00
$ISQfacebook
$ISQtwitter
$ISQplus
$ISQlinkedin
2011-04-19 19:45:10 +01:00
RESULT ;
// Part to be executed when no form has been submitted
} else {
$site = YOURLS_SITE ;
echo <<< HTML
< h2 > Enter a new URL to shorten </ h2 >
2011-05-07 12:44:45 +01:00
< h3 > Hover over the labels to see more information </ h3 >
2011-04-19 19:45:10 +01:00
< form method = " post " action = " " >
2011-05-07 12:44:45 +01:00
< p >< label for = " url " title = " Paste the long URL here " > Long URL ( required ) :</ label > < input type = " text " id = " url " class = " right " name = " url " /></ p >
< p >< label for = " keyword " title = " A keyword replaces the default short string " > Custom keyword :</ label > < input type = " text " id = " keyword " class = " right " name = " keyword " /></ p >
< p >< label for = " title " title = " Optional title used when sharing a link from YOURLS " > Optional title :</ label > < input type = " text " id = " title " class = " right " name = " title " /></ p >
2011-04-19 19:45:10 +01:00
< p >< input type = " submit " value = " Shorten " /></ p >
2011-05-07 12:44:45 +01:00
</ form >
2011-04-19 19:45:10 +01:00
HTML ;
}
?>
2012-08-29 14:55:08 +01:00
</ div >
2011-04-19 19:45:10 +01:00
2012-08-29 14:55:08 +01:00
< div class = " paragraph " >
2011-04-19 19:45:10 +01:00
< h2 > The bookmarklets </ h2 >
2012-08-29 14:55:08 +01:00
< p > To use the bookmarklets drag them to your bookmark bar or simply right click on them and select the appropriate option . The instant bookmarklet shortens the URL of the current tab and then opens a kwl . me page in the current tab .</ p >
< p >< a href = " javascript:void(location.href='<?php echo YOURLS_SITE; ?>/index.php?format=simple&action=shorturl&url='+escape(location.href)) " class = " bookmarklet " > Instant Shorten </ a ></ p >
</ div >
2011-04-19 19:45:10 +01:00
< div class = " footer " >
2011-09-02 15:14:13 +01:00
< p > Powered by < a href = " http://yourls.org/ " title = " YOURLS " > YOURLS </ a >. Design by < a href = " http://tomslominski.net/ " > Tom Slominski </ a >. Also used : < a href = " http://formalize.me/ " > Formalize </ a > and < a href = " http://craigsworks.com/projects/qtip2/ " > qTip² </ a >. Find this theme on < a href = " https://github.com/tomslominski/infinity-squared " > GitHub </ a >.</ p >
2011-04-19 19:45:10 +01:00
</ div >
</ div >
</ body >
</ html >