[PHP] VS.Php?

2011-07-03 Thread Murray By Moonlight
Hi All,

Just wondering if anyone has any experience with VS.Php? I'm coming from C#
job into a job where I will do mixed C# / PHP, and it would be good to be
able to work in the IDE environment I'm already used to when working on PHP
code.

M is for Murray
http://www.voodoologic.org


Re: [PHP] Re: How important is your Express or Web Edition database? Please weigh in--

2009-02-27 Thread Murray
Not sure he's from a company. His email address is in the
berkeley.edudomain. I guess there's a chance he's involved in Berkeley
DB, although I
believe this is now owned by Oracle? I'd be curious to know if any Berkeley
people are still involved in the development of the engine.

M is for Murray
http://www.voodoologic.org


On Sat, Feb 28, 2009 at 10:32 AM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 Oh, funny thing. I filled in the questionnaire above, and when it got to
 the final 'thanks' page, I clicked the button, and it bombed out to a
 completely blank page. Doesn't bode too well for a company attempting to
 sell a product for use in enterprise situations!



Re: [PHP] Re: DB Comparisons

2009-02-06 Thread Murray
In fact, ASP.NET happily connects with other DBMSes. I have several C#
ASP.NET web apps happily working with MySQL.

M is for Murray


On Fri, Feb 6, 2009 at 7:39 AM, Ashley Sheridan 
a...@ashleysheridan.co.ukwrote:

 although I think ASP can only connect to MSSQL and
 ASP.Net connects only to MSSQL and Oracle (but I'm not 100% certain on
 this)



[PHP] Help me understand unit testing?

2009-01-21 Thread Murray
Hi All,

I'd like to understand unit testing better (or, in fact, at all). I
understand the broad idea that testing Is A Very Good Thing, but when I have
tried to look into it further (for example, have just been looking through
the PHPUnit site), I always end up thinking 'This looks like more trouble
than it's worth.' I'm sure that's down to me and not the process of unit
testing, but I'd like to get some idea of how people on the list actually
use unit testing in the real world.

I'm assuming that you have your actual application classes and functions
designed in their own files, and then you build a series of unit testing
classes / functions in their own sort of space, but do you build these in
parallel to your application code, or during alpha / beta testing etc?

Any practical or even theoretical advice welcome!

Many thanks,

M is for Murray


Re: [PHP] Help me understand unit testing?

2009-01-21 Thread Murray
I think this is my problem -- basically to know how to get some benefit from
it.

If I have a function in a class that is supposed to return some rows, how
would I go about performing a useful unit test on it? In theory (and in my
current practice), I can simply dump the array or object, or step through
the code with XDebug in Netbeans PHP (love this app!) to see what is taking
place.

Where would a unit test come into this process in a useful way? Is it
because I can abstract the call to that function / class without having code
that puts it to the page? Some other benefit?

M is for Murray


On Thu, Jan 22, 2009 at 10:13 AM, Eric Butera eric.but...@gmail.com wrote:

 On Wed, Jan 21, 2009 at 7:01 PM, Murray planetthought...@gmail.com
 wrote:
  Hi All,
 
  I'd like to understand unit testing better (or, in fact, at all). I
  understand the broad idea that testing Is A Very Good Thing, but when I
 have
  tried to look into it further (for example, have just been looking
 through
  the PHPUnit site), I always end up thinking 'This looks like more trouble
  than it's worth.' I'm sure that's down to me and not the process of unit
  testing, but I'd like to get some idea of how people on the list actually
  use unit testing in the real world.
 
  I'm assuming that you have your actual application classes and functions
  designed in their own files, and then you build a series of unit testing
  classes / functions in their own sort of space, but do you build these in
  parallel to your application code, or during alpha / beta testing etc?
 
  Any practical or even theoretical advice welcome!
 
  Many thanks,
 
  M is for Murray
 

 Well this was a hard topic for me to grasp too.  A lot of times I
 still get lazy about it, but I strive to do my best.  Unit testing
 makes sure your code works as expected.  So if you're messing around
 with stuff, keep re-running your test suite and see if your changes
 break any of your tests.  This way you know whether or not your
 changes are breaking the very apps that rely on your code.

 Unit testing also allows you to quickly assess problems with different
 servers, php upgrades, whatever.

 Of course these are just little points.  Just give it a try and keep
 going at it.  Once I started I noticed that I had been writing my code
 all wrong.  Lots of weird dependencies, reliance on hard to recreate
 state, stuff like that.  It helped me to start writing leaner methods
 that targeted what they were supposed to do a lot better.

 There's a lot of info on this subject all across the net  in books.
 It isn't just limited to php, but programming in general.

 V is for Vendetta?



Re: [PHP] Code Not entering the value in the Database

2009-01-21 Thread Murray
You don't appear to be doing anything with this line of your code. You build
a string variable, but you don't call anything like mysql_query($sql) to
actually execute the INSERT statement.

M is for Murray


On Wed, Jan 21, 2009 at 12:34 AM, Chris Carter chandan9sha...@yahoo.comwrote:

 $sql = insert into `userstable` (hiddendata) VALUES ('$hiddendata');



Re: [PHP] Parsing HTML href-Attribute

2009-01-15 Thread Murray
Hi Edmund,

You want a regex that looks something like this:

$result = preg_replace('%(href=)(|\')(?!c:/)(.+?)(|\')%',
'\1\2c:/my_absolute_path\3\4', $subject);

This example assumes that your absolute path begins with c:/. You would
change this to whatever suits. You would also change c:/my_absolute_path
to be whatever appropriate value indicates the absolute path element that
you want to prepend.

Note: this will NOT accound for hrefs that are not encapsulated in either '
or . The problem being that while you can probably predictably how the
substring starts, it would be more difficult to determine how it ends,
unless you can provide a white list of file extensions for the regex (ie, if
you know you only ever link to, for example, files with .php and or .html
extensions). In that case, you probably could alter the regex to test for
these instead of a ' or .

M is for Murray


On Fri, Jan 16, 2009 at 8:13 AM, Edmund Hertle 
edmund.her...@student.kit.edu wrote:

 Hey,
 I want to parse a href-attribute in a given String to check if there is a
 relative link and then adding an absolute path.
 Example:
 $string  = 'a class=sample [...additional attributes...]
 href=/foo/bar.php ';

 I tried using regular expressions but my knowledge of RegEx is very
 limited.
 Things to consider:
 - $string could be quite long but my concern are only those href attributes
 (so working with explode() would be not very handy)
 - Should also work if href= is not using quotes or using single quotes
 - link could already be an absolute path, so just searching for href= and
 then inserting absolute path could mess up the link

 Any ideas? Or can someone create a RegEx to use?

 Thanks



Re: [PHP] Zend Framework...where to start? -- don't.

2009-01-15 Thread Murray
Hi Daevid,

Your included db.inc.php file contains what appears to be a very strict
injunction against people on this list making use of it.

In particular, these lines:

#---
#
# Confidential - Property of Symcell Corporation
# Do not copy or distribute.
# Copyright 2005-2008 Symcell Corporation. All rights reserved.
#
#---

Any chance you can resend this file without that warning included, if you
have the authority to remove it?

All the best,

M is for Murray


On Thu, Jan 15, 2009 at 7:39 AM, Daevid Vincent dae...@daevid.com wrote:

  Not to start a Holy War (as these to framework or not to framework
 debates often turn into), but I personally had a horrible experience with
 using frameworks. I was forced to use Symfony at my last job and it was so
 cumbersome and slow to do even the simplest things. The whole MVC thing can
 be overkill. Plus the learning curve can be quite steep. Then if you want to
 hire other developers to work with you, you have to train them and let them
 ramp up on not only the framework but also your core project too! More
 wasted time.

 The pages are significantly slower than straight PHP by orders of
 magnitude: http://paul-m-jones.com/?p=315

 The basic problem with frameworks is they try to be one thing for all
 people. This carries a lot of baggage with it. There's a lot of crap you end
 up pulling in that you don't want/need. Plus if you want to deviate at all,
 you either have to roll your own, or sometimes you simply just can't. They
 seem attractive with all their plugins and stuff, but honestly, rarely do
 the plugins do EXACTLY what you want, the way you want. It might be as
 simple as trying to change the look/feel of a button or something and you'll
 find out that you can't -- so now you have this website that has this
 section that doesn't look like the rest of your site. And if you find a bug,
 you have to try to either fix it yourself and then keep those changes
 migrated into new updates, or submit it to the developer and hope they
 implement them (and trust me, you can submit to them and have them rejected
 for all sorts of lame reasons -- even though the work has been done and
 you're using it!)

 I advise against it. Just follow good practices and use thin wrappers and
 functions. Don't get all OO googlie eyed and try to over-engineer and
 over-OO the code. OO is great for some things (like a User class) but don't
 start making some OO page renderer or form builder. Don't fall into the DB
 Abstraction trap either -- just use a wrapper around your DB calls (see
 attached), so you can swap out that wrapper if (and you almost never do) you
 change the DB. Don't be suckered by something like QuickForms -- you WILL
 run into limitations that you can't get around and are at their mercy. Don't
 buy the hype that DIV's are the magic bullet and TABLEs are poor design --
 Tables are still the best and most ubiquitous way to align things in a
 browser agnostic way (including mobile phones, etc.) and to layout forms.

 I've not used Zend myself, so I can't say for certain, but the above
 tenements I think would still hold true. I guess I would trust the Zend one
 the most given they actually make PHP, but at this point in time, I would
 never choose to use a bloated framework. Then again, I write enterprise
 level and very custom applications (Saas) so maybe this doesn't apply if all
 you're trying to do is make yet another Blog or Photo-album or
 personal/corporate website or something generic/basic. I've been coding
 nearly 20 years and founded several $MM companies. That's my take (or rant
 depending on how you look at it).

 Daevid.
 http://daevid.com


 On Wed, 2009-01-14 at 20:36 +, jco...@gmail.com wrote:

 I've been reading about these great new 'frameworks' for PHP development.

 The most similar experience I have so far is using PEAR/Smarty in
 application development.

 I am becoming very interested in adding one (or more) of these frameworks
 to my work existence.

 I'm leaning toward the Zend Framework for the following reasons:
 1. Zend's commitment to PHP in the enterprise environment
 2. I'm studying for Zend PHP certification...so remaining within the same
 family sort of makes sense.
 3. It's widely heralded as a very good 'framework'
 4. Integration with my IDE, Zend Studio
 5. Great support/userbase/forums/docs

 I'm getting ready to start a new project that is going to be somewhat of a
 stretch for me. It'll be probably the most complex project I've done where
 I'm the only designer/developer and have to do everything myself: from func
 spec to mockups to wireframes to database design to documentation to code
 to maintenance...all of it is me.

 What do you think, should I kill 2 birds with one stone and use the ZF to
 build this new project? Or would it slow me down to add 'learning the ins
 and outs of a new way

Re: [PHP] Referencing variable in calling class?

2009-01-11 Thread Murray
Hi Paul,

To be honest, I'm still finding my way around as to how I want to approach
this application, but my question is valid in some sense no matter which
direction I pursue.

I finally opted to make the relevant variables in my front controller class
static, so I could directly reference them from optionally included
downstream code.

This has worked well so far, at least in my early experimentation with a
code layout.

Thanks for your reply all the same!

M is for Murray


On Sun, Jan 11, 2009 at 4:39 PM, Paul M Foster pa...@quillandmouse.comwrote:

 On Sun, Jan 11, 2009 at 10:33:30AM +1000, Murray wrote:

  Hi All,
 
  I'd like to reference the value of a variable in a class that called the
  current piece of code via a require_once.
 
  In essence, I have a 'front controller' class that builds the page to be
  displayed depending on several criteria.
 
  One issue I'm having is that when a user logs out of my application, I
  destroy the cookie that indicated the user was logged in during my
 preRender
  process, and then go onto display the 'logged out' page. Unfortunately, I
  have a page element that indicates whether the user is logged in or not,
 and
  I assume because the cookie destruction is being sent down in that page
  request, when that page renders it still appears as if the user is logged
  in, because the cookie still exists until after that page is rendered.
 
  So, I thought perhaps as part of my logout routine, I could set a
 variable
  that my 'are you logged in or out' code could check and use to override
  whether or not it displays the 'login' url or the 'logout' url.
 
  I thought that in that code I should be able to check the value of a
 public
  variable that is in my front controller class, but it appears I can't?
 
  So, pseudo chain of processing would be something like this:
 
  - call index.php
  - instantiate front loader class
  - perform pre-render processing, if logging out, set public variable in
  class to true
  - call actual page to be rendered via require_once
  - in page being rendered, call function from separate file that displays
  'login / logout' url
  - in that function test public variable in front controller class to see
 if
  true
  - if true, regardless of whether or not the cookie still 'appears' to
 exist,
  display 'login' url because user has logged out
 
  However, am I right in thinking that the function that displays the login
 /
  logout url is actually unaware of the existence of the front controller
  class at the point at which it is being called?
 
  M is for Murray

 I'm not quite sure why you don't force the login/logout page to use the
 front controller. Here's how I do it: I set various variables, and check
 the login status (I use $_SESSION variables to hold user ID and
 encrypted password). If the user is not logged in, I force the
 controller to be the login controller, regardless of whatever page the
 user *wants* to display. Then I go ahead with instantiating the
 controller, in this case, the login controller. So essentially, if the
 user is logged in, I go ahead and instantiate whatever controller they
 specify. But if they're not logged in, I force the login controller to
 be the one which is instantiated. (In my case, the front controller
 isn't really a class as other controllers are. It's just a bunch of
 routines and function calls in index.php.)

 Does that make sense?

 Paul

 --
 Paul M. Foster

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




Re: [PHP] Using MDB2 outside the PEAR framework?

2009-01-10 Thread Murray
Just for the record, it appears (so far) that the fix for my problem was
REMOVING the path to the normal PEAR directory from my 'include_path'
string. I guess a conflict was taking place where files were being loaded
both from the included subdirectories in my application and the PEAR
directories themselves.

M is for Murray


On Sat, Jan 10, 2009 at 9:47 PM, Murray planetthought...@gmail.com wrote:

 Hi Richard,

 Where would I find that article, if you think it might help me get MDB2
 working properly?

 Many thanks in advance,

 M is for Murray


 On Sat, Jan 10, 2009 at 9:32 PM, Richard Heyes rich...@php.net wrote:

  ...

 FWIW, for anyone considering the same, it can be done easily by not
 using the PEAR installer, and copy/pasting the code from the PEAR
 website. I wrote an article on appliction structure which illustrates
 this, having a PEAR installation directory alongside your htdocs
 directory.

 --
 Richard Heyes

 HTML5 Graphing for FF, Chrome, Opera and Safari:
 http://www.rgraph.org (Updated January 4th)





Re: [PHP] Apache File Quesiton

2009-01-10 Thread Murray
The fundamental thing you're missing, as I understand it (I'm sure someone
will speak up if I'm wrong), is that you shouldn't be storing your site
outside the htdocs directory. This is where Apache looks for files it can
display in your browser.

So, you need to move all of the files you have in My
Documents\Sites\nameofsite to \xampp\htdocs\nameofsite in your xampp
installation location.

I presume you can point Dreamweaver at this directory as the root of your
project once you've copied / moved the files across. It sounds like My
Documents\Sites\etc is simply Dreamweaver's default preference.

Once you've moved your files into \xampp\htdocs\nameofsite, try going to the
following in your browser:

http://localhost/nameofsite (or, as you pointed out, your files will be in
\xampp\htdocs\barrister and you would then go to
http://localhost/barristerin your browser).

M is for Murray


On Sat, Jan 10, 2009 at 11:22 PM, Gary gwp...@ptd.net wrote:

 Ok, not yet...

 If the file I want to test resides in My Documents\Sites\nameofsite, I set
 my Test server folder in DW to map to here...correct?

 Now down to URL prefix, I have tried
 http://localhost
 http://localhost/sitename
 C:/xampp/apache,( which btw is the Site Root as described in httpd.conf )
 C:/localhost/

 and a few other variations that are escaping me at this moment, but keep
 getting an error.

 Some other BG info

 Server Model : PHP Mysql
 Access : Local/Network
 Testing server folder: C:\Documents and Settings\myname\My
 Documents\sites\barrister\ (barrister is the name of the file and site)
 URL Prefix http://localhost/barrister/ (currently)

 What am I missing (besides a fundemental understanding of it).


 Murray planetthought...@gmail.com wrote in message
 news:6481f4d0901092018g31d9a08fkd0321e1532c85...@mail.gmail.com...
  In general, as Phpster points out, your development will take place in
  directories underneath your htdocs directory, which, if you installed
  XAMPP
  into the root directory on C:, would be something like
  C:\xampp\htdocs\yourdevdirectory.
 
  Depending on how XAMPP is configured (you can make many changes, for
  example, to the Apache conf files to determine Apache's behaviour), you
  would probably use a URL of http://localhost/yourdevdirectory/index.php
  etc
  to access your actual application.
 
  This is not to mention that you can go on to setup virtual sites, so that
  you could access your site as http://yourapplicationname/index.php.
 
  M is for Murray
 
 
  On Sat, Jan 10, 2009 at 12:13 PM, Gary gwp...@ptd.net wrote:
 
  Not sure how to word this, but I have just installed the XAMMP package
  with
  Apache,  PHP for the purpose of having a testing server.
 
  My confusion is the location of the files.  I am using Dreamweaver CS3,
  and
  all of my sites were in My Douments\Sites. When I was trying to set up
  the
  testing server in DW, I directed it to http://localhost.  I was pretty
  sure
  it was not going to work, and I was right.  I then created a folder in
  C:\xammp\htdocs\ and directed it to there...again no go.
 
  Part of my confusion is that if I create a page as I normally do, and it
  is
  stored in My documents\Sites\sitename, then there is no file that is
 then
  created in the C:\xammp\htdocs\.
 
  So, does it make sense for me to simply put all of my local files in the
  tester server root folder? Or am I going about it wrong?
 
  Thanks
 
  Gary
 
 
 
  --
  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




[PHP] Referencing variable in calling class?

2009-01-10 Thread Murray
Hi All,

I'd like to reference the value of a variable in a class that called the
current piece of code via a require_once.

In essence, I have a 'front controller' class that builds the page to be
displayed depending on several criteria.

One issue I'm having is that when a user logs out of my application, I
destroy the cookie that indicated the user was logged in during my preRender
process, and then go onto display the 'logged out' page. Unfortunately, I
have a page element that indicates whether the user is logged in or not, and
I assume because the cookie destruction is being sent down in that page
request, when that page renders it still appears as if the user is logged
in, because the cookie still exists until after that page is rendered.

So, I thought perhaps as part of my logout routine, I could set a variable
that my 'are you logged in or out' code could check and use to override
whether or not it displays the 'login' url or the 'logout' url.

I thought that in that code I should be able to check the value of a public
variable that is in my front controller class, but it appears I can't?

So, pseudo chain of processing would be something like this:

- call index.php
- instantiate front loader class
- perform pre-render processing, if logging out, set public variable in
class to true
- call actual page to be rendered via require_once
- in page being rendered, call function from separate file that displays
'login / logout' url
- in that function test public variable in front controller class to see if
true
- if true, regardless of whether or not the cookie still 'appears' to exist,
display 'login' url because user has logged out

However, am I right in thinking that the function that displays the login /
logout url is actually unaware of the existence of the front controller
class at the point at which it is being called?

M is for Murray


Re: [PHP] Editing in a text area field

2009-01-10 Thread Murray
I don't know why, but I always baulk when I see HTML and, for example, XML
etc described as a 'language'.

I may well be wrong, but these always seem to be more appropriately
described as a 'syntax' rather than a 'language', at least in the computer
science sense. Of course, maybe these are essentially synonymous, but
'language' has always implied to me a more active role, so that PHP would be
a language, while HTML would be a syntax.

Just thinking out loud.

M is for Murray


On Sun, Jan 11, 2009 at 2:04 AM, Nathan Rixham nrix...@gmail.com wrote:

 HTML is a markup language used to describe the structure of a document;
 presentation of HTML is controlled by either a client, with optional
 instructions via attributes (bad) or css (good)


Re: [PHP] Editing in a text area field

2009-01-10 Thread Murray
Interesting, I've never seen this presented as an issue of ethics before. I
think I can see your point, but I'd suggest that there's an interplay of
ethical obligations between a user and the host / creator of an application
in which perhaps the user should or in many cases has to accept a
de-prioritised ethical consideration.

For example, I would guess that a user doesn't have the right to expect an
application to perform exactly to his or her expectations, regardless of
what they might be. So, I wouldn't consider myself ethically obligated to
work out how to accept 3gb of text from a POSTed form without truncating /
modifying that text due to practical limitations of my application. (not
suggesting this is a possible real-world example).

But still, an interesting observation!

M is for Murray


On Sat, Jan 10, 2009 at 6:36 AM, Daniel Brown danbr...@php.net wrote:

Well, of course you have the _right_ to do it --- as long as it's
 legal, and it's not something that *requires* the data to remain
 unaltered, you have the right to do manipulate it however you want.
 The question comes down to ethics and in predicting the preferences of
 the user.



Re: [PHP] Editing in a text area field

2009-01-10 Thread Murray
I agree with others that in most cases you should be storing input as it is
presented to you once POSTed (with the usual caveats of escaping etc to make
INSERTing / UPDATEing possible).

This is exactly what you are doing when accepting input from FCKEditor etc.
Your input contains markup, and that's what you store.

My issue with modifying content after being POSTed, prior to storing in my
db is that for all of the careful considerations that I might put into
making only 'good' modifications, I might inadvertently make 'bad'
modifications instead or as well.

The same is true if I store the text and modify on the fly on the way to
presentation, but the important difference is that my stored version has
remained true to input, and if I correct whatever I might have done wrong
during display processing, I have not permanently changed or damaged my
stored data.

M is for Murray


On Sun, Jan 11, 2009 at 11:57 AM, Eric Butera eric.but...@gmail.com wrote:

 I don't see any problem with accepting html/xhtml/xml in an input
 area.  I do it all the time with FCKEditor.



Re: [PHP] Using MDB2 outside the PEAR framework?

2009-01-09 Thread Murray
I'm still experiencing problems making use of my imported MDB2 classes.

General querying appears to work fine, but performing something like
$mdb2-quote($variable) causes the application to come to a halt, without
any error messages (at least, without any displayed while debugging through
Netbeans 6.5).

What I did was copy into my application directories the following:

- MDB2.php
- PEAR.php
- All files under subdirectory MDB2

I added the directory where MDB2.php and PEAR.php are located to the
include_path, as well as the MDB2 subdirectory.

I know this is probably a longshot, but I was wondering if anyone on the
list has any ideas if I should be including any other subdirectories, or if
I should have copied anything else across from the PEAR installation to get
functions such as $mdb2-quote() to work?

Other than that, does anyone know of a resource where I can ask questions
such as the above to people more actively involved with the MDB2 project?
Unfortunately, this is driving me bonkers and means I'm not spending quality
time on the actual development of the application I'm trying to build.

M is for Murray


On Sat, Dec 27, 2008 at 3:50 PM, Murray planetthought...@gmail.com wrote:

 Thanks John and Mattias,

 It looks like your advice has helped me achieve my goal.

 Thanks again!

 M is for Murray



 On Sat, Dec 27, 2008 at 2:05 PM, Mattias Thorslund 
 matt...@thorslund.uswrote:

 As far as I recall, having done this, all that is required for a basic
 MDB2 is the PEAR base class and the driver classes for the platforms you
 want to support.



 Murray wrote:

 Hi All,

 I'm wondering if it's possible or practical to implement MDB2 in my web
 application, but without requiring a PEAR installation on the destination
 server?

 Essentially, I'd like to include MDB2 entirely within my web application,
 so
 I can make use of db abstraction even on servers where PEAR isn't and
 can't
 be installed.

 Any suggestions?

 Many thanks in advance,

 M is for Murray








Re: [PHP] Apache File Quesiton

2009-01-09 Thread Murray
In general, as Phpster points out, your development will take place in
directories underneath your htdocs directory, which, if you installed XAMPP
into the root directory on C:, would be something like
C:\xampp\htdocs\yourdevdirectory.

Depending on how XAMPP is configured (you can make many changes, for
example, to the Apache conf files to determine Apache's behaviour), you
would probably use a URL of http://localhost/yourdevdirectory/index.php etc
to access your actual application.

This is not to mention that you can go on to setup virtual sites, so that
you could access your site as http://yourapplicationname/index.php.

M is for Murray


On Sat, Jan 10, 2009 at 12:13 PM, Gary gwp...@ptd.net wrote:

 Not sure how to word this, but I have just installed the XAMMP package with
 Apache,  PHP for the purpose of having a testing server.

 My confusion is the location of the files.  I am using Dreamweaver CS3, and
 all of my sites were in My Douments\Sites. When I was trying to set up the
 testing server in DW, I directed it to http://localhost.  I was pretty
 sure
 it was not going to work, and I was right.  I then created a folder in
 C:\xammp\htdocs\ and directed it to there...again no go.

 Part of my confusion is that if I create a page as I normally do, and it is
 stored in My documents\Sites\sitename, then there is no file that is then
 created in the C:\xammp\htdocs\.

 So, does it make sense for me to simply put all of my local files in the
 tester server root folder? Or am I going about it wrong?

 Thanks

 Gary



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




Re: [PHP] Is MD5 still considered safe for storing application user passwords?

2008-12-31 Thread Murray
Well, the idea would be to allow the person downloading and implementing the
application to choose their own salt value. That way, in theory, each
implementation of the application will be salting the hash algorithm with a
different value.

I guess, if you really wanted to get tricky, you could programatically
generate a random string on first run of the application and store it in a
background db or in your config file, so that you could be more certain that
the salt value from implementation to implementation was different.

M is for Murray


On Thu, Jan 1, 2009 at 12:12 AM, Jason Pruim japr...@raoset.com wrote:


 On Dec 31, 2008, at 5:36 AM, Richard Heyes wrote:

 Hi,

 ...


 You should also take into account how crucial your data is. If it's
 nuclear launch codes I would say that you can't get enough security.
 Howver if it's an admin system for Bobs local grocery store, then as
 Phpster suggested, a salted hash may well be enough. For example,
 you could use this:

 ?php
 $hash = md5($password . 'salt -
 bhuyfuyftyfctujvikhgvbhjiftye5645rt68ty97tgifyvcu6yt7d');
 ?


 Correst me if I'm wrong... but assuming that your salt string is hard coded
 into the program, with a MD5 a password + salt is no more secure then a
 simple password?

 Unless... When they log in, you store a MD5 hash of the salt in a separate
 field in the database, and store it on in a cookie so it can be compared.

 Or am I just missing something obvious like usual? :)


 --
 Jason Pruim
 japr...@raoset.com
 616.399.2355






[PHP] Is MD5 still considered safe for storing application user passwords?

2008-12-30 Thread Murray
Hi All,

I've been vaguely aware that more and more effort is going into proving that
MD5 isn't secure anymore, but this article in particular -
http://www.win.tue.nl/hashclash/rogue-ca/ - has me wondering if MD5 is still
safe for storing hashed user passwords?

I realise that article is talking about a very different use of an attack on
MD5, but I'm curious if other developers are still using MD5, or if another
hashing algorithm is considered better?

Many thanks for any advice,

M is for Murray
http://www.ulblog.org


Re: [PHP] Architecture patterns in PHP

2008-12-27 Thread Murray
I'm interested in this topic as well. I'm starting out on a reasonably large
web application, and I'm wondering at the best approach in PHP, particularly
since it's been some years since I worked with PHP on a daily basis (the
last 5 years have been purely C#).

There's some dev community bias against using frameworks, isn't there? On
one hand I'd love to take an approach that would make my end goal easier
(thanks for pointing out Code Igniter, I'll look into it further), but on
the other hand I'd rather avoid choices that 'tainted' (perhaps not the
right word, but the best I could think of) the overall acceptance of the
application once it's ready for release.

So, currently I'm wondering about things like, 'Do I make an app that is a
distinct page-per-function, or do I make an app that uses a monolithic
index.php (similar to Wordpress?) and dynamically presents
*everything*based on querystring values.'

M is for Murray


On Sun, Dec 28, 2008 at 10:05 AM, Nathan Nobbe quickshif...@gmail.comwrote:



  Hey,

 How do you structure your web applications? I am thinking in terms of
 separating presentation  and logic. How is that done in PHP?


 mvc is pretty popular, but php is so flexible you often don't need it for
 smaller applications.

 For example, if you take a page-controller approach, a php app is dead
 simple.  You have a seperate entery point for evrything; login.php,
 register.php, etc could be considered controllers, then all your common
 logic comes in via some includes, hopefully files outside the webroot.  then
 you have some template directory w/ files that are a mixture of php and
 html(for example).  your 'controller' files include the library code, hit
 the db (if necc.) and then stuff data into the templates for output.

 if you want to see an exmple if a more traditional mvc there are scads of
 open source frameworks out there which use a front controller approach. Code
 igniter is really straight forward, you can probly learn quickly from it.

  And how many architecture patterns are there?


 please do try to avoid pandoras box on the list ;)  It can result in 100+
 post threads, heh.  that being said patterns are pretty general things,
 that's why they're called patterns.  most of the time various languages will
 result in slightly different concrete realizations of a pattern, but you'll
 find most of them rather simple to realize in php.  One that really isn't
 well suited to phps build-up / tear-down paradigm is the state pattern.
  much easier in java or cpp, imo.

 -nathan


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




[PHP] Using MDB2 outside the PEAR framework?

2008-12-26 Thread Murray
Hi All,

I'm wondering if it's possible or practical to implement MDB2 in my web
application, but without requiring a PEAR installation on the destination
server?

Essentially, I'd like to include MDB2 entirely within my web application, so
I can make use of db abstraction even on servers where PEAR isn't and can't
be installed.

Any suggestions?

Many thanks in advance,

M is for Murray


Re: [PHP] Using MDB2 outside the PEAR framework?

2008-12-26 Thread Murray
Hi John,

Well, this is the thing -- I suspect there are dependencies, particularly on
the core PEAR files themselves. I'm just wondering if someone else has done
this and if it's too difficult to make the effort worthwhile.

The Wordpress project, for example, I think rebuilt an abstraction layer in
the application. Since it uses a similar (or exact?) syntax as MDB2, I'd
always assumed they basically ported the MDB2 engine into the application,
rather than relying on PEAR and MDB2 as external dependencies.

Obviously there are good reasons for maintaining the PEAR libraries, since
these can be (relatively) easily updated to latest releases, but I for one
have previously helped out people who were hosted on sites that didn't allow
users to maintain PEAR libraries, and I'd like to remove that sort of
'compatibility' issue for my own project.

Thanks for your reply!

M is for Murray


On Sat, Dec 27, 2008 at 12:34 PM, jco...@gmail.com wrote:

 I guess you could just put MDB2.php and /MDB2 somewhere in your include
 path, right?

 If MDB2 has any dependencies, you'd need those too.

 I've never tried it, couldn't say whether they'd work outside of the PEAR
 installation/framework.

 John Corry

 On Dec 26, 2008 9:11pm, Murray planetthought...@gmail.com wrote:
  Hi All,
 
 
 
  I'm wondering if it's possible or practical to implement MDB2 in my web
 
  application, but without requiring a PEAR installation on the destination
 
  server?
 
 
 
  Essentially, I'd like to include MDB2 entirely within my web application,
 so
 
  I can make use of db abstraction even on servers where PEAR isn't and
 can't
 
  be installed.
 
 
 
  Any suggestions?
 
 
 
  Many thanks in advance,
 
 
 
  M is for Murray
 


Re: [PHP] Using MDB2 outside the PEAR framework?

2008-12-26 Thread Murray
Thanks John and Mattias,

It looks like your advice has helped me achieve my goal.

Thanks again!

M is for Murray


On Sat, Dec 27, 2008 at 2:05 PM, Mattias Thorslund matt...@thorslund.uswrote:

 As far as I recall, having done this, all that is required for a basic MDB2
 is the PEAR base class and the driver classes for the platforms you want to
 support.



 Murray wrote:

 Hi All,

 I'm wondering if it's possible or practical to implement MDB2 in my web
 application, but without requiring a PEAR installation on the destination
 server?

 Essentially, I'd like to include MDB2 entirely within my web application,
 so
 I can make use of db abstraction even on servers where PEAR isn't and
 can't
 be installed.

 Any suggestions?

 Many thanks in advance,

 M is for Murray







[PHP] Do defined variables exist at application scope, or session scope?

2008-12-26 Thread Murray
Hi All,

In the index.php file of my application I define several variables,
including such things as the base path of the app, and the theme path etc.

Since I use 'define()' to do this, are these variables available to my app
regardless of where a particular user enters the app?

So, in starting the app, I define these variables by visiting index.php. But
if another user gets sent a url to, for example, the help page, when they
visit it will those variables be available, or will I need to explicitly
check on each to make sure the variables are defined, because the user
entered at a different entry point than the 'normal' one?

Note: I will probably do an explicit check anyway, since this seems more
robust, but I ask to better understand how define works.

Many thanks,

M is for Murray


Re: [PHP] Do defined variables exist at application scope, or session scope?

2008-12-26 Thread Murray
Hi Larry,

You're absolutely right, I'm talking about constants rather than variables.

I guess in my very crude way, I'm trying to ask about the following:

UserA goes to the site via index.php, which defines several helpful
constants.

So do UserB through UserF.

UserG, however, first arrives at the site on help.php.

Because UserA, UserB, UserC etc have been to index.php, which has now been
executed, are the constants available with their values in help.php, even
though UserG, in particular, started in the application at this point?

So, another way of putting it, do these constants live for the life of the
application per se (ie, presumably until the server is restarted etc), or
will code in help.php be unable to access the values of defined constants
for this particular user because they were not at index.php first?

Many thanks for your reply,

M is for Murray


On Sat, Dec 27, 2008 at 5:00 PM, Larry Garfield la...@garfieldtech.comwrote:

 On Friday 26 December 2008 11:54:30 pm Murray wrote:
  Hi All,
 
  In the index.php file of my application I define several variables,
  including such things as the base path of the app, and the theme path
 etc.
 
  Since I use 'define()' to do this, are these variables available to my
 app
  regardless of where a particular user enters the app?
 
  So, in starting the app, I define these variables by visiting index.php.
  But if another user gets sent a url to, for example, the help page, when
  they visit it will those variables be available, or will I need to
  explicitly check on each to make sure the variables are defined, because
  the user entered at a different entry point than the 'normal' one?
 
  Note: I will probably do an explicit check anyway, since this seems more
  robust, but I ask to better understand how define works.
 
  Many thanks,
 
  M is for Murray

 Well, there is no such thing as a defined variable.  You are, I presume,
 talking about constants.  (That's what you get from define().)  A global
 constant (vis, not a class constant) is super-global, that is, available
 absolutely everywhere after the line of code that defines it has executed.

 So if the user goes to index.php, and the first line defines a constant
 DEBUG_LEVEL, then that constant now exists anywhere in any function or
 method
 for the rest of that page request, period.

 However, if someone goes to help.php then the line in index.php is never
 executed (why would it be, since the file was never included?), so the
 constant
 is not defined.

 Does that make sense?

 --
 Larry Garfield
 la...@garfieldtech.com

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




Re: Re: [PHP] exec() Error

2008-06-26 Thread Jason Murray
Alice,

If you are already set 755 on the CGI, it looks like it might be a webserver
configuration issue.

If you are using Apache (I'm assuming you are) you might want to take a look
at

http://httpd.apache.org/docs/2.0/howto/cgi.html#configuringapachetopermitcgi

for some hints on how to make sure that the server configuration is proper
for using CGI scripts.

Regards

Jason

On Thu, Jun 26, 2008 at 8:50 AM, Wei, Alice J. [EMAIL PROTECTED] wrote:

 Hi, Todd:

   It looks like I have some other errors in my Perl code, and I got it
 fixed, switched the permission to 755, and made attempts to call it using
 cURL through my working PHP script.

   Here is the code:

 // create a new cURL resource
 $ch = curl_init();

 // set URL and other appropriate options
 curl_setopt($ch, CURLOPT_URL, http://192.168.10.63/total.cgi;);
 curl_setopt($ch, CURLOPT_HEADER, false);

 // grab URL and pass it to the browser
 curl_exec($ch);

 // close cURL resource, and free up system resources
 curl_close($ch);

 This time, I do not get the script output from the script in total.cgi,
 but I got

 Forbidden
 You don't have permission to access /total.cgi on this server.

 I have switched the permission to both scripts at both servers. Is there
 something wrong I have done here?

 Thanks again for your help.

 Alice
 ==
 Alice Wei
 MIS 2009
 School of Library and Information Science
 Indiana University Bloomington
 [EMAIL PROTECTED]
 
 From: Boyd, Todd M. [EMAIL PROTECTED]
 Sent: Wednesday, June 25, 2008 5:07 PM
 To: Wei, Alice J.; php-general@lists.php.net
 Subject: RE: Re: [PHP] exec() Error

  -Original Message-
  From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, June 25, 2008 3:31 PM
  To: Boyd, Todd M.; Per Jessen; php-general@lists.php.net
  Subject: RE: Re: [PHP] exec() Error

 ---8--- snip

   Well, http://www.mysite.com/calculate.php; is not an executable.
  Try
   this instead:
  
   exec(php path/calculate.php);
 
  I still don't think this is how exec() should be used when executing
  remote PHP scripts via HTTP, since the web server is not going to give
  you the underlying code simply because you're calling the URL from PHP
  and not your web browser. User-Agent tags do not a secure connection
  make.
 
  Perhaps doing a wget and directing it to /dev/null (if you're on *nix)
  would be appropriate to invoke a remote script and pass it parameters.
  Hell, even wget to standard output if you want, and use that as your
  result code. It's basically doing what cURL does, but outside of the
  PHP script itself.
 
  Anyway, I digress. My point is that exec(php
  http://mysite.com/script.php;) will fail, since it will be reading the
  remote script's OUTPUT, and not the remote script's SOURCE CODE.
 
 I dont' know how come his code works either. I figured that exec()
  is not going to get me anywhere when I have it stored remotely.
 I am now using cURL instead of using exec(), since it is doing a
 lot
  closer to what I initiated. I am not sure if I should have a new
 thread
  for this, but I found that things start to get a little weird when I
  tried to do cURL with Perl files inside. The PHP only brings me back
  Perl code and not the processed content. Is this something I should
 not
  be doing with cURL? It seems to do quite a bit of powerful processing
  when I wrote everything in PHP and have it stored remotely.

 Alice,

 If it's returning the code instead of the processed content, then it
 means that the webserver which houses the Perl script is not
 executing/parsing it. You should check with the administrator of the
 remote webserver to see if they have a Perl module installed, and if it
 is configured properly for your web app.

 HTH,


 Todd Boyd
 Web Programmer




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




Re: [PHP] Inspiration for a Tombstone.

2008-06-26 Thread Jason Murray
I'm thinking:

?php
header(HTTP/1.1 410 Gone);
die();
?

Regards,

Jason

On Thu, Jun 26, 2008 at 1:54 PM, David Giragosian [EMAIL PROTECTED] wrote:

  My favorite vi command:

 e! Damn it. e!

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



Re: [PHP] Inspiration for a Tombstone.

2008-06-26 Thread Jason Murray
Body not found? Who do you think I am?  Jesus?

On Thu, Jun 26, 2008 at 3:01 PM, Robert Cummings [EMAIL PROTECTED] wrote:
 On Thu, 2008-06-26 at 14:54 -0400, Jason Murray wrote:
 I'm thinking:

 ?php
 header(HTTP/1.1 410 Gone);
 die();
 ?

 What about a 404? :)

 ?php

header( 'HTTP/1.1 404 Body Not Found' );

 ?

 Cheers,
 Rob.
 --
 http://www.interjinn.com
 Application and Templating Framework for PHP



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



Re: [PHP] changing order of items

2008-05-15 Thread Jason Murray
On Thu, May 15, 2008 at 2:09 PM, afan pasalic [EMAIL PROTECTED] wrote:

 this one bugs me for a while. how to change order.

 I have a list of tasks. by status, task could be 1 (todo) or 0 (done) -
 status value stored in mysql. I can list tasks per status or all.
 order number is stored in mysql too.
 the easiest way to change order is to have form for each task where you
 will enter manually number and then submit (one submit button for whole
 form). but, if you change order number for any task you have to change
 then all order numbers below the task manually

 solution with arrows (or up/down buttons) where you click on arrow and
 the task switch the place with its neighbor is easy and fancy. Though,
 I get in trouble if, e.g. tasks 10, 11, 12, and 13 change status from 1
 to 0 and I have to move task 14 to place 6. I have to click first 4
 times (to switch places with tasks 13, 12, 11, and 10) - but nothing is
 actually happening on screen (of course) before start switching places
 with 9, 8, 7, and 6.

 how do you avoid this gap?
 what solution do you use at all?

 thanks for any help.

 -afan
  http://www.php.net/unsub.php


I am assuming that each time you click the up or down arrow you are
re-loading the page (via a GET request).  A simple solution to this, would
be to adjust the URLs assigned to the up and down arrows to carry an extra
variable, the item either directly above or directly below the one selected,
and instead of doing whole-sale renumbering, create a swap function.  That
just swaps the position of the two items.

example:

?php
$rows = get_items_in_list();
for ($i = 0 ; $i  count($rows); $i ++) {
  echo $rows[$i]['taskname'].nbsp;;
  // create move up link
  if ($i  0) {
echo 'a
href=page.php?this='.rows[$i]['position'].'other='.$rows[($i-1)]['position'].'move
up/anbsp;';
  }
  //create mode down link
  if ($i  (count($rows) -1)) {
echo 'a
href=page.php?this='.rows[$i]['position'].'other='.$rows[($i+1)]['position'].'move
up/abr/';
  }
}
?

Then your page would just have to watch for those two variables being set at
load and select the appropriate items in the database based on the order and
swap their two positions, this will allow you to handle gaps in the
positioning scheme, for example when you are only listing the status 1 items
and not all the items.

*note* The code above is completely off-the-cuff and not tested, don't blame
me if there are any bugs in it ;)

Regards,

Jason


Re: [PHP] Two word array Value

2008-05-14 Thread Jason Murray
Try:

  echo tdinput name=.urlencode($key). type=checkbox
value=.urlencode($value)./tdtd. $value./td;


On Wed, May 14, 2008 at 4:02 PM, Mark Bomgardner [EMAIL PROTECTED]
wrote:

 I am trying to use array's to populate a group of check boxes for a form.
  I
 am getting the checkboxes to print OK, but when the form is posted I am
 only
 getting part of the array.



 Form Page:



 $vars = array(Main Classroom = Main Classroom, Break Out Classroom
 =
 Break Out Classroom, Gym = Gym,

 Firearms Range = Firearms Range, EVOC Track = EVOC Track);





 $cols = 4;

 echo form method=post action=twocoltests.phptabletrtd
 colspan=.$cols. align=centerEquipment Needed/tdtr;

foreach($vars as $key = $value){

  if (($cols % 4) == 0 ){ echo /trtr; }



  echo tdinput name=.$key. type=checkbox
 value=.$value./tdtd.$value./td;

  $cols++;

}



 echo /tr/table;

 echo br /;



 When I submit the form I am only getting the following having checked the
 boxes for Mail Classroom and Break Out Classroom.  If I eliminate the
 spaces
 between the words, I get everything, but when I put the spaces between the
 words in the array, it cuts off the second word.  Not sure what is
 happening?



 Array ( [Main] = Main [Break] = Break [Submit] = Submit )




Re: [PHP] Is it better to return a multi-array, or an array of objects?

2006-03-03 Thread Murray @ PlanetThoughtful

On 4/03/2006 3:10 PM, Daevid Vincent wrote:

I'm building a fairly large project. I've been trying to follow best
practices, but I'm a bit worried about performance. Using PHP 5.1 and mySQL
5.0.

I have product and company classes.

So when a user does a search of the database, is it better/faster/etc. to
return just a two dimensional associative array to populate an HTML table of
the results like: product name, product id, price, company name, company
phone, etc. (assume I'm only showing some of the total number of fields).
  

[snip]

One observation: you shouldn't return all fields in a recordset unless 
you *need* all of the fields in a recordset.


The majority of the time, you should be explicitly stating which fields 
to retrieve in your SQL statement, as in:


SELECT field1, field2, field8 FROM mytable WHERE whatever

as opposed to:

SELECT * FROM mytable WHERE whatever

Some of the time, yes, that will mean you're explicitly typing out 7 
field names from a table that only has 8 field names, but getting out of 
the habit of using *, particularly if you expect your application to 
work well under heavy loads, will save you resources, which will 
increase your app's overall performance.


It may be you're already doing this, but it wasn't clear from your post.

Much warmth,

planetthoughtful
---
Lost in thought
http://www.planetthoughtful.org

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



Re: [PHP] Mysql Rows

2006-03-03 Thread Murray @ PlanetThoughtful

On 4/03/2006 2:49 PM, benifactor wrote:

thank you. the table does have and id feild that auto increments, however if
you delete a user there will be a gap between the users between which would
not be what is not acurate enough. thank you for you help. simple fix. i
should have caught it.
- Original Message - 
From: Anthony Ettinger [EMAIL PROTECTED]

To: benifactor [EMAIL PROTECTED]
Cc: php php-general@lists.php.net
Sent: Friday, March 03, 2006 3:52 PM
Subject: Re: [PHP] Mysql Rows


define $1 = 0 outside your loop.

i'm curious why you are relying on row-order in the database?
Typically you'd have a PRIMARY KEY auto_increment for something like
this.

  


I have to agree with Anthony - why are you using row order to determine 
something relating to users? I couldn't follow your brief explanation 
above, and the fact that you're doing it sets off some soft alarm bells 
about the design of your application. Why is it important that there 
shouldn't be any 'gaps' between users? Because you want to know how many 
users there are? If so, simply do a SELECT COUNT(*) on the table 
whenever / wherever you need to know.


If you're using it for IDs for the users, it's generally a bad idea to 
reuse this type of information. If you have some other purpose, I'm 
extremely curious about what it might be.


Much warmth,

planetthoughtful
---
Lost in thought
http://www.planetthoughtful.org

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



Re: [PHP] Mysql Rows

2006-03-03 Thread Murray @ PlanetThoughtful



I have to agree with Anthony - why are you using row order to determine
something relating to users? I couldn't follow your brief explanation
above, and the fact that you're doing it sets off some soft alarm bells
about the design of your application. Why is it important that there
shouldn't be any 'gaps' between users? Because you want to know how many
users there are? If so, simply do a SELECT COUNT(*) on the table
whenever / wherever you need to know.

If you're using it for IDs for the users, it's generally a bad idea to
reuse this type of information. If you have some other purpose, I'm
extremely curious about what it might be.




What I was getting at is you get the unique id for the username (if
you allow username changes, then you want a unique key to do your
joins on from other tables).

  


Yep, that's one good reason among many for using unique ids. Thinking a 
little about the OP's question, I could understand row order being 
relevant in certain situations where you wanted to display something 
like, You were the 432nd person to register at our site!, etc.


But, too often I've seen people new to database design not liking 'gaps' 
because 'user1' will have a unique id of '1', while 'user2' will have a 
unique id of '6' because the records associated with unique ids '2' 
through '5' were deleted during testing, and so on. So, they feel that 
'user2' should have a unique id of '2', ignoring the fact that that's 
not a unique id at all, if you had id '2' associated with another record 
at some point.


I'm not suggesting this is what the OP is doing, just that that's why I 
was curious about the purpose.


Much warmth,

planetthoughtful
---
Lost in thought
http://www.planetthoughtful.org

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



Re: [PHP] Mysql Rows

2006-03-03 Thread Murray @ PlanetThoughtful

On 4/03/2006 5:36 PM, Anthony Ettinger wrote:



Yep, that's one good reason among many for using unique ids.
Thinking a
little about the OP's question, I could understand row order being
relevant in certain situations where you wanted to display something
like, You were the 432nd person to register at our site!, etc.



I'd do this with a timestamp, and then sorting by date and doing a 
count() on the results. But then again that's just me. I remember the 
days where i'd clear a database after testing to keep the 
auto_increment inline, but eventually, you will get out of sync on 
that, so it's not a reliable way of keeping a numerical sequence.


Right, or you could just as easily do the same sort and WHERE clause by 
your unique id, but even just doing a count, you're interested in the 
fact that the record is at position whatever in that recordset, so 
'row order' is relevant and, in that context, meaningful.


Much warmth,

planetthoughtful
---
Lost in thought
http://www.planetthoughtful.org

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



Re: [PHP] how to learn php

2006-02-10 Thread Murray @ PlanetThoughtful

On 11/02/2006 10:10 AM, /dev/null wrote:

hello

i have been trying to learn php.

what is the best approach to learning php for someone who has no 
programming experience?


i am very familiar with html, xhtml, and css. i'm not an idiot when it 
comes to using computers.
i have bought several books and have subscribed to a couple of the php 
mailing lists, but i feel that i could be doing more to learn php.


what approach (and steps) did you take in learning this really cool 
scripting language? should i look into taking classes or stick with an 
autodidact approach?


any advice and/or opinions would be greatly appreciated.

thanks.



I honestly believe the best way to learn any programming language, aside 
from perhaps tertiary study (and then only perhaps), is to start out 
with a project and ask the questions you need to solve as you build that 
project.


It should quickly become obvious which things you need to learn, as you 
plan and pursue the project.


Some of those questions might be:

- I need to access data in a database. How do I do that?
- I need to be able to carry data from one page to another, how do I do 
that?
- I need to be able to store 'stuff' at one point in a page (ie, maybe 
data I got from the database) so I can use it again at another point in 
the page.


And so on.

Armed with those questions, you can go through your books, go through 
helpful web sites (don't underestimate the quality of the docs and 
comments on php.net) and ask questions in forums like this one.


Another useful way of picking up knowledge that might not be relevant to 
you right now, but will probably be handy to know later, is reading 
threads in this mailing list. That way you learn about the kinds of 
problems others have encountered, and the suggestions for solving them 
they have received.


Much warmth,

Murray
---
Lost in thought
http://www.planetthoughtful.org

Urban legends, superstitions, ghost
stories and folklore
http://www.ulblog.org

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



[PHP] Redirect from /rss.xml to /rss/rss.xml

2006-02-09 Thread Murray @ PlanetThoughtful

Hi All,

This may turn out to be more of an apache question (but I'm hoping there 
are some apache experts on the list as well), but I'm wondering how I 
would go about automatically redirecting requests for /rss.xml to read 
the contents of /rss/rss.xml instead?


Any help appreciated!

Much warmth,

Murray
---
Lost in thought
http://www.planetthoughtful.org

Urban legends, superstitions, ghost
stories and folklore
http://www.ulblog.org

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



[PHP] Preparing site content for RSS XML feed

2006-02-02 Thread Murray @ PlanetThoughtful

Hi All,

I currently generate a simple rss.xml file for syndication from my site, 
containing nothing more than the subject of the post and a link to the 
article on my site.


I'd like to syndicate the the actual content of each of the posts, but 
as I understand it RSS / XML is somewhat demanding in what it expects of 
how various html entities are treated etc?


I don't suppose, by any chance, that there are any PHP tools that can be 
easily factored in to a process to take content that would include 
normal HTML (ie DIV and SPAN tags, links, TABLEs etc)?


Failing that, does anyone know of a good guide on what steps need to be 
taken to create a valid RSS feed where the content contains HTML?


Any help appreciated!

Much warmth,

Murray

--
Lost in thought :-
http://www.planetthoughtful.org

A blog devoted to urban legends,
superstitions, ghost stories, and
all things folkloric. :-

http://www.ulblog.org

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



[PHP] CR \ LFs being represented as ascii characters in output of mail()

2006-01-31 Thread Murray @ PlanetThoughtful

Hi All,

I'm having an odd problem with formatting of line feeds in an email my 
site automatically sends to me when someone comments on one of my blog 
entries.


For some reason \r\n characters are coming through exactly like that 
in the email, and yet the same value being stored in the backend MySQL 
database seems to represent the carriage-return \ line-feed characters 
as it should.


A typical example of the value when sent in the email would be:

Lol, hi Duncan.\r\n\r\nIt\'s possible that this post once had some comments. I 
lost most of PT at one point when my host had a harddrive crash, and salvaged a 
lot of entries from local copies on my computer, and notes I\'d scribbled in my 
journals and so on.\r\n\r\nStill, it\'s great to see you commenting on the post 
that made you a legend on PT!\r\n\r\nMuch warmth,\r\n\r\nMr Banderas

The odd thing is that the rest of the email is correctly interpreting 
line-feed characters, it's only the value entered on the comment form 
that represents CR \ LFs as normal characters.


I'm not sure if this is the culprit, but because my remote host for this 
site has magic_quotes_gpc on, and my local setup doesn't, I run the 
following function every time a page is requested where form processing 
is performed:


  function traverse ( $arr )
  {
  if ( !is_array ( $arr ) )
  return;

  foreach ( $arr as $key = $val )
  is_array ( $arr[$key] ) ? traverse ( $arr[$key] ) : ( 
$arr[$key] = stripslashes ( $arr[$key] ) );

  }

Can anyone give me any thoughts on how to represent these CR \ LF 
characters properly in the email?


Many thanks,

Murray

--
Lost in thought :-
http://www.planetthoughtful.org

---

A blog devoted to urban legends,
superstitions, ghost stories, and
all things folkloric. :-

http://www.ulblog.org

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



[PHP] date(H, $datevalue) always adds an hour?

2006-01-20 Thread Murray @ PlanetThoughtful

Hi All,

Wondering if anyone can help me work out why date(H) always adds an 
hour? I'm *assuming* it thinks it should be compensating for Daylight 
Saving Time (though I'd be just as willing to believe that it's caused 
by something else), however we don't observe DST in Queensland, Australia.


Making matters a little more complex, while my local machine shouldn't 
be compensating for DST (if that's what's happening), my remote machine 
(based in Florida somewhere, I think) should, when applicable.


So, just to explain a little better.

Let's say the clock on my computer reads 7:00pm. If I do echo 
date(H); it will output 20, instead of 19.


The same thing happens if I take a date value from my mysql database.

$sql = SELECT UNIX_TIMESTAMP(datecreated) AS unx_date FROM mytable;
$rs = mysql_query($sql);
$row = mysql_fetch_object($rs);
echo date(H, $row-unx_date);

If the above record contained the value '2006-01-10 19:00', the code 
would output 20 instead of 19.


Can anyone help me figure out how to accommodate for this?

Much warmth,

Murray

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



Re: [PHP] date(H, $datevalue) always adds an hour?

2006-01-20 Thread Murray @ PlanetThoughtful

On 20/01/2006 8:39 PM, David Grant wrote:

Murray,

What do you get if you print date(T)?

David
  

Hi David,

I get EST, which I assume is Eastern Savings Time? If that's the 
case, any idea where I change this value so that it only affects my 
local machine?


Much warmth,

Murray

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



Re: [PHP] date(H, $datevalue) always adds an hour?

2006-01-20 Thread Murray @ PlanetThoughtful

On 20/01/2006 8:48 PM, David Grant wrote:

Murray,

As far as I know, Queensland is in EST (Eastern Standard Time), so that
is the correct value.  Are you using the same machine or is it remote?

David
  

Hi David,

I'm currently working entirely on my local (Queensland) machine. The 
remote machine only becomes an issue when I'm finished putting the site 
together.


Thanks for giving this some thought...

Murray

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



[PHP] Template engine that doesn't rely on PEAR?

2006-01-15 Thread Murray @ PlanetThoughtful

Hi All,

Can anyone recommend a PHP 4.x compliant template engine that doesn't 
depend on PEAR?


I can't get PEAR to operate properly on my remote host, so I'm looking 
for something that can be dropped in to an existing site and is complete 
in and of itself.


Any recommendations that suit the above would be very welcome!

Much warmth,

Murray

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



Re: [PHP] What software do you use for writing PHP?

2005-12-07 Thread Murray @ PlanetThoughtful

Jim Moseby wrote:

man you guys are wimps.. gvim on windows... :)
  

Pt'Edit' in DOS.  ;)




(Pt * 2)  'edlin' in DOS.  :)


Infinitely recursive pfft A pencil and a piece of paper and 
ringing people to describe the cool web site you've just drawn,


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



Re: [PHP] No forums?

2005-11-08 Thread Murray @ PlanetThoughtful

Richard Davey wrote:


I agree 99% with you, the majority are (excuse my French) utter shite.

*but* the code quality, features and stability of the excellent FUD
Forum thankfully doesn't fall into the camp you describe. While I
don't use it myself, you only need to take a quick look at the code
and who's involved with it to recognise its quality.
 



Hmmm, thank you for mentioning this forum, I wasn't previously aware of 
it. I know phpBB has been criticized previously for behind-the-scenes 
code quality, though it seems like a fairly mature online forum package 
while using it.


Any thoughts on a comparison between the 2?

Much warmth,

Murray

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



[PHP] Line breaks in mail function?

2005-11-06 Thread Murray @ PlanetThoughtful

Hi All,

I'm building a site on a new web host and am currently working on 
feedback forms.


I'm using the mail() function to send the feedback to the destination 
mail account, and I'm having problems getting the body of the email to 
line break.


I've tried constructing the body with both \n\n and \r\n\r\n 
terminating lines where I want line breaks to appear, but both return an 
email with the body in one long string showing the actual \n\n or 
\r\n\r\n characters, as opposed to interpreting them as line breaks.


Example code:

   $body = 'From: ' . $name . '\r\n\r\n';
   $body .= 'Email:' . $email . '\r\n\r\n';
   $body .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . '\r\n\r\n';
   $body .= 'Feedback:\r\n\r\n';
   $body .= $feedback;
   mail([EMAIL PROTECTED], Feedback, $body, From: 
$email\r\nReply-To: $email\r\nX-Mailer: PHP/ . phpversion());


As I said above, I've also tried using \n\n instead of \r\n\r\n.

Can anyone give me some advive on how to get the linebreak characters 
interpreted as linebreaks?


Many thanks and much warmth,

Murray

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



Re: [PHP] Line breaks in mail function?

2005-11-06 Thread Murray @ PlanetThoughtful

Jasper Bryant-Greene wrote:


On Mon, 2005-11-07 at 12:20 +1000, Murray @ PlanetThoughtful wrote:
 


Example code:

   $body = 'From: ' . $name . '\r\n\r\n';
   $body .= 'Email:' . $email . '\r\n\r\n';
   $body .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . '\r\n\r\n';
   $body .= 'Feedback:\r\n\r\n';
   $body .= $feedback;
   mail([EMAIL PROTECTED], Feedback, $body, From: 
$email\r\nReply-To: $email\r\nX-Mailer: PHP/ . phpversion());


As I said above, I've also tried using \n\n instead of \r\n\r\n.

Can anyone give me some advive on how to get the linebreak characters 
interpreted as linebreaks?
   



Use double quotes around the parts that have \r and \n characters if you
want them to be interpreted.

 


Ah, damn you Jasper, I should have noticed that myself.

Don't you hate it when you've been staring at code too long to notice 
the obvious?


Thank you!

Much warmth,

Murray

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



[PHP] Unsubscribing from several PHP lists

2005-11-04 Thread Murray @ PlanetThoughtful

Hi All,

Does anyone know of a way to unsubscribe an email address from the PHP 
email lists when you can't send a reply to the confirmation email?


My host for my currently subscribed email address has an issue with its 
SSL certificate which means that I can't send replies from that account 
(which has gone on for months and I've given up on waiting for it to be 
resolved). For this reason, I'm swapping my subscriptions over to 
another email account through a different host, but of course the reason 
why I'm subscribing from another account is also the reason why I can't 
reply to confirm the unsubscription from the 'broken' account.


Any help appreciated.

Much warmth,

Murray

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



Re: [PHP] Handling competing edits in a wiki engine?

2005-10-04 Thread Murray @ PlanetThoughtful

Terence wrote:




Murray @ PlanetThoughtful wrote:


Hi All,

I've recently been working on building my own wiki engine for my blog
site. While the majority of the engine is complete, a remaining concern
I have is how to handle competing edits (ie when two or more people are
editing the same wiki page simultaneously).

I'm wondering if anyone else on the list has given this some thought?
How would / do you handle competing edits to the same entry in a wiki
application?



We use a combination of locking the record using a simple boolean 
column together with the user id who has locked the item and the 
timestamp.


The locking prevents another user from opening the form  and happily 
editing away without realising his changes will be lost when he 
presses submit. The user id is to inform the second user who has 
opened the document, and the timestemp is so that the first guy doesnt 
open the document and go out for lunch leaving it locked. We default 
it to 5 minutes after which someone else can open the document and 
edit it.


I think I'm going to go with Jasper's suggestion, re: simply 
timestamping the current edit from the preceding version and testing 
that timestamp against the existence of more recent edits and throwing 
back to the user a request to resolve their changes against the now 
'current' version.


I had been thinking about a timed locking strategy (5 minutes seems 
short, though, for content creation, and what do you currently do when 
person A comes back from lunch, person B has made an edit in the same 
entry after person A's lock timed out, and person A commits their now 
aged edit? Do you basically throw an error anyway, and ask person A to 
resolve?), and perhaps implementing a simple javascript countdown on the 
page to alert the person editing the page when time for their edit is 
running out, but in all honesty I think throwing back the error, and 
perhaps presenting a diff of the newer version of the entry, and the 
version the user has edited, might be the way to go.


Either way, gives me plenty to think about.

Out of curiosity, does anyone know if it's possible to tell whether an 
individual session is still alive from PHP? I don't mean from within 
code being run for a particular user, but in code that, for example, 
might be executed by a cron job, which would examine a table in which 
session ids have been recorded automatically for each visitor, and 
determining which of those sessions are still theoretically alive? I 
suspect this isn't possible, but I've also learned to never 
underestimate the ingenuity of those faced with things that aren't possible.


Much warmth,

Murrray @ PlanetThoughftul
---
A man, a canoe, and a dream to climb Mt Everest...
http://www.planetthoughtful.org

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



[PHP] Handling competing edits in a wiki engine?

2005-10-03 Thread Murray @ PlanetThoughtful

Hi All,

I've recently been working on building my own wiki engine for my blog
site. While the majority of the engine is complete, a remaining concern
I have is how to handle competing edits (ie when two or more people are
editing the same wiki page simultaneously).

I'm wondering if anyone else on the list has given this some thought?
How would / do you handle competing edits to the same entry in a wiki
application?

Just to add a little extra information: all 'edits' are in fact
'inserts'. Entries are stored in a mysql table. The engine simply
displays the most recent record for the entry being viewed. This is, of
course, to allow for retrieval of an historical version of the entry
should one or more entries be vandalized.

Much warmth,

Murrray @ PlanetThoughftul
---
A man, a canoe, and a dream to climb Mt Everest...
http://www.planetthoughtful.org

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



RE: [PHP] Regex Help

2005-09-28 Thread Murray @ PlanetThoughtful
 Hi, folks.   I'm having trouble with a simple regex.  I'm sure it's just
 something small that I'm missing but nothing I'm trying is working.
 
 In an HTML file I have comments like this:
 
 !-- START PRINT --
 various html crap here
 !-- END PRINT --
 
 Here's the regex I'm using:
 
 /!-- START PRINT --(.*?)!-- END PRINT --/
 
 And then the call to preg_match_all():
 
 preg_match_all($printable_reg, $str, $out);
 
 It's been quite a while since I've worked with regular expressions so
 I'm not sure what the problem is.  The regex isn't throwing errors, it's
 just not matching the content located between the start print and end
 print comments.
 
 Can anyone lend a hand or give some advice?

Hi Pablo,

At a (reasonable) guess, I'd say it's because you're not using the s
pattern modifier in your preg_match_all()? The s modifier forces your
regular expression to match new lines with the . metacharacter.

Try:

preg_match_all(/!-- START PRINT --(.*?)!-- END PRINT --/s, $str,
$out);

http://php.planetmirror.com/manual/en/reference.pcre.pattern.modifiers.php

Hope this helps.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] serialize

2005-09-26 Thread Murray @ PlanetThoughtful
 murray...
 
 it may have been helpful to the guy to also give him an idea of your tbl
 structure. i think you're talking about something like:
  tbl schema
 
 EvalTBL
-id
-UserID
-ScoreTypeID
 
 ScoreTBL
-id
-ScoreType
 
 table ScoreType could/would have as many different categorites as
 required.
 table EvalType would have a scoreTypeID (from the ScoreTBL) for each
 userID.
 each user could have multiple scoreTypes in the EvalTBL...

Hi bruce,

That would have been an even more normalized representation of the table(s),
yes.

For the purposes of demonstrating a state of normalization that still
allowed the OP to maintain a single table, my structure in that post was:

Scores
-ScoredThingID
-scoretype
-score

I would personally have implemented a structure similar to the one you
outlined, but posted with the idea of first things first. That's why I
included a link to a tutorial on normalization and suggested Googling on the
topic as well, for further reading.

Still and all, it's helpful of you to clarify.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] PCRE false match with preg_match?

2005-09-26 Thread Murray @ PlanetThoughtful
 I recently encountered a strange behaviour, could someone please
 countercheck it, to either tell me there is an error in my pattern?
 
 I have a test string: 7005-N/52
 I have two match patterns:a) /([0-9]*)\/(.*)/i
   b) /([0-9]*)\-(.*)/i
 I check the test string with the help of preg_match, and they both
 matched, but normally variant a) shouldn't have matched.
 
 Normally I test my patterns with the tool The Regex Coach, and
 according to this tool it shouldn't have matched.
 PHP version is 5.0.4, PCRE extension version is 4.5 01-December-2003

Hi Jens

Your first pattern 'matches' because it finds a hit on the /52 component
of your test string.

If you look at the pattern itself, it's because you're using the
'zero-or-more-occurrences' quantifier (ie *) in the first part of your
pattern: ([0-9]*).

It's a valid hit, because there are zero incidences of numeric characters
immediately prior to the /52 component of the test string.

Changing the * to a + (at least one or more occurrences) could 'fix'
that pattern (ie so that it doesn't match your string), depending on any
other values being tested by it.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] serialize

2005-09-26 Thread Murray @ PlanetThoughtful
 Sent this to [EMAIL PROTECTED] but forgot to copy php-general...
 heh. Here it is again.
 
 I would use a table such as
 Table
  |_UserData
 
 Then use objects per user to store the data.
 class User {
   var TestScore;
   var ScoreType;
   ...
   var Vars;
   function __construct($TestScore, $ScoreType) {
 $this-TestScore = $TestScore;
 $this-ScoreType = $ScoreType;
   }
   function __sleep() {
   $this-Vars = get_object_variables($this);
  }
  ...
  function ListVars() {
 $MyString = ;
 ForEach($this-Vars as $key = $value) {
   $MyString .= ${key}: ${value}\n;
 }
 Return $MyString;
 }
 }
 $Joe = new User(WhateverScore, WhateverType);
 $sJoe = Serialize($Joe);
 ...Store it...
 
 
 ...Recall it...
 (Variable result = recieved serialized version of $Joe)
 $Joe = unserialize($Result);
 $Results = $Joe-ListVars();

Hi Jake,

I guess this comes down to preference, but I personally simply couldn't
bring myself to store serialized objects in a table in the way you're
describing.

A well-designed database should not only be normalized, but should also be
agnostic of the technology being used to access it.

I don't know enough about whether or not serialize() is a widely implemented
language construct, but I have worked on enough projects where someone in
management has said, Hey, I know you've done all this work in PHP (or
insert language here), but we've decided we want to rework it in (insert
other language which someone read a glowing article about on some website)
to shudder at the thought of storing data in a database that perhaps only
one language can access.

It also implies more coding to perform relatively simple recordset
operations such as give me the average of 'score12' across all things being
scored, etc. Lastly, it locks your DBA (assuming you have one) out of being
able to perform granular updates should the need arise. It's for pretty much
the same reason that I hide under my desk, whimpering, when someone
inevitably suggests storing XML recordsets as XML documents in database
fields.

So, full marks for fully exploiting the potential of objects, but you'll
have to excuse me while I go make a coffee and maybe go for a brisk walk to
get over the case of heebie-jeebies this suggestion gave me. ;-)

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] Optimal Regex?

2005-09-26 Thread Murray @ PlanetThoughtful
 I need to catch all instances of a coordinate in a give string. So far I
 have this, which only works if the coordinate is in a certain format.
 
 
 $string = (334,-53.44),(111,222);
 $expression = '([(][-]?[0-9]*[.0-9]*?,[-]?[0-9]*[.0-9]*?[)])';
 preg_match_all($expression, $string, $matches);
 
 This returns the correct strings (334,-53.44) and (111,222), but I'd like
 all formats to work. Like (111, 222), ( 111 , 222 ), (111, 222 ), etc,
 etc.
 How would I change my regex to accomplish this?

Hi David,

Someone else may have a more direct answer (ie a tweak of your regex that
accounts for the possibilities that you've mentioned) but looking at your
email I immediately had a concern over etc, etc.

Regular expressions rely very much on you being able to predict the
different possible cases you will be dealing with.

Looking at the examples you provided, it looks like you're (currently?)
concerned with anomalous spaces in your string.

A simple way of dealing with these would be to do:

$string = str_replace( , , $string);

...before you attempt your regex match. This will remove all spaces from the
string, making it fit a more predictable pattern (one that your current
regex matches).

If, however, there are other possible anomalous characters you need to take
into account, it would be much more helpful if you could supply examples of
them.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] Optimal Regex?

2005-09-26 Thread Murray @ PlanetThoughtful

 Wow, that definitely works. I would sort of like to know how to tweak the
regex, but maybe this is the best way of doing it. Is [0-9]*[.0-9]*? the
best way of looking for a number with decimals?

Hi David,

Just to answer this question, I would probably use something like the
following pattern to match a number with optional decimals:

-?([\d]+)?(\.[\d]+)?

In and of itself, the pattern you have above will only match numeric digits.
So, with a string of 23.99, it would match the 23 and the 99 as
separate matches. Basically this happens because you have the 'lazy'
quantifier (ie ?) after the zero-or-more-occurrences quantifier (*), and
the laziest iteration of [.0-9]*? is to match nothing.

A small improvement can be made by putting () around the [.0-9]* part of the
pattern, thus: ([.0-9]*)?

This now becomes the optional quantifier, indicating that the pattern
between () can be matched *if it exists*.

This still isn't perfect, however, since the modified [0-9]*([.0-9]*)?
will not only match a number like 29.33 in it's entirety, it will also
match 129..3..57 in its entirety. This is because you include the period
(.) within the character class, so it can be matched zero-or-more times as
well as the digits. Moving the period (.) outside the character class so
that the regex only attempts to find an optional single instance of it
between two sets of numbers (where the second set of numbers is also
optional) makes another improvement.

[0-9]*(\.[0-9]*)?

Note that I've escaped the period, because otherwise it would be interpreted
as meaning any single character.

This should now work pretty much as you expect it to.

My version adds the ability to match both positive and negative numbers with
decimals. It also uses the shorthand character class for numeric digits
(\d).

Hope this is of some help.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] serialize

2005-09-25 Thread Murray @ PlanetThoughtful
 I have an app that stores evaluation scores so I have 30+ values all
 within a certain range, currently in the db, each of these values has
 it's own column:
 
 Table test
id
user_id
motivation
caring
personal_characteristics
creativity,
...etc.
 
 If the client decides they want to trap more characteristics, it
 requires changes to the table structure and the table quickly gets
 large with 30+ columns.  I was thinking of just compacting all of
 these down to one column and then using serialize/unserialize and
 storing an array of the test scoresis this the best way??

Hi,

This has less to do with PHP (though it will impact on your code) and more
to do with database design principles.

From what you describe, you have a denormalized table. Ie, every score value
has its own field for each thing being scored:

Id, score1, score2, score3, score4..., score30

, 23, 18, 12, 36, 38
1112, 45, 12, 62, 25, 73

A more normalized representation of that table would be:

Id, scoretype, score

, 'score1', 23
, 'score2', 18
, 'score3', 12
, 'score4', 36

, 'score30', 38
1112, 'score1', 45
1112, 'score2', 12
1112, 'score3', 62
1112, 'score4', 25

1112, 'score30', 73

Adding a new score type for each id is then as simple as inserting rows for
the ids with a new 'scoretype' value, meaning that no change of the actual
table structure is required.

To retrieve the scores for any given id in your PHP code, you'd do something
like:

$sql = SELECT scoretype, score FROM scores WHERE id=;
$rs = mysql_query($sql);
while ($row = mysql_fetch_object($rs)){
$scores[$row-scoretype] = $row-score;
}
mysql_free_result($rs);
print_r($scores);

It might be helpful to you to Google on the topic of database normalization.

Here's a link from the MySQL site that gives a brief introduction to the
topic.

http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html

Hope this helps.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] basic user/input form questions... more validation!

2005-09-22 Thread Murray @ PlanetThoughtful


 -Original Message-
 From: bruce [mailto:[EMAIL PROTECTED]
 Sent: Friday, 23 September 2005 10:23 AM
 To: 'Jasper Bryant-Greene'; php-general@lists.php.net
 Subject: RE: [PHP] basic user/input form questions... more validation!
 
 one more question/issue...
 
 the mysql_real_escape function escapes with a'\' which works for mysql,
 but isn't standard ansi... is there another function that does the same
 thing, but uses the ansi standard '. also, if there is another function,
 does it also work with mysql??

The important thing here is that escaping with a \ is MySQL's standard for
escaping, so should be used when using MySQL as your storage backend.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org



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



RE: [PHP] Re: email validation (no regex)

2005-09-21 Thread Murray @ PlanetThoughtful
What you have is virtually impossible to determine if all legitimate
 possibilities are covered.
email validation using regex is a very heavily analyzed subject
Google regex email validate and you'll find loads of expressions.
 Look at the Zend article, it provides some insight.
 
 I fully understand about the almost limitless possibilities. Googling the
 subject returns results more mind boggling than the regex itself.  :o)  Do
 ANY of the regex examples you have found cover all those possibilities?
 If
 so, why are there so many different approaches?  For most applications,
 where you will only be validating a small number of emails in a given day,
 why put yourself to all the regex pain, still to not have covered all the
 possibilities?
 
 In the end, with regards to email validation, all most people need is to
 know that a given email has a proper username, just 1 '@' in the middle,
 and
 a valid domain.  If it doesn't, its a bogus email address.

As to that, why not validate the email address by sending an automated
message to the supplied account, requiring the person to click on a
validation link? Easy, simple, works better than either method currently
being discussed, purely for its simplicity, if nothing else.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] Re: email validation (no regex)

2005-09-21 Thread Murray @ PlanetThoughtful
 because you should want/need to validate that the address is correct prior
 to determining if the email server is up running...
 
 the regex function simply allows you to quickly determine if the address
 is
 valid... doens't mean that it's going to go to an actual live user...!!
 
 btw simply checking for a single '@' with a domain doesn't do it... what
 if
 the user has '[EMAIL PROTECTED]' or '[EMAIL PROTECTED]'. will your regex 
 accept/deny
 this???
 
 welcome to the world of email validation
 
 -bruce
 
 As to that, why not validate the email address by sending an automated
 message to the supplied account, requiring the person to click on a
 validation link? Easy, simple, works better than either method currently
 being discussed, purely for its simplicity, if nothing else.

I agree, so basic validation is A Good Thing. However, the most desirable
form of validation would have to be, can I send a legitimate email to that
account and receive acknowledgement that it's working by having the user
click on a validation link.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] Re: email validation (no regex)

2005-09-21 Thread Murray @ PlanetThoughtful
  because you should want/need to validate that the address is correct
 prior
  to determining if the email server is up running...
 
  the regex function simply allows you to quickly determine if the address
  is
  valid... doens't mean that it's going to go to an actual live user...!!
 
  btw simply checking for a single '@' with a domain doesn't do it... what
  if
  the user has '[EMAIL PROTECTED]' or '[EMAIL PROTECTED]'. will your regex
 accept/deny
  this???
 
  welcome to the world of email validation
 
  -bruce
 
  As to that, why not validate the email address by sending an automated
  message to the supplied account, requiring the person to click on a
  validation link? Easy, simple, works better than either method currently
  being discussed, purely for its simplicity, if nothing else.
 
 I agree, so basic validation is A Good Thing. However, the most desirable
 form of validation would have to be, can I send a legitimate email to that
 account and receive acknowledgement that it's working by having the user
 click on a validation link.

After all, for all the regex / interrogation you perform, you still can't be
certain that the user entered an account *they own*. See? Sending a
validation email is *also* A Good Thing!

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] Re: Suggestions for class design

2005-09-20 Thread Murray @ PlanetThoughtful
 on 09/19/2005 02:33 PM Chris W. Parker said the following:
  Let's take for example a class called 'Customer' that (obviously)
  manipulates customers in the database. Here is a very basic Customer
  class. (Data validation and the like are left out for brevity.)
 
 This is a basic object persistence problem.
 
 
  (Unless I've already got some major design flaws I think we should be
  good to go.)
  
   Where I get tripped up is when I realize I'll need to at some point
   get more than one customer at a time and thus I want to add a method
   called 'get_customers()'.
 
 
 Yes, there is a problem. You are trying to retrieve objects into memory
 before they exist. It makes more sense that you retrieve objects using a
 factory class.
 
 That is the approach of Metastorage. You may want to take a looka at
 Metastorage before you reinvent the wheel.

Hi Manuel,

I very much understand your desire to promote your various projects, but the
original poster is asking a question that is basic to any programmer's
development in object-oriented coding.

Once he understands how to solve class abstraction problems such as the one
he is asking about, he will be better equipped to deal with a wider range of
application development tasks.

This is not to trivialize your Metastorage project (or, to be more accurate,
I know nothing about it, so it's not my place to trivialize it or
otherwise), but to point out that 'out-of-the-box' solutions to fundamental
coding development problems probably ultimately makes for a poorer
programmer. I could well be wrong, but it seems this is a case of give a
man a fish as opposed to teach a man to fish.

Also, and separate from above, I don't understand the relevance of your
comment, You are trying to retrieve objects into memory before they exist.
Unless I'm horribly mistaken [1], the original poster has developed a class
that abstracts a single customer, and is asking the list for suggestions in
how to best approach a need to be able to abstract collections of customers.
This is a normal application development issue, and for the life of me I
can't grasp how your comment relates.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

[1] And it wouldn't be the first time!

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



RE: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Murray @ PlanetThoughtful
 Jochem Maas wrote:
  Michael Sims wrote:
  So, as far as foo() knows:
 
  foo($a = 5);
  and
  foo(5);
 
  are exactly the same...
 
  I don't think they are, and you're examples don't prove it.
  Anyone care to come up with the proof.
 
 No, I was wrong, Rasmus corrected me.  That's my one allowed mistake for
 the day.  I promise to wait until tomorrow before making another one. ;)

Who was it that said, If you find that you only made one mistake today, you
weren't looking hard enough?

Oh, that's right, it was me. ;)

Off to make more mistakes...

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] Re: Suggestions for class design

2005-09-20 Thread Murray @ PlanetThoughtful
[snippage]

 I do not understand why this could bother you or anybody else. If you
 have a better solution, nothing stops you to make your recommendations.

Hi Manuel,

I did make my recommendation. To you. It went something like (and I'm
paraphrasing), Your proposed solution doesn't solve the original poster's
conceptual problem with abstracting classes that deal with collections of
objects in conjunction with classes that abstract single objects.

In other words, and I realize I'm stretching out on a limb with this
metaphor, I saw in your post an attempt to treat the symptoms without
offering a cure for the disease.

Actually, that really is a terrible metaphor. I'm certain I'll think of a
better one about 3 seconds after I hit 'send'. Isn't that always the way?

And your perception of bias may or may not be accurate. I don't recall
delivering wrath-of-god denunciation of your suggestion to use a project you
developed, just acknowledged a desire to promote a project you're probably
(and perhaps justifiably) proud of. You say that wasn't a component of your
recommendation. I'm willing to accept that, not that I expect you to be
losing any sleep over whether or not I believe you.

This is a reality of expressing opinions on a public list: others are free
to disagree with you. See Michael Sims' response to the same post you're
addressing here. He makes some great points and I for one am glad he had an
opportunity to make them in response and counterpoint to a post I made. His
thoughts enrich the list, as do yours, and as, I hope, do mine.

  This is not to trivialize your Metastorage project (or, to be more
 accurate,
  I know nothing about it, so it's not my place to trivialize it or
  otherwise), but to point out that 'out-of-the-box' solutions to
 fundamental
  coding development problems probably ultimately makes for a poorer
  programmer. I could well be wrong, but it seems this is a case of give
 a
  man a fish as opposed to teach a man to fish.
 
 I think you should have learned about Metastorage first before
 commenting. It is not really a out-of-the-box solution. It is a code
 generator tool that employs well known design patterns to generate code
 to customized to the developer needs.

At some point I just may do that. It's an interesting concept, if nothing
else. My comments remain relevant, however, regardless of my knowledge of
your project. At least, and this is important, that's my opinion.

  Also, and separate from above, I don't understand the relevance of your
  comment, You are trying to retrieve objects into memory before they
 exist.
  Unless I'm horribly mistaken [1], the original poster has developed a
 class
  that abstracts a single customer, and is asking the list for suggestions
 in
  how to best approach a need to be able to abstract collections of
 customers.
  This is a normal application development issue, and for the life of me I
  can't grasp how your comment relates.
 
 I tried to explain in the part of the message that you did not quote,
 why using a factory class as entry point, which is my suggestion, it
 makes more sense.

Thank you for the extra explanation. I still don't understand the comment's
relevancy to the actual question being asked by the original poster, but I
will explain, in case it's of interest, why that comment caused me some
confusion:

- The original poster outlined that he had created a class that represented
a customer.

- He told the list he was having difficulties with the concept of
abstracting a collection of customers

- He received some helpful suggestions from the list about how to approach
that task

- None of which would have meant he was 'trying to retrieve objects into
memory before they exist.' I don't know about anyone else, but what that
comment implied to me was that the original poster was attempting to
instantiate a class as an object before including the file that contained
the class definition.

I may well have misunderstood what you meant by your comment, but it still
stands out as not being relevant to the problem the original poster was
describing.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] Re: Suggestions for class design

2005-09-20 Thread Murray @ PlanetThoughtful
 happened to be working on.  That meant they were closer to the problem,
 had
 more experience with it, and were willing to do more to solve it more
 fully
 and generally than I was.

Again we go back to my original point. You were at a different stage of your
development as a PHP OO programmer when you began using Propel than the
original poster. You understood (or at least, I infer from what you write
above that you understood) the fundamentals of classes and how to abstract
objects with them.

Let's tackle the situation from a different perspective. Remove from the
scenario the specific question the poster was asking: how do I get at / use
/ manipulate my data? Look at the general problem he is facing: I have an
object that represents a thing, but I also need to be able to deal with
collections of that object, because I have a need to deal with multiples of
that thing, and I don't know how to do that.

Suggesting implementing a package such as Metastorage (again, don't know
anything about it) or Propel (still don't know anything about it) probably
addresses the surface issue. But it ignores a fundamental step a programmer
should take in learning OO programming.

And it's also worth mentioning at this point that it might present more of a
challenge to the original poster to implement and make use of a complex data
abstraction package [1] than to learn a solution that not only addresses his
specific question but also helps in his learning as a programmer.

 So
 let me amend my recommendation by saying check out Propel/Metastorage if
 you're willing to actually study the approach it takes as opposed to
 simply
 plugging it in. :)

Not a bad compromise at all. I'd amend it further by saying, Here's how to
understand the concept you're having difficulty with, and *then*...

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

[1] Particularly since I *assume* both examples mentioned make heavy use of
classes and class methods, which is exactly what the original poster is
currently seeking help to understand at a fairly basic level

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



RE: [PHP] html forms in php

2005-09-15 Thread Murray @ PlanetThoughtful
 Good day all,
 
 I have a problem for you all..
 I have a form that has has the ability to delete a lot of information from
 my MySQL database.
 
 I would like to create a bit of security, in case the user hits the button
 by accident.
 I would like to create an additionnal window that would appear that would
 ask:
 Are you sure? and then a yes and no buttons to confirm the deletion
 or
 to cancel the command.
 
 Any thougts??

Hi Phil,

You can achieve this in several ways. One would be to use a JavaScript
onClick event on the 'dangerous' button to pop up a dialog with your 'Are
you sure?' prompt and the yes/no buttons. If the user clicks on the 'no'
button, you use JavaScript to cancel the page submission. If they click on
the 'yes' button, the page submits. This approach would mean assuming that
your users have JavaScript enabled.

A second approach would be to have an intermediary page between the page
with the button, and the page that performs the actual delete. The
intermediary page would be little more than another form with the yes/no
buttons.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] Modifying data in forms with values

2005-09-13 Thread Murray @ PlanetThoughtful
 I have to create registration forms all the time for people in the office
 and
 what I keep running into is that I need a way for when they edit a field
 that
 the drop-down list of choices is automatically set for the right now.
 
 I have 100+ counties in one list, but I don't want to write 100+ if
 statements
 for checking to see if the value of $county equals the value of the field
 I am
 drop down choice.
 
 Anyone have some quick solutions?
 
 I have radio buttons as well, but going to use a drop-down list for the
 editing
 pages to make it all simple.

Hi Robert,

As a suggestion, why not put your counties in an array (are you taking them
from a recordset? If so, same idea applies) and use foreach() to iterate
through the array, building the select list. When $county equals the current
value of the array, include  SELECTED in the select HTML you are building.
One if statement should handle the situation nicely.

Much warmth,

Murray @ PlanetThoughtful
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] error message while mysqling on php

2005-09-13 Thread Murray @ PlanetThoughtful
 I have received an error: Warning: mysql_num_rows(): supplied argument is
 not a valid MySQL result resource in /home/www/mksystem.net when trying to
 execute $num = mysql_num_rows($result);
 
 Please go to http://mksystem.net/phpinfo.php and tell me whether it is due
 to the version of php I have on server and an easy workaround would be
 appreciated.

Check the syntax of your SQL statement, it's very possible you have an error
in it somewhere. If you have PHPMyAdmin, or some other interface to MySQL
such as MySQL Query Browser, etc, try executing the SQL statement in one of
them directly, to see if they return a valid resultset.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] setting 'expiry date'

2005-09-12 Thread Murray @ PlanetThoughtful
 I have a php/mysql database with articles. What I need is a php sctipt
 that
 will compare the current day with the 'expiry date' entered by the user
 and
 if the there is a difference then drop it from the database..
 
 I retrieve the date (called time and format it like this...
 
 $query= SELECT DATE_FORMAT(time, '%d.%m.%Y') AS time, article, id FROM
 news
 ORDER BY id DESC;
 
 
 The expiry date is entered through a javascript widget and is in the
 format
 dd/mm/.

Hi Ross,

Is there a real reason for deleting the articles? Why not only display
articles where the current date/time is less than the expiration date/time?

Once the current date/time is greater than the expiration date/time, stop
displaying the article.

Same effect as far as your users are concerned, and you're not faced with
the frustration of, 'I need a copy of that article from 12 months ago!'

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] Opinion Request - No PHP content - Versioning Systems

2005-09-12 Thread Murray @ PlanetThoughtful
 
 Hey, I'm about to implement a versioning system here, and was going to
 go with CVS, but being that I haven't used it in almost two years I was
 wondering what y'all think?  Opinions on the best, user-friendly (Mac
 Geeks will be using it), etc?  Thanks.
 

Hi John,

I only have experience with CVS and Subversion, but of the two, I *much*
prefer Subversion. Could be a purely subjective thing, but it's worth
looking into all the same.

http://subversion.tigris.org/

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] searching through a mysql db/tbl

2005-09-10 Thread Murray @ PlanetThoughtful
 hi...
 
 i'm trying to figure out how to approach/solve a few issues. looking
 through
 google hasn't made the light shine!!
 
 1) i'm trying to figure out how to allow a user to search through a
 query/tbl for a given string. ie, if i have the following as the result of
 a
 query:
 
   name   email   foo...
   aa [EMAIL PROTECTED] 
   b1 [EMAIL PROTECTED]123
   bb [EMAIL PROTECTED]qwe
 
 
 if i allow a user to search on say 'aa', i'd like the user to be able to
 get:
 
   name   email   foo...
   aa [EMAIL PROTECTED] 
   b1 [EMAIL PROTECTED]123
 
 any ideas as to how i could go about and create the query, or what would i
 need to do to have this result...

Hi,

Basically what you need to do is dynamically create the WHERE clause of your
query string.

In the example above, the WHERE clause might look something like:

$qry = SELECT * FROM table WHERE name LIKE '%$searchterm%' OR email LIKE
'%$searchterm%';

If you want to span the search across more fields, simply add them as extra
OR elements to the WHERE clause. 


 
 2) if i have a query that produces a number of rows, how/what would i need
 to do, to limit the number of rows displayed, and to allow the user to
 select a 'back/next' button that would generate/display the next 'N' items
 in the list/query results...
 
 if anybody could direct me to sample docs/code that kind of
 describes/solves
 what i've described, i'd appreciate it!!!

Here I'm making the assumption that you're using MySQL. If that's the case,
you need to familiarize yourself with the LIMIT clause. This allows you to
specify a starting point and number of rows to return for the resultset.

So, using the query above again:

$qry = SELECT * FROM table WHERE name LIKE '%$searchterm%' OR email LIKE
'%$searchterm%' LIMIT 0,10;

...will return the first 10 results from your query (records 0 to 9). Note
that the 'first' row is at position 0 in the recordset. Also note: if there
are less than 10 records returned by your query (ie in your example, only 2
match your pseudo request), only those records will be returned.

Then, issuing:

$qry = SELECT * FROM table WHERE name LIKE '%$searchterm%' OR email LIKE
'%$searchterm%' LIMIT 9,10;

...will return the next 10 results from your query (records 10 to 19), and
so on.

This requires you to pass some variables from one search result page to the
next, particularly the variable that indicates where the 'next' results
should begin, allowing you to factor that in when building the LIMIT clause
of the query string for the search results that should be displayed on that
page.

A Google search on PHP pagination or PHP paginate should return a number
of online resources explaining how to paginate results returned from a db
query in PHP.

Hope this helps.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] RE: PHP wiki recommendations

2005-09-09 Thread Murray @ PlanetThoughtful
  I'm not a Wiki expert, but have been using TikiWiki for a while and
 very much like it.  It does everything you say with the possible
 exception of CSS.  It may very well support CSS, I just don't need it so
 haven't investigated.  It also allows for the use of templates that can
 be applied globally or by each user (these may be the CSS bit, again, I
 just haven't played).
 
 User logins can be pre-assigned or user driven so you can control who
 does what.
 
 I think you can turn on/off the CamelCase feature.
 
 Doug
 
 
 -Original Message-
 From: Murray @ PlanetThoughtful [mailto:[EMAIL PROTECTED]
 Sent: Thursday, September 08, 2005 2:03 AM
 To: php-general@lists.php.net
 Subject: PHP wiki recommendations
 
 Hi All,
 
 I want to add a wiki to my blog site to help create a knowledgebase of
 the characters, localities, stories I write to make it easier for new
 visitors to delve into the areas that interest them.
 
 I've been experimenting with a couple of different wiki packages, but am
 always interested in others' thoughts and recommendations.
 
 In particular, I've looked at MediaWiki and PmWiki. Of the two, I like
 MediaWiki's 'completeness', but it's also quite slow and doesn't strike
 me as being particularly (or easily?) customizable. PmWiki is probably
 my current candidate, but again I'd like to make sure I'm not missing a
 more obvious choice.
 
 My shopping list for the ideal wiki application is:
 
 - wiki entries preferably stored in MySQL tables. I'm not adamant about
 this (eg PmWiki uses files rather than a db backend), but it would suit
 my purposes better to be able to draw from the wiki tables from the
 front page of my blog to show lists of recently added and recently
 updated wiki entries
 
 - non-reliance on CamelCase wiki links. Many of my characters etc use
 joined CamelCase names (eg KillFork and DangerSpoon), and to avoid
 confusion I'd rather explicitly define links to wiki content
 
 - ability to categorize wiki entries
 
 - ability to compare history of wiki edits and easily reinstate older
 edits if wiki pages get 'graffiti'd'
 
 - ability to allow others to edit / create wiki entries, thru a user id
 / password system, so that regulars who would like to participate can do
 so
 
 - ability to customize presentation of wiki pages, presumably through
 CSS etc, so that I can maintain the 'look and feel' of my blog thru the
 wiki content
 
 - PHP based, though my host does run Perl, so if the killer wiki app is
 a Perl-based one, I'm sure I can muddle thru implementing it
 
 If anyone has any recommendations for other wiki applications I should
 look at before making a decision, I'd love to hear from you!

Hi Doug,

Thanks for the recommendation -- I did take a brief glance at TikiWiki, but
my original impression was that it was too CMS-heavy for my needs.

Given your recommendation, though, I'll take another look at it, and will
probably download it and play around with it on my local machine.

If anyone else has any other recommendations, I'm still very open to
suggestions!

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



[PHP] PHP wiki recommendations

2005-09-08 Thread Murray @ PlanetThoughtful
Hi All,

I want to add a wiki to my blog site to help create a knowledgebase of the
characters, localities, stories I write to make it easier for new visitors
to delve into the areas that interest them.

I've been experimenting with a couple of different wiki packages, but am
always interested in others' thoughts and recommendations.

In particular, I've looked at MediaWiki and PmWiki. Of the two, I like
MediaWiki's 'completeness', but it's also quite slow and doesn't strike me
as being particularly (or easily?) customizable. PmWiki is probably my
current candidate, but again I'd like to make sure I'm not missing a more
obvious choice.

My shopping list for the ideal wiki application is:

- wiki entries preferably stored in MySQL tables. I'm not adamant about this
(eg PmWiki uses files rather than a db backend), but it would suit my
purposes better to be able to draw from the wiki tables from the front page
of my blog to show lists of recently added and recently updated wiki entries

- non-reliance on CamelCase wiki links. Many of my characters etc use joined
CamelCase names (eg KillFork and DangerSpoon), and to avoid confusion I'd
rather explicitly define links to wiki content

- ability to categorize wiki entries

- ability to compare history of wiki edits and easily reinstate older edits
if wiki pages get 'graffiti'd' 

- ability to allow others to edit / create wiki entries, thru a user id /
password system, so that regulars who would like to participate can do so

- ability to customize presentation of wiki pages, presumably through CSS
etc, so that I can maintain the 'look and feel' of my blog thru the wiki
content

- PHP based, though my host does run Perl, so if the killer wiki app is a
Perl-based one, I'm sure I can muddle thru implementing it

If anyone has any recommendations for other wiki applications I should look
at before making a decision, I'd love to hear from you!

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] Cleaning a resultset

2005-09-08 Thread Murray @ PlanetThoughtful
 Hi,
 
 I have a resultset from a query and need to remove some rows after doing
 some php processing then insert into another table i.e.
 
 /** Get data**/
  $qid = mysql_query('SELECT ...);
 
  /** Clean data **/
  while( $r = mysql_fetch_object( $qid ) ) {
 
  }
 
 How can i generate a new resultset / remove data from the existing
 resultset
 using this method?
 
 Thanks for your help

Hi Shaun,

Basically while iterating thru the resultset in $qid, test / cleans the data
row by row, and perform an INSERT query for each row within your while loop
that you want to be inserted into your other table.

Hope this helps.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org



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



RE: [PHP] regular expression for integer range

2005-09-07 Thread Murray @ PlanetThoughtful
 Hi all,
 
 
 I want to write regular expression for checking the string format entered
 by user.
 
 the allowed formats are
 
 examples:
 10
 10,
 10,12-10
 12-10
 
 that is the valid strings are:
 1. only integer
 2. an integer, range of integers example 3
 
 and no other characters must be allowed.

Hi babu,

As you've pointed out, you have 4 distinct scenarios to deal with, and it
may be very difficult, without a great deal of tuning and tweaking, to
define a regular expression that can effectively match all 4 scenarios
without including false matches as well.

One way of dealing with this is to build more specialized and exact regular
expressions for each possible scenario and group them together in an if
statement.

Eg.

if (preg_match('/^\d+$/',$subject) || preg_match('/^\d+,$/',$subject) ||
preg_match('/^\d+,\d+-\d+$/', $subject) || etc etc){

// code for successful match of valid data in $subject

} else {

// code for invalid data in $subject

}

Basically, the if/else statement is testing each distinct possible pattern
and executing code if any of those distinct possible patterns match.

It may not ultimately be the most graceful way of dealing with the
situation, but having spent many hours attempting to tweak complex regular
expressions looking for the magic combination, I've learned that breaking
scenarios down this way can save a lot of development time and frustration.
This doesn't mean there isn't a benefit to finding the perfect regular
expression for your needs, just that it can often be difficult to guarantee
your code won't be plagued by false matches or false exclusions as your
expression becomes more and more complex.

Hope this helps a little.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



Re: [PHP] php/mysql web question

2005-09-06 Thread Murray @ PlanetThoughtful

 hi...
 
 if an app has a webpage that has to interface/display data from a mysql
 db,
 does the app have to essentially do a new db_connection for each time that
 a
 user accesses the page during the session.
 
 as far as i can tell, it does.
 
 in other words, the page would need to look something like:
 
   ?
 start the page
 do the db_connect
 do the db_query
 process the information from the db/tbl
 close the db_connection
   ?
 
 the only reason i ask is that it would be nice/good if there was some way
 of
 opening a connetion once for a given session (save bandwidth) as well as
 somehow saving data from the db/tbl (short of using session vars)

Hi Bruce,

Basically what you're asking about is persistent connections from PHP to
MySQL, which are performed using mysql_pconnect().

In the pseudo-code outline you have above, you don't need to perform the
'close the db_connection' step. Each time a page loads that has a
mysql_pconnect statement, it will check to see if an existing (or persisted)
connection is available, and will use it instead of creating a new
connection, if one does. If no persisted connection is found to be
available, mysql_pconnect goes ahead and creates the connection, and
persists it for future connection attempts.

Each page should still probably perform the mysql_pconnect function, since
unless you have a very statically defined interaction of pages, you may not
be able to guarantee that a connection already exists when a particular page
is loaded.

Don't forget that while closing the db connection isn't necessary on a
page-by-page basis when using persistent connections, you should still
habitually free recordsets either at the bottom of the page, or at a point
in your code where you know they are no longer needed.

Hope this helps a little.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] Saturdays and Sundays

2005-09-01 Thread Murray @ PlanetThoughtful
 Hi,
 
 Is it possible to get the number of saturdays and sundays for a given
 month
 / year?
 
 Thanks for your help.

Hi Shaun,

Not sure if there's a graceful PHP solution (there probably is, but can't
think of one, myself, right at this moment) but it sounds like what you
might need is a calendar table in your database.

This is a common approach to solving a number of date-related issues, of the
type you're asking about.

A typical structure might be

Recid (int autoincrement)
Date (datetime)
Year (int)
Month (int)
Day (int)
Day_name (varchar)
Month_name (varchar)
Etc..

A record for today's date would then look like:

1, '2005-09-01', 2005, 9, 1, 'Thursday', 'September'

There are a number of other fields you could add, depending on your needs
(financial_quarter, for example, if your site is a business application,
week_num and so on)

You would then write a routine that would populate the table with
appropriate values for any given time period (10 years into the future, for
example) and thus would be able to very simply perform operations like:

SELECT COUNT(*) FROM date_info WHERE year=2005 and month=9 and
(day_name='Saturday' or day_name='Sunday')

Again, there may be a better solution in PHP, but any date-intensive
application would probably benefit from the above approach. In particular,
it becomes very useful when you use the recid value for the date from your
calendar table in application data tables instead of the actual date,
allowing you to perform very flexible queries where you might be interested
in sales results for all the Thursdays in every September for the last 5
years, etc.

Regards,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] conditional statement inside while loop?

2005-09-01 Thread Murray @ PlanetThoughtful
 Hello everyone,
 
 I'm using a while loop to display a list of people contained in my
 database.
 I'd like to assign different font colors to each depending on which city
 they're from, but I can't seem to get an if/elseif/else statement to work
 inside the while loop.  Is there another way to do this?

Hi Zach,

There should be no reason why you can't use if/elseif/else within your while
loop. The fact that you're experiencing problems strongly suggests that you
have a combination of conditionals in your if/elseif/else that is
effectively ignoring the data being returned from your recordset.

It may be something as simple as using = in your if statement instead of
== (ie, so the conditional is always true, because you're using the
assignment = operator instead of the evaluative == operator), or a
combination of conditions, each of which are accurate but which when placed
together cause problems.

To get an idea where your problem is occurring, try going from simple to
complex. Start with something like the following pseudo-code:

while ($row = get_data_from_your_recordset){
if (strlen($row['a_recordset_field'])  0){
echo Data found:  . $row['a_recordset_field'] . br /;
} else {
echo Data not foundbr /;
}
}

The assumption being made above is that you will be using a field from your
recordset that contains data that is ordinarily longer than 0 bytes.

Doing the above will demonstrate that at the very least you are returning a
valid recordset and that conditional statements work within while loops. If
even this fails, then check the SQL that is being used to populate the
recordset, and make sure that you are using the same field names in your PHP
code as is being returned from the table by the recordset.

Once the above is working, add back in your actual conditional(s), one by
one. You're looking for the point where 'working' code becomes 'broken'
code. Most of the time when you debug in this way it becomes obvious why the
code isn't behaving the way you expect it to. If there's still any confusion
at that point, at least you will be in a better position to supply actual
code to the list, so we can work out the real problem.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] (Yet another) I'm blind ... post

2005-08-31 Thread Murray @ PlanetThoughtful
 In this code, I'm not getting the value of $list passed to the Mailman
 page.
 I've checked this umpteen times by now, but fail to see the error. I've
 beaten myself suitably with a steel ruler -- but it didn't help. Nor does
 the cold I'm coming down with I suppose.
 
 Anyone see the error, and feel like pointing it out to me?
 
 Martin S

Hi Martin,

Try checking for the value in $_POST['lista'] on your subscribe page.
Failing that, try the following:

print_r($_POST);

This should give you all the variables and values being sent by the form to
the page being used to process that form.

Hope this helps.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] Problem With Inner Loop

2005-08-30 Thread Murray @ PlanetThoughtful
 Hi,
 
 The following code is attempting to display a list of work types for all
 the
 users in my database. However it only loops through the inner loop once
 and
 I can't work out why, can anyone help here please?
 
 Thanks for your help
 
 table
 ?php
 include('application.php');
 $staff_qid = mysql_query('SELECT
   U.User_ID,
   CONCAT_WS( , U.user_Firstname, U.User_Lastname) AS User_Name
   FROM Users U, Allocations A, Projects P
   WHERE U.User_ID = A.User_ID
   AND A.Project_ID = P.Project_ID
   AND P.Project_ID = 38
   AND (U.User_Type = Staff
OR U.User_Type = Manager
OR U.User_Type = Administrator)
   ORDER By User_Name');
 $work_type_qid = mysql_query('SELECT
Work_Type_ID,
Work_Type
FROM Work_Types
WHERE Project_ID = 38
ORDER BY Day_Type');
 ?
 table
 ?php while( $staff_r = mysql_fetch_object( $staff_qid ) ) { ?
  tr
  ?php while( $work_type_r = mysql_fetch_object( $work_type_qid ) ) { ?
   td?php echo $work_type_r-Work_Type; ?/td
  ?php } ?
  /tr
 ?php } ?
 /table

Hi Shaun,

Looking at your code, it doesn't appear that there's an actual relationship
between your two queries? Ie the select statement for the 'inner' query
doesn't reference any value returned by the select statement from the
'outer' query.

This means that for every record returned by the outer query, the same
record or records will be returned by the inner query, which doesn't seem to
match the intention of the summary you gave at the top of your email. This
could be an error of interpretation on my part. It may well be that every
record returned by the inner query is relevant to each and every record
returned by the outer query. It's hard to tell from the details you've
included.

Having said which, I'm personally more used to situations where the
following occurs (warning, pseudo-code alert!):

$outerrs = select_query;
while ($outerdata = get_result_from_outerrs){
$innerrs = select_query_using_value_in_where_clause_from_$outerdata;
while ($innerdata = get_result_from_innerrs){
display_information_from_outerdata_and_or_innerdata;
}
}

In the above situation, the inner query is called for each record in the
outer query, indicating a relationship between the two resultsets.

As another thought, have you run the inner select statement against your db
(ie using PHPMyAdmin / MySQL Query Browser / etc) to confirm that under
normal circumstances that query actually returns more than one record?

Regards,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] How can I format text in textarea?

2005-08-30 Thread Murray @ PlanetThoughtful
 Hi
 When I enter text as more than on paragrahs in a textarea field,The text
 is displayed in one solid block of text even though I have entered it in
 paragraphs.
 How I can  to insert line breaks in the text. (The values of textarea is
 stored in database and then displayed.)
 
 
 Bushra

Hi Bushra,

When displaying the data stored in your db from a textarea field, use the
nl2br() function.

This converts newlines in the data into br / html tags. You're currently
not seeing the paragraph breaks because the HTML specification doesn't
display newline / carriage returns when a page is rendered in a browser --
you have to specifically indicate where paragraph breaks should take place
using HTML tags.

Eg:

echo nl2br($data_from_db_entered_via_textarea);

See: http://au2.php.net/nl2br

Regards,

Murray
---
http://www.planetthoughtful.org
Building a thoughtful planet...

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



RE: [PHP] divide-column?

2005-08-30 Thread Murray @ PlanetThoughtful
 Hi there!
 
 How do I do a sort in PHP where a column in a db must be two other columns
 divided...`?

snip

Hi Gustav,

You should be able to use the divide operation in your query's ORDER BY
clause.

Eg

SELECT * FROM mytable ORDER BY (field1 / field2)

Regards,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] divide-column?

2005-08-30 Thread Murray @ PlanetThoughtful
 Murray @ PlanetThoughtful wrote:
 Hi there!
 
 How do I do a sort in PHP where a column in a db must be two other
 columns
 divided...`?
 
 
  snip
 
  Hi Gustav,
 
  You should be able to use the divide operation in your query's ORDER BY
  clause.
 
  Eg
 
  SELECT * FROM mytable ORDER BY (field1 / field2)
 
 You might need to do:
 
 SELECT *, (field1 / field2) AS divField FROM mytable ORDER BY divField
 
 as I'm not sure if you can use expressions like that in the ORDER BY
 clause. Maybe...

Hi Jasper,

The statement I included worked in testing when run against my local
installation of MySQL.

Still, good to point out different options, in the event that something goes
awry.

Regards,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



[PHP] Subscribing with GMail accounts

2005-08-29 Thread Stuart Murray-Smith
Hi list

I've googled... how is it that no PHP list-server email goes to any of
my gmail accounts?

This email is in itself a test ;-) so I might not even get your reply(ies).

TiA

smee

--
/bin/tar --done-dat

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



[PHP] Resizing thumbnails to the browser

2005-08-21 Thread Murray @ PlanetThoughtful
Hello All,

 

I have a series of thumbnails on my site of photos I've taken that are all
150px in width, but of variable height. I want to randomly display one of
the thumbnails each time the home page of my site is loaded in a column that
is 140px wide.

 

I'm wondering if anyone can point me at some code that would achieve this?
All of the thumbnails are in jpg format.

 

So, essentially, I'm trying to resize the thumbnails down to 140px wide
while maintaining the aspect ratio of the image's height.

 

I have GD enabled.

 

Any help appreciated!

 

Much warmth,

 

Murray

---

http://www.planetthoughtful.org

Building a thoughtful planet,

one quirky comment at a time.

 



[PHP] Class for creating RSS 2 feed?

2005-07-26 Thread Murray @ PlanetThoughtful
Hi All,

Just curious if anyone knows of an existing class that will take MySQL
records containing HTML and create a valid RSS 2.0 newsfeed from them?

Much warmth,

Murray
---
http://www.planetthoughtful.org
Building a thoughtful planet,
one quirky comment at a time.

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



[PHP] Translating english into amglish

2005-07-19 Thread Murray @ PlanetThoughtful
Hi All,

 

I'm based in Australia but my blog is predominantly read by Americans. I'm
wondering if anyone knows of a class that will translate Australian / UK /
Canadian / Whathaveyou English spellings into their American English
equivalents?

 

In other words, a class that will take a string with spellings such as The
colour of my neighbour's car, I recently realised, isn't grey after all and
will return The color of my neighbor's car, I recently realized, isn't gray
after all, and so on.

 

Given time I'm sure I could work out many of the transformation rules
myself, and implement them via regular expressions, but why reinvent the
wheel if someone has already done so?

 

Much warmth,

 

Murray

---

http://www.planetthoughtful.org

Building a thoughtful planet,

one quirky comment at a time.

 



[PHP] Re: Ouput HTML w/PHP

2005-06-30 Thread Murray @ PlanetThoughtful

Rick Emery wrote:

This leads (sort of) to a second question: how can I validate my HTML? 
My applications run on an intranet (with database access), so I can't 
use the W3C Validator to point to the URL. If I try to upload the file, 
the validator doesn't parse the PHP to get the HTML output (which is why 
I wonder if I'm not better writing the HTML and sticking PHP where it's 
needed). Is there a way for me to maybe use the PHP tidy functions on 
the string containing the HTML ouput to validate it?


If you run FireFox you can download the entirely invaluable Web 
Developer plugin, one feature of which (under the Tools button) is 
Validate Local HTML. This automates a post of your page to the W3C 
Validator, thus not requiring a URL visible to the ineternet. The only 
caveat being, you do still need internet access from your development 
machine for the post to be possible.


This is a great way for developers to validate the output of their code 
while it still resides on their local machines, prior to actually 
uploading the code to a public (and therefore visible) site.


Regards,

Murray

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



RE: [PHP] Re: security question...??

2005-06-22 Thread Murray @ PlanetThoughtful
 if i as a bank, refuse to allow you to signin to my server, because i
 detect
 that your client is not valid/legitimate, meaning i think it's been
 hacked,
 how have i trampled the rights of anyone. i haven't. will some customers
 run, sure.. perhaps.. will i potentially feel better. yeah. will i
 potentially have something that i can promote as an extra level of
 security
 that others don't have, maybe..

The banking industry is generally not slow in exploring security issues. In
point of fact, I know a guy here in Australia who works as a consultant for
the major banks on encryption protocols and strategies (and his
encryption-related background before working privately for the banking
industry is *scary*), so it should be a given that banks do care about
security both generally and specifically.

That having been said, you're waving the stick around by the wrong end. It
is fundamentally more important to a bank that general access to customer
records be protected, not to specific records relating to any one customer
because of that customer's negligence. By this I mean, most of their money
is invested in attempting to stop hostile attempts to gain access to
customer databases at their end, not at stopping hostile attempts to gain
access to customer data at the client's end. Why? Because that's where the
liability lies. Follow the money.

If you expose your own records by being foolish enough to run spyware-ridden
browser software, this is your own issue. Again, as I mentioned before, once
the data is in your hands, it's your responsibility. Behave responsibly or
stupidly / ignorantly, the choice is ultimately yours.
 
 let people continue to read/hear about massive losses of data and see what
 happens...

Again, the massive losses of data we generally hear about are not as a
result of sniffer programs sitting at the client end. They're ordinarily
about hackers gaining access to the data at the source, where thousands or
millions of customer records can be compromised, not at the client. This
doesn't mean it's not an issue, but that it's an issue that can't and won't
be addressed by anything more than public awareness campaigns.

Which is why I think you're wasting energy on this topic. I'd much rather
see you or anyone else, for that matter, putting this care and attention
into reviewing how secure your app is, even if it's for the 20th time, than
wondering how you go about hypothetically doing something that can't be
done, and which, to the best of anyone's knowledge, isn't going to be
practically implemented by anyone any time soon.

Obligatory, Oh my god, can you really believe they did that? story: 

From a consultancy project I was hired on to extend a retail web site. SSL
encryption where customer data was being entered or viewed? Check. Efforts
to negate the potential of SQL / code injection? Check. Backup strategy?
Daily dump of all records using PHPMyAdmin. From a directory where SSL was
not being enforced. All that customer data. All that effort to protect it
from being exposed to hostile eyes. From a directory where SSL was not being
enforced. Makes you want to weep.

Regards,

Murray

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



RE: [PHP] Re: security question...??

2005-06-20 Thread Murray @ PlanetThoughtful
 from my perspective, i strongly disagree...
 
 if you're going to be writing apps that deal with sensitive information,
 you
 better damm well give some thought as to how secure the client is, or even
 if the client is actually valid!

To the best of my knowledge, if you're developing an app that uses a web
browser as the client, then you better damn well give up on lying awake at
night worrying about this as an issue.

IE, which still holds something like 80+% market share of the browser base,
is full of many, many holes. I'm sure this isn't news to you. Unless you're
talking about exposing this sensitive data only to a user base within a
strictly maintained network environment, then you *must* assume that some of
the data can and perhaps will be compromised at the client end some of the
time. There are an amazing number of variables to take into account, all of
which, under most circumstances, are entirely out of your control. Which
version of which browser is being used? Which operating system? What service
pack and security updates have been applied? Which firewall software or
hardware is in use, if any? Which antiviral software is being used, and how
often is it being updated?

Another way of looking at this is, where does your responsibility as a web
developer end? Is it up to you to be concerned what happens to the data
once it has been requested by the client, as opposed to it being the
client's concern? What if a particular user is writing this data down in a
notebook and loses it on the train on the way home from work? What if
they're printing it out on a communal printer and other people are leafing
through it while waiting for their own print jobs to finish? What if they're
copying and pasting it into an email and blindly sending it to a huge
distribution list? What if this data is stored in their browser cache and
their laptop gets stolen? And on, and on, and on.

Even given your suggestion re: browser vendors exposing some method of
independently verifying 'unhacked' browsers, the implications would probably
be many and varied. Do you suddenly stop communicating with every browser
that has an unregistered 3rd-party add-on? What would be the effect on your
business if customers objected to you telling them what browser add-ons they
are allowed to use? How would that trickle over into open-source and smaller
start-up initiatives that a company like Microsoft (infamously open-source
opposed, according to the EFF) might not like to see thrive? Do you simply
consolidate browser market dominance, and stifle innovation, by introducing
a defacto licensing requirement? And on, and on, and on.

If you're honestly concerned about the security of the data once it has been
requested, then all I can suggest is, don't use a browser as the client.
Develop a purpose-built client that enforces more security than you can hope
for out of a browser. Even then, accept that the people who request the data
may not have even the slightest respect for your security concerns once it's
in their possession. 

As a last resort, and purely as a public awareness initiative, you might
want to invite your users to check their browser for known spyware, etc,
using a service such as DoxDesk (http://www.doxdesk.com/parasite/). I
believe this site uses an activex control to specifically check details in
IE. I have no idea how accurate it is. Alternatively, you could encourage
them to use an application such as Ad-Aware (http://www.lavasoft.de/) etc to
perform routine security checks. Beyond that, like I said, get some sleep.

Regards,

Murray

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



[PHP] Retrievable weather service info?

2005-06-14 Thread Murray @ PlanetThoughtful
Hi All,

Just wondering if anyone knows of a free weather service that can be
interrogated by PHP for information such as current temperature for a range
of cities around the world?

Regards,

Murray

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



RE: [PHP] Re: Retrievable weather service info?

2005-06-14 Thread Murray @ PlanetThoughtful
 http://www.weather.com/services/xmloap.html
 
 Weather XML Data Feed
 Now you can include weather from The Weather Channel in your own
 application by signing up for access to our XML data feed. We'll enable
 you to search for a location and to integrate current conditions and the
 forecast for today and tomorrow in your application - for FREE!
 
 
 Hope that helps
 
 Zac

Hi Zac,

Thanks for the suggestion! Having downloaded weather.com's xml sdk I'm a
little bemused to see that you are required to display referral links
provided by weather.com to make use of the service.

I'd be very happy to include a weather details provided by... link on the
page in question, but carrying unspecified referral links, particularly when
the application is simply my personal blog, is a little more of a constraint
that I'm comfortable with.

However and again, thank you for the suggestion!

Regards,

Murray

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



RE: [PHP] Re: Retrievable weather service info?

2005-06-14 Thread Murray @ PlanetThoughtful
 http://weather.noaa.gov/pub/data/forecasts/zone/

Hi Philip,

This would probably have been ideal for what I have in mind (don't mind
going to a little effort to parse the text files) but appears to be limited
to US information only, whereas I'm hoping to be able to randomly select a
city from around the world and present it's current time and weather
information.

Thanks for the suggestion, though.

Regards,

Murray

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



RE: [PHP] Re: reverse MD5 ???

2005-06-13 Thread Murray @ PlanetThoughtful
 In that framework there is no such thing as decrypting an MD5 digest,
 because an MD5 digest is not an encrypted version of the message to
 start with.  No amount of CPU power will change this basic fact --
 though CPU power can be used to do a brute force search for strings
 which will generate a given MD5 value.  However, as stated before, at
 current levels of computing power this is not feasible for messages
 beyond I think 7 or 8 characters long (don't quote me on that).

One real-world example of the potential weakness of 'md5 out of the box'
comes from a consultancy project I was involved in not so long back.

The app in question was storing the md5 value of 4-digit PINs in the
background database, and the owners of the app were quietly confident that
this meant the PINs were 'encrypted' and 'secure'.

Of course, there are only 10,000 possible PIN values between  and ,
regardless of whether or not they're stored in plaintext or md5 hashed form,
and I guess it took me less than 15 minutes to build a reference table of
all md5 hash values for the possible plaintext PINs and therefore
effortlessly retrieve the plaintext PIN values from their table. Imagine
their surprise.

And if *I* could do it...

Md5 is a very handy way of 'securing' [1] password information, but only
when the plaintext value offers enough possible variation in length and / or
value to make building a 'possible variations' lookup table a difficult
proposition.

Regards,

Murray


Footnotes:

[1] Without wanting to get into a technical debate of exactly what
constitutes 'secure' when it comes to hashing / encrypting sensitive
information

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



RE: [PHP] Re: reverse MD5 ???

2005-06-13 Thread Murray @ PlanetThoughtful
 Amazing.
 
 Thanks for sharing that. It's a great example. :-)

You're very welcome! If it helps just one other developer avoid the same
pitfall, then today is a very good day. :-)

 Exactly, and this is why it's a good practice to use a seed when you
 generate MD5s for passwords.

Which is exactly what I suggested, and what they ended up implementing,
thanks to the fact that I could provide them with the original plaintext PIN
values for the existing records.

Still, once I'd had a chance to look at the plaintext PINs, it was
depressing to notice the frequency of 'easy' PIN values, such as '',
'1234', '' etc.

Even with a seed, those values would have been relatively easy to guess at
with frequency analysis, and it goes beyond my meager hostile decryption
skills to guess at whether that made deriving the seed any easier or not.

I suggested implementing a class that randomly selected from somewhere
between 5 to 10 possible seed values when hashing the PIN for storage, which
would have meant simply using all 5 or 10 seeds when comparing the PIN for
subsequent validation, to reduce the frequency of hash-to-easy-PIN
repetition, but it hadn't been implemented by the time my consultancy ended
and I'd be willing to bet a year's pay it, or any other method of providing
some sort of buffering against frequency analysis, hasn't been since.

Of course, there's a whole conversation to be had regarding the fact that if
your db server has been compromised to the point where the contents of
tables are exposed, then it's reasonable to at least speculate (depending on
your server setup and method by which it was accessed) that perhaps your
entire app has been compromised, and your seed values may now be known to
the hostile entity as well.

Still and all, there's absolutely no reason to make the job of compromising
your data any easier on a hypothetical hacker than is within your level of
competency as a developer. Adding a seed value to md5 hashes is a simple and
effective method under most circumstances that even beginner to intermediate
developers can employ. In other words, It Is A Very Good Thing. ;-)

Regards,

Murray

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



RE: [PHP] formatting paragraphs in to strings

2005-06-13 Thread Murray @ PlanetThoughtful
 Use the PHP str_replace function before writing it to the DB.  Replace
 all \n characters with an empty string .
 
 http://us2.php.net/manual/en/function.str-replace.php

I think it might be better to replace all \n characters with spaces  ,
otherwise you will end up with sentences that have no space break between
them.

Ie:

original text
This is the first sentence.

This is the second sentence.
/original text

...would become:

replaced text
This is the first sentence.This is the second sentence.
/replaced text

Regards,

Murray

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



RE: [PHP] formatting paragraphs in to strings

2005-06-13 Thread Murray @ PlanetThoughtful
 Good point.  Only problem is, if someone hit enter a-million times,
 you would end up with a-million spaces where the \n characters were.
  To take care of that repetition, maybe something like:
 
 
 while (strpos($textarea_text, \n\n)) {
  .
 }
 
 
 would be one way you could do it.

Ordinarily most browsers render multiple consecutive spaces as a single
space. This doesn't mean that it's not a good idea to remove them, just that
not doing so shouldn't effect the way the text is displayed in the div tag,
as the original poster mentioned was his intention.

Regards,

Murray

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



RE: [PHP] ampersands in href's

2005-06-04 Thread Murray @ PlanetThoughtful
 If I want to make a link to a URL which includes some GETs can I just do:
 
 a href='{$_SERVER['PHP_SELF']}?p={$p}c={$s}' ... etc etc
 
 or must I escape the ampersand somehow?

Depends very much on the document type of your page. Valid XHTML
(transitional, at least), for example, doesn't like single ampersands in a
href= links. For XHTML, you need to replace s with amp;s.

So the following link:

a href='http://www.somewhere.com/index.php?id1=1id2=2'Something/a

...should be changed to:

a href='http://www.somewhere.com/index.php?id=1amp;id=2'Something/a

Regards,

Murray

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



RE: [PHP] Frames or iframes? (Basically The devil or deap sea or A rock and a hard place etc) - - - - (0T)

2005-06-04 Thread Murray @ PlanetThoughtful
 Since its a forum and she is not doing any advertising its important the
 search engines index the site
 properly or shes going to have a big forum with no visitors.
 Then I read that the search engines dont like frames muchso I was
 thinking of using iframes and
 then I read about the evils of iframes...so I thought I'll ask you guys
 for your opinions/suggestions
 as I'm dead outa ideas and a bit confused...any alternate ideas too would
 be
 appreciated.

As a compromise solution, you could greet visitors to the forum with a
welcoming 'splash' page that displays your flash animation etc (please,
please put a 'skip intro' link for the sake of repeat visitors) and then
pass to your forum page(s). You could even put a static jpg at the top of
the forum of the final image (ie once all that funky animation has played
out) of your flash file, if you want to carry it over for a consistent look
/ feel.

Regards,

Murray

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



RE: [PHP] Re: Best way to use other objects within classes?

2005-06-03 Thread Murray @ PlanetThoughtful
 If you're developing with PHP5, but the production environment is PHP4
 then at the top of each script you probably want to add:
 
 ?php
 
 ini_set('zend.ze1_compatibility_mode', 1);
 
 ?
 
 This way you will have objects default to pass by value instead of by
 reference and you don't end up deploying to production server with some
 really hard-to-find dereferencing problems.

Hi Jason,

Not a bad tip, thank you! However, I've been, to the best of my knowledge,
explicit in passing by reference in my code wherever I've needed to access
objects within classes etc.

Many thanks,

Murray

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



[PHP] Best way to use other objects within classes?

2005-06-02 Thread Murray @ PlanetThoughtful

Hi All,

I'm using the MDB2 object to access my MySQL database. I have a number 
of classes that perform page-building activities that need db access, 
and I'm wondering what the best way to expose the MDB2 object to them is?


(Note: my development environment is PHP 5.0.3, but the production 
environment is 4.3.10. This is my first project built with 5.x local and 
4.1.x remote, so if anyone with more experience spots any fatal flaws 
where I'm using 5.x specific methods etc, I'd appreciate knowing about them)


Currently, I'm instantiating the MDB2 class in my main page, then 
passing it as an object reference to each of the other classes that 
require it.


A simple representation of my main page and a class would be:

?
 $db = connectMDB2(); // function that returns instantiated MDB2 object

 $comments = new displayComments(); // class that performs displaying 
of comments

 $comments-set_db($db); // passing the MDB2 object to the class
 $comments-doSomethingElse();
?

The displayComments() class might then look something like:

class displayComments{
private $db;

public function set_db($db){
$this-db = $db;
}

public function doSomethingElse(){
$sql = SELECT something FROM sometable;
$rs = $this-db-query($sql);
while ($row = $rs-fetchRow(MDB2_FETCHMODE_OBJECT)){
echo $row-something.br /;
}
$rs-free();
}   
}

My main page calls on at least 8 or 9 such classes as it is being built, 
and I'm concerned that I may not be handling the MDB2 object in respect 
to them in the most efficient way possible. In a way, I guess this isn't 
 specifically about the MDB2 package, but more about how to handle 
objects when they are required within classes.


I'd very much appreciate any comments or advice anyone might be able to 
give.


Much warmth,

Murray

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



  1   2   3   4   5   6   >