3 <title>YOURLS Public Interface Sample</title>
\r
5 body {background:#BFE0FE; color:#666; font:16px/30px verdana,arial,sans-serif;}
\r
6 h1 {text-align:center}
\r
7 h2 {border-bottom:1px solid white}
\r
8 #credits, #credit a {font-size:80%; color:#aaa}
\r
10 <!-- customize more: CSS, etc -->
\r
14 <h1>YOURLS: Your Own URL Shortener</h1>
\r
17 require_once( dirname(__FILE__).'/includes/load-yourls.php' );
\r
19 // Part to be executed if FORM has been submitted
\r
20 if ( isset($_REQUEST['url']) ) {
\r
22 $url = $_REQUEST['url'];
\r
23 $keyword = isset( $_REQUEST['keyword'] ) ? $_REQUEST['keyword'] : '' ;
\r
25 $return = yourls_add_new_link( $url, $keyword );
\r
27 $shorturl = $return['shorturl'];
\r
28 $message = $return['message'];
\r
31 <h2>URL has been shortened</h2>
\r
32 <p>Original URL: <code><a href="$url">$url</a></code></p>
\r
33 <p>Short URL: <code><a href="$shorturl">$shorturl</a></code></p>
\r
38 If you want to add the Quick Share box like on the private bookmarklet, simply use this PHP function:
\r
39 <?php yourls_share_box( $url, $shorturl ); ?>
\r
40 For all the special stuff to work you need to include js/share.js in the <head> of your page
\r
44 // Part to be executed when no form has been submitted
\r
48 <h2>Enter a new URL to shorten</h2>
\r
49 <form method="post" action="">
\r
50 <p><label>URL: <input type="text" name="url" value="http://" size="50" /></label></p>
\r
51 <p><label>Optional custom keyword: <input type="text" name="keyword" size="5" /></label></p>
\r
52 <p><input type="submit" value="Shorten" /></p>
\r
60 <!-- Example bookmarklet. Be sure to rename the link target from "sample-public-front-page.php" to whatever you'll use (probably index.php) -->
\r
61 <p><a href="javascript:void(location.href='<?php echo YOURLS_SITE; ?>/sample-public-front-page.php?format=simple&action=shorturl&url='+escape(location.href))">bookmarklet</a>
\r
63 <div id="footer"><p>Powered by <a href="http://yourls.org/" title="YOURLS">YOURLS</a> v<?php echo YOURLS_VERSION; ?></p></div>
\r