mirror of
				https://github.com/DigitalDevices/octonet.git
				synced 2023-10-10 11:36:52 +00:00 
			
		
		
		
	Channel scanning
Added web frontend bug fixes
This commit is contained in:
		
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -55,6 +55,15 @@ local function cmp_title(a,b)
 | 
				
			|||||||
   return a.Title < b.Title
 | 
					   return a.Title < b.Title
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local function Report(count,Title)
 | 
				
			||||||
 | 
					   local f = io.open("/tmp/doscan.lock/doscan.tmp","w+")
 | 
				
			||||||
 | 
					   if f then
 | 
				
			||||||
 | 
					      f:write(count..":"..Title)
 | 
				
			||||||
 | 
					      f:close()
 | 
				
			||||||
 | 
					      os.execute("mv /tmp/doscan.lock/doscan.tmp /tmp/doscan.lock/doscan.msg")
 | 
				
			||||||
 | 
					   end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local keys = {}
 | 
					local keys = {}
 | 
				
			||||||
local include_radio     = 1
 | 
					local include_radio     = 1
 | 
				
			||||||
local include_encrypted = 0
 | 
					local include_encrypted = 0
 | 
				
			||||||
@@ -63,13 +72,13 @@ local outfile = "/config/ChannelList.json"
 | 
				
			|||||||
local ipAddr = nil
 | 
					local ipAddr = nil
 | 
				
			||||||
local sort = nil
 | 
					local sort = nil
 | 
				
			||||||
local include_sitables = nil
 | 
					local include_sitables = nil
 | 
				
			||||||
 | 
					local restart_dms = nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local a
 | 
					local a
 | 
				
			||||||
 | 
					 | 
				
			||||||
for _,a in ipairs(arg) do
 | 
					for _,a in ipairs(arg) do
 | 
				
			||||||
   local par,val = a:match("(%a+)=(.+)")
 | 
					   local par,val = a:match("(%a+)=(.+)")
 | 
				
			||||||
   if par == "key" then
 | 
					   if par == "key" then
 | 
				
			||||||
      local key,src = val:match("(%a+),(d+)")
 | 
					      local key,src = val:match("(%w+)%.(%d+)")
 | 
				
			||||||
      if key then
 | 
					      if key then
 | 
				
			||||||
         keys[key] = tonumber(src)
 | 
					         keys[key] = tonumber(src)
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
@@ -83,6 +92,8 @@ for _,a in ipairs(arg) do
 | 
				
			|||||||
      sort = val
 | 
					      sort = val
 | 
				
			||||||
   elseif par == "sitables" then
 | 
					   elseif par == "sitables" then
 | 
				
			||||||
      include_sitables = val
 | 
					      include_sitables = val
 | 
				
			||||||
 | 
					   elseif par == "restartdms" then
 | 
				
			||||||
 | 
					      restart_dms = val
 | 
				
			||||||
   elseif par == "in" then
 | 
					   elseif par == "in" then
 | 
				
			||||||
      infile = val
 | 
					      infile = val
 | 
				
			||||||
   elseif par == "out" then
 | 
					   elseif par == "out" then
 | 
				
			||||||
@@ -102,10 +113,14 @@ ChannelList.GroupList = {}
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
local Max = 999999
 | 
					local Max = 999999
 | 
				
			||||||
local Count = 0
 | 
					local Count = 0
 | 
				
			||||||
 | 
					local ChannelCount = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Report(ChannelCount,"*")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if tl.SourceList then
 | 
					if tl.SourceList then
 | 
				
			||||||
   for _,Source in ipairs(tl.SourceList) do
 | 
					   for _,Source in ipairs(tl.SourceList) do
 | 
				
			||||||
      if keys[Source.Key] then
 | 
					      if keys[Source.Key] then
 | 
				
			||||||
 | 
					         Report(ChannelCount,Source.Title)
 | 
				
			||||||
         print("Scanning: "..Source.Title)
 | 
					         print("Scanning: "..Source.Title)
 | 
				
			||||||
         local SourceOptions = ""
 | 
					         local SourceOptions = ""
 | 
				
			||||||
         if Source.UseNIT then
 | 
					         if Source.UseNIT then
 | 
				
			||||||
@@ -162,7 +177,7 @@ if tl.SourceList then
 | 
				
			|||||||
                        end
 | 
					                        end
 | 
				
			||||||
                        print(line)
 | 
					                        print(line)
 | 
				
			||||||
                        if line == "END" then
 | 
					                        if line == "END" then
 | 
				
			||||||
                           local all_pids = ",0"
 | 
					                           local all_pids = "0"
 | 
				
			||||||
                           if include_sitables then
 | 
					                           if include_sitables then
 | 
				
			||||||
                              if isencrypted then
 | 
					                              if isencrypted then
 | 
				
			||||||
                                 all_pids = all_pids..",1"
 | 
					                                 all_pids = all_pids..",1"
 | 
				
			||||||
@@ -170,17 +185,19 @@ if tl.SourceList then
 | 
				
			|||||||
                              all_pids = all_pids..",16,17,18,20"
 | 
					                              all_pids = all_pids..",16,17,18,20"
 | 
				
			||||||
                           end
 | 
					                           end
 | 
				
			||||||
                           if #pids > 0 then
 | 
					                           if #pids > 0 then
 | 
				
			||||||
                              all_pids = all_pids .. ",pids"
 | 
					                              all_pids = all_pids..","..pids
 | 
				
			||||||
                           end
 | 
					                           end
 | 
				
			||||||
                           local channel = { Title=sname, Service=sid, Request = '?'..Request.."&pids="..pids, Tracks=tracks }
 | 
					                           local channel = { Title=sname, Service=sid, Request = '?'..Request.."&pids="..all_pids, Tracks=tracks }
 | 
				
			||||||
                           local gname = pname
 | 
					                           local gname = pname
 | 
				
			||||||
                           if isradio then
 | 
					                           if isradio then
 | 
				
			||||||
                              gname = "Radio - "..gname
 | 
					                              gname = "Radio - "..gname
 | 
				
			||||||
                           end
 | 
					                           end
 | 
				
			||||||
                           if not isradio or (include_radio > 0) then
 | 
					                           if (not isradio or (include_radio > 0)) and (not isencrypted or (include_encrypted > 0)) then
 | 
				
			||||||
                              local group = GetGroup(ChannelList,gname)
 | 
					                              local group = GetGroup(ChannelList,gname)
 | 
				
			||||||
                              if group then
 | 
					                              if group then
 | 
				
			||||||
                                 table.insert(group.ChannelList,channel)
 | 
					                                 table.insert(group.ChannelList,channel)
 | 
				
			||||||
 | 
					                                 ChannelCount = ChannelCount + 1
 | 
				
			||||||
 | 
					                                 Report(ChannelCount,sname)
 | 
				
			||||||
                              end
 | 
					                              end
 | 
				
			||||||
                           end
 | 
					                           end
 | 
				
			||||||
                           break
 | 
					                           break
 | 
				
			||||||
@@ -238,3 +255,9 @@ if tl.SourceList then
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					os.execute("mv /tmp/doscan.lock/doscan.msg /tmp/doscan.msg")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if restart_dms then
 | 
				
			||||||
 | 
					   os.execute("/etc/init.d/S92dms restart")
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					os.execute("rm -rf /tmp/doscan.lock");
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,13 +6,192 @@
 | 
				
			|||||||
<link rel="stylesheet" type="text/css" href="/style.css">
 | 
					<link rel="stylesheet" type="text/css" href="/style.css">
 | 
				
			||||||
<script type="text/javascript" src="/menu.js"></script>
 | 
					<script type="text/javascript" src="/menu.js"></script>
 | 
				
			||||||
<!--  Add included scripts here -->
 | 
					<!--  Add included scripts here -->
 | 
				
			||||||
 | 
					<script type="text/javascript" src="/systeminfo.lua"></script>
 | 
				
			||||||
 | 
					<script type="text/javascript">Octoserve = false;</script>
 | 
				
			||||||
 | 
					<script type="text/javascript" src="/octoserve/serverinfo.js"></script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<!-- Add page scripts here -->
 | 
					<!-- Add page scripts here -->
 | 
				
			||||||
<script type="text/javascript">
 | 
					<script type="text/javascript">
 | 
				
			||||||
 | 
					var hasCable = false;
 | 
				
			||||||
 | 
					var hasSat = false;
 | 
				
			||||||
 | 
					var hasTer = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var xmlhttp = new XMLHttpRequest();
 | 
				
			||||||
 | 
					var url = "/channelscan.lua?select=keys";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					xmlhttp.onreadystatechange=function()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (xmlhttp.readyState == 4 )
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      if( xmlhttp.status == 200 )
 | 
				
			||||||
 | 
					         myFunction(xmlhttp.responseText);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function myFunction(response)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   var kl = JSON.parse(response);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   document.Cable.Select.length = 0;
 | 
				
			||||||
 | 
					   document.Satellite1.Select.length = 0;
 | 
				
			||||||
 | 
					   document.Satellite2.Select.length = 0;
 | 
				
			||||||
 | 
					   document.Satellite3.Select.length = 0;
 | 
				
			||||||
 | 
					   document.Satellite4.Select.length = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   document.Cable.Select.options[0] = (new Option("-", null, false, true) );
 | 
				
			||||||
 | 
					   document.Satellite1.Select.options[0] = (new Option("-", null, false, true) );
 | 
				
			||||||
 | 
					   document.Satellite2.Select.options[0] = (new Option("-", null, false, true) );
 | 
				
			||||||
 | 
					   document.Satellite3.Select.options[0] = (new Option("-", null, false, true) );
 | 
				
			||||||
 | 
					   document.Satellite4.Select.options[0] = (new Option("-", null, false, true) );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   var iCable = 1;
 | 
				
			||||||
 | 
					   var iSat = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   for(var i = 0; i < kl.KeyList.length; i++)
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					      if( (hasCable && kl.KeyList[i].DVBType.indexOf("C") >= 0) ||
 | 
				
			||||||
 | 
					          (hasTer   && kl.KeyList[i].DVBType.indexOf("T") >= 0) )
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					         var Select = (kl.KeyList[i].Key == "UM");
 | 
				
			||||||
 | 
					         document.Cable.Select.options[iCable] = (new Option(kl.KeyList[i].Title, kl.KeyList[i].Key, false, Select) );
 | 
				
			||||||
 | 
					         iCable += 1;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      if( (hasSat && kl.KeyList[i].DVBType.indexOf("S") >= 0) )
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					         var Select = (kl.KeyList[i].Key == "0192");
 | 
				
			||||||
 | 
					         document.Satellite1.Select.options[iSat] = (new Option(kl.KeyList[i].Title, kl.KeyList[i].Key, false, Select) );
 | 
				
			||||||
 | 
					         document.Satellite2.Select.options[iSat] = (new Option(kl.KeyList[i].Title, kl.KeyList[i].Key, false, false) );
 | 
				
			||||||
 | 
					         document.Satellite3.Select.options[iSat] = (new Option(kl.KeyList[i].Title, kl.KeyList[i].Key, false, false) );
 | 
				
			||||||
 | 
					         document.Satellite4.Select.options[iSat] = (new Option(kl.KeyList[i].Title, kl.KeyList[i].Key, false, false) );
 | 
				
			||||||
 | 
					         iSat += 1;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   if( iCable > 1 )
 | 
				
			||||||
 | 
					      document.getElementById("trCable").style.display = "table-row";
 | 
				
			||||||
 | 
					   if( iSat > 1 )
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					      document.getElementById("trSat1").style.display = "table-row";
 | 
				
			||||||
 | 
					      document.getElementById("trSat2").style.display = "table-row";
 | 
				
			||||||
 | 
					      document.getElementById("trSat3").style.display = "table-row";
 | 
				
			||||||
 | 
					      document.getElementById("trSat4").style.display = "table-row";
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function SetSource(Src,SourceIndex)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function OnLoad()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   for(var i = 0; i < Octoserve.TunerList.length; i++ )
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					      if( Octoserve.TunerList[i] )
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					         if( Octoserve.TunerList[i].Desc.indexOf("C/T") >= 0 ) hasCable = true;
 | 
				
			||||||
 | 
					         if( Octoserve.TunerList[i].Desc.indexOf("C/C2") >= 0 ) hasCable = true;
 | 
				
			||||||
 | 
					         if( Octoserve.TunerList[i].Desc.indexOf("S/S2") >= 0 ) hasSat = true;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					   // TODO: differentiate between dvbc and dvbt
 | 
				
			||||||
 | 
					   hasTer = hasCable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   xmlhttp.open("GET", url, true);
 | 
				
			||||||
 | 
					   xmlhttp.send();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var ScanReq = new XMLHttpRequest();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ScanReq.onreadystatechange=function()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (ScanReq.readyState == 4 )
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      if( ScanReq.status == 200 )
 | 
				
			||||||
 | 
					         ScanStatus(ScanReq.responseText);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function GetStatus()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   ScanReq.open("GET", "/channelscan.lua?select=status", true);
 | 
				
			||||||
 | 
					   ScanReq.send();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function ScanStatus(response)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   var s = JSON.parse(response);
 | 
				
			||||||
 | 
					   if( s.status == "active" )
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					      document.getElementById("scancount").firstChild.nodeValue = s.count;
 | 
				
			||||||
 | 
					      document.getElementById("scantext").firstChild.nodeValue = s.msg;
 | 
				
			||||||
 | 
					      window.setTimeout(GetStatus,500);
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					   else if( s.status == "busy" )
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					      document.getElementById("scancount").firstChild.nodeValue = "";
 | 
				
			||||||
 | 
					      document.getElementById("scantext").firstChild.nodeValue = "BUSY";
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					   else if( s.status == "done" )
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					      document.getElementById("scancount").firstChild.nodeValue = s.count;
 | 
				
			||||||
 | 
					      document.getElementById("scantext").firstChild.nodeValue = "Channels found";
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					   else
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					      window.setTimeout(GetStatus,500);
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function InitiateScan()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   var param = "";
 | 
				
			||||||
 | 
					   for(var i = 1; i < document.Cable.Select.options.length; i += 1)
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					      if( document.Cable.Select.options[i].selected )
 | 
				
			||||||
 | 
					         param = param + "&key=" + document.Cable.Select.options[i].value;
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					   for(var i = 1; i < document.Satellite1.Select.options.length; i += 1)
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					      if( document.Satellite1.Select.options[i].selected )
 | 
				
			||||||
 | 
					         param = param + "&key=" + document.Satellite1.Select.options[i].value + ".1";
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					   for(var i = 1; i < document.Satellite2.Select.options.length; i += 1)
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					      if( document.Satellite2.Select.options[i].selected )
 | 
				
			||||||
 | 
					         param = param + "&key=" + document.Satellite2.Select.options[i].value + ".2";
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					   for(var i = 1; i < document.Satellite3.Select.options.length; i += 1)
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					      if( document.Satellite3.Select.options[i].selected )
 | 
				
			||||||
 | 
					         param = param + "&key=" + document.Satellite3.Select.options[i].value + ".3";
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					   for(var i = 1; i < document.Satellite4.Select.options.length; i += 1)
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					      if( document.Satellite4.Select.options[i].selected )
 | 
				
			||||||
 | 
					         param = param + "&key=" + document.Satellite4.Select.options[i].value + ".4";
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   if( param != "" )
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					      ScanReq.open("GET", "/channelscan.lua?select=scan" + param + "&sitables=1&sort=1&restartdms=1", true);
 | 
				
			||||||
 | 
					      ScanReq.send();
 | 
				
			||||||
 | 
					      document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
 | 
				
			||||||
 | 
					      document.getElementById("scantext").firstChild.nodeValue = "Scanning...";
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					   else
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					      document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
 | 
				
			||||||
 | 
					      document.getElementById("scantext").firstChild.nodeValue = "\u00A0";
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
<body>
 | 
					<body onload="OnLoad()">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<table class="maintable" align="center">
 | 
					<table class="maintable" align="center">
 | 
				
			||||||
  <colgroup>
 | 
					  <colgroup>
 | 
				
			||||||
@@ -28,6 +207,71 @@
 | 
				
			|||||||
    <td class="content">
 | 
					    <td class="content">
 | 
				
			||||||
      <div>
 | 
					      <div>
 | 
				
			||||||
        <!-- Begin Content -->
 | 
					        <!-- Begin Content -->
 | 
				
			||||||
 | 
					        <table cellpadding="2px" align="center">
 | 
				
			||||||
 | 
					          <tr id="trCable" style="display:none">
 | 
				
			||||||
 | 
					            <td>Cable</td>
 | 
				
			||||||
 | 
					            <td style="text-align:right">
 | 
				
			||||||
 | 
					              <form name="Cable" action="">
 | 
				
			||||||
 | 
					                <select name="Select" size="1" style="width: 300px" onchange="SetSource(0,document.Cable.Select.selectedIndex)" >
 | 
				
			||||||
 | 
					                </select>
 | 
				
			||||||
 | 
					              </form>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					          </tr>
 | 
				
			||||||
 | 
					          <tr id="trSat1" style="display:none">
 | 
				
			||||||
 | 
					            <td>Satellite 1</td>
 | 
				
			||||||
 | 
					            <td style="text-align:right">
 | 
				
			||||||
 | 
					              <form name="Satellite1" action="">
 | 
				
			||||||
 | 
					                <select name="Select" size="1" style="width: 300px" onchange="SetSource(1,document.Satellite1.Select.selectedIndex)" >
 | 
				
			||||||
 | 
					                </select>
 | 
				
			||||||
 | 
					              </form>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					          </tr>
 | 
				
			||||||
 | 
					          <tr id="trSat2" style="display:none">
 | 
				
			||||||
 | 
					            <td>Satellite 2</td>
 | 
				
			||||||
 | 
					            <td style="text-align:right">
 | 
				
			||||||
 | 
					              <form name="Satellite2" action="">
 | 
				
			||||||
 | 
					                <select name="Select" size="1" style="width: 300px" onchange="SetSource(2,document.Satellite2.Select.selectedIndex)" >
 | 
				
			||||||
 | 
					                </select>
 | 
				
			||||||
 | 
					              </form>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					          </tr>
 | 
				
			||||||
 | 
					          <tr id="trSat3" style="display:none">
 | 
				
			||||||
 | 
					            <td>Satellite 3</td>
 | 
				
			||||||
 | 
					            <td style="text-align:right">
 | 
				
			||||||
 | 
					              <form name="Satellite3" action="">
 | 
				
			||||||
 | 
					                <select name="Select" size="1" style="width: 300px" onchange="SetSource(3,document.Satellite3.Select.selectedIndex)" >
 | 
				
			||||||
 | 
					                </select>
 | 
				
			||||||
 | 
					              </form>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					          </tr>
 | 
				
			||||||
 | 
					          <tr id="trSat4" style="display:none">
 | 
				
			||||||
 | 
					            <td>Satellite 4</td>
 | 
				
			||||||
 | 
					            <td style="text-align:right">
 | 
				
			||||||
 | 
					              <form name="Satellite4" action="">
 | 
				
			||||||
 | 
					                <select name="Select" size="1" style="width: 300px" onchange="SetSource(4,document.Satellite4.Select.selectedIndex)" >
 | 
				
			||||||
 | 
					                </select>
 | 
				
			||||||
 | 
					              </form>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					          </tr>
 | 
				
			||||||
 | 
					          <tr>
 | 
				
			||||||
 | 
					            <td> </td>
 | 
				
			||||||
 | 
					            <td style="text-align:right">
 | 
				
			||||||
 | 
					               <form action="">
 | 
				
			||||||
 | 
					                 <input type="Button" value="Start Scan" onclick="InitiateScan()" >
 | 
				
			||||||
 | 
					               </form>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					          </tr>
 | 
				
			||||||
 | 
					          <tr>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					               <div id="scancount" style="text-align:right"> </div>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					               <div id="scantext" style="text-align:left"> </div>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					          </tr>
 | 
				
			||||||
 | 
					        </table>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <hr/>
 | 
				
			||||||
        <table cellpadding="2px" align="center">
 | 
					        <table cellpadding="2px" align="center">
 | 
				
			||||||
          <tr>
 | 
					          <tr>
 | 
				
			||||||
            <td>System Channel Database</td>
 | 
					            <td>System Channel Database</td>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										135
									
								
								octoserve/var/www/channelscan.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										135
									
								
								octoserve/var/www/channelscan.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,135 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/lua
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local host = os.getenv("HTTP_HOST")
 | 
				
			||||||
 | 
					local proto = os.getenv("SERVER_PROTOCOL")
 | 
				
			||||||
 | 
					local query = os.getenv("QUERY_STRING")
 | 
				
			||||||
 | 
					local method = os.getenv("REQUEST_METHOD")
 | 
				
			||||||
 | 
					local clength = os.getenv("CONTENT_LENGTH")
 | 
				
			||||||
 | 
					local ctype = os.getenv("CONTENT_TYPE")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function http_print(s)
 | 
				
			||||||
 | 
					  if s then
 | 
				
			||||||
 | 
					    io.stdout:write(tostring(s).."\r\n")
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    io.stdout:write("\r\n")
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if #arg> 0 then
 | 
				
			||||||
 | 
					  method="GET"
 | 
				
			||||||
 | 
					  query=arg[1]
 | 
				
			||||||
 | 
					  proto = "HTTP/1.0"
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function SendError(err,desc)
 | 
				
			||||||
 | 
					  http_print(proto.." "..err)
 | 
				
			||||||
 | 
					  http_print("Content-Type: text/html")
 | 
				
			||||||
 | 
					  http_print()
 | 
				
			||||||
 | 
					  local file = io.open("e404.html")
 | 
				
			||||||
 | 
					  if file then
 | 
				
			||||||
 | 
					    local tmp = file:read("*a")
 | 
				
			||||||
 | 
					    tmp = string.gsub(tmp,"404 Not Found",err .. " " .. desc)
 | 
				
			||||||
 | 
					    http_print(tmp)
 | 
				
			||||||
 | 
					    file:close()
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					local newdecoder = require("lunajson.decoder")
 | 
				
			||||||
 | 
					local newencoder = require("lunajson.encoder")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local function LoadTransponderList()
 | 
				
			||||||
 | 
					   local tl = nil
 | 
				
			||||||
 | 
					   local f = nil
 | 
				
			||||||
 | 
					   f = io.open("/config/TransponderList.json","r")
 | 
				
			||||||
 | 
					   if not f then
 | 
				
			||||||
 | 
					      f = io.open("/var/channels/TransponderList.json","r")
 | 
				
			||||||
 | 
					   end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   if f then
 | 
				
			||||||
 | 
					      local t = f:read("*a")
 | 
				
			||||||
 | 
					      f:close()
 | 
				
			||||||
 | 
					      local decode = newdecoder()
 | 
				
			||||||
 | 
					      tl = decode(t)
 | 
				
			||||||
 | 
					   end
 | 
				
			||||||
 | 
					   return tl
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if method == "GET" then
 | 
				
			||||||
 | 
					  local filename = nil
 | 
				
			||||||
 | 
					  local contenttype = "application/json; charset=utf-8"
 | 
				
			||||||
 | 
					  local data = nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  local q,v
 | 
				
			||||||
 | 
					  local params = ""
 | 
				
			||||||
 | 
					  local cmd = ""
 | 
				
			||||||
 | 
					  for q,v in query:gmatch("(%a+)=([%w%.]+)") do
 | 
				
			||||||
 | 
					      if q == "select" then
 | 
				
			||||||
 | 
					         cmd = v
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					         params = params.." "..q.."="..v
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if cmd == "keys" then
 | 
				
			||||||
 | 
					      local tl = LoadTransponderList()
 | 
				
			||||||
 | 
					      if tl then
 | 
				
			||||||
 | 
					         local kl = { KeyList = { } }
 | 
				
			||||||
 | 
					         local s
 | 
				
			||||||
 | 
					         for _,s in ipairs(tl.SourceList) do
 | 
				
			||||||
 | 
					            table.insert(kl.KeyList, { Key=s.Key,Title=s.Title,DVBType=s.DVBType })
 | 
				
			||||||
 | 
					         end
 | 
				
			||||||
 | 
					         kl.KeyList[0] = #kl.KeyList
 | 
				
			||||||
 | 
					         local encode = newencoder()
 | 
				
			||||||
 | 
					         data = encode(kl)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					  elseif cmd == "scan" then
 | 
				
			||||||
 | 
					      local rc = os.execute("mkdir /tmp/doscan.lock")
 | 
				
			||||||
 | 
					      if rc ~= 0 then
 | 
				
			||||||
 | 
					         data = '{"status":"busy"}'
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					         data = '{"status":"retry"}'
 | 
				
			||||||
 | 
					         os.execute("/var/channels/doscan.lua "..params.." >/tmp/doscan.log 2>&1 &")
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					   elseif cmd == "status" then
 | 
				
			||||||
 | 
					      local js = { }
 | 
				
			||||||
 | 
					      local f = io.open("/tmp/doscan.lock/doscan.msg")
 | 
				
			||||||
 | 
					      if f then
 | 
				
			||||||
 | 
					         js.status = "active"
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					         f = io.open("/tmp/doscan.msg")
 | 
				
			||||||
 | 
					         if f then
 | 
				
			||||||
 | 
					            js.status = "done"
 | 
				
			||||||
 | 
					         else
 | 
				
			||||||
 | 
					            js.status = "retry"
 | 
				
			||||||
 | 
					         end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      if f then
 | 
				
			||||||
 | 
					         local m = f:read("*l")
 | 
				
			||||||
 | 
					         local count,msg = m:match("(%d+):(.*)")
 | 
				
			||||||
 | 
					         js.count = count
 | 
				
			||||||
 | 
					         js.msg = msg
 | 
				
			||||||
 | 
					         f:close()
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      local encode = newencoder()
 | 
				
			||||||
 | 
					      data = encode(js)
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if data then
 | 
				
			||||||
 | 
					    http_print(proto.." 200" )
 | 
				
			||||||
 | 
					    http_print("Pragma: no-cache")
 | 
				
			||||||
 | 
					    http_print("Cache-Control: no-cache")
 | 
				
			||||||
 | 
					    http_print("Content-Type: "..contenttype)
 | 
				
			||||||
 | 
					    if filename then
 | 
				
			||||||
 | 
					      http_print('Content-Disposition: filename="'..filename..'"')
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    http_print(string.format("Content-Length: %d",#data))
 | 
				
			||||||
 | 
					    http_print()
 | 
				
			||||||
 | 
					    http_print(data)
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    SendError("404","not found")
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					  SendError("500","What")
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
		Reference in New Issue
	
	Block a user