php-general Digest 19 Nov 2007 11:34:13 -0000 Issue 5136

Topics (messages 264762 through 264772):

Re: submitting forms with ajax
        264762 by: samantha_o
        264763 by: samantha_o
        264764 by: Nathan Nobbe
        264767 by: samantha_o

PHP CURL
        264765 by: Fahad Pervaiz

Re: bank query and curl
        264766 by: Zoltán Németh
        264768 by: Stut
        264769 by: Stut

overloading members. aghhh!!!
        264770 by: Kiketom
        264771 by: Robert Cummings
        264772 by: Robert Cummings

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
I did not try using json becausse i am very knew in this field and dont know
much bout it. Can you give me some examples about it? Thanks for helping.


Shiplu wrote:
> 
> Why dont you use json as server response? Then manipulate it by own
> javascript. You can use jquery $.getJSON function to do the ajax part
> for you.
> 
> On 11/16/07, Shiplu <[EMAIL PROTECTED]> wrote:
>> Why dont you use json as server response? Then manipulate it by own
>> javascript. You can use jquery $.getJSON function to do the ajax part
>> for you.
>>
>> On 11/16/07, samantha_o <[EMAIL PROTECTED]> wrote:
>> >
>> > Hi,
>> >
>> > i would like to submit forms with ajax, using jquery and then load the
>> next
>> > page. I had successfully do it with jquery and form plugin. however, it
>> does
>> > not work whenever the server response consist of both HTMLs and
>> javascript
>> > together. Is it possible to make it works? I am new in all this. Can
>> anyone
>> > help me?
>> > --
>> > View this message in context:
>> >
>> http://www.nabble.com/submitting-forms-with-ajax-tf4819530.html#a13788322
>> > Sent from the PHP - General mailing list archive at Nabble.com.
>> >
>> > --
>> > 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
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/submitting-forms-with-ajax-tf4819530.html#a13826338
Sent from the PHP - General mailing list archive at Nabble.com.

--- End Message ---
--- Begin Message ---
I did not try using json because i am very new in this field and dont know
much about it. Can you give me some examples about it? Thanks for helping.


Shiplu wrote:
> 
> Why dont you use json as server response? Then manipulate it by own
> javascript. You can use jquery $.getJSON function to do the ajax part
> for you.
> 
> On 11/16/07, Shiplu <[EMAIL PROTECTED]> wrote:
>> Why dont you use json as server response? Then manipulate it by own
>> javascript. You can use jquery $.getJSON function to do the ajax part
>> for you.
>>
>> On 11/16/07, samantha_o <[EMAIL PROTECTED]> wrote:
>> >
>> > Hi,
>> >
>> > i would like to submit forms with ajax, using jquery and then load the
>> next
>> > page. I had successfully do it with jquery and form plugin. however, it
>> does
>> > not work whenever the server response consist of both HTMLs and
>> javascript
>> > together. Is it possible to make it works? I am new in all this. Can
>> anyone
>> > help me?
>> > --
>> > View this message in context:
>> >
>> http://www.nabble.com/submitting-forms-with-ajax-tf4819530.html#a13788322
>> > Sent from the PHP - General mailing list archive at Nabble.com.
>> >
>> > --
>> > 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
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/submitting-forms-with-ajax-tf4819530.html#a13826338
Sent from the PHP - General mailing list archive at Nabble.com.

--- End Message ---
--- Begin Message ---
json is just a terse way to create objects anonymously as well as other data
structures in javascript.
http://json.org/

to build a json response with html
essentially all you need to do is create a javascript array in php and put
the html
you want for the next page in that.  then you use the eval() function in
javascript
to 'incarnate' the javascript array (which contains the html).  once youve
done that
you can put the html into the dom wherever you like.  typically you will
replace some
existing dom content w/ the new html.

so as an example; lets say on the php side of things you have your html; for
the sake
of brevity lets assume its in a variable called *$html*.  you will need to
encode this for
transmission (so the javascript interpreter doesnt blow up when it tries to
'incarnate' the
string as literal javascript code).  if youre using php5 this is as simple
as

$jsonResponse = json_encode(utf8_encode('var newHtml = [' . $html . ']'));

notice the braces on either side of the html; here were creating a
javascript array containing
our html string.  if you have multiple html segments youd like to stitch
into different parts of the
dom, simply delimit them with commas, such as

$jsonResponse = json_encode(utf8_encode('var newHtml = [' . $html . ', ' .
$html1 . ', ' . $html2 . ']'));
and so on.

then you will send that to the browser, where your ajax handler will
intercept it.
echo $jsonReponse;

on the javascript side all you need to do is run this output from the php
through the javascript interpreter.
jquery will hand you back the results packed up somehow, you will have to
read up on how it will hand this
to you (its an XMLHttpRequest object under the hood); but lets say its in a
variable, *responseText*.
the javascript to incarnate your string is:

eval('('+responseText+')');

now all the strings of html you put in the array on the server side are
available to your javascript as indexes of
the *newHtml* array.

so lets say you have a section of the dom in a div tag, with id, *
dynamicContentSection*; using traditional dhtml
techniques you would do something like this to get your new html in place

document.getElementById('dynamicContentSection').innerHtml = newHtml[0];

thats about it.  there are plenty of places to make mistakes though :)
and there alternatives to the methods ive suggested, of course.

take a look a firebug (firefox plugin) and jslint (javascript syntax
checker)
theyre great javascript debugging tools.

-nathan


On Nov 18, 2007 8:25 PM, samantha_o <[EMAIL PROTECTED]> wrote:

>
> I did not try using json because i am very new in this field and dont know
> much about it. Can you give me some examples about it? Thanks for helping.
>
>
> Shiplu wrote:
> >
> > Why dont you use json as server response? Then manipulate it by own
> > javascript. You can use jquery $.getJSON function to do the ajax part
> > for you.
> >
> > On 11/16/07, Shiplu <[EMAIL PROTECTED]> wrote:
> >> Why dont you use json as server response? Then manipulate it by own
> >> javascript. You can use jquery $.getJSON function to do the ajax part
> >> for you.
> >>
> >> On 11/16/07, samantha_o <[EMAIL PROTECTED]> wrote:
> >> >
> >> > Hi,
> >> >
> >> > i would like to submit forms with ajax, using jquery and then load
> the
> >> next
> >> > page. I had successfully do it with jquery and form plugin. however,
> it
> >> does
> >> > not work whenever the server response consist of both HTMLs and
> >> javascript
> >> > together. Is it possible to make it works? I am new in all this. Can
> >> anyone
> >> > help me?
> >> > --
> >> > View this message in context:
> >> >
> >>
> http://www.nabble.com/submitting-forms-with-ajax-tf4819530.html#a13788322
> >> > Sent from the PHP - General mailing list archive at Nabble.com.
> >> >
> >> > --
> >> > 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
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/submitting-forms-with-ajax-tf4819530.html#a13826338
> Sent from the PHP - General mailing list archive at Nabble.com.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Thanks a lot. Really appreciate it. I will try to apply it.


quickshiftin wrote:
> 
> json is just a terse way to create objects anonymously as well as other
> data
> structures in javascript.
> http://json.org/
> 
> to build a json response with html
> essentially all you need to do is create a javascript array in php and put
> the html
> you want for the next page in that.  then you use the eval() function in
> javascript
> to 'incarnate' the javascript array (which contains the html).  once youve
> done that
> you can put the html into the dom wherever you like.  typically you will
> replace some
> existing dom content w/ the new html.
> 
> so as an example; lets say on the php side of things you have your html;
> for
> the sake
> of brevity lets assume its in a variable called *$html*.  you will need to
> encode this for
> transmission (so the javascript interpreter doesnt blow up when it tries
> to
> 'incarnate' the
> string as literal javascript code).  if youre using php5 this is as simple
> as
> 
> $jsonResponse = json_encode(utf8_encode('var newHtml = [' . $html . ']'));
> 
> notice the braces on either side of the html; here were creating a
> javascript array containing
> our html string.  if you have multiple html segments youd like to stitch
> into different parts of the
> dom, simply delimit them with commas, such as
> 
> $jsonResponse = json_encode(utf8_encode('var newHtml = [' . $html . ', ' .
> $html1 . ', ' . $html2 . ']'));
> and so on.
> 
> then you will send that to the browser, where your ajax handler will
> intercept it.
> echo $jsonReponse;
> 
> on the javascript side all you need to do is run this output from the php
> through the javascript interpreter.
> jquery will hand you back the results packed up somehow, you will have to
> read up on how it will hand this
> to you (its an XMLHttpRequest object under the hood); but lets say its in
> a
> variable, *responseText*.
> the javascript to incarnate your string is:
> 
> eval('('+responseText+')');
> 
> now all the strings of html you put in the array on the server side are
> available to your javascript as indexes of
> the *newHtml* array.
> 
> so lets say you have a section of the dom in a div tag, with id, *
> dynamicContentSection*; using traditional dhtml
> techniques you would do something like this to get your new html in place
> 
> document.getElementById('dynamicContentSection').innerHtml = newHtml[0];
> 
> thats about it.  there are plenty of places to make mistakes though :)
> and there alternatives to the methods ive suggested, of course.
> 
> take a look a firebug (firefox plugin) and jslint (javascript syntax
> checker)
> theyre great javascript debugging tools.
> 
> -nathan
> 
> 
> On Nov 18, 2007 8:25 PM, samantha_o <[EMAIL PROTECTED]> wrote:
> 
>>
>> I did not try using json because i am very new in this field and dont
>> know
>> much about it. Can you give me some examples about it? Thanks for
>> helping.
>>
>>
>> Shiplu wrote:
>> >
>> > Why dont you use json as server response? Then manipulate it by own
>> > javascript. You can use jquery $.getJSON function to do the ajax part
>> > for you.
>> >
>> > On 11/16/07, Shiplu <[EMAIL PROTECTED]> wrote:
>> >> Why dont you use json as server response? Then manipulate it by own
>> >> javascript. You can use jquery $.getJSON function to do the ajax part
>> >> for you.
>> >>
>> >> On 11/16/07, samantha_o <[EMAIL PROTECTED]> wrote:
>> >> >
>> >> > Hi,
>> >> >
>> >> > i would like to submit forms with ajax, using jquery and then load
>> the
>> >> next
>> >> > page. I had successfully do it with jquery and form plugin. however,
>> it
>> >> does
>> >> > not work whenever the server response consist of both HTMLs and
>> >> javascript
>> >> > together. Is it possible to make it works? I am new in all this. Can
>> >> anyone
>> >> > help me?
>> >> > --
>> >> > View this message in context:
>> >> >
>> >>
>> http://www.nabble.com/submitting-forms-with-ajax-tf4819530.html#a13788322
>> >> > Sent from the PHP - General mailing list archive at Nabble.com.
>> >> >
>> >> > --
>> >> > 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
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/submitting-forms-with-ajax-tf4819530.html#a13826338
>> Sent from the PHP - General mailing list archive at Nabble.com.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/submitting-forms-with-ajax-tf4819530.html#a13830261
Sent from the PHP - General mailing list archive at Nabble.com.

--- End Message ---
--- Begin Message ---
I am looking forward to write a script that can send invite to contacts in
gmail,hotmail, yahoo and aol. I think it is possible to write it using php
CURL. If yes can any one suggest how?
and can any one help me write this script or join me to write this script?

-- 
Regards
Fahad Pervaiz
www.ecommerce-xperts.com
(Shopping Cart System)

--- End Message ---
--- Begin Message ---
2007. 11. 17, szombat keltezéssel 23.15-kor Stut ezt írta:
> [EMAIL PROTECTED] wrote:
> > WHY! Would you even want to pull that data first off? 
> > It would be out dated as of the next transaction anyway.
> > Secondly if you can curl the data from the server, and get your account
> > information! I suggest you change banks.
> 
> With that attitude you'll end up keeping your money under your bed. 
> Anything my browser can do curl can do.

hmm, my bank won't let me access my account with only a browser. it uses
some additional authentication, either by sms or by card reader.

greets
Zoltán Németh

> 
> > Bad decision I think to make this attempt. 
> 
> Why? If Ronald decides to access *his* account using a method other than 
> a browser, what is he doing wrong? The only downside to it is if he's 
> storing his authentication credentials somewhere so it can be an 
> automated process. Aside from that possibility I don't see the bad here.
> 
> > You can bet I will be watching your networks for an attempt on
> > authentication failures.
> > Because that request does not sound RIGHT to me.
> > 
> > inetnum: 59.124.0.0 - 59.127.255.255
> > netname: HINET-NET
> > country: TW
> > descr: CHTD, Chunghwa Telecom Co.,Ltd.
> > descr: Data-Bldg.6F, No.21, Sec.21, Hsin-Yi Rd.
> > descr: Taipei Taiwan 100
> > 
> > 
> > Interland, Inc. MAXIM-NETBLK-1 (NET-216-65-0-0-1) 
> > 216.65.0.0 - 216.65.127.255
> > Poke Internet Services MAX-CUSTNET-348 (NET-216-65-86-0-1) 
> > 216.65.86.0 - 216.65.86.255
> 
> Wow. Look everyone, he knows how to look up the owner of an IP address. 
> Phear his mad sysadmin skillz!
> 
> Seriously, I highly doubt Ronald is going to try anything against your 
> systems. Just curious about something... what would you do if he did try 
> something? Call your mother and have a little cry?
> 
> > -----Original Message-----
> > From: Ronald Wiplinger [mailto:[EMAIL PROTECTED] 
> > Sent: Friday, November 16, 2007 11:38 PM
> > To: PHP General list
> > Subject: [PHP] bank query and curl
> > 
> > I have a bank account and would like to query the last transactions.
> > 
> > I can do that now via web and think that I can convert this procedure to
> > a list of curl requests and finally put the result into a database on my
> > server.
> > Fortunately this bank account does not allow transactions, just viewing
> > the account.
> > 
> > Is there a guide available how to start this project?
> 
> I would suggest the curl documentation. In order to duplicate what a 
> browser does you basically just need to make sure you persist cookies 
> between requests. Depending on what the site you're accessing does it 
> may not be particularly trivial to do this. You may end up needing to 
> parse each page that's returned to get the right URL to use for the next 
> request, but it shouldn't get any more complicated than that.
> 
> As I mentioned above I would strongly recommend that you do not store 
> your authentication credentials anywhere. If you need this to be an 
> automated system don't bother - it's not worth the risk.
> 
> Oh, and don't underestimate the damage that can be caused by someone 
> gaining access to this account. Just because you can't carry out 
> transactions through the site doesn't mean the information it gives you 
> access to can't be used for evil purposes.
> 
> One last thing... you may find yourself getting blocked from the banks 
> site if you make too many failed requests. You may want to pick another 
> site while you learn how curl works.
> 
> -Stut
> 
> -- 
> http://stut.net/
> 

--- End Message ---
--- Begin Message ---
Zoltán Németh wrote:
2007. 11. 17, szombat keltezéssel 23.15-kor Stut ezt írta:
[EMAIL PROTECTED] wrote:
WHY! Would you even want to pull that data first off? It would be out dated as of the next transaction anyway.
Secondly if you can curl the data from the server, and get your account
information! I suggest you change banks.
With that attitude you'll end up keeping your money under your bed. Anything my browser can do curl can do.

hmm, my bank won't let me access my account with only a browser. it uses
some additional authentication, either by sms or by card reader.

Maybe so, but that doesn't alter the fact that anything my browser can do curl can do. An external source like a card reader or code by SMS would prevent completely automating the process, but it doesn't stop it being done with curl.

-Stut

--
http://stut.net/

Bad decision I think to make this attempt.
Why? If Ronald decides to access *his* account using a method other than a browser, what is he doing wrong? The only downside to it is if he's storing his authentication credentials somewhere so it can be an automated process. Aside from that possibility I don't see the bad here.

You can bet I will be watching your networks for an attempt on
authentication failures.
Because that request does not sound RIGHT to me.

inetnum: 59.124.0.0 - 59.127.255.255
netname: HINET-NET
country: TW
descr: CHTD, Chunghwa Telecom Co.,Ltd.
descr: Data-Bldg.6F, No.21, Sec.21, Hsin-Yi Rd.
descr: Taipei Taiwan 100


Interland, Inc. MAXIM-NETBLK-1 (NET-216-65-0-0-1) 216.65.0.0 - 216.65.127.255 Poke Internet Services MAX-CUSTNET-348 (NET-216-65-86-0-1) 216.65.86.0 - 216.65.86.255
Wow. Look everyone, he knows how to look up the owner of an IP address. Phear his mad sysadmin skillz!

Seriously, I highly doubt Ronald is going to try anything against your systems. Just curious about something... what would you do if he did try something? Call your mother and have a little cry?

-----Original Message-----
From: Ronald Wiplinger [mailto:[EMAIL PROTECTED] Sent: Friday, November 16, 2007 11:38 PM
To: PHP General list
Subject: [PHP] bank query and curl

I have a bank account and would like to query the last transactions.

I can do that now via web and think that I can convert this procedure to
a list of curl requests and finally put the result into a database on my
server.
Fortunately this bank account does not allow transactions, just viewing
the account.

Is there a guide available how to start this project?
I would suggest the curl documentation. In order to duplicate what a browser does you basically just need to make sure you persist cookies between requests. Depending on what the site you're accessing does it may not be particularly trivial to do this. You may end up needing to parse each page that's returned to get the right URL to use for the next request, but it shouldn't get any more complicated than that.

As I mentioned above I would strongly recommend that you do not store your authentication credentials anywhere. If you need this to be an automated system don't bother - it's not worth the risk.

Oh, and don't underestimate the damage that can be caused by someone gaining access to this account. Just because you can't carry out transactions through the site doesn't mean the information it gives you access to can't be used for evil purposes.

One last thing... you may find yourself getting blocked from the banks site if you make too many failed requests. You may want to pick another site while you learn how curl works.

-Stut

--
http://stut.net/



--- End Message ---
--- Begin Message --- "Admin": Please don't reply directly to me. If you want to say something that you don't want to share with the group, don't bother.

I did start replying to this email, but decided it wasn't worth it. Anyone who uses language like this does not deserve a response, but it made me chuckle so I thought I'd share it...

[EMAIL PROTECTED] wrote:
Before you open your SMART MOUTH about me again, find out who I am first
smart ass.
I am a level 3 IASO(Information Assurance Security Officer) Certified
software Engineer. I work for the D.O.D. and if I have to spell it out for
you smart one it is, the "Department of Defense".

It is IDIOT's like you who no clue of what that MX record is tied to, and
the past attempts on banking systems tied to that IP address range whom rant
off like they know something, when you're an idiot in all sense of the word.
Yet you spout off like your just a know it all.
It amazes me you have not choked to death on a sandwich (lacking to brain
power to comprehend the chewing process).

Look moron before you pout around like you actually know something, be DAMN
sure you are so not so fucking stupid that your brain does not over load
your ass, like you just did.
This might be hard for someone in your capacity but   R E A D     B E L O W
Brain child!!!!!

******************Just released Security alert
****************************************************************************
****************************
IT security services provider ****** says from September through October, it
blocked anywhere from 10,000 to 20,000 SQL Injection attacks per day. But as
of November that number jumped from 10,000 to 40,000 to 80,000 per day.
SQL Injection is a type of security exploit in which the attacker adds
structured query language (SQL) code to a Web form input box to gain access
to a form's resources or to make changes to data. Using this technique,
hackers can determine the structure and location of key databases and can
download the database or compromise the database server. ****** says the majority of the attacks are coming from outside the US in
the Taiwan location.
SQL injection attacks include the CardSystems security breach last year,
where hackers stole 263,000 customer credit card numbers and exposed 40
million more.

################### SysWatch ***   ####################
Processing Initiated: Sun Nov 17 04:02:01 2007
--------------------- SSHD Begin ------------------------
Failed logins from these:
   admin/password from 59.124.45.124: 502 Time(s)
   root/password from 59.124.45.124: 234 Time(s)
   guest/password from 59.124.45.124: 19 Time(s)

Illegal users from these:
   admin/none from 59.124.45.124: 1 Time(s)
   root/none from 59.124.45.124: 3 Time(s)
   guest/password from 59.124.45.124: 2 Time(s)
---------------------- SSHD End -------------------------
###################### SysWatch End  #########################


****************************************************************************
****************************************************************************

-Stut

--
http://stut.net/

-----Original Message-----
From: Stut [mailto:[EMAIL PROTECTED] Sent: Saturday, November 17, 2007 5:15 PM
To: [EMAIL PROTECTED]
Cc: 'Ronald Wiplinger'; 'PHP General list'
Subject: Re: [PHP] bank query and curl

[EMAIL PROTECTED] wrote:
WHY! Would you even want to pull that data first off? It would be out dated as of the next transaction anyway.
Secondly if you can curl the data from the server, and get your account
information! I suggest you change banks.

With that attitude you'll end up keeping your money under your bed. Anything my browser can do curl can do.

Bad decision I think to make this attempt.

Why? If Ronald decides to access *his* account using a method other than a browser, what is he doing wrong? The only downside to it is if he's storing his authentication credentials somewhere so it can be an automated process. Aside from that possibility I don't see the bad here.

You can bet I will be watching your networks for an attempt on
authentication failures.
Because that request does not sound RIGHT to me.

inetnum: 59.124.0.0 - 59.127.255.255
netname: HINET-NET
country: TW
descr: CHTD, Chunghwa Telecom Co.,Ltd.
descr: Data-Bldg.6F, No.21, Sec.21, Hsin-Yi Rd.
descr: Taipei Taiwan 100


Interland, Inc. MAXIM-NETBLK-1 (NET-216-65-0-0-1) 216.65.0.0 - 216.65.127.255 Poke Internet Services MAX-CUSTNET-348 (NET-216-65-86-0-1) 216.65.86.0 - 216.65.86.255

Wow. Look everyone, he knows how to look up the owner of an IP address. Phear his mad sysadmin skillz!

Seriously, I highly doubt Ronald is going to try anything against your systems. Just curious about something... what would you do if he did try something? Call your mother and have a little cry?

-----Original Message-----
From: Ronald Wiplinger [mailto:[EMAIL PROTECTED] Sent: Friday, November 16, 2007 11:38 PM
To: PHP General list
Subject: [PHP] bank query and curl

I have a bank account and would like to query the last transactions.

I can do that now via web and think that I can convert this procedure to
a list of curl requests and finally put the result into a database on my
server.
Fortunately this bank account does not allow transactions, just viewing
the account.

Is there a guide available how to start this project?

I would suggest the curl documentation. In order to duplicate what a browser does you basically just need to make sure you persist cookies between requests. Depending on what the site you're accessing does it may not be particularly trivial to do this. You may end up needing to parse each page that's returned to get the right URL to use for the next request, but it shouldn't get any more complicated than that.

As I mentioned above I would strongly recommend that you do not store your authentication credentials anywhere. If you need this to be an automated system don't bother - it's not worth the risk.

Oh, and don't underestimate the damage that can be caused by someone gaining access to this account. Just because you can't carry out transactions through the site doesn't mean the information it gives you access to can't be used for evil purposes.

One last thing... you may find yourself getting blocked from the banks site if you make too many failed requests. You may want to pick another site while you learn how curl works.

-Stut


--- End Message ---
--- Begin Message ---
Hi all.
Yesterday i have looking for the overloading members

Member overloading
void __set ( string name, mixed value )
mixed __get ( string name )

As an example i put this code:

class foo
{
    private $ID;
    private $Name;
    private $LastName;

    private function __get($var)
    {
        return $var;
    }

    private function __set($var,$value)
    {
        $var = $value;
    }
}


$foo = new foo();
$foo->ID = 1;
$foo->Name = "Henry";
$foo->LastName = "Ford",
....

that's horrible!!!

And if i want to validate that ID > 0??

i have to put this validation in the function __set for each property??
    private function __set($var,$value)
    {
        if ($var = 'ID')
        {
            //validate that ID is > 0
        }
        $var = $value;
    }


Not exists a better method to manage the properties in a class?

Like in C#

private int _ID;

public int ID
{
    get { return _ID;}
    set
    {
        if (value > 0)
        {
            _ID = value;
        }
 else
 {
     //Exception
 }
    }
}

--- End Message ---
--- Begin Message ---
On Mon, 2007-11-19 at 11:25 +0100, Kiketom wrote:
> Hi all.
> Yesterday i have looking for the overloading members
> 
> Member overloading
> void __set ( string name, mixed value )
> mixed __get ( string name )
> 
> As an example i put this code:
> 
> class foo
> {
>     private $ID;
>     private $Name;
>     private $LastName;
> 
>     private function __get($var)
>     {
>         return $var;
>     }
> 
>     private function __set($var,$value)
>     {
>         $var = $value;
>     }
> }
> 
> 
> $foo = new foo();
> $foo->ID = 1;
> $foo->Name = "Henry";
> $foo->LastName = "Ford",
> ....
> 
> that's horrible!!!
> 
> And if i want to validate that ID > 0??
> 
> i have to put this validation in the function __set for each property??
>     private function __set($var,$value)
>     {
>         if ($var = 'ID')
>         {
>             //validate that ID is > 0
>         }
>         $var = $value;
>     }
> 
> 
> Not exists a better method to manage the properties in a class?
> 
> Like in C#
> 
> private int _ID;
> 
> public int ID
> {
>     get { return _ID;}
>     set
>     {
>         if (value > 0)
>         {
>             _ID = value;
>         }
>  else
>  {
>      //Exception
>  }
>     }
> }

Well, if you really want to, you can do the following:

<?php

class foo
{
    private $ID;
    private $Name;
    private $LastName;

    private function __get( $var )
    {
        if( method_exists( $this, '___get_'.$var ) )
        {
            return $this->{'___get_'.$var}();
        }
        else
        {
            return $this->{$var};
        }
    }

    private function __set( $var, $value )
    {
        if( method_exists( $this, '___get_'.$var ) )
        {
            return $this->{'___set_'.$var}( $value );
        }
        else
        {
            return ($this->{$var} = $value);
        }
    }

    private function ___get_ID()
    {
    }

    private function ___set_ID( $value )
    {
    }
}

?>

But I wouldn't.

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

--- End Message ---
--- Begin Message ---
On Mon, 2007-11-19 at 06:27 -0500, Robert Cummings wrote:
> On Mon, 2007-11-19 at 11:25 +0100, Kiketom wrote:
> > Hi all.
> > Yesterday i have looking for the overloading members
> > 
> > Member overloading
> > void __set ( string name, mixed value )
> > mixed __get ( string name )
> > 
> > As an example i put this code:
> > 
> > class foo
> > {
> >     private $ID;
> >     private $Name;
> >     private $LastName;
> > 
> >     private function __get($var)
> >     {
> >         return $var;
> >     }
> > 
> >     private function __set($var,$value)
> >     {
> >         $var = $value;
> >     }
> > }
> > 
> > 
> > $foo = new foo();
> > $foo->ID = 1;
> > $foo->Name = "Henry";
> > $foo->LastName = "Ford",
> > ....
> > 
> > that's horrible!!!
> > 
> > And if i want to validate that ID > 0??
> > 
> > i have to put this validation in the function __set for each property??
> >     private function __set($var,$value)
> >     {
> >         if ($var = 'ID')
> >         {
> >             //validate that ID is > 0
> >         }
> >         $var = $value;
> >     }
> > 
> > 
> > Not exists a better method to manage the properties in a class?

Why don't you use a switch btw?

<?php

switch( $var )
{
    case 'ID':
    {
        break;
    }

    case 'Name':
    {
        break;
    }

    default:
    {
        break;
    }
}

?>

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

--- End Message ---

Reply via email to