3 // Display <h1> header and logo
\r
4 function yourls_html_logo() {
\r
7 <a href="<?php echo yourls_admin_url('index.php') ?>" title="YOURLS"><span>YOURLS</span>: <span>Y</span>our <span>O</span>wn <span>URL</span> <span>S</span>hortener<br/>
\r
8 <img src="<?php echo YOURLS_SITE; ?>/images/yourls-logo.png" alt="YOURLS" title="YOURLS" border="0" style="border: 0px;" /></a>
\r
13 // Display HTML head and <body> tag
\r
14 function yourls_html_head( $context = 'index' ) {
\r
15 // All components to false, except when specified true
\r
16 $share = $insert = $tablesorter = $tabs = false;
\r
17 // Load components as needed
\r
18 switch ( $context ) {
\r
20 $share = $tabs = true;
\r
24 $share = $insert = $tablesorter = true;
\r
28 $insert = $tablesorter = true;
\r
40 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
41 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
\r
43 <title>YOURLS » Your Own URL Shortener | <?php echo YOURLS_SITE; ?></title>
\r
44 <link rel="icon" type="image/gif" href="<?php echo YOURLS_SITE; ?>/images/favicon.gif" />
\r
45 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
46 <meta http-equiv="X-UA-Compatible" content="chrome=1" />
\r
47 <meta name="copyright" content="Copyright © 2008-<?php echo date('Y'); ?> YOURS" />
\r
48 <meta name="author" content="Ozh Richard, Lester Chan" />
\r
49 <meta name="description" content="Insert URL « YOURLS » Your Own URL Shortener' | <?php echo YOURLS_SITE; ?>" />
\r
50 <script src="<?php echo YOURLS_SITE; ?>/js/jquery-1.3.2.min.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
\r
51 <link rel="stylesheet" href="<?php echo YOURLS_SITE; ?>/css/style.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" />
\r
52 <?php if ($tabs) { ?>
\r
53 <link rel="stylesheet" href="<?php echo YOURLS_SITE; ?>/css/infos.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" />
\r
54 <script src="<?php echo YOURLS_SITE; ?>/js/infos.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
\r
56 <?php if ($tablesorter) { ?>
\r
57 <link rel="stylesheet" href="<?php echo YOURLS_SITE; ?>/css/tablesorter.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" />
\r
58 <script src="<?php echo YOURLS_SITE; ?>/js/jquery.tablesorter.min.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
\r
60 <?php if ($insert) { ?>
\r
61 <script src="<?php echo YOURLS_SITE; ?>/js/insert.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
\r
63 <?php if ($share) { ?>
\r
64 <link rel="stylesheet" href="<?php echo YOURLS_SITE; ?>/css/share.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" />
\r
65 <script src="<?php echo YOURLS_SITE; ?>/js/share.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
\r
68 <body class="<?php echo $context; ?>">
\r
73 // Display HTML footer (including closing body & html tags)
\r
74 function yourls_html_footer() {
\r
77 $num_queries = $ydb->num_queries > 1 ? $ydb->num_queries.' queries' : $ydb->num_queries.' query';
\r
79 </div> <?php // wrap ?>
\r
80 <div id="footer"><p>Powered by <a href="http://yourls.org/" title="YOURLS">YOURLS</a> v<?php echo YOURLS_VERSION; echo ' – '.$num_queries; ?></p></div>
\r
81 <?php if( defined('YOURLS_DEBUG') && YOURLS_DEBUG == true ) {
\r
82 echo '<p>'. $ydb->all_queries .'<p>';
\r
89 // Display "Add new URL" box
\r
90 function yourls_html_addnew( $url = '', $keyword = '' ) {
\r
91 $url = $url ? $url : 'http://';
\r
95 <form id="new_url_form" action="" method="get">
\r
96 <div><strong>Enter the URL</strong>:<input type="text" id="add-url" name="url" value="<?php echo $url; ?>" class="text" size="80" />
\r
97 Optional: <strong>Custom short URL</strong>:<input type="text" id="add-keyword" name="keyword" value="<?php echo $keyword; ?>" class="text" size="8" />
\r
98 <input type="button" id="add-button" name="add-button" value="Shorten The URL" class="button" onclick="add();" /></div>
\r
100 <div id="feedback" style="display:none"></div>
\r
106 // Display main table's footer
\r
107 function yourls_html_tfooter( $params = array() ) {
\r
108 extract( $params ); // extract $search_text, $page, $search_in_sql ...
\r
113 <th colspan="4" style="text-align: left;">
\r
114 <form action="" method="get">
\r
116 <div style="float:right;">
\r
117 <input type="submit" id="submit-sort" value="Filter" class="button primary" />
\r
119 <input type="button" id="submit-clear-filter" value="Clear Filter" class="button" onclick="window.parent.location.href = 'index.php'" />
\r
122 Search for
\r
123 <input type="text" name="s_search" class="text" size="20" value="<?php echo $search_text; ?>" />
\r
125 <select name="s_in" size="1">
\r
126 <!-- <option value="id"<?php if($search_in_sql == 'id') { echo ' selected="selected"'; } ?>>ID</option> -->
\r
127 <option value="url"<?php if($search_in_sql == 'url') { echo ' selected="selected"'; } ?>>URL</option>
\r
128 <option value="ip"<?php if($search_in_sql == 'ip') { echo ' selected="selected"'; } ?>>IP</option>
\r
130 – Order by
\r
131 <select name="s_by" size="1">
\r
132 <option value="id"<?php if($sort_by_sql == 'id') { echo ' selected="selected"'; } ?>>ID</option>
\r
133 <option value="url"<?php if($sort_by_sql == 'url') { echo ' selected="selected"'; } ?>>URL</option>
\r
134 <option value="timestamp"<?php if($sort_by_sql == 'timestamp') { echo ' selected="selected"'; } ?>>Date</option>
\r
135 <option value="ip"<?php if($sort_by_sql == 'ip') { echo ' selected="selected"'; } ?>>IP</option>
\r
136 <option value="clicks"<?php if($sort_by_sql == 'clicks') { echo ' selected="selected"'; } ?>>Clicks</option>
\r
138 <select name="s_order" size="1">
\r
139 <option value="asc"<?php if($sort_order_sql == 'asc') { echo ' selected="selected"'; } ?>>Ascending</option>
\r
140 <option value="desc"<?php if($sort_order_sql == 'desc') { echo ' selected="selected"'; } ?>>Descending</option>
\r
142 – Show
\r
143 <input type="text" name="perpage" class="text" size="2" value="<?php echo $perpage; ?>" /> rows<br/>
\r
146 <select name="link_filter" size="1">
\r
147 <option value="more"<?php if($link_filter === 'more') { echo ' selected="selected"'; } ?>>more</option>
\r
148 <option value="less"<?php if($link_filter === 'less') { echo ' selected="selected"'; } ?>>less</option>
\r
151 <input type="text" name="link_limit" class="text" size="4" value="<?php echo $link_limit; ?>" />clicks
\r
157 <th colspan="3" style="text-align: right;">
\r
158 Pages (<?php echo $total_pages; ?>):
\r
161 echo '<b><a href="'.$base_page.'?s_by='.$sort_by_sql.'&s_order='.$sort_order_sql.$search_url.'&perpage='.$perpage.'&page=1'.'" title="Go to First Page">« First</a></b> ... ';
\r
164 echo ' <b><a href="'.$base_page.'?s_by='.$sort_by_sql.'&s_order='.$sort_order_sql.$search_url.'&perpage='.$perpage.'&page='.($page-1).'" title="« Go to Page '.($page-1).'">«</a></b> ';
\r
166 for($i = $page - 2 ; $i <= $page +2; $i++) {
\r
167 if ($i >= 1 && $i <= $total_pages) {
\r
169 echo "<strong>[$i]</strong> ";
\r
171 echo '<a href="'.$base_page.'?s_by='.$sort_by_sql.'&s_order='.$sort_order_sql.$search_url.'&perpage='.$perpage.'&page='.($i).'" title="Page '.$i.'">'.$i.'</a> ';
\r
175 if($page < $total_pages) {
\r
176 echo ' <b><a href="'.$base_page.'?s_by='.$sort_by_sql.'&s_order='.$sort_order_sql.$search_url.'&perpage='.$perpage.'&page='.($page+1).'" title="Go to Page '.($page+1).' »">»</a></b> ';
\r
178 if (($page+2) < $total_pages) {
\r
179 echo ' ... <b><a href="'.$base_page.'?s_by='.$sort_by_sql.'&s_order='.$sort_order_sql.$search_url.'&perpage='.$perpage.'&page='.($total_pages).'" title="Go to Last Page">Last »</a></b>';
\r
188 // Display the Quick Share box of the tools.php page
\r
189 function yourls_share_box( $longurl, $shorturl, $title='', $text='', $shortlink_title = '<h2>Your short link</h2>', $share_title = '<h2>Quick Share</h2>' ) {
\r
190 $text = ( $text ? '"'.$text.'" ' : '' );
\r
191 $title = ( $title ? "$title " : '' );
\r
192 $share = htmlspecialchars_decode( $title.$text.$shorturl );
\r
193 $_share = rawurlencode( $share );
\r
194 $_url = rawurlencode( $shorturl );
\r
195 $count = 140 - strlen( $share );
\r
198 <div id="shareboxes">
\r
200 <div id="copybox" class="share">
\r
201 <?php echo $shortlink_title; ?>
\r
202 <p><input id="copylink" class="text" size="40" value="<?php echo $shorturl; ?>" /></p>
\r
203 <p><small>Original link: <a href="<?php echo $longurl; ?>"><?php echo $longurl; ?></a></small></p>
\r
206 <div id="sharebox" class="share">
\r
207 <?php echo $share_title; ?>
\r
209 <span id="charcount"><?php echo $count; ?></span>
\r
210 <textarea id="tweet_body"><?php echo $share; ?></textarea>
\r
212 <p id="share_links">Share with
\r
213 <a id="share_tw" href="http://twitter.com/home?status=<?php echo $_share; ?>" title="Tweet this!" onclick="share('tw');return false">Twitter</a>
\r
214 <a id="share_fb" href="http://www.facebook.com/share.php?u=<?php echo $_url; ?>" title="Share on Facebook" onclick="share('fb');return false;">Facebook</a>
\r
215 <a id="share_ff" href="http://friendfeed.com/share/bookmarklet/frame#title=<?php echo $_share; ?>" title="Share on Friendfeed" onclick="javascript:share('ff');return false;">FriendFeed</a>
\r
226 function yourls_die( $message = '', $title = '', $header_code = 200 ) {
\r
227 yourls_status_header( $header_code );
\r
229 yourls_html_head();
\r
230 yourls_html_logo();
\r
231 echo "<h2>$title</h2>";
\r
232 echo "<p>$message</p>";
\r
233 yourls_html_footer();
\r
237 // Echo HTML tag for a link
\r
238 function yourls_html_link( $href, $title = '', $element = '' ) {
\r
242 $element = "id='$element'";
\r
243 echo "<a href='$href' $element>$title</a>";
\r
246 // Display the login screen. Nothing past this point.
\r
247 function yourls_login_screen( $error_msg = '' ) {
\r
248 yourls_html_head( 'login' );
\r
250 $action = ( isset($_GET['mode']) && $_GET['mode'] == 'logout' ? '?' : '' );
\r
252 yourls_html_logo();
\r
255 <form method="post" action="<?php echo $action; ?>"> <?php // reset any QUERY parameters ?>
\r
257 if(!empty($error_msg)) {
\r
258 echo '<p class="error">'.$error_msg.'</p>';
\r
262 <label for="username">Username</label><br />
\r
263 <input type="text" id="username" name="username" size="30" class="text" />
\r
266 <label for="password">Password</label><br />
\r
267 <input type="password" id="password" name="password" size="30" class="text" />
\r
269 <p style="text-align: right;">
\r
270 <input type="submit" id="submit" name="submit" value="Login" class="button" />
\r
273 <script type="text/javascript">$('#username').focus();</script>
\r
276 yourls_html_footer();
\r
280 // Display the admin menu
\r
281 function yourls_html_menu() {
\r
283 <ul id="admin_menu">
\r
284 <?php if ( yourls_is_private() ) { ?>
\r
285 <li>Hello <strong><?php echo YOURLS_USER; ?></strong> (<a href="?mode=logout" title="Logout">Logout</a>)</li>
\r
287 <li>Go to the <a href="<?php echo yourls_admin_url('index.php') ?>">Admin Interface</a></li>
\r
288 <li>Check the <a href="<?php echo yourls_admin_url('tools.php'); ?>">Tools</a></li>
\r
289 <li>Read the <a href="<?php echo YOURLS_SITE; ?>/readme.html">Help</a></li>
\r