Tuesday, January 1, 2019

Create zebra language code in php

Zebra Programming Language (ZPL) is a page description language from Zebra Technologies, which is used for label printing. It is a command based language used by the printer as instructions for creating the images printed on the labels. Zebra language commands always start with a caret sign (^) Currently, many command exits for new version of ZPL II. In this language each format has to start with the command `^XA` and end with `^XZ` which is ANSI BASIC oriented.
So when you are working with printing application in PHP or some label printing than must use ZPL code to send to zebra printer. For FedEx, USPS, DHL and other other courier services use ZPL language for own label printing software. So when you want to work with label printing for eCommerce use than must need ZPL code for the printer.
Here you can write direct text to ZPL using start with `^XA` & end with `^XZ`. Here below example to create ZPL language from image.
For that create `Image.php` file as below

class Image
{
    protected $width;
    protected $height;
    public function __construct($image)
    {
        if (!$this->isGdResource($image)) {
            throw new InvalidArgumentException('Invalid resource');
        }
        if (!imageistruecolor($image)) {
            imagepalettetotruecolor($image);
        }
        imagefilter($image, IMG_FILTER_GRAYSCALE);
        $this->image = $image;
        $this->width = imagesx($this->image);
        $this->height = imagesy($this->image);
    }
    public function __destruct()
    {
        imagedestroy($this->image);
    }
    public function isGdResource($image)
    {
        if (is_resource($image)) {
            return get_resource_type($image) === 'gd';
        }
        return false;
    }
    public function width()
    {
        return (int)ceil($this->width / 8);
    }
    public function height()
    {
        return $this->height;
    }
    public function toAscii()
    {
        return $this->encoded ?: $this->encoded = $this->encode();
    }
    protected function encode()
    {
        $bitmap = null;
        $lastRow = null;
        for ($y = 0; $y < $this->height; $y++) {
            $bits = null;
            for ($x = 0; $x < $this->width; $x++) {
                $bits .= (imagecolorat($this->image, $x, $y) & 0xFF) < 127 ? 1 : 0;
            }
            $bytes = str_split($bits, 8);
            $bytes[] = str_pad(array_pop($bytes), 8, '0');
            $row = null;
            foreach ($bytes as $byte) {
                $row .= sprintf('%02X', bindec($byte));
            }
            $bitmap .= $this->compress($row, $lastRow);
            $lastRow = $row;
        }
        return $bitmap;
    }
    protected function compress(string $row, ?string $lastRow): string
    {
        if ($row === $lastRow) {
            return ':';
        }
        $row = $this->compressTrailingZerosOrOnes($row);
        $row = $this->compressRepeatingCharacters($row);
        return $row;
    }
    protected function compressTrailingZerosOrOnes(string $row): string
    {
        return preg_replace(['/0+$/', '/F+$/'], [',', '!'], $row);
    }
    protected function compressRepeatingCharacters(string $row): string
    {
        $callback = function ($matches) {
            $original = $matches[0];
            $repeat = strlen($original);
            $count = null;
            if ($repeat > 400) {
                $count .= str_repeat('z', floor($repeat / 400));
                $repeat %= 400;
            }
            if ($repeat > 19) {
                $count .= chr(ord('f') + floor($repeat / 20));
                $repeat %= 20;
            }
            if ($repeat > 0) {
                $count .= chr(ord('F') + $repeat);
            }
            return $count . substr($original, 1, 1);
        };
        return preg_replace_callback('/(.)(\1{2,})/', $callback, $row);
    }
}

Now create `Builder.php` file from convert image to zpl as below

class Builder
{
    protected $zpl = [];
    public function command()
    {
        $parameters = func_get_args();
        $command = strtoupper(array_shift($parameters));
        $parameters = array_map([$this, 'parameter'], $parameters);
        $this->zpl[] = '^' . $command . implode(',', $parameters);
        return $this;
    }
    protected function parameter($parameter)
    {
        if (is_bool($parameter)) {
            return $parameter ? 'Y' : 'N';
        }
        return $parameter;
    }
    public function __call($method, $arguments)
    {
        array_unshift($arguments, $method);
        return call_user_func_array([$this, 'command'], $arguments);
    }
    public function gf()
    {
        $arguments = func_get_args();
        if (func_num_args() === 1 && ($image = $arguments[0])) {
            $bytesPerRow = $image->width();
            $byteCount = $fieldCount = $bytesPerRow * $image->height();
            return $this->command('GF', 'A', $byteCount, $fieldCount, $bytesPerRow, $image->toAscii());
        }
        array_unshift($arguments, 'GF');
        return call_user_func_array([$this, 'command'], $arguments);
    }
    public function toZpl($newlines = false, $top = null, $shift = null)
    {
        $start = '^XA';
        if($top) {
            $start .= '^LT'.$top;
        }
        if($shift) {
            $start .= '^LS'.$shift;
        }
        return implode($newlines ? "\n" : '', array_merge([$start], $this->zpl, ['^XZ']));
    }
    public function __toString()
    {
        return $this->toZpl();
    }
}

After create below files convert your image file to zpl code by including both files as below.

include 'Image.php';
include 'Builder.php';
$image = new Image(imagecreatefrompng('test.png')); //You can also use imagecreatefromjpeg for jpg image
$zpl = new Builder();
echo $zpl->gf($image)->toZpl(false, 10, -10); // toZpl(Newline, Top Margin, Left Shift)

Install Radis Server on Windows (WAMP Server)


Radius (Remote Dictionary Server) is an open-source advanced key-value database storage system like NoSQL. Redis supports different kinds of abstract data structures, such as strings, lists, maps, sets, sorted sets, bitmaps and spatial indexes. radius is used for caching to speed up a web application.
If you want to install radios on Linux system than it's easy to install using command line and configure auto in any programming language. when you want to install in window server than manually make some changes for works perfectly.
Process below steps for installing & work redis on a window server.
  • Download redis setup file for window (32bit & 64bit) here. (You can also download files from here)
  • Install/Put redis in any location you want.
  • Run `redis-server.exe` file from instillation files for start radis server.
  • Now check your php version by running phpinfo(); command in any file.
  • Find redis version match your PHP version from PECL package here.
  • Download radis as php extension according to radis version from https://pecl.php.net/package/redis/RADISVERSION(from below point)/windows. (Ex. https://pecl.php.net/package/redis/4.1.1/windows)
  • Here download DLL files list accoring to your PHP version and Thread Safe / Non Thread Safe.
  • Copy the `php_redis.dll` and paste to following folder in Wamp Server `wamp\bin\php\phpVERSION\ext\`.
  • Open php.ini file add redis extension to extensions list as below `extension=php_redis.dll`
  • Restart wamp server & check phpinfo() which shows redis to confirm radis install successfully.
  • Here you can check radis using php code as below.
    
    try {
        $redis = new Redis();
        $redis->connect('localhost', 6379); //connect redis server
        $redis->set('variable', 'Redis Test'); //save data in server
        $redis->get('variable');  //get data from server
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    
    
  • Here for radis connection you must open redis-server.exe file which installed first(don't close radis server window).

Top 10 Bollywood Item Songs 2018

Item song is one type of dance with music as musical performance. now these days, many movies known for it's item songs and it's conman in a Bollywood movie. Currently, all top actress plays the role as item girl instead of the main role in the movie and become that song hits with her best performance. The concept of item song is old in Bollywood industry. This year 2018 Bollywood gives many item songs with any item girls in many movies here list of top 10 item songs of 2018.

HAT JA TAU - VEEREY KI WEDDING

ITEM GIRL Sapna Chaudhary
MOVIE VEEREY KI WEDDING
DIRECTOR Ashu Trikha
RELEASE DATE 2nd March
CAST Pulkit Samrat, Kriti Kharbanda, Jimmy Sheirgill
SINGER Sunidhi Chauhan
MUSIC Jaidev Kumar
MUSIC PUBLISHER T-Series
LYRICS Dr. Devendra Kafir



AASHIQ BANAYA AAPNE - HATE STORY 4

ITEM GIRL Urvashi Rautela
MOVIE HATE STORY 4
DIRECTOR Vishal Pandya
RELEASE DATE 9th March
CAST Urvashi Rautela, Vivan Bhatena, Karan Wahi, Gulshan Grover
SINGER Himesh Reshammiya, Neha Kakkar
MUSIC Himesh Reshammiya
MUSIC PUBLISHER T-Series
LYRICS Sameer



EK DO TEEN - BAAGHI 2

ITEM GIRL Jacqueline Fernandez
MOVIE BAAGHI 2
DIRECTOR Ahmed Khan
RELEASE DATE 30th March
CAST Tiger Shroff, Disha Patani
SINGER Shreya Ghoshal
MUSIC Laxmikant, Pyarelal
MUSIC PUBLISHER T-Series
LYRICS Javed Akhtar



BEWAFA BEAUTY - BLACKMAIL

ITEM GIRL Urmila Matondkar
MOVIE BLACKMAIL
DIRECTOR Abhinay Deo
RELEASE DATE 6th April
CAST Irrfan Khan, Kirti Kulhari, Divya Dutta
SINGER Pawni Pandey
MUSIC Amit Trivedi
MUSIC PUBLISHER T-Series
LYRICS Amitabh Bhattacharya



DILBAR - SATYAMEVA JAYATE

ITEM GIRL Nora Fatehi
MOVIE SATYAMEVA JAYATE
DIRECTOR Milap Milan Zaveri
RELEASE DATE 15th August
CAST John Abraham, Manoj Bajpayee, Aisha Sharma, Amruta Khanvilkar
SINGER Dhvani Bhanushali, Ikka Singh, Neha Kakkar
MUSIC Tanishk Bagchi
MUSIC PUBLISHER T-Series
LYRICS Ikka, Shabbir Ahmed





KAMARIYA - STREE

ITEM GIRL Nora Fatehi
MOVIE STREE
DIRECTOR Amar Kaushik
RELEASE DATE 31st August
CAST Raj Kumar Rao, Shraddha Kapoor
SINGER Aastha Gill, Sachin Sanghvi, Jigar Saraiya, Divya Kumar
MUSIC Sachin-Jigar
MUSIC PUBLISHER T-Series
LYRICS Vayu

HELLO HELLO - PATAAKHA

ITEM GIRL Malaika Arora
MOVIE PATAAKHA
DIRECTOR Vishal Bhardwaj
RELEASE DATE 28th September
CAST Radhika Madan, Sanya Malhotra, Sunil Grover, Vijay Raaz
SINGER Rekha Bhardwaj
MUSIC Vishal Bhardwaj
MUSIC PUBLISHER Zee Music Company
LYRICS Gulzar



SURAIYYA - THUGS OF HINDOSTAN

ITEM GIRL Katrina Kaif
MOVIE THUGS OF HINDOSTAN
DIRECTOR Vijay Krishna Acharya
RELEASE DATE 8th November
CAST Amitabh Bachchan, Aamir Khan, Fatima Sana Shaikh, Katrina Kaif
SINGER Vishal Dadlani, Shreya Ghoshal
MUSIC Ajay – Atul
MUSIC PUBLISHER YRF
LYRICS Amitabh Bhattacharya



GALI GALI - KGF

ITEM GIRL Mouni Roy
MOVIE KGF
DIRECTOR Prashanth Neel
RELEASE DATE 20st December
CAST Yash Srinidhi Shetty
SINGER Neha Kakkar
MUSIC Tanishk Bagchi
MUSIC PUBLISHER T-Series
LYRICS Rashmi Virag



HUSN PARCHAM - ZERO

ITEM GIRL Katrina Kaif
MOVIE ZERO
DIRECTOR Aanand L. Rai
RELEASE DATE 21st December
CAST Shah Rukh Khan, Anushka Sharma, Katrina Kaif
SINGER Bhoomi Trivedi, Raja Kumari
MUSIC Ajay – Atul
MUSIC PUBLISHER T-Series
LYRICS Irshad Kamil

Friday, August 25, 2017

Top 20 Bollywood Movies by Running Time

Bollywood movies are most entertaining part of everyone's life because of some action, drama, thriller, romance or music. So every person wants to watch movie in cinema or mobile & television.
When you watch some movies that it's much interesting like you never want to end that and watch and watch again according to own hobby or interest and although some are much boring that you want to leave to see it.
Here below list of top 20 Bollywood movies according to its running time, which are listed at longest running screen time till now.


20. M.S. Dhoni: The Untold Story (3h 10m)

 
RELEASE DATE 30 September 2016
DIRECTOR Neeraj Pandey
PRODUCER Arun Pandey
CAST Sushant Singh Rajput, Disha Patani, Kiara Advani, Anupam Kher, Bhumika Chawla
RUNNING TIME 190 Minutes


19. Sholay (3h 24m)

 
RELEASE DATE 15 August 1975
DIRECTOR Ramesh Sippy
PRODUCER G. P. Sippy
CAST Dharmendra, Amitabh Bachchan, Hema Malini, Jaya Bhaduri, Sanjeev Kumar, Amjad Khan
RUNNING TIME 204 minutes


18. Hum Aapke Hain Koun (3h 26m)

 
RELEASE DATE 5 August 1994
DIRECTOR Sooraj R. Barjatya
PRODUCER Ajit Kumar Barjatya, Kamal Kumar Barjatya, Rajkumar Barjatya
CAST Salman Khan, Madhuri Dixit, Mohnish Bahl, Anupam Kher, Renuka Shahane, Reema Lagoo, Alok Nath
RUNNING TIME 206 minutes


17. Waqt (3h 26m)

 
RELEASE DATE 1965
DIRECTOR Yash Chopra
PRODUCER B. R. Chopra
CAST Raaj Kumar, Shashi Kapoor, Sharmila Tagore, Balraj Sahni, Sunil Dutt, Sadhana
RUNNING TIME 206 Minutes


16. Netaji Subhas Chandra Bose: The Forgotten Hero (3h 28m)

 
RELEASE DATE 13 May 2005
DIRECTOR Shyam Benegal
PRODUCER Raj Pius, Barbara von Wrangell
CAST Sachin Khedekar, Kulbhushan Kharbanda, Rajit Kapur, Divya Dutta
RUNNING TIME 208 Minutes


15. Swades (3h 30m)

 
RELEASE DATE 17 December 2004
DIRECTOR Ashutosh Gowariker
PRODUCER Ronnie Screwvala
CAST Shah Rukh Khan, Gayatri Joshi, Kishori Balal
RUNNING TIME 210 Minutes


14. Kabhi Khushi Kabhie Gham (3h 30m)

 
RELEASE DATE 14 December 2001
DIRECTOR Karan Johar
PRODUCER Yash Johar
CAST Amitabh Bachchan, Jaya Bachchan, Shah Rukh Khan, Kajol, Hrithik Roshan, Kareena Kapoor
RUNNING TIME 210 Minutes


13. Khoon Pasina (3h 30m)

 
RELEASE DATE 21 January 1977
DIRECTOR Rakesh Kumar
PRODUCER Babboo Mehra
CAST Amitabh Bachchan, Vinod Khanna, Rekha, Nirupa Roy
RUNNING TIME 210 Minutes


12. Indrasabha (3h 31m)

 
RELEASE DATE 1932
DIRECTOR J.J. Madan
PRODUCER Sayed Aga Hasan Amanat
CAST Nissar, Jehanara Kajjan, Abdul Rehman Kabuli
RUNNING TIME 211 Minutes


11. Saudagar (3h 33m)

 
RELEASE DATE 9 August 1991
DIRECTOR Subhash Ghai
PRODUCER Ashok Ghai
CAST Dilip Kumar, Raaj Kumar, Manisha Koirala, Vivek Mushran, Amrish Puri, Gulshan Grover, Anupam Kher, Jackie Shroff
RUNNING TIME 213 Minutes


10. Jodhaa Akbar (3h 34m)

 
RELEASE DATE 15 February 2008
DIRECTOR Ashutosh Gowariker
PRODUCER Ronnie Screwvala
CAST Hrithik Roshan, Aishwarya Rai, Sonu Sood
RUNNING TIME 214 Minutes


09. Narsimha (3h 34m)

 
RELEASE DATE 5 July 1991
DIRECTOR N. Chandra
PRODUCER N. Chandra
CAST Sunny Deol, Dimple Kapadia, Urmila Matondkar
RUNNING TIME 214 Minutes


08. Kabhi Alvida Naa Kehna (3h 35m)

 
RELEASE DATE 11 August 2006
DIRECTOR Karan Johar
PRODUCER Karan Johar
CAST Amitabh Bachchan, Shah Rukh Khan, Abhishek Bachchan, Rani Mukerji, Preity Zinta, Kirron Kher
RUNNING TIME 215 Minutes


07. Salaam-E-Ishq (3h 36m)

 
RELEASE DATE 26 January 2007
DIRECTOR Nikhil Advani
PRODUCER Sunil Manchanda
CAST Salman Khan, Anil Kapoor, Govinda, John Abraham, Sohail Khan, Akshaye Khanna, Priyanka Chopra, Vidya Balan, Juhi Chawla, Shannon Esra, Ayesha Takia, Ishaa Koppikar
RUNNING TIME 216 Minutes


06. Mohabbatein (3h 36m)

 
RELEASE DATE 27 October 2000
DIRECTOR Aditya Chopra
PRODUCER Yash Chopra
CAST Amitabh Bachchan, Shah Rukh Khan, Aishwarya Rai, Uday Chopra, Jugal Hansraj, Jimmy Shergill, Shamita Shetty, Kim Sharma, Preeti Jhangianim Anupam Kher
RUNNING TIME 216 Minutes


05. Khatarnaak (3h 43m)

 
RELEASE DATE 19 January 1990
DIRECTOR Bharat Rangachary
PRODUCER Raam Shetty
CAST Sanjay Dutt, Farha Naaz, Anita Raj, Anupam Kher, Kiran Kumar
RUNNING TIME 223 Minutes


04. Lagaan (3h 44m)

 
RELEASE DATE 15 June 2001
DIRECTOR Ashutosh Gowariker
PRODUCER Aamir Khan, Mansoor Khan
CAST Aamir Khan, Gracy Singh, Rachel Shelley, Paul Blackthorne
RUNNING TIME 224 Minutes


03. Sangam (3h 58m)

 
RELEASE DATE 18 June 1964
DIRECTOR Raj Kapoor
PRODUCER Raj Kapoor
CAST Vyjayanthimala, Raj Kapoor, Rajendra Kumar
RUNNING TIME 238 Minutes


02. Mera Naam Joker (4h 4m)

 
RELEASE DATE 18 December 1970
DIRECTOR Raj Kapoor
PRODUCER Raj Kapoor
CAST Raj Kapoor, Simi Garewal, Manoj Kumar, Rishi Kapoor, Dharmendra
RUNNING TIME 244 Minutes


01. LOC Kargil (4h 6m)

 
RELEASE DATE 25 December 2003
DIRECTOR J.P. Dutta
PRODUCER J.P. Dutta
CAST Sanjay Dutt, Ajay Devgan, Karan Nath, Saif Ali Khan, Sunil Shetty, Abhishek Bachchan, Rani Mukerji, Kareena Kapoor, Esha Deol, Raveena Tandon, Preeti Jhangiani
RUNNING TIME 246 Minutes

Saturday, July 15, 2017

Top 10 Highest Paying URL Shortener to Make Money Online

Now a days all persons are busy with own commercial life and looking for some work for earning additional money online with the help of internet. URL Shortener is one of best and easiest method for that because in that not need much knowledge or education with little time.
For that you need to create account on that website with your email and add any link you want to shoot. You can short any URL even if you haven't owned website/blog, but if you have then it's good. Shortener website short your given URL and return you them URL you just share that URL on social sites or own blog/website.
Whenever any user click on your shorten link then there is some advertise, display on the browser and after sometime or any click user will redirect to the original URL and you got a point/money for that user.
Here all websites have own policy and own earning rate according to visitor country.even all site's minimum payout rate are different.All websites also provide referral functionality to earn money and some site provide page script to use in your website/blog for increase money.
There are various URL Shortener website available some are fraud Here below listed Top 10 Best URL Shorteners That Really Pays and these are the Highest Paying URL Shortener.

1. Shorte.st : Earn money on short links. Make short links and earn the biggest money


Payout for 1000 Views : Upto $9.20
Minimum Withdrawal : $5
Referral Commission : 20%
Payment Methods : PayPal, Payoneer, WebMoney
Alexa Rank (Global) : 5,425
Website : shorte.st

2. AdFly - The URL shortener service that pays you! Earn money for every visitor to your links


Payout for 1000 Views : Upto $17.07
Minimum Withdrawal : $5
Referral Commission : 20%
Payment Methods : PayPal, Payoneer, Payza
Alexa Rank (Global) : 124
Website : adf.ly

3. Ouo.io - Make short links and earn the biggest money


Payout for 1000 Views : Upto $4.7
Minimum Withdrawal : $5
Referral Commission : 20%
Payment Methods : PayPal, Payza
Alexa Rank (Global) : 338
Website : ouo.io

4. Linkbucks.com - Make money when people leave your website


Payout for 1000 Views : Upto $6.20
Minimum Withdrawal : $10
Referral Commission : 10%
Payment Methods : PayPal, Payza, Payoneer
Alexa Rank (Global) : 10,449
Website : www.linkbucks.com

5. LinkShrink.net - Earn money sharing shrinked links!


Payout for 1000 Views : Upto $5.71
Minimum Withdrawal : $5
Referral Commission : 20%
Payment Methods : PayPal, Payza, Bitcoin
Alexa Rank (Global) : 652
Website : linkshrink.net

6. Fas.li - Earn money on short links. Make short links and earn the biggest money


Payout for 1000 Views : Upto $12.00
Minimum Withdrawal : $5
Referral Commission : 10%
Payment Methods : PayPal, Payza
Alexa Rank (Global) : 5,836
Website : fas.li

7. Bc.vc - a modern URL shortener


Payout for 1000 Views : Upto $14.00
Minimum Withdrawal : $10
Referral Commission : 10%
Payment Methods : PayPal
Alexa Rank (Global) : 1,845
Website : bc.vc

8. Link.TL - url shortener and earn money!


Payout for 1000 Views : Upto $16.00
Minimum Withdrawal : $5
Referral Commission : 20%
Payment Methods : PayPal, Payza
Alexa Rank (Global) : 4,884
Website : link.tl

9. Uskip.me - Shorten your links and make money!


Payout for 1000 Views : Upto $8.11
Minimum Withdrawal : $5
Referral Commission : 10%
Payment Methods : PayPal, Payza, Webmoney, Payoneer
Alexa Rank (Global) : 16,266
Website : uskip.me

10. Ally - Earn money by sharing short links


Payout for 1000 Views : Upto $6.83
Minimum Withdrawal : $1
Referral Commission : 20%
Payment Methods : PayPal, Payza, Payoneer, Skrill
Alexa Rank (Global) : 154,251
Website : al.ly

Thursday, July 13, 2017

Magento : add breadcrumbs to cms pages


Magento is an eCommerce application and it supports CMS features with few limitations. Magento displays, bread crumbs, which helps the user to know where they are and it displays the navigation path. Usually, the breadcrumb will be located below the header. But in Magento breadcrumb is available only in the catalog pages an not in the CMS pages or in the checkout pages.

Magento 2.X

  • On the Admin panel, Select Settings -> Stores -> Configuration.
  • In the panel on the left under General, select Web
  • Open the Default Pages section.
  • Change Show Breadcrumbs for CMS Pages to 'Yes'
  • When complete, click Save Config

Magento 1.X

`breadcrump.phtml` in `app/design/default/THEME/page` folder is responsible for displaying the breadcrumb. Add the following code to the breadcrumb.phtml file before the normal breadcrumb check to display the breadcrumb in the CMS, shopping cart and checkout pages.

if ((!$crumbs || !is_array($crumbs)) && $this->getUrl('') != $this->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true))) {
	$breadcrumb = $this->getLayout()->getBlock('breadcrumbs');
	$breadcrumb->addCrumb('home', array('label' => Mage::helper('cms')->__('Home'), 'title' => Mage::helper('cms')->__('Home Page'), 'link' => Mage::getBaseUrl()));
	$breadcrumb->addCrumb('my_account activetrail', array('label' => $this->getLayout()->getBlock('head')->getTitle(), 'title' => $this->getLayout()->getBlock('head')->getTitle(), 'last' => 1));
	$crumbs = $breadcrumb->_crumbs;
}
 
The above code restricts the breadcrumb to be displayed from the home page, if you want that to be shown also in the home page, then remove the following condition from the first line of the above code.

$this->getUrl('') != $this->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true))

Sunday, July 9, 2017

Login With Username/ Mobile in Magento 1.x






Magento provides login functionality for login to account with email and password but sometimes you want to login with customer username/mobileno with account password than here below describe how you implement this functionality in Magento 1. x modify some changes.

Here first add new customer attribute as mobile/username according to your requirement by create sql file in any extension or run installer command as below.

$installer = $this;
$installer->startSetup();
$setup = Mage::getModel('customer/entity_setup', 'core_setup');
$setup->addAttribute('customer', 'mobile', array(
    'type' => 'varchar',
    'input' => 'text',
    'label' => 'Mobile No',
    'global' => 1,
    'visible' => 1,
    'required' => 0,
    'user_defined' => 1,
    'default' => '0',
    'visible_on_front' => 1,
));
$installer->endSetup();

After execute below code in your mysql file or directly from any Magento page.Mobile No field display on website admin panel see add or edit any customer there is display mobile No field. Now you must set login with mobile no in magento front for that changes in `loginPostAction` function located in 'app/code/core/Mage/Customer/controllers/AccountController.php' as below.

public function loginPostAction()
{
    $loginpost = $this->getRequest()->getPost();
    $mobileno = $loginpost['login']['username'];
    if (filter_var($mobileno, FILTER_VALIDATE_EMAIL) //check username as email or mobile.
    {
     parent::loginPostAction(); //excute current code
    }
    else
    {
     $session = Mage::getSingleton('customer/session');
        $collection = Mage::getModel('customer/customer')->getCollection();
        $website_id = Mage::app()->getWebsite()->getId();
        $collection->addAttributeToFilter('mobile', array('eq' =>$mobileno));
        $custData = $collection->getData();
        $email = trim($custData[0]['email']);
        $customerId = (int) trim($custData[0]['entity_id']);
        try{
         $authenticateuser = Mage::getModel('customer/customer')->setWebsiteId($website_id)->authenticate($email, $username['login']['password']);
       }catch( Exception $e ){
            $session->addError('Invalid Login Detail');
            $this->_redirect('customer/account');
       }      
       try{
         if($authenticateuser && $customerId){
             $customer = Mage::getModel('customer/customer')->load($customerId);
                $session->setCustomerAsLoggedIn($customer);
                $message = $this->__('You are now logged in as %s', $customer->getName());
                $session->addSuccess($message);
            }
            else{
             throw new Exception ($this->__('The login attempt was unsuccessful. Some parameter is missing Or wrong data '));
            }
      }
      catch (Exception $e){$session->addError($e->getMessage());}
      $this->_redirect('customer/account');
    }
} 
 
Before make changes in below file you must remove email validation from your theme login. phtml file because default Magento provides only login with email so you must remove login textbox validation by removing validate-email` class of the textbox.
Here customer login using mobileno/username. You can set customer attribute as unique for preventing duplication. You can also check below logic before saving any customer as below.

$customer = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('mobileno')->addAttributeToFilter('mobileno',{Val})->load();
if (is_object($customer)){
 //Customer already exits with same mobileno
}

Magento 2 : List of all console command (CLI)

Magento 2 is new version of Magento with new structure, design and some functionality improve and include for creating a fully customized store. for any developer who works on Magento 2 than much familiar with Magento command line arguments. For use Magento CLI in any operating system need some system requirements for Magento check all configuration Here.
Magento has one command-line interface that performs both installation and configuration tasks. So you can install Magento using command line. Here below table summarizes the available commands in Magento 2. from that some are most used when you develop websites in Magento 2.
Every command run in bin directory of your Magento installation. so first navigate to that directory than use below commands.
When you run want to run command from Magento root directory than write command as `php bin/magento COMMAND`. You can also create own command to run in CLI.

Command Use
admin
magento admin:user:create [--<parameter_name>=<value>, ...] Create a new administrator or to edit an existing administrator
magento admin:user:unlock [admin_user_name] Unlock the account of an administrator that was locked
app
magento app:config:dump Create dump of application
cache
magento cache:status To view the status of the cache
magento cache:enable [type] Omitting [type] enables or disables all cache types at the same time
magento cache:disable [type] This command disable all([type]) types
mmagento cache:clean [type] Deletes all items from enabled Magento cache types only
mmagento cache:flush [type] Flushing a cache type purges the cache storage
cron
magento cron:run [--group="<cron group name>"] To set up(run) custom cron jobs and groups
customer
magento customer:hash:upgrade Upgrade customer hash according to latest algorithm.It helps to increase customer Password security
deploy
magento deploy:mode:show Displays current application mode
magento deploy:mode:set {mode} Change application mode either developer or production
dev
magento dev:source-theme:display Collects and publishes source files for theme
magento dev:tests:run Runs test(all, unit, integration, integration-all, static, static-all, integrity, legacy, default)
magento dev:urn-catalog:generate <path> Generates the catalog of URNs to *.xsd for IDE to highlight XML(Currently, only PHPStorm is supported)
magento dev:xml:convert [-o|--overwrite] {xml file} {xslt stylesheet} Update your layout XML files if you update the corresponding Extensible Style sheet Language Transformations (XSLT) style sheet.
i18n
magento i18n:collect-phrases [-o|--output="<csv file path and name>"] [-m|--magento] <path to directory to translate> Run the translation collection command to extract translatable words and phrases from enabled components
magento i18n:pack [-m|--mode={merge|replace}] [-d|--allow-duplicates] <ource> <locale> Save language package
magento i18n:uninstall [-b|--backup-code] {language package name} ... {language package name} Uninstall language package
indexer
magento indexer:info View the list of indexers
magento indexer:status [indexer] View the status of all or selected indexers
magento indexer:reindex [indexer] Re-index all or selected indexers one time only
magento indexer:show-mode [indexer] To view the current/all indexer configuration
magento indexer:set-mode {realtime|schedule} [indexer] To specify the indexer configuration
magento indexer:reset [indexer] To reset current/all indexer
info
magento info:adminuri Displays Magento admin URI
magento info:backups:list Prints all lists of backup files
magento info:currency:list Displays list of available currencies
magento info:dependencies:show-modules [-d|--directory=" "] [-o|--output="<path and filename>" Show number of dependencies between module
magento info:dependencies:show-modules-circular [-d|--directory=" "] [-o|--output="<path and filename>" Show number of circular dependencies between module
magento info:dependencies:show-framework [-d|--directory=" "] [-o|--output="<path and filename>" Show number of dependencies on Magento framework
magento info:language:list Displays list of available languages
magento info:timezone:list Displays list of available time zones
maintenance
magento maintenance:allow-ips <ip address> .. <ip address> [--none] Maintain the list of exempt IP addresses
magento maintenance:enable [--ip=<ip address> ... --ip=<ip address>] | [ip=none] Enable maintenance mode
magento maintenance:disable [--ip=<ip address> ... --ip=<ip address>] | [ip=none] Disable maintenance mode
magento maintenance:status Displays maintenance mode status
module
magento module:enable [-c|--clear-static-content] [-f|--force] [--all] <module-list> Enable specified/all available modules
magento module:disable [-c|--clear-static-content] [-f|--force] [--all] <module-list> Disable specified/all available modules
magento module:status Displays status of all available modules
magento module:uninstall [--backup-code] [--backup-media] [--backup-db] [-r|--remove-data] [-c|--clear-static-content] \ {ModuleName} ... {ModuleName} Uninstall module\modules {ModuleName} define as <VendorName>_<ModuleName>
sample data
magento sampledata:deploy Deploy sample data module
magento sampledata:remove Remove all sample data packages from composer.json
magento sampledata:reset Reset all sample data modules for re-installation
setup
magento setup:backup [--code] [--media] [--db] Takes backup of Magento application code base, media and database
magento setup:config:set [--<parameter>=<value>, ...] To update the deployment configuration without affecting anything else
magento cron:run [--group="<cron group name>"] Runs all/specifies cron job schedule for setup application
magento setup:db-schema:upgrade Install and upgrade schema in DB
magento setup:db-data:upgrade Install and upgrade data in DB
magento setup:db:status Check if DB data or schema requires upgrade
magento setup:install --<option>=<value> ... --<option><value> Install the Magento application database schema and data with configuration
magento setup:upgrade [--keep-generated] Upgrade the Magento application database schema and data
magento setup:uninstall Uninstalling the Magento software drops and restores the database, removes the deployment configuration, and clears directories
magento setup:di:compile Compile code to generated code and dependency injection configuration
magento setup:rollback [-c|--code-file="<name>"] [-m|--media-file="<name>"] [-d|--db-file="<name>"] Rollback of Magento application code base, media and database according to backup
magento setup:perf:generate-fixtures {path to profile} Generate data for performance testing
magento setup:store-config:set [--<parameter_name>=<value>, ...] Install & configure the store with basic parameters
magento setup:static-content:deploy [<list of languages>] [-t|--theme[="<theme>"]] [--exclude-theme[="<theme>"]] [-l|--language[="<language>"]] [--exclude-language[="<language>"]] [-a|--area[="<area>"]] [--exclude-area[="<area>"]] [-j|--jobs[=">number>"]] [--no-javascript] [--no-css] [--no-less] [--no-images] [--no-fonts] [--no-html] [--no-misc] [--no-html-minify] [-d|--dry-run] Run the static view files deployment
theme
magento theme:uninstall [--backup-code] [-c|--clear-static-content] {theme path} Uninstall themes Composer packages

Wednesday, April 5, 2017

Connect MS SQL Server in PHP using Wamp Server

Wamp Server is mostly used server application for PHP development in Window which is combination of Apache, MySql and PHP. So whenever you use Wamp than must work with MySql database. Sometimes you want to connect Microsoft SQL database in PHP using Wamp server than PHP connection function `mysql_connect` not working for connecting MS SQL database.
For connecting MS SQL server PHP provide `sqlsrv_connect` function as below.



$server = "connect.myserver.name";
$username = "Username";
$password = "Password";
$dbname = "MYDATABASE_NAME";
$connectionInfo = array("Database"=>$dbname, "UID" => $username, "PWD" => $password);
$conn = sqlsrv_connect($server, $connectionInfo);
if( $conn === false )
{
    echo "failed connection";
}

When you try to run below function in Wamp it's given error for `sqlsrv_connect` function because of `sqlsrv` service not installed in Wamp server.
So here follow below steps to run `sqlsrv_connect` function on your Wamp server.
  1. Download Microsoft Drivers for PHP for SQL Server from Microsoft site.
  2. When you click on Download button there are different versions display for download.Download version according to your PHP version
    • SQLSRV40.EXE for PHP 7.0+ on Windows and Linux
    • SQLSRV32.EXE for PHP 5.6, 5.5, and 5.4 on Windows
    • SQLSRV31.EXE for PHP 5.5 and 5.4 on Windows
    • SQLSRV30.EXE for PHP 5.4 on Windows
  3. Extact that files on local.
  4. Copy `php_sqlsrv_54_ts.dll` and `php_pdo_sqlsrv_54_ts.dll` to C:\wamp\bin\php\PHP_VERSION0\ext\ folder
  5. Now Open php.ini file from C:\wamp\bin\apache\APACHE_VERSION\bin\ or from WAMP icon.
  6. Add extension for the two drivers by adding these lines below all extensions list in `php.ini` file.
    
    extension=php_sqlsrv_54_ts.dll //for PHP 5.4
    extension=php_pdo_sqlsrv_54_ts.dll //for PHP 5.4
    
    
    and comment out the existing lines below if not commented
    ;extension=php_pdo_mssql.dll 
    ;extension=php_mssql.dll
  7. Now restart Wamp services.
Now you can connect MS SQL Server in Wamp server using `sqlsrv_connect` function.You can use other sqlsrv function according to mysql function.See list of all PHP:SQLSRV functions.

Tuesday, January 3, 2017

Most Awaited Upcoming Bollywood Movies of 2017

Bollywood movie is most entertaining part of some people so every year, many movie releases with different concept or story or based on some topic or biopic of any star in person. Now a days every movie famous or noticed before come because of its publicity or any big star.
Previous year 2016 many movies cross 100 Crore in box office collection and create new record. In feature many movies create new record because of every day increase Bollywood fan, casts, movie budget and screen also.
So, according to current year people must wait for them favorite movie. Here below list of top movies according to release date which are mostly in news because of its casts, story, budget or squeal of any other movie.


MOVIE NAME CASTS DIRECTOR RELEASE DATE
Ok Jaanu Aditya Roy Kapur, Shraddha Kapoor, Naseeruddin Shah, Leela Samson Shaad Ali 13th January
Raees Shah Rukh Khan, Mahira Khan, Nawazuddin Siddiqui Rahul Dholakia 25th January
Kaabil Hrithik Roshan, Yami Gautam, Ronit Roy Sanjay Gupta 25th January
Jolly LLB 2 Akshay Kumar, Huma Qureshi, Annu Kapoor Subhash Kapoor 20th February
Rangoon Shahid Kapoor, Saif Ali Khan, Kangana Ranaut Vishal Bhardwaj 24th February
Commando 2 Vidyut Jammwal, Adil Hussain, Adah Sharma, Esha Gupta Deven Bhojani 3rd March
Badrinath Ki Dulhania Varun Dhawan, Alia Bhatt Shashank Khaitan 10rd March
Sarkar 3 Amitabh Bachchan, Manoj Bajpayee, Yami Gautam, Ronit Roy Ram Gopal Varma 10rd March
Jagga Jasoos Ranbir Kapoor, Katrina Kaif, Sayani Gupta Anurag Basu 7th April
Baahubali 2 Prabhas, Tamannaah Bhatia, Anushka Shetty, Rana Daggubati S.S. Rajamouli 28th April
Half Girlfriend Arjun Kapoor, Shraddha Kapoor Mohit Suri 19th May
Raabta Sushant Singh Rajput, Kriti Sanon Dinesh Vijan 9th June
Tubelight Salman Khan, Zhu Zhu, Sohail Khan Kabir Khan 26th June
The Ring Shah Rukh Khan, Anushka Sharma Imtiaz Ali 11th August
Baadshaho Ajay Devgn, Emraan Hashmi, Vidyut Jammwal, Ileana D'Cruz, Esha Gupta Milan Lutharia 1st September
Judwaa 2 Varun Dhawan, Tapsee Pannu, Jacqueline Fernandez David Dhawan 29th September
Aankhen 2 Amitabh Bachchan, Arshad Warsi, Anil Kapoor, Arjun Rampal, Ileana D'Cruz Anees Bazmee 19th October
Robot 2 Rajnikanth, Akshay Kumar, Amy Jackson Shankar 19th October
Golmaal Again Ajay Devgn, Tusshar Kapoor, Parineeti Chopra Rohit Shetty 19th October
Padmavati Deepika Padukone, Ranveer Singh, Aditi Rao Hydari Sanjay Leela Bhansali 17th November
Tiger Zinda Hai Salman Khan, Katrina Kaif Ali Abbas Zafar 22th December