Tuesday, February 21, 2017
Use ffmpeg to convert your videos
ffmpeg -i products_video.mp4 -c:v h264 -an products_video_h264.mp4 # Convert to MP4
ffmpeg -i products_video.mp4 -c:v libtheora -an products_video_libtheora.ogv # Convert to OGV
ffmpeg -i products_video.mp4 -c:v libvpx -an products_video_libvpx.webm # Convert to Webm
ffmpeg -i products_video.mp4 -c:v h264 -an -filter:v scale=720:-1 products_video_h264_720.mp4 # Convert to MP4
Sunday, January 8, 2017
Add Compression (Gzip) and caching methods for htaccess
AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE image/x-icon AddOutputFilterByType DEFLATE image/svg+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/x-font AddOutputFilterByType DEFLATE application/x-font-truetype AddOutputFilterByType DEFLATE application/x-font-ttf AddOutputFilterByType DEFLATE application/x-font-otf AddOutputFilterByType DEFLATE application/x-font-opentype AddOutputFilterByType DEFLATE application/vnd.ms-fontobject AddOutputFilterByType DEFLATE font/ttf AddOutputFilterByType DEFLATE font/otf AddOutputFilterByType DEFLATE font/opentype # For Olders Browsers Which Can't Handle Compression BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html ## EXPIRES CACHING ##ExpiresActive On ExpiresByType image/jpg "access 1 year" ExpiresByType image/jpeg "access 1 year" ExpiresByType image/gif "access 1 year" ExpiresByType image/png "access 1 year" ExpiresByType text/css "access 1 month" ExpiresByType text/html "access 1 month" ExpiresByType application/pdf "access 1 month" ExpiresByType text/x-javascript "access 1 month" ExpiresByType application/x-shockwave-flash "access 1 month" ExpiresByType image/x-icon "access 1 year" ExpiresDefault "access 1 month" ## EXPIRES CACHING ##
Thursday, July 28, 2016
Error connecting external SMTP server
Here I am with some quick solution, if you are sending email connecting to
external smtp server like smtp.gmail.com you may have to consider to check 2
options.
1. Check smtp ports are open or make sure its not block:
Open your WHM and go to "ConfigServer Security & Firewall" and Edit the configuration file for the csf firewall and lfd or click on "Firewall Configuration" locate SMTP_PORTS and make sure porst are open (Ex: 25,465,587)
2. Check smtp allowed users are added in the list or Always allow the following comma separated users and groups to bypass SMTP_BLOCK
Open your WHM and go to "ConfigServer Security & Firewall" and Edit the configuration file for the csf firewall and lfd or click on "Firewall Configuration" locate SMTP_ALLOWUSER and add the cpanel username (Ex: cpanel, )
Save the changes & you restart both csf and lfd.
In anyway if this one helps you, please make a comment & share in your post
Thank you.
Saf
UPDATE:
This is really strange, new problem rise everyday and we have to find solution, codes are also same like life now.
“Password not accepted from server: 535 Incorrect authentication data” when sending with GMail and phpMailer
using CentOs 6 Login to CPanel > Tweak Settings > All> "Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak)" <== disable it.
Reference: http://stackoverflow.com/questions/14297264/password-not-accepted-from-server-535-incorrect-authentication-data-when-send
1. Check smtp ports are open or make sure its not block:
Open your WHM and go to "ConfigServer Security & Firewall" and Edit the configuration file for the csf firewall and lfd or click on "Firewall Configuration" locate SMTP_PORTS and make sure porst are open (Ex: 25,465,587)
2. Check smtp allowed users are added in the list or Always allow the following comma separated users and groups to bypass SMTP_BLOCK
Open your WHM and go to "ConfigServer Security & Firewall" and Edit the configuration file for the csf firewall and lfd or click on "Firewall Configuration" locate SMTP_ALLOWUSER and add the cpanel username (Ex: cpanel, )
Save the changes & you restart both csf and lfd.
In anyway if this one helps you, please make a comment & share in your post
Thank you.
Saf
UPDATE:
This is really strange, new problem rise everyday and we have to find solution, codes are also same like life now.
“Password not accepted from server: 535 Incorrect authentication data” when sending with GMail and phpMailer
using CentOs 6 Login to CPanel > Tweak Settings > All> "Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak)" <== disable it.
Reference: http://stackoverflow.com/questions/14297264/password-not-accepted-from-server-535-incorrect-authentication-data-when-send
Tuesday, July 5, 2016
Flash Nexus 5 Manually
- fastboot erase boot
- fastboot erase cache
- fastboot erase recovery
- fastboot erase system
- fastboot flash bootloader "name-of-bootloader.img"
- fastboot reboot-bootloader
- fastboot flash radio "name-of-radio.img" (if present)
- fastboot reboot-bootloader
- fastboot flash system system.img
- fastboot flash boot boot.img
- fastboot flash recovery recovery.img
- fastboot flash cache cache.img
- fastboot flash vendor vendor.img (Nexus 9 only)
- fastboot erase userdata
- fastboot flash userdata userdata.img
- fastboot reboot
Source : http://www.howtogeek.com/176284/how-to-upgrade-your-nexus-device-without-waiting-by-flashing-a-factory-image/
Saturday, July 2, 2016
Fatal error: Uncaught exception 'ImapMailboxException' with message 'Connection error: Can not authenticate to IMAP server
I am using php to connect and download mail from imap.google.com and also to send email using smpt.google.com this was working without any problem, sudenly this stop working and started to give error messages as bellow.
"Fatal error: Uncaught exception 'ImapMailboxException' with message 'Connection error: Can not authenticate to IMAP server: [AUTHENTICATIONFAILED] Invalid credentials (Failure)"
Fatal error: Uncaught exception 'ImapMailboxException' with message 'Connection error: Can not authenticate to IMAP server: [ALERT] Please log in via your web browser: https://support.google.com/mail/acco' in /xxxxxx/classes/ImapMailbox.php:51 Stack trace: #0 /home/xxxx/public_html/_backoffice/mailpilot/classes/ImapMailbox.php(42): ImapMailbox->initImapStream() #1 /xxxxxx/classes/ImapMailbox.php(114): ImapMailbox->getImapStream() #2 /xxxxxx/mail.v3.php(28): ImapMailbox->searchMailbox('ALL') #3 {main} thrown in/xxxxx/classes/ImapMailbox.php on line 51
Was looking for a solution two weeks and finally google contacted me with an answer, here is what you have to do.
It seems this error is related to the access to "Less secure apps" disabled for the user you're trying to connect via IMAP. Please follow these steps to solve this issue:
1. In your Admin Console, follow the steps available at this support article https://support.google.com/a/answer/6260879?hl=en under the section "Enabling less secure apps to access accounts".
2. Log in as the affected user and follow the steps to "Allow less secure apps to access your account" as described at this support article https://support.google.com/accounts/answer/6010255.
Added Later: or go to this url https://myaccount.google. com/lesssecureapps
Added Later: If you have any smtp problem, make sure you have added cpanel username to firewall and also please follow the instruction in this url https://stackoverflow.com/questions/14297264/password-not-accepted-from-server-535-incorrect-authentication-data-when-send
Thanks Saf
"Fatal error: Uncaught exception 'ImapMailboxException' with message 'Connection error: Can not authenticate to IMAP server: [AUTHENTICATIONFAILED] Invalid credentials (Failure)"
Fatal error: Uncaught exception 'ImapMailboxException' with message 'Connection error: Can not authenticate to IMAP server: [ALERT] Please log in via your web browser: https://support.google.com/mail/acco' in /xxxxxx/classes/ImapMailbox.php:51 Stack trace: #0 /home/xxxx/public_html/_backoffice/mailpilot/classes/ImapMailbox.php(42): ImapMailbox->initImapStream() #1 /xxxxxx/classes/ImapMailbox.php(114): ImapMailbox->getImapStream() #2 /xxxxxx/mail.v3.php(28): ImapMailbox->searchMailbox('ALL') #3 {main} thrown in/xxxxx/classes/ImapMailbox.php on line 51
Was looking for a solution two weeks and finally google contacted me with an answer, here is what you have to do.
It seems this error is related to the access to "Less secure apps" disabled for the user you're trying to connect via IMAP. Please follow these steps to solve this issue:
1. In your Admin Console, follow the steps available at this support article https://support.google.com/a/answer/6260879?hl=en under the section "Enabling less secure apps to access accounts".
2. Log in as the affected user and follow the steps to "Allow less secure apps to access your account" as described at this support article https://support.google.com/accounts/answer/6010255.
Added Later: or go to this url https://myaccount.google.
Added Later: If you have any smtp problem, make sure you have added cpanel username to firewall and also please follow the instruction in this url https://stackoverflow.com/questions/14297264/password-not-accepted-from-server-535-incorrect-authentication-data-when-send
Thanks Saf
Monday, November 25, 2013
How to Install Zurb Foundation 5
Think most of the people having difficulties to install Zurb Foundation 5. Ruby Error messages, "compass watch" not working etc. etc. I had the same issue last night but solved it myself.
This is a small guide, how to Install Zurb Foundation 5 properly in Windows 7.
https://msysgit.googlecode.com/files/Git-1.8.4-preview20130916.exe
When installing, choose the 2nd option. (Run Git from Windows command prompt)
Then, manually set configure the Windows Path as follows. (System->Advanced System Settings->Environment Variables)
C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd
This will not harm anything in your system, so no need to worry.
http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-1.9.3-p484.exe?direct
Choose this version rather than the 2.00 or 2.00 64bit version. And if you installed any other Ruby version, uninstall it. (But remember the gems you have installed before)
Next Next Finish :)
http://nodejs.org/dist/v0.10.22/x64/node-v0.10.22-x64.msi
This is a small guide, how to Install Zurb Foundation 5 properly in Windows 7.
1. Install Git
As per Zurb Foundation docs, the 1st thing is you have to install Git.https://msysgit.googlecode.com/files/Git-1.8.4-preview20130916.exe
When installing, choose the 2nd option. (Run Git from Windows command prompt)
Then, manually set configure the Windows Path as follows. (System->Advanced System Settings->Environment Variables)
C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd
This will not harm anything in your system, so no need to worry.
2. Install Ruby
2nd thing as per the Zurb Foundation Docs.http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-1.9.3-p484.exe?direct
Choose this version rather than the 2.00 or 2.00 64bit version. And if you installed any other Ruby version, uninstall it. (But remember the gems you have installed before)
Next Next Finish :)
3. NodeJs
Pretty straightforward.http://nodejs.org/dist/v0.10.22/x64/node-v0.10.22-x64.msi
4. Restart PC
Path to npm will set when you install NodeJs.5. Install Bower
Go to the command prompt and type "npm install -g bower"
6. Uninstall/ Install Foundation
If you uninstall ruby, the foundation gem also gone. But to make sure, try below.
gem uninstall foundation
gem uninstall zurb-foundation
If it said 0 gem uninstalled, then your foundation gem gone. What we have to do here is to install the new foundation as per the docs.
If it said 0 gem uninstalled, then your foundation gem gone. What we have to do here is to install the new foundation as per the docs.
gem install foundation
7. Install Compass
Dont forget to Install Compass too. :)
gem install compass
gem install compass
8. Create Foundation 5 Project
YOUR_PATH> foundation new MY_PROJECT
9. Watch Sass Changes
YOUR_PATH> compass watch
10. Finish
Enjoy Foundation 5. :)
Sunday, November 10, 2013
How to submit a form using jQuery, AJAX and PHP
We can submit a form via jQuery, AJAX and PHP from two methods.
1. Data String
2. JSON
Here, Im using the 1st method and it is the easiest.
Here I used a very simple method to post data into PHP. Now lets look at the "form-submit" file
PS : in jQuery file, i commented "alert (dataString);return false;". You can uncomment this and see whether your dataString is correctly passing or not. coz of return "false", it will not proceed to ajax call. :)
On a later day, lets see how to achieve this via JSON. :)
1. Data String
2. JSON
Here, Im using the 1st method and it is the easiest.
// link jquery main
$(function() {
// Your Button ID
$("#submit").click(function() {
/* field names */
var fld1 = $("#fld1").val();
var fld2 = $("#fld2").val();
var fld3 = $("#fld3").attr('checked');
var fld4 = $("fld4 :selected").val();
var dataString = 'fld1=' + fld1 + '&fld2=' + fld2 + '&fld3=' + fld3 + '&fld4=' + fld4 ;
//alert (dataString);return false;
$.ajax({
type: "POST",
url: "./form-submit.php",
data: dataString,
success: function(html) {
var trimmed = trim(html);
if(trimmed == 'success') {
/* Do what you want to do when its success */
} else {
/* Error Message */
}
}
});
return false;
});
});
Here I used a very simple method to post data into PHP. Now lets look at the "form-submit" file
$fld1 = $_REQUEST['fld1']; $fld2 = $_REQUEST['fld2']; $fld3 = $_REQUEST['fld3']; $fld4 = $_REQUEST['fld4']; /* MySQL Insert commands. At the end, echo "success"; */ echo "success";Why echo Success? That is the command we are giving for jQuery file saying that the operation did successfully. If form-submit returned a string different than 'success', then its an error.
PS : in jQuery file, i commented "alert (dataString);return false;". You can uncomment this and see whether your dataString is correctly passing or not. coz of return "false", it will not proceed to ajax call. :)
On a later day, lets see how to achieve this via JSON. :)
Thursday, November 7, 2013
How to read folder names/ file names in PHP
1. How to read folder name in PHP
2. How to read file names in a folder in PHP
Might you will complain that it is reading the whole path, not the folder/ filename you want to get at the end. So follow this trick. :)
$folderpath = "./FOLDER-NAME/*";
foreach(glob($folderpath, GLOB_ONLYDIR) as $foldername){
/* Do your magic here */
echo $foldername;
}
Don't forget to add '/*' after your folder name 2. How to read file names in a folder in PHP
$folderpath = "./FOLDER-NAME/*.*";
foreach(glob($folderpath) as $filename){
/* Do your magic here */
echo $filename;
}
Don't forget to add '/*.*' after your folder name Might you will complain that it is reading the whole path, not the folder/ filename you want to get at the end. So follow this trick. :)
$folderpath = "./FOLDER-NAME/*";
foreach(glob($folderpath, GLOB_ONLYDIR) as $foldername){
$newFolderName = str_replace("./FOLDER-NAME/", '', $foldername);
echo $newFolderName;
}
TaDa !!!!
Tuesday, November 5, 2013
How to use the same MySQL query again and again
Actually, what we going to do is to move the internal row pointer to re-query. For this, Im going to use the mysql function mysql_data_seek().
The internal row pointer is the current row position in a result returned by the mysql_query() function.
$sql = "SELECT * FROM tbl_data";
$result = mysql_query($sql,$con);
while ($row = mysql_fetch_array($result)) {
/* Show your data here*/
}
/* Call the result info again*/
mysql_data_seek($result,0);
// you can change the 0 into any number. From this, it will control from which row number you want to start the query again.
while ($row = mysql_fetch_array($result)) {
/* Show your data for the 2nd time */
}
Monday, May 13, 2013
Getting the first letters of text using PHP [SafGetFirstLetters]
It is always better to make small small functions and keep a library, I was collecting all my experimental functions since I am in to PHP.
I wanted to take first letters from a line of text and realized that I have to use this for many places. Yesterday I have made a new one "SafGetFirstLetters"?
What does it do?
Example Text: This Is A Example Text Line
Output: TTIAETL
SafGetFirstLetters("Lagoon Water Villa with Private Pool", 5)
will return: "LWVwP"
5 is the limit of the text I have asked from function to return.
Thanks.
Safras Ahamed
I wanted to take first letters from a line of text and realized that I have to use this for many places. Yesterday I have made a new one "SafGetFirstLetters"?
What does it do?
Example Text: This Is A Example Text Line
Output: TTIAETL
SafGetFirstLetters("Lagoon Water Villa with Private Pool", 5)
will return: "LWVwP"
5 is the limit of the text I have asked from function to return.
function SafGetFirstLetters($Text,$MaxChr){
$TextArray = explode(" ",$Text);
$WordCount = count($TextArray);
if ($WordCount) {
$MakeText='';
for ($i_a = 0; $i_a < $WordCount; $i_a++) {
$MakeText = $MakeText . substr($TextArray[$i_a],0,1);
}
}
if ($MaxChr) {
return substr($MakeText,0,$MaxChr);
}else{
return $MakeText;
}
}
If you like it please comment.Thanks.
Safras Ahamed
Wednesday, April 3, 2013
How to create a unique string in PHP (Simple Way)
$string = md5(time());
Instead of md5, you can use SHA1 or any other encryption method in PHP OR a mix of them.
Eg :
$string = sha1(md5(time()));
Tuesday, March 26, 2013
How Get Number of Days in a Month in PHP
Extracted from PHP.net
More Simple way by a SafFunction
function days_in_month($month, $year) {
return $month == 2 ?
($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) :
(($month - 1) % 7 % 2 ? 30 : 31);
}
echo days_in_month(YOUR_MONTH,YOUR_YEAR);
More Simple way by a SafFunction
function days_in_month($month,$year) {
return date('t',mktime(0,0,0,$month,1,$year));
}
echo days_in_month(YOUR_MONTH,YOUR_YEAR);
Sunday, March 24, 2013
SafSendMailV2: A function to send mail using php
I started to make and collect my own function since 2001 and SafSendMail I made it in 2002 for a project where there was lots of mail sending option. If I want to send a mail I have to write whole lot and I didn't like it. Created SafSendMail so that I can send mail as I want using a single line.
Later I made SafSendMailV2 supporting HTML and other stuff as you can see, if any mail sent using V2 it will also record From-IP & From-File. Using this you can Identify different things.
function SafSendMailV2(
$MYRECIPIENTE_EMAIL,
$MYRECIPIENTE_NAME,
$MYFROM_NAME,
$MYFROM_EMAIL,
$MYSUBJECT,
$MYBODY,
$MYHTML,
$REMOTE_ADDR,
$PHP_SELF){
$MYRECIPIENTE_EMAIL = "$MYRECIPIENTE_EMAIL";
if ($MYHTML==true) {
$MYHEADERS = "From: $MYFROM_NAME <$MYFROM_EMAIL>\r\n";
$MYHEADERS .= "MIME-Version: 1.0\r\n";
$MYHEADERS .= "Content-Type: text/html; charset=windows-1256\r\n";
$MYHEADERS .= "Content-Transfer-Encoding: base64\r\n";
$MYHEADERS .= "From-IP: $REMOTE_ADDR\r\n";
$MYHEADERS .= "From-File: $PHP_SELF\r\n";
$MYHEADERS .= chunk_split(base64_encode("$MYBODY"));
mail("$MYRECIPIENTE_EMAIL", "$MYSUBJECT", "", $MYHEADERS);
}else{
$MYHEADERS = "From: $MYFROM_NAME <$MYFROM_EMAIL>\r\n";
$MYHEADERS .= "From-IP: $REMOTE_ADDR\r\n";
$MYHEADERS .= "From-File: $PHP_SELF";
mail("$MYRECIPIENTE_EMAIL", "$MYSUBJECT", "$MYBODY", $MYHEADERS);
}
}
How to use?
SafSendMailV2("Recipiente@domain.com","Recipiente Name","Your Name","Your Email","Subject",$MYBODY,true,$REMOTE_ADDR,$PHP_SELF)
Subscribe to:
Comments (Atom)

