Public server page
parent
95d30f9619
commit
a9f0f64c78
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP Server Monitor
|
||||||
|
* Monitor your servers and websites.
|
||||||
|
*
|
||||||
|
* This file is part of PHP Server Monitor.
|
||||||
|
* PHP Server Monitor is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* PHP Server Monitor is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with PHP Server Monitor. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @package phpservermon
|
||||||
|
* @author Pepijn Over <pep@mailbox.org>
|
||||||
|
* @copyright Copyright (c) 2008-2017 Pepijn Over <pep@mailbox.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
||||||
|
* @version Release: @package_version@
|
||||||
|
* @link http://www.phpservermonitor.org/
|
||||||
|
**/
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
define('PSM_PUBLIC_PAGE', true);
|
||||||
|
|
||||||
|
require __DIR__ . '/src/bootstrap.php';
|
||||||
|
|
||||||
|
$router->run('server');
|
||||||
|
}
|
|
@ -108,6 +108,19 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for a public page var
|
||||||
|
// This should be defined in the config
|
||||||
|
if (!defined('PSM_PUBLIC')) {
|
||||||
|
define('PSM_PUBLIC', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for a public page
|
||||||
|
// This variable is for internal use
|
||||||
|
// and should not be changed by the user manualy
|
||||||
|
if (!defined('PSM_PUBLIC_PAGE')) {
|
||||||
|
define('PSM_PUBLIC_PAGE', false);
|
||||||
|
}
|
||||||
|
|
||||||
$lang = psm_get_conf('language', 'en_US');
|
$lang = psm_get_conf('language', 'en_US');
|
||||||
psm_load_lang($lang);
|
psm_load_lang($lang);
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,7 @@ $sm_lang = array(
|
||||||
'level' => 'Level',
|
'level' => 'Level',
|
||||||
'level_10' => 'Administrator',
|
'level_10' => 'Administrator',
|
||||||
'level_20' => 'User',
|
'level_20' => 'User',
|
||||||
|
'level_30' => 'Anonymous',
|
||||||
'level_description' => '<b>Administrators</b> have full access: they can manage servers, users and edit the
|
'level_description' => '<b>Administrators</b> have full access: they can manage servers, users and edit the
|
||||||
global configuration.<br><b>Users</b> can only view and run the updater for the
|
global configuration.<br><b>Users</b> can only view and run the updater for the
|
||||||
servers that have been assigned to them.',
|
servers that have been assigned to them.',
|
||||||
|
|
|
@ -124,7 +124,7 @@ abstract class AbstractController implements ControllerInterface
|
||||||
* @var int $user_level_required
|
* @var int $user_level_required
|
||||||
* @see setMinUserLevelRequired()
|
* @see setMinUserLevelRequired()
|
||||||
*/
|
*/
|
||||||
protected $user_level_required = PSM_USER_USER;
|
protected $user_level_required = (PSM_PUBLIC && PSM_PUBLIC_PAGE) ? PSM_USER_ANONYMOUS : PSM_USER_USER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required user level for certain actions
|
* Required user level for certain actions
|
||||||
|
|
|
@ -100,6 +100,17 @@ class User
|
||||||
}
|
}
|
||||||
$this->session = $session;
|
$this->session = $session;
|
||||||
|
|
||||||
|
if (PSM_PUBLIC === true && PSM_PUBLIC_PAGE === true) {
|
||||||
|
$query_user = $this->db_connection->prepare('SELECT * FROM ' .
|
||||||
|
PSM_DB_PREFIX . 'users WHERE user_name = :user_name and level = :level');
|
||||||
|
$query_user->bindValue(':user_name', "__PUBLIC__", \PDO::PARAM_STR);
|
||||||
|
$query_user->bindValue(':level', PSM_USER_ANONYMOUS, \PDO::PARAM_STR);
|
||||||
|
$query_user->execute();
|
||||||
|
|
||||||
|
// get result row (as an object)
|
||||||
|
$this->setUserLoggedIn($query_user->fetchObject()->user_id);
|
||||||
|
}
|
||||||
|
|
||||||
if ((!defined('PSM_INSTALL') || !PSM_INSTALL)) {
|
if ((!defined('PSM_INSTALL') || !PSM_INSTALL)) {
|
||||||
// check the possible login actions:
|
// check the possible login actions:
|
||||||
// 1. login via session data (happens each time user opens a page on your php project AFTER
|
// 1. login via session data (happens each time user opens a page on your php project AFTER
|
||||||
|
|
|
@ -39,7 +39,7 @@ class UserValidator
|
||||||
* Available editable user levels
|
* Available editable user levels
|
||||||
* @var array $user_levels
|
* @var array $user_levels
|
||||||
*/
|
*/
|
||||||
protected $user_levels = array(PSM_USER_ADMIN, PSM_USER_USER);
|
protected $user_levels = array(PSM_USER_ADMIN, PSM_USER_USER, PSM_USER_ANONYMOUS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User service
|
* User service
|
||||||
|
|
Loading…
Reference in New Issue