-
Notifications
You must be signed in to change notification settings - Fork 2
/
common.php
44 lines (40 loc) · 1.34 KB
/
common.php
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
42
43
44
<?php
/* This file provides includes and sets up sessions, certain variables,
remember me functionality and logins.
This file is included from many different pages. */
include_once("class.User.php");
include_once("class.Topic.php");
include_once("class.Post.php");
include_once("class.Forum.php");
include_once("class.PM.php");
include_once("function.OnlineList.php");
include_once("outHtml.php");
session_start();
if (isset($_COOKIE['username']) && isset($_COOKIE['password']) && ($_SESSION['loggedIn'] == false || !isset($_SESSION['loggedIn'])))
{
$fileC = file("db/forumUsers.dat");
foreach ($fileC as $item)
{
$temp = new User($item);
if ($_COOKIE['username'] == $temp->getUserId() && $_COOKIE['password'] == $temp->getPassword())
{
setcookie("username",$_COOKIE['username'],time()+(60*60*24*14));
setcookie("password",$_COOKIE['password'],time()+(60*60*24*14));
$_SESSION['loggedIn'] = true;
$_SESSION['user'] = $temp;
}
}
}
if ($_SESSION['loggedIn'] == true)
{
addUser($_SESSION['user']->getUserId());
}
else
{
addGuest($_SERVER['SERVER_ADDR']);
}
$boardname = trim(file_get_contents("db/boardname.dat"));
$boarddescription = trim(file_get_contents("db/boarddescription.dat"));
define(BOARDNAME,$boardname);
define(BOARDDESCRIPTION,$boarddescription);
?>