本文整理汇总了PHP中normalize_url函数的典型用法代码示例。如果您正苦于以下问题:PHP normalize_url函数的具体用法?PHP normalize_url怎么用?PHP normalize_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了normalize_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_junkblog
function is_junkblog($url, $strict = false)
{
$url = normalize_url($url);
$query = XN_Query::create('Content')->filter('owner->relativeUrl', '=', 'someblogs')->filter('type', 'eic', 'Website')->filter('my.url', '=', $url);
$items = $query->execute();
if (count($items)) {
if ($strict === true && !$items[0]->my->verify) {
return false;
}
return $items[0];
}
//end if count items
if ($strict) {
return false;
}
$page = strip_tags(file_get_contents($url));
$stoplist = array('drunk', 'free links', 'sex', 'cock', 'pussy', 'porn', 'pr0n', 'pron', 'I went', 'I slept', 'slept with', 'my boss', 'loser', 'my cat', 'I love you', 'this update is');
foreach ($stoplist as $stop) {
if (stristr($page, ' ' . $stop . ' ')) {
$dummy = file_get_contents('http://someblogs.ning.com/add.php?xn_auth=no&url=' . urlencode($url));
return $strict ? false : true;
}
//end if stop
}
//end foreach stoplist
return false;
}
示例2: get_url
/**
* build a reference to a version
*
* Depending on parameter '[code]with_friendly_urls[/code]' and on action,
* following results can be observed:
*
* - view - versions/view.php?id=123 or versions/view.php/123 or version-123
*
* - other - versions/edit.php?id=123 or versions/edit.php/123 or version-edit/123
*
* @param int the id of the version to handle
* @param string the expected action ('view', 'print', 'edit', 'delete', ...)
* @return string a normalized reference
*
* @see control/configure.php
*/
public static function get_url($id, $action = 'view')
{
global $context;
// list versions -- the id has to be an anchor (e.g., 'article:15')
if ($action == 'list') {
if ($context['with_friendly_urls'] == 'Y') {
return 'versions/list.php/' . str_replace(':', '/', $id);
} else {
return 'versions/list.php?id=' . urlencode($id);
}
}
// check the target action
if (!preg_match('/^(delete|restore|view)$/', $action)) {
return 'versions/' . $action . '.php?id=' . urlencode($id);
}
// normalize the link
return normalize_url(array('versions', 'version'), $action, $id);
}
示例3: require_login
<?php
// Make sure user is logged in
require_login();
// Normalize the URL
$href = normalize_url(@$_POST['href']);
// Strip tags, normalize whitespace, shorten if necessary
$summary = summarize($_POST['summary']);
// Filter content to prevent against XSS attacks
$content = filter_content($_POST['content']);
// Escape content for the database to prevent SQL injection
$href = $db->escape($href);
$summary = $db->escape($summary);
$space = $db->escape($_POST['space']);
$content = $db->escape($content);
$version = $db->escape($_POST['version']);
if (isset($_POST['status']) && is_numeric($_POST['status'])) {
$status = $db->escape($_POST['status']);
} else {
$status = 1;
}
// Check to make sure we have everything
if (empty($href)) {
respond(0, "Please specify an 'href' argument.");
} else {
if (empty($space)) {
respond(0, "Please specify a 'space' argument.");
} else {
if (empty($content)) {
respond(0, "Please specify a 'content' argument.");
} else {
示例4: ob_flush
padding-left: 0px;
}
</style>
</head>
<body>
<?php
require 'header.php';
ob_flush();
flush();
if ($_GET['id']) {
$person_id = mysql_real_escape_string($_GET['id'], $db);
} else {
require 'normalize_url.php';
$url = mysql_real_escape_string(normalize_url($_GET['url']), $db);
if (!isset($_GET['nofetch'])) {
shell_exec("ruby fetch_profile.rb '{$url}' 2>&1");
}
$person_id = @mysql_fetch_assoc(mysql_query("SELECT person_id FROM urls WHERE url='{$url}'", $db));
$person_id = $person_id['person_id'];
}
//end if id
if (!$person_id) {
die('No profile found!');
}
if (!isset($_GET['contacts'])) {
$person = mysql_fetch_assoc(mysql_query("SELECT * FROM people WHERE person_id={$person_id}", $db));
echo "\t\t" . '<div id="profile" class="vcard">' . "\n";
$photos = mysql_query("SELECT value FROM fields WHERE type='photo' AND person_id={$person_id}", $db);
if (mysql_num_rows($photos)) {
示例5: normalize_url
<?php
require_once 'xn-app://someblogs/normalize_url.php';
$_REQUEST['url'] = normalize_url($_REQUEST['url']);
require_once 'is_junkblog.php';
$item = is_junkblog($_REQUEST['url']);
if ($_REQUEST['format'] == 'xml') {
header('Content-Type: application/xml;charset=utf-8');
echo '<blog>' . "\n";
echo ' <result>' . ($item && $item->my->verify ? '1' : '0') . '</result>' . "\n";
echo ' <blog_url>' . htmlspecialchars($_REQUEST['url']) . '</blog_url>';
echo '</blog>';
} else {
if ($item) {
echo '<h2>Blog Found!</h2><p>' . htmlspecialchars($_REQUEST['url']) . ($item->my->verify ? " is a 'junk' blog. If you think this listing is in error, please contact us using the 'Report This App' feature from the 'Popular' tab of the Ningbar, above." : " has been suggested as a 'junk' blog. If you think this listing is in error, please vote 'Not Junk' on <a href=\"/\">the main page</a>.") . '</p>';
} else {
echo '<h2>Blog Not Found!</h2><p>' . htmlspecialchars($_REQUEST['url']) . " is not a 'junk' blog.</p>";
}
echo '<br /><p><a href="?url=' . $_REQUEST['url'] . '&format=xml">Get these results as XML</a></p>';
}
//end if-else format
示例6: explode
//end while person = fetch people
echo "], ";
}
//end if-else num_rows people
return $matches;
}
//end function print_results
$n = explode(' ', $_GET['q']);
$nickname = mysql_real_escape_string($_GET['q'], $db);
$given_name = mysql_real_escape_string(array_shift($n), $db);
$family_name = mysql_real_escape_string(array_pop($n), $db);
$additional_name = mysql_real_escape_string(implode(' ', $n), $db);
$results = 0;
if ($_GET['pov']) {
require 'normalize_url.php';
$pov = @mysql_fetch_assoc(mysql_query("SELECT person_id FROM urls WHERE url='" . mysql_real_escape_string(normalize_url($_GET['pov']), $db) . "'"));
$pov = intval($pov['person_id']);
$people = mysql_query("SELECT people.person_id,people.fn,urls.url FROM contacts,urls,people WHERE contacts.person_id={$pov} AND contacts.url=urls.url AND urls.person_id=people.person_id AND people.fn LIKE '%{$nickname}%'", $db) or die(mysql_error());
$results += print_results($people, $db, 'Matches from Contacts');
}
//end if pov
$people = mysql_query("SELECT person_id,fn FROM people WHERE `given-name` LIKE '%{$given_name}%' AND `family-name` LIKE '%{$family_name}%' AND `additional-name` LIKE '%{$additional_name}%'" . ($_GET['count'] ? ' LIMIT ' . intval($_GET['count']) : ''), $db) or die(mysql_error());
$results += print_results($people, $db, 'Exact matches');
$people = mysql_query("SELECT person_id,value AS fn FROM fields WHERE value LIKE '%{$nickname}%' AND (type='nickname' OR type='email')" . ($_GET['count'] ? ' LIMIT ' . intval($_GET['count'] - $results) : ''), $db) or die(mysql_error());
$results += print_results($people, $db, 'Nickname matches');
$people = mysql_query("SELECT person_id,fn FROM people WHERE fn LIKE '%{$nickname}%'" . ($_GET['count'] ? ' LIMIT ' . intval($_GET['count'] - $results) : ''), $db) or die(mysql_error());
$results += print_results($people, $db, 'Fuzzy matches');
echo '}';
if ($_GET['callback']) {
echo ')';
}
示例7: get_url
/**
* build a reference to a server
*
* Depending on parameter '[code]with_friendly_urls[/code]' and on action,
* following results can be observed:
*
* - view - servers/view.php?id=123 or servers/view.php/123 or server-123
*
* - other - servers/edit.php?id=123 or servers/edit.php/123 or server-edit/123
*
* @param int the id of the server to handle
* @param string the expected action ('view', 'print', 'edit', 'delete', ...)
* @return string a normalized reference
*
* @see control/configure.php
*/
public static function get_url($id, $action = 'view')
{
global $context;
// check the target action
if (!preg_match('/^(delete|edit|test|view)$/', $action)) {
return 'servers/' . $action . '.php?id=' . urlencode($id);
}
// normalize the link
return normalize_url(array('servers', 'server'), $action, $id);
}
示例8: get_url
/**
* build a reference to a section
*
* Depending on parameter '[code]with_friendly_urls[/code]' and on action,
* following results can be observed:
*
* - view - sections/view.php?id=123 or sections/view.php/123 or section-123
*
* - other - sections/edit.php?id=123 or sections/edit.php/123 or section-edit/123
*
* If a fourth parameter is provided, it will take over the third one. This
* is used to leverage nick names in YACS, as per the following invocation:
* [php]
* Sections::get_url($item['id'], 'view', $item['title'], $item['nick_name']);
* [/php]
*
* @param int the id of the section to handle
* @param string the expected action ('view', 'print', 'edit', 'delete', ...)
* @param string additional data, such as section nick name, if any
* @param string alternate name, if any, to take over on previous parameter
* @return string a normalized reference
*
* @see control/configure.php
*/
public static function get_url($id, $action = 'view', $name = NULL, $alternate_name = NULL)
{
global $context;
// use nick name instead of regular name, if one is provided
if ($alternate_name && $context['with_alternate_urls'] == 'Y') {
$name = str_replace('_', ' ', $alternate_name);
}
// the service to check for updates
if ($action == 'check') {
if ($context['with_friendly_urls'] == 'Y') {
return 'services/check.php/section/' . rawurlencode($id);
} elseif ($context['with_friendly_urls'] == 'R') {
return 'services/check.php?id=' . urlencode('section:' . $id);
} else {
return 'services/check.php?id=' . urlencode('section:' . $id);
}
}
// the RSD link
if ($action == 'EditURI') {
if ($context['with_friendly_urls'] == 'Y') {
return 'services/describe.php/' . rawurlencode($id);
} elseif ($context['with_friendly_urls'] == 'R') {
return 'services/describe.php/' . rawurlencode($id);
} else {
return 'services/describe.php?anchor=' . urlencode($id);
}
}
// the rss feed for files --deprecated to files::get_url()
if ($action == 'files') {
if ($context['with_friendly_urls'] == 'Y') {
return 'files/feed.php/section/' . rawurlencode($id);
} elseif ($context['with_friendly_urls'] == 'R') {
return 'files/feed.php/section/' . rawurlencode($id);
} else {
return 'files/feed.php?anchor=' . urlencode('section:' . $id);
}
}
// invite someone to participate
if ($action == 'invite') {
if ($name) {
return 'sections/invite.php?id=' . urlencode($id) . '&invited=' . urlencode($name);
} else {
return 'sections/invite.php?id=' . urlencode($id);
}
}
// the prefix for managing content
if ($action == 'manage') {
if ($name) {
return 'sections/manage.php?id=' . urlencode($id) . '&' . urlencode($name) . '=';
} else {
return 'sections/manage.php?id=' . urlencode($id);
}
}
// check the target action
if (!preg_match('/^(delete|describe|duplicate|edit|export|feed|import|invite|lock|mail|navigate|own|print|view)$/', $action)) {
return 'sections/' . $action . '.php?id=' . urlencode($id) . '&action=' . urlencode($name);
}
// normalize the link
return normalize_url(array('sections', 'section'), $action, $id, $name);
}
示例9: get_url
/**
* build a reference to a image
*
* Depending on parameter '[code]with_friendly_urls[/code]' and on action,
* following results can be observed:
*
* - view - images/view.php?id=123 or images/view.php/123 or image-123
*
* - other - images/edit.php?id=123 or images/edit.php/123 or image-edit/123
*
* @param int the id of the image to handle
* @param string the expected action ('view', 'print', 'edit', 'delete', ...)
* @return string a normalized reference
*
* @see control/configure.php
*/
public static function get_url($id, $action = 'view')
{
global $context;
// check the target action
if (!preg_match('/^(delete|edit|set_as_icon|set_as_thumbnail|view)$/', $action)) {
return 'images/' . $action . '.php?id=' . urlencode($id);
}
// normalize the link
return normalize_url(array('images', 'image'), $action, $id);
}
示例10: json_response
$channel->type = 'feeds';
$channel->save();
json_response($app, ['result' => 'ok']);
}
});
$app->post('/channels/discover', function ($format = 'json') use($app) {
if ($user = require_login_json($app)) {
$params = $app->request()->params();
// $feeds = array(
// array('url' => 'http://pk.dev/', 'display_url' => friendly_url('http://pk.dev/'), 'type' => 'microformats2'),
// array('url' => 'http://pk.dev/articles.atom', 'display_url' => friendly_url('http://pk.dev/articles.atom'), 'type' => 'atom')
// );
$feeds = [];
// Parse the URL and check for microformats h-entry posts, as well as linked rss or atom feeds
$html = request\get_url($params['url']);
$url = normalize_url($params['url']);
if ($html) {
$mf2 = feeds\parse_mf2($html, $params['url']);
// check if there are any h-entry posts
$feed = feeds\find_feed_info($mf2);
if ($feed) {
$feeds[] = ['url' => $url, 'display_url' => friendly_url($url), 'icon' => '<i class="icon-microformats"></i>', 'enabled' => true];
}
$alternates = feeds\get_alternates($mf2);
foreach ($alternates as $alt) {
$feeds[] = ['url' => $alt['url'], 'display_url' => friendly_url($alt['url']), 'icon' => '<i class="fa fa-rss"></i>', 'enabled' => false];
}
}
json_response($app, ['feeds' => $feeds]);
}
});
示例11: respond
<?php
// Check for content based on URL
$href = $db->escape(normalize_url(@$_POST['href']));
// Sanity check
if (empty($href)) {
respond(0, "Please specify an 'href' argument.");
}
$response = array();
if (empty($user)) {
// Only check for public content
$response['count'] = $db->value("\n SELECT COUNT(id)\n FROM shift\n WHERE status = 1\n AND href = '{$href}'\n ");
} else {
// Check for both public and private content
$response['count'] = $db->value("\n SELECT COUNT(s.id)\n FROM shift s,\n user u\n WHERE (\n s.status = 1\n OR (\n s.status = 2\n AND s.user_id = {$user->id}\n )\n )\n AND s.user_id = u.id\n AND s.href = '{$href}'\n ");
$response['username'] = $user->username;
$response['email'] = $user->email;
}
// Done
respond(1, $response);
示例12: get_url
/**
* build a reference to a category
*
* Depending on parameter '[code]with_friendly_urls[/code]' and on action,
* following results can be observed:
*
* - view - categories/view.php?id=123 or categories/view.php/123 or categorie-123
*
* - other - categories/edit.php?id=123 or categories/edit.php/123 or category-edit/123
*
* @param int the id of the category to handle
* @param string the expected action ('view', 'print', 'edit', 'delete', ...)
* @param string additional data, such as category name, if any
* @return string a normalized reference
*
* @see control/configure.php
*/
public static function get_url($id, $action = 'view', $name = NULL)
{
global $context;
// select a category for an anchor
if ($action == 'select') {
return 'categories/select.php?anchor=' . urlencode($id);
}
// check the target action
if (!preg_match('/^(delete|describe|edit|feed|mail|navigate|print|view)$/', $action)) {
return 'categories/' . $action . '.php?id=' . urlencode($id) . '&action=' . urlencode($name);
}
// normalize the link
return normalize_url(array('categories', 'category'), $action, $id, $name);
}
示例13: get_url
/**
* build a reference to a user
*
* Depending on parameter '[code]with_friendly_urls[/code]' and on action,
* following results can be observed:
*
* - view - users/view.php?id=123 or users/view.php/123 or user-123
*
* - other - users/edit.php?id=123 or users/edit.php/123 or user-edit/123
*
* @param int the id of the user to handle
* @param string the expected action ('view', 'print', 'edit', 'delete', ...)
* @param string user name
* @return string a normalized reference
*
* @see control/configure.php
*/
public static function get_url($id, $action = 'view', $name = NULL)
{
global $context;
// track something -- the id has to be an anchor (e.g., 'article:15')
if ($action == 'track') {
if ($context['with_friendly_urls'] == 'Y') {
return 'users/track.php/' . str_replace(':', '/', $id);
} elseif ($context['with_friendly_urls'] == 'R') {
return 'users/track.php/' . str_replace(':', '/', $id);
} else {
return 'users/track.php?anchor=' . urlencode($id);
}
}
// assign users to an anchor
if ($action == 'select') {
return 'users/select.php?member=' . urlencode($id);
}
// list watchers
if ($action == 'watch') {
return 'users/select.php?anchor=' . urlencode($id);
}
// check the target action
if (!preg_match('/^(contact|delete|describe|edit|element|feed|fetch_vcard|leave|mail|navigate|password|print|select_avatar|share|transfer|validate|view|visit)$/', $action)) {
return 'users/' . $action . '.php?id=' . urlencode($id) . '&action=' . urlencode($name);
}
// // view user profile --use only the nick name, since it is unique
// if(($action == 'view') && $name) {
// $id = $name;
// $name = '';
// }
// normalize the link
return normalize_url(array('users', 'user'), $action, $id, $name);
}
示例14: social_networking_get_normalized_urls
function social_networking_get_normalized_urls($url, $level = 0)
{
global $social_networking_normalized_urls;
$openIDc = new WordpressOpenIDRegistration();
$page = social_networking_getTidy($url);
if (is_int($url[strlen($url) - 1])) {
unset($url[strlen($url) - 1]);
}
$social_networking_normalized_urls[] = $openIDc->normalize_username(normalize_url($url));
$theParser = xml_parser_create();
xml_parse_into_struct($theParser, $page, $vals);
xml_parser_free($theParser);
foreach ($vals as $el) {
if (!in_array('me', explode(' ', strtolower(trim($el['attributes']['REL']))))) {
continue;
}
$el['attributes']['HREF'] = trim($el['attributes']['HREF']);
if (!$level) {
social_networking_get_normalized_urls($el['attributes']['HREF'], $level + 1);
}
if (is_int($el['attributes']['HREF'][strlen($el['attributes']['HREF']) - 1])) {
unset($el['attributes']['HREF'][strlen($el['attributes']['HREF']) - 1]);
}
$tmp[] = $openIDc->normalize_username(normalize_url($el['attributes']['HREF']));
}
//end foreach vals as el
}
示例15: process_avatarurl
function process_avatarurl($url)
{
global $vbulletin;
if ($url == '') {
return;
}
if (stripos($url, 'http:') !== false) {
return reverse_htmlentities(normalize_url($url));
} else {
if (is_vb()) {
if (strpos($url, '/') === 0) {
$host = parse_url($vbulletin->options['bburl']);
return normalize_url($host['scheme'] . '://' . $host['host'] . reverse_htmlentities($url));
} else {
return normalize_url($vbulletin->options['bburl'] . '/' . reverse_htmlentities($url));
}
} else {
if (is_phpbb()) {
return normalize_url(fr_get_phpbb_bburl() . reverse_htmlentities($url));
} else {
if (is_xen()) {
return normalize_url(fr_get_xenforo_bburl() . '/' . reverse_htmlentities($url));
}
}
}
}
}