Rename a file if same already exists

While uploading a file you may want to check if a file already exists in target directory then create a new file instead of replacing and rename new file with an incremental no. Example some_dir/some_file.png already exists, and you try to upload a file with name some_file.png again, so it should be uploaded as some_dir/some_file1.png […]

Integrating stripe using stripe.js and stripe-php library

Stripe is getting popular as a payment processor because of its simplicity and PCI compliance. To meet with PCI standards your website shouldn’t send or store any credit card information to any where other than stripe, so to send credit card information directly to stripe we use stripejs. How it works Stripe.js collects credit card […]

Stripe error Amount must be at least 50 cents

Uncaught StripeErrorInvalidRequest: Amount must be at least 50 cents Stripe expects amounts in cents/pence, so if you pass amount as amount = 10 This will be considered as 10 pence instead of 10 USD. So when Stripe gets pence lower than 50 it generates that error. How to send USD instead of pence You need […]

Passing arguments to cron and receive in php

Setting up cron Crons can pass parameters or arguments to scripts as well for example you have example.php set as cron like below Now if you want to pass parameters to example.php in cron you can do it as follow by using key value pairs If you want to send arguments without keys you can […]

How to set php script to cronjob

Cron is a task scheduler which can execute a task on certain intervals, you can add php script to cron to run it on certain time intervals. For example you want to delete temporary files after every 14 days, you write a script to delete temporary files and add that script to cron. How to […]

How to secure you Magento installation from possible hacks

Magento is widely used as a powerful e-commerce platform, hence it is popular and widely used there are more hacks and malware created from outside world to attack magento to steal information or redirecting users to advertisement pages. Here I will tell you how you can protect your magento installation files, there are other steps […]

Magento Error 404 on every page

That is possible due to mod rewrite not working properly To solve this check either mod_rewrite is enabled if enabled then check your virtual host file and change it to following Often virtualhost file contains AllowOverride none that actually restricts magento .htacess files to execute. You need to put it to AllowOverride all.

Change file permissions recursively using php

You often ran into a position where you need to deploy your script on hosting and you have only ftp access. Your web server configuration may need to have right permissions on files to execute them. Normally on linux servers directory permissions are set to 0755 and file permissions are 644, but if security is […]