当前位置: 首页>>代码示例>>PHP>>正文


PHP yourls_add_action函数代码示例

本文整理汇总了PHP中yourls_add_action函数的典型用法代码示例。如果您正苦于以下问题:PHP yourls_add_action函数的具体用法?PHP yourls_add_action怎么用?PHP yourls_add_action使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了yourls_add_action函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bulk

<?php

/*
Plugin Name: Bulk URL shortener
Plugin URI: https://github.com/tdakanalis/bulk_api_bulkshortener
Description: Shorten URLs in bulk (a single request with many URLs to shorten).
Version: 1.0
Author: Stelios Mavromichalis
Author URI: http://www.cytech.gr
*/
yourls_add_action('api', 'bulk_api_bulkshortener');
function bulk_api_bulkshortener($action)
{
    if ($action[0] != 'bulkshortener') {
        return;
    }
    if (!isset($_REQUEST['urls'])) {
        $return = array('errorCode' => 400, 'message' => 'bulkshortener: missing URLS parameter', 'simple' => 'bulkshortener: missing URLS parameter');
        echo $return['errorCode'] . ": " . $return['simple'];
        die;
    }
    $keyword = isset($_REQUEST['keyword']) ? $_REQUEST['keyword'] : '';
    $title = isset($_REQUEST['title']) ? $_REQUEST['title'] : '';
    $urls = isset($_REQUEST['urls']) ? $_REQUEST['urls'] : array();
    foreach ($urls as $url) {
        $return = yourls_add_new_link($url, $keyword, $title);
        echo $return['shorturl'] . "\n";
    }
    die;
}
开发者ID:liruqi,项目名称:bulk_api_bulkshortener,代码行数:30,代码来源:plugin.php

示例2: define

// No direct call.
if (!defined('YOURLS_ABSPATH')) {
    die;
}
// Change to true to get extra debugging info on-screen. Must be true or false, cannot be undefined.
define("PCE_DEBUG", false);
// Define the separator between bits of information.
define("PCE_SEP", ' | ');
// Some version details, same as at the top of this file, for use in the page footer.
define("PCE_REL_VER", '0.1');
define("PCE_REL_DATE", '2014-07-16');
// Repository URL.
define("PCE_REPO", 'https://github.com/vaughany/yourls-popular-clicks-extended');
// Get the GMT offset if it is set
define("PCE_OFFSET", defined('YOURLS_HOURS_OFFSET') ? YOURLS_HOURS_OFFSET * 60 * 60 : 0);
yourls_add_action('plugins_loaded', 'vaughany_popularclicksextended_add_page');
function vaughany_popularclicksextended_add_page()
{
    yourls_register_plugin_page('popularclicksextended', 'Popular Clicks Extended', 'vaughany_popularclicksextended_display_page');
}
function vaughany_popularclicksextended_display_page()
{
    echo '<h2>Popular Clicks Extended</h2>' . "\n";
    echo '<p>This report shows the most popular clicks for the selected time periods as of ' . date('jS F Y, g:ia', time()) . '.</p>' . "\n";
    echo '<p>Legend: <em>Position. Clicks' . PCE_SEP . 'Short URL' . PCE_SEP . 'Page</em></p>' . "\n";
    /**
     * vaughany_show_last_period(): queries the database for the number of clicks per link since n seconds ago,
     *     e.g. 'time() - 300' to 'time()'
     *     e.g. '2014-07-15 14:52:27' to '2014-07-15 14:57:27'
     *
     * $period:     integer:    The number of seconds to look back.
开发者ID:theukedge,项目名称:yourls-popular-clicks-extended,代码行数:31,代码来源:plugin.php

示例3: yourls_add_action

<?php

/*
Plugin Name: GA-Measurement-Protocol
Plugin URI: https://github.com/powerthazan/YOURS-GA-MP-Tracking
Description: Tracks clicks using Google Analytics Measurement Protocol.
Version: 1.1
Author: Powerthazan
Author URI: https://www.twitter.com/powerthazan
License: Creative Commons Attribution 3.0 Unported: https://creativecommons.org/licenses/by/3.0/
*/
yourls_add_action('pre_redirect', 'power_ga_mp');
yourls_add_filter('shunt_update_clicks', 'power_ga_mp_trackCurrent');
function power_ga_mp_trackCurrent($unused)
{
    global $keyword;
    power_ga_mp($keyword, yourls_get_keyword_title($keyword), $_SERVER['HTTP_REFERER']);
    return $unused;
}
// Handle the retrieval of the GA Measurment Protocol via curl instead of file_get_contents
function file_get_contents_curl($url)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    // Don't bother checking the peer. This may imply a MIM can happen though...
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    curl_close($ch);
    return $response;
开发者ID:Efreak,项目名称:YOURLS-GA-MP-Tracking,代码行数:31,代码来源:plugin.php

示例4: yourls_add_notice

/**
 * Wrapper function to display admin notices
 *
 */
function yourls_add_notice($message, $style = 'notice')
{
    // Escape single quotes in $message to avoid breaking the anonymous function
    $message = yourls_notice_box(strtr($message, array("'" => "\\'")), $style);
    yourls_add_action('admin_notices', create_function('', "echo '{$message}';"));
}
开发者ID:yourls,项目名称:yourls,代码行数:10,代码来源:functions-html.php

示例5: yourls_add_action

Version: 0.1
Author: Ozh
Author URI: http://ozh.org/
*/
/* Example of an action
 *
 * We're going to add an entry to the menu.
 *
 * The menu is drawn by function yourls_html_menu() in file includes/functions-html.php.
 * Right before the function outputs the closing </ul>, notice the following function call:
 * yourls_do_action( 'admin_menu' );
 * This function says: "hey, for your information, I've just done something called 'admin menu', thought I'd let you know..."
 *
 * We're going to hook into this action and add our menu entry
 */
yourls_add_action('admin_menu', 'ozh_sample_add_menu');
/* This says: when YOURLS does action 'admin_menu', call function 'ozh_sample_add_menu'
 */
function ozh_sample_add_menu()
{
    echo '<li><a href="http://ozh.org/">Ozh</a></li>';
}
/* And that's it. Activate the plugin and notice the new menu entry.
 */
/* Example of a filter
 *
 * We're going to modify the <title> of pages in the admin area
 *
 * The <title> tag is generated by function yourls_html_head() in includes/functions-html.php
 * Notice the following function call:
 * $title = yourls_apply_filter( 'html_title', 'YOURLS: Your Own URL Shortener' );
开发者ID:TheProjecter,项目名称:yourls-ext,代码行数:31,代码来源:plugin.php

示例6: yourls_add_action

<?php

/*
Plugin Name: Protected URLS
Plugin URI: http://yourls.org/
Description: Show password page for Protected Urls
Version: 1.0
Author: ID
Author URI: http://demirel.ws/
*/
// Hook our custom function into the 'pre_redirect' event
yourls_add_action('redirect_shorturl', 'gural_yourls_protected_keyword');
// Our custom function that will be triggered when the event occurs
function gural_yourls_protected_keyword($args)
{
    require_once YOURLS_INC . '/functions.php';
    $longurl = $args[0];
    $keyword = $args[1];
    $pass = yourls_get_keyword_pass($keyword);
    //echo "Pass : ".$pass." <br>";die();
    if (isset($pass) && $pass != "") {
        $postedPass = $_POST['pass'];
        if (!$postedPass || $pass != $postedPass) {
            echo GetPasswordForm();
            die;
        } else {
            $update_clicks = yourls_update_clicks($keyword);
        }
    } else {
        echo "Not Protected";
        die;
开发者ID:idemirel,项目名称:YOURLS-Password-Protected-Links,代码行数:31,代码来源:plugin.php

示例7: gmo_domain_swap_update_option

}
// Update option in database
function gmo_domain_swap_update_option()
{
    $in = $_POST['domain_swap_values'];
    if (!empty($in)) {
        $in = preg_split('/(\\r?\\n)+/', trim($in));
        array_walk($in, "gmo_domain_trim_value");
        $arr = array('domains' => $in);
        $json = json_encode($arr);
        yourls_update_option('domain_swap_values', $json);
    }
}
/**
 * User action
 */
if (basename($_SERVER['PHP_SELF']) == 'index.php') {
    yourls_add_action('admin_menu', 'gmo_domain_swap_add_menu');
}
function gmo_domain_swap_add_menu()
{
    echo '<li>';
    echo 'Active domain: <select onchange="window.location.hostname = this.value;">';
    $domain_swap_values = json_decode(yourls_get_option('domain_swap_values'));
    foreach ($domain_swap_values->domains as $domain) {
        $selected = $_SERVER["SERVER_NAME"] == $domain ? 'selected' : '';
        echo '<option ' . $selected . ' value="' . $domain . '"/>//' . $domain . '/';
    }
    echo '</select>';
    echo '</li>';
}
开发者ID:gmolop,项目名称:yourls-domain-swap,代码行数:31,代码来源:plugin.php

示例8: ozh_yourls_antispam_check_add

function ozh_yourls_antispam_check_add($false, $url)
{
    // Sanitize URL and make sure there's a protocol
    $url = yourls_sanitize_url($url);
    // only check for 'http(s)'
    if (!in_array(yourls_get_protocol($url), array('http://', 'https://'))) {
        return false;
    }
    if (ozh_yourls_antispam_is_blacklisted($url) != false) {
        return array('status' => 'fail', 'code' => 'error:spam', 'message' => 'This domain is blacklisted', 'errorCode' => '403');
    }
    // All clear, not interrupting the normal flow of events
    return false;
}
// Has the remote link become compromised lately? Check on redirection
yourls_add_action('redirect_shorturl', 'ozh_yourls_antispam_check_redirect');
function ozh_yourls_antispam_check_redirect($url, $keyword = false)
{
    if (is_array($url) && $keyword == false) {
        $keyword = $url[1];
        $url = $url[0];
    }
    // Check when the link was added
    // If shorturl is fresh (ie probably clicked more often?) check once every 15 times, otherwise once every 5 times
    // Define fresh = 3 days = 259200 secondes
    // TODO: when there's a shorturl_meta table, store last check date to allow checking every 2 or 3 days
    $now = date('U');
    $then = date('U', strtotime(yourls_get_keyword_timestamp($keyword)));
    $chances = $now - $then > 259200 ? 15 : 5;
    if ($chances == mt_rand(1, $chances)) {
        if (ozh_yourls_antispam_is_blacklisted($url) != false) {
开发者ID:kst87,项目名称:antispam,代码行数:31,代码来源:plugin.php

示例9: addAction

 /**
  * Add action function
  *
  * @param $name
  */
 protected function addAction($name)
 {
     //         $hook, $function_name, $priority = 10, $accepted_args = 1, $type = 'action'
     //        yourls_add_filter(substr($name, 7), [$this, $name], 10, 1, 'action');
     yourls_add_action(substr($name, 7), [$this, $name]);
 }
开发者ID:laemmi,项目名称:laemmi-yourls-default-tools,代码行数:11,代码来源:AbstractDefault.php

示例10: yourls_add_action

<?php

/*
Plugin Name: iTunes Affiliate
Plugin URI: https://github.com/floschliep/YOURLS-iTunes-Affiliate
Description: Add your iTunes Affiliate-Token to all iTunes URLs before redirection
Version: 1.0.1
Author: Florian Schliep
Author URI: http://floschliep.com
*/
yourls_add_action('pre_redirect', 'flo_addToken');
function flo_addToken($args)
{
    $token = 'YOUR_TOKEN_HERE';
    $url = $args[0];
    // check if URL is an iTunes URL
    if (preg_match("/(itunes\\.apple\\.com\\/)([a-z]{2,3}\\/)|([a-z].+\\/)id[0-9]+/ui", $url) == true) {
        // check if last char is an "/" (in case it is, remove it)
        if (substr($url, -1) == "/") {
            $url = substr($url, 0, -1);
        }
        // remove existing affiliate token if needed
        $existingToken;
        if (preg_match("/(\\?|&)ign-mpt=.+\\&/ui", $url, $matches) == true) {
            // first way affiliate tokens can appear (encoded and not at end of string)
            $existingToken = $matches[0];
            $existingToken = substr($existingToken, 0, -1);
            // last char is an "&"
        } else {
            if (preg_match("/(\\?|&)ign-mpt=.+/uim", $url, $matches) == true) {
                // second way affiliate tokens can appear (encoded and at end of string)
开发者ID:acaranta,项目名称:YOURLS-iTunes-Affiliate,代码行数:31,代码来源:plugin.php

示例11: yourls_add_action

<?php

/*
Plugin Name: 404 if no short URL
Plugin URI: 
Description: Modified after https://github.com/YOURLS/YOURLS/issues/1869
Author: Sven Koeppel
*/
yourls_add_action('redirect_keyword_not_found', 'my404');
function my404($data)
{
    $shorturl = $data[0];
    include_once dirname(__FILE__) . '/../../404.php';
    show404($shorturl);
    exit;
}
开发者ID:mimischi,项目名称:gu-urlshorter,代码行数:16,代码来源:plugin.php

示例12: yourls_add_action

/*
Plugin Name: Upload & Shorten
Plugin URI: https://github.com/fredl99/YOURLS-Upload-and-Shorten
Description: Upload a file and create a short-YOURL for it in one step.
Based on: "Share Files" by Matt Temple
Forked from: http://www.mattytemple.com/projects/yourls-share-files
Version: 1.2
Author: Fredl
Author URI: https://github.com/fredl99
*/
// No direct call
if (!defined('YOURLS_ABSPATH')) {
    die;
}
// Register our plugin admin page
yourls_add_action('plugins_loaded', 'my_upload_and_shorten_add_page');
function my_upload_and_shorten_add_page()
{
    // load custom text domain
    yourls_load_custom_textdomain('upload-and-shorten', dirname(__FILE__) . '/i18n/');
    // create entry in the admin's plugin menu
    yourls_register_plugin_page('upload-and-shorten', 'Upload & Shorten', 'my_upload_and_shorten_do_page');
    // parameters: page slug, page title, and function that will display the page itself
}
// Display admin page
function my_upload_and_shorten_do_page()
{
    // Check if a form was submitted
    if (isset($_POST['submit'])) {
        $my_save_files_message = my_upload_and_shorten_save_files();
    }
开发者ID:iLtc,项目名称:YOURLS-Upload-and-Shorten,代码行数:31,代码来源:plugin.php

示例13: yourls_add_action

<?php

/*
Plugin Name: Popular Clicks
Plugin URI: hhttps://github.com/miconda/yourls
Description: Shows an admin page with the top of last clicked links
Version: 1.0
Author: miconda
Author URI: http://miconda.blogspot.com/
*/
yourls_add_action('plugins_loaded', 'popularclicks_add_page');
function popularclicks_add_page()
{
    yourls_register_plugin_page('popular_clicks', 'Popular Clicks', 'popularclicks_do_page');
}
// Display popular clicks
function popularclicks_do_page()
{
    $nonce = yourls_create_nonce('popular_clickks');
    echo '<h2>Popular Clicks</h2>';
    function show_top($numdays, $numrows)
    {
        global $ydb;
        $base = YOURLS_SITE;
        $table_url = YOURLS_DB_TABLE_URL;
        $table_log = YOURLS_DB_TABLE_LOG;
        $outdata = '';
        /**
        			SELECT a.shorturl AS shorturl, count(*) AS clicks, b.url AS longurl
        			  FROM yourls_log a, yourls_url b WHERE a.shorturl=b.keyword AND DATE_SUB(NOW(),
        			  INTERVAL 30 DAY)<a.click_time GROUP BY a.shorturl ORDER BY count(*) DESC LIMIT 20;
开发者ID:ZaleHack,项目名称:yourls,代码行数:31,代码来源:plugin.php

示例14: define

if (!defined('VVA_CHANGE_PASSWORD_MINIMUM_LENGTH')) {
    define('VVA_CHANGE_PASSWORD_MINIMUM_LENGTH', 6);
}
if (!defined('VVA_CHANGE_PASSWORD_USE_DIGITS')) {
    define('VVA_CHANGE_PASSWORD_USE_DIGITS', FALSE);
}
if (!defined('VVA_CHANGE_PASSWORD_USE_SPECIAL')) {
    define('VVA_CHANGE_PASSWORD_USE_SPECIAL', FALSE);
}
if (!defined('VVA_CHANGE_PASSWORD_USE_UPPERCASE')) {
    define('VVA_CHANGE_PASSWORD_USE_UPPERCASE', FALSE);
}
/**
 * Add hooks required for plugin
 */
yourls_add_action('plugins_loaded', 'vva_change_password_register_page');
yourls_add_filter('logout_link', 'vva_change_password_logout_link');
yourls_add_filter('admin_sublinks', 'vva_change_password_admin_sublinks');
/**
 * Register the change password page
 */
function vva_change_password_register_page()
{
    yourls_register_plugin_page('change_password', 'Change Password', 'vva_change_password_display_page');
}
/**
 * Add the change password link next to logout so it makes sense in the UI
 * 
 * @param string $logout_link
 * @return string $logout_link
 */
开发者ID:walkfor,项目名称:YOURLS-Change-Password,代码行数:31,代码来源:plugin.php

示例15: yourls_add_action

Author URI: http://ozh.org/
Disclaimer: Toolbars ruin the user experience. Be warned.
*/
global $ozh_toolbar;
$ozh_toolbar['do'] = false;
$ozh_toolbar['keyword'] = '';
// When a redirection to a shorturl is about to happen, register variables
yourls_add_action('redirect_shorturl', 'ozh_toolbar_add');
function ozh_toolbar_add($args)
{
    global $ozh_toolbar;
    $ozh_toolbar['do'] = true;
    $ozh_toolbar['keyword'] = $args[1];
}
// On redirection, check if this is a toolbar and draw it if needed
yourls_add_action('pre_redirect', 'ozh_toolbar_do');
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
开发者ID:469306621,项目名称:Languages,代码行数:31,代码来源:plugin.php


注:本文中的yourls_add_action函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。