the itjerk

my adventures with technology

Tag Archives: xml

hide xml from browsers

I publish a daily rss feed, an “Album Of The Day” type thing, that feeds various social media pages as well. It works automatically, so I don’t really have to do anything, other than make sure is working correctly (sometimes one needs to┬árenew app permissions). Down side, is that there’s a huge xml file out there that is easily accessible from any web browsers. It’s not that big of a deal, because, after all, I am publishing bits each day. But two lines of codes hides it from honest people:

First, create a css stylesheet. To hide everything, make sure the css applies to the root element of your xml file, which in my case is “albums”. Then you only need one line of code in your css file.

albums {visibility: hidden;}

Next, in the xml file, reference your stylesheet:

<?xml-stylesheet href=”rss.css” media=”screen” type=”text/css”?>

Ptoof! Empty page!

Of course, if you really want to hide that xml source, you’ll need to move it to a directory that’s not visible like /var/.

album of the day in php & xml

     // load the xml file 
	    trigger_error('Error reading XML file',E_USER_ERROR);
    // generate a random number each day
	$today = date("Ymd");
	srand($today / pi());
	$max = count($xml->event) - 1 ;
	$num = rand (0,$max);
    // display random record with attributes
	echo "<span class=head>";	
	echo 'Album of the Day:<br />';
	echo $xml->event[$num]->attributes()->title;
	echo "<br />";
	echo "[html:img src=";
	echo $xml-]event[$num]->attributes()->image; 
	echo " width=150 height=150>";
	echo "<br />";
    //	convert from utf-8 to iso8859-1
	$review = iconv( "UTF-8", "ISO-8859-1//TRANSLIT", $xml->event[$num]);
	echo "<span class=item>";
    	echo $review	

On the web: