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/config.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 $db = yourls_db_connect();
\r
27 $return = yourls_add_new_link( $url, $keyword, $db );
\r
29 $shorturl = $return['shorturl'];
\r
30 $message = $return['message'];
\r
33 <h2>URL has been shortened</h2>
\r
34 <p>Original URL: <code><a href="$url">$url</a></code></p>
\r
35 <p>Short URL: <code><a href="$shorturl">$shorturl</a></code></p>
\r
40 // Part to be executed when no form has been submitted
\r
44 <h2>Enter a new URL to shorten</h2>
\r
45 <form method="post" action="">
\r
46 <p><label>URL: <input type="text" name="url" value="http://" size="50" /></label></p>
\r
47 <p><label>Optional custom keyword: <input type="text" name="keyword" size="5" /></label></p>
\r
48 <p><input type="submit" value="Shorten" /></p>
\r
56 <div id="footer"><p>Powered by <a href="http://yourls.org/" title="YOURLS">YOURLS</a> v<?php echo YOURLS_VERSION; ?></p></div>
\r