diff --git a/config.php b/config.php index d738c18..a2aeb21 100644 --- a/config.php +++ b/config.php @@ -12,6 +12,9 @@ define('DB_PREFIX','uf_'); define('VERSION','2.0.0'); define('UF_INSTALLED',true); -define('COOKIE_DOMAIN', ''); -define('COOKIE_PATH', '/uf2'); +define('FORUM_DOMAIN', 'localhost'); +define('FORUM_PATH', '/uf2'); +define('HTTP_PORT', 81); +define('HTTPS_PORT', 443); +define('USE_HTTPS', true); ?> diff --git a/inc/askModel.class.php b/inc/askModel.class.php index 00e6e11..0f2ea9e 100644 --- a/inc/askModel.class.php +++ b/inc/askModel.class.php @@ -1,4 +1,13 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ + +require_once('./inc/model.class.php'); abstract class AskModel { @@ -6,7 +15,7 @@ abstract class AskModel function loadModel($model) { - if (file_exists('./inc/models/'.$model.'.class.php') && !array_key_exists($model, $this->models)) //realizowany singleton + if (file_exists('./inc/models/'.$model.'.class.php') && !array_key_exists($model, $this->models)) //singleton { require_once('./inc/models/'.$model.'.class.php'); $this->models[$model] = new $model($this->db); @@ -30,5 +39,4 @@ abstract class AskModel $this->models[$model] = $model_ptr; } } - ?> \ No newline at end of file diff --git a/inc/bbcode.php b/inc/bbcode.php index 7e6a4c0..d2d4073 100644 --- a/inc/bbcode.php +++ b/inc/bbcode.php @@ -1,4 +1,11 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ function BBCode($content) { @@ -35,8 +42,7 @@ function BBCode($content) '/\[code\](.*?)\[\/code\]/is', # [code] '/\\n/', # \n '/\\r/', # \r - '/(^|[^"])((http:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i', - + '/(^|[^"])((http:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i', ); $replace = array( @@ -77,35 +83,4 @@ function BBCode($content) return preg_replace($pattern, $replace, $content); } - -function StripBBCode($content) -{ - $pattern = array( - '/\\n/', # \n - '/\\r/', # \r - '/\[b\](.*?)\[\/b\]/is', # [b] - '/\[i\](.*?)\[\/i\]/is', # [i] - '/\[u\](.*?)\[\/u\]/is', # [u] - '/\[s\](.*?)\[\/s\]/is', # [s] - '/\[url=(.*?)\](.*?)\[\/url\]/is', # [url=] - '/\[url](.*?)\[\/url\]/is', # [url] - '/\[img](.*?)\[\/img\]/is', # [img] - '/\[color=(.*?)\](.*?)\[\/color\]/is', # [color] - ); - - $replace = array( - '', # \n - '', # \r - '\1', # [b] - '\1', # [i] - '\1', # [u] - '\1', # [s] - '\2', # [url=] - '\1', # [url] - '', # [img] - '\2', # [color] - ); - - return preg_replace($pattern, $replace, $content); -} ?> \ No newline at end of file diff --git a/inc/constants.php b/inc/constants.php index dac2914..3612cef 100644 --- a/inc/constants.php +++ b/inc/constants.php @@ -1,4 +1,11 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ //tables define('BANLIST_TABLE',DB_PREFIX.'banlist'); @@ -18,6 +25,7 @@ define('POSTS_VIEW', DB_PREFIX.'view_posts'); define('LOGGED_USERS_VIEW', DB_PREFIX.'view_logged_users'); define('USERS_PC_VIEW', DB_PREFIX.'view_users_post_count'); define('TOPICS_PC_VIEW', DB_PREFIX.'view_topics_post_count'); + define('COOKIE_NAME', 'uf2_auth'); define('RANK_USER', 0); diff --git a/inc/controller.class.php b/inc/controller.class.php index 0d872ee..f71a586 100644 --- a/inc/controller.class.php +++ b/inc/controller.class.php @@ -1,6 +1,14 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ require_once('./inc/askModel.class.php'); +require_once('./inc/view.class.php'); abstract class Controller extends AskModel { @@ -27,11 +35,10 @@ abstract class Controller extends AskModel { header('Location: ' . $address); } - public function loadView($view) { if (file_exists('./inc/views/'.$view.'.class.php') && !array_key_exists($view, $this->views)) - { + { require_once('./inc/views/'.$view.'.class.php'); $this->views[$view] = new $view($this->db); } diff --git a/inc/controllers/AdminController.class.php b/inc/controllers/AdminController.class.php index d063c2a..4e82a97 100644 --- a/inc/controllers/AdminController.class.php +++ b/inc/controllers/AdminController.class.php @@ -1,4 +1,11 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ require ('./inc/controller.class.php'); diff --git a/inc/controllers/MainController.class.php b/inc/controllers/MainController.class.php index 386bfbb..f4aa952 100644 --- a/inc/controllers/MainController.class.php +++ b/inc/controllers/MainController.class.php @@ -1,4 +1,11 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ require ('./inc/controller.class.php'); @@ -17,12 +24,21 @@ class MainController extends Controller $this->loadView('MainView'); $this->getView('MainView')->putExistingModel('SessionModel', $this->getModel('SessionModel')); $this->getView('MainView')->putExistingModel('ConfigModel', $this->getModel('ConfigModel')); + + //przekierowanie! + if ($_GET['mode'] == 'editprofile' || $_GET['mode'] == 'register' || $_GET['mode'] == 'login') + { + if ($_SERVER['REQUEST_SCHEME'] != 'https' && USE_HTTPS) + $this->forward(buildURL($_SERVER['REQUEST_URI'], true)); + } + else + if ($_SERVER['REQUEST_SCHEME'] != 'http') + $this->forward(buildURL($_SERVER['REQUEST_URI'])); } public function main() { $this->loadDependencies(); - $this->getView('MainView')->main(); } @@ -37,7 +53,7 @@ class MainController extends Controller $f = $this->getModel('ForumsModel')->getForum($_GET['id']); if ($f == null) - $this->getView('MainView')->forum_message('Forum does not exist!', 'index.php'); + $this->getView('MainView')->forum_message('Forum does not exist!', buildURL('index.php')); else { $this->getView('MainView')->putExistingModel('ForumsModel', $this->getModel('ForumsModel')); @@ -91,7 +107,7 @@ class MainController extends Controller $t = $this->getModel('PostsModel')->getTopic($_GET['id']); if ($t == null) - $this->getView('MainView')->forum_message('Topic does not exist!', 'index.php'); + $this->getView('MainView')->forum_message('Topic does not exist!', buildURL('index.php')); else { $this->getView('MainView')->putExistingModel('PostsModel', $this->getModel('PostsModel')); @@ -130,13 +146,13 @@ class MainController extends Controller if (!$this->getModel('SessionModel')->isLogged()) { - $this->getView('MainView')->forum_message('You are not logged.', 'index.php?mode=login'); + $this->getView('MainView')->forum_message('You are not logged.', buildURL('index.php?mode=login', true)); $lockv = true; } if ($this->getModel('SessionModel')->getRank() == RANK_USER && !isset($lockv)) { - $this->getView('MainView')->forum_message('Only mods have access to this menu', 'index.php'); + $this->getView('MainView')->forum_message('Only mods have access to this menu', buildURL('index.php')); $lockv = true; } @@ -152,7 +168,7 @@ class MainController extends Controller if ($t == null) { - $this->getView('MainView')->forum_message('Topic does not exist!', 'index.php'); + $this->getView('MainView')->forum_message('Topic does not exist!', buildURL('index.php')); $lockv = true; } break; @@ -161,7 +177,7 @@ class MainController extends Controller $p = $this->getModel('PostsModel')->getPost($_GET['id']); if ($p == null) { - $this->getView('MainView')->forum_message('Post does not exist!', 'index.php'); + $this->getView('MainView')->forum_message('Post does not exist!', buildURL('index.php')); $lockv = true; } else @@ -170,7 +186,7 @@ class MainController extends Controller if ($t['post_count'] == 1) { - $this->getView('MainView')->forum_message('If topic has only one post, use delete topic option.', 'index.php?mode=viewtopic&id='.$p['topic_id'], 3); + $this->getView('MainView')->forum_message('If topic has only one post, use delete topic option.', buildURL('index.php?mode=viewtopic&id='.$p['topic_id']), 3); $lockv = true; } } @@ -178,7 +194,7 @@ class MainController extends Controller break; default: - $this->getView('MainView')->forum_message('Invalid mode', 'index.php'); + $this->getView('MainView')->forum_message('Invalid mode', buildURL('index.php')); $lockv = true; break; } @@ -192,13 +208,13 @@ class MainController extends Controller { case 'deletepost': $this->getModel('PostsModel')->deletePost($_GET['id']); - $this->getView('MainView')->forum_message('Post deleted. Redirecting...', 'index.php?mode=viewtopic&id='.$p['topic_id']); + $this->getView('MainView')->forum_message('Post deleted. Redirecting...', buildURL('index.php?mode=viewtopic&id='.$p['topic_id'])); $lockv = true; break; case 'deletetopic': $this->getModel('PostsModel')->deleteTopic($_GET['id']); - $this->getView('MainView')->forum_message('Topic deleted. Redirecting...', 'index.php?mode=viewforum&id='.$t['forum_id']); + $this->getView('MainView')->forum_message('Topic deleted. Redirecting...', buildURL('index.php?mode=viewforum&id='.$t['forum_id'])); $lockv = true; break; @@ -206,22 +222,22 @@ class MainController extends Controller if ($t['topic_locked'] == false) { $this->getModel('PostsModel')->lockTopic($_GET['id']); - $this->getView('MainView')->forum_message('Topic locked. Redirecting...', 'index.php?mode=viewtopic&id='.$_GET['id']); + $this->getView('MainView')->forum_message('Topic locked. Redirecting...', buildURL('index.php?mode=viewtopic&id='.$_GET['id'])); } else { $this->getModel('PostsModel')->lockTopic($_GET['id'], false); - $this->getView('MainView')->forum_message('Topic unlocked. Redirecting...', 'index.php?mode=viewtopic&id='.$_GET['id']); + $this->getView('MainView')->forum_message('Topic unlocked. Redirecting...', buildURL('index.php?mode=viewtopic&id='.$_GET['id'])); } $lockv = true; break; case 'movetopic': if ($this->getModel('ForumsModel')->getForum($_POST['forum_id']) == null) - $this->getView('MainView')->forum_message('Forum does not exist!', 'index.php?mode=viewtopic&id='.$_GET['id']); + $this->getView('MainView')->forum_message('Forum does not exist!', buildURL('index.php?mode=viewtopic&id='.$_GET['id'])); else { $this->getModel('PostsModel')->moveTopic($_GET['id'], $_POST['forum_id']); - $this->getView('MainView')->forum_message('Topic moved. Redirecting...', 'index.php?mode=viewtopic&id='.$_GET['id']); + $this->getView('MainView')->forum_message('Topic moved. Redirecting...', buildURL('index.php?mode=viewtopic&id='.$_GET['id'])); } $lockv = true; break; @@ -235,10 +251,10 @@ class MainController extends Controller case 'deletetopic': case 'locktopic': case 'movetopic': - $this->forward('index.php?mode=viewtopic&id='.$_GET['id']); + $this->forward(buildURL('index.php?mode=viewtopic&id='.$_GET['id'])); break; case 'deletepost': - $this->forward('index.php?mode=viewtopic&id='.$p['topic_id']); + $this->forward(buildURL('index.php?mode=viewtopic&id='.$p['topic_id'])); } } } @@ -279,50 +295,50 @@ class MainController extends Controller if (!$this->getModel('SessionModel')->isLogged()) { - $this->getView('MainView')->forum_message('You are not logged.', 'index.php?mode=login'); + $this->getView('MainView')->forum_message('You are not logged.', buildURL('index.php?mode=login', true)); $lockv = true; } - //SPRAWDZANIE CZY TEMAT/FORUM ISTNIEJE I CZY NIE ZABLOKOWANE + //CHECKING IF TOPIC/FORUM EXISTS AND IS NOT LOCKED if (!isset($lockv)) switch($type) { - case POSTING_NEWTOPIC: //sprawdzenie czy forum istnieje i czy nie zablokowane + case POSTING_NEWTOPIC: //checking if forum exists and is not locked $f = $this->getModel('ForumsModel')->getForum($_GET['id']); if ($f == null) { - $this->getView('MainView')->forum_message('Forum does not exist!', 'index.php'); + $this->getView('MainView')->forum_message('Forum does not exist!', buildURL('index.php')); $lockv = true; } else if ($f['locked'] == true) { - $this->getView('MainView')->forum_message('Forum is locked', 'index.php?mode=viewforum&id='.$_GET['id']); + $this->getView('MainView')->forum_message('Forum is locked', buildURL('index.php?mode=viewforum&id='.$_GET['id'])); $lockv = true; } break; - case POSTING_REPLY: //sprawdzenie czy temat istnieje + case POSTING_REPLY: //checking if topic exists case POSTING_QUOTE: $t = $this->getModel('PostsModel')->getTopic($_GET['id']); if ($t == null) { - $this->getView('MainView')->forum_message('Topic does not exist!', 'index.php'); + $this->getView('MainView')->forum_message('Topic does not exist!', buildURL('index.php')); $lockv = true; } else { if ($t['forum_locked'] == true && $this->getModel('SessionModel')->getRank() < RANK_MOD) { - $this->getView('MainView')->forum_message('Forum is locked', 'index.php?mode=viewtopic&id='.$t['topic_id']); + $this->getView('MainView')->forum_message('Forum is locked', buildURL('index.php?mode=viewtopic&id='.$t['topic_id'])); $lockv = true; } if ($t['topic_locked'] == true && $this->getModel('SessionModel')->getRank() < RANK_MOD) { - $this->getView('MainView')->forum_message('Topic is locked', 'index.php?mode=viewtopic&id='.$t['topic_id']); + $this->getView('MainView')->forum_message('Topic is locked', buildURL('index.php?mode=viewtopic&id='.$t['topic_id'])); $lockv = true; } @@ -333,14 +349,14 @@ class MainController extends Controller if ($qp == null) { - $this->getView('MainView')->forum_message('Invalid quoted post', 'index.php?mode=viewtopic&id='.$t['topic_id']); + $this->getView('MainView')->forum_message('Invalid quoted post', buildURL('index.php?mode=viewtopic&id='.$t['topic_id'])); $lockv = true; } else { if ($qp['topic_id'] != $_GET['id']) { - $this->getView('MainView')->forum_message('Invalid quoted post', 'index.php?mode=viewtopic&id='.$t['topic_id']); + $this->getView('MainView')->forum_message('Invalid quoted post', buildURL('index.php?mode=viewtopic&id='.$t['topic_id'])); $lockv = true; } } @@ -353,7 +369,7 @@ class MainController extends Controller if ($p == null) { - $this->getView('MainView')->forum_message('Post does not exist!', 'index.php'); + $this->getView('MainView')->forum_message('Post does not exist!', buildURL('index.php')); $lockv = true; } else @@ -361,17 +377,15 @@ class MainController extends Controller $t = $this->getModel('PostsModel')->getTopic($p['topic_id']); if ($t['forum_locked'] == true && $this->getModel('SessionModel')->getRank() < RANK_MOD) { - $this->getView('MainView')->forum_message('Forum is locked', 'index.php?mode=viewtopic&id='.$t['topic_id']); + $this->getView('MainView')->forum_message('Forum is locked', buildURL('index.php?mode=viewtopic&id='.$t['topic_id'])); $lockv = true; } if ($t['topic_locked'] == true && $this->getModel('SessionModel')->getRank() < RANK_MOD) { - $this->getView('MainView')->forum_message('Topic is locked', 'index.php?mode=viewtopic&id='.$t['topic_id']); + $this->getView('MainView')->forum_message('Topic is locked', buildURL('index.php?mode=viewtopic&id='.$t['topic_id'])); $lockv = true; } - //sprawdzić czy edycja tematu - // i ustawić opdowiednie parametry $type = POSTING_EDITTOPIC $first = $this->getModel('PostsModel')->getFirstPost($t['topic_id']); if ($first['post_id'] == $_GET['id']) @@ -379,7 +393,7 @@ class MainController extends Controller if ($p['user_id'] != $this->getModel('SessionModel')->getID() && $this->getModel('SessionModel')->getRank() < RANK_MOD) { - $this->getView('MainView')->forum_message('You can edit only own posts', 'index.php?mode=viewtopic&id='.$t['topic_id']); + $this->getView('MainView')->forum_message('You can edit only own posts', buildURL('index.php?mode=viewtopic&id='.$t['topic_id'])); $lockv = true; } } @@ -412,7 +426,7 @@ class MainController extends Controller $topic_id = $this->getModel('PostsModel')->addTopic($_POST['topic'], $_POST['post'], $_GET['id'], $this->getModel('SessionModel')->getID()); if ($topic_id != null) { - $this->getView('MainView')->forum_message('Topic created, Redirecting...', 'index.php?mode=viewtopic&id='.$topic_id); + $this->getView('MainView')->forum_message('Topic created, Redirecting...', buildURL('index.php?mode=viewtopic&id='.$topic_id)); $lockv = true; } else @@ -425,7 +439,7 @@ class MainController extends Controller if ($type == POSTING_EDITTOPIC) $this->getModel('PostsModel')->changeTopic($t['topic_id'], $_POST['topic']); - $this->getView('MainView')->forum_message('Post edited. Redirecting to topic...', 'index.php?mode=viewtopic&id='.$t['topic_id']); + $this->getView('MainView')->forum_message('Post edited. Redirecting to topic...', buildURL('index.php?mode=viewtopic&id='.$t['topic_id'])); $lockv = true; break; @@ -433,7 +447,7 @@ class MainController extends Controller case POSTING_REPLY: $this->getModel('PostsModel')->addPost($_GET['id'], $this->getModel('SessionModel')->getID(), $_POST['post']); - $this->getView('MainView')->forum_message('Reply saved. Redirecting to topic...', 'index.php?mode=viewtopic&id='.$_GET['id']); + $this->getView('MainView')->forum_message('Reply saved. Redirecting to topic...', buildURL('index.php?mode=viewtopic&id='.$_GET['id'])); $lockv = true; break; } @@ -478,7 +492,7 @@ class MainController extends Controller if (!$this->getModel('SessionModel')->isLogged()) $this->forward('index.php'); else - $this->forward('index.php?mode=viewprofile&id='.$this->getModel('SessionModel')->getID()); + $this->forward(buildURL('index.php?mode=viewprofile&id='.$this->getModel('SessionModel')->getID())); } public function viewprofile() @@ -491,10 +505,9 @@ class MainController extends Controller $_GET['id'] = (isset($_GET['id'])) ? trim(strip_tags($this->db->real_escape_string($_GET['id']))) : 0; if ($this->getModel('UsersModel')->getUserInformation($_GET['id']) == null) - $this->getView('MainView')->forum_message('User does not exist!', 'index.php'); + $this->getView('MainView')->forum_message('User does not exist!', buildURL('index.php')); else { - //$this->getView('MainView')->putExistingModel('PostsModel', $this->getModel('PostsModel')); $this->getView('MainView')->viewprofile(); } } @@ -507,7 +520,7 @@ class MainController extends Controller if (!$this->getModel('SessionModel')->isLogged()) { - $this->getView('MainView')->forum_message('You are not logged.', 'index.php?mode=login'); + $this->getView('MainView')->forum_message('You are not logged.', buildURL('index.php?mode=login', true)); } else { @@ -580,7 +593,7 @@ class MainController extends Controller $this->getModel('UsersModel')->changeUserPassword($this->getModel('SessionModel')->getID(), sha1($_POST['passwd'])); $this->getModel('UsersModel')->updateUserProfile($this->getModel('SessionModel')->getID(), '', $_POST['email'], $_POST['location'], $_POST['signature'], $av); - $this->getView('MainView')->forum_message('Your profile has changed.', 'index.php?mode=viewprofile&id='.$this->getModel('SessionModel')->getID()); + $this->getView('MainView')->forum_message('Your profile has changed.', buildURL('index.php?mode=viewprofile&id='.$this->getModel('SessionModel')->getID())); $lockv = true; } @@ -607,7 +620,7 @@ class MainController extends Controller $this->getModel('SessionModel')->deleteSession(); - $this->getView('MainView')->forum_message('You are logged out.', 'index.php'); + $this->getView('MainView')->forum_message('You are logged out.', buildURL('index.php')); } public function login() @@ -615,11 +628,8 @@ class MainController extends Controller $this->loadDependencies(); $this->loadModel('BansModel'); - if ($_SERVER['REQUEST_SCHEME'] == 'http') - $this->forward('https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']); - if ($this->getModel('SessionModel')->isLogged()) - $this->forward('index.php'); + $this->forward(buildURL('index.php')); $msg = ''; if (isset($_POST['nick'], $_POST['passwd'])) @@ -640,7 +650,7 @@ class MainController extends Controller if ($ban_info == null) { $this->getModel('SessionModel')->registerNewSession($userinfo['user_id']); - $this->getView('MainView')->forum_message('You are logged as: '.$userinfo['nick'].'', 'index.php'); + $this->getView('MainView')->forum_message('You are logged as: '.$userinfo['nick'].'', buildURL('index.php')); } else { @@ -663,9 +673,6 @@ class MainController extends Controller if ($this->getModel('SessionModel')->isLogged()) $this->forward('index.php'); - - if ($_SERVER['REQUEST_SCHEME'] == 'http') - $this->forward('https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']); $msg = ''; if (isset($_POST['nick'], $_POST['passwd'], $_POST['passwd_confirm'], $_POST['email'])) @@ -694,7 +701,7 @@ class MainController extends Controller if ($msg == '') { $this->getModel('UsersModel')->createNewUser($_POST['nick'], sha1($_POST['passwd']), $_POST['email']); - $this->getView('MainView')->forum_message('Your account has created. Log in to write new posts.', 'index.php'); + $this->getView('MainView')->forum_message('Your account has created. Log in to write new posts.', buildURL('index.php'), 3); $lockv = true; } } diff --git a/inc/database_connection.php b/inc/database_connection.php index 37f246e..3ddfe4a 100644 --- a/inc/database_connection.php +++ b/inc/database_connection.php @@ -1,4 +1,12 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ + $DB = new MySQLi(DB_HOST, DB_USER, DB_PASSWD, DB_NAME); diff --git a/inc/misc_functions.php b/inc/misc_functions.php index ba2e1f6..e2d4fc2 100644 --- a/inc/misc_functions.php +++ b/inc/misc_functions.php @@ -1,5 +1,23 @@ \ No newline at end of file diff --git a/inc/model.class.php b/inc/model.class.php index 121a6f0..1273633 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -1,6 +1,11 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ abstract class Model extends AskModel { @@ -53,4 +58,5 @@ abstract class Model extends AskModel return $out; } -} \ No newline at end of file +} +?> \ No newline at end of file diff --git a/inc/models/BansModel.class.php b/inc/models/BansModel.class.php index 7ec7414..4ea28a2 100644 --- a/inc/models/BansModel.class.php +++ b/inc/models/BansModel.class.php @@ -1,6 +1,11 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ class BansModel extends Model { diff --git a/inc/models/ConfigModel.class.php b/inc/models/ConfigModel.class.php index 1a8e7fa..b3bcd41 100644 --- a/inc/models/ConfigModel.class.php +++ b/inc/models/ConfigModel.class.php @@ -1,6 +1,11 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ class ConfigModel extends Model { @@ -34,5 +39,4 @@ class ConfigModel extends Model $this->db->query($query); } } - ?> \ No newline at end of file diff --git a/inc/models/ForumsModel.class.php b/inc/models/ForumsModel.class.php index bfaa554..e22edb7 100644 --- a/inc/models/ForumsModel.class.php +++ b/inc/models/ForumsModel.class.php @@ -1,6 +1,11 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ class ForumsModel extends Model { @@ -115,5 +120,4 @@ class ForumsModel extends Model $this->db->query($query); } } - ?> \ No newline at end of file diff --git a/inc/models/NavigationModel.class.php b/inc/models/NavigationModel.class.php index 81e454c..d71a2ab 100644 --- a/inc/models/NavigationModel.class.php +++ b/inc/models/NavigationModel.class.php @@ -1,6 +1,11 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ class NavigationModel extends Model { diff --git a/inc/models/PostsModel.class.php b/inc/models/PostsModel.class.php index 4c7b09f..b78c5c2 100644 --- a/inc/models/PostsModel.class.php +++ b/inc/models/PostsModel.class.php @@ -1,6 +1,11 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ class PostsModel extends Model { @@ -122,5 +127,4 @@ class PostsModel extends Model $this->db->query($query); } } - ?> \ No newline at end of file diff --git a/inc/models/SessionModel.class.php b/inc/models/SessionModel.class.php index 6d6e0a9..8dd7d50 100644 --- a/inc/models/SessionModel.class.php +++ b/inc/models/SessionModel.class.php @@ -1,6 +1,11 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ class SessionModel extends Model { @@ -38,18 +43,15 @@ class SessionModel extends Model public function updateSession() { - /*$this->db->query('UPDATE '.SESSIONS_TABLE.' SET expiry_time=(NOW() + INTERVAL 120 MINUTE) WHERE session_id=\''.$_COOKIE[COOKIE_NAME].'\''); - setcookie(COOKIE_NAME, $_COOKIE[COOKIE_NAME], $_SERVER['REQUEST_TIME']+7200, COOKIE_PATH, COOKIE_DOMAIN, false, true); */ - $newid = $this->generateSessionID(); - $this->db->query('UPDATE '.SESSIONS_TABLE.' SET expiry_time=(NOW() + INTERVAL 120 MINUTE), session_id=\''.$newid.'\' WHERE session_id=\''.$_COOKIE[COOKIE_NAME].'\''); - setcookie(COOKIE_NAME, $newid, $_SERVER['REQUEST_TIME']+7200, COOKIE_PATH, COOKIE_DOMAIN, false, true); - $_COOKIE[COOKIE_NAME] = $newid; + $newID = $this->generateSessionID(); + $this->db->query('UPDATE '.SESSIONS_TABLE.' SET expiry_time=(NOW() + INTERVAL 120 MINUTE), session_id=\''.$newID.'\' WHERE session_id=\''.$_COOKIE[COOKIE_NAME].'\''); + $this->registerSessionCookie($newID, $_SERVER['REQUEST_TIME']+7200); } public function deleteSession() { - setcookie(COOKIE_NAME, '', $_SERVER['REQUEST_TIME']-3600, COOKIE_PATH, COOKIE_DOMAIN, false, true); $this->db->query('DELETE FROM '.SESSIONS_TABLE.' WHERE session_id=\''.$_COOKIE[COOKIE_NAME].'\''); + $this->registerSessionCookie('', $_SERVER['REQUEST_TIME']-3600); } private function generateSessionID() @@ -76,7 +78,7 @@ class SessionModel extends Model $this->db->query($query); - setcookie(COOKIE_NAME, $newID, $_SERVER['REQUEST_TIME']+7200, COOKIE_PATH, COOKIE_DOMAIN, false, true); + $this->registerSessionCookie($newID, $_SERVER['REQUEST_TIME']+7200); } public function tryGetUser($nick, $passwd) @@ -120,6 +122,12 @@ class SessionModel extends Model else return null; } + + private function registerSessionCookie($session_id, $expiry_time) + { + $domain = (FORUM_DOMAIN == 'localhost') ? '' : FORUM_DOMAIN; + setcookie(COOKIE_NAME, $session_id, $expiry_time, FORUM_PATH, $domain, false, true); + $_COOKIE[COOKIE_NAME] = $session_id; + } } - ?> \ No newline at end of file diff --git a/inc/models/StatisticsModel.class.php b/inc/models/StatisticsModel.class.php index e46ff3c..41ffb17 100644 --- a/inc/models/StatisticsModel.class.php +++ b/inc/models/StatisticsModel.class.php @@ -1,6 +1,11 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ class StatisticsModel extends Model { @@ -52,5 +57,4 @@ class StatisticsModel extends Model return $this->logged_users; } } - ?> \ No newline at end of file diff --git a/inc/models/UsersModel.class.php b/inc/models/UsersModel.class.php index 6b5f535..cf7ca69 100644 --- a/inc/models/UsersModel.class.php +++ b/inc/models/UsersModel.class.php @@ -1,6 +1,11 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ class UsersModel extends Model { @@ -124,5 +129,4 @@ class UsersModel extends Model $this->db->query($query); } } - ?> \ No newline at end of file diff --git a/inc/view.class.php b/inc/view.class.php index 9330ed0..1c38cef 100644 --- a/inc/view.class.php +++ b/inc/view.class.php @@ -1,6 +1,11 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ abstract class View extends AskModel { diff --git a/inc/views/MainView.class.php b/inc/views/MainView.class.php index 313a61a..f8b354f 100644 --- a/inc/views/MainView.class.php +++ b/inc/views/MainView.class.php @@ -1,6 +1,11 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ class MainView extends View { diff --git a/index.php b/index.php index e4f3b86..6875ed4 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,12 @@ +* @link http://www.pioder.pl/ +* @license see LICENSE.txt +**/ + $_GET['mode'] = (isset($_GET['mode'])) ? trim(strip_tags($_GET['mode'])) : ''; $_GET['submode'] = (isset($_GET['submode'])) ? trim(strip_tags($_GET['submode'])) : ''; @@ -7,6 +15,7 @@ require_once('./config.php'); require_once('./inc/constants.php'); require_once('./inc/database_connection.php'); require_once('./inc/bbcode.php'); +require_once('./inc/misc_functions.php'); try { switch ($_GET['mode'])