Telnet and PHP
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
- Zoey76
- L2j Inner Circle
- Posts: 7005
- Joined: Tue Aug 11, 2009 3:36 am
Telnet and PHP
Hello community, I'll try to write a few functions in PHP to use telnet from a website
Note that commands that use a parameter needs one space.
Also you might need to use a form to submit the actions.
At the moment it's only the PHP code part.
When I get time I'll post something complete.
This is just an example:
Note that commands that use a parameter needs one space.
Also you might need to use a form to submit the actions.
At the moment it's only the PHP code part.
When I get time I'll post something complete.
This is just an example:
You do not have the required permissions to view the files attached to this post.
Powered by Eclipse 4.30 | Eclipse Temurin 21 | MariaDB 11.3.2 | L2J Server 2.6.3.0 - High Five
Join our Discord!
Join our Discord!
- UnAfraid
- L2j Veteran
- Posts: 4199
- Joined: Mon Jul 23, 2007 4:25 pm
- Location: Bulgaria
- Contact:
Re: Telnet and PHP
here is my version
[php]<?phpclass telnet { var $ip = '127.0.0.1'; var $port = 12345; var $timeout = 2; var $password = 'rndpasswd?'; function command($command) { $fp=@fsockopen($this->ip,$this->port,$errno,$errstr, $this->timeout); if(!$fp) return "<font color=#6F5A0B>Warning:</font> No telnet connection to Server.<br>"; else { fputs($fp, $this->password . "\r"); fputs($fp, $command . "\r"); fputs($fp,"quit\r"); $output = ''; while(!feof($fp)) $output.=fread($fp,16); fclose($fp); $clear_r=array("Please Insert Your Password!","Password Correct!","Welcome To The L2J Telnet Session.","[L2J]","Bye Bye!"); $output = str_replace($clear_r,"", $output); if(strstr($output,"Incorrect Password!")) return "<font color=#6F5A0B>Warning:</font> Incorrect Telnet Password.<br>"; return $output; } } function Execute($command) { return $this->command($command); } function give($char, $item, $count) { return $this->command("give " . $char . " " . $item . " " . $count . "\r"); } function kick($char_name) { $this->command("kick ".$char_name."\r"); } function stats() { return $this->command("stats\r"); }}?>[/php]
using
[php]$telnet = new telnet; $telnet->ip = '127.0.0.1'; $telnet->port = 12345; $telnet->password = 'password'; $telnet->timeout = 2; echo $telnet->Execute('help');[/php]
[php]<?phpclass telnet { var $ip = '127.0.0.1'; var $port = 12345; var $timeout = 2; var $password = 'rndpasswd?'; function command($command) { $fp=@fsockopen($this->ip,$this->port,$errno,$errstr, $this->timeout); if(!$fp) return "<font color=#6F5A0B>Warning:</font> No telnet connection to Server.<br>"; else { fputs($fp, $this->password . "\r"); fputs($fp, $command . "\r"); fputs($fp,"quit\r"); $output = ''; while(!feof($fp)) $output.=fread($fp,16); fclose($fp); $clear_r=array("Please Insert Your Password!","Password Correct!","Welcome To The L2J Telnet Session.","[L2J]","Bye Bye!"); $output = str_replace($clear_r,"", $output); if(strstr($output,"Incorrect Password!")) return "<font color=#6F5A0B>Warning:</font> Incorrect Telnet Password.<br>"; return $output; } } function Execute($command) { return $this->command($command); } function give($char, $item, $count) { return $this->command("give " . $char . " " . $item . " " . $count . "\r"); } function kick($char_name) { $this->command("kick ".$char_name."\r"); } function stats() { return $this->command("stats\r"); }}?>[/php]
using
[php]$telnet = new telnet; $telnet->ip = '127.0.0.1'; $telnet->port = 12345; $telnet->password = 'password'; $telnet->timeout = 2; echo $telnet->Execute('help');[/php]
- disorder35
- Posts: 700
- Joined: Sat Aug 01, 2009 3:29 pm
Re: Telnet and PHP
I need to turn this script into telnet to give the player a coin after he vote for the server. Just the part that add the item to the players account.
Can anyone help me with that?
Thanks
Can anyone help me with that?
Thanks
Code: Select all
<?php//CONFIGS$server = 'XXXXXXXX'; //Server$database = 'XXXXXXXX'; //Database name$user = 'XXXXXXXX'; //MySQL User$pass = "XXXXXXXX"; //MySQL User Password$reward = 14720; //Item ID$reward_name = 'Event - Apiga'; //Item's Name$quantity = 1; //Quantity of the item //END OF CONFIGS?> <head><title>Get your reward!</title><style type="text/css">.input_field, .button1 { background: #0c0c0c; border: 1px solid #1c1c1c; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 0.90em; padding: 3px; color: #FFFFFF;}</style></head><body bgcolor=#0b0b0b><center><form action=vote.php method=post><font color=orange><b>Character's Name:</b></font><br><input type=text name=char class=input_field><br><input class=button1 type=submit name=reward value='Send my Reward'></form><?phpif($quantity>1){$be='were';}else{$be='was';}if(isset($_POST['reward'])){mysql_connect("$server", "$user", "$pass");mysql_select_db("$database");$char = $_POST['char'];if($char == ""){echo "<font color=red>Invalid Character's Name!</font>";}else {$microtime = explode(" ", microtime());$microtime = $microtime[1];$voteTime = 12*60*60;$voteBounds = $microtime - $voteTime;$votedToday = mysql_query("SELECT site_voted FROM voting_system WHERE ip_address = '$char' && time_voted > $voteBounds");if(mysql_num_rows($votedToday) == 0) {$result = mysql_query("SELECT * FROM voting_system WHERE ip_address LIKE '$char'") or die(mysql_error());$row_sql = mysql_fetch_assoc($result);$total = mysql_num_rows($result); if($total>0){mysql_query("UPDATE voting_system SET time_voted='$microtime' WHERE ip_address='$char'");}else {mysql_query("INSERT INTO voting_system(ip_address, time_voted, site_voted) VALUES('$char', '$microtime', '1')"); } $query="SELECT * FROM characters WHERE char_name='$char' LIMIT 1"; $result = mysql_query($query); if($row = mysql_fetch_array($result)) { $id = $row['charId']; $acc = $row['account_name']; //$rec = $row['rec_have']; mysql_query("INSERT INTO items VALUES('$id', '', '$reward', '$quantity', '0', 'INVENTORY', '0', 'null', '0', '0', '-1', '-1')"); echo "<font color=green>Thanks for Voting!<br>$quantity $reward_name $be added to char $char </font><br><form method=post><input type=button class=button1 value='Close Window'onclick=\"window.close()\"></form>"; } else { echo "<font color=red>Character Doesn't Exist!<br></font>"; } }else { echo "<font color=red>You can only vote every 12 hours!</font><br><form method=post><input type=button class=button1 value='Close Window'onclick=\"window.close()\"></form>"; }}}?>
So What?????
- disorder35
- Posts: 700
- Joined: Sat Aug 01, 2009 3:29 pm
Re: Telnet and PHP
Can anyone help me please, I need a script that will give the item to the players after they vote on all 3 sites.
I need the Item to be added in inventory in game.
Please help me.
Thank you.
I need the Item to be added in inventory in game.
Please help me.
Thank you.
So What?????
-
- Posts: 73
- Joined: Wed Dec 14, 2005 5:24 pm
Re: Telnet and PHP
Could you share this complete voting system?disorder35 wrote:Can anyone help me please, I need a script that will give the item to the players after they vote on all 3 sites.
I need the Item to be added in inventory in game.
Please help me.
Thank you.
-
- Posts: 39
- Joined: Thu Jun 10, 2010 9:06 am
Re: Telnet and PHP
Oh how much i love unsafe PHP scripts
-
- Posts: 2
- Joined: Sun May 22, 2011 1:47 pm
- Contact:
Re: Telnet and PHP
huh? your talking about mine?Naminator_X_ wrote:Oh how much i love unsafe PHP scripts
-
- Posts: 39
- Joined: Thu Jun 10, 2010 9:06 am
Re: Telnet and PHP
I was talking about the telnet script BUT i haven't yet tested yours
-
- Posts: 2
- Joined: Sun May 22, 2011 1:47 pm
- Contact:
Re: Telnet and PHP
it's working fine if u find something let me knowNaminator_X_ wrote:I was talking about the telnet script BUT i haven't yet tested yours
-
- Posts: 87
- Joined: Fri Jul 18, 2008 2:27 pm
- Location: Slovakia
Re: Telnet and PHP
I have rewrited this telnet class, that classes made for every command new connection to the server, now you can make x commands on one connection, when class is destructed, socket is clossed, or you can call disconnect() function.
My telnet class: http://pastebin.com/LpL9kgzN
My telnet class: http://pastebin.com/LpL9kgzN
Code: Select all
<?php include "l2jTelnet.php"; //host, port, pass, timeout $telnet = new telnet("127.0.0.1", "12345", "123456", 2); $telnet->init(); echo $telnet->write("help"); echo $telnet->write("help"); echo $telnet->write("status");
You do not have the required permissions to view the files attached to this post.
Sorry for my bad english.