Archive for the ‘linux’ Category

Generating a Google Sitemap via PHP

Monday, June 15th, 2009

A sitemap is  an XML file,that lists the URLs of a site.  The sitemap file can be used to inform search engines like google on the pages available on a site and when those pages have been modified.  The search engines require a particular format for the sitemap xml file. Let me give a brief on sitemap creation for google.

Create an xml file(say sitemap.xml). Its better to create the xml file dynamically using the scripting language like php, jsp etc.

Format of sitemap xml  accepted by google:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
<url>
<loc>http://domain.tld/</loc>
<lastmod>2008-01-01</lastmod>
<changefreq>daily</changefreq>
<priority>0.1</priority>
</url>
</urlset>

The points to be remembered when creating a sitemap are:

1. Sitemap should start with the tag <urlset> and end with </urlset>
2. Each set of xml entry shouild start with <url> and end with </url>
3. <loc></loc> contains the url
4. The <lastmod> tag expects a date in the  format YYYY-MM-DD,  or the date format can be in w3c format.
5. The <changefreq> tag expects one of the  values: always, hourly, daily, weekly, monthly etc.
6. The <priority> can be a value between 1.0 and 10

7. Replace special charecters from xml file.
Character                   Replacement
Ampersand     &         &amp;
Single Quote    ‘         &apos;
Double Quote  “         &quot;
Greater Than   >        &gt;
Less Than       <        &lt;

8. Encoding should be UTF-8 mode
9. The maximum permitted size of a sitemap file is 10 MB.

Sample PHP  code for sitemap generation:

$xml = '';
$xml =  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"."\n";
$xml .= "<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"."\n";
for($i=0;$i<$subLimit;$i++){
$title = str_replace("&","&amp;",strip_tags($response['title']));
$loc = str_replace("&","&amp;",strip_tags($response['location']));
$com = str_replace("&","&amp;",strip_tags($response['company']));
//$loc1 = $row['job_jobs_location'];
$title = htmlentities($title, ENT_QUOTES, "UTF-8");
$com = htmlentities($com, ENT_QUOTES, "UTF-8");
$loc = htmlentities($loc, ENT_QUOTES, "UTF-8");
$date = $response['date'];
$date = strtotime($date);
$date = date(DATE_W3C, $date);   //Date in w3c format
$xml .= "<url>"."\n";
$xml .= "<loc>http://www.jobtreks.com/jobresult/$title/$com/$loc/$id</loc>"."\n";
$xml .= "<lastmod>$date</lastmod>"."\n";
$xml .= "<priority>0.50</priority>"."\n";
$xml .= "<changefreq>weekly</changefreq>"."\n";
$xml .= "</url>"."\n";}
$xml .= "</urlset>";
$fh = fopen('sitemap.xml', 'w'); //After exceuting this file, an xml file called sitemap.xml is created.
  • Share/Save/Bookmark

Getting Openfire Groups to work with Zimbra OpenLDAP Authentication

Friday, April 10th, 2009

Its quite easy to get openfire and spark messenger to authenticate with Zimbra’s OpenLDAP by selecting OpenLDAP directory server during initial openfire setup.  One of the biggest drawbacks is that the groups feature will not be available.  Group feature is important for enterprises with large number of users and wnat to provide preset groups in spark like IT, HR, Sales etc. (more…)

  • Share/Save/Bookmark

Authenticating your web applications with LDAP and .htaccess

Saturday, January 3rd, 2009

Here is a trick to have your web applications that run on apache servers to authenticate using a LDAP server.   Note, your apache server should support .htaccess.  This is useful when you want to restrict certain applications to authorised users in a network. (more…)

  • Share/Save/Bookmark

Adobe AIR 1.5 available for Ubuntu, Fedora, and openSUSE

Sunday, December 21st, 2008

Adobe has released AIR 1.5 for Linux. You need to install Flash player (10.0.15.3) to be able to use badge install feature of AIR.  This will enable multi platform development of desktop based applications which will run on most popular desktop operating systems Linux, Max, and Windows. Go get a copy today here.

  • Share/Save/Bookmark

Introduction to Gumbo (Flex 4)

Sunday, December 21st, 2008

Gumbo is the upcoming version of opensource adobe flex 4 which is in development.  Here are a series of tube videos that introduces gumbo.  These videos are made by Northern Kentucky University.  Also here is a Flex 4 SDK presentation by Matt Chotin, Product Development Manager at Adobe. (more…)

  • Share/Save/Bookmark