[PHP] Working with internal data formats

2008-05-15 Thread John Gunther
What technique can I use to take an 8-byte double precision value, as 
stored internally, and assign its value to a PHP float variable without 
having the bytes misinterpreted as a character string.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Working with internal data formats

2008-05-15 Thread John Gunther

Iv Ray wrote:

John Gunther wrote:
  What technique can I use to take an 8-byte double precision value, as
  stored internally, and assign its value to a PHP float variable without
  having the bytes misinterpreted as a character string.

Does it get misinterpreted, or do you just want to be sure?

The documentation says -

Some references to the type double may remain in the manual. Consider 
double the same as float; the two names exist only for historic reasons.


Does this cover your case?

Iv

No.

Example: I extract the 8 bytes 40 58 FF 5C 28 F5 C2 8F from an external 
file, which is the internal double precision float representation of the 
decimal value 99.99. Starting with that byte string, how can I create a 
PHP variable whose value is 99.99?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: menu andfolder question

2008-01-05 Thread John Gunther
Unless I misunderstand your question, this is normal behavior. The page 
designer purposely enters the link in the simpler form: 
http://www.zend.com/en/company
because the web server is configured to assume that index.htm is the 
default page in that folder and correctly displays it.


Alain Roger wrote:

Hi,

Serveral web sites have a menu and when you pass your mouse over a link, the
browser statusbar only shows the folder where is located the file link, not
the complete address including the file link.

i mean if you take web site : http://www.zend.com/en/
when you pass your mouse cursor over Company link, it displays only : 
http://www.zend.com/en/company; in the statusbar of your browser.
how is it possible whereas the link points to company/index.htm ?

thanks a lot,



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: website tree

2008-01-05 Thread John Gunther

Get the various parts from the $_SERVER superglobal variable:
1) scheme (e.g. http://) from $_SERVER['HTTPS'] (https if on)
2) host:port (e.g. bucksvsbytes.com) from $_SERVER['HTTP_HOST']
3) /path/page?query part (e.g. /catalog/index.php?pid=444) from 
$_SERVER['REQUEST_URI']


John Gunther
Alain Roger wrote:

Hi,

let's imaging we have the following thing :

www.mywebsite.com/company/index.php
www.mywebsite.com/company/profile.php
www.mywebsite.com/services/index.php

how can i detect in which address am i ?

for example how to retrieve www.mywebsite.com/services or
www.mywebsite.com/company



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] HTML form upload works, CURL fails when uploading file from c:

2008-01-05 Thread John Gunther

PHP 5.2.1 on Apache/Linux. Client is Firefox and IE7 on Windows XP.

Uploading C:\boot.ini works great from an HTML type=file form element 
but fails using what should be the equivalent:

curl_setopt($ch,CURLOPT_POSTFIELDS,array('peru'='@C:/boot.ini'));

CURL error is failed creating formpost data. Same CURL works when the 
test file resides on the PHP server:

curl_setopt($ch,CURLOPT_POSTFIELDS,array('peru'='@/home/user/boot.ini'));

so problem seems to be in the '@C:/boot.ini' filespec. Substituting 
'@C:\boot.ini' or '@C:\\boot.ini' doesn't help.


What am I doing wrong?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: HTML form upload works, CURL fails when uploading file from c:

2008-01-05 Thread John Gunther
Well, dope slap I think I understand the problem now: CURL is 
operating from the server so it knows nothing about C: on the client!


So how do I solve my problem? I want to upload multiple files from C: to 
the server based on a single wildcard spec typed into an HTML form by 
the user.


John Gunther wrote:

PHP 5.2.1 on Apache/Linux. Client is Firefox and IE7 on Windows XP.

Uploading C:\boot.ini works great from an HTML type=file form element 
but fails using what should be the equivalent:

curl_setopt($ch,CURLOPT_POSTFIELDS,array('peru'='@C:/boot.ini'));

CURL error is failed creating formpost data. Same CURL works when the 
test file resides on the PHP server:

curl_setopt($ch,CURLOPT_POSTFIELDS,array('peru'='@/home/user/boot.ini'));

so problem seems to be in the '@C:/boot.ini' filespec. Substituting 
'@C:\boot.ini' or '@C:\\boot.ini' doesn't help.


What am I doing wrong?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] can't figure out proper format for c:\ path for curl upload

2008-01-04 Thread John Gunther
I can't figure out how to pass a c:\... filepath via curl for an RFC1867 
 multipart form upload in PHP 5.2.1.


I'm using the following code to perform a programmatic file upload to 
the PHP server:


$filepath='/home/user/testfile.txt';
$ch=curl_init('http://bucksvsbytes.com/upload.php');
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,array('peru'='@'.$filepath));
curl_exec($ch);
curl_close($ch);

Works great if the file I want to upload is on the web server but it 
never is. The files I want are on the client computer, of course, e.g. 
c:\home\user\testfile.txt


I've tried passing every variation of that path I can think of, e.g.:

C:\home\user\testfile.txt
C:\\home\\user\\testfile.txt
C:/home/user/testfile.txt
urlencode(...)
utf8_encode(...)

and nothing works. I either get the dreaded failed creating formpost 
data or the filepath shows up in $_POST and $_FILES is empty. The 
listed formats don't work with fopen() either.


I've searched dozens of web examples but I can't get it. Help!

For that matter, is there a better approach than curl for programmed 
uploads of client computer files to the PHP server?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] debugging imap_open

2007-11-09 Thread John Gunther
I'm trying to use imap functions for the first time and always get 
Couldn't open stream errors so I turned on both kinds of debugging. 
Unfortunately I can't find debugging output anywhere. What am I doing 
wrong? Here's my code:


ini_set('error_log','/tmp/imap.txt');
$po='{mail.usservas.org:143/debug}';
$mbox = imap_open($po, $user, $password ,OP_DEBUG);


Thanks for the help.

John Gunther

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Sending Mails

2007-11-09 Thread John Gunther
All true. sendmail or a sendmail shell must be running. The sendmail 
command to use can be customized in the sendmail_path directive in the 
php.ini configuration file.


If you can't manually use sendmail to send an email, php can't either.

John Gunther

Alberto García Gómez wrote:

I want to use the mail() function but doesn't work so I have some questions:

1. Is necessary that sendmail must be installed in the server to use this 
function?
2. Is necessary that sendmail must be running to use this function?
3. Is necessary that sendmail must be proper configure to use this function?


Este correo ha sido enviado desde el Politécnico de Informática Carlos Marx 
de Matanzas.
La gran batalla se librará en el campo de las ideas



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Sending Mails

2007-11-09 Thread John Gunther
From what you posted, it looks like it was successful: stat=Sent 
(lA9KQHhY008650 Message accepted for delivery)


If it isn't arriving, the cause may be down the line.

John

Alberto García Gómez wrote:
John, those are the lines in the log file when I try to send a mail 
using mail() function. PLease let me know my errors.


Nov  9 15:26:17 shannon sendmail[8649]: lA9KQHYt008649: from=apache, 
size=82, class=0, nrcpts=1, 
msgid=[EMAIL PROTECTED], 
[EMAIL PROTECTED]


Nov  9 15:26:17 shannon sendmail[8650]: lA9KQHhY008650: 
from=[EMAIL PROTECTED], size=382, class=0, nrcpts=1, 
msgid=[EMAIL PROTECTED], 
proto=ESMTP, daemon=Daemon0, relay=shannon.ipimtzcm.rimed.cu [127.0.0.1]


Nov  9 15:26:17 shannon sendmail[8649]: lA9KQHYt008649: 
[EMAIL PROTECTED], ctladdr=apache (48/48), delay=00:00:00, 
xdelay=00:00:00, mailer=relay, pri=30082, relay=[127.0.0.1] [127.0.0.1], 
dsn=2.0.0, stat=Sent (lA9KQHhY008650 Message accepted for delivery)


- Original Message - From: John Gunther [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Friday, November 09, 2007 03:16 PM
Subject: [PHP] Re: Sending Mails


All true. sendmail or a sendmail shell must be running. The sendmail 
command to use can be customized in the sendmail_path directive in the 
php.ini configuration file.


If you can't manually use sendmail to send an email, php can't either.

John Gunther


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: debugging imap_open

2007-11-09 Thread John Gunther
Since no one seems to know about the debug feature, let me ask about the 
imap argument directly. None of the following work, always Couldn't 
open stream:

mail.usservas.org:143
mail.usservas.org:110
mail.usservas.org:143/imap
mail.usservas.org:110/pop3
mail.usservas.org:143/imap/notls
mail.usservas.org:110/pop3/notls
mail.usservas.org:143/imap/ssl/novalidate-cert
mail.usservas.org:110/pop3/ssl/novalidate-cert

The only mention of imap in phpinfo() is in the imap section:
IMAP c-Client Version   2001
SSL Support enabled
Kerberos Supportenabled

I can manually log in to pop3  and imap through telnet, so I'm at a 
loss. Am I leaving something important out? I'm running PHP 5.2.1 on 
Apache 2.0


John

John Gunther wrote:
I'm trying to use imap functions for the first time and always get 
Couldn't open stream errors so I turned on both kinds of debugging. 
Unfortunately I can't find debugging output anywhere. What am I doing 
wrong? Here's my code:


ini_set('error_log','/tmp/imap.txt');
$po='{mail.usservas.org:143/debug}';
$mbox = imap_open($po, $user, $password ,OP_DEBUG);


Thanks for the help.

John Gunther


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Retrieving response headers from an off-site page

2006-08-01 Thread John Gunther
Thank you! It sure looks like cURL is exactly the tool I need. As soon 
as I get it installed, I'll start playing with it.


Ray Hauge wrote:

I deal with screen-scraping a lot at work.  I would suggest using cURL to 
store the cookie data, and then subsequently get the data you need.


HTH
 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Retrieving response headers from an off-site page

2006-07-31 Thread John Gunther
I'm trying to programatically retrieve a sales tax lookup page using 
file_get_contents() but the page doesn't return data unless a session id 
is first retrieved and then supplied.


You can see how it works as follows:

The first time I send the following request: 
http://www7.nystax.gov/STLR/stlrHome?street=48%20central%20avezip=12472B1=Lookup%20Address 
I get an empty form back, and one of the response headers is Set-Cookie 
with a value of, say, 
JSESSIONID=0001WQEmZF6tI-yClq4S9_7a8ii:10amela49;Path=/


If I then reload the same URL, the resulting page includes the desired 
info, probably because the second time one of the request headers is 
Cookie with a value of JSESSIONID=0001WQEmZF6tI-yClq4S9_7a8ii:10amela49


I want to get the second version of the page, the one with data, using 
file_get_contents(), but it appears I first have to get the page to 
return a sessionid and then I have to send it in a Cookie header the 
second time.


Reading the first GET's response headers and sending the needed request 
header on the second GET - in combination with file_get_contents() - is 
just beyond me. Can anyone enlighten me?


John Gunther

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Startinga shell process with a life of its own

2006-07-11 Thread John Gunther
Great approach! Slicker'n snot. I added one enhancement: The shell 
script writss progress info to the database which the trigger page 
displays on entry.




Richard Lynch wrote:

I would recommend, however, that you re-structure things slightly so
that the Architecture is more like this:

User visits web page.
Page generates a database record of what needs to be done.
Page finished.


CRON JOB:
Look in task list of what needs doing, and do some of them.
Make sure only one job is done at a time, or whatever race conditions
are handled here.

I've done projects both ways, and always end up frustrated with the
PHP attempts to background a process and the Task List + Cron
always works out far far better.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Startinga shell process with a life of its own

2006-07-06 Thread John Gunther
Which PHP method allows me to start a shell process from a web page 
script and let it proceed to its conclusion even though I end the page. 
Most of the various execute functions seem to wait for the process to 
finish before PHP continues. I don't understand the ones with open/close 
functions. Will opening a process and failing to close it let it run 
after the page ends? Will failing to close cause other problems? Can you 
point me to example code? The shell commands I want to run are typically 
themselves PHP programs whose execution time is far too long to complete 
in a browser context.


John Gunther
Bucks vs Bytes Inc

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] serve long duration pages

2006-06-28 Thread John Gunther
This may be more appropriate for an Apache or browser forum. Perhaps you 
can suggest an appropriate one.


I have a PHP script that takes a long time to complete (due to very 
heavy database activity) although it echoes unbuffered output every few 
seconds. I've set max_execution_time to 0 with set_time_limit(0) so PHP 
doesn't time out the page but after about 3 minutes, Firefox says, The 
connection to the server was reset while the page was loading. and IE7 
says, Internet Explorer cannot display the web page. I want to try 
apache_reset_timeout() but it's not implemented in 4.3.10.


Is there anything I can do from PHP or elsewhere to solve this?

John Gunther
Bucks vs Bytes Inc

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] serve long duration pages

2006-06-28 Thread John Gunther
You're right sads (self-administered dope slap), my task is really not 
a web function except for the need to trigger it from an admin page. I'm 
going to use the PHP command line interface to run it without web 
interaction. However, there are still situations where a web script may 
sometimes involve long run times depending on the parameters supplied by 
the user (an example might be a SQL execution page where the 
user-supplied query could range from simple to very complex). I'd still 
like to know how to communicate via PHP that I want an infinite timeout 
for a particular web page..



lets start by saying that any webpage script that takes that long to run is
shit by design.
 


John

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Calculations and exponents in languages

2006-06-28 Thread John Gunther

Algol used ^

More common, historically, is the use of ** as the exponentiation 
operator: Fortran, PL/I, perl, python


Curiously, many modern languages -- inexplicably -- don't have an 
exponentiation operator: C, Java, Javascript, PHP


John Gunther


Robin Vickery wrote:

On 28/06/06, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

Huh.. thanks for the illustration Robin.  Can't say that I did much 
with exponents when I've played around with perl or python or C.. and 
never worked with Java.  You've expanded my view.


Ok, now what languages DO use ^ for exponents?



The only one I can think of off the top of my head is BASIC.

Even Bash uses ^ as an xor operator:

  $ echo $(( 7 ^ 2 ))
  5
  $ echo $(( 7 ** 2 ))
  49

-robin


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] sessions expiring

2006-06-02 Thread John Gunther

I can't find the proper settings to keep unattended sessions from
expiring in about an hour. Specifically, the $_SESSION variable contents
disappear. I've read the docs, but nothing seems to work. Any ideas?
Here are the session parameters that are in effect:

session.auto_startOn
session.bug_compat_42On
session.bug_compat_warnOn
session.cache_expire180
session.cache_limiternocache
session.cookie_domainno value
session.cookie_lifetime0
session.cookie_path/
session.cookie_secureOff
session.entropy_fileno value
session.entropy_length0
session.gc_divisor100
session.gc_maxlifetime28800
session.gc_probability0
session.namePHPSESSID
session.referer_checkno value
session.save_handlerfiles
session.save_path/var/lib/php4
session.serialize_handlerphp
session.use_cookiesOn
session.use_only_cookiesOff
session.use_trans_sidOff


Thanks.

John Gunther
Bucks vs Bytes Inc

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] SVG page displays correctly, but not when generated by PHP

2002-02-24 Thread john gunther

Does anyone have any idea why I can display a true SVG file successfully 
in IE 6 with Adobe SVG viewer 3.0, but not when the identical content is 
generated by PHP. Example:

SVGRECT.SVG displays properly (Apache server includes directive AddType 
image/svg+xml svg):

?xml version=1.0 encoding=UTF-8 standalone=no ?
!DOCTYPE svg PUBLIC -//W3C//DTD SVG 1.0//EN 
http://www.w3.org/TR/SVG/DTD/svg10.dtd;
svg
rect x=10 y=0 width=460 height=50 /
/svg

However, SVGRECT.PHP, which results in the same page text, brings up a 
dialog box Would you like to open the file or save it to your 
computer? Choosing Open causes nothing to happen. Choosing Save 
results in another dialog box Internet Explorer  was unable to open 
this internet site:

?php
header(Content-type: image/svg+xml);
echo ?xml version=\1.0\ encoding=\UTF-8\ standalone=\no\ ?;
echo \n!DOCTYPE svg PUBLIC \-//W3C//DTD SVG 1.0//EN\ 
\http://www.w3.org/TR/SVG/DTD/svg10.dtd\;;
echo \nsvg;
echo \nrect x=\10\ y=\0\ width=\460\ height=\50\ /;
echo \n/svg;
?

Displaying SVGRECT.PHP from another PHP page using the embed tag works 
properly.

Here's another curious occurrence that may be related: displaying any   php 
page as a local file brings up the Windows Open with dialog, whereas 
referencing the same page as a URL works.

Any insighta you can provide would be appreciated. Thanks.

John Gunther


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php