Online lijst

Gestart doorShahiem40 reacties76 weergaven

41 berichten · pagina 3 van 3

Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik krijg nu deze fout;
Parse error: syntax error, unexpected T_VARIABLE in /home/shahiem/domains/habboregio.nl/public_html/v3/uitloggen.php on line 14

En hoe kan ik die cookies beveiligen.

En ik heb volgnesmij geen userinformatie zitten.
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Hoe heb je uitloggen.php nu dan?

Cookies kun je niet beveiligen, je kunt beter sessies gebruiken en in cookies een hash zitten waarmee je de informatie ophaalt die je in de sessies wilt hebben (want sessies verlopen na elke browsersessie, en je wilt niet dat je leden elke keer opnieuw moeten inloggen).

Dus in cookies sla je een unieke code op die ook in je database staat; in je database controleer je ip + die code en daardoor weet je bij welke user die code hoort, en die informatie zet je in sessies.
0
Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Uitloggen.php

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/define"]define[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]TITLE[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]Uitloggen[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/require_once"]require_once[/URL] [COLOR= #DD0000]inc/header.php[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR]ingelogd[COLOR= #007700]() ==[/COLOR] FALSE[COLOR= #007700]) {[/COLOR]
    [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Location: /[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700];
}[/COLOR]

[URL="http://www.php.net/setcookie"]setcookie[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]hash[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/setcookie"]setcookie[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700]);[/COLOR]


[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE leden SET ingelogd = 0 WHERE id = "[/COLOR][COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]
                Je bent succesvol uitgelogd. <meta http-equiv="refresh" content="3; URL=[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$link[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]/" />[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/require_once"]require_once[/URL] [COLOR= #DD0000]inc/footer.php[/COLOR][COLOR= #007700];[/COLOR]
?>


Hash heb ik ook .
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
mysql_query("UPDATE leden SET ingelogd = 0 WHERE id = ".$_COOKIE[id]) or die(mysql_error());

Die hash heb je goed bedacht dan smile moet je alleen nog niets proberen te maken wat userinformatie in sessies zet.
Das niet alleen nu handig, maar is ook handiger als je ergens de gebruikersnaam van de huidige ingelogde persoon wil laten zien of iets dergelijks.
0
Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bedankt Lennard biggrinHij veranderd nu als je uitlogd naar 0.
Nu nog alleen ledenlijst.
Want nu staan er da er geen leden online zijn.

Code:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/define"]define[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]TITLE[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]Wie is Online?[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/require_once"]require_once[/URL] [COLOR= #DD0000]inc/header.php[/COLOR][COLOR= #007700];[/COLOR]


[COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT id, naam, muntjes FROM leden WHERE DATE_ADD(laatst_actief, INTERVAL 300 SECOND) > NOW()
"[/COLOR][COLOR= #007700]);[/COLOR]


[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]) !=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$online[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Er zijn geen leden online.[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]) >[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$online[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Er zijn <b>[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]</b> leden online.[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$online[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Er is <b>1</b> lid online.[/COLOR][COLOR= #007700];
    }[/COLOR]
    

    [URL="http://www.php.net/echo"]echo[/URL]
                [COLOR= #0000BB]$online[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]
                <table width="100%">
                    <tr>
                        <td>Naam:</td>
                        <td>Muntjes:</td>
                    </tr>[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700])) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]
                    <tr>
                        <td><a href="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$link[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]/profiel?id=[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]&p=1">[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]</a></td>
                        <td>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]muntjes[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]</td>
                    </tr>[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]
                </table>[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]
                Er zijn geen leden online.[/COLOR][COLOR= #007700];
}[/COLOR]

[URL="http://www.php.net/require_once"]require_once[/URL] [COLOR= #DD0000]inc/footer.php[/COLOR][COLOR= #007700];[/COLOR]
?>
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
laatst_actief update je wel?
0
Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oja dat moest ik nog doen, Welke query is dat?
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
UPDATE leden SET laatst_actief = NOW() WHERE id = ...
0
Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb hem bij online.php gezet maar hij geeft nog steeds aan dat leden niet online zijn
0
Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
BUMP

Het is geluktbiggrin
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Nice. clown
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