commit 035a2521fee0604cf11912bc65235c379beef1fc Author: djpbessems Date: Wed Jan 16 11:37:35 2019 +0100 import local files into repo diff --git a/include/JWT/BeforeValidException.php b/include/JWT/BeforeValidException.php new file mode 100644 index 0000000..a6ee2f7 --- /dev/null +++ b/include/JWT/BeforeValidException.php @@ -0,0 +1,7 @@ + + * @author Anant Narayanan + * @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD + * @link https://github.com/firebase/php-jwt + */ +class JWT +{ + + /** + * When checking nbf, iat or expiration times, + * we want to provide some extra leeway time to + * account for clock skew. + */ + public static $leeway = 0; + + /** + * Allow the current timestamp to be specified. + * Useful for fixing a value within unit testing. + * + * Will default to PHP time() value if null. + */ + public static $timestamp = null; + + public static $supported_algs = array( + 'HS256' => array('hash_hmac', 'SHA256'), + 'HS512' => array('hash_hmac', 'SHA512'), + 'HS384' => array('hash_hmac', 'SHA384'), + 'RS256' => array('openssl', 'SHA256'), + 'RS384' => array('openssl', 'SHA384'), + 'RS512' => array('openssl', 'SHA512'), + ); + + /** + * Decodes a JWT string into a PHP object. + * + * @param string $jwt The JWT + * @param string|array $key The key, or map of keys. + * If the algorithm used is asymmetric, this is the public key + * @param array $allowed_algs List of supported verification algorithms + * Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256' + * + * @return object The JWT's payload as a PHP object + * + * @throws UnexpectedValueException Provided JWT was invalid + * @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed + * @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf' + * @throws BeforeValidException Provided JWT is trying to be used before it's been created as defined by 'iat' + * @throws ExpiredException Provided JWT has since expired, as defined by the 'exp' claim + * + * @uses jsonDecode + * @uses urlsafeB64Decode + */ + public static function decode($jwt, $key, array $allowed_algs = array()) + { + $timestamp = is_null(static::$timestamp) ? time() : static::$timestamp; + + if (empty($key)) { + throw new InvalidArgumentException('Key may not be empty'); + } + $tks = explode('.', $jwt); + if (count($tks) != 3) { + throw new UnexpectedValueException('Wrong number of segments'); + } + list($headb64, $bodyb64, $cryptob64) = $tks; + if (null === ($header = static::jsonDecode(static::urlsafeB64Decode($headb64)))) { + throw new UnexpectedValueException('Invalid header encoding'); + } + if (null === $payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64))) { + throw new UnexpectedValueException('Invalid claims encoding'); + } + if (false === ($sig = static::urlsafeB64Decode($cryptob64))) { + throw new UnexpectedValueException('Invalid signature encoding'); + } + if (empty($header->alg)) { + throw new UnexpectedValueException('Empty algorithm'); + } + if (empty(static::$supported_algs[$header->alg])) { + throw new UnexpectedValueException('Algorithm not supported'); + } + if (!in_array($header->alg, $allowed_algs)) { + throw new UnexpectedValueException('Algorithm not allowed'); + } + if (is_array($key) || $key instanceof \ArrayAccess) { + if (isset($header->kid)) { + if (!isset($key[$header->kid])) { + throw new UnexpectedValueException('"kid" invalid, unable to lookup correct key'); + } + $key = $key[$header->kid]; + } else { + throw new UnexpectedValueException('"kid" empty, unable to lookup correct key'); + } + } + + // Check the signature + if (!static::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) { + throw new SignatureInvalidException('Signature verification failed'); + } + + // Check if the nbf if it is defined. This is the time that the + // token can actually be used. If it's not yet that time, abort. + if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) { + throw new BeforeValidException( + 'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->nbf) + ); + } + + // Check that this token has been created before 'now'. This prevents + // using tokens that have been created for later use (and haven't + // correctly used the nbf claim). + if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway)) { + throw new BeforeValidException( + 'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat) + ); + } + + // Check if this token has expired. + if (isset($payload->exp) && ($timestamp - static::$leeway) >= $payload->exp) { + throw new ExpiredException('Expired token'); + } + + return $payload; + } + + /** + * Converts and signs a PHP object or array into a JWT string. + * + * @param object|array $payload PHP object or array + * @param string $key The secret key. + * If the algorithm used is asymmetric, this is the private key + * @param string $alg The signing algorithm. + * Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256' + * @param mixed $keyId + * @param array $head An array with header elements to attach + * + * @return string A signed JWT + * + * @uses jsonEncode + * @uses urlsafeB64Encode + */ + public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $head = null) + { + $header = array('typ' => 'JWT', 'alg' => $alg); + if ($keyId !== null) { + $header['kid'] = $keyId; + } + if ( isset($head) && is_array($head) ) { + $header = array_merge($head, $header); + } + $segments = array(); + $segments[] = static::urlsafeB64Encode(static::jsonEncode($header)); + $segments[] = static::urlsafeB64Encode(static::jsonEncode($payload)); + $signing_input = implode('.', $segments); + + $signature = static::sign($signing_input, $key, $alg); + $segments[] = static::urlsafeB64Encode($signature); + + return implode('.', $segments); + } + + /** + * Sign a string with a given key and algorithm. + * + * @param string $msg The message to sign + * @param string|resource $key The secret key + * @param string $alg The signing algorithm. + * Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256' + * + * @return string An encrypted message + * + * @throws DomainException Unsupported algorithm was specified + */ + public static function sign($msg, $key, $alg = 'HS256') + { + if (empty(static::$supported_algs[$alg])) { + throw new DomainException('Algorithm not supported'); + } + list($function, $algorithm) = static::$supported_algs[$alg]; + switch($function) { + case 'hash_hmac': + return hash_hmac($algorithm, $msg, $key, true); + case 'openssl': + $signature = ''; + $success = openssl_sign($msg, $signature, $key, $algorithm); + if (!$success) { + throw new DomainException("OpenSSL unable to sign data"); + } else { + return $signature; + } + } + } + + /** + * Verify a signature with the message, key and method. Not all methods + * are symmetric, so we must have a separate verify and sign method. + * + * @param string $msg The original message (header and body) + * @param string $signature The original signature + * @param string|resource $key For HS*, a string key works. for RS*, must be a resource of an openssl public key + * @param string $alg The algorithm + * + * @return bool + * + * @throws DomainException Invalid Algorithm or OpenSSL failure + */ + private static function verify($msg, $signature, $key, $alg) + { + if (empty(static::$supported_algs[$alg])) { + throw new DomainException('Algorithm not supported'); + } + + list($function, $algorithm) = static::$supported_algs[$alg]; + switch($function) { + case 'openssl': + $success = openssl_verify($msg, $signature, $key, $algorithm); + if ($success === 1) { + return true; + } elseif ($success === 0) { + return false; + } + // returns 1 on success, 0 on failure, -1 on error. + throw new DomainException( + 'OpenSSL error: ' . openssl_error_string() + ); + case 'hash_hmac': + default: + $hash = hash_hmac($algorithm, $msg, $key, true); + if (function_exists('hash_equals')) { + return hash_equals($signature, $hash); + } + $len = min(static::safeStrlen($signature), static::safeStrlen($hash)); + + $status = 0; + for ($i = 0; $i < $len; $i++) { + $status |= (ord($signature[$i]) ^ ord($hash[$i])); + } + $status |= (static::safeStrlen($signature) ^ static::safeStrlen($hash)); + + return ($status === 0); + } + } + + /** + * Decode a JSON string into a PHP object. + * + * @param string $input JSON string + * + * @return object Object representation of JSON string + * + * @throws DomainException Provided string was invalid JSON + */ + public static function jsonDecode($input) + { + if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) { + /** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you + * to specify that large ints (like Steam Transaction IDs) should be treated as + * strings, rather than the PHP default behaviour of converting them to floats. + */ + $obj = json_decode($input, false, 512, JSON_BIGINT_AS_STRING); + } else { + /** Not all servers will support that, however, so for older versions we must + * manually detect large ints in the JSON string and quote them (thus converting + *them to strings) before decoding, hence the preg_replace() call. + */ + $max_int_length = strlen((string) PHP_INT_MAX) - 1; + $json_without_bigints = preg_replace('/:\s*(-?\d{'.$max_int_length.',})/', ': "$1"', $input); + $obj = json_decode($json_without_bigints); + } + + if (function_exists('json_last_error') && $errno = json_last_error()) { + static::handleJsonError($errno); + } elseif ($obj === null && $input !== 'null') { + throw new DomainException('Null result with non-null input'); + } + return $obj; + } + + /** + * Encode a PHP object into a JSON string. + * + * @param object|array $input A PHP object or array + * + * @return string JSON representation of the PHP object or array + * + * @throws DomainException Provided object could not be encoded to valid JSON + */ + public static function jsonEncode($input) + { + $json = json_encode($input); + if (function_exists('json_last_error') && $errno = json_last_error()) { + static::handleJsonError($errno); + } elseif ($json === 'null' && $input !== null) { + throw new DomainException('Null result with non-null input'); + } + return $json; + } + + /** + * Decode a string with URL-safe Base64. + * + * @param string $input A Base64 encoded string + * + * @return string A decoded string + */ + public static function urlsafeB64Decode($input) + { + $remainder = strlen($input) % 4; + if ($remainder) { + $padlen = 4 - $remainder; + $input .= str_repeat('=', $padlen); + } + return base64_decode(strtr($input, '-_', '+/')); + } + + /** + * Encode a string with URL-safe Base64. + * + * @param string $input The string you want encoded + * + * @return string The base64 encode of what you passed in + */ + public static function urlsafeB64Encode($input) + { + return str_replace('=', '', strtr(base64_encode($input), '+/', '-_')); + } + + /** + * Helper method to create a JSON error. + * + * @param int $errno An error number from json_last_error() + * + * @return void + */ + private static function handleJsonError($errno) + { + $messages = array( + JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', + JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON', + JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', + JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', + JSON_ERROR_UTF8 => 'Malformed UTF-8 characters' //PHP >= 5.3.3 + ); + throw new DomainException( + isset($messages[$errno]) + ? $messages[$errno] + : 'Unknown JSON error: ' . $errno + ); + } + + /** + * Get the number of bytes in cryptographic strings. + * + * @param string + * + * @return int + */ + private static function safeStrlen($str) + { + if (function_exists('mb_strlen')) { + return mb_strlen($str, '8bit'); + } + return strlen($str); + } +} diff --git a/include/JWT/SignatureInvalidException.php b/include/JWT/SignatureInvalidException.php new file mode 100644 index 0000000..27332b2 --- /dev/null +++ b/include/JWT/SignatureInvalidException.php @@ -0,0 +1,7 @@ +LDAP['Server'], $settings->LDAP['Port']); + + // Strict namingconvention: only allow alphabetic characters + $strGivenname = preg_replace('([^a-zA-Z]*)', '', $_POST['username']); + $strUsername = $settings->LDAP['Domain'] . '\\' . $strGivenname; + + if (@ldap_bind($ds, $strUsername, utf8_encode($_POST['password']))) { + // Successful auth; get additional userdetails from Active Directory + $ldapSearchResults = ldap_search($ds, $settings->LDAP['BaseDN'], "sAMAccountName=$strGivenname"); + $strFullname = ldap_get_entries($ds, $ldapSearchResults)[0]['cn'][0]; + // Create JWT-payload + $jwtPayload = [ + 'iat' => time(), // Issued at: time when the token was generated + 'iss' => $_SERVER['SERVER_NAME'], // Issuer + 'sub' => $strGivenname, // Subject (ie. username) + 'name' => $strFullname // Full name (as retrieved from AD) + ]; + + $secureToken = JWT::encode($jwtPayload, base64_decode($settings->JWT['PrivateKey_base64'])); + return ['status' => 'Success', 'token' => $secureToken]; + } else { + // LDAP authentication failed! + return ['status' => 'Fail', 'reason' => '1']; + } + } else { + // Empty username or passwords not allowed! + return ['status' => 'Fail', 'reason' => '1']; + } +} + +function storeToken (string $username, string $password, object $cookie) { + global $settings; + + +} + +function retrieveToken (string $username, ) { + global $settings; + +} + +function validateCookie (int $expiration, string $username, string $securetoken) { +# $_COOKIE['Exp'], $_COOKIE['Sub'], $_COOKIE['JWT'] + global $settings; + + If ($expiration > ) +} + +?> \ No newline at end of file diff --git a/include/lucidAuth.template.php b/include/lucidAuth.template.php new file mode 100644 index 0000000..d972ec6 --- /dev/null +++ b/include/lucidAuth.template.php @@ -0,0 +1,123 @@ + + + + + lucidAuth + + + + + + + + + + + + + + +
+
+ +
+ +
+
+ +
+ + +PAGE; + +$contentLayout['login'] = << +
+ Login Details +
    +
  • + + + +
  • +
  • + + +
  • +
  • + +
  • +
  • +   +
  • +
  • + Inloggegevens verkrijgbaar op aanvraag! +
  • +
+
+ PVR [Secure] +LOGIN; + +$contentLayout['manage'] = << + Ingelogd als {$_SESSION['fullname']} --- [Browser plugin
Select browser:[v0.2.122.4]
] [EN NL] [Log uit]
+ +MANAGE; + +$contentLayout['dialog'] = << +
  • + +
  • +
  • + +
  • + +DIALOG; + +?> \ No newline at end of file diff --git a/lucidAuth.config.php.example b/lucidAuth.config.php.example new file mode 100644 index 0000000..9165393 --- /dev/null +++ b/lucidAuth.config.php.example @@ -0,0 +1,51 @@ + [ + 'Server' => 'server.domain.tld', + // FQDN of the LDAP-server + 'Port' => 389, + // Port of the LDAP-server; default port is 389 + 'BaseDN' => 'OU=Users,DC=domain,DC=tld', + // Location of your useraccounts + // Syntax: + // 'OU=container,DC=domain,DC=tld' + 'Domain' => 'domain' + // Specify the NetBios name of the domain; to allow users to log on with just their usernames. + ], + + 'DomainNames' => ['*.subdomain.domain.{(tld1|tld2)}'], + + 'Sqlite' => [ + 'Path' => '../config/lucidAuth.sqlite.db' + // Relative path to the location where the database should be stored + ], + + 'ApiKeyFile' => 'externalResource.api.key', + // File containing your token + + 'JWT' => [ + 'PrivateKey_base64' => 'result of base64_encode()', + 'Algorithm' => [ + 'HS256', + ] + ], + + 'Cookie' => [ + 'Duration' => 2592000, + // In seconds (2592000 is equivalent to 30 days) +# 'Prefix' => 'lucidAuth_' + ], + + 'Debug' => [ + 'Verbose' => False, + 'LogToFile' => False + ] + +); + +?> \ No newline at end of file diff --git a/public/images/bg_header.gif b/public/images/bg_header.gif new file mode 100644 index 0000000..bec2069 Binary files /dev/null and b/public/images/bg_header.gif differ diff --git a/public/images/bg_header_l.gif b/public/images/bg_header_l.gif new file mode 100644 index 0000000..f649f9f Binary files /dev/null and b/public/images/bg_header_l.gif differ diff --git a/public/images/bg_header_m.gif b/public/images/bg_header_m.gif new file mode 100644 index 0000000..4fbdf3f Binary files /dev/null and b/public/images/bg_header_m.gif differ diff --git a/public/images/bg_header_r.gif b/public/images/bg_header_r.gif new file mode 100644 index 0000000..028a559 Binary files /dev/null and b/public/images/bg_header_r.gif differ diff --git a/public/images/bg_main_bottom.gif b/public/images/bg_main_bottom.gif new file mode 100644 index 0000000..7bff6db Binary files /dev/null and b/public/images/bg_main_bottom.gif differ diff --git a/public/images/tag_pvr.png b/public/images/tag_pvr.png new file mode 100644 index 0000000..1a58550 Binary files /dev/null and b/public/images/tag_pvr.png differ diff --git a/public/lucidAuth.login.php b/public/lucidAuth.login.php new file mode 100644 index 0000000..3dc7af2 --- /dev/null +++ b/public/lucidAuth.login.php @@ -0,0 +1,34 @@ +Debug['Verbose']; + + if ($_POST['do'] == 'login') { + $result = authenticateLDAP($_POST['username'], $_POST['password']); + if ($result['status'] == 'Success') { + // Since this request is only ever called through an AJAX-request; return JSON object + echo '{"Result":"Success","Location":""}' . PHP_EOL; + } else { + switch ($result['reason']) { + case '1': + echo '{"Result":"Fail","Reason":"Invalid username and/or password"}' . PHP_EOL; + break; + default: + echo '{"Result":"Fail","Reason":"Uncaught error"}' . PHP_EOL; + } + } + } else { + $stylevar['content']['top'] = '-125px'; + $stylevar['content']['margin-left'] = '-225px'; + $stylevar['content']['height'] = '220px'; + $stylevar['content']['width'] = '450px'; + + include_once('../include/lucidAuth.template.php'); + + $pageLayout = str_replace('', $contentLayout['login'], $pageLayout); + echo $pageLayout; + } + +?> \ No newline at end of file diff --git a/public/lucidAuth.validateRequest.php b/public/lucidAuth.validateRequest.php new file mode 100644 index 0000000..c0d88a1 --- /dev/null +++ b/public/lucidAuth.validateRequest.php @@ -0,0 +1,40 @@ + $value) { + if (strpos($key, 'HTTP_') === 0) { + // Trim and then convert all headers to camelCase + $proxyHeaders[str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))))] = $value; + } + } + // Keep only headers relevant for proxying + $proxyHeaders = array_filter($proxyHeaders, function ($key) { + return substr($key, 0, 10) === 'XForwarded'; + }, ARRAY_FILTER_USE_KEY); + + // For debugging purposes - enable it in ../lucidAuth.config.php + if ($settings->Debug['LogToFile']) file_put_contents('../requestHeaders.log', (new DateTime())->format('Y-m-d\TH:i:s.u') . ' --- ' . (json_encode($proxyHeaders, JSON_FORCE_OBJECT) . PHP_EOL), FILE_APPEND); + +# if (sizeof($proxyHeaders) == 0) { + if (False) { + // Non-proxied request; this is senseless, go fetch! + header("HTTP/1.1 403 Forbidden"); + exit; + } + +# if (validateToken($_COOKIE['Exp'], $_COOKIE['Sub'], $_COOKIE['JWT']) != True) { + if (False) { + // No or invalid authentication token found, redirecting to loginpage + header("HTTP/1.1 401 Unauthorized"); +#remember to include cookies/headers/something + header("Location: lucidAuth.login.php"); + } else { + // Valid authentication token found + header("HTTP/1.1 202 Accepted"); + exit; + } + +?> \ No newline at end of file diff --git a/public/misc/script.index.js b/public/misc/script.index.js new file mode 100644 index 0000000..e1f4254 --- /dev/null +++ b/public/misc/script.index.js @@ -0,0 +1,57 @@ +$(document).ready(function(){ + // Allow user to press enter to submit credentials + $('#username, #password').keypress(function(event) { + if (event.which == 13) { + $('#btnlogin').trigger('click'); + } + }); + + $('#btnlogin').click(function() { + // Give feedback that request has been submitted (and prevent repeated requests) + $('#btnlogin').prop('disabled', true).css({ + 'background': '#999 url(data:image/gif;base64,R0lGODlhEAAQAPIAAJmZmf///7CwsOPj4////9fX18rKysPDwyH+GkNyZWF0ZWQgd2l0aCBhamF4bG9hZC5pbmZvACH5BAAKAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQACgABACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkEAAoAAgAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkEAAoAAwAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkEAAoABAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQACgAFACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQACgAGACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAAKAAcALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==) no-repeat center', + 'color': 'transparent', + 'transform': 'rotateX(180deg)' + }); + $.post("lucidAuth.login.php", { + do: "login", + username: $('#username').val(), + password: $('#password').val() + }) + .done(function(data,status) { + try { + var ajaxData = JSON.parse(data); + } + catch (e) { + console.log(data); + } + if (ajaxData.Result == 'Success') { + $('#btnlogin').css({ + 'background': 'green url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAaklEQVQ4jeXOMQ5AQBBG4T2BC4i76EWich7ncAKbqCRuodTqnMNTkFgJs3ZU4tXz/Rlj/hUQv8EpMAClFk9sjUAiHVcCnoFMwhZYgPYG575Xe46aIOyMdJx7ji9GwrEzUgOFCu8DkRp/qxU2BKCUyZR6ygAAAABJRU5ErkJggg==) no-repeat center', + 'transform': 'rotateX(0deg)' + }); + setTimeout(function() { + $('#btnsync').prop('disabled', false).css({ + 'background': '#B50000 linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0) 50%, rgba(255,255,255,0.25) 51%) no-repeat center', + 'color': '#FFF' + }); + window.location.replace(ajaxData.Location); + }, 2250); + } else { + $('#btnlogin').css({ + 'background': 'red url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAv0lEQVQ4jaWT0Q3CMAxELwh1BEag87AJ6hcLlE/KBLABrNEV2h26QaXHj4NMGgpS7sfJJXd24kQqRMiRQC3pIKk2apD0DCEMq25ABZyBmSVmW6vWxH1GmKLPmph7xJQReq5dnNmVPQE7oHOCzrhoMts9vQ1OSbYOCBb92OPkDe6ZkqMwJwa4SdJmtS1/YGsx7e9VUiPpYvPG4tHtGUsvcf+RkpI2mkHZQ3ImLd+fcpuKf32meM5R0iOEMOb2F+EF33vgCePVr8UAAAAASUVORK5CYII=) no-repeat center', + 'transform': 'rotateX(0deg)' + }); + setTimeout(function() { + $('#btnsync').prop('disabled', false).css({ + 'background': '#B50000 linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0) 50%, rgba(255,255,255,0.25) 51%) no-repeat center', + 'color': '#FFF' + }); + // TODO: Add feedback (based on ajaxData.Reason) + // Is the redirect needed? + window.location.replace('lucidAuth.login.php'/*+ '?reason=' + ajaxData.Reason*/); + }, 2250); + } + }); + }); +}); \ No newline at end of file diff --git a/public/misc/script.theme.js b/public/misc/script.theme.js new file mode 100644 index 0000000..7ebde0b --- /dev/null +++ b/public/misc/script.theme.js @@ -0,0 +1,19 @@ +$(document).ready(function() { + if (localStorage.getItem('theme') != '') { + $('html').addClass(localStorage.getItem('theme')); + } + + $('.logo .sub').on('click', function(event) { + if (event.ctrlKey) { + var classes = ["tablecloth", "weave", "madras", "tartan", "seigaiha"]; + var selectedTheme = classes[~~(Math.random()*classes.length)]; + + $('html').removeClass().addClass(selectedTheme); + localStorage.setItem('theme', selectedTheme); + } + if (event.altKey) { + $('html').removeClass(); + localStorage.removeItem('theme'); + } + }); +}); \ No newline at end of file diff --git a/public/misc/script.translation.js b/public/misc/script.translation.js new file mode 100644 index 0000000..ee56a89 --- /dev/null +++ b/public/misc/script.translation.js @@ -0,0 +1,60 @@ +var locales = { + en: { + button_add: "add", + button_cancel: "cancel", + button_continue: "continue", + button_delete: "delete", + button_login: "login", + heading_error: "ERROR!", + label_password: "Password:", + label_username: "Username:", + label_selectbrowser: "Select browser:", + link_install: "Install!", + link_logout: "Logout", + link_plugin: "Browser plugin", + span_credentialsavailable: "Login credentials available upon request!", + span_loggedinas: "Logged in as", + span_plugin: "Browser plugin?" + }, + nl: { + button_add: "voeg toe", + button_cancel: "annuleer", + button_continue: "doorgaan", + button_delete: "verwijder", + button_login: "log in", + heading_error: "FOUT!", + label_password: "Wachtwoord:", + label_username: "Gebruikersnaam:", + label_selectbrowser: "Selecteer browser:", + link_install: "Installeer!", + link_logout: "Log uit", + link_plugin: "Browser plugin", + span_credentialsavailable: "Inloggegevens verkrijgbaar op aanvraag!", + span_loggedinas: "Ingelogd als", + span_plugin: "Browser plugin?" + } // ... etc. +}; + +$(document).ready(function(){ + $('[id^=linklanguage-]').click(function() { + var selectedlang = $(this).attr('id').split('-')[1]; + // Replace text of each element with translated value + $('[data-translation]').each(function(index) { + $(this).text(locales[selectedlang][$(this).data('translation')]); + }); + // Enable/disable (toggle) anchors + $('span#user a.current').removeClass('current'); + $(this).addClass('current'); + + // Store current languagesetting in persistent localstorage + localStorage.setItem('language', selectedlang); + }); + + if (localStorage.getItem('language') !== null) { + $('[data-translation]').each(function(index) { + $(this).text(locales[localStorage.getItem('language')][$(this).data('translation')]); + }); + $('span#user a.current').removeClass('current'); + $('#linklanguage-' + localStorage.getItem('language')).addClass('current'); + } +}); \ No newline at end of file diff --git a/public/misc/style.button.css b/public/misc/style.button.css new file mode 100644 index 0000000..9a22a78 --- /dev/null +++ b/public/misc/style.button.css @@ -0,0 +1,139 @@ +@charset "UTF-8"; +/*! + * + * bttn.css - https://ganapativs.github.io/bttn.css + * Version - 0.2.4 + * Demo: https://bttn.surge.sh + * + * Licensed under the MIT license - http://opensource.org/licenses/MIT + * + * Copyright (c) 2016 Ganapati V S (@ganapativs) + * + */ +/* standalone - .bttn-simple */ +.bttn-default { + color: #fff; +} +.bttn-primary, +.bttn, +.bttn-lg, +.bttn-md, +.bttn-sm, +.bttn-xs { + color: #1d89ff; +} +.bttn-warning { + color: #feab3a; +} +.bttn-danger { + color: #ff5964; +} +.bttn-success { + color: #28b78d; +} +.bttn-royal { + color: #bd2df5; +} +.bttn, +.bttn-lg, +.bttn-md, +.bttn-sm, +.bttn-xs { + margin: 0; + padding: 0; + border-width: 0; + border-color: transparent; + background: transparent; + font-weight: 400; + cursor: pointer; + position: relative; +} +.bttn-lg { + padding: 8px 15px; + font-size: 24px; + font-family: inherit; +} +.bttn-md { + font-size: 20px; + font-family: inherit; + padding: 5px 12px; +} +.bttn-sm { + padding: 4px 10px; + font-size: 16px; + font-family: inherit; +} +.bttn-xs { + padding: 3px 8px; + font-size: 12px; + font-family: inherit; +} +.bttn-simple { + margin: 0; + padding: 0; + border-width: 0; + border-color: transparent; + border-radius: 4px; + background: transparent; + font-weight: 400; + cursor: pointer; + position: relative; + font-size: 20px; + font-family: inherit; + padding: 5px 12px; + overflow: hidden; + background: rgba(255,255,255,0.4); + color: #fff; + -webkit-transition: all 0.3s cubic-bezier(0.02, 0.01, 0.47, 1); + transition: all 0.3s cubic-bezier(0.02, 0.01, 0.47, 1); +} +.bttn-simple:hover, +.bttn-simple:focus { + opacity: 0.75; +} +.bttn-simple.bttn-xs { + padding: 3px 8px; + font-size: 12px; + font-family: inherit; +} +.bttn-simple.bttn-sm { + padding: 4px 10px; + font-size: 16px; + font-family: inherit; +} +.bttn-simple.bttn-md { + font-size: 20px; + font-family: inherit; + padding: 5px 12px; +} +.bttn-simple.bttn-lg { + padding: 8px 15px; + font-size: 24px; + font-family: inherit; +} +.bttn-simple.bttn-default { + background: rgba(255,255,255,0.4); +} +.bttn-simple.bttn-primary { + background: #550055; + background-image: linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0) 50%, rgba(255,255,255,0.25) 51%); +} +.bttn-simple.bttn-warning { + background: #feab3a; +} +.bttn-simple.bttn-danger { + background: #ff5964; +} +.bttn-simple.bttn-success { + background: #28b78d; +} +.bttn-simple.bttn-royal { + background: #bd2df5; +} +.bttn-simple.disabled { + background: #999 !important; + color: rgba(255,255,255,0.625); + cursor: default; + text-shadow: 0.375px 0.375px 0 rgba(140,140,140,0.6), -0.375px -0.375px 0.375px rgba(0,0,0,0.67); + opacity: 1; +} diff --git a/public/misc/style.css b/public/misc/style.css new file mode 100644 index 0000000..c932699 --- /dev/null +++ b/public/misc/style.css @@ -0,0 +1,235 @@ +* { + font-family: Tahoma, sans-serif; + font-size: 16px; + margin: 0; + padding: 0; +} +body { + color: #000000; + background-color: #333333; + margin: 0px; +} +#horizon { + text-align: center; + position: absolute; + top: 50%; + left: 0px; + width: 100%; + height: 1px; + overflow: visible; + visibility: visible; + display: block; +} +#content, +#error { + background: url(/images/bg_main_bottom.gif) repeat-x bottom left; + font-family: Tahoma, sans-serif; + border: 3px solid #CCCCCC; + background-color: #FFFFFF; + position: absolute; + left: 50%; + visibility: visible; + border-radius: 5px; +} + #error .main { + padding: 0 10px; + } + #error ol { + margin: 10px 0; + } + #error span { + margin: 0; + } + #error button { + text-transform: uppercase; + } +.logo { + background: url(/images/bg_header.gif) repeat-x top left; + height: 45px; + z-index: 50; + border-radius: 5px 5px 0 0; +} + .logo .left { + background: url(/images/bg_header_l.gif) no-repeat top left; + position: relative; + top: 4px; + left: 5px; + height: 49px; + float: left; + z-index: 48; + } + .logo .middle { + background: url(/images/bg_header_m.gif) no-repeat 25px 0; + margin: 0 5px; + padding: 5px 10px 0; + height: 49px; + float: left; + z-index: 49; + display: inline; + font-size: 18px; + font-weight: bold; + color: #FFFFFF; + } + .logo .right { + background: url(/images/bg_header_r.gif) no-repeat top left; + position: relative; + top: 4px; + height: 49px; + width: 5px; + float: left; + } + .logo .sub { + margin-top: 12px; + margin-left: 20px; + float: left; + display: inline; + font-size: 13px; + font-weight: bold; + color: #FFFFFF; + } + .logo .sub em { + font-size: 13px; + } +.main { + clear: both; +} + .main fieldset { + border: 0; + } + .main fieldset legend { + visibility: hidden; + } + .main fieldset label.pre { + display: inline-block; + width: 155px; + text-align: right; + vertical-align: top; + margin-top: 3px; + } + .main fieldset label#labelallaliases { + float: left; + } + .main fieldset output#aliasstats { + float: left; + clear: left; + width: 160px; + text-align: right; + font-size: 12px; + } + .main fieldset output#aliasstats:after { + margin-left: 7px; + content: ' '; + } + .main fieldset input { + border: 1px solid #550055; + padding: 2px; + width: 100px; + } + .main fieldset input[type=radio] { + border: none; + margin-top: 7px; + width: 20px; + } + .main fieldset button { + margin-left: 160px; + text-transform: uppercase; + } + .main fieldset select { + border: 1px solid #550055; + padding: 2px; + width: 375px; + } + .main fieldset select .new { + font-weight: bold; + } + .main fieldset select .deleted { + text-decoration: line-through; + } + .main fieldset#signup label.pre { + width: 205px; + } + .main fieldset#signup span.indent, .main fieldset#signup input.button { + margin-left: 210px; + } + .main li { + list-style: none; + padding: 5px; + text-align: left; + } + .main li.misc { + padding: 0 5px; + } + .main span, + .main strong, + .main a { + font-size: 12px; + } + .main span.indent { + color: #666666; + margin-left: 160px; + } + .main span.dialogdesc { + margin-left: 10px; + } + .main a:link, .main a:visited { + color: #550055; + text-decoration: none; + } + .main a:hover, .main a:active { + text-decoration: underline; + } + .main span#user { + color: #666666; + float: right; + margin: 0 5px 0 0; + } + .main span#user, + .main span#user a { + font-size: 12px; + } + .main span#user a:link, .main span#user a:visited { + color: #CC1111; + text-decoration: none; + } + .main span#user a:hover, .main span#user a:active { + text-decoration: underline; + } + .main span#user a.current { + text-decoration: none; + font-weight: 900; + cursor: default; + color: #666666; + } + .main span#user a.current:before { + content: '\00bb'; + font-weight: 100; + } + .main span#user a.current:after { + content: '\00ab'; + font-weight: 100; + } + .main span#user nav { + display: inline; + } + .main span#user #pluginlogos { + display: none; + position: absolute; + top: 72px; + right: 10px; + height: 112px; + width: 250px; + border: 1px solid rgb(181, 0, 0); + box-shadow: black 0px 0px 20px; + box-sizing: border-box; + padding-top: 5px; + background: white; + font-size: inherit; + font-weight: bold; + } + .main span#user #pluginlogos img { + width: 75px; + height: 75px; + filter: saturate(500%) contrast(200%) grayscale(100%) opacity(50%); + transition: all 375ms; + cursor: pointer; + } diff --git a/public/misc/style.theme.css b/public/misc/style.theme.css new file mode 100644 index 0000000..e446051 --- /dev/null +++ b/public/misc/style.theme.css @@ -0,0 +1,39 @@ +html.tablecloth { + height: 100%; + background: repeating-linear-gradient(-45deg, transparent, transparent 1em, rgba(136, 136, 136, 0.4) 0, rgba(136, 136, 136, 0.1) 2em, transparent 0, transparent 1em, rgba(136, 136, 136, 0.3) 0, rgba(136, 136, 136, 0.2) 4em, transparent 0, transparent 1em, rgba(68, 68, 68, 0.6) 0, rgba(68, 68, 68, 0.2) 2em), + repeating-linear-gradient(45deg, transparent, transparent 1em, rgba(136, 136, 136, 0.4) 0, rgba(136, 136, 136, 0.1) 2em, transparent 0, transparent 1em, rgba(136, 136, 136, 0.3) 0, rgba(136, 136, 136, 0.2) 4em, transparent 0, transparent 1em, rgba(68, 68, 68, 0.4) 0, rgba(68, 68, 68, 0.1) 2em), #666; + background-blend-mode: multiply; +} + +html.weave { + background: linear-gradient(45deg, #666 12%, transparent 0, transparent 88%, #666 0), + linear-gradient(135deg, transparent 37%, #888 0, #888 63%, transparent 0), + linear-gradient(45deg, transparent 37%, #666 0, #666 63%, transparent 0), + #444; + background-size: 40px 40px; +} + +html.madras { + height: 100%; + background-color: #e9d4b9; + background-image: repeating-linear-gradient(45deg, transparent 5px, rgba(11, 36, 45, 0.5) 5px, rgba(11, 36, 45, 0.5) 10px, rgba(211, 119, 111, 0) 10px, rgba(211, 119, 111, 0) 35px, rgba(211, 119, 111, 0.5) 35px, rgba(211, 119, 111, 0.5) 40px, rgba(11, 36, 45, 0.5) 40px, rgba(11, 36, 45, 0.5) 50px, rgba(11, 36, 45, 0) 50px, rgba(11, 36, 45, 0) 60px, rgba(211, 119, 111, 0.5) 60px, rgba(211, 119, 111, 0.5) 70px, rgba(247, 179, 85, 0.5) 70px, rgba(247, 179, 85, 0.5) 80px, rgba(247, 179, 85, 0) 80px, rgba(247, 179, 85, 0) 90px, rgba(211, 119, 111, 0.5) 90px, rgba(211, 119, 111, 0.5) 110px, rgba(211, 119, 111, 0) 110px, rgba(211, 119, 111, 0) 120px, rgba(11, 36, 45, 0.5) 120px, rgba(11, 36, 45, 0.5) 140px), + repeating-linear-gradient(135deg, transparent 5px, rgba(11, 36, 45, 0.5) 5px, rgba(11, 36, 45, 0.5) 10px, rgba(211, 119, 111, 0) 10px, rgba(211, 119, 111, 0) 35px, rgba(211, 119, 111, 0.5) 35px, rgba(211, 119, 111, 0.5) 40px, rgba(11, 36, 45, 0.5) 40px, rgba(11, 36, 45, 0.5) 50px, rgba(11, 36, 45, 0) 50px, rgba(11, 36, 45, 0) 60px, rgba(211, 119, 111, 0.5) 60px, rgba(211, 119, 111, 0.5) 70px, rgba(247, 179, 85, 0.5) 70px, rgba(247, 179, 85, 0.5) 80px, rgba(247, 179, 85, 0) 80px, rgba(247, 179, 85, 0) 90px, rgba(211, 119, 111, 0.5) 90px, rgba(211, 119, 111, 0.5) 110px, rgba(211, 119, 111, 0) 110px, rgba(211, 119, 111, 0) 140px, rgba(11, 36, 45, 0.5) 140px, rgba(11, 36, 45, 0.5) 160px); +} + +html.tartan { + height: 100%; + background-color: #a0302c; + background-image: repeating-linear-gradient(20deg, transparent, transparent 50px, rgba(0, 0, 0, 0.4) 50px, rgba(0, 0, 0, 0.4) 53px, transparent 53px, transparent 63px, rgba(0, 0, 0, 0.4) 63px, rgba(0, 0, 0, 0.4) 66px, transparent 66px, transparent 116px, rgba(0, 0, 0, 0.5) 116px, rgba(0, 0, 0, 0.5) 166px, rgba(255, 255, 255, 0.2) 166px, rgba(255, 255, 255, 0.2) 169px, rgba(0, 0, 0, 0.5) 169px, rgba(0, 0, 0, 0.5) 179px, rgba(255, 255, 255, 0.2) 179px, rgba(255, 255, 255, 0.2) 182px, rgba(0, 0, 0, 0.5) 182px, rgba(0, 0, 0, 0.5) 232px, transparent 232px), + repeating-linear-gradient(290deg, transparent, transparent 50px, rgba(0, 0, 0, 0.4) 50px, rgba(0, 0, 0, 0.4) 53px, transparent 53px, transparent 63px, rgba(0, 0, 0, 0.4) 63px, rgba(0, 0, 0, 0.4) 66px, transparent 66px, transparent 116px, rgba(0, 0, 0, 0.5) 116px, rgba(0, 0, 0, 0.5) 166px, rgba(255, 255, 255, 0.2) 166px, rgba(255, 255, 255, 0.2) 169px, rgba(0, 0, 0, 0.5) 169px, rgba(0, 0, 0, 0.5) 179px, rgba(255, 255, 255, 0.2) 179px, rgba(255, 255, 255, 0.2) 182px, rgba(0, 0, 0, 0.5) 182px, rgba(0, 0, 0, 0.5) 232px, transparent 232px), + repeating-linear-gradient(145deg, transparent, transparent 2px, rgba(0, 0, 0, 0.2) 2px, rgba(0, 0, 0, 0.2) 3px, transparent 3px, transparent 5px, rgba(0, 0, 0, 0.2) 5px); +} + +html.seigaiha { + background-color: grey; + background-image: radial-gradient(circle at 100% 150%, grey 24%, silver 25%, silver 28%, grey 29%, grey 36%, silver 36%, silver 40%, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0)), + radial-gradient(circle at 0 150%, grey 24%, silver 25%, silver 28%, grey 29%, grey 36%, silver 36%, silver 40%, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0)), + radial-gradient(circle at 50% 100%, silver 10%, grey 11%, grey 23%, silver 24%, silver 30%, grey 31%, grey 43%, silver 44%, silver 50%, grey 51%, grey 63%, silver 64%, silver 71%, rgba(0, 0, 0, 0) 71%, rgba(0, 0, 0, 0)), + radial-gradient(circle at 100% 50%, silver 5%, grey 6%, grey 15%, silver 16%, silver 20%, grey 21%, grey 30%, silver 31%, silver 35%, grey 36%, grey 45%, silver 46%, silver 49%, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0)), + radial-gradient(circle at 0 50%, silver 5%, grey 6%, grey 15%, silver 16%, silver 20%, grey 21%, grey 30%, silver 31%, silver 35%, grey 36%, grey 45%, silver 46%, silver 49%, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0)); + background-size: 100px 50px; +} \ No newline at end of file