update old programe

This commit is contained in:
Bigsk 2021-01-01 15:48:55 +08:00
parent 9b8ca51b29
commit bb608d1000
17 changed files with 1084 additions and 20 deletions

View File

@ -5,9 +5,9 @@ from Astronomy import *
#Define Area #Define Area
class APICore(object): class APICore(object):
HTTPHead={ HTTPHead={
'200':'HTTP/1.1 200 OK\r\nServer: SparkE/Alpha1.0\r\nContent-Type: application/json; charset=utf-8\r\n\r\n', '200':'HTTP/1.1 200 OK\r\nServer: SparkE/Alpha1.0\r\nContent-Type: application/json; charset=utf-8\r\nConnection: keep-alive\r\n\r\n',
'400':'HTTP/1.1 400 BAD REQUEST\r\nServer: SparkE/Alpha1.0\r\nContent-Type: application/json; charset=utf-8\r\n\r\n', '400':'HTTP/1.1 400 BAD REQUEST\r\nServer: SparkE/Alpha1.0\r\nContent-Type: application/json; charset=utf-8\r\nConnection: keep-alive\r\n\r\n',
'404':'HTTP/1.1 404 NOT FOUND\r\nServer: SparkE/Alpha1.0\r\nContent-Type: application/json; charset=utf-8\r\n\r\n' '404':'HTTP/1.1 404 NOT FOUND\r\nServer: SparkE/Alpha1.0\r\nContent-Type: application/json; charset=utf-8\r\nConnection: keep-alive\r\n\r\n'
} }
def __init__(self): def __init__(self):
self.__Log=[] self.__Log=[]
@ -108,6 +108,7 @@ def socket(sock,addr):
#No Parameter #No Parameter
sock.send(API.HTTPHead['200'].encode("utf-8")) sock.send(API.HTTPHead['200'].encode("utf-8"))
API.SunAzEl(sock,addr) API.SunAzEl(sock,addr)
break
elif("POST " in data.decode("utf-8")): elif("POST " in data.decode("utf-8")):
#POST Request #POST Request
try: try:
@ -183,21 +184,6 @@ def socket(sock,addr):
API.Log(addr[0],addr[1],"STATUS","Wrong code mode,must be utf-8.") API.Log(addr[0],addr[1],"STATUS","Wrong code mode,must be utf-8.")
API.Log(addr[0],addr[1],"STATUS","Lost connection.") API.Log(addr[0],addr[1],"STATUS","Lost connection.")
break break
def _async_raise(tid, exctype):
"""raises the exception, performs cleanup if needed"""
tid = ctypes.c_long(tid)
if not inspect.isclass(exctype):
exctype = type(exctype)
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
if res == 0:
raise ValueError("invalid thread id")
elif res != 1:
# """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed")
def stop_thread(thread):
_async_raise(thread.ident, SystemExit)
def main(): def main():
LogOutput=API.AutoLogOutput LogOutput=API.AutoLogOutput
log_thread=threading.Thread(target=LogOutput,args=()) log_thread=threading.Thread(target=LogOutput,args=())

View File

@ -0,0 +1,13 @@
<?php
$command="python api_core.py";
if($_GET['stamp']!=""){
$command=$command." --stamp ".strval($_GET['stamp'])." ";
}
if($_GET['lon']!=""){
$command=$command." --lon ".$_GET['lon']." ";
}
if($_GET['zone']!=""){
$command=$command." --zone ".$_GET['zone']." ";
}
@os.system($command);
?>

View File

@ -0,0 +1,168 @@
import os,time,math,argparse,json
#-------------------------------------#
class Calendar(object):
def calcSunDeclination(self,Stamp=None,TimeZone=8):
MonthList = [
{"name": 'January', "numdays": 31},
{"name": 'February', "numdays": 28},
{"name": 'March', "numdays": 31},
{"name": 'April', "numdays": 30},
{"name": 'May', "numdays": 31},
{"name": 'June', "numdays": 30},
{"name": 'July', "numdays": 31},
{"name": 'August', "numdays": 31},
{"name": 'September', "numdays": 30},
{"name": 'October', "numdays": 31},
{"name": 'November', "numdays": 30},
{"name": 'December', "numdays": 31},
]
if(Stamp==None):
TimeStamp = time.time()
else:
TimeStamp = Stamp
Year=int(time.strftime("%Y",time.localtime(TimeStamp)))
Month=int(time.strftime("%m",time.localtime(TimeStamp)))
Day=int(time.strftime("%d",time.localtime(TimeStamp)))
Hour=int(time.strftime("%H",time.localtime(TimeStamp)))
Minute=int(time.strftime("%M",time.localtime(TimeStamp)))
Second=int(time.strftime("%S",time.localtime(TimeStamp)))
if(((Year % 4 == 0 and Year % 100 != 0) or Year % 400 == 0) and (Month == 2)):
if(Day > 29):
Day=29
else:
if(Day > MonthList[Month-1]['numdays']):
Day = MonthList[Month-1]['numdays']
if(Month <= 2):
Year -= 1
Month += 12
L0 = 280.46646 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (36000.76983 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (0.0003032))
while(L0 > 360.0):
L0 -= 360.0
while(L0 < 0.0):
L0 += 360.0
return (math.degrees(math.asin(math.sin(math.radians(23 + (26 + ((21.448 - ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (46.8150 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (0.00059 - ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (0.001813)))) / 60.0)) / 60.0 + 0.00256 * math.cos(math.radians(1254 - 1934.136 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525))))) * math.sin(math.radians(L0 + math.sin(math.radians(357.52911 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (359995029 - 0.0001537 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525)))) * (1.914602 - ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (0.004817 + 0.000014 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525))) + math.sin(math.radians(357.52911 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (359995029 - 0.0001537 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525))) * 2) * (0.019993 - 0.000101 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525)) + math.sin(math.radians(357.52911 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (359995029 - 0.0001537 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525))) * 3) * 0.000289 - 0.00569 - 0.00478 * math.sin(math.radians(1254 - 1934.136 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525))))))) * 100 + 0.5) / 100.0
def calcHourAngle(self,Stamp=None,Lon=120,TimeZone=8):
MonthList = [
{"name": 'January', "numdays": 31},
{"name": 'February', "numdays": 28},
{"name": 'March', "numdays": 31},
{"name": 'April', "numdays": 30},
{"name": 'May', "numdays": 31},
{"name": 'June', "numdays": 30},
{"name": 'July', "numdays": 31},
{"name": 'August', "numdays": 31},
{"name": 'September', "numdays": 30},
{"name": 'October', "numdays": 31},
{"name": 'November', "numdays": 30},
{"name": 'December', "numdays": 31},
]
if(Stamp==None):
TimeStamp = time.time()
else:
TimeStamp = Stamp
Year=int(time.strftime("%Y",time.localtime(TimeStamp)))
Month=int(time.strftime("%m",time.localtime(TimeStamp)))
Day=int(time.strftime("%d",time.localtime(TimeStamp)))
Hour=int(time.strftime("%H",time.localtime(TimeStamp)))
Minute=int(time.strftime("%M",time.localtime(TimeStamp)))
Second=int(time.strftime("%S",time.localtime(TimeStamp)))
if(((Year % 4 == 0 and Year % 100 != 0) or Year % 400 == 0) and (Month == 2)):
if(Day > 29):
Day=29
else:
if(Day > MonthList[Month-1]['numdays']):
Day = MonthList[Month-1]['numdays']
if(Month <= 2):
Year -= 1
Month += 12
TimeJulianCent = (math.floor(365.25*(Year + 4716)) + math.floor(30.6001*(Month+1)) + Day + 2 - math.floor(Year/100) + math.floor(math.floor(Year/100)/4) - 1524.5 + Hour * 60 + Minute + Second/60.0/1440.0 - TimeZone/24 - 2451545)/36525
L0 = 280.46646 + TimeJulianCent * (36000.76983 + TimeJulianCent *(0.0003032))
while(L0 > 360.0):
L0 -= 360.0
while(L0 < 0.0):
L0 += 360.0
TrueSolarTime = (Hour * 60 + Minute + Second / 60) + ((4 * math.degrees((math.tan(math.radians((23 + (26 + ((21.448 - TimeJulianCent * (46.8150 + TimeJulianCent * (0.00059 - TimeJulianCent * (0.001813)))) / 60.0)) / 60.0 + 0.00256 * math.cos(math.radians(1254 - 1934.136 * TimeJulianCent))))/2) ** 2) * math.sin(2 * math.radians(L0)) - 2 * (0.016708634 - TimeJulianCent * (0.000042037 + 0.0000001267 * TimeJulianCent)) * math.sin(math.radians(357.52911 + TimeJulianCent * (359995029 - 0.0001537 * TimeJulianCent))) + 4 * (0.016708634 - TimeJulianCent * (0.000042037 + 0.0000001267 * TimeJulianCent)) * (math.tan(math.radians((23 + (26 + ((21.448 - TimeJulianCent * (46.8150 + TimeJulianCent * (0.00059 - TimeJulianCent * (0.001813)))) / 60.0)) / 60.0 + 0.00256 * math.cos(math.radians(1254 - 1934.136 * TimeJulianCent)))) / 2) ** 2) * math.sin(math.radians(357.52911 + TimeJulianCent * (359995029 - 0.0001537 * TimeJulianCent))) * math.cos(2 * math.radians(L0)) - 0.5 * (math.tan(math.radians((23 + (26 + ((21.448 - TimeJulianCent * (46.8150 + TimeJulianCent * (0.00059 - TimeJulianCent * (0.001813)))) / 60.0)) / 60.0 + 0.00256 * math.cos(math.radians(1254 - 1934.136 * TimeJulianCent))))/2) ** 2) * (math.tan(math.radians((23 + (26 + ((21.448 - TimeJulianCent * (46.8150 + TimeJulianCent * (0.00059 - TimeJulianCent * (0.001813)))) / 60.0)) / 60.0 + 0.00256 * math.cos(math.radians(1254 - 1934.136 * TimeJulianCent))))/2) ** 2) * math.sin(4 * math.radians(L0)) - 1.25 * ((0.016708634 - TimeJulianCent * (0.000042037 + 0.0000001267 * TimeJulianCent)) ** 2) * math.sin(2 * math.radians(math.radians(357.52911 + TimeJulianCent * (359995029 - 0.0001537 * TimeJulianCent)))))) + 4 * Lon - 60.0 * TimeZone)
while (TrueSolarTime > 1440):
TrueSolarTime -= 1440
HourAngle = TrueSolarTime / 4 - 180.0
if (HourAngle < -180):
HourAngle += 360.0
return HourAngle
def calcSunAzEl(self,Stamp=None,Lon=120,Lat=30,TimeZone=8,ZeroAzimuth="North"):
MonthList = [
{"name": 'January', "numdays": 31},
{"name": 'February', "numdays": 28},
{"name": 'March', "numdays": 31},
{"name": 'April', "numdays": 30},
{"name": 'May', "numdays": 31},
{"name": 'June', "numdays": 30},
{"name": 'July', "numdays": 31},
{"name": 'August', "numdays": 31},
{"name": 'September', "numdays": 30},
{"name": 'October', "numdays": 31},
{"name": 'November', "numdays": 30},
{"name": 'December', "numdays": 31},
]
if(Stamp==None):
TimeStamp = time.time()
else:
TimeStamp = Stamp
Year=int(time.strftime("%Y",time.localtime(TimeStamp)))
Month=int(time.strftime("%m",time.localtime(TimeStamp)))
Day=int(time.strftime("%d",time.localtime(TimeStamp)))
Hour=int(time.strftime("%H",time.localtime(TimeStamp)))
Minute=int(time.strftime("%M",time.localtime(TimeStamp)))
Second=int(time.strftime("%S",time.localtime(TimeStamp)))
if(((Year % 4 == 0 and Year % 100 != 0) or Year % 400 == 0) and (Month == 2)):
if(Day > 29):
Day=29
else:
if(Day > MonthList[Month-1]['numdays']):
Day = MonthList[Month-1]['numdays']
if(Month <= 2):
Year -= 1
Month += 12
ZeroAzimuth=180 if(ZeroAzimuth=="South") else 0
csz = math.sin(math.radians(Lat)) * math.sin(math.radians(self.calcSunDeclination(Stamp,TimeZone))) + math.cos(math.radians(Lat)) * math.cos(math.radians(self.calcSunDeclination(Stamp,TimeZone))) * math.cos(math.radians(self.calcHourAngle(Stamp,Lon,TimeZone)))
if(csz > 1):
csz = 1
elif(csz < -1):
csz = -1
if(abs((math.cos(math.radians(Lat)) * math.sin(math.radians(math.degrees(math.acos(csz)))))) > 0.001):
azRad = ((math.sin(math.radians(Lat)) * math.cos(math.radians(math.degrees(math.acos(csz))))) - math.sin(math.radians(self.calcSunDeclination(Stamp,TimeZone)))) / (math.cos(math.radians(Lat)) * math.sin(math.radians(math.degrees(math.acos(csz)))))
if(abs(azRad) > 1.0):
if(azRad < 0):
azRad = -1.0
else:
azRad = 1.0
azimuth = 180.0 - math.degrees(math.acos(azRad))
if(self.calcHourAngle(Stamp,Lon,TimeZone) > 0.0):
azimuth = -azimuth
else:
if(Lat > 0.0):
azimuth = 180.0
else:
azimuth = 0.0
if(azimuth < 0.0):
azimuth += 360.0
exoatmElevation = (90.0 - math.degrees(math.acos(csz)))
if (exoatmElevation > 85.0):
refractionCorrection = 0.0
else:
te = math.tan (math.radians(exoatmElevation))
if (exoatmElevation > 5.0):
refractionCorrection = 58.1 / te - 0.07 / (te*te*te) + 0.000086 / (te*te*te*te*te)
elif (exoatmElevation > -0.575):
refractionCorrection = 1735.0 + exoatmElevation * (-518.2 + exoatmElevation * (103.4 + exoatmElevation * (-12.79 + exoatmElevation * 0.711) ) )
else:
refractionCorrection = -20.774 / te
refractionCorrection = refractionCorrection / 3600.0
solarZen = math.degrees(math.acos(csz)) - refractionCorrection
return {"az":((azimuth*100 +0.5) - (ZeroAzimuth*100))/100.0,"el":((90.0-solarZen)*100+0.5)/100.0}
c=Calendar()
parser=argparse.ArgumentParser()
parser.add_argument("--stamp",default=time.time())
parser.add_argument("--lon",default=120)
parser.add_argument("--zone",default=8)
parser=parser.parse_args()
print(json.dumps(c.calcHourAngle(int(parser.stamp),int(parser.lon),int(parser.zone))))

View File

@ -0,0 +1,19 @@
<?php
$command="python api_core.py";
if($_GET['stamp']!=""){
$command=$command." --stamp ".strval($_GET['stamp'])." ";
}
if($_GET['lon']!=""){
$command=$command." --lon ".$_GET['lon']." ";
}
if($_GET['lat']!=""){
$command=$command." --lat ".$_GET['lat']." ";
}
if($_GET['zone']!=""){
$command=$command." --zone ".$_GET['zone']." ";
}
if($_GET['zero']!=""){
$command=$command." --zero ".$_GET['zero']." ";
}
@os.system($command);
?>

View File

@ -0,0 +1,170 @@
import os,time,math,argparse,json
#-------------------------------------#
class Calendar(object):
def calcSunDeclination(self,Stamp=None,TimeZone=8):
MonthList = [
{"name": 'January', "numdays": 31},
{"name": 'February', "numdays": 28},
{"name": 'March', "numdays": 31},
{"name": 'April', "numdays": 30},
{"name": 'May', "numdays": 31},
{"name": 'June', "numdays": 30},
{"name": 'July', "numdays": 31},
{"name": 'August', "numdays": 31},
{"name": 'September', "numdays": 30},
{"name": 'October', "numdays": 31},
{"name": 'November', "numdays": 30},
{"name": 'December', "numdays": 31},
]
if(Stamp==None):
TimeStamp = time.time()
else:
TimeStamp = Stamp
Year=int(time.strftime("%Y",time.localtime(TimeStamp)))
Month=int(time.strftime("%m",time.localtime(TimeStamp)))
Day=int(time.strftime("%d",time.localtime(TimeStamp)))
Hour=int(time.strftime("%H",time.localtime(TimeStamp)))
Minute=int(time.strftime("%M",time.localtime(TimeStamp)))
Second=int(time.strftime("%S",time.localtime(TimeStamp)))
if(((Year % 4 == 0 and Year % 100 != 0) or Year % 400 == 0) and (Month == 2)):
if(Day > 29):
Day=29
else:
if(Day > MonthList[Month-1]['numdays']):
Day = MonthList[Month-1]['numdays']
if(Month <= 2):
Year -= 1
Month += 12
L0 = 280.46646 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (36000.76983 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (0.0003032))
while(L0 > 360.0):
L0 -= 360.0
while(L0 < 0.0):
L0 += 360.0
return (math.degrees(math.asin(math.sin(math.radians(23 + (26 + ((21.448 - ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (46.8150 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (0.00059 - ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (0.001813)))) / 60.0)) / 60.0 + 0.00256 * math.cos(math.radians(1254 - 1934.136 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525))))) * math.sin(math.radians(L0 + math.sin(math.radians(357.52911 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (359995029 - 0.0001537 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525)))) * (1.914602 - ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (0.004817 + 0.000014 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525))) + math.sin(math.radians(357.52911 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (359995029 - 0.0001537 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525))) * 2) * (0.019993 - 0.000101 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525)) + math.sin(math.radians(357.52911 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (359995029 - 0.0001537 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525))) * 3) * 0.000289 - 0.00569 - 0.00478 * math.sin(math.radians(1254 - 1934.136 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525))))))) * 100 + 0.5) / 100.0
def calcHourAngle(self,Stamp=None,Lon=120,TimeZone=8):
MonthList = [
{"name": 'January', "numdays": 31},
{"name": 'February', "numdays": 28},
{"name": 'March', "numdays": 31},
{"name": 'April', "numdays": 30},
{"name": 'May', "numdays": 31},
{"name": 'June', "numdays": 30},
{"name": 'July', "numdays": 31},
{"name": 'August', "numdays": 31},
{"name": 'September', "numdays": 30},
{"name": 'October', "numdays": 31},
{"name": 'November', "numdays": 30},
{"name": 'December', "numdays": 31},
]
if(Stamp==None):
TimeStamp = time.time()
else:
TimeStamp = Stamp
Year=int(time.strftime("%Y",time.localtime(TimeStamp)))
Month=int(time.strftime("%m",time.localtime(TimeStamp)))
Day=int(time.strftime("%d",time.localtime(TimeStamp)))
Hour=int(time.strftime("%H",time.localtime(TimeStamp)))
Minute=int(time.strftime("%M",time.localtime(TimeStamp)))
Second=int(time.strftime("%S",time.localtime(TimeStamp)))
if(((Year % 4 == 0 and Year % 100 != 0) or Year % 400 == 0) and (Month == 2)):
if(Day > 29):
Day=29
else:
if(Day > MonthList[Month-1]['numdays']):
Day = MonthList[Month-1]['numdays']
if(Month <= 2):
Year -= 1
Month += 12
TimeJulianCent = (math.floor(365.25*(Year + 4716)) + math.floor(30.6001*(Month+1)) + Day + 2 - math.floor(Year/100) + math.floor(math.floor(Year/100)/4) - 1524.5 + Hour * 60 + Minute + Second/60.0/1440.0 - TimeZone/24 - 2451545)/36525
L0 = 280.46646 + TimeJulianCent * (36000.76983 + TimeJulianCent *(0.0003032))
while(L0 > 360.0):
L0 -= 360.0
while(L0 < 0.0):
L0 += 360.0
TrueSolarTime = (Hour * 60 + Minute + Second / 60) + ((4 * math.degrees((math.tan(math.radians((23 + (26 + ((21.448 - TimeJulianCent * (46.8150 + TimeJulianCent * (0.00059 - TimeJulianCent * (0.001813)))) / 60.0)) / 60.0 + 0.00256 * math.cos(math.radians(1254 - 1934.136 * TimeJulianCent))))/2) ** 2) * math.sin(2 * math.radians(L0)) - 2 * (0.016708634 - TimeJulianCent * (0.000042037 + 0.0000001267 * TimeJulianCent)) * math.sin(math.radians(357.52911 + TimeJulianCent * (359995029 - 0.0001537 * TimeJulianCent))) + 4 * (0.016708634 - TimeJulianCent * (0.000042037 + 0.0000001267 * TimeJulianCent)) * (math.tan(math.radians((23 + (26 + ((21.448 - TimeJulianCent * (46.8150 + TimeJulianCent * (0.00059 - TimeJulianCent * (0.001813)))) / 60.0)) / 60.0 + 0.00256 * math.cos(math.radians(1254 - 1934.136 * TimeJulianCent)))) / 2) ** 2) * math.sin(math.radians(357.52911 + TimeJulianCent * (359995029 - 0.0001537 * TimeJulianCent))) * math.cos(2 * math.radians(L0)) - 0.5 * (math.tan(math.radians((23 + (26 + ((21.448 - TimeJulianCent * (46.8150 + TimeJulianCent * (0.00059 - TimeJulianCent * (0.001813)))) / 60.0)) / 60.0 + 0.00256 * math.cos(math.radians(1254 - 1934.136 * TimeJulianCent))))/2) ** 2) * (math.tan(math.radians((23 + (26 + ((21.448 - TimeJulianCent * (46.8150 + TimeJulianCent * (0.00059 - TimeJulianCent * (0.001813)))) / 60.0)) / 60.0 + 0.00256 * math.cos(math.radians(1254 - 1934.136 * TimeJulianCent))))/2) ** 2) * math.sin(4 * math.radians(L0)) - 1.25 * ((0.016708634 - TimeJulianCent * (0.000042037 + 0.0000001267 * TimeJulianCent)) ** 2) * math.sin(2 * math.radians(math.radians(357.52911 + TimeJulianCent * (359995029 - 0.0001537 * TimeJulianCent)))))) + 4 * Lon - 60.0 * TimeZone)
while (TrueSolarTime > 1440):
TrueSolarTime -= 1440
HourAngle = TrueSolarTime / 4 - 180.0
if (HourAngle < -180):
HourAngle += 360.0
return HourAngle
def calcSunAzEl(self,Stamp=None,Lon=120,Lat=30,TimeZone=8,ZeroAzimuth="North"):
MonthList = [
{"name": 'January', "numdays": 31},
{"name": 'February', "numdays": 28},
{"name": 'March', "numdays": 31},
{"name": 'April', "numdays": 30},
{"name": 'May', "numdays": 31},
{"name": 'June', "numdays": 30},
{"name": 'July', "numdays": 31},
{"name": 'August', "numdays": 31},
{"name": 'September', "numdays": 30},
{"name": 'October', "numdays": 31},
{"name": 'November', "numdays": 30},
{"name": 'December', "numdays": 31},
]
if(Stamp==None):
TimeStamp = time.time()
else:
TimeStamp = Stamp
Year=int(time.strftime("%Y",time.localtime(TimeStamp)))
Month=int(time.strftime("%m",time.localtime(TimeStamp)))
Day=int(time.strftime("%d",time.localtime(TimeStamp)))
Hour=int(time.strftime("%H",time.localtime(TimeStamp)))
Minute=int(time.strftime("%M",time.localtime(TimeStamp)))
Second=int(time.strftime("%S",time.localtime(TimeStamp)))
if(((Year % 4 == 0 and Year % 100 != 0) or Year % 400 == 0) and (Month == 2)):
if(Day > 29):
Day=29
else:
if(Day > MonthList[Month-1]['numdays']):
Day = MonthList[Month-1]['numdays']
if(Month <= 2):
Year -= 1
Month += 12
ZeroAzimuth=180 if(ZeroAzimuth=="South") else 0
csz = math.sin(math.radians(Lat)) * math.sin(math.radians(self.calcSunDeclination(Stamp,TimeZone))) + math.cos(math.radians(Lat)) * math.cos(math.radians(self.calcSunDeclination(Stamp,TimeZone))) * math.cos(math.radians(self.calcHourAngle(Stamp,Lon,TimeZone)))
if(csz > 1):
csz = 1
elif(csz < -1):
csz = -1
if(abs((math.cos(math.radians(Lat)) * math.sin(math.radians(math.degrees(math.acos(csz)))))) > 0.001):
azRad = ((math.sin(math.radians(Lat)) * math.cos(math.radians(math.degrees(math.acos(csz))))) - math.sin(math.radians(self.calcSunDeclination(Stamp,TimeZone)))) / (math.cos(math.radians(Lat)) * math.sin(math.radians(math.degrees(math.acos(csz)))))
if(abs(azRad) > 1.0):
if(azRad < 0):
azRad = -1.0
else:
azRad = 1.0
azimuth = 180.0 - math.degrees(math.acos(azRad))
if(self.calcHourAngle(Stamp,Lon,TimeZone) > 0.0):
azimuth = -azimuth
else:
if(Lat > 0.0):
azimuth = 180.0
else:
azimuth = 0.0
if(azimuth < 0.0):
azimuth += 360.0
exoatmElevation = (90.0 - math.degrees(math.acos(csz)))
if (exoatmElevation > 85.0):
refractionCorrection = 0.0
else:
te = math.tan (math.radians(exoatmElevation))
if (exoatmElevation > 5.0):
refractionCorrection = 58.1 / te - 0.07 / (te*te*te) + 0.000086 / (te*te*te*te*te)
elif (exoatmElevation > -0.575):
refractionCorrection = 1735.0 + exoatmElevation * (-518.2 + exoatmElevation * (103.4 + exoatmElevation * (-12.79 + exoatmElevation * 0.711) ) )
else:
refractionCorrection = -20.774 / te
refractionCorrection = refractionCorrection / 3600.0
solarZen = math.degrees(math.acos(csz)) - refractionCorrection
return {"az":((azimuth*100 +0.5) - (ZeroAzimuth*100))/100.0,"el":((90.0-solarZen)*100+0.5)/100.0}
c=Calendar()
parser=argparse.ArgumentParser()
parser.add_argument("--stamp",default=time.time())
parser.add_argument("--lon",default=120)
parser.add_argument("--lat",default=30)
parser.add_argument("--zone",default=8)
parser.add_argument("--zero",default="North")
parser=parser.parse_args()
print(json.dumps(c.calcSunAzEl(int(parser.stamp),int(parser.lon),int(parser.lat),int(parser.zone),parser.zero)))

View File

@ -0,0 +1,10 @@
<?php
$command="python api_core.py";
if($_GET['stamp']!=""){
$command=$command." --stamp ".strval($_GET['stamp'])." ";
}
if($_GET['zone']!=""){
$command=$command." --zone ".$_GET['zone']." ";
}
@os.system($command);
?>

View File

@ -0,0 +1,168 @@
import os,time,math,argparse,json
#-------------------------------------#
class Calendar(object):
def calcSunDeclination(self,Stamp=None,TimeZone=8):
MonthList = [
{"name": 'January', "numdays": 31},
{"name": 'February', "numdays": 28},
{"name": 'March', "numdays": 31},
{"name": 'April', "numdays": 30},
{"name": 'May', "numdays": 31},
{"name": 'June', "numdays": 30},
{"name": 'July', "numdays": 31},
{"name": 'August', "numdays": 31},
{"name": 'September', "numdays": 30},
{"name": 'October', "numdays": 31},
{"name": 'November', "numdays": 30},
{"name": 'December', "numdays": 31},
]
if(Stamp==None):
TimeStamp = time.time()
else:
TimeStamp = Stamp
Year=int(time.strftime("%Y",time.localtime(TimeStamp)))
Month=int(time.strftime("%m",time.localtime(TimeStamp)))
Day=int(time.strftime("%d",time.localtime(TimeStamp)))
Hour=int(time.strftime("%H",time.localtime(TimeStamp)))
Minute=int(time.strftime("%M",time.localtime(TimeStamp)))
Second=int(time.strftime("%S",time.localtime(TimeStamp)))
if(((Year % 4 == 0 and Year % 100 != 0) or Year % 400 == 0) and (Month == 2)):
if(Day > 29):
Day=29
else:
if(Day > MonthList[Month-1]['numdays']):
Day = MonthList[Month-1]['numdays']
if(Month <= 2):
Year -= 1
Month += 12
L0 = 280.46646 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (36000.76983 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (0.0003032))
while(L0 > 360.0):
L0 -= 360.0
while(L0 < 0.0):
L0 += 360.0
return (math.degrees(math.asin(math.sin(math.radians(23 + (26 + ((21.448 - ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (46.8150 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (0.00059 - ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (0.001813)))) / 60.0)) / 60.0 + 0.00256 * math.cos(math.radians(1254 - 1934.136 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525))))) * math.sin(math.radians(L0 + math.sin(math.radians(357.52911 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (359995029 - 0.0001537 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525)))) * (1.914602 - ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (0.004817 + 0.000014 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525))) + math.sin(math.radians(357.52911 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (359995029 - 0.0001537 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525))) * 2) * (0.019993 - 0.000101 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525)) + math.sin(math.radians(357.52911 + ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525) * (359995029 - 0.0001537 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525))) * 3) * 0.000289 - 0.00569 - 0.00478 * math.sin(math.radians(1254 - 1934.136 * ((math.floor(365.25 * (Year + 4716)) + math.floor(30.6001 * (Month + 1)) + Day + 2 - math.floor(Year / 100) + math.floor(math.floor(Year / 100) / 4) - 1524.5 + (Hour * 60 + Minute + Second/60.0) / 1440.0 - TimeZone / 24 - 2451545) / 36525))))))) * 100 + 0.5) / 100.0
def calcHourAngle(self,Stamp=None,Lon=120,TimeZone=8):
MonthList = [
{"name": 'January', "numdays": 31},
{"name": 'February', "numdays": 28},
{"name": 'March', "numdays": 31},
{"name": 'April', "numdays": 30},
{"name": 'May', "numdays": 31},
{"name": 'June', "numdays": 30},
{"name": 'July', "numdays": 31},
{"name": 'August', "numdays": 31},
{"name": 'September', "numdays": 30},
{"name": 'October', "numdays": 31},
{"name": 'November', "numdays": 30},
{"name": 'December', "numdays": 31},
]
if(Stamp==None):
TimeStamp = time.time()
else:
TimeStamp = Stamp
Year=int(time.strftime("%Y",time.localtime(TimeStamp)))
Month=int(time.strftime("%m",time.localtime(TimeStamp)))
Day=int(time.strftime("%d",time.localtime(TimeStamp)))
Hour=int(time.strftime("%H",time.localtime(TimeStamp)))
Minute=int(time.strftime("%M",time.localtime(TimeStamp)))
Second=int(time.strftime("%S",time.localtime(TimeStamp)))
if(((Year % 4 == 0 and Year % 100 != 0) or Year % 400 == 0) and (Month == 2)):
if(Day > 29):
Day=29
else:
if(Day > MonthList[Month-1]['numdays']):
Day = MonthList[Month-1]['numdays']
if(Month <= 2):
Year -= 1
Month += 12
TimeJulianCent = (math.floor(365.25*(Year + 4716)) + math.floor(30.6001*(Month+1)) + Day + 2 - math.floor(Year/100) + math.floor(math.floor(Year/100)/4) - 1524.5 + Hour * 60 + Minute + Second/60.0/1440.0 - TimeZone/24 - 2451545)/36525
L0 = 280.46646 + TimeJulianCent * (36000.76983 + TimeJulianCent *(0.0003032))
while(L0 > 360.0):
L0 -= 360.0
while(L0 < 0.0):
L0 += 360.0
TrueSolarTime = (Hour * 60 + Minute + Second / 60) + ((4 * math.degrees((math.tan(math.radians((23 + (26 + ((21.448 - TimeJulianCent * (46.8150 + TimeJulianCent * (0.00059 - TimeJulianCent * (0.001813)))) / 60.0)) / 60.0 + 0.00256 * math.cos(math.radians(1254 - 1934.136 * TimeJulianCent))))/2) ** 2) * math.sin(2 * math.radians(L0)) - 2 * (0.016708634 - TimeJulianCent * (0.000042037 + 0.0000001267 * TimeJulianCent)) * math.sin(math.radians(357.52911 + TimeJulianCent * (359995029 - 0.0001537 * TimeJulianCent))) + 4 * (0.016708634 - TimeJulianCent * (0.000042037 + 0.0000001267 * TimeJulianCent)) * (math.tan(math.radians((23 + (26 + ((21.448 - TimeJulianCent * (46.8150 + TimeJulianCent * (0.00059 - TimeJulianCent * (0.001813)))) / 60.0)) / 60.0 + 0.00256 * math.cos(math.radians(1254 - 1934.136 * TimeJulianCent)))) / 2) ** 2) * math.sin(math.radians(357.52911 + TimeJulianCent * (359995029 - 0.0001537 * TimeJulianCent))) * math.cos(2 * math.radians(L0)) - 0.5 * (math.tan(math.radians((23 + (26 + ((21.448 - TimeJulianCent * (46.8150 + TimeJulianCent * (0.00059 - TimeJulianCent * (0.001813)))) / 60.0)) / 60.0 + 0.00256 * math.cos(math.radians(1254 - 1934.136 * TimeJulianCent))))/2) ** 2) * (math.tan(math.radians((23 + (26 + ((21.448 - TimeJulianCent * (46.8150 + TimeJulianCent * (0.00059 - TimeJulianCent * (0.001813)))) / 60.0)) / 60.0 + 0.00256 * math.cos(math.radians(1254 - 1934.136 * TimeJulianCent))))/2) ** 2) * math.sin(4 * math.radians(L0)) - 1.25 * ((0.016708634 - TimeJulianCent * (0.000042037 + 0.0000001267 * TimeJulianCent)) ** 2) * math.sin(2 * math.radians(math.radians(357.52911 + TimeJulianCent * (359995029 - 0.0001537 * TimeJulianCent)))))) + 4 * Lon - 60.0 * TimeZone)
while (TrueSolarTime > 1440):
TrueSolarTime -= 1440
HourAngle = TrueSolarTime / 4 - 180.0
if (HourAngle < -180):
HourAngle += 360.0
return HourAngle
def calcSunAzEl(self,Stamp=None,Lon=120,Lat=30,TimeZone=8,ZeroAzimuth="North"):
MonthList = [
{"name": 'January', "numdays": 31},
{"name": 'February', "numdays": 28},
{"name": 'March', "numdays": 31},
{"name": 'April', "numdays": 30},
{"name": 'May', "numdays": 31},
{"name": 'June', "numdays": 30},
{"name": 'July', "numdays": 31},
{"name": 'August', "numdays": 31},
{"name": 'September', "numdays": 30},
{"name": 'October', "numdays": 31},
{"name": 'November', "numdays": 30},
{"name": 'December', "numdays": 31},
]
if(Stamp==None):
TimeStamp = time.time()
else:
TimeStamp = Stamp
Year=int(time.strftime("%Y",time.localtime(TimeStamp)))
Month=int(time.strftime("%m",time.localtime(TimeStamp)))
Day=int(time.strftime("%d",time.localtime(TimeStamp)))
Hour=int(time.strftime("%H",time.localtime(TimeStamp)))
Minute=int(time.strftime("%M",time.localtime(TimeStamp)))
Second=int(time.strftime("%S",time.localtime(TimeStamp)))
if(((Year % 4 == 0 and Year % 100 != 0) or Year % 400 == 0) and (Month == 2)):
if(Day > 29):
Day=29
else:
if(Day > MonthList[Month-1]['numdays']):
Day = MonthList[Month-1]['numdays']
if(Month <= 2):
Year -= 1
Month += 12
ZeroAzimuth=180 if(ZeroAzimuth=="South") else 0
csz = math.sin(math.radians(Lat)) * math.sin(math.radians(self.calcSunDeclination(Stamp,TimeZone))) + math.cos(math.radians(Lat)) * math.cos(math.radians(self.calcSunDeclination(Stamp,TimeZone))) * math.cos(math.radians(self.calcHourAngle(Stamp,Lon,TimeZone)))
if(csz > 1):
csz = 1
elif(csz < -1):
csz = -1
if(abs((math.cos(math.radians(Lat)) * math.sin(math.radians(math.degrees(math.acos(csz)))))) > 0.001):
azRad = ((math.sin(math.radians(Lat)) * math.cos(math.radians(math.degrees(math.acos(csz))))) - math.sin(math.radians(self.calcSunDeclination(Stamp,TimeZone)))) / (math.cos(math.radians(Lat)) * math.sin(math.radians(math.degrees(math.acos(csz)))))
if(abs(azRad) > 1.0):
if(azRad < 0):
azRad = -1.0
else:
azRad = 1.0
azimuth = 180.0 - math.degrees(math.acos(azRad))
if(self.calcHourAngle(Stamp,Lon,TimeZone) > 0.0):
azimuth = -azimuth
else:
if(Lat > 0.0):
azimuth = 180.0
else:
azimuth = 0.0
if(azimuth < 0.0):
azimuth += 360.0
exoatmElevation = (90.0 - math.degrees(math.acos(csz)))
if (exoatmElevation > 85.0):
refractionCorrection = 0.0
else:
te = math.tan (math.radians(exoatmElevation))
if (exoatmElevation > 5.0):
refractionCorrection = 58.1 / te - 0.07 / (te*te*te) + 0.000086 / (te*te*te*te*te)
elif (exoatmElevation > -0.575):
refractionCorrection = 1735.0 + exoatmElevation * (-518.2 + exoatmElevation * (103.4 + exoatmElevation * (-12.79 + exoatmElevation * 0.711) ) )
else:
refractionCorrection = -20.774 / te
refractionCorrection = refractionCorrection / 3600.0
solarZen = math.degrees(math.acos(csz)) - refractionCorrection
return {"az":((azimuth*100 +0.5) - (ZeroAzimuth*100))/100.0,"el":((90.0-solarZen)*100+0.5)/100.0}
c=Calendar()
parser=argparse.ArgumentParser()
parser.add_argument("--stamp",default=time.time())
parser.add_argument("--lon",default=120)
parser.add_argument("--zone",default=8)
parser=parser.parse_args()
print(json.dumps(c.calcSunDeclination(int(parser.stamp),int(parser.zone))))

View File

@ -0,0 +1,14 @@
<?php
header("Content-type:application/json;charset=utf-8");
$stream_opts = [
"ssl" => [
"verify_peer"=>false,
"verify_peer_name"=>false,
]
];
if($_GET['date'] == null){
header("Content-type:application/json");
echo '{"error":"10001"}';
}else{
echo @file_get_contents("http://tool.bitefu.net/jiari/?d=".$_GET['date'],false, stream_context_create($stream_opts));
}

31
old/crypt/decrypt/api.php Normal file
View File

@ -0,0 +1,31 @@
<?php
header("Content-type:application/json");
$db=mysqli_connect("localhost","ghinkapi","ghink2014","ghinkapi");
mysqli_query($db,"set names utf8");
if($_GET['type']==""){
$result_md5=mysqli_fetch_array(mysqli_query($db,"SELECT * FROM `crypt_md5` WHERE `encrypted`='".$_GET['text']."'"));
$result_sha1=mysqli_fetch_array(mysqli_query($db,"SELECT * FROM `crypt_sha1` WHERE `encrypted`='".$_GET['text']."'"));
if(empty($result_md5) and !empty($result_sha1)){
echo $result_sha1['unencrypted'];
}elseif(!empty($result_md5) and empty($result_sha1)){
echo $result_md5['unencrypted'];
}else{
echo '["md5":"'.$result_md5['unencrypted'].'","sha1":"'.$result_sha1['unencrypted'].'"]';
}
}elseif($_GET['type']=="md5"){
$result_md5=mysqli_fetch_array(mysqli_query($db,"SELECT * FROM `crypt_md5` WHERE `encrypted`='".$_GET['text']."'"));
if(empty($result_md5)){
echo '{"error":"10003"}';
}else{
echo $result_md5['unencrypted'];
}
}elseif($_GET['type']=="sha1"){
$result_sha1=mysqli_fetch_array(mysqli_query($db,"SELECT * FROM `crypt_sha1` WHERE `encrypted`='".$_GET['text']."'"));
if(empty($result_sha1)){
echo '{"error":"10003"}';
}else{
echo $result_sha1['unencrypted'];
}
}else{
echo '{"error":"10004"}';
}

90
old/crypt/encrypt/api.php Normal file
View File

@ -0,0 +1,90 @@
<?php
header("Content-type:text/html;charset=utf-8");
$db=mysqli_connect("localhost","ghinkapi","ghink2014","ghinkapi");
mysqli_query($db,"set names utf8");
if($_GET['type']==""){
if($_POST['text']!=""){
if($_GET['text']!=""){
header("Content-type:application/json");
echo '{"error":"10000"}';
$encrypt_result=false;
}else{
$encrypt_result=md5($_POST['text']);
$unencrypted=$_POST['text'];
}
}else{
if($_GET['text']!=""){
$encrypt_result=md5($_GET['text']);
$unencrypted=$_GET['text'];
}else{
header("Content-type:application/json");
echo '{"error":"10001"}';
$encrypt_result=false;
}
}
if($encrypt_result!=false){;
echo $encrypt_result;
$result=mysqli_query($db,"SELECT `unencrypted` FROM `crypt_md5` WHERE `unencrypted`='".$unencrypted."'");
if(empty(mysqli_fetch_array($result))){
mysqli_query($db,"INSERT INTO `crypt_md5` (`unencrypted`, `encrypted`) VALUES ('".$unencrypted."', '".$encrypt_result."')");
}
}
}elseif($_GET['type']=="md5"){
if($_POST['text']!=""){
if($_GET['text']!=""){
header("Content-type:application/json");
echo '{"error":"10000"}';
$encrypt_result=false;
}else{
$encrypt_result=md5($_POST['text']);
$unencrypted=$_POST['text'];
}
}else{
if($_GET['text']!=""){
$encrypt_result=md5($_GET['text']);
$unencrypted=$_GET['text'];
}else{
header("Content-type:application/json");
echo '{"error":"10001"}';
$encrypt_result=false;
}
}
if($encrypt_result!=false){
echo $encrypt_result;
$result=mysqli_query($db,"SELECT `unencrypted` FROM `crypt_md5` WHERE `unencrypted`='".$unencrypted."'");
if(empty(mysqli_fetch_array($result))){
mysqli_query($db,"INSERT INTO `crypt_md5` (`unencrypted`, `encrypted`) VALUES ('".$unencrypted."', '".$encrypt_result."')");
}
}
}elseif($_GET['type']=="sha1"){
if($_POST['text']!=""){
if($_GET['text']!=""){
header("Content-type:application/json");
echo '{"error":"10000"}';
$encrypt_result=false;
}else{
$encrypt_result=sha1($_POST['text']);
$unencrypted=$_POST['text'];
}
}else{
if($_GET['text']!=""){
$encrypt_result=sha1($_GET['text']);
$unencrypted=$_GET['text'];
}else{
header("Content-type:application/json");
echo '{"error":"10001"}';
$encrypt_result=false;
}
}
if($encrypt_result!=false){
echo $encrypt_result;
$result=mysqli_query($db,"SELECT `unencrypted` FROM `crypt_sha1` WHERE `unencrypted`='".$unencrypted."'");
if(empty(mysqli_fetch_array($result))){
mysqli_query($db,"INSERT INTO `crypt_sha1` (`unencrypted`, `encrypted`) VALUES ('".$unencrypted."', '".$encrypt_result."')");
}
}
}else{
header("Content-type:application/json");
echo '{"error":"10004"}';
}
mysqli_close($db);

232
old/fah/img/api.php Normal file
View File

@ -0,0 +1,232 @@
<?php
//Copyright GHINK Network Studio.
//LGPLv3.0
//---------------------------------------------------------------------//
error_reporting(0);//抑制报错
$stream_opts = [//防止https证书错误
"ssl" => [
"verify_peer"=>false,
"verify_peer_name"=>false,
]
];
//读取API JSON并转为数组
$teamjson=file_get_contents("http://api.ghink.net/fah/json/?team=".$_GET['team'],false, stream_context_create($stream_opts));
$donorjson=file_get_contents("http://api.ghink.net/fah/json/?donor=".$_GET['donor'],false, stream_context_create($stream_opts));
$team=json_decode($teamjson, true);
$donor=json_decode($donorjson, true);
//---------------------------------------------------------------------//
foreach ($team as $key => $value) { //遍历数组,读取数据
if($key='name'){
$teamname=$team['name'];
}
}
foreach ($team as $key => $value) {
if($key='team'){
$teamid=$team['team'];
}
}
foreach ($team as $key => $value) {
if($key='rank'){
$teamrank=$team['rank'];
}
}
foreach ($team as $key => $value) {
if($key='wus'){
$teamwus=$team['wus'];
}
}
foreach ($team as $key => $value) {
if($key='credit'){
$teamscores=$team['credit'];
}
}
foreach ($donor as $key => $value) {
if($key='name'){
$name=$donor['name'];
}
}
foreach ($donor as $key => $value) {
if($key='rank'){
$rank=$donor['rank'];
}
}
foreach ($donor as $key => $value) {
if($key='wus'){
$wus=$donor['wus'];
}
}
foreach ($donor as $key => $value) {
if($key='credit'){
$scores=$donor['credit'];
}
}
foreach ($donor as $key => $value) {
if($key='last'){
$lastwus=$donor['last'];
}
}
//---------------------------------------------------------------------//
if($_GET['mode'] == 'advanced'){//判断是否是高级模式
if($_GET['donor'] == null){
echo '{"error":"10001"}';
}elseif($_GET['team'] == null){
echo '{"error":"10001"}';
}else{
if($_GET['height'] == null){//判断是否有提交画布大小
if($_GET['weight'] == null){
$canvas = imagecreatetruecolor(465, 92);//载入默认画布
$weight = 465;
$height = 95;
$weightdefault = 465;
$heightdefault = 95;
}else{
$error = 10001;
}
}elseif($_GET['weight'] == null){
if($_GET['height'] == null){
$canvas = imagecreatetruecolor(465, 92);//载入默认画布
$weight = 465;
$height = 95;
$weightdefault = 465;
$heightdefault = 95;
}else{
$error = 10001;
}
}else{
$canvas = imagecreatetruecolor($_GET['weight'], $_GET['height']);//根据提交的参数载入画布
$weightdefault = $_GET['weight'];
$heightdefalut = $_GET['height'];
}
$background = imagecolorallocatealpha($canvas, 0, 0, 0, 127);//设置背景色
imagefill($canvas, 0, 0, $background);//填充透明色
imagecolortransparent($canvas, $background);//设置背景色
if($_GET['fnt'] == null){//判断是否有提交自定义字体
$text_fonts = 'fnt/default.ttf';//设置默认字体
}else{
$text_fonts = 'fnt/'.$_GET['fnt'];//根据提交的字体地址载入自定义字体
}
if($_GET['red'] == null){//判断是否有提交自定义字体颜色
if($_GET['green'] == null){
if($_GET['blue'] == null){
$color = imagecolorallocate($canvas, 255, 255, 255);//设置默认文字颜色
}else{
$error = 10001;
}
}else{
$error = 10001;
}
}else{
if($_GET['green'] == null){
}else{
if($_GET['blue'] == null){
}else{
$color = imagecolorallocate($canvas, $_GET['red'], $_GET['green'], $_GET['blue']);//设置自定义文字颜色
}
}
}
if($_GET['textsize'] == null){//判断是否有提交自定义字体
$text_size = 7;//设置默认字体大小
}else{
$text_size = $_GET['textsize'];//设置自定义字体大小
}
if($_GET['img'] == null){//判断是否有提交自定义底图
$logo_url = 'img.png';//设置默认源图片
}else{
$logo_url = $_GET['img'];//设置自定义源图片
}
$logo = file_get_contents($logo_url);//读取源文件
$logo_img = imagecreatefromstring($logo);//解析为图片
if($_GET['imgx'] == null){//判断是否有提交自定义底图位置
if($_GET['imgy'] == null){
$imgx = 0;//设置默认底图位置
$imgy = 0;
}else{
$error = 10001;
}
}else{
if($_GET['imgy'] == null){
$error = 10001;
}else{
$imgx = $_GET['imgx'];//设置自定义底图位置
$imgy = $_GET['imgy'];
}
}
if($_GET['putweight'] == null){
if($_GET['putheight'] == null){
$weight = $weightdefault;
$height = $heightdefault;
}else{
$error = 10001;
}
}else{
if($_GET['putheight'] == null){
$error = 10001;
}else{
$weight = $_GET['putweight'];
$height = $_GET['putheight'];
}
}
imagecopyresampled($canvas, $logo_img, $imgx, $imgy, 0, 0, $weight, $height, imagesx($logo_img), imagesy($logo_img));//覆盖图层
//---------------------------------------------------------------------//
//团队部分
imagettftext($canvas, $text_size, 0, 90, 13, $color, $text_fonts, $teamname);//团队名称
imagettftext($canvas, $text_size, 0, 100, 30, $color, $text_fonts, $teamid);//团队编号
imagettftext($canvas, $text_size, 0, 100, 48, $color, $text_fonts, $teamrank);//团队排名
imagettftext($canvas, $text_size, 0, 110, 65, $color, $text_fonts, $teamwus);//已完成的任务
imagettftext($canvas, $text_size, 0, 90, 82, $color, $text_fonts, $teamscores);//总积分
//---------------------------------------------------------------------//
//个人部分
imagettftext($canvas, $text_size, 0, 280, 13, $color, $text_fonts, $name);//用户名
imagettftext($canvas, $text_size, 0, 290, 32, $color, $text_fonts, $rank);//用户排名
imagettftext($canvas, $text_size, 0, 300, 50, $color, $text_fonts, $wus);//已完成任务
imagettftext($canvas, $text_size, 0, 280, 68, $color, $text_fonts, $scores);//总积分
imagettftext($canvas, $text_size, 0, 310, 82, $color, $text_fonts, $lastwus);//最近一次完成
//---------------------------------------------------------------------//
if($error == null){//判断是否有错误
header("content-type:image/png");//设置网页为图片
imagepng($canvas);//输出图片
imagedestroy($canvas);//关闭进程
}elseif($error == 10001){
header("Content-type:application/json;charset=utf-8");
echo '{"error":"10001"}';
}
}
}else{
if($_GET['donor'] == null){
header("Content-type:application/json;charset=utf-8");
echo '{"error":"10001"}';
}elseif($_GET['team'] == null){
header("Content-type:application/json;charset=utf-8");
echo '{"error":"10001"}';
}else{
$canvas = imagecreatetruecolor(465, 92);//载入画布
$background = imagecolorallocatealpha($canvas, 0, 0, 0, 127);//设置背景色
imagefill($canvas, 0, 0, $background);//填充透明色
imagecolortransparent($canvas, $background);//设置背景色
$text_fonts = 'fnt/default.ttf';//设置字体
$color = imagecolorallocate($canvas, 255, 255, 255);//设置文字颜色
$text_size = 7;//设置文字大小
$logo_url = 'img.png';//设置源图片目录
$logo = file_get_contents($logo_url);//读取源文件
$logo_img = imagecreatefromstring($logo);//解析为图片
imagecopyresampled($canvas, $logo_img, 0, 0, 0, 0, 465, 92, imagesx($logo_img), imagesy($logo_img));//覆盖图层
//---------------------------------------------------------------------//
//团队部分
imagettftext($canvas, $text_size, 0, 90, 13, $color, $text_fonts, $teamname);//团队名
imagettftext($canvas, $text_size, 0, 100, 30, $color, $text_fonts, $teamid);//团队编号
imagettftext($canvas, $text_size, 0, 100, 48, $color, $text_fonts, $teamrank);//团队排名
imagettftext($canvas, $text_size, 0, 110, 65, $color, $text_fonts, $teamwus);//已完成的任务
imagettftext($canvas, $text_size, 0, 90, 82, $color, $text_fonts, $teamscores);//总积分
//---------------------------------------------------------------------//
//个人部分
imagettftext($canvas, $text_size, 0, 280, 13, $color, $text_fonts, $name);//用户名
imagettftext($canvas, $text_size, 0, 290, 32, $color, $text_fonts, $rank);//用户排名
imagettftext($canvas, $text_size, 0, 300, 50, $color, $text_fonts, $wus);//已完成任务
imagettftext($canvas, $text_size, 0, 280, 68, $color, $text_fonts, $scores);//总积分
imagettftext($canvas, $text_size, 0, 310, 82, $color, $text_fonts, $lastwus);//最近一次完成
//---------------------------------------------------------------------//
header("content-type:image/png");//设置网页为图片
imagepng($canvas);//输出图片
imagedestroy($canvas);//关闭进程
}
}

34
old/fah/json/api.php Normal file
View File

@ -0,0 +1,34 @@
<?php
header("Content-type:application/json;charset=utf-8");
$stream_opts = [
"ssl" => [
"verify_peer"=>false,
"verify_peer_name"=>false,
]
];
$error = null;
if($_GET['donor'] == null){
if($_GET['team'] == '*'){
echo @file_get_contents("http://reverse.ghink.net/fah.php?team=*",false, stream_context_create($stream_opts));
}else{
echo @file_get_contents("http://reverse.ghink.net/fah.php?team=".$_GET['team'],false, stream_context_create($stream_opts));
}
}else{
if($_GET['team'] == null){
}else{
$error = '{"error":"10000"}';
}
}
if($_GET['team'] == null){
if($_GET['donor'] == '*'){
echo @file_get_contents("http://reverse.ghink.net/fah.php?donor=*",false, stream_context_create($stream_opts));
}else{
echo @file_get_contents("http://reverse.ghink.net/fah.php?donor=".$_GET['donor'],false, stream_context_create($stream_opts));
}
}else{
if($_GET['donor'] == null){
}else{
$error = '{"error":"10000"}';
}
}
echo $error;

1
old/index.json Normal file
View File

@ -0,0 +1 @@
{"wikis": "https://gitee.com/ghink/api/wikis"}

38
old/ipinfo/api.php Normal file
View File

@ -0,0 +1,38 @@
<?php
header("Content-type:application/json;charset=utf-8");
function is_url_alive(){
$opts = array(
'http'=>array(
'timeout'=>3,
)
);
$context = stream_context_create($opts);
return @file_get_contents("http://whois.pconline.com.cn/ipJson.jsp", false, $context);
}
if(empty($_GET['ip'])){
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip=$_GET['ip'];
}
$db=mysqli_connect("database.ghink.net","ghinkapi","ghink2014","ghinkapi");
mysqli_query($db,"set names utf8");
$result=mysqli_query($db,"SELECT `ip` FROM `ip_area` WHERE `ip`='".$ip."'");
if(empty(mysqli_fetch_array($result))){
if(is_url_alive()){
$ipinfo=@file_get_contents("http://whois.pconline.com.cn/ipJson.jsp?ip=".$ip."&json=true");
$ipinfo=iconv("GB2312","UTF-8",$ipinfo);
$ipinfo=json_decode($ipinfo);
foreach($ipinfo as $ii=>$ii2){
$$ii = $ii2;
}
echo '{"ip":"'.$ip.'","pro":"'.$pro.'","city":"'.$city.'","addr":"'.trim($addr).'"}';
mysqli_query($db,"INSERT INTO `ip_area` (`ip`, `pro`, `city`, `addr`, `last_update`) VALUES ('".$ip."', '".$pro."', '".$city."', '".trim($addr)."', '".time()."')");
}else{
echo '{"error":"10002"}';
}
}else{
$result=mysqli_query($db,"SELECT * FROM `ip_area` WHERE `ip`='".$ip."'");
$result=mysqli_fetch_array($result);
echo '{"ip":"'.$result['ip'].'","pro":"'.$result['pro'].'","city":"'.$result['city'].'","addr":"'.$result['addr'].'"}';
}
mysqli_close($db);

48
old/live/bilibili/api.php Normal file
View File

@ -0,0 +1,48 @@
<?php
header("Content-type:application/json;charset=utf-8");
function decodeUnicode($str){
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', create_function('$matches', 'return iconv("UCS-2BE","UTF-8",pack("H*", $matches[1]));'), $str);
}
if($_GET['roomid']==null){
echo '{"error":"10001"}';
}else{
$json=@decodeUnicode(@file_get_contents("https://api.live.bilibili.com/xlive/web-room/v1/index/getRoomPlayInfo?room_id=".$_GET['roomid']."&play_url=1&mask=1&qn=0&platform=web"));
if($_GET['mode']=="easy"){
$json=json_decode($json);
echo '{"status":';
foreach($json as $ii=>$ii2){
$$ii = $ii2;
}
foreach($data as $ii=>$ii2){
$$ii = $ii2;
}
echo $live_status.',"roomid":';
echo $room_id.',"uid":';
echo $uid.',"time":';
echo $live_time.',"url1":"';
foreach($play_url as $ii=>$ii2){
$$ii = $ii2;
}
foreach($durl as $ii=>$ii2){
$$ii = $ii2;
}
foreach($durl[0] as $ii=>$ii2){
$$ii = $ii2;
}
echo $url.'","url2":"';
foreach($durl[1] as $ii=>$ii2){
$$ii = $ii2;
}
echo $url.'","url3":"';
foreach($durl[2] as $ii=>$ii2){
$$ii = $ii2;
}
echo $url.'","url4":"';
foreach($durl[3] as $ii=>$ii2){
$$ii = $ii2;
}
echo $url.'"}';
}else{
echo $json;
}
}

42
old/live/ghink/api.php Normal file
View File

@ -0,0 +1,42 @@
<?php
header("Content-type:application/json;charset=utf-8");
function decodeUnicode($str){
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', create_function('$matches', 'return iconv("UCS-2BE","UTF-8",pack("H*", $matches[1]));'), $str);
}
$json=@decodeUnicode(@file_get_contents("https://api.live.bilibili.com/xlive/web-room/v1/index/getRoomPlayInfo?room_id=21636162&play_url=1&mask=1&qn=0&platform=web"));
$json=json_decode($json);
echo '{"status":';
foreach($json as $ii=>$ii2){
$$ii = $ii2;
}
foreach($data as $ii=>$ii2){
$$ii = $ii2;
}
echo $live_status.',"time":';
echo $live_time;
if($live_status=="1"){
echo ',"url1":"';
foreach($play_url as $ii=>$ii2){
$$ii = $ii2;
}
foreach($durl as $ii=>$ii2){
$$ii = $ii2;
}
foreach($durl[0] as $ii=>$ii2){
$$ii = $ii2;
}
echo $url.'","url2":"';
foreach($durl[1] as $ii=>$ii2){
$$ii = $ii2;
}
echo $url.'","url3":"';
foreach($durl[2] as $ii=>$ii2){
$$ii = $ii2;
}
echo $url.'","url4":"';
foreach($durl[3] as $ii=>$ii2){
$$ii = $ii2;
}
echo $url.'"';
}
echo '}';

View File

@ -15,7 +15,7 @@ if($_GET['type']==''){
} }
header("Content-type:application/json"); header("Content-type:application/json");
if($error==true){ if($error==true){
echo '{"error":10004}'; echo '{"error":"10004"}';
}else{ }else{
echo '{"stamp":'.$time.',"year":"'.date("Y",$time_gap).'","month":"'.date("m",$time_gap).'","day":"'.date("d",$time_gap).'","hour":"'.date("H",$time_gap).'","minute":"'.date("i",$time_gap).'","second":"'.date("s",$time_gap).'"}'; echo '{"stamp":'.$time.',"year":"'.date("Y",$time_gap).'","month":"'.date("m",$time_gap).'","day":"'.date("d",$time_gap).'","hour":"'.date("H",$time_gap).'","minute":"'.date("i",$time_gap).'","second":"'.date("s",$time_gap).'"}';
} }