Здравствуйте! Битый час мучаюсь с менюшкой флеш-галереи. Суть такова, что название пунктов навигации берётся из названий папок, но т.к. название папок на кириллице, выходит такая абракадабра. Подскажите пожалуйста как можно решить сей проблему.
Код выглядит следующим образом (путь находится в переменной $path, а далее в $data_folder если я всё правильно понял):
и
Пробовал по всякому, менял кодировки переменных с помощью функции перекодировки из windows-1251 в utf-8: $path=win_utf8($path) и $data_folder=win_utf8($data_folder), но безрезультатно. Что я делаю не так?
Код выглядит следующим образом (путь находится в переменной $path, а далее в $data_folder если я всё правильно понял):
Код:
<?PHP
//get path to gallery
$path = isset($_GET["p"]) ? $_GET["p"] : "";
echo "<data>" . chr(13);
$ignore = array('.', '..' );
// Directories to ignore when listing output. Many hosts
// will deny PHP access to the cgi-bin.
$dh = @opendir( $path . "/_thumbs" );
while( false !== ( $file = readdir( $dh ) ) ){
// Loop through the directory
if( !in_array( $file, $ignore ) ){
// Check that this file is not to be ignored
// get images
if( !is_dir( "$path/_thumbs/$file" ) ){
//print out xml
echo '<image file="' . $file . '" />' . chr(13);
}
}
}
closedir( $dh );
// Close the directory handle
echo '</data>';
?>
Код:
<?PHP
require_once("config.php");
//creates xml data for navigation structure of fig
echo '<root name="Галерея" path="' . $data_folder . '">' . chr(13);
getDirectory("$data_folder");
function getDirectory( $path = '.'){
$ignore = array('.', '..' );
// Directories to ignore when listing output. Many hosts
// will deny PHP access to the cgi-bin.
$dh = @opendir( $path );
// Open the directory to the handle $dh
while( false !== ( $file = readdir( $dh ) ) ){
// Loop through the directory
if( !in_array( $file, $ignore ) ){
// Check that this file is not to be ignored
// show the directory tree.
if( is_dir( "$path/$file" ) ){
// Its a directory, is it a folder or a gallery
if(!file_exists("$path/$file/_thumbs")){
//directory is a folder
echo '<folder path="' . $file . '">' . chr(13);
getDirectory("$path/$file");
echo '</folder>' . chr(13);
}
}
}
}
$dh = @opendir( $path );
while( false !== ( $file = readdir( $dh ) ) ){
// Loop through the directory
if( !in_array( $file, $ignore ) ){
// Check that this file is not to be ignored
// show the directory tree.
if( is_dir( "$path/$file" ) ){
// Its a directory, is it a folder or a gallery
if(file_exists("$path/$file/_thumbs")){
//the directory has a folder for thumbnails, it's a gallery
echo '<gallery path="' . $file . '" />' . chr(13);
}
}
}
}
closedir( $dh );
// Close the directory handle
}
echo '</root>';
?>