Re: [PHP] No SSL support in core functions with shared extensions

2004-08-31 Thread Curt Zirzow
* Thus wrote Michael Ranner:
 Hello!
 
 Warning: fsockopen(): no SSL support in this build 
 in /usr/local/www/squirrelmail/functions/imap_general.php on line 445
 
 If I build PHP with --with-openssl=${OPENSSLBASE} SSL is supported by 
 fsockopen(), but with --with-openssl=shared,${OPENSSLBASE} fsockopen() 
 gives me the above error message.

Is php loading the openssl.so file, via extension=openssl.so?
Check the output of phpinfo() and look for openssl in the list of
modules that are loaded.


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

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



Re: [PHP] Time consumed in microseconds

2004-08-31 Thread Karam Chand
Darn missed it. Looking into the docs I am using code
somthing like this:

$start   = microtime();
$result  = mysql_query ( $query, $mysql );
$end = microtime();

$diff   =  microtime_diff ($start, $end);

function microtimdiff() is given by:

function microtime_diff($a, $b)
{
   list($a_dec, $a_sec) = explode( , $a);
   list($b_dec, $b_sec) = explode( , $b);

   return ((float)$b_sec - (float)$a_sec +
(float)$b_dec - (float)$a_dec);
}

The result from one operation is like:

$start = 0.26562800 1093931165
$end = 0.26813400 1093931165
$diff = 0.002506

So to get the difference in ms I have to multilply
$diff by 1000. 

Am I correct?

Regards,
Karam

--- John Holmes [EMAIL PROTECTED] wrote:

 Karam Chand wrote:
  In Win32 API to profile a job we use the following
  method:
  
  
   timetaken = GetTickCount();
   /* do some job */
   timetaken = GetTickCount() - timetaken;
  
  In this way timetaken returns you the time taken
 by
  the job to complete?
  
  How can I get it in PHP. I want the exact figure
 in
  ms? I used microtime() and the samples given in
  php.net but none of them correctly returns the
  difference only in ms?
 
 Read the manual page again. Use the example to get
 the microtime as a 
 float at the start and then after your job. Subtract
 to get the 
 difference. If you're using PHP5, just use
 microtime(TRUE); to get the 
 float value.
 
 -- 
 
 ---John Holmes...
 
 Amazon Wishlist:
 www.amazon.com/o/registry/3BEXC84AB3A5E/
 
 php|architect: The Magazine for PHP Professionals –
 www.phparch.com
 
 
 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



Re: [PHP] No SSL support in core functions with shared extensions

2004-08-31 Thread Michael Ranner
Am Dienstag, 31. August 2004 08:18 schrieb Curt Zirzow:
 * Thus wrote Michael Ranner:
  Hello!
 
  Warning: fsockopen(): no SSL support in this build
  in /usr/local/www/squirrelmail/functions/imap_general.php on line 445
 
  If I build PHP with --with-openssl=${OPENSSLBASE} SSL is supported by
  fsockopen(), but with --with-openssl=shared,${OPENSSLBASE}
  fsockopen() gives me the above error message.

 Is php loading the openssl.so file, via extension=openssl.so?
 Check the output of phpinfo() and look for openssl in the list of
 modules that are loaded.

Yes, openssl.so is loaded, openssl functions are there but no SSL support in 
fsockopen().

-- 
/\/\ichael Ranner

[EMAIL PROTECTED] - [EMAIL PROTECTED] - [EMAIL PROTECTED]
--
JAWA Management Software GmbH - http://www.jawa.at/
  Liebenauer Hauptstrasse 2oo - A-8041 Graz
Tel +43 316 403274 21 - Fax +43 316 403274 10
--
 Mariazell Online - http://www.mariazell.at/
--

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



[PHP] Re: No SSL support in core functions with shared extensions

2004-08-31 Thread Michael Ranner
Am Dienstag, 31. August 2004 06:32 schrieben Sie:
 A) I have never done, nor seen, a FBSD port build with a
 tag=value,value construct before, but perhaps it does work?

Yes it builds the shared extension, look at configure --help

 B) Using PHP5 as a reference instead of PHP4, the ext/openssl/configure
 reports:

  --with-openssl=DIR

This builds the static openssl extension, as the old style port does it. But 
using openssl as shared extension, fsockopen() did not use SSL or TLS.

So my question is, will anyone experience the same problem if using shared 
extensions e.g. for openssl.

-- 
/\/\ichael Ranner

[EMAIL PROTECTED] - [EMAIL PROTECTED] - [EMAIL PROTECTED]
--
JAWA Management Software GmbH - http://www.jawa.at/
  Liebenauer Hauptstrasse 2oo - A-8041 Graz
Tel +43 316 403274 21 - Fax +43 316 403274 10
--
 Mariazell Online - http://www.mariazell.at/
--

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



[PHP] Bitwise operations criticism needed

2004-08-31 Thread Gerard Samuel
The situation.
Im currently using a home brewed groups permission code in my site,
but for limited users/groups its ok.  Beyond that, the code will take 
the fast road to hell.
I started to look in depth at bitwise operations today,
and after much googling, and looking at other code, came up with this
mock up, of a basic permissions routine (not neccessarilly the final 
product), that utilizes bitwise operations.

Im looking for advise, to see if Im heading in the right way, and/or 
improvements with this.
Thanks for your time...

-- start code --
?php
$perm = $user = array();
$perm_total = 0;
// Permissions from some source like a database/file
$perm['execute'] = 1;
$perm['write']   = 2;
$perm['read']= 4;
// User permissions (predetermined) from sessions maybe
$user['tom']= 7;  // rwx
$user['joe']= 5;  // rx
$user['dirty_harry']= 9;  // illegal in this case??
$user['whats_his_face'] = 6;  // rw
// Set the sum of source permissions
foreach($perm as $value)
{
$perm_total |= $value;
}
echo ul;
// Loop over the users
foreach($user as $id = $user_perm)
{
// User permissions should be between 1  7, else set it to 0
if ($user_perm  $perm_total || $user_perm  0)
{
$user_perm = 0;
}
// Compare user bits to permission bits
$compare = $perm_total  $user_perm;
// Make it an even 4 bit string (for visual effect)
$bits_string = sprintf(%03d, decbin( $compare ));
echo liUser:  . $id . /li;
// Check to see if the comparision contains any permission bits
$can_read= (($compare  $perm['read']) == $perm['read']) === 
TRUE ? TRUE : FALSE;
$can_write   = (($compare  $perm['write']) == $perm['write']) === 
TRUE ? TRUE : FALSE;
$can_execute = (($compare  $perm['execute']) == $perm['execute']) 
=== TRUE ? TRUE : FALSE;

echo ul;
echo li . $user_perm . ' - ' . $bits_string . /li;
echo liCan Read: $can_read/li;
echo liCan Write: $can_write/li;
echo liCan Execute: $can_execute/li;
echo /ul;
}
echo /ul;
?
-- end code --
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Bitwise operations criticism needed

2004-08-31 Thread Marek Kilimajer
Gerard Samuel wrote:
The situation.
Im currently using a home brewed groups permission code in my site,
but for limited users/groups its ok.  Beyond that, the code will take 
the fast road to hell.
I started to look in depth at bitwise operations today,
and after much googling, and looking at other code, came up with this
mock up, of a basic permissions routine (not neccessarilly the final 
product), that utilizes bitwise operations.

Im looking for advise, to see if Im heading in the right way, and/or 
improvements with this.
Thanks for your time...

-- start code --
?php
$perm = $user = array();
$perm_total = 0;
// Permissions from some source like a database/file
$perm['execute'] = 1;
$perm['write']   = 2;
$perm['read']= 4;
// User permissions (predetermined) from sessions maybe
$user['tom']= 7;  // rwx
$user['joe']= 5;  // rx
$user['dirty_harry']= 9;  // illegal in this case??
9 is 1001, so if you ignore fourth bit, it's equal to 1. Some day you 
might want to add other permission rights using other bits.

$user['whats_his_face'] = 6;  // rw
// Set the sum of source permissions
foreach($perm as $value)
{
$perm_total |= $value;
}
echo ul;
// Loop over the users
foreach($user as $id = $user_perm)
{
These 2 pieces of code:
// User permissions should be between 1  7, else set it to 0
if ($user_perm  $perm_total || $user_perm  0)
{
$user_perm = 0;
}
and
// Compare user bits to permission bits
$compare = $perm_total  $user_perm;
do the same thing, and are quite useless, the code will work without it. 
If you extend the rights one day, you would have to modify it.

// Make it an even 4 bit string (for visual effect)
$bits_string = sprintf(%03d, decbin( $compare ));
echo liUser:  . $id . /li;
// Check to see if the comparision contains any permission bits
$can_read= (($compare  $perm['read']) == $perm['read']) === 
TRUE ? TRUE : FALSE;
$can_write   = (($compare  $perm['write']) == $perm['write']) === 
TRUE ? TRUE : FALSE;
$can_execute = (($compare  $perm['execute']) == $perm['execute']) 
=== TRUE ? TRUE : FALSE;

echo ul;
echo li . $user_perm . ' - ' . $bits_string . /li;
echo liCan Read: $can_read/li;
echo liCan Write: $can_write/li;
echo liCan Execute: $can_execute/li;
echo /ul;
}
echo /ul;
?
-- end code --
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Problem sending mail

2004-08-31 Thread Zoran Lorkovic
 Zoran Lorkovic wrote:

  $file = file_get_contents(text.inc);
  $start = [start];
  $end = [/end];
  $pos_start = strpos ($file, $start);
  $pos_end = strpos ($file, $end);
  $data = substr ($file, $pos_start, $pos_end);
  mail ([EMAIL PROTECTED], My Subject, $data);
 
 
  This code works when I call it from browser, but when I call it from
command line, $data is not put into mail
  (mail is send but it is empty, without any data in body).
 
 that would depend from which place you run the script.
 file_get_contents(text.inc) will be looked for in:
 1. the current working directory
 2. the included dirs

 So, if you're running the script like:
 [EMAIL PROTECTED] /]# cd /
 [EMAIL PROTECTED] /]# php -q /var/www/html/scripts/mail.php
 then you're actually working in /, so it's looking for text.inc in:
 /text.inc and in all include-paths.

Yeah! Of course. This was the problem.
Script and text file were in 'mydir/public_html' but I call script from
'mydir' so I script looks for text file in 'mydir' because of $file =
file_get_contents(text.inc);
For the quick test I've changed this to:
$file = file_get_contents(public_html/text.inc);
and now it's working. Thanks a lot!

Regards.
Zoran

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



Re: [PHP] Re: Instantiating class, classname in constant

2004-08-31 Thread Wouter van Vliet
Quoting Catalin Trifu [EMAIL PROTECTED]:
  ?php
  class Foo {
   const Bar   = 'Foo_Bar';
   const Chocolate = 'Foo_Chocolate';
   const Target= 'Foo Target';
  }
 
  $bar = new Foo::Bar();
  ?

 Foo::Bar() is taken by php as a function call and then it tries to
 instantate whatever that function returns.
 This is quite logical behaviour since function calls always end up with
 ().
 When you call
 $bar = new Foo::Bar;
 then the Foo::Bar is definetely refering to constant Bar in class Foo

 Cheers,
 Catalin
First of all: thank you Catalin for your thoughts!

Seems logical from that point of view.

According to the list if differences between variables and constants
(http://nl2.php.net/manual/en/language.constants.php) though, they should
pretty much work the same (no difference is mentioned). Thus, when both $bar
and Foo::Bar evaluate to the same value I would expect PHP to do the same
thing. Let me at least hope that the php team has considered many options on
how to deal with this...

If I do want to use the :: notation between PackageName and the actual name of
the class, I'm probably gonna be stuck using smth like:

?php
class Foo {
  public static function Bar() {
return new Foo_Bar();
  }
}
?

Or smth with the __call() function and an (iew) eval() call, since
call_user_func_array() doesn't work on constructors (or so I heard, haven't
tried it).

--
Always consider all options before deciding which object to talk to

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



[PHP] Creating a zip and pumping it through the headers - ERROR

2004-08-31 Thread Thomas Hochstetter
Hi again,
 
After a clever question follows a dumb one: :-(
 
I am trying to pack a few resources from off the server, zip them together
(at this stage still storing in a tmp folder and afterwards deleting it
again) and make the freshly created zip file available to the user via a
'Save File' prompt. Now I have searched the archives a bit and have read the
suggestions in the extended chm version of the manual TWICE, but still, I
don't seem to be able to get rid of this one stupid problem:
 
The zip gets created fine, but when I readfile() it and pump it through the
headers it adds the whole html (which the server sent to the browser - not
the php code) and so corrupts the zip file. I have read about suggestions to
these issues, implemented these suggestion and still sit with it.
 
I am using Apache 1.3.20, PHP 4.3.2 and mySQL on a Windows stove. The
browsers I have tested this on was IE6 and Opera 7 . both acted the same
way. This got me thinking that: maybe I am doing something wrong . ;-)
 
So here is the method I am using to pack and send the stuff .
 
[code]
function PackAndSend( )
{
include_once( realpath(classes/pclzip.lib.php) );

$filePath = realpath( tmp/zips/. substr( md5( $_GET[file] ),
0, 5 ) ..zip );

$zip = new PclZip( $filePath );
$zip-create( realpath(files/papers/$_GET[file]),
Resources/Docs ID [$_GET[file]], files/papers/ );

$fz = filesize( $filePath );
$mime_type = application/zip;

header('Pragma: public'); // IE specific
header('Cache-Control: private');
header('Cache-Control: no-cache, must-revalidate');
header('Accept-Ranges: bytes');
header('Content-Length: ' . $fz);
header('Content-Type: $mime_type');
header('Content-Disposition: attachment;
filename=Resources.zip');

@readfile( $filePath );
unlink( $filePath );
$GLOBALS['COPE_LOG']-devLog();
}
[/code]
 
The headers sequence I have tried with many others . all did not do anything
different.]
 
Help would be appreciated.
 
Thomas


[PHP] CMS, Seperation of concerns - the Cocoon style

2004-08-31 Thread Thomas Hochstetter
Hi there,
 
I was thinking about this a lot today and was wondering if there are any
people here on this list that have experimented with this:
 
I hope you know what Cocoon does. If I can just sum up what I am concerned
about:
 
*   Separation of concerns (i.e. Design, Content and Logic are
COMPLETELY separate entities)
*   Pipelining xml to create out of one content file many other,
semantically different files (like xhtml, pdf, wml .)
*   To use such a system as a generic template system, say for
Conferences
 
What is was now wondering about is, what would be the best practice here. I
have read a little up on the use of PHP in combination with Cocoon 2, and it
looks like that there are a few ways of doing this. 
 
Question: the reason why I went the PHP and not the XSP way was because of
the huge complexity and slowness of Cocoon (jsp, xsp, servlets) compared to
PHP. So now the combination of the two still does not sound feasible, or
does it not matter much? The fact still remains that xml transformations
nibble CPU time. Then there is also Java involved. :-/
 
A second option would be to write my own PHP 5 driven XML
transformers/template engine (I would not dare to say that I could do so!).
I know that PHP 5 has got a hugely improved XML and DOM interface. And one
could possibly combine this with PEAR classes and Smarty (or something
similar).
 
Then there are things like . err, forgot the name, but there is an open
source project out there that emulates what Cocoon does (separation of
concerns and pipelining), by using only PHP.
 
I am quite keen on getting some sort of backbone going where I can create,
manipulate pdf's and even stuff like Word files and rtfs. I am still
mesmerized by the whole XML idea. Some people talk about it having failed
the web . hmmm, not sure of that. Maybe it's just not been tried enough?
 
So, any inputs on that? I would not mind going the java route, just prefer
rapid development over: asant - asant deploy - asant undeploy - asant clean
.. And so on .
 
Thanks,
 
Thomas
 


Re: [PHP] Creating a zip and pumping it through the headers - ERROR

2004-08-31 Thread Marek Kilimajer
Thomas Hochstetter wrote:
Hi again,
 
After a clever question follows a dumb one: :-(
 
I am trying to pack a few resources from off the server, zip them together
(at this stage still storing in a tmp folder and afterwards deleting it
again) and make the freshly created zip file available to the user via a
'Save File' prompt. Now I have searched the archives a bit and have read the
suggestions in the extended chm version of the manual TWICE, but still, I
don't seem to be able to get rid of this one stupid problem:
 
The zip gets created fine, but when I readfile() it and pump it through the
headers it adds the whole html (which the server sent to the browser - not
the php code) and so corrupts the zip file. 
Either output html or the zip file, never both.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] CMS, Seperation of concerns - the Cocoon style

2004-08-31 Thread Christian Stocker
You maybe want to have a  look at Popoon - Cocoon for PHP ...

Documentation is sparse, but see:
http://www.bitflux.ch/developer/cms/popoon.html

It's for PHP 5 only in the meantime.

If you have any questions, just ask

chregu

On Tue, 31 Aug 2004 11:37:39 +0200, Thomas Hochstetter
[EMAIL PROTECTED] wrote:
 Hi there,
 
 I was thinking about this a lot today and was wondering if there are any
 people here on this list that have experimented with this:
 
 I hope you know what Cocoon does. If I can just sum up what I am concerned
 about:
 
 *   Separation of concerns (i.e. Design, Content and Logic are
 COMPLETELY separate entities)
 *   Pipelining xml to create out of one content file many other,
 semantically different files (like xhtml, pdf, wml .)
 *   To use such a system as a generic template system, say for
 Conferences
 
 What is was now wondering about is, what would be the best practice here. I
 have read a little up on the use of PHP in combination with Cocoon 2, and it
 looks like that there are a few ways of doing this.
 
 Question: the reason why I went the PHP and not the XSP way was because of
 the huge complexity and slowness of Cocoon (jsp, xsp, servlets) compared to
 PHP. So now the combination of the two still does not sound feasible, or
 does it not matter much? The fact still remains that xml transformations
 nibble CPU time. Then there is also Java involved. :-/
 
 A second option would be to write my own PHP 5 driven XML
 transformers/template engine (I would not dare to say that I could do so!).
 I know that PHP 5 has got a hugely improved XML and DOM interface. And one
 could possibly combine this with PEAR classes and Smarty (or something
 similar).
 
 Then there are things like . err, forgot the name, but there is an open
 source project out there that emulates what Cocoon does (separation of
 concerns and pipelining), by using only PHP.
 
 I am quite keen on getting some sort of backbone going where I can create,
 manipulate pdf's and even stuff like Word files and rtfs. I am still
 mesmerized by the whole XML idea. Some people talk about it having failed
 the web . hmmm, not sure of that. Maybe it's just not been tried enough?
 
 So, any inputs on that? I would not mind going the java route, just prefer
 rapid development over: asant - asant deploy - asant undeploy - asant clean
 .. And so on .
 
 Thanks,
 
 Thomas
 
 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

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



[PHP] Form Spoofing - How?

2004-08-31 Thread Nick Wilson
Hi everyone

I've been asked to make a php script to automatically fill out and
submit a form on a remote site. I know this is possible, but have no
idea where to begin

So, my question is: What functions/theories/etc should I start looking
at in order to get started on this?

Much thanks for your help ;-)
-- 
Nick W

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



Re: [PHP] Form Spoofing - How?

2004-08-31 Thread Marek Kilimajer
Nick Wilson wrote:
Hi everyone
I've been asked to make a php script to automatically fill out and
submit a form on a remote site. I know this is possible, but have no
idea where to begin
So, my question is: What functions/theories/etc should I start looking
at in order to get started on this?
Much thanks for your help ;-)
Check out the various HTTP classes, they have features for submiting forms.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Form Spoofing - How?

2004-08-31 Thread Nick Wilson

* and then Marek Kilimajer declared
 So, my question is: What functions/theories/etc should I start looking
 at in order to get started on this?
 
 Check out the various HTTP classes, they have features for submiting forms.


Great, where do I find them?

thanks!

-- 
Nick W

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



Re: [PHP] Form Spoofing - How?

2004-08-31 Thread Marek Kilimajer
Nick Wilson wrote:
* and then Marek Kilimajer declared
So, my question is: What functions/theories/etc should I start looking
at in order to get started on this?
 

Check out the various HTTP classes, they have features for submiting forms.

Great, where do I find them?
thanks!
google ... pear, phpclasses.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] writing a pdf file to the filesystem

2004-08-31 Thread Merlin
Hi there,
I am trying to write a pdf file which is created by a php script to the 
filesystem.

Here is the end of the php file which creates the pdf document:
.
.
.
$pdf_close($pdf);
$data = pdf_get_buffer($pdf);
Can anybody tell me how to save the file instead of printing it out 
directly?

Thank you for any hint,
Merlin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Form Spoofing - How?

2004-08-31 Thread Nick Wilson

* and then Marek Kilimajer declared
 So, my question is: What functions/theories/etc should I start looking
 at in order to get started on this?
 
 Check out the various HTTP classes, they have features for submiting 
 forms.
 
 Great, where do I find them?
 
 google ... pear, phpclasses.org

hehe, i know how to google, sorry, badly phrased! I meant where is the
best place, i found phpclasses and am *trying* to download what looks
like the exact thing I need the advanced http client class. Comes with
a nice example script for posting forms too, luvverly! ;)

Thanks very much m8

-- 
Nick W

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



Re: [PHP] writing a pdf file to the filesystem

2004-08-31 Thread Stut
On Tue, 31 Aug 2004 12:58:49 +0200, Merlin [EMAIL PROTECTED] wrote:
 I am trying to write a pdf file which is created by a php script to the
 filesystem.
 
 Here is the end of the php file which creates the pdf document:
 
 $pdf_close($pdf);
 $data = pdf_get_buffer($pdf);

$fp = fopen('file.pdf', 'w');
if ($fp)
{
fwrite($fp, $data);
fclose($fp);
}
else
print 'Failed to open file for writing';

-- 
Stut

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



[PHP] [PHP5]__get, __set and isset()

2004-08-31 Thread Frédéric Hardy
Is it possible to do something like this :
class foo
{
private $array = array();
function __construct()
{
...
}
function __get($key)
{
return (isset($this-array[$key]) == false ? null : 
$this-array[$key]);
}
function __set($key, $value)
{
$this-array[$key] = $value;
}
}
$foo = new foo();
if (isset($foo-bar) == false)
$foo-bar = 'bar';
else
echo $foo-bar;
It seems that isset($foo-bar) return ALWAYS false.
Bug ?
Fred.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Closing my Window after Download

2004-08-31 Thread PHP Junkie
Ave,

I hear you... Even I feel it's a different problem but I don't know what.
My first thought was that HTML or anything doesn't work after the
Force-Download script in general But since you seem to use it, I guess
it does.

Now I don't know what to do, how to make it work. I can't understand what
exactly is causing the problem.

Thanks though.



On 8/30/04 7:13 PM, Jasper Howard [EMAIL PROTECTED] wrote:

 if you're not getting any html after your php script, then there's a
 different problem. I do the same thing and all I use is:
 
 ?php
 ...
 ?
 script language=javascript
 !--
 window.close();
 //--
 /script
 
 and I've never had a problem with it not closing...



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



Re: [PHP] Closing my Window after Download

2004-08-31 Thread PHP Junkie
Ave,

I didn't quite understand what you meant.
The kind of files being saved by this script range from ZIP files to DBF
files to JPG files etcetera. Where will the HTML be in those saved files?

Any suggestions on what I need to do to make this work?



On 8/30/04 8:31 PM, Curt Zirzow [EMAIL PROTECTED] wrote:

 * Thus wrote PHP Junkie:
 Ave,
 
 It still doesn't work. Not only that, I put up a close window button in
 the page and even that doesn't show up. Although that's still not what I
 want. What I want is the window to close automatically.
 
 Here's my page:
 
 ?php
 $file = $P/$F;
 header(Content-Description: File Transfer);
 header(Content-Type: application/force-download);
 header(Content-Disposition: attachment; filename=.basename($file));
 @readfile($file);
 ? 
 html
 head
 titleD/L Window/title
 script language=javascript
 function close_opener()
 
 Take a look at the end of the file you saved, you'll see your html
 there.
 
 Curt

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



Re: [PHP] Storing image in database

2004-08-31 Thread raditha dissanayake
Dre wrote:
Hi ..
I'm trying to save and view image files in a MySQL database, I made the save
operation successfully, I stored the image file name, type, size and the
image file itself
the problem occurred when I tried to retrieve the image data I've previously
stored, in specific when I tried to preview the image file
I tried to make something like the following but it did not work
 

while solutions are being offered, may i bring to your kind attention 
the fact that storing images in a database is woefully inefficient.

--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] [Newbie Guide] For the benefit of new members

2004-08-31 Thread raditha dissanayake
Jason Wong wrote:
On Tuesday 31 August 2004 07:06, Brent Clements wrote:
 

Damn, I just felt the wrath of the list even though I completely agree with
you guys, I was just pointing out some employers requirements.
   

Wrath? What wrath? You ain't seen nuthin yet. I think all we're pointing out 
is that it takes just a little common sense and a little common courtesy to 
both comply with your employee's requirements AND and the same time not annoy 
the list.
 

you aint seen nothing yet.
You will  wrath when you gently point out to someone that this is not 
the place for javascript questions, or apache questions, or mysql 
questions or questions about where to pay your traffic fine.


--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] quoted_printable_encode

2004-08-31 Thread raditha dissanayake
Bambero wrote:
What do you think about this function ?
nothing much.
--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Time consumed in microseconds

2004-08-31 Thread raditha dissanayake
Karam Chand wrote:
Darn missed it. Looking into the docs I am using code
somthing like this:
 

If you are really keen about chaning +1 to ++  and double quotes to 
single quotes in the hope of shaving off a few milliseconds in execution 
time you might want to try something like xdebug.

--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Problems with writing a stream wrapper to regular fopen/close functions...

2004-08-31 Thread John Holmes
From: Curt Zirzow [EMAIL PROTECTED]
change return to:
 return ($this-fp? true: false);
technically, internally the function is treated as
 function stream_open(...)
and will convert the value to a boolean value as you were
experiencing.
Dammit... I knew that whole this method should return TRUE or FALSE would 
come back to bite me on the ass... Thanks for the tip, it works now, of 
course.

---John Holmes... 

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


[PHP] Help with Strings Please

2004-08-31 Thread Nick Wilson
Hi, 

I have a string like this, read from an html file: ' VALUE=16'
The value could be any number. I am trying to get that number.

I have this so far, i was hoping someone might tell me how to get that
number:


?php

  $handle = fopen(page.php, r);
  while (!feof($handle)) {
$buffer .= fgets($handle, 4096);
  }
  fclose($handle);

  $result = stristr($buffer, 'NAME=c');
  print (Result:br /.$result);

?

Im not very good at regex, is there an function that would help me?
(couldnt see one...)

thx...

-- 
Nick W

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



Re: [PHP] open_basedir / not working after upgrade

2004-08-31 Thread Federico Petronio
Ed Lazor wrote:

Directory /apache2/htdocs/horde 
  php_admin_flag safe_mode off
  php_admin_value upload_tmp_dir /tmp
  php_admin_value open_basedir /
/Directory
.
But after setting
   php_admin_value open_basedir none
instead of
   php_admin_value open_basedir /
the problem disappeared.
I just want to know the exact meaning of that directive.

From php.ini

Are you assuming that / refers to /apache2/htdocs/horde ?
No. As I understand it means:
All php scripts inside '/apache2/htdocs/horde' could access to any file 
inside '/'. Which is the same as letting the webmail access any file it 
needs in the filesystem.

Since each virtualhost is restricted to its home directory, and webmail 
is common for all the virtualhosts (http://virtualhost/webmail), I 
needed to define a rule in a directory basis to let the webmail system 
access more than just the file inside the virtualhost home.

Currently I only want to know the exact meaning of:
open_basedir none

--
Federico Petronio
[EMAIL PROTECTED]
Linux User #129974
---
There are only 10 types of people in the world:
  Those who understand binary and those who don't.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Help with Strings Please

2004-08-31 Thread Marek Kilimajer
Nick Wilson wrote:
Hi, 

I have a string like this, read from an html file: ' VALUE=16'
The value could be any number. I am trying to get that number.
I have this so far, i was hoping someone might tell me how to get that
number:
?php
  $handle = fopen(page.php, r);
  while (!feof($handle)) {
$buffer .= fgets($handle, 4096);
  }
  fclose($handle);
  $result = stristr($buffer, 'NAME=c');
  print (Result:br /.$result);
?
Im not very good at regex, is there an function that would help me?
(couldnt see one...)
thx...
preg_match('/value\s*=\s*([0-9]+)/i', $buffer, $result);
print (Result:br /.$result[1]);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Help with Strings Please

2004-08-31 Thread Justin French
Nick,
Nick wrote:
I have a string like this, read from an html file: ' VALUE=16'
The value could be any number. I am trying to get that number.
If you have that exact string and you want to extract just the number, 
then a simple regex to delete all non-numeric characters should 
suffice.

I have this so far, i was hoping someone might tell me how to get that
number:
?php
  $handle = fopen(page.php, r);
  while (!feof($handle)) {
$buffer .= fgets($handle, 4096);
  }
  fclose($handle);
  $result = stristr($buffer, 'NAME=c');
  print (Result:br /.$result);
?
Ok, so I don't see ' VALUE=16' in here anywhere -- I think you need 
to be a lot more descriptive about the source content and what exactly 
you want to extract, and provide a few examples, so that we can cover 
all your bases.

Regular Expressions are _probably_ what you need, but you REALLY need 
to provide a decent description and multiple examples of what you want, 
otherwise we're just wasting time.

---
Justin French
http://indent.com.au
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Help with Strings Please

2004-08-31 Thread John Holmes
From: Marek Kilimajer [EMAIL PROTECTED]
  $handle = fopen(page.php, r);
  while (!feof($handle)) {
$buffer .= fgets($handle, 4096);
  }
  fclose($handle);
file_get_contents() could be helpful here, too...
---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Help with Strings Please

2004-08-31 Thread Nick Wilson

* and then Marek Kilimajer declared
 Im not very good at regex, is there an function that would help me?
 (couldnt see one...)
 
 
 preg_match('/value\s*=\s*([0-9]+)/i', $buffer, $result);
 print (Result:br /.$result[1]);

Marek, you're a star ;-)

I *hate* having to ask someone to do my work, mastering regular
expressions' in going on my christmas wish list! hehe... 

thanks again...

PS: Justin, got it covered. Thanks..


-- 
Nick W

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



[PHP] Authors and Instructors Needed

2004-08-31 Thread Keystone Learning Systems
KeyStone Learning Systems (www.keystonelearning.com) is currently seeking subject 
matter experts to work with us to author future courseware titles delivered via 
CD-ROM, VHS, DVD and the Web. 
 

Are you a leading expert or trainer in your field? Do you have a passion or desire to 
teach others?
 
Have you always wanted to be a published author but haven't had the time or 
opportunity to pursue your goal?
 

KeyStone has been working with leading experts for more than 15 years in the areas of 
desktop software, development, programming and certification topics to develop 
computer and video-based courseware. 
 
Our products are used by more than 500,000 active professional users and sold along 
with more than 1,200 course titles in some of the following categories: 
 
  - Professional Certifications, such as MCSE and CCNA 
  - Application and Web Developers, such as Java, SQL and VB.Net 
  - Desktop Applications, such as Microsoft Office, QuickBooks and Publisher 
  - Digital Media Applications, such as Macromedia Flash and Adobe Photoshop 
  - Professional Soft skills, such as Project Management and Accounting 
  - Other Information Technology, Communications and development related courses 
 
 
 
If you are interested in joining our team of leading experts, we encourage you to 
visit our site at http://www.keystonelearning.com/keystone/sme  for additional 
information.
 

Thank you.
 
The KeyStone Team

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



[PHP] Re: [PHP5]__get, __set and isset()

2004-08-31 Thread Daniel Schierbeck
Frédéric hardy wrote:
Is it possible to do something like this :
class foo
{
private $array = array();
function __construct()
{
...
}
function __get($key)
{
return (isset($this-array[$key]) == false ? null : 
$this-array[$key]);
}

function __set($key, $value)
{
$this-array[$key] = $value;
}
}
$foo = new foo();
if (isset($foo-bar) == false)
$foo-bar = 'bar';
else
echo $foo-bar;
It seems that isset($foo-bar) return ALWAYS false.
Bug ?
Fred.
It seems that you are right. I've tried off this code:
?php
class OO
{
private $elem = array(a = 1);

public function __get ($prop)
{
if (isset($this-elem[$prop])) {
return $this-elem[$prop];
} else {
return NULL;
}
}

public function __set ($prop, $val)
{
$this-elem[$prop] = $val;
}
}
$o = new OO();
echo isset($o-a) ? yes\n : no\n;
echo isset($o-b) ? yes\n : no\n;
echo is_null($o-a) ? yes\n : no\n;
echo is_null($o-b) ? yes\n : no\n;
?
I expected something like this:
yes
no
no
yes
But got this:
no
no
no
yes
It looks like isset() can't handle object properties correctly. I'll 
post the bug on php.net.

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


[PHP] Dealer Locater web app

2004-08-31 Thread Sam

Anyone know of a Dealer Locater PHP app that I can buy (or get for free)
other than the one at YourPHPpro
http://phpdealerlocator.yourphppro.com/demo/?

They guys software is great but I've been trying to buy it for a week and
can't get a response from him.

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



Re: [PHP] Authors and Instructors Needed

2004-08-31 Thread John Holmes
Are you a leading expert or trainer in your field? Do you have a passion 
or desire to teach others?
Hi. I am a SME (subject matter expert) at detecting spam and desire to teach 
others to do the same. I have included a sample of what I detected below as 
proof of my expertise. You can contact me at:

*hn[foo]hl!$s(_2_)littler$dpsar%[foo]c!
replacing:
$ with e
 with o
[foo] with .
(_2_) with @
ps with sp
little with big
% with k
! with m
* with j
---John Holmes...
- Original Message - 
From: Keystone Learning Systems [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, August 30, 2004 5:43 PM
Subject: [PHP] Authors and Instructors Needed


KeyStone Learning Systems (www.keystonelearning.com) is currently seeking 
subject matter experts to work with us to author future courseware titles 
delivered via CD-ROM, VHS, DVD and the Web.

Are you a leading expert or trainer in your field? Do you have a passion 
or desire to teach others?

Have you always wanted to be a published author but haven't had the time 
or opportunity to pursue your goal?

KeyStone has been working with leading experts for more than 15 years in 
the areas of desktop software, development, programming and certification 
topics to develop computer and video-based courseware.

Our products are used by more than 500,000 active professional users and 
sold along with more than 1,200 course titles in some of the following 
categories:

 - Professional Certifications, such as MCSE and CCNA
 - Application and Web Developers, such as Java, SQL and VB.Net
 - Desktop Applications, such as Microsoft Office, QuickBooks and 
Publisher
 - Digital Media Applications, such as Macromedia Flash and Adobe 
Photoshop
 - Professional Soft skills, such as Project Management and Accounting
 - Other Information Technology, Communications and development related 
courses


If you are interested in joining our team of leading experts, we encourage 
you to visit our site at http://www.keystonelearning.com/keystone/sme  for 
additional information.

Thank you.
The KeyStone Team
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: [PHP5]__get, __set and isset()

2004-08-31 Thread Frédéric Hardy
Bug Id is 29917.
Fred.
Daniel Schierbeck wrote:
Frédéric hardy wrote:
Is it possible to do something like this :
class foo
{
private $array = array();
function __construct()
{
...
}
function __get($key)
{
return (isset($this-array[$key]) == false ? null : 
$this-array[$key]);
}

function __set($key, $value)
{
$this-array[$key] = $value;
}
}
$foo = new foo();
if (isset($foo-bar) == false)
$foo-bar = 'bar';
else
echo $foo-bar;
It seems that isset($foo-bar) return ALWAYS false.
Bug ?
Fred.
It seems that you are right. I've tried off this code:
?php
class OO
{
private $elem = array(a = 1);

public function __get ($prop)
{
if (isset($this-elem[$prop])) {
return $this-elem[$prop];
} else {
return NULL;
}
}

public function __set ($prop, $val)
{
$this-elem[$prop] = $val;
}
}

$o = new OO();
echo isset($o-a) ? yes\n : no\n;
echo isset($o-b) ? yes\n : no\n;
echo is_null($o-a) ? yes\n : no\n;
echo is_null($o-b) ? yes\n : no\n;
?
I expected something like this:
yes
no
no
yes
But got this:
no
no
no
yes
It looks like isset() can't handle object properties correctly. I'll 
post the bug on php.net.

--
===
Frederic HARDYEmail: [EMAIL PROTECTED]
HEXANET SARL  URL: http://www.hexanet.fr/
ZAC Les CharmillesTel: +33 (0)3 26 79 30 05
3, allée Thierry Sabine   Direct: +33 (0)3 26 61 77 84
BP 202 - 51686 REIMS CEDEX 2 FRANCE
===
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Authors and Instructors Needed

2004-08-31 Thread Nick Wilson

* and then Keystone Learning Systems declared
 Have you always wanted to be a published author but haven't had the time or 
 opportunity to pursue your goal?
  

No, but i've always wanted to be a teapot. Does that count?

-- 
Nick W

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



RE: [PHP] PHP Oficial Certification

2004-08-31 Thread Dan Joseph
Hi,

 As a PHP security advocate for the last few years, I can tell you that
 Curt is absolutely correct. In fact, poor open source applications written
 in PHP are the top reason why PHP is considered insecure by the
 programming community at large. This is a myth that is very difficult to
 dispel, and it shows how powerful perception can be.

Myth it is for sure.  We've passed 7 security audits in a row here.
All PHP systems.

-Dan Joseph

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



Re: [PHP] Bitwise operations criticism needed

2004-08-31 Thread Gerard Samuel
Marek Kilimajer wrote:
Gerard Samuel wrote:
The situation.
Im currently using a home brewed groups permission code in my site,
but for limited users/groups its ok.  Beyond that, the code will take 
the fast road to hell.
I started to look in depth at bitwise operations today,
and after much googling, and looking at other code, came up with this
mock up, of a basic permissions routine (not neccessarilly the final 
product), that utilizes bitwise operations.

Im looking for advise, to see if Im heading in the right way, and/or 
improvements with this.
Thanks for your time...

-- start code --
?php
$perm = $user = array();
$perm_total = 0;
// Permissions from some source like a database/file
$perm['execute'] = 1;
$perm['write']   = 2;
$perm['read']= 4;
// User permissions (predetermined) from sessions maybe
$user['tom']= 7;  // rwx
$user['joe']= 5;  // rx
$user['dirty_harry']= 9;  // illegal in this case??

9 is 1001, so if you ignore fourth bit, it's equal to 1. Some day you 
might want to add other permission rights using other bits.

Yes I may use it some day.  I was trying to simulate an illegal 
permission.  So how should I handle this, if I should handle this???

$user['whats_his_face'] = 6;  // rw
// Set the sum of source permissions
foreach($perm as $value)
{
$perm_total |= $value;
}
echo ul;
// Loop over the users
foreach($user as $id = $user_perm)
{

These 2 pieces of code:
// User permissions should be between 1  7, else set it to 0
if ($user_perm  $perm_total || $user_perm  0)
{
$user_perm = 0;
}

and
// Compare user bits to permission bits
$compare = $perm_total  $user_perm;

do the same thing, and are quite useless, the code will work without it. 
If you extend the rights one day, you would have to modify it.
Ok, I understand what you mean about the if() statement, as its related 
to your previous comment above.
But isn't $compare = $perm_total  $user_perm; needed for this to work?


// Make it an even 4 bit string (for visual effect)
$bits_string = sprintf(%03d, decbin( $compare ));
echo liUser:  . $id . /li;
// Check to see if the comparision contains any permission bits
$can_read= (($compare  $perm['read']) == $perm['read']) === 
TRUE ? TRUE : FALSE;
$can_write   = (($compare  $perm['write']) == $perm['write']) === 
TRUE ? TRUE : FALSE;
$can_execute = (($compare  $perm['execute']) == $perm['execute']) 
=== TRUE ? TRUE : FALSE;

echo ul;
echo li . $user_perm . ' - ' . $bits_string . /li;
echo liCan Read: $can_read/li;
echo liCan Write: $can_write/li;
echo liCan Execute: $can_execute/li;
echo /ul;
}
echo /ul;
?
-- end code --

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


[PHP] $_SERVER['HTTP_HOST'] without the 'www.'

2004-08-31 Thread Shaun
Hi,

How can I get the URL of the page I am on without the 'www.' i.e. just
mydomain.com? I need to enurse this is correct in case the user types in the
domain without using the 'www.'.

I have looked at using substr but if the user leaves out the 'www.' then
substr($_SERVER['HTTP_HOST'], 4) would return 'main.com', is there a better
function to use in this instance?

Thanks for your help

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



Re: [PHP] Bitwise operations criticism needed

2004-08-31 Thread Marek Kilimajer
Gerard Samuel wrote:
Marek Kilimajer wrote:
Gerard Samuel wrote:
The situation.
Im currently using a home brewed groups permission code in my site,
but for limited users/groups its ok.  Beyond that, the code will take 
the fast road to hell.
I started to look in depth at bitwise operations today,
and after much googling, and looking at other code, came up with this
mock up, of a basic permissions routine (not neccessarilly the final 
product), that utilizes bitwise operations.

Im looking for advise, to see if Im heading in the right way, and/or 
improvements with this.
Thanks for your time...

-- start code --
?php
$perm = $user = array();
$perm_total = 0;
// Permissions from some source like a database/file
$perm['execute'] = 1;
$perm['write']   = 2;
$perm['read']= 4;
// User permissions (predetermined) from sessions maybe
$user['tom']= 7;  // rwx
$user['joe']= 5;  // rx
$user['dirty_harry']= 9;  // illegal in this case??

9 is 1001, so if you ignore fourth bit, it's equal to 1. Some day you 
might want to add other permission rights using other bits.

Yes I may use it some day.  I was trying to simulate an illegal 
permission.  So how should I handle this, if I should handle this???
Your checks are something like
if($user['tom']  $perm['read']) echo 'Tom can read';
Only the 3rd bit is checked, all others are ignored and won't do any harm.
Anyway, the clean way of setting permissions is:
$user['tom'] = $perm['execute'] | $perm['write'] | $perm['read'];


$user['whats_his_face'] = 6;  // rw
// Set the sum of source permissions
foreach($perm as $value)
{
$perm_total |= $value;
}
echo ul;
// Loop over the users
foreach($user as $id = $user_perm)
{

These 2 pieces of code:
// User permissions should be between 1  7, else set it to 0
if ($user_perm  $perm_total || $user_perm  0)
{
$user_perm = 0;
}

and
// Compare user bits to permission bits
$compare = $perm_total  $user_perm;

do the same thing, and are quite useless, the code will work without 
it. If you extend the rights one day, you would have to modify it.

Ok, I understand what you mean about the if() statement, as its related 
to your previous comment above.
But isn't $compare = $perm_total  $user_perm; needed for this to work?
$compare = $perm_total  $user_perm; unsets all bits other than 1, 2 and 
4, so  0 = $compare = 7. However, your first condition already did this.



// Make it an even 4 bit string (for visual effect)
$bits_string = sprintf(%03d, decbin( $compare ));
echo liUser:  . $id . /li;
// Check to see if the comparision contains any permission bits
$can_read= (($compare  $perm['read']) == $perm['read']) === 
TRUE ? TRUE : FALSE;
$can_write   = (($compare  $perm['write']) == $perm['write']) 
=== TRUE ? TRUE : FALSE;
$can_execute = (($compare  $perm['execute']) == 
$perm['execute']) === TRUE ? TRUE : FALSE;

echo ul;
echo li . $user_perm . ' - ' . $bits_string . /li;
echo liCan Read: $can_read/li;
echo liCan Write: $can_write/li;
echo liCan Execute: $can_execute/li;
echo /ul;
}
echo /ul;
?
-- end code --


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


Re: [PHP] Form Spoofing - How?

2004-08-31 Thread Michal Migurski
 I've been asked to make a php script to automatically fill out and
 submit a form on a remote site. I know this is possible, but have no
 idea where to begin

SimpleTest can do this quite elegantly.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] $_SERVER['HTTP_HOST'] without the 'www.'

2004-08-31 Thread Michal Migurski
 How can I get the URL of the page I am on without the 'www.' i.e. just
 mydomain.com? I need to enurse this is correct in case the user types in
 the domain without using the 'www.'.

This should be Apache's job - you can configure the webserver to redirect
requests from example.com to www.example.com without PHP's involvement, if
that's what you're interested in.

 I have looked at using substr but if the user leaves out the 'www.' then
 substr($_SERVER['HTTP_HOST'], 4) would return 'main.com', is there a
 better function to use in this instance?

preg_match() should get you started.
/(\w+\.\w+)$/ ought to match just the primary domain.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Authors and Instructors Needed

2004-08-31 Thread Jim Grill
I can hold my pee for hours

Jim Grill
- Original Message - 
From: Keystone Learning Systems [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, August 30, 2004 4:43 PM
Subject: [PHP] Authors and Instructors Needed


 KeyStone Learning Systems (www.keystonelearning.com) is currently seeking
subject matter experts to work with us to author future courseware titles
delivered via CD-ROM, VHS, DVD and the Web.


 Are you a leading expert or trainer in your field? Do you have a passion
or desire to teach others?

 Have you always wanted to be a published author but haven't had the time
or opportunity to pursue your goal?


 KeyStone has been working with leading experts for more than 15 years in
the areas of desktop software, development, programming and certification
topics to develop computer and video-based courseware.

 Our products are used by more than 500,000 active professional users and
sold along with more than 1,200 course titles in some of the following
categories:

   - Professional Certifications, such as MCSE and CCNA
   - Application and Web Developers, such as Java, SQL and VB.Net
   - Desktop Applications, such as Microsoft Office, QuickBooks and
Publisher
   - Digital Media Applications, such as Macromedia Flash and Adobe
Photoshop
   - Professional Soft skills, such as Project Management and Accounting
   - Other Information Technology, Communications and development related
courses



 If you are interested in joining our team of leading experts, we encourage
you to visit our site at http://www.keystonelearning.com/keystone/sme  for
additional information.


 Thank you.

 The KeyStone Team

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




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



Re: [PHP] $_SERVER['HTTP_HOST'] without the 'www.'

2004-08-31 Thread Nick Wilson

* and then Shaun declared
 Hi,
 
 How can I get the URL of the page I am on without the 'www.' i.e. just
 mydomain.com? I need to enurse this is correct in case the user types in the
 domain without using the 'www.'.

parse_url() ;-)

-- 
Nick W

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



RE: [PHP] Authors and Instructors Needed

2004-08-31 Thread KeyStone Learning Systems
All,

We apologize if this posting was interpreted as spam.  Our intentions
were not to spam and we posted this message to your list, as it has many
professional PHP developers that may be interested in working with us on
course development.  

Regards,

KeyStone Learning Systems

- Original Message - 
From: Keystone Learning Systems [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, August 30, 2004 4:43 PM
Subject: [PHP] Authors and Instructors Needed


 KeyStone Learning Systems (www.keystonelearning.com) is currently 
 seeking
subject matter experts to work with us to author future courseware
titles delivered via CD-ROM, VHS, DVD and the Web.


 Are you a leading expert or trainer in your field? Do you have a 
 passion
or desire to teach others?

 Have you always wanted to be a published author but haven't had the 
 time
or opportunity to pursue your goal?


 KeyStone has been working with leading experts for more than 15 years 
 in
the areas of desktop software, development, programming and
certification topics to develop computer and video-based courseware.

 Our products are used by more than 500,000 active professional users 
 and
sold along with more than 1,200 course titles in some of the following
categories:

   - Professional Certifications, such as MCSE and CCNA
   - Application and Web Developers, such as Java, SQL and VB.Net
   - Desktop Applications, such as Microsoft Office, QuickBooks and
Publisher
   - Digital Media Applications, such as Macromedia Flash and Adobe
Photoshop
   - Professional Soft skills, such as Project Management and
Accounting
   - Other Information Technology, Communications and development 
 related
courses



 If you are interested in joining our team of leading experts, we 
 encourage
you to visit our site at http://www.keystonelearning.com/keystone/sme
for additional information.


 Thank you.

 The KeyStone Team

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




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



Re: [PHP] $_SERVER['HTTP_HOST'] without the 'www.'

2004-08-31 Thread Greg Donald
On Tue, 2004-08-31 at 09:38, Shaun wrote:
 Hi,
 
 How can I get the URL of the page I am on without the 'www.' i.e. just
 mydomain.com? I need to enurse this is correct in case the user types in the
 domain without using the 'www.'.
 
 I have looked at using substr but if the user leaves out the 'www.' then
 substr($_SERVER['HTTP_HOST'], 4) would return 'main.com', is there a better
 function to use in this instance?

str_replace()

You can replace the www. with an empty string.


-- 
Greg Donald

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



Re: [PHP] DOM loadXML not loading doctype as expected in PHP5

2004-08-31 Thread David Numan
It worked! Thank you so much!

I couldn't find documentation for this anywhere. I think I will add a
note on the DOM Function page in the php docs.

-dave

On Tue, 2004-08-31 at 01:23, Christian Stocker wrote:
 On Tue, 31 Aug 2004 00:27:25 -0400, David Numan [EMAIL PROTECTED] wrote:
  Hi
  
  I'm working on a project using PHP5 and I'm using the DOM extension
  quite heavily. I need to be able to store various character entities
  such as $nbsp; and eacute; Note: this is for a custom XML document, not
  standard (X)HTML.
  
  When I load my XML string into my domDocument I've been trying
  variations of $doctype1 and $doctype2 below. Here is my code:
  
  $doctype1 = EODT
  !DOCTYPE page [
  !ENTITY % ISOlat1 PUBLIC -//W3C//ENTITIES Latin1 for XHTML//EN
  http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent;
  %ISOlat1;
  !ENTITY % ISOsymbol PUBLIC -//W3C//ENTITIES Symbols for XHTML//EN
  http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent;
  %ISOsymbol;
  !ENTITY % ISOspecial PUBLIC -//W3C//ENTITIES Special for XHTML//EN
  http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent;
  %ISOspecial;
  ]
  EODT;
  
  $doctype2 = '!DOCTYPE page PUBLIC -
  http://gv.ca/dtd/character-entities.dtd;';
  
  $xml = '?xml version=1.0 encoding=UTF-8?'.$doctype1.
 'pagenbsp;/page';
  $dom = new domDocument();
  $dom-loadXML($xml);
  echo $dom-saveXML();
  
  The above code works as-is and the nbsp; is present in the huge output.
  However, when I change it to use $doctype2 the nbsp; is no longer there
  and returns the warning Entity 'nbsp' not defined in Entity, line 1.
  Of course the $doctype2 string is the one I need.
  
  What am I doing wrong? Why isn't it loading the external entities? Is
  there some other way of doing this that I somehow missed? I tested the
  exact same xml code using xmllint -format -loaddtd file.xml and it
  worked fine.
 
 try if it works with
 
 $dom-resolveExternals = true:
 
 before $dom-load()
 
 not tested, but I assume it has something to do with not loading
 external entities
 
 chregu
  
  Tested on Gentoo with PHP 5.0.0 and 5.0.1 with libxml 2.6.11.
  
  Any ideas would be appreciated.
  Thanks,
  --
  David Numan [EMAIL PROTECTED]
  
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
  
-- 
David H. Numan, Software Architect
Guided Vision: Internet Application Construction
(905) 528-3095   http://guidedvision.com

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



[PHP] Re: $_SERVER['HTTP_HOST'] without the 'www.'

2004-08-31 Thread Torsten Roehr
Shaun [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,

 How can I get the URL of the page I am on without the 'www.' i.e. just
 mydomain.com? I need to enurse this is correct in case the user types in
the
 domain without using the 'www.'.

 I have looked at using substr but if the user leaves out the 'www.' then
 substr($_SERVER['HTTP_HOST'], 4) would return 'main.com', is there a
better
 function to use in this instance?

 Thanks for your help

Does your Apache provide $_SERVER['SERVER_NAME']? For me it outputs the
domain like google.com.

Regards, Torsten Roehr

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



[PHP] Re: [PHP5]__get, __set and isset()

2004-08-31 Thread Catalin Trifu
Hi,

Is this really a bug. I think not.
There is no variable $o-a or $a-b in the class OO
there is only the variable $elem and $a and $b is a member
of that array
So ...
The fact that PHP5 provides __set and __get magic
functions does not mean that the actual variables exist with
that particular name in the class ?
Perhaps it would be nice to have a __isset magic function ?

Cheers
Catalin


 ?php

 class OO
 {
 private $elem = array(a = 1);

 public function __get ($prop)
 {
 if (isset($this-elem[$prop])) {
 return $this-elem[$prop];
 } else {
 return NULL;
 }
 }

 public function __set ($prop, $val)
 {
 $this-elem[$prop] = $val;
 }
 }

 $o = new OO();

 echo isset($o-a) ? yes\n : no\n;
 echo isset($o-b) ? yes\n : no\n;

 echo is_null($o-a) ? yes\n : no\n;
 echo is_null($o-b) ? yes\n : no\n;

 ?

 I expected something like this:

 yes
 no
 no
 yes

 But got this:

 no
 no
 no
 yes

 It looks like isset() can't handle object properties correctly. I'll post 
 the bug on php.net.

 -- 
 Daniel Schierbeck 

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



[PHP] Re: [PHP5]__get, __set and isset()

2004-08-31 Thread M. Sokolewicz
next time, please read the isset documentation carefully. I quote:
[quote]isset() will return FALSE if testing a variable that has been set 
to NULL.[/quote]

Catalin Trifu wrote:
Hi,
Is this really a bug. I think not.
There is no variable $o-a or $a-b in the class OO
there is only the variable $elem and $a and $b is a member
of that array
So ...
The fact that PHP5 provides __set and __get magic
functions does not mean that the actual variables exist with
that particular name in the class ?
Perhaps it would be nice to have a __isset magic function ?
Cheers
Catalin

?php
class OO
{
private $elem = array(a = 1);
public function __get ($prop)
{
if (isset($this-elem[$prop])) {
return $this-elem[$prop];
} else {
return NULL;
}
}
public function __set ($prop, $val)
{
$this-elem[$prop] = $val;
}
}
$o = new OO();
echo isset($o-a) ? yes\n : no\n;
echo isset($o-b) ? yes\n : no\n;
echo is_null($o-a) ? yes\n : no\n;
echo is_null($o-b) ? yes\n : no\n;
?
I expected something like this:
yes
no
no
yes
But got this:
no
no
no
yes
It looks like isset() can't handle object properties correctly. I'll post 
the bug on php.net.

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


[PHP] Re: [PHP5]__get, __set and isset()

2004-08-31 Thread Daniel Schierbeck
M. Sokolewicz wrote:
next time, please read the isset documentation carefully. I quote:
[quote]isset() will return FALSE if testing a variable that has been set 
to NULL.[/quote]

Catalin Trifu wrote:
Hi,
Is this really a bug. I think not.
There is no variable $o-a or $a-b in the class OO
there is only the variable $elem and $a and $b is a member
of that array
So ...
The fact that PHP5 provides __set and __get magic
functions does not mean that the actual variables exist with
that particular name in the class ?
Perhaps it would be nice to have a __isset magic function ?
Cheers
Catalin

?php
class OO
{
private $elem = array(a = 1);
public function __get ($prop)
{
if (isset($this-elem[$prop])) {
return $this-elem[$prop];
} else {
return NULL;
}
}
public function __set ($prop, $val)
{
$this-elem[$prop] = $val;
}
}
$o = new OO();
echo isset($o-a) ? yes\n : no\n;
echo isset($o-b) ? yes\n : no\n;
echo is_null($o-a) ? yes\n : no\n;
echo is_null($o-b) ? yes\n : no\n;
?
I expected something like this:
yes
no
no
yes
But got this:
no
no
no
yes
It looks like isset() can't handle object properties correctly. I'll 
post the bug on php.net.

--
Daniel Schierbeck 
Next time, please read my post carefully. $a is not NULL, it is 1. 
Therefore, isset($a) should return TRUE, which it does normally, just 
not when $a is returned via __get().

@catalin: Yes, a __isset() method would be ideal, but i still can't see 
why isset() shouldn't support the overloaded variables - after all, if 
you are able to access such a variable using the __get() method, why 
shouldn't you be able to check whether or not it has been set? 
Currently, if you want to check whether a variable in the $elem array is 
set, you would have to use this:

$a = $o-a;
echo isset($a) ? yes\n : no\n;
Which in my opinion isn't optimal.
Bottom line - if you can access a variable through property overloading 
you should be able to use isset() on them as well.

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


Re: [PHP] Bitwise operations criticism needed

2004-08-31 Thread Gerard Samuel
Marek Kilimajer wrote:
Your checks are something like
if($user['tom']  $perm['read']) echo 'Tom can read';
Only the 3rd bit is checked, all others are ignored and won't do any harm.
Anyway, the clean way of setting permissions is:
$user['tom'] = $perm['execute'] | $perm['write'] | $perm['read'];
Understood.  It cant be illegal if its set as you described.
$compare = $perm_total  $user_perm; unsets all bits other than 1, 2 and 
4, so  0 = $compare = 7. However, your first condition already did this.

Ok.
So here is the updated code -
-- start code --
?php
$perm = $user = array();
$perm_total = 0;
// Permissions from some source like a database/file
$perm['execute'] = 1;
$perm['write']   = 2;
$perm['read']= 4;
// User permissions (predetermined) from sessions maybe
$user['tom']= $perm['read'] | $perm['write'] | 
$perm['execute'];  // rwx
$user['joe']= $perm['read'] | $perm['execute'];  // rx
$user['whats_his_face'] = $perm['read'] | $perm['write'];  // rw

// Set the sum of source permissions
foreach($perm as $value)
{
$perm_total |= $value;
}
echo ul;
// Loop over the users
foreach($user as $id = $user_perm)
{
// Compare user bits to permission bits
$compare = $perm_total  $user_perm;
// Make it an even 4 bit string (for visual effect)
$bits_string = sprintf(%03d, decbin( $compare ));
echo liUser:  . $id . /li;
// Check to see if the comparision contains any permission bits
$can_read= (($compare  $perm['read']) == $perm['read']) === 
TRUE ? TRUE : FALSE;
$can_write   = (($compare  $perm['write']) == $perm['write']) === 
TRUE ? TRUE : FALSE;
$can_execute = (($compare  $perm['execute']) == $perm['execute']) 
=== TRUE ? TRUE : FALSE;

echo ul;
echo li . $user_perm . ' - ' . $bits_string . /li;
echo liCan Read: $can_read/li;
echo liCan Write: $can_write/li;
echo liCan Execute: $can_execute/li;
echo /ul;
}
echo /ul;
?
-- end code --
So if thats it, now its time to expand on this idea on my end...
Thanks
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: $_SERVER['HTTP_HOST'] without the 'www.'

2004-08-31 Thread John Nichel
Torsten Roehr wrote:

Does your Apache provide $_SERVER['SERVER_NAME']? For me it outputs the
domain like google.com.
Regards, Torsten Roehr
Server name from Apache is not guaranteed to be sans 'www'.  Server name 
will return whatever the web server is configured as in the httpd.conf

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] RPM package for PHP5

2004-08-31 Thread Denis Gerasimov

Hello all,

Is there any RMP package for PHP 5.0.1 available?
(Our server runs under RedHat Linux Fedora Core 1 (RedHat Linux 10))

Best regards, Denis Gerasimov
Outsourcing Services Manager,
VEKOS, Ltd.
www.vekos.ru

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



Re: [PHP] Re: [PHP5]__get, __set and isset()

2004-08-31 Thread Frédéric Hardy
Yes but not :-).
With you use these magic functions, when you write $o-a = 'foo', you 
create a property in the object. Not ? Even if it is stored in an array 
member, __set() create a property and __get() retrieve its value.

Doc says :
The $name parameter used is the name of the variable that should
 be set or retrieved.
The __set() method's $value parameter specifies the value that
 the object should set set the $name.
Conclusion :
class OO
{
   private $elem = array();
   public function __get ($prop)
   {
  if (isset($this-elem[$prop])) {
 return $this-elem[$prop];
   }
   else
   {
  return NULL;
   }
   public function __set ($prop, $val)
   {
  $this-elem[$prop] = $val;
   }
}
$o = new OO();
echo isset($o-a) ? yes\n : no\n; # Must return false and return 
false effectively, cool
$o-a = 'foo';
echo isset($o-a) ? yes\n : no\n; # Must return false and return 
false effectively, NOT COOL

Fred.
Catalin Trifu wrote:
Hi,
Is this really a bug. I think not.
There is no variable $o-a or $a-b in the class OO
there is only the variable $elem and $a and $b is a member
of that array
So ...
The fact that PHP5 provides __set and __get magic
functions does not mean that the actual variables exist with
that particular name in the class ?
Perhaps it would be nice to have a __isset magic function ?
Cheers
Catalin

?php
class OO
{
private $elem = array(a = 1);
public function __get ($prop)
{
if (isset($this-elem[$prop])) {
return $this-elem[$prop];
} else {
return NULL;
}
}
public function __set ($prop, $val)
{
$this-elem[$prop] = $val;
}
}
$o = new OO();
echo isset($o-a) ? yes\n : no\n;
echo isset($o-b) ? yes\n : no\n;
echo is_null($o-a) ? yes\n : no\n;
echo is_null($o-b) ? yes\n : no\n;
?
I expected something like this:
yes
no
no
yes
But got this:
no
no
no
yes
It looks like isset() can't handle object properties correctly. I'll post 
the bug on php.net.

--
Daniel Schierbeck 

--
===
Frederic HARDYEmail: [EMAIL PROTECTED]
HEXANET SARL  URL: http://www.hexanet.fr/
ZAC Les CharmillesTel: +33 (0)3 26 79 30 05
3, allée Thierry Sabine   Direct: +33 (0)3 26 61 77 84
BP 202 - 51686 REIMS CEDEX 2 FRANCE
===
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: [PHP5]__get, __set and isset()

2004-08-31 Thread Frédéric Hardy
But there is no property set to NULL !!
Fred.
M. Sokolewicz wrote:
next time, please read the isset documentation carefully. I quote:
[quote]isset() will return FALSE if testing a variable that has been set 
to NULL.[/quote]

Catalin Trifu wrote:
Hi,
Is this really a bug. I think not.
There is no variable $o-a or $a-b in the class OO
there is only the variable $elem and $a and $b is a member
of that array
So ...
The fact that PHP5 provides __set and __get magic
functions does not mean that the actual variables exist with
that particular name in the class ?
Perhaps it would be nice to have a __isset magic function ?
Cheers
Catalin

?php
class OO
{
private $elem = array(a = 1);
public function __get ($prop)
{
if (isset($this-elem[$prop])) {
return $this-elem[$prop];
} else {
return NULL;
}
}
public function __set ($prop, $val)
{
$this-elem[$prop] = $val;
}
}
$o = new OO();
echo isset($o-a) ? yes\n : no\n;
echo isset($o-b) ? yes\n : no\n;
echo is_null($o-a) ? yes\n : no\n;
echo is_null($o-b) ? yes\n : no\n;
?
I expected something like this:
yes
no
no
yes
But got this:
no
no
no
yes
It looks like isset() can't handle object properties correctly. I'll 
post the bug on php.net.

--
Daniel Schierbeck 

--
===
Frederic HARDYEmail: [EMAIL PROTECTED]
HEXANET SARL  URL: http://www.hexanet.fr/
ZAC Les CharmillesTel: +33 (0)3 26 79 30 05
3, allée Thierry Sabine   Direct: +33 (0)3 26 61 77 84
BP 202 - 51686 REIMS CEDEX 2 FRANCE
===
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: [PHP5]__get, __set and isset()

2004-08-31 Thread Catalin Trifu
Actually i think no property is created; not in the sense of
real object property.
The only real property of the object is $elem.
The $o-a, and $o-b are, IMHO, not object properties;
It is true that one can access $o-a and $o-b, but what is actually
returned is a member of the array $elem, and only because of the
implementation of the magic functions __set and __get.
isset() does test for an actual variable beeing set, which is 
definetely
not the case.
I agree however that this is confusing. I am definetely puzzled by the
usefullness of these methods since i consider this to be a real error trap;
it would be so easy to fill up an object with values without knowing
what they are and what they are supposed to do and when developing some
kinda library, things can get really messy.
On my part I would stick with the usual declaration of properties and 
not
use __set() and __get().
I think it's much cleaner to say:
class OO {
/** this is variable a and means ... */
public $a;
/** this is variable a and means ... */
public $b;
}

cheers,
Catalin


Frédéric hardy [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Yes but not :-).

 With you use these magic functions, when you write $o-a = 'foo', you 
 create a property in the object. Not ? Even if it is stored in an array 
 member, __set() create a property and __get() retrieve its value.

 Doc says :

 The $name parameter used is the name of the variable that should
  be set or retrieved.
 The __set() method's $value parameter specifies the value that
  the object should set set the $name.

 Conclusion :

 class OO
 {
private $elem = array();
public function __get ($prop)
{
   if (isset($this-elem[$prop])) {
  return $this-elem[$prop];
}
else
{
   return NULL;
}

public function __set ($prop, $val)
{
   $this-elem[$prop] = $val;
}
 }

 $o = new OO();
 echo isset($o-a) ? yes\n : no\n; # Must return false and return false 
 effectively, cool
 $o-a = 'foo';
 echo isset($o-a) ? yes\n : no\n; # Must return false and return false 
 effectively, NOT COOL

 Fred.


 Catalin Trifu wrote:

 Hi,

 Is this really a bug. I think not.
 There is no variable $o-a or $a-b in the class OO
 there is only the variable $elem and $a and $b is a member
 of that array
 So ...
 The fact that PHP5 provides __set and __get magic
 functions does not mean that the actual variables exist with
 that particular name in the class ?
 Perhaps it would be nice to have a __isset magic function ?

 Cheers
 Catalin



?php

class OO
{
private $elem = array(a = 1);

public function __get ($prop)
{
if (isset($this-elem[$prop])) {
return $this-elem[$prop];
} else {
return NULL;
}
}

public function __set ($prop, $val)
{
$this-elem[$prop] = $val;
}
}

$o = new OO();

echo isset($o-a) ? yes\n : no\n;
echo isset($o-b) ? yes\n : no\n;

echo is_null($o-a) ? yes\n : no\n;
echo is_null($o-b) ? yes\n : no\n;

?

I expected something like this:

yes
no
no
yes

But got this:

no
no
no
yes

It looks like isset() can't handle object properties correctly. I'll post 
the bug on php.net.

-- 
Daniel Schierbeck



 -- 
 ===
 Frederic HARDYEmail: [EMAIL PROTECTED]
 HEXANET SARL  URL: http://www.hexanet.fr/
 ZAC Les CharmillesTel: +33 (0)3 26 79 30 05
 3, allée Thierry Sabine   Direct: +33 (0)3 26 61 77 84
 BP 202 - 51686 REIMS CEDEX 2 FRANCE
 === 

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



[PHP] enabling mail function/mail functions help

2004-08-31 Thread AceZero2790
I'm trying to use the eFiction fanction/story archiving script for my website 
(view the script here: http://www.thesonicworld.net/efiction/), but the 
registration process is giving me trouble. It's one of those where you fill in your 
email and username and they send you a default password. Well, I'm not 
getting that e-mail.

I was told I need to make sure my mail functions are active. Furthermore I 
have been told lots of things about SMTP servers and webservers and localhost 
and I'm really not following.

What is my SMTP server? How do I enable it/make sure its working? If it isn't 
working, how do I get it to work?

-Andrew


[PHP] Weblog -Blog software wrtten in PHP and My SQL

2004-08-31 Thread Bestman4unowwa
Does anyone know of Blog sw available in the marketplace written in PHP and 
maybe MySQL?


[PHP] Re: [PHP5]__get, __set and isset()

2004-08-31 Thread Greg Beaver
Frédéric hardy wrote:
Is it possible to do something like this :
class foo
{
private $array = array();
function __construct()
{
...
}
function __get($key)
{
return (isset($this-array[$key]) == false ? null : 
$this-array[$key]);
}

function __set($key, $value)
{
$this-array[$key] = $value;
}
}
$foo = new foo();
if (isset($foo-bar) == false)
$foo-bar = 'bar';
else
echo $foo-bar;
It seems that isset($foo-bar) return ALWAYS false.
Bug ?
Not a bug, __get() and __set() are called only if !isset($foo-var).
The purpose of __get and __set is to implement transparent getters and 
setters without forcing users to do

function setVal($val)
{
$this-val = $val;
}
function getVal()
{
return $this-val;
}
If you are not sure which properties even exist, you probably shouldn't 
be using __get()/__set(), or should refactor so that you can rely upon 
certain values existing.  If absolutely necessary, you can always provide

function ifexists($name)
{
return isset($this-array[$name]);
}
and then you can if ($o-ifexists('a')) instead of if (isset($o-a))
Greg
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: [PHP5]__get, __set and isset()

2004-08-31 Thread Daniel Schierbeck
Catalin Trifu wrote:
Actually i think no property is created; not in the sense of
real object property.
The only real property of the object is $elem.
The $o-a, and $o-b are, IMHO, not object properties;
It is true that one can access $o-a and $o-b, but what is actually
returned is a member of the array $elem, and only because of the
implementation of the magic functions __set and __get.
isset() does test for an actual variable beeing set, which is 
definetely
not the case.
I agree however that this is confusing. I am definetely puzzled by the
usefullness of these methods since i consider this to be a real error trap;
it would be so easy to fill up an object with values without knowing
what they are and what they are supposed to do and when developing some
kinda library, things can get really messy.
On my part I would stick with the usual declaration of properties and 
not
use __set() and __get().
I think it's much cleaner to say:
class OO {
/** this is variable a and means ... */
public $a;
/** this is variable a and means ... */
public $b;
}

cheers,
Catalin
Frédéric hardy [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

Yes but not :-).
With you use these magic functions, when you write $o-a = 'foo', you 
create a property in the object. Not ? Even if it is stored in an array 
member, __set() create a property and __get() retrieve its value.

Doc says :

The $name parameter used is the name of the variable that should
be set or retrieved.
The __set() method's $value parameter specifies the value that
the object should set set the $name.
Conclusion :
class OO
{
  private $elem = array();
  public function __get ($prop)
  {
 if (isset($this-elem[$prop])) {
return $this-elem[$prop];
  }
  else
  {
 return NULL;
  }
  public function __set ($prop, $val)
  {
 $this-elem[$prop] = $val;
  }
}
$o = new OO();
echo isset($o-a) ? yes\n : no\n; # Must return false and return false 
effectively, cool
$o-a = 'foo';
echo isset($o-a) ? yes\n : no\n; # Must return false and return false 
effectively, NOT COOL

Fred.
Catalin Trifu wrote:

   Hi,
   Is this really a bug. I think not.
   There is no variable $o-a or $a-b in the class OO
there is only the variable $elem and $a and $b is a member
of that array
   So ...
   The fact that PHP5 provides __set and __get magic
functions does not mean that the actual variables exist with
that particular name in the class ?
   Perhaps it would be nice to have a __isset magic function ?
Cheers
Catalin


?php
class OO
{
private $elem = array(a = 1);
public function __get ($prop)
{
if (isset($this-elem[$prop])) {
return $this-elem[$prop];
} else {
return NULL;
}
}
public function __set ($prop, $val)
{
$this-elem[$prop] = $val;
}
}
$o = new OO();
echo isset($o-a) ? yes\n : no\n;
echo isset($o-b) ? yes\n : no\n;
echo is_null($o-a) ? yes\n : no\n;
echo is_null($o-b) ? yes\n : no\n;
?
I expected something like this:
yes
no
no
yes
But got this:
no
no
no
yes
It looks like isset() can't handle object properties correctly. I'll post 
the bug on php.net.

--
Daniel Schierbeck

--
===
Frederic HARDYEmail: [EMAIL PROTECTED]
HEXANET SARL  URL: http://www.hexanet.fr/
ZAC Les CharmillesTel: +33 (0)3 26 79 30 05
3, allée Thierry Sabine   Direct: +33 (0)3 26 61 77 84
BP 202 - 51686 REIMS CEDEX 2 FRANCE
=== 
I personally find the __get() and __set() methods very usefull, 
especially when constructing object hierarchies. But, as Frédéric said, 
they're not sufficient. Either make isset() work with the __get() method 
or add a __isset() magic method.

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


RE: [PHP] Weblog -Blog software wrtten in PHP and My SQL

2004-08-31 Thread Ed Lazor
 -Original Message-
 Does anyone know of Blog sw available in the marketplace written in PHP
 and
 maybe MySQL?

Go to Google and search for blog php.  I just did and there were several
options available.

-Ed

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



Re: [PHP] Weblog -Blog software wrtten in PHP and My SQL

2004-08-31 Thread Xongoo!com: Central unit
Current trend in my opinion:
http://wordpress.org/

--
Tadas Talaikis
[EMAIL PROTECTED]
http://www.xongoo.com

- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, August 31, 2004 8:28 PM
Subject: [PHP] Weblog -Blog software wrtten in PHP
and My SQL


 Does anyone know of Blog sw available in the
marketplace written in PHP and
 maybe MySQL?


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



RE: [PHP] Weblog -Blog software wrtten in PHP and My SQL

2004-08-31 Thread Justin Palmer
WordPress
Wordpress.org - PHP/MySQL Lots of skins and support.

Justin


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 31, 2004 10:28 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Weblog -Blog software wrtten in PHP and My SQL


Does anyone know of Blog sw available in the marketplace written in PHP
and 
maybe MySQL?

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



Re: [PHP] Weblog -Blog software wrtten in PHP and My SQL

2004-08-31 Thread eoghan
wordpress
[EMAIL PROTECTED] wrote:
Does anyone know of Blog sw available in the marketplace written in PHP and 
maybe MySQL?

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


RE: [PHP] Weblog -Blog software wrtten in PHP and My SQL

2004-08-31 Thread Vail, Warren
PHP Nuke includes BLOG's and a lot more (referred to as Journals in the
App).

http://www.phpnuke.org


Warren Vail


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 31, 2004 10:28 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Weblog -Blog software wrtten in PHP and My SQL


Does anyone know of Blog sw available in the marketplace written in PHP and 
maybe MySQL?

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



Re: [PHP] Closing my Window after Download

2004-08-31 Thread Jasper Howard
try this, after you force download of the file, use:

header(Location: close_window_script.php);

where the only code in that file is something like this:

script language=javascript
!--
window.close();
//--
/script


this is a total workaround, but since its the only thing in the document,
its very possible that it'll work, it won't take any more time to load
either because you're using the header() function to forward, so the user
has to download the same amount of info.

-- 


--
Jasper Howard :: Database Administration
Velocity7
1.530.470.9292
http://www.Velocity7.com/
--
Php Junkie [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Ave,

 I hear you... Even I feel it's a different problem but I don't know what.
 My first thought was that HTML or anything doesn't work after the
 Force-Download script in general But since you seem to use it, I guess
 it does.

 Now I don't know what to do, how to make it work. I can't understand what
 exactly is causing the problem.

 Thanks though.



 On 8/30/04 7:13 PM, Jasper Howard [EMAIL PROTECTED] wrote:

  if you're not getting any html after your php script, then there's a
  different problem. I do the same thing and all I use is:
 
  ?php
  ...
  ?
  script language=javascript
  !--
  window.close();
  //--
  /script
 
  and I've never had a problem with it not closing...



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



Re: [PHP] Weblog -Blog software wrtten in PHP and My SQL

2004-08-31 Thread Saqib . N . Ali
http://cafelog.com/  (PHP + mysql)

a very light  weight  (simple and primitive) blog: 
http://www.xml-dev.com/blog/

Thanks.
Saqib Ali
https://validate.sf.net

[EMAIL PROTECTED] wrote on 08/31/2004 10:28:09 AM:

 Does anyone know of Blog sw available in the marketplace written in PHP 
and 
 maybe MySQL?

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



Re: [PHP] Weblog -Blog software wrtten in PHP and My SQL

2004-08-31 Thread Chris Shiflett
--- [EMAIL PROTECTED] wrote:
 Does anyone know of Blog sw available in the marketplace written in
 PHP and maybe MySQL?

http://www.s9y.org/

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

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



Re: [PHP] Weblog -Blog software wrtten in PHP and My SQL

2004-08-31 Thread Xongoo!com: Central unit
I've used nuike for a year or so, it was hacked 3
times, blog script there is ugly. Wordpress rocks!

- Original Message -
From: Vail, Warren [EMAIL PROTECTED]
To: [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Tuesday, August 31, 2004 9:04 PM
Subject: RE: [PHP] Weblog -Blog software wrtten in
PHP and My SQL


 PHP Nuke includes BLOG's and a lot more
(referred to as Journals in the
 App).

 http://www.phpnuke.org


 Warren Vail


 -Original Message-
 From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 31, 2004 10:28 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Weblog -Blog software wrtten in
PHP and My SQL


 Does anyone know of Blog sw available in the
marketplace written in PHP and
 maybe MySQL?

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





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



[PHP] Parsing large file

2004-08-31 Thread Adrian Teasdale
Hi there

We have a text file that is 2.2gb in size that we are trying to parse
using PHP to put the content into a mysql database. This file contains
40 million individual lines of data.  Basically PHP isn't parsing it.
Any suggestions of how we could do this?

Thanks

Ade

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



[PHP] Broken data within an Array

2004-08-31 Thread Harlequin
Hi all.

Having a problem echoing a broken date. Here's where I'm at:

$DateAdvertisedBroken = explode(-, $DateAdvertised);

later, in a table, I use:

$result[DateAdvertised]

How can I change this so I can call the broken date...?

I've tried datebroken [2] etc but no joy.

-- 
-
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-

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



[PHP] Re: List of cities

2004-08-31 Thread Harlequin
I scoured the web. begged borrowed and stole and eventually ended up with a
list of over 1,600 cities and towns in the UK.

-- 
-
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-
Harlequin [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Morning...

 Does anyone know of a site that or resource available where I could pull a
 list of ALL UK cities and towns for an option list...?

 I started out with 100+, then expanded this list to over 200 but still get
 complaints that certain towns are not listed.

 -- 
 -
  Michael Mason
  Arras People
  www.arraspeople.co.uk
 -

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



Re: [PHP] Closing my Window after Download

2004-08-31 Thread Curt Zirzow
* Thus wrote Jasper Howard:
 try this, after you force download of the file, use:
 
 header(Location: close_window_script.php);
 
 where the only code in that file is something like this:
 
 script language=javascript
 !--
 window.close();
 //--
 /script
 
 
 this is a total workaround, but since its the only thing in the document,
 its very possible that it'll work, it won't take any more time to load
 either because you're using the header() function to forward, so the user
 has to download the same amount of info.

This will *not* work. you can't send a file and close a window in
the same request.


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

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



Re: [PHP] Weblog -Blog software wrtten in PHP and My SQL -- Thank you!!

2004-08-31 Thread Bestman4unowwa
Thanks to everyone that responded. This will keep me busy. I'll look into 
these -- wordpress, php nuke journals, cafelog, etc.

Do any of you have any experience with these or others? Care to share your 
opinions?


RE: [PHP] Parsing large file

2004-08-31 Thread Pablo Gosse
Adrian Teasdale wrote:
 Hi there
 
 We have a text file that is 2.2gb in size that we are trying to parse
 using PHP to put the content into a mysql database. This file
 contains 40 million individual lines of data.  Basically PHP isn't
 parsing it. Any suggestions of how we could do this?   
 
 Thanks
 
 Ade

Use split to break the file down into parts of manageable size, and then
process those.

split -b nM filename (where n is the number of Megs you wish each part
to be).

man split

HTH.

Pablo

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



[PHP] instanceof / __CLASS__ question

2004-08-31 Thread Jason Barnett
It's only a minor nuisance, but in order to use __CLASS__ with instanceof I have 
to assign __CLASS__ to a variable first.  Should I bother submitting a bug 
report for this?  Or am I perhaps missing something...

?php
class Test {
  function checkObj2()
  {
//workaround
$class = __CLASS__;
if ($this instanceof $class) {
  return TRUE;
} else {
  return FALSE;
}
  }
  function checkObj()
  {
// this causes a parsing error
// return ($this instanceof __CLASS__);
  }
}
$t = new Test();
echo $t-checkObj2() ? 'TRUE' : 'FALSE';
echo $t-checkObj();  // can't even test it
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Weblog -Blog software wrtten in PHP and My SQL

2004-08-31 Thread Vail, Warren
Hmmm, I had one also that was hacked half dozen times (and a half dozen
sites that were never touched) till I installed security patches from
release 7.4, works great now.  What do you like about Wordpress?  Are the
themes changeable?

Warren Vail


-Original Message-
From: Xongoo!com: Central unit [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 31, 2004 11:31 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Weblog -Blog software wrtten in PHP and My SQL


I've used nuike for a year or so, it was hacked 3
times, blog script there is ugly. Wordpress rocks!

- Original Message -
From: Vail, Warren [EMAIL PROTECTED]
To: [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Tuesday, August 31, 2004 9:04 PM
Subject: RE: [PHP] Weblog -Blog software wrtten in
PHP and My SQL


 PHP Nuke includes BLOG's and a lot more
(referred to as Journals in the
 App).

 http://www.phpnuke.org


 Warren Vail


 -Original Message-
 From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 31, 2004 10:28 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Weblog -Blog software wrtten in
PHP and My SQL


 Does anyone know of Blog sw available in the
marketplace written in PHP and
 maybe MySQL?

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





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

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



RE: [PHP] Parsing large file

2004-08-31 Thread Jay Blanchard
[snip]
We have a text file that is 2.2gb in size that we are trying to parse
using PHP to put the content into a mysql database. This file contains
40 million individual lines of data.  Basically PHP isn't parsing it.
Any suggestions of how we could do this?
[/snip]

Post some code and we'll see if we can help.

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



Re: [PHP] Parsing large file

2004-08-31 Thread William Moore
 We have a text file that is 2.2gb in size that we are trying to parse
 using PHP to put the content into a mysql database. This file contains
 40 million individual lines of data.  Basically PHP isn't parsing it.
 Any suggestions of how we could do this?

Without knowing more information (eg: Any errors, does the script run
completely, partially, or not at all?) I would say that you could
running into the script execution timeout.  Check your php.ini file
for max_execution_time and adjust accordingly.

If you are surpassing max_execution_time then you will notice that the
script runs correctly, but it will not finish parsing all of the data.
 If you check the DB, do some of the records show up there?

-William

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



[PHP] help with crc32

2004-08-31 Thread Jason Barnett
I've been able to use md5 / md5_file to verify file integrity.  However when I 
try to check crc32's I'm running into some problems.  As an example I download 
and extract the PHP package for Windows, then when I try to crc32() the file 
contents I get a totally different value from what I think I should be getting. 
 Obviously I'm missing out on some crucial detail(s) here...

?php
echo 'pre';
// This is the extracted install.txt from PHP-5.0.1.Win32.zip
$file = 'C:\Downloads\install.txt';
// crc for the file - got from my unzip utility
echo $crc = 'EEED9D44' . \n;
// reading all at once - buffer added line by line produced same results
$contents = file_get_contents($file);
printf (%u\n, crc32($contents));
// result: 4008549700
// by the way, how can we cast to unsigned integer instead of using printf?
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Broken data within an Array

2004-08-31 Thread Jason Barnett
Harlequin wrote:
Hi all.
Having a problem echoing a broken date. Here's where I'm at:
$DateAdvertisedBroken = explode(-, $DateAdvertised);
So this contains an array of (year, month, day) or something similar?  You 
should be able to grab the values here if that's the case.

later, in a table, I use:
$result[DateAdvertised]
How can I change this so I can call the broken date...?
implode(' ', $DateAdvertisedBroken)
or use nbsp; if needed.
Or did you mean $DateAdvetisedBroken[2] ?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: help with crc32 [SOLVED]

2004-08-31 Thread Jason Barnett
I hate when this happens all I needed was dechex().  *sigh*
I could have sworn I'd tried that already, ah well.

Jason Barnett wrote:
I've been able to use md5 / md5_file to verify file integrity.  However 
when I try to check crc32's I'm running into some problems.  As an 
example I download and extract the PHP package for Windows, then when I 
try to crc32() the file contents I get a totally different value from 
what I think I should be getting.  Obviously I'm missing out on some 
crucial detail(s) here...

?php
echo 'pre';
// This is the extracted install.txt from PHP-5.0.1.Win32.zip
$file = 'C:\Downloads\install.txt';
// crc for the file - got from my unzip utility
echo $crc = 'EEED9D44' . \n;
// reading all at once - buffer added line by line produced same results
$contents = file_get_contents($file);
printf (%u\n, crc32($contents));
// result: 4008549700
// by the way, how can we cast to unsigned integer instead of using printf?
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Broken data within an Array

2004-08-31 Thread Jason Wong
On Wednesday 01 September 2004 02:45, Harlequin wrote:

 Having a problem echoing a broken date. Here's where I'm at:

 $DateAdvertisedBroken = explode(-, $DateAdvertised);

 later, in a table, I use:

 $result[DateAdvertised]

 How can I change this so I can call the broken date...?

 I've tried datebroken [2] etc but no joy.

I've no idea what you're trying to ask here. If you're asking how to access 
the individual elements in the array $DateAdvertisedBroken, then

1) Know what you're doing by print_r($DateAdvertisedBroken)
2) Then $DateAdvertisedBroken[n], when 'n' is the element you want.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
/*
 *   Should be panic but... (Why are BSD people panic obsessed ??)
 */
2.0.38 /usr/src/linux/net/ipv4/ip_fw.c
*/

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



[PHP] PHP Cached Templates

2004-08-31 Thread rogue
Sorry if this is the wrong place for this post. I am having problems 
where PHP templates that I modify via ftp are not showing changes for 
like 1 minute or so. I assume this is some kind of server caching but I 
am not sure how to adjust this (it is my development server). Running 
Apache server.

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


[PHP] running php script from batch file

2004-08-31 Thread Trent DeCamp
Win2k Pro/ IIS

I'm baffled by this one after updating to PHP 5.0

I called a php script through a batch file scheduled in 'at'. Worked
beautifully in 4.x.

In 5.0, the batch file goes off, but the php script doesn't execute.
HOWEVER, if I run the batch file manually from the command line or if I run
the php file from the command line, both work! It's driving me crazy.

Thanks for ANY help!

- Trent ([EMAIL PROTECTED])

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



[PHP] Re: instanceof / __CLASS__ question

2004-08-31 Thread Greg Beaver
Hi,
I'm not sure I understand why you would use instanceof on $this.  Try 
this code:

?php
class a1 {
}
class a2 extends a1 {
}
echo new a1 instanceof a1; // true
echo new a2 instanceof a1; // true
?
instanceof defines whether an object is or descends from a class (like 
is_a()).

If you want to check whether $this is the Test class or a descendant 
class, the simplest way I know is

if (get_class($this) == 'Test')
otherwise, you could use reflection
$z = new ReflectionClass($this);
if ($z-getName() == 'Test')
but that's a bit more cumbersome.
Greg
Jason Barnett wrote:
It's only a minor nuisance, but in order to use __CLASS__ with 
instanceof I have to assign __CLASS__ to a variable first.  Should I 
bother submitting a bug report for this?  Or am I perhaps missing 
something...

?php
class Test {
  function checkObj2()
  {
//workaround
$class = __CLASS__;
if ($this instanceof $class) {
  return TRUE;
} else {
  return FALSE;
}
  }
  function checkObj()
  {
// this causes a parsing error
// return ($this instanceof __CLASS__);
  }
}
$t = new Test();
echo $t-checkObj2() ? 'TRUE' : 'FALSE';
echo $t-checkObj();  // can't even test it
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Parsing large file

2004-08-31 Thread Adrian Teasdale
Hi everyone.

Thanks for advice so far.  Going to try that split command (looks
useful).  IN the meantime, here is the code:

?php

include config.php;

// open database
if (!mysql_connect($config['db']['host'], $config['db']['user'],
$config['db']['password'])) {
die ('Can\' connect to DB!');
}

if (!mysql_select_db($config['db']['dbname'])) {
die ('Can\' work with DB! Try do FLUSH PRIVILEGES.');
}

// clear table
mysql_query('TRUNCATE TABLE '.$config['table_name']);


$pattern = '/^([a-z0-9]+[a-z0-9-]*[a-z0-9]) NS [a-z0-9.-]+$/i';

$handle = fopen($config['parsefile'], 'r');

$count = 0;
while (!feof($handle)) {
  
$sql = '';
$buffer = fgets($handle);

$count++;
if ($count$config['max_count']) break;

 // parse string
 if (preg_match($pattern, $buffer, $match)) {
$sql .= '('.$match[1].')';
 }

 if ($sql) { 
$sql = 'INSERT IGNORE '.$config['table_name'].' (domain) VALUES
'.$sql;
echo $sql.br;
mysql_query($sql);
}

}
fclose($handle);

?


Any ideas?  Works 100% ok on a smaller file

Thanks

Ade


 -Original Message-
 From: Jay Blanchard [mailto:[EMAIL PROTECTED] 
 Sent: 31 August 2004 20:29
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: RE: [PHP] Parsing large file
 
 
 [snip]
 We have a text file that is 2.2gb in size that we are trying 
 to parse using PHP to put the content into a mysql database. 
 This file contains 40 million individual lines of data.  
 Basically PHP isn't parsing it. Any suggestions of how we 
 could do this? [/snip]
 
 Post some code and we'll see if we can help.
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



[PHP] is_a (WAS: Re: instanceof / __CLASS__ question [SOLVED])

2004-08-31 Thread Jason Barnett
Greg Beaver wrote:
Hi,
I'm not sure I understand why you would use instanceof on $this.  Try 
this code:

Kind of complicated (so probably not the best way) but I have objects I'm 
creating with a factory method - and all of these objects *should* be extending 
a parent class.  It's in the parent class where I'm using $this instanceof 
__CLASS__ and alternatives are welcome.  I thought is_a was being deprecated 
(correct me if I'm wrong) ?


instanceof defines whether an object is or descends from a class (like 
is_a()).

If you want to check whether $this is the Test class or a descendant 
class, the simplest way I know is

if (get_class($this) == 'Test')

Yes, it probably makes more sense to do it this way.  Reflections would be 
overkill, all I need is to test for inheritance.

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


Re: [PHP] Closing my Window after Download

2004-08-31 Thread PHP Junkie
Ave,

Indeed, it didn't work. Anymore suggestions?




On 8/31/04 2:09 PM, Jasper Howard [EMAIL PROTECTED] wrote:

 try this, after you force download of the file, use:
 
 header(Location: close_window_script.php);
 
 where the only code in that file is something like this:
 
 script language=javascript
 !--
 window.close();
 //--
 /script
 
 
 this is a total workaround, but since its the only thing in the document,
 its very possible that it'll work, it won't take any more time to load
 either because you're using the header() function to forward, so the user
 has to download the same amount of info.

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



[PHP] Cannot load modules

2004-08-31 Thread Bronislav Klucka
Hi,
I'm using Apache2 and PHP5 and mysql on WinXP and I have problem with
loading modules. When starting apache, error occures:

PHP startup: unable to load dynamic library 'c:\Program
files..\php_curl.dll'  - Module was not find
PHP startup: unable to load dynamic library 'c:\Program
files..\php_myslq.dll'  - Module was not find

I'm loading 4 modules, all at the same location, how is it possible, that
PHP loads 2 of them and 2 of them not???
INI file:

extension_dir = c:\Program Files\ApachePhpMysql\php\ext\

extension=php_curl.dll
extension=php_imap.dll
extension=php_mbstring.dll
extension=php_mysql.dll


Thnx for any help...

Brona

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



Re: [PHP] Parsing large file

2004-08-31 Thread Michal Migurski
We have a text file that is 2.2gb in size that we are trying to parse
using PHP to put the content into a mysql database. This file contains
40 million individual lines of data.  Basically PHP isn't parsing it.
Any suggestions of how we could do this?
Process the file line-by-line instead of all-at-once, using fgets().
Check your max execution time, as William suggests.
Post a little example code or an error message.

michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Storing image in database

2004-08-31 Thread Dre
I got the idea .. and I will work on it
thanks a lot
Jim Grill [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
  Dre wrote:
   line 8 is ?php
  
   just that .. and the code before it is the following
  
   //==
   html
   head
   titleUntitled Document/title
   meta http-equiv=Content-Type content=text/html;
charset=iso-8859-1
   /head
  
   body
   //==
  
 
  That is the output I mentioned.
 
  And output either html OR image, you cannot output both. Try yourself,
  open a image file (gif, jpg...) in a text editor and put html code in
  it, then save it. Obviosly, you'll get broken image file.
 

 As others have mentioned, you cannot output *anything* at all before
 modifying headers. If your script outputs even a space, headers are sent.
 Headers can only ever be sent one time per request. The solution: make a
 separate request for the image.

 To get around this problem put your image fetching code into a separate
 script and call it with an image tag. Ideally, you would have saved the
 image sizes in a separate column so you might select only the id (or name
of
 the image) and the size in your main script and then call the second image
 fetching script like so:
 img src=image.php?img_id=$id width=$width height=$height border=0
 /

 The $id, $width, and $height would have come from your db. Save the actual
 fetching of the image itself for image.php.

 Good luck and have fun!

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

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



Re: [PHP] Storing image in database

2004-08-31 Thread Dre
may I ask why is it inefficient ??

thanks in advance
Raditha Dissanayake [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Dre wrote:

 Hi ..
 
 I'm trying to save and view image files in a MySQL database, I made the
save
 operation successfully, I stored the image file name, type, size and the
 image file itself
 the problem occurred when I tried to retrieve the image data I've
previously
 stored, in specific when I tried to preview the image file
 
 I tried to make something like the following but it did not work
 
 
 while solutions are being offered, may i bring to your kind attention
 the fact that storing images in a database is woefully inefficient.

 -- 
 Raditha Dissanayake.
 
 http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
 Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
 Graphical User Inteface. Just 128 KB | with progress bar.


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



[PHP] Re: Form Spoofing - How?

2004-08-31 Thread Manuel Lemos
Hello,
On 08/31/2004 07:47 AM, Nick Wilson wrote:
I've been asked to make a php script to automatically fill out and
submit a form on a remote site. I know this is possible, but have no
idea where to begin
So, my question is: What functions/theories/etc should I start looking
at in order to get started on this?
You may want to try this HTTP client class. I let you submit forms 
including uploading files if necessary. It can collect and send back 
cookies as well handle redirection automatically for you.

http://www.phpclasses.org/httpclient
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Storing image in database

2004-08-31 Thread Jay Blanchard
[snip]
may I ask why is it inefficient ??
[/snip]

Because BLOB data requires tremendous overhead and cannot usually be
indexed by itself. You are better storing the image somewhere in your
system and then storing a pointer (URL, whatever) to the image.

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



Re: [PHP] Storing image in database

2004-08-31 Thread Jason Wong
On Wednesday 01 September 2004 05:18, Dre wrote:
 may I ask why is it inefficient ??

Yes.

Also you can goggle around a bit for the pros and cons.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
You'll pay to know what you really think.
-- J.R. Bob Dobbs
*/

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



  1   2   >