diff --git a/common.php b/common.php index 32d0a37..a1663b3 100644 --- a/common.php +++ b/common.php @@ -174,6 +174,17 @@ function main($path) $_SERVER['sitename'] = getConfig('sitename'); if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename'); + if (isset($_GET['jsFile'])) { + if (substr($_GET['jsFile'], -3)!='.js') return output('', 403); + if (!($path==''||$path=='/')) return output('', 308, [ 'Location' => path_format($_SERVER['base_path'] . '/?jsFile=' . $_GET['jsFile']) ]); + if (strpos($_GET['jsFile'], '/')>-1) $_GET['jsFile'] = splitlast($_GET['jsFile'], '/')[1]; + $jsFile = file_get_contents('js/' . $_GET['jsFile']); + if (!!$jsFile) { + return output( base64_encode($jsFile), 200, [ 'Content-Type' => 'text/javascript; charset=utf-8', 'Cache-Control' => 'max-age=' . 3*24*60*60 ], true ); + } else { + return output('', 404); + } + } if (isset($_GET['WaitFunction'])) { $response = WaitFunction($_GET['WaitFunction']); //var_dump($response); @@ -609,6 +620,14 @@ function proxy_replace_domain($url, $domainforproxy, &$header) return $aim . '/' . $uri . $sp . 'Origindomain=' . $domain; } +function bchexdec($hex) { + $len = strlen($hex); + for ($i = 1; $i <= $len; $i++) + $dec = bcadd($dec, bcmul(strval(hexdec($hex[$i - 1])), bcpow('16', strval($len - $i)))); + + return $dec; +} + function isHideFile($name) { $FunctionalityFile = [ @@ -717,6 +736,20 @@ function sortConfig(&$arr) return $arr; } +function chkTxtCode($str) { + $code = array( + 'ASCII', + 'GBK', + 'GB18030', + 'UTF-8', + 'UTF-16', + ); + foreach ($code as $c) { + if ($str === iconv('UTF-8', $c, iconv($c, 'UTF-8', $str))) return $c; + } + return false; +} + function getconstStr($str) { global $constStr; @@ -985,7 +1018,7 @@ function message($message, $title = 'Message', $statusCode = 200, $wainstat = 0) //setTimeout(function() { getStatus() }, 1000); } } else if (xhr.status==206) { - errordiv.innerHTML = "' . getconstStr('Wait') . '" + x + "
" + min; + errordiv.innerHTML = "' . getconstStr('Wait') . ' " + min + "
" + x; setTimeout(function() { getStatus() }, 1000); } else { errordiv.innerHTML = "ERROR
" + xhr.status + "
" + xhr.responseText; @@ -1146,12 +1179,28 @@ function adminform($name = '', $pass = '', $storage = '', $path = '') f.password1.value = sha1(timestamp + "" + f.password1.value); return true; } catch { - alert("sha1.js not loaded."); + //alert("sha1.js not loaded."); + if (confirm("sha1.js not loaded.\n\nLoad from program?")) loadjs("?jsFile=sha1.min.js"); return false; } } + function loadjs(url) { + var xhr = new XMLHttpRequest; + xhr.open("GET", url); + xhr.onload = function(e) { + if (xhr.status==200) { + var script = document.createElement("script"); + script.type = "text/javascript"; + script.text = xhr.responseText; + document.body.appendChild(script); + } else { + console.log(xhr.response); + } + } + xhr.send(null); + } -'; +'; $html .= ''; return output($html, $statusCode); } @@ -1675,7 +1724,7 @@ output: } else { if (count($disktags)>1) { $frame .= ' - +