php-general Digest 23 Jun 2005 13:15:36 -0000 Issue 3528

Topics (messages 217451 through 217478):

Re: variable object creating
        217451 by: Richard Lynch

Something is messing up the php output
        217452 by: Jonathan Duncan
        217453 by: Matt Babineau
        217459 by: Richard Lynch
        217463 by: Jonathan Duncan
        217464 by: Jonathan Duncan

Re: text areas and line brakes
        217454 by: Richard Lynch

Re: sending eml file
        217455 by: Richard Lynch

Re: Strategies for debugging a segmentation fault on a production ser ver
        217456 by: Richard Lynch

Re: comparing two texts
        217457 by: Richard Lynch
        217458 by: Robert Cummings
        217469 by: Jochem Maas
        217473 by: Tom Rogers

Re: Help recognizing bots?
        217460 by: Richard Lynch
        217468 by: JamesBenson

Re: security question...??
        217461 by: Richard Lynch

Re: Extra (persistant) tier
        217462 by: Leila Lappin

Help with image map problem...
        217465 by: Joey

Socket server in PHP
        217466 by: kioto

Re: passing login paramters from php web application to asp web application. 
help.
        217467 by: symbulos
        217470 by: Jochem Maas
        217471 by: Rory Browne
        217472 by: symbulos
        217475 by: symbulos

Accessing forms through php
        217474 by: José Miguel López-Coronado

Showing tables (converting from MySQL to Oracle)
        217476 by: Shane Presley

Re: How to convert documents to PDF using PHP
        217477 by: Rory Browne

setting include_path ini directive at runtime
        217478 by: blackwater dev

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 ---



On Tue, June 21, 2005 8:33 pm, Eli said:
> Hi,
>
> I want to create an object in a form that I get the class name and its
> parameters, and I need to create that object...
> How can this been done?
>
> i.e:
> $classname = "MyClass";
> $construct_params = array("param1","param2","param3");
> /* Now create the object with the given classname and params... how? */

Did you try:

$instance = new $classname($param1, $param2, $param3);

Or do you really need the parameters in an array?...

You could maybe use call_user_func_array or whatever it is, and write a
tiny function that calls new on the arguments...

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

--- End Message ---
--- Begin Message ---
I have a site that has this problem every once in a while, and seemingly 
randomly.  It is a database driven site, as indicated by the error.  This 
same page when loaded numerous times will sometimes work just fine, and then 
sometimes it will give an error message like this:

-----------------------------------------------------
Warning: mysql_connect(): Unknown MySQL Server Host
'hostn[]me.domain.com' (1) in
/usr/local/apache/htdocs/filename.php on line 8
Unknown MySQL Server Host 'hostn[]me.domain.com' (1)
-----------------------------------------------------

Notice that in the word "hostname" the 'a' is not an 'a'.  It is one of the 
empty boxes that usually indicates an unknown character.  Here I represent 
it with square brackets for visual effect.

When the source is check, there is absolutely nothing wrong with the 
hostname in the mysql_connect function.  As I mentioned, if this page is 
reloaded it may be fine.  After a while it may not have anymore problems for 
weeks.  Or it may come back the next day.  When It is happening I do not 
notice any major server process usage.

The mis-interpreted character problem sometimes truncates a word, or just 
messes up a cerain random characters.

I have had this happen on more than one site on more than one server.

Does anyone have any idea what this may be?  I am even accepting wild 
guesses at this point.

Thanks,
Jonathan 

--- End Message ---
--- Begin Message ---
I bet if you connect using the IP directly it will solve your problem. 



Thanks,

Matt Babineau
Criticalcode
858.733.0160
[EMAIL PROTECTED]
http://www.criticalcode.com
 
-----Original Message-----
From: Jonathan Duncan [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 22, 2005 6:27 PM
To: [email protected]
Subject: [PHP] Something is messing up the php output

I have a site that has this problem every once in a while, and seemingly
randomly.  It is a database driven site, as indicated by the error.  This
same page when loaded numerous times will sometimes work just fine, and then
sometimes it will give an error message like this:

-----------------------------------------------------
Warning: mysql_connect(): Unknown MySQL Server Host 'hostn[]me.domain.com'
(1) in /usr/local/apache/htdocs/filename.php on line 8 Unknown MySQL Server
Host 'hostn[]me.domain.com' (1)
-----------------------------------------------------

Notice that in the word "hostname" the 'a' is not an 'a'.  It is one of the
empty boxes that usually indicates an unknown character.  Here I represent
it with square brackets for visual effect.

When the source is check, there is absolutely nothing wrong with the
hostname in the mysql_connect function.  As I mentioned, if this page is
reloaded it may be fine.  After a while it may not have anymore problems for
weeks.  Or it may come back the next day.  When It is happening I do not
notice any major server process usage.

The mis-interpreted character problem sometimes truncates a word, or just
messes up a cerain random characters.

I have had this happen on more than one site on more than one server.

Does anyone have any idea what this may be?  I am even accepting wild
guesses at this point.

Thanks,
Jonathan 

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

--- End Message ---
--- Begin Message ---
On Wed, June 22, 2005 6:26 pm, Jonathan Duncan said:
> I have a site that has this problem every once in a while, and seemingly
> randomly.  It is a database driven site, as indicated by the error.  This
> same page when loaded numerous times will sometimes work just fine, and
> then
> sometimes it will give an error message like this:
>
> -----------------------------------------------------
> Warning: mysql_connect(): Unknown MySQL Server Host
> 'hostn[]me.domain.com' (1) in
> /usr/local/apache/htdocs/filename.php on line 8
> Unknown MySQL Server Host 'hostn[]me.domain.com' (1)
> -----------------------------------------------------
>
> Notice that in the word "hostname" the 'a' is not an 'a'.  It is one of
> the
> empty boxes that usually indicates an unknown character.  Here I represent
> it with square brackets for visual effect.
>
> When the source is check, there is absolutely nothing wrong with the
> hostname in the mysql_connect function.  As I mentioned, if this page is
> reloaded it may be fine.  After a while it may not have anymore problems
> for
> weeks.  Or it may come back the next day.  When It is happening I do not
> notice any major server process usage.
>
> The mis-interpreted character problem sometimes truncates a word, or just
> messes up a cerain random characters.
>
> I have had this happen on more than one site on more than one server.
>
> Does anyone have any idea what this may be?  I am even accepting wild
> guesses at this point.

WILD GUESS ALERT!
Until you said "on more than one server" I was thinking a heat-related
intermittent hardware error corrupting the file read, so "a" turned into
some not-quite-random character...  You *SURE* it's on multiple
servers?...

Are all machines running the same software versions?

Are you using multi-byte strings?  Those are not quite as pounded on as
much as one might like...

Have you done anything funky to force libc->glibc upgrade?

Or a kernel upgrade?

Are you running anything bleeding/leading edge? (Apache 2, PHP 5, mysqli
etc)  Can you rollback for awhile and test?

If you are using Apache 2, are you in that pre-fork mode, or is it running
threaded?

What PHP Modules are you running?

Aha!  My wild guesses have lead me to a hypothesis:

You *are* using Apache 2 in threaded environment and some PHP Module (or
other software) is not thread-safe.

*WHICH* one[s] are not thread-safe is totally open to question...

It could even be some weird interaction between *TWO* Modules that very
rarely exhibits itself by random changing of memory bits.  Ugh!

Are there any Modules you could get rid of completely and just change the
applications to "do without"?

Do you have a test Development box that exhibits this behaviour?  Run it
and ab stress test it and pound on it with as many different requests in
as random an order you can achieve.

If you can get the dev box to mis-behave somewhat reliably, try getting
rid of one PHP Module after another, and re-test incessantly.

Could you roll back to Apache 1.x or at least do that pre-fork thing so
you are not using threads on the production server, and see if it goes
away?

Some of the above questions/implications are mutually exclusive. :-)

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

--- End Message ---
--- Begin Message ---
I see where you are coming from and it is a good idea.  However, in this 
particular problem it is not so much DNS related.  If I were to use an IP 
then the error could very well just say this:

-----------------------------------------------------
Warning: mysql_connect(): Unknown MySQL Server Host '192.1[]8.0.1'
(1) in /usr/local/apache/htdocs/filename.php on line 8 Unknown MySQL Server
Host '192.1[]8.0.1' (1)
-----------------------------------------------------

Thanks,
Jonathan


""Matt Babineau"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>I bet if you connect using the IP directly it will solve your problem.
>
>
>
> Thanks,
>
> Matt Babineau
> Criticalcode
> 858.733.0160
> [EMAIL PROTECTED]
> http://www.criticalcode.com
>
> -----Original Message-----
> From: Jonathan Duncan [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 22, 2005 6:27 PM
> To: [email protected]
> Subject: [PHP] Something is messing up the php output
>
> I have a site that has this problem every once in a while, and seemingly
> randomly.  It is a database driven site, as indicated by the error.  This
> same page when loaded numerous times will sometimes work just fine, and 
> then
> sometimes it will give an error message like this:
>
> -----------------------------------------------------
> Warning: mysql_connect(): Unknown MySQL Server Host 'hostn[]me.domain.com'
> (1) in /usr/local/apache/htdocs/filename.php on line 8 Unknown MySQL 
> Server
> Host 'hostn[]me.domain.com' (1)
> -----------------------------------------------------
>
> Notice that in the word "hostname" the 'a' is not an 'a'.  It is one of 
> the
> empty boxes that usually indicates an unknown character.  Here I represent
> it with square brackets for visual effect.
>
> When the source is check, there is absolutely nothing wrong with the
> hostname in the mysql_connect function.  As I mentioned, if this page is
> reloaded it may be fine.  After a while it may not have anymore problems 
> for
> weeks.  Or it may come back the next day.  When It is happening I do not
> notice any major server process usage.
>
> The mis-interpreted character problem sometimes truncates a word, or just
> messes up a cerain random characters.
>
> I have had this happen on more than one site on more than one server.
>
> Does anyone have any idea what this may be?  I am even accepting wild
> guesses at this point.
>
> Thanks,
> Jonathan
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php 



--- End Message ---
--- Begin Message ---
Yes, it has happened on different servers, none of them is bleeding edge, 
still using Apache 1.x and PHP 4.3.x.  The sites are not using any character 
sets other than default.  The machines are in a heat controlled environment 
and monitored for change so I would know if there was that kind of problem. 
One of the sites that I have seen it on is an osCommerce site.  Another site 
is a custom built site.  I am inclined to think that because it happens so 
rarely and when it does happen it is so random that there must be some 
combination of events that are hard to track as being part of the same 
problem.

Thanks for the brainstorm, you did give me some things to think about.  It 
has since subsided again so I will have to wait for it to happen again 
before I can troubleshoot more.  This makes it very hard.

Thanks everyone.  If anyone has more ideas I am still open to them.

Jonathan


""Richard Lynch"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
> WILD GUESS ALERT!
> Until you said "on more than one server" I was thinking a heat-related
> intermittent hardware error corrupting the file read, so "a" turned into
> some not-quite-random character...  You *SURE* it's on multiple
> servers?...
>
> Are all machines running the same software versions?
>
> Are you using multi-byte strings?  Those are not quite as pounded on as
> much as one might like...
>
> Have you done anything funky to force libc->glibc upgrade?
>
> Or a kernel upgrade?
>
> Are you running anything bleeding/leading edge? (Apache 2, PHP 5, mysqli
> etc)  Can you rollback for awhile and test?
>
> If you are using Apache 2, are you in that pre-fork mode, or is it running
> threaded?
>
> What PHP Modules are you running?
>
> Aha!  My wild guesses have lead me to a hypothesis:
>
> You *are* using Apache 2 in threaded environment and some PHP Module (or
> other software) is not thread-safe.
>
> *WHICH* one[s] are not thread-safe is totally open to question...
>
> It could even be some weird interaction between *TWO* Modules that very
> rarely exhibits itself by random changing of memory bits.  Ugh!
>
> Are there any Modules you could get rid of completely and just change the
> applications to "do without"?
>
> Do you have a test Development box that exhibits this behaviour?  Run it
> and ab stress test it and pound on it with as many different requests in
> as random an order you can achieve.
>
> If you can get the dev box to mis-behave somewhat reliably, try getting
> rid of one PHP Module after another, and re-test incessantly.
>
> Could you roll back to Apache 1.x or at least do that pre-fork thing so
> you are not using threads on the production server, and see if it goes
> away?
>
> Some of the above questions/implications are mutually exclusive. :-)
>

--- End Message ---
--- Begin Message ---
On Tue, June 21, 2005 8:59 am, Sunny Boy said:
> if someone writes something in a text box, how would I convert a line
> break in the text area to echo a <br />? I think i'll have to get the \n
> and convert it. can anyone tell me?

While the two solutions provided so far are Really Nifty (tm) both ignore
the fact that Mac browsers/users may not be providing \n in the text area
in the first place.

<?php
  //Convert line break to Unix standard:
  $text = str_replace("\r\n", "\n", $text);
  $text = str_replace("\r", "\n", $text);

  //Convert to HTML:
  $text = nl2br($text);
?>

I HIGHLY recommend you do the conversion to Unix as part of your input
filtering.

The nl2br should be done only on OUTPUT, imho.

YMMV

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

--- End Message ---
--- Begin Message ---
On Tue, June 21, 2005 9:00 am, david forums said:
> Could you give me a way to send (with a local sendmail) eml file.
>
> Not as attachment but as the whole email.

If you want to maintain as many of the headers in the original as
possible, you will want to use the extra fourth argument to
http://php.net/mail or you may want to consider using SMTP directly or one
of the Mail classes at http://phpclasses.org to make it easier to keep the
headers you need.

Some of the headers should probably not be preserved -- Message-ID springs
to mind.

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

--- End Message ---
--- Begin Message ---
On Tue, June 21, 2005 7:57 am, Michael Caplan said:
> I am looking for some advice on how to go about debugging Apache 1.3.33 /
> PHP 5.0.4 on a production Linux box (RHE 3).  The scenario is this:  Once
> a
> day we find a segfault in our apache logs.  From our current position, we
> don't know what page was accessed, and our 400+ users haven't brought the
> issue to our attention.  All we know is the date/time and PID of when the
> segfault occurred.  The question is this:  how can we go about isolating
> the
> offending requested page that bombs?

Have you managed to get the same segfault on a development box?...

Obviously, if you can make it happen on a dev box, you can then set up the
conditions with Apache -X and whatnot to debug to your heart's content.

Focus on reproducing the bug under laboratory conditions.

> I've set up a custom apache log file that populates each entry with the
> PID
> that handled it.  However, when we do see a segfault, this  log file does
> not appear to be populated with an entry that corresponds (within a 5 - 10
> second period) to the PID that bombs.  I'm guessing that the log file is
> only written to after a request is delivered?

Maybe you could compare access_log to error_log.

access_log tells you what they asked for.

error_log tells you what they didn't get...

> Otherwise, looking at the PHP bugs page, it recommends rebuilding PHP with
> -enable-debug and running Apache with -X in order to get a core dump.
> Running apache with debug mode on is not an option on our production box.
> Is running apache -X mandatory to get a core dump?
>
> Any other strategies that you can recommend that would help us isolate the
> offending page so we can get to the good work of reproducing and fixing
> the
> problem at hand?

For something this rare, as I said above, try to focus on making it happen
on a dev box.

In the sort term, you might be able to have the children serve fewer
requests before commiting suicide, which might be worse for load, but also
might avoid the segfaulting as often.  Tough balancing act.  And will only
help if the segfault is somehow related to how long a child has been
running, which might not be the case at all.

I think you could also temporarily set up your logs to log MORE stuff --
perhaps even enough that you can compare access to error and make a
one-to-one comparison of what was requested/delivered.

It will chew up disk space something terrible, slow down the server a fair
amount, but it might be feasible for a production box just long enough to
get the data you need to pin down the segfault.

If the segfault is hardware related, though, knowing which script it
occurred in won't help in the least.  A bad spot in RAM or on the hard
drive in /tmp won't be triggered by any particular script.

PS I'm no expert. Something I typed above could be balderdash.

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

--- End Message ---
--- Begin Message ---
On Sun, June 19, 2005 8:33 am, Robert Cummings said:
> On Sun, 2005-06-19 at 09:22, M. Sokolewicz wrote:
>> jenny mathew wrote:
>> >>Untested, very crude:
               ^^^^^^^^^^

> It's a bit of a dirty hack though. If I compare a 2 character text
> against a 40k text, the error handler will be invoked (39998 * 3)  times
> if $text1 is the 2 byte string. That's extremely inefficient. I don't
> think I've ever seen error suppression abused so badly to prevent
> writing an extra line or 2 using isset().

Don't you think I knew that when I typed it?

What part of "very crude" did you not get?

Ya want me to do Jenny's work for her for free or what?! :-)

The point was that depending on what Jenny wants for output, it could be
pretty easy to compare two strings character by character.

Or it could be incredibly difficult, if you need diff-like capabilities of
recognizing similar lines of text interspersed with radically different
lines of text.

She obviously didn't like the "use diff" answer, so I gave her the yeast
to roll her own.

'Course, she didn't like that either, but that's hardly my fault.
[shrug]

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

--- End Message ---
--- Begin Message ---
On Wed, 2005-06-22 at 22:55, Richard Lynch wrote:
> On Sun, June 19, 2005 8:33 am, Robert Cummings said:
> > On Sun, 2005-06-19 at 09:22, M. Sokolewicz wrote:
> >> jenny mathew wrote:
> >> >>Untested, very crude:
>                ^^^^^^^^^^
> 
> > It's a bit of a dirty hack though. If I compare a 2 character text
> > against a 40k text, the error handler will be invoked (39998 * 3)  times
> > if $text1 is the 2 byte string. That's extremely inefficient. I don't
> > think I've ever seen error suppression abused so badly to prevent
> > writing an extra line or 2 using isset().
> 
> Don't you think I knew that when I typed it?
> 
> What part of "very crude" did you not get?

Well some noobs might think crude works quite well for them :)

> Ya want me to do Jenny's work for her for free or what?! :-)

No but it seemed like Jenny did *grin*.

> The point was that depending on what Jenny wants for output, it could be
> pretty easy to compare two strings character by character.
> 
> Or it could be incredibly difficult, if you need diff-like capabilities of
> recognizing similar lines of text interspersed with radically different
> lines of text.
> 
> She obviously didn't like the "use diff" answer, so I gave her the yeast
> to roll her own.
> 
> 'Course, she didn't like that either, but that's hardly my fault.
> [shrug]

-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
On Wed, 2005-06-22 at 22:55, Richard Lynch wrote:


...



Well some noobs might think crude works quite well for them :)


Ya want me to do Jenny's work for her for free or what?! :-)


No but it seemed like Jenny did *grin*.

_seemed_ ??? r u kidding :-)

whereas I'll happily spend an hour writing up and contemplating someone
else's problem - I don't have five minutes for people who are expecting to be
spoonfed (go learn ASP and get a support contract, thanks ;-).



The point was that depending on what Jenny wants for output, it could be
pretty easy to compare two strings character by character.

Or it could be incredibly difficult, if you need diff-like capabilities of
recognizing similar lines of text interspersed with radically different
lines of text.

She obviously didn't like the "use diff" answer, so I gave her the yeast
to roll her own.

'Course, she didn't like that either, but that's hardly my fault.

don't suppose you want to hear a joke about 'womens perogative' do you? ;-)

[shrug]



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

Thursday, June 23, 2005, 9:42:34 PM, you wrote:
.
.
.

JM> whereas I'll happily spend an hour writing up and contemplating someone
JM> else's problem - I don't have five minutes for people who are expecting to 
be
JM> spoonfed (go learn ASP and get a support contract, thanks ;-).

Perhaps I missed it but could you point out the bit where the original
poster asked to be spoon fed??

-- 
regards,
Tom

--- End Message ---
--- Begin Message ---
On Wed, June 22, 2005 3:57 pm, Brian Dunning said:
> I'm using the following code in an effort to identify bots:
>
> $client = $_SERVER['HTTP_USER_AGENT'];
> if(!strpos($client, 'ooglebot') && !strpos($client, 'ahoo') && !strpos
> ($client, 'lurp') && !strpos($client, 'msnbot'))
> {
>      (Stuff that I do if it's not a bot)
> }
>
> But it doesn't seem to be catching a lot of bot action. Anyone have a
> better list of user agents? (I left off the first letter of some to
> avoid case conflicts.)

Check your logfiles and/or web stats.

The most common bots should be pretty apparent.

Here's a hack that might be useful to you:

1. Change .htaccess thusly:
<Files robots.txt>
  ForceType application/x-httpd-php
</Files>

2. Edit robots.txt:
<?php
  error_log("robot_detected: $_SERVER[HTTP_USER_AGENT]");
?>

Since only legitimate robots read robots.txt, that should quickly generate
a list of legimate bots visiting your site.

You could even insert it into a database with a unique key on the value,
ignoring the errors of duplicates, and then you'd have the data already
filtered down to uniques.  Be a bit slower than error_log, I should
think... Maybe.

Course, it won't help at all with the idiot illegitmate bots...

And this could be a bit too much for a real busy site...

Though you'd hope that the good bots (which read robots.txt) aren't
pounding you THAT hard...

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


--- End Message ---
--- Begin Message ---
http://www.funender.com/phpBB2/about18577.html








Brian Dunning wrote:
I'm using the following code in an effort to identify bots:

$client = $_SERVER['HTTP_USER_AGENT'];
if(!strpos($client, 'ooglebot') && !strpos($client, 'ahoo') && !strpos ($client, 'lurp') && !strpos($client, 'msnbot'))
{
    (Stuff that I do if it's not a bot)
}

But it doesn't seem to be catching a lot of bot action. Anyone have a better list of user agents? (I left off the first letter of some to avoid case conflicts.)

--- End Message ---
--- Begin Message ---
On Wed, June 22, 2005 3:27 pm, bruce said:
> rene..
>
> you've grapsed the problem/issue, as have most. all i said was that i've
> started to think about the issue of security as also meaning i have to
> start
> thinking about the client. just as users have had to start to think about
> 'is the site i'm looking at, really the site i want/should be looking at?'

It's remotely possible that you could get an RFC going about software
installation generating an SSL certificate on the client, tied to the
client's hardware signature[s]/ID[s], digitally signed by the software
installation only if the MD5 hash of the software matched an expected
value, and...

No, still too easy to hack, if the Bad Guy can change out the binary of
the browser in the first place.

I think everybody here is thinking about what you are saying, and they're
all saying "It won't work"

So you can either be the next Einstein and prove them wrong, or it really
won't work.

Take your pick.

At any rate, it's not a PHP question, and you should probably take it to a
Security RFC type of forum, please.

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

--- End Message ---
--- Begin Message ---
When I worked with other OO languages, I usually designed my persistent
business objects in two levels.  A level (lower level) designed and
implemented direct database calls.  Each database table had a class
abstraction at this level which provided the database calls for saving,
loading and etc.  At this level I also provided for the caching
considerations, i.e. if a table was already queried and a list was available
the list in memory was used instead of querying again.

The next level was where the business model was implemented.  If a business
object required information from three tables that related to each other in
a certain way the load methods would access the objects from cached lists in
three different classes (each representing a database table) and created the
final list.  At this stage the list was cached and also represented the
business logic.

Although I haven't done this in PHP I think with PHP5 it's possible.  The
only challenge may be the caching of query results but I think Pear modules
already have something about that.

-----Original Message-----
From: Richard Lynch [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 22, 2005 9:14 PM
To: Evert | Rooftop
Cc: PHP-Users
Subject: Re: [PHP] Extra (persistant) tier


On Mon, June 20, 2005 11:44 am, Evert | Rooftop said:
> I'm writing a big web application, and trying really hard to seperate
> business logic and presentation, which been no problem up to now.
> Because I abstracted the business logic so much the framework became
> heavier, sometimes a simple action can take up to 2 mb memory and
> several extra milliseconds.

Perhaps you have abstracted the business logic in an inefficient manner...
 It's real easy to get carried away making a ton of objects that look real
purty in the abstract, but are really just clutter when you get down to
what you want the application to *DO*.

Take a break from it, step back, and try to look at it "sideways"

Sometimes the "obvious" set of classes is actually not the "right answer"

I don't know how else to describe this...

> I know this doesn't sound much and I'm applying all kinds of technique's
> to reduce resource-usage and increase speed. The thing is, I feel like I
> need to split the business tier up in 2 tiers, one of them being my
> persisitant object manager. The main reason is because every script that
> is executed must do some initialization and database calls, and I think
> I could reduce this by making a persistant tier, but there doesn't seem
> a good way to do this using php except when I would use sockets.

I don't think you are going to get the database connection to persist
across scripts, period. You can use _pconnect so that the database server
will re-use a connection data structure, which can improve performance.

The penalties for _pconnect are memory and number of active connections.

Each persistent connection will chew up a little bit of memory.

The way it works out, each persistent connection ends up being tied to an
Apache child.  So you *MUST* configure your database to have *more*
connections active than the number of Apache children.  You want a few
extra so you can still use mysql from shell or mysqladmin to bring down
the server if you need to.  You do *NOT* want to be locked out of
mysqladmin because all the connections are tied up in Apache children.
[shudder]

If you really have a good chunk of semi-static persistent data, you should
consider moving those into a PHP Module by re-writing the data load in C.

> Shared memory doesn't really seem like an option, because I would still
> need to include all the classes to manage it, and when I use shared
> memory, the memory would still be copied into the php memory + having a
> central manager seems like a good idea.

Perhaps the data wouldn't *ALL* need to be copied into each PHP Module,
but some of it could be accessed on an as-needed basis.

> I know I'm pretty vague in my requirements, but I think it should be
> enough to explain what kind of solution I´m looking for, because this
> seems like a big advantage of java over php, or am I mistaken?
> If you have any ideas, let me know :)

I dunno how stable/mature the PHP/Java interface is, but maybe it would be
an option to move the semi-static data into a Java object...  Though you'd
probably be even slower to get that data to/from PHP then.  Worth checking
out other's experience, or even a quickie trial run if you can hack up a
test for a benchmark.

Maybe (gasp) Java is what you should have written this in in the first
place.

OTOH, maybe you shouldn't have gone the route of Object-Oriented
abstraction of business logic.  If blazing speed is the requirement,
that's not gonna be the answer, most times.  A well-designed procedural
body of code will generally out-perform OO and can still have sufficient
separation of business logic from presentation logic.  YMMV

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

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

--- End Message ---
--- Begin Message ---
OK this is one of those crazy issues where blindness seems to set in, or
some kind of issue.
I seem to not be getting a value passed to a php script when trying to use
the value within an image map.
 

If I put this in the .php file, the results are as expected:
Value: <% echo $value; %>
 
If in the SAME file I put:
<map name="FPMap0">
<area href="display_status.php?searchby=cust_no&search=1&value="<% echo
$value %>" shape="rect" coords="51, 1, 215, 34">
</map>
 
or if I get carried away this:
<%
echo "<map name=\"FPMap0\">
<area href=\"display_status.php?searchby=cust_no&search=1&value=\"" .$value.
"\" shape=\"rect\" coords=\"51, 1, 215, 34\">
</map><img border=\"0\" src=\"images/repair_status_menu.gif\" width=\"570\"
height=\"203\" usemap=\"#FPMap0\">"
%>
 
neither one provides the value of $value
 
Any ideas are greatly appreciated!
 
Joey
 

--- End Message ---
--- Begin Message --- Hi all sorry for the ignorance :D.This is my first time with Socket and i have
a question for you.I want create a script that run like daemon in background
and listen incoming request.It's possible with socket open a stream to a directory
and check any change on this directory ?
I want send notify about the state of directory through e-mail for example:
when a user add  new files or change any data.
Thanks so much and good work to all.

--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
> Can you get the usename/password from the other application?

Yes, we have them.

> With it, you can then use http://php.net/curl to simulate the user logging
> in to the other site.

Thanks.
 
> You simply have to convince the other site that your PHP script actually
> *IS* the user logging in, which is seldom very tricky, and is always
> *POSSIBLE* with enough effort.
 
How can be that done? Do you know of any tutorial, example?

--- End Message ---
--- Begin Message ---
symbulos wrote:
Richard Lynch wrote:

Can you get the usename/password from the other application?


Yes, we have them.


With it, you can then use http://php.net/curl to simulate the user logging
in to the other site.


Thanks.
You simply have to convince the other site that your PHP script actually
*IS* the user logging in, which is seldom very tricky, and is always
*POSSIBLE* with enough effort.

How can be that done? Do you know of any tutorial, example?

one way is to use the cURL extension. the concept is that your script
pretends to be a browser, using cURL to initiate a HTTP connection (aka
a request) to the ASP server - your request should send the same as your 
browser would if
you had sumbitted a login attempt to the ASP site directly...





come on, you too know how to type stuff into the google search box:

http://www.google.nl/search?q=php+cURL&start=0

fourth hit:
http://www.phpfreaks.com/quickcode/Curl_Abstraction_Class_v1.0/120.php



--- End Message ---
--- Begin Message ---
Just out of curiousity, does your PHP/MySQL site share a domain name?
By that I mean can your site be accessed by php.commondomain.com, and
theirs asp.commondomain.com, where the commondomain.com part is the
same on your side and theirs?

If not, then your site will not be able to set cookies for their site,
so for the login process you'll probably have to redirect the visitor
to the other site(with login parameters(which may or may not be the
uname/passwd) in the QueryString), for it to set the cookie, which can
then redirect back to your site after the login is complete. This
might be simpler than using cURL even if you're on the same domain.

On 6/23/05, symbulos <[EMAIL PROTECTED]> wrote:
> Richard Lynch wrote:
> > Can you get the usename/password from the other application?
> 
> Yes, we have them.
> 
> > With it, you can then use http://php.net/curl to simulate the user logging
> > in to the other site.
> 
> Thanks.
> 
> > You simply have to convince the other site that your PHP script actually
> > *IS* the user logging in, which is seldom very tricky, and is always
> > *POSSIBLE* with enough effort.
> 
> How can be that done? Do you know of any tutorial, example?
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
Rory Browne wrote:

> Just out of curiousity, does your PHP/MySQL site share a domain name?
> By that I mean can your site be accessed by php.commondomain.com, and
> theirs asp.commondomain.com, where the commondomain.com part is the
> same on your side and theirs?

Unfortunately not.

At the same time, we would rather not pass confidential information, like
username / password using get methods (with variable appended to url). This
is the main problem.

--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
> come on, you too know how to type stuff into the google search box:

gorgle? what is that?

> 
> http://www.google.nl/search?q=php+cURL&start=0

> fourth hit:
> http://www.phpfreaks.com/quickcode/Curl_Abstraction_Class_v1.0/120.php

I am not sure about it. I did not understand it at all. It is not exactly
well documented.

:-)

--- End Message ---
--- Begin Message ---
I have seen how to use cURL to retreive results from a web site after
processing a form. The problem is that I want to simulate completely the
submiting of a form, I mean, I wan to "enter" the page in the server
instead of retreive the results into my own page. I'm trying to use a
php script to login into a site without having to enter user and pass.
Anyone knows how to do this using cURL or any other option like HEADER
or something like that?

Thanks in advance and best wishes.

________________________________________________________________________


Disbase Internet
www.disbase.com
     José Miguel López Coronado

--- End Message ---
--- Begin Message ---
Hello,

I've recompiled PHP to use Oracle, and been able to run a quick test
script that looks like...

<?php
if ($c=OCILogon("user", "pw", "server")) {
  echo "Successfully connected to Oracle.\n";
  OCILogoff($c);
} else {
  $err = OCIError();
  echo "Oracle Connect Error " . $err[text];
}
?>


So now I'm going through and converting my MySQL code to Oracle.  I've
finished the connect functions, but getting hung up on how to do
queries.  For example the first query wants to SHOW TABLES.  Not sure
how to do this with Oracle calls?

function get_tables($link) {
        $tableList = array();
        $query = "SHOW TABLES";
        $result = perform_query($query, $link);
        while($row = fetch_array($result)) {
                array_push($tableList, $row[0]);
        }

        return $tableList;
}


function perform_query($query, $link) {
        if($link) {
                $result = mysql_query($query, $link) or die('Query
failed: ' . mysql_error());
        }
        else {
                die('No DB link');
        }

        return $result;
}


Thanks!
Shane

--- End Message ---
--- Begin Message ---
What OS are you using?

If you're on Win, then you may be able to do something with COM and a
PDF printer driver(pdfcreator comes to mind - check out theopencd)

If you're not, then you may be able to do something similar with OOo
and UNO, although Python may be a better choice than PHP, since there
is a native Python / UNO module, where as there is no PHP Uno module
afaik. If it _has_ to be PHP based, then perhaps you could make an
extension to interact with UNO in C.

On 6/22/05, Bosky, Dave <[EMAIL PROTECTED]> wrote:
> I need to find a way to allow users to select multiple files from a list
> and generate a single PDF file from them.
> 
> The documents are limited to the following formats: MS Word, MS
> PowerPoint, MS Excel, Plain Text, gif/jpeg images.
> 
> 
> 
> Are there any PHP classes or modules that exist which can tackle this
> tough task?
> 
> 
> 
> Thanks,
> 
> Dave
> 
> 
> 
> 
> 
> HTC Disclaimer:  The information contained in this message may be privileged 
> and confidential and protected from disclosure. If the reader of this message 
> is not the intended recipient, or an employee or agent responsible for 
> delivering this message to the intended recipient, you are hereby notified 
> that any dissemination, distribution or copying of this communication is 
> strictly prohibited.  If you have received this communication in error, 
> please notify us immediately by replying to the message and deleting it from 
> your computer.  Thank you.
> 
>

--- End Message ---
--- Begin Message ---
I am calling php from the command line and was wondering how I can set
the include_path of the ini file at run time?  Can I pass in an extra
param to php to set this?

Thanks!

--- End Message ---

Reply via email to