Re: [PHP] output buffering in CLI script.

2008-02-28 Thread Jochem Maas

Stuart Dallas schreef:

On 28 Feb 2008, at 11:52, Stut wrote:

On 28 Feb 2008, at 11:39, Jochem Maas wrote:
I can't seem to manage to buffer output (of an included file) in a 
CLI script,

the following does not work:


  // buffer output so we can avoid the shebang line 
being output (and strip it from the output we log)

  $oldIFvalue = ini_set('implicit_flush', false);
  ob_start();

  if ([EMAIL PROTECTED] $script) {
  ob_end_clean();
  } else {
  $output = explode(\n, ob_get_clean());
  if ($output[0]  preg_match('%^#!\/%', 
$output[0]))

  unset($output[0]);
  }

  ini_set('implicit_flush', $oldIFvalue);


the reason I'm wanting to do this is, primarily, in order to stop the 
shebang line that *may*

be present in the included script from being output to stdout.


On my local machine here PHP does not output the shebang line. AFAIK 
it detects and strips it at the compilation phase. Have you tried it?


Hang on, ignore that. You're including the file, not running it on the CLI.

What do you mean when you say it doesn't work? Do you mean you get no 
output?


I mean that the shebang line at the top of the included file is output
to stdout even when I turn on output buffering on prior to including the file.

nothing else is output but that's because the script doesn't generate any 
further
output - it logs everything instead - and I know it runs because the relevant 
lines
appear in the relevant log file.



I suggest you remove the @ at the start of the include while developing 
it. Or alternatively spit something out after you call ob_end_clean so 
you know it couldn't include the file.


the @ is niether here nor there with regard to the problem I have, well more
of an annoyance - nobody is going get hurt by some spurious output to stdout but
it looks messy.

just to clarify - I need to be able to run the script directly (as an 
executable) and
be able to include it within another script ... so the shebang line is needed
(well I could hack around it with a wrapper script to use directly on the 
command line
or run it using /usr/bin/php foo.php ... but I don't find either of those 
satisfactory)





-Stut



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



Re: [PHP] Guidance

2008-02-28 Thread Jochem Maas

Stut schreef:

On 28 Feb 2008, at 12:15, Timothy Asiedu wrote:
Please I would be grateful if you could remove my e-mail address: 
[EMAIL PROTECTED] from the general Mailing List.


Unsubscribe instructions are in the footer of every email you receive 
from this list. Follow them to get your favourable response.


lol ... who gave him a ieee.org address in the first place :-)




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


-Stut



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



Re: [PHP] output buffering in CLI script.

2008-02-28 Thread Jochem Maas

Nathan Rixham schreef:

Jochem Maas wrote:


...



-Stut



bit of false logic here but have you tried:

eval(ltrim(file_get_contents($script),$shebang));


haven't tried it, did consider it. I hate eval() :-)





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



[PHP] [SOLVEDish] Re: [PHP] output buffering in CLI script.

2008-02-28 Thread Jochem Maas

Stuart Dallas schreef:

On 28 Feb 2008, at 12:29, Jochem Maas wrote:

Stuart Dallas schreef:

On 28 Feb 2008, at 11:52, Stut wrote:

On 28 Feb 2008, at 11:39, Jochem Maas wrote:
I can't seem to manage to buffer output (of an included file) in a 
CLI script,

the following does not work:


 // buffer output so we can avoid the shebang line 
being output (and strip it from the output we log)

 $oldIFvalue = ini_set('implicit_flush', false);
 ob_start();

 if ([EMAIL PROTECTED] $script) {
 ob_end_clean();
 } else {
 $output = explode(\n, ob_get_clean());
 if ($output[0]  preg_match('%^#!\/%', 
$output[0]))

 unset($output[0]);
 }

 ini_set('implicit_flush', $oldIFvalue);


the reason I'm wanting to do this is, primarily, in order to stop 
the shebang line that *may*

be present in the included script from being output to stdout.


This works...



indeed ... I tested it and it works on my server too. my code is no different
to yours with regard to the context of the problem. so what's going on.

I think (I know) I forgot to mention one tiny little detail.
the whole 'include' code occurs in a script that forks itself ...
the script forks itself a number of times and each child then performs
the include.

so I tested the fork issue with your script ... it still bloody works,
(see the for loop below) so it's something else ... I thought it might
be the difference between using ob_get_clean() and 
ob_get_contents()+ob_end_clean()
but that doesn't seem to be it either.

the worse thing is my script has just stopped outputting the shebang lines of
the included script(s) ... oh well ... the problem is solved, dunno how, dunno 
why,

situations like these I'd rather the problem didn't go away .. I prefer to know
wtf happened!


test.php
#!/usr/bin/php
?php
echo arse\n;


for ($i = 0; $i  3; $i++) {
$pid  = pcntl_fork();
if ($pid == 0) {
echo Inc('testinc.php');
exit;
}
}



function  Inc($f)
{
ob_start();
@include($f);
$content = ob_get_contents();
ob_end_clean();
if (substr($content, 0, 2) == '#!')
{
$content = substr($content, strpos($content, \n)+1);
}
return $content;
}
/test.php

testinc.php
#!/usr/bin/php
?php
echo testinc\n;
/testinc.php

output
[EMAIL PROTECTED]:~$ ./test.php
arse
testinc
/output

-Stut



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



Re: [PHP] [NOT SOLVEDish] Re: [PHP] output buffering in CLI script.

2008-02-28 Thread Jochem Maas

Jochem Maas schreef:

...



indeed ... I tested it and it works on my server too. my code is no 
different

to yours with regard to the context of the problem. so what's going on.

I think (I know) I forgot to mention one tiny little detail.
the whole 'include' code occurs in a script that forks itself ...
the script forks itself a number of times and each child then performs
the include.

so I tested the fork issue with your script ... it still bloody works,
(see the for loop below) so it's something else ... I thought it might
be the difference between using ob_get_clean() and 
ob_get_contents()+ob_end_clean()

but that doesn't seem to be it either.

the worse thing is my script has just stopped outputting the shebang 
lines of
the included script(s) ... oh well ... the problem is solved, dunno how, 
dunno why,


situations like these I'd rather the problem didn't go away .. I prefer 
to know

wtf happened!


wtf happened was I was looking at the wrong output. I changed my code to
be as much like your test code as possible (to the point that I now
use a function to perform the buffering and 'include' and returning output) ... 

the output buffering is not working at all.

I've had enough - /dev/null meet script output, output meet /dev/null




test.php
#!/usr/bin/php
?php
echo arse\n;


for ($i = 0; $i  3; $i++) {
$pid  = pcntl_fork();
if ($pid == 0) {
echo Inc('testinc.php');
exit;
}
}



function  Inc($f)
{
ob_start();
@include($f);
$content = ob_get_contents();
ob_end_clean();
if (substr($content, 0, 2) == '#!')
{
$content = substr($content, strpos($content, \n)+1);
}
return $content;
}
/test.php

testinc.php
#!/usr/bin/php
?php
echo testinc\n;
/testinc.php

output
[EMAIL PROTECTED]:~$ ./test.php
arse
testinc
/output

-Stut





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



Re: [PHP] Re: [SOLVEDish] Re: [PHP] output buffering in CLI script.

2008-02-28 Thread Jochem Maas

Nathan Rixham schreef:

how's this?

#!/usr/bin/php
?php
class trimshebang {
  function filter($in, $out, $consumed, $closing)
  {
while ($bucket = stream_bucket_make_writeable($in)) {
  $bucket-data = ltrim($bucket-data,#!/usr/bin/php\n);
  $consumed += $bucket-datalen;
  stream_bucket_append($out, $bucket);
}
return PSFS_PASS_ON;
  }
}

stream_filter_register(trim.shebang, trimshebang);
include php://filter/read=trim.shebang/resource=/path/to/include.php;
?

bit more graceful ;)


it's sick, I like it, nice example of streams filtering while your at it.
I learned something! it also works in so far that the shebang line is no longer
output but the output buffering in *my* script(s) doesn't work, whilst the same
construction does work in Stut's test scripts (although whilst playing with
his script I did manage to bork ik so that the output buffering *doesn't* work
there anymore ... how I did that I can't fathom)

anyway - they problem has been nicely shoved under the carpet. apart from
the shebang lines the script don't ever output anything anyway but rather
log to files ... a simple redirect output to /dev/null in the command line
that is used to run the 'master' script will take care of any spurious cruft
ending up on screen.

thanks to everyone for their input regarding my output! :-)





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



Re: [PHP] Start/stop daemon using php

2008-02-27 Thread Jochem Maas

David Sveningsson schreef:
Hi, I've written an application in c which I would like to start/stop as 
a daemon in gnu/linux.


The application has the argument --daemon which forks the process and 
exits the parent. Then it setups a SIGQUIT signal handler to properly 
cleanup and terminate. It also maintains a lockfile (with the pid) so 
only one instance is allowed.


So, to start this application I created a php site that calls 
exec(/path/to/binary --daemon  /dev/null 2 /dev/null).


Everything is working so far, but I cannot get the application to 
receive the SIGQUIT when I start using php and exec. Not even manually 
using kill in the shell. It works correctly if I start manually thought.


So, is this possible to do? Doesn't exec allow applications with signal 
handlers? Is there some other way to terminate the application?


there is nothing special about exec that makes working with the kill command
different to anything else, though you might take a look at the posix_kill()
command instead. e.g. posix_kill(`cat /path/to/pidfile`, SIGQUIT);

you say you can't even send SIGQUIT to the daemon using kill on the command 
line,
this suggests the problem lies in the fact that the daemon's signal handler is
not actually working (when the process is daemonized).





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



Re: [PHP] What design patterns do you usually use?

2008-02-27 Thread Jochem Maas

Paul Scott schreef:

On Wed, 2008-02-27 at 19:50 +0800, skylark wrote:

What design patterns do you usually use?


I am not sure that you are understanding what a design pattern is. It is
not a piece of software or a thing to use, but it is a set of repeatable
components that you use in whatever app you are writing. 


Take for instance an observer pattern. When would you use that? Why
would you use that? Have you used it somewhere before and what were the
circumstances? Is it repeatable? Is your previous code re-usable?

Answer some of those questions, look up design patterns (even on
wikipedia to get an overview) and buy some books to see solid examples. 


If you suspect that you need to use a specific pattern, or are
interested in how to implement a specific pattern, write some throwaway
code to do it and ask opinions.

Look at the simple things that you would probably have used already -
factory, singleton and MVC and expand on those a little to get them to
be actual design patterns that you can use/reuse.



there seems to be some misunderstanding ... a design pattern is not
a component (or anything else of substance) but merely a conceptual
strategy used to tackle a problem ... ever find yourself writing code
that's conceptually identical to previously written code (in a different
site/project/context), if so you've got yourself a pattern and as such it's
probably been documented as an 'official' design pattern with suitable fancy
name (something like 'Observer', 'Delegator', 'Factory')

chances are then that you're already using design patterns - it's just
that you don't know them by name :-)


Don't use design patterns because you heard it on TV - same as
Web2.0 _think_ about what it means to you and your enterprise before
asking for a buzzword generator to do your job for you! :)

--Paul





All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 





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



Re: [PHP] What design patterns do you usually use?

2008-02-27 Thread Jochem Maas

Daniel Brown schreef:

On Wed, Feb 27, 2008 at 9:40 AM, David Giragosian [EMAIL PROTECTED] wrote:

On 2/27/08, Daniel Brown [EMAIL PROTECTED] wrote:
  On Wed, Feb 27, 2008 at 6:46 AM, skylark [EMAIL PROTECTED] wrote:
   Hi all,
  
What design patterns do you usually use?
 
 
 This one:
 
 http://www.vam.ac.uk/vastatic/microsites/1486_couture/create.php
 

 Somebody been thinking about wedding attire?


Yeah, but I can't fit into that dress.  ;-P


besides the flower pattern doesn't really suit you, go with blue velvet ;-)





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



Re: [PHP] What design patterns do you usually use?

2008-02-27 Thread Jochem Maas

Paul Scott schreef:

On Wed, 2008-02-27 at 14:48 +0100, Jochem Maas wrote:

Paul Scott schreef:
there seems to be some misunderstanding ... a design pattern is not
a component (or anything else of substance) but merely a conceptual
strategy used to tackle a problem ... ever find yourself writing code
that's conceptually identical to previously written code (in a different
site/project/context), if so you've got yourself a pattern and as such it's
probably been documented as an 'official' design pattern with suitable fancy
name (something like 'Observer', 'Delegator', 'Factory')

chances are then that you're already using design patterns - it's just
that you don't know them by name :-)



Ja, that's what I was trying to say in a long, convoluted,
burning-the-candle-at-both-ends type of way :)


lol ... I often have the same problem ... then Richard Lynch comes along
and explains 'whatever' in a way that the rest of the world does understand :-)



Thanks Jochem for clearing that up!

--Paul





All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 





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



Re: [PHP] What design patterns do you usually use?

2008-02-27 Thread Jochem Maas

Aschwin Wesselius schreef:

Nathan Nobbe wrote:

Surely he didn't explain OOP to you... he's anti OOP :)

ya; im waiting to see one of these 'simple' sites thats written 
strictly w/

functions and procedural code that does more than support a username
and password :)

-nathan
I worked for a company where they maintain an interface for a 
creditcard-billing platform (one of the eight biggest platforms in the 
world). They only have 1 library file for each part of the application 
and they don't do classes at all.


It does millions of transactions per day for clients worldwide and is 
real fast.


So, it can be done. Except that only two persons know where to find the 
code and how to maintain it and it is not documented. I learned a lot at 
that company.


including how to build job-security into your code by the sounds of it ;-)






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



Re: [PHP] What design patterns do you usually use?

2008-02-27 Thread Jochem Maas

Richard Heyes schreef:

What design patterns do you usually use?


Whatever solves the problem. Factory is quite a common one. MVC is another.



anyone considered that 'function' and 'class' (given that we seem to
be flogging the old OOP v. Functions horse) are both design patterns if you
look at it from a generic angle ... both are widely adopted, generally 
understood,
concepts used to solve programming problems.

and to the people arguing about not being able to find their way through other
peoples spaghetti ... that's what a decent IDE is for (i.e. the 'go to 
declaration'
functionality) ... anyone for italian? :-)

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



Re: [PHP] What design patterns do you usually use?

2008-02-27 Thread Jochem Maas

Daniel Brown schreef:

On Wed, Feb 27, 2008 at 12:10 PM, tedd [EMAIL PROTECTED] wrote:

 Sure, I understand that if you want to swap databases (MySQL to
 whatever) having a abstract layer makes it easier. But, it don't make
 it easier for me in the short term.


Or create a simple non-OOP db_query() function and rewrite or
expand that as necessary like I do.

Lynch isn't the only anti-OOP person on this list, after all ;-P

Rephrase: I'm not necessarily anti-OOP, I just choose not to use
it.  I can work with it, I can read it, and I can update it but I
don't do my own applications that way when building from the ground
up.

Most of my code is like public school on a Sunday or that one
uncle that no one in the family likes to acknowledge: no class.


that explains your taste in dresses :-)





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



Re: [PHP] Sometimes I wonder why I even started programming...

2008-02-27 Thread Jochem Maas

Jason Pruim schreef:
So I was supposed to go home a half hour ago but that didn't happen... I 
hate deadlines! :P


in my home language Pruim means prune ... you sound like you've had to suck on
one to many ;-)



Can someone tell me why this code works for setting the table name:


dunno. lets rewrite the thing shall we? let cutdown on variable usage, shorten 
some
names and use a verb rather than a noun to name the function ... and let's learn
about 'by reference' parameters (notice the '' before '$table')

function authenticate($user, $pass, $table)
{
// do you want to stop/catch 're-authentication'?
if ($_SESSION['loggedin'])
return;

// escape your data!
$pass = 
mysql_real_escape_string(md5(someThingOnlyDanBrownCouldGuess.$pass));
$name = mysql_real_escape_string($user);

// only select what you need (no semi-colons [needed] to delimit the 
query)
// name + password should be unique! so no real need for the LIMIT 
clause
$res  = mysql_query(SELECT tableName FROM current WHERE loginName='{$name}' 
AND loginPassword='{$pass}' LIMIT 0,1);

// I think a die() is overkill
// rather an abrupt end to the script, such errors can be with more 
grace
if (!$res)
die(Wrong data supplied or database error  .mysql_error());

// nobody found - bad credentials, authentication failed
if (!mysql_numrows($res))
return false;

// grab data
$row = mysql_fetch_assoc($res);

// set session data
$_SESSION['user']   = $user;
$_SESSION['loggedin']   = true; // use a BOOLEAN ... because NO 
equates to TRUE!

// no idea what this 'table name' is about but ...
// let's set the 'by reference' variable to the value we found
$table = $row['tableName'];

// user authenticated!
return true;
}


which you would use like so:

$spoon = null;
if (authenticate(Jochem, MySecret, $spoon))
echo authenticated! table is set to $spoon;
else
echo authentication failed, there is no \$spoon;


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]






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



Re: [PHP] Guidance

2008-02-27 Thread Jochem Maas

Matty Sarro schreef:

Greetings all!
I am still relatively new to any kind of web design or php programming, I'll
be completely honest. I am used to working with C, Perl, Java, and a splash
of C++. PHP and web application development are kind of a new bag for me and
I'm still trying to get my bearings. I see that designing a web application
can involve all of the following: html, javascript, php, sql, ajax, xml,
design patterns, and other things. Its kind of... information overload right
now? For what I want to do I know I'm going to need to learn all of them,
but coming up with a roadmap for what should I learn first? is becoming
problematic. I want to start working on projects but I'm just not sure what
order to learn things in. I don't want to come up with something that works,
and then have to re-write it all over again simply because I read a new
chapter in a new book.

I would just like some advice on what order to go about this stuff. Thanks!


HTML, xHTML, XML - the basics of this are simple enough - the intricasies will
show their ugly head as time goes by. outputting something that a browser will 
grok
is a piece of cake, in time you'll get the hang of generating output that's 
100% valid :-)

javascript - learn as you go, start with cut and paste solutions and work up 
from
there as required, plenty of people never bother with javascript at all for 
accessibility
reasons. basically anything you want to make dynamic (singing and dancing) on 
the clientside
(i.e. in the browser) will require javascript (okay so there is Java and Flash 
also buts
that's beside the point)

AJAX (or AJAS ;-) in our neck of the woods) is basically the use of javascript 
to
run HTTP requests 'in the background' of a page, i.e. grabbing/sending some 
data from the
server without refreshing the page (and then presumably manipulating the 
existing page
based on the results of said background request ... AJAX can get fairly 
advanced and I think
you'll know when you actually need it.

Design Patterns (there is another current thread about this) - basically it 
comes down
to applying known concepts/paradigms/strategies to solve a problem ... patterns 
apply to
all walk of programming life ... my guess is you've 'used' them plenty in other 
languages even
though you may not have recognized them as such ... writing clear and 
maintainable code is probably
the best pattern to apply to development ;-)

PHP, the king of web-development languages, *this is the place to start* if 
your interested in
server-side coding (you could specialize in client-side stuff only - there are 
plenty that do).

SQL, very shortly after your first php script is up and running you'll be 
wanting to
store stuff in a database - SQL is the means to manipulate the data ... 
learning SQL, especially
the mySQL variant, will come naturally when you dive into php because the 
practical ties
between the 2 are so strong ... what's a dynamic website with out persistent, 
changeable data?

rewrite stuff? yes you will, garanteed, many times over. this doesn't ever stop 
:-)
apart from the odd occasion when you throw something away and forget it ;-) you 
could
consider using perl instead of php ... perl's write-only nature would admonish 
you
from any rewriting responsibilities :-P

so basically? start writing some crufty php ... find yourself diving into HTML 
and SQL before
you know it and then rewrite the cruft as and when new understanding presents 
itself :-) it's
the road most of us walked (except for Tedd, he programmed the Rocks[tm] used 
to build the
road)


-Matthew



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



Re: [PHP] Guidance

2008-02-27 Thread Jochem Maas

Stut schreef:

On 27 Feb 2008, at 20:59, Daniel Brown wrote:

   So let this be at least a basic retort to those who don't consider
web development real programming.  Because you'd be surprised how
much I hear, oh, you work with web stuff, I thought you meant you
were a real programmer.

   Well, I'm not.  I'm an engineer.  At least according to my 
paycheck.  ;-P


I hear that a lot and by the numbers it's fairly accurate.

In my experience there is a big difference between a web developer and a 
software engineer. If someone is hiring a web developer then I'm not 
interested. If they want a properly engineered website then I might be 
interested.


I guess it's a matter of semantics. to me 'developer' means 'engineer' in terms
of a being able to perform high-level problem analysis, designing a solution
and implementing it ... within budget, whilst keeping an eye on the actual
[commercial] goals of the client (as opposed to the goals a client might speak 
of ...
what a client says they need, and what they actually need aren't often the same)

what others might consider a 'developer' I'd call a 'programmer' - someone
whoe takes my analysis and proposed solution and makes a botch job of 
implementing it ...
with the added bonus of not actually ever thinking about their creation outside
the confines of their little fish bowl.

I've interviewed more than my fair share of web developers who 
couldn't reverse an array without using array_reverse if their life 
depended on it. Sometimes it really does scare me!


are there any other restrictions other than not to use array_reverse()? ;-)



So my experience is that there are far more web developers out there 
than software engineers who do web development, and it's getting harder 
to find decent software engineers to do web-based work at a reasonable 
price. The good ones are rare - so rare in fact that I'm having trouble 
finding one at the moment. If anyone considers themselves a software 
engineer rather than a web developer and would like a job in Windsor 
drop me a note.


-Stut



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



Re: [PHP] Guidance

2008-02-27 Thread Jochem Maas

Daniel Brown schreef:

On Wed, Feb 27, 2008 at 4:34 PM, tedd [EMAIL PROTECTED] wrote:

 I would include DOM scripting and understanding what the current buzz
 words mean (i.e., graceful degradation, unobtrusive code, accessible,
 functional, secure, and compliant).


I was going to include terminology as a line item, but decided
against it.  DOM is a good addition though.

We also generally know:
* Content writing
* Graphic design and manipulation
* Media and marketing
* 

That's going overboard though.  I don't want to get involved in
doing that stuff for an employer any more than I must.  I don't even
especially enjoy doing it for my own projects.


you forgot thick skin, ability to work 24-7 (and eat, sleep,  web tech),
and a razor sharp sense of humour (with exception to those that succumb to
the Ruby crack pipe)





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



Re: [PHP] Functions not available when run as Scheduled Task?

2008-02-27 Thread Jochem Maas

Brian Dunning schreef:
Don't laugh but we have a Win 2003 Server set up with WAMP, and the 
PHP/MySQL scripts work great. I set one up to run as a scheduled task:


C:\php5\php.exe D:\wamp\www\scriptname.php

...but nothing happens and the Scheduled Tasks log says that it exited 
with an (ff). So I entered the above manually into a command prompt, and 
it said that mysql_connect() is an unknown function! WTF? It's like it's 
trying to use a different php.ini file that maybe has mysql commented 
out. I double checked that all the php.ini files on the machine do have 
mysql enabled, and anyway mysql works fine normally.


Anyone know what PHP is doing to me here in the scheduled service?


AFAIK php on windows is generally built with all relevant modules included
(check the php.ini used by apaches mod_php and you'll probably notice the
extension=php_mysql.dll line is actually commented out)

my guess would be that the CLI version of php is built without the mysql
extension.

and if it's not that then it's probably down to difference in php.ini after all.





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



Re: [PHP] Guidance

2008-02-27 Thread Jochem Maas

Stut schreef:

On 27 Feb 2008, at 23:25, Jochem Maas wrote:

Stut schreef:


I DID NOT!! It was him! I only schreef in private!



that's what they all say ... my thunderbird knows different ;-)



I've interviewed more than my fair share of web developers who 
couldn't reverse an array without using array_reverse if their life 
depended on it. Sometimes it really does scare me!


are there any other restrictions other than not to use 
array_reverse()? ;-)


well for the record then (it's late, I'm on my third glass of wine,
it could probably be more efficient) ... feel free to use in your
next php3 project :-)

if (!function_exists('array_reverse')) {
function array_reverse($a, $pk = false) {
$r = array();

if ($pk) {
do {
end($a);
$v = each($a);
$r[ $v[0] ] = $v[1];
} while (array_pop($a)  count($a));
} else {
while ($i = array_pop($a)) $r[] = $i;
}

return $r;
}
}

function ar($a, $pk = false) {
$r = array();

if ($pk) {
do {
end($a);
$v = each($a);
$r[ $v[0] ] = $v[1];
} while (array_pop($a));
} else {
while ($i = array_pop($a)) $r[] = $i;
}

return $r;
}




Well, implemented in PHP would be nice, but nothing beyond that. There 
are many different ways to do it.


skinacat.com

It's worth noting that I've asked the same question to more than a few 
interviewees for traditional C/C++ roles, and I never came across one 
that couldn't do it which I find quite interesting.


Incidentally, the same distinction between engineers and developers 
applies here too, it's certainly not specific to web development.


hmm. thing is you need a bit of paper to call yourself an engineer .. I ain't
got one.



-Stut



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



Re: [PHP] How do you send stylized email?

2008-02-26 Thread Jochem Maas

tedd schreef:

Hi gang:

I want to send a styled email via heredoc, can that be done?

$message = EOT
Title: This is a title of the Event.
Time: This the time of the Event.

Please show up on time.
EOT


that's just string generation ... 'style' equates to harassing people
with HTML emails ... which will require a message built using the multipart mime
specification ... for which you'll want to grab a ready built lib/class
in order to save your self the hassle.

recommended: phpmailer (google it)

which you can then pull apart to see exactly how it works (it's work
comprises of building the $message into a format that mail readers will
understand as multi-part mime.)



mail('[EMAIL PROTECTED]' , 'An Event' , $message);

If so, how do you style it?

If not, how do you send stylized email?


style comes naturally to some of us ;-)

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



Re: [PHP] How do you send stylized email?

2008-02-26 Thread Jochem Maas

tedd schreef:

At 3:46 PM +0100 2/26/08, Jochem Maas wrote:

style comes naturally to some of us ;-)


:-)

Yes, but it eventually comes to style=oldeveryone/style


only if your markup is correct

quot;but it eventually comes to span class=oldeveryone/spanquot;

;-)



Cheers,

tedd


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



Re: [PHP] How do you send stylized email?

2008-02-26 Thread Jochem Maas

tedd schreef:

At 4:10 PM +0100 2/26/08, Jochem Maas wrote:

tedd schreef:

At 3:46 PM +0100 2/26/08, Jochem Maas wrote:

style comes naturally to some of us ;-)


:-)

Yes, but it eventually comes to style=oldeveryone/style


only if your markup is correct


Now you sound like my wife.  :-)


for your sake I hope I don't look like her :-P
that said I'd hazard a guess and say you listen to what she says ... my ex
used to say the same thing.


It's not what you said -- it's how you said it. (wife)

Cheers,

tedd



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



Re: [PHP] RE: temprorary error

2008-02-25 Thread Jochem Maas

Robert Cummings schreef:

On Mon, 2008-02-25 at 14:50 +, Nathan Rixham wrote:






ps: I can't believe how long this thread has lasted without anyone 
mentioning that the subject line is misspelled.

I notice it everytime a post arrives, but usually the content is
juicier :)

Cheers,
Rob.

Ps. Someone follow this up, I don't want to be the last post :B



the subject line is misspelt.

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



Re: [PHP] APC __autoload webclusters

2008-02-22 Thread Jochem Maas

Nathan Nobbe schreef:

On Thu, Feb 21, 2008 at 12:01 PM, Jochem Maas [EMAIL PROTECTED] wrote:


Richard Lynch schreef:

If it's that inter-tangled, then I would hazard a WILD GUESS that the
__autoload will still end up loading everything...

but not on every request ;-) ... I do use output caching, and I know
not everything is actually used in every request.



i think youre good to go w/ autoload not loading everything up, but what
about existing include / require directives?  if the code doesnt already
use __autoload() its almost certainly strewn w/ these.  so i think if you
want the boost from __autoload, not loading up everything, youll at least
have
to strip these out.


I know, I have ... I wrote the code in the first :-)



I know - but it's a rubbish solution because it offer no control as to what

is cleared from the APC cache, sometimes I want to clear opcodes,
sometimes user-data,
sometimes both ... graceful means being forced to clear everything.



you can pass a parameter to apc_clear_cache()
http://www.php.net/manual/en/function.apc-clear-cache.php
that distinguishes what you want to clear; user data or cached opcode.
obviously calling it from the cli will not clear the webserver user cache
though.


I know apc_clear_cache() ... the whole problem is doing it on multiple servers.
your statement about not being able to do it from the CLI (which I know) is half
correct AFAICT - you can't clear anything cached in APC via mod_php from the
CLI ... which is my whole problem in a nutshell :-)



One would think that there was something like this indeed - I cannot find

it,
but then there must be something ... I assume, for instance, that Yahoo!**
occassionally
see fit to clear APC caches on more than one machine and I doubt Rasmus
sits there and
opens a browser to run apc.php on each one ;-)



i dont know how yahoo does it, but i do know a little about how facebook
does it; they had
3 speakers at the dc php conference last year.  i think you might find these
slides helpful,
(sorry for the ridiculuus url)
http://www.google.com/url?sa=tct=rescd=1url=http%3A%2F%2Ftekrat.com%2Ftalks_files%2Fphpdc2007%2Fapc%40facebook.pdfei=tce9R9T4FqrszATeiZG6CAusg=AFQjCNF_1Ecm2cL1EINgRQG9k3fTEclzpAsig2=ifrJK545M2liBdXbRrHrIw


thanks for that link - it gives me a few angles and ideas to work on!


you can use capistrano to deploy the new files; but it may be more
convenient to use php
and http requests to update all the server caches; *just a thought*.


I'm not using capistrano for file deployment (files are stored centrally
on a GFS volume to which all servers have access) ... I am (will be) using
capistrano in order to run commands symultaneously on all webservers ...
one of which will have to be some kind of cache control mechanism, which is
the case of apc will probably be a php script that hits apc.php on the local
machines webserver (but I want to be able to run said php script on
multiple machines at once, or at least without having to log in to every
machine ... and I see no reason to duplicate the functionality of capistrano,
I just write a php script to do the actual apc.php interaction on the
local webserver that cap can call on each machine.


there are optimizations that are possible as well, such as setting,
apc.stat=0 and


got that one set already. :-)


using apc_compile_file() rather than clearing the entire cache, but these
techniques add


I read the facebook story about preloading the cache (using memory 
dumping/loading)
in combination with apc_compile_file() ... which is cool but a little too much
effort given the time/budget I have to complete this (my client doesn't have
X billion to burn ... but funnily enough they do have a viable business model 
...
but that's another story ;-)


complexity.  it sounds like you just want to get a decent bumb w/o too much
additional
complexity, so i wouldnt recommend them here, but i thought id mention them
in passing..


apart from writing some kind of management cli script to [remote] control the
apc cache of each webserver I'm also going [to have to] incorporate memcache
functionality into my current caching stuff - many thanks for that PDF link
(I hadn't come accross it before in my searching, although I had discovered
various other facebook+apc/memcache/caching related presentations) it's given me
jsut enough code and ideas to hang myself with ... er I mean write a transparent
memcache layer into my app :-)



-nathan



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



[PHP] APC __autoload webclusters

2008-02-21 Thread Jochem Maas

hi people,

1. __autoload  APC

I have been STW to try and find a definitive answer as to whether using 
__autoload with APC
is a bad idea ... and if so why? ... I can't find that definitive answer, can 
anyone here
state whether this it's an absolutely bad idea to use __autoload with APC? (I 
need to
speed up an app that currently loads in pretty much everything on every request 
... and it's
impossible to untangle the class interdependencies, in the time I have, and 
thereby load only
what is absolutely needed, when it's needed ... so I want to give __autoload() 
a shot in order
to minimize what classes are loaded.

2. webclusters  APC

I'm building a load-balanced cluster for the same app ... a certain times new 
data is imported
from a thirdparty system after which some APC cached data needs to be cleared, 
in the same vein
I occasionally roll out a new version and then the APC opcode cache needs to be 
cleared (each webserver
in the cluster has it's own APC cache obviously).

now I'm stuck with the problem of how to trigger the cache clearance on all 
servers ... Greg Donald
already mentioned the ruby based capistrano for executing commands on multiple 
remote servers and I'll
be using that to manage things like cache clearance, webserver restarting, etc 
on all the webservers

... BUT I have found that it is not possible to control the APC cache of 
php_mod from the CLI version of
php, they apparently use different APC caches. it seems that the only way to 
control the APC cache of
mod_php is via a web interface. APC ships with the very handy apc.php script 
but this is hardly a decent
way of controlling/clearing the APC cache of multiple machine programmatically.

Am I stuck with one of:

1. doing a graceful restart of all servers (which causes APCs cache to 
disappear)?
2. writing a cmdline script that performs a URL request to a copy of apc.php 
that is reachable via each
webserver in order to clear/manage the APC cache?

or is there another way that I can control the webserver's APC cache from the 
cmdline?

rgds,
Jochem

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



Re: [PHP] APC __autoload webclusters

2008-02-21 Thread Jochem Maas

Richard Lynch schreef:

On Thu, February 21, 2008 9:27 am, Jochem Maas wrote:

1. __autoload  APC

I have been STW to try and find a definitive answer as to whether
using __autoload with APC
is a bad idea ... and if so why? ... I can't find that definitive
answer, can anyone here
state whether this it's an absolutely bad idea to use __autoload with
APC? (I need to
speed up an app that currently loads in pretty much everything on
every request ... and it's
impossible to untangle the class interdependencies, in the time I
have, and thereby load only
what is absolutely needed, when it's needed ... so I want to give
__autoload() a shot in order
to minimize what classes are loaded.


If it's that inter-tangled, then I would hazard a WILD GUESS that the
__autoload will still end up loading everything...


but not on every request ;-) ... I do use output caching, and I know
not everything is actually used in every request.

I'm being optimistic and hoping it has a marginally positive effective on
average request processing time.




2. webclusters  APC

I'm building a load-balanced cluster for the same app ... a certain
times new data is imported
from a thirdparty system after which some APC cached data needs to be
cleared, in the same vein
I occasionally roll out a new version and then the APC opcode cache
needs to be cleared (each webserver
in the cluster has it's own APC cache obviously).

now I'm stuck with the problem of how to trigger the cache clearance
on all servers ... Greg Donald
already mentioned the ruby based capistrano for executing commands on
multiple remote servers and I'll
be using that to manage things like cache clearance, webserver
restarting, etc on all the webservers

... BUT I have found that it is not possible to control the APC cache
of php_mod from the CLI version of
php, they apparently use different APC caches. it seems that the only
way to control the APC cache of
mod_php is via a web interface. APC ships with the very handy apc.php
script but this is hardly a decent
way of controlling/clearing the APC cache of multiple machine
programmatically.

Am I stuck with one of:

1. doing a graceful restart of all servers (which causes APCs cache to
disappear)?


Yes, that should work.


I know - but it's a rubbish solution because it offer no control as to what
is cleared from the APC cache, sometimes I want to clear opcodes, sometimes 
user-data,
sometimes both ... graceful means being forced to clear everything.




2. writing a cmdline script that performs a URL request to a copy of
apc.php that is reachable via each
webserver in order to clear/manage the APC cache?


Yes, but obviously password-protect it to avoid DOS.


yeah - think this is the route I have to take somehow .. I'm going to look into
running a seperate vhost only available via 127.0.0.1, with a pwd on it and then
write a little script that can control the apc cache via said vhost from the
cmdline ... the cmdline script would then be controlled remotely via ssh using
the coolness that is capistrano (http://www.capify.org/)




or is there another way that I can control the webserver's APC cache
from the cmdline?


One would think there would be some kind of USR_* signal that can be
sent through Apache to APC to clear cache...


One would think that there was something like this indeed - I cannot find it,
but then there must be something ... I assume, for instance, that Yahoo!** 
occassionally
see fit to clear APC caches on more than one machine and I doubt Rasmus sits 
there and
opens a browser to run apc.php on each one ;-)

** is it too early to say 'MicroHoo!' ?





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



[PHP] Re: [PHP-DEV] string operators for assigning class constants

2008-02-20 Thread Jochem Maas

this is a php generals type of question.

Sebastian schreef:

hi,

why isn't it possible to assign class constants like this:  

class test
{
   const 
DIR='dirname'.DIRECTORY_SEPARATOR.'anotherdirname'.DIRECTORY_SEPARATOR;

}

is there some performance issue?


classes are defined at compile time, so are their const declarations - it's
not possible to evaluate an expression at compile time.

with define('FOO', 'bar'.QUX); you can do it because the define occurs at run 
time.



anyone ever tried this or was there a discussion about it? i would find this 
very useful.


find another way to do 'it' :-)



greetings 



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



Re: [PHP] Php warning message

2008-02-20 Thread Jochem Maas

Yuval Schwartz schreef:

Hello and thank you,

Another question, I get a message:

*Warning*: feof(): supplied argument is not a valid stream resource in *
/home/content/t/h/e/theyuv/html/MessageBoard.php* on line *52*
**
And I've tried troubleshooting for a while; I'm pretty sure I'm opening the
file handle correctly and everything but I can't get feof or similar
functions like fgets to work.


you pretty sure? your code doesn't check that the file handle is valid.



Here is my code if you're interested (it's so that I color every 2nd line in
the text):

*$boardFile = MessageBoard.txt;


do you know what the current working directory is? my guess
is that whatever it is the text file is not in that directory.
try setting an absolute path to the text file e.g.


$boardFile = /path/to/my/MessageBoard.txt;

and then do something like ...


$boardFileHandle = fopen($boardFile,r);


if (!$boardFileHandle)
die ('no messages, or something equally annoying!');


for ($counter = 1; !feof($boardFileHandle); $counter += 1) {
 $colorLine = fgets(boardFilehandle);
 if ($counter % 2 == 0) {
  echo font color='00ff00'$colorline/font;


the font tag is evil - go read alistapart for the next 6 hours ;-)


 } else {
  echo $colorline;
 }
}
fclose($boardFileHandle);*




Thank you



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



Re: [PHP] Static variable in a class method

2008-02-14 Thread Jochem Maas

Pauau schreef:
I have a class method which declares a static variable within.However, 
across all the instances of the class, the current value on that variable 
replicates. Is it the intended functionality? Example: class A {public 
function foo() {static $i=0;$i++;}}$obj1 = new 
A();$obj1-foo(); //$i = 1 $obj2 = new A();$obj2-foo(); //$i = 2 where I 
think it should be 1, becaue it's a new instance. 


the engine doesn't give 2 hoots about what you think it should be of course.
'static' doesn't do what you think.

chances are you want to use a private instance property:

?php
class Foo {
private $i = 0;
public function bar() {
echo $this-i, \n;
$this-i++;
}
}

$a = new Foo;
$b = new Foo;

$a-bar();
$a-bar();
$a-bar();

$b-bar();
$b-bar();
?

do please read the OO sections of the manual, some functionality, although named
similarly to other languages, works quite differently - you'll avoid alot of 
assumption
biting you in the a$$.





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



Re: [PHP] Static variable in a class method

2008-02-14 Thread Jochem Maas

Nathan Nobbe schreef:

On Feb 13, 2008 8:44 PM, Nirmalya Lahiri [EMAIL PROTECTED] wrote:


--- Pauau [EMAIL PROTECTED] wrote:


I have a class method which declares a static variable
within.However,
across all the instances of the class, the current value on that
variable
replicates. Is it the intended functionality? Example: class A {
public
function foo() {static $i=0;$i++;}}$obj1 = new
A();$obj1-foo(); //$i = 1 $obj2 = new A();$obj2-foo(); //$i = 2
where I
think it should be 1, becaue it's a new instance.


Pauau,
 Please visit the link below for help..
http://www.php.net/manual/en/language.oop5.static.php



what you are using is potentially not what you think it is.  you are using
a 'static variable' which is not a static class member. 


actually it pretty much *is* the same - the static class member will exhibit the
same behaviour, only the scope is different.


you can find the
doc on static variables here,
http://www.php.net/manual/en/language.variables.scope.php
im not sure if their behavior is well defined when they are used in classes,
or objects.


behaviour is indentical to usage inside standalone functions.



as Nirmalya, has alluded, you should check out the docs on static class
members.  im sure that you can achieve whatever you need to by using
some combination of static class members and instance variables.

-nathan



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



Re: [PHP] Copying 1000s files and showing the progress

2008-02-14 Thread Jochem Maas

Ritesh Nadhani schreef:

On Feb 13, 2008 6:03 PM, Richard Lynch [EMAIL PROTECTED] wrote:

On Wed, February 13, 2008 4:28 am, Ritesh Nadhani wrote:

I have a situation where I have to copy something like 1000 files one
by one to a temporary folder. Tar it using the system tar command and
let the user download the tar file.

Now while the copy is going on at server, I want to show some progress
to the user at client side. Most of the tutorial I found on net was
about showing progress while a file is being uploaded from client to
server. In this case the client has the info but for my case, the
client has no info.

A similar was problem was solved at
http://menno.b10m.net/blog/blosxom/perl/cgi-upload-hook.html but its
in PERL and uses some form of hook. I have no clue how to do it in
PHP.

Any clues or right direction would be awesome.

First of all, don't do that. :-)

Instead, set up a job system of what should be copied/tarred, and
then notify the user via email.

Don't make the user sit there waiting for the computer!

If you absolutely HAVE to do this due to a pointy-haired boss...

?php
  $path = /full/path/to/1000s/of/files;
  $dir = opendir($path) or die(Change that path);
  $tmp = tmpname(); //or whatever...
  while (($file = readdir($dir)) !== false){
echo $filebr /\n;
copy($path/$file, /tmp/$tmp/$path);
  }
  exec(tar -cf /tmp/$tmp.tar /tmp/$tmp/, $output, $error);
  echo implode(br /\n, $output);
  if ($error){
//handle error here!
die(OS Error: $error);
  }
?

shameless plug:
//handle error here could perhaps use this:
http://l-i-e.com/perror.

--
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?




I was actually doing what you just gave the code for. As of now, I was
doing something like:


for file in files:
   copy from source to folder
   echo Copying files encapsulated in ob_flush()

tar the file which hardly takes time on the filessyetm but does take some time

Provide the link to the tar


So at the client side it was like:

Copying file #1
Copying file #2

Download link

I though I could apply some funkiness to it by using some AJAX based
progress bar for which the example showed some sort of hooking and all
which I thought was too much for such a job. I will talk to my boss
regarding this and do the necessary.

BTW, whats the issue with AJAX based approach? Any particular reason
other then it seems to be a hack rather then an elegant solution
(which is more then enough reason not to implement it...but I wonder
if there is a technical reason to it too)?


the problem with the AJAX approach is the fact that there is absolutely
no reason for a user to sit staring at the screen. hit 'Go' get an
email when it's done, do something else in the mean time.

of course a PHB might demand functionality that gives him/her an excuse to
watch a progress bar ... in which case why not waste man hours making it a
funky web2.0 deal ... heck go the whole hog and use 'comet technique' to
push update info to the browser.





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



Re: [PHP] Static variable in a class method

2008-02-14 Thread Jochem Maas

Nathan Nobbe schreef:

On Thu, Feb 14, 2008 at 6:37 AM, Jochem Maas [EMAIL PROTECTED] wrote:


Nathan Nobbe schreef:

what you are using is potentially not what you think it is.  you are

using

a 'static variable' which is not a static class member.

actually it pretty much *is* the same - the static class member will
exhibit the
same behaviour, only the scope is different.


you can find the
doc on static variables here,
http://www.php.net/manual/en/language.variables.scope.php
im not sure if their behavior is well defined when they are used in

classes,

or objects.

behaviour is indentical to usage inside standalone functions.



thats a gamble since there is no description of how the static keyword
behaves inside class member functions.  i for one will stick to static class
variables and instance variables, and avoid this static variable feature
altogether.


they work the same because they are the same thing. no gamble. nada.



-nathan



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



Re: [PHP] PHP fsockopen with the UNIX abstract namespace

2008-02-13 Thread Jochem Maas

@4u schreef:

Hi,

I have a problem with fsockopen in connection with the UNIX abstract
namespace.

To open a UNIX socket in the abstract namespace I have to add a nul byte
in front of the path.

Unfortunately PHP returns
fsockopen() [function.fsockopen]: unable to connect to unix://:0
(Connection refused)

for unix://\x00/tmp/dbus-whatever which is a bit strange because I
expected at least the error message fsockopen() [function.fsockopen]:
unable to connect to unix://[NUL byte]/tmp/dbus-whatever:0 (Connection
refused)


your problem might be version related, but php does have a C level function
php_stream_sock_open_unix() explicitly for the issue of the NUL byte
(the NUL byte is seen as the end of a string, unless the string handling
is binary safe - if I got the lingo correct).

my first guess would be to use socket_create() in combination with
socket_connect() instead of fsockopen() and see if that does the trick.




Is this a known issue or do I have to set something in the php.ini?

I would appreciate any ideas how to debug this issue.



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



Re: [PHP] PHP fsockopen with the UNIX abstract namespace

2008-02-13 Thread Jochem Maas

@4u schreef:

Hi,

thanks for your help - unfortunately it doesn't help.

With stream_socket_client () I get the message unable to connect to
unix://\0/tmp/hald-local/dbus-ZniNmvr5O0 (Connection refused) in
/root/dbus_session.php on line 272 which is at least better, because it
shows the full path.


is the connection refused a permissions thing here? can you
verify that it's possible to connect?

you might consider attaching php to gdb and seeing where things
go wrong, if the socket itself is fine and usable and your sure
then a bug report is in order, no?

maybe someone smarter cares to comment.



I verified it with

PHP 5.1.2 (cli) (built: Jul 17 2007 17:32:48)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

(It's a Debian based machine)

and

PHP 5.2.5-pl1-gentoo (cli) (built: Dec 29 2007 11:46:44)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with eAccelerator v0.9.5.1, Copyright (c) 2004-2006 eAccelerator, by
eAccelerator

(Gentoo)

socket_create and socket_connect produces the following error:

Warning: socket_connect() [function.socket-connect]: unable to connect
[22]: Invalid argument in ...

again verified on both systems and definitely with the right arguments -
 the socket resource and a [NUL]/tmp/path string as written in the PHP
manual.

Are their other solutions or known problems? If not, I will maybe post
it as a bug - but wanted to make sure that it's not my fault.

Jochem Maas schrieb:

@4u schreef:

Hi,

I have a problem with fsockopen in connection with the UNIX abstract
namespace.

To open a UNIX socket in the abstract namespace I have to add a nul byte
in front of the path.

Unfortunately PHP returns
fsockopen() [function.fsockopen]: unable to connect to unix://:0
(Connection refused)

for unix://\x00/tmp/dbus-whatever which is a bit strange because I
expected at least the error message fsockopen() [function.fsockopen]:
unable to connect to unix://[NUL byte]/tmp/dbus-whatever:0 (Connection
refused)

your problem might be version related, but php does have a C level function
php_stream_sock_open_unix() explicitly for the issue of the NUL byte
(the NUL byte is seen as the end of a string, unless the string handling
is binary safe - if I got the lingo correct).

my first guess would be to use socket_create() in combination with
socket_connect() instead of fsockopen() and see if that does the trick.



Is this a known issue or do I have to set something in the php.ini?

I would appreciate any ideas how to debug this issue.





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



Re: [PHP] Template system in PHP

2008-02-12 Thread Jochem Maas

Xavier de Lapeyre schreef:

Hi,
I need to develop a website, but my management is rather unstable in his
vision for the layout.
I'm thinking of developing the components as classes and functions, and
then use a template system to render the layout.
If the management wishes to change the layout, I'll just have to modify
my template and the jobs' done.

Do any of you guys  gurls know of a way to implement that template
system.

(The best one I know of is that of Wordpress)


you can do better.
don't bother to create your own template system, using something that already
exists. there are plenty of 'php template engines' out there. one of the
most well known is Smarty (http://smarty.net/) which is a good one to start 
with,
they have quite extensive docs and a decent mailing list (things which I feel 
are
worth taking into consideration beyond the purely technical pros and cons when
deciding which one to use).

googling for php+template+engine will get you a stack of possible candidates.

also consider that the way you write your HTML heavily influences how much
you have to change when management  decides on a visual change. if you go the
route of writing very functional HTML (i.e. HTML that makes next to no attempt 
to
provide layout/styling) and use CSS as much as possible to provide the actually
layout/design then you might consider not bothering with a template and just 
using
CSS to implement UI design changes.

to get an idea of exactly how different a single page of HTML can look 
depending on
the CSS that is applied take a look at csszengarden



Regards,
Xavier de Lapeyre
Web Developer



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



Re: [PHP] Better DB Class MySQL

2008-02-10 Thread Jochem Maas

Larry Garfield schreef:

http://www.php.net/pdo

All the cool kids are doing it.


not true - some of them use firebird ;-)



On Saturday 09 February 2008, nihilism machine wrote:

Looking to really beef up my DB class, any suggestions for functions
to add that will be more time saving for a web 2.0 app, or ways to
improve existing methods? thank you everyone in advance.

?php

class db {

//  Members
public $db_user = ;
public $db_pass = ;
public $db_name = ;
public $db_server = ;
public $link;
public $result_id;

//  Methods
public function __construct() {
$this-connect();
}

// Connect to MySQL Server
public function connect() {
$this-link = 
mysql_connect($this-db_server,$this-db_user,$this-

 db_pass) or die(Error: Cannot Connect to DataBase);

mysql_select_db($this-db_name,$this-link) or die(Error: 
Cannot
Select Database ( . $this-db_name .  ));
}

// MySQL Query
public function query($sql) {
$this-result_id = mysql_query($sql);
return $this-fetch_rows();
}

// MySQL Query
public function insert($sql) {
$this-result_id = mysql_query($sql);
return $this-select_id;
}

// MySQL Fetch Rows
public function fetch_rows() {
$rows = array();
if($this-result_id){
while($row = mysql_fetch_object($this-result_id)) {
$rows[] = $row;
}
}
return $rows;
}

// MySQL Affected Rows
public function num_rows() {
return mysql_num_rows($this-link);
}

// MySQL Affected Rows
public function select_id() {
return mysql_insert_id($this-link);
}

// Disconnect from MySQL Server
public function disconnect() {
mysql_close($this-link);
}

// Terminator Style Function simply in coolness
public function Terminator($tbl) {
}

// Destruct!
public function __destruct() {
$this-disconnect();
}
}

?





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



Re: [PHP] Profiling with register_tick_function / declare

2008-02-08 Thread Jochem Maas

Daniel Brown schreef:

On Feb 7, 2008 7:10 PM, Jochem Maas [EMAIL PROTECTED] wrote:

McNaught, Scott schreef:

. Get profile results for novices without having to mess around
installing php binaries such as APD / zend debugger etc

I suppose that includes xdebug?


If xdebug works as a local binary (which it may, I'm not sure),
you'd still have to have a local php.ini and be allowed to override
the server php.ini by configuration, no?

What if both of the above are true, but a user has no permissions
to compile?

While I was going to point out this morning that he failed to
mention xdebug (which is my personal favorite), I still wouldn't
discount his script-based profiler, if he can get it to work.  Imagine
being able to drop that into a project on SourceForge.


indeed - I wasn't discounting his idea, if it works it could be very handy
for situtation where you don't have any server access.





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



Re: [PHP] issues with calling methods twice in a row

2008-02-08 Thread Jochem Maas

nihilism machine schreef:
i have a method called CreateUser() which is public and takes 5 
variables as its data, then adds them to a db. it only executes the 
first method not the other although its all the same but the variable.


ex:

$auth = new auth();
$auth-CreateUser(fake email, 1, fake name, 4);
$auth-CreateUser(fake email, 2, fake name, 4);
$auth-CreateUser(fake email, 3, fake name, 4);
$auth-CreateUser(fake email, 4, fake name, 4);
$auth-CreateUser(fake email, 5, fake name, 4);

any ideas? only the first method gets executed?


no-one can smell the problem with the info you gave.

what is the code for createUser()?
what is does you error log contain?
are you displaying errors? (you should probably do so in a dev environment)
are the 2nd + subsequent calls being made and nothing is entering
in the DB OR are the 2nd + subsequent calls not occuring at all?





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



Re: [PHP] Name of variable to string [SOLVED]

2008-02-08 Thread Jochem Maas

Daniel Brown schreef:

On Feb 8, 2008 4:17 PM, tedd [EMAIL PROTECTED] wrote:

At 10:31 AM -0500 2/8/08, Daniel Brown wrote:

  On Feb 8, 2008, at 10:14 AM, tedd wrote:

  Hi gang:
 
  From a variable with the name of $this_variable -- how do I get a

   string 'this_variable' ?
What Tedd means is this:  ;-P

BINGO! We have a winner!

For those of you who want to know what I'm doing with the solution,
please review:

  http://www.webbytedd.com//var-string/index.php

Warning: Geek meters should be worn at all times and exposure should
be limited. All code is shown.

The problem that I was seeking a solution for was simply an easier
way to grab POST and GET variables and place them into SESSIONs while
keeping the most current values current.

I'm a little disappointed in the solution because I wanted the
statements to be:

$post_var = sessionize_post($post_var);
$get_var = sessionize_get($ger_var);

But, the function provided by Daniel (and found in the literature)
would not work from within my session_post and session_get functions
-- I think it's probably something to do with the scope of the
variable.

In any event, I had to alter the calls to:

 $post_var = @sessionize_post($post_var, vname($post_var));
 $get_var = @sessionize_get($get_var, vname($get_var));


I don't see why this has to be so convoluted - it would be a heck of
a lot easier to do it with a string:

$post_var = @sessionize_post('post_var');

so why exactly is that not an option (or good idea)?



You see, there can be reasons why someone would want to know the
variable's name.

Thanks Daniel and to all who commented.


And thank you for putting credit where it was really due.  I knew
I had gotten that code a couple of years ago from somewhere, but
couldn't remember where.  I hadn't written it, only modified it.  I'm
going to update my code now to put the thanks to section in there to
the person who deserves the credit: Lucas Karisny (lucas dot karisny
at linuxmail dot org).

I had tried to find that each time I referenced the code or used
it myself, but never did.  If only I had R'd TFM.  :-\



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



Re: [PHP] Passing object reference to session

2008-02-07 Thread Jochem Maas

Michael Moyle schreef:

Hi,

I am new to the list and have a question that inspired me to join the
list as I can not find any answer online.

When a object reference is passed to the $_SESSION array what happens to


let's assume php5. all objects are reference like, they behave from a user POV
as objects would in php4 if you passed them by reference explicitly.

that said they're not really references - there is a Sara Golemon article which
explains it ... not that I truely understand the inner machinations of the 
engine.


the object? Is the object serialized and saved in session (in this case
file)? Or just the reference with the object in memory remaining on the
heap? 


php is 'share nothing' architecture ... everything disappears at the end of a
request - nothing remains in memory.

an object stored in $_SESSION will be automatically serialized and saved where 
ever
the session data is saved (usually to disk).

the only thing to remember is that you must have the class of the object stored 
in
$_SESSION loaded *before* you restart the session otherwise php will generate an
object of class stdClass.





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



Re: [PHP] Passing object reference to session

2008-02-07 Thread Jochem Maas

Michael Moyle schreef:

Jochem,

On Thu, 2008-02-07 at 09:11 +0100, Jochem Maas wrote:

Michael Moyle schreef:

Hi,

I am new to the list and have a question that inspired me to join the
list as I can not find any answer online.

When a object reference is passed to the $_SESSION array what happens to

let's assume php5. all objects are reference like, they behave from a user POV
as objects would in php4 if you passed them by reference explicitly.

that said they're not really references - there is a Sara Golemon article which
explains it ... not that I truely understand the inner machinations of the 
engine.

Thanks. I believe the article is : 


http://blog.libssh2.org/index.php?/archives/51-Youre-being-lied-to..html


yup, that's the one ... good stuff, Sara knows her  :-)

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



Re: [PHP] problem with imagefontwidth function, It looks to be unavailable...

2008-02-07 Thread Jochem Maas

Legolas wood schreef:

Hi
Thank you for reading my post
I am trying to run a php based application using php5 and apache.
but I receive an error like:


*Fatal error*:  Call to undefined function imagefontwidth() in 
*/var/www/v603/includes/functions.php* on line *28*


that would tend to indicate that it's unavailable yes.
you don't have the [php] GD extension loaded (and probably not even installed)

php.net/gd

mostly likely you'll have to ask your sys admin to install/activate this
extension ... and if you have cheaphosting then likely the answer will be
no we don't do that - in which case find other hosting?




when line 28 and its surrounding lines are:

## create an image not a text for the pin

$font  = 6;

$width = imagefontwidth($font) * strlen($generated_pin);

$height = ImageFontHeight($font);

 


$im = @imagecreate ($width,$height);

$background_color = imagecolorallocate ($im, 219, 239, 249); //cell 
background

$text_color = imagecolorallocate ($im, 0, 0,0);//text color

imagestring ($im, $font, 0, 0,  $generated_pin, $text_color);

touch($image_url . 'uplimg/site_pin_' . $full_pin . '.jpg');

imagejpeg($im, $image_url . 'uplimg/site_pin_' . $full_pin . '.jpg');

 


$image_output = 'img src=' . $image_url . 'uplimg/site_pin_' . $full_pin . 
'.jpg';

 


imagedestroy($im);

 


return $image_output;



Can you tell me what is wrong with this code and how I can resolve the
problem.

Thanks



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



Re: [PHP] PHP setup

2008-02-07 Thread Jochem Maas

Louie Henry schreef:

Good Day All

 


I am running windows xp pro and using built in IIS as my web-server.  And I
installed PHP 5.2.5. I also installed MySQL 5.0.37.  Now PHP is working, how
ever I having problems with the configuration with MySQL.  


I used phpinfo(), and I notice this

doc_root  no value   no value

extension_dir  C:\php5   C:\php5


the output of phpinfo() also tells you where pp is loading in php.ini from (or
trying to load it in).

my guess is the php.ini your editing is not located where php is looking for it.



 


I did edit my php.ini file:

include_path =C:\PHP;C:\PHP\ext

doc_root =C:\Inetpub\wwwroot

extension_dir =C:\PHP\ext

 


And windows systems paths I have C:\PHP; and it shows up in the path
command.  

 


I do not understand why it’s not using the php.ini file or what I am doing
wrong.  

 



No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.19.21/1263 - Release Date: 06/02/2008

8:14 PM
 



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



Re: [PHP] date() and wrong timezone (or time)

2008-02-07 Thread Jochem Maas

Martin Marques schreef:

Nathan Nobbe escribió:
On Feb 6, 2008 6:13 AM, Martin Marques [EMAIL PROTECTED] 
wrote:



I got an update from tzdata on a Debian server due to a daylight saving
change here in Argentina.


I doubt that debian stable is pushing newer versions of TZ db, than that found 
in
php ... you don't mention your php version btw.



The problem is that, even when the system sees the correct time, php
keeps giving me the *old* hour.

$ date
mié feb  6 09:03:57 ARST 2008
$ echo ?php echo date('H:i') . \\n\; ?|php5
08:04

What can my problem be?


what timezone does php think it's in? - output all stuff from date,
not just hour:minutes.




see what you have as the value for the date.timezone ini setting.


I've already checked that, and it's not set.


it should be set to something, so fix that.



Anyway, I found out that PHP uses an internal tz database (very bad 
IMHO) and it might be out of date.


there is a good reason for this being internal - and if you search the
internals mailing list archive you'll find plenty of discussion about it.

whether it's bad depends on whether you look at it from a phper's POV or a
sysadmin/package maintainers POV - there is no way to make everyone happy in 
this
situation AFAICT.





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



Re: [PHP] date() and wrong timezone (or time)

2008-02-07 Thread Jochem Maas

Daniel Brown schreef:

On Feb 7, 2008 8:34 AM, Jochem Maas [EMAIL PROTECTED] wrote:

Martin Marques schreef:

see what you have as the value for the date.timezone ini setting.

I've already checked that, and it's not set.

it should be set to something, so fix that.


All other points being valid, Jochem, I disagree with this.  I've
never forced a setting on any of my PHP installations, and so far
(knock on wood) I've never had a problem.  I think PHP does a fine job
of reading the server time and zone.


most likely, personally I set it in code as required. I was reiterating what
the author of the new datetime stuff has repeated on a number of occasions,
namely that your application or php.ini file should be settingthe value to
something suitable explicitly.

how valid this actually is obviously open to question, besides date/time
issues will probably be one of those horrid things that will keep on biting
people in the *** no? calendars, timezones and everything related is just
too finickity :)





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



Re: [PHP] Profiling with register_tick_function / declare

2008-02-07 Thread Jochem Maas

McNaught, Scott schreef:

Hi there,

 


Is it possible to make the declare(ticks=1) statement apply to *all*
functions executed in a php script, regardless of scope?



is the declare() pragma not a file scope wotsit? i.e. you'd have to
do declare(ticks=1); at the top of each file.

...



. Get profile results for novices without having to mess around
installing php binaries such as APD / zend debugger etc


I suppose that includes xdebug?



. Profile on demand on production servers without having to install
a resource intensive debugging module


does profiling need to be done in production at all? slow code is slow however 
you
look at it no? so profiling something in a dev environment should show just as
much info as anywhere else?



 


Any help greatly appreciated.

 


Thanks,

 


Scott McNaught

 





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



Re: [PHP] string vs number

2008-02-06 Thread Jochem Maas

Ford, Mike schreef:

On 05 February 2008 21:37, Jochem Maas advised:


the same is not exactly true for floats - although you can
use them as array keys you'll
notice in the output of code below that they are stripped of
their decimal part (essentially
a floor() seems to be performed on the float value. I have no
idea whether this is intentional,
and whether you can therefore rely on this behaviour:


Yes, and Yes!

From http://php.net/language.types.array


ah yes, I should have looked it up, that said I find it rather odd that
is works let alone that it's intentional.

though thinking about it you could probably use it for some float val
distribution counting or something. I dunno, seems like it offers a handy
shortcut - although what that shortcut is escapes me just now :-)




A key may be either an integer or a string. If a key is the
standard representation of an integer, it will be interpreted
as such (i.e. 8 will be interpreted as 8, while 08 will
be interpreted as 08). Floats in key are truncated to
integer.


 --
Mike Ford,  Electronic Information Services Adviser,
JG125, The Headingley Library,
James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730  Fax:  +44 113 812 3211


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm




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



Re: [PHP] PHP CLI Problem

2008-02-06 Thread Jochem Maas

Robbert van Andel schreef:

I am having trouble with a PHP CLI script I wrote to help manage my website.
The site is on a shared hosting server where the PHP installation is set up
as a CGI.  The script creates some backups of my databases and sends them to
Amazon's S3 service.  


First off, the script runs great from the command line when I type php5
backup.php but when I type ./backup.php I get an error: bash:
./backup.php: No such file or directory.  


is the script marked as executable?


I thought maybe this is a problem
with the top declaration in the script #!/usr/local/bin/php5. The problem
is that it appears the server has several php5s I can reference

/usr/local/apache/share/cgi-bin/php5
/usr/local/bin/php5


to determine which php5 you are using type:

$ which php5

this gives you the full path, which you will need to use in the relevant
cron line (and/or the shebang line at the top of the script) - cron requires 
fullpaths.



But it doesn't matter which one I put at the top of the script, I get the
same error.

Okay, so I can live with having to type php5 backup.php.  However, when I
try to make a cron job from the script, the script never runs.  The crontab
entry looks like this
1 0 * * 2 php5
/kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/
backup.php  backup.log

I know the backup never runs because I redirect the output to a file and
have an email sent to me upon conclusion of the script.  The log file
doesn't show anything nor do I ever receive an email.  My web host will not
provide any support for scripting, so I'm hoping someone here can help.

Questions:
* How do I determine what to put at the top of the script so that I can just
call backup.php?
* What, if anything, do I need to do to make the script work from cron?

I've seen some comments on the web regarding PHP CLI when PHP is a CGI, but
none of them seem to apply to me.  


Thank you in advance for your help.

Robbert



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



Re: [PHP] string vs number

2008-02-05 Thread Jochem Maas

Casey schreef:

On Feb 5, 2008, at 10:43 AM, Eric Butera [EMAIL PROTECTED] wrote:


On Feb 5, 2008 1:40 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:

On Feb 5, 2008 1:36 PM, Hiep Nguyen [EMAIL PROTECTED] wrote:


hi all,

i have this php statement:

? if($rowB[$rowA[0]]=='Y') {echo checked;} ?


debugging, i got $rowA[0] = 54, but i want $rowB[$rowA[0]] = 
$rowB['54'].


is this possible?  how do i force $rowA[0] to be a string 
('54')?http://www.php.net/unsub.php



php should handle the conversion internally for you.
if you want to type cast a value to a string, simply do

(string)$varname

-nathan



I was thinking about saying that, but php is loosely typed, so 54 ==
'54'.  I'm thinking something else is wrong here.

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



I believe this is the difference with arrays:

$a = array(2 = foo);
Array(0 = null, 1 = null, 2 = foo)

$a = array(2 = foo);
Array(2 = foo)


not true:


alice:~ jochem$ php -r '
$a = array(2 = foo); $b = array(2 = foo); var_dump($a, $b);'
array(1) {
  [2]=
  string(3) foo
}
array(1) {
  [2]=
  string(3) foo
}

php treats anything that is the string equivelant of an integer as an integer 
when
it comes to array keys - which comes down to the fact that you cannot therefore 
use
a string version of an integer as an associative key.

so $a[2] and $a[2] are always the same element.

the same is not exactly true for floats - although you can use them as array 
keys you'll
notice in the output of code below that they are stripped of their decimal part 
(essentially
a floor() seems to be performed on the float value. I have no idea whether this 
is intentional,
and whether you can therefore rely on this behaviour:

alice:~ jochem$ php -r '
$a = array(2.5 = foo); $b = array(2.5 = foo); var_dump($a, $b);'
array(1) {
  [2]=
  string(3) foo
}
array(1) {
  [2.5]=
  string(3) foo
}
alice:~ jochem$ php -r '
$a = array(2.6 = foo); $b = array(2.6 = foo); var_dump($a, $b);'
array(1) {
  [2]=
  string(3) foo
}
array(1) {
  [2.6]=
  string(3) foo
}






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



Re: [PHP] php competion

2008-02-04 Thread Jochem Maas

Richard Lynch schreef:


On Sun, February 3, 2008 11:51 am, Robert Cummings wrote:

On Sun, 2008-02-03 at 18:15 +0200, Paul Scott wrote:

On Sun, 2008-02-03 at 20:10 +1100, doc wrote:

come on people try you skills at

http://www.rhwebhosting.com/comp/index.php

Reworded as:

Redesign our complete web presence and give us a couple of apps that
we can flog to our clients,
and we *may* give you a consolation prize.

So not worth the time and effort. Any person capable of doing the code
conversion (to AT LEAST C, Python, and Perl nonetheless) is smart
enough
to know the potential payoff is worse than flipping burger and
McGeneric's.


Actually, the specification for the real estate listing thingie looked
pretty trivial...


on the surface of things I would agree - which is why there are plenty of 
trivial
real-estate listing apps out there. but I doubt that's what they are looking 
for.

when you factor in multi-user, multi-currency, multi-language aspects, the 
ability
to switch between metric and imperial measurements, the issues related to
normalization of real-estate data with regard to offering usable search 
mechanisms
(everyone has different 'styles' of data), backend integration, automated export
to third party systems and map integration things become a little more involved 
...
oh and flexibility because every real-estate agent is looking for something 
*slightly*
different.

given those points I would hazard a guess and say the development costs 
outweigh the
potential prize money at least 4 to 1. granted a RE tool is not technically very
challenging but I wouldn't under estimate the ammount of time the details of 
such an
app would take to implement.

anyway you put it these rhwebhosting guys are nuts if they think anyone 
(meaning anyone
with the skills to actually produce the kind of quality/functionality their 
looking for)
would be interested in this 'competition'







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



Re: [PHP] In Your Arms

2008-02-04 Thread Jochem Maas

Eric Butera schreef:

On Feb 4, 2008 5:13 PM, Jim Lucas [EMAIL PROTECTED] wrote:

[EMAIL PROTECTED] wrote:

Destiny http://86.31.249.90/


I love FF + NoScript  :)

--
Jim Lucas

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

Twelfth Night, Act II, Scene V
 by William Shakespeare


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




I used curl. :)


I don't click the link :-)





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



Re: [PHP] how dod you get to do multiple mysql queries concurrently?

2008-02-03 Thread Jochem Maas

Paul Scott schreef:

Did anyone actually get this mail?


it came through :-)



More concrete example? What would you like to see?


the column spec. what kind of geomtery column is it? and
are you using it as a primary key? or some else ... if so what kind
of stuff are you storing in there? also in what way are you
using it that gives you such a speed boost with queries?

I read the mysql docs, I understand the principles but I'm having
a hard time figuring out how to apply in practice in terms of
making use of the performance gains you mentione ... specifically
in a web environment where heavy queries are often along the lines
of paginated data combined with user defined filters (e.g. a product
list sorted by price, etc and filter on type/category/keyword/etc)

sorry if I'm sounding like a idiot :-)



I suspect that some of my mail is getting dropped :(

--Paul

On Fri, 2008-02-01 at 06:33 +0200, Paul Scott wrote:

On Fri, 2008-02-01 at 03:40 +0100, Jochem Maas wrote:


I for one would really like to see a concrete example of this kind of
use of geometry columns and spacial indexes as an alternative to the stand
integer based primary keys.


On one of my local postGIS tables:

CREATE INDEX k1
  ON kanagawa
  USING gist
  (the_geom);


A gist index is a GEOS based spatial index. You will need GEOS to create
one.

When loading spatial data, your geometry column looks like so:

01050001000102000C0011ECE564CF7561404A8999CCDABC4140E5C0981ACE75614012901CD641BD4140603C8386BE756140E525611B40BD41405BF216D3BD756140151DC9E53FBD414054DC1A4DBD756140760B997A3FBD414012219BD1BC756140D20823E33EBD41407AB2884EBC7561400F2110243EBD41404571B4D0BB756140CC0C6A213DBD4140F707192ABB7561405DF2A1803CBD4140F0F11CA4BA756140C3D1B7413CBD4140E89CB2ADB97561406F046D233CBD414017D4B7CCA97561406D47AD7F39BD4140

Which is WKB (Well Known Binary) data or WKT (Well Known Text) data. The
gist index simply indexes this as opposed to the regular gid (which you
still use btree indexes on anyways)

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 


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



All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 


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



Re: [PHP] PEAR website and MSIE 6

2008-02-02 Thread Jochem Maas

Shawn McKenzie schreef:

Glad I read threads that I don't care about or I wouldn't have found out
about Firebug!  I just installed it, very cool!


it can definitely make your day less painful :-)



Also, considering the price of oil/gas, I'm sorry that the 'war for oil'
didn't work out the way we had hoped.  You would have thought we would
have learned in WWII when we started the 'war for strudel'.  Have you
seen the price of strudel?  It went up during WWII and has continued to
rise.


I'm not much a strudel fan, unfortunately I'm just as hooked on oil as the next
man ... the point I was making is that alot of the 'problems' encountered in
'cyberspace' aqre pretty lame compared to the crap going on in meatspace.

the iraqi that just watched his wife and children mowed down by 'friendly fire'
probably doesn't care too much that pear.php.net crashes IE6.


I would call you a dumb ass, but you seem very knowledgeable in PHP and
I may need some help in the future :-)


nuff people would agree with you on the first part, some might credit me
with the second part and here's hoping I can offer some help of the third
part happens to pass.

credit given for a smarty comment ... appreciated :-)

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



Re: [PHP] array iteration vs. ArrayIterator

2008-02-01 Thread Jochem Maas

Nathan Nobbe schreef:

all,

as ive been researching SPL lately ive read several times that spl will
store only the current element of the underlying collection in memory
during iteration.  articles that mention this will say that using these
iterators should afford savings when traversing large collections.  well
having found nothing empirical i decided to run some tests myself.
and for the hell of it, i also decided to throw the array-by-reference
construct in there (thats the name im giving to the syntax which lets
you alter the array youre iterating over from within the array).  mainly
because ive heard people say it will save memory.  however, based
upon some things ive read, ive been skeptical of that info.
so here is a quick little report i whipped up, which has the script i used
for the test, and the results in a graphical format so you can get a quick
feel for them.
http://nathan.moxune.com/arrayVsArrayIteratorReport.php

at this point i must retract some of the statements i made during the
conversation about ruby yesterday.  it turns out, spl iteration is not
twice as fast as standard array iteration, in fact it quite a bit slower!


that makes sense - your creating objects and wrapping the original data in order
to iterate over it - that can only mean overhead in terms of memory and 
performance.

I stick with arrays and foreach (I agree with the carpal tunnel syndrome 
statement)


also, it takes up more memory, and lastly, whoever said that using the
array-by-reference syntax saves memory is dead wrong ;)

-nathan



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



[PHP] Calling All Opinionated ******** ....

2008-02-01 Thread Jochem Maas

hi people,

I'm in the market for a new framework/toolkit/whatever-you-want-to-call-it.
I've been taking a good hard look at the Zend Framework - if nothing else the 
docs
are very impressive.

I'd like to hear from people who have or are using ZF with regard to their
experiences, dislikes, likes, problems, new found fame and fortune, etc ... but
only if it concerns ZF.

I don't need to hear stuff like 'use XYZ it's great' - finding php 
frameworks/CMS/etc
is easy ... figuring out which are best of breed is another matter, if only 
because
it involves reading zillions of lines of code and documentation. besides I find 
that
you only ever get bitten in the ass by short-comings and bugs when your 80% 
into the
project that needs to be online yesterday and you knee deep in a nightmare 
requirements
change or tackling some PITA performance issue.

so people, roll out your ZF love stories and nightmares - spare no details - 
share the
knowledge. or something :-)

tia,
Jochem

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



Re: [PHP] Calling All Opinionated ******** ....

2008-02-01 Thread Jochem Maas

Greg Donald schreef:

On 2/1/08, Jochem Maas [EMAIL PROTECTED] wrote:

I'm in the market for a new framework/toolkit/whatever-you-want-to-call-it.
I've been taking a good hard look at the Zend Framework - if nothing else the 
docs
are very impressive.

I'd like to hear from people who have or are using ZF with regard to their
experiences, dislikes, likes, problems, new found fame and fortune, etc ... but
only if it concerns ZF.

I don't need to hear stuff like 'use XYZ it's great' - finding php 
frameworks/CMS/etc
is easy ... figuring out which are best of breed is another matter, if only 
because
it involves reading zillions of lines of code and documentation. besides I find 
that
you only ever get bitten in the ass by short-comings and bugs when your 80% 
into the
project that needs to be online yesterday and you knee deep in a nightmare 
requirements
change or tackling some PITA performance issue.

so people, roll out your ZF love stories and nightmares - spare no details - 
share the
knowledge. or something :-)


Hilarious.  I'm in the market for a new framework, but please only
tell me about ZF because I don't want to spend my own time researching
stuff for myself.  


you need some glasses?  I've just spent 4 hours reading
ZF documentation and code ... today - I've played with it in the past
but it was still beta at that time. I'm starting to take another look,
but no ammount of playing with it or reading documentation will tell me
if I'm going to have major regrets about choosing ZF for a large project
when I'm 400 hours into it and stuck with a deadline and an impossible
situation.

funnily enough I'm not capable of researching inside someone else's head
when it comes to *their opinion*, more specifically people who you are familiar
with to soome degree, whereby you able to gauge to a better extent how relevant
the opinion/experience offered is to one's own situation.

Since when is learning something new a crime?  


and where do you go to learn someone else's opinion?


Why
are you even a programmer?


something bothering you? got out of the wrong side of bed today?


ZF works fine if you don't mind all the bloated OO PHP.  Use it or don't.


brilliant advice, you we're on better form yesterday my friend.





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



Re: [PHP] PEAR website and MSIE 6

2008-01-31 Thread Jochem Maas

Richard Heyes schreef:
Anyone have any trouble with this combination? It consistently crashes 
for me.


firefox not an option? or anything else that resembles a proper browser ;-)



http://pear.php.net

Thanks.



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



Re: [PHP] PEAR website and MSIE 6

2008-01-31 Thread Jochem Maas

Eric Butera schreef:

On Jan 31, 2008 7:33 AM, Jochem Maas [EMAIL PROTECTED] wrote:

Richard Heyes schreef:

Anyone have any trouble with this combination? It consistently crashes
for me.

firefox not an option? or anything else that resembles a proper browser ;-)


http://pear.php.net

Thanks.


--

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




IE8 passes Acid2. :)


a, it's not out.
b, all that was said was it does - is there proof? (screenshot doesn't count).
c, they also want to force developers to include extra meta tags to force IE8 
to run in
strict valdation mode ... otherwise it will run using the old parser ... or 
something like
that.
d, it's liable to be more to do with EU lawsuits than actually giving a hoot 
about
stds compliance of any sort.

http://www.regdeveloper.co.uk/2008/01/25/ie8_version_switch/





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



Re: [PHP] PEAR website and MSIE 6

2008-01-31 Thread Jochem Maas

Richard Heyes schreef:

firefox not an option?


Nope.

  or anything else that resembles a proper browser ;-)

Strange, IE has been working fine for me for the last eight years...


that's the kind of thing people say just after they hear they have prostrate 
cancer ;-)

seriously though - why is FF (or any other browser) not an option? your
a web developer, I would imagine you should be running a complete arsenal of
different browsers as part of the job, no?

and then there's the question as to why you don't upgrade to IE7. or maybe
rebuild the windows machine in question (hey it wouldn't be the first time 
something
like this was helped by a clean install right?)






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



Re: [PHP] PEAR website and MSIE 6

2008-01-31 Thread Jochem Maas

Eric Butera schreef:

On Jan 31, 2008 9:27 AM, Jochem Maas [EMAIL PROTECTED] wrote:

Eric Butera schreef:


On Jan 31, 2008 7:33 AM, Jochem Maas [EMAIL PROTECTED] wrote:

Richard Heyes schreef:

Anyone have any trouble with this combination? It consistently crashes
for me.

firefox not an option? or anything else that resembles a proper browser ;-)


http://pear.php.net

Thanks.


--

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



IE8 passes Acid2. :)

a, it's not out.
b, all that was said was it does - is there proof? (screenshot doesn't count).
c, they also want to force developers to include extra meta tags to force IE8 
to run in
strict valdation mode ... otherwise it will run using the old parser ... or 
something like
that.
d, it's liable to be more to do with EU lawsuits than actually giving a hoot 
about
stds compliance of any sort.

http://www.regdeveloper.co.uk/2008/01/25/ie8_version_switch/




I'm up to date on the situation, thanks! :)

I just had to throw that in there because you said Firefox like it is
the best browser. 


no that's your interpretation. I merely implied firefox was better than IE.
and if your a webdeveloper then atm it is the best browser for one simple 
reason - firebug.


I use Firefox with NoScript when I'm browsing the


 bully for you. given that this is the world of web2.0 I'd imagine your
browsing is rather limited. it's also masochistic given that you apparently
choose to use an inferior product (as per your own opinion)


web, but it is by no means the best browser.  Safari  Opera have
better renderers and do it faster. 


ah so my supposed opinion needs to take a back seat to your better opinion,
no renderer is perfect. and they're all slightly different. let's not forget
that nobody outside of IT actually uses Opera and Safari is only used by 
MacHeads
(which account for about 0.1% of the population) - recommending firefox is 
mostly about
educating Joe Average to the possiblities of an alternative that is used by 
more than
5 people already.


I'm not talking about the
Mozilla engine though because Camino fairly decent.  It's just all
that chrome bloat really makes me sick.


then go to bed.





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



Re: [PHP] PEAR website and MSIE 6

2008-01-31 Thread Jochem Maas

Eric Butera schreef:

On Jan 31, 2008 11:14 AM, Jochem Maas [EMAIL PROTECTED] wrote:

Eric Butera schreef:

On Jan 31, 2008 9:27 AM, Jochem Maas [EMAIL PROTECTED] wrote:

Eric Butera schreef:


On Jan 31, 2008 7:33 AM, Jochem Maas [EMAIL PROTECTED] wrote:

Richard Heyes schreef:

Anyone have any trouble with this combination? It consistently crashes
for me.

firefox not an option? or anything else that resembles a proper browser ;-)


http://pear.php.net

Thanks.


--

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



IE8 passes Acid2. :)

a, it's not out.
b, all that was said was it does - is there proof? (screenshot doesn't count).
c, they also want to force developers to include extra meta tags to force IE8 
to run in
strict valdation mode ... otherwise it will run using the old parser ... or 
something like
that.
d, it's liable to be more to do with EU lawsuits than actually giving a hoot 
about
stds compliance of any sort.

http://www.regdeveloper.co.uk/2008/01/25/ie8_version_switch/



I'm up to date on the situation, thanks! :)

I just had to throw that in there because you said Firefox like it is
the best browser.

no that's your interpretation. I merely implied firefox was better than IE.
and if your a webdeveloper then atm it is the best browser for one simple 
reason - firebug.


I agree that Firebug is an amazing ext in Firefox.  I use it regularly
along with the live headers ext in my work to track XHTTP requests.
What are your favorite aspects of Firebug?  


in line editing of just about everything, introspection of everything. er 
everything.

Safari has some nice HTML

and Javascript debugging with Drosera  the Web Inspector.


I use Firefox with NoScript when I'm browsing the

  bully for you. given that this is the world of web2.0 I'd imagine your
browsing is rather limited. it's also masochistic given that you apparently
choose to use an inferior product (as per your own opinion)


I use different browsers for tasks.  Gmail/Google Reader share Camino.
 Safari is the browser I use for browsing/work.  Firefox is the
browser I use for viewing sites I don't trust with the
NoScript/Flashblock extensions.  The fact that XSS and CSRF can steal
your identity/perform actions is serious business to me.  I do what I
can to protect myself.

web, but it is by no means the best browser.  Safari  Opera have
better renderers and do it faster.

ah so my supposed opinion needs to take a back seat to your better opinion,
no renderer is perfect. and they're all slightly different. let's not forget
that nobody outside of IT actually uses Opera and Safari is only used by 
MacHeads
(which account for about 0.1% of the population) - recommending firefox is 
mostly about
educating Joe Average to the possiblities of an alternative that is used by 
more than
5 people already.


I wasn't trying to say my opinion was better.  I was just stating that
the rendering engine in Opera and Safari pass the acid2 test[1].
Firefox does not.


you didn't state anything of the sort until just then.
and you do realise that Acid2 is not actually a standard AND that there
are plenty of differences of opinion regarding the minutae of 'proper
implementation' of some of the things Acid2 tests.




I'm not talking about the
Mozilla engine though because Camino fairly decent.  It's just all
that chrome bloat really makes me sick.

then go to bed.




[1] http://en.wikipedia.org/wiki/Acid2#Compliant_applications


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



Re: [PHP] PEAR website and MSIE 6

2008-01-31 Thread Jochem Maas

Robert Cummings schreef:

On Thu, 2008-01-31 at 17:14 +0100, Jochem Maas wrote:

let's not forget that nobody outside of IT actually uses Opera


Please back up that st-ass-tistic please. Methinks you reached around
and pulled it out of your lightless nether regions.


given that you can prove anything with statistics, I'd say that's where
all stats come from - well not all from my ass but always someone's ;-)

let me guess you use Opera ... and you work in IT right? :-P



Cheers,
Rob.


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



Re: [PHP] PEAR website and MSIE 6

2008-01-31 Thread Jochem Maas

Eric Butera schreef:

On Jan 31, 2008 12:02 PM, Jochem Maas [EMAIL PROTECTED] wrote:

Robert Cummings schreef:

On Thu, 2008-01-31 at 17:14 +0100, Jochem Maas wrote:

let's not forget that nobody outside of IT actually uses Opera

Please back up that st-ass-tistic please. Methinks you reached around
and pulled it out of your lightless nether regions.

given that you can prove anything with statistics, I'd say that's where
all stats come from - well not all from my ass but always someone's ;-)

let me guess you use Opera ... and you work in IT right? :-P


Cheers,
Rob.




My wife uses Opera and she doesn't know much about computers.  I
installed IE7, FF, Opera,  Safari for Windows and she picked Opera on
her own.  I can't really get into it though.


I guess the shitty interface is appealing to people with more taste than us :-)
Steve Job's would be annoyed though - which is funny in and of itself :-P





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



Re: [PHP] PEAR website and MSIE 6

2008-01-31 Thread Jochem Maas

Richard Heyes schreef:

Jochem Maas wrote:

Richard Heyes schreef:

firefox not an option?


Nope.

  or anything else that resembles a proper browser ;-)

Strange, IE has been working fine for me for the last eight years...


that's the kind of thing people say just after they hear they have 
prostrate cancer ;-)


Lol.


seriously though - why is FF (or any other browser) not an option?


I suppose it is, but I like Internet Explorer. Have done for ages.


lol - some people like MacDonalds - no account for taste :-)
my guess is if you use another browser for a month, you'll get so used
to it that going back to IE will feel just as painful as opening something
other than IE does now ... at least that's how it always is for me.

I don't like Safari ... but now I use a MacBook I keep opening it up and
really I am starting to like it more and more .. although I don't really,
sort of, not, possibly :-)



  your
a web developer, I would imagine you should be running a complete 
arsenal of

different browsers as part of the job, no?


Yes. MSIE, Firefox, Opera etc.

and then there's the question as to why you don't upgrade to IE7. or 
maybe
rebuild the windows machine in question (hey it wouldn't be the first 
time something

like this was helped by a clean install right?)


I don't like the IE7 interface, in particular the font smoothing thing. 


got to admit the IE7 interface is indeed a step backwards - that is quite an
achievement :-P


And besides, I can't be arsed... :-)



spoken like a true webhead. may I refer you to that last comment with regard to
seeking an answer to your original question :-P

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



Re: [PHP] PEAR website and MSIE 6

2008-01-31 Thread Jochem Maas

Nathan Nobbe schreef:

i like opera for 4 reasons,
1. it renders fast
2. when i have 50 tabs open, its still responsive
3. it supports ctrl+z, wicked feature :


undo? undo what?


4. when you close and reopen, all the tabs from before are still there; key

however, firefox is the champion for web development.
not only is firebug awesome, but i still use the older web developer plugin.
its good for showing form details, outlining things, and clearing the cache,
all very quick to get to and execute.

for a while i tried the multiple browser thing.  but managing bookmarks in
more than one browser is a pain.  also, have you ever looked at memory
consumption on ur pc w/ 2 browsers running??  get another gig for that :)


I keep bookmarks in my head and in a search engine. managing them in even one 
browser
is too much hassle :-) I jsut keep tabs open and read whatever when I'm 
ready/able - I
don't ever have to shut down the browser or the machine ... and 50 open tabs is 
no problem
... did I mention I use a Mac ;-)



so, despite some of the klunkieness of ff, that is what i use for browsing
and development.

eric,
thanks for the tips on the safari plugins, Drosera  the Web Inspector, ill
definitely install those for my safari debugging :)

-nathan


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



Re: [PHP] PEAR website and MSIE 6

2008-01-31 Thread Jochem Maas

Mr Webber schreef:

PHP is a server-side page generator.  It has NOTHING to do with the browser.
The PHP programmer determines the content of the resulting HTML and the
browser reacts to THAT.  Browsers never see a line of PHP script!



yes I think Richard knows that. he was asking whether anybody experienced
problems view the PEAR site (i.e. the resulting HTML) with IE6**


** I'd hazard a guess that people have problems viewing any site with IE6
but that's a different topic ;-)



-Original Message-
From: Richard Heyes [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 31, 2008 6:42 AM

To: PHP General List
Subject: [PHP] PEAR website and MSIE 6

Anyone have any trouble with this combination? It consistently crashes 
for me.


http://pear.php.net

Thanks.



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



Re: [PHP] [Slightly OT] Apple MacBook MAMP and Logic

2008-01-31 Thread Jochem Maas

Tom Chubb schreef:

I am looking to buy a Mac in a couple of weeks primarily for writing music
using Apple Logic Studio 8 which will run absolutely fine on a MacBook.
However, I am considering installing something like MAMP and using that as
my development server too at which point I'm wondering whether I should
invest in a MacBook Pro or whether I can get away with the lower spec
MacBook.
So I guess what I'm asking is, does having Apache, MySQL  PHP installed on
a Mac use much system resources?


the biggest problem, with Leopard at least, is getting a build of php5 with all
the bells and whistles on it that you need. mostly likely the nice chap and 
entrophy.ch
has rolled a DMG package with all the trimming by now.

I have no idea how much faster an MBP is compared to an MB but I can tell you 
it goes
like a bat out of hell - seriously the faster piece of kit I've ever used by far
(it's running WinXP in a Parallels VM as fast as my previous laptop did 
natively ... and
that was a CoreDuo2 2.0 with 2Gigs ... granted the MBP has a few mroe cpu 
cycles and
double the RAM but still!)

mostly though you'll probably kick yourself for settling for the less sexy 
option. ;-)
that said I can't imagine that an MB won't cut it.





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



Re: [PHP] PEAR website and MSIE 6

2008-01-31 Thread Jochem Maas

Robert Cummings schreef:

On Thu, 2008-01-31 at 18:42 +0100, Jochem Maas wrote:

Nathan Nobbe schreef:

i like opera for 4 reasons,
1. it renders fast
2. when i have 50 tabs open, its still responsive
3. it supports ctrl+z, wicked feature :

undo? undo what?


What you just typed into a form, or erased and decide you actually want,
etc.


FF does that - at least it does for me, has done for as long as I can remember.



Cheers,
Rob.


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



Re: [PHP] PEAR website and MSIE 6

2008-01-31 Thread Jochem Maas

Robert Cummings schreef:

On Thu, 2008-01-31 at 18:02 +0100, Jochem Maas wrote:


...


Would you believe me if I said I wasn't in IT? ;)  My wife isn't in IT,
but she uses Opera regularly, she likes it's speed and the way it zooms.
My 4 year old son loves Opera, but he doesn't know anything else yet :)
He likes it when I jump on google images and do searches for things like
dinosaurs, solar system, trucks, etc. Then he browses through the
results. of course, he also only knows Linux so far. He can happily
navigate folders and menus. The icons help determine his interest level
since he can't read very well just yet.


great story. :-) my 4yo mostly likes trains and stuff - but he kind of
expects the images to browse by themselves (which they do when you slideshow 
them ;-).

I try to steer him away from tech crap, trying to get him to grok a piano
keyboard before a PC one. and no TV either.




Cheers,
Rob.


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



Re: [PHP] Strtotime returns 02/09/2008 for next Saturday....

2008-01-31 Thread Jochem Maas

Mike Morton schreef:

Good point ;)

Except that generally, when am told next Saturday - I take that to mean
the next Saturday - just one more ambiguity in the english language that
makes it so hard to learn I suppose!

The odd thing about this whole situation it that it seems to have cropped up
just after we upgraded to 4.3.9 - prior to that, next Saturday worked
just peachy.  I wish I knew which version we were running before that - but
that record was not kept.

I guess we are stuck with this, what maybe is a problem with this version,
until the Redhat RPM gets higher than 4.3.9 - since that is what our server
manager uses for updates

I could always adjust it to be:

date(m/d/Y,strtotime(+ .(6-date(w)). days));

That should always return the next Saturday of the week, and if I am correct
in my thinking, then even on the Saturday, 6-6 = 0 - which would return that
day... Which does, at least for my application of it, work.


so your actually saying 'find the closest saturday, in the future, from today'.
because if it was saturday, and you said to me see you next saterday I'd 
expect
to see you in 7 days time.





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



Re: [PHP] PEAR website and MSIE 6

2008-01-31 Thread Jochem Maas

Daevid Vincent schreef:
 


-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 31, 2008 8:19 AM

To: [EMAIL PROTECTED]
Cc: PHP General List
Subject: Re: [PHP] PEAR website and MSIE 6

Richard Heyes schreef:

firefox not an option?

Nope.

  or anything else that resembles a proper browser ;-)

Strange, IE has been working fine for me for the last eight years...


Yes. http://pear.php.net crashes my IE6 too. This is a problem with the
site, not the browser. 

seriously though - why is FF (or any other browser) not an 
option? your
a web developer, I would imagine you should be running a 
complete arsenal of

different browsers as part of the job, no?
and then there's the question as to why you don't upgrade to 
IE7.


Please stop with the browser wars.


it's not browser wars - it's pragmatism - thinking aloud about how to
get round the issue - I'm assuming Richard does have access to the PEAR site's
source files or the means to upload them to the PEAR webserver.

 They're boring and tired and serve no

purpose. IE6 is fast and launches in 1 second. FF takes many seconds. IE7 is
also a bloated pig and I will be very sad in 15 days when M$ FORCES everyone
to it. IE also has very nice DirectX rendering filters for gradients.
 
or maybe rebuild the windows machine in question (hey it wouldn't be 
the first time something

like this was helped by a clean install right?)


It is NOT the OS. It is the PEAR site itself that is to blame. There is
clearly some code or tag or something that is causing this failure. 


let's see now - a webserver outputs some content, it may be invalid. a browser
crashes upon trying to render the content. hmm, sounds to me like the problem is
in the browser, decent software should crash because of shitty input.

granted if the PEAR just didn't render properly or caused 'invalid 
XML/XHTML/whatever'
message in the browser then yes it would be the site's problem. but until the 
browser
is capable of saying 'hey this content is junk, I can't use it [because of 
XYZ]' then
really the first issue is with that browser.

it's same at the server end - if your browser (or you, maliciously) posts 
freaking/invalid
byte sequences at some script I've got on the server then would you consider it 
correct
that the server crashed? or would you expect some kind of 'your input sucks' 
error
message to appear?


It
didn't used to be there either. I've gone to the PEAR site many times in the
past. The site isn't even that compex, so I'm curious why the webmaster
couldn't just fix this problem and make everyone happy? 


we work around bugs and problems all day in the job we do - how is cranking up a
different browser because a site happens not to work with a particular site any 
different?

if we're really about making everyone happy - how about we tackle something
serious like the whole 'war for oil' business? exactly how fragile is a human 
mind if
a browser crashing on a particular site is deciding factor in being capable of
experiencing happiness? (not that I'm suggesting this about Richard - Im sure he
was just a little miffed and ping'ed the question out of curiousity more than 
anything)


Or is the PHP
community so snobbish that they're turning into the Linux community?
I find it so ironic that all the fringe browser people freak out if their
browser isn't supported by some site and demand retribution, yet when the
tables are turned how quick they are to tell 80% of the world to use a 20%
browser...


let's make it sound like they all *chose* IE shall we - a large majority
of that 80% actually think IE *is* the internet, they certainly didn't choose it
because they thought it was the best tool for the job (which it may or may not
be depending or circumstance and/or perspective) - indoctrination and ignorance
do not make good metrics for determining the superiority of a given product ...
keyboard layout being another fine example ... de facto not necessarily equal 
da bom



*sigh*


indeed

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



Re: [PHP] how dod you get to do multiple mysql queries concurrently?

2008-01-31 Thread Jochem Maas

Per Jessen schreef:

Richard Lynch wrote:


OK, what is a 'geometry column' and what is a 'spatial index' ?

Imagine a single column combining both longitude and latitude.

Now imagine an index that knows about long/lat, and keeps
geographically close objects sorted in the index for you.

Including knowing about the 180 - -180 degree wrap-around.
(Or 360 === 0 wrap-around in the other geo-system.)

So when you ask for theme parks near Zurich your DB can answer in
milliseconds instead of minutes.


Thanks Richard - I thought Nathan was talking about an abstract concept,
not something real. 

So, back the Nathans suggestion: 


Back on the mysql side of things, try using geometry columns rather
than numerical primary keys, with spatial indexes.. it's a MASSIVE
performance upgrade (I've cut 5 second queries down to 0.005 by
using geo columns)


Is this worth a try?  Have others tried this?


I for one would really like to see a concrete example of this kind of
use of geometry columns and spacial indexes as an alternative to the stand
integer based primary keys.




/Per Jessen, Zürich



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



Re: [PHP] call to a member function select() on a non object.

2008-01-30 Thread Jochem Maas

you already had the answer to this problem. do try to read the error message 
properly.
a 'non object' is quite clear - if in doubt about what something is or something
should be use var_dump() or print_r() to output the variable in question (e.g. 
$DB, which
you would have seen was NULL).

now for some tips ...

nihilism machine schreef:
I amn trying to use my db class in my auth class, but i get the error: 
call to a member function select() on a non object


?php

class db {

//Members
private $db_user = mydbuser;
private $db_pass = mypassword;
private $db_name = mydb;
private $db_server = myhost.com;


don't store these in the class - it makes the class usable
only for 1 explicit project/DB, and classes are supposed to
be reusable.

instead pass in these connection parameters to the constructor
(or something similar)


private $link;
private $result_id;

//Methods
public function __construct() {
$this-connect();
}

// Connect to MySQL Server
private function connect() {
$this-link = 
mysql_connect($this-db_server,$this-db_user,$this-db_pass) or 
die(ERROR - Cannot Connect to DataBase);
mysql_select_db($this-db_name,$this-link) or die(ERROR: 
Cannot Select Database ( . $this-db_name .  ));   


the 'or die(bla bla);' type of error handling is rubbish, you can
use it for simple/throw-away scripts but when your writing a class
you should make the error handling much more flexible and leave it
up to the code that uses the class to decide how to handle the
error. with the die() statement the consumer of the class has no choice
about what to do if a connection error occurs.


}

// Disconnect from MySQL Server
private function disconnect() {
mysql_close($this-link);
}

// MySQL Select

public function select($sql) {
$this-result_id = $this-query($sql);
if($this-result_id){
$rows = $this-fetch_rows();
}
return $rows;


your returning $rows even if it was not created, this gives you an
E_NOTICE error when you don't get a result id back.


}

// Insert into MySQL
public function insert($params) {
extract($params);


I wouldn't use extract, also your not doing any input parameter checking here.


$sql = 'INSERT INTO '.$table.' ('.$fields.') VALUES ('.$values.')';


the preceding line has SQL injection potential written all over it.


$this-query($sql);
if($this-result_id){
$affected_rows = $this-affected_rows();
}
return $affected_rows;   
}

// Delete from MySQL

public function delete($params) {
extract($params);
$sql = 'DELETE FROM '.$table.' WHERE '.$where;
if (is_numeric($limit)) {
$sql .= ' LIMIT '.$limit;
}
$this-query($sql);
if($this-result_id){
$affected_rows = $this-affected_rows();
}
return $affected_rows;   
}

// Update MySQL

public function update($params) {
extract($params);
$sql = 'UPDATE '.$table.' SET '.$values.' WHERE '.$where;
if(is_numeric($limit)){
$sql .= ' LIMIT '.$limit;
}
$this-query($sql);
if($this-result_id){
$affected_rows = $this-affected_rows();
}
return $affected_rows;
}

// MySQL Query

private function query($sql) {
$this-result_id = mysql_query($sql);
return $this-fetch_rows();
}   


// MySQL Fetch Rows

private function fetch_rows() {
$rows = array();
if($this-result_id){
while($row = mysql_fetch_object($this-result_id)){
$rows[] = $row;
}   
}
return $rows;   
}

// MySQL Affected Rows

private function affected_rows() {
return mysql_affected_rows($this-link);
}

// MySQL Affected Rows
private function num_rows() {
return mysql_num_rows($this-link);
}

// MySQL Affected Rows

private function select_id() {
return mysql_insert_id($this-link);
}

// Destruct!

public function __destruct() {
$this-disconnect();
}
}

?



?php

require_once(db.class.php);

class auth {

public $DB;
public $UserID;
public $AdminLevel;
public $FirstName;
public $LastName;
public $DateAdded;
public $MobileTelephone;
public $LandLineTelephone;


public members suck.



// Connect to the database
public function __construct() {
$DB = new db();


how many objects will be using a DB connection? will each one be
using a new copy? consider passing in a DB object, that way your
saving having to create one each time.


}

// Attempt to login a user
public function CheckValidUser($Email, $Password) {
$PasswordEncoded = $this-encode($Password);
$rows = $DB-select(SELECT * 

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jochem Maas

Stut schreef:

Nathan Nobbe wrote:

On Jan 29, 2008 7:27 PM, Stut [EMAIL PROTECTED] wrote:

Personally I'd use a static method in this instance.


thats what i recommended.


If you need to create
an instance of the class you can do so in the static method and that 
way it
will get destroyed when the function is done. Otherwise the object 
scope is

far larger than it needs to be, which IMHO is an unnecessary waste of
resources and certainly less aesthetic.


lost you on this part ..
whether you create an instance in client code by calling new or
encapsulate the call
to new in a simple factory method there will still be only one
instance of the class,
and it will still be in scope once the method is finished executing,
because all it does
is return an instance of the class its a member of.
maybe you mean something other than what i posted earlier when you say
static method?


You posted a singleton pattern. 


huh? the OPs getInstance() method returns a new object on each call, hardly
a singleton is it?

That means that from the moment you call
the static method until the end of the script that object exists. That's 
probably fine for web-based scripts that don't run for long, but I live 
in a world where classes often get used in unexpected ways so I tend to 
write code that's efficient without relying on the environment it's 
running in to clean it up.


are you saying that the OPs getInstance() method causes each new instance
to hang around inside memory because php doesn't know that it's no longer 
referenced,
even when it's used like so:

Test::getInstance()-doSomething();

and that your alternative does allow php to clean up the memory?



This was your code...

?php
class Test {
public static function getInstance() {
return new Test();
}

public function doSomething() {
echo __METHOD__ . PHP_EOL;
}
}
Test::getInstance()-doSomething();
?

This would be my implementation...

?php
class Test {
public static function doSomething() {
$o = new Test();
$o-_doSomething();
}

protected function _doSomething() {
// I'm assuming this method is fairly complex, and involves
// more than just this method, otherwise there is no point
// in creating an instance of the class, just use a static
// method.
}
}
Test::doSomething();
?

Of course this is just based on what the OP said they wanted to do. If 
there is no reason to create an instance of the object then don't do it. 
It's fairly likely that I'd actually just use a static method here, but 
it depends on what it's actually doing.


But as I said earlier, each to their own.

-Stut



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



Re: [PHP] php embeded in html after first submit html disappear

2008-01-30 Thread Jochem Maas

Janet N schreef:

Hi there,

I have two forms on the same php page.  Both forms has php embeded inside
html with it's own submit button.

How do I keep the second form from not disappearing when I click submit on
the first form?  My issue is that when I click the submit button from the
first
form (register), the second form (signkey) disappear.  Code below, any
feedback is appreciated:


we the users clicks submit the form is submitted and a new page is returned. 
nothing
you can do about that (unless you go the AJAX route, but my guess is that's a 
little
out of your league given your question).

why not just use a single form that they can fill in, nothing in the logic
seems to require that they are seperate forms.

BTW your not validating or cleaning your request data. what happens when I 
submit
$_POST['domain'] with the following value?

'mydomain.com ; cd / ; rm -rf'

PS - I wouldn't try that $_POST['domain'] value.
PPS - font tags are so 1995




form name=register method=post action=/DKIMKey.php
input type=submit name=register value=Submit Key

?php
if (isset($_POST['register']))
{
   $register = $_POST['register'];
}
if (isset($register))
{
   $filename = '/usr/local/register.sh';
   if(file_exists($filename))
   {
   $command = /usr/local/register.sh ;
   $shell_lic = shell_exec($command);
echo font size=2 color=blue$shell_lic/font;
   }
}
?
/form



form name=signkey action=/DKIMKey.php method=post  label
domain=labelEnter the domain name: /label
input name=domain type=text input type=submit name=makesignkey
value=Submit

?php
if (isset($_POST['makesignkey']))
{
$makesignkey = $_POST['makesignkey'];
}
if (isset($makesignkey))
{
  if(isset($_POST['domain']))
  {
$filename = '/usr/local//keys/generatekeys';
if(file_exists($filename))
{
$domain = $_POST['domain'];
$command = /usr/local/keys/generatekeys  . $domain;

$shell_createDK = shell_exec($command);
print(pfont size=2
color=blue$shell_createDK/font/p);
}
  }
?
/form



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



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jochem Maas

Stut schreef:

Jochem Maas wrote:

Stut schreef:

Nathan Nobbe wrote:

On Jan 29, 2008 7:27 PM, Stut [EMAIL PROTECTED] wrote:

Personally I'd use a static method in this instance.


thats what i recommended.


If you need to create
an instance of the class you can do so in the static method and 
that way it
will get destroyed when the function is done. Otherwise the object 
scope is

far larger than it needs to be, which IMHO is an unnecessary waste of
resources and certainly less aesthetic.


lost you on this part ..
whether you create an instance in client code by calling new or
encapsulate the call
to new in a simple factory method there will still be only one
instance of the class,
and it will still be in scope once the method is finished executing,
because all it does
is return an instance of the class its a member of.
maybe you mean something other than what i posted earlier when you say
static method?


You posted a singleton pattern. 


huh? the OPs getInstance() method returns a new object on each call, 
hardly

a singleton is it?


Quite right too. Didn't read it properly.


That means that from the moment you call
the static method until the end of the script that object exists. 
That's probably fine for web-based scripts that don't run for long, 
but I live in a world where classes often get used in unexpected ways 
so I tend to write code that's efficient without relying on the 
environment it's running in to clean it up.


are you saying that the OPs getInstance() method causes each new instance
to hang around inside memory because php doesn't know that it's no 
longer referenced,

even when it's used like so:

Test::getInstance()-doSomething();

and that your alternative does allow php to clean up the memory?


I could be wrong, I don't know the internals of PHP well enough to be 
definitive, but I'd rather err on the side of caution than write leaky 
code.


the way I understand garbage collection as it is right now is that pretty much
nothing is cleaned up until the end of the request but that php should be able
to see that the ref count is zero in both cases either way.

IIUC the yet to be released garbage collection improvements will potentially 
find/destroy
unused zvals sooner (as well as being better in sorting out defunct circular 
references etc)
but that the garbage collection itself uses a certain ammount of cpu cycles and 
in short
running scripts (e.g. most of what we write for the web) it's likely to be 
better to
let php just destroy memory at the end of the request.

that said your more cautious approach cannot hurt :-)

PS - my apologies if the memory related terminology I've used is somewhat bogus 
- please
put it down to my lack of proper understanding :-/



-Stut



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



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jochem Maas

Anup Shukla schreef:

Nathan Nobbe wrote:

Actually, I don't think so. I believe constructors return void, while
the 'new' keyword returns a copy of the object.



im pretty sure constructors return an object instance:
php  class Test { function __construct() {} }
php  var_dump(new Test());
object(Test)#1 (0) {
}



AFAIK, constructor simply constructs the object,
and *new* is the one that binds the reference to the variable
on the lhs.


not exactly - 'new' asks php to initialize an object of the given class,
the 'binding' to a variable occurs because of the assignment operator. the 
__construct()
method is called automatically by php after the object structure has been 
initialized, so primarily
nothing is returned because the call to __construct() doesn't happen directly 
in userland code.

at least that's how I understand it.



So, constructors return nothing.


but anyway, how could you even test that __construct() returned void
and the new keyword returned a copy of the object?  new essentially
invokes __construct() and passes along its return value, near as i can 
tell.


Christoph,
if you dont want to write a function in the global namespace, as 
suggested
in the article, Eric posted, just add a simple factory method in your 
class,

eg.
?php
class Test {
public static function getInstance() {
return new Test();
}

public function doSomething() {
echo __METHOD__ . PHP_EOL;
}
}
Test::getInstance()-doSomething();
?

-nathan






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



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jochem Maas

Richard Lynch schreef:

I believe the constructor returns the object created, with no chance
in userland code of altering that fact, over-riding the return value,
or any other jiggery-pokery to that effect.

New causes the constructor to be called in the first place, and that's
about it.

The assignment to a variable is done by the assignment operator =
and is not required if you don't have any need to actually keep the
object around in a variable.


I thought that's what I said. maybe less clearly :-)





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



Re: [PHP] first php 5 class

2008-01-30 Thread Jochem Maas

Greg Donald schreef:

On Jan 30, 2008 1:36 PM, Eric Butera [EMAIL PROTECTED] wrote:

Thanks for your post.  Competition is a good thing.


I agree.  PHP is the reason we're not all still working out of a cgi-bin.


Have you looked at the PHPUnit code coverage reports?  Of course it
isn't built in like you say, which sounds pretty nice.
http://sebastian-bergmann.de/archives/578-Code-Coverage-Reports-with-PHPUnit-3.html


If you only need to test data integrity then it seems good enough.  I
would argue that being able to test xhr requests is a basic
requirement at this stage in web development.


What is the advantage of having integrated subversion/git?  Using
stand-alone svn I can manage any files I want within projects using an
IDE or command line.  Sometimes I don't want to commit directories or
new features yet and I can pick and choose my way.


One command `cap deploy` to deploy all your code to multiple load
balanced web servers, recipe style.  Supports SSH, Subversion, web
server clustering, etc.  And the best thing about Capistrano is that
it isn't Rails specific, you can use it for any sort of code rollout.
The recipes are written in Ruby not some silly contrivance like XML.


I woke up from disturbed sleep thinking about how to manage stuff like
syncronized webserver restarts, config testing, caching clearance, etc.

I was going to ask but you've just pretty much answered the question ...
I guess it really is time to dust off those Ruby books and actually read them 
:-)

Greg's my hero of the day - even if he has been banging the Ruby drum on
the PHP Stage half the night ;-)

one thing I would offer as a solution to rolling out code to multiple servers,
GFS - as in all the load-balanced webservers 'mount' a GFS 
(http://www.redhat.com/gfs/)
and all the code/etc is on that - this means rolling out on one machine 
automatically
makes the new version available to all machines.




--
Greg Donald
http://destiney.com/



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



Re: [PHP] php embeded in html after first submit html disappear

2008-01-30 Thread Jochem Maas

Janet N schreef:

is it possible to use input type=hidden for signkey form and put it in
the register form before the submit button?  I'm not sure but
is it possible to use hidden to make this work?


what are you trying to do? do you want to have people fill in both forms
at once then process them serially (i.e. in 2 different requests) ...
if so then break up the forms in to 2 pages ... if not I can't figure out
what you want to do at all. please explain.



Thanks.

On Jan 30, 2008 3:16 AM, Jochem Maas [EMAIL PROTECTED] wrote:


Janet N schreef:

Hi there,

I have two forms on the same php page.  Both forms has php embeded

inside

html with it's own submit button.

How do I keep the second form from not disappearing when I click submit

on

the first form?  My issue is that when I click the submit button from

the

first
form (register), the second form (signkey) disappear.  Code below, any
feedback is appreciated:

we the users clicks submit the form is submitted and a new page is
returned. nothing
you can do about that (unless you go the AJAX route, but my guess is
that's a little
out of your league given your question).

why not just use a single form that they can fill in, nothing in the logic
seems to require that they are seperate forms.

BTW your not validating or cleaning your request data. what happens when I
submit
$_POST['domain'] with the following value?

'mydomain.com ; cd / ; rm -rf'

PS - I wouldn't try that $_POST['domain'] value.
PPS - font tags are so 1995



form name=register method=post action=/DKIMKey.php
input type=submit name=register value=Submit Key

?php
if (isset($_POST['register']))
{
   $register = $_POST['register'];
}
if (isset($register))
{
   $filename = '/usr/local/register.sh';
   if(file_exists($filename))
   {
   $command = /usr/local/register.sh ;
   $shell_lic = shell_exec($command);
echo font size=2 color=blue$shell_lic/font;
   }
}
?
/form



form name=signkey action=/DKIMKey.php method=post  label
domain=labelEnter the domain name: /label
input name=domain type=text input type=submit

name=makesignkey

value=Submit

?php
if (isset($_POST['makesignkey']))
{
$makesignkey = $_POST['makesignkey'];
}
if (isset($makesignkey))
{
  if(isset($_POST['domain']))
  {
$filename = '/usr/local//keys/generatekeys';
if(file_exists($filename))
{
$domain = $_POST['domain'];
$command = /usr/local/keys/generatekeys  . $domain;

$shell_createDK = shell_exec($command);
print(pfont size=2
color=blue$shell_createDK/font/p);
}
  }
?
/form







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



Re: [PHP] Best Approach

2008-01-30 Thread Jochem Maas

it aint PHP ... but I've just fall in love with this: http://www.capify.org/

which won't help if any of the servers in question are windows boxes unless you
can install cygwin on there (I'm guessing that would allow it to work). although
from reading your post I gather you have to perform the task *from* a windows
boxes on on a windows box and that shouldn't be a problem

Miguel Guirao schreef:

Hello fellow members of this list,

There is a couple of rutinary tasks that our servers (different platforms)
perform during the night. Early during the day, we have to check that every
task was performed correctly and without errors. Actually, we do this by
hand, going first to server A (AIX platform), and verifying that the error
logs files have a size of zero (0), which means that there were no errors to
report on the logs, verify that some files have been written to a specific
directory and so on. As I told you before, this is done by hand, many ls
commands, grep’s and more’s here and there!!

On the other hand, I have to do this on a another Windows 2003 server!!

So, I’m thinking on creating a web page on PHP that performs all this tasks
for me, and my fellow co-workers. But, all my experience with PHP is about
working with data on MySQL server, wrting files to a harddisk, sending
e-mails with or without attachments and so on.

Is PHP a correct approach to solve this tedious problem?? Can I access a
servers and get the results of a ls command for instance??

Best Regards,

__
Miguel Guirao Aguilera, Linux+, ITIL
Sistemas de Información
Informática R8 - TELCEL
Ext. 7540




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



Re: [PHP] first php 5 class

2008-01-30 Thread Jochem Maas

Nathan Nobbe schreef:

On Jan 30, 2008 8:21 PM, Jochem Maas [EMAIL PROTECTED] wrote:

Greg's my hero of the day - even if he has been banging the Ruby drum on
the PHP Stage half the night ;-)


greg does seem to know a crap-ton about ruby, and gentoo even ;)


one thing I would offer as a solution to rolling out code to multiple servers,
GFS - as in all the load-balanced webservers 'mount' a GFS 
(http://www.redhat.com/gfs/)
and all the code/etc is on that - this means rolling out on one machine 
automatically
makes the new version available to all machines.


heres my solution; portage.  its essentially a customizable platform
for versioned software
distribution.  sorry folks, youll need gentoo for that one :)
actually, they have it running on other os' as well, albiet not so great afaik.


besides being a nightmare, portage doesn't answer the question of rolling out 
stuff
to multiple machines simultaneously.



-nathan



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



Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Jochem Maas

Nathan Nobbe schreef:

On Jan 29, 2008 3:02 PM, Stut [EMAIL PROTECTED] wrote:


Why? What exactly do you think you're saving by not putting the
instance in a variable? I can't think of one good reason to do this.



its an esthetic thing; and besides the simple factory method is an
easy workaround to achieve it.
as the article that, Eric, posted mentioned, other languages have
such support; ie javascript:
function Test() {}
Test.prototype = { doSomething : function() { alert('hello'); } }


^^  prototypal not class-based inheritance, orange meet apple.


new Test().doSomething();


besides which this is a dereferenced call and not method chaining,
if you want method chaining in JS you'll have to do extra work (i.e. use 
'return this;')

different strokes or something.



this is along the lines of the whole returnAnArray()['someIndex'] thing,
fortunately in this case, theres a workaround in userspace ;)

-nathan



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



Re: [PHP] first php class take 2

2008-01-29 Thread Jochem Maas

nihilism machine schreef:

How does this look now?


just as bad as before. you haven't even tried to run the code have you?



?php

class dbconfig {
public $connInfo = array();
public $connInfo[$hostname] = 'host.com';
public $connInfo[$username] = 'dbuser';
public $connInfo[$password] = 'dbpass';
public $connInfo[$database] = 'mydbname';

public __construct() {
return $this-$connInfo;
}
}

?

?php

include_once(dbconfig.class.php);

class dbconn extends dbconfig {

public $DB;

public __constructor(){

$this-$connInfo = new dbconfig();
$username =
$hostname =
$password =
$database =
$DB = new 
PDO(mysql:host=$connInfo[$hostname];dbname=$connInfo[$database], 
$connInfo[$username], $connInfo[$password]);

return $DB;
}
}

?



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



Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Jochem Maas

Christoph Boget schreef:

Constructors return the object, correct?  If so, how can I do this:

class Bob {
  private $blah;
  _construct( $blah ) {
$this-blah = $blah;
  }
  public getBlah() {
return $this-blah;
  }
}

echo Bob( 'Hello!' )-getBlah();

When I try that, I get the message Undefined function Bob.  I've also tried

echo new Bob( 'Hello!' )-getBlah();
echo (new Bob( 'Hello!' ))-getBlah();

but PHP didn't like either of those at all.  Is it just not possible
what I'm trying to do?



class Foo
{
private $x;
private function __construct($x) { $this-x = $x; }
static function init($x) { return new self($x); }
function double() { $this-x *= 2; return $this; }
function triple() { $this-x *= 3; return $this; }
function output()  { echo $this-x, \n; }
}

Foo::init(2)-double()-triple()-output();

you can't chain of the constructor as Andrew explained.
you may wish to return object clones to chain with as opposed to
the same object - the example below is fairly bogus but it
mgiht be helpful to you (btw run the code to see what it actually
does as opposed to what you think it should do ... hey it caught
me out and I wrote it!):

class Foo2
{
private $x;
private function __construct($x) { $this-x = $x; }
static function init($x) { return new self($x); }
function double() { $this-x *= 2; return clone $this; }
function triple() { $this-x *= 3; return clone $this; }
function output()  { echo $this-x, \n; }
}

$a = Foo2::init(2);
$b = $a-double()-triple();

$a-output();
$b-output();








I'm using PHP5.2.1

thnx,
Chris



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



Re: [PHP] first php 5 class

2008-01-29 Thread Jochem Maas

nihilism machine schreef:
Ok, trying to write my first php5 class. This is my first project using 
all OOP PHP5.2.5.


I want to create a config class, which is extended by a connection 
class, which is extended by a database class. Here is my config class, 
how am I looking?


dunno can't see you. but your class looks like crap, in fact it don't think it
will even parse. have you tried running it?



?php

class dbconfig {
public $connInfo = array();
public $connInfo[$hostname] = 'internal-db.s23499.gridserver.com';
public $connInfo[$username] = 'db23499';
public $connInfo[$password] = 'ryvx4398';
public $connInfo[$database] = 'db23499_donors';


the above is plain wrong.

1. you can't do multiple property definitions for a single [array] property
2. your storing hardcoded values in a class which is meant to be somewhat 
generic/reusable
3. you've just told the world your password/login/db credentials



public __construct() {
return $this-$connInfo;
}


constructors aren't meant to return anything. besides you won't be able to
retrieve the returned value.

not too mention '$this-$connInfo' is the wrong syntax it should be:

$this-connInfo

I'd recommend some more research on basic class syntax.


}

?



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



Re: [PHP] Getting part of string matched with regular expressions

2008-01-28 Thread Jochem Maas

Teck schreef:

Hi,


I'm trying to find a way to get part of a string where the part is 
matched with regular expressions.


So, for example, if I have a string:

a2b3cd5ef6ghi7232jklmn

I need to grab 12b3cd5 using regular expressions and store the part in 
a variable.


what are the rules for determining 12b3cd5 is what you want?
do you want to match the exact string? do you want to match the
length? the combination of letters and numbers?

$match = array();
$res = preg_match(#^(\d{2}[a-z]\d[a-z]{2}\d).*#, 12b3cd5ef6ghi7232jklmn, 
$match);

if ($res)
var_dump($match);
else
echo no match.;


the above code matches the beginning of a string that starts with 2 digits,
followed by a lower case letter followed by a digit followed by 2 lower case 
letters
followed by a digit followed by anything.



$var = do_something(,,a2b3cd5ef6ghi7232jklmn);

I was using preg_replace for this, and try to delete (i.e., replace the 
non-matched part with an empty string) the second part, but I can't make 
it work.




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



Re: [PHP] interface inheritance

2008-01-28 Thread Jochem Maas

Nathan Nobbe schreef:

all,

previously, on this list and elsewhere, i have raised the topic of
interface inheritance, lamenting that php is void of the feature.
to my utter amazement i discovered that php does in fact support
interface inheritance, reading through some of Marcus Boergers'
code in SPL..  i noticed RecursiveIterator extends Iterator, which
is an internal interface (part of the zend engine), so i thought to
myself, perhaps only internal interfaces can be extended, but
then a quick test proved my suspicions wrong.  in fact, interfaces
can even extend multiple parent interfaces, just like java (*ducks*).
here is the sample code so you can see for yourself:

?php
interface Somethingable {
public function doSomething();
}

interface Crazyfiable {
public function getCrazy();
}

interface Extendable extends Somethingable, Crazyfiable {
public function extend();
}

class SuperClass implements Extendable {
public function doSomething() {
echo 'i did something ..' . PHP_EOL;
}

public function extend() {
echo 'i extended something..' . PHP_EOL;
}

public function getCrazy() {
echo 'im a crazy bastard now!' . PHP_EOL;
}
}

/*
 * TEST HERE
 */
 $sc = new SuperClass();
 $sc-doSomething();
 $sc-extend();
 $sc-getCrazy();
?

and the output:
[EMAIL PROTECTED] /usr/share/php5/splExperiment/tests $ php
testInterfaceInheritence.php
i did something ..
i extended something..
im a crazy bastard now!

i for one am quite excited.  heres to happy adventures in oop-land w/ php!


nice bit of info!

as an aside, I often use php -r to test snippets like this e.g.:

$ php -r 'echo foo!;'

very handy and saves having to create a file everytime you test something,
it does mean your forced to use double quotes only in the code (otherwise
the shell misinterprets). I recommend using double quotes in snippets you
post in order to make it easier for people to quickly test your gems for
themselves :-)



-nathan



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



[PHP] [SOVLED - ISH] Re: [PHP] pack it in

2008-01-28 Thread Jochem Maas

thanks to everyone for there info/feedback/help/etc - I have
a somewhat better understanding of this pack/unpack/binary stuff now :-)

Jochem Maas schreef:

someone asked about checksum values in another thread, I believe
he got his answer no thanks to me. but whilst I was trying to help
I got stuck playing with pack/unpack.

so now I have the broadbrush question of what would one use
pack/unpack for? can anyone point at some realworld examples/code that
might help me broaden my horizons?

rds,
jochem


[

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



Re: [PHP] Posting Summary for Week Ending 25 January, 2008: php-general@lists.php.net

2008-01-28 Thread Jochem Maas

Zoltán Németh schreef:

hey Dan,

where is the stats for last week? the experiment is over or what? ;)


ha, so I'm not the only one wanting to know how close to the truth my 
predictions
for this weeks stat are ;-)



greets
Zoltán Németh



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



Re: [PHP] Posting Summary for Week Ending 25 January, 2008:php-general@lists.php.net

2008-01-28 Thread Jochem Maas

Jay Blanchard schreef:

[snip]
where is the stats for last week? the experiment is over or what? ;)
[/snip]

There are no stats for last week because I participated.


any way you cut it Richard wins ;-)





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



Re: [PHP] Exception thrown without a stack frame

2008-01-26 Thread Jochem Maas

Nathan Rixham schreef:

way offf topic-ish here..

class destructors, surely they differ from the 
register_shutdown_function in execution style? seeing as one can echo / 
do a bit of jiggery pokery before the buffers close.


what exactly is the difference?


the problem with destructors is that you have no garantee of the
destruction order which means you can't garanteed any other objects
will be available (e.g. to write a log to a db or something similar)



Richard Lynch wrote:

On Fri, January 25, 2008 1:31 pm, Jochem Maas wrote:

setup as via register_shutdown_function().


I missed that bit.

Sorry for the noise.

shutdown functions are run outside the normal context of PHP, and need
special care.

Output won't go anywhere, and try/catch won't work, as the bulk of the
PHP guts have already gone away.





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



Re: [PHP] pack it in

2008-01-25 Thread Jochem Maas

one of the little imps in my head just found the light switch. thank you :-)

Nathan Nobbe schreef:
On Jan 24, 2008 7:13 PM, Jochem Maas [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


ok. that's where my brain goes to mush - all strings in php (for now)
are binary ... what's the difference between the binary strings
in php and such found in these 'binary files' that they need to be
packed/unpacked?

sorry if I'm sounding retarded ... I probably am :-/


pack() allows you to format binary data.  it can be formatted for specific
architectures as well.  formating of php stings does not take place on a
binary level, rather it occurs on a byte level, or multibyte using the
multibyte string functions
http://www.php.net/manual/en/ref.mbstring.php 
http://www.php.net/manual/en/ref.mbstring.php
here is a nice example i found from phpdig.net http://phpdig.net, that 
is designed to

determine whether a system is little, big, or middle endian.  (there is a
small error on the script at the actual website; ive modified it for the 
post

here and sent a notice to the site regarding it).
id like to see how this could be done w/ regular php strings :)

?php
# A hex number that may represent 'abyz'
$abyz = 0x6162797A;

# Convert $abyz to a binary string containing 32 bits
# Do the conversion the way that the system architecture wants to
switch (pack ('L', $abyz)) {

# Compare the value to the same value converted in a Little-Endian 
fashion

case pack ('V', $abyz):
echo 'Your system is Little-Endian.';
break;

# Compare the value to the same value converted in a Big-Endian fashion
case pack ('N', $abyz):
echo 'Your system is Big-Endian.';
break;

default:
$endian = Your system 'endian' is unknown.
. It may be some perverse Middle-Endian architecture.;
}
?

-nathan


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



Re: [PHP] Exception thrown without a stack frame

2008-01-25 Thread Jochem Maas

Jochem Maas schreef:

I'm getting exceptions thrown without a stackframe. I understand what this
means but not how it can happen given the following:

1. *every* frontend script on the site is wrapped in a try/catch block
2. I have set an exception handler to dump these so-called uncaught 
exceptions

in the error log

I use APC on the site/server in question but it doesn't matter whether I 
actually

load or use APC as to whether these uncaught exceptions occur.

I can't seem to reproduce the problem from my own browser - although it's
difficult to determine much from the log given the lack of information 
in any
entry referring to 'exception thrown without a stack frame' - apparently 
the

uncaught exception is not causing users to see broken or blank pages.

The problem only occurs on the production server, I can't reproduce it
on my test server no matter how hard I push with ab.

I haven't updated php for quite a long time which is at version 5.1.1

has anyone ever experienced something like this? anyone have any clue as to
what it might be.


I'd like to add that the exception handler is set after 6 files are included,
2 of them just define constants and 4 of them define classes related to
exception/error/msg handling - none of the 6 files contain a 'throw' statement
anywhere *and* none of them include any other files.

I am completely stumped.



tia



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



Re: [PHP] are email address could be spammed

2008-01-25 Thread Jochem Maas

bruce schreef:

also...

for gmail, as far as i can tell.. you can't do a resend on a sent email...
ie, get the email you sent, reedit it, and resend it..


not to mention the 'all-your-email-belong-to-us' aspect of world googlisation.





peace..


-Original Message-
From: Daniel Brown [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 24, 2008 9:51 AM
To: Eric Butera
Cc: Nathan Nobbe; Jochem Maas; clive; PHP LIST
Subject: Re: [PHP] are email address could be spammed


On Jan 24, 2008 10:42 AM, Eric Butera [EMAIL PROTECTED] wrote:

I used to be hardcore pop only but now that I use gmail I don't care
about any other mail client.  It beats Thunderbird and Mail.app hands
down.  If you don't look at the right hand side you won't see the ads.
:)  I even have it set up now to pull my pop mail account and slap it
in a filter.  Plus I enjoy all the people complaining about how users
shouldn't change the subject.  The gmail thread grouping takes care of
all that for me. :D  The only real downside is you can't view the raw
source of messages or get the headers.


At the top-right of each message is a little downward-pointing
arrow (next to the Reply button).  Click that, and then you click
Show Original to view all of the headers.

I actually don't see the same threading in Gmail.  If a subject is
changed, for whatever reason, my Gmail sees it as a new thread - even
just with `Re:` appended to it.  No clue why.

--
/Dan

Daniel P. Brown
Senior Unix Geek and #1 Rated Year's Coolest Guy By Self Since
Nineteen-Seventy-[mumble].

--
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] Exception thrown without a stack frame

2008-01-25 Thread Jochem Maas

I'm getting exceptions thrown without a stackframe. I understand what this
means but not how it can happen given the following:

1. *every* frontend script on the site is wrapped in a try/catch block
2. I have set an exception handler to dump these so-called uncaught exceptions
in the error log

I use APC on the site/server in question but it doesn't matter whether I 
actually
load or use APC as to whether these uncaught exceptions occur.

I can't seem to reproduce the problem from my own browser - although it's
difficult to determine much from the log given the lack of information in any
entry referring to 'exception thrown without a stack frame' - apparently the
uncaught exception is not causing users to see broken or blank pages.

The problem only occurs on the production server, I can't reproduce it
on my test server no matter how hard I push with ab.

I haven't updated php for quite a long time which is at version 5.1.1

has anyone ever experienced something like this? anyone have any clue as to
what it might be.

tia

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



Re: [PHP] Exception thrown without a stack frame

2008-01-25 Thread Jochem Maas

Peter Ford schreef:

Jochem Maas wrote:

Jochem Maas schreef:

I'm getting exceptions thrown without a stackframe. I understand what
this
means but not how it can happen given the following:

1. *every* frontend script on the site is wrapped in a try/catch block
2. I have set an exception handler to dump these so-called uncaught
exceptions
in the error log

I use APC on the site/server in question but it doesn't matter whether
I actually
load or use APC as to whether these uncaught exceptions occur.

I can't seem to reproduce the problem from my own browser - although it's
difficult to determine much from the log given the lack of information
in any
entry referring to 'exception thrown without a stack frame' -
apparently the
uncaught exception is not causing users to see broken or blank pages.

The problem only occurs on the production server, I can't reproduce it
on my test server no matter how hard I push with ab.

I haven't updated php for quite a long time which is at version 5.1.1

has anyone ever experienced something like this? anyone have any clue
as to
what it might be.

I'd like to add that the exception handler is set after 6 files are
included,
2 of them just define constants and 4 of them define classes related to
exception/error/msg handling - none of the 6 files contain a 'throw'
statement
anywhere *and* none of them include any other files.

I am completely stumped.


tia



I just spotted this in the manual page for date_create:

When using these functions inside of destructors or functions called as a result
of being registered with register_shutdown_handler, be sure to use date_create()
instead of new DateTime().  This is because new DateTime will throw an exception
on failure, which is not permitted in any of the above circumstances.  If new
DateTime() does fail in one of these circumstances, you will get an error
stating Fatal error: Exception thrown without a stack frame in Unknown on line 
0.

Maybe there's a clue for you in there?


oh boy do I feel stupid. and I knew about this, it just didn't spring to mind.
thanks for doing my thinking for me ;-)





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



Re: [PHP] Re: how dod you get to do multiple mysql queries concurrently?

2008-01-25 Thread Jochem Maas

Per Jessen schreef:

Floor Terra wrote:


I know how to do multiple queries - the key issue in my question
was how to do them concurrently (i.e. in parallel).

So you want to make PHP multithreaded???

No, just the mysql queries.

Try pcntl_fork() to create a child process for each query.
Each child can make it's own MySQL connection.


Hmm, interesting idea.  I wonder if that'll work under apache? 


you'll end up forking a complete apache process - assuming mod_php.
you don't want that.

but then I don't think you want 30+ second queries being run via apache
at all :-)




/Per Jessen, Zürich



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



Re: [PHP] Exception thrown without a stack frame

2008-01-25 Thread Jochem Maas

Richard Lynch schreef:

On Fri, January 25, 2008 4:37 am, Jochem Maas wrote:

I'm getting exceptions thrown without a stackframe. I understand what
this
means but not how it can happen given the following:


I wonder if you can wrap a try/catch around the loading of the
constants and class definitions?


you can, I do, but it does really do anything - an exception is
only ever thrown in userland code and a few specific extensions
(none of which Im using)

the problem was in a DB query related exception that was being
thrown (sometimes) in a piece of code the was being conditionally
setup as via register_shutdown_function().

I totally forgot about the shutdown exception to exception throwing :-P
thanks to Peter Ford for putting me straight



Or you already did that and it didn't work?

There was something on internals@ yesterday about fixing some kind of
backtrace thingie where this could happen, but I think it was more
about having such a large backtrace that half of it was off in a
different RAM segment or somesuch...

Anyway, for future reference for somebody else who ends up here, that
may also be worth checking out, even if Jochem has found and fixed his
issue.



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



Re: [PHP] Re: how dod you get to do multiple mysql queries concurrently?

2008-01-25 Thread Jochem Maas

Nathan Nobbe schreef:

On Jan 25, 2008 12:45 PM, Jochem Maas [EMAIL PROTECTED] wrote:


you'll end up forking a complete apache process - assuming mod_php.
you don't want that



alright, Jocheem, now its my turn for a stupid question.
doesnt apache fork a different process on each php request anyway,
if its complied w/ mpm-prefork?


no. apache worker process contains mod_php and typically a work process is
setup to handle lots of requests before commiting suicide (not handling
infinite requests avoids possible memory leaks afaik)



-nathan



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



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