/** * Display list of links to plugin admin pages, if any */ function yourls_list_plugin_admin_pages() { global $ydb; if (!property_exists($ydb, 'plugin_pages') || !$ydb->plugin_pages) { return; } echo '<ul id="admin_pluginmenu">' . "\n"; foreach ((array) $ydb->plugin_pages as $page) { echo '<li><a href="' . yourls_admin_url('plugins.php?page=' . $page['slug']) . '">' . $page['title'] . "</a></li>\n"; } echo "</ul>\n"; }
if (preg_match("@^([{$pattern}]+)/?\$@", $request, $matches)) { $keyword = isset($matches[1]) ? $matches[1] : ''; $keyword = yourls_sanitize_keyword($keyword); yourls_do_action('load_template_go', $keyword); require_once YOURLS_ABSPATH . '/yourls-go.php'; exit; } // Stats: if (preg_match("@^([{$pattern}]+)\\+(all)?/?\$@", $request, $matches)) { $keyword = isset($matches[1]) ? $matches[1] : ''; $keyword = yourls_sanitize_keyword($keyword); $aggregate = isset($matches[2]) ? (bool) $matches[2] && yourls_allow_duplicate_longurls() : false; yourls_do_action('load_template_infos', $keyword); require_once YOURLS_ABSPATH . '/yourls-infos.php'; exit; } // Prefix-n-Shorten sends to bookmarklet (doesn't work on Windows) if (preg_match("@^[a-zA-Z]+://.+@", $request, $matches)) { $url = yourls_sanitize_url($matches[0]); if ($parse = yourls_get_protocol_slashes_and_rest($url, array('up', 'us', 'ur'))) { yourls_do_action('load_template_redirect_admin', $url); $parse = array_map('rawurlencode', $parse); // Redirect to /admin/index.php?up=<url protocol>&us=<url slashes>&ur=<url rest> yourls_redirect(yourls_add_query_arg($parse, yourls_admin_url('index.php')), 302); exit; } } // Past this point this is a request the loader could not understand yourls_do_action('loader_failed', $request); yourls_redirect(YOURLS_SITE, 302); exit;
?> </li> </ul> <p><?php yourls_e("If you want to share a description along with the link you're shortening, simply <span>select text</span> on the page you're viewing before clicking on your bookmarklet link"); ?> </p> <h3><?php yourls_e('The Bookmarklets'); ?> </h3> <?php $base_bookmarklet = yourls_admin_url('index.php'); ?> <p><?php yourls_e('Click and drag links to your toolbar (or right-click and bookmark it)'); ?> </p> <table class="tblSorter" cellpadding="0" cellspacing="1"> <thead> <tr> <td> </td> <th><?php yourls_e('Standard (new page)'); ?> </th>
/** * Yourls filter table_add_row_action_array * * @param $data * @return array */ public function filter_table_add_row_action_array() { global $url_result; list($actions) = func_get_args(); if (!isset($url_result)) { return array(); } if (!$this->_hasPermission(self::PERMISSION_ACTION_EDIT_OTHER)) { if (!$this->_hasPermission(self::PERMISSION_ACTION_EDIT, $url_result->{self::SETTING_URL_PROJECTS})) { if ($url_result->{self::SETTING_URL_USER_CREATE} && YOURLS_USER !== $url_result->{self::SETTING_URL_USER_CREATE}) { unset($actions['edit']); } } } if (!$this->_hasPermission(self::PERMISSION_ACTION_DELETE_OTHER)) { if (!$this->_hasPermission(self::PERMISSION_ACTION_DELETE, $url_result->{self::SETTING_URL_PROJECTS})) { if ($url_result->{self::SETTING_URL_USER_CREATE} && YOURLS_USER !== $url_result->{self::SETTING_URL_USER_CREATE}) { unset($actions['delete']); } } } if (!$this->_hasPermission(self::PERMISSION_ACTION_EDIT_PROJECT)) { return $actions; } if (!$this->_hasPermission(self::PERMISSION_ACTION_EDIT_OTHER)) { if (!$this->_hasPermission(self::PERMISSION_ACTION_EDIT_PROJECT, $url_result->{self::SETTING_URL_PROJECTS})) { if ($url_result->{self::SETTING_URL_USER_CREATE} && YOURLS_USER !== $url_result->{self::SETTING_URL_USER_CREATE}) { return $actions; } } } $id = yourls_string2htmlid($this->_keyword); $href = yourls_nonce_url('laemmi_edit_ldapgroup_' . $id, yourls_add_query_arg(['action' => 'laemmi_edit_ldapgroup', 'keyword' => $this->_keyword], yourls_admin_url('admin-ajax.php'))); $actions['laemmi_edit_ldapgroup'] = ['href' => $href, 'id' => '', 'title' => yourls__('Edit Projects', self::APP_NAMESPACE), 'anchor' => 'edit_ldapgroup', 'onclick' => '']; return $actions; }
/** * Display list of links to plugin admin pages, if any */ function yourls_list_plugin_admin_pages() { global $ydb; if (!property_exists($ydb, 'plugin_pages') || !$ydb->plugin_pages) { return; } $plugin_links = array(); foreach ((array) $ydb->plugin_pages as $plugin => $page) { $plugin_links[$plugin] = array('url' => yourls_admin_url('plugins.php?page=' . $page['slug']), 'anchor' => $page['title']); } return $plugin_links; }
?> <p> <img src="<?php yourls_site_url(); ?> /images/yourls-logo.png" alt="YOURLS" title="YOURLS" /> </p> <?php // Print errors, warnings and success messages foreach (array('error', 'warning', 'success') as $info) { if (count(${$info}) > 0) { echo "<ul class='{$info}'>"; foreach (${$info} as $msg) { echo '<li>' . $msg . "</li>\n"; } echo '</ul>'; } } // Display install button or link to admin area if applicable if (!yourls_is_installed() && !isset($_REQUEST['install'])) { echo '<p style="text-align: center;"><input type="submit" name="install" value="' . yourls__('Install YOURLS') . '" class="button" /></p>'; } else { if (count($error) == 0) { echo '<p style="text-align: center;">» <a href="' . yourls_admin_url() . '" title="' . yourls__('YOURLS Administration Page') . '">' . yourls__('YOURLS Administration Page') . '</a></p>'; } } ?> </form> </div> <?php yourls_html_footer();
yourls_db_connect(); } // Allow early inclusion of a cache layer if (file_exists(YOURLS_USERDIR . '/cache.php')) { require_once YOURLS_USERDIR . '/cache.php'; } // Read options right from start yourls_get_all_options(); // Register shutdown function register_shutdown_function('yourls_shutdown'); // Core now loaded yourls_do_action('init'); // plugins can't see this, not loaded yet // Check if need to redirect to install procedure if (!yourls_is_installed() && !yourls_is_installing()) { yourls_redirect(yourls_admin_url('install.php'), 302); } // Check if upgrade is needed (bypassed if upgrading or installing) if (!yourls_is_upgrading() && !yourls_is_installing()) { if (yourls_upgrade_is_needed()) { yourls_redirect(YOURLS_SITE . '/admin/upgrade.php', 302); } } // Init all plugins yourls_load_plugins(); yourls_do_action('plugins_loaded'); // Is there a new version of YOURLS ? yourls_new_core_version_notice(); if (yourls_is_admin()) { yourls_do_action('admin_init'); }
function authmgr_require_capability($capability) { if (!authmgr_have_capability($capability)) { // TODO: display a much nicer error page //die('Sorry, you are not authorized for the action: '.$capability); yourls_redirect(yourls_admin_url('?access=denied'), 302); die; } }
</p> <p><?php yourls_e("On every step, if <span class='error'>something goes wrong</span>, you'll see a message and hopefully a way to fix."); ?> </p> <p><?php yourls_e('If everything goes too fast and you cannot read, <span class="success">good for you</span>, let it go :)'); ?> </p> <p><?php yourls_e('Once you are ready, press "Upgrade" !'); ?> </p> <?php echo "\n\t\t\t<form action='upgrade.php?' method='get'>\n\t\t\t<input type='hidden' name='step' value='1' />\n\t\t\t<input type='hidden' name='oldver' value='{$oldver}' />\n\t\t\t<input type='hidden' name='newver' value='{$newver}' />\n\t\t\t<input type='hidden' name='oldsql' value='{$oldsql}' />\n\t\t\t<input type='hidden' name='newsql' value='{$newsql}' />\n\t\t\t<input type='submit' class='primary' value='" . yourls_esc_attr__('Upgrade') . "' />\n\t\t\t</form>"; break; case 1: case 2: $upgrade = yourls_upgrade($step, $oldver, $newver, $oldsql, $newsql); break; case 3: $upgrade = yourls_upgrade(3, $oldver, $newver, $oldsql, $newsql); echo '<p>' . yourls__('Your installation is now up to date ! ') . '</p>'; echo '<p>' . yourls_s('Go back to <a href="%s">the admin interface</a>', yourls_admin_url('index.php')) . '</p>'; } } ?> <?php yourls_html_footer();
$oldsql = yourls_sanitize_version($_GET['oldsql']); } else { list($oldver, $oldsql) = yourls_get_current_version_from_sql(); } // To what are we upgrading ? $newver = YOURLS_VERSION; $newsql = YOURLS_DB_VERSION; // Verbose & ugly details $ydb->show_errors = true; // Let's go $step = isset($_GET['step']) ? intval($_GET['step']) : 0; switch ($step) { default: case 0: echo "\n\t\t\t<p>Your current installation needs to be upgraded.</p>\n\t\t\t<p>Please, pretty please, it is recommended that\n\t\t\tyou <strong>backup</strong> your database<br/>(you should do this regularly anyway)</p>\n\t\t\t<p>Nothing awful <em>should</em> happen, but this doesn't mean it <em>won't</em> happen, right? ;)</p>\n\t\t\t<p>On every step, if <span class='error'>something goes wrong</span>, you'll see a message and hopefully a way to fix</p>\n\t\t\t<p>If everything goes too fast and you cannot read, <span class='success'>good for you</span>, let it go :)</p>\n\t\t\t<p>Once you are ready, press Upgrade!</p>\n\t\t\t<form action='upgrade.php?' method='get'>\n\t\t\t<input type='hidden' name='step' value='1' />\n\t\t\t<input type='hidden' name='oldver' value='{$oldver}' />\n\t\t\t<input type='hidden' name='newver' value='{$newver}' />\n\t\t\t<input type='hidden' name='oldsql' value='{$oldsql}' />\n\t\t\t<input type='hidden' name='newsql' value='{$newsql}' />\n\t\t\t<input type='submit' class='primary' value='Upgrade' />\n\t\t\t</form>"; break; case 1: case 2: $upgrade = yourls_upgrade($step, $oldver, $newver, $oldsql, $newsql); break; case 3: $upgrade = yourls_upgrade(3, $oldver, $newver, $oldsql, $newsql); $admin = yourls_admin_url('index.php'); echo "\n\t\t\t<p>Your installation is now up to date !</p>\n\t\t\t<p>Go back to <a href='{$admin}'>the admin interface</a></p>\n\t\t\t"; } } ?> <?php yourls_html_footer();
yourls_verify_nonce('manage_plugins', $_REQUEST['nonce']); // Check plugin file is valid if (isset($_GET['plugin']) && yourls_validate_plugin_file(YOURLS_PLUGINDIR . '/' . $_GET['plugin'] . '/plugin.php')) { global $ydb; // Activate / Deactive switch ($_GET['action']) { case 'activate': $result = yourls_activate_plugin($_GET['plugin'] . '/plugin.php'); if ($result === true) { yourls_redirect(yourls_admin_url('plugins.php?success=activated'), 302); } break; case 'deactivate': $result = yourls_deactivate_plugin($_GET['plugin'] . '/plugin.php'); if ($result === true) { yourls_redirect(yourls_admin_url('plugins.php?success=deactivated'), 302); } break; default: $result = 'Unsupported action'; break; } } else { $result = 'No plugin specified, or not a valid plugin'; } yourls_add_notice($result); } // Handle message upon succesfull (de)activation if (isset($_GET['success'])) { if ($_GET['success'] == 'activated' or $_GET['success'] == 'deactivated') { yourls_add_notice('Plugin ' . $_GET['success']);
// Now load required template and exit yourls_do_action('pre_load_template', $request); // At this point, $request is not sanitized. Sanitize in loaded template. // Redirection: if (preg_match("@^([{$pattern}]+)/?\$@", $request, $matches)) { $keyword = isset($matches[1]) ? $matches[1] : ''; $keyword = yourls_sanitize_keyword($keyword); yourls_do_action('load_template_go', $keyword); include YOURLS_ABSPATH . '/yourls-go.php'; exit; } // Stats: if (preg_match("@^([{$pattern}]+)\\+(all)?/?\$@", $request, $matches)) { $keyword = isset($matches[1]) ? $matches[1] : ''; $keyword = yourls_sanitize_keyword($keyword); $aggregate = isset($matches[2]) ? (bool) $matches[2] && yourls_allow_duplicate_longurls() : false; yourls_do_action('load_template_infos', $keyword); include YOURLS_ABSPATH . '/yourls-infos.php'; exit; } // Prefix-n-Shorten sends to bookmarklet (doesn't work on Windows) if (preg_match("@^[a-zA-Z]+://.+@", $request, $matches)) { $url = yourls_sanitize_url($matches[0]); yourls_do_action('load_template_redirect_admin', $url); yourls_redirect(yourls_admin_url('index.php') . '?u=' . rawurlencode($url), 302); exit; } // Past this point this is a request the loader could not understand yourls_do_action('loader_failed', $request); yourls_redirect(YOURLS_SITE, 302); exit;
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_string2int($keyword); // used as HTML #id $date = date('M d, Y H:i', $timestamp + YOURLS_HOURS_OFFSET * 3600); $clicks = number_format($clicks, 0, '', ''); $shorturl = YOURLS_SITE . '/' . $keyword; $statlink = $shorturl . '+'; if ($title) { $display_link = "<a href=\"{$url}\" title=\"{$title}\">{$display_title}</a><br/><small><a href=\"{$url}\" title=\"{$title_url}\">{$display_url}</a></small>"; } else { $display_link = "<a href=\"{$url}\" title=\"{$title_url}\">{$display_url}</a>"; } $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'))); $actions = <<<ACTION <a href="{$statlink}" id="statlink-{$id}" title="Stats" class="button button_stats">Stats</a><a href="" id="share-button-{$id}" name="share-button" title="Share" class="button button_share" onclick="toggle_share('{$id}');return false;">Share</a><a href="{$edit_link}" id="edit-button-{$id}" name="edit-button" title="Edit" class="button button_edit" onclick="edit('{$id}');return false;">Edit</a><a href="{$delete_link}" id="delete-button-{$id}" name="delete-button" title="Delete" class="button button_delete" onclick="remove('{$id}');return false;">Delete</a> ACTION; $actions = yourls_apply_filter('action_links', $actions, $keyword, $url, $ip, $clicks, $timestamp); $row = <<<ROW <tr id="id-{$id}"><td id="keyword-{$id}" class="keyword"><a href="{$shorturl}">{$display_keyword}</a></td><td id="url-{$id}" class="url">{$display_link}</td><td id="timestamp-{$id}" class="timestamp">{$date}</td><td id="ip-{$id}" class="ip">{$ip}</td><td id="clicks-{$id}" class="clicks">{$clicks}</td><td class="actions" id="actions-{$id}">{$actions}<input type="hidden" id="keyword_{$id}" value="{$keyword}"/></td></tr> ROW; $row = yourls_apply_filter('table_add_row', $row, $keyword, $url, $title, $ip, $clicks, $timestamp); return $row; }
/** * Display the change password page */ function vva_change_password_display_page() { // verify we have all necessary features if (!vva_change_password_verify_capabilities()) { return; } $error_message = NULL; $form_submitted = FALSE; $password_changed = FALSE; // if a form was submitted check for errors & minimum requirements if (isset($_REQUEST['submit'])) { $error_message = vva_change_password_get_form_errors(); $form_submitted = TRUE; } // if the new password meets requirements update it if ($form_submitted && empty($error_message)) { $password_changed = vva_change_password_write_file($_REQUEST['new_password']); if (!$password_changed) { return; } } // show password updated message or the form if ($password_changed) { ?> <div id="password_updated" class="success"> <p>Your password has been updated.</p> <p><a href="<?php echo yourls_admin_url('index.php'); ?> ">Continue</a></p> </div> <?php } else { vva_change_password_display_form($error_message); } }
<th class="header"><?php yourls_e('Custom Keyword'); ?> </th> <td><a href="javascript:(function()%7Bvar%20d=document,w=window,enc=encodeURIComponent,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),s2=((s.toString()=='')?s:enc(s)),f='<?php echo yourls_admin_url('index.php'); ?> ',l=d.location,k=prompt(%22Custom%20URL%22),k2=(k?'&k='+k:%22%22),p='?u='+enc(l.href)+'&t='+enc(d.title)+'&s='+s2+k2,u=f+p;if(k!=null)%7Btry%7Bthrow('ozhismygod');%7Dcatch(z)%7Ba=function()%7Bif(!w.open(u))l.href=u;%7D;if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();%7Dvoid(0)%7D%7D)()" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__('Drag to your toolbar!'); ?> ');return false;"><?php yourls_e('Custom shorten'); ?> </a></td> <td><a href="javascript:(function()%7Bvar%20d=document,k=prompt('Custom%20URL'),s=d.createElement('script');if(k!=null){window.yourls_callback=function(r)%7Bif(r.short_url)%7Bprompt(r.message,r.short_url);%7Delse%7Balert('An%20error%20occured:%20'+r.message);%7D%7D;s.src='<?php echo yourls_admin_url('index.php'); ?> ?u='+encodeURIComponent(d.location.href)+'&k='+k+'&jsonp=yourls';void(d.body.appendChild(s));%7D%7D)();" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__('Drag to your toolbar!'); ?> ');return false;"><?php yourls_e('Instant Custom Shorten'); ?> </a></td> </tr> </tbody> </table> <h2><?php yourls_e('Prefix-n-Shorten'); ?>
function yourls_html_menu() { ?> <ul id="admin_menu"> <?php if (yourls_is_private()) { ?> <li>Hello <strong><?php echo YOURLS_USER; ?> </strong> (<a href="?action=logout" title="Logout">Logout</a>)</li> <?php } ?> <li><a href="<?php echo yourls_admin_url('index.php'); ?> ">Admin Interface</a></li> <?php if (yourls_is_admin()) { ?> <li><a href="<?php echo yourls_admin_url('tools.php'); ?> ">Tools</a></li> <li><a href="<?php echo yourls_admin_url('plugins.php'); ?> ">Plugins</a></li> <?php yourls_list_plugin_admin_pages(); ?> <li><a href="<?php yourls_site_url(); ?> /readme.html">Help</a></li> <?php yourls_do_action('admin_menu'); ?> <?php } ?> </ul> <?php 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 = "<div>OMG, dude, I mean!</div>" ); yourls_add_action('admin_notices', create_function( '', "echo '$message';" ) ); */ }
<?php define('YOURLS_ADMIN', true); require_once dirname(dirname(__FILE__)) . '/includes/load-yourls.php'; yourls_maybe_require_auth(); // Variables $table_url = YOURLS_DB_TABLE_URL; $where = $search_sentence = $search_text = $url = $keyword = ''; $date_filter = $date_first = $date_second = ''; $base_page = yourls_admin_url('index.php'); // Default SQL behavior $search_in_text = yourls__('URL'); $search_in = 'all'; $sort_by_text = yourls__('Short URL'); $sort_by = 'timestamp'; $sort_order = 'desc'; $page = isset($_GET['page']) ? intval($_GET['page']) : 1; $search = yourls_get_search_text(); $perpage = isset($_GET['perpage']) && intval($_GET['perpage']) ? intval($_GET['perpage']) : yourls_apply_filter('admin_view_per_page', 15); $click_limit = isset($_GET['click_limit']) && $_GET['click_limit'] !== '' ? intval($_GET['click_limit']) : ''; if ($click_limit !== '') { $click_filter = isset($_GET['click_filter']) && $_GET['click_filter'] == 'more' ? 'more' : 'less'; $click_moreless = $click_filter == 'more' ? '>' : '<'; $where = " AND clicks {$click_moreless} {$click_limit}"; } else { $click_filter = ''; } // Searching if (!empty($search) && !empty($_GET['search_in'])) { switch ($_GET['search_in']) { case 'all':
function yourls_update_table_to_14() { global $ydb; $table = YOURLS_DB_TABLE_URL; // Modify each link to reflect new structure $chunk = 45; $from = isset($_GET['from']) ? intval($_GET['from']) : 0; $total = yourls_get_db_stats(); $total = $total['total_links']; $sql = "SELECT `keyword`,`url` FROM `{$table}` WHERE 1=1 ORDER BY `url` ASC LIMIT {$from}, {$chunk} ;"; $rows = $ydb->get_results($sql); $count = 0; $queries = 0; foreach ($rows as $row) { $keyword = $row->keyword; $url = $row->url; $newkeyword = yourls_int2string($keyword); $ydb->query("UPDATE `{$table}` SET `keyword` = '{$newkeyword}' WHERE `url` = '{$url}';"); if ($ydb->result === true) { $queries++; } else { echo "<p>Huho... Could not update rown with url='{$url}', from keyword '{$keyword}' to keyword '{$newkeyword}'</p>"; // Find what went wrong :/ } $count++; } // All done for this chunk of queries, did it all go as expected? $success = true; if ($count != $queries) { $success = false; $num = $count - $queries; echo "<p>{$num} error(s) occured while updating the URL table :(</p>"; } if ($count == $chunk) { // there are probably other rows to convert $from = $from + $chunk; $remain = $total - $from; echo "<p>Converted {$chunk} database rows ({$remain} remaining). Continuing... Please do not close this window until it's finished!</p>"; yourls_redirect_javascript(yourls_admin_url("upgrade.php?step=2&oldver=1.3&newver=1.4&oldsql=100&newsql=200&from={$from}"), $success); } else { // All done echo '<p>All rows converted! Please wait...</p>'; yourls_redirect_javascript(yourls_admin_url("upgrade.php?step=3&oldver=1.3&newver=1.4&oldsql=100&newsql=200"), $success); } }
function yourls_html_menu() { ?> <ul id="admin_menu"> <?php if (yourls_is_private()) { ?> <li>Hello <strong><?php echo YOURLS_USER; ?> </strong> (<a href="?mode=logout" title="Logout">Logout</a>)</li> <?php } ?> <li>Go to the <a href="<?php echo yourls_admin_url('index.php'); ?> ">Admin Interface</a></li> <li>Check the <a href="<?php echo yourls_admin_url('tools.php'); ?> ">Tools</a></li> <li>Read the <a href="<?php echo YOURLS_SITE; ?> /readme.html">Help</a></li> </ul> <?php }
/** * Display the admin menu * */ function yourls_html_menu() { // Build menu links if (defined('YOURLS_USER')) { $logout_link = yourls_apply_filter('logout_link', sprintf(yourls__('Hello <strong>%s</strong>'), YOURLS_USER) . ' (<a href="?action=logout" title="' . yourls_esc_attr__('Logout') . '">' . yourls__('Logout') . '</a>)'); } else { $logout_link = yourls_apply_filter('logout_link', ''); } $help_link = yourls_apply_filter('help_link', '<a href="' . yourls_site_url(false) . '/readme.html">' . yourls__('Help') . '</a>'); $admin_links = array(); $admin_sublinks = array(); $admin_links['admin'] = array('url' => yourls_admin_url('index.php'), 'title' => yourls__('Go to the admin interface'), 'anchor' => yourls__('Admin interface')); if (yourls_is_admin()) { $admin_links['tools'] = array('url' => yourls_admin_url('tools.php'), 'anchor' => yourls__('Tools')); $admin_links['plugins'] = array('url' => yourls_admin_url('plugins.php'), 'anchor' => yourls__('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 '<nav role="navigation"><ul id="admin_menu">' . "\n"; if (yourls_is_private() && !empty($logout_link)) { echo '<li id="admin_menu_logout_link">' . $logout_link . '</li>'; } foreach ((array) $admin_links as $link => $ar) { if (isset($ar['url'])) { $anchor = isset($ar['anchor']) ? $ar['anchor'] : $link; $title = isset($ar['title']) ? 'title="' . $ar['title'] . '"' : ''; printf('<li id="admin_menu_%s_link" class="admin_menu_toplevel"><a href="%s" %s>%s</a>', $link, $ar['url'], $title, $anchor); } // Output submenu if any. TODO: clean up, too many code duplicated here if (isset($admin_sublinks[$link])) { echo "<ul>\n"; foreach ($admin_sublinks[$link] as $link => $ar) { if (isset($ar['url'])) { $anchor = isset($ar['anchor']) ? $ar['anchor'] : $link; $title = isset($ar['title']) ? 'title="' . $ar['title'] . '"' : ''; printf('<li id="admin_menu_%s_link" class="admin_menu_sublevel admin_menu_sublevel_%s"><a href="%s" %s>%s</a>', $link, $link, $ar['url'], $title, $anchor); } } echo "</ul>\n"; } } if (isset($help_link)) { echo '<li id="admin_menu_help_link">' . $help_link . '</li>'; } yourls_do_action('admin_menu'); echo "</ul></nav>\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 = "<div>OMG, dude, I mean!</div>" ); yourls_add_action( 'admin_notices', create_function( '', "echo '$message';" ) ); */ }
?> <p> <img src="<?php echo YOURLS_SITE; ?> /images/yourls-logo.png" alt="YOURLS" title="YOURLS" /> </p> <?php // Print errors, warnings and success messages foreach (array('error', 'warning', 'success') as $info) { if (count(${$info}) > 0) { echo "<ul class='{$info}'>"; foreach (${$info} as $msg) { echo '<li>' . $msg . "</li>\n"; } echo '</ul>'; } } // Display install button or link to admin area if applicable if (!yourls_is_installed() && !isset($_REQUEST['install'])) { echo '<p> </p><p style="text-align: center;"><input type="submit" name="install" value="Install YOURLS" class="button" /></p>'; } else { if (count($error) == 0) { echo '<p> </p><p style="text-align: center;">» <a href="' . yourls_admin_url() . '" title="YOURLS Administration Page">YOURLS Administration Page</a></p>'; } } ?> </form> </div> <?php yourls_html_footer();
/** * Filter table_add_row_action_array * * @return mixed */ public function filter_table_add_row_action_array() { list($actions) = func_get_args(); $permissions = $this->helperGetAllowedPermissions(); if (!isset($permissions[self::PERMISSION_ACTION_EDIT_COMMENT]) && !isset($permissions[self::PERMISSION_ACTION_EDIT_LABEL])) { return $actions; } $id = yourls_string2htmlid($this->_keyword); $href = yourls_nonce_url('laemmi_edit_comment_label_' . $id, yourls_add_query_arg(['action' => 'laemmi_edit_comment_label', 'keyword' => $this->_keyword], yourls_admin_url('admin-ajax.php'))); $actions['laemmi_edit_comment_label'] = ['href' => $href, 'id' => '', 'title' => yourls__('Edit comment & label', self::APP_NAMESPACE), 'anchor' => 'edit_comment_label', 'onclick' => '']; return $actions; }