Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP][COŚ JEST NIE TAK] Automatyczne sklepik
Forum PHP.pl > Forum > Przedszkole
Rilekt
Witam,
Zacząłem tworzyć sklepik, ale 'wyskakuje mi kilka błedów, są jakieś błedy w kodzie.
Pomożecie mi je znaleźć?!

index.html
  1. <form action="wyslij.php" method="POST">
  2. Nick <input type=text name=1><br>
  3. Kod <input type=text name=2><br>
  4.  
  5. <input type=submit value="Wyślij">
  6. <input type=reset><br>
  7.  
  8. </form>



wyslij.php
  1. <?php
  2. include("PHPSend.php");
  3.  
  4. $con = new PHPSsend();
  5. $succ = $con->PHPSconnect("91.204.162.210","PASSWORD","25565");
  6.  
  7. # teraz spróbujemy sprawdzić poprawność kodu DotPAY
  8.  
  9. $id = 10; # numer ID zarejestrowanego klienta
  10. $code = "abcd";# identyfikator usług SMS
  11. $type = "c1";# typ konta: C1 - 8 znakowy kod bezobsługowy
  12. $page = "poprawny.php";# nazwa pliku jaki ma sie zaladowac po podaniu poprawnego kodu
  13.  
  14. $check = $_POST['check'];
  15. if($check == NULL)
  16. exit("Prosze wpisac kod");
  17.  
  18.  
  19. $handle = fopen("http://dotpay.pl/check_code.php?id=".$id."&code=".$code."&check=".$check."&type=".$type."&del=".$del, 'r');
  20. $status = fgets($handle, 8);
  21. $czas_zycia = fgets($handle, 24);
  22. fclose($handle);
  23. $czas_zycia = rtrim($czas_zycia);
  24.  
  25.  
  26.  
  27. if ($status == 0) {print "Kod niepoprawny."; exit;} # zly kod nie wykonuje phpsend
  28. else
  29. { # gdy kod poprawny:
  30. if (!isset($_COOKIE['ActiveCode'])) # ?!
  31. {
  32. $con->PHPScommand("/setrank nick? VIP 30d"); #przyznaje range
  33. }
  34. header("Location: ".$page); # włączenie strony głównej
  35. }
  36. $succ = $con->PHPSdisconnect();
  37. ?>



Z góry dziękuję
Rysh
Masz źle napisany kod. Mam nadzieję, że pomogłem.
sajegib
Kod
name="1"


pokaż błędy
Rilekt
http://i.imgur.com/E1H6qMo.png <-- błędy w localhost, używam WampServer
r4xz
No przecież drugi błąd masz jawnie napisane co jest nie tak: "nie znaleziono indeksu 'check'" (w tym przypadku czyt. w formularzu nie przesyłasz nic z name="check")

A pierwszy dotyczy pliku PHPSend.php (którego nam nie pokazałeś)
Rilekt
@UP Dziękuję.

PHPsend.php
  1. <?php
  2.  
  3. include("PHPSendConf.php");
  4.  
  5. class PHPSresponse
  6. {
  7. var $msg;
  8. var $from;
  9.  
  10. function isFrom($who)
  11. {
  12. if ($who==$from)
  13. return true;
  14. else
  15. return false;
  16. }
  17. }
  18.  
  19. function recv($socket)
  20. {
  21. $r=socket_read($socket, 256, PHP_NORMAL_READ);
  22. return substr($r,0,-1);
  23. }
  24.  
  25. function PHPSauth($pass)
  26. {
  27. global $PHPSpassword, $PHPSuseWhitelist, $PHPSpostPassword, $PHPSwhitelist;
  28.  
  29. $from=$_SERVER['REMOTE_ADDR'];
  30. if ($PHPSuseWhitelist && !in_array($from,$PHPSwhitelist))
  31. return 1;
  32. if ($pass==sha1($PHPSpostPassword))
  33. return 0;
  34. else
  35. return 2;
  36. }
  37.  
  38. class PHPSsend
  39. {
  40. var $socket=null;
  41.  
  42. function PHPSconnect($adress, $password, $port=11223)
  43. {
  44. $this->socket = socket_create(AF_INET, SOCK_STREAM, 0);
  45.  
  46. socket_set_block($this->socket);
  47.  
  48. $result = socket_connect($this->socket, $adress, $port);
  49.  
  50. if ($this->socket==null)
  51. return 1;
  52.  
  53. socket_write($this->socket, sha1($password)."\n", strlen(sha1($password))+2); //auth
  54. $result=recv($this->socket);
  55.  
  56. if ($result=="PHPSpass0")
  57. return 0;
  58. else if ($result=="PHPSpass1")
  59. return 2;
  60. else if ($result=="PHPSpass2")
  61. return 3;
  62. else if ($result=="PHPSbusy")
  63. return 4;
  64. else
  65. return 5;
  66. }
  67.  
  68. function PHPScommand($command)
  69. {
  70. socket_write($this->socket, "[server]\n",10);
  71. socket_write($this->socket, $command."\n",strlen($command)+2);
  72. $result=recv($this->socket);
  73.  
  74. if ($result!="PHPScmd0")
  75. return 1;
  76. return 0;
  77. }
  78.  
  79. function PHPScommandAsPlayer($player,$command)
  80. {
  81. socket_write($this->socket, $player."\n",strlen($player)+2);
  82. socket_write($this->socket, $command."\n",strlen($command)+2);
  83. $result=recv($this->socket);
  84.  
  85. if ($result!="PHPScmd0")
  86. return 1;
  87. return 0;
  88. }
  89.  
  90. function PHPSdisconnect()
  91. {
  92. socket_write($this->socket, "[server]\n",10);
  93. socket_write($this->socket, "PHPSdisconnect\n",15);
  94. $result=recv($this->socket);
  95.  
  96. if ($result!="PHPSdisconnect0")
  97. return 1;
  98. return 0;
  99. }
  100.  
  101. function PHPSrecv()
  102. {
  103. $result=recv($this->socket);
  104. $resp=explode(':',$result,2);
  105. $r=new PHPresponse();
  106. $r->from=$resp[0];
  107. $r->msg=$resp[1];
  108. return $r;
  109. }
  110.  
  111. function PHPSrecvMsg()
  112. {
  113. $result=recv($this->socket);
  114. $resp=explode(':',$result,2);
  115. return $resp[1];
  116. }
  117. }
  118.  
  119. ?>
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.