php-general Digest 2 Apr 2005 08:53:43 -0000 Issue 3373
Topics (messages 212048 through 212075):
Re: hotlinking images
212048 by: Jochem Maas
SSL & XML File Download Problem
212049 by: Shaun
212051 by: Chris W. Parker
Re: IE problem downloading files
212050 by: kjohnson.zootweb.com
Accessing env variables
212052 by: Ravi Natarajan
212054 by: Philip Hallstrom
Re: PHP 5 Status
212053 by: Matthew Fonda
212057 by: Jordi Canals
Easy way to grab a value out of XML?
212055 by: Brian Dunning
212056 by: Franklin van de Meent
212058 by: emre.vt.com.tr
212066 by: Rasmus Lerdorf
can I limit DB access
212059 by: Dave Reinhardt
212061 by: emre.vt.com.tr
212062 by: Mart�n Marqu�s
Re: php pages
212060 by: bruce
212064 by: Alan Milnes
pass variable from vbscript to php
212063 by: Ashley
212065 by: Chris W. Parker
Recommendation for a MySql wrapper class
212067 by: Ryan A
212074 by: Dan Rossi
Retrieve URL of website
212068 by: HarryG
212069 by: Zareef Ahmed
212070 by: Leif Gregory
212073 by: HarryG
Connection to Two databases simultaneously
212071 by: HarryG
212075 by: Jochem Maas
Re: getting filenames from dir
212072 by: Mario St-Gelais
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 ---
Sebastian wrote:
i have an issue with site linking directly to my images.
the problem is these images are generated on the fly with php/gd -- they're
generated each time its viewed because i have done some watermarking
manipulation and didnt want to watermaker them in a static way. they're
including the images like this:
<img src=http://mydomain.com/script.php?pic=232">
not only is bandwidth usage increase but so does cpu because php/gd has to
process them as well.. if they're including 5 or 6 of these images on a
single page i can imagin how much cpu is being used.
how can i work around this, if at all possible?
you already got 2 answers covering the issues of direct linking to your
images,
I would just like to add that you should also consider caching, you could
roll your own by saving the manipulated images on disk and checking to see
whether
a cached image already exists before processing (and if it does just output
that instead)
... on the other end of the scale you could try Squid (which can also act as a
reverse-proxy)
rgds,
Jochem
--- End Message ---
--- Begin Message ---
Hi,
I have a site that allows users to download xml files. I have the following
php script which prints the results of the query to the browser. As the
header is chaged to XML it forces the browser to ask the user if they want
to download the file rather than outputting the results straight to the
browser:
<?php
header('Content-type: text/xml');
header('Content-Disposition: attachment; filename="test.xml"');
// doquery
$xml = "<?xml version=\"1.0\" ?>\r\n";
// add query results to $xml
echo $xml;
?>
This was working fine until i added an SSL certificate to my site, now I get
the following error message:
Internet Explorer cannot download ..._download.php?id=4723 from www... .com
Internet Explorer was not able to open this Internet site. The requested
site is either unavailable or cannot be found...
Any ideas?
--- End Message ---
--- Begin Message ---
Shaun <mailto:[EMAIL PROTECTED]>
on Friday, April 01, 2005 11:20 AM said:
> This was working fine until i added an SSL certificate to my site,
> now I get the following error message:
>
> Internet Explorer cannot download ..._download.php?id=4723 from
> www... .com
>
> Internet Explorer was not able to open this Internet site. The
> requested site is either unavailable or cannot be found...
>
> Any ideas?
IIRC you've got friendly error messages turned on. Turn it off to see
what's really happening.
Chris.
--- End Message ---
--- Begin Message ---
"Luis Lebron" <[EMAIL PROTECTED]> wrote on 04/01/2005 09:42:32 AM:
>
> I have just changed the server that was being used our public website.
> In the process the php scripts used to download files stopped working
> with IE. The new box is running Debian Testing. The php version is
> listed as PHP Version 4.3.10-9. Apache 1.0.33. The download script looks
> like this:
>
>
> if(file_exists($path))
> {
> $filesize = filesize($path);
> Header("Content-Length: $filesize");
> Header("Content-type: application/download");
> Header("Content-Disposition-type: attachment");
> Header("Content-Disposition: filename=$filename");
> Header("Content-Transfer-Encoding: binary");
> $fp = fopen("$path","rb");
> $result = fpassthru($fp);
> unlink($path);
> exit;
> }
> else
> {
> print "Could not create backup file";
> }
I am not exactly sure what the goal is here, so I don't have an exact
solution. However, below are some links and code that helped us solve an
"IE and pdf download" problem.
Good luck!
Kirk
Straight from somewhere in the horse's anatomy:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q293792
In short - ie will send 2-3 requests to the server per document, most
servers/code are not prepared for what ie is sending.
Some general info and a way to trick IE:
http://us2.php.net/manual/en/function.session-cache-limiter.php
http://pgsql.designmagick.com/include/fpdf/FAQ.htm#5
Some working code to download a pdf and open it in an acrobat window:
<?
session_cache_limiter('none');
session_start();
// generate the file. . .
// now send it
header('Content-Length: ' . strlen($pdfFileData));
header('Content-Disposition: inline; filename="' . $pdfFileName . '"');
header('Content-Type: application/pdf');
echo $pdfFileData;
?>
--- End Message ---
--- Begin Message ---
Hi,
I have defined couple of environment variables in one of my apache
module using setenv() at fixups and handler function calls.
I have another php module, where I need to access these variables. So I
have defined these variables as "global $var1, $var2 ..etc";
When I try to access these variables as $var1 and $var2 , they don't
seem to be set, so I am not getting correct values, but they give
correct values when I acess them using getenv() call.
I thought that the global command would make the global environment
variables available in the local php code.
How to access these environment variables in my php code without using
getenv() call.
Thanks
Ravi Natarajan
--- End Message ---
--- Begin Message ---
On Fri, 1 Apr 2005, Ravi Natarajan wrote:
I have defined couple of environment variables in one of my apache
module using setenv() at fixups and handler function calls.
I have another php module, where I need to access these variables. So I
have defined these variables as "global $var1, $var2 ..etc";
When I try to access these variables as $var1 and $var2 , they don't
seem to be set, so I am not getting correct values, but they give
correct values when I acess them using getenv() call.
How to access these environment variables in my php code without using
getenv() call.
Try using $_SERVER and $_ENV...
See here for more info...
http://us3.php.net/reserved.variables
-philip
--- End Message ---
--- Begin Message ---
Yes, PHP5 is ready for production environments. It is stable, and has been
stable for almost an entire year.
Is PHP 5 ready for production environments? Is it concidered stable,
or is it just a matter of going a while with no new bugs discovered to
get to stable..
Colin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On Apr 1, 2005 8:30 PM, Colin Ross <[EMAIL PROTECTED]> wrote:
> Is PHP 5 ready for production environments? Is it concidered stable,
> or is it just a matter of going a while with no new bugs discovered to
> get to stable..
Yes, it is ready. I've been using on my production servers since
version 5.0.1 without any problem. Now I'm running 5.0.3 and this
weekend will update to 5.0.4. I'm really happy with PHP-5 and
specially with all his new features. Now the majority of my scripts
require PHP-5 (And don't wok with previous versions).
Also I run PHP-5 in some hosting server for my customers, some of them
running old scripts, and everything runs really well.
I would recommend it to anybody who starts a new development do it
with PHP-5 in mind. To all those people who has PHP-4 running, I would
recommend to test PHP-5 and start deploying it.
Regards,
Jordi.
--- End Message ---
--- Begin Message ---
I've been looking at the XML commands and am feeling a bit overwhelmed.
My needs are simple and I'm hoping there's an easy solution that I'm
just missing. I have a hunk of well-formed XML in a variable, $xml, and
it contains only one instance of <price>x.xx</price>. I just want to
get the $price out of $xml. What's the simplest way?
- Brian
--- End Message ---
--- Begin Message ---
If you are using PHP5 check out SimpleXML (http://php.net/simplexml)
On Apr 1, 2005 10:53 PM, Brian Dunning <[EMAIL PROTECTED]> wrote:
> I've been looking at the XML commands and am feeling a bit overwhelmed.
> My needs are simple and I'm hoping there's an easy solution that I'm
> just missing. I have a hunk of well-formed XML in a variable, $xml, and
> it contains only one instance of <price>x.xx</price>. I just want to
> get the $price out of $xml. What's the simplest way?
>
> - Brian
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
you can handle xml output as if a string file, then easily parse xml file
with preg_match / preg_match_all,
smt like this can do the job:
<?php
$str="<xml version bla
bla><price>somevaluehere</price><price>somevaluehere2</price><price>somevaluehere2</price>etc";
preg_match_all("/<price>([^<])*<\/price>/i", $str, $matches);
echo count($matches[0]);
for ($i=0; $i< count($matches[0]); $i++) {
echo '<br> + '.$matches[0][$i];
}
?>
but you'd better learn to handle xml files via xml parsers.
----- Original Message -----
From: "Brian Dunning" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, April 01, 2005 11:53 PM
Subject: [PHP] Easy way to grab a value out of XML?
I've been looking at the XML commands and am feeling a bit overwhelmed. My
needs are simple and I'm hoping there's an easy solution that I'm just
missing. I have a hunk of well-formed XML in a variable, $xml, and it
contains only one instance of <price>x.xx</price>. I just want to get the
$price out of $xml. What's the simplest way?
- Brian
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
The XML functions really aren't that hard to use. If you just want a
simple parse to pick out something have a look at:
for PHP4: http://php.net/xml_parse_into_struct
for PHP5: http://php.net/simplexml_load_file
-Rasmus
[EMAIL PROTECTED] wrote:
you can handle xml output as if a string file, then easily parse xml
file with preg_match / preg_match_all,
smt like this can do the job:
<?php
$str="<xml version bla
bla><price>somevaluehere</price><price>somevaluehere2</price><price>somevaluehere2</price>etc";
preg_match_all("/<price>([^<])*<\/price>/i", $str, $matches);
echo count($matches[0]);
for ($i=0; $i< count($matches[0]); $i++) {
echo '<br> + '.$matches[0][$i];
}
?>
but you'd better learn to handle xml files via xml parsers.
----- Original Message ----- From: "Brian Dunning" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, April 01, 2005 11:53 PM
Subject: [PHP] Easy way to grab a value out of XML?
I've been looking at the XML commands and am feeling a bit
overwhelmed. My needs are simple and I'm hoping there's an easy
solution that I'm just missing. I have a hunk of well-formed XML in a
variable, $xml, and it contains only one instance of
<price>x.xx</price>. I just want to get the $price out of $xml. What's
the simplest way?
- Brian
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
How can I limit access to my database to one computer or one domain?
I do not want it accessable from just any place on the web.
--- End Message ---
--- Begin Message ---
mysql comes with 2 predefined databases, their names are
show databases;
1. mysql
2. test
open mysql database
> use mysql;
find the table named as 'user' , there mysql users and their access
privileges are stored.
>select Host, User, Password from user
modify Host column as you wish to limit access to your database. also you'd
better check other columns to understand how to grant priviliges to mysql
users.
btw dont forget to flush privileges after you are done with the
modification.
flush privileges;
hope this helps.
----- Original Message -----
From: "Dave Reinhardt" <[EMAIL PROTECTED]>
To: "PHP General-List" <[email protected]>
Sent: Friday, April 01, 2005 11:22 PM
Subject: [PHP] can I limit DB access
How can I limit access to my database to one computer or one domain?
I do not want it accessable from just any place on the web.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
El Vie 01 Abr 2005 17:22, Dave Reinhardt escribi�:
> How can I limit access to my database to one computer or one domain?
>
> I do not want it accessable from just any place on the web.
This is DataBase related. PHP has nothing to do with it. And anyway, you are
not saying which database you are using.
--
19:16:57 up 3:45, 3 users, load average: 0.83, 1.04, 0.89
-----------------------------------------------------------------
Mart�n Marqu�s | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica | DBA, Programador, Administrador
Universidad Nacional
del Litoral
-----------------------------------------------------------------
--- End Message ---
--- Begin Message ---
hey guys....
can someone tell me why this seems to work.. is it because a security
attribute hasn't been correctly set?
> Add this to any php page ?=PHPE9568F36-D428-11d2-A769-00AA001ACF42
> Ex. http://www.fedoraforum.org/?=PHPE9568F36-D428-11d2-A769-00AA001ACF42
thanks..
-----Original Message-----
From: jim lawrence [mailto:[EMAIL PROTECTED]
Sent: Friday, April 01, 2005 1:05 PM
To: [EMAIL PROTECTED]
Subject: Re: php pages
On Apr 1, 2005 3:59 PM, bruce <[EMAIL PROTECTED]> wrote:
> the question i have is why this does this..???
>
> i was under the impression that php/webservers shouldn't return results
for
> query vars that aren't defined...
>
> clarification...??
Found it at fedoraforums.org
>
> Add this to any php page ?=PHPE9568F36-D428-11d2-A769-00AA001ACF42
> Ex. http://www.fedoraforum.org/?=PHPE9568F36-D428-11d2-A769-00AA001ACF42
>
--
Jim Lawrence
Registered Linux User: #376813
********************************************************
When I'm feeling down, I like to whistle.
It makes the neighbor's dog run to the end of his chain and gag himself.
************************************
--- End Message ---
--- Begin Message ---
bruce wrote:
hey guys....
can someone tell me why this seems to work.. is it because a security
attribute hasn't been correctly set?
It's called an "easter egg" - check out your phpinfo on April 1st ...
http://www.phpfreaks.com/articles/229/0.php
Alan
--- End Message ---
--- Begin Message ---
I have a unique problem that may be able to be solved another way, but I
don't know how.
What I need to do is pass a variable from a vbscript into php for use.
I am using vbscript to access an activeX control on the computer that
grabs the currently logged in user. This works fine, but I cannot
determine how I can get that value into php so that I can use it.
This is for an Intranet app. Basically I want to use the currently
logged in user so that they don't have to log into the Intranet app.
I am running this on a Netware 6.5 server running Apache 2.5.
This may not be the best way to go about this, but it is the only thing
that I have been able to find so I am open to suggestions.
Thanks in advance,
Ashley
--- End Message ---
--- Begin Message ---
Ashley <mailto:[EMAIL PROTECTED]>
on Friday, April 01, 2005 2:32 PM said:
> I have a unique problem that may be able to be solved another way,
> but I don't know how.
Another way? What's the first way? :|
> What I need to do is pass a variable from a vbscript into php for use.
>
> I am using vbscript to access an activeX control on the computer that
> grabs the currently logged in user. This works fine, but I cannot
> determine how I can get that value into php so that I can use it.
[snip /]
> This may not be the best way to go about this, but it is the only
> thing that I have been able to find so I am open to suggestions.
I must be missing something. Where is the first way?
In any case, here is "another way":
You need to pass the variable through the querystring:
http://intranet/page.php?yourvariable=yourvalue
HTH,
Chris.
--- End Message ---
--- Begin Message ---
Hi,
After spending a long time reading about SQL injection on the Google,PHP.net
site and on Shifflet.org (very good article, links, feedback - and I'm
really happy that knowledgeable people like Chris take the time to help
actively on the list) I have some mixed views on how easy it is to actually
inject something into some of my sites, and I have also corrected some
mistakes which would have gone unnoticed if I didnt read the above.
Anyway, I have decided to start using a database wrapper from now on,
visiting the php classes site and searching sites/google I have found a
*LOT* of classes to do the job.
BUT, few promise to take care of any SQL injection without the programmer
first cleaning out the variables/strings,
so although this is new to me, I know there are a lot of PHP gurus on the
list and i'm sure this is not new to them....I was hopeing someone could
recommend a class they are using as I am starting a new project on monday
and dont have the time to test each class before picking one (honest guys,
there are a lot, you gotto browse them to belive it)
I dont need anything fancy just something that gets the job done....safely
and effectivly.
Note: This address accepts attachements if it has [PHP] somewhere in the
subject line so if you want, zip it up and mail it to me.
Thanks in advance,
Ryan
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.0 - Release Date: 3/31/2005
--- End Message ---
--- Begin Message ---
I have nothing to do with these but I would check out PEAR DB, MDB,MDB2
and ADODB.
On 02/04/2005, at 10:41 PM, Ryan A wrote:
--- End Message ---
--- Begin Message ---
Hi,
I want to retrieve the complete url in my php script. How can I do this?
eg. www.mysite.com/mydirectory/mypage.php
Result should either be www.mysite.com/mydirectory/mypage.php or
/mydirectory/mypage.php
Thanks in advance
HarryG
--- End Message ---
--- Begin Message ---
HI,
Look for $_SERVER['REQUEST_URI'];
<?php
print $_SERVER['REQUEST_URI'];
?>
But Dear first you should search the documentation , it is very easy
to notice if you can use phpinfo();
zareef ahmed
On Apr 2, 2005 8:12 AM, HarryG <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I want to retrieve the complete url in my php script. How can I do this?
>
> eg. www.mysite.com/mydirectory/mypage.php
>
> Result should either be www.mysite.com/mydirectory/mypage.php or
> /mydirectory/mypage.php
>
> Thanks in advance
> HarryG
>
--
Zareef Ahmed :: A PHP Developer in India ( Delhi )
Homepage :: http://www.zareef.net
--- End Message ---
--- Begin Message ---
Hello HarryG,
Friday, April 1, 2005, 7:42:25 PM, you wrote:
H> I want to retrieve the complete url in my php script. How can I do this?
H> eg. www.mysite.com/mydirectory/mypage.php
H> Result should either be www.mysite.com/mydirectory/mypage.php or
/mydirectory/mypage.php
If you mean on your own site, use $_SERVER['PHP_SELF']
Cheers,
Leif Gregory
--
TB Lists Moderator (and fellow registered end-user)
PCWize Editor / ICQ 216395 / PGP Key ID 0x7CD4926F
Web Site <http://www.PCWize.com>
--- End Message ---
--- Begin Message ---
Thanks guys.
"HarryG" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Hi,
I want to retrieve the complete url in my php script. How can I do this?
eg. www.mysite.com/mydirectory/mypage.php
Result should either be www.mysite.com/mydirectory/mypage.php or
/mydirectory/mypage.php
Thanks in advance
HarryG
--- End Message ---
--- Begin Message ---
Hi,
I am connecting to two database in my index.php.
Here is how:
@ $db = mysql_connect("localhost", USERLOGIN, USERDBPASS);
if (!$db)
{ print "Error: Could not connect to database. Please try again later.";
exit; }
mysql_select_db(DATABASE);
@ $userdb = mysql_connect("localhost", USERLOGIN, USERDBPASS);
if (!$userdb)
{ print "Error: Could not connect to database. Please try again later.";
exit; }
mysql_select_db(USERDB);
$getaccount = "SELECT * FROM account WHERE visible=1"; //Account table is
present in USERDB.
$result = mysql_query($getaccount);
$get = "SELECT * FROM useraccount"; //UserAccount table is present in DATABASE.
$result = mysql_query($get);
There is no problem with the connection. but I need to query tables in both
databases. I know you need to use link identifiers, but have had no luck in
getting it to work. Appreciate your help.
Thanks.
HarryG
--- End Message ---
--- Begin Message ---
HarryG wrote:
Hi,
I am connecting to two database in my index.php.
Here is how:
@ $db = mysql_connect("localhost", USERLOGIN, USERDBPASS);
if (!$db)
{ print "Error: Could not connect to database. Please try again later.";
exit; }
mysql_select_db(DATABASE);
@ $userdb = mysql_connect("localhost", USERLOGIN, USERDBPASS);
if (!$userdb)
{ print "Error: Could not connect to database. Please try again later.";
exit; }
mysql_select_db(USERDB);
$getaccount = "SELECT * FROM account WHERE visible=1"; //Account table is
present in USERDB.
$result = mysql_query($getaccount);
$get = "SELECT * FROM useraccount"; //UserAccount table is present in DATABASE.
$result = mysql_query($get);
There is no problem with the connection. but I need to query tables in both databases. I know you need to use link identifiers,
but have had no luck in getting it to work. Appreciate your help.
er, you are not actually using the link identifiers.... try like this:
@ $db = mysql_connect("localhost", USERLOGIN, USERDBPASS);
if (!$db) {
print "Error: Could not connect to database. Please try again later.";
exit; }
mysql_select_db(DATABASE, $db);
}
@ $userdb = mysql_connect("localhost", USERLOGIN, USERDBPASS);
if (!$userdb) {
print "Error: Could not connect to database. Please try again later.";
exit; }
mysql_select_db(USERDB, $userdb);
}
$getaccount = "SELECT * FROM account WHERE visible=1"; //Account table is
present in USERDB.
$result = mysql_query($getaccount, $userdb);
$get = "SELECT * FROM useraccount"; //UserAccount table is present in DATABASE.
$result = mysql_query($get, $db);
Thanks.
HarryG
--- End Message ---
--- Begin Message ---
That should get you started :
$dirname='/var';
$dh=opendir($dirname) or die('could not open directory');
while (!(($file=readdir($dh))===false)){
if (is_dir('$dirname/$file')){
$myarray[]=$file;
}
echo "$file<br>";
$myarray[]=$file;
}
Mario
Merlin wrote:
Hi there,
does anybody know how to get all file names from a specified directory
into an array?
Thanx,
Merlin
--- End Message ---