We can use wristwatch class to apply the loading time and you can download it from here 1kb (including an example of use) .
Counting Loading-Time
If we look at the top-right corner of google search result page, we see how fast is the search time (loading time). Maybe we want todo so to our web visitors to perform how fast is they access our web page.
Stored Procedure Class For MySQL
Stored Procedure is a set of some sql statements which are stored in database server and can be executed anytime we call them.
As MySQL older than version 5 doesn't support the stored procedure functionatlity, then we have to use ST_Proc class. It can be downloaded from phpclasses.org or from here (3 kb including an example).
In this package there should be 2 main files, namely, sqlLayer.php and STProc.php.
For practicing you should prepare a database named test with a table named test as well (just for dummy). Then create 2 fields, id int (11) and text varchar (20). Insert some dummy data on the table.
Then create stored procedure and save it (just like in the example default.sp in the package), and create a file to call and execute it (sp.php in the example file). Execute this file to see the results.
Creating and Extracting ZIP on-the-fly
If you want to create or extract zip files on-the-fly you can use pclzip class. The class can be downloaded from phpclass.org or you can download here (including an example script 33kb!!). You can change the source or destination folder.
Thumbnail and Watermark On-The-Fly
Sometimes we may want to create thumbnails and/or watermark on-the-fly for images on our web sites instead of creating offline by using some tools or image editors. We want to generate it automatically from our php scripts. Thus, we can use thumbnail class made by Emilio Rodriguez and we can download it from phpclass.org or from here (including an example file 7kb).
/**
*This is a class that can process an image on the fly by either generate a thumbnail, apply an watermark to the image, or resize it.
*
* The processed image can either be displayed in a page, saved to a file, or returned to a variable.
* It requires the PHP with support for GD library extension in either version 1 or 2. If the GD library version 2 is available it the class can manipulate the images in true color, thus providing better quality of the results of resized images.
* Features description:
* - Thumbnail: normal thumbnail generation
* - Watermark: Text or image in PNG format. Suport multiples positions.
* - Auto-fitting: adjust the dimensions so that the resized image aspect is not distorted
* - Scaling: enlarge and shrink the image
* - Format: both JPEG and PNG are supported, but the watermark image can only be in PNG format as it needs to be transparent
* - Autodetect the GD library version supported by PHP
* - Calculate quality factor for a specific file size in JPEG format.
* - Suport bicubic resample algorithm
* - Tested: PHP 4 valid
*
* @package Thumbnail and Watermark Class
* @author Emilio Rodriguez
* @version 1.48 <2005/07/18>
* @copyright GNU General Public License (GPL)
**/
Securing Logo/Image
Sometime, you may want to secure a logo (image) on your user-interface to avoid some replacement.
In that case we can encode the image to a text-base code. To do that we need img2php class which can be downloaded from phpclasses.org or you can download it here (12.7kb including samples)
Following are the example of steps after extracting the package:
1. write this script
<?php
require_once("img2php.class.php");
$t = new img2php;
$t->generate("images/"); //place image(s) in a subfolder
?>
2. run the script and the result should be similiar to this:
<?php
/**
* gonximage class : Generated based on directory (images/)
*
* @package
* @author Ben Yacoub Hatem <hatem@php.net>
* @copyright Copyright (c) 2004
* @version $Id$ - 2009-03-11 11:03:42 - gonximage.class.php
* @access public
**/
class gonximage{
/**
* Constructor
* @access protected
*/
function gonximage(){
}
/**
* Return image based on it name
* @access public
* @return void
**/
function getimage($img){
switch($img){
case "orchid_jpg":
gonximage::orchid_jpg();
break;
} // switch
}
function orchid_jpg()
{
header("Content-type: image/jpg");
header("Content-length: 3980");
echo base64_decode(
'/9j/4AAQSkZJRgABAgAAAQABAAD/4QDmRXhpZgAASUkqAAgAAAAFABIBAwAB'.
'AAAAAQAAADEBAgAcAAAASgAAADIBAgAUAAAAZgAAABMCAwABAAAAAQAAAGmH'.
'BAABAAAAegAAAAAAAABBQ0QgU3lzdGVtcyBEaWdpdGFsIEltYWdpbmcAMjAw'.
'OTowMToxMiAyMjoyOTo0MwAFAACQBwAEAAAAMDIyMJCSAgAEAAAANDE4AAKg'.
'BAABAAAAjAAAAAOgBAABAAAAtAAAAAWgBAABAAAAvAAAAAAAAAACAAEAAgAE'.
'AAAAUjk4AAIABwAEAAAAMDEwMAAAAAAAAAAA/8AAEQgAtACMAwEhAAIRAQMR'.
'Af/bAIQAEw0OEQ4MExEPERUUExcdMB8dGhodOyotIzBGPkpJRT5EQ05XcF9O'.
'UmpUQ0RhhGJqc3d9fn1LXYmTiHmScHt9eAEfISEsJixWLy9Wtnlneba2tra2'.
'tra2tra2tra2tra2tra2tra2tra2tra2tra2tra2tra2tra2tra2tra2tra2'.
'/8QAfQAAAwEBAQEAAAAAAA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NF2yi'.
'7mBPEAxUl4yJA9ppSRpEzWW7fqXEtjG4gUsryy3dQWW2zW0wpmAAMCtO9rpV'.
'rgZQJAHjtiskGoG1kMgAiBU7MQohBnkgRUjbd1ltm2m0TnjJHcTXPeWYk0xU'.
'NaKQPAFYBNSYK0UF2/p4Dactv9Pb5ODThcRV22wXnlu1BR6vcz9TLPtU119q'.
'qQeo0ikdqdpRta5e/wCkhI+TgUh4qqKqtdF3wiExVN656FlNwXeE7D+1BSX7'.
'j7/SJxgmexivWrxtXGK5BEc4qQLbuL28RMznihu2SssIAOY8VAmK8BUm96YA'.
'IpIOK0ChOvZtyioZJCzAHFUekFX7o+eaIU1zYDltznuDgVFeGcCY5pgpXYCi'.
'FxhZNqRsZtxxk+KQ2yAjBzkLmnrF9LW5TL3SOcAYmgkXnS4zsBBZifx2pPya'.
'k2TtPtS97EQWJFIZXu1CaOaaaiXRJlh81J1NGGF9yC2QRg5NPF1P6gXnHMCg'.
'prlxVB2ruY9+AtSXAWPME5OaQHvt4oWEZPekPAYnFX2Rt06uYiyrEgfqbAFC'.
'c6OkV7kQKk8eDQqmc1J51igqQ0HWKZUSxWrUlqsRicHBqstssEqqz8UETWw9'.
'gseR4qJ7am0W7gUolz1/igbO4eKgJAN0e1Ux/wALYXtcutu94gCkJHADECh7'.
'VJ5hFBuM80J5uaGpDT7hRVF//9k='.
'');
}
}
?>
3. copy and save the result above (for instance encode.class.php)
4. write a script to show the image (show.php):
<?php
include "encode.class.php";
$img = new gonximage();
$imgfile = "orchid_jpg";
$img->getimage($imgfile);
?>
Financial Class
This class is made by Enrique Garcia to move excel functions into php class. This is very powerful to help develop web based financial system. The functions comprise FV (Future Value), PV (Present Value), PMT (Payment), NPER (Number of Periode), etc.
This class can be downloaded from phpclass.com or here (12kb) including an example file.
Classes for numerical data manipulation
For complicated numerical calculation we can use these classes instead of using php built-in functions in which we still write some long lines of codes. These classes can be downloaded from phpclasses.com or from here (9kb).
Files included in the package are:
class.complex.php
Class for manipulating complex numbers
class.hist.php
Class to generate a histogram from an array of data
pkg.arith.php
A set of simple arithmetic functions
pkg.geom.php
Geometrical functions
pkg.stats.php
Statistical functions for unidimensional data arrays
pkg.trig.php
Trigonometric functions to complement the ones in PHP
utils.inc.php
Utility functions (error handling, etc.) to be used by
other packages or classes in numPHP
Subscribe to:
Posts (Atom)