Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts
Wednesday, July 10, 2013
Monday, July 9, 2012
Facebook PHP SDK logout : resolved
Facebook sdk is creating one cookie in browser.
Which has to be cleared on logout.
Here is my Codeigniter code to do that.
Logout URL
$this->facebook->getLogoutUrl(array('next' => site_url('user/logout'));
Logout Function
public function logout() {
setcookie('PHPSESSID', '', time()-3600, "/");
$this->session->sess_destroy();
redirect('/user', 'refresh');
}
Which has to be cleared on logout.
Here is my Codeigniter code to do that.
Logout URL
$this->facebook->getLogoutUrl(array('next' => site_url('user/logout'));
Logout Function
public function logout() {
setcookie('PHPSESSID', '', time()-3600, "/");
$this->session->sess_destroy();
redirect('/user', 'refresh');
}
Thursday, May 24, 2012
Friday, May 11, 2012
Decide Drupal or PHP ?
Both technology, has it's own potential, in their area. First I will brief about the both technology, and what is their area.
Drupal:
This is one of the strongest tool built for php developer. It comes with it's own code base(file & folders) and database. Not only that there are 15,993 third party modules(Free), 1,374 Themes(UI). So basically, Drupal is built with all the generic features which almost 70% web applications requires. Features like user accounts, roles, permissions, Admin CRUD, Generic report.Pros
- Development becomes very fast, since instead of writing code developer assembles drupal modules.
- Lot of features are already developed, it has a very active community, available for support.
- It is CMS cum Framework, so when require we can write our own custom module also.
Cons
- It has its certain core area (codebase & DB), that is not changeable.
- Even though, one can develop custom modules, but it has to follow drupal standard, which ultimately make a boundary for developer.
When to use drupal
- When we know we are going to build a generic web applications. Where things are straight forward.
- Client requirement are not stiff. Client is ready to accept our suggestions.
- When we need to make process fast.
When not use drupal
- When your requirement may break the drupal core system.
- When client is more cautious about the quality, rather than time or budget
- When you don't have right resource
PHP
PHP, is the Father of Drupal, and Father is always bigger than child :).
What ever we can do with drupal, i.e. also available here, with unlimited freedom.
This is pretty similar to command line of any operating system(like linux) and it's GUI alternative.
Pros
- Here since you start from scratch, you can plan your core DB & code base. From here your freedom starts.
- PHP also has its own very robust, mature community. these people don't write their contribution in a standard module. but they talk and write in some CMS or framework in which they are good. So you get support but nothing like plug n play module.
- As you are free to work in PHP, at the same time if you can google, and find(not guaranteed) something already written, and same(if not exactly then 80% same) as your project would be.
- Resources are easily available.
Cons:
- Compare to drupal, only thing which is lacking here is, some time for small thing. it takes too much time.
When to go with PHP
- When your application is using multiple technology.
- Client requirement contains lot of exclusive things. Like some client want to set a new trend with their application. Some time they want to beat Facebook, twitter and even google also :).
- When Your client use words, like pixel perfect, it should be in professional way or It's a common web standard, etc.
When to not go with PHP
- When Client asks suggestion from you, and you know you can mould in your way.
- In your application, there is nothing like you invent something from zero.
Other References:
Friday, March 23, 2012
Thursday, February 24, 2011
PHP GD Lib image generation from jpg file
<?php
function getCenterX($font_size, $font_file, $text, $img_width) {
$box = imagettfbbox($font_size, 0, $font_file, $text);
$text_width = $box[2] - $box[0];
// Position to align in center
$position_center = ceil(($img_width - $text_width) / 2);
return($position_center);
}
$img_width = 960;
$img_height = 640;
$font_file = 'Kentucky.ttf';
$canvas = imagecreatefromjpeg('coupan_ip4.jpg');
$pre_header = '<b>sare jahan se achcha hindusit';
$main_header = 'Jan gan man';
$main_description = "Main Description";
$sub_description = "Main Description";
$ccode = "Coupon Code : 112345767";
$expire = "Expires: 02/09/2011";
$ccode_server ="Server: select coupon code 18";
$disclaimer = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et ";
// Allocate colors
$pink = imagecolorallocate($canvas, 255, 105, 180);
$white = imagecolorallocate($canvas, 255, 255, 255);
$green = imagecolorallocate($canvas, 37, 102, 70);
$black = imagecolorallocate($canvas, 0, 0, 0);
$red = imagecolorallocate($canvas, 190, 33, 50);
imagettftext ($canvas, 20, 0, getCenterX(20, $font_file, $pre_header, $img_width), 40, $black, $font_file, $pre_header);
imagettftext ($canvas, 40, 0, getCenterX(40, $font_file, $main_header, $img_width), 100, $red, $font_file, $main_header);
imagettftext ($canvas, 18, 0, 10, 140, $green, $font_file, $main_description);
imagettftext ($canvas, 13, 0, 10, 180, $black, $font_file, $sub_description);
imagettftext ($canvas, 16, 0, 10, 200, $black, $font_file, $ccode);
imagettftext ($canvas, 13, 0, 10, 220, $black, $font_file, $expire);
imagettftext ($canvas, 13, 0, 10, 240, $black, $font_file, $ccode_server);
imagettftext ($canvas, 13, 0, 10, ($img_height-50), $black, $font_file, $disclaimer);
//echo $font_width = ImageFontWidthByFilename($font_file);
// Output and free from memory
header('Content-Type: image/jpg');
imagejpeg($canvas);
imagedestroy($canvas);
?>
function getCenterX($font_size, $font_file, $text, $img_width) {
$box = imagettfbbox($font_size, 0, $font_file, $text);
$text_width = $box[2] - $box[0];
// Position to align in center
$position_center = ceil(($img_width - $text_width) / 2);
return($position_center);
}
$img_width = 960;
$img_height = 640;
$font_file = 'Kentucky.ttf';
$canvas = imagecreatefromjpeg('coupan_ip4.jpg');
$pre_header = '<b>sare jahan se achcha hindusit';
$main_header = 'Jan gan man';
$main_description = "Main Description";
$sub_description = "Main Description";
$ccode = "Coupon Code : 112345767";
$expire = "Expires: 02/09/2011";
$ccode_server ="Server: select coupon code 18";
$disclaimer = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et ";
// Allocate colors
$pink = imagecolorallocate($canvas, 255, 105, 180);
$white = imagecolorallocate($canvas, 255, 255, 255);
$green = imagecolorallocate($canvas, 37, 102, 70);
$black = imagecolorallocate($canvas, 0, 0, 0);
$red = imagecolorallocate($canvas, 190, 33, 50);
imagettftext ($canvas, 20, 0, getCenterX(20, $font_file, $pre_header, $img_width), 40, $black, $font_file, $pre_header);
imagettftext ($canvas, 40, 0, getCenterX(40, $font_file, $main_header, $img_width), 100, $red, $font_file, $main_header);
imagettftext ($canvas, 18, 0, 10, 140, $green, $font_file, $main_description);
imagettftext ($canvas, 13, 0, 10, 180, $black, $font_file, $sub_description);
imagettftext ($canvas, 16, 0, 10, 200, $black, $font_file, $ccode);
imagettftext ($canvas, 13, 0, 10, 220, $black, $font_file, $expire);
imagettftext ($canvas, 13, 0, 10, 240, $black, $font_file, $ccode_server);
imagettftext ($canvas, 13, 0, 10, ($img_height-50), $black, $font_file, $disclaimer);
//echo $font_width = ImageFontWidthByFilename($font_file);
// Output and free from memory
header('Content-Type: image/jpg');
imagejpeg($canvas);
imagedestroy($canvas);
?>
Subscribe to:
Posts (Atom)