• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP yourls_is_private函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: clayton_api_action_delete

function clayton_api_action_delete()
{
    // We don't want unauthenticated users deleting links
    // If YOURLS is in public mode, force authentication anyway
    if (!yourls_is_private()) {
        yourls_do_action('require_auth');
        require_once YOURLS_INC . '/auth.php';
    }
    // Need 'shorturl' parameter
    if (!isset($_REQUEST['shorturl'])) {
        return array('statusCode' => 400, 'simple' => "Need a 'shorturl' parameter", 'message' => 'error: missing param');
    }
    $shorturl = $_REQUEST['shorturl'];
    // Check if valid shorturl
    if (!yourls_is_shorturl($shorturl)) {
        return array('statusCode' => 404, 'simple ' => 'Error: short URL not found', 'message' => 'error: not found');
    }
    // Is $shorturl a URL (http://sho.rt/abc) or a keyword (abc) ?
    if (yourls_get_protocol($shorturl)) {
        $keyword = yourls_get_relative_url($shorturl);
    } else {
        $keyword = $shorturl;
    }
    // Delete shorturl
    if (yourls_delete_link_by_keyword($keyword)) {
        return array('statusCode' => 200, 'simple' => "Shorturl {$shorturl} deleted", 'message' => 'success: deleted');
    } else {
        return array('statusCode' => 500, 'simple' => 'Error: could not delete shorturl, not sure why :-/', 'message' => 'error: unknown error');
    }
}
开发者ID:Gawel1,项目名称:yourls-api-delete,代码行数:30,代码来源:plugin.php


示例2: lc_full_bootstrap_logout_link

/**
 * Rewrite logout link
 *
 * @param string $link   Default element
 * @param string $show   Allow muting
 * @return string        Logout element (HTML)
 */
function lc_full_bootstrap_logout_link($link, $show = false)
{
    if ($show && yourls_is_private() && defined('YOURLS_USER')) {
        return '<div class="navbar-right"><p class="navbar-text">' . sprintf(yourls__('Hello <strong>%s</strong>'), YOURLS_USER) . '</p><a href="?action=logout" title="' . yourls_esc_attr__('Logout') . '" class="btn btn-default navbar-btn"><i class="icon-signout"></i> ' . yourls__('Logout') . '</a></div>';
    } else {
        return '';
    }
}
开发者ID:master3395,项目名称:yourls-full-bootstrap,代码行数:15,代码来源:theme.php


示例3: error_reporting

    error_reporting(E_ERROR | E_PARSE);
}
// Include all functions
require_once YOURLS_INC . '/version.php';
require_once YOURLS_INC . '/functions.php';
require_once YOURLS_INC . '/functions-plugins.php';
require_once YOURLS_INC . '/functions-formatting.php';
require_once YOURLS_INC . '/functions-api.php';
require_once YOURLS_INC . '/functions-kses.php';
require_once YOURLS_INC . '/functions-l10n.php';
require_once YOURLS_INC . '/functions-compat.php';
require_once YOURLS_INC . '/functions-html.php';
require_once YOURLS_INC . '/functions-http.php';
require_once YOURLS_INC . '/functions-infos.php';
// Load auth functions if needed
if (yourls_is_private()) {
    require_once YOURLS_INC . '/functions-auth.php';
}
// Load locale
yourls_load_default_textdomain();
// Check if we are in maintenance mode - if yes, it will die here.
yourls_check_maintenance_mode();
// Fix REQUEST_URI for IIS
yourls_fix_request_uri();
// If request for an admin page is http:// and SSL is required, redirect
if (yourls_is_admin() && yourls_needs_ssl() && !yourls_is_ssl()) {
    if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
        yourls_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
        exit;
    } else {
        yourls_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
开发者ID:mimischi,项目名称:gu-urlshorter,代码行数:31,代码来源:load-yourls.php


示例4: yourls_html_menu

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 
}
开发者ID:momoim,项目名称:momo-api,代码行数:29,代码来源:functions-html.php


示例5: 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 '<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';" ) );
    */
}
开发者ID:yourls,项目名称:yourls,代码行数:61,代码来源:functions-html.php


示例6: yourls_check_IP_flood

/**
 * Check if an IP shortens URL too fast to prevent DB flood. Return true, or die.
 *
 */
function yourls_check_IP_flood($ip = '')
{
    // Allow plugins to short-circuit the whole function
    $pre = yourls_apply_filter('shunt_check_IP_flood', false, $ip);
    if (false !== $pre) {
        return $pre;
    }
    yourls_do_action('pre_check_ip_flood', $ip);
    // at this point $ip can be '', check it if your plugin hooks in here
    // Raise white flag if installing or if no flood delay defined
    if (defined('YOURLS_FLOOD_DELAY_SECONDS') && YOURLS_FLOOD_DELAY_SECONDS === 0 || !defined('YOURLS_FLOOD_DELAY_SECONDS') || yourls_is_installing()) {
        return true;
    }
    // Don't throttle logged in users
    if (yourls_is_private()) {
        if (yourls_is_valid_user() === true) {
            return true;
        }
    }
    // Don't throttle whitelist IPs
    if (defined('YOURLS_FLOOD_IP_WHITELIST') && YOURLS_FLOOD_IP_WHITELIST) {
        $whitelist_ips = explode(',', YOURLS_FLOOD_IP_WHITELIST);
        foreach ((array) $whitelist_ips as $whitelist_ip) {
            $whitelist_ip = trim($whitelist_ip);
            if ($whitelist_ip == $ip) {
                return true;
            }
        }
    }
    $ip = $ip ? yourls_sanitize_ip($ip) : yourls_get_IP();
    $ip = yourls_escape($ip);
    yourls_do_action('check_ip_flood', $ip);
    global $ydb;
    $table = YOURLS_DB_TABLE_URL;
    $lasttime = $ydb->get_var("SELECT `timestamp` FROM {$table} WHERE `ip` = '{$ip}' ORDER BY `timestamp` DESC LIMIT 1");
    if ($lasttime) {
        $now = date('U');
        $then = date('U', strtotime($lasttime));
        if ($now - $then <= YOURLS_FLOOD_DELAY_SECONDS) {
            // Flood!
            yourls_do_action('ip_flood', $ip, $now - $then);
            yourls_die(yourls__('Too many URLs added too fast. Slow down please.'), yourls__('Forbidden'), 403);
        }
    }
    return true;
}
开发者ID:steenhulthin,项目名称:hult.in,代码行数:50,代码来源:functions.php


示例7: yourls_html_menu

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';" ) );
    */
}
开发者ID:469306621,项目名称:Languages,代码行数:54,代码来源:functions-html.php


示例8: yourls_check_IP_flood

function yourls_check_IP_flood($ip = '')
{
    if (defined('YOURLS_FLOOD_DELAY_SECONDS') && YOURLS_FLOOD_DELAY_SECONDS === 0 || !defined('YOURLS_FLOOD_DELAY_SECONDS')) {
        return true;
    }
    $ip = $ip ? yourls_sanitize_ip($ip) : yourls_get_IP();
    // Don't throttle whitelist IPs
    if (defined('YOURLS_FLOOD_IP_WHITELIST' && YOURLS_FLOOD_IP_WHITELIST)) {
        $whitelist_ips = explode(',', YOURLS_FLOOD_IP_WHITELIST);
        foreach ($whitelist_ips as $whitelist_ip) {
            $whitelist_ip = trim($whitelist_ip);
            if ($whitelist_ip == $ip) {
                return true;
            }
        }
    }
    // Don't throttle logged in users
    if (yourls_is_private()) {
        if (yourls_is_valid_user() === true) {
            return true;
        }
    }
    global $ydb;
    $table = YOURLS_DB_TABLE_URL;
    $lasttime = $ydb->get_var("SELECT `timestamp` FROM {$table} WHERE `ip` = '{$ip}' ORDER BY `timestamp` DESC LIMIT 1");
    if ($lasttime) {
        $now = date('U');
        $then = date('U', strtotime($lasttime));
        if ($now - $then <= YOURLS_FLOOD_DELAY_SECONDS) {
            // Flood!
            yourls_die('Too many URLs added too fast. Slow down please.', 'Forbidden', 403);
        }
    }
    return true;
}
开发者ID:momoim,项目名称:momo-api,代码行数:35,代码来源:functions.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP yourls_redirect函数代码示例发布时间:2022-05-23
下一篇:
PHP yourls_html_menu函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap