Suddenly only PHP code instead of a page
-
Hello together,
the last time I worked on my website everything was fine but today I used xampp as usual to start my Apache server and MySQL DB and when I call localhost/wordpress now all I see is this
nitVar = “”){ $var = $initVar; if(isset($_GET[$name])) $var = $_GET[$name]; return($var); } /** * * validate that some file exists, if not – throw error */ public static function validateFilepath($filepath,$errorPrefix=null){ if(file_exists($filepath) == true) return(false); if($errorPrefix == null) $errorPrefix = “File”; $message = $errorPrefix.” $filepath not exists!”; self::throwError($message); } /** * * validate that some value is numeric */ public static function validateNumeric($val,$fieldName=””){ self::validateNotEmpty($val,$fieldName); if(empty($fieldName)) $fieldName = “Field”; if(!is_numeric($val)) self::throwError(“$fieldName should be numeric “); } /** * * validate that some variable not empty */ public static function validateNotEmpty($val,$fieldName=””){ if(empty($fieldName)) $fieldName = “Field”; if(empty($val) && is_numeric($val) == false) self::throwError(“Field $fieldName should not be empty”); } /** * * if directory not exists – create it * @param $dir */ public static function checkCreateDir($dir){ if(!is_dir($dir)) mkdir($dir); if(!is_dir($dir)) self::throwError(“Could not create directory: $dir”); } /** * * delete file, validate if deleted */ public static function checkDeleteFile($filepath){ if(file_exists($filepath) == false) return(false); $success = @unlink($filepath); if($success == false) self::throwError(“Failed to delete the file: $filepath”); } //———————————————————— //filter array, leaving only needed fields – also array public static function filterArrFields($arr,$fields){ $arrNew = array(); foreach($fields as $field){ if(isset($arr[$field])) $arrNew[$field] = $arr[$field]; } return($arrNew); } //———————————————————— //get path info of certain path with all needed fields public static function getPathInfo($filepath){ $info = pathinfo($filepath); //fix the filename problem if(!isset($info[“filename”])){ $filename = $info[“basename”]; if(isset($info[“extension”])) $filename = substr($info[“basename”],0,(-strlen($info[“extension”])-1)); $info[“filename”] = $filename; } return($info); } /** * Convert std class to array, with all sons * @param unknown_type $arr */ public static function convertStdClassToArray($arr){ $arr = (array)$arr; $arrNew = array(); foreach($arr as $key=>$item){ $item = (array)$item; $arrNew[$key] = $item; } return($arrNew); } //———————————————————— //save some file to the filesystem with some text public static function writeFile($str,$filepath){ if(is_writable(dirname($filepath)) == false){ @chmod(dirname($filepath),0755); //try to change the permissions } if(!is_writable(dirname($filepath))) UniteFunctionsRev::throwError(“Can’t write file \””.$filepath.”\”, please change the permissions!”); $fp = fopen($filepath,”w+”); fwrite($fp,$str); fclose($fp); } //———————————————————— //save some file to the filesystem with some text public static function writeDebug($str,$filepath=”debug.txt”,$showInputs = true){ $post = print_r($_POST,true); $server = print_r($_SERVER,true); if(getType($str) == “array”) $str = print_r($str,true); if($showInputs == true){ $output = “——————–“.”\n”; $output .= $str.”\n”; $output .= “Post: “.$post.”\n”; }else{ $output = “—“.”\n”; $output .= $str . “\n”; } if(!empty($_GET)){ $get = print_r($_GET,true); $output .= “Get: “.$get.”\n”; } //$output .= “Server: “.$server.”\n”; $fp = fopen($filepath,”a+”); fwrite($fp,$output); fclose($fp); } /** * * clear debug file */ public static function clearDebug($filepath = “debug.txt”){ if(file_exists($filepath)) unlink($filepath); } /** * * save to filesystem the error */ public static function writeDebugError(Exception $e,$filepath = “debug.txt”){ $message = $e->getMessage(); $trace = $e->getTraceAsString(); $output = $message.”\n”; $output .= $trace.”\n”; $fp = fopen($filepath,”a+”); fwrite($fp,$output); fclose($fp); } //———————————————————— //save some file to the filesystem with some text public static function addToFile($str,$filepath){ if(!is_writable(dirname($filepath))) UniteFunctionsRev::throwError(“Can’t write file \””.$filepath.”\”, please change the permissions!”); $fp = fopen($filepath,”a+”); fwrite($fp,”———————\n”); fwrite($fp,$str.”\n”); fclose($fp); } //————————————————————– //check the php version. throw exception if the version beneath 5 private static function checkPHPVersion(){ $strVersion = phpversion(); $version = (float)$strVersion; if($version < 5) throw new Exception(“You must have php5 and higher in order to run the application. Your php version is: $version”); } //————————————————————– // valiadte if gd exists. if not – throw exception private static function validateGD(){ if(function_exists(‘gd_info’) == false) throw new Exception(“You need GD library to be available in order to run this application. Please turn it on in php.ini”); } //————————————————————– //return if the json library is activated public static function isJsonActivated(){ return(function_exists(‘json_encode’)); } /** * * encode array into json for client side */ public static function jsonEncodeForClientSide($arr){ $json = “”; if(!empty($arr)){ $json = json_encode($arr); $json = addslashes($json); } $json = “‘”.$json.”‘”; return($json); } /** * * decode json from the client side */ public static function jsonDecodeFromClientSide($data){ $data = stripslashes($data); $data = str_replace(‘\”‘,’\”‘,$data); $data = json_decode($data); $data = (array)$data; return($data); } //————————————————————– //validate if some directory is writable, if not – throw a exception private static function validateWritable($name,$path,$strList,$validateExists = true){ if($validateExists == true){ //if the file/directory doesn’t exists – throw an error. if(file_exists($path) == false) throw new Exception(“$name doesn’t exists”); } else{ //if the file not exists – don’t check. it will be created. if(file_exists($path) == false) return(false); } if(is_writable($path) == false){ chmod($path,0755); //try to change the permissions if(is_writable($path) == false){ $strType = “Folder”; if(is_file($path)) $strType = “File”; $message = “$strType $name is doesn’t have a write permissions. Those folders/files must have a write permissions in order that this application will work properly: $strList”; throw new Exception($message); } } } //————————————————————– //validate presets for identical keys public static function validatePresets(){ global $g_presets; if(empty($g_presets)) return(false); //check for duplicates $assoc = array(); foreach($g_presets as $preset){ $id = $preset[“id”]; if(isset($assoc[$id])) throw new Exception(“Double preset ID detected: $id”); $assoc[$id] = true; } } //————————————————————– //Get url of image for output public static function getImageOutputUrl($filename,$width=0,$height=0,$exact=false){ //exact validation: if($exact == “true” && (empty($width) || empty($height) )) self::throwError(“Exact must have both – width and height”); $url = CMGlobals::$URL_GALLERY.”?img=”.$filename; if(!empty($width)) $url .= “&w=”.$width; if(!empty($height)) $url .= “&h=”.$height; if($exact == true) $url .= “&t=exact”; return($url); } /** * * get list of all files in the directory * ext – filter by his extension only */ public static function getFileList($path,$ext=””){ $dir = scandir($path); $arrFiles = array(); foreach($dir as $file){ if($file == “.” || $file == “..”) continue; if(!empty($ext)){ $info = pathinfo($file); $extension = UniteFunctionsRev::getVal($info, “extension”); if($ext != strtolower($extension)) continue; } $filepath = $path . “/” . $file; if(is_file($filepath)) $arrFiles[] = $file; } return($arrFiles); } /** * * get list of all files in the directory */ public static function getFoldersList($path){ $dir = scandir($path); $arrFiles = array(); foreach($dir as $file){ if($file == “.” || $file == “..”) continue; $filepath = $path . “/” . $file; if(is_dir($filepath)) $arrFiles[] = $file; } return($arrFiles); } /** * * do “trim” operation on all array items. */ public static function trimArrayItems($arr){ if(gettype($arr) != “array”) UniteFunctionsRev::throwError(“trimArrayItems error: The type must be array”); foreach ($arr as $key=>$item){ if(is_array($item)){ foreach($item as $key => $value){ $arr[$key][$key] = trim($value); } }else{ $arr[$key] = trim($item); } } return($arr); } /** * * get url contents */ public static function getUrlContents($url,$arrPost=array(),$method = “post”,$debug=false){ $ch = curl_init(); $timeout = 0; $strPost = ”; foreach($arrPost as $key=>$value){ if(!empty($strPost)) $strPost .= “&”; $value = urlencode($value); $strPost .= “$key=$value”; } //set curl options if(strtolower($method) == “post”){ curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$strPost); } else //get $url .= “?”.$strPost; //remove me //Functions::addToLogFile(SERVICE_LOG_SERVICE, “url”, $url); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $headers = array(); $headers[] = “User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8”; $headers[] = “Accept-Charset:utf-8;q=0.7,*;q=0.7”; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); if($debug == true){ dmp($url); dmp($response); exit(); } if($response == false) throw new Exception(“getUrlContents Request failed”); curl_close($ch); return($response); } /** * * get link html */ public static function getHtmlLink($link,$text,$id=””,$class=””){ if(!empty($class)) $class = ” class=’$class'”; if(!empty($id)) $id = ” id=’$id'”; $html = “$text”; return($html); } /** * * get select from array */ public static function getHTMLSelect($arr,$default=””,$htmlParams=””,$assoc = false){ $html = “”; return($html); } /** * * Convert array to assoc array by some field */ public static function arrayToAssoc($arr,$field=null){ $arrAssoc = array(); foreach($arr as $item){ if(empty($field)) $arrAssoc[$item] = $item; else $arrAssoc[$item[$field]] = $item; } return($arrAssoc); } /** * * convert assoc array to array */ public static function assocToArray($assoc){ $arr = array(); foreach($assoc as $item) $arr[] = $item; return($arr); } /** * * strip slashes from textarea content after ajax request to server */ public static function normalizeTextareaContent($content){ if(empty($content)) return($content); $content = stripslashes($content); $content = trim($content); return($content); } /** * * get random array item */ public static function getRandomArrayItem($arr){ $numItems = count($arr); $rand = rand(0, $numItems-1); $item = $arr[$rand]; return($item); } /** * * recursive delete directory or file */ public static function deleteDir($path,$deleteOriginal = true, $arrNotDeleted = array(),$originalPath = “”){ if(empty($originalPath)) $originalPath = $path; //in case of paths array if(getType($path) == “array”){ $arrPaths = $path; foreach($path as $singlePath) $arrNotDeleted = self::deleteDir($singlePath,$deleteOriginal,$arrNotDeleted,$originalPath); return($arrNotDeleted); } if(!file_exists($path)) return($arrNotDeleted); if(is_file($path)){ // delete file $deleted = unlink($path); if(!$deleted) $arrNotDeleted[] = $path; } else{ //delete directory $arrPaths = scandir($path); foreach($arrPaths as $file){ if($file == “.” || $file == “..”) continue; $filepath = realpath($path.”/”.$file); $arrNotDeleted = self::deleteDir($filepath,$deleteOriginal,$arrNotDeleted,$originalPath); } if($deleteOriginal == true || $originalPath != $path){ $deleted = @rmdir($path); if(!$deleted) $arrNotDeleted[] = $path; } } return($arrNotDeleted); } /** * copy folder to another location. * */ public static function copyDir($source,$dest,$rel_path = “”,$blackList = null){ $full_source = $source; if(!empty($rel_path)) $full_source = $source.”/”.$rel_path; $full_dest = $dest; if(!empty($full_dest)) $full_dest = $dest.”/”.$rel_path; if(!is_dir($full_source)) self::throwError(“The source directroy: ‘$full_source’ not exists.”); if(!is_dir($full_dest)) mkdir($full_dest); $files = scandir($full_source); foreach($files as $file){ if($file == “.” || $file == “..”) continue; $path_source = $full_source.”/”.$file; $path_dest = $full_dest.”/”.$file; //validate black list $rel_path_file = $file; if(!empty($rel_path)) $rel_path_file = $rel_path.”/”.$file; //if the file or folder is in black list – pass it if(array_search($rel_path_file, $blackList) !== false) continue; //if file – copy file if(is_file($path_source)){ copy($path_source,$path_dest); } else{ //if directory – recursive copy directory if(empty($rel_path)) $rel_path_new = $file; else $rel_path_new = $rel_path.”/”.$file; self::copyDir($source,$dest,$rel_path_new,$blackList); } } } /** * * get text intro, limit by number of words */ public static function getTextIntro($text, $limit){ $arrIntro = explode(‘ ‘, $text, $limit); if (count($arrIntro)>=$limit) { array_pop($arrIntro); $intro = implode(” “,$arrIntro); $intro = trim($intro); if(!empty($intro)) $intro .= ‘…’; } else { $intro = implode(” “,$arrIntro); } $intro = preg_replace(‘
\[[^\]]*\]‘,”,$intro); return($intro); } } ?> exit(); } //—————————————————————————————— // get src image from filepath according the image type private function getGdSrcImage($filepath,$type){ // create the image $src_img = false; switch($type){ case IMAGETYPE_JPEG: $src_img = @imagecreatefromjpeg($filepath); break; case IMAGETYPE_PNG: $src_img = @imagecreatefrompng($filepath); break; case IMAGETYPE_GIF: $src_img = @imagecreatefromgif($filepath); break; case IMAGETYPE_BMP: $src_img = @imagecreatefromwbmp($filepath); break; default: $this->throwError(“wrong image format, can’t resize”); break; } if($src_img == false){ $this->throwError(“Can’t resize image”); } return($src_img); } //—————————————————————————————— // save gd image to some filepath. return if success or not private function saveGdImage($dst_img,$filepath,$type){ $successSaving = false; switch($type){ case IMAGETYPE_JPEG: $successSaving = imagejpeg($dst_img,$filepath,$this->jpg_quality); break; case IMAGETYPE_PNG: $successSaving = imagepng($dst_img,$filepath); break; case IMAGETYPE_GIF: $successSaving = imagegif($dst_img,$filepath); break; case IMAGETYPE_BMP: $successSaving = imagewbmp($dst_img,$filepath); break; } return($successSaving); } //—————————————————————————————— // crop image to specifix height and width , and save it to new path private function cropImageSaveNew($filepath,$filepathNew){ $imgInfo = getimagesize($filepath); $imgType = $imgInfo[2]; $src_img = $this->getGdSrcImage($filepath,$imgType); $width = imageSX($src_img); $height = imageSY($src_img); //crop the image from the top $startx = 0; $starty = 0; //find precrop width and height: $percent = $this->maxWidth / $width; $newWidth = $this->maxWidth; $newHeight = ceil($percent * $height); if($this->type == “exact”){ //crop the image from the middle $startx = 0; $starty = ($newHeight-$this->maxHeight)/2 / $percent; } if($newHeight < $this->maxHeight){ //by width $percent = $this->maxHeight / $height; $newHeight = $this->maxHeight; $newWidth = ceil($percent * $width); if($this->type == “exact”){ //crop the image from the middle $startx = ($newWidth – $this->maxWidth) /2 / $percent; //the startx is related to big image $starty = 0; } } //resize the picture: $tmp_img = ImageCreateTrueColor($newWidth,$newHeight); $this->handleTransparency($tmp_img,$imgType,$newWidth,$newHeight); imagecopyresampled($tmp_img,$src_img,0,0,$startx,$starty,$newWidth,$newHeight,$width,$height); $this->handleImageEffects($tmp_img); //crop the picture: $dst_img = ImageCreateTrueColor($this->maxWidth,$this->maxHeight); $this->handleTransparency($dst_img,$imgType,$this->maxWidth,$this->maxHeight); imagecopy($dst_img, $tmp_img, 0, 0, 0, 0, $newWidth, $newHeight); //save the picture $is_saved = $this->saveGdImage($dst_img,$filepathNew,$imgType); imagedestroy($dst_img); imagedestroy($src_img); imagedestroy($tmp_img); return($is_saved); } //—————————————————————————————— // if the images are png or gif – handle image transparency private function handleTransparency(&$dst_img,$imgType,$newWidth,$newHeight){ //handle transparency: if($imgType == IMAGETYPE_PNG || $imgType == IMAGETYPE_GIF){ imagealphablending($dst_img, false); imagesavealpha($dst_img,true); $transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127); imagefilledrectangle($dst_img, 0, 0, $newWidth, $newHeight, $transparent); } } //—————————————————————————————— // handle image effects private function handleImageEffects(&$imgHandle){ if(empty($this->effect)) return(false); switch($this->effect){ case self::EFFECT_BW: if(defined(“IMG_FILTER_GRAYSCALE”)) imagefilter($imgHandle,IMG_FILTER_GRAYSCALE); break; case self::EFFECT_BRIGHTNESS: if(defined(“IMG_FILTER_BRIGHTNESS”)){ if(!is_numeric($this->effect_arg1)) $this->effect_arg1 = 50; //set default value UniteFunctionsRev::validateNumeric($this->effect_arg1,”‘ea1’ argument”); imagefilter($imgHandle,IMG_FILTER_BRIGHTNESS,$this->effect_arg1); } break; case self::EFFECT_DARK: if(defined(“IMG_FILTER_BRIGHTNESS”)){ if(!is_numeric($this->effect_arg1)) $this->effect_arg1 = -50; //set default value UniteFunctionsRev::validateNumeric($this->effect_arg1,”‘ea1’ argument”); imagefilter($imgHandle,IMG_FILTER_BRIGHTNESS,$this->effect_arg1); } break; case self::EFFECT_CONTRAST: if(defined(“IMG_FILTER_CONTRAST”)){ if(!is_numeric($this->effect_arg1)) $this->effect_arg1 = -5; //set default value imagefilter($imgHandle,IMG_FILTER_CONTRAST,$this->effect_arg1); } break; case self::EFFECT_EDGE: if(defined(“IMG_FILTER_EDGEDETECT”)) imagefilter($imgHandle,IMG_FILTER_EDGEDETECT); break; case self::EFFECT_EMBOSS: if(defined(“IMG_FILTER_EMBOSS”)) imagefilter($imgHandle,IMG_FILTER_EMBOSS); break; case self::EFFECT_BLUR: $this->effect_Blur($imgHandle,5); /* if(defined(“IMG_FILTER_GAUSSIAN_BLUR”)) imagefilter($imgHandle,IMG_FILTER_GAUSSIAN_BLUR); */ break; case self::EFFECT_MEAN: if(defined(“IMG_FILTER_MEAN_REMOVAL”)) imagefilter($imgHandle,IMG_FILTER_MEAN_REMOVAL); break; case self::EFFECT_SMOOTH: if(defined(“IMG_FILTER_SMOOTH”)){ if(!is_numeric($this->effect_arg1)) $this->effect_arg1 = 15; //set default value imagefilter($imgHandle,IMG_FILTER_SMOOTH,$this->effect_arg1); } break; case self::EFFECT_BLUR3: $this->effect_Blur($imgHandle,5); break; default: $this->throwError(“Effect not supported: “.$this->effect.””); break; } } private function effect_Blur(&$gdimg, $radius=0.5) { // Taken from Torstein Hרnsi’s phpUnsharpMask (see phpthumb.unsharp.php) $radius = round(max(0, min($radius, 50)) * 2); if (!$radius) { return false; } $w = ImageSX($gdimg); $h = ImageSY($gdimg); if ($imgBlur = ImageCreateTrueColor($w, $h)) { // Gaussian blur matrix: // 1 2 1 // 2 4 2 // 1 2 1 // Move copies of the image around one pixel at the time and merge them with weight // according to the matrix. The same matrix is simply repeated for higher radii. for ($i = 0; $i < $radius; $i++) { ImageCopy ($imgBlur, $gdimg, 0, 0, 1, 1, $w – 1, $h – 1); // up left ImageCopyMerge($imgBlur, $gdimg, 1, 1, 0, 0, $w, $h, 50.00000); // down right ImageCopyMerge($imgBlur, $gdimg, 0, 1, 1, 0, $w – 1, $h, 33.33333); // down left ImageCopyMerge($imgBlur, $gdimg, 1, 0, 0, 1, $w, $h – 1, 25.00000); // up right ImageCopyMerge($imgBlur, $gdimg, 0, 0, 1, 0, $w – 1, $h, 33.33333); // left ImageCopyMerge($imgBlur, $gdimg, 1, 0, 0, 0, $w, $h, 25.00000); // right ImageCopyMerge($imgBlur, $gdimg, 0, 0, 0, 1, $w, $h – 1, 20.00000); // up ImageCopyMerge($imgBlur, $gdimg, 0, 1, 0, 0, $w, $h, 16.666667); // down ImageCopyMerge($imgBlur, $gdimg, 0, 0, 0, 0, $w, $h, 50.000000); // center ImageCopy ($gdimg, $imgBlur, 0, 0, 0, 0, $w, $h); } return true; } return false; } //—————————————————————————————— // resize image and save it to new path private function resizeImageSaveNew($filepath,$filepathNew){ $imgInfo = getimagesize($filepath); $imgType = $imgInfo[2]; $src_img = $this->getGdSrcImage($filepath,$imgType); $width = imageSX($src_img); $height = imageSY($src_img); $newWidth = $width; $newHeight = $height; //find new width if($height > $this->maxHeight){ $procent = $this->maxHeight / $height; $newWidth = ceil($width * $procent); $newHeight = $this->maxHeight; } //if the new width is grater than max width, find new height, and remain the width. if($newWidth > $this->maxWidth){ $procent = $this->maxWidth / $newWidth; $newHeight = ceil($newHeight * $procent); $newWidth = $this->maxWidth; } //if the image don’t need to be resized, just copy it from source to destanation. if($newWidth == $width && $newHeight == $height && empty($this->effect)){ $success = copy($filepath,$filepathNew); if($success == false) $this->throwError(“can’t copy the image from one path to another”); } else{ //else create the resized image, and save it to new path: $dst_img = ImageCreateTrueColor($newWidth,$newHeight); $this->handleTransparency($dst_img,$imgType,$newWidth,$newHeight); //copy the new resampled image: imagecopyresampled($dst_img,$src_img,0,0,0,0,$newWidth,$newHeight,$width,$height); $this->handleImageEffects($dst_img); $is_saved = $this->saveGdImage($dst_img,$filepathNew,$imgType); imagedestroy($dst_img); } imagedestroy($src_img); return(true); } /** * * set image effect */ public function setEffect($effect,$arg1 = “”){ $this->effect = $effect; $this->effect_arg1 = $arg1; } private function showImageByID($fileID, $maxWidth=-1, $maxHeight=-1, $type=””){ $fileID = intval($fileID); if($fileID == 0) $this->throwError(“image not found”); $img = wp_get_attachment_image_src( $fileID, ‘thumb’ ); if(empty($img)) $this->throwError(“image not found”); $this->outputImage($img[0]); exit(); } //—————————————————————————————— //return image private function showImage($filename,$maxWidth=-1,$maxHeight=-1,$type=””){ if(empty($filename)) $this->throwError(“image filename not found”); //validate input if($type == self::TYPE_EXACT || $type == self::TYPE_EXACT_TOP){ if($maxHeight == -1) $this->throwError(“image with exact type must have height!”); if($maxWidth == -1) $this->throwError(“image with exact type must have width!”); } $filepath = $this->pathImages.$filename; if(!is_file($filepath)) $this->outputEmptyImageCode(); //if gd library doesn’t exists – output normal image without resizing. if(function_exists(“gd_info”) == false) $this->throwError(“php must support GD Library”); //check conditions for output original image if(empty($this->effect)){ if((is_numeric($maxWidth) == false || is_numeric($maxHeight) == false)) outputImage($filepath); if($maxWidth == -1 && $maxHeight == -1) $this->outputImage($filepath); } if($maxWidth == -1) $maxWidth = 1000000; if($maxHeight == -1) $maxHeight = 100000; //init variables $this->filename = $filename; $this->maxWidth = $maxWidth; $this->maxHeight = $maxHeight; $this->type = $type; $filepathNew = $this->getThumbFilepath(); if(is_file($filepathNew)){ $this->outputImage($filepathNew); exit(); } try{ if($type == self::TYPE_EXACT || $type == self::TYPE_EXACT_TOP){ $isSaved = $this->cropImageSaveNew($filepath,$filepathNew); } else $isSaved = $this->resizeImageSaveNew($filepath,$filepathNew); if($isSaved == false){ $this->outputImage($filepath); exit(); } }catch(Exception $e){ $this->outputImage($filepath); } if(is_file($filepathNew)) $this->outputImage($filepathNew); else $this->outputImage($filepath); exit(); } /** * * show image from get params */ public function showImageFromGet(){ //$imageFilename = UniteFunctionsRev::getGetVar(“img”); $imageID = intval(UniteFunctionsRev::getGetVar(“img”)); $maxWidth = UniteFunctionsRev::getGetVar(“w”,-1); $maxHeight = UniteFunctionsRev::getGetVar(“h”,-1); $type = UniteFunctionsRev::getGetVar(“t”,””); //set effect $effect = UniteFunctionsRev::getGetVar(“e”); $effectArgument1 = UniteFunctionsRev::getGetVar(“ea1”); if(!empty($effect)) $this->setEffect($effect,$effectArgument1); $this->showImageByID($imageID); echo ‘sechs
‘; //$this->showImage($imageFilename,$maxWidth,$maxHeight,$type); } //—————————————————————————————— // download image, change size and name if needed. public function downloadImage($filename){ $filepath = $this->urlImages.”/”.$filename; if(!is_file($filepath)) { echo “file doesn’t exists”; exit(); } $this->outputImageForDownload($filepath,$filename); } //—————————————————————————————— // output image for downloading private function outputImageForDownload($filepath,$filename,$mimeType=””){ $contents = file_get_contents($filepath); $filesize = strlen($contents); if($mimeType == “”){ $info = UniteFunctionsRev::getPathInfo($filepath); $ext = $info[“extension”]; $mimeType = “image/$ext”; } header(“Content-Type: $mimeType”); header(“Content-Disposition: attachment; filename=\”$filename\””); header(“Content-Length: $filesize”); echo $contents; exit(); } /** * * validate type * @param unknown_type $type */ public function validateType($type){ switch($type){ case self::TYPE_EXACT: case self::TYPE_EXACT_TOP: break; default: $this->throwError(“Wrong image type: “.$type); break; } } } ?>
Warning: session_start(): Cannot send session cookie – headers already sent by (output started at C:\xampp\apps\wordpress\htdocs\wp-content\plugins\revslider\inc_php\framework\functions.class.php:650) in C:\xampp\apps\wordpress\htdocs\wp-content\themes\wpcasa\lib\widgets\listing-contact.php on line 19Warning: session_start(): Cannot send session cache limiter – headers already sent (output started at C:\xampp\apps\wordpress\htdocs\wp-content\plugins\revslider\inc_php\framework\functions.class.php:650) in C:\xampp\apps\wordpress\htdocs\wp-content\themes\wpcasa\lib\widgets\listing-contact.php on line 19
Fatal error: Class ‘UniteFunctionsRev’ not found in C:\xampp\apps\wordpress\htdocs\wp-content\plugins\revslider\revslider_front.php on line 44
Screenshot Version:
– https://dl.dropboxusercontent.com/u/37336669/Screenshot%202015-01-28%2019.19.04.png
– https://dl.dropboxusercontent.com/u/37336669/Screenshot%202015-01-28%2019.19.07.pngI´ve absolutly no idea what´s wrong and how I can recover my data since I can´t go to the backend with localhost/wordpress/wp-admin.
Any help is really appreciated!
Thanks in advance!
The topic ‘Suddenly only PHP code instead of a page’ is closed to new replies.