php-general Digest 13 Mar 2006 01:21:04 -0000 Issue 4012

Topics (messages 231801 through 231822):

what would a c extension buy me
        231801 by: joseph
        231820 by: Chris

Re: PHP/CSS/Javascript question
        231802 by: tedd
        231803 by: Satyam
        231804 by: tedd
        231805 by: Satyam
        231815 by: Anas Mughal
        231817 by: tedd
        231819 by: Satyam

Phone number validation
        231806 by: Paul Goepfert
        231807 by: Curt Zirzow
        231811 by: Paul Goepfert
        231813 by: Curt Zirzow
        231814 by: Paul Goepfert
        231816 by: tedd
        231821 by: Anthony Ettinger

Re: Why Session can't be timed out!
        231808 by: Curt Zirzow

Re: PDOStatement::execute() Return Values
        231809 by: Curt Zirzow

Re: DB calls vs Session solution
        231810 by: Curt Zirzow

Re: X-Mailer and headers when sending mail
        231812 by: Curt Zirzow

Re: LDAP and Single Sign On MORE THOUGHTS
        231818 by: Rick Emery

determining client's external IP
        231822 by: David Calkins

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:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
hi,
my site is www.myowndictionary.com
i use javascript to create definitions for words (from open source
dictionaries) as pop-ups and hook word-lists for vocabulary study with
that.  
i can now parse the html from rss feeds and match only text of interest.
i just wrote my own multibyte html parser by combining various other
code i already had on hand for the parsing of multibyte text anyhow.  
but, that's not the slowest part.  that takes maybe 3 seconds to get the
page, 3 seconds to parse it, but it sometimes takes 5 minutes for the
next step on huge rss files.
(I know the time because they are cached)
that last step...
The slow part that's left is the dictionary searching itself.  It's the
parsing of complicated php code -- 550 lines of complex data structure
loops, function calls, looping through arrays to make sql queeries --
lots of sql queeries.... 
the seconds ~ 5 minute it takes it all takes so much time.  

i want to ask for opinion about:
1) rewriting the php as C extension.  Would it slow my down to the below
15 second range?
2) does mysql have server-side functions yet?
3) if i moved the php code off mysql to postgresql and wrote server-side
functions (which i've been trained to do), how much of a time
improvement would we be talking about?

please send me your input!  
i am at a growing stage and need direction here.  
because any of those steps will require considerable time.  

thank you.

joseph.

--- End Message ---
--- Begin Message ---
joseph wrote:
hi,
my site is www.myowndictionary.com
i use javascript to create definitions for words (from open source
dictionaries) as pop-ups and hook word-lists for vocabulary study with
that. i can now parse the html from rss feeds and match only text of interest.
i just wrote my own multibyte html parser by combining various other
code i already had on hand for the parsing of multibyte text anyhow. but, that's not the slowest part. that takes maybe 3 seconds to get the
page, 3 seconds to parse it, but it sometimes takes 5 minutes for the
next step on huge rss files.
(I know the time because they are cached)
that last step...
The slow part that's left is the dictionary searching itself.  It's the
parsing of complicated php code -- 550 lines of complex data structure
loops, function calls, looping through arrays to make sql queeries --
lots of sql queeries.... the seconds ~ 5 minute it takes it all takes so much time.
i want to ask for opinion about:
1) rewriting the php as C extension.  Would it slow my down to the below
15 second range?

Who knows? We don't know what the code does or how it works.

C will be quicker because it's already compiled. It will be harder to maintain and debug because it's compiled.

2) does mysql have server-side functions yet?

Mysql 5 has stored procedures if that's what you mean.

3) if i moved the php code off mysql to postgresql and wrote server-side
functions (which i've been trained to do), how much of a time
improvement would we be talking about?

See # 1.

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

--- End Message ---
--- Begin Message ---
Hi all,

Is it possible to modify a table using JavaScript to control CSS
visabilty when the entire table is developed dynamically using PHP?

Thanks,
Paul

Paul:

I am sure that you can change css via javascript, but you can as well with php -- see:

http://www.sperling.com/examples/styleswitch/

tedd
--
--------------------------------------------------------------------------------
http://sperling.com

--- End Message ---
--- Begin Message ---

>Hi all,

Is it possible to modify a table using JavaScript to control CSS
visabilty when the entire table is developed dynamically using PHP?

Thanks,
Paul

You don't need to change the CSS (I don't even know if it is possible), but you can change specific styles of any element within the HTML. For example:

document.getElementById('IdOfDivContainingTable').style.display='none';

It is particularly usefull to enclose whichever set of elements that you wish to change into a single entity, a DIV or SPAN, if at all possible.

Styles assigned in this way have precedence over those from a style sheet

Satyam

--- End Message ---
--- Begin Message ---
 >Hi all,

Is it possible to modify a table using JavaScript to control CSS
visabilty when the entire table is developed dynamically using PHP?

Thanks,
Paul

Satyam said:

You don't need to change the CSS (I don't even know if it is possible), but you can change specific styles of any element within the HTML. For example:

Yes, it's just a text file -- it can be re-written. However, it needs to be loaded again to take affect.

document.getElementById('IdOfDivContainingTable').style.display='none';

It is particularly usefull to enclose whichever set of elements that you wish to change into a single entity, a DIV or SPAN, if at all possible.

That's the main principle of ajax, isn't it? Using DOM to apply changes within the document. It might be old-hat to most, but I find it fascinating.

Styles assigned in this way have precedence over those from a style sheet

The precedence is simply inheritance -- last stated is applied.

tedd

--
--------------------------------------------------------------------------------
http://sperling.com

--- End Message ---
--- Begin Message --- ----- Original Message ----- From: "tedd" <[EMAIL PROTECTED]>


 >Hi all,

Is it possible to modify a table using JavaScript to control CSS
visabilty when the entire table is developed dynamically using PHP?

Thanks,
Paul

Satyam said:

You don't need to change the CSS (I don't even know if it is possible), but you can change specific styles of any element within the HTML. For example:

Yes, it's just a text file -- it can be re-written. However, it needs to be loaded again to take affect.

And it affects all documents of all users. Suddenly, by the action of one user, all other users reaching the same page will see things as per the actions of another user. Unless you take care to keep separate CSS files.

document.getElementById('IdOfDivContainingTable').style.display='none';

It is particularly usefull to enclose whichever set of elements that you wish to change into a single entity, a DIV or SPAN, if at all possible.

That's the main principle of ajax, isn't it? Using DOM to apply changes within the document. It might be old-hat to most, but I find it fascinating.


No, this is not AJAX, it is simply using the DOM. Ajax also involves communication with the server in the background.

Styles assigned in this way have precedence over those from a style sheet

The precedence is simply inheritance -- last stated is applied.

No, if you dynamically load a new stylesheet after you set the style of an element using the DOM, this style would still have precedence over the new stylesheet. The precedence of styles is set by how you set it. Setting a style through the DOM has precedence over CSS attributes, which have precedence over styles specified by the style HTML attribute which has precedence over the default rendering of an element. Only within the same category the order of assignment would matter.

And, by the way, yes, you can load a new stylesheet.

Satyam




tedd

--
--------------------------------------------------------------------------------
http://sperling.com

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




--- End Message ---
--- Begin Message ---
JF on March 11th answered it appropriately.
Please take this topic off this group.
Thanks.



On 3/12/06, Satyam <[EMAIL PROTECTED]> wrote:
>
> ----- Original Message -----
> From: "tedd" <[EMAIL PROTECTED]>
>
>
> >>  >Hi all,
> >>>
> >>>Is it possible to modify a table using JavaScript to control CSS
> >>>visabilty when the entire table is developed dynamically using PHP?
> >>>
> >>>Thanks,
> >>>Paul
> >
> > Satyam said:
> >
> >>You don't need to change the CSS (I don't even know if it is possible),
> >>but you can change specific styles of any element within the HTML. For
> >>example:
> >
> > Yes, it's just a text file -- it can be re-written. However, it needs to
> > be loaded again to take affect.
>
> And it affects all documents of all users.  Suddenly, by the action of one
> user, all other users reaching the same page will see things as per the
> actions of another user.  Unless you take care to keep separate CSS files.
> >
> >>document.getElementById('IdOfDivContainingTable').style.display='none';
> >>
> >>It is particularly usefull to enclose whichever set of elements that you
> >>wish to change into a single entity, a DIV or SPAN, if at all possible.
> >
> > That's the main principle of ajax, isn't it? Using DOM to apply changes
> > within the document. It might be old-hat to most, but I  find it
> > fascinating.
> >
>
> No, this is not AJAX, it is simply using the DOM.  Ajax also involves
> communication with the server in the background.
>
> >>Styles assigned in this way have precedence over those from a style
> sheet
> >
> > The precedence is simply inheritance -- last stated is applied.
>
> No, if you dynamically load a new stylesheet after you set the style of an
> element using the DOM, this style  would still have precedence over the
> new
> stylesheet.  The precedence of styles is set by how you set it.  Setting a
> style through the DOM has precedence over CSS attributes, which have
> precedence over styles specified by the style HTML attribute which has
> precedence over the default rendering of an element.   Only within the
> same
> category the order of assignment would matter.
>
> And, by the way, yes, you can load a new stylesheet.
>
> Satyam
>
>
>
> >
> > tedd
> >
> > --
> >
> --------------------------------------------------------------------------------
> > http://sperling.com
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Anas Mughal

--- End Message ---
--- Begin Message ---

Yes, it's just a text file -- it can be re-written. However, it needs to be loaded again to take affect.

And it affects all documents of all users. Suddenly, by the action of one user, all other users reaching the same page will see things as per the actions of another user. Unless you take care to keep separate CSS files.

Yes, that's true -- but I was thinking that the user was the coder and that's what he/she wanted to do -- not that it was open to users to change per their whim.

Perhaps I misunderstood the original post.

document.getElementById('IdOfDivContainingTable').style.display='none';

It is particularly usefull to enclose whichever set of elements that you wish to change into a single entity, a DIV or SPAN, if at all possible.

That's the main principle of ajax, isn't it? Using DOM to apply changes within the document. It might be old-hat to most, but I find it fascinating.


No, this is not AJAX, it is simply using the DOM. Ajax also involves communication with the server in the background.

Yes, you are correct -- thanks for the clarification. At this point in my learning, both appear so intertwined that they are synonymous.

Styles assigned in this way have precedence over those from a style sheet

The precedence is simply inheritance -- last stated is applied.

No, if you dynamically load a new stylesheet after you set the style of an element using the DOM, this style would still have precedence over the new stylesheet. The precedence of styles is set by how you set it. Setting a style through the DOM has precedence over CSS attributes, which have precedence over styles specified by the style HTML attribute which has precedence over the default rendering of an element. Only within the same category the order of assignment would matter.

And, by the way, yes, you can load a new stylesheet.

As Johnny Carson said often "I didn't know that!" -- thanks.

So it's: DOM > CSS > HTML > Browser Default -- is that the precedence you are saying?

tedd
--
--------------------------------------------------------------------------------
http://sperling.com

--- End Message ---
--- Begin Message --- ----- Original Message ----- From: "tedd" <[EMAIL PROTECTED]>



Yes, it's just a text file -- it can be re-written. However, it needs to be loaded again to take affect.

And it affects all documents of all users. Suddenly, by the action of one user, all other users reaching the same page will see things as per the actions of another user. Unless you take care to keep separate CSS files.

Yes, that's true -- but I was thinking that the user was the coder and that's what he/she wanted to do -- not that it was open to users to change per their whim.

Perhaps I misunderstood the original post.


Well, the original question was quite short. Either of us might be right or wrong. I assumed the case of a table with optional sub-items, like an expanding tree, or a menu or a table with categories where you want to expand any of the categories into its components.

document.getElementById('IdOfDivContainingTable').style.display='none';

It is particularly usefull to enclose whichever set of elements that you wish to change into a single entity, a DIV or SPAN, if at all possible.

That's the main principle of ajax, isn't it? Using DOM to apply changes within the document. It might be old-hat to most, but I find it fascinating.


No, this is not AJAX, it is simply using the DOM. Ajax also involves communication with the server in the background.

Yes, you are correct -- thanks for the clarification. At this point in my learning, both appear so intertwined that they are synonymous.

Styles assigned in this way have precedence over those from a style sheet

The precedence is simply inheritance -- last stated is applied.

No, if you dynamically load a new stylesheet after you set the style of an element using the DOM, this style would still have precedence over the new stylesheet. The precedence of styles is set by how you set it. Setting a style through the DOM has precedence over CSS attributes, which have precedence over styles specified by the style HTML attribute which has precedence over the default rendering of an element. Only within the same category the order of assignment would matter.

And, by the way, yes, you can load a new stylesheet.

As Johnny Carson said often "I didn't know that!" -- thanks.

So it's: DOM > CSS > HTML > Browser Default -- is that the precedence you are saying?


That's what my manual says. I remembered there was some precedence issue from some code of mine, some time ago, that didn't work as expected. I think it was a style="" attribute that wasn't working while when assigning it via the DOM did, and I couldn't figure out until I realized that a CSS definition was in between, having higher precedence than the style attribute, but lower than the DOM. One of those bugs that drive you nuts.

Satyam

tedd
--
--------------------------------------------------------------------------------
http://sperling.com



--- End Message ---
--- Begin Message ---
Hi all,

I am trying to validate phone numbers in a web form that I have
created.  I am using a regular expression to validate the phone
number.  It seems when I enter the phone number in the following ways
I get errors

(123) 456 7890
123 456 7890
(123) 456 - 7890
123 456-7890

I am using the ereg method in php to test the regular expression. 
Here is the Regular Expression that I am using to test against
potential phone numbers

$validPhone = "^([0-9]{3}[ ]*)?[0-9]{3}[ ]*[0-9]{4}$";

By the way The phone numbers are in US format.

If anyone can help me with this I would really appreciate it.

Thanks,
Paul

--- End Message ---
--- Begin Message ---
On Sun, Mar 12, 2006 at 12:09:42PM -0700, Paul Goepfert wrote:
> Hi all,
> 
> I am trying to validate phone numbers in a web form that I have
> created.  I am using a regular expression to validate the phone
> number.  It seems when I enter the phone number in the following ways
> I get errors
> 
> (123) 456 7890
> 123 456 7890
> (123) 456 - 7890
> 123 456-7890

Dont forget:

  123.456.780
  1-123-456-7890

> 
> ...
> 
> $validPhone = "^([0-9]{3}[ ]*)?[0-9]{3}[ ]*[0-9]{4}$";
> 
> By the way The phone numbers are in US format.

With US phone numbers I always use this approach to avoid what
format people use to enter the phone:

  - Remove any non digit
     $check_phone = preg_replace('/[^0-9]/', '', $phone);


  - If $check_phone strlen < 10.. invalid
  - if $check_phone strlen == 11 && first char == '1'.. remove it
  - if $check_phone strlen == 10, seems ok
    - possible area code check with prefix check (if have db to
      support that)

I would even go as far as storing the phone striped of any
formating and only format it when you display it.

The other option would to make three seperate input fields in the
form and join them together in your script:

 (<input name="phone[area]">) <input name="phone[code]">-<input 
name="phone[num]">


Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
On 3/12/06, Curt Zirzow <[EMAIL PROTECTED]> wrote:
> On Sun, Mar 12, 2006 at 12:09:42PM -0700, Paul Goepfert wrote:
> > Hi all,
> >
> > I am trying to validate phone numbers in a web form that I have
> > created.  I am using a regular expression to validate the phone
> > number.  It seems when I enter the phone number in the following ways
> > I get errors
> >
> > (123) 456 7890
> > 123 456 7890
> > (123) 456 - 7890
> > 123 456-7890
>
> Dont forget:
>
>   123.456.780
>   1-123-456-7890
>
> >
> > ...
> >
> > $validPhone = "^([0-9]{3}[ ]*)?[0-9]{3}[ ]*[0-9]{4}$";
> >
> > By the way The phone numbers are in US format.
>
> With US phone numbers I always use this approach to avoid what
> format people use to enter the phone:
>

>   - Remove any non digit
>      $check_phone = preg_replace('/[^0-9]/', '', $phone);

I just want to be sure about something.  Is there a second quotation
mark missing?  I only count one and I added a space between the
quotes.

Paul
>
>
>   - If $check_phone strlen < 10.. invalid
>   - if $check_phone strlen == 11 && first char == '1'.. remove it
>   - if $check_phone strlen == 10, seems ok
>     - possible area code check with prefix check (if have db to
>       support that)
>
> I would even go as far as storing the phone striped of any
> formating and only format it when you display it.
>
> The other option would to make three seperate input fields in the
> form and join them together in your script:
>
>  (<input name="phone[area]">) <input name="phone[code]">-<input 
> name="phone[num]">
>
>
> Curt.
> --
> cat .signature: No such file or directory
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Sun, Mar 12, 2006 at 01:48:28PM -0700, Paul Goepfert wrote:
> On 3/12/06, Curt Zirzow <[EMAIL PROTECTED]> wrote:
> >
> > With US phone numbers I always use this approach to avoid what
> > format people use to enter the phone:
> >
> 
> >   - Remove any non digit $check_phone =
> >   preg_replace('/[^0-9]/', '', $phone);
> 
> I just want to be sure about something.  Is there a second
> quotation mark missing?  I only count one and I added a space
> between the quotes.

I'm not sure what you're seeing but the line reads like this:

  http://pastebin.com/598522


Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
I didn't realize that those were single quotes.  I printed out the
email message and it looked like one set of double quotes for the
second parameter rather the two single quotes.

Is it possible for anyone to tell me what php method is used to grab
the first charater of a string?  And onece I have it what method
removes the characted or number?

I know this seems trivial but I am still new to php and I don't have a
good understanding of the language yet.  The more I do the better I'll
get.

Thanks
Paul

On 3/12/06, Curt Zirzow <[EMAIL PROTECTED]> wrote:
> On Sun, Mar 12, 2006 at 01:48:28PM -0700, Paul Goepfert wrote:
> > On 3/12/06, Curt Zirzow <[EMAIL PROTECTED]> wrote:
> > >
> > > With US phone numbers I always use this approach to avoid what
> > > format people use to enter the phone:
> > >
> >
> > >   - Remove any non digit $check_phone =
> > >   preg_replace('/[^0-9]/', '', $phone);
> >
> > I just want to be sure about something.  Is there a second
> > quotation mark missing?  I only count one and I added a space
> > between the quotes.
>
> I'm not sure what you're seeing but the line reads like this:
>
>   http://pastebin.com/598522
>
>
> Curt.
> --
> cat .signature: No such file or directory
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Paul:

Also check out:

http://www.weberdev.com/get_example-3605.html

tedd


Hi all,

I am trying to validate phone numbers in a web form that I have
created.  I am using a regular expression to validate the phone
number.  It seems when I enter the phone number in the following ways
I get errors

(123) 456 7890
123 456 7890
(123) 456 - 7890
123 456-7890

I am using the ereg method in php to test the regular expression.
Here is the Regular Expression that I am using to test against
potential phone numbers

$validPhone = "^([0-9]{3}[ ]*)?[0-9]{3}[ ]*[0-9]{4}$";

By the way The phone numbers are in US format.

If anyone can help me with this I would really appreciate it.

Thanks,
Paul

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


--
--------------------------------------------------------------------------------
http://sperling.com

--- End Message ---
--- Begin Message ---
On 3/12/06, tedd <[EMAIL PROTECTED]> wrote:
>
> Paul:
>
> Also check out:
>
> http://www.weberdev.com/get_example-3605.html
>
> tedd
>
>
> >Hi all,
> >
> >I am trying to validate phone numbers in a web form that I have
> >created.  I am using a regular expression to validate the phone
> >number.  It seems when I enter the phone number in the following ways
> >I get errors
> >
> >(123) 456 7890
> >123 456 7890
> >(123) 456 - 7890
> >123 456-7890
> >
> >I am using the ereg method in php to test the regular expression.
> >Here is the Regular Expression that I am using to test against
> >potential phone numbers
> >
> >$validPhone = "^([0-9]{3}[ ]*)?[0-9]{3}[ ]*[0-9]{4}$";
> >
> >By the way The phone numbers are in US format.
> >
> >If anyone can help me with this I would really appreciate it.
> >
> >Thanks,
> >Paul
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --




One suggestion is to have 1 field for all countries, I believe the total is
23?

+011-049-069-13788-1234



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


--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

--- End Message ---
--- Begin Message ---
On Sat, Mar 11, 2006 at 09:44:01PM +0800,   wrote:
> Excuse me,when i develop programe php in linux FC3 , i want the life time 
> of the session to be 20 minutes ,i do the follow things in the php.ini file

What version of PHP are we talking about with FC3?

> 1.change session.gc_maxlifetime = 1200
> 2.change session.gc_probability = 100
> 3.change session.use_cookies = 0

The only one, in that list, that may effect when a session expires
is the gc_maxlifetime.  Wich means data not accessed in the seconds
specified is able to be removed by the gc (garbage collection)
system.

The key setting you want is:

  session.cache_expire



> 4. restart the apache server
> and it does work happily, how can i troubeshooting this problem ?

Does or doesn't, this is confusing me wether you have a problem
with the session lifetime working or not?


Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
On Fri, Mar 10, 2006 at 12:09:44PM -0500, Chris wrote:
> Under what circumstances does PDOStatement::execute() return false?
> 
> It seems to always return true.

I'm assuming you have some code like:

$sth = $dbh->prepare($sql);
if(! $sth->execute() ) {
  // false
} else {
  //true
}


When it returns false sort of depends what kind of $sql you have.
if you have something like:

  select * from something ...

->execute() will return true probably about 99.9% of the time,
except for cases like when you loose a connection to the db, since
the prepare() does the parsing of the statment, the errors in
parsing will occur at prepare().

If you have something like:
  insert into blah values(something)

The ->execute will fail if you violate a constraint on the DB like
a primary/foreign/unique key constraint. 

Basically anytime the db server responsed with: Um this isn't
allowed even though the syntax is valid.


HTH,

Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
On Fri, Mar 10, 2006 at 02:10:54PM +0200, Thomas wrote:
> 
> Hi there,
> 
> Quick question on performance:
> 
> I have got some expensive sql queries (doing lots of LEFT JOINS) that result
> in anything between 10 to 10000 results. I need to do paging on those. So
> far I have used a LIMIT solution which will not do anymore because you don't
> get the whole total.
 
The next couple paragraphs are assuming your are using mysql.

A little side note (assuming your using Mysql), there is a select
option called SQL_CALC_FOUND_ROWS, which will allow you to know the
total of rows even though you specify a LIMIT clause.  Becareful
with this though, mysql has to perform the query fully before doing
anything so it can be harmful with large results sets from queries.


The first thing I would look at is, if there is a way you can make
the query not have to use a left join, and ensure that indexes are
all properly used.

Another helpful suggestion is the SQL_CACHE option, this will take
the logic of caching data from your hands.  Be careful, again,
cause if you are dealing with a heavily modified table it will bite
you in the ass.

> 
> Now, the idea is to store the results (or the sql query string?) in the
> session to avoid too many db calls (on paging). 
> 
> The question now is: is the serializing/unserializing more expensive than
> another db call?

Well it depends.

At first you might notice that you execute a query that takes very
long 4 seconds before a response happens, you then store the
resulted data in a session array variable. 

On the next page you just jump to the proper record from the array
of data you have stored in the session array, and the page loads
much quicker, probably less than 2 seconds (of course pending how
many results your dealing with.


The problem with this approach is you are taking the cost of the
CPU to other resources, like disk usage, memory usage, as well
with managing the session data yourself.

If we take a resultset of 5000 records, with the above method those
records will have to be stored in the session of some sort of
array. Stored on  that may or may not be used again.  And if you
get a medium load say 25 requests per second, now all this data is
being transfered to a local disk.  Now your bottle neck is your
hard drive.


I guess what I'm saying is try to find a solution on how to do this
at the Database level vs trying to solve it with php, even if it
means you have to flatten your table structure for the searches you
are looking for.


Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
On Thu, Mar 09, 2006 at 05:27:11PM -0800, Angelo Zanetti wrote:
> Hi guys.
> 
> When adding additional headers to an email that gets sent from the mail 
> function. What purpose does the X-Mailer have?

Any X-* header is generally a header that is not a standard but a
way to trace things. Or still in eXperimental mode, not a standard
yet, but a (becomming) common practice.

X-Mailer:, has been in practice, to specify what software
version/versions automatically mailed the email, usually from sort
of script, ie:

  X-Mailer: phpmailer-3.2/php-4.3

> 
> Also are the following linked:
>
> -X-Priority
> -Importance
> -X-MSMail-Priority

No.

Personally, those things are rather useless, practically everyone
sends message with those flags set at 'High', my client ignores
those.

> 
> Another question is can I omit the Message-ID for the email? or will this 
> result in some mail servers viewing the mail as spam? What criteria do I 
> use to generate the Message-ID?

The message-id is generated by the MTA you shouldn't be generating
this on your own.  The only basic headers you ever (really) need to
send is:

  To: <valid email address>
  From: <valid from address>
  Subject: A Subject

Subject even isn't 100% needed.



> 
> I've seen:
>       $headers .= "Message-ID: 
>       <".date("YmdHis")."you@".$_SERVER['SERVER_NAME'].">\n";
> 
> is this ok?

No, forget about message-id in your headers.

> 
> Perhaps if someone has a link on the headers for a mail that could help me 
> it would be much appreciated.

There are quite a few on google, I'm not entirely clear what focus
you desire on the headers you desire.


Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
Quoting Rory Browne <[EMAIL PROTECTED]>:

I've got a bit lost on this, but assuming that we are talking about an
intranet enviornment, with windows/IE6 clients, and apache servers, then
personally:

I would check logins based on a valid session. If the user doesn't have a
session they aren't logged in. Store the username in the session variable.
PHP session variables are AFAIK designed to be hard to detect and fake.

Any code that is run under a http:// website ( as opposed to an ssl or
https:// one ), reads the session(ie does not write to it). Any
authentication should be done using a script accessed over https, protected
by mod_auth_kerb.

The http:// script would be accessed by the person when they first access
the protected site. The protected site would detect that the user is not
logged in, and redirect them to the authentication site(which is behind
mod_auth_kerb, and https), which would create the session, and redirect the
user back, to the page where they originally tried to access.

I think you're talking about the user logging on once through a web page and carrying that authentication throughout. We're (or *I* am, at least) talking about the user logging on to the network (LDAP or, in my case, Active Directory) and using those credentials for the web applications.

Rick

--- End Message ---
--- Begin Message ---
My web page needs to determine the client's external IP address, i.e., the
IP address that others viewing the web page would be able to use to contact
that user's machine (assuming they've setup the appropriate forwarding into
their actual machine of course). In this environment the clients want their external IP to be correctly reported, so there's no issue of people trying to spoof and
show a wrong IP.

I'm currently using $_SERVER['REMOTE_ADDR'] as this seemed like the best
approach as I thought it would yield the IP as seen from the web server and
hence, hopefully, as seen by everyone else on the internet.

This works in many cases, but in a couple cases users have reported issues
with others not being able to use the IPs the web page reports to contact their
machines.  In these cases the $_SERVER['REMOTE_ADDR'] seems to be returning
a different IP than what www.whatismyip.com <http://www.whatismyip.com> returned, for example.

Is there another reccomended way to get the client's externally visible IP
address?  Or is $_SERVER['REMOTE_ADDR'] the right approach but might
not always work?

Thanks!

--- End Message ---

Reply via email to