public static function getPresentations() { $presentations = array(); $list = \OC_FileCache::searchByMime('application', 'zip'); foreach ($list as $l) { $info = pathinfo($l); $size = \OC_Filesystem::filesize($l); $mtime = \OC_Filesystem::filemtime($l); $entry = array('url' => $l, 'name' => $info['filename'], 'size' => $size, 'mtime' => $mtime); $presentations[] = $entry; } return $presentations; }
/** * get the filesystem info * @param string path * @return array * * returns an associative array with the following keys: * - size * - mtime * - ctime * - mimetype * - encrypted * - versioned */ public static function getFileInfo($path) { if (($path == '/Shared' || substr($path, 0, 8) == '/Shared/') && OC_App::isEnabled('files_sharing')) { if ($path == '/Shared') { list($info) = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP_ROOT); } else { $info['size'] = OC_Filesystem::filesize($path); $info['mtime'] = OC_Filesystem::filemtime($path); $info['ctime'] = OC_Filesystem::filectime($path); $info['mimetype'] = OC_Filesystem::getMimeType($path); $info['encrypted'] = false; $info['versioned'] = false; } } else { $info = OC_FileCache::get($path); } return $info; }
* This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ // Init owncloud // Check if we are a user OCP\JSON::checkLoggedIn(); // Set the session key for the file we are about to edit. $dir = isset($_GET['dir']) ? $_GET['dir'] : ''; $filename = isset($_GET['file']) ? $_GET['file'] : ''; if (!empty($filename)) { $path = $dir . '/' . $filename; if (OC_Filesystem::is_writable($path)) { $mtime = OC_Filesystem::filemtime($path); $filecontents = OC_Filesystem::file_get_contents($path); $filecontents = iconv(mb_detect_encoding($filecontents), "UTF-8", $filecontents); OCP\JSON::success(array('data' => array('filecontents' => $filecontents, 'write' => 'true', 'mtime' => $mtime))); } else { $mtime = OC_Filesystem::filemtime($path); $filecontents = OC_Filesystem::file_get_contents($path); $filecontents = iconv(mb_detect_encoding($filecontents), "UTF-8", $filecontents); OCP\JSON::success(array('data' => array('filecontents' => $filecontents, 'write' => 'false', 'mtime' => $mtime))); } } else { OCP\JSON::error(array('data' => array('message' => 'Invalid file path supplied.'))); }
/** * Returns the last modification time, as a unix timestamp * * @return int */ public function getLastModified() { return OC_Filesystem::filemtime($this->path); }
ob_end_clean(); $ftype = OC_Filesystem::getMimeType($arguments['path']); $songId = OC_MEDIA_COLLECTION::getSongByPath($arguments['path']); OC_MEDIA_COLLECTION::registerPlay($songId); header('Content-Type:' . $ftype); // calc an offset of 24 hours $offset = 3600 * 24; // calc the string in GMT not localtime and add the offset $expire = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT"; //output the HTTP header header($expire); header('Cache-Control: max-age=3600, must-revalidate'); header('Pragma: public'); header('Accept-Ranges: bytes'); header('Content-Length: ' . OC_Filesystem::filesize($arguments['path'])); $gmt_mtime = gmdate('D, d M Y H:i:s', OC_Filesystem::filemtime($arguments['path'])) . ' GMT'; header("Last-Modified: " . $gmt_mtime); OC_Filesystem::readfile($arguments['path']); exit; case 'find_music': OC_JSON::encodedPrint(findMusic()); exit; } } function findMusic($path = '') { $music = array(); $dh = OC_Filesystem::opendir($path); if ($dh) { while ($filename = readdir($dh)) { if ($filename[0] != '.') {
$song['album'] = OC_MEDIA_COLLECTION::getAlbumName($song['song_album']); OCP\JSON::encodedPrint($song); } } break; case 'play': @ob_end_clean(); $ftype = OC_Filesystem::getMimeType($arguments['path']); if (substr($ftype, 0, 5) != 'audio' and $ftype != 'application/ogg') { echo 'Not an audio file'; exit; } $songId = OC_MEDIA_COLLECTION::getSongByPath($arguments['path']); OC_MEDIA_COLLECTION::registerPlay($songId); header('Content-Type:' . $ftype); OCP\Response::enableCaching(3600 * 24); // 24 hour header('Accept-Ranges: bytes'); header('Content-Length: ' . OC_Filesystem::filesize($arguments['path'])); $mtime = OC_Filesystem::filemtime($arguments['path']); OCP\Response::setLastModifiedHeader($mtime); OC_Filesystem::readfile($arguments['path']); exit; case 'find_music': $music = OC_FileCache::searchByMime('audio'); $ogg = OC_FileCache::searchByMime('application', 'ogg'); $music = array_merge($music, $ogg); OCP\JSON::encodedPrint($music); exit; } }