[PHP] Removing Risky Characters

2003-03-22 Thread Tom Rawson
When validating user input to remove quotes and other characters that 
can be used for hacks, does one need to be concerned about the high-
ASCII characters which have 'quote' meanings (e.g. 0x91 - 0x94).  I 
presume not, but just wanted to verify that PHP will not interpret 
these as quotes.

 ------
 Tom Rawson




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



[PHP] Creating Session Variables

2003-04-03 Thread Tom Rawson
Hmmm, this doesn't seem clear in the docs ...

Consider this:

function foo() {
$_SESSION['varname'] = "test";
.
}

At this point:

- Can I reference $varname inside the function?  If so, must it be 
declared global first?  Or can I only reference it via 
$_SESSION['varname']?

- Can I reference it outside the function (as $varname) after the 
function returns?

In other words if one creates a variable by adding it to the session 
array, does it then become a variable in either the global or (though I 
can't quite imagine this) current local scope?

Thanks,

 --
 Tom Rawson




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



[PHP] Session Vars and Performance

2005-02-14 Thread Tom Rawson
I have a multi-page form which I build up and store in session 
variables.  The data saved includes all an internal list of items on 
the form (derived from a database table), all the form field specs 
(derived from the internal item list), the data for the fields (from 
another table), default data for restting the form (from yet another 
table), and a data structure for my forms class.

It adds up to about 250KB in the actual session file -- that is, the 
serialized data.

I'm not clear of the impact this will have in performance when it's in 
a multi-user environment, and I'm not sure at what point the overhead 
of serializing and unserializing gets to be more than the overhead of 
sticking this stuff in a temporary database table and then retrieving 
it.  Serializing is simpler but my git says there has to be a point at 
which it gets inefficient.  Testing is complex since I would have to 
write all the database code in order to do any performance measurement.

Anyone have relevant experience in this area, and/or some educated 
guesses?

Thanks,

--
Tom

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



[PHP] Selectively Extract Sub-Array from an Array

2005-04-13 Thread Tom Rawson
On PHP 4.3.x ... (not using PHP 5)

Say I have two arrays, the first has keys 'key1' ... 'key20'.  The 
second has some other keys with different names (i.e. they do not 
overlap those in the first array).  I want to add certain elements from 
array1 to array2.  I can do it like this:

$array2['key3'] = $array1['key3'];
$array2['key8'] = $array1['key8'];
$array2['key17'] = $array1['key17'];

or like this:

$array2 += array('key3' => $array1['key3'], 'key8' => $array1['key8'],
'key17' => $array1['key17']);

What would be nicer is something like:

$array2 += array_select($array1, 'key3', 'key8', 'key17');

In other words ... a way to create an array that is a selected subset 
of another.

Is there a function that does this that I'm missing?  I realize I could 
write one but I was looking for something built-in.  Nothing I can see 
under array functions in the manual seems to do it.

Thanks,

--
Tom

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



[PHP] Re: [PHP-WIN] Localhost not working with cookies

2005-04-17 Thread Tom Rawson
On 18 Apr 2005 Proudly Pinoy wrote:

> I've read from php.net/setcookie and codecomments.com that using
> localhost won't work with cookies and neither are IP addresses. So
> how do I test cookies on local system? 

Hmmm, this works just fine for me -- I do it all the time.  I tend to 
do it with a domain mapped to 127.0.0.1 via the hosts file, rather than 
"localhost", but using that approach I can set cookies fine under Win98 
(as far as I remember, not using it now), Win 2000, and Win XP, in both 
Mozilla and IE.  I am running Apache 1.3.29 as the local server in all 
cases.

--
Tom

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



[PHP] Avoiding NOTICEs on Array References

2005-01-26 Thread Tom Rawson
I have many places where I use references like this:

if ($fields['flags']['someflag']) ...

or perhaps

if ($_POST['checkboxfieldname']) ...

If there is no value for 'someflag', or if the check box was not 
checked -- both of which are often the case -- these generate errors at 
level E_NOTICE.  Is there any way to prevent references to missing 
array elements from generating errors without turning off all E_NOTICE 
notifications?

Thanks,

--
Tom

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