php functions to prevent hacks
Categories: php
strip_tags() removes html and php tags from string. should be immediately called on data input and before any data processing functions.
nl2br() converts newlines to <br />. run strip_tags before calling this function or the <br /> will be stripped.
htmlspecialchars() convert special chars to html entities. & (ampesand) becomes &, < becomes < etc.
2008-12-17 14:53:54 • Link • Comments • Trackbacks
php: is gd library installed?
Categories: php
to check if the server has gd library,
PHP:
if (extension_loaded("gd")) | |
echo "yes!"; |
another way is to check any gd related function, eg
PHP:
if (function_exists("gd_info")) | |
echo "yes!"; |
2008-12-11 14:11:21 • Link • Comments • Trackbacks
php: get image size
Categories: php
Tags: getimagesize, image, php
to access basic image information like width and height, call getimagesize, which returns data in array format such as
Code:
Array | |
( | |
[0] => 640 // width | |
[1] => 426 // height | |
[2] => 2 // not sure what this is. anyone? | |
[3] => width="640" height="426" // for <img> param | |
[bits] => 8 | |
[channels] => 3 | |
[mime] => image/jpeg // mime type | |
) |
note: this function does not require gd library.
2008-12-04 16:06:14 • Link • Comments • Trackbacks
php: image manipulation
Tags: fedora, gd, image, php, ubuntu
the gd image library provide functions to manipulate image files.
on some installations, this does not come as default and needs to be installed.
on fedora, the command is
yum install php-gd
on ubuntu, the command is
sudo apt-get install php5-gd
2008-12-04 10:57:59 • Link • Comments • Trackbacks
open source ecommerce products
Categories: php, tool, bookmark, free
Tags: ecommerce, free, open source
list and reviews here and here.
according to the comments to these articles, stay away from OsCommerce – this comes up top from google search. ![]()
2008-11-21 10:33:35 • Link • Comments • Trackbacks
