New Request Script for anyone who wants it.

When i try this with data in my url it transposes it with real data to "http://$rb_server:$rb_port/?pass=$rb_password";
 
Yes but it takes up a lot of resources to get from XML then put it into SQL http://deniserose.ezyro.com/music_now_playing.php and i havent managed to work out how to get it into https, which has a http stream, which means mixed formats, which https doesnt like
If you need HTTPS that can be configured in RadioBOSS, but you need a certificate (buy it or create self signed).
See "Using HTTPS" section here: https://manual.djsoft.net/radioboss/en/remote_control_api.htm
 
Yes, but my stream is http, not https. I thought you could not mix them? Oh I see you mean the request to RB.
 
This could be because of hidden security changes.
  1. Early Implementation of the Same-Origin Policy (SOP) (1995–2000s)
    SOP prevents a script on one domain from accessing resources (such as cookies, DOM elements, or files) on another domain.
    This stopped direct JavaScript access to files from other sites.
  2. Cross-Origin Resource Sharing (CORS) (2009)
    W3C introduced CORS to allow controlled cross-origin access by requiring explicit permission from the target server.
    Without the correct Access-Control-Allow-Origin headers, browsers block cross-origin requests.
  3. Blocking Cross-Origin File Access (2010s)
    XHR & Fetch API Restrictions: Browsers began blocking cross-origin file requests unless explicitly allowed.
    File URI Restrictions: Accessing local files (file://) from a remote webpage was blocked for security reasons.
    Cross-Origin Read Blocking (CORB) (2018): Google Chrome implemented CORB to block sensitive data in cross-origin responses that lack proper CORS headers.
  4. More Stringent Fetch Metadata (2020s)
    Browsers introduced Fetch Metadata Request Headers (Sec-Fetch-Site, Sec-Fetch-Mode) to detect and block unauthorized cross-origin resource access.
    Websites can now configure Cross-Origin-Opener-Policy (COOP) and Cross-Origin-Embedder-Policy (COEP) to fully isolate their context.
  5. Deprecation of Insecure Protocols & Third-Party Access
    Blocking Mixed Content (2019–2023): Browsers started blocking HTTP resources from loading on HTTPS pages.
    Third-Party Cookie Phase-Out (2024): Google Chrome and other browsers have begun restricting cookies and storage access across sites.
 
Hi I thought i would share this in case some one could make it simpler as i know some are you are more profient than me with tyour curls and things

<?php

// * Create SSQL Entry from FTP delivery
// *


/*
<?xml version="1.0" encoding="utf-8"?>
<PLAYER name="RadioBOSS" version="6.2.3.2">
<TRACK ARTIST="Morcheeba" TITLE="The Sea" ALBUM="Parts of the Process" YEAR="2003" GENRE="Lush;downbeat;" COMMENT="Ripped by Winamp" FILENAME="C:\Music &amp; Video\Morcheeba - Parts of the Process\01 - Morcheeba - The Sea.mp3" DURATION="05:49" STARTED="2022-12-19 01:37:03" PLAYCOUNT="4" LASTPLAYED="2022-12-19 01:37:02" INTRO="0.00" OUTRO="0.00" LANGUAGE="" RATING="0" BPM="150" TAGS="" F1="" F2="" F3="" F4="" F5="" CASTTITLE="Morcheeba - The Sea" LISTENERS="0" />
<PREVTRACK><TRACK ARTIST="Metric" TITLE="Nobody Home" ALBUM="Fantasies" YEAR="2009" GENRE="Lush; Rock; Indie Rock; New Wave;" COMMENT="http://mp3caprice.com" FILENAME="C:\Music &amp; Video\Metric - Fantasies\14_nobody-home.mp3" DURATION="03:13" STARTED="2022-12-19 01:37:03" PLAYCOUNT="13" LASTPLAYED="2022-12-19 01:34:14" INTRO="182.68" OUTRO="1.26" LANGUAGE=" English" RATING="6" BPM="166" TAGS="" F1="" F2="" F3="" F4="" F5="" CASTTITLE="Metric - Nobody Home" /></PREVTRACK>
</PLAYER>

*/



//exit(); /*************************************************** TERMINATE ********************************************/

$baseurl = "http://deniserose.ezyro.com/";
$servername = "sql306.ezyro.com";
$username = "ezyro_33672165";
$password="4hzhjvr1s2";
$dbname = "ezyro_33672165_song_history";
$filename = "images/nowplaying.txt";
$artwork_filename = "images/nowplaying.txt";
$textXML = "";
$title = "";
$artist = "";
$album = "";
$length = "";
$bpm = "";
$genre = "";
$listeners = "";
$comment = "";
$artwork = "";
$lyrics="";

$search = ["À","Á" ,"Â" ,"Ã","Ä","Å","à","á","â","ã","ä","å","Æ","æ","ß","Ç","ç","È","É","Ê","Ë","è","é","ê","ë","ƒ","Ì","Í","Î","Ï","ì","í","î","ï","Ñ","ñ","Ò","Ó","Ô","Õ","Ö","ò","ó","ô","õ","ö","Ø","ø","Œ","œ","Š","š","Ù","Ú","Û","Ü","ù","ú","û","ü","µ","×","Ý","Ÿ","ý","ÿ","°","†","‡","<",">","±","«","»","¿","¡","·","•", "™","©","®","§" ];
$replace = ["&Agrave","&Aacute","&Acirc","&Atilde","&Auml","&Aring","&agrave","&aacute","&acirc","&atilde","&auml","&aring","&AElig","&aelig;","&szlig;","&Ccedil;","&ccedil;","&Egrave;","&Eacute;","&Ecirc;","&Euml;","&egrave;","&eacute;","&ecirc;","&euml;","&#131;","&Igrave;","&Iacute;","&Icirc;","&Iuml;","&igrave;","&iacute;", "&icirc;","&iuml;","&Ntilde;","&ntilde;","&Ograve;","&Oacute;","&Ocirc;","&Otilde;","&Ouml;","&ograve;","&oacute;","&ocirc;","&otilde;","&ouml;","&Oslash;","&oslash;","&#140;","&#156;","&#138;","&#154;","&Ugrave;","&Uacute;","&Ucirc;","&Uuml;","&ugrave;","&uacute;","&ucirc;","&uuml;","&#181;","&#215;","&Yacute;","&#159;","&yacute;","&yuml;","&#176;","&#134;","&#135;","&lt;","&gt;","&#177;","&#171;","&#187;","&#191;","&#161;","&#183;","&#149;","&#153;","&copy;","&reg;","&#167;"];

function cleanup($str) {
return str_replace($search,$replace,$str);
}


$pattern_replace = array (
"À" => "&Agrave",
"Á" => "&Aacute",
"Â" => "&Acirc",
"Ã" => "&Atilde",
"Ä" => "&Auml",
"Å" => "&Aring",
"à" => "&agrave",
"á" => "&aacute",
"â" => "&acirc",
"ã" => "&atilde",
"ä" => "&auml",
"å" => "&aring",
"Æ" => "&AElig",
"æ" => "&aelig;",
"ß" => "&szlig;",
"Ç" => "&Ccedil;",
"ç" => "&ccedil;",
"È" => "&Egrave;",
"É" => "&Eacute;",
"Ê" => "&Ecirc;",
"Ë" => "&Euml;",
"è" => "&egrave;",
"é" => "&eacute;",
"ê" => "&ecirc;",
"ë" => "&euml;",
"ƒ" => "&#131;",
"Ì" => "&Igrave;",
"Í" => "&Iacute;",
"Î" => "&Icirc;",
"Ï" => "&Iuml;",
"ì" => "&igrave;",
"í" => "&iacute;",
"î" => "&icirc;",
"ï" => "&iuml;",
"Ñ" => "&Ntilde;",
"ñ" => "&ntilde;",
"Ò" => "&Ograve;",
"Ó" => "&Oacute;",
"Ô" => "&Ocirc;",
"Õ" => "&Otilde;",
"Ö" => "&Ouml;",
"ò" => "&ograve;",
"ó" => "&oacute;",
"ô" => "&ocirc;",
"õ" => "&otilde;",
"ö" => "&ouml;",
"Ø" => "&Oslash;",
"ø" => "&oslash;",
"Œ" => "&#140;",
"œ" => "&#156;",
"Š" => "&#138;",
"š" => "&#154;",
"Ù" => "&Ugrave;",
"Ú" => "&Uacute;",
"Û" => "&Ucirc;",
"Ü" => "&Uuml;",
"ù" => "&ugrave;",
"ú" => "&uacute;",
"û" => "&ucirc;",
"ü" => "&uuml;",
"µ" => "&#181;",
"×" => "&#215;",
"Ý" => "&Yacute;",
"Ÿ" => "&#159;",
"ý" => "&yacute;",
"ÿ" => "&yuml;",
"°" => "&#176;",
"†" => "&#134;",
"‡" => "&#135;",
"<" => "&lt;",
">" => "&gt;",
"±" => "&#177;",
"«" => "&#171;",
"»" => "&#187;",
"¿" => "&#191;",
"¡" => "&#161;",
"·" => "&#183;",
"•" => "&#149;",
"™" => "&#153;",
"©" => "&copy;",
"®" => "&reg;",
"§" => "&#167;"


);

function str_replace_json($search, $replace, $output){

return json_decode(str_replace($search, $replace, json_encode($output)));



}

function replace_chars_with_entities( $str )

{

$str = str_replace( 'À', '&#192;', $str );

$str = str_replace( 'Á', '&#193;', $str );

$str = str_replace( 'Â', '&#194;', $str );

$str = str_replace( 'Ã', '&#195;', $str );

$str = str_replace( 'Ä', '&#196;', $str );

$str = str_replace( 'Å', '&#197;', $str );

$str = str_replace( 'Æ', '&#198;', $str );

$str = str_replace( 'Ç', '&#199;', $str );

$str = str_replace( 'È', '&#200;', $str );

$str = str_replace( 'É', '&#201;', $str );

$str = str_replace( 'Ê', '&#202;', $str );

$str = str_replace( 'Ë', '&#203;', $str );

$str = str_replace( 'Ì', '&#204;', $str );

$str = str_replace( 'Í', '&#205;', $str );

$str = str_replace( 'Î', '&#206;', $str );

$str = str_replace( 'Ï', '&#207;', $str );

$str = str_replace( 'Ð', '&#208;', $str );

$str = str_replace( 'Ñ', '&#209;', $str );

$str = str_replace( 'Ò', '&#210;', $str );

$str = str_replace( 'Ó', '&#211;', $str );

$str = str_replace( 'Ô', '&#212;', $str );

$str = str_replace( 'Õ', '&#213;', $str );

$str = str_replace( 'Ö', '&#214;', $str );

$str = str_replace( '×', '&#215;', $str );

$str = str_replace( 'Ø', '&#216;', $str );

$str = str_replace( 'Ù', '&#217;', $str );

$str = str_replace( 'Ú', '&#218;', $str );

$str = str_replace( 'Û', '&#219;', $str );

$str = str_replace( 'Ü', '&#220;', $str );

$str = str_replace( 'Ý', '&#221;', $str );

$str = str_replace( 'Þ', '&#222;', $str );

$str = str_replace( 'ß', '&#223;', $str );

$str = str_replace( 'à', '&#224;', $str );

$str = str_replace( 'á', '&#225;', $str );

$str = str_replace( 'â', '&#226;', $str );

$str = str_replace( 'ã', '&#227;', $str );

$str = str_replace( 'ä', '&#228;', $str );

$str = str_replace( 'å', '&#229;', $str );

$str = str_replace( 'æ', '&#230;', $str );

$str = str_replace( 'ç', '&#231;', $str );

$str = str_replace( 'è', '&#232;', $str );

$str = str_replace( 'é', '&#233;', $str );

$str = str_replace( 'ê', '&#234;', $str );

$str = str_replace( 'ë', '&#235;', $str );

$str = str_replace( 'ì', '&#236;', $str );

$str = str_replace( 'í', '&#237;', $str );

$str = str_replace( 'î', '&#238;', $str );

$str = str_replace( 'ï', '&#239;', $str );

$str = str_replace( 'ð', '&#240;', $str );

$str = str_replace( 'ñ', '&#241;', $str );

$str = str_replace( 'ò', '&#242;', $str );

$str = str_replace( 'ó', '&#243;', $str );

$str = str_replace( 'ô', '&#244;', $str );

$str = str_replace( 'õ', '&#245;', $str );

$str = str_replace( 'ö', '&#246;', $str );

$str = str_replace( '÷', '&#247;', $str );

$str = str_replace( 'ø', '&#248;', $str );

$str = str_replace( 'ù', '&#249;', $str );

$str = str_replace( 'ú', '&#250;', $str );

$str = str_replace( 'û', '&#251;', $str );

$str = str_replace( 'ü', '&#252;', $str );

$str = str_replace( 'ý', '&#253;', $str );

$str = str_replace( 'þ', '&#254;', $str );

$str = str_replace( 'ÿ', '&#255;', $str );
$str = str_replace( "'" , '&apos;', $str );


return $str;

}
// use Square bracket notation $pattern_replace["§"] and
// array_search("§", $pattern_replace, strict) or preg_replace(

if(!isset($conn)) {include("file_operations.php");}


include "mp3/check_remote_server.php";
$remote_server = checkRemoteServerStatus(
"http://virtualkitten.ds.sparrowindustries.net:27274/",
19200,
0
);

if($remote_server == 0) echo "No server up and available.";
function ReturnError($code, $text)
{
return;
$protocol = isset($_SERVER["SERVER_PROTOCOL"])
? $_SERVER["SERVER_PROTOCOL"]
: "HTTP/1.0";
//header($protocol . ' ' . $code . ' ' . $text);

echo "<HTML>";
echo "<img src ='images/favpng_construction-worker-architectural-engineering-cartoon-royalty-free.png' width='200' height='240'></img><br><br>";
echo "SERVER_PROTOCOL ERROR<BR><BR>";
echo "Add data to SQL -." . $text . "<br><br>";
throw Error("EXIT CODE");
exit();
}
//$remote_server=true;
if ($remote_server == true) {
$xml=simplexml_load_file("images/nowplaying.xml");
if( $xml == false) {ReturnError(500, "Failed to open ("."images/nowplaying.xml".") bytes of XML from file XML.");}
//$artist= iconv( "UTF-8", "ISO-8859-1//TRANSLIT", $artist); //TO REMOVE THE ISO-8859-1 ISSUE
//print_r($xml);
$title = implode($xml->xpath('//PLAYER/TRACK/@TITLE'));
$title = replace_chars_with_entities($title);
$artist = implode($xml->xpath('//PLAYER/TRACK/@ARTIST'));
$artist = replace_chars_with_entities($artist );
$album = implode($xml->xpath('//PLAYER/TRACK/@ALBUM'));
$year = implode($xml->xpath('//PLAYER/TRACK/@YEAR'));
$album = replace_chars_with_entities($album );
$genre = implode($xml->xpath('//PLAYER/TRACK/@GENRE'));
$comment = implode($xml->xpath('//PLAYER/TRACK/@COMMENT'));
$bpm = implode($xml->xpath('//PLAYER/TRACK/@BPM'));
$length = implode($xml->xpath('//PLAYER/TRACK/@DURATION'));
$listeners =implode($xml->xpath('//PLAYER/TRACK/@LISTENERS'));
$rating = implode($xml->xpath('//PLAYER/TRACK/@RATING'));
$lyrics = implode($xml->xpath('//PLAYER/TRACK/@LYRICS'));
$exit_old = false;
print_r($lyrics);
$parts = preg_split('/(?=[A-Z])/', $lyrics, -1, PREG_SPLIT_NO_EMPTY);
echo "<br><br>";
$xml = null; // clear the used class XML.
// note there is now num_rows in PDO so we have to calculate a new one to get record number.


$n = 0;
$result = OpenPDO($conn,"SELECT * FROM `played_songs` ORDER BY `datetime` DESC LIMIT 1",$_query,"");
$row = $result->fetch();
if ($artist != $row['artist'] && $title != $row['song']) {
$exit_old = true;

$t = fopen("images/nowplaying_artwork_2.png", "r");
if ($t !== false) {
$artwork = fread($t, filesize("images/nowplaying_artwork_2.png"));
fclose($t);
} else {
fclose($t);
ReturnError(500, "Failed to write artwork to a file.");
}
$base64artwork = base64_encode($artwork);
try {
$sql = "INSERT INTO `played_songs` (`song`, `artist`, `album`, `length`, `bpm`,`genre`, `listeners`,`track_user_rating`,`track_user_num`,`comment`,`ImageBase64`,`lyrics`,`year`) VALUES ('$title','$artist', '$album', '$length', '$bpm', '$genre','$listeners','0','0', '$comment','$base64artwork','','$year') ON DUPLICATE KEY UPDATE `listeners`='$listeners'";

$result= OpenPDO($conn,$sql,$_execute,"");

} catch(Exception $e) {
//$result->rollBack();
ReturnError($code, "An Error occurd inserting record to SQL");
}
try {
$sql ="UPDATE `played_songs` SET `lyrics` = '$lyrics' WHERE datetime = (select max(datetime) FROM `played_songs`)";
$result= OpenPDO($conn,$sql,$_execute,"");
} catch(Exception $e) {
//$result->rollBack();
ReturnError($code, "An Error occurd updatig record in SQL");
}


$result = OpenPDO($conn,"SELECT COUNT(`datetime`) FROM `played_songs` ORDER BY `datetime` ASC",$_query,"");
$row = $result->fetch();
$n = $row["COUNT(`datetime`)"] - 300;

if ($n > 1) {
$q = OpenPDO($conn,"SELECT `datetime` FROM `played_songs` ORDER BY `datetime` ASC",$_query,"");
while ($n) {
$r = $q->fetch();
$id = $r["datetime"];
OpenPDO($conn,"DELETE FROM `played_songs` WHERE `datetime`=?" ,$_execute,$id);
$n--;
}

}

} else {
ReturnError(500,"Failed to write/read record to SQL. NO data read from the XML file");

}
//echo "New record created successfully";



} else {
ReturnError(500, "Failed to write /read from xml file no data was loaded." );

}


//Server disconnected

?>
</HTML>
 
with a static ip give everyone access to my pc so they can browse my library
No thanks is too insecure for me
You should protect RadioBOSS with a password and also only the script accesses the RadioBOSS API, not the users directly, so the script should also be made secure. RadioBOSS 7.1 offers API users with limited rights, I think those will developed in the future for enhanced security.
 
Back
Top