- /** This is an example file for a public interface and a bookmarklet. It* is provided so you can build from it and customize to suit your needs.* It's not really part of the project. Don't submit feature requests* about this file. It's _your_ job to make it what you need it to be :)** Rename to .php**/// Start YOURLS enginerequire_once( dirname(__FILE__).'/includes/load-yourls.php' );// Change this to match the URL of your public interface. Something like: http://your-own-domain-here.com/index.php$page = YOURLS_SITE . '/sample-public-front-page.php' ;// Part to be executed if FORM has been submittedif ( isset( $_REQUEST['url'] ) && $_REQUEST['url'] != 'http://' ) {// Get parameters -- they will all be sanitized in yourls_add_new_link()$url = $_REQUEST['url'];$keyword = isset( $_REQUEST['keyword'] ) ? $_REQUEST['keyword'] : '' ;$title = isset( $_REQUEST['title'] ) ? $_REQUEST['title'] : '' ;$text = isset( $_REQUEST['text'] ) ? $_REQUEST['text'] : '' ;// Create short URL, receive array $return with various information$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'] : '';$status = isset( $return['status'] ) ? $return['status'] : '';// Stop here if bookmarklet with a JSON callback function ("instant" bookmarklets)if( isset( $_GET['jsonp'] ) && $_GET['jsonp'] == 'yourls' ) {$short = $return['shorturl'] ? $return['shorturl'] : '';$message = "Short URL (Ctrl+C to copy)";header('Content-type: application/json');echo yourls_apply_filter( 'bookmarklet_jsonp', "yourls_callback({'short_url':'$short','message':'$message'});" );die();}}// Insert markup and all CSS & JS filesyourls_html_head();// Display titleecho "
YOURLS - Your Own URL Shortener
\n";// Display left hand menuyourls_html_menu() ;// Part to be executed if FORM has been submittedif ( isset( $_REQUEST['url'] ) && $_REQUEST['url'] != 'http://' ) {// Display result message of short link creationif( isset( $message ) ) {echo "$message
";}if( $status == 'success' ) {// Include the Copy box and the Quick Share boxyourls_share_box( $url, $shorturl, $title, $text );// Initialize clipboard -- requires js/share.js and js/clipboard.min.js to be properly loaded in theecho "\n";}// Part to be executed when no form has been submitted} else {$site = YOURLS_SITE;// Display the formecho <<Enter a new URL to shorten
HTML;}?>Bookmarklets
Bookmark these links:
Please note
Be aware that a public interface will attract spammers. You are strongly advised to install anti spam plugins and any appropriate counter measure to deal with this issue.
// Display page footeryourls_html_footer();
Menu
New paste
Download
Show/Hide line no.
Copy text to clipboard