<?php
/*
###################################################################################
  Bigware Shop 2.3
  Release Datum: 23.08.2015
  
  Bigware Shop
  http://www.bigware.de

  Copyright (c) 2015 Bigware LTD
  (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
  (c) 2015	Bigware LTD

  Copyrightvermerke duerfen nicht entfernt werden.
  ------------------------------------------------------------------------
  Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
  der GNU General Public License, wie von der Free Software Foundation
  veroeffentlicht, weitergeben und/oder modifizieren, entweder gemaess Version 2 
  der Lizenz oder (nach Ihrer Option) jeder spaeteren Version.
  Die Veroeffentlichung dieses Programms erfolgt in der Hoffnung, dass es Ihnen
  von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die
  implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FUER EINEN
  BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License.
  
  Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
  Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

  Infos:
  ------------------------------------------------------------------------
  Der Bigware Shop wurde vor vielen Jahren bereits aus dem bekannten Shopsystem osCommerce
  weiter- und neuentwickelt.
  Der Bigware Shop legt im hohen Masse Wert auf Bedienerfreundlichkeit, beinhaltet eine leichte
  Installation, viele neue professionelle Werkzeuge und zeichnet sich aus durch eine grosse 
  Community, die bei Problemen weiterhelfen kann.
  
  Der Bigware Shop ist auf jedem System lauffaehig, welches eine PHP Umgebung
  (ab PHP 4.1.3) und mySQL zur Verfuegung stellt und auf Linux basiert.
 
  Hilfe erhalten Sie im Forum auf www.bigware.de 
  
  -----------------------------------------------------------------------
  
 ##################################################################################

Captcha f�r Bigware 2.1 by Ede & Tigerstyle


*/
?>
<?php
  require('load_this/load_this_bigware_10.php');
  $date_availability = 'AND (to_days(items_date_available_end) IS NULL OR (to_days(items_date_available_end) IS NOT NULL AND to_days(now()) <= to_days(items_date_available_end)))';
  
 //Captcha by Ede & Tigerstyle
$sql=go_db_query('SELECT * FROM captcha_settings');
$row=go_db_fetch_array($sql); 
$captcha_enable_37 = $row['captcha_enable_37'];

  
  if (!go_session_is_registered('attendee_id')) {
    $navigation->set_snapshot();
    go_forward(go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_40], '', 'SSL'));
  }
  $item_info_query = go_db_query("select p.items_id, p.items_model, p.items_picture, p.items_price, p.items_tax_class_id, pd.items_name from " . DB_TBL_ITEMS . " p, " . DB_TBL_ITEMS_DESCRIPTION . " pd where p.items_id = '" . (int)$_GET['items_id'] . "' and p.items_status = '1' and p.items_id = pd.items_id and pd.language_id = '" . (int)$languages_id . "' $date_availability");
  if (!go_db_num_rows($item_info_query)) {
    go_forward(go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_35], go_get_all_get_parameter(array('action'))));
  } else {
    $item_info = go_db_fetch_array($item_info_query);
  }
  $attendee_query = go_db_query("select attendees_firstname, attendees_lastname from " . DB_TBL_ATTENDEES . " where attendees_id = '" . (int)$attendee_id . "'");
  $attendee = go_db_fetch_array($attendee_query);
  if (isset($_GET['action']) && ($_GET['action'] == 'process')) {
    $rating = go_db_producing_input($_POST['rating']);
    $review = go_db_producing_input($_POST['review']);
    $error = false;
    if (strlen($review) < REVIEW_TEXT_MIN_LENGTH) {
      $error = true;
      $messageStack->add('review', JS_REVIEW_TEXT);
    }
    if (($rating < 1) || ($rating > 5)) {
      $error = true;
      $messageStack->add('review', JS_REVIEW_RATING);
    }

//Tigerstyle captcha test, sets error message and error flag
	if ($captcha_enable_37 == "ja"){
		if( empty($captcha_code) || empty($_POST['captcha_code']) || go_urlsafe_b64encode(go_CAP_RC4($_POST['captcha_code'])) != $captcha_code ) {
			$error = true;
			$messageStack->add('review', CAPTCHA_INVALID_TEXT );
		}
	}
	//END 
  

    if ($error == false) {
      go_db_query("insert into " . DB_TBL_REVIEWS . " (items_id, attendees_id, attendees_name, reviews_rating, date_added) values ('" . (int)$_GET['items_id'] . "', '" . (int)$attendee_id . "', '" . go_db_input($attendee['attendees_firstname']) . ' ' . go_db_input($attendee['attendees_lastname']) . "', '" . go_db_input($rating) . "', now())");
      $insert_id = go_db_insert_id();
      go_db_query("insert into " . DB_TBL_REVIERELATIV_DESCRIPTION . " (reviews_id, languages_id, reviews_text) values ('" . (int)$insert_id . "', '" . (int)$languages_id . "', '" . go_db_input($review) . "')");
      go_forward(go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_35], go_get_all_get_parameter(array('action'))));
            		// Tigerstyle captcha unregister here not needed anymore
		if ($captcha_enable_37 == "ja"){
			if (go_session_is_registered('captcha_code')) {
				go_session_unregister('captcha_code');
			}
		}
		//END 
     }
    }
  
  if ($new_price = go_get_items_special_price($item_info['items_id'])) {
    $items_price = '<s>' . $currencies->display_price($item_info['items_price'], go_get_tax_rate($item_info['items_tax_class_id'])) . '</s> <span class="itemSpecialPrice">' . $currencies->display_price($new_price, go_get_tax_rate($item_info['items_tax_class_id'])) . '</span>';
  } else {
    $items_price = $currencies->display_price($item_info['items_price'], go_get_tax_rate($item_info['items_tax_class_id']));
  }
  if (go_not_null($item_info['items_model'])) {
    $items_name = $item_info['items_name'] . '<br><span class="smallText">[' . $item_info['items_model'] . ']</span>';
  } else {
    $items_name = $item_info['items_name'];
  }
  
  //Captcha by Ede & Tigerstyle
if ($captcha_enable_37 == "ja") {  
// captcha generate a new captcha image and code, encoded and encrypt, register the code with session for testing $_POST
  $captcha_code = go_captcha_image();
    go_session_register('captcha_code');
  }
  //END
  require(FOLDER_RELATIV_LANGUAGES . $language . '/' . $GLOBALS[CONFIG_NAME_FILE][main_bigware_37]);
  
  $breadcrumb->add(NAVBAR_TITLE, go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_35], go_get_all_get_parameter()));
  $content = $GLOBALS[CONFIG_SHOW_FILE][main_bigware_37];
  $javascript = $content . '.js';
  require(FOLDER_RELATIV_TEMPLATES . TEMPLATENAME_MAIN_PAGE);
  require(FOLDER_RELATIV_INCLUDES . 'load_this_bigware_3.php');
?>
