@name Dup Relay Radio
@inputs [DataOutput]:string Sending Receive
@outputs [DataInput Send Data]:string [Chunks DataHold]:array
@persist [Chunks DataHold]:array ChunkCount
@trigger

if(Sending&~Sending){DataHold=array()}
if(DataOutput&Sending){DataHold:pushString(DataOutput)}
runOnChat(1)
runOnHTTP(1)
if(owner():lastSaid()=="flush the cache"){reset()}
if(!DataOutput&!Chunks:count()&DataHold:count()){
    Packet=httpUrlEncode(glonEncode(DataHold))
    Length=Packet:length()
        timer("delay",3000)
        Chunks=array()
        for(C=1,ceil(Length/4012)){
            First=(C-1)*4012
            Second=C*4012
            Chunks[C,string]=Packet:sub(First,Second)
        }
        Append=0
}
Address="http://www1.dd-tech.com:9000/Upload/upload/dupe.php"
File="Zapsats4_0"

ChunkCount=Chunks:count()
if(Append){State="append"}else{State="send"}

if(Chunks:count()&clk("delay")){
    
    Send=httpUrlEncode(Chunks:shiftString())
    #Send=Chunks:shiftString()
    httpRequest(Address+"?action="+State+"&file="+File+"&glon="+Send)
    Append=1
    timer("delay",3000)
}
if(!Chunks:count()){DataHold=array()}
if(httpClk()){Data=httpData()}


