Ejemplo n.º 1
0
 public static function run_admin()
 {
     JxBotConfig::setup_environment();
     require_once dirname(__FILE__) . '/admin.php';
     session_name(JxBotConfig::SESSION_NAME);
     session_start();
     JxBotAdmin::admin_generate();
 }
Ejemplo n.º 2
0
The above copyright notice, preamble and this permission notice shall be 
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*******************************************************************************/
if (!defined('JXBOT')) {
    die('Direct script access not permitted.');
}
$error = false;
if (isset($_POST['username']) || isset($_POST['password'])) {
    $logged_in = JxBotAdmin::check_and_login();
    if (!$logged_in) {
        $error = true;
    }
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JxBot: Administration</title>
<link rel="base" href="<?php 
print JxBotConfig::bot_url();
?>
jxbot/">
<!--link href="https://fonts.googleapis.com/css?family=Roboto+Condensed|Oswald:700" rel="stylesheet" type="text/css"-->
Ejemplo n.º 3
0
    public static function check_and_login()
    {
        $inputs = JxBotUtil::inputs('username,password');
        /* check the user hasn't logged in too often recently */
        $stmt = JxBotDB::$db->prepare('SELECT COUNT(*) FROM login
			WHERE stamp > DATE_SUB(NOW(), INTERVAL 1 MINUTE)
				AND username=?');
        $stmt->execute(array($inputs['username']));
        $recent_logins = intval($stmt->fetchAll(PDO::FETCH_NUM)[0][0]);
        if ($recent_logins > 5) {
            return false;
        }
        /* are credentials wrong? */
        if (JxBotConfig::option('admin_user') != $inputs['username'] || JxBotConfig::option('admin_hash') != hash('sha256', $inputs['password'])) {
            $stmt = JxBotDB::$db->prepare('INSERT INTO login
				(username, note) VALUES (?, ?)');
            $stmt->execute(array($inputs['username'], 'failure'));
            return false;
        }
        /* do the login */
        $_SESSION['jxbot-admin'] = 1;
        $stmt = JxBotDB::$db->prepare('INSERT INTO login
			(username, note) VALUES (?, ?)');
        $stmt->execute(array($inputs['username'], 'success'));
        $_SESSION['jxbot-last'] = time();
        /* generate the admin page */
        JxBotAdmin::admin_generate();
        return true;
    }