BAB IV HASIL DAN PEMBAHASAN
4.6 Hasil Pengujian
Berdasarkan rencana pengujian yang telah dibuat , maka hasil pengujian perangkat lunak dari sistem web E-market akan dijelaskan pada bagian ini.
1. Hasil Pengujian Aplikasi Sistem Web E-Market
Hasil Pengujian Aplikasi Sistem Web E-Market adalah sebagai berikut:
a. Form Registrasi.
Tabel 4.3 Hasil Pengujian Form Registrasi Hasil Uji
Kelas Uji
Hasil Yang Diharapkan
Hasil Pengujian Kesimpulan
Form Registrasi
Jika pengisian data lengkap dan
sesuai , maka sistem menympan
data akan masuk ke halaman akun
customer. tidak sesuai dan
kurang lengkap
maka akan tampil pesan sesuai data
yang kurang lengkap/tidak
valid.
sesuai data yang kosong/salah.
b. Form Login
Tabel 4.4 Hasil Pengujian Form Login Hasil Uji
Kelas Uji
Hasil Yang Diharapkan
Hasil Pengujian Kesimpulan
Form Login
Jika email dan password benar, maka akan masuk
ke halaman akun customer.
Masuk ke halaman akun customer jika
email dan password benar.
[ x ]Berhasil [ ]Gagal
Jika email dan password salah, maka akan tampil
pesan “email dan
Tampil Pesan
140
password tidak terdaftar”.
input email dan password salah.
c. Form Halaman Utama
Tabel 4.5 Hasil Pengujian Form Halaman Utama Hasil Uji
Kelas Uji
Hasil Yang Diharapkan
Hasil Pengujian Kesimpulan
Form Halaman Utama
Jika customer menekan tombol
“Ambil Produk”, maka akan masuk
ke Keranjang Belanja
Produk masuk ke Keranjang
Jika customer menekan tombol “
Keranjang
“Kategori” , maka akan muncul list kategori produk.
142
“cari” maka akan tampil halaman pencarian produk.
d. Form Keranjang Belanja
Tabel 4.6 Hasil Pengujian Form Keranjang Belanja.
Hasil Uji
Kelas Uji
Hasil Yang Diharapkan
Hasil Pengujian Kesimpulan
Form Keranjang menekan tombol “
Konfirmasi Pesanan” , maka
Tampil Halaman
Pesanan Berhasil [ x ]Berhasil [ ]Gagal
akan tampil halaman Pesanan
Berhasil
e. Form Akun Customer.
Tabel 4.7 Hasil Pengujian Form Akun Customer.
Hasil Uji
Kelas Uji
Hasil Yang Diharapkan
Hasil Pengujian Kesimpulan
Form Akun Customer
Jika customer menekan tombol “
Ubah Profil “
,maka akan tampil halaman informasi alamat
Tampil Halaman Informasi Alamat
[ x ]Berhasil [ ]Gagal
144
,maka akan tampil list riwayat
2. Hasil Pengujian Aplikasi sistem web Admin.
Hasil Pengujian Aplikasi sistem web admin adalah sebagai berikut:
a. Form Login
Tabel 4.8 Hasil Pengujian Form Login.
Hasil Uji
Kelas Uji
Hasil Yang Diharapkan
Hasil Pengujian Kesimpulan
Form Login
Jika username dan password benar, maka akan masuk
ke halaman password benar.
[ x ]Berhasil [ ]Gagal
Jika username dan password salah, maka akan tampil
pesan “username
146
b. Form Menu Produk
Tabel 4.9 Hasil Pengujian Form Menu Produk.
Hasil Uji
Kelas Uji
Hasil Yang Diharapkan
Hasil Pengujian Kesimpulan
Form Menu Produk
Dapat melakukan proses menambah data produk baru
Dapat melakukan proses menambah data produk baru
[ x ]Berhasil
c. Form Menu Customer.
Tabel 4.10 Hasil Pengujian Form Menu Customer.
Hasil Uji
Kelas Uji
Hasil Yang Diharapkan
Hasil Pengujian Kesimpulan
Form Menu
148
d. Form Menu Transaksi/Order.
Tabel 4.11 Hasil Pengujian Form Menu Transaksi/Order.
Hasil Uji
Kelas Uji
Hasil Yang Diharapkan
Hasil Pengujian Kesimpulan
Form Menu Transaksi
Dapat melakukan proses menambah data pesanan baru
Dapat melakukan proses menambah data pesanan baru
[ x ]Berhasil
Dapat menyajikan laporan catatan
Dapat menyajikan laporan catatan
[ x ]Berhasil [ ]Gagal
pengiriman
150
e. Form Menu Laporan
Tabel 4.12 Hasil Pengujian Form Menu Laporan.
Hasil Uji
Kelas Uji
Hasil Yang Diharapkan
Hasil Pengujian Kesimpulan
Form Menu
151 5.1 Kesimpulan
Dari hasil penelitian yang dilakukan penulis mulai dari awal hingga proses pengujian dapat disimpulkan bahwa aplikasi sistem E-Market berbasis web dengan menggunakan metode Extreme Programming ini mampu memberikan solusi terhadap permasalahan yang dihadapi CV. Sion Jaya dalam memasarkan produk anak-anak yang dijual. Selain itu dapat menekan biaya produksi brosur dan meningkatkan minat pelanggan melalui tampilan yang ada pada sistem E-Market . Diharapkan melalui aplikasi sistem E-Market ini dapat meningkatkan keuntungan perusahaan dimasa yang akan datang.
5.2 Saran
Berdasarkan hasil penelitian yang telah dilakukan, maka ada beberapa hal yang penulis perlu sarankan yaitu:
1. Sistem e-market ini dapat menjadi referensi bagi toko-toko yang belum memliki sistem berbasis web atau toko online.
2. Untuk perancangan sistem ini selain CMS(Content Management System) opencart bisa juga menggunakan CMS lainnya.
3. Sistem ini bisa dikembangkan lagi dengan merubah tema web toko dan menambah fitur-fitur lainnya.
152
DAFTAR PUSTAKA
A.S., Rosa, M.Shalahuddin . 2014. Rekayasa Perangkat Lunak Terstruktur dan Berorientasi Objek. Bandung: Informatika.
Al Fatta, Hanif. 2007. Analisis dan Perancangan Sistem Informasi untuk Keunggulan Bersaing Perusahaan dan Organisasi Modern.Yogyakarta: Andi.
Chen-Ling F., & Lie T.2006. Assessment of internet marketing and competitive strategies for leisure farming industry in Taiwan. Jurnal of American Academy of Business, vol 8,No.2,p296.
Ependi, Usman. 2012. Pengembangan E-Trace Alumni Dengan Menggunakan Pendekatan Metode Agile.Seminar Nasional Informatika 2012.
Gunardi, I Made , Lirva32. 2007. Joomla website magic : dengan joomla membuat website semudah memasak mie instan. Jakarta: JasaKom
Kottler , Amstrong. 2004. Prinsip-prinsip Pemasaran. Alih Bahasa oleh Wisnu Chandra Kristiaji. Jilid 2.Edisi Kedelapan .Jakarta: Erlangga.
Mulhim, Imam. 2013. Aplikasi Toko Bangunan Online dengan PHP & MySql.
Palembang: Maxikom.
Mulyanto, Agus.2009. Sistem Informasi Konsep dan Aplikasi. Pustaka Pelajar.
Yogyakarta
Oktavian, Diar Puji.2013 .Menjadi Programmer Jempolan Menggunakan PHP.Yogyakarta: Penerbit MediaKom.
Romney, Paul John Steinbart . 2015. Accounting Information Systems, 13 th ed.
England: Pearson Educational Limited.
Sadeli, Muhammad.2014 . Aplikasi Bisnis dengan PHP dan MySQL. Palembang:
MaxiKom.
Shore, James, Shane Warden. 2008. The Art Of Agile Development. Sebastopol,CA:
O'Reilly Media.
Susanto, Azhar .2013 . Sistem Informasi Akuntansi . Bandung: Lingga Jaya.
Sutabri, Tata. 2012. Analisis Sistem Informasi. Yogyakarta: Andi Utomo, Sutarman . 2012 .Pengantar Teknologi Informasi.Jakarta: Bumi Aksara
Widodo. 2008. Extreme Programming: Pengembangan Perangkat Lunak Semi Formal. Konferensi dan Temu Nasional Teknologi Informasi dan Komunikasi untuk Indonesia. Jakarta: e-Indonesia Initiative 2008.
154 LAMPIRAN
1. Account.php
<?php
class ControllerAccountAccount extends Controller { public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect']=$this->url>link('account/account','', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/account');
$this->document->setTitle($this->language->get('heading_title'));
$data['text_wishlist'] = $this->language->get('text_wishlist');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home') );
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'), 'href' => $this->url->link('account/account', '', true) );
if (isset($this->session->data['success'])) {
$data['success'] = $this->session->data['success'];
unset($this->session->data['success']);
} else {
$data['success'] = '';
}
$data['edit'] = $this->url->link('account/edit', '', true);
$data['password'] = $this->url->link('account/password', '', true);
$data['address'] = $this->url->link('account/address', '', true);
$data['credit_cards'] = array(); $files=glob(DIR_APPLICATION.'controller/extension/credit_card/*.php');
foreach ($files as $file) {
$code = basename($file, '.php');
if ($this->config->get('payment_' . $code . '_status') && $this->config->get('payment_' . $code . '_card')) {
$this->load->language('extension/credit_card/' . $code, 'extension');
$data['credit_cards'][] = array(
'name' => $this->language->get('extension')->get('heading_title'), 'href' => $this->url->link('extension/credit_card/' . $code, '', true)
);
} }
$data['wishlist'] = $this->url->link('account/wishlist');
$data['order'] = $this->url->link('account/order', '', true);
$data['download'] = $this->url->link('account/download', '', true);
if ($this->config->get('total_reward_status')) {
$data['reward'] = $this->url->link('account/reward', '', true);
} else {
$data['reward'] = '';
}
$data['return'] = $this->url->link('account/return', '', true);
$data['transaction'] = $this->url->link('account/transaction', '', true);
$data['newsletter'] = $this->url->link('account/newsletter', '', true);
$data['recurring'] = $this->url->link('account/recurring', '', true);
$this->load->model('account/customer');
$affiliate_info = $this->model_account_customer->getAffiliate($this->customer->getId());
if (!$affiliate_info) {
$data['affiliate'] = $this->url->link('account/affiliate/add', '', true);
} else {
$data['affiliate'] = $this->url->link('account/affiliate/edit', '', true);
}
if ($affiliate_info) {
$data['tracking'] = $this->url->link('account/tracking', '', true);
} else {
$data['tracking'] = '';
}
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right']=$this->load->controller('common/column_right');
156
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom']=$this>load>controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load>view('account/account', $data));
}
public function country() {
$json = array();
$this->load->model('localisation/country');
$country_info=$this->model_localisation_country->getCountry($this->request->get['country_id']);
if ($country_info) {
$this->load->model('localisation/zone');
$json = array(
'country_id' => $country_info['country_id'], 'name' => $country_info['name'],
'iso_code_2' => $country_info['iso_code_2'], 'iso_code_3' => $country_info['iso_code_3'], 'address_format' =>$country_info['address_format'], 'postcode_required' =>$country_info['postcode_required'],
'zone'=>$this->model_localisation_zone>getZonesByCountryId($this->request-
>get['country_id']),
'status' => $country_info['status']
);
class ControllerAccountAddress extends Controller { private $error = array();
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/address', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
public function add() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/address', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
$this->model_account_address->addAddress($this->customer->getId(), $this->request->post);
$this->session->data['success'] = $this->language->get('text_add');
$this->response->redirect($this->url->link('account/address', '', true));
}
$this->getForm();
}
public function edit() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/address', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/address');
$this->document->setTitle($this->language->get('heading_title'));
158
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
$this->model_account_address->editAddress($this->request->get['address_id'], $this->request->post);
// Default Shipping Address
if (isset(>session->data['shipping_address']['address_id']) && (>request->get['address_id'] ==
$this->session>data['shipping_address']['address_id'])) {
$this->session->data['shipping_address']=$this->model_account_address->getAddress($this->request->get['address_id']);
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
}
// Default Payment Address
if (isset(>session->data['payment_address']['address_id']) && (>request->get['address_id'] ==
$this->session>data['payment_address']['address_id'])) {
$this->session->data['payment_address']=$this->model_account_address->getAddress($this->request->get['address_id']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
}
$this->session->data['success'] = $this->language->get('text_edit');
$this->response->redirect($this->url->link('account/address', '', true));
}
$this->getForm();
}
public function delete() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/address', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/address');
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('account/address');
if (isset($this->request->get['address_id']) && $this->validateDelete()) {
$this->model_account_address->deleteAddress($this->request >get['address_id']);
// Default Shipping Address
if (isset(>session->data['shipping_address']['address_id']) && ($this >request->get['address_id'] ==
$this->session>data['shipping_address']['address_id'])) { unset($this->session->data['shipping_address']);
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
}
// Default Payment Address
if (isset(>session->data['payment_address']['address_id']) && (>request->get['address_id'] ==
$this->session>data['payment_address']['address_id'])) { unset($this->session->data['payment_address']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
}
$this->session->data['success'] = $this->language->get('text_delete');
$this->response->redirect($this->url->link('account/address', '', true));
}
$this->getList();
}
protected function getList() {
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home') );
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'), 'href' => $this->url->link('account/account', '', true) );
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'), 'href' => $this->url->link('account/address', '', true) );
if (isset($this->error['warning'])) {
160
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->session->data['success'])) {
$data['success'] = $this->session->data['success'];
unset($this->session->data['success']);
} else {
$data['success'] = '';
}
$data['addresses'] = array();
$results = $this->model_account_address->getAddresses();
foreach ($results as $result) { if ($result['address_format']) {
$format = $result['address_format'];
} else {
$replace = array(
'firstname' => $result['firstname'], 'lastname' => $result['lastname'], 'company' => $result['company'],
'address_1' => $result['address_1'], 'address_2' => $result['address_2'], 'city' => $result['city'], 'postcode' => $result['postcode'], 'zone' => $result['zone'], 'zone_code' => $result['zone_code'], 'country' => $result['country']
);
$data['addresses'][] = array(
'address_id' => $result['address_id'],
'address'=>str_replace(array("\r\n","\r","\n"),'<br/>',preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"),'<br />', trim(str_replace($find, $replace, $format)))),
'update'=>$this->url->link('account/address/edit','address_id='.$result ['address_id'], true), 'delete'=>$this->url->link('account/address/delete','address_id=' . $result ['address_id'], true) );
}
$data['add'] = $this->url->link('account/address/add', '', true);
$data['back'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/address_list', $data));
}
protected function getForm() {
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home') );
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'), 'href' => $this->url->link('account/account', '', true)
162
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'), 'href' => $this->url->link('account/address', '', true) );
if (!isset($this->request->get['address_id'])) {
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_address_add'), 'href' => $this->url->link('account/address/add', '', true) );
} else {
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_address_edit'),
'href' => $this->url->link('account/address/edit', 'address_id=' . $this->request->get['address_id'], true) );
}
$data['text_address']=!isset($this->request->get['address_id'])?$this->language->get('text_address_add'):
$this->language->get('text_address_edit');
if (isset($this->error['firstname'])) {
$data['error_firstname'] = $this->error['firstname'];
} else {
$data['error_firstname'] = '';
}
if (isset($this->error['lastname'])) {
$data['error_lastname'] = $this->error['lastname'];
} else {
$data['error_lastname'] = '';
}
if (isset($this->error['address_1'])) {
$data['error_address_1'] = $this->error['address_1'];
} else {
$data['error_address_1'] = '';
}
if (isset($this->error['city'])) {
$data['error_city'] = $this->error['city'];
} else {
$data['error_city'] = '';
}
if (isset($this->error['postcode'])) {
$data['error_postcode'] = $this->error['postcode'];
} else {
$data['error_postcode'] = '';
}
if (isset($this->error['country'])) {
$data['error_country'] = $this->error['country'];
} else {
$data['error_country'] = '';
}
if (isset($this->error['zone'])) {
$data['error_zone'] = $this->error['zone'];
} else {
$data['error_zone'] = '';
}
if (isset($this->error['custom_field'])) {
$data['error_custom_field'] = $this->error['custom_field'];
} else {
$data['error_custom_field'] = array();
}
if (!isset($this->request->get['address_id'])) {
$data['action'] = $this->url->link('account/address/add', '', true);
} else {
$data['action'] = $this->url->link('account/address/edit', 'address_id=' . $this->request->get['address_id'], true);
}
if(isset($this->request->get['address_id'])&&($this->request >server ['REQUEST_METHOD'] != 'POST')) {
$address_info=$this->model_account_address->getAddress($this- >request->get['address_id']);
}
if (isset($this->request->post['firstname'])) {
$data['firstname'] = $this->request->post['firstname'];
164
} elseif (!empty($address_info)) {
$data['firstname'] = $address_info['firstname'];
} else {
$data['firstname'] = '';
}
if (isset($this->request->post['lastname'])) {
$data['lastname'] = $this->request->post['lastname'];
} elseif (!empty($address_info)) {
$data['lastname'] = $address_info['lastname'];
} else {
$data['lastname'] = '';
}
if (isset($this->request->post['company'])) {
$data['company'] = $this->request->post['company'];
} elseif (!empty($address_info)) {
$data['company'] = $address_info['company'];
} else {
$data['company'] = '';
}
if (isset($this->request->post['address_1'])) {
$data['address_1'] = $this->request->post['address_1'];
} elseif (!empty($address_info)) {
$data['address_1'] = $address_info['address_1'];
} else {
$data['address_1'] = '';
}
if (isset($this->request->post['address_2'])) {
$data['address_2'] = $this->request->post['address_2'];
} elseif (!empty($address_info)) {
$data['address_2'] = $address_info['address_2'];
} else {
$data['address_2'] = '';
}
if (isset($this->request->post['postcode'])) {
$data['postcode'] = $this->request->post['postcode'];
} elseif (!empty($address_info)) {
$data['postcode'] = $address_info['postcode'];
} else {
$data['postcode'] = '';
}
if (isset($this->request->post['city'])) {
$data['city'] = $this->request->post['city'];
} elseif (!empty($address_info)) {
$data['city'] = $address_info['city'];
} else {
$data['city'] = '';
}
if (isset($this->request->post['country_id'])) {
$data['country_id'] = (int)$this->request->post['country_id'];
} elseif (!empty($address_info)) {
$data['country_id'] = $address_info['country_id'];
} else {
$data['country_id'] = $this->config->get('config_country_id');
}
if (isset($this->request->post['zone_id'])) {
$data['zone_id'] = (int)$this->request->post['zone_id'];
} elseif (!empty($address_info)) {
$data['zone_id'] = $address_info['zone_id'];
} else {
$data['zone_id'] = '';
}
$this->load->model('localisation/country');
$data['countries']=$this->model_localisation_country->getCountries();
// Custom fields
$data['custom_fields'] = array();
$this->load->model('account/custom_field');
$custom_fields=$this->model_account_custom_field
>getCustomFields($this->config->get('config_customer_group_id'));
166
foreach ($custom_fields as $custom_field) { if ($custom_field['location'] == 'address') {
$data['custom_fields'][] = $custom_field;
} }
if (isset($this->request->post['custom_field']['address'])) {
$data['address_custom_field']=$this->request->post ['custom_field']['address'];
} elseif (isset($address_info)) {
$data['address_custom_field'] = $address_info['custom_field'];
} else {
$data['address_custom_field'] = array();
}
if (isset($this->request->post['default'])) {
$data['default'] = $this->request->post['default'];
} elseif (isset($this->request->get['address_id'])) {
$data['default'] = $this->customer->getAddressId() == $this->request- >get['address_id'];
} else {
$data['default'] = false;
}
$data['back'] = $this->url->link('account/address', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/address_form', $data));
}
protected function validateForm() {
if((utf8_strlen(trim($this->request->post['firstname']))<1)||(utf8_strlen(trim ($this->request->post['firstname'])) > 32)) {
$this->error['firstname'] = $this->language->get('error_firstname');
}
if((utf8_strlen(trim($this->request->post['lastname']))<1)||(utf8_strlen(trim ($this->request->post['lastname'])) > 32)) {
$this->error['lastname'] = $this->language->get('error_lastname');
}
if((utf8_strlen(trim($this->request->post['address_1'])) < 3) || (utf8_strlen(trim ($this->request->post['address_1'])) >
128)) {
$this->error['address_1'] = $this->language->get('error_address_1');
}
if ((utf8_strlen(trim($this->request->post['city'])) < 2) || (utf8_strlen(trim($this->request->post['city'])) > 128)) {
$this->error['city'] = $this->language->get('error_city');
}
$this->load->model('localisation/country');
$country_info=$this->model_localisation_country->getCountry($this->request->post['country_id']);
if($country_info&&$country_info['postcode_required']&&(utf8_strlen(trim($this->request->post['postcode']))
<2||utf8_strlen(trim($this->request>post ['postcode'])) > 10)) {
$this->error['postcode'] = $this->language->get('error_postcode');
}
if ($this->request->post['country_id'] == '' || !is_numeric($this->request->post['country_id'])) {
$this->error['country'] = $this->language->get('error_country');
}
if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '' ||
!is_numeric($this->request->post['zone_id'])) {
$this->error['zone'] = $this->language->get('error_zone');
}
// Custom field validation
$this->load->model('account/custom_field');
$custom_fields=$this->model_account_custom_field->getCustomFields
($this->config->get('config_customer_group_id'));
foreach ($custom_fields as $custom_field) { if ($custom_field['location'] == 'address') {
if($custom_field['required']&&empty($this->request->post['custom_field']
[$custom_field['location']][$custom_field['custom_field_id']])) {
$this->error['custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'),
$custom_field['name']);
}elseif(($custom_field['type']=='text') && !empty($custom_field['validation']) &&!filter_var($this->request
>post['custom_field'][$custom_field['location']] [$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) {
$this->error['custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'),
$custom_field['name']);
168
protected function validateDelete() {
if ($this->model_account_address->getTotalAddresses() == 1) {
$this->error['warning'] = $this->language->get('error_delete');
}
if ($this->customer->getAddressId() == $this->request->get['address_id']) {
$this->error['warning'] = $this->language->get('error_default');
}
class ControllerAccountEdit extends Controller { private $error = array();
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/edit', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_account_customer->editCustomer($this->customer->getId(), $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('account/account', '', true));
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home') );
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'), 'href' => $this->url->link('account/account', '', true) );
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_edit'), 'href' => $this->url->link('account/edit', '', true) );
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->error['firstname'])) {
$data['error_firstname'] = $this->error['firstname'];
} else {
$data['error_firstname'] = '';
}
if (isset($this->error['lastname'])) {
$data['error_lastname'] = $this->error['lastname'];
} else {
$data['error_lastname'] = '';
}
if (isset($this->error['email'])) {
$data['error_email'] = $this->error['email'];
170
} else {
$data['error_email'] = '';
}
if (isset($this->error['telephone'])) {
$data['error_telephone'] = $this->error['telephone'];
} else {
$data['error_telephone'] = '';
}
if (isset($this->error['custom_field'])) {
$data['error_custom_field'] = $this->error['custom_field'];
} else {
$data['error_custom_field'] = array();
}
$data['action'] = $this->url->link('account/edit', '', true);
if ($this->request->server['REQUEST_METHOD'] != 'POST') {
$customer_info=$this->model_account_customer->getCustomer($this->customer->getId());
}
if (isset($this->request->post['firstname'])) {
$data['firstname'] = $this->request->post['firstname'];
} elseif (!empty($customer_info)) {
$data['firstname'] = $customer_info['firstname'];
} else {
$data['firstname'] = '';
}
if (isset($this->request->post['lastname'])) {
$data['lastname'] = $this->request->post['lastname'];
} elseif (!empty($customer_info)) {
$data['lastname'] = $customer_info['lastname'];
} else {
$data['lastname'] = '';
}
if (isset($this->request->post['email'])) {
$data['email'] = $this->request->post['email'];
} elseif (!empty($customer_info)) {
$data['email'] = $customer_info['email'];
} else {
$data['email'] = '';
}
if (isset($this->request->post['telephone'])) {
$data['telephone'] = $this->request->post['telephone'];
} elseif (!empty($customer_info)) {
$data['telephone'] = $customer_info['telephone'];
} else {
$data['telephone'] = '';
}
// Custom Fields
$data['custom_fields'] = array();
$this->load->model('account/custom_field');
$custom_fields=$this->model_account_custom_field->getCustomFields($this->config->get('config_customer _group_id'));
foreach ($custom_fields as $custom_field) { if ($custom_field['location'] == 'account') {
$data['custom_fields'][] = $custom_field;
} }
if (isset($this->request->post['custom_field']['account'])) {
$data['account_custom_field']=$this->request->post['custom_field'] ['account'];
} elseif (isset($customer_info)) {
$data['account_custom_field'] = json_decode($customer_info['custom_field'], true);
} else {
$data['account_custom_field'] = array();
}
$data['back'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
172
$this->response->setOutput($this->load->view('account/edit', $data));
}
protected function validate() {
if ((utf8_strlen(trim($this->request->post['firstname'])) < 1) || (utf8_strlen(trim ($this->request->post['firstname'])) >
32)) {
$this->error['firstname'] = $this->language->get('error_firstname');
}
if ((utf8_strlen(trim($this->request->post['lastname'])) < 1) || (utf8_strlen(trim ($this->request->post['lastname'])) >
32)) {
$this->error['lastname'] = $this->language->get('error_lastname');
}
if ((utf8_strlen($this->request->post['email']) > 96) || !filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) {
$this->error['email'] = $this->language->get('error_email');
}
if (($this->customer->getEmail() != $this->request->post['email']) &&
$this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
$this->error['warning'] = $this->language->get('error_exists');
}
if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
$this->error['telephone'] = $this->language->get('error_telephone');
}
// Custom field validation
$this->load->model('account/custom_field');
$custom_fields=$this->model_account_custom_field->getCustomFields('account',$this->config->get('config_customer_group _id'));
foreach ($custom_fields as $custom_field) { if ($custom_field['location'] == 'account') {
if($custom_field['required']&&empty($this->request->post['custom_field'][$custom_field['location']
][$custom_field['custom_field_id']])) {
$this->error['custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'),
$custom_field['name']);
}elseif(($custom_field['type'] == 'text') && !empty($custom_field['validation']
&&!filter_var($this->request>post['custom_field'][$custom_field['location']] [$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) {
$this->error['custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'),
$custom_field['name']);
} }
}
class ControllerAccountLogin extends Controller { private $error = array();
public function index() {
$this->load->language('account/login');
// Analytics
$this->load->model('setting/extension');
$data['analytics'] = array();
$analytics = $this->model_setting_extension->getExtensions('analytics');
foreach ($analytics as $analytic) {
if ($this->config->get('analytics_' . $analytic['code'] . '_status')) {
$data['analytics'][] = $this->load->controller('extension/analytics/' . $analytic['code'],
$this->config->get('analytics_' . $analytic['code'] . '_status'));
} }
if ($this->request->server['HTTPS']) {
$server = $this->config->get('config_ssl');
} else {
$server = $this->config->get('config_url');
}
if (is_file(DIR_IMAGE . $this->config->get('config_icon'))) {
$this->document->addLink($server'image/'.$this->config->get ('config_icon'), 'icon');
}
$data['title'] = $this->language->get('heading_title');
$data['text_register'] = $this->language->get('text_register');
$data['base'] = $server;
$data['description'] = $this->document->getDescription();
$data['keywords'] = $this->document->getKeywords();
$data['links'] = $this->document->getLinks();
174
$data['styles'] = $this->document->getStyles();
$data['scripts'] = $this->document->getScripts('header');
$data['lang'] = $this->language->get('code');
$data['direction'] = $this->language->get('direction');
$data['name'] = $this->config->get('config_name');
if (is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
$data['logo'] = $server . 'image/' . $this->config->get('config_logo');
} else {
$data['logo'] = '';
}
$this->load->model('account/customer');
// Login override for admin users if (!empty($this->request->get['token'])) {
$this->customer->logout();
if($customer_info&&$this->customer->login($customer_info ['email'], '', true)) { // Default Addresses
$this->load->model('account/address');
if ($this->config->get('config_tax_customer') == 'payment') {
$this->session->data['payment_address']=$this->model_account
_address->getAddress($this->customer->getAddressId());
}
if ($this->config->get('config_tax_customer') == 'shipping') {
$this->session->data['shipping_address']=$this->model_account_
address->getAddress($this->customer->getAddressId());
}
$this->response->redirect($this->url->link('account/account', '', true));
} }
if ($this->customer->isLogged()) {
$this->response->redirect($this->url->link('account/account', '', true));
}
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { // Unset guest
unset($this->session->data['guest']);
// Default Shipping Address
$this->load->model('account/address');
if ($this->config->get('config_tax_customer') == 'payment') {
$this->session->data['payment_address']=$this->model_account_address->getAddress($this->customer->getAddressId());
}
if ($this->config->get('config_tax_customer') == 'shipping') {
$this->session->data['shipping_address']=$this->model_account
_address->getAddress($this->customer->getAddressId());
} // Wishlist
if(isset($this->session->data['wishlist'])&&is_array($this->session->data ['wishlist'])) {
$this->load->model('account/wishlist');
foreach ($this->session->data['wishlist'] as $key => $product_id) {
$this->model_account_wishlist->addWishlist($product_id);
unset($this->session->data['wishlist'][$key]);
} }
if (isset($this->request->post['redirect']) && $this->request->post['redirect'] != $this->url->link('account/logout', '', true) && (>post['redirect'], $this->config->get('config_url')) !== false ||
strpos($this->request->post['redirect'], $this->config->get('config_ssl')) !== false)) {
$this->response->redirect(str_replace('&','&',$this->request->post ['redirect']));
} else {
$this->response->redirect($this->url->link('account/account', '', true));
176
} }
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home') );
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'), 'href' => $this->url->link('account/account', '', true) );
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_login'), 'href' => $this->url->link('account/login', '', true) );
if (isset($this->session->data['error'])) {
$data['error_warning'] = $this->session->data['error'];
unset($this->session->data['error']);
} elseif (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
$data['action'] = $this->url->link('account/login', '', true);
$data['register'] = $this->url->link('account/register', '', true);
$data['forgotten'] = $this->url->link('account/forgotten', '', true);
// Added strpos check to pass McAfee PCI compliance test
(http://forum.opencart.com/viewtopic.php?f=10&t=12043&p=151494#p151295)
if (isset($this->request->post['redirect']) && (strpos($this->request->post['redirect'],
$this->config->get('config_url')) !== false || strpos($this->request->post['redirect'], $this->config->get('config_ssl')) !== false)) {
$data['redirect'] = $this->request->post['redirect'];
} elseif (isset($this->session->data['redirect'])) {
$data['redirect'] = $this->session->data['redirect'];
unset($this->session->data['redirect']);
} else {
$data['redirect'] = '';
}
if (isset($this->session->data['success'])) {
$data['success'] = $this->session->data['success'];
unset($this->session->data['success']);
} else {
$data['success'] = '';
}
if (isset($this->request->post['email'])) {
$data['email'] = $this->request->post['email'];
} else {
$data['email'] = '';
}
if (isset($this->request->post['password'])) {
$data['password'] = $this->request->post['password'];
} else {
$data['password'] = '';
}
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/login', $data));
}
protected function validate() {
// Check how many login attempts have been made.
$login_info = $this->model_account_customer->getLoginAttempts($this->request->post['email']);
if($login_info&&($login_info['total']>=$this->config->get('config_login_attempts'))&&strtotime('-1hour')<strtotime ($login_info ['date_modified'])) {
$this->error['warning'] = $this->language->get('error_attempts');
}
// Check if customer has been approved.
$customer_info=$this->model_account_customer->getCustomerByEmail ($this->request->post['email']);
178
if ($customer_info && !$customer_info['status']) {
$this->error['warning'] = $this->language->get('error_approved');
}
if (!$this->error) {
if(!$this->customer->login($this->request->post['email'],$this->request->post ['password'])) {
$this->error['warning'] = $this->language->get('error_login');
$this->model_account_customer->addLoginAttempt($this->request->post['email']); } else {
$this->model_account_customer->deleteLoginAttempts($this->request->post['email']);
class ControllerAccountRegister extends Controller { private $error = array();
public function index() {
$this->load->language('account/register');
$data['analytics'] = array();
$analytics = $this->model_setting_extension->getExtensions('analytics');
foreach ($analytics as $analytic) {
if ($this->config->get('analytics_' . $analytic['code'] . '_status')) {
$data['analytics'][] = $this->load->controller('extension/analytics/' . $analytic['code'],
$this->config->get('analytics_' . $analytic['code'] . '_status'));
} }
if ($this->request->server['HTTPS']) {
$server = $this->config->get('config_ssl');
} else {
$server = $this->config->get('config_url');
}
if (is_file(DIR_IMAGE . $this->config->get('config_icon'))) {
$this->document->addLink($server . 'image/' . $this->config->get('config_icon'), 'icon');
}
$data['title'] = $this->language->get('heading_title');
$data['base'] = $server;
$data['description'] = $this->document->getDescription();
$data['keywords'] = $this->document->getKeywords();
$data['links'] = $this->document->getLinks();
$data['styles'] = $this->document->getStyles();
$data['scripts'] = $this->document->getScripts('header');
$data['lang'] = $this->language->get('code');
$data['direction'] = $this->language->get('direction');
$data['name'] = $this->config->get('config_name');
if (is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
$data['logo'] = $server . 'image/' . $this->config->get('config_logo');
} else {
$data['logo'] = '';
}
if ($this->customer->isLogged()) {
$this->response->redirect($this->url->link('account/account', '', true));
}
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$customer_id=$this->model_account_customer->addCustomer($this->request->post);
// Clear any previous login attempts for unregistered accounts.
$this->model_account_customer->deleteLoginAttempts($this->request->post['email']);
$this->customer->login($this->request->post['email'],$this->request->post ['password']);
unset($this->session->data['guest']);
$this->response->redirect($this->url->link('account/success'));
}
$data['breadcrumbs'] = array();
180
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home') );
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'), 'href' => $this->url->link('account/account', '', true) );
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_register'), 'href' => $this->url->link('account/register', '', true) );
$data['text_account_already']=sprintf($this->language->get ('text_account_already'), $this->url->link('account/login', '', true));
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->error['firstname'])) {
$data['error_firstname'] = $this->error['firstname'];
} else {
$data['error_firstname'] = '';
}
if (isset($this->error['lastname'])) {
$data['error_lastname'] = $this->error['lastname'];
} else {
$data['error_lastname'] = '';
}
if (isset($this->error['email'])) {
$data['error_email'] = $this->error['email'];
} else {
$data['error_email'] = '';
}
if (isset($this->error['telephone'])) {
$data['error_telephone'] = $this->error['telephone'];
} else {
$data['error_telephone'] = '';
}
if (isset($this->error['custom_field'])) {
$data['error_custom_field'] = $this->error['custom_field'];
} else {
$data['error_custom_field'] = array();
}
if (isset($this->error['password'])) {
$data['error_password'] = $this->error['password'];
} else {
$data['error_password'] = '';
}
if (isset($this->error['confirm'])) {
$data['error_confirm'] = $this->error['confirm'];
} else {
$data['error_confirm'] = '';
}
$data['action'] = $this->url->link('account/register', '', true);
$data['customer_groups'] = array();
if (is_array($this->config->get('config_customer_group_display'))) {
$this->load->model('account/customer_group');
$customer_groups=$this->model_account_customer_group->getCustomer Groups();
foreach ($customer_groups as $customer_group) {
if (in_array($customer_group['customer_group_id'],
$this->config->get('config_customer_group_display'))) {
$data['customer_groups'][] = $customer_group;
} }
}
if (isset($this->request->post['customer_group_id'])) {
$data['customer_group_id'] = $this->request->post['customer_group_id'];
} else {
$data['customer_group_id']= $this->config->get('config_customer_group_id');