本文整理汇总了PHP中yourls_apply_filter函数的典型用法代码示例。如果您正苦于以下问题:PHP yourls_apply_filter函数的具体用法?PHP yourls_apply_filter怎么用?PHP yourls_apply_filter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了yourls_apply_filter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: churl_reachability
function churl_reachability($churl_reachable, $url, $keyword = '')
{
global $ydb;
preg_match('!^[a-zA-Z0-9\\+\\.-]+:(//)?!', $url, $matches);
$protocol = isset($matches[0]) ? $matches[0] : '';
$different_protocols = array('http://', 'https://');
if ($protocol == '') {
$protocol = 'http://';
$url = 'http://' . $url;
}
$check_url = in_array($protocol, $different_protocols);
// Return to normal routine if non-http(s) protocol is valid
if ($check_url == false) {
return false;
}
// Check if the long URL is reachable
$resURL = curl_init();
curl_setopt($resURL, CURLOPT_URL, $url);
curl_setopt($resURL, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($resURL, CURLOPT_HEADERFUNCTION, 'curlHeaderCallback');
curl_setopt($resURL, CURLOPT_FAILONERROR, 1);
curl_exec($resURL);
$intReturnCode = curl_getinfo($resURL, CURLINFO_HTTP_CODE);
curl_close($resURL);
// Return error if the entered URL is unreachable
if ($intReturnCode == '' || $intReturnCode == 404) {
$return['status'] = 'fail';
$return['code'] = 'error:url';
$return['message'] = 'The entered URL is unreachable. Check the URL or try again later.';
$return['statusCode'] = 200;
// regardless of result, this is still a valid request
return yourls_apply_filter('add_new_link_fail_unreachable', $return, $url, $keyword, $title);
}
return false;
}
示例2: yourls_kses_init
/**
* Init KSES globals if not already defined (by a plugin)
*
* @since 1.6
*
*/
function yourls_kses_init()
{
global $yourls_allowedentitynames, $yourls_allowedprotocols;
if (!$yourls_allowedentitynames) {
$yourls_allowedentitynames = yourls_apply_filter('kses_allowed_entities', yourls_kses_allowed_entities());
}
if (!$yourls_allowedprotocols) {
$yourls_allowedprotocols = yourls_apply_filter('kses_allowed_protocols', yourls_kses_allowed_protocols());
}
/** See NOTE ABOUT GLOBALS **
if( ! $yourls_allowedtags_all ) {
$yourls_allowedtags_all = yourls_kses_allowed_tags_all();
$yourls_allowedtags_all = array_map( '_yourls_add_global_attributes', $yourls_allowedtags_all );
$yourls_allowedtags_all = yourls_apply_filter( 'kses_allowed_tags_all', $yourls_allowedtags_all );
} else {
// User defined: let's sanitize
$yourls_allowedtags_all = yourls_kses_array_lc( $yourls_allowedtags_all );
}
if( ! $yourls_allowedtags ) {
$yourls_allowedtags = yourls_kses_allowed_tags();
$yourls_allowedtags = array_map( '_yourls_add_global_attributes', $yourls_allowedtags );
$yourls_allowedtags = yourls_apply_filter( 'kses_allowed_tags', $yourls_allowedtags );
} else {
// User defined: let's sanitize
$yourls_allowedtags = yourls_kses_array_lc( $yourls_allowedtags );
}
/**/
}
示例3: yourls_get_duplicate_keywords
/**
* Return list of all shorturls associated to the same long URL. Returns NULL or array of keywords.
*
*/
function yourls_get_duplicate_keywords($longurl)
{
yourls_deprecated_function(__FUNCTION__, '1.7', 'yourls_get_longurl_keywords');
if (!yourls_allow_duplicate_longurls()) {
return NULL;
}
return yourls_apply_filter('get_duplicate_keywords', yourls_get_longurl_keywords($longurl), $longurl);
}
示例4: fix_long_url
function fix_long_url($url, $unsafe_url)
{
$search = array('%2520', '%2521', '%2522', '%2523', '%2524', '%2525', '%2526', '%2527', '%2528', '%2529', '%252A', '%252B', '%252C', '%252D', '%252E', '%252F', '%253A', '%253D', '%253F', '%255C', '%255F');
$replace = array('%20', '%21', '%22', '%23', '%24', '%25', '%26', '%27', '%28', '%29', '%2A', '%2B', '%2C', '%2D', '%2E', '%2F', '%3A', '%3D', '%3F', '%5C', '%5F');
$url = str_ireplace($search, $replace, $url);
// Remove any trailing spaces from the long URL
while (substr($url, -strlen('%20')) == '%20') {
$url = preg_replace('/%20$/', '', $url);
}
return yourls_apply_filter('after_fix_long_url', $url, $unsafe_url);
}
示例5: allow_aliases
function allow_aliases()
{
yourls_do_action('pre_get_request');
// Ignore protocol & www. prefix
$root = str_replace(array('https://', 'http://', 'https://www.', 'http://www.'), '', YOURLS_SITE);
// Use the configured domain instead of $_SERVER['HTTP_HOST']
$root_host = parse_url(YOURLS_SITE);
// Case insensitive comparison of the YOURLS root to match both http://Sho.rt/blah and http://sho.rt/blah
$request = preg_replace("!{$root}/!i", '', $root_host['host'] . $_SERVER['REQUEST_URI'], 1);
// Unless request looks like a full URL (ie request is a simple keyword) strip query string
if (!preg_match("@^[a-zA-Z]+://.+@", $request)) {
$request = current(explode('?', $request));
}
return yourls_apply_filter('get_request', $request);
}
示例6: insensitive_get_keyword_infos
function insensitive_get_keyword_infos($keyword, $use_cache = true)
{
global $ydb;
$keyword = yourls_sanitize_string($keyword);
yourls_do_action('pre_get_keyword', $keyword, $use_cache);
if (isset($ydb->infos[$keyword]) && $use_cache == true) {
return yourls_apply_filter('get_keyword_infos', $ydb->infos[$keyword], $keyword);
}
yourls_do_action('get_keyword_not_cached', $keyword);
$table = YOURLS_DB_TABLE_URL;
$infos = $ydb->get_row("SELECT * FROM `{$table}` WHERE LOWER(`keyword`) = LOWER('{$keyword}')");
if ($infos) {
$infos = (array) $infos;
$ydb->infos[$keyword] = $infos;
} else {
$ydb->infos[$keyword] = false;
}
return yourls_apply_filter('get_keyword_infos', $ydb->infos[$keyword], $keyword);
}
示例7: ozh_yourls_antispam_is_blacklisted
function ozh_yourls_antispam_is_blacklisted($url)
{
$parsed = parse_url($url);
if (!isset($parsed['host'])) {
return yourls_apply_filter('ozh_yourls_antispam_malformed', 'malformed');
}
// Remove www. from domain (but not from www.com)
$parsed['host'] = preg_replace('/^www\\.(.+\\.)/i', '$1', $parsed['host']);
// Major blacklists. There's a filter if you want to manipulate this.
$blacklists = yourls_apply_filter('ozh_yourls_antispam_list', array('dbl.spamhaus.org', 'multi.surbl.org', 'black.uribl.com'));
// Check against each blacklist, exit if blacklisted
foreach ($blacklists as $blacklist) {
$domain = $parsed['host'] . '.' . $blacklist . '.';
$record = @dns_get_record($domain);
if ($record && count($record) > 0) {
return yourls_apply_filter('ozh_yourls_antispam_blacklisted', true);
}
}
// All clear, probably not spam
return yourls_apply_filter('ozh_yourls_antispam_clean', false);
}
示例8: yourls_content_type_header
/**
* Send a filerable content type header
*
* @since 1.7
* @param string $type content type ('text/html', 'application/json', ...)
* @return bool whether header was sent
*/
function yourls_content_type_header($type)
{
yourls_do_action('content_type_header', $type);
if (!headers_sent()) {
$charset = yourls_apply_filter('content_type_header_charset', 'utf-8');
header("Content-Type: {$type}; charset={$charset}");
return true;
}
return false;
}
示例9: yourls_encodeURI
/**
* PHP emulation of JS's encodeURI
*
* @link https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURI
* @param $url
* @return string
*/
function yourls_encodeURI($url)
{
// Decode URL all the way
$result = yourls_rawurldecode_while_encoded($url);
// Encode once
$result = strtr(rawurlencode($result), array('%3B' => ';', '%2C' => ',', '%2F' => '/', '%3F' => '?', '%3A' => ':', '%40' => '@', '%26' => '&', '%3D' => '=', '%2B' => '+', '%24' => '$', '%21' => '!', '%2A' => '*', '%27' => '\'', '%28' => '(', '%29' => ')', '%23' => '#'));
// @TODO:
// Known limit: this will most likely break IDN URLs such as http://www.académie-française.fr/
// To fully support IDN URLs, advocate use of a plugin.
return yourls_apply_filter('encodeURI', $result, $url);
}
示例10: yourls_http_user_agent
function yourls_http_user_agent()
{
return yourls_apply_filter('http_user_agent', 'YOURLS v' . YOURLS_VERSION . ' +http://yourls.org/ (running on ' . YOURLS_SITE . ')');
}
示例11: yourls_api_expand
/**
* Expand short url to long url
*
*/
function yourls_api_expand($shorturl)
{
$keyword = str_replace(YOURLS_SITE . '/', '', $shorturl);
// accept either 'http://ozh.in/abc' or 'abc'
$keyword = yourls_sanitize_string($keyword);
$longurl = yourls_get_keyword_longurl($keyword);
if ($longurl) {
$return = array('keyword' => $keyword, 'shorturl' => YOURLS_SITE . "/{$keyword}", 'longurl' => $longurl, 'simple' => $longurl, 'message' => 'success', 'statusCode' => 200);
} else {
$return = array('keyword' => $keyword, 'simple' => 'not found', 'message' => 'Error: short URL not found', 'errorCode' => 404);
}
return yourls_apply_filter('api_expand', $return, $shorturl);
}
示例12: isset
$url = $_REQUEST['url'];
$keyword = isset($_REQUEST['keyword']) ? $_REQUEST['keyword'] : '';
$title = isset($_REQUEST['title']) ? $_REQUEST['title'] : '';
$text = isset($_REQUEST['text']) ? $_REQUEST['text'] : '';
// Create short URL, receive array $return with various information
$return = yourls_add_new_link($url, $keyword, $title);
$shorturl = isset($return['shorturl']) ? $return['shorturl'] : '';
$message = isset($return['message']) ? $return['message'] : '';
$title = isset($return['title']) ? $return['title'] : '';
$status = isset($return['status']) ? $return['status'] : '';
// Stop here if bookmarklet with a JSON callback function ("instant" bookmarklets)
if (isset($_GET['jsonp']) && $_GET['jsonp'] == 'yourls') {
$short = $return['shorturl'] ? $return['shorturl'] : '';
$message = "Short URL (Ctrl+C to copy)";
header('Content-type: application/json');
echo yourls_apply_filter('bookmarklet_jsonp', "yourls_callback({'short_url':'{$short}','message':'{$message}'});");
die;
}
}
// Part to be executed if FORM has been submitted
if (isset($_REQUEST['url']) && $_REQUEST['url'] != 'http://') {
// Display result message of short link creation
if (isset($message)) {
echo "<h2><center>{$message}</h2></center>";
}
if ($status == 'success') {
echo "<h3><center>Short: {$shorturl}</h3></center>";
// Include the Copy box and the Quick Share box
// yourls_share_box( $url, $shorturl, $title, $text );
// Initialize clipboard -- requires js/share.js and js/jquery.zclip.min.js to be properly loaded in the <head>
// echo "<script>init_clipboard();</script>\n";
示例13: muAdminUrl
function muAdminUrl($page = '')
{
$admin = YOURLS_SITE . '/user/plugins/multi-user/' . $page;
return yourls_apply_filter('admin_url', $admin, $page);
}
示例14: yourls_html_menu
/**
* 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 '<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>\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';" ) );
*/
}
示例15: yourls_deprecated_function
/**
* Marks a function as deprecated and informs when it has been used. Stolen from WP.
*
* There is a hook deprecated_function that will be called that can be used
* to get the backtrace up to what file and function called the deprecated
* function.
*
* The current behavior is to trigger a user error if YOURLS_DEBUG is true.
*
* This function is to be used in every function that is deprecated.
*
* @since 1.6
* @uses yourls_do_action() Calls 'deprecated_function' and passes the function name, what to use instead,
* and the version the function was deprecated in.
* @uses yourls_apply_filter() Calls 'deprecated_function_trigger_error' and expects boolean value of true to do
* trigger or false to not trigger error.
*
* @param string $function The function that was called
* @param string $version The version of WordPress that deprecated the function
* @param string $replacement Optional. The function that should have been called
*/
function yourls_deprecated_function($function, $version, $replacement = null)
{
yourls_do_action('deprecated_function', $function, $replacement, $version);
// Allow plugin to filter the output error trigger
if (YOURLS_DEBUG && yourls_apply_filter('deprecated_function_trigger_error', true)) {
if (!is_null($replacement)) {
trigger_error(sprintf(yourls__('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement));
} else {
trigger_error(sprintf(yourls__('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version));
}
}
}