function temp_instead_function($args) { $url = $args[0]; $code = $args[1]; $match = strpos($url, yourls_site_url(false)); $mode = intval(yourls_get_option('temp_instead_mode', 1)); // We check here if the url contains the YOURLS installation address, // and if it doesn't we'll return a 302 redirect if it isn't getting // one already. if ($code != 302 && ($mode == 1 || $match === false && $mode == 3)) { yourls_redirect($url, 302); } // We check here if the url contains the YOURLS installation address, // and if it does we'll return a 301 redirect if it isn't getting // one already. if ($code != 301 && ($mode == 2 || $match !== false && $mode == 3)) { yourls_redirect($url, 301); } }
$error = array_merge($error, $install['error']); } if (isset($install['success'])) { $success = array_merge($success, $install['success']); } } // Start output yourls_html_head('install', yourls__('Install YOURLS')); ?> <div id="login"> <form method="post" action="?"><?php // reset any QUERY parameters ?> <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
/** * 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';" ) ); */ }
/** * Auto detect custom favicon in /user directory, fallback to YOURLS favicon, and echo/return its URL * */ function yourls_favicon($echo = true) { static $favicon = null; if ($favicon !== null) { if ($echo) { echo $favicon; } return $favicon; } $custom = null; // search for favicon.(gif|ico|png|jpg|svg) foreach (array('gif', 'ico', 'png', 'jpg', 'svg') as $ext) { if (file_exists(YOURLS_USERDIR . '/favicon.' . $ext)) { $custom = 'favicon.' . $ext; break; } } if ($custom) { $favicon = yourls_site_url(false, YOURLS_USERURL . '/' . $custom); } else { $favicon = yourls_site_url(false) . '/images/favicon.gif'; } if ($echo) { echo $favicon; } return $favicon; }
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';" ) ); */ }
/** * Get bootstrap js * * @return bool|string */ public function getBootstrap() { if (false === self::$_isBootstrap) { self::$_isBootstrap = true; $path = yourls_site_url(false) . '/user/plugins/' . self::APP_NAMESPACE . '/assets/lib/bootstrap/dist'; return trim(' <link href="' . $path . '/css/bootstrap.min.css" rel="stylesheet"> <link href="' . $path . '/css/bootstrap-theme.min.css" rel="stylesheet"> <script src="' . $path . '/js/bootstrap.min.js"></script> '); } return false; }
/** * Displays the plugin's configuration page */ function itfs_piwik_admin_settings() { // Check if an update to the configuration was submitted if (isset($_POST['piwik_config'])) { itfs_piwik_admin_settings_update(); } // Get current configuration from database $piwik_config = yourls_get_option('piwik_config'); ?> <link rel="stylesheet" href="<?php yourls_site_url(); ?> /user/plugins/piwik/themes/default/uniform.default.css" type="text/css" media="screen" charset="utf-8" xmlns="http://www.w3.org/1999/html"/> <link rel="stylesheet" href="<?php yourls_site_url(); ?> /user/plugins/piwik/css/form.css" type="text/css" media="screen" charset="utf-8"/> <script type="text/javascript" src="<?php yourls_site_url(); ?> /user/plugins/piwik/js/jquery.uniform.min.js"></script> <script type='text/javascript' src="<?php yourls_site_url(); ?> /user/plugins/piwik/js/form.js"></script> <div id="piwik"> <div id="piwik_config"> <h2>Piwik plugin settings</h2> <form method="post" id="piwik_config_form"> <div class="piwik_config_zone"> <h3>Basic settings</h3> <div> <label for="piwik_url">Piwik URL <span class="required">*</span></label> <input type="text" id="piwik_url" name="piwik_config[piwik_url]" size="40" value="<?php echo $piwik_config[piwik_url]; ?> "/> </div> <div> <label for="site_id">Site ID <span class="required">*</span></label> <input type="text" id="site_id" name="piwik_config[site_id]" size="2" value="<?php echo $piwik_config[site_id]; ?> "/> </div> <div> <p class="checkbox_description">You can disable the built-in stats system by ticking the box below</p> <label for="disable_stats" class="piwik_config_checkbox">Disable built-in stats</label> <input type="checkbox" <?php echo $piwik_config[disable_stats] ? 'checked="checked"' : ''; ?> id="disable_stats" name="piwik_config[disable_stats]"/> <p> <small>Clicks will still be counted locally</small> </p> </div> <div> <p class="checkbox_description">You can stop tracking visits from bots by ticking the box below</p> <label for="remove_bots" class="piwik_config_checkbox">Stop tracking bots</label> <input type="checkbox" <?php echo $piwik_config[remove_bots] ? 'checked="checked"' : ''; ?> id="remove_bots" name="piwik_config[remove_bots]"/> </div> <p> <span class="required">* Required fields</span> </p> </div> <div id='options'> <div class="piwik_config_zone"> <h3><a href="#authentication">Authentication</a></h3> <div class='parameter' id='authentication'> <p>This is required if you want to be able to track you visitors' IPs<br/> This must be an admin token (read/write access)</p> <div> <label for="token">Auth token</label> <input type="text" id="token" name="piwik_config[token]" size="40" value="<?php echo $piwik_config[token]; ?> "/> </div> </div> </div> <div class="piwik_config_zone"> <h3><a href="#customVariable">Custom Variable</a></h3> <div class='parameter' id='customVariable'> <p>You can set an optional <a href="http://piwik.org/docs/custom-variables/" rel="external">custom variable</a> if you have the use for it</p> <div> <label for="customvar_name">Variable name</label> <input type="text" id="customvar_name" name="piwik_config[customvar_name]" value="<?php echo $piwik_config[customvar_name]; ?> "/> </div> <div> <label for="customvar_value">Variable value</label> <input type="text" id="customvar_value" name="piwik_config[customvar_value]" value="<?php echo $piwik_config[customvar_value]; ?> "/> </div> <div> <label>Variable scope</label> <select class="" name="piwik_config[customvar_scope]"> <option value="visit" <?php echo $piwik_config[customvar_scope] == "visit" ? 'selected="selected"' : ''; ?> /> visit</option> <option value="page" <?php echo $piwik_config[customvar_scope] == "page" ? 'selected="selected"' : ''; ?> /> page</option> </select> </div> </div> </div> </div> <div class="piwik_config_submit"> <input type="submit" value="Save settings"/> </div> </form> </div> <div id="piwik_support"> <h2>Support developpement</h2> <p>This plugin was developed by <a href="http://www.interfasys.ch" rel="external">interfaSys</a> and you can support its development by making a donation below.</p> <p>Even $2 makes a difference by showing your appreciation ;)</p> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="9J6VKYC45QG46"> <input type="image" src="https://www.paypalobjects.com/en_US/CH/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> <h2>Project homepage</h2> <p>You can find the latest version of the plugin on <a href="https://github.com/interfasys/piwik-yourls" rel="external">GitHub</a>.</p> <h3>License</h3> <p>Copyright 2012 - interfaSys sàrl - <a href="http://www.interfasys.ch" rel="external">www.interfasys.ch</a><br/><br/> Licensed under the GNU Affero General Public License, version 3 (AGPLv3) (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at<br/><br/> <a href="http://www.gnu.org/licenses/agpl-3.0.html" rel="external">http://www.gnu.org/licenses/agpl-3.0.html</a> </p> </div> <div id="reset"></div> </div> <?php }