getTransitions(time()); if(sizeOf($nextDayLightSavingTZTransitions) != 1){ $nextDayLightSavingTZTime = array_slice($nextDayLightSavingTZTransitions,1,1)[0]; $nextDayLightSavingTZTimeDT = new DateTime($nextDayLightSavingTZTime["time"]); $currentTimeDT = new DateTime($result["fulltime"]); $interval = $currentTimeDT->diff($nextDayLightSavingTZTimeDT); $result["nextdaylight"] = $nextDayLightSavingTZTimeDT->format('Y-m-d H:m:s'); $result["nextdaylightremains"] = $interval->format('%a'); //dst means Day Light Saving Time $result["nextdst"] = $nextDayLightSavingTZTime["isdst"]; $result["existdaylight"] = true; }else{ $result["existdaylight"] = false; } echo json_encode($result); }else if($_GET["opr"] == "alltimezone"){ echo json_encode($timezone); }else if($_GET["opr"] == "modify"){ if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'){ $tz_win = ""; foreach ($timezone as $tz) { if($tz[1] == $_GET["tz"]){ $tz_win = $tz[2]; } } //for NTP exec("w32TM /config /syncfromflags:manual /manualpeerlist:".$_GET["ntpserver"]); //for TZ exec('tzutil /s "'.$tz_win.'"'); echo "Finish"; }else{ //for NTP exec("sudo chmod -R 0777 /etc/systemd/timesyncd.conf"); $NTPFile = '# This file is part of systemd.'.PHP_EOL.'#'.PHP_EOL.'# systemd is free software; you can redistribute it and/or modify it'.PHP_EOL.'# under the terms of the GNU Lesser General Public License as published by'.PHP_EOL.'# the Free Software Foundation; either version 2.1 of the License, or'.PHP_EOL.'# (at your option) any later version.'.PHP_EOL.'#'.PHP_EOL.'# Entries in this file show the compile time defaults.'.PHP_EOL.'# You can change settings by editing this file.'.PHP_EOL.'# Defaults can be restored by simply deleting this file.'.PHP_EOL.'#'.PHP_EOL.'# See timesyncd.conf(5) for details.'.PHP_EOL.'# Generated by ArOZ Online at '.date("Y-m-d H:i:s O T").PHP_EOL.PHP_EOL.'[Time]'.PHP_EOL; $NTPFile = $NTPFile.'NTP='.$_GET["ntpserver"].PHP_EOL.'#FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org'.PHP_EOL.'#RootDistanceMaxSec=5'.PHP_EOL.'#PollIntervalMinSec=32'.PHP_EOL.'#PollIntervalMaxSec=2048'; file_put_contents("/etc/systemd/timesyncd.conf",$NTPFile); exec("sudo timedatectl set-ntp true"); //for TZ exec("sudo timedatectl set-timezone '".$_GET["tz"]."'"); //for All exec("sudo systemctl restart systemd-timesyncd"); //exec("sudo timedatectl status"); //exec("sudo timedatectl timesync-status"); //exec("sudo timedatectl show-timesync"); echo "Finish"; } } ?>