public function Install_Template() { # Was this a Post request with data enctype? if (!Is_Array($_FILES) || empty($_FILES)) { return False; } # Check the files foreach ($_FILES as $field_name => $arr_file) { if (!Is_File($arr_file['tmp_name'])) { unset($_FILES[$field_name]); } } # Check if there are uploaded files if (empty($_FILES)) { return False; } # Create template dir if (!Is_Dir($this->template_dir)) { MkDir($this->template_dir); ChMod($this->template_dir, 0755); } # Copy the template file if (isset($_FILES['template_zip'])) { # Install the ZIP Template $zip_file = $_FILES['template_zip']['tmp_name']; require_once 'includes/file.php'; WP_Filesystem(); return UnZip_File($zip_file, $this->template_dir); } elseif (isset($_FILES['template_php']) && $this->Get_Template_Properties($_FILES['template_php']['tmp_name'])) { # Install the PHP Template $php_file = $_FILES['template_php']['tmp_name']; $template_name = BaseName($_FILES['template_php']['name'], '.php'); # Create dir and copy file if (!Is_Dir($this->template_dir . '/' . $template_name)) { MkDir($this->template_dir . '/' . $template_name); ChMod($this->template_dir . '/' . $template_name, 0755); } Copy($php_file, $this->template_dir . '/' . $template_name . '/' . $template_name . '.php'); ChMod($this->template_dir . '/' . $template_name . '/' . $template_name . '.php', 0755); } else { return False; } # Template installed return True; }
function cache_or_output_image() { // Cache the new image and send it to the browser or redirect the browser to the cached image if ($this->use_cache && is_writable($this->cache_file_path)) { // Save the image in cache switch ($this->attachment_type) { case 'gif': imagegif($this->image, $this->cache_file_path); break; case 'jpeg': imagejpeg($this->image, $this->cache_file_path, $this->dst_qualy); break; case 'png': imagepng($this->image, $this->cache_file_path); break; default: return false; } ChMod($this->cache_file_path, 0755); // If we have the image cached we have to output it now Header('Location: ' . $this->cache_file_url); } else { // The cache is not writable. Send the image to the browser Header('Content-Type: image/' . $this->attachment_type); switch ($this->attachment_type) { case 'gif': imagegif($this->image); break; case 'jpeg': imagejpeg($this->image, Null, $this->dst_qualy); break; case 'png': imagepng($this->image); break; default: return false; } exit; } }