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] Need assistance using sendmail or mail()

2008-01-30 Thread Tom Chubb
On 30/01/2008, Per Jessen [EMAIL PROTECTED] wrote:

 philip wrote:

  Hi everyone,
 
  I need assistance using sendmail or mail() as my web hosting service
  does not allow opening sockets.
 
  This is the code I use:

 Philip, please state what sort of problems you are having.  mail() and
 sendmail are both easy to use from php.
 And please don't post another 2000 lines of code. No-one is going to
 read them.



 /Per Jessen, Zürich

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


He's just trying to get a nice share of the bytes on Dan's weekly posting
summary ;)


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

2008-01-30 Thread Stut

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


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

--
http://stut.net/

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

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 Stut

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.


-Stut

--
http://stut.net/

--
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 Anup Shukla

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.

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




--
Regards,
Anup Shukla

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



Re: [PHP] potentially __sleep() bug

2008-01-30 Thread Anup Shukla

Nathan Nobbe wrote:

all,

i was playing around w/ some object serialization tonight during
further exploration of spl and i stumbled on what appears to be a
bug in the behavior of the __sleep() magic method.

here is the pertinent documentation on the method
..is supposed to return an array with the names of all variables
of that object that should be serialized.

so, the idea is, *only* the instance variables identified in the array
returned are marked for serialization.
however, it appears all instance variables are being serialized no matter what.
see the reproducible code below.  ive run this on 2 separate php5
boxes, one w/ 5.2.5, another w/ a 5.2.something..

?php
class A {
public $a1 = 'a1';
public $a2 = 'a2';
public $a3 = 'a3';

public function __sleep() {
echo __FUNCTION__ . PHP_EOL;
return array('a1', 'a2');
}
}

var_dump(unserialize(serialize(new A(;
?

this is what i get despite having marked only member variables 'a',
and 'b' for serialization.

__sleep
object(A)#1 (3) {
  [a1]=
  string(2) a1
  [a2]=
  string(2) a2
  [a3]=
  string(2) a3
}

consensus ?



To check if __sleep is proper, you should be doing
var_dump(serialize(new A()));

unserialize'ing effectively also does a __wakeup()

This should give a clearer picture

?php
class A {
public $a1 = 'a1';
public $a2 = 'a2';
public $a3 = null;

public function __construct(){
   $this-a3 = 'a3';
}

public function __sleep() {
echo __FUNCTION__ . PHP_EOL;
return array('a1', 'a2');
}
}

var_dump(unserialize(serialize(new A(;
?

__sleep
object(A)#1 (3) {
  [a1]=
  string(2) a1
  [a2]=
  string(2) a2
  [a3]=
  NULL
}

= and ==

?php
class A {
public $a1 = 'a1';
public $a2 = 'a2';
public $a3 = null;

public function __construct(){
   $this-a3 = 'a3';
}

public function __sleep() {
echo __FUNCTION__ . PHP_EOL;
return array('a1', 'a2', 'a3');
}
}

var_dump(unserialize(serialize(new A(;
?

__sleep
object(A)#1 (3) {
  [a1]=
  string(2) a1
  [a2]=
  string(2) a2
  [a3]=
  string(2) a3
}

--
Regards,
Anup Shukla

--
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] Another question about functions...

2008-01-30 Thread Jason Pruim


On Jan 29, 2008, at 4:29 PM, Nathan Nobbe wrote:


On Jan 29, 2008 3:53 PM, Jason Pruim [EMAIL PROTECTED] wrote:
I did as you suggested, and I think I found the reason... I included  
info for the doctype, and some files that are on all my pages...  
Once I comment out those lines it works just fine...


I'm assuming that that is expected behavior?

where did you include this information?
i didnt see it in the original code you posted.
and, btw. im no expert on setting mime types for excel :)

-nathan





They were included in a config file I am working on... the  
defaults.php file that has other config info, such as DB auth info and  
system wide variables.



--

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




Re: [PHP] first php 5 class

2008-01-30 Thread Eric Butera
On Jan 29, 2008 3:29 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 On Jan 29, 2008 3:19 PM, nihilism machine [EMAIL PROTECTED] wrote:

  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?
 
  ?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';
 
 public __construct() {
 return $this-$connInfo;
 }
  }
 
  ? http://www.php.net/unsub.php


 if youre going to have a class for configuration information; you probly
 should
 go for singleton:
 http://www.phppatterns.com/docs/design/singleton_pattern?s=singleton

 -nathan


Still pimping singleton, huh? :)

-- 
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 Nathan Nobbe
On Jan 30, 2008 5:56 AM, Stut [EMAIL PROTECTED] wrote:

 Nathan Nobbe wrote:
 You posted a singleton pattern.


no, what i posted was a simple factory pattern.
if you invoke it twice there will be 2 instances of Test in memory,
eg. not singleton.
$a = Test::getInstance();
$b = Test::getInstance();


 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.


i usually only need to do cleanup in cli scripts that batch large amounts of
data.  this is my practical experience anyway.


 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.


well you are still creating an instance of the object.  the only difference
is
you are forcing it the ref count to 0 by assigning the instance to a local
local variable.

It's fairly likely that I'd actually just use a static method here,


both your and my code use static methods.  it sounds to me like you are
using the term 'static method' to mean a static method that has a variable
with a reference to an instance of the class that it is a member of.  which
is obviously a particular use of a static method, and therefore a bad
practice
imho.  not the technique, mind you, the label of 'static method' for the
technique.


-nathan


Re: [PHP] first php 5 class

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 8:40 AM, Eric Butera [EMAIL PROTECTED] wrote:

 On Jan 29, 2008 3:29 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 Still pimping singleton, huh? :)


hell yeah :)

i looked at the registry classes you pointed out.
you know what funny about the one in solar?
they refer to the same article i mentioned, namely,
the article at the phppatterns site.  good to know
somebody else out there thinks highly of that site :)

also, i took a look (briefly though), in patterns of
enterprise architecture by martin fowler, which is
(perhaps) where the pattern was originally formalized.
he says that he prefers to have the data in the registry
stored in instance variables, but obviously there are ways
to vary the implementation of a pattern.  ergo, in his
design the registry class itself would be a singleton.

it looks like the 3 examples you showed previously, are
all of essentially the same design.  a class uses static
class members to store the data, and it is essentially
global, because well, any bit of code can reference the class.
id say the technique only works as a consequence of phps
dynamic nature, that is, in other languages like java and c++
i dont think you can create static class members on the fly.
the technique is certainly interesting.

-nathan


[PHP] We need PHP/LAMP Developers and Programmers in FL, MD, VA, NY, DC, CA, MA!!!!

2008-01-30 Thread PHP Employer

We need PHP/LAMP Developers and Programmers in FL, MD, VA, NY, DC, CA, MA

World NetMedia is a world class leader in the development of multimedia
internet sites. We are seeking highly motivated individuals who eat, breath,
and love the work they do. If you like working in a fun, laid-back, yet
exciting environment; then we want to hear from you!


Job Description :
– Looking for a true PHP Programmer that loves to hack code in several
languages and has fun doing it.
– Design, develop, maintain and optimize secure and scalable multi-tier web
applications.
– Strong knowledge of PHP, Perl, Javascript, UNIX shell, SQL, HTML, CSS,
XML.
– Comfortable with both object oriented and procedural programming
methodologies.
– Experience with PHP5 and MySQL5 preferable.
– Experience with C, C++, Java, Python, and other languages a plus.
– Knowledge installing, configuring and maintaining Linux, Apache, MySQL and
PHP packages.
– Strong knowledge of stored procedures, triggers, indexes, table
normalization and database design.
– Familiarity with Zeus Web Server a big plus.
– Knowledge of AJAX development a plus.
– Comfortable hacking and compiling Linux software packages.
– Strong understanding of software development life-cycle and best
practices.
– Proficiency in working and developing on Linux (any flavor – debian,
redhat, ubuntu, slackware etc.

Requirements :
– BS/MS in CS/CE or significant work experience.
– Must be able to gather requirements, design, code and test independently
as well as work jointly with the team.

*This is not a recruiter, agency, or headhunter ad. You will be contacted by
someone from our Corporate Recruiting team directly.

Apply online or click here for a link to job posting (You can also submit
your resume to [EMAIL PROTECTED] :

Links to job postings:


Miami Beach, FL:
http://tbe.taleo.net/NA7/ats/careers/requisition.jsp?org=WORLDNETMEDIAcws=1rid=11


Alexandria, VA:
http://tbe.taleo.net/NA7/ats/careers/requisition.jsp?org=WORLDNETMEDIAcws=1rid=38


Baltimore, MD:
http://tbe.taleo.net/NA7/ats/careers/requisition.jsp?org=WORLDNETMEDIAcws=1rid=42


Manhattan, NY:
http://tbe.taleo.net/NA7/ats/careers/requisition.jsp?org=WORLDNETMEDIAcws=1rid=47


Washington, DC:
http://tbe.taleo.net/NA7/ats/careers/requisition.jsp?org=WORLDNETMEDIAcws=1rid=50


Silicon Valley:
http://tbe.taleo.net/NA7/ats/careers/requisition.jsp?org=WORLDNETMEDIAcws=1rid=51


-- 
View this message in context: 
http://www.nabble.com/We-need-PHP-LAMP-Developers-and-Programmers-in-FL%2C-MD%2C-VA%2C-NY%2C-DC%2C-CA%2C-MA%21%21%21%21-tp15183845p15183845.html
Sent from the PHP - General mailing list archive at Nabble.com.

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

Nathan Nobbe wrote:
On Jan 30, 2008 10:46 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Nathan Nobbe wrote:

Actually no, I mean I would *just* use a static method. If there is no
reason to instantiate an object, why would you? http://stut.net/


you realize you are instantiating an class in the code you posted, right?
from you post:
$o = new Test();
if i didnt know any better, id call that an instantiation of the Test 
class ;)

the only thing is you are forcing it out of scope by using a local variable
to store the reference to the object.


Seriously? You really need to read the emails you're replying to. I gave 
an example that did what the OP asked for. Then I went on to say that I 
would probably just use a static method. I never said I wasn't creating 
an instance in the example I posted.


The forcing it out of scope was the crux of my point. However, if 
Jochem is right then it's kinda pointless with the current 
implementation of the GC, but may become relevant in the new GC.


-Stut

--
http://stut.net/

--
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 Nathan Nobbe
On Jan 30, 2008 10:46 AM, Stut [EMAIL PROTECTED] wrote:

 Nathan Nobbe wrote:

 Actually no, I mean I would *just* use a static method. If there is no
 reason to instantiate an object, why would you? http://stut.net/


you realize you are instantiating an class in the code you posted, right?
from you post:
$o = new Test();
if i didnt know any better, id call that an instantiation of the Test class
;)
the only thing is you are forcing it out of scope by using a local variable
to store the reference to the object.

-nathan


Re: [PHP] first php 5 class

2008-01-30 Thread Eric Butera
On Jan 30, 2008 9:57 AM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 On Jan 30, 2008 8:40 AM, Eric Butera [EMAIL PROTECTED] wrote:

 
 
  On Jan 29, 2008 3:29 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:
  Still pimping singleton, huh? :)
 

 hell yeah :)

 i looked at the registry classes you pointed out.
 you know what funny about the one in solar?
 they refer to the same article i mentioned, namely,
 the article at the phppatterns site.  good to know
 somebody else out there thinks highly of that site :)

 also, i took a look (briefly though), in patterns of
 enterprise architecture by martin fowler, which is
 (perhaps) where the pattern was originally formalized.
 he says that he prefers to have the data in the registry
  stored in instance variables, but obviously there are ways
 to vary the implementation of a pattern.  ergo, in his
 design the registry class itself would be a singleton.

 it looks like the 3 examples you showed previously, are
  all of essentially the same design.  a class uses static
 class members to store the data, and it is essentially
 global, because well, any bit of code can reference the class.
 id say the technique only works as a consequence of phps
  dynamic nature, that is, in other languages like java and c++
 i dont think you can create static class members on the fly.
 the technique is certainly interesting.

 -nathan


The only gripe I have about the registry pattern is the lack of code
completion in PDT. ;)

I love php patterns, but it seems to sort of be dead for years now.

I just keep downloading copies of various frameworks and poke through
their implementations.  At the end of the day though it is my job to
write code, so I'm going to always balance the code purity vs getting
it done.  I am okay with a registry that uses static methods because
it works in my projects.  Some people would insist on being able to
create an instance and pass that around, but I don't need that level
of complexity.

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

Nathan Nobbe wrote:

It's fairly likely that I'd actually just use a static method here,


both your and my code use static methods.  it sounds to me like you are
using the term 'static method' to mean a static method that has a variable
with a reference to an instance of the class that it is a member of.  which
is obviously a particular use of a static method, and therefore a bad 
practice
imho.  not the technique, mind you, the label of 'static method' for the 
technique.



Actually no, I mean I would *just* use a static method. If there is no 
reason to instantiate an object, why would you?


-Stut

--
http://stut.net/

--
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 Jim Lucas

Stut wrote:

Nathan Nobbe wrote:
On Jan 30, 2008 10:53 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Nathan Nobbe wrote:
I never said I wasn't creating
an instance in the example I posted.


then what exactly did you mean by this?

Actually no, I mean I would *just* use a static method. If there is no
reason to instantiate an object, why would you?


I meant I would *just* use a static method. Calling a static method 
does not create an instance of the class. My comments usually follow the 
rule of Ronseal.


What do you think I meant by it?

-Stut




From your previous email


--
Jim Lucas

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

Twelfth Night, Act II, Scene V
by William Shakespeare

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



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

2008-01-30 Thread Stut

Nathan Nobbe wrote:
On Jan 30, 2008 10:53 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Nathan Nobbe wrote:
I never said I wasn't creating
an instance in the example I posted.


then what exactly did you mean by this?

Actually no, I mean I would *just* use a static method. If there is no
reason to instantiate an object, why would you?


I meant I would *just* use a static method. Calling a static method 
does not create an instance of the class. My comments usually follow the 
rule of Ronseal.


What do you think I meant by it?

-Stut

--
http://stut.net/

--
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 Nathan Nobbe
On Jan 30, 2008 10:35 AM, Eric Butera [EMAIL PROTECTED] wrote:

 The only gripe I have about the registry pattern is the lack of code
 completion in PDT. ;)


heh.  does that still blowup when you try to open a file w/ an interface
definition?


 I love php patterns, but it seems to sort of be dead for years now.


me too; ya, it is sort of dead, sad, but its still worth a look to people
getting
there feet wet w/ patterns, and occasionally as a point of reference for
patterns implemented in php.


 I just keep downloading copies of various frameworks and poke through
 their implementations.


this is a great idea, and youve got me doing more of it.


  At the end of the day though it is my job to
 write code, so I'm going to always balance the code purity vs getting
 it done.  I am okay with a registry that uses static methods because
 it works in my projects.


its sorta like the 'php way' for the registry.  theres something we can say
the java guys cant do ;)

  Some people would insist on being able to

 create an instance and pass that around, but I don't need that level
 of complexity.


i dont think Registry::getInstance() is really that much overhead; but it is
another line of code to write :)

-nathan


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

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 10:53 AM, Stut [EMAIL PROTECTED] wrote:

 Nathan Nobbe wrote:
 I never said I wasn't creating
 an instance in the example I posted.


then what exactly did you mean by this?

Actually no, I mean I would *just* use a static method. If there is no
reason to instantiate an object, why would you?


-nathan


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

2008-01-30 Thread Jim Lucas

Stut wrote:

Nathan Nobbe wrote:
On Jan 30, 2008 10:53 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Nathan Nobbe wrote:
I never said I wasn't creating
an instance in the example I posted.


then what exactly did you mean by this?

Actually no, I mean I would *just* use a static method. If there is no
reason to instantiate an object, why would you?


I meant I would *just* use a static method. Calling a static method 
does not create an instance of the class. My comments usually follow the 
rule of Ronseal.


What do you think I meant by it?

-Stut




From your previous email


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

The above line IS creating a instance of the class Test

Now with proper garbage collection, it should be wiped out when you are done 
using the static doSomething() method.


$o-_doSomething();

You could always include this to remove the instance of class Test

unset($o);


}

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();
?

--
Jim Lucas

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

Twelfth Night, Act II, Scene V
by William Shakespeare

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



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

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 11:21 AM, Stut [EMAIL PROTECTED] wrote:

 Calling a static method
 does not create an instance of the class.


there you go again; calling a static method does create an instance of
the class if you call new inside of it :P

-nathan


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

2008-01-30 Thread Stut

Jim Lucas wrote:

Stut wrote:

Nathan Nobbe wrote:
On Jan 30, 2008 10:53 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Nathan Nobbe wrote:
I never said I wasn't creating
an instance in the example I posted.


then what exactly did you mean by this?

Actually no, I mean I would *just* use a static method. If there is no
reason to instantiate an object, why would you?


I meant I would *just* use a static method. Calling a static method 
does not create an instance of the class. My comments usually follow 
the rule of Ronseal.


What do you think I meant by it?

-Stut



 From your previous email


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

The above line IS creating a instance of the class Test

Now with proper garbage collection, it should be wiped out when you are 
done using the static doSomething() method.


$o-_doSomething();

You could always include this to remove the instance of class Test

unset($o);


}

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();
?


I would *just* use a static method

*just* *just* *just* *just* *just* *just* *just* *just* *just*

No instance. None. Grrr.

FFS.

-Stut

--
http://stut.net/

--
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 Greg Donald
On Jan 30, 2008 10:13 AM, Nathan Nobbe [EMAIL PROTECTED] wrote:
  I love php patterns, but it seems to sort of be dead for years now.

 me too; ya, it is sort of dead, sad, but its still worth a look to people
 getting
 there feet wet w/ patterns, and occasionally as a point of reference for
 patterns implemented in php.

If list traffic is any sign, PHP is indeed slowing down from the new
peeps wanting to learn it perspective:

http://marc.info/?l=php-generalw=2

I would assume it's because there are much more interesting advances
in web development technology to focus on elsewhere.


-- 
Greg Donald
http://destiney.com/

-- 
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 Nathan Nobbe
On Jan 30, 2008 11:31 AM, Stut [EMAIL PROTECTED] wrote:


 I would *just* use a static method

 *just* *just* *just* *just* *just* *just* *just* *just* *just*

 No instance. None. Grrr.


here is a mod of the code you posted w/ a var_dump() of the
local variable $o;

?php
class Test {
public static function doSomething() {
$o = new Test();
var_dump($o);
$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();
?

[EMAIL PROTECTED] ~/ticketsDbCode $ php testCode.php
object(Test)#1 (0) {
}


clearly in the act of *just* using a static method, you *just*
created an instance of class Test ;)

-nathan


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

2008-01-30 Thread Stut

Nathan Nobbe wrote:
On Jan 30, 2008 11:21 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Calling a static method
does not create an instance of the class.


there you go again; calling a static method does create an instance of
the class if you call new inside of it :P


FFS, are you just trolling?

Note that I actually wrote *just* a static method, and I stated quite 
clearly that it was what I would do and that the code I posted was 
providing what the OP wanted. If you can't see the separation then I'm 
done with trying to convince you.


-Stut

--
http://stut.net/

--
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 Nathan Nobbe
On Jan 30, 2008 11:38 AM, Greg Donald [EMAIL PROTECTED] wrote:

 If list traffic is any sign, PHP is indeed slowing down from the new
 peeps wanting to learn it perspective:

 http://marc.info/?l=php-generalw=2


interesting..

http://marc.info/?l=php-generalw=2I would assume it's because there are
 much more interesting advances
 in web development technology to focus on elsewhere.


such as ?


-nathan


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

2008-01-30 Thread Stut

Nathan Nobbe wrote:
On Jan 30, 2008 11:31 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:



I would *just* use a static method

*just* *just* *just* *just* *just* *just* *just* *just* *just*

No instance. None. Grrr.


here is a mod of the code you posted w/ a var_dump() of the
local variable $o;

?php
class Test {
public static function doSomething() {
$o = new Test();
var_dump($o);
$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();
?

[EMAIL PROTECTED] ~/ticketsDbCode $ php testCode.php
object(Test)#1 (0) {
}


clearly in the act of *just* using a static method, you *just*
created an instance of class Test ;)


Ok, I'm going to have to assume you really are as stupid as you seem. If 
I need to provide an example to demonstrate what I meant I will, but I 
feel I made it quite clear that my comment regarding what *I* would do 
did not in any way relate to the code example I had provided above. The 
example I provided was fulfilling the OP's requirements.


This is what *I* would do...

?php
class Test {
public static 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.

//  See this comment here, this was taken from the
// non-static method in the example I posted. This is what
// I meant when I say just use a static method.
}
}
Test::doSomething();
?

Look ma, no instance.

FYI I'm not at all new to OOP, in general or in PHP, so I am well aware 
that the example I originally posted created an instance of the class.


-Stut

--
http://stut.net/

--
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 Eric Butera
On Jan 30, 2008 11:43 AM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 On Jan 30, 2008 11:38 AM, Greg Donald [EMAIL PROTECTED] wrote:

  If list traffic is any sign, PHP is indeed slowing down from the new
  peeps wanting to learn it perspective:
 
  http://marc.info/?l=php-generalw=2


 interesting..

 http://marc.info/?l=php-generalw=2I would assume it's because there are
  much more interesting advances
  in web development technology to focus on elsewhere.


 such as ?


 -nathan


No matter how fancy any scripting language is, it still just generates
(x)html.  :)  If you're more into ajax then json_encode() is really
all that you need, right?

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



[PHP] php spanish character problem

2008-01-30 Thread greenCountry

hello everyone, 

This is important,I am trying to post some spanish characters from a form on
a page and i am comparing those spanish characters to the same letters on
the same page but on strcmp the return is not zero.I don't know what is
wrong some problem with the post method i guess or strcmp i don't
knowPlease helphere is the code... 

htmlbody?php 
echo(strcmp('í',$_POST['check'])); 
? 

form action=./index.php method=post 
input type=text name=check 
input type=submit name=go  
/form 
/body/html 

the name of the file is index.php and i am typing í in the text box before
pressing submit.the result is not coming as zero but -1.The result is not
coming for any of spanish or special characters like ¿,ñ,ü how to solve it
that echo answer is zero. 

I have searched a lot on net and finally i am coming here to get some help.
-- 
View this message in context: 
http://www.nabble.com/php-spanish-character-problem-tp15185959p15185959.html
Sent from the PHP - General mailing list archive at Nabble.com.

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



Re: [PHP] php spanish character problem

2008-01-30 Thread Eric Butera
On Jan 30, 2008 12:07 PM, greenCountry [EMAIL PROTECTED] wrote:

 hello everyone,

 This is important,I am trying to post some spanish characters from a form on
 a page and i am comparing those spanish characters to the same letters on
 the same page but on strcmp the return is not zero.I don't know what is
 wrong some problem with the post method i guess or strcmp i don't
 knowPlease helphere is the code...

 htmlbody?php
 echo(strcmp('í',$_POST['check']));
 ?

 form action=./index.php method=post
 input type=text name=check
 input type=submit name=go 
 /form
 /body/html

 the name of the file is index.php and i am typing í in the text box before
 pressing submit.the result is not coming as zero but -1.The result is not
 coming for any of spanish or special characters like ¿,ñ,ü how to solve it
 that echo answer is zero.

 I have searched a lot on net and finally i am coming here to get some help.
 --
 View this message in context: 
 http://www.nabble.com/php-spanish-character-problem-tp15185959p15185959.html
 Sent from the PHP - General mailing list archive at Nabble.com.

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



Read up on character encodings.


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

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 11:58 AM, Stut [EMAIL PROTECTED] wrote:

 Ok, I'm going to have to assume you really are as stupid as you seem. If
 I need to provide an example to demonstrate what I meant I will, but I
 feel I made it quite clear that my comment regarding what *I* would do
 did not in any way relate to the code example I had provided above. The
 example I provided was fulfilling the OP's requirements.

 This is what *I* would do...

 ?php
 class Test {
 public static 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.

 //  See this comment here, this was taken from the
 // non-static method in the example I posted. This is what
 // I meant when I say just use a static method.
 }
 }
 Test::doSomething();
 ?

 Look ma, no instance.


well, at least its clear now, what you meant.


 FYI I'm not at all new to OOP, in general or in PHP, so I am well aware
 that the example I originally posted created an instance of the class.


glad to hear it; no hard feelings i hope..

-nathan


Re: [PHP] first php 5 class

2008-01-30 Thread Eric Butera
On Jan 30, 2008 11:13 AM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 i dont think Registry::getInstance() is really that much overhead;

In my initial tests I found that static methods accessing $GLOBALS
directly was much faster than using an instance and working on it
tucked away in a static variable.  The getInstance() to pull and check
against the existence of the instance and creating it really added a
lot of extra code execution.

I use the intercept filter pattern on my code execution so that I can
set up different filters for authentication, authorization, gzip
output buffering, session management, etc based on my page needs.  I
then wrap that around a front controller.  So the registry has been
key in being able to push and pull data from many different scopes.
Then again sometimes I just use include files like the php patterns
site recommended[1].

Up until the start of this year my company was stuck in PHP4 since in
the real world clients don't want their sites to break because people
want the latest and greatest.  :)  A big reason I've had to dig around
is because I want to use the best ideas yet be able to run them on 4.
Now that we have 5 running everywhere it might be an option to
re-visit and use a fluent interface to do something like:

registry::getInstance()-get('foo');

I'd store the getInstance() instance in some sort of protected self::
accessed property and return if it exists or not.  Maybe when I get
some free time I'll do a benchmark to see how nasty that is versus
just using static methods.

PDT hasn't ever crashed on me, but now that I've typed that... ;D

[1] http://www.phppatterns.com/docs/design/the_front_controller_and_php

-- 
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 Jim Lucas

Stut wrote:

Nathan Nobbe wrote:
On Jan 30, 2008 11:31 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:



I would *just* use a static method

*just* *just* *just* *just* *just* *just* *just* *just* *just*

No instance. None. Grrr.


here is a mod of the code you posted w/ a var_dump() of the
local variable $o;

?php
class Test {
public static function doSomething() {
$o = new Test();
var_dump($o);
$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();
?

[EMAIL PROTECTED] ~/ticketsDbCode $ php testCode.php
object(Test)#1 (0) {
}


clearly in the act of *just* using a static method, you *just*
created an instance of class Test ;)


Ok, I'm going to have to assume you really are as stupid as you seem. If 
I need to provide an example to demonstrate what I meant I will, but I 
feel I made it quite clear that my comment regarding what *I* would do 
did not in any way relate to the code example I had provided above. The 
example I provided was fulfilling the OP's requirements.


This is what *I* would do...

?php
class Test {
public static 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.

//  See this comment here, this was taken from the
// non-static method in the example I posted. This is what
// I meant when I say just use a static method.
}
}
Test::doSomething();
?

Look ma, no instance.


Now this is clear.


But to point out in the code I quoted, you said that you were going to only use 
the static method, but you were calling the static method that created an 
instance of the Test class and then calling the non-static method from the 
instance of the Test class.


Your previous example was not showing us what you were saying.  To me it looked 
like you were confused about how you were calling/creating things.


--
Jim Lucas

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

Twelfth Night, Act II, Scene V
by William Shakespeare

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



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

2008-01-30 Thread Stut

Nathan Nobbe wrote:
On Jan 30, 2008 11:58 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Ok, I'm going to have to assume you really are as stupid as you seem. If
I need to provide an example to demonstrate what I meant I will, but I
feel I made it quite clear that my comment regarding what *I* would do
did not in any way relate to the code example I had provided above. The
example I provided was fulfilling the OP's requirements.

This is what *I* would do...

?php
class Test {
public static 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.

//  See this comment here, this was taken from the
// non-static method in the example I posted. This is what
// I meant when I say just use a static method.
}
}
Test::doSomething();
?

Look ma, no instance.


well, at least its clear now, what you meant.
 


FYI I'm not at all new to OOP, in general or in PHP, so I am well aware
that the example I originally posted created an instance of the class.


glad to hear it; no hard feelings i hope..


Indeed. Now, the place where you sleep... is it guarded?

;)

-Stut

--
http://stut.net/

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

 Indeed. Now, the place where you sleep... is it guarded?


well it is, but..
i probly misunderstood some implication in the directions of
my virtual fortress and therefore, probly not as well a i suspect ;)

-nathan


Re: [PHP] first php 5 class

2008-01-30 Thread Greg Donald
On Jan 30, 2008 10:43 AM, Nathan Nobbe [EMAIL PROTECTED] wrote:
  I would assume it's because there are much more interesting advances
  in web development technology to focus on elsewhere.

 such as ?

Ruby 1.9, Ruby on Rails 2, Perl6/Parrot.

Parrot is particularly interesting, especially if your into
meta-languages or language creation in general.

http://destiney.com/blog/play-with-perl6-mac-os-x-leopard


-- 
Greg Donald
http://destiney.com/

-- 
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 Zoltán Németh
2008. 01. 30, szerda keltezéssel 11.45-kor Greg Donald ezt írta:
 On Jan 30, 2008 10:43 AM, Nathan Nobbe [EMAIL PROTECTED] wrote:
   I would assume it's because there are much more interesting advances
   in web development technology to focus on elsewhere.
 
  such as ?
 
 Ruby 1.9, Ruby on Rails 2, Perl6/Parrot.

oh the Ruby and Rails stuff here it comes again... I really don't see
why is it a 'more interesting advance in web development technology'...
and what's more important for me, I really don't like it ;)

as for the new perl, it might worth a look, but I'm almost sure that it
won't replace PHP in what I am doing...

greets
Zoltán Németh

 
 Parrot is particularly interesting, especially if your into
 meta-languages or language creation in general.
 
 http://destiney.com/blog/play-with-perl6-mac-os-x-leopard
 
 
 -- 
 Greg Donald
 http://destiney.com/
 

-- 
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 Nathan Nobbe
On Jan 30, 2008 12:45 PM, Greg Donald [EMAIL PROTECTED] wrote:

 On Jan 30, 2008 10:43 AM, Nathan Nobbe [EMAIL PROTECTED] wrote:
   I would assume it's because there are much more interesting advances
   in web development technology to focus on elsewhere.
 
  such as ?

 Ruby 1.9, Ruby on Rails 2, Perl6/Parrot.


i love how the ruby crew has 1 framework, whereas php has scads.
php affords the power of choice.
and last time i checked, php was a lot faster:
http://shootout.alioth.debian.org/gp4/benchmark.php?test=alllang=all


 Parrot is particularly interesting, especially if your into
 meta-languages or language creation in general.

 http://destiney.com/blog/play-with-perl6-mac-os-x-leopard


parot does look interesting; but this is drifting from a particular web
technology.
there are many systems out there using the jvm to drop scripting languages
on
top, such as ibm project0, to name one; but i dont see these projects really
catching on.

also, if you want to see some code generation, php-style, check out propel
;)

-nathan


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

2008-01-30 Thread Stut

Jim Lucas wrote:

Stut wrote:

Nathan Nobbe wrote:
On Jan 30, 2008 11:31 AM, Stut [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:



I would *just* use a static method

*just* *just* *just* *just* *just* *just* *just* *just* *just*

No instance. None. Grrr.


here is a mod of the code you posted w/ a var_dump() of the
local variable $o;

?php
class Test {
public static function doSomething() {
$o = new Test();
var_dump($o);
$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();
?

[EMAIL PROTECTED] ~/ticketsDbCode $ php testCode.php
object(Test)#1 (0) {
}


clearly in the act of *just* using a static method, you *just*
created an instance of class Test ;)


Ok, I'm going to have to assume you really are as stupid as you seem. 
If I need to provide an example to demonstrate what I meant I will, 
but I feel I made it quite clear that my comment regarding what *I* 
would do did not in any way relate to the code example I had provided 
above. The example I provided was fulfilling the OP's requirements.


This is what *I* would do...

?php
class Test {
public static 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.

//  See this comment here, this was taken from the
// non-static method in the example I posted. This is what
// I meant when I say just use a static method.
}
}
Test::doSomething();
?

Look ma, no instance.


Now this is clear.


Glad to hear it.

But to point out in the code I quoted, you said that you were going to 
only use the static method, but you were calling the static method that 
created an instance of the Test class and then calling the non-static 
method from the instance of the Test class.


I thought the comment in that static method explained that I didn't see 
the point in creating the instance. I thought it was pretty clear, but 
clearly not.


Your previous example was not showing us what you were saying.  To me it 
looked like you were confused about how you were calling/creating things.


I was never confused! ;)

-Stut

--
http://stut.net/

--
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 Greg Donald
On Jan 30, 2008 11:52 AM, Zoltán Németh [EMAIL PROTECTED] wrote:
 oh the Ruby and Rails stuff here it comes again... I really don't see
 why is it a 'more interesting advance in web development technology'...
 and what's more important for me, I really don't like it ;)

It's opinionated software and is certainly not for everyone.


-- 
Greg Donald
http://destiney.com/

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



[PHP] Help looking for inventory software

2008-01-30 Thread Zbigniew Szalbot
Hello,

I am sorry if this is appropriate but does anyone know php based, open
source solution that would enable me to put a system handling
inventory (books, booklets). I work for a charity and we are archiving
our old products by making a digital archive. So far we have been
doing it in Excel but I would really like to move it to a relational
database (like mysql).

Have been googling around for solution but without much luck. Anyway,
it does not have to be an inventory project. Even a modular system
that would allow me to design and generate php files, would be really,
really helpful.

Sorry if this is wrong group to be asking such a question.

Thank you in advance for any pointers!

Zbigniew Szalbot

-- 
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 Zoltán Németh
2008. 01. 30, szerda keltezéssel 12.03-kor Greg Donald ezt írta:
 On Jan 30, 2008 11:52 AM, Zoltán Németh [EMAIL PROTECTED] wrote:
  oh the Ruby and Rails stuff here it comes again... I really don't see
  why is it a 'more interesting advance in web development technology'...
  and what's more important for me, I really don't like it ;)
 
 It's opinionated software and is certainly not for everyone.

ok it's not for everyone, certainly not for me. but what is it from your
point of view that makes it a 'more interesting advance'?

greets
Zoltán Németh

 
 
 -- 
 Greg Donald
 http://destiney.com/
 

-- 
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 Greg Donald
On Jan 30, 2008 11:56 AM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 i love how the ruby crew has 1 framework, whereas php has scads.

Ruby has 7 frameworks that I know of: Nitro, IOWA, Ramaze, Cerise,
Ruby on Rails, Merb and Camping.

http://www.nitroproject.org/
http://enigo.com/projects/iowa/
http://ramaze.net/
http://cerise.rubyforge.org/
http://www.rubyonrails.org/
http://www.merbivore.com/
http://code.whytheluckystiff.net/camping

The most popular PHP frameworks are Rails clones it seems.  Zend's
best effort at a framework is an almost direct copy of the Mojavi
framework.

Further, if the number frameworks a language has is any measure of
that's language's quality or capabilities (clue: it isn't) then why
aren't you a Java guy?  It clearly has _more_ frameworks.

  php affords the power of choice.
 and last time i checked, php was a lot faster:

 http://shootout.alioth.debian.org/gp4/benchmark.php?test=alllang=all

That benchmark doesn't include Ruby 1.9.

 also, if you want to see some code generation, php-style, check out propel

Propel still uses XML last I messed with it.  Yaml is a lot better for
similar tasks.  The syntax is a lot smaller which makes it a lot
faster than XML.  Perfect example of an advance in web technology.


-- 
Greg Donald
http://destiney.com/

-- 
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 Greg Donald
On Jan 30, 2008 12:15 PM, Zoltán Németh [EMAIL PROTECTED] wrote:
  It's opinionated software and is certainly not for everyone.

 ok it's not for everyone, certainly not for me. but what is it from your
 point of view that makes it a 'more interesting advance'?

1) Test driven development is built-in, and not just unit tests, but
functional tests and integration tests too.  In addition there's
several plugins that extend your tests into realms you may not have
thought of.  There's Rcov which will tell you what code you haven't
written test for.  I know, you don't write tests.  It's perfectly
natural to not write tests when your framework doesn't support them
out of the box.

2) Prototype and script.aculo.us are built-in.  Not just included in
the download but fully integrated into the models.

Symphony tried to pull off the same thing with it's framework but it's
fairly messy in my opinion.

update_element_function('foo', array(
  'content'  = New HTML,
));

Compared to the Rails equivalent:

page.replace_html 'foo', :html = 'New HTML'

The other Javascript helpers like observers for example are similarly
very small.

3) Database migrations that allow for versioned SQL.  I can roll out
new sql or roll back my broken sql with a single command.

rake db:migrate VERISON=42

I can rebuild my entire database from scratch:

rake db:migrate VERISON=0; rake db:migrate

The migrations are Ruby code that are very tight in syntax:

class CreateSessions  ActiveRecord::Migration

  def self.up
create_table :sessions do |t|
  t.string :session_id, :null = false
  t.datetime :updated_at, :null = false
  t.text :data
end
add_index :sessions, :session_id
add_index :sessions, :updated_at
  end

  def self.down
drop_table :sessions
  end

end

4) Capistrano which is fully integrated with Subversion (and soon Git
I heard) allows me to roll out a versioned copy of my application with
a single command:

cap deploy

And then I can also rollback just as easily in case of an error:

cap rollback

5) Ruby on Rails has a built-in plugin architecture for adding vendor
code.  I can add new functionality to my app as easy as

gem install acts_as_taggable

or

gem install pagination

It's a bit like Perl's CPAN if you're familiar.

There are also plugins, engines, and components depending on the level
of integration you want the vendor code to have.

6) Model validations extend into the view.  No re-mapping of variables
like with Smarty or some others I've tried.

7) The REST architecture is built-in to Rails.  No more SOAP, unless
you want it of course.  No one's using it but it's there.



-- 
Greg Donald
http://destiney.com/

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



RE: [PHP] Help looking for inventory software

2008-01-30 Thread Bastien Koert

check for code / systems on
 
www.hotscripts.com
http://sourceforge.net
 
hth
 
bastien Date: Wed, 30 Jan 2008 19:14:57 +0100 From: [EMAIL PROTECTED] To: 
php-general@lists.php.net Subject: [PHP] Help looking for inventory software 
 Hello,  I am sorry if this is appropriate but does anyone know php based, 
open source solution that would enable me to put a system handling inventory 
(books, booklets). I work for a charity and we are archiving our old products 
by making a digital archive. So far we have been doing it in Excel but I would 
really like to move it to a relational database (like mysql).  Have been 
googling around for solution but without much luck. Anyway, it does not have 
to be an inventory project. Even a modular system that would allow me to 
design and generate php files, would be really, really helpful.  Sorry if 
this is wrong group to be asking such a question.  Thank you in advance for 
any pointers!  Zbigniew Szalbot  --  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 Nathan Nobbe
On Jan 30, 2008 1:29 PM, Greg Donald [EMAIL PROTECTED] wrote:
 Ruby has 7 frameworks that I know of: Nitro, IOWA, Ramaze, Cerise,
 Ruby on Rails, Merb and Camping.
 http://www.nitroproject.org/
 http://enigo.com/projects/iowa/
 http://ramaze.net/
 http://cerise.rubyforge.org/
 http://www.rubyonrails.org/
 http://www.merbivore.com/
 http://code.whytheluckystiff.net/camping

good for ruby, rails is the only one people ever mention.

 The most popular PHP frameworks are Rails clones it seems.
im no framework expert, but last time i checked one of the first guys
on the block was, struts, way back in the day.  and most frameworks
for the web are based on mvc, a concept from decades ago, not something
the ruby guys cooked up.

  Further, if the number frameworks a language has is any measure of
 that's language's quality or capabilities (clue: it isn't) then why
 aren't you a Java guy?

java is awesome, it just hasnt worked out for me career wise.

  It clearly has _more_ frameworks.

just pointing out that the rails guys dont have much wiggle room.
surely, youre familiar w/ this post:
http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back_to_p_1.html

 Propel still uses XML last I messed with it.  Yaml is a lot better for
 similar tasks.  The syntax is a lot smaller which makes it a lot
 faster than XML.
well lets see, it only reads the xml when the code is generated, which is not
that often so any slowness of xml is not valid.  and last time i generated code
in my project it took like under 5 seconds; boy that xml sure was painful =/

Perfect example of an advance in web technology.
perfect example of something that doesnt make much difference.

-nathan

-- 
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 Greg Donald
On Jan 30, 2008 12:40 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 just pointing out that the rails guys dont have much wiggle room.
 surely, youre familiar w/ this post:
 http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back_to_p_1.html

One article from one developer means what exaclty?  Perhaps he wasn't
writing enough lines of code per day to be stay happy using Rails?

  Propel still uses XML last I messed with it.  Yaml is a lot better for
  similar tasks.  The syntax is a lot smaller which makes it a lot
  faster than XML.
 well lets see, it only reads the xml when the code is generated, which is not
 that often so any slowness of xml is not valid.  and last time i generated 
 code
 in my project it took like under 5 seconds; boy that xml sure was painful =/

Well if all you do is toy projects then XML is fine.

user id=babooey on=cpu1
  firstnameBob/firstname
  lastnameAbooey/lastname
  departmentadv/department
  cell555-1212/cell
  address password=[EMAIL PROTECTED]/address
  address password=[EMAIL PROTECTED]/address
/user

versus the Yaml equivalent:

babooey:
  computer: cpu1
  firstname: Bob
  lastname: Abooey
  cell: 555-1212
  addresses:
- address: [EMAIL PROTECTED]
  password: 
- address: [EMAIL PROTECTED]
  password: 


 Perfect example of an advance in web technology.
 perfect example of something that doesnt make much difference.

The time saved writing Yaml instead of XML makes a huge difference to
me.  Similar savings are to be had when comparing PHP to most anything
except Java.


-- 
Greg Donald
http://destiney.com/

-- 
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 Nathan Nobbe
On Jan 30, 2008 2:38 PM, Greg Donald [EMAIL PROTECTED] wrote:
 If you like Java then stick with PHP as that's where the syntax is
 clearly headed:

 http://www.php.net/~helly/php/ext/spl/

ive been studying spl a lot recently.  actually, last night
i was benching it against foreach over standard arrays.
the results were staggering, spl is roughly twice as fast.
and if you iterate over the same structure more than once,
say ArrayIterator, vs. multiple times iterating over a regular
array w/ the foreach or while construct, the savings only
compound!
when you said earlier that people arent interested in learning
php, this is something i immediately thought of.  primarily
because spl debuted in php 5.0 and practically nobody is
using it (which could just be my skewed perception) when it
is extremely powerful.

-nathan

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


--
Greg Donald
http://destiney.com/

-- 
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 Nathan Nobbe
On Jan 30, 2008 2:33 PM, Greg Donald [EMAIL PROTECTED] wrote:
 On Jan 30, 2008 12:40 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:
  just pointing out that the rails guys dont have much wiggle room.
  surely, youre familiar w/ this post:
  http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back_to_p_1.html

 One article from one developer means what exaclty?  Perhaps he wasn't
 writing enough lines of code per day to be stay happy using Rails?

   Propel still uses XML last I messed with it.  Yaml is a lot better for
   similar tasks.  The syntax is a lot smaller which makes it a lot
   faster than XML.
  well lets see, it only reads the xml when the code is generated, which is 
  not
  that often so any slowness of xml is not valid.  and last time i generated 
  code
  in my project it took like under 5 seconds; boy that xml sure was painful =/

 Well if all you do is toy projects then XML is fine.

 user id=babooey on=cpu1
   firstnameBob/firstname
   lastnameAbooey/lastname
   departmentadv/department
   cell555-1212/cell
   address password=[EMAIL PROTECTED]/address
   address password=[EMAIL PROTECTED]/address
 /user

 versus the Yaml equivalent:

 babooey:
   computer: cpu1
   firstname: Bob
   lastname: Abooey
   cell: 555-1212
   addresses:
 - address: [EMAIL PROTECTED]
   password: 
 - address: [EMAIL PROTECTED]
   password: 


  Perfect example of an advance in web technology.
  perfect example of something that doesnt make much difference.

 The time saved writing Yaml instead of XML makes a huge difference to
 me.  Similar savings are to be had when comparing PHP to most anything
 except Java.

i will concede that typing out the initial schema for my project was cumbersome.
however, once an initial schema is in place, its really not a hassle
add a table or
tweak the existing schema.
if  you were going to make a point that would have really hit, you
should have said
that propel doesnt support automatic generation of xml based on an existing db
schema.  qcodo does this, but then again, qcodo is a complete package, whereas
propel is strictly an orm layer. which is what i mostly prefer,
blending technologies
to suit my needs.  so the real drawback id charge propel w/ atm. is
the overhead for
an existing schema; say you have 100 tables, more even..  now that would be a
real pain to build the schema.xml file for.  of course you can always
use it as an
excuse to scrub the cruft off your database schema, right ? ;)

-nathan

-- 
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 Greg Donald
On Jan 30, 2008 12:40 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 java is awesome, it just hasnt worked out for me career wise.

If you like Java then stick with PHP as that's where the syntax is
clearly headed:

http://www.php.net/~helly/php/ext/spl/


-- 
Greg Donald
http://destiney.com/

-- 
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 Eric Butera
On Jan 30, 2008 2:01 PM, Greg Donald [EMAIL PROTECTED] wrote:
 On Jan 30, 2008 12:15 PM, Zoltán Németh [EMAIL PROTECTED] wrote:
   It's opinionated software and is certainly not for everyone.
 
  ok it's not for everyone, certainly not for me. but what is it from your
  point of view that makes it a 'more interesting advance'?

 1) Test driven development is built-in, and not just unit tests, but
 functional tests and integration tests too.  In addition there's
 several plugins that extend your tests into realms you may not have
 thought of.  There's Rcov which will tell you what code you haven't
 written test for.  I know, you don't write tests.  It's perfectly
 natural to not write tests when your framework doesn't support them
 out of the box.

 2) Prototype and script.aculo.us are built-in.  Not just included in
 the download but fully integrated into the models.

 Symphony tried to pull off the same thing with it's framework but it's
 fairly messy in my opinion.

 update_element_function('foo', array(
   'content'  = New HTML,
 ));

 Compared to the Rails equivalent:

 page.replace_html 'foo', :html = 'New HTML'

 The other Javascript helpers like observers for example are similarly
 very small.

 3) Database migrations that allow for versioned SQL.  I can roll out
 new sql or roll back my broken sql with a single command.

 rake db:migrate VERISON=42

 I can rebuild my entire database from scratch:

 rake db:migrate VERISON=0; rake db:migrate

 The migrations are Ruby code that are very tight in syntax:

 class CreateSessions  ActiveRecord::Migration

   def self.up
 create_table :sessions do |t|
   t.string :session_id, :null = false
   t.datetime :updated_at, :null = false
   t.text :data
 end
 add_index :sessions, :session_id
 add_index :sessions, :updated_at
   end

   def self.down
 drop_table :sessions
   end

 end

 4) Capistrano which is fully integrated with Subversion (and soon Git
 I heard) allows me to roll out a versioned copy of my application with
 a single command:

 cap deploy

 And then I can also rollback just as easily in case of an error:

 cap rollback

 5) Ruby on Rails has a built-in plugin architecture for adding vendor
 code.  I can add new functionality to my app as easy as

 gem install acts_as_taggable

 or

 gem install pagination

 It's a bit like Perl's CPAN if you're familiar.

 There are also plugins, engines, and components depending on the level
 of integration you want the vendor code to have.

 6) Model validations extend into the view.  No re-mapping of variables
 like with Smarty or some others I've tried.

 7) The REST architecture is built-in to Rails.  No more SOAP, unless
 you want it of course.  No one's using it but it's there.




 --
 Greg Donald
 http://destiney.com/

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



Thanks for your post.  Competition is a good thing.

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

Making applications spit out Js just seems like a bad idea.  I haven't
seen the way it works, but it seems like you'd have a lack of
flexibility.  If I want to use JS I just symlink whatever copy of YUI
I want into a directory on my server and start using it.

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.


Re: [PHP] first php 5 class

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 2:55 PM, Greg Donald [EMAIL PROTECTED] wrote:
 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.

how exactly do you test an xhr request?
my suspicion is that you would just set data in superglobal
arrays, eg.
$_POST['somevar'] = ' blah';

i dont really see what the difference between an xhr request
and a non-xhr request is in the context of a unit test.
its still http..

-nathan

-- 
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 Greg Donald
On 1/30/08, Nathan Nobbe [EMAIL PROTECTED] wrote:
 On Jan 30, 2008 2:38 PM, Greg Donald [EMAIL PROTECTED] wrote:
  If you like Java then stick with PHP as that's where the syntax is
  clearly headed:
 
  http://www.php.net/~helly/php/ext/spl/

 ive been studying spl a lot recently.  actually, last night
 i was benching it against foreach over standard arrays.
 the results were staggering, spl is roughly twice as fast.
 and if you iterate over the same structure more than once,
 say ArrayIterator, vs. multiple times iterating over a regular
 array w/ the foreach or while construct, the savings only
 compound!
 when you said earlier that people arent interested in learning
 php, this is something i immediately thought of.  primarily
 because spl debuted in php 5.0 and practically nobody is
 using it (which could just be my skewed perception) when it
 is extremely powerful.

I think your perception is correct.  But Perl is very powerful too,
and not so many people use it for new web development either.. with
list serve traffic being my reference.

SPL's main drawback for me personally is carpal tunnel syndrome, I
don't have it and I don't care to acquire it.


-- 
Greg Donald
http://destiney.com/

-- 
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 Greg Donald
On 1/30/08, Nathan Nobbe [EMAIL PROTECTED] wrote:
 On Jan 30, 2008 2:55 PM, Greg Donald [EMAIL PROTECTED] wrote:
  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.

 how exactly do you test an xhr request?
 my suspicion is that you would just set data in superglobal
 arrays, eg.
 $_POST['somevar'] = ' blah';

 i dont really see what the difference between an xhr request
 and a non-xhr request is in the context of a unit test.
 its still http..

A unit test, in it's most general sense, has nothing to do with http
specifically, it's just model/data validation for small units of code.
 It's answers the question Does my model read and write records to
and from the database correctly?.  It won't catch integration errors,
performance problems, or other system-wide issues not local to the
unit being tested.

An xhr request needs to be tested to see if your javascript fired when
expected and equally important what was sent back, and did what was
sent back land in the DOM where you expected it to.  Rails provides
that and much more.


-- 
Greg Donald
http://destiney.com/

-- 
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 Nathan Nobbe
On Jan 30, 2008 3:11 PM, Greg Donald [EMAIL PROTECTED] wrote:
 I think your perception is correct.  But Perl is very powerful too,
 and not so many people use it for new web development either.. with
 list serve traffic being my reference.

 SPL's main drawback for me personally is carpal tunnel syndrome, I
 don't have it and I don't care to acquire it.

i sortof enjoy having php on the backend and javascript on the client side.
it lets be bounce around between paradigms.  as per the ruby / prototype
integration, i will say, that is one nice component, that i actually use all
the time now.  infact, im on the rails-spinoffs mailing list where we discuss
prototype.
i read a book, 'prototype and scriptaculous in action'; learned a ton of course.
nowadays, my webapps have the web 2.0 buzz.  but as far as the generation
of javascript on the server side, i still have mixed feelings.  the case made by
rhino is, your favorite java editor, your current java debugger and
you dont have
to learn another language.  well, i suppose the case is somewhat similar for the
rails / prototype integration.
javascript is actually quite a complex language and its funny because
people will
always say things like, its such a nice 'little' language.  if youre
not familiar w/
functional languages w/ closures and so forth, anonymous objects and
functions, etc..
javascript can be really confusing!  i would extend this as a good
reason to understand
the language.  but what a hippocrate i am, since im using propel to
get away from
sql :)  to each his own, indeed.

what id like to know, since you seem to know so much about the ruby on
rails framework,
is, what sort of debugging support is there?  this is a weak spot in
php to be sure.  ive
tried multiple clients w/ xdebug w/ marginal success at this point.

-nathan

-- 
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 Nathan Nobbe
On Jan 30, 2008 3:22 PM, Greg Donald [EMAIL PROTECTED] wrote:
 An xhr request needs to be tested to see if your javascript fired when
 expected and equally important what was sent back, and did what was
 sent back land in the DOM where you expected it to.  Rails provides
 that and much more.

ill admit the prospect of doing that programmattically is enticing.
scriptaculous has a unit testing framework, one class really, that i
intend to look into.
btw. i cooked up an abbreviated spl for you ;)

?php
class RII extends RecursiveIteratorIterator {}
class RAI extends RecursiveArrayIterator {}

$testData = array('a', 'b', 'c',
array('d', 'e', 'f',
array('g', 'h', 'i')));

foreach(new RII(new RAI($testData)) as $key = $val) {
echo $key = $val . PHP_EOL;
}
?


-nathan

-- 
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 Nathan Nobbe
On Jan 30, 2008 3:34 PM, Greg Donald [EMAIL PROTECTED] wrote:
 On 1/30/08, Nathan Nobbe [EMAIL PROTECTED] wrote:
  what id like to know, since you seem to know so much about the ruby on
  rails framework,
  is, what sort of debugging support is there?  this is a weak spot in
  php to be sure.  ive
  tried multiple clients w/ xdebug w/ marginal success at this point.

 Rails has support for ruby-debug built-in.

 `gem install ruby-debug` to install it.

 You would then add 'debugger' or 'breakpoint' into the code in
 question.  When execution hits that point your (development) server
 drops into an IRB session where you would find your entire Rails
 environment at your fingertips.  You can interrogate the get/post data
 or perform a database query.  Whatever you can do in code you can do
 in irb in real-time, zero limitations.

 Ruby's IRB itself is a lot of fun even when not debugging:

  irb
  'ruby'  'php'
 = true

 It's like having a shell built directly into the language.

php has an interactive shell; php -a.
therein you have access to anything in the language your
include path, or the local disc.
however, ive never heard of an extension whereby the debugger
drops you into a 'php -a' session.
and btw.  php does have pecl and pear, these are both modular
systems where functional components can be easily installed or
upgraded on any given system, despite the underlying os, with
little effort.

-nathan

-- 
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 Nathan Nobbe
On Jan 30, 2008 4:08 PM, Greg Donald [EMAIL PROTECTED] wrote:
 On 1/30/08, Nathan Nobbe [EMAIL PROTECTED] wrote:
  php has an interactive shell; php -a.
  therein you have access to anything in the language your
  include path, or the local disc.

 You obviously have a very different understanding of the word
interactive.

 `php -a` seems pretty broken to me:

  php -a
 Interactive mode enabled

 sprintf( '%f^[[3~^[[3~

 My backspace doesn't work.  Ctrl-C to start over.  I'm guessing I
 would lose any local variables at this point?

  php -a
 Interactive mode enabled

 echo 'foo';

 So where's the output?


  php -a
 Interactive mode enabled

 ^[[A

 Aww..  no up-arrow history either?

 `php -a` doesn't work very well from where I sit.

php  $rf = new ReflectionClass('Iterator');
php  echo $rf;
Interface [ internal interface Iterator implements Traversable ] {

 - Constants [0] {
 }

 - Static properties [0] {
 }

 - Static methods [0] {
 }

 - Properties [0] {
 }

 - Methods [5] {
   Method [ internal abstract public method current ] {
   }

   Method [ internal abstract public method next ] {
   }

   Method [ internal abstract public method key ] {
   }

   Method [ internal abstract public method valid ] {
   }

   Method [ internal abstract public method rewind ] {
   }
 }
}

up arrow works just fine.  history is gone if it crashes, but
if you exit gracefully, eg. with quit, then the history will be there.
maybe youre using debian or some other silly os; i run gentoo
and there is no prob w/ php -a.  although i wont lie; it seems to
be jacked on all the debian systems ive tried :(

 And since you can't see it I will also mention that IRB has beautiful
 syntax highlighting.

nice

 Every time I ever went to the PEAR site I played a game of 'how many
 times do I have to click before I dig down deep enough to realize the
 docs aren't really there'.
thats cause a lot of them are on the php site itself.  again, ill admit, the
docs are scattered, but they are there:
http://us2.php.net/manual/en/ref.apc.php
http://us2.php.net/manual/en/ref.apd.php

 Meanwhile every gem you install with Ruby has an rdoc package with
 complete api docs for the gem.  You just fire up your local `gem
 server` and browse to http://localhost:8808/ to view complete api
 docs, offline or on.

you can host the php docs on a local webserver if you like, or download
them; there is even a chm version:
http://us2.php.net/docs-echm.php

-nathan


Re: [PHP] first php 5 class

2008-01-30 Thread Greg Donald
On 1/30/08, Nathan Nobbe [EMAIL PROTECTED] wrote:
 what id like to know, since you seem to know so much about the ruby on
 rails framework,
 is, what sort of debugging support is there?  this is a weak spot in
 php to be sure.  ive
 tried multiple clients w/ xdebug w/ marginal success at this point.

Rails has support for ruby-debug built-in.

`gem install ruby-debug` to install it.

You would then add 'debugger' or 'breakpoint' into the code in
question.  When execution hits that point your (development) server
drops into an IRB session where you would find your entire Rails
environment at your fingertips.  You can interrogate the get/post data
or perform a database query.  Whatever you can do in code you can do
in irb in real-time, zero limitations.

Ruby's IRB itself is a lot of fun even when not debugging:

 irb
 'ruby'  'php'
= true

It's like having a shell built directly into the language.


-- 
Greg Donald
http://destiney.com/

-- 
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 Greg Donald
On 1/30/08, Nathan Nobbe [EMAIL PROTECTED] wrote:
 php has an interactive shell; php -a.
 therein you have access to anything in the language your
 include path, or the local disc.

You obviously have a very different understanding of the word interactive.

`php -a` seems pretty broken to me:

 php -a
Interactive mode enabled

sprintf( '%f^[[3~^[[3~

My backspace doesn't work.  Ctrl-C to start over.  I'm guessing I
would lose any local variables at this point?

 php -a
Interactive mode enabled

echo 'foo';

So where's the output?


 php -a
Interactive mode enabled

^[[A

Aww..  no up-arrow history either?

`php -a` doesn't work very well from where I sit.


IRB actually works:

 irb
 [].class
= Array
 [].methods.sort
= [, *, +, -, , =, ==, ===, =~, [], []=,
__id__, __send__, all?, any?, assoc, at, class, clear,
clone, collect, collect!, compact, compact!, concat,
delete, delete_at, delete_if, detect, display, dup,
each, each_index, each_with_index, empty?, entries, eql?,
equal?, extend, fetch, fill, find, find_all, first,
flatten, flatten!, freeze, frozen?, gem, grep, hash,
id, include?, index, indexes, indices, inject, insert,
inspect, instance_eval, instance_of?,
instance_variable_defined?, instance_variable_get,
instance_variable_set, instance_variables, is_a?, join,
kind_of?, last, length, map, map!, max, member?,
method, methods, min, nil?, nitems, object_id, pack,
partition, po, poc, pop, pretty_inspect, pretty_print,
pretty_print_cycle, pretty_print_inspect,
pretty_print_instance_variables, private_methods,
protected_methods, public_methods, push, rassoc, reject,
reject!, replace, require, respond_to?, reverse, reverse!,
reverse_each, ri, rindex, select, send, shift,
singleton_methods, size, slice, slice!, sort, sort!,
sort_by, taint, tainted?, to_a, to_ary, to_s, transpose,
type, uniq, uniq!, unshift, untaint, values_at, zip,
|]


And since you can't see it I will also mention that IRB has beautiful
syntax highlighting.


 however, ive never heard of an extension whereby the debugger
 drops you into a 'php -a' session.

 and btw.  php does have pecl and pear, these are both modular

Every time I ever went to the PEAR site I played a game of 'how many
times do I have to click before I dig down deep enough to realize the
docs aren't really there'.

Meanwhile every gem you install with Ruby has an rdoc package with
complete api docs for the gem.  You just fire up your local `gem
server` and browse to http://localhost:8808/ to view complete api
docs, offline or on.


-- 
Greg Donald
http://destiney.com/

-- 
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 Greg Donald
On 1/30/08, Nathan Nobbe [EMAIL PROTECTED] wrote:
 up arrow works just fine.  history is gone if it crashes, but
  if you exit gracefully, eg. with quit, then the history will be there.
 maybe youre using debian or some other silly os; i run gentoo

Gentoo is a damn fun distro I must admit.. but using it for anything
besides a development server seems very risky to me.  You've got the
Gentoo creat0r running off to lick salt with the M$ weiners up in WA
right when Gentoo was peaking in popularity.  In less than a year he
realizes his mistake and comes back crying wanting to control stuff
again as if he had never left.  Then just recently the Gentoo
leadership forgot to renew the non-profit tax status paperwork!?!?
With all that spare time waiting for things to compile I figured they
wouldn't have forgotten about such an important task.  Do they not
having meetings or whatever?

And where's my 2007.1 release?  At the start we were getting a new
Gentoo release four times a year.  Then it went to two, then last year
was just one.  Contrary to what you may think, `emerge -uND` is not an
upgrade path, at least not for a serious server deployment.  The
bottom line is emerge breaks things, and the older the Gentoo install,
the more likely the breakage will occur.

Why do I even have to deal with etc-update?  Who has time for all that
silliness?  Obviously you and not me, but that's life.  Sooner or
later you too will get tired of cleaning up behind emerge.  Took me
like two years I guess.  I like my Linux stable, and Gentoo is not
stable, especially not right now.

 and there is no prob w/ php -a.  although i wont lie; it seems to
 be jacked on all the debian systems ive tried :(

I compiled my PHP from source so the jacking may be of my own doing, I
don't know.  See anything in my config that might prevent it from
working?

/configure --prefix=/usr/local/php5
--with-config-file-path=/usr/local/php5/lib
--with-apxs2=/usr/local/apache2/bin/apxs --with-gettext --with-gd
--with-jpeg-dir --with-png-dir --with-freetype-dir --with-xpm-dir
--with-mcrypt --with-mhash --with-curl --enable-mbstring --with-zlib
--enable-ftp --enable-sockets --enable-bcmath --with-bz2 --enable-zip
--with-mysql --without-iconv
--with-oci8=instantclient,/opt/oracle/instantclient_10_2
--with-pdo-oci=instantclient,/opt/oracle/instantclient_10_2,10.2
--with-pdo-mysql --with-pdo-pgsql --with-pgsql --with-ldap
--with-openssl --with-ldap-sasl

 you can host the php docs on a local webserver if you like, or download
 them; there is even a chm version:

 http://us2.php.net/docs-echm.php

Right, but it's not integrated like gems are.  When you install a gem
the docs are created by rdoc for you on the fly using the gem's Ruby
code itself.  As a result you can't not get current api docs when you
install a gem.


-- 
Greg Donald
http://destiney.com/

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



[PHP] first php 5 class

2008-01-30 Thread Isaac Gouy
On 2008-01-30 18:29:57 Greg Donald wrote:
-snip-
 
http://shootout.alioth.debian.org/gp4/benchmark.php?test=alllang=all
 That benchmark doesn't include Ruby 1.9.

Now that the benchmarks game homepage

http://shootout.alioth.debian.org/

includes an A to Z list of language implementations you should find it
easier to see that Ruby 1.9 is in fact shown.


  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

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



Re: [PHP] Sum of results

2008-01-30 Thread Richard Lynch


On Wed, January 30, 2008 12:58 am, Dax Solomon Umaming wrote:
 Hi;

 I've tried Googling this out but failed to search for an answer to
 this, so
 I'm posting to this list. I'd like to know if there's a way to get the
 sum
 this results:

 // Results
 Individual Daily Consumption
 //AccountNo : Consumption
 4146121002: 1.42
 4146111002: 0.29
 4146113002: 1.38
 4146110002: 0.33
 4146112002: 0.00
 4146118002: 9.96
 == MORE ==

 // Code that generated the results
 while ($row6 = mysql_fetch_assoc($queryconsumerresults)) {
   // Show Consumer AccountNo and their Consumption
   echo $row6['AccountNo'] . :  . sprintf(%1.2f,
 $row6['Reading'] +
 $row6['KwHrAdjustment']) - ($row6['Reading1'] +
 $row6['KwHrAdjustment1'])) /
 $noofdays) * $row6['Multiplier'])) . br /;
 }

 I've tried getting the sum() from the MySQL table, but Multiplier is
 either at
 1 or 2 or 2.5 and the only way I can get an accurate total consumption
 is
 getting the sum from the results.

You should be able to use:
sum( (Reading + KwHrAdjustment - Reading1 + KwHrAdjustment1) /
$noofdays * Multiplier) from MySQL in another query...

But if you are already iterating through the results anyway, it's
probably just as easy to do:

$sum = 0;
while ($row6 = mysql_fetch_assoc(...)){
  $consumption = $row6['Reading'] + ...;
  $sum += $consumption;
}
echo Total: $sumhr /\n;

 Is there a way I can place this code on an array? I've tried using
 $indcons = array( sprintf(%1.2f, $row6['Reading'] + $row6
 ['KwHrAdjustment']) - ($row6['Reading1'] + $row6['KwHrAdjustment1']))
 /
 $noofdays) * $row6['Multiplier']))) but I've obviously failed.

 --
 Dax Solomon Umaming
 http://knightlust.com/
 GPG: 0x715C3547



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

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



Re: [PHP] We need PHP/LAMP Developers and Programmers in FL, MD, VA,NY, DC, CA, MA!!!!

2008-01-30 Thread Manuel Lemos
Hello,

on 01/30/2008 01:52 PM PHP Employer said the following:
 We need PHP/LAMP Developers and Programmers in FL, MD, VA, NY, DC, CA, MA
 
 World NetMedia is a world class leader in the development of multimedia
 internet sites. We are seeking highly motivated individuals who eat, breath,
 and love the work they do. If you like working in a fun, laid-back, yet
 exciting environment; then we want to hear from you!

Have you looked at the PHP Professionals directory?

http://www.phpclasses.org/professionals/country/us/

-- 

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

-- 
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 Richard Lynch
On Wed, January 30, 2008 10:43 am, Nathan Nobbe wrote:
 On Jan 30, 2008 11:38 AM, Greg Donald [EMAIL PROTECTED] wrote:

 If list traffic is any sign, PHP is indeed slowing down from the
 new
 peeps wanting to learn it perspective:

 http://marc.info/?l=php-generalw=2


 interesting..

Perhaps everybody on the whole planet already knows php?

:-)

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

-- 
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 Richard Lynch
On Wed, January 30, 2008 9:53 am, Stut wrote:
 The forcing it out of scope was the crux of my point. However, if
 Jochem is right then it's kinda pointless with the current
 implementation of the GC, but may become relevant in the new GC.

I dunno about the OOP instances getting GC'ed, but PHP *definitely*
reclaims memory from arrays and strings as they go out of scope,
usually.

You can work at something complicated enough to confuse it that it
won't reclaim it, but you have to work at it to get there.

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

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



Re: [PHP] Timeout while waiting for a server-client transfer to start (large files)

2008-01-30 Thread Richard Lynch
On Tue, January 29, 2008 12:45 pm, Barney Tramble wrote:
 I have a script that I am trying to figure out to allow a remote file
 to
 be sent to a client's browser. It works ok for small files, but it
 keeps
 timing out for large files. I don't think it should even take as long
 as
 it does (i.e. about 10seconds) before it pops up a dialog box for me
 to
 download a 700KB file. Any ideas? It times out on a line around which
 reads

   while (!feof($fp))
   {
  $tmp .= fread($fp, 64);
   }

Your script is reading the whole file, 64 measly bytes at a time, into
a monstrous string $tmp.

Then, finally, when you've loaded the whole [bleep] file into RAM in
$tmp, you just echo it out, right?

Don't do that.

:-)

while (!feof($fp)){
  echo fread($fp, 2048);
}

You can play around with 2048 versus 64 versus 100 on your box to
see what's fastest but I'll be pretty shocked if 64 bytes is the
best performer...

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

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



I dunno about the OOP instances getting GC'ed, but PHP *definitely*
reclaims memory from arrays and strings as they go out of scope,
usually.


Does anyone else find that funny? :)

It definitely does it ... usually ;)


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

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



Re: [PHP] first php 5 class

2008-01-30 Thread Richard Lynch
On Wed, January 30, 2008 1:33 pm, Greg Donald wrote:
 On Jan 30, 2008 12:40 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 just pointing out that the rails guys dont have much wiggle room.
 surely, youre familiar w/ this post:
 http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back_to_p_1.html

 One article from one developer means what exaclty?  Perhaps he wasn't
 writing enough lines of code per day to be stay happy using Rails?

Actually...

It meant a lot more to me than most other articles, since he clearly
gave Rails a fair tryout, and he doesn't claim Rails Sucks or
anything of the sort.

He just described exactly WHY Rails was not suitable for his needs, in
case your needs were similar.

I'd have to say that it's been the most meaningful
comparison/description of Rails I've ever seen :-)

I am biased, however, as I've known the guy since he started posting
on this very list (or perhaps its predecessor back when there was only
one PHP list) and I was answering his questions.

He's actually built a rather amazing site/business if you look into it...

http://cdbaby.com/about



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

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

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

-- 
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 Richard Lynch


On Wed, January 30, 2008 6:19 pm, Chris wrote:

 I dunno about the OOP instances getting GC'ed, but PHP *definitely*
 reclaims memory from arrays and strings as they go out of scope,
 usually.

 Does anyone else find that funny? :)

 It definitely does it ... usually ;)

Ah well.

It definitely does it when it can, but you can confuse it with enough
circular references and large enough data structures that it ends up
with a giant mess of data it can't GC, because it's just not THAT
smart.

There are improvements coming in this area, I think, in PHP 6, if I
remember the posts to internals correctly.

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

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

Richard Lynch wrote:


On Wed, January 30, 2008 6:19 pm, Chris wrote:

I dunno about the OOP instances getting GC'ed, but PHP *definitely*
reclaims memory from arrays and strings as they go out of scope,
usually.

Does anyone else find that funny? :)

It definitely does it ... usually ;)


Ah well.


I was just picking on the phrasing, nothing else :)


It definitely does it when it can, but you can confuse it with enough
circular references and large enough data structures that it ends up
with a giant mess of data it can't GC, because it's just not THAT
smart.


Yep, they suck pretty hard and can be pretty hard to unravel at times 
but that's another topic altogether.



There are improvements coming in this area, I think, in PHP 6, if I
remember the posts to internals correctly.


Awesome :)

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

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



Re: [PHP] 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] Another question about functions...

2008-01-30 Thread Richard Lynch
On Tue, January 29, 2008 1:39 pm, Jason Pruim wrote:
 Okay, so I checked everything I can think of, and it's still
 downloading it as an application which means it's downloading the
 entire website instead of just the data from the database... Anyone
 have any idea what to check?

Can you explain what you mean by downloading it as an application?...


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

-- 
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 Richard Lynch
On Wed, January 30, 2008 1:44 pm, Nathan Nobbe wrote:
 when you said earlier that people arent interested in learning
 php, this is something i immediately thought of.  primarily
 because spl debuted in php 5.0 and practically nobody is
 using it (which could just be my skewed perception) when it
 is extremely powerful.

I don't use SPL because it makes my head spin to read it, and I never
ever try to do something as silly as iterate over a *LARGE* array in
end-user pages.

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


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



Re: [PHP] Handle time-outs and errors with file()

2008-01-30 Thread Richard Lynch


On Tue, January 29, 2008 9:58 am, John Papas wrote:
 I'm using file() to get the contents of a remote page in my script but
 I cannot find any information regarding how I could *gracefully*
 handle a broken network connection or even a time-out (slow
 connection).

 Is there a way?

 ---
 Example:
 $menu = file('http://www.remotesite.org/mypage.html');

Use http://php.net/set_error_handler

You can change the timeout with set_ini() right before the file() call.

If $menu === false, then it failed.

 foreach ($menu as $line_num = $line) {
 echo $line.\n;
 }

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




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

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



Re: [PHP] Framed Linked Content

2008-01-30 Thread Richard Lynch
On Tue, January 29, 2008 9:21 am, Mike Potter wrote:
 There is JavaScript out there, to make a page break out of frames if
 someone else has your page in a frame of theirs.
 Is it possible to do this with PHP or is that the wrong side of
 Server/Client-side operations?

PHP is the wrong side of the tracks for that.

 Related, when target files are PDF's, images, or other than
 .php/.htm(l), does PHP provide any remedies against that
 sort of remote site linking?

Not really.

You can require a login or other authentication by using a PHP wrapper
that spews out the PDF/image/whatever.

But an HTTP request is an HTTP request which your server will respond
to unless you add logic in PHP to make it respond differently.

Nothing built-in; Just plenty of tools to build whatever you want.

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

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



Re: [PHP] Framed Linked Content

2008-01-30 Thread Richard Lynch


On Tue, January 29, 2008 10:32 am, Per Jessen wrote:
 Robert Cummings wrote:

 The only remedy agaonst remote linking is to embed some kind of
 expiration in the link that accesses the document.

 Wouldn't a check of the REFERER field be enough to disable most remote
 links?  (I know it is easily forged.)

Normal users also use browsers which choose not to send it all.

If you don't mind losing X% of your audience because they like to use
such a browser, you're all set... :-v

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

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



Re: [PHP] Framed Linked Content

2008-01-30 Thread Michael McGlothlin



The only remedy agaonst remote linking is to embed some kind of
expiration in the link that accesses the document.
  

Wouldn't a check of the REFERER field be enough to disable most remote
links?  (I know it is easily forged.)



Normal users also use browsers which choose not to send it all.

If you don't mind losing X% of your audience because they like to use
such a browser, you're all set... :-v
  
Yeah, those two people would be blocked. Wouldn't bother anyone else. 
You can do it but it's not effective against people smart enough to 
supply a fake referer. Often you'll just create more problems for 
yourself than you'll really see benefit. It is useful sometimes though.


I'd do it at the webserver level though and not with PHP.

--
Michael McGlothlin
Southwest Plumbing Supply



smime.p7s
Description: S/MIME Cryptographic Signature


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] curl timeout vs socket timeout

2008-01-30 Thread Richard Lynch
On Mon, January 28, 2008 3:56 pm, Ravi Menon wrote:
 1) curl:

 .
 .
 curl_setopt( $handle, CURLOPT_TIMEOUT, 1 );
 .
 .
 $resp = curl_exec($handle)


 2) sockets:

 stream_set_timeout( $sock, 1);

This is only for AFTER you've already opened up the socket.

If you want a timeout on the opening, the setting is in php.ini, or
you can just use ini_set() right before the fsockopen.

 In (1),  how is the timeout applied - is it:

 a) timeout includes the entire curl_exec() call - the combined socket
 write()  ( to send the request ) and
 the  read() ( read the response ) calls.

 or

 b) timeout is independently applied to write() and read() end
 respectively.

 Some of our tests seem to indicate it is (a).

You'd probably have to ask the cURL folks...

 In (2), I am assuming the stream timeout is applied at each i/o call
 independently for fwrite() and fread() - I am pretty
 much certain on this as this is how it would map to underlying C
 calls.

Almost for sure, it applies to any given fwrite/fread.

Actually, probably at an even lower level, to any given packet
sent/received within an fwrite/fread

 It will be good to get a confirmation on our doubts.

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

-- 
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 Janet N
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?

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
 




RE: [PHP] determine file-upload's tmp-filename

2008-01-30 Thread Richard Lynch
Your first line of PHP code does not execute until PHP finishes
accepting the whole file...

On Mon, January 28, 2008 2:34 pm, Mr Webber wrote:

 This is the info available to upload scripts

 I have not done this, but am inspired to do it now.  My design is to
 develop
 my own meter by compare $FILES;'size'] to the actual size on disk as
 the
 file uploads; I would use some sort of JavaScript / Ajax service
 connection
 so that the upload meter is displayed in the current browsing window
 or an
 upload popup.

 $_FILES['userfile']['name']
 $_FILES['userfile']['type']
 $_FILES['userfile']['size']
 $_FILES['userfile']['tmp_name']
 $_FILES['userfile']['error']

 -Original Message-
 From: Michael Fischer [mailto:[EMAIL PROTECTED]
 Sent: Monday, January 28, 2008 2:50 PM
 To: php-general
 Subject: Re: [PHP] determine file-upload's tmp-filename

 On Mon, 2008-01-28 at 12:17 -0600, Richard Lynch wrote:

 On Sat, January 26, 2008 5:57 pm, Michael Fischer wrote:
  hi there,
 
  is there a way to determine the tmp-filename of a file upload
 while
  the upload is still in progress?
 
  the tmp-file is stored in /tmp and it's name is something like
  PHP.
 
  what i would like to do is:
  i want to upload a file via a html-form and while the upload is in
  progress make repeatedly ajax-requests to a php-script on the
 server
  that replies the size of the tmp file (the amount of data that was
  already uploaded). So in this script i need to know what the
  tmp-filename is.
 
  or do you think this is a completely useless approach?

 Google for PHP upload meter instead.

 That's probably how it works, more or less...

 I still think it's STOOPID to round-trip back and forth to the
 server
 to get an upload progress meter -- The browser developers should be
 providing you with some kind of progress notification system
 locally!

 well, i agree with you - the browser should provide some sort of
 functionality to find out the amount of data already sent. but i don't
 know any browser that does.

 all the php upload meters that i found on google either require to
 patch php or use perl.

 lg, Michi
 --
 Sautergasse 27-29/35
 1160 Wien
 phone: 0043 650 2526276
 email: [EMAIL PROTECTED]
 web: http://www.webfischer.at

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




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

-- 
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] Re: disable referer ? (was: Framed Linked Content)

2008-01-30 Thread Richard Lynch
On Tue, January 29, 2008 10:55 am, Per Jessen wrote:
 Robert Cummings wrote:

 Referer value is completely worthless. Many people completely
 disable
 it-- such as myself :)

 But most people probably don't - 'coz most don't know how to edit e.g.
 the firefox config.

 What is the purpose of disabling it?

It's none of your [bleep] business what website I was on before I came
to your site...

Large companies and advertising and the sharing of personal data in
the background makes this a pretty serious privacy issue if you think
about it for a while.

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

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



Re: [PHP] Re: disable referer ? (was: Framed Linked Content)

2008-01-30 Thread Richard Lynch
On Tue, January 29, 2008 12:48 pm, Per Jessen wrote:
 Robert Cummings wrote:

 Actually, now you made me think on it... the primary reason I
 disable
 referrer logging is because it will also pass along lovely
 information
 such as any session ID embedded in the URL. So if you happen to get
 on
 a malicious site, they could access the account from which you've
 come.

 Hmm, interesting idea.  I wonder if the sessionid isn't tied to the
 IP-address even when it's part of the URL?

It CANNOT be tied to the IP address, because most users' IP addresses
are not static.

Google for session hijacking for more info.

 Still, I can't help thinking that if this is a serious problem, it
 would
 have been dealt with long ago.

War is a serious problem.

So is murder.

So is people cutting me off in traffic. :-v

None of them have been dealt with effectively yet.

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

-- 
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] how dod you get to do multiple mysql queries concurrently?

2008-01-30 Thread Richard Lynch
On Mon, January 28, 2008 12:37 pm, Per Jessen wrote:
 Richard Lynch wrote:

 On Sat, January 26, 2008 3:45 am, Per Jessen wrote:
 Nathan Rixham wrote:

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)

 Uh, could you could elaborate a bit on that (whilst I go and do
 some
 googling)?

 If you are doing geography/geometry stuff, spatial indices can be
 nice.


 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.

It's a bit more complex than that, as a geometry can be much more
than just long/lat, and space could be 3-D or even N-space, but that's
the simple version to light up the bulb.

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

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



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

2008-01-30 Thread Richard Lynch
On Mon, January 28, 2008 2:52 pm, Per Jessen wrote:
 True again. However, I was commenting on your assertion that Process
 forking has EVERYTHING to do with thread safety, which I will stay is
 wrong.  When you fork another process, you don't need to worry about
 whether your code is thread-safe or not. You don't have to be
 reentrant, you could even use self-modifying code if you felt the
 urge.

Perhaps I mis-remember my C days, but I'm pretty sure it's trivial to
write a fork program in which both parent and child attempt to
utilize the same global resource as if they have exclusive access
and crash your program.

Sure smells like a thread-safety issue to this naive reader...

fork() manages to do the right thing for many common resources, but
it doesn't handle all of them.

If you expect to have two processes running the same lines of codes at
once, you need to worry about thread safety just as if there were
real threads involved.

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

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



RE: [PHP] We need PHP/LAMP Developers and Programmers in FL, MD, VA,NY, DC, CA, MA!!!!

2008-01-30 Thread resumes
No, but we will.  Thanks.

 


-Original Message-
From: Manuel Lemos [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 30, 2008 6:44 PM
To: PHP Employer
Cc: php-general@lists.php.net
Subject: Re: [PHP] We need PHP/LAMP Developers and Programmers in FL, MD, 
VA,NY, DC, CA, MA

Hello,

on 01/30/2008 01:52 PM PHP Employer said the following:
 We need PHP/LAMP Developers and Programmers in FL, MD, VA, NY, DC, CA, MA
 
 World NetMedia is a world class leader in the development of multimedia
 internet sites. We are seeking highly motivated individuals who eat, breath,
 and love the work they do. If you like working in a fun, laid-back, yet
 exciting environment; then we want to hear from you!

Have you looked at the PHP Professionals directory?

http://www.phpclasses.org/professionals/country/us/

-- 

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--
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 Janet N
Hi Jochem,

Thanks for the prompt response.  No I do not want people to fill in both
forms at once.

I actually have a three step process. I simplified it to two because if I
can get two steps to work, I should be good to go.  Each step depends on the
preceding step having completed successfully.  Users therefore need a
success message after each step is successfully completed.  We cannot
require that users do all steps in one sitting.  It must be possible to do
step one, leave, come back the next day and do 2,etc.

Because there is not enough to each step to justify a full web page devoted
to it alone, I have decided to keep all steps on one page.

Is there any way to use the hidden attribute of HTML variables to prevent
the output message from overwriting the page?


On Jan 30, 2008 5:30 PM, Jochem Maas [EMAIL PROTECTED] wrote:

 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
 
 
 




Re: [PHP] first php 5 class

2008-01-30 Thread Nathan Nobbe
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.

-nathan

-- 
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 Nathan Nobbe
On Jan 30, 2008 7:58 PM, Richard Lynch [EMAIL PROTECTED] wrote:
 I don't use SPL because it makes my head spin to read it, and I never
 ever try to do something as silly as iterate over a *LARGE* array in
 end-user pages.

are there pages where you iterate over the same 'small' array more than
once?  spl will definitely beat out the foreach performance over the arrays.

its really not that bad to learn, and once you have it down, its so easy.
you can decorate one thing w/ another to get new behavior at runtime.
suppose you have a structure, you want to get some stuff out of it.  ok,
iterate over it, but wait you dont want all of it, wrap it in a FilterIterator,
but wait, you might need those results again, wrap it in a CachingIterator.
not only is the library seamless, but its faster than the stock stuff.  and
it has lots of other useful features as well, besides the iterators.

-nathan

-- 
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] first php 5 class

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 10:58 PM, Jochem Maas [EMAIL PROTECTED] wrote:
 besides being a nightmare, portage doesn't answer the question of rolling out 
 stuff
 to multiple machines simultaneously.

portage is one of the most elegant software distribution mechanisms
ever created.
and you dont have to have a cluster to leverage its usefulness.  how
would i push
to multiple machines simultaneously, probly batch an emerge of the
latest version
of my code as soon as its available in my proprietary overlay.  the
remote machines
periodically poll the source box for the latest version of the
overlay.  when its available
they then run an install script which updates to w/e is specified by
the latest ebuild.
and you could easily embed 'instructions' in such overlays; like roll
back to version x,
in the event of a catastrophe; though i cant think if a great way to
force an immediate
rollback, at least not off the top of my head.
i mean, you could really build it yourself, especially since php is
just source files to
push around.  but why reinvent the wheel, portage is already here and
it works great.

-nathan

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



  1   2   >