|
<?php |
|
$url = $_GET['feed_url']; |
|
ini_set( "display_errors", 0); |
|
|
|
if(@$test = file_get_contents($url)) |
|
{ |
|
if($xml = simplexml_load_string($test)) |
|
{ |
|
$search = array('<', '>', 'red</font>>'); |
|
$replace = array('<<font color=red>', '</font>>','red>'); |
|
$disp = str_replace($search, $replace, $test); |
|
|
|
//echo "<pre>".$disp."</pre>"; |
|
|
|
|
|
$json=json_encode($xml); |
|
|
|
|
|
$test_a=json_decode($json, true); |
|
echo "<br><br>"; |
|
|
|
echo "Please check the tags of whose values you need as a update<br><br>"; |
|
processArray($test_a,"root"); |
|
|
|
echo "<input type='hidden' name='url_valid_flag' id='url_valid_flag' value='1'> |
|
<br><input type='hidden' name='xml_string' id='xml_string' value='".$xml."'>"; //for form validation of check boxes of tags, 0 for invalid url, 1 for valid url |
|
|
|
} |
|
|
|
else if($test_a=json_decode($test, true)) |
|
{ |
|
//echo "Check the <a href='xml-display.php?url=$url' target='_blank'>xml</a> available for the $url <br><br>"; |
|
echo "Please check the tags of whose values you need as a update<br><br>"; |
|
|
|
processArray($test_a,"root"); |
|
|
|
echo "<input type='hidden' name='url_valid_flag' id='url_valid_flag' value='1'> |
|
<br><input type='hidden' name='xml_string' id='xml_string' value='".$xml."'>"; //for form validation of check boxes of tags, 0 for invalid url, 1 for valid url |
|
} |
|
else |
|
{ |
|
echo "<br><center><font color=red>Please enter a valid URL containing XML data</font><center>"; |
|
|
|
echo "<input type='hidden' name='url_valid_flag' id='url_valid_flag' value='0'>"; //for form validation of check boxes of tags, 0 for invalid url, 1 for valid url |
|
|
|
|
|
} |
|
} |
|
|
|
else |
|
{ |
|
echo "<br><center><font color=red>Please enter a valid URL</font><center>"; |
|
|
|
echo "<input type='hidden' name='url_valid_flag' id='url_valid_flag' value='0'>"; //for form validation of check boxes of tags, 0 for invalid url, 1 for valid url |
|
} |
|
|
|
|
|
function processArray($array,$parent_p) { |
|
|
|
global $count; |
|
|
|
$count++; //this variable is for calculating tab space |
|
$parent=$parent_p; |
|
if(is_array($array) === true) |
|
{ |
|
|
|
foreach($array as $key => $value) |
|
{ |
|
$parent_2=$parent_p; |
|
|
|
if(is_array($value)==true && is_numeric($key)!=true) // for getting the parent node name properly. |
|
{ |
|
$parent=$key; |
|
|
|
} |
|
|
|
if(is_array($value) === true) |
|
{ |
|
|
|
|
|
if(is_numeric($key) != true) // for displaying the parent node, just for reference. |
|
{ |
|
for($i = 1 ; $i < $count ; $i++) echo " "; //change this to space ' ' if running from CLI |
|
echo "<font color='red'>".$key."</font><br/>"; |
|
} |
|
|
|
$size=count($array); |
|
if(is_numeric($key)== true) // for not displaying the duplicates. |
|
{ |
|
|
|
for($j=0; $j<($size-1); $j++) |
|
{ |
|
|
|
array_pop($array); |
|
} |
|
} |
|
|
|
@processArray($array[$key],$parent); |
|
|
|
} |
|
else |
|
{ |
|
for($i = 1 ; $i < $count ; $i++) echo " "; |
|
|
|
echo "<input type='checkbox' name='tags[]' id='tags' value=".$key."_".$parent_2.">".$key."<br />"; |
|
} |
|
} |
|
} |
|
//echo "<font color=blue>".$parent_2."</font><br>"; |
|
|
|
$count--; |
|
} |
|
|
|
?> |