This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

tcl connection

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
f
franko
Voice
Posts: 4
Joined: Sun Jul 26, 2009 1:37 pm

tcl connection

Post by franko »

Hello..
Hope that anybody can help me here

I coded a PHP script which sends Information to the Eggdrop.

My problem is that i dont receive them correctly..

Here a snippet from my PHP script:

Code: Select all

$host="IP";
$port="PORT";
$pass="PW";
$channel="#channel";
$channel2="#channel2";

if($board[cforum] !=="1"){
     	if($board[uploadsystem]=="2") {
       if ($board['invisible']==0) {
                              if ($fp=@fsockopen($host,$port,$errno,$errstr,30)) {
	                     fputs($fp,$pass."\r\n");
      	               fputs($fp,"PRIVMSG $channel : \0034\002[New]\003\002 \002$name\002 \0034\002[Poster]\003\002 \002$poster @ $user_c\002\r\n ");
      	               fclose($fp);
      	               $fp=@fsockopen($host,$port,$errno,$errstr,30);
      	               fputs($fp,$pass."\r\n");
      	               fputs($fp,"PRIVMSG $channel : \0034\002[Section]\003\002 \002$board[title]\002 \0034\002[Loc]\003\002 \002$country[country_name]\002 \0034\002[time]\003\002 \002$time2\002\r\n ");
      	               fclose($fp);
      	                     	                     	               $fp=@fsockopen($host,$port,$errno,$errstr,30);
      	               fputs($fp,$pass."\r\n");
      	               fputs($fp,"PRIVMSG $channel : \0034\002[URL]\003\002 \002$URL\002 \r\n ");
      	               fclose($fp);
      	              }
}
}
Anybody an idea how to receive this Information?

lg franko
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

example:

Code: Select all

set port 1234
set host 127.0.0.1

###########################################
bind evnt - prerehash prerehash_proc

set s_socket [socket -server socket_proc -myaddr $host $port]

proc prerehash_proc { type } {
        global s_socket

        close $s_socket
}

proc socket_proc { sock host port } {
        fconfigure $sock -buffering line
        fileevent $sock readable "action $sock $host $port"
}

proc action { chan host port } {
        if {![eof $chan]} {
                set data [gets $chan]

                if {$data != ""} {
                        putquick "PRIVMSG #CHANNEL :data from $host:$port -> data = $data"
                }
        } {
                close $chan
        }
}
its working, but you have to fix your PHP code,
some hints,
1. you don't need to open socket 3 times, you can open it just once, send all data and close it at the end
2. don't send tcl command trough socket, send just data and output it with proper eggdrop script
f
franko
Voice
Posts: 4
Joined: Sun Jul 26, 2009 1:37 pm

Post by franko »

works fine !!

thanks m8
Post Reply