[PHP] Re: Recursion issue with Zend_Soap_AutoDiscovery.
2010/1/25 Richard Quadling rquadl...@googlemail.com: 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 ... xsd:element name=SupersededBy type=xsd:string / to xsd:element name=SupersededBy type=tns:ServiceDetails / 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=ZEND002498r=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=ZEND002498r=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/1/25 Nathan Rixham nrix...@gmail.com: 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 ... xsd:element name=SupersededBy type=xsd:string / to xsd:element name=SupersededBy type=tns:ServiceDetails / 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=ZEND002498r=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.
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 ... xsd:element name=SupersededBy type=xsd:string / to xsd:element name=SupersededBy type=tns:ServiceDetails / 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Recursion to sanitize user input
Very simple :) when recursion happens, you return the sanitized value, but never store it ;) [EMAIL PROTECTED] wrote: I'm trying to sanitize my user input. My sanitize function does not work if I send a variable that's an array. I'm using recursion to go through the array. The example below shows that $_POST['city'] works but $_POST['user'] doesn't work. The array comes back blank. Anyone see what's wrong with my code? OUTPUT: Array ( [city] = New York [user] = ) CODE: ?php function sanitize($userInput = '') { if ( is_array($userInput) ) { foreach ( $userInput as $key = $value ) { sanitize( $value ); } } else { if ( get_magic_quotes_gpc() ) { return trim( $userInput ); } else { return trim( addslashes($userInput) ); } } } $_POST['city'] = 'New York'; $_POST['user']['firstName'] = 'Bob'; $_POST['user']['lastName'] = 'Smith'; $_POST['user']['country'] = 'USA'; foreach ( $_POST as $key = $value ) { $_POST[$key] = sanitize( $value ); } echo 'pre'; echo print_r($_POST); echo '/pre'; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Recursion to sanitize user input
Hi M I don't understand. I don't think I'm storing it anywhere. I have it looping through all the POST variables. If it's not an array then the sanitize function returns a sanitized value. If it's an array then the sanitize function calls itself again and again until it finds a single variable and returns it as a sanitized value. - Original Message - From: M. Sokolewicz [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, October 08, 2004 6:19 PM Subject: [PHP] Re: Recursion to sanitize user input Very simple :) when recursion happens, you return the sanitized value, but never store it ;) [EMAIL PROTECTED] wrote: I'm trying to sanitize my user input. My sanitize function does not work if I send a variable that's an array. I'm using recursion to go through the array. The example below shows that $_POST['city'] works but $_POST['user'] doesn't work. The array comes back blank. Anyone see what's wrong with my code? OUTPUT: Array ( [city] = New York [user] = ) CODE: ?php function sanitize($userInput = '') { if ( is_array($userInput) ) { foreach ( $userInput as $key = $value ) { sanitize( $value ); } } else { if ( get_magic_quotes_gpc() ) { return trim( $userInput ); } else { return trim( addslashes($userInput) ); } } } $_POST['city'] = 'New York'; $_POST['user']['firstName'] = 'Bob'; $_POST['user']['lastName'] = 'Smith'; $_POST['user']['country'] = 'USA'; foreach ( $_POST as $key = $value ) { $_POST[$key] = sanitize( $value ); } echo 'pre'; echo print_r($_POST); echo '/pre'; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Recursion to sanitize user input
The recursion doesn't do anything with the returned value from the function. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: recursion?????
% The benefit of checking in javascript(which I suspect is enabled in most Not me! Not me! Not me! It is by no means ubiquitous. Anyone who even moderately considers security will have it turned off. The latest survey I've seen indicates that about 11% of browsers have JS disabled. About the same percent have cookies disabled. Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: recursion?????
On Tuesday, February 18, 2003, at 10:58 AM, Johnson, Kirk wrote: The latest survey I've seen indicates that about 11% of browsers have JS disabled. About the same percent have cookies disabled. Too many for my tastes. Probably 8% of browsers have JS and cookies disabled for a reason (knowingly) and therefore can be considered the most dangerous segment of users. (Knowledge being power and all.) Erik -- Erik Price email: [EMAIL PROTECTED] jabber: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: recursion?????
Kirk -- ...and then Johnson, Kirk said... % [quoting me] % % Not me! Not me! Not me! % % It is by no means ubiquitous. Anyone who even moderately considers % security will have it turned off. % % The latest survey I've seen indicates that about 11% of browsers have JS % disabled. Hmmm... Less than I thought; I was under the impresssion that it was up nearer 20%. % % About the same percent have cookies disabled. Yeah. Just as I do :-) % % Kirk HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! msg97395/pgp0.pgp Description: PGP signature
Re: [PHP] Re: recursion?????
Fred, et al -- ...and then Fred Merritt said... % ... % The benefit of checking in javascript(which I suspect is enabled in most Not me! Not me! Not me! It is by no means ubiquitous. Anyone who even moderately considers security will have it turned off. HTH HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! msg97144/pgp0.pgp Description: PGP signature
[PHP] Re: recursion?????
Alex, as a general rule of thumb, try to do as much checking as you can with JavaScript. For those checks such as is the field a valid date, is the field numeric and so on, it is much faster to check on the client, than to send the data back to the server and check it there. Probably the best way to do this is with an onSubmit clause on the form. Something like: form name='RegisterForm' action='register.php' method='post' onSubmit='return checkRegisterScreen(this)' Some things you cannot check on the client, for example does the value of the field already exist in a data store on the server. There are many ways in which you could check these fields. On of the easiest to understand ways would be to name your submit field something like Register, and use code something like the following in register.php: switch ($_POST['submit']) { case a; processA(); break; case b; processB(); break; case Register; checkFormAndRedisplay(); break; default; processDefault(); break; } In the procedure checkFormAndRedisplay(), you can write code to check your fields, and the relationships between them, and then redisplay the form with appropriate error messages, and highlighting, to guide the end user to correct his errors. Hope this helps. . . Fred Alex Davis wrote: Ok ... here is the sitituation... I am creating a registration form. What I have so far works ... the user registers using this form and the form calls another page that will check the validity of the data (checking for username availability, etc...). If there is an error, display the error and have the user GO BACK AND TRY AGAIN - This is the problem I want to fix. What I want to do is have the registration form, on submit, check the data validity right then, if there is an error, redisplay the form with an * next to the field that is incorrect. This way the user does not have to go back and try again, it will be there in front of them. Basically, have the form action call itself hince the recursion. Any suggestion/examples? Thanks, -Alex -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Recursion????? A message for Alex Davis
Alex Like you I have php scripts that validate the contents of registration and other forms. I'm new to php and do not have a clue about client side (java) scripting. Yes and the GO BACK AND TRY AGAIN process is what my php scripts do. All very messy. I'll have to learn javascript but currently I have a deadline to meet with the php implementation.Be interested to see sometime in the future the javascripts you write to validate you forms. Regards Mike Eacott rentAweek Ltd http://www.rentaweek.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Recursion?????
Alex, and Michael, here is a code fragment which I have cut and simplified from one of my working scripts, that does some simple javascript checking of a form. It should give you an idea of how to do it. There is a lot of documentation, and examples of javascript on the web. Try a google search. At this level it is relatively easy(well at least it is after you have done it once). When you get into more complicated javascripts, you have to take into account that because of different document object models, some things are implemented differently in different browsers. . . . ? head script LANGUAGE=JavaScript !-- Hide from older browsers var whitespace = \t\n\r; function isEmpty(s) { // +--+ // | Return true if the string s is empty | // +--+ return ((s == null) || (s.length == 0)) } function isWhitespace (s) { // +---+ // | Return true if s is empty or contains only whitespace | // +---+ var i; if (isEmpty(s)) { return true; } for (i = 0; i s.length; i++) { var c = s.charAt(i); if (whitespace.indexOf(c) == -1) return false; } return true;// must be whitespace } function checkRegisterScreen (form) { // +---+ // | Return true if all fields on screen are valid | // +---+ if (isWhitespace(form.userid.value)) { alert(Userid may not be blank); form.userid.focus(); return false; } if (isWhitespace(form.username.value)) { alert(User name may not be blank); return false; } return true; } // End of hidden section -- /script /head body form name='RegisterForm' action='Register.php' method=post onSubmit='return checkRegisterScreen(this)' ?php . . . The key thing to notice here, is that the submit will only happen if the onSubmit returns true. Hope this helps. . . Fred Michael Eacott wrote: Alex Like you I have php scripts that validate the contents of registration and other forms. I'm new to php and do not have a clue about client side (java) scripting. Yes and the GO BACK AND TRY AGAIN process is what my php scripts do. All very messy. I'll have to learn javascript but currently I have a deadline to meet with the php implementation.Be interested to see sometime in the future the javascripts you write to validate you forms. Regards Mike Eacott rentAweek Ltd http://www.rentaweek.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: recursion?????
as a general rule of thumb, try to do as much checking as you can with JavaScript. For those checks such as is the field a valid date, is the field numeric and so on, it is much faster to check on the client, than to send the data back to the server and check it there. Except, of course, that you need to check it AGAIN in your php script in case the browser has javascript disabled - because if it's disabled you'll end up with unchecked form data. CYA, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: recursion?????
David, of course. You always should check in the server, even if javascript is working. You have to protect your data integrity. Sorry I did not make this clear. The benefit of checking in javascript(which I suspect is enabled in most browsers these days), is that the client gets an instant response for the out of line situation. Best regards. . . Fred David Freeman wrote: as a general rule of thumb, try to do as much checking as you can with JavaScript. For those checks such as is the field a valid date, is the field numeric and so on, it is much faster to check on the client, than to send the data back to the server and check it there. Except, of course, that you need to check it AGAIN in your php script in case the browser has javascript disabled - because if it's disabled you'll end up with unchecked form data. CYA, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Recursion
Thank you so much! This eases my worries for next semester. Would happen to have an example script showing PHP using recursion? Thanks again! Martin wrote: Hi Andres, Yes, PHP support recoursion. That means, that you are calling a function again and again, but with new start-parameters. For example, if you want to search a harddisc for a file, you will call your function SearchFolder($path) with C:\. If the function itself detects subfolder, it will call itself, but with the parameters C:\Subfolder1, C:\Subfolder2 and so on. You have to watch out then, the the function terminated correctly, if the searched file is found. Martin -- 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]