Search the Community
Showing results for tags 'client'.
-
Hi, there's a site I saw which allows it's users to upload a link that will be implemented to the site. Now I was wondering but how would you do this in PHP? To elaborate I would like it so that the user can upload a link and it'll implement it on the site through php? So for example I want to add a link to the site WITHOUT having any kind of login required, so something like "www.google.com" and after it'll appear on the site under a list. How would I make it so it does this function? Thanks.
-
Note: This is mainly a PHP issue, but the java part is a Bukkit plugin. My TCP Server (made in Java) is one that can send and recieve messages/commands from a client like PuTTy. Everything works perfectly in PuTTy, however when I use a small PHP client I made to test commands, it doesn't recieve the complete output. My PHP is as follows <?php echo '<html><body>'; include('config.php'); $service_port = $_GET['sPort']; $address = $_GET['sIP']; $command = null; $args = null; $api = 0; if (isset($_GET['api'])) { $api = 1; } if (!isset($_GET['sMsg'])) { die('No command given'); } else { $command = trim(strtolower($_GET['sMsg'])); if ($command == null || $command == "") { die('No command given'); } if ((strpos($command, ";")) == false) { /* Args check */ //do nothing, no args } else { $args = explode(";", $command); } } $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket === false) { die('Failed to create socket'); } $result = socket_connect($socket, $address, $service_port); if ($result === false) { die('Failed to connect to server'); } $messag = $command; $message = $messag."\n"; $out = ''; socket_write($socket, $message, strlen($message)); $resp = ""; while ($out = socket_read($socket, 2048)) { $resp .= $out; } $response = trim($resp); $rep = array("/", "\\", "-", "_", "(", ")", "'", "|", "Welcome! Please input the password.", ","); $stripped = str_replace($rep, "", $response); echo $stripped; socket_close($socket); echo '</body></html>'; ?> and when I send the command /adminsconnected the following Java code is fired by the server if (sent.equalsIgnoreCase("/adminsconnected")) { sendText("0", true); plugin.log.info("adminsConnected"); } public void sendText(String text, Boolean suppress) { try { if (suppress) { this.toClient.writeBytes(text + "\r\n"); } else { this.toClient.writeBytes(getTime() + " - "+text + "\r\n"); } if (!suppress) MainClass.log.info("[bTS] Sent: \"" + text + "\""); } catch (Exception e) { e.printStackTrace(); plugin.log.severe(e.toString() + " - sendText (suppress)"); } } My output from PHP is blank, however I recieve the "adminsConnected" and PuTTy gives "0" (the intended output) I get an error in my console: 18:25:53 [sEVERE] java.net.SocketException: Software caused connection abort: socket write error 18:25:53 [sEVERE] at java.net.SocketOutputStream.socketWrite0(Native Method) 18:25:53 [sEVERE] at java.net.SocketOutputStream.socketWrite(Unknown Source) 18:25:53 [sEVERE] at java.net.SocketOutputStream.write(Unknown Source) 18:25:53 [sEVERE] at java.io.DataOutputStream.writeBytes(Unknown Source) 18:25:53 [sEVERE] at com.atrociouss.BTS.Users.sendText(Users.java:339) 18:25:53 [sEVERE] at com.atrociouss.BTS.Users.ssendText(Users.java:323) 18:25:53 [sEVERE] at com.atrociouss.BTS.Users.run(Users.java:278) 18:25:53 [sEVERE] java.net.SocketException: Software caused connection abort: socket write error - sendText (suppress) I was wondering if this was a server issue, or a client issue and if its a mistake that I simply haven't been able to see because i've been staring at it for so long, or if theres something going terribly wrong with my code and I should start from scratch. Any help appreciated!