• Tidak ada hasil yang ditemukan

Aplikasi toko online berbasiskan teknologi CMS (Content Management System) yang penulis kembangkan ini masih terdapat beberapa kekurangan. Oleh karena itu, penulis juga ingin menyampaikan beberapa saran guna menambah manfaat penelitian ini, yaitu :

1) Dengan berkembangnya teknologi seluler, penulis berharap akan ada pengembangan lanjutan untuk akses aplikasi ini melalui ponsel.

2) Melakukan evaluasi sistem secara berkala untuk mengantisipasi penambahan kebutuhan sistem sebagai contoh penambahan jenis produk yang akan datang atau perubahan harga produk barang.

3) Content website e-commerce perlu ditambah untuk menarik lebih banyak pembeli.

DAFTAR PUSTAKA

Alipha, Beberapa macam jenis CMS, 2009,

(http://alipha.net/category/blogger/ diakses 2 Desember 2009 pukul

10.15 WIB).

B2C, (http://www.cert.or.id/~budi/articles/1999-02.pdf , diakses tanggal 20 Desember 2009 pukul 14.00 WIB).

Chaudhury, Abijit & Jean-Pierre Kuilboer, 2002, e-Business and e-Commerce Infrastructure, McGraw-Hill.

Date, C.J, 2005, Pengenalan Sistem Basis Data Jilid 2 Edisi ketujuh, Indeks, Jakarta. xviii + 472 hlm.

E-commerce, (http://r-marpaung.tripod.com/ElectronicCommerce.doc diakses tanggal 20 Desember 2009 pukul 10.44 WIB).

(http://www.nofieiman.com diakses tanggal 20 Desember 2009

pukul 12.04 WIB).

Hartono, Jogiyanto, 1999, Analisis & Disain Sistem Informasi : pendekatan terstruktur teori dan praktek aplikasi bisnis, Andi, Yogyakarta.

Jenis-jenis E-commerce, (http://www.cert.or.id/~budi/articles/1999-02.pdf , diakses tanggal 20 Desember 2009 pukul 12.15 WIB).

Kendall, K.E. dan Julie E. Kendall. 2003. Analisis dan Perancangan Sistem. Edisi Terjemahan. PT Intan Sejati : Klaten.

Paypal, www.paypal.com diakses pada tanggal 2 Juni 2010 pukul 19.34 WIB.

Peranginangin, Kasiman, 2006, Aplikasi Web dengan PHP dan MySQL, Andi, Yogyakarta.

Pressman, Roger S, 2001, Software Engineering A Practioner’s Approach 5th edition, Mc Graw Hill.

Prestashop Country codes,

http://www.iso.org/iso/country_codes/iso_3166_code_lists/english

_country_names_and_code_elements.htm. diakses pada 20

November 2009 pukul 14.00 WIB.

Prestashop Download,

http://www.prestashop.com/download/prestashop_1.2.5.0.zip

diakses pada 20 November 2009 pukul 11.05 WIB.

Prestashop Forum,

www.prestashop.com/forum/ diakses pada 22 November 2009

pukul 21.55 WIB.

Prestashop Icon Flags,

http://www.famfamfam.com/lab/icons/flags/ diakses pada 25

November 2009 pukul 20.00 WIB.

Prestashop Language,

http://www.prestashop.com/download/lang_packs/gzip/id.gzip

Prestashop Wiki,

www.prestashop.com/wiki/ diakses pada 14 November 2009

pukul 22.10 WIB.

Recaptcha, http://www.recaptcha.net diakses pada 3 Juni 2010 pukul 11.00 WIB.

Rahimsyah, MB, 2002, Kamus Komputer dan Internet, Aprindo, Jakarta.

Rohmatullah, Amin, 2009, Panduan membuat toko online,

http://wgtt.org diakses pada 5 Januari 2010 pukul 15.32 WIB.

Setiawan, Deris, 2002, E-Commerce,Corbis.com.

Suprianto, Dodit, 2008, Buku Pintar Pemrograman PHP, OASE Media, Bandung.

Sutanta, Edhy, 2005. Pengantar Teknologi Informasi, Graha Ilmu, Yogyakarta.

Stallings, William, 2002, Komunikasi Data dan Komputer Jaringan Komputer, Salemba Teknika,Jakarta.

Wikipedia, XAMPP,

http://en.wikipedia.org/wiki/Xampp diakses pada 14 November

2009 pukul 22.24 WIB.

Wikipedia, E-Commerce, 2010,

http://wartawarga.gunadarma.ac.id/2010/02/e-commerce-34/

LAMPIRAN A

WAWANCARA

LAMPIRAN A WAWANCARA

A.1. Wawancara Dengan Owner Batik Shop

Tanggal : 1 November 2009 Narasumber : Sitti Salamah

Bagaimana menurut ibu mengenai sistem berbelanja dan bertransaksi secara stand alone ( berdiri sendiri ) saat ini yang masih dijalankan pada batik shop?

Sistem yang saat ini diterapkan menurut saya masih termasuk belum efektif. Batik shop membutuhkan suatu wadah untuk mempromosikan produk secara lebih luas lagi, sehingga konsumen pun tidak hanya sebatas satu kota saja.

Apakah ada kendala di dalam sistem yang berjalan saat ini ?

Kendalanya adalah konsumen harus datang langsung ke toko untuk dapat berbelanja produk dan bertransaksi.

Bagaimana mengatasi kendala-kendala tersebut?

Belum ada cara untuk mengatasi kendala-kendala tersebut.

Apa harapan bapak / ibu terhadap sistem yang ada sekarang?

supaya batik shop memiliki wadah untuk mempromosikan produknya 24 jam non stop dan pelanggan toko tidak hanya datang dari 1 kota saja, sehingga nantinya diharapkan dapat menambah income bagi batik shop.

A.2 Wawancara dengan Konsumen Batik Shop

Tanggal : 27 Desember 2009 Narasumber : Sitti Thoyibah

Bagaimana menurut bapak / ibu mengenai sistem berbelanja dan bertransaksi secara stand alone ( berdiri sendiri ) saat ini yang masih dijalankan pada batik shop ?

Sistem yang berjalan saat ini masih manual dan tidak efektif.

Apakah ada kendala di dalam sistem yang berjalan saat ini ?

Bagi pelanggan dari luar kota harus datang langsung ke toko.

Bagaimana mengatasi kendala-kendala tersebut?

Belum ada cara mengatasinya.

Apa harapan bapak / ibu terhadap sistem yang ada sekarang?

Saya berharap adanya perubahan cara supaya lebih efektif dan tepat waktu.

LAMPIRAN B

KUESIONER UJICOBA ADMIN Batik Shop Online

( Webshopping )

__________________________________________________________________

Nama : Jabatan :

Silakan dijawab sesuai dengan pendapat anda setelah mencoba Aplikasi Batik Shop dengan melingkari salah satu jawaban.

1. Bagaimanakah tampilan dari aplikasi webshopping batik shop ini?

a. Kurang baik b. Cukup Baik c. Baik d. Sangat baik

2. Bagaimanakah struktur menu navigasi dalam aplikasi ini?

a. Kurang jelas b. Cukup Jelas c. Jelas d. Sangat jelas

3. Bagaimanakah prosedur pengoperasian Batik shop online ini?

a. Sangat sulit b. Sulit c. Mudah d. Sangat mudah

4. Sebagai aplikasi toko online, apakah fasilitas yang tersedia pada aplikasi ini sudah cukup memadai?

a. Kurang memadai b. Cukup memadai c. Memadai d.Sangat memadai

5. Apakah menu admin ( Back office ) pada Batik shop online ini dapat membantu anda mengelola sistem?

a. Ya b. Tidak

Jakarta, 20 Februari 2010

KUESIONER UJICOBA USER Batik Shop Online

( Webshopping )

__________________________________________________________________

Nama : Pelerjaan :

Silakan dijawab sesuai dengan pendapat Bapak / Ibu setelah mencoba Aplikasi Batik shop online ini dengan melingkari salah satu jawaban.

1. Bagaimanakah tampilan dari aplikasi Batik shop online ini?

a. Kurang baik b. Cukup Baik c. Baik d. Sangat baik

2. Bagaimanakah struktur menu navigasi dalam Batik shop online ini?

a. Kurang jelas b. Cukup Jelas c. Jelas d. Sangat jelas

3. Bagaimanakah prosedur pengoperasian Batik shop ini?

a. Sangat sulit b. Sulit c. Mudah d. Sangat mudah

4. Sebagai aplikasi toko online, apakah fitur yang tersedia pada Batik shop online ini sudah cukup memadai?

a. Kurang memadai b. Cukup memadai c. Memadai d.Sangat memadai

5. Apakah Batik shop online ini dapat membantu pelanggan dalam mengetahui detail produk tanpa harus datang ke toko secara langsung?

a. Ya b. Tidak

Jakarta,2 Maret 2010

LAMPIRAN C

1. Halaman Home

3. Halaman User login

5. Halaman Contact Us

7. Halaman Shipping (Pengiriman)

11.Halaman Add Sub Kategory

13.Halaman Upload 2

15.Halaman Admin

LAMPIRAN D

SOURCE CODE

1. Online help yahoo messenger

<div id="informations_block_left" class="block">

<h4>{l s="Online Help" mod="onlinehelp"}</h4>

<ul class="block_content">

<div align="center">Yahoo Messenger Online Help<br>

<a href="ymsgr:sendim?novie_pumpkins"><imgsrc="http://opi.yahoo .com/online?u=novie_pumpkins&m=g&t=14" width="128" height="100" border=0></a></div> </ul> </div>

2. Image slideshow s3slider

<!-- Module Editorial -->

<div id="editorial_block_center" class="editorial_block">

<script type="text/javascript" src="{$this_path}s3Slider.js"></script> <script type="text/javascript"> {literal} $(document).ready(function() {$('#slider').s3Slider({timeOut: 3000});}); {/literal} </script> <style type="text/css">@import url({$this_path}editorial.css);</style> <div id="slider"> <ul id="sliderContent"> <li class="sliderImage">

<a href=""><img src="{$this_path}1.jpg" alt="1" /></a>

<span class="bottom"><strong>Selamat datang di toko pakaian

batik online kami</strong><br />Batik Shop</span>

</li>

<li class="sliderImage">

<a href=""><img src="{$this_path}2.jpg" alt="2" /></a>

<span class="bottom"><strong>BATIK SHOP</strong><br />Batik

merupakan warisan budaya yang tak ternilai, salah satu

kebanggaan Indonesia yang telah diakui dunia.</span>

</li>

<li class="sliderImage">

<img src="{$this_path}3.jpg" alt="3" />

<span class="bottom"><strong>Title text 2</strong><br

/>Content text...</span>

</li>

<div class="clear sliderImage"></div>

</ul> <div class="clear"></div> </div> </div> <!-- /Module Editorial --> <!-- Module Editorial -->

<div id="editorial_block_center" class="editorial_block">

{if $xml->body->home_logo_link}<a

href="{$xml->body->home_logo_link|escape:'htmlall':'UTF-8'}"

{if $homepage_logo}<img src="{$this_path}homepage_logo.jpg" alt="{$xml->body->$title|escape:'htmlall':'UTF-8'|stripslashes}" />{/if} {if $xml->body->home_logo_link}</a>{/if} {if $xml->body->$logo_subheading}{$xml->body->$logo_subheading|stripslashes}{/if} {if $xml->body->$title}<h2>{$xml->body->$title|stripslashes}</h2>{/if} {if $xml->body->$subheading}<h3>{$xml->body->$subheading|stripslashes}</h3>{/if}

{if $xml->body->$paragraph}<div

class="rte">{$xml->body->$paragraph|stripslashes}</div>{/if}

</div>

<!-- /Module Editorial -->

2. Images enlarge

<link rel="stylesheet" type="text/css"

href="{$module_dir}imagesenlarge.css" />

<!-- MODULE images enlarge -->

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

var setAnimationStatus = {$animationStatus};

var extendedZoomSatus = {$extendedZoom};

</script>

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

src="{$module_dir}imagesenlarge.js"></script>

3. Captcha Code (Contact UsForm.php) <?php $useSSL = true; include(dirname(__FILE__).'/config/config.inc.php'); include(dirname(__FILE__).'/header.php'); include(dirname(__FILE__).'/enginerecaptcha/recaptchalib.php '); include(dirname(__FILE__).'/modules/recaptcha/recaptcha.php' ); $errors = array(); //instant recaptcha

$recaptcha = new Recaptcha(); $smarty->assign('contacts', Contact::getContacts(intval($cookie->id_lang))); if (Tools::isSubmit('submitMessage')) { //reCaptcha cek if ($recaptcha->isActive()) if ($_POST["recaptcha_response_field"]) $resp = recaptcha_check_answer ($recaptcha->getPrivateKey(), $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!($from = Tools::getValue('from')) OR !Validate::isEmail($from))

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

elseif (!($message =

nl2br2(Tools::getValue('message'))))

$errors[] = Tools::displayError('message cannot be blank');

elseif (!Validate::isMessage($message))

$errors[] = Tools::displayError('invalid message'); elseif (!($id_contact =

intval(Tools::getValue('id_contact'))) OR !(Validate::isLoadedObject($contact = new

Contact(intval($id_contact), intval($cookie->id_lang))))) $errors[] = Tools::displayError('please select a contact in the list');

//cek recaptcha

elseif (!isset($resp) and $recaptcha->isActive()) $errors[] = Tools::displayError('Image Verification ERROR, please try again');

elseif (!$resp->is_valid and $recaptcha->isActive()) $errors[] = Tools::displayError('Image Verification ERROR, please try again');

else {

if (intval($cookie->id_customer))

$customer = new Customer(intval($cookie->id_customer));

if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $_POST['from'], '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : $from)))

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

$errors[] = Tools::displayError('an error occurred while sending message');

} }

$email = Tools::safeOutput(Tools::getValue('from', ((isset($cookie) AND isset($cookie->email) AND

Validate::isEmail($cookie->email)) ? $cookie->email : ''))); $smarty->assign(array( 'errors' => $errors, 'email' => $email )); if ($recaptcha->isActive()) { $smarty->assign('userecaptcha', 1); $smarty->assign('recaptcha', recaptcha_get_html($recaptcha->getPublicKey())); } $smarty->display(_PS_THEME_DIR_.'contact-form.tpl'); include(dirname(__FILE__).'/footer.php'); ?>

4. Captcha Code (Validator.php)

<?php include(dirname(__FILE__).'/config/config.inc.php'); include(dirname(__FILE__).'/init.php'); if ($cookie->isLogged()) Tools::redirect('my-account.php'); $errors = array(); if (!Validate::isEmail($email = Tools::getValue('m'))) $errors[] = Tools::displayError('invalid e-mail address');

$key = Tools::getValue('k');

if (!empty($email) && !empty($key)) {

$customer = new Customer();

$mail_ok = $customer->getByEmail(trim($email), NULL, 1);

if ($customer->active == 2) {

$validation_link = sha1('g$p_'.$customer->firstname.$customer->id);

if (($customer->email == trim($email)) && $validation_link == $key && $customer->id && $mail_ok) {

$customer->active = 1; $customer->update();

}

else $errors[] = Tools::displayError('invalid validation link');

}

else $errors[] = Tools::displayError('account already activated'); include(dirname(__FILE__).'/header.php'); $smarty->assign('errors', $errors); $smarty->display(_PS_THEME_DIR_.'validator.tpl'); include(dirname(__FILE__).'/footer.php'); } else Tools::redirect('my-account.php'); ?>

5. Captcha Code (Aunthentication.php)

<?php /* SSL Management */ $useSSL = true; include(dirname(__FILE__).'/config/config.inc.php'); include(dirname(__FILE__).'/init.php'); include(dirname(__FILE__).'/enginerecaptcha/recaptchalib.php '); include(dirname(__FILE__).'/modules/recaptcha/recaptcha.php' ); if ($cookie->isLogged()) Tools::redirect('my-account.php'); //CSS ans JS file calls

$js_files = array(

_THEME_JS_DIR_.'tools/statesManagement.js' );

$errors = array(); //instant recaptcha

$recaptcha = new Recaptcha(); $back = Tools::getValue('back'); if (!empty($back)) $smarty->assign('back', Tools::safeOutput($back)); if (Tools::getValue('create_account')) { $create_account = 1; $smarty->assign('email_create', 1); } if (Tools::isSubmit('SubmitCreate')) { if (!Validate::isEmail($email = Tools::getValue('email_create')))

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

elseif (Customer::customerExists($email)) $errors[] = Tools::displayError('someone has already registered with this e-mail address');

else {

$create_account = 1; $smarty->assign('email_create', Tools::safeOutput($email)); $_POST['email'] = $email; } } if (Tools::isSubmit('submitAccount')) { $create_account = 1; $smarty->assign('email_create', 1); //reCaptcha cek if ($recaptcha->isActive()) if ($_POST["recaptcha_response_field"]) $resp = recaptcha_check_answer ($recaptcha->getPrivateKey(), $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!Validate::isEmail($email = Tools::getValue('email')))

$errors[] = Tools::displayError('e-mail not valid'); elseif (!Validate::isPasswd(Tools::getValue('passwd'))) $errors[] = Tools::displayError('invalid password'); elseif (Customer::customerExists($email)) $errors[] = Tools::displayError('someone has already registered with this e-mail address');

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

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

$errors[] = Tools::displayError('invalid birthday');

//cek recaptcha

elseif (!isset($resp) and $recaptcha->isActive()) $errors[] = Tools::displayError('Image Verification ERROR, please try again');

elseif (!$resp->is_valid and $recaptcha->isActive()) $errors[] = Tools::displayError('Image Verification ERROR, please try again');

else {

$customer = new Customer();

if (Tools::isSubmit('newsletter')) { $customer->ip_registration_newsletter = pSQL($_SERVER['REMOTE_ADDR']); $customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s')); }

$customer->birthday = (empty($_POST['years']) ? '' : intval($_POST['years']).'-'.intval($_POST['months']).'-'.intval($_POST['days']));

/* Customer and address, same fields, caching data */

$addrLastname = isset($_POST['lastname']) ? $_POST['lastname'] : $_POST['customer_lastname'];

$addrFirstname = isset( $_POST['firstname']) ? $_POST['firstname'] : $_POST['customer_firstname']; $_POST['lastname'] = $_POST['customer_lastname']; $_POST['firstname'] = $_POST['customer_firstname']; $errors = $customer->validateControler(); $_POST['lastname'] = $addrLastname; $_POST['firstname'] = $addrFirstname; $address = new Address();

$address->id_customer = 1; $errors = array_unique(array_merge($errors, $address->validateControler())); if (!sizeof($errors)) { $customer->active = 2; if (!$customer->add())

$errors[] = Tools::displayError('an error occurred while creating your account');

else { $address->id_customer = intval($customer->id); if (!$address->add()) $errors[] = Tools::displayError('an error occurred while creating your address');

else { $validation_link = 'validator.php?m='.$customer- >email.'&k='.sha1('g$p_'.$customer->firstname.$customer->id); if (Mail::Send(intval($cookie->id_lang), 'account', 'Welcome!', array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd'), '{validation_link}' => $validation_link), >email, $customer->firstname.' '.$customer->lastname)) $smarty->assign('confirmation', 1); Module::hookExec('createAccount', array( '_POST' => $_POST,

'newCustomer' => $customer )); if ($back) Tools::redirect($back); } } } } } if (Tools::isSubmit('SubmitLogin')) { $passwd = trim(Tools::getValue('passwd')); $email = trim(Tools::getValue('email')); if (empty($email))

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

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

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

elseif (empty($passwd))

$errors[] = Tools::displayError('password is required');

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

$errors[] = Tools::displayError('password is too long'); elseif (!Validate::isPasswd($passwd)) $errors[] = Tools::displayError('invalid password'); else {

$customer = new Customer(); $authentication = $customer->getByemail(trim($email), trim($passwd));

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

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

$errors[] = Tools::displayError('authentication failed');

$errors[] = Tools::displayError('did you

activate your account by clicking the link in the register mail?'); } else { $cookie->id_customer = intval($customer->id); $cookie->customer_lastname = $customer->lastname; $cookie->customer_firstname = $customer->firstname; $cookie->logged = 1; $cookie->passwd = $customer->passwd; $cookie->email = $customer->email;

if

(Configuration::get('PS_CART_FOLLOWING') AND (empty($cookie->id_cart) OR Cart::getNbProducts($cookie-(empty($cookie->id_cart) == 0)) $cookie->id_cart = intval(Cart::lastNoneOrderedCart(intval($customer->id))); Module::hookExec('authentication'); if ($back = Tools::getValue('back')) Tools::redirect($back); Tools::redirect('my-account.php'); } } } if (isset($create_account)) {

/* Generate years, months and days */ if (isset($_POST['years']) AND is_numeric($_POST['years'])) $selectedYears = intval($_POST['years']); $years = Tools::dateYears(); if (isset($_POST['months']) AND is_numeric($_POST['months'])) $selectedMonths = intval($_POST['months']); $months = Tools::dateMonths(); if (isset($_POST['days']) AND is_numeric($_POST['days'])) $selectedDays = intval($_POST['days']); $days = Tools::dateDays();

/* Select the most appropriate country */ if (isset($_POST['id_country']) AND is_numeric($_POST['id_country'])) $selectedCountry = intval($_POST['id_country']); elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $array = split(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); if (Validate::isLanguageIsoCode($array[0])) { $selectedCountry = Country::getByIso($array[0]); if (!$selectedCountry) $selectedCountry = intval(Configuration::get('PS_COUNTRY_DEFAULT')); } } if (!isset($selectedCountry)) $selectedCountry = intval(Configuration::get('PS_COUNTRY_DEFAULT')); $countries = Country::getCountries(intval($cookie->id_lang), true); $smarty->assign(array( 'years' => $years, 'sl_year' => (isset($selectedYears) ? $selectedYears : 0),

'months' => $months, 'sl_month' => (isset($selectedMonths) ? $selectedMonths : 0), 'days' => $days, 'sl_day' => (isset($selectedDays) ? $selectedDays : 0), 'countries' => $countries, 'sl_country' => (isset($selectedCountry) ? $selectedCountry : 0) ));

/* Call a hook to display more information on form */ $smarty->assign('HOOK_CREATE_ACCOUNT_FORM', Module::hookExec('createAccountForm'));

}

include(dirname(__FILE__).'/header.php');

$smarty->assign('errors', $errors);

//added for recaptcha

if ($recaptcha->isActive()) { $smarty->assign('userecaptcha', 1); $smarty->assign('recaptcha', recaptcha_get_html($recaptcha->getPublicKey())); } Tools::safePostVars(); $smarty->display(_PS_THEME_DIR_.'authentication.tpl'); include(dirname(__FILE__).'/footer.php'); ?> 6. Recaptchalib.php <?php /*

* This is a PHP library that handles calling reCAPTCHA. * - Documentation and latest version

* http://recaptcha.net/plugins/php/ * - Get a reCAPTCHA API Key

* http://recaptcha.net/api/getkey * - Discussion group

* http://groups.google.com/group/recaptcha *

* Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net * AUTHORS:

* Mike Crawford * Ben Maurer *

* Permission is hereby granted, free of charge, to any person obtaining a copy

* of this software and associated documentation files (the "Software"), to deal

* in the Software without restriction, including without limitation the rights

* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

* copies of the Software, and to permit persons to whom the Software is

* furnished to do so, subject to the following conditions: *

* The above copyright notice and this permission notice shall be included in

* all copies or substantial portions of the Software. *

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN

* THE SOFTWARE. */

/**

* The reCAPTCHA server URL's */ define("RECAPTCHA_API_SERVER", "http://api.recaptcha.net"); define("RECAPTCHA_API_SECURE_SERVER", "https://api-secure.recaptcha.net"); define("RECAPTCHA_VERIFY_SERVER", "api-verify.recaptcha.net"); /**

* Encodes the given data into a query string format * @param $data - array of string elements to be encoded * @return string - encoded request

*/

function _recaptcha_qsencode ($data) { $req = "";

foreach ( $data as $key => $value ) $req .= $key . '=' . urlencode( stripslashes($value) ) . '&';

// Cut the last '&'

$req=substr($req,0,strlen($req)-1); return $req;

}

/**

* Submits an HTTP POST to a reCAPTCHA server * @param string $host

* @param array $data * @param int port

* @return array response */

function _recaptcha_http_post($host, $path, $data, $port = 80) {

$req = _recaptcha_qsencode ($data);

$http_request = "POST $path HTTP/1.0\r\n"; $http_request .= "Host: $host\r\n";

$http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";

$http_request .= "Content-Length: " . strlen($req) . "\r\n";

$http_request .= "User-Agent: reCAPTCHA/PHP\r\n"; $http_request .= "\r\n";

$http_request .= $req;

$response = '';

if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {

die ('Could not open socket'); }

fwrite($fs, $http_request);

while ( !feof($fs) )

$response .= fgets($fs, 1160); // One TCP-IP packet

fclose($fs);

$response = explode("\r\n\r\n", $response, 2);

return $response; }

/**

* Gets the challenge HTML (javascript and non-javascript version).

* This is called from the browser, and the resulting reCAPTCHA HTML widget

* is embedded within the HTML form it was called from. * @param string $pubkey A public key for reCAPTCHA * @param string $error The error given by reCAPTCHA (optional, default is null)

* @param boolean $use_ssl Should the request be made over ssl? (optional, default is false)

* @return string - The HTML to be embedded in the user's form.

*/

function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)

if ($pubkey == null || $pubkey == '') {

die ("To use reCAPTCHA you must get an API key from <a href='http://recaptcha.net/api/getkey'>http://recaptcha.net/ api/getkey</a>"); } if ($use_ssl) { $server = RECAPTCHA_API_SECURE_SERVER; } else { $server = RECAPTCHA_API_SERVER; } $errorpart = ""; if ($error) {

$errorpart = "&amp;error=" . $error; }

return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>

<noscript>

<iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/> <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/> </noscript>'; } /**

* A ReCaptchaResponse is returned from recaptcha_check_answer() */ class ReCaptchaResponse { var $is_valid; var $error; } /**

* Calls an HTTP POST function to verify if the user's guess was correct

* @param string $privkey * @param string $remoteip * @param string $challenge * @param string $response

* @param array $extra_params an array of extra variables to post to the server

* @return ReCaptchaResponse */

function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array())

{

if ($privkey == null || $privkey == '') {

die ("To use reCAPTCHA you must get an API key from <a

href='http://recaptcha.net/api/getkey'>http://recaptcha.net/ api/getkey</a>");

}

if ($remoteip == null || $remoteip == '') {

die ("For security reasons, you must pass the remote ip to reCAPTCHA");

Dokumen terkait