Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. <?php
  2.  
  3. $config = require "../config.php";
  4. require "../database.php";
  5.  
  6. if(isset($_REQUEST["ch"])) {
  7. $username = $_REQUEST["ch"][0];
  8. array_shift($_REQUEST["ch"]);
  9.  
  10. if(count($_REQUEST["ch"]) > 0) {
  11. $database = new DataBase(
  12. $config["mysql"]["host"],
  13. $config["mysql"]["user"],
  14. $config["mysql"]["password"],
  15. $config["mysql"]["database"]
  16. );
  17.  
  18. $cost = 0;
  19. foreach($_REQUEST["ch"] as $row) {
  20. $ex = explode("-", $row);
  21. $cost = $cost + $config["capabilities"][$ex[1]]["cost"];
  22. }
  23.  
  24. $database->query("CREATE TABLE IF NOT EXISTS `cd_payments` (
  25. `id` int(11) NOT NULL AUTO_INCREMENT,
  26. `values` text NOT NULL,
  27. `username` text NOT NULL,
  28. `status` int(11) NOT NULL,
  29. `sum` int(11) NOT NULL,
  30. PRIMARY KEY (`id`)
  31. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
  32.  
  33. function getFormSignature($account, $desc, $sum) {
  34. $hashStr = $account.'{up}'.$desc.'{up}'.$sum.'{up}'.$config["unitpay"]["secret_key"];
  35. return hash('sha256', $hashStr);
  36. }
  37.  
  38. $data = implode(",", $_REQUEST["ch"]);
  39. $account = $database->query("INSERT INTO `cd_payments` (`id`, `values`, `username`, `status`, `sum`) VALUES (NULL, {?}, {?}, {?}, {?})", [$data, $username, 0, $cost]);
  40. $account = $account."_construct";
  41.  
  42. $message = "Создание доната в конструкторе для игрока {$username}";
  43. $public_key = $config["unitpay"]["public_key"];
  44.  
  45. $signature = getFormSignature($account, $message, $cost);
  46. $unitpay_uri = "https://unitpay.ru/pay/{$public_key}/qiwi?sum={$cost}&account={$account}&desc={$message}&signature={$signature}";
  47. die(json_encode(array("status" => "success", "uri" => $unitpay_uri)));
  48. } else {
  49. die(json_encode(array("status" => "fail", "message" => "Выберите любую возможность")));
  50. }
  51. }
  52.  
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement