require_once('albumutil.php'); require_once('photoutil.php'); $id_str = $_GET['id']; $id_arr = explode('_', $id_str); if (3 !== count($id_arr) || ('photo' !== $id_arr[0] && 'video' !== $id_arr[0])) { $error = true; } $albumName = @pack('H*', $id_arr[1]); $fileName = @pack('H*', $id_arr[2]); $path = SYNOPHOTO_SERVICE_REAL_DIR . "/" . ("/" === $albumName ? "" : $albumName . "/") . $fileName; $item = checkVideoAvailable($albumName, $path, $id_arr[0]); if ($item) { $quality = findQualityObject($item['additional']['video_quality'], $_GET['quality']); $quality_id = $quality['id']; $videoType = $quality['container']; $videoProfile = $quality['profile_name']; $video = SYNOPHOTO_URL_PREFIX . "/photo/webapi/download.php/1.mp4?api=SYNO.PhotoStation.Download&method=getvideo&version=1&id=$id_str&quality_id=$quality_id"; $image = SYNOPHOTO_URL_PREFIX . "/photo/webapi/thumb.php?api=SYNO.PhotoStation.Thumb&method=get&version=1&id=$id_str&size=large"; $title = $item['info']['title'].' - '. __(photo_str_ap_name_6); } else { $title = __(photo_str_ap_name_6); } function findQualityObject ($videoQuality, $qualityProfileName) { if (!$videoQuality) { return null; } foreach ($videoQuality as $i) { if ($qualityProfileName == $i['profile_name']) { return $i; } } usort($videoQuality, function($a, $b) { $profileOrder = Array('high'=>0, 'medium'=>1, 'low'=>2, 'orig_h264'=>3, 'mobile'=>4, 'flv'=>5); return $profileOrder[$a['profile_name']] > $profileOrder[$b['profile_name']] ? 1 : -1; }); return $videoQuality[0]; } function checkVideoAvailable ($albumName, $path, $type) { if (!csSynoPhotoMisc::CheckPathValid($path)) { return false; } csSYNOPhotoDB::GetDBInstance()->SetSessionCache(); if (!csSYNOPhotoMisc::CheckAlbumAccessible($albumName)) { return false; } if (@file_exists($path)) { if (!($item = PhotoAPIUtil::getItemByPath($path, array('video_quality'), $type, false))) { return false; } } return $item; } ?>