[PHP] Preg_match hulp

Gestart doorRik6 reacties61 weergaven

7 berichten · pagina 1 van 1

Rik

Lid · Topicstarter

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Heya one2xs,

Ik ben bezig om een extentie te maken op mijn curl class, die verbinding maakt met one2xs. Nu gaat dit allemaal leuk en aardig, alleen wanneer ik strpos / eregi wil vervangen door preg_match loopt het helemaal in de soep. Het script logt niet opnieuw in (het weet dus dat het al is ingelogd op one2xs) maar geeft toch terug dat het nog moet inloggen.

Het is dus de bedoeling dat het script terug geeft dat het al is ingelogd, en dan zegt of de gebruiker al bestaat of niet.

http://leden.just-rik.nl/?one2xs&user=sdfsgjgjkdshgjkdsfg (bestaat niet)
http://leden.just-rik.nl/?one2xs&user=Rik (bestaat wel)

Dit stukje code checkt of de gebruiker is ingelogd:

public function checkLogin()
    {
        $this->objCurl->setUrl(http://www.one2xs.com/);
        $this->objCurl->execute();
        return preg_match("(" . $this->strUsername . ")" , $this->objCurl->printContent());
    }


en deze of de gebruiker bestaat:

public function checkUser($strUser)
    {
        $this->objCurl->setUrl(http://www.one2xs.com/profiel/bekijk?gebruiker= . $strUser);
        $this->objCurl->execute();
        $strOutput = $this->objCurl->PrintContent();
        
        if(preg_match("(<h1>Foutmelding</h1>)", $strOutput) == TRUE)
        {
            return FALSE;
        }
        else
        {
            return TRUE;
        }    
    }


Het bestaan deed hij nog wel goed, maar het checken of het script is ingelogd werkt met ongeveer dezelfde regex niet meer.

Hopelijk kan iemand mij verder helpen!

~ Rik
0
Miel

Lid

Berichten
4.462
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rik.. Ik snap je ingelogd ding niet? Straks heet een gebruiker bijvoorbeeld Nieuws Nieuwe, en dat geeft jouw ding dat hij is ingelogd?
0
Rik

Lid · Topicstarter

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Ja daarom, ik moet dat allemaal nog finetunen, maar hij geeft gewoon helemaal niets weer omdat het script denkt dat het niet ingelogd is.
0
Miel

Lid

Berichten
4.462
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
http://www.one2xs.com/profiel/mijnprofiel
En dan kijken of de gebruikersnaam daar gelijk is aan de gebruikersnaam waarmee je wilt werken.

[COLOR= #0000BB]<?php[/COLOR]
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] checkLogin[COLOR= #007700]()
    {[/COLOR]
        [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]objCurl[COLOR= #007700]->[/COLOR]setUrl[COLOR= #007700]([/COLOR][COLOR= #DD0000]http://www.one2xs.com/[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]objCurl[COLOR= #007700]->[/COLOR]execute[COLOR= #007700]();[/COLOR]
        [COLOR= #0000BB]$checkstring[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Je bent ingelogd als [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]strUsername[COLOR= #007700].[/COLOR][COLOR= #DD0000].[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/return"]return[/URL] [URL="http://www.php.net/strpos"]strpos[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]objCurl[COLOR= #007700]->[/COLOR]printContent[COLOR= #007700](),[/COLOR] [COLOR= #0000BB]$checkstring[/COLOR][COLOR= #007700]);
    }[/COLOR]
?>


Zoiets zou moeten werken
0
Rik

Lid · Topicstarter

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Miel schreef:
En dan kijken of de gebruikersnaam daar gelijk is aan de gebruikersnaam waarmee je wilt werken.

[COLOR= #0000BB]<?php[/COLOR]
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] checkLogin[COLOR= #007700]()
    {[/COLOR]
        [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]objCurl[COLOR= #007700]->[/COLOR]setUrl[COLOR= #007700]([/COLOR][COLOR= #DD0000]http://www.one2xs.com/[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]objCurl[COLOR= #007700]->[/COLOR]execute[COLOR= #007700]();[/COLOR]
        [COLOR= #0000BB]$checkstring[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Je bent ingelogd als [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]strUsername[COLOR= #007700].[/COLOR][COLOR= #DD0000].[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/return"]return[/URL] [URL="http://www.php.net/strpos"]strpos[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]objCurl[COLOR= #007700]->[/COLOR]printContent[COLOR= #007700](),[/COLOR] [COLOR= #0000BB]$checkstring[/COLOR][COLOR= #007700]);
    }[/COLOR]
?>


Zoiets zou moeten werken

Quote:
alleen wanneer ik strpos / eregi wil vervangen door preg_match loopt het helemaal in de soep
Of is preg_match helemaal niet zo handig / snel in dit geval?
0
Miel

Lid

Berichten
4.462
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Naja, strpos is makkelijker, en werkt net zo goed.smile
0
Rik

Lid · Topicstarter

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Mjah, heb nu ook maar gewoon weer strpos terug gedaan. Werkt goed genoeg.
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren