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

PHP validate_url函数代码示例

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

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



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

示例1: validate_avatar

function validate_avatar($avatar_url)
{
    validate_url($avatar_url);

    if(!preg_match('/.+\.jpg/', $avatar_url))
        throw new invalid_avatar_exception();

    $image_size = @getimagesize($avatar_url);

    if($image_size === false)
        throw new invalid_avatar_exception();

    if($image_size[0] != 100 || $image_size[1] != 100)
        throw new invalid_avatar_exception();
}
开发者ID:robehickman,项目名称:decentralised_microblogging_system,代码行数:15,代码来源:users.php


示例2: index

    function index()
    {
        if(!isset($_SESSION['active_user']))
            redirect_to(make_url("users"));

        $usr = instance_model('users');
        $user = $usr->get_user_by_id($_SESSION['active_user']['id']);

        if($user == array())
            throw new no_such_user_exception();

        if(!isset($_POST['Submit']))
        {
            $form_vals = array(
                $user[0]['E-mail'],
                $user[0]['Full_name'],
                $user[0]['Location'],
                $user[0]['Web'],
                $user[0]['Bio']);

        // Display main
            $view = instance_view("settings_main");
            $view = $view->parse_to_variable(array(
                'form_vals' => $form_vals));
        }
        else
        {
            $form_vals = $_POST;

        // Validate email
            try {
                validate_email($form_vals[0]);
            } catch(exception $e) {
                new_flash('Email address is invalid', 1);
                $form_vals[0] = $user[0]['E-mail'];
            }

        // Validate full name
            try {
                validate_50($form_vals[1]);
            } catch(exception $e) {
                new_flash('Full name is too long, max 50 chars', 1);
                $form_vals[1] = $user[0]['User_name'];
            }
            
        // Validate location
            try {
                validate_50($form_vals[2]);
            } catch(exception $e) {
                new_flash('Location is too long, max 50 chars', 1);
                $form_vals[2] = $user[0]['Location'];
            }

        // Validate web
            try {
                validate_url($form_vals[3]);
            } catch(exception $e) {
                new_flash('Website URL is invalid', 1);
                $form_vals[3] = $user[0]['Web'];
            }

        // Validate bio
            try {
                validate_bio($form_vals[4]);
            } catch(exception $e) {
                new_flash('Bio is invalid', 1);
                $form_vals[4] = $user[0]['Bio'];
            }

            if(count(get_errors()) == 0)
            {
            // Everything was vald, save updated user options
                $usr->update_user(
                    $user[0]['ID'],
                    $form_vals[0],
                    $form_vals[1],
                    $form_vals[2],
                    $form_vals[3],
                    $form_vals[4]);

                redirect_to(make_url('settings'));
            }
            else
            {
            // Something was invalid, redisplay main
                $view = instance_view("settings_main");
                $view = $view->parse_to_variable(array(
                    'form_vals' => $form_vals));
            }
        }

    // Display sidebar
        $sb_view = instance_view("settings_sidebar");
        $sb_view = $sb_view->parse_to_variable(array(
            'uid'   => $_SESSION['active_user']['id'],
            'uname' => $_SESSION['active_user']['name']));

        $this->set_template_paramiters(
            array('main_content' => $view,
                  'sidebar'      => $sb_view));
//.........这里部分代码省略.........
开发者ID:robehickman,项目名称:decentralised_microblogging_system,代码行数:101,代码来源:settings.php


示例3: create_user

function create_user($arr)
{
    // Required: { username, nickname, email } or { openid_url }
    $a = get_app();
    $result = array('success' => false, 'user' => null, 'password' => '', 'message' => '');
    $using_invites = get_config('system', 'invitation_only');
    $num_invites = get_config('system', 'number_invites');
    $invite_id = x($arr, 'invite_id') ? notags(trim($arr['invite_id'])) : '';
    $username = x($arr, 'username') ? notags(trim($arr['username'])) : '';
    $nickname = x($arr, 'nickname') ? notags(trim($arr['nickname'])) : '';
    $email = x($arr, 'email') ? notags(trim($arr['email'])) : '';
    $openid_url = x($arr, 'openid_url') ? notags(trim($arr['openid_url'])) : '';
    $photo = x($arr, 'photo') ? notags(trim($arr['photo'])) : '';
    $password = x($arr, 'password') ? trim($arr['password']) : '';
    $blocked = x($arr, 'blocked') ? intval($arr['blocked']) : 0;
    $verified = x($arr, 'verified') ? intval($arr['verified']) : 0;
    $publish = x($arr, 'profile_publish_reg') && intval($arr['profile_publish_reg']) ? 1 : 0;
    $netpublish = strlen(get_config('system', 'directory_submit_url')) ? $publish : 0;
    $tmp_str = $openid_url;
    if ($using_invites) {
        if (!$invite_id) {
            $result['message'] .= t('An invitation is required.') . EOL;
            return $result;
        }
        $r = q("select * from register where `hash` = '%s' limit 1", dbesc($invite_id));
        if (!results($r)) {
            $result['message'] .= t('Invitation could not be verified.') . EOL;
            return $result;
        }
    }
    if (!x($username) || !x($email) || !x($nickname)) {
        if ($openid_url) {
            if (!validate_url($tmp_str)) {
                $result['message'] .= t('Invalid OpenID url') . EOL;
                return $result;
            }
            $_SESSION['register'] = 1;
            $_SESSION['openid'] = $openid_url;
            require_once 'library/openid.php';
            $openid = new LightOpenID();
            $openid->identity = $openid_url;
            $openid->returnUrl = $a->get_baseurl() . '/openid';
            $openid->required = array('namePerson/friendly', 'contact/email', 'namePerson');
            $openid->optional = array('namePerson/first', 'media/image/aspect11', 'media/image/default');
            try {
                $authurl = $openid->authUrl();
            } catch (Exception $e) {
                $result['message'] .= t("We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.") . EOL . EOL . t("The error message was:") . $e->getMessage() . EOL;
                return $result;
            }
            goaway($authurl);
            // NOTREACHED
        }
        notice(t('Please enter the required information.') . EOL);
        return;
    }
    if (!validate_url($tmp_str)) {
        $openid_url = '';
    }
    $err = '';
    // collapse multiple spaces in name
    $username = preg_replace('/ +/', ' ', $username);
    if (mb_strlen($username) > 48) {
        $result['message'] .= t('Please use a shorter name.') . EOL;
    }
    if (mb_strlen($username) < 3) {
        $result['message'] .= t('Name too short.') . EOL;
    }
    // I don't really like having this rule, but it cuts down
    // on the number of auto-registrations by Russian spammers
    //  Using preg_match was completely unreliable, due to mixed UTF-8 regex support
    //	$no_utf = get_config('system','no_utf');
    //	$pat = (($no_utf) ? '/^[a-zA-Z]* [a-zA-Z]*$/' : '/^\p{L}* \p{L}*$/u' );
    // So now we are just looking for a space in the full name.
    $loose_reg = get_config('system', 'no_regfullname');
    if (!$loose_reg) {
        $username = mb_convert_case($username, MB_CASE_TITLE, 'UTF-8');
        if (!strpos($username, ' ')) {
            $result['message'] .= t("That doesn't appear to be your full (First Last) name.") . EOL;
        }
    }
    if (!allowed_email($email)) {
        $result['message'] .= t('Your email domain is not among those allowed on this site.') . EOL;
    }
    if (!valid_email($email) || !validate_email($email)) {
        $result['message'] .= t('Not a valid email address.') . EOL;
    }
    // Disallow somebody creating an account using openid that uses the admin email address,
    // since openid bypasses email verification. We'll allow it if there is not yet an admin account.
    $adminlist = explode(",", str_replace(" ", "", strtolower($a->config['admin_email'])));
    //if((x($a->config,'admin_email')) && (strcasecmp($email,$a->config['admin_email']) == 0) && strlen($openid_url)) {
    if (x($a->config, 'admin_email') && in_array(strtolower($email), $adminlist) && strlen($openid_url)) {
        $r = q("SELECT * FROM `user` WHERE `email` = '%s' LIMIT 1", dbesc($email));
        if (count($r)) {
            $result['message'] .= t('Cannot use that email.') . EOL;
        }
    }
    $nickname = $arr['nickname'] = strtolower($nickname);
    if (!preg_match("/^[a-z][a-z0-9\\-\\_]*\$/", $nickname)) {
        $result['message'] .= t('Your "nickname" can only contain "a-z", "0-9", "-", and "_", and must also begin with a letter.') . EOL;
//.........这里部分代码省略.........
开发者ID:rahmiyildiz,项目名称:friendica,代码行数:101,代码来源:user.php


示例4: parse

function parse($url)
{
    //parse $url.  Essentially we are going to take what is given and remove any extension
    $url_array = explode(".", $url);
    //define paths
    $url_name = substr($url_array[0], 1);
    $url_html = "templates" . $url_array[0] . ".html";
    $url_php = "scripts/pages" . $url_array[0] . ".php";
    if ($url_array[0] == "/login") {
        serve_login_page();
        return;
    }
    if ($url_array[0] == "/signup") {
        serve_signup_page();
        return;
    }
    if ($_SESSION["logged_in"] !== true) {
        serve_login_page();
        return;
    }
    //validate url
    if (!validate_url($url_html, $url_php)) {
        $url_name = "home";
        $url_html = "templates/home.html";
        $url_php = "scripts/pages/home.php";
    }
    //load generic template file
    $html = file_get_contents("templates/HTMLTemplate");
    //load body file
    $body = file_get_contents($url_html);
    $has_permission = true;
    //clear out permission variable
    //execute page specific php, if it exists
    file_exists($url_php);
    include $url_php;
    //check permission variable against user account.
    //If permission variable not set, die loudly
    if (!$has_permission) {
        return;
    }
    $html = str_replace("==active==", $url_name, $html);
    //push body content into $html
    $html = str_replace("==body==", $body, $html);
    $growl = get_growl();
    $html = str_replace("==growl==", $growl, $html);
    //echo out resulting webpage
    echo $html;
}
开发者ID:arfink,项目名称:BISS-TEA,代码行数:48,代码来源:index.php


示例5: update_user

    function update_user($id, $email, $full_name, $location, $web, $bio)
    {
        $this->verify_user_id($id);
        validate_email($email);
        validate_50($full_name);
        validate_50($location);
        validate_url($web);
        validate_bio($bio);

        $query = "UPDATE `users` SET
            `E-mail` = '@v',
            `Full_name` = '@v',
            `Location` = '@v',
            `Web` = '@v',
            `Bio` = '@v'
            WHERE `ID` = '@v' LIMIT 1";

        $this->query($query, $email, $full_name, $location, $web, $bio, $id);
    }
开发者ID:robehickman,项目名称:Scripts,代码行数:19,代码来源:users.php


示例6: new_dm

    function new_dm($user_id, $type, $remote_name, $remote_profile,
        $remote_avatar, $remote_message, $remote_time)
    {
        $users = instance_model('users');
        $users->verify_user_id($user_id);

        if(!($type == "public" || $type == 'private'))
            throw new invalid_dm_type_exception();

        validate_username($remote_name);
        validate_url($remote_profile);
        validate_avatar($remote_avatar);
        validate_message($remote_message);

        $query = "INSERT INTO `direct-message`
            (`User_ID`, `Type`, `Remote_name`, `Remote_profile`,
                `Remote_avatar`, `Remote_message`, `Remote_time`)
            VALUES ('@v','@v','@v','@v','@v', '@v', '@v')";

        $this->query($query, $user_id, $type, $remote_name,
            $remote_profile, $remote_avatar, $remote_message, $remote_time);
    }
开发者ID:robehickman,项目名称:decentralised_microblogging_system,代码行数:22,代码来源:direct_message.php


示例7: test_validate_url

 function test_validate_url()
 {
     $this->change_global('evo_charset', 'latin1');
     // valid:
     foreach (array('http://b2evolution.net', 'https://demo.b2evolution.net', 'http://[email protected]/path', 'http://user:[email protected]/path', 'mailto:[email protected]', 'mailto:[email protected]?subject=TEST', 'http://lдu.de/', 'http://lдu.de/foo bar') as $url) {
         $r = validate_url($url, 'commenting', false);
         // True means validation ok
         $this->assertFalse($r, $url . ' NOT allowed in comments');
     }
     foreach (array('http://b2evolution.net', 'https://demo.b2evolution.net', 'http://[email protected]/path', 'http://user:[email protected]/path', 'mailto:[email protected]', 'mailto:[email protected]?subject=TEST', 'http://lдu.de/', '/foobar', '/foobar#anchor', '#anchor') as $url) {
         $r = validate_url($url, 'posting', false);
         $this->assertFalse($r, $url . ' NOT allowed in posts');
     }
     // invalid:
     foreach (array('http://', 'http://&amp;', 'http://<script>...</script>', 'mailto:www.example.com', 'foobar') as $url) {
         $r = validate_url($url, 'commenting', false);
         // True means validation rejected
         $this->assertTrue($r, $url . ' allowed in comments');
         $r = validate_url($url, 'posting', false);
         $this->assertTrue($r, $url . ' allowed in posts');
     }
 }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:22,代码来源:misc.funcs.simpletest.php


示例8: authenticate_success

        authenticate_success($r[0]);
    }
} else {
    if (isset($_SESSION)) {
        nuke_session();
    }
    if (x($_POST, 'password') && strlen($_POST['password'])) {
        $encrypted = hash('whirlpool', trim($_POST['password']));
    } else {
        if (x($_POST, 'openid_url') && strlen($_POST['openid_url']) || x($_POST, 'username') && strlen($_POST['username'])) {
            $noid = get_config('system', 'no_openid');
            $openid_url = trim(strlen($_POST['openid_url']) ? $_POST['openid_url'] : $_POST['username']);
            // validate_url alters the calling parameter
            $temp_string = $openid_url;
            // if it's an email address or doesn't resolve to a URL, fail.
            if ($noid || strpos($temp_string, '@') || !validate_url($temp_string)) {
                $a = get_app();
                notice(t('Login failed.') . EOL);
                goaway(z_root());
                // NOTREACHED
            }
            // Otherwise it's probably an openid.
            try {
                require_once 'library/openid.php';
                $openid = new LightOpenID();
                $openid->identity = $openid_url;
                $_SESSION['openid'] = $openid_url;
                $a = get_app();
                $openid->returnUrl = $a->get_baseurl(true) . '/openid';
                goaway($openid->authUrl());
            } catch (Exception $e) {
开发者ID:robhell,项目名称:friendica,代码行数:31,代码来源:auth.php


示例9: is_url

/**
 * Checks if the url is valid
 *
 * @param string url to check
 * @return boolean true if OK
 */
function is_url($url)
{
    if (validate_url($url, 'posting', false)) {
        return false;
    }
    return true;
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:13,代码来源:_misc.funcs.php


示例10: die

                ";
                die ('');
            }       
            error_reporting(E_ALL);
            session_destroy();    
        }
        
		// 	clean input			
		$url 		= 	cleaninput(cleanup_text(trim(substr ($url, 0,100))));
		$title 		= 	cleaninput(cleanup_text(trim(substr ($title, 0,100))));
		$description = 	cleaninput(cleanup_text(nl2br(trim(substr ($description, 0,250)))));
		$email 		= 	cleaninput(cleanup_text(trim(substr ($email, 0,100))));
		
		//	check Url
		$input  = $url;        
		validate_url($input);
        $url = $input;
			
		//	check Title
		if(!preg_match('/^[[:print:]]{5,100}$/', $title)) {
            echo "<h1>$mytitle</h1><br />
                <p class='em cntr warnadmin'> 
                ".$sph_messages['InvTitle']."
                <br />               
                </p>
                <br />
                <a class='bkbtn' href='addurl.php' title='Go back to Suggest form'>".$sph_messages['BackToSubForm']."</a>                
                </body>
                </html>
            ";
            die ('');
开发者ID:sean-tan,项目名称:sphiderplus,代码行数:31,代码来源:addurl.php


示例11: xmlrpcs_new_comment

/**
 * Create a new Comment and return an XML-RPC response
 *
 * @param array of params
 *			- Item (object)
 *			- User (object) Can be NULL for anonymous comments
 *			- password (string)
 *			- username (string)
 *			- comment_parent (int)
 *			- content (string)
 *			- author (string)
 *			- author_url (string)
 *			- author_email (string)
 * @return xmlrpcmsg
 */
function xmlrpcs_new_comment($params = array(), &$commented_Item)
{
    global $DB, $Plugins, $Messages, $Hit, $localtimenow, $require_name_email, $minimum_comment_interval;
    $params = array_merge(array('password' => '', 'username' => '', 'content' => '', 'comment_parent' => 0, 'author' => '', 'author_url' => '', 'author_email' => ''), $params);
    $comment = $params['content'] = trim($params['content']);
    if (!$commented_Item->can_comment(NULL)) {
        return xmlrpcs_resperror(5, T_('You cannot leave comments on this post!'));
    }
    $commented_Item->load_Blog();
    // Make sure Blog is loaded (will be needed whether logged in or not)
    if (empty($params['username']) && empty($params['password'])) {
        // Anonymous comment
        // NO permission to edit!
        $perm_comment_edit = false;
        $User = NULL;
        $author = trim($params['author']);
        $email = trim($params['author_email']);
        if ($commented_Item->Blog->get_setting('allow_anon_url')) {
            $url = trim($params['author_url']);
        } else {
            $url = NULL;
        }
        // we need some id info from the anonymous user:
        if ($require_name_email) {
            // We want Name and EMail with comments
            if (empty($author)) {
                return xmlrpcs_resperror(5, T_('Please fill in your name.'));
            }
            if (empty($email)) {
                return xmlrpcs_resperror(5, T_('Please fill in your email.'));
            }
        }
        if (!empty($author) && antispam_check($author)) {
            return xmlrpcs_resperror(5, T_('Supplied name is invalid.'));
        }
        if (!empty($email) && (!is_email($email) || antispam_check($email))) {
            return xmlrpcs_resperror(5, T_('Supplied email address is invalid.'));
        }
        if (!stristr($url, '://') && !stristr($url, '@')) {
            // add 'http://' if no protocol defined for URL; but not if the user seems to be entering an email address alone
            $url = 'http://' . $url;
        }
        if (strlen($url) <= 8) {
            // ex: https:// is 8 chars
            $url = '';
        }
        // Note: as part of the validation we require the url to be absolute; otherwise we cannot detect bozos typing in
        // a title for their comment or whatever...
        if ($error = validate_url($url, 'commenting')) {
            return xmlrpcs_resperror(5, T_('Supplied website address is invalid: ') . $error);
        }
    } else {
        $User =& $params['User'];
        $perm_comment_edit = $User->check_perm('blog_comment!published', 'edit', false, $commented_Item->Blog->ID);
        $author = $User->ID;
        $url = $User->url;
        $email = $User->email;
    }
    // Following call says "WARNING: this does *NOT* (necessarilly) make the HTML code safe.":
    $comment = check_html_sanity($comment, $perm_comment_edit ? 'posting' : 'commenting', $User);
    if ($comment === false) {
        // ERROR! Restore original comment for further editing:
        $comment = $params['content'];
    }
    if (empty($comment)) {
        // comment should not be empty!
        return xmlrpcs_resperror(5, T_('Please do not send empty comments.'));
    }
    $now = date2mysql($localtimenow);
    /*
     * Flood-protection
     * NOTE: devs can override the flood protection delay in /conf/_overrides_TEST.php
     * TODO: Put time check into query?
     * TODO: move that as far !!UP!! as possible! We want to waste minimum resources on Floods
     * TODO: have several thresholds. For example:
     * 1 comment max every 30 sec + 5 comments max every 10 minutes + 15 comments max every 24 hours
     * TODO: factorize with trackback
     */
    $query = 'SELECT MAX(comment_date)
				FROM T_comments
				WHERE comment_author_IP = ' . $DB->quote($Hit->IP) . '
				OR comment_author_email = ' . $DB->quote($email);
    $ok = 1;
    if ($then = $DB->get_var($query)) {
        $time_lastcomment = mysql2date("U", $then);
//.........这里部分代码省略.........
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:101,代码来源:_xmlrpcs.funcs.php


示例12: register_post

 function register_post(&$a)
 {
     global $lang;
     $verified = 0;
     $blocked = 1;
     switch ($a->config['register_policy']) {
         case REGISTER_OPEN:
             $blocked = 0;
             $verified = 1;
             break;
         case REGISTER_APPROVE:
             $blocked = 1;
             $verified = 0;
             break;
         default:
         case REGISTER_CLOSED:
             if (!x($_SESSION, 'authenticated') && !x($_SESSION, 'administrator')) {
                 notice(t('Permission denied.') . EOL);
                 return;
             }
             $blocked = 1;
             $verified = 0;
             break;
     }
     $using_invites = get_config('system', 'invitation_only');
     $num_invites = get_config('system', 'number_invites');
     $invite_id = x($_POST, 'invite_id') ? notags(trim($_POST['invite_id'])) : '';
     $username = x($_POST, 'username') ? notags(trim($_POST['username'])) : '';
     $nickname = x($_POST, 'nickname') ? notags(trim($_POST['nickname'])) : '';
     $email = x($_POST, 'email') ? notags(trim($_POST['email'])) : '';
     $openid_url = x($_POST, 'openid_url') ? notags(trim($_POST['openid_url'])) : '';
     $photo = x($_POST, 'photo') ? notags(trim($_POST['photo'])) : '';
     $publish = x($_POST, 'profile_publish_reg') && intval($_POST['profile_publish_reg']) ? 1 : 0;
     $netpublish = strlen(get_config('system', 'directory_submit_url')) ? $publish : 0;
     $tmp_str = $openid_url;
     if ($using_invites) {
         if (!$invite_id) {
             notice(t('An invitation is required.') . EOL);
             return;
         }
         $r = q("select * from register where `hash` = '%s' limit 1", dbesc($invite_id));
         if (!results($r)) {
             notice(t('Invitation could not be verified.') . EOL);
             return;
         }
     }
     if (!x($username) || !x($email) || !x($nickname)) {
         if ($openid_url) {
             if (!validate_url($tmp_str)) {
                 notice(t('Invalid OpenID url') . EOL);
                 return;
             }
             $_SESSION['register'] = 1;
             $_SESSION['openid'] = $openid_url;
             require_once 'library/openid.php';
             $openid = new LightOpenID();
             $openid->identity = $openid_url;
             $openid->returnUrl = $a->get_baseurl() . '/openid';
             $openid->required = array('namePerson/friendly', 'contact/email', 'namePerson');
             $openid->optional = array('namePerson/first', 'media/image/aspect11', 'media/image/default');
             goaway($openid->authUrl());
             // NOTREACHED
         }
         notice(t('Please enter the required information.') . EOL);
         return;
     }
     if (!validate_url($tmp_str)) {
         $openid_url = '';
     }
     $err = '';
     // collapse multiple spaces in name
     $username = preg_replace('/ +/', ' ', $username);
     if (mb_strlen($username) > 48) {
         $err .= t('Please use a shorter name.') . EOL;
     }
     if (mb_strlen($username) < 3) {
         $err .= t('Name too short.') . EOL;
     }
     // I don't really like having this rule, but it cuts down
     // on the number of auto-registrations by Russian spammers
     //  Using preg_match was completely unreliable, due to mixed UTF-8 regex support
     //	$no_utf = get_config('system','no_utf');
     //	$pat = (($no_utf) ? '/^[a-zA-Z]* [a-zA-Z]*$/' : '/^\p{L}* \p{L}*$/u' );
     // So now we are just looking for a space in the full name.
     $loose_reg = get_config('system', 'no_regfullname');
     if (!$loose_reg) {
         $username = mb_convert_case($username, MB_CASE_TITLE, 'UTF-8');
         if (!strpos($username, ' ')) {
             $err .= t("That doesn't appear to be your full (First Last) name.") . EOL;
         }
     }
     if (!allowed_email($email)) {
         $err .= t('Your email domain is not among those allowed on this site.') . EOL;
     }
     if (!valid_email($email) || !validate_email($email)) {
         $err .= t('Not a valid email address.') . EOL;
     }
     // Disallow somebody creating an account using openid that uses the admin email address,
     // since openid bypasses email verification. We'll allow it if there is not yet an admin account.
     if (x($a->config, 'admin_email') && strcasecmp($email, $a->config['admin_email']) == 0 && strlen($openid_url)) {
//.........这里部分代码省略.........
开发者ID:ryivhnn,项目名称:friendica,代码行数:101,代码来源:register.php


示例13: dfrn_request_post


//.........这里部分代码省略.........
         $hcard = '';
         $url = webfinger_dfrn($url, $hcard);
         if (substr($url, 0, 5) === 'stat:') {
             $network = NETWORK_OSTATUS;
             $url = substr($url, 5);
         } else {
             $network = NETWORK_DFRN;
         }
         logger('dfrn_request: url: ' . $url);
         if (!strlen($url)) {
             notice(t("Unable to resolve your name at the provided location.") . EOL);
             return;
         }
         if ($network === NETWORK_DFRN) {
             $ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1", intval($uid), dbesc($url));
             if (count($ret)) {
                 if (strlen($ret[0]['issued-id'])) {
                     notice(t('You have already introduced yourself here.') . EOL);
                     return;
                 } elseif ($ret[0]['rel'] == CONTACT_IS_FRIEND) {
                     notice(sprintf(t('Apparently you are already friends with %s.'), $a->profile['name']) . EOL);
                     return;
                 } else {
                     $contact_record = $ret[0];
                     $parms = array('dfrn-request' => $ret[0]['request']);
                 }
             }
             $issued_id = random_string();
             if (is_array($contact_record)) {
                 // There is a contact record but no issued-id, so this
                 // is a reciprocal introduction from a known contact
                 $r = q("UPDATE `contact` SET `issued-id` = '%s' WHERE `id` = %d LIMIT 1", dbesc($issued_id), intval($contact_record['id']));
             } else {
                 if (!validate_url($url)) {
                     notice(t('Invalid profile URL.') . EOL);
                     goaway($a->get_baseurl() . '/' . $a->cmd);
                     return;
                     // NOTREACHED
                 }
                 if (!allowed_url($url)) {
                     notice(t('Disallowed profile URL.') . EOL);
                     goaway($a->get_baseurl() . '/' . $a->cmd);
                     return;
                     // NOTREACHED
                 }
                 require_once 'Scrape.php';
                 $parms = scrape_dfrn($hcard ? $hcard : $url);
                 if (!count($parms)) {
                     notice(t('Profile location is not valid or does not contain profile information.') . EOL);
                     goaway($a->get_baseurl() . '/' . $a->cmd);
                 } else {
                     if (!x($parms, 'fn')) {
                         notice(t('Warning: profile location has no identifiable owner name.') . EOL);
                     }
                     if (!x($parms, 'photo')) {
                         notice(t('Warning: profile location has no profile photo.') . EOL);
                     }
                     $invalid = validate_dfrn($parms);
                     if ($invalid) {
                         notice(sprintf(tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", $invalid), $invalid) . EOL);
                         return;
                     }
                 }
                 $parms['url'] = $url;
                 $parms['issued-id'] = $issued_id;
                 dbesc_array($parms);
开发者ID:nextgensh,项目名称:friendica,代码行数:67,代码来源:dfrn_request.php


示例14: redirect

function redirect($url, $absolute = false)
{
    if (strpos($url, '/actions/') !== false) {
        $url = CONFIG_INDEX_REDIRECT_TO;
    }
    if (!$absolute) {
        $url = CONFIG_SITE_URL . trim($url, '/');
    }
    validate_url($url);
    header('location: ' . $url);
    exit;
}
开发者ID:aallen,项目名称:mellivora,代码行数:12,代码来源:general.inc.php


示例15: innovation_show

function innovation_show()
{
    global $services, $innovation_file, $innovation_data, $thisfile_innov;
    $success = $error = null;
    // submitted form
    if (isset($_POST['submit'])) {
        foreach ($services as $var) {
            if ($_POST[$var] != '') {
                if (validate_url($_POST[$var])) {
                    $resp[$var] = $_POST[$var];
                } else {
                    $error .= i18n_r($thisfile_innov . '/' . strtoupper($var) . '_ERROR') . ' ';
                }
            }
        }
        # if there are no errors, save data
        if (!$error) {
            $xml = @new SimpleXMLElement('<item></item>');
            foreach ($services as $var) {
                if (isset($resp[$var])) {
                    $xml->addChild($var, $resp[$var]);
                }
            }
            if (!$xml->asXML($innovation_file)) {
                $error = i18n_r('CHMOD_ERROR');
            } else {
                $innovation_data = getXML($innovation_file);
                $success = i18n_r('SETTINGS_UPDATED');
            }
        }
    }
    ?>
	<h3><?php 
    i18n($thisfile_innov . '/INNOVATION_TITLE');
    ?>
</h3>
	
	<?php 
    if ($success) {
        echo '<p style="color:#669933;"><b>' . $success . '</b></p>';
    }
    if ($error) {
        echo '<p style="color:#cc0000;"><b>' . $error . '</b></p>';
    }
    ?>
	
	<form method="post" action="<?php 
    echo $_SERVER['REQUEST_URI'];
    ?>
">
		
		<?php 
    foreach ($services as $var) {
        $value = '';
        if (isset($innovation_data->{$var})) {
            $value = $innovation_data->{$var};
        }
        echo '<p><label for="inn_' . $var . '" >' . i18n($thisfile_innov . '/' . strtoupper($var) . '_URL') . '</label><input id="inn_' . $var . '" name="' . $var . '" class="text" value="' . $value . '" type="url" /></p>';
    }
    ?>

		<p><input type="submit" id="submit" class="submit" value="<?php 
    i18n('BTN_SAVESETTINGS');
    ?>
" name="submit" /></p>
	</form>
	
	<?php 
}
开发者ID:Foltys,项目名称:Masopust,代码行数:69,代码来源:InnovationPlugin.php


示例16: settings_post


//.........这里部分代码省略.........
        }
    }
    if ($email != $a->user['email']) {
        $email_changed = true;
        //  check for the correct password
        $r = q("SELECT `password` FROM `user`WHERE `uid` = %d LIMIT 1", intval(local_user()));
        $password = hash('whirlpool', $_POST['mpassword']);
        if ($password != $r[0]['password']) {
            $err .= t('Wrong Password') . EOL;
            $email = $a->user['email'];
        }
        //  check the email is valid
        if (!valid_email($email)) {
            $err .= t(' Not valid email.');
        }
        //  ensure new email is not the admin mail
        //if((x($a->config,'admin_email')) && (strcasecmp($email,$a->config['admin_email']) == 0)) {
        if (x($a->config, 'admin_email')) {
            $adminlist = explode(",", str_replace(" ", "", strtolower($a->config['admin_email'])));
            if (in_array(strtolower($email), $adminlist)) {
                $err .= t(' Cannot change to that email.');
                $email = $a->user['email'];
            }
        }
    }
    if (strlen($err)) {
        notice($err . EOL);
        return;
    }
    if ($timezone != $a->user['timezone']) {
        if (strlen($timezone)) {
            date_default_timezone_set($timezone);
        }
    }
    $str_group_allow = perms2str($_POST['group_allow']);
    $str_contact_allow = perms2str($_POST['contact_allow']);
    $str_group_deny = perms2str($_POST['group_deny']);
    $str_contact_deny = perms2str($_POST['contact_deny']);
    $openidserver = $a->user['openidserver'];
    $openid = normalise_openid($openid);
    // If openid has changed or if there's an openid but no openidserver, try and discover it.
    if ($openid != $a->user['openid'] || strlen($openid) && !strlen($openidserver)) {
        $tmp_str = $openid;
        if (strlen($tmp_str) && validate_url($tmp_str)) {
            logger('updating openidserver');
            require_once 'library/openid.php';
            $open_id_obj = new LightOpenID();
            $open_id_obj->identity = $openid;
            $openidserver = $open_id_obj->discover($open_id_obj->identity);
        } else {
            $openidserver = '';
        }
    }
    set_pconfig(local_user(), 'expire', 'items', $expire_items);
    set_pconfig(local_user(), 'expire', 'notes', $expire_notes);
    set_pconfig(local_user(), 'expire', 'starred', $expire_starred);
    set_pconfig(local_user(), 'expire', 'photos', $expire_photos);
    set_pconfig(local_user(), 'expire', 'network_only', $expire_network_only);
    set_pconfig(local_user(), 'system', 'suggestme', $suggestme);
    set_pconfig(local_user(), 'system', 'post_newfriend', $post_newfriend);
    set_pconfig(local_user(), 'system', 'post_joingroup', $post_joingroup);
    set_pconfig(local_user(), 'system', 'post_profilechange', $post_profilechange);
    set_pconfig(local_user(), 'system', 'email_textonly', $email_textonly);
    if ($page_flags == PAGE_PRVGROUP) {
        $hidewall = 1;
        if (!$str_contact_allow && !$str_group_allow && !$str_contact_deny && !$str_group_deny) {
            if ($def_gid) {
                info(t('Private forum has no privacy permissions. Using default privacy group.') . EOL);
                $str_group_allow = '<' . $def_gid . '>';
            } else {
                notice(t('Private forum has no privacy permissions and no default privacy group.') . EOL);
            }
        }
    }
    $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s',  `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `def_gid` = %d, `blockwall` = %d, `hidewall` = %d, `blocktags` = %d, `unkmail` = %d, `cntunkmail` = %d  WHERE `uid` = %d", dbesc($username), dbesc($email), dbesc($openid), dbesc($timezone), dbesc($str_contact_allow), dbesc($str_group_allow), dbesc($str_contact_deny), dbesc($str_group_deny), intval($notify), intval($page_flags), dbesc($defloc), intval($allow_location), intval($maxreq), intval($expire), dbesc($openidserver), intval($def_gid), intval($blockwall), intval($hidewall), intval($blocktags), intval($unkmail), intval($cntunkmail), intval(local_user()));
    if ($r) {
        info(t('Settings updated.') . EOL);
    }
    $r = q("UPDATE `profile`\n\t\tSET `publish` = %d,\n\t\t`name` = '%s',\n\t\t`net-publish` = %d,\n\t\t`hide-friends` = %d\n\t\tWHERE `is-default` = 1 AND `uid` = %d", intval($publish), dbesc($username), intval($net_publish), intval($hide_friends), intval(local_user()));
    if ($name_change) {
        q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self` = 1", dbesc($username), dbesc(datetime_convert()), intval(local_user()));
    }
    if ($old_visibility != $net_publish || $page_flags != $old_page_flags) {
        // Update global directory in background
        $url = $_SESSION['my_url'];
        if ($url && strlen(get_config('system', 'directory_submit_url'))) {
            proc_run('php', "include/directory.php", "{$url}");
        }
    }
    require_once 'include/profile_update.php';
    profile_change();
    //$_SESSION['theme'] = $theme;
    if ($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) {
        // FIXME - set to un-verified, blocked and redirect to logout
        // Why? Are we verifying people or email addresses?
    }
    goaway($a->get_baseurl(true) . '/settings');
    return;
    // NOTREACHED
}
开发者ID:strk,项目名称:friendica,代码行数:101,代码来源:settings.php


示例17: validate

 /**
  * Validates the comment.
  */
 private function validate()
 {
     $this->errors = array();
     // Validate values.
     if (!validate_name($this->user)) {
         $this->errors['name'] = TRUE;
     }
     if (!validate_url($this->website)) {
         $this->errors['website'] = TRUE;
     }
     if (!validate_email($this->email)) {
         $this->errors['email'] = TRUE;
     }
     if (count($this->errors) == 0) {
         $this->is_valid = TRUE;
     }
 }
开发者ID:pvorb,项目名称:php-yuki,代码行数:20,代码来源:comment.php


示例18: zrl_init

function zrl_init(&$a)
{
    $tmp_str = get_my_url();
    if (validate_url($tmp_str)) {
        proc_run('php', 'include/gprobe.php', bin2hex($tmp_str));
        $arr = array('zrl' => $tmp_str, 'url' => $a->cmd);
        call_hooks('zrl_init', $arr);
    }
}
开发者ID:ridcully,项目名称:friendica,代码行数:9,代码来源:boot.php


示例19: create_href

 /**
  * Creates a 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP validate_user函数代码示例发布时间:2022-05-23
下一篇:
PHP validate_upload函数代码示例发布时间: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