File size: 4.33Kb
<?php
/**
* @desc получение полного пути к папке
* @param $array
*/
function get_namepath ($directories_array, $delim = ' / ') {
if (empty($directories_array)) {
return;
}
foreach ($directories_array AS $directory) {
$directory_path[] = '<a href="index.php?id=' . $directory['id'] . '">' . $directory['name'] . '</a>';
}
if (count($directory_path) > 1) {
$realpath = array_reverse($directory_path);
$realpath = implode($delim, $realpath);
} else {
$realpath = $directory_path[0];
}
return $realpath;
}
/**
* @desc получение реального пути к папке
* @param $int
*/
function get_path ($directory_id, $directory_path = array (), $i = 0) {
$parent = DB::run()->queryFetch("SELECT * FROM downloads_category WHERE id = (SELECT id_parent FROM downloads_category WHERE id = ?)", array ($directory_id));
$i++;
if ($parent['id'] != 0) {
$directory_path[$i]['id'] = $parent['id'];
$directory_path[$i]['name'] = $parent['name'];
$directory_path = get_path($parent['id'], $directory_path, $i);
}
return $directory_path;
}
/**
* @desc получение полного пути к папке
* @param $array
*/
function get_realpath ($directories_array) {
if (empty($directories_array))
return;
foreach ($directories_array AS $directory) {
$directory_path[] = $directory['id'];
}
if (count($directory_path) > 1) {
$realpath = array_reverse($directory_path);
$realpath = implode('/', $realpath);
} else {
$realpath = $directory_path[0];
}
return $realpath;
}
function mp3info ($file) {
include_once ('Id.php');
// Создаем объект, читаем файл
$id3 = new MP3_Id();
$result = $id3->read($file);
$result = $id3->study();
// Читаем поля и выводим информацию
if (!empty($id3->artists)) {
echo '<b>Исполнитель:</b> ' . iconv('windows-1251', 'UTF-8', $id3->artists) . '<br />';
}
if (!empty($id3->album)) {
echo '<b>Альбом:</b> ' . iconv('windows-1251', 'UTF-8', $id3->album) . '<br />';
}
if (!empty($id3->year)) {
echo '<b>Год выхода:</b> ' . iconv('windows-1251', 'UTF-8', $id3->year) . '<br />';
}
if (!empty($id3->genre)) {
echo '<b>Жанр:</b> ' . iconv('windows-1251', 'UTF-8', $id3->genre) . '<br />';
}
if (!empty($id3->name)) {
echo '<b>Название:</b> ' . iconv('windows-1251', 'UTF-8', $id3->name) . '<br />';
}
if (!empty($id3->track)) {
echo '<b>Трэк:</b> ' . iconv('windows-1251', 'UTF-8', $id3->track) . '<br />';
}
if ($id3->getTag('bitrate')) {
echo '<b>Битрейт:</b> ' . $id3->getTag('bitrate') . ' kBit/sec <br /><b>Длительность:</b> ' . $id3->getTag('length') . '<br />';
}
}
/**
* @desc Рекурсивный подсчет файлов в папке
* @param $string
*/
function count_files ($directory_id) {
$files = DB::run()->querySingle("SELECT COUNT(*) FROM downloads_files WHERE category = ? AND file != ''", array ($directory_id));
$result = DB::run()->query("SELECT * FROM downloads_category WHERE id_parent = ?", array ($directory_id));
while ($cild_directory = $result->fetch()) {
$files += count_files($cild_directory['id']);
}
return $files;
}
function counts () {
$counts['count_files'];
$counts['new_day'];
$coun_file_db = DB::run()->querySingle("SELECT count(*) as count FROM downloads_files WHERE category = ?", array ($row['id']));
$coun_file = $coun_file_db['count'];
$coun_cat_db = DB::run()->querySingle("SELECT count(*) as count FROM downloads_category WHERE id_parent = ?", array ($row['id']));
$coun_cat = $coun_cat_db['count'];
if ($coun_file > 0 and $coun_cat > 0) {
$count = 'К: ' . $coun_cat . ' / Ф: ' . $coun_file;
} else {
if ($coun_file['count'] > 0) {
$count = 'Ф: ' . $coun_file;
} else {
if ($coun_cat['count'] > 0) {
$count = 'К: ' . $coun_cat;
} else {
$count = 'Пусто';
}
}
}
}