[PHP] Alternative session control system

2011-12-26 Thread Francisco M. Marzoa Alonso
Hello,

I need an alternative session control system different from the PHP
standard one, that does not need to use the headers, because it's for a
series of scripts that will be accessed through AJAX javascript code
inserted in different places of a web page which headers I do not
control, so I cannot do an start_session before headers sent or
setcookies neither.

I have an idea on how to solve this, based on client IP, but if there is
something done yet, I do not want to reinvent the wheel from scratch.

Thanks a lot in advance,

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



[PHP] Problems with CURL using an HTTP Proxy on PHP5

2011-12-16 Thread Francisco M. Marzoa Alonso
Hello,

The following code is failing and I do not find the cause (please, note
that checkurl value and CURLOPT_PROXY are NOT the real values I'm using,
of course):

$ch = curl_init();
$checkurl = 'http://mycheckhost.com/';
curl_setopt ($ch, CURLOPT_TIMEOUT, 6000);
curl_setopt ($ch, CURLOPT_URL, $checkurl);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_HEADER, false);
curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt ($ch, CURLOPT_PROXY, '1.2.3.4:' );

$data = curl_exec($ch);
$curl_info = curl_getinfo ($ch);

if ( $data === false ) {
$rtn = false;
} else {
$rtn = true;
}

return $rtn;

Every curl_exec returns false, and a var_dump of $curl_info looks as
follows:

array(21) {
  [url]=
  string(25) http://mycheckhost.com/;
  [content_type]=
  NULL
  [http_code]=
  int(0)
  [header_size]=
  int(0)
  [request_size]=
  int(99)
  [filetime]=
  int(-1)
  [ssl_verify_result]=
  int(0)
  [redirect_count]=
  int(0)
  [total_time]=
  float(1.843925)
  [namelookup_time]=
  float(0.00018)
  [connect_time]=
  float(0.333015)
  [pretransfer_time]=
  float(0)
  [size_upload]=
  float(0)
  [size_download]=
  float(0)
  [speed_download]=
  float(0)
  [speed_upload]=
  float(0)
  [download_content_length]=
  float(-1)
  [upload_content_length]=
  float(-1)
  [starttransfer_time]=
  float(0)
  [redirect_time]=
  float(0)
  [certinfo]=
  array(0) {
  }
}


I know it is NOT a problem with the website, because if I comment out
the line curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, 1) disabling the use
of a proxy, it works fine.

I know the proxy is working fine, because if I use curl from command
line like:

curl -x 1.2.3.4: http://mycheckhost.com/

It also WORKS fine.

So the problem may be or within the PHP5 curl implementation, or in my
own code, but I have not been able to find the problem with my code.

Any hints?

BTW:

$ php --version
PHP 5.3.6-13ubuntu3.3 with Suhosin-Patch (cli) (built: Dec 13 2011
18:37:10)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies



Thanks a lot in advance,

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



[PHP] Problems with proc_open and getmypid

2011-11-14 Thread Francisco M. Marzoa Alonso
Hello,

I'm developing a PHP application that runs on GNU/Linux with php cli. A
process must launch another one and store its pid, so I use proc_open
and then proc_status to achieve that.

The child process must also get its own pid and write it down to a file.

After that, the calling process should compare both pids and they should
match, but in fact they shoudln't.

The problem is that when calling to proc_open like:

$res = proc_open (/usr/bin/php proc2.php, array(), $pipes);

Two processes are created, one for the sh shell that launchs the php
interpreter, and another for the php interpreter itself. Also, it seems
like proc_get_status($res) returns the status of the sh, while getmypid
in the second process returns the pid of the php interpreter.

I wonder if there's anyway of do something of these:

a) Get the pid of the php interpreter on proc_open instead of the sh one
on the parent process, or...

b) Get the pid of the sh process instead of the php interpreter on the
child process.

Or any manner in which two pids matches.

Thanks a lot in advance,

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



Re: [PHP] Select record by ID

2007-01-28 Thread Francisco M. Marzoa Alonso
The first thing that I probably do is to check for possible errors from
DB:

$result = mysql_query(SELECT * FROM inf_member WHERE
user_id='$user_id' );
if ( ! $result ) {
die (Could not perform query $query: .mysql_error().\n);
}

Regards,


On dom, 2007-01-28 at 18:21 -0500, nitrox . wrote:
 Before I ask my next question I just wanted to thank you all for being in 
 this mailing community and sharing your knowledge. Its communitys like this 
 that make life easier for all of us. Ok enough with the mushy stuff
 
 Im trying to display one record at a time by ID. Well im getting a blank 
 page. Ive looked over my code and tried 20 different ways to get it to work 
 to no avail. So any pointers on what Im doing wrong would be great. here is 
 the code im working with so far.
 
 ?php
 include(db.php);
 
 $result = mysql_query(SELECT * FROM inf_member WHERE 
 user_id='$user_id' );
 while($myrow = mysql_fetch_assoc($result))
   {
  echo b;
  echo $myrow['user_name'];
  echo /b;
  echo $myrow['rank'];
echo /b;
  echo $myrow['country'];
echo /b;
  echo $myrow['email'];
  echo /b;
  echo $myrow['quote'];
  echo /b;
  echo $myrow['config'];
echo /b;
echo $myrow['map'];
  echo /b;
  echo $myrow['gun'];
  echo /b;
  echo $myrow['brand'];
echo /b;
echo $myrow['cpu'];
echo /b;
  echo $myrow['ram'];
  echo /b;
  echo $myrow['video'];
  echo /b;
  echo $myrow['sound'];
echo /b;
echo $myrow['monitor'];
  echo /b;
  echo $myrow['mouse'];
  echo /b;
  echo $myrow['brand'];
echo /b;
 
  }
 ?
 
 _
 FREE online classifieds from Windows Live Expo – buy and sell with people 
 you know 
 http://clk.atdmt.com/MSN/go/msnnkwex001001msn/direct/01/?href=http://expo.live.com?s_cid=Hotmail_tagline_12/06
 


signature.asc
Description: This is a digitally signed message part


Re: [PHP] Select record by ID

2007-01-28 Thread Francisco M. Marzoa Alonso
Ops!, Better this one:

$query = SELECT inf_member WHERE user_id='$user_id' ;
$result = mysql_query($query);
if ( ! $result ) {
die (Could not perform query $query: .mysql_error().\n);
}

I did copy and paste from my own code and you've not $query defined on
your one. I prefer to store first the query on a string to show it
complete if there's an error late, because it may show also the point.



On lun, 2007-01-29 at 00:39 +0100, Francisco M. Marzoa Alonso wrote:
 The first thing that I probably do is to check for possible errors from
 DB:
 
 $result = mysql_query(SELECT  inf_member WHERE
 user_id='$user_id' );
   if ( ! $result ) {
   die (Could not perform query $query: .mysql_error().\n);
   }
 
 Regards,
 
 
 On dom, 2007-01-28 at 18:21 -0500, nitrox . wrote:
  Before I ask my next question I just wanted to thank you all for being in 
  this mailing community and sharing your knowledge. Its communitys like this 
  that make life easier for all of us. Ok enough with the mushy stuff
  
  Im trying to display one record at a time by ID. Well im getting a blank 
  page. Ive looked over my code and tried 20 different ways to get it to work 
  to no avail. So any pointers on what Im doing wrong would be great. here is 
  the code im working with so far.
  
  ?php
  include(db.php);
  
  $result = mysql_query(SELECT * FROM inf_member WHERE 
  user_id='$user_id' );
  while($myrow = mysql_fetch_assoc($result))
{
   echo b;
   echo $myrow['user_name'];
   echo /b;
   echo $myrow['rank'];
   echo /b;
   echo $myrow['country'];
   echo /b;
   echo $myrow['email'];
   echo /b;
   echo $myrow['quote'];
   echo /b;
   echo $myrow['config'];
   echo /b;
   echo $myrow['map'];
   echo /b;
   echo $myrow['gun'];
   echo /b;
   echo $myrow['brand'];
   echo /b;
   echo $myrow['cpu'];
   echo /b;
   echo $myrow['ram'];
   echo /b;
   echo $myrow['video'];
   echo /b;
   echo $myrow['sound'];
   echo /b;
   echo $myrow['monitor'];
   echo /b;
   echo $myrow['mouse'];
   echo /b;
   echo $myrow['brand'];
   echo /b;
  
   }
  ?
  
  _
  FREE online classifieds from Windows Live Expo – buy and sell with people 
  you know 
  http://clk.atdmt.com/MSN/go/msnnkwex001001msn/direct/01/?href=http://expo.live.com?s_cid=Hotmail_tagline_12/06
  


signature.asc
Description: This is a digitally signed message part


Re: [PHP] Select record by ID

2007-01-28 Thread Francisco M. Marzoa Alonso
On dom, 2007-01-28 at 18:51 -0500, nitrox . wrote:
 I took the quotes off. I thought that quotes around numbers was wrong also. 

Quotes are no necessary around numeric values, but they aren't wrong
neither, simply optional.

 I added the error checking and this is the error:
 
 Could not perform query : You have an error in your SQL syntax; check the 
 manual that corresponds to your MySQL server version for the right syntax to 
 use near '' at line 1

Try with the new code I sent you too see the query you're sending,
probably -but not sure- $user_id is void and you're doing:

SELECT * FROM inf_member WHERE user_id=

Anyway if you can see the query, you'll see the source of the error.

 
 and this is the code again:
 
 ?php
 include(db.php);
 $result = mysql_query(SELECT * FROM inf_member WHERE 
 user_id=$user_id);
 if ( ! $result ) {
   die (Could not perform query $query: .mysql_error().\n);
   }
 
   while($myrow = mysql_fetch_assoc($result))
   {
  echo b;
  echo $myrow['user_name'];
  echo /b;
  echo $myrow['rank'];
echo /b;
  echo $myrow['country'];
echo /b;
  echo $myrow['email'];
  echo /b;
  echo $myrow['quote'];
  echo /b;
  echo $myrow['config'];
echo /b;
echo $myrow['map'];
  echo /b;
  echo $myrow['gun'];
  echo /b;
  echo $myrow['brand'];
echo /b;
echo $myrow['cpu'];
echo /b;
  echo $myrow['ram'];
  echo /b;
  echo $myrow['video'];
  echo /b;
  echo $myrow['sound'];
echo /b;
echo $myrow['monitor'];
  echo /b;
  echo $myrow['mouse'];
  echo /b;
  echo $myrow['brand'];
echo /b;
 
  }
 ?
 
 _
 Laugh, share and connect with Windows Live Messenger 
 http://clk.atdmt.com/MSN/go/msnnkwme002001msn/direct/01/?href=http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-ussource=hmtagline
 


signature.asc
Description: This is a digitally signed message part


Re: [PHP] Select record by ID

2007-01-28 Thread Francisco M. Marzoa Alonso
On dom, 2007-01-28 at 18:20 -0600, Larry Garfield wrote:
 On Sunday 28 January 2007 5:54 pm, Francisco M. Marzoa Alonso wrote:
  On dom, 2007-01-28 at 18:51 -0500, nitrox . wrote:
   I took the quotes off. I thought that quotes around numbers was wrong
   also.
 
  Quotes are no necessary around numeric values, but they aren't wrong
  neither, simply optional.
 
 Actually, I believe they are wrong in some database engines but not others.  
 MySQL doesn't care.  Some others do.  Yes, it sucks. :-(

Good point, but he's using mysql in this case, and in mysql they're
simply optional but not wrong.

Regards,



signature.asc
Description: This is a digitally signed message part


[PHP] My objects eats too much (and weird!) memory

2007-01-27 Thread Francisco M. Marzoa Alonso
Hello!

I'm new here, so I do not know if attachments are allowed, so I put my
code below.

I've written this to check memory consumption of PHP5 objects, because
I'm having memory problems with an OO XMLParser that I've written.

When I execute the code from cli, I get:



$ php MemTest.php
Obj1 uses 208 bytes
Obj2 uses 168 bytes
Obj3 uses 200 bytes
Obj4 uses 200 bytes
Obj5 uses 200 bytes
Obj6 uses 200 bytes


I understand that first instance may be bigger than next ones because
method allocation and other things of that kind, but I do not understand
why second instance is smaller than third :-?

So, my first question is: Why third object is a 16% smaller than third
and nexts?

In any case, my second question is: Isn't too much memory 200 bytes for
a so simply object??


And the third: Is there any manner to get more compact objects in PHP5?


Thanks a lot in advance.

---
?php

class dummy {
protected $a;

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

$before=0;
$memdiff=0;

$before = memory_get_usage();
$obj1 = new dummy (0);
$memdiff = memory_get_usage()-$before;
echo Obj1 uses $memdiff bytes\n;

$before = memory_get_usage();
$obj2 = new dummy (0);
$memdiff = memory_get_usage()-$before;
echo Obj2 uses $memdiff bytes\n;

$before = memory_get_usage();
$obj3 = new dummy (0);
$memdiff = memory_get_usage()-$before;
echo Obj3 uses $memdiff bytes\n;

$before = memory_get_usage();
$obj4 = new dummy (0);
$memdiff = memory_get_usage()-$before;
echo Obj4 uses $memdiff bytes\n;

$before = memory_get_usage();
$obj5 = new dummy (0);
$memdiff = memory_get_usage()-$before;
echo Obj5 uses $memdiff bytes\n;

$before = memory_get_usage();
$obj6 = new dummy (0);
$memdiff = memory_get_usage()-$before;
echo Obj6 uses $memdiff bytes\n;


?

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



Re: [PHP] My objects eats too much (and weird!) memory

2007-01-27 Thread Francisco M. Marzoa Alonso
On sáb, 2007-01-27 at 20:05 +, Roman Neuhauser wrote:
 # [EMAIL PROTECTED] / 2007-01-26 20:40:34 +0100:
  I've written this to check memory consumption of PHP5 objects, because
  I'm having memory problems with an OO XMLParser that I've written.
 
 It measures something else though. The memory manager doesn't allocate
 memory for individual variables in PHP.
 
  $ php MemTest.php
  Obj1 uses 208 bytes
  Obj2 uses 168 bytes
  Obj3 uses 200 bytes
  Obj4 uses 200 bytes
  Obj5 uses 200 bytes
  Obj6 uses 200 bytes
  
  
  I understand that first instance may be bigger than next ones because
  method allocation and other things of that kind
 
 No.
 
  but I do not understand why second instance is smaller than third :-?
 
 It's not.
  
  In any case, my second question is: Isn't too much memory 200 bytes for
  a so simply object??
 
 It's not memory consumption of that object.


AFAIK there's no other way to measure memory usage on PHP than this, if
you know something better it could be more constructive if you show it.

 
  And the third: Is there any manner to get more compact objects in PHP5?
 
 You need to measure something before you want to compare it (more
 compact than what?)

If I say that I need a more compact car I think everyone understands me
without needing to say than the one I own, so I think its pretty clear
what I'm asking for.
 
  $before = memory_get_usage();
 
 What's $before here?

Memory consumption until next code.

 
  $obj1 = new dummy (0);
  $memdiff = memory_get_usage()-$before;
  echo Obj1 uses $memdiff bytes\n;
  
  $before = memory_get_usage();
 
 What's $before here?

The same as $before of before.

Thank you by your helpless comment.



signature.asc
Description: This is a digitally signed message part


Re: [PHP] Re: My objects eats too much (and weird!) memory

2007-01-27 Thread Francisco M. Marzoa Alonso
Hello,

I took a look to www.xdebug.org and the only memory related functions
was those I found here:

http://www.xdebug.org/docs-functions.php#tracing

int xdebug_memory_usage()
int xdebug_peak_memory_usage() 

The first seems to be the same that memory_get_usage 

http://es2.php.net/manual/en/function.memory-get-usage.php

that I'm using on my script, and the second seems to be just like
memory_get_peak_usage:

http://es2.php.net/manual/en/function.memory-get-peak-usage.php

That has no sense for this test.

Thanks anyway.

On sáb, 2007-01-27 at 20:46 +, Colin Guthrie wrote:
 Francisco M. Marzoa Alonso wrote:
  AFAIK there's no other way to measure memory usage on PHP than this, if
  you know something better it could be more constructive if you show it.
 
 The last time I looked I think the xdebug module allowed you to get the
 memory consumption of a given object in PHP. I can't remember for sure
 tho', so check the docs/API before spending too much time with it :)
 
 HTH
 
 Col.
 


signature.asc
Description: This is a digitally signed message part


Re: [PHP] DATE

2007-01-27 Thread Francisco M. Marzoa Alonso
On sáb, 2007-01-27 at 23:51 -0500, Ron Piggott wrote:
 I have date in the variable $date_reference in the format -MM-DD.
 How do I find out the date before this and the date after this?  Ron
 


http://us3.php.net/manual/en/function.date.php#68716

RTFM :-P


signature.asc
Description: This is a digitally signed message part


[PHP] Objects and sessions

2004-12-09 Thread Francisco M. Marzoa Alonso
Following code:
?php
class SessionTestC {
   protected $value;
   function __construct ( $val ) {
   $this-value = $val;
   }
   function GetValue () {
   return $this-value;
   }
}
if ( isset ($_SESSION['TestObj'])) {
   echo 'Session Test is set to: '.$_SESSION['TestObj']-GetValue().'br';
} else {
   session_start ();
   echo 'Session Test was not set.br';
   $_SESSION['TestObj'] = new SessionTestC ( 'This is a test' );
   echo a href='.basename($_SERVER['PHP_SELF']).'Click here./abr;
}
?
Gives me an error of incomplete object on second access, like this:
*Fatal error*: main() [function.main 
http://localhost/sfcms/Scripts/function.main]: The script tried to 
execute a method or access a property of an incomplete object. Please 
ensure that the class definition SessionTestC of the object you are 
trying to operate on was loaded _before_ unserialize() gets called or 
provide a __autoload() function to load the class definition in 
*/home/fmmarzoa/Develop/Stradivarius/Scripts/SessionTest.php* on line *16

*But as it can be seen, the class is defined in the script 
SessionTest.php itself, so... ??

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


[PHP] [SOLUTION] Re: [PHP] Objects and sessions

2004-12-09 Thread Francisco M. Marzoa Alonso
Thomas Munz wrote:
I think, its not possible to init an Objeect on a session. 

Yes, it can.
The problem was with serialization. With session.auto_start set to 1 on 
php.ini, seems like session's objects are unserialized before loading 
the script, so the class is not loaded when the session unserialized the 
object, and therefore it fails to unserialize it as an instance of its 
class.

Setting session.auto_start to 0 on php.ini you should take care of 
resume sessions calling session_start() each time, but you can put that 
call after class definition, so the object will be unserialized after, 
so the problem is solved.

This code works fine:
?php
class SessionTestC {
   protected $value;
   function __construct ( $val ) {
   $this-value = $val;
   }
   function GetValue () {
   return $this-value;
   }
}
if ( isset ($_GET['close_session'])) {
   unset ($_SESSION);
   session_start ();
   session_destroy ();
}
session_start ();
if ( isset ($_SESSION['TestObj'])) {
   echo 'TestObj is an instance of 
'.get_class($_SESSION['TestObj']).'br';
   echo 'pre';
   print_r ($SESSION['TestObj']);
   echo '/pre';

   echo a 
href='.basename($_SERVER['PHP_SELF']).?close_session=1'Close 
session./abr;
   echo 'Session Test is set to: '.$_SESSION['TestObj']-GetValue().'br';
} else {
   echo 'Session Test was not set.br';
   $_SESSION['TestObj'] = new SessionTestC ( 'This is a test' );
   echo a href='.basename($_SERVER['PHP_SELF']).'Click here./abr;
}

?
BTW, I do not know if the code I've used to destroy the session is the 
best, but this is a secondary issue...

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


[PHP] Getting static member for a class which name is stored in a variable

2004-11-25 Thread Francisco M. Marzoa Alonso
I've code like follows:
?php
class TestClass {
   public static $Data = 'This is the data';
}
$Obj = new TestClass ();
$ClassName = get_class ($Obj);
echo $ClassName::$Data;
?
It gives me an error like:
Parse error: parse error, unexpected T_PAAMAYIM_NEKUDOTAYIM ...
I've found googling that it means that those '::' are unexpected. So, 
How can I get an static member for a class which name is stored in a 
variable?

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


[PHP] Overriding static members?

2004-11-25 Thread Francisco M. Marzoa Alonso
Can I override static members in someway under PHP5? Is the answer is 
negative, Why not?

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


Re: [PHP] Sorting...

2004-11-17 Thread Francisco M. Marzoa Alonso
If each element of the array is a string with those contains, it should 
be sorted as you want just calling sort function. It will considerate 
also rest of characters, of course, but the most significative should be 
the first ones.

Another alternative is to wrote a quicksort function in PHP customized 
by yourself, but I cannot figure out if this will be faster (probably not).

Russell P Jones wrote:
I have an array filled with CSV data...
array (
20040310, Title, Author
20041115, Title, Author
20040513, Title, Author
 )
where each array element is 1 line from the csv. When I go to print it
out, Im going to explode each by , and then print it out the way I like.
BUT, I want to sort them all by those first 8 digits, which happen to be
the date. Any way to sort an array by the first x characters in its
string?
This would save a lot on processor time, otherwise Im going to have to
pull an array of those characters, sort it, and then run some matching
scheme against the CSV data to print it in the order I like - which would
be HUGELY processor intensive.
Thanks,
Russ
 

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


[PHP] explode and PATH_SEPARATOR

2004-11-15 Thread Francisco M. Marzoa Alonso
Taking this code:
pre
?php
define (PATH_SEPARATOR, /);
$String=Root/One/Two/Three/Last;
$arr = explode ( PATH_SEPARATOR, $String );
var_dump ( $arr );
$arr = explode ( /, $String );
var_dump ( $arr );
?
/pre
It works fine in second case returing a five elements array, but in the 
first one it returns an array with just one elemen that's the source 
string itself. I've test it also changing PATH_SEPARATOR by SEPARATOR in 
both cases, and it works nice... Is PATH_SEPARATOR any kind of reserved 
word or so?

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


[PHP] Dinamically adding methods to an object instance?

2004-11-15 Thread Francisco M. Marzoa Alonso
I've seen that's possible to add public members to objects dinamically, 
such as:

?php
class TestClass {
   public $One=1;
}
$Obj = new TestClass ();
$Obj-Two = 2;
echo $Obj-Two;
?
There'll be a public Two member that's not defined in the class.
Is it possible to add methods dinamically to an object instance in same 
way? how? will these methods have access to private and protected 
members of the class of the object?

Thanks a lot in advance...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Callback function as parameter

2004-11-10 Thread Francisco M. Marzoa Alonso
Hi everybody,
I want to wrote a function that receives another function as parameter 
that will be used as a Callback. Well, better a bit of code than 
thousand words:

class TreeNode {
...
   function Traverse ( CallBack ) {
   $rtn = CallBack ($this);
   foreach ($this-Sons as $Son) {
   $Son-Traverse ( CallBack );
   }
   return $rtn;
   }
...
}
And later I'll do something as:
function CallBack ( $Node ) {
   echo $Node-Name;
}
$MyTreeNode-Traverse ( CallBack );
...
Hope you understand what I'm trying to do. Can it be done as is or am I 
on the wrong way?

Thx. a million in advance,
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Re: VOTE TODAY

2004-11-05 Thread Francisco M. Marzoa Alonso
That's true for Germany and France and probably another european 
countries, but in Spain by example we've just 512/128kbps paying the 
same that a french by 6Mbps/512kbps. Never mind, this dammed country 
continues being more the North of Africa than the South of Europe...

Best regards,
Michelle Konzack wrote:
Hello Michael and *,
Am 2004-11-04 16:10:02, schrieb Michael Lauzon:
 

6Mb, that's no fair, the highest we have in Canada is 4Mb; although
supposedly there is a 5Mb service somewhere...well there is 7Mb
service but you'll be paying out of your @$$ for it.
   

In Europe the prices for ADSL are falling endless
We can have 6MBit/512kBit for Internet, TeleVision and Telephone (SIP)
So I can see TV, phone with you and surf the Internet at the same time.
In Europe we have the biggest Backbones of the World...
Allone Strasbourg exceed some STM-64 (10 GBit Backbones) !!!
For 5 years it was only 3 STM-4 (622 Mbit) and some OC-3 (155,5 Mbit)
Greetings
Michelle
 

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


Re: [PHP] Determining system resources

2004-11-04 Thread Francisco M. Marzoa Alonso
Greetings Robin,
As far as you cannot lock another processes in the system, so this will 
not give you the security that the resources will not change -and 
probably they'll do it- while you're trying to download that file.

Best regards,
Robin Getz wrote:
I have been unable to find a php function to determine available system
memory (physical and swap)?
Right now I am using something like:
=
# ensure there is enough free memory for the download
$free = shell_exec('free -b'); $i=0; while ( $i != strlen($free) ) {
i = strlen($free);
free = str_replace('  ',' ',$free);   
}
$free = str_replace(\n,'',$free);
$freeArray = explode(' ',$free);
$total_free = $freeArray[9] + $freeArray[18];
==

Does anyone have any ideas that could be used on all OSes? i.e. 
Without shell_exec()?

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


[PHP] Unexpected results with object to array cast

2004-11-03 Thread Francisco M. Marzoa Alonso
This code:
?php
class TestClass {
   private $self;
   function __construct () {
   $this-self = $this;
   }
}
$Obj = new TestClass ();
print_r ( $Obj );
echo br;
$Arr = (array) $Obj;
print_r ( $Arr );
?
Produce the following output:
TestClass Object ( [self:private] = TestClass Object *RECURSION* )
Array ( [ TestClass self] = TestClass Object ( [self:private] = 
TestClass Object *RECURSION* ) )

While I expect to find for the second line something more similar to:
Array ( [self:private] = TestClass Object *RECURSION* )
Can someone explain me what I'm doing wrong?

P.S. Die Reischtag Brände
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Unexpected results with object to array cast

2004-11-03 Thread Francisco M. Marzoa Alonso
Forget it, it has a lot of sense since self is a reference to the object
itself, but the new array is not in the same memory than the source
object, so result cannot be as I expected because self is no really
self within the array, but a reference to an object outside it.
The result its perfectly logical, indeed.
Francisco M. Marzoa Alonso wrote:
Produce the following output:
TestClass Object ( [self:private] = TestClass Object *RECURSION* )
Array ( [ TestClass self] = TestClass Object ( [self:private] = 
TestClass Object *RECURSION* ) )

While I expect to find for the second line something more similar to:
Array ( [self:private] = TestClass Object *RECURSION* )
Can someone explain me what I'm doing wrong?

P.S. Die Reischtag Brände
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: VOTE TODAY

2004-11-03 Thread Francisco M. Marzoa Alonso
This is my second and last message on this issue.
Perhaps this list is not the best place to discuse about politics, but 
it isn't for create and follow personal issues neither. In my (not-so 
:-P) humble opinion everyone that follows this kind of threads is as 
guilty of making noise as the one who begins it (and that's include 
me.php, indeed).

I  think politics are rather important, a lot of more relevant than 
coding -just read a bit of History-, greeks had a word for those that 
doesn't care about politics, that translated to english is IDIOT, but I 
also agree that this is not the best place to discusse about that. Use 
www.kuro5hin.org by example instead.

Best regards,
Ryan A wrote:
On 11/3/2004 2:48:28 PM, Daniel Schierbeck ([EMAIL PROTECTED]) wrote:
 

Ryan A wrote:
   

switch ($the_choice) {
 

case Daniel_Schierbeck_1:
 

echo
 

'Didnt read previous thread and comes voiceing his political opinions
   

like a jackass on a high traffic PHP mailing list which people from
different countries other than the states receive';
 

break;
 

case Daniel_Schierbeck_2:
 

echo 'Just a moron';
 

break;
 

default:
 

echo 'both of the above';
 

}
 

   

 

1)
I'm not American.
   

Never said you were and i'm not either.
 

2) Nice job with the constants, though I usually use upper case
characters only...
   

Personal preference.
 

3) Don't
get personal, nobody likes a bitch.
   


Sorry, didnt know you were so disliked.
- Ryan A
 

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


[PHP] [SOLUTION] Re: [PHP] Convert an array in an object instance

2004-10-27 Thread Francisco M. Marzoa Alonso
Ok, I've write a function that emulates the Perl's bless one. It works 
pretty well.

The idea comes to me when Rob suggest to parse the serialized data. I 
think this is better -or at least faster- than parsing all serialized 
data to modify object values: Just convert the object to an array, 
modify whatever values you want -no matter about member visibility-, and 
then convert the array again in an object.

Note that you should NEVER modify private and protected members outside 
its visibility environment... well, never UNLESS you're writting your 
own serialization routines indeed (that's exactly because I need to do 
it ;-) )

?
function bless ( $Instance, $Class ) {
   $serdata = serialize ( $Instance );
   /* For an array serialized data seems to meant:
array_tag:array_count:{array_elems}
   array_tag is always 'a'
   array_count is the number of elements in the array
   array_elems are the elemens in the array
 For an object seems to meant:
 
object_tag:object_class_name_len:object_class_name:object_count:{object_members}

   object_tag is always 'O'
   object_class_name_len is the length in chars of 
object_class_name string
   object_class_name is a string with the name of the class
   object_count is the number of object members
   object_members is the object_members itself (exactly equal to 
array_elems)
   */

   list ($array_params, $array_elems) = explode ('{', $serdata, 2);
   list ($array_tag, $array_count) = explode (':', $array_params, 3 );
   $serdata = O:.strlen 
($Class).:\$Class\:$array_count:{.$array_elems;

   $Instance = unserialize ( $serdata );
   return $Instance;
}
class TestClass {
   private $One=1;
   protected $Two=2;
   public $Three=3;
   public function sum() {
   return $this-One+$this-Two+$this-Three;
   }
}
$Obj = new TestClass ();
$Clone = (array) $Obj;
echo As an array:br;
print_r ($Clone);
bless ( $Clone, TestClass );
echo brbrAfter blessing as a TestClass instance:br;
print_r ($Clone);
echo brbrCalling sum method: ;
echo $Clone-sum();
echo brThe array was blessed! miracle!!! ;-)br;
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] [SOLUTION] Re: [PHP] Convert an array in an object instance

2004-10-27 Thread Francisco M. Marzoa Alonso
Erm... I've seen there're some aspects to perform... it fails because
the name of the members is changed during conversion to the array. It 
puts the class name using '\0' (0 is a zero, not a caps 'o') character 
as separator before member name in private and an '*' in protected.

It's not an unaffordable issue, because you still can modify array 
values having this in account. For example, if you want to modify the 
$One private member in the array, you cannot do:

$Clone['One']=5;
you should do
$Clone[\0TestClass\0One]=5;
instead.
Anyway I think it should be easily fixed (when I've time to do it, now I 
must work in another thing :-| )

Francisco M. Marzoa Alonso wrote:
Ok, I've write a function that emulates the Perl's bless one. It works 
pretty well.

The idea comes to me when Rob suggest to parse the serialized data. I 
think this is better -or at least faster- than parsing all serialized 
data to modify object values: Just convert the object to an array, 
modify whatever values you want -no matter about member visibility-, 
and then convert the array again in an object.

Note that you should NEVER modify private and protected members 
outside its visibility environment... well, never UNLESS you're 
writting your own serialization routines indeed (that's exactly 
because I need to do it ;-) )

?
function bless ( $Instance, $Class ) {
   $serdata = serialize ( $Instance );
   /* For an array serialized data seems to meant:
array_tag:array_count:{array_elems}
   array_tag is always 'a'
   array_count is the number of elements in the array
   array_elems are the elemens in the array
 For an object seems to meant:
 
object_tag:object_class_name_len:object_class_name:object_count:{object_members} 

   object_tag is always 'O'
   object_class_name_len is the length in chars of 
object_class_name string
   object_class_name is a string with the name of the class
   object_count is the number of object members
   object_members is the object_members itself (exactly equal to 
array_elems)
   */

   list ($array_params, $array_elems) = explode ('{', $serdata, 2);
   list ($array_tag, $array_count) = explode (':', $array_params, 3 );
   $serdata = O:.strlen 
($Class).:\$Class\:$array_count:{.$array_elems;

   $Instance = unserialize ( $serdata );
   return $Instance;
}
class TestClass {
   private $One=1;
   protected $Two=2;
   public $Three=3;
   public function sum() {
   return $this-One+$this-Two+$this-Three;
   }
}
$Obj = new TestClass ();
$Clone = (array) $Obj;
echo As an array:br;
print_r ($Clone);
bless ( $Clone, TestClass );
echo brbrAfter blessing as a TestClass instance:br;
print_r ($Clone);
echo brbrCalling sum method: ;
echo $Clone-sum();
echo brThe array was blessed! miracle!!! ;-)br;
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Problem with Regular expression

2004-10-27 Thread Francisco M. Marzoa Alonso
Try with \s instead of \b, I meant:
$pattern = 
/(\sand\s)|(\snot\s)|(\sor\s)|(\s\s)|(\s\s)|(\s\.\s)|(\s\+\s)|(\s\|\|\s)|(\s\|\s)/i;

kioto wrote:
Hi all.
I have a problem: i want subs any characters from a string but i don't 
have fix the problem.
The string that i want to manipulate is the value from a text field of 
a search engine.
The characters that i want to try substitute is , , +, -, |, ||, 
or, and, not in not case-sensitive mode with .
I have create a  pattern like this:

$str = Sybase and PHP not ASP or JSP  Oracle not Andy | Perl || 
Python + Ruby;
$pattern = 
/(\band\b)|(\bnot\b)|(\bor\b)|(\b\b)|(\b\b)|(\b\.\b)|(\b\+\b)|(\b\|\|\b)|(\b\|\b)/i; 

echo $str = preg_replace($pattern, , $str, -1);
But characters like +  don't subs with .
Thanks to all and sorry my bad language
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] bless function

2004-10-27 Thread Francisco M. Marzoa Alonso
Ok, I think I've got it now. The code is autoexplicative, the only 
restriction is that the object must be converted to an array using the 
function obj2array instead of a direct cast. There's another ways to do 
this without the needless of that obj2array function, but I think this 
is not really a limitation.

Here it is:
?
function obj2array ( $Instance ) {
   $clone = (array) $Instance;
   $rtn = $clone;
   while ( list ($key, $value) = each ($clone) ) {
   $aux = explode (\0, $key);
   $newkey = $aux[count($aux)-1];
   if ( $newkey != $key ) {
   $rtn[$newkey] = $rtn[$key];
   $rtn['___FAKE_KEYS_'][] = $newkey;
   }
   }
   return $rtn;
}

function bless ( $Instance, $Class ) {
   if ( ! (is_array ($Instance) ) ) {
   return NULL;
   }
   // First drop faked keys if available
   foreach ( $Instance['___FAKE_KEYS_'] as $fake_key ) {
   unset ($Instance[$fake_key]);
   }
   unset ( $Instance['___FAKE_KEYS_'] );
   // Get serialization data from array
   $serdata = serialize ( $Instance );
   /* For an array serialized data seems to meant:
array_tag:array_count:{array_elems}
   array_tag is always 'a'
   array_count is the number of elements in the array
   array_elems are the elemens in the array
 For an object seems to meant:
 
object_tag:object_class_name_len:object_class_name:object_count:{object_members}

   object_tag is always 'O'
   object_class_name_len is the length in chars of 
object_class_name string
   object_class_name is a string with the name of the class
   object_count is the number of object members
   object_members is the object_members itself (exactly equal to 
array_elems)
   */

   list ($array_params, $array_elems) = explode ('{', $serdata, 2);
   list ($array_tag, $array_count) = explode (':', $array_params, 3 );
   $serdata = O:.strlen 
($Class).:\$Class\:$array_count:{.$array_elems;

   $Instance = unserialize ( $serdata );
   return $Instance;
}
class TestClass {
   private $One=1;
   protected $Two=2;
   public $Three=3;
   public function sum() {
   return $this-One+$this-Two+$this-Three;
   }
}
$Obj = new TestClass ();
//$Clone = (array) $Obj;
$Clone = obj2array ( $Obj );
echo As the original object:br;
print_r ($Obj);
echo brbrAs an array:br;
print_r ($Clone);
$Clone[One]=7;
$Clone[Two]=7;
$Clone[Three]=7;
bless ( $Clone, TestClass );
echo brbrAfter blessing as a TestClass instance:br;
print_r ($Clone);
echo brbrCalling sum method: ;
echo $Clone-sum();
echo brThe array was blessed! miracle!!! ;-)br;
?
Hope someone appart from me find it useful. :-)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] bless function: a better aproach

2004-10-27 Thread Francisco M. Marzoa Alonso
Giving it a round, this seems to be a better aproach than the previous 
one. It has the advantage of provide direct access to the original array 
obtained from casting without boring about ___FAKE_KEYS_.

?
function obj2array ( $Instance ) {
   $clone = (array) $Instance;
   $rtn = array ();
   $rtn['___SOURCE_KEYS_'] = $clone;
   while ( list ($key, $value) = each ($clone) ) {
   $aux = explode (\0, $key);
   $newkey = $aux[count($aux)-1];
   $rtn[$newkey] = $rtn['___SOURCE_KEYS_'][$key];
   }
   return $rtn;
}
function bless ( $Instance, $Class ) {
   if ( ! (is_array ($Instance) ) ) {
   return NULL;
   }
   // First get source keys if available
   if ( isset ($Instance['___SOURCE_KEYS_'])) {
   $Instance = $Instance['___SOURCE_KEYS_'];
   }
   // Get serialization data from array
   $serdata = serialize ( $Instance );
   /* For an array serialized data seems to meant:
array_tag:array_count:{array_elems}
   array_tag is always 'a'
   array_count is the number of elements in the array
   array_elems are the elemens in the array
 For an object seems to meant:
 
object_tag:object_class_name_len:object_class_name:object_count:{object_members}

   object_tag is always 'O'
   object_class_name_len is the length in chars of 
object_class_name string
   object_class_name is a string with the name of the class
   object_count is the number of object members
   object_members is the object_members itself (exactly equal to 
array_elems)
   */

   list ($array_params, $array_elems) = explode ('{', $serdata, 2);
   list ($array_tag, $array_count) = explode (':', $array_params, 3 );
   $serdata = O:.strlen 
($Class).:\$Class\:$array_count:{.$array_elems;

   $Instance = unserialize ( $serdata );
   return $Instance;
}
class TestClass {
   private $One=1;
   protected $Two=2;
   public $Three=3;
   public function sum() {
   return $this-One+$this-Two+$this-Three;
   }
}
$Obj = new TestClass ();
//$Clone = (array) $Obj;
$Clone = obj2array ( $Obj );
echo As the original object:br;
print_r ($Obj);
echo brbrAs an array:br;
print_r ($Clone);
$Clone[One]=7;
$Clone[Two]=7;
$Clone[Three]=7;
bless ( $Clone, TestClass );
echo brbrAfter blessing as a TestClass instance:br;
print_r ($Clone);
echo brbrCalling sum method: ;
echo $Clone-sum();
echo brThe array was blessed! miracle!!! ;-)br;
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Protecting Commercial PHP Scripts

2004-10-26 Thread Francisco M. Marzoa Alonso
Nick Wilson wrote:
Hello all, 

I was wondering if anyone might have suggestions or useful links on
protecting commercial php scripts.
I am about to design a system that would be pretty valuable in a very
niche market and would not wish the script to be passed on to others
once downloaded.
Suggestions, discussion and links would be much appreciated ;-)
 

There's no way to protect the code from copying. The only way to do that
is not to give no one the code, provide the service based on the code
instead of the code itself. Dont waste your time looking for a solution
for a lost battle. It's just an advice, of course.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Protecting Commercial PHP Scripts

2004-10-26 Thread Francisco M. Marzoa Alonso
Nick Wilson wrote:
* and then Francisco M. Marzoa Alonso declared
 

I was wondering if anyone might have suggestions or useful links on
protecting commercial php scripts.
I am about to design a system that would be pretty valuable in a very
niche market and would not wish the script to be passed on to others
once downloaded.
 

There's no way to protect the code from copying. The only way to do that
is not to give no one the code, provide the service based on the code
instead of the code itself. Dont waste your time looking for a solution
for a lost battle. It's just an advice, of course.
   

I've had about 5 off list (why so many today?) telling me about zend
encoder so that would seem not to be true.
 

AFAIK Zend Encoder is used to protect from reverse engineering, not from 
copying. The only thing it does is to produce a binary program as a 
compiler avoiding than the final users can easily view or modify the 
source code, but the users can still copy those binary files.

In the real world (tm) there's no effective protection for this kind of 
things. All inviolable protections for programs has been broken sooner 
than later since the first computer program code has been closed to 
today, even those based on hardware artifacts (as port-key devices).


Thankyou all, i will check out the links, and especially the zend
encoder page ;-)
 

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


[PHP] Add methods to object dinamically

2004-10-26 Thread Francisco M. Marzoa Alonso
I've seen that's possible to add members to objects dinamically, in example:
class MyClass {
   private $a;
}
$MyObject = new MyClass ();
$MyObject-b = 1;
Now $MyObject has a public member called 'b' that has a value of '1'.
The question is, is it possible to add methods in the same way?
I meant something such as:
function sum ( $this ) {
   return $this-a+$this-b;
}
$MyObject-sum = sum;
Note that code will not work, but it illustrates what I'm asking for.
TIA.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Convert an array in an object instance

2004-10-25 Thread Francisco M. Marzoa Alonso
Hi,
Is it possible to convert an array in an object instance?
I can convert an object in an array as follows:
$Test = new MyClass ();
$TestArray = (array) $Test;
Then I've an array with all members of the object $Test, but it seems
that I cannot simply do:
$TestObject = (MyClass) $TestArray;
To recover the object in the inverse way, so... is there any manner to
do this?
Thanks a lot in advance,
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Substr

2004-10-25 Thread Francisco M. Marzoa Alonso
Use regular expresions:
?php
$string = pid_1_date_2004_10_25;
preg_match ( '/^pid_(.*?)_date_(.*?)$/', $string, $regs );
print_r ($regs);
?
Shaun wrote:
Hi,
I have a string as follows: pid_1_date_2004_10_25
pid tells me the Project_ID and date tells me the date(!). I need to extract 
this information from the string so to get the date I need everything after 
'date_' as follows:

substr(strstr($key, 'date_'), 4)
However, to get the Project ID I need to extract everything after 'pid_' and 
everything before 'date_'. Can someone help me with this please as PHP 
doesn't seem to provide a function for extracting information from a string 
that occurs before the 'needle'? 

 

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


Re: [PHP] Substr

2004-10-25 Thread Francisco M. Marzoa Alonso
You can also use split function if you do not know about regular 
expressions and do not want to learn:

?php
$string = pid_1_date_2004_10_25;
$regs = split (_, $string );
print_r ($regs);
?
I think its autoexplicative.
Shaun wrote:
Hi,
I have a string as follows: pid_1_date_2004_10_25
pid tells me the Project_ID and date tells me the date(!). I need to extract 
this information from the string so to get the date I need everything after 
'date_' as follows:

substr(strstr($key, 'date_'), 4)
However, to get the Project ID I need to extract everything after 'pid_' and 
everything before 'date_'. Can someone help me with this please as PHP 
doesn't seem to provide a function for extracting information from a string 
that occurs before the 'needle'? 

 

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


Re: [PHP] Re: Convert an array in an object instance

2004-10-25 Thread Francisco M. Marzoa Alonso
[EMAIL PROTECTED] wrote:
No. You need to remember that in most cases where you cast a variable from
one type to another, you will experience data (precision) loss. This is
also the case in converting an object to an array. Only the properties are
copied over (since functions can not be part of an array). 

The point is interesting, but as far as I do not need to store class 
methods I think there's nothing lost between conversion. I'll store the 
name of the class of the instance, so the methods of the instance will 
be those of that class. I only need some manner to tell PHP that the 
object is an instance of MyClass (following the original example) to 
have the object exactly equal as it was before conversions.

Perl has a function to to that, that's called bless:
http://www.perldoc.com/perl5.6/pod/func/bless.html
FYI, the reason I need this is because I'm creating my own object's 
serialization routines.

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


Re: [PHP] Re: Convert an array in an object instance

2004-10-25 Thread Francisco M. Marzoa Alonso
Marek Kilimajer wrote:
Francisco M. Marzoa Alonso wrote:
[EMAIL PROTECTED] wrote:
No. You need to remember that in most cases where you cast a 
variable from
one type to another, you will experience data (precision) loss. This is
also the case in converting an object to an array. Only the 
properties are
copied over (since functions can not be part of an array).

The point is interesting, but as far as I do not need to store class 
methods I think there's nothing lost between conversion. I'll store 
the name of the class of the instance, so the methods of the instance 
will be those of that class. I only need some manner to tell PHP that 
the object is an instance of MyClass (following the original 
example) to have the object exactly equal as it was before conversions.

Perl has a function to to that, that's called bless:
http://www.perldoc.com/perl5.6/pod/func/bless.html
FYI, the reason I need this is because I'm creating my own object's 
serialization routines.

$obj = new MyClass;
foreach($array as $key = $val) $obj-$key = $val;
Not very elegant but the only way as far as I know
Its an interesting workaround, but that doesn't work with classes that 
has mandatory arguments on its constructors. :-(

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


Re: [PHP] Re: Convert an array in an object instance

2004-10-25 Thread Francisco M. Marzoa Alonso
Curt Zirzow wrote:
* Thus wrote Francisco M. Marzoa Alonso:
 

FYI, the reason I need this is because I'm creating my own object's 
serialization routines.
   

Why would you want to do this?
 

I was walking through the forest when, suddenly, a white light comes 
from the west through the trees calling me. Who are you? What do you 
want from me? -I said- You!, bastard!!!, do your own serialization 
routines!!...

That, and the fact that PHP standard serialization functions does not 
fit my needs, did finally convince me to do it ;-) but I did not find a 
way to bless O:-) my objects as in Perl... wait a minute! perhaps that 
Holy voice wants to show me that objects cannot be blessed in PHP!... 
I'm scared...

Curt
 

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


[PHP] Serializing objects with protected members

2004-10-22 Thread Francisco M. Marzoa Alonso
Hi,
I'm trying to wrote my own serialization routines and I've found a 
previsible problem: protected members are not visible to my 
serialization routine. This is ok and it should be as is, but I've seen 
that PHP's serialize function have access to that members anyway, so the 
question is: Is there any kind of hack that I can use to access those 
variables from my own serialization routine?

Thx. a lot in advance,
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] change server unix-win

2004-10-20 Thread Francisco M. Marzoa Alonso
Just a point: this will be a problem if they have some forward slashes 
that are not specifying file paths, i.e. URLs in the code like 
http://www.whereveryouwant.com/ will be substituted by 
http:\\www.whereveryouwant.com\


Greg Donald wrote:
On Wed, 20 Oct 2004 13:17:08 +0200, Patrick Fehr [EMAIL PROTECTED] wrote:
 

I have a serious problem:
The client want's to emigrate the webhosting from a unix server to a windows
server. Now my biggest problem are the path's.
Is there a way to fast convert all the /root-style directories into the
windows standard \  ??
Thanks for your consideration, I have the strong feeling that this is much
work coming.
   

A small sed script would easily handle this conversion.  I doubt you
have any of those on windows so I'd do the conversion before moving.
for file in *.php; do
cp $file $file.tmp
sed -e s/\///g $file.tmp $file
rm $file.tmp
done
Remember on windows you will be dealing with backslashes instead of
forward slashes, and you have to escape the backslashes with
backslashes.
$path = '/usr/local/blah';
will be something like:
$path = 'c:\\inetpub\\www';
 

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


[PHP] Nesting level too deep - recursive dependency?

2004-10-18 Thread Francisco M. Marzoa Alonso
This code:
?php
class TestClass {
public $myself;
function __construct () {
$this-myself = $this;
}
}
$TestObj = new TestClass ();
if ( $TestObj-myself == $TestObj ) {
echo They are same.\n;
}
?
Gives me a Fatal error: Nesting level too deep - recursive dependency?
on line #13: if ( $TestObj-myself == ...)
Could this be a PHP bug or I'm doing something wrong?
FYI:
PHP Version 5.0.2
PHP API 20031224
PHP Extension 20040412
Zend Extension 220040412
Server API Apache 2.0 Handler
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Nesting level too deep - recursive dependency?

2004-10-18 Thread Francisco M. Marzoa Alonso
Can someone tell me if I should fill a bug report about this or is it my 
fault???

Francisco M. Marzoa Alonso wrote:
This code:
?php
class TestClass {
public $myself;
function __construct () {
$this-myself = $this;
}
}
$TestObj = new TestClass ();
if ( $TestObj-myself == $TestObj ) {
echo They are same.\n;
}
?
Gives me a Fatal error: Nesting level too deep - recursive dependency?
on line #13: if ( $TestObj-myself == ...)
Could this be a PHP bug or I'm doing something wrong?
FYI:
PHP Version 5.0.2
PHP API 20031224
PHP Extension 20040412
Zend Extension 220040412
Server API Apache 2.0 Handler
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Nesting level too deep - recursive dependency?

2004-10-18 Thread Francisco M. Marzoa Alonso
Ah, OK thanks for your advice Chris.
Chris Dowell wrote:
Francisco
You really need to post this to [EMAIL PROTECTED] - this list is 
for us lowly users of PHP, the developers and maintainers of the 
language have their own list.

Cheers
Chris
Francisco M. Marzoa Alonso wrote:
Can someone tell me if I should fill a bug report about this or is it 
my fault???

Francisco M. Marzoa Alonso wrote:
This code:
?php
class TestClass {
public $myself;
function __construct () {
$this-myself = $this;
}
}
$TestObj = new TestClass ();
if ( $TestObj-myself == $TestObj ) {
echo They are same.\n;
}
?
Gives me a Fatal error: Nesting level too deep - recursive 
dependency?
on line #13: if ( $TestObj-myself == ...)

Could this be a PHP bug or I'm doing something wrong?
FYI:
PHP Version 5.0.2
PHP API 20031224
PHP Extension 20040412
Zend Extension 220040412
Server API Apache 2.0 Handler


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