Skip to content

Commit

Permalink
* Reorganizing
Browse files Browse the repository at this point in the history
  • Loading branch information
matricali committed Jun 30, 2018
1 parent 3f2f8bd commit 058928e
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions x3n4.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<?php
$user = 'x3n4';
$password = 'P455W0rd';

require_auth($user, $password);

define('X3N4_VERSION', 'v0.1.5-alpha');

session_start();
$user = 'x3n4';
$password = 'P455W0rd';

/**
* Functions
Expand Down Expand Up @@ -90,10 +87,30 @@ function output_json($output = '')
session_write_close();
exit(0);
}
function require_auth($user, $password)
{
$AUTH_USER = $user;
$AUTH_PASS = $password;
header('Cache-Control: no-cache, must-revalidate, max-age=0');
$has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));
$is_not_authenticated = (
!$has_supplied_credentials ||
$_SERVER['PHP_AUTH_USER'] != $AUTH_USER ||
$_SERVER['PHP_AUTH_PW'] != $AUTH_PASS
);
if ($is_not_authenticated) {
header('HTTP/1.1 401 Authorization Required');
header('WWW-Authenticate: Basic realm="Access denied"');
exit;
}
}

/**
* CORE
*/
require_auth($user, $password);
session_start();

if (!empty($_SESSION['pwd'])) {
chdir($_SESSION['pwd']);
}
Expand Down Expand Up @@ -133,22 +150,6 @@ function output_json($output = '')
$output = execute_command(base64_decode($_REQUEST['cmd']) . ' 2>&1');
output_json(base64_encode($output));
}
function require_auth($user, $password) {
$AUTH_USER = $user;
$AUTH_PASS = $password;
header('Cache-Control: no-cache, must-revalidate, max-age=0');
$has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));
$is_not_authenticated = (
!$has_supplied_credentials ||
$_SERVER['PHP_AUTH_USER'] != $AUTH_USER ||
$_SERVER['PHP_AUTH_PW'] != $AUTH_PASS
);
if ($is_not_authenticated) {
header('HTTP/1.1 401 Authorization Required');
header('WWW-Authenticate: Basic realm="Access denied"');
exit;
}
}

/**
* HTML
Expand Down

0 comments on commit 058928e

Please sign in to comment.