include 'admin/xml.php';
$dir = realPath("xml");
$canReadDir = true;
//define variables
$message = "";
global $xmlContent;
global $tempXMLContent;
$xmlContent= array();
$counter = 0;
$couponsPerRow = 2;
?>

|
|
 |
|
//read xml directory
if( is_dir( $dir ) ){
if( $dh = opendir( $dir )){
while (($file = readdir($dh)) !== false) {
if( is_file( $dir."/".$file ) ){
//for each file reads title
$filenameXML = $dir."/".$file;
$title = $file;
//try to open XML file
if( !($xmlText = file_get_contents( $filenameXML ) ) ){
$title = "Unable to read coupon";
}
else{
//creates XML parser and assigns handlers
$xmlParser = xml_parser_create("ISO-8859-1");
xml_set_element_handler( $xmlParser, "openElement", "closeElement" );
xml_set_character_data_handler( $xmlParser, "XMLData" );
//parse XML data
if( !xml_parse( $xmlParser, $xmlText, TRUE ) ){
$title = "Unable to parse coupon";
}
else{
$title = $xmlContent["title"];
}
}
//if is first coupon or the row must end
if( $counter==0 ){
?>
}
//if we have enough coupons for the row
else if( ($counter%$couponsPerRow)==0 ){
?>
}
?>
|
|
$counter++;
}
}
closedir( $dh );
}
}
//there is no coupons?
if( $counter==0 ){
?>
| The list is empty |
}
else{
?>
}
?>
|
|
|
|