RE: [PHP] Apache

2013-09-24 Thread Arno Kuhl
On 23 Sep 2013, at 11:37, Domain nikha.org m...@nikha.org wrote:

 Tamara Temple am Montag, 23. September 2013 - 06:49:
 
 GoDaddy's default plesk-generated configuration for FastCGI-served 
 PHP
 files only looked to see if the file contained .php somewhere on 
 it's path - i.e. it would happily execute 'malicilous.php.txt' as php 
 code, even something ridiculous like 'malware.phpnoreallyiwantthistorun'.
 
 
 Yes, looks stupid.  
 But my service prodider wrote me this, I quote:
 ---QUOTE---
 This is because Apache offers features like language negotiation based 
 on extensions, too -- the final extension doesn't always just specify 
 the handler; it can specify other things. Apache can automatically 
 pick a German-language script from these, for example:
 
 file.php.de
 file.php.en
 
 Whether this is a good idea or not is debatable. It's possible to set 
 things up in a different way (using FilesMatch instead of AddHandler) 
 to avoid this particular problem, but that breaks other things, so 
 there's no perfect solution.
 
 More generally, the real problem is that scripts are looking at the 
 final extension of uploaded files to decide whether they're safe or 
 not, which is dangerous. They're simply assuming that a .gif file 
 can't run a PHP interpreter, for example... which is usually true, but 
 certainly not always: some people run all their files through PHP.
 ---END QUOTE---

This is somewhat daft. Yes, Apache offers this feature, but you don't need
to configure it to work will all extensions. I'd be curious to know what
their issue is with using FilesMatch, since that provides a way to disable
this behaviour. And, honestly, who would have a PHP file per language? I
think it's perfectly reasonable to not allow that, because duplicating PHP
code across many files is an incredible stupid way to support multiple
languages.

Some people run all their files through PHP - true, but that doesn't mean
they should, or that you, as a responsible web host, should be endorsing it.

 The problem is the weak PHP upload mechanism! 
 As workaround my service provider tries to block suspicious filenames, 
 but the PHP developpers themself should work on this severe security 
 problem.

PHP developers should absolutely validate all content coming in from users
in every possible way, but I would be highly dubious about trusting a host
who gives the reason above for what I consider a lax and insecure Apache
configuration. It's like saying they sliced your arm off with their chainsaw
because it's made for cutting things, attempting to dodge all responsibility
for having swung it in your direction!

-Stuart
--

It seems this is the standard apache configuration, but that's no excuse. 
Googling returned many results where this was described as a major security
threat
e.g. Beware of the default Apache 2 config for PHP
http://ilia.ws/archives/226-Beware-of-the-default-Apache-2-config-for-PHP.ht
ml
On that site the solution was to change AddHandler to AddType. 
My service provider is going the FilesMatch route.

Cheers
Arno


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



[PHP] Apache's PHP handlers

2013-09-19 Thread Arno Kuhl
For the past week I've been trying to get to the bottom of an exploit, but
googling hasn't been much help so far, nor has my service provider.
Basically a file was uploaded with the filename xxx.php.pgif which contained
nasty php code, and then the file was run directly from a browser. The
upload script used to upload this file checks that the upload filename
doesn't have a .php extension, which in this case it doesn't, so let it
through. I was under the impression apache would serve any file with an
extension not listed in its handlers directly back to the browser, but
instead it sent it to the php handler. Is this normal behaviour or is there
a problem with my service provider's apache configuration? Trying this on my
localhost returns the file contents directly to the browser as expected and
doesn't run the php code.

 

Cheers

Arno



RE: [PHP] Apache's PHP handlers

2013-09-19 Thread Arno Kuhl

-Original Message-
From: Ken Robinson [mailto:kenrb...@rbnsn.com] 
Sent: 19 September 2013 01:52 PM
To: a...@dotcontent.net
Cc: php-general@lists.php.net
Subject: Re: [PHP] Apache's PHP handlers

Check you .htaccess file. The hackers could have modified it to allow that
type of file to be executed. I had some that modified my .htaccess file to
go to a spam site when my site got a 404 error. That was nasty. 

Ken

Sent from my iPad

On Sep 19, 2013, at 7:35 AM, Arno Kuhl a...@dotcontent.net wrote:

 For the past week I've been trying to get to the bottom of an exploit, 
 but googling hasn't been much help so far, nor has my service provider.
 Basically a file was uploaded with the filename xxx.php.pgif which 
 contained nasty php code, and then the file was run directly from a 
 browser. The upload script used to upload this file checks that the 
 upload filename doesn't have a .php extension, which in this case it 
 doesn't, so let it through. I was under the impression apache would 
 serve any file with an extension not listed in its handlers directly 
 back to the browser, but instead it sent it to the php handler. Is 
 this normal behaviour or is there a problem with my service provider's 
 apache configuration? Trying this on my localhost returns the file 
 contents directly to the browser as expected and doesn't run the php code.
 
 
 
 Cheers
 
 Arno
  S

Hi Ken, .htaccess wasn't modified, this file was just uploaded and run. So
far all my service provider has told me is it was because the filename
contained .php in the filename, even though it's not the extension, and
that's the reason apache sent it to the php handler.  I'm sure that can't be
right, otherwise it would be open to all sorts of exploits.

Cheers
Arno



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



RE: [PHP] Apache's PHP handlers

2013-09-19 Thread Arno Kuhl
 For the past week I've been trying to get to the bottom of an exploit, but
 googling hasn't been much help so far, nor has my service provider.
 Basically a file was uploaded with the filename xxx.php.pgif which
contained
 nasty php code, and then the file was run directly from a browser. The
 upload script used to upload this file checks that the upload filename
 doesn't have a .php extension, which in this case it doesn't, so let it
 through. I was under the impression apache would serve any file with an
 extension not listed in its handlers directly back to the browser, but
 instead it sent it to the php handler. Is this normal behaviour or is
there
 a problem with my service provider's apache configuration? Trying this on 
 my localhost returns the file contents directly to the browser as expected

 and doesn't run the php code.
--

Arno,

the php file hidden as a gif will indeed not execute if opened directly from

your website. But if opened from a page hosted elsewhere with some code like

require($path_to_your_image), the php code inside the image will be sent to 
the php handler and will be executed.

Prevention is the best way to avoid hacking from image upload. Check the 
file extention and the file content before upload.

Cheers.
Steven 
-- 

Hi Steven, I agree the best way to avoid this is for the file upload script
to check the file contents and that's something I'll have to sort out,
currently it just checks the extension. But it's still a concern that a file
with any arbitrary extension can be processed as php script as long as it
has the text .php in the filename. I'm not worried about including the
file because that would require pre-existing malicious php code, I want to
prevent that malicious php code from running in the first place.

Cheers
Arno


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



RE: [PHP] Apache's PHP handlers

2013-09-19 Thread Arno Kuhl
Arno: If you can request that file using a web browser, and it gets executed
as PHP on your server then there is an error in the Apache configuration.

Easy test: create a file in a text editor containing some PHP (?php
phpinfo(); ? would be enough) and upload it to the www root of your site
and name it test.pgif. Then hit http://www.yourdomain.com/test.pgif in your
browser. If you see the PHP code or an error then you're fine. If you see
PHP's info page then you need to change web host as quickly as possible. I
don't care if they fix it - the fact their server was configured to do this
by default is enough for me to never trust them again.

-Stuart
--

Thanks Stuart. I just tried it now, test.php.pgif displayed the info while
test.xyz.pgif returned the content, confirming the problem. My service
provider finally conceded the problem is on their side and are looking for
an urgent fix, much too complicated to consider moving service providers in
the short term.

As a side note, the sp said the issue is new and coincided with an upgrade
to fastcgi recently, I wonder if the hacker was exploiting a known issue
with that scenario?

Cheers
Arno


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



RE: [PHP] significance of escape character in string in PHP - MySQL

2013-03-18 Thread Arno Kuhl
There's no need for it to be a flame war. The mysql extension is officially
not recommended for writing new code, so anyone using it should be informed
of this fact. I think it should consist of more than don't use that, but
at the very least that should cause the questioner to want to know why.

http://php.net/intro.mysql

This issue is problematic for exactly the reason Norah demonstrates above:
it's working. Great that in this case it hasn't been left at that, but
most will see it work and think they've got it right. I believe the
community has a responsibility to give good advice and recommend best
practices as well as directly addressing people's problems, so it's right
that things like this get repeatedly pointed out where appropriate.

-Stuart
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--

Thanks, didn't know about this. No doubt it's been general news for months
or years but I see the PHP manual page you linked to was edited 3 days ago.
Will have to see what ADOdb is doing - the last release I saw didn't support
PDO_MySQL or mysqli. I googled and saw a first release of 5.5 will be this
month?

Cheers
Arno


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



RE: [PHP] Re: UNLESS Statement Equivalent

2013-03-12 Thread Arno Kuhl
-Original Message-
From: Ford, Mike [mailto:m.f...@leedsmet.ac.uk] 
Sent: 12 March 2013 10:51 AM
To: PHP General
Subject: RE: [PHP] Re: UNLESS Statement Equivalent

 unless ( $a and $b )
 =
 if ( ! ($a and $b) )
 
 So in simple terms, just stick a ! (or the keyword not) in front of 
 your expression, and you'll have exactly what you want:
 if( not ( ($current_page == $saved_page) and ($current_ip ==
 $saved_ip)
 and ($current_dt  ($saved_dt + 3600) ) ) {

Whilst this is true as far as it goes, I would suggest applying deMorgan's
laws to simplify slightly to

   if ( ($current_page != $saved_page) or ($current_ip != $saved_ip) or
($current_dt = ($saved_dt + 3600) ) )

Also, the keyword versions of the Boolean operators are very low priority,
which is why you need all those extra parentheses -- if you switch to the
symbolic versions, you can leave all the internal parentheses out to give:

   if ($current_page != $saved_page || $current_ip != $saved_ip ||
$current_dt = $saved_dt + 3600)

Cheers!
Mike
--

Mike, I presume you're saying the precedence of the Boolean keyword
operators is lower than the Boolean symbol operators, but if so then
wouldn't there be less need for the parentheses? I prefer using the Boolean
keyword operators for both the readability and because of the lower
precedence. Unless I've been wrong all this while and the keyword precedence
is actually higher?

Cheers
Arno


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



RE: [PHP] Re: UNLESS Statement Equivalent

2013-03-12 Thread Arno Kuhl
-Original Message-
From: Ford, Mike [mailto:m.f...@leedsmet.ac.uk]
Sent: 12 March 2013 10:51 AM
To: PHP General
Subject: RE: [PHP] Re: UNLESS Statement Equivalent

 unless ( $a and $b )
 =
 if ( ! ($a and $b) )
 
 So in simple terms, just stick a ! (or the keyword not) in front of 
 your expression, and you'll have exactly what you want:
 if( not ( ($current_page == $saved_page) and ($current_ip ==
 $saved_ip)
 and ($current_dt  ($saved_dt + 3600) ) ) {

Whilst this is true as far as it goes, I would suggest applying deMorgan's
laws to simplify slightly to

   if ( ($current_page != $saved_page) or ($current_ip != $saved_ip) or
($current_dt = ($saved_dt + 3600) ) )

Also, the keyword versions of the Boolean operators are very low priority,
which is why you need all those extra parentheses -- if you switch to the
symbolic versions, you can leave all the internal parentheses out to give:

   if ($current_page != $saved_page || $current_ip != $saved_ip ||
$current_dt = $saved_dt + 3600)

Cheers!
Mike
--

Mike, I presume you're saying the precedence of the Boolean keyword
operators is lower than the Boolean symbol operators, but if so then
wouldn't there be less need for the parentheses? I prefer using the Boolean
keyword operators for both the readability and because of the lower
precedence. Unless I've been wrong all this while and the keyword precedence
is actually higher?

Cheers
Arno
--

I checked the manual, the Boolean symbol operators have a higher precedence
than ternary and assignment, while the Boolean keyword operators have the
lowest precedence. So using Boolean keyword operators should obviate
internal parentheses.

Cheers
Arno


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



RE: [PHP] Some date() oddities

2013-01-09 Thread Arno Kuhl
On Tue, 8 Jan 2013, Arno Kuhl wrote:

 Starting with a unix timestamp for 31 December 2012 13:12:12 (which is
 1356952332) I calculate a week number:

 $ux_date = 1356952332;

 $weeknumber = date(W, $ux_date);   // returns 01 instead of 52

I'm not that familiar with date, I tend to use strftime myself (no idea why
there's both).  Sounds like date's W is equivalent to strftime's %V which
does indeed return 01 for this date as there's at least 4 days of the new
year in that particular week.

Both %U and %W seem to return what you want, using strftime.  I'd guess that
date would also have flags for these.

Cheers,
Geoff.
--

Thanks Geoff, that's what I was looking for.

Cheers
Arno


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



[PHP] Some date() oddities

2013-01-08 Thread Arno Kuhl
I've bumped into an odd result with the date() function that I can't make
sense of.

 

Starting with a unix timestamp for 31 December 2012 13:12:12 (which is
1356952332) I calculate a week number:

$ux_date = 1356952332;

$weeknumber = date(W, $ux_date);   // returns 01 instead of 52

 

I found some warnings regarding ISO8601 for this in the user notes for the
date() function in the PHP manual but couldn't see how this is managed in
code, does anyone know of a workaround for this?

 

Cheers

Arno

 

 



RE: [PHP] Unexpected Notice message

2012-07-05 Thread Arno Kuhl
-Original Message-
From: Tim Streater [mailto:t...@clothears.org.uk] 
Sent: 04 July 2012 06:56 PM
To: Marc Guay; php-general@lists.php.net
Subject: Re: [PHP] Unexpected Notice message

On 04 Jul 2012 at 16:51, Marc Guay marc.g...@gmail.com wrote: 

 Notice: Use of undefined constant QUERY_STRING - assumed 'QUERY_STRING' in

 I would guess that it's asking you to add quotes around QUERY_STRING...?

As in:
if (strlen($_SERVER['QUERY_STRING'])  0) {


Cheers  --  Tim


Excellent, a bit surprised but that was it, thanks a lot.

Cheers
Arno


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



[PHP] Unexpected Notice message

2012-07-04 Thread Arno Kuhl
I'm a bit baffled by a notice message displayed:
Notice: Use of undefined constant QUERY_STRING - assumed 'QUERY_STRING' in
..

The line in question has
if (strlen($_SERVER[QUERY_STRING])  0) {
..

So I set a breakpoint on the line of the notice. The code executes to the
breakpoint, I inspect the $_SERVER[QUERY_STRING] and it's got the expected
value, it only executes that line once (never gets to that breakpoint
again), and yet I get the notice message. Can anyone give me an idea what's
going on here?

Cheers
Arno


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



RE: [PHP] Watch out for automatic type casting

2012-03-30 Thread Arno Kuhl
-Original Message-
From: Simon Schick [mailto:simonsimc...@googlemail.com] 
Sent: 29 March 2012 07:19 PM
To: a...@dotcontent.net
Cc: php-general@lists.php.net
Subject: Re: [PHP] Watch out for automatic type casting

Hi, Arno

FYI: I found a page in the php-manual that's exactly for that:
http://www.php.net/manual/en/language.operators.precedence.php

p.s. some of them were also new to me  Thanks for getting me to read it.

Bye
Simon


Thanks Simon and others, thought it was typecasting, but precedence makes more 
sense.

I remember seeing that table when I first started using php, which is why I 
always use AND and OR rather than  and || because it's lower precedence than 
the assignment and the ternary operators, but I couldn't remember where I'd 
seen it. So thanks for linking to it.

Cheers
Arno


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



RE: [PHP] Watch out for automatic type casting

2012-03-30 Thread Arno Kuhl
-Original Message-
From: Simon Schick [mailto:simonsimc...@googlemail.com]
Sent: 29 March 2012 07:19 PM
To: a...@dotcontent.net
Cc: php-general@lists.php.net
Subject: Re: [PHP] Watch out for automatic type casting

Hi, Arno

FYI: I found a page in the php-manual that's exactly for that:
http://www.php.net/manual/en/language.operators.precedence.php

p.s. some of them were also new to me  Thanks for getting me to read it.

Bye
Simon


Thanks Simon and others, thought it was typecasting, but precedence makes more 
sense.

I remember seeing that table when I first started using php, which is why I 
always use AND and OR rather than  and || because it's lower precedence than 
the assignment and the ternary operators, but I couldn't remember where I'd 
seen it. So thanks for linking to it.

Cheers
Arno
--

BTW interesting to note on that precedence page that ! has a higher 
precedence than = (which you'd expect it to be) but you can still do 
if (!$a = foo())

I use that form often (as I'm sure many others do) and just took it for granted 
that it works even though the order of precedence says it shouldn't.

It could be expanded to
if ($a = foo() != TRUE)
But that wouldn't get the expected result due to order of precedence, though at 
first glance you could reasonably expect it to work because of 
if (!$a = foo())
being valid.

I think that's why it's so easy to be caught out (at least for me) by the 
similar form of
if ( $pos = strpos($sText, test) !== FALSE)

Cheers
Arno


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



[PHP] Watch out for automatic type casting

2012-03-29 Thread Arno Kuhl
I found automatic typecasting can be a bit of a gotcha.

 

$sText = this.is.a.test.text;

if ( $pos = strpos($sText, test) !== FALSE) {

echo  substr($sText, 0, $pos)..substr($sText, $pos,
strlen(test))..substr($sText, $pos+strlen(test));

}

 

The code seems logical enough, and the expected result would be:

this.is.a.test.text

 

In fact it ends up being:

this.is.a.test.text

 

The reason is $pos is typecast as TRUE, not int 10, presumably because it's
in the same scope as the boolean test.

Then when $pos is later used as an int it's converted from TRUE to 1.

 

You have to bracket the $pos setting to move it into its own scope to
prevent it being typecast:

if ( ($pos = strpos($sText, test)) !== FALSE) {

 

No doubt it's mentioned somewhere in the php manual, I just never came
across it.

Just thought I'd highlight one of the gotchas of auto typecasting for any
other simpletons like me.

 

Cheers

Arno



RE: [PHP] foreach weirdness

2012-03-26 Thread Arno Kuhl
Requesting that will at least require a major-release (f.e. PHP 6.0) ... but I 
would rather request to add a notice or warning to the documentation of 
references to remind stuff like that.
http://www.php.net/manual/en/language.references.php
I think this is stuff more people will stumble over ...

Bye
Simon
--

I agree it would be wrong to change php's handling of call by reference in 
foreach loops because there may be a need to access that reference after 
completing the loop. I was going to suggest there should be a warning in the 
manual to unset the reference after the foreach loop is completed, but I see 
the current online manual has that warning prominently displayed on the foreach 
page. I had a version of the manual from July last year that didn't have the 
warning, so I'll update my local manual and make sure I keep it up to date. 
Lesson learned (both manual and foreach references).

Cheers
Arno


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



RE: [PHP] foreach weirdness

2012-03-26 Thread Arno Kuhl
Note that somewhat similar error was discussed on this list a few months 
ago[1]. You could probably have solved it yourself if you searched the mailing 
list archives.

- Matijn

[1] http://www.mail-archive.com/php-general@lists.php.net/msg269552.html
---

Thanks Matijn, I missed that discussion, not following the list that actively. 
I'll try search next time before raising an issue.

Cheers
Arno


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



RE: [PHP] foreach weirdness

2012-03-25 Thread Arno Kuhl
 See this following example that illustrates the problem:
 $array = array(0, 1, 2, 3, 4, 5, 6);
 foreach ($array as $index=$value) { 
   if ( ($index+1)  count($array) ) { 
   $array[$index+1] += $value; 
   } 
   echo $value. ;
 }
 echo br /;
 foreach ($array as $index=$value) { 
   echo $value. ;
 }
 
 You'd expect the output to be: 
 0 1 3 6 10 15 21
 0 1 3 6 10 15 21
 
 But it's actually: 
 0 1 2 3 4 5 6
 0 1 3 5 7 9 11

Hey,

the ouput you get is right. If you want your ouput you have to rewrite your 
code.
Currently you are adding the value of the current index to the next indexes 
value (e.g. $array[0] + $array[1]; $array[1] + $array[2]; etc.).
As I understand it you want to add the current value with the next index (e.g. 
$array[0] + 1; $array[1] + 2; $array[2] + 3).
--

Hi Stephan, the first foreach loop adds the next value to the current value, 
not the next index. The reason you don't get the expected result in the first 
foreach loop is because you need to assign the $value by reference, as per the 
php manual
foreach ($array as $index=$value) 

But then to get the correct output from the second simple foreach loop, you 
also have to assign the $value by reference, contrary to the php manual. If you 
don't you get the wrong result and the array becomes corrupted. That could be 
classified as a bug, or at least the manual needs to elaborate on using a 
foreach when you assign the $value by reference.

Cheers
Arno


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



RE: [PHP] foreach weirdness

2012-03-25 Thread Arno Kuhl
From: Simon Schick [mailto:simonsimc...@googlemail.com] 
Sent: 24 March 2012 12:30 AM
To: Robert Cummings
Cc: a...@dotcontent.net; php-general@lists.php.net
Subject: Re: [PHP] foreach weirdness

2012/3/23 Robert Cummings rob...@interjinn.com

 On 12-03-23 11:16 AM, Arno Kuhl wrote:


 it still does not produce the correct result:
 0 1 3 6 10 15 21
 0 1 3 6 10 15 15


 This looks like a bug... the last row should be the same. What version 
 of PHP are you using? Have you checked the online bug reports?



Hi, Robert

Does not seem like a bug to me ...
http://schlueters.de/blog/archives/141-References-and-foreach.html

What you should do to get the expected result:
Unset the variable after you don't need this reference any longer.

Bye
Simon

--

Hi Simon, unsetting the $value does fix the problem, but I found that any time 
you assign $value by reference in a foreach loop you have to do an unset to 
avoid corrupting the array unless you continue to assign $value by reference 
(as illustrated in the article you linked).
 
So doing something as simple as:
$array = array(0, 1, 2, 3, 4, 5, 6);
foreach ($array as $key=$value) {
echo Key: $key; Value: $valuebr /\n;
}

and then follow with (from the php manual):
foreach ($array as $key=$value) {
echo Key: $key; Value: $valuebr /\n;
}

will not only give the wrong result, it will corrupt the array for *any* 
further use of that array. I still think it’s a bug according to the definition 
of foreach in the php manual. Maybe php needs to do an implicit unset at the 
closing brace of the foreach where was an assign $value by reference, to remove 
the reference to the last element (or whatever element it was pointing to if 
there was a break) so that it doesn't corrupt the array, because any assign to 
$value after the foreach loop is completed will corrupt the array (confirmed by 
testing). The average user (like me) wouldn't think twice about reusing $value 
after ending the foreach loop, not realising that without an unset the array 
will be corrupted.

BTW thanks for that reference, it was quite an eye-opener on the pitfalls of 
using assign by reference, not only in the foreach loop.

Cheers
Arno


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



[PHP] foreach weirdness

2012-03-23 Thread Arno Kuhl
The following snippet is copied from the php manual:
foreach ($arr as $key = $value) {
echo Key: $key; Value: $valuebr /\n;
}

I've always used the foreach loop that way.
But recently I started hitting some really odd problems.

See this following example that illustrates the problem:
$array = array(0, 1, 2, 3, 4, 5, 6); 
foreach ($array as $index=$value) { 
if ( ($index+1)  count($array) ) { 
$array[$index+1] += $value; 
} 
echo $value. ; 
} 
echo br /; 
foreach ($array as $index=$value) { 
echo $value. ; 
} 

You'd expect the output to be: 
0 1 3 6 10 15 21 
0 1 3 6 10 15 21 

But it's actually: 
0 1 2 3 4 5 6 
0 1 3 5 7 9 11 

If you assign the $value by reference in the first loop as someone pointed
out (and confirmed by the manual: As of PHP 5, you can easily modify
array's elements by preceding $value with . This will assign reference
instead of copying the value)

$array = array(0, 1, 2, 3, 4, 5, 6); 
foreach ($array as $index=$value) {// - assign $value by reference
if ( ($index+1)  count($array) ) { 
$array[$index+1] += $value; 
} 
echo $value. ; 
} 
echo br /; 
foreach ($array as $index=$value) { 
echo $value. ; 
} 

it still does not produce the correct result: 
0 1 3 6 10 15 21 
0 1 3 6 10 15 15 

If I watch the $array in a debugger I see odd behaviour for the last element
$array[6] when stepping through the second foreach loop. 
Just before entering the second loop $array[6] == 21 which is correct. 
When I move to the next line (echo $value. ;)  $array[6] changes to 0 !! 
As I step through the second loop $array[6] keeps on changing for each
iteration, with the following values: 
0, 1, 3, 6, 10, 15, 15 
And once I've left the second loop $array[6] is permanently changed from 21
to 15, even though there's no code in the second loop to change $array[6]. 
So what's going on here? 

I confirm this by echoing $array[6] in each iteration in the second loop: 
$array = array(0, 1, 2, 3, 4, 5, 6); 
foreach ($array as $index=$value) {
if ( ($index+1)  count($array) ) { 
$array[$index+1] += $value; 
} 
echo $value. ; 
} 
echo br /; 
foreach ($array as $index=$value) { 
echo $array[6]. ; 
} 
echo br /; 
echo $array[6]; 

the result is: 
0 1 3 6 10 15 21 
0 1 3 6 10 15 15 
15

Note that $array[6] is still 15 even after completing the second foreach
loop.
If you break out of the second loop then $array[6] will be at whatever value
it was at the time you break out (ouch!)

If you assign the $value by reference in the second loop as well: 
$array = array(0, 1, 2, 3, 4, 5, 6); 
foreach ($array as $index=$value) { 
if ( ($index+1)  count($array) ) { 
$array[$index+1] += $value; 
} 
echo $value. ; 
} 
echo br /; 
foreach ($array as $index=$value) {// - assign $value by reference
echo $array[6]. ; 
} 
echo br /; 
echo $array[6]; 

you finally get the correct result: 
0 1 3 6 10 15 21 
21 21 21 21 21 21 21 
21

You can test this with multiple foreach loops and get the same results. If
you modify the array in the first foreach loop, then use an assign $value by
reference in the next 9 foreach loops to get the correct values (without
modifying the array), and then in the 10th foreach loop you don't use an
assign $value by reference (without modifying the array), the array becomes
corrupted.

I sort of understand the need to assign the $value by reference in the first
loop, but why is it also required in every subsequent loop where the array
is not being modified? Especially since all the examples in the manual show
it's not needed? It would appear that once you've modified an array's
elements in a foreach loop you always have to assign $value by reference in
any subsequent foreach loop using that array. And if you don't, not only
will you get the wrong results but the array itself is actually altered,
even if there's no code in the loop to alter it. Is that correct or is it a
bug? At what stage can you start using the array in the normal way again?
That could create hair-pulling havoc for anyone maintaining code if they
haven't noticed that somewhere previously there was code that modified the
array in a foreach loop. Maybe the answer is to always assign $value by
reference in a foreach loop regardless of what you do in that loop, but I'm
not sure what the implications are.

Cheers
Arno


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



RE: [PHP] foreach weirdness

2012-03-23 Thread Arno Kuhl
-Original Message-
From: Robert Cummings [mailto:rob...@interjinn.com] 
Sent: 23 March 2012 06:11 PM
To: a...@dotcontent.net
Cc: php-general@lists.php.net
Subject: Re: [PHP] foreach weirdness

On 12-03-23 11:16 AM, Arno Kuhl wrote:
 The following snippet is copied from the php manual:
 foreach ($arr as $key =  $value) {
   echo Key: $key; Value: $valuebr /\n; }

 I've always used the foreach loop that way.
 But recently I started hitting some really odd problems.

 See this following example that illustrates the problem:
 $array = array(0, 1, 2, 3, 4, 5, 6);
 foreach ($array as $index=$value) {//- assign $value by reference
   if ( ($index+1)  count($array) ) {
   $array[$index+1] += $value;
   }
   echo $value. ;
 }
 echo br /;
 foreach ($array as $index=$value) {
   echo $value. ;
 }

 it still does not produce the correct result:
 0 1 3 6 10 15 21
 0 1 3 6 10 15 15

This looks like a bug... the last row should be the same. What version of PHP 
are you using? Have you checked the online bug reports?

.
--

Hi Rob

I'm using php 5.3.5. What result do you get when you run this code?
I haven't checked any bug reports, I'll google to see where I would do that.

Your code gets round the problem, but I was specifically referring to the use 
of foreach with its unexpected side-effects. There are a few different designs 
like look-ahead where it seemed the obvious way to go. I know I've used this 
type of foreach coding in the past, and have this nagging feeling there's a 
whole bunch of code just waiting to explode. I always just assumed it worked 
because it's pretty simple. I'd previously been caught out forgetting the 
assign by reference in the foreach loop that modified the array but I always 
caught it long before it went live, but I never considered having to also use 
assign by reference in subsequent foreach loops because it so obviously wasn't 
necessary. Now I'm searching through my scripts to see if there are any 
potential problems caused by this (already found one), and wondering what else 
I've done where I no longer have access to the sources.

BTW I'm told on another forum this issue has been discussed multiple times on 
this mailing list - did I miss it? Was there a resolution?

Cheers
Arno


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



RE: [PHP] Getting knotted with quotes encoding - (one possible solution)

2012-03-19 Thread Arno Kuhl
-Original Message-
From: tamouse mailing lists [mailto:tamouse.li...@gmail.com] 
Sent: 19 March 2012 10:28 AM
To: php-general@lists.php.net
Subject: Re: [PHP] Getting knotted with quotes encoding - (one possible 
solution)

On Sun, Mar 18, 2012 at 10:19 PM, Tamara Temple 
tamouse.li...@tamaratemple.com wrote:
 On Tue, 13 Mar 2012 16:35:44 +0200, Arno Kuhl a...@dotcontent.net sent:

 From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
 Sent: 13 March 2012 03:25 PM
 To: a...@dotcontent.net; php-general@lists.php.net
 Subject: Re: [PHP] Getting knotted with quotes encoding


 Arno Kuhl a...@dotcontent.net wrote:

 I've been battling with quotes encoding when outputting javascript 
 with php.
 It can't be unique, so I'm hoping someone has a working solution 
 they're willing to share.

 The following works perfectly as long as there aren't any single 
 quotes in the link text:
echo span onclick=\insertLink('$sUrl','$sTitle')\
 class='linkSel'$sTitle/span;

 if $sTitle has the valueWhat's newit outputs:
span 
 onclick=insertLink('article/whats-new.html','What#039;s
 new') class='linkSel'What#039;s new/span

 It displays fine, but javascript complains with:
Expected ')'  linkmanager.php Line:525 Char:63


 So I fix this by swapping the double and single quotes around:
echo span onclick='insertLink(\$sUrl\,\$sTitle\)'
 class='linkSel'$sTitle/span;

 Now for that specific link it outputs:
span 
 onclick='insertLink(article/whats-new.html,What#039;s
 new)' class='linkSel'What#039;s new/span And javascript is happy.

 But elsewhere there's a link Fred Buster Cox and it outputs:
span 
 onclick='insertLink(article/fred-buster-cox.html,Fred
 quot;Busterquot; Cox)' class='linkSel'Fred quot;Busterquot; 
 Cox/span

 Again it displays fine, but javascript complains with:
Expected ')'  linkmanager.php Line:743 Char:77


 So it looks like I can't have links that include single quotes and 
 double quotes, only one or the other.

 One work-around I thought of was to convert any link texts that 
 included double quotes into single quotes when the content is 
 posted, and it would then be displayed with single quotes even 
 though the user entered double quotes. It's far from ideal but it 
 would work, though I can think of a few situations where it would be 
 quite confusing to the reader. Are there any other solutions that 
 would allow both types of quotes without any conversions?

 Cheers
 Arno


 --


 You aren't escaping the quotes correctly when they go into your  output.
 You're escaping them for html not javascript. Javascript  (like php) 
 escapes single quotes inside a single quote string with a  back slash.


  Thanks,
 Ash
 http://ashleysheridan.co.uk
 -

 Thanks for that Ashley.
 You're right about the encoding.
 I had a line prior to that:
$sTitle = htmlentities($title, ENT_QUOTES, 'ISO-8859-1', 
 FALSE); Which encoded the quotes.


 I couldn't find anything so made a function, which might be useful  
 for others.
 It’s a first shot, I'm sure there are ways to improve performance.
 I also changed the encoding to exclude single quotes.
 (I'm sure the indenting will get screwed up in the mail)


 $sTitle = fixSingleQuotes(htmlentities($title, ENT_COMPAT,  
 'ISO-8859-1', FALSE));

 .


 /
 /// // convert single quotes to curly quotes, xml compliant 
 // assumes apostrophes must be between 2 alpha chars // and any other 
 ' is a single quote // #8216; = left single quote // #8217; = right 
 single quote and apostrophe function fixSingleQuotes($sText) {
if (strpos($sText, ') !== FALSE) {
// there are quotes to convert
$bOpenQuote = FALSE;
$arrAlpha = explode(' ', a b c d e f g h i j k l m n 
 o p q r s t  u v w x y z A B C D E F G H I J K L M N O P Q R S T U V 
 W X Y Z);
$arrText = str_split($sText);
while (($pos = strpos($sText, ')) !== FALSE) {
if ($pos == 0) {
// must be an open quote in first pos
$sText = #8216;.substr($sText, 1);
$bOpenQuote = TRUE;
} else {
if (in_array($arrText[$pos-1], 
 $arrAlpha)
  AND   in_array($arrText[$pos+1], $arrAlpha)) {
// apostrophe
$quote = #8217;;
} else {
// quote
if (!$bOpenQuote) {
$quote = #8216;;
$bOpenQuote = TRUE;
} else {
$quote = #8217

[PHP] Getting knotted with quotes encoding

2012-03-13 Thread Arno Kuhl
I've been battling with quotes encoding when outputting javascript with php.
It can't be unique, so I'm hoping someone has a working solution they're
willing to share.

The following works perfectly as long as there aren't any single quotes in
the link text:
echo span onclick=\insertLink('$sUrl','$sTitle')\
class='linkSel'$sTitle/span;

if $sTitle has the valueWhat's newit outputs:
span onclick=insertLink('article/whats-new.html','What#039;s
new') class='linkSel'What#039;s new/span

It displays fine, but javascript complains with:
Expected ')'  linkmanager.php Line:525 Char:63


So I fix this by swapping the double and single quotes around:
echo span onclick='insertLink(\$sUrl\,\$sTitle\)'
class='linkSel'$sTitle/span;

Now for that specific link it outputs: 
span onclick='insertLink(article/whats-new.html,What#039;s
new)' class='linkSel'What#039;s new/span
And javascript is happy.

But elsewhere there's a link Fred Buster Cox and it outputs:
span onclick='insertLink(article/fred-buster-cox.html,Fred
quot;Busterquot; Cox)' class='linkSel'Fred quot;Busterquot; Cox/span

Again it displays fine, but javascript complains with:
Expected ')'  linkmanager.php Line:743 Char:77


So it looks like I can't have links that include single quotes and double
quotes, only one or the other.

One work-around I thought of was to convert any link texts that included
double quotes into single quotes when the content is posted, and it would
then be displayed with single quotes even though the user entered double
quotes. It's far from ideal but it would work, though I can think of a few
situations where it would be quite confusing to the reader. Are there any
other solutions that would allow both types of quotes without any
conversions?

Cheers
Arno


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



RE: [PHP] Getting knotted with quotes encoding - (one possible solution)

2012-03-13 Thread Arno Kuhl
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 13 March 2012 03:25 PM
To: a...@dotcontent.net; php-general@lists.php.net
Subject: Re: [PHP] Getting knotted with quotes encoding


Arno Kuhl a...@dotcontent.net wrote:

I've been battling with quotes encoding when outputting javascript with 
php.
It can't be unique, so I'm hoping someone has a working solution 
they're willing to share.

The following works perfectly as long as there aren't any single quotes 
in the link text:
   echo span onclick=\insertLink('$sUrl','$sTitle')\
class='linkSel'$sTitle/span;

if $sTitle has the valueWhat's newit outputs:
   span onclick=insertLink('article/whats-new.html','What#039;s
new') class='linkSel'What#039;s new/span

It displays fine, but javascript complains with:
   Expected ')'  linkmanager.php Line:525 Char:63


So I fix this by swapping the double and single quotes around:
   echo span onclick='insertLink(\$sUrl\,\$sTitle\)'
class='linkSel'$sTitle/span;

Now for that specific link it outputs: 
   span onclick='insertLink(article/whats-new.html,What#039;s
new)' class='linkSel'What#039;s new/span And javascript is happy.

But elsewhere there's a link Fred Buster Cox and it outputs:
   span onclick='insertLink(article/fred-buster-cox.html,Fred
quot;Busterquot; Cox)' class='linkSel'Fred quot;Busterquot; 
Cox/span

Again it displays fine, but javascript complains with:
   Expected ')'  linkmanager.php Line:743 Char:77


So it looks like I can't have links that include single quotes and 
double quotes, only one or the other.

One work-around I thought of was to convert any link texts that 
included double quotes into single quotes when the content is posted, 
and it would then be displayed with single quotes even though the user 
entered double quotes. It's far from ideal but it would work, though I 
can think of a few situations where it would be quite confusing to the 
reader. Are there any other solutions that would allow both types of 
quotes without any conversions?

Cheers
Arno


--

You aren't escaping the quotes correctly when they go into your output. You're 
escaping them for html not javascript. Javascript (like php) escapes single 
quotes inside a single quote string with a back slash.


 Thanks,
Ash
http://ashleysheridan.co.uk
-

Thanks for that Ashley.
You're right about the encoding.
I had a line prior to that:
$sTitle = htmlentities($title, ENT_QUOTES, 'ISO-8859-1', FALSE);
Which encoded the quotes.


I couldn't find anything so made a function, which might be useful for others.
It’s a first shot, I'm sure there are ways to improve performance.
I also changed the encoding to exclude single quotes.
(I'm sure the indenting will get screwed up in the mail)


$sTitle = fixSingleQuotes(htmlentities($title, ENT_COMPAT, 'ISO-8859-1', 
FALSE));

.


// convert single quotes to curly quotes, xml compliant
// assumes apostrophes must be between 2 alpha chars
// and any other ' is a single quote
// #8216; = left single quote
// #8217; = right single quote and apostrophe
function fixSingleQuotes($sText)
{
if (strpos($sText, ') !== FALSE) {
// there are quotes to convert
$bOpenQuote = FALSE;
$arrAlpha = explode(' ', a b c d e f g h i j k l m n o p q r s 
t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z);
$arrText = str_split($sText);
while (($pos = strpos($sText, ')) !== FALSE) {
if ($pos == 0) {
// must be an open quote in first pos
$sText = #8216;.substr($sText, 1);
$bOpenQuote = TRUE;
} else {
if (in_array($arrText[$pos-1], $arrAlpha)  AND  
in_array($arrText[$pos+1], $arrAlpha)) {
// apostrophe
$quote = #8217;;
} else {
// quote
if (!$bOpenQuote) {
$quote = #8216;;
$bOpenQuote = TRUE;
} else {
$quote = #8217;;
$bOpenQuote = FALSE;
}
}
$sText = substr($sText, 0, 
$pos).$quote.substr($sText, $pos+1);
}
}
}
return ($sText);

} //fixSingleQuotes()



Cheers
Arno


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



[PHP] ip2long and ipv6

2012-01-09 Thread Arno Kuhl
My dev and test tools are windows based and the apps deployed on linux, and
it's been working well. But moving to win7 created problems because it uses
ipv6 and code for ratings is for ipv4. Specifically, using ip2long to save
the ip as an int (to prevent duplicate votes) doesn't work in test
(win7/php5.3). I've got a quick-n-dirty workaround (::1 converted to 0)
but it seemed a good opportunity to add code to handle ipv6 properly when
it's deployed.

I found a reference to do that in the help
(http://php.net/manual/en/function.ip2long.php), but the referenced site no
longer exists. I also found a page where Daniel Brown mentions that user
notes referencing external sites are normally removed
(http://www.lmpx.com/nav/article.php/news.php.net/php.notes/177158/read/inde
x.html) but that the note added enough value to make an exception. I'd be
very grateful if anyone could please point me to any other record of this
code, or could post it if they have a copy.

Also, I'm assuming the code returns 2 ints because of the size of ipv6, and
it's fine to change my code to store that, but I'd like to know if there's a
standard way to store ip addresses in sql for quick lookup?

Cheers
Arno



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



RE: [PHP] Seeking strategy/algorithm for maintaining order of records

2011-10-17 Thread Arno Kuhl
From: Stephen [mailto:stephe...@rogers.com] 
Sent: 16 October 2011 11:33 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Seeking strategy/algorithm for maintaining order of
records

Displaying in an order is easy when you have a field called order.

SELECT descriptions FROM categories ORDER by order;

My issue is, say I have three records:

ID CategoryOrder

1BW1
2Landscapes 2
3Nudes  3

I am looking for the best way to be able to change the values to

ID CategoryOrder

1BW3
2Landscapes 2
3Nudes  1

Dynamically building a form, entering the new order value, and then looping
through the post, with a SQL UPDATE is the best I can come up with.

A future issue will be doing the same to the table category-photograph

ID Category_id photo_id order

This table is needed to allow a photograph to be in more than one category.

Cheers
Stephen

-- 

One way would be to use ajax. Each time a photo is moved up or down the
order list you issue an ajax request to update the order. That way your php
script only needs to deal with 2 records at a time and switch their order
values.

Besides that, I can't think of any way of processing a form with multiple
order changes other than looping through the post the way you described.

Cheers
Arno


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



RE: [PHP] Dennis Ritchie, Father of Unix and C programming language, dead at 70

2011-10-15 Thread Arno Kuhl
-Original Message-
From: Daevid Vincent [mailto:dae...@daevid.com] 
Sent: 14 October 2011 12:08 AM
To: php-general@lists.php.net
Subject: [PHP] Dennis Ritchie, Father of Unix and C programming language,
dead at 70

#include stdio.h
 
int main()
{
   printf(R.I.P. Dennis Ritchie: 1941-2011\n);
   return 0;
}
 
http://www.networkworld.com/news/2011/101311-ritchie-251936.html

===

He might have put it a bit differently:

int main()
{
   printf(Goodbye world\n);
   return 0;
} 



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



RE: [PHP] Check for open file

2011-03-04 Thread Arno Kuhl
 -Original Message-
 From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
 Sent: Thursday, March 03, 2011 2:03 PM
 To: sstap...@mnsi.net
 Cc: php-general@lists.php.net
 Subject: RE: [PHP] Check for open file
 
 
 As far as I was aware, if you're in the middle of writing to a file 
 and another script was attempting to write to it, the OS would prevent 
 that as you had an open lock on it.
 
 --
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 

And as it turned out, that was not the case.  I started copying a
200MiB file from my desktop machine onto the Samba share.  While that was
copying, I got onto the server and tried to copy the file to /tmp and it
happily did that for me without any indication that it was still being
written to (which is was by the way.)  So, that's not a good way of dealing
with this.

I think I'm going to have to go with a time delay function here ...


--

There are potential problems using timing delays, and networking compounds
them. It might be more robust to use some simple method outside of php to
indicate a file is busy being copied, like using a reserved extension for
the copy and then renaming to the proper filename after the copy is
complete, or copying to a temp directory and then moving the file to the
destination directory once copied (renames and moves take milliseconds).
Assuming you're able to automate the copy process.

Cheers
Arno



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



RE: [PHP] Paging and permissions

2011-02-09 Thread Arno Kuhl
On Tue, 2011-02-08 at 14:36 +0200, Arno Kuhl wrote: 

I'm hoping some clever php gurus have been here before and are
willing to
share some ideas.
 
I have a site where articles are assigned to categories in
containers. An
article can be assigned to only one category per container, but one
or more
containers. Access permissions can be set per article, per category
and/or
per container, for one or more users and/or user groups. If an
article is
assigned to 10 categories and only one of those has a permission
denying
access, then the article can't be accessed even if browsing through
one of
the other 9 categories. Currently everything works fine, with
article titles
showing when browsing through category or search result lists, and a
message
is displayed when the article is clicked if it cannot be viewed
because of a
permission.
 
Now there's a requirement to not display the article title in
category lists
and search results if it cannot be viewed. I'm stuck with how to
determine
the number of results for paging at the start of the list or search.
The
site is quite large (20,000+ articles and growing) so reading the
entire
result set and sifting through it with permission rules for each
request is
not an option. But it might be an option if done once at the start
of each
search or list request, and then use that temporary modified result
set for
subsequent requests on the same set. I thought of saving the set to
a
temporary db table or file (not sure about overhead of
serializing/unserializing large arrays). A sizing exercise based on
the
recordset returned for searches and lists shows a max of about 150MB
for
20,000 articles and 380MB for 50,000 articles that needs to be saved
temporarily per search or list request - in the vast majority of
cases the
set will be *much* smaller but it needs to cope with the worst case,
and
still do so a year down the line.
 
All this extra work because I can't simply get an accurate number of
results
for paging, because of permissions!
 
So my questions are:
1. Which is better (performance) for this situation: file or db?
2. How do I prepare a potentially very large data set for file or
fast
writing to a new table (ie I obviously don't want to write it record
by
record)
3. Are there any other alternatives worth looking at?
 
TIA
 
Cheers
Arno



How are you determining (logically, not in code) when an article is allowed
to be read?

Assume an article on user permissions in mysql is in a container called
'databases' and in a second one called 'security' and both containers are in
a category called 'computers'

Now get a user called John who is in a group called 'db admins' and that
group gives him permissions to view all articles in the 'databases'
container and any articles in any container in the 'computers' category. Now
assume John also has explicit user permissions revoking that right to view
the article in any container.

What I'm getting at is what's the order of privilege for rights? Do group
rights for categories win out over those for containers, or do individual
user rights trump all of them overall?

I think once that's figured out, a lot can be done inside the query itself
to minimise the impact on the script getting the results.


Thanks,
Ash
http://www.ashleysheridan.co.uk

---

The simple structure is articles in categories, categories in containers,
only one article per container/category, in one or more containers. If an
article permission explicitly allows or denies access then the permission
applies, otherwise the container/s and category/s permissions are checked.
The permission checks user access first then group. A user can belong to
multiple groups.

There's no query to handle this that can return a neat recordset for paging.
Currently the complete checks are only done for an article request. The
category list only checks access to the category and the container it
belongs to, so the list is either displayed in its entirety (including
titles of articles that can't be viewed) or not at all, and obviously the
paging works perfectly because the total number of titles is known up front
and remains constant for subsequent requests.

If I use read-ahead to make allowance for permissions and remove paging
(just keep prev/next) the problem goes away. Or I could use best-guess
paging, which could range from 100% accurate to 99% wrong. At first glance
that's not really acceptable, but I noticed recently Google does the same
thing with their search results. 

First prize is to work out a proper solution that is fast and accurate and
works on fairly large results, and I'm still hoping for some

RE: [PHP] Paging and permissions

2011-02-09 Thread Arno Kuhl
Instead of serializing the articles, you only need their IDs. Using

$sql .= ' where id in (' . implode(',', $ids) . ')';

you can load the data for a page of results in a single query. Storing the
IDs is much cheaper than the articles.

If the permissions are fairly static (i.e. access for user X to article Y
doesn't change every two minutes) you could create a calculated permission
table as a many-to-many between user and article. Here's the logic flow for
a query:

1. Run the query to find matching article IDs
2. Load permissions from table for all IDs
3. For each article without a calculated permission, calculate it and insert
a row (do a batch insert to save time)

If you flag the query in the middle tier as having been processed as above,
you can join to the calculated permissions each time you need another page.
The downside is that the code that runs the queries has to operate in two
modes: raw and joined to the permissions. If most users end up querying for
all articles, the table could grow. Plus you need to purge rows any time the
permissions for an article/user changes which could get fairly complicated.

David

---
 
Storing only the IDs is way cheaper than storing the entire resultset, and
I'd been thinking along the same lines. Getting a complete list of valid IDs
in the first place is turning out to be a different matter. The permissions
for article/user aren't that straight-forward, and in fact the most common
permissions are group/category and group/container, where an article can be
assigned to one or more category/containers. Using a temporary permission
table could be the solution. Thanks.

Cheers
Arno



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



[PHP] Paging and permissions

2011-02-08 Thread Arno Kuhl
I'm hoping some clever php gurus have been here before and are willing to
share some ideas.
 
I have a site where articles are assigned to categories in containers. An
article can be assigned to only one category per container, but one or more
containers. Access permissions can be set per article, per category and/or
per container, for one or more users and/or user groups. If an article is
assigned to 10 categories and only one of those has a permission denying
access, then the article can't be accessed even if browsing through one of
the other 9 categories. Currently everything works fine, with article titles
showing when browsing through category or search result lists, and a message
is displayed when the article is clicked if it cannot be viewed because of a
permission.
 
Now there's a requirement to not display the article title in category lists
and search results if it cannot be viewed. I'm stuck with how to determine
the number of results for paging at the start of the list or search. The
site is quite large (20,000+ articles and growing) so reading the entire
result set and sifting through it with permission rules for each request is
not an option. But it might be an option if done once at the start of each
search or list request, and then use that temporary modified result set for
subsequent requests on the same set. I thought of saving the set to a
temporary db table or file (not sure about overhead of
serializing/unserializing large arrays). A sizing exercise based on the
recordset returned for searches and lists shows a max of about 150MB for
20,000 articles and 380MB for 50,000 articles that needs to be saved
temporarily per search or list request - in the vast majority of cases the
set will be *much* smaller but it needs to cope with the worst case, and
still do so a year down the line.
 
All this extra work because I can't simply get an accurate number of results
for paging, because of permissions!
 
So my questions are:
1. Which is better (performance) for this situation: file or db?
2. How do I prepare a potentially very large data set for file or fast
writing to a new table (ie I obviously don't want to write it record by
record)
3. Are there any other alternatives worth looking at?
 
TIA
 
Cheers
Arno


RE: [PHP] tutorial failure

2010-08-18 Thread Arno Kuhl
-Original Message-
From: e-letter [mailto:inp...@gmail.com] 
Sent: 18 August 2010 10:44 AM
To: php-general@lists.php.net
Subject: [PHP] tutorial failure

Readers,

Copy below of message sent 15 August to php install digest list, but to date
not including in mail archive?

The tutorial example:

html
  head
  titlephp test
  /title
  /head
  body
  ?php
  echo 'pHi, I am a PHP script/p';
  ?
  p
  this is a test
  /p
  /body
/html

is saved to the normal user temporary folder as 'test.php' and then copied
to the folder '/var/www/html/' using the root user account. The web browser
is directed to url 'http://localhost.test.php, to show:

Hi, I am a PHP script

'; ?

this is a test

What is the error please?

Urpmi was used to install so the php version installed is not known.
How to obtain this please

--

Shouldn't that be http://localhost/test.php

Cheers
Arno



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



RE: [PHP] Recent Influx of Unrelated Discussions

2010-07-16 Thread Arno Kuhl
-Original Message-
From: paras...@gmail.com [mailto:paras...@gmail.com] On Behalf Of Daniel
Brown
Sent: 15 July 2010 05:11 PM
To: PHP General
Subject: [PHP] Recent Influx of Unrelated Discussions

Also known as off-topic posts.  We're all guilty of them, but has anyone
recently noticed that there is a significant number (about 35% of all
traffic) that is off-topic?  There have been questions on databases,
JavaScript, WordPress, Apache directives, and more none of which were
even related to PHP.  Unfortunately, this is how dilution occurs, which
often causes communities to dwindle into a defunct or otherwise low-quality
state.  As those of you who have been around for at least a couple of years
know, we have continued to thrive here because we're not strict on the
topics of discussion, and frequently [d]evolve into off-topic banter
(particularly on Fridays, as it used to be).  However, have you noticed the
influx of extremely low-quality and/or low-class posts to the list?  Couple
that with the ominous silence from the formerly-frequent contributors of
high-quality material, code examples, and community assistance.  It is not a
coincidence.

This is an open list, and we don't moderate or censor any of the
discussions, but before it gets out of hand, I'd like to suggest a
moratorium on all off-topic posts through the end of this month --- with the
exception, again, of Fridays.  Which would mean that those in agreement
would participate in the hiatus by not only not posting off-topic threads,
but also not replying to those that are off the general topic.  This isn't
to say that threads can't still eventually decay into a friendly discussion,
as has always been welcome, but that it shouldn't be the intent of a thread
to seek assistance on topics unrelated to PHP and PHP programming in
general.

--
/Daniel P. Brown
UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ ||
http://www.pilotpig.net/

--

It's Friday so I suppose I can respond... ;)

I belong to a couple of mailing lists and always found the PHP list
particularly active, focused,  mature, and a tremendously helpful resource,
even just following issues others raise and resolve. And Daniel, your own
gentle prods to keep things on track I think sets some of the professional
tone of the list. However, the subject of the list can be broad and fuzzy
and can lead to some semi off-topic posts like Apache directives that affect
PHP apps, JavaScript/Ajax interaction with PHP code, open-source PHP apps,
etc. And even some non-PHP issues that most PHP developers will deal with at
some time or another. Of course there are degrees of just how far off-topic
one can go, but the fact that you can tap into a huge resource of skills and
experience to find answers that can be difficult to find elsewhere is
obviously very tempting. I'm sure I'm not the only one who finds some of the
responses to these off-topic issues quite edifying, considering they're
almost always within the broad realm of PHP-related web development (though
I agree low-quality posts are useless to everyone whether on-topic or not).
At the same time I can see it's a difficult balancing act to cater for
everyone from total beginners to highly skilled professionals and still keep
everyone on board, especially if some of the more experienced and busy users
feel they're being flooded with hundreds of mostly irrelevant posts (like
this one) every day. But I also think those same users have the skills and
filters to quickly scan and find the posts that are
useful/interesting/relevant. Personally I think this list is great, even
with some of the off-topic discussion. And your own involvement has always
been very professional, and of course very focused, thanks.

Cheers
Arno



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



RE: [PHP] Dynamic Menus in a PHP Form Issue

2010-05-25 Thread Arno Kuhl
-Original Message-
From: Alice Wei [mailto:aj...@alumni.iu.edu] 
Sent: 24 May 2010 04:47 PM
To: php-general@lists.php.net
Subject: [PHP] Dynamic Menus in a PHP Form Issue

Hi,I have a snippet as in the following:   ul
liSelect the type of your starting point of interest:br/
div id=start_menuform action= name=form1 method=post
spaninput type=radio value=Apartment name=start
onclick=alert(document.form1.start)/ Apartment /span
/form/div/li/ulIf I tried to put this at the top of a
file where I save as PHP with other PHP execution statements, looks like the
form does not do anything, and yet when I save the page as in HTML with out
the other PHP execution, it works. I am trying to create a page where I have
dynamic drop down menu lists so users can egenerate dynamic content based on
their preference. Is it possible that I can save the entire file as a PHP
and still keep the functionality, including generating dynamic menus,
writing the proper entries to the database and printing out the proper
output?

Thanks for your help. 

Alice 
_

The reason it works in html is because it is executed in the browser. If
you want this html to get to the browser you must either echo it to the
output buffer that is sent to the browser, or end your php section with ?
so that these lines are interpreted as part of the output that is sent to
the browser.

If your php script is running without error then I presume you're already
doing this. If that's the case then maybe it's not being put into the output
buffer the way you're expecting (e.g. maybe the quotes don't match). You can
look at the source code in the browser and compare it against the working
html code to see where the difference is.

Cheers
Arno



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



RE: [PHP] PHP Application Structre

2010-05-10 Thread Arno Kuhl
-Original Message-
From: Alex Major [mailto:p...@allydm.co.uk] 
Sent: 10 May 2010 12:39 PM

From what I've seen and used, there seem to be three distinct ways of going
about it.

1)  Using a 'core' class which has a request handler in it. All pages in
the site are accessed through that one page, e.g.
http://www.somesite.com/index.php?page=ViewUser
http://www.somesite.com/index.php?page=ViewProduct
This is one that I've personally used most after becoming familiar with a
bulletin board system several years ago. It means that pages are easily
created as all the template/session/database handling is done by the central
class.

2)  Using SE friendly URL's like:
http://www.somesite.com/products/22012/cool-game/
http://www.somesite.com/products/22013/other-game/
This approach seems to be becoming more common on the sites I frequent,
however by accounts I've read it seems to be more intensive on apache as it
requires a mod-rewrite function. 

3)  Using different PHP files for each page:
http://www.somesite.com/viewproduct.php?product=
http://www.somesite.com/viewuser.php?user=...
This would appear to be the least developer friendly option?
 
Alex.

=

The second option doesn't really belong here, because you could go for
option 1 or option 3, and then decide whether to hide your implementation
behind a mod-rewrite. Option 2 would rather be part of a separate question
what is the cost/benefit of using mod-rewrite.

Cheers
Arno



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



RE: [PHP] PHP Application Structre

2010-05-10 Thread Arno Kuhl
  _  

From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 10 May 2010 01:58 PM
To: a...@dotcontent.net
Cc: 'Alex Major'; 'php-general General List'
Subject: RE: [PHP] PHP Application Structre


On Mon, 2010-05-10 at 13:15 +0200, Arno Kuhl wrote: 

-Original Message-

From: Alex Major [mailto:p...@allydm.co.uk] 

Sent: 10 May 2010 12:39 PM



From what I've seen and used, there seem to be three distinct ways of going

about it.



1)  Using a 'core' class which has a request handler in it. All pages in

the site are accessed through that one page, e.g.

http://www.somesite.com/index.php?page=ViewUser

http://www.somesite.com/index.php?page=ViewProduct

This is one that I've personally used most after becoming familiar with a

bulletin board system several years ago. It means that pages are easily

created as all the template/session/database handling is done by the central

class.



2)  Using SE friendly URL's like:

http://www.somesite.com/products/22012/cool-game/

http://www.somesite.com/products/22013/other-game/

This approach seems to be becoming more common on the sites I frequent,

however by accounts I've read it seems to be more intensive on apache as it

requires a mod-rewrite function. 



3)  Using different PHP files for each page:

http://www.somesite.com/viewproduct.php?product=

http://www.somesite.com/viewuser.php?user=...

This would appear to be the least developer friendly option?

 

Alex.



=



The second option doesn't really belong here, because you could go for

option 1 or option 3, and then decide whether to hide your implementation

behind a mod-rewrite. Option 2 would rather be part of a separate question

what is the cost/benefit of using mod-rewrite.



Cheers

Arno








Personally, I go with option 3 (as Arno said, option 2 isn't really an
alternative option, it's something you can use with either 1 or 3)

Consider a basic website with a small shopping cart and a blog. It would
seem crazy to have all the logic needed for the blog and the cart being
pulled in by PHP everytime you just needed to display a contact page. Far
easier to keep everything a bit more modular. That way, if you need to
update something, you update only a small part of the site rather than some
huge core file.

But, if your needs are even more simple, say it's just a very small brochure
website you have, then running everything through a single index.php might
not be such a bad idea.



Thanks,
Ash
http://www.ashleysheridan.co.uk

 ==
 
There are many approaches to this, and I think your final design will
largely be determined by what you want to do, and your own skill and
experience.
 
If you want to initialise your application, check input and load all your
base api functions before calling the specific script (function) to handle
the query, then maybe you can consider using a single entry point for your
application. It can simplify your design and maintenance, and there are ways
to ensure that access to your scripts have been initialised via the single
entry point. Careful design can allow you to add new
modules/scripts/whatever without having to update your single entry point
each time (look at some open-source apps for examples). It also allows you
to move your entire application to some place outside the document root and
leave only the entry script open to the public, which can add a bit of extra
security to your application. 
 
Personally I use two entry-points, one for admin and one for everything
else. Then besides graphics, flash and javascript, everything else is put
someplace outside the document root. The reason I settled on that approach
was because the admin script can handle all the slow heavy security-checking
stuff and loading additional admin api's, while the general script can be
small, fast and lightweight, but won't allow any access to the admin
functions. Neither script needs to be updated when adding to or changing the
main application.
 
Cheers
Arno


RE: [PHP] Will PHP ever grow up and have threading?

2010-03-24 Thread Arno Kuhl
If you added threading to the bag of tricks it already has, you're getting
into areas that make it more difficult to pick up for beginners (and that's
not to mention the technical elements involved in actually adding threading
to PHP) Currently the only other 'easy' language I know for beginners is
ColdFusion, and that's just horrible. You wouldn't want to be responsible
for sending the newbies down that path would you?! :p

Thanks,
Ash
http://www.ashleysheridan.co.uk

==

That's not a good argument against implementing threading, regardless of the
technical issues involved in making it work. There are plenty of more
advanced areas of php that beginners stay clear of. Just because threading
is available doesn't mean it will automatically be used or even considered
in most projects. I wrote C code for years in a large fairly complex banking
front-office system and only found a very few occasions where threading was
required to get the job done. In the majority of C and C++ code you find
very few examples of threading, either because it's not required (99.9% of
the time) or the coder didn't feel comfortable using it and found another
way to achieve the result. In the few occasions where I did use threading I
would say that most the time there was no other way of achieving the
required result. But the issues you need to solve with C are very different
to the issues you need to solve with php. I've spent more than 8 years
coding php and I haven't ever hit a brick wall because of the lack of
threading, but of course every project is different and I'm sure there are
situations out there where trying to work around the lack of threading can
cause major hassles. But as others have pointed out you use the right tools
for the job, and if php doesn't have what is required then use something
else.

Cheers
Arno



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



RE: [PHP] Will PHP ever grow up and have threading?

2010-03-24 Thread Arno Kuhl
-Original Message-
From: Rene Veerman [mailto:rene7...@gmail.com] 
Sent: 24 March 2010 11:31 AM
Subject: Re: [PHP] Will PHP ever grow up and have threading?

thanks for opening my eyes and telling to abandon ship in time.

===

Bye, enjoy the swim... 

Maybe by the time you get back to shore you'll realise how dumb it would be
if a sailor complained that his yatch didn't behave like a hovercraft, or
his passenger ship couldn't carry a million barrels of oil, or his tug boat
was useless at pulling a skier... Just how much (or little) development
experience do you have?

Cheers
Arno



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



[PHP] Using $$

2009-11-19 Thread Arno Kuhl
I was looking at some old code that I'm convinced once worked but now using
php5 it doesn't seem to work anymore.
 
$input = _REQUEST;
if (is_array($$input)) {
// do something
}
 
 
I know $_REQUEST is an array, but $$input is NULL (I was expecting it ==
$_REQUEST).
 
I also tried ${$input} but same result.
 
I tested something other than a superglobal and it works as expected. What
am I missing?
 
Cheers
Arno



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



RE: [PHP] Using $$

2009-11-19 Thread Arno Kuhl
-Original Message-
From: Ford, Mike [mailto:m.f...@leedsmet.ac.uk] 
Sent: 19 November 2009 07:06 PM
To: php-general@lists.php.net
Subject: RE: [PHP] Using $$

 -Original Message-
 From: Arno Kuhl [mailto:ak...@telkomsa.net]
 Sent: 19 November 2009 12:23
 
 I was looking at some old code that I'm convinced once worked but now 
 using
 php5 it doesn't seem to work anymore.
 
 $input = _REQUEST;
 if (is_array($$input)) {
 // do something
 }


 I tested something other than a superglobal and it works as expected. 
 What am I missing?


Depends where you have this fragment of code, but possibly the big fat
warning box towards the bottom of
http://php.net/language.variables.variable?

Cheers!

Mike
 --

Thanks for the link Mike, didn't know that. It doesn't say when this was
introduced but I'm sure superglobal variable variables must have worked at
some stage, because I've got code that once worked but doesn't anymore and
it's due to this. There's always a workaround, just not as elegant.

Cheers
Arno



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



RE: [PHP] Need unrounded precision

2009-10-12 Thread Arno Kuhl
-Original Message-
From: Andre Dubuc [mailto:aajdu...@webhart.net] 
Sent: 02 January 2010 03:20 AM
To: php-general@lists.php.net
Subject: [PHP] Need unrounded precision

Hi,

I need to extract the first digit after the decimal point from a number such
as 28.56018, which should be '5'.

I've tried a few methods to accomplish this. If I use 'ini_set' I would need
to know the number of digits before the decimal (which, unfortunately, I
would not have access to). 

Then I've tried:

?php

$elapsed = 28.56018;

$digit = round($elapsed, 1); // rounds result is '6'
$digit = number_format($elapsed, 1); // still rounds result to '6'

?

What I need is only the first digit after the decimal -- all the rest could
be 'chopped' or discarded but without rounding the first digit after the
decimal point. 

Is there any way of doing this?

I'm stumped.

Tia,
Andre

--

One way that should work regardless the number of digits before/after the
decimal is:
- convert to string (sprintf or typecast)
- strpos the decimal
- grab the char from the next position

Cheers
Arno


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



[PHP] Output buffering

2009-10-07 Thread Arno Kuhl
Has there been a change to the way output buffering works? 

The manual states for ob_get_contents()
This will return the contents of the output buffer or FALSE, if output
buffering isn't active.

But the following works in php4.4.4 and php5.2.6 whether output buffering is
on or not

?php
  ob_start();
  echo htmlbody;
  echo output_buffering is ;
  echo ini_get('output_buffering')?on:off;
  echo /body/html;
  $check = ob_get_contents();
  if ($check === FALSE)
echo  FALSE;
  $info = ob_get_contents();
  ob_clean();
  echo $info. -2-;
  ob_flush();
?

The output is output_buffering is off -2- (or on) displayed once - FALSE
is obviously never appended.

According to the manual I shouldn't see anything at all when
output_buffering is off (or if memory serves me correctly I should see an
error about headers already sent or something). Looking at phpinfo
confirms the value echoed by the script. Has something changed with output
buffering?

Cheers
Arno


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



RE: [PHP] Output buffering

2009-10-07 Thread Arno Kuhl
From: djo...@gmail.com [mailto:djo...@gmail.com] On Behalf Of David Otton
Sent: 07 October 2009 10:54 AM
To: a...@dotcontent.net
Cc: php-general@lists.php.net
Subject: Re: [PHP] Output buffering

2009/10/7 Arno Kuhl ak...@telkomsa.net:

 According to the manual I shouldn't see anything at all when 
 output_buffering is off (or if memory serves me correctly I should see 
 an error about headers already sent or something). Looking at 
 phpinfo confirms the value echoed by the script. Has something changed 
 with output buffering?

Use

echo ob_get_level() . br/;

to find out how many levels of output buffering you are wrapped in.

Whether output buffering is set to start automatically, and whether output
buffering is on right now are two different things:

ob_end_clean();
echo ob_get_level() . br/;
echo ini_get('output_buffering') . br/;

--

Thanks David. After taking another look at the description for ob_start() I
began to suspect there was a difference, but the manual doesn't mention
anything about it. And the fact they use the same terminolgy for both the
settings and the functions is confusing. I can see from tests that the
htaccess/ini settings have no obvious effect on the ob functions (maybe
buffer size?).

Cheers
Arno


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



RE: [PHP] Fixing the path

2009-09-14 Thread Arno Kuhl
-Original Message-
From: Rico Secada [mailto:coolz...@it.dk] 

Some time ago I developed a small web application that a bunch of users has
installed.

I have always used the DOCUMENT_ROOT for my includes, but the other day I
installed the application in a subdirectory, and as you've guessed a lot of
the includes didn't work.

I have been reading up on the subject of absolute vs. relative paths etc.
And on the subject of defining your own document root.

I need the application to be as user friendly as possible, and I would like
to avoid having users enter path details in the configuration.

What is the best way to solve this problem?

Rico.
--

Who are your users? Can users download the script and run it on their own
servers? If so there shouldn't be a problem asking them to set a path in a
config file because presumably the users would know something about servers
and paths, and presumably they'll know enough to create the directory and
copy the files there in the first place.

If you have an install process you can pick up the current directory from
system globals and write it to the path setting in the config file. You
might need two different absolute paths, one for includes and one for urls.

Cheers
Arno


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



[PHP] PHP configuration values

2009-09-11 Thread Arno Kuhl
I'm having some problems with the way my service provider is implementing
FastCGI. My tests show that local configuration values are no longer used,
even though those are the values reported by php when the script queries a
setting (e.g. register_globals). In fact all settings done by script or in
.htaccess are ignored, though reported to be in effect by php. I seem to
remember seeing somewhere that local values are supposed to override master
values but I can't find the reference right now. Can anyone please tell me
how local vs. master values are supposed to work, or point me to a
definitive reference.
 
Cheers
Arno


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



RE: [PHP] PHP configuration values

2009-09-11 Thread Arno Kuhl
On Fri, Sep 11, 2009 at 3:06 AM, Arno Kuhl ak...@telkomsa.net wrote:
 I'm having some problems with the way my service provider is 
 implementing FastCGI. My tests show that local configuration values 
 are no longer used, even though those are the values reported by php 
 when the script queries a setting (e.g. register_globals).

-Original Message-
From: Andrew Ballard [mailto:aball...@gmail.com] 

Changing register_globals in script will not have the desired effect, since
the action of registering globals will have been either completed or skipped
by the time you call ini_set(). If the host allows it, you can override it
in .htaccess, but I've not been able to do so on the couple sites I've
touched that were hosted on by a shared hosting provider. In those cases, I
WAS able to create my own php.ini file in the web root folder and configure
it as needed. Of course, if you do that you should also configure Apache to
not serve that file if requested.

Andrew
--


You're right, you can't change register_globals in script but you can query
it in script, which is what I was referring to. There aren't many settings
you can change in script, about the only useful one that we use is
max_execution_time. Either way, what I find in testing is that on our host
php returns the value reported in phpinfo as the local value which is
correct, because that's the value that should be in effect (combination of
httpd.conf, php.ini, .htaccess and values set in script), but the value
that's actually in effect is the master value. 

For example, if php.ini sets register_globals on and .htaccess sets
register_globals off, then the code 

ini_get('register_globals')

reports register_globals is off (it's reporting the local value) but in fact
register_globals is on. In this particular case our app would stop with a
configuration error if it found register_globals on, but it thinks it's off
so happily carries on.

Local is supposed to override master values but they have master overriding
local values. I'm trying to confirm that local is supposed to override
master, and find a proper reference that I can show to my hosting guys. I
searched php.net but they don't mention which one takes precedence. Anyone
know of any references?

BTW Andrew, were those hosting servers that wouldn't allow override in
.htaccess running FastCGI? Maybe FastCGI doesn't allow config settings in
.htaccess but I can't find anything conclusive about that either.

Cheers
Arno


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



RE: [PHP] header problem

2009-09-10 Thread Arno Kuhl
-Original Message-
From: A.a.k [mailto:blue...@gmail.com] 
Sent: 10 September 2009 08:27 AM
To: php-general@lists.php.net
Subject: [PHP] header problem

hello
I recentrly uploaded my project from localhost to a hosting and found many
errors and warnings which didnt have in local. one of the most annoying one
is header('Location xxx').
I have used header to redirect users from pages, and kinda used it alot. i
know about the whitespace causing warning, but most of the pages i'm sending
users got html and php mixed so i'm confused about how to remove whitespace
in a html/php file. the error is :
Warning: Cannot modify header information - headers already sent by 
here is a simple example, user update page :
 if($valid)
{
$msg='111';
$user-dbupdate();
 header(Location: /admin/index.php?msg=$msg);

}
else
{
 foreach($errors as $val)
echo 'p id=error'.$val.'/p';
}

and on admin index i get $msg and display it.
html
..
//lots of stuff
   ?php
   $msg = $_GET['msg'];
   switch($msg){
   case '111'   echo 'p /p';
break;
  case '421':...
}
?
//  more html and php

how can i fix this? 
--

It's possible that on your localhost you have output_buffering set on either
in php.ini or in a .htaccess, which would avoid the displayed error about
headers. If it's switched on locally and off for your host server then
you'll get the problem you reported. Check that this is off locally (use
phpinfo) so that you can be sure your code is working properly before you
upload.

Alternatively if you want to be able to do a redirect after you've already
started your output (this is sometimes done for error handling) you could
use ob_start() to start output buffering, ob_end_clean() to clear the output
buffer and start again, and ob_flush() to send the output buffer. If you
want to continue using output buffering after an ob_end_clean() you'll have
to do an ob_start() again.

Cheers
Arno


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



RE: [PHP] Re: page works on public web site, but not on my computer

2009-08-27 Thread Arno Kuhl
-Original Message-
From: mike bode [mailto:mikebo...@hotmail.com]
Sent: 27 August 2009 04:49 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Re: page works on public web site, but not on my computer

I understand, but that's not an option. I am not interested in getting into
a Linux vs. Windows fight here, let's just say that I am stuck with Windows.

Now, somthing's gotta be seriously wrong here. I have tried now 4 or 5
different scripts for the photo gallery that I am trying to implement and
NONE of them has worked. I have enabled all extensions and loaded all
modules in Apache and php -- still nothing.

I can't believe that the Apache Society out there simply ignores the 80% or
so that use Windows. Can anybody point me to a group that deals with Apache
(PHP) on Windows?  Thanks.

mike

 -Original Message-
 From: mike bode [mailto:mikebo...@hotmail.com]
 Sent: Tuesday, August 25, 2009 11:41 PM
 To: php-general@lists.php.net
 Subject: [PHP] Re: page works on public web site, but not on my
 computer

 I just de-installed, then re-installed MySQL, Apache and PHP 5.3. No
 changes. The script does not work on my computer.

 Now I get in addition to the error message below this:

 [Tue Aug 25 21:29:11 2009] [error] [client 127.0.0.1] PHP Deprecated:
 Function eregi() is deprecated in
 C:\\webdev\\rmv3\\album\\getalbumpics.php
 on line 11, referer: http://localhost/album.php

 Don't know if those warnings would stop the execution of the php script.


 mike bode mikebo...@hotmail.com wrote in message
 news:99.f2.08117.ccf74...@pb1.pair.com...
 I have posted the question in another thread a bit down, but only
 buried
 within the thread, so please excuse me when I ask again.
 
  I want to use some PHP code from a web site
  (http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm), and
  I
 am
  following their instruction how to implement it. I was not able to
  get
 it
  to work. Then I uploaded the code to a server, and lo and behold,
  it
 does
  work on the server. On the public site you see thumbnails of images
 (never
  mind the junk above them), when I run the SAME html and php code on
  my

  omputer, I get a blank white page.
 
  The error log has several entries, but they are all warnings:
 
  [Tue Aug 25 18:12:00 2009] [error] [client 127.0.0.1] PHP Warning:
  date(): It is not safe to rely on the system's timezone settings.
  You
 are
  *required* to use the date.timezone setting or the
  date_default_timezone_set() function. In case you used any of those
  methods and you are still getting this warning, you most likely
 misspelled
  the timezone identifier. We selected 'America/Denver' for '-6.0/DST'
  instead in C:\\webdev\\rmv3\\album\\getalbumpics.php on line 11,
 referer:
  http://localhost/album.htm
 
  (this error is repeated for as many images I have in the directory
 that
  the php script is reading).
 
  Between php.ini, httpd.conf, and Windows Vista, I can't figure out
 where
  to start to diagnose this, and how. Anybody out there who can give
  me
 a
  pointer on how to roubleshoot this issue? I am almost ready to
  throw
 in
  the towel and either start from scratch (although this is alrady
  the second time that I have uninstalled and re-installed
  everything), or simply forget about php altogether. that would be a
shame, though...


 --

I'm sure there are many on this list that develop on the Windows platform,
including myself. I deploy on Linux, and personally I find the two
environments to be very compatible (in fact besides the url and filename
case differences I haven't found any practical difference between the two at
all). So it's not at all true that Apache simply ignores the 80% or so that
use Windows. You previously said you're new to php, so what are the chances
that this has more to do with your own inexperience with php rather than
some Windows-only bug you've discovered and are revealing to the rest of the
php community?

The error message mentions the script name and a line number, have you
checked what code is causing the error?

You said you installed php 5.3 on your pc. Chances are very high that the
host you uploaded this to is not running php 5.3. Someone previously
mentioned that there are differences between 5.3 and the previous versions
that could account for your issues. Have you tried installing php 5.2 and
trying it again? There are also settings in php ini file that you can change
to change the error reporting, but it's not clear if you've tried that yet.
One final thing, have you tried to google with the error message to see how
others dealt with this problem?

Cheers
Arno




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



RE: [PHP] anchor inside form

2009-08-25 Thread Arno Kuhl
-Original Message-
From: leledumbo [mailto:leledumbo_c...@yahoo.co.id] 
Sent: 25 August 2009 09:55 AM
To: php-general@lists.php.net
Subject: [PHP] anchor inside form

If I have an anchor inside form, how can I send form using the anchor
without displaying target url? I've tried the code below but IE says that
this.form is null or empty and Firefox does nothing.

form action=somewhere.php method=get
# Pick me
/form
--

You can use javascript behind a button or image or link to submit the form
from anywhere in your html page. You don't need the anchor but you do need a
form name. Something like:

  href=javascript:document.FormName.submit();

Cheers
Arno


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



RE: [PHP] (was: anchor inside form) js switched on/off

2009-08-25 Thread Arno Kuhl
 
 You can use javascript behind a button or image or link to submit the 
 form from anywhere in your html page. You don't need the anchor but 
 you do need a form name. Something like:
 
   href=javascript:document.FormName.submit();
 
 Cheers
 Arno
 
 
And all it takes for that to break is for someone to turn off Javascript...

Thanks,
Ash
http://www.ashleysheridan.co.uk

-

Ash, from what I've seen you enjoy engaging in a debate. Well here's
something you'll no doubt want to engage in: the number of people who have
javascript switched off vs the number of people using browsers that support
all the latest ajax-type gizmos. I've not seen anyone told not to go the
ajax route, but it's amazing how concerned some people are about whether
javascript is switched on or not (the fact that js is required for ajax
seems to be overlooked). When w3schools was still keeping stats about it
they showed about 5% of users had js switched off (though they conceded the
stats were unreliable - tech types go to w3schools and they're much more
likely to mess with browser settings than the average user). Generally it's
accepted that the average joe doesn't know how to switch js off, or even why
they would want to. When we investigated sites where this is specifically
measured (e.g. a banking site, which I once worked on) users who had js
switched off were prompted to switch it on, and logs showed that 100% of
those users reloaded the page with js switched on (and our stats, during the
launch phase, showed much less than .5% users had js switched off in the
first place). Generally we found that requiring js was a complete non-issue.
I've subsequently found this is true on other sites I've worked on, even
when users are not prompted. With navigation menus using js more frequently
these days and the increased use of ajax, browsing with js switched off is
almost not an option anymore. I'm sure, Ash, you'll tell me how corporate
firewalls strip javascripts - I'd be interested if you can point out an
example and show how common this is. And as for most people telling you js
is a bad idea - is this true? Do you have stats to back up your statement,
or are you just stating your perception as a fact?

A second point, Ash, is that you yourself have mentioned coding javascript,
and have suggested the use of ajax as a solution to others - I presume you
know what the j in ajax is? I've even seen you providing javascript
solutions without any concern as to whether js was switched on or not.
Perhaps your concern about js is selectively applied to certain posts rather
than real-world situations?

BTW I'm not in a debating mood - I've made my point, no doubt Ash you'll
make yours, and I'll leave it at that. But if anyone else has any further
info regarding real-world stats or experience about js switched on or off it
would be very interesting to hear.

Cheers
Arno


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



RE: [PHP] Beginner question

2009-08-25 Thread Arno Kuhl
-Original Message-
From: mike bode [mailto:mikebo...@hotmail.com]
Sent: 25 August 2009 07:16 AM
To: php-general@lists.php.net
Subject: [PHP] Beginner question

I am trying to use PHP on my web site I am developing now. I have installed
Apache 2.2 and PHP 5.2. My problem is that I can execute PHP code embedded
in my HTML code, but I can't execute the same cose when I put it into a
separate .php file that i then call from within the html code. for example:

I have a html file with

body
?php
echo Printing with php;
?
?body

and it works fine.

When I take out the php code and put it inot a file pp.php, and I call that
file with my browser (localhost/pp.php), it works, too.

But when I change the html code to:

body
script type=text/javascript src=pp.php/script /body

I get a blank page. this is probably something really stupid, but I have
been wrecking my head for days now, and I can't figure it out. anybody has
an idea?

--

I presume your html/php code is in a file with a .php extension? If not then
change the extension to php because most other webservers won't parse php
code in a html file. If you have a .php file you can mix html and php the
way you described, and you can put your php code between the ?php and ?
tags.

The php script you're trying to include in your html code with javascript
script type=text/javascript src=pp.php/script
would presumably echo out the javascript code that ends up in your html
page, but if you don't know php then you're trying to run before you can
walk.

If possible try to see what javascript code is being generated (echoed) by
the php script and put it in a normal .js file (e.g. pp.js) and then use it
like any other javascript file
script type=text/javascript src=pp.js/script
This isn't always possible because often php is used to decide what
javascript to output (otherwise why bother). If you have to use php to
generate your javascript code then start with small steps - try echoing some
simple js code in your pp.php (like an alert) just so you can see how it
works. Once you get that working you can move on to more useful things.


To illustrate, what's actually happening with the code you have at the
moment is this:

The browser parses the initial html code and finds
script type=text/javascript src=pp.php/script
And sends a request back to the server for pp.php

The server runs pp.php and send the output generated by the php script back
to the browser,
so effectively the browser ends up with
script type=text/javascriptPrinting with php/script

Obviously that isn't going to work. Hopefully you can now see what the
problem is and how to fix it.


Cheers
Arno





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



RE: [PHP] Invoking functions stored in a separate directory?

2009-08-21 Thread Arno Kuhl
-Original Message-
From: Clancy [mailto:clanc...@cybec.com.au] 
Sent: 21 August 2009 01:26 PM
To: php-general@lists.php.net
Subject: [PHP] Invoking functions stored in a separate directory?

I am developing an idea for a website engine which can be shared between
several different websites. Each website would have its own directory under
a common root directory, and the engine would be in a separate directory
Engine:

Root
Website_1.com, Website_2.com, Engine

The website directories would each contain the design data for that website,
consisting basically of a mixture of text files and images. The various
pages would be loaded by loading index.php from the website root directory,
and specifying a number of parameters e.g.

http://www.corybas.com/index.php?path=Holidayslevel=0item=0

I have the minimum amount of code in index.php -- just enough to set some
parameters to identify the website, and then include
../Engine/Main_prog.php.  This in turn can include any of a large number of
other include files to carry out particular functions. 

I have the prototype working nicely on my PC, and on a stand-alone basis on
a server, but now I am trying to upload the multi-website version to a
public host, and am encountering a number of problems, mainly because I have
never done any serious work with UNIX, and the host support staff don't
understand what I am trying to do.

The problems mainly relate to setting permissions to allow the website to
access the engine code. I only have a rough idea of how the permissions
work, but I think that to include engine code the website has to have read
and execute rights to it, and I also think that so far as the engine is
concerned the website will count as 'other'.  (I can easily arrange that all
temporary files are written in the website directory.)

I suspect that rather than including the engine code in index.php, it would
be better to call functions in it, so that the website only required
'execute' rights, but I don't know of any way to do this without having
anything running permanently on the server. Can anyone suggest how it can be
done?

-

Using include ../Engine/Main_prog.php won't work for you in a production
environment. You need to create a path.php file that defines the absolute
path to the engine for each website, and include it at the top of your
website script. Then you can do something like:

   include ENGINEPATH.Main_prog.php;

You can have different path files, one for dev and one for live, that allows
you to use the same scripts for both environments and just use the
appropriate path definition script.

E.g. Windows path.php
define('ENGINEPATH','../Engine/');

Linux path.php
define('ENGINEPATH','/usr/home/Engine/');

You shouldn't really have permission problems as long as your website and
engine are on the same server. I do something similar where the bulk of my
code is below doc root, and I use path files to find the main system
directories. The beauty of it is you can change your mind about directory
structures, and just change the path file definitions without making any
changes in the application code (my path file defines about 20 directories).
It also lets you do dev on a Windows pc and deploy on a *nix box without any
problems - just use a different path file for each.

One other advantage it will give you for your particualr design is that you
can have multiple engines per server (e.g. Engine1, Engine2, etc) so that
you can bring one engine down for upgrade while still keeping sites running
on the other engines.

Cheers
Arno



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



RE: [PHP] about to run PHP script when POST data.

2009-08-21 Thread Arno Kuhl
-Original Message-
From: Jacky [mailto:newbde...@gmail.com] 
Sent: 21 August 2009 03:12 PM
To: php-general@lists.php.net
Subject: [PHP] about to run PHP script when POST data.

Hi guys,

As I know When we POST a big data(e.g. 500M) to a php script, the php script
only can run after the big data finished POST.

for example:
a.php

 ?php die(''); ?


and I post 500m data to a.php,  after that a.php cannot be died immediately.
only when the data finished post.

How can I make the a.php die before the 500m data finish?

Thanks in advance.

--
Regards,
Jacky

---

Your script will die ungracefully when it runs out of execution time
(defined in php.ini)

Cheers
Arno


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



RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Arno Kuhl
-Original Message-
From: Leon du Plessis [mailto:l...@dsgnit.com] 
Sent: 20 August 2009 09:44 AM
To: php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

Since we are on the subject: I have the following similar problem:

When testing page on internet explorer, I find that one tab's variables can
affect another tab's variables. Thus when having the same web-site open and
using SESSION variables but for different users, Internet explorer can
become disorientated. This also sometimes happen when I have two
separate browsing windows open with Internet Explorer for the same site.

I have yet to determine if this is an internet explorer, or PHP or
combination of the two that is causing this condition. 

To my understanding _SESSION variables should be maintained per session, tab
or window. If this has been addressed already, my apologies, but thought it
worthwhile to mention.  

If someone perhaps have a solution or can confirm this as a known issue and
maybe is the same or related to Angelo's problem?



If different browser windows/tabs on the same client-side computer didn't
share session info then you'd get the effect of being able to log onto a
site with one browser window, but find in a second browser window that you
were not yet logged on. Experience will tell you that you're logged on in
both browser windows (try it with your online bank). It's not an issue, it's
a feature. If you want to be able to use different browser windows as though
they were different users then use different browsers e.g. IE and FF on the
same client-side computer will look like two separate end users to the
server, and they don't share session info or cookies.

Cheers
Arno


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



RE: [PHP] How to make sure that the target file to read is not under writing by others?

2009-08-20 Thread Arno Kuhl
-Original Message-
From: Tom Worster [mailto:f...@thefsb.org] 
Sent: 20 August 2009 01:28 PM
To: Clancy; php-general@lists.php.net
Subject: Re: [PHP] How to make sure that the target file to read is not
under writing by others?

On 8/19/09 9:56 PM, Clancy clanc...@cybec.com.au wrote:

 I gather from this discussion that PHP allows two users to open a file 
 for R/W? I had assumed it wouldn't.

i think php does allow this. but i'm not sure all file systems do.

--

PHP does allow more than one process to open a file for read-write, as does
every other filesystem I know of (PHP doesn't have a filesystem, it
implements a subset of file commands common to all OS's [some differences
between *nix and Windows] that it uses to communicate with the underlying OS
filesystem). If there's a need to ensure that multiple processes don't step
on each others toes the file can be locked. The two most common file
accesses are read and append, where a lock is mostly not required. It's only
in special cases where you want to write or update something and want to be
sure that another process isn't trying to update the same data or trying to
read data that may no longer be consistent (until you finish your update)
that you'd want to lock it.

Cheers
Arno


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



RE: [PHP] How to make sure that the target file to read is not under writing by others?

2009-08-19 Thread Arno Kuhl
-Original Message-
From: Dengxule [mailto:dengx...@gmail.com] 
Sent: 19 August 2009 09:56 AM
To: Php Maillist
Subject: [PHP] How to make sure that the target file to read is not under
writing by others?

Hi everyone:

I have a crontab command to execuate my php-script every half an hour.

The mission of the php-script is to open a file(log file), examine it.

The target file(log file) is transported to local every half an hour.

I've no idea how much time it will costs and on the other hand, i want to
make sure the file i'm openning is Completely Written.

Any instruction will be grateful.


PS: I've made a test. My php-script just fopen a local file being
transported in, and the fopen returns no FALSE value but a resource.


Dengxule
2009/08/19


Check the timestamp of the log file. Alternatively you can have a log
control file that is updated by the program transferring the log file only
when the transfer is completed, and work on that.

Cheers
Arno


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



RE: [PHP] How to make sure that the target file to read is not under writing by others?

2009-08-19 Thread Arno Kuhl
-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 19 August 2009 11:57 AM
To: a...@dotcontent.net
Cc: 'Dengxule'; 'Php Maillist'
Subject: RE: [PHP] How to make sure that the target file to read is not
under writing by others?

On Wed, 2009-08-19 at 11:55 +0200, Arno Kuhl wrote:
 -Original Message-
 From: Dengxule [mailto:dengx...@gmail.com]
 Sent: 19 August 2009 09:56 AM
 To: Php Maillist
 Subject: [PHP] How to make sure that the target file to read is not 
 under writing by others?
 
 Hi everyone:
 
 I have a crontab command to execuate my php-script every half an hour.
 
 The mission of the php-script is to open a file(log file), examine it.
 
 The target file(log file) is transported to local every half an hour.
 
 I've no idea how much time it will costs and on the other hand, i want 
 to make sure the file i'm openning is Completely Written.
 
 Any instruction will be grateful.
 
 
 PS: I've made a test. My php-script just fopen a local file being 
 transported in, and the fopen returns no FALSE value but a resource.
 
 
 Dengxule
 2009/08/19
 
 
 Check the timestamp of the log file. Alternatively you can have a log 
 control file that is updated by the program transferring the log file 
 only when the transfer is completed, and work on that.
 
 Cheers
 Arno
 
 
The log control file wouldn't work, as how would you know when to open the
control file?!

Thanks,
Ash
http://www.ashleysheridan.co.uk

--

You can open the control file any time you want. The info in the control
file tells you whether to proceed. The transfer program adds the entry when
the log has been transferred, the processing script updates the entry to
indicate it's been processed. You can either add a new entry each time
(useful for monitoring to fine-tune the timing, or for keeping a history) or
work on a single entry that's overwritten each time the log is transferred.

Cheers
Arno


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



RE: [PHP] How to make sure that the target file to read is not under writing by others?

2009-08-19 Thread Arno Kuhl
-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 19 August 2009 01:00 PM
To: a...@dotcontent.net
Cc: 'Dengxule'; 'Php Maillist'
Subject: RE: [PHP] How to make sure that the target file to read is not
under writing by others?

On Wed, 2009-08-19 at 12:56 +0200, Arno Kuhl wrote:
 -Original Message-
 From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
 Sent: 19 August 2009 11:57 AM
 To: a...@dotcontent.net
 Cc: 'Dengxule'; 'Php Maillist'
 Subject: RE: [PHP] How to make sure that the target file to read is 
 not under writing by others?
 
 On Wed, 2009-08-19 at 11:55 +0200, Arno Kuhl wrote:
  -Original Message-
  From: Dengxule [mailto:dengx...@gmail.com]
  Sent: 19 August 2009 09:56 AM
  To: Php Maillist
  Subject: [PHP] How to make sure that the target file to read is not 
  under writing by others?
  
  Hi everyone:
  
  I have a crontab command to execuate my php-script every half an hour.
  
  The mission of the php-script is to open a file(log file), examine it.
  
  The target file(log file) is transported to local every half an hour.
  
  I've no idea how much time it will costs and on the other hand, i 
  want to make sure the file i'm openning is Completely Written.
  
  Any instruction will be grateful.
  
  
  PS: I've made a test. My php-script just fopen a local file being 
  transported in, and the fopen returns no FALSE value but a resource.
  
  
  Dengxule
  2009/08/19
  
  
  Check the timestamp of the log file. Alternatively you can have a 
  log control file that is updated by the program transferring the log 
  file only when the transfer is completed, and work on that.
  
  Cheers
  Arno
  
  
 The log control file wouldn't work, as how would you know when to open 
 the control file?!
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 
 --
 
 You can open the control file any time you want. The info in the 
 control file tells you whether to proceed. The transfer program adds 
 the entry when the log has been transferred, the processing script 
 updates the entry to indicate it's been processed. You can either add 
 a new entry each time (useful for monitoring to fine-tune the timing, 
 or for keeping a history) or work on a single entry that's overwritten
each time the log is transferred.
 
 Cheers
 Arno
 
 
No, what you're saying is 'use a log file in order to know when to look at
another log file'. What would happen if you tried to access the control log
file whilst it was in the process of being written to?
Admittedly, you reduce your chances of failure because there is less data
being written to the control log than the actual log, but the chance of
reading incomplete data is still there!

Thanks,
Ash
http://www.ashleysheridan.co.uk



A control file is used to control processing, a log file is used to log
events. I'm definitely talking about a control file. If the control file
happens to keep a log then it's a bonus, but not its primary purpose.

Access the control file while being written to? I'm talking about a short
single-line entry, and the file is only written to when the write command is
processed. Copying a file is very different to issuing a single write
command. Don't forget that PHP and webservers run on top of operating
systems, and the OS ultimately handles all file activity. The OS ensures
that another process can't read a file that is halfway through a write
command (any computer would instantly crash if that sort of basic
housekeeping wasn't done). 

If you don't trust the OS then file locking can be used (though pointless in
this case). For the ultra-paranoids who don't trust OS's or locks you can
either (a) choose a different career, or (b) add a time-stamp to the
beginning of the entry and check that the entry wasn't written in the last
few nanoseconds (if you get this far I'd recommend option a). You can even
go so far as to check the length of the timestamp string to be sure that you
got all of it, and if it's too short you know you're busy reading a file
that's halfway through a write command, and sleep for a millisecond and then
try again ;)

Cheers
Arno


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



RE: [PHP] How to make sure that the target file to read is not under writing by others?

2009-08-19 Thread Arno Kuhl
-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 19 August 2009 03:34 PM
To: a...@dotcontent.net
Cc: 'Dengxule'; 'Php Maillist'
Subject: RE: [PHP] How to make sure that the target file to read is not
under writing by others?

On Wed, 2009-08-19 at 15:31 +0200, Arno Kuhl wrote:
 (any computer would instantly crash if that sort of basic housekeeping 
 wasn't done)

No, it really wouldn't! If it did, then you'd never have video playing
software out there that supported broken downloads, no preview software for
semi-downloaded items. Have you ever been sent a large jpeg over a slow
connection on a messenger program? You can open the file way before it's
finished downloading and actually see it progressively load in.

Thanks,
Ash
http://www.ashleysheridan.co.uk

---

If anyone was left a bit unsure about whether or not a write command in PHP
could result in a file on a local filesystem being left in a semi-written
state (i.e. some other script started reading the file while your script had
only written part of its output string) rest assured that fwrite() always
writes *all* the contents to the file without the need of flock(), by the
time any other process (whether PHP or not) reads that file (assuming you're
not writing megabytes of data with a single fwrite()). To quote the PHP
manual:

If handle was fopen()ed in append mode, fwrite()s are atomic (unless the
size of string exceeds the filesystem's block size, on some platforms, and
as long as the file is on a local filesystem). That is, there is no need to
flock() a resource before calling fwrite(); all of the data will be written
without interruption.

Cheers
Arno


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



RE: [PHP] DB Question | A hotel reservation scenario

2009-08-18 Thread Arno Kuhl
-Original Message-
From: Behzad [mailto:behzad.esl...@gmail.com] 
Sent: 18 August 2009 04:46 PM
To: PHP General Mailing List
Subject: [PHP] DB Question | A hotel reservation scenario

Dear list,
e-Greetings!

I'm faced with an interesting and challenging problem.

Consider a database, designed for a hotel.
At any given time, each room has a different status: It's Busy or Reserved,
or Free.

It's easy to retrieve number of Free rooms at the current time.
But how can I count the number of rooms that were busy during the last week
?

I would appreciate if you take a brief moment of your time and share your
opinion.

Thank you in advance,
-b
-

You get that information from the history table. I presume there is some
sort of a history table?

Cheers
Arno


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



RE: [PHP] Re: unsetting a referenced parameter in a function

2009-07-23 Thread Arno Kuhl
-Original Message-
From: Shawn McKenzie [mailto:nos...@mckenzies.net] 
Sent: 23 July 2009 02:36 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Re: unsetting a referenced parameter in a function

Tom Worster wrote:
 On 7/22/09 6:09 PM, Shawn McKenzie nos...@mckenzies.net wrote:
 
 Tom Worster wrote:
 though the manual is perfectly clear that this should be expected, i 
 was a bit surprised that the result of the following is 42

 ?php
 function foo($a) {
   $a = 42;
   unset($a);
   $a = 'meaning';
 }
 foo($a);
 print($a\n);
 ?

 normally i would expect unset() to free some memory. but in this 
 example it doesn't and has a different behavior: it releases foo's 
 reference to the global $a, allowing the next line to define a local $a.

 i think i'd have preferred compile error.


 Well, you unset the reference and then you assigned 'meaning' to a 
 local function variable $a.  Why would you get a compile error?
 
 when you state it in those terms (which are clearly correct) i wouldn't.
 
 but if the way i think is unset() destroys the specified variables 
 (as the manual puts it) then i expect that the specified variable 
 would be destroyed, not the reference.
 
 so, as i said, i was a bit surprised when the variable wasn't destroyed.
 once i understood what was happening, i thought it a bit confusing to 
 have such scope-dependent differences in behavior of a language element.
 
 
It might be easier to understand if you don't use the same var names:

function foo($arg) {
  $arg = 42;
  unset($arg);
  $arg = 'meaning';
}

$a = 0;
foo($a);
print($a\n);

-Shawn
--

Another way to see it (from Shawn's example): the  is an address of
(reference to) a variable, so function foo($arg) creates a local variable
$arg pointing to a global variable called $a. Changing the value of local
$arg updates the global $a. The unset($arg) removes the local $arg but has
no effect on global $a. The next line $arg = 'meaning' creates a new local
variable called $arg which has no connection whatsoever with the $arg that
was unset - it could just as well have been called $xyz. 

As Shawn pointed out there's no problem here with scope, you were just
confusing yourself by using the same variable name in the function, but it's
a separate local variable regardless of what name you give it.

A slight variation of your example:

?php
function foo() {
  global $a;
  $a = 42;
  unset($a);
  $a = 'meaning';
}

$a = 0;
foo($a);
print($a\n);
?

You get exactly the same result as your example, for the same reason, the
only difference is that you obviously can't change the local variable name
in the function.

A final variation (to drive the point home):

function foo($arg) {
  global $a;
  $a = 42;== at this point $arg = 42
  unset($a);
  $a = 'meaning'; == $arg is still 42
  $a = $arg;  == $a now points to same address $arg is pointing to
  $a = 'of life'; == $arg now = 'of life'
}

$a = 0;
foo($a);
print($a\n); == prints 'of life'

Here in function foo() local $arg and local $a are both pointing to the
global $a, and changing either of them changes the other (and changes the
global variable). After unset($a) only local $arg is pointing to global $a.
After $a = $arg both local variables are again pointing to global $a, and
local $a value has therefor obviously changed from 'meaning' to 42. Then
after $a = 'of life' both local variables and the global $a is changed to
'of life'. Local $a and global $a have the same names but are different
variables. Also, the local $a after unset($a) happens to have the same name
as the $a before unset($a) but it's a different variable, it could just as
easily been called $b after unset($a). 

A final point: the global $a; in the function doesn't mean it's THE global
$a, it just means it's a local variable called $a pointing to (referencing)
a global variable with the same name. In PHP it has to be the same name
because that's the way the global statement works, but it can sometimes
create the impression that it's the same variable.

Hope I haven't made that as clear as mud.

Cheers
Arno
--


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



RE: [PHP] Obeying the rules (was Simple login form with cookies)

2009-07-10 Thread Arno Kuhl
I'm sure those who've been on this list a while muttered here we go
again... when this thread started. Personally I think if there was a poll
about this the bell curve would have some on the left demanding we all top
post, many on the right of the curve demanding we all bottom post, and a
solid bulge in the middle representing the great unwashed couldn't give a
damn folks (and probably couldn't give a damn to enter the debate). On
the very few occasions I've had anything to contribute I've generally bottom
posted, mostly because I've seen this debate before and partly because I
think it's easier for some people, but I'd place myself in the middle of the
bell curve. I think most people on this list are more than smart enough to
quickly figure out the thread in a post regardless whether the previous
person top posted or not. Most of the regular responders bottom post which
makes up the bulk, but I think if you look at the variety of people who post
it's about 50/50, and most times it doesn't cause any problem at all. I
agree that rules are important, but some are more important than others, and
I think the top-posting rule is pretty low in the list of priorities, more a
useful guide than a rule. Things like personal attacks and attempted mail
spoofing are more important - both happened during the course of this thread
but hardly raised an eyebrow. I also agree that context plays a big part,
because once a thread starts getting complicated with many responses then
bottom posting definitely makes it easier to follow, but most threads don't
get to that stage. Just my 2c.

Cheers
Arno


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



RE: [PHP] PHP doesn't see php.ini

2009-06-26 Thread Arno Kuhl
-Original Message-
From: Tir [mailto:tirsa...@yandex.ru]
Sent: 25 June 2009 08:48 PM
To: php-general@lists.php.net
Subject: Re: [PHP] PHP doesn't see php.ini

 Presume you did restart apache after making the change?
Of course

 Is there anything in your phpinfo output that relates to your php.ini?
I think there must be a mention of MySQL because i've enabled it. But it
isn't there.

 Maybe some error near the beginning of php.ini causes php to stop 
 loading the ini file?
I use a copy of php.ini-recommended from PHP distributive. I don't think
that there could be errors. I've only uncommented few strings to enable
MySQL extensions, set display_errors on and changed extension_dir.

 Check that the extension_dir in phpinfo agrees with the extension_dir 
 in your php.ini.
It agrees.

 Maybe try enabling error logging in the php.ini and check the log file
 - I use apache\logs\phperror.log and invalid extension loading is 
 definitely reported there (I've had this problem before).
That's it, i think. I've enabled display_startup_errors and now on start
apache i receive errors. PHP can't find libraries of MySQL extensions. But
this libraries exactly exist in folder that indicated in error messages. 
What that could be? 

--

Does mysql run from the command line? You can also download MySQL
Administrator from mysql.com and see if it can connect to mysql.

Cheers
Arno


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



RE: [PHP] This Friday's OT Thread

2009-06-26 Thread Arno Kuhl
-Original Message-
From: Michelle Konzack [mailto:linux4miche...@tamay-dogan.net] 
Sent: 26 June 2009 03:20 PM
To: php-general@lists.php.net
Subject: Re: [PHP] This Friday's OT Thread

...and no one care about the foreign (european) sniper WHO  killed  Neda in
Iran.

Note:   I can not reach my Company Website in Tehran nor can I reach  my
Office over fixed telephone lines. I can not even contact one of
my 57 employees  privately.  No  one  has  tried  to  access  my
courier-imap or my webmail server in Germany...

F..king world...  and now Jackson?  WHO IS HE?
--

You've been living in a missile launcher for too long



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



RE: [PHP] PHP doesn't see php.ini

2009-06-25 Thread Arno Kuhl
-Original Message-
From: Bastien Koert [mailto:phps...@gmail.com] 
Sent: 25 June 2009 03:11 PM
To: Tir
Cc: php-general@lists.php.net
Subject: Re: [PHP] PHP doesn't see php.ini

On Wed, Jun 24, 2009 at 8:32 AM, Tirtirsa...@yandex.ru wrote:
 When i installed PHP, I had written to my httpd.conf PHPIniDir 
 c:/php. But
 phpinfo() returns C:\WINDOWS in Configuration File (php.ini) Path 
 row and right path to my php.ini in Loaded Configuration File. It 
 looks like php.ini really isn't used. I think so because when i try to 
 enable MySQL extension it doesn't work (extension=php_mysql.dll, 
 extension=php_mysqli.dll and extension=php_pdo_mysql.dll is 
 uncommented, extension_dir is correct, libmysql.dll is copied to
C:\WINDOWS\system32).
 I've tried to write to php.ini an abracadabra. But I haven't received 
 an error as i expected. I've tried to rename php.ini. phpinfo() has 
 returned (none) in Loaded Configuration File row instead of 
 c:\php\php.ini as that was before. But PHP still worked. It worked 
 without php.ini. It seems very strange. I've searched another php.ini 
 on my system. There is no another one. What's wrong? Why doesn't PHP use
php.ini file?
 --

Did you use an installer or have another version of php installed at some
point?

Bastien

Cat, the other other white meat

--
On my Windows I see the same thing - Configuration File (php.ini) Path
points to C:\WINDOWS (even though there is no php.ini there) and Loaded
Configuration File points to the dir where the php.ini actuall is. My setup
(PHP 5.2.6) works fine. Presume you did restart apache after making the
change? It looks like your php is using your php.ini since phpinfo reports
(none) when you rename it. Is there anything in your phpinfo output that
relates to your php.ini? Maybe some error near the beginning of php.ini
causes php to stop loading the ini file? Check that the extension_dir in
phpinfo agrees with the extension_dir in your php.ini.

Maybe try enabling error logging in the php.ini and check the log file - I
use apache\logs\phperror.log and invalid extension loading is definitely
reported there (I've had this problem before). In php.ini set
log_errors=On and set error_log=c:\apache\logs\phperror.log (or wherever
your apache is installed). Restart apache and check the phperror.log file.
If you find nothing then create a dummy entry to force an error, something
like extension=php_dummy.dll to check that the error logging is working.
If your logging is working and there is no error reported for loading the
mysql extension, and you still see no entry for mysql in phpinfo output,
then you have a different problem, maybe a mysql installation problem.

HTH
Arno


Cat, the other other white meat - looks like the economic downturn hit
really hard... 
Does it go with Weed, the other green tea?



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



RE: [PHP] sessions tutorial

2009-06-19 Thread Arno Kuhl
-Original Message-
From: PJ [mailto:af.gour...@videotron.ca] 
Sent: 18 June 2009 11:28 PM
To: php-general@lists.php.net
Subject: [PHP] sessions tutorial

Top of the list is for real dummies at tizag.com.
So I don't have to search 282,000 entries for php sessions tutorial (doesn't
this say something about the stupidity on the internet - just how many of
those entries could possibly be real and worth looking at?
Since you gurus (I kowtow) have been there, done that, I would appreciate
hearing of a tutorial that will give something more than you can use
sessions in to store information; like what kind of information, just how
is it used e.g. whatis this, where did it come from, what does it mean? --
if (isset($_REQUEST[ReturnToBooksList]))
and  if (!isset($_SESSION[addNewBooks])) - in these examples it come from
inputs. They were not specifically declared or is this a declaration by
itself... how can I find this information so I can understand how to use it?
I really don't want to bother you guys but do you see the futility here?
My little programs are advancing little by little, but boy is it a struggle
to get any information. I eventually dig it out but, frankly, it might be
more productive digging salt mines in the Urals. :-( PJ the bitcher

--
Hervé Kempf: Pour sauver la planète, sortez du capitalisme.
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 

Pour sauver la planète, sortez du capitalisme. - pinko liberal ;)

I'm sure someone else has already proposed this, but... Get an entry-level
book on php, it will answer all your current and future questions about
arrays, forms, sessions, etc. Alternatively look at VTC or Lynda.com for
their excellent video tutorials. I'm sure many of the gurus you refer to
on this list started their path to gurudom by going through one or both
these routes. Definitely easier than digging salt mines, and has the added
advantage of enlightening you to new possibilities you hadn't thought of
before. I've done both (but I'm no guru) and I can definitely recommend
both, especially having a book around for a reference when you want to
quickly check something - easier than trying to find the reference in a
video.

Cheers
Arno


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



RE: [PHP] php applications

2009-06-10 Thread Arno Kuhl
At 11:49 AM -0400 6/8/09, Daniel Brown wrote:
On Mon, Jun 8, 2009 at 11:48, teddt...@sperling.com wrote:
  Hi gang:

  I've heard that php can be used for more than web programming, but I 
 am not  aware of specifically how that can be done. So, let me ask 
 directly -- can  php be used to create a Mac Application?

  If so, how?

 Probably the most well-known method is php-gtk:

 http://gtk.php.net/

I must be getting too old for this stuff.

I'm used to an IDE where you write code, run, and debug it. When you get it
where you want and want to create an application, then you compile the code
and there's an application -- a stand alone application -- done!

But I don't see anything like that there. In fact, if you review their
applications link, you'll see that they don't have any applications either.
It's all There's not any applications in this category ... Maybe you would
like to add one?  Well... a Hello world would be nice.

I downloaded and installed the MacPorts too, but that leaves me wanting for
a simple Hello World example as well, but nothing there either.

In both cases they are very verbose about command line stuff, but short on
how to use php to create an application. I just don't see it. Maybe my
terminology is not correct. My applications stand by themselves and run when
clicked -- no command line is needed.

To me it looks like another one of those other things that everyone says is
great, but I sit here saying Hey, I don't know about you guys, but the
Emperor's naked.

Cheers,

tedd

--

Nusphere has something called PhpDock, but it's for Windows desktop only. I
use their excellent PhpED IDE and have seen references in PhpED for PhpDock
development, exactly as you describe (code-debug-test-encode-deploy all in
PhpED - a well-dressed Emperor). Looking at how they do it I'm not too sure
why PhpDock is Windows-only. From the Nusphere forum I've seen that Mac
users use PhpED fine in wine or vmware, but I don't know if that also works
for PhpDock runtime. I haven't tried any PhpDock development.

http://www.nusphere.com/products/phpdock.htm

Cheers
Arno


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



RE: [PHP] WHILE LOOP PROBLEM

2009-03-27 Thread Arno Kuhl
-Original Message-
From: Andrew Williams [mailto:andrew4willi...@gmail.com] 
Sent: 27 March 2009 10:12 AM
To: PHP LIST
Subject: [PHP] WHILE LOOP PROBLEM

can some tell why the below loop stop running after some time.

$start=10;
const run=0;
while($start run){

//do somthing

}

--

The webserver or php environment is probably terminating the script. It will
only run for the max number of seconds set in your php.ini file.

Arno


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



RE: [PHP] Frameworks / obstinate?

2009-03-23 Thread Arno Kuhl
-Original Message-
From: Sancar Saran [mailto:sancar.sa...@evodot.com] 
Sent: 23 March 2009 11:52 AM
To: php-general@lists.php.net
Subject: Re: [PHP] Frameworks / obstinate?

Probably a bit off topic and

The Game is over man.

Javascript coming with flank speed. Next generation JS Framworks will take
html generation jobs from server side.

Whole thing of Server Side MVC and other yada yada was became joke. Those
server siders become JSON pushers for JS frameworks.

Astrosurfing ?

Yeah, just compare PHP mailing list vs Jquery Mailing list activity.

And The New Game just begun...

Regards

Sancar

--
You seem to suggest the more you do on client side the less you do on the
server. Not sure where you get that from. I'm inclined to think the opposite
- the more you do on the client the more you'll need to do on the server.
Sure there will be certain types of client apps that will all but eliminate
the need for server-side processing, but it's likely more power on the
client will mean internet apps are going to be more powerful all round, both
client and server side.

Arno



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



RE: [PHP] [News] Affordable Independent Web Developer - Search Engine Optimization Services - March 19th, 2009

2009-03-20 Thread Arno Kuhl
Sounds like a good deal - clean your home and develop your home page
all-in-one. A sailor friend once told me about all-in-one services he got
when he stopped for shore leave in Bangkok - also sounded like a good deal,
though I don't think it included web development. Experienced sailors
pre-booked appointments with the ship's medic before going ashore so they
could be seen first when they got back. I wonder if there's something
similar with Samantha? Might be a good business: Web Medics. Pre-book an
appointment with us before jumping into your web project - we'll fix it
afterwards.

-Original Message-
From: George Larson [mailto:george.g.lar...@gmail.com] 
Sent: 20 March 2009 05:01 PM
To: Jochem Maas
Cc: Ginkga Studio LLC; Php-general
Subject: Re: [PHP] [News] Affordable Independent Web Developer - Search
Engine Optimization Services - March 19th, 2009

Not only that but, judging from the phone number, Samantha cleans also
cleans houses:
http://betterthancleanmaidandmaintenanceservices.com/choose-us/contact-us-ma
inmenu-3/12-contacts/1-name.html

On Fri, Mar 20, 2009 at 10:57 AM, Jochem Maas joc...@iamjochem.com wrote:

 Ginkga Studio LLC schreef:
  Today's Date: March 19th, 2009
 
  Hello,
I'm a real person sending you this email - this is an initial 
  contact opt-in request for permission to contact you for web 
  development services.
 
  WHO I AM AND MY INTENTIONS:
  I'm an affordable, independent web developer, been in business for 
  about 5 years. Interested in building a new website for you or help 
  you on your current site.

 you realise you just posted to a list of web developers, right?


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




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



RE: [PHP] Weird pdo-mysql behavior

2008-11-13 Thread Arno Kuhl
Suppose I have two tables Contracts and Clients that are connected using 
ClientId field.

This is a stripped sample code that doesn't work:

?php


function getClientFullName($id,$dbh){


$query = SELECT * FROM Clients WHERE Id=.$id;

$sthr = $dbh-query($query);


$res = $sthr-fetch(PDO::FETCH_ASSOC);


return $res['Name'];


}


try {

$dbh = new PDO('mysql:host=localhost;port=3306;dbname=ins', 'root', 
'', array(PDO::ATTR_ERRMODE=PDO::ERRMODE_EXCEPTION,PDO::ATTR_PERSISTENT 
= true));


$sql = SELECT * FROM Contracts;

$sth = $dbh-query($sql);


print pre;


while($res = $sth-fetch(PDO::FETCH_ASSOC)) {

$name = getClientFullName($res['ClientId'],$dbh);

print $name.br;

}

} catch (Exception $e) {

print $e-getMessage();

}

?

And when I say it doesn't work I mean that that I get:

Call to a member function fetch() on a non-object


When calling: getClientFullName


BTW try to top post.

-- 
Thodoris
--

Hi Theodoris

First place I'd look is to see if the sql query was successful. 
If it failed you'll get this error.
You can try a simple test

$sth = $dbh-query($sql);
if ($sth == FALSE) {
print failed;
exit;
}

Arno


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



RE: [PHP] DOCTYPE, javascript and Firefox

2008-10-31 Thread Arno Kuhl
-Original Message-
From: Andrew Ballard [mailto:[EMAIL PROTECTED] 
Sent: 30 October 2008 05:15 PM
To: [EMAIL PROTECTED]
Cc: PHP - General
Subject: Re: [PHP] DOCTYPE, javascript and Firefox

The pragmatic approach says that you've already fixed it: just leave
the DOCTYPE out. :-)

I'm not sure what yours should be, but based on the snippet of HTML
you posted, yours should not be HTML 4.01. Since you are closing the
input/ tags, you should probably be using one of the XHTML DOCTYPEs
(as long as the rest of your markup is consistent). I'm not sure that
would fix your issue, though.

As for why your page does that, I'm not really sure. If you leave the
DOCTYPE off the the browser will select the DOCTYPE it wants to use.
Perhaps since you declared the document to be HTML 4.01 Transitional,
Firefox is applying JavaScript rules where you can't refer to an
element in script simply using its ID attribute. You usually have to
use something like:

 document.getElementById('autostartlabel').className = 'disable';

Andrew

-- 

Hi Andrew and Ross, thanks a lot - using getElementById sorted it out. As
for the DOCTYPE the scripts aren't consistent enough yet to use one of the
XHTML DOCTYPEs, but it's work in progress. Maybe starting that process
caused the problem because I remember testing this successfully in FF, the
reason I persevered so long was I knew it once worked.

As a matter of interest is there a way to see what DOCTYPE the browser chose
to use? The browser is obviously smarter than I am in selecting DOCTYPEs so
maybe I should follow its cue.

Thanks to everyone else who kindly responded as well, I really appreciate
it.

Cheers
Arno


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



[PHP] DOCTYPE, javascript and Firefox

2008-10-30 Thread Arno Kuhl
I came across an odd thing with DOCTYPE, javascript and Firefox 3 that has
me stumped. Not exactly a php issue but hoping someone else on the list has
seen this before. (At least the script is php, hope that counts)

I have the following code in my header script:

echo !DOCTYPE HTML PUBLIC \-//W3C//DTD HTML 4.01 Transitional//EN\
\http://www.w3.org/TR/html4/loose.dtd\;\n;


Elsewhere I have (simplified):

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


It's simply 2 radio buttons and if yes is clicked related form fields are
enabled, if no is clicked they're disabled.

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

Cheers
Arno


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



RE: [PHP] DOCTYPE, javascript and Firefox

2008-10-30 Thread Arno Kuhl
 

-Original Message-
From: tedd [mailto:[EMAIL PROTECTED] 
Sent: 30 October 2008 03:58 PM
To: [EMAIL PROTECTED]; 'PHP - General'
Cc: Arno Kuhl
Subject: Re: [PHP] DOCTYPE, javascript and Firefox

At 3:45 PM +0200 10/30/08, Arno Kuhl wrote:
I came across an odd thing with DOCTYPE, javascript and Firefox 3 that 
has me stumped. Not exactly a php issue but hoping someone else on the 
list has seen this before. (At least the script is php, hope that 
counts)

I have the following code in my header script:

echo !DOCTYPE HTML PUBLIC \-//W3C//DTD HTML 4.01 Transitional//EN\
\http://www.w3.org/TR/html4/loose.dtd\;\n;


Elsewhere I have (simplified):

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


It's simply 2 radio buttons and if yes is clicked related form fields 
are enabled, if no is clicked they're disabled.

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

Cheers
Arno

Arno:

Wild guess, place this --

?php header('Content-Type: text/css; charset=UTF-8'); ?

-- before the DOCTYPE

HTH's,

tedd

--
---

Hi tedd

Thanks for the suggestion. What it did though was output the html as text
rather than render the html. At least it's consistent across all browsers...
I tried changing it to Content-Type: text/html; which rendered the html
but still gave a js error in FF.

Cheers
Arno


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



RE: [PHP] Apache blocking certain requests instead of php

2008-07-24 Thread Arno Kuhl
 I'm getting a lot of bogus requsts in the form of 
 index.php?id=http://64.15.67.17/~babysona/logo.jpg?;, sometimes more 
 than a hundred a day per domain. The php script catches it, logs the 
 request, sends an email report and replies with access denied, but 
 it takes processing which I'd rather not have php busy with. (The php 
 script rejects anything where id=something_not_numeric.) Is there a 
 way for apache to catch these requests before passing it to php? Is it 
 more efficient for apache to handle this than php?
 
 Arno
 

Yes, in Apache turn off userdir access
In your httpd.conf file do this.
UserDir disabled
That way it will not process url that starts with a tildy ~...
That should take care of it.  Apache should then only report a 404 error to
the error log for the given virtual host.

--
Thanks for the reply. Is that correct htough? I always thought in the
example 
http://mysite.com/index.php?id=http://64.15.67.17/~babysona/logo.jpg?
the url started with index.php...

Most the requests though look more like
http://mysite.com/index.php?id=http://calebsbirth.pisem.su/caleb.htm?
without the tilde.

I was hoping there's a way to tell apache to block requests where
id=non_numeric.

Cheers
Arno


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



RE: [PHP] Apache blocking certain requests instead of php

2008-07-24 Thread Arno Kuhl
 Is there a
 way for apache to catch these requests before passing it to php? Is it 
 more efficient for apache to handle this than php?

2 x yes. I think you could probably use LocationMatch and ban all access
with Deny from all. 

/Per Jessen, Zürich

--
Thanks for replying Per. Isn't Deny from all more to do with apache
accessing local files on my server? These images aren't on my server, and
the requests aren't trying to access images on my server. What I see are
requests using the php script on my server to try access an image file (or
html or txt or php) on someone else's server. I was hoping there's a way to
tell apache to block requests where id=non_numeric.

Cheers
Arno


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



RE: [PHP] Apache blocking certain requests instead of php

2008-07-24 Thread Arno Kuhl
 I was hoping there's a way to tell apache to block requests where 
 id=non_numeric.

It's trying to do a remote inclusion.

It's easy for you to fix in php:

if (isset($_GET['id'])) {
if (!is_numeric($_GET['id'])) {
die(Die hacker die!);
}
}

I'm sure there would be a way to do it with ModRewrite or something but it's
5 lines of code in php so I'd do it there *shrug*.

--
Thanks, I'm already doing something like that, but I want to stop it getting
to php.

Cheers
Arno


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



RE: [PHP] Apache blocking certain requests instead of php

2008-07-24 Thread Arno Kuhl
Hi Arno

No, when you use Location it's not filesystem specific any more. But I've
just found out that you can't match on the query-string.

 These images aren't on my server, and
 the requests aren't trying to access images on my server. What I see 
 are requests using the php script on my server to try access an image 
 file (or html or txt or php) on someone else's server. I was hoping 
 there's a way to tell apache to block requests where id=non_numeric.

I think you'll have to use URL rewriting.

Try this:

http://jessen.ch/arnokuhl?id=nonnumeric

That should give you a 403.

http://jessen.ch/arnokuhl?id=

Should give you a print_r() output.

This is the rewrite config:

RewriteEngine on
RewriteCond %{QUERY_STRING} id=[^0-9]+
RewriteRule (/arnokuhl.*) $1 [f]

HTH
Per


Many thanks for all your effort and help Per. That's exactly what I was
trying to achieve.

Cheers
Arno


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



[PHP] Apache blocking certain requests instead of php

2008-07-23 Thread Arno Kuhl
I'm getting a lot of bogus requsts in the form of
index.php?id=http://64.15.67.17/~babysona/logo.jpg?;, sometimes more than a
hundred a day per domain. The php script catches it, logs the request, sends
an email report and replies with access denied, but it takes processing
which I'd rather not have php busy with. (The php script rejects anything
where id=something_not_numeric.) Is there a way for apache to catch these
requests before passing it to php? Is it more efficient for apache to handle
this than php?

Arno


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



RE: [PHP] Forum coded in PHP with mail and news gateway

2008-06-12 Thread Arno Kuhl
Not sure about the gateways but you can look at www.phpbb.com


-Original Message-
From: Michelle Konzack [mailto:[EMAIL PROTECTED] 
Sent: 11 June 2008 04:52
To: PHP - General
Subject: [PHP] Forum coded in PHP with mail and news gateway

Hello,

because it is actual for me while having  some  problems  with  Ubuntu's
LAUNCHPAD (does not support threating) I like to know, whether there  is a
light Forum software written in PHP availlable.

It should support:

1)  PostgreSQL  (my own database)
2)  MySQL   (my current hosting provider offer it only)
3)  Threating
4)  Gateway to mailinglist including threating
5)  Gateway to usenet including threating
6)  Subscriber only
7)  Scanning for SPAM  :-D

I like to install it on my devel website  and  have  the  need  for  a
category for each software package I have.  So it is  not  a  big  thing
with currently 61 packages bu maybe increase to arround 150.

My current mailinglist software is courier-mlm which works nicely.

Any suggestions?

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


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


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



[PHP] Problem with script timing out in php 4.4.8

2008-06-04 Thread Arno Kuhl
I recently picked up an issue when I upgraded my IDE, where the browser
window timed out while I was debugging the code. I checked with support and
was told the problem was with php 4.4.8 which they'd upgraded to, so to
confirm I installed 4.4.8 and ran a test - and it seems there is a problem
with 4.4.8.

The test was:

change max_execution_time from 30 to 600 in php.ini - phpinfo confirms
max_execution_time=600

?php 
$t=70; 
echo h2Test timeout - sleep for $t seconds/h2; 
echo sleeping .date('h:i:s').br /; 
sleep($t); 
echo stop sleeping .date('h:i:s'); 
? 

$t=59 works fine, but $t=70 times out.

(Windows 2000, Apache Release 10324100)

I ran the same test successfully with $t=500 seconds on a different machine
running php 4.3.4, everything else the same as the original test pc.

What bothers me a bit is 4.4.8 has been available since February and
checking the archives I see no-one else has reported this problem, which
seems highly unlikely, so I'm wondering if this is specific only to my
environment somehow. Has anyone else had problems with max_execution_time in
4.4.8?

Cheers
Arno


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



RE: [PHP] Problem with script timing out in php 4.4.8

2008-06-04 Thread Arno Kuhl
The fact that 59 seconds worked suggested the ini settings was in effect,
otherwise it would have timed out after 30 seconds (default ini setting).
But I also tested your suggestion:

?php
$t=70;
ini_set(max_execution_time,600);
echo h2Test timeout - sleep for $t seconds/h2;
echo max execution time set to .ini_get(max_execution_time).br /;
echo sleeping .date('h:i:s').br /;
sleep($t);
echo stop sleeping .date('h:i:s'); ?
?

Same result, $t=59 works but $t=70 times out

Cheers
Arno

-Original Message-
From: Ólafur Waage [mailto:[EMAIL PROTECTED]
Sent: 04 June 2008 11:19
To: php-general@lists.php.net
Subject: Re: [PHP] Problem with script timing out in php 4.4.8

Could you try setting the max_execution_time with ini_set and confirming the
status of it with ini_get ?

- Waage

2008/6/4 Arno Kuhl [EMAIL PROTECTED]:
 I recently picked up an issue when I upgraded my IDE, where the
 browser window timed out while I was debugging the code. I checked
 with support and was told the problem was with php 4.4.8 which they'd
 upgraded to, so to confirm I installed 4.4.8 and ran a test - and it
 seems there is a problem with 4.4.8.

 The test was:

 change max_execution_time from 30 to 600 in php.ini - phpinfo confirms
 max_execution_time=600

 ?php
 $t=70;
 echo h2Test timeout - sleep for $t seconds/h2; echo sleeping
 .date('h:i:s').br /; sleep($t); echo stop sleeping
 .date('h:i:s'); ?

 $t=59 works fine, but $t=70 times out.

 (Windows 2000, Apache Release 10324100)

 I ran the same test successfully with $t=500 seconds on a different
 machine running php 4.3.4, everything else the same as the original test
pc.

 What bothers me a bit is 4.4.8 has been available since February and
 checking the archives I see no-one else has reported this problem,
 which seems highly unlikely, so I'm wondering if this is specific only
 to my environment somehow. Has anyone else had problems with
 max_execution_time in 4.4.8?

 Cheers
 Arno


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



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





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



RE: [PHP] Conditional popup driven from server-side

2008-04-08 Thread Arno Kuhl
 Arno Kuhl [EMAIL PROTECTED] wrote: 
 I know popup windows are a client-side issue, but I can't figure how 
 to create and close a popup window from the server side only on 
 condition, otherwise display normal browser page.
 
 What I want is to accept a form, check the input, if there are errors 
 return them to the browser, if there aren't errors then popup a modal 
 window and start processing (a possibly long process) while displaying 
 results in the popup window, then automatically close the popup after 
 processing is complete and redirect to normal browser page with the 
 final results. I want to use the popup to (a) feedback ongoing 
 progress to the user, and (b) keep the browser side alive because the
process could take several minutes.
 
 Googling for +php +popup is getting me nowhere, all the results are 
 for javascript. I know how to create a link or button that when 
 clicked will create a popup that will display the results of a php 
 script, but I need to do it the other way round. Can anyone please 
 suggest some pointers on how to generate a conditional popup from the 
 server, and then get the server to close it when done.
 
 Thanks
 Arno

That's because it is a CLIENT side issue, the server isn't able to do it.

If you want to provide feedback on the form, then look into Ajax or use
output buffering and flushing to push out a status message as the form is
processed.  You could do this in a javascripted pop-up window or on the
window they submitted the form.

If it takes your script minutes to process a form  you need to look into
your processes.  I'd suggest verifying the form had all the pieces and then
advising them you will email them when the registration or what-not is
complete.

HTH,
Wolf
===

I fully understand this is a client side issue, but figured there may be a
way for the server to drive it using smoke and mirrors. For instance if the
input is ok I thought of redisplaying the completed form with an onload to
popup a modal window, then output progress to the window until the process
was finished, then send something to the window to close itself. But after
that I get stuck because I don't know how to make the underlying browser
page request the final results from the server, or have some way for the php
script to push the results to the page without a request. Or maybe it's all
javascript, with the browser page waiting for the window to close before
requesting the results? (though I see some timing issues with that solution,
unless I create a temp results page waiting for the browser's request). Has
anyone on the list done anything like this, or have any pointers, examples
or ideas? (BTW Wolf's suggestion of sending the results via email is not an
option in this case)

Thanks
Arno


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



[PHP] Conditional popup driven from server-side

2008-04-07 Thread Arno Kuhl
I know popup windows are a client-side issue, but I can't figure how to
create and close a popup window from the server side only on condition,
otherwise display normal browser page. 

What I want is to accept a form, check the input, if there are errors return
them to the browser, if there aren't errors then popup a modal window and
start processing (a possibly long process) while displaying results in the
popup window, then automatically close the popup after processing is
complete and redirect to normal browser page with the final results. I want
to use the popup to (a) feedback ongoing progress to the user, and (b) keep
the browser side alive because the process could take several minutes. 

Googling for +php +popup is getting me nowhere, all the results are for
javascript. I know how to create a link or button that when clicked will
create a popup that will display the results of a php script, but I need to
do it the other way round. Can anyone please suggest some pointers on how to
generate a conditional popup from the server, and then get the server to
close it when done.

Thanks
Arno


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



RE: [PHP] PHP date: ISO year = loss of hair

2007-12-14 Thread Arno Kuhl
-Original Message-
From: tedd [mailto:[EMAIL PROTECTED] 
Sent: 14 December 2007 04:50
To: [EMAIL PROTECTED]; php-general@lists.php.net
Cc: Arno Kuhl
Subject: Re: [PHP] PHP date: ISO year = loss of hair

At 10:02 AM +0200 12/14/07, Arno Kuhl wrote:
I'm battling with getting the last week number using date(W, 
$unixdate). If the date is 30 December 2007 ($unixdate=1198965600)

Not accordingly to my calculations -- try it:

http://webbytedd.com/c/unix-time/

Cheers,

tedd

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

--
The standard date calculations don't show a week number. If you use
1198965600 as the decimal seconds in your form you'll see that the human
date is 30 December 2007 12:00:00. But if you try date(W, 1198965600) you'll
get a value of 01 for the week number. This conforms to the ISO date
standards, but it doesn't help much when you're trying to calculate the real
week number. Luckily (?) this year is a bit of a fluke or I might not have
detected this error in my script - the next time it happens is in 2012. I
fixed it by taking the long code route: use the week number for December 28
 if the date is  December 28 , check for a sunday between December
28 and the date and increment the week number. I now get week 53 for 30
December 2007.

Cheers
Arno

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



RE: [PHP] PHP date: ISO year = loss of hair

2007-12-14 Thread Arno Kuhl
-Original Message-
From: Andrew Ballard [mailto:[EMAIL PROTECTED] 
Sent: 14 December 2007 04:38
To: PHP General list
Subject: Re: [PHP] PHP date: ISO year = loss of hair

If the last week of the year is the one that has Dec. 28 in it, and the last
week number is 52, then Dec. 30 SHOULD return 1. Dec. 30 is not in the 53rd
week of 2007; it is in the first week of 2008 according to the ISO, so a
week number of 1 is correct.

Andrew

--

You're right. I didn't spell out what I was doing. My script calculates week
53 for 30 December 2007 (at least now it does), week 54 for 9 January 2008,
week 55 for 16 January 2008 etc, if I start calculating from some date in
2007. It calculates the number of weeks between dates. The problem was if I
specifically used 30 or 31 December 2007 in the calculation it fell over -
if the end date was 30/31 Dec 07 I got 52 weeks less than the actual count,
and if the start date was 30/31 Dec 07 I got 52 weeks more than the actual
count. All the other dates worked fine, and would have worked fine for the
next 4 years. The next time week 53 occurs is in 2012.

Cheers
Arno

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



[PHP] PHP date: ISO year = loss of hair

2007-12-13 Thread Arno Kuhl
I'm battling with getting the last week number using date(W, $unixdate). If
the date is 30 December 2007 ($unixdate=1198965600) then date(W, $unixdate)
returns 01. I know that according to the ISO spec, the last week of the ISO
year has 28 December in it, so in this particular case the last week number
of the ISO year is 52. However 30 December is in the following week, week
53. How do I get the correct value of 53 for 30 December 2007? 

I'm thinking along the lines of: if the date is greater than 28 December
then use the week number of 28 December; then check every day between 28
December and the date to see if a Sunday occurs and if so add one to the
week number. It looks like it will work but seems ridiculously laboured for
such a simple issue. Am I overlooking something obvious here - is there
something I've missed about PHP date? Any pointers would be greatly
appreciated.

Thanks
Arno

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



RE: [PHP] IDE

2007-11-16 Thread Arno Kuhl
-Original Message-
From: William Betts [mailto:[EMAIL PROTECTED] 
Sent: 16 November 2007 05:13
To: [EMAIL PROTECTED]
Cc: David Giragosian; php-general@lists.php.net
Subject: Re: [PHP] IDE

Have you ever used Zend Studio? If so how does it compare to PhpED?

---

I've tried Zend Studio a few times, but I certainly can't say I'm familiar
with it enough to give any real comparison. I looked at the Zend tools
pretty closely 4 years ago, and quite superficially a couple of times since
then. I found ZS slow and cumbersome, and not very intuitive (probably due
to unfamiliarity more than anything else). I'm sure each has it's strengths
and weaknesses. I decided on PhpED because (a) it was fast and intuitive and
I felt comfortable with it straight away, coming from c dev background using
IBM dev tools, (b) it had everything I expected in an IDE and more, (c) the
response from NuSphere and the forums was quick, (d) it was much cheaper
than ZS. Since making the choice I find PhpED very stable, and the updates
are frequent with real useful new features and functionality. The latest
version has a feature I requested a few months ago  so the developers are
generally good at listening to feedback and requests. And the debugger is
excellent. PhpED is the single most important dev tool I have and well worth
the investment, and I'm not sure the extra cost for ZS would have given me
any extra value. But I'm sure there are many ZS users who would disagree.
Best advice is do what I did - download both trial versions and give them a
thorough test yourself. What you feel comfortable with is likely different
to what I feel comfortable with.

Arno

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



RE: [PHP] IDE

2007-11-16 Thread Arno Kuhl

-Original Message-
From: David Giragosian [mailto:[EMAIL PROTECTED] 
Sent: 16 November 2007 05:21
To: php-general@lists.php.net
Subject: Re: [PHP] IDE

On 11/15/07, Jammer [EMAIL PROTECTED] wrote:

 Børge Holen wrote:
  On Thursday 15 November 2007 21:35:04 Jammer wrote:
  Hi All,
 
  This is my first post here ... I'm very much a newbie to php but 
  work during the day using SQL Server, VS2005 and Foxpro.  Looking 
  to gen up on my PHP.
 
  Are there any IDE's for PHP worth checking out.  Particularly free
 ones!
 
  TIA,
 
  --
  jammer
  www.jammer.biz
 
  I LOVE this IDE quiz'
  the same answers everytime.

 duh!

 look, i'm really sorry everyone ... we all make mistakes!

 if this is a question that comes up as often as it appears from the 
 responses this thread has generated maybe the FAQ needs to *really* 
 address that?

 http://uk3.php.net/FAQ.php

 --
 jammer

It's OK. I think there's been a long thread on the subject each of the last
two weeks. The folks who are really passionate about their IDE's jump in
first, then those less motivated or less interested add theirs, then it
seems to die for a day or so before it rises from the ashes to sputter and
hiccup a time or two. And then it starts all over, again.

If you stick around long enough on this list, you'll be fussin' at the
question, too.

David
--

I think jammer's idea is a good one. I've been lurking on this list for
years and seen many resurrections of the IDE thread. It's an important
thread, and the PHP IDE world is ever changing and new products come onto
the scene every now and then. I use my favourite commercial IDE but quite
frequently check out the other IDE's mentioned in those threads, mostly to
confirm the choice I made 4 years ago is still the right one. A
well-maintained list of free and commercial PHP IDE's on the php.net site
would be a great idea, especially if it also had links to reviews, and also
included the mix-n-match IDE's I see some people on the list use. And/or
maybe a forum on php.net dedicated to PHP IDE's, with user polls. Then
whenever the IDE thread pops up the response would be to look at the web
site (RTFWS). The only downside might be the resources to run it.

BTW jammer, if you start using php for big projects I'd recommend NuSphere
PhpED, but it's overkill if you just want to dabble. There's a trial version
if you want to check it out, and a good tip is they drop the price every now
and then for promotions (wish I knew that 4 years ago).

Arno

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



RE: [PHP] Generating foldout menus in php

2007-09-04 Thread Arno Kuhl
 I'm looking for a way to generate dropdown/foldout menus (horizontal 
 and
 vertical) on the fly, but all the javascript solutions I've seen use 
 absolute or relative pixel positioning, which means I can't use them 
 because I don't know at the time of generating a specific menu item 
 how many pixels across or down the preceding items have already used. 
 I'm currently using a javascript menu that works really well, but all 
 the top-level menu items have to be preset with specific x-y pixel 
 coordinates, and all the subsequent items are then relative to the 
 top-level items. So I can generate the second-level and subsequent 
 items on the fly but not the top-level items. Is there a way to use 
 css or dhtml or something else (maybe something in javascript that I
missed) to do this?

Is this: http://www.phpguru.org/static/dynContext.example.html what you
mean?

--
Richard Heyes


--
Thanks for the reference Richard. dynContext looks pretty good and is
similar to what I'm already using, but it looks like it also uses x-y
coordinates for the top-level item (looking at the show() function, unless I
misunderstood the manual).

I had problems making it work on my local machine. The
annotated.example.html displayed an error code (I presume) on right click.

BTW I stumbled across cssplay in my search and think it may be the solution.
Just trying to figure if lack of support for IE5 is a problem or not
(supports IE5.5 etc and all other browsers).

Cheers
Arno

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



RE: [PHP] Generating foldout menus in php

2007-09-04 Thread Arno Kuhl
This may not be directly php related but I'm hoping that generating the 
code with PHP will keep it on topic.

I'm looking for a way to generate dropdown/foldout menus (horizontal 
and
vertical) on the fly, but all the javascript solutions I've seen use 
absolute or relative pixel positioning, which means I can't use them 
because I don't know at the time of generating a specific menu item how 
many pixels across or down the preceding items have already used. I'm 
currently using a javascript menu that works really well, but all the 
top-level menu items have to be preset with specific x-y pixel 
coordinates, and all the subsequent items are then relative to the 
top-level items. So I can generate the second-level and subsequent 
items on the fly but not the top-level items. Is there a way to use css 
or dhtml or something else (maybe something in javascript that I missed) to
do this?

Thanks
Arno

Arno:

There's really no way to do this just using php. I can envision a way to use
php with a couple of other languages to provide drop-down and pop-out menus,
but that would be more complicated than just using css with js, like so:

http://sperling.com/examples/menuh/

http://sperling.com/examples/menuv/

Why complicate your life?

Cheers,

tedd

--

Hi tedd

Thanks, that's pretty much what I was looking for. I found something similar
at cssplay, except the examples I saw didn't use .htc file. Like your
examples the cssplay code only runs on IE5.5 and up (and other browsers).
Not sure yet if that would be a problem. I don't have IE5 to test with, so I
don't know if there's a graceful fallback that would still allow the user to
navigate. As you said, it doesn't look like there's a solution to fit all
browsers and versions.

Cheers
Arno

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



[PHP] Generating foldout menus in php

2007-09-03 Thread Arno Kuhl
This may not be directly php related but I'm hoping that generating the code
with PHP will keep it on topic.

I'm looking for a way to generate dropdown/foldout menus (horizontal and
vertical) on the fly, but all the javascript solutions I've seen use
absolute or relative pixel positioning, which means I can't use them because
I don't know at the time of generating a specific menu item how many pixels
across or down the preceding items have already used. I'm currently using a
javascript menu that works really well, but all the top-level menu items
have to be preset with specific x-y pixel coordinates, and all the
subsequent items are then relative to the top-level items. So I can generate
the second-level and subsequent items on the fly but not the top-level
items. Is there a way to use css or dhtml or something else (maybe something
in javascript that I missed) to do this?

Thanks
Arno

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



RE: [PHP] PHP debugger

2007-05-16 Thread Arno Kuhl
If you don't see any change in phpinfo then maybe it's not picking up the
dbg extension in your php.ini. Presumably you've also put the other debugger
directives in your ini?

You can also try download the trial version of PHPEd from Nusphere, install
that, and check how it configures the debugger. The trial lasts a month I
think, so maybe you'll sort out your problems in that time anyway. Just be
sure to completely uninstall it afterwards because I think the free dbg
version is not the same as the version integrated in PHPEd. Any version
differences cause the extension to not load, though in that case it should
report an error. You can't use the dbg integrated in PHPEd after uninstall
because it doesn't work without PHPEd.

Arno


-Original Message-
From: Miles Thompson [mailto:[EMAIL PROTECTED]
Sent: 15 May 2007 08:21
To: PHP List
Subject: [PHP] PHP debugger


I am trying to load a PHP debugger in our most recent build of PHP 5.2.1.

The debugger which I am trying to set up is the free, pre-compiled
Linux version of dbg ( DBG 2.15.5 dbg modules), from
http://dd.cron.ru/dbg/, and all of the instructions have been followed
as posted on the NuSphere site.

Yes, Apache has been stopped and restarted!!

There is no difference in the output from phpinfo(). The line
with DBG v2.11.30, (C) 2000,2004 by Dmitri Dmitrienko, http://dd.cron.ru;
does not appear.

PHP is compiled without debugging, but I did consider that was for the
purpose of debugging PHP itself, not scripts.

Suggestions will be most welcome. Also, I'm not married to this, so if
anyone thinks there is a better debugger, please jump in.

Regards - Miles Thompson

PS Why are we doing this? Because we are getting tired of debugging
with Javascript alert()  boxes. /mt

PPS And we are using those because of Joomla!  Some things are buried
so deeply we cannot use print() or echo(). /mt

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

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



[PHP] Why does this encoding work in PHP?

2007-05-04 Thread Arno Kuhl
I recently came across a script that was oddly encoded. A bit of digging
revealed it was encoded in octal. What puzzles me is why the php interpreter
is able to understand the script.

An example (not from the original script)

require_once ../file.php;
require_once \56\56\57\146\151\154\145\56\160\150\160;

Arno

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



RE: [PHP] Ide help needed

2007-04-02 Thread Arno Kuhl
Nuspere's PHPEd. Highly recommended. I looked at all the alternatives,
including Zend and Eclipse, and IMO PHPEd is superior. And faster
performance is a real bonus.

Arno


-Original Message-
From: Davi [mailto:[EMAIL PROTECTED]
Sent: 02 April 2007 02:50
To: php-general@lists.php.net
Subject: Re: [PHP] Ide help needed


Em Sexta 30 Março 2007 14:39, [EMAIL PROTECTED] escreveu:
 I am a beginer with php and i need to know which IDE is best suited
 under windows and linux both

 i have seen dreamweaver working and have heard about GoLive too but don't
 know whichone to go for

 can you please help me decide
 and also
 tell me some other IDE's if possible

Does anyone knows any IDE for PHP like VisualStudio.net?

TIA

--
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--

Agora com fortune:
Beneath this stone lies Murphy,
They buried him today,
He lived the life of Riley,
While Riley was away.

--

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



[PHP] Newline and tab characters

2007-03-26 Thread Arno Kuhl
I've just noticed that \r\n and \t characters create a space when
rendered in the browser (tested in IE and Firefox). I'd always thought the
browser would ignore these characters. This wouldn't normally be a problem
but the wysiwyg html editor in the cms I'm using tries to be friendly by
formatting the html code, so something like

span style=\COLOR: #af0e14\get/spanspan style=\COLOR:
#33\online/span

becomes

\r\n\t\tspan style=\COLOR: #af0e14\get/span\r\n\t\tspan
style=\COLOR: #33\online/span

and instead of being displayed as getonline it's displayed as get online.

Is there a simple way to sort this out or do I need to create a function to
strip these characters before display, checking first that they don't occur
within a pre tag in which case I mustn't strip them.

TIA
Arno

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



RE: [PHP] using return in include files

2007-01-23 Thread Arno Kuhl
-Original Message-
From: Aaron Axelsen [mailto:[EMAIL PROTECTED]
Sent: 23 January 2007 06:12
To: php-general@lists.php.net
Subject: [PHP] using return in include files


I'm trying to figure out what the desired behavior is of using the
return function to bail out of an include page.

I did some testing, and this is what I concluded.

First, I created the following file:

?php
if (defined('TEST_LOADED')) {
return;
}
define('TEST_LOADED',true);
echo blah blah blah blahbr/;
?

I then called it as follows:
include('test.php');
include('test.php');
include('test.php');

The output is:
blah blah blah blah

Second, I changed the test.php file to be the following:

?php
if (defined('TEST_LOADED')) {
return;
}
define('TEST_LOADED',true);
echo blah blah blah blahbr/;

function myFunc($test) {

}
?

When I load the page now, it throws the following error: PHP Fatal
error: Cannot redeclare myfunc()

It appears that if there are functions in the include page that you
can't use return to bail out.  What is the desired functionality in this
case?  Is this a bug in how php handles it? or was return never designed
to be used this way?

Any thoughts are appreciated.

--
Aaron Axelsen
[EMAIL PROTECTED]



Include works as though the include statement line is replaced by the code
that is being included. So try the following exercise and it should become
obvious why you're getting that error: copy-and-paste the code from test.php
into the code that includes test.php for each line that includes test.php,
and then delete each of those include lines (I'll comment them out). You end
up with:

?php
// include('test.php');
if (defined('TEST_LOADED')) {
return;
}
define('TEST_LOADED',true);
echo blah blah blah blahbr/;

function myFunc($test) {

}

// include('test.php');
if (defined('TEST_LOADED')) {
return;
}
define('TEST_LOADED',true);
echo blah blah blah blahbr/;

function myFunc($test) {

}

// include('test.php');
if (defined('TEST_LOADED')) {
return;
}
define('TEST_LOADED',true);
echo blah blah blah blahbr/;

function myFunc($test) {

}
?

Run that and you should get exactly the same error. Interestingly under php4
neither your code nor my expanded version of your code throws an error, so I
assume you're using php5?

If you're trying to avoid including the file more than once you could use
include_once, but I've had problems with that - the file was previously
included but not in the same scope, so it wasn't included second time it was
called and yet none of the included file's contents existed. The way I got
round it was by assigning a value in the include file, and then testing for
that value before including the file.

For example:

test.php
?php
$testphp_loaded = TRUE; // - must be outside any function or braces
.
.
.
?

main.php
?php
if (!$testphp_loaded) {
require('test.php');
}
?

You can't use a define for this because it has a much wider scope and you
end up with the same problem as using include_once.

Arno

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



RE: [PHP] most powerful php editor

2007-01-21 Thread Arno Kuhl
-Original Message-
From: Vinicius C Silva [mailto:[EMAIL PROTECTED]
Sent: 21 January 2007 02:54
To: php-general@lists.php.net
Subject: [PHP] most powerful php editor


hi everyone!

i'd like to ask something maybe commonly asked here. what is the most
powerful php editor?

=

There've been lots of good replies to this, and I figured I'll add my 2c

I spent several months trying out many editors and IDE's on the Windows
platform about 3 years ago - all the usual suspects, most have been
mentioned in other replies - and settled on Nusphere's PHPEd (an IDE rather
than an editor). Every year when it comes time to renew my license (which I
had to do 2 weeks ago) I look at what else is available and new, try out the
latest versions of some of the candidates that made it to my short list, and
then renew my license anyway because it's worth every cent and because for
me there's nothing that matches it. There are lots of good editors and a few
good IDE's, but every one I tried had some or other niggle that put me off:
buggy software, slow performance, missing or shallow functionality, bitty
integration, etc. Nusphere's PHPEd was the 2nd most expensive (at the time)
but it hit the sweet spot and I've never regretted buying it. A bonus was
finding that the response from the support forum was good, and updates are
regular and stable and meaningful. A real bonus was finding that the most
recent license renewal is now valid for 3 years instead of 1 year. So I'll
only be looking at the competition again in 3 years time - unlike Stut I
hope this question is asked at least once a year because I'd like to hear
what's new.

For me the analogy goes something like this: if you type the occasional
letter or note then Wordpad is perfectly adequate, but if your livelihood is
churning out professional well-formatted heavy-weight documents then it pays
you to invest in a top-class word processor and supporting tools. The same
goes for an IDE.

Arno

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



RE: [PHP] most powerful php editor

2007-01-21 Thread Arno Kuhl
-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED]
Sent: 22 January 2007 01:32
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Subject: RE: [PHP] most powerful php editor


On Mon, 2007-01-22 at 01:22 +0200, Arno Kuhl wrote:

 For me the analogy goes something like this: if you type the occasional
 letter or note then Wordpad is perfectly adequate, but if your livelihood
is
 churning out professional well-formatted heavy-weight documents then it
pays
 you to invest in a top-class word processor and supporting tools. The same
 goes for an IDE.

I think I just vomited in my mouth...

Yep, tastes like bile :|

Cheers,
Rob.
--

Hope you get over it :)

So you don't think EditPlus or UltraEdit or Notepad++ (some of the proposed
editors that I consider Wordpad-type editors) would be a bit inadequate
for more complex project developments? Some people who've never been exposed
to a really good IDE think this is as good as it gets.

Arno

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



RE: [PHP] most powerful php editor

2007-01-21 Thread Arno Kuhl
-Original Message-
From: John Meyer [mailto:[EMAIL PROTECTED]
Sent: 22 January 2007 03:15
To: php-general@lists.php.net
Subject: Re: [PHP] most powerful php editor


Dear god  Arnot, would you like to stand back for a moment and consider
how retarded those statements are, or would you like for me to do it for
you?

Whether you use a powerful IDE or not, you still have to use the same
compiler underneath.  In PHP, that compiler is the web server.  Unless
you buy an IDE that contains a mini-server for you to test the files,
yoru comparison between IDEs and word processors is ludicrous at best.

==

That's the point I was trying to make, but obviously not very well.

A good PHP IDE does have a built-in web server. It can do profiling,
debugging, error high-lighting, project level function cross-checking,
scope-checking, defines checking, version control, internal ftp, db
front-end, and a whole truckload of other features that help you manage
large projects. Sure it's not going to turn a monkey into a coding guru, but
it's sure going to help anyone trying to manage large complex environments.
I had the fortune to work with a brilliant IBM IDE years ago when I was
working in C, and I discovered how much more you can get done (code and
complexity) when you use the right tools. When I moved to PHP I struggled
for the first while working on a project with more than a hundred files and
more than a hundred db tables, using a bunch of unintegrated tools to get
the job done. I could make it work but it was a laborious process of
cross-checking every step of the way. And the biggest problem was no
debugger. Now with a real IDE I can work between 4 and 10 times as fast, and
tackle bigger projects and far more complex stuff. But as Robert said, to
each their own.

BTW I did once have the misfortune of having to prepare about 100 documents
for ECITE back in 2002, each doc about 20-50 pages. Between projects and
short of cash. I'm no document formatter - I far prefer coding for 18 hrs a
day than spending 18 hrs a day formatting documents, no matter how good the
word processor. I believe there are people who lap this kind of stuff up,
but I'm not one of them. I got the job done but would never do it again. A
good example where the right tools can't turn a monkey into a pro. But my
point is that not even the pro's could do it properly without the right
tools.

Arno

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



  1   2   >