php functions to prevent hacks

Categories: php

Tags: hack, 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 &amp;, < becomes &lt; etc.


php: is gd library installed?

Categories: php

Tags: gd, image, 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!";

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.


php: image manipulation

Categories: php, unix

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


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. :-/


1 2 3 4 5 »

Affliates

Spreadfirefox Affiliate Button