Re: [PHP] Get country from Phone number

2008-03-03 Thread Dani Castaños


As a little project, I took the link provided by the other Rob and 
make this little search tool.


It only looks at the beginning numbers.  It does no number 
validation.  I don't validate the length of the number.  ie: I would 
have to know the min/max lenth of each phone number for that given 
country/region, and I didn't search for that information.


Let me know what you'll think.

http://www.cmsws.com/examples/php/areacodes/countrycodes.php



It's enough for me... Can you send me the code please?

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



[PHP] Get country from Phone number

2008-02-29 Thread Dani Castaños

Hi all!

I'm looking for some piece of code or class which giving a phone number 
it returns me from wich country is this phone.

Do you know where I can find something like this?

Thank you in advanced!

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



Re: [PHP] Get country from Phone number

2008-02-29 Thread Dani Castaños

Andrés Robinet escribió:

-Original Message-
From: Dani Castaños [mailto:[EMAIL PROTECTED]
Sent: Friday, February 29, 2008 5:03 AM
To: PHP LIST
Subject: [PHP] Get country from Phone number

Hi all!

I'm looking for some piece of code or class which giving a phone number
it returns me from wich country is this phone.
Do you know where I can find something like this?

Thank you in advanced!

--



Seems like you'll have a hard time if you want to include all the possibilities:
http://www.kropla.com/dialcode.htm
But probably Rob (Cummings) will come up with a solve-it-all regex that will
save your day.

Regards,

Rob(inet)
OoooH! I will be happy for ever is this could be solved by regexp... I 
will do my doctorate on REGEXP then... :-)


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



[PHP] simplexml problem

2007-12-31 Thread Dani Castaños

Hi all!

I'm using simplexml to load an xml into an object.
The XML is this:
?xml version=1.0?
request
 customerID3/customerID
 appNameagenda/appName
 ticketTypecticket_agenda_server/ticketType
 ticketTypeID1/ticketTypeID
 platformID1/platformID
 ticketActionaddUsersToGroup/ticketAction
/request

When I do this:

$file = simplexml_load_file( 'file.xml' );
$ticketType = $file-ticketType;

What i really have into $ticketType is a SimpleXMLElement... not the 
value cticket_agenda_server... What am I doing wrong?


Because if I echo this value... Yes, I obtain the 
cticket_agenda_server... But if I want to use like:


$ticket = new $ticketType( $param1, $param2);

It throws:
Uncaught exception 'Exception' with message 
'SimpleXMLElement::__construct() expects parameter 1 to be string, array 
given' in C:\Dani\htdocs\ticket_server\ticket_execute.php:134

Stack trace:
#0 C:\Dani\htdocs\ticket_server\ticket_execute.php(134): 
SimpleXMLElement-__construct(Array, Object(clogger))

#1 {main}
 thrown

It seems like it uses $ticketType class instead the value inside.

Than you in advance

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



Re: [PHP] simplexml problem

2007-12-31 Thread Dani Castaños

Nathan Nobbe escribió:
On Dec 31, 2007 7:11 AM, Dani Castaños [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Hi all!

I'm using simplexml to load an xml into an object.
The XML is this:
?xml version=1.0?
request
 customerID3/customerID
 appNameagenda/appName
 ticketTypecticket_agenda_server/ticketType
 ticketTypeID1/ticketTypeID
 platformID1/platformID
 ticketActionaddUsersToGroup/ticketAction
/request

When I do this:

$file = simplexml_load_file( 'file.xml' );
$ticketType = $file-ticketType;

What i really have into $ticketType is a SimpleXMLElement... not the
value cticket_agenda_server... What am I doing wrong? 



cast the value to a string  when you pull it out if you want to use it 
that way:


?php
$xml =
XML
?xml version=1.0?
request
 customerID3/customerID
 appNameagenda/appName
 ticketTypecticket_agenda_server/ticketType
 ticketTypeID1/ticketTypeID
 platformID1/platformID
 ticketActionaddUsersToGroup/ticketAction
/request
XML;

$file = new SimpleXMLElement($xml);
$ticketTypeAsSimpleXmlElement = $file-ticketType;
$ticketTypeAsString = (string)$file-ticketType;
$ticketTypeAnalyzer = new 
ReflectionObject($ticketTypeAsSimpleXmlElement);


echo (string)$ticketTypeAnalyzer . PHP_EOL;
var_dump($ticketTypeAsString);
?

-nathan




Thanks! Problem fixed... But I think PHP must do the cast automatically. 
I think it's a bug fixed in a further version than mine as I've read


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



Re: [PHP] Session timeout

2007-12-14 Thread Dani Castaños
Hi all, I've found the key of all... at least this is what I think ;-) 
(And, again, at least, for Debian users)


The thing is I want to have control on what exactly a session lasts, 
and advice the user some time before to renew the session if he wants.
If you only set gc_maxlifetime with ini_set or even in php.ini the 
session management won't work properly... why?


In Debian, garbage collector is called from a cron taks located in 
/etc/cron.d/php5
This task is set to be called every 30 minutes, then you can't set 
session.gc_maxlifetime less than this time... Because GC won't do its 
work till minute 30...
Then, the first thing you should do is set this task to be called in 
fewer minutes. ( I set up to */2, i.e. every to minutes)

But this is not enough...
This cron task calls a script located in /usr/lib/php5/ - maxlifetime.sh:

#!/bin/sh -e

max=1440

for ini in /etc/php5/*/php.ini; do
   cur=$(sed -n -e 
's/^[[:space:]]*session.gc_maxlifetime[[:space:]]*=[[:sp

ace:]]*\([0-9]\+\).*$/\1/p' $ini 2/dev/null || true);
   [ -z $cur ]  cur=0
   [ $cur -gt $max ]  max=$cur
done

echo $(($max/60))

exit 0

As you see... It opens every php.ini located in /etc/php5 and gets 
session.gc_maxlifetime and it keeps the max value of all.
It is compared with max variable and if it's greater it sets $max to 
this value... Then, if you set up session.gc_lifetime for example to 600 
seconds in all your php.ini's, this script will return 24 minutes (1440 
seconds) Because 600 is not greater than 1440. So, you must change the 
third line and set max to another value, 600 or less for example.


And this is it... GC will work properly.

I hope it helps to somebody!

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



[PHP] Session timeout

2007-12-13 Thread Dani Castaños

Hi all!

I've read a bit about PHP session timeout. Is it configurable?? I mean, 
If i want user logged out after 10 minutes of innactivity... where i can 
to set it up?? Is it possible to expire session configuring php.ini.

I know i will have to write code to do whatever when the session expires...

Thank you in advance

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



Re: [PHP] Session timeout

2007-12-13 Thread Dani Castaños


There are various configuration options for this (which you change in 
the php.ini or by using the ini_set() function):


session.gc_maxlifetime
session.cookie_lifetime



Before sending my first mail, i've changed those parameters... and 
nothing seems to change. I set up also session.cache_expire... but... 
nothing happens... session does not expire


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



Re: [PHP] LoadXML trouble

2007-12-11 Thread Dani Castaños

If i use your script like this:

$xml = '?xml version=1.0?
response
 ticketID1197027955_8310/ticketID
 statusOK/status
 errCode200/errCode
 errMsg/errMsg
/response';

$obj = new DOMDocument();
$obj-loadXML( $xml );

echo print_r( $obj, true );
echo $obj-saveXML() . PHP_EOL;

The first statement writes:
DOMDocument Object
(
)

The second:
?xml version=1.0?
response
 ticketID1197027955_8310/ticketID
 statusOK/status
 errCode200/errCode
 errMsg/
/response

It's just the xml is not properly stored in loadXML method... but the 
string must be inside due to saveXML returns the proper value.



Nathan Nobbe escribió:
On Dec 10, 2007 12:08 PM, Dani Castaños [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Yep, it works when i do saveXML, but not on loadXML step...


did the loadXML() method work in the test script i sent over in my 
last post?
if it does then something else is going on when loadXML() is called in 
the context

of your application.

The thing is... i'm trying to do something like this:

$request = $_POST['xml'];
$logger-debug( 'New ticket request' );

/**
 * Parse XML request to obtain values
 */
$xml = new DOMDocument();
//$xml-validateOnParse = true;
$xml-loadXML( $request );


you should always sanitize input.  at the very least you should be 
running $_POST['xml']

through a call to trim() before handing it to the DOMDocument  instance.

$request = trim($_POST['xml']);
$xml = new DOMDocument();
$xml-loadXML($request);

i suspect there is some garbage in or around the string contained in 
$_POST['xml'] that
the DomDocument instance doesnt like, therefore its not behaving the 
way youd anticipate.
for example if you modify the script i sent over last time by putting 
some spaces in between the
xml declaration and the opening tag of the envelope (response) you 
should see the following error

(or something similar [depending on the value of error_reporting])

Warning: DOMDocument::loadXML(): XML declaration allowed only at the 
start of the document in Entity,

line: 3 in /home/nathan/testDom.php on line 19

which consequently leads to
?xml version=1.0?

when invoking
echo $domDoc-saveXML() . PHP_EOL;
rather than
?xml version= 1.0?
response
 ticketID1197026188_ec76/ticketID
 statusKO/status
 errCode500/errCode
 errMsgInternal Server Error/errMsg
/response

which is what you would expect.
-nathan
 


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



Re: [PHP] LoadXML trouble

2007-12-11 Thread Dani Castaños



that is expected behavior.  some of the internal classes dont define
any member variables that the php language has access to.  obviously
they are storing data internally, said variables just arent accessible as
member variables of the class thats being defined.


Ok! Thank you for this info...

But then...
Why can i do this in Windows:
$xml-getElementsByTagName( 'ticketID' )-item( 0 )-nodeValue;

and not in Linux?

-- Xml example:
?xml version=1.0?
response
ticketID1197027955_8310/ticketID
statusOK/status
errCode200/errCode
errMsg/errMsg
/response

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



Re: [PHP] LoadXML trouble

2007-12-11 Thread Dani Castaños

Hi Nathan!

Thank you for all your help!
Problem has been fixed...

The thing is, when request is sent, there is a little difference in what 
i get... I get ?xml version=\1.0\ and so on...
These backslashes make the loadXML not load data properly... I've put an 
str_replace and the problem has been solved


Again... Thank you very much!

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



[PHP] LoadXML trouble

2007-12-10 Thread Dani Castaños

Hi list!

I have a problem with DOMDocument loadXML method. I used Windows to 
develop my applications, and nothing happens on it when i do something like


$xml = new DOMDocument();
$xml-loadXML( $request );

Obviously, request is not empty...

But when I have upload this code to production machine ( which runs 
under Debian ) it doesn't works properly, The DOMDocument Object is empty...


Any ideas?

Thank you in advance

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



Re: [PHP] LoadXML trouble

2007-12-10 Thread Dani Castaños

I've checked $request previously and is not empty... it has something like:

?xml version=1.0?
response
 ticketID1197026188_ec76/ticketID
 statusKO/status
 errCode500/errCode
 errMsgInternal Server Error/errMsg
/response

The curious thing is that I've built this xml string with DOMDocument in 
my request... Then I suppose my Linux system has DOM support,


Nathan Nobbe escribió:
On Dec 10, 2007 4:48 AM, Dani Castaños [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Hi list!

I have a problem with DOMDocument loadXML method. I used Windows to
develop my applications, and nothing happens on it when i do
something like

$xml = new DOMDocument();
$xml-loadXML( $request );

Obviously, request is not empty...


have you checked the contents of $request on the production machine 
prior to

the invocation of loadXML() ?

But when I have upload this code to production machine ( which runs
under Debian ) it doesn't works properly, The DOMDocument Object
is empty...


are the systems running the same major version of  php; and have you 
verified

the linux system has DOM support?

-nathan


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



Re: [PHP] LoadXML trouble

2007-12-10 Thread Dani Castaños

Yep, it works when i do saveXML, but not on loadXML step...

The thing is... i'm trying to do something like this:

$request = $_POST['xml'];
$logger-debug( 'New ticket request' );

/**
* Parse XML request to obtain values
*/
$xml = new DOMDocument();
//$xml-validateOnParse = true;
$xml-loadXML( $request );

$customer_id   = $xml-getElementsByTagName( 'customerID' )-item( 0 
)-nodeValue;
$app_name  = $xml-getElementsByTagName( 'appName' )-item( 0 
)-nodeValue;
$ticket_type   = $xml-getElementsByTagName( 'ticketType' )-item( 0 
)-nodeValue;
$ticket_action = $xml-getElementsByTagName( 'ticketAction' )-item( 0 
)-nodeValue;
$ticket_params = $xml-getElementsByTagName( 'parameters' )-item( 0 
)-childNodes;


...

Nathan Nobbe escribió:
On Dec 10, 2007 11:40 AM, Dani Castaños [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


I've checked $request previously and is not empty... it has
something like:

?xml version=1.0?
response
 ticketID1197026188_ec76/ticketID
 statusKO/status
 errCode500/errCode
 errMsgInternal Server Error/errMsg
/response


have you been testing this in the context of your application, or have 
you also

tried a focused test script?  i would try something trivial, like:

?php
$xml =
XML
?xml version=1.0?
response
 ticketID1197026188_ec76/ticketID
 statusKO/status
 errCode500/errCode
 errMsgInternal Server Error/errMsg
/response
XML;

$domDoc = new DOMDocument();
$domDoc-loadXML($xml);
echo $domDoc-saveXML() . PHP_EOL;
?

just to ensure the DOM extension is available and working as expected.

-nathan


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



[PHP] Flow chart graph library

2007-09-06 Thread Dani Castaños

Hi all!

Does anybody know a PHP library to create Flow chart graphs??
I need it to do something like this:

   (yes)
Is it true   ? --- Update
 |
(no) |
 |
 
 Cancel

Thank you in advance!

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