This file is indexed.

/usr/share/freevo/htdocs/guidechannel.rpy is in freevo 1.9.2b2-4.2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# -*- coding: iso-8859-1 -*-
# vim:autoindent:tabstop=4:softtabstop=4:shiftwidth=4:expandtab:filetype=python:
# -----------------------------------------------------------------------
# Web interface to the Freevo EPG.
# -----------------------------------------------------------------------
# $Id: guidechannel.rpy 11648 2010-01-28 11:10:58Z duncan $
#
# Notes:
# Todo:
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------

import sys, string
import time
import datetime

from twisted.web import static

import util.tv_util as tv_util
import util
import config
import tv.epg_xmltv
from www.web_types import HTMLResource, FreevoResource, RecordClientResource
from www.configlib import *

DEBUG = 0

TRUE = 1
FALSE = 0

class GuideResource(FreevoResource):
    def __init__(self):
        self.recordclient = RecordClientResource()


    def GetChannelList(self, guide):
        clist = []
        for dchan in guide.chan_list:
            clist.append(dchan.displayname)
        return clist


    def TimeBooked(self, prog):
        bookedtime = False
        for schedule_prog in self.schedule.getProgramList().values():
            if  prog.start >= schedule_prog.start and prog.start < schedule_prog.stop:
                bookedtime = True, schedule_prog
        if not bookedtime:
            schedule_prog = None
        return bookedtime, schedule_prog


    def GetChannel(self, display_channel, guide):
        for dchan in guide.chan_list:
            if display_channel == dchan.displayname:
                chan = dchan
        return chan


    def CreateChannelLine(self, prog):
        status = "programline"

        bookedtime, sch_prog = self.TimeBooked(prog)
        program_tip = ''
        if bookedtime:
            status = 'programtimebooked'
            program_tip = 'Scheduled Program : %s' %  Unicode(sch_prog.sub_title)

        if self.got_schedule:
            (result, reason) = self.recordclient().isProgScheduledNow(prog, self.schedule)
            if result:
                status = 'programlinerecord'
                if self.currenttime > prog.start  and self.currenttime < prog.stop:
                    status = 'programlinerecording'

        channel_line = ''
        cell = ''
        cell += '%s' % prog.title
        popid = '%s:%s' % (prog.channel_id, prog.start)
        pstarttime = time.localtime(prog.start)
        pstart = time.strftime(config.TV_TIME_FORMAT, pstarttime)
        channel_line += '<li id="%s">\n' % status
        channel_line += '<a id="%s" name="%s" onclick="guide_click(this, event)"> %s %s </a>\n' % \
            (popid, program_tip, pstart, cell)
        channel_line += '<ul>\n'
        channel_line += '<li id="description">\n'
        if not prog.desc:
            channel_line += 'No Program Data'
        else:
            channel_line += '%s' % prog.desc
        channel_line  += '</li>\n'
        channel_line += '<li>%s</li>' % program_tip
        channel_line += '</ul>\n'
        channel_line += '</li>\n'
        return channel_line


    def BookTimeDiv():
        html = ''
        html += (
        u"<div id=\"popup\" class=\"proginfo\" style=\"display:none\">\n"\
        u"<div id=\"program-waiting\" style=\"background-color: #0B1C52; position: absolute\">\n"\
        u"  <br /><b>Fetching program information ...</b>\n"\
        u"</div>\n"\
        u"   <table id=\"program-info\" class=\"popup\">\n"\
        u"      <thead>\n"\
        u"         <tr>\n"\
        u"            <td id=\"program-title\">\n"\
        u"            </td>\n"\
        u"         </tr>\n"\
        u"      </thead>\n"\
        u"      <tbody>\n"\
        u"         <tr>\n"\
        u"            <td class=\"progdesc\" id=\"program-desc\">\n"\
        u"            </td>\n"\
        u"         </tr>\n"\
        u"         <tr>\n"\
        u"         <td class=\"progtime\">\n"\
        u"            <b>"+_('Start')+u":</b> <span id=\"program-start\"></span>, \n"\
        u"            <b>"+_('Stop')+u":</b> <span id=\"program-end\"></span>, \n"\
        u"            <b>"+_('Runtime')+u":</b> <span id=\"program-runtime\"></span> min\n"\
        u"            </td>\n"\
        u"         </td>\n"\
        u"      </tbody>\n"\
        u"      <tfoot>\n"\
        u"         <tr>\n"\
        u"            <td>\n"\
        u"               <table class=\"popupbuttons\">\n"\
        u"                  <tbody>\n"\
        u"                     <tr>\n"\
        u"                        <td onclick=\"program_popup_close();\">\n"\
        u"                        "+_('Close Window')+u"\n"\
        u"                        </td>\n"\
        u"                     </tr>\n"\
        u"                  </tbody>\n"\
        u"               </table>\n"\
        u"            </td>\n"\
        u"         </tr>\n"\
        u"      </tfoot>\n"\
        u"   </table>\n"\
        u"</div>\n" )
        html += "<iframe id='bookedhidden' style='visibility: hidden; width: 1px; height: 1px'></iframe>\n"
        return html


    def GetChannelPrograms(self, channel):
        channel_programs = '<ul id="daylistcontainer">\n'
        current_day =''

        for prog in channel.programs:

            if prog.stop > self.currenttime:
#                if self.TimeBooked(prog):

                if time.strftime('%b %d (%a)', time.localtime(prog.start)) <> current_day:
                    if current_day <> '':
                        channel_programs += '</ul>\n'
                        channel_programs += '</li>\n'

                    current_day = time.strftime('%b %d (%a)', time.localtime(prog.start))
                    js_onclick = "ShowList('%s')" % current_day
                    channel_programs += '<li id="dayline">\n'
                    channel_programs += '<a onclick="%s" id="current">%s</a>\n' % (js_onclick, current_day)
                    channel_programs += '<ul id="%s" class="subnavlist">\n' % (current_day)
                channel_programs += self.CreateChannelLine(prog)


        channel_programs += '</ul>\n'
        return channel_programs


    def _render(self, request):
        fv = HTMLResource()
        form = request.args

        self.guide = tv.epg_xmltv.get_guide()
        (self.got_schedule, self.schedule) = self.recordclient().getScheduledRecordingsNow()
        self.currenttime = time.time()

        fv.printHeader(_('TV Guide'), config.WWW_STYLESHEET, config.WWW_JAVASCRIPT, selected=_('TV Guide'))
        fv.res += '<link rel="stylesheet" href="styles/guidechannel.css" type="text/css" media="screen">\n'
        fv.res += '<div id="content">\n';
        fv.res += '&nbsp;<br/>\n'

        if not self.got_schedule:
            fv.printMessages([ '<b>'+_('ERROR')+'</b>: '+_('Recording server is not available') ])

        display_channel = fv.formValue(form, 'channel')
        if not display_channel:
            display_channel = self.guide.chan_list[0].displayname
        clist = []

        getprogramlist = fv.formValue(form, 'getprogramlist')
        if getprogramlist:
            chan = self.GetChannel(getprogramlist, self.guide)
            fv.res = self.GetChannelPrograms(chan)
            return String(fv.res)

        dchan = self.GetChannel(display_channel, self.guide)
        fv.res += '<script language="JavaScript" type="text/JavaScript" src="scripts/guidechannel.js"></script>\n'
        js_onclick = "ChangeChannel(this)"
        ctrl_opts = 'onchange="%s"' % js_onclick
        clist = self.GetChannelList(self.guide)
        fv.res += CreateSelectBoxControl('channel', clist, display_channel, ctrl_opts)

        if not dchan.programs:
            fv.res += 'This channel has no data loaded\n'

        channel_programs = self.GetChannelPrograms(dchan)
        fv.res += '<div id="ProgramList">\n'
        fv.res += channel_programs
        fv.res += '</div>\n'

        fv.printSearchForm()
        fv.printLinks()
        fv.res += '</div>\n'
        fv.res += (
            u"<div id=\"popup\" class=\"proginfo\" style=\"display:none\">\n"\
            u"<div id=\"program-waiting\" style=\"background-color: #0B1C52; position: absolute\">\n"\
            u"  <br /><b>Fetching program information ...</b>\n"\
            u"</div>\n"\
            u"   <table id=\"program-info\" class=\"popup\">\n"\
            u"      <thead>\n"\
            u"         <tr>\n"\
            u"            <td id=\"program-title\">\n"\
            u"            </td>\n"\
            u"         </tr>\n"\
            u"      </thead>\n"\
            u"      <tbody>\n"\
            u"         <tr>\n"\
            u"            <td class=\"progdesc\" id=\"program-desc\">\n"\
            u"            </td>\n"\
            u"         </tr>\n"\
            u"         <tr>\n"\
            u"         <td class=\"progtime\">\n"\
            u"            <b>"+_('Start')+u":</b> <span id=\"program-start\"></span>,\n"\
            u"            <b>"+_('Stop')+u":</b> <span id=\"program-end\"></span>,\n"\
            u"            <b>"+_('Runtime')+u":</b> <span id=\"program-runtime\"></span> min\n"\
            u"            </td>\n"\
            u"         </td>\n"\
            u"      </tbody>\n"\
            u"      <tfoot>\n"\
            u"         <tr>\n"\
            u"            <td>\n"\
            u"               <table class=\"popupbuttons\">\n"\
            u"                  <tbody>\n"\
            u"                     <tr>\n"\
            u"                        <td id=\"program-record-button\">\n"\
            u"                           "+_('Record')+u"\n"\
            u"                        </td>\n"\
            u"                        <td id=\"program-favorites-button\">\n"\
            u"                        "+_('Add to Favorites')+u"\n"\
            u"                        </td>\n"\
            u"                        <td onclick=\"program_popup_close();\">\n"\
            u"                        "+_('Close Window')+u"\n"\
            u"                        </td>\n"\
            u"                     </tr>\n"\
            u"                  </tbody>\n"\
            u"               </table>\n"\
            u"            </td>\n"\
            u"         </tr>\n"\
            u"      </tfoot>\n"\
            u"   </table>\n"\
            u"</div>\n" )
        fv.res += "<iframe id='hidden' style='visibility: hidden; width: 1px; height: 1px'></iframe>\n"
        fv.printFooter()

        return String( fv.res )


resource = GuideResource()