// Begin output of the page $context = $is_bookmark ? 'bookmark' : 'index'; yourls_html_head($context); yourls_html_logo(); yourls_html_menu(); yourls_do_action('admin_page_before_content'); if (!$is_bookmark) { ?> <p><?php echo $search_sentence; ?> </p> <p><?php printf(yourls__('Display <strong>%1$s</strong> to <strong class="increment">%2$s</strong> of <strong class="increment">%3$s</strong> URLs'), $display_on_page, $max_on_page, $total_items); if ($total_items_clicks !== false) { echo ", " . sprintf(yourls_n('counting <strong>1</strong> click', 'counting <strong>%s</strong> clicks', $total_items_clicks), yourls_number_format_i18n($total_items_clicks)); } ?> .</p> <?php } ?> <p id="overall_tracking"><?php printf(yourls__('Overall, tracking <strong class="increment">%1$s</strong> links, <strong>%2$s</strong> clicks, and counting!'), yourls_number_format_i18n($total_urls), yourls_number_format_i18n($total_clicks)); ?> </p> <?php yourls_do_action('admin_page_before_form'); yourls_html_addnew(); // If bookmarklet, add message. Otherwise, hide hidden share box. if (!$is_bookmark) {
<td valign="top"> <h3><?php yourls_e('Direct vs Referrer Traffic'); ?> </h3> <?php yourls_stats_pie(array(yourls__('Direct') => $direct, yourls__('Referrers') => $notdirect), 5, '440x220', 'stat_tab_source_direct'); ?> <p><?php yourls_e('Direct traffic:'); echo ' ' . sprintf(yourls_n('<strong>%s</strong> hit', '<strong>%s</strong> hits', $direct), $direct); ?> </p> <p><?php yourls_e('Referrer traffic:'); echo ' ' . sprintf(yourls_n('<strong>%s</strong> hit', '<strong>%s</strong> hits', $notdirect), $notdirect); ?> </p> </td> </tr> </table> <?php yourls_do_action('post_yourls_info_sources', $keyword); ?> <?php } else { echo '<p>' . yourls__('No referrer data.') . '</p>'; }
function yourls_load_plugins() { global $ydb; $ydb->plugins = array(); $active_plugins = yourls_get_option('active_plugins'); // Don't load plugins when installing or updating if (!$active_plugins or yourls_is_installing() or yourls_upgrade_is_needed()) { return; } foreach ((array) $active_plugins as $key => $plugin) { if (yourls_validate_plugin_file(YOURLS_PLUGINDIR . '/' . $plugin)) { include_once YOURLS_PLUGINDIR . '/' . $plugin; $ydb->plugins[] = $plugin; unset($active_plugins[$key]); } } // $active_plugins should be empty now, if not, a plugin could not be find: remove it if (count($active_plugins)) { yourls_update_option('active_plugins', $ydb->plugins); $message = yourls_n('Could not find and deactivated plugin :', 'Could not find and deactivated plugins :', count($active_plugins)); $missing = '<strong>' . join('</strong>, <strong>', $active_plugins) . '</strong>'; yourls_add_notice($message . ' ' . $missing); } }
/** * Display main table's footer * * The $param array is defined in /admin/index.php, check the yourls_html_tfooter() call * * @param array $params Array of all required parameters * @return string Result */ function yourls_html_tfooter($params = array()) { extract($params); // extract $search_text, $page, $search_in ... ?> <tfoot> <tr> <th colspan="6"> <div id="filter_form"> <form action="" method="get"> <div id="filter_options"> <?php // First search control: text to search $_input = '<input type="text" name="search" class="text" size="12" value="' . yourls_esc_attr($search_text) . '" />'; $_options = array('all' => yourls__('All fields'), 'keyword' => yourls__('Short URL'), 'url' => yourls__('URL'), 'title' => yourls__('Title'), 'ip' => yourls__('IP')); $_select = yourls_html_select('search_in', $_options, $search_in); /* //translators: "Search for <input field with text to search> in <select dropdown with URL, title...>" */ yourls_se('Search for %1$s in %2$s', $_input, $_select); echo "–\n"; // Second search control: order by $_options = array('keyword' => yourls__('Short URL'), 'url' => yourls__('URL'), 'timestamp' => yourls__('Date'), 'ip' => yourls__('IP'), 'clicks' => yourls__('Clicks')); $_select = yourls_html_select('sort_by', $_options, $sort_by); $sort_order = isset($sort_order) ? $sort_order : 'desc'; $_options = array('asc' => yourls__('Ascending'), 'desc' => yourls__('Descending')); $_select2 = yourls_html_select('sort_order', $_options, $sort_order); /* //translators: "Order by <criteria dropdown (date, clicks...)> in <order dropdown (Descending or Ascending)>" */ yourls_se('Order by %1$s %2$s', $_select, $_select2); echo "–\n"; // Third search control: Show XX rows /* //translators: "Show <text field> rows" */ yourls_se('Show %s rows', '<input type="text" name="perpage" class="text" size="2" value="' . $perpage . '" />'); echo "<br/>\n"; // Fourth search control: Show links with more than XX clicks $_options = array('more' => yourls__('more'), 'less' => yourls__('less')); $_select = yourls_html_select('click_filter', $_options, $click_filter); $_input = '<input type="text" name="click_limit" class="text" size="4" value="' . $click_limit . '" /> '; /* //translators: "Show links with <more/less> than <text field> clicks" */ yourls_se('Show links with %1$s than %2$s clicks', $_select, $_input); echo "<br/>\n"; // Fifth search control: Show links created before/after/between ... $_options = array('before' => yourls__('before'), 'after' => yourls__('after'), 'between' => yourls__('between')); $_select = yourls_html_select('date_filter', $_options, $date_filter); $_input = '<input type="text" name="date_first" id="date_first" class="text" size="12" value="' . $date_first . '" />'; $_and = '<span id="date_and"' . ($date_filter === 'between' ? ' style="display:inline"' : '') . '> & </span>'; $_input2 = '<input type="text" name="date_second" id="date_second" class="text" size="12" value="' . $date_second . '"' . ($date_filter === 'between' ? ' style="display:inline"' : '') . '/>'; /* //translators: "Show links created <before/after/between> <date input> <"and" if applicable> <date input if applicable>" */ yourls_se('Show links created %1$s %2$s %3$s %4$s', $_select, $_input, $_and, $_input2); ?> <div id="filter_buttons"> <input type="submit" id="submit-sort" value="<?php yourls_e('Search'); ?> " class="button primary" /> <input type="button" id="submit-clear-filter" value="<?php yourls_e('Clear'); ?> " class="button" onclick="window.parent.location.href = 'index.php'" /> </div> </div> </form> </div> <?php // Remove empty keys from the $params array so it doesn't clutter the pagination links $params = array_filter($params, 'yourls_return_if_not_empty_string'); // remove empty keys if (isset($search_text)) { $params['search'] = $search_text; unset($params['search_text']); } ?> <div id="pagination"> <span class="navigation"> <?php if ($total_pages > 1) { ?> <span class="nav_total"><?php echo sprintf(yourls_n('1 page', '%s pages', $total_pages), $total_pages); ?> </span> <?php $base_page = yourls_admin_url('index.php'); // Pagination offsets: min( max ( zomg! ) ); $p_start = max(min($total_pages - 4, $page - 2), 1); $p_end = min(max(5, $page + 2), $total_pages); if ($p_start >= 2) { $link = yourls_add_query_arg(array_merge($params, array('page' => 1)), $base_page); echo '<span class="nav_link nav_first"><a href="' . $link . '" title="' . yourls_esc_attr__('Go to First Page') . '">' . yourls__('« First') . '</a></span>'; echo '<span class="nav_link nav_prev"></span>'; } for ($i = $p_start; $i <= $p_end; $i++) { if ($i == $page) { echo "<span class='nav_link nav_current'>{$i}</span>"; } else { $link = yourls_add_query_arg(array_merge($params, array('page' => $i)), $base_page); echo '<span class="nav_link nav_goto"><a href="' . $link . '" title="' . sprintf(yourls_esc_attr('Page %s'), $i) . '">' . $i . '</a></span>'; } } if ($p_end < $total_pages) { $link = yourls_add_query_arg(array_merge($params, array('page' => $total_pages)), $base_page); echo '<span class="nav_link nav_next"></span>'; echo '<span class="nav_link nav_last"><a href="' . $link . '" title="' . yourls_esc_attr__('Go to Last Page') . '">' . yourls__('Last »') . '</a></span>'; } ?> <?php } ?> </span> </div> </th> </tr> <?php yourls_do_action('html_tfooter'); ?> </tfoot> <?php }
/** * Translate the result of yourls_n_noop() or yourls_nx_noop() * * @since 1.6 * @param array $nooped_plural Array with singular, plural and context keys, usually the result of yourls_n_noop() or yourls_nx_noop() * @param int $count Number of objects * @param string $domain Optional. The domain identifier the text should be retrieved in. If $nooped_plural contains * a domain passed to yourls_n_noop() or yourls_nx_noop(), it will override this value. * @return string */ function yourls_translate_nooped_plural($nooped_plural, $count, $domain = 'default') { if ($nooped_plural['domain']) { $domain = $nooped_plural['domain']; } if ($nooped_plural['context']) { return yourls_nx($nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain); } else { return yourls_n($nooped_plural['singular'], $nooped_plural['plural'], $count, $domain); } }
function ozh_toolbar_do($args) { global $ozh_toolbar; // Does this redirection need a toolbar? if (!$ozh_toolbar['do']) { return; } // Do we have a cookie stating the user doesn't want a toolbar? if (isset($_COOKIE['yourls_no_toolbar']) && $_COOKIE['yourls_no_toolbar'] == 1) { return; } // Get URL and page title $url = $args[0]; $pagetitle = yourls_get_keyword_title($ozh_toolbar['keyword']); // Update title if it hasn't been stored yet if ($pagetitle == '') { $pagetitle = yourls_get_remote_title($url); yourls_edit_link_title($ozh_toolbar['keyword'], $pagetitle); } $_pagetitle = htmlentities(yourls_get_remote_title($url)); $www = YOURLS_SITE; $ver = YOURLS_VERSION; $md5 = md5($url); $sql = yourls_get_num_queries(); // When was the link created (in days) $diff = abs(time() - strtotime(yourls_get_keyword_timestamp($ozh_toolbar['keyword']))); $days = floor($diff / (60 * 60 * 24)); if ($days == 0) { $created = 'today'; } else { $created = $days . ' ' . yourls_n('day', 'days', $days) . ' ago'; } // How many hits on the page $hits = 1 + yourls_get_keyword_clicks($ozh_toolbar['keyword']); $hits = $hits . ' ' . yourls_n('view', 'views', $hits); // Plugin URL (no URL is hardcoded) $pluginurl = YOURLS_PLUGINURL . '/' . yourls_plugin_basename(dirname(__FILE__)); // All set. Draw the toolbar itself. echo <<<PAGE <html> <head> \t<title>{$pagetitle} — YOURLS</title> \t<link rel="icon" type="image/gif" href="{$www}/images/favicon.gif" /> \t<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \t<meta http-equiv="X-UA-Compatible" content="IE-9"/> \t<meta name="generator" content="YOURLS v{$ver}" /> \t<meta name="ROBOTS" content="NOINDEX, FOLLOW" /> \t<link rel="stylesheet" href="{$pluginurl}/css/toolbar.css" type="text/css" media="all" /> </head> <body> <div id="yourls-bar"> \t<div id="yourls-about"> \t\tShort link powered by <a href="http://yourls.org/">YOURLS</a> and created {$created}. {$hits}. \t\t<!-- {$sql} queries --> \t</div> \t \t<div id="yourls-delicious"> \t<img src="http://static.delicious.com/img/delicious.small.gif" height="10" width="10" alt="Delicious" /> \t<a id="yourls-delicious-link" title="Bookmark on delicious" href="http://delicious.com/save" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;"> Bookmark on Delicious</a> \t</div> \t<script type="text/javascript" id="topsy_global_settings"> \tvar topsy_theme = "light-blue"; \tvar topsy_nick = " "; \tvar topsy_style = "small"; \tvar topsy_order = "count,retweet,badge"; \t</script> \t<div id="yourls-topsy" class="topsy_widget_data"> \t\t<!--{ \t\t "url": "{$www}/{$ozh_toolbar['keyword']}", \t\t "title": "{$_pagetitle}", \t\t}--> \t</div> \t \t<div id="yourls-selfclose"> \t\t<a id="yourls-once" href="{$url}" title="Close this toolbar">close</a> \t\t<a id="yourls-always" href="{$url}" title="Never show me this toolbar again">close</a> \t\t \t</div> </div> <iframe id="yourls-frame" frameborder="0" noresize="noresize" src="{$url}" name="yourlsFrame"></iframe> <script type="text/javascript" src="{$pluginurl}/js/toolbar.js"></script> <script type="text/javascript" src="http://cdn.topsy.com/topsy.js?init=topsyWidgetCreator"></script> <script type="text/javascript" src="http://feeds.delicious.com/v2/json/urlinfo/{$md5}?callback=yourls_get_books"></script> </body> </html> PAGE; // Don't forget to die, to interrupt the flow of normal events (ie redirecting to long URL) die; }
} yourls_html_head('plugins', yourls__('Manage Plugins')); yourls_html_logo(); yourls_html_menu(); ?> <h2><?php yourls_e('Plugins'); ?> </h2> <?php $plugins = (array) yourls_get_plugins(); uasort($plugins, 'yourls_plugins_sort_callback'); $count = count($plugins); $plugins_count = sprintf(yourls_n('%s plugin', '%s plugins', $count), $count); $count_active = yourls_has_active_plugins(); ?> <p id="plugin_summary"><?php /* //translators: "you have '3 plugins' installed and '1' activated" */ yourls_se('You currently have <strong>%1$s</strong> installed, and <strong>%2$s</strong> activated', $plugins_count, $count_active); ?> </p> <table id="main_table" class="tblSorter" cellpadding="0" cellspacing="1"> <thead> <tr> <th><?php yourls_e('Plugin Name'); ?>