Technical Details of The Script

Although the Internet TV Script needs all the files the following are the main ones used from a programming point of view.

 

config.php
index.php
serverA.php

 

config.php

This file contains various configuration options such as variables that contain email address and database configuration.


index.php

include("config.php");

$dbz=mysql_connect($dbhost, $dbuser, $dbpass) or die (mysql_error());
mysql_select_db($dbname, $dbz) or die (mysql_error());

 

The above loads and executes the contents of config.php. In this case it initializes the database variables and sets the email variable.

 

Next is setting up the Categories and Countries stream selection menu, heres the code for setting up the Categories.

 

$query1 = "SELECT SQL_CACHE DISTINCT category FROM tvchannels WHERE category != 'Adults' AND category != '' ORDER BY category ASC";

$result1 = mysql_query($query1,$dbz) or die (mysql_error());
while ($record1 = mysql_fetch_array($result1) ) { $records1[] = $record1; }
$categories="";
foreach ($records1 as $rec){
$categories.="<h3 onclick=\"GetCat('".getSI($rec['category'])."')\">".$rec['category']."</h3>";
$categories.="<div class='menuz'><ul id='".getSI($rec['category'])."'></ul></div>";
}

 

The code above first sets up a mysql query to get all the categories available.it then loops throgh the results and creates the categories that are displayed when you load the script into your browser.

 

Each category member when setup uses a javascript function GetCat("category") so when a user clicks on one of the categories the function is called and this in turn populates that category with a sub menu of channels that belong to that category.

 

Further down the page there will be some HTML similar to this:

 

<div class="accordion"><div class="accordion1"><?=$categories ?></div></div>

 

The code <?=$categories ?> holds the actual categories code that gets displayed, and the DIVs that surround that are the menu appearence and functionality containers.

 

Heres the code for setting up the Countries.

 

$query2 = "SELECT SQL_CACHE DISTINCT country FROM tvchannels WHERE country != '' ORDER BY country ASC";

$result2 = mysql_query($query2,$dbz) or die (mysql_error());
while ($record2 = mysql_fetch_array($result2) ) { $records2[] = $record2; }
$countries="";
foreach ($records2 as $rec){
$countries.="<h3 onclick=\"GetCntry('".getSI($rec['country'])."')\">".$rec['country']."</h3>";
$countries.="<div class='menuz'><ul id='".getSI($rec['country'])."'></ul></div>";
}

 

The code above first sets up a mysql query to get all the countries available.it then loops throgh the results and creates the countries that are displayed when you load the script into your browser.

 

Each country member when setup uses a javascript function GetCntry("country") so when a user clicks on one of the countries the function is called and this in turn populates that country with a sub menu of channels that belong to that country.

 

Further down the page there will be some HTML similar to this:

 

<div class="accordion"><div class="accordion2"><?=$countries ?></div></div>

 

The code <?=$countries ?> holds the actual countries code that gets displayed, and the DIVs that surround that are the menu appearence and functionality containers.

 

Near the bottom of the page there is some javascript.

 

<script type="text/javascript">

$(document).ready(function(){
$(".accordion1 div:first").hide();
$(".accordion1 div:not(:first)").hide();

$(".accordion1 h3").click(function(){
$(this).next("div").slideToggle("slow")
.siblings("div:visible").slideUp("slow");
$(this).toggleClass("active");
$(this).siblings("h3").removeClass("active");
});

$(".accordion2 div:first").hide();
$(".accordion2 div:not(:first)").hide();

$(".accordion2 h3").click(function(){
$(this).next("div").slideToggle("slow")
.siblings("div:visible").slideUp("slow");
$(this).toggleClass("active");
$(this).siblings("h3").removeClass("active");
});
$(".menuz li").click(function(){
$("li").removeClass("active");
$(this).toggleClass("active");
});
});

function GetCat(category){
$.get("serverA.php?what=catchanns&cat="+category, function(response) {
document.getElementById(category).innerHTML=response;
//$("#"+category).html(response);
});
}
function GetCntry(country){
$.get("serverA.php?what=cntrychanns&cat="+country, function(response) {
document.getElementById(country).innerHTML=response;
//$("#"+country).html(response);
});
}
function Play(tvid){
$.get("serverA.php?what=play&cat="+tvid, function(response) {
document.getElementById('player').innerHTML=response;
});
}

<? if(isset($_GET['play']) and is_numeric($_GET['play'])){ ?>
Play(<?=$_GET['play'] ?>);
<? } ?>

</script>

 

In the above code the first part is for the channel selection menu functionality and its appearence.

After that we have the GetCat() javascript function this calls serverA.php to retrieve the categories.

After that we have the GetCntry() javascript function this calls serverA.php to retrieve the countries.

After that we have the Play() javascript function this calls serverA.php to retrieve the the stream info to play it.


serverA.php

 

This file does all the work for index.php. It creates and returns the channels for both categories and countries when someone clicks on either a actual ctegory or country.

 

Below is how the channels are displayed if someone clicks on a category:

 

...elseif($what=='catchanns'){
$dbz=mysql_connect($dbhost, $dbuser, $dbpass) or die (mysql_error());
mysql_select_db($dbname, $dbz) or die (mysql_error());

$query1 = "SELECT SQL_CACHE * FROM tvchannels WHERE category = '".$cat."' AND channel != '' AND enabled = 1 AND chanworking = 1 ORDER BY channel";
$result1 = mysql_query($query1,$dbz) or die (mysql_error());
while ($record1 = mysql_fetch_array($result1) ) { $records1[] = $record1; }

foreach ($records1 as $rec){
echo "<li onclick=\"Play('".getSI($rec['tvid'])."')\" title=\"".$rec['discription']."\">".$rec['channel']."</li>";
}
}elseif...

 

This sets up mysql to get all channels that are in the category held in the variable $cat so long as the channel is not empty and the channel is enabled and also working.

 

Then after retrieving the channels it then loops through them creating the code for the channels links that are displayed and also sets up the javascript to play the channels.

 

Also below is how the channels are displayed if someone clicks on a country:

 

...elseif($what=='cntrychanns'){
$dbz=mysql_connect($dbhost, $dbuser, $dbpass) or die (mysql_error());
mysql_select_db($dbname, $dbz) or die (mysql_error());

$query1 = "SELECT SQL_CACHE * FROM tvchannels WHERE country = '".$cat."' AND channel != '' AND enabled = 1 AND chanworking = 1 ORDER BY channel";
$result1 = mysql_query($query1,$dbz) or die (mysql_error());
while ($record1 = mysql_fetch_array($result1) ) { $records1[] = $record1; }

foreach ($records1 as $rec){
echo "<li onclick=\"Play('".getSI($rec['tvid'])."')\" title=\"".$rec['discription']."\">".$rec['channel']."</li>";
}
}elseif...

 

This sets up mysql to get all channels that are in the category held in the variable $cat so long as the channel is not empty and the channel is enabled and also working.

 

Then after retrieving the channels it then loops through them creating the code for the channels links that are displayed and also sets up the javascript to play the channels.

 

Below is the code that looks after playing a channel:

 

...elseif($what=='play'){
$dbz=mysql_connect($dbhost, $dbuser, $dbpass) or die (mysql_error());
mysql_select_db($dbname, $dbz) or die (mysql_error());

$query1 = "SELECT SQL_CACHE * FROM tvchannels WHERE tvid = '".$cat."'";
$result1 = mysql_query($query1,$dbz) or die (mysql_error());
while ($record1 = mysql_fetch_array($result1) ) { $records1[] = $record1; }
$rec=$records1[0];

$st=str_replace("&logo=http://i43.tinypic.com/xmqq9t.gif", "", $rec['streamurl']);

echo "<div align='left' style='padding: 4px; color:#FFFFFF;'><b>".$rec['channel']."</b></div>";
//echo "<div align='left' style='padding: 4px; padding-top: 0px; color:#FFFFFF;'>".$rec['discription']."</div>";

if($rec['chanworking']==0){
$plr="<p style='font-size:20px; color:#FFFFFF;'><br><br><br><br><b>".$rec['channel']."</b><br>This Channel is currently not working.<br><br><b>Please try again later.</b></p>";
echo $plr;

}else{
$d=$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
if (dirname($_SERVER['PHP_SELF'])=="/") $d=$_SERVER['HTTP_HOST'];

if($rec['player']=="fp"){
$plr="<embed src=\"".$st."\" width=\"490\" height=\"320\" allowscriptaccess=\"always\" allowfullscreen=\"true\" flashvars=\"autostart=true&repeat=list&width=490&height=320&logo=\"></embed>";
}else{
$plr="<embed type=\"application/x-mplayer2\" width=\"490\" height=\"320\" pluginspage=\"http://www.microsoft.com/Windows/MediaPlayer/\" autostart=\"1\" showcontrols=\"1\" mute=\"false\" volume=\"100\" autoplay=\"1\" uimode=\"full\" enablefullscreencontrols=\"true\" autosize=\"1\" showtracker=\"1\" transparentatstart=\"1\" showstatusbar=\"1\" showdisplay=\"0\" stretchToFit=\"1\" displaybackcolor=\"000000\" src=\"http://".$d."/play.php?tvid=".getSI($rec['tvid'])."\"></embed>";
}
echo $plr;

echo "<div align='center' style='padding: 4px; color:#FFFFFF;'><b>Please allow some time for the stream to start playing</b></div>";

$eml="mailto:".$email;
$eml.="?Subject=Channel Not Working (".$_SERVER['HTTP_HOST'].")";
$eml.="&Body=Channel Info:".urlencode("\n\n")."Channel ID: ".getSI($rec['tvid']).urlencode("\n")."Channel: ".$rec['channel'].urlencode("\n")."Category: ".$rec['category'].urlencode("\n")."Discription: ".$rec['discription'];

echo "<div style='margin:auto'><a align=\"center\" href=\"".$eml."\" style='color:#99FFFF; font-weight:bold'>Channel Not Working? Report It</a></div>";

echo "<div align='left' style='padding:4px; color:#99FFFF'>&nbsp;&nbsp;&nbsp;&nbsp;Direct URL to this Channel:</div>";
echo "<div style='padding-bottom:4px'><input type='text' value='http://".$d."/?play=".$rec['tvid']."' size='74' style='color:#cccccc; background:#444444' /></div>";

echo "<div align='left' style='padding:4px; color:#99FFFF'>&nbsp;&nbsp;&nbsp;&nbsp;Embed in your website/blog:</div>";
echo "<div style='padding-bottom:4px'><input type='text' value='".$plr."' size='74' style='color:#cccccc; background:#444444' /></div>";
}
}

 

This then when clicked on gets the channel to play when clicked on.

 

First it call mysql to get all info for the channel that has tvid held in $cat, then it builds the embed code for either windows media player or flash player, it finds which one by looking at the value held in field player in the returned mysql data, if its wm it windows media if its fp its flash player.

 

With this info the correct player embed code is selected and the stream url is added.

 

after the embed code and url is added then info about the channel is added along with perma link url and embed code itself, This is all added in order and displayed.

 

 

Privacy policy | Legal Disclaimer | About us | Contact us