Sistem Penjualan Ponsel Berbasis Ecommerce

(1)

KEMENTERIAN PENDIDIKAN DAN KEBUDAYAAN UNIVERSITAS SUMATERA UTARA

FAKULTAS MATEMATIKA DAN ILMU PENGETAHUAN ALAM Jln. Bioteknologi No.1 Kampus USU Padang Bulan Medan-20155

Telp. (061) 8211050, 8214290, Fax. (061) 8214290

KARTU BIMBINGAN TUGAS AKHIR MAHASISWA Nama Mahasiswa : VIVI SAUFINA

Nomor Induk Mahasiswa : 102406040

Judul Tugas Akhir : Sistem Penjualan Ponsel Berbasis Ecommerce Dosen Pembimbing : Dr. Saib Suwilo, M.Sc

Tanggal Mulai Bimbingan : Tanggal Selesai Bimbingan :

 Kartu ini harap dikembalikan kejurusan Matematika Bila Bimbingan Mahasiswa telah Selesai.

Diketahui, Disetujui

Ketua Dapartemen Matematika Pembimbing Utama/ Penanggung Jawab

Prof. Dr. Tulus, M.Si Dr. Saib Suwilo, M.Sc 19620901 198803 1 002 19640109 198803 1 004 No

Tanggal Asisten Bimbingan

Pembahasan pada Asistensi Mengenai, pada Bab :

Paraf Dosen

Pembimbing Keterangan 1

2 3 4 5 6


(2)

SURAT KETERANGAN Hasil Uji Program Tugas Akhir

Yang bertanda dibawah ini, menerangkan bahwa Mahasiswa Tugas Akhir Program D3 Teknik Informatika :

Nama : VIVI SAUFINA NIM : 102406040

Prog. Studi : D3 Teknik Informatika

Judul TA : Penjualan Ponsel Berbasis Ecommerce

Telah melaksanakan test program Tugas Akhir Mahasiswa diatas pada tanggal ……….

Dengan Hasil : Sukses / Gagal

Demikianlah diterangkan untuk digunakan melengkapi syarat pendaftaran ujian Meja Hijau Tugas Akhir Mahasiswa bersangkutan di Dapartemen Matematika FMIPA USU Medan.

Medan, Mei 2013 Dosen Pembimbing

Dr. Saib Suwilo, M.Sc 19640109 198803 1 004


(3)

LAMPIRAN : LISTING PROGRAM

Listing Index.php <?php

/*

* 2007-2011 PrestaShop *

* NOTICE OF LICENSE *

* This source file is subject to the Open Software License (OSL 3.0)

* that is bundled with this package in the file LICENSE.txt.

* It is also available through the world-wide-web at this URL:

* http://opensource.org/licenses/osl-3.0.php

* If you did not receive a copy of the license and are unable to

* obtain it through the world-wide-web, please send an email

* to license@prestashop.com so we can send you a copy immediately.

*

* DISCLAIMER *

* Do not edit or add to this file if you wish to upgrade PrestaShop to newer

* versions in the future. If you wish to customize PrestaShop for your

* needs please refer to http://www.prestashop.com for more information.

*

* @author PrestaShop SA <contact@prestashop.com> * @copyright 2007-2011 PrestaShop SA

* @version Release: $Revision: 7233 $

* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)

* International Registered Trademark & Property of PrestaShop SA

*/

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

header("Cache-Control: no-store, no-cache, must-revalidate");


(4)

header("Cache-Control: post-check=0, pre-check=0", false);

header("Pragma: no-cache"); header("Location: ../"); exit;

Listing CategoryController.php <?php

/*

* 2007-2011 PrestaShop *

* NOTICE OF LICENSE *

* This source file is subject to the Open Software License (OSL 3.0)

* that is bundled with this package in the file LICENSE.txt.

* It is also available through the world-wide-web at this URL:

* http://opensource.org/licenses/osl-3.0.php

* If you did not receive a copy of the license and are unable to

* obtain it through the world-wide-web, please send an email

* to license@prestashop.com so we can send you a copy immediately.

*

* DISCLAIMER *

* Do not edit or add to this file if you wish to upgrade PrestaShop to newer

* versions in the future. If you wish to customize PrestaShop for your

* needs please refer to http://www.prestashop.com for more information.

*

* @author PrestaShop SA <contact@prestashop.com> * @copyright 2007-2011 PrestaShop SA

* @version Release: $Revision: 9643 $

* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)

* International Registered Trademark & Property of PrestaShop SA

*/


(5)

{

public $php_self = 'category.php'; protected $category;

public function setMedia() {

parent::setMedia(); Tools::addCSS(array(

_PS_CSS_DIR_.'jquery.cluetip.css' => 'all',

_THEME_CSS_DIR_.'scenes.css' => 'all', _THEME_CSS_DIR_.'category.css' => 'all', _THEME_CSS_DIR_.'product_list.css' => 'all'));

if

(Configuration::get('PS_COMPARATOR_MAX_ITEM') > 0) Tools::addJS(_THEME_JS_DIR_.'products-comparison.js');

}

public function displayHeader() {

parent::displayHeader(); $this->productSort(); }

public function canonicalRedirection() {

// Automatically redirect to the canonical URL if the current in is the right one

// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain

if (Validate::isLoadedObject($this->category) && Configuration::get('PS_CANONICAL_REDIRECT') && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET' && !Tools::getValue('noredirect'))

{

$currentURL = preg_replace('/[?&].*$/', '', self::$link->getCategoryLink($this->category));

if

(!preg_match('/^'.Tools::pRegexp($currentURL, '/').'([&?].*)?$/',

Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQU EST_URI']))

{

header('HTTP/1.0 301 Moved');

if (defined('_PS_MODE_DEV_') AND


(6)

die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$currentURL.'">'.$currentURL.'</a>');

Tools::redirectLink($currentURL); }

} }

public function preProcess() {

if ($id_category =

(int)Tools::getValue('id_category'))

$this->category = new

Category($id_category, self::$cookie->id_lang);

if (!Validate::isLoadedObject($this->category)) {

header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); }

else

$this->canonicalRedirection(); parent::preProcess();

}

public function process() {

parent::process();

if (!($id_category =

(int)Tools::getValue('id_category')) OR

!Validate::isUnsignedId($id_category))

$this->errors[] =

Tools::displayError('Missing category ID'); else

{

if

(!Validate::isLoadedObject($this->category))

$this->errors[] =

Tools::displayError('Category does not exist');

elseif

(!$this->category->checkAccess((int)(self::$cookie->id_customer)))

$this->errors[] =

Tools::displayError('You do not have access to this category.');

elseif (!$this->category->active)

self::$smarty->assign('category', $this->category);

else {


(7)

$rewrited_url = self::$link->getCategoryLink((int)$this->category->id, $this->category->link_rewrite);

/* Scenes (could be externalised to another controler if you need them */

self::$smarty->assign('scenes', Scene::getScenes((int)($this->category->id),

(int)(self::$cookie->id_lang), true, false)); /* Scenes images formats */

if ($sceneImageTypes =

ImageType::getImagesTypes('scenes')) {

foreach ($sceneImageTypes AS

$sceneImageType)

{

if ($sceneImageType['name'] == 'thumb_scene')

$thumbSceneImageType = $sceneImageType;

elseif

($sceneImageType['name'] == 'large_scene')

$largeSceneImageType = $sceneImageType;

}

self::$smarty->assign('thumbSceneImageType',

isset($thumbSceneImageType) ? $thumbSceneImageType : NULL);

self::$smarty->assign('largeSceneImageType',

isset($largeSceneImageType) ? $largeSceneImageType : NULL);

}

$this->category->description = nl2br2($this->category->description);

$subCategories = $this->category->getSubCategories((int)self::$cookie->id_lang);

self::$smarty->assign('category', $this->category);

if (isset($subCategories) AND

!empty($subCategories) AND $subCategories) {

self::$smarty->assign('subcategories', $subCategories);


(8)

'subcategories_nb_total' => sizeof($subCategories),

'subcategories_nb_half' => ceil(sizeof($subCategories) / 2)));

}

if ($this->category->id != 1) $this->productListAssign(); self::$smarty->assign(array(

'products' => (isset($this->cat_products) AND $this->cat_products) ? $this->cat_products : NULL,

'id_category' => (int)($this->category->id),

'id_category_parent' =>

(int)($this->category->id_parent),

'return_category_name' =>

Tools::safeOutput($this->category->name),

'path' =>

Tools::getPath((int)($this->category->id)),

'add_prod_display' =>

Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),

'categorySize' =>

Image::getSize('category'),

'mediumSize' =>

Image::getSize('medium'),

'thumbSceneSize' =>

Image::getSize('thumb_scene'),

'homeSize' =>

Image::getSize('home') ));

if (isset(self::$cookie->id_compare))

self::$smarty->assign('compareProducts',

CompareProduct::getCompareProducts((int)self::$cookie->id_compare));

} }

self::$smarty->assign(array(

'allow_oosp' =>

(int)(Configuration::get('PS_ORDER_OUT_OF_STOCK')),

'comparator_max_item' =>

(int)(Configuration::get('PS_COMPARATOR_MAX_ITEM')), 'suppliers' => Supplier::getSuppliers() ));

}


(9)

{

$hookExecuted = false;

Module::hookExec('productListAssign',

array('nbProducts' => &$this->nbProducts, 'catProducts' => &$this->cat_products, 'hookExecuted' => &$hookExecuted));

if(!$hookExecuted) // The hook was not

executed, standard working {

self::$smarty->assign('categoryNameComplement', '');

$this->nbProducts = >category->getProducts(NULL, NULL, NULL, >orderBy, $this->orderWay, true);

$this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts"

$this->cat_products = $this->category->getProducts((int)(self::$cookie->id_lang), (int)($this->p), (int)($this->n), $this->orderBy, $this->orderWay);

}

else // Hook executed, use the override

$this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts"

self::$smarty->assign('nb_products', (int)$this->nbProducts);

}

public function displayContent() {

parent::displayContent();

self::$smarty->display(_PS_THEME_DIR_.'category.tpl'); }

}

Listing ProductController.php <?php

/*

* 2007-2011 PrestaShop *

* NOTICE OF LICENSE *

* This source file is subject to the Open Software License (OSL 3.0)

* that is bundled with this package in the file LICENSE.txt.


(10)

* It is also available through the world-wide-web at this URL:

* http://opensource.org/licenses/osl-3.0.php

* If you did not receive a copy of the license and are unable to

* obtain it through the world-wide-web, please send an email

* to license@prestashop.com so we can send you a copy immediately.

*

* DISCLAIMER *

* Do not edit or add to this file if you wish to upgrade PrestaShop to newer

* versions in the future. If you wish to customize PrestaShop for your

* needs please refer to http://www.prestashop.com for more information.

*

* @author PrestaShop SA <contact@prestashop.com> * @copyright 2007-2011 PrestaShop SA

* @version Release: $Revision: 10539 $

* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)

* International Registered Trademark & Property of PrestaShop SA

*/

class ProductControllerCore extends FrontController {

protected $product;

public $php_self = 'product.php'; protected $canonicalURL;

public function setMedia() {

parent::setMedia();

Tools::addCSS(_THEME_CSS_DIR_.'product.css'); Tools::addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css', 'screen');

Tools::addJS(array(

_PS_JS_DIR_.'jquery/jquery.fancybox-1.3.4.js',

_PS_JS_DIR_.'jquery/jquery.idTabs.modified.js', _PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js',

_PS_JS_DIR_.'jquery/jquery.serialScroll-1.2.2-min.js',


(11)

_THEME_JS_DIR_.'tools.js', _THEME_JS_DIR_.'product.js'));

if (Configuration::get('PS_DISPLAY_JQZOOM') == 1)

{

Tools::addCSS(_PS_CSS_DIR_.'jqzoom.css', 'screen');

Tools::addJS(_PS_JS_DIR_.'jquery/jquery.jqzoom.js'); }

}

public function canonicalRedirection() {

// Automatically redirect to the canonical URL if the current in is the right one

// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain

if (Validate::isLoadedObject($this->product) && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET')

{

$canonicalURL =

self::$link->getProductLink($this->product); if

(!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/',

Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQU EST_URI']))

{

header('HTTP/1.0 301 Moved');

if (defined('_PS_MODE_DEV_') AND

_PS_MODE_DEV_)

die('[Debug] This page has

moved<br />Please use the following URL instead: <a href="'.$canonicalURL.'">'.$canonicalURL.'</a>');

Tools::redirectLink($canonicalURL); }

} }

public function preProcess() {

if ($id_product =

(int)Tools::getValue('id_product'))

$this->product = new Product($id_product, true, self::$cookie->id_lang);

if (!Validate::isLoadedObject($this->product)) {


(12)

header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); }

else

$this->canonicalRedirection(); parent::preProcess();

}

public function process() {

global $cart, $currency; parent::process();

if (!Validate::isLoadedObject($this->product))

$this->errors[] =

Tools::displayError('Product not found'); else

{

if ((!$this->product->active AND

(Tools::getValue('adtoken') !=

Tools::encrypt('PreviewProduct'.$this->product->id)) ||

!file_exists(dirname(__FILE__).'/../'.Tools::getValue('ad ').'/ajax.php')))

{

header('HTTP/1.1 404 page not

found');

$this->errors[] =

Tools::displayError('Product is no longer available.'); }

elseif

(!$this->product->checkAccess((int)self::$cookie->id_customer))

$this->errors[] =

Tools::displayError('You do not have access to this product.');

else {

self::$smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int)$this->product->id));

if (!$this->product->active)

self::$smarty->assign('adminActionDisplay', true);

/* Product pictures management */ require_once('images.inc.php'); if ($this->product->customizable)


(13)

{

self::$smarty->assign('customizationFormTarget',

Tools::safeOutput(urldecode($_SERVER['REQUEST_URI']))); if

(Tools::isSubmit('submitCustomizedDatas')) {

$this->pictureUpload($this->product, $cart);

$this->textRecord($this->product, $cart);

$this->formTargetFormat(); }

elseif

(isset($_GET['deletePicture']) AND

!$cart->deletePictureToProduct((int)($this->product->id), (int)(Tools::getValue('deletePicture'))))

$this->errors[] =

Tools::displayError('An error occurred while deleting the selected picture');

$files =

self::$cookie->getFamily('pictures_'.(int)($this->product->id));

$textFields =

self::$cookie->getFamily('textFields_'.(int)($this->product->id));

foreach ($textFields as $key => $textField)

$textFields[$key] =

str_replace('<br />', "\n", $textField);

self::$smarty->assign(array( 'pictures' => $files,

'textFields' =>

$textFields));

}

/* Features / Values */

$features =

$this->product->getFrontFeatures((int)self::$cookie->id_lang);

$attachments =

($this->product->cache_has_attachments ?

$this->product->getAttachments((int)self::$cookie->id_lang) : array()); /* Category */

$category = false;

if (isset($_SERVER['HTTP_REFERER'])

AND

preg_match('!^(.*)\/([0-9]+)\-(.*[^\.])|(.*)id_category=([0-9]+)(.*)$!',

$_SERVER['HTTP_REFERER'], $regs) AND


(14)

{

if (isset($regs[2]) AND

is_numeric($regs[2]))

{

if

(Product::idIsOnCategoryId((int)($this->product->id), array('0' => array('id_category' => (int)($regs[2])))))

$category = new

Category((int)($regs[2]), (int)(self::$cookie->id_lang)); }

elseif (isset($regs[5]) AND

is_numeric($regs[5]))

{

if

(Product::idIsOnCategoryId((int)($this->product->id), array('0' => array('id_category' => (int)($regs[5])))))

$category = new

Category((int)($regs[5]), (int)(self::$cookie->id_lang)); }

}

if (!$category)

$category = new Category($this->product->id_category_default, (int)(self::$cookie->id_lang));

if (isset($category) AND

Validate::isLoadedObject($category)) {

self::$smarty->assign(array(

'path' =>

Tools::getPath((int)$category->id, $this->product->name, true),

'category' => $category,

'subCategories' =>

$category->getSubCategories((int)self::$cookie->id_lang, true),

'id_category_current' => (int)$category->id,

'id_category_parent' => (int)$category->id_parent,

'return_category_name' => Tools::safeOutput($category->name)

)); }

else

self::$smarty->assign('path', Tools::getPath((int)$this->product->id_category_default, $this->product->name));


(15)

self::$smarty->assign('return_link',

(isset($category->id) AND $category->id) ?

Tools::safeOutput(self::$link->getCategoryLink($category)) : 'javascript:

history.back();');

if (Pack::isPack((int)$this->product->id) AND !Pack::isInStock((int)$this->product-(Pack::isPack((int)$this->product->id))

$this->product->quantity = 0; $id_customer = (isset(self::$cookie->id_customer) AND self::$cookie->id_customer) ? (int)(self::$cookie->id_customer) : 0;

$id_group = $id_customer ?

(int)(Customer::getDefaultGroupId($id_customer)) :

_PS_DEFAULT_CUSTOMER_GROUP_;

$id_country = (int)($id_customer ?

Customer::getCurrentCountry($id_customer) :

Configuration::get('PS_COUNTRY_DEFAULT'));

$group_reduction =

GroupReduction::getValueForProduct($this->product->id, $id_group);

if ($group_reduction == 0)

$group_reduction =

Group::getReduction((int)self::$cookie->id_customer) / 100;

// Tax

$tax =

(float)(Tax::getProductTaxRate((int)($this->product->id), $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));

self::$smarty->assign('tax_rate', $tax);

$productPriceWithTax =

Product::getPriceStatic($this->product->id, true, NULL, 6);

if (Product::$_taxCalculationMethod == PS_TAX_INC)

$productPriceWithTax =

Tools::ps_round($productPriceWithTax, 2);

$productPriceWithoutEcoTax =

(float)($productPriceWithTax - $this->product->ecotax);

$ecotax_rate = (float)

Tax::getProductEcotaxRate($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});

$ecotaxTaxAmount = Tools::ps_round($this->product->ecotax, 2);


(16)

if (Product::$_taxCalculationMethod == PS_TAX_INC && (int)Configuration::get('PS_TAX'))

$ecotaxTaxAmount =

Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2);

self::$smarty->assign(array(

'quantity_discounts' => $this->formatQuantityDiscounts(SpecificPrice::getQuantityDiscou nts((int)$this->product->id, (int)Shop::getCurrentShop(), (int)self::$cookie->id_currency, $id_country, $id_group), $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false), (float)$tax),

'product' => $this->product,

'ecotax_tax_inc' =>

$ecotaxTaxAmount,

'ecotax_tax_exc' =>

Tools::ps_round($this->product->ecotax, 2),

'ecotaxTax_rate' =>

$ecotax_rate,

'homeSize' =>

Image::getSize('home'),

'product_manufacturer' => new Manufacturer((int)$this->product->id_manufacturer,

self::$cookie->id_lang),

'token' =>

Tools::getToken(false),

'productPriceWithoutEcoTax' => (float)($productPriceWithoutEcoTax),

'features' => $features,

'attachments' => $attachments, 'allow_oosp' => $this->product-

>isAvailableWhenOutOfStock((int)($this->product->out_of_stock)),

'last_qties' =>

(int)Configuration::get('PS_LAST_QTIES'),

'group_reduction' => (1 - $group_reduction),

'col_img_dir' =>

_PS_COL_IMG_DIR_,

));

self::$smarty->assign(array(

'HOOK_EXTRA_LEFT' =>

Module::hookExec('extraLeft'),

'HOOK_EXTRA_RIGHT' =>

Module::hookExec('extraRight'),

'HOOK_PRODUCT_OOS' =>

Hook::productOutOfStock($this->product),

'HOOK_PRODUCT_FOOTER' =>


(17)

'HOOK_PRODUCT_ACTIONS' => Module::hookExec('productActions'),

'HOOK_PRODUCT_TAB' =>

Module::hookExec('productTab'),

'HOOK_PRODUCT_TAB_CONTENT' => Module::hookExec('productTabContent')

));

$images =

$this->product->getImages((int)self::$cookie->id_lang);

$productImages = array();

foreach ($images AS $k => $image) {

if ($image['cover']) {

self::$smarty->assign('mainImage', $images[0]);

$cover = $image;

$cover['id_image'] =

(Configuration::get('PS_LEGACY_IMAGES') ?

($this->product->id.'-'.$image['id_image']) :

$image['id_image']);

$cover['id_image_only'] = (int)($image['id_image']);

}

$productImages[(int)$image['id_image']] = $image; }

if (!isset($cover))

$cover = array('id_image' => Language::getIsoById(self::$cookie->id_lang).'-default', 'legend' => 'No picture', 'title' => 'No picture');

$size = Image::getSize('large'); self::$smarty->assign(array(

'cover' => $cover,

'imgWidth' =>

(int)($size['width']),

'mediumSize' =>

Image::getSize('medium'),

'largeSize' =>

Image::getSize('large'),

'accessories' => $this->product->getAccessories((int)self::$cookie->id_lang)

));

if (count($productImages))

self::$smarty->assign('images', $productImages);

/* Attributes / Groups & colors */ $colors = array();


(18)

$attributesGroups = $this->product->getAttributesGroups((int)(self::$cookie->id_lang)); // @todo (RM) should only get groups and not all declination ?

if (is_array($attributesGroups) AND $attributesGroups)

{

$groups = array();

$combinationImages =

$this- >product->getCombinationImages((int)(self::$cookie->id_lang));

foreach ($attributesGroups AS $k => $row)

{

/* Color management */ if

(((isset($row['attribute_color']) AND

$row['attribute_color']) OR

(file_exists(_PS_COL_IMG_DIR_.$row['id_attribute'].'.jpg' ))) AND $row['id_attribute_group'] == $this->product->id_color_default)

{

$colors[$row['id_attribute']]['value'] =

$row['attribute_color'];

$colors[$row['id_attribute']]['name'] =

$row['attribute_name'];

if

(!isset($colors[$row['id_attribute']]['attributes_quantit y']))

$colors[$row['id_attribute']]['attributes_quantity'] = 0;

$colors[$row['id_attribute']]['attributes_quantity'] += (int)($row['quantity']);

} if

(!isset($groups[$row['id_attribute_group']])) {

$groups[$row['id_attribute_group']] = array( 'name' => $row['public_group_name'],

'is_color_group' => $row['is_color_group'],

'default' => -1,


(19)

); }

$groups[$row['id_attribute_group']]['attributes'][$r ow['id_attribute']] = $row['attribute_name'];

if ($row['default_on'] && $groups[$row['id_attribute_group']]['default'] == -1)

$groups[$row['id_attribute_group']]['default'] =

(int)($row['id_attribute']); if

(!isset($groups[$row['id_attribute_group']]['attributes_q uantity'][$row['id_attribute']]))

$groups[$row['id_attribute_group']]['attributes_quan tity'][$row['id_attribute']] = 0;

$groups[$row['id_attribute_group']]['attributes_quan tity'][$row['id_attribute']] += (int)($row['quantity']);

$combinations[$row['id_product_attribute']]['attribu

tes_values'][$row['id_attribute_group']] =

$row['attribute_name'];

$combinations[$row['id_product_attribute']]['attribu tes'][] = (int)($row['id_attribute']);

$combinations[$row['id_product_attribute']]['price'] = (float)($row['price']);

$combinations[$row['id_product_attribute']]['ecotax' ] = (float)($row['ecotax']);

$combinations[$row['id_product_attribute']]['weight' ] = (float)($row['weight']);

$combinations[$row['id_product_attribute']]['quantit y'] = (int)($row['quantity']);

$combinations[$row['id_product_attribute']]['referen ce'] = $row['reference'];

$combinations[$row['id_product_attribute']]['ean13'] = $row['ean13'];

$combinations[$row['id_product_attribute']]['unit_im pact'] = $row['unit_price_impact'];


(20)

$combinations[$row['id_product_attribute']]['minimal _quantity'] = $row['minimal_quantity'];

$combinations[$row['id_product_attribute']]['id_imag

e'] =

isset($combinationImages[$row['id_product_attribute']][0]

['id_image']) ?

$combinationImages[$row['id_product_attribute']][0]['id_i mage'] : -1;

}

//wash attributes list (if some attributes are unavailables and if allowed to wash it)

if

(!Product::isAvailableWhenOutOfStock($this->product->out_of_stock) &&

Configuration::get('PS_DISP_UNAVAILABLE_ATTR') == 0) {

foreach ($groups AS

&$group)

foreach

($group['attributes_quantity'] AS $key => &$quantity) if (!$quantity) unset($group['attributes'][$key]);

foreach ($colors AS $key => $color)

if (!$color['attributes_quantity'])

unset($colors[$key]); }

foreach ($groups AS &$group) natcasesort($group['attributes']);

foreach ($combinations AS

$id_product_attribute => $comb) {

$attributeList = ''; foreach

($comb['attributes'] AS $id_attribute)

$attributeList .=

'\''.(int)($id_attribute).'\',';

$attributeList =


(21)

$combinations[$id_product_attribute]['list'] = $attributeList;

}

self::$smarty->assign(array( 'groups' => $groups,

'combinaisons' =>

$combinations, /* Kept for compatibility purpose only */

'combinations' =>

$combinations,

'colors' =>

(sizeof($colors) AND $this->product->id_color_default) ? $colors : false,

'combinationImages' => $combinationImages));

}

self::$smarty->assign(array(

'no_tax' =>

Tax::excludeTaxeOption() OR

!Tax::getProductTaxRate((int)$this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}),

'customizationFields' =>

($this->product->customizable ?

$this->product->getCustomizationFields((int)self::$cookie->id_lang) : false)

));

// Pack management

self::$smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, (int)(self::$cookie->id_lang), true) : array());

self::$smarty->assign('packs', Pack::getPacksTable($this->product->id,

(int)(self::$cookie->id_lang), true, 1)); }

}

self::$smarty->assign(array(

'ENT_NOQUOTES' => ENT_NOQUOTES,

'outOfStockAllowed' =>

(int)(Configuration::get('PS_ORDER_OUT_OF_STOCK')), 'errors' => $this->errors,

'categories' =>

Category::getHomeCategories((int)self::$cookie->id_lang),

'have_image' => (isset($cover) ?


(22)

'tax_enabled' => Configuration::get('PS_TAX'),

'display_qties' =>

(int)Configuration::get('PS_DISPLAY_QTIES'),

'display_ht' => !Tax::excludeTaxeOption(), 'ecotax' => (!sizeof($this->errors) AND

$this->product->ecotax > 0 ?

Tools::convertPrice((float)($this->product->ecotax)) : 0),

'currencySign' => $currency->sign,

'currencyRate' =>

$currency->conversion_rate,

'currencyFormat' => $currency->format, 'currencyBlank' => $currency->blank,

'jqZoomEnabled' =>

Configuration::get('PS_DISPLAY_JQZOOM') ));

}

public function displayContent() {

parent::displayContent();

self::$smarty->display(_PS_THEME_DIR_.'product.tpl'); }

public function pictureUpload(Product $product, Cart $cart)

{

if (!$fieldIds =

$this->product->getCustomizationFieldIds()) return false;

$authorizedFileFields = array(); foreach ($fieldIds AS $fieldId)

if ($fieldId['type'] == _CUSTOMIZE_FILE_) $authorizedFileFields[(int)($fieldId['id_customizati

on_field'])] =

'file'.(int)($fieldId['id_customization_field']);

$indexes = array_flip($authorizedFileFields); foreach ($_FILES AS $fieldName => $file)

if (in_array($fieldName,

$authorizedFileFields) AND isset($file['tmp_name']) AND !empty($file['tmp_name']))

{

$fileName = md5(uniqid(rand(),

true));

if ($error = checkImage($file,

(int)(Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE'))) )


(23)

$this->errors[] = $error;

if ($error OR (!$tmpName =

tempnam(_PS_TMP_IMG_DIR_, 'PS') OR

!move_uploaded_file($file['tmp_name'], $tmpName))) return false;

/* Original file */

elseif (!imageResize($tmpName,

_PS_UPLOAD_DIR_.$fileName))

$this->errors[] =

Tools::displayError('An error occurred during the image upload.');

/* A smaller one */

elseif (!imageResize($tmpName,

_PS_UPLOAD_DIR_.$fileName.'_small',

(int)(Configuration::get('PS_PRODUCT_PICTURE_WIDTH')), (int)(Configuration::get('PS_PRODUCT_PICTURE_HEIGHT'))))

$this->errors[] =

Tools::displayError('An error occurred during the image upload.');

elseif

(!chmod(_PS_UPLOAD_DIR_.$fileName, 0777) OR

!chmod(_PS_UPLOAD_DIR_.$fileName.'_small', 0777))

$this->errors[] =

Tools::displayError('An error occurred during the image upload.');

else

$cart->addPictureToProduct((int)($this->product->id), $indexes[$fieldName], $fileName);

unlink($tmpName); }

return true; }

public function textRecord(Product $product, Cart $cart)

{

if (!$fieldIds =

$this->product->getCustomizationFieldIds()) return false;

$authorizedTextFields = array(); foreach ($fieldIds AS $fieldId)

if ($fieldId['type'] ==

_CUSTOMIZE_TEXTFIELD_)

$authorizedTextFields[(int)($fieldId['id_customizati

on_field'])] =

'textField'.(int)($fieldId['id_customization_field']); $indexes = array_flip($authorizedTextFields);


(24)

foreach ($_POST AS $fieldName => $value)

if (in_array($fieldName,

$authorizedTextFields) AND !empty($value)) {

if (!Validate::isMessage($value))

$this->errors[] =

Tools::displayError('Invalid message'); else

$cart->addTextFieldToProduct((int)($this->product->id), $indexes[$fieldName], $value);

}

elseif (in_array($fieldName,

$authorizedTextFields) AND empty($value))

$cart->deleteTextFieldFromProduct((int)($this->product->id), $indexes[$fieldName]);

}

public function formTargetFormat() {

$customizationFormTarget =

Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])); foreach ($_GET AS $field => $value)

if (strncmp($field, 'group_', 6) == 0)

$customizationFormTarget =

preg_replace('/&group_([[:digit:]]+)=([[:digit:]]+)/', '', $customizationFormTarget);

if (isset($_POST['quantityBackup']))

self::$smarty->assign('quantityBackup', (int)($_POST['quantityBackup']));

self::$smarty->assign('customizationFormTarget', $customizationFormTarget);

}

public function

formatQuantityDiscounts($specificPrices, $price,

$taxRate) {

foreach ($specificPrices AS $key => &$row) {

$row['quantity'] = &$row['from_quantity']; // The price may be directly set

if ($row['price'] != 0) {

$cur_price =

(Product::$_taxCalculationMethod == PS_TAX_EXC ?

$row['price'] : $row['price'] * (1 + $taxRate / 100)); if ($row['reduction_type'] == 'amount')


(25)

$cur_price =

Product::$_taxCalculationMethod == PS_TAX_INC ?

$cur_price - $row['reduction'] : $cur_price -

($row['reduction'] / (1 + $taxRate / 100)); else

$cur_price = $cur_price * ( 1 - ($row['reduction']));

$row['real_value'] = $price -

$cur_price;

} else {

global $cookie;

$id_currency = (int)$cookie->id_currency;

if ($row['reduction_type'] ==

'amount')

{

$reduction_amount = $row['reduction']; if (!$row['id_currency'])

$reduction_amount =

Tools::convertPrice($reduction_amount, $id_currency);

$row['real_value'] =

Product::$_taxCalculationMethod == PS_TAX_INC ?

$reduction_amount : $reduction_amount / (1 + $taxRate / 100);

}

else {

$row['real_value'] =

$row['reduction'] * 100; }

}

$row['nextQuantity'] =

(isset($specificPrices[$key + 1]) ?

(int)($specificPrices[$key + 1]['from_quantity']) : -1); }

return $specificPrices; }

}

Listing AuthController.php <?php

/*

* 2007-2011 PrestaShop *


(26)

*

* This source file is subject to the Open Software License (OSL 3.0)

* that is bundled with this package in the file LICENSE.txt.

* It is also available through the world-wide-web at this URL:

* http://opensource.org/licenses/osl-3.0.php

* If you did not receive a copy of the license and are unable to

* obtain it through the world-wide-web, please send an email

* to license@prestashop.com so we can send you a copy immediately.

*

* DISCLAIMER *

* Do not edit or add to this file if you wish to upgrade PrestaShop to newer

* versions in the future. If you wish to customize PrestaShop for your

* needs please refer to http://www.prestashop.com for more information.

*

* @author PrestaShop SA <contact@prestashop.com> * @copyright 2007-2011 PrestaShop SA

* @version Release: $Revision: 9643 $

* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)

* International Registered Trademark & Property of PrestaShop SA

*/

class AuthControllerCore extends FrontController {

public $ssl = true;

public $php_self = 'authentication.php'; public function preProcess()

{

parent::preProcess();

if (self::$cookie->isLogged() AND

!Tools::isSubmit('ajax'))

Tools::redirect('my-account.php'); if (Tools::getValue('create_account')) {

$create_account = 1;


(27)

}

if (Tools::isSubmit('SubmitCreate')) {

if (!Validate::isEmail($email =

Tools::getValue('email_create')) OR empty($email))

$this->errors[] =

Tools::displayError('Invalid e-mail address');

elseif (Customer::customerExists($email)) {

$this->errors[] =

Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');

$_POST['email'] =

$_POST['email_create'];

unset($_POST['email_create']); }

else {

$create_account = 1;

self::$smarty->assign('email_create', Tools::safeOutput($email));

$_POST['email'] = $email; }

}

if (Tools::isSubmit('submitAccount') OR

Tools::isSubmit('submitGuestAccount')) {

$create_account = 1;

if (Tools::isSubmit('submitAccount'))

self::$smarty->assign('email_create', 1);

/* New Guest customer */

if (!Tools::getValue('is_new_customer', 1) AND !Configuration::get('PS_GUEST_CHECKOUT_ENABLED'))

$this->errors[] =

Tools::displayError('You cannot create a guest

account.');

if (!Tools::getValue('is_new_customer', 1))

$_POST['passwd'] =

md5(time()._COOKIE_KEY_);

if (isset($_POST['guest_email']) AND

$_POST['guest_email'])

$_POST['email'] =


(28)

/* Preparing customer */ $customer = new Customer();

$lastnameAddress = $_POST['lastname']; $firstnameAddress = $_POST['firstname'];

$_POST['lastname'] =

$_POST['customer_lastname'];

$_POST['firstname'] =

$_POST['customer_firstname'];

if (!Tools::getValue('phone') AND

!Tools::getValue('phone_mobile'))

$this->errors[] =

Tools::displayError('You must register at least one phone number');

if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) AND

!(Tools::getValue('months') == '' AND

Tools::getValue('days') == '' AND

Tools::getValue('years') == ''))

$this->errors[] =

Tools::displayError('Invalid date of birth');

$customer->birthday =

(empty($_POST['years']) ? '' : (int)($_POST['years']).'-'.(int)($_POST['months']).'-'.(int)($_POST['days']));

$this->errors =

array_unique(array_merge($this->errors, $customer->validateControler()));

/* Preparing address */ $address = new Address();

$_POST['lastname'] = $lastnameAddress; $_POST['firstname'] = $firstnameAddress; $address->id_customer = 1;

$this->errors =

array_unique(array_merge($this->errors,

$address->validateControler()));

/* US customer: normalize the address */

if ($address->id_country ==

Country::getByIso('US')) {

include_once(_PS_TAASC_PATH_.'AddressStandardization Solution.php');

$normalize = new

AddressStandardizationSolution;

$address->address1 = $normalize->AddressLineStandardization($address->address1);

$address->address2 = $normalize->AddressLineStandardization($address->address2);


(29)

}

$zip_code_format =

Country::getZipCodeFormat((int)(Tools::getValue('id_count ry'))); if (Country::getNeedZipCode((int)(Tools::getValue('id_countr y')))) {

if (($postcode =

Tools::getValue('postcode')) AND $zip_code_format) {

$zip_regexp =

'/^'.$zip_code_format.'$/ui';

$zip_regexp = str_replace(' ', '( |)', $zip_regexp);

$zip_regexp = str_replace('-', '(-|)', $zip_regexp);

$zip_regexp = str_replace('N', '[0-9]', $zip_regexp);

$zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);

$zip_regexp = str_replace('C', Country::getIsoById((int)(Tools::getValue('id_country'))) , $zip_regexp);

if (!preg_match($zip_regexp,

$postcode))

$this->errors[] =

'<strong>'.Tools::displayError('Zip/ Postal

code').'</strong> '.Tools::displayError('is

invalid.').'<br />'.Tools::displayError('Must be typed as

follows:').' '.str_replace('C',

Country::getIsoById((int)(Tools::getValue('id_country')))

, str_replace('N', '0', str_replace('L', 'A',

$zip_code_format))); }

elseif ($zip_code_format)

$this->errors[] =

'<strong>'.Tools::displayError('Zip/ Postal

code').'</strong> '.Tools::displayError('is required.');

elseif ($postcode AND

!preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))

$this->errors[] =

'<strong>'.Tools::displayError('Zip/ Postal

code').'</strong> '.Tools::displayError('is invalid.'); }

if

(Country::isNeedDniByCountryId($address->id_country) AND

(!Tools::getValue('dni') OR


(30)

$this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');

elseif

(!Country::isNeedDniByCountryId($address->id_country)) $address->dni = NULL;

if (!sizeof($this->errors)) {

if

(Customer::customerExists(Tools::getValue('email')))

$this->errors[] =

Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');

if (Tools::isSubmit('newsletter')) {

$customer->ip_registration_newsletter =

pSQL(Tools::getRemoteAddr());

$customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s'));

}

if (!sizeof($this->errors)) {

if (!$country = new

Country($address->id_country,

Configuration::get('PS_LANG_DEFAULT')) OR

!Validate::isLoadedObject($country))

die(Tools::displayError());

if

((int)($country->contains_states) AND !(int)($address->id_state))

$this->errors[] =

Tools::displayError('This country requires a state selection.');

else {

$customer->active = 1; /* New Guest customer */ if

(Tools::isSubmit('is_new_customer'))

$customer->is_guest = !Tools::getValue('is_new_customer', 1);

else

$customer->is_guest = 0;


(31)

$this->errors[] = Tools::displayError('An error occurred while creating your account.');

else {

$address->id_customer = (int)($customer->id);

if (!$address->add()) $this->errors[] = Tools::displayError('An error occurred while creating your address.');

else {

if

(!$customer->is_guest)

{

if

(!Mail::Send((int)(self::$cookie->id_lang), 'account', Mail::l('Welcome!'),

array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' =>

$customer->email, '{passwd}' =>

Tools::getValue('passwd')), >email, $customer->firstname.' '.$customer->lastname))

$this->errors[] = Tools::displayError('Cannot send email');

}

self::$smarty->assign('confirmation', 1);

self::$cookie->id_customer = (int)($customer->id);

self::$cookie->customer_lastname = $customer->lastname;

self::$cookie->customer_firstname = $customer->firstname;

self::$cookie->passwd = $customer-self::$cookie->passwd;

self::$cookie->logged = 1;

self::$cookie->email = $customer-self::$cookie->email;

self::$cookie->is_guest = !Tools::getValue('is_new_customer', 1);

/* Update cart

address */

self::$cart->secure_key = $customer-self::$cart->secure_key;


(32)

self::$cart->id_address_delivery =

Address::getFirstCustomerAddressId((int)($customer->id));

self::$cart->id_address_invoice =

Address::getFirstCustomerAddressId((int)($customer->id));

self::$cart->update();

Module::hookExec('createAccount', array(

'_POST' => $_POST,

'newCustomer' => $customer

)); if (Tools::isSubmit('ajax'))

{

$return =

array(

'hasError' => !empty($this->errors), 'errors' => $this->errors,

'isSaved' => true,

'id_customer' => (int)self::$cookie->id_customer,

'id_address_delivery' =>

self::$cart->id_address_delivery,

'id_address_invoice' =>

self::$cart->id_address_invoice,

'token' => Tools::getToken(false)

); die(Tools::jsonEncode($return));

}

if ($back =

Tools::getValue('back')) Tools::redirect($back);

Tools::redirect('my-account.php'); } }

} }


(33)

} if (sizeof($this->errors)) { if (!Tools::getValue('is_new_customer')) unset($_POST['passwd']); if (Tools::isSubmit('ajax')) {

$return = array(

'hasError' => !empty($this->errors),

'errors' => $this->errors, 'isSaved' => false,

'id_customer' => 0 ); die(Tools::jsonEncode($return)); } } } if (Tools::isSubmit('SubmitLogin')) { Module::hookExec('beforeAuthentication'); $passwd = trim(Tools::getValue('passwd')); $email = trim(Tools::getValue('email')); if (empty($email))

$this->errors[] =

Tools::displayError('E-mail address required'); elseif (!Validate::isEmail($email))

$this->errors[] =

Tools::displayError('Invalid e-mail address'); elseif (empty($passwd))

$this->errors[] =

Tools::displayError('Password is required');

elseif (Tools::strlen($passwd) > 32)

$this->errors[] =

Tools::displayError('Password is too long');

elseif (!Validate::isPasswd($passwd))

$this->errors[] =

Tools::displayError('Invalid password'); else

{

$customer = new Customer();

$authentication =

$customer->getByEmail(trim($email), trim($passwd));

if (!$authentication OR !$customer->id)

{

/* Handle brute force attacks */ sleep(1);


(34)

$this->errors[] = Tools::displayError('Authentication failed');

} else {

self::$cookie->id_compare = isset(self::$cookie->id_compare) ? self::$cookie->id_compare:

CompareProduct::getIdCompareByIdCustomer($customer->id); self::$cookie->id_customer = (int)($customer->id);

self::$cookie->customer_lastname = $customer->lastname;

self::$cookie->customer_firstname = $customer->firstname;

self::$cookie->logged = 1;

self::$cookie->is_guest =

$customer->isGuest();

self::$cookie->passwd =

$customer->passwd;

self::$cookie->email =

$customer->email;

if

(Configuration::get('PS_CART_FOLLOWING') AND

(empty(self::$cookie->id_cart) OR

Cart::getNbProducts(self::$cookie->id_cart) == 0))

self::$cookie->id_cart = (int)(Cart::lastNoneOrderedCart((int)($customer->id)));

/* Update cart address */ self::$cart->id_carrier = 0; self::$cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id));

self::$cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id));

// If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated

self::$cart->secure_key =

$customer->secure_key;

self::$cart->update(); Module::hookExec('authentication');

if (!Tools::isSubmit('ajax')) {

if ($back =

Tools::getValue('back')) Tools::redirect($back);


(35)

Tools::redirect('my-account.php');

} }

}

if (Tools::isSubmit('ajax')) {

$return = array(

'hasError' => !empty($this->errors),

'errors' => $this->errors,

'token' =>

Tools::getToken(false) );

die(Tools::jsonEncode($return)); }

}

if (isset($create_account)) {

/* Select the most appropriate country */

if (isset($_POST['id_country']) AND

is_numeric($_POST['id_country']))

$selectedCountry =

(int)($_POST['id_country']);

/* FIXME : language iso and country iso are not similar,

* maybe an associative table with country an language can resolve it,

* But for now it's a bug ! * @see : bug #6968

*

@link:http://www.prestashop.com/bug_tracker/view/6968/ elseif

(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {

$array = explode(',',

$_SERVER['HTTP_ACCEPT_LANGUAGE']); if

(Validate::isLanguageIsoCode($array[0])) {

$selectedCountry =

Country::getByIso($array[0]);

if (!$selectedCountry)

$selectedCountry =

(int)(Configuration::get('PS_COUNTRY_DEFAULT')); }

}*/


(36)

$selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT'));

if

(Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES'))

$countries =

Carrier::getDeliveredCountries((int)self::$cookie->id_lang, true, true);

else

$countries =

Country::getCountries((int)self::$cookie->id_lang, true);

self::$smarty->assign(array( 'countries' => $countries,

'sl_country' =>

(isset($selectedCountry) ? $selectedCountry : 0),

'vat_management' =>

Configuration::get('VATNUMBER_MANAGEMENT') ));

/* Call a hook to display more information on form */

self::$smarty->assign(array(

'HOOK_CREATE_ACCOUNT_FORM' =>

Module::hookExec('createAccountForm'),

'HOOK_CREATE_ACCOUNT_TOP' =>

Module::hookExec('createAccountTop') ));

}

/* Generate years, months and days */

if (isset($_POST['years']) AND

is_numeric($_POST['years']))

$selectedYears = (int)($_POST['years']); $years = Tools::dateYears();

if (isset($_POST['months']) AND

is_numeric($_POST['months']))

$selectedMonths = (int)($_POST['months']); $months = Tools::dateMonths();

if (isset($_POST['days']) AND

is_numeric($_POST['days']))

$selectedDays = (int)($_POST['days']); $days = Tools::dateDays();

self::$smarty->assign(array( 'years' => $years,

'sl_year' => (isset($selectedYears) ? $selectedYears : 0),


(37)

'sl_month' => (isset($selectedMonths) ? $selectedMonths : 0),

'days' => $days,

'sl_day' => (isset($selectedDays) ? $selectedDays : 0)

));

self::$smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active);

}

public function setMedia() {

parent::setMedia();

Tools::addCSS(_THEME_CSS_DIR_.'authentication.css'); Tools::addJS(array(_THEME_JS_DIR_.'tools/statesManag

ement.js',

_PS_JS_DIR_.'jquery/jquery-typewatch.pack.js')); }

public function process() {

parent::process();

$back = Tools::getValue('back');

$key =

Tools::safeOutput(Tools::getValue('key')); if (!empty($key))

$back .= (strpos($back, '?') !== false ? '&' : '?').'key='.$key;

if (!empty($back)) {

self::$smarty->assign('back', Tools::safeOutput($back));

if (strpos($back, 'order.php') !== false) {

if

(Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES'))

$countries =

Carrier::getDeliveredCountries((int)self::$cookie->id_lang, true, true);

else

$countries =

Country::getCountries((int)self::$cookie->id_lang, true); self::$smarty->assign(array(


(38)

'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'),

'sl_country' =>

(int)Tools::getValue('id_country',

Configuration::get('PS_COUNTRY_DEFAULT')),

'countries' => $countries ));

} }

}

public function displayContent() {

$this->processAddressFormat(); parent::displayContent();

self::$smarty->display(_PS_THEME_DIR_.'authentication.tpl'); }

protected function processAddressFormat() {

$addressItems = array();

$addressFormat =

AddressFormat::getOrderedAddressFields(Configuration::get ('PS_COUNTRY_DEFAULT'), false, true);

$requireFormFieldsList =

AddressFormat::$requireFormFieldsList;

foreach ($addressFormat as $addressline)

foreach (explode(' ', $addressline) as $addressItem)

$addressItems[] = trim($addressItem); // Add missing require fields for a new user susbscription form

foreach($requireFormFieldsList as $fieldName) if (!in_array($fieldName, $addressItems))

$addressItems[] = trim($fieldName); foreach (array('inv', 'dlv') as $addressType)

self::$smarty->assign(array($addressType.'_adr_fields' =>

$addressFormat, $addressType.'_all_fields' =>

$addressItems)); }


(39)

Listing ManufacturerController.php <?php

/*

* 2007-2011 PrestaShop *

* NOTICE OF LICENSE *

* This source file is subject to the Open Software License (OSL 3.0)

* that is bundled with this package in the file LICENSE.txt.

* It is also available through the world-wide-web at this URL:

* http://opensource.org/licenses/osl-3.0.php

* If you did not receive a copy of the license and are unable to

* obtain it through the world-wide-web, please send an email

* to license@prestashop.com so we can send you a copy immediately.

*

* DISCLAIMER *

* Do not edit or add to this file if you wish to upgrade PrestaShop to newer

* versions in the future. If you wish to customize PrestaShop for your

* needs please refer to http://www.prestashop.com for more information.

*

* @author PrestaShop SA <contact@prestashop.com> * @copyright 2007-2011 PrestaShop SA

* @version Release: $Revision: 9124 $

* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)

* International Registered Trademark & Property of PrestaShop SA

*/

class ManufacturerControllerCore extends FrontController {

public $php_self = 'manufacturer.php'; protected $manufacturer;

public function setMedia() {


(40)

Tools::addCSS(_THEME_CSS_DIR_.'product_list.css'); }

public function canonicalRedirection() {

if

(Validate::isLoadedObject($this->manufacturer) &&

Configuration::get('PS_CANONICAL_REDIRECT') && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET')

{

$canonicalURL =

self::$link->getManufacturerLink($this->manufacturer); if

(!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/',

Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQU EST_URI']))

{

header('HTTP/1.0 301 Moved');

if (defined('_PS_MODE_DEV_') AND

_PS_MODE_DEV_)

die('[Debug] This page has

moved<br />Please use the following URL instead: <a href="'.$canonicalURL.'">'.$canonicalURL.'</a>');

Tools::redirectLink($canonicalURL); }

} }

public function preProcess() {

if ($id_manufacturer =

(int)Tools::getValue('id_manufacturer')) {

$this->manufacturer = new

Manufacturer($id_manufacturer, self::$cookie->id_lang);

if

(!Validate::isLoadedObject($this->manufacturer) OR !$this->manufacturer->active) {

header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found');

$this->errors[] =

Tools::displayError('Manufacturer does not exist.'); }

else

$this->canonicalRedirection(); }


(41)

parent::preProcess(); }

public function process() {

if

(Validate::isLoadedObject($this->manufacturer) AND $this->manufacturer->active) {

$nbProducts =

$this->manufacturer->getProducts($this->manufacturer->id, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);

$this->pagination($nbProducts); self::$smarty->assign(array(

'nb_products' => $nbProducts,

'products' => $this->manufacturer->getProducts($this->manufacturer->id, (int)self::$cookie->id_lang, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay),

'path' => ($this->manufacturer->active ? Tools::safeOutput($this->manufacturer->name) : ''),

'manufacturer' =>

$this->manufacturer)); }

elseif (!Tools::getValue('id_manufacturer')) {

if

(Configuration::get('PS_DISPLAY_SUPPLIERS')) {

$result =

Manufacturer::getManufacturers(true, (int)self::$cookie->id_lang, true);

$nbProducts = count($result); $this->pagination($nbProducts);

$manufacturers =

Manufacturer::getManufacturers(true, (int)self::$cookie->id_lang, true, $this->p, $this->n);

foreach ($manufacturers AS &$row)

$row['image'] =

(!file_exists(_PS_MANU_IMG_DIR_.'/'.$row['id_manufacturer

'].'-medium.jpg')) ?

Language::getIsoById((int)self::$cookie->id_lang).'-default' : $row['id_manufacturer'];

self::$smarty->assign(array(

'pages_nb' => ceil($nbProducts / (int)$this->n),

'nbManufacturers' =>


(42)

'mediumSize' => Image::getSize('medium'),

'manufacturers' =>

$manufacturers,

'add_prod_display' =>

Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), ));

} else

self::$smarty->assign('nbManufacturers', 0);

} }

public function displayHeader() {

parent::displayHeader(); $this->productSort(); }

public function displayContent() {

parent::displayContent(); if ($this->manufacturer)

self::$smarty->display(_PS_THEME_DIR_.'manufacturer.tpl'); else

self::$smarty->display(_PS_THEME_DIR_.'manufacturer-list.tpl'); }

}

Listing CMSController.php <?php

/*

* 2007-2011 PrestaShop *

* NOTICE OF LICENSE *

* This source file is subject to the Open Software License (OSL 3.0)

* that is bundled with this package in the file LICENSE.txt.

* It is also available through the world-wide-web at this URL:


(43)

* If you did not receive a copy of the license and are unable to

* obtain it through the world-wide-web, please send an email

* to license@prestashop.com so we can send you a copy immediately.

*

* DISCLAIMER *

* Do not edit or add to this file if you wish to upgrade PrestaShop to newer

* versions in the future. If you wish to customize PrestaShop for your

* needs please refer to http://www.prestashop.com for more information.

*

* @author PrestaShop SA <contact@prestashop.com> * @copyright 2007-2011 PrestaShop SA

* @version Release: $Revision: 10156 $

* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)

* International Registered Trademark & Property of PrestaShop SA

*/

class CmsControllerCore extends FrontController {

public $php_self = 'cms.php'; public $assignCase;

public $cms;

public $cms_category;

public function canonicalRedirection() {

// Automatically redirect to the canonical URL if the current in is the right one

// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain

if (Configuration::get('PS_CANONICAL_REDIRECT') && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET')

{

if (Validate::isLoadedObject($this->cms) AND $canonicalURL = self::$link->getCMSLink($this->cms))

if

(!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/',

Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQU EST_URI']))


(44)

{

header('HTTP/1.0 301 Moved'); if (_PS_MODE_DEV_)

die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$canonicalURL.'">'.$canonicalURL.'</a>');

Tools::redirectLink($canonicalURL); }

if

(Validate::isLoadedObject($this->cms_category) AND $canonicalURL = self::$link->getCMSCategoryLink($this->cms_category))

if

(!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/',

Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQU EST_URI']))

{

header('HTTP/1.0 301 Moved'); if (_PS_MODE_DEV_ )

die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$canonicalURL.'">'.$canonicalURL.'</a>');

Tools::redirectLink($canonicalURL); }

} }

public function preProcess() {

if ($id_cms = (int)Tools::getValue('id_cms'))

$this->cms = new CMS($id_cms,

self::$cookie->id_lang);

elseif ($id_cms_category =

(int)Tools::getValue('id_cms_category'))

$this->cms_category = new

CMSCategory($id_cms_category, self::$cookie->id_lang); $this->canonicalRedirection();

parent::preProcess();

/* assignCase (1 = CMS page, 2 = CMS category) */

if (Validate::isLoadedObject($this->cms) AND ($this->cms->active OR (Tools::getValue('adtoken') == Tools::encrypt('PreviewCMS'.$this->cms->id) AND file_exists(dirname(__FILE__).'/../'.Tools::getValue('ad' ).'/ajax.php'))))


(45)

elseif (Validate::isLoadedObject($this->cms_category))

$this->assignCase = 2; else

Tools::display404Error('404.php'); // too early if in setMedia

if ($this->assignCase == 1)

Tools::addJS(_THEME_JS_DIR_.'cms.js'); }

public function setMedia() {

parent::setMedia();

Tools::addCSS(_THEME_CSS_DIR_.'cms.css'); }

public function process() {

parent::process();

$parent_cat = new CMSCategory(1,

(int)(self::$cookie->id_lang));

self::$smarty->assign('id_current_lang', self::$cookie->id_lang);

self::$smarty->assign('home_title', $parent_cat->name);

self::$smarty->assign('cgv_id', Configuration::get('PS_CONDITIONS_CMS_ID'));

if ($this->assignCase == 1) {

self::$smarty->assign(array( 'cms' => $this->cms,

'content_only' =>

(int)(Tools::getValue('content_only')),

'path' => ((isset($this->cms->id_cms_category) AND $this->cms->id_cms_category) ? Tools::getFullPath((int)($this->cms->id_cms_category), $this->cms->meta_title, 'CMS') : Tools::getFullPath(1, $this->cms->meta_title, 'CMS'))

)); }

elseif ($this->assignCase == 2) {

self::$smarty->assign(array(

'category' => $this->cms_category,

'sub_category' =>

$this- >cms_category->getSubCategories((int)(self::$cookie->id_lang)),


(46)

'cms_pages' => CMS::getCMSPages((int)(self::$cookie->id_lang),

(int)($this->cms_category->id) ),

'path' => ($this->cms_category->id !== 1) ? Tools::getPath((int)($this->cms_category->id), $this->cms_category->name, false, 'CMS') : '',

)); }

}

public function displayContent() {

parent::displayContent();

self::$smarty->display(_PS_THEME_DIR_.'cms.tpl'); }

}

Listing BestSalesController.php <?php

/*

* 2007-2011 PrestaShop *

* NOTICE OF LICENSE *

* This source file is subject to the Open Software License (OSL 3.0)

* that is bundled with this package in the file LICENSE.txt.

* It is also available through the world-wide-web at this URL:

* http://opensource.org/licenses/osl-3.0.php

* If you did not receive a copy of the license and are unable to

* obtain it through the world-wide-web, please send an email

* to license@prestashop.com so we can send you a copy immediately.

*

* DISCLAIMER *

* Do not edit or add to this file if you wish to upgrade PrestaShop to newer

* versions in the future. If you wish to customize PrestaShop for your

* needs please refer to http://www.prestashop.com for more information.


(47)

* @author PrestaShop SA <contact@prestashop.com> * @copyright 2007-2011 PrestaShop SA

* @version Release: $Revision: 7197 $

* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)

* International Registered Trademark & Property of PrestaShop SA

*/

class BestSalesControllerCore extends FrontController {

public $php_self = 'best-sales.php'; public function process()

{

$this->productSort();

$nbProducts = (int)(ProductSale::getNbSales()); $this->pagination($nbProducts);

self::$smarty->assign(array(

'products' =>

ProductSale::getBestSales((int)(self::$cookie->id_lang), (int)($this->p) - 1, (int)($this->n), $this->orderBy, $this->orderWay),

'add_prod_display' =>

Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts,

'homeSize' => Image::getSize('home') ));

}

public function setMedia() {

parent::setMedia();

Tools::addCSS(_THEME_CSS_DIR_.'product_list.css'); }

public function displayContent() {

parent::displayContent();

self::$smarty->display(_PS_THEME_DIR_.'best-sales.tpl');

} }


(48)

Listing NewProductsController.php <?php

/*

* 2007-2011 PrestaShop *

* NOTICE OF LICENSE *

* This source file is subject to the Open Software License (OSL 3.0)

* that is bundled with this package in the file LICENSE.txt.

* It is also available through the world-wide-web at this URL:

* http://opensource.org/licenses/osl-3.0.php

* If you did not receive a copy of the license and are unable to

* obtain it through the world-wide-web, please send an email

* to license@prestashop.com so we can send you a copy immediately.

*

* DISCLAIMER *

* Do not edit or add to this file if you wish to upgrade PrestaShop to newer

* versions in the future. If you wish to customize PrestaShop for your

* needs please refer to http://www.prestashop.com for more information.

*

* @author PrestaShop SA <contact@prestashop.com> * @copyright 2007-2011 PrestaShop SA

* @version Release: $Revision: 7197 $

* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)

* International Registered Trademark & Property of PrestaShop SA

*/

class NewProductsControllerCore extends FrontController {

public $php_self = 'new-products.php'; public function setMedia()

{

parent::setMedia();

Tools::addCSS(_THEME_CSS_DIR_.'product_list.css'); }


(49)

public function process() {

parent::process(); $this->productSort();

$nbProducts =

(int)(Product::getNewProducts((int)(self::$cookie->id_lang), isset($this->p) ? (int)($this->p) - 1 : NULL, isset($this->n) ? (int)($this->n) : NULL, true));

$this->pagination($nbProducts); self::$smarty->assign(array(

'products' =>

Product::getNewProducts((int)(self::$cookie->id_lang), (int)(>p) - 1, (int)(>n), false, $this->orderBy, $this->orderWay),

'add_prod_display' =>

Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int)($nbProducts), 'homeSize' => Image::getSize('home') ));

}

public function displayContent() {

parent::displayContent();

self::$smarty->display(_PS_THEME_DIR_.'new-products.tpl');

} }

Listing PricesDropController.php <?php

/*

* 2007-2011 PrestaShop *

* NOTICE OF LICENSE *

* This source file is subject to the Open Software License (OSL 3.0)

* that is bundled with this package in the file LICENSE.txt.

* It is also available through the world-wide-web at this URL:

* http://opensource.org/licenses/osl-3.0.php

* If you did not receive a copy of the license and are unable to


(50)

* obtain it through the world-wide-web, please send an email

* to license@prestashop.com so we can send you a copy immediately.

*

* DISCLAIMER *

* Do not edit or add to this file if you wish to upgrade PrestaShop to newer

* versions in the future. If you wish to customize PrestaShop for your

* needs please refer to http://www.prestashop.com for more information.

*

* @author PrestaShop SA <contact@prestashop.com> * @copyright 2007-2011 PrestaShop SA

* @version Release: $Revision: 7197 $

* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)

* International Registered Trademark & Property of PrestaShop SA

*/

class PricesDropControllerCore extends FrontController {

public $php_self = 'prices-drop.php'; public function setMedia()

{

parent::setMedia();

Tools::addCSS(_THEME_CSS_DIR_.'product_list.css'); }

public function process() {

parent::process(); $this->productSort();

$nbProducts =

Product::getPricesDrop((int)(self::$cookie->id_lang), NULL, NULL, true);

$this->pagination($nbProducts); self::$smarty->assign(array(

'products' =>

Product::getPricesDrop((int)(self::$cookie->id_lang), (int)(>p) - 1, (int)(>n), false, $this->orderBy, $this->orderWay),


(51)

'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),

'nbProducts' => $nbProducts,

'homeSize' => Image::getSize('home') ));

}

public function displayContent() {

parent::displayContent();

self::$smarty->display(_PS_THEME_DIR_.'prices-drop.tpl');

} }

Listing Login.php <?php

/*

* 2007-2011 PrestaShop *

* NOTICE OF LICENSE *

* This source file is subject to the Open Software License (OSL 3.0)

* that is bundled with this package in the file LICENSE.txt.

* It is also available through the world-wide-web at this URL:

* http://opensource.org/licenses/osl-3.0.php

* If you did not receive a copy of the license and are unable to

* obtain it through the world-wide-web, please send an email

* to license@prestashop.com so we can send you a copy immediately.

*

* DISCLAIMER *

* Do not edit or add to this file if you wish to upgrade PrestaShop to newer

* versions in the future. If you wish to customize PrestaShop for your

* needs please refer to http://www.prestashop.com for more information.

*

* @author PrestaShop SA <contact@prestashop.com> * @copyright 2007-2011 PrestaShop SA


(52)

* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)

* International Registered Trademark & Property of PrestaShop SA

*/

ob_start();

define('PS_ADMIN_DIR', getcwd());

include(PS_ADMIN_DIR.'/../config/config.inc.php'); include(PS_ADMIN_DIR.'/functions.php');

$clientIsMaintenanceOrLocal =

in_array(Tools::getRemoteAddr(),

array_merge(array('127.0.0.1'),explode(',', Configuration::get('PS_MAINTENANCE_IP')))); $errors = array();

if ((empty($_SERVER['HTTPS']) OR

strtolower($_SERVER['HTTPS']) == 'off')

AND Configuration::get('PS_SSL_ENABLED')) {

// You can uncomment theses lines if you want to force https even from localhost and automatically redirect

// header('HTTP/1.1 301 Moved Permanently');

// header('Location:

'.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']); // exit();

// If ssl is enabled, https protocol is required. Exception for maintenance and local (127.0.0.1) IP

if ($clientIsMaintenanceOrLocal)

$errors[] = translate('SSL is activated.

However, your IP is allowed to use unsecure mode (Maintenance or local IP).').'<br/>';

else

$warningSslMessage = translate('SSL is

activated. Please connect using the following url to log in in secure mode (https).')

.'<br/><br/><a

href="https://'.Tools::getServerName().Tools::safeOutput( $_SERVER['REQUEST_URI']).'">https://'.Tools::getServerNam e().Tools::safeOutput($_SERVER['REQUEST_URI']).'</a>'; }

$cookie = new Cookie('psAdmin',

substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__), -10));


(53)

if (!isset($cookie->id_lang))

$cookie->id_lang =

Configuration::get('PS_LANG_DEFAULT');

$iso = strtolower(Language::getIsoById((int)($cookie->id_lang)));

include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php'); include(_PS_TRANSLATIONS_DIR_.$iso.'/errors.php'); /* Cookie creation and redirection */

if (Tools::isSubmit('Submit')) {

/* Check fields validity */

$passwd = trim(Tools::getValue('passwd')); $email = trim(Tools::getValue('email')); if (empty($email))

$errors[] = Tools::displayError('E-mail is empty');

elseif (!Validate::isEmail($email))

$errors[] = Tools::displayError('Invalid e-mail address');

elseif (empty($passwd))

$errors[] = Tools::displayError('Password is blank');

elseif (!Validate::isPasswd($passwd))

$errors[] = Tools::displayError('Invalid

password'); else {

/* Seeking for employee */ $employee = new Employee();

$employee = $employee->getByemail($email, $passwd);

if (!$employee) {

$errors[] = Tools::displayError('Employee does not exist or password is incorrect.');

$cookie->logout(); }

else {

/* Creating cookie */

$cookie->id_employee = $employee->id; $cookie->email = $employee->email;

$cookie->profile = $employee->id_profile; $cookie->passwd = $employee->passwd;

$cookie->remote_addr =

ip2long(Tools::getRemoteAddr()); $cookie->write();

/* Redirect to admin panel */ if (isset($_GET['redirect']))


(54)

$url =

strval($_GET['redirect'].(isset($_GET['token']) ?

('&token='.$_GET['token']) : '')); else

$url = 'index.php';

if (!Validate::isCleanHtml($url)) die(Tools::displayError());

echo '<!DOCTYPE html PUBLIC "-//W3C//DTD

XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$iso.'" lang="'.$iso.'">

<meta http-equiv="Refresh" content="0;URL='.str_replace('&amp;', '&', Tools::safeOutput($url, true)).'">

<head>

<script language="javascript" type="text/javascript">

window.location.replace("'.str_replace('&amp;', '&', Tools::safeOutput($url, true)).'");

</script>

<div style="text-align:center; margin-top:250px;"><a href="'.str_replace('&amp;', '&', Tools::safeOutput($url, true)).'">'.translate('Click here to launch Administration panel').'</a></div>

</head> </html>'; exit ; }

} }

echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$iso.'" lang="'.$iso.'">

<head>

<meta http-equiv="content-type"

content="text/html; charset=utf-8" />

<link type="text/css" rel="stylesheet" href="../css/login.css" />

<title>PrestaShop&trade; -

'.translate('Administration panel').'</title>'; echo '

</head> <body>


(55)

<div id="container">'; if ($nbErrors = sizeof($errors)) {

echo '

<div id="error">

<h3>'.($nbErrors > 1 ? translate('There are') : translate('There is')).' '.$nbErrors.' '.($nbErrors > 1 ? translate('errors') : translate('error')).'</h3>

<ol style="margin: 0 0 0 20px;">'; foreach ($errors AS $error)

echo '<li>'.$error.'</li>'; echo '

</ol> </div> <br />'; }

echo '

<div id="login">

<h1>'.Tools::htmlentitiesUTF8(Configuration::get('PS _SHOP_NAME')).'</h1>

<form

action="'.Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI'] ).'" method="post">';

$randomNb = rand(100, 999);

if (file_exists(PS_ADMIN_DIR.'/../install') OR

file_exists(PS_ADMIN_DIR.'/../admin')) {

echo ' <span>'.translate('For

security reasons, you cannot connect to the Back Office until after you have:').'<br /><br />

- '.translate('delete the /install

folder').'<br />

- '.translate('renamed the /admin folder (eg. ').'/admin'.$randomNb.')<br />

<br />'.translate('Please then access this page

by the new url (eg.

http://www.domain.tld/admin').$randomNb.')</span>'; }

else {

// If https enabled, we force it except if you try to log in from maintenance or local ip

if ( (empty($_SERVER['HTTPS']) OR

strtolower($_SERVER['HTTPS']) == 'off')

AND ( Configuration::get('PS_SSL_ENABLED') AND !$clientIsMaintenanceOrLocal)


(56)

)

echo '<div

class="error">'.$warningSslMessage.'</div>'; else

echo '<label for="email">'.translate('E-mail address:').'</label><br />

<input type="text" id="email" name="email"

value="'.Tools::safeOutput(Tools::getValue('email')).'" class="input"/>

<div style="margin: 1.8em 0 0 0;">

<label

for="passwd">'.translate('Password:').'</label><br />

<input id="passwd" type="password" name="passwd" class="input" value=""/>

</div> <div>

<div id="submit"><input type="submit" name="Submit" value="'.translate('Log in').'" class="button" /></div>

<div id="lost"><a href="password.php">'.translate('Lost

password?').'</a></div>

</div> ';

} ?>

<script type="text/javascript"> //<![CDATA[

if (document.getElementById('email'))

document.getElementById('email').focus(); //]]>

</script> <?php echo '

</form> </div>

<h2><a

href="http://www.prestashop.com">&copy; Copyright by PrestaShop. all rights reserved.</a></h2>

</div> </body> </html>';


(57)

DAFTAR PUSTAKA

Ducket, Jon, Beginning Web programming with HTML, XHTML and CSS, Wiley Publishing, Inc , 2007.

Kadir Abdul, Belajar Database Menggunakan MySQL , 2008 , Yogyakarta: Andi. Etahan Watrall, Jeff Siarto , Head First Web Design , O‟Reilly Media, Inc.,2009. M.Shalahuddin, Rosa A.S , Java Di Web , 2010, Bandung, Informatika.

Bruce Lawson, Remy Sharp , Introducing HTML 5, New Riders is an imprint ofPeachpit, a division of Pearson Education , 2011.

Raharjo , Budi , Belajar Pemrograman Web , Modula , 2011.

http://en.wikipedia.org/wiki/Data_flow_diagram. Diakses Selasa,15 April 2013 http://blogxaris.wordpress.com/2010/12/09/pengertian-dasar-dan-simbol-flowchart. Diakses Selasa, 15 April 2013

http://safrilblog.wordpress.com/2012/10/15/simbol-simbol-pada-flowchart-dan-penjelasannya-softskill/. Diakses Rabu, 16 April 2013


(1)

PERNYATAAN

SISTEM PENJUALAN PONSEL BERBASIS ECOMMERCE

TUGAS AKHIR

Saya mengakui bahwa tugas akhir ini adalah hasil kerja saya sendiri, kecuali beberapa kutipan yang masing-masing disebutkan sumbernya.

Medan, Juni 2013

VIVI SAUFINA 102406040


(2)

PENGHARGAAN

Bismillahhirrahmannirrahim

Puji dan syukur penulis ucapkan kehadirat Allah SWT yang telah memberikan Rahmat serta Hidayah kepada kita semua, sehingga berkat Karunian-Nya penulis dapat menyelesaikan Tugas Akhir dengan baik yang berjudul “ SISTEM PENJUALAN PONSEL BERBASIS ECOMMERCE “ pada waktu yang telah ditetapkan. Adapun penyusunan Tugas Akhir ini berdasarkan data yang penulis peroleh dari buku pedoman, situs internet, serta data dan keterangan dari bimbingan.

Penulis menyadari bahwa dalam penyusunan Tugas Akhir tidak terlepas dari dukungan serta bantuan berbagai pihak, oleh karena itu pada kesempatan ini penulis menyampaikan ucapan terima kasih kepada :

1. Kepada kedua orang tua saya H. Wahyuddin dan ibunda tercinta Hj. Yusnizar beserta seluruh adik dan kakak, yang senantiasa memberikan semangat, dukungan, kasih saying dan selalu mendoakan penulis agar lancer dalam setiap hal.

2. Bapak Dr. Saib Suwilo, M.Sc selaku Dosen Pembimbing Tugas Akhir Program Studi D3 Teknik Informatika Fakultas MIPA universitas Sumatera Utara yang telah memberikan bimbingan dan arahan selama ini kepada penulis dalam penyelesaian Tugas Akhir.

3. Bapak Dr.Sutarman, M.Sc selaku Dekan Fakultas MIPA Universitas Sumatera Utara.

4. Bapak Syahriol Sitorus, S.Si.,M.IT selaku Ketua Jurusan Program Studi D3 Teknik Informatika

5. Seluruh Staf Pengajar Studi D3 Teknik Informatika Fakultas MIPA Universitas Sumatera Utara yang telah memberikan ilmu dan pengetahuannya kepada penulis selama masa perkuliahan.


(3)

6. Buat seluruh sahabat dan kerabat penulis yang telah membantu dalam suka dan duka Anggi, Septi, Dwi, Icha, Vika, Irma dan yang paling teristimewa Ahmad Arif Abdi D serta seluruh keluaarga besar kom C‟10 yang berperan penting dalam menyelesaikan Tugaas Akhir ini.

7. Seluruh pihak yang telah banyak membantu penulis, yang tidak dapat penulis sebutkan namanya satu-persatu.

Penulis menyadari sepenuhnya bahwa dalam penyusunan laporan ini masih banyak kekurangan, karena keterbatasan pengetahuan dan kemampuan, untuk itu kritik dan saran yang membangun dari pembaca sangat diharapkan demi kesempurnaan Tugas Akhir ini.

Demikian penulis sampaikan dengan harapan Tugas Akhir ini dapat bermanfaat bagi pembaca dan penulis sendiri.

Medan, Juni 2013 Penulis


(4)

ABSTRAK

Sistem Penjualan Ponsel Berbasis Ecommerce ini bertujuan untuk mendapatkan pelanggan yang banyak, dan membuat pelanggan bisa tertarik dengan penjualan secara online dengan kualitas terbaik, dan harga yang murah dan terpercaya. Adapun fasilitas yang terddapat dalam aplikasi ini yaitu berupa profil perusahaan, katagori produk, produk, order pembelian, langkah-langkah pembelian, keranjang belanja , dan hubungi kami. Pada proses pembuatan aplikasi ini untuk bahasa pemrogramannya digunakan perangkat lunak CMS yang menggunakan Prestashop, Xampp, dan Adobe Photoshop sebagai editor grafis.


(5)

DAFTAR ISI

Halaman

Persetujuan ii

Pernyataan iii

Penghargaan iv

Abstrak vi

Daftar isi vii

Daftar Table x

Daftar Gambar xi

BAB 1 PENDAHULUAN

1.1 Latar Belakang 1

1.2 Identifikasi Masalah 2

1.3 Batasan Masalah 2

1.4 Rumusan Masalah 2

1.5 Tujuan 3

1.6 Manfaat 3

1.7 Sistematika Penulisan 4

BAB 2 LANDASAN TEORI

2.1 Pengertian Komputer 6

2.2 Sistem 6

2.3 Internet 7

2.3.1 Sejarah Internet 7

2.4 Ecommerce 8

2.5 Sejarah Ecommerce 12

BAB 3 PERANCANGAN SISTEM

3.1 Perancangan Sistem 14

3.2 Perancangan Data Flow Diagram 14

3.3 Perancangan Database 15

3.3.1 Field Name 16


(6)

3.5 Flowchart 19

3.5.1 Simbol – Simbol Flowchart 20

3.5.2 Flowchart Menu Utama 22

3.5.3 Flowchart pembelian Ponsel 23

3.5.3 Flowchart Login Admin 24

BAB 4 ANALISA HASIL DAN PEMBAHASAN

4.1 Pembuatan Program 25

4.1.1 Tampilan Menu Utama 25

4.1.2 Tampilan Menu Katagori 26

4.1.3 Tampilan Produk yang Pernah Di Lihat 27

4.1.4 Tampilan Produk-Produk Baru 28

4.1.5 Tampilan Cara Melihat Produk Beserta Keterangannya 29

4.1.6 Cara Menambahkan Produk ke Keranjang Belanja 31

4.1.7 Cara Melihat Daftar Belanja 32

4.1.8 Langkah-langkah Pengiriman Barang dan

Pembayaran barang 33

BAB 5 KESIMPULAN DAN SARAN

5.1 Kesimpulan 37

5.2 Saran 38

DAFTAR PUSTAKA 39

LAMPIRAN A : Surat Keterangan Uji Program dan Kartu Bimbingan Tugas Akhir