[PHP] Server-side encryption to prevent form hacking: new idea?

2009-12-11 Thread Kelly Jones
If you have an HTML form select field xyz with possible values apple, banana, and cucumber, anyone can easily set xyz to an arbitrary value. To prevent this, I create a hidden field code[xyz] with value: base64_encode(mcrypt_ecb( MCRYPT_RIJNDAEL_256,$salt,apple,banana,cucumber,MCRYPT_ENCRYPT));

[PHP] Encrypt then decrypt yields extra dots at end

2009-09-07 Thread Kelly Jones
I thought this code: $enc=mcrypt_ecb(MCRYPT_RIJNDAEL_256,salt123,encrypt_me,MCRYPT_ENCRYPT); $dec=mcrypt_ecb(MCRYPT_RIJNDAEL_256,salt123,$enc,MCRYPT_DECRYPT); echo $dec; would yield encrypt_me. The actual result is encrypt_me.. (bunch of extra dots). Why, and how do I fix

[PHP] Arbitrary mathematical relations, not just hashes

2008-04-06 Thread Kelly Jones
Many programming languages (including Perl, Ruby, and PHP) support hashes: $color['apple'] = 'red'; $color['ruby'] = 'red'; $type['apple'] = 'fruit'; $type['ruby'] = 'gem'; This quickly lets me find the color or type of a given item. In this sense, color() and type() are like mathematical

[PHP] Intercepting fopen, mysql_connect, and similar functions for migration

2007-06-08 Thread Kelly Jones
I'm migrating a website from one server to another, and my file paths and dbs have changed. For example /a/b/c/foo.txt on the old machine is at /x/y/z/foo.txt on the new machine. The MySQL db foo on the old machine is bar on the new machine. Can I intercept fopen() and mysql_connect() so that

[PHP] Calling static child method from inherited static parent method

2007-01-03 Thread Kelly Jones
I'm trying to implement what I think is called a virtual method: my abstract parent class ParentClass defines a method xxx that calls method yyy, but yyy is defined only in ParentClass's children. I can't get this to work (PHP5.0.4). Sample code: === start sample code === abstract class

[PHP] func_get_args as a hash? (faster constructors)

2006-11-27 Thread Kelly Jones
If I define a function like this: function foo ($x, $y, $z) {} and then call: foo(1,2,bar); is there a function I can call inside foo() that yields this hash: {x = 1, y = 2, z = bar} In other words, gives me the values *and names* of the arguments to foo? func_get_args just yields the

[PHP] PHP sendmail proxy (using xinetd)

2006-11-26 Thread Kelly Jones
I'm trying to write a sendmail proxy in PHP: people would connect to my proxy running on port 25 (via xinetd), and the proxy would connect to sendmail (tweaked to run on port 26). Currently, the proxy is 100% transparent, but I plan to tweak it to intercept sendmail's replies and substitute its