My Code Genius by 2 Geniuses
Wednesday, September 20, 2017
Font Awesome in AAYUS TravelSys
Tuesday, September 12, 2017
SMTP Error connecting External Mail Server
When you are sending email connecting another/external mail server and your are using php & cpanel
You will get an error like, Can not send, smtp problem and some stupid error.
Please make sure the port is open: 587
and you have to go to you WHM
Search for "ConfigServer Security & Firewall"
Edit Fire Wall Configuration (Edit the configuration file for the csf firewall and lfd)
Scroll down till SMTP_ALLOWUSER and add username of cpanel account and press enter to save and restart
You will get an error like, Can not send, smtp problem and some stupid error.
Please make sure the port is open: 587
and you have to go to you WHM
Search for "ConfigServer Security & Firewall"
Edit Fire Wall Configuration (Edit the configuration file for the csf firewall and lfd)
Scroll down till SMTP_ALLOWUSER and add username of cpanel account and press enter to save and restart
Sunday, September 10, 2017
Problem with GET parameters when posting large data in php
Problem is suhosin (Most of the time)
change the suhosin.get.max_value_length=2000
When you are submitting a form using GET specially, you will get this
change the suhosin.get.max_value_length=2000
When you are submitting a form using GET specially, you will get this
Where is the php.ini file on a Linux/CentOS?
Login to your SSH
Simply type
php -i | grep "Loaded Configuration File"
or
php -i | grep "php.ini"
Thanks
Saf,
PLEASE: Motivate us, if this code helped for you just say a Thanks.
Simply type
php -i | grep "Loaded Configuration File"
or
php -i | grep "php.ini"
Thanks
Saf,
PLEASE: Motivate us, if this code helped for you just say a Thanks.
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 !!!!
Subscribe to:
Posts (Atom)