Use multiple databases in OpenCart

Use multiple databases in OpenCart

To use multiple databases in OpenCart (1.5.*), just update 3 files as given below:

  1. Config.php:
    Add:

     //New DB

    define(‘NEWDB_DRIVER’, ‘mysql’);
    define(‘NEWDB_HOSTNAME’, ‘localhost’);
    define(‘NEWDB_USERNAME’, ‘root’);
    define(‘NEWDB_PASSWORD’, ‘password’);
    define(‘NEWDB_DATABASE’, ‘sitename_newdb’);
    define(‘NEWDB_PREFIX’, ‘ndb’);
  2. Index.php:
    Below the current database setup ($db = new DB(DB_DRIVER …) add:

     $newdb = new DB(NEWDB_DRIVER, NEWDB_HOSTNAME, NEWDB_USERNAME, NEWDB_PASSWORD, NEWDB_DATABASE);

    $registry->set(‘newdb’, $newdb );
  3. system/database/mysql.php:
    Modify:

     change:

    if (!$this->link = mysql_connect($hostname, $username, $password)) {
    to:
    if (!$this->link = mysql_connect($hostname, $username, $password, true)) {

After these above steps we can access the new database by:

$this->newdb->query("SELECT * FROM ". NEWDB_PREFIX . "users");

multiple database connection in laravel

multiple database connection in laravel

.env file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database1 //database first
DB_DATABASE_OPENCART=database2    // database second
DB_USERNAME=root
DB_PASSWORD=aaaa@#2233

config/database

‘mysql’ => [
‘driver’ => ‘mysql’,
‘host’ => env(‘DB_HOST’, ‘localhost’),
‘port’ => env(‘DB_PORT’, ‘3306’),
‘database’ => env(‘DB_DATABASE’, ‘database1’),
‘username’ => env(‘DB_USERNAME’, ‘root’),
‘password’ => env(‘DB_PASSWORD’, ‘aaaa@#2233’),
‘charset’ => ‘utf8’,
‘collation’ => ‘utf8_unicode_ci’,
‘prefix’ => ”,
‘strict’ => false,
‘engine’ => null,
],
‘opencart’ => [
‘driver’ => ‘mysql’,
‘host’ => env(‘DB_HOST’, ‘localhost’),
‘port’ => env(‘DB_PORT’, ‘3306’),
‘database’ => env(‘DB_DATABASE_OPENCART’, ‘database2’),
‘username’ => env(‘DB_USERNAME’, ‘root’),
‘password’ => env(‘DB_PASSWORD’, ‘aaaa@#2233’),
‘charset’ => ‘utf8’,
‘collation’ => ‘utf8_unicode_ci’,
‘prefix’ => ”,
‘strict’ => false,
‘engine’ => null,
],

In Controller file

$db_ext = DB::connection(‘opencart’);
$countries = $db_ext->table(‘fit_cart’)->get();
print_r($countries);

HOW TO DOWNGRADE WORDPRESS TO A PREVIOUS VERSION

HOW TO DOWNGRADE WORDPRESS TO A PREVIOUS VERSION

Have you ever updated to the newest version of WordPress, and then noticed that your site starts to have a bunch of problems? Don’t freak out. A lot of the times, it’s an issue with a plugin or theme that’s not compatible with the newest update. Sometimes (rarely) there’s an issue with the WordPress update itself. Whatever the case, one of of the quickest solutions to bring your site back to normal is to downgrade WordPress back to the previous version.

Compatibility issues are one of the reasons I try to avoid plugins and themes that don’t get updated regularly. I don’t want to be stuck with an older version of WordPress just because one of my plugins or themes doesn’t work with the latest update. Before you go through the process of downgrading, I’d suggest checking to see if a plugin is what’s causing the issue. If it is, you can just disable the plugin until there’s an update for it. If it’s a problem with the theme though, that’s an entirely different story. That’s when you’ll want to consider downgrading your version of WordPress.

Before you downgrade, I’d highly recommend making sure you have a backup of your site just in case things don’t go as planned and everything gets screwed up. I’ve never run into an issue but I always have the feeling that the one time I downgrade and my site goes berserk, I won’t have a backup. There are tons of backup plugins for WordPress and your web host might/should be able to provide you with the latest backup they have.
The first thing you’re going to need is a previous WordPress release. You can download any of the previous WordPress versions here –> WordPress releases. Only downgrade down to the version before the newest one. Don’t go way back into the archives to version 1.1. Some of the older versions of WordPress have security issues that could put your site at risk.

Here’s how to downgrade WordPress to an older version.

MANUAL WORDPRESS DOWNGRADE TUTORIAL

STEP 1: DEACTIVATE ALL YOUR PLUGINS

After you’ve created a backup of your site and downloaded the WordPress version you want to downgrade to, it’s time to actually downgrade. The first thing you want to do is login to your WP Dashboard and deactivate all of your plugins.

Deactivate All WordPress plugins

STEP 2: LOGOUT OF WORDPRESS

After all your plugins have been deactivated, logout of WordPress.

STEP 3: USE AN FTP CLIENT AND LOCATE YOUR SITE’S WORDPRESS FILES

This step will require that you have an FTP client. An FTP client allows you to access all of the files on your site. I use FireFTP from Firefox and FileZilla is another very popular option. Both are free and you can’t go wrong with either. The images in this tutorial are from FireFTP. In your FTP client, locate your WordPress files (wp-admin, wp-content, etc.). In FireFTP, they will be the first thing you see when you open your site’s folder.

STEP 4: DELETE THE WP-ADMIN AND WP-INCLUDES FOLDERS

Delete both the wp-admin and wp-includes folders. Do not touch the wp-content folder! You can leave all of the other files alone because you will overwrite them in the next step.

how to downgrade wordpress step 4

STEP 5: TRANSFER THE FILES FROM THE PREVIOUS WP VERSION TO YOUR SITE WITH FTP

While you’re still in your FTP client, go into the folder where you have the WordPress version you want to downgrade to. Transfer over everything except the wp-contentfolder. After all the files have been transferred, your downgrade is finished.

how to downgrade wordpress step 5

STEP 6: UPDATE YOUR WORDPRESS DATABASE

Login to your WP Dashboard. You will be prompted to update your WordPress database. Click on “Update WordPress Database” and then click continue to login.

update wordpress database

Once you’re logged in, you should see that you’re running whatever version of WordPress that you downgraded to. Congrats!

A word of caution. I don’t recommend using older versions of WordPress when newer ones are available. Like I said in the beginning, a lot of the updates come with security patches to stop known security threats that could leave your site open to hackers.

If your theme isn’t compatible with the most current version of WordPress, contact the theme developer and let them know. If there’s no support offered for your theme, then you’ll want to switch to a different one that’s updated on a regular basis.

I hope you found my guide helpful. If you have any questions, feel free to leave a comment below!

Converting .pfx to a .crt/.key files

Converting .pfx to a .crt/.key files

This article will walk a user through the process of converting a .pfx file to a .crt and .key file so that the SSL certificate can be uploaded into the StackPath control panel.

.pfx file is a PKCS#12 archive: a file that can contain a lot of objects with optional password protection; but, usually, a PKCS#12 archive has  a certificate (possibly with its assorted set of CA certificates) attached to it  and the corresponding private key.

Thats how .crt or .cer files differ from .pfx files – they contain a single certificate file, without any keys attached.

The StackPath portal requires that you upload the certificate and key in their separate corresponding fields and this is how you can extract them from your .pfx file.

Navigate to the terminal of your operating system and execute the following commands to extract the files:

Certificate:

{code}

openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]

{code}

Key:

{code}

openssl rsa -in [keyfile-encrypted.key] -out [keyfile-decrypted.key]

{code}

These two commands will generate two separate files which you can later use in your Stackpath SSL configuration.

5 Ways to Check Your Sending Reputation

5 Ways to Check Your Sending Reputation

We always stress the importance of a strong sending reputation. By keeping an eye on your engagement (opens, clicks TiNs, etc.) and reputation (spam complaints, spam traps, unknown users, etc.) metrics you’ll get a good picture of how your emails are being received by subscribers.

But if you’re looking for another measure of your reputation, you can take advantage of a handful of resources that will let you know where you stand. Here are 5 sites that will help you check your sending reputation and keep you on track:

  1. SenderScore.org

Like a credit score, a Sender Score is a measure of your reputation. Scores are calculated from 0 to 100. The higher your score, the better your reputation and the higher your email deliverability rate. Numbers are calculated on a rolling 30-day average and illustrate where your IP address ranks against other IP addresses. This service is provided by Return Path.

  1. Senderbase.org

Senderbase is a product of Cisco and provides you with the tools to check your reputation by ranking you as GoodNeutral, or Poor. Good means there is little or no threat activity. Neutral means your IP address or domain is within acceptable parameters, but may still be filtered or blocked. Poor means there is a problematic level of threat activity and you are likely to be filtered or blocked.

  1. ReputationAuthority

WatchGuard’s ReputationAuthority helps protect business and government organizations from unwanted email and web traffic that contain spam, malware, spyware, malicious code, and phishing attacks. You can look up your IP address or domain, receive a reputation score from 0-100, and get the percentage of emails that were good versus bad.

IP lookup for ReputationAuthority

  1. BarracudaCentral

Barracuda Networks provides both an IP and domain reputation lookup via their Barracuda Reputation System; a real-time database of IP addresses with “poor” or “good” reputations.

  1. TrustedSource


TrustedSource is a site very similar to senderbase.org, but run by McAfee. It provides information on both your domain’s email and web reputations as well as affiliations, domain name system (DNS), and mail server information. It also provides details on the history, activation, and associations of your domain.

Takeaways

Your email reputation is always in your control. By taking advantage of these resources, you can ensure that you’re being proactive about your email deliverability. But our delivery team likes to emphasize that while these reputation monitoring systems are a great help, they are not the authoritative metric by which you should determine the health of your entire email program.

They are best used as one data point (an important one) in an overarching holistic assessment of your email program. It is not uncommon to see senders with SenderScores around 98-99 that are still having inboxing problems, so it’s important to know that just because you get a high score on one of these sites, it doesn’t mean you won’t be getting throttled, sent to the spam folder, or blocked outright. So the more eyes and ears you can have on your IP and domain reputation the better.

.htaccess useful tricks

.htaccess useful tricks

RewriteEngine on

#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

#RewriteEngine On

#RewriteCond %{HTTPS} !=on

#RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

ErrorDocument 404 /index.php

#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

How to convert a PFX to a seperate .key/.crt file

How to convert a PFX to a seperate .key/.crt file

In this article will show you the commands you need to convert your .PFX Certificate file to a seperate certificate and keyfile. This article can come in handy when you need to import your certificates on devices like Cisco routers/loadbalancers etc. where you probably need to import the certificates and keyfiles in plain text (unencrypted). Tool of choice (but there might be others) is OpenSSL for Windows, which can be downloaded here.

  1. Installed OpenSSL – start it from it’s Bin folder.
  2. Start command prompt and cd to the folder that contains your .pfx file.
  3. First type the first command to extract the private key:openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]

      What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.
  4. Extract the certificate:openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]
    Just press enter and your certificate appears.
  5. Now as I mentioned in the intro of this article you sometimes need to have an unencrypted .key file to import on some devices. I probably don’t need to mention that you should be carefully. If you store your unencrypted keypair somewhere on an unsafe location anyone can have a go with it and impersonate for instance a website or a person of your company. So always be extra careful when it comes to private keys! Just throw the unencrypted keyfile away when you’re done with it, saving just the encrypted one.The command: openssl rsa -in [keyfile-encrypted.key] -out [keyfile-decrypted.key] Again you need to enter an import password. This time you need to enter the new password that you created in step 1. After that you’re done. You decrypted your private key. In the folder you ran OpenSSL from you’ll find the certifcate (.crt) and the two private keys (encrypted and unencrypted).

In some cases you might be forced to convert your private key to PEM format. You can do so with the following command:

openssl rsa -in [keyfile-encrypted.key] -outform PEM -out [keyfile-encrypted-pem.key]

.htaccess to hide extension for both html and php files

.htaccess to hide extension for both html and php

<IfModule mod_rewrite.c>

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.website.com/$1 [R,L]

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.html -f 
RewriteRule ^(.*)$ $1.html

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php

</IfModule>

List of Sql Injection code strings

List of Sql Injection code strings

‘ or 1=1–

” or 1=1–

or 1=1–

‘ or ‘a’=’a

” or “a”=”a

‘) or (‘a’=’a

“) or (“a”=”a