Re: [PHP] Re: Sending PHP mail with Authentication

2013-09-29 Thread Paul M Foster
On Fri, Sep 27, 2013 at 12:06:30AM +0200, Maciek Sokolewicz wrote:

[snip]
 
 I'm sure I'm going to annoy people with this, but I would advise to
 never use PEAR. It's the biggest load of extremely badly coded PHP
 you'll ever find. Creating an SMTP client (with the purpose of just
 sending mail) is very easy to do yourself (and also a good challenge
 if you're not yet very skilled with PHP). Alternatively, you can
 indeed use a package such as PHPMailer; it's not perfect, and quite
 bloated for what you want probably, but it works rather well.
 

I have to agree on the code bloat. Unless your requirements are
extraordinary (which the OP's are), the native PHP mail() function is
generally quite adequate.

Never thought about creating a PHP email client. Interesting idea...

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Static methods vs. plain functions

2013-09-19 Thread Paul M Foster
On Thu, Sep 19, 2013 at 06:28:32PM +0200, Simon Dániel wrote:

 Hi,
 
 I am working on an OOP project, and cannot decide which way to follow when
 I have to write a simple function.
 
 For example, I want to write a function which generates a random string. In
 an OOP environtment, it is a matter of course to create a static class and
 a static method for that. But why? Isn't it more elegant, if I implement
 such a simple thing as a plain function? Not to mention that a function is
 more efficient than a class method.
 
 So, in object-oriented programming, what is the best practice to implement
 such a simple function?

Best practices are for academics and people who read Datamation.

You have to look at why OOP exists and then ask yourself if the function
you wish to create really needs any of the values that attend OOP. You
also have to look at how simple your code is to read and understand.
Based on what you've described, there would appear to be absolutely no
value in making it into a class with a static method. In that case, all
you would have done is to add an extra level of complexity to your code.
If I were a programmer coming in after you to work with your code, I'd
ask myself why in the world you did that. And if feasible, I would
change it back to a flat function for the sake of simplicity.

Always prefer non-OOP unless you have some compelling reason to make
something object-oriented. For example, the interface to a DBMS is
something which may involve many many functions. It is definitely
something which benefits from OOP code, not flat functions. I've
personally found that dates benefit from this same treatment.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] PHP Dependency Injector

2013-09-05 Thread Paul M Foster
On Thu, Sep 05, 2013 at 04:19:18PM -0400, Bastien Koert wrote:

 Jee, that should have been a friday comment...how does your dic standout

Don't send emails like that to the list when I've got a mouthful of
water! It all came out my nose! ;-}

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] PHP vs JAVA

2013-08-20 Thread Paul M Foster
On Tue, Aug 20, 2013 at 05:09:37PM +0100, Lester Caine wrote:

 shiplu wrote:
 During PHPvsPython search I found this info graphic
 https://www.udemy.com/blog/modern-language-wars/#. Some of the
 statistics contain Java too. Also you can search PHP and Web
 Development in big job sites and compare with same search but with
 Java.
 
 'Python is arguably the most readable programming language' probably
 says it all? Personally I find it almost impossible to understand
 when coming in cold to someone elses code ... Java is not much
 better ... but I still have to persist with both since some key
 elements of a usable PHP IDE now rely on both :(

Python may be most readable, but it's a huge fail for two reasons:

1. There are no statement terminators. Lose your indentation for ANY
reason and your program is well and truly screwed, in ways you can't
imagine.

2. Python programs fail in the most ungraceful way I've ever seen in an
interpreted programming language. (Don't even start in on C. It's a
compiled language.)

Java is an incredibly heavy language for web work. Much like Ruby but
more so.

I'll say it again-- one of the reasons for the popularity of PHP is its
similarity to C, at least a passing skill in which is common to most
programmers.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] how to see all sessions sets in server

2013-08-04 Thread Paul M Foster
On Sun, Aug 04, 2013 at 05:58:53PM +0100, Ashley Sheridan wrote:

[snip]

 
 I'm not saying the method is bad, but the way Facebook does it isn't
 great, I'm constantly seeing people online who sign out when I open
 up a message box. Now that might be genuine, but I'm not *that*
 unpopular! 

I'm sorry. Were you saying something? As soon as I saw Ashley Sheridan
in my email client, it closed and my computer rebooted for some strange
reason. ;-}

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] POST action

2013-08-01 Thread Paul M Foster
On Thu, Aug 01, 2013 at 02:35:04PM -0500, Larry Garfield wrote:

[snip]

 
 So you're writing your own form tags for each specific time you need
 a form, or you wrote your own form builder API that is writing the
 form tags for you?

Unless my wife creates the form in Dreamweaver, I write the HTML for the
form fields. Even when she does, I add the proper code to validate each
field and the form overall, using my field validation class, etc.

 
 Because if the former, I claim it's insecure.  The development
 process is insecure, so you will screw up sooner or later.  You're
 only human.

A-ha! That's where you're wrong, Matey! For I am SUPER-CODER! Faster
than a speeding 300 baud modem! More powerful than a teletype! Able
to leap tall procedural functions at a single bound! With my pocket
protector and trusty slide rule, I defend the indefensible and champion
the cause of spaghetti code!

So there! ;-P

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] POST action

2013-07-29 Thread Paul M Foster
On Mon, Jul 29, 2013 at 11:50:01AM -0500, Larry Garfield wrote:

 On 7/28/13 9:23 PM, Paul M Foster wrote:
 On Sun, Jul 28, 2013 at 08:46:06PM -0500, Larry Garfield wrote:

[snip]

 
 Except as noted above. This is all home-grown, using native PHP
 functions designed to do these things, and classes I've written. I
 carefully examine each field when writing the POST-handling code with
 the idea in mind that no matter what the HTML says, the return value
 must conform to what *I* think it should be. No MVC framework written by
 others (though I do conform to MVC paradigm).
 
 Paul
 
 Then you're not writing your own form tags from the sound of it;
 you're writing your own Form API.  Still an improvements. :-)

No, I'm writing the form tags as well. I write the whole thing, soup to
nuts. But as I'm writing the back end validation stuff, I realize that
what I wrote in the HTML doesn't matter when it comes to hackers and
script kiddies. So I use my bless and validation libraries to tackle
form responses. That's the point I'm making. I understand what you're
saying about using someone else's framework so you can make sure that
tested code is being used to ensure against hacking attempts. But your
pronouncement was so thunderous that I had to provide the exception. If
you hang around here and read a book or two on security, you can write
your own code that handles this stuff. Particularly if you have an
example like CodeIgniter to use, to see how it's done.

(There are times when I *don't* write the HTML. My wife the designer
does. But I still go in and modify it to provide the validation bits
which she can't do. She uses Dreamweaver, so a lot of the time, she
doesn't even know what the raw HTML looks like.)

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] POST action

2013-07-28 Thread Paul M Foster
On Sun, Jul 28, 2013 at 08:46:06PM -0500, Larry Garfield wrote:

 On 07/28/2013 12:38 PM, Ashley Sheridan wrote:
 On Sun, 2013-07-28 at 13:37 -0400, Jim Giner wrote:
 
 
 Never write your own form?  I'm guilty - oh, so guilty.  What exactly is
 a 'security hardened' form?
 
 - All forms need a valid CSRF token to avoid CSRF attacks.  This
 needs to be matched between the submitted form and server-maintained
 state.  Do all of your forms have that?  Every single one?  (A GET
 lookup form like a search box doesn't need it, but anything with
 POST does, I'd argue.)

Yes. I wrote a bless class just for this purpose, which I use on all
form pages.

 
 - Do you have a select element? Do you have error handling for when
 someone submits a value for that wasn't one of the option elements?

Yes, since I realize that what comes back to me may bear no resemblence
to what I coded in HTML. Thus, I always check for allowed SELECT
values.

 
 - Your text input field has a max length of 20. Does your code
 return an error when the user enters a string of 100 characters?

Yes. Same answer. Putting a max length of 20 in the HTML works okay, but
the user could still submit something much longer if they are attempting
to hack the page. Thus I always check for max characters on the return.

 
 - Are you checking for weird edge-case-y character encoding issues?
 (Some versions of some browsers can be hacked by sending UTF-7
 instead of UTF-8 for certain parts of the request. I don't fully
 understand that stuff myself, either.)

No I don't check for this.

 
 - You have a number field (HTML5).  Does your PHP code handle
 someone submitting a string anyway?

I don't use HTML5 tags like this, since they are not universally
supported. However, I check that numbers look like numbers on return and
strings look like strings on return. PHP has built-in functions for
this.

All this is part of my validation class.

 
 - Are you checking all of those correctly every single time you
 write a form?

Except as noted above. This is all home-grown, using native PHP
functions designed to do these things, and classes I've written. I
carefully examine each field when writing the POST-handling code with
the idea in mind that no matter what the HTML says, the return value
must conform to what *I* think it should be. No MVC framework written by
others (though I do conform to MVC paradigm).

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Reseting the auto-increment number in a MySQL database.

2013-06-27 Thread Paul M Foster
On Thu, Jun 27, 2013 at 11:47:28PM +0200, adriano wrote:

 
 holes in sequence of auto increment happen using transaction for
 insert new record but you don't commit transaction itself
 it seems that the autoincrement is incremented anyway
 at least this is my case.

I think what Tedd was referring to was something else. The hole was
quite large. I've seen this behavior myself, in PostgreSQL. From one
transaction to the next, there were over 10,000 skipped numbers, and
only me and my wife on the system. Some sort of bug, like a spinlock
that wasn't interrupted the way it should have been. I remember the
system taking forever to calm down before it gave the next transaction a
number way forward of the last one. I waited in front of my browser for
quite some time. But I couldn't explain why.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Migration of applications to PHP 5.4

2013-06-25 Thread Paul M Foster
On Tue, Jun 25, 2013 at 07:58:32PM +0200, Forum wrote:

 Hello,
 
 i recently migrated my webserver from Debian Lenny (with PHP 4.x) to Wheezy 
 with PHP 5.4.
 
 Some applications like mediawiki could be updated and they are running fine.
 
 But there are some old and beloved applications that run any more.
 A good example is PHPmyedit 5.7.1 http://www.phpmyedit.org/
 The first page with data is displayed but all links and buttons are dead!
 
 There is no error produced by PHP and i have no idea why it is not working?
 I'm have only basic knowledge with PHP and would be glad to have some tips 
 how to debug things without error.
 
 My hope is that this migration problem is known and can be fixed simply?

You should probably turn your error reporting threshold way up, so you
can see what's happening.

Ultimately, you'll probably need to contact the authors of the
individual packages to get them to upgrade, so they can see the problems
and fix them. 

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Detect and Redirect Mobile Users

2013-06-12 Thread Paul M Foster
On Wed, Jun 12, 2013 at 04:19:50PM -0700, dealTek wrote:

 Hi all,
 
 I'm curious of a simple, common, universal way to detect a mobile user so I 
 can redirect them to a mobile directory...
 
 What is best for this: Javascript - CSS - PHP?
 
 I think for my purposes if I can detect screen size or mobile browser agent - 
 that would be good enough for what I need right now.

This is not really a PHP question. I understand your asking it, though.
Does anyone know of a better list or whatever for generic web designer
questions?

To your question, there are two problems: 1) Looking for a browser
signature is a needle/haystack proposition, and the haystack is
enormous, and it gets bigger every time a new phone/tablet model comes
out; 2) Screen size used to be a good indicator, but as I feared when
people first started using screen resolution as the main indicator, the
screens on mobile devices have become progressively more and more
capable. Some of them are better than many desktops I've seen.

So I'd be interested in the answer to the question myself.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] limit access to php page

2013-05-30 Thread Paul M Foster
On Thu, May 30, 2013 at 12:06:02PM -0400, Tedd Sperling wrote:

 On May 29, 2013, at 11:05 PM, Paul M Foster pa...@quillandmouse.com
 wrote:
  http://sperling.com/php/authorization/log-on.php
  
  I realize this is example code.
  
  My question is, in a real application where that $_SESSION['auth']
  token would be used subsequently to gain entry to other pages, what
  would you use instead of the simple TRUE/FALSE value? It seems that
  someone (with far more knowledge of hacking than I have) could
  rather easily hack the session value to change its value. But then
  again, I pretty much suck when it comes to working out how you'd
  hack (crack) things.
  
  Paul
 
 Paul:
 
 While the above link may be example code, it is still sound for
 production.
 
 Keep in mind that everything in security comes down to a true/false
 condition. Do you let the person in or not!
 
 Certainly there are attacks on session ids and one must deal with
 that. But that's the level of security we have today.
 
 I could go through all the things you need to consider in protecting
 your session id (e.g., not accessing your bank accounts while having
 coffee at StartBucks) but that would defeat the purpose of attending
 one of my classes on the subject. :-)

Yep, next time I'm up at the North Pole, I'll drop in and see you.
Meantime, the beach is heating up. Better go get some more ice for my
margueritas. [grin]

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] limit access to php page

2013-05-29 Thread Paul M Foster
On Wed, May 29, 2013 at 08:51:47PM -0400, Tedd Sperling wrote:

 On May 29, 2013, at 7:11 PM, Tim Dunphy bluethu...@gmail.com wrote:
 
  Hello list,
  
  I've created an authentication page (index.php) that logs into an LDAP
  server, then points you to a second page that some folks are intended to
  use to request apache redirects from the sysadmin group (redirect.php).
  
  Everything works great so far, except if you pop the full URL of
  redirect.php into your browser you can hit the page regardless of the login
  process on index.php.
  
  How can I limit redirect.php so that it can only be reached once you login
  via the index page?
  
  Thank you!
  Tim
  
  -- 
  GPG me!!
 
 Try this:
 
 http://sperling.com/php/authorization/log-on.php

I realize this is example code.

My question is, in a real application where that $_SESSION['auth'] token
would be used subsequently to gain entry to other pages, what would you
use instead of the simple TRUE/FALSE value? It seems that someone (with
far more knowledge of hacking than I have) could rather easily hack the
session value to change its value. But then again, I pretty much suck
when it comes to working out how you'd hack (crack) things.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] webform spam prevention

2013-04-04 Thread Paul M Foster
On Thu, Apr 04, 2013 at 07:29:12PM +0100, Terry Ally (Gmail) wrote:

 I am running captcha but the problem that I am having is that fly-by-night
 SEO marketeers are using the form to send marketing messages anyway. We get
 so many spam messages that I put up in red letters on the form that we do
 not want cold-calling SEO marketing messages. Since that message there has
 been a significant reduction in emails from legitimate SEO companies.

legitimate SEO companies

ROTFL! (Oh, sorry, did I say that out loud?)

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] target question

2013-03-25 Thread Paul M Foster
On Mon, Mar 25, 2013 at 10:01:03AM -0400, Jim Giner wrote:

 target as in the form attribute
 
 In my appl devl I utilize an extra window when my current form is
 asked to generate a pdf report.  Works well since that way the user
 can generate one report into a new window, read it, close it, and
 still have the reports menu in front of him/her and generate a 2nd
 report.
 
 I'm experiencing a problem tho and I'm guessing it's associated with
 ie9 or FPDF. In my reports menu form, when I click on a button that
 will generate a pdf, I alter the form's target to create a new
 window.  This used to work last fall, but since then I have a new
 laptop running ie9, not 8.  The target changing js logic is working
 as far as I can see (alerts in my js) but the effect is not there.
 Instead of a new window, the pdf opens up in the same window where
 the menu was and so when the user does a back he ends up going up
 one too many levels and has to re-request the reports menu.
 
 Didn't have this much trouble originally setting this up as I'm
 having now trying to debug this.  I'm using the FPDF extension/class
 to generate my pdfs - made no recent changes there.  Also my concept
 works very well still in a simple html document that has only two
 buttons on it which I created today to test a theory.  That is -
 maybe it's not just IE9, but FPDF.
 
 Anyone have any experience in this area?

This behavior of the browser actually conforms to the standard as far as
I know. The target attribute is attached only to the a tag,
according to w3schools.com. It may work when you use it with a form tag,
it doesn't surprise me if IE doesn't honor it (of course, nothing IE
does would surprise me). In any case, using it with the form tag appears
to be non-standard usage, which may or may not be supported by
individual browsers.

I handle this situation differently. My generator code (also using
FPDF) dumps the PDF in a PDF directory. Then I provide a link elsewhere
with an Adobe Acrobat logo which, when clicked, opens the PDF in a
separate window, using the aforementioned 

a href=example.com/pdfs/something.pdf target=_blankMy PDF/a 

paradigm.

In any case, I doubt very much FPDF has anything to do with this. It
just dumps its creation to wherever you tell it. The browser determines
what helper application it will use to open it when it downloads the
content. Whether to open a separate window/tab is determined by the
HTML the browser is looking at when it makes the content request.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] target question

2013-03-25 Thread Paul M Foster
On Mon, Mar 25, 2013 at 04:37:50PM +, Stuart Dallas wrote:

 On 25 Mar 2013, at 16:35, Ford, Mike m.f...@leedsmet.ac.uk wrote:
 
  -Original Message-
  From: Paul M Foster [mailto:pa...@quillandmouse.com]
  Sent: 25 March 2013 16:09
  
  This behavior of the browser actually conforms to the standard as
  far as
  I know. The target attribute is attached only to the a tag,
  according to w3schools.com
  
  Actually, the W3C HTML 4.01 Recommendation says:
  
 target = frame-target [CI]
  
 This attribute specifies the name of a frame where a document
 is to be opened.
  
 By assigning a name to a frame via the name attribute, authors
 can refer to it as the target of links defined by other
 elements. The target attribute may be set for elements that
 create links (A, LINK), image maps (AREA), and forms (FORM).
  
  In the current HTML5 draft, target is explicitly a permitted
  attribute of the form tag -- although I believe it was originally
  marked as deprecated.
 
 Indeed. In fact w3schools.com is known to be a very unreliable source of 
 information these days. My advice would be to avoid it at all costs!
 
 http://w3fools.com/

Interesting. I wasn't aware of this. Thanks for the info. 

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Re: Open form in new window

2013-03-04 Thread Paul M Foster
On Mon, Mar 04, 2013 at 05:39:00PM +, Tim Streater wrote:

 On 04 Mar 2013 at 17:10, John Taylor-Johnston 
 john.taylor-johns...@cegepsherbrooke.qc.ca wrote: 
 
  button type=button onclick=OpenWindow()Submit/button will not
  submit the form contents.
 
 Nothing to stop your OpenWindow() function doing a submit as in:
 
 button type=button onclick=OpenWindow(this.form)Submit/button
 
 
 function OpenWindow (formPtr)
  {
 
  // Some actions
 
  formPtr.submit ();
 
  }
 
 

 Personally I never submit forms. I use ajax to communicate with PHP
 scripts and do something with the data that is returned by the script.
 You can see a simple example at http://www.clothears.org.uk
 
 --
 Cheers  --  Tim
 

I'm trying to figure out where the net gain in that is. The PHP file
being called via AJAX is doing its processing on the server either way.
So it appears the only difference is an asynchronous Javascript/AJAX
call or a synchronous PHP call (on a standard PHP form submission). What
am I missing?

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Re: Open form in new window

2013-03-04 Thread Paul M Foster
On Mon, Mar 04, 2013 at 06:58:41PM +0100, Matijn Woudt wrote:

 On Mon, Mar 4, 2013 at 6:10 PM, John Taylor-Johnston 
 john.taylor-johns...@cegepsherbrooke.qc.ca wrote:
 
   You could echo HTML code e.g.
 
  Which is still purely HTML and has nothing whatsoever to do with PHP.
 
  
   form action=result.php method=post
   Number: input id=quantity type=text /
   button type=button onclick=OpenWindow()Submit**/button
   /form
  
   or include it as one of your form attributes:
  
   form action=demo_form.asp method=get target=_blank
 First name: input type=text name=fnamebr
 Last name: input type=text name=lnamebr
 input type=submit value=Submit
   /form
  Again, pure HTML, and no PHP involved. Specifically, the (asp??) page
  called in the form action handler will never even be aware of the fact
  that the page was opened in a new window, or at least was supposed to.
 
 
  I was using an example and NOT intended to show ASP.
 
  target=_blank will open a new window every time. That will defeat the
  purpose.
 
  I have many different submit buttons, for different purposes. Depending on
  the $_POST value of each submit button, I tell PHP to do different things,
 
 
 I don't wanna interrupt this thread, but are you sure you want multiple
 submit buttons, especially more than two?
 There are probably better solutions for what you want, for example, radio
 button to select which action to take?
 
 - Matijn

I have to agree with Matijn for this reason: If the user hits the
[Enter] button at the end of their form data entry, it will trigger the
*first* submit button on the page, which may or may not be what you
want. Perhaps better to have the user indicate the action they wish via
radio button (as Matijn suggested) and then a single submit button.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Formatting -- defining sections of code

2012-12-14 Thread Paul M Foster
On Fri, Dec 14, 2012 at 10:48:05AM -0500, Andy McKenzie wrote:

 Hey folks, kind of a strange question here.
 
 Basically, I've been trying to move my style from self taught to Oh
 yeah, there IS a standard for this.  One of the things I frequently
 want to do is define sections of my code:  to take a simplistic
 example, this outputs everything that needs to be in file A, this
 outputs what needs to be in file B, and so on.
 
 Up until now, I've used my own standards (generally 
 SectionName, since it's easy to search for).  But it occurs to me to
 wonder;  IS there a standard for this?  Most likely, the programming
 world being what it is, there either isn't one or there are lots of
 competing standards, but I'd be interested to know...

A *standard* for something? ROTFL! Yeah, like there's a standard for
herding cats! [guffaw]

Seriously, no I know of no such standards. It sounds like you're
thinking of the kind of thing that's more common in languages like COBOL
than anything modern. Plus, it's near impossible on any significantly
sized project to segregate code in such a way.

That said, I would recommend PHPDoc or similar. It's a package for
generating code documentation from the comments embedded in your code.
You adhere to certain conventions in the format of your comments, and
PHPDoc can scan your code and produce pretty docs. Plus, the comments
themself serve as a sort of discipline in explaining what functions and
sections of code do. If you keep your functions to singular, small tasks
(as you should), the comments are invaluable when you come back later to
try to figure out what you were thinking when you wrote this or that
block of code.

I don't know how extensive your experience is with coding or PHP. So in
case you're a relative newbie, I'd also suggest that you keep classes in
their own files (one file per class) in a libraries directory or
somesuch. In fact, I'd suggest downloading something like CodeIgniter,
and studying the way they structure their code physically. They may not
be the optimum example, but for a well-known framework, their code base
is relatively slim and well-organized. Also, obviously, study the MVC
(model-view-controller) paradigm. It's a very useful way of dividing up
your code's functionality.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] storing searching docs

2012-12-12 Thread Paul M Foster
On Wed, Dec 12, 2012 at 01:00:41PM -0500, Jim Giner wrote:

 Slightly off-topic perhaps but I'm looking for general input here.
 
 New idea for a project - save the minutes of my firehouse meetings
 into a mysql table and build a ui to search them for words and such.
 The docs are written in Word currently.  My simplistic idea is to
 perhaps convert them to something other than Word format and then to
 store them into a field of a mysql record with the meeting date as a
 key field.
 Of course having them online I should also allow for viewing as a
 document in something close to their original (?) format.
 
 Any ideas - pro or con - on this idea?

First off, I'd convert them to RTF (rich text format). Word format is
too ephemeral ( = self-incompatible). RTF is a lowest common denomenator
which can be converted to a variety of other formats. And RTF is a
standardized format that both Word and things like Open Office both
understand. The formatting for meeting minutes don't dictate a very
complicated layout (something that RTF isn't that good with). I would
suggest HTML format, but Word is notoriously atrocious at faithfully
converting its own formats into HTML. The result is horrid.

Second, you've hit on one of my pet peeves. Never never store huge
blocks of text in SQL files. It slows them down and there's no real
reason for it. There's no reason to force a DBMS to schlep around
massive clumps of text or binary data. That's what disk file systems are
for. Store the target data in a file and store a reference to the
location of the data in the SQL database. Or perhaps, use a NoSQL
solution. I don't know much about the internals of nosql systems, but I
would hope that the metadata about the text objects would be stored
separately from the payload (text object).

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



[PHP] PHP site search broken?

2012-12-04 Thread Paul M Foster
Is it just me, or is the search feature on php.net broken?

When I enter a full search term (known good function name) and then hit
the arrow, it brings me back to the generic search page. If I enter a
partial search term and then click on one of the suggested
completions, it usually (not always) does the same thing. Etc.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



[PHP] Beneficial site spamming framework

2012-10-11 Thread Paul M Foster
Folks:

I've been getting spam comments on my personal blog (runs on
self-written PHP blog software). I'd like to test some methods I've
devised to prevent or block it. Does anyone know of a very lightweight
framework for simulating an automated form fill-out on a site?
Something where you could just add some code to designate the site for
the attack and then what fields you wanted to send?

This should be a relatively simple task for PHP and curl, but I'm not
really familiar with the headers and that part of the HTTP conversation.
Yes, I know this is a risky question for a public list. Feel free to
contact me privately if you think the answer shouldn't be in the
archives of a public list. Likewise, if you can point me to a source of
quickly absorbable research on the subject. I frankly don't know how I'd
google such a thing.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Day after Friday

2012-09-23 Thread Paul M Foster
On Sun, Sep 23, 2012 at 09:33:33AM -0400, Tedd Sperling wrote:

 On Sep 22, 2012, at 3:59 PM, Paul M Foster pa...@quillandmouse.com
 wrote:
  On Sat, Sep 22, 2012 at 01:05:51PM -0400, Tedd Sperling wrote:
  
  Hi gang:
  
  I know it's the Day after Friday, but I'm asking a off-topic
  question anyway -- sorry.
  
  Normally, I teach a PHP class at the local college, but it got
  canceled (don't ask why) -- now I'm teaching Java.
  
  So, can anyone recommend a Java list that is similar to this list?
  
  Off off topic...
  
  Who the hell cancels a PHP class? Do they not realize damn near the
  whole internet runs on PHP? Wordpress, Drupal, Joomla, Facebook ad
  nauseum, not to mention Symfony, CakePHP, Code Igniter, etc.
  Administrators! Ach!
  
  Paul


[snip]

 
 This is just another example of how administration makes decisions. It
 would be nice if administration decisions were made with respect to
 what is best for the student as compared to this type of nonsense.

You know, I never had much respect for academia (no offense, Tedd;
that's not aimed at you), and this just confirms my contempt.
Administrators tend to completely lack common sense. And professors tend
to be arrogant and suffer from a lack of understanding of the real world
and real people. Add to this the skyrocketing cost of higher education.
Particularly when many of the things learned in school are either
unnecessary or could be learned just as well by the diligent student
through books and research on the internet. (Incidentally, when I was a
kid, my best friend's father was a university professor. Brilliant
economist who hated tenure.)

And from what I've seen, even at the primary level, decisions are rarely
made on the basis of what is best for the student. We're dealing with
this currently with my granddaughter (11 years old). The only saving
grace of the whole system appears to be individual teachers who manage
to look past all the crap and hold the line for students. 

What a pity.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Day after Friday

2012-09-22 Thread Paul M Foster
On Sat, Sep 22, 2012 at 01:05:51PM -0400, Tedd Sperling wrote:

 Hi gang:
 
 I know it's the Day after Friday, but I'm asking a off-topic question anyway 
 -- sorry.
 
 Normally, I teach a PHP class at the local college, but it got canceled 
 (don't ask why) -- now I'm teaching Java.
 
 So, can anyone recommend a Java list that is similar to this list?

Off off topic...

Who the hell cancels a PHP class? Do they not realize damn near the
whole internet runs on PHP? Wordpress, Drupal, Joomla, Facebook ad
nauseum, not to mention Symfony, CakePHP, Code Igniter, etc.
Administrators! Ach!

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Bounce messages

2012-09-21 Thread Paul M Foster
On Fri, Sep 21, 2012 at 08:40:23AM +0100, Lester Caine wrote:

 I know that the php list are one of the 'reply to sender' email
 handling camp rather than reply to list. I can cope with that now
 and handle the multiple reply address problem this end so I ONLY
 reply to list. BUT is there no way of cleaning up the bounce emails
 we all get when posting to the list(s)?
 
 ( Waits to delete all the bounce messages for this post :) )

Not seeing bounce messages here.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Re: Programmers and developers needed

2012-09-18 Thread Paul M Foster
On Tue, Sep 18, 2012 at 11:02:41AM -0700, Daevid Vincent wrote:

  -Original Message- From: Matijn Woudt
  [mailto:tijn...@gmail.com]
 
  You're missing the most important aspect of social networks..
  Advertising.
 
 Please tell me that is said sarcastically. Advertising is the cancer
 of the internet. There was a time when there weren't ad banners,
 interstitials, pop-ups, pop-unders, spam, and all the other bullshit
 you have to sift through on a daily basis. 

I might add to this that one of the reasons I switched to using Google
for internet searches many years ago was precisely this. All the other
search portals at the time blasted you with ads. Google's search page
was just a blank and the name Google, much as it is now. (Though I think
Google has now become its own kind of evil.)

And now I'm seeing more and more pop-up ads on websites all the time.
I'm trying to read content and every little while I have to banish some
pop-up or another. Grrr.

Here's another massive evil: Web pages that take forever to load. Why?
Because they have ads and other content being served up from other
sites. It takes forever for the page to fully paint because of
congestion at *other* sites which are supposed to be serving up
content/ads to the page I'm visiting. Yeah, that's not annoying or
anything. In fact, I've gone so far as to force my computer/browser to
believe most common providers of ad content are localhost, making
most requests for ad content yield 404 errors.

I bought TiVo partially so I could skip ads. I've revelled in it every
day since. I can watch an hour-long program in 47 minutes. (Though this
is a sad commentary on television and cable content providers.)

Yes, ads are Evil(tm).

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] The end of mysql

2012-09-08 Thread Paul M Foster
On Fri, Sep 07, 2012 at 09:58:38PM -0400, Jim Giner wrote:

 So with the announced end of the mysql functions (and switching to a
 different extension), one would think that my isp/hoster would be a
 bit more interested in my dilemma.  I tried today to create my first
 mysqli-based test script and found that I didn't have that
 extension.  A series of emails with my tech support told me that the
 shared server farm does not get mysqli - only their business
 servers.  Since I dont' have a need for and want to pay more for a
 'business server', I'm told I'm s... outta luck.
 
 Any idea on the approximate date when mysql truly goes away - ie,
 when is the proposed (next) update that will completely refuse to
 recognize it?  Might be ammunition for me.

Please excuse my ignorance. I feel like I just stepped into the middle
of a conversation. What's this about announced end of the mysql
functions? Who exactly announced what, and is there a link to whatever
announcement somewhere?

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] FoxPro Table Structure

2012-08-28 Thread Paul M Foster
On Tue, Aug 28, 2012 at 10:46:24AM -0400, Floyd Resler wrote:

 Is there a way in PHP to get the structure of a FoxPro table (using
 ODBC) without having to query the table?  I know I can get it by
 getting a row from the table and using odbc_field_type but I'd rather
 not have to query an entire table since there is no LIMIT command in
 FoxPro.  I've looked and looked and haven't found a solution.
 
 Thanks!  Floyd

FoxPro tables have a header which details the structure of the rows
which follow it. I've never written PHP code to do what you're asking,
but I did write a C program which will detail the header, dump the
records, output the table as SQL and a variety of other things,
depending on the command line switches. I generally use it *with* PHP,
using a system() call, capture the results, and then display them on
screen as needed. The code is on SourceForge. See:

http://noferblatz.com/dbfsak.php

If you download the code and need help, just let me know. I believe the
command line switch you're looking for is -i, as in:

dbfsak -i mytable.dbf

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Cost of redirect and site domain switch? Good Practice / Bad Practice / Terrible Practice

2012-08-18 Thread Paul M Foster
On Fri, Aug 17, 2012 at 01:35:11PM -0600, Tristan wrote:

 So, I need to change from somedomain.com to somenewdomain.com
 
 I was thinking of doing this
 
 1) create an alias to the site somenewdomain.com to point to current server
 2) run permanent 301 redirect from somedomain.com to somenewdomain.com
 
 
 I was thinking this was a clean safe way to do it so we dont have to run a
 global find replace.
 
 Concerns might be but, I don't know for sure?
 
 1) SEO
 2) processing / time / cost for the 301 redirect on any old
 somedomain.comrequests
 
 
 What do you guys think?

I can comment on part of this based on what I was recently told by an
SEO company. Let's assume you've got a bunch of SEO goodness
(recognition, Google search placement, etc.) going for you on site1.com.
If you a permanent redirect (301) to site2.com, all that SEO goodness
will transfer straight across to the new site.

You may take this with whatever grain of salt you like, considering it
comes from an SEO company and I consider SEO companies almost uniformly
liars and ripoff artists who generally have no earthly idea what they're
talking about. In this case, what they're saying makes sense to me, and
I suspect it's true.

Paul


-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Cost of redirect and site domain switch? Good Practice / Bad Practice / Terrible Practice

2012-08-18 Thread Paul M Foster
On Sat, Aug 18, 2012 at 05:10:39PM -0400, Daniel Brown wrote:

On Aug 18, 2012 4:49 PM, Paul M Foster [1]pa...@quillandmouse.com
wrote:

 I can comment on part of this based on what I was recently told by an
 SEO company. Let's assume you've got a bunch of SEO goodness
 (recognition, Google search placement, etc.) going for you on
[2]site1.com.
 If you a permanent redirect (301) to [3]site2.com, all that SEO goodness
 will transfer straight across to the new site.

 You may take this with whatever grain of salt you like, considering it
 comes from an SEO company and I consider SEO companies almost uniformly
 liars and ripoff artists who generally have no earthly idea what they're
 talking about. In this case, what they're saying makes sense to me, and
 I suspect it's true.
 
��� That doesn't sound right to me.� If so, I'd presume a lot of folks
would be doing that as a service.� I have several PR6-8 domains myself,
and could see how someone (not me) might say, since I'm really not using
these domains anyway, I'll 301 to a paying customer for them to include
their ranking.� If for no other reason than I haven't heard of folks
doing this (read: SPAM), I'd guess it's not true.
 
��� Still, other folks are far more knowledgeable than Yours Truly when it
comes to SEO.� Just for good measure, I've CC'd one (Thiago Pojda) to see
if he'd be interested in chiming in on the matter.

[grin]

Well, what I didn't say in my original email was why this came up with
the SEO company in the first place (and part of why I think SEO
companies have no idea what they're talking about).

We had built a website for a customer, and then they called in this SEO
company to advise them. The SEO company insisted on a 301 permanent
redirect at the top of every page of the site. From what domain to what
domain, you may ask. From www.yourdomain.com to yourdomain.com. I kid
you not. The theory being that the SEO goodness from
www.yourdomain.com would transfer to yourdomain.com, if someone came in
from a www.yourdomain.com link somewhere. Seriously. Never mind that for
years, DNS zone files have been routinely set up so that www.example.com
is a DNS alias for example.com, and so it was in this case as well.
Besides which, does anyone imagine that the spiders and evaluation
engines for bright companies like Google and Yahoo might actually think
that www.example.com and example.com have completely different content? 

I can also say that, on some of these pages we built, there were forms
which emailed the surfer's responses to someone at our customer's
company. And the extraneous 301s at the top of these form pages
apparently interfered with the functionality of these pages. When the
301s were removed, we ceased to have complaints from our customer
regarding the forms.

Like I said, take it with whatever grain of salt you like. And if
someone more knowledgeable than the rest of us says otherwise, take
their word for it instead.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Two ways to obtain an object property

2012-08-15 Thread Paul M Foster
On Wed, Aug 15, 2012 at 09:28:28AM +0100, phplist wrote:

 This relates to a minor dilemma I come across from time and time,
 and I'm looking for advice on pros and cons and best practice. Last
 night I encountered it again.
 
 Within a site I have a User object, and within page code would like to have
 if ($crntUser-isASubscriber) {...}
 
 There seems to be two ways to handle this:
 
 I can have a User object method getSubscriberStatus() which sets
 $this-isASubscriber. But to use this I would have to run the method
 just before the if statement.
 
 Or I could have a method isASubscriber() which returns the result,
 meaning the if statement should be
 if ($crntUser-isASubscriber()) {...}
 
 While this is last night's specific example, I seem to face the
 method-setting-variable or the method-returning-result-directly
 decision quite often.
 
 Is either of these approaches preferable, or does it simply not matter?

If I read you correctly, the latter would be preferable, primarily
because it involves one less step. But if you're going to have to make
that decision in an if statement repeatedly, I'd probably say:

$isSubscribed = $crntUser-isASubscriber();

just because in subsequent code, you're not suffering the (admittedly
small) repeated overhead of the function call.

But in answer to your question, isASubscriber() would be a pretty
standard getter method to expose internal object properties.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Re: What do you call the end-user?

2012-07-24 Thread Paul M Foster
On Tue, Jul 24, 2012 at 10:12:34AM -0500, Shawn McKenzie wrote:

 On 07/19/2012 12:26 PM, Tedd Sperling wrote:
  Hi gang:
  
  I can't wait for tomorrow -- so here's my off-topic post today.
  
  First question:
  
  What do you call the people who ultimately use your code?
 
 Many times I would call them dumb asses.  Especially many of the users
 of free software.  Even with clear detailed user guides and the fact
 that it is free, they are indignant about a missing feature or having to
 look in the docs for anything.

Very true. Also, apparently in some quarters, free == worthless. But
in the case of FOSS, nothing could be further from the truth.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Re: [PHP-WEBMASTER] Re: [PHP] The Cat Signal

2012-07-20 Thread Paul M Foster
On Fri, Jul 20, 2012 at 09:04:30AM +0100, Lester Caine wrote:

 Paul M Foster wrote:
 Here's another one: There are currently discussions in the U.S. Congress
 in favor of forcing internet vendors to charge sales tax on*all*  sales,
 regardless of whether the vendor has a presence in that state or not.
 Imagine having to file state sales tax returns in 50 states. This effort
 has rather significant bipartisan support. Now ask yourself what large
 corporation with brick and mortar stores *wouldn't* sign on to support
 this one? That's what you're up against. You've got Amazon.com on your
 side. Yay. You might want to get busy on that one.
 
 In Europe VAT is applied even on on-line sales. It is the likes of
 Amazon shipping bulk stock from overseas 'clients' into European
 warehouses and then supplying them without VAT added directly in
 Europe that is the problem! How can I compete with someone who is
 also giving next day delivery, but 20% cheaper ... American sellers
 are one of the problems here.
 
 There are two sides to every problem and simply fighting for one
 side is as bad. What is needed is a reasoned debate rather than
 things like 'The Cat Signal' which personally I find as
 objectionable as the laws it's complaining about!

The real problem is the VAT tax itself. In my opinion, VAT is worse than
direct income tax. The only good thing about VAT is that you
(presumably) don't have to file returns with every state/province
involved.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] What do you call the end-user?

2012-07-19 Thread Paul M Foster
On Thu, Jul 19, 2012 at 01:26:50PM -0400, Tedd Sperling wrote:

 Hi gang:
 
 I can't wait for tomorrow -- so here's my off-topic post today.
 
 First question:
 
 What do you call the people who ultimately use your code?
 
 I call them the end-user, but others have stated other terms, such
 as customer or user.

User, because I'm writing the code for *my* customer. The person
actually exposed to my code may or may not be a customer of anyone. They
may simply be an internet surfer at my customer's site.

 
 Second question:
 
 Are you concerned with their (whomever) experience in using your
 code? 
 
 This question transcends your code working correctly, accurately, and
 securely -- no need to comment on those aspects. But rather more
 specifically do you consider how easily your whomever can use your
 work efforts?
 
 As you may have guessed - I just attended a UX conference and they
 provide an interesting perspective on UX. I was wondering how php
 developers typically address the subject.

I'm interested in user experience to a limited extent. My interest stops
when a user wants the code to wipe their nose for them. Can we make the
website automatically update our accounting system and then write a
check for the cost of goods to the vendor? Sure. How much money do you
have? (Their accounting system is some inscrutable pile of Windows COM
objects, like SAP, behind a firewall. And they don't even know which
vendor to write the check to. I guess mental telepathy is a part of the
PHP libraries not installed on my development system.) Or when someone
sends the form on the website for an appointment request, can you make a
reminder pop up on all the desktops in the office? No, I can't. Here's
an idea: assign someone to check the email for appointment requests
throughout the day, and contact the customer to confirm, based on you 
actually *looking* at your appointment calendar. Sheesh. Apparently,
computers (not mine) are capable of performing magic tricks.

I think my screens should be fairly self-explanatory, if possible. But
I'm averse to making them idiot-proof. If you're an idiot, get someone
else to operate your computer for you. You shouldn't be using one. But
there may be times when a computer screen or set of screens will
absolutely require some training, rather than someone completely
unfamiliar with the workings of the office just sitting down and being
able to guess how to operate the system. You didn't learn to drive by
just sitting in a car and guessing how it is done. Don't expect a
web-based application to be operable simply by guessing, necessarily.

By the way, I'm quite happy to write documentation for systems.
Unfortunately, more than half the people who read anything can't
actually *apply* what they read to whatever system they're working with.
Supposedly they can read. But somehow they still need someone to explain
it to them, no matter how good the docs are.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Re: [PHP-WEBMASTER] Re: [PHP] The Cat Signal

2012-07-19 Thread Paul M Foster
On Thu, Jul 19, 2012 at 03:45:46PM -0400, Jeff Burcher wrote:

 Hi,
 
 I have been out of the loop and just did some quick skimming of SOPA/PIPA to
 see what all the fuss was about. PIPA seems a little vague, but SOPA seems
 pretty straight forward, stop piracy of copyrighted materials. I don't
 understand what is wrong with that?

Here's another one: There are currently discussions in the U.S. Congress
in favor of forcing internet vendors to charge sales tax on *all* sales,
regardless of whether the vendor has a presence in that state or not.
Imagine having to file state sales tax returns in 50 states. This effort
has rather significant bipartisan support. Now ask yourself what large
corporation with brick and mortar stores *wouldn't* sign on to support
this one? That's what you're up against. You've got Amazon.com on your
side. Yay. You might want to get busy on that one.

Governments and large corporations are about power and *control*. The
internet is the antithesis of this. So expect their efforts to control
some or all of the internet to continue until they succeed.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] What do you call the end-user?

2012-07-19 Thread Paul M Foster
On Thu, Jul 19, 2012 at 06:57:53PM -0400, admin wrote:


[snip]

 
 LOL Paul,
   You are so very spot on, I have a current customer who would like
 the website to just load when he logs in. I wish I had not agreed to writing
 him a startup script to load the interface for him because NOW he wants it
 to auto login for him. They use a random key generator as a portion on their
 login authentication. So let's see: The system sends you a report every hour
 on the hour. You no longer have to navigate to the interface. It auto logs
 into the system for you.
 
 I pander to these kind of people like there is no tomorrow when they are the
 ones who sign the check, because anything outside of scope cost BIG TIME. :)
 I have gone so far to create training aids that are system mimics to explain
 to them what they are doing wrong and what the next step is. I use to write
 SCO compliant learning systems and let me tell you there is NO such thing as
 idiot proof.

My wife and I were discussing something tangential to this the other
day. When people are young, they engage in all sorts of silly things
that waste time. But when you get older, your time becomes progressively
more valuable to you. In this case, I wouldn't want to waste my time on
what you describe. I don't care how big the check is. I have too many
other more important things to do with my time.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Creating drop-down menus

2012-07-17 Thread Paul M Foster
On Wed, Jul 18, 2012 at 08:45:34AM +1200, James Newman wrote:

 Just to put my 2cents in, you might want to try jQuery if you're going to
 go down the AJAX road.

JQuery is a LOT of code to include if you're just going to do an AJAX
call or two. There are examples of doing straight AJAX with Javascript
on the 'Net. Once you work through them, you find that there's a
static part that you can include in all the files you want to make
AJAX calls. And then there's the part that deals directly with the data
you get back from whatever PHP or other script is feeding you data from
outside the website. That's the part that needs custom work. I *hate*
Javascript, but I managed to figure it out.

Another point: I'm not sure if it's the same for other people. I'm on a
crappy little computer running Linux. I've got a little CPU meter in my
taskbar. And nothing jacks that meter up like Javascript. I don't know
why, but Javascript just devours CPU on my computer. The more
javascript, the worse. And like I said, JQuery is a LOT of code. This is
one of the reasons I tend to code things in PHP instead of Javascript.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] PDO: extend or encapsulate?

2012-07-13 Thread Paul M Foster
On Fri, Jul 13, 2012 at 12:06:22AM -0500, tamouse mailing lists wrote:

 It's Friday, so...
 
 Yes, it's true, I have just started looking at using PDO instead of
 mysqli -- a bit behind the times...
 
 My question at this stage, is do people tend to extend the PDO class
 for their own use, or encapsulate it in a class (or do most people use
 it mostly in procedural code?)

I encapsulated it in my own database class. One reason for that is that
the PDO class is really two classes, which is fine for low level
drivers but not production code that I have to use daily. A second
reason is that many of the methods are not really necessary in a
production environment. I want to limit the methods my code uses to
interact with the database. Third, I wanted to handle errors and
exceptions with my own methods, more suitable to the code I write. For
example, a fatal error should only, but always, be issued if the
database code is given something illegal to chew on. Anything else, like
a failure to return the expected result, should simply yield some sort
of sentinal value or something. If *my code* ever gives the database
library something illegal to chew on, then it should only be because of
my bad code, not because a user managed to somehow get bad data through.
That is, my code should always catch illegal data before it ever gets to
the database library. Fourth, encapsulation means that I can have the
class itself carry around some of the data that I would normally have to
explicitly pass around among functions. This way, I make that useful
data (like the number of records returned from the last fetch), part of
the payload of the class itself.

Extension is tricky and requires a more subtle and refined knowledge of
the classes involved. Besides, it exposes methods which I would prefer
not be used by my code. Encapsulation limits the methods of the classes
to just what I deem necessary and no more. I can always write new
methods if I need them.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Entry point of an MVC framework

2012-07-12 Thread Paul M Foster
On Thu, Jul 12, 2012 at 10:21:21PM +0200, Simon Dániel wrote:

 Hi,
 
 I have started to develop a simple MVC framework.
 
 I have a base controller class which is abstract and all of the
 controllers are inherited from that. Every controller contains actions
 represented by methods. (E. g. there is a controller for managing
 product items in a webshop, and there are seperate actions for create,
 modify, remove, etc.) There is also a default action (usually an index
 page), which is used when nothing is requested.
 
 But what is the best way to invoke an action? I can't do it with the
 baseController constructor, becouse parent class can't see inherited
 classes. And I can't do it with the constructor of the inherited
 class, becouse this way I would overwrite the parent constructor. And
 as far as I know, it is not a good practice to call a method outside
 of the class, becouse the concept of operation of the class should be
 hidden from the other parts of the application.

While I have a progressively growing dislike of frameworks, I'll give
you the following advice from what I've observed in other frameworks:

Normally, you build a controller class elsewhere which inherits from the
base controller class. Let's say it's a controller for blog entries.
Now, you populate the (child) controller with the methods you'll need
for each action. Like a method to delete blog entries. A method for
adding blog entries. Etc.

At that point, you have to decide if you're going to use server
redirection or standard URLs to get to your controller. That is:

http://mysite.com?controller=blogaction=add

or

http://mysite.com/blog/add/

The latter method is preferred by those who believe there's such a
mythical beast as pretty URLs preferred by search engines (there
isn't). It requires the use of .htaccess files and Apache's mod_rewrite,
which you may not have in a shared hosting environment.

Hopefully that helps.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Entry point of an MVC framework

2012-07-12 Thread Paul M Foster
On Thu, Jul 12, 2012 at 02:44:12PM -0700, Daevid Vincent wrote:

  -Original Message-
  From: Simon Dániel [mailto:simondan...@gmail.com]
  Sent: Thursday, July 12, 2012 1:21 PM
  Subject: [PHP] Entry point of an MVC framework
  
  I have started to develop a simple MVC framework.
 
 Yeah! Just what PHP needs, another MVC framework
 
 NOT.

And here's why Daevid is right. I've been having to work with Symfony, a
well-known framework. Nothing against Symfony, per se. It's much like
other frameworks. However, here's the kicker-- if you make an unknowing
mistake with Symfony (feed it the wrong data at the wrong time), you get
the most beautiful 23-file deep stack trace. Trying to track down why
this parameter (which I didn't even give Symfony) is making it barf is
pure torture. I'm having to wade through deep Symfony code to figure it
out. Object after object instantiating other objects, magic methods,
virtual classes, design pattern classes, etc. I didn't write any of this
code, but I've got to wade through 23 files of it to figure out what the
heck went wrong. And, oh by the way, if you don't call ./symfony cc
(which clears its internal cache) at the right time, you're screwed and
you'll never know why.

Don't get me wrong. MVC is a great idea. It's a good way to divvy up
your code. But frameworks which enforce the paradigm have a way of
getting carried away with themselves. I think a lot of the people who
write them try too hard to impress other programmers with the cleverness
of their designs. By the time they're done, there are hundreds or
thousands of files involved. Every page load has to call in a
significant portion of those files, full of deep, obscure classes. Sure
*looks* kewl. But it's about 15 levels deeper than it has to be.
Remember, this is the web, folks. Your application has a lifetime of
one page load, unlike the platform-native accounting program, which
you're liable to keep open on your desktop all day.

I prefer to develop shallow classes which deal with specific aspects of
page handling (dates, databases, encryption, users, etc.). Then use
those as part of the toolkit, assembled (again on a shallow basis) in
a loosely MVC pattern.

If I make a mistake, I should be able to isolate where it is within an
hour (ideally much less). And be able to go to the specific class and
method involved.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Entry point of an MVC framework

2012-07-12 Thread Paul M Foster
On Fri, Jul 13, 2012 at 12:26:33AM +0200, Timmy Sjöstedt wrote:


[snip]

 
 The Controllers also doesn't care if the data is stored in MySQL,
 Postgres, in RAM or on butterflies or anything else, as long as data
 is returned in an expected format.

I can attest that attempting to store data on butterflies is
exceptionally difficult. You really want to isolate that in your models.
Fortunately, the herding_cats design pattern works equally well with
butterflies.

(Welcome to Friday, half a day early! ;-)

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] disabled cookies

2012-06-04 Thread Paul M Foster
On Sun, Jun 03, 2012 at 10:21:21PM +0100, Ashley Sheridan wrote:

 
 
 Al n...@ridersite.org wrote:
 
 Disabled cookies use to be a problem years ago.  What's your
 experience these days.
 
 I need it for my session ID. As I read the docs, the old method of
 appending it to the URL is a security issue.
 
 I can obviously save the ID in a temp file which can be read by all
 the pages needing it.
 
 Al
 
 -- PHP General Mailing List (http://www.php.net/) To unsubscribe,
 visit: http://www.php.net/unsub.php
 
 There is a new law been passed in the UK that makes non-essential
 cookies opt-in only, so you must get permission in order to use them.

Good lord. I'm glad the U.S. Congress has not gotten together to pass
laws about how we build websites here. I'm not sure I could take
less-than-bright government bureaucrats telling me how to do the job of
programming. No offense, Ash, but you can keep your parliament.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Open Call: Official PHP Mirror

2012-06-02 Thread Paul M Foster
On Fri, Jun 01, 2012 at 04:50:03PM -0400, Daniel Brown wrote:


[snip]

 
 Who should not apply?
 
 Third-party sponsors, those who want to try to run the mirror from
 their Blackberry, people without servers located in the respective
 country for which they're applying, shared hosting clients, Droids,
 Borg, Klingons, Romulans, toddlers, and the gum disease known as
 gingivitis.

There I was, ready to volunteer, until I saw Romulans. Geez, a few bad
apples spoiling it for the rest of us. Crap. ;-}

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Happy Diamond Jubilee everyone!

2012-06-01 Thread Paul M Foster
On Fri, Jun 01, 2012 at 06:44:17PM +0100, Ashley Sheridan wrote:

 This is a bit of a shameless plug, but it is a Friday and a pretty
 special weekend over here.
 
 I recently got to work on something a bit fun at work in my spare time
 and they liked it so much that it got used internally to celebrate the
 jubilee weekend.
 
 This is the result http://jubilee.themlondon.com 
 
 For those of you interested, the leg-work is done by a bunch of PHP
 scripts run in the background via cron, split into 3 tasks:
 
 
  1. A script goes out and searches Twitter for tweets that mention
 the jubilee, one instance per keyword and records those to a DB
 to limit the draw on the Twitter API
  2. A second script goes over those tweets and pulls in all the
 non-default profile images for each unique user
  3. Lastly, the image is built as 12 separate tiles every half hour,
 using PHP and GD to match the average colour of each profile pic
 to a spot on the image, and then these are stitched together for
 the final image
 
 Anyway, hope you guys all have a great weekend, more so if you're
 unlucky enough to be working over the whole 4 days :-/

*Very* nice work!

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Re: Function size

2012-05-30 Thread Paul M Foster
On Tue, May 29, 2012 at 11:40:25PM +0200, Matijn Woudt wrote:

[snip]

 On Tue, May 29, 2012 at 11:06 PM, Paul M Foster pa...@quillandmouse.com 
 wrote:

[snip]

 
  I think a lot of coders try to be kewler than the next 18 guys who are
  gonna have to look at the code, so they use a lot of compression
  techniques to reduce LOC. Plus, they're lazy. I'd rather see everything
  with lots of spaces and plenty of comments and blank lines. Especially
  since I'm sometimes that 18th guy to look at the code.
 
  Paul
 
 Paul,
 
 Are you stating here that compression is a bad thing?
 
 That means you consider this nice:
 
 if ( action == A )
 {
 doA();
 }
 else if (action == B )
 {
 doB();
 }
 else
 {
 doC();
 }
 
 Or perhaps flooded with comments that merely say the same as the code does?
 
 I'd go for
 if(action == A)
 doA();
 else if(action == B)
 doB();
 else
 doC();
 
 or , if it's really that clean, i'd probably go for
 if(action == A)  doA();
 else if(action == B)  doB();
 else doC();

No, that's not what I mean. It's not necessarily compression in the
sense that the coder is taking up less actual space. It's hard to
explain, and I'm not good at it because I try not to do it. It's more
along the lines of using very terse and peculiar coding techniques to
save time and look kewl. Maybe something like this:

The long way:

$alfa = 0;
if ($bravo) {
if ($delta)
$alfa = echo();
elseif ($foxtrot)
$alfa = golf();
}
elseif ($hotel) {
$alfa = india();
}

The kewl way would be to translate the above into a single expression
using solely multiple nested terniary operators ( ? : ) on a single line.
Nothing wrong with the functionality of the result, but it becomes hard
has hell to read and figure out what the code is trying to do. And
nothing against terniary operators. I use them where appropriate. But in
a complex conditional like the above, they really only serve to
obfuscate the meaning of the code. We might marvel at the skill of a
programmer who did such a thing, but he's obviously not looking down the
road at the other people who will later maintain his code.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Re: Function size

2012-05-30 Thread Paul M Foster
On Wed, May 30, 2012 at 04:31:12PM +0200, Sebastian Krebs wrote:


[snip]

 
 If the functions were named properly you don't have to follow every
 execution path to the deepest deep. Or do you reading PHPs C-source, just
 because a wild substr() appeared? When you see a method loadFromFile()
 and the IDE tells you, that it expects a $filename as parameter, why should
 you jump there just to make sure, that the method loads something from a
 file by the filename given as first parameter?

Here's why, and I've seen this happen a *lot*. The function may be
properly named, but have side effects. Or the guy who named the function
*thought* it was properly named, but was wrong. For example, he may have
named the function loadFromFile(), and the function does in fact do
that. What the name doesn't tell you is that it then erases the file
from which it pulled. Oops! No, you're correct, the function is *not*
properly named in that case. But the guy who wrote it thought it was.
And before I look at the internals of the function, I don't know whether
it's properly named or not. Worse, the side effects may not show up
until later, and then with disasterous results. Imagine assuming
everything's okay, patching your code into the system, and finding out
that it's been hacking up the customer's filesystem for the last three
weeks. All because you didn't check to see what that other function was
*actually* doing.

Rule: NEVER assume you know what a function is doing by looking at its
name. ALWAYS satisfy yourself that you know what a function is doing by
*looking* at what it's doing.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Re: Function size

2012-05-29 Thread Paul M Foster
On Tue, May 29, 2012 at 08:52:46AM +0100, Tony Marston wrote:

 On May 21, 2012, at 8:32 PM, tamouse mailing lists wrote:
   A rule of thumb is no more than 50 lines per
  function, most much less. Back in the day when we didn't have nifty
  gui screens and an 24 line terminals (yay green on black!), if a
  function exceeded one printed page, it was deemed too long and marked
  for refactoring.
 
 I think the idea of setting an arbitrary limit on the number of lines that a
 function should contain is quite ludicrous and something which I will
 completely ignore. If a function requires a hundred or more lines then so be
 it. The only reason to take a block of code and put it into its own function
 is when that code is likely to be called more than once so that it conforms
 to the DRY principle. If it is only ever used in one place then there is no
 point.
 
 The problems I have with creating lots of small used-only-once functions is
 as follows:
 - you have to create a meaningful name for each function.
 - all those functions should be arranged in alphabetical order within their
 containing file - having them in a random sequence makes it difficult to
 find the one you want.

OMG in alpha order?! At best, I might group them together by function
type, with some comment notation in the file. But not alpha order. I
prefer not to have forward declares in my files, so I generally
arrange functions so that those called by other functions later are
defined before they're called. (Probably a holdover from my C days; PHP
doesn't care.)

No offense. I never even thought about arranging functions in
alphabetical order. But I don't think I'd do it.

 - when browsing through the code you have to keep jumping to another
 function, and then returning to where you came from.
 
 I don't know about you, but I would rather use the scroll wheel on my mouse
 than keep jumping from one position in the file to another.
 
 Another problem I have encountered in the past with such an idea is that it
 encourages a stupid programmer to decrease the number of lines of code by
 compressing as many statements as possible into a single line, which then
 makes the code less easy to read and understand. This is much worse than
 having more than 20 lines in a function.

I think a lot of coders try to be kewler than the next 18 guys who are
gonna have to look at the code, so they use a lot of compression
techniques to reduce LOC. Plus, they're lazy. I'd rather see everything
with lots of spaces and plenty of comments and blank lines. Especially
since I'm sometimes that 18th guy to look at the code.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Function size

2012-05-29 Thread Paul M Foster
On Tue, May 29, 2012 at 11:56:47AM -0400, Tedd Sperling wrote:

 On May 29, 2012, at 10:20 AM, Stuart Dallas wrote:
 
  -snip- Besides, truth is subjective, but then so is everything,
  including that assertion.
  
  -Stuart
 
 You reply was longer than my monitor was high so I can't give an
 immediate reply -- I have to scroll. :-)
 
 However, with that said, you made good points and I don't disagree
 with any of them.
 
 As for me, I was speaking from my experience where the size of my
 functions over the last few decades has grown (up to a point) with my
 increasing monitor size. However, my eyesight has not improved and
 thus should be figured into this somehow.
 
 As I said before, mine is just an observation that supports the limits
 in reception/comprehension articles I have read.
 
 I think your 24 line terminal vs the 30 monitor argument is a valid
 one, up to a point. But I think the problems (if any) would depend
 upon many factors -- too numerous to elaborate here.
 
 But let me pose an idea. 
 
 When I was in college, my degrees were in Geology. My Summer Field
 study (6 weeks) was to map out Geologic outcrops on a USGS topographic
 map. At the end of the study, all maps that matched the Professors'
 maps, were given the highest grades (mine the highest in all modesty).
 Not because they were alike, but because they approached the truth
 of the matter. The truth here was not subjective for there was only
 ONE defining truth and that could be discovered by detailed mapping.
 We all (including the Professors) approached the same problem in the
 same way and reached similar results. The closer to the truth, the
 more similar the maps.
 
 Over the years I've seen programming languages converge producing
 single solutions for common tasks, such as a FOR loop and IF
 statements. These seem to be universal constructs in programming
 logic. So my question is, as in my Geology study Is this convergence
 in programming logic discovering the truth of the task? Do you see
 what I mean?
 
 If so, then maybe the way we break down problems into smaller subsets
 might also be approaching an optimum method as well. I used to use
 (30+ years ago): 1) Input; 2) Calculation; 3) Display; as the main
 categories in my division logic to tackle problems and that was long
 before I heard of MVC.
 
 So, what I am saying is that we might all be approaching and
 contributing to an overall optimal logical solution in programming.
 Kind of an ant-colony think sort of thing. The solution is certainly
 not simple, but it might be an universally single solution to all the
 problems we perceive.
 
 Said only for Food for thought.

About 30 years ago, a guy wrote an essay about architectural
stablization or somesuch. He was a computer guy who had written a whole
office suite for 8 bit computers (called Valdocs, written for the Epson
QX-10 computer, for you voracious learners). His point was that this
phenomena was recognizable in many fields involving technology. For
example, the architecture of automobiles eventually stabilized in such a
way that these days, they pretty much all have steering wheels used for
steering, four wheels, two headlights, etc. I think mainstream
programming languages have probably done a lot of stabilization over the
years. You do occasionally find weird languages like Lisp/Scheme, but in
the main, most languages bear strong resemblance to C and Fortran.
They're geared for slightly different environments or purposes, but
syntactically, they bear strong resemblance to each other, compared to,
say, APL or Lisp/Scheme. And to some extent they model how most people
(programmers) would naturally approach the solution of programming
problems.

(Of course, there are always the oddballs like me who still prefer
reverse polish notation on our calculators. Go figure.)

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] PHP: a fractal of bad design

2012-04-11 Thread Paul M Foster
On Wed, Apr 11, 2012 at 05:06:10PM -0700, Daevid Vincent wrote:

 http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/
  
 Can't say he doesn't have some good points, but he sure goes about it in a
 dickish way.

Wow. I wish I could find something that complete for Javascript.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Swiftlet is quite possibly the smallest MVC framework you'll ever use.

2012-02-13 Thread Paul M Foster
On Mon, Feb 13, 2012 at 09:01:03AM +0100, Simon Schick wrote:

 Hi, Paul
 
 I personally pretty much like the idea of auto-loaders, but that's a
 personal point of view.
 If you have always develop with scripts having autoloaders you'll hate to
 write a *require_once* command at the beginning of all files. And what
 would a dependency-injection-container be without an autoloader ;)
 http://www.slideshare.net/fabpot/dependency-injection-with-php-53

I wrote a quite solid dependency-injector one time, and used it for a
while. But it introduced a certain opacity into my code that I didn't
like very much, and I ultimately abandoned it, even though it worked
quite well.

It's kinda like in C. If I want to use the strchr() function, I know I'd
better do an #include string.h to get that functionality. I can't just
assume all the library functions are all just there, waiting for me to
use them. While I've often complained about having to include those
header files to get to those functions, I still prefer having those
include calls obviously staring at me at the top of my files. I don't
have to *assume* it's there somewhere. I can see it right there, and it
comforts me.

Maybe all this is my C upbringing

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Swiftlet is quite possibly the smallest MVC framework you'll ever use.

2012-02-12 Thread Paul M Foster
On Mon, Feb 13, 2012 at 09:24:38AM +1100, Elbert F wrote:

 Hi Simon,
 
 I think you're right that I may be abusing the constructor a bit. I'm going
 to follow your suggestion and split it up into smaller functions. I'm also
 thinking of moving the set_error_handler and spl_autoload_register
 functions to index.php where Swiftlet is bootstrapped so they can be
 changed.

I didn't look thoroughly at your code (though, if the respondent's
perceptions were correct, I'd have to agree with his prescriptions for
improvement). But I wanted to make a comment about autoloaders, since
you mentioned it.

My philosophy, since autoloading was introduced, was that it was a cool
way to avoid having a lot of complicated file inclusion calls all over
the place. Just tell the autoloader function where different types of
files were located, and then just instantiate classes as you like. Easy.

But I recently did some work for one of these companies with a million
file internally developed framework. And at the top of each file, they'd
include a require_once() (or similar) call for each of the files which
would be called if you needed to instantiate a class from any of those
files. So rather than putting all the magic in an autoloader function,
they'd simply include the file where they knew it would be needed.
(E.g., you know you're going to be calling your Date class in this file,
so you put a require_once() call to the file that contains it at the top
of this file.)

The more I've thought about it since then, the more I've considered it a
Good Thing(tm). It makes troubleshooting existing code a whole lot
easier. I don't have to wonder what the autoloader is doing or where the
files are, on which the current file depends. It sort of obviates the
autoloader stuff, but I'd rather do that than spend hours trying to
track down which file in which directory contains the class which paints
the screen blue or whatever. (Yes, I'm aware that require_once()
introduces some latency.)

Just something to consider.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: Re: Re: [PHP] What's Your Favorite Design Pattern?

2012-02-08 Thread Paul M Foster
On Wed, Feb 08, 2012 at 02:25:00PM +, Tim Streater wrote:


[snip]

 
 Mmmm. Well, at this point I feel underwhelmed - but its entirely
 possible that I'm missing something profound [1]. 


Not really. 

 After looking at some of the reviews of the book you mention on
 Amazon, I might be inclined to get a simpler intro.

Um, yeah. It's very meta. 

(That's what I love about The C Programming Language. It's a little
over half an inch thick in paperback, explains the whole language
clearly and concisely, and has barely been revised since 1988. I'm not
sure you could ask for more in a technical book.)

 
 [1] In June 1982 (or was it '83?) I visited PARC with a small group
 from SLAC. We saw the Star or whatever it was, with bit-mapped display
 and mouse pointer. Whoosh !! (Well, to be fair, we'd gone along to
 look into XNS).
 

I remember working for Xerox (copy center employee) around that time,
and seeing all kinds of talk in the company materials about *Ethernet*.
They explained the basic protocol and compared it to token ring, and I
just thought, Hmm, yes, that seems like a pretty clever way to go about
networking.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Arrays: Comma at end?

2012-02-07 Thread Paul M Foster
On Tue, Feb 07, 2012 at 11:50:45AM -0800, Micky Hulse wrote:

 Was there ever a time when having a comma at the end of the last array
 element was not acceptable in PHP?
 
 I just did a few quick tests:
 
 https://gist.github.com/1761490
 
 ... and it looks like having that comma ain't no big deal.
 
 I can't believe that I always thought that having the trailing comma
 was a no-no in PHP (maybe I picked that up from my C++ classes in
 college? I just don't remember where I picked up this (bad) habit).
 
 I would prefer to have the trailing comma... I just can't believe I
 have avoided using it for all these years.
 
 Thanks!
 Micky

I've always avoided trailing array commas, but only because I was under
the impression that leaving one there would append a blank array member
to the array, where it might be problematic. Yes? No?

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: Re: [PHP] What's Your Favorite Design Pattern?

2012-02-07 Thread Paul M Foster
On Tue, Feb 07, 2012 at 09:02:00PM +, Tim Streater wrote:

 On 07 Feb 2012 at 19:34, Daniel Brown danbr...@php.net wrote: 
 
  On Tue, Feb 7, 2012 at 13:56, Mike Mackintosh
  mike.mackint...@angrystatic.com wrote:
  I was curious to see what everyones favorite design patterns were, if you 
  use
  any, and why/when have you used it?
 
  Choices include slots and signals (observer), singleton, mvc, hmvc, 
  factory,
  commander etc..
 
 Mine is apparently CPSV (Commentless Procedural Spaghetti Vomit),
  as that's what I encounter no less than 80% of the time in the wild.
 
 Since I have no idea what anyone is talking about, I can only conclude that 
 you're playing Mornington Crescent (q.v.), on a non-standard board.
 
 --
 Cheers  --  Tim
 

Design Patterns are Way Nifty Kewl patterns of code which are supposed
to facilitate certain types of operations. (Was that sarcasm you
detected? Yes it was.)

For example, the Singleton pattern. Let's say you had a configuration
class that held the configuration values for your application, and you
wanted to make sure there was only one object of that class
instantiated, no matter how many times it was called in your code. You'd
arrange the code and call the class in a certain way to ensure that only
one object of that class resulted. To make your configuration class a
singleton, you'd probably make the class have a *private* constructor
(so no outside routine could call it), and then provide a method called
get_instance() which tested for the existence of an object of that
class. If such an instance was found, someone calling
configuration::get_instance() would simply get the existing object
returned to them. Otherwise, configuration::get_instance() would
instantiate the class and then return the new object to the caller.

As you can see, that's a peculiar way of setting up your code for a
specific purpose. Other design patterns do other things and dictate
setting up things in other ways.

The definitive work on this (and where it first gained the most
publicity) is a book called Design Patterns by four authors (Gamma,
Helm, Johnson and Vlissides). It essentially contains a chapter about
each (known at the time) design pattern and some pseudocode about how it
might be constructed. I imagine the authors looked at a lot of code and
discovered that programmers were coming up with code that, in each case
was remarkably similar for solving certain types of programming
problems. So they codified what that found and wrote a book about it.

I have the book on my shelf, and it's decent technology, but you could
spend your whole career and never use any of it, and get along just
fine. 

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Paul M Foster
On Mon, Feb 06, 2012 at 02:28:42PM -0600, Donovan Brooke wrote:

 Paul M Foster wrote:
 This is sort of obliquely related to PHP.
 
 I don't have a smart phone, but I need to know a couple of things:
 
 1) Do smart phones use the same browsers as the desktop, or do they have
 their own stripped down versions of browsers?
 
 2) When a browser broadcasts its header telling the server what kind of
 browser is involved, do they broadcast anything in the header to
 indicate that they're being run on a smart phone?
 
 3) Bonus question: Is there a preferred method amongst coders to
 determine what type of environment is being browsed from, so as to serve
 up the proper type of page (desktop or smart phone version of a
 webpage)?
 
 Paul
 
 Hi Paul, I think this is a great PHP conversation.. and I don't
 understand why GOTO threads always get way more replies than
 something like this ;-)

See religion (n), defs 1-10.

 
 Diverse User Agent compatibility is going to be more and more of a
 challenge for us.. gone are the days of a few known browsers that
 are viewing our sites.  From bots, to browsers, to mobile devices,
 to game UA's, to app UA's.., to IE's stubborn outlook on the web...
 the idea of user experience is growing complicated! ;-)

Well, cursory research shows there are at least 12 different major
layout engines underneath modern browsers. Multiply that by versions of
same, different OSes on which each run, versions of the OSes themselves,
etc. etc. etc. I don't envy the job of any piece of code which tries to
analyze all this. Plus, I believe that in the future, handhelds
(specifically smart phones) will approach desktops in screen
resolution.

 
 I really liked Mari's posted link to the a list apart blog about
 responsive web design using media query (CSS).. however, it
 seems to me that it takes the use of many languages and techniques
 in many cases to get the job done... user agent serving (using PHP
 or JS or alike), flexible CSS and web design, and a keen eye on your
 target audience may all play apart.

Not to mention that W3C has all but abandoned its efforts to standardize
HTML5. They will likely follow the path of browsers in simple de facto
standardization.

 
 However, this is a PHP list.. and I think we can better approach
 this topic by limiting our scope to talk about how PHP could be
 useful.
 
 My first question, being that my first language is not PHP, is; is
 their any core PHP mobile detection functions/tools that exist?

From what I've seen, only the get_browser() function, which depends on
the existence of a browsecap file, which may or may not be installed on
your system. And if it is, it's 300K in size, and introduces significant
latency to page loads as a result.

 
 I have a running list of mobile UA's that I picked up somewhere that
 I often use and edit to distribute content accordingly. I also have
 a PHP mobile detection script that I picked up somewhere. I'm sure
 these things can be found via google as well. The problem, as Mari's
 link suggests, is that UA list's and browser sniffing scripts need
 maintaining quite regularly, since mobile UA's are being added on a
 weekly basis perhaps.

I suspect that's more as a result of everything sniffer scripts do. They
don't just detect the platform, but a variety of other things as well.

 
 Many of my projects do some PC UA (browser) sniffing.. especially
 for IE., as IE has it's own system that it uses for how to render
 content.
 
 Anyway, I'm happy to share what I have.. but like I said, PHP is not
 my first language, so I am interested to see what the more
 established PHP'ers may have to say.

How about this: those of you with iPhones, Androids and the like, point
your phones at a page which reports $_SERVER['HTTP_USER_AGENT'] (like a
page which runs the phpinfo() function), and post what you get back from
that exercise and what device made the query. I'd like to see if there
is anything significant which indicates handheld platforms.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Paul M Foster
On Mon, Feb 06, 2012 at 09:02:34PM +, Ashley Sheridan wrote:

[snip]

 
 
 Keeping a PHP angle to this, have you looked at using an up-to-date
 browscap.ini file with PHP? Basically, you can use that to read in the
 raw user agent string from the browser, and it then finds a matching
 entry in the ini file and gives you back some values about what it can
 assume about that device, such as whether it is known to support Java
 (although this is something you should be careful of, as it only tells
 you if it's is supported, not if there is an available JVM), if it is a
 mobile or search bot, what version of CSS it should support, etc. I use
 it myself in a personal web stats script, and as long as you keep the
 copy of the ini file recent, you should be OK.

The issue with this (according to the get_browser() docs) is that the
browsecap file is 300K long, will get longer, and significantly slows
loading of your applications. Moreover, the parsing of the UA string and
other data is far more extensive than anything I'd want or could use.
The only thing I'd want to know is whether I'm serving pages to a
handheld or desktop device.

From what I've seen, pages built for handheld devices (see, for example,
yahoo.mobi) are considerably stripped down, often with no CSS styling.
For now, if I have to make the decision on whether to serve up desktop
or handheld versions of a page, all I want to know is a yes or no answer
to the question of, Is this a handheld? The native PHP get_browser()
function appears to be overkill for that, and may, in fact be
insufficient.

That was the origin of the original questions-- was there some
definitive way of knowing the platform when the page request came in.
And from all the research I've done, the answer is, No. The UA string
may not work as intended. There are javascript sniffers and CSS
triggers, but neither are they definitive. For example, the CSS
triggers test for resolution or screen width or the like. This is fine,
so long as handhelds remain at crappy resolutions. But I don't expect
that to be the case forever. 

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Paul M Foster
On Mon, Feb 06, 2012 at 04:04:28PM -0500, Adam Richardson wrote:

On Mon, Feb 6, 2012 at 3:50 PM, Adam Richardson [1]simples...@gmail.com
wrote:
 
  On Mon, Feb 6, 2012 at 12:58 AM, Paul M Foster
  [2]pa...@quillandmouse.com wrote:
 
This is sort of obliquely related to PHP.
 
I don't have a smart phone, but I need to know a couple of things:
 
1) Do smart phones use the same browsers as the desktop, or do they
have
their own stripped down versions of browsers?
 
  Both, although more and more smart phones join the ranks of the
  desktop-quality browser every day (iPhone and Android both have very
  capable browsers, with the iPhone's omission of flash support being the
  biggest difference between these two.)
  �
 
2) When a browser broadcasts its header telling the server what kind
of
browser is involved, do they broadcast anything in the header to
indicate that they're being run on a smart phone?
 
  Yes, but that gets complicated quickly:
  [3]http://www.zytrax.com/tech/web/mobile_ids.html
  �

This gets directly at the answer, but also proves that there's no
practical way of using the information. There are simply too many
variations, and more to come. Great reference. I didn't find it in my
prior research on Google.

 
3) Bonus question: Is there a preferred method amongst coders to
determine what type of environment is being browsed from, so as to
serve
up the proper type of page (desktop or smart phone version of a
webpage)?
 
  To supplement the alistapart link already mentioned, here's another
  recent writeup:
  
 [4]http://dev.opera.com/articles/view/how-to-serve-the-right-content-to-mobile/
 
Apologies, I sent the wrong link last time:
[5]http://dev.opera.com/articles/view/the-mobile-web-optimization-guide/
Adam

Thanks,

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Paul M Foster
On Mon, Feb 06, 2012 at 09:01:45PM +, Stuart Dallas wrote:

 On 6 Feb 2012, at 05:58, Paul M Foster wrote:
 
  This is sort of obliquely related to PHP.
  
  I don't have a smart phone, but I need to know a couple of things:
 
 There are simulators available for most smartphones.
 
  1) Do smart phones use the same browsers as the desktop, or do they
  have their own stripped down versions of browsers?
 
 The trend is certainly moving towards full desktop capability, but
 personally I still think that if you expect a significant amount of
 traffic from mobile devices then your site should adapt accordingly.
 
  2) When a browser broadcasts its header telling the server what kind
  of browser is involved, do they broadcast anything in the header to
  indicate that they're being run on a smart phone?
 
 Yes, but there's no standard at the moment so detection requires
 something similar to https://gist.github.com/1124666. That code is
 pretty old, and I can't remember where I got it, but at the time it
 worked really well.
 
  3) Bonus question: Is there a preferred method amongst coders to
  determine what type of environment is being browsed from, so as to
  serve up the proper type of page (desktop or smart phone version of
  a webpage)?
 
 Generally speaking you're better off with a design that automatically
 adapts to the viewport on which it's being displayed. While there's
 more than one reason for this, the overriding reason is that the same
 software (i.e. the same user agent) could be running on any size of
 device, from watch to huge flat panel screen on a wall.
 
 I think the world needs to move on from is it a mobile device or not
 to accepting the reality which is that the browser / OS is irrelevant,
 and that the way your site renders should be purely based upon the
 size of the display. Responsive designs such as that described in the
 A List Apart article Mari posted are fantastic tools for achieving
 this goal.
 

I'm inclined to agree.

In fact, my daughter, who owns an iPhone, hates the mobile-only webpages
and will normally opt to see the full (desktop) website, even on her
iPhone. She'd rather gesture around the original website than see a
vastly simplified version with everything vertically stacked, as it
often is on strictly mobile sites.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



[PHP] Headers on smart phone browsers

2012-02-05 Thread Paul M Foster
This is sort of obliquely related to PHP.

I don't have a smart phone, but I need to know a couple of things:

1) Do smart phones use the same browsers as the desktop, or do they have
their own stripped down versions of browsers?

2) When a browser broadcasts its header telling the server what kind of
browser is involved, do they broadcast anything in the header to
indicate that they're being run on a smart phone?

3) Bonus question: Is there a preferred method amongst coders to
determine what type of environment is being browsed from, so as to serve
up the proper type of page (desktop or smart phone version of a
webpage)?

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Variable Troubleshooting Code

2012-01-09 Thread Paul M Foster
On Mon, Jan 09, 2012 at 10:42:59AM -0500, Marc Guay wrote:

  some pretty natives php functions exists to do the job :
 
 But how many times in my life will I have write echo pre; ???
 Does anyone have a handy solution? (Make this the default behavior?
 Add a even more human-readable flag to the function?  Create a
 simple macro in Aptana 3?)

I have an init file that I include in every site that contains a few
routines I use over and over. One such is:

function instrument($legend, $var)
{
print $legend . br/\n;;
print prebr/\n;
print_r($var);
print /prebr/\n;
}

I use this routine wherever I want to see what's going on. It formats
(particularly) array output so that I can read it, instead of having
everything look like JSON, which is much harder to read.

Feel free to use the above yourself as needed.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] PDF Printing instead?

2012-01-05 Thread Paul M Foster
On Thu, Jan 05, 2012 at 03:14:58PM -0500, Jim Giner wrote:

 ok - somebody has advised that I should not be trying to print to a printer 
 from my website php script.
 
 The suggestion of creating a pdf and sending to the client was made.  How do 
 I install the pdf functions?  I've never had to install a package before or 
 is that something my hoster does? 
 

The fpdf and/or tcpdf libraries are the standard answers to this. The
fpdf library is more primitive, but if your needs are simple, it's
considerably less bulky than tcpdf. Installation on either one should
be very simple, as in, download the package, put it in a subdirectory,
read the documentation, and start.

I use fpdf constantly for printing invoices, reports, etc. Once you've
built a PDF (by following the instructions for the specific package),
dump it in a subdirectory and provide a link to it on a webpage. The
user can then simply click on the link and their browser will open it
and provide the native (usually Adobe Reader) interface for viewing and
printing it.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Way to output HTML on professional websites

2011-12-26 Thread Paul M Foster
On Tue, Dec 27, 2011 at 12:46:29AM +0100, Florian Müller wrote:

 
 Hi guys
 Just a little question: I've programmed some nice little websites up to 
 25'000 lines of code.
 Now if I see some bigger websites just as facebook and so on, how are they 
 printing their website out?
 Does it work like 
 ?phpecho htmlhead...;?
 or do they output it like
 ?phpif (true) {?body
 /body?php} else { ?head
 /head?php}?
 Or is the code even generated or gotten from a database and evaluated?
 How does the website itself gets printet on really professional websites?
 Thanks for answer!

You're asking for an opinion. In mine, if you have to call fifty files
before printing a byte to screen, you've introduced too much complexity.
I just finished up five weeks at a company where they were calling
probably upwards of 100 files before printing anything on screen.

It ought to be like this:

body
?php if ($condition): ?
h1Some text/h1
Other stuffbr/
Much other stuff.br/
?php endif; ?
/body
/html

That said, a lot of CMS-based sites use some sort of templating engine.
Those go like this:

body
{{if condition}}
((h1:Some text}}
Other stuffbr/
Much other stuff.br/
{{endif}}
/body
/html

... with PHP or some other language decoding the pseudo-HTML above and
displaying it. Kind of a waste, in my opinion, though a lot of people
swear by templating systems. Again, my opinion, they're lazy typists.

In any case, I think you'll find that most CMS based site presentations
are based on templating engines, though I could be wrong.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



[PHP] Question regarding passwords/security

2011-12-22 Thread Paul M Foster
Not sure how to ask this question... I've always eschewed consulting a
database on page loads to determine if a user is logged in, primarily
because of latency issues. For example, you could store a nonce like the
session ID in a table for a user when they log in. Then each time they
arrive at a page which needs certain permissions to access, you'd check
the table for the nonce and compare it to the actual session ID or
whatever to determine that they're properly logged in. This seems
reasonable but suffers from the lag on the database link's
query-and-response lag time. So I've always preferred some solution
where something is dragged along in a session cookie instead. Maybe
something like the hash of user login, email and user name, which
wouldn't be there unless you'd put it there on login. But this latter
scheme just seems inherently less secure than consulting the table.

Is there any concensus or overwhelming argument one way or the other?

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Re: Question regarding passwords/security

2011-12-22 Thread Paul M Foster
On Thu, Dec 22, 2011 at 12:55:41PM -0500, Al wrote:

 
 
 On 12/22/2011 10:05 AM, Paul M Foster wrote:
 Not sure how to ask this question... I've always eschewed consulting a
 database on page loads to determine if a user is logged in, primarily
 because of latency issues. For example, you could store a nonce like the
 session ID in a table for a user when they log in. Then each time they
 arrive at a page which needs certain permissions to access, you'd check
 the table for the nonce and compare it to the actual session ID or
 whatever to determine that they're properly logged in. This seems
 reasonable but suffers from the lag on the database link's
 query-and-response lag time. So I've always preferred some solution
 where something is dragged along in a session cookie instead. Maybe
 something like the hash of user login, email and user name, which
 wouldn't be there unless you'd put it there on login. But this latter
 scheme just seems inherently less secure than consulting the table.
 
 Is there any concensus or overwhelming argument one way or the other?
 
 Paul
 
 
 Why not just use Sessions, that's what the function is for.
 http://php.net/manual/en/features.sessions.php There is a good example on 
 this page.
 
 I'm also big on using the session buffer to maintain the current
 states for visitors.  e.g., one I'm working on now. Obviously, most
 are binary switches. Makes condition logic simple.
 
 [confirmedRestrictedUser] =
 [idPassed] =
 [loggedIn] =
 [newRegRecordMode] =
 [pendingRestrictedUser] =
 [recordToken] =
 [regModeLoggedIn] =
 [regUserEditMode] =
 [restrictedMode] = 1
 [secrCodePassed] =
 [securityPassed] =
 [sessionStart] = Thu, 22 Dec 2011 12:49:54 -0500
 [userType] = restricted

I have concerns that the items in a session buffer can be copied and
used to spoof legitimate logins. This is harder to do when the info is
held in a database.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Finding and reading firefox bookmarks with PHP

2011-11-28 Thread Paul M Foster
On Mon, Nov 28, 2011 at 10:59:03AM -0500, David McGlone wrote:

 On Sun, 2011-11-27 at 22:20 -0500, Paul M Foster wrote:
  On Sun, Nov 27, 2011 at 06:47:36PM -0500, David McGlone wrote:
  
   Hi all, I am wondering if it's possible to find the bookmarks file in
   firefox and output the contents on a page with PHP.. I'm wanting to do
   this so I can use it as my home page.
  
  The answer to this is not in PHP; it can be done in Firefox by itself.
  It's been a long time since I set this up, but if I'm not mistaken, the
  procedure goes like this:
  
  1. In Firefox, enter about:config in the URL bar. (Ignore warnings.)
  2. You are now in the raw configs. Search for a key called
  browser.bookmarks.autoExportHTML. Set this to 2. This should cause
  Firefox to dump the contents of it places.sqlite file to a file called
  bookmarks.html when Firefox is closed.
  3. Find another key called browser.startup.homepage. Set this to the
  absolute path of a file called bookmarks.html in your Firefox file tree.
  The path will be something like (in Linux):
  /home/username/.mozilla/firefox/random string.default/bookmarks.html.
  (Obviously, you'll have to locate this file ahead of time.)
  
  If this isn't the exact procedure, it's close. You can dig into the
  Firefox docs to get the exact values or keys if these aren't right. (For
  example, I don't know why the first key I mentioned is 2 instead of 1.)
  
  Anyway, I have my Firefox set up this way.
 
 Hi Paul. The drawback I have found so far with this setup is that the
 page will not update until firefox is restarted. do you have a
 workaround for this?

Yeah, that's the rub. When I found the instructions for doing this, they
were clear that Firefox wouldn't update the file until the browser was
closed. Outside of that, you'd just have to read the actual SQLite file,
I suppose.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Finding and reading firefox bookmarks with PHP

2011-11-27 Thread Paul M Foster
On Sun, Nov 27, 2011 at 06:47:36PM -0500, David McGlone wrote:

 Hi all, I am wondering if it's possible to find the bookmarks file in
 firefox and output the contents on a page with PHP.. I'm wanting to do
 this so I can use it as my home page.

The answer to this is not in PHP; it can be done in Firefox by itself.
It's been a long time since I set this up, but if I'm not mistaken, the
procedure goes like this:

1. In Firefox, enter about:config in the URL bar. (Ignore warnings.)
2. You are now in the raw configs. Search for a key called
browser.bookmarks.autoExportHTML. Set this to 2. This should cause
Firefox to dump the contents of it places.sqlite file to a file called
bookmarks.html when Firefox is closed.
3. Find another key called browser.startup.homepage. Set this to the
absolute path of a file called bookmarks.html in your Firefox file tree.
The path will be something like (in Linux):
/home/username/.mozilla/firefox/random string.default/bookmarks.html.
(Obviously, you'll have to locate this file ahead of time.)

If this isn't the exact procedure, it's close. You can dig into the
Firefox docs to get the exact values or keys if these aren't right. (For
example, I don't know why the first key I mentioned is 2 instead of 1.)

Anyway, I have my Firefox set up this way.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Tutorial for the structure of an php-app ?

2011-11-26 Thread Paul M Foster
On Sat, Nov 26, 2011 at 01:38:28AM +0100, Andreas wrote:

 Hi again,
 is there a tutorial for the structure of an php-app?
 
 There are more than enough books and online docs that teach the
 basics of PHP and of course the native mysql commands.
 
 I'd now rather need a help to figure out how to pull up a wee bit
 more complex app.
 I know how to connect to a DB even though it might not be mysql. I
 can select stuff and dump it into a HTML table.
 Actually I prefer PDO and PostgreSQL.
 
 Is there a tutorial that teaches how to construct a app with a
 2-column design.
 E.g. a menue frame on the left and a bigger content area on the right.
 So a click on a menue item would dynamically display a form or a
 list in the content area.
 What is a good way to glue everthing together between login and logout.
 I know cookies and sessions and I suspect those were a way to do it.
 How would I integrate a template system like smarty?
 It weren't bad if there were clues about AJAX, too.
 
 I'm in search of a way to extend the knowledge about bricks, tubes
 and cables to the wisdom to actually build a house out of those
 things.

Aside from the fact that, yes, much of what you're asking for has to do
with the user interface and not PHP, there is no ONE way to build a PHP
app. PHP is flexible enough to allow you to do it any of a number of
ways.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] news and article posts in one table

2011-11-26 Thread Paul M Foster
On Sat, Nov 26, 2011 at 01:26:49PM -0600, Tamara Temple wrote:

 muad shibani muad.shib...@gmail.com wrote:
 
  i wanna to create one table that contains both news and articles posts,
  they have similar columns like id, title, content, and date but they are
  differ in one column = the source of news or article post
  article has  writers that have permanent names and pictures obtained from
  another table called writers that supposed to be  left joined with the news
  table, while news posts simply have a source as text like AFP
  or Reuters and so one.
  
  How I can solve this ?
 
 How you store things in tables can sometimes get a little tricky. One
 way to approach this is with normalized tables and using joins in your
 query like you are doing. To make this work, in your main entries table,
 have a field that indicates what the entry type is. If you are doing one
 select that gets both articles and news stories, having that extra field
 can help you distinguish what type it is, and which fields contain data
 in each record.
 
 (cf: Wordpress wp_posts table for an example of how this is done. They
 store posts, pages, and attachments in a single table this way. I can't
 say if this is a better arrangement than keeping them in separate
 tables.)

I've had to hack this table. It's a prime example of bad design. Take a
long look at the records of this table in an active blog, with a survey
of each of the fields and their values. You'll see what I mean.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Need help Wth PHP

2011-10-10 Thread Paul M Foster
On Mon, Oct 10, 2011 at 03:58:31PM -0700, Rod Lindgren wrote:

 Thanks for the info. Very helpful. I am working on it. 
 
 What is it that makes Wordpress valuable? The website in question is really
 pretty basic. I am trying to figure out the reason Wordpress was used. 

It allows the site owner to directly modify the site, without having to
call a programmer or web developer.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Multiple SQLite statements

2011-10-10 Thread Paul M Foster
On Mon, Oct 10, 2011 at 04:14:00PM +0100, Tim Streater wrote:

 I would like to use the SQLite3 (not PDO) interface to SQLite, and I
 would like to be able to supply a string containing several SQL
 statements and have them all executed, thus saving the overhead of
 several calls. It *appears* that this may be how it actually works,
 but I wondered if anyone could confirm that.
 
 --
 Cheers  --  Tim
 

The docs appear to agree that this is allowed. See:

http://us.php.net/manual/en/function.sqlite-exec.php

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Re: Secure data management

2011-10-07 Thread Paul M Foster
On Fri, Oct 07, 2011 at 12:46:52AM -0400, Govinda wrote:

  http://stut.net/2011/09/15/mysql-real-escape-string-is-not-enough/
 
 Hi everyone
 
 I have read many many articles and blog posts in the last few days to
 bolster my (still mostly newbie) understanding of the factors that
 play in to preventing various methods of SQL injection prevention..
 and by now I am well aware that most everyone (expert) here says
 prepared statements are the most secure method of (string hacking)
 SQL-injection prevention.. even to the point of saying that one common
 (and at least previously-popular) alternative
 mysql-real-escape-string is ..silly and technically insecure...
 
 I am learning and using the CodeIgniter (CI) framework for my current
 project and, not wanting to leave myself vulnerable, I read posts on
 the CI forum on this topic, to find out if I could (or needed) to use
 prepared statements in CI.. and I read one forum thread where one dev
 shows how to hack the core system of CI so that it can use PDO (for
 prepared statements) instead of the built-in ActiveRecord (or Query
 Bindings) which apparently rely on mysql-real-escape-string.  In that
 thread, the debate goes back and forth, as it does in other threads..
 and while the sentiment that prepared statements are better because
 they remove the need to keep being ahead of the char-escaping chase...
 I never did see any example of *how* mysql-real-escape-string fails.
 The only thing I ever read that does show mysql-real-escape-string
 possibly failing is in the example in this article:
 
 http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-string
 
 or rather an article referred to there, here:
 http://ilia.ws/archives/103-mysql_real_escape_string-versus-Prepared-Statements.html
 
 ..which only comes up in certain circumstances..  ([snip]..The bottom
 line while the problem is serious, it would only affect people
 changing character sets from single-byte encodings to multibyte ones.
 As long as you stay away from multibyte encodings, with the exception
 of UTF8 you should be safe...[snip]).
 
 All well and good.  I just wanted to understand, as a relative newbie,
 why such bold seemingly definitive statements are made here on this
 list in recent weeks, like .. escaping doesn't work.. ?
 
 http://marc.info/?l=php-generalm=131293616328301w=2
 http://marc.info/?l=php-generalm=131603743606025w=2
 
   Isn't it that it does work in most cases.. and one just needs to
   know in which cases it can fail, and how to handle things in each
   case?  I totally get the point that prepared statements just remove
   so much of the head pressure of sorting all this out.. BUT when
   someone (mostly new) like me comes along and hears that
   mysql-real-escape-string is simply not secure, then it just gives
   an unclear and incomplete picture, and creates more head pressure.
 
 Or is there definitive evidence, more recent than the above-mentioned
 articles, that shows how to hack through mysql-real-escape-string even
 in an SQL statement e.g. inserting into a UTF8 db, a properly escaped
 (mysql-real-escape-string) var?
 
 In case my post here is lacking understanding, then please forgive..
 and better yet, please explain!  I post/ask because I am wanting to
 SEE the whole everything like you few experts here who really know
 exactly what everyone is talking about (or when they are just groping
 in the dark).

There is more to SQL injection than getting the quoting correct. In my
understanding, prepared statements handles the other problems associated
with queries and SQL injection beyond just quoting. Here's a good
tutorial on how this works:

http://www.youtube.com/watch?v=bORZlmyDw0s

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] What determines your use of the type of DB framework/abstract?

2011-09-22 Thread Paul M Foster
On Thu, Sep 22, 2011 at 11:31:54AM -0700, Jamie Krasnoo wrote:

 Sorry, not sure if the first part of the conversation made it to the list.
 
 I will be looking in to Symfony. I'm well versed with ZF and Zend_Db.
 I'm also somewhat versed with Doctrine and integrating it with ZF. My
 question isn't whether Doctrine is a part *of* that framework but
 rather on *what* and *when* it is appropriate to *use* or *substitute*
 something like Doctrine instead of using straight pdo or mysqli or the
 abstract that came with that particular framework. Substituting
 Doctrine or some other abstract could complicate a project rather than
 help.

Doctrine is more than just an abstraction layer. Well, no, but it's also
an ORM framework. That alone would kill it for me.

I built my own wrapper around PDO, that I use whenever possible. Main
reason: it makes my interface the same, whether I'm using MySQL or
PostgreSQL. That simplifies things for me. Why not just use PDO? I think
PDO, for all its assets, has kind of a clunky interface. When I'm doing
work internally, I use PostgreSQL. But for customers, I'm generally
forced to use MySQL. So having the same interface for both (for the most
part) eases the work. As for ORMs, I'm old skool; my preference is to
use straight SQL where possible. I think it makes you think more
carefully about your database structure and the type of queries you do.
And sooner or later, ORM gets in the way of multi-table foreign-key
reliant queries.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Any free online tests to test my PHP knowledge?

2011-09-22 Thread Paul M Foster
On Thu, Sep 22, 2011 at 11:53:54AM -0600, Mike Hansen wrote:

 Does anyone know of a site that has an online test of PHP skills?
 I'd like to review my PHP knowledge.
 
 I've already run across this site:
 http://vladalexa.com/scripts/php/test/test_php_skill.html
 
 Thanks,
 
 Mike

I've had to take online PHP tests twice for recruiters. My beefs are 1)
they're not open book, and I code with a tab open to php.net all the
time. (Who remembers which parameter comes first on which function call:
needle or haystack?) 2) They never tell you *what* you got wrong. That's
not very helpful.

Mind you, these aren't free tests like you're probably talking about.
They are through a vendor whom the recruiter probably pays to administer
the test.

Incidentally, despite having written an awful lot of working PHP code, I
don't do well on those tests. Helps my confidence a lot, as you can
imagine.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: Re: [PHP] What would you like to see in most in a text editor?

2011-09-14 Thread Paul M Foster
On Wed, Sep 14, 2011 at 01:18:00PM +0100, Tim Streater wrote:

 On 14 Sep 2011 at 12:40, Richard Quadling rquadl...@gmail.com wrote: 
 
  On 14 September 2011 01:23, tamouse mailing lists
  tamouse.li...@gmail.com wrote:
  On Tue, Sep 13, 2011 at 3:35 PM, Robert Cummings
  rob...@interjinn.com
 wrote:
  I'm a big fan of editors that work in the terminal.
 
 You'll get my emacs when you pry it out of my cold dead hands.
 
 Pah! You and your full screen editor.
 
 EDLIN is the way to go.
 
 Is that more or less terse than TECO?
 
 Back in 1989 when I was
 at SLAC, they were just getting into unix, and debates were raging
 about which editor to standardise on and teach people (emacs, vi,
 jove, etc). Because this wasn't settled, I started using notepad (and
 later, dxnotepad) and got on with coding. Six months later, the
 debates were still raging. I then had an epiphany: I'd been using
 notepad for six moths  got work done. It took me 5 minutes to find
 out how to use it. I didn't need teaching about it or to have a
 manual. So IMO, emacs, vi, and all their ilk belong in the dustbin of
 history.
 
 --
 Cheers  --  Tim
 

I agree with you for the most part. I used to use Nano for this reason,
which tends to be available on any given system. But sometimes Nano
isn't available and/or is difficult to find/install. It offers very
little flexibility and, as far as I know, no capability to do add-ons.
It also doesn't do syntax highlighting, as far as I know.

I resisted Emacs because I'd have arthritis in short order from having
to deal with the plethora of control and alt keystrokes which don't make
mnemonic sense to me. Plus, it can be a massive.

Eventually I switched to Vim (counter-intuitively) because 1) there's no
*unix variant on which it's not available; 2) at some point, you're
probably going to *have* to know how to operate Vi if you move around
among foreign machines and networks; 3) there are many other
applications which use many of the same keystroke patterns which are
fundamental to Vi; 4) most keystroke combinations do not require leaving
the home row, etc.; 5) Vi easily does syntax hilighting and a variety of
other things, depending on add-ons.

The modal model of Vi/Vim is sometimes a pain in the ass. And yes, it
can take a long time to know all the features of Vim. But there are a
number of things I can do faster in Vim, than anyone else can do in
other editors, with less effort.

No attempt here to dissuade Emacers or others. Whatever floats your boat
and you're happy with, continue using. Why should you or I care what
someone else uses for an editor?

BTW, my big beef with online editors is latency, and it's a *huge*
problem, as far as I'm concerned. Ultimately this is why I wrote blog
software for myself which requires you to compose and edit your posts
locally, and then *upload* them to the blog. That, and the silly idea
that one should store huge masses of text in relation databases; large
masses of text should be stored as what they are-- flat files.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Code should be selv-maintaining!

2011-08-31 Thread Paul M Foster
On Wed, Aug 31, 2011 at 08:20:14PM -0400, Tedd Sperling wrote:

 On Aug 30, 2011, at 3:09 PM, Robert Cummings wrote:
 
  On 11-08-30 11:36 AM, Richard Quadling wrote:
  On 30 August 2011 15:04, Tedd Sperlingtedd.sperl...@gmail.com
  wrote:
  To all:
  
  I prefer the Whitesmiths style:
  
  http://rebel.lcc.edu/sperlt/citw229/brace-styles.php
  
  But style is really up to the individual -- what works best for
  you is the best (unless it's a team effort or the clients
  demand).
  
  Cheers,
  
  tedd
  
  At last Someone's code I could read without having to reformat
  it every bloody time!!!
  
  http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style
  
  You're just saying that so Tedd will be your friend!! Come now,
  let's be honest with everyone... Whitesmith's is -GLEE!
  ;)
  
  Cheers, Rob.
 
 No, not indenting braces is T
 LYY.
 
 Make things uniform -- a condition followed by indented code located
 between equally indented braces makes sense to me. 
 How people read
 other code styles is a mystery to me.

Indeed it is a mystery, a religious one. The way we do it is because we
finally broke through the clouds of earthly obfuscation to comprehend
the blinding truth that is KR. Amen.

(Nah, it wasn't Kool-Aid. Tasted more like a cross between RC Cola and
Dr Pepper.) ;-}

Paul


-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] PHP frameworks

2011-07-21 Thread Paul M Foster
On Thu, Jul 21, 2011 at 03:59:52PM -0500, Chris Stinemetz wrote:

 Hello all,
 
 I am thinking about venturing into PHP frameworks, but I would like to
 get advice on what the correct selection would be for someone that is
 about intermediate in PHP knowledge.
 
 Thank you,

Try CodeIgniter ( http://codeigniter.com ). It's a lightweight,
well-engineered framework with relatively transparent code (meaning you
can examine the source and see relatively easily what they're doing).
Documentation is some of the best out there.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] How to sum monetary variables

2011-07-18 Thread Paul M Foster
On Mon, Jul 18, 2011 at 11:22:00PM +0100, Tim Streater wrote:

 On 18 Jul 2011 at 23:00, Martín Marqués martin.marq...@gmail.com wrote: 
 
  I'm building a table (which is a report that has to be printed) with a
  bunch of items (up to 300 in some cases) that have unitary price
  (stored in a numeric(9,2) field), how many there are, and the total
  price for each item. At the end of the table there is a total of all
  the items.
 
  The app is running on PHP and PostgreSQL is the backend.
 
  The question is, how do I get the total of everything?
 
  Running it on PHP gives one value, doing a sum() on the backend gives
  another, and I'm starting to notice that even using python as a
  calculator gives me errors (big ones). Right now I'm doing the maths
  by hand to find out who has the biggest error, or if any is 100%
  accurate.
 
 Much safer to price everything internally in pence or cents or whatever, and 
 convert to £xxx.xx for external display. Then just use integer arithmetic for 
 the calculations.

Let me echo this. If you need precise arithmetic in an environment where
you're doing mostly adds and subtracts, store data as integers and do
your math that way. Only convert to decimal for display. If you're doing
multiplies and divides, do them with the multi-precision PHP functions.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Re: Re: Top Posting

2011-07-06 Thread Paul M Foster
On Wed, Jul 06, 2011 at 03:03:44PM -0400, Jim Giner wrote:

[snip]

 
 As for your solution to spam.  What is Postfix?
 

Postfix is a *nix program which can be connected to whatever program you
use to grab mail with. With postfix, you write recipes which dictate
what will be done with a piece of incoming mail, based on whatever
characteristics you choose. Think of it as the spam controls in Firefox
or Outlook, but on steroids. Typically, postfix will either drop a piece
of spam on the floor, mark it in some way your mail client will
understand, or file it an a separate folder. Moreover, it's not just for
spam. It can be used to filter out duplicate emails, file copies of
emails under different folders by subject, etc.

It also makes for a great car wax and salad dressing. ;-}

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Re: Re: Top Posting

2011-07-06 Thread Paul M Foster
On Wed, Jul 06, 2011 at 04:24:29PM -0500, Tamara Temple wrote:

 
 On Jul 6, 2011, at 3:19 PM, Paul M Foster wrote:
 Postfix is a *nix program which can be connected to whatever
 program you
 use to grab mail with. With postfix, you write recipes which dictate
 what will be done with a piece of incoming mail, based on whatever
 characteristics you choose. Think of it as the spam controls in
 Firefox
 or Outlook, but on steroids. Typically, postfix will either drop a
 piece
 of spam on the floor, mark it in some way your mail client will
 understand, or file it an a separate folder. Moreover, it's not
 just for
 spam. It can be used to filter out duplicate emails, file copies of
 emails under different folders by subject, etc.
 
 
 Actually, what you're describing sounds much more like procmail than
 postfix. Postfix is a MTA - Mail Transfer Agent, a replacement for
 Sendmail on Unix systems. It does SMTP and local delivery of mail,
 and can hook into procmail to further process mail for a given user.
 Procmail *can* act as a MTA, but only in the local context.
 

Well, DUH!

I can't believe I wrote this whole email about Postfix, while instead
carefully explaining what procmail was! Maybe I need more rest than I
thought.

My apologies for the waste of bandwidth. Tamara's explanation is exactly
correct.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Top Posting

2011-07-05 Thread Paul M Foster
On Tue, Jul 05, 2011 at 10:29:12AM -0400, ad...@buskirkgraphics.com wrote:

 Since this is the 3rd time I have been chewed out for top posting.
 
 Anyone know how to make Outlook changes its reply position.
 
 I am using outlook  2007 and I do not find an option for this.
 
 I have to scroll down to the bottom of the email and it considers that to be
 an adjustment to the original email , plus I have to manually write my
 signature block.
 
 Assuming this is what they mean about top posting!!!
 
 Richard L. Buskirk

As far as I know, you're stuck with exactly what you described. However,
you can make life easier both on yourself and the rest of us by snipping
content not relevant to your reply (that doesn't mean *all* preceding
content).

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Re: Top Posting

2011-07-05 Thread Paul M Foster
On Tue, Jul 05, 2011 at 10:48:34AM -0400, Jim Giner wrote:

 And besides - I'm sure there are PLENTY of people here who despise scrolling 
 thru endless repeated paragraphs from a long list of posts just to get the 
 the latest contribution to the topic.:)
 
 This newgroup may have its rules, but if bottom-posting was such a wise and 
 preferred method, why do millions of business users subscribe to a product 
 such as Outlook, that top-posts by default, to conduct their daily business 
 via emails flying back and forth with the latest post at the beginning so 
 that readers don't have to re-hash old news unless they want to? 

Seriously? That behavior is dictated by Microsoft and could be simply a
shortcut, making it easier on Microsoft. (They don't have to scan down
the email and place the cursor at the end of the email. They can just
put it at the top, easy-peasy.) Or it could have been dictated by Bill
Gates, who didn't want to scroll down. One thing's for sure: Microsoft's
rarely met a standard they liked or willingly followed. Business users
simply went along with this behavior, mostly because they had no
knowledge of anything else. It was the default behavior of the only
email client that came with their operating system. They learned to live
with it and even appreciate it.

My point is, I seriously doubt that business users (who were not the
original target audience for Outlook) dictated to Microsoft that they
arrange their email client so that the cursor defaulted to the top. And
by many accounts, Outlook (et al) is an appalling broken email client
for many reasons. Business users don't subscribe to the Microsoft
email client. It comes with their operating system for free and it
pretty much does what they want, even if it has gaping holes in it. Why
retrain and spend billions to install something else on every computer
in their company?

A similar question might be, if Unix/Linux is so great, why do millions
of business owners stick with Windows year after year? Answer: because
it comes with their computer and pretty much does what they want. And
Microsoft actively blocks, discourages and prevents the installation of
any other operating system on hardware from anyone they can possibly
control.

Questioning bottom-posting is one thing. Holding up the widespread
adoption of Outlook as a reason why top-posting is superior (because
business people demand it) is silly. No offense, but it's pretty weak
reasoning.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Create a hierarchical hash from flat source

2011-06-24 Thread Paul M Foster
On Thu, Jun 23, 2011 at 01:57:24PM -0400, Robert Cummings wrote:

 On 11-06-23 12:54 PM, Tamara Temple wrote:
 
 On Jun 22, 2011, at 5:24 PM, Scott Baker wrote:
 
 On 06/22/2011 03:17 PM, Simon J Welsh wrote:
 You still need to pass the value by reference to assign_children(),
 so:
 $new =$leaf[$pid];
 assign_children($pid,$list,$new);
 
 One last thing I fixed was that PHP was complaining that run-time pass
 by reference was deprecated. I changed assign_children to be
 
 function assign_children($id,$list,$leaf)
 
 Which solved that also!
 
 Ah, pointers, how we love them. The bane of every CS undergrad.
 
 Bane? I thought they were elegant :)

The way you know they're *not* elegant is that hardly any language since
C has included them. We worship at the alter of languages with garbage
collection. ;-}

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Doctrine madness!

2011-06-16 Thread Paul M Foster
On Thu, Jun 16, 2011 at 08:53:18PM -0400, Eric Butera wrote:

 On Thu, Jun 16, 2011 at 7:32 PM, Daevid Vincent dae...@daevid.com wrote:
 

[snip]

 
 I'm sorry but this is absolute rubbish.  I used to write my queries by
 hand, but over time you start to realize that perhaps, maybe writing
 out thousands of identical lines of code over hundreds of projects
 might not be an efficient usage of time.  If you have performant
 requirements, that is one thing and can easily be overcome with slight
 deviations on a case by case basis.  Most of the time, contrary to
 your position, things just need to work and be completed quickly.
 What is the more common question from clients: why is this so slow,
 or, client asks why is this not finished yet?

I generally side with Daevid on this, though my position isn't as
extreme. However, I have to take exception to the either/or question
from clients. As far as I'm concerned, clients need to learn that coding
takes as long as it takes. I'd much rather spend the extra time and
never have the customer ask why the code is so slow. The theoretical
alternative, having the customer satisfied with the delivery time, but
complain about latency, isn't what I'd consider acceptable.

Looking at some of the code that comprises most ORM and other frameworks
(but particularly ORM frameworks) the bloat is amazing.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Doctrine madness!

2011-06-16 Thread Paul M Foster
On Thu, Jun 16, 2011 at 06:50:00PM -0700, Daevid Vincent wrote:

[snip]

 
 Name me some LARGE popular sites that use frameworks?
 

I generally agree with your position, but I'm not sure about this one.
I'm too lazy/busy to do extensive research, but I believe that Joomla and
Drupal are used pretty extensively in the big website category. Of
course, if you ever want to do anything outside the Drupal/Joomla box,
you're looking at a helluva lot of work and time. I've been there
(briefly).

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



[PHP] Uncatchable errors

2011-06-13 Thread Paul M Foster
There's certain class of errors which happen before any error-handler
(set_error_handler) can catch them, like parse errors and such. Is there
a way to have these generate the same type of response as the errors
handled by set_error_handler()? In my case, the error handler emails me
a summary and trace of the error. Any way to have things like parse
errors do the same thing?

Pointers to prior threads would do fine.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Class not used as an object (Scope Resolution Operator)

2011-06-09 Thread Paul M Foster
On Thu, Jun 09, 2011 at 03:42:49PM -0600, George Langley wrote:

   Hi all. Am fixing some inherited code, and the previous coder created a 
 class, ie:
 
 class myClass {
   function doThis($passedVar) {
   doSomething;
   }
 
   function doThat($anotherVar) {
   doSomethingElse;
   }
 }
 
 BUT, I don't see anywhere where he created an object, ie:
 
 $myObject = new myClass();
 
 or
 
 $myObject = myClass::doThis(value);
 
   Instead, it's only ever just called directly with a Scope Resolution 
 Operator, ie:
 
 myClass::doThis(valueOne);
 myClass::doThat($whatever);
 myClass::doThis(valueTwo);
 myClass::doThat($andSoOn);
 
   It seems that this would be making an object, and then destroying it 
 again, on each of the four calls above, which I would think would be wasteful 
 - time, memory, cpu usage, etc.
   The class has no constants or variables (properties) for any need for 
 persistence, and is just a collection of functions (methods), so I don't see 
 a reason to group them into a class - they could all reside as independent 
 functions within the php file.
   Is this good? Is there some advantage to making a non-persistent class?
   Thanks!

I'm not real good with static stuff, but he's essentially using calls to
what are [being treated as] static methods inside the class. I'm not
sure this means an actual object is being created. There's certainly no
reason to create one.

If these methods truly have no persistent members within the class, then
I agree, they can simply be external functions. These may be grouped
this way for logical reasons, but if I have functions like this (which
relate to a class but don't depend on the class), I generally put them
in the class source file but outside the class. They become global as
soon as the source file is include()ed.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] phpsadness - P.C. shmee seee.

2011-06-05 Thread Paul M Foster
On Fri, Jun 03, 2011 at 01:52:15PM -0700, Daevid Vincent wrote:

 and I'm balding from Alopecia

Me too, but in my case, it's just 'cause I'm old. ;-}

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] phpsadness

2011-06-03 Thread Paul M Foster
On Fri, Jun 03, 2011 at 04:23:54PM +0200, Peter Lind wrote:

 On Jun 3, 2011 3:48 PM, tedd tedd.sperl...@gmail.com wrote:
 
  At 1:02 PM -0400 6/2/11, Daniel Brown wrote:
 
  On Tue, May 31, 2011 at 22:13, Bill Guion bgu...@comcast.net wrote:
 
 
   So if I understand, you want an explode() with empty parameters to
 explode
   the host machine?
 
 
 That's correct.  If it causes too much userland confusion, we can
  alias it as detonate() as well.
 
 
  Yes, to be preceded with:
 
  echo('Alaho Akbar');
 
 
 Nice ... any idea how many people you just insulted there?

I'm guessing no one with an actual sense of humor.

I suspect most people snickered at the joke and admired the chutzpah it
took to post it.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Announcing New PHP Extension: System Detonation Library (was: phpsadness)

2011-06-03 Thread Paul M Foster
On Fri, Jun 03, 2011 at 11:56:21AM -0400, Daniel Brown wrote:

 First of all, a happy Friday to all here.  Hopefully some of you
 will be able to pass this on to your boss and get sent home early.
 
 Second, as dreamed up in the previous thread, I've decided to take
 a few moments this morning to build and release a new PHP extension,
 which provides a single function: detonate().
 
 Third, you can read about it and download it here:
 http://links.parasane.net/29nh

+1!

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] phpsadness

2011-06-02 Thread Paul M Foster
On Thu, Jun 02, 2011 at 01:02:26PM -0400, Daniel Brown wrote:

 On Tue, May 31, 2011 at 22:13, Bill Guion bgu...@comcast.net wrote:
 
  So if I understand, you want an explode() with empty parameters to explode
  the host machine?
 
 That's correct.  If it causes too much userland confusion, we can
 alias it as detonate() as well.

It would be so hilarious if this made it into the docs as a (spoof)
command. I could see some n00b skimming over the docs and going, Wait,
what--?

Oh-- how about if the detonate() command just echoed a series of tick
strings to the web page? Can't you just imagine the frantic tech support
calls from n00b PHP coders to the tech support departments of their
hosting companies? Oh crap oh crap! Pick up the phone already! Oh
crap I'm so busted!

Reminds me (obliquely) of an entry in the index for The C Programming
Language for recursion, which points right back to that index page. I
about doubled over when I first discovered it.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] iPhone sadness

2011-05-29 Thread Paul M Foster
On Sun, May 29, 2011 at 12:50:36PM +0100, Lester Caine wrote:

[snip]

 
 There IS no right way - but it IS polite to follow the rules even if
 it is a little more difficult doing it from your chosen software.
 Rather than apologising or simply ignoring the guide lines.

I would imagine that interleaved replies or bottom posting will never be
considered offensive on any list. Whereas we all know that top posting
can often be considered offensive, depending on the list.

By the way, bottom posting only really becomes offensive when you fail
to trim as needed.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] simple question abt convert to integer

2011-05-24 Thread Paul M Foster
On Wed, May 25, 2011 at 08:57:18AM +0430, Negin Nickparsa wrote:

 $id=(int)$_POST['txt'];
 $query1=select * from patient where id=.$id.;

You're not *thinking* about what you're doing. The above is silly. Think
about it: you're sending a string to MySQL. If $_POST['txt'] returns a
string which looks like the number 1, then

$query1 = select * from patient where id = $_POST[txt];

should suffice. If you like, test $_POST['txt'] first by echoing it.


 echo $query1;
 $result1=mysql_query($query1);

Ideally, you should be calling this function with an added connection
parameter. Like this:

$link = mysql_connect($connection_stuff);
$result1 = mysql_query($query1, $link);

It's not *necessary*, but advisable.

mysql_query() returns a resource object, unless there is a problem. If
there is a problem, then it returns FALSE. You can check what it returns
this way:

if (is_resource($result1))
print It's a resource!;
elseif ($result1 === FALSE)
print It's false!;
else
print I don't know what the heck it is!;

 
 echo $result1;

I don't know what you'll get from this echo if $result1 truly is a
resource. But if it's false, you won't get much. $result1 should be a
resource object, which means it's opaque. You can't know what's in it
unless you use a helper function like mysql_num_rows(), etc.

 $num2=Mysql_num_rows($result1);
 $num3=Mysql_num_fields($result1);
 
 still it has previous error
 
 Here is my output:select * from patient where id=1
 *Warning*: mysql_num_rows() expects parameter 1 to be resource, boolean
 given in
 
 *Warning*: mysql_num_fields() expects parameter 1 to be resource, boolean
 given in **

Your error messages clearly mean that 1) you're not getting a proper
resource object back from mysql_query(), or 2) you're somehow changing
$result1 into a boolean before passing it to these other functions. But
I suspect it's #1 above.

Please see the documentation for these functions at php.net. It may
even be available in your native language.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] A Review Request

2011-05-20 Thread Paul M Foster
On Fri, May 20, 2011 at 02:32:42PM -0400, tedd wrote:


[snip]

 
 And I agree with the majority that your bracing style is horrid. But I
 long ago despaired of turning you from the Dark Side(tm). ;-}
 
 I understand, but like my wife often says Bite me  :-)

OMG! She must be related to *my* wife! ;-}

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] A Review Request

2011-05-19 Thread Paul M Foster
On Wed, May 18, 2011 at 03:22:35PM -0400, tedd wrote:

 Hi gang:
 
 I am considering providing PHP code to the general public via my website
 
 This is my first attempt:
 
 http://sperling.com/php/authorization/
 
 What do you people think?

I've always been a fan of your site(s). It's been annoying from time to
time that the code making a certain example work wasn't available. Here,
it is.

As pointed out, there are security and other issues. But since I know
what kind of code you can produce, I realize you left these issues in
place because you were getting at a different point.

And I agree with the majority that your bracing style is horrid. But I
long ago despaired of turning you from the Dark Side(tm). ;-}

Making professional coding techniques visible to others can only be a
good thing. I've been doing this for a while, but I'm still interested
in how other people do these things. I never know when I might learn
something.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Consistent Class Renaming (Simple Refactoring)

2011-05-16 Thread Paul M Foster
On Mon, May 16, 2011 at 11:05:07PM +0200, Tony Mak wrote:

 Hi there,
 
 i have following problem:
 
 Assume we have a cron.php which is called every hour by a cron
 job. This cron.php should then be used to execute other php-scripts
 script1.php, script2.php.
 
 For a pitty our server has Safe-Mode activated so we arent able to
 shell_exec / exec those files. So we came up with the idea: Lets
 include those scripts using include(). But this lead us to another
 problem: Namespace conflicts (our server is running php 2.7.2)
 especially with classes and constants.

Pretty sure you're *not* running PHP 2.7.2. If you are, give up now.

 
 Example:
 script1.php
 ?php
 class A {
   public function test(){ echo im class A at script 1; }
 }
 ?
 
 script2.php
 ?php
 class A {
   public function test(){ echo im class A at script 2; }
 }
 ?
 
 cron.php
 ?php
 
 include('./script1.php');
 include('./script2.php');
 ?
 
 
 Cron.php will raise a cannot redefine class A error.

Well of course, you would get that error. But I'm completely lost beyond
that point. Why must both scripts use the same class names in them? Why
not call the class in script2.php B instead of A? I'm guessing you
left out a huge piece of explanation here.

 
 So my idea is to continously rename every occurence of class names
 and constants in the scripts by adding a suffix (ie. class A_123 and
 class A_234). Do you have an idea how to implement this during the
 deployment step?

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



[PHP] Running PHP5 in a PHP4 environment

2011-05-12 Thread Paul M Foster
I recently installed some code written for a PHP 5 environment on a
server which I thought was running PHP 5. It was a form which should
have painted at least something to the browser window. But instead, I
got a complete blank page. Come to find out that the server was actually
running PHP 4.

I've seen PHP do this before-- trying to run PHP 5 in a PHP 4
environment causes it to do every step up to the point where it sees
future code it doesn't understand. Then it just stops, no errors, no
panics, no nothing.

Is this expected behavior, or am I missing something? It seems like if
the PHP interpreter hit some future code it didn't understand, it
would issue a syntax warning or something similar. Is there some way I
can squeeze some identifiable error code out of PHP 4 to indicate it's
hit PHP 5 code it doesn't understand?

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



[PHP] Using SQLite without hosting support

2011-05-03 Thread Paul M Foster
Assume you have a hosting account with PHP5 support, but no SQLite
support. Yes, supposedly SQLite support is standard for PHP5, but
there's no law that keeps someone from compiling PHP5 without SQLite
support.

So assuming that's the case, given that SQLite is a pretty simple
product, is it possible to run PHP5 and use SQLite, even if support for
it is not built in? The dl() function has some restrictions on it which
might prohibit its use, so is there some way to use SQLite in this
situation without resorting to using the dl() function?

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Using SQLite without hosting support

2011-05-03 Thread Paul M Foster
On Tue, May 03, 2011 at 02:14:17PM -0400, ad...@buskirkgraphics.com wrote:

 
 -Original Message-
 From: Paul M Foster [mailto:pa...@quillandmouse.com] 
 Sent: Tuesday, May 03, 2011 12:36 PM
 To: php-general@lists.php.net
 Subject: [PHP] Using SQLite without hosting support
 
 Assume you have a hosting account with PHP5 support, but no SQLite
 support. Yes, supposedly SQLite support is standard for PHP5, but
 there's no law that keeps someone from compiling PHP5 without SQLite
 support.
 
 So assuming that's the case, given that SQLite is a pretty simple
 product, is it possible to run PHP5 and use SQLite, even if support for
 it is not built in? The dl() function has some restrictions on it which
 might prohibit its use, so is there some way to use SQLite in this
 situation without resorting to using the dl() function?
 


 Paul,
   I could be wrong on this but unless you have a dedicated server, you
 do not have the recompilation rights if the hosting company is worth
 anything.

No, of course not. I have no desire to recompile PHP. But the hosting
company is entirely capable of recompiling PHP without support for
SQLite, if that's their preference.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Debugging Help Needed

2011-04-12 Thread Paul M Foster
On Tue, Apr 12, 2011 at 03:37:26PM -0700, Rich Shepard wrote:

 On Tue, 12 Apr 2011, Daniel Brown wrote:
 
You missed the ending semicolon, that's all.
 
 Daniel,
 
   Oops! Too long since C and Python doesn't use semicolons.

Wait, what?! Did they change C? When did this happen?! ;-}

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] the best 1 book for php

2011-04-07 Thread Paul M Foster
On Thu, Apr 07, 2011 at 02:54:45PM -0500, Donovan Brooke wrote:

 Kirk Bailey wrote:
 If I only had 1 book on php, what would it be?
 
 
 I have to disagree with the php.net 'docs' being the best book.
 
 Though most of us will have a php.net tab open in your browser every
 time we write code, it's not the same learning that comes with a
 good book IMO. Reading a book can give a more robust understanding
 to a language, perhaps especially when starting out. You get to
 listen in on the author's perceptions of tools, theories of
 practice, etc.. which can help with concepts, reasoning, and
 understanding etc..
 
 Perhaps you start to get a similar type of learning with a good talk
 list combined with php.net however... perhaps with a bit of spam.
 ;-)
 
 Anyway, someone mentioned Larry Ullman's books and I'd have to
 second that suggestion.

I agree regarding php.net.

php.net is a great resource for function references. It is less of a
great resource for basic language elements and such, mainly because of
the way it's indexed. It's much harder to find a full explanation of
something like heredocs on the site than an explanation of, say the
date() function.

However, if you're trying to learn the language, a book is a better
companion than php.net. I'd recommend the O'Reilly book Programming
PHP by Lerdorf, Tatroe  MacIntyre. Before I discovered php.net, it was
my bible (not the one Tedd referred to).

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



  1   2   3   4   5   6   7   >