[PHP] $_GET $_POST simultaneously

2005-01-11 Thread Bostjan Skufca @ domenca.com
Hello,

If I create form like this
form name=form action=##_URI_ROOT##/entity/edit.php?a=b method=post
input type=hidden name=action value=modify /
...
both arrays contain appropriate variables when submitted:
::: $_GET :::
Array
 (
 [a] = b
 )
 
::: $_POST :::
Array
 (
 [action] = modify
...
)

Now what I am interested in is if this is valid behaviour regarding HTTP 
specification and if other platforms support this interference of GET and 
POST variables in request?

Thank your for your answers,
Bostjan

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



[PHP] Re: Error loading extension dlls in WindosXP for PHP4.3.10

2005-01-11 Thread Lester Caine
Ranjan K. Baisak wrote:
I am using PHP4.3.10 in WindowsXP. When I am trying to
use extension dlls e.g. php_xmlrpc.dll and when trying
to restart Apache2 Web Server, I am getting error
message as UnKnows():Unable to load dynamic library
'./php_xmlrpc.dll.dll' - The specified module could
Transcription error? (.dll.dll)
not be found. The DLL file php_xmlrpc.dll is already
exists in Windows/System32 directory. Can anybody help
me to how to use extension dlls.
I set the php.ini to look for the extensions where you installed PHP
--
Lester Caine
-
L.S.Caine Electronic Services
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] $_GET $_POST simultaneously

2005-01-11 Thread Lars B. Jensen
Is it just me or ... why on earth would you want to populate both GET and 
POST arrays through this obscure way of coding ?

If you really have a form where you dont have a clue wether your data comes 
from GET or POST, it should be way less effort to copy one array to another 
or have a lookup function to return the given value.

/ Lars
- Original Message - 
From: Bostjan Skufca @ domenca.com [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Tuesday, January 11, 2005 5:42 PM
Subject: [PHP] $_GET  $_POST simultaneously


Hello,
If I create form like this
form name=form action=##_URI_ROOT##/entity/edit.php?a=b 
method=post
input type=hidden name=action value=modify /
...
both arrays contain appropriate variables when submitted:
::: $_GET :::
Array
(
[a] = b
)

::: $_POST :::
Array
(
[action] = modify
...
)
Now what I am interested in is if this is valid behaviour regarding HTTP
specification and if other platforms support this interference of GET and
POST variables in request?
Thank your for your answers,
Bostjan
--
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] $_GET $_POST simultaneously

2005-01-11 Thread Bostjan Skufca @ domenca.com
Browser history: I do not want it to contain any URIs to files which require 
some sort of id variable passed.

Example:
1. http://www.entity.org/edit.php 
(should produce an error or redirect to entity list)

2. http://www.entity.org/edit.php?id=1 
(should display editing interface)

Now I really do not like to use redirects in case of errors. So I could 
constantly use (2) second form of URI, even in POST requests.

But then, if I already have id in $_GET, why the redundancy of sending 
another id to $_POST?


B.

On Tuesday 11 January 2005 09:48, you wrote:
 Is it just me or ... why on earth would you want to populate both GET and
 POST arrays through this obscure way of coding ?

 If you really have a form where you dont have a clue wether your data comes
 from GET or POST, it should be way less effort to copy one array to another
 or have a lookup function to return the given value.

 / Lars

 - Original Message -
 From: Bostjan Skufca @ domenca.com [EMAIL PROTECTED]
 To: php-general@lists.php.net
 Sent: Tuesday, January 11, 2005 5:42 PM
 Subject: [PHP] $_GET  $_POST simultaneously

  Hello,
 
  If I create form like this
  form name=form action=##_URI_ROOT##/entity/edit.php?a=b
  method=post
  input type=hidden name=action value=modify /
  ...
 
  both arrays contain appropriate variables when submitted:
  ::: $_GET :::
 
  Array
  (
  [a] = b
  )
 
  ::: $_POST :::
 
  Array
  (
  [action] = modify
  ...
  )
 
  Now what I am interested in is if this is valid behaviour regarding HTTP
  specification and if other platforms support this interference of GET and
  POST variables in request?
 
  Thank your for your answers,
  Bostjan
 
  --
  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] Re: Error loading extension dlls in WindosXP for PHP4.3.10

2005-01-11 Thread Ranjan K. Baisak

--- Lester Caine [EMAIL PROTECTED] wrote:

 I set the php.ini to look for the extensions where
 you installed PHP
 
I copied all dlls from PHP diectory to
WINDOWS/System32 directory and then it started
running. But still I am not sure how PHP picks up the
dll files. In my php.ini file I have set 
extension_dir = C:\PHP4\extensions\
so from this directory all dlls should be picked up
then why I need to copy again all dll files from php
directiry to system32.
Onething I am assuming that Apache interpreter picks
up dll files from c:\windows\system32 directory and
php interpreter picks from C:\PHP4\extensions
directory. This is just my guess.
Weird ... not sure what exactly happens?

regards,
Ranjan




__ 
Do you Yahoo!? 
Yahoo! Mail - You care about security. So do we. 
http://promotions.yahoo.com/new_mail

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



Re: [PHP] Re: Error loading extension dlls in WindosXP for PHP4.3.10

2005-01-11 Thread Lester Caine
Ranjan K. Baisak wrote:
I set the php.ini to look for the extensions where
you installed PHP
I copied all dlls from PHP diectory to
WINDOWS/System32 directory and then it started
running. But still I am not sure how PHP picks up the
dll files. In my php.ini file I have set 
extension_dir = C:\PHP4\extensions\
so from this directory all dlls should be picked up
then why I need to copy again all dll files from php
directiry to system32.
Onething I am assuming that Apache interpreter picks
up dll files from c:\windows\system32 directory and
php interpreter picks from C:\PHP4\extensions
directory. This is just my guess.
Weird ... not sure what exactly happens?
Apache does not use the php modules!
There is no need to copy them to WINDOWS/System32
Apache is only complaining because PHP will not start.
Where have you actually got php.ini? the default is in c:\Windows
--
Lester Caine
-
L.S.Caine Electronic Services
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Functions in replacement string of eregi_replace

2005-01-11 Thread M. Sokolewicz
Ville Mattila wrote:
Hi there!
I'm looking for a workaround to carry out a feature similar to that I 
could use any PHP function inside the replacement string in 
eregi_replace (or ereg_replace).

I have a set of HTML code with some h2-headers. Now I should convert 
all HTML headers to uppercase strings. As far as I know and have tested, 
I can't use code like:
$newstr = eregi_replace(h3([a-z0-9 \.!\?]+)/h3, strtoupper(\\1));

How could I do that?
Ville
use preg_replace with the /e modifier
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Error loading extension dlls in WindosXP for PHP4.3.10

2005-01-11 Thread Ranjan K. Baisak

--- Lester Caine [EMAIL PROTECTED] wrote:
 
 Apache does not use the php modules!
 There is no need to copy them to WINDOWS/System32
 Apache is only complaining because PHP will not
 start.
 Where have you actually got php.ini? the default is
 in c:\Windows
Well php.ini file is in c:\windows directory. If I am
not copying all dlls to c:\windows\system32 directory
then duirng Apache service startup, it displays error
messages as I have mentioned in my first mail.
 Apache is only complaining because PHP will not
 start.
So should I assume that even of Apache displays error
messages but actually all dlls are loaded and I can
use them in my php files?

regards,
Ranjan

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



[PHP] 2 dimensional array processing

2005-01-11 Thread Benjamin Edwards
If I create the following 2 dimensional associative array:-

$insert[tab2][fields1] = value1;
$insert[tab1][fields2] = value2;
$insert[tab2][fields5] = value3;
$insert[tab1][fields7] = value4;

how do I do 2 levels of nested loop with the first level looping through the 
first level of the array and the second nesting through the second.  something 
like:-

foreach( $insert as $table = $fields ) {
  foreatch( $fields as $field = $value ) {
echo update $table set $field = $value;
  }
}

Regards,
Ben







Re: [PHP] Re: Error loading extension dlls in WindosXP for PHP4.3.10

2005-01-11 Thread Lester Caine
Ranjan K. Baisak wrote:
--- Lester Caine [EMAIL PROTECTED] wrote:
Apache does not use the php modules!
There is no need to copy them to WINDOWS/System32
Apache is only complaining because PHP will not
start.
Where have you actually got php.ini? the default is
in c:\Windows
Well php.ini file is in c:\windows directory. If I am
not copying all dlls to c:\windows\system32 directory
then duirng Apache service startup, it displays error
messages as I have mentioned in my first mail.
OK back up a step. So is PHP4 running if you do not enable the 
php_xmlrpc module in php.ini?

Apache is only complaining because PHP will not
start.
So should I assume that even of Apache displays error
messages but actually all dlls are loaded and I can
use them in my php files?
I have seen some strange errors when things that a module relies on to 
run are not available. If I don't have the firebird client installed, 
php_interbase fails to load, and PHP will not start. I wonder if that 
has something to do with it?

I'm on PHP5 now myself, and so that fixed a number if niggles which I 
had with PHP4, so hopefully someone will wake up soon and provide the 
real answer to the problem ;)

--
Lester Caine
-
L.S.Caine Electronic Services
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: unable to load curl

2005-01-11 Thread Zareef Ahmed
Please read install.txt carefully, it has a section on this problems,
if PHP.INI is fine., then you need to copy some of the dlls available
in dlls folder to your system folder.

zareef ahmed 



On Mon, 10 Jan 2005 22:38:41 +0530, Sagar C Nannapaneni
[EMAIL PROTECTED] wrote:
  Please respond to the newsgroup and not to my personal email.
 
  quoteIs it a file access/ownership thing?/quote
 
  This is possible.  Have you checked permissions for PHP user?  My
  original question remains unanswered though and it is probably a better
  place to start...
 
extension_dir = C:\php\extensions
   
where all the extension dlls reside.
All extensions are working and all dlls are loading properly,,
 
  What do you mean by this statement? How do you know this if you claim
  that cURL is not loading (it is an extension)... have you tried phpinfo()
 ?
 
 
 What i mean by the statement is that when i tried to load other
 modules(extensions u could say)
  like php_cpdf,php_mhash...they are working...i mean i could see them as
 enabled in phpinfo().
 
 But when i load the curl extension i'm getting error.
 
 Yes..i've tried phpinfo().
 
 Its not displaying anything about cURL.
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
Zareef Ahmed :: A PHP Developer in India ( Delhi )
Homepage :: http://www.zareef.net

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



Re: [PHP] Re: Error loading extension dlls in WindosXP for PHP4.3.10

2005-01-11 Thread Ranjan K. Baisak

--- Lester Caine [EMAIL PROTECTED] wrote:

 OK back up a step. So is PHP4 running if you do not
 enable the 
 php_xmlrpc module in php.ini?
Its running and I can see in service. But the specific
functions related to php_xmlrpc module are not
recognized, so I can say that this module is not
loaded.
 I'm on PHP5 now myself, and so that fixed a number
 if niggles which I 
 had with PHP4, so hopefully someone will wake up
 soon and provide the 
 real answer to the problem ;)
I never tried with PHP5. My server was written in java
and now I am trying to move to PHP. And as a newbie to
PHP so I am facing lots of problem .
Now I can keep it as is till it runs fine and as
suggested by you, if anybody can look into it will
help a lot.

regards,
Ranjan



__ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 

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



Re: [PHP] Forms on PHP

2005-01-11 Thread Leon Poon
Refer to the following line numbers:
01  ?php
02  // Start of PHP code - Extract values from form.
03  /* Other values read */
04  $n=$_POST['n'];
05 
06  // Pass the data from the form to lightcurve_csharp
07  $command=./lightcurve_csharp $a $i $e $lomega $bomega $lambda $n;
08  $result=`$command`;
09 
10  $form_submitted=$_POST['form_sumbitted'];
11  if (isset($form_submitted)) {
12 if ($form_submitted) {
13 echo 'The form has been submittedbr';
14 unset($form_submitted);
15 }
16  } else
17 echo 'The form has not been submittedbr';
When the user first load the page, no data was posted. So there was no 
$_POST['form_sumbitted'] available. Line 10 will cause $form_submitted to 
contain the NULL value (I think). $form_submitted will evaluate to FALSE at 
line 12. Thus it will not display any message.

By the way, by doing line 10, $form_submitted would have been set regardless 
whether there is $_POST['form_sumbitted'], and line 11 will evaluate to TRUE 
always. Thus you will never ever see the 'form not been submitted' message.

Anyway, when you posted for the first time, $_POST['form_sumbitted'] is 
available. The 'The form has been submittedbr' message will be printed. 
After that, when you press Reload button on the browser, the post data will 
once again be sent from the user. (This is the behaviour of reloading a 
posted page. In Internet Explorer there should be a message dialog box 
asking the user whether to resend form data in order to refresh.) Reposting 
the data during the reload means that there will be 
$_POST['form_sumbitted'], thus once again the 'form hass been submitted' 
message.

In order to prevent this from happening, you should do a header('Location: 
success-page.php') on a successful submit. This is so that at the redirected 
page, the user would not have resent data even if he press the Reload 
button.

Hope this helps

-Leon 

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


Re: [PHP] $_GET $_POST simultaneously

2005-01-11 Thread tg-php
If your question is a matter of Is this a good programming practice then I 
think it's ok.  There are times when something like this could be really useful.

Should people get into the practice of using this kind of thing?  I think it 
really depends on the circumstances and there's definitely times when it would 
just make things more confusing which is bad programming practice in general.

So unless there's a web server that looks for POST data and ignores any GET 
data sent (which I've never heard of but I'm guessing that someone's managed to 
create a web server at one point that did this.. on purpose or not), then I 
think this is an ok technique if there's not a simpler one that does the same 
thing.

Simplicity is really the key, but it's nice to know that you CAN use GET and 
POST together if you want/need to.  Just as long as it's not complicating the 
situation for no reason.

-TG

= = = Original message = = =

Browser history: I do not want it to contain any URIs to files which require 
some sort of id variable passed.

Example:
1. http://www.entity.org/edit.php 
(should produce an error or redirect to entity list)

2. http://www.entity.org/edit.php?id=1 
(should display editing interface)

Now I really do not like to use redirects in case of errors. So I could 
constantly use (2) second form of URI, even in POST requests.

But then, if I already have id in $_GET, why the redundancy of sending 
another id to $_POST?


B.

On Tuesday 11 January 2005 09:48, you wrote:
 Is it just me or ... why on earth would you want to populate both GET and
 POST arrays through this obscure way of coding ?

 If you really have a form where you dont have a clue wether your data comes
 from GET or POST, it should be way less effort to copy one array to another
 or have a lookup function to return the given value.

 / Lars

 - Original Message -
 From: Bostjan Skufca @ domenca.com [EMAIL PROTECTED]
 To: php-general@lists.php.net
 Sent: Tuesday, January 11, 2005 5:42 PM
 Subject: [PHP] $_GET  $_POST simultaneously

  Hello,
 
  If I create form like this
  form name=form action=##_URI_ROOT##/entity/edit.php?a=b
  method=post
  input type=hidden name=action value=modify /
  ...
 
  both arrays contain appropriate variables when submitted:
  ::: $_GET :::
 
  Array
  (
  [a] = b
  )
 
  ::: $_POST :::
 
  Array
  (
  [action] = modify
  ...
  )
 
  Now what I am interested in is if this is valid behaviour regarding HTTP
  specification and if other platforms support this interference of GET and
  POST variables in request?
 
  Thank your for your answers,
  Bostjan


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] strange sessions

2005-01-11 Thread Tim Burgan
Hello,
Here's a link to a website demonstrating my problems: 
http://www.timburgan.com/problems/
You can download the code from the site or here: 
http://www.timburgan.com/problems/files/site.zip

I'm experiencing some weird issues with sessions, and because I'm quite 
new to PHP and sessions.. I'm a bit lost. My use of headers also seems 
to be playing up.

I'd really appreciate it if someone has time to assist me, look at my 
code, and solve some of my problems that are described below.

On my website, there are 3 types of users:
  1. Students
  2. Staff
  3. Admin
There are many students, and students are able to login and edit their 
own page, but they have no rights to edit other student pages, staff 
pages, or any other pages.

There are many staff members, and staff are able to login and edit their 
own page, but they also have no rights to edit other student pages or 
staff pages. BUT THEY ARE ALLOWED TO EDIT ANY OTHER PAGES.

The admin is also staff member, but they are given admin status and 
therefore able to edit anything - including any students, staff, or content.

When someone logs-in successfully, they are taken to the editing page. 
If the editing page is then closed and the user tries to navigate the 
site as any normal non-logged-in user would (by clicking the 
navigation links), the address bar in the browser changes, but the 
content stays the same and doesn't change.

Also, when someone logs-in successfully, they are taken to the editing 
page. If the editing page is then closed they are returned to the 
original page they were trying to edit. If the user then clicks [edit 
this page] again, it says they do not have permission to edit this 
page.. even though they do!

By the way- to login, staff are Joe (username  password are both: joe) 
and Simon (username  password are both: simon). Students are Tim 
(username  password both: tim), and Grace (username  password both: 
grace).

Thank you very much for your time and assistance.
I cannot thank you enough.
Tim Burgan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: [PHP-DB] Complicated Question (maybe)?

2005-01-11 Thread Philip Thompson
On Jan 10, 2005, at 11:16 PM, JeRRy wrote:
Hi,
I have my reasons in asking this.  But instead of
going on about it I'll make it quick.
Is there a way to BLOCK an update to a column in a
databasefrom a webform or php page?
What I mean is this.
A user registers for a site.  They enter details like
their address, username and etc.
I want to BLOCK any possible updates from a webform or
php page to the address field.  Or even halt any sort
of update/modification from mysql to that column but
have it possible to unblock by admin.
Is this possible?  Sure I could refuse an mysql update
to do this but I want to lock out everyone to ensure
no sneaky activity or changes are made.
Is it possible or am I talking too much?
J
Maybe I'm over-simplifying this. But if you do not want them to update 
this field via the web, then don't let them have that ability.

So, is this what you're doing?:
form action=thispage.php method=post
	Username: input type=text value=? echo $username; ? 
name=username size=30 /
	...etc...
	Address: ? echo $fieldYouDoNotWantToUpdate; ?
/form

Do you see what I'm saying? If you're pulling information from a 
database, then just display it on screen as text, then they will for 
sure not be able to update it. Otherwise, put it in a modifiable 
input/ or select field.

Hope that helps.
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] 2 dimensional array processing

2005-01-11 Thread Brent Baisley
You've created a 2x2 array, not a 1x4, which might be confusing you:
tab2 [fields1] [fields5]
tab1 [fields2] [fields7]
You almost have it, you just need to set your loop up to handle 
unlimited field/value pairs in your array.

One option is to structure your loop like this:
foreach  ($insert as $table = $fields) {
foreach($fields as $field = $value) {
$fieldValuePairs[] = $field = $value;
}
$fieldValueStr = implode(',', $fieldValuePairs);
echo update $table set $fieldValueStr;
unset($fieldValuePairs);
}
On Jan 11, 2005, at 6:22 AM, Benjamin Edwards wrote:
If I create the following 2 dimensional associative array:-
$insert[tab2][fields1] = value1;
$insert[tab1][fields2] = value2;
$insert[tab2][fields5] = value3;
$insert[tab1][fields7] = value4;
how do I do 2 levels of nested loop with the first level looping 
through the first level of the array and the second nesting through 
the second.  something like:-

foreach( $insert as $table = $fields ) {
  foreatch( $fields as $field = $value ) {
echo update $table set $field = $value;
  }
}
Regards,
Ben



--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] 2 dimensional array processing

2005-01-11 Thread Benjamin Edwards
Ok - looking at what you did I cant see any diference apart from turning a 
serious updated into a single update. This is usefull if I want to do an update 
but I actualy want an insert (the update was just used for this example).

I actualy want to do an insert so i'me thinking the following would work:-

foreach  ($insert as $table = $fields) {
foreach($fields as $field = $value) {
$columns[] = $field;
$values[] = '.$value.';
}

echo 
insert into $table ( .implode( ', ', $columns ).
 values ( .implode( ', ', $values ). ) ;
unset($columns);
unset($values);
}

Ben

 Brent Baisley [EMAIL PROTECTED] 01/11/05 03:02pm 
You've created a 2x2 array, not a 1x4, which might be confusing you:
tab2 [fields1] [fields5]
tab1 [fields2] [fields7]

You almost have it, you just need to set your loop up to handle 
unlimited field/value pairs in your array.

One option is to structure your loop like this:
foreach  ($insert as $table = $fields) {
foreach($fields as $field = $value) {
$fieldValuePairs[] = $field = $value;
}
$fieldValueStr = implode(',', $fieldValuePairs);
echo update $table set $fieldValueStr;
unset($fieldValuePairs);
}

On Jan 11, 2005, at 6:22 AM, Benjamin Edwards wrote:

 If I create the following 2 dimensional associative array:-

 $insert[tab2][fields1] = value1;
 $insert[tab1][fields2] = value2;
 $insert[tab2][fields5] = value3;
 $insert[tab1][fields7] = value4;

 how do I do 2 levels of nested loop with the first level looping 
 through the first level of the array and the second nesting through 
 the second.  something like:-

 foreach( $insert as $table = $fields ) {
   foreatch( $fields as $field = $value ) {
 echo update $table set $field = $value;
   }
 }

 Regards,
 Ben






-- 
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

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


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__


__
This email and any files transmitted with it are confidential. It is for the 
intended recipient only. If you have received the email in error please notify 
the author by replying to this email. If you are not the intended recipient, 
you must not disclose, distribute, copy, print, or rely on this email. Any 
views expressed by an individual within this email which do not constitute or 
record professional advice relating to the RNLI, do not necessarily reflect the 
views of the organisation.

Registered Charity Number 209603

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



[PHP] client information

2005-01-11 Thread Bruno Santos
Hello all.
   I have a problem that i hope to solve with php. i know that, using 
$_SERVER['xxx'] is possible to find some information about the client 
who is accessing the script.
what i need to know if its possible to find out more information about 
the client, like in linux the DISPLAY variable of the client ?
if i make a system call, i get the server information and thats not what 
i want ?
if not with php, is possible to do it with javascript ?

thanx in advance
Bruno Santos
--
Say no to Software patents
www.nosoftwarepatents.com
--
[EMAIL PROTECTED]
--
Divisão de Informática
[EMAIL PROTECTED]
Tel: +272 000 155
Fax: +272 000 257
--
Hospital Amato Lusitano
[EMAIL PROTECTED]
Tel: 272 000 272
Fax: 272 000 257
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] client information

2005-01-11 Thread Benjamin Edwards
A couple of things that mey help.  I think phpinfo() will display all the 
system varables.  These varables come from the web server so your web server 
documentation may help.  Another thing that may work is implode ( ',' $_SERVER 
) which should give you a (, comma) seperated list of $_SERVER (Not sure uf 
this works for assosiated arrays) and you can also see if the varable is there.

Ben

 Bruno Santos [EMAIL PROTECTED] 01/11/05 03:43pm 
Hello all.

I have a problem that i hope to solve with php. i know that, using 
$_SERVER['xxx'] is possible to find some information about the client 
who is accessing the script.
what i need to know if its possible to find out more information about 
the client, like in linux the DISPLAY variable of the client ?
if i make a system call, i get the server information and thats not what 
i want ?
if not with php, is possible to do it with javascript ?

thanx in advance

Bruno Santos

-- 
Say no to Software patents
www.nosoftwarepatents.com 

--

[EMAIL PROTECTED] 

--

Divisão de Informática
[EMAIL PROTECTED] 
Tel: +272 000 155
Fax: +272 000 257

--

Hospital Amato Lusitano
[EMAIL PROTECTED] 
Tel: 272 000 272
Fax: 272 000 257

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


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__


__
This email and any files transmitted with it are confidential. It is for the 
intended recipient only. If you have received the email in error please notify 
the author by replying to this email. If you are not the intended recipient, 
you must not disclose, distribute, copy, print, or rely on this email. Any 
views expressed by an individual within this email which do not constitute or 
record professional advice relating to the RNLI, do not necessarily reflect the 
views of the organisation.

Registered Charity Number 209603

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



Re: [PHP] 2 dimensional array processing

2005-01-11 Thread Brent Baisley
A, I was wondering why your variable was named insert.
Anyway, that's easy too.
foreach($insert as $table = $fields) {
	$fieldList = array_keys($fields);
	$fieldNames = implode(',', $fieldList);
	$fieldValues = ''.implode(',', $fields).'';
	echo 'insert into '.$table.' ('.$fieldNames.') values 
('.$fieldValues.')';
}

That puts double quotes around the values. I always use single quotes 
around my text pieces since PHP doesn't parse what's inside them, thus 
it's supposed to be faster.

On Jan 11, 2005, at 10:42 AM, Benjamin Edwards wrote:
Ok - looking at what you did I cant see any diference apart from 
turning a serious updated into a single update. This is usefull if I 
want to do an update but I actualy want an insert (the update was just 
used for this example).
 
I actualy want to do an insert so i'me thinking the following would 
work:-
 
foreach ($insert as $table = $fields) {
 foreach($fields as $field = $value) {
 $columns[] = $field;
 $values[] = '.$value.';
 }
 
 echo
 insert into $table ( .implode( ', ', $columns ).
  values ( .implode( ', ', $values ). ) ;
 unset($columns);
 unset($values);
}
 
Ben
 
 Brent Baisley [EMAIL PROTECTED] 01/11/05 03:02pm 
You've created a 2x2 array, not a 1x4, which might be confusing you:
tab2 [fields1] [fields5]
tab1 [fields2] [fields7]
 
You almost have it, you just need to set your loop up to handle
 unlimited field/value pairs in your array.
 
One option is to structure your loop like this:
foreach ($insert as $table = $fields) {
 foreach($fields as $field = $value) {
 $fieldValuePairs[] = $field = $value;
 }
 $fieldValueStr = implode(',', $fieldValuePairs);
 echo update $table set $fieldValueStr;
 unset($fieldValuePairs);
}
 
On Jan 11, 2005, at 6:22 AM, Benjamin Edwards wrote:
 
 If I create the following 2 dimensional associative array:-

 $insert[tab2][fields1] = value1;
 $insert[tab1][fields2] = value2;
 $insert[tab2][fields5] = value3;
 $insert[tab1][fields7] = value4;

 how do I do 2 levels of nested loop with the first level looping
  through the first level of the array and the second nesting through
  the second. something like:-

 foreach( $insert as $table = $fields ) {
 foreatch( $fields as $field = $value ) {
 echo update $table set $field = $value;
 }
 }

 Regards,
 Ben






--
 Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
 
--
 PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
 
 
__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
__
 
  
 __
 This email and any files transmitted with it are confidential. It is 
for the intended recipient only. If you have received the email in 
error please notify the author by replying to this email. If you are 
not the intended recipient, you must not disclose, distribute, copy, 
print, or rely on this email. Any views expressed by an individual 
within this email which do not constitute or record professional 
advice relating to the RNLI, do not necessarily reflect the views of 
the organisation.

 Registered Charity Number 209603
image.tiff
image.tiff
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Get name of extending class with static method call

2005-01-11 Thread Torsten Roehr
Hi list,

in PHP4 it was possible to get the name of the calling class with
debug_bcktrace(). Unfortunately this behaviour has been changed in PHP5. I
didn't find a solution in the archives.

Is there *any* way to get the name of the calling class?:

class Car {
function drive() {
// I need the name of the calling class here
// in this case it should be 'Porsche'
}
}

class Porsche extends Car {
}

Porsche::drive();


Any help is greatly appreciated!

Thanks and best regards,

Torsten Roehr

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



[PHP] PHP5 sprintf() function borken

2005-01-11 Thread Thomas Munz
Today i think i found an bu in the PHP5 version 5.0.3 ( allready exits also in 
the version 5.0.2 , i try this version also ). 

When tryo one of this scripts:

$i_test = 0.085007667542;
$tm_total = sprintf('%.2f', $i_test);
echo $tm_total;

$i_test = 0.085007667542;
$tm_total = sprintf('%.2f', $i_test);
echo $tm_total;

$i_test = 0.085007667542;
$tm_total = sprintf('%.2f', floatval($i_test));
echo $tm_total;


i always get an other result. Some time it get a result like that:

-2681561585988522000.00

my friend try it also and have the same problems...

is that a bug in php5?

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



Re: [PHP] Get name of extending class with static method call

2005-01-11 Thread Christopher Fulton
Not sure if this is the best way to do it or not, but you can do this
and it should (untested code) work.

class Car {
function drive() {
 return $this-getClassName();
}
function getClassName() {
  return Car; 
}
}

class Porshe {
 function getClassName() {
  return Porshe;
 }
}

$foo = new Porshe();
echo $foo-drive();


On Tue, 11 Jan 2005 17:08:27 +0100, Torsten Roehr [EMAIL PROTECTED] wrote:
 Hi list,
 
 in PHP4 it was possible to get the name of the calling class with
 debug_bcktrace(). Unfortunately this behaviour has been changed in PHP5. I
 didn't find a solution in the archives.
 
 Is there *any* way to get the name of the calling class?:
 
 class Car {
 function drive() {
 // I need the name of the calling class here
 // in this case it should be 'Porsche'
 }
 }
 
 class Porsche extends Car {
 }
 
 Porsche::drive();
 
 Any help is greatly appreciated!
 
 Thanks and best regards,
 
 Torsten Roehr
 
 --
 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: Get name of extending class with static method call

2005-01-11 Thread M. Sokolewicz
try using __CLASS__
Torsten Roehr wrote:
Hi list,
in PHP4 it was possible to get the name of the calling class with
debug_bcktrace(). Unfortunately this behaviour has been changed in PHP5. I
didn't find a solution in the archives.
Is there *any* way to get the name of the calling class?:
class Car {
function drive() {
// I need the name of the calling class here
// in this case it should be 'Porsche'
}
}
class Porsche extends Car {
}
Porsche::drive();
Any help is greatly appreciated!
Thanks and best regards,
Torsten Roehr
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: client information

2005-01-11 Thread M. Sokolewicz
Bruno Santos wrote:
Hello all.
   I have a problem that i hope to solve with php. i know that, using 
$_SERVER['xxx'] is possible to find some information about the client 
who is accessing the script.
what i need to know if its possible to find out more information about 
the client, like in linux the DISPLAY variable of the client ?
if i make a system call, i get the server information and thats not what 
i want ?
if not with php,
it's not. PHP is a SERVER-side language, this means that it just has to 
do with all info that is sent to it. All info that is sent to it, are 
the HTTP request headers. Request headers are quite small, and usually 
don't contain too much info. Specific info like the DISPLAY variable are 
not included there.
 is possible to do it with javascript ?
well, since I don't know what the DISPLAY variable is, I can't say if 
it can or can't. However, a lot of things you can't do with PHP can be 
done with JS (especially things like getting more info about the 
browser/system)
thanx in advance
Bruno Santos
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Get name of extending class with static method call

2005-01-11 Thread Jason Barnett
M. Sokolewicz wrote:
try using __CLASS__
Torsten Roehr wrote:
This is a good suggestion but I wonder... Torsten do you have a large 
heirarchy of parent classes or just one parent?  E.g. Car - Sports Car 
- Porsche.  More importantly will __CLASS__ resolve to the class name 
that you need...

If __CLASS__ works for you then I would go with it.  If not can you just 
send the appropriate class name as a parameter?

--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Comparison Operator

2005-01-11 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 10 January 2005 21:20, Chadwick, Russell wrote:

 The function this is from sometimes uses $_POST or $_GET input, so
 sometimes its comparing 1337 with '1337' and === would break that.
 
 so I'll have to use something like:
 
 if (($value == $curval)  !(is_string ($curval)  ($value == 0)))

I would cast both sides of the comparison to the same type and then use the
identity operator.  So, depending on exactly what kind of comparison you
want (and maybe how safe your data are!), either of:

   if ((int)$value === (int)$curval)

   if (string)$value === (string)$curval)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] 2 dimensional array processing

2005-01-11 Thread Richard Lynch
Brent Baisley wrote:
 foreach($insert as $table = $fields) {
   $fieldList = array_keys($fields);
   $fieldNames = implode(',', $fieldList);
   $fieldValues = ''.implode(',', $fields).'';
   echo 'insert into '.$table.' ('.$fieldNames.') values
 ('.$fieldValues.')';
 }

 That puts double quotes around the values.

Which is not valid SQL, so won't work on most SQL engines.
[Though MySQL may be forgiving in this regard...]

$fieldValues = implode(', ', $fields);
would work on all standard SQL engines if ALL the fields were text (or
non-numeric).

Or, in MySQL, for integer/float as well, as MySQL lets you get away with
bogus (non-standard) apostrophes on numeric field values, so this will
work for MySQL even though it's morally wrong :-)

To make it really portable (standard SQL), you'd want to query your
database as to the type of each field and put apostrophes only around
non-numeric field values.

Or you could have some other way of keeping track of what's numeric and
what's not, of course.

 I always use single quotes
 around my text pieces since PHP doesn't parse what's inside them, thus
 it's supposed to be faster.

It's not measurably faster.

Even apostrophes have *some* internal processing (for embedded ' and \) so
there is no real difference in speed.

Benchmark it on your own machine to confirm.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] client information

2005-01-11 Thread Richard Lynch
Bruno Santos wrote:
 I have a problem that i hope to solve with php. i know that, using
 $_SERVER['xxx'] is possible to find some information about the client
 who is accessing the script.

PHP passes on *everything* the server passes on which is usually
*everything* the browser provides.

There is no more information hidden somewhere from you.

 what i need to know if its possible to find out more information about
 the client, like in linux the DISPLAY variable of the client ?

It's incredibly unlikely that Linux browsers provide this info to the web
server, so it's not going to be available to PHP.

 if i make a system call, i get the server information and thats not what
 i want ?
 if not with php, is possible to do it with javascript ?

JavaScript *might* let you read Environment variables, though I doubt it.

Google for JavaScript and Environment Variables and you should find it
if it's possible.

Perhaps if you explained why you want the DISPLAY variable we could
suggest some work-arounds...

I can't imagine what that would be, mind you, but...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] $_GET $_POST simultaneously

2005-01-11 Thread Richard Lynch
[EMAIL PROTECTED] wrote:
 If your question is a matter of Is this a good programming practice then
 I think it's ok.  There are times when something like this could be really
 useful.

There are many scripts I write which provide results for either GET or
POST data interchangably, so that links or forms can be used in the other
pages to fit in with their look/feel.

As far as mixing GET/POST goes, one reason for doing it would be this:
Suppose throughout your whole site, you are passing $username via GET.

But you have a FORM on one page with other information being sent via
POST, for the minor convenience benefits that POST provides.

To *keep* your username usage consistent, you pass username in the URL
being POSTed to.

This makes perfect sense to me, even if some don't like the idiom.

 Should people get into the practice of using this kind of thing?  I think
 it really depends on the circumstances and there's definitely times when
 it would just make things more confusing which is bad programming practice
 in general.

 So unless there's a web server that looks for POST data and ignores any
 GET data sent (which I've never heard of but I'm guessing that someone's
 managed to create a web server at one point that did this.. on purpose or
 not), then I think this is an ok technique if there's not a simpler one
 that does the same thing.

It's trivial to configure Apache to allow only GET or POST (or neither)
for any given directory:

http://httpd.apache.org/docs/mod/core.html#limit

 Simplicity is really the key, but it's nice to know that you CAN use GET
 and POST together if you want/need to.  Just as long as it's not
 complicating the situation for no reason.

 = = = Original message = = =

 Browser history: I do not want it to contain any URIs to files which
 require
 some sort of id variable passed.

 Example:
 1. http://www.entity.org/edit.php
 (should produce an error or redirect to entity list)

 2. http://www.entity.org/edit.php?id=1
 (should display editing interface)

 Now I really do not like to use redirects in case of errors. So I could
 constantly use (2) second form of URI, even in POST requests.

 But then, if I already have id in $_GET, why the redundancy of sending
 another id to $_POST?

Don't send the id in $_POST.
That's too confusing -- to have the same thing coming in via two vehicles.

You *can* do it, and consistently use either $_POST or $_GET to read the
variable, and ignore the other one, but why send data you *know* you'll
ignore?

 Is it just me or ... why on earth would you want to populate both GET
 and
 POST arrays through this obscure way of coding ?

See above.

 If you really have a form where you dont have a clue wether your data
 comes
 from GET or POST,

It's more like:  I don't care if the other programmer asks for my content
via GET or POST, I'll give it to him either way.

  Now what I am interested in is if this is valid behaviour regarding
 HTTP
  specification and if other platforms support this interference of GET
 and
  POST variables in request?

Completely valid, and that's why PHP has settings in php.ini to determine
precisely which ones over-ride with others in $_REQUEST (an array
combining POST+GET+COOKIES) as well as in the global variables if you turn
register_globals ON which you shouldn't.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] UBB Code correct use

2005-01-11 Thread Bruno B B Magalhães
Hi people,
I have a small class that encodes and decodes ubb code, no problem with 
this.. But..

My question is, what is the correct use of the translation routines in 
a CMS... I meam:

When creating a new article:
New article form  --- UBB Encode --- Database
  |
 Eg. b encoded to [b]
When editing an article:
Database --- UBB Decode --- Edit form --- UBB Encode --- Database
  |
  Eg. [b] becomes b
When viewing in the site:
Database --- UBB Decode --- Display
Did you get what my question is? :)
What is the correct order... I mean, because I am having problems when 
editing an article all the BRs are being duplicated, and other problems 
that have to do with the order.

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


Re: [PHP] Error loading extension dlls in WindosXP for PHP4.3.10

2005-01-11 Thread Richard Lynch
Ranjan K. Baisak wrote:
 I am using PHP4.3.10 in WindowsXP. When I am trying to
 use extension dlls e.g. php_xmlrpc.dll and when trying
 to restart Apache2 Web Server, I am getting error
 message as UnKnows():Unable to load dynamic library
 './php_xmlrpc.dll.dll' - The specified module could
 not be found. The DLL file php_xmlrpc.dll is already
 exists in Windows/System32 directory. Can anybody help
 me to how to use extension dlls.

Some questions for you:

Does it REALLY have an extra .dll on the end in the message?
Perhaps somebody goofed up somewhere, but rip of the '.dll' in your
php.ini and see what happens...

Did the php_xmlrpc.dll you have COME WITH the EXACT SAME php distribution?

If it's from some other version, do *NOT* try to mix-n-match it.

Worse than having it not work at all, is having it work flawlessly until
you try to use the function that changed in that DLL between 4.x.y and
4.x.z!

Where the PHP DLLs are located *should* be set in php.ini, but one first
has to be *sure* your php.ini file is being used.

Take a step back and turn off all the extensions and change something
innocuous in php.ini like the syntax highlighting colors (remember the old
settings) and load up a ?php phpinfo();? page.

Did your settings take effect?

If not, where is PHP looking for php.ini? (at the top of phpinfo output)

That's where your php.ini file has to go.

*THEN* you can change php.ini and put your PHP extensions where they
belong, which is almost for sure not down in your Windows\System32
directory (shudder).

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] client information

2005-01-11 Thread Greg Donald
On Tue, 11 Jan 2005 10:10:37 -0800 (PST), Richard Lynch [EMAIL PROTECTED] 
wrote:
  what i need to know if its possible to find out more information about
  the client, like in linux the DISPLAY variable of the client ?
 
 It's incredibly unlikely that Linux browsers provide this info to the web
 server, so it's not going to be available to PHP.

 php -r 'system(set|grep DISPLAY);'
DISPLAY=65-86-94-210.client.dsl.net:0.0


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



[PHP] Re: Get name of extending class with static method call

2005-01-11 Thread Torsten Roehr
Jason Barnett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 M. Sokolewicz wrote:
  try using __CLASS__
 
  Torsten Roehr wrote:
 

 This is a good suggestion but I wonder... Torsten do you have a large
 heirarchy of parent classes or just one parent?  E.g. Car - Sports Car
 - Porsche.  More importantly will __CLASS__ resolve to the class name
 that you need...

 If __CLASS__ works for you then I would go with it.  If not can you just
 send the appropriate class name as a parameter?

__CLASS__ contains the name of the class the method is in. In my sample it
would be 'Car' and not 'Porsche'.

What I don't understand is why the behaviour of debug_backtrace() has been
changed!?!

Regards, Torsten

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



Re: [PHP] Forms on PHP

2005-01-11 Thread Richard Lynch
PHPDiscuss - PHP Newsgroups and mailing lists wrote:
 I am new to this or any newsgroup in PHP, as well as PHP itself, so this
 question is probably rather elementary.  I have a form which on clicking
 on the Submit button calls up a compiled program on the server that is
 executed and writes output to a file.  This file is then read by the PHP
 script and passed on for other processes.

Yikes!

What if two guys surf to the same page AT THE SAME TIME?

Is this all being taken care of?

Or is this an admin page that only one guy ever uses, and he *KNOWS* not
to run it in two different browsers at the same time?  And you'll *NEVER*
try to run it for testing while he's trying to run it for real?  And...

This scenario is rife with potential problems.

 When the page is first loaded,
 it knows that the Submit button has not been clicked, and after clicking
 the button it knows, which is of course what we want.  The problem is that
 subsequently it always thinks the button has been clicked, even if the
 reload button on the browser has been clicked.

When I hit re-load, you get back *exactly* the same thing I sent you last
time.

$_POST and everything.

If you want to do something *different* then you need to keep a record of
the fact that I already POSTed this data.

For example, you could embed a http://php.net/uniqid in your FORM in a
HIDDEN INPUT, and then store that in a database, and if I POST again, you
can do whatever you want.

Don't call that external program, and just read the file from the previous
action but with an added notification that I'm reading old data, or send
me a different output, or ...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Get name of extending class with static method call

2005-01-11 Thread Torsten Roehr

Christopher Fulton [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Not sure if this is the best way to do it or not, but you can do this
 and it should (untested code) work.

 class Car {
 function drive() {
  return $this-getClassName();
 }
 function getClassName() {
   return Car;
 }
 }

 class Porshe {
  function getClassName() {
   return Porshe;
  }
 }

 $foo = new Porshe();
 echo $foo-drive();

Of course this might work but it requires the definition of such a method in
*every* class I have.

Any more ideas?

Thanks in advance!

Torsten

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



Re: [PHP] 403 not working -- apache 2 / php5 / linux

2005-01-11 Thread Richard Lynch
Rasmus Lerdorf wrote:
 Jason Barnett wrote:
 the wrong permissions.  Why does apache not server the 403 on the php
 page?  Maybe  this is better off in the apache list.

 Yeah, this is really better on an Apache list... but...
 http://httpd.apache.org/docs/mod/core.html#errordocument

 No, it has nothing to do with Apache.  Apache doesn't open the file, PHP
 does.  You could argue that PHP should try to throw a 403 on a
 permissions error, but the problem is that it is really too late in the
 game to do so once we get to the content handler phase where PHP lives.
 It could be hacked to do it a number of ways, but it wouldn't be pretty
 and it wouldn't be very consistent either since we would have to only do
 it if no output has been sent on the request yet.  So a sub-request or
 an auto-prepend would both change the behaviour.

Actually, as the naive PHP programmer, I'd only want it to happen if it
were the file matching the original URI request rather than no content
sent to the browser yet

Consider:
?php
  /* index.php */
  require 'connect.inc';
  require 'authenticate.inc';
?

If index.php is not readable, then a 403 would make sense to me.

But suppose index.php is readable, and so is connect.inc, but *not*
authenticate.inc:

chmod 644 index.php
chmod 644 connect.inc
chmod 000 authenticate.inc

If authenticate.inc were not readable, a 403 sent because PHP can't read
one of those files would just be morally wrong, even if no content went to
the browser yet.

Because it's real likely that *I* am sending a 403 as part of my script in
authenticate.inc, using HTTP Basic Authentication as described in the PHP
manual.

You'd be confusing the HELL out of me to have PHP sending out a 403
because it couldn't read the included file after it already managed to
read index.php and connect.inc

At that point, the problem is not that the page is not readable, but some
portion of PHP script is not readable, and I would expect PHP to know the
difference.

That may be an unreasonable expectation on my part, and maybe I'm just
spoiled by PHP's exemplary behaviour in the past of telling me exactly
which file where I managed to screw up, but that's what I expect from PHP
these days. :-)

I suspect that this makes it even more of a hack to try to do, and even
less likely, if it's even possible to be less likely, that it will be done
some day.

Throw in some mod_rewrite stuff and having PHP figure out when to do 403,
and when to complain that it can't read a file, will be probably be *way*
too much hackery.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] 403 not working -- apache 2 / php5 / linux

2005-01-11 Thread Rasmus Lerdorf
Richard Lynch wrote:
You'd be confusing the HELL out of me to have PHP sending out a 403
because it couldn't read the included file after it already managed to
read index.php and connect.inc
Right, I don't disagree with you that it would be confusing and 
inconsistent which is why no such magic is being done.  To me a PHP 
script with incorrect permissions is really no different from a PHP 
script with a syntax error in it.  In both cases you would want to know 
you screwed up and you just have to manage where these error messages 
should appear.

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


[PHP] Checking if

2005-01-11 Thread Bruno B B Magalhães
Hi people,
how to determine if the last char of a string is a '/'...
The problem, a webpage can be accessed by www.domain.com/page.php or  
www.domain.com/page.php/

Regards,
Bruno B B Magalhães
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Checking if

2005-01-11 Thread Ben Ramsey
Bruno B B Magalhães wrote:
how to determine if the last char of a string is a '/'...
The problem, a webpage can be accessed by www.domain.com/page.php or  
www.domain.com/page.php/
Use substr()...
http://www.php.net/substr
$url = 'http://example.com/index.php/';
if (strcmp(substr($url, -1), '/') == 0) {
// it ends with a '/'; strip it off
$url = substr($url, 0, -1);
}
--
Ben Ramsey
Zend Certified Engineer
http://benramsey.com
---
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Security - chmod 777 - PHP upload/write

2005-01-11 Thread Richard Lynch
SED wrote:
 Sometimes when I write a PHP-script and upload it to a ISP through
 password
 protected FTP, the only way to write data to a folder is to run chmod 777
 for that folder, I want to write (or save) a data to (e.g. file-upload,
 flat-file-database). However, if I do so, I have been told, everyone can
 write data to that file, which is a security risk. Is that true?

 If I do so, is it right that anyone can write a data to that folder? E.g.
 PHP-script that can reveal everything?

If it's 777, they don't even need to write a PHP script to read/write it.

ANYBODY with a login on the same server, or anybody who manages to break
into that server, will be able to read/write this file.

One common practice is to chown/chmod the files that PHP needs to
read/write so only the PHP user can read/write them.  If the PHP user (see
output of http://php.net/phpinfo) can read/write the files, but nobody
else can, you've raised the bar a little bit to access.

This then limits the access to PHP scripts.

Of course, some other user with a login can write a PHP script, load it in
their browser, and effectively be running as the PHP user and still
read/write your data, same as you.

If you think about this a bit, you'll realize that you've got a chicken
and egg problem:  If *your* PHP script can alter the data, so can theirs. 
If you make it so *their* PHP script can't alter the data, neither can
yours, and your application won't be real useful, eh?

[+} It was rumored at some point that Apache 2 would allow PHP Modules to
be run as different users in different VirtualHosts.  A recent post by
Rasmus makes me think that never happened.  But maybe it did.  RTFM.  If
you *can* set up your server that way, and make each VirtualHost run PHP
Module as a different user, then you can limit access in Apache 2 in a
better way.

You can add a *tiny* bit of a barrier by burying the stuff PHP can
read/write *outside* the web tree, and only display things on your server
using PHP to 'filter' the content.

For example, if you allow JPEGs to be uploaded, set up your PHP
readable/writeable directory in, say, ~/image instead of
~/public_html/images

Then you need a PHP script to 'display' the JPEG:
?php
  /* display.php */
  if (!isset($_SERVER['PATH_INFO'])){
trigger_error(Invalid attempt to use display.php without specifying
image filename, possibly for nefarious reasons., E_USER_ERROR);
exit;
  }
  $filename = $_SERVER['PATH_INFO'];
  $filename = preg_replace('/[A-Za-z0-9_\\.-]/', '', $filename);
  if ($filename != $_SERVER['PATH_INFO']){
trigger_error(Invalid character in image filename, possibly for
nefarious reasons., E_USER_ERROR);
exit;
  }
  readfile(/full/path/to/your/home/images/$filenaem);
?

You can even bury it *inside* a directory that the PHP user can *NOT*
read, so the Bad Guy has to guess at the name of the directory that they
can read, because it's inside a directory that they can't read:

mkdir access
chmod 600 access
mkdir access/images
chmod 700 access/images
chown apache access/images

So now the 'apache' user (may be 'nobody' or 'www' or ... on your system)
can do what it wants with the images directory, but somebody poking around
in your system won't *KNOW* there is an images directory, cuz they can't
read 'access' directory to find out it's there.

You then change the PHP display.php script to run some basic sanity checks
before presenting any JPEG to the browser.

You can, fairly easily:

Be sure that http://php.net/getimagesize 'works' on the JPEG, so it's
probably a JPEG and not some kind of Trojan/Virus/Whatever.

Only serve up images that were recorded through your application in the
database as having been uploaded.  So if somebody manages to put a JPEG in
your directory, they'd *also* have to hack into your MySQL data to add it
to the database.

Record an http://php.net/md5 hash of the file when it was uploaded, so if
somebody changes the file out from under you, you can do md5() again and
see that it was changed.

If all these security measures are insufficient for your application, then
it's time to buy a dedicated server, where there aren't any other PHP
users other than yourself [*] and then this is all moot.

[*] Of course, on a dedicated server, if a hacker breaks in, they can
probably run PHP and do these Bad Things but if they've already broken
in, you've got MUCH BIGGER PROBLEMS than your PHP-alterable data.

For *MOST* web applications, the measures outline here (or similar) are
sufficient, so you can make PHP secure enough to manage your risk to an
acceptable level on a shared server.

In some cases, you simply can't, and you need a dedicated server -- But
that's usually something you know you need anyway, for all the *OTHER*
security issues involved in the first place.

PS The ideas above are but a fraction of the kinds of things one can do to
limit access and sanity check content using PHP.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List 

[PHP] Re: Get name of extending class with static method call

2005-01-11 Thread Jason Barnett
__CLASS__ contains the name of the class the method is in. In my sample it
would be 'Car' and not 'Porsche'.
What I don't understand is why the behaviour of debug_backtrace() has been
changed!?!
Regards, Torsten
I have no idea why the behaviour changed (I didn't really use the 
function before, either).  And I see now the change in the manual that 
addresses this (essentially debug_backtrace gives you __CLASS__)

If you had an actual instance of the class you could use get_class, but 
alas you are using a static method call.  You punk.

The only other solution that comes to mind is a little messy but it lets 
you get away with no object.  Instead of calling the method statically 
you can use call_user_func_array() with the child class name as a 
parameter.  Then change the parent method to accept the child class name 
as a parameter.

?php
function call_static_child() {
  $drive_args = func_get_args();
  /** assume that first parameter is child of class Car */
  return call_user_func_array(array($drive_args[0], 'drive'), $drive_args);
}
?

--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://www.php.net/manual/en/index.php
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] client information

2005-01-11 Thread Richard Lynch
Greg Donald wrote:
 On Tue, 11 Jan 2005 10:10:37 -0800 (PST), Richard Lynch [EMAIL PROTECTED]
 wrote:
  what i need to know if its possible to find out more information about
  the client, like in linux the DISPLAY variable of the client ?

 It's incredibly unlikely that Linux browsers provide this info to the
 web
 server, so it's not going to be available to PHP.

 php -r 'system(set|grep DISPLAY);'
 DISPLAY=65-86-94-210.client.dsl.net:0.0

-r isn't listed in my php -h, so I dunno what it does, but...

I don't think that's the DISPLAY environment variable set by the CLIENT
surfing from their Linux box is it?

Is that not the DISPLAY you, the webmaster, are using for your shell?

Which, in the case of a PHP Module of Apache, is most likely '' since the
server probably doesn't even have X on it, much less a shell environment
for the 'apache' User, much less a default DISPLAY variable set for that
user...

Try putting your code on your web server and surfing to it.  What do you
get as output?

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] UBB Code correct use

2005-01-11 Thread Richard Lynch
Bruno B B Magalhães wrote:
 Hi people,

 I have a small class that encodes and decodes ubb code, no problem with
 this.. But..

 Did you get what my question is? :)
 What is the correct order... I mean, because I am having problems when
 editing an article all the BRs are being duplicated, and other problems
 that have to do with the order.

*ONLY* call your routines to change [b] to b and new-line to BR in
Display

Database --- UBB Decode --- Display

* Of course, if you have a Preview in your UBB, then that's also a
Display

But you'll go *NUTS* if you try to convert back and forth as often as you
are now.

Minimize the number of times you need to use your decoder.

In fact, you should *NEVER* need to go from B to [b] unless you import
content from some outside source to 'seed' your forum.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] geographic search engine

2005-01-11 Thread symbulos partners
We would like to implement a geographic search engine.

We have a list of places, the user enters a postcode + a radius in kms and
the search engine returns a list of places within a certain radius.

Any body has any experience with anything similar?
-- 
symbulos partners
-.-
symbulos - ethical services for your organisation
http://www.symbulos.com

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



Re: [PHP] Checking if

2005-01-11 Thread John Nichel
Bruno B B Magalhães wrote:
Hi people,
how to determine if the last char of a string is a '/'...
The problem, a webpage can be accessed by www.domain.com/page.php or  
www.domain.com/page.php/
preg_match ( /\/$/, $string );
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] client information

2005-01-11 Thread Greg Donald
On Tue, 11 Jan 2005 11:31:53 -0800 (PST), Richard Lynch [EMAIL PROTECTED] 
wrote:
 -r isn't listed in my php -h, so I dunno what it does, but...

r is for run.

 I don't think that's the DISPLAY environment variable set by the CLIENT
 surfing from their Linux box is it?

It's not, was that a requirement..  doh.

 Is that not the DISPLAY you, the webmaster, are using for your shell?

Yes it is.

 Which, in the case of a PHP Module of Apache, is most likely '' since the
 server probably doesn't even have X on it, much less a shell environment
 for the 'apache' User, much less a default DISPLAY variable set for that
 user...
 
 Try putting your code on your web server and surfing to it.  What do you
 get as output?

Not much.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



Re: [PHP] geographic search engine

2005-01-11 Thread Greg Donald
On Tue, 11 Jan 2005 19:57:15 +, symbulos partners
[EMAIL PROTECTED] wrote:
 We would like to implement a geographic search engine.
 
 We have a list of places, the user enters a postcode + a radius in kms and
 the search engine returns a list of places within a certain radius.

So often php-general is graced with the presence of people with
multiple personalities.. or are you really the borg?  :)

 Any body has any experience with anything similar?

I coded a zip code to distance calculater last week.

x = 69.1 * ( zip2.lat - zip1.lat )
y = 69.1 * ( zip2.lon - zip1.lon ) * cos( zip1.lat / 57.3 )
miles = sqrt( x^2 + y^2 )

This does not take into account the curve of the earth.  In addition
you'll need a db with the latitude and longitude for each zip code.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



Re: [PHP] $_GET $_POST simultaneously

2005-01-11 Thread Greg Donald
On Tue, 11 Jan 2005 10:26:05 -0800 (PST), Richard Lynch [EMAIL PROTECTED] 
wrote:
 There are many scripts I write which provide results for either GET or
 POST data interchangably, so that links or forms can be used in the other
 pages to fit in with their look/feel.

When I need to come in both ways, I just do stuff like:

$id = isset( $_POST[ 'id' ] ) ? $_POST[ 'id' ] : 0;
$id = isset( $_GET[ 'id' ] ) ? $_GET[ 'id' ] : $id;


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



Re: [PHP] Get name of extending class with static method call

2005-01-11 Thread Daniel Schierbeck
Torsten Roehr wrote:
Christopher Fulton [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Not sure if this is the best way to do it or not, but you can do this
and it should (untested code) work.
class Car {
   function drive() {
return $this-getClassName();
   }
   function getClassName() {
 return Car;
   }
}
class Porshe {
function getClassName() {
 return Porshe;
}
}
$foo = new Porshe();
echo $foo-drive();

Of course this might work but it requires the definition of such a method in
*every* class I have.
Any more ideas?
Thanks in advance!
Torsten
I'm not sure if this will work, but hey, you could give it a try.
class Car
{
  public static $className = __CLASS__;
  public static function drive ()
  {
return self::$className;
  }
}
class Porche extends Car
{
  public static $className = __CLASS__;
}
Porche::drive(); // Should return Porche
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] geographic search engine

2005-01-11 Thread Brian Dunning
On Jan 11, 2005, at 12:39 PM, Greg Donald wrote:
This does not take into account the curve of the earth.  In addition
you'll need a db with the latitude and longitude for each zip code.
If I might be so bold as to suggest one without getting flamed:
  http://www.zipwise.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Get name of extending class with static method call

2005-01-11 Thread Christopher Fulton
This should work for you then(maybe...i don't have php5 on my
system, so it may not, but i think it would.
http://us4.php.net/manual/en/function.get-class.php

class Car {
function drive() {
 return get_class($this);
}
 }

 class Porshe {
 }

$foo = new Porshe();
echo $foo-drive();

On Tue, 11 Jan 2005 14:24:46 -0500, Jason Barnett
[EMAIL PROTECTED] wrote:
 
  __CLASS__ contains the name of the class the method is in. In my sample it
  would be 'Car' and not 'Porsche'.
 
  What I don't understand is why the behaviour of debug_backtrace() has been
  changed!?!
 
  Regards, Torsten
 
 I have no idea why the behaviour changed (I didn't really use the
 function before, either).  And I see now the change in the manual that
 addresses this (essentially debug_backtrace gives you __CLASS__)
 
 If you had an actual instance of the class you could use get_class, but
 alas you are using a static method call.  You punk.
 
 The only other solution that comes to mind is a little messy but it lets
 you get away with no object.  Instead of calling the method statically
 you can use call_user_func_array() with the child class name as a
 parameter.  Then change the parent method to accept the child class name
 as a parameter.
 
 ?php
 
 function call_static_child() {
$drive_args = func_get_args();
/** assume that first parameter is child of class Car */
return call_user_func_array(array($drive_args[0], 'drive'), $drive_args);
 }
 
 ?
 
 
 --
 Teach a person to fish...
 
 Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
 PHP Manual: http://www.php.net/manual/en/index.php
 php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
 
 --
 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] Building key sequences from strings

2005-01-11 Thread Bruce Cooper

Oh wise and widely knowledgeable list:



  I'm trying to set up a custom sort for multi-level [i.e. nested] arrays.  The 
problem is I can't seem to get PHP to recognize syntax such as follows



$test=$test_array.'[index][next]';



 The above example is greatly simplified.  In the real world I'd be dynamically 
building that string to pin on the end.[i.e. I'd like to be able the drill down 
to a depth determined from inside a function rather than having to hard-code 
it]  I'm all confused.  The same type of syntax works for other variable 
types



What am I doing wrong ?



:Bruce Cooper

___
Join Excite! - http://www.excite.com
The most personalized portal on the Web!

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



Re: [PHP] Building key sequences from strings

2005-01-11 Thread Greg Donald
On Tue, 11 Jan 2005 16:10:00 -0500 (EST), Bruce Cooper
[EMAIL PROTECTED] wrote:
   I'm trying to set up a custom sort for multi-level [i.e. nested] arrays.  
 The problem is I can't seem to get PHP to recognize syntax such as follows
 
 $test=$test_array.'[index][next]';
 
  The above example is greatly simplified.  In the real world I'd be 
 dynamically building that string to pin on the end.[i.e. I'd like to be able 
 the drill down to a depth determined from inside a function rather than 
 having to hard-code it]  I'm all confused.  The same type of syntax works for 
 other variable types
 
 What am I doing wrong ?


Use eval() on the string after you construct it.

php.net/eval


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



[PHP] imagecreatefromjpeg

2005-01-11 Thread Juergen Rehberger
Hi

Thanx for the fast response to my problem

I have checked my memory limit in the php.ini file and it is 8mb as well on my 
offline server. i further noticed that on my online server it doesnt realy 
depend on the filesize in mb but rather the size in pixel. once i try to upload 
images larger than 1280*960 it gives me an error message. on my offline server 
this size is no problem.

I wonder why it tries to allocate so much memory in teh first place since the 
pics are not that big in size. the last one i tried was 300kb but had a 
resolution of 2272 / 1704px. its really weird.

Regards
J


Re: [PHP] Re: Get name of extending class with static method call

2005-01-11 Thread Daniel Schierbeck
Christopher Fulton wrote:
This should work for you then(maybe...i don't have php5 on my
system, so it may not, but i think it would.
http://us4.php.net/manual/en/function.get-class.php
class Car {
function drive() {
 return get_class($this);
}
 }
 class Porshe {
 }
$foo = new Porshe();
echo $foo-drive();
He needs a static function, ie Porche::drive()
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Apache 2.0 and Sessions

2005-01-11 Thread Stephen Craton
I just updated to Apache 2.0 and have gotten PHP all with it. However, I
just loaded up a script that worked fine on my old Apache 1.3 install but is
now causing my errors. Here's the error:

 

Warning: session_start():
open(C:\WINDOWS\TEMP\\sess_8c53cb2382f75076c51ed4b3edece36b, O_RDWR) failed:
No such file or directory (2) in D:\htdocs\payments\index.php on line 8

Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at D:\htdocs\payments\index.php:8) in
D:\htdocs\payments\index.php on line 8

 

I don't see why it's happening, especially since I went into php.ini (I'm on
Windows XP) and changed session.save_patch to this:

 

session.save_path = C:/PHP/sessiondata

 

Can anyone give me some input here? I think I see the problem, the whole
double back slash in the file location, but I don't see how to fix that.

 

Thanks,

Stephen Craton



[PHP] dba_open(), NFS file locking test please

2005-01-11 Thread Gerard Samuel
If you have php installed with the dba extension, and have access to NFS,
could you try out the code below, to see if it works for you.
Doesn't matter what OS you're using (as long as the OS professes its capable
of locking over NFS).
Im currently using FreeBSD 5.3 (server  client), with NFS  the lockd 
daemon running.

Dummy code -
?php
var_dump(dba_open('/path/to/nfs_mount/foo.dat', 'c', 'gdbm'));die;
?
Gives me -
Warning: dba_open(/path/to/nfs_mount/foo.dat,c) [function.dba-open]: 
Driver initialization failed for handler: gdbm: Can't be writer in 
/usr/home/gsam/www/index.php on line 2
bool(false)

It creates the file, but Im guessing that its unable to get a lock on it.
Im trying to figure out who is to blame for the failure.
Thanks for your time...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] imagecreatefromjpeg

2005-01-11 Thread Rasmus Lerdorf
Juergen Rehberger wrote:
Hi
Thanx for the fast response to my problem
I have checked my memory limit in the php.ini file and it is 8mb as well on my 
offline server. i further noticed that on my online server it doesnt realy 
depend on the filesize in mb but rather the size in pixel. once i try to upload 
images larger than 1280*960 it gives me an error message. on my offline server 
this size is no problem.
I wonder why it tries to allocate so much memory in teh first place since the pics are not that big in size. the last one i tried was 300kb but had a resolution of 2272 / 1704px. its really weird.
Not really that strange.  The internal manipulation format is 
uncompressed so you can work out exactly how much memory it needs simply 
by multiplying your resolution by the colour depth.  The fact that it is 
300k on your disk is completely irrelevant.

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


Re: [PHP] Re: Get name of extending class with static method call

2005-01-11 Thread Jason Barnett
Christopher Fulton wrote:
This should work for you then(maybe...i don't have php5 on my
system, so it may not, but i think it would.
http://us4.php.net/manual/en/function.get-class.php
class Car {
function drive() {
 return get_class($this);
}
 }
 class Porshe {
 }
$foo = new Porshe();
echo $foo-drive();
Chris, I was thinking of this as well.  Except that the method drive is 
actually a static method so the class definition for Car is (I'm 
assuming) more like this:

?php
class Car {
  static function drive() {
/** I am a static function, so $this should not exist! */
/** However, class constants and static variables are available */
  }
}
class Porsche extends Car { }
Porsche::drive();
?
Torsten, I also found the following link to be helpful.  Check out the 
user notes from michael at digitalgnosis dot removethis dot com (he did 
something similar to what I have already suggested, i.e. call_user_func)

http://www.php.net/manual/en/language.oop5.static.php

--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://www.php.net/manual/en/index.php
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] imagecreatefromjpeg

2005-01-11 Thread Jason Wong
On Wednesday 12 January 2005 05:55, Juergen Rehberger wrote:

 I have checked my memory limit in the php.ini file and it is 8mb as well on
 my offline server. 

Are you sure that your local server was compiled with --enable-memory-limit? 
The memory limit set in php.ini will only be enforced if you have 
--enable-memory-limit.

 i further noticed that on my online server it doesnt 
 realy depend on the filesize in mb but rather the size in pixel. once i try
 to upload images larger than 1280*960 it gives me an error message. on my
 offline server this size is no problem.

 I wonder why it tries to allocate so much memory in teh first place since
 the pics are not that big in size. the last one i tried was 300kb but had a
 resolution of 2272 / 1704px. its really weird.

That's because 2272 x 1704 x (3 bytes/pixel) = a lot of memory

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



Re: [PHP] Building key sequences from strings

2005-01-11 Thread Jason Barnett
Greg Donald wrote:
On Tue, 11 Jan 2005 16:10:00 -0500 (EST), Bruce Cooper
[EMAIL PROTECTED] wrote:
 I'm trying to set up a custom sort for multi-level [i.e. nested] arrays.  The 
problem is I can't seem to get PHP to recognize syntax such as follows
$test=$test_array.'[index][next]';
Perhaps this will work for you.
?php
$index1 = 'index';
$index2 = 'next';
$test_array[$index1][$index2] = 'some value';
var_dump($test_array[$index1][$index2]);
?
--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://www.php.net/manual/en/index.php
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Building key sequences from strings

2005-01-11 Thread John Holmes
Bruce Cooper wrote:
I'm trying to set up a custom sort for 
multi-level [i.e. nested] arrays.  The problem 
is I can't seem to get PHP to recognize syntax 
such as follows

$test=$test_array.'[index][next]';
Maybe
$test = ${$test_array.'[index][next]'};
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] dba_open(), NFS file locking test please

2005-01-11 Thread Gerard Samuel
Gerard Samuel wrote:
If you have php installed with the dba extension, and have access to NFS,
could you try out the code below, to see if it works for you.
Doesn't matter what OS you're using (as long as the OS professes its 
capable
of locking over NFS).

Im currently using FreeBSD 5.3 (server  client), with NFS  the lockd 
daemon running.

Dummy code -
?php
var_dump(dba_open('/path/to/nfs_mount/foo.dat', 'c', 'gdbm'));die;
?
Gives me -
Warning: dba_open(/path/to/nfs_mount/foo.dat,c) [function.dba-open]: 
Driver initialization failed for handler: gdbm: Can't be writer in 
/usr/home/gsam/www/index.php on line 2
bool(false)

It creates the file, but Im guessing that its unable to get a lock on it.
Im trying to figure out who is to blame for the failure. 

Well I figured out who is to blame for the failure.
The man in the mirror :(
I didn't have lockd running on the client box.
But now it is working correctly, so there is no need to run the test.
Thanks
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Get name of extending class with static method call

2005-01-11 Thread M. Sokolewicz
Daniel Schierbeck wrote:
Christopher Fulton wrote:
This should work for you then(maybe...i don't have php5 on my
system, so it may not, but i think it would.
http://us4.php.net/manual/en/function.get-class.php
class Car {
function drive() {
 return get_class($this);
}
 }
 class Porshe {
 }
$foo = new Porshe();
echo $foo-drive();
He needs a static function, ie Porche::drive()
PHP 5.1 does have support for $this in static objects though ;) but 
there's some special case because of which it has that... can't remember 
what or how. I might be off on this entirely though aswell :P

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


[PHP] Re: geographic search engine

2005-01-11 Thread Manuel Lemos
Hello,
on 01/11/2005 05:57 PM Symbulos Partners said the following:
We would like to implement a geographic search engine.
We have a list of places, the user enters a postcode + a radius in kms and
the search engine returns a list of places within a certain radius.
Any body has any experience with anything similar?
Here you may find a couple of solutions that search a database of post 
codes with coordinates to find which are within the range:

http://www.phpclasses.org/phpziplocator
http://www.phpclasses.org/zipcodesrange
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] drag and drop CMS made with php

2005-01-11 Thread Graham Anderson
is there a php based CMS that exists that allows you to drag/drop and 
reorder tracks ?
something akin to itunes or winamp  playlist...

I want users to be able to the change 'order_id'  field  in the 
'PlaylistItems' table...basically a bunch of UPDATE statements to a 
found set.  Basically, the user drags a playlist record and moves it to 
another area in the playlist...

does this allready exist somewhere?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Apache 2.0 and Sessions

2005-01-11 Thread Jerry Kita
Stephen Craton wrote:
I just updated to Apache 2.0 and have gotten PHP all with it. However, I
just loaded up a script that worked fine on my old Apache 1.3 install but is
now causing my errors. Here's the error:
 

Warning: session_start():
open(C:\WINDOWS\TEMP\\sess_8c53cb2382f75076c51ed4b3edece36b, O_RDWR) failed:
No such file or directory (2) in D:\htdocs\payments\index.php on line 8
Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at D:\htdocs\payments\index.php:8) in
D:\htdocs\payments\index.php on line 8
 

I don't see why it's happening, especially since I went into php.ini (I'm on
Windows XP) and changed session.save_patch to this:
 

session.save_path = C:/PHP/sessiondata
 

Can anyone give me some input here? I think I see the problem, the whole
double back slash in the file location, but I don't see how to fix that.
 

Thanks,
Stephen Craton

Stephen,
Not sure I can see your error either but here's a thought that might be 
useful. I run Apache 2.0 on my laptop with PHP 4.3.4. Sessions work fine 
for me. For various reasons I chose to set my session.save_path at the 
beginning of every script and it works fine. Here's the line of code I use:

session_save_path('c:\Program Files\Apache Group\Apache2\htdocs\tmp');
Again  it doesn't answer the question you're asking but it might be 
an approach that's easy for you to implement. I do it via an include().

--
Jerry Kita
http://www.salkehatchiehuntersville.com
email: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Re: Apache 2.0 and Sessions

2005-01-11 Thread Stephen Craton
Thanks for the reply, and I apologize for being a top poster, just a habit.

I would do that, and it is a good idea, just not practical since I usually
upload or publish the scripts I have on here to a server or to other people.
What I have here will not work on their servers if I do this. I could just
comment that line out, granted, but it doesn't seem practical for my
situation. Thanks for the suggestion though!

Thanks,
Stephen Craton

-Original Message-
From: Jerry Kita [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 11, 2005 7:03 PM
To: php-general@lists.php.net
Subject: [PHP] Re: Apache 2.0 and Sessions

Stephen Craton wrote:
 I just updated to Apache 2.0 and have gotten PHP all with it. However, I
 just loaded up a script that worked fine on my old Apache 1.3 install but
is
 now causing my errors. Here's the error:
 
  
 
 Warning: session_start():
 open(C:\WINDOWS\TEMP\\sess_8c53cb2382f75076c51ed4b3edece36b, O_RDWR)
failed:
 No such file or directory (2) in D:\htdocs\payments\index.php on line 8
 
 Warning: session_start(): Cannot send session cache limiter - headers
 already sent (output started at D:\htdocs\payments\index.php:8) in
 D:\htdocs\payments\index.php on line 8
 
  
 
 I don't see why it's happening, especially since I went into php.ini (I'm
on
 Windows XP) and changed session.save_patch to this:
 
  
 
 session.save_path = C:/PHP/sessiondata
 
  
 
 Can anyone give me some input here? I think I see the problem, the whole
 double back slash in the file location, but I don't see how to fix that.
 
  
 
 Thanks,
 
 Stephen Craton
 
 
Stephen,

Not sure I can see your error either but here's a thought that might be 
useful. I run Apache 2.0 on my laptop with PHP 4.3.4. Sessions work fine 
for me. For various reasons I chose to set my session.save_path at the 
beginning of every script and it works fine. Here's the line of code I use:

session_save_path('c:\Program Files\Apache Group\Apache2\htdocs\tmp');

Again  it doesn't answer the question you're asking but it might be 
an approach that's easy for you to implement. I do it via an include().

-- 
Jerry Kita

http://www.salkehatchiehuntersville.com

email: [EMAIL PROTECTED]

-- 
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] stdClass to array

2005-01-11 Thread Cere Davis

Hey folks,

Does anyone know of a painless way to convert a stdClass object to an
associative array in php?

Also, I wonder, is there a way to flatten associative arrays in php?
So say:  
$b=new array(s=S)
$a=new array(a=A,b=$b) 

goes to:
 $z=flatten($a);
z turns to:
 (a=A, b=$b, s=S);

Thanks,
Cere

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



RE: [PHP] stdClass to array

2005-01-11 Thread Michael Sims
Cere Davis wrote:
 Hey folks,
 
 Does anyone know of a painless way to convert a stdClass object to an
 associative array in php?

Just cast it:

$arr = (array) $stdClassInstance;

 Also, I wonder, is there a way to flatten associative arrays in php?
 So say:
 $b=new array(s=S)
 $a=new array(a=A,b=$b)
 
 goes to:
  $z=flatten($a);
 z turns to:
  (a=A, b=$b, s=S);

array_merge()

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

HTH

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



[suspicious - maybe spam] [PHP] [suspicious - maybe spam] how to use a URL as a filename

2005-01-11 Thread shimuqiheb
I want to get a file 'http://www.china.com/' , I can use 
file_get_contents('http://www.china.com/');
But how can I get it via a Proxy.



 Shi MuQi 
 LangFang ABC (China)  v 
 Tel:(86)-311-7876466 /(_)\ 
E-mail:[EMAIL PROTECTED]  ^ ^ 




RE: [PHP] Apache 2.0 and Sessions

2005-01-11 Thread Stephen Craton
Not a production server, just a development server. It doesn't bail either,
it still displays the page correctly, but no sessions work, obviously.

Thanks,
Stephen Craton

-Original Message-
From: Bret Hughes [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 11, 2005 7:24 PM
To: Stephen Craton
Subject: Re: [PHP] Apache 2.0 and Sessions

On Tue, 2005-01-11 at 16:02, Stephen Craton wrote:
 I just updated to Apache 2.0 and have gotten PHP all with it. However, I
 just loaded up a script that worked fine on my old Apache 1.3 install but
is
 now causing my errors. Here's the error:
 
  
 
 Warning: session_start():
 open(C:\WINDOWS\TEMP\\sess_8c53cb2382f75076c51ed4b3edece36b, O_RDWR)
failed:
 No such file or directory (2) in D:\htdocs\payments\index.php on line 8
WAG
sounds like the apache/php user does not have rights to write to
C:\WINDOWS\TEMP.  is that possible?
/WAG

 
 Warning: session_start(): Cannot send session cache limiter - headers
 already sent (output started at D:\htdocs\payments\index.php:8) in
 D:\htdocs\payments\index.php on line 8
 

this is probably because your script does not bail if there is a problem
with establishing a session.  Since php sent the error message the rest
could not happen.

It looks like your php is set to send error msgs. not a good idea on a
production server as was discussed in a thread the last day or so.

Bret


  
 
 I don't see why it's happening, especially since I went into php.ini (I'm
on
 Windows XP) and changed session.save_patch to this:
 
  
 
 session.save_path = C:/PHP/sessiondata
 
  
 
 Can anyone give me some input here? I think I see the problem, the whole
 double back slash in the file location, but I don't see how to fix that.
 
  
 
 Thanks,
 
 Stephen Craton
 

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



Re: [PHP] drag and drop CMS made with php

2005-01-11 Thread Andrew Kreps
On Tue, 11 Jan 2005 15:53:39 -0800, Graham Anderson [EMAIL PROTECTED] wrote:
 is there a php based CMS that exists that allows you to drag/drop and
 reorder tracks ?
 something akin to itunes or winamp  playlist...
 

I'm not entirely sure you could make this work, if you're speaking of
a web app.  On my Firefox browser running under Linux, I can select
and drag text and links from the page I'm on into the textbox I'm
using to reply to this message.  But, in order to make it actually
work, you'd need some sort of form field on the page between each
track, which would auto-submit when it receives text (which you can do
via javascript).  You'd also need code to decipher what's being sent
to figure out what in the database it relates too.  I also think it
would be entirely browser dependent, which can't be a good thing.  It
sounds like a lot of work to me, although you might have fun creating
it.  :)

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



[PHP] weird upload problem

2005-01-11 Thread Sebastian
Hi,
im working on this mulitiple upload script to auto resize images. everything
works, except two problems.
1) for some odd reason if i attach all fields with an image it only submits
5. seems its skipping one.
2) if i attach an image to field 1, 3, 5 and skip the other fields only 1
file gets uploaded.. how do i make it so it doesnt matter which fields are
used? just submit whatever fields(s) are used.. i snipped a lot of the code
off the script so its easier to find the problem.. maybe i just overlooked
something.

form action=/ enctype=multipart/form-data method=post
1: input type=file name=image[]br /
2: input type=file name=image[]br /
3: input type=file name=image[]br /
4: input type=file name=image[]br /
5: input type=file name=image[]br /
6: input type=file name=image[]br /
input name=submit type=submit value=submit
/form


if (isset($_FILES['image']))
{
 $number = 0;
for ($i = 0; $i  count($_FILES['image']); $i++)
{
$number++;
$imageid = time();

resize_img('image', $imageid.$number, $original_width,
$original_height));
resize_img('image', 't'.$imageid.$number, $new_width, $new_height));

}
}

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



Re: [PHP] Re: Get name of extending class with static method call

2005-01-11 Thread Rory Browne
I was kinda thinking about all that too, for  a project I'm currently
doing, in that I wanted to be able to create a singleton, without
having to put the singleton code in each class. The only hack I could
think of was to use debug_backtrace() to get the line of source that
contained the call, and parse(reparse) it manually.

Bare in mind that this is EXTREMELY UGLY, and probably extremely slow,
and unprofessional, but as a wise man once said(Andrew Morton IIRC),
if there is no implemention there is nothing to improve on, but if you
provide a crappy solution, you can rally people to improve on it.

If you're new to PHP, or prone to picking up bad habits, stop reading now.

eg

?pseudo_code

class Base {

function static_get_class_name(){
 list($file, $line, $method) =
get_calling_file_and_line_and_method_from_debug_backtrace();
 $codeline = file($file)[$line];
 preg_match(/([a-zA-Z_][a-zA-Z0-9_]*)::$method_name/, $codeline, $match);
 return $match[1];
}

}



On Tue, 11 Jan 2005 11:38:55 -0500, Jason Barnett
[EMAIL PROTECTED] wrote:
 M. Sokolewicz wrote:
  try using __CLASS__
 
  Torsten Roehr wrote:
 
 
 This is a good suggestion but I wonder... Torsten do you have a large
 heirarchy of parent classes or just one parent?  E.g. Car - Sports Car
 - Porsche.  More importantly will __CLASS__ resolve to the class name
 that you need...
 
 If __CLASS__ works for you then I would go with it.  If not can you just
 send the appropriate class name as a parameter?
 
 --
 Teach a person to fish...
 
 Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
 PHP Manual: http://php.net/manual/
 php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
 
 --
 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] Re: Apache 2.0 and Sessions

2005-01-11 Thread Jerry Kita
Stephen Craton wrote:
Thanks for the reply, and I apologize for being a top poster, just a habit.
I would do that, and it is a good idea, just not practical since I usually
upload or publish the scripts I have on here to a server or to other people.
Steve  My laptop is my development server but my production work is 
on a public server. I apologize for not giving you a complete 
description of what I do ... I set my session.save_path on the public 
server by creating a TMP directory in my Public_html folder. I've 
created an IF THEN ELSE that recognizes whether the code is being 
executed on my laptop or at the public server. The entire include() file 
is as follows:

?php
if ($_SERVER['SERVER_NAME'] == localhost)
{
 session_save_path('c:\Program Files\Apache Group\Apache2\htdocs\tmp');
  } else { 
session_save_path('/...x/public_html/tmp'); 

}
?
Works great ... and the old session files in the public_html/tmp 
directory get cleaned out automatically.

Still might not be practical for you for other reasons but I thought I 
should give you a more complete answer .. Jerry

What I have here will not work on their servers if I do this. I could just
comment that line out, granted, but it doesn't seem practical for my
situation. Thanks for the suggestion though!
Thanks,
Stephen Craton
-Original Message-
From: Jerry Kita [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 11, 2005 7:03 PM
To: php-general@lists.php.net
Subject: [PHP] Re: Apache 2.0 and Sessions

Stephen Craton wrote:
I just updated to Apache 2.0 and have gotten PHP all with it. However, I
just loaded up a script that worked fine on my old Apache 1.3 install but
is
now causing my errors. Here's the error:

Warning: session_start():
open(C:\WINDOWS\TEMP\\sess_8c53cb2382f75076c51ed4b3edece36b, O_RDWR)
failed:
No such file or directory (2) in D:\htdocs\payments\index.php on line 8
Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at D:\htdocs\payments\index.php:8) in
D:\htdocs\payments\index.php on line 8

I don't see why it's happening, especially since I went into php.ini (I'm
on
Windows XP) and changed session.save_patch to this:

session.save_path = C:/PHP/sessiondata

Can anyone give me some input here? I think I see the problem, the whole
double back slash in the file location, but I don't see how to fix that.

Thanks,
Stephen Craton

Stephen,
Not sure I can see your error either but here's a thought that might be 
useful. I run Apache 2.0 on my laptop with PHP 4.3.4. Sessions work fine 
for me. For various reasons I chose to set my session.save_path at the 
beginning of every script and it works fine. Here's the line of code I use:

session_save_path('c:\Program Files\Apache Group\Apache2\htdocs\tmp');
Again  it doesn't answer the question you're asking but it might be 
an approach that's easy for you to implement. I do it via an include().


--
Jerry Kita
http://www.salkehatchiehuntersville.com
email: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] weird upload problem

2005-01-11 Thread Sebastian
well i found the problem to #1. i forgot an = on the for() loop.. so it
uploads all 6 instead of 5. still looking for a solution on #2

- Original Message - 
From: Sebastian [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Tuesday, January 11, 2005 8:59 PM
Subject: [PHP] weird upload problem


 Hi,
 im working on this mulitiple upload script to auto resize images.
everything
 works, except two problems.
 1) for some odd reason if i attach all fields with an image it only
submits
 5. seems its skipping one.
 2) if i attach an image to field 1, 3, 5 and skip the other fields only 1
 file gets uploaded.. how do i make it so it doesnt matter which fields are
 used? just submit whatever fields(s) are used.. i snipped a lot of the
code
 off the script so its easier to find the problem.. maybe i just overlooked
 something.

 form action=/ enctype=multipart/form-data method=post
 1: input type=file name=image[]br /
 2: input type=file name=image[]br /
 3: input type=file name=image[]br /
 4: input type=file name=image[]br /
 5: input type=file name=image[]br /
 6: input type=file name=image[]br /
 input name=submit type=submit value=submit
 /form


 if (isset($_FILES['image']))
 {
  $number = 0;
 for ($i = 0; $i  count($_FILES['image']); $i++)
 {
 $number++;
 $imageid = time();

 resize_img('image', $imageid.$number, $original_width,
 $original_height));
 resize_img('image', 't'.$imageid.$number, $new_width,
$new_height));

 }
 }

 -- 
 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] weird upload problem

2005-01-11 Thread Jason Wong
On Wednesday 12 January 2005 09:59, Sebastian wrote:

 2) if i attach an image to field 1, 3, 5 and skip the other fields only 1
 file gets uploaded.. 

How did you ascertain this? What does print_r($_FILES) show? Unless you're 
using a broken browser it *should* work.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



Re: [PHP] Forms on PHP

2005-01-11 Thread PHPDiscuss - PHP Newsgroups and mailing lists
Leon Poon wrote:

 Refer to the following line numbers:

 01  ?php
 02  // Start of PHP code - Extract values from form.
 03  /* Other values read */
 04  $n=$_POST['n'];
 05 
 06  // Pass the data from the form to lightcurve_csharp
 07  $command=./lightcurve_csharp $a $i $e $lomega $bomega $lambda $n;
 08  $result=`$command`;
 09 
 10  $form_submitted=$_POST['form_sumbitted'];
 11  if (isset($form_submitted)) {
 12 if ($form_submitted) {
 13 echo 'The form has been submittedbr';
 14 unset($form_submitted);
 15 }
 16  } else
 17 echo 'The form has not been submittedbr';

 When the user first load the page, no data was posted. So there was no 
 $_POST['form_sumbitted'] available. Line 10 will cause $form_submitted to 
 contain the NULL value (I think). $form_submitted will evaluate to FALSE at 
 line 12. Thus it will not display any message.

 By the way, by doing line 10, $form_submitted would have been set regardless 
 whether there is $_POST['form_sumbitted'], and line 11 will evaluate to TRUE 
 always. Thus you will never ever see the 'form not been submitted' message.

 Anyway, when you posted for the first time, $_POST['form_sumbitted'] is 
 available. The 'The form has been submittedbr' message will be printed. 
 After that, when you press Reload button on the browser, the post data will 
 once again be sent from the user. (This is the behaviour of reloading a 
 posted page. In Internet Explorer there should be a message dialog box 
 asking the user whether to resend form data in order to refresh.) Reposting 
 the data during the reload means that there will be 
 $_POST['form_sumbitted'], thus once again the 'form hass been submitted' 
 message.

 In order to prevent this from happening, you should do a header('Location: 
 success-page.php') on a successful submit. This is so that at the redirected 
 page, the user would not have resent data even if he press the Reload 
 button.

 Hope this helps



 -Leon

Many thanks - at the top of the file I put in the code:

if ($_POST['submit'])
header('Location: .../submitted.php');

where further down in the form I have name=submit for the submit button.
 This goes to a new page submitted.php.  The code is in fact now at
http://proteus.as.arizona.edu/~csharp/lightcurved.php .

No doubt there is still a way of writing back to the original page after
the submit button has been clicked, but I can't see an easy way, so this
will have to do for now.  A work-around is to do it in frames, and write
to a frame at the bottom so that it appears to be in the same page.

Christopher Sharp

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



Re: [PHP] weird upload problem

2005-01-11 Thread Sebastian
Jason Wong wrote:

 How did you ascertain this? What does print_r($_FILES) show? Unless you're
 using a broken browser it *should* work.


i tried both IE6 and Firebox 1.0, both do the same.
does appear its being passed.. doesn't it? array:
Array
(
[image] = Array
(
[name] = Array
(
[0] = image1.jpg
[1] =
[2] = image2.jpg
[3] =
[4] =
[5] = image3.jpg
)

[type] = Array
(
[0] = image/pjpeg
[1] =
[2] = image/pjpeg
[3] =
[4] =
[5] = image/pjpeg
)

[tmp_name] = Array
(
[0] = /tmp/php6ubg5D
[1] =
[2] = /tmp/phpYjSRr2
[3] =
[4] =
[5] = /tmp/phpuqTWXO
)

[error] = Array
(
[0] = 0
[1] = 4
[2] = 0
[3] = 4
[4] = 4
[5] = 0
)

[size] = Array
(
[0] = 83330
[1] = 0
[2] = 83330
[3] = 0
[4] = 0
[5] = 83330
)

)

)

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



Re: [PHP] weird upload problem

2005-01-11 Thread Santa
So, in $_FILES all right.

may be use foreach instead for?
case count() show count of fulled cell of array, and in your case it show 3. 
but 3 is not end of your array.



12  2005 07:16 Sebastian (a):
 Jason Wong wrote:
  How did you ascertain this? What does print_r($_FILES) show? Unless
  you're using a broken browser it *should* work.

 i tried both IE6 and Firebox 1.0, both do the same.
 does appear its being passed.. doesn't it? array:
 Array
 (
 [image] = Array
 (
 [name] = Array
 (
 [0] = image1.jpg
 [1] =
 [2] = image2.jpg
 [3] =
 [4] =
 [5] = image3.jpg
 )

 [type] = Array
 (
 [0] = image/pjpeg
 [1] =
 [2] = image/pjpeg
 [3] =
 [4] =
 [5] = image/pjpeg
 )

 [tmp_name] = Array
 (
 [0] = /tmp/php6ubg5D
 [1] =
 [2] = /tmp/phpYjSRr2
 [3] =
 [4] =
 [5] = /tmp/phpuqTWXO
 )

 [error] = Array
 (
 [0] = 0
 [1] = 4
 [2] = 0
 [3] = 4
 [4] = 4
 [5] = 0
 )

 [size] = Array
 (
 [0] = 83330
 [1] = 0
 [2] = 83330
 [3] = 0
 [4] = 0
 [5] = 83330
 )

 )

 )

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



Re: [PHP] Error loading extension dlls in WindosXP for PHP4.3.10

2005-01-11 Thread Ranjan K. Baisak

--- Richard Lynch [EMAIL PROTECTED] wrote:
 
 Some questions for you:
 
 Does it REALLY have an extra .dll on the end in the
 message?
 Perhaps somebody goofed up somewhere, but rip of the
 '.dll' in your
 php.ini and see what happens...
 
 Did the php_xmlrpc.dll you have COME WITH the EXACT
 SAME php distribution?
 
 If it's from some other version, do *NOT* try to
 mix-n-match it.
 
 Worse than having it not work at all, is having it
 work flawlessly until
 you try to use the function that changed in that DLL
 between 4.x.y and
 4.x.z!
 
 Where the PHP DLLs are located *should* be set in
 php.ini, but one first
 has to be *sure* your php.ini file is being used.
 
 Take a step back and turn off all the extensions and
 change something
 innocuous in php.ini like the syntax highlighting
 colors (remember the old
 settings) and load up a ?php phpinfo();? page.
 
 Did your settings take effect?
 
 If not, where is PHP looking for php.ini? (at the
 top of phpinfo output)
 
 That's where your php.ini file has to go.
 
 *THEN* you can change php.ini and put your PHP
 extensions where they
 belong, which is almost for sure not down in your
 Windows\System32
 directory (shudder).
 
Well Richard, I could able to solve it by copying all
dlls into Windows\System32 directory. But still not
sure why I need to copy all dlls into system32
directory though I have mentioned in php.ini file that
extension_directory=c:\PHP4\extensions.

regards,
Ranjan



__ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 

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



Re: [PHP] weird upload problem

2005-01-11 Thread Jason Wong
On Wednesday 12 January 2005 12:16, Sebastian wrote:

 i tried both IE6 and Firebox 1.0, both do the same.
 does appear its being passed.. doesn't it? array:
 Array
 (
 [image] = Array
 (
 [name] = Array
 (
 [0] = image1.jpg
 [1] =
 [2] = image2.jpg
 [3] =
 [4] =
 [5] = image3.jpg
 )

Certainly looks like they're uploaded OK.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



[PHP] HTTP Proxy Script

2005-01-11 Thread John Camp
I am looking for a script that uses GET data to retrieve a website and 
display it to whoever requested it (a HTTP proxy).  If it can translate 
links to go through the proxy as well it would be even better. Thanks.

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


Re: [PHP] $_GET $_POST simultaneously

2005-01-11 Thread Curt Zirzow
* Thus wrote Bostjan Skufca @ domenca.com:
 Hello,
 
 If I create form like this
 form name=form action=##_URI_ROOT##/entity/edit.php?a=b method=post
   input type=hidden name=action value=modify /
 ...

 Now what I am interested in is if this is valid behaviour regarding HTTP 
 specification and if other platforms support this interference of GET and 
 POST variables in request?

Well the action should tell the browser to request:
  POST /root/entity/edit.php?a=b
 
And supply the appropiate data to be posted.

if the browser does do this then it is up to php to populate the
GET and POST varibles, and if memory server me right, this has been
done since early php3.


Now as to wether the client support's passing the full action URI's
to the server, i've only had issues with early version's of IE4.

Basically the only difference between a GET and POST is a POST has
extra data that is sent, besides some minor issues like what when
and how to cache post form.

HTH,

Curt
-- 
Quoth the Raven, Nevermore.

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



[PHP] Re: HTTP Proxy Script

2005-01-11 Thread Manuel Lemos
Hello,
on 01/12/2005 04:54 AM John Camp said the following:
I am looking for a script that uses GET data to retrieve a website and 
display it to whoever requested it (a HTTP proxy).  If it can translate 
links to go through the proxy as well it would be even better. Thanks.
You may want to try this HTTP client class that you can use to forward 
any type of HTTP requests.

http://www.phpclasses.org/httpclient
As for link translation, I think you need to use some regular 
expressions to translate the URLs of links, images, forms, etc...

--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] T1 Lib

2005-01-11 Thread PJ
Hello everybody!
I have some connection problems when I am searching topics in ThunderB., 
so I am sorry if my question is somewhere answered!

Does anybody know, where to download T1Lib for PHP4 - windows version? 
After half hour googling I have feeling that it doesn't exist... :o(

So, I would be very very glad, if there is someone, who can help me by 
posting link or dll via mail!

Thanks a lot!
Pavel
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] libphp4.so not created on upgrade

2005-01-11 Thread heath boutwell

--- Rasmus Lerdorf [EMAIL PROTECTED] wrote:
 Well, what is created?  Do you get a .libs/libphp4 file with no 
 extension?  If so, you can either just rename that to .libs/libphp4.so 
 or run libtoolize --force and re-run ./configure
 
 -Rasmus
 

Still no libphp4.so created by make install.

Here is results from libtoolize --force
Using `AC_PROG_RANLIB' is rendered obsolete by `AM_PROG_LIBTOOL'
You should add the contents of `/usr/share/aclocal/libtool.m4' to `aclocal.m4'.

Here are the files created by make install:
Installing PHP SAPI module:   cgi
Installing PHP CGI into: /usr/bin/
Installing shared extensions: 
/usr/lib/php4/extensions/no-debug-non-zts-20020429/
Installing PEAR environment:  /usr/lib/php4/php/
[PEAR] Archive_Tar- already installed: 1.2
[PEAR] Console_Getopt - already installed: 1.2
[PEAR] PEAR   - already installed: 1.3.2
Wrote PEAR system config file at: /usr/etc/pear.conf
You may want to add: /usr/lib/php4/php to your php.ini include_path
[PEAR] DB - already installed: 1.6.8
[PEAR] HTTP   - already installed: 1.3.3
[PEAR] Mail   - already installed: 1.1.4
[PEAR] Net_SMTP   - already installed: 1.2.6
[PEAR] Net_Socket - already installed: 1.0.2
[PEAR] XML_Parser - already installed: 1.2.1
[PEAR] XML_RPC- already installed: 1.1.0
Installing build environment: /usr/lib/php/build/
Installing header files:  /usr/include/php/
Installing helper programs:   /usr/bin/
  program: phpize
  program: php-config
  program: phpextdist
  
  
I get no errors in the make/make test/make install stages.  Why isn't 
libphp4.so created?  It also
seems bizarre that I am the only person that has encountered this.

Thanks.



__ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250

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