public function prepareImage($image, $format = null) { if (!$this->exists($image, $format)) { if (!is_dir($this->root_images_disk_path . $format)) { mkdir($this->root_images_disk_path . $format, 0777, true); } $original_path = $this->getImagePath($image); $resized_path = $this->getImagePath($image, $format); if (file_exists($original_path)) { $info = getimagesize($original_path); $mime = $info['mime']; switch ($mime) { case 'image/png': $image_create_func = 'imagecreatefrompng'; $image_save_func = 'imagepng'; $new_image_ext = 'png'; break; case 'image/gif': $image_create_func = 'imagecreatefromgif'; $image_save_func = 'imagegif'; $new_image_ext = 'gif'; break; default: //case 'image/jpeg': $image_create_func = 'imagecreatefromjpeg'; $image_save_func = 'imagejpeg'; $new_image_ext = 'jpg'; break; } $format_width = Images::$formats[$format]['width']; $format_height = Images::$formats[$format]['height']; $img = $image_create_func($original_path); list($width, $height) = getimagesize($original_path); if ($width > $format_width) { $newHeight = $height / $width * $format_width; $newWidth = $format_width; } else { $newHeight = $height; $newWidth = $width; } if ($newHeight > $format_height) { $newWidth = $newWidth / $newHeight * $format_height; $newHeight = $format_height; } $tmp = imagecreatetruecolor($newWidth, $newHeight); switch ($new_image_ext) { case "png": // integer representation of the color black (rgb: 0,0,0) $background = imagecolorallocate($tmp, 0, 0, 0); // removing the black from the placeholder imagecolortransparent($tmp, $background); // turning off alpha blending (to ensure alpha channel information // is preserved, rather than removed (blending with the rest of the // image in the form of black)) imagealphablending($tmp, false); // turning on alpha channel information saving (to ensure the full range // of transparency is preserved) imagesavealpha($tmp, true); break; case "gif": // integer representation of the color black (rgb: 0,0,0) $background = imagecolorallocate($tmp, 0, 0, 0); // removing the black from the placeholder imagecolortransparent($tmp, $background); break; } imagecopyresampled($tmp, $img, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); if (file_exists($resized_path)) { unlink($resized_path); } $image_save_func($tmp, "{$resized_path}"); imagedestroy($img); imagedestroy($tmp); } else { handleErr("Image {$original_path} not found. Cannot resize.", 'error'); } } }
function uninstallMain(&$s) { global $dbName, $dbUser, $dbUserPw, $dbHost; $s = ""; if (!isset($dbName)) { iPrint($s1, "err", $sp); $s .= $sp; $txt = "dbName not set"; handleErr($txt, __FILE__, __LINE__); } showInstallHeader($s1); $s .= $s1; $s .= "<h1>Uninstall</h1>"; connectDb($dbHost, $dbUser, $dbUserPw, $dbName); $query = "DROP DATABASE {$dbName}"; $result = executeQuery($query); iPrint("Db dropped", "ok", $sp); $s .= $sp; iPrint("Uninstall successful", "hurra", $sp); $s .= $sp; return ok; }
function getCount(&$count) { global $cookiePath, $noCookieCount; //a kuki_count nem list-enkent tarolodik, csak egy van! //ez lehet, hogy eleg, de neha gondot okozhat: //pl. ketfele lista parhuzamos lapozgatasakor ket kulon ablakban if (!$noCookieCount && isset($_COOKIE["kuki_count"]) && $_COOKIE["kuki_count"]) { $count = $_COOKIE["kuki_count"]; } else { $select = $this->getListSelect(TRUE); // select only if ($select == "") { handleErr("No select from getSelect class:" . $this->get_table(), __FILE__, __LINE__); } if (is_array($select)) { $select[0] = ereg_replace("SELECT .* FROM", "SELECT COUNT(*) FROM", $select[0]); } else { $select = ereg_replace("SELECT .* FROM", "SELECT COUNT(*) FROM", $select); } getDbCount($count, $select); if (!$noCookieCount) { setcookie("kuki_count", $count, 0, $cookiePath); $_COOKIE["kuki_count"] = $count; } } //echo "count:$count"; }
function reportError($query) { $txt = ""; $txt .= "query = {$query}\n\n"; $txt .= "POST VARS\n"; foreach ($_POST as $key => $value) { $txt .= "{$key} = {$value}\n"; } $txt .= "\n\nGET VARS\n"; foreach ($_GET as $key => $value) { $txt .= "{$key} = {$value}\n"; } //mail("*****@*****.**","Serious error",$txt); //handleErr("A serious error is occured. If you want to help the developers to find this error, send a mail to <a href='mailto:contact@phpoutsourcing.com'>contact@phpoutsourcing.com</a> and describe the steps you have made before this error occured. The better your description is, the easier we can find the bug. Thanks.",__FILE__, __LINE__); echo $txt; handleErr("An error occured.", __FILE__, __LINE__); }