Browse Source

implemented buildURL() function (and fixed redirecting on https page)

added comments block (file description) in each PHP file
master
Piotr Dergun 9 years ago
parent
commit
a542813c8f
21 changed files with 234 additions and 130 deletions
  1. +5
    -2
      config.php
  2. +10
    -2
      inc/askModel.class.php
  3. +8
    -33
      inc/bbcode.php
  4. +8
    -0
      inc/constants.php
  5. +9
    -2
      inc/controller.class.php
  6. +7
    -0
      inc/controllers/AdminController.class.php
  7. +59
    -52
      inc/controllers/MainController.class.php
  8. +8
    -0
      inc/database_connection.php
  9. +20
    -2
      inc/misc_functions.php
  10. +9
    -3
      inc/model.class.php
  11. +7
    -2
      inc/models/BansModel.class.php
  12. +7
    -3
      inc/models/ConfigModel.class.php
  13. +7
    -3
      inc/models/ForumsModel.class.php
  14. +7
    -2
      inc/models/NavigationModel.class.php
  15. +7
    -3
      inc/models/PostsModel.class.php
  16. +19
    -11
      inc/models/SessionModel.class.php
  17. +7
    -3
      inc/models/StatisticsModel.class.php
  18. +7
    -3
      inc/models/UsersModel.class.php
  19. +7
    -2
      inc/view.class.php
  20. +7
    -2
      inc/views/MainView.class.php
  21. +9
    -0
      index.php

+ 5
- 2
config.php View File

@ -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);
?>

+ 10
- 2
inc/askModel.class.php View File

@ -1,4 +1,13 @@
<?php
/**
* @package uForum2
* @file inc/askModel.class.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @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;
}
}
?>

+ 8
- 33
inc/bbcode.php View File

@ -1,4 +1,11 @@
<?php
/**
* @package uForum2
* @file inc/bbcode.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @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);
}
?>

+ 8
- 0
inc/constants.php View File

@ -1,4 +1,11 @@
<?php
/**
* @package uForum2
* @file inc/constants.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @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);

+ 9
- 2
inc/controller.class.php View File

@ -1,6 +1,14 @@
<?php
/**
* @package uForum2
* @file inc/controller.class.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @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);
}

+ 7
- 0
inc/controllers/AdminController.class.php View File

@ -1,4 +1,11 @@
<?php
/**
* @package uForum2
* @file inc/controllers/AdminController.class.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @link http://www.pioder.pl/
* @license see LICENSE.txt
**/
require ('./inc/controller.class.php');

+ 59
- 52
inc/controllers/MainController.class.php View File

@ -1,4 +1,11 @@
<?php
/**
* @package uForum2
* @file inc/controllers/MainController.class.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @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 <span style="font-weight: bold">delete topic</span> option.', 'index.php?mode=viewtopic&amp;id='.$p['topic_id'], 3);
$this->getView('MainView')->forum_message('If topic has only one post, use <span style="font-weight: bold">delete topic</span> option.', buildURL('index.php?mode=viewtopic&amp;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&amp;id='.$p['topic_id']);
$this->getView('MainView')->forum_message('Post deleted. Redirecting...', buildURL('index.php?mode=viewtopic&amp;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&amp;id='.$t['forum_id']);
$this->getView('MainView')->forum_message('Topic deleted. Redirecting...', buildURL('index.php?mode=viewforum&amp;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&amp;id='.$_GET['id']);
$this->getView('MainView')->forum_message('Topic locked. Redirecting...', buildURL('index.php?mode=viewtopic&amp;id='.$_GET['id']));
}
else
{
$this->getModel('PostsModel')->lockTopic($_GET['id'], false);
$this->getView('MainView')->forum_message('Topic unlocked. Redirecting...', 'index.php?mode=viewtopic&amp;id='.$_GET['id']);
$this->getView('MainView')->forum_message('Topic unlocked. Redirecting...', buildURL('index.php?mode=viewtopic&amp;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&amp;id='.$_GET['id']);
$this->getView('MainView')->forum_message('Forum does not exist!', buildURL('index.php?mode=viewtopic&amp;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&amp;id='.$_GET['id']);
$this->getView('MainView')->forum_message('Topic moved. Redirecting...', buildURL('index.php?mode=viewtopic&amp;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&amp;id='.$_GET['id']);
$this->getView('MainView')->forum_message('Forum is locked', buildURL('index.php?mode=viewforum&amp;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&amp;id='.$t['topic_id']);
$this->getView('MainView')->forum_message('Forum is locked', buildURL('index.php?mode=viewtopic&amp;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&amp;id='.$t['topic_id']);
$this->getView('MainView')->forum_message('Topic is locked', buildURL('index.php?mode=viewtopic&amp;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&amp;id='.$t['topic_id']);
$this->getView('MainView')->forum_message('Invalid quoted post', buildURL('index.php?mode=viewtopic&amp;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&amp;id='.$t['topic_id']);
$this->getView('MainView')->forum_message('Invalid quoted post', buildURL('index.php?mode=viewtopic&amp;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&amp;id='.$t['topic_id']);
$this->getView('MainView')->forum_message('Forum is locked', buildURL('index.php?mode=viewtopic&amp;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&amp;id='.$t['topic_id']);
$this->getView('MainView')->forum_message('Topic is locked', buildURL('index.php?mode=viewtopic&amp;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&amp;id='.$t['topic_id']);
$this->getView('MainView')->forum_message('You can edit only own posts', buildURL('index.php?mode=viewtopic&amp;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&amp;id='.$topic_id);
$this->getView('MainView')->forum_message('Topic created, Redirecting...', buildURL('index.php?mode=viewtopic&amp;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&amp;id='.$t['topic_id']);
$this->getView('MainView')->forum_message('Post edited. Redirecting to topic...', buildURL('index.php?mode=viewtopic&amp;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&amp;id='.$_GET['id']);
$this->getView('MainView')->forum_message('Reply saved. Redirecting to topic...', buildURL('index.php?mode=viewtopic&amp;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&amp;id='.$this->getModel('SessionModel')->getID());
$this->getView('MainView')->forum_message('Your profile has changed.', buildURL('index.php?mode=viewprofile&amp;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: <span style="font-weight: bold">'.$userinfo['nick'].'</span>', 'index.php');
$this->getView('MainView')->forum_message('You are logged as: <span style="font-weight: bold">'.$userinfo['nick'].'</span>', 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;
}
}

+ 8
- 0
inc/database_connection.php View File

@ -1,4 +1,12 @@
<?php
/**
* @package uForum2
* @file inc/database_connection.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @link http://www.pioder.pl/
* @license see LICENSE.txt
**/
$DB = new MySQLi(DB_HOST, DB_USER, DB_PASSWD, DB_NAME);

+ 20
- 2
inc/misc_functions.php View File

@ -1,5 +1,23 @@
<?php
function buildURL($URI, $https = false)
{
$url = 'http';
if ($https && USE_HTTPS)
$url .= 's';
$url .= '://'.FORUM_DOMAIN;
if ($https && USE_HTTPS && HTTPS_PORT != 443)
$url .= ':'.HTTPS_PORT;
if ((!$https || !USE_HTTPS) && HTTP_PORT != 80)
$url .= ':'.HTTP_PORT;
if (strpos($URI, FORUM_PATH) === 0)
$url .= $URI;
else
$url .= FORUM_PATH.'/'.$URI;
return $url;
}
?>

+ 9
- 3
inc/model.class.php View File

@ -1,6 +1,11 @@
<?php
require_once('./inc/askModel.class.php');
/**
* @package uForum2
* @file inc/model.class.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @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;
}
}
}
?>

+ 7
- 2
inc/models/BansModel.class.php View File

@ -1,6 +1,11 @@
<?php
require_once('./inc/model.class.php');
/**
* @package uForum2
* @file inc/models/BansModel.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @link http://www.pioder.pl/
* @license see LICENSE.txt
**/
class BansModel extends Model
{

+ 7
- 3
inc/models/ConfigModel.class.php View File

@ -1,6 +1,11 @@
<?php
require_once('./inc/model.class.php');
/**
* @package uForum2
* @file inc/models/ConfigModel.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @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);
}
}
?>

+ 7
- 3
inc/models/ForumsModel.class.php View File

@ -1,6 +1,11 @@
<?php
require_once('./inc/model.class.php');
/**
* @package uForum2
* @file inc/models/ForumsModel.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @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);
}
}
?>

+ 7
- 2
inc/models/NavigationModel.class.php View File

@ -1,6 +1,11 @@
<?php
require_once('./inc/model.class.php');
/**
* @package uForum2
* @file inc/models/NavigationModel.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @link http://www.pioder.pl/
* @license see LICENSE.txt
**/
class NavigationModel extends Model
{

+ 7
- 3
inc/models/PostsModel.class.php View File

@ -1,6 +1,11 @@
<?php
require_once('./inc/model.class.php');
/**
* @package uForum2
* @file inc/models/PostsModel.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @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);
}
}
?>

+ 19
- 11
inc/models/SessionModel.class.php View File

@ -1,6 +1,11 @@
<?php
require_once('./inc/model.class.php');
/**
* @package uForum2
* @file inc/models/SessionModel.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @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;
}
}
?>

+ 7
- 3
inc/models/StatisticsModel.class.php View File

@ -1,6 +1,11 @@
<?php
require_once('./inc/model.class.php');
/**
* @package uForum2
* @file inc/models/StatisticsModel.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @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;
}
}
?>

+ 7
- 3
inc/models/UsersModel.class.php View File

@ -1,6 +1,11 @@
<?php
require_once('./inc/model.class.php');
/**
* @package uForum2
* @file inc/models/UsersModel.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @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);
}
}
?>

+ 7
- 2
inc/view.class.php View File

@ -1,6 +1,11 @@
<?php
require_once('./inc/askModel.class.php');
/**
* @package uForum2
* @file inc/view.class.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @link http://www.pioder.pl/
* @license see LICENSE.txt
**/
abstract class View extends AskModel
{

+ 7
- 2
inc/views/MainView.class.php View File

@ -1,6 +1,11 @@
<?php
require_once('./inc/view.class.php');
/**
* @package uForum2
* @file inc/views/MainView.class.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @link http://www.pioder.pl/
* @license see LICENSE.txt
**/
class MainView extends View
{

+ 9
- 0
index.php View File

@ -1,4 +1,12 @@
<?php
/**
* @package uForum2
* @file index.php
* @copyright 2007-2015 (c) PioDer <piotrek@pioder.pl>
* @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'])

Loading…
Cancel
Save