[PHP] Re: PHP from ASP using AJAX?

2012-09-18 Thread Ross McKay
On Mon, 17 Sep 2012 23:03:55 -0700, Girish Talluru wrote:

Can we able to call PHP script from ASP using AJAX?

Yup.

If you're talking about Classic ASP (VBScript) then here's a few
examples. They talk about WordPress, but really any PHP service will
work the same.

http://snippets.webaware.com.au/snippets/integrating-classic-asp-with-wordpress-using-ajax/
( http://goo.gl/rHlgF )
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: cyberweaponry

2012-05-31 Thread Ross McKay
On Thu, 31 May 2012 13:21:07 -0400, Tedd Sperling wrote:

[...]
I watched a interview today where an security expert claimed that 
the Flame Virus was written in a scripted language named lua 
(http://www.lua.org/).

That's surprising... I'm intrigued, can you supply a link?

He said that this was unusual because typically such viruses are
written in languages like Ruby-on-Rails and such.

Um, really? I very much doubt that. AFAIK, most true viruses are written
in a compiled language, and many trojans as well. RoR websites would
definitely be a vulnerability target though...

So, my question to the group -- has PHP produced any viruses? If not, 
could it? If so, can anyone elaborate on the details?

It's unlikely to be used for viruses per se, even trojans. Mainly, it's
a target of vulnerability hacks due to the low level of entry to
building websites in PHP and some (now deprecated) truly awful features
like register globals. But even professionally written PHP can serve as
a hack target, as seen in the Plesk fiasco earlier this year:

http://arstechnica.com/business/2012/02/plesk-control-panel-bug-left-ftc-sites-and-thousands-more-exposed-to-anon/
( http://preview.tinyurl.com/8xxjcsj )

I've been burned by that one personally when the servers some customers'
sites are hosted on were taken down by a series of failures triggered by
that hack. The host proudly told me that their security was fine and
that it was WordPress that must have been hacked (because the malware
found was in scripts hidden in the various WP folders). They got awful
busy after reading that link though.
--
Ross McKay, Toronto, NSW Australia
A just machine to make big decisions
 Programmed by fellows with compassion and vision
 We'll be clean when their work is done
 We'll be eternally free yes and eternally young
 What a beautiful world this'll be
 What a glorious time to be free... - Donald Fagan

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



[PHP] Re: Email Antispam

2012-04-18 Thread Ross McKay
On Wed, 18 Apr 2012 11:08:00 -0400, Jim Giner wrote:

He literally wants the addresses visible on the sight?  [...]

Yes, they want the addresses visible and clickable on the website. They
have contact forms, but they also want the email addresses (of their
scientists and other consultants) available to their clients. And they
want the addresses to be shielded against harvesting for spam.

As I said, I don't like doing it this way, but the client gets what they
want after the options have been explained to them.
-- 
Ross McKay, Toronto, NSW Australia
Nobody expects the Spanish inquisition - Cardinal Ximénez

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



[PHP] Re: Email Antispam

2012-04-17 Thread Ross McKay
On Tue, 17 Apr 2012 16:04:19 -0400, David Mehler wrote:

I'm working on a site that has email addresses on it. I am not wanting
to use mailto links so as to avoid spam harvesters, I'd like another
solution so that mailto links would work but would not work with
spammers. I've tried several javascript-based solutions, but am not
able to get them to be consistent. It seems like once they're used
they revert to coded links. If anyone has any solutions I'd appreciate
it. I'm not sure I can do this in php, generate email addresses
dynamically then pass them to the client, it would be the same as the
spammer hitting the page. I'd prefer something self-hosted and
preferably light on the resources.

I don't like this sort of thing, but I have a client who needs it. What
I did for them was to put the email address on the page encoded with
base64, and use client-side script to decode it. i.e. the encoded data
is replaced with the decoded data, once on page load. Hook up the decode
function on the browser-side to your page load scripts. No jQuery
required :)

https://gist.github.com/2409958
-- 
Ross McKay, Toronto NSW Australia
All we are saying
 Is give peas a chance - SeedSavers

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



[PHP] Re: Email Antispam

2012-04-17 Thread Ross McKay
On Tue, 17 Apr 2012 21:11:45 -0400, Jim Giner wrote:

So - does that mean you building the site from information contained in a 
database? 

Yes. Client wanted email addresses on the website, but not available to
SPAM harvesters. And not all addresses are in the database as
structured data, many are embedded in page content (I have a WordPress
shortcode that encodes the email address for those).
-- 
Ross McKay, Toronto, NSW Australia
Faced with a choice between the survival of the planet
 and a new set of matching tableware, most people would
 choose the tableware - George Monbiot

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



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

2012-04-12 Thread Ross McKay
On Wed, 11 Apr 2012 17:06:10 -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.

There are only two kinds of languages: the ones people complain about
and the ones nobody uses. -- Bjarne Stroustrup
-- 
Ross McKay, Toronto, NSW Australia
The chief cause of problems is solutions -Eric Sevareid

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



[PHP] Re: To ? or not to ?

2012-04-03 Thread Ross McKay
On Tue, 3 Apr 2012 17:29:33 -0400, Tedd Sperling wrote:

[...]
Does anyone have more examples of where scripts will fail 
IF they end with ?  (note the additional space)?

+1 on everyone's call to omit on an included file due to the potential
for sending headers.

[... rearranged for ease of reply ...]
You see, the scripts created image but apparently the image 
delivery method objected to the additional whitespace.

If you're sending binary data, you're best throwing in an exit() after
the last output. It doesn't matter then whether or not you have a
closing ?, with or without additional white space.
-- 
Ross McKay, Toronto, NSW Australia
The chief cause of problems is solutions -Eric Sevareid

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



[PHP] Re: CMS identification

2012-03-18 Thread Ross McKay
On Sun, 18 Mar 2012 23:20:21 +0100, Alain Roger wrote:

i have a customer who need to update his website but he was not able to
tell me more about it.
he just told me it's a CMS and sent me a screenshot.
[...]

Instead of hoping for a USENET reader to recognise that screenshot, open
the login page in a web browser and view source. It's likely that there
will be a meta tag in the head that tells you what the CMS is.
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: sql injection protection

2012-01-17 Thread Ross McKay
On Mon, 16 Jan 2012 19:34:09 -0800, Haluk Karamete wrote:

I understand some ways are better than others in this one, and it
looks like the PDO based implementations shine the most as far as SQL
Injection.

PDO is one way (and happens to be the one I prefer), but there are
others. Essentially, you are best validating your inputs (always!) and
then using prepared statements where possible. See here for some
options:

http://bobby-tables.com/php.html

But would not the following be good enough - without implementing a
PDO solution?
[...]

You should always validate your inputs anyway, but whereas a PDO
solution (by which I infer you mean using prepared statements) is
safest simply because it forces you to use safe practices, you can still
build safe SQL statements by using mysql(i)_real_escape_string().
Equally, you can bollocks up a prepared statement by building it with
string appends for some parameters that should instead be bound.

Use common sense, use the appropriate tool for the job, but err on the
side of caution and use prepared statements in preference to dynamic SQL
where appropriate. (And where I need to use dynamic SQL, e.g. some
searches, I often do so by building sets of parameters to apply to the
prepared statement for the dynamic SQL)

[...]
4- check the magic_quotes_gpc and do the stripslashes and then the
mysqli_real_escape_string() and the htmlentities.

htmlentities() and htmlspecialchars() are for writing safe HTML, and are
not concerned with SQL injection. You should use them, but only when
writing output to HTML (e.g. don't use them for plain text or XML) and
certainly they have no place in writing to a database except in specific
circumstances (like where you're storing HTML in the database, not
text).

5- and on top pf all this, I also check for the specific occurrences
of these following words; if any exist, I just do not execute that SQL
query.
   and that list is
sysobjects,
syscolumns,
systypes,
EXEC(@,
CHAR(,
exec%20,
DECLARE%20@,
wscript.
CAST(
CONVERT(

A nice-to-have if you're going to try to detect an attack, but otherwise
not required if you have the bases covered with prepared statements or
properly escaped data. Realise that this is a short list and incomplete,
and can never be complete. I would not rely on it to safe-guard
anything; it can only be used as an indication of a *possible* attack
(but it will also prevent someone submitting perfectly good code to a
forum, for example).

[...]
These may raise a false negative on some valid user input that's
coming from a textarea where the data type is string, and an accepted
char length is big enough to create some havoc in the db, so be it, I
reject that input.

Which may be fine in your application, but why stop legitimate data for
no good reason?

My question even after all these are there still ways to break in?
[...]

Yes :)
-- 
Ross McKay, Toronto, NSW Australia
Pay no attention to that man behind the curtain - Wizard of Oz

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



[PHP] Re: http_referer. what's wrong with that?

2012-01-11 Thread Ross McKay
On Wed, 11 Jan 2012 21:27:58 -0800, Haluk Karamete wrote:

[...]
Notice: Undefined index: HTTP_REFERER in
D:\Hosting\5291100\html\blueprint\bp_library.php on line 16
die;
[...]
But I'm still curious, what configuration am I missing so that
http_referer is treated like that?

You only get an HTTP_REFERER when you link to a page from another page.
If you go directly to the page, e.g. by typing / pasting the URL into
the location bar, or linking from an email, then there is no
HTTP_REFERER.
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



Re: [PHP] Re: Preferred Syntax

2011-12-17 Thread Ross McKay
On Fri, 16 Dec 2011 23:53:46 -0500, Eric Butera wrote:

To all the people who responded to this thread:
It is 2011 - please stop writing code like this.

To the OP:
I'm glad you're asking questions and realizing you're not happy with
your current abilities and suspect there's a better way.  I've read
the replies in this thread and feel a bit let down.  Use a templating
language - yes, I understand that is what php is for - but I won't go
into it.  You should not be echoing, printing, or any other method of
concatenating html dealing with escaping quotes inside your php logic
code.  Please separate your concerns.

By and large, I agree with you, and certainly it is a good idea to raise
that with the OP since they were asking about recommended practices.
However, should not is not the same as don't and there are still
places where this is appropriate. 

Here's a chunk of real code from a WordPress plugin, taken from the
class that extends the Page admin form to provide a button for selecting
a custom associated image:

echo HTML
input type=button class=button mmm-admin-image-button
data-fieldname=$fieldName value=Select
id=mmm-admin-image-button-$fieldName /
input type=hidden name=$fieldName value=$fieldValue /
span id=mmm-admin-image-caption-$fieldName
{$this-getAttachmentCaption($fieldValue)}/span
input type=button class=button mmm-admin-clear-button
data-fieldname=$fieldName value=Clear /

HTML;

HEREDOC provides me a way to do templating in a simple way within a
WordPress hook function. The purpose of the hook is to provide a way to
augment WordPress Page editing by adding some HTML; sending a small
fragment of HTML to the browser is its function. I gain nothing by
spinning that fragment out to a template file somewhere.

For other hook functions (e.g. representing shortcodes), it is
beneficial to use templating, and I do so -- but horses for courses.

Not sure what that means?  That's OK!  If you want to move forward,
look up how modern frameworks deal with this issue using their views
or template views.  You don't have to use a framework if you do not
want to, that's perfectly fine.  If it works, it works.  But in the
end, it the separation of logic and html is essential to code
maintenance.

Applause! :)
-- 
Ross McKay, Toronto, NSW Australia
The chief cause of problems is solutions -Eric Sevareid

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



Re: [PHP] Re: Preferred Syntax

2011-12-15 Thread Ross McKay
Jim Lucas wrote:

I second this example, with one minor change, I would add '{' and '}' around
variables.

echo HTML
a style=text-align:left;size:14;font-weight:bold
   href=/mypage.php/{$page_id}{$page_name}/abr
HTML;

This works for $variables, $objects, and variable functions calls.  But doesn't
work if you try to call functions directly (bummer).

In fact, we are in agreement here :) I was just simplifying for the
example at hand. And as for calling functions directly, also add
constants :(

However, it's easy enough to assign a constant to a variable and embed
it in a HEREDOC, and also easy to wrap a function in a method,
especially when your HEREDOC is within a method itself:

define('MSG', 'My name is');

class X {
  function html($text) {
return htmlspecialchars($text);
  }

  function output($name) {
$msg = MSG;
echo HTML
p$msg {$this-html($name)}/p
HTML;
  }
}

$x = new X();
$x-output('silly rockstar name like ');

[...]
This is why I like heredoc syntax over pretty much everything else.

Concur!
-- 
Ross McKay, Toronto, NSW Australia
Pay no attention to that man behind the curtain - Wizard of Oz

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



[PHP] Re: Preferred Syntax

2011-12-14 Thread Ross McKay
On Wed, 14 Dec 2011 07:59:46 -0500, Rick Dwyer wrote:

Can someone tell me which of the following is preferred and why?

  echo a style='text-align:left;size:14;font-weight:bold' href='/ 
mypage.php/$page_id'$page_name/abr;

  echo a style='text-align:left;size:14;font-weight:bold' href='/ 
mypage.php/.$page_id.'.$page_name./abr;
[...]

Just to throw in yet another possibility:

echo HTML
a style=text-align:left;size:14;font-weight:bold
   href=/mypage.php/$page_id$page_name/abr
HTML;

I love HEREDOC for slabs of HTML, sometimes SQL, email bodies, etc.
because they allow you to drop your variables into the output text
without crufting up the formatting with string concatenation, AND they
allow you to use double quotes which can be important for HTML
attributes that may contain single quotes.

So whilst either above option is fine for the specific context, I prefer
HEREDOC when there's attributes like href.

But what is preferred is rather dependent on the preferrer.
-- 
Ross McKay, Toronto NSW Australia
All we are saying
 Is give peas a chance - SeedSavers

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



Re: [PHP] Sequential access of XML nodes.

2011-09-28 Thread Ross McKay
Richard Quadling wrote:

It seems that the SimpleXMLIterator is perfect for me.
[...]

Interesting, I forget that's there... I must have a play with it
sometime. Thanks for resurfacing it :)
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



Re: [PHP] Sequential access of XML nodes.

2011-09-26 Thread Ross McKay
On Mon, 26 Sep 2011 14:17:43 -0400, Adam Richardson wrote:

I believe the XMLReader allows you to pull node by node, and it's really
easy to work with:
http://www.php.net/manual/en/intro.xmlreader.php

In terms of dealing with various forms of compression, I believe you con use
the compression streams to handle this:
http://stackoverflow.com/questions/1190906/php-open-gzipped-xml
http://us3.php.net/manual/en/wrappers.compression.php

+1 here. XMLReader is easy and fast, and will do the job you want albeit
without the nice foreach(...) loop Richard spec's. You just loop over
reading the XML and checking the node type, watching the state of your
stream to see how to handle each iteration.

e.g. (assuming $xml is an open XMLReader, $db is PDO in example)

$text = '';
$haveRecord = FALSE;
$records = 0;

// prepare insert statement
$sql = '
insert into Product (ID, Product, ...)
values (:ID, :Product, ...)
';
$cmd = $db-prepare($sql);

// set list of allowable fields and their parameter type
$fields = array(
'ID' = PDO::PARAM_INT,
'Product' = PDO::PARAM_STR,
...
);

while ($xml-read()) {
switch ($xml-nodeType) {
case XMLReader::ELEMENT:
if ($xml-name === 'Product') {
// start of Product element, 
// reset command parameters to empty
foreach ($fields as $name = $type) {
$cmd-bindValue(:$name, NULL, PDO::PARAM_NULL);
}
$haveRecord = TRUE;
}
$text = '';
break;

case XMLReader::END_ELEMENT:
if ($xml-name === 'Product') {
// end of Product element, save record
if ($haveRecord) {
$result = $cmd-execute();
$records++;
}
$haveRecord = FALSE;
}
elseif ($haveRecord) {
// still inside a Product element, 
// record field value and move on
$name = $xml-name;
if (array_key_exists($name, $fields)) {
$cmd-bindValue(:$name, $text, $fields[$name]);
}
}
$text = '';
break;

case XMLReader::TEXT:
case XMLReader::CDATA:
// record value (or part value) of text or cdata node
$text .= $xml-value;
break;

default:
break;
}
}

return $records;
-- 
Ross McKay, Toronto, NSW Australia
Tuesday is Soylent Green day

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



[PHP] Re: While on the topic of PHP Web Site Stats - SharePoint...

2011-09-19 Thread Ross McKay
On Mon, 19 Sep 2011 16:22:59 -0600, George Langley wrote:

[...]
   Any stats on (warning - buzzwords ahead) External-facing web 
sites using SharePoint? [...]

Try here:

http://w3techs.com/technologies/overview/content_management/all

(SharePoint comes in at 0.1% of all websites, 0.3% of all CMS; i.e.
wy behind the PHP-based CMS out there -- e.g. WordPress on 14.9%
websites and 54.4% CMS)
-- 
Ross McKay, Toronto NSW Australia
All we are saying
 Is give peas a chance - SeedSavers

-- 
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-09-01 Thread Ross McKay
Robert Cummings wrote:

That's because JavaScript is broken in some ways. As much as I like 
JavaScript, some parts of the language were thrown together by flinging 
crap at a fan and seeing what sticks to the wall... this being a prime 
example.

Sounds a lot like PHP :) which I must add I love dearly, though it
certainly resembles your remark much more closely than JavaScript.

But on-topic, novices using a coding style and feeling their way around
a new language would be better served by the 1TB style than anything
that easily allows statement insertion (either by them, or by silly
language defects like JavaScript's semicolon insertion). 
-- 
Ross McKay, Toronto, NSW Australia
Hold very tight please! Ting! Ting! - Flanders and Swann

-- 
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 Ross McKay
On Tue, 30 Aug 2011 10:04:54 -0400, Tedd Sperling wrote:

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

I note on your page that you prefer Whitesmiths (truly ugly!) style even
for JavaScript. I'd strongly recommend against that, and also Allman
style, due to semicolon insertion. e.g. (randomly selected from Google)

http://encosia.com/in-javascript-curly-brace-placement-matters-an-example/
http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/

Sure, instances of the problem are minimal, but if you're in the habit
of Dangerous Open Brace Placement then you just might fall afoul of it.

Besides, my editor (Geany) folds code mostly neatly with KR :)
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: Resizing an image

2011-03-30 Thread Ross McKay
On Tue, 29 Mar 2011 03:21:48 +0300, Andre Polykanine wrote:

[...]
My questions are:
1.  what  are the restrictions of ImageCopyResampled()? Can I make a jpg
image  from  a jpg one, and a png image from a png one? And what about
gif's?

Yes, or even a JPEG from a GIF, or a PNG from a JPEG, etc. 

But: imagecopyresampled works on image *resources*, which you create
either as blank canvases or by reading from files. In your case, you
want to create a resource from a file (JPEG, PNG, GIF etc.) and another
as a blank canvas into which you will copy the original image, resampled
(or resized). See the examples here:

http://au2.php.net/manual/en/function.imagecopyresampled.php

After the comment // Resample it:
* creates a new blank image resource to copy into, i.e. $dst_image
* creates an image by reading a file, i.e. $src_image
* copies with resampling, i.e. from $src_image to $dst_image

2.  I  don't  need to output the image as the script output, I need to
upload it as a file (replacing the uploaded larger file). Could I make
it with fwrite and then copy it to the server? All of the examples give 
header(image/jpeg)...

You can write the new image to a file using one of these:

http://au2.php.net/manual/en/function.imagepng.php
http://au2.php.net/manual/en/function.imagejpeg.php
http://au2.php.net/manual/en/function.imagegif.php


NB: see the following comments by tim (at) leethost (dot) com, regarding
performance of imagecopyresampled vs imagecopyresized:

http://au2.php.net/manual/en/function.imagecopyresampled.php#77679
http://au2.php.net/manual/en/function.imagecopyresampled.php#72606

Also check out ImageMagick, if your host provides it (or you can install
it):

http://au2.php.net/manual/en/book.imagick.php
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: Cross-platform IDE

2011-01-27 Thread Ross McKay
On Wed, 26 Jan 2011 08:06:12 -0500, Andy McKenzie wrote:

[...]   So:  does anyone have a recommendation for an IDE that works in
Windows, Mac, and Linux?  I spend roughly equal time in all three, and
I haven't found a tool I like yet that works in all of them.
Actually, I stopped looking three or four years ago, but at that point
there didn't seem to be anything.  If anyone has any advice, I'd love
to hear it!

Try Geany: http://www.geany.org/

The one thing it doesn't do (yet) is debugging PHP. Otherwise, we find
it to be great for working on PHP, JS, HTML, XML and CSS. It's small and
fast, so if you don't need all the bells and whistles of an Eclipse,
Geany might suit you better. Worth a try at least.
-- 
Ross McKay, Toronto, NSW Australia
It doesn't matter if the Rock wants to go get diamond rings or not!
- The Rock

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



[PHP] Re: php photo galery

2010-05-18 Thread Ross McKay
On Tue, 18 May 2010 21:11:00 -0400, David Mehler wrote:

I've googled for this and tried some downloads but not finding what
i'm looking for. A site requirement is to have a photo gallery. These
user's are not very technical so i thought about getting a galery with
the ability to upload photos via a browser, I would also like thumb
nails, and the ability to have an alt text attribute with the photo
and a longer description of the picture, for accessibility reasons.
If anyone has anything similar to this please let me know.

http://www.plogger.org/
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: Security/Development Question

2010-04-28 Thread Ross McKay
On Wed, 28 Apr 2010 16:54:56 -0400, David Stoltz wrote:

[...]
We recently have added a very small web application that is vendor
supported. They said it's not working, so I investigated. I found that
our software protection was blocking their pages because they are
actually passing entire SQL queries in their form POSTs. Now, the app is
SSL protected, and they claim the queries are not executed - only
inserted into the database to be used later. They also said it's
protected by the ASP.NET framework authentication [...]

Unless they're storing the SQL queries so that they can show them later
on, e.g. as text in a forum post, I think you have a major WTF on your
hands! Please submit here!

http://thedailywtf.com/Contact.aspx

:)
-- 
Ross McKay, Toronto, NSW Australia
The chief cause of problems is solutions -Eric Sevareid

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



[PHP] Re: Malware Question

2010-04-28 Thread Ross McKay
On Thu, 29 Apr 2010 00:50:52 +0100, Ashley Sheridan wrote:

This isn't exactly a PHP question, but I don't know anyone else with the
collected smarts of this list. Basically, a site I built and am managing
has been identified by Google as a source of malware. [...]

Check the sites you link to. We had a client who had some links to
websites that had been turned into malware sites; just having the links
to the malware sites was enough to mark that website as a source of
malware.

We had to advise the client to only add links for actual people they've
had contact with, not just people who send them email invitations to
exchange links.
-- 
Ross McKay, Toronto, NSW Australia
I really hope they find a nice place,
 I hope they find it somewhere,
 I HOPE THEY GO AWAY
 - Everclear

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



[PHP] Re: Replacing accented characters?

2010-01-27 Thread Ross McKay
On Wed, 27 Jan 2010 16:55:46 -0600, Skip Evans wrote:

I'm looking for recommendations on how to replace accented 
characters, like e and u with those two little dots above 
them, with the regular e and u characters.

$newText = iconv('UTF-8', 'ASCII//TRANSLIT', $text);

But ensure you have set your locale properly.

http://au.php.net/manual/en/function.iconv.php
-- 
Ross McKay, Toronto NSW Australia
All we are saying
 Is give peas a chance - SeedSavers

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



Re: [PHP] Re: Replacing accented characters?

2010-01-27 Thread Ross McKay
On Wed, 27 Jan 2010 23:38:42 +, Ashley Sheridan wrote:

Don't forget that changing some characters can actually change the words
and meanings of words. While an ë might look like and e, it's actually a
completely different character, with a different pronunciation to go
with it. [...]

True. But for the purposes of cleaning up URLs (not I18N friendly, but
practical on Anglo-centric websites) it has its uses.
-- 
Ross McKay, Toronto, NSW Australia
Faced with a choice between the survival of the planet
 and a new set of matching tableware, most people would
 choose the tableware - George Monbiot

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



[PHP] Re: uniqid() and repetition of numbers generated

2009-11-12 Thread Ross McKay
On Fri, 13 Nov 2009 08:22:47 +1000, Angus Mann wrote:

I need a unique identifier in an SQL table and for complicated reasons 
I don't want to use auto-increment. [...]

So why not use a UUID/GUID as created by the DB? You don't specify which
DB server technology you're using, but:

* Microsoft SQL Server has uniqueidentifier and newid()
* Oracle has sys_guid()
* MySQL has uuid() and uuid_short()
* PostgreSQL has uuid and contributor function contrib/uuid-ossp

Or are you using something else which doesn't support UUIDs?

(Ash, maybe he's doing replication and can't rely on auto-increment
integers aligning across peers)
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: Best way to test for form submission?

2009-08-31 Thread Ross McKay
On Sat, 29 Aug 2009 04:47:09 -0400, O. Lavell wrote:

There are more methods, I always use:

if($_SERVER[REQUEST_METHOD] == POST) {

do_something();

}

+1. Although, this doesn't catch PUT requests, but I have yet to
encounter a place where I want one with form data.
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



Re: [PHP] how to enable ttf support in php 5.2.9

2009-05-13 Thread Ross McKay
Ashley Sheridan wrote:

Great idea in theory, if you can guarantee that they'll *only* be using
MS Office to paste from. In my experience, you can only guarantee on the
stupidity of the end users, nothing else.

I was mostly being facetious :)
The only thing that really works is getting the users to cooperate by
giving them a button for Word and a button for Text and explaining to
them how it *helps them* to use those buttons properly. But that only
works while they remember, and they never remember when they're in a
hurry (which is always).
-- 
Ross McKay, Toronto, NSW Australia
Darwin's rolling over in his coffin,
'cos the fittest are surviving much less often - NOFX

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



[PHP] Re: Problems with HTTPS and maybe an .htaccess???

2009-05-08 Thread Ross McKay
On Tue, 05 May 2009 13:20:56 -0500, Skip Evans wrote:

[...]
But now I have a problem implementing this on their 
development site, which is just a duplicate code base inside a 
directory public_html/_dev and a domain name dev.sitename.com, 
instead of sitename.com.

The problem is, and I believe it may be the .htaccess file, 
redirecting the https pages to the live [...]

You should be telling the browser to redirect to the new page, rather
than just pulling up a page to offer back instead of the requested URL.
You want the browser to request a new page, using HTTPS (i.e. SSL or
TLS). See here, which forces a redirect to HTTPS for any pages in the
orders folder that have been requested via HTTP:

RewriteCond %{SERVER_PORT}  !443$
RewriteRule ^orders/?.*$https://%{SERVER_NAME}/orders [R=301,L]

The bit at the end, R=301 makes Apache tell the browser to ask for
another page at the new URL.

The %{SERVER_NAME} bit tells Apache to insert the server name, whether
it be your sitename.com or dev.sitename.com
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: Encrypting email

2009-04-23 Thread Ross McKay
On Tue, 21 Apr 2009 08:39:25 -0400, Bob McConnell wrote:

I have been asked by a product manager what our options are for
encrypting email messages with sensitive information. We are currently
using PHPMailer to send email. What can be done to encrypt those
messages? Can it be done without OOP?

Server configuration:
  RHEL 5
  Apache 2.0
  PHP 5.2.3
  PHPMailer 1.73

Use S/MIME, and nearly all of your clients will be able to decrypt your
emails. There are a few exceptions: Forté Agent still doesn't handle
S/MIME, and Eudora needs a plug-in to handle it. However, all mainstream
email programs support it directly, without need to install new
software.

You need to generate (or purchase - I prefer generate for free in
OpenSSL) email certificates for encrypting emails, then distribute the
certificates to allow people to decrypt them. Once they have the key,
the emails generally just automatically decrypt when you view them
(depending on the email program). NB: give your clients individual
certificates, and keep the public keys to encrypt the emails to them.

PHP has support for this, and it's easy to use:

http://au2.php.net/manual/en/function.openssl-pkcs7-encrypt.php

Apparently, PHPMailer supports it too so check that out.
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: 2 forms, same page, 1st is file upload - works in IE, 'dies' in non-IE browsers

2009-03-19 Thread Ross McKay
On Thu, 19 Mar 2009 16:27:38 -0600, scubak1w1 wrote:

I have it set in a div tag and use AJAX...

When it is 'off' (i..e, when the page first opens) it is simply a grayed out 
image with a 'tool tip' to indicate it is not functional...

Once the array key exists for the first form, I have (sic) AJAX change the 
connets of the div to make it a 'true' submit button... 

Sounds like you have some browser-specific DOM code there when adding
the submit button. Can we see the code please?

A simpler approach could be to have the submit button there all along,
but disable it (attribute: disabled=disabled) until you have your
array key (script: submitElement.disabled = false). No chance of
bollocksing up the DOM code then :)
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: PHP to create an ERD (sic) on the fly on a web page based on current DB records?

2009-03-13 Thread Ross McKay
On Thu, 12 Mar 2009 18:47:40 -0600, scubak1w1 wrote:

Seeking some advice on how to create an ERD (sic) graphically on the page on 
the fly when the page is 'called'...
[...]

Maybe GraphViz?

http://graphviz.org/
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: 2 forms, same page, 1st is file upload - works in IE, 'dies' in non-IE browsers

2009-03-13 Thread Ross McKay
On Thu, 12 Mar 2009 18:39:38 -0600, scubak1w1 wrote:

[...]
In the non-IE browsers I have tried (Firefox, Chrome, Opera), the first form 
uploads the file properly, the 2nd form's submit is 'turned on' by AJAX - 
BUT the submit button on the 2nd form doesn't seem to do anything - i.e., 
the onsubmit is not being triggered, etc, etc

How do you turn on your submit button? (for that matter, how do you
turn it off?)

Have you checked Firefox's log to see if you have JavaScript errors?
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



Re: [PHP] Question about template systems

2009-03-03 Thread Ross McKay
On Tue, 3 Mar 2009 20:46:40 +, stuttle wrote:

[...]
As far as templating systems go I personally don't think they add anything
to the equation unless you're working with designers who are already
familiar with something. Separation of logic and content is important,
abstraction away from PHP is not (IMHO).

Yeah, I've been meaning to ask about that myself - what benefit is there
in using something like Smarty, which requires learning yet another set
of notation, over just having a class/interface for the page and calling
methods on that in plain-old PHP from the template?

--- the PHP page (e.g. index.php) ---

?php
$page = new YourPageClass();
require_once 'include/template.php';

--- template.php ---

html
head
title?php $page-showPageTitle();?/title
...
?php $page-showCustomHeaders();?
/head
body
...
?php $page-showMenu();?
...
?php $page-showContent();?
...
/body
/html

--- snip 

For that matter, why go with Smarty over the more widely supported
(across multiple languages) XSL?

Maybe I'm missing something, but I don't see the point of special
templating systems that require you to know yet another notation set,
i.e. abstraction away from PHP as Stuart puts it.
-- 
Ross McKay, Toronto NSW Australia
Click me, drag me, treat me like an object

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



Re: [PHP] Re: mysql_real_escape_string(asdasddas) ??? wtf

2009-02-21 Thread Ross McKay
German Geek wrote:

Ah, ic. Mh, why wouldn't a function like that function without a db
connection? Does it use the db? Isn't that less efficient? 

It doesn't use the db - at least, it doesn't make a call to the db. It
probably wants a db resource handle so that it can know what character
set it is meant to be handling, which is established as a property on
the connection.

I might just use
str_replace, because i can't think of any way that one could get a sql
injection into

str_replace(', \\\', $value); // might need to replace a literal \ too.

If you can, please enlighten me.

And also: NUL, LF, CR,  and ^Z

Or you could just call mysql_real_escape_string and know that you
haven't coded your str_replace with some hole in it :)
-- 
Ross McKay, Toronto, NSW Australia
The chief cause of problems is solutions -Eric Sevareid

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



[PHP] Re: mysql_real_escape_string(asdasddas) ??? wtf

2009-02-20 Thread Ross McKay
On Sat, 21 Feb 2009 19:19:44 +1300, t...@ihostnz.com wrote:

Can anyone here tell me why mysql_real_escape_string(asdasddas) returns an
empty string?

Have you opened a connection to a MySQL database? It won't work without
an open connection.
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



Re: [PHP] Re: 64bit vs. 32bit

2009-01-20 Thread Ross McKay
On Mon, 19 Jan 2009 18:39:40 -0800, James Colannino wrote:

I could be wrong, but I'll bet anything that Wine made use of the now
defunct vm86 component of the x86 architecture.  [...]

Yes, I believe that's true, and that it's not available when you compile
for x86-64. However... why? If you really need to run DOS programs,
there's always DOSBOX, or even FreeDOS running in QEMU or similar, and
the graphics support will be better than whatever Wine would have
allowed.
-- 
Ross McKay, Toronto, NSW Australia
Nobody ever rioted for austerity - George Monbiot

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



Re: [PHP] Re: 64bit vs. 32bit

2009-01-20 Thread Ross McKay
Micah Gersten wrote:

Linux can already address all the RAM on a 32 bit system with PAE.  The
advantage of 64 bit with regards to RAM is that a single process can
address more than 2.5 - 2.7 GB of RAM.

True, what I meant was processes on Linux will be able to address more.
Good catch. 

Even with PAE and 64GB of RAM, there's a physical limit on what a
process can address, 4GB, and that's further limited by resources that
must be mapped into the process space. IIRC, the number is more like
3.3GB or thereabouts, depending on the build and hardware. Unless, of
course, they're specifically coded to make use of PAE... :)
-- 
Ross McKay, Toronto, NSW Australia
My old man told me one time, you never get wise, you only get older
- Dandy Warhols

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



[PHP] Re: How to use SVN + PHP

2009-01-20 Thread Ross McKay
On Mon, 19 Jan 2009 22:32:49 +0100, Edmund Hertle wrote:

I'm thinking about implementing Subversion to an existing php project for
obvious reasons.

Yay! What Nathan said, plus a couple of comments from me...

[...]
My ideas about using SVN are these:
- Repository is managing trunk, branch and tag
- Live-server works as client of the rep, getting the latest tag
- Develop-server uses mainly latest trunk and of course branches as needed

Personally, I'd just work in the trunk. Even with multiple developers,
stick to working in the trunk. On release, copy the trunk to a tag to
preserve its state.

Branches are great for long-running diversions from the trunk, e.g. when
creating a whole new release with new features and potentially different
architecture, copy the trunk to a branch so that maintenance work can
continue on the branch, and perform new work on the trunk. Of course,
you can do that the other way around, new work on the branch and
maintenance on the trunk, but that means merging the branch into the
trunk at the end and potentially creating a new branch for
maintenance... i.e. the same result as the other method, but with more
effort.

Putting it another way: working in branches is good for maintaining
separate codebases concurrently, either because of feature differences
or platform differences (e.g. a Linux branch and a Windows branch).

NB: in Subversion, there really isn't proper support for either branches
or tags; we just emulate it by copying a folder to another folder. A tag
is then just a copied folder that is never altered again, and a branch
is a copied folder that is later modified. Convention has us calling
these things tags and branches, and calling the original folder the
trunk.

For simple websites, I tend to drop the trunk/tag/branch model entirely
and just work in the trunk. Some things just don't warrant the extra
work :) but they still benefit from revision control.

[...]
Is it possible to configure one client (here develop-server) to
automatically updating from rep if something is committed?

IMHO, that would be a Bad Thing® because it means only committing to the
repository when it works. Alternatively, it could mean releasing
untested changes to production, an even more Bad Thing®.

Better is to commit early, commit often and thus get deep undo through
Subversion's history of changes. Once you've tested your changes and are
happy that everything is working, and committed them all to the trunk,
copy the trunk to a tag and put that on the server.
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: 64bit vs. 32bit

2009-01-19 Thread Ross McKay
On Mon, 19 Jan 2009 14:56:36 -0600, dbrooke wrote:

I am interested in hearing opinions about if there
are reasons to stay with a 32bit php/apache if there
is 64bit options available. What are the pros/cons
in running in the different architectures?

If you need to run some 32-bit stuff, you'll have multiple copies of
some libraries (one each for 32-bit and 64-bit). But hard drive space is
cheap these days.

You'll also use a little more RAM due to pointer and integer sizes.
However, Linux will be able to address more RAM on a 3GB system.

One restriction I know (knew?) of is that you can't run DOS programs
under Wine on 64-bit, but then... why? Not much of a restriction here,
at least. Conversely, the Wine people are working on 64-bit support in
Wine.

There have been drivers for some hardware that have not been available
for 64-bit, and that may still be true. I remember that early cuts of
madwifi for Atheros AR242x wifi were only available for 32-bit for quite
a while (now resolved). If you have hardware that requires special
drivers, check that 64-bit drivers are available.

PHP specific (at last ;) that comes to mind is that time_t on 64-bit
solves the Year 2038 problem, so any date calculations you have in PHP
will work past 2038. This includes forecasting 30+ years into the
future, which will break in PHP on 32-bit unless you avoid time_t based
functions like time() and stick with DateTime objects.
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: developers life

2009-01-19 Thread Ross McKay
On Mon, 19 Jan 2009 21:28:05 +, Nathan Rixham wrote:

well just for the hell of it; and because I'm feeling worn..

anybody else find the following true when you're a developer?
[...]

Yes.
-- 
Ross McKay, Toronto, NSW Australia
Towers get higher, Jobs get cheaper,
 Highways get wider, Love gets deeper
 - Jackson Jackson

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



Re: [PHP] Editing in a text area field

2009-01-11 Thread Ross McKay
G'day Tedd,

Yes, when you have intelligent and cooperative clients -- have 
any to spare?

Hey, you keep your grubby mitts off my intelligent and cooperative
clients, it took a while to get them that way :)

Let's face it: people who pay other people to do a job for them usually
don't understand the job, or they'd probably do it themselves.
Sometimes, they've already done it themselves and worn the consequences,
which is why they're paying for it now. 

Most of them actually understand that, and just need a little
encouragement to work with you on it, as long as you meet them part of
the way and let them get their job done too. 

But you know all of that, you've probably been doing this far longer
than I have.

What I want to know is how to get verbally-oriented people to specify
what it is that they want in emails... :/

The biggest problem is when they copy/paste content from a MS Word
document,

Amen to that. I have had clients say Where did that come from? That 
wasn't in my Word document. I guess it must be something in your code 
screwed it up -- please fix.

Training. Use the Paste from Word button. It doesn't work all the
time, but it works enough of the time. Paste as Text is better still. I
tell them both - with preference for Paste as Text unless they need to
preserve their bold and italics.

Usually, something slips through as invalid HTML or looking slightly odd
in FF. So be it, as long as the website does its job, the client is
happy. If it's a problem, they know who to call.

1. It does bug me when the client finally realizes the problem and 
says Why didn't you know that? or You should have told me or I 
didn't know that would happen even though you warned them six months 
ago.

You get that. Plumbers and doctors get that too. I think it's why God
invented alcohol.

2. Mixing style elements with data is still wrong, at least in my 
mind. 

Yes and no. If you are prepared to break all elements down into
individual rows in a database, tagged with the required layout type, and
determine at runtime how to render them, then go for it. Most of us are
happy to meet clients' requirements by letting them put some HTML into a
database. Where possible, it's minimal, but sometimes it's the content
of a page. 

Preventing clients from specifying styles directly helps preserve the
style consistency of the site, and is easy enough if all they want to do
is specify which bits are headings, bold, italics, and links. Styling of
those layout elements can then be applied through the stylesheets.

It's when they want to specify all sorts of other stuff, like colours(!)
and underline that problems start. I prefer to give 'em classes, but it
doesn't always go my way :(

I realize the client is paying the bill and because of that 
they make the call, but I take pride in my work and I am really 
resistant to clients requiring bad practice.

If I really wanted to meet clients' requirements without letting them do
the odd dodgy thing to *their* site, I'd have to charge a lot more and
thus would probably not get the job.

A designer I did some work for recently lamented that our client had
finally completed inputting their content, and the site was live, but
with the design destroyed by some collages they'd added. Sure, it
wasn't as pretty as the original design, but those collages showed off
the products and premises well, and made the client happy. Designer
isn't bothered, the bill was paid which is what this is about.

There's time for creating masterpieces in retirement :)

I guess it's the age old problem of dealing with actions vs consequences.

I see it as more like: good, cheap, fast, pick ONE.

Thanks for the tip on TinyMCE -- I'll look into that.

As Eric mentions, FCKEditor can do this stuff too, and I imagine yui and
others do as well. You just need to configure them to fit your
requirements.
-- 
Ross McKay, Toronto, NSW Australia
Before enlightenment: chop wood, carry water;
 After enlightenment: chop wood, carry water - Wu Li

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



Re: [PHP] Editing in a text area field

2009-01-11 Thread Ross McKay
On Sun, 11 Jan 2009 09:59:22 -0500, tedd.sperling wrote:

I've tried stripping out all Gremlins, like so:

That looks like a great (slow) way to rip out characters that probably
ought to be there, like left and right single and double quotes, em and
en dashes, ellipses, copyright and trademark symbols, etc.

Isn't that causing a problem, rather than dealing with one?

If the problem is one of validation, then maybe you should investigate
character sets and the full abilities of htmlentities.
-- 
Ross McKay, Toronto, NSW Australia
The chief cause of problems is solutions -Eric Sevareid

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



Re: [PHP] Editing in a text area field

2009-01-10 Thread Ross McKay
On Sat, 10 Jan 2009 09:58:24 -0500, tedd.sperling wrote:

Never store any html whatsoever in a database.

HTML is presentation and is NOT data.

Except when HTML is data, e.g. CMS. And it's better to let people input
that using something like TinyMCE than to let them put in b tags
themselves and forget to close them.
-- 
Ross McKay, Toronto, NSW Australia
Nobody ever rioted for austerity - George Monbiot

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



Re: [PHP] Editing in a text area field

2009-01-10 Thread Ross McKay
On Sat, 10 Jan 2009 10:40:43 -0500, tedd.sperling wrote:

[...]
One might want to design a CMS for a client (I've done it) such that 
you limit the client's ability to inject presentation choices, such 
as using bold/italic tags. But that also requires more programming 
effort to determine if the client has entered well-formed html, which 
is not easy to do. Lot's of effort for little return.

With a little cooperation from the client, and a properly configured
TinyMCE, you can fairly easily limit what HTML tags they use. You can
then provide a set of CSS classes for specific styles used within the
site, and tell TinyMCE about those classes so that the user can make use
of them (via the Styles drop-down).

The biggest problem is when they copy/paste content from a MS Word
document, but again, with cooperation from the client this can be
cleaned up a bit with the Paste from Word and Paste as Text buttons. If
you really want to limit their ability to mess things up with pasting
from word, specify restrictive limits on the HTML tags and make them
pick CSS classes (styles).

When confronted with the choice, I try to guide clients into CMS's 
where I use constructs like 'Please enter the headline here: and 
Please enter the body of the text here: and then provide the h1 
and p tags in the html that delivers the content. That way I 
control both the data and presentation.

That's my preference too. Unfortunately, it doesn't always meet the
client's requirements. They want to enter rich text, so rich text they
get. Where all they want to do is highlight some things bold or italics,
I only let them have p, br/, a, strong, and em. Something
else? Let them use the class attribute on anything, or perhaps give them
access to h1, h2, h3.

Sometimes, they want complete freedom, so they get it. They're paying.

I could imagine a database containing what h1 means (i.e., 
font-size, margins, color), but that would not be any different than 
a simple css file, would it not? And be much simpler.

If you set up whichever rich text editor you use correctly, the user
should be able to see h1 as defined in your CSS - using CSS! There is
no need for a database to know anything about what h1 tags mean.
With TinyMCE, it means having a subset of the website's stylesheet
duplicated for the editor (and perhaps modified a little too), but
that's no drama once the site design has settled down.
-- 
Ross McKay, Toronto, NSW Australia
It doesn't matter if the Rock wants to go get diamond rings or not!
- The Rock

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



Re: [PHP] Editing in a text area field

2009-01-10 Thread Ross McKay
tedd wrote:

The argument over what HTML is, will never be resolved.

I say it's a delivery mechanism and tags such as b and i are 
unwanted elements. They simply confuse/blur the purpose of the 
language.

I should have said strong and em, I guess. Of course, copypasta from
another rich text editor can put in b and i but you should be able
to handle that as strong and em, and then define what you want that
to look like in CSS.

HTML is a markup language. The actual appearance should be left to
stylesheets, but HTML is how users specify which bits of text get which
appearance. 

Sometimes, the only way to meet a client's requirements is to allow
content stored as HTML. IMHO, the worst thing you can do there is let
them type in the HTML tags themselves; as you have noted, they forget to
close tags, then complain when the website breaks. That's where the
many browser-based (mostly JavaScript) rich text editors come in to
their own.
-- 
Ross McKay, Toronto, NSW Australia
Nobody ever rioted for austerity - George Monbiot

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



Re: [PHP] Editing in a text area field

2009-01-10 Thread Ross McKay
Nathan Rixham wrote:

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

I almost agree, except that there are attributes that define the
behaviour of HTML elements that cannot be defined by css; such trivial
things as href, name, class, id, tabindex, maxlength, value, etc.

I know, I'm nit picking a bit...
-- 
Ross McKay, Toronto, NSW Australia
Words can only hurt if you try to read them. Don't play their game - Zoolander

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



Re: [PHP] Editing in a text area field

2009-01-10 Thread Ross McKay
On Sat, 10 Jan 2009 17:01:28 -0500, Stephen wrote:

How do you suggest dealing with a need to allow italics, bold, 
underlines, etc?

Give them a rich text editor, IMHO. That way, you get close tags!

Some examples:

http://tinymce.moxiecode.com/
http://www.fckeditor.net/
http://developer.yahoo.com/yui/
http://geniisoft.com/showcase.nsf/WebEditors

I see forum web sites that allow the user to enter [b]bold text[/b] for 
example.

I would like to do this.

Anyone have a function to convert this kind of thing to HTML?

http://au2.php.net/manual/en/book.bbcode.php
-- 
Ross McKay, Toronto, NSW Australia
The chief cause of problems is solutions -Eric Sevareid

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



[PHP] Re: Unique Object Instance ID..?

2009-01-10 Thread Ross McKay
On Sat, 10 Jan 2009 23:31:29 +, Nathan Rixham wrote:

[...]
all I need is a completely unique id for each object instance that can 
never be repeated at any time, even in a multiserver environment (and 
without using any kind of incremented value from a db table or third 
party app)

Have you looked at uniqid() ?

http://au2.php.net/manual/en/function.uniqid.php

I use it in a couple of places, converted to a more compressed format:

$id = explode('.', uniqid(rand(), TRUE), 2);
$id = base_convert($id[0], 16, 36) . '.' . base_convert($id[1], 16, 36);

Returns stuff like this:

9xm1k6oodk8o00s4wc.50nplu
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



Re: [PHP] Editing in a text area field

2009-01-10 Thread Ross McKay
Ashley Sheridan wrote:

FCKEditor is a good editor (although poorly named!) that allows you to
set it not to use b and i tags and force it to convert them to
strong and em instead. Couple this with a decent regex and you can
strip out the extra style tags which result from a pasted MSWord
selection.

Likewise with TinyMCE (and I suspect many of the others). Given the
abundance of good rich text editors, I don't see any good reason for
making clients enter HTML tags directly - it only confuses them.
--  
Ross McKay, Toronto, NSW Australia
The lawn could stand another mowing; funny, I don't even care
- Elvis Costello

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



Re: [PHP] Unique Object Instance ID..?

2009-01-10 Thread Ross McKay
On Sat, 10 Jan 2009 18:42:01 -0700, Nathan Nobbe wrote:

checkout spl_object_hash()

http://php.net/function.spl_object_hash

NB: only guarantees uniqueness for objects instantiated and in memory at
the same time. See the comments on that page for an example of creating
identical object hashes for two separate and distinct instances.
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: First steps towards unix and php

2009-01-08 Thread Ross McKay
On Thu, 8 Jan 2009 11:44:48 -0500, Frank Stanovcak wrote:

I've been a microshaft punk for some time now, and am just getting ready to 
try to step over to unix on one of my own boxes.

Does anyone have any suggestions on which flavor would be a good idea to 
start with?  I'm looking mostly for compatibility with php, mysql, and other 
web based programming languages.

What Nathan said, test each candidate in a VM like VirtualBox to see
which you might be comfortable in. Then pick Fedora :)

Seriously, any of the major distros (or their derivatives) would be
good, as they take care of the build dependencies for you via packaging
systems. Check them out here:

http://distrowatch.com/dwres.php?resource=major

Picking a desktop is harder, especially coming from a Windows world.
Linux has a great many desktops, each with advantages and disadvantages.
Many distros allow you to easily switch between at least KDE and GNOME,
maybe even XFCE. A tiny distro called DSL-N (damned small linux NOT)
allows you to boot up in several of the lighter desktops to check them
out. Realise that you can pick a GNOME or KDE desktop and still run apps
made to suit one of the others, with maybe just some minor integration
glitches; I run GNOME and use a number of KDE programs just fine.

You should also check out editors and IDEs - STFW for previous posts
made to this and other groups. Then pick Geany ;)

And don't forget to add a revision control system, e.g. Subversion.
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



Re: [PHP] Re: First steps towards unix and php

2009-01-08 Thread Ross McKay
Skip Evans wrote:

I used Kate on Ubuntu for a code editor. I just read through a bit about 
Geany (was not familiar with it), but don't see too much more it would 
do for me than Kate.

What are some of your favorite features of Geany I should be aware of?

There's probably not much that Geany does that Kate doesn't, to be frank
(other than run on Windows too). OTOH, there are many things that Kate
does that Geany doesn't.

However, being built on GTK, Geany is a little quicker, especially now
that Kate's gone all KDE4. Certainly, when I was running on a P-III @
666MHz, Kate was frustratingly sluggish while Geany was very quick and
responsive. Thinking about it now, that's probably why I picked Geany
over the other options at the time.

John Corry wrote:

Kate for PHP development? That sounds really slow and inefficient.
Eclipse and Zend studio offer such efficiencies as code
completion/hints (PHP core or any other included classes/files), code
explorer views/trees, SVN/CVS support, debugging...very capable IDEs.

Geany has basic code completion hints for built-in functions, and
file-by-file code explorer views but not a project-wide code explorer.

For me, feature-rich IDEs mean more stuff I need to remember and fight
with, and that's a problem these daze. I do a fair bit from the shell,
including most SVN ops. Small and fast, with snippets, and regex search
and replace, is pretty much all I need. Except when debugging (for which
I've been using NetBeans). Hmmm... must do something about that some
day.
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot

2009-01-07 Thread Ross McKay
Richard Heyes wrote:

So where's the advantage of VARCHAR ?

Less space on disc = less data retrieved from disc = faster data
retrieval - sometimes. If you have small columns, a small number of
rows, or both, then char columns may be faster. If you have large
columns of varying actual length, lots of rows, or both, then varchar
columns may be faster.

The best thing for performance is reducing the number of times you hit
the disc. If you can cache (more of) a table by using varchars instead
of chars for some columns, then varchars have an advantage.

Knowing what your data requires leads to better results than picking in
advance whether to use char or varchar (or text). Measuring is even
better.

Oh, and for a column with a limited range of values, enum beats 'em all!
-- 
Ross McKay, Toronto, NSW Australia
You can't control what you can't measure - Tom DeMarco

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



Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot

2009-01-07 Thread Ross McKay
Stuart wrote:

Got anything to back that up?

http://www.mysqlperformanceblog.com/2008/01/24/enum-fields-vs-varchar-vs-int-joined-table-what-is-faster/

Thanks, that'll do nicely. Even that strapped chicken test with tables
that are likely cached shows enum as the fasted, albeit only marginally.
Where disc reads are required, or even (hand-to-forehead) a large table
scan, the difference would be much more significant.

Not that I'd advocate enum columns widely instead of char or varchar (or
text); horses for courses, whatever suits the data best. As I said in
the last post, knowing what your data requires leads to better results
than picking in advance whether to use char or varchar (or text).
Measuring is even better.
-- 
Ross McKay, Toronto, NSW Australia
There is more to life than simply increasing its speed. - Gandhi

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



Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot

2009-01-07 Thread Ross McKay
Richard Heyes wrote:

I've not come across many databases where 20-50 tables have 10 million
rows each. And with a table of that size, then I might be coerced into
thinking about the storage requirements a little more. Maybe.

Not on MySQL, but I've worked on databases with hundreds of millions of
rows, in multiple tables. Converting varchars to chars would mean huge
amounts of expensive SAN storage, plus the overheads of scanning through
rows on disc suddenly become important.

Maybe not applicable to little website databases, but again... know your
data and pick the appropriate type. I use a mix of char, varchar and
text depending on the requirements. And enum :)

 Now add another 20 to 50 tables depending on
 the database. If you want to throw away money go ahead, but I don't know
 too many clients that want to waste 10 gigs of mostly padded space.

I don't know of many clients who care as long as it is performant and
cost effective. Wasting 10 Gigs is not a great deal when you have a
drive measured in the hundreds of Gigs.

Performant isn't a word - Microsoft marketing term.

Wasting 10GB is important when it's expensive storage, backed up,
replicated, transferred to other systems over comms links, etc. It also
means more disc access, unless you have a surplus 10GB RAM for extra
caching. Disc access is usually what kills database performance.
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot

2009-01-05 Thread Ross McKay
First, start here:

http://dev.mysql.com/doc/refman/5.1/en/string-types.html

Stuart wrote:

 varchar: only the space required for the content of the field is
 allocated per row but these fields are limited to 255 chars (IIRC) in
 length.

In MySQL, varchar can hold up to 65,535 characters, but the actual
maximum size is limited by the maximum row length (65,535 bytes) and the
character set (e.g. utf8 uses between one and three bytes per
character).

Maybe you're thinking of char, which is limited to 255 characters.

Robert Cummings wrote:

It's generally worth mentioning that you can usually index char or
varchar, but not text.

No, you can index a text column, but it will only index part of the
column:

Only the first max_sort_length bytes of the column are used when
sorting. The default value of max_sort_length is 1024. - TFM.

Also, you can create a FULLTEXT index on text columns stored in the
MyISAM engine. (which is a PITA, because if you want ACID transactions
and full-text searching, you need to create and maintain a MyISAM shadow
table of the data you want to full-text search on)
--  
Ross McKay, Toronto, NSW Australia
The lawn could stand another mowing; funny, I don't even care
- Elvis Costello

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



Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot

2009-01-05 Thread Ross McKay
Micah Gersten wrote:

You're referencing the 5.1 manual.  In the 5.0 manual it says that
VARCHAR was extended to 65535 in 5.0.3, so you're statement is not
entirely correct, nor was Stuart's.  That's why I linked him to the 5.0
manual page on data types.

Good point, thanks! I usually read from the .chm manual but just jumped
to the website to grab a link. Should have been:

http://dev.mysql.com/doc/refman/5.0/en/string-types.html

I note that Stuart was most likely talking about MySQL = 4 which had a
limit of 255 characters for varchar.
-- 
Ross McKay, Toronto, NSW Australia
My old man told me one time, you never get wise, you only get older
- Dandy Warhols

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



Re: [PHP] Chrome 1.0 released

2008-12-14 Thread Ross McKay
On Sun, 14 Dec 2008 09:28:49 -0500, tedd.sperling wrote:

IE's popularity is dropping. I know it depends upon what site you 
test, but I like this set of stats:

http://www.w3schools.com/browsers/browsers_stats.asp

You see here that IE6 and IE7 together hold less than 50 percent.
[...]

I like those stats, but they basically show that web-savvy users who are
trying to develop websites are tending to dump IE in favour of Firefox.
This is probably in large part because of extensions like Web Developer
and Firebug. You need to take the user base into account when viewing
such statistics.

The site that Richard posted a link to shows this variability nicely:

http://www.upsdell.com/BrowserNews/stat.htm
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: Poll of sorts: Javascript Form validation or PHP

2008-12-06 Thread Ross McKay
On Fri, 5 Dec 2008 12:28:08 -0600, Terion Miller wrote:

I have a huge form to validate and wonder which is better javascript
validation or php, the page is a php page, I actually put js validation on
it but then it stopped working (stopped inserting into the db) not sure if
that had anything to do with it
What does everyone prefer?

As per all others here (and nice to see that!) I say always validate in
PHP, and if you have time, add JavaScript to improve the user
experience. Never trust your inputs to be valid; always check in PHP.

Terion who is actually finally learning stuff to her surprise!!

Good, because when you stop learning is when you start dying...
-- 
Ross McKay, Toronto, NSW Australia
Before enlightenment: chop wood, carry water;
 After enlightenment: chop wood, carry water - Wu Li

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



Re: [PHP] Experience (was: while-question)

2008-11-17 Thread Ross McKay
On Mon, 17 Nov 2008 14:30:34 -0500, tedd.sperling wrote:

I can program with rocks -- and do a good job of it. I can make a one 
that can stand for a couple of thousand years.

http://xkcd.com/505/
-- 
Ross McKay, Toronto, NSW Australia
Before enlightenment: chop wood, carry water;
 After enlightenment: chop wood, carry water - Wu Li

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



Re: [PHP] Experience (was: while-question)

2008-11-17 Thread Ross McKay
On Mon, 17 Nov 2008 11:43:31 -0800, Yeti wrote:

Ok, ok I admit it. PHP is a programming language. I guess I drank too
much assembly code today.
By the way ... Motorola 68000! Those were to good old days.

680x0 was the nicest machine I ever met - especially nice when writing
for OS-9/68000. Yup, them was the daze...

My perspective: scripting can be programming light (or lite, if you're
illiterate and/or in marketing), but can just as easily be serious
programming. This is especially so, now that many scripting languages
support OO to some degree. Equally, I've seen some C code that I'd be
somewhat reticent to call programming.

Programming isn't all about stacks of procedural code either; consider
declarative programming. (Yes, Ash, XHTML and CSS are effectively a form
of declarative programming!)

http://en.wikipedia.org/wiki/Declarative_programming

The trick with languages is to:

* pick the one (or more) appropriate for the task
* pick the design approach appropriate to the language (and other tools)

To be a decent web developer, with database-driven pages, one often has
to manage a design that spans multiple languages and sometimes more than
one programming paradigm. Consider a simple HTML input form sending
information to a database:

* (X)HTML for the page, including the input form
* CSS for managing layout and styling, even active menus etc.
* maybe some JavaScript for smart validation or field management
* server-side programming for accepting the form post
* maybe some database programming (SQL) for updating the database

Compound that with some mostly-declarative XSLT, Flash, Java, .htaccess
etc. and you've got a relatively complicated toolset that traditional
programmers scratch their heads over when initially making the switch
from their one-language development environment. (Frameworks strive to
clean that up for developers)

So, is PHP programming? :)
-- 
Ross McKay, Toronto, NSW Australia
Pay no attention to that man behind the curtain - Wizard of Oz

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



[PHP] Re: DOCTYPE, javascript and Firefox

2008-10-31 Thread Ross McKay
On Thu, 30 Oct 2008 15:45:55 +0200, Arno Kuhl wrote:

[...]
This code works fine in IE, Opera and Chrome, but gives a javascript error
in FF when I click the radio button: autostartlabel is not defined.
However if I comment out the DOCTYPE line in the header it works fine in all
browsers including FF. (Took ages to narrow it down to the DOCTYPE.) Does
anyone know why, and how to fix it?

You aren't doing it the DOM way, and telling FF3 to use HTML 4.01 (or
XHTML) means you should be doing it the DOM way. IE, Opera and Chrome
are being lax; FF isn't.

input type='radio' name='autostart' value='0'
 onclick=document.getElementById('autostartlabel').className='disable';
 document.getElementById('startdate').disabled=true; No
input type='radio' name='autostart' value='1'
 onclick=document.getElementById('autostartlabel').className='normal';
 document.getElementById('startdate').disabled=false; Yes
label id='autostartlabel'Startdate/label
input type='text' name='startdate' id='startdate' disabled='disabled' 

Better would be to throw the actions into a function, e.g.

script type=text/javascript
function setStartDateDisabled(asDisabled) {
var autostartlabel = document.getElementById('autostartlabel');
if (autostartlabel)
autostartlabel.className = asDisabled ? 'disable' : 'normal';

var startdate = document.getElementById('startdate');
if (startdate)
startdate.disabled = asDisabled;
}
/script

input type='radio' name='autostart' id='autostart_0' value='0'
 onclick=setStartDateDisabled(true); No
input type='radio' name='autostart' id='autostart_1' value='1'
 onclick=setStartDateDisabled(false); Yes

PS: pick HTML4 or XHTML; your sample code shows the latter, the DOCTYPE
says the former.
--  
Ross McKay, Toronto, NSW Australia
The lawn could stand another mowing; funny, I don't even care
- Elvis Costello

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



[PHP] Re: PHP Dev Facts

2008-10-16 Thread Ross McKay
On Fri, 17 Oct 2008 00:14:18 +0100, Nathan Rixham wrote:

*Procedural or OOP?*

OOP, except really small stuff.

*Dev OS*

Fedora 9

*Dev PHP Version*

5.2.6

*Live Server OS*

Hosted services - var. Linux, Windows 2003 Server

*Live Server PHP Version*

Mostly 5.2.3+, some 4.x (haven't looked lately) but I imagine even the
worst of those hosts will upgrade soon, or die.

*Which HTTP Server Software (+version)?*

Apache 2.2 on Linux, IIS 6.0 on Windows

*IDE / Dev Environment*

Geany, mostly

*Preferred Framework(s)?*

Prefer small code libraries over large frameworks. Otherwise, I'd be
writing Java or .NET, eh?

*Do you Unit Test?*

Yes.

*Most Used Internal PHP Class*

A MySQL wrapper - needed it for a PITA host once, still easier / lighter
than others (although PDO, adodb interest me)

*Preferred OS CMS*

Joomla is great, SilverStripe is nicer but I have yet to use it in
anger.

*Anything else you use frequently in you're PHP'ing that's worth 
mentioning:*

* iepngfix.htc - lets me use PNG with alpha channels in IE6
* csshover.htc - lets me do pure-CSS fly-out menus
* tinymce - lets me do rich-text editing for admin pages (simple CMS)
* KVM - lets me test in IE6/IE7 without having to reboot into Windows
* Subversion - because I value my time :)
* Meld - because I value my sanity! (graphical diff/merge)
-- 
Ross McKay, Toronto, NSW Australia
Before enlightenment: chop wood, carry water;
 After enlightenment: chop wood, carry water - Wu Li

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



Re: [PHP] [Semi-OT] Tonns of jobs available

2008-10-10 Thread Ross McKay
On Fri, 10 Oct 2008 14:54:19 -0400, tedd wrote:

[...]
Is everyone stupid or is it just me?  :-)

Yes. No.

However, the software world is amazingly amenable to both propagating
stupidity and allowing it to grow and foster further stupidity. Probably
because when it all does finally collapse, there's nobody underneath to
get flattened :)

TDWTF likes to point out the difference between success in the real
world and success in the software world: in the real world, it isn't a
success just because the client paid for it, it actually has to stay up
and working without constant patch-ups (on which basis, I'd guess the
Leaning Tower of Pisa isn't really a success :)

http://thedailywtf.com/Articles/What_Could_Possibly_Be_Worse_Than_Failure_0x3f_.aspx

If/when you recognise stupidity in your own actions, stupid tends to
stop. If you never see the stupidity... :)
-- 
Ross McKay, Toronto, NSW Australia
It's not the right time to be sober,
 Now that the idiots have taken over - NOFX

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



[PHP] Re: question about EOF

2008-09-30 Thread Ross McKay
On Tue, 30 Sep 2008 12:48:35 +0800, LKSunny wrote:

i want on inner EOF do something, calculate and call function ? can not ? if 
yes, how to ?

Same way as you do with  strings. e.g.

?php
class foo {
  function bar() {
return 'world!';
  }

  function hello() {
echo ENDHELLO
Hello, {$this-bar()}
ENDHELLO;
  }
}

$foo = new foo();
$foo-hello();
?
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: Making $_POST and $_FILES play together nicely

2008-09-30 Thread Ross McKay
On Tue, 30 Sep 2008 11:11:33 -0500, Mike Potter wrote:

I have a PHP5 .class file that validates form inputs and sends
notification emails from contact pages. Recently a client wanted to
add a file upload function. No sweat, I thought.

Well, I can't get the $_FILES portion to validate properly in my
.class file, since it apparently only registers the $_POST vars. This
is the section of code, *currently functional as-is* that I need to
modify so that $_FILES is also processed:
[...]

Not wanting to comment on your formfield validation, here's what I do
with file upload validation:

if (!isset($_FILES[$inputName])) {
// handle form error (e.g. forgot form encoding type!)
}
else
switch ($_FILES[$inputName]['error']) {
case UPLOAD_ERR_OK:
// process as per nicely uploaded file
break;

case UPLOAD_ERR_NO_FILE:
// file wasn't attached; if mandatory, complain!
break;

case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
$errmsg .= # error uploading file: file too big.br/\n;
break;

default:
$errmsg .= # error uploading file: 
. $_FILES[$inputName]['error'] . .br/\n;
break;
}
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: Unicode problems

2008-09-26 Thread Ross McKay
On Fri, 26 Sep 2008 10:39:33 +0100, Nathan Rixham wrote:

 [...]
 I couldn't find any good function/script to convert all my files to UTF-8
 and then I built my own. It uses iconv and works like a charm. But
 unfortunately I still can't get all pages to work. I have no idea why or
 how, but *some* queries return the text in ISO-8859-1. I even dropped the
 table and recreated them explictly saying it's a UTF8 table but some rows
 are in ISO and others in UTF-8 (that or some mysql_fetch_* functions
 converts them).

Can you confirm: are you telling your PHP connection into MySQL to use
Unicode? e.g. tell MySQL directly by executing the following statement:

set names 'utf8'

Also, is some of your data going through htmlentities() and coming out
wrong? If so, look at specifying the character set:

htmlentities($someText, ENT_COMPAT, 'utf-8');
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



Re: [PHP] PHP tags - any reasons to close ?

2008-09-23 Thread Ross McKay
On Tue, 23 Sep 2008 19:48:12 +0200, Per Jessen wrote:

Simcha Younger wrote:

 I often put a number of empty lines at the end of a script since I
 enjoy editing with the script higher up on the screen, and very few
 editors allow you to scroll the last lines of the program above the
 bottom of the screen. (Crimson Editor is the only one I have found
 that does this.)

vi has no problem doing that.

Geany does this too, unless you ask it not to (preferences).
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



Re: [PHP] Re: MySQL Workbench coming for Linux

2008-09-18 Thread Ross McKay
Luke wrote:

so it's like Microsoft Access? I don't get it...

No, Microsoft Access is a development environment sitting on top of a
simplistic database (JET). Access gives you a nice GUI to help you
interactively build up your database, and it makes a great prototyping
tool and data massage tool, but it isn't very good for data modelling.

I'm talking about proper data modelling tools, where you design the
conceptual and physical databases, then generate scripts to build them
(e.g. in Oracle, Microsoft SQL Server, MySQL, etc.) and generate nice
documentation including diagrams that help you understand your database
at a quick glance. Usually, they can also suck a live database back in
(reverse engineer) to help you document whatever nasty hack you've
inherited from your predecessors in a legacy application ;-)

MySQL Workbench is what I really want, or something similar. I just
happen to already have a copy of Visio Enterprise Architect that comes
close enough to doing the job, so I use that until Workbench is up and
working properly on Linux. I hack the generated SQL scripts (minimally)
to make them MySQL friendly, and I hack the generated RTF data
dictionary files to make them more to my liking, and load them into OOo
and embed the ER diagrams, to get nice, easily referenced documentation
on my DBs.

See here for more information about data modelling tools in general, and
a couple of specific ones:

http://en.wikipedia.org/wiki/Entity-relationship_model
http://en.wikipedia.org/wiki/CA_ERwin_Data_Modeler
http://en.wikipedia.org/wiki/ER/Studio
http://en.wikipedia.org/wiki/Toad_Data_Modeler
http://en.wikipedia.org/wiki/MySQL_Workbench
-- 
Ross McKay, Toronto, NSW Australia
Before enlightenment: chop wood, carry water;
 After enlightenment: chop wood, carry water - Wu Li

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



Re: [PHP] Re: MySQL Workbench coming for Linux

2008-09-17 Thread Ross McKay
On Wed, 17 Sep 2008 09:00:45 +0100, Luke wrote:

What is it?

I'm only familiar with the MySQL tools such as Query Browser and Admin?

http://dev.mysql.com/downloads/workbench/5.0.html

In short, it's a data modelling tool. Such things are very handy for
designing and building databases, and usually also for documenting them.
If your DB has more than a handful of tables, it's well worth the
effort.
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



Re: [PHP] Re: MySQL Workbench coming for Linux

2008-09-17 Thread Ross McKay
Bastien Koert wrote:

what about dia on llinux? Not quite as nice as visio...but livable

The Enterprise Architect version of Visio lets you add column
definitions to your entities, add foreign key relationships, add
indices, add comments at the table and column level, and then generate a
build script. It also has a reporting tool for generating a data
dictionary. In short, it makes a pretty good stab at being a data
modelling tool (imperfectly, but sufficiently for my needs).

Dia is just a diagramming tool (unless you can tell me otherwise).
-- 
Ross McKay, Toronto, NSW Australia
Nobody ever rioted for austerity - George Monbiot

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



Re: [PHP] Re: Why MS Won't Retire Browsers -- was: Interntet Explorer 8 beater 2

2008-09-16 Thread Ross McKay
On Tue, 16 Sep 2008 20:11:22 +0100, Ashley Sheridan wrote:

Would it be totally off topic if everyone were to say what their
favourite OS was and why? I'm just a little curious as to what OS's
people use in this field.

Likely yes, but: Fedora 9 works nicely for me and SWMBO. Essentially
though, any Linux with a decent desktop manager would do. I just wish I
could find a Linux-native data modelling tool I liked, then I could
ditch WinXP for all except testing in IE! :)

(actually, not quite true; some customers manage to create incredible
concoctions in Microsoft Word that just don't come across right in any
Linux word processor, so I still need to open up Microsoft Word
occasionally)
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] MySQL Workbench coming for Linux

2008-09-16 Thread Ross McKay
Posting this here, because a few people responded when I mentioned not
having a Linux-native data modelling tool. Apparently, MySQL Workbench
should be alpha-ready by end of the month...

http://dev.mysql.com/workbench/?p=138

Maybe I can ditch Visio one day soon... :)
-- 
Ross McKay, Toronto, NSW Australia
Hope is the dream o a foolish man - The Wee Book of Calvin

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



[PHP] Re: Email - Best practice/advice please

2008-09-12 Thread Ross McKay
On Fri, 12 Sep 2008 11:55:03 +0100, Tom Chubb wrote:

I have generally been using the PHP mail function for sending emails from
contact forms on websites, but have recently had problems with a lot of
mails being delivered to junk/spam folders. [...]

If you don't end up using PHPMailer, make sure that you are setting
these fields properly or SpamAssassin et al will suspect your emails as
being SPAM.

From: a valid (looking) email address
Date: the send date in RFC-2822 format, date('r')
Message-ID: some unique ID
Content-Type: whatever is appropriate for your email (e.g. text/plain)

Good idea:
X-Mailer: 'PHP/' . phpversion()

To test, send some emails to yourself at an account that has
SpamAssassin and look at the headers to see what SpamAssassin says as it
should indicate what it doesn't like about your emails. Try this first,
before messing with the headers above.
--  
Ross McKay, Toronto, NSW Australia
You can't have egg bacon spam and sausage without the spam. - Pythons

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



Re: [PHP] Re: Email - Best practice/advice please

2008-09-12 Thread Ross McKay
Tom Chubb wrote:

I have read somewhere before about creating a message id with the datetime
and a random number.

Something like this:

'' . date('U') . '.' . rand() . '.php@' . $_SERVER['SERVER_NAME'] . ''

Still I think I'm going to be ending up down the phpmailer route!

It's the easiest route, and will catch some other problems for you into
the bargain.
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: Interntet Explorer 8 beater 2

2008-09-11 Thread Ross McKay
On Thu, 11 Sep 2008 08:25:11 +0100, Colin Guthrie wrote:

[...]
It should be respected that browsers go out of date and beyond that time 
*noone* supports them, not their authors or the web developing public.

The worst thing about Vista is that not enough Win2K and WinXP (IE6)
users want to upgrade to it (and who can blame them?) The best thing
about Google Chrome is that maybe, just maybe, the tide will turn
against Microsoft Word as the tech-unsavvy move to this cloud
computing buzzword-paradise (onto Linux-based cheap PCs with no IE6!)

Ah, a man can dream, can't he?
-- 
Ross McKay, Toronto, NSW Australia
Hope is the dream o a foolish man - The Wee Book of Calvin

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



[PHP] Re: Interntet Explorer 8 beater 2

2008-09-11 Thread Ross McKay
On Thu, 11 Sep 2008 14:22:30 +0100, Colin Guthrie wrote:

[...] I'm not sure how you would police it, but 
there should be a badge of honour associated with the system in some 
way, probably overseen by W3C.

Like this?

http://en.wikipedia.org/wiki/Acid2
-- 
Ross McKay, Toronto, NSW Australia
You can't control what you can't measure - Tom DeMarco

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



Re: [PHP] Re: Interntet Explorer 8 beater 2

2008-09-10 Thread Ross McKay
Michael McGlothlin wrote:

[...] I think web developers 
should look into a class action case against Microsoft for failing to 
make their browser standards compliant - it sure costs us a lot extra in 
development time. :p

Let me know where the PayPal donate button is... DW  I are fed up with
having to find nasty kludges for IE6 every time we build a website!
-- 
Ross McKay, Toronto, NSW Australia
I think you are blind to the fact that the hand you hold
 is the hand that holds you down - Everclear

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



Re: [PHP] Re: Interntet Explorer 8 beater 2

2008-09-08 Thread Ross McKay
On Mon, 8 Sep 2008 13:03:18 +0100, Richard Heyes wrote:

I really don't want to install a beta (though I did install Chrome, so
maybe that should be an MS beta) but I am interested in how it
performs.

That's what God invented the virtual machine for. Load up Windows XP in
KVM, QEMU, VirtualBox, VMware or whatever takes your fancy, then plaster
it with IE8b2 and see what breaks.

I have to admit it's been sitting in a folder here waiting for just that
to happen for ... when was it released? Crikey, work can really get in
the way sometimes, eh?  :)

(although I did find time to test Chrome in KVM - and I must say it is
fast, if not particularly useful yet)
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



Re: [PHP] Re: Interntet Explorer 8 beater 2

2008-09-08 Thread Ross McKay
Jochem Maas wrote:

how do you handle licensing/activation in these VMs?
I have parallels on my Mac and a 'proper' bootcamp install of WinXP
which I need for work ... and I'm not about to screw with that install
for the sake of testing another POS version of IE. 

You need a license for each instance of XP that you run. AFAIK, you only
need one license to multi-boot XP on a single computer (but you should
check that!) so I don't see why it would be any different for multiple
images run singly in a VM.

NB: I'm talking XP here; I vaguely recall something about the Vista EULA
(spit!) specifically excluding installation in a non-MS VM, so you'd
need to check with your lawyers on that one... :/

However, I'm using my MSDN Universal (or whatever it's now called) copy
of XP. I built an image once, backed it up, and it became my IE6 test
image. I copied it a couple of times for an IE7 image, an IE8 image (as
yet unused!), a Chrome image, and a .NET environment for running a
couple of Windows tools and testing legacy .ASP websites I have to
maintain from time to time.

It all runs very nicely in KVM, and lets me test in IE without shutting
down Linux :)

but I'd love to
be able to have a prinstine winXP image laying about that I
can repeatedly screw up in the name of compatibility and
cross-browser testing.

Certainly QEMU / KVM, and I'm pretty sure the others too, allow you to
run in snapshot mode whereby hard drive writes are held in temporary
files and only written back to the image if / when you tell the VM to
commit. Thus, you don't even need to refresh the image if you just test
in snapshot all the time. (and work with network data files, or version
control workspaces)
-- 
Ross McKay, Toronto, NSW Australia
And don't forget ladies and gentlemen
 you have to buy this new thing that you don't have
 and if you have it
 well actually
 the new better version of the thing that you have
 well it just came out - Jackson Jackson

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



[PHP] Re: PHP Equivalent of JavaScript whatever.toFixed(2)

2008-09-08 Thread Ross McKay
Arnie Shore wrote:
 Folks, I need to take a given float value to, say, two decimals, as per
 subject JS.  I've RTFM, but to no avail.

On Mon, 08 Sep 2008 22:03:54 +0200, Sjoerd wrote:
$str = sprintf(%01.2f, $number);

Skinning cat, method two:

$str = number_format($number, 2);
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: how to write good code

2008-09-01 Thread Ross McKay
On Mon, 1 Sep 2008 08:50:45 -0700 (PDT), larry wrote:

Write a lot of code, rewrite code you think is messy (we can always do
better).
The more you do the better you should get.

Here is some inspiration on that:
http://www.codinghorror.com/blog/archives/001160.html

NB: the message of that blog post isn't valid at the most simplistic
level (just write lots of code), and the comments to the post explain
why. Don't just read the guy's blog, read the comments! As an extreme
example, consider the latest repost of a classic at TheDailyWTF:

http://thedailywtf.com/Articles/Classic-WTF-To-the-Hexth-Degree.aspx

5,000+ LOC that misses the point, and can be easily replaced by a
one-line framework call. Clearly, just writing lots of code wasn't this
coder's greatest challenge.

Practice makes perfect, but only if you review your output with an eye
to pick up faults.

On rewriting messy code, I've always approached a bug fix on legacy code
with the view that tidy code breaks less, or at least breaks where you
can see it. More often than not, tidying up some rat's nest of code will
magically fix the problem anyway, and if it doesn't, it can make the bug
very clear to see. This even has a name: refactoring.

I would posit that writing lots of code is good practice, but learning
good from bad comes from reading code. Read your old code (if you can!)
Read other people's code. Read sites that make fun of bad code (great
way to learn what bad code looks like!) Read what makes code good and
what makes it bad. Then write some more code :)
-- 
Ross McKay, Toronto, NSW Australia
Before enlightenment: chop wood, carry water;
 After enlightenment: chop wood, carry water - Wu Li

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



Re: [PHP] ASCII Captcha

2008-08-31 Thread Ross McKay
On Sun, 31 Aug 2008 05:35:42 -0400, Robert Cummings wrote:

[...] As Stut has
pointed out already, the best filter for spam I've encountered is to
reject posts with links :/

This also is what works for me. However, this is for commercial
websites, not blogs / forums, so links are not expected in posts to
these websites. If they were, well... :/
-- 
Ross McKay, Toronto, NSW Australia
The chief cause of problems is solutions -Eric Sevareid

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



Re: [PHP] ASCII Captcha

2008-08-31 Thread Ross McKay
On Sun, 31 Aug 2008 13:25:52 -0400, Eric Butera wrote:

[...]
Honey Pots
This is a two step process.  First I have a hidden form field that has
a specific value in it.  If this value is tampered with, then I reject
the form.  The second form field is inside of an html comment.  If
that value is posted, then I reject the form since it shouldn't exist.

Nice idea, I'll try that one. Have not heard of any customers with
problems lately, but it happens from time to time... this sounds like a
good buster for automated spam injectors.

thanks!
-- 
Ross McKay, Toronto, NSW Australia
Before enlightenment: chop wood, carry water;
 After enlightenment: chop wood, carry water - Wu Li

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



Re: [PHP] ASCII Captcha

2008-08-31 Thread Ross McKay
On Sun, 31 Aug 2008 18:49:15 +0100, Stut wrote:

Field names
Don't name fields things like name, email, address, postcode, message,  
etc. Instead name them a, b, c, d, e, etc but name your hidden field  
email. That should provoke most bots into changing that value and  
leaves others unsure what to put where so they ignore the form.

The downside of this one is that auto-fill in Firefox will not know how
to populate an email field, a name field, and address field, etc. so
these frequently typed fields will need to be entered by a (now
aggravated) visitor who normally gets to just press down arrow, tab.
-- 
Ross McKay, Toronto, NSW Australia
It doesn't matter if the Rock wants to go get diamond rings or not!
- The Rock

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



Re: [PHP] ASCII Captcha

2008-08-31 Thread Ross McKay
Jochem Maas wrote:

any idea as to whether auto-fill can recognize stuff like:

   foo[email] or email[foo] or email_foo
[...]

AFAIK, the auto-fill form stuff works off previously entered field
names. If a user enters their email address into a field called 'email'
on one site, then another site asks for 'email', Firefox will oblige by
remembering the email address(es) from previous entry.

Thus, if every form used 'foo[email]' then yes, it should work. 

But most forms use 'email', so that's what Firefox remembers.

... me I like to have my cake and eat. ;-)

I've always thought cake was over-rated...
-- 
Ross McKay, Toronto, NSW Australia
Read beans and rice, I could eat a plate twice - Spearhead

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



Re: [PHP] ASCII Captcha

2008-08-31 Thread Ross McKay
Jochem Maas wrote:

figures, no blooming good to us then :-)

No, I wouldn't bother! (It actually p!sses me off when I have to type my
email address into a form because they've decided to pick some unique
name for the field!)

makes me think of another trick to block spam/cruft/etc from
form submissions (including double POSTs) ... set a hidden field
to a random value that session bound and usable only once ... if
the value is not present in the POST or it's not set in the session
as being valid and usable then don't accept the POST ... if the
POST is accepted then remove the value from the session.

Yes, your Honey Pots idea intrigues me, and I'll be stealing it, thanks!

cake is a metaphor. let's imagine it means 'girls' for instance ... 
you with me now? ;-)

Um... nope, no idea what you mean (nodding!).

[She's about to come over and demand her coffee, must fetch ;) ]
-- 
Ross McKay, Toronto, NSW Australia
Such a pretty girl, happy in an ugly place,
 watching all the pretty people
 doing lots of ugly things - Everclear

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



[PHP] Re: how to write good code

2008-08-30 Thread Ross McKay
On Sat, 30 Aug 2008 20:17:18 -0400, Shiplu wrote:

I wanna know how to write good code in php.
Not oop stuff. I wanna know how to write a good php code file.
documentation, comments. indentation etc.
what are the good practices??

Find out what bad is by reading this:

http://thedailywtf.com/Series/CodeSOD.aspx

Then, don't do it like that!

But seriously, you might want to check out this page on Wikipedia, and
follow some of its references:

http://en.wikipedia.org/wiki/Programming_style
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



Re: [PHP] Re: Variable name as a string

2008-08-27 Thread Ross McKay
On Wed, 27 Aug 2008 22:25:44 -0500, Micah Gersten wrote:

You cannot have anything in the brackets for the name in a checkbox
group.  [...]

Bollocks.

form action=?php echo $_SERVER['SCRIPT_NAME']; ? method=post
poption 1 - colour: input type=text name=options[colour]//p
poption 2 - flavour: input type=text name=options[flavour]//p
poption 3 - size: input type=text name=options[size]//p
pinput type=submit//p
/form

?php
function test() {
$colour = $_POST['options']['colour'];
echo pcolour: $colour/p\n;

$flavour = $_POST['options']['flavour'];
echo pflavour: $flavour/p\n;

$size = $_POST['options']['size'];
echo psize: $size/p\n;
}
?

NB: no quotes around array key!

I found this very handy for having variable product options on a simple
shopping cart.
--  
Ross McKay, Toronto, NSW Australia
The lawn could stand another mowing; funny, I don't even care
- Elvis Costello

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



Re: [PHP] Re: Variable name as a string

2008-08-27 Thread Ross McKay
More specifically:

form action=?php echo $_SERVER['SCRIPT_NAME']; ? method=post
poption 1 - colour:br/
# input type=checkbox name=options[colour][] value=red/ redbr/
# input type=checkbox name=options[colour][] value=green/
greenbr/
# input type=checkbox name=options[colour][] value=blue/
blue/p
pinput type=submit//p
/form

?php
foreach($_POST['options']['colour'] as $colour)
echo pcolour: $colour/p\n;
?
-- 
Ross McKay, Toronto, NSW Australia
If ye cannae see the bottom, dinnae complain if ye droon
- The Wee Book of Calvin

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



Re: [PHP] PHP editor for linux

2008-08-14 Thread Ross McKay
On Thu, 14 Aug 2008 23:46:05 -0400, Michael S. Dunsavage wrote:

I use geany and Quantum

+2 for geany (SWMBO uses it too). It's a good general-purpose text
editor and simplified IDE. Build it from SVN, as it has been moving
fairly quickly and distro packages often haven't kept up.
-- 
Ross McKay, Toronto, NSW Australia
Nobody ever rioted for austerity - George Monbiot

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



Re: [PHP] Re: A dumb question regarding sending email

2008-08-13 Thread Ross McKay
On Wed, 13 Aug 2008 15:32:12 +0100, Richard Heyes wrote:

 NSW Australia

North, South, West? Can't you make up your mind? :-)

:) we move around a bit... though not so much for a while now!

Good to see you backup. I mean, back up!

(NSW is the state of New South Wales, on the East Coast of Australia, or
IOW somewhat to the left of Kalifornia and down a bit)
-- 
Ross McKay, Toronto, NSW Australia
Under the big bright yellow sun - Fat Boy Slim

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



[PHP] Re: A dumb question regarding sending email

2008-08-13 Thread Ross McKay
On Wed, 13 Aug 2008 15:46:47 + (UTC), Jonesy wrote:

I'd've thought with Aussie, Southern Cross-oriented globes, it would be 
to the _right_ of Kalifornia and _up_ a bit.

Yes, but I was translating from Strine to Wronglish for the North
Americans ;)
-- 
Ross McKay, Toronto, NSW Australia
I come from a land down under,
 where beer does flow and men chunder - Men At Work

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



[PHP] Re: A dumb question regarding sending email

2008-08-12 Thread Ross McKay
On Tue, 12 Aug 2008 22:07:41 -0400, tedd sperling wrote:

I have a herdoc that I send out as an email -- no problems there.

However, how do I include a link within it?

If I use http://example.com, it's just a string but not an actual link.

So, how do you format a link in a heredoc?

a) most email programs will detect that plain-text URL and turn it into
a link when displaying the email, so... maybe you don't want to bother!

b) send the email with an HTML body (either instead of or in addition to
the plain-text body), and use the standard 
a href='http://example.com/'http://example.com//a
in the HTML body. You'll need to catch the heredoc as a string, and
replace any URLs with the anchored URL as above.
-- 
Ross McKay, Toronto, NSW Australia
Before enlightenment: chop wood, carry water;
 After enlightenment: chop wood, carry water - Wu Li

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



[PHP] Re: Kill Magic Quotes

2008-08-07 Thread Ross McKay
Dave M G wrote:
I am developing a web site that is hosted on a web server where I do not 
have permission to change the php.ini file.

This server has magic quotes turned on. I'd like them off.

I wrote two functions to detect when magic quotes is on, and to try and 
counter act its effects. But it does not seem to be working. It seems to 
have no effect, and I get slashes showing up in all sorts of output 
where I don't want them. Not only in data put into the database, but 
also emails sent to from the site contact page and other places.

Perhaps you also need to disable magic_quotes_runtime:

  set_magic_quotes_runtime(0);  // just call it once per page

Are you sure you actually call your removeSlashes() function?

Why do you think you need your restoreSlashes() function? (NB: not
sufficient for MySQL statements, and not applicable for some other
databases)

Roger Bigras wrote:
you may try the

ini_set('magic_quotes_gpc',0);

That won't work:

http://au.php.net/manual/en/function.get-magic-quotes-gpc.php

Keep in mind that the setting magic_quotes_gpc will not work at
runtime.
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



Re: [PHP] Re: An appeal to your better nature

2008-08-06 Thread Ross McKay
Chris Haensel wrote:

I never thought someone seriously would go the whole way from dev, test and
prod servers [...]

Really? You've never:

* developed locally on your own server
* uploaded to a published site, not the client's live site, for preview
* uploaded the approved changes to the client's live site

thus development, test and production?

Never worked on a project with multiple developers, a few development
environments, integration testing, system testing, user acceptance
testing, and releases to the live system?

AND use all the version control stuff.

Just one is sufficient :) and it certainly saves time in the long run.
It can be especially useful when clients make their own modifications,
and need you to come in and restore just the bits they broke; version
control and a good diff-and-merge tool (e.g. Subversion and Meld) can
save hours of sorting that out.

Honestly: I use dev servers and two backup servers for our company website,
but having  a version control system and everything would, in my opinion,
really make this whole being a developer some kind of ... ugh. Might be good
to do, I don't know. Never tried, and probably never will. And being a good
IT professional to me means: know what you're doing, and take the hits you
get. Lost your data? Well, there is a hit to take. 

That's your prerogative, and presumably your company's too, but maybe
Richard would like to know what some of his options are.

But pointing fingers has never helped anybody.

Who was pointing fingers? I pointed out that hacking the live site with
no version control and no backups wasn't being a good IT professional,
and then I suggested where to find some of the missing files (Google
cache). I also pointed out that I had changes outstanding and not backed
up too, i.e. I'm hardly claiming to be the good IT professional either.

Maybe if Richard picks up some proven software development procedures
like those simple ones mentioned, he won't be bitten like this again.
Maybe you won't be bitten likewise, unless you'd prefer to take umbrage
at offers of advice you don't like.

Or perhaps you think that good IT professionals do hack their production
environments without backups as a matter of course? And on low-service
hosting environments. :)
-- 
Ross McKay, Toronto, NSW Australia
Words can only hurt if you try to read them. Don't play their game - Zoolander

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



[PHP] Re: Version Control Software

2008-08-06 Thread Ross McKay
On Wed, 6 Aug 2008 16:42:23 -0400, Benjamin Darwin wrote:

[...]
I'm wondering if anybody knows of a version control software program that
may fit my needs.

Basically, I'm looking for something that runs locally, not on the live
site, that I can edit the files on the dev computer, and store old versions
on the dev computer, and then just publish off of the local onto the live
site whenever I need to. [...]

A couple of very easy-to-use ones are Subversion and CVS. Both are very
easy to use from a shell / command line, and both have nice GUIs
available for both Windows and *nix. Many editors and IDEs will work
with CVS directly, and some with Subversion.

I chose Subversion because I was trying to move SWMBO off Windows onto
Linux, and the GUIs for Subversion were similar enough and simple enough
on both (TortoiseSVN on Windows, RapidSVN on Linux). Subversion has some
nice options for setting up network servers if you need to go down that
path too (although you probably would get by nicely using local file
storage).

Under Windows, TortoiseSVN comes with a pretty good diff / merge tool
built-in. Under Linux, you'll want to grab Meld. 

If you're doing website development by yourself with no self-built
common code libraries (or frameworks!) then you probably won't even need
to worry about stuff like branching. If you have set up some common code
libraries, then it's a good idea to look at branching so that you can
support older sites on older versions of the libraries whilst further
developing them for newer sites.

http://subversion.tigris.org/
http://tortoisesvn.tigris.org/
http://rapidsvn.tigris.org/
http://meld.sourceforge.net/

Of course, a good IT professional would probably tell you to use git,
with its 132-odd shell commands... ;)
-- 
Ross McKay, Toronto, NSW Australia
And don't forget ladies and gentlemen
 you have to buy this new thing that you don't have
 and if you have it
 well actually
 the new better version of the thing that you have
 well it just came out - Jackson Jackson

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



[PHP] Re: An appeal to your better nature

2008-08-05 Thread Ross McKay
On Tue, 5 Aug 2008 12:34:53 +0100, Richard Heyes wrote:

Seems my 1and1 server has finally gone kaput taking my website with
it, and in the tradition of all good IT professionals, I have no
backups. :( So this is an appeal to you to ask if you have downloaded
anything from phpguru.org at all, could you please send it to me so I
can try to rebuild my site.

Problems I see with the above:

* good IT professionals use version control AND take backups
* good IT professionals work on dev servers and migrate to test, prod
* good IT professionals don't tend to claim guru status themselves :)

Having said that, I'm about to commit yesterday's changes to Subversion
and run another backup whilst touching wood!

Checking Google's cache should give you an idea of what you had up
there, and the rebuild is always better than the original anyway...
-- 
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



[PHP] Re: question about linux editor

2008-03-25 Thread Ross McKay
On Tue, 25 Mar 2008 11:28:07 +0900, Sudhakar wrote:

i need to connect to the linux server using an editor. can anyone suggest
which would be an ideal linux editor to connect to the server.

Geany - http://geany.uvena.de/

Also look at:

Quanta Plus - http://quanta.kdewebdev.org/
Bluefish - http://bluefish.openoffice.nl/
Zend Studio (not free) - http://www.zend.com/en/products/studio/

apart from the ip address, username and password are there any other details
i would need to connect to the server.

How are you proposing to connect? e.g.

* FTP down the files, edit them, FTP them up again
* mount the remote server via NFS
* mount the remote server locally via SFTP
* run the editor remotely: ssh -Y [EMAIL PROTECTED] 

etc.

A conventional way would be to have a development environment locally,
into which you transfer the files from the Linux server, edit them,
TEST! them, and transfer back the changes (e.g. via FTP).
--
Ross McKay, Toronto, NSW Australia
Let the laddie play wi the knife - he'll learn
- The Wee Book of Calvin

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



  1   2   >