first checkin of wp_connect
authorgreg gay <ggay@ocad.ca>
Wed, 22 Jun 2011 20:36:26 +0000 (20:36 -0000)
committergreg gay <ggay@ocad.ca>
Wed, 22 Jun 2011 20:36:26 +0000 (20:36 -0000)
mods/wordpress/wp_connect.php [new file with mode: 0644]

diff --git a/mods/wordpress/wp_connect.php b/mods/wordpress/wp_connect.php
new file mode 100644 (file)
index 0000000..f220f37
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+// Wordpress database connection setup for atutor_wordpress integration module
+require('wp_config.php');
+global $db_wp;
+
+if (AT_INCLUDE_PATH !== 'NULL') {
+       $db_wp= @mysql_connect(WP_DB_HOST.':'.WP_DB_PORT, WP_DB_USER, WP_DB_PWD);       
+
+       if (!$db_wp) {
+               /* AT_ERROR_NO_DB_CONNECT */
+               require_once(AT_INCLUDE_PATH . 'classes/ErrorHandler/ErrorHandler.class.php');
+               $err = new ErrorHandler();
+               trigger_error('VITAL#Unable to connect to db. Set database information in the module\'s wp_config.php file.', E_USER_ERROR);
+               exit;
+       }
+       if (!@mysql_select_db(WP_DB_NAME, $db_wp)) {
+               require_once(AT_INCLUDE_PATH . 'classes/ErrorHandler/ErrorHandler.class.php');
+               $err = new ErrorHandler();
+               trigger_error('VITAL#DB connection established, but database "'.WP_DB_NAME.'" cannot be selected.',
+                                               E_USER_ERROR);
+               exit;
+       }
+
+}
+?>
\ No newline at end of file