Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed Exceptions. DBException and DatabaseException didn't exist

  • Loading branch information...
commit 965d176cc556f9e978b02058cfaf6d8de5b44c18 1 parent f4f7bbf
@juanramon juanramon authored
View
2  item.php
@@ -212,7 +212,7 @@
);
osc_sendMail($params);
}
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('We are very sorry but could not save your comment. Try again later.'));
}
View
130 oc-admin/admins.php
@@ -26,75 +26,77 @@
$action = osc_readAction();
switch($action) {
- case 'add':
- osc_renderAdminSection('admins/add.php', __('Administrators'), __('Add'));
- break;
- case 'add_post':
- $_POST['s_password'] = sha1($_POST['s_password']);
- try {
- $adminManager->insert($_POST);
+ case 'add':
+ osc_renderAdminSection('admins/add.php', __('Administrators'), __('Add'));
+ break;
+ case 'add_post':
+ $_POST['s_password'] = sha1($_POST['s_password']);
+ try {
+ $adminManager->insert($_POST);
- osc_addFlashMessage(__('The item has been added.'));
- } catch (DatabaseException $e) {
- osc_addFlashMessage( __('The administrator could not be created.') . ' (' . $e->getMessage() . ')');
- }
- osc_redirectTo('admins.php');
- break;
- case 'edit':
- $admin = null;
- if(isset($_GET['id']))
- $adminEdit = $adminManager->findByPrimaryKey ($_GET['id']);
- elseif(isset($_SESSION['adminId']))
- $adminEdit = $adminManager->findByPrimaryKey($_SESSION['adminId']);
- osc_renderAdminSection('admins/edit.php', __('Administrators'), __('Edit'));
- break;
- case 'edit_post':
- $conditions = array('pk_i_id' => $_POST['id']);
- $admin = $adminManager->findByPrimaryKey($_POST['id']);
- unset($_POST['id']);
- if(empty($_POST['s_password'])) {
- unset($_POST['s_password']);
- } else {
- if(sha1($_POST['old_password'])==$admin['s_password']) {
- if($_POST['s_password']==$_POST['s_password2']) {
- $_POST['s_password'] = sha1($_POST['s_password']);
- } else {
- unset($_POST['s_password']);
- osc_addFlashMessage(__('Password didn\'t update. Passwords don\'t match.'));
- }
+ osc_addFlashMessage(__('The item has been added.'));
+ } catch (Exception $e) {
+ osc_addFlashMessage( __('The administrator could not be created.') . ' (' . $e->getMessage() . ')');
+ }
+ osc_redirectTo('admins.php');
+ break;
+ case 'edit':
+ $admin = null;
+ if(isset($_GET['id']))
+ $adminEdit = $adminManager->findByPrimaryKey ($_GET['id']);
+ elseif(isset($_SESSION['adminId']))
+ $adminEdit = $adminManager->findByPrimaryKey($_SESSION['adminId']);
+ osc_renderAdminSection('admins/edit.php', __('Administrators'), __('Edit'));
+ break;
+ case 'edit_post':
+ $conditions = array('pk_i_id' => $_POST['id']);
+ $admin = $adminManager->findByPrimaryKey($_POST['id']);
+ unset($_POST['id']);
+ if(empty($_POST['s_password'])) {
+ unset($_POST['s_password']);
+ } else {
+ if(sha1($_POST['old_password'])==$admin['s_password']) {
+ if($_POST['s_password']==$_POST['s_password2']) {
+ $_POST['s_password'] = sha1($_POST['s_password']);
} else {
unset($_POST['s_password']);
- osc_addFlashMessage(__('Password didn\'t update. "Old password" didn\'t match with our records in the database.'));
+ osc_addFlashMessage(__('Password didn\'t update. Passwords don\'t match.'));
}
+ } else {
+ unset($_POST['s_password']);
+ osc_addFlashMessage(__('Password didn\'t update. "Old password" didn\'t match with our records in the database.'));
}
- unset($_POST['old_password']);
- unset($_POST['s_password2']);
+ }
+ unset($_POST['old_password']);
+ unset($_POST['s_password2']);
- try {
- $adminManager->update($_POST, $conditions);
- } catch (DatabaseException $e) {
- osc_addFlashMessage( __('Error: ') . $e->getMessage());
+ try {
+ $adminManager->update($_POST, $conditions);
+ } catch (Exception $e) {
+ osc_addFlashMessage( __('Error: ') . $e->getMessage());
+ }
+ osc_redirectTo('admins.php');
+ break;
+ case 'delete':
+ $id = osc_paramRequest('id', false);
+ if($id) {
+ // Verification to avoid an administrator trying to remove to itself
+ if(in_array($_SESSION['adminId'], $id)) {
+ osc_addFlashMessage( __('The operation was not completed. You were trying to remove yourself!') );
+ } else {
+ try {
+ $adminManager->delete(array('pk_i_id IN (' . implode(', ', $id) . ')'));
+ } catch (Exception $e) {
+ osc_addFlashMessage( __('Error: ') . $e->getMessage());
+ }
}
- osc_redirectTo('admins.php');
- break;
- case 'delete':
- $id = osc_paramRequest('id', false);
- if($id) {
- // Verification to avoid an administrator trying to remove to itself
- if(in_array($_SESSION['adminId'], $id)) {
- osc_addFlashMessage( __('The operation was not completed. You were trying to remove yourself!') );
- } else {
- try {
- $adminManager->delete(array('pk_i_id IN (' . implode(', ', $id) . ')'));
- } catch (DatabaseException $e) {
- osc_addFlashMessage( __('Error: ') . $e->getMessage());
- }
- }
- }
- osc_redirectTo('admins.php');
- break;
- default:
- $admins = $adminManager->listAll();
+ }
+ osc_redirectTo('admins.php');
+ break;
+ default:
+ $admins = $adminManager->listAll();
+
+ osc_renderAdminSection('admins/index.php', __('Administrators'));
+}
- osc_renderAdminSection('admins/index.php', __('Administrators'));
-}
+?>
View
14 oc-admin/categories.php
@@ -52,7 +52,7 @@
$categoryManager->insert($fields, $aFieldsDescription);
osc_addFlashMessage(__('The category has been added.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('categories.php');
@@ -79,7 +79,7 @@
try {
$categoryManager->updateByPrimaryKey($fields, $aFieldsDescription, $id);
osc_addFlashMessage(__('The item has been updated.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
if( !is_null( $fields['fk_i_parent_id'] ) ) {
@@ -97,7 +97,7 @@
}
}
osc_addFlashMessage(__('The items have been deleted.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('categories.php');
@@ -117,7 +117,7 @@
$msg = __('There was a problem with this page. The ID for the category is not set.') ;
}
osc_addFlashMessage($msg) ;
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('categories.php');
@@ -132,7 +132,7 @@
}
}
osc_addFlashMessage(__('The categories have been enabled.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('categories.php');
@@ -147,7 +147,7 @@
}
}
osc_addFlashMessage(__('Selected categories have been disabled.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('categories.php');
@@ -170,4 +170,4 @@
osc_renderAdminSection('categories/index.php', __('Categories'));
}
-?>
+?>
View
223 oc-admin/comments.php
@@ -1,4 +1,5 @@
<?php
+
/*
* OSCLass – software for creating and publishing online classified
* advertising platforms
@@ -24,133 +25,111 @@
$manager = ItemComment::newInstance();
$action = osc_readAction();
-switch($action) {
-
-
-
- case 'bulk_actions':
-
- switch($_POST['bulk_actions']) {
- case 'delete_all':
- $id = osc_paramRequest('id', false);
- try {
- if($id) {
- $manager->delete(array(
- DB_CUSTOM_COND => 'pk_i_id IN (' . implode(', ', $id). ')'
- ));
- }
- osc_addFlashMessage( __('The comments have been deleted.') );
- } catch (DatabaseException $e) {
- osc_addFlashMessage( __('Error: ') . $e->getMessage());
- }
- break;
-
- case 'activate_all':
- $id = osc_paramRequest('id', false);
- $value = 'ACTIVE';
- try {
- if($id) {
- foreach($id as $_id) {
- $manager->update(
- array('e_status' => $value),
- array('pk_i_id' => $_id)
- );
- }
- }
- osc_addFlashMessage( __('The comments have been activated.') );
- } catch (DatabaseException $e) {
- osc_addFlashMessage( __('Error: ') . $e->getMessage());
- }
- break;
-
- case 'deactivate_all':
- $id = osc_paramRequest('id', false);
- $value = 'INACTIVE';
- try {
- if($id) {
- foreach($id as $_id) {
- $manager->update(
- array('e_status' => $value),
- array('pk_i_id' => $_id)
- );
- }
- }
- osc_addFlashMessage( __('The comments have been deactivated.') );
- } catch (DatabaseException $e) {
- osc_addFlashMessage( __('Error: ') . $e->getMessage());
- }
- break;
-
- }
- osc_redirectTo('comments.php');
- break;
-
- case 'status':
- $id = osc_paramRequest('id', false);
- $value = osc_paramRequest('value', false);
-
- if(!$id)
- return false;
+switch ($action) {
+ case 'bulk_actions':
+ switch ($_POST['bulk_actions']) {
+ case 'delete_all':
+ $id = osc_paramRequest('id', false);
+ try {
+ if ($id) {
+ $manager->delete(array(
+ DB_CUSTOM_COND => 'pk_i_id IN (' . implode(', ', $id) . ')'
+ ));
+ }
+ osc_addFlashMessage(__('The comments have been deleted.'));
+ } catch (Exception $e) {
+ osc_addFlashMessage(__('Error: ') . $e->getMessage());
+ }
+ break;
+
+ case 'activate_all':
+ $id = osc_paramRequest('id', false);
+ $value = 'ACTIVE';
+ try {
+ if ($id) {
+ foreach ($id as $_id) {
+ $manager->update(
+ array('e_status' => $value),
+ array('pk_i_id' => $_id)
+ );
+ }
+ }
+ osc_addFlashMessage(__('The comments have been activated.'));
+ } catch (Exception $e) {
+ osc_addFlashMessage(__('Error: ') . $e->getMessage());
+ }
+ break;
+
+ case 'deactivate_all':
+ $id = osc_paramRequest('id', false);
+ $value = 'INACTIVE';
+ try {
+ if ($id) {
+ foreach ($id as $_id) {
+ $manager->update(
+ array('e_status' => $value),
+ array('pk_i_id' => $_id)
+ );
+ }
+ }
+ osc_addFlashMessage(__('The comments have been deactivated.'));
+ } catch (Exception $e) {
+ osc_addFlashMessage(__('Error: ') . $e->getMessage());
+ }
+ break;
+ }
+ osc_redirectTo('comments.php');
+ break;
- $id = (int) $id;
+ case 'status':
+ $id = osc_paramRequest('id', false);
+ $value = osc_paramRequest('value', false);
- if(!is_numeric($id))
- return false;
+ if (!$id) return false;
+ $id = (int) $id;
+ if (!is_numeric($id)) return false;
+ if (!in_array($value, array('ACTIVE', 'INACTIVE'))) return false;
- if(!in_array($value,array('ACTIVE','INACTIVE')))
- return false;
-
- try {
- $manager->update(
+ try {
+ $manager->update(
array('e_status' => $value),
array('pk_i_id' => $id)
- );
- osc_addFlashMessage( __('The comment has been activate.') );
- } catch (DatabaseException $e) {
- osc_addFlashMessage( __('Error: ') . $e->getMessage());
- }
- osc_redirectTo('comments.php');
- break;
-
-
-
- case 'comment_edit':
- $itemId = null;
-
- if(isset($_REQUEST['id']) && !empty($_REQUEST['id']))
- $itemId = $_GET['id'];
-
- $comment = Comment::newInstance()->findByPrimaryKey($itemId);
- osc_renderAdminSection('comments/comment_edit.php', __('Comments'));
- break;
-
- case 'comment_edit_post':
-
- import_request_variables('p', 'P');
- $manager->update(array(
- 's_title' => $Ptitle,
- 's_body' => $Pbody,
- 's_author_name' => $PauthorName,
- 's_author_email' => $PauthorEmail
- ), array('pk_i_id' => $Pid));
-
-
- osc_runHook('item_edit_post');
-
- osc_addFlashMessage(__('Great! We\'ve just update your item.'));
+ );
+ osc_addFlashMessage(__('The comment has been activate.'));
+ } catch (Exception $e) {
+ osc_addFlashMessage(__('Error: ') . $e->getMessage());
+ }
osc_redirectTo('comments.php');
- break;
-
- case 'delete':
- $manager->deleteByID($_GET['id']);
- default:
- $itemId = null;
-
- if(isset($_REQUEST['id']) && !empty($_REQUEST['id']))
- $itemId = $_GET['id'];
-
- !is_null($itemId) ? $comments = $manager->getAllComments($itemId) : $comments = $manager->getAllComments();
- osc_renderAdminSection('comments/index.php', __('Comments'));
+ break;
+ case 'comment_edit':
+ $itemId = null;
+
+ if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) $itemId = $_GET['id'];
+
+ $comment = Comment::newInstance()->findByPrimaryKey($itemId);
+ osc_renderAdminSection('comments/comment_edit.php', __('Comments'));
+ break;
+ case 'comment_edit_post':
+ import_request_variables('p', 'P');
+ $manager->update(array(
+ 's_title' => $Ptitle,
+ 's_body' => $Pbody,
+ 's_author_name' => $PauthorName,
+ 's_author_email' => $PauthorEmail
+ ), array('pk_i_id' => $Pid));
+
+ osc_runHook('item_edit_post');
+
+ osc_addFlashMessage(__('Great! We\'ve just update your item.'));
+ osc_redirectTo('comments.php');
+ break;
+ case 'delete':
+ $manager->deleteByID($_GET['id']);
+ default:
+ $itemId = null;
+
+ if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) $itemId = $_GET['id'];
+ !is_null($itemId) ? $comments = $manager->getAllComments($itemId) : $comments = $manager->getAllComments();
+ osc_renderAdminSection('comments/index.php', __('Comments'));
}
-
?>
View
14 oc-admin/items.php
@@ -44,7 +44,7 @@
}
}
osc_addFlashMessage(__('The items have been activated.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
break;
@@ -64,7 +64,7 @@
}
}
osc_addFlashMessage(__('The items have been deactivated.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
break;
@@ -82,7 +82,7 @@
}
}
osc_addFlashMessage(__('The items have been made premium.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
break;
@@ -101,7 +101,7 @@
}
}
osc_addFlashMessage(__('The chages have been made.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
break;
@@ -122,7 +122,7 @@
}
}
osc_addFlashMessage(__('The items have been deleted.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('items.php');
@@ -161,7 +161,7 @@
}
osc_addFlashMessage(__('The item has been activate.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('items.php');
@@ -188,7 +188,7 @@
array('pk_i_id' => $id)
);
osc_addFlashMessage(__('Changes have been made.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('items.php');
View
4 oc-admin/languages.php
@@ -76,7 +76,7 @@
osc_addFlashMessage(__('There was a problem updating the language. The ID of the language was lost.'));
}
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('languages.php');
@@ -112,7 +112,7 @@
osc_addFlashMessage(__('There was a problem updating the languages. The IDs of the languages were lost.'));
}
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('languages.php');
View
6 oc-admin/pages.php
@@ -62,7 +62,7 @@
$pageManager->deleteDraft($_REQUEST['id']);
osc_addFlashMessage( __('The page has been updated.') );
}
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage( __('Error: ') . $e->getMessage() );
}
osc_redirectTo('pages.php');
@@ -79,7 +79,7 @@
}
}
osc_addFlashMessage(__('The items have been deleted.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage( __('Error: ') . $e->getMessage());
}
osc_redirectTo('pages.php');
@@ -124,7 +124,7 @@
osc_addFlashMessage(__('Ops! That internal name is already in use. We couldn\'t made the changes.'));
}
}
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
default:
View
4 oc-admin/settings.php
@@ -176,7 +176,7 @@
case 'addCurrency_post':
try {
Currency::newInstance()->insert($_POST);
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage($e->getMessage());
}
osc_redirectTo('settings.php?action=currencies');
@@ -192,7 +192,7 @@
case 'editCurrency_post':
try {
Currency::newInstance()->update(array('s_name' => $_POST['s_name'], 's_description' => $_POST['s_description']), array('pk_c_code' => $_POST['pk_c_code']));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage($e->getMessage());
}
osc_redirectTo('settings.php?action=currencies');
View
8 oc-admin/users.php
@@ -34,7 +34,7 @@
try {
$userManager->insert($_POST);
osc_addFlashMessage(__('The item has been added.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('users.php');
@@ -58,7 +58,7 @@
try {
$userManager->update($_POST, $conditions);
osc_addFlashMessage(__('The user has been updated.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('users.php');
@@ -70,7 +70,7 @@
try {
$userManager->update($values, $conditions);
osc_addFlashMessage(__('The user has been deactivated.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
}
@@ -83,7 +83,7 @@
try {
$userManager->update($values, $conditions);
osc_addFlashMessage(__('The user has been deactivated.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
}
View
4 oc-content/plugins/cars_attributes/index.php
@@ -58,7 +58,7 @@ function cars_call_after_install() {
$sql = file_get_contents($path);
$conn->osc_dbImportSQL($sql);
$conn->commit();
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
$conn->rollback();
echo $e->getMessage();
}
@@ -81,7 +81,7 @@ function cars_call_after_uninstall() {
$conn->osc_dbExec('DROP TABLE %st_item_car_make_attr', DB_TABLE_PREFIX);
$conn->osc_dbExec('DROP TABLE %st_item_car_vehicle_type_attr', DB_TABLE_PREFIX);
$conn->commit();
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
$conn->rollback();
echo $e->getMessage();
}
View
4 oc-content/plugins/dating_attributes/index.php
@@ -59,7 +59,7 @@ function dating_call_after_install() {
$sql = file_get_contents($path);
$conn->osc_dbImportSQL($sql);
$conn->commit();
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
$conn->rollback();
echo $e->getMessage();
}
@@ -77,7 +77,7 @@ function dating_call_after_uninstall() {
$conn->osc_dbExec("DELETE FROM %st_plugin_category WHERE s_plugin_name = 'dating_plugin'", DB_TABLE_PREFIX);
$conn->osc_dbExec('DROP TABLE %st_item_dating_attr', DB_TABLE_PREFIX);
$conn->commit();
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
$conn->rollback();
echo $e->getMessage();
}
View
4 oc-content/plugins/jobs_attributes/index.php
@@ -76,7 +76,7 @@ function job_call_after_install() {
$sql = file_get_contents($path);
$conn->osc_dbImportSQL($sql);
$conn->commit();
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
$conn->rollback();
echo $e->getMessage();
}
@@ -95,7 +95,7 @@ function job_call_after_uninstall() {
$conn->osc_dbExec('DROP TABLE %st_item_job_description_attr', DB_TABLE_PREFIX);
$conn->osc_dbExec('DROP TABLE %st_item_job_attr', DB_TABLE_PREFIX);
$conn->commit();
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
$conn->rollback();
echo $e->getMessage();
}
View
4 oc-content/plugins/products_attributes/index.php
@@ -55,7 +55,7 @@ function products_call_after_install() {
$sql = file_get_contents($path);
$conn->osc_dbImportSQL($sql);
$conn->commit();
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
$conn->rollback();
echo $e->getMessage();
}
@@ -73,7 +73,7 @@ function products_call_after_uninstall() {
$conn->osc_dbExec("DELETE FROM %st_plugin_category WHERE s_plugin_name = 'products_plugin'", DB_TABLE_PREFIX);
$conn->osc_dbExec('DROP TABLE %st_item_products_attr', DB_TABLE_PREFIX);
$conn->commit();
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
$conn->rollback();
echo $e->getMessage();
}
View
4 oc-content/plugins/realstate_attributes/index.php
@@ -139,7 +139,7 @@ function realstate_call_after_install() {
$sql = file_get_contents($path);
$conn->osc_dbImportSQL($sql);
$conn->commit();
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
$conn->rollback();
echo $e->getMessage();
}
@@ -158,7 +158,7 @@ function realstate_call_after_uninstall() {
$conn->osc_dbExec('DROP TABLE %st_item_house_description_attr', DB_TABLE_PREFIX);
$conn->osc_dbExec('DROP TABLE %st_item_house_property_type_attr', DB_TABLE_PREFIX);
$conn->commit();
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
$conn->rollback();
echo $e->getMessage();
}
View
9 oc-includes/osclass/db.php
@@ -22,6 +22,8 @@
class DB
{
private $db = null ;
+ private $db_errno = 0;
+ private $db_error = 0;
private $dbHost = null ;
private $dbUser = null ;
private $dbPassword = null ;
@@ -80,6 +82,7 @@ function osc_dbConnect() {
$this->db = @new mysqli($this->dbHost, $this->dbUser, $this->dbPassword, $this->dbName);
if ($this->db->connect_error) {
$this->debug('Error connecting to \'' . $this->dbName . '\' (' . $this->db->connect_errno . ': ' . $this->db->connect_error . ')', false) ;
+ if ( $this->dbLogLevel == LOG_NONE ) throw new Exception( $this->db->connect_errno );
}
$this->debug('Connected to \'' . $this->dbName . '\': [DBHOST] = ' . $this->dbHost . ' | [DBUSER] = ' . $this->dbUser . ' | [DBPWD] = ' . $this->dbPassword) ;
@@ -121,6 +124,7 @@ function osc_dbExec()
$result = $this->db->query($sql);
if(!$result) {
$this->debug($sql . ' | ' . $this->db->error . ' (' . $this->db->errno . ')', false) ;
+ if ( $this->dbLogLevel == LOG_NONE ) throw new Exception( $this->db->errno );
} else {
$this->debug($sql) ;
}
@@ -149,6 +153,7 @@ function osc_dbFetchValue() {
$qry->free();
} else {
$this->debug($sql . ' | ' . $this->db->error . ' (' . $this->db->errno . ')', false) ;
+ if ( $this->dbLogLevel == LOG_NONE ) throw new Exception( $this->db->errno );
}
return $result;
@@ -178,6 +183,7 @@ function osc_dbFetchValues() {
$qry->free();
} else {
$this->debug($sql . ' | ' . $this->db->error . ' (' . $this->db->errno . ')', false) ;
+ if ( $this->dbLogLevel == LOG_NONE ) throw new Exception( $this->db->errno );
}
return $results;
}
@@ -203,6 +209,7 @@ function osc_dbFetchResult() {
$qry->free();
} else {
$this->debug($sql . ' | ' . $this->db->error . ' (' . $this->db->errno . ')', false) ;
+ if ( $this->dbLogLevel == LOG_NONE ) throw new Exception( $this->db->errno );
}
return $result;
@@ -229,6 +236,7 @@ function osc_dbFetchResults() {
$qry->free();
} else {
$this->debug($sql . ' | ' . $this->db->error . ' (' . $this->db->errno . ')', false) ;
+ if ( $this->dbLogLevel == LOG_NONE ) throw new Exception( $this->db->errno );
}
return $results;
@@ -248,6 +256,7 @@ function osc_dbImportSQL($sql, $needle = '')
$this->debug($s) ;
} else {
$this->debug($s . ' | ' . $this->db->error . ' (' . $this->db->errno . ')', false) ;
+ if ( $this->dbLogLevel == LOG_NONE ) throw new Exception( $this->db->errno );
}
}
}
View
10 oc-includes/osclass/plugins.php
@@ -150,7 +150,7 @@ function osc_loadActivePlugins() {
}
}
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
echo $e->getMessage();
}
}
@@ -169,7 +169,7 @@ function osc_listInstalledPlugins() {
}
}
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
echo $e->getMessage();
}
@@ -214,7 +214,7 @@ function osc_activatePlugin($path) {
} else {
echo "Error: Plugin already installed." ;
}
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
$conn->rollback();
echo $e->getMessage();
}
@@ -263,7 +263,7 @@ function osc_activatePluginHook($path) {
} else {
echo "Error: Plugin already installed.";
}
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
$conn->rollback();
echo $e->getMessage();
}
@@ -299,7 +299,7 @@ function osc_deactivatePlugin($path)
unset($data);
$conn->commit();
}
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
$conn->rollback();
echo $e->getMessage();
}
View
10 oc-installer/index.php
@@ -57,7 +57,7 @@ function oc_install()
$master_conn = getConnection($dbhost, $adminuser, $adminpwd, 'mysql', DEBUG_LEVEL) ;
$master_conn->osc_dbExec(sprintf("CREATE DATABASE IF NOT EXISTS %s DEFAULT CHARACTER SET 'UTF8' COLLATE 'UTF8_GENERAL_CI'", $dbname)) ;
} catch (Exception $e) {
- $error_num = $e->getErrno();
+ $error_num = $e->getMessage();
if($error_num == 1006 || $error_num == 1044 || $error_num == 1045) {
return array('error' => 'Cannot create the database. Check if the admin username and password are correct.');
}
@@ -68,14 +68,14 @@ function oc_install()
try {
$conn = getConnection($dbhost, $username, $password, $dbname, DEBUG_LEVEL) ;
} catch (Exception $e) {
- $error_num = $e->getErrno();
+ $error_num = $e->getMessage();
if( $error_num == 1049 ) return array('error' => 'The database doesn\'t exist. You should check the "Create DB" checkbox and fill username and password with the right privileges');
if ( $error_num == 1045 ) return array('error' => 'Cannot connect to the database. Check if the user has privileges.');
if ( $error_num == 1044 ) return array('error' => 'Cannot connect to the database. Check if the username and password are correct.');
return array('error' => 'Cannot connect to database. Unknown error.');
}
-
+ die();
$abs_url = osc_getAbsoluteWebURL();
$rel_url = osc_getRelativeWebURL();
@@ -204,7 +204,7 @@ function oc_install()
$sql = file_get_contents('data/struct.sql');
$conn->osc_dbImportSQL($sql);
} catch (Exception $e) {
- $error_num = $e->getErrno();
+ $error_num = $e->getMessage();
if ( $error_num == 1050 ) {
return array('error' => 'There are tables with the same name in the database. Change the table prefix or the database and try again.');
}
@@ -248,7 +248,7 @@ function oc_install()
$conn->osc_dbImportSQL($sql, ')');
} catch (Exception $e) {
- $error_num = $e->getErrno();
+ $error_num = $e->getMessage();
if ( $error_num == 1471 ) {
return array('error' => 'Cannot insert basic configuration. This user has no privileges to \'INSERT\' into the database.');
}
View
4 user.php
@@ -105,7 +105,7 @@
osc_addFlashMessage(__('Sorry, but that username is already in use.'));
osc_redirectTo(osc_createRegisterURL());//'user.php?action=register');
}
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('The user could not be registered, sorry.'));
}
osc_redirectTo('index.php');
@@ -138,7 +138,7 @@
}
osc_addFlashMessage(__('We resend you the validation email. If you don\'t recive it after a few minutes, please check your SPAM folder.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('The email couldn\'t be sent, sorry.'));
}
}

0 comments on commit 965d176

Please sign in to comment.
Something went wrong with that request. Please try again.