php-general Digest 2 Apr 2007 10:22:28 -0000 Issue 4711

2007-04-02 Thread php-general-digest-help

php-general Digest 2 Apr 2007 10:22:28 - Issue 4711

Topics (messages 251903 through 251910):

Re: simple page not found 404 script - PHP
251903 by: Zoltán Németh

Re: HTDIGEST FILE FORMAT
251904 by: Buesching, Logan J

Re: finding the index name of an associative array
251905 by: Myron Turner

Re: Ide help needed
251906 by: Davi
251907 by: Arno Kuhl

pg_last_error()
251908 by: Miguel J. Jiménez

Re: Security Best Practice: typecast?
251909 by: Robin Vickery

Re: 0x9f54
251910 by: Seak, Teng-Fong

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:
php-general@lists.php.net


--
---BeginMessage---
2007. 03. 30, péntek keltezéssel 19.01-kor Dwayne Heronimo ezt írta:
 wierd.. your code is behaving exactly the same as mine did.
 it will display the error and the page.. but both at the same time :S
 
 it is working but somehow it continues to execute.
 
 http://arubaguide.org/arubaguide/categories.php?catcode=art
 
 http://arubaguide.org/arubaguide/categories.php?catcode=blabla
 
 
 
 Davi [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 Em Sexta 30 Maro 2007 13:42, Dwayne Heronimo escreveu:
  Yes but this file does not exist. It is just to use for my queries. so I
  think I cannot use the file_exists function. Which other function I would
  use to do this?
  I already have setup the .htaccess file to point also to a 404 page. but
  this works only if the URL is totally wrong. like 
  www.arubaguide.org/blabla
  but not www.arubaguide.org/categories.php?catcode=blabla
 
 
 
 Try something like that:
 
 ?php
 
 define(HTML,html/);
 
 define(INC,inc/);
 
 $ext = array (php,html,htm);
 
 $exists = false;
 
 foreach($ext as $file_ext) {
 
 if ( file_exists ( HTML.$_GET[catcode]...$file_ext ) )
 {
 $exists = true;
 break;
 }
 }
 
 if ( ! ( $exists ) ){
 include ( 404.php );
don't forget the exit here:
exit;

that's why it displays all the stuff later on

greets
Zoltán Németh


 }
 else {
 include ( HTML.$_GET[catcode]...$file_ext );}
 
 ?
 
 
 -- 
 Davi Vidal
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 --
 
 Agora com fortune:
 [Peter and his friends have formed a rock band and are performing at a
 prison]
 Peter Griffin:  [shouting into microphone] Hello, Cleveland!
 Cleveland:  Hello, Peter.
 Quagmire:  [clapping drum sticks together] One, two, three, *four*!
 Peter Griffin:  [small amount of time passes] Oh, my God. We don't know any
 songs. [prisoners get mad]  
 
---End Message---
---BeginMessage---
The password is the hash of the entire thing, not just the password.  So
it would be the following:

echo admin:trac:.md5('admin:trac:admin');

-Logan

-Original Message-
From: Manolet Gmail [mailto:[EMAIL PROTECTED] 
Sent: Sunday, April 01, 2007 5:28 PM
To: php-general@lists.php.net
Subject: HTDIGEST FILE FORMAT

hi, i want a php script to create htdigest file...

the correct file is:
username:admin
digest:trac
pass:admin

admin:trac:71ea86385b35d5e2575b0baec1904ded

i try to do it on php with this:

echo admin:trac:.md5(admin);

but i receive this:

admin:trac:21232f297a57a5a743894a0e4a801fc3

how is the htdigest format?
---End Message---
---BeginMessage---
Man-wai Chang wrote:
 myarray=array()
 myarray['a']=1
 myarray['b']=1
 myarray['c']=1

 Is there an iterative way to find out the array index values ('a', 'b'
 and 'c') of myarray?

   

array *array_keys* ( array $input [, mixed $search_value [, bool $strict]] )

*array_keys()* returns the keys, numeric and string, from the /input/
array.


http://www.php.net/manual/en/function.array-keys.php

-- 

_
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/
---End Message---
---BeginMessage---
Em Sexta 30 Março 2007 14:39, [EMAIL PROTECTED] escreveu:
 I am a beginer with php and i need to know which IDE is best suited
 under windows and linux both

 i have seen dreamweaver working and have heard about GoLive too but don't
 know whichone to go for

 can you please help me decide
 and also
 tell me some other IDE's if possible

Does anyone knows any IDE for PHP like VisualStudio.net?

TIA

-- 
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--

Agora com fortune:
Beneath this stone lies Murphy,
They buried him today,
He lived the life of Riley,
While Riley was away.
---End Message---
---BeginMessage---
Nuspere's PHPEd. Highly recommended. I looked at all the alternatives,
including Zend and Eclipse, and IMO PHPEd is superior. And faster
performance is a real bonus.

Arno


-Original Message-
From: Davi [mailto:[EMAIL PROTECTED]
Sent: 02 April 2007 02:50
To: php-general@lists.php.net
Subject: Re: [PHP] Ide help needed


Em Sexta 30 Março 2007 14:39, [EMAIL PROTECTED] escreveu:
 I am a beginer with php and i need to 

RE: [PHP] Ide help needed

2007-04-02 Thread Arno Kuhl
Nuspere's PHPEd. Highly recommended. I looked at all the alternatives,
including Zend and Eclipse, and IMO PHPEd is superior. And faster
performance is a real bonus.

Arno


-Original Message-
From: Davi [mailto:[EMAIL PROTECTED]
Sent: 02 April 2007 02:50
To: php-general@lists.php.net
Subject: Re: [PHP] Ide help needed


Em Sexta 30 Março 2007 14:39, [EMAIL PROTECTED] escreveu:
 I am a beginer with php and i need to know which IDE is best suited
 under windows and linux both

 i have seen dreamweaver working and have heard about GoLive too but don't
 know whichone to go for

 can you please help me decide
 and also
 tell me some other IDE's if possible

Does anyone knows any IDE for PHP like VisualStudio.net?

TIA

--
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--

Agora com fortune:
Beneath this stone lies Murphy,
They buried him today,
He lived the life of Riley,
While Riley was away.

--

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



[PHP] pg_last_error()

2007-04-02 Thread Miguel J. Jiménez
Hello, the question is simple... After I try to free a resultset in 
postgres using pg_free_result() it returns false ... Can I use 
pg_last_error() to get the cause of this last error? I have tried but it 
returns an empty string and I do not know if it is because I cannot use 
pg_last_error() thus. Thanks a lot...


--
Miguel J. Jiménez
Programador Senior
Área de Internet/XSL/PHP
[EMAIL PROTECTED]



ISOTROL
Edificio BLUENET, Avda. Isaac Newton nº3, 4ª planta.
Parque Tecnológico Cartuja '93, 41092 Sevilla.
Teléfono: 955 036 800 - Fax: 955 036 849
http://www.isotrol.com

Killing is often a part of life. What's hypocritical is to condemn, and then make 
allowances when the situation suits.
Utu-Noranti Pralatong (Farscape 4x17 - A Constellation Of Doubt)


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

Re: [PHP] Security Best Practice: typecast?

2007-04-02 Thread Robin Vickery

On 01/04/07, Richard Lynch [EMAIL PROTECTED] wrote:

So, after a recent thread on data filtering, I'm wondering...

Is this good enough in ALL possible Unicode/charset situations:

$foo_id = (int) $_POST['foo_id'];
$query = insert into whatever(foo_id) values($foo_id);

Or is it possible, even theoretically possible, for a sequence of:
[-]?[0-9]+
to somehow run afoul of ANY charset?



Depends how standard you want to get: '--' is the SQL comment
character, so if you have something like:

SELECT ... WHERE column-$foo  3 AND password='$password'

and foo is a negative integer, then in ANSI SQL, you've just commented
out everything after 'column', leaving you with:

SELECT ... WHERE column

Mysql protects you from that by demanding a space after the comment sequence.

-robin

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



[PHP] Example from www.php.net

2007-04-02 Thread Timothy Murphy
I was trying Example 2147, which reads:
---
?php
$string = XML
a xmlns:b
 foo name=one game=lonely1/foo
/a
XML;

$xml = simplexml_load_string($string);
foreach($xml-foo[0]-attributes() as $a = $b) {
echo $a,'=',$b,\\n;
}
?
---
It says that 'The above example will output:

name=one
game=lonely'

However, in my case it outputs nothing.
(I'm running php-5.1.6 under Fedora-6.)

Is there an error in the example;
or is the error mine?



-- 
Timothy Murphy  
e-mail (80k only): tim /at/ birdsnest.maths.tcd.ie
tel: +353-86-2336090, +353-1-2842366
s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland

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



[PHP] Problems with mail

2007-04-02 Thread Mário Gamito
Hi,

I have this very straight forward code to send an e-mail:

$subject_users_subscription_confirmation = Subscription confirmation;
$message_users_subscription_confirmation = 'Please, click this link to
confirm your subscritpion:
http://www.telbit.pt/subscribe-confirm.php?email=' . $email . 'conf=' .
$barfles;

mail($email, $subject_users_subscription_confirmation,
$message_users_subscription_confirmation);  

The three variables are ok, as i debuged them with prints, but no mail
is sent.

If i do a test with

mail('[EMAIL PROTECTED]', 'Hello', 'Hello');

then the mail is sent ok!

I'm driving nuts here.

Can someone give me a hand on this, please ?

Warm Regards
-- 
:wq! Mário Gamito

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



Re: [PHP] Re: 0x9f54

2007-04-02 Thread Seak, Teng-Fong
Man-wai Chang wrote:
 MySQL? MSSQL? PgSQL?
 Tijnema
   
 It seems he wanted to insert a Chinese character with that hex value.
 

 Yes... I tried the insert with PHP, including the use of
 mysql_real_escape_string(), but MySQL still gave me a blank only.

Well, this doesn't seem to be PHP related.  You'd better ask your
answer in MySQL forum/mailing-list.

But have you tried to insert your value using MySQL Query Browser?
If you can't do that there, it's a problem which is unrelated to PHP.

On the other hand, I remember you talked about the type of that
column to be char(2).  Have you specified what encoding it's using?
Moreover, I hope you're not using legacy encoding like Big5 or GB.  Use
Unicode (UTF-8) if your database is a brand new one.

Good luck




--
* Zoner PhotoStudio 8 - Your Photos perfect, shared, organised! 
www.zoner.com/zps
  You can download your free version.

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



[PHP] Sending mail through another (SMTP authenticated) host

2007-04-02 Thread Mário Gamito
Hi,

How can i use the mail function to send messages through another server
that has authenticated SMTP ?

Any help would be appreciated.

Warm Regards
-- 
:wq! Mário Gamito

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



[PHP] Re: Example from www.php.net

2007-04-02 Thread Timothy Murphy
Timothy Murphy wrote:

 I was trying Example 2147, which reads:
 ---
 ?php
 $string = XML
 a xmlns:b
  foo name=one game=lonely1/foo
 /a
 XML;
 
 $xml = simplexml_load_string($string);
 foreach($xml-foo[0]-attributes() as $a = $b) {
 echo $a,'=',$b,\\n;
 }
 ?
 ---
...
 However, in my case it outputs nothing.
 (I'm running php-5.1.6 under Fedora-6.)

I see that the example does work if I substitute
a for a xmlns:b.
[I'm not sure what effect the xmlns:b has?]

-- 
Timothy Murphy  
e-mail (80k only): tim /at/ birdsnest.maths.tcd.ie
tel: +353-86-2336090, +353-1-2842366
s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland

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



Re: [PHP] Date/time format?

2007-04-02 Thread Zoltán Németh
2007. 03. 30, péntek keltezéssel 14.00-kor Jason Pruim ezt írta:
 On Mar 29, 2007, at 4:52 PM, Zoltán Németh wrote:
 
 
 
 snip
 
  (I assume you want this calculation within one given day)
  you could read all rows into an array like
 
  $timeinfo = array();
  $sql = SELECT minute, sequence FROM table WHERE day='$day';
  $result = mysql_query($result);
  while ($row = mysql_fetch_assoc($result)) {
  $timeinfo[$row['sequence'] = $row['minute'];
  }
 
  and then calculate and echo the difference between any element of the
  array:
 
  $diff0_1 = $timeinfo[1] - $timeinfo[0];
 
 
 $timeinfo[$row['sequence'] = $row['minute']; --- is the [ between  
 $timeinfo and $row a typo? or is there supposed to be a closing ]  
 somewhere?

yeah it should be closed, sorry for the typo.
this way:

$timeinfo[$row['sequence']] = $row['minute'];

greets
Zoltán Németh

 
 When I add a closing ] to it as such:
 
 $timeinfo[$row['sequence'] = $row['minute']];
 
 I get this error when I try and open the page:
 [Fri Mar 30 13:55:36 2007] [error] PHP Notice:  Undefined index:   
 minute in /Volumes/RAIDer/webserver/Documents/tests/oatstest/ 
 oatstime.php on line 15
 [Fri Mar 30 13:55:36 2007] [error] PHP Notice:  Undefined index:
 in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on  
 line 15
 [Fri Mar 30 13:55:36 2007] [error] PHP Notice:  Undefined offset:  1  
 in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on  
 line 18
 [Fri Mar 30 13:55:36 2007] [error] PHP Notice:  Undefined offset:  0  
 in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on  
 line 18
 
 Line 15 is this line:
 
 $timeinfo[$row['sequence'] = $row['minute']];
 
 and line 18 has:
 
 $diff0_1 = $timeinfo[1] - $timeinfo[0];
 
 What I am trying to do is subtract $timeinfo[1] from $timeinfo[0] and  
 then display the difference.
 
 When I echo $timeinfo it just says array so my thinking is that the  
 errors are caused by the array not being populated properly based on  
 the extra [ or a missing ]. Am I at least on the right track?
 
 

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



Re: [PHP] Gnome and MIME types

2007-04-02 Thread Zoltán Németh
2007. 03. 30, péntek keltezéssel 13.51-kor Nathan Ziarek ezt írta:
 Got it.
 
 After putting .gnome2 folders every where I could think of, I  
 accidentally put one in /var/www/ and it worked. I guess PHP  
 considers the root of my web site to its home (which makes sense, but  
 not what I was expecting.
 
 Now, having a writable folder in the server path seems like a pretty  
 bad idea to me. I feel like I've been through the php.ini file a  
 thousand times, but I don't see anywhere to tell it to use another  
 directory as home.
 
 Is that possible, or do I hack my way around making this .gnome  
 folder less of a security risk?
 
 Thanks again everyone. You've all been really helpful.
 
 Nate
 

I think the home directory of www-data user is by default /var/www
this can be set in /etc/passwd file not in php.ini

greets
Zoltán Németh

 
 On Mar 30, 2007, at 11:50 AM, Nathan Ziarek wrote:
 
  I appreciate everyone's help. I think I may have to throw in the towel
  in a second here.
 
  I create a directory /home/www-data. I chown'd, chgrp'd and chmod'd it
  to www-data/www-data and 777 (I figured if it worked I could scale it
  back later). No dice.
 
  I then create a .gnome directory inside there and made sure it was
  owned and operated by www-data. Same error.
 
  Finally, I tried just running exec(ls ~/ 21, $array) and received
  ls: ~/: No such file or directory
 
  With a pretty limited knowledge of the environment PHP runs in, my
  guess is that it either doesn't know how to translate ~/ to
  HOME_DIRECTORY or the environment is set up in such a way that the
  fake home directory I made is in the wrong place.
 
  I've been looking through the PHP docs for days, but I wouldn't even
  know what to search for...suggestions welcome!
 
  Nate
 
  On 3/30/07, Edward Vermillion [EMAIL PROTECTED] wrote:
  ~ is an alias for /home/USERNAME
 
  so it's probably trying to create it in /home/www-data
 
 
 
  On Mar 30, 2007, at 11:20 AM, Nathan Ziarek wrote:
 
   I'm capturing the output of exec in an array  --  exec(command,
   $array);
  
   Shouldn't $array have the error from bash?
  
   Researching this more, I found this command that returns the error:
  
   exec(gnomevfs-info file.doc 21)   ---   gives me this:
  
   (gnomevfs-info:27496): libgnomevfs-WARNING **: Unable to create
   ~/.gnome2 directory: Permission denied
   Cannot initialize gnome-vfs.
  
   So Gnome is trying to make a folder in a user directory (www- 
  data, the
   apache2 user?) that either doesn't exist or can't be created.
  
   Any ideas on a work around for this? I don't see any way to specify
   where Gnome makes this directory.
  
   Thanks,
  
   Nate
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
 
 
 

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



[PHP] Re: Problems with mail

2007-04-02 Thread itoctopus
Weird, this code should work. Are you sure there is no hidden space
somewhere in the email. Try just to hardcode the email (eg.
mail('[EMAIL PROTECTED]', $subject_users_subscription_confirmation,
$message_users_subscription_confirmation); and see what'll happen.

--
itoctopus - http://www.itoctopus.com
Mário Gamito [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,

 I have this very straight forward code to send an e-mail:

 $subject_users_subscription_confirmation = Subscription confirmation;
 $message_users_subscription_confirmation = 'Please, click this link to
 confirm your subscritpion:
 http://www.telbit.pt/subscribe-confirm.php?email=' . $email . 'conf=' .
 $barfles;

 mail($email, $subject_users_subscription_confirmation,
 $message_users_subscription_confirmation);

 The three variables are ok, as i debuged them with prints, but no mail
 is sent.

 If i do a test with

 mail('[EMAIL PROTECTED]', 'Hello', 'Hello');

 then the mail is sent ok!

 I'm driving nuts here.

 Can someone give me a hand on this, please ?

 Warm Regards
 --
 :wq! Mário Gamito

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



[PHP] scandir and ftp wrapper

2007-04-02 Thread j

Hi I have a question about scandir

I have been trying to track down problems after upgrading from
5.1.6 to 5.2.1.

I have been getting errors with a section of code that does something
similar to the following

$fileList=scandir(ftp://user:[EMAIL PROTECTED]/);

I get the following error.

Warning: scandir(ftp://[EMAIL PROTECTED]/): failed to open dir: not 
implemented in /path/to/file.php on line 9


I checked phpinfo and ftp is included in the registered streams list.
allow_url_fopen is set to on.

Any suggestions why this code is not working?

Thanks

j.

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



Re: [PHP] Problems with mail

2007-04-02 Thread cajbecu
Mário Gamito wrote:
 Hi,
 
 I have this very straight forward code to send an e-mail:
 
 $subject_users_subscription_confirmation = Subscription confirmation;
 $message_users_subscription_confirmation = 'Please, click this link to
 confirm your subscritpion:
 http://www.telbit.pt/subscribe-confirm.php?email=' . $email . 'conf=' .
 $barfles;
 
 mail($email, $subject_users_subscription_confirmation,
 $message_users_subscription_confirmation);
 

try:

$message_users_subscription_confirmation = Please, click this link to
confirm your subscritpion:
http://www.telbit.pt/subscribe-confirm.php?email=; . $email . conf= .
$barfles;


(change simple quote: ' with double quote:  )

cajb.

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



[PHP] Best opensource XML parser for PHP ?

2007-04-02 Thread Don Don
Hi all 
whats the best open source (free) xml parser for php (4 ) ?  I've come across 
a few but am looking the best as adjudged by the industry.

Cheers

 
-
Food fight? Enjoy some healthy debate
in the Yahoo! Answers Food  Drink QA.

[PHP] Duplicate dates in array

2007-04-02 Thread Dave Goodchild

Hi all, I have an array containing a sequence of dates in the following
format, for example:

Mon 26 Nov 2007
Mon 24 Dec 2007
Mon 31 Dec 2007
Mon 28 Jan 2007

...and I want to remove any the first element in cases where the Mondays
fall in the same month, so in this case I want to be
left with:

Mon 26 Nov 2007
Mon 31 Dec 2007
Mon 28 Jan 2007

Any ideas on the most efficient way to do it? I am working on using
combinations of array_search, in_array and so on and want to avoid regular
expressions if I can. Many thanks in advance for any suggestions!

--
http://www.web-buddha.co.uk


[PHP] How to detect charset encoding with PHP and command line?

2007-04-02 Thread William Lovaton
Hi there,

I'd like to know a way to detect the file encoding from PHP and Linux
command line too.

In PHP I tried mb_detect_encoding() but it doesn't work reliable, first
I have to specify a list of posible encodings and second it always
returns the first encoding I put in the list no matter what.

Thanks for your help,


-William

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



Re: [PHP] Duplicate dates in array

2007-04-02 Thread Arpad Ray

Dave Goodchild wrote:

Any ideas on the most efficient way to do it? I am working on using
combinations of array_search, in_array and so on and want to avoid 
regular

expressions if I can. Many thanks in advance for any suggestions!
If you mean that you only want one date for each month (you'll end up 
with the last one), then it's very simple:


foreach ($dates as $date) {
   preg_match('/[a-z]{3} \d{4}/i', $date, $m);
   $newDates[$m[0]] = $date;
}

If you're really averse to regex, you could use date('Y-m', 
strtotime($date)) there instead, but I suspect that would perform far worse.


Arpad

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



Re: [PHP] Duplicate dates in array

2007-04-02 Thread Dave Goodchild

Amazing, just what I needed - many thanks. Have been coding non-stop for 10
days and things are getting foggy. Grats for your informed and quick
response and have a fantastic day!


Re: [PHP] Best opensource XML parser for PHP ?

2007-04-02 Thread Tijnema !

On 4/2/07, Don Don [EMAIL PROTECTED] wrote:

Hi all
whats the best open source (free) xml parser for php (4 ) ?  I've come across 
a few but am looking the best as adjudged by the industry.

Cheers


There's already an XML parser build into PHP. I don't see any reasong
using an external.
www.php.net/xml

Tijnema



-
Food fight? Enjoy some healthy debate
in the Yahoo! Answers Food  Drink QA.


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



[PHP] php 5 upgrade and background script on unix

2007-04-02 Thread Frederic Belleudy
Hello there, I hope someone resolved the same issue. I upgraded my 
server to 5.2.1
I got some script that are running background script (generally we call 
this technic FORKING)
Ive got a web interface that running (depending the action chosen) other 
scripts in the background.

My issue is, it doesn't work anymore since my new upgrade.
So I'm using this line to run my background script from the web browser 
interface:

/usr/local/bin/php test.php 21 error.log

if Im executing my script from the shell, my fork is working very fine! 
(Odd isn't it)

I taught it could be owner and rights problems but it's not the case...

Anyone got suggestions??

--
Frederic Belleudy
Programmer
PWIdeas
ICQ #: 253-372-030 


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



[PHP] Forking doesn't work on php 5.2.1?

2007-04-02 Thread Frederic Belleudy
Hello there, I hope someone resolved the same issue. I upgraded my 
server to 5.2.1
I got some script that are running background script (generally we call 
this technic FORKING)
Ive got a web interface that running (depending the action chosen) other 
scripts in the background.

My issue is, it doesn't work anymore since my new upgrade.
So I'm using this line to run my background script from the web browser 
interface:

/usr/local/bin/php test.php 21 error.log

if Im executing my script from the shell, my fork is working very fine! 
(Odd isn't it)

I taught it could be owner and rights problems but it's not the case...

Anyone got suggestions??

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



Re: [PHP] php 5 upgrade and background script on unix

2007-04-02 Thread Jochem Maas
Frederic Belleudy wrote:
 Hello there, I hope someone resolved the same issue. I upgraded my
 server to 5.2.1
 I got some script that are running background script (generally we call
 this technic FORKING)
 Ive got a web interface that running (depending the action chosen) other
 scripts in the background.
 My issue is, it doesn't work anymore since my new upgrade.
 So I'm using this line to run my background script from the web browser
 interface:
 /usr/local/bin/php test.php 21 error.log

and the [php] code that does the fork is what exactly??

 
 if Im executing my script from the shell, my fork is working very fine!
 (Odd isn't it)
 I taught it could be owner and rights problems but it's not the case...
 
 Anyone got suggestions??

don't fork webserver processes, granted it doesn't fix the problem, but you 
really
should be doing it anyway.

I'm guessing that the pcntl extension is not compiled into the webserver php 
SAPI,
it's a really big guess because you didn't supply the code you use to do the 
forking with.

 

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



Re: [PHP] Forking doesn't work on php 5.2.1?

2007-04-02 Thread Jochem Maas
Frederic Belleudy wrote:
 Hello there, I hope someone resolved the same issue. I upgraded my
 server to 5.2.1
 I got some script that are running background script (generally we call
 this technic FORKING)
 Ive got a web interface that running (depending the action chosen) other
 scripts in the background.
 My issue is, it doesn't work anymore since my new upgrade.
 So I'm using this line to run my background script from the web browser
 interface:
 /usr/local/bin/php test.php 21 error.log
 
 if Im executing my script from the shell, my fork is working very fine!
 (Odd isn't it)
 I taught it could be owner and rights problems but it's not the case...
 
 Anyone got suggestions??

don't double post, especially not within 10 minutes of each other -
contrary to what you may have heard this mailing list doesn't consist of
10,000 clones bred for the single purpose of answer *your* question as
fast as you can ask them.

 

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



[PHP] imagecreate() question

2007-04-02 Thread tedd

Hi gang:

A couple of image questions:

In the php manual it says:

imagecreate() returns an image identifier representing a blank image 
of specified size.

We recommend the use of imagecreatetruecolor().

Q: Why the recommendation?

imagecreate() returns a blank page whereas imagecreatetruecolor() 
returns a black page.


Q: Is there a problem with a blank page?

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Forking doesn't work on php 5.2.1? OT

2007-04-02 Thread Børge Holen
On Monday 02 April 2007 17:11, Jochem Maas wrote:
 Frederic Belleudy wrote:
  Hello there, I hope someone resolved the same issue. I upgraded my
  server to 5.2.1
  I got some script that are running background script (generally we call
  this technic FORKING)
  Ive got a web interface that running (depending the action chosen) other
  scripts in the background.
  My issue is, it doesn't work anymore since my new upgrade.
  So I'm using this line to run my background script from the web browser
  interface:
  /usr/local/bin/php test.php 21 error.log
 
  if Im executing my script from the shell, my fork is working very fine!
  (Odd isn't it)
  I taught it could be owner and rights problems but it's not the case...
 
  Anyone got suggestions??

 don't double post, especially not within 10 minutes of each other -
 contrary to what you may have heard this mailing list doesn't consist of
 10,000 clones bred for the single purpose of answer *your* question as
 fast as you can ask them.

WUT???

noone told me.


-- 
---
Børge
http://www.arivene.net
---

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



Re: [PHP] imagecreate() question

2007-04-02 Thread Richard Davey

tedd wrote:


In the php manual it says:

imagecreate() returns an image identifier representing a blank image of 
specified size.

We recommend the use of imagecreatetruecolor().

Q: Why the recommendation?


Because the need to create 256 colour (or less) images grows less year 
by year. If you need to work with a jpeg/png then imagecreatetruecolor() 
is required. As this is what most people need, hence the manual comment 
exists.


imagecreate() returns a blank page whereas imagecreatetruecolor() 
returns a black page.


Sure, but both are easily changed.

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

Never trust a computer you can't throw out of a window

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



Re: [PHP] php 5 upgrade and background script on unix

2007-04-02 Thread Frederic Belleudy



don't fork webserver processes, granted it doesn't fix the problem, but you 
really
should be doing it anyway.

I'm guessing that the pcntl extension is not compiled into the webserver php 
SAPI,
it's a really big guess because you didn't supply the code you use to do the 
forking with.

  

Ok then you want to have the fork code!
I'm doing a complete example


My script is forking on itself.
So from my browser I go on:
http://localhost/test_fork.php

My code in test_fork.php is :

?
$in = get_shell_args($_SERVER['argv']); // DONT PAY ATTENTION TO THAT 
FUNCTION, it a made home function


if($in['bg']) {
   print HERE;  
   sleep(30);

}
else {
   print forking;
   `/usr/local/bin/php /www/admin.gammacash.com/test/test_fork.php bg=1 
21 /var/log/test.log `

}
?

So Im assuming that the fork will get the bg argument, in this case I 
should receive HERE in /var/log/test.log (did tail -f 
/var/log/test.log while I was running the script)

I've put a sleep 30 seconds to get the fork PID number.

Unfortunately, when I do execute test_fork.php from the web, it wont 
execute itself in background.

This method was running fine with my old config.

The script works perfectly because if Im executing test_fork.php from 
the shell, the fork is working fine!




__ NOD32 2162 (20070402) Information __

This message was checked by NOD32 antivirus system.
http://www.eset.com



  



--
Frederic Belleudy
Programmer
PWIdeas
ICQ #: 253-372-030 


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



Re: [PHP] Forking doesn't work on php 5.2.1?

2007-04-02 Thread Frederic Belleudy

Well I think I've found the answer:
the configure command is (in part):

'--disable-cli' '--disable-pear'

Ive got another server who is running fork script and '--enable-cli' is 
in the configure command.


Well Ill let you know guys if it works after I've recompiled apache
How comes it does work when Im executing it from the shell and not from 
the web???

Any explanations?

Frederic Belleudy wrote:
Hello there, I hope someone resolved the same issue. I upgraded my 
server to 5.2.1
I got some script that are running background script (generally we 
call this technic FORKING)
Ive got a web interface that running (depending the action chosen) 
other scripts in the background.

My issue is, it doesn't work anymore since my new upgrade.
So I'm using this line to run my background script from the web 
browser interface:

/usr/local/bin/php test.php 21 error.log

if Im executing my script from the shell, my fork is working very 
fine! (Odd isn't it)

I taught it could be owner and rights problems but it's not the case...

Anyone got suggestions??




--
Frederic Belleudy
Programmer
PWIdeas
ICQ #: 253-372-030 


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



Re: [PHP] Forking doesn't work on php 5.2.1? OT

2007-04-02 Thread Jochem Maas
Børge Holen wrote:
 On Monday 02 April 2007 17:11, Jochem Maas wrote:
 Frederic Belleudy wrote:
 Hello there, I hope someone resolved the same issue. I upgraded my
 server to 5.2.1
 I got some script that are running background script (generally we call
 this technic FORKING)
 Ive got a web interface that running (depending the action chosen) other
 scripts in the background.
 My issue is, it doesn't work anymore since my new upgrade.
 So I'm using this line to run my background script from the web browser
 interface:
 /usr/local/bin/php test.php 21 error.log

 if Im executing my script from the shell, my fork is working very fine!
 (Odd isn't it)
 I taught it could be owner and rights problems but it's not the case...

 Anyone got suggestions??
 don't double post, especially not within 10 minutes of each other -
 contrary to what you may have heard this mailing list doesn't consist of
 10,000 clones bred for the single purpose of answer *your* question as
 fast as you can ask them.
 
 WUT???
 
 noone told me.

'they' never tell anyone, but once in a while one of us drones gets lucky and 
figures
out there is 'life beyond the list' ;-)

 
 

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



Re: [PHP] Forking doesn't work on php 5.2.1?

2007-04-02 Thread Jochem Maas
Frederic Belleudy wrote:
 Well I think I've found the answer:
 the configure command is (in part):
 
 '--disable-cli' '--disable-pear'
 
 Ive got another server who is running fork script and '--enable-cli' is
 in the configure command.

then that is probably what the problem is - although I find it a strange
compile option would have that effect. if you run ./configure --help you'll
see the following:

--disable-cli   Disable building CLI version of PHP

which doesn't suggest that it would have any effect on the workings of a
webserver SAPI.

 
 Well Ill let you know guys if it works after I've recompiled apache

try recompiling php - recompiling apache won't have an effect as far as that 
compile
option goes.

 How comes it does work when Im executing it from the shell and not from
 the web???
 Any explanations?
 
 Frederic Belleudy wrote:
 Hello there, I hope someone resolved the same issue. I upgraded my
 server to 5.2.1
 I got some script that are running background script (generally we
 call this technic FORKING)
 Ive got a web interface that running (depending the action chosen)
 other scripts in the background.
 My issue is, it doesn't work anymore since my new upgrade.
 So I'm using this line to run my background script from the web
 browser interface:
 /usr/local/bin/php test.php 21 error.log

 if Im executing my script from the shell, my fork is working very
 fine! (Odd isn't it)
 I taught it could be owner and rights problems but it's not the case...

 Anyone got suggestions??

 
 

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



Re: [PHP] php 5 upgrade and background script on unix

2007-04-02 Thread Jochem Maas
Frederic Belleudy wrote:
 
 don't fork webserver processes, granted it doesn't fix the problem,
 but you really
 should be doing it anyway.

 I'm guessing that the pcntl extension is not compiled into the
 webserver php SAPI,
 it's a really big guess because you didn't supply the code you use to
 do the forking with.

   
 Ok then you want to have the fork code!

'want' is putting it strongly - unless of course your handing out AudiRS4's
in which case 'want' is spot on.

 I'm doing a complete example
 
 
 My script is forking on itself.
 So from my browser I go on:
 http://localhost/test_fork.php
 
 My code in test_fork.php is :
 
 ?
 $in = get_shell_args($_SERVER['argv']); // DONT PAY ATTENTION TO THAT

does $_SERVER['argv'] exist at all? does your error reporting include E_NOTICE?
what is the value of the ini setting 'register_argc_argv'?

 FUNCTION, it a made home function
 
 if($in['bg']) {
print HERE; sleep(30);
 }
 else {
print forking;
`/usr/local/bin/php /www/admin.gammacash.com/test/test_fork.php bg=1
 21 /var/log/test.log `
 }
 ?
 
 So Im assuming that the fork will get the bg argument, in this case I
 should receive HERE in /var/log/test.log (did tail -f
 /var/log/test.log while I was running the script)
 I've put a sleep 30 seconds to get the fork PID number.

no idea how the sleep() will help.

 
 Unfortunately, when I do execute test_fork.php from the web, it wont
 execute itself in background.

won't it? what does it do? does it go into and endless loop and bring your 
machine to a halt
by any chance? .. because by looking at it, as long as $in['bg'] is not set and 
not equal to
true it's going to keep spawning sub-shells with cmdlines that call itself.

 This method was running fine with my old config.
 
 The script works perfectly because if Im executing test_fork.php from
 the shell, the fork is working fine!

and what is the value of the ini setting 'register_argc_argv' when running
via the php CLI SAPI?

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



Re: [PHP] Forking doesn't work on php 5.2.1?

2007-04-02 Thread Sebe

Jochem Maas wrote:

Frederic Belleudy wrote:
  

Well Ill let you know guys if it works after I've recompiled apache



try recompiling php - recompiling apache won't have an effect as far as that 
compile
option goes.
  

  
it will if php is complied statically into apache, then you have to 
recompile apache each time you compile php.. i use static because u get 
better performance, but that's another topic of it's own..


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



Re: [PHP] Forking doesn't work on php 5.2.1? OT

2007-04-02 Thread Stut

Jochem Maas wrote:

'they' never tell anyone, but once in a while one of us drones gets lucky and 
figures
out there is 'life beyond the list' ;-)


You want me to do what with who now?

-Stut

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



Re: [PHP] php 5 upgrade and background script on unix

2007-04-02 Thread Frederic Belleudy

Jochem:
won't it? what does it do? does it go into and endless loop and bring your 
machine to a halt
by any chance? .. because by looking at it, as long as $in['bg'] is not set and 
not equal to
true it's going to keep spawning sub-shells with cmdlines that call itself.

Me:
You haven't read my message? It works fine when Im running it from the shell

When I do:

`/usr/local/bin/php /www/admin.gammacash.com/test/test_fork.php bg=1 21 
/var/log/test.log `
you can see bg=1

its the passing arguments!
any other suggestions?



Jochem Maas wrote:

Frederic Belleudy wrote:
  

don't fork webserver processes, granted it doesn't fix the problem,
but you really
should be doing it anyway.

I'm guessing that the pcntl extension is not compiled into the
webserver php SAPI,
it's a really big guess because you didn't supply the code you use to
do the forking with.

  
  

Ok then you want to have the fork code!



'want' is putting it strongly - unless of course your handing out AudiRS4's
in which case 'want' is spot on.

  

I'm doing a complete example


My script is forking on itself.
So from my browser I go on:
http://localhost/test_fork.php

My code in test_fork.php is :

?
$in = get_shell_args($_SERVER['argv']); // DONT PAY ATTENTION TO THAT



does $_SERVER['argv'] exist at all? does your error reporting include E_NOTICE?
what is the value of the ini setting 'register_argc_argv'?

  

FUNCTION, it a made home function

if($in['bg']) {
   print HERE; sleep(30);
}
else {
   print forking;
   `/usr/local/bin/php /www/admin.gammacash.com/test/test_fork.php bg=1
21 /var/log/test.log `
}
?

So Im assuming that the fork will get the bg argument, in this case I
should receive HERE in /var/log/test.log (did tail -f
/var/log/test.log while I was running the script)
I've put a sleep 30 seconds to get the fork PID number.



no idea how the sleep() will help.

  

Unfortunately, when I do execute test_fork.php from the web, it wont
execute itself in background.



won't it? what does it do? does it go into and endless loop and bring your 
machine to a halt
by any chance? .. because by looking at it, as long as $in['bg'] is not set and 
not equal to
true it's going to keep spawning sub-shells with cmdlines that call itself.

  

This method was running fine with my old config.

The script works perfectly because if Im executing test_fork.php from
the shell, the fork is working fine!



and what is the value of the ini setting 'register_argc_argv' when running
via the php CLI SAPI?

  



--
Frederic Belleudy
Programmer
PWIdeas
ICQ #: 253-372-030 


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



Re: [PHP] Forking doesn't work on php 5.2.1?

2007-04-02 Thread Frederic Belleudy

Well my php.ini
register_argc_argv = Off

apache was configured with the option --disable-cli
but cli is installed on my system and it works fine when i do execute 
the script from the shell

so its a problem running php cli from my php apache module

any other suggestions!?!??!

Sebe wrote:

Jochem Maas wrote:

Frederic Belleudy wrote:
 

Well Ill let you know guys if it works after I've recompiled apache



try recompiling php - recompiling apache won't have an effect as far 
as that compile

option goes.
 
  
it will if php is complied statically into apache, then you have to 
recompile apache each time you compile php.. i use static because u 
get better performance, but that's another topic of it's own..





--
Frederic Belleudy
Programmer
PWIdeas
ICQ #: 253-372-030 


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



Re: [PHP] imagecreate() question

2007-04-02 Thread tedd

At 4:27 PM +0100 4/2/07, Richard Davey wrote:

tedd wrote:


In the php manual it says:

imagecreate() returns an image identifier representing a blank 
image of specified size.

We recommend the use of imagecreatetruecolor().

Q: Why the recommendation?


Because the need to create 256 colour (or less) images grows less 
year by year. If you need to work with a jpeg/png then 
imagecreatetruecolor() is required. As this is what most people 
need, hence the manual comment exists.


imagecreate() returns a blank page whereas imagecreatetruecolor() 
returns a black page.


Sure, but both are easily changed.

Cheers,

Rich


I found, which generated my questions, that the difference between a 
blank page and a black page can be significant when dealing with 
alpha channels.


For example, if I create a blank page and then place a 50 percent 
transparent circle on it, it works. However if I do the same thing 
using a black page and change the color black to transparent, I 
lose the 50 percent transparency of the circle. In other words, it 
generates a transparent page with a nontransparent circle.


If anyone knows how to use imagecreatetruecolor() to create a png 
image that has a 100% transparent background with a 50% transparent 
circle on it, I sure would like to see how you did it.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] php 5 upgrade and background script on unix

2007-04-02 Thread Frederic Belleudy

Jochem Maas wrote:

Frederic Belleudy wrote:
  

don't fork webserver processes, granted it doesn't fix the problem,
but you really
should be doing it anyway.

I'm guessing that the pcntl extension is not compiled into the
webserver php SAPI,
it's a really big guess because you didn't supply the code you use to
do the forking with.

  
  

Ok then you want to have the fork code!



'want' is putting it strongly - unless of course your handing out AudiRS4's
in which case 'want' is spot on.

  

I'm doing a complete example


My script is forking on itself.
So from my browser I go on:
http://localhost/test_fork.php

My code in test_fork.php is :

?
$in = get_shell_args($_SERVER['argv']); // DONT PAY ATTENTION TO THAT



does $_SERVER['argv'] exist at all? does your error reporting include E_NOTICE?
what is the value of the ini setting 'register_argc_argv'?

  

FUNCTION, it a made home function

if($in['bg']) {
   print HERE; sleep(30);
}
else {
   print forking;
   `/usr/local/bin/php /www/admin.gammacash.com/test/test_fork.php bg=1
21 /var/log/test.log `
}
?

So Im assuming that the fork will get the bg argument, in this case I
should receive HERE in /var/log/test.log (did tail -f
/var/log/test.log while I was running the script)
I've put a sleep 30 seconds to get the fork PID number.



no idea how the sleep() will help.

  

Unfortunately, when I do execute test_fork.php from the web, it wont
execute itself in background.



won't it? what does it do? does it go into and endless loop and bring your 
machine to a halt
by any chance? .. because by looking at it, as long as $in['bg'] is not set and 
not equal to
true it's going to keep spawning sub-shells with cmdlines that call itself.

  

This method was running fine with my old config.

The script works perfectly because if Im executing test_fork.php from
the shell, the fork is working fine!



and what is the value of the ini setting 'register_argc_argv' when running
via the php CLI SAPI?

  

the value is OFF

but my other servers that is running php cli is set to OFF too...

--
Frederic Belleudy
Programmer
PWIdeas
ICQ #: 253-372-030 


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



Re: [PHP] imagecreate() question

2007-04-02 Thread Edward Vermillion

Did you try making it transparent first, before adding the circle?


Only a question because I'm not sure if it will make a difference. I  
know I had problems trying to get the alpha blending to actually look  
decent in png's (ended up looking like a very poor gif with a non- 
antialiased mask) and I think I eventually gave up and put the image  
on a white background.


But that was six months to a year ago and anything more than two  
weeks out is all but forgotten, old-timers disease I think.


Ed

On Apr 2, 2007, at 12:26 PM, tedd wrote:


At 4:27 PM +0100 4/2/07, Richard Davey wrote:

tedd wrote:


In the php manual it says:

imagecreate() returns an image identifier representing a blank  
image of specified size.

We recommend the use of imagecreatetruecolor().

Q: Why the recommendation?


Because the need to create 256 colour (or less) images grows less  
year by year. If you need to work with a jpeg/png then  
imagecreatetruecolor() is required. As this is what most people  
need, hence the manual comment exists.


imagecreate() returns a blank page whereas imagecreatetruecolor 
() returns a black page.


Sure, but both are easily changed.

Cheers,

Rich


I found, which generated my questions, that the difference between  
a blank page and a black page can be significant when dealing  
with alpha channels.


For example, if I create a blank page and then place a 50 percent  
transparent circle on it, it works. However if I do the same thing  
using a black page and change the color black to transparent, I  
lose the 50 percent transparency of the circle. In other words, it  
generates a transparent page with a nontransparent circle.


If anyone knows how to use imagecreatetruecolor() to create a png  
image that has a 100% transparent background with a 50% transparent  
circle on it, I sure would like to see how you did it.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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



Re: [PHP] Security Best Practice: typecast?

2007-04-02 Thread Chris Shiflett
Richard Lynch wrote:
 Should one be ultra-conservative and just do:
 $foo_sql = mysql_real_escape_string($connection);

I don't consider this (escaping) to be particularly conservative; it's
appropriate for any data you want to use in an SQL query that's being
sent to MySQL.

Filtering is different - making sure something is what you expect.
Escaping makes sure that something isn't mistaken for something else in
a different context, and mysql_real_escape_string() takes character
encoding into consideration, protecting you against edge cases like this:

http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-string

Hope that helps.

Chris

-- 
Chris Shiflett
http://shiflett.org/

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



Re: [PHP] Security Best Practice: typecast?

2007-04-02 Thread Chris Shiflett
Tijnema wrote:
 use this instead:
 $foo_sql = mysql_real_escape_string($foo_sql,$connection);

Don't escape an entire SQL query.

Escaping helps us provide distinction between the query and the data,
eliminating cases where data can interfere with the format of the query
(SQL injection).

If escaping the entire query actually did anything useful, databases
would do this for us, and we've never be discussing this topic.

Chris

-- 
Chris Shiflett
http://shiflett.org/

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



[PHP] Security: Passing URLs between pages for redirect

2007-04-02 Thread Chris W. Parker
Hi.

Currently I'm building a small application for internal office use but
I'd like to get some feedback on a certain aspect of it.

When someone tries to access a page they do not have access to they are
redirected to the login page with the URL they tried to access in the
querystring. This URL is then snuck into the login form as a hidden
variable (called 'nexturl') so they can be sent back to the page they
came from after a successful login.

I can see this happening when someone bookmarks one of their own pages
and then tries to go directly there after their session has ended.
Instead of making them navigate all the way back to that page I figure
I'll just send them directly.

My question for the list is: Are there any validation checks I should do
on the 'nexturl' variable before it is used as a redirect?

The only situation I can come up with where this could be exploited is
if someone sends a malicious URL through email to another employee with
the intention of course being that after they successfully login they
will be redirected to desired URL.

Are there any best practices for this kind of thing? Would it be
enough to verify that the page being redirected to is within my own
domain?



Thanks,
Chris.

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



RE: [PHP] Security: Passing URLs between pages for redirect

2007-04-02 Thread Jay Blanchard
[snip]
Currently I'm building a small application for internal office use but
I'd like to get some feedback on a certain aspect of it.

When someone tries to access a page they do not have access to they are
redirected to the login page with the URL they tried to access in the
querystring. This URL is then snuck into the login form as a hidden
variable (called 'nexturl') so they can be sent back to the page they
came from after a successful login.

I can see this happening when someone bookmarks one of their own pages
and then tries to go directly there after their session has ended.
Instead of making them navigate all the way back to that page I figure
I'll just send them directly.

My question for the list is: Are there any validation checks I should do
on the 'nexturl' variable before it is used as a redirect?

The only situation I can come up with where this could be exploited is
if someone sends a malicious URL through email to another employee with
the intention of course being that after they successfully login they
will be redirected to desired URL.

Are there any best practices for this kind of thing? Would it be
enough to verify that the page being redirected to is within my own
domain?
[/snip]

You could always make the value a session variable and then use location
to redirect. That way the URL is hidden from the user and would prevent
others from spoofing.

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



[PHP] Re: Sending mail through another (SMTP authenticated) host

2007-04-02 Thread Haydar TUNA
Hello,
 You can use phpmailer from http://phpmailer.sourceforge.net/   web 
adress:) . You can use examples like this:
?php
require(class.phpmailer.php);

$mail = new PHPMailer();

$mail-IsSMTP(); // send via SMTP
$mail-Host = post.somehost.com; // SMTP servers
$mail-SMTPAuth = true; // turn on SMTP authentication
$mail-Username = somebady; // SMTP username
$mail-Password = somepass; // SMTP password
$mail-CharSet = iso-8859-9;
$mail-From = [EMAIL PROTECTED];
$mail-FromName = Mailer;
$mail-AddAddress([EMAIL PROTECTED],Name Surname);

$mail-WordWrap = 50;

$mail-IsHTML(true);


$mail-Subject = Subject;
$mail-Body = Fýstýkçý Þahap;

if(!$mail-Send())
{
echo Message was not sent p;
echo Mailer Error:  . $mail-ErrorInfo;
exit;
}

echo Message has been sent;
?


Mário Gamito [EMAIL PROTECTED], haber iletisinde sunlari 
yazdi:[EMAIL PROTECTED]
 Hi,

 How can i use the mail function to send messages through another server
 that has authenticated SMTP ?

 Any help would be appreciated.

 Warm Regards
 -- 
 :wq! Mário Gamito 

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



[PHP] Cannot remove PHP Version 5.2.1-0.dotdeb.1

2007-04-02 Thread Miles Thompson

This probably belongs under php-install, but thought I would try here first,
and it comes under the general header of Be careful what you wish for.

On a new Ubuntu (Debian) server I installed this version of PHP because I
wanted some 5.2 features. It's the hardened version, and not the one we
want.

I have done the conventional aptitude remove php5, and then went to all of
the directories returned by whereis php5 and manually removed them.

I've rebooted both the server and my own computer, and still a
http://localhost/phpinfo.php returns the phpinfo() data AND shows
configuration file paths: etc/php5/apache2 and /etc/php5/apache2/conf.d
which have been deleted.

Does anyone have experience with this beastie? A steer in the right
direction would be appreciated, especially as I set up a new server about
once every decade or so.

Cheers - Miles


RE: [PHP] Audio CAPTCHA review request

2007-04-02 Thread Daevid Vincent
I think what you're doing is very interesting.

I will point you at http://www.cepstral.com/ for a possible solution to your
.mp3 usage. You could use Cepstral's swift tool to say the text
dynamically.

Another suggestion on your security: put in a random delay after
unsuccessful attempts. This can help a DoS from hammering your box. And log
how many attempts failed. After say 3 attempts, lock the user's account. If
you're really clever/paranoid, add the cracker's IP to your firewall deny
file. This of course is all dependant upon how secure/paranoid you want to
be.

 -Original Message-
 From: tedd [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, March 29, 2007 9:41 AM
 To: php-general@lists.php.net
 Subject: [PHP] Audio CAPTCHA review request
 
 Hi gang:
 
 If you people would be so kind as to review this:
 
 http://sperling.com/examples/captcha/
 
 and tell me what you think (ease of use, if it works, security, 
 etc.), I would appreciate it.
 
 The point is to be able to get to the Congratulations page by 
 hearing and entering the key. If you can get there some other way or 
 defeat the process, I sure would like to know about it.
 
 I've tested this with a couple of dozen blind users and they find no 
 problems with it. Now, I'll like to test it for the sighted.
 
 It's mixture of a several languages, but there is php in it, so I 
 guess it's on topic.
 
 Cheers,
 
 tedd
 
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



Re: [PHP] Cannot remove PHP Version 5.2.1-0.dotdeb.1

2007-04-02 Thread Mario Guenterberg
On Mon, Apr 02, 2007 at 04:52:02PM -0300, Miles Thompson wrote:
 This probably belongs under php-install, but thought I would try here first,
 and it comes under the general header of Be careful what you wish for.
 
 On a new Ubuntu (Debian) server I installed this version of PHP because I
 wanted some 5.2 features. It's the hardened version, and not the one we
 want.
 
 I have done the conventional aptitude remove php5, and then went to all of
 the directories returned by whereis php5 and manually removed them.
 
 I've rebooted both the server and my own computer, and still a
 http://localhost/phpinfo.php returns the phpinfo() data AND shows
 configuration file paths: etc/php5/apache2 and /etc/php5/apache2/conf.d
 which have been deleted.

Try dpkg --purge php-5.2.1 or so.
You may have only the php binaries (CLI) removed.
This removes the config-scripts at all.
Apt-get remove libapache2-mod-php5 removes your apache2 modules and
the dpkt --purge libapache2-mod-php5 removes all the config scripts
of them.

I have build php 5.2.1 from source on Ubuntu 6.10 and it works
fine. Installad in /usr/local for some system reasons and of course
a easy way to upgrade.

Greetings
Mario
-- 
 -
| havelsoft.com - Ihr Service Partner für Open Source |
| Tel:  033876-21 966 |
| Notruf: 0173-277 33 60  |
| http://www.havelsoft.com|
| |
| Inhaber: Mario Günterberg   |
| Mützlitzer Strasse 19   |
| 14715 Märkisch Luch |
 -


signature.asc
Description: Digital signature


RE: [PHP] Downloads for subsrcibers only

2007-04-02 Thread Daevid Vincent
Look at mod_auth_mysql. Then authenticate your pdf directory against that
database of users. 

Otherwise anyone who knows the direct link to your PDF can download it,
bypassing all your 'subscription' security. 

 -Original Message-
 From: Mário Gamito [mailto:[EMAIL PROTECTED] 
 Sent: Sunday, April 01, 2007 1:54 AM
 To: php-general@lists.php.net
 Subject: [PHP] Downloads for subsrcibers only
 
 Hi,
 
 I made this site in PHP that has a page with some PDFs to download.
 My costumer wants that only subscribed people are allowed to download
 the PDFs.
 
 I've already made the subscrbe and login mechanism.
 
 Now, my question for you is about letting only subscribers 
 download the
 PDFs.
 What is the best approach ?
 Register a session when they login and then in the PDFs page apply a
 
 if email is registered
   you can download the PDFs
 else
   you can't
 
 Something like this ?
 Or is it there a better way ?
 
 Any help would be appreciated.
 
 Warm Regards
 -- 
 :wq! Mário Gamito
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



Re: [PHP] pg_last_error()

2007-04-02 Thread Chris

Miguel J. Jiménez wrote:
Hello, the question is simple... After I try to free a resultset in 
postgres using pg_free_result() it returns false ... Can I use 
pg_last_error() to get the cause of this last error? I have tried but it 
returns an empty string and I do not know if it is because I cannot use 
pg_last_error() thus. Thanks a lot...



pg_free_result tells you whether memory was free'd up or not.

pg_last_error tells you the last error message from postgresql.

They aren't related, so you can't use pg_last_error to work out why 
pg_free_result didn't work.


Do you have a small test script that fails to free memory? What php version?

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Problems with mail

2007-04-02 Thread Chris

Mário Gamito wrote:

Hi,

I have this very straight forward code to send an e-mail:

$subject_users_subscription_confirmation = Subscription confirmation;
$message_users_subscription_confirmation = 'Please, click this link to
confirm your subscritpion:
http://www.telbit.pt/subscribe-confirm.php?email=' . $email . 'conf=' .
$barfles;

mail($email, $subject_users_subscription_confirmation,
$message_users_subscription_confirmation);  

The three variables are ok, as i debuged them with prints, but no mail
is sent.

If i do a test with

mail('[EMAIL PROTECTED]', 'Hello', 'Hello');

then the mail is sent ok!


So mail() works, which means you're doing something wrong or your host 
is blocking the email or spam filters are catching it.


If you're on a test machine, watch the mail logs and see if that gives 
you any clues about what's going on.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Cannot remove PHP Version 5.2.1-0.dotdeb.1

2007-04-02 Thread Miles Thompson

Thanks Mario, I'll try that tomorrow morning.
Much appreciated - Miles

On 4/2/07, Mario Guenterberg [EMAIL PROTECTED] wrote:


On Mon, Apr 02, 2007 at 04:52:02PM -0300, Miles Thompson wrote:
 This probably belongs under php-install, but thought I would try here
first,
 and it comes under the general header of Be careful what you wish for.

 On a new Ubuntu (Debian) server I installed this version of PHP because
I
 wanted some 5.2 features. It's the hardened version, and not the one we
 want.

 I have done the conventional aptitude remove php5, and then went to
all of
 the directories returned by whereis php5 and manually removed them.

 I've rebooted both the server and my own computer, and still a
 http://localhost/phpinfo.php returns the phpinfo() data AND shows
 configuration file paths: etc/php5/apache2 and /etc/php5/apache2/conf.d
 which have been deleted.

Try dpkg --purge php-5.2.1 or so.
You may have only the php binaries (CLI) removed.
This removes the config-scripts at all.
Apt-get remove libapache2-mod-php5 removes your apache2 modules and
the dpkt --purge libapache2-mod-php5 removes all the config scripts
of them.

I have build php 5.2.1 from source on Ubuntu 6.10 and it works
fine. Installad in /usr/local for some system reasons and of course
a easy way to upgrade.

Greetings
Mario
--
-
| havelsoft.com - Ihr Service Partner für Open Source |
| Tel:  033876-21 966 |
| Notruf: 0173-277 33 60  |
| http://www.havelsoft.com|
| |
| Inhaber: Mario Günterberg   |
| Mützlitzer Strasse 19   |
| 14715 Märkisch Luch |
-

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.3 (GNU/Linux)

iQIVAwUBRhFizDUZahlMISn3AQIJaBAAkb0tlZFXTO/6yRgZGf0tP4+U1eiTGnMR
r+jqzCiYD3EA6vg7Qlf7K97nn+Jo9CwuYLC2WXRIWGoHK8Mor5UqWPLX6mRFut2w
d19ksKv605Dq1FuweNzTAZo9SiJwG8DsZ9Kj0Xboysu5098g/mV+mTvcnyONDmDU
6XiLqHkfITkUES/Hn3Nb0mOSNI7K41lipm/3TrWqPep1Fs/QUyDb/wtLRzfrcScm
CmdDCE+nBsKtCdtcZD3VDNN4F3O4x2ZbM1yAp9+S5yQn0b1kK4HoAJ99dpCR+Q4V
C+O5VFDr515dujlMo4+CcGPe63xLvU8wn2f5P1vcXcQFPEBj5zJYZGQSPWfrVeBa
H0R7sNraBOL+JJD1c5eSYIbZBCjFnaKyMzlQCJ/qgmG/t1akzNJdNlBJ15lMn8dd
d8nsa5Za/19ULJR0cPq0CyjAgd1+S0/ykUOGDa2S0uIhURB3AJ/xf2ffH23XbI6m
So5maXF2I9hsOwYkZgxv4Kv+HhgJAQesFj7FwBjljXcPXYlXX3DWzC1VwzTKik3F
kHviM3PH9XSoGlizwIAwBKlq3sY/CnUo7xoWvmapVvpJDEumi2AvgpDkBl27ogEV
Rh7wx0twS8WCSytNSz3XeFJIwmdtrQudXBbNGBSOU6NOk3NwbMhKt5JX2RL7omwE
D0lQzqENPDY=
=cWaV
-END PGP SIGNATURE-




[PHP] secure database info in different environments

2007-04-02 Thread Bruce Cowin
Hi,

I have a generic database class that I built to connect to our different 
databases.  From other posts that I've read, I think the safe thing is for me 
to put this file outside the web root, ensure it has a .php extension, set the 
include path to include this folder and include it in any pages that require 
it.  Is this correct?

Also, how do you handle the different environments: dev, test, and prod?  I 
don't want to have to change the code every time I copy the file over.  Do I 
have an independent file that determines if that folder should point to 
dev/test/prod?

Thanks for your help.



Regards,

Bruce

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



Re: [PHP] Re: Example from www.php.net

2007-04-02 Thread Chris

Timothy Murphy wrote:

Timothy Murphy wrote:


I was trying Example 2147, which reads:
---
?php
$string = XML
a xmlns:b
 foo name=one game=lonely1/foo
/a
XML;

$xml = simplexml_load_string($string);
foreach($xml-foo[0]-attributes() as $a = $b) {
echo $a,'=',$b,\\n;
}
?
---

...

However, in my case it outputs nothing.
(I'm running php-5.1.6 under Fedora-6.)


I see that the example does work if I substitute
a for a xmlns:b.
[I'm not sure what effect the xmlns:b has?]


If it's an official comment (not a user comment) then post a 
documentation bug report at http://bugs.php.net/


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Google-Yahoo venture and PHP

2007-04-02 Thread Chris

Matt Kay wrote:

I really dont see what all the fuss is about. If MS is going to have us all
running
on thin clients, and Google/Yahoo want to beat them to the punch, is this
really
going to matter who we pay? The article on digg.com
http://digg.com/tech_news/Google_Yahoo_Merger_Redefines_Access
simply means we will be getting our desktop as a service, and MS have the
same
goal. PHP will only be a small part of this if Zend decide to throw thier
lot in also.


Did you look at the date? ;)

--
Postgresql  php tutorials
http://www.designmagick.com/

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