function convert_to_india_time($date){
$month = date("n", strtotime($date));
$day = date("j", strtotime($date));
//DST from March 10th to November 3 for USA
if ($month > 3 && $month < 11){
return date("F d, Y h:i A", strtotime("+10 hours 30 minutes", strtotime($date)));
}
else if ($month == 3 && $day >= 10){
return date("F d, Y h:i A", strtotime("+10 hours 30 minutes", strtotime($date)));
}
else if ($month == 11 && $day <= 3){
return date("F d, Y h:i A", strtotime("+10 hours 30 minutes", strtotime($date)));
}
else{ // non-DST time
return date("F d, Y h:i A", strtotime("+11 hours 30 minutes", strtotime($date)));
}
}
function convert_to_india_time_short($date){
$month = date("n", strtotime($date));
$day = date("j", strtotime($date));
//DST from March 10th to November 3 for USA
if ($month > 3 && $month < 11){
return date("d/m/Y", strtotime("+10 hours 30 minutes", strtotime($date)));
}
else if ($month == 3 && $day >= 10){
return date("d/m/Y", strtotime("+10 hours 30 minutes", strtotime($date)));
}
else if ($month == 11 && $day <= 3){
return date("d/m/Y", strtotime("+10 hours 30 minutes", strtotime($date)));
}
else{ // non-DST time
return date("d/m/Y", strtotime("+11 hours 30 minutes", strtotime($date)));
}
}
function cleanup_for_url( $string ){
$string = str_replace(" - ", "_", $string);
$string = str_replace("-", "_", $string);
$string = str_replace(" ", "_", $string);
$string = str_replace("'", "", $string);
$string = str_replace(",", "", $string);
$string = str_replace("?", "", $string);
$string = str_replace("!", "", $string);
$string = str_replace("%", "", $string);
$string = str_replace("__", "_", $string);
return $string;
}
//Use this to prevent SQL Injection
function sql_quote( $value ){
if( get_magic_quotes_gpc() )
{
$value = stripslashes( $value );
}
//check if this function exists
if( function_exists( "mysql_real_escape_string" ) )
{
$value = mysql_real_escape_string( $value );
}
//for PHP version < 4.3.0 use addslashes
else
{
$value = addslashes( $value );
}
return $value;
}
function display_pagenation($total_pages, $current_page, $file_name){
$display_count = 12;
$display_count_before = 5;
$display_count_after = 1 + $display_count - $display_count_before;
global $category_id;
if ($total_pages > $display_count){
$start = ($current_page - $display_count_before);
if ($start < 0) $start = 0;
$end = ($current_page + $display_count_after);
if ($end > $total_pages) $end = $total_pages;
}
else{
$start = 0;
$end = $total_pages;
}
if ($current_page > 0){
echo " << previous";
}
for($i = $start; $i < $end; $i++){
if ($i == $current_page){
if ($i == $start){
echo " " . ($i + 1);
}
else{
echo " | " . ($i + 1);
}
}
else{
echo " | " . ($i + 1) . "";
}
}
if ($current_page < $total_pages - 1){
echo " | next >>";
}
}
function display_pagenation_querystring($total_pages, $current_page, $file_name){
$display_count = 12;
$display_count_before = 5;
$display_count_after = 1 + $display_count - $display_count_before;
global $category_id;
if ($total_pages > $display_count){
$start = ($current_page - $display_count_before);
if ($start < 0) $start = 0;
$end = ($current_page + $display_count_after);
if ($end > $total_pages) $end = $total_pages;
}
else{
$start = 0;
$end = $total_pages;
}
if ($current_page > 0){
echo " << previous";
}
for($i = $start; $i < $end; $i++){
if ($i == $current_page){
if ($i == $start){
echo " " . ($i + 1);
}
else{
echo " | " . ($i + 1);
}
}
else{
echo " | " . ($i + 1) . "";
}
}
if ($current_page < $total_pages - 1){
echo " | next >>";
}
}
function only_numbers_and_comma($val){
$reg = "#[^0-9 -]#i";
$count = preg_match($reg, $val, $matches);
if ($count > 0){
return false;
}
else{
return true;
}
}
//strip all chars from source other than those mentioned in $allow.
//eg: cleanup_allow("12,13,14a", "0123456789,") => "12,13,14"
function cleanup_allow($value, $allow){
$output = $value;
for($i = 0; $i < strlen($value); $i++){
$temp = substr($value, $i, 1);
$allowed = false;
for ($j = 0; $j < strlen($allow); $j++){
$temp_allow = substr($allow, $j, 1);
if ($temp == $temp_allow){
$allowed = true;
break;
}
}
if ($allowed == false){
$output = str_replace($temp, "", $output);
}
}
return $output;
}
//find_invalid_chars returns true if invalid chars are found.
function find_invalid_chars($value, $invalid){
for($i = 0; $i < strlen($invalid); $i++){
$invalid_char = substr($invalid, $i, 1);
if (strpos($value, $invalid_char) === false){
continue;
}
else{
return true;
}
}
return false;
}
?>
|