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')); } }
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')); } }
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')); } }
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); }