1 0 Archive | PHP RSS feed for this section
post icon

Uploading image using class.upload.php

Uploading Image using “class.upload.php” for various image size’s.

 

if ($handle->uploaded) {
$handle->file_new_name_body   = $name;
$handle->image_resize         = true;
$handle->image_x              = 170;
$handle->image_ratio_y        = true;
$handle->process($savepath);

$handle->image_watermark       = ‘nbs-logo.png’;
$handle->image_watermark_position = ‘R’;

//medium image size
$savepath = “ians/Photo/”.$date.”/med/”;
$handle->file_new_name_body   = $name;
$handle->image_resize         = true;
$handle->image_x              = 800;
$handle->image_ratio_y        = true;
$handle->process($savepath);

//original image size
$savepath = “ians/Photo/”.$date.”/ori/”;
$handle->file_new_name_body   = $name;
$handle->image_resize         = false;
$handle->process($savepath);

}

Leave a Comment
February 14, 2013
post icon

Setting Timezone for India in PHP

if you need to setup Time Zone for India, do includes these lines at the begining of

date_default_timezone_set(‘Asia/Calcutta’);
$date = date(‘Y-m-d’);

Leave a Comment
September 4, 2012
post icon

Adding Local Time Zone

If need to set time adjusted as per the localtime of hosting domain country

date_default_timezone_set(‘Asia/Calcutta’);

date_default_timezone_set(‘America/Chicago ‘);

Leave a Comment
August 30, 2012
post icon

Auto Refresh PHP page

<?php
$sec = 10;
$page = $_SERVER[‘PHP_SELF’];

header(“Refresh: $sec; url=$page”);
?>

 

Page will refresh every 10 sec.

Leave a Comment
August 27, 2012
post icon

Get first image from wordpress post

function catch_that_image() {
global $post, $posts;
$first_img = ”;
ob_start();
ob_end_clean();
if(preg_match_all(‘//i’, $post->post_content, $matches)){
$first_img = $matches [1] [0];
return $first_img;
}
else {
$first_img = “/images/default.jpg”;
return $first_img;
}
}

Leave a Comment
June 11, 2012
post icon

Stop access to speific folder

If you want to stop accessing user outside the specific IP address,

you can add these lines to .htaccess file

 

Deny from all
Aloow from xxx.xxx.xxx.xxx

where xxx is you IP address.

How to find IP address

Leave a Comment
post icon

php difference between two dates

<?php
$startDate =”1-1-2011″;
$endDate = “2-2-2011”;
$days = (strtotime($endDate) – strtotime($startDate)) / (60 * 60 * 24);
print $days;
?>

Leave a Comment
post icon

Adding unique name for uploaded files

$a = uniqid();

$a = “free-news-agency-“.$a;
$filename = $_FILES[image_field][name];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$name = $a.”.”.$ext;

this is for using upload.class.php from http://www.verot.net/php_class_upload.htm

Leave a Comment
December 30, 2011
post icon

Screen resolution using java script and using it in php

use this code to set screen resolution into a cookie

< script language=”javascript”>
<!–
writeCookie();
function writeCookie()
{
var today = new Date();
var the_date = new Date(“December 31, 2023”);
var the_cookie_date = the_date.toGMTString();

var the_cookie = “users_resolutionx=”+ screen.width ;
var the_cookie = the_cookie + “;expires=” + the_cookie_date;
document.cookie=the_cookie

var the_cookie = “users_resolutiony=”+ screen.height ;
var the_cookie = the_cookie + “;expires=” + the_cookie_date;
document.cookie=the_cookie

}
//–>
</script>

 

use this code to access screen size

 

<? php

$x = $_COOKIE[users_resolutionx];
$y = $_COOKIE[users_resolutiony];
?>

Leave a Comment
post icon

Round Corner box with CSS “Border-radius”

Have you(programmer) ever need a round corner box around some text. What you do

ask designer to make a round corner image and use it as a <DIV> backround, right?

Now with CSS3, IE9, FF7+, you can use CSS to define a “round corner box” using only CSS.

//css

<style>
.round{
border-radius: 25px;
background-color:#CCC;
width:300px;
height:300px;
padding-top:5px;
padding-left:5px;
}
</style>

 

//HTML/PHP

<div class=”round”>This is round corner box</div>

 

//output

CSS Round Corner Box using DIV

 

Leave a Comment