PHP - Get Packets From A Specific Port On The Php Server
Hello
Is it possible to uses PHP, to grap incoming packets from a port, on the PHP server ?? Similar TutorialsStupid question but why would it need the port contained inside the URL for redirection later on? Code: [Select] /* The servername and serverport tells PayPal where the buyer should be directed back to after authorizing payment. In this case, its the local webserver that is running this script Using the servername and serverport, the return URL is the first portion of the URL that buyers will return to after authorizing payment */ $serverName = $_SERVER['SERVER_NAME']; $serverPort = $_SERVER['SERVER_PORT']; $url=dirname('http://'.$serverName.':'.$serverPort.$_SERVER['REQUEST_URI']); hello and good day dear php-freaks which is the passwd for the mysql db run opensuse - therein i have installed a myql serfver and an apache now i want to port over a cms-system from a server to the localhost. question: the passwd of the configuriatin of the cms has got the following db connecgtion host : localhost db-name db-passwd question: does the db passwd need to match the passwd of the local mysql server!? is this true love to hear from you Hi All - I'm trying to see if the below is possible using PHP. is it possible for php to allow a user to check if a port is open/listening on a remote server/PC, from their local machine. I've seen scripts on the web that talk about opening cmd.exe - this won't work as not all of my users will be on windows. Also saw fsock.. but the remote server is not serving http page(s). Also saw telnet, but again, some of my users may not have that windows feature enabled. Desired workflow: 1. user enters the server hostname/IP and a port 2. my php webapp will emulate checking if that hostname and port is open from the local user's computer.
thanks! Hi, I upgraded my XAMPP to the version 1.8.3 (win32) recently. Apache failed to start and I got the following error Hi guys
I'll try keep this simple
I have been given access to a betting xml feed which requires my IP to be whitelisted.
I have whitelisted my home IP and it works fine.
I have whitelisted an IP on server 1 (linux, cpanel), this works fine
I have whitelisted an IP on server 2 (linux, cpanel), this doesn't work and I get:
"simplexml_load_file failed to open stream: http request failed!"
The IP is definitely whitelisted but I think it is something to do with the server. What could be blocking this?
allow_url_fopen and allow_url_include are both on by the way
Many thanks
Sam
Hi there, I'm writing an application that pulls from two separate web based APIs, collates the data into a single array of data. Once done, it then enters a loop that cycles through the array and executes a cURL call for each cycle. This worked perfectly for a controlled set of 10 artificial records and so I've started testing with live data. On running the code, I eventually the following : Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. I'm not sure how to debug this and so I'm hoping I can find some help here. I'm running WAMP, and the php.ini contains the following: max_execution_time = 0 ; Maximum execution time of each script, in seconds max_input_time = 0 ; Maximum amount of time each script may spend parsing request data Through testing, I have discovered the following : The script can do exactly 35 iterations through the loop in under 2 minutes. Any number greater than this causes the error. If I skip the first 20 curl submits, I can then do 21 to 55 iterations before failure, so I do not believe it is the 36th value. If I put a sleep(5) command into the loop, I can still do 35 and no more iterations than that. If I put a sleep(10) command into the loop, it fails on 35 and needs less. Code: [Select] $action = "post"; $url = "http://url.url.url/api/v1.0/udo_Position/create"; // I've replaced the actual URL out of necessity // set user agent { print("Setting CURL options, using URL ".$url."<br>"); $cd = curl_init(); curl_setopt($cd, CURLOPT_HEADER, 1); curl_setopt($cd, CURLOPT_URL, $url); curl_setopt($cd, CURLOPT_USERPWD, 'username:password'); curl_setopt($cd, CURLOPT_RETURNTRANSFER, 1); // Don't send return value to screen curl_setopt($cd, CURLOPT_USERAGENT, "Firefox/2.0.0.1"); // spoofing FireFox 2.0 curl_setopt($cd, CURLOPT_VERBOSE, true); // } if ($action == 'get') { ; } elseif ($action == 'post') { print("POST set;<br>"); print("<pre style='font-family:verdana;font-size:13'>"); print_r($pointval); print("</pre>"); $pointval["save"] = "Save"; // The AddNew step form requires this. curl_setopt($cd, CURLOPT_POSTFIELDS, $pointval); } else { print("Invalid usage. Please see example<br>"); return; } $reply = curl_exec($cd); $http_status = curl_getinfo($cd, CURLINFO_HTTP_CODE); print("<pre style='font-family:verdana;font-size:13'>"); print_r($http_status); print("</pre>"); print("Here is the reply from the AddNew function: <br>"); print("<pre style='font-family:verdana;font-size:13'>"); print_r($reply); print("</pre>"); if (curl_error($cd)) { print("Error: ".(curl_error($cd))."<br>"); } curl_close($cd); print("Insert Successful.<br>"); I am uncertain whether it is a PHP, Apache or cURL issue at this point. I have another script that pushes a great deal more cURL calls to the same system but pulls from only one external resource, instead of two. Any help or suggestions would be appreciated. I use the Wholesale Suite Premium Prices plugin with WooCommerce. I have 6 specific wholesale roles out of 15 that I wish to hide two specific shipping methods from being selected for the 6 exceptions. I'm just trying this on my staging server at this time using a code snippet example that I found and modified for my specific conditions. Would the following work for this purpose? /* Hide specific shipping methods for specific wholesale roles */ add_filter( 'woocommerce_package_rates', function( $shipping_rates ) { // User role and shipping method ID to hide for the user role $role_shipping_method_arr = array( 'ws_silvia_silver' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_silver_pst_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_silver_tax_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_silver' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_silver_pst_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_silver_tax_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_gold' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_gold_pst_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_gold_tax_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_gold' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_gold_pst_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_gold_tax_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), ); // Getting the current user role $curr_user = wp_get_current_user(); $curr_user_data = get_userdata($current_user->ID); // Wholesale Suite Roles if (isset($current_user) && class_exists('WWP_Wholesale_Roles')) { $wwp_wholesale_roles = WWP_Wholesale_Roles::getInstance(); $wwp_wholesale_role = $wwp_wholesale_roles->getUserWholesaleRole(); // Loop through the user role and shipping method pair foreach( $role_shipping_method_arr as $role => $shipping_methods_to_hide ) { // Check if defined role exist in current user role or not if( in_array( $role, $current_user->roles) ) { // Loop through all the shipping rates foreach( $shipping_rates as $shipping_method_key => $shipping_method ) { $shipping_id = $shipping_method->get_id(); // Unset the shipping method if found if( in_array( $shipping_id, $shipping_methods_to_hide) ) { unset($shipping_rates[$shipping_method_key]); } } } } } return $shipping_rates; }); Any insights as to how to accomplish this would be greatly appreciated. Lyse Hello, I have a webpage that runs some php code to control electrical devices. One part of it controls outside lights. Another part controls an electric door striker. I keep expanding the functionality of it and need to change one pin of the port without affecting the others. So far I use a different port for each function but I am out of ports so I need to use the different pins of the parallel port. I am using a linux ubuntu server. From my php webpage I issue this command: <?php exec("/home/setSerialSignal /dev/ttyS0 0 0"); ?> which controls the lights using the serial port. I can control 2 pins but I can't check the status of them so if I make a change to one pin it cancels the other. For another one I use the parallel port with this command: <?php exec("/home/parashell 0x378 1"); ?> which turns on pin #2 of the parallel port. Parashell has an executable called "pin". If you type the command "pin 0x378" it will return a value for the status of the parallel port. "1" for example which tells me that pin #2 is on. Is there a way to pass this value to a php variable? I am looking to be able to read the status of the port and make changes to just the pin I want. Lets say pin #2 is on and I want to turn pin #3 on. I would have to issue <?php exec("/home/parashell 0x378 2"); ?> to turn pin #3 on, but that would turn off pin #2. If I could pass the "1" from the "pin" command I could add it to the "2" and give it the command with a variable as "3". Thanks in advance for any help you can give. I hope I explained it ok and didn't confuse everyone. Hi!
I'm trying to make an button that when it's pressed sends an http post to my home server. But my home server is runing on port 84 and i think that i'm not being able to send the post correctly because of this port. any help?
my code now is this:
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://homeserver.net:84/?device=35"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch);The way I have the URL is correct? thanks! Hi all,
I want to send a string of data to serial port. Below is the code. Sdata contains the string. for example "<LT-ON-50>".
<?php exec("mode com3: BAUD=600 PARITY=n DATA=8 STOP=1 to=off dtr=off rts=off"); if (isset($_GET['action'])) { $SData = $_GET['action']; $fp = fopen("com3","w"); fwrite($fp,$SData); fclose($fp); } ?>unfortunately, it will send only one character i.e '<'. the remaining characters will be lost. What could be wrong in the code. Any help can be greatly appreciated. Thanks, Okay, I'm using fsockopen to see if a port is being used, But all it does it crashes the page if it isn't. If it is one it works but if it is off the pages just doesn't load at all. Code: <?php $fp=fsockopen("localhost", 43594, $errno, $errstr, 30); if($fp){ echo('The server is <font color="#0066FF"><b>Online!</b></font>'); } else { echo('The server is <font color="#FF0000"><b>Offline!</b></font>'); } ?> Can one of you amazing helpful souls help me out? Thanks in advance! Hi, I'm trying to connect to a database on a port other than 3306 to create a database. Here's my connect code: $connection = new MySQLi($host,$user,$pass)() But according to the PHP website it says I can lay the code out like so: new MySQLi($host,$user,$pass,$database,$port)() But how do I specify the port without the database? I've tried just "" as the database but the connection still fails. Any help would be much appreciated. hello and good day dear joomla-experts well i want to add a business-directory to joomla and want to run this below mentioned code on overpass-turbo.eu see this http://overpass-turbo.eu/s/5pv and include the results into businessdirectory see the option for the code http://overpass-turbo.eu/ [adiff:"2014-07-01T00:00:00Z"]; area[name="Argentina"][boundary=administrative]->.a; ( node (area.a) [amenity=school][website]; way (area.a) [amenity=school][website]; ); out meta geom; and then see the results <?xml version="1.0" encoding="UTF-8"?> <osm version="0.6" generator="Overpass API"> <note>The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.</note> <meta osm_base="2014-10-12T14:10:02Z" areas="2014-10-12T03:37:02Z"/> <action type="modify"> <old> <node id="961544799" lat="-34.6064077" lon="-58.3749056" version="4" timestamp="2013-10-04T06:43:38Z" changeset="18172855" uid="79602" user="Zalitoar"> <tag k="addr:housenumber" v="165"/> <tag k="addr:street" v="Florida"/> <tag k="amenity" v="school"/> <tag k="name" v="IBL - International Bureau of Language"/> <tag k="website" v="http://www.ibl.com.ar"/> </node> </old> <new> <node id="961544799" lat="-34.6065440" lon="-58.3750010" version="5" timestamp="2014-07-11T17:43:16Z" changeset="24086663" uid="79602" user="Zalitoar"> <tag k="addr:housenumber" v="165"/> <tag k="addr:street" v="Florida"/> <tag k="amenity" v="school"/> <tag k="name" v="IBL - International Bureau of Language"/> <tag k="website" v="http://www.ibl.com.ar"/> </node> </new> </action> <action type="modify"> <old> <node id="2512237096" lat="-34.5636728" lon="-58.4422897" version="2" timestamp="2014-01-30T22:19:42Z" changeset="20291654" uid="255141" user="Souchong"> <tag k="addr:housenumber" v="1395"/> <tag k="addr:street" v="Avenida Luis María Campos"/> <tag k="amenity" v="school"/> <tag k="name" v="Método DeRose Belgrano"/> <tag k="phone" v="+54 11 47854882"/> <tag k="website" v="http://derosebelgrano.com.ar/"/> </node> </old> <new> <node id="2512237096" lat="-34.5636835" lon="-58.4423120" version="3" timestamp="2014-08-23T04:01:26Z" changeset="24947372" uid="331218" user="AgusQui"> <tag k="addr:housenumber" v="1395"/> <tag k="addr:street" v="Avenida Luis María Campos"/> <tag k="amenity" v="school"/> <tag k="name" v="Método DeRose Belgrano"/> <tag k="phone" v="+54 11 47854882"/> <tag k="website" v="http://derosebelgrano.com.ar/"/> </node> </new> </action> <action type="create"> <node id="2934940034" lat="-34.6181407" lon="-58.5235741" version="2" timestamp="2014-08-06T03:29:38Z" changeset="24567582" uid="648570" user="Abejo"> <tag k="addr:housenumber" v="5490"/> <tag k="addr:street" v="Simbrón"/> <tag k="amenity" v="school"/> <tag k="name" v="I.M.E.P."/> <tag k="phone" v="+54 011 45676610"/> <tag k="website" v="http://formarfuturo.org.ar"/> </node> </action> <action ty i love to do this - many many thanks for all help Hi. I am writing a web app to control Zoom Player on my HTPC. I found that ZP supports listening on a TCP port to accept control commands. The docs say to quit ZP, send 5100,fnExit + ASCII 13/10 to port 4769. My original client was C# and I implemented it there, works great. I then realized WTF am I doing using an external .EXE to just send data to a TCP port? Switched to using PHP's fsockopen. Alas, that causes an error to pop up on ZP (List index out of bounds or some such). Perplexed, I wrote a GUI for the HTPC to just display an ASCII val breakdown of what it receives to compa So it looks like they both send the data the same. Any idea why the discrepancy? Here is the code: C# that works: Code: [Select] string cmdstr = ""; for (int x=2; x<=args.Length-1; x++) cmdstr += args[x] + " "; if (SendCommand(args[0], System.Convert.ToInt16(args[1]), cmdstr.Trim() + Environment.NewLine)) Console.WriteLine("Command string sent."); Environment.Exit(0); static bool SendCommand(string dest, int port, string cmd) { try { IPAddress[] ips = Dns.GetHostAddresses(dest); TcpClient client = new TcpClient(); IPEndPoint serverEndPoint = new IPEndPoint(ips[0], port); client.Connect(serverEndPoint); NetworkStream clientStream = client.GetStream(); ASCIIEncoding encoder = new ASCIIEncoding(); byte[] buffer = encoder.GetBytes(cmd); clientStream.Write(buffer, 0, buffer.Length); clientStream.Flush(); clientStream.Close(); clientStream.Dispose(); client.Close(); return true; } catch (Exception ex) { Console.WriteLine("Failed: " + ex.Message); return false; } } The PHP that is being difficult: Code: [Select] send_data("lioth", "4769", "5100,fnExit"); function send_data($host,$port,$data='') { $fp = fsockopen($host,$port); if($fp) { fputs($fp, "$data\r\n"); fclose($fp); } return; } I have a small project. I have a control board that is connected to the parallel port. It controls 8 strips of LED on the LPT1 port. I can turn these on and off via the command prompt, using LPTOUT.exe ie lptout 1 turns on the 1st LED lptout 2 will turn off 1st LED and turn on 2nd, lptout 4 turns on 3rd and 2nd off, etc 1, 2, 4, 8, 16, 32, 64, 128. and combinations ie lptout 3 turns on LEDS 1 and 2, and so on. However lptout seems very unresponsive sometimes I have to do lptout 1 twice before LED 1 turns on. Is there another command I can use to write to LPT1 port. I need some PHP code to control the outputs. I want to sequence the outputs ie 1on (1second) 2on (1 second) 3 on (1 second) 4 on etc. to 8, then all off then repeat. Can anyone help me. THANK YOU. how to arrange a port forward via ssh-tunnel i need to do that on a domain with this syntax https://www2.mydomain.org:2211/ i am on opensuse guess that i firstly have to activate the ssh Hello guys, I am new to PHP programming. I am trying to figure out how to use PHP language to transmit/write characters to a USB port device at 9600 baud rate 8-N-1. Basically I just need the PHP coding to allow me to send stuff to the USB device but I have no idea how I can interface this. I did some researching but most were for RS-232 COM Port. I can't find the proper one for USB. If someone can help me out, that would be awesome. Thank you! I have a PHP web system that store in a windows server. In the system, there is a function for user to upload files to another server (Shared server in Unix). When i try to upload a file, it gives warning: Warning: move_uploaded_file(\\unixserver/sharedfolder/upload/test.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\wamp\www\upload\index.php on line 40 For your information, my username has been assigned in xxx's group that has access to read and write on that folder. Besides, i'm able to open,create and delete files on that folder's server manually (samba). The safe mode setting is off. Does anybody has any idea why this thing happen? I'm trying to make a simple website where people register to my website. When the user doesn't fill anything inside the boxes they get a message "Please fill all required fields" on the register.php page On my local host require_once works good. It shows up.
But when i upload the files to my sever the require_once does not show up on the register.php It just refreshes and i dont get the message "Please fill all required fields"
This is the code that works in local host but not in a live server <?php require_once 'messages.php'; ?>
Here is my full code
Register page: <html> <?php require_once 'messages.php'; ?> <br><br> <form action="register-clicked.php" method="POST"> Username:<br> <input type="text" name="usernamebox" placeholder="Enter Username Here"> <br><br> Email:<br> <input type="text" name="emailbox" placeholder="Enter email here"> <br><br> Password:<br> <input type="password" name="passwordbox" placeholder="Enter password here"> <br><br> Confirm Password:<br> <input type="password" name="passwordconfirmbox" placeholder="Re-enter password here"> <br><br> <input type="submit" name="submitbox" value="Press to submit"> <br><br> </form> </html>
Register clicked <?php session_start(); $data = $_POST; if( empty($data['usernamebox']) || empty($data['emailbox']) || empty($data['passwordbox']) || empty($data['passwordconfirmbox'])) { $_SESSION['messages'][] = 'Please fill all required fields'; header('Location: register.php'); exit; } if ($data['passwordbox'] !== $data['passwordconfirmbox']) { $_SESSION['messages'][] = 'Passwords do not match'; header('Location: register.php'); exit; } $dsn = 'mysql:dbname=mydatabase;host=localhost'; $dbUser='myuser'; $dbPassword= 'password'; try{ $connection = new PDO($dsn, $dbUser, $dbPassword); } catch (PDOException $exception){ $_SESSION['messages'][] = 'Connection failed: ' . $exception->getMessage(); header('Location: register.php'); exit; }
messages.php <?php session_start(); if (empty($_SESSION['messages'])){ return; } $messages = $_SESSION['messages']; unset($_SESSION['messages']); ?> <ul> <?php foreach ($messages as $message): ?> <li><?php echo $message; ?></li> <?php endforeach; ?> </ul> Edited Wednesday at 12:49 AM by bee65 Hi, I am not a PHP programmer. I took on a new client with a simple PHP site, without any databases. The site is up and running on the web. I would like to get it running on my local machine for further development. I have latest version of WAMP installed, running Apache version 2.2.11 and PHP version 5.3.0 I created a directory in the WAMP "www" project directory and it shows up there like it's supposed to when I browse to "localhost" Problem: The home page of website displays text but no, images, styles, footer, header, nav links, etc. Here is the code for the home page: <? define("NAV","home"); require_once('local/local.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>TITLE</title> <meta name="keywords" content=""> <meta name="Description" content=""> <? include("common/dochead.php"); ?> </head> <body onLoad="<? include('common/preloads.php'); ?>"> <!-- ============================ main ============================= --> <div id="main-frame"><div id="main" class="noCollapse"> <? include("common/sign.php"); ?> <div id="right-frame"> <? include("common/navigation.php"); ?> <div id="content-frame"> <div id="content"> <h1>Welcome</h1> <p>This is the content area. This is the content area. This is the content area. </p> </div><!-- end content --> </div><!-- end content-frame --> </div><!-- end right-frame --> <div class="clearFloats"></div> </div><!-- end main --></div><!-- end main-frame --> <? include("common/footer.php"); ?> </body> </html> Any help would be greatly appreciated. I have spent many hours on this. Regards |