function replaceurl($matches) { $url = str_replace(array('"', '\''), '', $matches[1]); global $current_css_url; $url = converturl($url, $current_css_url); return "url('{$url}')"; }
function startapi() { if (isset($_GET['type'])) { switch ($_GET['type']) { case 'roku': header('Content-Type: text/xml'); db_connect(); echo '<?xml version="1.0" encoding="UTF-8"?><orml version="1.2" xmlns="http://sourceforge.net/p/openrokn/home/ORML"><channel> <item type="poster" style="flat-episodic-16x9" title="GREEK TV" shortdesc="GreekTV" sdposterurl="pkg:/images/sdvideos.png" hdposterurl="pkg:/images/hdvideos.png">'; echo db_select("select greekchannels.title,greekchannels.channel_order,greekchannels.description,greekchannels.sd_image,greekchannels.hd_image,greekchannels.region,greekchannels.type,streams.streamurl,streams.streamformat,streams.active,streams.ishd from greekchannels join streams on greekchannels.id = streams.channelid where greekchannels.type = 'video' and streams.active = '1' order by greekchannels.channel_order desc", 'roku'); echo '</item></channel></orml>'; break; case 'greekchannels': $aaData = array(); header('Content-Type: application/json'); db_connect(); $rows = array(); $query = "select * from greekchannels"; $result = db_query($query); if ($result === false) { return false; } while ($row = mysqli_fetch_assoc($result)) { $aaData[] = $row; } $response = array('data' => $aaData); if (isset($_REQUEST['sEcho'])) { $response['sEcho'] = $_REQUEST['sEcho']; } echo json_encode($response); break; case 'addstream': if (isset($_GET['channelid']) & isset($_GET['streamurl']) & isset($_GET['streamformat']) & isset($_GET['active']) & isset($_GET['ishd']) & isset($_GET['user'])) { db_connect(); $channelid = $_GET['channelid']; $streamurl = $_GET['streamurl']; $streamformat = $_GET['streamformat']; $active = $_GET['active']; $ishd = $_GET['ishd']; $user = $_GET['user']; $query = "insert into streams (channelid,streamurl,streamformat,active,ishd,user) VALUES ('{$channelid}','{$streamurl}','{$streamformat}','{$active}','{$ishd}','{$user}')"; // echo $query; $result = db_query($query); if ($result === false) { return false; } echo '<meta http-equiv="refresh" content="0; url=/admin/?thepath=streamurls" />'; } else { echo '<meta http-equiv="refresh" content="0; url=/admin/?thepath=streamurls" />'; } break; case 'editstream': if (isset($_GET['streamid']) & isset($_GET['channelid']) & isset($_GET['streamurl']) & isset($_GET['streamformat']) & isset($_GET['active']) & isset($_GET['ishd']) & isset($_GET['user'])) { db_connect(); $streamid = $_GET['streamid']; $channelid = $_GET['channelid']; $streamurl = $_GET['streamurl']; $streamformat = $_GET['streamformat']; $active = $_GET['active']; $ishd = $_GET['ishd']; $user = $_GET['user']; $query = "UPDATE streams SET channelid = '{$channelid}', streamurl = '{$streamurl}',streamformat = '{$streamformat}',active = '{$active}',ishd = '{$ishd}',user = '******' where id = '{$streamid}'"; // echo $query; $result = db_query($query); if ($result === false) { return false; } echo '<meta http-equiv="refresh" content="0; url=/admin/?thepath=streamurls" />'; } else { echo '<meta http-equiv="refresh" content="0; url=/admin/?thepath=streamurls" />'; } break; case 'editchannel1': echo '?'; if (isset($_GET['title']) & isset($_GET['region']) & isset($_GET['type']) & isset($_GET['description']) & isset($_GET['sdimage']) & isset($_GET['sdimage']) & isset($_GET['hdimage'])) { db_connect(); $channelid = $_GET['channelid']; $title = $_GET['title']; $region = $_GET['region']; $type = $_GET['type']; $description = $_GET['description']; $sdimage = $_GET['sdimage']; $hdimage = $_GET['hdimage']; $order = $_GET['order']; $query = "UPDATE greekchannels SET title = '{$title}', region = '{$region}',type = '{$type}',description = '{$description}',sd_image = '{$sdimage}',hd_image = '{$hdimage}',channel_order = '{$order}' where id = '{$channelid}'"; echo $query; $result = db_query($query); if ($result === false) { return false; } echo '<meta http-equiv="refresh" content="0; url=/admin/?thepath=greekchannels" />'; echo '???'; } else { echo '<meta http-equiv="refresh" content="0; url=/admin/?thepath=greekchannels" />'; echo '???????'; } break; case 'editchannel': if (isset($_GET['title']) & isset($_GET['region']) & isset($_GET['thetype']) & isset($_GET['description']) & isset($_GET['sdimage']) & isset($_GET['sdimage']) & isset($_GET['hdimage'])) { db_connect(); $channelid = $_GET['channelid']; $title = $_GET['title']; $region = $_GET['region']; $type = $_GET['thetype']; $description = $_GET['description']; $sdimage = $_GET['sdimage']; $hdimage = $_GET['hdimage']; $order = $_GET['order']; $query = "UPDATE greekchannels SET title = '{$title}', region = '{$region}',type = '{$type}',description = '{$description}',sd_image = '{$sdimage}',hd_image = '{$hdimage}',channel_order = '{$order}' where id = '{$channelid}'"; // echo $query; $result = db_query($query); if ($result === false) { return false; } echo '<meta http-equiv="refresh" content="0; url=/admin/?thepath=greekchannels" />'; } else { echo '<meta http-equiv="refresh" content="0; url=/admin/?thepath=greekchannels" />'; } break; case 'addchannel': if (isset($_GET['title']) & isset($_GET['region']) & isset($_GET['thetype']) & isset($_GET['description']) & isset($_GET['sdimage']) & isset($_GET['sdimage']) & isset($_GET['hdimage'])) { db_connect(); $title = $_GET['title']; $region = $_GET['region']; $type = $_GET['thetype']; $description = $_GET['description']; $sdimage = $_GET['sdimage']; $hdimage = $_GET['hdimage']; $order = $_GET['order']; $query = "insert into greekchannels (title,region,type,description,sd_image,hd_image,channel_order) VALUES ('{$title}','{$region}','{$type}','{$description}','{$sdimage}','{$hdimage}','{$order}')"; // echo $query; $result = db_query($query); if ($result === false) { return false; } echo '<meta http-equiv="refresh" content="0; url=/admin/?thepath=greekchannels" />'; } else { echo '<meta http-equiv="refresh" content="0; url=/admin/?thepath=greekchannels" />'; } break; case 'deletestream': if (isset($_GET['streamid'])) { db_connect(); $streamid = $_GET['streamid']; $query = "delete from streams where id = '{$streamid}'"; // echo $query; $result = db_query($query); if ($result === false) { return false; } echo '<meta http-equiv="refresh" content="0; url=/admin/?thepath=streamurls" />'; } else { echo '<meta http-equiv="refresh" content="0; url=/admin/?thepath=streamurls" />'; } break; case 'deletechannel': if (isset($_GET['channelid'])) { db_connect(); $channelid = $_GET['channelid']; $query = "delete from greekchannels where id = '{$channelid}'"; // echo $query; $result = db_query($query); if ($result === false) { return false; } echo '<meta http-equiv="refresh" content="0; url=/admin/?thepath=greekchannels" />'; } else { echo '<meta http-equiv="refresh" content="0; url=/admin/?thepath=greekchannels" />'; } break; case 'streams': $aaData = array(); header('Content-Type: application/json'); db_connect(); $rows = array(); $query = "select streams.id,channelid,streamurl,streamformat,active,ishd,bitrate,user,greekchannels.title AS channel from streams left join greekchannels on streams.channelid = greekchannels.id where channelid != 0"; $result = db_query($query); if ($result === false) { return false; } while ($row = mysqli_fetch_assoc($result)) { $aaData[] = $row; } $response = array('data' => $aaData); if (isset($_REQUEST['sEcho'])) { $response['sEcho'] = $_REQUEST['sEcho']; } echo json_encode($response); break; case 'channelnames': $aaData = array(); header('Content-Type: application/json'); db_connect(); $rows = array(); $query = "select id,title from greekchannels"; $result = db_query($query); if ($result === false) { return false; } while ($row = mysqli_fetch_assoc($result)) { $aaData[] = $row; } echo json_encode($aaData); break; case 'kodi': header('Content-Type: text/plain'); db_connect(); echo db_select("select greekchannels.title,greekchannels.channel_order,greekchannels.sd_image,streams.streamurl from greekchannels JOIN streams on greekchannels.id = streams.channelid where greekchannels.type = 'video' and streams.active = '1' order by greekchannels.channel_order desc", 'kodi'); // echo db_select("select * from content where type2 = 'tv' and active = '1' order by ord desc", 'roku'); break; case 'ripurl': header('Content-Type: text/plain'); converturl($_GET['url']); break; case 'ripm3ulist': header('Content-Type: text/plain'); convertm3uurl($_GET['url'], $_GET['type2']); break; case 'enterdb': enterdb($_GET['url'], $_GET['type2']); break; case 'tvos': header('Content-Type: application/javascript'); db_connect(); echo 'var Template = function() { return `<?xml version="1.0" encoding="UTF-8" ?><document><catalogTemplate><banner><title>Greek TV by UPG.GR</title></banner><list><section><listItemLockup><title>Greek TV</title><decorationLabel>Live</decorationLabel><relatedContent><grid><section>'; echo db_select("select greekchannels.title,greekchannels.channel_order,greekchannels.description,greekchannels.sd_image,greekchannels.hd_image,greekchannels.region,greekchannels.type,streams.streamurl,streams.streamformat,streams.active,streams.ishd from greekchannels join streams on greekchannels.id = streams.channelid where greekchannels.type = 'video' and streams.active = '1' order by greekchannels.channel_order desc", 'tvos'); echo '</section></grid></relatedContent></listItemLockup></section>'; echo '<section><listItemLockup><title>Greek Radio</title><decorationLabel>Live</decorationLabel><relatedContent><grid><section>'; echo db_select("select greekchannels.title,greekchannels.channel_order,greekchannels.description,greekchannels.sd_image,greekchannels.hd_image,greekchannels.region,greekchannels.type,streams.streamurl,streams.streamformat,streams.active,streams.ishd from greekchannels join streams on greekchannels.id = streams.channelid where greekchannels.type = 'radio' and streams.active = '1' order by greekchannels.channel_order desc", 'tvos'); echo '</section></grid></relatedContent></listItemLockup></section>'; echo '</list></catalogTemplate></document>`}'; break; case 'web': header('Content-Type: text/xml'); db_connect(); echo '<?xml version="1.0" encoding="UTF-8"?><orml version="1.2" xmlns="http://sourceforge.net/p/openrokn/home/ORML"><channel> <item type="poster" style="flat-episodic-16x9" title="GREEK TV" shortdesc="GreekTV" sdposterurl="pkg:/images/sdvideos.png" hdposterurl="pkg:/images/hdvideos.png">'; // echo db_select("select * from content where type2 = 'tv' and active = '1' order by ord desc", 'roku'); echo db_select("select greekchannels.title,greekchannels.channel_order,greekchannels.description,greekchannels.sd_image,greekchannels.hd_image,greekchannels.region,greekchannels.type,streams.streamurl,streams.streamformat,streams.active,streams.ishd from greekchannels join streams on greekchannels.id = streams.channelid where greekchannels.type = 'video' and streams.active = '1' order by greekchannels.channel_order desc", 'web'); echo '</item></channel></orml>'; break; case 'plex': header('Content-Type: text/xml'); db_connect(); echo '<?xml version="1.0" encoding="UTF-8"?><orml version="1.2" xmlns="http://sourceforge.net/p/openrokn/home/ORML"><channel> <item type="poster" style="flat-episodic-16x9" title="GREEK TV" shortdesc="GreekTV" sdposterurl="pkg:/images/sdvideos.png" hdposterurl="pkg:/images/hdvideos.png">'; echo db_select("select greekchannels.id, greekchannels.title,greekchannels.channel_order,greekchannels.description,greekchannels.sd_image,greekchannels.hd_image,greekchannels.region,greekchannels.type,streams.streamurl,streams.streamformat,streams.active,streams.ishd from greekchannels join streams on greekchannels.id = streams.channelid where greekchannels.type = 'video' and streams.active = '1' order by greekchannels.channel_order desc", 'plex'); echo '</item></channel></orml>'; break; case 'unixml': header("Content-Type: application/xml; charset=UTF-8"); db_connect(); echo '<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title>GreekTV by upg.gr</title><description>Greek TV video feed</description><link>http://greektv.upg.gr</link>'; echo db_select("select greekchannels.id,greekchannels.title,greekchannels.channel_order,greekchannels.description,greekchannels.sd_image,greekchannels.hd_image,greekchannels.region,greekchannels.type,streams.streamurl,streams.streamformat,streams.active,streams.ishd from greekchannels join streams on greekchannels.id = streams.channelid where greekchannels.type = 'video' and streams.active = '1' order by greekchannels.channel_order desc", 'unixml'); echo '</channel></rss>'; break; case 'unijson': header('Content-Type: application/json'); db_connect(); echo db_select("select greekchannels.id,greekchannels.title,greekchannels.channel_order,greekchannels.description,greekchannels.sd_image,greekchannels.hd_image,greekchannels.region,greekchannels.type,streams.streamurl,streams.streamformat,streams.active,streams.ishd from greekchannels join streams on greekchannels.id = streams.channelid where greekchannels.type = 'video' and streams.active = '1' order by greekchannels.channel_order desc", 'unijson'); break; case 'all': db_connect(); echo db_select('select * from greekchannels order by ord desc', 'all'); break; case 'Select api response': echo ''; break; case 'vlc': header('Content-Type: audio/mpegurl;'); //header('Content-Type: text'); db_connect(); echo "#EXTM3U\r\n"; echo db_select("select greekchannels.title,greekchannels.channel_order,greekchannels.description,greekchannels.sd_image,greekchannels.hd_image,greekchannels.region,greekchannels.type,streams.streamurl,streams.streamformat,streams.active,streams.ishd from greekchannels join streams on greekchannels.id = streams.channelid where greekchannels.type = 'video' and streams.active = '1' order by greekchannels.channel_order desc", 'vlc'); break; case 'findactive': db_connect(); echo db_select('select * from streams', 'findactive'); break; case 'removeinactive': db_connect(); echo db_select('select * from streams where timesinactive > 250', 'removeinactive'); break; case 'skaiurl': $url = "www.skai.gr/player/tvlive/"; $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); curl_close($ch); $re = "/<span itemprop=\"contentUrl\" href=\"(.*?)\"><\\/span>/"; preg_match($re, $data, $matches); echo 'https://www.youtube.com/watch?v=' . $matches[1]; break; case 'skaiurl_redirected': $url = "www.skai.gr/player/tvlive/"; $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); curl_close($ch); $re = "/<span itemprop=\"contentUrl\" href=\"(.*?)\"><\\/span>/"; preg_match($re, $data, $matches); $theurl = 'https://www.youtube.com/watch?v=' . $matches[1]; header("Location: {$theurl}"); break; } } else { echo "<form>\n\t<select name='type' onchange='this.form.submit()'>\n\t\t<option selected>Select api response</option>\n\t\t<option>roku</option>\n \t\t<option>tvos</option>\n \t\t<option>web</option>\n\t\t<option>plex</option>\n <option>kodi</option>\n\t\t<option>vlc</option>\n <option>ripurl</option>\n\t\t<option>all</option>\n\t\t<option>findactive</option>\n\t</select>\n\t<noscript><input type='submit' value='Submit'></noscript>\n\t</form><br> Note that -Find active- takes time as it checks every stream individually"; } }