Sanjoy Roy

[MCM, MCP, SCJP] – Senior PHP Programmer

Monthly Archives: August 2012

Block Google and bots using htaccess and robots.txt


Robots.txt
User-agent: *
Disallow: /

.htaccess

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} AltaVista [OR]
RewriteCond %{HTTP_USER_AGENT} Googlebot [OR]
RewriteCond %{HTTP_USER_AGENT} msnbot [OR]
RewriteCond %{HTTP_USER_AGENT} Slurp
RewriteRule ^.*$ “http\:\/\/domainname\.com.au” [R=301,L]

Advertisements

How to force browser to resize when window resizing doesn’t work


use the code below:

window.onresize = function() {
   window.resizeTo(500,500);
}

How to hide window scrollbar for IE, FF and Google Chrome


It is easy if you add the attribute scrollbars=no inside the window.open()‘s window attributes. But what if you wish to hide them when the popup window is already open. Thank you CSS! Yes, it is possible by using Javascript and accessing the window style’s property overflow. However, there is a cross-browser issue. Both IE and Firefox/Google Chrome have different codes that make this work. You can place both their codes in the same page and/or Javascript function. If the browser does not understand the property, it will ignore it anyway so there is no need to do a browser check to execute the code specific to that certain browser.
The code below does the trick:

document.documentElement.style.overflow = 'hidden'; // firefox, chrome
document.body.scroll = "no"; // ie only

Just in case you wish to disable either just the horizontal or vertical scrollbar, this code works for non IE browsers

document.documentElement.style.overflowX = 'hidden'; // horizontal scrollbar will be hidden
document.documentElement.style.overflowY = 'hidden'; // vertical scrollbar will be hidden

Bluehost error: [an error occurred while processing this directive]


ISSUE RESOLVED:

For the benefit of anyone encountering a similar problem, try the steps that follow:

– Go to cPanel
– Open File Manager from Files section
– Navigate to domain folder
– Check “Perms” column on far right hand side
– Files should be set to: 0644 (this is the UNIX file permissions)
– Folders should be set to: 0755

This will change your file permissions to their proper settings for the Bluehost file system. Additionally, if you have PHP code within.htm or .html files, you will need to add an additional Apache handler to tell Bluehost to parse these files as PHP. Do this using Apache Handlers in cPanel:

HANDLER: application/x-httpd-php5s
EXTENSIONS: .php .htm .html

Opencart coupon history not working with Paypal


in catalog/model/checkout/coupon.php
change:

Code:

  public function getCoupon($code) {

to

Code:

 public function getCoupon($code,$noverify=0) {

AND change

Code:

       if ($status) {
             return array(

to

Code:

       if (($status)||($noverify)) {
             return array(

Next, in catalog/model/total/coupon.php in the confirm function right near the bottom change

Code:

    $coupon_info = $this->model_checkout_coupon->getCoupon($code);

to

Code:

    $coupon_info = $this->model_checkout_coupon->getCoupon($code,1);

Here is the VQMod xml file:

<?xml version="1.0" encoding="utf-8"?>
<modification>
<id>Fix Coupon Codes (so they register after using paypal or similar payment gateway)</id>
<version>1.0.0</version>
<vqmver>2.1.0</vqmver>
<author>Sanjoy Roy </author>
<file name="catalog/model/checkout/coupon.php">
<operation>
<search position="replace"><![CDATA[ public function getCoupon($code) { ]]></search>
<add><![CDATA[ public function getCoupon($code, $verify = true) { ]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[ if ($status) { ]]></search>
<add><![CDATA[ if ($status || $verify === false) { ]]></add>
</operation>
</file>

<file name="catalog/model/total/coupon.php">
<operation>
<search position="replace"><![CDATA[ $coupon_info = $this->model_checkout_coupon->getCoupon($code); ]]></search>
<add><![CDATA[ $coupon_info = $this->model_checkout_coupon->getCoupon($code, false); ]]></add>
</operation>
</file>
</modification>

Combining animation and ActionScript using Flash Professional CS5 and Flash Builder 4

Adobe Configuration Error 130:10


Configuration Error 130:10

How to bypass Apache password protected directories without showing popup login

.htaccess for CMSMS


 Options +FollowSymLinks
 DirectoryIndex index.htm index.html index.php
 Options -Indexes 
  order allow,deny
  deny from all 
 ErrorDocument 403 /forbidden403.shtml
 ServerSignature Off

.htaccess for creloaded or osCommerce root


Options +FollowSymLinks
DirectoryIndex index.htm index.html index.php
RewriteEngine On
# proc/self/environ? no way!
RewriteCond %{QUERY_STRING} proc/self/environ [OR]
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]
 
# Block out any script that includes a  tag in URL
RewriteCond %{QUERY_STRING} (|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
php_flag register_long_arrays On
php_flag register_globals On 
php_flag display_errors Off
php_value session.use_trans_sid 0
php_value register_globals 1
php_flag display_errors On
php_flag track_errors Off

www redirect issues Fix


How to change domain.com.au to http://www.domain.com.au?

if ($_SERVER['HTTP_HOST'] != 'www.domain.com.au') header('Location: http://www.domain.com.au' . $_SERVER['REQUEST_URI']);

If we use the cart, the cookies will be stored differently if we don’t use it. So, it will be always storing under domain http://www.domain.com.au. Applied for the client SHE Lights.

%d bloggers like this: