Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP7 Decoder for SourceGuardian Encoder)
- *
- * @ Version : 4.1.0.1
- * @ Author : DeZender
- * @ Release on : 29.08.2020
- * @ Official site : http://DeZender.Net
- *
- */
- class Image
- {
- private $file;
- private $image;
- private $type;
- public function load($file)
- {
- if ($info = getimagesize($this->file = $file)) {
- $this->type = $info[2];
- if ($this->type == IMAGETYPE_JPEG) {
- $this->image = imagecreatefromjpeg($file);
- }
- else if ($this->type == IMAGETYPE_GIF) {
- $this->image = imagecreatefromgif($file);
- }
- else if ($this->type == IMAGETYPE_PNG) {
- $this->image = imagecreatefrompng($file);
- }
- }
- }
- public function save($file = NULL, $type = NULL, $compression = 75)
- {
- if (is_null($file)) {
- $file = $this->file;
- }
- if (is_null($type)) {
- $type = $this->type;
- }
- if ($type == IMAGETYPE_JPEG) {
- imagejpeg($this->image, $file, $compression);
- }
- else if ($type == IMAGETYPE_GIF) {
- imagegif($this->image, $file);
- }
- else if ($type == IMAGETYPE_PNG) {
- imagepng($this->image, $file);
- }
- }
- public function output($type = NULL)
- {
- if (is_null($type)) {
- $type = $this->type;
- }
- if ($type == IMAGETYPE_JPEG) {
- header('Content-Type: image/jpeg');
- imagejpeg($this->image);
- }
- else if ($type == IMAGETYPE_GIF) {
- header('Content-Type: image/gif');
- imagegif($this->image);
- }
- else if ($type == IMAGETYPE_PNG) {
- header('Content-Type: image/png');
- imagepng($this->image);
- }
- exit();
- }
- public function getWidth()
- {
- return imagesx($this->image);
- }
- public function getHeight()
- {
- return imagesy($this->image);
- }
- public function resizeToHeight($height)
- {
- $ratio = $height / $this->getHeight();
- $width = $this->getWidth() * $ratio;
- $this->resize($width, $height);
- }
- public function resizeToWidth($width)
- {
- $ratio = $width / $this->getWidth();
- $height = $this->getheight() * $ratio;
- $this->resize($width, $height);
- }
- public function scale($scale)
- {
- $width = ($this->getWidth() * $scale) / 100;
- $height = ($this->getheight() * $scale) / 100;
- $this->resize($width, $height);
- }
- public function resize($width, $height)
- {
- $image = imagecreatetruecolor($width, $height);
- if ($this->type == IMAGETYPE_PNG) {
- imagealphablending($image, false);
- imagefill($image, 0, 0, imagecolorallocatealpha($image, 0, 0, 0, 127));
- imagesavealpha($image, true);
- }
- imagecopyresampled($image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
- $this->image = $image;
- }
- }
- function db_connect()
- {
- static $conn = null;
- if ($conn) {
- return $conn;
- }
- if ($db = get_config('app', 'db')) {
- if (($conn = sql_connect($db['server'], $db['login'], $db['password'], $db['database'])) && sql_query($conn, 'SET NAMES ' . $db['charset'])) {
- return $conn;
- }
- else {
- echo 'Could not connect to database';
- exit();
- }
- }
- else {
- echo 'Could not get db config';
- exit();
- }
- }
- function db_query($query)
- {
- if ($query) {
- if ($conn = db_connect()) {
- return sql_query($conn, $query);
- }
- }
- return false;
- }
- function get_user_uid()
- {
- return fetch_auth('login');
- }
- function format_storage_uid($uid)
- {
- return implode('/', str_split(md5($uid)));
- }
- function get_auth($login, $password)
- {
- if ($hash = get_auth_hash($login, $password)) {
- return ['login' => $login, 'password' => $password, 'hash' => $hash];
- }
- }
- function get_auth_hash($login, $password)
- {
- if ($login && $password) {
- .....................................................................
- ........................................
- ..................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement