public function parse_match_post() { //----------------------------------------------------- if (!empty($this->match[1]) || $this->match[1] != "") { $this->src_path_markup = $this->match[1]; $this->src_path = $this->match[2]; /*if (is_null($this->link_compile_file)) { krumo($this->save_path); $this->save_path_relative = Compiler::cleanURL($this->src_path, ""); $this->save_path = $this->compilePath.$this->save_path_relative; krumo($this->save_path); }*/ } //----------------------------------------------------- if (is_null($this->save_path)) { if (!is_null($this->content)) { if (!file_exists($this->src_path) && !CurlUtil::is_url_exist($this->src_path)) { $this->markup_CFG(); $this->inline = true; $this->save_path_relative = $this->savePath_CFG() . "inline_" . $this->index . "." . $this->saveas_ext; $this->save_path = $this->compilePath . $this->save_path_relative; } else { $path = is_null($this->save_dir) ? Compiler::cleanURL(FileFolder::getFileName($this->src_path, true, true)) : $this->save_dir . FileFolder::getFileName($this->src_path, true); $path = $this->removeModified($path); $this->save_path_relative = $path . "." . $this->saveas_ext; $this->save_path = $this->compilePath . $this->save_path_relative; //krumo(basename($this->save_path)); } } } //----------------------------------------------------- /*if (!is_null($this->replacePath) && !is_null($this->save_path)) { foreach ($this->replacePath as $key => $value) { $this->save_path_relative = str_replace($key, $value, $this->save_path_relative); $this->save_path = str_replace($key, $value, $this->save_path); } }*/ //----------------------------------------------------- /*if (!is_null($this->str_replace_silent)) { foreach ($this->str_replace_silent as $key => $value) { $txt = str_replace($key, $value, $txt); } }*/ //----------------------------------------------------- //if ($this->compileType == "seperate") { //} //----------------------------------------------------- if (!is_null($this->content)) { $prop = array("src_content" => $this->content, "compilerGlobal" => $this->compilerGlobal, "forceDownload" => $this->forceDownload, "src_content_type" => $this->codeType, "src_dir" => !is_null($this->src_path) ? dirname($this->src_path) . "/" : $this->src_path, "src_save_dir" => !is_null($this->save_path_relative) ? dirname($this->save_path_relative) . "/" : $this->save_path_relative, "compilePath" => $this->compilePath); //krumo($this->content); //--------------------------------------------- $this->images = new Compile_Images($prop); //--------------------------------------------- SetPublicProp::go($this->images, $this->imagesProp); //--------------------------------------------- SetPublicProp::go($this->images, $this->filesObj, false); //--------------------------------------------- $this->images->init(); $this->content_updated = $this->images->src_content_updated; if ($this->removeInline && !is_null($this->output_updated)) { $replaceWith = $this->onRemoveMatch_CHK("code"); $this->output_updated = str_replace($this->match[0], $replaceWith, $this->output_updated); } } //----------------------------------------------------- }
public function file_CHK() { //----------------------------------------------------- $content = NULL; $getContent = true; //----------------------------------------------------- if (preg_match('/\\.(jpg|jpeg|png|gif)(?:[\\?\\#].*)?$/i', $this->filePath)) { $this->fileType = "image"; } //----------------------------------------------------- $filePath = explode("?", $this->filePath); $filePath = $filePath[0]; //----------------------------------------------------- if (strpos($filePath, "../") !== false) { $this->filePath_local = FileFolder::getParDirFromSrc($filePath, $this->url_local . $this->src_dir); //--------------------------------------------- if (FileFolder::file_exists($this->filePath_local)) { $this->exist = true; $this->content = $this->getContent($this->filePath_local); } //--------------------------------------------- $result = StringUtil::replaceOverlap($this->url_local, $this->filePath_local, "", "/"); //--------------------------------------------- if ($this->relativeToSrc && $this->exist) { $this->save_path = $this->compilePath . str_replace($this->url_local, "", $this->filePath_local); //----------------------------------------- if ($result['overlap'] != $this->url_local) { krumo($result); krumo($this->filePath_local . " cannot be saved outside of " . $this->compilePath . " ,'relativeToSrc' will be set to 'false'"); //----------------------------------------- $this->relativeToSrc = false; } } //--------------------------------------------- $filePath = str_replace($result["overlap"], "", $this->filePath_local); } else { if (strpos($filePath, "http://") !== false || strpos($filePath, "https://") !== false) { if (FileFolder::file_exists($filePath_local = GenFun::get_local_url($filePath))) { $this->filePath_local = $filePath_local; $this->content = $this->getContent($this->filePath_local); $this->filePath_local_relative = Compiler::cleanURL($this->filePath_local, ""); $filePath = !is_null($this->save_dir) ? basename($this->filePath_local_relative) : $this->filePath_local_relative; $this->exist = true; } else { if (CurlUtil::is_url_exist($this->filePath)) { $this->exist = true; if ($this->forceDownload) { $filePath = (!is_null($this->save_dir) ? "" : "global/forced/") . basename($filePath); $this->content = $this->getContent($this->filePath); $this->forced = true; } else { $this->link = Html::getExtLink($this->filePath); } } } } else { if (!is_null($this->src_save_dir) && $this->src_content_type == "css") { if (FileFolder::file_exists($this->filePath_local = (!is_null($this->src_dir) ? GenFun::get_local_url($this->src_dir) : $this->url_local) . $filePath)) { $this->exist = true; } $this->content = $this->getContent($this->filePath_local); if ($this->relativeToSrc) { $filePath = $this->src_save_dir . $filePath; } $this->save_path = $this->compilePath . $filePath; } else { if (FileFolder::file_exists($this->filePath_local = $this->url_local . $filePath)) { $this->content = $this->getContent($this->filePath_local); $filePath = $this->filePath; $this->exist = true; } } } } //------------------------------------------------- if (!$this->base64 || $this->fileType != "image") { if ($this->relativeToSrc && $this->src_content_type == "css") { $this->save_path_relative = $filePath; } else { if (!is_null($this->filePath_local)) { //--------------------------------------------- $this->save_path_relative = $this->get_savePath($filePath); $this->save_path = $this->compilePath . $this->save_path_relative; } else { //$this->save_path = $filePath; } } //------------------------------------------------- if ($this->relativeToSrc && !is_null($this->src_save_dir)) { $this->save_path_relative = StringUtil::pathRelativeToPath($this->save_path, $this->compilePath . $this->src_save_dir, "/", true); } } else { if ($this->fileType == "image") { $info = getimagesize($this->filePath_local); if ($info['mime'] == "image/png") { $this->base64_content = Image::compress_png($this->filePath_local, $this->quality, true); } else { if ($info['mime'] == "image/jpeg") { $this->base64_content = Image::compress_jpeg($this->filePath_local, $this->quality, true); } else { $this->base64_content = GenFun::fileToBase64($this->filePath_local, $info['mime']); } } } } //------------------------------------------------- if ($this->exist) { $this->src_content_updated = str_replace($this->filePath, !is_null($this->base64_content) ? $this->base64_content : $this->save_path_relative, $this->src_content); } else { $this->existCaseInsensitive = FileFolder::file_exists($this->filePath_local, false); array_push($this->compilerGlobal->notifications, array("existCaseInsensitive" => $this->existCaseInsensitive, "file" => $this->filePath)); } }