Permalink
Browse files

Changed indexes to start at 1 not 0.

  • Loading branch information...
1 parent c7881e2 commit 98090ed8e5aa3fc2c004f68d7b5cb9775af80ba4 @zane131 committed Mar 24, 2012
Showing with 40 additions and 28 deletions.
  1. +29 −17 mythroku/xml_data.php
  2. +11 −11 mythroku/xml_utils.php
View
@@ -19,8 +19,11 @@ function get_xml_data()
$sort = '';
if ( isset($_GET['sort']) ) { $sort = $_GET['sort']; }
- $start_row = 0;
- if ( isset($_GET['index']) ) { $start_row = $_GET['index']; }
+ $start_row = 1;
+ if ( isset($_GET['index']) and (0 < $_GET['index']) )
+ {
+ $start_row = $_GET['index'];
+ }
$test = false;
if ( isset($_GET['test']) ) { $test = true; }
@@ -45,10 +48,17 @@ function get_xml_data()
$sql_result = mysql_query($SQL);
$total_rows = mysql_num_rows($sql_result);
+ // Check boundry limits
+ if ( $total_rows < $start_row )
+ {
+ $start_row = $total_rows;
+ $_GET['index'] = $start_row;
+ }
+
// Limit the number results
if ( 0 !== $ResultLimit )
{
- $SQL .= " LIMIT $start_row, $ResultLimit";
+ $SQL .= " LIMIT " . ($start_row - 1) . ", $ResultLimit";
// Get the subset results
$sql_result = mysql_query($SQL);
@@ -182,16 +192,16 @@ function build_xml_vid( $sql_result, $index )
'title' => html_cleanup($db_field['title']),
'subtitle' => html_cleanup($db_field['subtitle']),
'synopsis' => html_cleanup($db_field['plot']),
- 'hdImg' => "$MythRokuDir/image.php?image=$hdimg",
- 'sdImg' => "$MythRokuDir/image.php?image=$sdimg",
+ 'hdImg' => "$MythRokuDir/image.php?image=" . html_cleanup($hdimg),
+ 'sdImg' => "$MythRokuDir/image.php?image=" . html_cleanup($sdimg),
'streamBitrate' => 0,
'streamUrl' => "$mythtvdata/video/" . html_encode($filename),
'streamQuality' => $quality,
- 'streamContentId' => $filename,
+ 'streamContentId' => html_cleanup($filename),
'streamFormat' => pathinfo($filename, PATHINFO_EXTENSION),
'isHD' => $isHD,
- 'episode' => $episode,
- 'genres' => $genre,
+ 'episode' => html_cleanup($episode),
+ 'genres' => html_cleanup($genre),
'runtime' => $db_field['length'] * 60,
'date' => date("m/d/Y", convert_date($db_field['releasedate'])),
'starRating' => $db_field['userrating'] * 10,
@@ -222,6 +232,8 @@ function build_xml_rec( $sql_result, $index )
$str_time = convert_datetime($db_field['starttime']);
$end_time = convert_datetime($db_field['endtime']);
+ $chanid_strtime = "{$db_field['chanid']}/$str_time";
+
$contentType = "movie";
$episode = "";
if ( 'series' == $db_field['category_type'] )
@@ -230,7 +242,7 @@ function build_xml_rec( $sql_result, $index )
$episode = $db_field['syndicatedepisodenumber'];
}
- $img = "{$db_field['hostname']}/{$db_field['chanid']}/$str_time";
+ $img = "{$db_field['hostname']}/$chanid_strtime";
$hdimg = "$img/100/56/-1/$filename.100x56x-1.png";
$sdimg = "$img/100/75/-1/$filename.100x75x-1.png";
@@ -239,30 +251,28 @@ function build_xml_rec( $sql_result, $index )
# if ( '0' !== $db_field['hdtv'] ) { $quality = 'HD'; }
if ( 'HD' == $quality ) { $isHD = 'true'; }
- $url = "$WebServer/pl/stream/{$db_field['chanid']}/$str_time";
-
$args = array(
'contentType' => $contentType,
'title' => html_cleanup($db_field['title']),
'subtitle' => html_cleanup($db_field['subtitle']),
'synopsis' => html_cleanup($db_field['description']),
- 'hdImg' => "$WebServer/tv/get_pixmap/$hdimg",
- 'sdImg' => "$WebServer/tv/get_pixmap/$sdimg",
+ 'hdImg' => "$WebServer/tv/get_pixmap/" . html_cleanup($hdimg),
+ 'sdImg' => "$WebServer/tv/get_pixmap/" . html_cleanup($sdimg),
'streamBitrate' => 0,
- 'streamUrl' => $url,
+ 'streamUrl' => "$WebServer/pl/stream/" . html_encode($chanid_strtime),
'streamQuality' => $quality,
- 'streamContentId' => $filename,
+ 'streamContentId' => html_cleanup($filename),
'streamFormat' => pathinfo($filename, PATHINFO_EXTENSION),
'isHD' => $isHD,
- 'episode' => $episode,
+ 'episode' => html_cleanup($episode),
'genres' => html_cleanup($db_field['category']),
'runtime' => $end_time - $str_time,
'date' => date("m/d/Y h:ia", $str_time),
'starRating' => 0,
'rating' => '',
'index' => $index,
'isRecording' => 'true',
- 'delCmd' => "$MythRokuDir/mythtv_tv_del.php?basename=$filename"
+ 'delCmd' => "$MythRokuDir/mythtv_tv_del.php?basename=" . html_encode($filename)
);
$xml .= xml_file( $args );
@@ -295,6 +305,8 @@ function convert_datetime( $datetime )
return $timestamp;
}
+//------------------------------------------------------------------------------
+
function html_cleanup($str)
{
return htmlspecialchars( preg_replace('/[^(\x20-\x7F)]*/', '', $str) );
View
@@ -24,6 +24,8 @@ function xml_end_feed()
}
+//------------------------------------------------------------------------------
+
function xml_file( $args )
{
return <<<EOF
@@ -75,26 +77,24 @@ function xml_dir( $args )
}
+//------------------------------------------------------------------------------
+
function xml_start_dir( $args )
{
$xml_output = '';
require 'settings.php';
- if ( 0 < $args['start_row'] )
+ if ( 1 < $args['start_row'] )
{
$startIndex = $args['start_row'] - $ResultLimit;
- if ( 0 > $startIndex )
+ if ( 1 > $startIndex )
{
- $startIndex = 0;
+ $startIndex = 1;
}
$args['html_parms']['index'] = $startIndex;
- $endIndex = $startIndex + $ResultLimit - 1;
- if ( $endIndex >= $args['start_row'] )
- {
- $endIndex = $args['start_row'] - 1;
- }
+ $endIndex = $args['start_row'] - 1;
$title = ( $startIndex == $endIndex )
? "Index $startIndex"
@@ -123,7 +123,7 @@ function xml_end_dir( $args )
require 'settings.php';
- if ( $args['total_rows'] > $args['start_row'] + $args['result_rows'] )
+ if ( $args['total_rows'] >= $args['start_row'] + $args['result_rows'] )
{
$startIndex = $args['start_row'] + $ResultLimit;
if ( $args['total_rows'] < $startIndex )
@@ -133,9 +133,9 @@ function xml_end_dir( $args )
$args['html_parms']['index'] = $startIndex;
$endIndex = $startIndex + $ResultLimit - 1;
- if ( $endIndex >= $args['total_rows'] )
+ if ( $endIndex > $args['total_rows'] )
{
- $endIndex = $args['total_rows'] - 1;
+ $endIndex = $args['total_rows'];
}
$title = ( $startIndex == $endIndex )

0 comments on commit 98090ed

Please sign in to comment.