Re: [PHP] Re: hello

2009-01-10 Thread Daniel Brown
On Sat, Jan 10, 2009 at 01:57, Robert Cummings rob...@interjinn.com wrote:

 Grumble, grumble... did I mention freshwater falls from the sky and
 forms vertical piles outside my home?

You have a camera for a reason, Rob.  Snap a few shots and we'll
help pick out the next Interjinn logo.  ;-P

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] Re: hello

2009-01-10 Thread Paul M Foster
On Sat, Jan 10, 2009 at 01:57:09AM -0500, Robert Cummings wrote:

 On Sat, 2009-01-10 at 05:20 +0200, Paul Scott wrote:
  On Fri, 2009-01-09 at 18:15 -0500, Phpster wrote:
   -12C in Toronto
  
 
  Meh! 30C - 35C in Cape Town, South Africa almost every day for the last
  month. It has been a scorcher this year!
 
 Grumble, grumble... did I mention freshwater falls from the sky and
 forms vertical piles outside my home?
 

High of 72 degrees in central Florida. Now, where did I put my swimsuit?
;-}

Paul

-- 
Paul M. Foster

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



Re: [PHP] Re: hello

2009-01-10 Thread Robert Cummings
On Sat, 2009-01-10 at 02:59 -0500, Daniel Brown wrote:
 On Sat, Jan 10, 2009 at 01:57, Robert Cummings rob...@interjinn.com wrote:
 
  Grumble, grumble... did I mention freshwater falls from the sky and
  forms vertical piles outside my home?
 
 You have a camera for a reason, Rob.  Snap a few shots and we'll
 help pick out the next Interjinn logo.  ;-P

How do YOU know I have a camera... is that why I feel like I'm being
watched?

;)

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


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



Re: [PHP] Re: hello

2009-01-10 Thread Robert Cummings
On Sat, 2009-01-10 at 03:10 -0500, Paul M Foster wrote:
 On Sat, Jan 10, 2009 at 01:57:09AM -0500, Robert Cummings wrote:
 
  On Sat, 2009-01-10 at 05:20 +0200, Paul Scott wrote:
   On Fri, 2009-01-09 at 18:15 -0500, Phpster wrote:
-12C in Toronto
   
  
   Meh! 30C - 35C in Cape Town, South Africa almost every day for the last
   month. It has been a scorcher this year!
  
  Grumble, grumble... did I mention freshwater falls from the sky and
  forms vertical piles outside my home?
  
 
 High of 72 degrees in central Florida. Now, where did I put my swimsuit?
 ;-}

*throws snowball at you*

:)


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


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



[PHP] com_event_sink question

2009-01-10 Thread Jason Paschal
Hello all,

Can i just create a function for the particular event i want to respond to?
Or do all possible events have to be dealt with in your class?

If I just make the function for the one event I want to respond to, will the
COM's other events stay intact?

Thank you,
Jason


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

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

M is for Murray


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

 Hi Richard,

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

 Many thanks in advance,

 M is for Murray


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

  ...

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

 --
 Richard Heyes

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





Re: [PHP] Apache File Quesiton

2009-01-10 Thread Gary
Ok, not yet...

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

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

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

Some other BG info

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

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


Murray planetthought...@gmail.com wrote in message 
news:6481f4d0901092018g31d9a08fkd0321e1532c85...@mail.gmail.com...
 In general, as Phpster points out, your development will take place in
 directories underneath your htdocs directory, which, if you installed 
 XAMPP
 into the root directory on C:, would be something like
 C:\xampp\htdocs\yourdevdirectory.

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

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

 M is for Murray


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

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

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

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

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

 Thanks

 Gary



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


 



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



Re: [PHP] Been staring at the code for too long...

2009-01-10 Thread tedd

At 1:38 PM -0500 1/9/09, Jason Pruim wrote:


mysqli_stmt_prepare($stmt, UPDATE database.table (


Jason:

Here's the problem, your code should read:

mysqli_stmt_prepare($stmt, UPDATE database.table SET (

You forgot the SET.

As a point of practice, I always use:

$query = UPDATE $db_table SET first = '$first', second = '$second' 
WHERE id = '$id' ;


and then use the $query, such as:

mysqli_stmt_prepare($stmt, $query);

I know every one has their own way, but also consider the following code:

--- code ---

$result = mysql_query($query) or die(report($query,__LINE__ ,__FILE__));

// with an accompanying function of:

//  show dB errors  ==

function report($query, $line, $file)
   {
   echo($query . 'br' .$line . 'br/' . $file . 'br/' . mysql_error());
   }

--- end of code ---

This will:

1. Allow you to see your errors in more detail during development;

2. After the development, you have only to comment out one line of 
code (the echo) to stop reporting dB errors project-wide.


It works for me.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Couple of beginner questions

2009-01-10 Thread tedd

At 12:18 PM -0500 1/9/09, Gary wrote:

I've done a number of sites in html and am now venturing into php.

Can I create a page in html and insert php code that will work? (for
example, take an existing page and insert a date command)

Can I create a page with the php extension that contains only contains html
and no php?  If so are there advantages/disadvantages?

Can I mix and match file formats (php/html) in a single site?

Thanks for any input.

Gary



Gary:

Welcome to the wonderful world of php.

As for your date question, try this:

http://sperling.com/examples/time/

As for mixing html and php, the following was the most important 
thing I learned about doing what you're trying to do:


http://sperling.com/examples/include-demo/

I think the demo is well worth your time to go through.

Hope this helps.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Couple of beginner questions

2009-01-10 Thread Gary
Looks like a great link, thank you.

But am I to understand that all I need to do is change the extention on a 
file to php from html for all to be right with the world?

Gary
tedd tedd.sperl...@gmail.com wrote in message 
news:p06240803c58e55325...@[192.168.1.101]...
 At 12:18 PM -0500 1/9/09, Gary wrote:
I've done a number of sites in html and am now venturing into php.

Can I create a page in html and insert php code that will work? (for
example, take an existing page and insert a date command)

Can I create a page with the php extension that contains only contains 
html
and no php?  If so are there advantages/disadvantages?

Can I mix and match file formats (php/html) in a single site?

Thanks for any input.

Gary


 Gary:

 Welcome to the wonderful world of php.

 As for your date question, try this:

 http://sperling.com/examples/time/

 As for mixing html and php, the following was the most important thing I 
 learned about doing what you're trying to do:

 http://sperling.com/examples/include-demo/

 I think the demo is well worth your time to go through.

 Hope this helps.

 Cheers,

 tedd

 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com 



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



[PHP] Re: Couple of beginner questions

2009-01-10 Thread tedd

At 5:39 PM + 1/9/09, Nathan Rixham wrote:
if it has the file extension .php then it will be passed through php 
and compiled; otherwise the php source code you insert will just 
show up in the html source.


Gary:

That is true, but with the following code in a .htaccess file you can 
force the interpreter to consider other files with other suffixes. 
For example:


# handler for phpsuexec..
FilesMatch \.(htm|html|css|tpl)$
 SetHandler application/x-httpd-php
/FilesMatch

This allows me to use php in css files and such.

Cheers,

tedd


PS: Nathan  -- I know you know this, but this post was for the 
benefit of the OP.

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Apache File Quesiton

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

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

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

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

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

M is for Murray


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

 Ok, not yet...

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

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

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

 Some other BG info

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

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


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



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




Re: [PHP] Couple of beginner questions

2009-01-10 Thread tedd

At 11:35 AM -0800 1/9/09, VamVan wrote:

-- Remember as you re still a beginner try to avoid using ? at the end of
complete PHP code page. or else if you have empty lines at the end of the
file then you wont see blank page of death in PHP.


I'm not a beginner, but this is a practice that many other 
programmers advise, but I never follow. In my defense, I have never 
had the problem surface.


For me, I like closure and symmetry. If I *had* to not close a php 
segment, then I would find another way to do it so that I could.


But then again, I also never use else if statements either for the 
lack of symmetry they show to me (YMMV).


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Apache File Quesiton

2009-01-10 Thread Nathan Rixham

Gary wrote:

Ok, not yet...

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


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

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


Some other BG info

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

URL Prefix http://localhost/barrister/ (currently)

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




think of it as having a local and a remote server on one machine;

first you have your source files in your /My Documents/sites/

then you have a directory where your web server (the apache part of 
xampp) looks for files to server (currently C:/xampp/apache/htdocs)


now becuase everything is on the one machine you can take 3 different 
approaches


Approach 1:
Keep your site files in there current place (my documents)
change testing server folder to a folder your web server can see (like 
c:/xampp/apache/htdocs/barrister
now when you test your files will be copied to htdocs/barrister and made 
available to see by http://localhost/barrister


Approach 2:
Change the site root in httpd.conf to match your source folder (so 
change it to C:\Documents and Settings\myname\My Documents\sites) and 
change the Directory block in httpd.conf to match
now you can forget the testing server bit in dreamweaver and simply load 
up a browser to http://localhost and all you're sites will be displayed 
there (http://localhost/barrister for the one in question)


Approach 3:
Use vhosts, but I won't mention until later on, best to get up and 
running the simple way first :)


ps: if you want to do a quick test, simply copy your barrister folder 
from my documents/sites in to your htdocs folder and open up 
http://localhost/barrister


regards

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



Re: [PHP] Re: Couple of beginner questions

2009-01-10 Thread tedd

At 2:04 PM + 1/10/09, Nathan Rixham wrote:

tedd wrote:

At 5:39 PM + 1/9/09, Nathan Rixham wrote:
if it has the file extension .php then it will be passed through 
php and compiled; otherwise the php source code you insert will 
just show up in the html source.


Gary:

That is true, but with the following code in a .htaccess file you 
can force the interpreter to consider other files with other 
suffixes. For example:


# handler for phpsuexec..
FilesMatch \.(htm|html|css|tpl)$
 SetHandler application/x-httpd-php
/FilesMatch

This allows me to use php in css files and such.

Cheers,

tedd


PS: Nathan  -- I know you know this, but this post was for the 
benefit of the OP.


lol and I knew *somebody* would say that :p
np; you may get some comments about being able to configure you're 
server so that php parses files with different extensions (such as 
.html); but this would require some customisation of the web server 
config files and probably best avoided for now.


Gary:

I agree with Nathan here.

If you have problems with using the php suffix or don't want to 
change from html, then what I presented is an option, but it's 
debatable as being good practice.


I think that using php suffixes tells you (as the developer) that 
some portion of the file has php code in it somewhere and that's 
usually good to know, thus good practice.


As you learn and grow you'll see the differences between and 
advantages for the separation of data, presentation, behavior, and 
function -- the four horseman of web development (much more than a 
single language). I could write a whole treaties on these differences 
and how different languages treat these different constructs. As they 
say in Perl There's always more than one way to do something.


In any event, it's probably good to use the php suffix if that 
doesn't brother you much. But it's also good to know that you have 
the option.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Couple of beginner questions

2009-01-10 Thread tedd

At 8:48 AM -0500 1/10/09, Gary wrote:

Looks like a great link, thank you.

But am I to understand that all I need to do is change the extention on a
file to php from html for all to be right with the world?


Yup.

By changing the suffix (extension), you are telling the server that 
this file is to be treated differently than a html file. As such, the 
php interpreter will process the file before it is sent to the 
browser.


A statement like:

?php echo('Hello'); ?

Will print Hello to the browser. In fact, the browser will never 
see your php code unless you make a mistake. The file will be 
processed and delivered to the browser as html.


Please note that my use of echo above does not require the (), that's 
a habit I practice for no good reason whatsoever other than I like 
it. I think it's because I'm dyslectic and it makes sense to me.


In any event, I would consider the followingbad practice:

?php echo('h1Hello/h1'); ?

Whereas, the following I would consider good practice.

h1?php echo('Hello'); ?/h1

As best as you can, try to keep php and html separate.

I know that some have different ideas on good/bad practices, but 
you'll develop your own views/habits as you grow and learn.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Apache File Quesiton

2009-01-10 Thread Gary
Ok, I believe I have it workingmeaning when I click on Live Data View, I 
see the date appear in my datetest.php page

But Im still confused...

The succesful configuration (providing I am not suffering from premature 
exhuberation) is

Testing server folder: c:\xampp\htdocs\barrister (the local settings 
remained My Documents\Sites\barrister)
URL prefix : http://localhost/barrister/

How does that reconcile that in the httpd.conf, the server root is 
C:/xampp/apache?

Gary

Nathan Rixham nrix...@gmail.com wrote in message 
news:4968af26.4050...@gmail.com...
 Gary wrote:
 Ok, not yet...

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

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

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

 Some other BG info

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

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



 think of it as having a local and a remote server on one machine;

 first you have your source files in your /My Documents/sites/

 then you have a directory where your web server (the apache part of xampp) 
 looks for files to server (currently C:/xampp/apache/htdocs)

 now becuase everything is on the one machine you can take 3 different 
 approaches

 Approach 1:
 Keep your site files in there current place (my documents)
 change testing server folder to a folder your web server can see (like 
 c:/xampp/apache/htdocs/barrister
 now when you test your files will be copied to htdocs/barrister and made 
 available to see by http://localhost/barrister

 Approach 2:
 Change the site root in httpd.conf to match your source folder (so change 
 it to C:\Documents and Settings\myname\My Documents\sites) and change the 
 Directory block in httpd.conf to match
 now you can forget the testing server bit in dreamweaver and simply load 
 up a browser to http://localhost and all you're sites will be displayed 
 there (http://localhost/barrister for the one in question)

 Approach 3:
 Use vhosts, but I won't mention until later on, best to get up and running 
 the simple way first :)

 ps: if you want to do a quick test, simply copy your barrister folder from 
 my documents/sites in to your htdocs folder and open up 
 http://localhost/barrister

 regards 



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



Re: [PHP] Create image from HTML

2009-01-10 Thread tedd

At 11:29 AM -0500 1/9/09, Christoph Boget wrote:

Does anyone know if it's possible, using PHP, to take HTML (either as
an input or from a URL) and generate an image (essentially, create a
screenshot) of that HTML/page?  I've looked around but was unable to
find anything and I'm just not sure if it's that there really is
nothing like this out there or if I'm just looking in the wrong
places.

Any advice/suggestions would be greatly appreciated!

thnx,
Christoph



Christoph:

A screenshot would most definitely be a client-side process. The 
server (thus php) has no way of knowing how the data that was 
presented to your browser is being, or has been, viewed.


Your browser simply asked for data and the server delivered it -- end of story.

Now, if you investigate client-side languages, like javascript, the 
you'll have a better chance of solving your problem.


Hope this helps.

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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

At 7:38 PM + 1/9/09, c...@l-i-e.com wrote:

Rule #1.
Never, ever, ever, alter the user's input, EXCEPT for sanitizing/filtering.
Specifically, do NOT add br / tags in place of newlines.
Store the newlines.

Upon OUTPUT, you can use nl2br() to get br / tags.
Or str_replace if you want /p instead.

This is crucial as a habit, down the road, when you later want to 
put their stuff out as non-HTML such as RSS or PDF or other output 
mechanisms.


Consider their input as sacrosanct (except for dangerous/evil input).


I second this strong recommendation.

Never store any html whatsoever in a database.

HTML is presentation and is NOT data.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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

At 11:43 AM -0800 1/9/09, VamVan wrote:

Rule #1.
Never, ever, ever, alter the user's input, EXCEPT for sanitizing/filtering.
Specifically, do NOT add br / tags in place of newlines.
Store the newlines.


100% I agree. Thats called the act of defensive programming. We have no
right over altering user input but yes we have right to display what we want
user see on the site.


Thanks,
V


While one can look at it as defensive programming, it has a larger 
scope than that.


Certainly you want to sanitize all input from users to prohibit 
injections, but more than that you want to keep data separate from 
presentation.


I always cringe when I see clients entering html into their CMS 
because they want to make some line of text bold, but then forget to 
close the tag and find that the entire dynamic page is now broken as 
the malformed html content is pulled from a database.


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Apache File Quesiton

2009-01-10 Thread Nathan Rixham

Gary wrote:
Ok, I believe I have it workingmeaning when I click on Live Data View, I 
see the date appear in my datetest.php page


But Im still confused...

The succesful configuration (providing I am not suffering from premature 
exhuberation) is


Testing server folder: c:\xampp\htdocs\barrister (the local settings 
remained My Documents\Sites\barrister)

URL prefix : http://localhost/barrister/

How does that reconcile that in the httpd.conf, the server root is 
C:/xampp/apache?




That's server root; what you want is DocumentRoot :)

here's a bit of an httpd.conf; these are the two bits of concern to you:

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot C:/xampp/apache/htdocs

---AND---

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
Directory G:/Apache/httpd/htdocs
#
# Possible values for the Options directive are None, All,
# or any combination of:
#Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that MultiViews must be named *explicitly* --- Options All
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#
#AllowOverride controls what directives may be placed in .htaccess files
# It can be All, None, or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
AllowOverride All

#
# Controls who can get stuff from this server.
#.
Order allow,deny
Allow from all
/Directory

---

if you read the comments aswell all should be explained :)

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



Re: [PHP] Apache File Quesiton

2009-01-10 Thread Gary
Ok...now that makes sense, I was looking for the documentroot, not the 
server root...

Thanks to everyone ... Im sure I will be back for more...

Gary



Nathan Rixham nrix...@gmail.com wrote in message 
news:4968ba7d.5000...@gmail.com...
 Gary wrote:
 Ok, I believe I have it workingmeaning when I click on Live Data 
 View, I see the date appear in my datetest.php page

 But Im still confused...

 The succesful configuration (providing I am not suffering from premature 
 exhuberation) is

 Testing server folder: c:\xampp\htdocs\barrister (the local settings 
 remained My Documents\Sites\barrister)
 URL prefix : http://localhost/barrister/

 How does that reconcile that in the httpd.conf, the server root is 
 C:/xampp/apache?


 That's server root; what you want is DocumentRoot :)

 here's a bit of an httpd.conf; these are the two bits of concern to you:

 #
 # DocumentRoot: The directory out of which you will serve your
 # documents. By default, all requests are taken from this directory, but
 # symbolic links and aliases may be used to point to other locations.
 #
 DocumentRoot C:/xampp/apache/htdocs

 ---AND---

 #
 # Note that from this point forward you must specifically allow
 # particular features to be enabled - so if something's not working as
 # you might expect, make sure that you have specifically enabled it
 # below.
 #

 #
 # This should be changed to whatever you set DocumentRoot to.
 #
 Directory G:/Apache/httpd/htdocs
 #
 # Possible values for the Options directive are None, All,
 # or any combination of:
 #Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
 #
 # Note that MultiViews must be named *explicitly* --- Options All
 # doesn't give it to you.
 #
 # The Options directive is both complicated and important.  Please see
 # http://httpd.apache.org/docs/2.2/mod/core.html#options
 # for more information.
 #
 Options Indexes FollowSymLinks

 #
 #AllowOverride controls what directives may be placed in .htaccess files
 # It can be All, None, or any combination of the keywords:
 #   Options FileInfo AuthConfig Limit
 #
 AllowOverride All

 #
 # Controls who can get stuff from this server.
 #.
 Order allow,deny
 Allow from all
 /Directory

 ---

 if you read the comments aswell all should be explained :) 



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



Re: [PHP] imagejpeg, imagecreatefromjpeg both choke

2009-01-10 Thread tedd

At 7:23 AM -0800 1/9/09, Brian Dunning wrote:
I'm trying a stripped down test just to try to get this work. I have 
a valid jpeg on disk:


-snip-

Try this:

http://webbytedd.com/b/thumb/index.php

All the code is there -- and it works.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
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] Re: Create image from HTML

2009-01-10 Thread Per Jessen
Daniel Brown wrote:

 You can use xvfb (X Virtual Frame Buffer) on *NIX systems without
 running X itself, a stripped down Mozilla navigate to and display the
 page, and then snap a screen shot of the buffer.  Not very
 economical, but it would work. 

I did just that a while ago, it worked pretty well AFAIR.  


/Per Jessen, Zürich


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

tedd wrote:

At 11:43 AM -0800 1/9/09, VamVan wrote:

Rule #1.
Never, ever, ever, alter the user's input, EXCEPT for 
sanitizing/filtering.

Specifically, do NOT add br / tags in place of newlines.
Store the newlines.


100% I agree. Thats called the act of defensive programming. We have no
right over altering user input but yes we have right to display what 
we want

user see on the site.


Thanks,
V


While one can look at it as defensive programming, it has a larger scope 
than that.


Certainly you want to sanitize all input from users to prohibit 
injections, but more than that you want to keep data separate from 
presentation.




exactly: you want to keep data separate from presentation.
only scope for this is that sometimes you want to store html / 
presentation data (seeing as it is data)


my personal preference is to always store a plain text version as well 
as a sanitized html version.


creating the plain text is simple; strip_tags then a simple preg_replace 
to remove extra horizontal whitespace, and another to make sure you're 
newlines are all in the correct place


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



Re: [PHP] Been staring at the code for too long...

2009-01-10 Thread Jason Pruim


On Jan 10, 2009, at 8:35 AM, tedd wrote:


At 1:38 PM -0500 1/9/09, Jason Pruim wrote:


   mysqli_stmt_prepare($stmt, UPDATE database.table (


Jason:

Here's the problem, your code should read:

mysqli_stmt_prepare($stmt, UPDATE database.table SET (

You forgot the SET.

As a point of practice, I always use:

$query = UPDATE $db_table SET first = '$first', second = '$second'  
WHERE id = '$id' ;


and then use the $query, such as:

mysqli_stmt_prepare($stmt, $query);


Hey tedd,

I hadn't done a update in a prepared statement before... and it was  
something I set up quite awhile ago... I ended up rewriting it just to  
refresh my mind on how it was working :)






I know every one has their own way, but also consider the following  
code:


--- code ---

$result = mysql_query($query) or  
die(report($query,__LINE__ ,__FILE__));


// with an accompanying function of:

//  show dB errors  ==

function report($query, $line, $file)
  {
  echo($query . 'br' .$line . 'br/' . $file . 'br/' .  
mysql_error());

  }

--- end of code ---

This will:

1. Allow you to see your errors in more detail during development;

2. After the development, you have only to comment out one line of  
code (the echo) to stop reporting dB errors project-wide.


I really need to start doing that... Then I can track down the issues  
easier hopefully... :)




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

At 11:58 AM -0500 1/9/09, Daniel Brown wrote:

// Convert HTML linebreak tags to paragraph tags.


Daniel:

-snip code-

Nice function.

Thanks,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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

At 3:19 PM + 1/10/09, Nathan Rixham wrote:

tedd wrote:
While one can look at it as defensive programming, it has a larger 
scope than that.


Certainly you want to sanitize all input from users to prohibit 
injections, but more than that you want to keep data separate from 
presentation.




exactly: you want to keep data separate from presentation.
only scope for this is that sometimes you want to store html / 
presentation data (seeing as it is data)


I understand that one might want to consider storing presentation 
elements as data in a database, but the alternative would be to 
simply keep html as html and control the styling via css.


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.


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.


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.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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

At 2:19 AM +1100 1/11/09, Ross McKay wrote:

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


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.


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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

tedd wrote:

At 2:19 AM +1100 1/11/09, Ross McKay wrote:

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


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.


Cheers,

tedd




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)


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



[PHP] Problem with sybase_get_last_message

2009-01-10 Thread Steve
I'm running into PHP Bug #11262:

It would be wonderful if PHP could discard error #3621 (Command has
been aborted.) This message is a pain, because when something goes
wrong, sybase gives the real error, and then also gives this second
useless message. This means that if a query fails,
sybase_get_last_message will return Command has been aborted
rather than the real error message.
--

  This bug is from 2001 and still occurs in PHP 4.4.9.  Does anyone
know how to get the real message out of sybase?
Thanks,
  Steve



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



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

2009-01-10 Thread Richard Heyes
 Where would I find that article, if you think it might help me get MDB2
 working properly?

It won't help you get MDB2 working - it's a general thing I wrote on
structuring your applications and websites. I have used for quite a
while though, and it's served me well.

-- 
Richard Heyes

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

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



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

2009-01-10 Thread Richard Heyes
 Where would I find that article, if you think it might help me get MDB2
 working properly?

 It won't help you get MDB2 working - it's a general thing I wrote on
 structuring your applications and websites. I have used for quite a
 while though, and it's served me well.

Sorry, forgot the URL:

http://www.phpguru.org/static/ApplicationStructure.html

-- 
Richard Heyes

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

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



[PHP] pecl4win - any updates?

2009-01-10 Thread pan
Has there been any progress reinstating pecl packages for
windows?



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



[PHP] is_readable() returns 1 if file is still uploading

2009-01-10 Thread Merlin Morgenstern

Hi there,

I am importing data out of xml files on a linux server. Now I am running 
into problems if the file is currently beeing uploaded and the upload 
has not finished to the server.
Is there a function which returns true if the file is complete and not 
in upload status? I tried is_readable(), but this only returns false if 
the file is missing.


This is the error msg from php:
parser error : Premature end of data

thank you for any help.

regards, merlin

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



Re: [PHP] is_readable() returns 1 if file is still uploading

2009-01-10 Thread Robert Cummings
On Sat, 2009-01-10 at 19:22 +0100, Merlin Morgenstern wrote:
 Hi there,
 
 I am importing data out of xml files on a linux server. Now I am running 
 into problems if the file is currently beeing uploaded and the upload 
 has not finished to the server.
 Is there a function which returns true if the file is complete and not 
 in upload status? I tried is_readable(), but this only returns false if 
 the file is missing.
 
 This is the error msg from php:
 parser error : Premature end of data
 
 thank you for any help.

You could skip any file that's been updated within the last 10 seconds.
See the filemtime() function.

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


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



Re: [PHP] is_readable() returns 1 if file is still uploading

2009-01-10 Thread Jim Lucas

Merlin Morgenstern wrote:

Hi there,

I am importing data out of xml files on a linux server. Now I am running 
into problems if the file is currently beeing uploaded and the upload 
has not finished to the server.
Is there a function which returns true if the file is complete and not 
in upload status? I tried is_readable(), but this only returns false if 
the file is missing.


It will also return false if your user doesn't have permission to read the file.



This is the error msg from php:
parser error : Premature end of data

thank you for any help.

regards, merlin




--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] Re: hello

2009-01-10 Thread Paul M Foster
On Sat, Jan 10, 2009 at 03:16:34AM -0500, Robert Cummings wrote:

 On Sat, 2009-01-10 at 03:10 -0500, Paul M Foster wrote:
  On Sat, Jan 10, 2009 at 01:57:09AM -0500, Robert Cummings wrote:
 
   On Sat, 2009-01-10 at 05:20 +0200, Paul Scott wrote:
On Fri, 2009-01-09 at 18:15 -0500, Phpster wrote:
 -12C in Toronto

   
Meh! 30C - 35C in Cape Town, South Africa almost every day for the last
month. It has been a scorcher this year!
  
   Grumble, grumble... did I mention freshwater falls from the sky and
   forms vertical piles outside my home?
  
 
  High of 72 degrees in central Florida. Now, where did I put my swimsuit?
  ;-}
 
 *throws snowball at you*
 

*ducks behind sand castle* ;-}

Paul
-- 
Paul M. Foster

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



Re: [PHP] Re: hello

2009-01-10 Thread Robert Cummings
On Sat, 2009-01-10 at 16:00 -0500, Paul M Foster wrote:
 On Sat, Jan 10, 2009 at 03:16:34AM -0500, Robert Cummings wrote:
 
  On Sat, 2009-01-10 at 03:10 -0500, Paul M Foster wrote:
   On Sat, Jan 10, 2009 at 01:57:09AM -0500, Robert Cummings wrote:
  
On Sat, 2009-01-10 at 05:20 +0200, Paul Scott wrote:
 On Fri, 2009-01-09 at 18:15 -0500, Phpster wrote:
  -12C in Toronto
 

 Meh! 30C - 35C in Cape Town, South Africa almost every day for the 
 last
 month. It has been a scorcher this year!
   
Grumble, grumble... did I mention freshwater falls from the sky and
forms vertical piles outside my home?
   
  
   High of 72 degrees in central Florida. Now, where did I put my swimsuit?
   ;-}
  
  *throws snowball at you*
  
 
 *ducks behind sand castle* ;-}

Snowball hits sandcastle... promptly melts... washes sandcastle away.

*throws another snowball at you*

I've got LOTS more where they came from.

:D

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


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



Re: [PHP] Re: hello

2009-01-10 Thread Daniel Brown
On Sat, Jan 10, 2009 at 16:06, Robert Cummings rob...@interjinn.com wrote:

 Snowball hits sandcastle... promptly melts... washes sandcastle away.

 *throws another snowball at you*

 I've got LOTS more where they came from.


*danbrown casts Spell of Awe and attains Level 63 Wizard.
*danbrown turns you into a frog.


-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] Couple of beginner questions

2009-01-10 Thread Paul M Foster
On Sat, Jan 10, 2009 at 09:46:14AM -0500, tedd wrote:

 At 8:48 AM -0500 1/10/09, Gary wrote:
 Looks like a great link, thank you.

 But am I to understand that all I need to do is change the extention on a
 file to php from html for all to be right with the world?

 Yup.

 By changing the suffix (extension), you are telling the server that
 this file is to be treated differently than a html file. As such, the
 php interpreter will process the file before it is sent to the
 browser.

 A statement like:

 ?php echo('Hello'); ?

 Will print Hello to the browser. In fact, the browser will never
 see your php code unless you make a mistake. The file will be
 processed and delivered to the browser as html.

 Please note that my use of echo above does not require the (), that's
 a habit I practice for no good reason whatsoever other than I like
 it. I think it's because I'm dyslectic and it makes sense to me.

 In any event, I would consider the followingbad practice:

 ?php echo('h1Hello/h1'); ?

 Whereas, the following I would consider good practice.

 h1?php echo('Hello'); ?/h1

 As best as you can, try to keep php and html separate.

 I know that some have different ideas on good/bad practices, but
 you'll develop your own views/habits as you grow and learn.

And let me present an alternative perspective. Never do something like:

?php echo 'Hellow world'; ?

Let Apache (or whatever) interpret HTML as HTML, and don't make it
interpret PHP code as HTML.

Instead, do:

h1Hello world/h1

If you're going to use PHP in the middle of a bunch of HTML, then only
use it where it's needed:

h1Hello ?php echo $name; ?/h1

The contents of the PHP $name variable can't be seen by the HTML, which
is why you need to enclose it in a little PHP island. Naturally, if
you're going to put PHP code in the middle of a HTML page, make the
extension PHP. Otherwise, Apache will not interpret the PHP code as PHP
(unless you do some messing with .htaccess or whatever). It's just
simplest to call a file something.php if it has PHP in it.

Paul
-- 
Paul M. Foster

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



Re: [PHP] Re: hello

2009-01-10 Thread Robert Cummings
On Sat, 2009-01-10 at 16:14 -0500, Daniel Brown wrote:
 On Sat, Jan 10, 2009 at 16:06, Robert Cummings rob...@interjinn.com wrote:
 
  Snowball hits sandcastle... promptly melts... washes sandcastle away.
 
  *throws another snowball at you*
 
  I've got LOTS more where they came from.
 
 
 *danbrown casts Spell of Awe and attains Level 63 Wizard.
 *danbrown turns you into a frog.

*quickly edits the PHP code controlling reality*

Babalicious princess walks up and kisses me reversing the spell.

*throws a snowman at you*

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


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



Re: [PHP] Re: hello

2009-01-10 Thread Nathan Rixham

Robert Cummings wrote:

On Sat, 2009-01-10 at 16:14 -0500, Daniel Brown wrote:

On Sat, Jan 10, 2009 at 16:06, Robert Cummings rob...@interjinn.com wrote:

Snowball hits sandcastle... promptly melts... washes sandcastle away.

*throws another snowball at you*

I've got LOTS more where they came from.


*danbrown casts Spell of Awe and attains Level 63 Wizard.
*danbrown turns you into a frog.


*quickly edits the PHP code controlling reality*

Babalicious princess walks up and kisses me reversing the spell.

*throws a snowman at you*

Cheers,
Rob.


are you three flirting?

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



Re: [PHP] Re: hello

2009-01-10 Thread Daniel Brown
On Sat, Jan 10, 2009 at 16:21, Nathan Rixham nrix...@gmail.com wrote:

 are you three flirting?

Are you jealous?

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] Re: hello

2009-01-10 Thread Robert Cummings
On Sat, 2009-01-10 at 21:21 +, Nathan Rixham wrote:
 Robert Cummings wrote:
  On Sat, 2009-01-10 at 16:14 -0500, Daniel Brown wrote:
  On Sat, Jan 10, 2009 at 16:06, Robert Cummings rob...@interjinn.com 
  wrote:
  Snowball hits sandcastle... promptly melts... washes sandcastle away.
 
  *throws another snowball at you*
 
  I've got LOTS more where they came from.
 
  *danbrown casts Spell of Awe and attains Level 63 Wizard.
  *danbrown turns you into a frog.
  
  *quickly edits the PHP code controlling reality*
  
  Babalicious princess walks up and kisses me reversing the spell.
  
  *throws a snowman at you*
  
  Cheers,
  Rob.
 
 are you three flirting?

Feeling left out?


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


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



Re: [PHP] Re: hello

2009-01-10 Thread Nathan Rixham

Daniel Brown wrote:

On Sat, Jan 10, 2009 at 16:21, Nathan Rixham nrix...@gmail.com wrote:

are you three flirting?


Are you jealous?



*throws snowball too* shut p

when in rome..

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

c...@l-i-e.com wrote:

Rule #1.
Never, ever, ever, alter the user's input, EXCEPT for sanitizing/filtering.
Specifically, do NOT add br / tags in place of newlines.
Store the newlines.

Upon OUTPUT, you can use nl2br() to get br / tags.
Or str_replace if you want /p instead.

This is crucial as a habit, down the road, when you later want to put their 
stuff out as non-HTML such as RSS or PDF or other output mechanisms.

Consider their input as sacrosanct (except for dangerous/evil input)
  
How do you suggest dealing with a need to allow italics, bold, 
underlines, etc?


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?

Stephen

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



Re: [PHP] Re: hello

2009-01-10 Thread Björn Bartels

*rofl*

damn... i love this list... so much for on- ehmmm off-list posts :p ...

Am 10.01.2009 um 22:24 schrieb Nathan Rixham:


Daniel Brown wrote:
On Sat, Jan 10, 2009 at 16:21, Nathan Rixham nrix...@gmail.com  
wrote:

are you three flirting?

   Are you jealous?


*throws snowball too* shut p



yeah... wonderful (genesis) concert ;)


when in rome..


YT
BB

[Björn Bartels   ]

[email :  bart...@dragon-projects.de ]
[home  :   http://dragon-projects.de ]
[skype :  bb-drummer ]
[icq   :   283827160 ]

[--- ]

Diese E-Mail könnte vertrauliche und/oder rechtlich geschützte  
Informationen enthalten. Wenn Sie nicht der richtige Adressat sind  
oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte  
sofort den Absender und vernichten Sie diese Mail. Das unerlaubte  
Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht  
gestattet.


This e-mail may contain confidential and/or privileged information. If  
you are not the intended recipient (or have received this e-mail in  
error) please notify the sender immediately and destroy this e-mail.  
Any unauthorised copying, disclosure or distribution of the material  
in this e-mail is strictly forbidden.


[--- ]










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



[PHP] Unique Object Instance ID..?

2009-01-10 Thread Nathan Rixham

Evening All,

Not too often I ask a question here, but here goes;

I'm making an Object class which all of my other classes extend, and I 
need each instance to have it's own unique id, seemed simple but it's 
harder than I thought (the difficulty is when it comes to deciding the 
syntax).


so far each object has an OBJECT_ID which is a simple static incremented 
integer representing the instance of the object, here's a simplified 
example:


abstract class Object {

  private static $INSTANCES = 0;
  private $OBJECT_ID = 0;

  public function __construct()
  {
$this-OBJECT_ID = ++self::$INSTANCES;
  }

}

Now back to the problem, I also need the object to have
private $UNIQUE_ID;

this unique_id needs to have:
timestamp
classname
object_id

combining the three makes a unique id; but it's only unique to that 
session, no good for a real world application as there could be 50 
sessions all running at the same time on the server; and odds are rather 
high that two instances of the object could have the same id. Thus an 
extra completely unique identified needs added to the three values above.


I'd thought a simple random integer would possibly be enough (combined 
with the timestamp), but there could still be collission.


so the best I've got so far is:
 [OBJECT_ID:private] = 3
 [UNIQUE_ID:private] = instance://1231629...@testobject.3:97739
timestamp @ class . instance : randomInteger

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)


thoughts, ideas, recommendations?

regards!

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

'Twas brillig, and Nathan Rixham at 10/01/09 23:31 did gyre and gimble:
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)


thoughts, ideas, recommendations?


While it's not guaranteed to be unique the general technique used in 
these situations is to use a UUID. The chances of a clash are slim 
(2x10^38 ish combinations).


You can generate a uuid via mysql SELECT UUID() or via the PHP Pecl 
extension php-uuid.


The other way of doing it would be to insert a row into a database row 
with an auto-increment field and use the value of that auto-incrment 
field as your identifier (SELECT LAST_INSERT_ID() in mysql or via the db 
layers API).


HTHs

Col


--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


--
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 Eric Butera
On Sat, Jan 10, 2009 at 6:31 PM, Nathan Rixham nrix...@gmail.com wrote:
 Evening All,

 Not too often I ask a question here, but here goes;

 I'm making an Object class which all of my other classes extend, and I
 need each instance to have it's own unique id, seemed simple but it's harder
 than I thought (the difficulty is when it comes to deciding the syntax).

 so far each object has an OBJECT_ID which is a simple static incremented
 integer representing the instance of the object, here's a simplified
 example:

 abstract class Object {

  private static $INSTANCES = 0;
  private $OBJECT_ID = 0;

  public function __construct()
  {
$this-OBJECT_ID = ++self::$INSTANCES;
  }

 }

 Now back to the problem, I also need the object to have
 private $UNIQUE_ID;

 this unique_id needs to have:
 timestamp
 classname
 object_id

 combining the three makes a unique id; but it's only unique to that session,
 no good for a real world application as there could be 50 sessions all
 running at the same time on the server; and odds are rather high that two
 instances of the object could have the same id. Thus an extra completely
 unique identified needs added to the three values above.

 I'd thought a simple random integer would possibly be enough (combined with
 the timestamp), but there could still be collission.

 so the best I've got so far is:
  [OBJECT_ID:private] = 3
  [UNIQUE_ID:private] = instance://1231629...@testobject.3:97739
 timestamp @ class . instance : randomInteger

 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)

 thoughts, ideas, recommendations?

 regards!

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



I was going to say uuid, but maybe SplObjectStorage might be of some help.

-- 
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 Phpster
That can and should be done with a simple str_replace() on the display  
portion of the code.


Bastien

Sent from my iPod

On Jan 10, 2009, at 5:01 PM, Stephen stephe...@rogers.com wrote:


c...@l-i-e.com wrote:

Rule #1.
Never, ever, ever, alter the user's input, EXCEPT for sanitizing/ 
filtering.

Specifically, do NOT add br / tags in place of newlines.
Store the newlines.

Upon OUTPUT, you can use nl2br() to get br / tags.
Or str_replace if you want /p instead.

This is crucial as a habit, down the road, when you later want to  
put their stuff out as non-HTML such as RSS or PDF or other output  
mechanisms.


Consider their input as sacrosanct (except for dangerous/evil input)

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


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?

Stephen

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



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



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

2009-01-10 Thread Phpster

Unique()?

Bastien

Sent from my iPod

On Jan 10, 2009, at 6:31 PM, Nathan Rixham nrix...@gmail.com wrote:


Evening All,

Not too often I ask a question here, but here goes;

I'm making an Object class which all of my other classes extend,  
and I need each instance to have it's own unique id, seemed simple  
but it's harder than I thought (the difficulty is when it comes to  
deciding the syntax).


so far each object has an OBJECT_ID which is a simple static  
incremented integer representing the instance of the object, here's  
a simplified example:


abstract class Object {

 private static $INSTANCES = 0;
 private $OBJECT_ID = 0;

 public function __construct()
 {
   $this-OBJECT_ID = ++self::$INSTANCES;
 }

}

Now back to the problem, I also need the object to have
private $UNIQUE_ID;

this unique_id needs to have:
timestamp
classname
object_id

combining the three makes a unique id; but it's only unique to that  
session, no good for a real world application as there could be 50  
sessions all running at the same time on the server; and odds are  
rather high that two instances of the object could have the same id.  
Thus an extra completely unique identified needs added to the three  
values above.


I'd thought a simple random integer would possibly be enough  
(combined with the timestamp), but there could still be collission.


so the best I've got so far is:
[OBJECT_ID:private] = 3
[UNIQUE_ID:private] = instance://1231629...@testobject.3:97739
timestamp @ class . instance : randomInteger

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)


thoughts, ideas, recommendations?

regards!

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



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



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

2009-01-10 Thread Nathan Rixham

Colin Guthrie wrote:

'Twas brillig, and Nathan Rixham at 10/01/09 23:31 did gyre and gimble:
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)


thoughts, ideas, recommendations?


While it's not guaranteed to be unique the general technique used in 
these situations is to use a UUID. The chances of a clash are slim 
(2x10^38 ish combinations).


You can generate a uuid via mysql SELECT UUID() or via the PHP Pecl 
extension php-uuid.


The other way of doing it would be to insert a row into a database row 
with an auto-increment field and use the value of that auto-incrment 
field as your identifier (SELECT LAST_INSERT_ID() in mysql or via the db 
layers API).


HTHs

Col




cheers for the input; uuid it has to be I guess; don't want it reliant 
on any third party software or db so pecl is out, as is mysql - looks 
like I'm going to have to (and probably enjoy) making a uuid function to 
generate type 4 random uuids.


only other thought is to combine all the instance variables, hash the 
combination of them and save that together with a timestamp..


considering

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

Ross McKay wrote:

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

completely agreed.. missed out a word:

with optional |display| instructions via attributes (bad) or css (good)

makes more sence 




--
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] Referencing variable in calling class?

2009-01-10 Thread Murray
Hi All,

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

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

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

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

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

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

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

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

M is for Murray


[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 Ashley Sheridan
On Sun, 2009-01-11 at 11:19 +1100, Ross McKay wrote:
 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
 
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.


Ash
www.ashleysheridan.co.uk


-- 
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 Nathan Nobbe
On Sat, Jan 10, 2009 at 4:31 PM, Nathan Rixham nrix...@gmail.com wrote:

 Evening All,

 Not too often I ask a question here, but here goes;

 I'm making an Object class which all of my other classes extend, and I
 need each instance to have it's own unique id, seemed simple but it's harder
 than I thought (the difficulty is when it comes to deciding the syntax).


checkout spl_object_hash()

http://php.net/function.spl_object_hash

-nathan


Re: [PHP] Editing in a text area field

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

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

Just thinking out loud.

M is for Murray


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

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


Re: [PHP] Editing in a text area field

2009-01-10 Thread Ashley Sheridan
On Sun, 2009-01-11 at 11:44 +1000, Murray wrote:

 I don't know why, but I always baulk when I see HTML and, for example, XML
 etc described as a 'language'.
 
 I may well be wrong, but these always seem to be more appropriately
 described as a 'syntax' rather than a 'language', at least in the computer
 science sense. Of course, maybe these are essentially synonymous, but
 'language' has always implied to me a more active role, so that PHP would be
 a language, while HTML would be a syntax.
 
 Just thinking out loud.
 
 M is for Murray
 
 
 On Sun, Jan 11, 2009 at 2:04 AM, Nathan Rixham nrix...@gmail.com wrote:
 
  HTML is a markup language used to describe the structure of a document;
  presentation of HTML is controlled by either a client, with optional
  instructions via attributes (bad) or css (good)

I think you are thinking of language being synonymous with programming
language, which HTML isn't really. What it is, is a computer language.
Subtle difference, but difference, I believe, there is. Also, the name
kind of gives it away ;)


Ash
www.ashleysheridan.co.uk


Re: [PHP] Editing in a text area field

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

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

But still, an interesting observation!

M is for Murray


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

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



Re: [PHP] Editing in a text area field

2009-01-10 Thread Eric Butera
On Sat, Jan 10, 2009 at 8:51 PM, Murray planetthought...@gmail.com wrote:
 Interesting, I've never seen this presented as an issue of ethics before. I
 think I can see your point, but I'd suggest that there's an interplay of
 ethical obligations between a user and the host / creator of an application
 in which perhaps the user should or in many cases has to accept a
 de-prioritised ethical consideration.

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

 But still, an interesting observation!

 M is for Murray


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

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



I don't see any problem with accepting html/xhtml/xml in an input
area.  I do it all the time with FCKEditor.  You can argue that it is
nice because you can use things like htmlpurifier to keep it sane
while also not having to invent weird things to give the input
structure/looks.  Also being able to parse it with
simplexml/domdocument is useful too in a lot of cases.

One easy way to get around the problem with modifying the user
input, just give the user a preview of what you've done.  They can
then decide whether or not it is acceptable.

-- 
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 Murray
I agree with others that in most cases you should be storing input as it is
presented to you once POSTed (with the usual caveats of escaping etc to make
INSERTing / UPDATEing possible).

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

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

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

M is for Murray


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

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



Re: [PHP] 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



Re: [PHP] Referencing variable in calling class?

2009-01-10 Thread Paul M Foster
On Sun, Jan 11, 2009 at 10:33:30AM +1000, Murray wrote:

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

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

Does that make sense?

Paul

-- 
Paul M. Foster

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



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

2009-01-10 Thread Micah Gersten
Can you use something like APC to cache the instance variable so that
it's persistent across different sessions?

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Nathan Rixham wrote:
 Colin Guthrie wrote:
 'Twas brillig, and Nathan Rixham at 10/01/09 23:31 did gyre and gimble:
 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)

 thoughts, ideas, recommendations?

 While it's not guaranteed to be unique the general technique used in
 these situations is to use a UUID. The chances of a clash are slim
 (2x10^38 ish combinations).

 You can generate a uuid via mysql SELECT UUID() or via the PHP Pecl
 extension php-uuid.

 The other way of doing it would be to insert a row into a database
 row with an auto-increment field and use the value of that
 auto-incrment field as your identifier (SELECT LAST_INSERT_ID() in
 mysql or via the db layers API).

 HTHs

 Col



 cheers for the input; uuid it has to be I guess; don't want it reliant
 on any third party software or db so pecl is out, as is mysql - looks
 like I'm going to have to (and probably enjoy) making a uuid function
 to generate type 4 random uuids.

 only other thought is to combine all the instance variables, hash the
 combination of them and save that together with a timestamp..

 considering


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