mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-27 05:50:51 -05:00
(Update) HTML Encrypt 🚀
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Bepsvpt\SecureHeaders\SecureHeaders;
|
||||
|
||||
class HtmlEncrypt
|
||||
{
|
||||
@@ -55,20 +56,22 @@ class HtmlEncrypt
|
||||
|
||||
public function encryptHtml($content)
|
||||
{
|
||||
$nonce = SecureHeaders::nonce();
|
||||
|
||||
$text = str_split(bin2hex($content), 2);
|
||||
|
||||
array_walk($text, function (&$a) {
|
||||
$this->addHexValue('%'.$a);
|
||||
});
|
||||
|
||||
$script = '<script type="text/javascript">document.writeln(unescape("'.$this->hex.'"));</script>';
|
||||
$script = "<script type='text/javascript' nonce='{$nonce}'>document.writeln(unescape('{$this->hex}'));</script>";
|
||||
|
||||
if (config('html-encrypt.disable_right_click')) {
|
||||
$script .= '<script>var body = document.getElementsByTagName("body")[0];var att = document.createAttribute("oncontextmenu");att.value = "return false";body.setAttributeNode(att);</script>';
|
||||
$script .= "<script type='text/javascript' nonce='{$nonce}'>let body = document.getElementsByTagName('body')[0];var att = document.createAttribute('oncontextmenu');att.value = 'return false'';body.setAttributeNode(att);</script>";
|
||||
}
|
||||
|
||||
if (config('html-encrypt.disable_ctrl_and_F12_key')) {
|
||||
$script .= '<script>document.onkeydown=function(e){if(e.ctrlKey || e.keyCode == 123){return false}}</script>';
|
||||
$script .= "<script type='text/javascript' nonce='{$nonce}'>document.onkeydown=function(e){if(e.ctrlKey || e.keyCode == 123){return false}}</script>";
|
||||
}
|
||||
|
||||
return $script;
|
||||
|
||||
Reference in New Issue
Block a user