[nycphp-talk] Module Organization ideas...
mikesz at qualityadvantages.com
mikesz at qualityadvantages.com
Mon Aug 25 23:45:05 EDT 2008
Hello talk,
I have a script that I added to an existing CMS as an include module.
It contains a few functions that do database look ups and tests user
input for specific conditions to see if the data matches a set of
known (to me) footprints. I am using a preg_match on some of the
conditions and on others I have a known value for which I am testing.
I have two database log feature when I find a match and it sends me an
email when a match occurs. The first one logs the event and the second
one logs the IP address and email address contained in $_REQUEST.
The way I organized this module, I have two functions, the first one
does the IP lookup in my database and quits if it finds a match. The
second function drops through the list of conditionals and manages
events accordingly. I have about five conditionals that all analyze
the data contained in $_REQUEST (about twenty fields).
I have noticed that one or both of the conditionals that write the IP
and email address will occasionally write a blank record to the
database but when I check the email report I send to myself, it contains
both records?
I am thinking that maybe I need to break up the second function into a
more specific set of functions so that some of the conditionals, like
the posting to the database can be explicitly called when required.
From what I have read about object coding, this seems like it might be
a candidate for a class structure but I don't know object coding that
well to sort it out. I feel like what I have now is an "orderly mess"
and would like to restructure the module to make it easier to debug
and more efficient to execute.
Given the ideas presented, I would appreciate any feedback. Given that
I have not provided any coding examples, I am only looking for ideas
on how to reorganize this module. BTW, if you haven't guessed it, this
is a bad guy trap code so posting the code has a risk that the bad guy
will see the code and adjust his robot code to circumvent my code
which has a 100% success rate currently even with the annoying
database write bug that I am chasing.
TIA
--
Best regards,
mikesz mailto:mikesz at qualityadvantages.com
More information about the talk
mailing list