Guest User

Untitled

a guest
May 3rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.29 KB | None | 0 0
  1. <?
  2. $db_Connect = mysql_connect($config->Host,$config->User,$config->Pass);
  3. mysql_select_db($config->DB,$db_Connect);
  4.  
  5. class UserControl
  6. {
  7. public $user;
  8.  
  9. public function check_user($name, $pass)
  10. {
  11. $sql = "SELECT id,Name,Admin,Password,Banned FROM `players` WHERE Name='".mysql_real_escape_string($name)."' AND Password='".md5(mysql_real_escape_string($pass))."' LIMIT 1";
  12. $result = mysql_query($sql) or die(mysql_error());
  13. if (mysql_num_rows($result) == 1)
  14. {
  15. $this->user = mysql_fetch_object($result);
  16. mysql_free_result($result);
  17. //session_register('name');
  18. $_SESSION['Name'] = $this->user->Name;
  19. $_SESSION['AdminLevel'] = $this->user->AdminLevel;
  20. $_SESSION['Password'] = $this->user->Password;
  21. $_SESSION['id'] = $this->user->id;
  22. $_SESSION['Locked'] = $this->user->Locked;
  23. return $this->user->id;
  24. }
  25. else
  26. {
  27. return false;
  28. }
  29. }
  30.  
  31. function login($userid)
  32. {
  33. $_SESSION['loggedin'] = true;
  34. echo 'Palun oota...';
  35. echo '<script language="javaScript">
  36. top.document.location="index.php?page=home";
  37. </script>';
  38. }
  39.  
  40. function CreatePass()
  41. {
  42. $chars = "abcdefghijkmnopqrstuvwxyz0123456789";
  43. srand((double)microtime()*1000000);
  44. $i = 0;
  45. $pass = '';
  46. while ($i <= 7)
  47. {
  48. $num = rand() % 33;
  49. $tmp = substr($chars, $num, 1);
  50. $pass = $pass . $tmp;
  51. $i++;
  52. }
  53. return $pass;
  54. }
  55. }
  56.  
  57. function GetContentLine($filename,$conline,$row,$loopsize)
  58. {
  59. $file = $filename;
  60. $handle = fopen($file,"r");
  61. $content = fread($handle,filesize($file));
  62. $filter = trim(strip_tags($content));
  63. $filter = explode("\n", $filter);
  64. foreach($filter as $value)
  65. {
  66. $output[] = trim($value);
  67. }
  68. while($i < $loopsize)
  69. {
  70. $line[] = explode(",",$output[$i]);
  71. $i++;
  72. }
  73. fclose($handle);
  74. return $line[$conline][$row];
  75. }
  76.  
  77. function logout()
  78. {
  79. $_SESSION['loggedin'] = false;
  80. header('refresh: 2; url=index.php?page=home');
  81. }
  82.  
  83. function check()
  84. {
  85. $check = mysql_query('SELECT link FROM `pages` WHERE pagename = "'.home.'" LIMIT 1');
  86. if(mysql_num_rows($check) != 0)
  87. {
  88. return true;
  89. }
  90. else
  91. {
  92. echo '<div class="right">You have not installed the MySQL table yet.</div>';
  93. include_once ('panel.php');
  94. include_once ('footer.php');
  95. exit;
  96. }
  97. }
  98.  
  99. function ResizeImage($old_image_name, $new_image_name, $new_image_x_size, $new_image_y_size)
  100. {
  101. global $image_prop;
  102.  
  103. if(@imagecreatetruecolor(1,1)) $GDLIB_VERS = 2;
  104. else $GDLIB_VERS = 1;
  105.  
  106. $file = basename($old_image_name);
  107. $image_ext = explode(".", $file);
  108.  
  109. if($image_ext[1] == "gif" || $image_ext[1] == "GIF")
  110. {
  111.  
  112. if(function_exists ("ImageCreateFromGIF"))
  113. {
  114. $imgA = ImageCreateFromGIF ($old_image_name);
  115.  
  116. // height and width recalculate
  117. $org_x = ImageSX($imgA);
  118. $org_y = ImageSY($imgA);
  119.  
  120. if($org_x >= $org_y && $image_prop == "ja") {
  121. $new_image_x_size = $new_image_x_size;
  122. $new_image_y_size = $org_y / ($org_x / $new_image_x_size);
  123. $new_image_y_size = floor($new_image_y_size);
  124. }
  125.  
  126. if($org_x < $org_y && $image_prop == "ja")
  127. {
  128. $new_image_y_size = $new_image_y_size;
  129. $new_image_x_size = $org_x / ($org_y / $new_image_y_size);
  130. $new_image_x_size = floor($new_image_x_size);
  131. }
  132.  
  133. if($GDLIB_VERS == 2)
  134. {
  135. $imgB = imagecreatetruecolor($new_image_x_size,$new_image_y_size);
  136. imagecopyresampled($imgB,$imgA,0,0,0,0, $new_image_x_size, $new_image_y_size, $org_x ,$org_y);
  137. }
  138. else
  139. {
  140. $imgB = imagecreate($new_image_x_size,$new_image_y_size);
  141. imagecopyresized($imgB, $imgA,0,0,0,0, $new_image_x_size, $new_image_y_size, $org_x ,$org_y);
  142. }
  143. if($imgB) imagegif($imgB, $new_image_name);
  144.  
  145. }
  146. else
  147. {
  148. return false;
  149. }
  150. }
  151.  
  152.  
  153. if($image_ext[1] == "jpg" || $image_ext[1] == "jpeg" || $image_ext[1] == "JPG" || $image_ext[1] == "JPEG")
  154. {
  155.  
  156. if(function_exists ("ImageCreateFromJPEG"))
  157. {
  158. $imgA = ImageCreateFromJPEG ($old_image_name);
  159. $org_x = ImageSX($imgA);
  160. $org_y = ImageSY($imgA);
  161.  
  162. if($org_x >= $org_y && $image_prop == "ja")
  163. {
  164. $new_image_x_size = $new_image_x_size;
  165. $new_image_y_size = $org_y / ($org_x / $new_image_x_size);
  166. $new_image_y_size = floor($new_image_y_size);
  167. }
  168.  
  169. if($org_x < $org_y && $image_prop == "ja")
  170. {
  171. $new_image_y_size = $new_image_y_size;
  172. $new_image_x_size = $org_x / ($org_y / $new_image_y_size);
  173. $new_image_x_size = floor($new_image_x_size);
  174. }
  175.  
  176. $quality = 100;
  177. if($GDLIB_VERS == 2)
  178. {
  179. $imgB = imagecreatetruecolor($new_image_x_size,$new_image_y_size);
  180. imagecopyresampled($imgB, $imgA,0,0,0,0, $new_image_x_size, $new_image_y_size, $org_x ,$org_y);
  181. }
  182. else
  183. {
  184. $imgB = imagecreate($new_image_x_size,$new_image_y_size);
  185. imagecopyresized($imgB, $imgA,0,0,0,0, $new_image_x_size, $new_image_y_size, $org_x ,$org_y);
  186. }
  187. imagejpeg($imgB, $new_image_name, $quality);
  188. }
  189. else
  190. {
  191. return false;
  192. }
  193. }
  194.  
  195. if($image_ext[1] == "png" || $image_ext[1] == "PNG")
  196. {
  197. if(function_exists ("ImageCreateFromPNG"))
  198. {
  199. $imgA = ImageCreateFromPNG ($old_image_name);
  200. $org_x = ImageSX($imgA);
  201. $org_y = ImageSY($imgA);
  202.  
  203. if($org_x >= $org_y && $image_prop == "ja")
  204. {
  205. $new_image_x_size = $new_image_x_size;
  206. $new_image_y_size = $org_y / ($org_x / $new_image_x_size);
  207. $new_image_y_size = floor($new_image_y_size);
  208. }
  209.  
  210. if($org_x < $org_y && $image_prop == "ja")
  211. {
  212. $new_image_y_size = $new_image_y_size;
  213. $new_image_x_size = $org_x / ($org_y / $new_image_y_size);
  214. $new_image_x_size = floor($new_image_x_size);
  215. }
  216.  
  217. if($GDLIB_VERS == 2)
  218. {
  219. $imgB = imagecreatetruecolor($new_image_x_size,$new_image_y_size);
  220. imagecopyresampled($imgB, $imgA,0,0,0,0, $new_image_x_size, $new_image_y_size, $org_x ,$org_y);
  221. }
  222. else
  223. {
  224. $imgB = imagecreate($new_image_x_size,$new_image_y_size);
  225. imagecopyresized($imgB, $imgA,0,0,0,0, $new_image_x_size, $new_image_y_size, $org_x ,$org_y);
  226. }
  227. imagepng($imgB, $new_image_name);
  228. }
  229. else
  230. {
  231. return false;
  232. }
  233. }
  234.  
  235. if(!$imgA)
  236. {
  237. return false;
  238. }
  239.  
  240. return true;
  241. }
  242. ?>
Add Comment
Please, Sign In to add comment