<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/15354" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2008-02-07T12:45:13-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/15354</id>

		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2008-02-06T18:38:01-04:00</updated>

		<published>2008-02-06T18:38:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=80705#p80705</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=80705#p80705"/>
		<title type="html"><![CDATA[Request: Announcement from PHP.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=80705#p80705"><![CDATA[
This forum is intended for Eggdrops and Eggdrop Tcl scripting. PHP is not supported here, you'll have to seek help in a forum related to PHP.<br><br>Edit: It seems there has been a misunderstanding, it's not clear that you're requesting a Tcl-script from your initial post. I suggest you elaborate more on what you want your Eggdrop to do.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Wed Feb 06, 2008 6:38 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[tueb]]></name></author>
		<updated>2008-02-06T14:48:21-04:00</updated>

		<published>2008-02-06T14:48:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=80698#p80698</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=80698#p80698"/>
		<title type="html"><![CDATA[Request: Announcement from PHP.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=80698#p80698"><![CDATA[
hi,<br><br>maybe this script helps you. it opens a telnet-conenction to your bot:<br> <div class="codebox"><p>Code: </p><pre><code>&lt;?$telnet = new telnet();$fp = $telnet-&gt;connect();$telnet-&gt;write("telnet-nick");$telnet-&gt;write("telnet-pass");$telnet-&gt;write(".msg #wheretosay whattosay");$telnet-&gt;disconnect();/*$Id: telnet.class.php,v 1.2 2004/03/22 10:01:35 mb Exp $Originally written by Marc Ennaji (in french),modified by Matthias Blaser &lt;mb@adfinis.ch&gt;- translated most function- and variable names from french to english- added get_buffer-method to get results of the last command  sent to server- added hack to get socket_strerror working on old systemsYou can find the original class which this translation is based onon this url: http://px.sklar.com/code.html?id=634The original class includes a small documentation about using itin your own applications, but be aware, all functions are in french there, thisone is partly translated.*/// hack to get socket_strerror working on old systemsif(!function_exists("socket_strerror")){    function socket_strerror($sh){        if(function_exists("strerror")){            return strerror($sh);        } else {            return false;        }    }}// telnet classdefine ("TELNET_ERROR", 0);define ("TELNET_OK", 1);define ("TELNET_ASK_CONFIRMATION", 2);define ("LIBELLE_CONFIRMATION", "[confirm]");class telnet {    var $socket  = NULL;    var $host = "89.110.157.240";    var $port = "33335";    var $error = "";    var $codeError = "";    var $prompt = "\$ ";    var $log = NULL;  // file handle    var $repertoireLog= "";    var $nomFichierLog = "";    var $test;    var $buffer = "";    //------------------------------------------------------------------------    function connect(){        $this-&gt;socket = fsockopen($this-&gt;host,$this-&gt;port);        if (!$this-&gt;socket){            $this-&gt;error = "unable to open a telnet connection: " . socket_strerror($this-&gt;socket) . "\n";            return TELNET_ERROR;        }        socket_set_timeout($this-&gt;socket,10,0);        return TELNET_OK;    }    //------------------------------------------------------------------------    function read_to($chaine){        $NULL = chr(0);        $IAC = chr(255);        $buf = '';        if (!$this-&gt;socket){            $this-&gt;error = "telnet socket is not open";            return TELNET_ERROR;        }        while (1){            $c = $this-&gt;getc();            if ($c === false){             // plus de caracteres a lire sur la socket                if ($this-&gt;contientErreur($buf)){                    return TELNET_ERROR;                }                $this-&gt;error = " Couldn't find the requested : '" . $chaine . "', it was not in the data returned from server : '" . $buf . "'" ;                $this-&gt;logger($this-&gt;error);                return TELNET_ERROR;            }            if ($c == $NULL || $c == "\021"){                continue;            }            if ($c == $IAC){                // Interpreted As Command                $c = $this-&gt;getc();                if ($c != $IAC){                    // car le 'vrai' caractere 255 est doubl. pour le differencier du IAC                    if (! $this-&gt;negocierOptionTelnet($c)){                        return TELNET_ERROR;                    } else {                        continue;                    }                }            }            $buf .= $c;            // append current char to global buffer            $this-&gt;buffer .= $c;            // indiquer . l'utilisateur de la classe qu'il a une demande de confirmation            if (substr($buf,strlen($buf)-strlen(LIBELLE_CONFIRMATION)) == LIBELLE_CONFIRMATION){                $this-&gt;logger($this-&gt;getDernieresLignes($buf));                return TELNET_ASK_CONFIRMATION;            }            if ((substr($buf,strlen($buf)-strlen($chaine))) == $chaine){                // on a trouve la chaine attendue                $this-&gt;logger($this-&gt;getDernieresLignes($buf));                if ($this-&gt;contientErreur($buf)){                    return TELNET_ERROR;                } else {                    return TELNET_OK;                }            }        }    }    //------------------------------------------------------------------------    function getc(){        return fgetc($this-&gt;socket);    }    //------------------------------------------------------------------------    function get_buffer(){        $buf = $this-&gt;buffer;        // cut last line (is always prompt)        $buf = explode("\n", $buf);        unset($buf[count($buf)-1]);        $buf = join("\n",$buf);        return trim($buf);    }    //------------------------------------------------------------------------    function negocierOptionTelnet($commande){        // on negocie des options minimales        $IAC = chr(255);        $DONT = chr(254);        $DO = chr(253);        $WONT = chr(252);        $WILL = chr(251);        if (($commande == $DO) || ($commande == $DONT)){            $opt = $this-&gt;getc();            //echo "wont ".ord($opt)."\n";            fwrite($this-&gt;socket,$IAC.$WONT.$opt);        } else if (($commande == $WILL) || ($commande == $WONT)) {            $opt = fgetc($this-&gt;socket);            //echo "dont ".ord($opt)."\n";            fwrite($this-&gt;socket,$IAC.$DONT.$opt);        } else {            $this-&gt;error = "Error : unknown command ".ord($commande)."\n";            return false;        }        return true;    }    //------------------------------------------------------------------------    function write($buffer, $valeurLoggee = "", $ajouterfinLigne = true){        // clear buffer from last command        $this-&gt;buffer = "";        if (! $this-&gt;socket){            $this-&gt;error = "telnet socket is not open";            return TELNET_ERROR;        }        if ($ajouterfinLigne){            $buffer .= "\n";        }        if (fwrite($this-&gt;socket,$buffer) &lt; 0){            $this-&gt;error = "error writing to socket";            return TELNET_ERROR;        }        if ($valeurLoggee != ""){            // cacher les valeurs confidentielles dans la log (mots de passe...)            $buffer = $valeurLoggee . "\n";        }        if (! $ajouterfinLigne){            // dans la log (mais pas sur la socket), rajouter tout de meme le caractere de fin de ligne            $buffer .= "\n";        }        $this-&gt;logger("&gt; " .$buffer);        return TELNET_OK;    }    //------------------------------------------------------------------------    function disconnect(){        if ($this-&gt;socket){            if (! fclose($this-&gt;socket)){                $this-&gt;error = "error while closing telnet socket";                return TELNET_ERROR;            }            $this-&gt;socket = NULL;        }        $this-&gt;setLog(false,"");        return TELNET_OK;    }    //------------------------------------------------------------------------    function contientErreur($buf){        $messagesErreurs[] = "nvalid";       // Invalid input, ...        $messagesErreurs[] = "o specified";  // No specified atm, ...        $messagesErreurs[] = "nknown";       // Unknown profile, ...        $messagesErreurs[] = "o such file or directory"; // sauvegarde dans un repertoire inexistant        $messagesErreurs[] = "llegal";       // illegal file name, ...        foreach ($messagesErreurs as $erreur){            if (strpos ($buf, $erreur) === false)                continue;                // une erreur est d.tect.e                $this-&gt;error =  "Un message d'erreur a .t. d.tect. dans la r.ponse de l'h.te distant : " .                    "&lt;BR&gt;&lt;BR&gt;" . $this-&gt;getDernieresLignes($buf,"&lt;BR&gt;") . "&lt;BR&gt;";                return true;            }        return false;    }    //------------------------------------------------------------------------    function wait_prompt(){        return $this-&gt;read_to($this-&gt;prompt);    }    //------------------------------------------------------------------------    function set_prompt($s){        $this-&gt;prompt = $s;        return TELNET_OK;    }    //------------------------------------------------------------------------    function set_host($s){        $this-&gt;host = $s;    }    //------------------------------------------------------------------------    function set_port($s){        $this-&gt;port = $s;    }    //------------------------------------------------------------------------    function get_last_error(){        return $this-&gt;error;    }    //------------------------------------------------------------------------    function setLog($activerLog, $traitement){        if ($this-&gt;log &amp;&amp; $activerLog){            return TELNET_OK;        }        if ($activerLog){            $this-&gt;repertoireLog =  "/log/" . date("m");            // repertoire mensuel inexistant ?            if (! file_exists($this-&gt;repertoireLog)){                if (mkdir($this-&gt;repertoireLog, 0700) === false){                    $this-&gt;error = "Impossible de cr.er le repertoire de log " .  $this-&gt;repertoireLog;                    return TELNET_ERROR;                }            }            global $HTTP_SERVER_VARS;            $this-&gt;nomFichierLog =     date("d") . "_" .                date("H:i:s") . "_" .            $traitement . "_" .                $HTTP_SERVER_VARS["PHP_AUTH_USER"]                . ".log";            $this-&gt;log = fopen($this-&gt;repertoireLog . "/" . $this-&gt;nomFichierLog,"a");            if (empty($this-&gt;log)){                $this-&gt;error = "Impossible de cr.er le fichier de log " . $this-&gt;nomFichierLog;                return TELNET_ERROR;            }            $this-&gt;logger("----------------------------------------------\r\n");            $this-&gt;logger("D.but de la log de l'utilisateur " . $HTTP_SERVER_VARS["PHP_AUTH_USER"] .                ", adresse IP " . $HTTP_SERVER_VARS["REMOTE_ADDR"] . "\r\n");            $this-&gt;logger("Connexion telnet sur " . $this-&gt;host . ", port " . $this-&gt;port . "\r\n");            $this-&gt;logger("Date : " . date("d-m-Y").  "  . " . date("H:i:s") . "\r\n");            $this-&gt;logger("Type de traitement effectu. : " . $traitement . "\r\n");            $this-&gt;logger("----------------------------------------------\r\n");            return TELNET_OK;        } else {            if ($this-&gt;log){                $this-&gt;logger("----------------------------------------------\r\n");                $this-&gt;logger("Fin de la log\r\n");                fflush($this-&gt;log);                if (! fclose($this-&gt;log)){                    $this-&gt;error = "erreur a la fermeture du fichier de log";                    return TELNET_ERROR;                }                $this-&gt;log = NULL;            }            return TELNET_OK;        }    }    //------------------------------------------------------------------------    function logger($s){        if ($this-&gt;log){            fwrite($this-&gt;log, $s);        }    }    //------------------------------------------------------------------------    function getDernieresLignes($s, $separateur="\n"){        // une reponse telnet contient (en principe) en premiere ligne l'echo de la commande utilisateur.        // cette methode renvoie tout sauf la premiere ligne, afin de ne pas polluer les logs telnet        $lignes = split("\n",$s);        $resultat = "";        $premiereLigne = true;        while(list($key, $data) = each($lignes)){            if ($premiereLigne){                $premiereLigne = false;            } else {                if ($data != ""){                    $resultat .= $data . $separateur;                }            }        }        $resultat == substr($resultat,strlen($resultat)-1); // enlever le dernier caractere de fin de ligne        return $resultat;    }    //------------------------------------------------------------------------}   //    Fin de la classe?&gt; </code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9349">tueb</a> — Wed Feb 06, 2008 2:48 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[vsoemlio]]></name></author>
		<updated>2008-02-07T12:45:13-04:00</updated>

		<published>2008-02-06T10:24:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=80686#p80686</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=80686#p80686"/>
		<title type="html"><![CDATA[Request: Announcement from PHP.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=80686#p80686"><![CDATA[
Hello<br><br>I'm making a website, and when the PHP-script add's a new entry to the database, I want to have a snippet in the PHP that send a msg to my eggdrop.<br><br>Can someone make a easy script with a password protection. Also, the php needs to send a password to verify.<br><br>Thanks <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br><strong class="text-strong">Edit:</strong> Sorry for misunderstandings, but I'm actually requesting a TCL-script to communicate with PHP.<br><br>I have this PHP-script:<div class="codebox"><p>Code: </p><pre><code>&lt;?php$botip = "127.0.0.1";$botport = "22739";$socket = fsockopen ($botip, $botport, $error, $errorstr, 60);$line = "Hei";if ( $socket ) {while ( !feof($socket) ) {$str = fgets($socket, 4096);if ( strcmp($str, "go") ) {#$out .= substr( $str, strlen($control)+1 );fputs($socket, $line . "\n");}}} fclose($socket);?&gt;</code></pre></div>And this tcl script:<div class="codebox"><p>Code: </p><pre><code>listen 22739 script listener pub proc listener {idx} {   control $idx listenerin   putdcc $idx "go\n"} proc listenerin {idx args} {   putlog $args   putserv "PRIVMSG #chan : $args"}</code></pre></div>When I run the php-script I got this in log:<div class="codebox"><p>Code: </p><pre><code>[17:44] Telnet connection: localhost/39894[17:44] Timeout/EOF ident connection[17:44] Hei</code></pre></div>Why timeout?<br><br>I want to compare a password-string the php script sends to tcl in the tcl script, and only allow scripts with the correct password.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8717">vsoemlio</a> — Wed Feb 06, 2008 10:24 am</p><hr />
]]></content>
	</entry>
	</feed>
