Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> łączenie dostpaya z innym skryptem
Sahee
post 1.09.2011, 19:21:12
Post #1





Grupa: Zarejestrowani
Postów: 34
Pomógł: 0
Dołączył: 1.09.2011

Ostrzeżenie: (0%)
-----


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 !
Go to the top of the page
+Quote Post
Rid
post 1.09.2011, 19:24:02
Post #2





Grupa: Zarejestrowani
Postów: 715
Pomógł: 47
Dołączył: 5.12.2010

Ostrzeżenie: (0%)
-----


Założył Pan dwa takie same tematy.

Ten post edytował Rid 1.09.2011, 19:24:20
Go to the top of the page
+Quote Post
phpion
post 2.09.2011, 07:14:58
Post #3





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




@Rid:
Proszę nie bawić się w moderatora. Masz przycisk "Raportuj" i jego używaj.

PS: Zdublowany temat poleciał do kosza.
Go to the top of the page
+Quote Post
dmateo
post 2.09.2011, 10:08:37
Post #4





Grupa: Zarejestrowani
Postów: 27
Pomógł: 3
Dołączył: 19.05.2009

Ostrzeżenie: (0%)
-----


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. }
Go to the top of the page
+Quote Post
Sahee
post 2.09.2011, 11:52:01
Post #5





Grupa: Zarejestrowani
Postów: 34
Pomógł: 0
Dołączył: 1.09.2011

Ostrzeżenie: (0%)
-----


A możesz mi to złączyć w jedna całość?
Go to the top of the page
+Quote Post
tehaha
post 2.09.2011, 12:20:48
Post #6





Grupa: Zarejestrowani
Postów: 1 748
Pomógł: 388
Dołączył: 21.08.2009
Skąd: Gdynia

Ostrzeżenie: (0%)
-----


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.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 26.06.2025 - 03:07