URL checker

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Ruud Bakker

Ruud Bakker

24/02/2004 11:03:00
Quote Anchor link
ik wil iets hebben dat kijkt of er een url is ingevuld of niet, en als er eentje is ingevuld of er http:// voor staat

dit heb ik nu:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?
if (empty($getklant[bedr_url])) {
$bedr_url = "";

}

else {

if(substr($getklant[bedr_url] ,0,7 == "http://"))
    {

    $new_url = "$getklant[bedr_url]";
    }

else
    {
    $new_url = "http://$getklant[bedr_url]";
    }



$bedr_url = "<a href=$new_url target=_blanc>$new_url</a>";
 
}

?>

als ie leeg laat ie niets zien, is dus oke, als de url begint met www zet ie er netjes http:// voor dus werkt ook goed,
maaaar.... als de url goed is ingevuld met http:// zet ie er ook http:// voor.. en dat moet niet...
 
PHP hulp

PHP hulp

19/02/2025 06:40:43
 
Remco nvt

Remco nvt

24/02/2004 11:20:00
Quote Anchor link
Dan moet je neer zetten bij het formulier dat ze het zonder http:// moeten schrijven.
 

24/02/2004 11:29:00
Quote Anchor link
Je moet zoiet doens
$bericht = str_replace ("www.", "http://", $bericht);
$bericht = str_replace ("http://", "http://www.", $bericht);
dan gelijk wat hij typt altijd het goede
 
Mitch X

Mitch X

24/02/2004 11:47:00
Quote Anchor link
Je wilt het checken?
Gebruik daarvoor dan regular expressions :)
 
Ruud Bakker

Ruud Bakker

24/02/2004 11:59:00
Quote Anchor link
regular expressions???
 
Mitch X

Mitch X

24/02/2004 13:28:00
 
Arend a

Arend a

24/02/2004 15:29:00
Quote Anchor link
of je gebruikt de PEAR validate classes

http://pear.php.net/package/Validate

Daar gebruiken ze de code

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?
    /**
     * Validate an URI (RFC2396)
     *
     * @param string    $url        URI to validate
     * @param array     $options    Options used by the validation method.
     *                              key => type
     *                              'domain_check' => boolean
     *                                  Whether to check the DNS entry or not
     *                              'allowed_schemes' => array, list of protocols
     *                                  List of allowed schemes ('http',
     *                                  'ssh+svn', 'mms')
     */

    function uri($url, $options = null)
    {

        $domain_check = false;
        $allowed_schemes = null;
        if (is_array($options)) {
            extract($options);
        }

        if (preg_match(
            '!^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?!',
            $url,$matches)
        ) {

            $scheme = $matches[2];
            $authority = $matches[4];
            if ( is_array($allowed_schemes) &&
                !
in_array($scheme,$allowed_schemes)
            ) {

                return false;
            }

            if ($domain_check && function_exists('checkdnsrr')) {
                if (!checkdnsrr($authority, 'A')) {
                    return false;
                }
            }

            return true;
        }

        return false;
    }

?>


Grtz,

Arend
 
Elwin - Fratsloos

Elwin - Fratsloos

24/02/2004 17:32:00
Quote Anchor link
Mwah... kan niet quoten op 1 bericht want iedereen heb het altijd over http:// ... Ik draai een SSL-server.. dus ik kan geen link daarheen doen? (https://)

Enne... dat www verhaal... als iemand nou een adres als http://gebruiker.domain.invalid heeft?

Elwin
 
Arend a

Arend a

24/02/2004 18:11:00
Quote Anchor link
Ik hoop toch echt dat je reactie niet op mijn post is gericht, anders zijn bij specsavers de gratis checks in de aanbieding.

Quote:
* 'domain_check' => boolean
* Whether to check the DNS entry or not
* 'allowed_schemes' => array, list of protocols
* List of allowed schemes ('http',
* 'ssh+svn', 'mms')


Dus [1]: Als je allowed schemes geeft als ftp, http, https vreet hij wat je wil dat hij vreet.

En [2]: als je domain_check aanstaat kijkt hij of de DNS van het domein wel goed gaat. gebruiker.domain.invalid zal niet resolven, en zal dus niet werken :)

Grtz,

Adje
 
Elwin - Fratsloos

Elwin - Fratsloos

24/02/2004 18:14:00
Quote Anchor link
Quote:
Ik hoop toch echt dat je reactie niet op mijn post is gericht, anders zijn bij specsavers de gratis checks in de aanbieding.

[knip]

Grtz,

Adje

Nope, was meer een algemene opmerking en dan meer richting de eerste stel posts..

Elwin
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.