Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: łączenie dostpaya z innym skryptem
Forum PHP.pl > Forum > PHP
Sahee
Siemka, potrzebuję połączyć 2 skrypty ze sobą.
Pierwszy to Whitelista do serwera MineCraft
a drugi to skrypt płatności SMS w dotpay'u


to skrypt sprawdzający czy dany kod jest aktywny (nie zużyty):
  1. <?php
  2. echo file_get_contents('http://dotpay.pl/check_code_fullinfo.php?type=sms&del=1&id=34286&code=LESSER&check=' . $sms);
  3. ?>


A tutaj kod z indexu który najprawdopodobniej trzeba przerobić :

  1. <?php
  2. $finish = false;
  3. include("config.php");
  4. require_once("libs/recaptchalib.php");
  5. $error= "";
  6. function Valid(){
  7. include("config.php");
  8. $resp = recaptcha_check_answer ($recaptcha_privatekey,
  9. $_SERVER["REMOTE_ADDR"],
  10. $_POST["recaptcha_challenge_field"],
  11. $_POST["recaptcha_response_field"]);
  12. if ($resp->is_valid or $recaptcha_enabled == false) {
  13. if(isset($_POST["username"]) and strlen($_POST["username"]) > 0 and $_POST["username"] != ""){
  14. $con = @mysql_connect($host,$username,$password);
  15. if($con == null){
  16. $error = "<span style='color: #990000;'>MySQL error: " . mysql_error() ."</span>";
  17. return $error;
  18. }
  19. $db = @mysql_select_db($db);
  20. if($db == null){
  21. $error = "<span style='color: #990000;'>MySQL error: " . mysql_error() ."</span>";
  22. return $error;
  23. }
  24. $IngameUsername = mysql_escape_string($_POST["username"]);
  25.  
  26. $result = @mysql_query("INSERT INTO `$table` (`name`) VALUES ('$IngameUsername');");
  27. if($result == null){
  28. $error = "<span style='color: #990000;'>MySQL error: " . mysql_error() ."</span>";
  29. return $error;
  30. }
  31. $error = "<span style='color: #009900;'>You are now added to the whitelist. Please wait a few minutes before trying to connect!</span>";
  32. return $error;
  33. }else{
  34. $error = "<span style='color: #990000;'>You need to enter your minecraft username!</span>";
  35. return $error;
  36. }
  37. }else{
  38. if(isset($_POST["formsent"])){
  39. $error = "<span style='color: #990000;'>Wrong captcha entered!</span>";
  40. return $error;
  41. }
  42. }
  43. }
  44. $error = Valid();
  45. ?>
  46. <html>
  47. <head>
  48. <title>Whitelist User</title>
  49.  
  50. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  51.  
  52. <script type="text/javascript" src="js/custom-form-elemtents.js"></script>
  53.  
  54. <link rel="stylesheet" href="css/default.css" media="screen" />
  55. </head>
  56. <body>
  57. <div class="wrapper">
  58. <fieldset>
  59. <legend>
  60. Whitelist submission
  61. </legend>
  62. <form method="post" action="">
  63. <?php
  64. if($recaptcha_enabled){
  65. echo "Anti-bot verification:<br />";
  66. echo recaptcha_get_html($recaptcha_publickey);
  67. }
  68. ?>
  69. Minecraft username:<br />
  70. <input type="hidden" id="formsent" name="formsent" />
  71. <input type="text" id="username" name="username" class="input" />
  72. <input type="submit" class="submit"/>
  73. </form>
  74. <?php
  75. echo $error;
  76. ?>
  77. </fieldset>
  78. </div>
  79. </body>
  80. </html>

Config:
  1. <?php
  2. $host = "localhost";
  3. $username = "";
  4. $password = "";
  5. $db = "";
  6. $table = "";
  7.  
  8. //Re-captcha
  9. $recaptcha_enabled = false;
  10. $recaptcha_publickey = "";
  11. $recaptcha_privatekey = "";
  12. ?>


To na tyle, jak będzie coś jeszcze potrzebne to pisać w tym temacie, z góry dziękuje za pomoc i wysiłek smile.gif !
Rid
Założył Pan dwa takie same tematy.
phpion
@Rid:
Proszę nie bawić się w moderatora. Masz przycisk "Raportuj" i jego używaj.

PS: Zdublowany temat poleciał do kosza.
dmateo
Na pewno trzeba będzie dodać nowy Input na kod z sms:

  1. <input type="text" id="sms" name="sms" class="input" />


Oraz obsłużyć wprowadzony kod, np.

  1. // zakladajac ze kod jest intem
  2. $sms = intval($_POST['sms']);
  3.  
  4. // z tego co widze dotpay zwraca 1 lub 0
  5. $result = intval( file_get_contents('http://dotpay.pl/check_code_fullinfo.php?type=sms&del=1&id=34286&code=LESSER&check=' . $sms) );
  6.  
  7. If ( $result === 0 )
  8. {
  9. $error = "<span style='color: #990000;'>Wrong sms code!</span>";
  10. return $error;
  11. }
Sahee
A możesz mi to złączyć w jedna całość?
tehaha
Dostałeś już wszystko co potrzebujesz, wykaż odrobinę inicjatywy.

Nie potrzebne jest to pierwsze intval(), bo przecież kod sms to nie tylko cyfry. Input wstaw do formularza a kod php po linijce 30.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.