2 /* This is an example file for a public interface and a bookmarklet. It
\r
3 * is provided so you can build from it and customize to suit your needs.
\r
4 * It's not really part of the project. Don't submit feature requests
\r
5 * about this file. It's _your_ job to make it what you need it to be :)
\r
8 // Start YOURLS engine
\r
9 require_once( dirname(__FILE__).'/includes/load-yourls.php' );
\r
11 // Insert <head> markup and all CSS & JS files
\r
15 $site = trim( YOURLS_SITE, 'http://' );
\r
16 echo "<h1>$site's URL Shortener</h1>\n";
\r
18 // Display left hand menu
\r
19 yourls_html_menu() ;
\r
22 // Part to be executed if FORM has been submitted
\r
23 if ( isset( $_REQUEST['url'] ) ) {
\r
25 $url = yourls_sanitize_url( $_REQUEST['url'] );
\r
26 $keyword = isset( $_REQUEST['keyword'] ) ? yourls_sanitize_keyword( $_REQUEST['keyword'] ): '' ;
\r
27 $title = isset( $_REQUEST['title'] ) ? yourls_sanitize_title( $_REQUEST['title'] ) : '' ;
\r
29 $return = yourls_add_new_link( $url, $keyword, $title );
\r
31 $shorturl = isset( $return['shorturl'] ) ? $return['shorturl'] : '';
\r
32 $message = isset( $return['message'] ) ? $return['message'] : '';
\r
33 $title = isset( $return['title'] ) ? $return['title'] : '';
\r
35 // Include the Copy box and the Quick Share box
\r
36 yourls_share_box( $url, $shorturl, $title );
\r
38 // Initialize clipboard -- requires js/share.js and js/jquery.zclip.min.js to be properly loaded
\r
45 // Part to be executed when no form has been submitted
\r
48 $site = YOURLS_SITE;
\r
52 <h2>Enter a new URL to shorten</h2>
\r
53 <form method="post" action="">
\r
54 <p><label>URL: <input type="text" class="text" name="url" value="http://" size="70" /></label></p>
\r
55 <p><label>Optional custom short URL: $site/<input type="text" class="text" name="keyword" size="8" /></label></p>
\r
56 <p><label>Optional title: <input type="text" class="text" name="title" size="57" /></label></p>
\r
57 <p><input type="submit" class="button primary" value="Shorten" /></p>
\r
63 // Display bookmarklet hint and link
\r
65 <!-- Example bookmarklet. Be sure to rename the link target from "sample-public-front-page.php" to whatever you'll use (probably index.php) -->
\r
66 <h2>Bookmarklet</h2>
\r
68 #bookmark{display:inline-block; border:1px solid #88c0eb; background:#eee; padding:5px 10px; color:#595441; font-weight:bold; cursor:move; border-radius:5px}
\r
70 <p>Bookmark this link (drag to bookmark bar) : <a id="bookmark" href="javascript:void(location.href='<?php echo YOURLS_SITE; ?>/sample-public-front-page.php?format=simple&action=shorturl&url='+escape(location.href))">Shorten</a>
\r
73 // Display page footer
\r
74 yourls_html_footer();
\r