Advertisement
Guest User

Untitled

a guest
Sep 16th, 2018
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. <?php
  2. session_start();
  3. ini_set('display_errors', 0);
  4.  
  5. if (!isset($_SESSION['username'])) {
  6. $_SESSION['msg'] = "You must log in first";
  7. header('location: ..\login');
  8. die();
  9. }
  10.  
  11. define("SELLY_EMAIL", "nex@weebware.net");
  12. define("SELLY_API_KEY", "");
  13.  
  14.  
  15. // connect to the database
  16. include secret_directory('config.php'); // SQL Server stuff
  17. $server_server = $config['server'];
  18. $server_username = $config['username'];
  19. $server_password = $config['password'];
  20. $server_dbname = $config['dbname'];
  21. $server_status = $config['status'];
  22. $conn = new PDO('mysql:host=' . $server_server . ';dbname=' . $server_dbname, $server_username, $server_password,[PDO::ATTR_DEFAULT_FETCH_MODE=>PDO::FETCH_ASSOC]);
  23.  
  24.  
  25. $username = $_SESSION['username'];
  26. $email = $_POST['email'];
  27.  
  28. if (isset($_POST['submit_purchase'])) {
  29. $secret = generateRandomString(16);
  30. $webhook_url = 'https://syzy.us/buy/webhook.php?secret=' . $secret;
  31. $request = selly_pay('syzy.us 1 month', 'PayPal', $email, '20', 'USD', 'https://syzy.us/home', $webhook_url);
  32. $createOrder = $conn->prepare("INSERT INTO orders (id, secret, order_id, user, status) VALUES ('', :secret, :order_id, :user, :status);");
  33. $createOrder->bindValue(':secret', $secret);
  34. $createOrder->bindValue(':order_id', $request['id']);
  35. $createOrder->bindValue(':user', $username);
  36. $createOrder->bindValue(':status', $request['status']);
  37. $createOrder->execute();
  38.  
  39. $redirect = $request['url'];
  40. header('location:' . $redirect);
  41. }
  42.  
  43. // thank justin for help ;3
  44. function selly_pay($title, $gateway, $email, $value, $currency, $return_url, $webhook_url) {
  45. $params = array ('title' => $title, 'gateway' => $gateway, 'email' => $email, 'value' => $value, 'currency' => $currency, 'return_url' => $return_url, 'webhook_url' => $webhook_url, 'white_label' => true);
  46. $query = http_build_query ($params);
  47. $auth = base64_encode(SELLY_EMAIL.':'.SELLY_API_KEY);
  48. $opts = array(
  49. 'http'=>array(
  50. 'method'=>"POST",
  51. 'header'=>
  52. "User-agent: {$email} - {$_SERVER['SERVER_NAME']}\r\n" .
  53. "Authorization: Basic {$auth}\r\n" .
  54. "Content-Type: application/x-www-form-urlencoded",
  55. 'content' => $query
  56. )
  57. );
  58. $context = stream_context_create($opts);
  59. $result = file_get_contents('https://selly.gg/api/v2/pay', false, $context);
  60. $data = json_decode($result, true);
  61. return $data;
  62. }
  63.  
  64. function generateRandomString($length) {
  65. $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  66. $charactersLength = strlen($characters);
  67. $randomString = '';
  68. for ($i = 0; $i < $length; $i++) {
  69. $randomString .= $characters[rand(0, $charactersLength - 1)];
  70. }
  71. return $randomString;
  72. }
  73.  
  74. function secret_directory($fileName) {
  75. return 'RmNy5KApCY/' . $fileName;
  76. }
  77.  
  78. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement