Re: [PHP] php + lynx + grep
Why not try cURL? Not the cURL functions included in PHP, but the actual binary installed with most linux distributions. Even better would be to actually use the cURL functions in PHP, but whatever you find easier. Matt On Tue, 2004-04-06 at 08:41, Brian L. Ollom wrote: lynx --source http://weather.noaa.gov/weather/current/KTOL.html |grep -v '41-35-19N' |grep TOL | head -n 1 I need to get the output of the above command for a web site I'm working on. I've tried exec(), system() and neither seems to work. It's output should be something like this(it changes hourly): TDFONT FACE=Arial,Helvetica KTOL 061152Z 23004KT 10SM CLR 00/M07 A3007 RMK AO2 SLP187 T1072 10017 21033 53005 Help! | Brian Ollom | | | NiteHawke.Com| http://www.nitehawke.com/| | An Authorized Firefly Dealer | email [EMAIL PROTECTED] |
Re: [PHP] http referrer
$HTTP_REFERER Although not all browsers send it properly (if at all). Don't rely on it. Matt On Thu, 2004-04-08 at 12:22, Chris Bruce wrote: I apologize for my ignorance, but I am trying to find a way to grab the referring url. I can't seem to find the environment variable to do this. Does anyone know how to grab this? Thanks. -- Chris Bruce [EMAIL PROTECTED] Idextrus E-Business Architects http://www.idextrus.com 3282 Wilmar Cres. Mississauga, ON L5L4B2 CA 905.828.9189 This e-mail and its contents are privileged, confidential and subject to copyright. If you are not the intended recipient, please delete this e-mail immediately. Any unauthorized use or disclosure of the information herein is prohibited.
Re: [PHP] Multiple Socket Read and Writes?
Wednesday, February 25, 2004, 2:19:26 AM, you wrote: D Hello all, D I am having a problem with getting multiple socket reads working in a D simple socket server! D The writes appear to be working but the reads seam to only allow one read? D I know i am missing something. Could even be my approach is totally wrong D Currently I have: D$input = socket_read($client[$i]['sock'] , 2024,PHP_BINARY_READ ); Dif ($input == null) { D // Zero length string meaning disconnected D echo null input 1\n; D unset($client[$i]); D} Delseif ($input == 'exit') { D // requested disconnect D echo exit\n; D socket_shutdown($client[$i]['sock']); D socket_close($client[$i]['sock']); D} D elseif ($input==kill) { D echo kill\n; D socket_shutdown($sock); D socket_close($sock); D die; D } D elseif ($input) { D // strip white spaces and write back to user D echo -- . $input.\n; D socket_write( $client[$i]['sock'],dechex(50) ); D echo -- SYN D .socket_strerror(socket_last_error()).\n; D socket_write( $client[$i]['sock'],dechex(50) ); D echo -- SYN D .socket_strerror(socket_last_error()).\n; D socket_write( $client[$i]['sock'],dechex(50) ); D echo -- SYN D .socket_strerror(socket_last_error()).\n; D //$output = ereg_replace([ \t\n\r],,$input).chr(0); D if ( false == ( socket_write( D $client[$i]['sock'],dechex(46) ) ) ) { D echo socket_write() failed: reason: . D socket_strerror(socket_last_error()) . \n; D } D else { D echo -- D ENQ .socket_strerror(socket_last_error()).\n; D $input1 = D socket_read($client[$i]['sock'] , D 2024,PHP_BINARY_READ ); D echo -- . $input1. . D socket_strerror(socket_last_error()) .\n; D }; D } D else { D echo nothing on INPUT\n; D } D -- D UMPA DBrian C. Doyle D Director, Internet Services D United Merchant Processing Association D http://www.umpa-us.comhttp://www.umpa-us.com D 1-800-555-9665 ext 212 How are you storing the socket in $client[$i]['sock']? Like This:? $socket = socket_create(...); $client[$i]['sock']; You need to do it like this: $client[$i]['sock'] = socket_create(...); Why are you using something like this anyways though? Wouldn't it be easier to use some sort of daemon? When processing one client your script will not be able to handle any of the others if you use the way you are using now. However, if you run it as a daemon, forking the process everyone someone connects, then it will be a separate process for each client and you wont have latency issues. Just a thought. Matt signature.asc Description: This is a digitally signed message part
Re: [PHP] multi dimension array sort help
Assuming your array is called $array1: $paths = array(); foreach ($array1 as $data_ptr = $data) { if (!in_array($data['path'],$paths) $paths[] = $data; } sort($paths) foreach($paths as $path_to_check) { foreach($array1 as $data_ptr = $data) { if ($data['path'] == $path_to_check) { /** Do your stuff here **/ } } } It's a little cumbersome and probably has way too many loops, but processor time is cheap and memory is even cheaper. I've found PHP's array parsing to be fairly quick. Alternatively, use the path as the index for your array; i.e: $array1 = array(path = array(path_id = 3, year = 2004, month = 02, day = 05, hits = 3); When you're parsing your log (which is what I'm assuming you're doing), you would populate $array1 as follows: $array1 = array(); while (parsing()) { $array1[$path]['path_id'] = $path_id; $array1[$path]['year'] = $year; /** etc... **/ } $paths = array_keys($array1); sort($paths); foreach($paths as $path_to_check) { /** Do stuff with $array1[$path_to_check] **/ } Matt Array ( [0] = Array ( [path_id] = 3 [year] = 2004 [month] = 02 [day] = 05 [hits] = 3 [path] = home ) [1] = Array ( [path_id] = 2 [year] = 2004 [month] = 02 [day] = 05 [hits] = 1 [path] = plan ) [2] = Array ( [path_id] = 7 [year] = 2004 [month] = 02 [day] = 05 [hits] = 1 [path] = specials ) ) On Wed, 2004-02-04 at 23:33, Justin French wrote: Hi, I've read and re-read array_multisort(), but still can't get a grip on how to sort my array: Array ( [0] = Array ( [path_id] = 3 [year] = 2004 [month] = 02 [day] = 05 [hits] = 3 [path] = home ) [1] = Array ( [path_id] = 2 [year] = 2004 [month] = 02 [day] = 05 [hits] = 1 [path] = plan ) [2] = Array ( [path_id] = 7 [year] = 2004 [month] = 02 [day] = 05 [hits] = 1 [path] = specials ) ) In this case, I'd like to sort the entire array on [path]. Can anyone provide some tips or an example to start from? Justin French signature.asc Description: This is a digitally signed message part
Re: [PHP] Unsetting multiple globals?
2 ways to do it: Simple, no control: foreach($GLOBALS as $key = $value) unset($GLOBALS[$key]); Or $vars_to_clear = array(1,2,3,4,a,b,C1,D2); foreach($vars_to_clear as $keyname) unset($GLOBALS[$keyname]); Matt On Tue, 2004-01-27 at 15:26, BOOT wrote: Hello. I can unset multiple variables easily, however I can't see how to unset multiple globals without: unset($GLOBALS['1']); unset($GLOBALS['2']) unset($GLOBALS['3']) and so forth I have tried a few variations with no success. Thanks for any help! signature.asc Description: This is a digitally signed message part
Re: [PHP] Re: Opening large file problem - fopen
Do you have long lines? If not try this: $file = error_log.txt; if (($fp = fopen($file,'r+') !== 0) { // Increment the 1024 sufficiently to read enough data, fgets automatically stops at \n while ($line = fgets($fp,1024)) { if ($line != ) echo($line.br); } } Alternatively, do you know what the last char or the first char in each line is? (i.e. an end-of-record or start-of-record identifier) Try this: $file = errors.txt; $file_size = filesize($file); $byte_count = 0; $fp = fopen($file,r+); $last_char = ; while ($byte_count $file_size) { $chr = ; $eol = ; $line = $last_char; while ($eol == 0) { //Use this for EOR checking, replace the $EOR with your EOL/EOR char) if (($chr = fread($fp,1)) === 0 || $chr == $EOR) $eol = 1; else $line .= $chr; /** Use this for SOR checking if (($chr = fread($fp,1)) === 0 || $chr == $SOR) $eol = 1; else $line .= $chr; $last_char = $chr **/ $byte_count = $byte_count + 1; } if (trim($line) != ) { //Do Something echo($line.br); } } this will need to be modified if you have a multi-byte EOR/SOR, but hopefully this will give you a good base. Matt On Tue, 2003-12-16 at 08:46, Kim Steinhaug wrote: Attached is a little textfile on 4 lines, it will choke afte 1 line due to the \n\n problem. I use this loop to parse it : $file= error_log.txt; if($fp=fopen($file, r+)) { while($line=trim(fgets($fp))) { echo $line . br; } } -- Kim Steinhaug --- There are 10 types of people when it comes to binary numbers: those who understand them, and those who don't. --- Kim Steinhaug [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, Thanks for you reply. The first approach works, I succesfully imported 1.903.541 entries into my mySQL database, phew! Problem was that as mentioned I had to massage the data beforehand, which with TextPad didnt take to much time but again I love my scripts to be complete and be standalone. Back to the 2) option, I tried another approach, just to see how far the script woul accually go. There are ~2,1 million lines in the error_log so I would like to see a result for the $i in this range. But this script also chokes. $file= error_log; $handle = fopen ($file, rb); $contents = ; do { $data = fread($handle, 8192); if (strlen($data) == 0) { break; } $contents = $data; $temp = explode(\n,$contents); $i = $i + count($temp); if($i%1000==0) // Spit out every 1000 lines count echo $i . br; } while(true); fclose ($handle); echo $count; exit; Do you have an example, or link to a site discussing the issue, of buffering the data? -- Kim Steinhaug --- There are 10 types of people when it comes to binary numbers: those who understand them, and those who don't. --- Eugene Lee [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Tue, Dec 16, 2003 at 01:30:14PM +0100, Kim Steinhaug wrote: : : I found out that what the script accually does is choke on \n\n, : empty lines. I havnt found a way to solve this with the script, : : What I do now is use TextPad and just replace all occurencies : of \n\n with \n-\n or something and it works all nice. But this : is a bad way of doing it, since the script still doesnt accually work... You have two options: 1) massage your data beforehand so that your script works properly 2) buffer your input lines so that you process them only after you have read a complete entry, since one entry may span multiple lines in your error_log. signature.asc Description: This is a digitally signed message part
Re: [PHP] Mulitple selects from form drop down box
On Thu, 2003-11-20 at 17:12, CPT John W. Holmes wrote: select size=1 name=D1[] multiple Now $_POST['D1'] will be an array of all the items that were chosen. ---John Holmes... ps: wouldn't it be easier to select multiple items if you had a size larger than 1?? The 'size=1' in a select doesn't mean there is only one object in the select, it means only show one object, or one row. 'size=3' would show three rows at a time. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple Forms
html body iframe name=post1 src=about:blank height=1 width=1 frameborder=no scrolling=no/iframe iframe name=post2 src=about:blank height=1 width=1 frameborder=no scrolling=no/iframe form name=form1 action=form_parser1.php target=post1 input type=text name=form1_value1 /form form name=form2 action=form_parser2.php target=post2 input type=text name=form2_value1 /form a href=about:blank onClick=form1.submit();form2.submit();return falseProcess Forms/a /body /html Matt On Tue, 2003-09-09 at 20:11, Dan Anderson wrote: Is it possible to tell a browser to send form a to URL a and form b to URL b? (i.e. post to two different URLS) Thanks, -Dan signature.asc Description: This is a digitally signed message part
Re: [PHP] Escaping nasty quotes
On Thu, 2003-07-31 at 14:31, Roy W wrote: I have this: $query = LOAD DATA LOCAL INFILE '/home/data.txt' INTO TABLE mytable FIELDS TERMINATED BY ',' ENCLOSED BY ' . '' . ' ; $result = MYSQL_QUERY($query); PRINT br$query2br; The query doesn't take ... but if I cut and paste the printed response into the mysql server manually ... works like a charm :-( Try this: $query = LOAD DATA LOCAL INFILE '/home/data.txt' INTO TABLE mytable FIELDS TERMINATED BY ',' ENCLOSED BY '\' ; It'll get rid of your parse error Matt signature.asc Description: This is a digitally signed message part
Re: [PHP] how to :: multi select
Hi Thomas. You need to name each checkbox a different name. alternatively, you can name them with array naming convention. i.e. input type=checkbox name='array1[value1]' value='Y' 1-1 input type=checkbox name='array1[value2]' value='Y' 1-2 input type=checkbox name='array2[value1]' value='Y' 2-1 input type=checkbox name='array2[value2]' value='Y' 2-2 Checking off 1-1 and 2-2 would create the following variables (assuming register_globals is on) in the target php script for the form: $array1=array(value1=Y,value2=); $array2=array(value1=,value2=Y); Hope this helps Matt On Fri, 2003-07-04 at 17:20, Thomas Hochstetter wrote: Hi guys, This might just be off the topic, but here it goes anyway: How can one multi select check boxes and pass them through in php, without getting mixed up with variables (email multi select style). Thomas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php