<?php require 'authentication_manager.php'; ?>
<?php


if (!empty($_GET['now_version'])) {
  $err = '';
/*
  if (!$_SERVER['HTTP_REFERER']) {
    $err='!$_SERVER[&quot;HTTP_REFERER&quot;]';
  }
  if ($web['root'] != get_root_domain($_SERVER['HTTP_REFERER'])) {
    $err='$_SERVER[&quot;HTTP_REFERER&quot;] != $web[&quot;root&quot;]';
  }
  //if (!$r = preg_replace('/\/(index\.html.*)?$/i', '', $_SERVER['HTTP_REFERER'])) {
  //  $err='empty($_SERVER[&quot;HTTP_REFERER&quot;])';
  //}
  //if ($r.'/' != $web['path']) {
  //  $err='$_SERVER[&quot;HTTP_REFERER&quot;] != $web[&quot;path&quot;]';
  //}
*/
  if (!file_exists('index.html')) {
    $err='!file_exists(&quot;index.html&quot;)';
  }
  if (!$f = file_get_contents('index.html')) {
    $err='!file_get_contents(&quot;index.html&quot;)';
  }
  if (!$f2 = file_get_contents('writable/require/browse_reload.txt')) {
    $err='!file_get_contents(&quot;writable/require/browse_reload.txt&quot;)';
  }
  if (!preg_match('/\<script.+var[\n\r\s]+nowVersion[\n\r\s]*\=[\n\r\s]*[\"\'](\d+)[\"\'].+\/script\>/isU', $f, $m)) {
    $err='!nowVersion';
  }
  if ($f2 == $m[1]) {
    $err='nowVersion无误';
  }

  $text_index = preg_replace('/\<script.+var[\n\r\s]+nowVersion[\n\r\s]*\=[\n\r\s]*[\"\']\d+[\"\'].+\/script\>/isU', '<script type="text/javascript" language="javascript">
<!--
var nowVersion=\''.$f2.'\';
-->
</script>', $f);
  @ require 'readonly/function/write_file.php';
  write_file('index.html', $text_index);  

  err('
<script>
if(parent && parent.$("addCFrame")!=null){
  parent.location.reload(true);
}
</script>'.$err, 'ok');




} else {

if (POWER != 5) {
  err('该命令必须以基本管理员身份登陆！请重登陆');
}

@ setcookie('weathercity', '', -(time() + 365 * 24 * 60 * 60), '/'); //+8*3600
echo '<script> setCookie(\'weathercity\',\'\',-366); </script>';
$id = gmdate('YmdHis', time() + (floatval($web['time_pos']) * 3600));
@ require 'readonly/function/write_file.php';
write_file('writable/require/browse_reload.txt', $id);

reset_indexhtml('index.php', 'index.html');
err('清除缓存命令已发出！'.$need_updated, 'ok');

}

?>