示例#1
0
 public static function execute(ApplicationAbstract $application)
 {
     $OSCOM_MessageStack = Registry::get('MessageStack');
     $data = array();
     if (DISPLAY_PRIVACY_CONDITIONS == '1') {
         if (isset($_POST['privacy_conditions']) === false || isset($_POST['privacy_conditions']) && $_POST['privacy_conditions'] != '1') {
             $OSCOM_MessageStack->add('Create', OSCOM::getDef('error_privacy_statement_not_accepted'));
         }
     }
     if (ACCOUNT_GENDER >= 0) {
         if (isset($_POST['gender']) && ($_POST['gender'] == 'm' || $_POST['gender'] == 'f')) {
             $data['gender'] = $_POST['gender'];
         } else {
             $OSCOM_MessageStack->add('Create', OSCOM::getDef('field_customer_gender_error'));
         }
     }
     if (isset($_POST['firstname']) && strlen(trim($_POST['firstname'])) >= ACCOUNT_FIRST_NAME) {
         $data['firstname'] = $_POST['firstname'];
     } else {
         $OSCOM_MessageStack->add('Create', sprintf(OSCOM::getDef('field_customer_first_name_error'), ACCOUNT_FIRST_NAME));
     }
     if (isset($_POST['lastname']) && strlen(trim($_POST['lastname'])) >= ACCOUNT_LAST_NAME) {
         $data['lastname'] = $_POST['lastname'];
     } else {
         $OSCOM_MessageStack->add('Create', sprintf(OSCOM::getDef('field_customer_last_name_error'), ACCOUNT_LAST_NAME));
     }
     if (ACCOUNT_DATE_OF_BIRTH == '1') {
         if (isset($_POST['dob_days']) && isset($_POST['dob_months']) && isset($_POST['dob_years']) && checkdate($_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years'])) {
             $data['dob'] = mktime(0, 0, 0, $_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years']);
         } else {
             $OSCOM_MessageStack->add('Create', OSCOM::getDef('field_customer_date_of_birth_error'));
         }
     }
     if (isset($_POST['email_address']) && strlen(trim($_POST['email_address'])) >= ACCOUNT_EMAIL_ADDRESS) {
         if (osc_validate_email_address($_POST['email_address'])) {
             if (Account::checkEntry($_POST['email_address']) === false) {
                 $data['email_address'] = $_POST['email_address'];
             } else {
                 $OSCOM_MessageStack->add('Create', OSCOM::getDef('field_customer_email_address_exists_error'));
             }
         } else {
             $OSCOM_MessageStack->add('Create', OSCOM::getDef('field_customer_email_address_check_error'));
         }
     } else {
         $OSCOM_MessageStack->add('Create', sprintf(OSCOM::getDef('field_customer_email_address_error'), ACCOUNT_EMAIL_ADDRESS));
     }
     if (isset($_POST['password']) === false || isset($_POST['password']) && strlen(trim($_POST['password'])) < ACCOUNT_PASSWORD) {
         $OSCOM_MessageStack->add('Create', sprintf(OSCOM::getDef('field_customer_password_error'), ACCOUNT_PASSWORD));
     } elseif (isset($_POST['confirmation']) === false || isset($_POST['confirmation']) && trim($_POST['password']) != trim($_POST['confirmation'])) {
         $OSCOM_MessageStack->add('Create', OSCOM::getDef('field_customer_password_mismatch_with_confirmation'));
     } else {
         $data['password'] = $_POST['password'];
     }
     if ($OSCOM_MessageStack->size('Create') === 0) {
         if (Account::createEntry($data)) {
             $OSCOM_MessageStack->add('Create', OSCOM::getDef('success_account_updated'), 'success');
         }
         osc_redirect(OSCOM::getLink(null, null, 'Create&Success', 'SSL'));
     }
 }
 function _process()
 {
     global $osC_Language, $messageStack, $osC_Product;
     if (empty($_POST['from_name'])) {
         $messageStack->add('tell_a_friend', $osC_Language->get('error_tell_a_friend_customers_name_empty'));
     }
     if (!osc_validate_email_address($_POST['from_email_address'])) {
         $messageStack->add('tell_a_friend', $osC_Language->get('error_tell_a_friend_invalid_customers_email_address'));
     }
     if (empty($_POST['to_name'])) {
         $messageStack->add('tell_a_friend', $osC_Language->get('error_tell_a_friend_friends_name_empty'));
     }
     if (!osc_validate_email_address($_POST['to_email_address'])) {
         $messageStack->add('tell_a_friend', $osC_Language->get('error_tell_a_friend_invalid_friends_email_address'));
     }
     if ($messageStack->size('tell_a_friend') < 1) {
         include 'includes/classes/email_template.php';
         $email_template = toC_Email_Template::getEmailTemplate('tell_a_friend');
         $email_template->setData($_POST['from_name'], $_POST['from_email_address'], $_POST['to_name'], $_POST['to_email_address'], $_POST['message'], $osC_Product->getTitle(), osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID(), 'NONSSL', false, true, true));
         $email_template->buildMessage();
         $email_template->sendEmail();
         $messageStack->add_session('header', sprintf($osC_Language->get('success_tell_a_friend_email_sent'), $osC_Product->getTitle(), osc_output_string_protected($_POST['to_name'])), 'success');
         osc_redirect(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID()));
     }
 }
示例#3
0
 function _process()
 {
     global $osC_Language, $osC_MessageStack, $osC_Product;
     if (empty($_POST['from_name'])) {
         $osC_MessageStack->add('tell_a_friend', $osC_Language->get('error_tell_a_friend_customers_name_empty'));
     }
     if (!osc_validate_email_address($_POST['from_email_address'])) {
         $osC_MessageStack->add('tell_a_friend', $osC_Language->get('error_tell_a_friend_invalid_customers_email_address'));
     }
     if (empty($_POST['to_name'])) {
         $osC_MessageStack->add('tell_a_friend', $osC_Language->get('error_tell_a_friend_friends_name_empty'));
     }
     if (!osc_validate_email_address($_POST['to_email_address'])) {
         $osC_MessageStack->add('tell_a_friend', $osC_Language->get('error_tell_a_friend_invalid_friends_email_address'));
     }
     if ($osC_MessageStack->size('tell_a_friend') < 1) {
         $email_subject = sprintf($osC_Language->get('email_tell_a_friend_subject'), osc_sanitize_string($_POST['from_name']), STORE_NAME);
         $email_body = sprintf($osC_Language->get('email_tell_a_friend_intro'), osc_sanitize_string($_POST['to_name']), osc_sanitize_string($_POST['from_name']), $osC_Product->getTitle(), STORE_NAME) . "\n\n";
         if (!empty($_POST['message'])) {
             $email_body .= osc_sanitize_string($_POST['message']) . "\n\n";
         }
         $email_body .= sprintf($osC_Language->get('email_tell_a_friend_link'), osc_href_link(FILENAME_PRODUCTS, $osC_Product->getKeyword(), 'NONSSL', false)) . "\n\n" . sprintf($osC_Language->get('email_tell_a_friend_signature'), STORE_NAME . "\n" . HTTP_SERVER . DIR_WS_CATALOG . "\n");
         osc_email(osc_sanitize_string($_POST['to_name']), osc_sanitize_string($_POST['to_email_address']), $email_subject, $email_body, osc_sanitize_string($_POST['from_name']), osc_sanitize_string($_POST['from_email_address']));
         $osC_MessageStack->add('header', sprintf($osC_Language->get('success_tell_a_friend_email_sent'), $osC_Product->getTitle(), osc_output_string_protected($_POST['to_name'])), 'success');
         osc_redirect(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID()));
     }
 }
示例#4
0
 function getPassword()
 {
     global $toC_Json, $osC_Language, $osC_Database;
     $error = false;
     $feedback = '';
     $email = $_REQUEST['email_address'];
     if (!osc_validate_email_address($email)) {
         $error = true;
         $feedback = $osC_Language->get('ms_error_wrong_email_address');
     } else {
         if (!osC_Administrators_Admin::checkEmail($email)) {
             $error = true;
             $feedback = $osC_Language->get('ms_error_email_not_exist');
         }
     }
     if ($error === false) {
         if (!osC_Administrators_Admin::generatePassword($email)) {
             $error = true;
             $feedback = $osC_Language->get('ms_error_email_send_failure');
         }
     }
     if ($error == false) {
         $response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed'));
     } else {
         $response = array('success' => false, 'feedback' => $feedback);
     }
     echo $toC_Json->encode($response);
 }
示例#5
0
 function _process()
 {
     global $messageStack, $osC_Database, $osC_Language, $osC_Customer;
     $data = array();
     $j_to_g = array();
     if (ACCOUNT_GENDER == '1') {
         if (isset($_POST['gender']) && ($_POST['gender'] == 'm' || $_POST['gender'] == 'f')) {
             $data['gender'] = $_POST['gender'];
         } else {
             $messageStack->add($this->_module, $osC_Language->get('field_customer_gender_error'));
         }
     } else {
         $data['gender'] = isset($_POST['gender']) ? $_POST['gender'] : '';
     }
     if (isset($_POST['firstname']) && strlen(trim($_POST['firstname'])) >= ACCOUNT_FIRST_NAME) {
         $data['firstname'] = $_POST['firstname'];
     } else {
         $messageStack->add('account_edit', sprintf($osC_Language->get('field_customer_first_name_error'), ACCOUNT_FIRST_NAME));
     }
     if (isset($_POST['lastname']) && strlen(trim($_POST['lastname'])) >= ACCOUNT_LAST_NAME) {
         $data['lastname'] = $_POST['lastname'];
     } else {
         $messageStack->add('account_edit', sprintf($osC_Language->get('field_customer_last_name_error'), ACCOUNT_LAST_NAME));
     }
     if (ACCOUNT_DATE_OF_BIRTH == '1') {
         if (isset($_POST['dob_days']) && isset($_POST['dob_months']) && isset($_POST['dob_years']) && jcheckdate($_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years'])) {
             $j_to_g = jalali_to_gregorian($_POST['dob_years'], $_POST['dob_months'], $_POST['dob_days']);
             // tabdil shamsi be miladi
             $data['dob'] = mktime(0, 0, 0, $j_to_g['1'], $j_to_g['2'], $j_to_g['0']);
         } else {
             $messageStack->add('account_edit', $osC_Language->get('field_customer_date_of_birth_error'));
         }
     }
     if (isset($_POST['email_address']) && strlen(trim($_POST['email_address'])) >= ACCOUNT_EMAIL_ADDRESS) {
         if (osc_validate_email_address($_POST['email_address'])) {
             if (osC_Account::checkDuplicateEntry($_POST['email_address']) === false) {
                 $data['email_address'] = $_POST['email_address'];
             } else {
                 $messageStack->add('account_edit', $osC_Language->get('field_customer_email_address_exists_error'));
             }
         } else {
             $messageStack->add('account_edit', $osC_Language->get('field_customer_email_address_check_error'));
         }
     } else {
         $messageStack->add('account_edit', sprintf($osC_Language->get('field_customer_email_address_error'), ACCOUNT_EMAIL_ADDRESS));
     }
     if ($messageStack->size('account_edit') === 0) {
         if (osC_Account::saveEntry($data)) {
             // reset the session variables
             if (ACCOUNT_GENDER > -1) {
                 $osC_Customer->setGender($data['gender']);
             }
             $osC_Customer->setFirstName(trim($data['firstname']));
             $osC_Customer->setLastName(trim($data['lastname']));
             $osC_Customer->setEmailAddress($data['email_address']);
             $messageStack->add_session('account', $osC_Language->get('success_account_updated'), 'success');
         }
         osc_redirect(osc_href_link(FILENAME_ACCOUNT, null, 'SSL'));
     }
 }
示例#6
0
 function _process()
 {
     global $osC_MessageStack, $osC_Database, $osC_Language, $osC_Customer;
     $data = array();
     if (DISPLAY_PRIVACY_CONDITIONS == '1') {
         if (isset($_POST['privacy_conditions']) === false || isset($_POST['privacy_conditions']) && $_POST['privacy_conditions'] != '1') {
             $osC_MessageStack->add($this->_module, $osC_Language->get('error_privacy_statement_not_accepted'));
         }
     }
     if (ACCOUNT_GENDER >= 0) {
         if (isset($_POST['gender']) && ($_POST['gender'] == 'm' || $_POST['gender'] == 'f')) {
             $data['gender'] = $_POST['gender'];
         } else {
             $osC_MessageStack->add($this->_module, $osC_Language->get('field_customer_gender_error'));
         }
     }
     if (isset($_POST['firstname']) && strlen(trim($_POST['firstname'])) >= ACCOUNT_FIRST_NAME) {
         $data['firstname'] = $_POST['firstname'];
     } else {
         $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('field_customer_first_name_error'), ACCOUNT_FIRST_NAME));
     }
     if (isset($_POST['lastname']) && strlen(trim($_POST['lastname'])) >= ACCOUNT_LAST_NAME) {
         $data['lastname'] = $_POST['lastname'];
     } else {
         $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('field_customer_last_name_error'), ACCOUNT_LAST_NAME));
     }
     if (ACCOUNT_DATE_OF_BIRTH == '1') {
         if (isset($_POST['dob_days']) && isset($_POST['dob_months']) && isset($_POST['dob_years']) && checkdate($_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years'])) {
             $data['dob'] = mktime(0, 0, 0, $_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years']);
         } else {
             $osC_MessageStack->add($this->_module, $osC_Language->get('field_customer_date_of_birth_error'));
         }
     }
     if (isset($_POST['email_address']) && strlen(trim($_POST['email_address'])) >= ACCOUNT_EMAIL_ADDRESS) {
         if (osc_validate_email_address($_POST['email_address'])) {
             if (osC_Account::checkDuplicateEntry($_POST['email_address']) === false) {
                 $data['email_address'] = $_POST['email_address'];
             } else {
                 $osC_MessageStack->add($this->_module, $osC_Language->get('field_customer_email_address_exists_error'));
             }
         } else {
             $osC_MessageStack->add($this->_module, $osC_Language->get('field_customer_email_address_check_error'));
         }
     } else {
         $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('field_customer_email_address_error'), ACCOUNT_EMAIL_ADDRESS));
     }
     if (isset($_POST['password']) === false || isset($_POST['password']) && strlen(trim($_POST['password'])) < ACCOUNT_PASSWORD) {
         $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('field_customer_password_error'), ACCOUNT_PASSWORD));
     } elseif (isset($_POST['confirmation']) === false || isset($_POST['confirmation']) && trim($_POST['password']) != trim($_POST['confirmation'])) {
         $osC_MessageStack->add($this->_module, $osC_Language->get('field_customer_password_mismatch_with_confirmation'));
     } else {
         $data['password'] = $_POST['password'];
     }
     if ($osC_MessageStack->size($this->_module) === 0) {
         if (osC_Account::createEntry($data)) {
             $osC_MessageStack->add('create', $osC_Language->get('success_account_updated'), 'success');
         }
         osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'create=success', 'SSL'));
     }
 }
示例#7
0
 function _process()
 {
     global $osC_Database, $messageStack, $osC_Language;
     $data = array();
     $data['url'] = osc_sanitize_string($_POST['url']);
     if (isset($_POST['title']) && !empty($_POST['title'])) {
         $data['title'] = osc_sanitize_string($_POST['title']);
     } else {
         $messageStack->add('guestbook', $osC_Language->get('field_guestbook_title_error'));
     }
     if (isset($_POST['email']) && !empty($_POST['email']) && osc_validate_email_address($_POST['email'])) {
         $data['email'] = $_POST['email'];
     } else {
         $messageStack->add('guestbook', $osC_Language->get('field_guestbook_email_error'));
     }
     if (isset($_POST['content']) && !empty($_POST['content'])) {
         $data['content'] = osc_sanitize_string($_POST['content']);
     } else {
         $messageStack->add('guestbook', $osC_Language->get('field_guestbook_content_error'));
     }
     if ($_POST['verify_code'] != $_SESSION['verify_code']) {
         $messageStack->add('guestbook', $osC_Language->get('field_guestbook_verify_code_error'));
     }
     if ($messageStack->size('guestbook') === 0) {
         if (toC_Guestbook::saveEntry($data)) {
             $messageStack->add_session('guestbook', $osC_Language->get('success_guestbook_saved'), 'success');
         }
         osc_redirect(osc_href_link(FILENAME_INFO, 'guestbook'));
     }
 }
示例#8
0
 public static function execute(ApplicationAbstract $application)
 {
     $OSCOM_Customer = Registry::get('Customer');
     $OSCOM_NavigationHistory = Registry::get('NavigationHistory');
     $OSCOM_MessageStack = Registry::get('MessageStack');
     $OSCOM_Service = Registry::get('Service');
     $OSCOM_Breadcrumb = Registry::get('Breadcrumb');
     if (ALLOW_GUEST_TO_TELL_A_FRIEND == '-1' && $OSCOM_Customer->isLoggedOn() === false) {
         $OSCOM_NavigationHistory->setSnapshot();
         osc_redirect(OSCOM::getLink(null, 'Account', 'LogIn', 'SSL'));
     }
     $requested_product = null;
     $product_check = false;
     if (count($_GET) > 3) {
         $requested_product = basename(key(array_slice($_GET, 3, 1, true)));
         if ($requested_product == 'Write') {
             unset($requested_product);
             if (count($_GET) > 4) {
                 $requested_product = basename(key(array_slice($_GET, 4, 1, true)));
             }
         }
     }
     if (isset($requested_product)) {
         if (Product::checkEntry($requested_product)) {
             $product_check = true;
         }
     }
     if ($product_check === false) {
         $application->setPageContent('not_found.php');
         return false;
     }
     Registry::set('Product', new Product($requested_product));
     $OSCOM_Product = Registry::get('Product');
     if (empty($_POST['from_name'])) {
         $OSCOM_MessageStack->add('TellAFriend', OSCOM::getDef('error_tell_a_friend_customers_name_empty'));
     }
     if (!osc_validate_email_address($_POST['from_email_address'])) {
         $OSCOM_MessageStack->add('TellAFriend', OSCOM::getDef('error_tell_a_friend_invalid_customers_email_address'));
     }
     if (empty($_POST['to_name'])) {
         $OSCOM_MessageStack->add('TellAFriend', OSCOM::getDef('error_tell_a_friend_friends_name_empty'));
     }
     if (!osc_validate_email_address($_POST['to_email_address'])) {
         $OSCOM_MessageStack->add('TellAFriend', OSCOM::getDef('error_tell_a_friend_invalid_friends_email_address'));
     }
     if ($OSCOM_MessageStack->size('TellAFriend') < 1) {
         $email_subject = sprintf(OSCOM::getDef('email_tell_a_friend_subject'), osc_sanitize_string($_POST['from_name']), STORE_NAME);
         $email_body = sprintf(OSCOM::getDef('email_tell_a_friend_intro'), osc_sanitize_string($_POST['to_name']), osc_sanitize_string($_POST['from_name']), $OSCOM_Product->getTitle(), STORE_NAME) . "\n\n";
         if (!empty($_POST['message'])) {
             $email_body .= osc_sanitize_string($_POST['message']) . "\n\n";
         }
         $email_body .= sprintf(OSCOM::getDef('email_tell_a_friend_link'), OSCOM::getLink(null, null, $OSCOM_Product->getKeyword(), 'NONSSL', false)) . "\n\n" . sprintf(OSCOM::getDef('email_tell_a_friend_signature'), STORE_NAME . "\n" . HTTP_SERVER . DIR_WS_CATALOG . "\n");
         osc_email(osc_sanitize_string($_POST['to_name']), osc_sanitize_string($_POST['to_email_address']), $email_subject, $email_body, osc_sanitize_string($_POST['from_name']), osc_sanitize_string($_POST['from_email_address']));
         $OSCOM_MessageStack->add('header', sprintf(OSCOM::getDef('success_tell_a_friend_email_sent'), $OSCOM_Product->getTitle(), osc_output_string_protected($_POST['to_name'])), 'success');
         osc_redirect(OSCOM::getLink(null, null, $OSCOM_Product->getKeyword()));
     }
     $application->setPageTitle($OSCOM_Product->getTitle());
     $application->setPageContent('tell_a_friend.php');
 }
示例#9
0
 public static function execute(ApplicationAbstract $application)
 {
     $OSCOM_MessageStack = Registry::get('MessageStack');
     $OSCOM_Customer = Registry::get('Customer');
     $data = array();
     if (ACCOUNT_GENDER >= 0) {
         if (isset($_POST['gender']) && ($_POST['gender'] == 'm' || $_POST['gender'] == 'f')) {
             $data['gender'] = $_POST['gender'];
         } else {
             $OSCOM_MessageStack->add('Edit', OSCOM::getDef('field_customer_gender_error'));
         }
     }
     if (isset($_POST['firstname']) && strlen(trim($_POST['firstname'])) >= ACCOUNT_FIRST_NAME) {
         $data['firstname'] = $_POST['firstname'];
     } else {
         $OSCOM_MessageStack->add('Edit', sprintf(OSCOM::getDef('field_customer_first_name_error'), ACCOUNT_FIRST_NAME));
     }
     if (isset($_POST['lastname']) && strlen(trim($_POST['lastname'])) >= ACCOUNT_LAST_NAME) {
         $data['lastname'] = $_POST['lastname'];
     } else {
         $OSCOM_MessageStack->add('Edit', sprintf(OSCOM::getDef('field_customer_last_name_error'), ACCOUNT_LAST_NAME));
     }
     if (ACCOUNT_DATE_OF_BIRTH == '1') {
         if (isset($_POST['dob_days']) && isset($_POST['dob_months']) && isset($_POST['dob_years']) && checkdate($_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years'])) {
             $data['dob'] = mktime(0, 0, 0, $_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years']);
         } else {
             $OSCOM_MessageStack->add('Edit', OSCOM::getDef('field_customer_date_of_birth_error'));
         }
     }
     if (isset($_POST['email_address']) && strlen(trim($_POST['email_address'])) >= ACCOUNT_EMAIL_ADDRESS) {
         if (osc_validate_email_address($_POST['email_address'])) {
             if (Account::checkDuplicateEntry($_POST['email_address']) === false) {
                 $data['email_address'] = $_POST['email_address'];
             } else {
                 $OSCOM_MessageStack->add('Edit', OSCOM::getDef('field_customer_email_address_exists_error'));
             }
         } else {
             $OSCOM_MessageStack->add('Edit', OSCOM::getDef('field_customer_email_address_check_error'));
         }
     } else {
         $OSCOM_MessageStack->add('Edit', sprintf(OSCOM::getDef('field_customer_email_address_error'), ACCOUNT_EMAIL_ADDRESS));
     }
     if ($OSCOM_MessageStack->size('Edit') === 0) {
         if (Account::saveEntry($data)) {
             // reset the session variables
             if (ACCOUNT_GENDER > -1) {
                 $OSCOM_Customer->setGender($data['gender']);
             }
             $OSCOM_Customer->setFirstName(trim($data['firstname']));
             $OSCOM_Customer->setLastName(trim($data['lastname']));
             $OSCOM_Customer->setEmailAddress($data['email_address']);
             $OSCOM_MessageStack->add('Account', OSCOM::getDef('success_account_updated'), 'success');
         }
         osc_redirect(OSCOM::getLink(null, null, null, 'SSL'));
     }
 }
示例#10
0
 protected function process()
 {
     $OSCOM_ShoppingCart = Registry::get('ShoppingCart');
     $OSCOM_Customer = Registry::get('Customer');
     $OSCOM_Language = Registry::get('Language');
     $OSCOM_Service = Registry::get('Service');
     $OSCOM_Breadcrumb = Registry::get('Breadcrumb');
     $OSCOM_MessageStack = Registry::get('MessageStack');
     // redirect to shopping cart if shopping cart is empty
     if (!$OSCOM_ShoppingCart->hasContents()) {
         osc_redirect(OSCOM::getLink(null, 'Cart'));
     }
     // check for e-mail address
     if (!$OSCOM_Customer->hasEmailAddress()) {
         if (isset($_POST['email']) && strlen(trim($_POST['email'])) >= ACCOUNT_EMAIL_ADDRESS) {
             if (osc_validate_email_address($_POST['email'])) {
                 $OSCOM_Customer->setEmailAddress(trim($_POST['email']));
             } else {
                 $OSCOM_MessageStack->add('Cart', OSCOM::getDef('field_customer_email_address_check_error'));
                 osc_redirect(OSCOM::getLink(null, 'Cart'));
             }
         } else {
             $OSCOM_MessageStack->add('Cart', sprintf(OSCOM::getDef('field_customer_email_address_error'), ACCOUNT_EMAIL_ADDRESS));
             osc_redirect(OSCOM::getLink(null, 'Cart'));
         }
     }
     // check product type perform_order conditions
     foreach ($OSCOM_ShoppingCart->getProducts() as $product) {
         $OSCOM_Product = new Product($product['id']);
         $OSCOM_Product->isTypeActionAllowed('PerformOrder');
     }
     $OSCOM_Language->load('checkout');
     $OSCOM_Language->load('order');
     $this->_page_title = OSCOM::getDef('confirmation_heading');
     if ($OSCOM_Service->isStarted('Breadcrumb')) {
         $OSCOM_Breadcrumb->add(OSCOM::getDef('breadcrumb_checkout_confirmation'), OSCOM::getLink(null, 'Checkout', null, 'SSL'));
     }
     if (isset($_POST['comments']) && isset($_SESSION['comments']) && empty($_POST['comments'])) {
         unset($_SESSION['comments']);
     } elseif (!empty($_POST['comments'])) {
         $_SESSION['comments'] = osc_sanitize_string($_POST['comments']);
     }
     if (DISPLAY_CONDITIONS_ON_CHECKOUT == '1') {
         if (!isset($_POST['conditions']) || $_POST['conditions'] != '1') {
             $OSCOM_MessageStack->add('Checkout', OSCOM::getDef('error_conditions_not_accepted'), 'error');
         }
     }
     if (Registry::exists('Payment') === false) {
         Registry::set('Payment', new Payment());
     }
     if ($OSCOM_ShoppingCart->hasBillingMethod()) {
         $OSCOM_Payment = Registry::get('Payment');
         $OSCOM_Payment->load($OSCOM_ShoppingCart->getBillingMethod('id'));
     }
 }
示例#11
0
 public static function execute(ApplicationAbstract $application)
 {
     $OSCOM_MessageStack = Registry::get('MessageStack');
     $name = osc_sanitize_string($_POST['name']);
     $email_address = osc_sanitize_string($_POST['email']);
     $enquiry = osc_sanitize_string($_POST['enquiry']);
     if (osc_validate_email_address($email_address)) {
         osc_email(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, OSCOM::getDef('contact_email_subject'), $enquiry, $name, $email_address);
         osc_redirect(OSCOM::getLink(null, null, 'Contact&Success'));
     } else {
         $OSCOM_MessageStack->add('Contact', OSCOM::getDef('field_customer_email_address_check_error'));
     }
 }
示例#12
0
 function _process()
 {
     global $osC_Language, $osC_MessageStack;
     $name = osc_sanitize_string($_POST['name']);
     $email_address = osc_sanitize_string($_POST['email']);
     $enquiry = osc_sanitize_string($_POST['enquiry']);
     if (osc_validate_email_address($email_address)) {
         osc_email(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, $osC_Language->get('contact_email_subject'), $enquiry, $name, $email_address);
         osc_redirect(osc_href_link(FILENAME_INFO, 'contact=success', 'AUTO'));
     } else {
         $osC_MessageStack->add('contact', $osC_Language->get('field_customer_email_address_check_error'));
     }
 }
 function setData($from_name, $from_email_address, $to_email_address, $message, $wishlist_url)
 {
     $this->_from_name = $from_name;
     $this->_from_email_address = $from_email_address;
     $this->_to_email_address = $to_email_address;
     $this->_message = $message;
     $this->_wishlist_url = $wishlist_url;
     $emails = explode(',', $this->_to_email_address);
     foreach ($emails as $email) {
         if (osc_validate_email_address($email)) {
             $this->addRecipient('', $email);
         }
     }
 }
示例#14
0
 function _process()
 {
     global $osC_Language, $messageStack;
     if (isset($_POST['department_email']) && !empty($_POST['department_email'])) {
         $department_email = osc_sanitize_string($_POST['department_email']);
         if (!osc_validate_email_address($department_email)) {
             $messageStack->add('contact', $osC_Language->get('field_departments_email_error'));
         }
     } else {
         $department_email = STORE_OWNER_EMAIL_ADDRESS;
     }
     if (isset($_POST['name']) && !empty($_POST['name'])) {
         $name = osc_sanitize_string($_POST['name']);
     } else {
         $messageStack->add('contact', $osC_Language->get('field_customer_name_error'));
     }
     if (isset($_POST['email']) && !empty($_POST['email'])) {
         $email_address = osc_sanitize_string($_POST['email']);
         if (!osc_validate_email_address($email_address)) {
             $messageStack->add('contact', $osC_Language->get('field_customer_concat_email_error'));
         }
     } else {
         $messageStack->add('contact', $osC_Language->get('field_customer_concat_email_error'));
     }
     if (isset($_POST['telephone']) && !empty($_POST['telephone'])) {
         $telephone = osc_sanitize_string($_POST['telephone']);
     }
     if (isset($_POST['enquiry']) && !empty($_POST['enquiry'])) {
         $enquiry = osc_sanitize_string($_POST['enquiry']);
     } else {
         $messageStack->add('contact', $osC_Language->get('field_enquiry_error'));
     }
     if (ACTIVATE_CAPTCHA == '1') {
         if (isset($_POST['captcha_code']) && !empty($_POST['captcha_code'])) {
             $securimage = new Securimage();
             if ($securimage->check($_POST['captcha_code']) == false) {
                 $messageStack->add('contact', $osC_Language->get('field_concat_captcha_check_error'));
             }
         } else {
             $messageStack->add('contact', $osC_Language->get('field_concat_captcha_check_error'));
         }
     }
     if ($messageStack->size('contact') === 0) {
         osc_email(STORE_OWNER, $department_email, $osC_Language->get('contact_email_subject'), $enquiry . '<br /><br /><br />' . $osC_Language->get('contact_telephone_title') . $telephone, $name, $email_address);
         osc_redirect(osc_href_link(FILENAME_INFO, 'contact=success', 'AUTO', true, false));
     }
 }
示例#15
0
 function addProduct()
 {
     global $toC_Json, $osC_Language, $osC_Tax, $osC_Weight, $osC_Currencies, $osC_ShoppingCart;
     $error = false;
     $feedback = array();
     $osC_ShoppingCart = new toC_ShoppingCart_Adapter($_REQUEST['orders_id']);
     $osC_Tax = new osC_Tax_Admin();
     $osC_Weight = new osC_Weight();
     $osC_Currencies = new osC_Currencies();
     $osC_Product = new osC_Product(osc_get_product_id($_REQUEST['products_id']));
     $gift_certificate_data = null;
     if ($osC_Product->isGiftCertificate()) {
         if (!isset($_REQUEST['senders_name']) || empty($_REQUEST['senders_name'])) {
             $error = true;
             $feedback[] = $osC_Language->get('error_sender_name_empty');
         }
         if (!isset($_REQUEST['recipients_name']) || empty($_REQUEST['recipients_name'])) {
             $error = true;
             $feedback[] = $osC_Language->get('error_recipients_name_empty');
         }
         if (!isset($_REQUEST['message']) || empty($_REQUEST['message'])) {
             $error = true;
             $feedback[] = $osC_Language->get('error_message_empty');
         }
         if ($osC_Product->isEmailGiftCertificate()) {
             if (!isset($_REQUEST['senders_email']) || empty($_REQUEST['senders_email'])) {
                 $error = true;
                 $feedback[] = $osC_Language->get('error_sender_email_empty');
             }
             if (!osc_validate_email_address($_REQUEST['senders_email'])) {
                 $error = true;
                 $feedback[] = $osC_Language->get('error_sender_email_invalid');
             }
             if (!isset($_REQUEST['recipients_email']) || empty($_REQUEST['recipients_email'])) {
                 $error = true;
                 $feedback[] = $osC_Language->get('error_recipients_email_empty');
             }
             if (!osc_validate_email_address($_REQUEST['recipients_email'])) {
                 $error = true;
                 $feedback[] = $osC_Language->get('error_recipients_email_invalid');
             }
         }
         if ($error === false) {
             if ($osC_Product->isEmailGiftCertificate()) {
                 $gift_certificate_data = array('senders_name' => $_REQUEST['senders_name'], 'senders_email' => $_REQUEST['senders_email'], 'recipients_name' => $_REQUEST['recipients_name'], 'recipients_email' => $_REQUEST['recipients_email'], 'message' => $_REQUEST['message']);
             } else {
                 $gift_certificate_data = array('senders_name' => $_REQUEST['senders_name'], 'recipients_name' => $_REQUEST['recipients_name'], 'message' => $_REQUEST['message']);
             }
             $gift_certificate_data['type'] = $osC_Product->getGiftCertificateType();
             if ($osC_Product->isOpenAmountGiftCertificate()) {
                 $gift_certificate_data['price'] = $_REQUEST['gift_certificate_amount'] / $osC_ShoppingCart->getCurrencyValue();
             }
         }
     }
     if ($error === false) {
         if ($osC_ShoppingCart->addProduct($_REQUEST['products_id'], $_REQUEST['new_qty'], $gift_certificate_data)) {
             $response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed'));
         } else {
             $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_action_not_performed'));
         }
     } else {
         $response = array('success' => false, 'feedback' => implode('<br />', $feedback));
     }
     echo $toC_Json->encode($response);
 }
示例#16
0
 function _process()
 {
     global $messageStack, $osC_Database, $osC_Language, $osC_Customer;
     $data = array();
     $j_to_g = array();
     if (DISPLAY_PRIVACY_CONDITIONS == '1') {
         if (isset($_POST['privacy_conditions']) === false || isset($_POST['privacy_conditions']) && $_POST['privacy_conditions'] != '1') {
             $messageStack->add($this->_module, $osC_Language->get('error_privacy_statement_not_accepted'));
         }
     }
     if (ACCOUNT_GENDER == '1') {
         if (isset($_POST['gender']) && ($_POST['gender'] == 'm' || $_POST['gender'] == 'f')) {
             $data['gender'] = $_POST['gender'];
         } else {
             $messageStack->add($this->_module, $osC_Language->get('field_customer_gender_error'));
         }
     } else {
         $data['gender'] = isset($_POST['gender']) ? $_POST['gender'] : '';
     }
     if (isset($_POST['firstname']) && strlen(trim($_POST['firstname'])) >= ACCOUNT_FIRST_NAME) {
         $data['firstname'] = $_POST['firstname'];
     } else {
         $messageStack->add($this->_module, sprintf($osC_Language->get('field_customer_first_name_error'), ACCOUNT_FIRST_NAME));
     }
     if (isset($_POST['lastname']) && strlen(trim($_POST['lastname'])) >= ACCOUNT_LAST_NAME) {
         $data['lastname'] = $_POST['lastname'];
     } else {
         $messageStack->add($this->_module, sprintf($osC_Language->get('field_customer_last_name_error'), ACCOUNT_LAST_NAME));
     }
     $data['newsletter'] = isset($_POST['newsletter']) && $_POST['newsletter'] == '1' ? 1 : 0;
     if (ACCOUNT_DATE_OF_BIRTH == '1') {
         if (isset($_POST['dob_days']) && isset($_POST['dob_months']) && isset($_POST['dob_years']) && jcheckdate($_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years'])) {
             $j_to_g = jalali_to_gregorian($_POST['dob_years'], $_POST['dob_months'], $_POST['dob_days']);
             // tabdil shamsi be miladi
             $data['dob'] = mktime(0, 0, 0, $j_to_g['1'], $j_to_g['2'], $j_to_g['0']);
         } else {
             $messageStack->add($this->_module, $osC_Language->get('field_customer_date_of_birth_error'));
         }
     }
     if (isset($_POST['email_address']) && strlen(trim($_POST['email_address'])) >= ACCOUNT_EMAIL_ADDRESS) {
         if (osc_validate_email_address($_POST['email_address'])) {
             if (osC_Account::checkDuplicateEntry($_POST['email_address']) === false) {
                 $data['email_address'] = $_POST['email_address'];
             } else {
                 $messageStack->add($this->_module, $osC_Language->get('field_customer_email_address_exists_error'));
             }
         } else {
             $messageStack->add($this->_module, $osC_Language->get('field_customer_email_address_check_error'));
         }
     } else {
         $messageStack->add($this->_module, sprintf($osC_Language->get('field_customer_email_address_error'), ACCOUNT_EMAIL_ADDRESS));
     }
     if (isset($_POST['password']) === false || isset($_POST['password']) && strlen(trim($_POST['password'])) < ACCOUNT_PASSWORD) {
         $messageStack->add($this->_module, sprintf($osC_Language->get('field_customer_password_error'), ACCOUNT_PASSWORD));
     } elseif (isset($_POST['confirmation']) === false || isset($_POST['confirmation']) && trim($_POST['password']) != trim($_POST['confirmation'])) {
         $messageStack->add($this->_module, $osC_Language->get('field_customer_password_mismatch_with_confirmation'));
     } else {
         $data['password'] = $_POST['password'];
     }
     if (ACTIVATE_CAPTCHA == '1') {
         if (isset($_POST['captcha_code']) && !empty($_POST['captcha_code'])) {
             $securimage = new Securimage();
             if ($securimage->check($_POST['captcha_code']) == false) {
                 $messageStack->add('create', $osC_Language->get('field_create_account_captcha_check_error'));
             }
         } else {
             $messageStack->add('create', $osC_Language->get('field_create_account_captcha_check_error'));
         }
     }
     if ($messageStack->size($this->_module) === 0) {
         if (osC_Account::createEntry($data)) {
             $messageStack->add_session('create', $osC_Language->get('success_account_updated'), 'success');
         }
         osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'create=success', 'SSL'));
     }
 }
示例#17
0
文件: cc.php 项目: kdexter/oscommerce
 function process()
 {
     global $osC_Database, $osC_MessageStack, $osC_Customer, $osC_Language, $osC_Currencies, $osC_ShoppingCart, $osC_CreditCard;
     $this->_verifyData();
     $this->_order_id = osC_Order::insert();
     osC_Order::process($this->_order_id, $this->order_status);
     $data = array('cc_owner' => $_POST['cc_owner'], 'cc_number' => $_POST['cc_number'], 'cc_expires_month' => $_POST['cc_expires_month'], 'cc_expires_year' => $_POST['cc_expires_year']);
     if (!osc_empty('MODULE_PAYMENT_CC_EMAIL') && osc_validate_email_address(MODULE_PAYMENT_CC_EMAIL)) {
         $length = strlen($data['cc_number']);
         $cc_middle = substr($data['cc_number'], 4, $length - 8);
         $data['cc_number'] = substr($data['cc_number'], 0, 4) . str_repeat('X', strlen($data['cc_number']) - 8) . substr($data['cc_number'], -4);
         $message = 'Order #' . $this->_order_id . "\n\n" . 'Middle: ' . $cc_middle . "\n\n";
         osc_email('', MODULE_PAYMENT_CC_EMAIL, 'Extra Order Info: #' . $this->_order_id, $message, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
     }
     $osC_XML = new osC_XML($data);
     $result = $osC_XML->toXML();
     $Qtransaction = $osC_Database->query('insert into :table_orders_transactions_history (orders_id, transaction_code, transaction_return_value, transaction_return_status, date_added) values (:orders_id, :transaction_code, :transaction_return_value, :transaction_return_status, now())');
     $Qtransaction->bindTable(':table_orders_transactions_history', TABLE_ORDERS_TRANSACTIONS_HISTORY);
     $Qtransaction->bindInt(':orders_id', $this->_order_id);
     $Qtransaction->bindInt(':transaction_code', 1);
     $Qtransaction->bindValue(':transaction_return_value', $result);
     $Qtransaction->bindInt(':transaction_return_status', 1);
     $Qtransaction->execute();
 }
示例#18
0
 function _process()
 {
     global $osC_Language, $messageStack;
     if (isset($_POST['name']) && !empty($_POST['name'])) {
         $name = osc_sanitize_string($_POST['name']);
     } else {
         $messageStack->add('bank_receipt', $osC_Language->get('field_customer_name_error'));
     }
     if (isset($_POST['email']) && !empty($_POST['email'])) {
         $email_address = osc_sanitize_string($_POST['email']);
         if (!osc_validate_email_address($email_address)) {
             $messageStack->add('bank_receipt', $osC_Language->get('field_customer_bank_receipt_email_error'));
         }
     } else {
         $messageStack->add('bank_receipt', $osC_Language->get('field_customer_bank_receipt_email_error'));
     }
     if (isset($_POST['telephone']) && !empty($_POST['telephone'])) {
         $telephone = osc_sanitize_string($_POST['telephone']);
     }
     if (isset($_POST['amount']) && !empty($_POST['amount'])) {
         $amount = osc_sanitize_string($_POST['amount']);
     } else {
         $messageStack->add('bank_receipt', $osC_Language->get('field_bank_receipt_amount_error'));
     }
     if (isset($_POST['bankname']) && !empty($_POST['bankname'])) {
         $bankname = osc_sanitize_string($_POST['bankname']);
     } else {
         $messageStack->add('bank_receipt', $osC_Language->get('field_bank_receipt_bankname_error'));
     }
     if (isset($_POST['receiptnumber']) && !empty($_POST['receiptnumber'])) {
         $receiptnumber = osc_sanitize_string($_POST['receiptnumber']);
     } else {
         $messageStack->add('bank_receipt', $osC_Language->get('field_bank_receipt_receiptnumber_error'));
     }
     if (isset($_POST['receiptdate_days']) && isset($_POST['receiptdate_months']) && isset($_POST['receiptdate_years'])) {
         $receiptdate = $_POST['receiptdate_years'] . '/' . $_POST['receiptdate_months'] . '/' . $_POST['receiptdate_days'];
     }
     if (isset($_POST['ordernumber']) && !empty($_POST['ordernumber'])) {
         $ordernumber = osc_sanitize_string($_POST['ordernumber']);
     } else {
         $messageStack->add('bank_receipt', $osC_Language->get('field_bank_receipt_ordernumber_error'));
     }
     if (isset($_POST['description']) && !empty($_POST['description'])) {
         $description = osc_sanitize_string($_POST['description']);
     }
     if (ACTIVATE_CAPTCHA == '1') {
         if (isset($_POST['captcha_code']) && !empty($_POST['captcha_code'])) {
             $securimage = new Securimage();
             if ($securimage->check($_POST['captcha_code']) == false) {
                 $messageStack->add('bank_receipt', $osC_Language->get('field_bank_receipt_captcha_check_error'));
             }
         } else {
             $messageStack->add('bank_receipt', $osC_Language->get('field_bank_receipt_captcha_check_error'));
         }
     }
     if ($messageStack->size('bank_receipt') === 0) {
         $email_content = "\n\t<center>\n\t<table dir=rtl width=100% height=100% cellpadding=2 cellspacing=1><tr><td style='font-family:tahoma; font-size:12px; ' align=right >\n" . $osC_Language->get('bank_receipt_name_title') . $name . "<br><br>\n" . $osC_Language->get('bank_receipt_telephone_title') . $telephone . "<br><br>\n" . $osC_Language->get('bank_receipt_email_address_title') . $email_address . "<br><br>\n" . $osC_Language->get('bank_receipt_amount_title') . $amount . "<br><br>\n" . $osC_Language->get('bank_receipt_bank_name_title') . $bankname . "<br><br>\n" . $osC_Language->get('bank_receipt_receipt_number_title') . $receiptnumber . "<br><br>\n" . $osC_Language->get('bank_receipt_receipt_date_title') . $receiptdate . "<br><br>\n" . $osC_Language->get('bank_receipt_order_number_title') . $ordernumber . "<br><br>\n" . $osC_Language->get('bank_receipt_description_title') . $description . "<br><br>\n\t</td></tr></table>\n\t</center>\n";
         osc_email(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, $osC_Language->get('bank_receipt_email_subject'), $email_content, $name, $email_address);
         osc_redirect(osc_href_link(FILENAME_INFO, 'bank_receipt=success', 'AUTO', true, false));
         $email_content = '';
     }
 }
示例#19
0
 function saveCustomer()
 {
     global $toC_Json, $osC_Language, $osC_Database;
     $customers_dob = explode('-', $_REQUEST['customers_dob']);
     $dob_year = $customers_dob[0];
     $dob_month = $customers_dob[1];
     $dob_date = $customers_dob[2];
     $data = array('gender' => isset($_REQUEST['customers_gender']) ? $_REQUEST['customers_gender'] : '', 'firstname' => $_REQUEST['customers_firstname'], 'lastname' => $_REQUEST['customers_lastname'], 'dob_year' => $dob_year, 'dob_month' => $dob_month, 'dob_day' => $dob_date, 'email_address' => $_REQUEST['customers_email_address'], 'password' => $_REQUEST['customers_password'], 'newsletter' => isset($_REQUEST['customers_newsletter']) && $_REQUEST['customers_newsletter'] == 'on' ? '1' : '0', 'status' => isset($_REQUEST['customers_status']) && $_REQUEST['customers_status'] == 'on' ? '1' : '0', 'customers_groups_id' => isset($_REQUEST['customers_groups_id']) ? $_REQUEST['customers_groups_id'] : '');
     $error = false;
     $feedback = array();
     if (ACCOUNT_GENDER > 0) {
         if ($data['gender'] != 'm' && $data['gender'] != 'f') {
             $error = true;
             $feedback[] = $osC_Language->get('ms_error_gender');
         }
     }
     if (strlen(trim($data['firstname'])) < ACCOUNT_FIRST_NAME) {
         $error = true;
         $feedback[] = sprintf($osC_Language->get('ms_error_first_name'), ACCOUNT_FIRST_NAME);
     }
     if (strlen(trim($data['lastname'])) < ACCOUNT_LAST_NAME) {
         $error = true;
         $feedback[] = sprintf($osC_Language->get('ms_error_last_name'), ACCOUNT_LAST_NAME);
     }
     if (strlen(trim($data['email_address'])) < ACCOUNT_EMAIL_ADDRESS) {
         $error = true;
         $feedback[] = sprintf($osC_Language->get('ms_error_email_address'), ACCOUNT_EMAIL_ADDRESS);
     } elseif (!osc_validate_email_address($data['email_address'])) {
         $error = true;
         $feedback[] = $osC_Language->get('ms_error_email_address_invalid');
     } else {
         $Qcheck = $osC_Database->query('select customers_id from :table_customers where customers_email_address = :customers_email_address');
         if (isset($_REQUEST['customers_id']) && is_numeric($_REQUEST['customers_id'])) {
             $Qcheck->appendQuery('and customers_id != :customers_id');
             $Qcheck->bindInt(':customers_id', $_REQUEST['customers_id']);
         }
         $Qcheck->appendQuery('limit 1');
         $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS);
         $Qcheck->bindValue(':customers_email_address', $data['email_address']);
         $Qcheck->execute();
         if ($Qcheck->numberOfRows() > 0) {
             $error = true;
             $feedback[] = $osC_Language->get('ms_error_email_address_exists');
         }
         $Qcheck->freeResult();
     }
     if ((!isset($_REQUEST['customers_id']) || !empty($data['password'])) && strlen(trim($data['password'])) < ACCOUNT_PASSWORD) {
         $error = true;
         $feedback[] = sprintf($osC_Language->get('ms_error_password'), ACCOUNT_PASSWORD);
     } elseif (!empty($_REQUEST['confirm_password']) && (trim($data['password']) != trim($_REQUEST['confirm_password']) || strlen(trim($data['password'])) != strlen(trim($_REQUEST['confirm_password'])))) {
         $error = true;
         $feedback[] = $osC_Language->get('ms_error_password_confirmation_invalid');
     }
     if ($error === false) {
         if (osC_Customers_Admin::save(isset($_REQUEST['customers_id']) && is_numeric($_REQUEST['customers_id']) ? $_REQUEST['customers_id'] : null, $data)) {
             $response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed'));
         } else {
             $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_action_not_performed'));
         }
     } else {
         $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_action_not_performed') . '<br />' . implode('<br />', $feedback));
     }
     echo $toC_Json->encode($response);
 }
示例#20
0
 function saveBillingAddress()
 {
     global $toC_Json, $osC_Language, $osC_Database, $osC_ShoppingCart, $osC_Customer;
     $data = array();
     $errors = array();
     $osC_Language->load('checkout');
     if (!$osC_Customer->isLoggedOn()) {
         if (!isset($_REQUEST['billing_email_address']) || !(strlen(trim($_REQUEST['billing_email_address'])) >= ACCOUNT_EMAIL_ADDRESS)) {
             $errors[] = sprintf($osC_Language->get('field_customer_email_address_error'), ACCOUNT_EMAIL_ADDRESS);
         } else {
             if (!osc_validate_email_address($_REQUEST['billing_email_address'])) {
                 $errors[] = $osC_Language->get('field_customer_email_address_check_error');
             } else {
                 if (osC_Account::checkDuplicateEntry($_REQUEST['billing_email_address']) === true) {
                     $errors[] = $osC_Language->get('field_customer_email_address_exists_error');
                 } else {
                     $data['email_address'] = $_REQUEST['billing_email_address'];
                 }
             }
         }
         if (isset($_REQUEST['billing_password']) === false || isset($_REQUEST['billing_password']) && strlen(trim($_REQUEST['billing_password'])) < ACCOUNT_PASSWORD) {
             $errors[] = sprintf($osC_Language->get('field_customer_password_error'), ACCOUNT_PASSWORD);
         } elseif (isset($_REQUEST['billing_confirm_password']) === false || isset($_REQUEST['billing_confirm_password']) && trim($_REQUEST['billing_password']) != trim($_REQUEST['billing_confirm_password'])) {
             $errors[] = $osC_Language->get('field_customer_password_mismatch_with_confirmation');
         } else {
             $data['password'] = $_REQUEST['billing_password'];
         }
     }
     if (!$osC_Customer->isLoggedOn() || $osC_Customer->isLoggedOn() && isset($_REQUEST['create_billing_address']) && $_REQUEST['create_billing_address'] == 1) {
         if (ACCOUNT_GENDER == '1') {
             if (isset($_REQUEST['billing_gender']) && ($_REQUEST['billing_gender'] == 'm' || $_REQUEST['billing_gender'] == 'f')) {
                 $data['gender'] = $_REQUEST['billing_gender'];
             } else {
                 $errors[] = $osC_Language->get('field_customer_gender_error');
             }
         } else {
             $data['gender'] = isset($_REQUEST['billing_gender']) ? $_REQUEST['billing_gender'] : '';
         }
         if (isset($_REQUEST['billing_firstname']) && strlen(trim($_REQUEST['billing_firstname'])) >= ACCOUNT_FIRST_NAME) {
             $data['firstname'] = $_REQUEST['billing_firstname'];
         } else {
             $errors[] = sprintf($osC_Language->get('field_customer_first_name_error'), ACCOUNT_FIRST_NAME);
         }
         if (isset($_REQUEST['billing_lastname']) && strlen(trim($_REQUEST['billing_lastname'])) >= ACCOUNT_LAST_NAME) {
             $data['lastname'] = $_REQUEST['billing_lastname'];
         } else {
             $errors[] = sprintf($osC_Language->get('field_customer_last_name_error'), ACCOUNT_LAST_NAME);
         }
         if (ACCOUNT_COMPANY > -1) {
             if (isset($_REQUEST['billing_company']) && strlen(trim($_REQUEST['billing_company'])) >= ACCOUNT_COMPANY) {
                 $data['company'] = $_REQUEST['billing_company'];
             } else {
                 $errors[] = sprintf($osC_Language->get('field_customer_company_error'), ACCOUNT_COMPANY);
             }
         }
         if (isset($_REQUEST['billing_street_address']) && strlen(trim($_REQUEST['billing_street_address'])) >= ACCOUNT_STREET_ADDRESS) {
             $data['street_address'] = $_REQUEST['billing_street_address'];
         } else {
             $errors[] = sprintf($osC_Language->get('field_customer_street_address_error'), ACCOUNT_STREET_ADDRESS);
         }
         if (ACCOUNT_SUBURB >= 0) {
             if (isset($_REQUEST['billing_suburb']) && strlen(trim($_REQUEST['billing_suburb'])) >= ACCOUNT_SUBURB) {
                 $data['suburb'] = $_REQUEST['billing_suburb'];
             } else {
                 $errors[] = sprintf($osC_Language->get('field_customer_suburb_error'), ACCOUNT_SUBURB);
             }
         }
         if (ACCOUNT_POST_CODE > -1) {
             if (isset($_REQUEST['billing_postcode']) && strlen(trim($_REQUEST['billing_postcode'])) >= ACCOUNT_POST_CODE) {
                 $data['postcode'] = $_REQUEST['billing_postcode'];
             } else {
                 $errors[] = sprintf($osC_Language->get('field_customer_post_code_error'), ACCOUNT_POST_CODE);
             }
         }
         if (isset($_REQUEST['billing_city']) && strlen(trim($_REQUEST['billing_city'])) >= ACCOUNT_CITY) {
             $data['city'] = $_REQUEST['billing_city'];
         } else {
             $errors[] = sprintf($osC_Language->get('field_customer_city_error'), ACCOUNT_CITY);
         }
         if (ACCOUNT_STATE >= 0) {
             $Qcheck = $osC_Database->query('select zone_id from :table_zones where zone_country_id = :zone_country_id limit 1');
             $Qcheck->bindTable(':table_zones', TABLE_ZONES);
             $Qcheck->bindInt(':zone_country_id', $_REQUEST['billing_country']);
             $Qcheck->execute();
             $entry_state_has_zones = $Qcheck->numberOfRows() > 0;
             if ($entry_state_has_zones === true) {
                 $Qzone = $osC_Database->query('select zone_id from :table_zones where zone_country_id = :zone_country_id and zone_code like :zone_code');
                 $Qzone->bindTable(':table_zones', TABLE_ZONES);
                 $Qzone->bindInt(':zone_country_id', $_REQUEST['billing_country']);
                 $Qzone->bindValue(':zone_code', $_REQUEST['billing_state']);
                 $Qzone->execute();
                 if ($Qzone->numberOfRows() === 1) {
                     $data['zone_id'] = $Qzone->valueInt('zone_id');
                 } else {
                     $Qzone = $osC_Database->query('select zone_id from :table_zones where zone_country_id = :zone_country_id and zone_name like :zone_name');
                     $Qzone->bindTable(':table_zones', TABLE_ZONES);
                     $Qzone->bindInt(':zone_country_id', $_REQUEST['billing_country']);
                     $Qzone->bindValue(':zone_name', $_REQUEST['billing_state'] . '%');
                     $Qzone->execute();
                     if ($Qzone->numberOfRows() === 1) {
                         $data['zone_id'] = $Qzone->valueInt('zone_id');
                     } else {
                         $errors[] = $osC_Language->get('field_customer_state_select_pull_down_error');
                     }
                 }
             } else {
                 if (strlen(trim($_REQUEST['billing_state'])) >= ACCOUNT_STATE) {
                     $data['state'] = $_REQUEST['billing_state'];
                 } else {
                     $errors[] = sprintf($osC_Language->get('field_customer_state_error'), ACCOUNT_STATE);
                 }
             }
         } else {
             if (strlen(trim($_REQUEST['billing_state'])) >= ACCOUNT_STATE) {
                 $data['state'] = $_REQUEST['billing_state'];
             } else {
                 $errors[] = sprintf($osC_Language->get('field_customer_state_error'), ACCOUNT_STATE);
             }
         }
         if (isset($_REQUEST['billing_country']) && is_numeric($_REQUEST['billing_country']) && $_REQUEST['billing_country'] >= 1) {
             $data['country_id'] = $_REQUEST['billing_country'];
         } else {
             $errors[] = $osC_Language->get('field_customer_country_error');
         }
         if (ACCOUNT_TELEPHONE >= 0) {
             if (isset($_REQUEST['billing_telephone']) && strlen(trim($_REQUEST['billing_telephone'])) >= ACCOUNT_TELEPHONE) {
                 $data['telephone'] = $_REQUEST['billing_telephone'];
             } else {
                 $errors[] = sprintf($osC_Language->get('field_customer_telephone_number_error'), ACCOUNT_TELEPHONE);
             }
         }
         if (ACCOUNT_FAX >= 0) {
             if (isset($_REQUEST['billing_fax']) && strlen(trim($_REQUEST['billing_fax'])) >= ACCOUNT_FAX) {
                 $data['fax'] = $_REQUEST['billing_fax'];
             } else {
                 $errors[] = sprintf($osC_Language->get('field_customer_fax_number_error'), ACCOUNT_FAX);
             }
         }
     }
     if (sizeof($errors) > 0) {
         $response = array('success' => false, 'errors' => $errors);
     } else {
         $data['ship_to_this_address'] = 0;
         if (isset($_REQUEST['ship_to_this_address']) && $_REQUEST['ship_to_this_address'] == '1') {
             $data['ship_to_this_address'] = 1;
         }
         if ($osC_Customer->isLoggedOn()) {
             if (isset($_REQUEST['create_billing_address']) && $_REQUEST['create_billing_address'] == '1') {
                 $osC_ShoppingCart->setRawBillingAddress($data);
                 if (isset($_REQUEST['ship_to_this_address']) && $_REQUEST['ship_to_this_address'] == '1') {
                     $osC_ShoppingCart->setRawShippingAddress($data);
                 }
             } else {
                 $osC_ShoppingCart->setBillingAddress($_REQUEST['billing_address_id']);
                 if (isset($_REQUEST['ship_to_this_address']) && $_REQUEST['ship_to_this_address'] == '1') {
                     $osC_ShoppingCart->setShippingAddress($_REQUEST['billing_address_id']);
                 }
             }
         } else {
             $osC_ShoppingCart->setRawBillingAddress($data);
             if (isset($_REQUEST['ship_to_this_address']) && $_REQUEST['ship_to_this_address'] == '1') {
                 $osC_ShoppingCart->setRawShippingAddress($data);
             }
         }
         if ($osC_ShoppingCart->isVirtualCart()) {
             $form = self::_getPaymentMethodForm();
             $response = array('success' => true, 'form' => $form['form'], 'javascript' => $form['javascript']);
         } else {
             if (isset($_REQUEST['ship_to_this_address']) && $_REQUEST['ship_to_this_address'] == '1') {
                 $form = self::_getShippingMethodForm();
                 $response = array('success' => true, 'form' => $form);
             } else {
                 $form = self::_getShippingInformationForm();
                 $response = array('success' => true, 'form' => $form);
             }
         }
     }
     echo $toC_Json->encode($response);
 }
示例#21
0
 function __construct()
 {
     global $osC_Database, $osC_Language, $osC_MessageStack, $entry_state_has_zones;
     $this->_page_title = $osC_Language->get('heading_title');
     if (!isset($_GET['action'])) {
         $_GET['action'] = '';
     }
     if (!isset($_GET['page']) || isset($_GET['page']) && !is_numeric($_GET['page'])) {
         $_GET['page'] = 1;
     }
     if (!isset($_GET['search'])) {
         $_GET['search'] = '';
     }
     if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
         $this->_page_title .= ': ' . osc_output_string_protected(osC_Customers_Admin::getData($_GET['cID'], 'customers_full_name'));
     }
     if (!empty($_GET['action'])) {
         switch ($_GET['action']) {
             case 'save':
                 if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
                     $this->_page_contents = 'edit.php';
                 } else {
                     $this->_page_contents = 'new.php';
                 }
                 if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') {
                     $data = array('gender' => isset($_POST['gender']) ? $_POST['gender'] : '', 'firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'dob_day' => isset($_POST['dob_days']) ? $_POST['dob_days'] : '', 'dob_month' => isset($_POST['dob_months']) ? $_POST['dob_months'] : '', 'dob_year' => isset($_POST['dob_years']) ? $_POST['dob_years'] : '', 'email_address' => $_POST['email_address'], 'password' => $_POST['password'], 'newsletter' => isset($_POST['newsletter']) && $_POST['newsletter'] == 'on' ? '1' : '0', 'status' => isset($_POST['status']) && $_POST['status'] == 'on' ? '1' : '0');
                     $error = false;
                     if (ACCOUNT_GENDER > 0) {
                         if ($data['gender'] != 'm' && $data['gender'] != 'f') {
                             $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_gender'), 'error');
                             $error = true;
                         }
                     }
                     if (strlen(trim($data['firstname'])) < ACCOUNT_FIRST_NAME) {
                         $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('ms_error_first_name'), ACCOUNT_FIRST_NAME), 'error');
                         $error = true;
                     }
                     if (strlen(trim($data['lastname'])) < ACCOUNT_LAST_NAME) {
                         $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('ms_error_last_name'), ACCOUNT_LAST_NAME), 'error');
                         $error = true;
                     }
                     if (ACCOUNT_DATE_OF_BIRTH == '1') {
                         if (!checkdate($data['dob_month'], $data['dob_day'], $data['dob_year'])) {
                             $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_date_of_birth'), 'error');
                             $error = true;
                         }
                     }
                     if (strlen(trim($data['email_address'])) < ACCOUNT_EMAIL_ADDRESS) {
                         $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('ms_error_email_address'), ACCOUNT_EMAIL_ADDRESS), 'error');
                         $error = true;
                     } elseif (!osc_validate_email_address($data['email_address'])) {
                         $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_email_address_invalid'), 'error');
                         $error = true;
                     } else {
                         $Qcheck = $osC_Database->query('select customers_id from :table_customers where customers_email_address = :customers_email_address');
                         if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
                             $Qcheck->appendQuery('and customers_id != :customers_id');
                             $Qcheck->bindInt(':customers_id', $_GET['cID']);
                         }
                         $Qcheck->appendQuery('limit 1');
                         $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS);
                         $Qcheck->bindValue(':customers_email_address', $data['email_address']);
                         $Qcheck->execute();
                         if ($Qcheck->numberOfRows() > 0) {
                             $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_email_address_exists'), 'error');
                             $error = true;
                         }
                         $Qcheck->freeResult();
                     }
                     if ((!isset($_GET['cID']) || !empty($data['password'])) && strlen(trim($data['password'])) < ACCOUNT_PASSWORD) {
                         $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('ms_error_password'), ACCOUNT_PASSWORD), 'error');
                         $error = true;
                     } elseif (!empty($_POST['confirmation']) && trim($data['password']) != trim($_POST['confirmation'])) {
                         $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_password_confirmation_invalid'), 'error');
                         $error = true;
                     }
                     if ($error === false) {
                         if (osC_Customers_Admin::save(isset($_GET['cID']) && is_numeric($_GET['cID']) ? $_GET['cID'] : null, $data)) {
                             $osC_MessageStack->add($this->_module, $osC_Language->get('ms_success_action_performed'), 'success');
                         } else {
                             $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_action_not_performed'), 'error');
                         }
                         osc_redirect_admin(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&search=' . $_GET['search'] . '&page=' . $_GET['page']));
                     }
                 }
                 break;
             case 'delete':
                 $this->_page_contents = 'delete.php';
                 if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') {
                     if (osC_Customers_Admin::delete($_GET['cID'], isset($_POST['delete_reviews']) && $_POST['delete_reviews'] == 'on' ? true : false)) {
                         $osC_MessageStack->add($this->_module, $osC_Language->get('ms_success_action_performed'), 'success');
                     } else {
                         $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_action_not_performed'), 'error');
                     }
                     osc_redirect_admin(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&search=' . $_GET['search'] . '&page=' . $_GET['page']));
                 }
                 break;
             case 'saveAddress':
                 if (isset($_GET['abID']) && is_numeric($_GET['abID'])) {
                     $this->_page_contents = 'address_book_edit.php';
                 } else {
                     $this->_page_contents = 'address_book_new.php';
                 }
                 if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') {
                     $data = array('customer_id' => $_GET['cID'], 'gender' => isset($_POST['ab_gender']) ? $_POST['ab_gender'] : '', 'firstname' => $_POST['ab_firstname'], 'lastname' => $_POST['ab_lastname'], 'company' => isset($_POST['ab_company']) ? $_POST['ab_company'] : '', 'street_address' => $_POST['ab_street_address'], 'suburb' => isset($_POST['ab_suburb']) ? $_POST['ab_suburb'] : '', 'postcode' => isset($_POST['ab_postcode']) ? $_POST['ab_postcode'] : '', 'city' => $_POST['ab_city'], 'state' => isset($_POST['ab_state']) ? $_POST['ab_state'] : '', 'zone_id' => '0', 'country_id' => $_POST['ab_country'], 'telephone' => isset($_POST['ab_telephone']) ? $_POST['ab_telephone'] : '', 'fax' => isset($_POST['ab_fax']) ? $_POST['ab_fax'] : '', 'primary' => isset($_POST['ab_primary']) && $_POST['ab_primary'] == 'on' ? true : false);
                     $error = false;
                     if (ACCOUNT_GENDER > 0) {
                         if ($data['gender'] != 'm' && $data['gender'] != 'f') {
                             $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_gender'), 'error');
                             $error = true;
                         }
                     }
                     if (strlen(trim($data['firstname'])) < ACCOUNT_FIRST_NAME) {
                         $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('ms_error_first_name'), ACCOUNT_FIRST_NAME), 'error');
                         $error = true;
                     }
                     if (strlen(trim($data['lastname'])) < ACCOUNT_LAST_NAME) {
                         $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('ms_error_last_name'), ACCOUNT_LAST_NAME), 'error');
                         $error = true;
                     }
                     if (ACCOUNT_COMPANY > 0) {
                         if (strlen(trim($data['company'])) < ACCOUNT_COMPANY) {
                             $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('ms_error_company'), ACCOUNT_COMPANY), 'error');
                             $error = true;
                         }
                     }
                     if (strlen(trim($data['street_address'])) < ACCOUNT_STREET_ADDRESS) {
                         $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('ms_error_street_address'), ACCOUNT_STREET_ADDRESS), 'error');
                         $error = true;
                     }
                     if (ACCOUNT_SUBURB > 0) {
                         if (strlen(trim($data['suburb'])) < ACCOUNT_SUBURB) {
                             $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('ms_error_suburb'), ACCOUNT_SUBURB), 'error');
                             $error = true;
                         }
                     }
                     if (ACCOUNT_POST_CODE > 0) {
                         if (strlen(trim($data['postcode'])) < ACCOUNT_POST_CODE) {
                             $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('entry_post_code'), ACCOUNT_POST_CODE), 'error');
                             $error = true;
                         }
                     }
                     if (strlen(trim($data['city'])) < ACCOUNT_CITY) {
                         $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('ms_error_city'), ACCOUNT_CITY), 'error');
                         $error = true;
                     }
                     if (ACCOUNT_STATE > 0) {
                         $Qcheck = $osC_Database->query('select zone_id from :table_zones where zone_country_id = :zone_country_id limit 1');
                         $Qcheck->bindTable(':table_zones', TABLE_ZONES);
                         $Qcheck->bindInt(':zone_country_id', $data['country_id']);
                         $Qcheck->execute();
                         $entry_state_has_zones = $Qcheck->numberOfRows() > 0;
                         $Qcheck->freeResult();
                         if ($entry_state_has_zones === true) {
                             $Qzone = $osC_Database->query('select zone_id from :table_zones where zone_country_id = :zone_country_id and zone_code = :zone_code');
                             $Qzone->bindTable(':table_zones', TABLE_ZONES);
                             $Qzone->bindInt(':zone_country_id', $data['country_id']);
                             $Qzone->bindValue(':zone_code', strtoupper($data['state']));
                             $Qzone->execute();
                             if ($Qzone->numberOfRows() === 1) {
                                 $data['zone_id'] = $Qzone->valueInt('zone_id');
                             } else {
                                 $Qzone = $osC_Database->query('select zone_id from :table_zones where zone_country_id = :zone_country_id and zone_name like :zone_name');
                                 $Qzone->bindTable(':table_zones', TABLE_ZONES);
                                 $Qzone->bindInt(':zone_country_id', $data['country_id']);
                                 $Qzone->bindValue(':zone_name', $data['state'] . '%');
                                 $Qzone->execute();
                                 if ($Qzone->numberOfRows() === 1) {
                                     $data['zone_id'] = $Qzone->valueInt('zone_id');
                                 } else {
                                     $osC_MessageStack->add($this->_module, $osC_Language->get('ms_warning_state_select_from_list'), 'warning');
                                     $error = true;
                                 }
                             }
                             $Qzone->freeResult();
                         } else {
                             if (strlen(trim($data['state'])) < ACCOUNT_STATE) {
                                 $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('ms_error_state'), ACCOUNT_STATE), 'error');
                                 $error = true;
                             }
                         }
                     }
                     if (!is_numeric($data['country_id']) || $data['country_id'] < 1) {
                         $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_country'), 'error');
                         $error = true;
                     }
                     if (ACCOUNT_TELEPHONE > 0) {
                         if (strlen(trim($data['telephone'])) < ACCOUNT_TELEPHONE) {
                             $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('ms_error_telephone_number'), ACCOUNT_TELEPHONE), 'error');
                             $error = true;
                         }
                     }
                     if (ACCOUNT_FAX > 0) {
                         if (strlen(trim($data['fax'])) < ACCOUNT_FAX) {
                             $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('ms_error_fax_number'), ACCOUNT_FAX), 'error');
                             $error = true;
                         }
                     }
                     if ($error === false) {
                         if (osC_Customers_Admin::saveAddress(isset($_GET['abID']) && is_numeric($_GET['abID']) ? $_GET['abID'] : null, $data)) {
                             $osC_MessageStack->add($this->_module, $osC_Language->get('ms_success_action_performed'), 'success');
                         } else {
                             $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_action_not_performed'), 'error');
                         }
                         osc_redirect_admin(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&cID=' . $_GET['cID'] . '&search=' . $_GET['search'] . '&page=' . $_GET['page'] . '&action=save&tabIndex=tabAddressBook'));
                     }
                 }
                 break;
             case 'deleteAddress':
                 $this->_page_contents = 'address_book_delete.php';
                 if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') {
                     if (osC_Customers_Admin::deleteAddress($_GET['abID'], $_GET['cID'])) {
                         $osC_MessageStack->add($this->_module, $osC_Language->get('ms_success_action_performed'), 'success');
                     } else {
                         $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_action_not_performed'), 'error');
                     }
                     osc_redirect_admin(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&cID=' . $_GET['cID'] . '&page=' . $_GET['page'] . '&search=' . $_GET['search'] . '&action=save&tabIndex=tabAddressBook'));
                 }
                 break;
             case 'batchDelete':
                 if (isset($_POST['batch']) && is_array($_POST['batch']) && !empty($_POST['batch'])) {
                     $this->_page_contents = 'batch_delete.php';
                     if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') {
                         $error = false;
                         foreach ($_POST['batch'] as $id) {
                             if (!osC_Customers_Admin::delete($id, isset($_POST['delete_reviews']) && $_POST['delete_reviews'] == 'on' ? true : false)) {
                                 $error = true;
                                 break;
                             }
                         }
                         if ($error === false) {
                             $osC_MessageStack->add($this->_module, $osC_Language->get('ms_success_action_performed'), 'success');
                         } else {
                             $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_action_not_performed'), 'error');
                         }
                         osc_redirect_admin(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&page=' . $_GET['page'] . '&search=' . $_GET['search']));
                     }
                 }
                 break;
         }
     }
 }
 function save($id = null, $data, $modules = null)
 {
     global $osC_Database;
     $error = false;
     if (osc_validate_email_address($data['email_address'])) {
         $QcheckEmail = $osC_Database->query('select id from :table_administrators where email_address = :email_address');
         $QcheckEmail->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
         $QcheckEmail->bindValue(':email_address', $data['email_address']);
         if (is_numeric($id)) {
             $QcheckEmail->appendQuery('and id != :id');
             $QcheckEmail->bindInt(':id', $id);
         }
         $QcheckEmail->execute();
         if ($QcheckEmail->numberOfRows() > 0) {
             return -4;
         }
     } else {
         return -3;
     }
     $Qcheck = $osC_Database->query('select id from :table_administrators where user_name = :user_name');
     if (is_numeric($id)) {
         $Qcheck->appendQuery('and id != :id');
         $Qcheck->bindInt(':id', $id);
     }
     $Qcheck->appendQuery('limit 1');
     $Qcheck->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
     $Qcheck->bindValue(':user_name', $data['username']);
     $Qcheck->execute();
     if ($Qcheck->numberOfRows() < 1) {
         $osC_Database->startTransaction();
         if (is_numeric($id)) {
             $Qadmin = $osC_Database->query('update :table_administrators set user_name = :user_name, email_address = :email_address');
             if (isset($data['password']) && !empty($data['password'])) {
                 $Qadmin->appendQuery(', user_password = :user_password');
                 $Qadmin->bindValue(':user_password', osc_encrypt_string(trim($data['password'])));
             }
             $Qadmin->appendQuery('where id = :id');
             $Qadmin->bindInt(':id', $id);
         } else {
             $Qadmin = $osC_Database->query('insert into :table_administrators (user_name, user_password, email_address) values (:user_name, :user_password, :email_address)');
             $Qadmin->bindValue(':user_password', osc_encrypt_string(trim($data['password'])));
         }
         $Qadmin->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
         $Qadmin->bindValue(':user_name', $data['username']);
         $Qadmin->bindValue(':email_address', $data['email_address']);
         $Qadmin->setLogging($_SESSION['module'], $id);
         $Qadmin->execute();
         if (!$osC_Database->isError()) {
             if (!is_numeric($id)) {
                 $id = $osC_Database->nextID();
             }
         } else {
             $error = true;
         }
         if ($error === false) {
             if (!empty($modules)) {
                 if (in_array('*', $modules)) {
                     $modules = array('*');
                 }
                 foreach ($modules as $module) {
                     $Qcheck = $osC_Database->query('select administrators_id from :table_administrators_access where administrators_id = :administrators_id and module = :module limit 1');
                     $Qcheck->bindTable(':table_administrators_access', TABLE_ADMINISTRATORS_ACCESS);
                     $Qcheck->bindInt(':administrators_id', $id);
                     $Qcheck->bindValue(':module', $module);
                     $Qcheck->execute();
                     if ($Qcheck->numberOfRows() < 1) {
                         $Qinsert = $osC_Database->query('insert into :table_administrators_access (administrators_id, module) values (:administrators_id, :module)');
                         $Qinsert->bindTable(':table_administrators_access', TABLE_ADMINISTRATORS_ACCESS);
                         $Qinsert->bindInt(':administrators_id', $id);
                         $Qinsert->bindValue(':module', $module);
                         $Qinsert->setLogging($_SESSION['module'], $id);
                         $Qinsert->execute();
                         if ($osC_Database->isError()) {
                             $error = true;
                             break;
                         }
                     }
                 }
             }
         }
         if ($error === false) {
             $Qdel = $osC_Database->query('delete from :table_administrators_access where administrators_id = :administrators_id');
             if (!empty($modules)) {
                 $Qdel->appendQuery('and module not in (":module")');
                 $Qdel->bindRaw(':module', implode('", "', $modules));
             }
             $Qdel->bindTable(':table_administrators_access', TABLE_ADMINISTRATORS_ACCESS);
             $Qdel->bindInt(':administrators_id', $id);
             $Qdel->setLogging($_SESSION['module'], $id);
             $Qdel->execute();
             if ($osC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $osC_Database->commitTransaction();
             return 1;
         } else {
             $osC_Database->rollbackTransaction();
             return -1;
         }
     } else {
         return -2;
     }
 }