C:\xampp\htdocs\kptv2\ro\inslastfive.php


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
<?php
// Cron-style script: polls the Shoutcast metadata endpoint, extracts the
// "now playing" track, and inserts it into the `lastfive` table when it
// differs from the most recent row. Keeps the table capped at 5 entries.
//
// Adapted for testsite2 -- previous hardcoded creds (kptv_site / yAct...)
// pointed at the production database, which does not exist on this server.
// We now load credentials from conf_/siteconf_.php so the script writes
// into whichever DB the rest of the site uses (kptv_site2 here).

require_once("../conf_/siteconf_.php");

$open fsockopen("de1.streamingpulse.com","7222");
if (
$open) {
fputs($open,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
$read fread($open,1000);
$text explode(",",$read);
$text substr($text[6], 0, -14);
//$text = substr($text[6],11, -14);
} else { $text="Nu pot afisa titlul piesei!"; }

$today date("Y-m-d H:i:s");
$db mysql_connect($db_host$db_usrName$db_password);
mysql_selectdb($db_name);

$la mysql_query("SELECT * FROM lastfive ORDER BY date DESC LIMIT 1");
$last mysql_fetch_row($la);

list(
$artist$title) = explode(" - "$text);

if ((
$last[0] !== $artist) && ($last[1] !== $title)){

$ins mysql_query("INSERT INTO lastfive VALUES ('".mysql_escape_string($artist)."', '".mysql_escape_string($title)."', '".$today."')");

$cou mysql_query("SELECT COUNT(*) FROM lastfive");
$count mysql_fetch_row($cou);

$integ intval($count[0]);

if (
$integ >= 6) {
mysql_query("DELETE FROM lastfive ORDER BY date ASC LIMIT 1");
}
}
?>
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586