function show_dir($dir, $pos = '', $files = array()) { global $gallery_config, $results, $images_per_loop, $albums_tree, $city_ids, $club_ids; $handle = @opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false && $images_per_loop < 10) { if (preg_match('~^\\.{1,2}$~', $file)) { continue; } $album_path = substr($dir . $file, strripos($dir . $file, 'massimport/') + 11); $album_path = explode('/', $album_path); if (is_dir($dir . $file)) { if (isset($album_path[0])) { //echo $album_path[0] . '/'; if (!isset($albums_tree[$album_path[0]])) { // Create album - City $parent_id = 0; $album = create_new_album($parent_id, $album_path[0], ALBUM_CAT); $albums_tree[$album_path[0]] = array(); $city_ids[$album_path[0]] = $album; } } if (isset($album_path[1])) { //echo $album_path[1] . '/'; if (!isset($albums_tree[$album_path[0]][$album_path[1]])) { // Create album - City > Club $parent_id = $city_ids[$album_path[0]]['album_id']; $album = create_new_album($parent_id, $album_path[1], ALBUM_CAT); $albums_tree[$album_path[0]][$album_path[1]] = array(); $club_ids[$album_path[0]][$album_path[1]] = $album; } } if (isset($album_path[2])) { //echo $album_path[2] . '/'; if (!isset($albums_tree[$album_path[0]][$album_path[1]][$album_path[2]])) { // Create album - City > Club > Date $parent_id = $club_ids[$album_path[0]][$album_path[1]]['album_id']; $album = create_new_album($parent_id, $album_path[2], ALBUM_UPLOAD); $albums_tree[$album_path[0]][$album_path[1]][$album_path[2]] = $album; } //echo ' ' . $albums_tree[$album_path[0]][$album_path[1]][$album_path[2]]; } //echo '<br />'; $files = show_dir($dir . $file . '/', $dir . $file, $files); } else { //echo substr($pos, strpos($pos, '/') + 1) . '/' . $file . '<br />'; if (substr(strtolower($file), '-4') == '.png' && $gallery_config['png_allowed'] || substr(strtolower($file), '-4') == '.gif' && $gallery_config['gif_allowed'] || substr(strtolower($file), '-4') == '.jpg' && $gallery_config['jpg_allowed']) { if ($images_per_loop < 10) { $results[] = utf8_encode($pos . '/' . $file); $images_per_loop++; } } } } closedir($handle); } return $files; }
function check_album($album, $albumai, $albumuri, $image, $date, $searched, $imagekey, $mbid, $domain, $upflag) { global $album_created; $index = null; $year = null; $img = null; if ($stmt = sql_prepare_query("SELECT Albumindex, Year, Image, AlbumUri FROM Albumtable WHERE LOWER(Albumname) = LOWER(?)" . " AND AlbumArtistindex = ? AND Domain = ?", $album, $albumai, $domain)) { $obj = $stmt->fetch(PDO::FETCH_OBJ); $index = $obj ? $obj->Albumindex : 0; if ($index) { $year = $obj->Year; $img = $obj->Image; $sl = $obj->AlbumUri; if ($year == null && $date != null || ($img == null || ($img = "")) && ($image != "" && $image != null) || $sl == null && $albumuri != null) { debuglog("Updating Details For Album " . $album, "MYSQL", 7); if ($up = sql_prepare_query("UPDATE Albumtable SET Year=?, Image=?, AlbumUri=? WHERE Albumindex=?", $date, $image, $albumuri, $index)) { debuglog(" ...Success", "MYSQL", 9); } else { debuglog(" Album " . $album . " update FAILED", "MYSQL", 3); return false; } } if ($upflag) { if ($result = generic_sql_query("SELECT COUNT(TTindex) AS num FROM Tracktable WHERE Albumindex = " . $index . " AND Hidden = 0 AND isSearchResult < 2 AND Uri IS NOT NULL")) { $obj = $result->fetch(PDO::FETCH_OBJ); if ($obj->num == 0) { $album_created = $index; debuglog("We're using album " . $album . " that was previously invisible", "MYSQL", 6); } } } } else { $index = create_new_album($album, $albumai, $albumuri, $image, $date, $searched, $imagekey, $mbid, $domain); } } return $index; }