MySQL Pager class
14
MySQL 5.x Stored Routines, PHP Session Values, a little CSS oh my! Complex to set up but easy to impliment. Geared toward security, simplicity (of use) and convenience.
2
If it's a .php page, you can simply include this file where you want a hit counter to appear.
One file - text output. Very simple, very easy. Based off the filename of the page (creates a pagename.counter file to hold the count).
(No use for it myself - made it for a friend).
One file - text output. Very simple, very easy. Based off the filename of the page (creates a pagename.counter file to hold the count).
(No use for it myself - made it for a friend).
2
When you need to perform an action on a single row of data, many people turn to cursors. Cursors come with a lot of overhead in the database engine and can be confusing. Here's a way to get the same results without the overhead in a much simplier way.
9
Grab a remote web document using sockets, with limited handling for 301 & 302 redirects.
12
Given a PHP array (even a deep nested array), returns a string representation of that array as JavaScript array. Useful when using PHP to output JavaScript.
-9
By this class you can make a RSS FEED page in your website.
13
Pagination Class , I think everyone knew now what's it does and means
NT: This class written by my friend have phun!
NT: This class written by my friend have phun!
6
This is a quick set of overrides for Javascript so that any variable can be passed to PHP in a GET/POST activity. Just call myVar.toPHP();
I use this little set of functions extensively in a little Javascript/PHP RPC handler I wrote. I don't have the reverse function, as I pass JSON back to the browser for the return value.
Note: This lib is not safe for binaries or HTML Elements. The former will come out similar to FTP ASCII breaks, and the latter will cause infinite recursion. If you want to make a speical case for HTML Elements, do so; you could probably just test for parentNode and create a 'safe' object from that. I didn't need it, so I didn't code it.
As for binary safety, at some point between toPHP/escape/post/urldecode/unserialize, the object breaks. Rather than create a huge fix for something I didn't need to do, I put in a quick match/hack. Don't like it? Write the fix yourself.
I use this little set of functions extensively in a little Javascript/PHP RPC handler I wrote. I don't have the reverse function, as I pass JSON back to the browser for the return value.
Note: This lib is not safe for binaries or HTML Elements. The former will come out similar to FTP ASCII breaks, and the latter will cause infinite recursion. If you want to make a speical case for HTML Elements, do so; you could probably just test for parentNode and create a 'safe' object from that. I didn't need it, so I didn't code it.
As for binary safety, at some point between toPHP/escape/post/urldecode/unserialize, the object breaks. Rather than create a huge fix for something I didn't need to do, I put in a quick match/hack. Don't like it? Write the fix yourself.
5
This is the final version of my Javascript serializer targetted at PHP.
The point:
Notes:
Javascript sample of use:
var myObject = {
name:'value',
test:['Array','of','strings'],
bool:false,
timestamp: new Date(),
float: 3.1415926539,
number: 42,
func: function () {
alert('Member functions are always omitted from serialization');
}
}
alert(Object.toPHP(myObject));
Output:
Sample of subsequent unserialization in PHP (passed via POST as 'myobject')
$myObject=unserialize(stripslashes($_POST['myobject']));
var_dump($myObject);
Output:
The point:
Objects are most easily passed over the network as serialized strings. Between serialization and unserialization, serialization is by far the easier of the two. Since object passing can sometimes be a process-hungry thing, we want to do things as quickly as possible.
My solution is to always do the hard part in compiled code, while doing the easy part in script. That is, whichever way you're passing an Object, you want to pass it in a natively decoded format for the target.
Since I work mostly in PHP, this meant writing a module that would be able to generate a string that can be decoded with PHP's unserialize() function into a PHP Associative Array (or other applicable type).
Notes:
This lib REQUIRES the Prototype lib. You can hack prototype out of it, of course (by replacing the references to Object.extend() with explicit assignments), but I can't imagine why you'd want to bother; it's used mostly with Ajax.Request anyway.
Previous versions of this code would add the .toPHP() member to the Object prototype. After trying to enumerate things, I found that this is a REALLY bad thing to do, as toPHP springs up where it's not wanted in ALL objects. As a result, I've opted to go the Prototype route and apply it as a member of the Object object.
Please note that if you pass a serialized string to PHP via GET or POST, you'll need to stripslashes() before unserialization.
Javascript sample of use:
var myObject = {
name:'value',
test:['Array','of','strings'],
bool:false,
timestamp: new Date(),
float: 3.1415926539,
number: 42,
func: function () {
alert('Member functions are always omitted from serialization');
}
}
alert(Object.toPHP(myObject));
Output:
a:7:{s:4:"name";s:5:"value";s:4:"test";a:3:{i:0;s:5:"Array";i:1;s:2:"of";i:2;s:7:"strings";}s:4:"bool";b:0;s:9:"timestamp";i:1190897619824;s:5:"float";d:3.1415926539;s:6:"number";i:42;s:4:"func";null}
Sample of subsequent unserialization in PHP (passed via POST as 'myobject')
$myObject=unserialize(stripslashes($_POST['myobject']));
var_dump($myObject);
Output:
array(7) {
["name"]=>
string(5) "value"
["test"]=>
array(3) {
[0]=>
string(5) "Array"
[1]=>
string(2) "of"
[2]=>
string(7) "strings"
}
["bool"]=>
bool(false)
["timestamp"]=>
int(1192296601)
["float"]=>
float(3.1415926539)
["number"]=>
int(42)
["func"]=>
NULL
}
3
Simple. It's parse_url, from PHP, implemented in Javascript. Seen a lot of similar ones around the web, but they were all bulky code and none of them took advantage of the RegEx parser in JS.
Applied as a member of the String prototype, so just call as myURL.parseURL(); Will return a named object with naming identical to that of PHP's function.
Additional: if first argument is present, will break the querystring up into name/value pairs, unescaped, and return that instead of the raw querystriing.
Applied as a member of the String prototype, so just call as myURL.parseURL(); Will return a named object with naming identical to that of PHP's function.
Additional: if first argument is present, will break the querystring up into name/value pairs, unescaped, and return that instead of the raw querystriing.









