example) function string_to_array($string) { $retval = array(); $string = urldecode($string); $tmp_array = explode('||', $string); $null_value = urlencode(base64_encode("^^^")); foreach ($tmp_array as $tmp_val) { list($index, $value) = explode('|', $tmp_val); $decoded_index = base64_decode(urldecode($index)); if($value != $null_value) $retval[$decoded_index] = base64_decode(urldecode($value)); else $retval[$decoded_index] = NULL; } return $retval; } /** * Parses the config files in the dirs and returns a hash-array * with config-settings: * FolderName, Title, Comment, Date and "New" label duration from * Text file 'config.txt' * * @param String $dirs directories where config will be searched * @param String $place * @return unknown */ function parseConfig($dirs, $place) { $allAlbumData = array(); foreach($dirs as $currentAlbDir){ //store each dir in currentAlbDir $configPath = $place.$currentAlbDir."/aconf.txt"; $albumSettings = array(); if (file_exists($configPath)){ //store the content from 'config.txt' in the string $configContent $configContent = trim(file_get_contents($configPath)); // first try if there are multiple lines, then try with ... seperator $splitOptions = array( "\n","..."); foreach ($splitOptions as $seperator ) { $parts = explode($seperator,$configContent); if ( count ( $parts) >= 2) { $albumSettings = array_merge( $albumSettings, $parts); break; } } } // if there wasn't foudn a good configuration (maybe the file is empty) if ( count ( $albumSettings) == 0) { // use Directory Name instead $date = date ( "d. F Y", filemtime($place.$currentAlbDir)); $name = str_replace(array(".", "_"), " ", $currentAlbDir); $albumSettings[] = $name; $albumSettings[] = $name; $albumSettings[] = $date; $albumSettings[] = 5; } // add album name at first position of config array array_unshift($albumSettings, $currentAlbDir); $allAlbumData[$currentAlbDir] = $albumSettings; } return $allAlbumData; } /** * Returns all files of a directory * * @param String $subDir * @param String $noSubDir * @return Array file list */ function getDirContent($subDir,$noSubDir){ if($noSubDir != 1) $subDir = "../".$subDir; $openSubDir = opendir("$subDir"); $myPics = array(); while($curFile=readdir($openSubDir)){ $chkImage = @getimagesize($subDir."/".$curFile); if($chkImage[2]==2) //2=JPG array_push($myPics, $curFile); } closedir($openSubDir); array_multisort($myPics, SORT_ASC); return $myPics; } function getAlbumDirs($subDir = "../"){ $excludeDirectories = array( "app", "thumbs", "CVS", "comments"); $myDirs = array(); $openSubDir = opendir($subDir); while($curItem=readdir($openSubDir)){ if ( in_array( $curItem , $excludeDirectories ) ) continue; $curItemFullPath = $subDir."/".$curItem; if(is_dir($curItemFullPath) //&& file_exists($curItemFullPath."/aconf.txt") && $curItem != "." && $curItem != "..") array_push($myDirs, $curItem); } closedir($openSubDir); array_multisort($myDirs, SORT_DESC); return $myDirs; } function getAlbums(){ return getAlbumDirs(".."); } function getPicNr($albumName, $picName){ $albPics = getDirContent($albumName,2); $picNr = 0; for($i=0;$i < count($albPics);$i++){ if($albPics[$i]==$picName){ $picNr = $i; break; } } return $picNr; } function isLandscape($albumname, $pic, $subPath){ $picSize = @getimagesize($subPath.$albumname."/".$pic); if($picSize[0] < $picSize[1]){ return 2; //landscape=false }else{ return 1; //landscape=true } } function formatCommentText($Name, $Comment){ $replace = array (";" => "" , "'" => "" , "(" => "" , ")" => ""); $Name = strtr($Name, $replace); $Comment = strtr($Comment, $replace); $Name = trim(strip_tags($Name)); $Comment = trim(strip_tags($Comment)); return formatCommentText($Name, $Comment); } function switch2bw($from){ $se_bw = $_SESSION[grayscale]; if($se_bw == 1 or $se_bw == 2){ $_SESSION[grayscale] = 0; $_SESSION[thumb_oriSize] = 1; }else{ $_SESSION[grayscale] = 2; $_SESSION[thumb_oriSize] = 0; } header("Location: ".$_SERVER['HTTP_REFERER']); } ?>