Ejemplo n.º 1
0
 function save()
 {
     $voteClass = hikashop_get('class.vote');
     if (!count($_POST)) {
         $app = JFactory::getApplication();
         $app->redirect(preg_replace('#ctrl=vote&task=save&[0-9a-z=]+#', '', preg_replace('#/vote/save/[0-9a-z-]+#', '', hikashop_currentURL())), '', 'message', true);
     }
     $element = new stdClass();
     $element->hikashop_vote_type = JRequest::getVar('hikashop_vote_type', 0, 'default', 'string', 0);
     $element->vote_ref_id = JRequest::getVar('hikashop_vote_ref_id', 0, 'default', 'int');
     if (empty($element->vote_ref_id)) {
         $element->vote_ref_id = JRequest::getVar('hikashop_vote_product_id', 0, 'default', 'int');
     }
     $element->user_id = JRequest::getVar('hikashop_vote_user_id', 0, 'default', 'int');
     $element->pseudo_comment = JRequest::getVar('pseudo_comment', 0, 'default', 'string', 0);
     $element->email_comment = JRequest::getVar('email_comment', 0, 'default', 'string', 0);
     $element->vote_type = JRequest::getVar('vote_type', 0, 'default', 'string', 0);
     $element->vote = JRequest::getVar('hikashop_vote', 0, 'default', 'int');
     $element->comment = JRequest::getVar('hikashop_vote_comment', '', '', 'string', JREQUEST_ALLOWRAW);
     // JRequest::getVar('hikashop_vote_comment', 0, 'default', 'string', 0);
     $element->comment = urldecode($element->comment);
     if (!empty($element->comment) || !empty($element->vote) || !empty($element->email_comment) || !empty($element->pseudo_comment) || $element->hikashop_vote_type == 'useful') {
         $voteClass->save($element);
     } else {
         echo '0';
     }
     exit;
 }
Ejemplo n.º 2
0
 function onAfterRoute()
 {
     $app = JFactory::getApplication();
     if ($app->isAdmin() || @$_REQUEST['tmpl'] == 'component') {
         return true;
     }
     if (empty($_REQUEST['ctrl'])) {
         $_REQUEST['ctrl'] = @$_REQUEST['view'];
     }
     if (empty($_REQUEST['task'])) {
         $_REQUEST['task'] = @$_REQUEST['layout'];
     }
     if (@$_REQUEST['option'] == 'com_hikashop' && (@$_REQUEST['ctrl'] == 'checkout' || @$_REQUEST['ctrl'] == 'order' && @$_REQUEST['task'] == 'pay')) {
         return true;
     }
     if (@$_REQUEST['option'] == 'com_ccidealplatform' && @$_REQUEST['task'] == 'bankform') {
         return true;
     }
     if (!empty($_POST)) {
         return true;
     }
     if (!defined('DS')) {
         define('DS', DIRECTORY_SEPARATOR);
     }
     if (!(include_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_hikashop' . DS . 'helpers' . DS . 'helper.php')) {
         return true;
     }
     if (hikashop_isSSL()) {
         $app->setUserState('com_hikashop.ssl_redirect', 0);
         $app->redirect(str_replace('https://', 'http://', hikashop_currentURL()));
     }
     return true;
 }
Ejemplo n.º 3
0
Archivo: vote.php Proyecto: rodhoff/MNW
 function save()
 {
     $voteClass = hikashop_get('class.vote');
     if (!count($_POST)) {
         $app = JFactory::getApplication();
         $app->redirect(preg_replace('#ctrl=vote&task=save&[0-9a-z=]+#', '', preg_replace('#/vote/save/[0-9a-z-]+#', '', hikashop_currentURL())), '', 'message', true);
     }
     $hikashop_vote_type = JRequest::getVar('hikashop_vote_type', 'update', 'default', 'string', 0);
     $element = new stdClass();
     $element->vote_type = JRequest::getVar('vote_type', '', 'default', 'string', 0);
     if ($hikashop_vote_type == 'useful') {
         $element->vote_id = JRequest::getVar('hikashop_vote_id', 0, 'default', 'int');
         $element->value = JRequest::getVar('value', 0, 'default', 'int');
         $voteClass->saveUseful($element);
     } else {
         $element->vote_ref_id = JRequest::getVar('hikashop_vote_ref_id', 0, 'default', 'int');
         if (empty($element->vote_ref_id) || $element->vote_ref_id == '0') {
             $element->vote_ref_id = JRequest::getVar('hikashop_vote_product_id', 0, 'default', 'int');
         }
         $element->vote_user_id = JRequest::getVar('hikashop_vote_user_id', 0, 'default', 'int');
         if ($element->vote_user_id == '0') {
             $element->vote_user_id = hikashop_loadUser();
         }
         $element->vote_pseudo = JRequest::getVar('pseudo_comment', 0, 'default', 'string', 0);
         $element->vote_email = JRequest::getVar('email_comment', 0, 'default', 'string', 0);
         $element->vote_type = JRequest::getVar('vote_type', '', 'default', 'string', 0);
         $element->vote_rating = JRequest::getVar('hikashop_vote', 0, 'default', 'int');
         $element->vote_comment = JRequest::getVar('hikashop_vote_comment', '', '', 'string', JREQUEST_ALLOWRAW);
         // JRequest::getVar('hikashop_vote_comment', 0, 'default', 'string', 0);
         $element->vote_comment = urldecode($element->vote_comment);
         $voteClass->save($element);
     }
     $return = array();
     if (!isset($voteClass->error) || empty($voteClass->error['code'])) {
         $return['error'] = array('code' => '500001', 'message' => JText::_('VOTE_ERROR'));
     } elseif ((int) $voteClass->error['code'] > 500000) {
         $return['error'] = array('code' => $voteClass->error['code'], 'message' => $voteClass->error['message']);
     } else {
         $return['success'] = array('code' => $voteClass->error['code'], 'message' => $voteClass->error['message']);
         if (!empty($voteClass->values)) {
             $return['values'] = array('average' => round($voteClass->values['average'], 2), 'rounded' => round($voteClass->values['average']), 'total' => $voteClass->values['total']);
             $return['tooltip'] = JText::sprintf('HIKA_VOTE_TOOLTIP', round($voteClass->values['average'], 2), $voteClass->values['total'], $element->vote_rating);
         }
     }
     ob_get_clean();
     echo json_encode($return);
     exit;
 }
Ejemplo n.º 4
0
            if (HK_GRID_THUMBNAILS !== false && HK_GRID_THUMBNAILS != '') {
                echo '</ul>';
            }
            echo '</div>';
        }
    }
    ?>
<div style="clear:both"></div>

	</div>
	<?php 
    if (in_array($pagination, array('bottom', 'both')) && $this->params->get('show_limit') && $this->pageInfo->elements->total > $this->pageInfo->limit->value) {
        $this->pagination->form = '_bottom';
        ?>
	<form action="<?php 
        echo hikashop_currentURL();
        ?>
" method="post" name="adminForm_<?php 
        echo $this->params->get('main_div_name') . $this->category_selected;
        ?>
_bottom">
		<div class="hikashop_subcategories_pagination hikashop_subcategories_pagination_bottom">
		<?php 
        echo $this->pagination->getListFooter($this->params->get('limit'));
        ?>
		<span class="hikashop_results_counter"><?php 
        echo $this->pagination->getResultsCounter();
        ?>
</span>
		</div>
		<input type="hidden" name="filter_order_<?php 
Ejemplo n.º 5
0
    function productDisplay()
    {
        $app = JFactory::getApplication();
        $db = JFactory::getDBO();
        $editor_name = JRequest::getString('editor_name', 'jform_articletext');
        $pageInfo = new stdClass();
        $pageInfo->limit = new stdClass();
        $pageInfo->search = $app->getUserStateFromRequest("com_content.productbutton.search", 'search', '', 'string');
        $pageInfo->search = JString::strtolower(trim($pageInfo->search));
        $pageInfo->limit->value = $app->getUserStateFromRequest('com_content.productbutton.limit', 'limit', $app->getCfg('list_limit'), 'int');
        $pageInfo->limit->start = $app->getUserStateFromRequest('com_content.productbutton.limitstart', 'limitstart', 0, 'int');
        if (JRequest::getVar('search') != $app->getUserState('com_content.productbutton.search') || JRequest::getVar('limit') != $app->getUserState('com_content.productbutton.limit')) {
            $pageInfo->limit->start = 0;
            $app->setUserState('com_content.productbutton.limitstart', 0);
        }
        $Select = 'SELECT * FROM ' . hikashop_table('product');
        $Where = ' WHERE product_type=\'main\' AND product_access=\'all\' AND product_published=1 ';
        $orderBY = ' ORDER BY product_id ASC';
        $searchMap = array('product_name', 'product_code', 'product_id');
        $filters = array();
        if (!empty($pageInfo->search)) {
            $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\'';
            $filter = '(' . implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}" . ')';
            $filters[] = $filter;
        }
        if (is_array($filters) && count($filters)) {
            $filters = ' AND ' . implode(' AND ', $filters);
        } else {
            $filters = '';
        }
        $db->setQuery($Select . $Where . $filters . $orderBY, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value);
        $products = $db->loadObjectList();
        $db->setQuery('SELECT COUNT(product_id) FROM ' . hikashop_table('product') . ' WHERE product_type=\'main\' AND product_access=\'all\' AND product_published=1' . $filters);
        $nbrow = $db->loadResult();
        $db->setQuery('SELECT * FROM ' . hikashop_table('price') . ' ORDER BY price_product_id ASC');
        $prices = $db->loadObjectList();
        if (HIKASHOP_J30) {
            $pagination = hikashop_get('helper.pagination', $nbrow, $pageInfo->limit->start, $pageInfo->limit->value);
        } else {
            jimport('joomla.html.pagination');
            $pagination = new JPagination($nbrow, $pageInfo->limit->start, $pageInfo->limit->value);
        }
        $scriptV1 = "function insertTag(tag){ window.parent.jInsertEditorText(tag,'text'); return true;}";
        $scriptV2 = "function insertTag(tag){ window.parent.jInsertEditorText(tag,'" . str_replace(array('\\', '\''), array('\\\\', '\\\''), $editor_name) . "'); return true;}";
        if (!HIKASHOP_PHP5) {
            $doc =& JFactory::getDocument();
        } else {
            $doc = JFactory::getDocument();
        }
        if (version_compare(JVERSION, '1.6.0', '<')) {
            $doc->addScriptDeclaration($scriptV1);
        } else {
            $doc->addScriptDeclaration($scriptV2);
        }
        $config =& hikashop_config();
        $pricetaxType = hikashop_get('type.pricetax');
        $discountDisplayType = hikashop_get('type.discount_display');
        ?>
	<script language="JavaScript" type="text/javascript">
		function divhidder(){
			if (document.getElementById('price').checked) {
				document.getElementById('Priceopt').style.visibility = 'visible';
			}
			else {
				document.getElementById('Priceopt').style.visibility = 'hidden';
			}
		}
		function checkSelect(){
			form = document.getElementById('adminForm');
			inputs = form.getElementsByTagName('input');
			nbbox = 0;
			nbboxOk = 0;
			nbboxProd = 0;
			for(i=0 ; i < inputs.length ; i++){
				if(inputs[i].type == 'checkbox' && inputs[i].checked==true){
					nbbox++;
				}
			}
			for(i=0 ; i < inputs.length ; i++){
				if(inputs[i].type == 'checkbox' && inputs[i].checked==true){
					nbboxOk++;
					if(inputs[i].id.match(/product_checkbox.*/)){
						if (nbboxProd == 0)
							document.getElementById('product_insert').value = '{product ';
						nbboxProd++;
						document.getElementById('product_insert').value = document.getElementById('product_insert').value +  inputs[i].name;
						if(nbbox > nbboxOk){
							document.getElementById('product_insert').value = document.getElementById('product_insert').value + '|';
						}
					}
				}
			}
			if( nbboxProd > 0 )
			{
				if(document.getElementById('name').checked==true){
					document.getElementById('product_insert').value =document.getElementById('product_insert').value +  '|name';
				}
				if(document.getElementById('cart').checked==true){
					document.getElementById('product_insert').value =document.getElementById('product_insert').value +  '|cart';
				}
				if(document.getElementById('quantityfield').checked==true){
					document.getElementById('product_insert').value =document.getElementById('product_insert').value +  '|quantityfield';
				}
				if(document.getElementById('description').checked==true){
					document.getElementById('product_insert').value =document.getElementById('product_insert').value +  '|description';
				}
				if(document.getElementById('picture').checked==true){
					document.getElementById('product_insert').value =document.getElementById('product_insert').value +  '|picture';
				}
				if(document.getElementById('link').checked==true){
					document.getElementById('product_insert').value =document.getElementById('product_insert').value +  '|link';
				}
				if(document.getElementById('border').checked==true){
					document.getElementById('product_insert').value =document.getElementById('product_insert').value +  '|border';
				}
				if(document.getElementById('badge').checked==true){
					document.getElementById('product_insert').value =document.getElementById('product_insert').value +  '|badge';
				}
				if(document.getElementById('menuid').value.length != 0){
					document.getElementById('product_insert').value =document.getElementById('product_insert').value +  '|menuid:' + document.getElementById('menuid').value;
				}
				if(document.getElementById('pricedisc').value==1 && document.getElementById('price').checked==true){
					document.getElementById('product_insert').value =document.getElementById('product_insert').value +  '|pricedis1';
				}
				if(document.getElementById('pricedisc').value==2 && document.getElementById('price').checked==true){
					document.getElementById('product_insert').value =document.getElementById('product_insert').value +  '|pricedis2';
				}
				if(document.getElementById('pricedisc').value==3 && document.getElementById('price').checked==true){
					document.getElementById('product_insert').value =document.getElementById('product_insert').value +  '|pricedis3';
				}
				if(document.getElementById('pricetax').value==1 && document.getElementById('price').checked==true){
					document.getElementById('product_insert').value =document.getElementById('product_insert').value +  '|pricetax1';
				}
				if(document.getElementById('pricetax').value==2 && document.getElementById('price').checked==true){
					document.getElementById('product_insert').value =document.getElementById('product_insert').value +  '|pricetax2';
				}
				if(document.getElementById('pricedisc').value==0 && document.getElementById('pricetax').value==0 && document.getElementById('price').checked==true){
					document.getElementById('product_insert').value =document.getElementById('product_insert').value +  '|price';
				}
				document.getElementById('product_insert').value=document.getElementById('product_insert').value + '}';
			}
			if(document.getElementById('name').checked==false
			&& document.getElementById('price').checked==false
			&& document.getElementById('cart').checked==false
			&& document.getElementById('description').checked==false
			&& document.getElementById('picture').checked==false){
				document.getElementById('product_insert').value='';
			}
		}
		function checkAllBox(){
			var checkAll = document.getElementById('checkAll');
			var toCheck = document.getElementById('ToCheck').getElementsByTagName('input');
			for (i = 0 ; i < toCheck.length ; i++) {
				if (toCheck[i].type == 'checkbox') {
					if(checkAll.checked == true){
						toCheck[i].checked = true;
					}else{
						toCheck[i].checked = false;
					}
				}
			}
		}
	</script>
	<form action="<?php 
        echo hikashop_currentURL();
        ?>
" method="POST" name="adminForm" id="adminForm">
		<table class="hikashop_no_border">
			<tr>
				<td width="100%">
					<?php 
        echo JText::_('FILTER');
        ?>
:
					<input type="text" name="search" id="hikashop_search" value="<?php 
        echo hikashop_getEscaped($pageInfo->search);
        ?>
" class="inputbox" onchange="document.adminForm.submit();" />
					<button class="btn" onclick="this.form.submit();"><?php 
        echo JText::_('GO');
        ?>
</button>
					<button class="btn" onclick="document.getElementById('hikashop_search').value='';this.form.submit();"><?php 
        echo JText::_('RESET');
        ?>
</button>
				</td>
			</tr>
		</table>
		<fieldset>
			<legend>OPTIONS</legend>
			<div id="productInsertOptions">
				<input type="checkbox" name="name" id="name" value="1" checked/><?php 
        echo JText::_('HIKA_NAME');
        ?>
				<input type="checkbox" name="description" id="description" value="1" checked/><?php 
        echo JText::_('PRODUCT_DESCRIPTION');
        ?>
				<input type="checkbox" name="cart" id="cart" value="1" <?php 
        if (!empty($_REQUEST['cart'])) {
            echo 'checked';
        }
        ?>
 /><?php 
        echo JText::_('HIKASHOP_CHECKOUT_CART');
        ?>
				<input type="checkbox" name="quantity" id="quantityfield" value="1" <?php 
        if (!empty($_REQUEST['quantityfield'])) {
            echo 'checked';
        }
        ?>
 /><?php 
        echo JText::_('HIKA_QUANTITY_FIELD');
        ?>
				<input type="checkbox" name="picture" id="picture" value="1" <?php 
        if (!empty($_REQUEST['picture'])) {
            echo 'checked';
        }
        ?>
/><?php 
        echo JText::_('HIKA_IMAGE');
        ?>
				<input type="checkbox" name="link" id="link" value="1" <?php 
        if (!empty($_REQUEST['link'])) {
            echo 'checked';
        }
        ?>
/><?php 
        echo JText::_('LINK_TO_PRODUCT_PAGE');
        ?>
				<input type="checkbox" name="border" id="border" value="1" <?php 
        if (!empty($_REQUEST['border'])) {
            echo 'checked';
        }
        ?>
 /><?php 
        echo JText::_('ITEM_BOX_BORDER');
        ?>
				<input type="checkbox" name="badge" id="badge" value="1" <?php 
        if (!empty($_REQUEST['badge'])) {
            echo 'checked';
        }
        ?>
 /><?php 
        echo JText::_('HIKA_BADGE');
        ?>
				<br/>
				Menu ID : <input type="text" name="menuid" id="menuid"  <?php 
        if (!empty($_REQUEST['menuid'])) {
            echo 'value="' . $_REQUEST['menuid'] . '"';
        }
        ?>
 />
				<input type="checkbox" name="pricetax" id="pricetax" value="<?php 
        echo $config->get('price_with_tax');
        ?>
" hidden/>
				<br/>
				<input type="checkbox" name="price" id="price" value="1" checked onclick="divhidder()"/><?php 
        echo JText::_('DISPLAY_PRICE');
        ?>
				<br/>
				<div id="Priceopt">
				<tr id="show_discount_line">
					<td class="key" valign="top">
						<?php 
        echo JText::_('SHOW_DISCOUNTED_PRICE');
        ?>
					</td>
					<td>
						<?php 
        $default_params = $config->get('default_params');
        echo $discountDisplayType->display('pricedisc', 3);
        ?>
					</td>
				</tr>
				<div>
				</div>
		</fieldset>
			<fieldset>
			<table class="adminlist table table-striped" cellpadding="1" width="100%">
				<thead>
					<tr>
						<th class="title titlenum">
							<?php 
        echo JText::_('HIKA_NUM');
        ?>
						</th>
						<th class="title titlebox">
							<input type="checkbox" name="checkAll" id="checkAll" value="" onclick="checkAllBox();"/>
						</th>
						<th class="title">
							<?php 
        echo JText::_('HIKA_NAME');
        ?>
						</th>
						<th class="title">
							<?php 
        echo JText::_('PRODUCT_PRICE');
        ?>
						</th>
						<th class="title">
							<?php 
        echo JText::_('PRODUCT_QUANTITY');
        ?>
						</th>
						<th class="title">
							<?php 
        echo 'ID';
        ?>
						</th>
					</tr>
				</thead>
				<tbody id="ToCheck">
					<?php 
        $i = 0;
        $row = '';
        $currencyClass = hikashop_get('class.currency');
        $currencies = new stdClass();
        $currency_symbol = '';
        foreach ($products as $product) {
            $i++;
            $row .= '<tr><td class="title titlenum">';
            $row .= $i;
            $row .= '</td><td class="title titlebox"><input type="checkbox" id="product_checkbox' . $product->product_id . '" name="' . $product->product_id;
            $row .= '" value=""/></td><td class="center">';
            $row .= $product->product_name;
            $row .= '</td><td class="center">';
            foreach ($prices as $price) {
                if ($price->price_product_id == $product->product_id) {
                    $row .= $price->price_value;
                    $currency = $currencyClass->getCurrencies($price->price_currency_id, $currencies);
                    foreach ($currency as $currrencie) {
                        if ($price->price_currency_id == $currrencie->currency_id) {
                            $currency_symbol = $currrencie->currency_symbol;
                        }
                    }
                    $row .= ' ' . $currency_symbol;
                }
            }
            $row .= '</td><td class="center">';
            if ($product->product_quantity > -1) {
                $row .= $product->product_quantity;
            } else {
                $row .= JText::_('UNLIMITED');
            }
            $row .= '</td><td class="center">';
            $row .= $product->product_id;
            $row .= '</td></tr>';
        }
        echo $row;
        ?>
				</tbody>
				<tfoot>
					<tr>
						<td colspan="7">
							<?php 
        echo $pagination->getListFooter();
        ?>
							<?php 
        echo $pagination->getResultsCounter();
        ?>
						</td>
					</tr>
				</tfoot>
			</table>
		</fieldset>
		<input type="hidden" name="product_insert" id="product_insert" value="" />
		<button class="btn" onclick="checkSelect(); insertTag(document.getElementById('product_insert').value); window.parent.SqueezeBox.close();"><?php 
        echo JText::_('HIKA_INSERT');
        ?>
</button>
		<?php 
        global $Itemid;
        ?>
		<input type="hidden" name="Itemid" value="<?php 
        echo $Itemid;
        ?>
"/>
		<?php 
        echo JHTML::_('form.token');
    }
Ejemplo n.º 6
0
 function init($cart = false)
 {
     $config =& hikashop_config();
     $url = $config->get('redirect_url_after_add_cart', 'stay_if_cart');
     switch ($url) {
         case 'checkout':
             $url = $this->_getCheckoutURL();
             break;
         case 'stay_if_cart':
             $url = '';
             if (!$cart) {
                 $url = $this->_getCheckoutURL();
                 break;
             }
         case 'ask_user':
         case 'stay':
             $url = '';
         case '':
         default:
             if (empty($url)) {
                 $url = hikashop_currentURL('return_url');
             }
             break;
     }
     return urlencode($url);
 }
Ejemplo n.º 7
0
                    ?>
				<input type="checkbox" name="data[products][<?php 
                    echo $cart->product_id;
                    ?>
][checked]" value="1"/>
			</td>
<?php 
                }
                if ($hasAccess) {
                    ?>
			<td data-title="<?php 
                    echo JText::_('HIKA_DELETE');
                    ?>
" class="hikashop_show_cart_delete">
				<a class="hikashop_no_print" href="<?php 
                    echo hikashop_completeLink('product&task=updatecart&stay=1&delete=1&quantity=0&cart_type=' . $cart_type . '&cart_id=' . $cart->cart_id . '&cart_product_id=' . $cart->cart_product_id . '&return_url=' . urlencode(base64_encode(hikashop_currentURL())) . $url_itemid);
                    ?>
"  title="<?php 
                    echo JText::_('HIKA_DELETE');
                    ?>
">
					<img src="<?php 
                    echo HIKASHOP_IMAGES . 'delete2.png';
                    ?>
" alt="<?php 
                    echo JText::_('HIKA_DELETE');
                    ?>
" />
				</a>
			</td>
<?php 
Ejemplo n.º 8
0
 function init()
 {
     $url = $this->params->get('url');
     if (empty($url)) {
         $url = hikashop_currentURL();
     }
     $this->params->set('url', urlencode($url));
 }
Ejemplo n.º 9
0
<?php

/**
 * @package	HikaShop for Joomla!
 * @version	2.3.5
 * @author	hikashop.com
 * @copyright	(C) 2010-2015 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
$current_url = hikashop_currentURL();
$set = JRequest::getString('sort_comment', '');
$config = JFactory::getConfig();
if (HIKASHOP_J30) {
    $sef = $config->get('sef');
} else {
    $sef = $config->getValue('config.sef');
}
if (!empty($set)) {
    if ($sef) {
        $current_url = preg_replace('/\\/sort_comment-' . $set . '/', '', $current_url);
    } else {
        $current_url = preg_replace('/&sort_comment=' . $set . '/', '', $current_url);
    }
}
$row =& $this->rows;
$elt =& $this->elts;
$pagination =& $this->pagination;
$no_comment = 1;
$hikashop_vote_con_req_list = $row->hikashop_vote_con_req_list;
$useful_rating = $row->useful_rating;
Ejemplo n.º 10
0
 function onAfterRoute()
 {
     $app = JFactory::getApplication();
     if (JRequest::getString('option') != 'com_virtuemart' || $app->isAdmin()) {
         return true;
     }
     $vmProdId = (int) JRequest::getVar('product_id');
     if (empty($vmProdId)) {
         $vmProdId = (int) JRequest::getVar('virtuemart_product_id');
     }
     $vmCatId = (int) JRequest::getVar('category_id');
     if (empty($vmCatId)) {
         $vmCatId = (int) JRequest::getVar('virtuemart_category_id');
     }
     $vmOrderId = JRequest::getInt('order_id');
     if (empty($vmOrderId)) {
         $vmOrderId = (int) JRequest::getVar('order_number');
     }
     $db = JFactory::getDBO();
     if (!defined('DS')) {
         define('DS', DIRECTORY_SEPARATOR);
     }
     if (!(include_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_hikashop' . DS . 'helpers' . DS . 'helper.php')) {
         return true;
     }
     if (empty($vmProdId) && empty($vmCatId) && empty($vmOrderId)) {
         $currentURL = hikashop_currentURL();
         if (preg_match_all('#/(virtuemart_product_id|product_id|category_id|virtuemart_category_id|order_id|order_number)/([0-9]+)#', $currentURL, $matches)) {
             foreach ($matches[1] as $k => $key) {
                 switch ($key) {
                     case 'product_id':
                     case 'virtuemart_product_id':
                         $vmProdId = $matches[2][$k];
                         break;
                     case 'category_id':
                     case 'virtuemart_category_id':
                         $vmCatId = $matches[2][$k];
                         break;
                     case 'order_id':
                     case 'order_number':
                         $vmOrderId = $matches[2][$k];
                         break;
                 }
             }
         }
         if (empty($vmProdId) && empty($vmCatId) && empty($vmOrderId)) {
             return true;
         }
     }
     $query = 'SHOW TABLES LIKE ' . $db->Quote($db->getPrefix() . substr(hikashop_table('vm_prod'), 3));
     $db->setQuery($query);
     $table = $db->loadResult();
     if (empty($table)) {
         return true;
     }
     $url = null;
     if (!empty($vmProdId) && $vmProdId > 0) {
         $query = "SELECT a.hk_id, b.product_name as 'name' FROM `#__hikashop_vm_prod` a INNER JOIN `#__hikashop_product` b ON a.hk_id = b.product_id WHERE a.vm_id = " . $vmProdId . ";";
         $baseUrl = 'product&task=show';
     } else {
         if (!empty($vmCatId) && $vmCatId > 0) {
             $id = 'vm-fallback';
             $alias = 'hikashop-menu-for-module-' . $id;
             $db->setQuery('SELECT id FROM ' . hikashop_table('menu', false) . ' WHERE alias=\'' . $alias . '\'');
             $itemId = $db->loadResult();
             if (empty($itemId)) {
                 $options = new stdClass();
                 $config =& hikashop_config();
                 $options->hikashop_params = $config->get('default_params', null);
                 $classMenu = hikashop_get('class.menus');
                 $classMenu->loadParams($options);
                 $options->hikashop_params['content_type'] = 'category';
                 $options->hikashop_params['layout_type'] = 'div';
                 $options->hikashop_params['content_synchronize'] = '1';
                 if ($options->hikashop_params['columns'] == 1) {
                     $options->hikashop_params['columns'] = 3;
                 }
                 $classMenu->createMenu($options->hikashop_params, $id);
                 $itemId = $options->hikashop_params['itemid'];
             }
             $query = "SELECT a.hk_id, b.category_name as 'name' FROM `#__hikashop_vm_cat` a INNER JOIN `#__hikashop_category` b ON a.hk_id = b.category_id WHERE a.vm_id = " . $vmCatId . ";";
             $baseUrl = 'category&task=listing&Itemid=' . $itemId;
         } elseif (!empty($vmOrderId)) {
             $db->setQuery('SELECT order_id FROM ' . hikashop_table('order') . ' WHERE order_vm_id=' . $vmOrderId);
             $hikaOrderId = $db->loadResult();
             if (!empty($hikaOrderId)) {
                 $url = hikashop_completeLink('order&task=show&cid=' . $hikaOrderId, false, true);
                 $app->redirect($url);
                 return true;
             } else {
                 $db->setQuery('SELECT order_id FROM ' . hikashop_table('order') . ' AS h INNER JOIN `#__virtuemart_orders` AS v ON h.order_vm_id = v.virtuemart_order_id WHERE v.order_number=' . $vmOrderId);
                 $hikaOrderId = $db->loadResult();
                 if (!empty($hikaOrderId)) {
                     $url = hikashop_completeLink('order&task=show&cid=' . $hikaOrderId, false, true);
                     $app->redirect($url);
                     return true;
                 }
             }
         }
     }
     if (!empty($query) && !empty($baseUrl)) {
         $db->setQuery($query);
         $link = $db->loadObject();
         if ($link) {
             if (method_exists($app, 'stringURLSafe')) {
                 $name = $app->stringURLSafe(strip_tags($link->name));
             } else {
                 $name = JFilterOutput::stringURLSafe(strip_tags($link->name));
             }
             $url = hikashop_completeLink($baseUrl . '&cid=' . $link->hk_id . '&name=' . $name, false, true);
         }
     }
     if ($url) {
         $app->redirect($url, '', 'message', true);
     }
 }
Ejemplo n.º 11
0
<?php

/**
 * @package	HikaShop for Joomla!
 * @version	2.6.1
 * @author	hikashop.com
 * @copyright	(C) 2010-2016 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
if (!defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}
if (!(include_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_hikashop' . DS . 'helpers' . DS . 'helper.php')) {
    echo 'This module can not work without the Hikashop Component';
    return;
}
$mode_noform = $params->get('mode_noform', 0);
$currency = hikashop_get('type.currency');
$config =& hikashop_config();
$redirectUrl = hikashop_currentURL();
require JModuleHelper::getLayoutPath('mod_hikashop_currency');
Ejemplo n.º 12
0
    function googleDirectCall($accounts, &$order, $currencyInfo)
    {
        $found = false;
        foreach ($accounts as $a) {
            if ($a->currency == $currencyInfo->currency_code && !empty($a->account_id)) {
                $account = $a->account_id;
                if (!preg_match('/UA-[0-9]{2,12}-[0-9]{1}/', $account)) {
                    continue;
                }
                $found = true;
                break;
            }
        }
        if (!$found) {
            return false;
        }
        $ip = hikashop_getIP();
        $uuid = round(rand() / getrandmax() * 0x7fffffff);
        $jconf = JFactory::getConfig();
        if (HIKASHOP_J30) {
            $siteName = $jconf->get('sitename');
        } else {
            $siteName = $jconf->getValue('config.sitename');
        }
        $data = array('v' => 1, 'tid' => $account, 'cid' => $uuid, 't' => 'transaction', 'ti' => $order->order_id, 'ta' => $siteName, 'tr' => round($order->order_full_price, 2), 'tt' => round($order->order_subtotal_no_vat + $order->order_shipping_tax + $order->order_discount_tax, 2), 'ts' => round($order->order_shipping_price, 2), 'cu' => $currencyInfo->currency_code);
        $this->googleDirectCallHit($data);
        foreach ($order->products as $product) {
            $data = array('v' => 1, 'tid' => $account, 'cid' => $uuid, 't' => 'item', 'ti' => $order->order_id, 'in' => strip_tags($product->order_product_name), 'ip' => $product->order_product_price + $product->order_product_tax, 'iq' => $product->order_product_quantity, 'ic' => $product->order_product_code, 'iv' => '', 'cu' => $currencyInfo->currency_code);
            $this->googleDirectCallHit($data);
        }
        if ($this->params->get('debug_mode')) {
            $data = 'Send transaction by direct call
IP: ' . $ip . '
URL: ' . hikashop_currentURL();
            $this->writeToLog($data);
        }
        return true;
    }
Ejemplo n.º 13
0
 function _addFacebookButton(&$plugin)
 {
     if (empty($plugin->params['display_fb'])) {
         return;
     }
     $element = $this->_getElementInfo();
     if (empty($element)) {
         return '';
     }
     $options = array('layout' => 'standard', 'width' => 400);
     $xfbml_options = array();
     $classname = 'standard';
     switch ((int) $plugin->params['fb_style']) {
         case 1:
             $classname = 'button_count';
             $options['layout'] = 'button_count';
             $xfbml_options['layout'] = 'button_count';
             $options['width'] = 115;
             break;
         case 2:
             $classname = 'box_count';
             $options['layout'] = 'box_count';
             $xfbml_options['layout'] = 'box_count';
             $options['width'] = 115;
             break;
         case 3:
             $classname = 'button';
             $options['layout'] = 'button';
             $xfbml_options['layout'] = 'button';
             $options['width'] = 65;
             break;
     }
     if (empty($plugin->params['fb_faces'])) {
         $options['show_faces'] = 'false';
         $xfbml_options['show-faces'] = 'false';
     } else {
         $options['show_faces'] = 'true';
         $xfbml_options['show-faces'] = 'false';
         // in the first version of the plugin, in fact is was set to "false", so...
     }
     if (empty($plugin->params['fb_verb'])) {
         $options['action'] = 'like';
     } else {
         $options['action'] = 'recommend';
         $xfbml_options['action'] = 'recommend';
     }
     if (empty($plugin->params['fb_theme'])) {
         $options['colorscheme'] = 'light';
     } else {
         $options['colorscheme'] = 'dark';
         $xfbml_options['colorscheme'] = 'dark';
     }
     $fonts = array(0 => 'arial', 1 => 'lucida%20grande', 2 => 'segoe%20ui', 3 => 'tahoma', 4 => 'trebuchet%20ms', 5 => 'verdana');
     if (isset($fonts[(int) $plugin->params['fb_font']])) {
         $options['font'] = $fonts[(int) $plugin->params['fb_font']];
         $xfbml_options['font'] = $fonts[(int) $plugin->params['fb_font']];
     }
     if (!empty($plugin->params['fb_send'])) {
         $xfbml_options['send'] = 'true';
     }
     if (!empty($element->url_canonical)) {
         $url = hikashop_cleanURL($element->url_canonical);
     } else {
         $url = hikashop_currentURL('', false);
     }
     $html = '<span class="hikashop_social_fb">';
     if ($plugin->params['position'] == 1) {
         $html = '<span class="hikashop_social_fb_right">';
     }
     $url_options = array();
     if ($plugin->params['fb_tag'] == 'iframe') {
         foreach ($options as $k => $v) {
             $url_options[] = $k . '=' . urlencode($v);
         }
         $html .= '<iframe ' . 'src="//www.facebook.com/plugins/like.php?href=' . urlencode($url) . '&amp;send=false&amp;' . implode('&amp;', $url_options) . '&amp;height=30" ' . 'scrolling="no" frameborder="0" allowTransparency="true" ' . 'style="border:none; overflow:hidden;" class="hikashop_social_fb_' . $classname . '"></iframe>';
     } else {
         foreach ($xfbml_options as $k => $v) {
             $url_options[] = 'data-' . $k . '="' . urlencode($v) . '"';
         }
         $html .= '<div class="fb-like" data-href="' . $url . '" ' . implode(' ', $url_options) . '></div>';
     }
     $html .= '</span>';
     $this->meta['property="og:title"'] = '<meta property="og:title" content="' . htmlspecialchars($element->name, ENT_COMPAT, 'UTF-8') . '"/> ';
     $types = array(0 => 'product', 1 => 'album', 2 => 'book', 3 => 'company', 4 => 'drink', 5 => 'game', 6 => 'movie', 7 => 'song');
     if (isset($types[(int) $plugin->params['fb_type']])) {
         $this->meta['property="og:type"'] = '<meta property="og:type" content="' . $types[(int) $plugin->params['fb_type']] . '"/> ';
     }
     $config =& hikashop_config();
     $uploadFolder = ltrim(JPath::clean(html_entity_decode($config->get('uploadfolder', 'media/com_hikashop/upload/'))), DS);
     $uploadFolder = rtrim($uploadFolder, DS) . DS;
     $this->uploadFolder_url = str_replace(DS, '/', $uploadFolder);
     $this->uploadFolder = JPATH_ROOT . DS . $uploadFolder;
     $this->thumbnail = $config->get('thumbnail', 1);
     $this->thumbnail_y = $config->get('product_image_y', $config->get('thumbnail_y'));
     $this->thumbnail_x = $config->get('product_image_x', $config->get('thumbnail_x'));
     $this->main_thumbnail_x = $this->thumbnail_x;
     $this->main_thumbnail_y = $this->thumbnail_y;
     $this->main_uploadFolder_url = $this->uploadFolder_url;
     $this->main_uploadFolder = $this->uploadFolder;
     $imageUrl = $this->_getImageURL($element);
     if (!empty($imageUrl)) {
         $this->meta['property="og:image"'] = '<meta property="og:image" content="' . $imageUrl . '" /> ';
     }
     $this->meta['property="og:url"'] = '<meta property="og:url" content="' . $url . '" />';
     $this->meta['property="og:description"'] = '<meta property="og:description" content="' . htmlspecialchars(strip_tags($element->description), ENT_COMPAT, 'UTF-8') . '"/> ';
     $jconf = JFactory::getConfig();
     if (HIKASHOP_J30) {
         $siteName = $jconf->get('sitename');
     } else {
         $siteName = $jconf->getValue('config.sitename');
     }
     $this->meta['property="og:site_name"'] = '<meta property="og:site_name" content="' . htmlspecialchars($siteName, ENT_COMPAT, 'UTF-8') . '"/> ';
     if (!empty($plugin->params['admin'])) {
         $this->meta['property="fb:admins"'] = '<meta property="fb:admins" content="' . htmlspecialchars($plugin->params['admin'], ENT_COMPAT, 'UTF-8') . '" />';
     }
     return $html;
 }
Ejemplo n.º 14
0
Archivo: cart.php Proyecto: rodhoff/MNW
                    ?>
'); if (qty_field){<?php 
                    echo $input;
                    ?>
 } document.<?php 
                    echo $form;
                    ?>
.submit(); return false;" />
<?php 
                }
            }
            if ($this->params->get('show_delete', 1) && $this->params->get('from', 'display') != 'module') {
                ?>
						<div class="hikashop_cart_product_quantity_delete">
							<a href="<?php 
                echo hikashop_completeLink('product&task=updatecart&product_id=' . $row->product_id . $this->url_itemid . '&quantity=0&return_url=' . urlencode(base64_encode(hikashop_currentURL('return_url'))));
                ?>
" onclick="var qty_field = document.getElementById('hikashop_checkout_quantity_<?php 
                echo $row->cart_product_id;
                ?>
'); if(qty_field){qty_field.value=0; <?php 
                echo $input;
                ?>
 qty_field.form.submit();} return false;" title="<?php 
                echo JText::_('HIKA_DELETE');
                ?>
">
								<img src="<?php 
                echo HIKASHOP_IMAGES . 'delete2.png';
                ?>
" border="0" alt="<?php 
Ejemplo n.º 15
0
    function loadJS()
    {
        static $done = false;
        if ($done) {
            return true;
        }
        $done = true;
        $current_url = hikashop_currentURL();
        $baseUrl = hikashop_completelink('vote&task=save&' . hikashop_getFormToken() . '=1');
        $ajaxUrl = hikashop_completelink('vote&task=save', true, true);
        if (strpos($baseUrl, '?') !== false) {
            $baseUrl .= '&';
        } else {
            $baseUrl .= '?';
        }
        $config = hikashop_config();
        $email_comment = $config->get('email_comment', 0);
        if ($config->get('enable_status_vote', 0) == 'both') {
            $vote_comment = 1;
        } else {
            $vote_comment = 0;
        }
        $note_comment = $config->get('register_note_comment', 0);
        if ($config->get('access_vote', 0) == 'buyed' || $config->get('access_vote', 0) == 'registered') {
            $hikashop_vote_con_req = 1;
        } else {
            $hikashop_vote_con_req = 0;
        }
        $js = '
function trim(myString){
	myString = myString.replace(/(^\\s|&)+/g,\'\').replace(/\\s+$/g,\'\').replace(/\\n/g,\'<br \\/>\');
	return myString;
}

function hikashop_vote_useful(hikashop_vote_id,val){
	var hikashop_vote_user_id = "";
	if(document.getElementById("hikashop_vote_user_id")) hikashop_vote_user_id = document.getElementById("hikashop_vote_user_id").value;
	var hikashop_vote_note_comment 	= ' . $note_comment . ';
	if((hikashop_vote_note_comment == 1 && hikashop_vote_user_id != "") || hikashop_vote_note_comment == 0){
		data = "hikashop_vote_type=useful";
		data += "&value=" + encodeURIComponent(val);
		data += "&hikashop_vote_id=" + encodeURIComponent(hikashop_vote_id);
		data += "&hikashop_vote_user_id=" + encodeURIComponent(hikashop_vote_user_id);
		window.Oby.xRequest("' . $ajaxUrl . '", {mode: "POST", data: data}, function(xhr) {
			var el = document.getElementById(hikashop_vote_id);
			if(xhr.responseText == "1"){el.innerHTML = " ' . JText::_('THANK_FOR_VOTE', true) . '";}
			else if(xhr.responseText == "3"){el.innerHTML = " ' . JText::_('ALREADY_VOTE_USEFUL', true) . '";}
			else{el.innerHTML = " ' . JText::_('VOTE_ERROR', true) . '";}
		});
		setTimeout("document.location=\'' . $current_url . '\'",2250);
	}
	else{
		document.getElementById(hikashop_vote_id).innerHTML = " ' . JText::_('ONLY_REGISTERED_CAN_VOTE', true) . '";
		setTimeout("document.getElementById(\'hikashop_vote_id\').innerHTML = \'\'",2250);
	}
}

function hikashop_send_vote(hikashop_vote, from){
	var re = new RegExp(\'id_(.*?)_hikashop\');
	var m = re.exec(from);
	if(m != null){
		var hikashop_vote_ref_id = "";
		for (i = 1; i < m.length; i++) {
			hikashop_vote_ref_id = hikashop_vote_ref_id + m[i] + "\\n";
		}
	}else{
		var hikashop_vote_ref_id = document.getElementById("hikashop_vote_ref_id").value;
	}
	document.getElementById("hikashop_vote_ok_"+parseInt(hikashop_vote_ref_id)).value = "1";
	var hikashop_vote_vote_comment 	= ' . $vote_comment . ';
	var hikashop_vote_con_req		= ' . $hikashop_vote_con_req . ';
	var hikashop_vote_user_id 		= document.getElementById("hikashop_vote_user_id_"+parseInt(hikashop_vote_ref_id)).value;
	var vote_type					= document.getElementById("vote_type_"+parseInt(hikashop_vote_ref_id)).value;
	var div_vote_status				= "hikashop_vote_status_"+parseInt(hikashop_vote_ref_id);
	if((hikashop_vote_con_req == 1 && hikashop_vote_user_id != "") || hikashop_vote_con_req == 0){
		if(hikashop_vote_vote_comment == 1){//User must enter a comment to note a product
			if(from =="hikashop_vote_rating_id"){
				document.getElementById("hikashop_vote_status_form").innerHTML = " ' . JText::_('LET_COMMENT_TO_VALID_VOTE', true) . '";
				setTimeout("document.getElementById(\'hikashop_vote_status_form\').innerHTML = \'\'",2250);
			}else{
				var el = document.getElementById(div_vote_status);
				el.innerHTML = " ' . JText::_('LET_COMMENT_TO_VALID_VOTE', true) . '";
				setTimeout(function(){el.innerHTML = "";},2250);
			}
		}
		else{// Only vote - sending request to saveFrontend() function, and analysing the result, status(thanks, bought, error)
			if(from =="hikashop_vote_rating_id"){
				var el = document.getElementById("hikashop_vote_status_form");
			}else{
				var el = document.getElementById(div_vote_status);
			}
			data = "vote_type=" + encodeURIComponent(vote_type);
			data += "&hikashop_vote_type=vote";
			data += "&hikashop_vote=" + encodeURIComponent(hikashop_vote);
			data += "&hikashop_vote_user_id=" + encodeURIComponent(hikashop_vote_user_id);
			data += "&hikashop_vote_ref_id=" + encodeURIComponent(hikashop_vote_ref_id);
			window.Oby.xRequest("' . $ajaxUrl . '", {mode: "POST", data: data}, function(xhr) {
				if(xhr.responseText == "1"){
					el.innerHTML = " ' . JText::_('VOTE_UPDATED', true) . '";

					setTimeout(function(){el.innerHTML = "";},2250);
					resetVotes();

				}
				else if(xhr.responseText == "2"){el.innerHTML = " ' . JText::_('THANK_FOR_VOTE', true) . '"; }
				else if(xhr.responseText == "3"){el.innerHTML = " ' . JText::_('MUST_HAVE_BUY_TO_VOTE', true) . '";}
				else{el.innerHTML = " ' . JText::_('VOTE_ERROR', true) . '";}
			});
		}
	}
	else{ //The user must be registered to vote
		if(from =="hikashop_vote_rating_id"){
			document.getElementById("hikashop_vote_status_form").innerHTML = " ' . JText::_('ONLY_REGISTERED_CAN_VOTE', true) . '";
			setTimeout("document.getElementById(\'hikashop_vote_status_form\').innerHTML = \'\'",2250);
		}else{
			var el = document.getElementById(div_vote_status);
			el.innerHTML = " ' . JText::_('ONLY_REGISTERED_CAN_VOTE', true) . '";
			setTimeout(function(){el.innerHTML = "";},2250);
		}
	}
}

function hikashop_send_comment(){ //Action on submit comment
	var hikashop_vote_ref_id 		= document.getElementById("hikashop_vote_ref_id").value;
	var hikashop_vote_comment 		= encodeURIComponent(trim(document.getElementById("hikashop_vote_comment").value));
	var vote_type					= document.getElementById("vote_type_"+parseInt(hikashop_vote_ref_id)).value;
	var hikashop_vote_ok 			= document.getElementById("hikashop_vote_ok_"+parseInt(hikashop_vote_ref_id)).value;
	var hikashop_vote_vote_comment 	= ' . $vote_comment . ';
	var hikashop_vote_con_req		= ' . $hikashop_vote_con_req . ';
	var email_comment_bool 			= ' . $email_comment . ';
	var hikashop_vote_user_id 		= document.getElementById("hikashop_vote_user_id_"+parseInt(hikashop_vote_ref_id)).value;
	var pseudo_comment 				= document.getElementById("pseudo_comment").value;
	var email_comment				= document.getElementById("email_comment").value;
	var reg = new RegExp(\'^[a-z0-9]+([_|\\.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|\\.|-]{1}[a-z0-9]+)*[\\.]{1}[a-z]{2,6}$\', \'i\'); // TEST EMAIL ADDRESS
	var verif_mail = reg.test(email_comment);

	if (hikashop_vote_user_id != ""){verif_mail = true;}
	if((hikashop_vote_con_req == 1 && hikashop_vote_user_id != "") || hikashop_vote_con_req == 0){ //if connection not required
		if(pseudo_comment == "" || (email_comment_bool == 1 && verif_mail == false)){ //if not connected
			if(pseudo_comment == ""){
				document.getElementById("hikashop_vote_status_form").innerHTML = "' . JText::_('PSEUDO_REQUIRED', true) . '";
				setTimeout("document.getElementById(\'hikashop_vote_status_form\').innerHTML = \'\'",2250);
			}else{
				document.getElementById("hikashop_vote_status_form").innerHTML = "' . JText::_('EMAIL_INVALID', true) . '";
				setTimeout("document.getElementById(\'hikashop_vote_status_form\').innerHTML = \'\'",2250);
			}
		}else{
			if(hikashop_vote_vote_comment == 1){ // Save comment & vote.
				var hikashop_vote = document.getElementById("hikashop_vote_rating_id").value;
				if(hikashop_vote_comment == "" || hikashop_vote_ok == 0){ // Just show a message
					document.getElementById("hikashop_vote_status_form").innerHTML = "' . JText::_('VOTE_AND_COMMENT_PLEASE', true) . '";
					setTimeout("document.getElementById(\'hikashop_vote_status_form\').innerHTML = \'\'",2250);
				}else{
					var data = window.Oby.getFormData("hikashop_comment_form");
					var regEx = /ctrl=(.*?)&/;
					data = data.replace(regEx,"");
					var regEx = /task=(.*?)&/;
					data = data.replace(regEx,"");
					var regEx = /limitstart=(.*?)&/;
					data = data.replace(regEx,"");
					data += "&hikashop_vote_type=both";
					regEx = /hikashop_vote_ref_id/;
					if(!regEx.test(data)){
						data += "&vote_type=" + encodeURIComponent(vote_type);
						data += "&email_comment=" + encodeURIComponent(email_comment);
						data += "&pseudo_comment=" + encodeURIComponent(pseudo_comment);
						data += "&hikashop_vote_user_id=" + encodeURIComponent(hikashop_vote_user_id);
						data += "&hikashop_vote_ref_id=" + encodeURIComponent(hikashop_vote_ref_id);
						data += "&hikashop_vote_comment=" + encodeURIComponent(hikashop_vote_comment);
					}
					data += "&hikashop_vote=" + encodeURIComponent(hikashop_vote);
					window.Oby.xRequest("' . $ajaxUrl . '", {mode: "POST", data: data}, function(xhr) {
						var el = document.getElementById("hikashop_vote_status_form");
						if(xhr.responseText == "1"){el.innerHTML = " ' . JText::_('THANKS_FOR_PARTICIPATION', true) . '";document.getElementById("hikashop_vote_comment").value="";}
						else if(xhr.responseText == "3"){el.innerHTML = " ' . JText::_('MUST_HAVE_BUY_TO_VOTE', true) . '";}
						else if(xhr.responseText == "2"){el.innerHTML = " ' . JText::_('REACH_LIMIT_OF_COMMENT', true) . '";}
						else{el.innerHTML = " ' . JText::_('VOTE_ERROR', true) . '";}
					});
					setTimeout("document.location=\'' . $current_url . '\'",2250);
				}
			}else if(hikashop_vote_comment != ""){
				var data = window.Oby.getFormData("hikashop_comment_form");
				var regEx = /ctrl=(.*?)&/;
				data = data.replace(regEx,"");
				var regEx = /task=(.*?)&/;
				data = data.replace(regEx,"");
				var regEx = /limitstart=(.*?)&/;
				data = data.replace(regEx,"");
				data += "&hikashop_vote_type=comment";
				regEx = /hikashop_vote_ref_id/;
				if(!regEx.test(data)){
					data += "&vote_type=" + encodeURIComponent(vote_type);
					data += "&email_comment=" + encodeURIComponent(email_comment);
					data += "&pseudo_comment=" + encodeURIComponent(pseudo_comment);
					data += "&hikashop_vote_user_id=" + encodeURIComponent(hikashop_vote_user_id);
					data += "&hikashop_vote_ref_id=" + encodeURIComponent(hikashop_vote_ref_id);
					data += "&hikashop_vote_comment=" + encodeURIComponent(hikashop_vote_comment);
				}
				window.Oby.xRequest("' . $ajaxUrl . '", {mode: "POST", data: data}, function(xhr) {
					var el = document.getElementById("hikashop_vote_status_form");
					if(xhr.responseText == "1"){el.innerHTML = " ' . JText::_('THANKS_FOR_COMMENT', true) . '";document.getElementById("hikashop_vote_comment").value="";}
					else if(xhr.responseText == "3"){el.innerHTML = " ' . JText::_('MUST_HAVE_BUY_TO_VOTE', true) . '";}
					else if(xhr.responseText == "2"){el.innerHTML = " ' . JText::_('REACH_LIMIT_OF_COMMENT', true) . '";}
					else{el.innerHTML = " ' . JText::_('VOTE_ERROR', true) . '";}
				});
				setTimeout("document.location=\'' . $current_url . '\'",2250);
			}else{
				document.getElementById("hikashop_vote_status_form").innerHTML = " ' . JText::_('PLEASE_COMMENT', true) . '";
				setTimeout("document.getElementById(\'hikashop_vote_status_form\').innerHTML = \'\'",2250);
			}
		}
	}else{
		document.getElementById("hikashop_vote_status_form").innerHTML = " ' . JText::_('ONLY_REGISTERED_CAN_COMMENT', true) . '";
		setTimeout("document.getElementById(\'hikashop_vote_status_form\').innerHTML = \'\'",2250);
	}
}
';
        if (!HIKASHOP_PHP5) {
            $doc =& JFactory::getDocument();
        } else {
            $doc = JFactory::getDocument();
        }
        $doc->addScriptDeclaration("\n<!--\n" . $js . "\n//-->\n");
        if (!HIKASHOP_J30) {
            JHTML::_('behavior.mootools');
        } else {
            JHTML::_('behavior.framework');
        }
    }
Ejemplo n.º 16
0
 function addRate(&$rates, $type, $parcel, &$rate, $currency, $nb_package)
 {
     if (empty($nb_package)) {
         $nb_package = 1;
     }
     $parcel->Service_Type = $type;
     $url = 'http://drc.edeliver.com.au/ratecalc.asp?';
     foreach (get_object_vars($parcel) as $key => $val) {
         $url .= $key . '=' . $val . '&';
     }
     $url = rtrim($url, '&');
     $url = parse_url($url);
     if (!isset($url['query'])) {
         $url['query'] = '';
     }
     if (!isset($url['port'])) {
         if (!empty($url['scheme']) && in_array($url['scheme'], array('https', 'ssl'))) {
             $url['port'] = 443;
         } else {
             $url['port'] = 80;
         }
     }
     if (!empty($url['scheme']) && in_array($url['scheme'], array('https', 'ssl'))) {
         $url['host_socket'] = 'ssl://' . $url['host'];
     } else {
         $url['host_socket'] = $url['host'];
     }
     $fp = fsockopen($url['host_socket'], $url['port'], $errno, $errstr, 30);
     if (!$fp) {
         $app = JFactory::getApplication();
         $app->enqueueMessage('Cannot connect to australia post web service. You hosting company might be blocking outbond connections');
         return false;
     }
     $uri = $url['path'] . ($url['query'] != '' ? '?' . $url['query'] : '');
     $header = "GET {$uri} HTTP/1.0\r\n" . "User-Agent: PHP/" . phpversion() . "\r\n" . "Referer: " . hikashop_currentURL() . "\r\n" . "Server: " . $_SERVER['SERVER_SOFTWARE'] . "\r\n" . "Host: " . $url['host'] . ":" . $url['port'] . "\r\n" . "Accept: */" . "*\r\n\r\n";
     fwrite($fp, $header);
     $response = '';
     while (!feof($fp)) {
         $response .= fgets($fp, 1024);
     }
     fclose($fp);
     $pos = strpos($response, "\r\n\r\n");
     $header = substr($response, 0, $pos);
     $body = substr($response, $pos + 2 * strlen("\r\n\r\n"));
     if (preg_match_all('#([a-z_]+)=([a-z_\\.0-9 ]+?)#Ui', $response, $matches)) {
         $data = array();
         foreach ($matches[1] as $key => $val) {
             $data[$val] = $matches[2][$key];
         }
         if (!empty($data['err_msg'])) {
             if ($data['err_msg'] == 'OK') {
                 if (empty($rates[$type])) {
                     $info = new stdClass();
                     $info = !HIKASHOP_PHP5 ? $rate : clone $rate;
                     $info->shipping_name .= ' ' . JText::_($type);
                     if (!empty($rate->shipping_description)) {
                         $info->shipping_description = $rate->shipping_description . ' ';
                     } else {
                         $shipping_description = JText::_($type . '_DESCRIPTION');
                         if ($shipping_description == $type . '_DESCRIPTION') {
                             $info->shipping_description .= $shipping_description;
                         }
                         $info->shipping_description = $shipping_description;
                     }
                     $types = array('SEA' => 1, 'AIR' => 2, 'EXPRESS' => 3, 'STANDARD' => 4);
                     $info->shipping_id .= '-' . $types[$type];
                     $rates[$type] = $info;
                 } else {
                     $shipping_description = JText::_($type . '_DESCRIPTION');
                     if ($shipping_description == $type . '_DESCRIPTION') {
                         $shipping_description = '';
                     }
                     if (empty($shipping_description)) {
                         $shipping_description = $rate->shipping_description;
                     }
                     if (!empty($shipping_description)) {
                         $shipping_description .= '<br/>';
                     }
                     if ($nb_package > 1 && (isset($rate->shipping_params->shipping_group) && $rate->shipping_params->shipping_group)) {
                         $rates[$type]->shipping_description = $shipping_description . JText::sprintf('X_PACKAGES', $nb_package);
                     } else {
                         $rates[$type]->shipping_description = $shipping_description;
                     }
                 }
                 if (@$rates[$type]->shipping_tax_id) {
                     $currencyClass = hikashop_get('class.currency');
                     $data['charge'] = $currencyClass->getUntaxedPrice($data['charge'], hikashop_getZone(), $rates[$type]->shipping_tax_id);
                 }
                 $rates[$type]->shipping_price += $data['charge'];
             } elseif (!empty($data['err_msg'])) {
                 if (preg_match('#Selected Destination not reached by .*#i', $data['err_msg'])) {
                     return true;
                 }
                 $app = JFactory::getApplication();
                 $app->enqueueMessage('The request to the Australia Post server failed with the message: ' . $data['err_msg']);
             } else {
                 $app = JFactory::getApplication();
                 $app->enqueueMessage('The request to the Australia Post server failed');
             }
         }
     }
 }
Ejemplo n.º 17
0
 function onPaymentNotification(&$statuses)
 {
     $vars = array();
     $data = array();
     $filter = JFilterInput::getInstance();
     foreach ($_REQUEST as $key => $value) {
         $key = $filter->clean($key);
         if (preg_match('#^[0-9a-z_-]{1,30}$#i', $key) && !preg_match('#^cmd$#i', $key)) {
             $value = JRequest::getString($key);
             $vars[$key] = $value;
             $data[] = $key . '=' . urlencode($value);
         }
     }
     $data = implode('&', $data) . '&cmd=_notify-validate';
     $dbOrder = $this->getOrder((int) @$vars['invoice']);
     $this->loadPaymentParams($dbOrder);
     if (empty($this->payment_params)) {
         return false;
     }
     $this->loadOrderData($dbOrder);
     if (!$this->payment_params->notification) {
         return false;
     }
     if ($this->payment_params->debug) {
         echo print_r($vars, true) . "\r\n\r\n";
     }
     if (empty($dbOrder)) {
         echo 'Could not load any order for your notification ' . @$vars['invoice'];
         return false;
     }
     if ($this->payment_params->debug) {
         echo print_r($dbOrder, true) . "\r\n\r\n";
     }
     $order_id = $dbOrder->order_id;
     $url = HIKASHOP_LIVE . 'administrator/index.php?option=com_hikashop&ctrl=order&task=edit&order_id=' . $order_id;
     $order_text = "\r\n" . JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE', $dbOrder->order_number, HIKASHOP_LIVE);
     $order_text .= "\r\n" . str_replace('<br/>', "\r\n", JText::sprintf('ACCESS_ORDER_WITH_LINK', $url));
     if (!empty($this->payment_params->ips)) {
         $ip = hikashop_getIP();
         $ips = str_replace(array('.', '*', ','), array('\\.', '[0-9]+', '|'), $this->payment_params->ips);
         if (!preg_match('#(' . implode('|', $ips) . ')#', $ip)) {
             $email = new stdClass();
             $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Paypal') . ' ' . JText::sprintf('IP_NOT_VALID', $dbOrder->order_number);
             $email->body = str_replace('<br/>', "\r\n", JText::sprintf('NOTIFICATION_REFUSED_FROM_IP', 'Paypal', $ip, implode("\r\n", $this->payment_params->ips))) . "\r\n\r\n" . JText::sprintf('CHECK_DOCUMENTATION', HIKASHOP_HELPURL . 'payment-paypal-error#ip') . $order_text;
             $action = false;
             $this->modifyOrder($action, null, null, $email);
             JError::raiseError(403, JText::_('Access Forbidden'));
             return false;
         }
     }
     if (empty($this->payment_params->url)) {
         $this->payment_params->url = 'https://www.paypal.com/cgi-bin/webscr';
     }
     $url = parse_url($this->payment_params->url);
     if (!isset($url['query'])) {
         $url['query'] = '';
     }
     if (!isset($url['port'])) {
         if (!empty($url['scheme']) && in_array($url['scheme'], array('https', 'ssl'))) {
             $url['port'] = 443;
         } else {
             $url['port'] = 80;
         }
     }
     if (!empty($url['scheme']) && in_array($url['scheme'], array('https', 'ssl'))) {
         $url['host_socket'] = 'ssl://' . $url['host'];
     } else {
         $url['host_socket'] = $url['host'];
     }
     if ($this->payment_params->debug) {
         echo print_r($url, true) . "\r\n\r\n";
     }
     $fp = fsockopen($url['host_socket'], $url['port'], $errno, $errstr, 30);
     if (!$fp) {
         $email = new stdClass();
         $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Paypal') . ' ' . JText::sprintf('PAYPAL_CONNECTION_FAILED', $dbOrder->order_number);
         $email->body = str_replace('<br/>', "\r\n", JText::sprintf('NOTIFICATION_REFUSED_NO_CONNECTION', 'Paypal')) . "\r\n\r\n" . JText::sprintf('CHECK_DOCUMENTATION', HIKASHOP_HELPURL . 'payment-paypal-error#connection') . $order_text;
         $action = false;
         $this->modifyOrder($action, null, null, $email);
         JError::raiseError(403, JText::_('Access Forbidden'));
         return false;
     }
     $uri = $url['path'] . ($url['query'] != '' ? '?' . $url['query'] : '');
     $header = 'POST ' . $uri . ' HTTP/1.1' . "\r\n" . 'User-Agent: PHP/' . phpversion() . "\r\n" . 'Referer: ' . hikashop_currentURL() . "\r\n" . 'Server: ' . $_SERVER['SERVER_SOFTWARE'] . "\r\n" . 'Host: ' . $url['host'] . "\r\n" . 'Content-Type: application/x-www-form-urlencoded' . "\r\n" . 'Content-Length: ' . strlen($data) . "\r\n" . 'Accept: */' . '*' . "\r\n" . 'Connection: close' . "\r\n\r\n";
     fwrite($fp, $header . $data);
     $response = '';
     while (!feof($fp)) {
         $response .= fgets($fp, 1024);
     }
     fclose($fp);
     if ($this->payment_params->debug) {
         echo print_r($header, true) . "\r\n\r\n";
         echo print_r($data, true) . "\r\n\r\n";
         echo print_r($response, true) . "\r\n\r\n";
     }
     $response = substr($response, strpos($response, "\r\n\r\n") + strlen("\r\n\r\n"));
     $verified = preg_match('#VERIFIED#i', $response);
     if (!$verified) {
         $email = new stdClass();
         if (preg_match('#INVALID#i', $response)) {
             $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Paypal') . 'invalid transaction';
             $email->body = JText::sprintf("Hello,\r\n A paypal notification was refused because it could not be verified by the paypal server") . "\r\n\r\n" . JText::sprintf('CHECK_DOCUMENTATION', HIKASHOP_HELPURL . 'payment-paypal-error#invalidtnx') . $order_text;
             if ($this->payment_params->debug) {
                 echo 'invalid transaction' . "\n\n\n";
             }
         } else {
             $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Paypal') . 'invalid response';
             $email->body = JText::sprintf("Hello,\r\n A paypal notification was refused because the response from the paypal server was invalid") . "\r\n\r\n" . JText::sprintf('CHECK_DOCUMENTATION', HIKASHOP_HELPURL . 'payment-paypal-error#invalidresponse') . $order_text;
             if ($this->payment_params->debug) {
                 echo 'invalid response' . "\n\n\n";
             }
         }
         $action = false;
         $this->modifyOrder($action, null, null, $email);
         return false;
     }
     $completed = preg_match('#Completed#i', $vars['payment_status']);
     $pending = preg_match('#Pending#i', $vars['payment_status']);
     if (!$completed && !$pending) {
         $email = new stdClass();
         $email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', 'Paypal', $vars['payment_status'], $dbOrder->order_number);
         $email->body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Paypal', $vars['payment_status'])) . ' ' . JText::_('STATUS_NOT_CHANGED') . "\r\n\r\n" . JText::sprintf('CHECK_DOCUMENTATION', HIKASHOP_HELPURL . 'payment-paypal-error#status') . $order_text;
         $action = false;
         $this->modifyOrder($action, null, null, $email);
         if ($this->payment_params->debug) {
             echo 'payment ' . $vars['payment_status'] . "\r\n\r\n";
         }
         return false;
     }
     echo 'PayPal transaction id: ' . $vars['txn_id'] . "\r\n\r\n";
     $history = new stdClass();
     $history->notified = 0;
     $history->amount = @$vars['mc_gross'] . @$vars['mc_currency'];
     $history->data = ob_get_clean();
     $price_check = round($dbOrder->order_full_price, (int) $this->currency->currency_locale['int_frac_digits']);
     if ($price_check != @$vars['mc_gross'] || $this->currency->currency_code != @$vars['mc_currency']) {
         $email = new stdClass();
         $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Paypal') . JText::_('INVALID_AMOUNT');
         $email->body = str_replace('<br/>', "\r\n", JText::sprintf('AMOUNT_RECEIVED_DIFFERENT_FROM_ORDER', 'Paypal', $history->amount, $price_check . $this->currency->currency_code)) . "\r\n\r\n" . JText::sprintf('CHECK_DOCUMENTATION', HIKASHOP_HELPURL . 'payment-paypal-error#amount') . $order_text;
         $this->modifyOrder($order_id, $this->payment_params->invalid_status, $history, $email);
         return false;
     }
     if (strtolower(@$vars['receiver_email']) != strtolower($this->payment_params->email) && strtolower(@$vars['business']) != strtolower($this->payment_params->email)) {
         $email = new stdClass();
         $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Paypal') . 'wrong receiver';
         $email->body = str_replace('<br/>', "\r\n", 'The money was sent to the wrong PayPal account, likely due to the customer trying to cheat.' . "\r\n" . 'Notification receiver: ' . @$vars['receiver_email'] . "\r\n" . 'Notification business: ' . @$vars['business'] . "\r\n" . 'Your paypal address: ' . $this->payment_params->email . "\r\n" . $order_text);
         $this->modifyOrder($order_id, $this->payment_params->invalid_status, $history, $email);
         return false;
     }
     if ($completed) {
         $order_status = $this->payment_params->verified_status;
     } else {
         $order_status = $this->payment_params->pending_status;
         $order_text = JText::sprintf('CHECK_DOCUMENTATION', HIKASHOP_HELPURL . 'payment-paypal-error#pending') . "\r\n\r\n" . $order_text;
     }
     if ($dbOrder->order_status == $order_status) {
         return true;
     }
     $config =& hikashop_config();
     if ($config->get('order_confirmed_status', 'confirmed') == $order_status) {
         $history->notified = 1;
     }
     $email = new stdClass();
     $email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', 'Paypal', $vars['payment_status'], $dbOrder->order_number);
     $email->body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Paypal', $vars['payment_status'])) . ' ' . JText::sprintf('ORDER_STATUS_CHANGED', $order_status) . "\r\n\r\n" . $order_text;
     $this->modifyOrder($order_id, $order_status, $history, $email);
     return true;
 }