Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

WordPress MySQL SSL dropin. Place in wp-content/db.php

By: a guest on Feb 26th, 2012  |  syntax: PHP  |  size: 1.68 KB  |  views: 114  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. class dd32_wpdb_ssl extends wpdb {
  4.         /**
  5.          * Connect to and select database
  6.          * This is a COPY of the WordPress function as of r19773
  7.          * Alteration: Adds the MySQL SSL arg.
  8.          */
  9.         function db_connect() {
  10.  
  11.                 $this->is_mysql = true;
  12.  
  13.                 if ( WP_DEBUG ) {
  14.                         $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, true, MYSQL_CLIENT_SSL );
  15.                 } else {
  16.                         $this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, true, MYSQL_CLIENT_SSL );
  17.                 }
  18.  
  19.                 if ( !$this->dbh ) {
  20.                         if ( ! function_exists( 'wp_load_translations_early' ) ) // only 3.4+ gets the wonderful error messages, everyone else, you just die
  21.                                 die( 'Error establishing database connection. Goodbye.' );
  22.  
  23.                         $this->bail( sprintf( __( "
  24. <h1>Error establishing a database connection</h1>
  25. <p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>%s</code>. This could mean your host's database server is down.</p>
  26. <ul>
  27.         <li>Are you sure you have the correct username and password?</li>
  28.         <li>Are you sure that you have typed the correct hostname?</li>
  29.         <li>Are you sure that the database server is running?</li>
  30. </ul>
  31. <p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p>
  32. " ), $this->dbhost ), 'db_connect_fail' );
  33.  
  34.                         return;
  35.                 }
  36.  
  37.                 $this->set_charset( $this->dbh );
  38.  
  39.                 $this->ready = true;
  40.  
  41.                 $this->select( $this->dbname, $this->dbh );
  42.         }
  43. }
  44. $wpdb = new dd32_wpdb_ssl( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );