php-general Digest 16 May 2006 15:34:19 -0000 Issue 4131
Topics (messages 236261 through 236281):
Help w/ 'headers already sent' and file download
236261 by: Mike Walsh
236262 by: Rabin Vincent
236267 by: Barry
236272 by: Mike Walsh
Re: Wierd ass code...
236263 by: Chris
Re: Trouble sending data via TCP socket
236264 by: Rabin Vincent
236274 by: Martin Marques
Re: Parsing a stdClass Object created with mimeDecode
236265 by: Stut
Re: DOMElement->setAttribute() loops forever (node_list_unlink bug?)
236266 by: Riku Palomäki
404 After Setting session.save_path to /tmp
236268 by: Mark Sargent
236270 by: nicolas figaro
236271 by: Jochem Maas
FIT implementation for PHP
236269 by: Ronny Unger
PHP daemons
236273 by: Martin Marques
236276 by: M. Sokolewicz
236278 by: Martin Marques
236279 by: Jad madi
236280 by: Martin Marques
Re: Class/function scope general question
236275 by: Edward Vermillion
Re: Development Environments/Automation
236277 by: Brian Anderson
Re: Does PECL install modify my php.ini? or even look at it?
236281 by: D. Dante Lorenso
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
I have an application which I am working on which takes a file supplied by
the user via a File Upload, peforms some processing on it, then prompts the
user to download a generated CSV file. What I would like to do is report
some processing statistics prior to the user prior to sending the CSV steam.
My CSV export ends with this:
header("Content-type: application/vnd.ms-excel") ;
header("Content-disposition: attachment; filename=CSVData." .
date("Y-m-d").".csv") ;
print $csvStream ;
Unfortunately if I display any content prior to sending the CSV stream I get
the 'headers already sent' error message.
Is there a way to both display a web page and send content to be saved by
the user? If someone knows of an example I could look at I'd be greatful.
Thanks,
Mike
--
Mike Walsh - mike_walsh at mindspring.com
--- End Message ---
--- Begin Message ---
On 5/16/06, Mike Walsh <[EMAIL PROTECTED]> wrote:
I have an application which I am working on which takes a file supplied by
the user via a File Upload, peforms some processing on it, then prompts the
user to download a generated CSV file. What I would like to do is report
some processing statistics prior to the user prior to sending the CSV steam.
My CSV export ends with this:
header("Content-type: application/vnd.ms-excel") ;
header("Content-disposition: attachment; filename=CSVData." .
date("Y-m-d").".csv") ;
print $csvStream ;
Unfortunately if I display any content prior to sending the CSV stream I get
the 'headers already sent' error message.
Is there a way to both display a web page and send content to be saved by
the user? If someone knows of an example I could look at I'd be greatful.
No, you cannot display both a webpage and send a file
on the same page to the user.
What you could do is save the processed file in a temporary
folder and provide a link to download the file in your processing
statistics page. Or, you could redirect the user to the file after
showing the statistics page.
Rabin
--- End Message ---
--- Begin Message ---
Mike Walsh schrieb:
I have an application which I am working on which takes a file supplied by
the user via a File Upload, peforms some processing on it, then prompts the
user to download a generated CSV file. What I would like to do is report
some processing statistics prior to the user prior to sending the CSV steam.
My CSV export ends with this:
header("Content-type: application/vnd.ms-excel") ;
header("Content-disposition: attachment; filename=CSVData." .
date("Y-m-d").".csv") ;
print $csvStream ;
Unfortunately if I display any content prior to sending the CSV stream I get
the 'headers already sent' error message.
Is there a way to both display a web page and send content to be saved by
the user? If someone knows of an example I could look at I'd be greatful.
Split the page.
One php page showing the content and the second generating the csv file.
Call that script with Javascript when the page is load.
That way you could display the content and download the file.
Greets
Barry
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
--- End Message ---
--- Begin Message ---
""Rabin Vincent"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
On 5/16/06, Mike Walsh <[EMAIL PROTECTED]> wrote:
[ ... snipped ... ]
>
> Is there a way to both display a web page and send content to be saved by
> the user? If someone knows of an example I could look at I'd be greatful.
No, you cannot display both a webpage and send a file
on the same page to the user.
What you could do is save the processed file in a temporary
folder and provide a link to download the file in your processing
statistics page. Or, you could redirect the user to the file after
showing the statistics page.
Rabin
[ ... snipped ... ]
I found a solution to my problem - an IFRAME with a 0 height and 0 width
does the trick.
Here is a thread which helped:
http://forums.invisionpower.com/index.php?showtopic=214649
Mike
--
Mike Walsh - mike_walsh at mindspring.com
--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
On Sat, May 13, 2006 6:37 pm, Rory Browne wrote:
There are some cases where the Error Suppression operator may be
useful in
good code.
Last I checked, you pretty much HAD to use it for pg_fetch_row() since
it does an E_NOTICE when you try to fetch a row beyind the number
available...
FYI - not any more.
I find I have to with imap_open though (should get around to posting a
bug report about that)..
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On 5/16/06, J. King <[EMAIL PROTECTED]> wrote:
To further my understanding of how Jabber works I have decided I should
try and write my own XMPP implementation in PHP. However, I've run into
trouble rather quickly.
To connect to a Jabber server, one must open a TCP socket to the server
(typically through port 5269) send an XML-based stream header, wait for
the server's confirmation and then log in, etc. As an initial test I
tried to open a TCP socket, send a stream header, get the server's
response, then disconnect. I did so thusly:
$server = "jabber.org"; //example server
$port = 5269; //default port
$nsStream = "http://etherx.jabber.org/streams"; // Streams namespace
$socket = stream_socket_client("tcp://$server:$port");
$header = "<stream:stream to='$server' xmlns='jabber:client'
xmlns:stream='$nsClient' xml:lang='en' version='1.0'>";
fwrite($socket, $header); //send header
echo stream_get_contents($socket); //get server confirmation
//close connection
fwrite($socket, "</stream:stream>");
fclose($socket);
[snipped]
I played with your code and here are some observations:
Shouldn't that variable inside $header be $nsStream (and not
$nsClient)? Also, stream_get_contents may not be ideal here
since it tries to get the full contents of the stream (until EOF?),
so you should probably be using fread() here.
Another thing, the Jabber.org default port seems to be 5222
(class.jabber.php also uses that port).
Rabin
--- End Message ---
--- Begin Message ---
On Mon, 15 May 2006, J. King wrote:
To further my understanding of how Jabber works I have decided I should try
and write my own XMPP implementation in PHP. However, I've run into trouble
rather quickly.
To connect to a Jabber server, one must open a TCP socket to the server
(typically through port 5269) send an XML-based stream header, wait for the
server's confirmation and then log in, etc. As an initial test I tried to
open a TCP socket, send a stream header, get the server's response, then
disconnect. I did so thusly:
$server = "jabber.org"; //example server
$port = 5269; //default port
$nsStream = "http://etherx.jabber.org/streams"; // Streams namespace
$socket = stream_socket_client("tcp://$server:$port");
$header = "<stream:stream to='$server' xmlns='jabber:client'
xmlns:stream='$nsClient' xml:lang='en' version='1.0'>";
[snip]
<stream:error>
<invalid-namespace
xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>
</stream:error>
What's the value of $nsClient??? I doesn't look like it's defined at all,
so I would guess that your problem is there.
--
21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18
---------------------------------------------------------
Lic. Martín Marqués | SELECT 'mmarques' ||
Centro de Telemática | '@' || 'unl.edu.ar';
Universidad Nacional | DBA, Programador,
del Litoral | Administrador
---------------------------------------------------------
--- End Message ---
--- Begin Message ---
Graham Anderson wrote:
I am trying to get the body text from a number of different emails using
mimeDecode [Pear]
Unfortunately, it appears that the body text could be in any number of
locations in the stdClass Object depending on which email is processed.
At this point, I can only access the node by looking at the
print_r($structure) directly :(
Out of the three different emails I parsed, I got three different
locations for the 'body' node
$structure->parts[0]->parts[0]->parts[0]->body;
$structure->body;
$structure->parts[0]->body;
Question:
Is there a way to generically traverse the entire object generated from
Mail_mimeDecode and search for the correct node ?
In my case, these conditions need to be met .
if (trim($part->ctype_primary)== "text" && trim($part->ctype_secondary)
== "plain")
{
$body = $part->body;
echo "the body text is: $body";
}
}
I've recently needed to do this for a site I'm writing. This is what I
came up with to find the first body (for my purposes I don't care about
the type). I've not tested it much, but it will be getting a grilling
over the coming weeks. It shouldn't be too hard to modify it to ensure
it meets your requirements, but bear in mind that an email is not
required to have a text/plain part.
if ($structure->ctype_primary == 'multipart')
{
$part = $structure->parts[0];
while ($part->ctype_primary == 'multipart')
$part = $part->parts[0];
$body = $part->body;
$type = $part->ctype_primary.'/'.$part->ctype_secondary;
}
else
{
$body = $structure->body;
$type = $structure->ctype_primary.'/'.
$structure->ctype_secondary;
}
Hope that helps.
-Stut
--- End Message ---
--- Begin Message ---
Rob Richards wrote:
> Riku Palomäki wrote:
>> Hello,
>>
>> I'm having problems with DOMElement->setAttribute() -method with my php
>> script. I stripped down the code to this:
>>
>> ----------------------
>> $doc = new DOMDocument();
>> $doc->resolveExternals = true;
>> $doc->loadXml('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><a b="" />');
>>
>> $root = $doc->getElementsByTagName('a')->item(0);
>> $root->setAttribute('b', '>');
>> $root->setAttribute('b', '');
>>
>> // This will never be executed
>> echo "done\n";
>> ----------------------
>
> Can you please bug this (no need for the backtrace), so I don't forget
> it. I see the problem but will take me a day or two to get around to fix.
>
> As a work around for now you can do:
> $root->setAttributeNode(new DOMAttr('b', '>'));
> $root->setAttribute('b', '');
Ok, http://bugs.php.net/37456
--
Riku
--- End Message ---
--- Begin Message ---
Hi All,
I get this,
Not Found
The requested URL /movie1.php was not found on this server.
------------------------------------------------------------------------
Apache/2.2.0 (Fedora) Server at localhost Port 80
when setting session.save_path to /tmp in /usr/local/lib/php.ini.
Even if I change it back, I still get that error. Restarting httpd
doesn't fix it. Only a reboot, ouch! Why is this happening? Cheers.
httpd = 2.2.2
php = 5.1.4
OS = Fedora 5
Mark Sargent.
--- End Message ---
--- Begin Message ---
Mark Sargent a écrit :
Hi All,
I get this,
Not Found
The requested URL /movie1.php was not found on this server.
------------------------------------------------------------------------
Apache/2.2.0 (Fedora) Server at localhost Port 80
when setting session.save_path to /tmp in /usr/local/lib/php.ini.
Even if I change it back, I still get that error. Restarting httpd
doesn't fix it. Only a reboot, ouch! Why is this happening? Cheers.
Hi,
you should check apache log files.
I don't know if your server is allowed to write to /tmp.
what's the initial (default) session.save_path ?
try to set it to a subdirectory of your DocumentRoot. (check httpd.conf
for the DocumentRoot).
(/www/root/default_vhost/tmp for example, if /www/root/default_vhost is
your DocumentRoot).
N F
httpd = 2.2.2
php = 5.1.4
OS = Fedora 5
Mark Sargent.
--- End Message ---
--- Begin Message ---
nicolas figaro wrote:
...
try to set it to a subdirectory of your DocumentRoot. (check httpd.conf
for the DocumentRoot).
(/www/root/default_vhost/tmp for example, if /www/root/default_vhost is
your DocumentRoot).
NO - DONT EVER DO THIS!!!! tmp/session files should not be stored in a
directory that
can be [potentially] read via http.
.htaccess directives can be used to block access to the dir BUT I still would
recommend
keeping 'tmp' outside of the web root.
just make sure 'tmp' is writable by the user the webserver is running as.
N F
httpd = 2.2.2
php = 5.1.4
OS = Fedora 5
Mark Sargent.
--- End Message ---
--- Begin Message ---
Hello,
I am looking for an implemantion of FIT (Framework for Integrated Test) for
PHP.
http://fit.c2.com/
https://sourceforge.net/projects/fitlibrary/
Now I am thinking about implementing it myself. But before I want to know if
anybody is already working on such an implementation or has heart of it?
Thanks alot!
Ronny Unger
#####################
Mail: [EMAIL PROTECTED]
WWW: www.php-workx.de
--- End Message ---
--- Begin Message ---
I've been using PHP for a while with a daemon I made a few years ago,
which is in use, working great. I used the example that's in the docs:
http://www.php.net/manual/en/ref.sockets.php
A few months ago I started to make a new daemon for other purposes, and I
decided to build some objects to make it OOP. This small server is almost
fully functional, but I got into a small problem: I can't kill the daemon
like I used to with the other daemon. I just won't die, unless I get the
pid and send a SIGKILL to the pid.
Both servers are runned executing the PHP script, which has in the first
line:
#!/usr/bin/php
In the first daemon all I have to do to kill it is execute a
pkill server_name.
But with the new daemon (the object orientaded one) it doesn't die. Any
ideas on why?
--
21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18
---------------------------------------------------------
Lic. Martín Marqués | SELECT 'mmarques' ||
Centro de Telemática | '@' || 'unl.edu.ar';
Universidad Nacional | DBA, Programador,
del Litoral | Administrador
---------------------------------------------------------
--- End Message ---
--- Begin Message ---
Well, by looking into my cristal ball I think your problem lies at line
12 of file x.php for sure!! It's probably the
I_have_not_seen_any_code_at_all("so I can't tell you anything about it")
function there.
goodluck!
- tul
Martin Marques wrote:
I've been using PHP for a while with a daemon I made a few years ago,
which is in use, working great. I used the example that's in the docs:
http://www.php.net/manual/en/ref.sockets.php
A few months ago I started to make a new daemon for other purposes, and
I decided to build some objects to make it OOP. This small server is
almost fully functional, but I got into a small problem: I can't kill
the daemon like I used to with the other daemon. I just won't die,
unless I get the pid and send a SIGKILL to the pid.
Both servers are runned executing the PHP script, which has in the first
line:
#!/usr/bin/php
In the first daemon all I have to do to kill it is execute a
pkill server_name.
But with the new daemon (the object orientaded one) it doesn't die. Any
ideas on why?
--
21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18
---------------------------------------------------------
Lic. Martín Marqués | SELECT 'mmarques' || Centro de
Telemática | '@' || 'unl.edu.ar';
Universidad Nacional | DBA, Programador,
del Litoral | Administrador
-------------------------------------------------------
--
--- End Message ---
--- Begin Message ---
On Tue, 16 May 2006, M. Sokolewicz wrote:
Well, by looking into my cristal ball I think your problem lies at line 12 of
file x.php for sure!! It's probably the I_have_not_seen_any_code_at_all("so I
can't tell you anything about it") function there.
No problem. :-)
I solved it making a second script that I run when I want to close the
server. This script just conects and sends a "shutdown" string. I changed
the daemon so that it will recieve this string and close all conections,
close the socket and break all the loops. :-)
Any way, I don't know why the code from the first daemon finish well when
a kill is sent to it (remember that this daemon is a copy from the first
example at: http://ar2.php.net/manual/en/ref.sockets.php)
--
21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18
---------------------------------------------------------
Lic. Martín Marqués | SELECT 'mmarques' ||
Centro de Telemática | '@' || 'unl.edu.ar';
Universidad Nacional | DBA, Programador,
del Litoral | Administrador
---------------------------------------------------------
--- End Message ---
--- Begin Message ---
Martin,
I'm afraid we cannot help you without reading the code, paste it to
phpfi.com and send the url here
now the general answer is, OOP or not OOP it doesn't matter
there is problem in the code whatever and however it's written dude.
--- End Message ---
--- Begin Message ---
On Tue, 16 May 2006, Jad madi wrote:
Martin,
I'm afraid we cannot help you without reading the code, paste it to
phpfi.com and send the url here
now the general answer is, OOP or not OOP it doesn't matter
there is problem in the code whatever and however it's written dude.
Yes (the code is really big, that's why I didn't paste it).
My question would be then, how can I control a SIGTERM signal from inside
a PHP CLI script?
P.D.: My original problem was solved, as you can see in an earlier post.
--
21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18
---------------------------------------------------------
Lic. Martín Marqués | SELECT 'mmarques' ||
Centro de Telemática | '@' || 'unl.edu.ar';
Universidad Nacional | DBA, Programador,
del Litoral | Administrador
---------------------------------------------------------
--- End Message ---
--- Begin Message ---
On May 15, 2006, at 7:53 PM, Richard Lynch wrote:
You can't do that.
Yeah I can, sorta. Well not really as I'm having to pass a reference
to the class object around. But that works.
The whold class has to be in a single contiguous file.
Last I checked.
To be able to use $this-> in the functions yeah, although it was
available in the file, outside of a function.... but that could get
*real* dangerous.
On the plus side, it's incredibly unlikely that having the functions
in separate files was a Good Idea...
Well... I know it's not a *good* idea, it's just an intermediate step
that's helping me see the class pieces a little better so I *can*
figure out the best way to go. I've got a monster that has grown out
of control over time that really needs to be tamed.
Ed
--- End Message ---
--- Begin Message ---
Thanks.
I will check out the links that you and Peer sent me. Qcodo and Cake
both look like promising alternatives.
I appreciate the help,
-Brian
Miles Thompson wrote:
At 02:01 PM 5/15/2006, Brian Anderson wrote:
Hello,
I am being asked to find some sort of development environment for
PHP/MySQL, if is exists, in which it has some sort of
automation/wizzardry. What is being done is a mass of MSAccess
interfaces, forms, reports, etc. are needing to be re-written in php
and connected to a MySQL database instead of the Access.
What is being asked for is something that although being able to
build some interfaces through wizzards/gui's, that is be somewhat
logical, and streamlined in its management of code and html.
Something that implements some kind of smarty tag or similar woould
be good instead of say... Macromedia which can do some fairly bloated
and cumbersome things with logic and markup. Also, It would need to
be flexible enough to manage projects back and forth between
wizzards, and hand coding so that one wasn't limited to the narrow
applications of the wizzard.
Does something like this exist?
I have played around with Macromedia, and another app called
CodeCharge Studio. I hope that I am asking the right or at least an
intelligent question.
-Brian
Do you mean a framework?
Have a look at Qcodo, Cake, etc. Qcodo allows you to preserve your
interface while making logic / database changes.
Regards - Miles Thompson
--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
On Thu, May 11, 2006 6:02 pm, D. Dante Lorenso wrote:
> pecl install memcache
Is it possible that pecl has an --extension-dir flag to tell it WHERE
to install stuff, or perhaps an optional command line arg or ...
Cuz, really, the odds on it being where you want it to be are pretty
slim.
Odds would be increased if 'pecl' would look at what I've already
declared in the PHP.ini file ;-)
Dante
--- End Message ---