Re[2]: [PHP] Cookies

2005-11-17 Thread Richard Davey
Hi Ben,

Thursday, November 17, 2005, 4:24:11 PM, you wrote:

> In order to set one and then check if it exists or not, I have to
> set it on one page, and then test it on the next page load - In this
> case, I don't figure out how I need to send information from page to
> page until they have already gone to another page, at which point,
> the test is no longer needed.

You don't have to set / test one on a *PAGE* at all, just from a PHP
script (these are not always the same thing).

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re[2]: [PHP] Cookies

2005-11-17 Thread Richard Davey
Hi Dan,

Thursday, November 17, 2005, 3:56:43 PM, you wrote:

> You can check on every page load, but I'm sure thats over kill for
> most public facing sites to catch some Yahoos who have too much time
> on their hands.

Is that a new technical term for 'hacker' ? :)

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re[2]: [PHP] Cookies

2005-11-17 Thread Richard Davey
Hi Robert,

Thursday, November 17, 2005, 3:39:43 PM, you wrote:

> *lol* I do that sometimes... with Javascript too.

:) it's amazing what you can break by doing that!

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re: [PHP] Cookies

2005-11-17 Thread Richard Davey
Hi Ben,

Thursday, November 17, 2005, 3:26:04 PM, you wrote:

> Is there a way to test if a user has cookies turned on or not so
> that I can use cookies if the user allows them and use the URL if
> the user does not allow them?

Set one? :)

Then check if it exists or not.

This of course will not catch those sneaky buggers who disable cookies
part way through your site just to see what effect it will have.

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re: [PHP] Error Messages, Windows, and Tequila

2005-11-16 Thread Richard Davey
Hi Jay,

Wednesday, November 16, 2005, 4:36:25 PM, you wrote:

> Does anyone know (I have error reporting set so high it would make
> your head swim) why errors wouldn't be output to a browser window
> when they occur? For instance, I typed the following;

Are you 100% Tequila-worm sure you've got all the relevant ini flags
set? (display errors, E_ALL, yadda yadda) and that PHP on your lovely
Windows box is actually *using* that ini file and not the mystic
built-in one?

Tis the only reason I can think of that would halt it dead, because as
shocking as this may sound - PHP on Windows *can* actually display
errors ;)

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re: [PHP] better way to mix html and php code?

2005-11-16 Thread Richard Davey
Hi afan,

Wednesday, November 16, 2005, 4:12:53 PM, you wrote:

> always wondered what's better way to mix html and php code. Here are
> three "ways" of the same code. Which one you prefer? (And why, of
> caurse :))

Honestly, I wouldn't pick any of them :)

But if I had to (i.e. forced at gun-point or something) it'd have to
be #2, because it's at least mixing HTML and PHP in a way that doesn't
create massive strings, for no actual reason other than it is the
easiest format to go in and change the HTML without causing a
potential syntax error.

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re[4]: [PHP] Is echo tag reasonably portable?

2005-11-15 Thread Richard Davey
Hi Jim,

Tuesday, November 15, 2005, 8:01:01 PM, you wrote:

> Still best practice is to use long tags. Suppose you write a
> closed-app for a client who makes a business decision to move it to
> a hosted server that does not allow short tags... The down side is,
> the app will break. The up side is, the client will probably call
> you to fix it, and pay you your standard rate to do so, unless he is
> bright enough to realize it was YOUR fault it broke.

To be honest, if a client upped and move an application I'd built to
an entirely different host, without consulting me prior to the move,
I'd place the blame ball firmly in their court.

I've never signed a contract yet that said "this code will work
anywhere you dump it", and I never will.

However, I understand what you're saying, and I agree with it
completely. I use long tags for all full app developments, and
short-tags for all prototypes.

My only point is that when two options are identical in nature, there
is no "best preference", only that which is the best for you, and your
immediate needs.

If your host doesn't support them, that's a pretty immediate need. If
your client likes to up and move stuff around without telling you,
that's quite a need too. If you had the luxury of building the entire
site from scratch, then it's your issue. However if your client wants
maintenance on a 3 year old app, spread across hundreds of files, with
thousands of lines of inter-mingled short-tagged code -- well, that's
a slightly different concern, and "best practises" don't always apply.

It ain't never black or white!

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re[4]: [PHP] Is echo tag reasonably portable?

2005-11-15 Thread Richard Davey
Hi Robin,

Tuesday, November 15, 2005, 7:53:55 PM, you wrote:

> I did quote the note concerning them in its entirety. If I had
> simply quoted the manual as saying "be sure not to use short tags"
> then I could see your point regarding lack of context. But I didn't.

Not in the message I was replying to, hence my comments. Although
having re-scanned the thread, it was quoted further back by someone
else. Personally I find there is a vast difference in meaning between
"don't use short-tags" and "don't use short-tags for distributed
applications".

> Firstly, I didn't actually suggest they were disabled. I suggested
> that they should be off by default. If they're needed then it's
> simple to turn them on, but it would discourage new developers from
> using a construct which is not compatible with xml and xhtml.

Agreed. Although, if they needed that construct, don't you think
they'd realise the implications rather quickly? (most likely at the
point at which everything goes tits up?! ;)

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re[2]: [PHP] Is echo tag reasonably portable?

2005-11-15 Thread Richard Davey
Hi Robin,

Tuesday, November 15, 2005, 6:18:06 PM, you wrote:

> Short tags have been deprecated for years. Both the manual and the
> php.ini file itself advise people not to use them. Personally I
> think it's about time they were turned off by default, but that's
> bound to annoy a lot of people who've ignored the warnings.

1) They are not deprecated.

2) The manual does not advise people not to use them per se. You're
missing out the entire context in which it advises against them.

3) The php.ini file does not advise people not to use them per se. You're
missing out the entire context in which it advises against them.

I doubt very much if they will be disabled. They are perfectly valid
SGML processing instructions.

I agree they are a legacy of the PHP3 era, and for re-distributable
apps you should avoid them. But that is all. Your statements are, in
their brevity, incorrect.

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re[2]: [PHP] Is echo tag reasonably portable?

2005-11-15 Thread Richard Davey
Hi Jim,

Tuesday, November 15, 2005, 5:25:58 PM, you wrote:

> I don't know, but those who do should not use short tags. And those
> who hope to should not get into the habit of using short tags.

And for the vast majority remaining, who write closed-apps for
clients??

> It will be when you have to sort through 1,000,000 lines of code in
> 400 files to change ' it right to start with, no?

There is no "right" or "wrong" for this, it's down to personal
developer preference. Nothing more, nothing less. It's only "right" if
you're building an app for distribution to unknown end-users. I don't
think that covers the majority of work we all do here somehow.

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re[2]: [PHP] Is echo tag reasonably portable?

2005-11-15 Thread Richard Davey
Hi Jochem,

Tuesday, November 15, 2005, 4:34:28 PM, you wrote:

> so how many people actually _need_ to write portable code? ok so
> many you are starting a project which will become a runaway success
> but until it starts receiving alot of attention use of
> short-open-tags is probably not your biggest issue either.

heh :) I have to admit I was thinking the same thing. I use short-tags
and always enable them, I specifically like the http://www.corephp.co.uk

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



Re: [PHP] PHP Framework

2005-11-15 Thread Richard Davey
Hi Yonatan,

Tuesday, November 15, 2005, 2:54:27 PM, you wrote:

> I want to start using a framework to my future sites and I saw that
> there are quite alot of options out there at the net, if anyone got
> any experience with frameworks I would really like to receive some
> suggestions, recommenditions and even ideas.

> The framework need to achieve the following goals (Doesn't have to
> be all of them):

I'll add a criteria to your list (which nearly all the frameworks out
there lack) - *DOCUMENTATION*

There are so many recent PHP apps out there in the wild (not just
frameworks) that have virtually no real, solid, *useful* documentation
for them. The vast majority of PEAR components suffer from this, lots
of the frameworks have virtually no good documentation at all, some of
the blog apps, the wiki apps, etc etc etc. Stick your finger anywhere
in the PHP pie and you'll hit a cherry, but more often than not have
no help at all on how to consume it, without ripping the thing apart.

I'm sure this isn't unique to PHP, but it gets my goat :) We've got
security consortiums, framework groups, component repositories, class
files a go-go - maybe it was time someone started a PHP Documentation
Group!

Err, apologies for diversifying from your original thread a bit.

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re: [PHP] file get contents

2005-11-14 Thread Richard Davey
Hi Ross,

Monday, November 14, 2005, 9:44:45 AM, you wrote:

> $lines = file_get_contents('../shared/acessibility_box.htm');

> In this file I have the a self submitting link
> A

> The problem I think is this code is inserted after the page headers have
> been set. And so the line just generates an error.

file_get_contents does exactly that - it gets the contents of the file
*without* parsing it, i.e. any raw PHP code that exists within it,
will be treated as what it is when 'got' = plain text.

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re: [PHP] post and variables

2005-11-10 Thread Richard Davey
Hi Ross,

Thursday, November 10, 2005, 10:39:48 AM, you wrote:

> How do I use $_POST with variables. Cant find an example of this
> anywhere on php.net

> if ($_POST['$table_name== 1']) {

if ($_POST['form_element_name'] == 'whatever')

There are many examples of this all over the web. You need to look
harder. Try Google for "beginners guide to PHP".

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re: [PHP] Unable to send variables to MySQL table

2005-11-09 Thread Richard Davey
Hi Stewart,

Wednesday, November 9, 2005, 7:15:39 PM, you wrote:

> The script executes with no errors, but when I check the table, the
> table is still empty. I can manually insert the data directly into
> the table, and when I echo the variables in the script, the values
> are displayed whe I run it, but for reasons unknown, the values are not 
> written to the table.

> $add_to_db = "insert into invoices (item1_desc, item1_cost,
> item2_desc, item2_cost, item3_desc, item3_cost, item4_desc,
> item4_cost, delivery_cost) values ('$item1_desc', '$item1_cost',
> '$item2_desc', '$item2_cost', '$item3_desc', '$item3_cost',
> '$item4_desc', '$item4_cost', '$delivery_cost')";
> mysql_query($add_to_db);

?>>

On the surface it looks fine, so I would echo out your query and then
paste it into MySQL (phpmyamin, SQLyog, etc) and check it works!

Or you could capture the result of the query and check for an error.

If there isn't one, it's probably a table design issue.

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re[2]: [PHP] No forums?

2005-11-08 Thread Richard Davey
Hi Murray,

Wednesday, November 9, 2005, 1:34:12 AM, you wrote:

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

> Any thoughts on a comparison between the 2?

IMHO there is no comparison. I think the only reason someone would
prefer phpbb is if they were crap at design, and wanted to use one of
the many phpbb templates that exist out there.

All logical, security and features reasons point to FUD. But it has to
be said, it just doesn't "look as nice", and sadly that is a good
enough factor to deter lots of people :-\

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re[2]: [PHP] No forums?

2005-11-08 Thread Richard Davey
Hi Richard,

Wednesday, November 9, 2005, 12:40:12 AM, you wrote:

> There are no decent PHP forum software packages that aren't riddled
> with security problems and really nasty PHP code. I sincerely wish
> the preceding statement were false, as my clients ask me for forums
> and I just say "No."

I agree 99% with you, the majority are (excuse my French) utter shite.
*but* the code quality, features and stability of the excellent FUD
Forum thankfully doesn't fall into the camp you describe. While I
don't use it myself, you only need to take a quick look at the code
and who's involved with it to recognise its quality.

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re: [PHP] Query regarding total count of pages in a site....

2005-11-08 Thread Richard Davey
Hi Suresh,

Tuesday, November 8, 2005, 1:28:47 PM, you wrote:

> I need to find the number of webpages in a site.. is there any
> inbuilt variables in php to find it.

I need to find the number of socks in my washing basket. Does PHP have
an inbuilt function to do it?

No, of course it doesn't. Just because PHP can be used to script apps
for web sites, it doesn't mean it has any actual concept of what a web
page is, any more than it knows what a sock is.

This is something you'll have to code yourself. Or use a CMS style
system that offers the functionality built in.

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re: [PHP] Security Issues - Where to look?

2005-11-07 Thread Richard Davey
Hi Richard,

Monday, November 7, 2005, 9:50:59 PM, you wrote:

> I've heard that php is not particularly secure, making it
> problematic if you intend to create a web site with commerce, etc.
> Is there a particular news group that addresses security issues? I'm
> looking for some guidlines on ensuring that my site is secure from
> malicious hackers.

The security of the application will be ultimately down to two
factors: you, and your hosting environment.

Server security is beyond the scope of this mailing list, and is a
multi-faceted and complex area. Shoring up your OS, Apache and the
likes can take years of skill. Or of course, your sys admin / web host
does this all for you. Even so, it's an area not to be ignored. You
can write the most secure application in the world, but if you've gone
and chmod 777'd your directories on a shared box, you're anyones
target.

The security of your application is down to you however. There is a
PHP security mailing list, but it's more for announcements than
discussion. As for guidelines there are many free on-line resources,
and you'd do worse than to start here: http://phpsec.org/library/

The majority of those documents are aimed at experienced PHP
developers however. And the majority of blatant security holes come
from the inexperienced who weren't aware of what they were doing wrong
in the first place. There are several books available on the subject
now, any (or all) of them would give you the grounding you need to
know BEFORE you start coding:

Pro PHP Security by Snyder & Southwell (Apress)
php architect's Guide to PHP Security by Ilia Alshanetsky (Nanobooks)
Essential PHP Security by Chris Shiflett (O'Reilly)

Also some on-line talks: http://brainbulb.com/talks

php architect magazine has a security column each month as well
(www.phparch.com)

There's a lot of reading material out there. Just make sure you read
it _before_ you start building, it'll save you days, if not weeks, of
code changes.

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re[2]: [PHP] No forums?

2005-11-05 Thread Richard Davey
Hi,

Saturday, November 5, 2005, 11:30:29 PM, you wrote:

 >> Start now and we'll check in on your progress in a years time :)

> You're joking, but I might actually do it. I was thinking about such
> forum before. It could be useful for many purposes.

It would be *extremely* useful, but I imagine quite a nightmare to
code properly, or someone would have done so already.

Even so - somebody has to be first, no reason why it can't be you. I
think a years estimate was a conservative one given the scale of the
project, but possible.

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re: [PHP] No forums?

2005-11-05 Thread Richard Davey
Hi,

Saturday, November 5, 2005, 3:09:01 AM, you wrote:

> AFAIK, there are no "official" forums for PHP. Considering the fact
> that PHP is a web development tool, such distaste for message boards
> is ironic at the least. So why exactly there aren't any forums on
> php.net?

How about some good logistical reasons? php.net does not exist in any
one location. It does not serve any one language. There are over 100
mirror sites across the entire world handling php.net, from Thailand
to South Africa.

The site is offered in 30+ different languages, English, Chinese,
Swedish, Japanese, etc.

To be true to the php project, if it were to start a forum it would
have to be mirrored across all of these servers, unless you're
advocating country elitism for this forum? (and no, it is not fair to
force users in say Africa to have to connect to a US server).

There is NO off the shelf forum software that can cope with a
distributed forum in this manner, with content and user repositories
spread across so many diverse networks. When you post a message on a
US server, how long before it should appear on the Slovenia mirror? If
it's not instant, it is less useful than the mailing list. So unless
this forum syncs across the 100+ mirrors on an application level,
you're left with a hardware level link-up (duplication of the database
perhaps, whatever). Eitherway it's quite some work, not to mention
expense, especially to keep it real-time.

The reason the mailing list *works* is that the content is delivered
to the people, the people don't have to seek it out. For those in
relatively low-bandwidth countries they get to choose which messages
they want prior to actually downloading them (most mailing packages
offer a read-headers option).

So if you want a "hosted in one country / location" PHP forum there
are plenty out there already, I can think of 4 in my bookmarks alone.
I can't think of any that will give you replies from some of the most
talented php developers in the world though.

If you want one that truly offers what the mailing list provides
already - you're going to have to write it, because it doesn't exist.
Start now and we'll check in on your progress in a years time :)

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re: [PHP] Pictureupload

2005-11-03 Thread Richard Davey
Hi twistednetadmin,

Thursday, November 3, 2005, 4:50:33 PM, you wrote:

> I have made this script to upload pictures into a picturegallery on a
> website.
> The script works just as I expected, but with one huge flaw. It doesn't work
> from every users computer.
> I can upload pictures with no problem, but another user get's an
> errormessage. the other user emailed the picture to me and I could upload it
> with no errors.

> Here's the script.

> 





> 
> 
>  class="holyheader18">Screenshot upload
> 
> 
> 
> 
> 
> Only pictures with the .jpg extension and size 300kb or less will be
> uploaded!
> Imagenames should not contain quotes or any special signs!!

> 
> 
> 
> 
> 
> 
> 
> File: 

> 
> 


> 
> 
> 
> 

> Comment:
> 

> 
> 
> 
> 
> 
> 
> 

> 


>  chmod("/guildimages/", 0777);
> ##
> ###Uploads the image and checks if the image exists already###
> ##

> if (isset($_POST['submit'])) //If you push the submit-button
> {

>  $sysfolder="/guildimages/";
> $filename="".$_FILES['guildimage']['name']."";

> if (file_exists($sysfolder . $filename)) //If the filename exists.
> {

>  echo "Filename exists or no file selected. Please rename the file or select
> a file";

> }

>  elseif ($_FILES['guildimage']['type'] == "image/jpeg") //And if the image
> is .jpg less or equal 300kb...
> {






> copy ($_FILES['guildimage']['tmp_name'],
> "/guildimages/".$_FILES['guildimage']['name']) //Copy the image to
> /guildimages
>  or die("Could not copy file"); //Or don't if it's wrong size or format



>  $insertSQL = sprintf("INSERT INTO guildimages (guildimage_date,
> guildimage_name, guildimage_comment, posted_by) VALUES (NOW(), '%s', '%s',
> '%s')",
>  ($_FILES['guildimage']['name']),
>  ($_POST['guildimage_comment']),
>  ($_SESSION['logname']));
>  $guildimage_upload = mysql_query($insertSQL) or die(mysql_error());
> //insert all info to the DB

> echo "Result:\n";
>  echo "Filename: ".$_FILES['guildimage']['name']."\n";
>  echo "Filesize: ".$_FILES['guildimage']['size']." byte\n";
>  echo "Filtype: ".$_FILES['guildimage']['type']."\n";
>  echo "Congrats! It worked!\n";
>  }
>  else
> {

> echo "Result:\n";
> echo "Now that didn't seem to work... \n
> Did you try a wrong format or size? \n
File that failed-->> (".$_FILES['guildimage']['name'].")";

> }
> }

?>>

> 
> 
> 

> 

> Can anyone see what's wrong? Since it works from some computers and not from
> all?

How large was the image? Could it be that the script is timing out
during an upload? I recently had to change the max_input_time value on
one site because the uploads were so large they kept timing the script
out, yet some people (on really fast connections) could upload just
fine.

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



[PHP] Anyone know where 5.1 RC1 has gone?

2005-10-31 Thread Richard Davey
Hi,

  PHP 5.1 RC1 was on the site two days ago, but has since been
  removed. I can see it in Googles cache, and snapshots are in CVS,
  but no Release Candidate. Does this mean an RC2 is imminent? :)

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] php mail function vs smtp server

2005-10-31 Thread Richard Davey
Hi Clive,

Monday, October 31, 2005, 10:10:02 AM, you wrote:

> does anyone know whats better/uses less resource etc:

> If I run a loop to send a 1000 emails, should I use php's mail fucntions
> or send directly to the servers smtp server.

Use PEAR Mail Queue.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] PHP version check

2005-10-27 Thread Richard Davey
Hi Andrew,

Friday, October 28, 2005, 7:41:21 AM, you wrote:

> How can I query for PHP version?

phpversion() !

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] GUID or any other unique IDs

2005-10-25 Thread Richard Davey
Hi Denis,

Tuesday, October 25, 2005, 10:01:48 AM, you wrote:

> I am in a need of GUID generator but it seems that PHP doesn't have
> this as a built-in feature.

uniqid() ?

Bearing in mind of course that no unique ID generator can ever be 100%
unique unless it keeps a record of previously generated IDs. So you
may wish to add this check.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



[PHP] Preference for User Permissions system

2005-10-21 Thread Richard Davey
Hi php-general,

  I'm interested to know what everyones preference is for user
  permissions / roles in php apps? For example do you employ a Unix
  style groups system, is there a ready-rolled class or package you
  use, or have you just built your own and stick with it?

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re[2]: [PHP] Invoking a DLL with PHP

2005-10-17 Thread Richard Davey
Hi Jay,

Monday, October 17, 2005, 4:15:58 PM, you wrote:

> Unfortunately I may not be able to have the DLL re-built with the
> COM interface. It is an older DLL containing engineering functions
> and it is huge. The real dingle here is that I only need to access
> some of the functionality of the DLL. I also do not want to compile
> it into PHP as it (the DLL) is a moving target.

If the resources allow, you could always write a small command-line
driven Windows app that passes arguments through to the DLL functions
and returns the results? Then exec() the app. It's a bit too messy for
my liking, but it's certainly an option.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] Invoking a DLL with PHP

2005-10-17 Thread Richard Davey
Hi Jay,

Monday, October 17, 2005, 3:20:58 PM, you wrote:

> Does anyone have any insight to this type of process? Would I have
> to build a PHP extension and compile the DLL as part of PHP's
> configuration? Ideally the DLL would be a black box that could be
> accessed utilizing functions that I build without a re-compile of
> any type.

Have only done this once, but I didn't compile the DLL into PHP
because that would have meant updating the php build every time a new
DLL was released, and updating the functions / documentation
accordingly.

The DLL was built specifically with a COM interface which I accessed
using the PHP COM functions (as I'm sure you've seen already). The DLL
authors had to rejig their original code a little, but it was a far
less painful process than compiling the DLL into PHP. However for the
next revision we are likely to move the DLL code into the .NET
framework, build a SOAP interface to it (C#) and let PHP talk to it
that way. Although that's more of a political decision than a
technical one, I'm just mentioning it incase the idea is useful for
you.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] Question about including files and server load

2005-10-14 Thread Richard Davey
Hi Jay,

Friday, October 14, 2005, 2:21:57 PM, you wrote:

> I was wondering isn't this putting a bigger load on a server by
> including so many files for each function? Also, I was wondering
> what everyone's opinion was on this approach in terms of
> maintenance. Do you think it's better practice to put all your
> functions in one file or do it in this manner?

How many are there? I don't use functions in that way, but I do a
similar thing for class files (minus that "definedfucntions" part of
course).

You could of course combine them all together, and yes it *would* be
faster for the script to execute as there is far less drive activity
going on. But then it's a trade-off between maintaining that single
massive file, as opposed to updating smaller chunks. If it's a real
issue looking at something like Zend Encoder would help.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] OPTIMIZING - The fastest way to open and show a file

2005-10-14 Thread Richard Davey
Hi Ruben,

Friday, October 14, 2005, 12:29:09 PM, you wrote:

> What can I do to make faster opening files?

> **
> Source code:
>if(file_exists($filename)){
>  $modified_date=filemtime($filename);
>  if(time()<($modified_date+1 * 24 * 60 * 60)){
>  $handle = fopen($filename, "r");
>  $contents = fread($handle, filesize($filename));
>  fclose($handle);
>  echo $contents;
>  }
>   }
> **

You could try using file_get_contents instead of fopen/fread/fclose
and see if that makes any difference.

Also possibly try stat instead of filemtime? It would at least cache
the file stats on the 2nd run through, etc.

At the end of the day though any hard drive operation is going to be
relatively slow. Perhaps there is another way to do what you need that
avoids opening all the files? At the moment you appear to be checking
every files modified time then opening it. Perhaps you could get back
a directory listing instead and parse the modified time from this,
rather than check every single file?

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re[2]: [PHP] Obsession with BC, take 2

2005-10-13 Thread Richard Davey
Hi,

Friday, October 14, 2005, 1:07:04 AM, you wrote:

> Let me get it straight. There are two ways of running PHP four and
> five on one server. First one is by using five's compatibility mode,
> and it breaks some of the old scripts. The second one is by using
> two different apache modules. It *does not break anything*, but it's
> a pain to setup.

There's another way - php4 runs as an Apache module, while php5 runs
as cgi (mapped to .php5, or to .php if you override it via htaccess).

Far less hassle to set-up.  Probably why the largest independent
hosting company in the world* does it this way. If they can manage it
across their thousands of servers, any host can.

* www.pair.com

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] Trouble figuring out a Walk through an Array

2005-10-13 Thread Richard Davey
Hi Phillip,

Thursday, October 13, 2005, 4:56:30 PM, you wrote:

> Having trouble figureing out a certain walk through an array.
> And I am not finding the help I need in the manual or anything.

> I have an associative arr ($arr) With about 20 elements in it.
> Ten of which are required. So I have another associative array called
> $required, with all the elements in the array that are required.

> I have initaited a foreach loop on the $arr splitting things into $key and
> $value.

> Now the part I am having trouble with is this.

> I want to see if $key matches any of the values in $required. If so do
> something in particular. If not then do something else. It does not
> particularly matter which value in the $required it matches, just so long as
> it matches.

While for-eaching through your $arr you could simply do an:

if (in_array($key, $required))

Unless you need something more complex than this?

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] Check if an url is a jpg image

2005-10-12 Thread Richard Davey
Hi Tommy,

Wednesday, October 12, 2005, 10:48:55 AM, you wrote:

> Is it possible to check if an url is a jpg image from php?

#1 Quick and unreliable: Check if there is a .jpg or .jpeg as the final
characters of the URL string.

#2 Bit more complex, very expensive: fopen() the URL, download the
content to a temporary location, inspect it with native php functions
like getimagesize. If your PHP config allows, you can probably perform
a getimagesize directly on the URL, but I've not tried this.

#3 Trickier, less expensive than #2, but balls-on accurate: fopen()
the URL (after suitable validation) and grab the header (the first few
KB). JPEG files are easily identified, but come in a variety of
flavours.

http://www.codeproject.com/bitmap/iptc.asp

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re[2]: [PHP] Obsession with BC

2005-10-11 Thread Richard Davey
Hi,

Tuesday, October 11, 2005, 7:14:05 PM, you wrote:

> Issue: I think BC slows down the evolution of the language. I know
> for sure it makes some people less willing to upgrade. And there are
> ways of avoding unnecessary BC maintenance altogether.

Beyond not staying stuck in the past? Not really. You either code for
PHP4 or you code for 5. If you're really lucky (or just write really
basic scripts) then your code will run on both. If your host doesn't
support 5, they need to wake-up and smell the roses.

Introducing a  tag is the wrong way to address it, never mind
being at the wrong end of the pipeline. If you want to control support
from a code point of view, it's not difficult to detect which version
of PHP your running under. But allowing for that through your entire
codebase is just a tad more work, to say the least.

Backwards compatibility doesn't slow down the evolution of a language
- having no users slows down the evolution of a language. And if PHP
was to totally change its language structure on every new version, I
can't think of too many people that would continue using it. The
changes from 4 to 5 are significant, but not overwhelmingly so. I
envisage that change from 5 to 6 will be significantly less of a jump.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] Obsession with BC

2005-10-11 Thread Richard Davey
Hi,

Tuesday, October 11, 2005, 5:41:53 PM, you wrote:

> Recently, I asked my hosting provider when they are going to switch
> to PHP5. They replied that it will not happen any time soon, since
> they will install PHP5 only on new servers. Their reasoning was
> simple: PHP5 will inevitably break some old scripts, and it's just
> not worh all the trouble. Such attitude is common, and it totally
> makes sence from a business perspective.

It does? I wouldn't waste my money with a host that was unable to
provide PHP 5 support, at least in some way. I think the "it will
break lots of scripts" is a cop-out. There are various ways to allow
both on one server. Assuming they're technically proficient enough of
course.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re[2]: [PHP] storing passwords in $_SESSION

2005-10-10 Thread Richard Davey
Hi Jay,

Monday, October 10, 2005, 7:36:12 PM, you wrote:

> I would think it neither safe nor practical. Once a user has logged
> in having the password in SESSION would be useless.

Agreed totally, I am curious as to why this question seems to get
asked a LOT though. I wonder what it is that causes this? (other than
inexperience) I mean there must be some common end result these
developers are hoping to obtain, resulting in a password being stashed
away in a session var.

I wonder if they're using it (+ a username) to perform a user look-up
on every page?

The mind boggles.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] storing passwords in $_SESSION

2005-10-10 Thread Richard Davey
Hi Dan,

Monday, October 10, 2005, 7:43:31 PM, you wrote:

> How secure is it to save a password in $_SESSION.

> i.e. $_SESSION['password'] 

> is it safe and is it practical?

No, and no (well, not if you want to be safe)

More to the point - why would you ever want to? If you've found
yourself in a situation where the only option open to you is this, you
need to hit the drawing board again and re-design your application.
Big time.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re[2]: [PHP] date comparisions...

2005-10-07 Thread Richard Davey
Hi,

Friday, October 7, 2005, 7:55:45 PM, you wrote:

> dateexpired is: 1128052800 which translates into: 2005-09-30 00:00:00

> Basically, I'm just trying to figure out when the dateexpired is. IF
> it is past the current date then I am erroring out and if it's under
> the current date... I'm allowing the transaction.

> I would assume the following:

> if (2005-09-30 00:00:00 > 2005-10-07 00:00:00)

> it should error out, no?

Not given your logic above, no.

You said "If it is past the current date then I am erroring out",
therefore 2005-09-30 00:00:00 > 2005-10-07 00:00:00 will NEVER error
out, because it will never be greater than the current timestamp in
seconds.

A = 2005-09-03 = 1,128,052,800
B = 2005-10-07 = 1,128,713,278 (approx, that's actually the value now)

So A will never be greater than B, hence you're always allowing the
transaction.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] date comparisions...

2005-10-07 Thread Richard Davey
Hi aaronjw,

Friday, October 7, 2005, 7:34:11 PM, you wrote:

> if ($discountResult["dateexpired"] > date("U"))
> {

>   //dosomething

> }
> else
> {

>   //do something else

> }

> Anyway... it's supposed to read: IF the expired date is past the current
> date... disallow "dosomething" otherwise... let it go.

> I set the expire date to be Sept 30, 2005 and obviously today is the
> current date but for some reason the "dosomething" is being allowed.

Start with the obvious - what actually IS the value of
$discountResult["dateexpired"]? var_dump it out and have a look. Check
you are comparing like with like. You're also not performing a strict
comparison, so string conversion could be going on here.

The other obvious fact is that if dateexpired is less than *right
now*, it'll always "dosomething" ! :)

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] Detect file size BEFORE upload it

2005-10-06 Thread Richard Davey
Hi Ruben,

Thursday, October 6, 2005, 7:38:35 AM, you wrote:

> The problem is that I was able to detect file size after complete
> file is transfered.

> I need to detect file size before all file is transfered, in order
> to cancel it and preserve server resources.

> Any ideas?

The only way to do it would be to write your own client uploading
application in the likes of Java or ActiveX.

Anything client side is always going to fail because it doesn't know
about the size of the file until it has it, by which point it's too
late.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] new ways to add an html body?

2005-09-25 Thread Richard Davey
Hello Ross,

Sunday, September 25, 2005, 2:27:42 PM, you wrote:

> I am using php mailer and am trying to find a new way to make the html email
> body instead of the old

> Can I make a whole html mage and just link it?? Or include ('mypage.htm')

$mail_body = file_get_contents('path/to/your/html/email.html');

Will save embedding all that HTML into your PHP scripts. You could
then do simply variable replacement on $mail_body to customise the
messages if you so wish.

-- 
Best regards,
 Richard Davey
 Zend Certified Engineer

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



Re: [PHP] specifying a font in PHP-generated email

2005-09-20 Thread Richard Davey
Hello Kenn,

Tuesday, September 20, 2005, 9:32:47 PM, you wrote:

> I'm attempting to create an HTML email via PHP and cannot get the
> email to render in the correct font. I've made several stabs at it,
> the most recent one below. The same code that works just fine on a
> web page won't work for me here. What am I doing wrong?

Forget trying to include style elements in the header block for
emails, most mail clients strip them out totally. There is no
foolproof way to embedded CSS into an email and have all clients
handle it correctly (if at all). Lots of mail clients will attempt to
render the HTML themselves and don't support any form of CSS at all,
whereas others (like Outlook) use the IE rendering engine on Windows.

My suggestion? Embed the font styles into the email body and don't
even bother with a  section. I'd even go so far as to suggest
you use the HTML 4.x  tags instead of CSS.

But as with everything on the Internet, your mileage will always vary.

This article should also help: http://www.alistapart.com/articles/cssemail

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



Re[4]: [PHP] Restarting windows from php

2005-08-10 Thread Richard Davey
Hello Richard,

Wednesday, August 10, 2005, 9:40:02 PM, you wrote:

RL> I dunno if YOUR Windows box has some cygwin thingie or something
RL> that makes shutdown be a real command, or if it's just a
RL> versioning issue, but the single test platform I had available
RL> pretty much had no shutdown command.

RL> Win 98 SE, I believe.

RL> I've got XP on my laptop, and if I cared enough about Windows, I
RL> guess I could test that too...

... and it would work.

Yes of course it's version specific (NT range up, 2K, NT, XP, etc)

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] Restarting windows from php

2005-08-10 Thread Richard Davey
Hello Joseph,

Wednesday, August 10, 2005, 3:26:05 PM, you wrote:

JO> First off, windows has no clue what a fork is,

A fork is several different things, and there's no reason why Windows
cannot implement a fork via its standard APIs.

JO> much less the command 'shutdown -r -t 01'.

-r = Shutdown with restart
-t = Set the timeout for shutdown (xx seconds)
01 = The timeout value

Open a command prompt, type in it.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] Restarting windows from php

2005-08-10 Thread Richard Davey
Hello Karl-Heinz,

Wednesday, August 10, 2005, 3:05:32 PM, you wrote:

KHCZ> Does anyone have any idea how to restart windows from a php script?
KHCZ> I tried the following:
KHCZ>  exec('SHUTDOWN -r -t 01');
KHCZ> or
KHCZ>  exec('SHUTDOWN /r');

KHCZ> I received the following warning message: Warning: exec():
KHCZ> Unable to fork [SHUTDOWN -r -t 01].

KHCZ> I never used this kind of functions before. What's wrong? In IIS
KHCZ> for "Execute Permissions" I have "Scripts and Executables". What
KHCZ> permissions should I set for the Internet Guest Account? Or
KHCZ> something else caused the problem, not the permissions? Please
KHCZ> help me.:)

While you can call shutdown directly from exec - some things are best
not called like this. PHP will be left hanging waiting for the process
to finish, so you'll get a really nasty shutdown going on without
properly ending your sessions.

You'd be better off looking at COM scripting it to be honest. Or write
a Windows application that does what you require (closes down all
services smoothly, reboots, etc) and exec that, providing your IIS
user has the correct permissions to do so.

The warning most likely comes from IIS, or your php.ini settings - I
just tested "shutdown -i" on Apache (in WinXP) and it ran without any
problems.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] Server-Client connection via TCP port with PHP

2005-08-09 Thread Richard Davey
Hello Eli,

Wednesday, August 10, 2005, 2:40:07 AM, you wrote:

E> I got a PHP program on my server. I want to open a live TCP port
E> connection between my server to a client (client is developed in
E> .NET, not regular HTTP browser). How can I do this using PHP?

Look in the manual at the quite considerable chapter on "Socket
Functions".

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] Re: Logging fatal errors and timeout

2005-08-08 Thread Richard Davey
Hello RPG,

Tuesday, August 9, 2005, 12:52:48 AM, you wrote:

RG> Thanks. How do I override PHP settings using .htaccess?

php_value include_path ".:/usr/local/lib/php"
php_admin_flag safe_mode on

etc

Look at the manual section titled "How to change configuration
settings" for more details (it's in the install section somewhere)

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] set variables based on HTTP_HOST

2005-08-08 Thread Richard Davey
Hello Joe,

Tuesday, August 9, 2005, 12:57:17 AM, you wrote:


JS> // call the include header file for that host
JS> if (file_exists("$includepath/$Header")) {// include valid?
JS> include stripslashes("$includepath/$Header"); // yup, include
JS> } else {
JS> echo "FAILURE MESSAGE OF SOME SORT";  // nope
JS> exit;
JS> }

?>>

JS> (rest of page)

JS> I figure I can get a regexp in there somehow so I don't need two
JS> entries for the main domain.com and it's www c name, either... need to
JS> add that.

You can just do this:

switch ($_SERVER['HTTP_HOST'])// check hostname
{
   case 'www.domain.com':
   case 'domain.com':// define host
  $Header = '/inc/main.header.inc'; // define header file
  break;// next
}

Stack 'em up as much as you need.

JS> I'm also sort of paranoid about unchecked includes in PHP and
JS> getting compromised--is doing a check like I am here for the
JS> include file's existence worthwhile or even useful to protect
JS> against possible problems?

You're not doing an un-checked include - it's definitely checked.

You've pre-defined the $includepath at the start of your script, so
no-one can over-write this. You've forced $header to be one of the
switch options and *nothing* else. So those two things are certainly
clean.

If someone manages to inject bogus variables into your
$_SERVER['HTTP_HOST'] element then you've got bigger things to worry
about than your code :) (i.e. someone has compromised your server) but
with your switch block and pre-set values even if they had managed
that, you'd still only ever include a valid header.

You have to draw the line somewhere with security - nothing will ever
be 100% safe because there are so many chains in the loop (firewall,
network, server, apache, php, etc). I would say that as it stands
you've done the best you can for this little section of code, but
perhaps some others might post more ideas if they have them.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] Generating a 404 status message with header()

2005-08-08 Thread Richard Davey
Hello Eric,

Monday, August 8, 2005, 9:37:12 PM, you wrote:

EG> I have another file (doesexist.php) with the contents:

EG>  header("HTTP/1.0 404 Not Found");
?>>

EG> If I enter into my browser:

EG>   http://mydomain.com/doesexist.php

EG> I get a blank page. Apparently, this does not trigger the 404
EG> directive.

The header 404 is correct - check to see if your script contains any
extra white-space somewhere that is causing the header to fail? (i.e.
a carriage return after the closing php tag).

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] Re: Logging fatal errors and timeout

2005-08-08 Thread Richard Davey
Hello RPG,

Monday, August 8, 2005, 9:34:52 PM, you wrote:

RG> I set my error report to 0 just like the ones at
RG> http://www.php.net/manual/en/ref.errorfunc.php: error_reporting
RG> (0);

RG> ... so that I can use the custom error handler function at
RG> http://www.php.net/manual/en/ref.errorfunc.php.

RG> I'm on a shared server, by the way.

You cannot catch Fatal run-time errors with that method of error
handling. The error has occurred before the script settings have had a
chance to be picked up.

Check to see if your host allows you to use .htaccess settings to
over-ride PHP ini settings - for trapping Fatal run-times on a shared
server that's most likely your only option. I've seen some hosts dump
PHP errors to an error_log in the same directory as the script that
caused the error. This might be an option (although not very secure,
it's better than displaying the error across the middle of your site)

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] lack of understanding of sessions

2005-08-08 Thread Richard Davey
Hello Sabine,

Monday, August 8, 2005, 7:17:51 PM, you wrote:

S> When I call the script for the first time the output is:
S> if, test: test
S> if, sesstest: test
S> test: test
S> sesstest: test
S> if, test2: test2
S> test2: test2

S> on all servers.
S> Additionaly I get a warning for the session_register-part on the 
S> PHP5-server. Thats ok.

You shouldn't really be using it even on 4.0.6, best remove it now and
the warning will go too.

S> PHP4.3.10:
S> else, test:
S> else, sesstest:
S> test:
S> sesstest:
S> else, test2:
S> test2:
S> I don't understand, why the variables seem to be empty.

Dump out the session contents and see what's in there (if anything):

print_r($_SESSION);

Equally, dump out the cookie super global to see if the session cookie
even got set

print_r($_COOKIE);

Or use the Web Developer extension for Firefox and "Display cookies"
after the first page load - you should see the PHPSESSID cookie in
existence. If not, that's the problem. If so, what does it say?

S> In the session_is_registered-part, the var seems to be empty, too. Why?

Because even 4.0.6 shouldn't be using that function. If you want to
check for the existence of a variable, use isset().

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] set variables based on HTTP_HOST

2005-08-08 Thread Richard Davey
Hello Joe,

Monday, August 8, 2005, 6:40:37 PM, you wrote:

JS> Is this potentially bad, security wise, to do something like this?
JS> Can you guys recommend any way to tighten this up a bit or do this
JS> sort of thing better/more eloquently?

$_SERVER is, thankfully, _mostly_ populated by the web server, not the
client. HTTP_HOST certainly falls into this category. The only thing
you probably shouldn't do is rely on it always being there, so have
some catch-all set of headers / css if it's not set (mind you, if that
happens you've got a bigger problem on your hands! but it'd stop your
site breaking).

JS>  $Host1 = array ('name1.host.com');
JS> if (in_array ($_SERVER['HTTP_HOST'], $Host1))
JS>  {
JS>  $HeaderImg = "/headers/name1_header.gif"; // define graphic 
JS>  $SiteCSS = "/css/name1_css.css"; // define css 
JS>  }

Why are you creating lots of arrays and then using in_array to check
them? Just seems a little pointless in this instance as it gives you
no real benefit - comparing a one element array against a variable is
just...  well.. comparing a variable with a variable! So why not do
that? Perhaps a switch block would serve your needs better?

switch ($_SERVER['HTTP_HOST'])
{
   case 'name1.host.com':
$header = ..
break;
}

etc - then you can combine multiple hosts into one section and have a
default set at the bottom.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] Logging fatal errors and timeout

2005-08-08 Thread Richard Davey
Hello RPG,

Monday, August 8, 2005, 6:05:47 PM, you wrote:

RG> I use the error handler function found at
RG> http://www.php.net/manual/en/ref.errorfunc.php . Whenever a fatal
RG> error has occurred, it does not log the error. I tried adding
RG> E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_WARNING, E_COMPILE_ERROR
RG> and so that whenever they occur, it will log itself to a log file.

Where did you add the error level flags? and have you enabled the
error log entry in the php.ini? It should look like this:

error_reporting  =  E_ALL|E_NOTICE|E_CORE_ERROR
log_errors = On
error_log = "D:/php4_error_log.txt" (or where-ever)

Stick display errors on for your dev machine too if you want:

display_errors = On
display_startup_errors = On

RG> Another question related to that is how do I log a timeout error
RG> for the fopen() function? When fopen() times out, it produces a
RG> fatal error and fatal error is not being logged.

Fix the above :)

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] Possible to read JavaScript results into a string?

2005-08-08 Thread Richard Davey
Hello Brian,

Monday, August 8, 2005, 6:38:54 PM, you wrote:

BD>  $x = file_get_contents('http://www.mydomain.com/log.js');
BD> // also tried urlencode() but that did not help
?>>

BD> The result:

BD> Warning: main(http://www.mydomain.com/log.js) [function.main]: failed
BD> to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in c: 
BD> \Inetpub\wwwroot\test.php on line 2

Your code will work providing that PHP is not running in Safe Mode
and allow_url_fopen is enabled in your php.ini file.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] parallel execution of php code?

2005-08-08 Thread Richard Davey
Hello Martin,

Monday, August 8, 2005, 4:07:47 PM, you wrote:

MvdB> Now here is the problem: when the user enters the page, and
MvdB> directly refreshes the record is inserted twice Is is
MvdB> possible that both requests are processed simulatiounsly by the
MvdB> server (apache on linux)? And can I add something like a
MvdB> critical section or semaphore to overcome this problem.

What data type does the execute function return? You're doing a
loose type comparison between $rows and zero (== rather than ===),
because it's a loose comparison a number of different results could
equal zero in this case. For example if execute() returned false your
code would assume an insert is required, which might not be the case.

If you're using MySQL then you may want to look at using a different
method for checking / inserting this data. Rather than a SELECT
followed by INSERT you could use an INSERT IGNORE which won't
duplicate data if it already exists. Or possibly REPLACE INTO -
depends how you need this to work (i.e. retain the oldest copy of the
data, or keep the newest). Look in the MySQL manual for those two
functions for more info.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] Write from form to DB

2005-08-03 Thread Richard Davey
Hello Jim,

Wednesday, August 3, 2005, 7:43:15 PM, you wrote:

>> You could do that. The reason that I don't is because of the mixing of
>> quote types.

JM> So, is that a "Really Bad Thing(tm)", or is it just bad form?  If the
JM> former, why?

It's in no way a "Really Bad Thing", probably just a personal coding preference.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] Write from form to DB

2005-08-03 Thread Richard Davey
Hello George,

Wednesday, August 3, 2005, 6:50:07 PM, you wrote:

GB> $query = "INSERT INTO user (name,password) VALUES ($username","$password")

$query = "INSERT INTO user (name, password) VALUES ('$username',
'$password')";

And don't forget to validate your user input before slamming it
directly into your database.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] Error Suppression with '@'

2005-08-02 Thread Richard Davey
Hello Justin,

Tuesday, August 2, 2005, 8:43:09 PM, you wrote:

JB> Does suppressing the error only suppress it from the screen, or
JB> does it ignore the error?
JB> ie: is the error still logged?

It will ignore it totally, it doesn't even make it as far as the log
files - which is why in most cases it's a bad thing to use. When it
comes to the mysql/i functions however I will suppress the error and
use my own error checking to avoid blank pages / unsightly warnings.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] Multipage form redux

2005-07-27 Thread Richard Davey
Hello André,

Wednesday, July 27, 2005, 2:22:30 PM, you wrote:

AM> That's not a very good idea. Imagine the user gets to the fourth
AM> form and gets a cup of coffee, or goes out to lunch. By the time
AM> he gets to the computer he might have lost the session, thus
AM> having data on your DB that is wasting space.

AM> And what if the user closes the browser window? :)

All of those things are unavoidable no matter what technique you use
:)

I've seen multi-page forms with a "Finish this later" option that
issues a cookie to your browser, allowing you to visit the site at any
(realistic) point in the future and carry on. In which cases the
part-filled contents must already be in a database somewhere. This
isn't a bad thing imho, it's a nice touch.

Of course it's prone to the usual "browser doesn't accept cookies /
browser deletes cookies" syndrome though.

If you don't want to pass the form values across in a hidden manner
(and I don't blame you) then it's either dump it all in a session and
hope it doesn't time-out, or dump it into a database, issue the
visitor some link to that entry (cookie, session var) and again hope
they don't time out.

The only real difference being the DB option will need purging to get
rid of incomplete forms > X days old. But that in itself could prove a
useful statistic for reports. Unless you're dealing with thousands of
sign-ups an hour, I don't see any issue with this option.

Another technique might be the following - rethink how your forms
work. Exactly what is it you're collecting data about? If it's part of
a long sign-up process then you could consider changing the process
around a bit - so that the VERY first thing the user does is create a
temporary account on your site (call them "incomplete users"). So you
grab some method of login + authentication details from them. Then the
form pages following this can all be saved to a DB and linked to that
user.

So, as long as they complete this first step, they can always come
back and finish the job off - whenever they want, avoiding cookie and
session time-out issues.

This won't work for all forms of course, it depends what the nature of
the process is, but it's certainly an option.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] Object Inheritance, get_class() and a static function call

2005-07-26 Thread Richard Davey
Hello axel,

Tuesday, July 26, 2005, 8:02:05 PM, you wrote:

a> class ClassA {
a>function getClassName() {
a>  return get_class($this); # [1]
a>}
a> }
a> class ClassB extends ClassA { }
a> echo ClassB::getClassName();

a> this script echoes "Object" instead of "ClassB". but i would like to
a> return the classname of the derived class without writing the method again.

"The double colon, is a token that allows access to static, constant,
and overridden members or methods of a class."

Of which none of yours are (at least not in the code posted)

Wouldn't get_parent_class() work in this situation?

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] running number

2005-07-25 Thread Richard Davey
Hello Roger,

Monday, July 25, 2005, 10:21:54 AM, you wrote:

RT> I am quite new at all these stuff and would like to seek your
RT> advise on the *recommended way* of achieving this. I am thinking
RT> along these lines:
RT> a) store that number (12345) in a table
RT> b) a user registers and assign that number to him
RT> c) increment number to 12346
RT> d) process repeats for the next registration

RT> Concern: How do tell mySQL to lock the 'number' table when a
RT> new registration process is about to take place. Is locking the
RT> best option here or is/are there better ways?

Do you HAVE to have a "starting off" number of 12345? If there is no
real reason to do this, then use an auto-increment column in MySQL and
let that do all the hard work for you!

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] skewed up images

2005-07-15 Thread Richard Davey
Hello Ryan,

Saturday, July 16, 2005, 3:53:16 AM, you wrote:

RA> in the beginning if the height is more, then its resizing
RA> perfectly...but if the width is more I want to cut out 90pix from
RA> the middle of the pic...instead its giving me a skewed image as
RA> you can see from

RA> Any ideas? I know I screwed up somewhere in the function...but just cant
RA> figure it out...

If the width is greater than the height you're calling CR_make_crop
which has this line:

imagecopyresized ($new, $img, 0, 0, 0, 0, 90,120,$width_orig2,$height_orig2);

The problem is that what you're effectively saying is:

Copy the entire original picture (0,0 to $width_orig2, $height_orig2)
into an area 90x120, and resize it when you do it.

That's not a crop :) That's a resize. You'd be better off with a
function like imagecopy() instead - once you have that 90x120 cropped
piece, then you can do whatever it is you wanted to do with it.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] Copy Remote File to Local Server

2005-07-15 Thread Richard Davey
Hello Matt,

Saturday, July 16, 2005, 3:31:26 AM, you wrote:

MP> I don't have access to edit the php.ini settings.  Is there anyway to
MP> copy part of the file, then copy the rest where it left off?

[ Note: Please reply to the mailing list - not to me personally ]

The suggestion I gave you doesn't involve the php.ini file at all -
try looking in the PHP manual for the function given.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] Copy Remote File to Local Server

2005-07-15 Thread Richard Davey
Hello Matt,

Saturday, July 16, 2005, 3:04:29 AM, you wrote:

MP> I am writing a script that will read a file from a remote server
MP> and write it to the local server. It works fine except when large
MP> files are attempted. It times out and gives the error that the
MP> maximum execution time has been reached and the file will only be
MP> partially copied to the local server. Is there a way around
MP> something like this? Or perhaps could the script keep time of how
MP> long it has been running will reading/writing and then be able to
MP> continue writing to the partial file? Does anyone have any
MP> suggestions for this problem?

Providing you feel it's safe / user friendly to do so, just increase
the time-out: set_time_limit()

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] Trimming Text

2005-07-15 Thread Richard Davey
Hello André,

Friday, July 15, 2005, 4:24:23 PM, you wrote:

AM> I am trying to trim some text containing HTML tags. What I want to
AM> do is to trim the text without trimming the tags or html entities
AM> like   and such, wich completelly break the design.

The problem as I see it, is that while it's easy to trim some text and
then check to see if you were inside an HTML tag or not, it becomes
MUCH harder to check if you were inside nested tags (for example
)

If there are no nested tags then it's much easier.. just trim the
string at X characters and then search for the last occurrence of a
'>' and the last occurance of '<' - if the first is LESS than the second
value, then you're in the middle of a tag.

This of course doesn't handle nested tags.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] array help

2005-07-14 Thread Richard Davey
Hello Fletcher,

Thursday, July 14, 2005, 11:33:36 PM, you wrote:

FM> while ($row = mysqli_fetch_assoc($result))
FM> $table[] = $row;

FM> but that generated this error;

FM> Fatal error: [] operator not supported for strings

The above WILL work providing that (1) $table hasn't been set
elsewhere in your script as a string, or (2) $table has been set as an
array ($table = array()) prior to being used.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] Win2000 easier than Win2003 ??

2005-07-14 Thread Richard Davey
Hello Steve,

Thursday, July 14, 2005, 5:15:01 PM, you wrote:

GSII> Is setting up PHP easier on Windows 2000 server rather than
GSII> Win2003? I'm having nothing but problems getting PHP files to
GSII> show up in IE on the Win2003 server, I get nothing but 404 -
GSII> file not found errors.

Just don't use IIS - use Apache instead. It's an extremely easy
install process, one I documented fully on this mailing list no more
than a few weeks ago.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] cannot connect to MySQL server and not sure why

2005-07-14 Thread Richard Davey
Hello Bruce,

Thursday, July 14, 2005, 4:27:12 PM, you wrote:

BG> ?php
BG> $database="bruceg_search";
BG> $mysql_user = "bruceg_webmaster";
BG> $mysql_password = " password"; 
BG> $mysql_host = "server-10.existhost.com";
BG> mysql_pconnect ($mysql_host, $mysql_user, $mysql_password);
BG> if (!$success)
BG> die ("Cannot connect to database, check if username, 
password and
BG> host are correct.");
BG> $success = mysql_select_db ($database);
BG> if (!$success) {
BG> print "Cannot choose database, check if database name is 
correct.";
BG> die();
BG> }
?>>

BG> I double checked the database and I have created a database called
BG> bruceg_search and added a user called bruceg_webmaster with all of
BG> the editing privileges. Of course 'password' is changes with the
BG> password used to connect in the actual script. and I double
BG> checked that to be correct as well. Any suggestions?

Sure.. where is $success set?

I don't see it being set anywhere :)

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] $PHP_SELF or echo $PHP_SELF

2005-07-14 Thread Richard Davey
Hello Ross,

Thursday, July 14, 2005, 11:11:25 AM, you wrote:

R> Just a quick thing that is bugging me. In some of my older
R> textbooks a form is returned to the same page by using

R> echo $PHP_SELF no just $PHP_SELF

R> is this just used in older versions of php?? Does the it make a
R> difference what one is used?

PHP_SELF is part of the $_SERVER super global, you should really
access it like this:

$_SERVER['PHP_SELF']

To answer your question though, it's just a variable - if you want to
output it into your form action then you can do either:

 or 

Either would work.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] searching multiple fields

2005-07-14 Thread Richard Davey
Hello Ross,

Thursday, July 14, 2005, 9:37:10 AM, you wrote:

R> $query = "SELECT * FROM sheet1 WHERE 'name' or 'area or 'organisation LIKE
R> '$search_field%'";

SELECT * FROM blah WHERE name LIKE '$search%' OR area LIKE '$search%'
OR blahblah LIKE '$search%'

etc

If you want to add extra conditions you can do so like this:

SELECT * FROM blah WHERE (name LIKE '$search%' AND id > 10) OR area LIKE 
'$search%'

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] 404 error - why???!!

2005-07-13 Thread Richard Davey
Hello Steve,

Wednesday, July 13, 2005, 5:11:58 PM, you wrote:

GSII> Ok, I thought I had installed PHP correctly on my Win2003 server, using
GSII> ISAPI.  I added the extension, and mapped it to the php4isapi.dll file,
GSII> added a path to my /php folder in Win2003, edited my php.ini file which
GSII> I copied to my /windows/system32 folder.

This won't fix the 404 (sorry), but the php.ini doesn't go in
system32, it just goes in the Windows directory. Do you only get 404s
on PHP files? What happens if you copy an .html file into the same
location and request that?

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[6]: [PHP] Re: Security, Late Nights and Overall Paranoia

2005-07-11 Thread Richard Davey
Hello Greg,

Monday, July 11, 2005, 5:06:51 PM, you wrote:

GD> I wouldn't know,  isn't one of the tags I allow.

If you stick to the plain vanilla HTML tags such as i, b, u, etc then
BBCode is pointless - I agreed on this with you several posts ago. I
don't however use it just for that, I use it to let thousands of kids
add a little sparkle to their messages/profiles with colours, images,
etc -- without them having to have good CSS/HTML knowledge (most of them
could handle a font tag, but that'd break my XHTML Trans). This is the
point I argued all along to which I get "it's not really a security
benefit" (no, it's a user benefit) and it's a "misuse of cpu cycles".

For people I hold in such high regard, I'm ashamed at the lot of you :)

GD> I don't bother with perfect tag validation, and I doubt the phpbb
GD> bbcode people do either since they average about 2-3 exploits a
GD> month on Bugtraq.

Not that I'd let an install of phpBB anywhere near a site I run, they
didn't invent BBCode, and in all fairness to those guys the majority
of their exploits are elsewhere.

GD> I allow a specific set of safe html tags and I provide a preview
GD> function. Even after that, if the user goofs up I allow a specific
GD> time span in which to edit the post to correct the goof.

Ditto. I just don't force them to use HTML.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[4]: [PHP] Re: Security, Late Nights and Overall Paranoia

2005-07-11 Thread Richard Davey
Hello Greg,

Monday, July 11, 2005, 3:46:24 PM, you wrote:

GD> On 7/11/05, Richard Davey <[EMAIL PROTECTED]> wrote:
>> I gave several valid good usability reasons, that I've yet to see
>> anyone provide a coherent reason not to use.

GD> Misuse of CPU cycles.

So if you wanted to allow a user to say colour a piece of text red,
they'd have to enter x to make it
happen? Poor bastards (never mind the fact I'd love to see you use
less CPU cycles to perfectly validate that tag than say [red][/red]).

Interesting.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] Re: Security, Late Nights and Overall Paranoia

2005-07-11 Thread Richard Davey
Hello Chris,

Sunday, July 10, 2005, 2:31:57 AM, you wrote:

CS> I completely agree. I think you'll find that, when pressed, no one
CS> can really provide a good reason to use BBCode. I often see
CS> security cited as a reason, but it makes no sense.

I gave several valid good usability reasons, that I've yet to see
anyone provide a coherent reason not to use.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[5]: [PHP] Re: Security, Late Nights and Overall Paranoia

2005-07-09 Thread Richard Davey
To follow-up my own post... which is sad I know, but hey...

Saturday, July 9, 2005, 7:08:37 PM, I wrote:

RD> The difference is the extra hoops your reg exps will have to jump
RD> through, and have to jump through perfectly. You will have to disallow
RD> all <'s and >'s, but do allow them for , , etc etc. Then check

I forgot to add that BB style codes come into real use for things a
little more advanced than . For example [red] to colour some text.
If you wish to allow this in HTML format you can either invalidate
your XHTML and allow  tags, otherwise allow spans with embedded
CSS?! Even if you do allow  you're then parsing for color="" and
nothing else, with potential variable width colours. After a short
while you'll find yourself having to write an HTML validator tool (and
I'm sorry but I have *never* seen one that worked flawlessly yet).

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[4]: [PHP] Re: Security, Late Nights and Overall Paranoia

2005-07-09 Thread Richard Davey
Hello Greg,

Saturday, July 9, 2005, 6:40:06 PM, you wrote:

GD> The same regular expression magic that keeps you from forgetting your
GD> [/i] can just as easily keep you from forgetting your .

The difference is the extra hoops your reg exps will have to jump
through, and have to jump through perfectly. You will have to disallow
all <'s and >'s, but do allow them for , , etc etc. Then check
there has been nothing malicious inserted inside every one of those
tags in any shape or form, and all combinations thereof. I'm sorry but
I fail to see how *having* to perform masses of flawless reg-ex
kung-fu is a good thing, in my mind it just widens the margin for
developer error, which is a never a plus point.

It's horses for courses though, in the CMS I built for myself I allow
any damn thing I want ;) In the forum built for thousands of
teenagers, you'd have to be out of your mind to allow it. May as well
just give them your server reboot button while you're at it and ask
not to touch.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] Re: Security, Late Nights and Overall Paranoia

2005-07-09 Thread Richard Davey
Hello Greg,

Friday, July 8, 2005, 5:00:23 PM, you wrote:

GD> On 7/8/05, Ryan A <[EMAIL PROTECTED]> wrote:
>> Yep, but this has no way of breaking my html

GD> If [/i] is missing, it'd be the same as  being missing.

I have to say I disagree, because with all modern BBcode parsers it
would never get to that stage.

If the user misses out the closing [/i] tag then when it comes to
parse the BBcode into HTML it'd never happen. All decent BBcode
parsers search for both pairs of tag. If an opening [i] is found but
no corresponding close tag, both would be ignored and skip onto the
next check. I haven't seen one that did a straight str_replace for a
long time now (although I guess they still exist! and in those cases I
agree with you, they are pointless and utterly insecure).

If you allow direct HTML as user input, you HAVE to check and validate
every single aspect of their HTML for all possible errors, typos,
included XSS attacks, etc - and if you fail in even one of these
checks, they can break the layout of your site, or worse. Whereas with
BBcode the worst that can happen (in this instance) is that the user
looks like an idiot because [i] tags are left in their input.

Another benefit IMHO is that you control what [i] gets turned into,
for example I don't use  tags in my HTML as I don't believe they
are semantically descriptive. But not everyone will know what the heck
an  does, just as with [b] to , etc. The second you allow
<&> for direct use you do open, imho, a whole can of worms that you'd
better be absolutely sure you have faultlessly checked and
double-checked, because as you know there's no room for error these
days.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] TimeStamp BEFORE 1970

2005-07-07 Thread Richard Davey
Hello Bruno,

Thursday, July 7, 2005, 7:04:44 PM, you wrote:

BBBM> I've read the manual, and the ADOdb Date package functions, and
BBBM> I am not using this because I want to keep my framework simple,
BBBM> flexible, and fast.

BBBM> Well, I just want a simple way to translate dates (I know what
BBBM> is the input format) to unix timestamp, with ability to do this
BBBM> with dates before 1970, and after 2023, is there any way?

Personally I'd use the Pear Date package. It's stable, well formed and
will do exactly what you require: http://pear.php.net/package/Date

Even if you don't like the thought of using it - you can always pour
over the source code to look at their methods and see how they handle
it.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[6]: [PHP] IBM's Learning PHP Part 1 tutorial.

2005-07-06 Thread Richard Davey
Hello Richard,

Thursday, July 7, 2005, 1:16:29 AM, you wrote:

RL> You've just made my point.

RL> The actual data tuple returned in both cases is a long, if there
RL> is a user to match.

This is where we differ :) I don't believe MySQL will return an entire
longs worth of data (typically 4 bytes) if the value is simply 1. By
return I mean across the network, etc. But maybe that is blind faith
in the skills of MySQLs developers? ;)

RL> 99 times out of a hundred, the very next thing your application is
RL> gonna do is get their ID, maybe their name, maybe their email,
RL> etc, so you can do something more interesting in your script than
RL> just know they exist.

Sure. But in the example given this wasn't the use of the query - they
were checking to see if the user existed so they could INSERT a new
one.

RL> Some days I think newbies should be forced to use IBM PC Jrs with
RL> 16K RAM and a 60 Meg hard drive (or whatever) just so they learn
RL> to code... :-)

I dunno.. I've seen shit code on every single system I've ever come
across :)

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] trouble with file upload page using PHP

2005-07-06 Thread Richard Davey
Hello Bruce,

Thursday, July 7, 2005, 12:10:30 AM, you wrote:

BG> I get an error stating:

BG> "Warning:
BG> copy(/hsphere/local/home/bruceg/inspired-evolution.com/LOR-BRUCE.pdf):
BG> failed to open stream: Permission denied in
BG> /hsphere/local/home/bruceg/inspired-evolution.com/Uploader.php on line
BG> 4
BG> Could not copy file"

The answer is in your error.

First of all I'd use move_uploaded_file instead of copy, just for the
additional checks it gives you.

But the problem is far more likely that the user the web server is
running as (nobody/apache/etc) doesn't have permissions to put files
into your "inspired-evolution.com" directory. Check the permissions
setting on that folder as a first course of action.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[4]: [PHP] IBM's Learning PHP Part 1 tutorial.

2005-07-06 Thread Richard Davey
Hello Richard,

Wednesday, July 6, 2005, 10:18:05 PM, you wrote:

RL> Actually, I think the "SELECT id" will transfer less data in the
RL> cases where no rows are returned.

Yes, I would agree with that.

RL> There are no rows to return, after all, whereas the count(*) will
RL> always return exactly one row.

Yup.

RL> And in the case case where a row is returned, the id will probably
RL> be the same number of bytes as a count(*): a 32-bit integer.

Say you've got user number 20,000 in a table. He only exists once, so
count() only returns 1. Bring back the ID and you'll get sent a value
of 2. I would be shocked if, on a byte for byte transfer level,
there was no difference between the two. Once it's in memory at the
other end, sure they'll both most likely become longs anyway.

As for the query itself, MySQL could use its query cache on either and
both would require the same analysis of the index/table to obtain
their end result due to the where clause.

RL> What's more, the num_rows is always available, so is PROBABLY
RL> pushed through the MySQL/PHP pipe from the get-go. So count(*) has
RL> the 32-bits for the number of rows, which is always 1, and 32-bits
RL> for the result, which is either 1 or 0.

Yes, the num_rows value will always be available, because of the
success of the select query. So yes, it is passed back and ultimately
stored in a long. Using count() has no effect here.

RL> But I'm guessing that if you actually managed to measure it
RL> accurately, "SELECT id" would be a gnat's whisker "faster" in
RL> cases where no rows were returned, and barely perceptible "faster"
RL> when there is a row, since MySQL doesn't have to "count()" the
RL> result set -- Which really means just copying the num_rows it has
RL> already calculated, most likely, in place of the actual result.

From MySQLs point of view num_rows is calculated and returned to PHP
irrespective of which method you use.

You could mysql_num_rows it and then PHP will have to perform a zend
fetch resource, doing an index look-up on the hash (and returning the
result). Or if you've count'ed it, it'll have to return the value
stored via a mysql_result call (or similar), which takes a few more
trips around the hash table.

When it comes down to milliseconds, I doubt there is much in it to be
honest. Certainly something hard (and I'm sure you'd agree useless) to
quantify. But hey, we're being pedantic here, yes? :) At the end of
the day it just seems like a coding preference to me. After all, I
don't want the users ID number, I want to know how many users exist
matching that username (i.e. I want a count of them), so that's what
I've directly asked MySQL for.

A "one cat, 1 billion skinning combinations" scenario again I feel.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] IBM's Learning PHP Part 1 tutorial.

2005-07-06 Thread Richard Davey
Hello Marek,

Wednesday, July 6, 2005, 3:15:58 PM, you wrote:

MK> You can select just the id, and provided that the query returns just
MK> zero or one row, you can spare one function call.

Sure that will work fine - but I fail to see how it will save a
function call. You either select, check there was no mysql error and
then check numrows. Or you select count, check there was no mysql
error and check the count value. I fail to see how your method
provides on less function call, but please elaborate :) (and hey,
select count = less bytes transferred from MySQL to PHP, regardless ;)

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] IBM's Learning PHP Part 1 tutorial.

2005-07-06 Thread Richard Davey
Hello André,

Wednesday, July 6, 2005, 3:25:37 PM, you wrote:

AM> Depending on the sittuation, IMHO, COUNT(*) wouldn't be the way to
AM> go. If you need the user's id or somesuch, you have to run an
AM> additional query to get the info.

But they're returning absolutely nothing in this case - which
(providing username was indexed) would make count() a far quicker and
less expensive query than selecting and bring back data and then doing
absolutely nothing with it (somewhat pointless imho)

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] IBM's Learning PHP Part 1 tutorial.

2005-07-06 Thread Richard Davey
Hello Bill,

Wednesday, July 6, 2005, 3:36:09 AM, you wrote:

BM> I'm working my way through IBM's PHP tutorial. Generally good ...
BM> but I'm stuck at an error point and have no idea what's going
BM> wrong. Before adding a new row to the mysql database (already
BM> opened) we do a query to see if a particular record already
BM> exists. (see $resultT).

BM> We then test, using if, to see if $resultT is true or false. If
BM> it's false we are then supposed to enter a new record. Problem:
BM> it's never false. It always evaluates true. What am I doing wrong?

BM> /*   build query to see if the record is entered already */
BM>  $sqlT = "select * from users where
BM> username='".$_POST["name"]."'";
BM>  $resultT = mysql_query($sqlT);

BM> /*   Now test -- did we find anything ... if not add this user */
BM>  if (! $resultT) {
BM> /*  here we add the new record if it doesn't already exit /*

To be honest that is quite shocking code, especially from a "teaching
beginners" perspective - and even more so coming from the likes of
IBM. But, SQL injection issues aside, the problem is most likely that
there is nothing wrong with your SQL query. mysql_query will return a
false (for a SELECT query) only if there is an error, not if "no
records exist" - that isn't an error.

It would make more sense to actually do a: "SELECT COUNT(*) AS hits FROM
users WHERE username = 'x'" and then check the value of the returned
"hits" (which will always return something, even if zero).
Alternatively instead of doing if (!$result) you could do: if
(mysql_num_rows($result) > 0) ... that way you know that the user
already exists.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] Report

2005-07-04 Thread Richard Davey
Hello Miles,

Monday, July 4, 2005, 3:09:58 PM, you wrote:

MT> There is a lot of JUNK showing up on this list, and for me this
MT> one was the last straw. From "Post Office" at
MT> [EMAIL PROTECTED] it had an attachment named

You're not alone Miles. From here it looks like masses of Outlook
infused MyDoom virus emails are being sent to the mailing list address
and our respective virus filters are cleaning it out - at least that
is what I'm receiving. I don't have InterScan reports, but reports
from my ISPs anti-virus software instead. Eitherway, it's highly
annoying though. I now my mail client set to delete messages matching
that content, and I fear you'll have to do the same if you want to
restore some sanity to your inbox.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] Help a Norwegian student!

2005-07-03 Thread Richard Davey
Hello Bjørn-Erik,

Sunday, July 3, 2005, 1:09:29 PM, you wrote:

BED> for "can not start the myswli extension,
BED> please check the PHP-configuration" A link follows to:
BED> http://localhost/phpMyAdmin/Documentation.html#faqmysql
->> "[1.20] I receive the error "cannot load MySQL extension, please
BED> check PHP Configuration".
BED> To connect to a MySQL server, PHP needs a set of MySQL functions called
BED> "MySQL extension". This extension may be
BED> part of the PHP distribution (compiled-in), otherwise it needs to be
BED> loaded dynamically. Its name is probably
BED> mysql.so or php_mysql.dll. phpMyAdmin tried to load the extension but
BED> failed.

Is this on a Windows? If so I assume you have installed a version of
PHP 5, because PHP 4 on Windows comes with MySQL support enabled as
default. For PHP 5 you need to check the php.ini file, the
php_mysql.dll extension is _not_ present in the extensions list as
standard and needs adding. If phpMyAdmin can use it (which I suspect
it can) you could also check to ensure the php_mysqli.dll extension
line is un-commented. Save your new ini file, restart Apache and see
what happens.

If you're on a flavour of Unix, wait for someone else to reply to your
message ;)

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] PHP vs. ColdFusion

2005-07-01 Thread Richard Davey
Hello Andrew,

Friday, July 1, 2005, 3:06:49 PM, you wrote:

AS> You know for a php developer your really don't know your own product to
AS> well (blah blah blah)

Isn't it time to run off and write another check to Adobe or
something? Rather than personally attacking other list members.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] PHP vs. ColdFusion

2005-07-01 Thread Richard Davey
Hello Andrew,

Friday, July 1, 2005, 3:32:14 PM, you wrote:

AS> Well I am on about 20-30 as well, and when I press reply it goes to a
AS> mailinglist address for broadcasting not the posters email address.

Most likely because they've bastardised the mail headers to force in a
reply-to address that wasn't ever there.

Thankfully most people on this list understand that when an email
arrives from an address, "reply" will reply to it.

Having said that, it does catch a lot of noobs out.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] MySQL error

2005-07-01 Thread Richard Davey
Hello Wessley,

Friday, July 1, 2005, 10:55:16 AM, you wrote:

WR> $sql = "LOAD DATA LOCAL INFILE '/path/to/file.txt' INTO TABLE
WR> `mytable` FIELDS TERMINATED BY '\t' ESCAPED BY '\' LINES TERMINATED
WR> BY '\n'";
WR> mysql_query($sql) or die(''.mysql_error());

WR> I get this MySQL error:
WR> You have an error in your SQL syntax. Check the manual that  
WR> corresponds to your MySQL server version for the right syntax to use
WR> near ''' at line 2

It looks to me like the \n (linefeed) character is actually being
turned into a line-feed character, because you've quoted the $sql
variable with " " - hence it's gone and turned \t into a tab, \n into
a line-feed, etc. I may be wrong, but I don't think MySQL likes this,
and given the error you are receiving it looks like that might be the
case. Quote it with ' ' to avoid translation of the \n and \t.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] PHP Magazine

2005-07-01 Thread Richard Davey
Hello Nadim,

Friday, July 1, 2005, 7:23:44 AM, you wrote:

NA> Two PHP magazines available are:
NA> - php|arch (www.phparch.com)
NA> - phpMag (www.php-mag.net)

NA> Want to subscribe to one of these 2. Please help me decide by sending your
NA> comments on these 2 mags.

They're both good. I only read the PDF version of php|a, which is much
cheaper and lets me print out only the pages I want to scribble notes
on.

php mag is nicely laid out and the content quality is as high as
php|a, but it's pretty expensive. Why not just buy a couple of issues
of each and see which you prefer?

On the topic of PHP Magazines, they are maturing quite a lot but still
suffer badly from coming across more as a collection of un-related
articles written by developers about their latest projects. Because
all the contributions come in from across the world, there's very
little consistency either in writing style or theme of content each
issue, and sometimes authors whose native language isn't English
create works that are harder to read.

They're both a great read and I appreciate nearly all of the articles
in them, and the people who've spent the time writing them. The
disjointed nature of the content isn't the authors fault, it's just
the way they are edited at the moment. Regular columns (such as
Security Corner in php|a or Guru Speak in php-mag) are helping to
address this, but what you won't find in them are all the authors
working together to address a specific topic. For example in most
development magazines I read they'll often have a theme for the issue,
i.e. security, and then the articles will be centered around that
theme from differing levels of complexity and scope. I am sure the
current crop of PHP magazines will migrate towards something more
coherent in structure as time goes on (and their circulations
increase), rather than feeling like a grab-bag of non-specific PHP
goodies as they do today.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] getting a filename [with no extension] out of a url

2005-06-30 Thread Richard Davey
Hello Graham,

Friday, July 1, 2005, 12:54:42 AM, you wrote:

GA> if  $_SERVER['SCRIPT_NAME'] give this
GA> /folder/folder/Library/php/filename.php

$_SERVER['SCRIPT_NAME'] won't give you that,
$_SERVER['SCRIPT_FILENAME'] would.

SCRIPT_NAME would just give you /filename.php

And if you need to remove the slash at the start, pick any of the
following: substr, str_replace, preg_replace, strpos, etc.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] PHP vs. ColdFusion

2005-06-30 Thread Richard Davey
Hello Andrew,

Thursday, June 30, 2005, 9:15:22 AM, you wrote:

AS> Coldfusion is also free (Blue Dragon) and has just as much support
AS> as PHP, although. PHP can not run in a J2EE environment, limiting
AS> it to small scall websites and limiting the prospect of expansion
AS> or server migration.

You like to tout CF as being J2EE/Enterprise ready. For this the free
version of Blue Dragon is NOT suitable, by the developers own
admission. You need the $6000 Enterprise version of CF (and you can
add on a few more thousand $ for extended support). This is before
you've bought any of the extra components you need to finish your
application.

1) Blue Dragon is also not just a "free" version of CF it would
appear, even on the developers web site they describe the free version
as "Functionality is robust and useful for most basic CFML
applications." - it's the words "most basic" that concern me here.

2) It doesn't support the newer CF 7 features.

3) The free version does not deploy into J2EE at all.

4) It only runs on Windows, OS X or Linux (sorry, but lots of very big
hosting companies prefer the stability of FreeBSD, Solaris, etc). If
you want Solaris support it costs $2499 per CPU. If you want FreeBSD
support, you're stuffed.

5) It only supports ODBC database connections (via JDBC), so unlike
PHP you won't be connecting to Oracle, MS SQL, SQLite, etc. MySQL is
supported, but not built-in.

If you want to do CF seriously, you need to invest thousands and
that's before you've paid your programmers - this is the bottom
line.

Perhaps that is why even the Blue Dragon developers themselves claim
its biggest advantage is: "You've invested heavily in CFML.. so have
we. Protect your investments." - and how do you protect them? by
deploying Blue Dragon so you can then interface directly with .NET
applications rather than migrate totally to them.

This doesn't strike me as being the approach of a growing, competitive
well supported language. It sounds more like "shit, people have woken
up to the massive cost of using CF, how can we slow the drop-out
rate?" if that is Blue Dragons primary selling angle, it says a *lot*
about the state of serious CF development.

When it comes to investing it think long-term. Zend are
aggressively attacking the enterprise market and we will see more and
more movement in this direction, to the point where I am quite sure
their objective is to make PHP itself enterprise capable *regardless*
of J2EE. With the rate things change around here, we won't have to
wait too long. If you don't actually need to build an enterprise scale
site (and let's face it, that covers most of us) then you're good to
go with PHP *right now* without actually spending a dime. Take that
$6000 CF budget, invest it into training for your entire team and
build your own framework, with the knowledge that no matter what
happens, your work is safe.

Anyway, time to get back to my project for BMW - just one of those
"small scall websites" (sic) things I guess?

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] Re: PHP vs. ColdFusion

2005-06-30 Thread Richard Davey
Hello Anton,

Thursday, June 30, 2005, 10:05:45 AM, you wrote:

AK> I do have some dozens of freinds who work as web-developers. The
AK> use Java, ASP.Net, PHP. I know none, who uses ColdFusion in his
AK> work, though ColdFusion is a relatevly old technology. So, that's
AK> my ugly point -)

It's a perfectly good point. I don't know a single CF developer
either, not any more. The last few I did know migrated to Python some
years ago. I guess that's the downside of locked-in proprietary
languages (which could be said for ASP, except Macromedia don't really
attract the same level of developers as Microsoft do). Personally for
me CF has the *perception* of being a very "1990s" technology
(regardless if it is or not)

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] turn off the www

2005-06-29 Thread Richard Davey
Hello André,

Wednesday, June 29, 2005, 8:03:00 PM, you wrote:

AM> Wouldn't
AM> $newUrl = 'https://' . substr( $_SERVER['SERVER_NAME'], 4 ) 
AM> be a _hell_ of a lot faster?

Sure.. providing they always link to the page using www.domain.com
(and the same goes for anyone else who links to their site)

Otherwise it could cause a slight problem, with unfortunate effects if
your domain is something like e-sparse.com :)

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] PHP vs. ColdFusion

2005-06-29 Thread Richard Davey
Hello Andrew,

Wednesday, June 29, 2005, 5:24:50 PM, you wrote:

AS> 
AS>  
AS>   
AS>   
AS>  
AS> 

AS> The above is tags that I am referring to very similar to java tag libraries,
AS> these tags read data from a database, validate and display the data like
AS> windows .net forms in a webpage. Yes the framework took a little time to
AS> develop, but it was worth the time invested. Now this same framework even
AS> decides whether it is updating inserting or deleting from the database as
AS> well as server / client side validation.

Very nice, a lot of hard work has obviously gone into the creation of
this. Are your CF tags are being inserted into standard HTML
documents? What kind of template system do you have in this framework
to separate business logic from display logic? What happens if for
example one of your tags needed to fetch data from a remote site via
SOAP, would you then have to create yet another tag, or add an extra
attribute to it?

AS> But the thing is PHP can not be delivered onto a J2EE server,
AS> coldfusion can

http://www.zend.com/store/products/zend-platform/java.php

AS> it worth going with something free, or could I leverage of the sms
AS> gateway to utilise sms messaging, or even use the report tools
AS> built into coldfusion to deliver invoices without too much effort.
AS> Or maybe you have data in a database and need to create a pdf,
AS> with a simple tag this can be achieved as it is built in.

What happens when your built-in PDF component fails to have a feature
a client requests? I'm not trying to start an argument btw, I'm asking
a question.

Most seasoned PHP developers I know already have a wide arsenal of
functions and objects at their disposal that can do what you've listed
- if they wished to assign this functionality to a "single tag" in
their template, well.. that's their choice I guess. Not everyone works
around that paradigm though.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov


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



Re[2]: [PHP] Conceptional question

2005-06-29 Thread Richard Davey
Hello Ryan,

Wednesday, June 29, 2005, 5:22:30 PM, you wrote:

RA> Interesting, I just created a "album" kind of section for a
RA> clients site, but i am dumping all the images of all users into
RA> the folder "user_album_pics" he's on a dedicated linux server with
RA> 2gigs ram and 300gigs hdd space...

RA> Any rough estimates what number of images would be too much? and
RA> does anyone think i should make folders for each user? Each user
RA> is limited to max 3mb of pics though...

(Disclaimer: I am NOT a Unix expert, this is just what I've picked up
over the years, perhaps it doesn't even apply any more? Hopefully
someone else can follow this post up and clarify)

AFAIK each file is assigned an inode. Some filesystems have inode
limitations - meaning you can run out of them if you have too many
files on a partition. You can use "df -i" to show this information,
right not it's probably nothing to worry about - over time as a site
gains popularity it can be. You can run out of inodes before you run
out of disk space (depending on the average size of your files).

Creating extra partitions helps avoid this, as does using an "extent"
based filesystem. A filesystem with "journaling" also helps should the
server ever crash as it caches disk information and won't need to
spend ages doing a massive re-built when the server boots again, which
depending on the number of files can take hours. ReiserFS / XFS are
good alternative filesystems, but again refer to my original
disclaimer - there may be better options these days.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] Conceptional question

2005-06-29 Thread Richard Davey
Hello Thomas,

Wednesday, June 29, 2005, 4:38:10 PM, you wrote:

T> I have a conceptional question about storing images/files on a
T> server. When the application gives users a possibility to store up
T> to 20 images, would it be better to create a new folder for each
T> signed-up user to store the images in, or use one large folder. I
T> have done the last quite often (just renamed the files to the
T> insert id) with good success.

Depends entirely on how many images you expect to be held in this
folder at any one time. Whilst all modern operating systems can cope
with lots of files, you hit a certain level* beyond which system
performance suffers increasingly.

Personally I'd create sub-dirs per user.

* Don't ask me what, but it's not a very high number IIRC.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] constant() - php5

2005-06-29 Thread Richard Davey
Hello Jochem,

Wednesday, June 29, 2005, 2:13:21 PM, you wrote:

JM> anybody here know what the logic is behind constant() triggering a
JM> warning if the named constant is not found?

JM>  $cnst = "DEBUG";

JM> // what I want to do but can't
JM> if ($dbg = constant($cnst)) {
JM> // do stuff
JM> }

JM> // the only real option, it seems - bit long winded to get round a stupid 
(IMHO)
JM> if (defined($cnst) && ($dbg = constant($cnst))) {
JM> // do stuff
JM> }

Isn't the warning coming from the fact that $cnst isn't defined,
rather than coming from the constant() function itself?

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re[2]: [PHP] Finding what links on a page have been clicked

2005-06-29 Thread Richard Davey
Hello,

Wednesday, June 29, 2005, 1:25:33 PM, you wrote:

DAG> Unfortunately I do not have access to those logs.

Some choices to get you started then:

1) Get a better web host :)

2) Subscribe to one of the free site stat services like Nedstat and
stick their little button onto your pages.

3) Make every single link on your site go via some kind of PHP
redirection script that, as part of its process, records the click to
a log file / SQL.

4) Alternatively, record this information at the top of every single
page (via an include), so each request for that page logs it.

Then hope you don't get a very busy site, as this is quite nasty
overhead to be performing for every single page request :-\

There are many ways to achieve what you wish, those are just a few.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



<    1   2   3   4   5   6   7   8   9   10   >