-- vim:set ft=lua: dofile(mg.script_name:gsub('[^\\/]*$','')..'util.lua') function AddOrChange(dataID,post) local aa={dataID=dataID} local found=nil local presetID=GetVarInt(post,'presetID',0,65534) if presetID then found=BinarySearch(edcb.EnumRecPresetInfo(),{id=presetID},CompareFields('id')) elseif dataID~=0 then found=BinarySearch(edcb.EnumManuAdd(),aa,CompareFields('dataID')) end if found then local useMargin=GetVarInt(post,'useDefMarginFlag')~=1 or nil aa.recSetting={ batFilePath=found.recSetting.batFilePath, recFolderList=found.recSetting.recFolderList, partialRecFolder=found.recSetting.partialRecFolder, recMode=GetVarInt(post,'recEnabled')~=1 and 5 or GetVarInt(post,'recMode',0,4), noRecMode=GetVarInt(post,'recMode',0,4), tuijyuuFlag=GetVarInt(post,'tuijyuuFlag')==1, priority=GetVarInt(post,'priority',1,5), pittariFlag=GetVarInt(post,'pittariFlag')==1, suspendMode=GetVarInt(post,'suspendMode',0,4), rebootFlag=GetVarInt(post,'rebootFlag')==1, startMargin=useMargin and GetVarInt(post,'startMargin',-6*3600,6*3600), endMargin=useMargin and GetVarInt(post,'endMargin',-6*3600,6*3600), serviceMode=GetVarInt(post,'serviceMode')==1 and 0 or 1+16*(GetVarInt(post,'serviceMode_1',0,1) or 0)+32*(GetVarInt(post,'serviceMode_2',0,1) or 0), continueRecFlag=GetVarInt(post,'continueRecFlag')==1, tunerID=GetVarInt(post,'tunerID'), partialRecFlag=GetVarInt(post,'partialRecFlag',0,1) or 0 } if aa.recSetting.recMode and aa.recSetting.priority and aa.recSetting.suspendMode and (not useMargin or aa.recSetting.startMargin and aa.recSetting.endMargin) and aa.recSetting.tunerID then aa.dayOfWeekFlag=0 for i=7,1,-1 do aa.dayOfWeekFlag=aa.dayOfWeekFlag*2+(GetVarInt(post,'checkDayOfWeek'..i)==1 and 1 or 0) end aa.startTime=(GetVarInt(post,'startHour',0,23) or 0)*3600+(GetVarInt(post,'startMin',0,59) or 0)*60+(GetVarInt(post,'startSec',0,59) or 0) aa.durationSecond=((GetVarInt(post,'endHour',0,23) or 0)*3600+(GetVarInt(post,'endMin',0,59) or 0)*60+(GetVarInt(post,'endSec',0,59) or 0)+24*3600-aa.startTime)%(24*3600) aa.onid,aa.tsid,aa.sid=GetVarServiceID(post,'serviceID') if aa.onid then local chInfo=BinarySearch(edcb.GetChDataList(),aa,CompareFields('onid',false,'tsid',false,'sid')) if chInfo then aa.stationName=chInfo.serviceName --制御文字は消す aa.title=(mg.get_var(post,'title') or ''):gsub('%c','') return edcb.AddOrChgManuAdd(aa) end end end end return false end ct=CreateContentBuilder(GZIP_THRESHOLD_BYTE) ct:Append(DOCTYPE_HTML4_STRICT..[=[
]=]) aa={dataID=GetVarInt(mg.request_info.query_string,'id') or 0} if aa.dataID==0 then ct:Append('

# プログラム予約 新規条件追加

\n
\n') post=AssertPost() if post then if mg.get_var(post,'addchg') then ct:Append('
'..(AddOrChange(0,post) and '追加しました' or '入力値不正')..'
\n') end else aa.dayOfWeekFlag=0 aa.startTime=0 aa.durationSecond=0 aa.title='' end edcb.htmlEscape=15 else ct:Append('

# プログラム予約 条件変更

\n
\n') post=AssertPost() if post then if mg.get_var(post,'addchg') then ct:Append('
'..(AddOrChange(aa.dataID,post) and '変更しました' or '入力値不正')..'
\n') end end edcb.htmlEscape=15 aa=BinarySearch(edcb.EnumManuAdd(),aa,CompareFields('dataID')) or aa end if aa.dayOfWeekFlag then ct:Append('

\n' ..'
プリセット
  \n' ..'
  \n' ..'
\n' ..'
条件
  \n' ..'\n' ..'
  \n' ..'\n' ..'
  \n' ..'

  ## 予約条件

  \n') for i=1,7 do ct:Append(' '..({'日','月','火','水','木','金','土'})[i]..'') aa.dayOfWeekFlag=math.floor(aa.dayOfWeekFlag/2) end endTime=(aa.startTime+aa.durationSecond)%(24*3600) ct:Append('
  \n' ..'時間 :: ～ ::
  \n' ..'番組名
  \n' ..'サービス
  \n' ..'

  ## 録画設定

  \n'..RecSettingTemplate(rs)..'
  \n' ..'
\n') if aa.dataID~=0 then ct:Append('
-
  \n' ..'
  \n' ..'\n' ..'\n' ..'
\n') end ct:Append('

\n') end ct:Append([=[
]=]) ct:Finish() mg.write(ct:Pop(Response(200,'text/html','utf-8',ct.len,ct.gzip)..'\r\n'))