php-general Digest 9 Oct 2006 12:30:31 -0000 Issue 4391

2006-10-09 Thread php-general-digest-help

php-general Digest 9 Oct 2006 12:30:31 - Issue 4391

Topics (messages 242831 through 242839):

Re: Apply the hyper link ( javascript functon ) with php
242831 by: J R
242838 by: edwardspl.ita.org.mo

Re: guess documentroot
242832 by: Ivo F.A.C. Fokkema

Re: FTP
242833 by: Chris

ereg_replace with unser defined function?
242834 by: Frank Arensmeier
242839 by: Roman Neuhauser

POPUP window in PHP
242835 by: Captain
242836 by: Max Belushkin
242837 by: Captain

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
php-general@lists.php.net


--
---BeginMessage---

echo 'a href=javascript:popup(\'index.htm\') Test /a';

On 10/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:


Dear All,

How to apply the following function with php ?
a href=javascript:popup('index.htm') Test /a

Edward.

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





--
GMail Rocks!!!
---End Message---
---BeginMessage---
Hello,

Sorry...

If the hyper link is :
a href=javascript:popup('/$dir/index.htm') Test /a

So, how to apply the echo tag for it ?

Remark:
$dir is php variable...

Edward.


J R wrote:

 echo 'a href=javascript:popup(\'index.htm\') Test /a';

 On 10/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:


 Dear All,

 How to apply the following function with php ?
 a href=javascript:popup('index.htm') Test /a

 Edward.

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




---End Message---
---BeginMessage---
On Thu, 05 Oct 2006 16:35:04 +0200, Javier Ruiz wrote:

 Perfect!
 
 got it using the following:
 
 /* 1 - remove the query string just in case it contains a '/' in it
2 - like Clive said, substr() and strrpos() 'clean' the path to provide
 the directories only */
 
 $aPath = str_replace($_REQUEST['QUERY_STRING'], '',
 $_SERVER['SCRIPT_NAME']);
 $aPath = substr($aRuta, 0, (strrpos($aRuta, '/') + 1));
 
 Thanks a lot guys :)

Why make your life harder than it needs to be:

$sPath = dirname($_SERVER['PHP_SELF']);

Ivo
---End Message---
---BeginMessage---

Stut wrote:

Raphael Martins wrote:

I will be sending files over my php script... One client asked me for a
project where he allow clients to send some large files (like 50mb)...I
thought that FTP (via PHP)  will allow that.

Today he just give the FTP server user and password to his clients, 
but he

is worried about the security (of course!). Is there a better way? I was
thinking in split the files in several .RAR volumes... (actually, the 
client
will send his .RAR files instead of a 50mb file), and use remote 
scripting

to upload each file separatly.


Eww, nasty.


Any Ideas?


Set the upload_max_filesize value for the directory where the upload 
script lives. That would be the cleanest way to allow this to happen.


However, HTTP was not designed for uploading files of that size so you 
are better off using an FTP server - this would almost certainly not 
involve PHP at all. If security is a concern you could generate a 
temporary FTP user from a PHP script that will get removed after, say, 
24 hours. How you would do this will vary depending on the FTP server 
you are using.


You could also set the ftp account up to be locked into a particular 
folder.. so if anyone got access to it, they would only see the .rar 
files and nothing else.


Easily done depending on which ftp server you are using but that's way 
out of scope for this mailing list.


--
Postgresql  php tutorials
http://www.designmagick.com/
---End Message---
---BeginMessage---

Hello all.

Is it possible to have a user defined function for the replacement  
within an ereg_replace (like preg_replace_callback)? I am working on  
a script that converts html pages with metric data into imperial  
data. My script takes text strings containing one or more instances  
of e.g. 123 mm, 321 mm, 123 kg, 123 cm2 and so on. The script  
searches the string with a pattern like:

([[:digit:]]+|[[:digit:]]+\.[[:digit:]]+)([[:blank:]]?)(mm)

When the script finds an instance, it stores the matches into an  
array - ereg ( $pattern, $textstring, $matches )


The replacement (for mm) looks like:
round ( ( $matches[1] * 0.039370079 ), 1 ) . $matches[2]  . in

Everything is working great accept when the string contains more than  
one instance for example of the metric unit mm. In that case, all  
instances of xy mm will be replaced with the first occurrence.


So, a text like:

The product is 230 mm tall, 120 mm thick and 340 mm wide will  
output as The product is 9.1 in tall, 9.1 in thick and 9.1 in wide  
- because the replacement string is based / calculated on the first  
occurrence 230 mm.


Alternatively, is there a way to limit 

Re: [PHP] guess documentroot

2006-10-09 Thread Ivo F.A.C. Fokkema
On Thu, 05 Oct 2006 16:35:04 +0200, Javier Ruiz wrote:

 Perfect!
 
 got it using the following:
 
 /* 1 - remove the query string just in case it contains a '/' in it
2 - like Clive said, substr() and strrpos() 'clean' the path to provide
 the directories only */
 
 $aPath = str_replace($_REQUEST['QUERY_STRING'], '',
 $_SERVER['SCRIPT_NAME']);
 $aPath = substr($aRuta, 0, (strrpos($aRuta, '/') + 1));
 
 Thanks a lot guys :)

Why make your life harder than it needs to be:

$sPath = dirname($_SERVER['PHP_SELF']);

Ivo

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



Re: [PHP] FTP

2006-10-09 Thread Chris

Stut wrote:

Raphael Martins wrote:

I will be sending files over my php script... One client asked me for a
project where he allow clients to send some large files (like 50mb)...I
thought that FTP (via PHP)  will allow that.

Today he just give the FTP server user and password to his clients, 
but he

is worried about the security (of course!). Is there a better way? I was
thinking in split the files in several .RAR volumes... (actually, the 
client
will send his .RAR files instead of a 50mb file), and use remote 
scripting

to upload each file separatly.


Eww, nasty.


Any Ideas?


Set the upload_max_filesize value for the directory where the upload 
script lives. That would be the cleanest way to allow this to happen.


However, HTTP was not designed for uploading files of that size so you 
are better off using an FTP server - this would almost certainly not 
involve PHP at all. If security is a concern you could generate a 
temporary FTP user from a PHP script that will get removed after, say, 
24 hours. How you would do this will vary depending on the FTP server 
you are using.


You could also set the ftp account up to be locked into a particular 
folder.. so if anyone got access to it, they would only see the .rar 
files and nothing else.


Easily done depending on which ftp server you are using but that's way 
out of scope for this mailing list.


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

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



[PHP] ereg_replace with unser defined function?

2006-10-09 Thread Frank Arensmeier

Hello all.

Is it possible to have a user defined function for the replacement  
within an ereg_replace (like preg_replace_callback)? I am working on  
a script that converts html pages with metric data into imperial  
data. My script takes text strings containing one or more instances  
of e.g. 123 mm, 321 mm, 123 kg, 123 cm2 and so on. The script  
searches the string with a pattern like:

([[:digit:]]+|[[:digit:]]+\.[[:digit:]]+)([[:blank:]]?)(mm)

When the script finds an instance, it stores the matches into an  
array - ereg ( $pattern, $textstring, $matches )


The replacement (for mm) looks like:
round ( ( $matches[1] * 0.039370079 ), 1 ) . $matches[2]  . in

Everything is working great accept when the string contains more than  
one instance for example of the metric unit mm. In that case, all  
instances of xy mm will be replaced with the first occurrence.


So, a text like:

The product is 230 mm tall, 120 mm thick and 340 mm wide will  
output as The product is 9.1 in tall, 9.1 in thick and 9.1 in wide  
- because the replacement string is based / calculated on the first  
occurrence 230 mm.


Alternatively, is there a way to limit ereg_replace to only replace  
one instance at a time?


Hopefully I am not too confusing...

regards,

/frank

ps. of course I have searched the manual and asked Google - no luck ds.



[PHP] POPUP window in PHP

2006-10-09 Thread Captain

hi,
i want to do YES/NO confirmation (like POPUP). If YES, it will upload a file
into server. Otherwise, it won't do anything.
In JavaScript, i can get using confirm(); But i am not able to do
manipulation from that javascript variable.

My Code(partial):

?
if (file_exists($fullPath)) {
echo ;
   $decide=??php;

# It is Printing either 0 or 1. But I can't able to manipulate further. For
eg, i can't do like the following,   

   if ($decide) {
   // Upload
   } else {
   // Don't Upload
   }
}

Please help me reg this..Please provide some solution for this..Thanks in
advance.

---Prabhakaran
-- 
View this message in context: 
http://www.nabble.com/POPUP-window-in-PHP-tf2408946.html#a6714594
Sent from the PHP - General mailing list archive at Nabble.com.


Re: [PHP] POPUP window in PHP

2006-10-09 Thread Max Belushkin

Captain wrote:

hi,
i want to do YES/NO confirmation (like POPUP). If YES, it will upload a file


PHP is server-side, not client-side. You can have the confirmation 
passed as a GET variable in a two-step process for example, i.e. first 
show a confirmation form if $_GET[confirm] is not set, else check 
$_GET[confirm] and process the uploaded file.


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



Re: [PHP] POPUP window in PHP

2006-10-09 Thread Captain

hi dude,
actually, i am new to php. i am not understanding clearly. plz explain it
clearly. 
My requirement is, i want to upload one file. i am checking whether it
exists or not in Server side.
If it exists, i am popping up a window that Do u want to have Duplication
of this file?.If YES, i sud upload. otherwise i sud giveup.
In script update part if once u uploaded one script from your PC (client)
and after some time u r editing or making change to the file(client). and
wish to put into that then it will ask for duplicate. that part you need to
think. 

Please reply to me.
Thanks again.
Prabhakaran



Max Belushkin wrote:
 
 Captain wrote:
 hi,
 i want to do YES/NO confirmation (like POPUP). If YES, it will upload a
 file
 
 PHP is server-side, not client-side. You can have the confirmation 
 passed as a GET variable in a two-step process for example, i.e. first 
 show a confirmation form if $_GET[confirm] is not set, else check 
 $_GET[confirm] and process the uploaded file.
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

-- 
View this message in context: 
http://www.nabble.com/POPUP-window-in-PHP-tf2408946.html#a6715723
Sent from the PHP - General mailing list archive at Nabble.com.

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



Re: [PHP] Apply the hyper link ( javascript functon ) with php

2006-10-09 Thread edwardspl
Hello,

Sorry...

If the hyper link is :
a href=javascript:popup('/$dir/index.htm') Test /a

So, how to apply the echo tag for it ?

Remark:
$dir is php variable...

Edward.


J R wrote:

 echo 'a href=javascript:popup(\'index.htm\') Test /a';

 On 10/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:


 Dear All,

 How to apply the following function with php ?
 a href=javascript:popup('index.htm') Test /a

 Edward.

 -- 
 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] ereg_replace with unser defined function?

2006-10-09 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-09 09:46:01 +0200:
 Is it possible to have a user defined function for the replacement  
 within an ereg_replace (like preg_replace_callback)? I am working on  
 a script that converts html pages with metric data into imperial  
 data. My script takes text strings containing one or more instances  
 of e.g. 123 mm, 321 mm, 123 kg, 123 cm2 and so on. The script  
 searches the string with a pattern like:
 ([[:digit:]]+|[[:digit:]]+\.[[:digit:]]+)([[:blank:]]?)(mm)

your pattern is valid PCRE AFAICS. why don't you just use
preg_replace_callback? it's faster, more capable...

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



[PHP] Re: [BULK] Re: [PHP] Apply the hyper link ( javascript functon ) with php

2006-10-09 Thread clive

[EMAIL PROTECTED] wrote:

Hello,

Sorry...

If the hyper link is :
a href=javascript:popup('/$dir/index.htm') Test /a
  

you want to use double quotes echo  ; instead of single quotes echo ' ';
the double quotes will parse any variables it finds, where as the single 
quotes will simply just echo what every you place between them.


clive

So, how to apply the echo tag for it ?

Remark:
$dir is php variable...

Edward.


J R wrote:

  

echo 'a href=javascript:popup(\'index.htm\') Test /a';

On 10/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:



Dear All,

How to apply the following function with php ?
a href=javascript:popup('index.htm') Test /a

Edward.

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


  



  



--
Regards,

Clive

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



Re: [PHP] if(), else() problem!

2006-10-09 Thread Rahul S. Johari

Well actually, all 80 fields (not records) that I'm displaying out of the
row (matched by phone number) have to be displayed on the page.
Non-Editable. Just displayed for viewing.

I am certainly using the query to search dbase and display the results. So
technically nothing that I'm doing is causing any problems...

As for the if(), else()... I did figure out a couple of ways to do it... But
I guess the simplest one was the one you  jochem had suggested, which is
pretty much like...

$db = dbase_open(osm.dbf, 0);
if ($db) {
   $record_numbers = dbase_numrecords($db);
$found = false;
for ($i = 1; $i = $record_numbers; $i++) {
   $row = dbase_get_record_with_names($db, $i);
   if ($row['PHONE'] == $thekey) {
   echo ³found²;
$found = $thekey;
  }
   else {
//   echo ³not found²;
// do nothing here
 }
 }

if (!$found) echo not found;
}

Basically used a 'flag'... If phone number was matched (found) in the
dbase... Everything gets displayed and nothing happens in the else() ... But
if phone number was not found, flag is raised, i.e., error message
displayed. 

Working like a charm as far as I can tell.

Thanks!

On 10/6/06 5:21 PM, Richard Lynch [EMAIL PROTECTED] wrote:

 On Fri, October 6, 2006 2:59 pm, Rahul S. Johari wrote:
 I'm not sure if I understand your point then! I have about 80 fields
 in that
 database that are fetched and displayed on the page using this code.
 If
 there's a simpler way to do this, and have it work the if() else()
 error as
 well, I would love to know about it...
 
 Are you displaying 79 records not editable, and ONE that is editable,
 all on one page?
 
 That's an Okay Reason, but you'd probably have happier users if you
 didn't do that...
 
 Give them a link to edit ONE record and let them edit that all by
 itself and then come back to the list when they are done.
 
 Too Much Information is not a good thing.

Rahul S. Johari
Supervisor, Internet  Administration
Informed Marketing Services Inc.
500 Federal Street, Suite 201
Troy NY 12180

Tel: (518) 687-6700 x154
Fax: (518) 687-6799
Email: [EMAIL PROTECTED]
http://www.informed-sources.com

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



Re: [PHP] POPUP window in PHP

2006-10-09 Thread Max Belushkin

Captain wrote:

My requirement is, i want to upload one file. i am checking whether it
exists or not in Server side.


Your script will have to work in stages, generating a page and sending 
to the browser on each stage:
1. Make a form to upload a file for the user to submit - this is just 
ordinary HTML.
2. Once the form is submitted to your script, process the file: check if 
it already exists. If it does not, just move the file to a permanent 
location and go to step 4. If it does, move it a temporary location on 
the server, and generate a page with a second form, asking the user 
whether they want the file replaced.
3. Once the form from step 2 is submitted, if the file is to be 
replaced, move the file from its temporary location to the permanent 
location.

4. Generate a page saying the operation went through fine.

  For a reference on file uploads, check the online documentation:
http://www.php.net/manual/en/features.file-upload.php

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



Re: [PHP] Re: [BULK] Re: [PHP] Apply the hyper link ( javascript functon ) with php

2006-10-09 Thread edwardspl
Hello Clive,

Would you mind to help to modify the hyper link with php ( apply echo
tag ) ?
Sorry... I don't quite to know the php command

Many thank for your help !

Edward.

clive wrote:

 [EMAIL PROTECTED] wrote:

 Hello,

 Sorry...

 If the hyper link is :
 a href=javascript:popup('/$dir/index.htm') Test /a

 you want to use double quotes echo  ; instead of single quotes echo
 ' ';
 the double quotes will parse any variables it finds, where as the
 single quotes will simply just echo what every you place between them.

 clive

 So, how to apply the echo tag for it ?

 Remark:
 $dir is php variable...

 Edward.


 J R wrote:

 echo 'a href=javascript:popup(\'index.htm\') Test /a';

 On 10/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Dear All,

 How to apply the following function with php ?
 a href=javascript:popup('index.htm') Test /a

 Edward.

 -- 
 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: [BULK] Re: [PHP] Apply the hyper link ( javascript functon ) with php

2006-10-09 Thread edwardspl
Hello Clive,

I just modified the php program code :

echo 'a href=javascript:popup(\'/$dir/index.htm\') Test /a';

But the page is error result (Display on the menu bar)!

Edward.

clive wrote:

 [EMAIL PROTECTED] wrote:

 Hello,

 Sorry...

 If the hyper link is :
 a href=javascript:popup('/$dir/index.htm') Test /a

 you want to use double quotes echo  ; instead of single quotes echo
 ' ';
 the double quotes will parse any variables it finds, where as the
 single quotes will simply just echo what every you place between them.

 clive

 So, how to apply the echo tag for it ?

 Remark:
 $dir is php variable...

 Edward.


 J R wrote:

 echo 'a href=javascript:popup(\'index.htm\') Test /a';

 On 10/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Dear All,

 How to apply the following function with php ?
 a href=javascript:popup('index.htm') Test /a

 Edward.

 -- 
 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] ereg_replace with unser defined function?

2006-10-09 Thread Ilaria De Marinis

Hi Frank,
I think preg_replace_callback is a good solution for you.

If you don't want to use it, you can construct two arrays defining 
matches and replacements.


For example:
$matches
[230]
[120]
[340]

$replacements
[9.1]
[replace2]
[replace3]



After you stored matches in $matches using regular expression like 
yours,/preg_match_all 
http://it.php.net/manual/en/function.preg-split.php/ 
(([[:digit:]]+|[[:digit:]]+\.[[:digit:]]+)([[:blank:]]?)(mm), $string, 
$matches, PREG_SET_ORDER)


you can define $replacements by this way:
for(int =0; icount($matches); i++){
   $replacements[$i]=round((substr($matches[$i][0], 0, 
3))*0.039370079),1); //take the last part of match with no digits, I 
don't know if there are sure 3 digits

}

for(int i=0; icount($matches); i++){
   preg_replace($string, $matches[$i][0], $replacement[$i].in);
}

hope to help you

Ilaria

Frank Arensmeier wrote:


Hello all.

Is it possible to have a user defined function for the replacement  
within an ereg_replace (like preg_replace_callback)? I am working on  
a script that converts html pages with metric data into imperial  
data. My script takes text strings containing one or more instances  
of e.g. 123 mm, 321 mm, 123 kg, 123 cm2 and so on. The script  
searches the string with a pattern like:

([[:digit:]]+|[[:digit:]]+\.[[:digit:]]+)([[:blank:]]?)(mm)

When the script finds an instance, it stores the matches into an  
array - ereg ( $pattern, $textstring, $matches )


The replacement (for mm) looks like:
round ( ( $matches[1] * 0.039370079 ), 1 ) . $matches[2]  . in

Everything is working great accept when the string contains more than  
one instance for example of the metric unit mm. In that case, all  
instances of xy mm will be replaced with the first occurrence.


So, a text like:

The product is 230 mm tall, 120 mm thick and 340 mm wide will  
output as The product is 9.1 in tall, 9.1 in thick and 9.1 in wide  
- because the replacement string is based / calculated on the first  
occurrence 230 mm.


Alternatively, is there a way to limit ereg_replace to only replace  
one instance at a time?


Hopefully I am not too confusing...

regards,

/frank

ps. of course I have searched the manual and asked Google - no luck ds.




--

De Marinis Ilaria
Settore Automazione Biblioteche
Phone: +3906-44486052
CASPUR - Via dei Tizii ,6b - 00185 Roma
e-mail: [EMAIL PROTECTED]


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



[PHP] Date verification

2006-10-09 Thread Ron Piggott (PHP)
Is there a PHP function which verifies a valid date has been entered
(-MM-DD)?  Ron


Re: [PHP] Date verification

2006-10-09 Thread Arpad Ray

Ron Piggott (PHP) wrote:

Is there a PHP function which verifies a valid date has been entered
(-MM-DD)?  Ron

  
preg_match('/^(\d{4})-(\d\d)-(\d\d)\z/', $s, $m)  checkdate($m[2], 
$m[3], $m[1])


Arpad

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



Re: [PHP] Date verification

2006-10-09 Thread Max Belushkin

Ron Piggott (PHP) wrote:

Is there a PHP function which verifies a valid date has been entered
(-MM-DD)?  Ron


http://www.php.net/manual/en/function.checkdate.php

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



Re: [PHP] Date verification

2006-10-09 Thread Richard Lynch
On Mon, October 9, 2006 11:26 am, Ron Piggott (PHP) wrote:
 Is there a PHP function which verifies a valid date has been entered
 (-MM-DD)?  Ron

Note that both solutions so far are only partial solutions for most
real world scenarios.

For example:
0001-12-25
will pass both, and would appear to be Christmas #1 to the average
human eye, or a least readily identifiable in context as such.

Unfortunately, we've made rather of mess of dates and calendars over
the centuries, and 0001-12-25 is unlikely to be correct in any real
sense of the word, for most applications.

So you probably should include several more stringent checks suitable
to your web application.

Some examples:
Birth dates for living humans would be current date - 120 years range.
Credit card expirations should be current date + 10 years (I think...)
-- Actually, older dates are 'valid' but the credit card won't go
through anyway, so that might need 2 separate checks.

My point being that there really cannot be a single valid date check
because there's no way to be certain of the unique needs of your web
application.

The vagaries of date/time input are legion.

And don't even get me started on the goofball 15-minute offset
time-zone thing... :-)

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



[PHP] PHP solution for virtual folder management

2006-10-09 Thread Angelo Zanetti

Hi all,

WE are developing a system and now we have to create our own folder 
management system, it however wont be physical folders on the hard drive 
but more database entries and then the user will view the output as if 
they were directories.


So Im looking for possibly and open source solution that can manage that 
information/folder hierarchy. The user will be able to add, edit and 
delete folders but most importantly move a folder with all its contents 
to an exisisting folder.  The moving folder part is not easy. the other 
functions like add, edit and delete and list sub folders is pretty easy 
with the parentID pointing to the parent directory.


if anyone has any links, or any thing that might help it would be 
greatly appreciated.


Thanks in advance.
Angelo

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



Re: [PHP] POPUP window in PHP

2006-10-09 Thread Richard Lynch
On Mon, October 9, 2006 6:22 am, Captain wrote:
 hi dude,
 actually, i am new to php. i am not understanding clearly. plz explain
 it
 clearly.

You can't do what you want.

More importantly, you should not even WANT to do what you want!

There are several reasons for this, and they are rather subtle, and
require a mind-shift in your thinking.

The first thing you MUST get used to is that the SERVER where your PHP
script lives is VERY far away, in all respects, from the CLIENT where
your user sits and the POPUP appears.

PHP can't be involved in the POPUP because it's nowhere near that
popup -- PHP spits out the HTML and Javascript and then PHP is *gone*

The second reason you do NOT want to do this is this:
Suppose you could even make it work -- Throw in some AJAX-y Web2.0
thingie that checked back to the server every 2 seconds to make sure I
put in a different filename.  Fine.

You *still* have a BIG PROBLEM in that you are, almost for sure,
dealing with a web application where ANOTHER user can upload the same
file name in between your check and when the upload is actually done:

Imagine 2 users working at the same time:
User 1 User 2
Check A.txt: OKCheck A.txt: OK
Upload A.txt   Upload A.txt

As you can see, only one of the users is going to win this race --
when they each checked if the name was already taken, everything was
fine.  But once they upload, one of them will be first and get the
name, and the second will either overwrite the first, or it will get
rejected anyway.

So you might as well not try to do any of this until the user actually
uploads -- And you do NOT need to store their filename exactly as they
used it.  You can just add a digit to make it unique.  Or you can put
each user's files in their own directory to reduce conflicts.

There are many ways to solve this, but, ultimately, you have to
check the filename in such a way that you do NOT introduce a Race
Condition.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



[PHP] Re: PHP solution for virtual folder management

2006-10-09 Thread Colin Guthrie
Angelo Zanetti wrote:
 Hi all,
 
 WE are developing a system and now we have to create our own folder
 management system, it however wont be physical folders on the hard drive
 but more database entries and then the user will view the output as if
 they were directories.
 
 So Im looking for possibly and open source solution that can manage that
 information/folder hierarchy. The user will be able to add, edit and
 delete folders but most importantly move a folder with all its contents
 to an exisisting folder.  The moving folder part is not easy. the other
 functions like add, edit and delete and list sub folders is pretty easy
 with the parentID pointing to the parent directory.
 
 if anyone has any links, or any thing that might help it would be
 greatly appreciated.

Try looking on pear.php.net for the VFS framework.

I've used if to FTP storage but it supports DB and filesystem backends too.

Docs are pretty crap, but hey ho.

Col.

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



Re: [PHP] Apply the hyper link ( javascript functon ) with php

2006-10-09 Thread Richard Lynch
On Sun, October 8, 2006 6:53 pm, [EMAIL PROTECTED] wrote:
 How to apply the following function with php ?
 a href=javascript:popup('index.htm') Test /a

If you're new to PHP, be a minimalist, and pull out PHP only when you
absolutely have to:

a href=javascript:popup('?php echo $dir?/index.htm') Test /a

Since $dir is the ONLY part you want to be changing, use PHP only for
that part.

Switching in/out of PHP like this is very fast/cheap, and leaves you
with HTML that mostly looks just like you are used to.

YMMV

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] $_SERVER['HTTP_REFERER']

2006-10-09 Thread Richard Lynch
On Sun, October 8, 2006 1:05 pm, Peter Lauri wrote:
 I am trying to track where the people entered a unique page from
 (developing
 an affiliate system).

 I have been using the $_SERVER['HTTP_REFERER'] to track this and
 record it
 on a affiliate entrance of the web site. However, that is not tracking
 all
 clicks. Only some of them have. I assume some of the links are not
 from a
 traditional a/a link.

Your assumption is incorrect.

Some browsers do not provide HTTP_REFERER.
Some users configure their browser not to.
Some proxy servers mask or alter HTTP_REFERER

Pretty much, in all respects, HTTP_REFERER is about the least reliable
thing you could have chosen, except maybe IP address.

 Is there any other way to do this?

Sure!

Just have your affiliates include a unique code in their URLs and use
$_SERVER['PATH_INFO'] to find it.

See my .sig for a very nice example. :-)

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Uploading files / processing with a PHP script

2006-10-09 Thread Richard Lynch
On Sun, October 8, 2006 7:47 am, Ron Piggott (PHP) wrote:
 When I upload a file into an application I am writing with the HTML
 form
 command

 INPUT NAME=userfile TYPE=file

 and then give the PHP command

 move_uploaded_file( $userfile , $destination_file_name);

 the owner of the file is 'www'.  Is there any way I am able to
 automatically change the owner of the file to my FTP login identity
 (for
 example 'rpiggott')

Yes, no, sort of, maybe, and exactly how depends.

See, here's the thing.  If you, rpiggott, or if www, could just chown
(change owner) of any file to anything they wanted, that would be Very
Bad.  Cuz you could change a file to be owned by 'root', then chmod it
to be run *AS* root, and then you essentially *are* 'root'.  And
that's bad.  If you don't know why that's bad, you're way behind on
your reading...

Anyway, here's what you can do, that should work no matter what else
is happening on the machine:
User www can make the file world or group readable with
http://php.net/chmod when the file is created.
If rpiggott and www are in a common group, group readable is enough;
If not, you have to use world readable.  Use group if you can.

Once www's file is readable by rpiggott, then rpiggott can copy the
file in a cron job or shell script that www can execute, or...  When
rpiggott copies www's file into a new file, then rpiggott is creating
the file, and it should be owned by rpiggott.


Another option, if you happen to have 'root' on the machine (which
would be kinda scary given the original question, but there it is) you
can make a root-owned script to just chown the files, and run it in a
cron job.


Before you do all this -- Think carefully.  Sometimes changing
ownership has broad and drastic implications.  You may want to just
have www chmod the file so rpiggott can read it or even write it, and
then you don't have to go so far as chown.

As a general principle, always do the minimum needed to get the task
done, when it comes to chmod/chown.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Uploading files / processing with a PHP script

2006-10-09 Thread Richard Lynch
On Sun, October 8, 2006 2:49 pm, Larry Garfield wrote:
 The owner of a file can change ownership of the file, too, I believe,
 essentially willing it to someone else.

I sure hope not...

Cuz then I could chmod 4777 a file to make it execute as owner, then I
could will it to 'root' owner, and then I am root.
[4### is how you make it run as user right?...]

Actually, at that point, as it's chmod 777, *every* user on the
machine is 'root' as they can cram whatever they want into that file. 
Total chaos ensues.

That would be bad. :-) :-) :-)

 A better solution is to set the file's group permissions to 7, then
 chown the
 file to apache:mygroup, then put both apache and your ftp user into
 the
 mygroup group.

This is a Good Solution, however, and probably most closely resembles
the real-world need: www and rpiggot need to be in a common group of
users with access to this file.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] PHP solution for virtual folder management

2006-10-09 Thread Richard Lynch
On Mon, October 9, 2006 12:32 pm, Angelo Zanetti wrote:
 to an exisisting folder.  The moving folder part is not easy. the
 other
 functions like add, edit and delete and list sub folders is pretty
 easy
 with the parentID pointing to the parent directory.

To move a folder, you just change its parentID...

Can't get much easier than that...

I would advise you to seriously consider just writing an interface to
the OS file system instead of attempting to re-invent the wheel and
cram a bunch of stuff into your database.

Your OS file system *IS* a highly-tuned optimized full-featured
database already.  Duplicating all that behaviour is just plain silly,
almost-for-sure and will probably have zero added value.


Sit down and work out exactly what you gain by putting all this
stuff into the DB.  Make sure you understand the performance
benefits/losses.  Maybe even run some quick scaled tests to see what
wins you get.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] ECHO $variable

2006-10-09 Thread Richard Lynch
On Sun, October 8, 2006 1:39 am, Ron Piggott (PHP) wrote:
 In one of my scripts I have

 input type=text name=message_title size=40 maxlength=80
 value=?echo
 $saved_message_title;?

 where

 $saved_message_title is 1 Peter 5:7 Cast all your cares on Him for He
 cares about you
 --- note the 

 When this is displayed on the screen $saved_message_title reads

 1 Peter 5:7

 I am assuming the  closes the value=

Yup.  Use View Souce in your browser to confirm that.

 How may I echo this to the screen and have the full text be displayed,
 not just 1 Peter 5:7 ?

*ALL* data going to HTML should have http://php.net/htmlentities
called on it.

This will convert  to quot; so that it is properly escaped for HTML
output.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] ECHO $variable

2006-10-09 Thread Richard Lynch
On Mon, October 9, 2006 7:45 am, benifactor wrote:
 the way i posted worked fine with out either... he doesn't need to use
 these
 to format the way his output is displayed, he only needs to use the
 proper
 php syntax if i am correct.

You were wrong, and you're still wrong. :-)

Try it and see.

http://php.net/htmlentities is the correct solution.

htmlspecialchars only catches a tiny subset of what *might* be in the
string...   So it will work if you can guarantee that only those
limited set of chars will ever be in there.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] FTP

2006-10-09 Thread Richard Lynch
On Sat, October 7, 2006 6:50 pm, Raphael Martins wrote:
 When I send files via FTP, the file size is limited to the php.ini max
 upload value?

Yes.

:-)

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] FTP

2006-10-09 Thread Richard Lynch
Uploading huge files via HTTP is generally problematic.

Set up FTP usernames/passwords/directories for each of his clients is
probably the best answer.

On Sun, October 8, 2006 6:05 am, Raphael Martins wrote:
 I will be sending files over my php script... One client asked me for
 a
 project where he allow clients to send some large files (like
 50mb)...I
 thought that FTP (via PHP)  will allow that.

 Today he just give the FTP server user and password to his clients,
 but he
 is worried about the security (of course!). Is there a better way? I
 was
 thinking in split the files in several .RAR volumes... (actually, the
 client
 will send his .RAR files instead of a 50mb file), and use remote
 scripting
 to upload each file separatly.

 Any Ideas?

 Thank you!

 2006/10/8, Yannick Warnier [EMAIL PROTECTED]:

 Le samedi 07 octobre 2006 à 20:50 -0300, Raphael Martins a écrit :
  Hi,
 
  When I send files via FTP, the file size is limited to the php.ini
 max
  upload value?
  Thank you!

 No, unless you handle the FTP server with a PHP script. php.ini only
 limits the size of files handled by PHP (generally via HTTP), so it
 should not affect FTP (unless your FTP server is in PHP).

 Yannick

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





-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] set cookie with non-english

2006-10-09 Thread Richard Lynch
On Sat, October 7, 2006 4:10 pm, Ahmad Al-Twaijiry wrote:
 BTW I want to access the (cookie or session) variable from php 
 javascript, so I don't think session is a solution

 so again, does anyone know how to resolve the problem so I can write
 the cookie output to UTF-8 html page ?

I don't think the charset of the HTML has any bearing on it...

You could base64encode it in PHP, and decode it in PHP Javascript,
maybe...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Re: Separate PHP Code From HTML || Pros Cons?

2006-10-09 Thread Richard Lynch
On Sat, October 7, 2006 4:24 pm, sit1way wrote:
 I would dearly love to have a base CMS repository that all sites would
 draw
 on, extending the base CMS in the event that a particular client has
 need of
 customization.  Some combo of Linux and Apache would do the trick;
 e.g. PHP
 requests for any of my sites would point to say, /home/cms/includes/

You might want to consider just installing subversion and using svn to
control your own source code.

 Now, the other issue I'd like to address is separating PHP code logic
 from
 site HTML.

This has been beaten to death here so often...

 I've often heard the mantra, separate code from HTML, but it seems
 ridiculous at times to include tiny HTML snippets that can easily be
 echoed
 out, or stored in a variable.  Smarty goes to the extreme in
 separating code
 from HTML, but looking at their templating system, I wonder what's the
 point?  Is it the end of the world if you've got a few choice if,
 then, else
 statements in your HTML templates?

I personally think you're doing a fine thing.

Going whole-hog template with no PHP allowed might be more useful for
larger teams where some HTML designer is supposed to know NOTHING
about PHP -- Though, honestly, teaching an HTML designed just enough
PHP to deal with your not-quite-templates is probably easier and
better in the long run, imho.

Just use whatever works for you.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Re: set cookie with non-english

2006-10-09 Thread Richard Lynch
On Sun, October 8, 2006 12:51 am, Nisse Engström wrote:
 * I use META http-equiv=Content-Type  content=text/html;
 charset=utf-8 in my page

The META thing might be good for storing pages
 on disk, but on the web you should use real HTTP
 headers.

Except IE will *ignore* your HTTP headers.

You need real HTTP headers for real browsers, *and* the META tag for
IE, if you want your charset to be honored.

IE will use some weird guess based on the bytes in the document to
choose a charset.  It mostly guesses right, except when it doesn't.

For some reason, MSIE thinks HTML designers and META tags are
absolutely believable, but headers are just silly things that are
never reliable.  This applies to everything from Content-type to
charset.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



RE: [PHP] Re: Understanding persistent connections with oci8

2006-10-09 Thread Mendonce, Kiran (STSD)
I did some checking on the web and noticed that another user encountered
a similar problem and even reported it as a bug (#36634). The
documentation is misleading here with the intent of the
persistent_timeout setting not clearly explained.

If the behavior is as designed, can someone please update the
documentation so its more clearer to the end user ?

Thanks and Regards,
Kiran 

-Original Message-
From: Mendonce, Kiran (STSD) 
Sent: Wednesday, October 04, 2006 10:34 AM
To: php-general@lists.php.net
Subject: RE: [PHP] Re: Understanding persistent connections with oci8

I understand the performance boost one can get by reusing existing
connections. And I did see for myself that with the default settings,
oci_pconnect() does reuse all the connections.

But what should happen if there are idle connections and the timeout is
reached ? That is my question. What is the purpose of the
persistent_timeout setting ? Does it give the user a means of specifying
a timeout after which idle connections are removed ?

-Original Message-
From: Manuel Lemos [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 04, 2006 12:16 AM
To: php-general@lists.php.net
Subject: [PHP] Re: Understanding persistent connections with oci8

Hello,

on 10/03/2006 07:03 PM Mendonce, Kiran (STSD) said the following:
 This is a follow up to the bug (#39029) that I reported earlier which 
 has been repeatedly closed as bogus.
 
 The oci8.persistent_timeout setting in the php.ini file is documented 
 as
 :
 The maximum length of time (in seconds) that a given process is 
 allowed to maintain an idle persistent connection. Setting this option

 to -1 means that idle persistent connections will be maintained
forever. 
 
 If I do not want the connection to be persist forever, then by using 
 this setting, I should be able to ensure that a connection is not idle

 for longer than what I specified. However, when I set 
 persistent_timeout to 10 seconds, I find that the connection is not 
 terminated even after 10 seconds have passed. In fact, it doesn't 
 terminate at all. So the question is what is the purpose of this 
 setting ? And what does an 'idle connection' mean ? A google query for

 'idle timeout' yields enough results to point that when the timeout 
 occurs, the idle connection is terminated.
 
 Obviously there is a bug somewhere. Either in the documentation or in 
 the behavior. Please advise.

I think that there is no bug and that option is useless.

If you are using Apache, it will rotate the processes that serve each
request. So, unless your server is mostly idle or your scripts rarely
access the database, your connections will keep being reused before
reaching that timeout.

If you are willing to reduce the number of persistent Oracle
connections, you will most likely get better results if you move your
site images to a separate Web server. Image requests do not establish
Oracle connections, but they raise the need for Apache to fork more
processes, which leads to more opened persistent connections.

Here you may find more details about that strategy:

http://www.meta-language.net/metabase-faq.html#excessive-connections

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--
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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Using mysql_real_escape_string

2006-10-09 Thread Alan Milnes


OK this should be really obvious but I just can't figure it out.  I have 
a script that opens a file, reads it line by line and inserts the 
contents into a database.  I know I need to use mysql_real_escape_string 
to properly escape the contents but I don't know where exactly to place 
it in the script.


Any pointers, liks, guidance etc gratefully received!

Alan

*CODE:*

//Input check file
$filename=input/w2wcheck.txt;   


echo h2$filename/h2;

# Open file
$fptr = fopen($filename, r);

# Check if file is open
if($fptr) {
   $current_line = fgets($fptr,4096);
  
   $retval = TRUE;

   echo open;
  
 while($current_line  $retval)

   {
   list(
$UNIQUEID,
$ASSETID   ,
$CNF 
  
   ) = explode(,,$current_line);

 $query = insert into invw2wcheck (

UNIQUEID,
ASSETID   ,
CNF
  
)

values
(
'$UNIQUEID',
'$ASSETID   ',
'$CNF'

);

 
 $result = mysql_query($query);
 

   if(!$result)

   {
echo h1Processing halted due to Error No:;
   echo mysql_errno().: ;
   echo mysql_error().BR;
   echo /h1;
   $retval = FALSE;
   die;
   }
   elseif(mysql_affected_rows() == 0)
   {
 $retval = FALSE;
   die;
   }

 $current_line = fgets($fptr,4096);
   }
} 


fclose($fptr);

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



Re: [PHP] Using mysql_real_escape_string

2006-10-09 Thread tg-php
mysql_real_escape_string() is a function that returns the post-processed value.

So you can either do it like this:

$safe_value = mysql_real_escape_string($unsafe_value);

then use $safe_value in your query, or put the function right into your query:

$myQY = INSERT INTO sometable (value) values (' . 
mysql_real_escape_string($unsafe_value) . ';;

Hope that helps (did I get this message in before the 400 other people 
responded? hah)

-TG

= = = Original message = = =

OK this should be really obvious but I just can't figure it out.  I have 
a script that opens a file, reads it line by line and inserts the 
contents into a database.  I know I need to use mysql_real_escape_string 
to properly escape the contents but I don't know where exactly to place 
it in the script.

Any pointers, liks, guidance etc gratefully received!

Alan

*CODE:*

//Input check file
$filename=input/w2wcheck.txt;   

echo h2$filename/h2;

# Open file
$fptr = fopen($filename, r);

# Check if file is open
if($fptr) 
$current_line = fgets($fptr,4096);
   
$retval = TRUE;
echo open;
   
  while($current_line  $retval)

list(
$UNIQUEID,
$ASSETID   ,
$CNF 
   
) = explode(,,$current_line);
 
  $query = insert into invw2wcheck (
UNIQUEID,
ASSETID   ,
CNF
   
)
values
(
'$UNIQUEID',
'$ASSETID   ',
'$CNF'

);
 
  
  $result = mysql_query($query);
  
 
if(!$result)

 echo h1Processing halted due to Error No:;
echo mysql_errno().: ;
echo mysql_error().BR;
echo /h1;
$retval = FALSE;
die;

elseif(mysql_affected_rows() == 0)

  $retval = FALSE;
die;


  $current_line = fgets($fptr,4096);

 

fclose($fptr);

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


___
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] Using mysql_real_escape_string

2006-10-09 Thread Eric Butera

On 10/9/06, Alan Milnes [EMAIL PROTECTED] wrote:


  $query = insert into invw2wcheck (
UNIQUEID,
ASSETID   ,
CNF

)
values
(
'$UNIQUEID',
'$ASSETID   ',
'$CNF'

);



Wrap escaping functions around the values you are sticking in the DB.
Escaping is only needed at the time you are using it because it helps
your data go somewhere.  You don't want to corrupt your data with
escaped values.

$query = insert into invw2wcheck (
UNIQUEID,
ASSETID   ,
CNF
)
values
(
'. mysql_real_escape_string($UNIQUEID) .',
'. mysql_real_escape_string($ASSETID) .',
'. mysql_real_escape_string($CNF) .'
);

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



[PHP] need help to build a query

2006-10-09 Thread afan
hi to all,

I have table orders with primary key order_id. I have table uploaded_files
with primary key ufid and uploaded files are linked to orders by order_id
column.

I have to list all orders and uploaded files. this works fine:

$query = mysql_query(
  select order_id, order_date, order_status
  from orders
  order by order_id desc
  limit 100);
while($result=mysql_fetch_array($query))
{
  echo ID: . $result['order_date'].|;
  echo DATE: . $result['order_date'] .|;
  echo STATUS: . $result['order_status'] .|;
  echo UPLOADED FILES: ;
  $query2 = mysql_query(
select uf.file_name
from uploaded_files as uf
where uf.order_id = $result['order_id']
  );
  while($result2=mysql_fetch_array($query2))
  {
echo $result2['file_name'].|;
  }
  echo hr;
}

but I know there must be much better solution then this one.

thanks for any help.

-afan

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



Re: [PHP] need help to build a query

2006-10-09 Thread John Wells

On 10/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

but I know there must be much better solution then this one.


You're right: Simply JOIN your queries...

SELECT order_id, order_date, order_status, file_name
   FROM orders
   JOIN uploaded_files AS uf ON orders.order_id = uf.order_id
   ORDER BY orders.order_id DESC
   LIMIT 100

HTH,
John W




thanks for any help.

-afan

--
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] need help to build a query

2006-10-09 Thread Brad Bonkoski

[EMAIL PROTECTED] wrote:

hi to all,

I have table orders with primary key order_id. I have table uploaded_files
with primary key ufid and uploaded files are linked to orders by order_id
column.

I have to list all orders and uploaded files. this works fine:

$query = mysql_query(
  select order_id, order_date, order_status
  from orders
  order by order_id desc
  limit 100);
while($result=mysql_fetch_array($query))
{
  echo ID: . $result['order_date'].|;
  echo DATE: . $result['order_date'] .|;
  echo STATUS: . $result['order_status'] .|;
  echo UPLOADED FILES: ;
  $query2 = mysql_query(
select uf.file_name
from uploaded_files as uf
where uf.order_id = $result['order_id']
  );
  while($result2=mysql_fetch_array($query2))
  {
echo $result2['file_name'].|;
  }
  echo hr;
}

but I know there must be much better solution then this one.

thanks for any help.

-afan

  


Perhaps something like this: (not sure how this would play with the 
limit key word, but you could play around with it...)
If you can guarantee that a record (order_id) will appear in both 
tables, a simple join will work...
but if a record in table A exists but not in table B, a join will not 
return that record, which is why there is a left outer join.


select o.order_id, o.order_date, o.order_status, uf.file_name
 from orders o left outer join uploaded_files uf on uf.order_id = o.order_id
 order by o.order_id desc

Not sure if mysql supports this..??

select * from (select o.order_id, o.order_date, o.order_status, uf.file_name
 from orders o left outer join uploaded_files uf on uf.oerder_id = o.order_id
 order by o.order_id desc ) LIMIT 100

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



Re: [PHP] ereg_replace with user defined function?

2006-10-09 Thread Frank Arensmeier
Thank you Ilaria and Roman for your input. I did not know that preg  
is able to deal with PCRE patterns. As a matter of fact I came up  
with the following solution (if someone is interested):


the function takes a text and an array with converters like:

$converters[] = array (	metric = mm, imperial = in, ratio  
= 0.039370079, round = 1 );
$converters[] = array (	metric = m, imperial = ft, ratio  
= 3.280839895, round = 1 );



function convertTextString ( $text, $convertTable )
{
	# this function takes a text string, searches for numbers to  
convert, convert those numbers and returns

# the complete text again.

	if ( !ereg ( [[:digit:]], $text ) ) // if the text does not  
contain any numbers, return the text as it is

{
return $text;
}

foreach ( $convertTable as $convertKey = $convertUnit )
{
		$pattern = ((\d{1,10}[,|.]*\d{0,10})*(\s)(%s)([$|\s|.|,|\)|/]+| 
$)); // this regex looks for a number followed by white space,  
followed by the metric unit, followed by a closing character like  
., , or )

$pattern = sprintf ( $pattern, $convertUnit['metric'] );

while ( preg_match ( $pattern, $text, $matches ) )
{
			$matches[1] = str_replace ( ,, ., $matches[1] ); // in case  
numbers are written like 6,6 m, we need to replace , with .
			// because we do not want to return 0, we have to make shure that  
the new value is not zero.

$itterator = 0;
do {
$value = round ( ( $matches[1] * $convertUnit['ratio'] ),  
$convertUnit['round'] + $itterator  );

++$itterator;
} while ( $value == 0 || $itterator == 10 );

$replacement = $value . $2 . $convertUnit['imperial'] . 
$4;
$text = preg_replace ( $pattern, $replacement, $text, 1 
);
}
}
return $text;
}

/frank

9 okt 2006 kl. 16.18 skrev Ilaria De Marinis:


Hi Frank,
I think preg_replace_callback is a good solution for you.

If you don't want to use it, you can construct two arrays defining  
matches and replacements.


For example:
$matches
[230]
[120]
[340]

$replacements
[9.1]
[replace2]
[replace3]



After you stored matches in $matches using regular expression like  
yours,/preg_match_all http://it.php.net/manual/en/function.preg- 
split.php/ (([[:digit:]]+|[[:digit:]]+\.[[:digit:]]+)([[:blank:]]?) 
(mm), $string, $matches, PREG_SET_ORDER)


you can define $replacements by this way:
for(int =0; icount($matches); i++){
   $replacements[$i]=round((substr($matches[$i][0], 0, 3)) 
*0.039370079),1); //take the last part of match with no digits, I  
don't know if there are sure 3 digits

}

for(int i=0; icount($matches); i++){
   preg_replace($string, $matches[$i][0], $replacement[$i].in);
}

hope to help you

Ilaria

Frank Arensmeier wrote:


Hello all.

Is it possible to have a user defined function for the  
replacement  within an ereg_replace (like preg_replace_callback)?  
I am working on  a script that converts html pages with metric  
data into imperial  data. My script takes text strings containing  
one or more instances  of e.g. 123 mm, 321 mm, 123 kg, 123  
cm2 and so on. The script  searches the string with a pattern like:

([[:digit:]]+|[[:digit:]]+\.[[:digit:]]+)([[:blank:]]?)(mm)

When the script finds an instance, it stores the matches into an   
array - ereg ( $pattern, $textstring, $matches )


The replacement (for mm) looks like:
round ( ( $matches[1] * 0.039370079 ), 1 ) . $matches[2]  . in

Everything is working great accept when the string contains more  
than  one instance for example of the metric unit mm. In that  
case, all  instances of xy mm will be replaced with the first  
occurrence.


So, a text like:

The product is 230 mm tall, 120 mm thick and 340 mm wide will   
output as The product is 9.1 in tall, 9.1 in thick and 9.1 in  
wide  - because the replacement string is based / calculated on  
the first  occurrence 230 mm.


Alternatively, is there a way to limit ereg_replace to only  
replace  one instance at a time?


Hopefully I am not too confusing...

regards,

/frank

ps. of course I have searched the manual and asked Google - no  
luck ds.





--

De Marinis Ilaria
Settore Automazione Biblioteche
Phone: +3906-44486052
CASPUR - Via dei Tizii ,6b - 00185 Roma
e-mail: [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



Re: [PHP] need help to build a query

2006-10-09 Thread afan
But, in this case I will have repeating order_date and order_status info?

idorder_datestatusfile_name
122006-10-09live  file1.jpg
122006-10-09live  file2.jpg
122006-10-09live  file3.jpg
132006-10-09live  file1.jpg
142006-10-09live  test.gif


right?


 On 10/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 but I know there must be much better solution then this one.

 You're right: Simply JOIN your queries...

 SELECT order_id, order_date, order_status, file_name
 FROM orders
 JOIN uploaded_files AS uf ON orders.order_id = uf.order_id
 ORDER BY orders.order_id DESC
 LIMIT 100

 HTH,
 John W



 thanks for any help.

 -afan

 --
 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] need help to build a query

2006-10-09 Thread afan
while I was trying again I did something wrong (?) and my server is now
busy and looks like it went down?!?

The qestion is how can I check first query before I apply it to be sure
I'm not goig to read every record in my DB or get into loop?

thanks.

-afan

 On 10/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 but I know there must be much better solution then this one.

 You're right: Simply JOIN your queries...

 SELECT order_id, order_date, order_status, file_name
 FROM orders
 JOIN uploaded_files AS uf ON orders.order_id = uf.order_id
 ORDER BY orders.order_id DESC
 LIMIT 100

 HTH,
 John W



 thanks for any help.

 -afan

 --
 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] need help to build a query

2006-10-09 Thread John Wells

Yes you are right, but I guess you can decide which is worse: sending
extra data in one query or send extra queries.  I guess it depends on
how many records we're talking about...

Brad also brings up a good point I hadn't considered.  I do think an
OUTER join is possible, perhaps depending on your mysql version...

Which brings up something I had meant to say before, which is that
this isn't actually a PHP question... :)

John W

On 10/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

But, in this case I will have repeating order_date and order_status info?

idorder_datestatusfile_name
122006-10-09live  file1.jpg
122006-10-09live  file2.jpg
122006-10-09live  file3.jpg
132006-10-09live  file1.jpg
142006-10-09live  test.gif


right?


 On 10/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 but I know there must be much better solution then this one.

 You're right: Simply JOIN your queries...

 SELECT order_id, order_date, order_status, file_name
 FROM orders
 JOIN uploaded_files AS uf ON orders.order_id = uf.order_id
 ORDER BY orders.order_id DESC
 LIMIT 100

 HTH,
 John W



 thanks for any help.

 -afan

 --
 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: set cookie with non-english

2006-10-09 Thread Nisse Engström
On Mon, 9 Oct 2006 13:17:37 -0500 (CDT), Richard Lynch wrote:

 On Sun, October 8, 2006 12:51 am, Nisse Engström wrote:

The META thing might be good for storing pages
 on disk, but on the web you should use real HTTP
 headers.
 
 Except IE will *ignore* your HTTP headers.
 
 You need real HTTP headers for real browsers, *and* the META tag for
 IE, if you want your charset to be honored.

 IE will use some weird guess based on the bytes in the document to
 choose a charset.  It mostly guesses right, except when it doesn't.
 
 For some reason, MSIE thinks HTML designers and META tags are
 absolutely believable, but headers are just silly things that are
 never reliable.  This applies to everything from Content-type to
 charset.

   I knew IE held some animosity towards the HTTP
specification, but I didn't know it paid more respect
to some bobs of META than the corresponding bits of
HTTP. Or maybe I did know but have forgotten.

   No matter. Thanks for the information. By the bye,
are we talking IE in general, or specific versions
thereof?


  --nfe

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



Re: [PHP] set cookie with non-english

2006-10-09 Thread Nisse Engström
On Sun, 8 Oct 2006 00:10:49 +0300, Ahmad Al-Twaijiry wrote:

 BTW I want to access the (cookie or session) variable from php 
 javascript, so I don't think session is a solution
 
 so again, does anyone know how to resolve the problem so I can write
 the cookie output to UTF-8 html page ?
 

   Unless I'm missing something, there is an elegant
solution to this.

   return decodeURIComponent (dc.substring ( ... ));


  --nfe

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



Re: [PHP] need help to build a query

2006-10-09 Thread Larry Garfield
On Monday 09 October 2006 16:50, John Wells wrote:
 Yes you are right, but I guess you can decide which is worse: sending
 extra data in one query or send extra queries.  I guess it depends on
 how many records we're talking about...

It will vary with your problem, but in general, fewer queries == A Good Thing.  
If you can do with a join or subselect what would take n queries otherwise, 
do so.  

Also, JOIN is faster than sub-queries.  Be aware, though, that MySQL doesn't 
support sub-queries until version 4.1.

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



[PHP] Working with overly aggressive anti-spam measures

2006-10-09 Thread Dave M G

PHP List,

I run a few various social groups, and with each one I keep in contact 
with members by emailing them short newsletters.


All my user information is stored in a MySQL database. I use PHP to get 
the relevant contact information, and use the mail() command to send out 
the emails one by one, so that each email is a little personalized.


I've used this system for many years now with no problems up until now.

What has changed, though, is that in recent years, anti-spam measures 
have become so aggressive that more and more people who sign up to my 
groups complain that they never receive the emails.


A lot of the times, after they alert me to the issue, I can educate them 
a little about the anti-spam measures they most likely have on their 
system, and walk them through how to make it so that my newsletters go 
through.


However, that is clearly not enough.

To shorten a story that has already gone on a little long, it's come to 
my attention that part of the reason that my emails may not be getting 
through are because the headers are not sufficiently legitimate looking 
enough to bypass some server side anti-spam measures. Things like 
Return-Path are being set so that they look like they come from an 
email address that begins with the username nobody.


If possible, can anyone help me with creating the PHP code that will 
make an email as legitimate as it can be? I know I can't totally prevent 
my email from being marked as spam (after all, if it were possible, all 
the spammers would do it). But as much as I can prevent anti-spam 
measures getting a false positive when testing my email, the better.


Here is the PHP code I currently use (trimmed for clarity):

while ( $member = mysql_fetch_row($mysqlResult) )
{
$subscriber = $member[0];
$email = $member[1];
$subject = Report for  . date('l jS F Y');
$mailContent = This is an email to  . $subscriber .  at  . $email . .;
$fromAddress = [EMAIL PROTECTED]
mail($email, $subject, $mailContent, $fromAddress);
}


And here is what the headers for an email from that code looks like:

-Account-Key: account5
X-UIDL: UID497-1152485402
X-Mozilla-Status: 0001
X-Mozilla-Status2: 
Return-path: [EMAIL PROTECTED]
Envelope-to: [EMAIL PROTECTED]
Delivery-date: Sun, 03 Sep 2006 14:22:42 -0700
Received: from nobody by server.myhostingservice.com with local (Exim 4.52)
id 1GJzQQ-0005pA-Mz
for [EMAIL PROTECTED]; Sun, 03 Sep 2006 14:22:42 -0700
To: [EMAIL PROTECTED]
Subject: Report for Monday 4th September 2006
From: [EMAIL PROTECTED]
Message-Id: [EMAIL PROTECTED]
Date: Sun, 03 Sep 2006 14:22:42 -0700

Which parts are key to change, and how?

Thank you for any and all advice.

--
Dave M G
Ubuntu 6.06 LTS
Kernel 2.6.17.7
Pentium D Dual Core Processor
PHP 5, MySQL 5, Apache 2

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



Re: [PHP] Working with overly aggressive anti-spam measures

2006-10-09 Thread Chris

Dave M G wrote:

PHP List,

I run a few various social groups, and with each one I keep in contact 
with members by emailing them short newsletters.


All my user information is stored in a MySQL database. I use PHP to get 
the relevant contact information, and use the mail() command to send out 
the emails one by one, so that each email is a little personalized.


I've used this system for many years now with no problems up until now.

What has changed, though, is that in recent years, anti-spam measures 
have become so aggressive that more and more people who sign up to my 
groups complain that they never receive the emails.


A lot of the times, after they alert me to the issue, I can educate them 
a little about the anti-spam measures they most likely have on their 
system, and walk them through how to make it so that my newsletters go 
through.


However, that is clearly not enough.

To shorten a story that has already gone on a little long, it's come to 
my attention that part of the reason that my emails may not be getting 
through are because the headers are not sufficiently legitimate looking 
enough to bypass some server side anti-spam measures. Things like 
Return-Path are being set so that they look like they come from an 
email address that begins with the username nobody.



mail($email, $subject, $mailContent, $fromAddress);


You need to set the 5th parameter to change who it comes from (instead 
of nobody). See php.net/mail for more info.



You can't change that parameter if safe-mode is on for the server or if 
exim doesn't have the webserver user as a 'trusted-user' (I think only 
exim is affected by this particular issue).


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

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



Re: [PHP] ftp_put and ftp_chmod does not work

2006-10-09 Thread Chris

João Cândido de Souza Neto wrote:

Hello everyone.

I have got some parts of my system where some files are sent and i use ftp 
functions to save suche files.


When i run it in my local machine, it works fine but, when it is on the 
server i got some errors.


I was using ftp_put to copy such files from upload_temp folder of php to my 
system own folder and it does not work, i thought it could be because the 
ftp user has no permission in upload_temp folder of php.


Most likely. ftp users are usually locked in to their own home folders 
and can't access any other parts of the system. It's simply a security 
thing.



Then i tried to use php_chmod to give permissions for the apache user, 
move_uploaded_files to move such file and ftp_chmod agais to remove 
permissions. It does not work too, i think it is because the server has 
safe_mode on.


chmod will be affected by safe mode (please read the documentation):

When safe mode is enabled, PHP checks whether the files or directories 
you are about to operate on have the same UID (owner) as the script that 
is being executed. In addition, you cannot set the SUID, SGID and sticky 
bits.



move_uploaded_file will always fail because the file isn't uploaded 
through a form. The documentation makes this rather clear (see also 
is_uploaded_file).


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

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