[PHP] Re: I am new - Having problems displaying something
passthru()'s prototype is actually: void passthru(string cmd[, int return) http://php.net/passthru Meaning using passthru() with the concatenation operator . will produce unexpected results, as the product of the passthru call is actually printed directly out to the page, as is. Nothing is returned. If you wish to snag the output of an external command into a variable, or modify it further using another function, consider the backtick operator (`): $output = `osascript /Library/WebServer...`; printf(Current song: %s\n, $output); If you have trouble finding the backtick ` -- remember, it's not a single-quote mark, it's a backtick, usually on the ~ key -- system() will accomplish the same thing in a functional fashion. Or, you can keep passthru(), and just use it differently: Current song: ?php passthru(osascript /Library/WebServer...); ? If this doesn't work, check to make sure osascript is printing to stdout. I'm not sure how osascript works, as I'm not a Mac user, but I'm assuming this is OS X (from the pathnames) -- therefore, I *imagine* there's a stdout on OS X. passthru() should grab whatever goes to stdout. If it still doesn't work for you, check the page source to see if passthru() drops anything but it's formatted out (hey, I have to say it). Oh, and make sure Apache can run osascript. If Apache can't run osascript, that's another problem. (I would imagine it'd have to be able to access your Applescript file as well.) Good luck! HTH Jed Brian Heibert wrote: Hi, I am new to this list. I am trying to do a php script that will say what song is currently playing in iTunes/NiceCast Internet Radio broadcaster Onto my website Every attempt I have made so far has failed I got a file called playing.php With this text inside it: ?php echo Current Song: .passthru(osascript /Library/WebServer/Documents/christiantoplist/whattrack.scpt); ? And a file called whattrack.scpt (AppleScript file) with this in it tell application iTunes set trk to current track set tle to name of trk set art to artist of trk set albm to album of trk return tle - art , albm end tell But it is not displaying what song is playing on my website All it says is Current Song: and then it doesn't say the song Brian Heibert PS: I have a iMac G4 800mhz OS 10.3.6 running Apple's webserver system preference which is there version of Apache I think -- _ (_)___Jed Smith, Code Ninja | / __| RFBs: [email for info] | \__ \ +1 (541) 606-4145 _/ |___/ [EMAIL PROTECTED] (Signed mail preferred: PGP 0x703F9124) |__/http://personal.jed.bz/keys/jedsmith.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: HTML form online
Jerry Swanson wrote: I want to write php script that fill out HTML form online. Any ideas how to do it? If you want to fill a form *remotely*, that's a little tougher. You'll need cooperation from the server-side code on the site you want to fill the form on. As Matthew noted, the VALUE attribute of an INPUT tag is what you are seeking to modify. Perhaps POST variables that PHP parses and sets the VALUE attribute to? Otherwise, if you *won't* have cooperation from the other server's code, it becomes a client-side, userspace app, since it'd be a matter of pretending the user is typing. (Think Mozilla, Gator, et. al.) PHP can do that, but I don't believe that's a solution for you. HTH -- _ (_)___Jed Smith, Code Ninja | / __| RFBs: [email for info] | \__ \ +1 (541) 606-4145 _/ |___/ [EMAIL PROTECTED] (Signed mail preferred: PGP 0x703F9124) |__/http://personal.jed.bz/keys/jedsmith.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML form online
Warren Vail wrote: If so you probably want to start here; http://www.php.net/manual/en/ref.curl.php cURL can do that? -- _ (_)___Jed Smith, Code Ninja | / __| RFBs: [email for info] | \__ \ +1 (541) 606-4145 _/ |___/ [EMAIL PROTECTED] (Signed mail preferred: PGP 0x703F9124) |__/http://personal.jed.bz/keys/jedsmith.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: ending a session
Hans J.J. Prins wrote: Hello, I started a session at www.mydomain.com:/myscript.php I want to destroy the session at www.mydomain.com/myscript.php I seem to not be able to destroy it though. Does the different port have anything to do with it? Thx, H J.J. P Although I've never encountered this situation before, I'll try. More information about the platform in question will be necessary, but I'm going to go ahead and venture a yes here. It is safe to assume that different copies of PHP end up being run when you request something on and on 80. Different copies of PHP don't (?) share session states. A custom session handler might be necessary for you. (Let me clarify that: PHP attached to *different servers* shouldn't share session states.) Questions: 1. What are you running on ? 2. What are you running on 80? 3. Is it the same copy of PHP? Same php.ini, same PHP SAPI? (If Apache for 1 2) 4. Same Apache? 5. What's your Listen directive look like, if YES for number 4? 6. Vhosts? This also may be a security feature, but I've personally never tackled the problem. Tough to say. I'll leave my advice at that for now pending further information. -- _ (_)___Jed Smith, Code Ninja | / __| RFBs: [email for info] | \__ \ +1 (541) 606-4145 _/ |___/ [EMAIL PROTECTED] (Signed mail preferred: PGP 0x703F9124) |__/http://personal.jed.bz/keys/jedsmith.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: ending a session
Hans J.J. Prins wrote: 3. Is it the same copy of PHP? Same php.ini, same PHP SAPI? I really don't know I would have to find out later. PHP attached to different Apaches can't share sessions, AFAIK. You'll need to make sure it's the same copy of Apache, listening on both ports, and that there's not a different configuration for each. Otherwise your application might need a redesign to accommodate the difference in ports. Your own, custom session handlers aren't that difficult to implement, if I recall (been a while :^)). That's the best advice I can give without further information. 4. Same Apache? How do I find out? Ask your sysadmin. 5. What's your Listen directive look like, if YES for number 4? Sorry, don't know what you mean by that. It's in httpd.conf or friends, whatever your particular instance of Apache uses. I suggest having a glance over the Apache manual and having a chat with your sysadmin. Good luck. -- _ (_)___Jed Smith, Code Ninja | / __| RFBs: [email for info] | \__ \ +1 (541) 606-4145 _/ |___/ [EMAIL PROTECTED] (Signed mail preferred: PGP 0x703F9124) |__/http://personal.jed.bz/keys/jedsmith.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Limit to the number of sockets socket_select can supervise?
Let me attack this. I'm bored. I'm on Windows XP SP 2, and I'll try this from the command line. I coded a simple server in PHP that just accepts the connection and listens. It doesn't attempt to send any data, its only select loop is to wait for a new connection attempt. I also wrote a load program. When attempted with 49 sockets (50 on the server), it worked fine, select and all. Server: http://labs.jed.bz/HCJ/server.php.txt Client: http://labs.jed.bz/HCJ/load.php.txt However, when I tried 500, odd things happened. The server (!) died due to Windows XP's DEP, which I removed for cli.exe and retried. It then died again (!) because of an existing connection [being] forcibly closed. I then lowered the limit to 70 and tried again. The server accepted 69: accepted #68 of 70 accepted #69 of 70 ... Before I could telnet in to make 70, the client died: connecting #69 of 69 ... ok waiting for spew Warning: socket_select(): unable to select [0]: An operation was attempted on something that is not a socket. in F:\Projects\HCJ\load.php on line 38 spew! done! Curious. The problem replicates itself here. I'm not sure. For the first time with PHP I honestly have no clue where to start attacking this problem. It could be a Windows limitation, but for that to be the case the scripts will have to be run on a UNIX system as well. I simply don't know. Very strange indeed. It was worth the hour I put into it, because I'm interested -- I've been playing with PHP daemons on Win32 for a while now, and this select limitation concerns me. I'll submit this as a bug report. Feel free to comment, bug #30852 Jed Hans-Christian Jehg wrote: Hi Im building a TCP server in PHP 5.0.2 on Windows. It will have to serve a lot of clients (500+) with low traffic. During this I have noticed that socket_select seems unable to supervise more than 64 connections at a time (Not good when I need 500+). It stops with a message that Socket select failed, error code is: 10038, error message is: An operation was at tempted on something that is not a socket. These are the outputs of socket_last_error() and socket_strerror(socket_last_error()). And now forthe questions: Does any of you have the same experience? Is it something to do with Windows? Does this limitation exist on Linux? Is it just a bug? Any good suggestions? Best regards and thanx in advance HC -- _ (_)___Jed Smith, Code Ninja | / __| RFBs: [email for info] | \__ \ +1 (541) 606-4145 _/ |___/ [EMAIL PROTECTED] (Signed mail preferred: PGP 0x703F9124) |__/http://personal.jed.bz/keys/jedsmith.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: default extension for includes?
Justin French wrote: I'd like to be able to call include(thing); and have PHP automatically look for thing.html -- I know include_path can look in multiple places, but I have no idea if I can look for multiple file extensions, close matches, etc. Doubt it, but I'm asking :) Justin No. -- _ (_)___Jed Smith, Code Ninja | / __| RFBs: [email for info] | \__ \ +1 (541) 606-4145 _/ |___/ [EMAIL PROTECTED] (Signed mail preferred: PGP 0x703F9124) |__/http://personal.jed.bz/keys/jedsmith.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP 5 MySql 4.1 issue - can't connect to mysql.sock
Try mysqli_connect(127.0.0.1, user, pass); Then MySQLI will try to use TCP/IP as opposed to a local socket. Jed Barley wrote: I am familiar with MySql, Linux and database programming in general, but I have not used PHP very much. On my server, I had an application running just fine under PHP 4.1 and MySql 3.23. For various reasons, I needed to move to MySql 4.1. When I did so, the PHP application was broken. I poked around and found that I needed to upgrade to PHP 5 to get mysqli support. I did so with no problems. I built PHP from source on a RedHat 7.3 box. Here's the problem: I can only connect to MySql via a PHP script if I run that script as root. Here is the example script I have been using: ?php $DB = mysqli_connect(localhost,user,pass); if (! $DB) { echo No.; } else { echo Yes.; } ? If I run the script from a shell prompt as root, it outputs Yes. If I run as any other user, it outputs No. It also gives this error: Warning: mysqli_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) This means I can't run PHP scripts via apache. I can log in to mysql via the command line with user/pass without any problems. Apache is connecting to PHP no problem, as I have a Hello world type PHP script running and can access it via the web. But no PHP script can connect to MySql unless it is run as root... Can anyone point me in the right direction? I have a feeling this is something very simple. Thanks! Gregg -- _ (_)___Jed Smith, Code Monkey | / __| [EMAIL PROTECTED] | [EMAIL PROTECTED] | \__ \ +1 541 606-4145 _/ |___/ Signed mail preferred (PGP 0x703F9124) |__/http://personal.jed.bz/keys/jedsmith.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Storing binary data within a php script.
This is done in a few examples using base64_encode() and base64_decode(). A particular OpenGL example I can recall encoded a small (~20k) DLL directly into the PHP source that relied upon it, then unpacked it at runtime. Ah, there it is: ** snip ** if ( is_file( SimpleWndProc.dll ) ? filesize( SimpleWndProc.dll ) != 2560 : 1 ) { $dll = eNrtVU9IFGEUf7NpTbZue1hCYqlvQT3JslsG0clt/aho1XHNDOnguDutY+uMzh80 . KDrYQTPJS1TUoWMEdSpYrEOEsQl66yD9gT1ILCHhIcqDML35Zla3IgO7mQ9+733v /* ... */ . dxBP8K4dRTzGcY6dBwcd8sBgVupS0lgfi9siXnQPAErZOyqrYXMXwO/8l7oiy5Fv . kdWIJ8pHfdFAdH90uzf+D/QDFVAQCA==; $dllout = fopen( SimpleWndProc.dll, wb ); if ( !$dllout ) die( Unable to extract SimpleWndProc.dll ); fwrite( $dllout, gzuncompress( base64_decode( $dll ) ) ); fclose( $dllout ); --- That's from an iridium example. You just base64 encode the data and enclose it in a string. Of course, that's simply one way of doing it. Jed Jamie wrote: Hi all, Well so far my attempts to make this work have failed so i thought i would try here. What i have is an installation script that has to write a few files to the webserver. Im trying to cut down on the amount of files that need to be uploaded/modified etc. So what im trying to do is include all the data in one file. What the user then uploads and the physical visual basic program activates the script what in turn sets up the web server side. The problem comes when im trying to handle the ascii values for the binary data. Warning: Unexpected character in input: '' (ASCII=3) state=2. I basicly have 3 questions. 1) Is it possible to store binary data in text form during transport and then using php's file writing functions to output the file? 2) How would i do it as i guess i have to encode the ascii characters but how would i do that? 3)Is there any better ways you suggest me to do this. Im trying to this for two reasons first is to make the application usable by anyone and the second reason is to try to push the boundarys of the langage. I would like anyones comments and views on this please. Any views might help me come to a result. Thanks Jamie -- _ (_)___Jed Smith, Code Monkey | / __| [EMAIL PROTECTED] | [EMAIL PROTECTED] | \__ \ +1 541 606-4145 _/ |___/ Signed mail preferred (PGP 0x703F9124) |__/http://personal.jed.bz/keys/jedsmith.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: sanitizing/security
mysql_escape_string() is what you're looking for. Jed Sebastian wrote: just a question, what is the best way to sanitize your scripts when you're using $_GET or $_REQUEST in a query? eg, i usually just do: if(is_numeric($_REQUEST['id'])) { mysql_query(SELECT id FROM table WHERE id=.intval($_REQUEST['id']).); } what about when the GET is text? just use htmlspecialchars? just looking for some advice to help keep my apps secure. cheers -- _ (_)___Jed Smith, Code Monkey | / __| [EMAIL PROTECTED] | [EMAIL PROTECTED] | \__ \ +1 541 606-4145 _/ |___/ Signed mail preferred (PGP 0x703F9124) |__/http://personal.jed.bz/keys/jedsmith.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Performance of magic_quotes_gpc ??
They do not do the same thing. mysql_escape_string() is what you're after, if you're inserting data from user input into an SQL statement, regardless! Jed -- _ (_)___Jed Smith, Code Monkey | / __| [EMAIL PROTECTED] | [EMAIL PROTECTED] | \__ \ +1 541 606-4145 _/ |___/ Signed mail preferred (PGP 0x703F9124) |__/http://personal.jed.bz/keys/jedsmith.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php