protected function _process()
 {
     global $lC_MessageStack, $lC_Database, $lC_Language, $lC_Vqmod;
     require_once $lC_Vqmod->modCheck('includes/classes/account.php');
     $Qcheck = $lC_Database->query('select customers_id, customers_firstname, customers_lastname, customers_gender, customers_email_address, customers_password from :table_customers where customers_email_address = :customers_email_address limit 1');
     $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS);
     $Qcheck->bindValue(':customers_email_address', $_POST['email_address']);
     $Qcheck->execute();
     if ($Qcheck->numberOfRows() === 1) {
         $password = lc_create_random_string(ACCOUNT_PASSWORD);
         if (lC_Account::savePassword($password, $Qcheck->valueInt('customers_id'))) {
             if (ACCOUNT_GENDER > -1) {
                 if ($data['gender'] == 'm') {
                     $email_text = sprintf($lC_Language->get('email_addressing_gender_male'), $Qcheck->valueProtected('customers_lastname')) . "\n\n";
                 } else {
                     $email_text = sprintf($lC_Language->get('email_addressing_gender_female'), $Qcheck->valueProtected('customers_lastname')) . "\n\n";
                 }
             } else {
                 $email_text = sprintf($lC_Language->get('email_addressing_gender_unknown'), $Qcheck->valueProtected('customers_firstname') . ' ' . $Qcheck->valueProtected('customers_lastname')) . "\n\n";
             }
             $email_text .= sprintf($lC_Language->get('email_password_reminder_body'), getenv('REMOTE_ADDR'), STORE_NAME, $password, STORE_OWNER_EMAIL_ADDRESS);
             lc_email($Qcheck->valueProtected('customers_firstname') . ' ' . $Qcheck->valueProtected('customers_lastname'), $Qcheck->valueProtected('customers_email_address'), sprintf($lC_Language->get('email_password_reminder_subject'), STORE_NAME), $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
         }
         lc_redirect(lc_href_link(FILENAME_ACCOUNT, 'login&success=' . urlencode($lC_Language->get('success_password_forgotten_sent')), 'SSL'));
     } else {
         $lC_MessageStack->add('password_forgotten', $lC_Language->get('error_password_forgotten_no_email_address_found'));
     }
 }
Example #2
0
 protected function _process()
 {
     global $lC_Language, $lC_MessageStack, $lC_Product;
     if (empty($_POST['from_name'])) {
         $lC_MessageStack->add('tell_a_friend', $lC_Language->get('error_tell_a_friend_customers_name_empty'));
     }
     if (!lc_validate_email_address($_POST['from_email_address'])) {
         $lC_MessageStack->add('tell_a_friend', $lC_Language->get('error_tell_a_friend_invalid_customers_email_address'));
     }
     if (empty($_POST['to_name'])) {
         $lC_MessageStack->add('tell_a_friend', $lC_Language->get('error_tell_a_friend_friends_name_empty'));
     }
     if (!lc_validate_email_address($_POST['to_email_address'])) {
         $lC_MessageStack->add('tell_a_friend', $lC_Language->get('error_tell_a_friend_invalid_friends_email_address'));
     }
     if ($lC_MessageStack->size('tell_a_friend') < 1) {
         $email_subject = sprintf($lC_Language->get('email_tell_a_friend_subject'), lc_sanitize_string($_POST['from_name']), STORE_NAME);
         $email_body = sprintf($lC_Language->get('email_tell_a_friend_intro'), lc_sanitize_string($_POST['to_name']), lc_sanitize_string($_POST['from_name']), $lC_Product->getTitle(), STORE_NAME) . "\n\n";
         if (!empty($_POST['message'])) {
             $email_body .= lc_sanitize_string($_POST['message']) . "\n\n";
         }
         $email_body .= sprintf($lC_Language->get('email_tell_a_friend_link'), lc_href_link(HTTP_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCTS, $lC_Product->getKeyword(), 'NONSSL', false)) . "\n\n" . sprintf($lC_Language->get('email_tell_a_friend_signature'), STORE_NAME . "\n" . HTTP_SERVER . DIR_WS_CATALOG . "\n");
         lc_email(lc_sanitize_string($_POST['to_name']), lc_sanitize_string($_POST['to_email_address']), $email_subject, $email_body, lc_sanitize_string($_POST['from_name']), lc_sanitize_string($_POST['from_email_address']));
         lc_redirect(lc_href_link(FILENAME_PRODUCTS, 'tell_a_friend&' . $lC_Product->getID() . '&success=' . urlencode(sprintf($lC_Language->get('success_tell_a_friend_email_sent'), $lC_Product->getTitle(), lc_output_string_protected($_POST['to_name'])))));
     }
 }
Example #3
0
 protected function _process()
 {
     global $lC_Language, $lC_MessageStack;
     $name = lc_sanitize_string($_POST['name']);
     $email_address = lc_sanitize_string($_POST['email']);
     $inquiry = lc_sanitize_string($_POST['inquiry']);
     if (lc_validate_email_address($email_address)) {
         lc_email(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, $lC_Language->get('contact_email_subject'), $inquiry, $name, $email_address);
         lc_redirect(lc_href_link(FILENAME_INFO, 'contact&success=' . urlencode($lC_Language->get('contact_email_sent_successfully')), 'AUTO'));
     } else {
         $lC_MessageStack->add('contact', $lC_Language->get('field_customer_email_address_check_error'));
     }
 }
Example #4
0
 /**
  * Stores a new customer account entry in the database
  *
  * @param array $data An array containing the customers information
  * @access public
  * @return boolean
  */
 public static function createEntry($data)
 {
     global $lC_Database, $lC_Session, $lC_Language, $lC_ShoppingCart, $lC_Customer, $lC_NavigationHistory;
     $Qcustomer = $lC_Database->query('insert into :table_customers (customers_firstname, customers_lastname, customers_email_address, customers_newsletter, customers_status, customers_ip_address, customers_password, customers_gender, customers_dob, number_of_logons, date_account_created) values (:customers_firstname, :customers_lastname, :customers_email_address, :customers_newsletter, :customers_status, :customers_ip_address, :customers_password, :customers_gender, :customers_dob, :number_of_logons, :date_account_created)');
     $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS);
     $Qcustomer->bindValue(':customers_firstname', $data['firstname']);
     $Qcustomer->bindValue(':customers_lastname', $data['lastname']);
     $Qcustomer->bindValue(':customers_email_address', $data['email_address']);
     $Qcustomer->bindValue(':customers_newsletter', $data['newsletter']);
     $Qcustomer->bindValue(':customers_status', '1');
     $Qcustomer->bindValue(':customers_ip_address', lc_get_ip_address());
     $Qcustomer->bindValue(':customers_password', lc_encrypt_string($data['password']));
     $Qcustomer->bindValue(':customers_gender', ACCOUNT_GENDER > -1 && isset($data['gender']) && ($data['gender'] == 'm' || $data['gender'] == 'f') ? $data['gender'] : '');
     $Qcustomer->bindValue(':customers_dob', ACCOUNT_DATE_OF_BIRTH == '1' ? @date('Ymd', $data['dob']) : '0000-00-00 00:00:00');
     $Qcustomer->bindInt(':number_of_logons', 0);
     $Qcustomer->bindRaw(':date_account_created', 'now()');
     $Qcustomer->execute();
     if ($Qcustomer->affectedRows() === 1) {
         $customer_id = $lC_Database->nextID();
         if (SERVICE_SESSION_REGENERATE_ID == '1') {
             $lC_Session->recreate();
         }
         $lC_Customer->setCustomerData($customer_id);
         // restore cart contents
         $lC_ShoppingCart->synchronizeWithDatabase();
         $lC_NavigationHistory->removeCurrentPage();
         // build the welcome email content
         if (ACCOUNT_GENDER > -1 && isset($data['gender'])) {
             if ($data['gender'] == 'm') {
                 $email_text = sprintf($lC_Language->get('email_addressing_gender_male'), $lC_Customer->getLastName()) . "\n\n";
             } else {
                 $email_text = sprintf($lC_Language->get('email_addressing_gender_female'), $lC_Customer->getLastName()) . "\n\n";
             }
         } else {
             $email_text = sprintf($lC_Language->get('email_addressing_gender_unknown'), $lC_Customer->getName()) . "\n\n";
         }
         $email_text .= sprintf($lC_Language->get('email_create_account_body'), STORE_NAME, STORE_OWNER_EMAIL_ADDRESS);
         lc_email($lC_Customer->getName(), $lC_Customer->getEmailAddress(), sprintf($lC_Language->get('email_create_account_subject'), STORE_NAME), $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
         return true;
     }
     return false;
 }
Example #5
0
 public static function save($id = null, $data, $send_email = true)
 {
     global $lC_Database, $lC_Language, $lC_DateTime;
     $lC_Language->loadIniFile('customers.php');
     $error = false;
     $result = array();
     if (!is_numeric($id) || is_numeric($id)) {
         // check that email doesnt exist
         $Qcheck = $lC_Database->query('select customers_id from :table_customers where customers_email_address = :customers_email_address');
         if (isset($id) && is_numeric($id)) {
             $Qcheck->appendQuery('and customers_id != :customers_id');
             $Qcheck->bindInt(':customers_id', $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;
             $result['rpcStatus'] = -2;
         }
         $Qcheck->freeResult();
         if (trim($data['password']) != null) {
             // check that passwords match
             if (trim($data['password']) != trim($data['confirmation'])) {
                 $error = true;
                 $result['rpcStatus'] = -3;
             }
         }
     } else {
         // check that passwords match
         if (trim($data['password']) != trim($data['confirmation'])) {
             $error = true;
             $result['rpcStatus'] = -3;
         }
     }
     if ($error === false) {
         $lC_Database->startTransaction();
         if (is_numeric($id)) {
             $Qcustomer = $lC_Database->query('update :table_customers set customers_group_id = :customers_group_id, customers_gender = :customers_gender, customers_firstname = :customers_firstname, customers_lastname = :customers_lastname, customers_email_address = :customers_email_address, customers_dob = :customers_dob, customers_newsletter = :customers_newsletter, customers_status = :customers_status, date_account_last_modified = :date_account_last_modified where customers_id = :customers_id');
             $Qcustomer->bindRaw(':date_account_last_modified', 'now()');
             $Qcustomer->bindInt(':customers_id', $id);
         } else {
             $Qcustomer = $lC_Database->query('insert into :table_customers (customers_group_id, customers_gender, customers_firstname, customers_lastname, customers_email_address, customers_dob, customers_newsletter, customers_status, number_of_logons, date_account_created) values (:customers_group_id, :customers_gender, :customers_firstname, :customers_lastname, :customers_email_address, :customers_dob, :customers_newsletter, :customers_status, :number_of_logons, :date_account_created)');
             $Qcustomer->bindInt(':number_of_logons', 0);
             $Qcustomer->bindRaw(':date_account_created', 'now()');
         }
         $dob = isset($data['dob']) && !empty($data['dob']) ? lC_DateTime::toDateTime($data['dob']) : '0000-00-00 00:00:00';
         $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS);
         $Qcustomer->bindValue(':customers_gender', $data['gender']);
         $Qcustomer->bindValue(':customers_firstname', $data['firstname']);
         $Qcustomer->bindValue(':customers_lastname', $data['lastname']);
         $Qcustomer->bindValue(':customers_email_address', $data['email_address']);
         $Qcustomer->bindValue(':customers_dob', $dob);
         $Qcustomer->bindInt(':customers_newsletter', $data['newsletter']);
         $Qcustomer->bindInt(':customers_status', $data['status']);
         $Qcustomer->bindInt(':customers_group_id', $data['group']);
         $Qcustomer->setLogging($_SESSION['module'], $id);
         $Qcustomer->execute();
         if (!$lC_Database->isError()) {
             if (!empty($data['password'])) {
                 $customer_id = !empty($id) ? $id : $lC_Database->nextID();
                 $result['new_customer_id'] = $customer_id;
                 $Qpassword = $lC_Database->query('update :table_customers set customers_password = :customers_password where customers_id = :customers_id');
                 $Qpassword->bindTable(':table_customers', TABLE_CUSTOMERS);
                 $Qpassword->bindValue(':customers_password', lc_encrypt_string(trim($data['password'])));
                 $Qpassword->bindInt(':customers_id', $customer_id);
                 $Qpassword->setLogging($_SESSION['module'], $customer_id);
                 $Qpassword->execute();
                 if ($lC_Database->isError()) {
                     $error = true;
                     $result['rpcStatus'] = -1;
                 }
             }
         }
     }
     if ($error === false) {
         $lC_Database->commitTransaction();
         if ($send_email === true) {
             if (empty($id)) {
                 $full_name = trim($data['firstname'] . ' ' . $data['lastname']);
                 $email_text = '';
                 if (ACCOUNT_GENDER > -1) {
                     if ($data['gender'] == 'm') {
                         $email_text .= sprintf($lC_Language->get('email_greet_mr'), trim($data['lastname'])) . "\n\n";
                     } else {
                         $email_text .= sprintf($lC_Language->get('email_greet_ms'), trim($data['lastname'])) . "\n\n";
                     }
                 } else {
                     $email_text .= sprintf($lC_Language->get('email_greet_general'), $full_name) . "\n\n";
                 }
                 $email_text .= sprintf($lC_Language->get('email_text'), STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, trim($data['password']));
                 $email_subject = sprintf($lC_Language->get('email_subject'), STORE_NAME);
                 lc_email($full_name, $data['email_address'], $email_subject, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
             }
         }
         return $result;
     }
     $lC_Database->rollbackTransaction();
     return $result;
 }
Example #6
0
 public static function lostPasswordConfirmEmail($email)
 {
     global $lC_Database, $lC_Language;
     $lC_Language->loadIniFile('login.php');
     // check for email
     $Qadmin = $lC_Database->query('select * from :table_administrators where user_name = :user_name limit 1');
     $Qadmin->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
     $Qadmin->bindValue(':user_name', $email);
     $Qadmin->execute();
     $admin = $Qadmin->toArray();
     // if email exists we continue
     if ($Qadmin->numberOfRows() > 0) {
         $lC_Database->startTransaction();
         $verify_key = utility::generateUID();
         // set the key to be verified from the resulting email
         $Qsetkey = $lC_Database->query('update :table_administrators set verify_key = :verify_key where user_name = :user_name');
         $Qsetkey->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
         $Qsetkey->bindValue(':user_name', $email);
         $Qsetkey->bindValue(':verify_key', $verify_key);
         $Qsetkey->setLogging($_SESSION['module'], $email);
         $Qsetkey->execute();
         if (!$lC_Database->isError()) {
             $lC_Database->commitTransaction();
             $_SESSION['user_not_exists'] = null;
             $_SESSION['user_confirmed_email'] = $email;
             // set email contents
             $email_text = '';
             $email_text .= sprintf($lC_Language->get('text_lost_password_verification_body_line_1'), $admin['first_name']) . "\n\n";
             $email_text .= sprintf($lC_Language->get('text_lost_password_verification_body_line_2'), $admin['user_name']) . "\n\n";
             $email_text .= sprintf($lC_Language->get('text_lost_password_verification_body_line_3'), lc_href_link_admin(FILENAME_DEFAULT, 'login&action=lost_password&email=' . $admin['user_name'] . '&key=' . $verify_key)) . "\n\n";
             $email_text .= sprintf($lC_Language->get('text_lost_password_verification_body_line_4'), $verify_key) . "\n\n";
             $email_text .= $lC_Language->get('text_lost_password_verification_body_line_5') . "\n\n";
             $email_text .= $lC_Language->get('text_lost_password_verification_body_line_6') . "\n\n";
             $email_text .= sprintf($lC_Language->get('text_lost_password_verification_body_line_7'), STORE_NAME) . "\n\n";
             // send verification email
             lc_email($Qadmin->valueProtected('first_name') . ' ' . $Qadmin->valueProtected('last_name'), $Qadmin->valueProtected('user_name'), sprintf($lC_Language->get('text_lost_password_verification_subject'), STORE_NAME), $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
             return true;
         } else {
             $lC_Database->rollbackTransaction();
             $_SESSION['user_not_exists'] = true;
             $_SESSION['user_confirmed_email'] = null;
             return false;
         }
     } else {
         $_SESSION['user_not_exists'] = true;
         $_SESSION['user_confirmed_email'] = null;
         return false;
     }
 }
Example #7
0
 public function sendEmail($id)
 {
     global $lC_Database, $lC_Language, $lC_Currencies, $lC_ShoppingCart;
     $Qorder = $lC_Database->query('select * from :table_orders where orders_id = :orders_id limit 1');
     $Qorder->bindTable(':table_orders', TABLE_ORDERS);
     $Qorder->bindInt(':orders_id', $id);
     $Qorder->execute();
     if ($Qorder->numberOfRows() === 1) {
         $email_order = STORE_NAME . "\n" . $lC_Language->get('email_order_separator') . "\n" . sprintf($lC_Language->get('email_order_order_number'), $id) . "\n" . sprintf($lC_Language->get('email_order_invoice_url'), lc_href_link(FILENAME_ACCOUNT, 'receipt=' . $id, 'SSL', false, true, true)) . "\n" . sprintf($lC_Language->get('email_order_date_ordered'), lC_DateTime::getLong()) . "\n\n" . $lC_Language->get('email_order_products') . "\n" . $lC_Language->get('email_order_separator') . "\n";
         $Qproducts = $lC_Database->query('select orders_products_id, products_model, products_sku, products_name, products_price, products_tax, products_quantity from :table_orders_products where orders_id = :orders_id order by orders_products_id');
         $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
         $Qproducts->bindInt(':orders_id', $id);
         $Qproducts->execute();
         while ($Qproducts->next()) {
             $skuModel = $Qproducts->value('products_model') != NULL ? $Qproducts->value('products_model') : NULL;
             if ($skuModel == NULL) {
                 $skuModel == ($Qproducts->value('products_sku') != NULL) ? $Qproducts->value('products_sku') : NULL;
             }
             $email_order .= $Qproducts->valueInt('products_quantity') . ' x ' . $Qproducts->value('products_name') . ' (' . $skuModel . ') = ' . $lC_Currencies->displayPriceWithTaxRate($Qproducts->value('products_price'), $Qproducts->value('products_tax'), $Qproducts->valueInt('products_quantity'), false, $Qorder->value('currency'), $Qorder->value('currency_value')) . "\n";
             $Qvariants = $lC_Database->query('select group_title, value_title from :table_orders_products_variants where orders_id = :orders_id and orders_products_id = :orders_products_id order by id');
             $Qvariants->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS);
             $Qvariants->bindInt(':orders_id', $id);
             $Qvariants->bindInt(':orders_products_id', $Qproducts->valueInt('orders_products_id'));
             $Qvariants->execute();
             while ($Qvariants->next()) {
                 $email_order .= "\t" . $Qvariants->value('group_title') . ': ' . $Qvariants->value('value_title') . "\n";
             }
         }
         unset($Qproducts);
         unset($Qvariants);
         $email_order .= $lC_Language->get('email_order_separator') . "\n";
         $Qtotals = $lC_Database->query('select title, text from :table_orders_total where orders_id = :orders_id order by sort_order');
         $Qtotals->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
         $Qtotals->bindInt(':orders_id', $id);
         $Qtotals->execute();
         while ($Qtotals->next()) {
             $email_order .= strip_tags($Qtotals->value('title') . ' ' . $Qtotals->value('text')) . "\n";
         }
         unset($Qtotals);
         if (lc_empty($Qorder->value('delivery_name')) === false && lc_empty($Qorder->value('delivery_street_address')) === false) {
             $address = array('name' => $Qorder->value('delivery_name'), 'company' => $Qorder->value('delivery_company'), 'street_address' => $Qorder->value('delivery_street_address'), 'suburb' => $Qorder->value('delivery_suburb'), 'city' => $Qorder->value('delivery_city'), 'state' => $Qorder->value('delivery_state'), 'zone_code' => $Qorder->value('delivery_state_code'), 'country_title' => $Qorder->value('delivery_country'), 'country_iso2' => $Qorder->value('delivery_country_iso2'), 'country_iso3' => $Qorder->value('delivery_country_iso3'), 'postcode' => $Qorder->value('delivery_postcode'), 'format' => $Qorder->value('delivery_address_format'));
             $email_order .= "\n" . $lC_Language->get('email_order_delivery_address') . "\n" . $lC_Language->get('email_order_separator') . "\n" . lC_Address::format($address) . "\n";
             unset($address);
         }
         $address = array('name' => $Qorder->value('billing_name'), 'company' => $Qorder->value('billing_company'), 'street_address' => $Qorder->value('billing_street_address'), 'suburb' => $Qorder->value('billing_suburb'), 'city' => $Qorder->value('billing_city'), 'state' => $Qorder->value('billing_state'), 'zone_code' => $Qorder->value('billing_state_code'), 'country_title' => $Qorder->value('billing_country'), 'country_iso2' => $Qorder->value('billing_country_iso2'), 'country_iso3' => $Qorder->value('billing_country_iso3'), 'postcode' => $Qorder->value('billing_postcode'), 'format' => $Qorder->value('billing_address_format'));
         $email_order .= "\n" . $lC_Language->get('email_order_billing_address') . "\n" . $lC_Language->get('email_order_separator') . "\n" . lC_Address::format($address) . "\n\n";
         unset($address);
         $Qstatus = $lC_Database->query('select orders_status_name from :table_orders_status where orders_status_id = :orders_status_id and language_id = :language_id');
         $Qstatus->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
         $Qstatus->bindInt(':orders_status_id', $Qorder->valueInt('orders_status'));
         $Qstatus->bindInt(':language_id', $lC_Language->getID());
         $Qstatus->execute();
         $email_order .= sprintf($lC_Language->get('email_order_status'), $Qstatus->value('orders_status_name')) . "\n" . $lC_Language->get('email_order_separator') . "\n";
         unset($Qstatus);
         $Qstatuses = $lC_Database->query('select date_added, comments from :table_orders_status_history where orders_id = :orders_id and comments != "" order by orders_status_history_id');
         $Qstatuses->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
         $Qstatuses->bindInt(':orders_id', $id);
         $Qstatuses->execute();
         while ($Qstatuses->next()) {
             $email_order .= lC_DateTime::getLong($Qstatuses->value('date_added')) . "\n\t" . wordwrap(str_replace("\n", "\n\t", $Qstatuses->value('comments')), 60, "\n\t", 1) . "\n\n";
         }
         unset($Qstatuses);
         if (is_object($lC_ShoppingCart)) {
             $email_order .= $lC_Language->get('email_order_payment_method') . "\n" . $lC_Language->get('email_order_separator') . "\n";
             $email_order .= $Qorder->value('payment_method') . "\n\n";
             /*if (isset($this->email_footer)) {
                 $email_order .= $this->email_footer . "\n\n";
               }*/
         }
         lc_email($Qorder->value('customers_name'), $Qorder->value('customers_email_address'), $lC_Language->get('email_order_subject'), $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
         // send emails to other people
         if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
             lc_email('', SEND_EXTRA_ORDER_EMAILS_TO, $lC_Language->get('email_order_subject'), $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
         }
     }
     unset($Qorder);
 }