IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Ma fonction ne me retourne rien


Sujet :

Langage PHP

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2008
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 35
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Octobre 2008
    Messages : 218
    Points : 111
    Points
    111
    Par défaut Ma fonction ne me retourne rien
    Bonjour,

    j'ai des valeur _POST qui sont correctement passé à la page (j'ai vérifié), seulement, mon script ne me retourne rien, je ne vois pas ou peut être l'erreur.

    Je vous remercie de votre aide :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    <?php
     
    # Source RCON by William Ruckman (http://ruckman.net)
     
     
        define('PACKET_SIZE', '1400');
        define('SERVERQUERY_INFO', "\xFF\xFF\xFF\xFFTSource Engine Query");
        define ('REPLY_INFO', "\x49");
        define('SERVERQUERY_GETCHALLENGE', "\xFF\xFF\xFF\xFF\x57");
        define ('REPLY_GETCHALLENGE', "\x41");
        define('SERVERDATA_AUTH', 3) ;
        define ('SERVERDATA_EXECCOMMAND', 2) ;
     
        class srcds_rcon
        {
     
             function getLong(&$string)
            {
                $data = substr($string, 0, 4);
                $string = substr($string, 4);
                $data = unpack('Vvalue', $data);
                return $data['value'];
            }
     
          function rcon_command($ip, $port, $password)
            {
    	    $requestId = 1;
                $s2 = '';
                $socket = @fsockopen ('tcp://'.$ip, $port, $errno, $errstr, 30);
                if (!$socket)
                    return 0;
                $data = pack("VV", $requestId, SERVERDATA_AUTH).$password.chr(0).$s2.chr(0);
                $data = pack("V",strlen($data)).$data;        
                fwrite ($socket, $data, strlen($data));
     
                $requestId++ ;
                $junk = fread ($socket, PACKET_SIZE);
                $string = fread ($socket, PACKET_SIZE);
                $size = $this->getLong($string);
                $id = $this->getLong($string) ;
     
                if ($id == -1)
                {
                  return 0;
                }
    	    else
    	   {
    	    return 1; //Si bon rcon : alors on retourne 1, sinon 0
                }
     
     
            }                
        }
     
        $ip = $_POST["ip"];
        $port = $_POST["port"];
        $password = $_POST["rcon"];
     
        $srcds_rcon = new srcds_rcon();
        $OUTPUT = $srcds_rcon->rcon_command($ip, $port, $password);
        return $OUTPUT;
     
     
     
    ?>

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Qu'attends-tu de ton script en faisant return $OUTPUT à la fin ?

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2008
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 35
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Octobre 2008
    Messages : 218
    Points : 111
    Points
    111
    Par défaut
    qu'il me retourne 1 ou 0 de la condition

    if !($socket)
    ou de if ($id == -1)

  4. #4
    Membre émérite
    Avatar de Seb33300
    Homme Profil pro
    Développeur Web
    Inscrit en
    Janvier 2007
    Messages
    1 564
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Thaïlande

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 564
    Points : 2 399
    Points
    2 399

  5. #5
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2008
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 35
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Octobre 2008
    Messages : 218
    Points : 111
    Points
    111
    Par défaut
    5 lettres : YOUPI

    merci beaucoup

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. une fonction qui ne retourne rien
    Par blackvicking dans le forum AppleScript
    Réponses: 3
    Dernier message: 07/12/2013, 20h54
  2. [AJAX] ma fonction ne retourne rien
    Par trigone dans le forum Général JavaScript
    Réponses: 14
    Dernier message: 22/12/2008, 18h06
  3. Ma fonction ne me retourne rien
    Par berti dans le forum Langage
    Réponses: 6
    Dernier message: 12/06/2008, 17h37
  4. fonction qui ne retourne rien, comment c'est possible ?
    Par lOeil dans le forum Général JavaScript
    Réponses: 9
    Dernier message: 02/06/2007, 00h51
  5. Fonction ne retournant rien ?
    Par bds2006 dans le forum Delphi
    Réponses: 8
    Dernier message: 05/06/2006, 14h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo