0
0
Fork 0
This repository has been archived on 2020-08-03. You can view files and clone it, but cannot push or open issues or pull requests.
bryanpedini.it_old/lib/php/switch_action.php

35 lines
1.7 KiB
PHP

<?php
switch ( $_SERVER [ 'QUERY_STRING' ] ) {
case "/login":
if ( isset ( $_SESSION [ 'user_id' ] ) ) {
header ( "Location: " . $environment [ 'installation_path' ] );
exit;
}
if ( isset ( $_POST [ 'username' ] ) && isset ( $_POST [ 'password' ] ) ) {
//TODO: maybe implement two factor authentication, if possible
include ( $environment [ 'installation_path' ] . '/lib/php/user_login.php' );
exit;
}
include ( $environment [ 'installation_path' ] . '/lib/php/templates/login.php' );
break;
case "/insert":
if ( ! isset ( $_SESSION [ 'user_id' ] ) || $_SESSION [ 'user_permission_level' ] != 0 ) {
header ( "Location: " . $environment [ 'installation_path' ] . "/login" );
exit;
}
if ( isset ( $_POST [ 'new_article' ] ) ) {
//TODO: insert the new article into the database, previous validation of course!
$_SESSION [ 'section_id'] = 0; //TODO: get the ID of the last article just inserted and redirect the editor to the new article for preview.
header ( "Location: " . $environment [ 'installation_path' ] );
exit;
}
include ( $environment [ 'installation_path' ] . '/lib/php/templates/insert.php' );
break;
case "/contactme":
if ( ! isset ( $_POST [ 'contact_message' ] ) ) {
header ( "Location: " . $environment [ 'installation_path' ] );
exit;
}
include ( $environment [ 'installation_path' ] . '/lib/php/contactme.php' );
break;
}