PHP

Export RSS 1.0 or 2.0 feeds to an array

?View Code PHP< ?php
/* exportrss.php
* Copyright 2007 Alec Hussey <alec.hussey@gmail.com>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* [...]


Using sockets in PHP : Get articles from Usenet

http://www.phpbuilder.net/columns/armel20010427.php3
PHP can open sockets on remote or local hosts. Here is a hands-on example of using such a socket: getting connected to a Usenet News Server, talking to this server, and downloading some articles for a precise newsgroup.
Opening a socket in PHP
Sockets are opened using fsockopen(). This function is both available in PHP3 and PHP4. [...]


Simple PHP Cache Manager Class

This class can be used to cache arbitrary data in files.
It can check if the cache with a certain key already exists. If it exists and it is not expired, it can return the cached data. Otherwise it can store newly generated data in a cache file with the given key.
The class can be configured [...]


PHP functions to Apache handle.htpasswd file

?View Code PHP< ?php
/*
 
Author : Mitko Kostov
Weblog : http://mkostov.wordpress.com
Mail :mitko.kostov@gmail.com
Date : 12/21/2007
Used : PHP and Smarty
 
*/
// function to register user
function regUser() {
$filename = ‘members/password/.htpasswd’;
$data = $_POST[’username’].":".htpasswd($_POST[’password’])."\n";
[...]


PHP Cookie Handler Class

This class allows for the handling of normal and serialized cookies as well as switching between these types of cookies.
Cookie Functions:
Write Cookies
Read Cookies
Delete Cookies
Use of this class is fairly simple.
Step 1: Include the class source in your php project using the require or include statement.
Step 2: Instance the cookie class by using the new keyword. [...]


PHP generate new an resizing image

?View Code PHP< ?PHP
class HanroadClass
{
/************************
generate new an Resizing image by the PHP GD library
Support picture format: jpg, gif, png
$source_img: Source image path
$target_dir: Target image path
$target_name: Target image name
$new_width: Target image width
$new_height: [...]


package transforming all php errors into catchable exceptions

This package can be used to turn PHP run-time errors into catchable exceptions.
It sets the PHP error handler function to point to a class function that will throw exceptions when an error occurs.
The class throws exceptions of different classes according to the type of PHP error that occurred.
All exception classes are derived from a common [...]


A calendar code

This class can be used to display month calendars in HTML tables.
It takes a given month and year and generates an HTML table with the days of that month. The calendar start week day may be set to Sunday or Monday.
Special event days may exhibit the title of the event in the respective calendar table [...]


PHP read Excel

?View Code PHP 
< ?php
/**
* <?php
* require "excel_class.php";
* Read_Excel_File("Book1.xls",$return);
* for ($i=0;$i<count($return[Sheet1]);$i++)
* {
* for ($j=0;$j<count($return[Sheet1][$i]);$j++)
* {
* echo $return[Sheet1][$i][$j]."|";
* }
* echo "<br>";
* }
* ?>
* < ?
* require "excel_class.php";
* Read_Excel_File("Book1.xls",$return);
* Create_Excel_File("ddd.xls",$return[Sheet1]);
* ?>
*/
define(’ABC_CRITICAL’, 0);
define(’ABC_ERROR’, [...]


I use frequently some PHP function

Before makes php the project development, uses frequently some functions, reorganize now, shares together with everybody

?View Code PHP< ?php
class function_class{
/**
* Get IP
*
* @return IP
*/
function GetIP() {
if ($_SERVER["HTTP_X_FORWARDED_FOR"]){
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
else if ($_SERVER["HTTP_CLIENT_IP"]){
$ip = $_SERVER["HTTP_CLIENT_IP"];
}
else if ($_SERVER["REMOTE_ADDR"]){
$ip = $_SERVER["REMOTE_ADDR"];
}
else if (getenv("HTTP_X_FORWARDED_FOR")){
$ip = getenv("HTTP_X_FORWARDED_FOR");
}
else if (getenv("HTTP_CLIENT_IP")){
$ip = getenv("HTTP_CLIENT_IP");
}
else if (getenv("REMOTE_ADDR")){
$ip = getenv("REMOTE_ADDR");
}
else{
$ip = "Unknown";
}
return [...]