@ -1,4 +1,11 @@
< ? php
< ? 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' );
require ( './inc/controller.class.php' );
@ -17,12 +24,21 @@ class MainController extends Controller
$this -> loadView ( 'MainView' );
$this -> loadView ( 'MainView' );
$this -> getView ( 'MainView' ) -> putExistingModel ( 'SessionModel' , $this -> getModel ( 'SessionModel' ));
$this -> getView ( 'MainView' ) -> putExistingModel ( 'SessionModel' , $this -> getModel ( 'SessionModel' ));
$this -> getView ( 'MainView' ) -> putExistingModel ( 'ConfigModel' , $this -> getModel ( 'ConfigModel' ));
$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 ()
public function main ()
{
{
$this -> loadDependencies ();
$this -> loadDependencies ();
$this -> getView ( 'MainView' ) -> main ();
$this -> getView ( 'MainView' ) -> main ();
}
}
@ -37,7 +53,7 @@ class MainController extends Controller
$f = $this -> getModel ( 'ForumsModel' ) -> getForum ( $_GET [ 'id' ]);
$f = $this -> getModel ( 'ForumsModel' ) -> getForum ( $_GET [ 'id' ]);
if ( $f == null )
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
else
{
{
$this -> getView ( 'MainView' ) -> putExistingModel ( 'ForumsModel' , $this -> getModel ( 'ForumsModel' ));
$this -> getView ( 'MainView' ) -> putExistingModel ( 'ForumsModel' , $this -> getModel ( 'ForumsModel' ));
@ -91,7 +107,7 @@ class MainController extends Controller
$t = $this -> getModel ( 'PostsModel' ) -> getTopic ( $_GET [ 'id' ]);
$t = $this -> getModel ( 'PostsModel' ) -> getTopic ( $_GET [ 'id' ]);
if ( $t == null )
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
else
{
{
$this -> getView ( 'MainView' ) -> putExistingModel ( 'PostsModel' , $this -> getModel ( 'PostsModel' ));
$this -> getView ( 'MainView' ) -> putExistingModel ( 'PostsModel' , $this -> getModel ( 'PostsModel' ));
@ -130,13 +146,13 @@ class MainController extends Controller
if ( ! $this -> getModel ( 'SessionModel' ) -> isLogged ())
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 ;
$lockv = true ;
}
}
if ( $this -> getModel ( 'SessionModel' ) -> getRank () == RANK_USER && ! isset ( $lockv ))
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 ;
$lockv = true ;
}
}
@ -152,7 +168,7 @@ class MainController extends Controller
if ( $t == null )
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 ;
$lockv = true ;
}
}
break ;
break ;
@ -161,7 +177,7 @@ class MainController extends Controller
$p = $this -> getModel ( 'PostsModel' ) -> getPost ( $_GET [ 'id' ]);
$p = $this -> getModel ( 'PostsModel' ) -> getPost ( $_GET [ 'id' ]);
if ( $p == null )
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 ;
$lockv = true ;
}
}
else
else
@ -170,7 +186,7 @@ class MainController extends Controller
if ( $t [ 'post_count' ] == 1 )
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&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&id=' . $p [ 'topic_id' ]) , 3 );
$lockv = true ;
$lockv = true ;
}
}
}
}
@ -178,7 +194,7 @@ class MainController extends Controller
break ;
break ;
default :
default :
$this -> getView ( 'MainView' ) -> forum_message ( 'Invalid mode' , 'index.php' );
$this -> getView ( 'MainView' ) -> forum_message ( 'Invalid mode' , buildURL ( 'index.php' ) );
$lockv = true ;
$lockv = true ;
break ;
break ;
}
}
@ -192,13 +208,13 @@ class MainController extends Controller
{
{
case 'deletepost' :
case 'deletepost' :
$this -> getModel ( 'PostsModel' ) -> deletePost ( $_GET [ 'id' ]);
$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 ;
$lockv = true ;
break ;
break ;
case 'deletetopic' :
case 'deletetopic' :
$this -> getModel ( 'PostsModel' ) -> deleteTopic ( $_GET [ 'id' ]);
$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 ;
$lockv = true ;
break ;
break ;
@ -206,22 +222,22 @@ class MainController extends Controller
if ( $t [ 'topic_locked' ] == false )
if ( $t [ 'topic_locked' ] == false )
{
{
$this -> getModel ( 'PostsModel' ) -> lockTopic ( $_GET [ 'id' ]);
$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
else
{
{
$this -> getModel ( 'PostsModel' ) -> lockTopic ( $_GET [ 'id' ], false );
$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 ;
$lockv = true ;
break ;
break ;
case 'movetopic' :
case 'movetopic' :
if ( $this -> getModel ( 'ForumsModel' ) -> getForum ( $_POST [ 'forum_id' ]) == null )
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
else
{
{
$this -> getModel ( 'PostsModel' ) -> moveTopic ( $_GET [ 'id' ], $_POST [ 'forum_id' ]);
$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 ;
$lockv = true ;
break ;
break ;
@ -235,10 +251,10 @@ class MainController extends Controller
case 'deletetopic' :
case 'deletetopic' :
case 'locktopic' :
case 'locktopic' :
case 'movetopic' :
case 'movetopic' :
$this -> forward ( 'index.php?mode=viewtopic&id=' . $_GET [ 'id' ]);
$this -> forward ( buildURL ( 'index.php?mode=viewtopic&id=' . $_GET [ 'id' ]) );
break ;
break ;
case 'deletepost' :
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 ())
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 ;
$lockv = true ;
}
}
//SPRAWDZANIE CZY TEMAT/FORUM ISTNIEJE I CZY NIE ZABLOKOWANE
//CHECKING IF TOPIC/FORUM EXISTS AND IS NOT LOCKED
if ( ! isset ( $lockv ))
if ( ! isset ( $lockv ))
switch ( $type )
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' ]);
$f = $this -> getModel ( 'ForumsModel' ) -> getForum ( $_GET [ 'id' ]);
if ( $f == null )
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 ;
$lockv = true ;
}
}
else
else
if ( $f [ 'locked' ] == true )
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 ;
$lockv = true ;
}
}
break ;
break ;
case POSTING_REPLY : //sprawdzenie czy temat istnieje
case POSTING_REPLY : //checking if topic exists
case POSTING_QUOTE :
case POSTING_QUOTE :
$t = $this -> getModel ( 'PostsModel' ) -> getTopic ( $_GET [ 'id' ]);
$t = $this -> getModel ( 'PostsModel' ) -> getTopic ( $_GET [ 'id' ]);
if ( $t == null )
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 ;
$lockv = true ;
}
}
else
else
{
{
if ( $t [ 'forum_locked' ] == true && $this -> getModel ( 'SessionModel' ) -> getRank () < RANK_MOD )
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 ;
$lockv = true ;
}
}
if ( $t [ 'topic_locked' ] == true && $this -> getModel ( 'SessionModel' ) -> getRank () < RANK_MOD )
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 ;
$lockv = true ;
}
}
@ -333,14 +349,14 @@ class MainController extends Controller
if ( $qp == null )
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 ;
$lockv = true ;
}
}
else
else
{
{
if ( $qp [ 'topic_id' ] != $_GET [ 'id' ])
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 ;
$lockv = true ;
}
}
}
}
@ -353,7 +369,7 @@ class MainController extends Controller
if ( $p == null )
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 ;
$lockv = true ;
}
}
else
else
@ -361,17 +377,15 @@ class MainController extends Controller
$t = $this -> getModel ( 'PostsModel' ) -> getTopic ( $p [ 'topic_id' ]);
$t = $this -> getModel ( 'PostsModel' ) -> getTopic ( $p [ 'topic_id' ]);
if ( $t [ 'forum_locked' ] == true && $this -> getModel ( 'SessionModel' ) -> getRank () < RANK_MOD )
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 ;
$lockv = true ;
}
}
if ( $t [ 'topic_locked' ] == true && $this -> getModel ( 'SessionModel' ) -> getRank () < RANK_MOD )
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 ;
$lockv = true ;
}
}
//sprawdzić czy edycja tematu
// i ustawić opdowiednie parametry $type = POSTING_EDITTOPIC
$first = $this -> getModel ( 'PostsModel' ) -> getFirstPost ( $t [ 'topic_id' ]);
$first = $this -> getModel ( 'PostsModel' ) -> getFirstPost ( $t [ 'topic_id' ]);
if ( $first [ 'post_id' ] == $_GET [ '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 )
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 ;
$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 ());
$topic_id = $this -> getModel ( 'PostsModel' ) -> addTopic ( $_POST [ 'topic' ], $_POST [ 'post' ], $_GET [ 'id' ], $this -> getModel ( 'SessionModel' ) -> getID ());
if ( $topic_id != null )
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 ;
$lockv = true ;
}
}
else
else
@ -425,7 +439,7 @@ class MainController extends Controller
if ( $type == POSTING_EDITTOPIC )
if ( $type == POSTING_EDITTOPIC )
$this -> getModel ( 'PostsModel' ) -> changeTopic ( $t [ 'topic_id' ], $_POST [ 'topic' ]);
$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 ;
$lockv = true ;
break ;
break ;
@ -433,7 +447,7 @@ class MainController extends Controller
case POSTING_REPLY :
case POSTING_REPLY :
$this -> getModel ( 'PostsModel' ) -> addPost ( $_GET [ 'id' ], $this -> getModel ( 'SessionModel' ) -> getID (), $_POST [ 'post' ]);
$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 ;
$lockv = true ;
break ;
break ;
}
}
@ -478,7 +492,7 @@ class MainController extends Controller
if ( ! $this -> getModel ( 'SessionModel' ) -> isLogged ())
if ( ! $this -> getModel ( 'SessionModel' ) -> isLogged ())
$this -> forward ( 'index.php' );
$this -> forward ( 'index.php' );
else
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 ()
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 ;
$_GET [ 'id' ] = ( isset ( $_GET [ 'id' ])) ? trim ( strip_tags ( $this -> db -> real_escape_string ( $_GET [ 'id' ]))) : 0 ;
if ( $this -> getModel ( 'UsersModel' ) -> getUserInformation ( $_GET [ 'id' ]) == null )
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
else
{
{
//$this->getView('MainView')->putExistingModel('PostsModel', $this->getModel('PostsModel'));
$this -> getView ( 'MainView' ) -> viewprofile ();
$this -> getView ( 'MainView' ) -> viewprofile ();
}
}
}
}
@ -507,7 +520,7 @@ class MainController extends Controller
if ( ! $this -> getModel ( 'SessionModel' ) -> isLogged ())
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
else
{
{
@ -580,7 +593,7 @@ class MainController extends Controller
$this -> getModel ( 'UsersModel' ) -> changeUserPassword ( $this -> getModel ( 'SessionModel' ) -> getID (), sha1 ( $_POST [ 'passwd' ]));
$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 -> 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 ;
$lockv = true ;
}
}
@ -607,7 +620,7 @@ class MainController extends Controller
$this -> getModel ( 'SessionModel' ) -> deleteSession ();
$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 ()
public function login ()
@ -615,11 +628,8 @@ class MainController extends Controller
$this -> loadDependencies ();
$this -> loadDependencies ();
$this -> loadModel ( 'BansModel' );
$this -> loadModel ( 'BansModel' );
if ( $_SERVER [ 'REQUEST_SCHEME' ] == 'http' )
$this -> forward ( 'https://' . $_SERVER [ 'SERVER_NAME' ] . $_SERVER [ 'REQUEST_URI' ]);
if ( $this -> getModel ( 'SessionModel' ) -> isLogged ())
if ( $this -> getModel ( 'SessionModel' ) -> isLogged ())
$this -> forward ( 'index.php' );
$this -> forward ( buildURL ( 'index.php' ));
$msg = '' ;
$msg = '' ;
if ( isset ( $_POST [ 'nick' ], $_POST [ 'passwd' ]))
if ( isset ( $_POST [ 'nick' ], $_POST [ 'passwd' ]))
@ -640,7 +650,7 @@ class MainController extends Controller
if ( $ban_info == null )
if ( $ban_info == null )
{
{
$this -> getModel ( 'SessionModel' ) -> registerNewSession ( $userinfo [ 'user_id' ]);
$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
else
{
{
@ -663,9 +673,6 @@ class MainController extends Controller
if ( $this -> getModel ( 'SessionModel' ) -> isLogged ())
if ( $this -> getModel ( 'SessionModel' ) -> isLogged ())
$this -> forward ( 'index.php' );
$this -> forward ( 'index.php' );
if ( $_SERVER [ 'REQUEST_SCHEME' ] == 'http' )
$this -> forward ( 'https://' . $_SERVER [ 'SERVER_NAME' ] . $_SERVER [ 'REQUEST_URI' ]);
$msg = '' ;
$msg = '' ;
if ( isset ( $_POST [ 'nick' ], $_POST [ 'passwd' ], $_POST [ 'passwd_confirm' ], $_POST [ 'email' ]))
if ( isset ( $_POST [ 'nick' ], $_POST [ 'passwd' ], $_POST [ 'passwd_confirm' ], $_POST [ 'email' ]))
@ -694,7 +701,7 @@ class MainController extends Controller
if ( $msg == '' )
if ( $msg == '' )
{
{
$this -> getModel ( 'UsersModel' ) -> createNewUser ( $_POST [ 'nick' ], sha1 ( $_POST [ 'passwd' ]), $_POST [ 'email' ]);
$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 ;
$lockv = true ;
}
}
}
}