[PHP] object method overloading

2002-12-03 Thread Javier Montserat
can you do method overloading in php as you can in java?

Javier





_
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


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



[PHP] PHP download problem IE5 on mac

2002-11-14 Thread Javier Montserat
I'm using this code to various files for download via a http header -

$filename = basename($filepath);
header(Content-type: unknown/unknown);
header(Content-Disposition: attachment; filename=$filename);
readfile($filepath);

works fine in most cases - the save dialogue appears.  However -

IE on a MAC loads the file inline rather than throwing the save prompt.

Any ideas?

Javier





_
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


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



[PHP] Re: multiple file upload

2002-11-14 Thread Javier Montserat
Is it posible to do multiple file upload without selecting each file manual
in multiple form fields?


Yes.  I have recently implemented an upload mechanism based on hotmails add 
attachment mechanism.  haven't got time for a detailed explanation but here 
is the basic idea -

on your html page -
// a file selector field
input type=file name=userfile tabindex=1 class=text
// add remove files buttons
input type=submit name=addFile value=   Addclass=text  
tabindex=2
input type=submit name=delFile value=Remove class=text 
tabindex=3
// files in the upload list field
select name=selectedFileList[] size=5 multiple tabindex=4 class=text
?php
 $FooObj-displayFileUploadList();
?
/select

file upload list is a database varchar field with each file id seperated 
with a pipe character -

fileID1|fileID2

add / remove event handlers write / remove entries from this list.

displayFileUploadList writes option tags for each file in the list

finally a doUpload function retrieves the file upload list and copies the 
files from the upload staging area to their final destination.

Incidentally the same mechanism works for lots of other stuff like sending 
email to multiple recipients etc.

Have Fun,

javier





_
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail


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



[PHP] Re: multiple file upload

2002-11-14 Thread Javier Montserat
here's a couple of the more tricky code snippets which should make it easy 
for folks to see how a multiple file upload select can work - the rest is 
basically a lot of interaction with the database - storing / retrieving the 
upload list.

Its a bit tricky but worth it though - the users responcible for uploads via 
the system I built have been saying it makes their lives a lot easier.

If i get time i'll try and generalise the whole thing into an absract class 
that folks can use...


// remove a file from upload target list
function removeFileFromUploadList() {
	$this-getFileUploadList(); // get the upload list from the database
	$selectedFileList = $_POST['selectedFileList']; // an array of selected 
values from the multiple select box
	// diff the arrays, store the new list
	if ((sizeof($this-uploadFileList) = 1)  ($selectedFileList != )) {
		$this-uploadFileList = 
array_values(array_diff($this-uploadFileList,$selectedFileList)); // 
subtract remove items
		$this-storeFileUploadList();
	}
}


// add pipe encoding to an array (file upload list) and return a string for 
storage in db
function addPipeEncoding($array) {
	for ($i = 0; $i  sizeof($array); $i++) {
		$addPipe = ((sizeof($array) == 1) || ($i == sizeof($array)-1)) ?  : |;
		$returnValue .= $array[$i].$addPipe;
	}
	return $returnValue;
}


// remove pipe encoding from string
function removePipeEncoding($encodedString) {
	$split = explode(|,$encodedString);
	for ($i = 0; $i  sizeof($split); $i++) {
		if ($split[$i] != ) {
			$returnArray[] = $split[$i];
		}
	}
	return $returnArray;
}


_
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail


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



RE: [PHP] left click downloads

2002-11-13 Thread Javier Montserat
here is a simple function I have created to do single click downloads in php 
-

function sendFile($filepath) {
  $filename = basename($filepath);
  $mimeType = mime_content_type($filepath)
  header(Content-type: $mimeType);
  header(Content-Disposition: attachment; filename=$filename);
  readfile($filepath);
}

In Unix can anyone post a method of obtaining mimeType using the file 
command which could be compatible with this function?

I guess this is possible... my understanding is that mime_content_type() is 
based on unix file commands method of pattern matching 'magic bytes' of 
known file formats.

hope this is useful to some of you...

javier


From: David Russell [EMAIL PROTECTED]
To: 'Javier Montserat' [EMAIL PROTECTED]
Subject: RE: [PHP] left click downloads
Date: Tue, 12 Nov 2002 13:46:58 +0200

Hi Javier,

Nope, this is not a php thing at all. You could probably get it right
with Javascript or something similar.

HTH

David Russell
IT Support Manager
Barloworld Optimus (Pty) Ltd
Tel: +2711 444-7250
Fax: +2711 444-7256
e-mail: [EMAIL PROTECTED]
web: www.BarloworldOptimus.com

-Original Message-
From: Javier Montserat [mailto:codareef;hotmail.com]
Sent: 12 November 2002 01:24 PM
To: [EMAIL PROTECTED]
Subject: [PHP] left click downloads


I want to make it easier for people to download files from my website by

having the download start when the visitor clicks a link (as opposed to
right click / save target as).

How can I achieve this with PHP?  Do I include the file in a header()
call ?

Thanks,

javier





_
MSN 8 with e-mail virus protection service: 2 months FREE*
http://join.msn.com/?page=features/virus


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

 smime.p7s 



_
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. 
http://join.msn.com/?page=features/virus


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



[PHP] Re: Works in html, not when echoed in PHP

2002-11-13 Thread Javier Montserat

rather than using echo why not just do this -

?
body onload=start();initialize();onoff('mainmenu',section,'on')
onresize=window.location.reload(false) topmargin=1 bottommargin=0 
leftmargin=0 rightmargin=0
?

this way you don't have to worry about getting the quotes right...



Hello,

Aaron Merrick [EMAIL PROTECTED] wrote:

Folks,

Can't see an answer anywhere in the archives, so here goes.

This works fine in plain html:

body onload=start();initialize();onoff('mainmenu',section,'on')
onresize=window.location.reload(false) topmargin=1 bottommargin=0
leftmargin=0 rightmargin=0

When I put it in PHP thus:

echo body onload=\start();initialize();onoff('mainmenu',section,'on')\
onresize=\window.location.reload(false)\ topmargin=\1\
bottommargin=\0\ leftmargin=\0\ rightmargin=\0\;

When the page loads, I get an Error: 'menuObj' is null or not an object

The onoff() function is what contains the menuObj, so I suspect the single
quotes around the parameters mainmenu and on, but have tried everyway I

can

think of and can't get rid of the Error.

The function is thus:









_
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail


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



[PHP] left click downloads

2002-11-12 Thread Javier Montserat
I want to make it easier for people to download files from my website by 
having the download start when the visitor clicks a link (as opposed to 
right click / save target as).

How can I achieve this with PHP?  Do I include the file in a header() call ?

Thanks,

javier





_
MSN 8 with e-mail virus protection service: 2 months FREE* 
http://join.msn.com/?page=features/virus


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



[PHP] weird IE cookie problem

2002-10-14 Thread Javier Montserat

Hi

I've successfully been using the following code to set cookies in IE / NS / 
Mozilla.  I've just bought a new laptop and in IE 5.5 and 6 the cookies are 
not being set by my site.  Other sites (msn etc) set cookies fine.  I've 
installed Mozilla and this accepts cookies fine.  WTF is wrong with IE on 
this new machine...???

Has anyone encountered anything like this...???

Here's the code -

$cookiename = test;
$value = testvalue;
$expires = time()+3600;
$domain = mydomain.com;
$path = /;

$COOKIE = Set-Cookie: $cookiename=$value;

if (isset($expires)  ($expires  0)) {
$COOKIE .= ; EXPIRES=.
gmdate(D, d M Y H:i:s,$expires) .
 GMT;}
if (isset($domain)) { $COOKIE .= ; DOMAIN=$domain; }
if (isset($path))   { $COOKIE .= ; PATH=$path; }
if (isset($secure)  $secure0) { $COOKIE .= ;
SECURE; }
header($COOKIE,false);

// this doesn't work either ...
setcookie ( $cookiename , $value, $expires, $path, $domain);


_
Send and receive Hotmail on your mobile device: http://mobile.msn.com


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




Re: [PHP] weird IE cookie problem

2002-10-14 Thread Javier Montserat

ahhh.  a combination of incorrect timezone on my new laptop and the server 
time being slightly out was causing my head a lot of pain...

thanks for the pointer,

Jav


From: Marco Tabini [EMAIL PROTECTED]
To: Javier Montserat [EMAIL PROTECTED]
CC: [EMAIL PROTECTED]
Subject: Re: [PHP] weird IE cookie problem
Date: 14 Oct 2002 13:44:25 -0400

Is the time set properly on your machine? Double check both the time AND
the timezone. I went nuts trying to fix a similar problem once just to
find out that someone had changed the timezone on the PC for a test and
then forgot to put it back.


On Mon, 2002-10-14 at 13:25, Javier Montserat wrote:
  Hi
 
  I've successfully been using the following code to set cookies in IE / 
NS /
  Mozilla.  I've just bought a new laptop and in IE 5.5 and 6 the cookies 
are
  not being set by my site.  Other sites (msn etc) set cookies fine.  I've
  installed Mozilla and this accepts cookies fine.  WTF is wrong with IE 
on
  this new machine...???
 
  Has anyone encountered anything like this...???
 
  Here's the code -
 
  $cookiename = test;
  $value = testvalue;
  $expires = time()+3600;
  $domain = mydomain.com;
  $path = /;
 
  $COOKIE = Set-Cookie: $cookiename=$value;
 
  if (isset($expires)  ($expires  0)) {
  $COOKIE .= ; EXPIRES=.
  gmdate(D, d M Y H:i:s,$expires) .
   GMT;}
  if (isset($domain)) { $COOKIE .= ; DOMAIN=$domain; }
  if (isset($path))   { $COOKIE .= ; PATH=$path; }
  if (isset($secure)  $secure0) { $COOKIE .= ;
  SECURE; }
  header($COOKIE,false);
 
  // this doesn't work either ...
  setcookie ( $cookiename , $value, $expires, $path, $domain);
 
 
  _
  Send and receive Hotmail on your mobile device: http://mobile.msn.com
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 




_
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


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




[PHP] quotes in text strings

2002-10-02 Thread Javier Montserat

Hi

Single quote's in strings entered via a text input field are subsequently 
appearing with what appears to be an escape character -

comm\'ents

how can i correct this?  I've tried
htmlspecialchars($string, ENT_QUOTES);
and
htmlentities($string, ENT_QUOTES);

but these don't seem to work (maybe its me).

Thanks

Javier


_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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




[PHP] setting .htaccess authentication with PHP

2002-09-27 Thread Javier Montserat

Hello Everyone,

I've developed a feature which allows clients to upload files to a dir on 
the server.  I want to allow clients to email a url to the file as follows 
:-

http://www.mysite.com/clientX/file01.jpg

I want to setup challenge / response authentication on the client folder so 
that when someone clicks the link they are prompted for a username / 
password.  I'm thinking that apache .htaccess permissions are the best way 
to do this.  The server is running Linux.

My question is, can I write a PHP / shell script to automatically set folder 
access permissions and how would this be done?

Thanks,

Javier



_
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


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




[PHP] formatting a filename

2002-09-05 Thread Javier Montserat

i want to format the filename of an uploaded file as follows :-

-- replace blankspace with _

-- remove any illegal characters.

Which string functions should I use to do this?

Thanks,

Javier



_
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


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




[PHP] Re: formatting a filename

2002-09-05 Thread Javier Montserat

$filename = strtolower (eregi_replace ([^A-Za-z0-9_.], _, $filename));

seems to be what I want.

thanks to everyone for the help

Javier


_
Send and receive Hotmail on your mobile device: http://mobile.msn.com


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




[PHP] Re: XML vs Everything Else

2002-09-04 Thread Javier Montserat

Spend some time learning about xml and you won't regret it

Could you (or anyone else on the list) recommend some good resources (Books 
/ Websites) for learning XML and XSLT?

Thanks,

Javier




_
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


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




[PHP] sorting array question

2002-09-03 Thread Javier Montserat

i have the following code which reads a list of files from a directory -

$listcmd = ls  .$dirPath;
$temp = exec($listcmd, $listoffiles, $status);
if($status == 0) {
for ($i =0; $i  sizeof($listoffiles); $i++) {
   $this-fileName[$i] = $listoffiles[$i];
   $this-sizeofFile[$i] = sprintf(%01.2f, 
(filesize($dirPath./.$listoffiles[$i])/1024)/1024);
   $this-fileDate[$i] = date(d-M-y H:i, 
filemtime($dirPath./.$listoffiles[$i]));
}
$this-displayFiles();

What I want to do is display the files sorted by date.

Okay, so I've just realised that the really easy way to do this is by adding 
-St (sort by time) to the ls command...

$listcmd = ls -St  .$dirPath;

But how could this be achieved by sorting the three arrays?  What if I 
alternately wanted to sort the files by name, size or date without 
re-reading the directory each time?

Would an associative array structure be better suited to this type of 
operation?

Thanks for your insight,

Javier

_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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




[PHP] greeting based on time

2002-09-03 Thread Javier Montserat

really simple one -

does someone have a bit of code that will variously display 'good morning', 
'good afternoon', 'good evening' based on the current time?

good morning from london,

Javier



_
Send and receive Hotmail on your mobile device: http://mobile.msn.com


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




[PHP] Class operator :: Problem

2002-09-03 Thread Javier Montserat

?
class a {
  function test() {
 echo Hallo;
  }
}

$testfunct = a::test();
$testfunct;
?

i think because you assign a method to the variable rather than a data 
member you need to include parenthsis...

a::test()




I have problems to make a dynamic call, please help me

?
class a {
  function test() {
 echo Hallo;
  }
}

$testfunct = a::test;

$testfunct();

?

returns:
Fatal error: Call to undefined function: a::test() in
/usr/local/share/version2.mypsi.de/index.html on line 10

---
Christian Unger
IT-Consultant

PSI Infrastruktur Services GmbH
Dircksenstr. 42-44
10178 Berlin

Tel: 030 / 2801 - 2536
Fax: 030 / 2801 - 297 2536
e-Mail: [EMAIL PROTECTED]



_
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


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




[PHP] re: Refering to an object from within an array variable in another class

2002-09-03 Thread Javier Montserat

Hi,

Syntax B doesnt seem to work exactly because as you say it doesn't directly 
access the 'bars' variable...;

here...

$reference_to_bar = $this-GetBar($id) ;

it seems that a copy of the bar object is being created, which is a new 
object.  This new bar object is not related to the bar object which is a 
part of the $bars array property of the foo object.

When you set the marklar property to the new value ...

$reference_to_bar-SetMarklar($value) ;

the value is changed for the new copy of the bar object you have just 
created.  Because this value is assigned to the new object it doesn't appear 
when you print the contents of foo.  This is illustrated by the lines i've 
added below.

Maybe after setting the new property value you could reassigned this object 
to the $bars array of object foo.

I'm no expert but it's always fun to play with code...

Hope this helps in some way,

Javier

/*
But this syntax doesn't: and this
would be prefered, as it doesn't directly
access the 'bars' variable...
*/

$reference_to_bar = $this-GetBar($id) ;
echo $reference_to_bar-marklar;
$reference_to_bar-SetMarklar($value) ;
echo $reference_to_bar-marklar;
print_r($reference_to_bar);


_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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




[PHP] re: Refering to an object from within an array variable in another class

2002-09-03 Thread Javier Montserat

I believe the following discussion from Web Application Development with PHP 
4.0 (available online at http://safari.oreilly.com) may shed some light on 
your question...



Whenever PHP encounters a statement for which write access to a variable is 
needed, it evaluates and calculates the data that will be written into the 
variable, copies it, and assigns the result to the target space in memory. 
(This description is a little bit simplified, but you get the idea.)


$some_var = 2;

$my_var = $some_var * 3;

$new_var = $some_var + $my_var;

Looking at this script, PHP will

Create space for $some_var and write 2 into it.

Create space for $my_var, retrieve the value of $some_var, multiply it by 3, 
and assign it to the newly allocated memory.

Create space for $new_var, retrieve the values of $some_var and $my_var, 
total them, and write them back to the new place in memory.

Well, this sounds nice and logical—but these are simple types and you've 
worked with them many times already. Things are very different (and 
illogical) when PHP is handling classes:


class my_class
{
   var $var1, $var2, $var3;
}

$my_object = new my_class;

$my_object-var1 = 1;
$my_object-var2 = 2;
$my_object-var3 = 3;

$new_object = $my_object;

$new_object-var1 = 3;
$new_object-var2 = 2;
$new_object-var3 = 1;

print(My object goes $my_object-var1, $my_object-var2, $my_object-var3 
!br);
print(New object goes $new_object-var1, $new_object-var2, 
$new_object-var3 !br);

What do you think this will produce as output? The script first declares a 
class, creates one instance of it, and assigns values to its three 
properties. After having done this, it creates a new reference to this 
object, reassigns its properties, and then just prints out each property by 
using both references. Remember, one instance. Figure 2.7 shows the result.

Figure 2.7. PHP creating a copy instead of a reference.

If you're not surprised now, you either know PHP very well already or 
haven't thought enough about objects yet. PHP has created a copy, a new 
instance of my_class instead of just a new reference! This is not the 
desired behavior, since the new operator is supposed to create an instance 
of my_class in memory, returning a reference to it. Thus, when assigning 
this reference to another variable, only the reference should be copied, 
leaving the original data untouched—similar to a file system link, which 
allows access to the same data through different locations on the file 
system. This behavior of PHP—creating copies of referenced data rather than 
just the reference itself—may not sound important enough to focus on; 
however, you'll see in a moment that it actually does make a difference.

Note:   At the time of this writing, both PHP 3.0 and PHP 4.0 are using copy 
syntax. A chat with someone closely involved in the core development 
revealed that the plan is to change the default behavior to use a reference 
syntax, but this change would cause a loss of backward compatibility. A 
possible change is planned with version 4.1—if this happens, information 
contained here will be invalid for all future versions.

Web Application Development with PHP 4.0

Tobias Ratschiller
Till Gerken
Zeev Suraski
Andi Gutmans
Publisher: New Riders Publishing
First Edition July 12, 2000
ISBN: 0-7357-0997-1, 416 pages



_
Send and receive Hotmail on your mobile device: http://mobile.msn.com


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




[PHP] Re: how do I send information to a php page from a menu list

2002-09-02 Thread Javier Montserat

different approach using JavaScript...

script language=JavaScript
// drop down redirect
function doRedirect(value) {
   if ((value != ) || (value != 0)) {
  self.location=value;
   } else {
 alert('Please Make a Selection');
 return false;
  }
}

//--
/script

form
select name=name 
onchange=javascript:dropdown(this.options[this.selectedIndex].value)
   option value=0lt; make a selection gt;
   option value=your_php_page.php?? echo $your_value1 ?? echo 
$your_value1 ?/option
   option value=your_php_page.php?? echo $your_value2 ?? echo 
$your_value2 ?/option
/select
/form


Bueno,

Javier

--=_NextPart_000_0055_01C252D0.ADA4A940
Content-Type: text/plain;
charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

Hello,
how do I send information to a php page from a menu list?

When a user selects an item from the list I would like to be able to =
send selcategoryid to faqbycat.php without the use of a submit button.

Is it done by using the onChange event? if so how may this be done?

The code I am using presently is below

form action=3Dfaqbycat.php
 select name=3Dselcategoryid value=3D0
  option name=3Dselcategoryid value=3D0 selectedSelect a =
Category/option
   ?php
   //display list of provider names
while ($myrowcating=3DMySQL_fetch_array($resultcatdet))
 {
  $faqcatsid=3Dstripslashes($myrowcating[breastfaqcatid]);   =20
  $faqcats=3Dstripslashes($myrowcating[breastfaqcat]);
  echo option name=3D\selcategoryid\ =
value=3D\$faqcatsid\$faqcats/option;
 }//while =
($myrowadmintitles=3DMySQL_fetch_array($admintilteresult))
   ?=20
 /select
 brbr
 input type=3DSubmit name=3Dselbycat value=3DShow FAQ's by =
Category
/form =20

Thanks for your answer,
Ivan

--=_NextPart_000_0055_01C252D0.ADA4A940--



_
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


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




[PHP] setcookie IE6 problem

2002-08-29 Thread Javier Montserat

I'm setting a session cookie with the following code -

function setSessionCookie(){
   $expires = time()+$this-session_expires;
   $issetCookie = setcookie($this-cookiename,
$this-sess_id,
$expires,
/,

   );
}

Occasionally setcookie seems to fail in IE6, or perhaps when I subsequently 
retrieve the cookie as a part of the authentication code on each page IE6 
fails to pick up the cookie - either way I get logged out.

Other browsers (NS4, IE5, IE5.5) seem okay.

Any Ideas?

Javier


_
Send and receive Hotmail on your mobile device: http://mobile.msn.com


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




Re: [PHP] setcookie IE6 problem

2002-08-29 Thread Javier Montserat

Thanks for the reply, a little more info below...

Speaking of cookies, any general thoughts on the relative merits of using 
php's setcookie function vs. setting a cookie with a header() call?  Are 
both methods equal?

Will do more research later and post anything interesting on the IE6 
issue...

. . . . .
php manual - setcookie notes
[EMAIL PROTECTED] wrote -
MSIE 6 has a inaccurate definition of third party cookies. If your domain is 
hosted on one server and your PHP stuff is on another, the IE6 p3p 
implementation considers any cookies sent from the second machine third 
party.
Third party cookies will be blocked automatically in most privacy settings 
if not accompanied by what MS considers an appropriate Compact Policy. In 
order to make this new piece of tweakable garbage happy I'd suggest you'd 
par exemple send
header('P3P: CP=NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM');
before sending your cookie from your second machine.
This header enables your cookie to survive any privacysetting.

MS has introduced p3p policy in IE6 which has impacted on cookies etc. If
the site or host does not have a machine generated xml privacy statement,
then stability with regards
to cookies is not guaranteed. Do a search and read up about it. Check out
w3c's site.

- Original Message -
From: Javier Montserat [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, August 29, 2002 1:39 PM
Subject: [PHP] setcookie IE6 problem


  I'm setting a session cookie with the following code -
 
  function setSessionCookie(){
 $expires = time()+$this-session_expires;
 $issetCookie = setcookie($this-cookiename,
  $this-sess_id,
  $expires,
  /,
  
 );
  }
 
  Occasionally setcookie seems to fail in IE6, or perhaps when I
subsequently
  retrieve the cookie as a part of the authentication code on each page 
IE6
  fails to pick up the cookie - either way I get logged out.
 
  Other browsers (NS4, IE5, IE5.5) seem okay.
 
  Any Ideas?
 
  Javier
 
 
  _
  Send and receive Hotmail on your mobile device: http://mobile.msn.com
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 




_
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


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




[PHP] Re: Cannot get data from form.

2002-08-29 Thread Javier Montserat

Turning off register globals and referencing variables through the new array 
syntax certainly gives a greater degree of control over the origin of data; 
ie: a variable referenced $_POST['foo'] has (most likely) been received as a 
result of http post and it's reasonably safe to assume $_COOKIE['foo'] is a 
value from a cookie etc.  In this example with globals=on $foo could have 
come from anywhere...

The only thing i've found a bit annoying is when a value can be passed 
variously by a form (method=post) or as a query string value appended to a 
link uri.

Writing...

if (isset($_GET['foo'])) {
  $foo = $_GET['foo']
} elseif (isset($_POST['foo'])) {
  $foo = $_POST['foo']
}

when I want to use $foo is a bit annoying, but i haven't figured out a more 
elegant way of saying this yet.


Javier



That's the way it works in the newer PHP for security reasons.  I had to 
rewrite all my
code about a week ago because my client was using php 4.2 and I had 4.0.  It 
has to do
with the Globals are set to being turned off in the php.ini file.  You 
should be able to
change the php.ini file to globals on, but people will argue that it's a 
security problem
and you should just change all your global varieables to the new way.  It's 
your call.
Hope this helps.

Brian


Le Van Thanh wrote:

- I have installed PHP4.2.2 with Apache 1.3.26 on Solaris7.
And now I have problems with getting data from form.
I have 2 pages test.html and welcome.php as following:

test.html
form userDetails method=post action=welcome.php
 Enter your Name: br
 input type=text  value= name=name
 input type=submit value=Enter name=welcome
/form
--welcome.html-

?php
 print  $name ;
?

===

Then I cannot get the value of input name.
But if I write  print $_POST['name']; or  print 
$HTTP_POST_VARS['name'];, it's ok.

Is there something wrong when I install PHP?
Thanks a lot.

--
Brian Windsor
Giant Studios
Senior Technical Director of Motion Capture
[EMAIL PROTECTED]
(404)367-1999





_
Send and receive Hotmail on your mobile device: http://mobile.msn.com


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




[PHP] insert query fails w/ postgres database

2002-08-22 Thread Javier Montserat

Hello PHP people...

I'm trying to insert a filename (string) into a postgres database field but 
the insert query is failing -

Warning: pg_exec() query failed: ERROR: oidin: error in 
abc_abcde012_010_mpeg1.mpeg: can't parse abc_abcde012_010_mpeg1.mpeg
in /usr/local/apache/htdocs/filename.php on line 835

Here's the query -

$addFileResult = pg_exec($db-db, INSERT INTO 
files(filename,type,size,uploaded) VALUES 
('$this-uploadedFileName','$this-uploadedFileType','$this-uploadedFileSize','now'::datetime));

Table looks like this -

CREATE TABLE files
(
filename oid,
type varchar(30),
size int,
uploaded datetime
);

Any Ideas?

Saludos,

Javier




_
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


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




[PHP] oops - solved re: insert fails w/ postgres database

2002-08-22 Thread Javier Montserat



the filename field is of type 'oid' rather than 'character varying'...

yep, inserting a string into an oid feild will make the db baarrrfff...

Saludos

Javier

_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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




[PHP] exec / mkdir question

2002-08-12 Thread Javier Montserat

i'm using the following code to create a directory :-

$temp = exec(mkdir $path);

it doesn't work...

i've validated the $path var which is correct.  i suspect it is a 
permissions issue.

what should i look for to resolve this?

thanks,

javier



_
Send and receive Hotmail on your mobile device: http://mobile.msn.com


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




[PHP] Login / Authentication Class

2002-07-23 Thread Javier Montserat

I've been developing a simple (protecting nuclear secrets it aint) login / 
authentication class library.

This code is designed to -

1. check unname  password are completed
2. check uname  password contain only permitted chars (a-z,1-9)
3. match user against dbase user table
4. generate a unique session token
5. store session token in dbase
6. set client side session cookie

I've attached the code here in the hope that it may be of use to some of 
you.  I also welcome any feedback regarding problems / security shortcomings 
or ways it can be improved.

Happy Coding...

Notes -

-- dbase is postgres (dbase stuff should probably should be abstracted to 
make the code platform independant)

-- password encyrption is done using CRYPT_STD_DES rather than md5 because 
of legacy data (passwords in current dbase are crypted like this)

Here's the code...

begin index.html 

?php

include(./lib/doLogin.inc);

?

end index.html

begin doLogin.inc 

?php

/*
App Name Here ---
doLogin.inc
** login validation / user authentication **
*/


// dbase class
include(./lib/db.inc);
// log class
//include(./lib/log.inc);

$uname = $_POST['uname'];
$pass = $_POST['pass'];

// if login form submitted do authentication
if ((isset($uname))  (isset($pass))) {
$doLogin = new doLogin($uname,$pass);
} else {
displayLogin();
}


/// -


class doLogin {

function doLogin($uname,$pass) {

$this-uname = $uname;
$this-pass = $pass;
$this-cookieName = cookieName;

$this-authUser();
}


   // validate  authenticate
function authUser(){


// check that both uname  password are complete
$this-loginDataComplete();

// check uname  pass contain only valid chars
$this-validateLogin();

// create dbase object
$db = new db();

// encrypt password
$cryptedpass = crypt($this-pass,CRYPT_STD_DES);

// select user  password from dbase
$userQuery = pg_exec($db-db, select oid, adminuser from user where 
username = '$this-uname' and  pass = '$cryptedpass');

if (pg_NumRows($userQuery) != 1) {
$this-halt();
} else {
$user_oid = pg_Result($userQuery, 0, oid);
$this-adminUsr = pg_Result($userQuery, 0, adminuser);

// generate unique md5 crypted session token
$this-createSessionID();

// write session token 2 user table
  $resultSessid = pg_Exec($db-db, update user set sessid = 
'$this-session_id' where oid = $user_oid);

// set session cookie
$this-setSessionCookie();

// authentication complete
// redirect 2 welcome page here
}
}



// check uname  password are not empty
function loginDataComplete(){
if ((!isset($uname)) || (!isset($pass))) {
$this-halt;
} else {
return;
}
}


// do login char validation
function validateLogin() {
if ( (!$isValidUname = $this-validateChars($this-uname)) || 
(!$isValidPass = $this-validateChars($this-pass)) ) {
//$this-halt();
} else {
return;
}
}


// validates login against permitted chars
function validateChars($what){
$isValid = (ereg(^([A-Za-z0-9_]*)$, $what)) ? true : false;
return $isValid;
}


// create unique md5 encrypted session token
function createSessionID() {
srand((double)microtime()*100);
$this-session_id = md5(uniqid(rand()));
return;
}


// set cookie with encrypted session token
function setSessionCookie(){
$issetCookie = setcookie($this-cookieName, $this-session_id, 
time()+7200);  /* expire in 1 hour */
if (!$issetCookie == 1) {
$this-halt();
} else {
return;
}
}


// record logon attempt 2 in log
function recordLogin(){
$log = new log;
$log-record();
}



// halt  display errors
function halt() {
// authentication failed display login form
displayLogin();
// write login attempt to log here
// call 2 optional error msg handler here
}



} // end authentication class 

[PHP] re: OO Programming - get practical

2002-07-23 Thread Javier Montserat

For a really good overview of the OO programming read Thinking in Java by 
Bruce Eckel.  What you learn can then easily be applied to your coding 
practices in PHP.

The author has made the book available for free from his site

www.mindview.com





_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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




[PHP] control structure question

2002-07-23 Thread Javier Montserat

is there a more programmatically elegant way of saying...

$isError = ;

function main() {

doStep1();

if (!$isError) {
doStep2();
}

if (!$isError) {
doStep3();
}
// etc. etc.
}

function doStep1() {
if ($something) {
$isError = 1;
}
}

function doStep2() {
if ($something) {
$isError = 1;
}
}

_
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


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




Re: [PHP] control structure question

2002-07-23 Thread Javier Montserat

So refering back, i re-wrote the original example using the switch syntax...

switch (true) {
case doStep1():
case doStep2():
case doStep3():
  error();
  break;
default:
  valid();
}

Each case expressions is evaluated, until one of them evaluates to a value 
equal (==) to the switch expression (in this case a boolean error flag).

The error() code will only be called if one of the doStep() evaluates to 
false.

And the valid() code will only be evaluated if the switch reached the 
default, which means that none of the above check returned false

I think for this example the switch syntax is more elegant than using a 
series of if() statements.

Thanks,
Javier

For steps and sequences, I always use switches.  Most commonly associated 
with the action variable, it would look like this:

switch($action) {
default:
   // what to show if no variable exists, or is set to a value
   // that is not acceptable below
break;
case add_file:
   // what to do in the even that a file needs to be added
   // to the database.
break;
case remove_file:
   // what to do in the even that a file need sto be removed
   // from the database.
break;
}

Basically, whatever the value of $action, that is what section of code will 
execute.  Hope that helps!

Martin Clifford
Homepage: http://www.completesource.net
Developer's Forums: http://www.completesource.net/forums/


  Javier Montserat [EMAIL PROTECTED] 07/23/02 10:03AM 
is there a more programmatically elegant way of saying...

$isError = ;

function main() {

 doStep1();

 if (!$isError) {
 doStep2();
 }

 if (!$isError) {
 doStep3();
 }
 // etc. etc.
}

function doStep1() {
 if ($something) {
 $isError = 1;
 }
}

function doStep2() {
 if ($something) {
 $isError = 1;
 }
}

_
Join the world's largest e-mail service with MSN Hotmail.
http://www.hotmail.com


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






_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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