first commit
This commit is contained in:
79
autoload/admin/class.Site.php
Normal file
79
autoload/admin/class.Site.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
namespace admin;
|
||||
|
||||
class Site
|
||||
{
|
||||
public static function special_actions()
|
||||
{
|
||||
$sa = \S::get( 's-action' );
|
||||
|
||||
switch ( $sa )
|
||||
{
|
||||
case 'user-logon':
|
||||
|
||||
$result = \admin\factory\Users::logon( \S::get( 'login' ), \S::get( 'password' ) );
|
||||
|
||||
if ( $result == 1 )
|
||||
\S::set_session( 'user', \admin\factory\Users::details( \S::get( 'login' ) ) );
|
||||
else
|
||||
{
|
||||
if ( $result == -1 )
|
||||
\S::alert( 'Z powodu nieudanych 5 prób logowania Twoje konto zostało zablokowane.' );
|
||||
else
|
||||
\S::alert( 'Podane hasło jest nieprawidłowe, lub brak użytkownika o podanym loginie.' );
|
||||
}
|
||||
header( 'Location: /admin/dashboard/main_view/' );
|
||||
exit;
|
||||
break;
|
||||
|
||||
case 'user-logout':
|
||||
session_destroy();
|
||||
header( 'Location: /admin/' );
|
||||
exit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static function route()
|
||||
{
|
||||
$_SESSION['admin'] = true;
|
||||
|
||||
if ( \S::get( 'p' ) )
|
||||
\S::set_session( 'p' , \S::get( 'p' ) );
|
||||
|
||||
$page = \S::get_session( 'p' );
|
||||
|
||||
$class = '\admin\controls\\';
|
||||
|
||||
$results = explode( '_', \S::get( 'module' ) );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
$class .= ucfirst( $row );
|
||||
|
||||
$action = \S::get( 'action' );
|
||||
|
||||
if ( class_exists( $class ) and method_exists( new $class, $action ) )
|
||||
return call_user_func_array( array( $class, $action ), array() );
|
||||
else
|
||||
{
|
||||
\S::alert( 'Nieprawidłowy adres url.' );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static public function update()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( $results = $mdb -> select( 'pp_updates', [ 'name' ], [ 'done' => 0 ] ) )
|
||||
{
|
||||
foreach ( $results as $row )
|
||||
{
|
||||
$class = '\admin\factory\Update';
|
||||
$method = $row['name'];
|
||||
|
||||
if ( class_exists( $class ) and method_exists( new $class, $method ) )
|
||||
call_user_func_array( array( $class, $method ), array() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user