本文整理汇总了PHP中is_valid_url函数的典型用法代码示例。如果您正苦于以下问题:PHP is_valid_url函数的具体用法?PHP is_valid_url怎么用?PHP is_valid_url使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_valid_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
function handle(array $record)
{
$message = $record['message'];
$class = "";
if ($record['level'] >= Logger::WARNING) {
if ($record['level'] >= Logger::ERROR) {
$class = "error";
$message = "[ERROR] " . $message;
} else {
$class = "warning";
$message = "[Warning] " . $message;
}
}
echo "<li class=\"{$class}\">";
// if it's ONLY a link_to(), then render it as a link
if (preg_match("#^(.*?)(<a href=\"[^\"<]+\">[^<]+</a>)\$#s", $message, $matches)) {
echo htmlspecialchars($matches[1]) . $matches[2];
} else {
if (is_valid_url($message)) {
echo link_to($message, $message);
} else {
echo htmlspecialchars($message);
}
}
echo "</li>\n";
}
示例2: validateOpenID
/**
* Try do OpenID validation (with the given redirect).
* @return the validated LightOpenID object on success
* @throws UserSignupException if anything bad happened
*/
static function validateOpenID($openid, $redirect)
{
if (!is_valid_url($openid)) {
throw new UserSignupException("That is not a valid OpenID identity.");
}
if (!$redirect) {
throw new \InvalidArgumentException("No redirect provided.");
}
$light = new \LightOpenID(\Openclerk\Config::get("openid_host"));
if (!$light->mode) {
// we still need to authenticate
$light->identity = $openid;
$light->returnUrl = $redirect;
redirect($light->authUrl());
return false;
} else {
if ($light->mode == 'cancel') {
// user has cancelled
throw new UserSignupException("User has cancelled authentication.");
} else {
// otherwise login as necessary
// optionally check for abuse etc
if (!\Openclerk\Events::trigger('openid_validate', $light)) {
throw new UserSignupException("Login was cancelled by the system.");
}
if ($light->validate()) {
return $light;
} else {
$error = $light->validate_error ? $light->validate_error : "Please try again.";
throw new UserSignupException("OpenID validation was not successful: " . $error);
}
}
}
}
示例3: addScript
function addScript($url, $plugin)
{
if (!isset($this->scripts)) {
$this->scripts = array();
}
$this->scripts[] = is_valid_url($url) ? $url : get_javascript_url($url, $plugin, true);
}
示例4: executeGet
public function executeGet()
{
$valid = $this->hasRequiredParameters($this->requiredParams);
if ($valid instanceof Frapi_Error) {
return $valid;
}
/*
get the url param and decode it
*/
$url = $this->getParam('url');
$url = urldecode($url);
/*
if we're missing 'http' at the beginning, add it
*/
if (!stristr($url, 'http')) {
$url = 'http://' . $url;
}
if (!is_valid_url($url)) {
throw new Frapi_Error('ERROR_INVALID_URL');
}
try {
$model = new Spaz_Urlinfo($url);
$res = $model->get();
} catch (Exception $e) {
throw new Frapi_Error($e->getMessage());
}
$this->data = $res;
return $this->toArray();
}
示例5: paper_presentation
public function paper_presentation()
{
$user_nick = $this->auth->get_user();
$user_details = $this->model->is_registered_for_paper_presentation($user_nick);
$errors = [];
if (!$user_details && $_SERVER['REQUEST_METHOD'] === 'POST') {
required_post_params(['contact_number', 'paper_link'], $errors);
if (!empty($_POST['contact_number']) && !is_valid_phone_number($_POST['contact_number'])) {
$errors['contact_number'] = 'Please enter a valid phone number';
}
if (!empty($_POST['paper_link']) && !is_valid_url($_POST['paper_link'])) {
$errors['paper_link'] = 'Please enter a valid link';
}
if (!$errors) {
$user_details = ['nick' => $user_nick, 'contact_number' => $_POST['contact_number'], 'paper_link' => $_POST['paper_link']];
$success = $this->model->register_for_paper_presentation($user_details);
if (!$success) {
$errors['common'] = 'Some unexpected error occured';
}
}
}
$this->load_view('skeleton_template/header', ['title' => __('Register') . ' · ' . __('Paper Presentation'), 'is_authenticated' => true, 'user_nick' => $user_nick]);
$this->load_view('contest/paper_presentation', ['user_details' => $user_details, 'errors' => $errors]);
$this->load_view('skeleton_template/footer');
}
示例6: edit_check
private function edit_check(&$category_id, &$name, &$url, &$error)
{
$error = '';
$category_id = isset($_POST['category_id']) ? (int) $_POST['category_id'] : '';
$name = isset($_POST['name']) ? trim($_POST['name']) : '';
$url = isset($_POST['url']) ? trim($_POST['url']) : '';
if (empty($category_id)) {
$error = '所属分类是必需的!';
} elseif ($name === '') {
$error = '名称是必需的!';
} elseif ($url === '') {
$error = '网址是必需的!';
} elseif (!is_valid_url($url)) {
$error = '网址格式不正确!';
}
}
示例7: executeGet
public function executeGet()
{
$valid = $this->hasRequiredParameters($this->requiredParams);
if ($valid instanceof Frapi_Error) {
return $valid;
}
/*
get the url param and decode it
*/
$url = $this->getParam('url');
$url = urldecode($url);
/*
if we're missing 'http' at the beginning, add it
*/
if (!stristr($url, 'http')) {
$url = 'http://' . $url;
}
if (!is_valid_url($url)) {
throw new Frapi_Error('ERROR_INVALID_URL');
}
try {
$model = new Spaz_Urlinfo($url);
$res = $model->get();
} catch (Exception $e) {
throw new Frapi_Error($e->getMessage());
}
/*
is content type html?
*/
if (stripos($res['content_type'], 'text/html') !== FALSE || stripos($res['content_type'], 'application/xhtml+xml' !== FALSE)) {
try {
$model = new Spaz_Urltitle($url);
$res = $model->get();
} catch (Exception $e) {
throw new Frapi_Error($e->getMessage());
}
} else {
$title = $res['content_type'];
$size = (int) $res['download_content_length'];
if ($size > 0) {
$title .= ' ' . $this->formatBytes($size);
}
$res = array('title' => $title);
}
$this->data = $res;
return $this->toArray();
}
示例8: validate
protected function validate(&$data, $nonce_name)
{
# check in parent class if nonce is legal
$is_valid = parent::validate($data, $nonce_name);
if ($is_valid && is_array($data)) {
$is_valid = true;
if (empty($data["venue_name"])) {
$is_valid = false;
$this->add_db_result("venue_name", "required", "Name is missing");
}
if (empty($data["venue_country"])) {
$is_valid = false;
$this->add_db_result("venue_country", "required", "Country is missing");
} else {
$country_code = get_country_by_name($data["venue_country"]);
if (!$country_code) {
$is_valid = false;
$this->add_db_result("venue_country", "field", "Country doesn't exist");
}
}
if (!empty($data["venue_state"]) && $country_code == "US") {
$state_code = get_state_by_name($data["venue_state"]);
if (!$state_code) {
$state_code = get_state_by_code(strtoupper($data["venue_state"]));
}
if (!$state_code) {
$is_valid = false;
$this->add_db_result("venue_state", "field", "The U.S State code is invalid.");
}
} else {
if ($country_code == "US") {
$is_valid = false;
$this->add_db_result("venue_state", "field", "State is missing");
}
}
if (!empty($data["venue_url"]) && !is_valid_url($data["venue_url"])) {
$is_valid = false;
$this->add_db_result("venue_url", "required", "Venue website in not valid, the required format is http://your_website_url");
}
if (!$is_valid) {
$this->db_result("error", null, array("data" => $this->db_response_msg));
}
}
return $is_valid;
}
示例9: handle_fatal_error
/**
* Handle fatal error
*
* @param Error $error
* @return null
*/
function handle_fatal_error($error)
{
if (DEBUG >= DEBUG_DEVELOPMENT) {
dump_error($error);
} else {
if (instance_of($error, 'RoutingError') || instance_of($error, 'RouteNotDefinedError')) {
header("HTTP/1.1 404 Not Found");
print '<h1>Not Found</h1>';
if (instance_of($error, 'RoutingError')) {
print '<p>Page "<em>' . clean($error->getRequestString()) . '</em>" not found.</p>';
} else {
print '<p>Route "<em>' . clean($error->getRouteName()) . '</em>" not mapped.</p>';
}
// if
print '<p><a href="' . assemble_url('homepage') . '">« Back to homepage</a></p>';
die;
}
// if
// Send email to administrator
if (defined('ADMIN_EMAIL') && is_valid_email(ADMIN_EMAIL)) {
$content = '<p>Hi,</p><p>activeCollab setup at ' . clean(ROOT_URL) . ' experienced fatal error. Info:</p>';
ob_start();
dump_error($error, false);
$content .= ob_get_clean();
@mail(ADMIN_EMAIL, 'activeCollab Crash Report', $content, "Content-Type: text/html; charset=utf-8");
}
// if
// log...
if (defined('ENVIRONMENT_PATH') && class_exists('Logger')) {
$logger =& Logger::instance();
$logger->logToFile(ENVIRONMENT_PATH . '/logs/' . date('Y-m-d') . '.txt');
}
// if
}
// if
$error_message = '<div style="text-align: left; background: white; color: red; padding: 7px 15px; border: 1px solid red; font: 12px Verdana; font-weight: normal;">';
$error_message .= '<p>Fatal error: activeCollab has failed to executed your request (reason: ' . clean(get_class($error)) . '). Information about this error has been logged and sent to administrator.</p>';
if (is_valid_url(ROOT_URL)) {
$error_message .= '<p><a href="' . ROOT_URL . '">« Back to homepage</a></p>';
}
// if
$error_message .= '</div>';
print $error_message;
die;
}
示例10: do_bbcode_url
function do_bbcode_url($action, $attributes, $content, $params, &$node_object)
{
// 1) the code is being valided
if ($action == 'validate') {
// the code is specified as follows: [url]http://.../[/url]
if (!isset($attributes['default'])) {
// is this a valid URL?
return is_valid_url($content);
}
// the code is specified as follows: [url=http://.../]Text[/url]
// is this a valid URL?
return is_valid_url($attributes['default']);
} else {
// the code was specified as follows: [url]http://.../[/url]
if (!isset($attributes['default'])) {
return '<a href="' . htmlspecialchars($content) . '">' . htmlspecialchars($content) . '</a>';
}
// the code was specified as follows: [url=http://.../]Text[/url]
return '<a href="' . htmlspecialchars($attributes['default']) . '">' . $content . '</a>';
}
}
示例11: redirect
function redirect($uri = '', $method = 'location', $http_response_code = 302)
{
if (IS_CLI) {
if (!defined('PHPUNIT_TEST')) {
echo "Redirecting: {$uri}\n";
exit;
} else {
return;
}
}
if (!is_valid_url($uri)) {
$uri = site_url($uri);
}
switch ($method) {
case 'refresh':
header("Refresh:0;url=" . $uri);
break;
default:
header("Location: " . $uri, TRUE, $http_response_code);
break;
}
exit;
}
示例12: path
function path($file, $file_type = '', $paths = array())
{
if (func_num_args() == 1) {
static $paths = array();
if (!isset($paths[$file])) {
$paths[$file] = NeoFrag::loader()->db->select('path')->from('nf_files')->where('file_id', $file)->row();
}
return $paths[$file] ? url($paths[$file]) : '';
} else {
if (is_valid_url($file)) {
return $file;
}
if (!$paths) {
$paths = NeoFrag::loader()->load->paths['assets'];
}
if (!in_array($file_type, array('images', 'css', 'js'))) {
NeoFrag::loader()->profiler->log(NeoFrag::loader()->lang('invalide_filetype'), Profiler::WARNING);
return url($file_type . '/' . $file);
}
//json_encode backslashe les /
$file = str_replace('\\/', '/', $file);
static $assets;
if (!isset($assets[$checksum = md5(serialize($paths))][$file_type][$file])) {
foreach ($paths as $path) {
if (file_exists($file_path = $path . '/' . $file_type . '/' . $file)) {
return $assets[$checksum][$file_type][$file] = url(trim_word($file_path, './'));
}
}
} else {
return $assets[$checksum][$file_type][$file];
}
if (file_exists($file)) {
return url($file);
}
return url($file_type . '/' . $file);
}
}
示例13: foaf_password
function foaf_password($config, $realm, $authreqissuer)
{
/*
print "<pre>";
print_r($_SERVER);
print "</pre>";
*/
if (empty($_SERVER['HTTP_AUTHORIZATION'])) {
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Digest realm="' . $realm . '",qop="auth,auth-int",nonce="' . uniqid() . '",opaque="' . md5($realm) . '"');
// failed_password_check('Authentication was cancelled', $authreqissuer);
die;
}
// analyze the PHP_AUTH_DIGEST variable
if (!($data = http_digest_parse($_SERVER['HTTP_AUTHORIZATION']))) {
failed_password_check('HTTP Digest was incomplete', $authreqissuer);
}
//$uri = 'http://'. $data['username'];
$uri = $data['username'];
$uri = urldecode($uri);
if (!is_valid_url($uri)) {
// $errmsg = "Authentication Failed - $uri is not a valid username for this service";
// failed_password_check($errmsg, $authreqissuer);
$agent = NULL;
} else {
$agent = get_agent($uri);
}
// set up db
$db = new db_class();
$db->connect('localhost', $config['db_user'], $config['db_pwd'], $config['db_name']);
$webid = isset($agent) ? $agent['agent']['webid'] : '';
// $sql ='select password from passwords where webid="'. $webid . '" or mbox = "' . $data['username'] . '" and active = 1 and verified_mbox = 1 ';
$sql = 'select password from passwords where webid="' . $webid . '" and active = 1 and verified_mbox = 1 ';
// print $sql . "<br/>";
$results = $db->select($sql);
if ($row = mysql_fetch_assoc($results)) {
$pin = $row['password'];
// generate the valid response
$A1 = md5($data['username'] . ':' . $realm . ':' . $pin);
$A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']);
$valid_response = md5($A1 . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $A2);
/*
print "<br/>A1 = md5 ( username= " . $data['username'] . " :realm= " . $realm . " :password/pin= ". $pin . ")<br/>";
print "A2 = md5 ( request_method = " . $_SERVER['REQUEST_METHOD']. " uri = " . $data['uri'] . ")<br/>";
print "valid = md5 ( A1 : nonce= " . $data['nonce'] . " :nc= " . $data['nc'] . " :cnonce= " . $data['cnonce'] . " :qop= " . $data['qop'] . ")<br/>";
print "valid response = " . $valid_response . "<br/><br/>";
print "http digest response = " . $data['response'] . "<br/><br/>";
*/
if ($valid_response == $data['response']) {
// print "auth " . $authreqissuer . "<br/><br/>";
// print "webid " . $agent['agent']['webid'] . "<br/><br/>";
if (isset($authreqissuer)) {
webid_redirect($authreqissuer, $agent['agent']['webid']);
} else {
login_screen($agent['agent']['webid']);
}
} else {
failed_password_check('FOAF Password doesnot match', $authreqissuer);
}
} else {
failed_password_check('FOAF Password doesnot match', $authreqissuer);
}
}
示例14: delete_avatar
/**
* Delete avatar
*
* @param void
* @return null
*/
function delete_avatar()
{
$user = Contacts::findById(get_id());
if (!($user instanceof Contact && $user->isUser()) || $user->getDisabled()) {
flash_error(lang('user dnx'));
ajx_current("empty");
return;
}
// if
if (!$user->canUpdateProfile(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
// if
$redirect_to = array_var($_GET, 'redirect_to');
if (trim($redirect_to) == '' || !is_valid_url($redirect_to)) {
$redirect_to = $user->getUpdateAvatarUrl();
}
// if
tpl_assign('redirect_to', $redirect_to);
if (!$user->hasAvatar()) {
flash_error(lang('avatar dnx'));
ajx_current("empty");
return;
}
// if
try {
DB::beginWork();
$user->setUpdatedOn(DateTimeValueLib::now());
$user->deleteAvatar();
$user->save();
ApplicationLogs::createLog($user, ApplicationLogs::ACTION_EDIT);
DB::commit();
flash_success(lang('success delete avatar'));
ajx_current("back");
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error delete avatar'));
ajx_current("empty");
}
// try
}
示例15: product_signature
echo $content_for_sidebar;
?>
</div>
<?php
}
// if
?>
<div class="clear"></div>
</div>
</div>
<!--Footer -->
<div id="footer">
<div id="copy">
<?php
if (is_valid_url($owner_company_homepage = owner_company()->getHomepage())) {
?>
<?php
echo lang('footer copy with homepage', date('Y'), $owner_company_homepage, clean(owner_company()->getName()));
} else {
?>
<?php
echo lang('footer copy without homepage', date('Y'), clean(owner_company()->getName()));
}
// if
?>
</div>
<div id="productSignature"><?php
echo product_signature();
?>
<span id="request_duration"><?php