20 Dec 2015

Laravel Tutorials

Laravel Tutorials: Installation Way : -

1. http://tutsnare.com/how-to-install-laravel-on-windows-xampp/           (Best)
2. http://jafty.com/blog/tag/moving-laravel-from-localhost-to-live-server/
3. http://strauss.io/blog/2015-deploy-laravel-on-shared-hosting.html

17 Dec 2015

Php Script to download files

Smart Php Script to download files -
             http://www.zubrag.com/scripts/download.php

8 Dec 2015

Image Resize & Crop Image Code

https://gist.github.com/netconstructor/2395159

function image_resize_crop ( $src, $w, $h, $dest = null, $override = false, $createNewIfExists = false ) {
     $ext = array_pop ( explode ('.', $src) );
     $filenameSrc = str_replace (".$ext", '', basename($src) );
     $filename = "{$filenameSrc}-{$w}X{$h}";
     $arrayUploadPath = wp_upload_dir();
     $fileUploadSubDir = str_replace(basename($src),'', str_replace($arrayUploadPath['baseurl'], '', $src));
     $fileUploadDir = $arrayUploadPath['basedir'] . $fileUploadSubDir;
   
     if(is_null($dest)) $dest = $fileUploadDir;
   
     $i = null;
     if( ! $override && $createNewIfExists ) {
      $i = 0;
      while ( file_exists("$dest$filename-$i.png") ) $i++;
      $i = '-' . $i;
     }
   
     $fileFullPath = "$dest$filename$i.png";
     $fileFullUrl = $arrayUploadPath['baseurl'] . $fileUploadSubDir . $filename.$i .'.png';
   
     //return cached file if $override == false and file's already there
     if( ! $override && file_exists($fileFullPath) ) return $fileFullUrl;
   
     if( $override ) @unlink($fileFullPath);
   
     switch ($ext) {
      case 'jpg':
      case 'jpeg' : $image = imagecreatefromjpeg($src); break;
      case 'gif' : $image = imagecreatefromgif($src); break;
      case 'png' : $image = imagecreatefrompng($src); break;
      case 'wbmp' :
      case 'bmp': $image = imagecreatefromwbmp($src); break;
      default: $image = imagecreatefromgd2($src);
     }
   
     $width = imagesx($image);
     $height = imagesy($image);
   
     $original_aspect = $width / $height;
     $thumb_aspect = $w / $h;
   
     if ( $original_aspect >= $thumb_aspect ) {
      if( $width > $w ) {
       $new_height = $h;
       $new_width = $width / ($height / $h);
      }else{
       $new_height = $height;
       $new_width = $width;
      }
     
     } else {
        if ( $width > $w ) {
         $new_width = $w;
         $new_height = $height / ($width / $w);
        } else {
         $new_width = $width;
         $new_height = $height;
        }
     }
   
     $thumb = imagecreatetruecolor($w, $h);
     $bg = imagecolorallocate($thumb, 255, 255, 255);
     imagefill($thumb, 0, 0, $bg);
   
     imagecopyresampled($thumb,
            $image,
            0 - ($new_width - $w) / 2,
            0 - ($new_height - $h) / 2,
            0, 0,
            $new_width, $new_height,
            $width, $height);
   
     imagepng($thumb, $fileFullPath, 9);
     imagedestroy($image);
   
     return $fileFullUrl;
    }

6 Dec 2015

PHP OOPS Based Concept-

PHP OOPS Based Concept-
http://www.ibm.com/developerworks/library/os-php-7oohabits/