Detect SSL mode or when page is in secure mode

if ($_SERVER == ‘on’) {
// secure mode
}

if ($_SERVER  !=  ’on’) {
// NOT secure mode
}

Tags: PHP and Mysql
Posted in PHP and Mysql | Leave a comment

htaccess useful tips

1. Custom Directory Index Files

DirectoryIndex index.html index.php index.htm

2. Custom Error Pages

#BAD_REQUEST
ErrorDocument 400 http://www.yourdomain.com/index.html
#UNAUTHORIZED
ErrorDocument 401 http://www.yourdomain.com/index.html
#FORBIDDEN
ErrorDocument 403 http://www.yourdomain.com/index.html
#NOT_FOUND
ErrorDocument 404 http://www.yourdomain.com/index.html
#METHOD_NOT_ALLOWED
ErrorDocument 405 http://www.yourdomain.com/index.html
#REQUEST_TIME_OUT
ErrorDocument 408 http://www.yourdomain.com/index.html
#GONE
ErrorDocument 410 http://www.yourdomain.com/index.html
#LENGTH_REQUIRED
ErrorDocument 411 http://www.yourdomain.com/index.html
#PRECONDITION_FAILED
ErrorDocument 412 http://www.yourdomain.com/index.html
#REQUEST_ENTITY_TOO_LARGE
ErrorDocument 413 http://www.yourdomain.com/index.html
#REQUEST_URI_TOO_LARGE
ErrorDocument 414 http://www.yourdomain.com/index.html
#UNSUPPORTED_MEDIA_TYPE
ErrorDocument 415 http://www.yourdomain.com/index.html
#INTERNAL_SERVER_ERROR
ErrorDocument 500 http://www.yourdomain.com/index.html
#NOT_IMPLEMENTED
ErrorDocument 501 http://www.yourdomain.com/index.html
#BAD_GATEWAY
ErrorDocument 502 http://www.yourdomain.com/index.html
#SERVICE_UNAVAILABLE
ErrorDocument 503 http://www.yourdomain.com/index.html
#VARIANT_ALSO_VARIES
ErrorDocument 506 http://www.yourdomain.com/index.html

3. Control access at files & directory level

<Files .htaccess>
order allow,deny
deny from all
</Files>
<FilesMatch "(\.log|dbclass\.php|\..*)">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>

4. Modifying the Environment Variable

Environment variables contain information used by server-side includes and CGI. Set / Unset environment variables using SetEnv and UnSetEnv.
SetEnv SITE_WEBMASTER "Jack Sprat"
SetEnv SITE_WEBMASTER_URI mailto:Jack.Sprat@characterology.com
UnSetEnv REMOTE_ADDR

5. 301 Redirect using htaccess

If you want to redirect from an…Read More

Tags: General
Posted in General | Leave a comment

Google “site not safe” warning removal

Many people ask me why Google shows a warning that says “this site may not be safe” when someone searches for their website name. They want it removed so the people will click through to their website. First of all this normally means that your website is been hacked and probably is delivering malware. Many hackers do not want to delete or disturb your site they just want to trick your visitors into downloading some malicious software. Normally the malicious software will then download a virus or something of that nature so the hacker can gain access to your…Read More

Tags: General
Posted in General | Leave a comment

Great way to share your screen

Here is a great website to share your screen with other people remotely so they can see what you are doing. It is free and easy to use.
http://www.joinme.com

Tags: General
Posted in General | Leave a comment

Naming passwords and usernames that make sense

Okay, here’s the deal. Let’s talke about designers/developers who uses cute, fun, clever, and other strange types of words in passwords and usernames for their clients. For instance, I had an employee working for me and I asked him to create a new account login for a client of ours. He used devil69 for the password and when I found out I asked him why he used that. Of course he did not have a clue he just thought it was cool. I carefully explained to him that our clients probably think we are less than professional when we give them passwords like…Read More

Tags: General
Posted in General | Leave a comment

Copy files from one server to another – both remote servers

I have always been looking for an easy way to copy files from one server to another. Not local servers, but 2 remote servers. For instance, I want to copy the entire website from www.domain1.com over to www.domain2.com . Normally I download the website using an FTP program and then upload it to the other website using the same FTP program. Recently I found that ipswitch ftp professional lets me open up a remote server on the left and the remote server on the right. Then I can drag-and-drop files between them. I know there are ways to…Read More

Tags: General
Posted in General | Leave a comment

Adding a Youtube Video To Magento Page

This tutorial will show you how to add a youtube video to a magento cms page. You can also use the same technique for adding a youtube video to a product page in the products description area.

Step 1: Go to your magento admin panel at http://www.yourdomain.com/admin/

Step 2: In the main menu go to CMS then choose Pages from the drop down menu

Step 3: You can create a new page or edit an existing page by clicking on the name of that page in the list shown. I will assume that you are on the page you created and/or…Read More

Tags: Ecommerce & Shopping Carts
Posted in Ecommerce & Shopping Carts | 4 Comments

Get last entry of an array

Here is a nice way to grab the last item of an exploded string:
$my_string = ‘one-two-three-four’;
$last_item = end(explode( ‘-’, $my_string);
echo $last_item; // four

Tags: Php Programming
Posted in Php Programming | Leave a comment

Opening large .sql files

Sometimes I have a backup of a mysql database in an .sql file and when I open it in notepad or wordpad it takes forever and freezes most of the time. I recently figured out that I could open it in Microsoft Excel and not only did it open quickly but it was laid out in an easy to use way. I found the table I needed easily and was able to copy and paste the code into my mysql gui.

Tags: General
Posted in General | Leave a comment

Session not working

Sometimes I have a site where the session does not seem to work when I set something on one page and go to the next. The session is empty no matther what I try. For instance, on page 1 I do this: $_SESSION = ‘something’;

Then when I go to page 2 and do this echo $_SESSION I get nothing.

I have found that sometimes the solution is the session_save_path() setting. If I create a directory called tmp and then add something like this to my page right above the session_start() things start working:

session_save_path(‘/full/path/to/your/site/tmp’);

Tags: General
Posted in General | Leave a comment