diff --git a/common.php b/common.php index 32d0a37..177c5aa 100644 --- a/common.php +++ b/common.php @@ -174,6 +174,16 @@ 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']) ]); + $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); @@ -1146,10 +1156,26 @@ 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 .= ''; @@ -1950,7 +1976,7 @@ output: try { sha1(1); } catch { - alert("sha1.js not loaded."); + if (confirm("sha1.js not loaded.\n\nLoad from program?")) loadjs("?jsFile=sha1.min.js"); return false; } var timestamp = new Date().getTime(); @@ -1993,7 +2019,7 @@ output: try { sha1(1); } catch { - alert("sha1.js not loaded."); + if (confirm("sha1.js not loaded.\n\nLoad from program?")) loadjs("?jsFile=sha1.min.js"); return false; } var timestamp = new Date().getTime(); @@ -2030,7 +2056,7 @@ output: try { sha1(1); } catch { - alert("sha1.js not loaded."); + if (confirm("sha1.js not loaded.\n\nLoad from program?")) loadjs("?jsFile=sha1.min.js"); return false; } var timestamp = new Date().getTime(); @@ -2038,6 +2064,21 @@ output: f.oldPass.value = sha1(f.oldPass.value + "" + timestamp); return true; } + 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 .= ' @@ -2406,12 +2447,21 @@ function render_list($path = '', $files = []) } } if ($_SERVER['is_guestup_path']||( $_SERVER['admin']&&$files['type']=='folder'&&$_SERVER['ishidden']<4 )) { - while (strpos($html, '')) $html = str_replace('', '', $html); - while (strpos($html, '')) $html = str_replace('', '', $html); $now_driver = baseclassofdrive(); - unset($Driver_arr[$now_driver]); - while (strpos($html, '')) $html = str_replace('', '', $html); - while (strpos($html, '')) $html = str_replace('', '', $html); + if ($now_driver) { + while (strpos($html, '')) $html = str_replace('', '', $html); + while (strpos($html, '')) $html = str_replace('', '', $html); + unset($Driver_arr[$now_driver]); + while (strpos($html, '')) $html = str_replace('', '', $html); + while (strpos($html, '')) $html = str_replace('', '', $html); + } else { + while (strpos($html, '')) { + $tmp = splitfirst($html, ''); + $html = $tmp[0]; + $tmp = splitfirst($tmp[1], ''); + $html .= $tmp[1]; + } + } foreach ($Driver_arr as $driver) { while (strpos($html, '')) { $tmp = splitfirst($html, ''); @@ -2840,7 +2890,7 @@ function render_list($path = '', $files = []) $imgextstr = ''; foreach ($exts['img'] as $imgext) $imgextstr .= '\''.$imgext.'\', '; $html = str_replace('', $imgextstr, $html); - + $html = str_replace('', $_SERVER['sitename'], $html); @@ -2870,7 +2920,7 @@ function render_list($path = '', $files = []) if ($diskname=='') $diskname = $_SERVER['disktag']; //if (strlen($diskname)>15) $diskname = substr($diskname, 0, 12).'...'; while (strpos($html, '')) $html = str_replace('', $diskname, $html); - + $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2887,7 +2937,7 @@ function render_list($path = '', $files = []) $headomf = str_replace('', $headomfcontent, $tmp[0]); } $html .= $headomf . $tmp[1]; - + $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2989,7 +3039,6 @@ function render_list($path = '', $files = []) } $html .= $Footomf . $tmp[1]; - $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], '');