[PHP] RE: PHP, Windows and COM.

2003-02-26 Thread Richard Quadling
Genius!

Thank you very much.

Can this example be added to the PHP Manual? All the online examples I've
seen relate to functions which you can pass the first few params and no
more. In this case having to pass the first and last param is not mentioned.

This simple example demonstrates the use of php's VARIANT() type and now to
call functions that use it.

Thank you VERY much!!

Regards,

Richard.

-Original Message-
From: Harald Radi [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 26, 2003 10:41 AM
To: 'Richard Quadling'
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: PHP, Windows and COM.


hi richard

> The problem with some of the VBA functions is that the first and last 
> parameter need to be set and the ones in the middle have no meaning 
> and cannot be present. This can only be achieved by using named
> parameters. The
> GoTo method, as a function, in VBA would be ...

sooner or later everything ends up in a native c(++) function call and there
are no such things as named parameters. therefore nonpresent parameters will
be assigned a default value (iirc NULL if no explicit default value is
specified.)

so try calling

GoTo(wdGoToBookmark, NULL, NULL, "BookmarkName");

or, if it doesn't work

$empty = new VARIANT();
GoTo(wdGoToBookmark, $empty, $empty, "BookmarkName");

the difference is, that there exists two different variant types with nearly
the same meaning, VT_NULL and VT_EMPTY. PHP's NULL will be marshalled to
VT_NULL, VT_EMPTY has to be created by explicitly creating an empty variant
container in php.

ad. your previous question:
there are two other ways of importing a type library, you can either
com_load_typelib("Word.Application") which will search for the typelib
assigned to that component or you can enable com.autoregister_typelib in
your php.ini which will cause php to load the typelib for every component
you instanciate.

harald

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



[PHP] RE: PHP, Windows and COM.

2003-02-26 Thread Richard Quadling
Hi Harald.

The problem with some of the VBA functions is that the first and last
parameter need to be set and the ones in the middle have no meaning and
cannot be present. This can only be achieved by using named parameters. The
GoTo method, as a function, in VBA would be ...

GoTo(wdGoToBookmark,,,"BookmarkName")

OLEView shows the GoTo method as ...

[id(0x00ad), helpcontext(0x095e00ad)]
HRESULT _stdcall GoTo(
[in] VARIANT* What, 
[in, optional] VARIANT* Which, 
[in, optional] VARIANT* Count, 
[in, optional] VARIANT* Name, 
[out, retval, optional] Range** prop);


I only want to supply What and Name, Which and Count are not valid for
bookmarks. Is there a true NULL type I can send?

Richard.

P.S. Thanks for the OLEView pointer.

-Original Message-
From: Harald Radi [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 25, 2003 5:14 PM
To: 'Richard Quadling'; [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: PHP, Windows and COM.



hi richard,

currently there is no way of calling a function with named arguments. your
proposed array syntax wouldn't allow for passing arrays. on the other hand
variant arrays can only be indexed arrays and not hash arrays so i could
treat all string indices as named parameters. this would be a possibility
though i still find it very confusing. if anybody has a good suggestion that
is feasable on top of the engine (meaning without modifying the
scanner/parser) don't hesitate to post it to the list.

back to your actual problem:
you still can call all functions without naming parameters, though you have
to specify the full list of parameters up to at least the last optional
parameter that should not be set to its default value (uuh, does this make
sence ? actually its exactly the same as calling a php function with
optional parameters). you can look up the default values for optional
parameters in the components typelibrary which is browsable using the
oleview tool. 

i hope that helps.

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



[PHP] Virtual Host document directory.

2001-05-23 Thread Richard Quadling

Hi.

I am using Sambar Server on Win98SE, PHP 4.0.5. All is well.

The server supports "virtual hosts". I am not sure of the terminology
outside of Sambar, but effectively, I can go to my browser and enter ...

local.site1.com
local.site2.com
etc.

And get different sites.

I have a set of PHP scripts which are copied to each of the sites
public_html directory.

They are all on the same IP address (as I only have 1 pc).

The server's documents are served out via localhost.

I want to know the document (or public_html) directory of the site that
called the PHP script.

The reason is that the script needs to see if certain files exist so that
the resultant HTML shows the correct info. Some of them are in both sites,
some files are only in 1 or 2 sites, but they always have the same name.

I assume there is a variable somewhere?

Ideas/suggestions please.

Thanks in advance.

Richard Quadling.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Virtual Hosts document root directory.

2001-05-23 Thread Richard Quadling

Hi.

I am using Sambar Server on Win98SE, PHP 4.0.5. All is well.

The server supports "virtual hosts". I am not sure of the terminology
outside of Sambar, but effectively, I can go to my browser and enter ...

local.site1.com
local.site2.com
etc.

And get different sites.

I have a set of PHP scripts which are copied to each of the sites
public_html directory.

They are all on the same IP address (as I only have 1 pc).

The server's documents are served out via localhost.

I want to know the document (or public_html) directory of the site that
called the PHP script.

The reason is that the script needs to see if certain files exist so that
the resultant HTML shows the correct info. Some of them are in both sites,
some files are only in 1 or 2 sites, but they always have the same name.

I assume there is a variable somewhere?

Ideas/suggestions please.

Thanks in advance.

Richard Quadling.






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Can PHP determine if the STDOUT to a CLI script is being redirected?

2009-04-22 Thread Richard Quadling
Hi.

Is there a simple way for a CLI based PHP script to determine if its
output is being redirected to a file or piped through a filter (find,
sort, etc.)

I'm using ANSI escape sequences to colour the output (all working very
nicely), but I want to suppress the codes if the output is being
filtered or redirected to a file.

Regards,

Richard Quadling.

-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

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



Re: [PHP] Can PHP determine if the STDOUT to a CLI script is being redirected?

2009-04-22 Thread Richard Quadling
2009/4/22 Per Jessen :
> Richard Quadling wrote:
>
>> Hi.
>>
>> Is there a simple way for a CLI based PHP script to determine if its
>> output is being redirected to a file or piped through a filter (find,
>> sort, etc.)
>>
>> I'm using ANSI escape sequences to colour the output (all working very
>> nicely), but I want to suppress the codes if the output is being
>> filtered or redirected to a file.
>
> Check out posix_isatty()
>
>
> /Per
>
> --
> Per Jessen, Zürich (16.4°C)
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

For windows?

-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

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



Re: [PHP] Unable to send mail from PHP to AT&T e-mail address

2009-04-22 Thread Richard Quadling
2009/4/22 Edward Diener :
> scubak1w1 wrote:
>>
>> "Edward Diener"  wrote in message
>> news:d9.64.21597.c829e...@pb1.pair.com...
>>>
>>> Chris wrote:
>>>>
>>>> kranthi wrote:
>>>>>
>>>>> of u are sure that the mail was not received as spam...
>>>>>
>>>>> check the log files of the mail server on the server to be sure that
>>>>> the mail actually reached the mail server from the http server
>>>>
>>>> Somehow I doubt AT&T gives out that sort of access ;)
>>>
>>> Exactly.
>>>
>>>> The idea is right if you have access to both servers though.
>>>
>>> As you suggested, I can check my own server but I doubt I can get access
>>> to AT&T's incoming mail server.
>>
>> AT&T is potentially using one of the BLs such as SCBLs...
>>
>> Try going to, say, http://www.senderbase.org/, enter the IP and then on
>> the listings page try the DNS-based blocklists [Show/Hide all] links
>
> I pinged the domain part of the 'from' email for the sending server and got
> back an IP address. I entered that IP address at http://www.senderbase.org/
> and received a 'Neutral' reputation score with 'no information' found from
> whois and 'unknown' found for information about the network.
>
> I am not sure what final IP address the mail server is using to send out
> e-mail but 7 addresses starting with the first 3 parts of the IP were listed
> as addresses and all showed 0 DNSBL listings and 'Neutral' SBRS. Needless to
> say no spam is being sent from the mail addresses, since it is used by the
> server as part of a legitimate client-server program.
>
> Also bl.spamcop.net shows nothing for the IP address.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

What output do you get from ...

nslookup -q=mx put_the_domain_here.com

e.g.

nslookup -q=mx google.com

Server:  bv-vm-svr-1.[srcubbed].local
Address:  10.0.30.1

google.com  MX preference = 10, mail exchanger = smtp3.google.com
google.com  MX preference = 10, mail exchanger = smtp4.google.com
google.com  MX preference = 10, mail exchanger = smtp1.google.com
google.com  MX preference = 10, mail exchanger = smtp2.google.com
google.com  nameserver = ns3.google.com
google.com  nameserver = ns1.google.com
google.com  nameserver = ns4.google.com
google.com  nameserver = ns2.google.com
smtp1.google.cominternet address = 209.85.237.25
smtp2.google.cominternet address = 64.233.165.25
smtp3.google.cominternet address = 209.85.137.25
smtp4.google.cominternet address = 72.14.221.25
ns1.google.com  internet address = 216.239.32.10
ns2.google.com  internet address = 216.239.34.10
ns3.google.com  internet address = 216.239.36.10
ns4.google.com  internet address = 216.239.38.10

As you can see there are MANY servers set up to receive SMTP mail for google.com

None of them are the same as the IP you see when you ...

ping google.com

Pinging google.com [74.125.45.100] with 32 bytes of data:

Reply from 74.125.45.100: bytes=32 time=104ms TTL=239
Reply from 74.125.45.100: bytes=32 time=103ms TTL=239
Reply from 74.125.45.100: bytes=32 time=105ms TTL=239
Reply from 74.125.45.100: bytes=32 time=104ms TTL=239

Ping statistics for 74.125.45.100:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 103ms, Maximum = 105ms, Average = 104ms



-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

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



Re: [PHP] Regex not working with ":"

2009-04-22 Thread Richard Quadling
2009/4/22 kyle.smith :
> Have you tried escaping the : with a \?
>
> Like:
> mb_ereg_replace('^(.*)this is the test\: replace(.*)$', '', $contents
> ,'UTF-8');
>
> Also, have you tried removing the : and adjusting the input string to
> verify your belief that it's the :?
>
> HTH,
> Kyle
>
> -Original Message-
> From: Merlin Morgenstern [mailto:merli...@fastmail.fm]
> Sent: Wednesday, April 22, 2009 4:09 AM
> To: php-general@lists.php.net
> Subject: [PHP] Regex not working with ":"
>
> Hi there,
>
> I am trying to remove a text which does contain a : inside. Somehow the
> regex does not match, no matter what I do:
>
> $contents = mb_ereg_replace('^(.*)this is the test: replace(.*)$', '',
> $contents ,'UTF-8');
>
> Looks like this is a result of the :.
>
> Does anybody have an idea how to do this?
>
> Thank you for any help.
>
> Merlin
>
> --
> 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
>
>

Can you try ..

# Your regular expression could not be converted to the flavor
required by this language:
# A POSIX Extended RE cannot match the start and the end of a line with ^ and $
# A POSIX Extended RE cannot match the start and the end of a line with ^ and $

# Because of this, the code snippet below will not work as you
intended, if at all.

$contents = mb_ereg_replace('^(.*)this is the test: replace(.*)$',
'\1\2', $contents, 'UTF-8');



The warnings above come from RegexBuddy. Considering the PHP examples,
I'm not sure how accurate they are.
-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

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



Re: [PHP] Multiple return statements in a function.

2009-04-23 Thread Richard Quadling
2009/4/23 Tony Marston :
>
> "tedd"  wrote in message
> news:p06240805c6161613a...@[192.168.1.101]...
>> At 8:12 AM -0400 4/23/09, Peter van der Does wrote:
>>>I tend to put my return value in a variable and at the end of the
>>>function I have 1 return statement.
>>>I have seen others doing returns in the middle of the function.
>>>
>>>-snip-
>>>
>>>What is your take? And is there any benefit to either method?
>>>
>>>Peter van der Does
>>
>> Peter:
>>
>> It's called "Structured programming" -- one way in and one way out of a
>> function.
>>
>> There are, of course, exceptions where it might help others reviewing your
>> code to see what's going on, such as returning a null value if the
>> argument(s) provided are not suitable. But normally the rule is, do not
>> provide an exit from a function in more than one place.
>
> There is no such "rule", it is a matter of personal preference. As a
> previous poster has already said, if you want to leave a function early and
> ignore all subsequent processing it is easier to understand if you return
> immediately rather than have a mechanism to jump over the remaining code to
> a single return point. In the good old days we used to use the GOTO in COBOL
> to jump to the exit point, but then people found a way to abuse GOTO in very
> imaginatve ways.
>
>> The "benefit" is easier to read code.
>
> I think that an immediate return is easier to read, but what do I know -
> I've only been programming for 30 years.
>
> --
> Tony Marston
> http://www.tonymarston.net
> http://www.radicore.org
>
>> Cheers,
>>
>> tedd
>>
>> --
>> ---
>> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

As someone's who been playing this game for only 29 years, I like a
single exit point.

One of the issues I found with multiple exit points is that you have
to work a little harder to guarantee a return.

I always write my code so that if the function did nothing, then null
or false are the return values ...

function foo() {
 $result = False;
// ... code which may or may nor affect $result
 return $result;
}

If your code is heavily nested (maybe an indicator that some
refactoring is worth undertaking) and you introduce yet more code,
keeping track of multiple exit points can be a little problematic.

I suppose if you are the only developer then create a style and stick with it.

Don't be afraid of refactoring your code if you feel that a different
style is easier to work with.

If you work in a team, then once the team has determined its style,
stick with it. Even if it hurts. The hassle you'll get when your code
doesn't "fit" is far more than the learning curve you'll go through
getting the style.

Richard.


-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

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



Re: RES: [PHP] inexplicable behaviour SOLVED

2009-04-28 Thread Richard Quadling
2009/4/27 9el :
>>
>> Thanks for the clarification, Mike. In my ignorance, I was under the
>> impression that the right side of the equation was only for the use of
>> the left part. How stupid of me. So what I should have been doing was
>> $Count1 = $Count + 1; right?
>>

$Count1 = $Count++;

is not the same as

$Count1 = $Count + 1;


 $Count = $Count + 1; is exactly(?) same as $Count++;  or ++$Count
> But not exactly same.  PostFix notation adds the value after assigning.
> PreFix notation adds the value right away.
> But optimized programming argues about how machine is coded nowadays.
>
>
>> Anyway, I don't need that statement anymore as I found the error of my
>> ways and have corrected it. And behold, the light came forth and it
>> worked. :-)
>>
>
> Regards
>
> Lenin
>
> www.twitter.com/nine_L
> www.lenin9l.wordpress.com
>



-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

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



Re: [PHP] Boolean Parameter to 3 Options?

2009-04-30 Thread Richard Quadling
2009/4/29 Matt Neimeyer :
> On Wed, Apr 29, 2009 at 1:30 PM, Shawn McKenzie  wrote:
>> Philip Thompson wrote:
>>> On Apr 29, 2009, at 11:42 AM, Matt Neimeyer wrote:
>>>
>>>> I have a function that currently takes a boolean value as a parameter.
>>>> But now I want to expand it to 3 options...  So if I have...
>>>>
>>>> function doFooBar($doFoo = false)
>>>>   {
>>>>   if($doFoo)
>>>>      { echo "Did Foo"; }
>>>>   else
>>>>      { echo "Did Bar"; }
>>>>   }
>>>>
>>>> Is it as "simple" as changing it like follows to avoid having to
>>>> change existing code that won't use the new values.
>>>>
>>>> function doFooBar($doFoo = 0)
>>>>   {
>>>>   if($doFoo == 2)
>>>>      { echo "Did Baz"; }
>>>>   else if($doFoo == 1)
>>>>      { echo "Did Foo"; }
>>>>   else
>>>>      { echo "Did Bar"; }
>>>>   }
>>>>
>>>> Something about that disturbs me. Perhaps because any time I think "Oh
>>>> it will be as simple as..." it usually isn't.
>>>>
>>>> Thanks in advance!
>>>>
>>>> Matt
>>>
>>> Unless you're doing a strict comparison (===), it probably won't make a
>>> lot of difference. However, if you sent "true" to the function, I
>>> believe it will reach the last else condition. You may revisit all the
>>> locations you call it and update them appropriately.
>>>
>>> Those are my initial thoughts
>>>
>>> ~Philip
>>>
>>
>> No, true will match the first condition.  If you're using true and false
>> now and just want to add a second option then continue using true/false.
>>  Don't mix and match.  1 == true and 2 == true.
>>
>> function doFooBar($doFoo = false)
>> {
>>   if($doFoo === 2) {
>>        //something
>>   }
>>   elseif($doFoo === true) {
>>        //something true
>>   }
>>   elseif($doFoo === false) {
>>        //something false
>>   }
>> }
>>
>
> Ah. I somehow missed the direction of the typecasting. Not that the
> documentation isn't completely explicit on the matter but for some
> reason I was thinking that the bool got cast to 1 or 0... not that the
> string/number got cast to a bool (following the standards there).
>
> Good to know.
>
> Thanks
>
> Matt
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Another way ...



outputs ...

Option 1 chosen
Option 2 chosen
Option 3 chosen
Option 1 chosen
Option 3 chosen


-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

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



Re: [PHP] $this = new Class();

2009-05-07 Thread Richard Quadling
2009/5/7 Richard Quadling :
> 2009/4/30 Olivier Lalonde :
>> Hi all,
>>
>> Since I can't do $this = new Class(); within my class (it gives an
>> error), I was looking for ways to get the same result by other means.
>>
>> I am actually working on an ORM and trying to implement lazy loading.
>>
>> $book = $orm->getBook('id'); // returns an Orm object
>> $book->load();
>>
>> // $book should now be a Book instead instead of an Orm instance
>>
>> Of course, I oversimplified the problem.  $book = $orm->getBook('id');
>> doesn't return a Book instance right ahead because it is a chained
>> method (i.e. $orm->getBook()->where(...)->prefetch(...)->etc
>> Therefore, it _has_ to return an Orm instance.
>>
>> Now, why not simply add ->load() at the end of the chain? Because it
>> adds an extra step for developers that doesn't bring meaningful
>> information. Instead of doing $book = $orm->getBook('id');, it would
>> mean having to do $book = $orm->getBook('id')->load(); (which is
>> longer to type :p). That's why I wanted to implement "lazy loading".
>>
>> $book = $dorm->getBook('id');
>> echo $book->title; // title should be trapped by __set() and it should
>> dynamically replace $book by an actual Book instance
>>
>> I tried doing the following, but PHP doesn't allow it:
>>
>> class A {
>>  public function transform() {
>>    $this = new B();
>>  }
>> }
>>
>> class B {}
>>
>> $var = new A();
>> $var->transform();
>>
>> This is not currently supported by PHP and I was wondering if there
>> was anyway of getting around the problem, that doesn't involve
>> 1) passing $var to the A class i.e:$var->var = $var;
>> 2) looping $GLOBALS[]
>> 3) using __call,__get and __set to proxy everything to the actual Book object
>>
>> PS1: don't lecture me about how I'm doing this all wrong. I've looked
>> at the problem from every possible angle and this is the only
>> solution.
>> PS2: Another alternative would be to subclass the Orm object with
>> Book, (class Orm extends Book {}), overload all properties/methods so
>> we can catch when to load the object... but that would be an extreme
>> pain in the ass.
>> PS3: Another alternative would be to have a parameter that
>> enables/disables chaining.
>> $dorm->getBook('id', true); // chain (you now have to add ->load() at
>> the end of the chain)
>> $dorm->getBook('id', false); // dont chain, this returns a Book instance
>>
>> The point of all this is to keep the most friendly interface !
>>
>> Cheers,
>> Olivier
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> In $orm->getBook('id') should be something similar to ...
>
> $book = new ClassBook('id');
> $book->load;
> return $book;
>
> surely?
>
> --
> -
> Richard Quadling
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> "Standing on the shoulders of some very clever giants!"
>

Oops.

$book->load();

Sorry.

-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

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



Re: [PHP] $this = new Class();

2009-05-07 Thread Richard Quadling
2009/4/30 Olivier Lalonde :
> Hi all,
>
> Since I can't do $this = new Class(); within my class (it gives an
> error), I was looking for ways to get the same result by other means.
>
> I am actually working on an ORM and trying to implement lazy loading.
>
> $book = $orm->getBook('id'); // returns an Orm object
> $book->load();
>
> // $book should now be a Book instead instead of an Orm instance
>
> Of course, I oversimplified the problem.  $book = $orm->getBook('id');
> doesn't return a Book instance right ahead because it is a chained
> method (i.e. $orm->getBook()->where(...)->prefetch(...)->etc
> Therefore, it _has_ to return an Orm instance.
>
> Now, why not simply add ->load() at the end of the chain? Because it
> adds an extra step for developers that doesn't bring meaningful
> information. Instead of doing $book = $orm->getBook('id');, it would
> mean having to do $book = $orm->getBook('id')->load(); (which is
> longer to type :p). That's why I wanted to implement "lazy loading".
>
> $book = $dorm->getBook('id');
> echo $book->title; // title should be trapped by __set() and it should
> dynamically replace $book by an actual Book instance
>
> I tried doing the following, but PHP doesn't allow it:
>
> class A {
>  public function transform() {
>    $this = new B();
>  }
> }
>
> class B {}
>
> $var = new A();
> $var->transform();
>
> This is not currently supported by PHP and I was wondering if there
> was anyway of getting around the problem, that doesn't involve
> 1) passing $var to the A class i.e:$var->var = $var;
> 2) looping $GLOBALS[]
> 3) using __call,__get and __set to proxy everything to the actual Book object
>
> PS1: don't lecture me about how I'm doing this all wrong. I've looked
> at the problem from every possible angle and this is the only
> solution.
> PS2: Another alternative would be to subclass the Orm object with
> Book, (class Orm extends Book {}), overload all properties/methods so
> we can catch when to load the object... but that would be an extreme
> pain in the ass.
> PS3: Another alternative would be to have a parameter that
> enables/disables chaining.
> $dorm->getBook('id', true); // chain (you now have to add ->load() at
> the end of the chain)
> $dorm->getBook('id', false); // dont chain, this returns a Book instance
>
> The point of all this is to keep the most friendly interface !
>
> Cheers,
> Olivier
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

In $orm->getBook('id') should be something similar to ...

$book = new ClassBook('id');
$book->load;
return $book;

surely?

-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

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



Re: [PHP] How to stop E_DEPRECATED messages in the PHP log?

2009-07-07 Thread Richard Quadling
2009/7/6 Jeff Weinberger :
> Hi:
>
> I am hoping someone can help me figure this out
>
> I've just upgraded my PHP installation to 5.3.0. Now I am receiving
> thousands of log messages of the form "PHP Deprecated: ...".
>
> I know I have a number of scripts that use now-deprecated functions, etc.
> and I now know what those are, thanks to all the messages.
>
> However, this is now growing to (literally) gigabytes of log entries, so I'd
> like to stop the messages until I have the time to re-write all the
> offending scripts.
>
> I have tried the following error.reporting lines in php.ini:
>
> error_reporting = E_ALL & ~E_DEPRECATED & E_ERROR & E_WARNING & E_PARSE &
> E_NOTICE & E_CORE_ERROR & E_USER_ERROR & E_USER_WARNING & E_USER_NOTICE &
> E_COMPILE_ERROR & E_COMPILE_WARNING
>
> error_reporting = ~E_DEPRECATED & E_ALL & E_ERROR & E_WARNING & E_PARSE &
> E_NOTICE & E_CORE_ERROR & E_USER_ERROR & E_USER_WARNING & E_USER_NOTICE &
> E_COMPILE_ERROR & E_COMPILE_WARNING
>
> error_reporting =  E_ALL & E_ERROR & E_WARNING & E_PARSE & E_NOTICE &
> E_CORE_ERROR & E_USER_ERROR & E_USER_WARNING & E_USER_NOTICE &
> E_COMPILE_ERROR & E_COMPILE_WARNING & ~E_DEPRECATED
>
> error_reporting = E_ERROR & E_CORE_ERROR & E_USER_ERROR & E_COMPILE_ERROR &
> E_COMPILE_WARNING & ~E_DEPRECATED
>
> error_reporting = ~E_DEPRECATED & E_ERROR & E_CORE_ERROR & E_USER_ERROR &
> E_COMPILE_ERROR & E_COMPILE_WARNING
>
> (as you can tell, I prefer verbose logs, but not that verbose...).
>
> None of these combinations have stopped the  "PHP Deprecated: ..." messages.
>
> System info: Mac OS/X 10.5.7 Client version, PHP 5.3.0 running as a CGI
> under Apache 2.2.11 and as a CLI. Please let me know if there's any other
> info that might help.
>
> php_info() reports error.reporting as "0"
>
> Any help or guidance is appreciated!!
>
> Thanks,
>
> --Jeff
>
>
>
> No one ever achieved greatness by playing it safe. -Harry Gray
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Try ...

error_reporting = 22527


-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
I need a car : http://snipurl.com/l4pih
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] PHP Manual in PDF format

2009-07-07 Thread Richard Quadling
2009/7/7 Angus Mann :
> Hi all. I realize this question has been asked before and I've found 
> responses in the archive, but none of the links work now, or the files they 
> point to are old or unsuitable.
>
> I'd like to print the most recent PHP manual to paper, so I need it in a 
> format that's suitable. I've downloaded it from php.net in chm and HTML 
> format but neither of them can easily be printed with proper attention to 
> page numbering and order.
>
> Any idea where to find a PDF or similar version of the manual?
>
> Thanks,
> Angus
>
>

$ pecl install haru
$ pear channel-discover doc.php.net
$ pear install doc.php.net/phd-beta
$ cvs -d:pserver:cvsr...@cvs.php.net/repository login
(the password is "phpfi")
$ cvs -d:pserver:cvsr...@cvs.php.net/repository co phpdoc
$ cd phpdoc
$ php configure.php
$ phd -f pdf -t phppdf -d .manual.xml

Now open the newly created "pdf" folder :)

If you'd like a big fat one PDF file then use "phpbigpdf" rather then "phppdf"


The PDF version will be available soon. Ish. Maybe. Hopefully.

-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
I need a car : http://snipurl.com/l4pih
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Is there any considerations for not putting php scripts in tmpfs?

2009-08-10 Thread Richard Quadling
2009/8/10 Peter Wang :
> Hi php-general,
> sorry if it is a wrong lists for this question.
>
> I have read many articles/messages about using tmpfs store temp files,
>
> for example, php session data, smarty compied templates and so on.
>
> An obvious reason for that is: it doesn't matter about data loss caused by
> machine restart/poweroff.
>
> since it is not that difficult to restore files on a tmpfs from a disk-based
> dir when machine boot up.
>
> so may i put all my php scripts on a tmpfs to speed it up?  would that cause
> other issues?
>
> thanks for your advices.
>

Considering that in the main PHP scripts are readonly, I would have
thought the normal file and disk caching of the OS would suffice.



-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-09 Thread Richard Quadling
2009/12/9 René Fournier :
> Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call 
> of file_get_contents() on a local file works fine -- the file is read and 
> returned. But any call of file_get_contents on a url -- any url, local or 
> remote -- always returns false.
>
> var_dump (file_get_contents ('http://www.google.com/'));
>
> bool(false)
>
> I've checked php.ini, and the obvious seems okay:
>
>        allow_url_fopen => On => On
>
> Any ideas?
>
> ...Rene

If you enable all errors, anything extra? ...

http://www.google.com'));





-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-09 Thread Richard Quadling
2009/12/9 René Fournier :
> It is, and I use curl elsewhere in the same script to fetch remote content.
> This exact same function works fine on my MacBook Pro (10.6 client, PHP 5.3), 
> and *was* previously working fine under Server 10.4.11 and PHP 5.3,
>
> On 2009-12-09, at 11:10 PM, laruence wrote:
>
>> try
>> wget http://www.google.com in your command line to see whether the network 
>> is reachable
>>
>> LinuxManMikeC wrote:
>>>
>>> On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC  
>>> wrote:
>>>
>>>> On Wed, Dec 9, 2009 at 6:45 AM, René Fournier  
>>>> wrote:
>>>>
>>>>> Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any 
>>>>> call of file_get_contents() on a local file works fine -- the file is 
>>>>> read and returned. But any call of file_get_contents on a url -- any url, 
>>>>> local or remote -- always returns false.
>>>>>
>>>>> var_dump (file_get_contents ('http://www.google.com/'));
>>>>>
>>>>> bool(false)
>>>>>
>>>>> I've checked php.ini, and the obvious seems okay:
>>>>>
>>>>>        allow_url_fopen => On => On
>>>>>
>>>>> Any ideas?
>>>>>
>>>>> ...Rene
>>>>>
>>>> http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
>>>>
>>>>
>>>
>>> "I've checked php.ini"
>>> Right, must remember not to reply to stuff till I'm awake. :-D
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> --
>> <2866791487_dbbbdddf9e.jpg>惠 新宸 xinchen.hui | 商务搜索部 | (+8610)82602112-7974 | 
>> <2866349865_203e53a6c6.jpg>:laruence
>
>

Do you have ANY errors/warning/notices?



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Upload dir

2009-12-11 Thread Richard Quadling
2009/12/11 kranthi :
> How can i change the temporary upload directory?
> var_dump(ini_get('upload_tmp_dir'));      gives me (and that is set in 
> php.ini)
> string '/var/www/cgi-bin' (length=16)
>
> but
> var_dump($_FILES)                                                     gives me
> 'tmp_name' => string '/tmp/phpbSZ6WP' (length=14)
>
> var_dump(file_exists($_FILES['file']['tmp_name']));  gives me  (/tmp
> has permissions drwxrwxrwt and i never used file_move_upload or any
> similar functions)
> boolean false
>
> am I missing something here?
> Kranthi.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Just assuming you could alter the upload_tmp_dir setting in your code
(you can't) ...

PHP puts the uploaded files into the upload_tmp_dir BEFORE your script
runs, so changing it in your script essentially hides the uploaded
files.

PHP drops the files into directory A.
PHP then runs your code.
Your code changes the directory to B.
Your code cannot see the files PHP put into A as your code is now looking in B.

But, as I said earlier, you can't use your code to change
upload_tmp_dir. It can only be done at the system level (php.ini or
httpd.conf). See [1] and [2].

Regards,

Richard Quadling.

[1] http://docs.php.net/manual/en/ini.core.php#ini.sect.file-uploads
[2] http://docs.php.net/manual/en/configuration.changes.modes.php

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Upload dir

2009-12-12 Thread Richard Quadling
2009/12/11 Ashley Sheridan 
>
> On Fri, 2009-12-11 at 15:44 +, Richard Quadling wrote:
>
> 2009/12/11 kranthi :
> > How can i change the temporary upload directory?
> > var_dump(ini_get('upload_tmp_dir'));      gives me (and that is set in 
> > php.ini)
> > string '/var/www/cgi-bin' (length=16)
> >
> > but
> > var_dump($_FILES)                                                     gives 
> > me
> > 'tmp_name' => string '/tmp/phpbSZ6WP' (length=14)
> >
> > var_dump(file_exists($_FILES['file']['tmp_name']));  gives me  (/tmp
> > has permissions drwxrwxrwt and i never used file_move_upload or any
> > similar functions)
> > boolean false
> >
> > am I missing something here?
> > Kranthi.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> Just assuming you could alter the upload_tmp_dir setting in your code
> (you can't) ...
>
> PHP puts the uploaded files into the upload_tmp_dir BEFORE your script
> runs, so changing it in your script essentially hides the uploaded
> files.
>
> PHP drops the files into directory A.
> PHP then runs your code.
> Your code changes the directory to B.
> Your code cannot see the files PHP put into A as your code is now looking in 
> B.
>
> But, as I said earlier, you can't use your code to change
> upload_tmp_dir. It can only be done at the system level (php.ini or
> httpd.conf). See [1] and [2].
>
> Regards,
>
> Richard Quadling.
>
> [1] http://docs.php.net/manual/en/ini.core.php#ini.sect.file-uploads
> [2] http://docs.php.net/manual/en/configuration.changes.modes.php
>
> --
> -
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>
>
> The only reason I can see for wanting to do this would be where several sites 
> exist on the same server and you might want each site to have its own 
> temporary upload directory. It won't have any bearing on how you handle the 
> uploads unless it becomes full.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>

Another way to handle this is via php.ini sections [1]

Regards,

Richard.

[1] http://docs.php.net/manual/en/ini.sections.php

--
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Best ajax library

2009-12-12 Thread Richard Quadling
2009/12/12 Floyd Resler :
> I've always been a big fan of prototype which does AJAX plus a whole lot more.
>
> Take care,
> Floyd
>
> On Dec 12, 2009, at 7:00 AM, Ali Asghar Toraby Parizy wrote:
>
>> Hi friends.
>> What ajax library do you suggest for php developers?
>> Can i use gwt with php, or It is compatible only with java web applications?
>>
>> --
>> 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
>
>

I REALLY like prototype, but it does do a lot to the standard objects,
which does mean it often doesn't play well with others.

If you use Prototype and Scriptaculous (the GUI side of things for
effects and such), then you've got a winner.

Something that is missing though is the more GUI-like components that
come with toolkits like BlueShoes (php CMS server and client side with
separatable JS components - license required depending upon usage).


For just the AJAX communication, then prototype is perfectly adequate.
Though the 'X' is often easier to work with if it is J as in JSON.

Prototype can return JS objects from an AJAX call. PHP support for
JSON is fine in this regard (though I would make sure you set
JSON_FORCE_OBJECT for json_encode() to make sure empty arrays are
returned as objects rather than an empty array if you are building
your objects dynamically).

Richard.


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Re: ErrorException and set_exception_handler()

2009-12-14 Thread Richard Quadling
2009/12/11 Hannes Magnusson :
> On Fri, Dec 11, 2009 at 23:39, Randall Girard  
> wrote:
>> Okay, my mistake.
>>
>>
>> E_USER_WARNING and E_USER_NOTICE are supposed to continue execution,
>> correct?
>
> Correct.
>
>
>> Then  I will restate what I previously said. throwing ErrorException from an
>
> No no. Stop there. Exceptions are *totally* different from E_*.
>
>
>> ERROR_HANDLER(...) is useless iwht E_USER_WARNING and E_USER_NOTICE. Why?
>> Because when you throw the exception from the ERROR_HANDLER, presumably it
>> may NOT get caught in a try/catch block. Therefor the execution cannot
>> continue.
>
> Exactly. And that is the point.
> Why would you be turning E_USER_* into exceptions if you don't want to
> bail out of the current scope?
>
> If you throw an exception from the error handler, what exactly do you
> expect to happen?
> I gave several reasons for why that simply is impossible, but I am
> curious: what exactly are you expecting?
>
>
>
>> Therefor, I think that either a check to see if the TRY/CATCH has been
>> initiated further up the call stack, or a function to call from within the
>> EXCEPTION_HANDLER that will return execution to the previous scope.
>>
>>
>> I don't see how this is difficult to understand.
>
> So you expect a scripting language to scroll up the entire execution
> chain to see if there is a catch() block at all, and if there is no
> catch() block, the simply ignore the exception and continue?
> If thats your expectations then you are severely misunderstanding the
> concept of exceptions.
>
>
> Please do "reply-all". And please do not top-post.
>
>
> -Hannes
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

In support of Hannes, and hopefully providing a simpler script to show
what is happening.

---script
getMessage(), PHP_EOL;
}

function uncaught_error_handler($i_ErrNo, $s_Error, $s_File, $i_Line,
$a_Context) {
  echo 'A PHP error has been generated. It will be turned into an
exception.', PHP_EOL;
  switch($i_ErrNo) {
case 0 : $s_ErrNo = '@'; return True; break;
case 1 : $s_ErrNo = 'E_ERROR'; break;
case 2 : $s_ErrNo = 'E_WARNING'; break;
case 4 : $s_ErrNo = 'E_PARSE'; break;
case 8 : $s_ErrNo = 'E_NOTICE'; break;
case16 : $s_ErrNo = 'E_CORE_ERROR'; break;
case32 : $s_ErrNo = 'E_CORE_WARNING'; break;
case64 : $s_ErrNo = 'E_COMPILE_ERROR'; break;
case   128 : $s_ErrNo = 'E_COMPILE_WARNING'; break;
case   256 : $s_ErrNo = 'E_USER_ERROR'; break;
case   512 : $s_ErrNo = 'E_USER_NOTICE'; break;
case  1024 : $s_ErrNo = 'E_USER_NOTICE'; break;
case  2048 : $s_ErrNo = 'E_STRICT'; break;
case  4096 : $s_ErrNo = 'E_RECOVERABLE_ERROR'; break;
case  8192 : $s_ErrNo = 'E_DEPRECATED'; break;
case 16384 : $s_ErrNo = 'E_USER_DEPRECATED'; break;
  }
  throw new Exception("PHP Error : $s_Error ($s_ErrNo) in $s_File at
Line $i_Line", $i_ErrNo);

  // Never reached as execution continues in the "catch" clause or by
a uncaught exception handler.
  echo 'The exception has been thrown.', PHP_EOL;
}

set_error_handler('uncaught_error_handler');
set_exception_handler('uncaught_exception_handler');

try {
echo 'About to divide by zero inside a try/catch.', PHP_EOL;
$a = 1 / 0;
} catch(Exception $e) {
echo 'Caught : ', $e->getMessage(), PHP_EOL;
}

echo 'Caught divide by zero E_WARNING.', PHP_EOL, PHP_EOL;

echo 'About to divide by zero without a safety net.', PHP_EOL;
$b = 1 / 0;

// Never reached as we are not catching the execption thrown by the
uncaught error handler
echo 'Un-caught divide by zero E_WARNING.', PHP_EOL;
?>
---script

outputs ...

output-
About to divide by zero inside a try/catch.
A PHP error has been generated. It will be turned into an exception.
Caught : PHP Error : Division by zero (E_WARNING) in Z:\test_error.php
at Line 36
Caught divide by zero E_WARNING.

About to divide by zero without a safety net.
A PHP error has been generated. It will be turned into an exception.
Exception : PHP Error : Division by zero (E_WARNING) in
Z:\test_error.php at Line 44
output-


The whole issue is that you are using the (and I can't stress this
enough) _UNCAUGHT_ handlers.

These are the last ditch attempt / safety net for your code. It is
STILL your responsibility to pre-detect the potential errors and code
around them.

A try/catch block will be enough, as demonstrated - I successfully
capture a divide by zero.

Richard.
-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Fwd: [PHP] Re: ErrorException and set_exception_handler()

2009-12-15 Thread Richard Quadling
-- Forwarded message --
From: Randall Girard 
Date: 2009/12/14
Subject: RE: [PHP] Re: ErrorException and set_exception_handler()
To: rquadl...@googlemail.com


I understood exactly what was going on in the code! (I'm no fool when
it comes to this) I just thought (logically) that if the ERROR_HANDLER
forces you to end the script when necessary, that the
EXCEPTION_HANDLER would have a similar function... Rather, there is
not a way at all to continue execution. Now that I contemplate this
further, I think I prefer this anyway as I would NOT want errors
firing for ANY reason on a production website! Additionally when one
error happens it often triggers a number of errors (if execution
continues) and when logging of course they are all logged. I would
rather have just the one backtraced error log, and so forth.


Thank you for your help however! It is much appreciated.

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



Re: [PHP] How to pronounce PHP code over the phone?

2009-12-15 Thread Richard Quadling
2009/10/16 Dotan Cohen :
>>>> It's called "vacation away from the 'net but there is an emergency". I'm
>>>> certain that a fair portion of the list is familiar with that!
>>>
>>> I haven't the slightest idea what you are talking about. Vacation? Away
>>> from the net? We must be from different planets...
>>
>> How to do you vacation from something implanted into your brain?
>>
>
> http://www.imdb.com/title/tt0100802/
>
> --
> Dotan Cohen
>
> http://what-is-what.com
> http://gibberish.co.il
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Surely  "Johnny Moronic" would have been a better example?

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] How to pronounce PHP code over the phone?

2009-12-15 Thread Richard Quadling
2009/10/16 Dotan Cohen :
> How would you read this out loud if you were to read it to someone
> over  the phone?
>
> ($item->getServiceId() ? $item->getServiceId() : $item->getId(;
>
> Thanks!
>
> --
> Dotan Cohen
>
> http://what-is-what.com
> http://gibberish.co.il
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I would optimize this though.

($item->getServiceId() || $item->getId())

Unless you REALLY need to call $item->getServiceId() twice.

So, this should be a little easier to say.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] can't retrieve more than 1 record at the time still

2009-12-15 Thread Richard Quadling
 self to get next candidate with updated numberCand */
>       $_SESSION['numberCand'] = $_SESSION['numberCand'] + 1;
>       exit;
>   }
>
>        $dirname = md5($cand['APP_ID']);
>        $curdir = '/my_location/'.$dirname;
>
>        print "App_id/Dir: " .  $row['APP_ID'] . $curdir . "\n";
>
>         if (!(is_dir($curdir)))
>
>                          {
>                                  if (!mkdir($curdir,0775))
>                                  print "error: " . $curdir . "\n";
>                                  exit;
>                          }
>
> /* Second Oracle DB connection  info removed */
>
>        try
>        {
>                $dbh2 = new
> PDO("oci:dbname=".$tns2,$db2_username,$db2_password);
>
>        }
>
>        catch(PDOException $e)
>        {
>                echo ($e->getMessage());
>                exit;
>        }
>
>
>        $stmt = $dbh2->prepare('select PERSONAL_HIST_PDF_CONTENT from
> otherdb.other_table
>        where DOC_ID = :id');
>
>        $stmt->bindParam(':id', $cand['DOC_ID'], PDO::PARAM_INT);
>        $stmt->bindColumn(1, $PDF, PDO::PARAM_LOB);
>
>        $stmt->execute();
>
>        if (!(chdir($curdir)))
>                {
>                        $_SESSION['msgs'][] = 'Could not change to '.$curdir;
>                        continue;
>                }
>
>        $cnt = 0;
>
>                while ($stmt->fetch(PDO::FETCH_BOUND))
>                {
>                        $filename = 'phs-'.$cnt.'.pdf';
>
>                   if (!file_exists($filename))
>                        { /* if file not already there, write file with BLOB
> contents */
>                                $fh = fopen($filename, 'w');
>                                fwrite($fh, stream_get_contents($PDF));
>                                fclose($fh);
>
>                                /* add to $_SESSION['PHPulled'] for each new
> file saved */
>                                $_SESSION['PHPulled'] = $_SESSION['PHPulled']
> + 1;
>                         }
>                }
>
>                /* increment stack counter */
>                $_SESSION['numberCand'] = $_SESSION['numberCand'] + 1;
>
>                $stmt = NULL; /* release the connection */
>
>                  /*if not done with stack, redirect to self to get next*/
>                if (!empty($_SESSION['DOCIDs']) and
>                        $_SESSION['numberCand'] < count($_SESSION['DOCIDs']))
>                        {
>                                exit;
>
>                        }
>
> }
>
> /* once done, go back to display search page after clearing stack*/
> if(isset($_SESSION['DOCIDs']))
> unset($_SESSION['DOCIDs'] );
>
> $_SESSION['msgs'][] = 'For '.$_SESSION['numberCand'].' candidate(s), '.
> $_SESSION['PHPulled'].' personal histories were loaded.';
> exit;
>
> $res = null;
> $dbh1 = null;
>
> ?>
>
> --
> Catherine Madsen
>
> Programmer Analyst
> College of Chemistry
> Berkeley, CA 94720-1460
>
> TEL: 510-643-1706
> FAX: 510-643-6178
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

The PDOStatement->fetchAll() method will allow you to return all the
rows as an array.

http://docs.php.net/manual/en/pdostatement.fetchall.php

So, no need to iterate the result set.

Something along the lines of ...


prepare("SELECT name, colour FROM fruit");
$sth->execute();

/* Fetch all of the remaining rows in the result set */
print("Fetch all of the remaining rows in the result set:\n");
$result = $sth->fetchAll();
print_r($result);
?>

for example.
-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] PHP + ODBC

2009-12-15 Thread Richard Quadling
2009/12/15 Philip Thompson :
> On Dec 14, 2009, at 8:47 PM, James McLean wrote:
>
>> On Tue, Dec 15, 2009 at 10:03 AM, Philip Thompson
>>  wrote:
>>> My head hurts from hitting it on my desk all day, so I thought I'd turn to 
>>> a fresher set of eyes. The issue I'm having is getting PHP to connect ODBC. 
>>> I can get it to work using isql from the command line. Can you verify my 
>>> settings:
>>>
>> [snipped]
>>>
>>> I've tried the above DSNs and many other versions of it ad nauseum. The 
>>> specific error I'm getting is... "[unixODBC][Driver Manager]Data source 
>>> name not found, and no default driver specified." I really have searched 
>>> high and low for a solution, but to no avail. Any thoughts?
>>
>> Why not just use the built in MySQL libraries or PDO?
>
> Oh, that would be "my" preference. However, the database that I really need 
> to connect to is an MSSQL one and the allowed connection type is ODBC. I was 
> just testing first with a MySQL connection to get it working (I don't have 
> the MSSQL credentials yet). Turned out I was VERY close with my solution, 
> which a coworker figured out this morning. The [ODBC Data Sources] entry for 
> MySQL needed to specified correctly in /etc/odbc.ini.
>
> [ODBC Data Sources]
> MySQL = MySQL
>
> [MySQL]
> Description...
> Driver...
>
> I could have sworn I tried that, but who knows
>
> Thank you!
> ~Philip
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

You can use a DNS-string too ...

odbc_pconnect("Driver={SQL Server Native Client
10.0};Server={$s_Server};Database={$s_DB};MARS_Connection=Yes;",
$s_User, $s_Pswd, SQL_CUR_USE_DRIVER);


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-15 Thread Richard Quadling
2009/12/14 Ashley Sheridan 
>
> On Mon, 2009-12-14 at 17:03 +0200, Cafer Şimşek wrote:
>
> René Fournier  writes:
>
> > On 2009-12-14, at 10:44 PM, Cafer Şimşek wrote:
> >
> >> René Fournier  writes:
> >>
> >>> 4.as per php.ini, allow_url_fopen On
> >>
> >> Look at from phpinfo() the settings is already "On".
> >
> > Yes, I know.
> >
> > Which is why it's odd that the function fails on URLs.
>
> try to get url content from any browser or (if you use Linux / Unix)
> curl.
>
> --
> Cafer Şimşek
> DEV Staff Leader
> http://pazar.com/
>
>
> He already said Curl works, and changing the browser won't affect what PHP is 
> doing.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>

Do you have a default stream context defined for the http stream?

A _LONG_ time ago, when I was using a firewall with NTLM
authentication (which PHP doesn't deal with), I had to route all my
calls through a local proxy.

This was the code I had ...

 array( // All HTTP requests are passed through the 
local
NTLM proxy server on port 8080.
'proxy' => 'tcp://127.0.0.1:8080',
'request_fulluri' => True,
),
)
);

// Though we said system wide, some extensions need a little coaxing.
libxml_set_streams_context($r_default_context);


Now, you may not see this in your code, but may be in a script which
is loaded via auto_prepend_file.

I would also suggest running something like WireShark at the same time
as your script. See if there is ANY traffic over the wire.

Do the cURL and file_get_contents() code generate identical requests?


--
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-16 Thread Richard Quadling
2009/12/16 René Fournier :
> On 2009-12-15, at 11:55 PM, Richard Quadling wrote:
>
> Do you have a default stream context defined for the http stream?
>
> Nope.
>
> A _LONG_ time ago, when I was using a firewall with NTLM
> authentication (which PHP doesn't deal with), I had to route all my
> calls through a local proxy.
>
> This was the code I had ...
>
>  // Define the default, system-wide context.
> $r_default_context = stream_context_get_default(
> array(
> 'http' => array( // All HTTP requests are passed through the local
> NTLM proxy server on port 8080.
> 'proxy' => 'tcp://127.0.0.1:8080',
> 'request_fulluri' => True,
> ),
> )
> );
>
> // Though we said system wide, some extensions need a little coaxing.
> libxml_set_streams_context($r_default_context);
>
>
> Now, you may not see this in your code, but may be in a script which
> is loaded via auto_prepend_file.
>
> Wish it were, but my test code is bare bones.
>
> I would also suggest running something like WireShark at the same time
> as your script. See if there is ANY traffic over the wire.
>
> Do the cURL and file_get_contents() code generate identical requests?
>
> cURL -- both PHP and command-line -- fetches files and URLs (remote and
> local) w/o issues. file_get_contents() fetches files, but fails on all URLs
> (remote and local). This is why I believe the problem lies with the
> machine's configuration and not the Firewall.
> It's pretty confounding, isn't it? I'm not sure what to do at this point.
> ...Rene
>
>

But by using something like WireShark you can see exactly what
requests ARE being made. You may be getting a redirect reply which is
failing or something daft. Anything really.



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] A strange question about mysql_close()

2009-12-17 Thread Richard Quadling
2009/12/17 唐家兴 :
> I want to ask a strange question.
>
> As we know, if we connect a mysql database in the same host twice with the
> same username, we won't get two new link, but two handle to only one link.
> Then, if I close one of them, whether the other one will be closed together?
>
> I wrote two pieces of code. The first is like this
>  $db1 = mysql_connect($host, $username, $pwd);
> $db2 = mysql_connect($host, $username, $pwd);
> $sql = 'show databases';
> mysql_close($db1);
> $res = mysql_query($sql, $db2);
> $a = mysql_fetch_row($res);
> print_r($a);
> ?>
> Then the output of the $db2 is correct. So the $db2 isn't closed together
> with the $db1.
>
> But when I add a line among the code, the result is different
>  $db1 = mysql_connect($host, $username, $pwd);
> $db2 = mysql_connect($host, $username, $pwd);
> $sql = 'show databases';
> mysql_close($db1);
> $db1 = true; //a new line
> $res = mysql_query($sql, $db2);
> $a = mysql_fetch_row($res);
> print_r($a);
> ?>
> Then the output is wrong. The PHP tell me that the link is not a valid one.
> I don't know how an assignment operation for the $db1 can close the $db2.
> Could someone help me.
> I'll appreciate your help.
>

When you xxx_connect() with the same parameters, internally, you are
sharing the connection. It seems that killing one of the references
kills all the references.

The solution is to a use the fourth parameter on mysql_connect(). The
"new_link" param.

So ...



should work.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] A strange question about mysql_close()

2009-12-17 Thread Richard Quadling
2009/12/17 Richard Quadling :
> 2009/12/17 唐家兴 :
>> I want to ask a strange question.
>>
>> As we know, if we connect a mysql database in the same host twice with the
>> same username, we won't get two new link, but two handle to only one link.
>> Then, if I close one of them, whether the other one will be closed together?
>>
>> I wrote two pieces of code. The first is like this
>> > $db1 = mysql_connect($host, $username, $pwd);
>> $db2 = mysql_connect($host, $username, $pwd);
>> $sql = 'show databases';
>> mysql_close($db1);
>> $res = mysql_query($sql, $db2);
>> $a = mysql_fetch_row($res);
>> print_r($a);
>> ?>
>> Then the output of the $db2 is correct. So the $db2 isn't closed together
>> with the $db1.
>>
>> But when I add a line among the code, the result is different
>> > $db1 = mysql_connect($host, $username, $pwd);
>> $db2 = mysql_connect($host, $username, $pwd);
>> $sql = 'show databases';
>> mysql_close($db1);
>> $db1 = true; //a new line
>> $res = mysql_query($sql, $db2);
>> $a = mysql_fetch_row($res);
>> print_r($a);
>> ?>
>> Then the output is wrong. The PHP tell me that the link is not a valid one.
>> I don't know how an assignment operation for the $db1 can close the $db2.
>> Could someone help me.
>> I'll appreciate your help.
>>
>
> When you xxx_connect() with the same parameters, internally, you are
> sharing the connection. It seems that killing one of the references
> kills all the references.
>
> The solution is to a use the fourth parameter on mysql_connect(). The
> "new_link" param.
>
> So ...
>
>  $db1 = mysql_connect($host, $username, $pwd, True); // Make sure a new
> link is created.
> $db2 = mysql_connect($host, $username, $pwd, True); // Make sure a new
> link is created.
> $sql = 'show databases';
> mysql_close($db1);
> $db1 = true; //a new line
> $res = mysql_query($sql, $db2);
> $a = mysql_fetch_row($res);
> print_r($a);
> ?>
>
> should work.
>

http://docs.php.net/mysql_connect


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] PHP to answer HEAD requests

2009-12-18 Thread Richard Quadling
2009/12/18 Dan Field :
> Is it possible to use PHP to answer HEAD http requests? Is it as simple as
> doing something like:
>
> header('blah')
> exit;
>
> I'd expect PHP to produce a full page rather than just a header though.
>
> --
> Dan Field                    Ffôn/Tel. +44 1970 632 582
> Peiriannydd Meddalwedd                          Senior Software Engineer
> Llyfrgell Genedlaethol Cymru                   National Library of Wales
>
>
>
>
>

$_SERVER['REQUEST_METHOD'] will/should contain the request type.
Documented as ...

"Which request method was used to access the page; i.e. 'GET', 'HEAD',
'POST', 'PUT'.
Note: PHP script is terminated after sending headers (it means after
producing any output without output buffering) if the request method
was HEAD."

See http://docs.php.net/manual/en/reserved.variables.server.php

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] File upload directive: $_FILES['filename']['name'] instead of $_FILES['filename']['tmp_name']

2009-12-23 Thread Richard Quadling
2009/12/22 Andrei Iarus :
> Hello,
>
> On my production & testing servers (production runs on a centrino and testing 
> runs on Windows) I can only access the temporary uploaded file using
> ini_get( 'upload_tmp_dir' . '/' . $_FILES['filename']['name'];
> while the file $_FILES['filename']['tmp_name'] simply does not exist (checked 
> with file_exists() function, and also looking in the temporary folder).
>
> Is there a problem with my PHP installations? Is there any directive to 
> change this bihaviour?
>
> On production: PHP 5.2.10 and on testing: PHP 5.2.8 and 5.3.0
>
> Thanks in advance.
>
>
>

2 functions to get to grips with:

1 - is_uploaded_file()
2 - move_uploaded_file()

Example from http://php.net/is_uploaded_file




-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] File upload directive: $_FILES['filename']['name'] instead of $_FILES['filename']['tmp_name']

2009-12-23 Thread Richard Quadling
2009/12/23 Andrei Iarus :
> Of course: also tried the is_uploaded_file, exactly like in the manual. And
> it fails :(
>
> --- On Wed, 12/23/09, Richard Quadling  wrote:
>
> From: Richard Quadling 
> Subject: Re: [PHP] File upload directive: $_FILES['filename']['name']
> instead of $_FILES['filename']['tmp_name']
> To: "Andrei Iarus" 
> Cc: php-general@lists.php.net
> Date: Wednesday, December 23, 2009, 6:10 PM
>
> 2009/12/22 Andrei Iarus :
>> Hello,
>>
>> On my production & testing servers (production runs on a centrino and
>> testing runs on Windows) I can only access the temporary uploaded file using
>> ini_get( 'upload_tmp_dir' . '/' . $_FILES['filename']['name'];
>> while the file $_FILES['filename']['tmp_name'] simply does not exist
>> (checked with file_exists() function, and also looking in the temporary
>> folder).
>>
>> Is there a problem with my PHP installations? Is there any directive to
>> change this bihaviour?
>>
>> On production: PHP 5.2.10 and on testing: PHP 5.2.8 and 5.3.0
>>
>> Thanks in advance.
>>
>>
>>
>
> 2 functions to get to grips with:
>
> 1 - is_uploaded_file()
> 2 - move_uploaded_file()
>
> Example from http://php.net/is_uploaded_file
>
> 
> if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
>    echo "File ". $_FILES['userfile']['name'] ." uploaded successfully.\n";
>    echo "Displaying contents\n";
>    readfile($_FILES['userfile']['tmp_name']);
> } else {
>    echo "Possible file upload attack: ";
>    echo "filename '". $_FILES['userfile']['tmp_name'] . "'.";
> }
>
> ?>
>
>
> --
> -
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>
>

What version of Windows?

Can you provide a really basic test?

And a var_dump($_FILES) please?

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] File upload directive: $_FILES['filename']['name'] instead of $_FILES['filename']['tmp_name']

2009-12-26 Thread Richard Quadling
2009/12/23 Andrei Iarus 
>
> Found the problem: I use Zend Framework, and after using a procedre, it is 
> automatically moved. :( Thanks very much, I thought it was a problem with 
> PHP, but from now on, it is a Zend Framework problem. Thanks again.
>
> --- On Wed, 12/23/09, Richard Quadling  wrote:
>
> From: Richard Quadling 
> Subject: Re: [PHP] File upload directive: $_FILES['filename']['name'] instead 
> of $_FILES['filename']['tmp_name']
> To: "Andrei Iarus" , "PHP General list" 
> 
> Date: Wednesday, December 23, 2009, 7:52 PM
>
> 2009/12/23 Andrei Iarus :
> > Of course: also tried the is_uploaded_file, exactly like in the manual. And
> > it fails :(
> >
> > --- On Wed, 12/23/09, Richard Quadling  wrote:
> >
> > From: Richard Quadling 
> > Subject: Re: [PHP] File upload directive: $_FILES['filename']['name']
> > instead of $_FILES['filename']['tmp_name']
> > To: "Andrei Iarus" 
> > Cc: php-general@lists.php.net
> > Date: Wednesday, December 23, 2009, 6:10 PM
> >
> > 2009/12/22 Andrei Iarus :
> >> Hello,
> >>
> >> On my production & testing servers (production runs on a centrino and
> >> testing runs on Windows) I can only access the temporary uploaded file 
> >> using
> >> ini_get( 'upload_tmp_dir' . '/' . $_FILES['filename']['name'];
> >> while the file $_FILES['filename']['tmp_name'] simply does not exist
> >> (checked with file_exists() function, and also looking in the temporary
> >> folder).
> >>
> >> Is there a problem with my PHP installations? Is there any directive to
> >> change this bihaviour?
> >>
> >> On production: PHP 5.2.10 and on testing: PHP 5.2.8 and 5.3.0
> >>
> >> Thanks in advance.
> >>
> >>
> >>
> >
> > 2 functions to get to grips with:
> >
> > 1 - is_uploaded_file()
> > 2 - move_uploaded_file()
> >
> > Example from http://php.net/is_uploaded_file
> >
> >  >
> > if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
> >    echo "File ". $_FILES['userfile']['name'] ." uploaded successfully.\n";
> >    echo "Displaying contents\n";
> >    readfile($_FILES['userfile']['tmp_name']);
> > } else {
> >    echo "Possible file upload attack: ";
> >    echo "filename '". $_FILES['userfile']['tmp_name'] . "'.";
> > }
> >
> > ?>
> >
> >
> > --
> > -
> > Richard Quadling
> > "Standing on the shoulders of some very clever giants!"
> > EE : http://www.experts-exchange.com/M_248814.html
> > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> > ZOPA : http://uk.zopa.com/member/RQuadling
> >
> >
>
> What version of Windows?
>
> Can you provide a really basic test?
>
> And a var_dump($_FILES) please?
>
> --
> -
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>

Glad you got it worked out.

--
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Instll php on Window 2003 64Bit questions

2010-01-04 Thread Richard Quadling
2010/1/3 Ashley Sheridan :
> On Sun, 2010-01-03 at 15:10 +0800, Edward S.P. Leong wrote:
>
>> Dear All,
>>
>> If the OS is Windows 2003 64Bit (IIS)...
>> So, which php package must download and how to config it for running
>> with IIS ?
>> Due to I don't quite the online manual:
>> http://www.php.net/manual/en/install.windows.iis.php
>> Which installation mode is suitable of it ?
>>
>> Thanks !
>>
>> Edward.
>>
>
>
> Personally I'd go with a WAMP install instead. Apache is faster, less
> resource intensive, and more secure than IIS. You also have the benefit
> of all the Apache mods out there, like mod_rewrite, which I believe
> you'd have to pay for on an IIS server.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

IIS7 has a URLRewrite module which is freely available via the Web
Platform Installer or via
http://learn.iis.net/page.aspx/460/using-url-rewrite-module

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] If design patterns are not supposed to produce reusable code then why use them?

2010-01-04 Thread Richard Quadling
2009/12/30 Tony Marston :
> I have recently been engaged in an argument via email with someone who
> criticises my low opinion of design patterns (refer to
> http://www.tonymarston.net/php-mysql/design-patterns.html ). He says that
> design patterns are merely a convention and not a reusable component. My
> argument is that something called a pattern is supposed to have a recurring
> theme, some element of reusability, so that all subsequent implementations
> of a pattern should require less effort than the first implementation. If
> design patterns do not provide any reusable code then what is the point of
> using them?
>
>
>
> I do not use design patterns as I consider them to be the wrong level of
> abstraction. I am in the business of designing and developing entire
> applications which comprise of numerous application transactions, so I much
> prefer to use transaction patterns (refer to
> http://www.tonymarston.net/php-mysql/design-patterns-are-dead.html and
> http://www.tonymarston.net/php-mysql/transaction-patterns.html ) as these
> provide large amounts of reusable code and are therefore a significant aid
> to programmer productivity.
>
>
>
> What is your opinion? Are design patterns supposed to provide reusable code
> or not? If not, and each implementation of a pattern takes just as much time
> as the first, then where are the productivity gains from using design
> patterns?
>
>
> --
> Tony Marston
> http://www.tonymarston.net
> http://www.radicore.org
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Hello Tony and everyone else (is it too late to say Happy New Year and
back to work?).

I think there seems to be a bit of a chicken and egg issue with your
comments of design patterns.

Design patterns are not blue-sky, out-of-the-box, (insert some other
marketing-speak here) concepts.

They are standardized descriptions of the purpose of code commonly seem.

They are not blocks of code to be reused.

They are nothing to do with code reuse per se.

They are to show you that the there are ways of standardizing your
approach to a problem based upon others experience. They are there to
act as templates for how you should be thinking.

Do they make you a better programmer? That depends. Do you have to
play with others? Is it easier to say we use the MVC, Active Record,
Registry and Factory Patterns? If the other members of your team do
NOT know these terms, then it is easy enough to read about them and
learn what they are for and then see how they've been implemented.
They give a common base.

Consider the alternative. I used to work on ICL System 25 running dmfx
with a 4GL style language which was converted to C before compilation
(and for the life of me I can't remember its name - it was over 20
years ago!).

The code I had to maintain was written by developers who used to write
in assembler macros. That whole argument about goto in modern
languages ... well, let's just say that THAT argument certainly didn't
exist for them.

The name that I heard for this style of coding was called "ladder
logic". No structure or common style that a newbie like me could see.

New programs were bastardised from old programs. Not cleanly, just
cobbled and a few goto's thrown in to bypass the unrequired bits. Why?
Cause only the original programmer knew what was going on and they'd
died a decade ago. Literally!

Jump forward through procedural and OOP and maybe AOP.

We all learn from the previous generation ("standing on the shoulders
of giants"). So. If they'd used design patterns back when I started
out, I'd've been able to understand the code better and faster.

I'd probably take just as long to write it, but I'd've been able to
describe it clearer and easier.

Design patterns are tools to help solve a problem. The solution MAY
involve some coding.

If you follow a design pattern, then others will be able to follow your code.

Design patterns are for community development. And probably for the
non-developer interviewers who want to see if the dweeb sat in front
of them knows his (reading from script) "Active Record" from his
(reading from script again) "Active Record" (No, sorry, just said
that, ...) "MVC" (wasn't that a chain of music shops in the UK?)...

Having said that, a real programmer only knows not to use Pascal!
Pretty much everything else is up for grabs.

Regards,

Richard.

P.S. I know nothing.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Luhn (modulo 10) check digit calculator

2010-01-05 Thread Richard Quadling
2010/1/5 Angus Mann :
> Hi all. Perhaps a lazy request, but does anybody have some cut-n-paste code 
> to calculate a Luhn check-digit?
>
> It's a check-digit often added to the end of things like credit card or 
> account numbers to make detecting typo's a bit easier.
>
> I found lots of code to validate a number once the check-digit is applied, 
> but nothing to calculate the digit in the first place.
>
> Thanks in advance !
> Angus
>
>

Modified version found at
http://blog.planzero.org/2009/08/luhn-modulus-implementation-php/

 9) {
$digit-=9;
  }
}
// Total up the digits
$total+=$digit;
  }

  return $total;
}

function luhn_checkdigit($number) {
  return 10 - (luhn_process($number . '0') % 20);
}


echo '49927398716 is ', (luhn_check('49927398716') ? 'Valid' :
'Invalid'), PHP_EOL;
echo 'The check digit for 4992739871 is ',
luhn_checkdigit('4992739871'), PHP_EOL;
?>


outputs ...

49927398716 is Valid
The check digit for 4992739871 is 6



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Luhn (modulo 10) check digit calculator

2010-01-05 Thread Richard Quadling
2010/1/5 Richard Quadling :
> 2010/1/5 Angus Mann :
>> Hi all. Perhaps a lazy request, but does anybody have some cut-n-paste code 
>> to calculate a Luhn check-digit?
>>
>> It's a check-digit often added to the end of things like credit card or 
>> account numbers to make detecting typo's a bit easier.
>>
>> I found lots of code to validate a number once the check-digit is applied, 
>> but nothing to calculate the digit in the first place.
>>
>> Thanks in advance !
>> Angus
>>
>>
>
> Modified version found at
> http://blog.planzero.org/2009/08/luhn-modulus-implementation-php/
>
>  /* Luhn algorithm number checker - (c) 2005-2008 - planzero.org            *
>  * This code has been released into the public domain, however please      *
>  * give credit to the original author where possible.                      */
>
> function luhn_check($number) {
>  // If the total mod 10 equals 0, the number is valid
>  return (luhn_process($number) % 10 == 0) ? TRUE : FALSE;
>
> }
>
> function luhn_process($number) {
>
>  // Strip any non-digits (useful for credit card numbers with spaces
> and hyphens)
>  $number=preg_replace('/\D/', '', $number);
>
>  // Set the string length and parity
>  $number_length=strlen($number);
>  $parity=$number_length % 2;
>
>  // Loop through each digit and do the maths
>  $total=0;
>  for ($i=0; $i<$number_length; $i++) {
>    $digit=$number[$i];
>    // Multiply alternate digits by two
>    if ($i % 2 == $parity) {
>      $digit*=2;
>      // If the sum is two digits, add them together (in effect)
>      if ($digit > 9) {
>        $digit-=9;
>      }
>    }
>    // Total up the digits
>    $total+=$digit;
>  }
>
>  return $total;
> }
>
> function luhn_checkdigit($number) {
>  return 10 - (luhn_process($number . '0') % 20);
> }
>
>
> echo '49927398716 is ', (luhn_check('49927398716') ? 'Valid' :
> 'Invalid'), PHP_EOL;
> echo 'The check digit for 4992739871 is ',
> luhn_checkdigit('4992739871'), PHP_EOL;
> ?>
>
>
> outputs ...
>
> 49927398716 is Valid
> The check digit for 4992739871 is 6
>
>
>
> --
> -
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>

And that 20 is a typo. Sorry.

function luhn_checkdigit($number) {
  return 10 - (luhn_process($number . '0') % 10);
}



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Re: splitting a string

2010-01-05 Thread Richard Quadling
2010/1/5 Ashley Sheridan :
> On Tue, 2010-01-05 at 08:45 -0600, Shawn McKenzie wrote:
>
>> Ingleby, Les wrote:
>> > Hi all, first time I have posted here so please be nice.
>> >
>> > I am using PEAR HTTP_Upload to handle multiple file uploads. What I need 
>> > to do is to take the file name which is output using the getProp() 
>> > function and then remove the file extension from the end of the file for 
>> > example:
>> >
>> > Original name held in the getProp() array [name] "word_doccument.docx"
>> >
>> > I need to put this into a string such as
>> >
>> > $filename = $props['name'];
>> >
>> > I then need to separate the file name from the file extension.
>> >
>> > I have been reading the php manual do please don't bother referring me to 
>> > that.
>> >
>> > Thanks in advance.
>> >
>> > LEGAL INFORMATION
>> > Information contained in this e-mail may be subject to public disclosure 
>> > under the Freedom of Information Act 2000. Unless the information is 
>> > legally exempt, the confidentiality of this e-mail and your reply cannot 
>> > be guaranteed.
>> > Unless expressly stated otherwise, the information contained in this 
>> > e-mail & any files transmitted with it are intended for the recipient 
>> > only. If you are not the intended recipient you must not copy, distribute, 
>> > or take any action or reliance upon it. If you have received this e-mail 
>> > in error, you should notify the sender immediately and delete this email. 
>> > Any unauthorised disclosure of the information contained in this e-mail is 
>> > strictly prohibited.  Any views or opinions presented are solely those of 
>> > the author and do not necessarily represent those of Tyne Metropolitan 
>> > College unless explicitly stated otherwise.
>> > This e-mail and attachments have been scanned for viruses prior to leaving 
>> > Tyne Metropolitan College. Tyne Metropolitan College will not be liable 
>> > for any losses as a result of any viruses being passed on.
>> >
>>
>> list($filename) = explode('.', $props['name']);
>>
>> Or if you may need the extension:
>>
>> list($filename, $extension) = explode('.', $props['name']);
>>
>> --
>> Thanks!
>> -Shawn
>> http://www.spidean.com
>>
>
>
> I just though. How would all these methods fare when given a file like
> archive.tar.gz, where the .tar.gz is the full extension, not just
> the .gz?
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>



outputs ...

Original : archve.tar.gz
Pathinfo : archve.tar / gz
Substr (right)   : archve.tar / .gz
Substr (left): archve / .tar.gz
List : archve / tar


The only option that seems to be working here (and one that wasn't
previously suggested) is to use

$substr_left_name  = substr($file, 0, strpos($file, '.'));
$substr_left_extension = substr($file, strpos($file, '.'));



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Re: splitting a string

2010-01-05 Thread Richard Quadling
pient you must not copy, distribute, or take any action 
> or reliance upon it. If you have received this e-mail in error, you should 
> notify the sender immediately and delete this email. Any unauthorised 
> disclosure of the information contained in this e-mail is strictly 
> prohibited.  Any views or opinions presented are solely those of the author 
> and do not necessarily represent those of Tyne Metropolitan College unless 
> explicitly stated otherwise.
> This e-mail and attachments have been scanned for viruses prior to leaving 
> Tyne Metropolitan College. Tyne Metropolitan College will not be liable for 
> any losses as a result of any viruses being passed on.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Make sure you check out the documentation at http://www.php.net/manual/en.

You can use http://www.php.net/function_name_here as a short cut -
e.g. http://www.php.net/substr

Pick one of the functions we've mentioned and follow the "See also"
for other related functions.

Regards,

Richard.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



[PHP] Using PHPDocumentor to document the magic functions.

2010-01-12 Thread Richard Quadling
Hi.

To implement public readonly properties you can use getX(), getY(),
getZ() methods (which then access the private vars) or you can use
__get($var) to consolidate/simplify the number of methods.

With the discrete getters() it is easy to docblock them. Everything is
obvious, but there is a LOT of duplicate code and documentation.

But how do you docblock __get()?

With the magic functions __get(), __set(), __call(), __callStatic(),
they act as proxies. It is NOT the proxy itself that is normally
wanted to be documented (maybe in a cursory manner), but what is being
proxied.


If you are creating a WSDL file for SOAP and have __get() and
__call(), then you would want to document each entry but without the
code duplication.


What is the best approach?


Regards,

Richard Quadling.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Using PHPDocumentor to document the magic functions.

2010-01-12 Thread Richard Quadling
2010/1/12 Jochem Maas :
> Op 1/12/10 12:46 PM, Richard Quadling schreef:
>> Hi.
>>
>> To implement public readonly properties you can use getX(), getY(),
>> getZ() methods (which then access the private vars) or you can use
>> __get($var) to consolidate/simplify the number of methods.
>>
>> With the discrete getters() it is easy to docblock them. Everything is
>> obvious, but there is a LOT of duplicate code and documentation.
>>
>> But how do you docblock __get()?
>>
>> With the magic functions __get(), __set(), __call(), __callStatic(),
>> they act as proxies. It is NOT the proxy itself that is normally
>> wanted to be documented (maybe in a cursory manner), but what is being
>> proxied.
>>
>>
>> If you are creating a WSDL file for SOAP and have __get() and
>> __call(), then you would want to document each entry but without the
>> code duplication.
>>
>>
>> What is the best approach?
>>
>
> this is a difficult problem, probably no real answer to it right now.
> I vaguely remember Derick Rethans mailing about this issue in regard to
> the ezComponents lib ... you might want to check that codebase for inspiration
> and or STW for what he had to say on the matter.
>
>>
>> Regards,
>>
>> Richard Quadling.
>>
>
>

@property and @method are my friends. Gee! Wood for trees.

Thanks.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] SMTP Local development to Send email in PHP; Windows Platform/ XP with no IIS

2010-01-15 Thread Richard Quadling
2010/1/15  :
> You can install any smtp server on your windows machine and the mail() will
> work with default settings. You can check this out:
> http://www.softstack.com/freesmtp.html
>
> Thanks,
>
> Vikash Kumar
> http://vika.sh
>
>
> On Fri, Jan 15, 2010 at 5:30 PM, Gaurav Kumar
> wrote:
>
>> Sorry Kim, don't want to use phpmailer script or manually setting user
>> accounts u/p in the script.
>>
>>
>>
>> On Fri, Jan 15, 2010 at 5:23 PM, Kim Madsen  wrote:
>>
>> > Hi Gaurav
>> >
>> > Gaurav Kumar wrote on 15/01/2010 09:54:
>> >
>> >
>> >  NO SMTP
>> >>
>> >> Any trusted SMTP software to install on local development machine and
>> how
>> >> to
>> >> set it up with php to send an email?
>> >>
>> >> Also just providing the SMTP server details in php.ini will not work for
>> >> me
>> >> as this requires authentication/credentials etc..
>> >>
>> >
>> > Get PHPmailer and make a gmail account that you connect to and mail
>> > through.
>> >
>> > --
>> > Kind regards
>> > Kim Emax - masterminds.dk
>> >
>>
>

You only need a local SMTP server if you want to hold and relay mail.

If you want to send mail directly to the recipients SMTP server you
can do that with standard PHP.

getmxrr() is your friend here.

You provide it with the domain of the recipient and you get back the
SMTP server(s) associated with that domain.

Now, you can send the message to THEIR smtp server ...

ini_set('SMTP', );

where  is one of the servers returned from getmxrr().

No authentication required.




-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server

2010-01-18 Thread Richard Quadling
2010/1/18 Edward S.P. Leong :
> Dear All,
>
> I had config the php.ini as the following :
> extension=php_mssql.dll
>
> Then run the cli "iisreset" and reboot the web server machine...
> After that, there is NO any MS-SQL within the phpinfo()...
> So, would you mind to help more ?
>
> Thanks !
>
> Edward.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

1 - Can you confirm that the ini file you are editing is the one that
is reported in phpinfo() as the file being used?
2 - At a command prompt, change directory to your PHP installation and type ...

php -m

See if you have any errors being reported.

If the INI file is in an unusual location, then use ...

php -c  -m

instead; e.g.

php -c D:\PHP\INI\php-cli.ini -m
php -c C:\windows\php-isapi.ini -m
etc.




-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Notices flooding logs with fastcgi

2010-01-18 Thread Richard Quadling
2010/1/18 Max Zimmermann :
> 2010/1/18 Ashley Sheridan 
>
>>  On Mon, 2010-01-18 at 12:20 +, Max Zimmermann wrote:
>>
>> Hello everybody,
>>
>> I have chosen this list because my problem is related to one particular
>> style of php installation. At least I think so.
>>
>> I'm running php 5.2.11 and plesk 9.2.3, php through fastCGI.
>>
>> My problem is that, since error_log is unset, php passes on any errors
>> to the webserver (-handler). This fills up my logs with hundreds of
>> MBytes of Notices every day, even though error_reporting is set to 6135
>> (notices shouldn't be logged).
>> So error_reporting appears to be ignored when error_log is unset and php
>> is run through fastcgi. Any idea how I can fix that?
>> I unfortunately can't change error_log to the appropriate path, because
>> the fastcgi user doesn't have access to the log directory...
>>
>> Here is an example log:
>> [Mon Oct 26 00:57:52 2009] [warn] mod_fcgid: stderr: PHP Notice:
>> Undefined offset: 1 in
>> /srv/www/vhosts//httpdocs/
>> x3/inc/shopstat_functions.inc.php on line 82
>>
>> Thanks so much in advance,
>> --
>> Cheers,
>>
>> Max
>>
>>
>> GNU/Linux - User #477672
>> PGP: 0x6C29B594
>>
>>
>> I believe that the reporting level is only used for errors displayed in the
>> browser window, not to the ones that are logged.
>>
>> If you're having your error logs fill up with errors, this isn't an issue
>> with PHP but the coder! It is obviously more than a few errors, unless your
>> website has millions of visitors each day triggering the same error, but
>> which is more likely a scenario?!
>>
>> I'd advise fixing those errors, even the warnings, as warnings are often a
>> prelude to a logic problem somewhere in the code.
>>
>>   Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>>
> Hey Ash,
>
> thanks for your reply.
> I know this is a coding issue, and xt:commerce always produces loads of
> notices. That said, I think the error_reporting setting does apply to
> logging when mod_php is used. I could be wrong though.
>
> But even fixing the whole of xt:commerce code to be notice free (which would
> be rediculously much work) doesn't solve the problem. Whenever anyone is
> installing something new on his website lying on this server, I'm gonna have
> the same problem again. I can't spend my whole time basically reviewing code
> that someone runs on the server... I think that's understandable ;)
> So I'm afraid I'm gonna need some other ideas :(
>
> Thanks again,
>
> Max
>

Don't log the errors!

Let them go to php's normal error log. If you can have a per-site
setup, then log them per site and pass them to the coder/owner to fix.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



[PHP] Casting objects.

2010-01-18 Thread Richard Quadling
Hello.

I've got an object via odbc_fetch_object (which is of stdClass).

I have an class structuresRemovalReason.

I want to cast the response of odbc_fetch_object to structuresRemovalReason.

The only way I can see of doing this is to not use odbc_fetch_object,
but odbc_fetch_assoc and then iterate the array and populate a new
structuresRemovalReason.

Or an I missing a trick. I'm pretty sure I am.

Regards,

Richard Quadling.

-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



[PHP] Re: Casting objects.

2010-01-19 Thread Richard Quadling
2010/1/18 Shawn McKenzie :
> Shawn McKenzie wrote:
>>>
>> Never mind, that was stupid. I saw that somewhere before, but obviously
>> it doesn't work.
>>
>
> I found some code, maybe I redeem myself?
>
> static public function cast(&$object, $class=__CLASS__){
>
>        if(class_exists($class)) {
>                $object = unserialize(
>                        preg_replace('/^O:[0-9]+:"[^"]+":/i',
>                        'O:'.strlen($class).':"'.$class.'":',
>                        serialize($object)));
>        }
> }
>
> $row = odbc_fetch_object($result);
> structuresRemovalReason::cast($row);
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
That's an interesting approach.

Though I'm going to use reflection. I realise I need to hold some of
the data in strings where the data is not a string (datetimes for
example).

So, using a docblock with a customtag and this seems to be working just fine.

Extended ReflectionClass and ReflectionProperty.

Thanks,

Richard.


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server

2010-01-19 Thread Richard Quadling
2010/1/19  :
> 引述 Richard Quadling :
>
>> 1 - Can you confirm that the ini file you are editing is the one that
>> is reported in phpinfo() as the file being used?
>
> Yes, BUT there is no MSSQL info of it...
>
>> 2 - At a command prompt, change directory to your PHP installation  and
>> type ...
>>
>> php -m
>>
>> See if you have any errors being reported.
>>
>> If the INI file is in an unusual location, then use ...
>>
>> php -c  -m
>
> T:\php5>php -c t:\php5\php.ini -m
> PHP Warning:  PHP Startup: Unable to load dynamic library
> 'T:\PHP5\ext\php_mssql
> .dll' - The specified module could not be found.
>  in Unknown on line 0
> [PHP Modules]
> bcmath
> calendar
> com_dotnet
> ctype
> date
> dom
> filter
> ftp
> gd
> hash
> iconv
> json
> libxml
> mbstring
> mcrypt
> mysql
> odbc
> pcre
> Reflection
> session
> SimpleXML
> SPL
> standard
> tokenizer
> wddx
> xml
> xmlreader
> xmlwriter
> zlib
>
> [Zend Modules]
>
> T:\php5\ext>dir php_mssql.dll
>  Volume in drive T is Data
>  Volume Serial Number is DC85-706F
>
>  Directory of T:\php5\ext
>
> 2009/12/16  下午 05:06            49,232 php_mssql.dll
>               1 File(s)         49,232 bytes
>               0 Dir(s)  52,215,365,632 bytes free
>
> T:\php5\ext>
>
> BTW : when running the cli of php -c t:\php5\php.ini -m, the system prompt
> me there is no "MSVCR71.dll" found...
> So, how can I install the dll file for test ( php -m ) again ?
>
> Thanks !
>
> Edward.
>
>
>
>
>
> 
> ITA Web Site : http://www.ita.org.mo
> E-mail Address : i...@ita.org.mo
>
>

It seems you are missing one (or more) of the MS Visual C Runtime files.

http://www.microsoft.com/downloads/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&displaylang=en
is where I'd go next.

But, first, I'd confirm this issue.

If you have depends.exe (http://www.dependencywalker.com/) to open the
php_mssql.dll and see if it reports the missing file in the same way -
look at the bottom of the bottom panel.

Whilst PHP _can_ find the php_mssql.dll file, it is unable to load it
due to missing libraries required by the dll.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] 64 bit date in 32 bit php ??

2010-01-19 Thread Richard Quadling
2010/1/19 Ashley Sheridan :
> On Mon, 2010-01-18 at 22:46 -0800, Michael A. Peters wrote:
>
>> php 5.2.12 running in CentOS 5.x
>>
>> Unfortunately, both my server (xen linode) and my test server (crappy
>> old dell I found in a field) are 32-bit. I need to work with some dates
>> earlier than 1901 and I would really prefer to store them in *nix time
>> in the database and use the date() function to format them for display
>> when I need to.
>>
>> My understanding is that 32 bit php has a lower limit in 1901 and upper
>> limit in 2038 for the date function.
>>
>> Is there a pcre / pecl / other wrapper that behaves identical to the
>> date function but uses a 64 bit float in 32 bit php?
>>
>> Yes, the right thing to do is probably to use 64 bit, and if I could I
>> would. A wrapper that just passes it off to date on 64 bit systems and
>> to date on 32 bit systems within what data can handle and only does its
>> magic on 32 bit systems with values beyond 32-bit date capabilities
>> would be sweet.
>>
>
>
> I've not used it, but the Pear Date class looks like it should do what
> you need. I've used other Pear classes before, and they are pretty easy
> to get to grips with, so I assume it should be the same for this one
> too.
>
> http://pear.php.net/package/Date
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

php -r "$o = new DateTime('1066-10-14T14:30:00+'); echo $o->format('r');"

Battle of Hastings. Just after 2:30 on the 14th of October 1066.

As I understand things, the DateTime class avoids the 32bit issue entirely.

Take a listen to the excellent PHP|Architect Summer Web cast from last
year by Derick Rethans [1] & [2].

Regards,

Richard.

[1] http://phparch.com/webcasts
[2] http://mtadata.s3.amazonaws.com/webcasts/20090828-date-time.wmv
-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server

2010-01-19 Thread Richard Quadling
But having said all of that, the php_mssql.dll uses a very old library
which may give you issues.

For the time being, using ODBC (php_odbc is built in for PHP on
Windows) is a much safer solution. You can also use the latest SQL
Native Client driver so you can talk to SQL7, 2000, 2005, 2008.

If you are used to using a DNS-less connection, then ...

$Conn = odbc_pconnect("Driver={SQL Server Native Client
10.0};Server={$Server};Database={$Database};MARS_Connection=Yes;",
$User, $Password, SQL_CUR_USE_DRIVER);

will give you the connection without the need to have a DNS entry.

-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server

2010-01-19 Thread Richard Quadling
2010/1/19 Edward S.P. Leong :
> Richard Quadling wrote:
>
>>But having said all of that, the php_mssql.dll uses a very old library
>>which may give you issues.
>>
>>For the time being, using ODBC (php_odbc is built in for PHP on
>>Windows) is a much safer solution. You can also use the latest SQL
>>Native Client driver so you can talk to SQL7, 2000, 2005, 2008.
>>
>>If you are used to using a DNS-less connection, then ...
>>
>>$Conn = odbc_pconnect("Driver={SQL Server Native Client
>>10.0};Server={$Server};Database={$Database};MARS_Connection=Yes;",
>>$User, $Password, SQL_CUR_USE_DRIVER);
>>
>>will give you the connection without the need to have a DNS entry.
>>
>>
> Hello to you,
>
> Where can we download the SQL Native Client driver for talking to MS-SQL
> ( eg : 2000 ) ?
>
> Thanks !
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en

and you also have the option of an official MS SQL driver for PHP

http://www.codeplex.com/SQLSRVPHP


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server

2010-01-20 Thread Richard Quadling
2010/1/20 Edward S.P. Leong :
> Richard Quadling wrote:
>
> 2010/1/19 Edward S.P. Leong :
>
>
> Richard Quadling wrote:
>
>
>
> But having said all of that, the php_mssql.dll uses a very old library
> which may give you issues.
>
> For the time being, using ODBC (php_odbc is built in for PHP on
> Windows) is a much safer solution. You can also use the latest SQL
> Native Client driver so you can talk to SQL7, 2000, 2005, 2008.
>
> If you are used to using a DNS-less connection, then ...
>
> $Conn = odbc_pconnect("Driver={SQL Server Native Client
> 10.0};Server={$Server};Database={$Database};MARS_Connection=Yes;",
> $User, $Password, SQL_CUR_USE_DRIVER);
>
> will give you the connection without the need to have a DNS entry.
>
>
>
>
> Hello to you,
>
> Where can we download the SQL Native Client driver for talking to MS-SQL
> ( eg : 2000 ) ?
>
> Thanks !
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
> http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>
>
> Sorry,
>
> Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
>
> Thanks !
>
> Edward.
>

Either ODBC or the MS SQL driver for PHP. Which ever suits you.

Both require the MS SQL Native Client (go for the latest).

That's it really.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server

2010-01-20 Thread Richard Quadling
2010/1/20 Richard Quadling :
> 2010/1/20 Edward S.P. Leong :
>> Richard Quadling wrote:
>>
>> 2010/1/19 Edward S.P. Leong :
>>
>>
>> Richard Quadling wrote:
>>
>>
>>
>> But having said all of that, the php_mssql.dll uses a very old library
>> which may give you issues.
>>
>> For the time being, using ODBC (php_odbc is built in for PHP on
>> Windows) is a much safer solution. You can also use the latest SQL
>> Native Client driver so you can talk to SQL7, 2000, 2005, 2008.
>>
>> If you are used to using a DNS-less connection, then ...
>>
>> $Conn = odbc_pconnect("Driver={SQL Server Native Client
>> 10.0};Server={$Server};Database={$Database};MARS_Connection=Yes;",
>> $User, $Password, SQL_CUR_USE_DRIVER);
>>
>> will give you the connection without the need to have a DNS entry.
>>
>>
>>
>>
>> Hello to you,
>>
>> Where can we download the SQL Native Client driver for talking to MS-SQL
>> ( eg : 2000 ) ?
>>
>> Thanks !
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>>
>> http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>>
>>
>> Sorry,
>>
>> Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
>>
>> Thanks !
>>
>> Edward.
>>
>
> Either ODBC or the MS SQL driver for PHP. Which ever suits you.
>
> Both require the MS SQL Native Client (go for the latest).
>
> That's it really.
>
> --
> -
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>
Microsoft SQL Server 2008 Native Client
Microsoft SQL Server 2008 Native Client (SQL Native Client) is a
single dynamic-link library (DLL) containing both the SQL OLE DB
provider and SQL ODBC driver. It contains run-time support for
applications using native-code APIs (ODBC, OLE DB and ADO) to connect
to Microsoft SQL Server 2000, 2005, or 2008. SQL Native Client should
be used to create new applications or enhance existing applications
that need to take advantage of new SQL Server 2008 features. This
redistributable installer for SQL Native Client installs the client
components needed during run time to take advantage of new SQL Server
2008 features, and optionally installs the header files needed to
develop an application that uses the SQL Native Client API.

Audience(s): Customer, Partner, Developer

X86 Package (sqlncli.msi) - 4549 KB -
http://go.microsoft.com/fwlink/?LinkId=123717&clcid=0x409
X64 Package (sqlncli.msi) - 7963 KB -
http://go.microsoft.com/fwlink/?LinkId=123718&clcid=0x409
IA64 Package (sqlncli.msi) - 2 KB -
http://go.microsoft.com/fwlink/?LinkId=123719&clcid=0x409


Microsoft SQL Server 2005 Driver for PHP
The SQL Server 2005 Driver for PHP is a PHP 5 extension that allows
for accessing data in all Editions of SQL Server 2005 and SQL Server
2008 (including Express Editions) from within PHP scripts. The driver
provides a procedural interface for accessing data and makes use of
PHP features, including PHP streams to read and write large objects.
With this release, the source code for the driver is available here:
http://go.microsoft.com/fwlink/?LinkID=123842&clcid=0x409 . The SQL
Server 2005 Driver for PHP relies on the Microsoft SQL Server Native
Client to communicate with SQL Server. For more information about SQL
Server Native Client, visit the SQL Server Native Client page on MSDN.

Audience(s): Developer, DBA

Download site - http://go.microsoft.com/fwlink/?LinkID=123470


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server

2010-01-20 Thread Richard Quadling
2010/1/20 Edward S.P. Leong :
> Richard Quadling wrote:
>
> http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>
>
> Sorry,
>
> Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
>
> Thanks !
>
> Edward.
>
>
>
> Either ODBC or the MS SQL driver for PHP. Which ever suits you.
>
> Both require the MS SQL Native Client (go for the latest).
>
> That's it really.
>
> Sorry,
>
> My means is which package support for connecting MS-SQL 2000 from php ?
> Due to I don't know which package ( file name ) I download it on the
> download site is suitable for me to use...
>
> Thanks !
>
> Edward.
>

As you are running IIS + PHP in 32bit mode, I'd stick with the x86 packages.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server

2010-01-20 Thread Richard Quadling
2010/1/20 Edward S.P. Leong :
> Richard Quadling wrote:
>
> 2010/1/20 Edward S.P. Leong :
>
>
> Richard Quadling wrote:
>
> http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>
>
> Sorry,
>
> Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
>
> Thanks !
>
> Edward.
>
>
>
> Either ODBC or the MS SQL driver for PHP. Which ever suits you.
>
> Both require the MS SQL Native Client (go for the latest).
>
> That's it really.
>
> Sorry,
>
> My means is which package support for connecting MS-SQL 2000 from php ?
> Due to I don't know which package ( file name ) I download it on the
> download site is suitable for me to use...
>
> Thanks !
>
> Edward.
>
>
>
> As you are running IIS + PHP in 32bit mode, I'd stick with the x86 packages.
>
>
>
> Hello,
>
> Do you means the x86 is suitable for me now ?
>
> Thanks !
>
> Edward.
>

If you were running 64 bit everything, then obviously, you would use
the 64 bit packages.

But you are running IIS and PHP in 32bit mode, so, for ease of
compatibility, the 32bit packages (x86 rather than x64) are what I
would be using.

In terms of which one you want to use, well, you have to get the Native Client.

>From there you can either use odbc (built into PHP for Windows) or use
the MS SQL Driver for PHP.

Both of them use the Native Client.

As the MS SQL driver is fairly new, you may want to stick with the
ODBC route within PHP.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Object Oriented Programming question

2010-01-20 Thread Richard Quadling
2010/1/20 tedd :
> Also IMO, one can argue the advantages that OOP and Design Patterns bring to
> the table over procedural, but after all is said and done, if you know your
> stuff in procedural, OOP is not going to provide you with much that you
> don't already have.

You also have to consider that whilst PHP provides all the fancy
clever OOP facilities, it is written in C, not C++. So, as you say, if
you know your stuff ...

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] could use some suggestions to speed this short piece of code up

2010-01-21 Thread Richard Quadling
2010/1/20 Rene Veerman :
> this is at least 1000% faster
>
> the crux is that array()+=array() is way faster than any array_merge()
> operations.
>
> global $hmGenKeys;
> $hmGenKeys = 0;
> function htmlMicroscope_generateRandomArray ($maxKeys, $maxDepth,
> $maxDuration=-1) {
>  global $hmGenKeys;
>  if ($maxKeys!==null) {
>    $hmGenKeys = $maxKeys;
>  }
>
>  $hmGenKeys--;
>  if ($hmGenKeys<=0) return false;
>  if ($maxDepth==0) return false;
>  srand(htmlMicroscope_randMakeSeed());
>  while ($hmGenKeys > 0) {
>      $range = rand(0,40);
>      file_put_contents('countdown.txt', $hmGenKeys);
>      for ($i=0; $i<$range && $hmGenKeys>=0; $i++) {
>        $hmGenKeys--;
>        if ($maxDuration!=-1 && $maxDuration < getDuration()) {
>          return false;
>        } else {
>            $r = array();
>            switch (rand(1,2)) {
>              case 1 :
>                $next = htmlMicroscope_generateRandomArray (null,
> $maxDepth-1, $maxDuration);
>                if ($next!==false)
>                  $r +=  array(
>                    htmlMicroscope_randomValue(3) => $next
>                  );
>                break;
>              case 2 :
>                $r += array(
>                  htmlMicroscope_randomValue(3) => 
> htmlMicroscope_randomValue(20)
>                );
>                break;
>            }
>        }
>      }
>  }
>  return $r;
> }
>
> function htmlMicroscope_randomValue($maxLength) {
>  $r = '';
>  switch (rand(0,9)) {
>    case 0 : $r = rand (0,1); break;
>    case 1 : $r = rand (0,1) / rand(1,100) / 3; break;
>    default:
>        switch (rand(0,1)) {
>          case 0:
>            for ($i = 0; $i < $maxLength; $i++) {
>              $r.= unichr(rand(0,hexdec('')));
>            }
>            break;
>          case 1:
>            for ($i = 0; $i < $maxLength; $i++) {
>              $r.=chr(rand(ord('a'),ord('z')));;
>            }
>            break;
>        }
>        break;
>  }
>  //echo $r.''.$maxLength.'';
>  return $r;
> }
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Also take a watch of the php|Architect webcast Jun 26Matthew
Turland New SPL Features in PHP 5.3.

This covered the ArrayObject and ArrayAccess class/interface. When
dealing with a LOT of data, this interface outperforms standard PHP
array.

http://www.phparch.com/webcasts
http://mtadata.s3.amazonaws.com/webcasts/20090623-spl.wmv

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



[PHP] Enforce a constant in a class.

2010-01-22 Thread Richard Quadling
Hello,

One of the aspects of an interface is to enforce a public view of a
class (as I see it).

Within PHP, interfaces are allowed to have constants, but you cannot
override them in a class implementing that interface.

This seems wrong.

The interface shouldn't define the value, just like it doesn't define
the content of the method, it only defines its existence and requires
that a class implementing the interface accurately matches the
interface.

Is there a reason for this behaviour?



_OR_

How do I enforce the presence of a constant in a class?



I want to enforce that any class implementing SetKillSwitch also has a
const KILL_SWITCH_DATE and a const KILL_SWITCH_NOTES.

I have to use reflection to see if the constant exists and throw an
exception when it doesn't.

The interface should only say that x, y and z must exist, not the
values of x, y and z.

Regards,

Richard.

--
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Re: Enforce a constant in a class.

2010-01-22 Thread Richard Quadling
2010/1/22 Pete Ford :
>
> IMHO, a constant is not the correct beastie in this case - if you want it to
> be different depending on the implementation then it ain't a constant!
>
> You should probably have protected static variables in the interface, and
> use the implementation's constructor to set the implementation-specific
> value (or override the default)
>
> interface SetKillSwitch
> {
>        protected static $isSet = TRUE;
>        protected static $notes;
>        protected static $date = '2010-01-22T11:23:32+';
> }
>
> class KilledClass implements SetKillSwitch
> {
>        public function __construct()
>        {
>                self::$isSet = FALSE;
>                self::$date = '2010-01-21T09:30:00+';
>                self::$notes = "Test";
>        }
> }
>
> Cheers
> Pete Ford

There is the problem. The interface is just saying that a killswitch
has been set. Not the date it was set, nor the notes. Thats specific
to the implentor.

In the implementor, they are constant.

In my mind, the interface is only saying that these elements need to
exist. Not what they are. Just like if I say there must be a method
X() in the interface, I don't define what it does.


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Enforce a constant in a class.

2010-01-22 Thread Richard Quadling
2010/1/22 Darren Karstens :
> One way to do it would be to use getter functions in your interface
> that return the value of the constant (or a member variable) in your
> implemented class. For example:
>
> interface SetKillSwitch {
>       public function getKillSwitchNotes();
> }
>
> Then in your class implement your getKillSwitchNotes function:
>
> class KilledClass implements SetKillSwitch {
>       const KILL_SWITCH_NOTES = 'Some notes';
>
>      public function getKillSwitchNotes()
>      {
>          return SetKillSwitch::KILL_SWITCH_NOTES;
>      }
> }
>

The killswitch is something I want to tag to a class (KILL_SWITCH_SET)

The class itself will have to be documented as to why it has been
killed off (KILLED_ON and KILL_SWITCH_NOTES).




-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Re: Enforce a constant in a class.

2010-01-22 Thread Richard Quadling
2010/1/22 Pete Ford :
> IMHO, a constant is not the correct beastie in this case - if you want it to
> be different depending on the implementation then it ain't a constant!
>
> You should probably have protected static variables in the interface, and
> use the implementation's constructor to set the implementation-specific
> value (or override the default)
>
> interface SetKillSwitch
> {
>        protected static $isSet = TRUE;
>        protected static $notes;
>        protected static $date = '2010-01-22T11:23:32+';
> }
>
> class KilledClass implements SetKillSwitch
> {
>        public function __construct()
>        {
>                self::$isSet = FALSE;
>                self::$date = '2010-01-21T09:30:00+';
>                self::$notes = "Test";
>        }
> }
>
> Cheers
> Pete Ford

And of course, "Fatal error: Interfaces may not include member variables".



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Enforce a constant in a class.

2010-01-22 Thread Richard Quadling
2010/1/22 Jochem Maas :
> constants in interfaces are not meant for this. a class constant doesn't
> constitute an interface. I believe constants in interfaces are allowed purely
> because it is helpful to have them defined outside of the global space and
> somewhere where all implementors of said interface can realiably reference 
> them.

Yep.

> I would suggest you need to define some extra methods in your interface e.g.
>
>        function getKillNotes();
>        function getKillTypeFlag();

The other option would be to be able to _easily_ detect the presence
of a class constant.

Without an error.

Fatal or otherwise.

$rfClass = ReflecionClass('KilledClass');
if (in_array('KILL_SWITCH_NOTES', $rfClass->getConstants())) { ...}

seems the only way.

You can't use getConstant('KILL_SWITCH_NOTES') as False is returned
for failure with no differentiation for a False value. Grrr.




Thanks to you all for the discussion.

Regards,

Richard.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Enforce a constant in a class.

2010-01-22 Thread Richard Quadling
2010/1/22 Ashley Sheridan 
> Constants are there for things that should never change. If you ever need to 
> change them, then whoever created the base class either didn't think things 
> through properly, or you're not. Imagine  a class that sets the value of π 
> (as is the erstwhile example for constants) If further classes that 
> implemented it were of a particular historical persuasion, then they might 
> want to redefine the constant as just 3. It seemed like a good idea to the 
> historical Roman Catholics at the time (it was defined as 3 in the Bible 
> after all) but it doesn't make it the correct value (imagine the problems 
> with volume calculations!)
>
> Constants are so called for a good reason!

And in the class that I want to enforce the presence of the constant,
it will be constant.

I just want to enforce the presence.


--
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Enforce a constant in a class.

2010-01-22 Thread Richard Quadling
2010/1/22 Jochem Maas :
> defined()

Sits.

Ponders.

Find's gun.

Shoots self!




-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Re: Enforce a constant in a class.

2010-01-25 Thread Richard Quadling
2010/1/25 Pete Ford :
> Richard Quadling wrote:
>>
>> 2010/1/22 Pete Ford :
>>>
>>> IMHO, a constant is not the correct beastie in this case - if you want it
>>> to
>>> be different depending on the implementation then it ain't a constant!
>>>
>>> You should probably have protected static variables in the interface, and
>>> use the implementation's constructor to set the implementation-specific
>>> value (or override the default)
>>>
>>> interface SetKillSwitch
>>> {
>>>       protected static $isSet = TRUE;
>>>       protected static $notes;
>>>       protected static $date = '2010-01-22T11:23:32+';
>>> }
>>>
>>> class KilledClass implements SetKillSwitch
>>> {
>>>       public function __construct()
>>>       {
>>>               self::$isSet = FALSE;
>>>               self::$date = '2010-01-21T09:30:00+';
>>>               self::$notes = "Test";
>>>       }
>>> }
>>>
>>> Cheers
>>> Pete Ford
>>
>> And of course, "Fatal error: Interfaces may not include member variables".
>>
>>
>>
>
> Ooops, sorry :)
>
> I tend to end up using abstract base classes rather than interfaces for that
> sort of reason...
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Essentially I was starting with the idea that a subclass with constant
X _MUST_ have constant Y and Z. That's what I wanted to enforce.

But, finding that defined() was enough, I now realize that Y and Z are
_not_ mandatory, but they are constants. So simply ...

$KillSwitchNotes = defined(get_called_class() . '::KILL_SWITCH_NOTES') ?: Null;

is enough and now the whole _MUST_ is gone and is now optional.

Much better.


Thank you to everyone who chipped in. Old dog should really have known
that old trick!


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



[PHP] Recursion issue with Zend_Soap_AutoDiscovery.

2010-01-25 Thread Richard Quadling
Hi.

I'm in the process of building a web service which incorporates the
ability for the server to inform the client that a particular call has
been superseded by another.

So, cut down (I've removed all the other details), ...

class ServiceDetails
{
/**
 * Superseded by
 *
 * Details of the replacement service that is now available.
 *
 * @var ServiceDetails
 */
public $SupersededBy = Null;
}

When I try to use Zend_Soap_AutoDiscover() against this class, I get ...

"Infinite recursion, cannot nest 'ServiceDetails' into itsself." (sic)

There has to be recursion, as there could be many levels of
supersedence, each one providing the details of their own replacement.

The call to return the service details read the requested
services/class constants. If there is a superseded entry, it creates a
new request for service details on the new class (the recursion).

If the value is Null, then there is no recursion.



I'm using ...

new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex');

as the strategy as the service has arrays of complex types in the output.



If I use @var string and then manually replace the type in the WSDL
file from ...

  

to

  

and use wsdl2php against this, it all _SEEMS_ to work OK.

So. Is this my best option? Or is there a way to do this that I'm missing?


Any ideas really.


Is this even a bug in the Zend_Soap_AutoDiscover class?



Regards,

Richard Quadling.




-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



[PHP] Re: Recursion issue with Zend_Soap_AutoDiscovery.

2010-01-26 Thread Richard Quadling
2010/1/25 Nathan Rixham :
> Richard Quadling wrote:
>> Hi.
>>
>> I'm in the process of building a web service which incorporates the
>> ability for the server to inform the client that a particular call has
>> been superseded by another.
>>
>> So, cut down (I've removed all the other details), ...
>>
>> class ServiceDetails
>>       {
>>       /**
>>        * Superseded by
>>        *
>>        * Details of the replacement service that is now available.
>>        *
>>        * @var ServiceDetails
>>        */
>>       public $SupersededBy = Null;
>>       }
>>
>> When I try to use Zend_Soap_AutoDiscover() against this class, I get ...
>>
>> "Infinite recursion, cannot nest 'ServiceDetails' into itsself." (sic)
>>
>> There has to be recursion, as there could be many levels of
>> supersedence, each one providing the details of their own replacement.
>>
>> The call to return the service details read the requested
>> services/class constants. If there is a superseded entry, it creates a
>> new request for service details on the new class (the recursion).
>>
>> If the value is Null, then there is no recursion.
>>
>>
>>
>> I'm using ...
>>
>> new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex');
>>
>> as the strategy as the service has arrays of complex types in the output.
>>
>>
>>
>> If I use @var string and then manually replace the type in the WSDL
>> file from ...
>>
>>           
>>
>> to
>>
>>           
>>
>> and use wsdl2php against this, it all _SEEMS_ to work OK.
>>
>> So. Is this my best option? Or is there a way to do this that I'm missing?
>>
>>
>> Any ideas really.
>>
>
> http://wso2.org/projects/wsf/php ;)
>
> helpful eh
>

Not yet! I'm on windows and I'm not confident enough to put extensions
I've built out on the live servers.

Also, it is using VC8 and I'm on 5.3 (VC9, x86, nts). So not tested.



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Re: Enforce a constant in a class.

2010-01-26 Thread Richard Quadling
2010/1/25 Colin Guthrie :
> 'Twas brillig, and Richard Quadling at 22/01/10 11:33 did gyre and gimble:
>> Hello,
>>
>> One of the aspects of an interface is to enforce a public view of a
>> class (as I see it).
>>
>> Within PHP, interfaces are allowed to have constants, but you cannot
>> override them in a class implementing that interface.
>>
>> This seems wrong.
>>
>> The interface shouldn't define the value, just like it doesn't define
>> the content of the method, it only defines its existence and requires
>> that a class implementing the interface accurately matches the
>> interface.
>>
>> Is there a reason for this behaviour?
>>
>>
>>
>> _OR_
>>
>> How do I enforce the presence of a constant in a class?
>>
>> > interface SetKillSwitch {
>>       const KILL_SWITCH_SET = True;
>>
>>       // Produces an error as no definition exists.
>>       // const KILL_SWITCH_NOTES;
>>
>>       // Cannot override in any class implementing this interface.
>>       const KILL_SWITCH_DATE = '2010-01-22T11:23:32+';
>> }
>>
>> class KilledClass implements SetKillSwitch {
>>       // Cannot override as defined in interface SetKillSwitch.
>>       // const KILL_SWITCH_DATE = '2010-01-22T11:23:32+';
>> }
>> ?>
>>
>> I want to enforce that any class implementing SetKillSwitch also has a
>> const KILL_SWITCH_DATE and a const KILL_SWITCH_NOTES.
>>
>> I have to use reflection to see if the constant exists and throw an
>> exception when it doesn't.
>>
>> The interface should only say that x, y and z must exist, not the
>> values of x, y and z.
>
> Forgive the perhaps silly question but why are you requiring to use
> constants here.
>
> I appreciate the desire to use Reflection but why not just define a
> method that must be implemented in the interface?
>
> interface SetKillSwitch {
>  public function getKillDate();
>  public function getKillNotes();
> }
>
>
> By virtue of something impementing the interface, you know the methods
> will exist.
>
> If you want to make implmentation of classes easier, then define and
> abstract class with an appropriate constructor and implementation:
>
>
> abstract class SetKillSwitchAbstract {
>  private $_killDate;
>  private $_killNotes;
>  protected function __construct($killDate, $killNotes)
>  {
>    $this->_killDate = $killDate;
>    $this->_killNotes = $killNotes;
>  }
>
>  public function getKillDate()
>  {
>    return $this->_killDate;
>  }
>
>  public function getKillNotes()
>  {
>    return $this->_killNotes;
>  }
> }
>
>
> You can either put your "implements SetKillSwitch" in this class or the
> derived classes depending on other methods you want to provide in the
> base class.
>
>
> I don't see why constants specifically are needed here. Rather than
> using reflection you can just use instanceof or similar to tell if a
> given object implements the interface or simply use the interface name
> as a type specifier on an argument to another function/method etc.
>
>
> Col
>
>
> --
>
> Colin Guthrie
> gmane(at)colin.guthr.ie
> http://colin.guthr.ie/
>
> Day Job:
>  Tribalogic Limited [http://www.tribalogic.net/]
> Open Source:
>  Mandriva Linux Contributor [http://www.mandriva.com/]
>  PulseAudio Hacker [http://www.pulseaudio.org/]
>  Trac Hacker [http://trac.edgewall.org/]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

With a constant, PhpDoc will pick up the value of the constant and
incorporate it into the documentation.

With a method, there is no way to know the return value. The type,
sure, but not the value.

Setting a constant is by far the simplest way to deal with this.

A method to return a constant is one method unneeded.

But, as I've said, I completely missed defined().

That's all I needed.

If the kill interface is applied to a class, then the parent class can
quite happily use defined(get_called_class() . '::KILL_SWITCH_SET') to
see if the class is defunct (or whatever).

Really. It was just the defined() call I missed. Everything is now working fine.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



[PHP] Re: Recursion issue with Zend_Soap_AutoDiscovery.

2010-01-27 Thread Richard Quadling
2010/1/25 Richard Quadling :
> Hi.
>
> I'm in the process of building a web service which incorporates the
> ability for the server to inform the client that a particular call has
> been superseded by another.
>
> So, cut down (I've removed all the other details), ...
>
> class ServiceDetails
>        {
>        /**
>         * Superseded by
>         *
>         * Details of the replacement service that is now available.
>         *
>         * @var ServiceDetails
>         */
>        public $SupersededBy = Null;
>        }
>
> When I try to use Zend_Soap_AutoDiscover() against this class, I get ...
>
> "Infinite recursion, cannot nest 'ServiceDetails' into itsself." (sic)
>
> There has to be recursion, as there could be many levels of
> supersedence, each one providing the details of their own replacement.
>
> The call to return the service details read the requested
> services/class constants. If there is a superseded entry, it creates a
> new request for service details on the new class (the recursion).
>
> If the value is Null, then there is no recursion.
>
>
>
> I'm using ...
>
> new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex');
>
> as the strategy as the service has arrays of complex types in the output.
>
>
>
> If I use @var string and then manually replace the type in the WSDL
> file from ...
>
>          
>
> to
>
>          
>
> and use wsdl2php against this, it all _SEEMS_ to work OK.
>
> So. Is this my best option? Or is there a way to do this that I'm missing?
>
>
> Any ideas really.
>
>
> Is this even a bug in the Zend_Soap_AutoDiscover class?
>
>
>
> Regards,
>
> Richard Quadling.
>
>
>
>
> --
> -
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>

I amended Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex::addComplexType().

Changing the (sic) ...

throw new Zend_Soap_Wsdl_Exception("Infinite recursion, cannot nest
'".$type."' into itsself.");

to ...

return "tns:$type";

and all is working just fine.

Obviously, I may be breaking something here, but I've not come across
it yet. Early days  !

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Multiple Class Inheritance

2010-01-27 Thread Richard Quadling
2010/1/27 Ryan Sun :
> 1, you can implement multiple interfaces
>
> 2, you may want to return object instead of extending classes,
> eg.
> class Small_Class_Abstract
> {
>  public function getFormGeneration()
>  {
>    return new Form_Generation();
>  }
> }
> class Small_Class_A extends Small_Class_Abstract
> {
> }
> $A = new Small_Class_A();
> $form = $A->getFormGeneration()->newForm();
>
> On Wed, Jan 27, 2010 at 7:52 AM, Ashley Sheridan
> wrote:
>
>> Hi All,
>>
>> I know that a class can only inherit from one other single class in PHP,
>> but how would I go about simulating a multiple class inheritance? For
>> example, if I had several small classes that dealt with things like form
>> generation, navbar generation, etc, how could I create a class in which
>> these all existed?
>>
>> Or am I thinking about this the wrong way? Should I have keep the
>> smaller classes, and have one larger object containing instances of each
>> as and how are necessary?
>>
>> I've used classes before, but I'm fairly new to class inheritance, and
>> more particularly, the complex inheritance like I describe here.
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>>
>

The Decorator pattern is an option here too I would guess.


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Richard Quadling
2010/1/27 Michael A. Peters :
> Paul M Foster wrote:
>>
>> "... should be obvious - but are often overlooked - points within coding
>> practice that can cause the programmer to develop bad habits and bad
>> code." - Dan Brown
>>
>> Tip #1:
>>
>> Don't use count() in loops unless there are very few items to count and
>> performance doesn't matter, or the number will vary over the loop. That
>> is, don't do this:
>>
>> for ($i = 0; $i < count($items); $i++)
>>
>> Instead, do this:
>>
>> $number = count($items);
>> for ($i = 0; $i < $number; $i++)
>
> Gah!
>
> for ($i=0;$i
> is something I do all the time.
> So the array size is being calculated each iteration?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

for ($i = 0, $j = count($a) ; $i < $j ; ++$i) {
}

is a very common way to handle that.

Of course...

foreach(range(0, count($a)) as $i) {
}

is an alternative.

You can see the effect of the counting if you replace ...

count($a)

with ...

mycount($a)

and have ...

function mycount($a) {
  echo 'Counting : ', count($a), PHP_EOL;
  return count($a);
}

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Richard Quadling
2010/1/27 Richard Quadling :
> 2010/1/27 Michael A. Peters :
>> Paul M Foster wrote:
>>>
>>> "... should be obvious - but are often overlooked - points within coding
>>> practice that can cause the programmer to develop bad habits and bad
>>> code." - Dan Brown
>>>
>>> Tip #1:
>>>
>>> Don't use count() in loops unless there are very few items to count and
>>> performance doesn't matter, or the number will vary over the loop. That
>>> is, don't do this:
>>>
>>> for ($i = 0; $i < count($items); $i++)
>>>
>>> Instead, do this:
>>>
>>> $number = count($items);
>>> for ($i = 0; $i < $number; $i++)
>>
>> Gah!
>>
>> for ($i=0;$i>
>> is something I do all the time.
>> So the array size is being calculated each iteration?
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> for ($i = 0, $j = count($a) ; $i < $j ; ++$i) {
> }
>
> is a very common way to handle that.
>
> Of course...
>
> foreach(range(0, count($a)) as $i) {
> }
>
> is an alternative.
>
> You can see the effect of the counting if you replace ...
>
> count($a)
>
> with ...
>
> mycount($a)
>
> and have ...
>
> function mycount($a) {
>  echo 'Counting : ', count($a), PHP_EOL;
>  return count($a);
> }



outputs ...

Counting : 10
Traditional for() loop 0
Counting : 10
Traditional for() loop 1
Counting : 10
Traditional for() loop 2
Counting : 10
Traditional for() loop 3
Counting : 10
Traditional for() loop 4
Counting : 10
Traditional for() loop 5
Counting : 10
Traditional for() loop 6
Counting : 10
Traditional for() loop 7
Counting : 10
Traditional for() loop 8
Counting : 10
Traditional for() loop 9
Counting : 10

Counting : 10
Modern for() loop 0
Modern for() loop 1
Modern for() loop 2
Modern for() loop 3
Modern for() loop 4
Modern for() loop 5
Modern for() loop 6
Modern for() loop 7
Modern for() loop 8
Modern for() loop 9

Counting : 10
Ultra-modern foreach() with range() loop 0
Ultra-modern foreach() with range() loop 1
Ultra-modern foreach() with range() loop 2
Ultra-modern foreach() with range() loop 3
Ultra-modern foreach() with range() loop 4
Ultra-modern foreach() with range() loop 5
Ultra-modern foreach() with range() loop 6
Ultra-modern foreach() with range() loop 7
Ultra-modern foreach() with range() loop 8
Ultra-modern foreach() with range() loop 9
Ultra-modern foreach() with range() loop 10


So, with the count inline, there are actually 11 calls to the count
compared to 1 in each of the other 2 scenarios.


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Reports generator

2010-01-28 Thread Richard Quadling
On 26 January 2010 17:54, PEPITOVADECURT  wrote:
> Exists any reports generator that exports directly to html/php?

Depending upon your platform, you have the option of using an external
report generator and invoking it appropriately from within PHP.

I'm on Windows and use Crystal Reports via PHP support of COM.

I then output the reports to MS Word, MS Excel, HTML or PDF -
depending upon the report/requirement/etc.

Due to the interface provided by Crystal, you can create an entire
report programmatically. It is a LOT of work, but it can be done.



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Appalling Dreamweaver performance

2010-01-31 Thread Richard Quadling
On 1 February 2010 00:28,   wrote:
>
> I use Dreamweaver as my editor, mainly because I'm familiar with it, although 
> I only use
> about 1% of its capabilities. However it generally handles long files well.  
> The other day
> I downloaded the two shortest of Brian Dunning's sets of test data *.  I 
> opened the
> shortest in Dreamweaver, had a quick look at it, and realised I would have to 
> replace the
> quote, comma, quote separators with semicolons, as part of converting the 
> files to my
> format.
>
> So I thought I would do that while I was working out what else I had to do. I 
> entered the
> old separator and the replacement in the 'Find and replace' window, then hit 
> 'Replace
> all', expecting the job be done in a few seconds. First I thought nothing was 
> happening,
> but then I realised it was trudging through the file, as if it was wading 
> through waist
> high molasses.
>
> So I closed the results window, and opened another file, but a few seconds 
> later focus
> switched back to the original file. I tried a couple of times more, but each 
> time it
> returned to the original window. I watched in morbid fascination for a bit, 
> then decided I
> would let it go, just to see how long it took.
>
> The file contained 500 lines, and was about 80 K. It was taking five seconds 
> to process
> each line, and eventually finished in about 40 minutes.
>
> The problem appeared to be the results processing. I have only looked at the 
> results list
> about twice, out of idle curiosity, but never saw any thing that I thought 
> could be
> remotely useful. I would like to be able to turn results logging off 
> altogether, as it
> wastes real estate (and time!), but this appears to be impossible.
>
> On this occasion the program was apparently writing a new line every time it 
> replaced a
> separator (9 times in each line), and then when it finished processing a line 
> it would
> erase all the intermediate result lines, and write a new one for the whole 
> line.  At the
> same time it reopened the results window if I had closed it, and return focus 
> to the file
> being processed.
>
> I then wrote a PHP program to read the file, split it, clean up and 
> re-arrange the various
> elements, enter them into an array in my format, and finally save it as a 
> file my program
> could handle.
>
>  After I had got this running on the 500 line file I used it to process the 
> 5000 line
> file. The whole process was done in the blink of an eye -- literally a 
> fraction of a
> second.
>
>
> * http://www.briandunning.com/sample-data/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

And the moral of the story is "Be happy that you learnt PHP!".


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] CLI behind proxy

2010-02-04 Thread Richard Quadling
On 4 February 2010 12:48, kranthi  wrote:
> Hi all,
>
> I want to run fsockopen etc behind a proxy.
> proxychains (http://proxychains.sourceforge.net/) may be helpful,
> unfortunately the support for that is pretty bad. Please inform me of other
> alternatives
>
> KK.
>

I used to use a proxy written in Python which provided the client NTLM
authentication to our ISA server for PHP.

So, PHP script talked to NTLM Authentication Proxy Server which talked
to ISA which talked to the outside world.

Worked fine.

The only thing I needed to do in PHP was setup a default context and
all my normal file_get_contents(),etc. which needed to communicate
through to the outside world worked fine.

Here is the code I used ...

// Define the default, system-wide context.
$r_default_context = stream_context_get_default
(
array
(
'http' => array
( // All HTTP requests are passed through the local 
NTLM proxy
server on port 8080.
'proxy' => 'tcp://127.0.0.1:8080',
'request_fulluri' => True,
),
)
);

// Though we said system wide, some extensions need a little coaxing.
libxml_set_streams_context($r_default_context);



So, set the proxy tcp address appropriately, put this code in a global
include file (maybe via the auto_prepend_file= ini file setting) and
see how you go.



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] CLI behind proxy

2010-02-04 Thread Richard Quadling
On 4 February 2010 14:19, kranthi  wrote:
> fsockopen

What type of socket are you opening?

-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] CLI behind proxy

2010-02-04 Thread Richard Quadling
On 4 February 2010 14:38, Richard Quadling  wrote:
> On 4 February 2010 14:19, kranthi  wrote:
>> fsockopen
>
> What type of socket are you opening?
>
> --
> -
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>

The code puts HTTP requests through the context.



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] CLI behind proxy

2010-02-04 Thread Richard Quadling
On 4 February 2010 15:27, kranthi  wrote:
> stream_socket_client("tcp://talk.google.com:5222")
> i m trying to use http://code.google.com/p/xmpphp/ actually
>

Does your proxy pass through all requests?

It might be easier to just set you NIC gateway to the proxy.

We stopped using ISA server with NTLM authentication.

Now, the gateway for my machine is the ISA server, so all requests go
through there automatically and we use AD for authentication.



-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] HTML & plain text in Outlook 2007

2010-02-05 Thread Richard Quadling
On 4 February 2010 16:44, Skip Evans  wrote:
> Hey all,
>
> First, let me say thanks for all the advice on Magento, and especially to
> Ryan who has used the beast and gave some great advice on skinning, links to
> some good docs and a book just for my designer. We'll be using and I'm
> looking forward to learning it.
>
> But anyway...
>
> I'm doing some maintenance work on a system that sends an email message
> using the multi-part boundaries to include both a plain text version and an
> HTML version of an email.
>
> I've read up on this before, but never actually done it. So implementing the
> code was not a big issue, and in fact it works perfectly when tested on my
> Ubuntu machine using Thunderbird to test the HTML and Evolution to test the
> plain text version. In fact, I can switch formats on both of these and all
> looks great.
>
> Enter Microsoft (Insert opening of Bach's Toccata and Fugue in D minor to
> send chills up my readers' spines.)
>
> On Outlook 2007 in HTML mode it renders, how can I put this... half-assedly.
> In text mode the whole things a bust. There is the HTML code all stuffed up
> at the top, boundary codes are visible, just plain awful.
>
> Googling around I see articles from 2007 when that version of Outlook came
> out lamenting the fact that MS pulled the IE rendering engine from it and
> replaced it with MS Word's renderer to plug security holes expoitable via
> email.
>
> Does anyone have any experience with HTML & plain text multi-part messages
> and Outlook 2007, or any tips how I can get this working? Still Googling,
> but any tips would be greatly appreciated.
>
> Skip
> --
> 
> Skip Evans
> PenguinSites.com, LLC
> 503 S Baldwin St, #1
> Madison WI 53703
> 608.250.2720
> http://penguinsites.com
> 
> Those of you who believe in
> telekinesis, raise my hand.
>  -- Kurt Vonnegut
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I create HTML.Mime based emails in PHP with a plain text part which is
basically a cop out saying that they should upgrade.

The HTML part is a fax form. They print it out, add some stickers
relating to work carried out and then fax it back (or email it as a
TIFF or PDF if they have the skills/tech to do that).

I use Outlook 2003 (work) and GMail via Chrome (personal).

The form includes embedded images (essentially their logo as the forms
are passed to their clients) and have a PDF attached ( a report from
our systems about the email they are receiving).

All fairly simple.

1 - Plain Text - (Please upgrade)
2 - Alternative HTML
3 -  Embedded images
4 - Attachment

For this, I use RMail from phpguru.org (previously known as
html_mime_mail5) http://www.phpguru.org/static/Rmail

The HTML I used contains limited CSS and is table based.

I initially did it "properly", or so I thought.

I'd used IE7/FireFox/Safari/Opera as a test of a proper HTML page with
CSS to produce a nice looking form. Scaled nicely, limited shrink,
etc.

Looked OK in Outlook 2003 too!

But when I sent them for approval to the line manager, who uses
Outlook 2007, well, let's just say he didn't understand the form at
all!

Even when I redid it with tables, I'd used , , 
(proper HTML at least). In O2K7? It renders in order - header, footer,
body. Great!

So, the HTML I ended up with REALLY looks like something from when I
was first learning HTML (I just worked it out as being 13 years ago!).

So, yes. The code is horribly old fashioned. But it works.


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Simple code obfuscation

2010-02-08 Thread Richard Quadling
On 8 February 2010 19:32, Brian Dunning  wrote:
> Hey all -
>
> I'm selling a custom PHP solution to FileMaker users. It uses FileMaker's PHP 
> API, so everyone who has FileMaker Server is already set up to use it, but 
> very few of them have any knowledge of how to set up a server or do anything 
> PHP related. But I do want to add some level of code obfuscation to prevent 
> them from making simple changes to my code that allow them to exceed the 
> privileges they've purchased.
>
> I've looked at custom code encryption services like Ioncube and phpCipher, 
> but in my estimation, deploying the needed server-side code for these is 
> going to be beyond the capabilities of a large segment of my customers. I 
> would rather have a few customers cheat me than offer a product that most 
> customers are unable to figure out how to run.
>
> So I was thinking of doing something like base64_encoding the crucial chunk 
> of my code (maybe 20 lines worth) and using 
> eval(base64_decode($that_content)) to run it. I figure that will scare away 
> most of the customers who might be able to edit my code. Can anyone suggest 
> something that goes one better?
>
> - Brian
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

For simple obfuscation, then maybe making a PHAR app may be of use here.

http://docs.php.net/phar


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Re: poll: howto do informative error handling without the fatalities

2010-02-09 Thread Richard Quadling
On 9 February 2010 11:48, Nathan Rixham  wrote:
> Rene Veerman wrote:
>> Hi,
>>
>> I'm looking for a strategy to do informative error handling at all
>> levels of my code, yet keep these errors non-fatal as often as
>> possible.
>
> error_log - for logging errors
> throw Exception - for show stoppers
> try/catch - for when you can handle a potential show stopper
>
> custom error logging / messaging can easily be achieved with something
> like this:
>
> 
> class Messenger
> {
>
>  private static $_messages = array();
>
>  public static function addMessage( $string )
>  {
>    self::$_messages[] = $string;
>    if( $string instanceof Exception ) {
>      echo self::report();
>    }
>  }
>
>  public static function report()
>  {
>    return implode( PHP_EOL , self::$_messages );
>  }
>
> }
>
> set_exception_handler( 'Messenger::addMessage' );
>
> Messenger::addMessage( 'little error report 1' );
> Messenger::addMessage( 'little error report 2' );
> Messenger::addMessage( 'little error report 3' );
> throw new Exception( 'this will stop the script' );
> // exception will kill the script; if you comment it out
> // or wrap it in a try catch then you can keep going..
> Messenger::addMessage( 'little error report 4' );
> // try catch exceptions and report them like this..
> try {
>  throw new Exception( 'we could catch this' );
> } catch ( Exception $e ) {
>  Messenger::addMessage( $e );
> }
> Messenger::addMessage( 'little error report 5' );
> // and when your done just echo it out or save it or..
> echo Messenger::report();
>
>
> Regards!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I have extended the standard exception class to send me an email
whenever an exception occurs.

I treat all errors on the live system as exceptions. They shouldn't
occur. If they do, I've missed something.

But at least I'll get a near instant notification of the issue, along
with the stack and all the params involved.

Very useful.



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Re: poll: howto do informative error handling without the fatalities

2010-02-09 Thread Richard Quadling
On 9 February 2010 12:55, Richard  wrote:
> Hi,
>
>> I have extended the standard exception class to send me an email
>> whenever an exception occurs.
>
> I did that once. Once being the operative word... :-) Ended up with
> tens of thousands of emails one morning. At first I thought... "Wow,
> maybe my popularity has grown somewhat". But it hadn't.
>
> --
> Richard Heyes
> HTML5 canvas graphing: RGraph - http://www.rgraph.net (updated 31st January)
> Lots of PHP and Javascript code - http://www.phpguru.org
>

But I bet you REALLY quickly fixed the problem!

Oh. BTW. Thanks for RMail (previously known as htmlmimemail5 if anyone
else is interested).



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Re: poll: howto do informative error handling without the fatalities

2010-02-09 Thread Richard Quadling
On 9 February 2010 14:20, Ashley Sheridan  wrote:
>
> On Tue, 2010-02-09 at 09:19 -0500, Robert Cummings wrote:
>
> Richard wrote:
> > Hi,
> >
> >> I have extended the standard exception class to send me an email
> >> whenever an exception occurs.
> >
> > I did that once. Once being the operative word... :-) Ended up with
> > tens of thousands of emails one morning. At first I thought... "Wow,
> > maybe my popularity has grown somewhat". But it hadn't.
>
> I have something similar... a cron job that checks the error_log file
> every 10 minutes and sends me the contents if any exist. I also set a
> special header so I can be sure it's not spam and appropriately route it
> into my mail folder maze, Much less spammy :)
>
> Cheers,
> Rob.
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
>
>
> Real developers don't have errors in their code; they're undocumented 
> features ;)
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>

So, no documentation AND bugs!!! Gee. I really wouldn't want to rely
on that code base!

--
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] create archive file in memory with zipArchive class

2010-02-09 Thread Richard Quadling
On 9 February 2010 15:42, Ryan Sun  wrote:
> I want to generate credential zip file for user on the fly with
> zipArchive and render it for download, so I created following code
> -
> $zip = new ZipArchive();
> $filename = '/tmp/xxx.zip';
> if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
>  throw new Exception();
> }
> if($zip)
> {
>     $zip->addFromString('xxx.xx', $fileString);
> }
> $zip->close();
> $fileString = file_get_contents($filename);
> unlink($filename);
>
> $this->getResponse()->setHeader('Content-Type', 'application/zip');
> $this->getResponse()->setHeader('Content-Disposition','attachment;filename=xxx.zip');
> $this->getResponse()->setBody($fileString);
> -
> it works, but I think creating the file in memory is a better
> approach, so I changed the 2nd lineI(using php 5.2.0) to
> $filename = 'php://temp/xxx.zip';
> then the php just won't archive the file and the file downloaded is
> just a plain text file.
>
> so
> question 1, how to create zip Archive file in memory on the fly and
> download it (I don't have to save it on disk)?
> question 2, if there is no way to create in memory, is it safe to just
> unlink() the file?
>
> thanks in advance.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

According to http://docs.php.net/manual/en/wrappers.php.php, it looks
like you should be using ...

$filename = 'php://temp';

That's it.

The actual file name is not your job.



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] create archive file in memory with zipArchive class

2010-02-10 Thread Richard Quadling
On 9 February 2010 16:47, Ryan Sun  wrote:
> thanks, Richard, maybe you are right, the actual file name is not my job
> I changed it to 'php://temp' but its still the same, nothing has been 
> changed...
>
> On Tue, Feb 9, 2010 at 11:13 AM, Richard Quadling
>  wrote:
>> On 9 February 2010 15:42, Ryan Sun  wrote:
>>> I want to generate credential zip file for user on the fly with
>>> zipArchive and render it for download, so I created following code
>>> -
>>> $zip = new ZipArchive();
>>> $filename = '/tmp/xxx.zip';
>>> if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
>>>  throw new Exception();
>>> }
>>> if($zip)
>>> {
>>>     $zip->addFromString('xxx.xx', $fileString);
>>> }
>>> $zip->close();
>>> $fileString = file_get_contents($filename);
>>> unlink($filename);
>>>
>>> $this->getResponse()->setHeader('Content-Type', 'application/zip');
>>> $this->getResponse()->setHeader('Content-Disposition','attachment;filename=xxx.zip');
>>> $this->getResponse()->setBody($fileString);
>>> -
>>> it works, but I think creating the file in memory is a better
>>> approach, so I changed the 2nd lineI(using php 5.2.0) to
>>> $filename = 'php://temp/xxx.zip';
>>> then the php just won't archive the file and the file downloaded is
>>> just a plain text file.
>>>
>>> so
>>> question 1, how to create zip Archive file in memory on the fly and
>>> download it (I don't have to save it on disk)?
>>> question 2, if there is no way to create in memory, is it safe to just
>>> unlink() the file?
>>>
>>> thanks in advance.
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> According to http://docs.php.net/manual/en/wrappers.php.php, it looks
>> like you should be using ...
>>
>> $filename = 'php://temp';
>>
>> That's it.
>>
>> The actual file name is not your job.
>>
>>
>>
>> --
>> -
>> Richard Quadling
>> "Standing on the shoulders of some very clever giants!"
>> EE : http://www.experts-exchange.com/M_248814.html
>> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
>> ZOPA : http://uk.zopa.com/member/RQuadling
>>
>

It looks like this isn't possible.





-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] RE: SOAP connect error

2010-02-10 Thread Richard Quadling
On 9 February 2010 22:14, Eric Lommatsch  wrote:
>>-Original Message-
>>From: Shawn McKenzie [mailto:nos...@mckenzies.net]
>>Sent: Tuesday, February 09, 2010 3:07 PM
>>To: Eric Lommatsch
>>Cc: php-general@lists.php.net
>>Subject: Re: SOAP connect error
>>
>>Eric Lommatsch wrote:
>>> Hello,
>>>
>>> I am working with the SOAP package of PHP and I am trying make a
>>> connection from a hosted website to a server in our office.
>>>
>>> I can get to the server perfectly fine from within our office, but I
>>> cannot connect from the eternal site.
>>>
>>> I have checked and I am certain that the firewall for the server is open.
>>> When I attempt to use the login page that I have created for the
>>> website I am getting the following error message:
>>>
>>> Connect Error to XX.XX.XX.XXX:8080
>>>
>>> Where XX.XX.XX.XXX mask the actual ip address of the server. I have
>>> tried to interogate all the values that soap_fault documents that it
>>> can return and the only information I have been able to find beside
>>> the above message, which is the $errorstring, is that my $faultcode =
> "HTTP".
>>>
>>> The information that I am getting is very cryptic. if I include our ip
>>> address when I search I get no results. If I put in connect error
>>> :8080 I get millions of meaningless results.
>>>
>>> Can someone please help to figure out how to get more meaningful
>>> information from soap_fault for this problem so that I can figure out how
> to fix it.
>>>
>>> Thank you
>>>
>>> Eric H. Lommatsch
>>> Programmer
>>> 360 Business
>>> 2087 South Grant Street
>>> Denver, CO 80210
>>> Tel 303-777-8939 Ext 23
>>> Fax 888-282-9927
>>>
>>> er...@360b.com
>>>
>>>
>>
>>If you go home or to Starbucks can you get to http://XX.XX.XX.XXX:8080 ?
>> If not, then the external server can't either.  It could be a network
> firewall/proxy sever in your office, or any number of things.
>>
>>--
>>Thanks!
>>-Shawn
>>http://www.spidean.com
>
>
> I have connected to a clients computer that is remote from our office and I
> am able to get to http://XX.XX.XX.XXX:8080. I probably should have mentioned
> that when I try to get the webservice outside of the PHP site I am developing
> I can get into that just fine. It is just when I try to use the PHP SOAP
> client to access the webservice that I am getting the issue.
>
>
> Thank you
>
> Eric H. Lommatsch
> Programmer
> 360 Business
> 2087 South Grant Street
> Denver, CO 80210
> Tel 303-777-8939 Ext 23
> Fax 888-282-9927
>
> er...@360b.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Are you using wsdl? If so, does the WSDL file contain the information
that the port to use for the requests is on port 8080?

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Re: poll: howto do informative error handling without the fatalities

2010-02-10 Thread Richard Quadling
On 9 February 2010 22:25,   wrote:
> On Tue, 9 Feb 2010 16:09:05 +, rquadl...@googlemail.com (Richard 
> Quadling) wrote:
>
>>On 9 February 2010 14:20, Ashley Sheridan  wrote:
>>>
>>> On Tue, 2010-02-09 at 09:19 -0500, Robert Cummings wrote:
>>>
>>> Richard wrote:
>>> > Hi,
>>> >
>>> >> I have extended the standard exception class to send me an email
>>> >> whenever an exception occurs.
>>> >
>>> > I did that once. Once being the operative word... :-) Ended up with
>>> > tens of thousands of emails one morning. At first I thought... "Wow,
>>> > maybe my popularity has grown somewhat". But it hadn't.
>>>
>>> I have something similar... a cron job that checks the error_log file
>>> every 10 minutes and sends me the contents if any exist. I also set a
>>> special header so I can be sure it's not spam and appropriately route it
>>> into my mail folder maze, Much less spammy :)
>>>
>>> Cheers,
>>> Rob.
>>> --
>>> http://www.interjinn.com
>>> Application and Templating Framework for PHP
>>>
>>>
>>> Real developers don't have errors in their code; they're undocumented 
>>> features ;)
>>>
>>> Thanks,
>>> Ash
>>> http://www.ashleysheridan.co.uk
>>>
>>>
>>
>>So, no documentation AND bugs!!! Gee. I really wouldn't want to rely
>>on that code base!
>
> So you don't use (or work with) any Microsoft product?
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

The closest I get is MSSQL which has BOL (Books OnLine). Its enough.

Occasionally MS Excel VBA which is fairly well documented and always
accessible via a COM interface (so self documenting more or less).

But point taken.

And only 12 MS critical updates today! Woo Hoo!

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] PHP Manual problems

2010-02-10 Thread Richard Quadling
On 10 February 2010 13:02, Ashley Sheridan  wrote:
> I've not had any personal experience with the public sector, but I have
> heard stories from those who have. By all accounts, it seems that most
> of the public sector is still stuck in the dark ages with regards to
> technology, which could go some way to explaining the abysmal failure
> rate of public sector projects! Open source in this sector would be a
> perfect solution in most cases, but it's shunned because of fear of the
> unknown and worry that anything free is worth the money paid for it.

I used to work for a company creating Payroll/Personal software. Our
software was cheaper than the BIG boys, and several times, when it
came to getting it into councils where there was little tech
knowledge/skills, the lower prices worked against us.

And once they knew the price, we couldn't just hike it up to get the deal.

Dark ages indeed!


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Simple code obfuscation

2010-02-10 Thread Richard Quadling
On 10 February 2010 14:33, דניאל דנון  wrote:
> Sent from my mobile device
>
> Use ROT26 for best security

I can't read a word of that!


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] problems with permissions or getting access to a file

2010-02-10 Thread Richard Quadling
On 10 February 2010 16:31, Pat  wrote:
> hi all
> having trouble here with a site that I am hosting on go-daddy
>
> I want to keep my php and my images apart
>
> so to do this I have the base directory which contains the php scripts. On
> the directory above that I have
> my photos stored in /photos
>
> when I run my scripts I get the following:
>
> time -4 hours1265815323 <
> *Warning*: filemtime() [function.filemtime
> <http://www.patrickrice.net/tomdcam/function.filemtime>]: stat failed for
> testPanasonicCamMotion20100201022429140.jpg in
> */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Hours.php* on line
> *16*
>
> 1265815323
>
> *Warning*: filemtime() [function.filemtime
> <http://www.patrickrice.net/tomdcam/function.filemtime>]: stat failed for
> testPanasonicCamMotion20100201022429140.jpg in
> */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Hours.php* on line
> *28*
> 0
> time -4 hours1265815323 <
> *Warning*: filemtime() [function.filemtime
> <http://www.patrickrice.net/tomdcam/function.filemtime>]: stat failed for
> testPanasonicCamMotion20100201022619570.jpg in
> */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Hours.php* on line
> *16
>
> *_The script is the following below _from running this script, I keep
> getting this error, now when I copy this script in to the directory photo
> where the photos are stored, the script displays the images with no problems
> leaving me think that the issue is with the permissions, I have modified the
> pre-emptions to give all access as a test and still problems. Anyone got any
> Ideas??
>
> Thanks in advance.
> Pat
>
>  6   7 $debug =1;
>  8 $d = dir('/home/content/j/a/c/jackcards/html/tomdcam/photo/') or
> die($php_errormsg);
>  9 while (false !== ($f = $d->read())) {
> 10     // only match alphabetic names
> 11     if (preg_match('/testPanasonicCamMotion/',$f)) {
> 12
> 13         if ($debug == 1) {
> 14         echo "time -4 hours" . strtotime("- 1 hours" ). "      <    ";
> 15
> 16         echo filemtime($f);
> 17         echo "  ";
> 18         }//end debug
> 19
> 20         $FourHoursAgo = intval(strtotime("- 1 hours" ));
> 21
> 22         if ($debug == 1) {
> 23         echo $FourHoursAgo;
> 24 #      25         echo "";
> 26         }
> 27
> 28         $dateOfFileModify = intval(date((filemtime($f)) ));
> 29
> 30         if ($debug == 1) {
> 31         echo $dateOfFileModify;
> 32         echo "";
> 33         }
> 34
> 35
> 36         if ($FourHoursAgo < $dateOfFileModify)
> 37 #       if(intval(strtotime("- 4 hours" )) <
> intval(strtotime(filemtime($f))) )
> 38
> 39 #       if (strcmp(strtotime("- 4 hours" ),strtotime(filemtime($f)) ) >
> 0)
> 40
> 41         {
> 42         #echo ' Images less than 4 hours ';
> 43
> 44
> 45
> 46
> 47         print "filename: $f ";
> 48         print " \n";
> 49
> 50 #       echo "Last accessed on: " . date("d-m-y H:i:s", strtotime("+ 8
> hours", fileatime($f)) );
> 51 #       echo "";
> 52         echo "Last modified on: " . date("d-m-y H:i:s", strtotime("+ 8
> hours", filemtime($f)) );
> 53         echo " ";
> 54         }//end of if statment
> 55
> 56
> 57 #       else {
> 58 #               print "  None Found ";
> 59 #       }
> 60     }
> 61 }
> 62 $d->close();
> 63
> 64
> 65 ?>
>
> *
> *
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

read() only returns the filename, not the full path.

So, when the script is in the same directory, the current directory
contains the required file.

Try using ...

filemtime(realpath($f))

instead.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] problems with permissions or getting access to a file

2010-02-11 Thread Richard Quadling
On 11 February 2010 09:31, Pat  wrote:
> Richard Quadling wrote:
>>
>> On 10 February 2010 16:31, Pat  wrote:
>>
>>>
>>> hi all
>>> having trouble here with a site that I am hosting on go-daddy
>>>
>>> I want to keep my php and my images apart
>>>
>>> so to do this I have the base directory which contains the php scripts.
>>> On
>>> the directory above that I have
>>> my photos stored in /photos
>>>
>>> when I run my scripts I get the following:
>>>
>>> time -4 hours1265815323 <
>>> *Warning*: filemtime() [function.filemtime
>>> <http://www.patrickrice.net/tomdcam/function.filemtime>]: stat failed for
>>> testPanasonicCamMotion20100201022429140.jpg in
>>> */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Hours.php* on
>>> line
>>> *16*
>>>
>>> 1265815323
>>>
>>> *Warning*: filemtime() [function.filemtime
>>> <http://www.patrickrice.net/tomdcam/function.filemtime>]: stat failed for
>>> testPanasonicCamMotion20100201022429140.jpg in
>>> */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Hours.php* on
>>> line
>>> *28*
>>> 0
>>> time -4 hours1265815323 <
>>> *Warning*: filemtime() [function.filemtime
>>> <http://www.patrickrice.net/tomdcam/function.filemtime>]: stat failed for
>>> testPanasonicCamMotion20100201022619570.jpg in
>>> */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Hours.php* on
>>> line
>>> *16
>>>
>>> *_The script is the following below _from running this script, I keep
>>> getting this error, now when I copy this script in to the directory photo
>>> where the photos are stored, the script displays the images with no
>>> problems
>>> leaving me think that the issue is with the permissions, I have modified
>>> the
>>> pre-emptions to give all access as a test and still problems. Anyone got
>>> any
>>> Ideas??
>>>
>>> Thanks in advance.
>>> Pat

>>
>> read() only returns the filename, not the full path.
>>
>> So, when the script is in the same directory, the current directory
>> contains the required file.
>>
>> Try using ...
>>
>> filemtime(realpath($f))
>>
>> instead.
>>
>>
>
> Thanks Richard, It was really wrecking my head.
> Pat
>

No problem.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] RE: SOAP connect error

2010-02-12 Thread Richard Quadling
On 11 February 2010 16:04, Eric Lommatsch  wrote:
>
>>Are you using wsdl? If so, does the WSDL file contain the information that
> the port to use for the requests is on port 8080?
>>
>>--
>>-
>>Richard Quadling
>>"Standing on the shoulders of some very clever giants!"
>>EE : http://www.experts-exchange.com/M_248814.html
>>EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>>Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
>>ZOPA : http://uk.zopa.com/member/RQuadling
>
> First, I am sorry for not getting back to this yesterday. I had some other
> things come up.
>
> As far as I know this website is using WSDL. I know that one of the early
> issues I ran into in trying to get this to work was not having the wsdl.php
> file in the path.
>
> That having been said are you talking about the wsdl file on the server that
> is providing the service or are you talking about the wsdl file on the system
> hosting the webpage.
>
> I can get everything to work correctly when I am working from our internal
> development server. But when I attempt to put the file on the hosted site our
> clients would ultimately be using I am getting the connect error.
>
> I have compared the wsdl.php files on these two servers and neither of them
> have specific information about the port in them.
>
> Here is the code that I am using to connect to the webservice:
>
>        $webservices_uri =
> "http://xx.xx.xx.xx:8080/jasperserver/services/repository";;
>
> Here is the code where I am trying to connect:
>
>        function ws_checkUsername($username, $password)
>        {
>                $connection_params = array("user" => $username, "pass" =>
> $password);
>                $info = new SOAP_client($GLOBALS["webservices_uri"], false,
> false, $connection_params);
>
>                $op_xml = " operationName=\"list\"> uriString=\"\" isNew=\"false\">".
>                "";
>
>                $params = array("request" => $op_xml );
>                $response = $info->call("list",$params,array('namespace' =>
> $GLOBALS["namespace"]));
>
>                return $response;
>        }
>
> This is working when I use the IP address of the server behind the firewall,
> but when I try to use the address that is open through the firewall it is not
> connecting. I can connect to the external IP address by entering it into the
> browser and it does ask for the username and password.
>
> Thank you
>
> Eric H. Lommatsch
> Programmer
> 360 Business
> 2087 South Grant Street
> Denver, CO 80210
> Tel 303-777-8939 Ext 23
> Fax 888-282-9927
>
> er...@360b.com
>

Run this at the command line ...

php -r "echo file_get_contents('http://www.google.com');"

Do you get the google home page?

I suspect your browser is using a proxy, but your default gateway is
set to something different


There should only be 1 WSDL url. That is the URL of the WSDL file
associated with the service you are using.

It may be cached to a physical file.

Either way, it probably doesn't know that YOU are behind a firewall.

So. You need to proxy the calls.

You can use the default stream context.

Take a look at my user note on
http://www.php.net/manual/en/function.stream-context-get-default.php.
The site it relates to is probably dead now.

You may be able to assign the proxy details to the SOAPClient.

"For HTTP authentication, the login and password options can be used
to supply credentials. For making an HTTP connection through a proxy
server, the options proxy_host, proxy_port, proxy_login and
proxy_password are also available. For HTTPS client certificate
authentication use local_cert and passphrase options. An
authentication may be supplied in the authentication option. The
authentication method may be either SOAP_AUTHENTICATION_BASIC
(default) or SOAP_AUTHENTICATION_DIGEST."
(http://www.php.net/manual/en/soapclient.soapclient.php#soapclient.soapclient.parameters)


Does any of that help?

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] optional object arguments to a function

2010-02-13 Thread Richard Quadling
On 13 February 2010 10:07, Jochem Maas  wrote:
> Op 2/13/10 8:05 AM, Michael A. Peters schreef:
>> I've started working on a class using DOMDocument to assemble MathML in
>> php. The class, assuming I actually succeed, will eventually be used for
>> parsing LaTeX math equations to MathML without the need to have TeX
>> installed. I probably won't be able to support all the possibilities for
>> equations that LaTeX does w/o a TeX install (and definitely not user
>> defined macros) but I suspect I can (hopefully) cover most of the common
>> stuff.
>>
>> One thing I don't know how to do, though, is write a function where
>> arguments are optional object.
>>
>> IE for a function to generate an integral, the limits are optional but
>> if specified must be an object (since they may be an equation
>> themselves). I want the default to be some kind of a null object so I
>> know to do nothing with it if it is null.
>>
>> With string/integer you just do
>>
>> function foo($a='',$b='',$c=false) {
>>   }
>>
>> How do I specify a default null object, or otherwise make the argument
>> argument optional?
>
> this first one doesn't work:
>
> 
> class Foo
> {
>        function dobar(stdObject $o = null) { /* ... */ }
> }
>
> $e = new Foo;
> $f = new Foo;
>
> $f->dobar();                    // works
> $f->dobar($e);                  // catchable fatal
> $f->dobar((object)array());     // catchable fatal - check the error msg!?!?
>
> ?>
>
> ... but if you're able/willing to specify a user defined class then you
> have this option:
>
> 
> class Bar {}
>
> class Foo
> {
>        function dobar(Bar $o = null) { /* ... */ }
> }
>
> $b = new Bar;
> $f = new Foo;
>
> $f->dobar($b);
> $f->dobar();
>
> ?>
>
>>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Try stdClass.

If you know the class type, then that can be the type hint.

You can also use func_get_args() to read all the parameters and type
check them if there are MANY optional parameters.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Quick research

2010-02-15 Thread Richard Quadling
On 14 February 2010 20:14, Nathan Rixham  wrote:
> Hi All,
>
> If you have 2 seconds could you answer the following 1 (one) question
> please  http://poll.fm/1lr8t
>
> Many thanks in advance if you answer, yes it is PHP related (ultimately)
> & need to get a good cross section of exposure.
>
> Nathan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

You need another option of "I don't use Linked Data".


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



[PHP] DocBlocking SOAP types.

2010-02-16 Thread Richard Quadling
Hi.

I want to docblock a set of properties to be xml primitive datatypes [1].

Considering that this is the correct type for the XML/SOAP/WSDL
communication, how do I "bypass" Zend_WSDL / Zend_AutoDiscovery so
that these types go through cleanly. I know that as far as PHP is
concerned, the type is loose and it will be my responsibility to
encode the values accordingly. It is in the WSDL generation, and hence
the docblocks, that I want these types to be valid.

I think I can achieve this by the following steps.

1 - Create a new concrete class from the
Zend_Soap_Wsdl_Strategy_Abstract abstract class, say
Zend_Soap_Wsdl_Strategy_W3C (as the type are defined by W3C).
2 - Implement the addComplexType() method to validate the type against
the list and return it if is OK.

What I am stuck on is how do I cascade from the new class so that I
can still drop back to the Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex.

I think the Zend_Soap_Wsdl_Strategy_Composite is of use here, but I
can't quite work out how to use it.

Any ideas would be appreciated.

Regards,

Richard Quadling.

[1] http://www.w3.org/TR/xmlschema11-2/#built-in-primitive-datatypes

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



[PHP] Re: DocBlocking SOAP types.

2010-02-16 Thread Richard Quadling
On 16 February 2010 16:41, Nathan Rixham  wrote:
> Nathan Rixham wrote:
>> Richard Quadling wrote:
>>> Hi.
>>>
>>> I want to docblock a set of properties to be xml primitive datatypes [1].
>>>
>>> Considering that this is the correct type for the XML/SOAP/WSDL
>>> communication, how do I "bypass" Zend_WSDL / Zend_AutoDiscovery so
>>> that these types go through cleanly. I know that as far as PHP is
>>> concerned, the type is loose and it will be my responsibility to
>>> encode the values accordingly. It is in the WSDL generation, and hence
>>> the docblocks, that I want these types to be valid.
>>>
>>> I think I can achieve this by the following steps.
>>>
>>> 1 - Create a new concrete class from the
>>> Zend_Soap_Wsdl_Strategy_Abstract abstract class, say
>>> Zend_Soap_Wsdl_Strategy_W3C (as the type are defined by W3C).
>>> 2 - Implement the addComplexType() method to validate the type against
>>> the list and return it if is OK.
>>>
>>> What I am stuck on is how do I cascade from the new class so that I
>>> can still drop back to the Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex.
>>>
>>> I think the Zend_Soap_Wsdl_Strategy_Composite is of use here, but I
>>> can't quite work out how to use it.
>>>
>>> Any ideas would be appreciated.
>>>
>>> Regards,
>>>
>>> Richard Quadling.
>>>
>>> [1] http://www.w3.org/TR/xmlschema11-2/#built-in-primitive-datatypes
>>>
>>
>> AFAIK the Zend Soap WSDL accessor already maps up php types to xsd
>> types; a PHP String maps to an xsd:string, integer to xsd:int and so forth.
>>
>> XML schema 1.1 datatypes are pretty much the same as; and backwards
>> compatible with the current xml schema datatypes (which are still the
>> recommended standard, as 1.1 isn't a recommendation yet, work in
>> progress) and use the same namespace. Thus the existing implementation
>> should be xml w3c complaint both now and in the future.
>>
>> All that's said purely based on the zend docs [1] and not through
>> practically using Zend_Soap_Wsdl_* though!
>
>
> sigh.. [1] = http://framework.zend.com/manual/en/zend.soap.wsdl.html
> (specifically Type mapping) - might make more sense now!
>
>
>

I think you've missed the point.

I want to tell the outside world, via the WSDL,  that property X is an
xsd:datetime (hmm ok, for that to make sense forget PHP's DateTime
builtin class)

How do I do that using AutoDiscovery?

PHP doesn't have all the types that I can ask for.

If I use PHP's types, they are all strings. So any junk can be put in.

The consumer of the service isn't PHP, but (I believe) C#. So strongly typed.


It isn't about mapping PHP "types"  to W3C types.




-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Re: DocBlocking SOAP types.

2010-02-17 Thread Richard Quadling
On 16 February 2010 18:20, Nathan Rixham  wrote:
> Richard Quadling wrote:
>> On 16 February 2010 16:41, Nathan Rixham  wrote:
>>> Nathan Rixham wrote:
>>>> Richard Quadling wrote:
>>>>> Hi.
>>>>>
>>>>> I want to docblock a set of properties to be xml primitive datatypes [1].
>>>>>
>>>>> Considering that this is the correct type for the XML/SOAP/WSDL
>>>>> communication, how do I "bypass" Zend_WSDL / Zend_AutoDiscovery so
>>>>> that these types go through cleanly. I know that as far as PHP is
>>>>> concerned, the type is loose and it will be my responsibility to
>>>>> encode the values accordingly. It is in the WSDL generation, and hence
>>>>> the docblocks, that I want these types to be valid.
>>>>>
>>>>> I think I can achieve this by the following steps.
>>>>>
>>>>> 1 - Create a new concrete class from the
>>>>> Zend_Soap_Wsdl_Strategy_Abstract abstract class, say
>>>>> Zend_Soap_Wsdl_Strategy_W3C (as the type are defined by W3C).
>>>>> 2 - Implement the addComplexType() method to validate the type against
>>>>> the list and return it if is OK.
>>>>>
>>>>> What I am stuck on is how do I cascade from the new class so that I
>>>>> can still drop back to the Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex.
>>>>>
>>>>> I think the Zend_Soap_Wsdl_Strategy_Composite is of use here, but I
>>>>> can't quite work out how to use it.
>>>>>
>>>>> Any ideas would be appreciated.
>>>>>
>>>>> Regards,
>>>>>
>>>>> Richard Quadling.
>>>>>
>>>>> [1] http://www.w3.org/TR/xmlschema11-2/#built-in-primitive-datatypes
>>>>>
>>>> AFAIK the Zend Soap WSDL accessor already maps up php types to xsd
>>>> types; a PHP String maps to an xsd:string, integer to xsd:int and so forth.
>>>>
>>>> XML schema 1.1 datatypes are pretty much the same as; and backwards
>>>> compatible with the current xml schema datatypes (which are still the
>>>> recommended standard, as 1.1 isn't a recommendation yet, work in
>>>> progress) and use the same namespace. Thus the existing implementation
>>>> should be xml w3c complaint both now and in the future.
>>>>
>>>> All that's said purely based on the zend docs [1] and not through
>>>> practically using Zend_Soap_Wsdl_* though!
>>>
>>> sigh.. [1] = http://framework.zend.com/manual/en/zend.soap.wsdl.html
>>> (specifically Type mapping) - might make more sense now!
>>>
>>>
>>>
>>
>> I think you've missed the point.
>
> totally!
>
>> I want to tell the outside world, via the WSDL,  that property X is an
>> xsd:datetime (hmm ok, for that to make sense forget PHP's DateTime
>> builtin class)
>>
>> How do I do that using AutoDiscovery?
>>
>> PHP doesn't have all the types that I can ask for.
>>
>> If I use PHP's types, they are all strings. So any junk can be put in.
>>
>> The consumer of the service isn't PHP, but (I believe) C#. So strongly typed.
>>
>>
>> It isn't about mapping PHP "types"  to W3C types.
>
> and now i completely follow after downloading the Zend code - which
> strategy are you currently using / need to use? either way I guess the
> two simplest approaches would either be:
>
> 1: create a class which extends
> Zend_Soap_Wsdl_Strategy_YOURCURRENTSTRATEGYCHOICE , and implement the
> addComplexType() method adding in all the xsd extra types and then
> calling parent::addComplexType when not found.
>
> 2: create a class which extends Zend_Soap_Wsdl and overrides the
> getType() method adding in all the xsd extra types and then calling
> parent::getType when not found.
>
> regards!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I've extended the ArrayOfComplexType strategy as this is the most
common one for me.

Overwrote the addComplexType to parse the type (xsd: where  is
in the known list).

Generates the WSDL just fine.

Now need to see what the client can do with that.

(Tomorrow).


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



[PHP] PHPDoc (not PhD) question.

2010-02-18 Thread Richard Quadling
Hello.

Does anyone have any other templates for PHPDoc?

I've found zym's ExtJS PHPDoc template, but this doesn't seem to be
maintained and there are a few bugs (source code not styled, source
code rendered as external windows with broken links, ordered and
unordered lists not rendered with appropriate styling, etc.).

Any suggestsions, fixes, alternatives.

Regards,

Richard.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Magnetic Stripe Reader or Barcode to PHP

2010-02-19 Thread Richard Quadling
 quickest/cheapest way
is to get blank cardboard "cards", print a barcode on them and then
laminate them. That way you can build your own layout relatively
cheaply.

You also don't have to use black/white bars. For one our systems
(Access control to buildings), we used infra-red detectable ink. When
it was printed, we could only just see it in the right light. The
scanners use a red laser and picked up the code easily. And the
barcode was overprinted on a photo ID card and them laminated.


Hope that all makes sense.

Regards,

Richard.
-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



  1   2   3   4   5   6   7   8   >