Re: [PHP] Re: hello

2009-01-11 Thread Robert Cummings
On Sat, 2009-01-10 at 23:58 +0100, Björn Bartels wrote:
> *rofl*
> 
> damn... i love this list... so much for on- ehmmm off-list posts :p ...

It's not just a list... it's a community :)

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: Unique Object Instance ID..?

2009-01-11 Thread Robert Cummings
On Sun, 2009-01-11 at 00:07 +, 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..

Use microtime for your timestamp... much less likely to have a collision
than using seconds.

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] Couple of beginner questions

2009-01-11 Thread tedd

At 4:16 PM -0500 1/10/09, Paul M Foster wrote:

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



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

Instead, do:

Hello world

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

Hello 

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


Paul:

I agree with you. My example was not well thought out. My point was 
not to mix style elements with data. I should have said:


I would consider the following"bad practice":

 $whatever"); ?>

Whereas, the following I would consider "good practice".



Thanks for keeping me honest.

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

At 7:02 PM -0500 1/10/09, Phpster wrote:
That can and should be done with a simple str_replace() on the 
display portion of the code.


Bastien


Really?

Then how do you handle these examples of client input?

This is  I have to say.

This is what I have to say.

This is what I have to say.

This is what /> I have to say.

This is what I have to say.

And I could go on with even more examples. The point is that when you 
allow the client to inject style elements into data, then things can 
go wrong on several fronts.


One, of course is that the client can inject malformed code, which 
can screw up the page.


Two, by allowing the client to do inject styling elements, then you 
are not keeping style and date elements separate. That is counter to 
"best practices".


For example, what happens at some later date when the client wants to 
change how the data looks? The client says "You told me that you were 
using css -- I thought it was easy to change things. Why can't you 
remove all these bold statements?"


Of course, you could go to the css file and make bold not bold but 
then what happens when you need bold? This problem not as simple as 
using str_replace().


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-11 Thread Ashley Sheridan
On Sun, 2009-01-11 at 08:08 -0500, tedd wrote:
> At 4:16 PM -0500 1/10/09, Paul M Foster wrote:
> >And let me present an alternative perspective. Never do something like:
> >
> >
> >
> >Let Apache (or whatever) interpret HTML as HTML, and don't make it
> >interpret PHP code as HTML.
> >
> >Instead, do:
> >
> >Hello world
> >
> >If you're going to use PHP in the middle of a bunch of HTML, then only
> >use it where it's needed:
> >
> >Hello 
> >
> >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
> 
> Paul:
> 
> I agree with you. My example was not well thought out. My point was 
> not to mix style elements with data. I should have said:
> 
> I would consider the following"bad practice":
> 
>   $whatever"); ?>
> 
> Whereas, the following I would consider "good practice".
> 
> 
> 
> Thanks for keeping me honest.
> 
> Cheers,
> 
> tedd
> 
> 
> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 
Unless it's something like this:

$whatever";
?>

Which is unlikely for a header tag, but I know this sort of format gets
used a lot by me and others, especially for setting alternate row styles
on tables (damn browsers and not supporting alternate rows!)


Ash
www.ashleysheridan.co.uk


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

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


With a little cooperation from the client, and a properly configured
TinyMCE, you can fairly easily limit what HTML tags they use.


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


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


That's a good idea -- I like that.


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



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


Yes, I understand -- but two things:

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.


2. Mixing style elements with data is still wrong, at least in my 
mind. 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.


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

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

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

At 11:19 AM +1100 1/11/09, 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  and  are
unwanted elements. They simply confuse/blur the purpose of the
language.


I should have said  and , I guess.


No, my comment wasn't about anything you said. My comment was about 
HTML -- IMO, it's a poorly designed language which is poorly enforced 
and poorly rendered by browsers. That's one of the reasons why there 
are so many problems with cross browser development.


Additionally, considering how badly (or how good) browsers deal with 
malformed code, it hasn't helped the language any. When people can 
write bad code, without immediate consequences, they do it.


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-11 Thread Eric Butera
On Sun, Jan 11, 2009 at 8:50 AM, tedd  wrote:
> At 11:12 AM +1100 1/11/09, Ross McKay wrote:
>>
>> With a little cooperation from the client, and a properly configured
>> TinyMCE, you can fairly easily limit what HTML tags they use.
>
> Yes, when you have intelligent and cooperative clients -- have any to spare?
>
>>  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).
>
> That's a good idea -- I like that.
>

In my FCKEditor installs I use the style.xml to define h1, h2, h3, h4
as headers so in the markup the client only gets to inject header tags
& p tags.

Unfortunately I have the same problems of pasting from Word/Apple apps
too.  Yes, that's right.  Copy something from Mail.app and it is
filled with apple span style crap.  The paste from word routine only
works if they click a special button and make sure to paste into that,
which of course nobody does.

I tried using tidy to clean up some of that stuff but it was giving me
even more problems.  I enjoyed having valid docs with all the crap
ripped out, but I use my editor blocks on lots of different parts of
the site, so having it remove/combine style tags was really annoying.
I'd really like to revisit this problem again, but unfortunately I've
got other more pressing issues so this always seems to fall to the
back burner.

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



Re: [PHP] String variable

2009-01-11 Thread Eric Butera
On Sun, Jan 11, 2009 at 8:59 AM, MikeP  wrote:
> Hello,
> I am trying yo get THIS:
> where ref_id = '1234'
> from this.
> $where="where ref_id="."'$Reference[$x][ref_id]'";
>
> but i certainly have a quote problem.
>
> Any help?
> Thanks
> Mike
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Looks like you're missing the single tics around ref_id.  In your
example you'd want one of these:

$where="where ref_id="."'{$Reference[$x]['ref_id']}";
$where="where ref_id="."$Reference[$x]['ref_id'];
$where=sprintf("where ref_id=%d", (int)$Reference[$x]['ref_id']); <--
use this one or else! (sql injection)

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



Re: [PHP] String variable

2009-01-11 Thread Ashley Sheridan
On Sun, 2009-01-11 at 08:59 -0500, MikeP wrote:
> Hello,
> I am trying yo get THIS:
> where ref_id = '1234'
> from this.
> $where="where ref_id="."'$Reference[$x][ref_id]'";
> 
> but i certainly have a quote problem.
> 
> Any help?
> Thanks
> Mike
> 
> 
> 
> 

It should look like this:

$where="where ref_id="'{$Reference[$x][ref_id]}'";


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] String variable

2009-01-11 Thread Ashley Sheridan
On Sun, 2009-01-11 at 14:36 +, Ashley Sheridan wrote:
> On Sun, 2009-01-11 at 08:59 -0500, MikeP wrote:
> > Hello,
> > I am trying yo get THIS:
> > where ref_id = '1234'
> > from this.
> > $where="where ref_id="."'$Reference[$x][ref_id]'";
> > 
> > but i certainly have a quote problem.
> > 
> > Any help?
> > Thanks
> > Mike
> > 
> > 
> > 
> > 
> 
> It should look like this:
> 
> $where="where ref_id="'{$Reference[$x][ref_id]}'";
> 
> 
> Ash
> www.ashleysheridan.co.uk
> 
> 
Sorry, it should look like this:

$where="where ref_id='{$Reference[$x][ref_id]}'";

I missed taking an extra quote mark out


Ash
www.ashleysheridan.co.uk


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

At 11:24 AM +1100 1/11/09, 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...


No, you bring up a good point.

Realize that all the elements you described are not style elements, 
but as you said are behavior elements. It's debatable if behavior 
elements should be in a markup language at all.


From my respective, I see things in five camps.

1. Data -- such as name, address, etc -- text
2. Structure -- HMTL
3. Style -- CSS
4. Behavior -- Javascript.
5. Function -- PHP/MySQL.

Now, each of these camps overlap considerably. I was going to show 
good/bad examples, but the list became more extensive than I wanted 
for this post.


The point I am trying to make was that each language has it's strong 
and weak points. Just because a language can do something doesn't 
mean that's the best way to do it.


Discover what problems are best solved with what languages and create 
multilingual code that observes best practices. And along the way, 
try to show others (including clients) the path to enlightenment.  :-)


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

At 1:49 PM + 1/11/09, Ashley Sheridan wrote:


Unless it's something like this:

$whatever";
?>

Which is unlikely for a header tag, but I know this sort of format gets
used a lot by me and others, especially for setting alternate row styles
on tables (damn browsers and not supporting alternate rows!)

Ash


Ash:

Here's the alterative I would use:



Again, please forgive my use of echo().

The point being, wherever you want to insert a variable, then do it, 
but leave html out of your code.


My "alternate row styles" solution is this:

http://webbytedd.com/b/color-rows/

Please note that no html is harmed in the making of this presentation. :-)

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-11 Thread Ashley Sheridan
On Sun, 2009-01-11 at 09:46 -0500, tedd wrote:
> At 1:49 PM + 1/11/09, Ashley Sheridan wrote:
> >
> >Unless it's something like this:
> >
> > >echo "$whatever";
> >?>
> >
> >Which is unlikely for a header tag, but I know this sort of format gets
> >used a lot by me and others, especially for setting alternate row styles
> >on tables (damn browsers and not supporting alternate rows!)
> >
> >Ash
> 
> Ash:
> 
> Here's the alterative I would use:
> 
> 
> 
> Again, please forgive my use of echo().
> 
> The point being, wherever you want to insert a variable, then do it, 
> but leave html out of your code.
> 
> My "alternate row styles" solution is this:
> 
> http://webbytedd.com/b/color-rows/
> 
> Please note that no html is harmed in the making of this presentation. :-)
> 
> Cheers,
> 
> tedd
> 
I'm not wanting ti nitpick, but what if there were several attributes
you needed to populate from the PHP? I just find it easier on my eyes to
include HTML in the PHP string that's being output, but I can see the
definite merits for echoing out single parts that would only get in the
way of the HTML.


Ash
www.ashleysheridan.co.uk


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

At 9:02 AM -0500 1/11/09, Eric Butera wrote:

I tried using tidy to clean up some of that stuff but it was giving me
even more problems.  I enjoyed having valid docs with all the crap
ripped out, but I use my editor blocks on lots of different parts of
the site, so having it remove/combine style tags was really annoying.
I'd really like to revisit this problem again, but unfortunately I've
got other more pressing issues so this always seems to fall to the
back burner.


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

 126))
 {
 $a .= "";
 }
  else
 {
 $a .= $str[$i];
 }
  }
   return $a;
   }
?>

And then strip_tags() --  it's a start.

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

At 3:02 PM + 1/11/09, Ashley Sheridan wrote:

On Sun, 2009-01-11 at 09:46 -0500, tedd wrote:

 At 1:49 PM + 1/11/09, Ashley Sheridan wrote:

 > >

 >Unless it's something like this:
 >
 >echo "$whatever";

 > >?>
 >

 Here's the alterative I would use:


 > 

I'm not wanting ti nitpick, but what if there were several attributes
you needed to populate from the PHP? I just find it easier on my eyes to
include HTML in the PHP string that's being output, but I can see the
definite merits for echoing out single parts that would only get in the
way of the HTML.


Ash:

Nitpick as much as you want -- we all have our level of accommodation.

To me, there usually is a clear demarcation between the different 
languages, their scope, and best application. If I had to deal with 
several attributes, such as shown here:


Hello World

I would write it up like so:

$header_class = "red header";
$whatever = "Hello World";



In my css, I would have

.red
   {
   color: #ff;
   }

.header
   {
   font-size: 1.2em;
   }

That would solve the problem of several attributes and keep php, 
html, and css separate.


So handling numerous attributes would not be a problem 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-11 Thread Ashley Sheridan
On Sun, 2009-01-11 at 10:16 -0500, tedd wrote:
> At 3:02 PM + 1/11/09, Ashley Sheridan wrote:
> >On Sun, 2009-01-11 at 09:46 -0500, tedd wrote:
> >>  At 1:49 PM + 1/11/09, Ashley Sheridan wrote:
> >  > >
> >>  >Unless it's something like this:
> >>  >
> >>  > >>  >echo "$whatever";
> >  > >?>
> >  >
> >>  Here's the alterative I would use:
> >>
> >  > 
> >
> >I'm not wanting ti nitpick, but what if there were several attributes
> >you needed to populate from the PHP? I just find it easier on my eyes to
> >include HTML in the PHP string that's being output, but I can see the
> >definite merits for echoing out single parts that would only get in the
> >way of the HTML.
> 
> Ash:
> 
> Nitpick as much as you want -- we all have our level of accommodation.
> 
> To me, there usually is a clear demarcation between the different 
> languages, their scope, and best application. If I had to deal with 
> several attributes, such as shown here:
> 
> Hello World
> 
> I would write it up like so:
> 
> $header_class = "red header";
> $whatever = "Hello World";
> 
> 
> 
> In my css, I would have
> 
> .red
> {
> color: #ff;
> }
> 
> .header
> {
> font-size: 1.2em;
> }
> 
> That would solve the problem of several attributes and keep php, 
> html, and css separate.
> 
> So handling numerous attributes would not be a problem for me.
> 
> Cheers,
> 
> tedd
> 
> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 
I was thinking more along the lines of this:

echo "";


which looks like this otherwise:






Ash
www.ashleysheridan.co.uk


-- 
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-11 Thread Eric Butera
On Sun, Jan 11, 2009 at 10:36 AM, Ashley Sheridan
 wrote:
> echo "http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Couple of beginner questions

2009-01-11 Thread Ashley Sheridan
On Sun, 2009-01-11 at 10:44 -0500, Eric Butera wrote:
> On Sun, Jan 11, 2009 at 10:36 AM, Ashley Sheridan
>  wrote:
> > echo " 
> Gross!  If that is what you're doing use a printf or change attr
> quotes to '.  I've seen entire html pages escaped out like that.
> 
No it was just an example, normally in that situation I use heredoc, but
I felt it unfair to deviate from the example I'd previously been using
as a comparison to the code separation method.


Ash
www.ashleysheridan.co.uk


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



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

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

Upon OUTPUT, you can use nl2br() to get  tags.
Or str_replace if you want  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've been following this thread with interest because it is a recurring 
challenge I've had to deal with while coding applications for my running club. 
We have numerous non techies who enter text material for several applications.


My code deals with most, if not all, the issues brought up in this thread.

All processing on server-side. I save the user's input intact and only add the 
HTML and styling code on the fly when sending to browsers.  Also, note, my 
rendered code is XHTML compliant. The error checking for the user is done with 
Tidy.


If anyone is interested, I will provide the code used for this portion of the 
application. It is well documented and easily modified.


Here is a copy of the user instructions for entering text in a textarea. Keep in 
mind when reading the instructions that the examples are styled, colored, 
bolded, etc. They are not in this plain text copy.  The real thing is here: 
http://www.ridersite.org/miniReg/miniRegInstr.php

**
User Instructions and Text Highlighting

Proxie Tags are special instructions for the user's browser and consist of 
starting and, generally [there are exceptions as noted], ending elements [e.g., 
Blue Text] Tag names can be lower or upper case, or any 
combination. A complete list of the usable tags is located just below the User 
Instructions box.


HTML tags: You can use actual HTML tags; but, unless you are proficient with 
HTML coding, we recommend sticking with the proxy tags.


Emphasize text like this:
Red Text Blue Text bold text [or the html 
bold text] italic underline


Headers: Header Text are used as paragraph lead-ins and are 
always left justified.


New Lines: Occasionally, you may want to force a new line. Simple add this tag 
as needed  to force the new line.


Titles: Titles are centered when rendered. You can use this tag for blue titles 
Title and Blue Subtitle; and 
this for normal titles Title Titles and subtitles must be on 
separate lines.


Use this syntax for Email and URL Links:
email links: recipient's email addrrecipient's name
URL links: URLlink text,

IMPORTANT.. Be very careful that you "close" all tags [e.g.,  ] 
and that tags are nested properly
[e.g., Red Text  ]. Note that  and  are 
both inside of  and .

User Instructions HTML Error Checking

To insure your user instructions will display properly on all browsers, the 
proxie and html tags you used are checked for validity. The check is performed 
on the actual HTML code that will be sent to the user. Thus, the proxie tags you 
used will have been converted to HTML tags.


The Error Report: shows the HTML errors and thus it may not be clear the cause 
is due to a proxy tag error. For example, assume you misspelled  as 
, the error report will say "Error:  is not recognized! Warning: 
discarding unexpected  Warning: discarding unexpected ". The  
error is noted OK. But, note the "discarding unexpected "; that is because 
you correctly spelled the  proxy tag and the proxy-to-HTML conversion 
process properly converted it to the HTML  tag. The error checker thus found 
an unexpected  tag.


Pasting Text from Word Processors: You can copy/paste text from your 
wordprocessor into the "member/user instructions" box. However, you need to be 
alert since wordprocessors use some special characters that are incompatible 
with internet standards. MiniReg converts most, but not all, of them to 
equivalent internet compatible characters. Carefully check your text in the box 
and make any necessary corrections.



/**
* Proxie tags for user admin prepared user instructions
* You add new ones, keep alpha order; just make certain they render properly 
under the "Compose your member/user instructions here" box

*/
$proxiesTranslateArray = array(// *
'' => '',
'' => '',
"" => '" => "\">",
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
);

Here is my Word translation table:

//Translate table for dumb Windows chars when user pastes from Word; function 
strips all >160


$win1252ToPlainTextArray=array(
chr(130)=> ',',
chr(131)=> '',
chr(132)=> ',,',
chr(133)=> '...',
chr(

[PHP] FirePHP -- pretty cool

2009-01-11 Thread Skip Evans

Hey all,

I'm sure many of you use Firebug in Firefox for help debugging, and some 
of you also no doubt know about FirePHP, the PHP class that let's you 
write logs to the Firebug console.


In case you don't know about it, Joe Bob Briggs says, "Check it out."

I just installed and it's pretty cool.

http://www.firephp.org/

Very easy install and set up: you basically include on PHP file and 
you're off to the races. I wrote a quick wrapper function that takes a 
string and outputs it to the Firebug console and am finding it pretty 
helpful.


I think it's especially useful if you write a lot of AJAX calls that 
don't allow easy output of debug statements.


Would like to hear other opinions of this little tool.
--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison, Wisconsin 53703
608-250-2720
http://bigskypenguin.com

"Those of you who believe in telekinetics, raise my hand."

-- Kurt Vonnegut

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

Ashley Sheridan wrote:

On Sun, 2009-01-11 at 10:16 -0500, tedd wrote:

At 3:02 PM + 1/11/09, Ashley Sheridan wrote:

On Sun, 2009-01-11 at 09:46 -0500, tedd wrote:

 At 1:49 PM + 1/11/09, Ashley Sheridan wrote:

 > >

 >Unless it's something like this:
 >
 >echo "$whatever";

 > >?>
 >

 Here's the alterative I would use:


 > 

I'm not wanting ti nitpick, but what if there were several attributes
you needed to populate from the PHP? I just find it easier on my eyes to
include HTML in the PHP string that's being output, but I can see the
definite merits for echoing out single parts that would only get in the
way of the HTML.

Ash:

Nitpick as much as you want -- we all have our level of accommodation.

To me, there usually is a clear demarcation between the different 
languages, their scope, and best application. If I had to deal with 
several attributes, such as shown here:


Hello World

I would write it up like so:

$header_class = "red header";
$whatever = "Hello World";



In my css, I would have

.red
{
color: #ff;
}

.header
{
font-size: 1.2em;
}

That would solve the problem of several attributes and keep php, 
html, and css separate.


So handling numerous attributes would not be a problem for me.

Cheers,

tedd

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


I was thinking more along the lines of this:

echo "";


which looks like this otherwise:






Ash
www.ashleysheridan.co.uk



i love these discussions on pedantics and semantics!

personally (when I need to) I always go for a bit of concatenation so in 
the example above:


// somewhere in the business logic / functional layer
$imgHTML = '';


.
// somewhere in the display layer
echo $imgHTML;

however; I only really do this when developing or in a quick bit of 
script; whenever possible I'll always use a templating engine, or 
xml/xsl which is the perfect abstraction between data and presentation IMHO.


another little note is that I'd never echo out a class or presentation 
data; infact I'd never use a class on a tag such as img either, 
preference going to a bit of css using selectors


div#article_content p img {
/* whatever */
}

I'm not sure what's brought me to these conclusions, I've certainly been 
through all the other methods of doing it - however for a couple of 
years now I've limitted all presentation to css only, css contained in a 
stylesheet - I try to use minimal css classes, and stick to using an id 
wherever I can't simply redefine the html tag.


TBH i think even if I'm doing a complete site myself, I still like to 
wear different caps (developer, designer, etc) and as such keep the 
layers as seperate as possible, as if it was somebody completely 
different working on the design.


the above means that moving back to the original  example(s) I'd simply

whatever

css:
h1 {
  color: rgb(255,0,0);
  font-size: 1.2em;
}

seeing as you can only have one h1 tag on a single document.

if you can take any points from this ramble of mine, it'd be that IMHO 
the output from a script should at most comprise of something like:

output( $template , $variables );
?>
infact ideally an html tag should never be seen in a php script

... and to take it further a echo'd string probably shouldn't either! so 
technically this is bad:




while this is good


which is caught higher up, the localized error message for 
WHATEVER_ERROR_CODE is then loaded, fired through to the display engine 
which formats and displays it to the client.


can seem like overkill, but if you want to have multiple front ends to 
you're app (say a soap interface, a flash ui and an html ui) there's no 
other way.


joy

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



Re: [PHP] String variable

2009-01-11 Thread Nathan Rixham

Ashley Sheridan wrote:

On Sun, 2009-01-11 at 14:36 +, Ashley Sheridan wrote:

On Sun, 2009-01-11 at 08:59 -0500, MikeP wrote:

Hello,
I am trying yo get THIS:
where ref_id = '1234'
from this.
$where="where ref_id="."'$Reference[$x][ref_id]'";

but i certainly have a quote problem.

Any help?
Thanks
Mike





It should look like this:

$where="where ref_id="'{$Reference[$x][ref_id]}'";


Ash
www.ashleysheridan.co.uk



Sorry, it should look like this:

$where="where ref_id='{$Reference[$x][ref_id]}'";

I missed taking an extra quote mark out


Ash
www.ashleysheridan.co.uk



actually unless ref_id is a constant (which i doublt) you may be best 
going with:


$where = "WHERE ref_id='" . $Reference[$x]['ref_id'] . "'";

keep the php and sql seperate and you'll find it much easier to see in 
you're editor


(imho) :)

--
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-11 Thread Robert Cummings
On Sun, 2009-01-11 at 17:01 +, Nathan Rixham wrote:
> 
> i love these discussions on pedantics and semantics!
> 
> personally (when I need to) I always go for a bit of concatenation so in 
> the example above:
> 
> // somewhere in the business logic / functional layer
> $imgHTML = '';

I do the same, except why you have all those space around your
concatenation I don't know. Although, to be honest I tend to vertically
spread my tags/attributes:

$imgHTML =
'';

This makes it easy to see at a glance what is there and to also comment
out lines easily.

> .
> // somewhere in the display layer
> echo $imgHTML;

For images I usually do:



The custom tag will expand the path to wherever the images directory was
defined and will scan the image for width and height and add those
attributes also.

> however; I only really do this when developing or in a quick bit of 
> script; whenever possible I'll always use a templating engine, or 
> xml/xsl which is the perfect abstraction between data and presentation IMHO.
> 
> another little note is that I'd never echo out a class or presentation 
> data; infact I'd never use a class on a tag such as img either, 
> preference going to a bit of css using selectors
> 
> div#article_content p img {
> /* whatever */
> }

Personally, I try not to use IDs to target my stylesheets. I try to use
IDs to target actual objects within the document for use with DHTML or
forms processing. It's a pain in the ass overriding a CSS rule that was
targeted with an ID since the ID carries so much weight. Otherwise, I
generally use higher up class definitions and do as you have done by
drilling down to individual members of the rule.

> I'm not sure what's brought me to these conclusions, I've certainly been 
> through all the other methods of doing it - however for a couple of 
> years now I've limitted all presentation to css only, css contained in a 
> stylesheet - I try to use minimal css classes, and stick to using an id 
> wherever I can't simply redefine the html tag.

I use lots and lots of CSS classes, all nicely kept in their own
contextual template files that are then built into the grand stylesheet
file with all my internal comments stripped from production.

> TBH i think even if I'm doing a complete site myself, I still like to 
> wear different caps (developer, designer, etc) and as such keep the 
> layers as seperate as possible, as if it was somebody completely 
> different working on the design.

Absolutely.

> the above means that moving back to the original  example(s) I'd simply
> 
> whatever

I'd probably do:

Whatever

Which would expand to:

Whatever

Which would expand to a bunch of intermixed HTML/PHP code directly in
the requested document.

The reason for the accumulator flush is to add content to the title in
an unrelated area of the templates as is occasionally necessary. The
first inserts accumulated content during the build process, the second
allows insertion at run-time. Run-time is probably used more often since
it may be when editing a user profile or something and the name is
inserted into the title from the form controller. The compile time
version is used less often but has no run-time hit since it's pre-built.

> css:
> h1 {
>color: rgb(255,0,0);
>font-size: 1.2em;
> }
> 
> seeing as you can only have one h1 tag on a single document.

Says who?

> if you can take any points from this ramble of mine, it'd be that IMHO 
> the output from a script should at most comprise of something like:
>  // business logic
> $display_engine->output( $template , $variables );
> ?>
> infact ideally an html tag should never be seen in a php script

That depends on what the role of the PHP script is. A custom tag handler
certainly should output HTML. A forms engine certainly should hide the
HTML details unless you want to do all the low level form crap yourself
(mine outputs convenient CSS classes/ids transparently for me).

> ... and to take it further a echo'd string probably shouldn't either! so 
> technically this is bad:

Again that depends on the purpose of the echo'd string. And also whether
you just use PHP for web applications, or as I and many others do, also
use it for shell scripts.

> 
>  if( whatever() ) {
> // whatever
> } else {
> echo 'turns out you entered some invalid data client';
> }
> ?>
> 
> while this is good
>  if( whatever() ) {
> // whatever
> } else {
> throw new UnexpectedValueException( WHATEVER_ERROR_CODE );
> }
> ?>
> 
> which is caught higher up, the localized error message for 
> WHATEVER_ERROR_CODE is then loaded, fired through to the display engine 
> which formats and displays it to the client.

Via echo? Thought you didn't like echo ;)

> can seem like overkill, but if you want to have multiple front ends to 
> you're app (say a soap interface, a flash ui and an html ui) there's no 
> other way.

You're still echoing it though.

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

[PHP] RSS feeder in PHP5?

2009-01-11 Thread Michelle Konzack
Hello,

on my website I have a NEWS section on



and the news are stored in a SQL table with "date", "summary", "fulltext"
Now I like to add an RSS feed with something like



which require only an additional function in my scripts...

Is there something in PHP5 which can generate the RSS feed?

It should only pick-up the "date" and  "summary"  from  maybe  the  last
10 entries from the database and that it is...

Note:   The RSS file can NOT pre-build because
I can not run cronjobs my own...

Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
   
Michelle Konzack   Apt. 917  ICQ #328449886
+49/177/935194750, rue de Soultz MSN LinuxMichi
+33/6/61925193 67100 Strasbourg/France   IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


Re: [PHP] is_readable(http://.... text file) says not, but I can in browser

2009-01-11 Thread John Allsopp

Daniel Brown wrote:

On Sun, Dec 28, 2008 at 13:02, John Allsopp  wrote:
  

  $myFileLast = "http://www.myDomain.com/text.txt";;
  if (is_readable($myFileLast))
  {
  $fh = fopen($myFileLast, 'r');
  $theDataLast = fread($fh, 200);
  fclose($fh);
  echo ("The dataLast: ".$theDataLast."\n");
  } else
  {
  echo ("Last fix file unavailable: $myFileLast\n");
  }



Simplified:

http://www.myDomain.com/text.txt";;
$theDataLast = file_get_contents($myFileLast);
?>

You can manipulate the code as you see fit.  If it doesn't work,
then check your php.ini file (if you have access) to ensure that you
have this line:

allow_url_fopen = On

  
Thanks, that worked a treat except I was getting warnings on 404. I 
looked around for solutions to that and it appears curl might handle 
that better, so I'm currently working on that. Many thanks tho .. let me 
know if you know how to stop the warnings :-)


J

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



Re: [PHP] is_readable(http://.... text file) says not, but I can in browser

2009-01-11 Thread John Allsopp

Nathan Nobbe wrote:

On Sun, Dec 28, 2008 at 11:02 AM, John Allsopp wrote:

  

Hi

I'm sure this is simple for yous all but I'm not sure I know the answer.

  $myFileLast = "http://www.myDomain.com/text.txt";;
  if (is_readable($myFileLast))
  {
  $fh = fopen($myFileLast, 'r');
  $theDataLast = fread($fh, 200);
  fclose($fh);
  echo ("The dataLast: ".$theDataLast."\n");
  } else
  {
  echo ("Last fix file unavailable: $myFileLast\n");
  }

returns Last fix file unavailable even for a file that my browser can read.
All I want to do is skip over files

This could be a very simple error, I'd appreciate a pointer. Is it
permissions being different for PHP versus the browser or something? PHP is
running on a different server.




are you basically trying to tell if theres a resource @ the given url?  if
so, id prefer curl myself.

something like

if(($ch = curl_init($url) === false)
  echo ("Last fix file unavailable: $myFileLast\n");
else {
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);*
*  $theDataLast = curl_exec($ch);
  echo ("The dataLast: ".$theDataLast."\n");*
*  curl_close($ch);*
*}

obviously, youll need the curl extension installed for this to work.  i know
the fopen wrappers will allow you to get a read-only handle to an http url,
but im not sure what is_readable() will do w/ that, it may be limited to the
local filesystem.

-nathan

  
Thanks. I'm trying to read the contents of the file at the URL, but it 
might not exist.


So far I'm getting a lot of *Warning*: curl_setopt(): supplied argument 
is not a valid cURL handle resource in 
*/home/myAcc/public_html/test.php* on line *58

*
I searched phpinfo for 'curl' and it came up nothing, so I'm just 
checking with my hosts to see if I have the extension installed.


I'll be back, thanks
J

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

Robert Cummings wrote:

On Sun, 2009-01-11 at 17:01 +, Nathan Rixham wrote:
  

i love these discussions on pedantics and semantics!

personally (when I need to) I always go for a bit of concatenation so in 
the example above:


// somewhere in the business logic / functional layer
$imgHTML = '';



I do the same, except why you have all those space around your
concatenation I don't know. Although, to be honest I tend to vertically
spread my tags/attributes:
  


re: space around concatenation; I add spaces in wherever I can, find it 
easier to read the code; and when it's a particularly long string it 
makes it far more readable; so using my own false logic if it's easier 
to see long, it's easier to see short as well.


re: vertically spread; I often do the same thing, general rule of thumb 
is if it's anywhere near a full line or scrolling sideways I'll 
multi-line it - in this case I would have multi-lined in my own code 
aswell :)



$imgHTML =
'';

This makes it easy to see at a glance what is there and to also comment
out lines easily.

  

.
// somewhere in the display layer
echo $imgHTML;



For images I usually do:



The custom tag will expand the path to wherever the images directory was
defined and will scan the image for width and height and add those
attributes also.

  
however; I only really do this when developing or in a quick bit of 
script; whenever possible I'll always use a templating engine, or 
xml/xsl which is the perfect abstraction between data and presentation IMHO.


another little note is that I'd never echo out a class or presentation 
data; infact I'd never use a class on a tag such as img either, 
preference going to a bit of css using selectors


div#article_content p img {
/* whatever */
}



Personally, I try not to use IDs to target my stylesheets. I try to use
IDs to target actual objects within the document for use with DHTML or
forms processing. It's a pain in the ass overriding a CSS rule that was
targeted with an ID since the ID carries so much weight. Otherwise, I
generally use higher up class definitions and do as you have done by
drilling down to individual members of the rule.
  
I use it for both; but sparingly for example  
means I should be able to pick up all sub elements for both dom 
manipulation and css rules
  
I'm not sure what's brought me to these conclusions, I've certainly been 
through all the other methods of doing it - however for a couple of 
years now I've limitted all presentation to css only, css contained in a 
stylesheet - I try to use minimal css classes, and stick to using an id 
wherever I can't simply redefine the html tag.



I use lots and lots of CSS classes, all nicely kept in their own
contextual template files that are then built into the grand stylesheet
file with all my internal comments stripped from production.
  


only time I'll use lots of classes is for things css like red, 
top-padding, bold etc (generics) never for .leftPageImageFirstImage
  
TBH i think even if I'm doing a complete site myself, I still like to 
wear different caps (developer, designer, etc) and as such keep the 
layers as seperate as possible, as if it was somebody completely 
different working on the design.



Absolutely.
  

:)
  

the above means that moving back to the original  example(s) I'd simply

whatever



I'd probably do:

Whatever

Which would expand to:

Whatever

Which would expand to a bunch of intermixed HTML/PHP code directly in
the requested document.

The reason for the accumulator flush is to add content to the title in
an unrelated area of the templates as is occasionally necessary. The
first inserts accumulated content during the build process, the second
allows insertion at run-time. Run-time is probably used more often since
it may be when editing a user profile or something and the name is
inserted into the title from the form controller. The compile time
version is used less often but has no run-time hit since it's pre-built.
  
I do like you're interjinn.. it's like a good coldfusion (no offense 
intented)
  

css:
h1 {
   color: rgb(255,0,0);
   font-size: 1.2em;
}

seeing as you can only have one h1 tag on a single document.



Says who?
  


well it's logical good practise I guess - not a hard and fast rule 
(although should probably be thought of as a rule..?)
H* tags are used to describe the semantic structure of a document, the 
H1 tag being used to describe what the entire document / page is about, 
then h2-h6 being used to split it into sub sections / sub headings. Thus 
two H1 tags indicates that the document is two different documents. The 
W3C site itself is normally a good indication for things like this, I'm 
100% sure if you check the source for every page you'll not find a 
single case where there are two H1 tags.


example:
http://www.w3.org/TR/xhtml1/

from the source:

 XHTML™ 1.0 The Extensible HyperText Markup 
Language (Second Edition)

because the d

Re: [PHP] is_readable(http://.... text file) says not, but I canin browser

2009-01-11 Thread Nathan Rixham

John Allsopp wrote:

Nathan Nobbe wrote:
On Sun, Dec 28, 2008 at 11:02 AM, John Allsopp 
wrote:


 

Hi

I'm sure this is simple for yous all but I'm not sure I know the answer.

  $myFileLast = "http://www.myDomain.com/text.txt";;
  if (is_readable($myFileLast))
  {
  $fh = fopen($myFileLast, 'r');
  $theDataLast = fread($fh, 200);
  fclose($fh);
  echo ("The dataLast: ".$theDataLast."\n");
  } else
  {
  echo ("Last fix file unavailable: $myFileLast\n");
  }

returns Last fix file unavailable even for a file that my browser can 
read.

All I want to do is skip over files

This could be a very simple error, I'd appreciate a pointer. Is it
permissions being different for PHP versus the browser or something? 
PHP is

running on a different server.




are you basically trying to tell if theres a resource @ the given 
url?  if

so, id prefer curl myself.

something like

if(($ch = curl_init($url) === false)
  echo ("Last fix file unavailable: $myFileLast\n");
else {
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);*
*  $theDataLast = curl_exec($ch);
  echo ("The dataLast: ".$theDataLast."\n");*
*  curl_close($ch);*
*}

obviously, youll need the curl extension installed for this to work.  
i know
the fopen wrappers will allow you to get a read-only handle to an http 
url,
but im not sure what is_readable() will do w/ that, it may be limited 
to the

local filesystem.

-nathan

  
Thanks. I'm trying to read the contents of the file at the URL, but it 
might not exist.


So far I'm getting a lot of *Warning*: curl_setopt(): supplied argument 
is not a valid cURL handle resource in 
*/home/myAcc/public_html/test.php* on line *58

*
I searched phpinfo for 'curl' and it came up nothing, so I'm just 
checking with my hosts to see if I have the extension installed.


I'll be back, thanks
J


might be a bracket thing..

could try:
if( ($ch = curl_init($url)) === false) {
  echo ("Last fix file unavailable: $myFileLast\n");
} else {


or
if( !is_resource($ch = curl_init($url)) ) {
  echo ("Last fix file unavailable: $myFileLast\n");
} else {


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



Re: [PHP] is_readable(http://.... text file) says not, but I canin browser

2009-01-11 Thread Nathan Rixham

John Allsopp wrote:

Daniel Brown wrote:
On Sun, Dec 28, 2008 at 13:02, John Allsopp  
wrote:
 

  $myFileLast = "http://www.myDomain.com/text.txt";;
  if (is_readable($myFileLast))
  {
  $fh = fopen($myFileLast, 'r');
  $theDataLast = fread($fh, 200);
  fclose($fh);
  echo ("The dataLast: ".$theDataLast."\n");
  } else
  {
  echo ("Last fix file unavailable: $myFileLast\n");
  }



Simplified:

http://www.myDomain.com/text.txt";;
$theDataLast = file_get_contents($myFileLast);
?>

You can manipulate the code as you see fit.  If it doesn't work,
then check your php.ini file (if you have access) to ensure that you
have this line:

allow_url_fopen = On

  
Thanks, that worked a treat except I was getting warnings on 404. I 
looked around for solutions to that and it appears curl might handle 
that better, so I'm currently working on that. Many thanks tho .. let me 
know if you know how to stop the warnings :-)


J


error supression is @ so:
http://www.myDomain.com/text.txt";;
$theDataLast = @file_get_contents($myFileLast);
?>

or using a conditional block
http://www.myDomain.com/text.txt";;
  if( ($theDataLast = file_get_contents($myFileLast)) !== FALSE ) {
// proceed
  }
?>

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



Re: [PHP] is_readable(http://.... text file) says not, but I can in browser

2009-01-11 Thread Daniel Brown
On Sun, Jan 11, 2009 at 13:07, John Allsopp  wrote:
>
> Thanks, that worked a treat except I was getting warnings on 404. I looked
> around for solutions to that and it appears curl might handle that better,
> so I'm currently working on that. Many thanks tho .. let me know if you know
> how to stop the warnings :-)

If you want to stop the warnings and verify that data exists, you
can just modify that code like so:

http://www.isawit.com/ffindex.php";;
   $theDataLast = (strlen($tmpData = @file_get_contents($myFileLast))
> 0) ? $tmpData : sprintf("File not found.");
?>

Then you can modify it to read generated error pages (such as
Apache's stock 404 page) through a simple regexp or other method to
verify that the file is what you expect it to be.

-- 

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] is_readable(http://.... text file) says not, but I can in browser

2009-01-11 Thread Daniel Brown
On Sun, Jan 11, 2009 at 13:10, John Allsopp  wrote:
>
> So far I'm getting a lot of *Warning*: curl_setopt(): supplied argument is
> not a valid cURL handle resource in */home/myAcc/public_html/test.php* on
> line *58
> *
> I searched phpinfo for 'curl' and it came up nothing, so I'm just checking
> with my hosts to see if I have the extension installed.

That error indirectly tells you that you do.  If cURL wasn't
installed, you'd get an undefined function error instead.

-- 

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] is_readable(http://.... text file) says not, but I can in browser

2009-01-11 Thread Nathan Rixham

Daniel Brown wrote:

On Sun, Jan 11, 2009 at 13:07, John Allsopp  wrote:

Thanks, that worked a treat except I was getting warnings on 404. I looked
around for solutions to that and it appears curl might handle that better,
so I'm currently working on that. Many thanks tho .. let me know if you know
how to stop the warnings :-)


If you want to stop the warnings and verify that data exists, you
can just modify that code like so:

http://www.isawit.com/ffindex.php";;
   $theDataLast = (strlen($tmpData = @file_get_contents($myFileLast))

0) ? $tmpData : sprintf("File not found.");

?>

Then you can modify it to read generated error pages (such as
Apache's stock 404 page) through a simple regexp or other method to
verify that the file is what you expect it to be.



pedantic: really you'd want to check the http status header returned and 
take the appropriate action depending on what header was returned.


I'm sure there's a way to get the headers from a file_get_contents using 
one of the stream_get_* functions but can't remember off hand, going to 
have to look into that at some point. (stream_get_metadata maybe?)


dan raises a good point though; there are loads of responses you can 
get, and not all of them will be the page you expect; worth giving some 
thought to.


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



Re: [PHP] FirePHP -- pretty cool

2009-01-11 Thread Nitsan Bin-Nun
I'm using FireBug 24/7/365 and I also knew FirePHP before but I never tried
it or had any experience with it that I can share.
There are any other options and functions that FirePHP gives which not
require you to involve changing your code?

Nitsan

On Sun, Jan 11, 2009 at 6:46 PM, Skip Evans  wrote:

> Hey all,
>
> I'm sure many of you use Firebug in Firefox for help debugging, and some of
> you also no doubt know about FirePHP, the PHP class that let's you write
> logs to the Firebug console.
>
> In case you don't know about it, Joe Bob Briggs says, "Check it out."
>
> I just installed and it's pretty cool.
>
> http://www.firephp.org/
>
> Very easy install and set up: you basically include on PHP file and you're
> off to the races. I wrote a quick wrapper function that takes a string and
> outputs it to the Firebug console and am finding it pretty helpful.
>
> I think it's especially useful if you write a lot of AJAX calls that don't
> allow easy output of debug statements.
>
> Would like to hear other opinions of this little tool.
> --
>
> Skip Evans
> Big Sky Penguin, LLC
> 503 S Baldwin St, #1
> Madison, Wisconsin 53703
> 608-250-2720
> http://bigskypenguin.com
>
> "Those of you who believe in telekinetics, raise my hand."
>
> -- Kurt Vonnegut
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] is_readable(http://.... text file) says not, but I can in browser

2009-01-11 Thread Daniel Brown
On Sun, Jan 11, 2009 at 13:42, Nathan Rixham  wrote:
>
> pedantic: really you'd want to check the http status header returned and
> take the appropriate action depending on what header was returned.
>
> I'm sure there's a way to get the headers from a file_get_contents using one
> of the stream_get_* functions but can't remember off hand, going to have to
> look into that at some point. (stream_get_metadata maybe?)

You're right, Nate.  I should've included that as well rather than
suggesting that parsing a page is the only way.  It wasn't how I
intended it, but by neglecting to include the info, I can see how it
would be thought that way.  So here it is, updated:

http://www.isawit.com/index.php";;
   $theDataLast = (strlen($tmpData = @file_get_contents($myFileLast))
> 0 && !strstr('404',$http_response_header[1])) ? $tmpData :
sprintf("File not found.");
?>

> dan raises a good point though; there are loads of responses you can get,
> and not all of them will be the page you expect; worth giving some thought
> to.

There's also a strong possibility that the data will be different
- or 404'ed, even if the data exists on the server, as a means of
dropping automated requests, which could be seen as data scraping.  So
if you go the cURL route, you may want to consider client (browser)
spoofing, using MSIE, Firefox, Safari, or even Googlebot.

I had written a paper several years ago for a security consortium,
and one of the things I had included in the website security section
was how some webmasters were adopting a practice of allowing Google
and other bots to spider private content in order to build searchable
terms and increase their results.  It would appear to Google, Yahoo!,
etc., that the page was a normal, unrestricted web page based only
upon the headers sent by the bot, while an unmodified browser would
send its headers as being a standard computer web browser.  By simply
changing the sent headers on a browser, I was able to surf the
websites without restriction - some even allowing me unchallenged into
administrative areas that contained personal information.

-- 

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] FirePHP -- pretty cool

2009-01-11 Thread Skip Evans

Hey Nitsan & all,

I haven't been through it all, I just installed the plug in and download 
the file to include and started using it.


I would imagine you have to use their log function to get any output, 
but it seems like the kind of thing that could be left in the code 
without any ill-affect.


I wrote a wrapper in my global functions file, and I suppose if I wanted 
to turn it off I'd just have that function return at the top.


So far I'm finding it useful and easy enough to use.

If you don't want to change your code I would imagine something like 
xdebug would be the next step.


Skip

Nitsan Bin-Nun wrote:
I'm using FireBug 24/7/365 and I also knew FirePHP before but I never 
tried it or had any experience with it that I can share.
There are any other options and functions that FirePHP gives which not 
require you to involve changing your code?


Nitsan

On Sun, Jan 11, 2009 at 6:46 PM, Skip Evans > wrote:


Hey all,

I'm sure many of you use Firebug in Firefox for help debugging, and
some of you also no doubt know about FirePHP, the PHP class that
let's you write logs to the Firebug console.

In case you don't know about it, Joe Bob Briggs says, "Check it out."

I just installed and it's pretty cool.

http://www.firephp.org/

Very easy install and set up: you basically include on PHP file and
you're off to the races. I wrote a quick wrapper function that takes
a string and outputs it to the Firebug console and am finding it
pretty helpful.

I think it's especially useful if you write a lot of AJAX calls that
don't allow easy output of debug statements.

Would like to hear other opinions of this little tool.
-- 


Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison, Wisconsin 53703
608-250-2720
http://bigskypenguin.com

"Those of you who believe in telekinetics, raise my hand."

-- Kurt Vonnegut

-- 
PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php




--
==
Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison, Wisconsin 53703
608-250-2720
http://bigskypenguin.com

"Those of you who believe in telekinetics, raise my hand."
-- Kurt Vonnegut

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



Re: [PHP] is_readable(http://.... text file) says not, but I canin browser

2009-01-11 Thread John Allsopp

Nathan Rixham wrote:

John Allsopp wrote:

Nathan Nobbe wrote:
On Sun, Dec 28, 2008 at 11:02 AM, John Allsopp 
wrote:


 

Hi

I'm sure this is simple for yous all but I'm not sure I know the 
answer.


  $myFileLast = "http://www.myDomain.com/text.txt";;
  if (is_readable($myFileLast))
  {
  $fh = fopen($myFileLast, 'r');
  $theDataLast = fread($fh, 200);
  fclose($fh);
  echo ("The dataLast: ".$theDataLast."\n");
  } else
  {
  echo ("Last fix file unavailable: $myFileLast\n");
  }

returns Last fix file unavailable even for a file that my browser 
can read.

All I want to do is skip over files

This could be a very simple error, I'd appreciate a pointer. Is it
permissions being different for PHP versus the browser or 
something? PHP is

running on a different server.




are you basically trying to tell if theres a resource @ the given 
url?  if

so, id prefer curl myself.

something like

if(($ch = curl_init($url) === false)
  echo ("Last fix file unavailable: $myFileLast\n");
else {
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);*
*  $theDataLast = curl_exec($ch);
  echo ("The dataLast: ".$theDataLast."\n");*
*  curl_close($ch);*
*}

obviously, youll need the curl extension installed for this to 
work.  i know
the fopen wrappers will allow you to get a read-only handle to an 
http url,
but im not sure what is_readable() will do w/ that, it may be 
limited to the

local filesystem.

-nathan

  
Thanks. I'm trying to read the contents of the file at the URL, but 
it might not exist.


So far I'm getting a lot of *Warning*: curl_setopt(): supplied 
argument is not a valid cURL handle resource in 
*/home/myAcc/public_html/test.php* on line *58

*
I searched phpinfo for 'curl' and it came up nothing, so I'm just 
checking with my hosts to see if I have the extension installed.


I'll be back, thanks
J


might be a bracket thing..

could try:
if( ($ch = curl_init($url)) === false) {
  echo ("Last fix file unavailable: $myFileLast\n");
} else {


or
if( !is_resource($ch = curl_init($url)) ) {
  echo ("Last fix file unavailable: $myFileLast\n");
} else {





Ah, perfect, it was a bracket thing.

Thanks muchly

J

--
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-11 Thread Robert Cummings
On Sun, 2009-01-11 at 18:14 +, Nathan Rixham wrote:
> Robert Cummings wrote:
> >   
> >> the above means that moving back to the original  example(s) I'd simply
> >>
> >> whatever
> >> 
> >
> > I'd probably do:
> >
> > Whatever
> >
> > Which would expand to:
> >
> > Whatever > name="contentTitle"/> > dyanmic="true"/>
> >
> > Which would expand to a bunch of intermixed HTML/PHP code directly in
> > the requested document.
> >
> > The reason for the accumulator flush is to add content to the title in
> > an unrelated area of the templates as is occasionally necessary. The
> > first inserts accumulated content during the build process, the second
> > allows insertion at run-time. Run-time is probably used more often since
> > it may be when editing a user profile or something and the name is
> > inserted into the title from the form controller. The compile time
> > version is used less often but has no run-time hit since it's pre-built.
> >   
> I do like you're interjinn.. it's like a good coldfusion (no offense 
> intented)

I've got to go do some crying... actually I've never used coldfusion, I
just wanted something that allowed embodying larger content
functionality in shorter syntax.

> >   
> >> css:
> >> h1 {
> >>color: rgb(255,0,0);
> >>font-size: 1.2em;
> >> }
> >>
> >> seeing as you can only have one h1 tag on a single document.
> >> 
> >
> > Says who?
> >   
> 
> well it's logical good practise I guess - not a hard and fast rule 
> (although should probably be thought of as a rule..?)
> H* tags are used to describe the semantic structure of a document, the 
> H1 tag being used to describe what the entire document / page is about, 
> then h2-h6 being used to split it into sub sections / sub headings. Thus 
> two H1 tags indicates that the document is two different documents. The 
> W3C site itself is normally a good indication for things like this, I'm 
> 100% sure if you check the source for every page you'll not find a 
> single case where there are two H1 tags.
> 
> example:
> http://www.w3.org/TR/xhtml1/
> 
> from the source:
> 
>  XHTML™ 1.0 The Extensible HyperText 
> Markup Language (Second Edition)
> 
> because the document is the "XHTML™ 1.0 The Extensible HyperText Markup 
> Language (Second Edition) "; if there was a Third Edition it'd be in a 
> different document

That link you provided just above... open it up in the source viewer...
now do a search for "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] Couple of beginner questions

2009-01-11 Thread Nathan Rixham

Robert Cummings wrote:

On Sun, 2009-01-11 at 18:14 +, Nathan Rixham wrote:

Robert Cummings wrote:
  

the above means that moving back to the original  example(s) I'd simply

whatever


I'd probably do:

Whatever

Which would expand to:

Whatever

Which would expand to a bunch of intermixed HTML/PHP code directly in
the requested document.

The reason for the accumulator flush is to add content to the title in
an unrelated area of the templates as is occasionally necessary. The
first inserts accumulated content during the build process, the second
allows insertion at run-time. Run-time is probably used more often since
it may be when editing a user profile or something and the name is
inserted into the title from the form controller. The compile time
version is used less often but has no run-time hit since it's pre-built.
  
I do like you're interjinn.. it's like a good coldfusion (no offense 
intented)


I've got to go do some crying... actually I've never used coldfusion, I
just wanted something that allowed embodying larger content
functionality in shorter syntax.



like flex as well

  

css:
h1 {
   color: rgb(255,0,0);
   font-size: 1.2em;
}

seeing as you can only have one h1 tag on a single document.


Says who?
  
well it's logical good practise I guess - not a hard and fast rule 
(although should probably be thought of as a rule..?)
H* tags are used to describe the semantic structure of a document, the 
H1 tag being used to describe what the entire document / page is about, 
then h2-h6 being used to split it into sub sections / sub headings. Thus 
two H1 tags indicates that the document is two different documents. The 
W3C site itself is normally a good indication for things like this, I'm 
100% sure if you check the source for every page you'll not find a 
single case where there are two H1 tags.


example:
http://www.w3.org/TR/xhtml1/

from the source:

 XHTML™ 1.0 The Extensible HyperText Markup 
Language (Second Edition)

because the document is the "XHTML™ 1.0 The Extensible HyperText Markup 
Language (Second Edition) "; if there was a Third Edition it'd be in a 
different document


That link you provided just above... open it up in the source viewer...
now do a search for "

lmfao - cheers rob; completely and utterly take that one back - and 
actually after running that url through the semantic extractor 
(http://www.w3.org/2003/12/semantic-extractor.html) I can see how much 
sense it makes to have multiple h1's


I think my confusions came from too long working with internet marketers 
and thinking the web should be designed for googlebot.


cheers rob!

--
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-11 Thread Robert Cummings
On Sun, 2009-01-11 at 21:01 +, Nathan Rixham wrote:
> Robert Cummings wrote:
> >
> >> example:
> >> http://www.w3.org/TR/xhtml1/
> >>
> >> from the source:
> >>
> >>  XHTML™ 1.0 The Extensible
> HyperText Markup Language (Second Edition)
> >>
> >> because the document is the "XHTML™ 1.0 The Extensible HyperText
> Markup 
> >> Language (Second Edition) "; if there was a Third Edition it'd be
> in a 
> >> different document
> > 
> > That link you provided just above... open it up in the source
> viewer...
> > now do a search for " a
> > level of heading... h1 being the most important on down to h6.
> > 
> > Cheers,
> > Rob.
> 
> lmfao - cheers rob; completely and utterly take that one back - and 
> actually after running that url through the semantic extractor 
> (http://www.w3.org/2003/12/semantic-extractor.html) I can see how much
> sense it makes to have multiple h1's
> 
> I think my confusions came from too long working with internet
> marketers and thinking the web should be designed for googlebot.

I think with Googlebot the first  encountered in your document gets
the highest priority with respect to the page's content... expecially if
it matches with the page title and incoming link labels to the document.

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: redoing website after 7 years

2009-01-11 Thread Chris

Robert Cummings wrote:

On Fri, 2009-01-09 at 08:56 -0500, Andrew Ballard wrote:

On Fri, Jan 9, 2009 at 2:09 AM, Robert Cummings  wrote:

On Fri, 2009-01-09 at 15:17 +1100, Chris wrote:

I know many people will grin at me for this solution but may be faster way
to overcome this problem to do a find for $ and replace with $_REQUEST. even
this will help you if you dealt with $_POST, $_GET, $_COOKIE.

Please don't.

$connection = mysql_connect(...)

becomes

$_REQUEST[$connection] (or something)

How did you get those braces when you did search and replace?

;)

Cheers,
Rob.

Doesn't your search and replace tool support regular expression
matching and replacement?


Well yes, but the instrutions didn't indicate using a regex ;)


I'd like to see you try it without a regex.. ;) I guess you could do it 
but php isn't going to parse it (or everything is going to be set to 
$_REQUEST)..


--
Postgresql & php tutorials
http://www.designmagick.com/


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



Re: [PHP] Re: redoing website after 7 years

2009-01-11 Thread Robert Cummings
On Mon, 2009-01-12 at 09:00 +1100, Chris wrote:
> Robert Cummings wrote:
> > On Fri, 2009-01-09 at 08:56 -0500, Andrew Ballard wrote:
> >> On Fri, Jan 9, 2009 at 2:09 AM, Robert Cummings  
> >> wrote:
> >>> On Fri, 2009-01-09 at 15:17 +1100, Chris wrote:
> > I know many people will grin at me for this solution but may be faster 
> > way
> > to overcome this problem to do a find for $ and replace with $_REQUEST. 
> > even
> > this will help you if you dealt with $_POST, $_GET, $_COOKIE.
>  Please don't.
> 
>  $connection = mysql_connect(...)
> 
>  becomes
> 
>  $_REQUEST[$connection] (or something)
> >>> How did you get those braces when you did search and replace?
> >>>
> >>> ;)
> >>>
> >>> Cheers,
> >>> Rob.
> >> Doesn't your search and replace tool support regular expression
> >> matching and replacement?
> > 
> > Well yes, but the instrutions didn't indicate using a regex ;)
> 
> I'd like to see you try it without a regex.. ;) I guess you could do it 
> but php isn't going to parse it (or everything is going to be set to 
> $_REQUEST)..

The point of my original comment was that you didn't follow the
instructions ;)

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: redoing website after 7 years

2009-01-11 Thread Chris

Robert Cummings wrote:

On Mon, 2009-01-12 at 09:00 +1100, Chris wrote:

Robert Cummings wrote:

On Fri, 2009-01-09 at 08:56 -0500, Andrew Ballard wrote:

On Fri, Jan 9, 2009 at 2:09 AM, Robert Cummings  wrote:

On Fri, 2009-01-09 at 15:17 +1100, Chris wrote:

I know many people will grin at me for this solution but may be faster way
to overcome this problem to do a find for $ and replace with $_REQUEST. even
this will help you if you dealt with $_POST, $_GET, $_COOKIE.

Please don't.

$connection = mysql_connect(...)

becomes

$_REQUEST[$connection] (or something)

How did you get those braces when you did search and replace?

;)

Cheers,
Rob.

Doesn't your search and replace tool support regular expression
matching and replacement?

Well yes, but the instrutions didn't indicate using a regex ;)
I'd like to see you try it without a regex.. ;) I guess you could do it 
but php isn't going to parse it (or everything is going to be set to 
$_REQUEST)..


The point of my original comment was that you didn't follow the
instructions ;)


You're right.. I guess I was thinking too much - it happens sometimes.

--
Postgresql & php tutorials
http://www.designmagick.com/


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



Re: [PHP] pecl4win - any updates?

2009-01-11 Thread Chris

pan wrote:

Has there been any progress reinstating pecl packages for
windows?


per the comment on php.net, join the "Windows Internals list" (or 
perhaps the "Windows PHP users list" might have some info).


--
Postgresql & php tutorials
http://www.designmagick.com/


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



Re: [PHP] pecl4win - any updates?

2009-01-11 Thread pan

"Chris"  wrote in message news:496a6f34.1080...@gmail.com...
> pan wrote:
>> Has there been any progress reinstating pecl packages for
>> windows?
>
> per the comment on php.net, join the "Windows Internals list" (or perhaps the 
> "Windows PHP users list" might have some info).
>

Thanks for the response.

I already read all the php lists and check the web sites often.
That's why I threw out a general question to elicit information.




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



[PHP] Re: FirePHP -- pretty cool

2009-01-11 Thread Colin Guthrie

'Twas brillig, and Skip Evans at 11/01/09 19:19 did gyre and gimble:

Hey Nitsan & all,

I haven't been through it all, I just installed the plug in and download 
the file to include and started using it.


I would imagine you have to use their log function to get any output, 
but it seems like the kind of thing that could be left in the code 
without any ill-affect.


I wrote a wrapper in my global functions file, and I suppose if I wanted 
to turn it off I'd just have that function return at the top.


So far I'm finding it useful and easy enough to use.

If you don't want to change your code I would imagine something like 
xdebug would be the next step.


If you use the Zend Framework it has a log target to this already. For 
production releases you would use a dummy logger. This still has code 
overhead but it's one of those load vs. benefits tradeoffs.


If you really want it to be efficient, you can format your code in such 
a way that a script would process your files and comment out all the log 
calls. Depends whether it's worth the effort to do this really!


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

2009-01-11 Thread Murray
Hi Paul,

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

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

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

Thanks for your reply all the same!

M is for Murray


On Sun, Jan 11, 2009 at 4:39 PM, Paul M Foster wrote:

> 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] String variable

2009-01-11 Thread Lars Torben Wilson
2009/1/11 Ashley Sheridan :
> On Sun, 2009-01-11 at 14:36 +, Ashley Sheridan wrote:
>> On Sun, 2009-01-11 at 08:59 -0500, MikeP wrote:
>> > Hello,
>> > I am trying yo get THIS:
>> > where ref_id = '1234'
>> > from this.
>> > $where="where ref_id="."'$Reference[$x][ref_id]'";
>> >
>> > but i certainly have a quote problem.
>> >
>> > Any help?
>> > Thanks
>> > Mike
>> >
>> >
>> >
>> >
>>
>> It should look like this:
>>
>> $where="where ref_id="'{$Reference[$x][ref_id]}'";
>>
>>
>> Ash
>> www.ashleysheridan.co.uk
>>
>>
> Sorry, it should look like this:
>
> $where="where ref_id='{$Reference[$x][ref_id]}'";
>
> I missed taking an extra quote mark out

Closer, but still not quite there. For encapsulation in the string, it
should look like:

$where = "where ref_is='{$Reference[$x]['ref_id']}'";

Someone else mentioned casting to int first as well to sanitize, which
is also a good idea.


Torben

> Ash
> www.ashleysheridan.co.uk




-- 
Torben Wilson 

-- 
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-11 Thread Chris

tedd wrote:

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.


When you do, you'll know why we suggest it ;) It takes ages to find 
something like this - especially in a largish site or a large app with 
lots of php files.. any of the files included in a request can cause it.


--
Postgresql & php tutorials
http://www.designmagick.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-11 Thread John Corry
One of the best things that ever happened to me (with regards to
writing PHP) was deciding not to embed it in HTML anymore.

I either:
a) generate the HTML from classes I've built (HTML, Forms, Tables,
Images, etc) or use an equivalent PEAR class

- or -

b) Use Smarty templates...in which I still generate the HTML that will
go to the template (where required) with the HTML generation classes.

The advantages are abundant.

I can't imagine having to maintain some of the code I saw in the
examples above. My favorite WTF was with this snippet:

$imgHTML = '';

Holy crap...REALLY!?

All that string concatenation and there's not even width/height
attributes in there!

That would look like:

$i = new Image('path/to/image/file');
$i->__set(array('class'=>$imgClass, 'alt' => $altText));
$i->toHtml();

Being able to change every image tag in a site by editing the
class/method that created is just too big an advantage not to use. Not
to mention the auto-generated width/height attributes, the ability to
auto-produce thumbnails and fullsize images from a single file...

After struggling through the beginnings, I wrote classes to generate
basic HTML elements, then tables, then forms, then images.

It saved me a bunch of time and taught me to see the website as an
application...not as a web-page with pieces of data in it.

Somehow, coming to that bit of knowledge was very helpful to my life
as a programmer.

Good luck,

John Corry

-- 
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-11 Thread Paul M Foster
On Mon, Jan 12, 2009 at 12:04:15AM -0500, John Corry wrote:

> One of the best things that ever happened to me (with regards to
> writing PHP) was deciding not to embed it in HTML anymore.
> 
> I either:
> a) generate the HTML from classes I've built (HTML, Forms, Tables,
> Images, etc) or use an equivalent PEAR class
> 
> - or -
> 
> b) Use Smarty templates...in which I still generate the HTML that will
> go to the template (where required) with the HTML generation classes.
> 
> The advantages are abundant.
> 
> I can't imagine having to maintain some of the code I saw in the
> examples above. My favorite WTF was with this snippet:
> 
> $imgHTML = '';
> 
> Holy crap...REALLY!?
> 
> All that string concatenation and there's not even width/height
> attributes in there!
> 
> That would look like:
> 
> $i = new Image('path/to/image/file');
> $i->__set(array('class'=>$imgClass, 'alt' => $altText));
> $i->toHtml();
> 
> Being able to change every image tag in a site by editing the
> class/method that created is just too big an advantage not to use. Not
> to mention the auto-generated width/height attributes, the ability to
> auto-produce thumbnails and fullsize images from a single file...
> 
> After struggling through the beginnings, I wrote classes to generate
> basic HTML elements, then tables, then forms, then images.
> 
> It saved me a bunch of time and taught me to see the website as an
> application...not as a web-page with pieces of data in it.
> 
> Somehow, coming to that bit of knowledge was very helpful to my life
> as a programmer.

I've written a lot of code like the original example above, and still
do, but I see your point, since I've written code like yours too. I
write all my PHP code (and I write a *lot* of it) solo, with no help and
no collaborators. But as I understand it from a lot of framework types,
the ideal is to set up the HTML so that a HTML coder can understand
what's going on, without having a lot of PHP weirdness in it. Meaning,
if you're going to infuse your HTML with PHP, you should do it in a
minimalistic way. It'd be a helluva lot easier on me to do it all
through PHP classes, though.

I also come from a C background, and I recognize significant differences
between the paradigm for C programs and HTTP-based coding. Considering
that every PHP "program" paints generally a single page, I'm not a fan
of loading up 14 support files every time I load a page of HTML. That's
why I don't use one of the MVC frameworks available in the FOSS world.
CodeIgniter, which is one of the lightest weight frameworks, opens
something like 17 files before it paints a single byte in the browser.
The upshot is that I don't like to use a lot of libraries scattered in a
variety of files to render HTML/PHP pages.

But here's a question for those of you who work in a collaborative
environment-- are you really ever in a situation where some HTML weenie
is coding HTML pages and you're somewhere else doing the PHP work? Or is
that some academic's view of the way things *should* be done?

Paul
-- 
Paul M. Foster

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