Export RSS 1.0 or 2.0 feeds to an array
[Copy to clipboard][-]View CodePHP< ?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. […]
Send Email from your GMAIL account using java
[Copy to clipboard][-]View CodeJAVApackage com.util.mail;
import java.security.Security;
import java.util.Date;
import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import org.apache.log4j.Logger;
public static final void sendMail(String to, String title, String content) {
try {
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
final String SSL_FACTORY […]
Edit this page form and left when prompted to do (jQuery)
[Copy to clipboard][-]View CodeJAVASCRIPT$.fn.enable_changed_form_confirm = function () {
var _f = this;
$(’:text, :password, textarea’, this).each(function() {
$(this).attr(’_value’, $(this).val());
});
$(’:checkbox, :radio’, this).each(function() {
var _v = this.checked ? ‘on’ : ‘off’;
$(this).attr(’_value’, _v);
});
$(’select’, this).each(function() {
$(this).attr(’_value’, this.options[this.selectedIndex].value);
});
$(this).submit(function() {
window.onbeforeunload = null;
});
window.onbeforeunload = function(_f) {
if(is_form_changed(_f)) {
return "You will lose any unsaved content.";
}
}
}
function is_form_changed(f) {
var changed = false;
$(’:text, :password, textarea’, f).each(function() {
var _v = $(this).attr(’_value’);
if(typeof(_v) […]
mysql backup
usage
#mysqldump [options] db_name [tables]
#mysqldump [options] –databases db_name1 [db_name2 db_name3…]
#mysqldump [options] –all-databases
Example
#mysqldump -u root -p mydatabase > db.sql
Specific table
#mysqldump -u root -p mydatabase -tables customer > db.sql
How to restore database
#mysql -u root -p database < db.sql
If want to restore to specific database
mysql -u root -pMyPassword MyDatabase < db.sql
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
[Copy to clipboard][-]View CodePHP< ?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
[Copy to clipboard][-]View CodePHP< ?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 […]
