Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2018
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.0.6.0
  8. * @ Author : DeZender
  9. * @ Release on : 20.09.2018
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class cpanel_manage2_license_3596PDOWrapper
  15. {
  16. static private $pdoConnection;
  17.  
  18. static private function getDbConnection()
  19. {
  20. if (class_exists('Illuminate\\Database\\Capsule\\Manager')) {
  21. return \Illuminate\Database\Capsule\Manager::connection()->getPdo();
  22. }
  23.  
  24. if (self::$pdoConnection === NULL) {
  25. self::$pdoConnection = self::setNewConnection();
  26. }
  27.  
  28. return self::$pdoConnection;
  29. }
  30.  
  31. static private function setNewConnection()
  32. {
  33. try {
  34. $includePath = ROOTDIR . DIRECTORY_SEPARATOR . 'configuration.php';
  35.  
  36. if (file_exists($includePath)) {
  37. require $includePath;
  38. }
  39. else {
  40. throw new Exception('No configuration file found');
  41. }
  42.  
  43. $connection = new PDO(sprintf('mysql:host=%s;dbname=%s;port=%s;charset=utf8', $db_host, $db_name, $db_port ? $db_port : 3360), $db_username, $db_password);
  44. $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  45. return $connection;
  46. }
  47. catch (PDOException $exc) {
  48. }
  49. }
  50.  
  51. static public function query($query, $params = [])
  52. {
  53. $statement = self::getDbConnection()->prepare($query);
  54. $statement->execute($params);
  55. return $statement;
  56. }
  57.  
  58. static public function real_escape_string($string)
  59. {
  60. return substr(self::getDbConnection()->quote($string), 1, -1);
  61. }
  62.  
  63. static public function fetch_assoc($query)
  64. {
  65. return $query->fetch(PDO::FETCH_ASSOC);
  66. }
  67.  
  68. static public function fetch_array($query)
  69. {
  70. return $query->fetch(PDO::FETCH_BOTH);
  71. }
  72.  
  73. static public function fetch_object($query)
  74. {
  75. return $query->fetch(PDO::FETCH_OBJ);
  76. }
  77.  
  78. static public function num_rows($query)
  79. {
  80. $query->fetch(PDO::FETCH_BOTH);
  81. return $query->rowCount();
  82. }
  83.  
  84. static public function insert_id()
  85. {
  86. return self::getDbConnection()->lastInsertId();
  87. }
  88.  
  89. static public function errorInfo()
  90. {
  91. $tmpErr = self::getDbConnection()->errorInfo();
  92. if ($tmpErr[0] && ($tmpErr[0] !== '00000')) {
  93. return $tmpErr;
  94. }
  95.  
  96. return false;
  97. }
  98.  
  99. static public function mysql_get_array($query, $params = [])
  100. {
  101. $qRes = self::query($query, $params);
  102. $arr = [];
  103.  
  104. while ($row = self::fetch_assoc($qRes)) {
  105. $arr[] = $row;
  106. }
  107.  
  108. return $arr;
  109. }
  110.  
  111. static public function mysql_get_row($query, $params = [])
  112. {
  113. $qRes = self::query($query, $params);
  114. return self::fetch_assoc($qRes);
  115. }
  116. }
  117.  
  118. class mgCpanelClient
  119. {
  120. private $error;
  121. private $username;
  122. private $password;
  123. private $format;
  124.  
  125. public function getError()
  126. {
  127. return $this->error;
  128. }
  129.  
  130. public function __construct($user, $pass)
  131. {
  132. $this->username = $user;
  133. $this->password = $pass;
  134. $this->format = $format;
  135. }
  136.  
  137. private function get($function, $args = [])
  138. {
  139. if (!function_exists('curl_init')) {
  140. $this->error = 'CURL is not installed!';
  141. return NULL;
  142. }
  143.  
  144. if (!$function) {
  145. $this->error = 'No function specified';
  146. return NULL;
  147. }
  148.  
  149. $curl = curl_init();
  150. curl_setopt($curl, CURLOPT_USERPWD, $this->username . ':' . $this->password);
  151. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  152. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  153. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  154. $this->format = 'json';
  155. $args['output'] = $this->format;
  156. $query = 'https://manage2.cpanel.net/' . $function . '?' . http_build_query($args);
  157. curl_setopt($curl, CURLOPT_URL, $query);
  158. $result = curl_exec($curl);
  159.  
  160. if (!$result) {
  161. $this->error = 'Connection error: ' . curl_error($curl);
  162. curl_close($curl);
  163. return NULL;
  164. }
  165.  
  166. curl_close($curl);
  167. return $result;
  168. }
  169.  
  170. private function validateID($id)
  171. {
  172. if (preg_match('/^(L|P|G)?\\d*$/', $id)) {
  173. return 1;
  174. }
  175. else {
  176. return 0;
  177. }
  178. }
  179.  
  180. private function validateIP($ip)
  181. {
  182. return preg_match('/^\\d*\\.\\d*\\.\\d*\\.\\d*$/', $ip);
  183. }
  184.  
  185. public function reactivateLicense($args)
  186. {
  187. if (!array_key_exists('liscid', $args)) {
  188. $this->error = 'Invalid License ID (2)';
  189. return NULL;
  190. }
  191.  
  192. if (!$this->validateID($args['liscid'])) {
  193. $this->error = 'Invalid License ID';
  194. return NULL;
  195. }
  196.  
  197. return $this->get('XMLlicenseReActivate.cgi', $args);
  198. }
  199.  
  200. public function expireLicense($args)
  201. {
  202. if (!array_key_exists('liscid', $args)) {
  203. $this->error = 'Invalid License ID (2)';
  204. return NULL;
  205. }
  206.  
  207. if (!$this->validateID($args['liscid'])) {
  208. $this->error = 'Invalid License ID ';
  209. return NULL;
  210. }
  211.  
  212. return $this->get('XMLlicenseExpire.cgi', $args);
  213. }
  214.  
  215. public function extendOnetimeUpdates($args)
  216. {
  217. if (!array_key_exists('ip', $args)) {
  218. $this->error = 'Invalid IP (2)';
  219. return NULL;
  220. }
  221.  
  222. if (!$this->validateIP($args['ip'])) {
  223. $this->error = 'Invalid IP';
  224. return NULL;
  225. }
  226.  
  227. return $this->get('XMLonetimeext.cgi', $args);
  228. }
  229.  
  230. public function changeip($args)
  231. {
  232. if (!array_key_exists('oldip', $args) || !array_key_exists('newip', $args)) {
  233. ........................................................................
  234. ..........................................
  235. ........................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement