php-general Digest 10 Feb 2004 05:38:19 -0000 Issue 2581
Topics (messages 177221 through 177251):
OT -> Pocket PC/PALM Application making/syncing?
177221 by: Robert Sossomon
Re: triple DES encryption
177222 by: "Miguel J. Jiménez"
177223 by: Adam Bregenzer
177225 by: craig
Re: XML and Excel
177224 by: Marek Kilimajer
177234 by: Jake McHenry
Can PHP redirects be detected?
177226 by: Lowell Allen
177228 by: John W. Holmes
177229 by: joel boonstra
177230 by: joel boonstra
177236 by: Lowell Allen
177248 by: Adam Bregenzer
check if user session exists
177227 by: Christian Calloway
177233 by: Larry Brown
177235 by: Christian Calloway
177239 by: Rob Adams
177240 by: Christian Calloway
Re: [PHP-DB] SMTP authentication
177231 by: John W. Holmes
need help with references
177232 by: motorpsychkill
file downloads using header problem
177237 by: Joshua Minnie
[PHP5] Using exceptions to write more perfect software, but ...
177238 by: Markus Fischer
177250 by: Adam Bregenzer
CURL and Cookies
177241 by: Richard Miller
177243 by: Manuel Lemos
php with mysql COUNT, DISTINCT syntax, might be a bit 0T
177242 by: Ryan A
177245 by: Shaunak Kashyap
177246 by: Ryan A
writing a manual
177244 by: Tim Thorburn
Re: Detecting the name of the file a function is being called from
177247 by: Samuel Ventura
177249 by: Adam Bregenzer
177251 by: André Cerqueira
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 know this is way off topic, but I figured some or most have hit upon
this problem, or may very well in the future. I have been looking for
and not really found a reference online or a hardcopy book that will
tell me how to write a PALM or winDoze pocket PC application that when I
sync it to the PC will go to the web and download data. I am finding
that I need to learn this quickly (they say) so that I can transform a
set of pages online onto a PDA for the users that can only connect at
6AM and 6PM to the website.
Any thoughts, suggestions, topics, books??
I am assuming I will have to turn the PHP pages into a web service but I
need to learn the PDA end as well.
Thanks,
Robert
--- End Message ---
--- Begin Message ---
craig wrote:
Hi all,
I have to replicate the file encryption of a desktop bound
application. This means using triple DES, but I can't find
anything on the web or in the maunual (other than single
DES).
Does anyone know if it is doable to implement this using php,
or if I should just tell the client that it can't be done?
TIA,
Craig
You'll need the MCRYPT module... it has DES, 3DES and whatever you want...
--- End Message ---
--- Begin Message ---
On Mon, 2004-02-09 at 12:36, craig wrote:
> Hi all,
> I have to replicate the file encryption of a desktop bound
> application. This means using triple DES, but I can't find
> anything on the web or in the maunual (other than single
> DES).
The mcrypt[1] module will do triple DES as well as stronger encryption
methods. In the manual it is referred to as 3DES.
[1] http://www.php.net/mcrypt
--
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/
--- End Message ---
--- Begin Message ---
Thanks, I wasn't looking for 3DES.
That should do the trick for me.
Craig
> -----Original Message-----
> From: Adam Bregenzer [mailto:[EMAIL PROTECTED]
> Sent: February 9, 2004 10:36 AM
> To: craig
> Cc: Php
> Subject: Re: [PHP] triple DES encryption
>
>
> On Mon, 2004-02-09 at 12:36, craig wrote:
> > Hi all,
> > I have to replicate the file encryption of a desktop bound
> > application. This means using triple DES, but I can't find
> > anything on the web or in the maunual (other than single
> > DES).
>
> The mcrypt[1] module will do triple DES as well as stronger encryption
> methods. In the manual it is referred to as 3DES.
>
> [1] http://www.php.net/mcrypt
>
> --
> Adam Bregenzer
> [EMAIL PROTECTED]
> http://adam.bregenzer.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Create native xls files, there are at least two classes that can help
you, here is one:
http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/
Jake McHenry wrote:
Hi everyone. Since my last post of outputing to excel, I have converted my output to XML, quite happy with myself. It looks perfect. Perfect on my set that is. I have win xp with office xp. Excel with office xp recognizes XML. Office 2000, which the rest of my company is using, doesn't. Does anyone know of a way I can take the XML I have now and have office 2000 recognize it? I feel kinda stupid... lol Sent out an email to my accounting department saying it was ready for them and all they get is garbage on their screen.
Anyone know of anything I can do?
Thanks,
Jake
--- End Message ---
--- Begin Message ---
----- Original Message -----
From: "Marek Kilimajer" <[EMAIL PROTECTED]>
To: "Jake McHenry" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, February 09, 2004 12:42 PM
Subject: Re: [PHP] XML and Excel
> Create native xls files, there are at least two classes that can help
> you, here is one:
> http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/
>
> Jake McHenry wrote:
> > Hi everyone. Since my last post of outputing to excel, I have converted
my output to XML, quite happy with myself. It looks perfect. Perfect on my
set that is. I have win xp with office xp. Excel with office xp recognizes
XML. Office 2000, which the rest of my company is using, doesn't. Does
anyone know of a way I can take the XML I have now and have office 2000
recognize it? I feel kinda stupid... lol Sent out an email to my accounting
department saying it was ready for them and all they get is garbage on their
screen.
> >
> > Anyone know of anything I can do?
> >
> > Thanks,
> > Jake
>
sweet.. thanks a lot.. took me about 3 hours, but I got it all converted.
works great!
Thanks again,
Jake
--- End Message ---
--- Begin Message ---
A recent thread on the WebDesign-L raised the question of whether search
engines can detect (and penalize sites for) PHP redirects of the form:
header("Location: http://www.whatever.com/");
I don't see how that could be the case, since the redirect occurs on the
server before any HTML is output to the browser. Someone else says:
> No, the header() redirect immediately tells the /client/ to make a second
> GET request at a different location and the client (search bot) must
> actively make that 2nd request to the "Location:" URL (what happens if you
> request amazon.com) Note this is different from simply sniffing the UA
> string from a single request and serving altered content.
What say you, PHP list? Would it be better (in terms of search engine
detection) to use include() to serve different or altered content?
TIA
--
Lowell Allen
--- End Message ---
--- Begin Message ---
From: "Lowell Allen" <[EMAIL PROTECTED]>
> A recent thread on the WebDesign-L raised the question of whether search
> engines can detect (and penalize sites for) PHP redirects of the form:
>
> header("Location: http://www.whatever.com/");
>
> I don't see how that could be the case, since the redirect occurs on the
> server before any HTML is output to the browser. Someone else says:
No, that's not the case. What you quoted below is correct.
> > No, the header() redirect immediately tells the /client/ to make a
second
> > GET request at a different location and the client (search bot) must
> > actively make that 2nd request to the "Location:" URL (what happens if
you
> > request amazon.com) Note this is different from simply sniffing the UA
> > string from a single request and serving altered content.
>
> What say you, PHP list? Would it be better (in terms of search engine
> detection) to use include() to serve different or altered content?
As for whether a redirect is penalized or not, I doubt it. It'd be in the
best interest of the search engine to follow the link just like it's going
to follow any link on a page and index the content. Now, whether the indexed
content will show up at domain.com in the search engine or
domain.com/redirected/url/page.php, I don't know.
---John Holmes...
--- End Message ---
--- Begin Message ---
On Mon, Feb 09, 2004 at 02:31:16PM -0500, Lowell Allen wrote:
> A recent thread on the WebDesign-L raised the question of whether search
> engines can detect (and penalize sites for) PHP redirects of the form:
>
> header("Location: http://www.whatever.com/");
>
> I don't see how that could be the case, since the redirect occurs on the
> server before any HTML is output to the browser. Someone else says:
>
> > No, the header() redirect immediately tells the /client/ to make a second
> > GET request at a different location and the client (search bot) must
> > actively make that 2nd request to the "Location:" URL (what happens if you
> > request amazon.com) Note this is different from simply sniffing the UA
> > string from a single request and serving altered content.
This is accurate (the explanation from webdesign-l). Try it yourself:
===
$> telnet www.yourserver.com 80
Trying 123.456.789.000...
Connected to www.yourserver.com.
Escape character is '^]'.
GET /path/to/redir.php http/1.0
host: www.yourserver.com
HTTP/1.1 302 Found
Date: Mon, 09 Feb 2004 19:49:35 GMT
Server: GoGoGadgetWebserver/0.3
Location: http://www.example.com/
Connection: close
Content-Type: text/html
Connection closed by foreign host.
===
Assuming redir.php contains a header() call that sends "Location:", the
bot will see something like that. It's up to them to parse that,
determine the status code (302, in this case), and decide what to do
with it. Browsers just do this transparently.
> What say you, PHP list? Would it be better (in terms of search engine
> detection) to use include() to serve different or altered content?
Do neither. Create excellent content, structured well, and the search
engines will reward you for this. Try to trick them, and they will
likely figure it out and penalize you.
However, if you're asking whether or not Google can determine if you're
using include() to serve up different content based on the UserAgent or
perhaps the IP address, then no, bots can't figure that out. Unless
they switch useragents/IPs and compare the results that they get. Or
unless a human complains that the listing is innacurate. etc...
--
[ joel boonstra | gospelcom.net ]
--- End Message ---
--- Begin Message ---
On Mon, Feb 09, 2004 at 02:48:07PM -0500, John W. Holmes wrote:
<snip>
> As for whether a redirect is penalized or not, I doubt it. It'd be in the
> best interest of the search engine to follow the link just like it's going
> to follow any link on a page and index the content. Now, whether the indexed
> content will show up at domain.com in the search engine or
> domain.com/redirected/url/page.php, I don't know.
In my experience, it depends on the status code sent with the redirect.
If it's a 302, then the original URL is indexed. If it's a 301 (Moved
Permanently), then the redirected URL is indexed.
I have nothing to back this up other than trying it out with some sites,
and watching the results (with Google) over a few months, but it makes
sense to me.
joel
--
[ joel boonstra | gospelcom.net ]
--- End Message ---
--- Begin Message ---
> On Mon, Feb 09, 2004 at 02:31:16PM -0500, Lowell Allen wrote:
>> A recent thread on the WebDesign-L raised the question of whether search
>> engines can detect (and penalize sites for) PHP redirects of the form:
>>
>> header("Location: http://www.whatever.com/");
>>
>> I don't see how that could be the case, since the redirect occurs on the
>> server before any HTML is output to the browser. Someone else says:
>>
>>> No, the header() redirect immediately tells the /client/ to make a second
>>> GET request at a different location and the client (search bot) must
>>> actively make that 2nd request to the "Location:" URL (what happens if you
>>> request amazon.com) Note this is different from simply sniffing the UA
>>> string from a single request and serving altered content.
>
> This is accurate (the explanation from webdesign-l). Try it yourself:
>
[snip]
>
>> What say you, PHP list? Would it be better (in terms of search engine
>> detection) to use include() to serve different or altered content?
>
> Do neither. Create excellent content, structured well, and the search
> engines will reward you for this. Try to trick them, and they will
> likely figure it out and penalize you.
I'm not interested in tricking search bots. However, for the sake of
user-friendly URLs, I use mod_rewrite to send most requests to index.php,
then based on the request string I include() different content. I wanted to
verify that wasn't creating a problem with search engines.
> However, if you're asking whether or not Google can determine if you're
> using include() to serve up different content based on the UserAgent or
> perhaps the IP address, then no, bots can't figure that out. Unless
> they switch useragents/IPs and compare the results that they get. Or
> unless a human complains that the listing is innacurate. etc...
Thanks Joel and thanks John for confirming the WebDesign-L explanation.
--
Lowell Allen
--- End Message ---
--- Begin Message ---
On Mon, 2004-02-09 at 14:31, Lowell Allen wrote:
> A recent thread on the WebDesign-L raised the question of whether search
> engines can detect (and penalize sites for) PHP redirects of the form:
>
> header("Location: http://www.whatever.com/");
>
> I don't see how that could be the case, since the redirect occurs on the
> server before any HTML is output to the browser. Someone else says:
Technically the header function sends an HTTP reply to the client
(browser) with your Location header in the response. The client then
initiates a second HTTP request with the new URL. I remember reading
that apache[1] will look at Location: headers and if it can handle the
request it will process it and pass the output of the Location's URL to
the browser. Regardless, the content will be cached by search engines
but the original URL used to initiate the process will be associated
with the content. To have the redirected URL remembered you need to
pass a 301 Permanent Redirect status instead.
[1] I can not find this anywhere after a short search on Google, it
could be incorrect.
--
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/
--- End Message ---
--- Begin Message ---
Given a set of session id's, is it possible to query whether a given session
exists. I am not talking about the current user session, instead I am
referring to any and all possible user sessions currently in play. For
example:
if (session_exists($sessionId)) doSomething();
I've been looking very hard for this one and haven't found an answer at all.
Any ideas?
--- End Message ---
--- Begin Message ---
I don't know of a function, but you could possibly read the directory where
the SID files are stored. I use sessions a lot; however, I've not tried to
accomplish this. I don't know if by default you can read the SID directory
from a script or if this is blocked for security reasons or not. If not,
you could read the directory, match the SIDs from your list and go from
there. There is no way of knowing if the person is still actively using the
SID this way though.
Larry.
-----Original Message-----
From: Christian Calloway [mailto:[EMAIL PROTECTED]
Sent: Monday, February 09, 2004 9:28 AM
To: [EMAIL PROTECTED]
Subject: [PHP] check if user session exists
Given a set of session id's, is it possible to query whether a given session
exists. I am not talking about the current user session, instead I am
referring to any and all possible user sessions currently in play. For
example:
if (session_exists($sessionId)) doSomething();
I've been looking very hard for this one and haven't found an answer at all.
Any ideas?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Yeah thats pretty much what I have concluded. I was absolutely sure there
would be a way to check if a session was still active, but I guess not :-(.
Thanks though
Christian
"Larry Brown" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I don't know of a function, but you could possibly read the directory
where
> the SID files are stored. I use sessions a lot; however, I've not tried
to
> accomplish this. I don't know if by default you can read the SID
directory
> from a script or if this is blocked for security reasons or not. If not,
> you could read the directory, match the SIDs from your list and go from
> there. There is no way of knowing if the person is still actively using
the
> SID this way though.
>
> Larry.
>
> -----Original Message-----
> From: Christian Calloway [mailto:[EMAIL PROTECTED]
> Sent: Monday, February 09, 2004 9:28 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] check if user session exists
>
>
> Given a set of session id's, is it possible to query whether a given
session
> exists. I am not talking about the current user session, instead I am
> referring to any and all possible user sessions currently in play. For
> example:
>
> if (session_exists($sessionId)) doSomething();
>
> I've been looking very hard for this one and haven't found an answer at
all.
> Any ideas?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
"Christian Calloway" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Yeah thats pretty much what I have concluded. I was absolutely sure there
> would be a way to check if a session was still active, but I guess not
:-(.
> Thanks though
It depends on your definition of 'active.' If you wanted to see if the
specific session you are looking at has been used in the past half hour,
that is possible. Following is a script I've used to help debug sessions
sometimes. While it's not what you're asking for, it may help you figure
out how to do it. It may need tweaking to run on your server.
<? // sessioninfo.php
$path = ini_get('session.save_path');
if (isset($_GET['empty']))
{
if (isset($_COOKIE['PHPSESSID']))
setcookie('PHPSESSID', '');
header('Location: sessioninfo.php');
}
if (count($_GET) == 0)
{
echo "<br>Path: $path<br>";
$dir = dir($path);
while ($file = $dir->read())
{
$file_arr[$file]['time'] = filectime($path . '/' . $file);
$file_arr[$file]['size'] = filesize($path . '/' . $file);
}
$dir->close();
asort($file_arr);
echo '<table
border=1><tr><th>Time</th><th>Size</th><th>SessionID</th></tr>';
foreach($file_arr as $fname => $data)
{
if ($fname == '.' || $fname == '..')
continue;
$ftime = date('Y-m-d G:i', $data['time']);
$sessid = substr($fname, 5);
echo "<tr><td>$ftime</td><td>{$data['size']}</td><td><a
href=\"?sessionid=$sessid\">$fname</a></td></tr>";
}
echo '</table>';
} else if (isset($_GET['sessionid'])) {
setcookie('PHPSESSID', $_GET['sessionid']);
header('Location: sessioninfo.php?show=true');
exit();
} else {
session_start();
echo '<pre>';
print_r($_SESSION);
print_r($_GET);
echo '</pre>';
}
?>
>
> Christian
>
> "Larry Brown" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > I don't know of a function, but you could possibly read the directory
> where
> > the SID files are stored. I use sessions a lot; however, I've not tried
> to
> > accomplish this. I don't know if by default you can read the SID
> directory
> > from a script or if this is blocked for security reasons or not. If
not,
> > you could read the directory, match the SIDs from your list and go from
> > there. There is no way of knowing if the person is still actively using
> the
> > SID this way though.
> >
> > Larry.
> >
> > -----Original Message-----
> > From: Christian Calloway [mailto:[EMAIL PROTECTED]
> > Sent: Monday, February 09, 2004 9:28 AM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] check if user session exists
> >
> >
> > Given a set of session id's, is it possible to query whether a given
> session
> > exists. I am not talking about the current user session, instead I am
> > referring to any and all possible user sessions currently in play. For
> > example:
> >
> > if (session_exists($sessionId)) doSomething();
> >
> > I've been looking very hard for this one and haven't found an answer at
> all.
> > Any ideas?
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Yeah, my solution so far has been to check the last modified time of the
session file and then go from there. If the modified time is > then time
permitted, then that file is removed and the user's session is rendered null
and void. What I am doing is allowing a variable X number of user's to
simultaneously log-in under the same user/pass combo (account), and the
problem I face is, if none of the user's logs-out, then how will I determine
when to pop an inactive account off the stack. Good times.. thanks guys
Christian
"Rob Adams" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "Christian Calloway" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Yeah thats pretty much what I have concluded. I was absolutely sure
there
> > would be a way to check if a session was still active, but I guess not
> :-(.
> > Thanks though
>
> It depends on your definition of 'active.' If you wanted to see if the
> specific session you are looking at has been used in the past half hour,
> that is possible. Following is a script I've used to help debug sessions
> sometimes. While it's not what you're asking for, it may help you figure
> out how to do it. It may need tweaking to run on your server.
>
> <? // sessioninfo.php
> $path = ini_get('session.save_path');
> if (isset($_GET['empty']))
> {
> if (isset($_COOKIE['PHPSESSID']))
> setcookie('PHPSESSID', '');
> header('Location: sessioninfo.php');
> }
> if (count($_GET) == 0)
> {
> echo "<br>Path: $path<br>";
> $dir = dir($path);
> while ($file = $dir->read())
> {
> $file_arr[$file]['time'] = filectime($path . '/' . $file);
> $file_arr[$file]['size'] = filesize($path . '/' . $file);
> }
> $dir->close();
> asort($file_arr);
> echo '<table
> border=1><tr><th>Time</th><th>Size</th><th>SessionID</th></tr>';
> foreach($file_arr as $fname => $data)
> {
> if ($fname == '.' || $fname == '..')
> continue;
> $ftime = date('Y-m-d G:i', $data['time']);
> $sessid = substr($fname, 5);
> echo "<tr><td>$ftime</td><td>{$data['size']}</td><td><a
> href=\"?sessionid=$sessid\">$fname</a></td></tr>";
> }
> echo '</table>';
> } else if (isset($_GET['sessionid'])) {
> setcookie('PHPSESSID', $_GET['sessionid']);
> header('Location: sessioninfo.php?show=true');
> exit();
> } else {
> session_start();
> echo '<pre>';
> print_r($_SESSION);
> print_r($_GET);
> echo '</pre>';
> }
> ?>
>
>
>
> >
> > Christian
> >
> > "Larry Brown" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> > > I don't know of a function, but you could possibly read the directory
> > where
> > > the SID files are stored. I use sessions a lot; however, I've not
tried
> > to
> > > accomplish this. I don't know if by default you can read the SID
> > directory
> > > from a script or if this is blocked for security reasons or not. If
> not,
> > > you could read the directory, match the SIDs from your list and go
from
> > > there. There is no way of knowing if the person is still actively
using
> > the
> > > SID this way though.
> > >
> > > Larry.
> > >
> > > -----Original Message-----
> > > From: Christian Calloway [mailto:[EMAIL PROTECTED]
> > > Sent: Monday, February 09, 2004 9:28 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP] check if user session exists
> > >
> > >
> > > Given a set of session id's, is it possible to query whether a given
> > session
> > > exists. I am not talking about the current user session, instead I am
> > > referring to any and all possible user sessions currently in play. For
> > > example:
> > >
> > > if (session_exists($sessionId)) doSomething();
> > >
> > > I've been looking very hard for this one and haven't found an answer
at
> > all.
> > > Any ideas?
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
From: "Marco A. Ortiz" <[EMAIL PROTECTED]>
> I want to ask you, how I must setup my PHP.INI file, to send e-mail from
my
> Web Site if my SMTP server requires authentication. Otherwise, I want to
> know if exits some kind of "public" SMTP sever that I could use.
If your SMTP server requires authentication, then you'll have to make use of
a PHP class that handles this for you. I'm sure Manuel will post a specific
link ;) but try searching the phpclasses.org site in the mean time. I know
there are several there that implement this.
The basic mail() function that uses the php.ini configuration settings
cannot do authentication.
Also, what's this got to do with databases??? (you posted to the php-db@
list!) This should be on php-general@
---John Holmes...
--- End Message ---
--- Begin Message ---
Hi,
I'm having trouble with the code below. Basically, I'm trying to set up
$message to inherit one of two forms depending on if there is a $_GET
request. The script works IF there is a $_GET request. It fails if there
isn't (i.e. parse error).
Is there a way to get $message to refer to include multiple references like
below? Thank you!
-m
<?
if ($_GET['id']){
$query = "select * from bc_help where help_id = '" . $_GET['id'] . "' ";
$message = & $body;
}
else {
$query = "select * from bc_help";
$message = "<ol>" . & $links . "</ol>" . & $body; // This is where the
trouble is.
}
$results = db_query($query);
while ($row = db_fetch_array($results)){
$links .= "<li><a class=internal href=#" . $row['help_id'] . ">" .
$row['help_topic'] . "</a></li>\n";
$body .= "<a name=" . $row['help_id'] . "><b>" . $row['help_topic'] .
"</b><br><br>" . $row['help_text'] . "</a><br><br><br>";
}
echo $message;
?>
--- End Message ---
--- Begin Message ---
I am trying to force a file download using headers. The problem is not
forcing the download. That is working fine, but if the user wants to click
on another download while the first one is still downloading it won't let
the user do it.
Here is the code that I'm using, adapted from phpbuilder.com:
<?php
$pathtofile = '\abs\path\to\file\'.urldecode( $_GET['link'] );
$download = 'http://www.somewhere.com'.urldecode( $_GET['link'] );
$type = urldecode( $_GET['type'] );
$size = filesize( $pathtofile );
header("Pragma: private");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
// browser must download file from server instead of cache
// force download dialog
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Type: $type");
// use the Content-Disposition header to supply a recommended filename
and
// force the browser to display the save dialog.
header("Content-Disposition: attachment;
filename=".basename($download).";");
/*
The Content-transfer-encoding header should be binary, since the file
will be read
directly from the disk and the raw bytes passed to the downloading
computer.
The Content-length header is useful to set for downloads. The browser
will be able to
show a progress meter as a file downloads. The content-lenght can be
determines by
filesize function returns the size of a file.
*/
header("Content-Transfer-Encoding: binary");
header("Accept-Ranges: bytes");
header("Content-Length: $size");
$fh = fopen( $pathtofile , "rb");
fpassthru($fh);
fclose($fh);
?>
[after this the html content is displayed]
Does anybody have any idea to allow for multiple downloads while another one
was going on. Maybe some additional headers? I have tried adding headers
before and after where I open the file for HTTP/1.1 200 OK and the
corresponding headers. I have also tried using a simple meta refresh, but
that doesn't work because it won't refresh until the page is entirely
loaded.
I am at a loss, I can't seem to find answer when I google it either. Maybe
I'm just missing something. I don't know.
Josh
--- End Message ---
--- Begin Message ---
Hi,
I've been playing around quite some while with the new exceptions in PHP5 and must say that this new feature by it self is .. well, exceptional.
However .. since internal PHP function do not make use of them, it's pretty hard to produce "exception proof" software. Because earlier or later, some internal functions will always throw an PHP warnung or error. I'm talking about run-time errors here; not fatal errors. Which brings me into the dilemma that when I wisely use exceptions to catch bad runtime behaviour, I still may get out of luck because internal functions are not aware of this. In such cases either the error won't cought or will only be caught in a later stage due the domino effect.
Simple example: take mysql_query(). If it fails in a miserable way (due to malformed SQL statement, database changes, whatever), it still only produces a warning and will return false; it's not useable from the POV of exceptions.
So, to have this area covered, I started to *duplicate* internal functions in its own namespace (static class) which , in case of errors, will throw an exception, and not only a warning (the warning is still OK, it should go to a dedicated log file anyway and not the output stream).
In practive this looks like this:
class System {
static function mysql_query() {
$arguments = func_get_args();
if (false === ($retval = call_user_func_array('mysql_query',
$arguments))) {
if (strlen($mysql_error = mysql_error()) > 0) {
$mysql_error = "; mysql_error = " . $mysql_error;
}
throw new Exception("Unable to execute MySQL
query$mysql_error");
}
return $retval;
}
}
But doing this now for every internal function call I don't want to lead my program into an unwanted state isn't very appealing.
I've had given hints not to use PHP as programming language if I want to have such a degree of "safety". Not possible for me, I'm pretty mature in PHP and can't afford learning another language just because of this issue.
I'm seeking for a "more perfect" programming model for application demanding that uncontrolled factors are limited to the max.
Has anyone played around with PHP5 and thought about such issues?
cheers,
- Markus
--- End Message ---
--- Begin Message ---
On Mon, 2004-02-09 at 15:58, Markus Fischer wrote:
> But doing this now for every internal function call I don't want to
> lead my program into an unwanted state isn't very appealing.
<snip>
> I'm seeking for a "more perfect" programming model for application
> demanding that uncontrolled factors are limited to the max.
>
> Has anyone played around with PHP5 and thought about such issues?
I have been thinking about this myself. When exceptions come they will
be interesting. I almost went down the path you are considering but
decided that I would likely end up with an object hierarchy of the
system calls available in PHP. This is something I very much did not
want to deal with. I also played with creating wrapper functions that
are designed to test for a specific indication of failure (returns
false, returns null, etc.). The problem there is the error reporting
must become more technical ("ERROR: function mysql_query returned
NULL"), or more useless ("a function returned an error"). Plus, code
that uses this is harder to read. Ultimately I decided to wrap my
necessary function calls in error checking wherever they are in my
files. This gives me more granularity in the application of the error
at the cost of some code bloat. It's not an optimal solution but I have
found I use little functions calls in the first place that would
generate an exception in return (memory errors are handled by PHP so
it's only functions that have system calls). This has actually forced
me into creating libraries for what I use and abstracting out system
interfaces anyways. Also, I have started using code generation for
handling the data side.
Ultimately I think it would be nice to have an object hierarchy of the
function calls in php. However I don't see php supporting it natively
and PEAR is still trying to sort itself out. Being a 'third party'
project it is too much for one person but would be quite useful. Maybe
when php5 becomes more popular we can all band together and standardize
this.
--
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/
--- End Message ---
--- Begin Message ---
I would appreciate any help you can give me about a problem I am having
with PHP's CURL functions.
I want to use CURL to download news from Wall Street Journal Online.
When you visit the WSJ home page, you're forwarded to an authentication
page to enter your name and password, and then forwarded back to the
home page. I want my CURL command to send the authentication cookie so
when it's forwarded to the authentication page it forwards right back
to the home page without having to enter the name and password.
I can get the following CURL command to run fine at the command prompt,
but not in PHP:
THIS WORKS
curl --cookie "WSJIE_LOGIN=blahblahblah" -L -O
"http://online.wsj.com/home/us"
THIS DOESN'T WORK
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://online.wsj.com/home/us");
curl_setopt($ch, CURLOPT_COOKIE, "WSJIE_LOGIN=blahblahblah");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch);
curl_close($ch);
I used a packet sniffer to see how this works. When I request the home
page (above) and send the WSJIE_LOGIN cookie, the home page redirects
to the authentication page. The authentication page uses the
WSJIE_LOGIN cookie to generate more cookies. Then these 5-6 cookies
are sent back to the home page and give the user access to the content.
The WSJIE_LOGIN cookie is my own personal authentication cookie; the
other cookies change from time to time. But I noticed that the PHP
CURL isn't perpetuating these other cookies when it forwards back to
the home page, like the command-line CURL does. Here are blocks from
the package capture:
CLI CURL
...
192.168.001.100.63745-206.157.193.068.00080: GET /home/us HTTP/1.1
User-Agent: curl/7.10.2 (powerpc-apple-darwin7.0) libcurl/7.10.2
OpenSSL/0.9.7b zlib/1.1.4
Cookie: WSJIE_LOGIN=abc
Host: online.wsj.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Cookie: fastlogin=xyz; wsjproducts=xyz; user_type=xyz;
REMOTE_USER=xyz; UBID=xyz
...
PHP CURL
...
192.168.001.100.63750-206.157.193.068.00080: GET /home/us HTTP/1.1
Cookie: WSJIE_LOGIN=abc
Host: online.wsj.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
...
PHP's curl doesn't forward the cookies that it is given at the previous
page, so, of course, I don't get my content. Any ideas why?
Richard Miller
--- End Message ---
--- Begin Message ---
Hello,
On 02/09/2004 05:29 PM, Richard Miller wrote:
I would appreciate any help you can give me about a problem I am having
with PHP's CURL functions.
I want to use CURL to download news from Wall Street Journal Online.
When you visit the WSJ home page, you're forwarded to an authentication
page to enter your name and password, and then forwarded back to the
home page. I want my CURL command to send the authentication cookie so
when it's forwarded to the authentication page it forwards right back to
the home page without having to enter the name and password.
When I use CURL I specify the whole request header, so I don't know what
is wrong with your code.
I only use CURL for HTTPS and fsockopen for normal HTTP requests. I
encapsulated the whole HTTP client protocol handling including cookie
support into this PHP HTTP client class, that you may want to check out:
http://www.phpclasses.org/httpclient
--
Regards,
Manuel Lemos
Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--- End Message ---
--- Begin Message ---
Hi,
I have a table where a users details are entered for the products he bought,
the only part that is repeated is the order_id,
I basically need to only get the order per person, and paginate for all the
customers
eg:
if user "tom" bought 3 items in the database it would be entered as:
order_id item_name
0000023 soap
0000023 brush
0000023 towel
So i am trying this:
$num_rows = mysql_result(mysql_query("SELECT COUNT(*),
DISTINCT(order_number) FROM ".$prefix."_purchases"),0);
(the idea being taht $num_rows will give my paginating part of the program
the total number of records
that match my search.)
which gives me the most pretty error of:
Warning: mysql_result(): supplied argument is not a valid MySQL result
resource in \www\p\admin\show_purc.php on line 9
I''m pretty sure the problem is in my SQL statement, but have had no luck
searching and reading in the mysql manual for
"count" with "distinct" but am pretty sure it can be done as i have not
found anything saying the opposite...any ideas?
Thanks,
-Ryan
--- End Message ---
--- Begin Message ---
Try this:
"SELECT COUNT(*), order_number FROM " . $prefix . "_purchases GROUP BY
order_number"
as your query.
Shaunak
----- Original Message -----
From: "Ryan A" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 09, 2004 8:36 PM
Subject: [PHP] php with mysql COUNT, DISTINCT syntax, might be a bit 0T
> Hi,
> I have a table where a users details are entered for the products he
bought,
> the only part that is repeated is the order_id,
> I basically need to only get the order per person, and paginate for all
the
> customers
>
> eg:
> if user "tom" bought 3 items in the database it would be entered as:
> order_id item_name
> 0000023 soap
> 0000023 brush
> 0000023 towel
>
> So i am trying this:
> $num_rows = mysql_result(mysql_query("SELECT COUNT(*),
> DISTINCT(order_number) FROM ".$prefix."_purchases"),0);
>
> (the idea being taht $num_rows will give my paginating part of the program
> the total number of records
> that match my search.)
>
>
> which gives me the most pretty error of:
> Warning: mysql_result(): supplied argument is not a valid MySQL result
> resource in \www\p\admin\show_purc.php on line 9
>
> I''m pretty sure the problem is in my SQL statement, but have had no luck
> searching and reading in the mysql manual for
> "count" with "distinct" but am pretty sure it can be done as i have not
> found anything saying the opposite...any ideas?
>
> Thanks,
> -Ryan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
Hey,
Thanks for replying.
Nope, that didnt work, but i modified my search terms on google and kept on
trying with different search terms and got the solution here:
http://dbforums.com/arch/230/2002/11/623223
Cheers,
-Ryan
On 2/10/2004 3:14:21 AM, Shaunak Kashyap ([EMAIL PROTECTED])
wrote:
> Try this:
>
> "SELECT COUNT(*), order_number FROM " . $prefix .
> "_purchases GROUP BY
> order_number"
>
> as your query.
>
> Shaunak
>
> ----- Original Message -----
> From: "Ryan A" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, February 09, 2004 8:36 PM
> Subject: [PHP] php with mysql COUNT, DISTINCT syntax, might be a bit 0T
>
>
> > Hi,
> > I have a table where a users details are entered for the products he
> bought,
> > the only part that is repeated is the order_id,
> > I basically need to only get the order per person, and paginate for all
> the
> > customers
> >
> > eg:
> > if user "tom" bought 3 items in the database it would be entered as:
> > order_id item_name
> > 0000023 soap
> > 0000023 brush
> > 0000023 towel
> >
> > So i am trying this:
> > $num_rows =
> mysql_result(mysql_query("SELECT COUNT(*),
> > DISTINCT(order_number) FROM ".
> $prefix."_purchases"),0);
> >
> > (the idea being taht $num_rows will give my paginating part of the
> program
> > the total number of
--- End Message ---
--- Begin Message ---
Hi,
Sorry for the slightly off-topic post, but I've just had a client ask me to
create a manual for the site management tool I wrote for them last
fall. Since I've never had to do one before I'm a bit lost on what would
be a reasonable amount to charge and whether or not I should put any
restrictions on how many copies they receive or if I'm ok with them
photocopying and handing them out all over the organization.
Any thoughts on what a going rate for a manual is? The site management
tool does what most content management scripts do - lets the client
add/edit/remove any and all text on their site, upload pictures, upload and
re-size pics for a photo gallery ... nothing ground breaking - standard
PHP/MySQL stuff, though last time I tried to put a manual together it
quickly got to be over 40 pages and that client decided they didn't want it
in the end.
Thanks
-Tim
--- End Message ---
--- Begin Message ---
Hi there
I have 2 scripts:
////////////////////////////////
<?php
/*
test1.php
*/
function called_from_file(){
print __FILE__
}
?>
///////////////////////////////
<?php
/*
test2.php
*/
include("test1.php");
called_from_file();
?>
/////////////////////////////////
I get the output
test1.php
what I need is to detect the name of the script
from which I called the function, (test2.php) in this
case.
For this application, it is not practical to pass an
aditional parameter to the function specifying the
caller, i need independence.
Any ideas?
__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html
--- End Message ---
--- Begin Message ---
On Mon, 2004-02-09 at 23:17, Samuel Ventura wrote:
> what I need is to detect the name of the script
> from which I called the function, (test2.php) in this
> case.
>
> For this application, it is not practical to pass an
> aditional parameter to the function specifying the
> caller, i need independence.
>
> Any ideas?
I don't think this is possible in php4. The __FILE__ variable is a
constant that is always replaced with a string containing the name of
the file it is in. Check out reflection[1] in php5 for an answer from
the future.
[1]
http://sitten-polizei.de/php/reflection_api/docs/language.reflection.html
--
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/
--- End Message ---
--- Begin Message ---
function called_from_file(){
$backtrace = debug_backtrace();
print $backtrace[0]['file'];
}
check: http://www.php.net/manual/en/function.debug-backtrace.php
Samuel Ventura wrote:
Hi there
I have 2 scripts:
////////////////////////////////
<?php
/*
test1.php
*/
function called_from_file(){
print __FILE__
}
?>
///////////////////////////////
<?php
/*
test2.php
*/
include("test1.php");
called_from_file();
?>
/////////////////////////////////
I get the output
test1.php
what I need is to detect the name of the script
from which I called the function, (test2.php) in this
case.
For this application, it is not practical to pass an
aditional parameter to the function specifying the
caller, i need independence.
Any ideas?
__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html
--- End Message ---