OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
php-general Digest 11 Oct 2007 15:03:08 -0000 Issue 5067

php-general-digest-helplists.php.net
Date: Thu Oct 11 2007 - 10:03:08 CDT


php-general Digest 11 Oct 2007 15:03:08 -0000 Issue 5067

Topics (messages 263084 through 263106):

Re: Something you can do with AJAX + PHP as well
        263084 by: Per Jessen
        263098 by: tedd
        263106 by: Per Jessen

How to decode the PHP Source Code
        263085 by: Javed Khan
        263089 by: Jay Blanchard
        263099 by: Robert Cummings
        263102 by: Daniel Brown

Filter input
        263086 by: Manuel Vacelet
        263105 by: Jim Lucas

Classes - Dumb question
        263087 by: Christian Hänsel
        263091 by: Jay Blanchard
        263093 by: Jason Pruim
        263100 by: Robert Cummings

Re: Beginner Tutorials for using CLASSES in PHP4
        263088 by: Jay Blanchard
        263097 by: Robert Cummings
        263103 by: Nathan Nobbe

Best way to automatically get mySQL database.
        263090 by: Angelo Zanetti
        263092 by: Jay Blanchard
        263096 by: Angelo Zanetti

FileZilla Password Decoder
        263094 by: Amos Vryhof

Re: FileZilla Password Decoder --- $i think therefore $i am
        263095 by: Jochem Maas

Re: round()
        263101 by: tedd
        263104 by: Nathan Nobbe

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


tedd wrote:

> At 3:27 PM +0200 10/10/07, Per Jessen wrote:
>>Colin Guthrie wrote:
>>
>>>> What do you think of this?
>>>>
>>>> http://webbytedd.com/b/timed-php/
>>>>
>>>> It's a combination of using both ajax and php together.
>>>
>>> I'd say overkill for the end result (could be done in plain
>>> Javascript without any "Ajax" calls),
>>
>>That was my reaction too. I've used iframe/rpc for about three years
>>- ajax doesn't improve on the basic functionality.
>>
>>/Per Jessen, Zürich
>
> The rotation of a graphic could be done in javascript, that's true.
> But, the process demonstrated goes a bit deeper than that.

Hi Tedd,

OK, what exactly have you demonstrated that could not have been done
using javascript/iframe-rpc ?

ajax is nothing but javascript, and in principle it is exactly the same
as using iframe-rpc.

/Per Jessen, Zürich

attached mail follows:


At 8:40 AM +0200 10/11/07, Per Jessen wrote:
>tedd wrote:
>
>> At 3:27 PM +0200 10/10/07, Per Jessen wrote:
>>>Colin Guthrie wrote:
>>>
>>>>> What do you think of this?
>>>>>
>>>>> http://webbytedd.com/b/timed-php/
>>>>>
>>>>> It's a combination of using both ajax and php together.
>>>>
>>>> I'd say overkill for the end result (could be done in plain
>>>> Javascript without any "Ajax" calls),
>>>
>>>That was my reaction too. I've used iframe/rpc for about three years
>>>- ajax doesn't improve on the basic functionality.
>>>
>>>/Per Jessen, Zürich
>>
>> The rotation of a graphic could be done in javascript, that's true.
>> But, the process demonstrated goes a bit deeper than that.
>
>Hi Tedd,
>
>OK, what exactly have you demonstrated that could not have been done
>using javascript/iframe-rpc ?
>
>ajax is nothing but javascript, and in principle it is exactly the same
>as using iframe-rpc.

I dunno -- I've never used iframe-rpc and I'm not commenting pro/con about it.

I was just saying that my demo is a combination
of using php and ajax to produce something.

Now, maybe some people want to call it an
overkill and say that *everything* could be done
in javascript alone. That's fine, but they are
missing the point I'm failing to make. My demo is
just another (not unique) way to use both
javascript and php to solve a problem.

For example: If you have a process that is taking
time server-side and want to let the user know in
real time what the progress is, this is one way
to do it. That's not something (by definition)
you can do with javascript alone, right?

There are other applications, but if you fail to
see the basic concept, then you also fail to see
the opportunity.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


tedd wrote:

> For example: If you have a process that is taking time server-side and
> want to let the user know in real time what the progress is, this is
> one way to do it. That's not something (by definition) you can do with
> javascript alone, right?

Correct, but it doesn't require any ajax either. That was my main
point.

/Per Jessen, Zürich

attached mail follows:


Hello Everyone,
I have the source code of a php application I got from someone but it is encoded with IonCude.
I would really appreciate if someone can send me any solution for that.

Thank you,
Javed

> From: percomputer.org
> Date: Thu, 11 Oct 2007 08:40:22 +0200
> To: php-generallists.php.net
> Subject: Re: [PHP] Re: Something you can do with AJAX + PHP as well
>
> tedd wrote:
>
> > At 3:27 PM +0200 10/10/07, Per Jessen wrote:
> >>Colin Guthrie wrote:
> >>
> >>>> What do you think of this?
> >>>>
> >>>> http://webbytedd.com/b/timed-php/
> >>>>
> >>>> It's a combination of using both ajax and php together.
> >>>
> >>> I'd say overkill for the end result (could be done in plain
> >>> Javascript without any "Ajax" calls),
> >>
> >>That was my reaction too. I've used iframe/rpc for about three years
> >>- ajax doesn't improve on the basic functionality.
> >>
> >>/Per Jessen, Zürich
> >
> > The rotation of a graphic could be done in javascript, that's true.
> > But, the process demonstrated goes a bit deeper than that.
>
> Hi Tedd,
>
> OK, what exactly have you demonstrated that could not have been done
> using javascript/iframe-rpc ?
>
> ajax is nothing but javascript, and in principle it is exactly the same
> as using iframe-rpc.
>
>
> /Per Jessen, Zürich
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE

attached mail follows:


[snip]
I have the source code of a php application I got from someone but it is
encoded with IonCude.
I would really appreciate if someone can send me any solution for that.
[/snip]

Please do not hijack threads. If you have a new subject create a new
e-mail with said subject. This helps to maintain thread readability.

http://www.qinvent.com/cyrj/deZender/index-en.php

was revealed in the first item of the first page of a google search for
"decode IonCube". Google is your friend.

attached mail follows:


On Thu, 2007-10-11 at 12:06 +0000, Javed Khan wrote:
> Hello Everyone,
> I have the source code of a php application I got from someone but it is encoded with IonCude.
> I would really appreciate if someone can send me any solution for that.

There's a reason it's encoded with IonCube. Someone didn't want you to
have access to plain source code.

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

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

attached mail follows:


On 10/11/07, Javed Khan <javedkhan1947hotmail.com> wrote:
>
> Hello Everyone,
> I have the source code of a php application I got from someone but it is encoded with IonCude.
> I would really appreciate if someone can send me any solution for that.
>
> Thank you,
> Javed
>
>
> > From: percomputer.org
> > Date: Thu, 11 Oct 2007 08:40:22 +0200
> > To: php-generallists.php.net
> > Subject: Re: [PHP] Re: Something you can do with AJAX + PHP as well
> >
> > tedd wrote:
> >
> > > At 3:27 PM +0200 10/10/07, Per Jessen wrote:
> > >>Colin Guthrie wrote:
> > >>
> > >>>> What do you think of this?
> > >>>>
> > >>>> http://webbytedd.com/b/timed-php/
> > >>>>
> > >>>> It's a combination of using both ajax and php together.
> > >>>
> > >>> I'd say overkill for the end result (could be done in plain
> > >>> Javascript without any "Ajax" calls),
> > >>
> > >>That was my reaction too. I've used iframe/rpc for about three years
> > >>- ajax doesn't improve on the basic functionality.
> > >>
> > >>/Per Jessen, Zürich
> > >
> > > The rotation of a graphic could be done in javascript, that's true.
> > > But, the process demonstrated goes a bit deeper than that.
> >
> > Hi Tedd,
> >
> > OK, what exactly have you demonstrated that could not have been done
> > using javascript/iframe-rpc ?
> >
> > ajax is nothing but javascript, and in principle it is exactly the same
> > as using iframe-rpc.
> >
> >
> > /Per Jessen, Zürich
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> _________________________________________________________________
> Discover the new Windows Vista
> http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE

    There are just way too many things wrong with this message. It
would be fun to count them all together, wouldn't it? ;-P

    By the way, Tedd.... you alright there? Ya' kinda' got squashed.

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Give a man a fish, he'll eat for a day. Then you'll find out he was
allergic and is hospitalized. See? No good deed goes unpunished....

attached mail follows:


Hi all,

I repeat the mantra 'filter input, escape output' every day before
writing any line of code.
About "filter input" I use to develop my own filter but I don't like
this solution as it's error prone (my regexp may be wrong, I don't
like to re-invent the wheel that much, ...).

I'd like to know if there is a library that could help me. I identified:
- PEAR Validate:
  * seems nice
  * but no activity since ~1year and still "beta".

- PEAR HTML_QuickForm:
  * validation is a part of its job.
  * not very usable if you only want to validate input (need to
declare each element before, access to invalid element not easy).

- PHP Filter:
  * Require php 5.2
  * As it's embedded in the php core, if there is a security hole we
need to wait for a new php version to fix the bug.

Is there any other library I need to investigate ?
What are you using for your own developments ?

-- Manuel

attached mail follows:


Manuel Vacelet wrote:
> Hi all,
>
> I repeat the mantra 'filter input, escape output' every day before
> writing any line of code.
> About "filter input" I use to develop my own filter but I don't like
> this solution as it's error prone (my regexp may be wrong, I don't
> like to re-invent the wheel that much, ...).
>
> I'd like to know if there is a library that could help me. I identified:
> - PEAR Validate:
> * seems nice
> * but no activity since ~1year and still "beta".
>
> - PEAR HTML_QuickForm:
> * validation is a part of its job.
> * not very usable if you only want to validate input (need to
> declare each element before, access to invalid element not easy).
>
> - PHP Filter:
> * Require php 5.2
> * As it's embedded in the php core, if there is a security hole we
> need to wait for a new php version to fix the bug.
>
> Is there any other library I need to investigate ?
> What are you using for your own developments ?
>
> -- Manuel
>
What are you wanting to validate?

Do you want a package/class/function set that when called will validate different types of input?
Email, string, int, etc...

--
Jim Lucas

    "Some men are born to greatness, some achieve greatness,
        and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
     by William Shakespeare

attached mail follows:


Howdy fellas,

okay, this is really (!) embarassing, but I have to ask:

Why would I want to use classes in PHP?

I have been using PHP for years now and writing the "normal" functions all
the time. I have never even bothered working with classes, but now I would
love to know what makes the classes so special...

Please go easy on me ;o) Just trying to make another step :o)

Cheerio, and thanks in advance for any answers.

Chris

attached mail follows:


[snip]
okay, this is really (!) embarassing, but I have to ask:

Why would I want to use classes in PHP?

I have been using PHP for years now and writing the "normal" functions all
the time. I have never even bothered working with classes, but now I would
love to know what makes the classes so special...

Please go easy on me ;o) Just trying to make another step :o)
[/snip]

Do not be embarrassed, this is a very good question.

First of all what you call "normal" is procedural or functional programming. There is nothing wrong with doing things this way and may be especially quick and efficient when doing basic web sites and applications. Document well and you will have no problem maintaining your code.

OOP (object oriented programming) is especially useful when the application you have created needs to scale. A quick example; you have sold your products to the consumer market for a long time but now the commercial market has become interested. Commercial customers are different than non-commercial customers, different data, different credit requirements, different shipping, etc. but they still have a lot in common, If you had a class Customer you could extended that class to include commercial customers and only have to code for the unique qualities of that kind of customer. Then if another type of customer crops up, say a military contract, you could extend again;

class Customer {
        ....
}

class CommercialCustomer extends Customer {
        /*
         *only code unique to commercial customers
         * inherits from Customer other variables
         * and functions that are common
         */
}

class MilitaryCustomer extends Customer {
        /*
         *only code unique to military customers
         * inherits from Customer other variables
         * and functions that are common
         */
}

http://www.sitepoint.com/article/object-oriented-php

attached mail follows:


On Oct 11, 2007, at 8:36 AM, Jay Blanchard wrote:

> [snip]
> okay, this is really (!) embarassing, but I have to ask:
>
> Why would I want to use classes in PHP?
>
> I have been using PHP for years now and writing the "normal"
> functions all
> the time. I have never even bothered working with classes, but now
> I would
> love to know what makes the classes so special...
>
> Please go easy on me ;o) Just trying to make another step :o)
> [/snip]
>
> Do not be embarrassed, this is a very good question.
>
> First of all what you call "normal" is procedural or functional
> programming. There is nothing wrong with doing things this way and
> may be especially quick and efficient when doing basic web sites
> and applications. Document well and you will have no problem
> maintaining your code.
>
> OOP (object oriented programming) is especially useful when the
> application you have created needs to scale. A quick example; you
> have sold your products to the consumer market for a long time but
> now the commercial market has become interested. Commercial
> customers are different than non-commercial customers, different
> data, different credit requirements, different shipping, etc. but
> they still have a lot in common, If you had a class Customer you
> could extended that class to include commercial customers and only
> have to code for the unique qualities of that kind of customer.
> Then if another type of customer crops up, say a military contract,
> you could extend again;
>
> class Customer {
> ....
> }
>
> class CommercialCustomer extends Customer {
> /*
> *only code unique to commercial customers
> * inherits from Customer other variables
> * and functions that are common
> */
> }
>
> class MilitaryCustomer extends Customer {
> /*
> *only code unique to military customers
> * inherits from Customer other variables
> * and functions that are common
> */
> }
>
> http://www.sitepoint.com/article/object-oriented-php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Not trying to hijack the thread... Hopefully this is related enough,
if not I apologize. Would a good use of a class be to write a generic
database connection script? and then feed in the different variables,
such as customer login, database, stuff like that?

something like class DBConnect {
        // Connect to database
        mysql_connect($server, $login, $password, $database);
        }

or no?
--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
japruimraoset.com

attached mail follows:


On Thu, 2007-10-11 at 07:36 -0500, Jay Blanchard wrote:
> [snip]
> okay, this is really (!) embarassing, but I have to ask:
>
> Why would I want to use classes in PHP?
>
> I have been using PHP for years now and writing the "normal" functions all
> the time. I have never even bothered working with classes, but now I would
> love to know what makes the classes so special...
>
> Please go easy on me ;o) Just trying to make another step :o)
> [/snip]
>
> Do not be embarrassed, this is a very good question.
>
> First of all what you call "normal" is procedural or functional programming. There is nothing wrong with doing things this way and may be especially quick and efficient when doing basic web sites and applications. Document well and you will have no problem maintaining your code.
>
> OOP (object oriented programming) is especially useful when the application you have created needs to scale. A quick example; you have sold your products to the consumer market for a long time but now the commercial market has become interested. Commercial customers are different than non-commercial customers, different data, different credit requirements, different shipping, etc. but they still have a lot in common, If you had a class Customer you could extended that class to include commercial customers and only have to code for the unique qualities of that kind of customer. Then if another type of customer crops up, say a military contract, you could extend again;
>
> class Customer {
> ....
> }
>
> class CommercialCustomer extends Customer {
> /*
> *only code unique to commercial customers
> * inherits from Customer other variables
> * and functions that are common
> */
> }
>
> class MilitaryCustomer extends Customer {
> /*
> *only code unique to military customers
> * inherits from Customer other variables
> * and functions that are common
> */
> }
>
> http://www.sitepoint.com/article/object-oriented-php

Another good reason is for function/data grouping. By using a class you
don't have to worry about name collisions for your functions, although
you can still have class name collisions. Also, data related to any
operations can be tracked via the object rather than cluttering the
global namespace between function calls.

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

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

attached mail follows:


[snip]
What I was really illustrating is how interfaces are syntactic
sugar only. In my above example what I've really shown is an
implicit interface :) Since OOP is largely meant to model real
world things, ask yourself this... when a doctor sews a pig's
heart into a human, do you think there's an explicit interface
someplace that checks for compatibility, or does it "just work"
if the conditions are right. Food for thought, pork in fact ;)
[/snip]

No doubt they are syntactic sugar (and not needed for polymorphism), PHP
and other languages are sprinkled with such spices. And just like spices
these things have a proper place and usage. (Unless I am slow cooking my
world famous brown sugar and cinnamon brisket.) Given the class brisket
that extends meat I would likely use an interface to implement said
world famous brisket just as others might implement an interface for
their brisket. Of course my recipe could be a child of brisket, but may
violate the IS_A relationship unless a recipe is implicitly implied for
each brisket. Sometimes this syntactic sugar makes for cleaner code
(especially when others who are not aware, sometimes folks do it just to
do it. YMMV and I am now hungry.

BTW, pigs hearts and other body parts are used extensively in research
where human physiology is concerned because of their similarity.

attached mail follows:


On Thu, 2007-10-11 at 07:19 -0500, Jay Blanchard wrote:
> [snip]
> What I was really illustrating is how interfaces are syntactic
> sugar only. In my above example what I've really shown is an
> implicit interface :) Since OOP is largely meant to model real
> world things, ask yourself this... when a doctor sews a pig's
> heart into a human, do you think there's an explicit interface
> someplace that checks for compatibility, or does it "just work"
> if the conditions are right. Food for thought, pork in fact ;)
> [/snip]
>
> No doubt they are syntactic sugar (and not needed for polymorphism), PHP
> and other languages are sprinkled with such spices. And just like spices
> these things have a proper place and usage. (Unless I am slow cooking my
> world famous brown sugar and cinnamon brisket.) Given the class brisket
> that extends meat I would likely use an interface to implement said
> world famous brisket just as others might implement an interface for
> their brisket. Of course my recipe could be a child of brisket, but may
> violate the IS_A relationship unless a recipe is implicitly implied for
> each brisket. Sometimes this syntactic sugar makes for cleaner code
> (especially when others who are not aware, sometimes folks do it just to
> do it. YMMV and I am now hungry.
>
> BTW, pigs hearts and other body parts are used extensively in research
> where human physiology is concerned because of their similarity.

And how do you think "similarity" was determined? Most likely by trying
options until something worked :)

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

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

attached mail follows:


On 10/11/07, Robert Cummings <robertinterjinn.com> wrote:
>
> On Thu, 2007-10-11 at 07:19 -0500, Jay Blanchard wrote:
> > [snip]
> > What I was really illustrating is how interfaces are syntactic
> > sugar only. In my above example what I've really shown is an
> > implicit interface :) Since OOP is largely meant to model real
> > world things, ask yourself this... when a doctor sews a pig's
> > heart into a human, do you think there's an explicit interface
> > someplace that checks for compatibility, or does it "just work"
> > if the conditions are right. Food for thought, pork in fact ;)
> > [/snip]
> >
> > No doubt they are syntactic sugar (and not needed for polymorphism), PHP
> > and other languages are sprinkled with such spices. And just like spices
> > these things have a proper place and usage. (Unless I am slow cooking my
> > world famous brown sugar and cinnamon brisket.) Given the class brisket
> > that extends meat I would likely use an interface to implement said
> > world famous brisket just as others might implement an interface for
> > their brisket. Of course my recipe could be a child of brisket, but may
> > violate the IS_A relationship unless a recipe is implicitly implied for
> > each brisket. Sometimes this syntactic sugar makes for cleaner code
> > (especially when others who are not aware, sometimes folks do it just to
> > do it. YMMV and I am now hungry.
> >
> > BTW, pigs hearts and other body parts are used extensively in research
> > where human physiology is concerned because of their similarity.
>
> And how do you think "similarity" was determined? Most likely by trying
> options until something worked :)

im sure they chopped a few of them open; that is they analyzed the
implementation
directly, rather than looking at it as a black box and praying..

and i would still say the holes or openings the heart exposes are an
explicit interface
that the doctors do run a check against. namely, how many holes are there,
and
do they correspond to the same holes on the human heart.

perhaps theres an implicit interface somewhere inside the implementation.
the pig
heart calls a method on a human blood cell that has to be there otherwise
something
doesnt happen and in the worst case a fatal error occurs and the person has
a stroke.

-nathan

attached mail follows:


hi guys.

We've got a local system (PHP intranet) and we need to connect to a live
mySQL server get some of the tables (contents) and overwrite the same
tables in the local mySQL database. This needs to be done with PHP.

Im wondering the best to do this.

Is it to get all the information into result sets for each table and
then delete the contents of each local table and then looping through
the result sets just insert the information into the local tables? This
seems like a good solution but I wonder if there are any out there
before going ahead with development.

Let me know your views etc...

Thanks in advance

--
------------------------------------------------------------------------
Angelo Zanetti
Systems developer
------------------------------------------------------------------------

*Telephone:* +27 (021) 552 9799
*Mobile:* +27 (0) 72 441 3355
*Fax:* +27 (0) 86 681 5885
*
Web:* http://www.zlogic.co.za
*E-Mail:* angelozlogic.co.za <mailto:angelozlogic.co.za>

attached mail follows:


[snip]
We've got a local system (PHP intranet) and we need to connect to a live

mySQL server get some of the tables (contents) and overwrite the same
tables in the local mySQL database. This needs to be done with PHP.

Im wondering the best to do this.

Is it to get all the information into result sets for each table and
then delete the contents of each local table and then looping through
the result sets just insert the information into the local tables? This
seems like a good solution but I wonder if there are any out there
before going ahead with development.
[/snip]

TRUNCATE local_table;
SELECT remote_stuff INTO local_table;

attached mail follows:


thanks

thought there was something simpler

Jay Blanchard wrote:
> [snip]
> We've got a local system (PHP intranet) and we need to connect to a live
>
> mySQL server get some of the tables (contents) and overwrite the same
> tables in the local mySQL database. This needs to be done with PHP.
>
> Im wondering the best to do this.
>
> Is it to get all the information into result sets for each table and
> then delete the contents of each local table and then looping through
> the result sets just insert the information into the local tables? This
> seems like a good solution but I wonder if there are any out there
> before going ahead with development.
> [/snip]
>
> TRUNCATE local_table;
> SELECT remote_stuff INTO local_table;
>
>

--
------------------------------------------------------------------------
Angelo Zanetti
Systems developer
------------------------------------------------------------------------

*Telephone:* +27 (021) 552 9799
*Mobile:* +27 (0) 72 441 3355
*Fax:* +27 (0) 86 681 5885
*
Web:* http://www.zlogic.co.za
*E-Mail:* angelozlogic.co.za <mailto:angelozlogic.co.za>

attached mail follows:


Good Morning everyone,

This week, I switched from FileZilla 2 to FileZilla 3, and much to my
dismay the import function doesn't import the local and remote folders
properly.

Looking at the FZ2 and FZ3 XML files, it appears that it would be a
simple task to write a converter that does. I have a good start on one,
(so far it takes all of the parameters in the FZ2 lines and converts
them into an array that I will just write back out in XML format) but
FZ3 stores the passwords while FZ2 used encoded passwords.

I found a Python script at http://www.petersblog.org/node/1152 that is
supposed to decode the passwords to plain text -

def DecodePassword( strPass):
     """Decode a filezilla password"""
     strKey = "FILEZILLA1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"

     nPassLen = len(strPass) / 3
     nOffset = nPassLen % len(strKey)

     strDecodedPass = ""

     for i in range(nPassLen):
         c = int(strPass[i * 3:(i * 3) + 3])
         c2 = ord(strKey[(i + nOffset) % len(strKey)])
         c3 = chr((c ^ c2))

         strDecodedPass += c3

     return strDecodedPass

...and tried to convert it to PHP, but since I don't know Python and
there is no documentation in the script to say what it's doing, my
function doesn't spit out all of the right characters... (it does some
though?? maybe coincidence)

   function DecodePassword($strPass) {
     $strKey = "FILEZILLA1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";

     $nPassLen = strlen($strPass) / 3;
     $nOffset = ($nPassLen % strlen($strKey));

     $strDecodedPass = "";
        
     $passPieces = str_split($strPass,3);
        
     foreach($passPieces as $passPiece) {
        $c = intval($passPiece);
         $c2 = ord($strKey[($i + $nOffset) % strlen($strKey)]);
         $c3 = chr(($c ^ $c2));

        $strDecodedPass .= $c3;
     }

     return $strDecodedPass;
}

I know I simplified quite a bit, but I might have done it wrong...I
tried to convert line-for line, but I'm not sure what the stuff on Lines
10 to 13 do. (Lack of Perl knowledge)

There are perl and Javascript functions to do the decoding at
http://filezilla.sourceforge.net/forum/viewtopic.php?t=170

I'm not looking for a major undertaking, just something to do the
conversion so I don't have to rebuild definitions for 200 and something
websites.... If I can get it working properly, I'll probably put a
version on my server so people can convert their files as well, as I can
see this being a major PITA.

Thanks!

attached mail follows:


Amos Vryhof wrote:
> Good Morning everyone,
>

....

>
> def DecodePassword( strPass):
> """Decode a filezilla password"""
> strKey = "FILEZILLA1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"
>
> nPassLen = len(strPass) / 3
> nOffset = nPassLen % len(strKey)
>
> strDecodedPass = ""
>
> for i in range(nPassLen):
> c = int(strPass[i * 3:(i * 3) + 3])
> c2 = ord(strKey[(i + nOffset) % len(strKey)])
> c3 = chr((c ^ c2))
>
> strDecodedPass += c3
>
> return strDecodedPass
>
> ...and tried to convert it to PHP, but since I don't know Python and
> there is no documentation in the script to say what it's doing, my
> function doesn't spit out all of the right characters... (it does some
> though?? maybe coincidence)
>
> function DecodePassword($strPass) {
> $strKey = "FILEZILLA1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
>
> $nPassLen = strlen($strPass) / 3;
> $nOffset = ($nPassLen % strlen($strKey));
>
> $strDecodedPass = "";
>
> $passPieces = str_split($strPass,3);
>
> foreach($passPieces as $passPiece) {
> $c = intval($passPiece);
> $c2 = ord($strKey[($i + $nOffset) % strlen($strKey)]);

                             ^---- WHERE IS $i DEFINED? (hint: it's not :-)

> $c3 = chr(($c ^ $c2));
>
> $strDecodedPass .= $c3;
> }
>
> return $strDecodedPass;
> }
>
> I know I simplified quite a bit, but I might have done it wrong...I
> tried to convert line-for line, but I'm not sure what the stuff on Lines
> 10 to 13 do. (Lack of Perl knowledge)
>
> There are perl and Javascript functions to do the decoding at
> http://filezilla.sourceforge.net/forum/viewtopic.php?t=170
>
> I'm not looking for a major undertaking, just something to do the
> conversion so I don't have to rebuild definitions for 200 and something
> websites.... If I can get it working properly, I'll probably put a
> version on my server so people can convert their files as well, as I can
> see this being a major PITA.
>
> Thanks!
>

attached mail follows:


At 4:18 PM -0600 10/10/07, <adminbuskirkgraphics.com> wrote:
>I disagree. I will need to see an example where the round() is inaccurate.

You may disagree if you wish, but the php function round() is
inaccurate by definition -- all *rounding* algorithms are inaccurate.

My claim is the there are more accurate ways to round.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


On 10/11/07, tedd <teddsperling.com> wrote:
>
> At 4:18 PM -0600 10/10/07, <adminbuskirkgraphics.com> wrote:
> >I disagree. I will need to see an example where the round() is
> inaccurate.
>
>
> You may disagree if you wish, but the php function round() is
> inaccurate by definition -- all *rounding* algorithms are inaccurate.
>

thats why i suggested the bcmath based algorithm, as bcmath supports
arbitrary
precision. i built a quick test script using the method from the top
comment of the
bcmath page, and round(). it allows for quick comparisons of the 2
algorithms and
tells you if the results are the same. i messed around w/ it a little bit
and the results
were the same every time.

nathandevel ~/working/www $ vim bcRound.php
nathandevel ~/working/www $ ./bcRound.php 5.58635634564356 6
round result: 5.586356
roundbc result: 5.586356
the results are different
nathandevel ~/working/www $ vim bcRound.php
nathandevel ~/working/www $ ./bcRound.php 5.58635634564356 6
round result: 5.586356
roundbc result: 5.586356
the results are the same
nathandevel ~/working/www $ ./bcRound.php 5.58635634564356 8
round result: 5.58635635
roundbc result: 5.58635635
the results are the same
nathandevel ~/working/www $ ./bcRound.php 5.58635634564356 3
round result: 5.586
roundbc result: 5.586
the results are the same

i dont know what the point of the toFixed() function is (posted earlier).
round takes a second parameter that specifies the desired precision.

#!/usr/bin/php
<?php
if($argc != 3) {
    die('Usage: rounder.php <float> <precision>' . PHP_EOL);
}

$float = $argv[1];
$precision = $argv[2];

$roundResult = round($float, $precision);
$roundbcResult = roundbc($float, $precision);

echo "round result: $roundResult" . PHP_EOL;
echo "roundbc result: $roundbcResult" . PHP_EOL;

if($roundResult !== $roundbcResult) {
    echo 'the results are the same' . PHP_EOL;
} else {
    echo 'the results are different' . PHP_EOL;
}

    /// borrowed from post on php.net
    function roundbc($x, $p) {

        $x = trim($x);
        $data = explode(".",$x);

        if(substr($data[1],$p,1) >= "5") {

           //generate the add string.
           $i=0;
           $addString = "5";
            while($i < $p) {
                $addString = "0" . $addString;
                $i++;
            }//end while.

           $addString = "." . $addString;

           //now add the addString to the original fraction.
           $sum = bcadd($data[0] . "." . $data [1],$addString,$p+1);

           //explode the result.
           $sumData = explode(".",$sum);

           //now, return the correct precision on the rounded number.
           return $sumData[0] . "." . substr($sumData[1],0,$p);

         } else {
           //don't round the value and return the orignal to the desired
           //precision or less.
           return $data[0] . "." . substr($data[1],0,$p);

      }//end if/else.

    }//end roundbc.
?>

-nathan