header and logo function yourls_html_logo() { yourls_do_action( 'pre_html_logo' ); ?>

YOURLS: Your Own URL Shortener
YOURLS

tag function yourls_html_head( $context = 'index', $title = '' ) { yourls_do_action( 'pre_html_head', $context, $title ); // All components to false, except when specified true $share = $insert = $tablesorter = $tabs = $cal = false; // Load components as needed switch ( $context ) { case 'infos': $share = $tabs = true; break; case 'bookmark': $share = $insert = $tablesorter = true; break; case 'index': $insert = $tablesorter = $cal = $share = true; break; case 'plugins': case 'tools': $tablesorter = true; break; case 'install': case 'login': case 'new': case 'upgrade': break; } // Force no cache for all admin pages if( yourls_is_admin() && !headers_sent() ) { header( 'Expires: Thu, 23 Mar 1972 07:00:00 GMT' ); header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); header( 'Pragma: no-cache' ); yourls_do_action( 'admin_headers', $context, $title ); } // Store page context in global object global $ydb; $ydb->context = $context; // Body class $bodyclass = yourls_apply_filter( 'bodyclass', '' ); $bodyclass .= ( yourls_is_mobile_device() ? 'mobile' : 'desktop' ); // Page title $_title = 'YOURLS — Your Own URL Shortener | ' . yourls_link(); $title = $title ? $title . " « " . $_title : $_title; $title = yourls_apply_filter( 'html_title', $title, $context ); ?> <?php echo $title ?>
num_queries > 1 ? $ydb->num_queries.' queries' : $ydb->num_queries.' query'; ?>
'. $ydb->all_queries .'

'; } ?> context ); ?>

Enter the URL: Optional: Custom short URL:
Search for   in  – Order by  – Show   rows
Show links with than clicks
Show links created > and />
 
Your short link', $share_title = '

Quick Share

', $hidden = false ) { // Allow plugins to short-circuit the whole function $pre = yourls_apply_filter( 'shunt_share_box', false ); if ( false !== $pre ) return $pre; $text = ( $text ? '"'.$text.'" ' : '' ); $title = ( $title ? "$title " : '' ); $share = htmlspecialchars_decode( $title.$text.$shorturl ); $count = 140 - strlen( $share ); $hidden = ( $hidden ? 'style="display:none;"' : '' ); // Allow plugins to filter all data $data = compact( 'longurl', 'shorturl', 'title', 'text', 'shortlink_title', 'share_title', 'share', 'count', 'hidden' ); $data = yourls_apply_filter( 'share_box_data', $data ); extract( $data ); $_share = rawurlencode( $share ); $_url = rawurlencode( $shorturl ); ?>
>

Long link:
Stats: +

$title" ); echo yourls_apply_filter( 'die_message', "

$message

" ); yourls_do_action( 'yourls_die' ); yourls_html_footer(); die(); } // Add the "Edit" row function yourls_table_edit_row( $keyword ) { global $ydb; $table = YOURLS_DB_TABLE_URL; $keyword = yourls_sanitize_string( $keyword ); $id = yourls_string2htmlid( $keyword ); // used as HTML #id $url = yourls_get_keyword_longurl( $keyword ); $title = htmlspecialchars( yourls_get_keyword_title( $keyword ) ); $safe_url = stripslashes( $url ); $safe_title = stripslashes( $title ); $www = yourls_link(); $save_link = yourls_nonce_url( 'save-link_'.$id, yourls_add_query_arg( array( 'id' => $id, 'action' => 'edit_save', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) ) ); $nonce = yourls_create_nonce( 'edit-save_'.$id ); if( $url ) { $return = <<Original URL: Short URL: $www
Title:   RETURN; } else { $return = 'Error, URL not found'; } $return = yourls_apply_filter( 'table_edit_row', $return, $keyword, $url, $title ); return $return; } // Add a link row function yourls_table_add_row( $keyword, $url, $title = '', $ip, $clicks, $timestamp ) { $keyword = yourls_sanitize_string( $keyword ); $display_keyword = htmlentities( $keyword ); $url = yourls_sanitize_url( $url ); $display_url = htmlentities( yourls_trim_long_string( $url ) ); $title_url = htmlspecialchars( $url ); $title = yourls_sanitize_title( $title ) ; $display_title = yourls_trim_long_string( $title ); $title = htmlspecialchars( $title ); $id = yourls_string2htmlid( $keyword ); // used as HTML #id $date = date( 'M d, Y H:i', $timestamp+( YOURLS_HOURS_OFFSET * 3600 ) ); $clicks = number_format( $clicks, 0, '', '' ); $shorturl = yourls_link( $keyword ); $statlink = yourls_statlink( $keyword ); if( yourls_is_ssl() ) $statlink = str_replace( 'http://', 'https://', $statlink ); if( $title ) { $display_link = "$display_title
$display_url"; } else { $display_link = "$display_url"; } $delete_link = yourls_nonce_url( 'delete-link_'.$id, yourls_add_query_arg( array( 'id' => $id, 'action' => 'delete', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) ) ); $edit_link = yourls_nonce_url( 'edit-link_'.$id, yourls_add_query_arg( array( 'id' => $id, 'action' => 'edit', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) ) ); // Action button links $actions = array( 'stats' => array( 'href' => $statlink, 'id' => "statlink-$id", 'title' => 'Stats', 'anchor' => 'Stats', ), 'share' => array( 'href' => '', 'id' => "share-button-$id", 'title' => 'Share', 'anchor' => 'Share', 'onclick' => "toggle_share('$id');return false;", ), 'edit' => array( 'href' => $edit_link, 'id' => "edit-button-$id", 'title' => 'Edit', 'anchor' => 'Edit', 'onclick' => "edit('$id');return false;", ), 'delete' => array( 'href' => $delete_link, 'id' => "delete-button-$id", 'title' => 'Delete', 'anchor' => 'Delete', 'onclick' => "remove('$id');return false;", ) ); $actions = yourls_apply_filter( 'table_add_row_action_array', $actions ); $action_links = ''; foreach( $actions as $key => $action ) { $onclick = isset( $action['onclick'] ) ? 'onclick="' . $action['onclick'] . '"' : '' ; $action_links .= sprintf( '%s', $action['href'], $action['id'], $action['title'], 'button button_'.$key, $onclick, $action['anchor'] ); } $action_links = yourls_apply_filter( 'action_links', $action_links, $keyword, $url, $ip, $clicks, $timestamp ); $row = <<$display_keyword$display_link$date$ip$clicks$action_links ROW; $row = yourls_apply_filter( 'table_add_row', $row, $keyword, $url, $title, $ip, $clicks, $timestamp ); return $row; } // Echo the main table head function yourls_table_head() { $start = ''."\n"; echo yourls_apply_filter( 'table_head_start', $start ); $cells = yourls_apply_filter( 'table_head_cells', array( 'shorturl' => 'Short URL ', 'longurl' => 'Original URL', 'date' => 'Date', 'ip' => 'IP', 'clicks' => 'Clicks  ', 'actions' => 'Actions' ) ); foreach( $cells as $k => $v ) { echo "\n"; } $end = "\n"; echo yourls_apply_filter( 'table_head_end', $end ); } // Echo the tbody start tag function yourls_table_tbody_start() { echo yourls_apply_filter( 'table_tbody_start', '' ); } // Echo the tbody end tag function yourls_table_tbody_end() { echo yourls_apply_filter( 'table_tbody_end', '' ); } // Echo the table start tag function yourls_table_end() { echo yourls_apply_filter( 'table_end', '
$v
' ); } // Echo HTML tag for a link function yourls_html_link( $href, $title = '', $element = '' ) { if( !$title ) $title = $href; if( $element ) $element = "id='$element'"; echo yourls_apply_filter( 'html_link', "$title" ); } // Display the login screen. Nothing past this point. function yourls_login_screen( $error_msg = '' ) { yourls_html_head( 'login' ); $action = ( isset($_GET['action']) && $_GET['action'] == 'logout' ? '?' : '' ); yourls_html_logo(); ?>
'.$error_msg.'

'; } ?>



' . YOURLS_USER . ' (Logout)' ); } else { $logout_link = yourls_apply_filter( 'logout_link', '' ); } $help_link = yourls_apply_filter( 'help_link', 'Help' ); $admin_links = array(); $admin_sublinks = array(); $admin_links['admin'] = array( 'url' => yourls_admin_url('index.php'), 'title' => 'Go to the admin interface', 'anchor' => 'Admin interface' ); if( yourls_is_admin() ) { $admin_links['tools'] = array( 'url' => yourls_admin_url('tools.php'), 'anchor' => 'Tools', ); $admin_links['plugins'] = array( 'url' => yourls_admin_url('plugins.php'), 'anchor' => 'Manage Plugins', ); $admin_sublinks['plugins'] = yourls_list_plugin_admin_pages(); } $admin_links = yourls_apply_filter( 'admin_links', $admin_links ); $admin_sublinks = yourls_apply_filter( 'admin_sublinks', $admin_sublinks ); // Now output menu echo '\n"; yourls_do_action( 'admin_notices' ); yourls_do_action( 'admin_notice' ); // because I never remember if it's 'notices' or 'notice' /* To display a notice: $message = "
OMG, dude, I mean!
" ); yourls_add_action( 'admin_notices', create_function( '', "echo '$message';" ) ); */ } // Wrapper to admin notices function yourls_add_notice( $message ) { $message = yourls_notice_box( $message ); yourls_add_action( 'admin_notices', create_function( '', "echo '$message';" ) ); } // Return a formatted notice function yourls_notice_box( $message ) { return <<

$message

HTML; } // Display a page function yourls_page( $page ) { $include = YOURLS_ABSPATH . "/pages/$page.php"; if( !file_exists($include) ) { yourls_die( "Page '$page' not found", 'Not found', 404 ); } yourls_do_action( 'pre_page', $page ); include($include); yourls_do_action( 'post_page', $page ); die(); }