<?php

$intervalyaml="
alive:
 interval: 3
 mode: seconds
 lastruntime: ".time()."

autoSync:
 interval: 4
 mode: minutes
 lastruntime: ".time()."

channelReader:
 interval: 2
 mode: minutes
 lastruntime: ".time()."

chnStepper:
 interval: 5
 mode: seconds
 lastruntime: ".time()."

deleteMarkedMessages:
 interval: 5
 mode: minutes
 lastruntime: ".time()."

deleteRequestMessages:
 interval: 12
 mode: hours
 lastruntime: ".time()."

fwdStepper:
 interval: 15
 mode: seconds
 lastruntime: ".time()."

someStats:
 interval: 1
 mode: minutes
 lastruntime: ".time()."

usr_managment:
 interval: 3
 mode: seconds
 lastruntime: ".time()."
 
repostMsg:
 interval: 30
 mode: seconds
 lastruntime: ".time()." 
";
$interval=yaml_parse($intervalyaml);

$typemappingyaml="
all:
 types:
  - 123
  
mp3:
 types:
  - audio/mp3
  - audio/mpeg3
  - audio/m4a
  - audio/mp4
  - audio/mpeg

flac:
 types:
  - audio/x-flac
  - audio/flac
  - audio/FLAC

audio:
 types:
  - audio/mp3
  - audio/mpeg3
  - audio/m4a
  - audio/mp4
  - audio/mpeg
  - audio/x-flac
  - audio/flac
  - audio/FLAC
  - audio/x-wav
  - audio/x-dsf  

movie:
 min-duration: 75
 types:
  - video/mp4
  - video/mpeg
  - video/webm 
  - video/x-matroska
  - video/x-msvideo
  - video/avi
  
moviefhd:
 min-duration: 75
 min-size: 1700
 min-width: 1800
 types:
  - video/mp4
  - video/mpeg
  - video/webm 
  - video/x-matroska
  - video/x-msvideo
  - video/avi

movie4gb:
 min-duration: 75
 min-size: 2500
 min-width: 1800
 types:
  - video/mp4
  - video/mpeg
  - video/webm 
  - video/x-matroska
  - video/x-msvideo
  - video/avi

# serie:  # not implemented 
#  min-duration: 15
#  max-duration: 70
#   types:
#    - video/mp4
#    - video/mpeg
#    - video/webm 
#    - video/x-matroska
#    - video/x-msvideo
#    - video/avi

video:
 min-duration: 15
 types:
  - video/mp4
  - video/mpeg
  - video/webm 
  - video/x-matroska
  - video/x-msvideo
  - video/avi

audiobooks:
 types:
 - application/octet-stream
 - application/rar
 - application/vnd.rar
 - application/x-7z-compressed
 - application/x-rar
 - application/x-rar-compressed
 - application/x-zip-compressed
 - application/zip
 - audio/m4a
 - audio/mp3
 - audio/mp4
 - audio/mpeg
 - audio/x-mpegurl
 - multipart/x-zip
 - video/mp4
  
archive:
 types:
  - application/rar
  - application/x-rar
  - application/x-rar-compressed
  - application/vnd.rar
  - application/zip
  - application/x-zip-compressed
  - application/x-7z-compressed
  - application/octet-stream
  - audio/vnd.dts.hd
  - text/x-matlab
  
ebooks:
 types:
  - application/epub+zip
  - application/msword
  - application/pdf
  - application/rar
  - application/vnd.comicbook-rar
  - application/vnd.openxmlformats-officedocument.wordprocessingml.document
  - application/vnd.rar
  - application/x-7z-compressed
  - application/x-aportisdoc
  - application/x-cbr
  - application/x-fictionbook+xml
  - application/x-mobipocket-ebook
  - application/zip
  - multipart/x-zip
";
$typemapping=yaml_parse($typemappingyaml);

$globalsettingsyaml="
user:
 role:
  - creator
  - admin
  - user
  - banned
  - deleted account
 userstatus:
  - userStatusOnline
  - userStatusOffline  
  - userStatusRecently
  - userStatusLastWeek
  - userStatusLastMonth
  - userStatusEmpty
  - userStatusNoStatusSet # my own status, when no status is set...
 allchannelsreaded: false
  
admin:
 setchannel:
  - mode 
#  - typemapping
  - autosync
  - disabled
  - channelbotname
 
request:
 deleterequestmessagesafter: 24 # in hour # not in use 
 requestMessagesDeleteTimer: 10 # in days # done 
 requestSilentMode: 1           # not in use 
 requestcommand:                # done
 
forward:
 recoverqueue: true

channels:
 channeldb: # done 
 channelinfo: 
 repostinfomintimer: 30 # in minutes
 repostinfocheckadmin: true

channelreader:
 bckStepArray: 
 isJobRunning: 

message:
 deletemessagestimer: 120 # in seconds # done 
 deletemarker: # done 
 cuttext: 50  # done
 lastmessage:  
 savelastmessagexml: # save last message xml 
  
search:
 maxresults: 25 # done

database:
 dbhost: # done
 dbport: # done
 dbuser: # done
 dbname: # done
 dbpass: # done
 pg_conn: true
 
bot:
 version: v0.0094 # done
 motto: no one will stop this train!
 pandaownerid:             # done 
 pandaownername:           # done
 starttime: ".time()."     # done 
 defaultdateformat: 'Y-m-d H:i:s'
 floodwait: -1
 systemload: 
 memory:
 shm_memory: 15000000 # in byte # done
 botname:
 downloaddirectory: 
 lastbotexceptions:
  count: 20
  exceptions: 
 lastbotcommands: 
  count: 20
  commands: 
 botcommands:     # done
  - help
  - say
  - search
  - suche  
  - last5
  - last10
  - last20
  - last30
#  - last50
#  - last100  
 adminbotcommands: # done 
  - help
  - stats
  - topics         # error when channel not on dialog :/ rewrite? channels->channeldb globalsettings class? easier access settings? 
  - channelstatus
  - setchannel
  - clearqueue
  - lastbotcommands
  - lastbotexceptions
  - user 
  - loadconfig
  - saveconfig
  - download
 channelmode:
  - i 
  - ir
  - r 
 autosyncmode:
  - 'true'
  - 'force'
  - 'false'
 disabledmode:
  - 'true'
  - 'updatedb'
  - 'false'

tgapp:
 APIID: 23842281 # done
 APIHASH: 521b703db3b046b7785d475db410a87d #done
 setTimeout: 30 # done
 setRpcResendTimeout: 10 # done
";
$globalsettings=yaml_parse($globalsettingsyaml);

date_default_timezone_set('Europe/Berlin');
$date=gmdate("Y-m-d H:i:s", time()+date("Z"));

$lastMessagePerChan=array(); 

$runtimeForwardCounter=0; 
$alltimeforwards=0;
$runtimeForwardCalls=0;
$recoverqueue=true;
$toForward=array();
$maxforwards=1400;
$forwardstopmsg="";
$floodchallange=array(); // floodtimer in floodchallange array ["floodtimer"] 
$floodchallange["floodtimer"]=time();
$floodwait=-1;

$forwardMsg=array(); // fwd backstepper array...

$bckStepArray=array(); 
$isJobRunning=array();

$usedPeakMemory="just wait";
$usedMemory="just wait";

$requestSilentMode=1; // -1 || 1 

$floodwait=-1;

ini_set('memory_limit', '64M');



