Post extends Auth
^ dat klinkt niet correct
^ dat klinkt niet correct
Raoul schreef:ja naja...Post extends Auth
^ dat klinkt niet correct
Dylan schreef:Heh. Je gebruikt die Auth class toch statisch? Waar heb je die [c]$auth[/c] dan voor nodig?^ dat klinkt niet correctEerdere citaten tonen
Raoul schreef:Post extends Auth
ja naja...
$auth = new Auth();
Dan maar dit werkt ook prima.
Sjoerd schreef:Auth is niet staticHeh. Je gebruikt die Auth class toch statisch? Waar heb je die [c]$auth[/c] dan voor nodig?Eerdere citaten tonen
Dylan schreef:^ dat klinkt niet correctEerdere citaten tonen
Raoul schreef:Post extends Auth
ja naja...
$auth = new Auth();
Dan maar dit werkt ook prima.
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]/*==========/
One2xs Auth
/==========*/[/COLOR]
namespace One2xs[COLOR= #007700];[/COLOR]
abstract [URL="http://www.php.net/class"]class[/URL] Auth extends Request [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/protected"]protected[/URL] [COLOR= #0000BB]$csrfToken[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/protected"]protected[/URL] [COLOR= #007700]function[/COLOR] login[COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$password[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]0[/COLOR] [COLOR= #007700]||[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
throw [COLOR= #007700]new[/COLOR] Exception[COLOR= #007700]([/COLOR][COLOR= #DD0000]"Username and/or password is invalid."[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/return"]return[/URL][COLOR= #007700];
}[/COLOR]
[COLOR= #0000BB]$request[/COLOR] [COLOR= #007700]=[/COLOR] Request[COLOR= #007700]::[/COLOR]request[COLOR= #007700]([/COLOR][URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR]
CURLOPT_URL [COLOR= #007700]=>[/COLOR] [COLOR= #DD0000]"http://www.one2xs.com/login.php"[/COLOR][COLOR= #007700],[/COLOR]
CURLOPT_POST [COLOR= #007700]=>[/COLOR] true[COLOR= #007700],[/COLOR]
CURLOPT_POSTFIELDS [COLOR= #007700]=>[/COLOR] http_build_query[COLOR= #007700]([/COLOR][URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR]
[COLOR= #DD0000]"gebruikersnaam"[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$username[/COLOR][COLOR= #007700],[/COLOR]
[COLOR= #DD0000]"wachtwoord"[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$password[/COLOR]
[COLOR= #007700]))
));[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]( ([/COLOR]boolean[COLOR= #007700])[/COLOR] [URL="http://www.php.net/preg_match"]preg_match[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"/Je bent ingelogd als "[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$username[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #DD0000]"/"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$request[/COLOR][COLOR= #007700]) ===[/COLOR] true[COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/preg_match"]preg_match[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]/<a href="http://www.one2xs.com/loguit?c=(.+)" title="Uitloggen">Uitloggen</a>/[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$request[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$token[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]csrfToken [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$token[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]];[/COLOR]
[URL="http://www.php.net/return"]return[/URL] true[COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/return"]return[/URL] false[COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/protected"]protected[/URL] [COLOR= #007700]function[/COLOR] logout[COLOR= #007700]() {[/COLOR]
[COLOR= #0000BB]$request[/COLOR] [COLOR= #007700]=[/COLOR] Request[COLOR= #007700]::[/COLOR]request[COLOR= #007700]([/COLOR][URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR]
CURLOPT_URL [COLOR= #007700]=>[/COLOR] [COLOR= #DD0000]"http://www.one2xs.com/loguit?c="[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]csrfToken
[COLOR= #007700]));
}
}[/COLOR] [COLOR= #0000BB]<?php
$auth[/COLOR] [COLOR= #007700]= new[/COLOR] Authentication[COLOR= #007700]([/COLOR][COLOR= #DD0000]Raoul[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]Hoi[/COLOR][COLOR= #007700]);[/COLOR]
try [COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$auth[/COLOR][COLOR= #007700]->[/COLOR]login[COLOR= #007700]();
}[/COLOR] catch [COLOR= #007700]([/COLOR]AuthException [COLOR= #0000BB]$e[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Kon niet aanmelden![/COLOR][COLOR= #007700];
}[/COLOR]
[COLOR= #0000BB]$postRequest[/COLOR] [COLOR= #007700]= new[/COLOR] PostRequest[COLOR= #007700]([/COLOR][COLOR= #0000BB]$auth[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$post[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$postRequest[/COLOR][COLOR= #007700]->[/COLOR]execute[COLOR= #007700]();[/COLOR]
[COLOR= #FF8000]// $post->getUser()
// $post->getMessage()[/COLOR]
[COLOR= #0000BB]$auth[/COLOR][COLOR= #007700]->[/COLOR]logout[COLOR= #007700]();[/COLOR]
?> Raoul schreef:en zo zie je, door dependency injection te gebruiken wordt je hele systeem 10x netter.je dient de auth class te injecteren (niet de extenden) in de post class.
ook, Post dient PostRequest te heten.
zoiets:[COLOR= #0000BB]<?php $auth[/COLOR] [COLOR= #007700]= new[/COLOR] Authentication[COLOR= #007700]([/COLOR][COLOR= #DD0000]Raoul[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]Hoi[/COLOR][COLOR= #007700]);[/COLOR] try [COLOR= #007700]{[/COLOR] [COLOR= #0000BB]$auth[/COLOR][COLOR= #007700]->[/COLOR]login[COLOR= #007700](); }[/COLOR] catch [COLOR= #007700]([/COLOR]AuthException [COLOR= #0000BB]$e[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Kon niet aanmelden![/COLOR][COLOR= #007700]; }[/COLOR] [COLOR= #0000BB]$postRequest[/COLOR] [COLOR= #007700]= new[/COLOR] PostRequest[COLOR= #007700]([/COLOR][COLOR= #0000BB]$auth[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #0000BB]$post[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$postRequest[/COLOR][COLOR= #007700]->[/COLOR]execute[COLOR= #007700]();[/COLOR] [COLOR= #FF8000]// $post->getUser() // $post->getMessage()[/COLOR] [COLOR= #0000BB]$auth[/COLOR][COLOR= #007700]->[/COLOR]logout[COLOR= #007700]();[/COLOR] ?>
");Raoul schreef:Dan kan ik toch beter de request class injecteren?alsnog fout, je maakt een nieuwe auth instance aan in de post request class.
je moet de auth injecteren (= meegeven in een constructor) in de post request. Dit zodat je dezelfde auth instance kan hergebruiken overal.
Afbeelding niet beschikbaarDe bron kon niet worden geladen (i.imgur.com).Bron openen ↗Shahiem schreef:Als je de y iets verhoogt en je zorgt dat de transparantie werkt dan kan het er wel leuk uitzien denk ikBezig om in mijn vrije tijd een MMOCC game te maken en java te leren.
Ik probeerde tiles naast elkaar te zetten maar gaat niet echt lekker. Maar ik ben blij dat ik iets op mijn window heb gekregen.
Afbeelding
. Zou graag meer screens zien van je vooruitgang 
Shahiem schreef:Waarom gebruik je geen library die isometric rendered?Bezig om in mijn vrije tijd een MMOCC game te maken en java te leren.
Ik probeerde tiles naast elkaar te zetten maar gaat niet echt lekker. Maar ik ben blij dat ik iets op mijn window heb gekregen.
Afbeelding
Alemaalte schreef:Ik gebruik op het moment LWJGL 3. Geen idee of die optie er gewoon in zit.Ik probeerde tiles naast elkaar te zetten maar gaat niet echt lekker. Maar ik ben blij dat ik iets op mijn window heb gekregen.Eerdere citaten tonen
Shahiem schreef:Bezig om in mijn vrije tijd een MMOCC game te maken en java te leren.
Afbeelding
Waarom gebruik je geen library die isometric rendered?
Afbeelding niet beschikbaarDe bron kon niet worden geladen (i.imgur.com).Bron openen ↗Shahiem schreef:Kijk (eventueel met process hacker) naar het geheugen- en cpuverbruik van je programma.Afbeelding
Nog niet helemaal goed, maar transparantie is weg. Ik heb nu wel het probleem, dat als ik de windows sluit mijn computer heel langzaam gaat doen. Ik heb nog geen idee waar dat aan ligt.
Kitnkiller schreef:Thanks, ik zal even kijkenNog niet helemaal goed, maar transparantie is weg. Ik heb nu wel het probleem, dat als ik de windows sluit mijn computer heel langzaam gaat doen. Ik heb nog geen idee waar dat aan ligt.Eerdere citaten tonen
Shahiem schreef:
Kijk (eventueel met process hacker) naar het geheugen- en cpuverbruik van je programma.
