Recommended:

  • phpclasses.org
  • jsclasses.org
  • jsmag.com
  • siteapps.com
  • View our reviews on Hot Scripts
  • JS Tutorial
  • scripts.com
  • securesignup.com




Recent Comments

Powered by Disqus




Javascript multiple file download queue

This piece of code allows you to force users to download multiple files one by one using javascript. It can be used to simply download files or use it combination with PHP force download. Although javascript opens file in new window, thus forcing open/save dialog box, it might not work in all browsers. So you may want to modify it to link file...

Comments Read more

One of the best php chats - phpFreeChat

phpFreeChat is one of the best, because of it's customization options and easy integration with site authentication. You can download it here:http://www.phpfreechat.net/.  The version I used is 1.2 and it has automatic installation PHP file, which I recommend to use. After installation to use this chat with your site...

Comments Read more

List of all $_SERVER variables and values

Here is the code, that gives you list of all $_SERVER variables and values: <?php echo "<table border='1'>"; foreach($_SERVER as $key => $value) { echo "<tr><td style='width:100px;'>" .$key ."</td>"; echo "<td style='width:600px;'>".$value."</td></tr>"; } echo...

Comments Read more

Array initialization

There are lot of different ways how to initialize array in php. Which one is the best? which is the slowest? Here are some test results: <?php //average result: 0.0044 seconds. for ($i=0;$i<1001;$i++) { $a=array("1","2","3","4","5","6","7"); } //average result: 0.0021 seconds for ($i=0;$i<1001;$i++) { ...

Comments Read more

Update select element using AJAX

To do this you will need http://webcodingeasy.com/jquery.js library. So for example in one select element we have two parents, each of them has their own children. We want to display children of selected parent in second select element. So here is a code for select elements: <select name='parent' id='parent'...

Comments Read more

Generate random string in specified length

This function generates random string up to 32 characters length. It can be used to generate text for captchas or generate random password, when user wants to reset is. It takes length of string to generate as parameter:  <?php function random_string($length = 0) { $random = md5(uniqid(rand(), true)); if ($length >...

Comments Read more

Updating countdown every second using javascript

Here is a code example how to update countdown on your website every second. You only need to setup start time. <p> <span id='years'></span><span id='y'> years </span> <span id='months'></span><span id='m'> months </span> <span id='days'></span><span id='d'> days...

Comments Read more

Get book title based on ISBN

Here is a function to get book title and author based on book's ISBN number. To use this function you will have to register here: http://isbndb.com to get your API key. After that you can use this function to ge xml data about the book: <?php //fucntion to get book title and author based on ISBN number function...

Comments Read more

Dynamic sub-domains

Browsers usually have limit on how many files they can download from one domain simultaneously, so in theory, if you files would be on different domains or sub-domains, they will be downloaded simultaneously, thus loading your page faster. Of course you don't want to create different sub-domains for different files and you don't have...

Comments Read more

Session security - fixation and hijacking

There are couple things you need to keep in mind, when dealing with sessions. Of course you can store session data in database with your own identifiers and prevent it from being hijacked. But if you choose to use $_SESSION variables, then first thing to keep in mind, that all sessions are saved in files in plain text, so it is possible to view...

Comments Read more

Drag and drop sortable list using Mootools

To create a sortable list you will need http://webcodingeasy.com/js/mootools.js javascript library in your <head> tags. Then you can use this simple list (attribute alt is the identifier) <ul id='list'> <li alt='1'>item1</li> <li alt='2'>item2</li> <li alt='3'>item3</li> <li...

Comments Read more

Mirrored text

Function that not only reverses string, but reverses each line of string, so it looks exactly like in mirror. Check here for example: http://mirrored-text.co.cc/ function rorrim() { reversed = document.getElementById('text').value; revertext = reversed.split(""); revertext = revertext.reverse(); reversed =...

Comments Read more

Get your unread GMail emails

It is not actually API, it's just retrieving atom feed of your unread emails. You can then modify this function to parse feed to match your needs: <?php //fucntion to get unread emails taking username and password as parametes function check_email($username, $password) { //url to connect to $url =...

Comments Read more

Create thumbnails for image files

This function creates thumbnails for images. It takes image path with file name, thumbnail width, thumbnail height and path where to save thumbnail as parameters. <?php function thumb($path, $width = 120, $height = 100, $dest = "./thumbs") { //getting image sizes $img_sizes = getimagesize($path); //sizes for calculation ...

Comments Read more

Resizing image files

This PHP function is to resize image in proportion between old size and new specified size without loosing much of image quality.  It determines if image is landscape oriented, portrait or square and resizes image accordingly. Function takes path to image, new width and new height as parameters. <?php function...

Comments Read more

Check if keyword has any result using Google AJAX API

This is function to check if there are any google search results on the given keyword. You only need to modify it to insert your google API key. <?php function check_result($keyword) { //your google API key $key = ""; $url = "http://ajax.googleapis.com/ajax/services/search/". "web?v=1.0&q=".$keyword. ...

Comments Read more

Image file print function

In PHP you can automatically get width and height of image file, so you don't have to write it manually. You can use this function to output your image in HTML code: <?php function print_image($imagepath) { $img_sizes = getimagesize($imagepath); $width = $img_sizes[0]; $height = $img_sizes[1]; echo "<img...

Comments Read more

Split unicode string into array of letters

This function allows you to split strings with unicode characters into array with single letters as elements. <?php header('Content-Type:text/html; charset=UTF-8'); function uni_strsplit($string, $split_length=1) { preg_match_all('`.`u', $string, $arr); $arr = array_chunk($arr[0], $split_length); $arr =...

Comments Read more

How to embed flash objects

The best way to embed flash object is using SWFObject javascript library. It automatically checks if visitor has flash player, what version, displays corresponding message, and you don't have to worry about those things. To use SWFObject, you need to include javascript library in your <head> tags, then create div, which will...

Comments Read more

PHP handling file uploads

Here is a function to handle file upload, by checking it to bad and forbidden characters and renaming it if file already exists on server: <?php function handle($arr, $dest) { //list of forbidden characters $clist = array("!", "@", "#", "$", "%", "^", "&", "*", "{", "}", "|", "'", ...

Comments Read more



1 2 3 4 5 6 7 8 9 10 11