public function get($album) { if (empty($album)) { $this->response(null, null, 400); } // ensure clean album name $this->root_path .= "/" . preg_replace("/[^a-zA-Z0-9-_]/", "", $album); $this->root_url .= "/" . preg_replace("/[^a-zA-Z0-9-_]/", "", $album); // check if folders exist if (!is_dir($this->root_path)) { $this->response(null, null, 400); } // grab folder here, load in the files for a particular folder $files = RazorFileTools::read_dir_contents($this->root_path, $type = 'files'); // remove anything not an image file ext foreach ($files as $key => $file) { $path_parts = explode('.', $file); if (!in_array(end($path_parts), $this->image_ext) || !in_array(exif_imagetype("{$this->root_path}/{$file}"), $this->image_types)) { unset($files[$key]); continue; } $files[$key] = array("url" => "{$this->root_url}/{$file}", "name" => $file); } sort($files); // json encode $this->response(array("images" => array_values($files)), "json"); }
public function get() { if ((int) $this->check_access() < 6) { $this->response(null, null, 401); } // check if folders exist if (!is_dir($this->root_files)) { mkdir($this->root_files); } if (!is_dir($this->root_files)) { mkdir($this->root_path); } // grab folder here, load in the files for a particular folder $files = RazorFileTools::read_dir_contents($this->root_path, $type = 'files'); // remove anything not an image file ext foreach ($files as $key => $file) { $path_parts = explode('.', $file); if (!in_array(end($path_parts), $this->image_ext) || !in_array(exif_imagetype("{$this->root_path}/{$file}"), $this->image_types)) { unset($files[$key]); continue; } $files[$key] = array("url" => "{$this->root_url}/{$file}", "name" => $file); } sort($files); // json encode $this->response(array("imageList" => array_values($files)), "json"); }
// grab settings for this content area and from that, find folder to use $content_ext_settings = json_decode($c_data["json_settings"]); $photos = "[]"; if (isset($content_ext_settings->album_name)) { // check if folders exist if (!is_dir(RAZOR_BASE_PATH . "storage/files/razorcms")) { mkdir(RAZOR_BASE_PATH . "storage/files/razorcms"); } if (!is_dir(RAZOR_BASE_PATH . "storage/files/razorcms/photo-gallery")) { mkdir(RAZOR_BASE_PATH . "storage/files/razorcms/photo-gallery"); } if (!is_dir(RAZOR_BASE_PATH . "storage/files/razorcms/photo-gallery/{$content_ext_settings->album_name}")) { mkdir(RAZOR_BASE_PATH . "storage/files/razorcms/photo-gallery/{$content_ext_settings->album_name}"); } // grab folder here, load in the files for a particular folder $files = RazorFileTools::read_dir_contents(RAZOR_BASE_PATH . "storage/files/razorcms/photo-gallery/{$content_ext_settings->album_name}", $type = 'files'); // remove anything not an image file ext foreach ($files as $key => $file) { if (!in_array(strtolower(substr($file, -4)), $image_files)) { unset($files[$key]); continue; } $files[$key] = array("url" => RAZOR_BASE_URL . "storage/files/razorcms/photo-gallery/{$content_ext_settings->album_name}/{$file}"); if (strtolower(substr($file, -4) == ".jpg" || strtolower(substr($file, -4) == "jpeg"))) { $details = exif_read_data(RAZOR_BASE_PATH . "storage/files/razorcms/photo-gallery/{$content_ext_settings->album_name}/{$file}"); if (isset($details["DocumentName"])) { $files[$key]["title"] = $details["DocumentName"]; } if (isset($details["ImageDescription"])) { $files[$key]["description"] = $details["ImageDescription"]; }
/** * Copy Dir * Copy a directory and all its contents * * @param string $fromDir Full path to dir to copy * @param string $toDir Full path to new location of copy * @return bool True on pass, false on fail */ public static function copy_dir($fromDir, $toDir) { $file_tools = new RazorFileTools(get_class($this)); $result = false; $readFromDir = $fromDir; $readToDir = $toDir; $file_tools->create_dir($readToDir); if (is_dir($readFromDir)) { $filesArray = array(); $filesArray = $file_tools->read_dir_contents($readFromDir); // do recursive delete if dir contains files // foreach ($filesArray as $name) { if (is_dir($readFromDir . '/' . $name)) { $result = self::copy_dir($fromDir . '/' . $name, $toDir . '/' . $name); } elseif (file_exists($readFromDir . '/' . $name)) { $result = self::copy_file($fromDir . '/' . $name, $toDir . '/' . $name, false); } } } return $result; }
if (in_array(strtolower(end($path_parts)), $media_files)) { $type = strtolower(end($path_parts)); } } if (isset($content_ext_settings->track_name)) { // play single track $path = RAZOR_BASE_PATH . "storage/files/razorcms/media-element-player/{$content_ext_settings->playlist_name}/{$content_ext_settings->track_name}"; $url = RAZOR_BASE_URL . "storage/files/razorcms/media-element-player/{$content_ext_settings->playlist_name}/{$content_ext_settings->track_name}"; if (is_file($path)) { $track = $url; $path_parts = explode(".", $track); $type = $type ? $type : "." . end($track); } } // grab folder here, load in the files for a particular folder $files = RazorFileTools::read_dir_contents(RAZOR_BASE_PATH . "storage/files/razorcms/media-element-player/{$content_ext_settings->playlist_name}", 'files'); // remove anything not an image file ext foreach ($files as $key => $file) { $file_parts = explode(".", $file); if (!in_array(strtolower(end($file_parts)), $media_files) || end($file_parts) != (!empty($type) ? $type : "mp3")) { continue; } $playlist[$key] = array("url" => RAZOR_BASE_URL . "storage/files/razorcms/media-element-player/{$content_ext_settings->playlist_name}/{$file}", "name" => $file); } $playlist = array_values($playlist); // one final type check if (empty($type) && isset($playlist[0]["name"])) { $path_parts = explode(".", $content_ext_settings->track_name); if (in_array(strtolower(end($playlist[0]["name"])), $media_files)) { $type = strtolower(end($playlist[0]["name"])); }