Php Curl

If you want to write a sort of php wrapper to include the results of another http(s) request maybe pointing to a totally different site or just different code (mod_perl with HTML::Mason, in my case) into a php based layout, and just pass-thru all GET and POST variables to the sub-request, the following snippet can be used. Note there is no error handling, so this is subject to the underlying application.

<?php
$ch = curl_init($sub_req_url);
$encoded = '';
// include GET as well as POST variables; your needs may vary.
foreach($_GET as $name => $value) {
  $encoded .= urlencode($name).'='.urlencode($value).'&';
}
foreach($_POST as $name => $value) {
  $encoded .= urlencode($name).'='.urlencode($value).'&';
}
// chop off last ampersand
$encoded = substr($encoded, 0, strlen($encoded)-1);
curl_setopt($ch, CURLOPT_POSTFIELDS,  $encoded);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_exec($ch);
curl_close($ch);
?>
Posted in Code Examples, PHP | Leave a comment

Understanding Organic SEO

Don’t go foolin’ yourself. Organic SEO is just as much work as any other type of SEO. It’s just a little different method of creating a site optimized for search ranking, without having to implement any new technologies or spend a lot of time submitting your site to different primary and secondary search engines. And really, the distinction here is a very general one. Only SEO purists
consider “real SEO” as being strictly organic — meaning you use no fee-based services whatever.

Most people are happy with “just plain SEO,” which usually means a combination of organic and fee-based. It’s best if you just think of SEO as just SEO; then you don’t have to worry about distinctions that aren’t really important in optimizing your web site. The definitions of organic SEO vary a little, depending on whom you talk to. Some SEO experts think it’s all about optimizing the content of your web site to catch the attention of the crawlers and spiders that index sites. Others think it’s the number of quality links you can generate on your site. But in
truth, organic SEO is a combination of those and other elements, such as site tagging, that will naturally place your web site in search engine rankings. How high in those rankings depends on how well
you design your site.

But before you go thinking that organic SEO is just the solution you’ve been looking for, take a step back. What organic SEO is not is an easy way to land in a search engine. Basically, if you put a web site online and spend a little time getting it ready for the world to see, you will have probably achieved some measure of organic SEO without really trying.

Credits:
Search Engine Optimization Bible & searchengineoptimization.com

Posted in SEO | Tagged , , , | Leave a comment

Difference between two dates in php

Here is an example on how to check to difference bewteen two dates in using PHP.

<?
$now = time();
$week = time()+60*60*24*7;
$diff = $week-$now;
echo $diff/(60*60*24)." days
"; // 7 Days
echo $diff/(60*60)." hours
"; // 168 hours
echo $diff/(60)." minutes
"; // 10080 minutes
?>
Posted in Code Examples, PHP | Leave a comment