Page 1 of 1 [ 3 posts ] 

Albinoboy
Yellow-bellied Woodpecker
Yellow-bellied Woodpecker

User avatar

Joined: 5 Aug 2010
Age: 29
Gender: Male
Posts: 70
Location: Surrey, England

11 Dec 2010, 7:19 pm

Code:
ircservices@LXS-SC1:~$ php nickserv.php
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/ircservices/nickserv.php on line 77
ircservices@LXS-SC1:~$

Not sure what went wrong there...
Code:
               /* Help list */
                        if(strtolower($ex[3])==":help"){
                                $nick=$ex2[1];
                                $nick=explode(' ', $nick);
                                $nick=$nick[0];
                                echo "[SENDING] %HELPLIST%";
                                fputs($this->socket, "NOTICE ".$nick." :"- Snowy's Nickname Service - Help -\n");
                                fputs($this->socket, "NOTICE ".$nick." :REGISTER - Information about how to register\n");
                                fputs($this->socket, "NOTICE ".$nick." :IDENTIFY - Login to Services\n");
                        }
                        if(strtolower($ex[3])==":register"){
                                $nick=$ex2[1];

This line gave me the same error, but when I changed the qoutes from a single (') to a double (") it fixed it, which is odd because I use the exact line before (see above)
Code:
                                $nick=explode(" ", $nick);

The rest of the code until the error line
Code:
                                $nick=$nick[0];
                                echo "[SENDING] REGISTERINFO";

This is the error line:
Code:
                                fputs($this->socket, "NOTICE ".$nick." :- Snowy's Nickname Service - Register -\n");

and the rest of the code (up until the next if that is)
Code:
                                fputs($this->socket, "NOTICE ".$nick." :To register an account, go to:\n");
                                fputs($this->socket, "NOTICE ".$nick." :http://ident.yourlifegroup.org/index.php\n");
                                fputs($this->socket, "NOTICE ".$nick." :and register for an account there\n");
                                fputs($this->socket, "NOTICE ".$nick." :Then you can use the IDENTIFY command\n");
                        }



mcg
Veteran
Veteran

User avatar

Joined: 26 Jan 2010
Age: 35
Gender: Male
Posts: 538
Location: Sacramento

12 Dec 2010, 1:04 am

If changing from single quotes to double quotes seemed to fix that line, then I suspect you have some screwed up quotes in the code above this code somewhere. If you want to post the whole file then I can take a look for you.



Albinoboy
Yellow-bellied Woodpecker
Yellow-bellied Woodpecker

User avatar

Joined: 5 Aug 2010
Age: 29
Gender: Male
Posts: 70
Location: Surrey, England

12 Dec 2010, 3:08 pm

BUG SOLVED

Code:
fputs($this->socket, "NOTICE ".$nick." :"- Snowy's Nickname Service - Help -\n");

Removed " after the :

Code:
<?php
/* Run bot run! */
set_time_limit(0);

$config=array(
   'nick'   =>   'NickServ2',      // Nickname
   'name'   =>   'Nickname Service',   // Name
   'svip'   =>   '192.168.0.128',   // Service Server IP
   'port'   =>   6667,         // Service Server Port
   /* Service's virtual host */
   'host'   =>   'services.snowy.yourlifegroup.org'
);

/* Set up Service class */
class Service {
   var $socket;

   /* Starting function */
   function __construct($config){
      echo "[CONNECT] Openning Socket\n";
      $this->socket = fsockopen($config['svip'], $config['port']);
      $this->connect($config);
      $this->NickServ($config);
   }

   /* Connect to services server */
   function connect($config){
      echo "[SENDING] USER ".$config['nick']." ".$config['host']." ".$config['nick']." :".$config['name']."\n";
      fputs($this->socket, "USER ".$config['nick']." ".$config['host']." ".$config['nick']." :".$config['name']."\n");
      echo "[SENDING] NICK ".$config['nick']."\n";
      fputs($this->socket, "NICK ".$config['nick']."\n");
      echo "[SENDING] MODE ".$config['nick']." +oS\n";
      fputs($this->socket, "MODE ".$config['nick']." +oS\n");
   }

   /* Working Function */
   function NickServ($config){
      while(true){
         $input=fgets($this->socket, 256);
         $input=trim($input);
         echo "[RECIEVED] ".$input."\n";
         $ex=explode(' ', $input);
         $ex2=explode(':', $input);

         /* Do Stuff! */
         if(strtolower($ex[3])==":devtest"){
            echo "[DEBUG] Doing Dev Test\n";
            echo "[SENDING] JOIN #opers\n";
            fputs($this->socket, "JOIN #opers\n");
            echo "[SENDING] PRIVMSG #opers :This is a Development test\n";
            fputs($this->socket, "PRIVMSG #opers :This is a development test\n");
            echo "[SENDING] NOTICE #opers :This is a notice\n";
            fputs($this->socket, "NOTICE #opers :This is a notice\n");
            echo "[SENDING] MODE #opers +ao ".$config['nick']." ".$config['nick']."\n";
            fputs($this->socket, "MODE #opers +ao ".$config['nick']." ".$config['nick']."\n");
            echo "[SENDING] PART #opers\n";
            fputs($this->socket, "PART #opers\n");
            echo "[DEBUG] Dev Test complete\n";
         }

         /* Help list */
         if(strtolower($ex[3])==":help"){
            $nick=$ex2[1];
            $nick=explode(' ', $nick);
            $nick=$nick[0];
            echo "[SENDING] %HELPLIST%";
            fputs($this->socket, "NOTICE ".$nick." :"- Snowy's Nickname Service - Help -\n");
            fputs($this->socket, "NOTICE ".$nick." :REGISTER - Information about how to register\n");
            fputs($this->socket, "NOTICE ".$nick." :IDENTIFY - Login to Services\n");
         }
         if(strtolower($ex[3])==":register"){
            $nick=$ex2[1];
                                $nick=explode(' ', $nick);
                                $nick=$nick[0];
            echo "[SENDING] %REGISTERINFO%";
            fputs($this->socket, "NOTICE ".$nick." :- Snowy's Nickname Service - Register -\n");
            fputs($this->socket, "NOTICE ".$nick." :To register an account, go to:\n");
            fputs($this->socket, "NOTICE ".$nick." :http://ident.yourlifegroup.org/index.php\n");
            fputs($this->socket, "NOTICE ".$nick." :and register for an account there\n");
            fputs($this->socket, "NOTICE ".$nick." :Then you can use the IDENTIFY command\n");
         }
         if(strtolower($ex[3])==":identify"){
            if($ex[4]=='' || $ex[5]==''){
               echo "[SENDING] %IDENTINFO%";
               fputs($this->socket, "NOTICE ".$nick."- Snowy's Nickname Service - Identify -\n");
               fputs($this->socket, "NOTICE ".$nick."Syntax: IDENTIFY <username> <password>\n");
            }else{
               echo "[SENDING] NOTICE ".$nick." :- Snowy's Nickname Service - Identify -\n";
               fputs($this->socket, "NOTICE ".$nick." :- Snowy's Nickname Service - Identify -\n");
               echo "[SENDING] NOTICE ".$nick." :Connecting to Yourlife Ident and verifying\n");
               fputs($this->socket, "NOTICE ".$nick." :Connecting to Yourlife Ident and verifying\n");
               $ident=file_get_contents("http://ident.yourlifegroup.org/api.php?u=".$ex[4]."&p=".$ex[5]."&s=somerandomkeythatiamnotgoingtogive");
               if($ident==strtolower($nick)){
                  echo "[SENDING] NOTICE ".$nick." :Successfully identified!\n";
                  fputs($this->socket, "NOTICE ".$nick." :Successfully identified!\n");
                  echo "[SENDING] MODE ".$nick." +r\n";
                  fputs($this->socket, "MODE ".$nick." +r\n");
               }else{
                  echo "[SENDING] NOTICE ".$nick." :Failed to identify!\n";
                  fputs($this->socket, "NOTICE ".$nick." :Failed to identify!\n");
               }
            }
         }
      }
   }
}
$service = new Service($config);
?>

EDIT:
Code:
f($ident==strtolower($nick)){

Added a ')'.
Code:
fputs($this->socket, "NOTICE ".$nick." :Failed to identify!\n");

Added a '\n'
Code:
var $ex;

Removed, never used. ($ex is used, but not var $ex ($this->ex))