PHP Code

Simple yet powerfull PHP class to parse RSS.

<?php
/*
 ======================================================================
 lastRSS 0.9.1
 Simple yet powerfull PHP class to parse RSS files.
 by Vojtech Semecky, webmaster @ oslab . net
 Latest version, features, manual and examples:
     http://lastrss.oslab.net/
     http://www.easemarry.com/blog 
———————————————————————-
 LICENSE This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License (GPL)
 as published by the Free Software Foundation; either version 2
 of the [...]


Give Your Visitors a Rough Time

Toby Somerville recently blogged about giving visitors a rough time - instead of displaying exact timestamps, providing a rough written approximation of the time.
Toby suggested that we generally communicate in approximate times, but on the web work with exact timestamps. His idea was that by displaying the time as you would describe it verbally, he [...]


Debugging PHP code using debug_backtrace

Most of the PHP developers debug php code in their local machine just by trial and error using “print_r”,”var_dump” and “echo”. They dont write unit tests or follow any advanced debugger like xdebug. But the problem of using these methods is you cannot fool proof your code and their might be some bugs still present [...]


The relative way transforms the absolute way

Withdraws in Gregarius a function. May turn into the homepage in relative way automatic extension the absolute way.
<?php
function relative_to_absolute($content, $feed_url) {
    preg_match(’/(http|https|ftp):\/\//’, $feed_url, $protocol);
    $server_url = preg_replace(”/(http|https|ftp|news):\/\//”, “”, $feed_url);
    $server_url = preg_replace(”/\/.*/”, “”, $server_url);
    if ($server_url == ”) {
        return $content;
    }
    if (isset($protocol[0])) {
        $new_content = preg_replace(’/href=”\//’, ‘href=”‘.$protocol[0].$server_url.’/’, $content);
        $new_content = preg_replace(’/src=”\//’, ’src=”‘.$protocol[0].$server_url.’/’, $new_content);
    [...]


Uses KSES to filter the data-in safely

The safe first principle is never needs to believe any exterior data in PHP! How effective achieves this is one of each development personnel’s difficult. Before has not used webeditor, this basically quite good processing.
But if has used webeditor, how to guarantee that the user the data, simultaneously achieves safely (for example prevents the XSS [...]


Raises the efficiency in PHP mode through the factory pattern [reprint]

  Conducting large-scale system development time, I always worry whether it should include every possible use of the class library document.
        If it is included in use, the development will bring great trouble. Because I am impossible to know in advance which place will use which kind. Moreover, if each page, in accordance with the [...]


Oracle class - PHP

<?php
class DB_Sql {
 var $Debug = false;
 var $Home = “/u01/app/oracle/ora90″;
 var $Remote = 1;
 /**
  * http://www.easemarry.com/blog
  * This Query will be sent directly after the first connection
  * Example:
  * var $ConnectQuery=”ALTER SESSION SET nls_date_language=german nls_date_format=’DD.MM.RRRR’”;
  * -> Set the date format for this session, this is fine when your ora-role
  * cannot be altered
  */
 var $ConnectQuery=”;
 /**
  [...]


Make Google Sitemap - PHP

 this a simple Making  google Sitemap the php function
<?php
require_once(”opendb.php”);
function makeSitemap($fname){
 $str  = “”;
 $str .= “<?xml version=\”1.0\” encoding=\”UTF-8\”?>\n”;
 $str .= “<urlset xmlns=\”http://www.sitemaps.org/schemas/sitemap/0.9\” xmlns:xsi=\”http://www.w3.org/2001/XMLSchema-instance\” xsi:schemaLocation=\”http://www.google.com/schemas/sitemap/0.84 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\”>\n“;
  $str .= “<url>”;
 $str .= “<loc>http://www.easemarry.com/</loc>”;
 $str .= “<lastmod>”.date(’Y-m-d\TH:m+08:00′).”</lastmod>”;
 $str .= “<changefreq>daily</changefreq>”;
 $str .= “<priority>1.00</priority>”;
 $str .= “</url>\r\n”;
 $str .= “<url>”;
 global $opendb;
 $sql=”SELECT url FROM table”;
 $query =$opendb->get_results($sql);
  if (count($query)>=1){
     foreach ($query as $list){
     $make_time=date(’Y-m-d\TH:m+08:00′);
     $str .= “<url>”;
     $str .= “<loc>”.$list->url.”</loc>”;
     $str .= “<lastmod>$make_time</lastmod>”;
     $str [...]


RSS Class - PHP

This is a generation RSS document PHP class
<?php
if (defined(’_CLASS_RSS_PHP’)) return;
define(’_CLASS_RSS_PHP’,1);
/**
 *  Class name: RSS
 *  $rss = new RSS(”Blog”,”http://www.easemarry.com/”,”EaseMarry’s Blog”);
 *  $rss->AddItem(”RSS Class”,”http://www.easemarry.com”,”description”,date());
 *  $rss->AddItem(…);
 *  $rss->SaveToFile(”../rss/index.xml”);
 */
class RSS {
 var $rss_ver = “2.0″;
 var $channel_title = ”;
 var $channel_link = ”;
 var $channel_description = ”;
 var $language = ‘en-us’;
 var $copyright = ‘easemarr.com’;
 var $webMaster = ‘web@easemarry.com’;
 var $pubDate = ”;
 var $generator = ‘Easemarry.com’;
 var $content = ”;
 var $items [...]