php-general Digest 22 Aug 2005 11:00:45 -0000 Issue 3639
Topics (messages 221053 through 221073):
Re: php explained in sql
221053 by: Jose Miguel
221061 by: John Taylor-Johnston
Re: Resizing thumbnails to the browser
221054 by: Richard Lynch
Re: support for database interaction
221055 by: Richard Lynch
Re: apache sessions
221056 by: Richard Lynch
Re: exec ping
221057 by: mikespook
Re: __sleep, __wakeup and persistent connections
221058 by: Richard Lynch
Re: preg_match
221059 by: Richard Lynch
Re: Hardware Detection
221060 by: Richard Lynch
php vulnerability
221062 by: Shafiq Rehman
221063 by: Jasper Bryant-Greene
221064 by: Torgny Bjers
221066 by: Shafiq Rehman
221067 by: Jasper Bryant-Greene
imagestring to picture
221065 by: Andras Kende
imap_open hangs...
221068 by: Michael Baas
221069 by: Burhan Khalid
221070 by: Michael Baas
Re: Looking for CMS advice
221071 by: Michael Baas
221072 by: Erik Gyepes
221073 by: Erik Gyepes
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 ---
We should use:
if (!empty($mydata->email))
in php, right?
On 8/19/05, Jasper Bryant-Greene <[EMAIL PROTECTED]> wrote:
> John Taylor-Johnston wrote:
> > In php, if I wanted to know if $mydata->email contained something, I
> > would do this, right?
> > if ($mydata->email)
> > {}
> >
> > How would I express this in SQL (MySQL)?
>
> That doesn't tell you if $mydata->email contains something. It tells you
> whether the value of $mydata->email, when cast to boolean, equals TRUE.
> If $mydata->email equaled zero or the string "0", it would still contain
> something, but that if statement would not get executed.
>
> In MySQL, it would depend on the datatype. You could do any of the
> following, depending on what you actually want to do:
>
> colname<>''
> colname<>0
> colname IS NOT NULL
>
> Or, if you're in MySQL >= 5.0.2 and are using true boolean values:
>
> colname IS TRUE
>
> or, if you just want to check if it's TRUE or UNKNOWN:
>
> colname IS NOT FALSE
>
>
> Jasper
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Jose Arce
http://sinexion.com - http://josearce.com
--- End Message ---
--- Begin Message ---
varchar:
colname<>''
Thanks,
John
Jasper Bryant-Greene wrote:
John Taylor-Johnston wrote:
In php, if I wanted to know if $mydata->email contained something, I
would do this, right?
if ($mydata->email)
{}
How would I express this in SQL (MySQL)?
That doesn't tell you if $mydata->email contains something. It tells
you whether the value of $mydata->email, when cast to boolean, equals
TRUE. If $mydata->email equaled zero or the string "0", it would still
contain something, but that if statement would not get executed.
In MySQL, it would depend on the datatype. You could do any of the
following, depending on what you actually want to do:
colname<>''
colname<>0
colname IS NOT NULL
Or, if you're in MySQL >= 5.0.2 and are using true boolean values:
colname IS TRUE
or, if you just want to check if it's TRUE or UNKNOWN:
colname IS NOT FALSE
Jasper
--- End Message ---
--- Begin Message ---
On Sun, August 21, 2005 3:04 pm, Murray @ PlanetThoughtful wrote:
> I have a series of thumbnails on my site of photos I've taken that are
> all
> 150px in width, but of variable height. I want to randomly display one
> of
> the thumbnails each time the home page of my site is loaded in a
> column that
> is 140px wide.
>
> I'm wondering if anyone can point me at some code that would achieve
> this?
> All of the thumbnails are in jpg format.
>
> So, essentially, I'm trying to resize the thumbnails down to 140px
> wide
> while maintaining the aspect ratio of the image's height.
The scaling is easy.
It's getting the damn browsers not to screw up that's hard :-)
Actually, a cheap and easy way would be to just use:
<img src="/image150.jpg" width="140">
The penalties are:
1. The browser downloads a 150x??? image which is a TINY bit larger
than 140x???, but, really, this is negligible.
2. The browser has to scale the image, and that's "slow" if it's a
really really old slow computer.
But, to do it "right" server-side.
1. Edit a .htaccess file and add this to it:
<Files thumbnail>
ForceType application/x-httpd-php
</Files>
This informs Apache that your 'thumbnail' file is REALLY a PHP file,
even without the .php on the end.
2. Put this in 'thumbnail':
<?php
//Untested...
$path = "/full/hard/drive/directory/path/to/your/images/";
$image = imagecreatefromjpeg(filename($path . $_SERVER['PATH_INFO']));
$width = imagesx($image);
$height = imagesy($image);
$new_width = 140;
$new_height = round(140 * $height/$width);
$new_image = imagecreatetruecolor($new_width, $new_height);
// resource dst_image, resource src_image, int dst_x, int dst_y, int
src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h
imagecopyresamples($new_image, $image, 0, 0, 0, 0, $new_width,
$new_height, $width, $height);
ob_start();
imagejpeg($new_image);
$data = ob_get_contents();
ob_end_clean();
header("Content-type: image/jpeg");
header("Content-length: " . strlen($data));
echo $data;
?>
Now, to use this script, make an IMG tag like:
<img src="thumbnail/original150image.jpg" width="140">
The browser will never know the image is dynamic, nor that you are
using PHP, and that's the way you want it.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Sat, August 20, 2005 11:58 pm, Fernando Garza wrote:
> I am creating a 'Shell' in prolog language that interacts with a
> 'Visual
> Prolog' database format in 'Win32', I would like to interact with this
> database with 'PHP', just like the interaction with 'MySQL' database,
> can
> you give me some notion or the code that need to be executed to get
> this
> done? for example in:
>
> 'mysql_connect'
>
> or
>
> 'mysql_create_db'
>
> what code is executed behind this functions?
The code in question can be found at:
http://cvs.php.net/
Or you can use anonymous CVS to get the bleeding-edge version of PHP
and develop a new module for Prolog.
> I think the functions to make this done should be execute a program
> with
> some function, passes values and receive values from the 'shell'
That would not be anything like the way MySQL works.
Though if you find it easier to do it that way, and can afford the
performance penalty of a shell execution on each query, go for it. It
would probably be fine for low-volume and maybe even moderate volume
sites. It would almost-for-sure fail miserably on a high-volume
server.
But if you're more interested in making it work today on your box than
making it work for everybody a year (or 2) from now, then that's maybe
the way to go.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Sat, August 20, 2005 1:41 pm, Bawt T. Eggdrop wrote:
> im trying to change my session backend for apache from files to mysql.
> is there something php provides that allows a php script to execute
> before each page gets loaded in apache. if not i have to edit hundreds
> of php files...theres gotta be an easier way. thanks.
In an ideal world, the line of code did 'session_start();' would have
been designed in your code to be in ONE file that got included by
everything else.
In that case, you would only have one (1) file to edit, in which you
would do http://php.net/session_set_save_handler (or whatever it is)
Now, assuming you've got a zillion session_start() lines scattered
through your files, you should consider doing two things.
1. Fix it the "Right Way" (tm) and move all those into a 'globals.inc'
include file that all those files <?php include 'globals.inc';?>
2. Quick hack use php.ini auto_prepend feature to force a file to be
executed at the top of every file in your site. This may be a
short-term way to keep working while #1 is the long-term project...
OTOH, a good sed script, or even just a real long vi session with :%sg
:wn can fix the session_start() problem the right way, so it's not
gonna take THAT long to do it right.
YMMV
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
The PEAR package Net_Monitor and Net_Ping is useful for you. It`s esay way
to detact the host~~
^_^
"Juan Pablo Herrera" <[EMAIL PROTECTED]>
??????:[EMAIL PROTECTED]
Hi all!
I have following script:
$comando = system('ping 168.192.0.1', $nn);
echo $nn;
Well, i need that only show the first ten lines of the ping and kill
the process.
How can i make it?
Regards,
JP
--- End Message ---
--- Begin Message ---
On Sat, August 20, 2005 6:33 am, Marcus Bointon wrote:
> I'm sorting out some code to handle session object storage,
I can't help with the OO stuff.
> given that the connection is persistent, and may thus be used by
> other scripts, is calling mysql_close a particularly bad idea? Should
> I just not bother closing the connection, letting PHP deal with it -
> the object will not attempt to re-use the stale connection because it
> will get a new instance courtesy of __wakeup when unserialized.
The persistence is all on the MySQL side -- From PHP's perspective,
it's more like a "re-usable" or a "return for deposit" connection :-)
When you "close" the persistent connection, MySQL still keeps around
the data structures to re-use it for the next script, which is what
"persistent" really means.
You don't have to close the connection -- PHP *is* going to close it
for you as the script ends.
When the same process (Apache child) asks for a connection with the
same username/password from MySQL, MySQL can re-use the existing data
structures to save the time of building them. That time is actually
rather expensive, as it involves a lot of buffers, structures, and, I
believe, a fair amount of resource-locking to be sure the current
connection will not be in a race condition with other connections for
things like mysql_insert_id() and, if you use innoDB, transactions.
So saving this time for MySQL to build a connection from scratch
instead of using the parts laying around from the last one is the
"persistent" connection.
HTH
NOTE: Be sure you have a few *more* max_connections in /etc/my.cnf
than the number of Apache MaxChildren -- Otherwise your Apache
children can lock up all the MySQL persistent connections and leave
you with Apache children starved for MySQL connection, as well as NO
WAY for you to use mysqladmin or mysqldump since *ALL* the available
connections are taken up by your Apache server. That's bad.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Sat, August 20, 2005 5:00 am, John Nichel wrote:
> Personally, I have never used \\ in PCRE when looking for things like
> spaces (\s), word boundraries (\b), etc. and it's all worked out fine.
Personally, {
I
} have
never {
used
proper
indenting
in
my
code } and
it's
all
worked
out
fine;
:-)
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Fri, August 19, 2005 9:55 pm, Saenal M wrote:
> Can we get information about hardware on client's PC. (e.g. hard disk,
> processor, keyboard, etc).? And How?
> anyone knows? please reply back.
Not only is it not possible, most of that information is NONE OF YOUR
DAMN BUSINESS!!! :-)
You can assume that if the browser is sending the headers to indicate
that I prefer French, then I probably have a keyboard that makes
French characters.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Hi all,
My server was hacked last week and the message displayed on home page was
"spy kidz owns your server". I researched on internet and found that this is
some kind of trojan which infects the *.index files. It penetrate from HTTP.
Some paople were saying that there is vulnerability in PHP. Please help how
can I protect my server from further attacks.
Best Regards
--
*** phpgurru.com <http://phpgurru.com> [A php resource provider] ***
\\\|///
\\ - - //
( @ @ ) PHP is too logical for my brain
+---oOOo-(_)-oOOo------------------------------------------+
| Mian Shafiq ur Rehman
| phpgurru.com <http://phpgurru.com> [A php resource provider]
| 107 B, New Town, Multan Road
| Lahore Pakistan
|
| Mobile: 0300 423 9385
|
| ooo0 http://www.phpgurru.com
| ( ) 0ooo E-Mail: [EMAIL PROTECTED]
+---\ (----( )------------------------------------------+
\_) ) /
(_/
--- End Message ---
--- Begin Message ---
Shafiq Rehman wrote:
My server was hacked last week and the message displayed on home page was
"spy kidz owns your server". I researched on internet and found that this is
some kind of trojan which infects the *.index files. It penetrate from HTTP.
Some paople were saying that there is vulnerability in PHP. Please help how
can I protect my server from further attacks.
You need to provide more detail. Do you mean index.* files?
Have you looked in your server logs to see if they left any tracks?
What applications are running on your server? There have been some
recent XMLRPC vulnerabilities affecting a large range of PHP
applications. IMHO the vulnerability is much more likely to be in an
application built in PHP than in PHP itself.
Do you run a firewall on your server? Which ports remain open?
Jasper
--- End Message ---
--- Begin Message ---
Shafiq Rehman wrote:
> My server was hacked last week and the message displayed on home page was
> "spy kidz owns your server". I researched on internet and found that this is
> some kind of trojan which infects the *.index files. It penetrate from HTTP.
> Some paople were saying that there is vulnerability in PHP. Please help how
> can I protect my server from further attacks.
Hello Shafiq,
One very common culprit in this scenario would be phpBB, especially
older versions, and if you are running PHP without safe_mode and
include_path directives, a script could very well overwrite every
world-writable (or web server writable) file on your entire server.
Happened to us once after a client had been running an old phpBB
version. We now have a set of scripts in place that scan our servers for
vulnerable scripts, phpBB among those, and alerts us when they're found
in a client's home directory.
So, to protect your server: turn on safe_mode. If clients (if you have
clients on the machine) request safe_mode to be turned off, you can do
that manually in httpd.conf for Apache (not sure about IIS on Windows).
Also, using hard include paths in the httpd.conf for each virtual host
will prevent the scripts running on a site from including/touching files
that are outside said paths unless they manage to run a shell with a PHP
script that can be activated without using php.ini, which might in this
case be another security hole.
Regards,
Torgny
--- End Message ---
--- Begin Message ---
Hi all,
Thanx to all of you. My server is running on Linux and there is not any
phpbb running on it. If vulnerability is in my code.. Is there any way that
I can find the buggy code on my server which allowed that trojan to write
into all the index files.
I analyzed the apache logs but did not found any thing wrong. My server is
protected with firewar and only port 80 is opened.
Thanx
--
*** phpgurru.com <http://phpgurru.com> [A php resource provider] ***
\\\|///
\\ - - //
( @ @ ) PHP is too logical for my brain
+---oOOo-(_)-oOOo------------------------------------------+
| Mian Shafiq ur Rehman
| phpgurru.com <http://phpgurru.com> [A php resource provider]
| 107 B, New Town, Multan Road
| Lahore Pakistan
|
| Mobile: 0300 423 9385
|
| ooo0 http://www.phpgurru.com
| ( ) 0ooo E-Mail: [EMAIL PROTECTED]
+---\ (----( )------------------------------------------+
\_) ) /
(_/
On 8/22/05, Torgny Bjers <[EMAIL PROTECTED]> wrote:
>
> Shafiq Rehman wrote:
> > My server was hacked last week and the message displayed on home page
> was
> > "spy kidz owns your server". I researched on internet and found that
> this is
> > some kind of trojan which infects the *.index files. It penetrate from
> HTTP.
> > Some paople were saying that there is vulnerability in PHP. Please help
> how
> > can I protect my server from further attacks.
>
> Hello Shafiq,
>
> One very common culprit in this scenario would be phpBB, especially
> older versions, and if you are running PHP without safe_mode and
> include_path directives, a script could very well overwrite every
> world-writable (or web server writable) file on your entire server.
> Happened to us once after a client had been running an old phpBB
> version. We now have a set of scripts in place that scan our servers for
> vulnerable scripts, phpBB among those, and alerts us when they're found
> in a client's home directory.
>
> So, to protect your server: turn on safe_mode. If clients (if you have
> clients on the machine) request safe_mode to be turned off, you can do
> that manually in httpd.conf for Apache (not sure about IIS on Windows).
> Also, using hard include paths in the httpd.conf for each virtual host
> will prevent the scripts running on a site from including/touching files
> that are outside said paths unless they manage to run a shell with a PHP
> script that can be activated without using php.ini, which might in this
> case be another security hole.
>
> Regards,
> Torgny
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Shafiq Rehman wrote:
Thanx to all of you. My server is running on Linux and there is not any
phpbb running on it. If vulnerability is in my code.. Is there any way that
I can find the buggy code on my server which allowed that trojan to write
into all the index files.
To start with, take a look at any filesystem or shell calls you make and
ensure that all parameters that are sourced from user input are properly
checked to ensure that the user hasn't entered something they
shouldn't've. For example "../../../etc/passwd" to a file_get_contents()
call.
Jasper
--- End Message ---
--- Begin Message ---
Hello,
I have a some colorful pictures, Would like to add white text with black
background around the white text...
I can add the text fine but could figure out how to add black background..
$textcolor = imagecolorallocate($destimg, 255, 255, 255);
imagestring($destimg, 3, 10, 10, "test text", $textcolor);
imagejpeg($destimg);
Best regards,
Andras Kende
http://www.kende.com
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.13/78 - Release Date: 8/19/2005
--- End Message ---
--- Begin Message ---
Hi,
I have a script which works fine for many users, but for some it doesn't.
I've been able to narrow it down to the imap_open-Command which just hangs
'forever'. I have verified that the imap-extensions are available, but other
than that I have no ideas what's going on there, why it would not respond
and what I could possibly do to avoid such errors. I assume something must
be missing/wrong in the PHP-setup, i.e. I've had other cases where
imap-extensions were included at compile-time, but not loaded due to an
error with the RAND_seed symbol etc. - but in all those cases there was at
least an error-msg telling you something was wrong. But just silently dying
is not a very helpful :(
Any ideas anyone?
Thanks
Michael
--- End Message ---
--- Begin Message ---
Michael Baas wrote:
Hi,
I have a script which works fine for many users, but for some it doesn't.
I've been able to narrow it down to the imap_open-Command which just hangs
'forever'. I have verified that the imap-extensions are available, but other
than that I have no ideas what's going on there, why it would not respond
and what I could possibly do to avoid such errors. I assume something must
be missing/wrong in the PHP-setup, i.e. I've had other cases where
imap-extensions were included at compile-time, but not loaded due to an
error with the RAND_seed symbol etc. - but in all those cases there was at
least an error-msg telling you something was wrong. But just silently dying
is not a very helpful :(
Any ideas anyone?
Could be a few things, such as:
1. Connection is timing out, and the time limit expired.
2. Firewall is blocking connections
Other connectivity-related issues (assuming imap_* works correctly)
--- End Message ---
--- Begin Message ---
Thanks Buran,
> 1. Connection is timing out, and the time limit expired.
We're only connecting to locahost here, sorry, forgot to mention.
> 2. Firewall is blocking connections
The ISP claims to support imap_open for POP3 and ISP, so I would expect him
to have sorted that one out.
> Other connectivity-related issues (assuming imap_* works correctly)
Hmm, imap_alerts() and imap_errors() at least work correctly (I can them
before imap_open to make sure they are reset). But other than that I have no
idea how to make sure that imap_* works correctly...
Cheers
Michael
--- End Message ---
--- Begin Message ---
Like Clint, I definitely recommend Mambo. Or, to be precise: "the CMS
formerly known as Mambo". Recently a split has happened between the
core-developers who will continue to develop the system (with much support
from the community) - see the new website at
http://www.opensourcematters.org/ - and between Miro, the company that had
the rights for the name, did some of the original work and recently set up a
foundation to support the whole OS-development. However, the way this all
happened as well as the terms and conditions of the new foundation caused
that split.
But regardless of all that dispute, "the CMS formerly known as Mambo" still
is a very solid solution and I have no doubt the devs will continue to take
good care of it :)
Cheers
Michael
--- End Message ---
--- Begin Message ---
Zachary Kessin wrote:
I am about to start on a project that seems like it would be right for
a CMS system. It will be about 80% rather boring stuff with about 20%
custom database work. I have looked at XOOPS and a few others. However
I can not seem to find one rather important thing about XOOPS. I
understand how to use a module that someone else wrote, but I have not
found any documentation on how to build my own blocks or application
components.
I am not yet committed to XOOPS, so if there is different system that
would be better that could work as well
--Zach
Nucleus seems to be good CMS too, see the: http://nucleuscms.org/.
Erik
--- End Message ---
--- Begin Message ---
Zachary Kessin wrote:
I am about to start on a project that seems like it would be right for
a CMS system. It will be about 80% rather boring stuff with about 20%
custom database work. I have looked at XOOPS and a few others. However
I can not seem to find one rather important thing about XOOPS. I
understand how to use a module that someone else wrote, but I have not
found any documentation on how to build my own blocks or application
components.
I am not yet committed to XOOPS, so if there is different system that
would be better that could work as well
--Zach
Nucleus seems to be good CMS too, see the: http://nucleuscms.org/.
Erik
--- End Message ---