I am using this code to write an xml file which can be viewed here
<!-- m --><a class="postlink" href="http://studioauditions.com/studio_auditions_gallery.php">http://studioauditions.com/studio_auditions_gallery.php</a><!-- m -->
must view source to see xml file obviously....
In php4 it all worked perfectly and pulled it all together in alphabetical order.
Now my host has upgraded to php5 and the weird thing is that the code no longer makes the xml file alphabetical, but reads through the directory structure in two chunks...alphabetical for date created of 2006, and then again as alphabetical for date created of 2007....
YOu can see what I am talking about in effect at
<!-- m --><a class="postlink" href="http://studioauditions.com/jamroomsessions.php">http://studioauditions.com/jamroomsessions.php</a><!-- m --> -- notice the manufacturer list is generrated perfectly...but its not alphabetical at the bottom of the list....
and I added the four folders that are out of order yesterday --- so they are sorting as 2007's and are alphabetical for theese 4, but not as a whole list...
Is there something I could add to the code below to get the list to be created in alphabetical order again?
It should theoretically make the xml file to then use in the flash file on the site...it was working perfectly for six months in 2006....these are the first folders and clips I have added in 2007....
To my knowledge this code just reads the file/folder structure as its listed on the server...but on the server in filezilla and dreamweaver, the structure sorts alphabetically just fine....so there are no hidden characters or anything....
<?php
echo('<?xml version="1.0" ?>' . "\n");
// _xmltree.php a utiliity to produce an XML directory tree
$directory=$_GET['d'];
$rh = fopen('_xmltree.txt', 'w');
global $rh;
//echo "<pre> \n";
// Argument is where list should start ./ = current directory
directory_list("./audio/".$directory,'');
//echo "</pre> \n";
function directory_list($address, $level, $tabs='') {
global $rh;
if ($handle = opendir($address)) {
$tabs .= "\t";
while (false !== ($file = readdir($handle))) {
if (is_dir("$address$file") && strpos($file, ".") !== 0) {
if (0 == strncmp($file, "_", 1)) continue;
$fileStrippedManuf = str_replace("_", " ", $file);
fwrite($rh, $tabs.'<'.$file.' label="'.$fileStrippedManuf.'" folder="'.$file.'">'."\n");
echo $tabs.' <'.$file. ' label="'.$fileStrippedManuf.'" folder="'.$file.'">'."\n";
directory_list("$address$file/", $file, $tabs); // Makes Listing Recursive
}
}
rewinddir ($handle);
while (false !== ($file = readdir($handle))) {
$URL = $address . $file;
if (is_dir("$URL") || strpos($file, ".") === 0) continue;
if (0 == strncmp($file, "_", 1)) continue;
//$fileStripped = rtrim($file , ".mp3");
$fileStrippedFirst = rtrim($file , "mp3" );
$fileStrippedSecond = rtrim($fileStrippedFirst, "." );
$fileStripped = $fileStrippedSecond;
$fileStrippedLabel = "default label";
//Will need to come back here and add all the source sample names when Shane gets them to me.
//The Compressor Section will have a more elaborate logic tree here.
//Something like - - - "Male_Vocal_Light" then label = "Male Vocal Light"
//HOWEVER, the preamps section might be trickier after I discuss with Shane.
if (substr_count($fileStripped, "Omni_Acoustic_Guitar") == 1) {
$fileStrippedLabel = "Omni-Acoustic";
} else if (substr_count($fileStripped, "0mni_Acoustic_Guitar") == 1) {
$fileStrippedLabel = "Omni-Acoustic";
} else if (substr_count($fileStripped, "Hyper_Acoustic_Guitar") == 1) {
$fileStrippedLabel = "Hyper-Acoustic";
} else if (substr_count($fileStripped, "Acoustic_Guitar") == 1) {
$fileStrippedLabel = "Acoustic Guitar";
} else if (substr_count($fileStripped, "Kickpad_Kick") == 1) {
$fileStrippedLabel = "Kickpad-Kick";
} else if (substr_count($fileStripped, "Hyper_Clean_Guitar") == 1) {
$fileStrippedLabel = "Hyper-Clean";
} else if (substr_count($fileStripped, "Clean_Guitar") == 1) {
$fileStrippedLabel = "Clean Guitar";
} else if (substr_count($fileStripped, "Hyper_Distorted_Guitar") == 1) {
$fileStrippedLabel = "Hyper-Distorted";
} else if (substr_count($fileStripped, "Distorted_Guitar") == 1) {
$fileStrippedLabel = "Distorted Guitar";
} else if (substr_count($fileStripped, "Omni_Acoustic_Guitar") == 1) {
$fileStrippedLabel = "Omni Acoustic";
} else if (substr_count($fileStripped, "Male_Vocal") == 1) {
$fileStrippedLabel = "Male Vocal";
} else if (substr_count($fileStripped, "Female_Vocal") == 1) {
$fileStrippedLabel = "Female Vocal";
} else if (substr_count($fileStripped, "Hip-Hop_Vocal") == 1) {
$fileStrippedLabel = "Hip-Hop Vocal";
} else if (substr_count($fileStripped, "Piano") == 1) {
$fileStrippedLabel = "Piano";
} else if (substr_count($fileStripped, "Brass") == 1) {
$fileStrippedLabel = "Brass";
} else if (substr_count($fileStripped, "Drum_Overheads") == 1) {
$fileStrippedLabel = "Drum Overheads";
} else if (substr_count($fileStripped, "Snare") == 1) {
$fileStrippedLabel = "Snare";
} else if (substr_count($fileStripped, "Kick") == 1) {
$fileStrippedLabel = "Kick";
} else if (substr_count($fileStripped, "Toms") == 1) {
$fileStrippedLabel = "Toms";
} else if (substr_count($fileStripped, "Tom") == 1) {
$fileStrippedLabel = "Tom";
} elseif (substr_count($fileStripped, "High-Hat") == 1) {
$fileStrippedLabel = "High-Hat";
} elseif (substr_count($fileStripped, "Hyper_Overheads") == 1) {
$fileStrippedLabel = "Hyper-Overheads";
} elseif (substr_count($fileStripped, "Omni_Overheads") == 1) {
$fileStrippedLabel = "Omni-Overheads";
} elseif (substr_count($fileStripped, "Overheads") == 1) {
$fileStrippedLabel = "Drum Overheads";
} else {
$fileStrippedLabel = $fileStripped;
}
$fileStrippedLabelModel = str_replace("_", " ", $file);
fwrite($rh, '<sample label="'.$fileStrippedLabel.'" audio="'.$file.'" image="'.$fileStripped.'.jpg" flashampvar="'.$fileStripped.'.txt" />'."\n");
echo $tabs.' <sample label="'.$fileStrippedLabel.'" audio="'.$file. '" image="'.$fileStripped.'.jpg" flashampvar="'.$fileStripped.'.txt" />';
}
closedir($handle);
$tabs = substr($tabs,0,strlen($tabs)-1);
if($level != '')
{
fwrite($rh, $tabs."</$level>\n");
echo $tabs.'</'.$level.'>'."\n";
}
}
}
?>
<!-- m --><a class="postlink" href="http://studioauditions.com/studio_auditions_gallery.php">http://studioauditions.com/studio_auditions_gallery.php</a><!-- m -->
must view source to see xml file obviously....
In php4 it all worked perfectly and pulled it all together in alphabetical order.
Now my host has upgraded to php5 and the weird thing is that the code no longer makes the xml file alphabetical, but reads through the directory structure in two chunks...alphabetical for date created of 2006, and then again as alphabetical for date created of 2007....
YOu can see what I am talking about in effect at
<!-- m --><a class="postlink" href="http://studioauditions.com/jamroomsessions.php">http://studioauditions.com/jamroomsessions.php</a><!-- m --> -- notice the manufacturer list is generrated perfectly...but its not alphabetical at the bottom of the list....
and I added the four folders that are out of order yesterday --- so they are sorting as 2007's and are alphabetical for theese 4, but not as a whole list...
Is there something I could add to the code below to get the list to be created in alphabetical order again?
It should theoretically make the xml file to then use in the flash file on the site...it was working perfectly for six months in 2006....these are the first folders and clips I have added in 2007....
To my knowledge this code just reads the file/folder structure as its listed on the server...but on the server in filezilla and dreamweaver, the structure sorts alphabetically just fine....so there are no hidden characters or anything....
<?php
echo('<?xml version="1.0" ?>' . "\n");
// _xmltree.php a utiliity to produce an XML directory tree
$directory=$_GET['d'];
$rh = fopen('_xmltree.txt', 'w');
global $rh;
//echo "<pre> \n";
// Argument is where list should start ./ = current directory
directory_list("./audio/".$directory,'');
//echo "</pre> \n";
function directory_list($address, $level, $tabs='') {
global $rh;
if ($handle = opendir($address)) {
$tabs .= "\t";
while (false !== ($file = readdir($handle))) {
if (is_dir("$address$file") && strpos($file, ".") !== 0) {
if (0 == strncmp($file, "_", 1)) continue;
$fileStrippedManuf = str_replace("_", " ", $file);
fwrite($rh, $tabs.'<'.$file.' label="'.$fileStrippedManuf.'" folder="'.$file.'">'."\n");
echo $tabs.' <'.$file. ' label="'.$fileStrippedManuf.'" folder="'.$file.'">'."\n";
directory_list("$address$file/", $file, $tabs); // Makes Listing Recursive
}
}
rewinddir ($handle);
while (false !== ($file = readdir($handle))) {
$URL = $address . $file;
if (is_dir("$URL") || strpos($file, ".") === 0) continue;
if (0 == strncmp($file, "_", 1)) continue;
//$fileStripped = rtrim($file , ".mp3");
$fileStrippedFirst = rtrim($file , "mp3" );
$fileStrippedSecond = rtrim($fileStrippedFirst, "." );
$fileStripped = $fileStrippedSecond;
$fileStrippedLabel = "default label";
//Will need to come back here and add all the source sample names when Shane gets them to me.
//The Compressor Section will have a more elaborate logic tree here.
//Something like - - - "Male_Vocal_Light" then label = "Male Vocal Light"
//HOWEVER, the preamps section might be trickier after I discuss with Shane.
if (substr_count($fileStripped, "Omni_Acoustic_Guitar") == 1) {
$fileStrippedLabel = "Omni-Acoustic";
} else if (substr_count($fileStripped, "0mni_Acoustic_Guitar") == 1) {
$fileStrippedLabel = "Omni-Acoustic";
} else if (substr_count($fileStripped, "Hyper_Acoustic_Guitar") == 1) {
$fileStrippedLabel = "Hyper-Acoustic";
} else if (substr_count($fileStripped, "Acoustic_Guitar") == 1) {
$fileStrippedLabel = "Acoustic Guitar";
} else if (substr_count($fileStripped, "Kickpad_Kick") == 1) {
$fileStrippedLabel = "Kickpad-Kick";
} else if (substr_count($fileStripped, "Hyper_Clean_Guitar") == 1) {
$fileStrippedLabel = "Hyper-Clean";
} else if (substr_count($fileStripped, "Clean_Guitar") == 1) {
$fileStrippedLabel = "Clean Guitar";
} else if (substr_count($fileStripped, "Hyper_Distorted_Guitar") == 1) {
$fileStrippedLabel = "Hyper-Distorted";
} else if (substr_count($fileStripped, "Distorted_Guitar") == 1) {
$fileStrippedLabel = "Distorted Guitar";
} else if (substr_count($fileStripped, "Omni_Acoustic_Guitar") == 1) {
$fileStrippedLabel = "Omni Acoustic";
} else if (substr_count($fileStripped, "Male_Vocal") == 1) {
$fileStrippedLabel = "Male Vocal";
} else if (substr_count($fileStripped, "Female_Vocal") == 1) {
$fileStrippedLabel = "Female Vocal";
} else if (substr_count($fileStripped, "Hip-Hop_Vocal") == 1) {
$fileStrippedLabel = "Hip-Hop Vocal";
} else if (substr_count($fileStripped, "Piano") == 1) {
$fileStrippedLabel = "Piano";
} else if (substr_count($fileStripped, "Brass") == 1) {
$fileStrippedLabel = "Brass";
} else if (substr_count($fileStripped, "Drum_Overheads") == 1) {
$fileStrippedLabel = "Drum Overheads";
} else if (substr_count($fileStripped, "Snare") == 1) {
$fileStrippedLabel = "Snare";
} else if (substr_count($fileStripped, "Kick") == 1) {
$fileStrippedLabel = "Kick";
} else if (substr_count($fileStripped, "Toms") == 1) {
$fileStrippedLabel = "Toms";
} else if (substr_count($fileStripped, "Tom") == 1) {
$fileStrippedLabel = "Tom";
} elseif (substr_count($fileStripped, "High-Hat") == 1) {
$fileStrippedLabel = "High-Hat";
} elseif (substr_count($fileStripped, "Hyper_Overheads") == 1) {
$fileStrippedLabel = "Hyper-Overheads";
} elseif (substr_count($fileStripped, "Omni_Overheads") == 1) {
$fileStrippedLabel = "Omni-Overheads";
} elseif (substr_count($fileStripped, "Overheads") == 1) {
$fileStrippedLabel = "Drum Overheads";
} else {
$fileStrippedLabel = $fileStripped;
}
$fileStrippedLabelModel = str_replace("_", " ", $file);
fwrite($rh, '<sample label="'.$fileStrippedLabel.'" audio="'.$file.'" image="'.$fileStripped.'.jpg" flashampvar="'.$fileStripped.'.txt" />'."\n");
echo $tabs.' <sample label="'.$fileStrippedLabel.'" audio="'.$file. '" image="'.$fileStripped.'.jpg" flashampvar="'.$fileStripped.'.txt" />';
}
closedir($handle);
$tabs = substr($tabs,0,strlen($tabs)-1);
if($level != '')
{
fwrite($rh, $tabs."</$level>\n");
echo $tabs.'</'.$level.'>'."\n";
}
}
}
?>