$word) { $where[$i] = 'locate("'.$word.'", concat(artist," - ",title))'; } } if ($_SESSION[':'.$id]['_POST']['count'] && $_SESSION[':'.$id]['_POST']['count'] < 100) $where[] = 'pos<='.$_SESSION[':'.$id]['_POST']['count']; $where = count($where) ? ' WHERE '.join(' AND ', $where) : ''; if ($_SESSION[':'.$id]['_POST']['search'] == 'by_date') { if ($_SESSION[':'.$id]['_POST']['date_mode'] == 'single' && $_SESSION[':'.$id]['_POST']['weeks']) { $having = ' HAVING date='.$_SESSION[':'.$id]['_POST']['weeks']; } elseif ($_SESSION[':'.$id]['_POST']['date_mode'] == 'multi' && $_SESSION[':'.$id]['_POST']['from_week']) { $having = ' HAVING date BETWEEN '. $_SESSION[':'.$id]['_POST']['from_week'].' AND '. $_SESSION[':'.$id]['_POST']['to_week']; } else $having = ''; } else $having = ''; $selectCols = join(',', array( $_SESSION[':'.$id]['_POST']['display'] == 'out' ? 'date+86400*7 AS date' : 'date', 'pos', 'artist', 'title', 'concat(artist," - ",title) as song' )); if ($_SESSION[':'.$id]['_POST']['display'] == 'out' || $_SESSION[':'.$id]['_POST']['count'] && $_SESSION[':'.$id]['_POST']['count'] < 100) { $subQuery = 'SELECT '.$selectCols.' FROM '.$table.$where; if ($_SESSION[':'.$id]['_POST']['display'] == 'out') $subQuery .= ' ORDER BY date desc'; } else $subQuery = false; $mysql_string = 'SELECT '.$selectCols.' FROM '; if ($subQuery) { $mysql_string .= '('.$subQuery.') AS '.$table; } else { $mysql_string .= $table.$where; } if ($_SESSION[':'.$id]['_POST']['display'] != 'all') $mysql_string .= ' GROUP BY song'; $mysql_string .= $having; $mysql_string .= sort_mysql('charts'); echo ''; $result = mysql_query($mysql_string); } else { unset($result); } ############################# # file search & data output # ############################# if (is_resource($result)) { include_mysql('/include/table'); $table = new Table('', array('name' => 'charts'), $cols); $fdirs = array(); while ($line = mysql_fetch_assoc($result)) { $line = str_ireplace($changeCase, $changeCase, $line); extract($line); // shall we search for items in the filesystem ? if (is_array($types)) { // beautify item for fs and split into words $song = preg_replace(array_keys($filenameSearch), array_values($filenameSearch), $artist.' '.$title); $song = convert($song, CHARSET, FS_CHARSET); // shouldn't need this anymore cuz we got utf8 fs $song = explode(' ', $song); foreach ($types as $h => $type) { if (!is_array($fdirs[$h])) $fdirs[$h] = array(); // print target dir for each file type given (music, video, ...) if ($h == 'album') { $subdir = date('y', $date).sprintf('%02d', date('W', $date)); } else { $year = date('y', $date); $month = date('n', $date); if ($month == 1) { $year -= 1; $month = 12; } else { $month -= 1; } $subdir = sprintf('%02d%02d', $year, $month); } $dirs = array(); if (!is_array($types[$h]['path'])) { $types[$h]['path'] = array($types[$h]['path']); } foreach ($types[$h]['path'] as $path) { if (!is_array($fdirs[$h][$path])) $fdirs[$h][$path] = array(); $dpath = $types[$h]['search_prefix'].$path.$subdir; $fpath = $types[$h]['ftp_prefix'].$path.$subdir; if (array_key_exists($subdir, $fdirs[$h][$path])) { $exist = (bool)$fdirs[$h][$path][$subdir]; $fpath = $fdirs[$h][$path][$subdir]; } elseif (strpos($path, '*') !== false) { $rpath = `ls -d $dpath | head -1`; if (isset($rpath)) { $exist = true; $fpath = str_replace($types[$h]['search_prefix'], $types[$h]['ftp_prefix'], $rpath); } else { $exist = false; } } else { $exist = file_exists($dpath); } if ($exist) { $dirs[] = ' '.$subdir.''; } else { /* $dirs[] = ' '.$subdir.''; */ } if (!array_key_exists($subdir, $fdirs[$h][$path])) $fdirs[$h][$path][$subdir] = $exist ? $fpath : false; } $types[$h]['dirs'] = join('
', $dirs); // search for each file type given (music, video, ...) ob_flush(); flush(); $cmd_result = ''; $types[$h]['locate'] = ''; foreach ($types[$h]['path'] as $path) { $count = substr_count($types[$h]['search_prefix'].$path, '/') + 1; $path = str_replace('/*/', '/', $path); $cmd = 'locate -d /share/common/users/fisch/media.database -i '. $types[$h]['search_prefix'].$path.' | egrep \'^(/[^/]+){'.$count.'}$\''; foreach ($song as $word) { $cmd .= " | grep -i \"$word\""; } echo ' '; $cmd_result = `$cmd 2>&1`; $_locate = explode(chr(10), $cmd_result); for ($i = 0; $i < count($_locate); $i++) { if ($_locate[$i]) { if (file_exists($_locate[$i])) { if ($h == 'album') { $arg = escapeshellarg($_locate[$i]); $size = `du -bs $arg`; } else { $size = filesize($_locate[$i]); } $size /= 1048576; $mtime = date('d.m.Y H:i:s', filemtime($_locate[$i])); $_locate[$i] = substr($_locate[$i], strlen($types[$h]['search_prefix']. $path)); $_locate[$i] = htmlentities( $_locate[$i], ENT_COMPAT, FS_CHARSET); $_locate[$i] = ' '.$_locate[$i].''; } else { $_locate[$i] = ' '.$_locate[$i].''; } } } $types[$h]['locate'] .= join('
', $_locate); } } } if ($_SESSION[':'.$id]['_POST']['esel']) { $song = preg_replace(array_keys($eselSearch), array_values($eselSearch), $line['artist'].' '.$line['title']); $uri = '/esel/submit?custom=Complex+Search'. '&keywords='.urlencode($song). '&minsize=&minsize_unit=1048576&maxsize='. '&maxsize_unit=1048576&media=&media_propose=&format='. '&format_propose=&artist=&album=&title=&bitrate=&network='; $link = array( '', ''); } else { $link = array('', ''); } $line = array(); $line[] = date('d.m.Y', $date); # $date = date('y', $date).'/'.sprintf('%02d', date('W', $date)); # $line[] = ''.$date.''; $line[] = $pos; // do some conversions when viewing items as filenames if ($_SESSION[':'.$id]['_POST']['cap']) { $song = preg_replace(array_keys($filenameView), array_values($filenameView), $artist.' - '.$title); $line[] = $link[0].htmlentities($song, ENT_COMPAT, CHARSET). (($_SESSION[':'.$id]['_POST']['type'] == 'single') ? '.mp3' : '').$link[1]; } else { $line[] = $link[0].htmlentities($artist, ENT_COMPAT, CHARSET). $link[1]; $line[] = $link[0].htmlentities($title, ENT_COMPAT, CHARSET). $link[1]; } if (is_array($types)) { foreach ($types as $key => $type) { $line[] = $type['dirs']; $line[] = $type['locate']; /* d = dir ('/var/ftp/pub/media/music/alben/'.$date); $dir = ''; while (false !== ($entry = $d->read())) { if ($entry != '.' && $entry != '..') { $dir .= $entry."
\n"; } } */ #$line[] = $dir; $song = preg_replace(array_keys($filenameView), array_values($filenameView), $artist.' - '.$title); #$line[] = 'move "'.$song.'" '.$date; } } // forget item if nothing found and 'show files only' checked if (!$_SESSION[':'.$id]['_POST']['show_files_only'] || !$type['locate']) { $table->drawLine(array('data' => $line)); } } unset($table); // draw table footer echo ' '; // ... and if we didn't get anything at all :-( } else { echo '
keine ergebnisse
'; }


Dieser Skript wurde 6880 mal aufgerufen. Letztes Update vor 4804 Tagen, 7 Stunden, 11 Minuten und 16 Sekunden. Die Ausführung dauerte etwa 113221 µs. by | impressum