Friday, March 16, 2012

Opencart Undefined index: scheme error

In opencart (version 1.5.2.1) you can get an error like
Undefined index: scheme ... 
if you activate the seo url feature from store settings (Server tab). However the solution is easy.

Open the file catalog/controller/common/seo_url.php and go to the line 110 (or the line number given in error you see for seo_url.php file ifdifferent than 110) change the line:

return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query;

with this:
return (isset($url_data['scheme'])?$url_data['scheme']:'http') . '://' . (isset($url_data['host'])?$url_data['host']:$_SERVER['HTTP_HOST'])  . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query;

After this change save the file and you shouln't see the error again and the seo urls should be working.

Thursday, March 15, 2012

.htaccess files dont work

If the .htaccess files in your server don't work for your web sites, first check the config file /etc/apache2/apache2.conf (location may vary for some distros) in your server to be sure if it has the following line:

AccessFileName .htaccess

After being sure this line exists, run the following command to edit your web host configuration file:

gksudo gedit /etc/apache2/sites-available/default

(You can also use sudo instead of gksudo if it causes an error.)

Than find the config group for your working directory (ie. the group regarding /var/www/) and check that the following line exists:

AllowOverride All

If there is None instead of All you should change it.

After saving the file restart apache server using this command:

sudo /etc/init.d/apache2 restart

The .htaccess files in your web directories should now be working.

Wednesday, March 14, 2012

Create random passwords in command line using apg (Automated Password Generator)

You may want to set random passwords for various purposes like creating new user accounts. There is a simple password generator command in linux that does this. The command is apg (Automated Password Generator) and some sample usages are:

apg
Creates passwords after entering random data from user input.

apg -y
Creates passwords including crypted text (i advise the crypted text since they seem more like passwords)

apg -c cl_seed
Creates passwords using cl_seed.

The information about this command is given below including options (type apg -h to get this output):

apg   Automated Password Generator
        Copyright (c) Adel I. Mirzazhanov
apg   [-a algorithm] [-r file]
      [-M mode] [-E char_string] [-n num_of_pass] [-m min_pass_len]
      [-x max_pass_len] [-c cl_seed] [-d] [-s] [-h] [-y] [-q]
-M mode         new style password modes
-E char_string  exclude characters from password generation process
-r file         apply dictionary check against file
-b filter_file  apply bloom filter check against filter_file
                (filter_file should be created with apgbfm(1) utility)
-p substr_len   paranoid modifier for bloom filter check
-a algorithm    choose algorithm
                 1 - random password generation according to
                     password modes
                 0 - pronounceable password generation
-n num_of_pass  generate num_of_pass passwords
-m min_pass_len minimum password length
-x max_pass_len maximum password length
-s              ask user for a random seed for password
                generation
-c cl_seed      use cl_seed as a random seed for password
-d              do NOT use any delimiters between generated passwords
-l              spell generated password
-t              print pronunciation for generated pronounceable password
-y              print crypted passwords
-q              quiet mode (do not print warnings)
-h              print this help screen
-v              print version information

Follow us on Twitter


After now you can also follow us on twitter:
@coding4web




Tuesday, March 13, 2012

Lost mysql root password

Here is a simple solution when you lose your mysql root password in your server.

Open console and switch directory to /var/lib/mysql/ (at least for my linux distro). Then add a file named as my.cnf to this folder. Edit the file and add these lines to the file:


[mysqld]
skip-grant-tables

Then restart the mysql server using this command:

/etc/init.d/mysql restart

After this you should -immediately if its a production server- set your root password for mysql and delete the file my.cnf previously mentioned. Then restart the mysql server again. After this everything should be working well for mysql.

Firebug extension

Firebug is a powerful extension for firefox that allows you to debug your web application on client side easily. It has many features regarding languages js, html, css and also any server requests including ajax calls. You can see and find the plugin at:

http://getfirebug.com/

Sunday, March 11, 2012

Json validation

If you use json data in your applications and sometimes need to check your syntax you can use the following service for this:

http://www.jsonlint.com

This service simply checks the given json data and checks if its valid or not. It also shows the lines with errors.