public function callback()
 {
     $this->load->library('encryption');
     $encryption = new AEncryption($this->config->get('encryption_key'));
     if (isset($this->request->post['order_id'])) {
         $order_id = $encryption->decrypt($this->request->post['order_id']);
     } else {
         $order_id = 0;
     }
     $this->load->model('checkout/order');
     $order_info = $this->model_checkout_order->getOrder($order_id);
     if ($order_info) {
         $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
         switch ($this->request->post['status']) {
             case '2':
                 $this->model_checkout_order->update($order_id, $this->config->get('default_moneybookers_order_status_id'), '', TRUE);
                 break;
             case '0':
                 $this->model_checkout_order->update($order_id, $this->config->get('default_moneybookers_order_status_pending_id'), '', TRUE);
                 break;
             case '-1':
                 $this->model_checkout_order->update($order_id, $this->config->get('default_moneybookers_order_status_canceled_id'), '', TRUE);
                 break;
             case '-2':
                 $this->model_checkout_order->update($order_id, $this->config->get('default_moneybookers_order_status_failed_id'), '', TRUE);
                 break;
             case '-3':
                 $this->model_checkout_order->update($order_id, $this->config->get('default_moneybookers_order_status_chargeback_id'), '', TRUE);
                 break;
         }
     }
 }
 public function callback()
 {
     $this->load->library('encryption');
     $encryption = new AEncryption($this->config->get('encryption_key'));
     if (isset($this->request->post['order_id'])) {
         $order_id = $encryption->decrypt($this->request->post['order_id']);
     } else {
         return null;
     }
     $this->load->model('checkout/order');
     $order_info = $this->model_checkout_order->getOrder($order_id);
     if (!$order_info) {
         return null;
     }
     $md5_ok = false;
     if ($this->config->get('default_skrill_email')) {
         $ourhash = $this->request->post['merchant_id'];
         $ourhash .= $this->request->post['transaction_id'] . '_' . UNIQUE_ID;
         $ourhash .= strtoupper(md5($this->config->get('default_skrill_secret')));
         $ourhash .= $this->request->post['mb_amount'];
         $ourhash .= $this->request->post['mb_currency'];
         $ourhash .= $this->request->post['status'];
         $ourmd5hash = strtoupper(md5($ourhash));
         $thiermd5sig = $this->request->post['md5sig'];
         if ($ourmd5hash == $thiermd5sig) {
             $md5_ok = true;
         }
     }
     $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
     if ($md5_ok) {
         switch ($this->request->post['status']) {
             case '2':
                 $this->model_checkout_order->update($order_id, $this->config->get('default_skrill_order_status_id'), '', TRUE);
                 break;
             case '0':
                 $this->model_checkout_order->update($order_id, $this->config->get('default_skrill_order_status_pending_id'), '', TRUE);
                 break;
             case '-1':
                 $this->model_checkout_order->update($order_id, $this->config->get('default_skrill_order_status_canceled_id'), '', TRUE);
                 break;
             case '-2':
                 $this->model_checkout_order->update($order_id, $this->config->get('default_skrill_order_status_failed_id'), 'Reason code: ' . $this->request->post['failed_reason_code'], TRUE);
                 break;
             case '-3':
                 $this->model_checkout_order->update($order_id, $this->config->get('default_skrill_order_status_chargeback_id'), '', TRUE);
                 break;
         }
     } else {
         //Security HASH verification failed
         $this->model_checkout_order->addHistory($order_id, $this->config->get('default_skrill_order_status_pending_id'), 'Manual order verification is required! MD5 hash returned (' + $thiermd5sig + ') does not match generated (' + $ourmd5hash + ').');
     }
     return null;
 }
 public function main()
 {
     //Load input arguments for gid settings
     $this->data = func_get_arg(0);
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('extension/extensions');
     $extension = $this->request->get['extension'];
     if ($extension && !$this->data['extension_info']) {
         $this->data['extension_info'] = $this->extensions->getExtensionInfo($extension);
     }
     $icon_ext_img_url = HTTP_CATALOG . 'extensions/' . $extension . '/image/icon.png';
     $icon_ext_dir = DIR_EXT . $extension . '/image/icon.png';
     $icon = is_file($icon_ext_dir) ? $icon_ext_img_url : RDIR_TEMPLATE . 'image/default_extension.png';
     $this->data['extension_info']['icon'] = $icon;
     $this->data['extension_info']['name'] = $this->language->get($extension . '_name');
     $datetime_format = $this->language->get('date_format_short') . ' ' . $this->language->get('time_format');
     if ($this->data['extension_info']['date_installed']) {
         $this->data['extension_info']['installed'] = dateISO2Display($this->data['extension_info']['date_installed'], $datetime_format);
     }
     if ($this->data['extension_info']['date_added']) {
         $this->data['extension_info']['date_added'] = dateISO2Display($this->data['extension_info']['date_added'], $datetime_format);
     }
     if (isset($this->session->data['extension_updates'][$extension])) {
         $this->data['upgrade_button'] = $this->html->buildElement(array('type' => 'button', 'name' => 'btn_upgrade', 'id' => 'upgradenow', 'href' => AEncryption::addEncoded_stid($this->session->data['extension_updates'][$extension]['url']), 'text' => $this->language->get('button_upgrade')));
     }
     $this->data['extension_info']['license'] = $this->data['extension_info']['license_key'];
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/extension/extension_summary.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('common/forgot_password');
     $this->document->setTitle($this->language->get('heading_title'));
     if ($this->request->is_POST() && $this->_validate()) {
         //generate hash
         $hash = AEncryption::getHash(time());
         $link = $this->html->getSecureURL('index/forgot_password/validate', '&hash=' . $hash);
         //create a scratch data for future use
         $passreset = new ADataset();
         $passreset->createDataset('admin_pass_reset', $this->request->post['username']);
         $passreset->setDatasetProperties(array('hash' => $hash, 'email' => $this->request->post['email']));
         $mail = new AMail($this->config);
         $mail->setTo($this->request->post['email']);
         $mail->setFrom($this->config->get('store_main_email'));
         $mail->setSender($this->config->get('config_owner'));
         $mail->setSubject(sprintf($this->language->get('reset_email_subject'), $this->config->get('store_name')));
         $mail->setHtml(sprintf($this->language->get('reset_email_body_html'), $link, $link));
         $mail->setText(sprintf($this->language->get('reset_email_body_text'), $link, $link));
         $mail->send();
         $this->redirect($this->html->getSecureURL('index/forgot_password', '&mail=sent'));
     }
     $this->data['login'] = $this->html->getSecureURL('index/login');
     if (isset($this->request->get['mail']) && $this->request->get['mail'] == 'sent') {
         $this->data['show_instructions'] = true;
     } else {
         $this->data['error'] = $this->error;
         $fields = array('username', 'email', 'captcha');
         foreach ($fields as $f) {
             if (isset($this->request->post[$f])) {
                 $this->data[$f] = $this->request->post[$f];
             } else {
                 $this->data[$f] = '';
             }
         }
         $this->data['action'] = $this->html->getSecureURL('index/forgot_password');
         $this->data['update'] = '';
         $form = new AForm('ST');
         $form->setForm(array('form_name' => 'forgotFrm', 'update' => $this->data['update']));
         $this->data['form']['id'] = 'forgotFrm';
         $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'forgotFrm', 'action' => $this->data['action']));
         $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_reset_password'), 'style' => 'button3'));
         $this->data['form']['fields']['username'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'username', 'value' => $this->data['username'], 'required' => true, 'placeholder' => $this->language->get('entry_username')));
         $this->data['form']['fields']['email'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'email', 'value' => $this->data['email'], 'required' => true, 'placeholder' => $this->language->get('entry_email')));
         if ($this->config->get('config_recaptcha_site_key')) {
             $this->data['form']['fields']['captcha'] = $form->getFieldHtml(array('type' => 'recaptcha', 'name' => 'captcha', 'recaptcha_site_key' => $this->config->get('config_recaptcha_site_key'), 'language_code' => $this->language->getLanguageCode()));
         } else {
             $this->data['form']['fields']['captcha'] = $form->getFieldHtml(array('type' => 'captcha', 'name' => 'captcha', 'value' => $this->data['captcha'], 'required' => true, 'placeholder' => $this->language->get('entry_captcha')));
         }
     }
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/index/forgot_password.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 private function _validate($loginname, $password)
 {
     if (!$this->customer->login($loginname, $password)) {
         return FALSE;
     } else {
         unset($this->session->data['guest']);
         $this->loadModel('account/address');
         $address = $this->model_account_address->getAddress($this->customer->getAddressId());
         $this->session->data['country_id'] = $address['country_id'];
         $this->session->data['zone_id'] = $address['zone_id'];
         $this->session->data['token'] = AEncryption::getHash(mt_rand());
         return TRUE;
     }
 }
Esempio n. 6
0
 public function callback()
 {
     $this->loadLanguage('default_paymate/default_paymate');
     $error = '';
     if (isset($this->request->post['responseCode'])) {
         if ($this->request->post['responseCode'] == 'PA' || $this->request->post['responseCode'] == 'PP') {
             if (isset($this->request->get['oid']) && isset($this->request->get['conf'])) {
                 $this->load->library('encryption');
                 $encryption = new AEncryption($this->config->get('encryption_key'));
                 $order_id = $encryption->decrypt(base64_decode($this->request->get['oid']));
                 $this->load->model('checkout/order');
                 $order_info = $this->model_checkout_order->getOrder($order_id);
                 if (isset($order_info['payment_firstname']) && isset($order_info['payment_lastname']) && strcmp($encryption->decrypt(base64_decode($this->request->get['conf'])), $order_info['payment_firstname'] . $order_info['payment_lastname']) == 0) {
                     $this->model_checkout_order->confirm($order_id, $this->config->get('default_paymate_order_status_id'));
                 } else {
                     $error = $this->language->get('text_unable');
                 }
             } else {
                 $error = $this->language->get('text_unable');
             }
         } else {
             $error = $this->language->get('text_declined');
         }
     } else {
         $error = $this->language->get('text_unable');
     }
     if ($error != '') {
         $template_data['heading_title'] = $this->language->get('text_failed');
         $template_data['text_message'] = sprintf($this->language->get('text_failed_message'), $error, $this->html->getURL('content/contact'));
         $template_data['button_continue'] = $this->language->get('button_continue');
         $template_data['continue'] = $this->html->getURL('index/home');
         $this->view->batchAssign($template_data);
         $this->processTemplate($this->config->get('config_storefront_template') . 'common/success.tpl');
     } else {
         $this->redirect($this->html->getSecureURL('checkout/success'));
     }
 }
Esempio n. 7
0
 public function editUser($user_id, $data)
 {
     $fields = array('username', 'firstname', 'lastname', 'email', 'user_group_id', 'status');
     $update = array();
     foreach ($fields as $f) {
         if (isset($data[$f])) {
             $update[] = $f . " = '" . $this->db->escape($data[$f]) . "'";
         }
     }
     if (!empty($data['password'])) {
         $update[] = "password = '******'password'])) . "'";
     }
     if (!empty($update)) {
         $sql = "UPDATE " . $this->db->table("users") . " SET " . implode(',', $update) . " WHERE user_id = '" . (int) $user_id . "'";
         $this->db->query($sql);
     }
 }
Esempio n. 8
0
 public function post()
 {
     //This is login attempt
     $request = $this->rest->getRequestParams();
     if (isset($request['token'])) {
         //this is the request to authorized
         $this->_validate_token($request['token']);
     } else {
         if (isset($request['username']) && isset($request['password']) && $this->_validate($request['username'], $request['password'])) {
             $this->session->data['token'] = AEncryption::getHash(mt_rand());
             $this->rest->setResponseData(array('status' => 1, 'success' => 'Logged in', 'token' => $this->session->data['token']));
             $this->rest->sendResponse(200);
         } else {
             $this->rest->setResponseData(array('status' => 0, 'error' => 'Login attempt failed!'));
             $this->rest->sendResponse(401);
         }
     }
 }
Esempio n. 9
0
 public function RunSQL($data)
 {
     $db = new ADB($data['db_driver'], $data['db_host'], $data['db_user'], $data['db_password'], $data['db_name']);
     $file = DIR_APP_SECTION . 'abantecart_database.sql';
     if ($sql = file($file)) {
         $query = '';
         foreach ($sql as $line) {
             $tsl = trim($line);
             if ($sql != '' && substr($tsl, 0, 2) != "--" && substr($tsl, 0, 1) != '#') {
                 $query .= $line;
                 if (preg_match('/;\\s*$/', $line)) {
                     $query = str_replace("DROP TABLE IF EXISTS `ac_", "DROP TABLE IF EXISTS `" . $data['db_prefix'], $query);
                     $query = str_replace("CREATE TABLE `ac_", "CREATE TABLE `" . $data['db_prefix'], $query);
                     $query = str_replace("INSERT INTO `ac_", "INSERT INTO `" . $data['db_prefix'], $query);
                     $query = str_replace("ON `ac_", "ON `" . $data['db_prefix'], $query);
                     $db->query($query);
                     //no silence mode! if error - will throw to exception
                     $query = '';
                 }
             }
         }
         $db->query("SET CHARACTER SET utf8;");
         $db->query("SET @@session.sql_mode = 'MYSQL40';");
         $db->query("INSERT INTO `" . $data['db_prefix'] . "users`\n\t\t\t\tSET user_id = '1',\n\t\t\t\t\tuser_group_id = '1',\n\t\t\t\t\temail = '" . $db->escape($data['email']) . "',\n\t\t\t\t    username = '******'username']) . "',\n\t\t\t\t    password = '******'password'])) . "',\n\t\t\t\t    status = '1',\n\t\t\t\t    date_added = NOW();");
         $db->query("UPDATE `" . $data['db_prefix'] . "settings` SET value = '" . $db->escape($data['email']) . "' WHERE `key` = 'store_main_email'; ");
         $db->query("UPDATE `" . $data['db_prefix'] . "settings` SET value = '" . $db->escape(HTTP_ABANTECART) . "' WHERE `key` = 'config_url'; ");
         $db->query("INSERT INTO `" . $data['db_prefix'] . "settings` SET `group` = 'config', `key` = 'install_date', value = NOW(); ");
         $db->query("UPDATE `" . $data['db_prefix'] . "products` SET `viewed` = '0';");
         //process triggers
         //$this->create_triggers($db, $data['db_name']);
         //run descructor and close db-connection
         unset($db);
     }
     //clear cache dir in case of reinstall
     $cache = new ACache();
     $cache->remove('*');
 }
Esempio n. 10
0
 /**
  * @param $username string
  * @param $password string
  * @return bool
  */
 public function login($username, $password)
 {
     $user_query = $this->db->query("SELECT *\n    \t                                FROM " . $this->db->table("users") . " \n    \t                                WHERE username = '******'\n    \t                                AND password = '******'");
     if ($user_query->num_rows) {
         $this->session->data['user_id'] = $user_query->row['user_id'];
         $this->session->data['user_last_login'] = $user_query->row['last_login'];
         $this->user_id = $user_query->row['user_id'];
         $this->username = $user_query->row['username'];
         $this->last_login = $user_query->row['last_login'];
         if (!$this->last_login || $this->last_login == 'null' || $this->last_login == '0000-00-00 00:00:00') {
             $this->session->data['user_last_login'] = $this->last_login = '';
         }
         $this->db->query("UPDATE " . $this->db->table("users") . " \n\t\t\t\t\t\t\t  SET last_login = NOW()\n\t\t\t\t\t\t\t  WHERE user_id = '" . (int) $this->session->data['user_id'] . "'");
         $user_group_query = $this->db->query("SELECT permission\n      \t\t                                      FROM " . $this->db->table("user_groups") . " \n      \t\t                                      WHERE user_group_id = '" . (int) $user_query->row['user_group_id'] . "'");
         if ($user_group_query->row['permission']) {
             foreach (unserialize($user_group_query->row['permission']) as $key => $value) {
                 $this->permission[$key] = $value;
             }
         }
         return TRUE;
     } else {
         return FALSE;
     }
 }
Esempio n. 11
0
 public function editUser($user_id, $data)
 {
     $fields = array('username', 'firstname', 'lastname', 'email', 'user_group_id', 'status');
     $update = array();
     foreach ($fields as $f) {
         if (isset($data[$f])) {
             $update[] = $f . " = '" . $this->db->escape($data[$f]) . "'";
         }
     }
     if ($data['password'] || $data['email'] || $data['username']) {
         //notify admin user of important infoamtion change
         $language = new ALanguage($this->registry, '', 1);
         $language->load('common/im');
         $message_arr = array(1 => array('message' => $language->get('im_account_update_text_to_admin')));
         $this->im->sendToUser($user_id, 'account_update', $message_arr);
     }
     if (!empty($data['password'])) {
         $update[] = "password = '******'password'])) . "'";
     }
     if (!empty($update)) {
         $sql = "UPDATE " . $this->db->table("users") . " SET " . implode(',', $update) . " WHERE user_id = '" . (int) $user_id . "'";
         $this->db->query($sql);
     }
 }
Esempio n. 12
0
 private function _get_products_data($order_info)
 {
     $this->load->library('encryption');
     $encryption = new AEncryption($this->config->get('encryption_key'));
     $this->data['products'] = array();
     $this->data['items_total'] = 0.0;
     $products = $this->cart->getProducts();
     foreach ($products as $product) {
         $option_data = array();
         foreach ($product['option'] as $option) {
             if ($option['type'] != 'file') {
                 $value = $option['value'];
             } else {
                 $filename = $encryption->decrypt($option['value']);
                 $value = mb_substr($filename, 0, mb_strrpos($filename, '.'));
             }
             $option_data[] = array('name' => $option['name'], 'value' => mb_strlen($value) > 20 ? mb_substr($value, 0, 20) . '..' : $value);
         }
         $price = $this->currency->format($product['price'], $order_info['currency'], $order_info['value'], FALSE);
         $this->data['products'][] = array('name' => $product['name'], 'model' => $product['model'], 'price' => $price, 'quantity' => $product['quantity'], 'option' => $option_data, 'weight' => $product['weight'], 'weight_type' => $product['weight_type']);
         $this->data['items_total'] += $price * $product['quantity'];
     }
     //check for virtual product such as gift certificate
     $virtual_products = $this->cart->getVirtualProducts();
     if ($virtual_products) {
         foreach ($virtual_products as $k => $virtual) {
             $this->data['products'][] = array('name' => $virtual['name'] ? $virtual['name'] : 'Virtual Product', 'model' => '', 'price' => $this->currency->format($virtual['amount'], $order_info['currency'], $order_info['value'], false), 'quantity' => $virtual['quantity'] ? $virtual['quantity'] : 1, 'option' => array(), 'weight' => 0);
             $this->data['items_total'] += ($virtual['quantity'] ? $virtual['quantity'] : 1) * $this->currency->format($virtual['amount'], $order_info['currency'], $order_info['value'], false);
         }
     }
     $this->data['discount_amount_cart'] = 0;
     $totals = $this->cart->buildTotalDisplay();
     foreach ($totals['total_data'] as $total) {
         if (in_array($total['id'], array('subtotal', 'total'))) {
             continue;
         }
         if (in_array($total['id'], array('promotion', 'coupon'))) {
             $total['value'] = $total['value'] < 0 ? $total['value'] * -1 : $total['value'];
             $this->data['discount_amount_cart'] += $total['value'];
         } else {
             $price = $this->currency->format($total['value'], $order_info['currency'], $order_info['value'], FALSE);
             if (in_array($total['id'], array('tax'))) {
                 $this->data['tax_total'] += $price;
             } elseif (in_array($total['id'], array('shipping'))) {
                 $this->data['shipping_total'] += $price;
             } elseif (in_array($total['id'], array('handling'))) {
                 $this->data['handling_total'] += $price;
             } else {
                 $this->data['items_total'] += $price;
             }
             $this->data['products'][$total['id']] = array('name' => $total['title'], 'model' => '', 'price' => $price, 'quantity' => 1, 'option' => array(), 'weight' => 0);
         }
     }
     $calc_total = $this->data['items_total'] + $this->data['shipping_total'] + $this->data['tax_total'] + $this->data['handling_total'];
     if ($calc_total - $order_info['order_total'] !== 0.0) {
         foreach ($totals['total_data'] as $total) {
             if (in_array($total['id'], array('subtotal', 'total', 'promotion', 'coupon'))) {
                 continue;
             }
             $price = $this->currency->format($total['value'], $order_info['currency'], $order_info['value'], FALSE);
             $this->data['products'][$total['id']] = array('name' => $total['title'], 'model' => '', 'price' => $price, 'quantity' => 1, 'option' => array(), 'weight' => 0);
         }
     }
     if ($this->data['discount_amount_cart'] > 0) {
         $price = -1 * $this->currency->format($this->data['discount_amount_cart'], $order_info['currency'], $order_info['value'], FALSE);
         $this->data['products'][] = array('name' => $this->language->get('text_discount'), 'model' => '', 'price' => $price, 'quantity' => 1, 'option' => array(), 'weight' => 0);
         $this->data['items_total'] += $price;
     }
     return $this->data['products'];
 }
 public function callback()
 {
     $this->load->library('encryption');
     $encryption = new AEncryption($this->config->get('encryption_key'));
     if (isset($this->request->post['custom'])) {
         $order_id = $encryption->decrypt($this->request->post['custom']);
     } else {
         $order_id = 0;
     }
     $this->load->model('checkout/order');
     $order_info = $this->model_checkout_order->getOrder($order_id);
     $suspect = false;
     $message = '';
     if ($order_info) {
         // check seller email and save message if not equal
         if ($this->request->post['receiver_email'] != $this->config->get('default_pp_standart_email')) {
             $this->load->language('default_pp_standart/default_pp_standart');
             $message .= $this->language->get('text_suspect');
             $params = array('payment_status', 'pending_reason', 'address_zip', 'address_country_code', 'address_name', 'address_country', 'address_city', 'quantity', 'payer_email', 'first_name', 'last_name', 'payment_gross', 'shipping', 'ipn_track_id', 'receiver_email');
             foreach ($params as $p) {
                 if (isset($this->request->post[$p])) {
                     $message .= $p . ": " . $this->request->post[$p] . "<br>\n";
                 }
             }
             $msg = new AMessage();
             $msg->saveNotice(sprintf($this->language->get('text_suspect_subj'), $order_id), $message);
             $suspect = true;
         }
         $request = 'cmd=_notify-validate';
         foreach ($this->request->post as $key => $value) {
             $request .= '&' . $key . '=' . urlencode(stripslashes(html_entity_decode($value, ENT_QUOTES, 'UTF-8')));
         }
         if (extension_loaded('curl')) {
             if (!$this->config->get('default_pp_standart_test')) {
                 $ch = curl_init('https://www.paypal.com/cgi-bin/webscr');
             } else {
                 $ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
             }
             curl_setopt($ch, CURLOPT_POST, true);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($ch, CURLOPT_HEADER, false);
             curl_setopt($ch, CURLOPT_TIMEOUT, 30);
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
             $response = curl_exec($ch);
             if ($suspect === true) {
                 // set pending status for all suspected orders
                 $this->model_checkout_order->confirm($order_id, 1, $message);
             } elseif (strcmp($response, 'VERIFIED') == 0 || $this->request->post['payment_status'] == 'Completed') {
                 $this->model_checkout_order->confirm($order_id, $this->config->get('default_pp_standart_order_status_id'));
             } else {
                 $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
             }
             curl_close($ch);
         } else {
             $header = 'POST /cgi-bin/webscr HTTP/1.0' . "\r\n";
             $header .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n";
             $header .= 'Content-Length: ' . mb_strlen($request) . "\r\n";
             $header .= 'Connection: close' . "\r\n\r\n";
             if (!$this->config->get('default_pp_standart_test')) {
                 $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
             } else {
                 $fp = fsockopen('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
             }
             if ($fp) {
                 fputs($fp, $header . $request);
                 while (!feof($fp)) {
                     $response = fgets($fp, 1024);
                     if (strcmp($response, 'VERIFIED') == 0 || $this->request->post['payment_status'] == 'Completed') {
                         $this->model_checkout_order->confirm($order_id, $this->config->get('default_pp_standart_order_status_id'));
                     } else {
                         $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
                     }
                 }
                 fclose($fp);
             }
         }
         $this->model_checkout_order->updatePaymentMethodData($this->session->data['order_id'], $response);
     }
 }
 /**
  * @param AForm $form
  * @param $data
  * @return array
  */
 private function _build_system($form, $data)
 {
     $ret_data = array();
     if ($data['storefront_template_debug']) {
         $this->session->data['tmpl_debug'] = AEncryption::getHash(mt_rand());
         $ret_data['storefront_debug_url'] = $this->html->getCatalogURL('index/home', '&tmpl_debug=' . $this->session->data['tmpl_debug']);
         $ret_data['admin_debug_url'] = $this->html->getSecureURL('index/home', '&tmpl_debug=' . $this->session->data['tmpl_debug']);
     } else {
         unset($this->session->data['tmpl_debug']);
         $ret_data['storefront_debug_url'] = '';
         $ret_data['admin_debug_url'] = '';
     }
     $ignore = array('common/login', 'common/logout', 'error/not_found', 'error/permission');
     $ret_data['tokens'] = array();
     $files_pages = glob(DIR_APP_SECTION . 'controller/pages/*/*.php');
     $files_response = glob(DIR_APP_SECTION . 'controller/responses/*/*.php');
     $files = array_merge($files_pages, $files_response);
     foreach ($files as $file) {
         $tmp_data = explode('/', dirname($file));
         $token = end($tmp_data) . '/' . basename($file, '.php');
         if (!in_array($token, $ignore)) {
             $ret_data['tokens'][$token] = $token;
         }
     }
     $ret_data['form'] = array('fields' => $this->conf_mngr->getFormFields('system', $form, $data));
     return $ret_data;
 }
Esempio n. 15
0
 /**
  * @param int $customer_id
  * @param string $field
  * @param mixed $value
  */
 public function editCustomerField($customer_id, $field, $value)
 {
     $data = array('loginname', 'firstname', 'lastname', 'email', 'telephone', 'fax', 'newsletter', 'customer_group_id', 'status', 'approved');
     if (in_array($field, $data)) {
         if ($this->dcrypt->active && in_array($field, $this->dcrypt->getEcryptedFields("customers"))) {
             //check key_id to use
             $query_key = $this->db->query("select key_id from " . $this->db->table("customers") . "\n\t\t\t\t\t\t\t  WHERE customer_id = '" . (int) $customer_id . "'");
             $key_id = $query_key->rows[0]['key_id'];
             $value = $this->dcrypt->encrypt_field($value, $key_id);
         }
     }
     $this->db->query("UPDATE " . $this->db->table("customers") . "\n\t\t\t\t\t\t\t  SET {$field} = '" . $this->db->escape($value) . "'\n\t\t\t\t\t\t\t  WHERE customer_id = '" . (int) $customer_id . "'");
     if ($field == 'password') {
         $this->db->query("UPDATE " . $this->db->table("customers") . "\n        \t                  SET password = '******'\n        \t                  WHERE customer_id = '" . (int) $customer_id . "'");
     }
 }
Esempio n. 16
0
 public function callback()
 {
     $this->loadLanguage('default_paypoint/default_paypoint');
     $template_data['title'] = sprintf($this->language->get('heading_title'), $this->config->get('store_name'));
     if (!isset($this->request->server['HTTPS']) || $this->request->server['HTTPS'] != 'on') {
         $template_data['base'] = HTTP_SERVER;
     } else {
         $template_data['base'] = HTTPS_SERVER;
     }
     $template_data['charset'] = 'utf-8';
     $template_data['language'] = $this->language->get('code');
     $template_data['direction'] = $this->language->get('direction');
     $template_data['heading_title'] = sprintf($this->language->get('heading_title'), $this->config->get('store_name'));
     $template_data['text_response'] = $this->language->get('text_response');
     $template_data['text_success'] = $this->language->get('text_success');
     $template_data['text_success_wait'] = sprintf($this->language->get('text_success_wait'), $this->html->getSecureURL('checkout/success'));
     $template_data['text_failure'] = $this->language->get('text_failure');
     $template_data['text_failure_wait'] = sprintf($this->language->get('text_failure_wait'), $this->html->getSecureURL('checkout/cart'));
     if (isset($this->request->get['valid']) && $this->request->get['valid'] == 'true') {
         $this->load->library('encryption');
         $encryption = new AEncryption($this->config->get('encryption_key'));
         $order_id = $encryption->decrypt($this->request->get['order_id']);
         $this->load->model('checkout/order');
         $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
         $message = '';
         if (isset($this->request->get['code'])) {
             $message .= 'code: ' . $this->request->get['code'] . "\n";
         }
         if (isset($this->request->get['auth_code'])) {
             $message .= 'auth_code: ' . $this->request->get['auth_code'] . "\n";
         }
         if (isset($this->request->get['ip'])) {
             $message .= 'ip: ' . $this->request->get['ip'] . "\n";
         }
         if (isset($this->request->get['cv2avs'])) {
             $message .= 'cv2avs: ' . $this->request->get['cv2avs'] . "\n";
         }
         if (isset($this->request->get['trans_id'])) {
             $message .= 'trans_id: ' . $this->request->get['trans_id'] . "\n";
         }
         if (isset($this->request->get['valid'])) {
             $message .= 'valid: ' . $this->request->get['valid'] . "\n";
         }
         $this->model_checkout_order->update($order_id, $this->config->get('default_paypoint_order_status_id'), $message, FALSE);
         $template_data['continue'] = $this->html->getSecureURL('checkout/success');
         $this->view->batchAssign($template_data);
         $this->view->setTemplate('responses/extension/paypoint_success.tpl');
     } else {
         $template_data['continue'] = $this->html->getSecureURL('checkout/cart');
         $this->view->batchAssign($template_data);
         $this->view->setTemplate('responses/extension/paypoint_failure.tpl');
     }
     $this->processTemplate();
 }
Esempio n. 17
0
 /**
  * @param string $loginname
  * @param string $password
  */
 public function editPassword($loginname, $password)
 {
     $password = AEncryption::getHash($password);
     $this->db->query("UPDATE " . $this->db->table("customers") . "\n      \t                SET password = '******'\n      \t                WHERE loginname = '" . $this->db->escape($loginname) . "'");
     //send IM
     $sql = "SELECT customer_id\n \t\t\t\tFROM " . $this->db->table("customers") . "\n\t\t      \tWHERE loginname = '" . $this->db->escape($loginname) . "'";
     $result = $this->db->query($sql);
     $customer_id = $result->row['customer_id'];
     if ($customer_id) {
         $language = new ALanguage($this->registry);
         $language->load('common/im');
         $message_arr = array(0 => array('message' => $language->get('im_customer_account_update_password_to_customer')));
         $this->im->send('customer_account_update', $message_arr);
     }
 }
 public function send()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     //validate input
     $post = $this->request->post;
     if (empty($post['cc_number'])) {
         $json['error'] = $this->language->get('error_incorrect_number');
     }
     if (empty($post['cc_owner'])) {
         $json['error'] = $this->language->get('error_incorrect_name');
     }
     if (empty($post['cc_expire_date_month']) || empty($post['cc_expire_date_year'])) {
         $json['error'] = $this->language->get('error_incorrect_expiration');
     }
     if (strlen($post['cc_cvv2']) != 3 && strlen($post['cc_cvv2']) != 4) {
         $json['error'] = $this->language->get('error_incorrect_cvv');
     }
     if (isset($json['error'])) {
         $this->load->library('json');
         $this->response->setOutput(AJson::encode($json));
         return null;
     }
     $this->loadModel('checkout/order');
     $this->loadModel('extension/default_realex');
     $this->loadLanguage('default_realex/default_realex');
     $order_id = $this->session->data['order_id'];
     $order_info = $this->model_checkout_order->getOrder($order_id);
     // currency code
     $currency = $this->currency->getCode();
     // order amount without decimal delimiter
     $amount = round($this->currency->convert($this->cart->getFinalTotal(), $this->config->get('config_currency'), $currency), 2) * 100;
     $cardnumber = preg_replace('/[^0-9]/', '', $post['cc_number']);
     $cvv2 = preg_replace('/[^0-9]/', '', $post['cc_cvv2']);
     // Card owner name
     $cardname = html_entity_decode($post['cc_owner'], ENT_QUOTES, 'UTF-8');
     $cardtype = $post['cc_type'];
     // card expire date mmyy
     $expdate = $post['cc_expire_date_month'] . substr($post['cc_expire_date_year'], 2, 2);
     $cardissue = $post['cc_issue'];
     $order_ref = $order_id . 'AB' . strftime("%Y%m%d%H%M%S") . mt_rand(1, 999);
     // Mechant id values are provided by Realex Payments, if you have not already received them please contact releax
     $conf_cc_list = unserialize($this->config->get('default_realex_creditcard_selection'));
     $account = $conf_cc_list[$cardtype]['subaccount'];
     if (empty($account) || $accounts[$cardtype]['default']) {
         //use default account by setting it to empty
         $account = '';
     }
     ADebug::checkpoint('Realex Payment: Order ID ' . $order_id);
     //do we have 3d on?
     $v3d = array();
     $pd = array('account' => $account, 'amount' => $amount, 'currency' => $currency, 'order_id' => $order_id, 'order_ref' => $order_ref, 'cc_number' => $cardnumber, 'cc_expire' => $expdate, 'cc_owner' => $cardname, 'cc_type' => $cardtype, 'cc_cvv2' => $cvv2, 'cc_issue' => $cardissue);
     if ($this->config->get('default_realex_3d')) {
         if ($cc_type == 'visa' || $cc_type == 'mc' || $cc_type == 'amex') {
             $verify_3ds = $this->model_extension_default_realex->check3DEnrollment($account, $amount, $currency, $order_ref, $post);
             ADebug::variable('Verify 3DS result: ', $verify_3ds);
             if (isset($verify_3ds->result) && $verify_3ds->result == '00') {
                 $encryption = new AEncryption($this->config->get('encryption_key'));
                 $enc_data = $encryption->encrypt(serialize($pd));
                 $json = array();
                 $json['ACSURL'] = (string) $verify_3ds->url;
                 $json['MD'] = $enc_data;
                 $json['PaReq'] = (string) $verify_3ds->pareq;
                 $json['TermUrl'] = $this->html->getSecureURL('extension/default_realex/callback');
                 $this->load->library('json');
                 $this->response->setOutput(AJson::encode($json));
                 return null;
             }
             //Cardholder Not Enrolled. Shift in liability. ECI = 6
             if (isset($verify_3ds->result) && $verify_3ds->result == '110' && isset($verify_3ds->enrolled) && $verify_3ds->enrolled == 'N') {
                 $v3d['eci_ref'] = 1;
                 if ($cardtype == 'mc') {
                     $v3d['eci'] = 1;
                 } else {
                     $v3d['eci'] = 6;
                 }
             }
             // Cannot Verify Enrollment. No shift in liability. ECI = 7
             if (isset($verify_3ds->result) && $verify_3ds->result == '110' && isset($verify_3ds->enrolled) && $verify_3ds->enrolled == 'U') {
                 if ($this->config->get('default_realex_liability_shift') != 1) {
                     $json['error'] = $this->language->get('error_3d_enroll');
                     $this->load->library('json');
                     $this->response->setOutput(AJson::encode($json));
                     return null;
                 } else {
                     $v3d['eci_ref'] = 2;
                     if ($cardtype == 'mc') {
                         $v3d['eci'] = 0;
                     } else {
                         $v3d['eci'] = 7;
                     }
                 }
             }
             // Invalid response from Enrollment Server. No shift in liability. ECI = 7
             if (isset($verify_3ds->result) && $verify_3ds->result >= 500 && $verify_3ds->result < 600) {
                 if ($this->config->get('realex_remote_liability') != 1) {
                     $json['error'] = (string) $verify_3ds->message;
                     $this->load->library('json');
                     $this->response->setOutput(AJson::encode($json));
                     return null;
                 } else {
                     $v3d['eci_ref'] = 3;
                     if ($cardtype == 'mc') {
                         $v3d['eci'] = 0;
                     } else {
                         $v3d['eci'] = 7;
                     }
                 }
             }
         }
     }
     $p_result = $this->model_extension_default_realex->processPayment($pd, $v3d);
     ADebug::variable('Processing payment result: ', $p_result);
     if ($p_result->result != '00') {
         // transaction failed
         $json['error'] = (string) $p_result->message . ' (' . (int) $p_result->result . ')';
     } else {
         $json['success'] = $this->html->getSecureURL('checkout/success');
     }
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->load->library('json');
     $this->response->setOutput(AJson::encode($json));
 }
 public function main()
 {
     $href = '/mp_api2';
     $GET = $this->request->get;
     // if set subfolder for request(seo requests) - concatenate it to url
     if (isset($GET['path'])) {
         $href .= $GET['path'];
         unset($GET['path']);
     }
     $unset = array('s', 'rt', 'token', 'path', 'store_id', 'store_ip', 'store_url', 'store_version', 'language_code');
     foreach ($unset as $key) {
         unset($GET[$key]);
     }
     $GET['store_id'] = UNIQUE_ID;
     $GET['store_ip'] = $_SERVER['SERVER_ADDR'];
     $GET['store_url'] = HTTP_SERVER;
     $GET['store_version'] = VERSION;
     $GET['language_code'] = $this->request->cookie['language'];
     // place your affiliate id here
     define('MP_AFFILIATE_ID', '');
     if (MP_AFFILIATE_ID) {
         $GET['aff_id'] = MP_AFFILIATE_ID;
     }
     $href .= '?' . http_build_query($GET);
     $connect = new AConnect();
     $html = $connect->getResponse($href);
     if (!$html) {
         $this->loadLanguage('extension/extensions_store', 'silent');
         $error = is_array($connect->error) ? $connect->error : array($connect->error);
         foreach ($error as $err) {
             $this->log->write($err);
         }
         $html = '<div style="padding: 10px 10px 10px 20px;	margin-bottom: 15px; background: #FFDFE0 !important;	border: 1px solid #FF9999;	font-size: 12px;">' . $this->language->get('error_connect') . '</div>';
     } else {
         //then parse response
         // get base href and remove it from response
         preg_match('/\\<base.*?href=(\\")(.*?)(\\")/is', $html, $basehref);
         $basehref = $basehref[2];
         $html = str_replace('<base href="' . $basehref . '" />', '', $html);
         // then replace relative url by absolute (css, js, img)
         $html = str_replace('<link href="/', '<link href="' . $basehref, $html);
         $html = str_replace(' src="/', ' src="' . $basehref, $html);
         // then need to replace url of http-links except anchors and absolute urls
         preg_match_all('/href=(\\")(.*?)(\\")/i', $html, $orig_hrefs);
         for ($i = 0; $i < count($orig_hrefs[0]); $i++) {
             $replace = $orig_hrefs[0][$i];
             $ohref = $orig_hrefs[2][$i];
             $link1 = 'href="' . AEncryption::addEncoded_stid($ohref) . (MP_AFFILIATE_ID ? '&aff_id=' . MP_AFFILIATE_ID : '') . '"';
             $link2 = 'href="' . $this->html->getSecureUrl('tool/extensions_store', '&path=' . $ohref . (MP_AFFILIATE_ID ? '&aff_id=' . MP_AFFILIATE_ID : '')) . '"';
             if (substr($ohref, 0, 4) == 'http' || substr($ohref, 0, 1) == '#') {
                 $html = str_replace($replace, $link1, $html);
             } else {
                 $html = str_replace($replace, $link2, $html);
             }
         }
         // construct action for search form
         $action = $this->html->getSecureUrl('tool/extensions_store', MP_AFFILIATE_ID ? '&aff_id=' . MP_AFFILIATE_ID : '');
         $html = str_replace(' action="/', ' action="' . $action, $html);
         $hidden = '<input type="hidden" name="search_performed" value="Y">';
         $hidden .= '<input type="hidden" name="rt" value="tool/extensions_store">';
         $hidden .= '<input type="hidden" name="s" value="' . ADMIN_PATH . '">';
         $hidden .= '<input type="hidden" name="token" value="' . $this->request->get['token'] . '">';
         $hidden .= '<input type="hidden" name="aff_id" value="' . MP_AFFILIATE_ID . '">';
         $html = preg_replace('/<input.*name="search_performed".*>/', $hidden, $html);
         $html = $this->html->convertLinks($html);
         $html = str_replace('<span>Store ID</span>', '<span><font size="1"> ' . UNIQUE_ID . '</font></span>', $html);
     }
     $this->response->setOutput($html);
 }
Esempio n. 20
0
 /**
  * @param int $order_id
  * @param int $order_status_id
  * @param string $comment
  * @param bool $notify
  */
 public function update($order_id, $order_status_id, $comment = '', $notify = FALSE)
 {
     $order_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t FROM `" . $this->db->table("orders") . "` o\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN " . $this->db->table("languages") . " l ON (o.language_id = l.language_id)\n\t\t\t\t\t\t\t\t\t\t WHERE o.order_id = '" . (int) $order_id . "' AND o.order_status_id > '0'");
     if ($order_query->num_rows) {
         $order_row = $this->dcrypt->decrypt_data($order_query->row, 'orders');
         $this->db->query("UPDATE `" . $this->db->table("orders") . "`\n\t\t\t\t\t\t\t\tSET order_status_id = '" . (int) $order_status_id . "',\n\t\t\t\t\t\t\t\t\tdate_modified = NOW()\n\t\t\t\t\t\t\t\tWHERE order_id = '" . (int) $order_id . "'");
         $this->db->query("INSERT INTO " . $this->db->table("order_history") . "\n\t\t\t\t\t\t\t\tSET order_id = '" . (int) $order_id . "',\n\t\t\t\t\t\t\t\t\torder_status_id = '" . (int) $order_status_id . "',\n\t\t\t\t\t\t\t\t\tnotify = '" . (int) $notify . "',\n\t\t\t\t\t\t\t\t\tcomment = '" . $this->db->escape($comment) . "',\n\t\t\t\t\t\t\t\t\tdate_added = NOW()");
         //send notifications
         $language = new ALanguage($this->registry, $order_row['code']);
         $language->load($order_row['filename']);
         $language->load('mail/order_update');
         $order_status_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("order_statuses") . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE order_status_id = '" . (int) $order_status_id . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND language_id = '" . (int) $order_row['language_id'] . "'");
         $language_im = new ALanguage($this->registry);
         $language_im->load('common/im');
         $status_name = '';
         if ($order_status_query->row['name']) {
             $status_name = $order_status_query->row['name'];
         }
         $message_arr = array(0 => array('message' => sprintf($language_im->get('im_order_update_text_to_customer'), $order_id, $status_name)), 1 => array('message' => sprintf($language_im->get('im_order_update_text_to_admin'), $order_id, $status_name)));
         $this->im->send('order_update', $message_arr);
         //notify via email
         if ($notify) {
             $subject = sprintf($language->get('text_subject'), html_entity_decode($order_row['store_name'], ENT_QUOTES, 'UTF-8'), $order_id);
             $message = $language->get('text_order') . ' ' . $order_id . "\n";
             $message .= $language->get('text_date_added') . ' ' . dateISO2Display($order_row['date_added'], $language->get('date_format_short')) . "\n\n";
             if ($order_status_query->num_rows) {
                 $message .= $language->get('text_order_status') . "\n\n";
                 $message .= $order_status_query->row['name'] . "\n\n";
             }
             if ($order_row['customer_id']) {
                 $message .= $language->get('text_invoice') . "\n";
                 $message .= $order_row['store_url'] . 'index.php?rt=account/invoice&order_id=' . $order_id . "\n\n";
             } elseif ($this->config->get('config_guest_checkout') && $order_row['email']) {
                 $order_token = AEncryption::mcrypt_encode($order_id . '~~~' . $order_row['email']);
                 if ($order_token) {
                     $message .= $language->get('text_invoice') . "\n";
                     $message .= $order_row['store_url'] . 'index.php?rt=account/invoice&ot=' . $order_token . "\n\n";
                 }
             }
             if ($comment) {
                 $message .= $language->get('text_comment') . "\n\n";
                 $message .= $comment . "\n\n";
             }
             $message .= $language->get('text_footer');
             $mail = new AMail($this->config);
             $mail->setTo($order_row['email']);
             $mail->setFrom($this->config->get('store_main_email'));
             $mail->setSender($order_row['store_name']);
             $mail->setSubject($subject);
             $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
             $mail->send();
         }
     }
 }
Esempio n. 21
0
 /**
  * Get unique hashed cache key string from an key/group pair
  *
  * @param   string	$key	The cache data key
  * @param   string	$group	The cache data group
  *
  * @return  string
  *
  * @since   1.2.7
  */
 protected function _hashCacheKey($key, $group)
 {
     return AEncryption::getHash($group . '-' . $key);
 }
Esempio n. 22
0
 /**
  * @param string $loginname
  * @param string $password
  * @return bool
  */
 public function login($loginname, $password)
 {
     $approved_only = '';
     if ($this->config->get('config_customer_approval')) {
         $approved_only = " AND approved = '1'";
     }
     $customer_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("customers") . "\n\t\t\t\t\t\t\t\t\t\t\tWHERE loginname = '" . $this->db->escape($loginname) . "'\n\t\t\t\t\t\t\t\t\t\t\tAND password = '******'\n\t\t\t\t\t\t\t\t\t\t\tAND status = '1'" . $approved_only);
     if ($customer_query->num_rows) {
         $this->session->data['customer_id'] = $customer_query->row['customer_id'];
         if ($customer_query->row['cart'] && is_string($customer_query->row['cart'])) {
             $cart = unserialize($customer_query->row['cart']);
             foreach ($cart as $key => $value) {
                 if (!array_key_exists($key, $this->session->data['cart'])) {
                     $this->session->data['cart'][$key] = $value;
                 } else {
                     $this->session->data['cart'][$key]['qty'] += $value['qty'];
                 }
             }
         }
         $this->loginname = $loginname;
         $this->customer_id = $customer_query->row['customer_id'];
         $this->firstname = $customer_query->row['firstname'];
         $this->lastname = $customer_query->row['lastname'];
         if ($this->dcrypt->active) {
             $this->email = $this->dcrypt->decrypt_field($customer_query->row['email'], $customer_query->row['key_id']);
             $this->telephone = $this->dcrypt->decrypt_field($customer_query->row['telephone'], $customer_query->row['key_id']);
             $this->fax = $this->dcrypt->decrypt_field($customer_query->row['fax'], $customer_query->row['key_id']);
         } else {
             $this->email = $customer_query->row['email'];
             $this->telephone = $customer_query->row['telephone'];
             $this->fax = $customer_query->row['fax'];
         }
         $this->newsletter = $customer_query->row['newsletter'];
         $this->customer_group_id = $customer_query->row['customer_group_id'];
         $this->address_id = $customer_query->row['address_id'];
         $this->cache->delete('storefront_menu');
         return TRUE;
     } else {
         return FALSE;
     }
 }
Esempio n. 23
0
 /**
  * @param int $order_id
  * @param array $data
  * @throws AException
  */
 public function addOrderHistory($order_id, $data)
 {
     $this->db->query("UPDATE `" . $this->db->table("orders") . "`\n\t\t\t\t\t\t\tSET order_status_id = '" . (int) $data['order_status_id'] . "',\n\t\t\t\t\t\t\t\tdate_modified = NOW()\n\t\t\t\t\t\t\tWHERE order_id = '" . (int) $order_id . "'");
     if ($data['append']) {
         $this->db->query("INSERT INTO " . $this->db->table("order_history") . "\n      \t\t                    SET order_id = '" . (int) $order_id . "',\n      \t\t                        order_status_id = '" . (int) $data['order_status_id'] . "',\n      \t\t                        notify = '" . (isset($data['notify']) ? (int) $data['notify'] : 0) . "',\n      \t\t                        comment = '" . $this->db->escape(strip_tags($data['comment'])) . "',\n      \t\t                        date_added = NOW()");
     }
     if ($data['notify']) {
         $order_query = $this->db->query("SELECT *, os.name AS status\n        \t                                FROM `" . $this->db->table("orders") . "` o\n        \t                                LEFT JOIN " . $this->db->table("order_statuses") . " os ON (o.order_status_id = os.order_status_id AND os.language_id = o.language_id)\n        \t                                LEFT JOIN " . $this->db->table("languages") . " l ON (o.language_id = l.language_id)\n        \t                                WHERE o.order_id = '" . (int) $order_id . "'");
         if ($order_query->num_rows) {
             //load language specific for the order in admin section
             $language = new ALanguage(Registry::getInstance(), $order_query->row['code'], 1);
             $language->load($order_query->row['filename']);
             $language->load('mail/order');
             $this->load->model('setting/store');
             $subject = sprintf($language->get('text_subject'), $order_query->row['store_name'], $order_id);
             $message = $language->get('text_order') . ' ' . $order_id . "\n";
             $message .= $language->get('text_date_added') . ' ' . dateISO2Display($order_query->row['date_added'], $language->get('date_format_short')) . "\n\n";
             $message .= $language->get('text_order_status') . "\n\n";
             $message .= $order_query->row['status'] . "\n\n";
             //send link to order only for registered custemers
             if ($order_query->row['customer_id']) {
                 $message .= $language->get('text_invoice') . "\n";
                 $message .= html_entity_decode($order_query->row['store_url'] . 'index.php?rt=account/invoice&order_id=' . $order_id, ENT_QUOTES, 'UTF-8') . "\n\n";
             } elseif ($this->config->get('config_guest_checkout') && $order_query->row['email']) {
                 $order_token = AEncryption::mcrypt_encode($order_id . '~~~' . $order_query->row['email']);
                 if ($order_token) {
                     $message .= $language->get('text_invoice') . "\n";
                     $message .= html_entity_decode($order_query->row['store_url'] . 'index.php?rt=account/invoice&ot=' . $order_token, ENT_QUOTES, 'UTF-8') . "\n\n";
                 }
             }
             if ($data['comment']) {
                 $message .= $language->get('text_comment') . "\n\n";
                 $message .= strip_tags(html_entity_decode($data['comment'], ENT_QUOTES, 'UTF-8')) . "\n\n";
             }
             $message .= $language->get('text_footer');
             if ($this->dcrypt->active) {
                 $customer_email = $this->dcrypt->decrypt_field($order_query->row['email'], $order_query->row['key_id']);
             } else {
                 $customer_email = $order_query->row['email'];
             }
             $mail = new AMail($this->config);
             $mail->setTo($customer_email);
             $mail->setFrom($this->config->get('store_main_email'));
             $mail->setSender($order_query->row['store_name']);
             $mail->setSubject($subject);
             $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
             $mail->send();
         }
     }
 }
Esempio n. 24
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('common/login');
     $this->cache->delete('admin_menu');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->document->addBreadcrumb(array('href' => '', 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('index/login'), 'text' => $this->language->get('heading_title'), 'current' => true, 'sub_text' => '', 'icon' => ''));
     if ($this->request->is_POST() && $this->_validate()) {
         $this->session->data['token'] = AEncryption::getHash(mt_rand());
         $this->session->data['checkupdates'] = true;
         // sign to run ajax-request to check for updates. see common/head for details
         //login is sussessful redirect to originaly requested page
         if (isset($this->request->post['redirect']) && !preg_match("/rt=index\\/login/i", $this->request->post['redirect'])) {
             $redirect = $this->html->filterQueryParams($this->request->post['redirect'], array('token'));
             $redirect .= "&token=" . $this->session->data['token'];
             $this->redirect($redirect);
         } else {
             $this->redirect($this->html->getSecureURL('index/home'));
         }
     }
     if (isset($this->session->data['token']) && !isset($this->request->get['token']) || isset($this->request->get['token']) && (isset($this->session->data['token']) && $this->request->get['token'] != $this->session->data['token'])) {
         $this->error['warning'] = $this->language->get('error_token');
     }
     //There was no login done, so clear the session for new login screen
     $this->session->clear();
     if ($this->request->cookie['new_cart'] == 1 && $this->error['warning'] && $this->request->server['REQUEST_METHOD'] == 'GET') {
         $this->error['warning'] = '';
     }
     $this->data['action'] = $this->html->getSecureURL('index/login');
     $this->data['update'] = '';
     $form = new AForm('ST');
     $form->setForm(array('form_name' => 'loginFrm', 'update' => $this->data['update']));
     $this->data['form']['id'] = 'loginFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'loginFrm', 'action' => $this->data['action']));
     $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_login'), 'style' => 'button3'));
     $fields = array('username', 'password');
     foreach ($fields as $f) {
         $this->data['form']['fields'][$f] = $form->getFieldHtml(array('type' => $f == 'password' ? 'password' : 'input', 'name' => $f, 'value' => $this->data[$f], 'placeholder' => $this->language->get('entry_' . $f)));
     }
     $this->view->assign('error_warning', $this->error['warning']);
     $this->view->assign('forgot_password', $this->html->getSecureURL('index/forgot_password'));
     if (isset($this->request->get['rt'])) {
         $route = $this->request->get['rt'];
         unset($this->request->get['rt']);
         if (isset($this->request->get['token'])) {
             unset($this->request->get['token']);
         }
         $url = '';
         if ($this->request->get) {
             $url = '&' . http_build_query($this->request->get);
         }
         if ($this->request->is_POST()) {
             $this->view->assign('redirect', $this->request->post['redirect']);
             // if login attempt failed - save path for redirect
         } else {
             $this->view->assign('redirect', $this->html->getSecureURL($route, $url));
         }
     } else {
         $this->view->assign('redirect', '');
     }
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/index/login.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Esempio n. 25
0
 public function CancelOrder()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     //do a few checks
     //is order exists
     $order_id = (int) $this->request->get['order_id'];
     $customer_id = $this->customer->getId();
     $this->loadModel('account/order');
     $guest = false;
     if (isset($this->request->get['ot']) && $this->config->get('config_guest_checkout')) {
         //try to decrypt order token
         $decrypted = AEncryption::mcrypt_decode($this->request->get['ot']);
         list($order_id, $email) = explode('~~~', $decrypted);
         $order_id = (int) $order_id;
         if (!$decrypted || !$order_id || !$email) {
             if ($order_id) {
                 $this->session->data['redirect'] = $this->html->getSecureURL('account/invoice', '&order_id=' . $order_id);
             }
             $this->redirect($this->html->getSecureURL('account/login'));
         }
         $order_info = $this->model_account_order->getOrder($order_id, '', 'view');
         //compare emails
         if ($order_info['email'] != $email) {
             $this->redirect($this->html->getSecureURL('account/login'));
         }
         $guest = true;
     } else {
         $order_info = $this->model_account_order->getOrder($order_id);
     }
     if (!$order_id && !$guest) {
         $this->redirect($this->html->getSecureURL('account/invoice'));
     }
     if (!$customer_id && !$guest) {
         $this->redirect($this->html->getSecureURL('account/login'));
     }
     if (!$order_info) {
         $this->redirect($this->html->getSecureURL('account/invoice'));
     }
     //is cancelation enabled at all
     if ($this->config->get('config_customer_cancelation_order_status_id')) {
         $order_cancel_ids = unserialize($this->config->get('config_customer_cancelation_order_status_id'));
     }
     //is cancelation allowed for current order status
     if (!$order_cancel_ids || !in_array($order_info['order_status_id'], $order_cancel_ids)) {
         $this->redirect($this->html->getSecureURL('account/invoice'));
     }
     //now do change
     $new_order_status_id = $this->order_status->getStatusByTextId('canceled_by_customer');
     if ($new_order_status_id) {
         $this->loadModel('checkout/order');
         $this->model_checkout_order->update($order_id, $new_order_status_id, 'Request an Order cancellation from Customer', true);
         $this->session->data['success'] = $this->language->get('text_order_cancelation_success');
         $this->messages->saveNotice(sprintf($this->language->get('text_order_cancelation_message_title'), $order_id), sprintf($this->language->get('text_order_cancelation_message_body'), $order_info['firstname'] . ' ' . $order_info['lastname'], $order_id, '#admin#rt=sale/order/details&order_id=' . $order_id));
     } else {
         //when new order status id is null by some unexpected reason - just redirect on the same page
         $this->log->write('Error: Unknown cancelation order status id. Probably integrity code problem. Check is file /core/lib/order_status.php exists.');
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     if (!$guest) {
         $url = $this->html->getSecureURL('account/invoice', '&order_id=' . $order_id);
     } else {
         $url = $this->html->getSecureURL('account/invoice', '&ot=' . $this->request->get['ot']);
     }
     $this->redirect($url);
 }
Esempio n. 26
0
 protected function migrateCustomers()
 {
     $customers = $this->cartObj->getCustomers();
     if (!$customers) {
         $errors = $this->cartObj->getErrors();
         $class = '';
         if (!$errors) {
             $errors = $this->language->get('text_no_customers');
             $class = 'attention';
         }
         $this->addLog($errors, $class);
         return true;
     }
     // get all loginnames to prevent conflicts.
     $query = $this->db->query("SELECT LOWER(`loginname`) AS loginname\n\t\t\t\t\t\t\t\t   FROM " . $this->db->table("customers"));
     $logins = array();
     foreach ($query->rows as $row) {
         $logins[] = $row['loginname'];
     }
     foreach ($customers as $data) {
         if (!trim($data['email'])) {
             continue;
         }
         $store_id = has_value($data['store_id']) ? (int) $data['store_id'] : (int) $this->config->get('config_store_id');
         $date_added = has_value($data['date_added']) ? "'" . $this->db->escape($data['date_added']) . "'" : 'NOW()';
         $status = has_value($data['status']) ? $data['status'] : 1;
         $approved = has_value($data['approved']) ? $data['approved'] : 1;
         $data['email'] = mb_strtolower($data['email']);
         //process unique loginname
         $loginname = $data['loginname'] ? $data['loginname'] : '';
         $loginname = mb_strtolower($loginname);
         if (!$loginname && !$this->config->get('prevent_email_as_login') && $data['email'] && !in_array($data['email'], $logins)) {
             $loginname = $data['email'];
         }
         if (in_array($loginname, $logins)) {
             $loginname = '';
         }
         if (!$loginname) {
             $loginname = 'gen_' . md5(microtime());
         }
         $sql = "INSERT INTO " . DB_PREFIX . "customers\n\t\t\t\t\tSET store_id = '" . $store_id . "',\n\t\t\t\t\t\tfirstname = '" . $this->db->escape($data['firstname']) . "',\n\t\t\t\t\t\tlastname = '" . $this->db->escape($data['lastname']) . "',\n\t\t\t\t\t\temail = '" . $this->db->escape($data['email']) . "',\n\t\t\t\t\t\tloginname = '" . $this->db->escape($loginname) . "',\n\t\t\t\t\t\ttelephone = '" . $this->db->escape($data['telephone']) . "',\n\t\t\t\t\t\tfax = '" . $this->db->escape($data['fax']) . "',\n\t\t\t\t\t\tpassword = '******'password'])) . "',\n\t\t\t\t\t\tnewsletter = '" . $this->db->escape($data['newsletter']) . "',\n\t\t\t\t\t\tip = '" . $this->db->escape($data['ip']) . "',\n\t\t\t\t\t\tcustomer_group_id = '" . (int) $this->config->get('config_customer_group_id') . "',\n\t\t\t\t\t\tstatus = '" . $status . "',\n\t\t\t\t\t\tapproved = '" . $approved . "',\n\t\t\t\t\t\tdate_added = " . $date_added . "";
         $result = $this->db->query($sql, true);
         $logins[] = $loginname;
         if ($result === false) {
             $this->addLog($this->db->error);
         }
         $customer_id = $this->db->getLastId();
         $customer_id_map[$data['customer_id']] = $customer_id;
         $data['address'] = (array) $data['address'];
         foreach ($data['address'] as $address) {
             $sql = "INSERT INTO " . DB_PREFIX . "addresses\n\t\t\t\t\t  SET customer_id = '" . (int) $customer_id . "',\n\t\t\t\t\t\t  firstname = '" . $this->db->escape($address['firstname']) . "',\n\t\t\t\t\t\t\tlastname = '" . $this->db->escape($address['lastname']) . "',\n\t\t\t\t\t\t\tcompany = '" . $this->db->escape($address['company']) . "',\n\t\t\t\t\t\t\taddress_1 = '" . $this->db->escape($address['address_1']) . "',\n\t\t\t\t\t\t\tcity = '" . $this->db->escape($address['city']) . "',\n\t\t\t\t\t\t\tpostcode = '" . $this->db->escape($address['postcode']) . "',\n\t\t\t\t\t\t\tcountry_id = " . ($address['country_iso_code2'] ? " COALESCE((SELECT country_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . DB_PREFIX . "countries\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE iso_code_2='" . $this->db->escape($address['country_iso_code2']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 0,1),0)" : "'0'") . ",\n\t\t\t\t\t\t\tzone_id = " . ($address['zone_iso_code2'] ? "COALESCE((SELECT zone_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . DB_PREFIX . "zones\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE code='" . $this->db->escape($address['zone_iso_code2']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 0,1),0)" : "'0'");
             $result = $this->db->query($sql, true);
             if ($result === false) {
                 $this->addLog($this->db->error);
             }
             $address_id = $this->db->getLastId();
         }
         $result = $this->db->query("UPDATE " . DB_PREFIX . "customers\n\t\t\t\t\t\t\t\t\t    SET address_id = '" . (int) $address_id . "'\n\t\t\t\t\t\t\t\t        WHERE customer_id = '" . (int) $customer_id . "'", true);
         if ($result === false) {
             $this->addLog($this->db->error);
         }
     }
     $this->addLog(count($customers) . ' customers imported', 'success');
     return true;
 }
Esempio n. 27
0
    public function edit()
    {
        //init controller data
        $this->extensions->hk_InitData($this, __FUNCTION__);
        $this->document->addScript($this->view->templateResource('/javascript/jquery/thickbox/thickbox-compressed.js'));
        $this->document->addStyle(array('href' => $this->view->templateResource('/javascript/jquery/thickbox/thickbox.css'), 'rel' => 'stylesheet', 'media' => 'screen'));
        $this->document->resetBreadcrumbs();
        $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
        $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('extension/extensions/' . $this->session->data['extension_filter']), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
        $extension = $this->request->get['extension'];
        $this->loadLanguage('extension/extensions');
        $this->loadLanguage($extension . '/' . $extension);
        $store_id = (int) $this->config->get('config_store_id');
        if ($this->request->get_or_post('store_id')) {
            $store_id = $this->request->get_or_post('store_id');
        }
        $ext = new ExtensionUtils($extension, $store_id);
        $settings = $ext->getSettings();
        $extension_info = $this->extensions->getExtensionInfo($extension);
        if (!$extension_info) {
            // if extension is not installed yet - redirect to list
            $this->redirect($this->html->getSecureURL('extension/extensions'));
        }
        /** build aform with settings**/
        $result = array('resource_field_list' => array());
        // store switcher for default store Cntrol Panel only
        if (!$this->config->get('config_store_id')) {
            $stores = array();
            $stores[0] = $this->language->get('text_default');
            $this->loadModel('setting/store');
            $stores_arr = $this->model_setting_store->getStores();
            if (count($stores_arr) > 1) {
                foreach ($stores_arr as $res) {
                    $stores[$res['store_id']] = $res['alias'];
                }
                $switcher = array('name' => 'store_id', 'type' => 'selectbox', 'options' => $stores, 'value' => $store_id, 'note' => $this->language->get('tab_store'), 'style' => 'no-save');
            } else {
                $switcher = array('type' => 'hidden', 'name' => 'store_id', 'note' => ' ', 'value' => 0);
            }
        } else {
            $switcher = array('type' => 'hidden', 'name' => 'store_id', 'note' => ' ', 'value' => $store_id);
        }
        array_unshift($settings, $switcher);
        foreach ($settings as $item) {
            $data = array();
            if ($item['name'] == $extension . '_status') {
                $status = $item['value'];
            }
            $data['name'] = $item['name'];
            $data['type'] = $item['type'];
            $data['value'] = $item['value'];
            $data['required'] = (bool) $item['required'];
            if ($item['note']) {
                $data['note'] = $item['note'];
            } else {
                $note_text = $this->language->get($data['name']);
                // if text definition not found - seek it in default settings definitions
                if ($note_text == $data['name']) {
                    $new_text_key = str_replace($extension . '_', 'text_', $data['name']);
                    $note_text = $this->language->get($new_text_key);
                    if ($note_text == $new_text_key) {
                        $note_text = $this->language->get($new_text_key . '_' . $extension_info['type']);
                    }
                }
                $data['note'] = $note_text;
            }
            if ($item['style']) {
                $data['style'] = $item['style'];
            }
            if ($item['attr']) {
                $data['attr'] = $item['attr'];
            }
            if ($item['readonly']) {
                $data['readonly'] = $item['readonly'];
            }
            switch ($data['type']) {
                case 'selectbox':
                case 'multiselectbox':
                case 'checkboxgroup':
                    // if options need to extract from db
                    $data['options'] = $item['options'];
                    if ($item['model_rt'] != '') {
                        //force to load models even before extension is enabled
                        $this->loadModel($item['model_rt'], 'force');
                        $model = $this->{'model_' . str_replace("/", "_", $item['model_rt'])};
                        $method_name = $item['method'];
                        if (method_exists($model, $method_name)) {
                            $res = call_user_func(array($model, $method_name));
                            if ($res) {
                                $field1 = $item['field1'];
                                $field2 = $item['field2'];
                                foreach ($res as $opt) {
                                    $data['options'][$opt[$field1]] = $opt[$field2];
                                }
                            }
                        }
                    }
                    if ($data['type'] == 'checkboxgroup' || $data['type'] == 'multiselectbox') {
                        #custom settings for multivalue
                        $data['scrollbox'] = 'true';
                        if (substr($item['name'], -2) != '[]') {
                            $data['name'] = $item['name'] . "[]";
                        }
                    }
                    break;
                case 'resource':
                    $item['resource_type'] = (string) $item['resource_type'];
                    if (!$result['rl_scripts']) {
                        $scripts = $this->dispatch('responses/common/resource_library/get_resources_scripts', array('object_name' => '', 'object_id' => '', 'types' => $item['resource_type'], 'mode' => 'url'));
                        $result['rl_scripts'] = $scripts->dispatchGetOutput();
                        unset($scripts);
                    }
                    //preview of resource
                    $resource = new AResource($item['resource_type']);
                    $resource_id = $resource->getIdFromHexPath(str_replace($item['resource_type'] . '/', '', $item['value']));
                    $preview = $this->dispatch('responses/common/resource_library/get_resource_html_single', array('type' => 'image', 'wrapper_id' => $item['name'], 'resource_id' => $resource_id, 'field' => $item['name']));
                    $item['value'] = $preview->dispatchGetOutput();
                    if ($data['value']) {
                        $data = array('note' => $data['note'], 'name' => $item['name'], 'type' => 'hidden');
                        if ($resource_id) {
                            $resource_info = $resource->getResource($resource_id);
                            $data['value'] = $item['resource_type'] . '/' . $resource_info['resource_path'];
                        }
                    }
                    $result['resource_field_list'][$item['name']]['value'] = $item['value'];
                    $result['resource_field_list'][$item['name']]['resource_type'] = $item['resource_type'];
                    $result['resource_field_list'][$item['name']]['resource_id'] = $resource_id;
                    break;
                default:
            }
            $item = HtmlElementFactory::create($data);
            $result['html'][$data['name']] = array('note' => $data['note'], 'value' => $item->getHtml());
        }
        // end building aform
        $this->data['settings'] = $result['html'];
        $this->data['resource_field_list'] = $result['resource_field_list'];
        $this->data['resource_edit_link'] = $this->data['resources_scripts'] = $result['rl_scripts'];
        $this->data['target_url'] = $this->html->getSecureURL('extension/extensions/edit', '&extension=' . $extension . '&store_id=' . $store_id);
        if (isset($this->request->get['restore']) && $this->request->get['restore']) {
            $this->extension_manager->editSetting($extension, $ext->getDefaultSettings());
            $this->cache->delete('settings.extension');
            $this->session->data['success'] = $this->language->get('text_restore_success');
            $this->redirect($this->data['target_url']);
        }
        if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->_validateSettings($extension, $store_id)) {
            foreach ($settings as $item) {
                if (!isset($this->request->post[$item['name']])) {
                    $this->request->post[$item['name']] = 0;
                }
            }
            $this->extension_manager->editSetting($extension, $this->request->post);
            $this->cache->delete('settings.extension');
            $this->session->data['success'] = $this->language->get('text_success');
            $this->redirect($this->data['target_url']);
        }
        $conflict_resources = $ext->validateResources();
        if (!empty($conflict_resources)) {
            ob_start();
            print_r($conflict_resources);
            $err = ob_get_clean();
            ADebug::warning('resources conflict', AC_ERR_USER_WARNING, $extension . ' Extension resources conflict detected.<br/><pre>' . $err . '</pre>');
        }
        $this->document->setTitle($this->language->get($extension . '_name'));
        $this->document->addBreadcrumb(array('href' => $this->data['target_url'], 'text' => $this->language->get($extension . '_name'), 'separator' => ' :: '));
        $this->data['heading_title'] = $this->language->get($extension . '_name');
        $this->data['text_version'] = $this->language->get('text_version');
        $this->data['text_installed_on'] = $this->language->get('text_installed_on');
        $this->data['text_date_added'] = $this->language->get('text_date_added');
        $this->data['text_license'] = $this->language->get('text_license');
        $this->data['text_dependency'] = $this->language->get('text_dependency');
        $this->data['text_configuration_settings'] = $this->language->get('text_configuration_settings');
        $this->data['button_back'] = $this->html->buildButton(array('name' => 'btn_back', 'text' => $this->language->get('text_back'), 'style' => 'button2'));
        $this->data['button_reload'] = $this->html->buildButton(array('name' => 'btn_reload', 'text' => $this->language->get('text_reload'), 'style' => 'button2'));
        $this->data['button_restore_defaults'] = $this->html->buildButton(array('name' => 'button_restore_defaults', 'text' => $this->language->get('button_restore_defaults'), 'style' => 'button2'));
        $this->data['button_save'] = $this->html->buildButton(array('name' => 'btn_save', 'text' => $this->language->get('button_save'), 'style' => 'button1'));
        $this->data['button_save_green'] = $this->html->buildButton(array('name' => 'btn_save', 'text' => $this->language->get('button_save'), 'style' => 'button3'));
        $this->data['button_reset'] = $this->html->buildButton(array('name' => 'btn_reset', 'text' => $this->language->get('text_reset'), 'style' => 'button2'));
        $this->data['reload'] = $this->html->getSecureURL('extension/extensions/edit/', '&extension=' . $extension);
        $this->data['back'] = $this->html->getSecureURL('extension/extensions/' . $this->session->data['extension_filter']);
        $this->data['update'] = $this->html->getSecureURL('listing_grid/extension/update', '&id=' . $extension . '&store_id=' . $store_id);
        $this->data['dependants_url'] = $this->html->getSecureURL('listing_grid/extension/dependants');
        $form = new AForm();
        $form->setForm(array('form_name' => 'editSettings'));
        $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'editSettings', 'attr' => 'confirm-exit="true"', 'action' => $this->html->getSecureURL('extension/extensions/edit/', '&action=save&extension=' . $extension . '&store_id=' . $store_id)));
        if (!$this->extension_manager->validateDependencies($extension, getExtensionConfigXml($extension))) {
            $this->error['warning'] = 'This extension cannot be enabled because required dependency missing or not enabled.';
        }
        if (isset($this->error['warning'])) {
            $this->data['error_warning'] = $this->error['warning'];
        } else {
            $this->data['error_warning'] = '';
        }
        if (isset($this->session->data['success'])) {
            $this->data['success'] = $this->session->data['success'];
            unset($this->session->data['success']);
        } else {
            $this->data['success'] = '';
        }
        if (isset($this->session->data['error'])) {
            $this->data['error_warning'] = $this->session->data['error'];
            unset($this->session->data['error']);
        } else {
            $this->data['error'] = '';
        }
        $icon_ext_img_url = HTTP_CATALOG . 'extensions/' . $extension . '/image/icon.png';
        $icon_ext_dir = DIR_EXT . $extension . '/image/icon.png';
        $icon = is_file($icon_ext_dir) ? $icon_ext_img_url : RDIR_TEMPLATE . 'image/default_extension.png';
        $extension_data = array('id' => $extension);
        $missing_extensions = $this->extensions->getMissingExtensions();
        if (!in_array($extension, $missing_extensions)) {
            $extension_data['icon'] = $icon;
            $extension_data['name'] = $this->language->get($extension . '_name');
            $extension_data['version'] = $extension_info['version'];
            $long_datetime_format = $this->language->get('date_format_long') . ' ' . $this->language->get('time_format');
            if ($extension_info['date_installed']) {
                $extension_data['installed'] = dateISO2Display($extension_info['date_installed'], $long_datetime_format);
            }
            if ($extension_info['create_date']) {
                $extension_data['create_date'] = dateISO2Display($extension_info['create_date'], $long_datetime_format);
            }
            $extension_data['license'] = $extension_info['license_key'];
            $extension_data['note'] = $ext->getConfig('note') ? $this->html->convertLinks($this->language->get($extension . '_note')) : '';
            $config = $ext->getConfig();
            if (!empty($config->preview->item)) {
                foreach ($config->preview->item as $item) {
                    if (!is_file(DIR_EXT . $extension . DIR_EXT_IMAGE . (string) $item)) {
                        continue;
                    }
                    $extension_data['preview'][] = HTTPS_EXT . $extension . DIR_EXT_IMAGE . (string) $item;
                }
            }
            if (isset($this->session->data['extension_updates'][$extension])) {
                $extension_data['upgrade'] = array('text' => $this->html->buildButton(array('id' => 'upgradenow', 'name' => 'btn_upgrade', 'text' => $this->language->get('button_upgrade'), 'style' => 'button1')), 'link' => AEncryption::addEncoded_stid($this->session->data['extension_updates'][$extension]['url']));
            }
            $extension_data['help'] = array('text' => $this->html->buildButton(array('name' => 'btn_help', 'text' => $this->language->get('text_help'), 'style' => 'button2')), 'ext_link' => $ext->getConfig('help_link'));
            if ($ext->getConfig('help_file')) {
                $extension_data['help']['file'] = true;
                $extension_data['help']['file_link'] = $this->html->getSecureURL('extension/extension/help', '&extension=' . $this->request->get['extension']);
                $this->data['text_more_help'] = $this->language->get('text_more_help');
            }
            $extension_data['dependencies'] = array();
            $extension_data['extensions'] = $this->extensions->getEnabledExtensions();
            $missing_extensions = $this->extensions->getMissingExtensions();
            $db_extensions = $this->extensions->getDbExtensions();
            if (isset($config->dependencies->item)) {
                foreach ($config->dependencies->item as $item) {
                    $id = (string) $item;
                    if (in_array($id, $db_extensions)) {
                        if (in_array($id, $missing_extensions)) {
                            $class = 'warning';
                            $action = str_replace('%EXT%', $id, $this->language->get('text_missing_extension')) . '<a class="btn_action" target="_blank" href="' . $this->html->getSecureURL('extension/extensions/delete', '&extension=' . $id) . '"
										onclick="return confirm(\'' . $this->language->get('text_delete_confirm') . '\')" title="' . $this->language->get('text_delete') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_delete.png" alt="' . $this->language->get('text_delete') . '" />' . '</a>';
                        } else {
                            if (!$this->config->has($id . '_status')) {
                                $class = 'attention';
                                $action = '<a class="btn_action" target="_blank" href="' . $this->html->getSecureURL('extension/extensions/install', '&extension=' . $id) . '"
								title="' . $this->language->get('text_install') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_install.png" alt="' . $this->language->get('text_install') . '" />' . '</a>' . '<a class="btn_action" target="_blank" href="' . $this->html->getSecureURL('extension/extensions/delete', '&extension=' . $id) . '"
									  onclick="return confirm(\'' . $this->language->get('text_delete_confirm') . '\')" title="' . $this->language->get('text_delete') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_delete.png" alt="' . $this->language->get('text_delete') . '" />' . '</a>';
                            } else {
                                $action = '<a id="action_edit_' . $id . '" target="_blank" class="btn_action"
												href="' . $this->html->getSecureURL('extension/extensions/edit', '&extension=' . $id) . '"
												title="' . $this->language->get('text_edit') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_edit.png" alt="' . $this->language->get('text_edit') . '" /></a>';
                                if (!(bool) $item['required']) {
                                    $action .= '<a class="btn_action" target="_blank" href="' . $this->html->getSecureURL('extension/extensions/uninstall', '&extension=' . $id) . '"
									  onclick="return confirm(\'' . str_replace('%extension%', $id, $this->language->get('text_uninstall_confirm')) . '\')"
									  title="' . $this->language->get('text_uninstall') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_uninstall.png" alt="' . $this->language->get('text_uninstall') . '" />' . '</a>';
                                }
                            }
                        }
                    } else {
                        $action = '<a href="' . $this->html->getSecureURL('extension/extensions_store', '&extension=' . $id) . '" target="_blank">';
                        $action = str_replace('%extensions_store%', $action, $this->language->get('text_visit_repository'));
                    }
                    $extension_data['dependencies'][] = array('required' => (bool) $item['required'], 'id' => $id, 'status' => ($this->config->has($id . '_status') ? $this->language->get('text_installed') : $this->language->get('text_not_installed')) . ' (' . ($this->config->get($id . '_status') ? $this->language->get('text_enabled') : $this->language->get('text_disabled')) . ' )', 'action' => $action, 'class' => $class);
                    unset($class);
                }
            }
        } else {
            // if extension missing
            $extension_data['icon'] = $icon;
            $extension_data['name'] = str_replace('%EXT%', $extension, $this->language->get('text_missing_extension'));
        }
        // additional settings page
        if ($ext->getConfig('additional_settings') && $status) {
            $btn_param = array('name' => 'btn_addsett', 'text' => $this->language->get('text_additional_settings'), 'style' => 'button1');
            $this->data['add_sett']['link'] = $this->html->getSecureURL($ext->getConfig('additional_settings'));
            if ($store_id) {
                $this->loadModel('setting/store');
                $store_info = $this->model_setting_store->getStore($store_id);
                $this->data['add_sett']['link'] = $store_info['config_url'] . '?s=' . ADMIN_PATH . '&rt=' . $ext->getConfig('additional_settings');
                $this->data['add_sett']['onclick'] = 'onclick="return confirm(\'' . $this->language->get('additional_settings_confirm') . '\');"';
            }
            $this->data['add_sett']['text'] = $this->html->buildButton($btn_param);
        }
        $this->data['extension'] = $extension_data;
        $this->data['target_url'] = $this->html->getSecureURL('extension/extensions/edit', '&extension=' . $extension);
        $this->view->assign('help_url', $this->gen_help_url('extension_edit'));
        $template = 'pages/extension/extensions_edit.tpl';
        //#PR set custom templates for extension settings page.
        if (has_value((string) $config->custom_settings_template)) {
            //build path to template directory.
            $dir_template = DIR_EXT . $extension . DIR_EXT_ADMIN . DIR_EXT_TEMPLATE . $this->config->get('admin_template') . "/template/";
            $dir_template .= (string) $config->custom_settings_template;
            //validate template and report issue
            if (!file_exists($dir_template)) {
                $warning = new AWarning("Cannot load override template {$dir_template} in extension {$extension}!");
                $warning->toLog()->toDebug();
            } else {
                $template = $dir_template;
            }
        }
        $this->view->batchAssign($this->data);
        $this->processTemplate($template);
        //update controller data
        $this->extensions->hk_UpdateData($this, __FUNCTION__);
    }
 /**
  * @param string $loginname
  * @param string $password
  * @return bool
  */
 public function login($loginname, $password)
 {
     $approved_only = '';
     if ($this->config->get('config_customer_approval')) {
         $approved_only = " AND approved = '1'";
     }
     $customer_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("customers") . "\n\t\t\t\t\t\t\t\t\t\t\tWHERE LOWER(loginname)  = LOWER('" . $this->db->escape($loginname) . "')\n\t\t\t\t\t\t\t\t\t\t\tAND password = '******'\n\t\t\t\t\t\t\t\t\t\t\tAND status = '1'" . $approved_only);
     if ($customer_query->num_rows) {
         $this->customer_id = $this->session->data['customer_id'] = $customer_query->row['customer_id'];
         //load customer saved cart and merge with session cart before login
         $cart = $this->getCustomerCart();
         $this->mergeCustomerCart($cart);
         //save merged cart
         $this->saveCustomerCart();
         $this->loginname = $loginname;
         $this->firstname = $customer_query->row['firstname'];
         $this->lastname = $customer_query->row['lastname'];
         if ($this->dcrypt->active) {
             $this->email = $this->dcrypt->decrypt_field($customer_query->row['email'], $customer_query->row['key_id']);
             $this->telephone = $this->dcrypt->decrypt_field($customer_query->row['telephone'], $customer_query->row['key_id']);
             $this->fax = $this->dcrypt->decrypt_field($customer_query->row['fax'], $customer_query->row['key_id']);
         } else {
             $this->email = $customer_query->row['email'];
             $this->telephone = $customer_query->row['telephone'];
             $this->fax = $customer_query->row['fax'];
         }
         $this->newsletter = $customer_query->row['newsletter'];
         $this->customer_group_id = $customer_query->row['customer_group_id'];
         $this->address_id = $customer_query->row['address_id'];
         $this->cache->delete('storefront_menu');
         //set cookie for unauthenticated user (expire in 1 year)
         $encryption = new AEncryption($this->config->get('encryption_key'));
         $cutomer_data = $encryption->encrypt(serialize(array('first_name' => $this->firstname, 'customer_id' => $this->customer_id, 'script_name' => $this->request->server['SCRIPT_NAME'])));
         setcookie('customer', $cutomer_data, time() + 60 * 60 * 24 * 365, '/', $this->request->server['HTTP_HOST']);
         return true;
     } else {
         return false;
     }
 }
 private function _get_products_data($order_info)
 {
     $that = $this->baseObject;
     $that->load->library('encryption');
     $encryption = new AEncryption($that->config->get('encryption_key'));
     $this->data['products'] = array();
     $this->data['items_total'] = 0.0;
     $products = $that->cart->getProducts();
     foreach ($products as $product) {
         $option_data = array();
         foreach ($product['option'] as $option) {
             if ($option['type'] != 'file') {
                 $value = $option['value'];
             } else {
                 $filename = $encryption->decrypt($option['value']);
                 $value = mb_substr($filename, 0, mb_strrpos($filename, '.'));
             }
             $option_data[] = array('name' => $option['name'], 'value' => mb_strlen($value) > 20 ? mb_substr($value, 0, 20) . '..' : $value);
         }
         $price = $that->currency->format($product['price'], $order_info['currency'], $order_info['value'], FALSE);
         $this->data['products'][] = array('name' => $product['name'], 'model' => $product['model'], 'price' => $price, 'quantity' => $product['quantity'], 'option' => $option_data, 'weight' => $product['weight'], 'weight_type' => $product['weight_type']);
         $this->data['items_total'] += $price * $product['quantity'];
     }
     $this->data['discount_amount_cart'] = 0;
     $totals = $that->cart->buildTotalDisplay();
     foreach ($totals['total_data'] as $total) {
         if (in_array($total['id'], array('subtotal', 'total'))) {
             continue;
         }
         if (in_array($total['id'], array('promotion', 'coupon'))) {
             $total['value'] = $total['value'] < 0 ? $total['value'] * -1 : $total['value'];
             $this->data['discount_amount_cart'] += $total['value'];
         } else {
             $price = $that->currency->format($total['value'], $order_info['currency'], $order_info['value'], FALSE);
             $this->data['products'][] = array('name' => $total['title'], 'model' => '', 'price' => $price, 'quantity' => 1, 'option' => array(), 'weight' => 0);
             $this->data['items_total'] += $price;
         }
     }
     if ($this->data['discount_amount_cart'] > 0) {
         $price = -1 * $that->currency->format($this->data['discount_amount_cart'], $order_info['currency'], $order_info['value'], FALSE);
         $this->data['products'][] = array('name' => $that->language->get('text_discount'), 'model' => '', 'price' => $price, 'quantity' => 1, 'option' => array(), 'weight' => 0);
         $this->data['items_total'] += $price;
     }
     return $this->data['products'];
 }
Esempio n. 30
0
 /**
  * Beta! 
  * Preload JavaScript and return an output.
  * @param string/array $js_file file(s) with relative name
  * @param string $group JS group name for caching 
  * @return string
  */
 public function PreloadJS($js_file, $group = 'js')
 {
     if (empty($js_file)) {
         return '';
     }
     //build hash key
     $key = '';
     //get file time stamp
     if (is_array($js_file)) {
         foreach ($js_file as $js) {
             //get file time stamp
             $key .= $js . "-" . filemtime($this->templateResource($js, 'file'));
         }
     } else {
         $key .= $js_file . "-" . filemtime($this->templateResource($js_file, 'file'));
     }
     $key = $group . "." . AEncryption::getHash($group . '-' . $key);
     //check if hash is created and load
     $js_data = $this->cache->pull($key);
     if ($js_data === false) {
         //load js and save to cache
         //TODO: Add stable minify method. minify_js in html-css-js-minifier.php is not stable
         $js_data = '';
         if (is_array($js_file)) {
             foreach ($js_file as $file) {
                 $js_data .= file_get_contents($this->templateResource($file, 'file')) . "\n";
             }
         } else {
             $js_data .= file_get_contents($this->templateResource($js_file, 'file'));
         }
         //$js_data = minify_js($js_data);
         $this->cache->push($key, $js_data);
     }
     return $js_data;
 }