Advertisement
Guest User

Untitled

a guest
Dec 29th, 2020
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for SourceGuardian Encoder)
  6. *
  7. * @ Version : 4.1.0.1
  8. * @ Author : DeZender
  9. * @ Release on : 29.08.2020
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class Image
  15. {
  16. private $file;
  17. private $image;
  18. private $type;
  19.  
  20. public function load($file)
  21. {
  22. if ($info = getimagesize($this->file = $file)) {
  23. $this->type = $info[2];
  24.  
  25. if ($this->type == IMAGETYPE_JPEG) {
  26. $this->image = imagecreatefromjpeg($file);
  27. }
  28. else if ($this->type == IMAGETYPE_GIF) {
  29. $this->image = imagecreatefromgif($file);
  30. }
  31. else if ($this->type == IMAGETYPE_PNG) {
  32. $this->image = imagecreatefrompng($file);
  33. }
  34. }
  35. }
  36.  
  37. public function save($file = NULL, $type = NULL, $compression = 75)
  38. {
  39. if (is_null($file)) {
  40. $file = $this->file;
  41. }
  42.  
  43. if (is_null($type)) {
  44. $type = $this->type;
  45. }
  46.  
  47. if ($type == IMAGETYPE_JPEG) {
  48. imagejpeg($this->image, $file, $compression);
  49. }
  50. else if ($type == IMAGETYPE_GIF) {
  51. imagegif($this->image, $file);
  52. }
  53. else if ($type == IMAGETYPE_PNG) {
  54. imagepng($this->image, $file);
  55. }
  56. }
  57.  
  58. public function output($type = NULL)
  59. {
  60. if (is_null($type)) {
  61. $type = $this->type;
  62. }
  63.  
  64. if ($type == IMAGETYPE_JPEG) {
  65. header('Content-Type: image/jpeg');
  66. imagejpeg($this->image);
  67. }
  68. else if ($type == IMAGETYPE_GIF) {
  69. header('Content-Type: image/gif');
  70. imagegif($this->image);
  71. }
  72. else if ($type == IMAGETYPE_PNG) {
  73. header('Content-Type: image/png');
  74. imagepng($this->image);
  75. }
  76.  
  77. exit();
  78. }
  79.  
  80. public function getWidth()
  81. {
  82. return imagesx($this->image);
  83. }
  84.  
  85. public function getHeight()
  86. {
  87. return imagesy($this->image);
  88. }
  89.  
  90. public function resizeToHeight($height)
  91. {
  92. $ratio = $height / $this->getHeight();
  93. $width = $this->getWidth() * $ratio;
  94. $this->resize($width, $height);
  95. }
  96.  
  97. public function resizeToWidth($width)
  98. {
  99. $ratio = $width / $this->getWidth();
  100. $height = $this->getheight() * $ratio;
  101. $this->resize($width, $height);
  102. }
  103.  
  104. public function scale($scale)
  105. {
  106. $width = ($this->getWidth() * $scale) / 100;
  107. $height = ($this->getheight() * $scale) / 100;
  108. $this->resize($width, $height);
  109. }
  110.  
  111. public function resize($width, $height)
  112. {
  113. $image = imagecreatetruecolor($width, $height);
  114.  
  115. if ($this->type == IMAGETYPE_PNG) {
  116. imagealphablending($image, false);
  117. imagefill($image, 0, 0, imagecolorallocatealpha($image, 0, 0, 0, 127));
  118. imagesavealpha($image, true);
  119. }
  120.  
  121. imagecopyresampled($image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
  122. $this->image = $image;
  123. }
  124. }
  125.  
  126. function db_connect()
  127. {
  128. static $conn = null;
  129.  
  130. if ($conn) {
  131. return $conn;
  132. }
  133.  
  134. if ($db = get_config('app', 'db')) {
  135. if (($conn = sql_connect($db['server'], $db['login'], $db['password'], $db['database'])) && sql_query($conn, 'SET NAMES ' . $db['charset'])) {
  136. return $conn;
  137. }
  138. else {
  139. echo 'Could not connect to database';
  140. exit();
  141. }
  142. }
  143. else {
  144. echo 'Could not get db config';
  145. exit();
  146. }
  147. }
  148.  
  149. function db_query($query)
  150. {
  151. if ($query) {
  152. if ($conn = db_connect()) {
  153. return sql_query($conn, $query);
  154. }
  155. }
  156.  
  157. return false;
  158. }
  159.  
  160. function get_user_uid()
  161. {
  162. return fetch_auth('login');
  163. }
  164.  
  165. function format_storage_uid($uid)
  166. {
  167. return implode('/', str_split(md5($uid)));
  168. }
  169.  
  170. function get_auth($login, $password)
  171. {
  172. if ($hash = get_auth_hash($login, $password)) {
  173. return ['login' => $login, 'password' => $password, 'hash' => $hash];
  174. }
  175. }
  176.  
  177. function get_auth_hash($login, $password)
  178. {
  179. if ($login && $password) {
  180. .....................................................................
  181. ........................................
  182. ..................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement