[PHP] error_handler : unique "caller ID" ?

2012-11-13 Thread B. Aerts

Dear list,

a penny for your thoughts on the following problem.

Does anyone have an idea how to find a unique "caller ID" for a 
user-defined error handler ?


The goal is to get a cached error messages tree where the following 
snippet would yield an array as below it:


// start-of-snippet

function Outer(&$a)
{
   trigger_error('entering Outer');
   $a=Inner($a) ;
   trigger_error('leaving Outer') ;
}

function Inner($x)
{
   trigger_error('entering Inner');
   return(2*$x) ;
}

trigger_error('Here we go ');
$b = 1 ;
$b = Outer($b) ;
trigger_error('End result is $b');


// end-of-snippet

Output:

Array(
[0] => 'Here we go'
['Outer()'] => Array(
   [0] => 'entering Outer' ;
   ['Inner()'] => Array(
  [0] => 'entering Inner' ;
   )
   [1] => 'leaving Outer' ;
   )
[1] => 'End result is 2'
)

I've considered the 'args' option in debug_backtrace(), but that fails 
for referenced arguments.


Having read access to a variable's address (like a C-pointer) would be 
perfect - but Google tells me you can't in PHP.


Any other idea's ?

Regards,

Bert

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



Re: [PHP] error_handler : unique "caller ID" ?

2012-11-14 Thread B. Aerts

On 13/11/12 20:04, Robert Williams wrote:

On 11/13/12 11:20, "B. Aerts"  wrote:



Having read access to a variable's address (like a C-pointer) would be
perfect - but Google tells me you can't in PHP.


If you can restrict yourself to objects for the passed variables, you can
use spl_object_hash(). It does exactly what you need, but it only works
with objects. AFAIK, there's no equivalent for scalars or arrays.

<http://php.net/manual/en/function.spl-object-hash.php>


Regards,
Bob

--
Robert E. Williams, Jr.
Associate Vice President of Software Development
Newtek Businesss Services, Inc. -- The Small Business Authority
https://www.newtekreferrals.com/rewjr
http://www.thesba.com/



Hello Bob,

thanks for the tip - indeed it does exactly what I need.
Unfortunately, I need to keep scalars/arrays in the frame too.

But thinking along your line, do you know of a function that does a 
similar thing to the function call itsself ?


( as functions get stacked, called recursive or through callback 
mechanisms, there must be a similar allocation table/mechanism as for 
variables/objects)


Regards,

Bert


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



[PHP] webDAV/CalDAV client class experience ?

2013-02-12 Thread B. Aerts

Hello,

I'm working on this one for more than a year (personal project) - but 
I'm turning pretty desperate here.


I'm trying to connect to 2 Calendars through the CalDAV protocol.
The calendars are hosted by 2 webmail providers.
If I try to sync through a dedicated calendar, like iCal or Thunderbird 
Lightning add-on, this works fine.


However, once I try to do it through "native" PHP, I fail miserably - 
even if I mimick HTTP requests as recorded by Charles (HTTP debugging 
proxy).


Up until now, I used the inc_caldav-client-v2.php, which worked for a 
while and then stopped all of a sudden. The PUT requests failed, and 
then any HTTP request got caught in what appears to be a socket timeout.


My question: is anyone using some webDAV/CalDAV class that actually works ?
If not, any tutorial on the subject is also deeply appreciated ( all I 
can rely on is the IETF spec rfc4791, which is far from accesible 
reading material)





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



Re: [PHP] webDAV/CalDAV client class experience ?

2013-02-16 Thread B. Aerts

On 13/02/13 14:27, Daniel Brown wrote:

On Tue, Feb 12, 2013 at 3:40 PM, B. Aerts  wrote:

Hello,

I'm working on this one for more than a year (personal project) - but I'm
turning pretty desperate here.

I'm trying to connect to 2 Calendars through the CalDAV protocol.
The calendars are hosted by 2 webmail providers.
If I try to sync through a dedicated calendar, like iCal or Thunderbird
Lightning add-on, this works fine.

However, once I try to do it through "native" PHP, I fail miserably - even
if I mimick HTTP requests as recorded by Charles (HTTP debugging proxy).

Up until now, I used the inc_caldav-client-v2.php, which worked for a while
and then stopped all of a sudden. The PUT requests failed, and then any HTTP
request got caught in what appears to be a socket timeout.

My question: is anyone using some webDAV/CalDAV class that actually works ?
If not, any tutorial on the subject is also deeply appreciated ( all I can
rely on is the IETF spec rfc4791, which is far from accesible reading
material)


 I haven't tried them myself, but there are PEAR packages for
client-server implementations for WebDAV:

 http://pear.php.net/search.php?q=webdav&in=packages&x=0&y=0

 They're not actively maintained by anyone right now (feel free to
apply to change that if you'd like the responsibility), but the most
recent server version was released just this past October (the client
version is about a year older).  At the very least, it may be enough
to get you started.



Hello,

I did try to download the PEAR package, but got stuck in some missing 
header problem.
In the mean time however, I did manage to solve a few problems - listed 
for archiving's sake :
- the biggest mistake: apparently I commented the fwrite() call to the 
stream, which explains why he went in time-out ... (in this case, please 
DO shoot the pianist)


- CalDAVClient class from inc_caldav-client-v2.php always adds the port 
to the "Host" HTTP header, even if it is the default port; by removing 
it from the header, I got less problems
- Adding the HTTP header "Accept: */*" made sure all read actions ( e.g. 
GET, PROPFIND, REPORT) worked perfectly


Only problem remaining was that PUT still isn't possible - at least not 
with one of the providers. Since I used a verbatim copy of a PUT action 
from the RFC, I strongly suspect the problem to be with the provider.


Thanks for the help !

Bert


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



Re: [PHP] webDAV/CalDAV client class experience ?

2013-02-18 Thread B. Aerts

- Adding the HTTP header "Accept: */*" made sure all read actions ( e.g.
GET, PROPFIND, REPORT) worked perfectly


This is interesting. The Accept header has to do with what media types
the browser will accept in return. I didn't think it had anything to
do with what operations the server/application accepts. Must go read
further


I'll have to revoke this statement, as I can't reproduce it anymore.
I noticed the DaviCal didn't use it, bu the CURL call did - and yielded 
more ( = meaningfull) results.

But, as I said, can't reproduce it.

The thing I could reproduce was that, if the request was sent to the 
default port, AND this port was included in the "Host" header, both GET 
and PUT yielded HTTP 404.





Only problem remaining was that PUT still isn't possible - at least not with
one of the providers. Since I used a verbatim copy of a PUT action from the
RFC, I strongly suspect the problem to be with the provider.


You've no doubt considered this already, but it might be intentional
on the provider's part. I'm not up on all the webDAV/calDAV providers;
I imagine some of them might add in additional layers of auth
(including the NOWAI layer)  just to consider themselves more secure.


Yes I did, but the following arguments should negate that consideration:
- when running OPTIONS, PUT is included in the allowed HTTP methods
- the HTTP return code from the PUT command is 301, where a security 
issue would have yielded a code in the 400 range
- I think the CalDAV spec does mention Basic auhentication, so it can't 
be anything more sophisticated
- the other provider does respond as expected (though I agree, that is 
the weakest argument: expectations != specifications )
- the provider does allow sync'ing Sunbird, iCal, ... over CalDAV, and 
that works, even entering a new event (which is a PUT action). The 
Charles debugging proxy too shows that it's only Basic authentication 
that's going up - and succeeding



I'll add the code I used for the tests.
When looking for the configuration ( Calendar URL, ...), the search term 
"CalDAV  Calendar Sunbird" always did the trick for me.
( I also had to modify the Davical client class a bit - make some 
protected members public for this test code to work)



if (1)
{
   $url  = 
"https://caldav.calendar..com/dav/ba_aerts/Calendar/tstCalDAV/" 
; // make sure it ends in a '/' !

   $user = "@.com" ;
   $pwd  = "*1" ;
}
else
{
   $url  = 
"https://www..com/calendar/dav/@.com/events/" 
;

   $user = "@.com" ;
   $pwd = "**2" ;
}

/
 * run OPTIONS test *
 /

$method = "OPTIONS" ;

$requestHeaders = Array("content-type" => "text/xml",
"Depth" => 1) ;

echo "\n" ;

echo "$method request:\n" ;
doCurlRequest($method, $url, $user, $pwd, "", $requestHeaders) ;
doCalDAVClientRequest($method, $url, $user, $pwd, "", $requestHeaders ) ;
echo " \n" ;

echo 
"\r\n= 
\n" ;


/
 * run PROPFIND test*
 /

$method = "PROPFIND" ;
$body = <










XML;

echo "$method request:\n" ;
doCurlRequest($method, $url, $user, $pwd, $body, $requestHeaders) ;
doCalDAVClientRequest($method, $url, $user, $pwd, $body, $requestHeaders ) ;

echo " \n" ;

echo 
"\r\n= 
\n" ;


/
 * run REPORT test  *
 /

$method = "REPORT" ;
$body = <<

 
   
   
 
 
   
 
   
 
   
 

XML;

echo "$method request:\n" ;
doCurlRequest($method, $url, $user, $pwd, $body, $requestHeaders) ;
doCalDAVClientRequest($method, $url, $user, $pwd, $body, $requestHeaders ) ;
echo " \n" ;

echo 
"\r\n= 
\n" ;


/
 * run GET test *
 /

$method   = "GET" ;
$icsFile  = "e26443db-02d4-4bf0-a97c-c1ddbd3126df.ics" ;

echo "$method request:\n" ;

// some cheating required: check the *.ICS name of an existing
// resource in a previous REPORT run

doCurlRequest($method, $url . $icsFile, $user, $pwd, "", $requestHeaders) ;
doCalDAVClientRequest($method, $url . $icsFile, $user, $pwd, "", 
$requestHeaders) ;


echo " \n" ;

echo 
"\r\n= 
\n" ;


/
 * run PUT test *
 /

$method = "PUT" ;
$UID = "ABCDE" . time() ;
$url .= $UID . ".ICS" ;

$body

[PHP] Re: Basic Auth

2013-08-27 Thread B. Aerts

On 27/08/13 15:37, Jim Giner wrote:

I"m using basic auth for a few of my pages that I want to limit access
to - nothing of a sensitive nature, but simply want to limit access to.
  Want to implement a signoff process, but can't figure it out.

 From the comments in the manual I take it one can't do this by simply
unsetting the PHP_AUTH_USER and _PW vars.  Can someone explain to me why
this doesn't suffice?  The signon process expects them to be there, so
when they are not (after the 'unset'), how come my signon process still
detects them and their values?


Hello Jim,

at the risk of under-estimating your knowledge (and over-estimating 
mine) of HTTP-requests in PHP - but here it goes.


I see two options of bypassing the JavaScript option.

The first one is to use the default authorization, and error pages of 
your HTTP server.
(For example, in Apache: 
http://httpd.apache.org/docs/2.2/custom-error.html)

This is for a login with invalid credentials.
For some-one to leave the protected site, a HTTP-request without 
credentials, and to a URI outside the protected domain, should do (as 
every HTTP request into the protected domain should repeat the 
Authorisation header).



The second one is to leave header(), and go down one level, to the likes 
of fsockopen() or stream_socket_server() - though personally, I've only 
limited knowledge of a bit of client-side programming.


Unless I've completely misunderstood your question,
Hope this helps,

Bert

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