Advertisement
Guest User

Untitled

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