-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathsplash.php
61 lines (56 loc) · 2.02 KB
/
splash.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* This file is a part of MyWebSQL package
*
* @file: modules/splash.php
* @author Samnan ur Rehman
* @copyright (c) 2008-2014 Samnan ur Rehman
* @web http://mywebsql.net
* @license http://mywebsql.net/license
*/
function getSplashScreen($msg = '', $formCode='') {
if ($formCode) {
$formCode = '<div class="login"><form method="post" action="" name="dbform" id="dbform" style="text-align:center">'
. $formCode . '</form></div>';
}
$scripts = "jquery";
$extraScript = "";
if (secureLoginPage()) {
$scripts = "jquery,encrypt";
$e = Session::get('auth_enc', 'e');
$d = Session::get('auth_enc', 'd');
$n = Session::get('auth_enc', 'n');
$keyLength = 128;
if(!$e || !$d || !$n) {
$enc_lib = BASE_PATH . ((extension_loaded('openssl') && extension_loaded('gmp'))
? "/lib/external/jcryption.php"
: "/lib/external/jcryption-legacy.php");
require_once( $enc_lib );
$jCryption = new jCryption();
$keys = $jCryption->generateKeypair($keyLength);
$e = array("int" => $keys["e"], "hex" => $jCryption->dec2string($keys["e"],16));
$d = array("int" => $keys["d"], "hex" => $jCryption->dec2string($keys["d"],16));
$n = array("int" => $keys["n"], "hex" => $jCryption->dec2string($keys["n"],16));
Session::set('auth_enc', 'e', $e);
Session::set('auth_enc', 'd', $d);
Session::set('auth_enc', 'n', $n );
}
$keyData = '{"e":"'.$e["hex"].'","n":"'.$n["hex"].'","maxdigits":"'.intval($keyLength*2/16+3).'"}';
$extraScript = '<script language="javascript" type="text/javascript">
$(function() {
$.jCryption.defaultOptions.getKeysURL = '.$keyData.';
$("#dbform").jCryption();
});
</script>';
}
$replace = array(
'MESSAGE' => $msg ? '<div class="msg">'.htmlspecialchars($msg).'</div>' : '',
'FORM' => $formCode,
'APP_VERSION' => APP_VERSION,
'PROJECT_SITEURL' => PROJECT_SITEURL,
'SCRIPTS' => $scripts,
'EXTRA_SCRIPT' => $extraScript
);
return view('splash', $replace);
}
?>