function m_eventHandler() { if (!isset($this->request['action'])) { $this->request['action'] = ""; } $action = explode(".", $this->request['action']); if (!isset($action[1])) { $action[1] = ""; } $this->libFunc = new c_libFunctions(); $obUserInterface = new c_userInterface(); $obUserInterface->obTpl =& $this->obTpl; $obUserInterface->obDb = $this->obDb; $obUserInterface->request = $this->request; switch ($action[0]) { case "user": $obUserDb = new c_userDb(); $obUserDb->obDb = $this->obDb; $obUserDb->request = $this->request; switch ($action[1]) { case "loginForm": //$_SESSION['referer']=$_SERVER['HTTP_REFERER']; $obUserInterface->userTemplate = $this->templatePath . "loginForm.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", " » Customer Login"); $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_loginForm()); break; case "home": $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "user/index.php?action=user.home"); $_SESSION['referer'] = $retUrl; $this->libFunc->authenticate(); unset($_SESSION['referer']); // $this->obTpl->set_var("TPL_VAR_BREDCRUMBS"," » My Account"); $obUserInterface->userTemplate = $this->templatePath . "userAccount.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_dspUserAccount()); break; case "checkLogin": if ($obUserInterface->m_checkLogin() == 1) { $obUserInterface->userTemplate = $this->templatePath . "loginForm.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", " » Customer Login"); $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_loginForm()); } else { if (isset($_SESSION['referer'])) { header("Location:" . $_SESSION['referer']); exit; } else { $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "index.php"); header("Location:" . $retUrl); exit; } } break; case "update": if ($obUserInterface->m_verifyEditUser() == 1) { $this->libFunc->authenticate(); $this->libFunc->check_token(); $obUserInterface->request['mode'] = "editDetails"; $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", " » My Account"); $obUserInterface->userTemplate = $this->templatePath . "userAccount.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_dspUserAccount()); } else { $obUserDb->m_updateUser(); } break; case "updatePass": if ($obUserInterface->m_verifyEditPass() == 1) { $this->libFunc->authenticate(); $obUserInterface->request['mode'] = "changePass"; $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", " » My Account"); $obUserInterface->userTemplate = $this->templatePath . "userAccount.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_dspUserAccount()); } else { $this->libFunc->check_token(); $obUserDb->m_updatePass(); } break; case "logout": session_destroy(); if (isset($_SESSION['referer']) && !empty($_SESSION['referer'])) { $retUrl = $_SESSION['referer']; } else { $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "user/index.php?action=user.loginForm"); } header("Location:" . $retUrl); break; case "signupForm": $obUserInterface->userTemplate = $this->templatePath . "signup.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", " » New account"); $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_dspSignupForm()); break; case "insert": if ($obUserInterface->m_verifyInsertUser() == 1) { $obUserInterface->userTemplate = $this->templatePath . "signup.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", " » New account"); $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_dspSignupForm()); } else { $obUserDb->m_insertUser(); } break; case "addnewsletter": $obUserDb->m_newsletter(); break; case "emailPass": $this->libFunc->check_token(); $obUserInterface->m_sendPassword(); break; case "recover": $obUserInterface->userTemplate = $this->templatePath . "resetpassword.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", " » Reset Password"); $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_reset_Password()); break; case "recoversave": $this->libFunc->check_token(); $obUserInterface->m_save_new_Password(); break; default: $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "user/index.php?action=user.home"); $_SESSION['referer'] = $retUrl; $this->libFunc->authenticate(); unset($_SESSION['referer']); $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", " » My Account"); $obUserInterface->userTemplate = $this->templatePath . "userAccount.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_dspUserAccount()); break; } break; #END CUSTOMER #END CUSTOMER default: $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "user/index.php?action=user.home"); $_SESSION['referer'] = $retUrl; $this->libFunc->authenticate(); unset($_SESSION['referer']); $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", " » My Account"); $obUserInterface->userTemplate = $this->templatePath . "userAccount.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_dspUserAccount()); break; } #END SWITCH CASE }
function m_eventHandler() { if (!isset($this->request['action'])) { $this->request['action'] = ""; } $action = explode(".", $this->request['action']); switch ($action[0]) { case "user": $obUserInterface = new c_userInterface(); $obUserInterface->obTpl = $this->obTpl; $obUserInterface->obDb = $this->obDb; $obUserInterface->request = $this->request; $obUserDb = new c_userDb(); $obUserDb->obDb = $this->obDb; $obUserDb->request = $this->request; if (!isset($action[1])) { $action[1] = ""; } switch ($action[1]) { case "home": $obUserInterface->userTemplate = $this->templatePath . "userDisplayHome.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_dspCustomers()); break; case "dspForm": $obUserInterface->userTemplate = $this->templatePath . "userForm.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_dspUserForm()); break; case "status": $obUserInterface->userTemplate = $this->templatePath . "status.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_userStatus()); break; case "details": $obUserInterface->userTemplate = $this->templatePath . "userDetails.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->dspUserDetails()); break; case "sendpass": $obUserInterface->m_sendPassword(); break; case "updateUser": $this->libfunc->check_token(); if (isset($this->request['mode']) && $this->request['mode'] == "edit") { $checkValue = $obUserInterface->m_verifyEditUser(); if ($checkValue == 0) { $obUserDb->m_updateUser(); } else { $obUserInterface->request['id'] = $this->request['id']; $obUserInterface->userTemplate = $this->templatePath . "userForm.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_dspUserForm()); } } else { $checkValue = $obUserInterface->m_verifyInsertUser(); if ($checkValue == 0) { $obUserDb->m_insertUser(); } else { $obUserInterface->userTemplate = $this->templatePath . "userForm.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_dspUserForm()); } } break; case "changestatus": $this->libfunc->check_token(); $obUserDb->m_changeStatus(); break; default: $obUserInterface->userTemplate = $this->templatePath . "userDisplayHome.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obUserInterface->m_dspCustomers()); break; } break; #END CUSTOMER #END CUSTOMER case "enquiry": $obEnquiryInterface = new c_enquiryInterface(); $obEnquiryInterface->obTpl = $this->obTpl; $obEnquiryInterface->obDb = $this->obDb; $obEnquiryInterface->request = $this->request; switch ($action[1]) { case "home": $obEnquiryInterface->contactTemplate = $this->templatePath . "enquiriesHome.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obEnquiryInterface->m_dspEnquiries()); break; case "details": $obEnquiryInterface->contactTemplate = $this->templatePath . "enquiriesDetails.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obEnquiryInterface->dspEnquiryDetails()); break; case "deleteEnq": $this->libfunc->check_token(); $obEnquiryInterface->m_deleteEnquiries(); break; case "delete": $this->libfunc->check_token(); $obEnquiryInterface->m_deleteEnquiry(); break; } break; case "supplier": $obSupplierInterface = new c_supplierInterface(); $obSupplierInterface->obTpl = $this->obTpl; $obSupplierInterface->obDb = $this->obDb; $obSupplierInterface->request = $this->request; $obSupplierInterface->imagePath = SITE_PATH . "images/"; $obSupplierInterface->imageUrl = SITE_URL . "images/"; $obSupplierDb = new c_supplierDb(); $obSupplierDb->obDb = $this->obDb; $obSupplierDb->request = $this->request; $obSupplierDb->imagePath = SITE_PATH . "images/"; switch ($action[1]) { case "home": $obSupplierInterface->supplierTemplate = $this->templatePath . "suppliersHome.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obSupplierInterface->m_dspSuppliers()); break; case "dspForm": $obSupplierInterface->supplierTemplate = $this->templatePath . "suppliersForm.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obSupplierInterface->m_dspSupplierForm()); break; case "updateSupplier": $this->libfunc->check_token(); if (isset($this->request['mode']) && $this->request['mode'] == "edit") { if (!$obSupplierInterface->m_verifyEditSupplier()) { $obSupplierDb->m_updateSupplier(); } else { $obSupplierInterface->request['id'] = $this->request['id']; $obSupplierInterface->supplierTemplate = $this->templatePath . "suppliersForm.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obSupplierInterface->m_dspSupplierForm()); } } else { if (!$obSupplierInterface->m_verifyInsertSupplier()) { $obSupplierDb->m_insertSupplier(); } else { $obSupplierInterface->supplierTemplate = $this->templatePath . "suppliersForm.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obSupplierInterface->m_dspSupplierForm()); } } break; case "uploadForm": $obSupplierInterface->uploadTemplate = MODULES_PATH . "default/templates/admin/upload.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obSupplierInterface->m_uploadForm()); break; case "upload": $this->libfunc->check_token(); if (!$obSupplierInterface->m_verifyImageUpload()) { $obSupplierDb->m_uploadImage(); } else { $obSupplierInterface->uploadTemplate = MODULES_PATH . "default/templates/admin/upload.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obSupplierInterface->m_uploadForm()); } break; case "delete": $this->libfunc->check_token(); $obSupplierDb->m_deleteSupplier(); break; } break; #END SUPPLIER #END SUPPLIER case "security": $obSecurityInterface = new c_securityInterface(); $obSecurityInterface->obTpl = $this->obTpl; $obSecurityInterface->obDb = $this->obDb; $obSecurityInterface->request = $this->request; $obSecurityDb = new c_securityDb(); $obSecurityDb->obDb = $this->obDb; $obSecurityDb->request = $this->request; switch ($action[1]) { case "home": $obSecurityInterface->adminTemplate = $this->templatePath . "adminUsers.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obSecurityInterface->m_dspAdminUsers()); break; case "createAdmin": $obSecurityInterface->adminTemplate = $this->templatePath . "createAdminForm.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obSecurityInterface->m_createAdminForm()); break; case "addAdmin": $this->libfunc->check_token(); if (isset($this->request['mode']) && $this->request['mode'] == "edit") { if ($obSecurityInterface->m_verifyEditAdmin() == 1) { $obSecurityDb->m_updateAdmin(); } else { if ($obSecurityInterface->m_verifyEditAdmin() == 2) { $obSecurityInterface->request['msg'] = 1; } if ($obSecurityInterface->m_verifyEditAdmin() == 3) { $obSecurityInterface->request['msg'] = 2; } $obSecurityInterface->request['adminid'] = $this->request['adminid']; $obSecurityInterface->adminTemplate = $this->templatePath . "createAdminForm.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obSecurityInterface->m_createAdminForm()); } } else { if ($obSecurityInterface->m_verifyInsertAdmin() == 1) { $obSecurityDb->m_insertAdmin(); } else { if ($obSecurityInterface->m_verifyInsertAdmin() == 2) { $obSecurityInterface->request['msg'] = 1; } if ($obSecurityInterface->m_verifyInsertAdmin() == 3) { $obSecurityInterface->request['msg'] = 2; } $obSecurityInterface->adminTemplate = $this->templatePath . "createAdminForm.tpl.htm"; $this->obTpl->set_var("TPL_VAR_BODY", $obSecurityInterface->m_createAdminForm()); } } break; case "deleteAdmin": $this->libfunc->check_token(); $obSecurityDb->m_deleteAdmin(); break; } break; #END SECURITY #HANDLING HELP PAGES #END SECURITY #HANDLING HELP PAGES case "help": $this->Template = MODULES_PATH . "default/templates/admin/helpOuter.htm"; $this->obTpl->set_file("mainContent", $this->Template); switch ($action[1]) { case "security": $this->Template = MODULES_PATH . "default/templates/help/admin_security.htm"; $this->obTpl->set_file("innerContent", $this->Template); $this->obTpl->set_var("TPL_VAR_HELPBODY", $this->obTpl->parse("return", "innerContent")); break; case "users": $this->Template = MODULES_PATH . "default/templates/help/admin_users.htm"; $this->obTpl->set_file("innerContent", $this->Template); $this->obTpl->set_var("TPL_VAR_HELPBODY", $this->obTpl->parse("return", "innerContent")); break; case "customer": $this->Template = MODULES_PATH . "default/templates/help/customer.htm"; $this->obTpl->set_file("innerContent", $this->Template); $this->obTpl->set_var("TPL_VAR_HELPBODY", $this->obTpl->parse("return", "innerContent")); break; case "contact": $this->Template = MODULES_PATH . "default/templates/help/contact.htm"; $this->obTpl->set_file("innerContent", $this->Template); $this->obTpl->set_var("TPL_VAR_HELPBODY", $this->obTpl->parse("return", "innerContent")); break; case "supplier": $this->Template = MODULES_PATH . "default/templates/help/suppliers.htm"; $this->obTpl->set_file("innerContent", $this->Template); $this->obTpl->set_var("TPL_VAR_HELPBODY", $this->obTpl->parse("return", "innerContent")); break; } $this->obTpl->pparse("return", "mainContent"); exit; break; case "logout": session_destroy(); header("Location:" . SITE_URL . "adminindex.php"); break; case "unauthorized": $this->Template = MODULES_PATH . "default/templates/admin/unAutherized.tpl.htm"; $this->obTpl->set_file("Content", $this->Template); $this->obTpl->set_var("TPL_VAR_BODY", $this->obTpl->parse("return", "Content")); break; default: if (isset($_SESSION['uname']) && trim($_SESSION['uname']) != "") { header("Location:" . SITE_URL . "user/adminindex.php?action=user.home"); exit; } else { header("Location:" . SITE_URL . "adminindex.php"); exit; } } #END SWITCH CASE }