示例#1
0
文件: click.php 项目: rodhoff/MNW
 function save(&$element)
 {
     if (empty($element->click_id)) {
         if (empty($element->click_created)) {
             $element->click_created = time();
         }
         if (empty($element->click_ip)) {
             $element->click_ip = hikashop_getIP();
         }
         if (empty($element->click_referer)) {
             if (!empty($_SERVER['HTTP_REFERER']) && preg_match('#^https?://.*#i', $_SERVER['HTTP_REFERER'])) {
                 $element->click_referer = str_replace(array('"', '<', '>', "'"), '', @$_SERVER['HTTP_REFERER']);
             }
         }
     }
     return parent::save($element);
 }
示例#2
0
 function onAfterOrderUpdate(&$order, &$send_email)
 {
     if (!empty($order->order_id)) {
         $history = new stdClass();
         $history->history_order_id = $order->order_id;
         $history->history_created = time();
         $history->history_ip = hikashop_getIP();
         $history->history_user_id = hikashop_loadUser();
         if (empty($order->order_status)) {
             $class = hikashop_get('class.order');
             $old = $class->get($order->order_id);
             $order->order_status = $old->order_status;
         }
         $history->history_new_status = $order->order_status;
         if (!empty($order->history)) {
             foreach (get_object_vars($order->history) as $k => $v) {
                 $history->{$k} = $v;
             }
         }
         $historyClass = hikashop_get('class.history');
         $historyClass->save($history);
     }
     return true;
 }
    function onPaymentNotification(&$statuses)
    {
        $vars = array();
        $data = array();
        $filter = JFilterInput::getInstance();
        foreach ($_POST 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';
        $order_id = (int) @$vars['cartId'];
        $dbOrder = $this->getOrder($order_id);
        if (empty($dbOrder)) {
            echo "Could not load any order for your notification " . @$vars['cartId'];
            return false;
        }
        $this->loadPaymentParams($dbOrder);
        if (empty($this->payment_params)) {
            return false;
        }
        if ($this->payment_params->debug) {
            echo print_r($vars, true) . "\n\n\n";
            echo print_r($dbOrder, true) . "\n\n\n";
        }
        $this->loadOrderData($dbOrder);
        if (@$vars['instId'] != $this->payment_params->instid) {
            return false;
        }
        $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', hikashop_encode($dbOrder), HIKASHOP_LIVE);
        $order_text .= "\r\n" . str_replace('<br/>', "\r\n", JText::sprintf('ACCESS_ORDER_WITH_LINK', $url));
        $hostError = -1;
        $ip = hikashop_getIP();
        if (!empty($element->payment_params->hostname)) {
            // \.outbound\.wp3\.rbsworldpay\.com
            $hostname = gethostbyaddr($ip);
            if (preg_match('#' . $this->payment_params->hostname . '#i', $hostname)) {
                $hostError = 0;
            } else {
                $hostError = 1;
            }
        }
        if ($hostError < 0 && !empty($this->payment_params->ips)) {
            $ips = str_replace(array('.', '*', ','), array('\\.', '[0-9]+', '|'), $this->payment_params->ips);
            if (!empty($ips)) {
                if (preg_match('#(' . implode('|', $ips) . ')#', $ip)) {
                    $hostError = 0;
                } else {
                    $hostError = 1;
                }
            }
        }
        if ($hostError > 0) {
            $email = new stdClass();
            $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Worldpay Business Gateway') . ' ' . JText::sprintf('IP_NOT_VALID', hikashop_encode($dbOrder));
            $body = str_replace('<br/>', "\r\n", JText::sprintf('NOTIFICATION_REFUSED_FROM_IP', 'Worldpay Business Gateway', $ip, 'See Hostname / IPs defined in configuration')) . "\r\n\r\n" . JText::sprintf('CHECK_DOCUMENTATION', HIKASHOP_HELPURL . 'payment-rbsworldpay-error#ip') . $order_text;
            $email->body = $body;
            $this->modifyOrder($order_id, $this->payment_params->invalid_status, false, $email);
            JError::raiseError(403, JText::_('Access Forbidden'));
            return false;
        }
        switch ($vars['transStatus']) {
            case 'Y':
                break;
            default:
                $email = new stdClass();
                $email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', 'Worldpay Business Gateway', $vars['transStatus'], $dbOrder->order_number);
                $body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Worldpay Business Gateway', $vars['payment_status'])) . ' ' . JText::_('STATUS_NOT_CHANGED') . "\r\n\r\n" . JText::sprintf('CHECK_DOCUMENTATION', HIKASHOP_HELPURL . 'payment-rbsworldpay-error#status') . $order_text;
                $email->body = $body;
                $this->modifyOrder($order_id, $this->payment_params->invalid_status, false, $email);
                if ($this->payment_params->debug) {
                    echo 'payment ' . $vars['transStatus'] . "\n\n\n";
                    echo '[OK]';
                }
                $dbg = ob_get_clean();
                $return_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=order&task=cancel_order&order_id=' . $order_id . $this->url_itemid;
                echo '<meta http-equiv="refresh" content="5;url=' . $return_url . '" />
		<style>
		.pageHeading {
			font-family: Verdana, Arial, sans-serif;
			font-size: 20px;
			font-weight: bold;
			color: #9a9a9a;
		}

		.main {
			font-family: Verdana, Arial, sans-serif;
			font-size: 11px;
			line-height: 1.5;
		}
		</style>

		<p class="pageHeading">' . JText::sprintf('TRANSACTION_PROCESSING_ERROR', $vars['transStatus']) . '</p>

		<form action="' . $return_url . '" method="post">
			<div align="center">
				<input name="submit" type="submit" class="btn" value="' . JText::_('GO_BACK_TO_SHOP') . '" />
				</div>
		</form>

		<p>&nbsp;</p>

		<WPDISPLAY ITEM=banner>';
                ob_start();
                if ($this->payment_params->debug) {
                    echo $dbg;
                }
                return false;
        }
        $history = new stdClass();
        $email = new stdClass();
        $history->notified = 0;
        $history->amount = @$vars['amount'] . @$vars['currency'];
        $history->data = '';
        $price_check = round($dbOrder->order_full_price, (int) $this->currency->currency_locale['int_frac_digits']);
        if ($price_check != @$vars['amount'] || $this->currency->currency_code != @$vars['currency']) {
            $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Worldpay Business Gateway') . JText::_('INVALID_AMOUNT');
            $body = str_replace('<br/>', "\r\n", JText::sprintf('AMOUNT_RECEIVED_DIFFERENT_FROM_ORDER', 'Worldpay Business Gateway', $history->amount, $price_check . $this->currency->currency_code)) . "\r\n\r\n" . JText::sprintf('CHECK_DOCUMENTATION', HIKASHOP_HELPURL . 'payment-rbsworldpay-error#amount') . $order_text;
            $email->body = $body;
            $this->modifyOrder($order_id, $this->payment_params->invalid_status, $history, $email);
            return false;
        }
        switch ($vars['transStatus']) {
            case 'Y':
                $payment_status = 'Authenticated';
                $order_status = $this->payment_params->verified_status;
                $history->notified = 1;
                break;
            default:
                $payment_status = 'Unknown';
                $order_status = $this->payment_params->invalid_status;
                $order_text = JText::sprintf('CHECK_DOCUMENTATION', HIKASHOP_HELPURL . 'payment-rbsworldpay-error#pending') . "\r\n\r\n" . $order_text;
        }
        $mail_status = $statuses[$order->order_status];
        $email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', 'Worldpay Business Gateway', $payment_status, $dbOrder->order_number);
        $body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Worldpay Business Gateway', $order_status)) . ' ' . JText::sprintf('ORDER_STATUS_CHANGED', $mail_status) . "\r\n\r\n" . $order_text;
        $email->body = $body;
        $this->modifyOrder($order_id, $order_status, $history, $email);
        $return_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=checkout&task=after_end&order_id=' . $order->order_id . $this->url_itemid;
        if ($this->payment_params->debug) {
            echo '[OK]';
        }
        $dbg = ob_get_clean();
        echo '<meta http-equiv="refresh" content="5;url=' . $return_url . '" />
<style>
.pageHeading {
	font-family: Verdana, Arial, sans-serif;
	font-size: 20px;
	font-weight: bold;
	color: #9a9a9a;
}

.main {
	font-family: Verdana, Arial, sans-serif;
	font-size: 11px;
	line-height: 1.5;
}
</style>

<p class="pageHeading">' . JText::_('THANK_YOU_FOR_PURCHASE') . '</p>

<form action="' . $return_url . '" method="post">
	<div align="center">
		<input name="submit" type="submit" class="btn" value="' . JText::_('GO_BACK_TO_SHOP') . '" />
		</div>
</form>

<p>&nbsp;</p>

<WPDISPLAY ITEM=banner>';
        ob_start();
        if ($element->payment_params->debug) {
            echo $dbg;
        }
        return true;
    }
示例#4
0
                    }
                } else {
                    $hika_useless[$i] = 0;
                    $hika_useful[$i] = 0;
                    if ($useful_style == "helpful") {
                        if ($useful_rating == 1) {
                            echo JText::_('HIKASHOP_NO_USEFUL');
                        }
                    }
                }
                ?>
							</div>
						</td>
						<?php 
                if ($useful_rating == 1) {
                    if ($row->hide == 0 && $elt[$i]->already_vote == 0 && $elt[$i]->vote_user_id != $hikashop_vote_user_id && $elt[$i]->vote_user_id != hikashop_getIP()) {
                        ?>
								<?php 
                        if ($useful_style == "thumbs") {
                            ?>
									<td class="hika_comment_listing_useful_p ui-corner-all">
										<?php 
                            echo $hika_useful[$i];
                            ?>
									</td>
								<?php 
                        }
                        ?>
								<td class="hika_comment_listing_useful" title="Useful" onclick="hikashop_vote_useful(<?php 
                        echo $elt[$i]->vote_id;
                        ?>
示例#5
0
 function onPaymentNotification(&$statuses)
 {
     $vars = array();
     $data = array();
     $filter = JFilterInput::getInstance();
     foreach ($_POST as $key => $value) {
         $key = $filter->clean($key);
         $value = JRequest::getString($key);
         $vars[$key] = $value;
     }
     $order_id = (int) @$vars['transaction_id'];
     $dbOrder = $this->getOrder($order_id);
     if (!empty($dbOrder)) {
         $order->old_status->order_status = $dbOrder->order_status;
         $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));
     } else {
         echo "Could not load any order for your notification " . $order_id;
         return false;
     }
     $this->loadPaymentParams($dbOrder);
     if ($this->payment_params->debug) {
         echo print_r($dbOrder, true) . "\n\n\n";
     }
     if (empty($this->payment_params)) {
         return false;
     }
     $this->loadOrderData($dbOrder);
     if (!$this->payment_params->notification) {
         return false;
     }
     $vars['calculated_md5sig'] = strtoupper(md5(@$this->payment_params->merchant_id . @$vars['transaction_id'] . strtoupper(md5($this->payment_params->secret_word)) . @$vars['mb_amount'] . @$vars['mb_currency'] . @$vars['status']));
     if ($this->payment_params->debug) {
         echo print_r($vars, true) . "\n\n\n";
     }
     $mailer = JFactory::getMailer();
     $config =& hikashop_config();
     $sender = array($config->get('from_email'), $config->get('from_name'));
     $mailer->setSender($sender);
     $mailer->addRecipient(explode(',', $config->get('payment_notification_email')));
     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)) {
             $mailer->setSubject(JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Moneybookers') . ' ' . JText::sprintf('IP_NOT_VALID', $dbOrder->order_number));
             $body = str_replace('<br/>', "\r\n", JText::sprintf('NOTIFICATION_REFUSED_FROM_IP', 'Moneybookers', $ip, implode("\r\n", $this->payment_params->ips))) . "\r\n\r\n" . $order_text;
             $mailer->setBody($body);
             $mailer->Send();
             JError::raiseError(403, JText::_('Access Forbidden'));
             return false;
         }
     }
     if (@$vars['md5sig'] != $vars['calculated_md5sig']) {
         $mailer->setSubject(JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Moneybookers') . 'invalid response');
         $body = JText::sprintf("Hello,\r\n A Moneybookers notification was refused because the response from the Moneybookers server was invalid") . "\r\n\r\n" . $order_text;
         $mailer->setBody($body);
         $mailer->Send();
         if ($this->payment_params->debug) {
             echo 'invalid response' . "\n\n\n";
         }
         return false;
     }
     $vars['status'] = (int) @$vars['status'];
     if (!in_array($vars['status'], array(0, 2))) {
         if ($vars['status'] == -1) {
             $vars['payment_status'] = 'Cancelled';
         } elseif ($vars['status'] == -2) {
             $vars['payment_status'] = 'Failed';
         } elseif ($vars['status'] == -3) {
             $vars['payment_status'] = 'Chargeback';
         } else {
             $vars['payment_status'] = 'Unknown';
         }
         $body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Moneybookers', $vars['payment_status'])) . ' ' . JText::_('STATUS_NOT_CHANGED') . "\r\n\r\n" . $order_text;
         $mailer->setSubject(JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', 'Moneybookers', $vars['payment_status'], $dbOrder->order_number));
         $mailer->setBody($body);
         $mailer->Send();
         if ($element->payment_params->debug) {
             echo 'payment with code ' . @$vars['status'] . (!empty($vars['failed_reason_code']) ? ' : ' . @$vars['failed_reason_code'] : '') . "\n\n\n";
         }
         return false;
     }
     $this->modifyOrder($order_id, $vars['status'], true, true);
     return true;
 }
示例#6
0
文件: listing.php 项目: rodhoff/MNW
            if ($row->useful_style == 'helpful') {
                echo JText::sprintf('HIKA_FIND_IT_HELPFUL', $hika_useful, $elt->total_vote_useful);
            }
        } else {
            $hika_useless = 0;
            $hika_useful = 0;
            if ($row->useful_style == 'helpful' && $row->useful_rating == 1) {
                echo JText::_('HIKASHOP_NO_USEFUL');
            }
        }
        ?>
</div>
		</td>
<?php 
        if ($row->useful_rating == 1) {
            if ($row->hide == 0 && $elt->already_vote == 0 && $elt->vote_user_id != hikashop_loadUser() && $elt->vote_user_id != hikashop_getIP()) {
                if ($row->useful_style == 'thumbs') {
                    ?>
		<td class="hika_comment_listing_useful_p"><?php 
                    echo $hika_useful;
                    ?>
</td>
<?php 
                }
                ?>
		<td class="hika_comment_listing_useful" title="<?php 
                echo JText::_('HIKA_USEFUL');
                ?>
" onclick="hikashop_vote_useful(<?php 
                echo $elt->vote_id;
                ?>
示例#7
0
文件: bluepaid.php 项目: rodhoff/MNW
 function onPaymentNotification(&$statuses)
 {
     $vars = array();
     $data = array();
     $filter = JFilterInput::getInstance();
     foreach ($_POST as $key => $value) {
         $key = $filter->clean($key);
         $value = JRequest::getString($key);
         $vars[$key] = $value;
     }
     $order_id = (int) @$vars['divers'];
     $dbOrder = $this->getOrder($order_id);
     if (!empty($dbOrder)) {
         $url = HIKASHOP_LIVE . 'administrator/index.php?option=com_hikashop&ctrl=order&task=edit&order_id=' . $order->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));
     } else {
         echo "Could not load any order for your notification " . @$vars['divers'];
         return false;
     }
     $this->loadPaymentParams($dbOrder);
     if (empty($this->payment_params)) {
         return false;
     }
     $this->loadOrderData($dbOrder);
     if ($this->payment_params->debug) {
         echo print_r($vars, true) . "\n\n\n";
         echo print_r($dbOrder, true) . "\n\n\n";
     }
     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)) {
             $body = str_replace('<br/>', "\r\n", JText::sprintf('NOTIFICATION_REFUSED_FROM_IP', 'Bluepaid', $ip, implode("\r\n", $this->payment_params->ips))) . "\r\n\r\n" . $order_text;
             $email = new stdClass();
             $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Bluepaid') . ' ' . JText::sprintf('IP_NOT_VALID', $dbOrder->order_number);
             $email->body = $body;
             $this->modifyOrder($order_id, $this->payment_params->invalid_status, false, $email);
             JError::raiseError(403, JText::_('Access Forbidden'));
             return false;
         }
     }
     if ($vars['secure_key'] != @$this->payment_params->secure_key) {
         $body = JText::sprintf("Hello,\r\n A Bluepaid notification was refused because the response from the Bluepaid server was invalid") . "\r\n\r\n" . $order_text;
         $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Bluepaid') . 'invalid response';
         $email->body = $body;
         $this->modifyOrder($order_id, $this->payment_params->invalid_status, false, $email);
         if ($element->payment_params->debug) {
             echo 'invalid response' . "\n\n\n";
         }
         return false;
     }
     $vars['status'] = strtolower(@$vars['etat']);
     if (!in_array($vars['status'], array("attente", "ok"))) {
         if ($vars['status'] == "annu") {
             $vars['payment_status'] = 'Cancelled';
         } elseif ($vars['status'] == "ko") {
             $vars['payment_status'] = 'Failed';
         } else {
             $vars['payment_status'] = 'Unknown';
         }
         $body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Bluepaid', $vars['payment_status'])) . ' ' . JText::_('STATUS_NOT_CHANGED') . "\r\n\r\n" . $order_text;
         $email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', 'Bluepaid', $vars['payment_status'], $dbOrder->order_number);
         $email->body = $body;
         $this->modifyOrder($order_id, null, false, $email);
         if ($element->payment_params->debug) {
             echo 'payment with code ' . @$vars['status'] . (!empty($vars['failed_reason_code']) ? ' : ' . @$vars['failed_reason_code'] : '') . "\n\n\n";
         }
         return false;
     }
     $history = new stdClass();
     $history->notified = 0;
     $history->amount = @$vars['montant'] . @$vars['devise'];
     $history->data = ob_get_clean();
     $price_check = round($dbOrder->order_full_price, (int) $this->currency->currency_locale['int_frac_digits']) . $this->currency->currency_code;
     if ($price_check != @$vars['montant'] . @$vars['devise']) {
         $mailer->setSubject(JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Bluepaid') . JText::_('INVALID_AMOUNT'));
         $body = str_replace('<br/>', "\r\n", JText::sprintf('AMOUNT_RECEIVED_DIFFERENT_FROM_ORDER', 'Bluepaid', $order->history->amount, $price_check)) . "\r\n\r\n" . $order_text;
         $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Bluepaid') . JText::_('INVALID_AMOUNT');
         $email->body = $body;
         $this->modifyOrder($order_id, $this->payment_params->invalid_status, $history, $email);
         return false;
     }
     if ($vars['status'] == "ok") {
         $order_status = $this->payment_params->verified_status;
         $vars['payment_status'] = 'Accepted';
     } else {
         $order_status = $this->payment_params->pending_status;
         $order_text = "Payment is pending\r\n\r\n" . $order_text;
         $vars['payment_status'] = 'Pending';
     }
     $config =& hikashop_config();
     if ($config->get('order_confirmed_status', 'confirmed') == $order_status) {
         $history->notified = 1;
     }
     $body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Bluepaid', $vars['payment_status'])) . ' ' . JText::sprintf('ORDER_STATUS_CHANGED', $statuses[$order->order_status]) . "\r\n\r\n" . $order_text;
     $email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', 'Bluepaid', $vars['payment_status'], $dbOrder->order_number);
     $email->body = $body;
     $this->modifyOrder($order_id, $order_status, $history, $email);
     return true;
 }
示例#8
0
 function getZone()
 {
     $app = JFactory::getApplication();
     $zone = $app->getUserState(HIKASHOP_COMPONENT . '.zone_id', 0);
     if (empty($zone)) {
         $geoClass = hikashop_get('class.geolocation');
         $this->geolocation = $geoClass->getIPLocation(hikashop_getIP());
         if (!empty($this->geolocation)) {
             $geolocation_country_code = $this->geolocation->countryCode;
             $db = JFactory::getDBO();
             $db->setQuery('SELECT * FROM ' . hikashop_table('zone') . ' WHERE zone_code_2 =' . $db->Quote($geolocation_country_code) . ' AND zone_type=\'country\'  AND zone_published=1');
             $zones = $db->loadObjectList();
             if (!empty($zones)) {
                 $states = array();
                 $countries = array();
                 foreach ($zones as $zone) {
                     if ($zone->zone_type == 'state') {
                         $states[] = $zone;
                     } else {
                         $countries[] = $zone;
                     }
                 }
                 if (!empty($states)) {
                     if (empty($countries)) {
                         $zone = $states[0]->zone_id;
                     } else {
                         $child_namekeys = array();
                         foreach ($states as $state) {
                             $child_namekeys[] = $db->Quote($state->zone_namekey);
                         }
                         $parent_namekeys = array();
                         foreach ($countries as $country) {
                             $parent_namekeys[] = $db->Quote($country->zone_namekey);
                         }
                         $db->setQuery('SELECT zone_child_namekey FROM ' . hikashop_table('zone_link') . ' WHERE zone_parent_namekey IN (' . implode(',', $parent_namekeys) . ') AND zone_child_namekey IN (' . implode(',', $child_namekeys) . ')');
                         $link = $db->loadResult();
                         if (empty($link)) {
                             $zone = $countries[0]->zone_id;
                         } else {
                             foreach ($states as $state) {
                                 if ($state->zone_namekey == $link) {
                                     $zone = $state->zone_id;
                                 }
                             }
                         }
                     }
                 } else {
                     $zone = $countries[0]->zone_id;
                 }
             }
             if (empty($zone)) {
                 $db->setQuery('SELECT zone_id FROM ' . hikashop_table('zone') . ' WHERE 	zone_code_2=' . $db->Quote($geolocation_country_code) . ' AND zone_published=1');
                 $zone = $db->loadResult();
             }
             if (!empty($zone)) {
                 $app->setUserState(HIKASHOP_COMPONENT . '.zone_id', $zone);
             }
         }
     }
     return $zone;
 }
示例#9
0
文件: vote.php 项目: rodhoff/MNW
 function save(&$element)
 {
     $this->app = Jfactory::getApplication();
     $this->config = hikashop_config();
     $dispatcher = JDispatcher::getInstance();
     $db = JFactory::getDBO();
     if (isset($element->vote_ref_id) || !$this->app->isAdmin()) {
         $this->checkVote($element);
     }
     if (!empty($this->error['code'])) {
         return false;
     }
     $element->vote_date = time();
     if (!$this->app->isAdmin()) {
         $element->vote_ip = hikashop_getIP();
         if (!empty($element->vote_comment) && !$this->config->get('published_comment', '1')) {
             $element->vote_published = 0;
         } else {
             $element->vote_published = 1;
         }
     }
     $oldElement = new stdClass();
     if ($this->app->isAdmin()) {
         if ($element->vote_id != '0') {
             $query = 'SELECT * FROM ' . hikashop_table('vote') . ' WHERE vote_id = ' . (int) $element->vote_id;
             $db->setQuery($query);
             $result = $db->loadObject();
             if (!empty($result)) {
                 $oldElement = $result;
                 if (!isset($element->vote_ref_id)) {
                     $published = $element->vote_published;
                     $element = clone $result;
                     $element->vote_published = $published;
                 }
                 $element->vote_type = $result->vote_type;
             } else {
                 $this->error = array('code' => '505018', 'message' => JText::_('HIKA_VOTE_MISSING_ENTRY'));
                 return false;
             }
         }
     } elseif ($element->vote_rating != 0 && !in_array($this->config->get('enable_status_vote', 'nothing'), array('nothing', 'comment', 'both'))) {
         //If it is only a rating
         $result = $this->getUserRating($element->vote_type, $element->vote_ref_id, $element->vote_user_id);
         if (!empty($result)) {
             $element->vote_id = $result->vote_id;
             $element->vote_published = $result->vote_published;
             $oldElement = $result;
         } else {
             $element->vote_id = 0;
         }
     } else {
         $element->vote_id = 0;
     }
     $new = false;
     if ($element->vote_id == 0) {
         $new = true;
     }
     if ($new) {
         $dispatcher->trigger('onBeforeVoteCreate', array(&$oldElement, &$do, &$element));
     } else {
         $dispatcher->trigger('onBeforeVoteUpdate', array(&$oldElement, &$do, &$element));
     }
     $success = parent::save($element);
     if (!$success) {
         $this->error = array('code' => '505016', 'message' => JText::_('HIKA_VOTE_ERROR_SAVING_DATA'));
         return false;
     }
     $return_data = array('average' => 0, 'total' => 0);
     if ($element->vote_type != 'product') {
         $db = JFactory::getDBO();
         $query = 'SELECT AVG(v.vote_rating) AS average, COUNT(v.vote_id) AS total FROM ' . hikashop_table('vote') . ' AS v ' . ' WHERE vote_ref_id = ' . (int) $element->vote_ref_id . ' AND vote_type = ' . $db->Quote($element->vote_type) . ' AND v.vote_rating != 0';
         $db->setQuery($query);
         $data = $db->loadObject();
         if ($data->total == 0) {
             $return_data['average'] = $element->vote_rating;
             $return_data['total'] = 1;
         } else {
             if (!$new) {
                 $return_data['average'] = ($data->total * $data->average - $oldElement->vote_rating + $element->vote_rating) / $data->total;
                 $return_data['total'] = $data->total;
             } else {
                 $return_data['average'] = ($data->total * $data->average + $element->vote_rating) / ($data->total + 1);
                 $return_data['total'] = $data->total++;
             }
         }
     }
     if (!$new) {
         $dispatcher->trigger('onAfterVoteCreate', array(&$element, &$return_data));
         $this->error = array('code' => '1', 'message' => JText::_('VOTE_UPDATED'));
     } else {
         $dispatcher->trigger('onAfterVoteUpdate', array(&$element, &$return_data));
         $this->error = array('code' => '2', 'message' => JText::_('THANK_FOR_VOTE'));
     }
     $itemClass = hikashop_get('class.' . $element->vote_type);
     if ($itemClass === null) {
         return true;
     }
     if (is_object($itemClass) && !empty($itemClass)) {
         $data = $itemClass->get($element->vote_ref_id);
         if (isset($data->alias)) {
             unset($data->alias);
         }
     } else {
         $data = new stdClass();
     }
     if ($element->vote_rating == 0) {
         return false;
     }
     if ($element->vote_type == 'product') {
         $newValues = $this->updateAverage($element, $oldElement, $data);
         $return_data = array('average' => $newValues->product_average_score, 'total' => $newValues->product_total_vote);
     }
     $this->values = $return_data;
     $success = $itemClass->save($data);
     if (!$success) {
         $this->error = array('code' => '505013', 'message' => JText::_('HIKA_VOTE_ERROR_SAVING_ITEM_DATA'));
         return false;
     }
     return true;
 }
示例#10
0
 function onAfterStoreUser($user, $isnew, $success, $msg)
 {
     if ($success === false) {
         return false;
     }
     $app = JFactory::getApplication();
     if ($app->isAdmin() || !$isnew) {
         return true;
     }
     $partner_id = JRequest::getCmd('hikashop_affiliate', 0, 'cookie');
     if (empty($partner_id)) {
         return true;
     }
     if (!(include_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_hikashop' . DS . 'helpers' . DS . 'helper.php')) {
         return true;
     }
     $partner_id = hikashop_decode($partner_id, 'partner');
     $userClass = hikashop_get('class.user');
     $partner = $userClass->get($partner_id);
     if (empty($partner->user_partner_activated)) {
         return true;
     }
     $config =& hikashop_config();
     if (empty($partner->user_params->user_custom_fee)) {
         $partner->user_params->partner_lead_fee = $config->get('partner_lead_fee', 0);
         $partner->user_params->partner_fee_currency = $config->get('partner_currency', 1);
     } else {
         $partner->user_params->partner_lead_fee = $partner->user_params->user_partner_lead_fee;
     }
     if (!$config->get('allow_currency_selection', 0) || empty($partner->user_currency_id)) {
         $partner->user_currency_id = $config->get('partner_currency', 1);
     }
     if (bccomp($partner->user_params->partner_lead_fee, 0, 5) && $partner->user_currency_id != $partner->user_params->partner_fee_currency) {
         $partner->user_params->partner_lead_fee = $this->_convert($partner->user_params->partner_lead_fee, $partner->user_params->partner_fee_currency, $partner->user_currency_id);
     }
     $ip = hikashop_getIP();
     $clickClass = hikashop_get('class.click');
     $latest = $clickClass->getLatest($partner_id, $ip, $config->get('lead_min_delay', 24));
     if ($config->get('add_partner_to_user_account', 0) || empty($latest) && bccomp($partner->user_params->partner_lead_fee, 0, 5)) {
         $userDataInDb = $userClass->get($user['id'], 'cms');
         $userData = new stdClass();
         $userData->user_id = @$userDataInDb->user_id;
         $userData->user_cms_id = $user['id'];
         $userData->user_partner_id = $partner_id;
         $userData->user_partner_price = @$partner->user_params->partner_lead_fee;
         $userData->user_partner_currency_id = $partner->user_currency_id;
         $userClass->save($userData);
     }
     return true;
 }
示例#11
0
 function listing()
 {
     $doc = JFactory::getDocument();
     $doc->addScript(HIKASHOP_JS . 'vote.js');
     $class = hikashop_get('class.vote');
     $class->loadJS();
     $db = JFactory::getDBO();
     $config = hikashop_config();
     $type_item = JRequest::getCmd('ctrl');
     $ctrl_param = $this->params->get('main_ctrl', '');
     if (!empty($ctrl_param)) {
         $type_item = $ctrl_param;
     }
     $row = new stdClass();
     $elts = null;
     $hikashop_vote_con_req_list = $config->get('show_listing_comment', 0);
     $comment_to_show = $config->get('number_comment_product');
     $useful_rating = $config->get('useful_rating', 0);
     $useful_style = $config->get('vote_useful_style');
     $vote_comment_sort = $config->get('vote_comment_sort');
     $access_useful = $config->get('register_note_comment', 0);
     $show_comment_date = $config->get('show_comment_date', 0);
     $vote_comment_sort_frontend = $config->get('vote_comment_sort_frontend', 0);
     $hikashop_vote_user_id = hikashop_loadUser();
     if (!empty($this->params)) {
         JRequest::setVar('productlayout', $this->params->get('productlayout', 'show_default'));
     } else {
         JRequest::setVar('productlayout', 'show_default');
     }
     $hide = 1;
     //already voted !!
     if ($access_useful == 1 && !empty($hikashop_vote_user_id) || $access_useful == 0) {
         $hide = 0;
     }
     if ($config->get('enable_status_vote', 0) == 'comment' || $config->get('enable_status_vote', 0) == 'two' || $config->get('enable_status_vote', 0) == 'both') {
         $comment_enabled = 1;
     } else {
         $comment_enabled = 0;
     }
     if ($comment_enabled == 1) {
         if (!empty($this->params)) {
             $hikashop_vote_ref_id = $this->params->get('vote_ref_id');
             if (empty($hikashop_vote_ref_id)) {
                 $hikashop_vote_ref_id = $this->params->get('product_id');
             }
         } else {
             $hikashop_vote_ref_id = hikashop_getCID();
         }
         $i = 1;
         $app = JFactory::getApplication();
         $pageInfo = new stdClass();
         $pageInfo->filter = new stdClass();
         $pageInfo->filter->order = new stdClass();
         $pageInfo->limit = new stdClass();
         $pageInfo->elements = new stdClass();
         $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int');
         $app->setUserState($this->paramBase . '.list_limit', $comment_to_show);
         $oldValue = $app->getUserState($this->paramBase . '.list_limit');
         if (empty($oldValue)) {
             $oldValue = $app->getCfg('list_limit');
         }
         $pageInfo->limit->value = $comment_to_show;
         $app->setUserState($this->paramBase . '.list_limit', $comment_to_show);
         if ($oldValue != $pageInfo->limit->value) {
             $pageInfo->limit->start = 0;
             $app->setUserState($this->paramBase . '.limitstart', 0);
         }
         if ($hikashop_vote_con_req_list == 1 && $hikashop_vote_user_id != "" || $hikashop_vote_con_req_list == 0) {
             // if log needed and user logged in or log not needed
             $where = ' WHERE vote_published = 1 AND vote_type = ' . $db->quote($type_item) . ' AND vote_ref_id = ' . (int) $hikashop_vote_ref_id . ' AND vote_comment != \'\'';
             $order = ' ORDER BY `vote_useful` DESC, `vote_date` ASC';
             if ($vote_comment_sort == "date") {
                 $order = ' ORDER BY `vote_date` ASC';
             } elseif ($vote_comment_sort == "date_desc") {
                 $order = ' ORDER BY `vote_date` DESC';
             }
             $sort_comments = JRequest::getString('sort_comment', '');
             if ($sort_comments == "date") {
                 $order = ' ORDER BY `vote_date` ASC';
             } else {
                 if ($sort_comments == "date_desc") {
                     $order = ' ORDER BY `vote_date` DESC';
                 } else {
                     if ($sort_comments == "helpful") {
                         $order = ' ORDER BY `vote_useful` DESC, `vote_date` ASC';
                     }
                 }
             }
             $query = 'FROM `#__hikashop_vote` AS hika_vote LEFT JOIN `#__hikashop_user` AS hika_user ON hika_vote.vote_user_id=hika_user.user_id LEFT JOIN `#__users`AS users ON hika_user.user_cms_id=users.id ' . $where . '';
             $db->setQuery('SELECT COUNT(*) ' . $query);
             $total = $db->loadResult();
             if ($total < $pageInfo->limit->start) {
                 $pageInfo->limit->start = 0;
             }
             $limit = ' LIMIT ' . (int) $pageInfo->limit->start . ',' . (int) $pageInfo->limit->value . '';
             $db->setQuery('SELECT * ' . $query . $order . $limit);
             $scores = $db->loadObjectList();
             $elts = array();
             foreach ($scores as $hikashop_vote) {
                 $elts[$i] = clone $hikashop_vote;
                 $elts[$i]->total_vote_useful = 0;
                 //know the total of useful vote for this post
                 $query = 'SELECT count(vote_user_id) FROM ' . hikashop_table('vote_user') . ' WHERE vote_user_id = ' . (int) $elts[$i]->vote_id . '';
                 $db->setQuery($query);
                 $elts[$i]->total_vote_useful = $db->loadResult();
                 $elts[$i]->already_vote = 0;
                 //know if the user already vote for this post
                 if (empty($hikashop_vote_user_id)) {
                     $hikashop_vote_user_id = hikashop_getIP();
                 }
                 $query = 'SELECT vote_user_useful FROM ' . hikashop_table('vote_user') . ' WHERE vote_user_id = ' . (int) $elts[$i]->vote_id . ' AND vote_user_user_id = ' . $db->quote($hikashop_vote_user_id) . '';
                 $db->setQuery($query);
                 $elts[$i]->already_vote = $db->loadResult();
                 if (!empty($hikashop_vote->vote_comment) && $type_item) {
                     $purchased = '';
                     $query = 'SELECT order_id FROM ' . hikashop_table('order') . ' WHERE order_user_id = ' . $db->quote($hikashop_vote->vote_user_id) . '';
                     $db->setQuery($query);
                     if (!HIKASHOP_J25) {
                         $order_ids = $db->loadResultArray();
                     } else {
                         $order_ids = $db->loadColumn();
                     }
                     if (!empty($order_ids)) {
                         $query = 'SELECT product_id FROM ' . hikashop_table('product') . ' WHERE product_parent_id = ' . (int) $hikashop_vote_ref_id . '';
                         $db->setQuery($query);
                         if (!HIKASHOP_J25) {
                             $product_ids = $db->loadResultArray();
                         } else {
                             $product_ids = $db->loadColumn();
                         }
                         if (empty($product_ids)) {
                             $product_ids = array(0 => 0);
                             //if the article has no variants
                         }
                         $query = 'SELECT order_product_id FROM ' . hikashop_table('order_product') . ' WHERE order_id IN (' . implode(',', $order_ids) . ') AND product_id = ' . (int) $hikashop_vote_ref_id . ' OR product_id IN (' . implode(',', $product_ids) . ')';
                         $db->setQuery($query);
                         $result = $db->loadResult();
                         if (!empty($result)) {
                             $purchased = 1;
                         }
                     }
                     $elts[$i]->purchased = $purchased;
                 }
                 if ($elts[$i]->vote_useful > 10) {
                     $row->top_ranked = $elts[$i]->vote_id;
                 }
                 $i++;
             }
             $pageInfo->elements->total = $total;
             jimport('joomla.html.pagination');
             $pagination = hikashop_get('helper.pagination', $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value);
             $pagination->hikaSuffix = '';
             $this->assignRef('pagination', $pagination);
             $this->assignRef('pageInfo', $pageInfo);
         }
         $row->comment_to_show = $i;
     }
     $row->hikashop_vote_con_req_list = $hikashop_vote_con_req_list;
     $row->useful_rating = $useful_rating;
     $row->comment_enabled = $comment_enabled;
     $row->show_comment_date = $show_comment_date;
     $row->vote_comment_sort_frontend = $vote_comment_sort_frontend;
     $row->vote_star_number = $config->get('vote_star_number');
     $row->hide = $hide;
     $row->useful_style = $useful_style;
     $this->assignRef('rows', $row);
     $this->assignRef('elts', $elts);
 }
示例#12
0
文件: vote.php 项目: q0821/esportshop
 function saveFrontend(&$element)
 {
     $db = JFactory::getDBO();
     $config = hikashop_config();
     $user_ip = hikashop_getIP();
     $date = time();
     if (empty($element->user_id) || (int) $element->user_id == 0) {
         $element->user_id = $user_ip;
     }
     if (empty($element->vote_type)) {
         $element->vote_type = 'product';
     }
     JPluginHelper::importPlugin('hikashop');
     $dispatcher = JDispatcher::getInstance();
     $do = true;
     $currentElement = new stdClass();
     $dispatcher->trigger('onBeforeVoteCreate', array(&$element, &$do, &$currentElement));
     if (!$do) {
         return false;
     }
     $vElement = new stdClass();
     $vElement->vote_ref_id = (int) $element->vote_ref_id;
     $vElement->vote_type = strip_tags($element->vote_type);
     $vElement->vote_user_id = strip_tags($element->user_id);
     $vElement->vote_pseudo = strip_tags(@$element->pseudo_comment);
     $vElement->vote_ip = strip_tags($user_ip);
     $vElement->vote_email = strip_tags(@$element->email_comment);
     $vElement->vote_date = $date;
     $comment_by_person_by_product = $config->get('comment_by_person_by_product');
     $send_email = $config->get('email_each_comment');
     $vote_if_bought = $config->get('access_vote', 0) == 'buyed';
     if ($vote_if_bought == 1 && $vElement->vote_type == 'product') {
         $purchased = $this->hasBought($vElement->vote_ref_id, $element->user_id);
     }
     if ($element->hikashop_vote_type == 'useful') {
         $useful = JRequest::getVar('value', 0, 'default', 'int');
         $vote_id = JRequest::getVar('hikashop_vote_id', 0, 'default', 'int');
         $element->user_id = JRequest::getVar('hikashop_vote_user_id', 0, 'default', 'int');
         if (empty($element->user_id)) {
             $element->user_id = $user_ip;
         }
         $already_vote = 0;
         $useful_old = 0;
         $query = 'SELECT vote_user_useful FROM ' . hikashop_table('vote_user') . ' WHERE vote_user_id = ' . (int) $vote_id . ' AND vote_user_user_id = ' . $db->quote($element->user_id) . '';
         $db->setQuery($query);
         $already_vote = $db->loadResult();
         if ($already_vote > 0) {
             echo '2';
             exit;
         }
         $voteClass = hikashop_get('class.vote');
         $results = $voteClass->get((int) $vote_id);
         $useful_old = $results->vote_useful;
         if ($useful == 1) {
             $useful_new = $useful_old + 1;
         } else {
             $useful_new = $useful_old - 1;
         }
         $vElement->vote_id = (int) $vote_id;
         $vElement->vote_useful = strip_tags($useful_new);
         $useful = new stdClass();
         $useful->vote_id = (int) $vote_id;
         $useful->vote_useful = (int) $useful_new;
         $updated = parent::save($useful);
         if ($updated) {
             $dispatcher->trigger('onAfterVoteUpdate', array(&$element, $useful));
             $query = 'INSERT INTO ' . hikashop_table('vote_user') . ' (vote_user_id,vote_user_user_id,vote_user_useful) VALUES (' . (int) $vote_id . ',' . $db->quote($element->user_id) . ',1)';
             $db->setQuery($query);
             $db->query();
             if ($db->getAffectedRows() > 0) {
                 echo '1';
             }
         }
         exit;
     }
     if ($vote_if_bought && !$purchased) {
         echo '3';
         exit;
     }
     if ($vElement->vote_type == 'product') {
         $typeClass = hikashop_get('class.product');
         $results = $typeClass->get($vElement->vote_ref_id);
         $hikashop_vote_average_score = $results->product_average_score;
         $hikashop_vote_total_score = $results->product_total_vote;
     } else {
         if (!isset($currentElement->average_score) || !isset($currentElement->total_vote)) {
             echo '4';
             exit;
         }
         $hikashop_vote_average_score = $currentElement->average_score;
         $hikashop_vote_total_score = $currentElement->total_vote;
     }
     $hikashop_vote_total_score_new = $hikashop_vote_total_score + 1;
     $hikashop_vote_average_score_new = ($hikashop_vote_average_score * $hikashop_vote_total_score + $element->vote) / $hikashop_vote_total_score_new;
     $vote_id = '';
     $vote_old = '';
     $filters = array('vote_type = ' . $db->quote($vElement->vote_type), 'vote_ref_id = ' . (int) $vElement->vote_ref_id, 'vote_rating != 0');
     if (empty($element->user_id) || $element->user_id == $user_ip) {
         $filters[] = 'vote_ip = ' . $db->quote($user_ip);
         $filters[] = 'vote_user_id = \'\'';
     } else {
         $filters[] = 'vote_user_id = ' . $db->quote($element->user_id);
     }
     $query = 'SELECT * FROM ' . hikashop_table('vote') . ' WHERE ' . implode(' AND ', $filters);
     $db->setQuery($query);
     $result = $db->loadObject();
     if (!empty($result)) {
         $vote_id = $result->vote_id;
         $vote_old = $result->vote_rating;
         $published = $result->vote_published;
     }
     $nb_comment = $this->commentPassed($vElement->vote_type, $vElement->vote_ref_id, $element->user_id);
     $vote_mode = $config->get('enable_status_vote', 0);
     if ($element->hikashop_vote_type == 'vote') {
         $vElement->vote_rating = strip_tags($element->vote);
         $vElement->vote_comment = '';
         if (!empty($vote_id)) {
             $vElement->vote_id = $vote_id;
             if (!empty($hikashop_vote_total_score)) {
                 $hikashop_vote_average_score_new = ($hikashop_vote_average_score * $hikashop_vote_total_score - $vote_old + $element->vote) / $hikashop_vote_total_score;
             }
             $updated = parent::save($vElement);
             if ($updated && $published == 1) {
                 if ($vElement->vote_type == 'product') {
                     $type = new stdClass();
                     $type->product_id = (int) $vElement->vote_ref_id;
                     $type->product_average_score = $hikashop_vote_average_score_new;
                     $type->product_total_vote = (int) $hikashop_vote_total_score;
                     $typeClass->save($type, true);
                 }
                 $element->average_score = $hikashop_vote_average_score_new;
                 $element->total_vote = (int) $hikashop_vote_total_score;
                 $dispatcher->trigger('onAfterVoteUpdate', array(&$element));
             }
             echo '1';
         } else {
             $inserted = parent::save($vElement);
             if ($inserted) {
                 if ($vElement->vote_type == 'product') {
                     $type = new stdClass();
                     $type->product_id = (int) $vElement->vote_ref_id;
                     $type->product_average_score = $hikashop_vote_average_score_new;
                     $type->product_total_vote = (int) $hikashop_vote_total_score_new;
                     $typeClass->save($type, true);
                 }
                 $element->average_score = $hikashop_vote_average_score_new;
                 $element->total_vote = (int) $hikashop_vote_total_score_new;
                 $dispatcher->trigger('onAfterVoteUpdate', array(&$element));
             }
             echo '2';
         }
         exit;
     }
     jimport('joomla.filter.filterinput');
     $safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1);
     $config = hikashop_config();
     $vElement->vote_published = $config->get('published_comment', 0);
     if ($element->hikashop_vote_type == 'both') {
         $vElement->vote_rating = strip_tags($element->vote);
         $vElement->vote_comment = $safeHtmlFilter->clean($element->comment, 'string');
         if ($nb_comment < $comment_by_person_by_product) {
             $inserted = parent::save($vElement);
             if ($inserted) {
                 if ($vElement->vote_type == 'product' && $vElement->vote_published) {
                     $type = new stdClass();
                     $type->product_id = (int) $vElement->vote_ref_id;
                     $type->product_average_score = $hikashop_vote_average_score_new;
                     $type->product_total_vote = (int) $hikashop_vote_total_score_new;
                     $typeClass->save($type, true);
                 }
                 $element->average_score = $hikashop_vote_average_score_new;
                 $element->total_vote = (int) $hikashop_vote_total_score;
                 $dispatcher->trigger('onAfterVoteUpdate', array(&$element));
                 if (!empty($send_email)) {
                     $vote_id = $db->insertid();
                     $this->sendNotifComment($vote_id, strip_tags($element->comment), (int) $vElement->vote_ref_id, (int) $element->user_id, strip_tags($element->pseudo_comment), strip_tags($element->email_comment), $vElement->vote_type);
                 }
                 echo '1';
             } else {
                 echo '0';
             }
         } else {
             echo '2';
         }
         exit;
     }
     if ($element->hikashop_vote_type == 'comment') {
         $vElement->vote_rating = '0';
         $vElement->vote_comment = $safeHtmlFilter->clean($element->comment, 'string');
         if ($nb_comment < $comment_by_person_by_product) {
             $inserted = parent::save($vElement);
             $vote_id = 0;
             if ($inserted) {
                 $dispatcher->trigger('onAfterVoteUpdate', array(&$element));
                 if ($send_email != '') {
                     $vote_id = $db->insertid();
                     $this->sendNotifComment($vote_id, strip_tags($element->comment), (int) $vElement->vote_ref_id, (int) $element->user_id, strip_tags($element->pseudo_comment), strip_tags($element->email_comment), $vElement->vote_type);
                 }
                 echo '1';
             } else {
                 echo '0';
             }
         } else {
             echo '2';
         }
     }
     exit;
 }
示例#13
0
 function _checkLogin()
 {
     if (count($this->controllers) == 1) {
         $user = JFactory::getUser();
         $app = JFactory::getApplication();
         $user_id = $app->getUserState(HIKASHOP_COMPONENT . '.user_id');
         if ($user->guest && empty($user_id)) {
             $found = $this->_getStep('login');
             if ($found !== false) {
                 JRequest::setVar('step', $found);
                 JRequest::setVar('previous', 0);
                 unset($_REQUEST['previous']);
                 $this->step();
                 return false;
             } else {
                 $userData = new stdClass();
                 $userData->user_created_ip = hikashop_getIP();
                 $class = hikashop_get('class.user');
                 $userData->user_id = $class->save($userData);
                 $app->setUserState(HIKASHOP_COMPONENT . '.user_id', $userData->user_id);
             }
         }
     }
     return true;
 }
示例#14
0
文件: normal.php 项目: rodhoff/MNW
		</td>
	</tr>
	<tr>
		<td class="key">
			<label for="data[vote][vote_ip]">
				<?php 
echo JText::_('HIKA_IP');
?>
			</label>
		</td>
		<td>
			<input type="text" size="100" name="data[vote][vote_ip]" value="<?php 
if ($newItem == true) {
    echo "\"";
} elseif (!isset($row->vote_ip)) {
    echo hikashop_getIP() . "\"";
} else {
    echo @$row->vote_ip . "\" disabled=\"disabled\"";
}
?>
" />
		</td>
	</tr>
	<tr>
		<td class="key">
			<label for="data[vote][vote_email]">
				<?php 
echo JText::_('HIKA_EMAIL');
?>
			</label>
		</td>
 /**
  * To make order  when order is updated
  */
 function onAfterOrderUpdate(&$order, &$send_email)
 {
     $order_type = isset($order->order_type) ? $order->order_type : $order->old->order_type;
     if ($order_type != 'sale' || empty($order->order_status)) {
         return;
     }
     // To check the type of the order. if EMC params is empty, no method envoimoinscher has been used
     if (!isset($order->order_shipping_params->EMC_params)) {
         return;
     }
     if (!$this->init()) {
         return false;
     }
     $config = hikashop_config();
     $order_confirmed_status = $config->get('order_confirmed_status', 'confirmed');
     $invoice_order_statuses = explode(',', $config->get('invoice_order_statuses', 'confirmed,shipped'));
     if (empty($invoice_order_statuses)) {
         $invoice_order_statuses = array('confirmed', 'shipped');
     }
     //if order status is "created" we do anything
     if ($order->order_status != $order_confirmed_status && !in_array($order->order_status, $invoice_order_statuses)) {
         return;
     }
     $order_shipping_params = isset($order->order_shipping_params) ? $order->order_shipping_params : $order->old->order_shipping_params;
     if (is_string($order_shipping_params)) {
         $order_shipping_params = unserialize($order_shipping_params);
     }
     /*
      * test if makeOrder has already been done once
      * if there was an error with one, we can't redo
      * we can improve this so we can redo those who had an error with the makeOrder
      */
     $ref_exist = false;
     foreach ($order_shipping_params->EMC_params as $value) {
         if (!empty($value['reference'])) {
             $ref_exist = true;
         }
     }
     if ($ref_exist == true) {
         return;
     }
     $db = JFactory::getDBO();
     $orderClass = hikashop_get('class.order');
     $fullOrder = $orderClass->loadFullOrder($order->order_id, true, false);
     // we group products by warehouse and shipping method
     //
     $tab_products = array();
     foreach ($fullOrder->order_shipping_params->EMC_params as $key => $value) {
         $data = array('products' => array());
         foreach ($fullOrder->products as $k => $product) {
             if ($product->order_product_shipping_method != 'envoimoinscher') {
                 continue;
             }
             if ($key == $product->order_product_shipping_id) {
                 $ids_products = explode('@', $product->order_product_shipping_id);
                 $warehouse_id = $ids_products[1];
                 $data['products'][] = $product;
             }
         }
         if (!empty($data['products'])) {
             $data['warehouse_id'] = $warehouse_id;
             $data['shipping_id'] = $ids_products[0];
             $tab_products[] = $data;
         }
     }
     // Get the destination country
     //
     $czone_code_to = @$fullOrder->shipping_address->address_country;
     $query = 'SELECT zone_id, zone_code_2 FROM ' . hikashop_table('zone') . ' WHERE zone_name_english = ' . $db->Quote($czone_code_to);
     $db->setQuery($query);
     $czone = $db->loadObject();
     $country_to = $czone->zone_code_2;
     if ($country_to == 'FX') {
         $country_to = 'FR';
     }
     $user_address_title = $fullOrder->shipping_address->address_title;
     $key = 'HIKA_TITLE_' . strtoupper($user_address_title);
     if ($key != JText::_($key)) {
         $user_address_title = JText::_($key);
     }
     $email = @$fullOrder->customer->user_email;
     $phone = @$fullOrder->shipping_address->address_telephone;
     // for each group we collect all informations to send the request makeOrder
     //
     foreach ($tab_products as $key => $value) {
         $shipping_ids = explode('-', $value['shipping_id']);
         $this->pluginParams($shipping_ids[0]);
         // check if option make order is disabled
         if ($this->plugin_params->make_order == 0) {
             continue;
         }
         // receiver informations
         if ($this->plugin_params->destination_type == 'res' || $this->plugin_params->destination_type == 'auto' && empty($fullOrder->shipping_address->address_company)) {
             $user_type = 'particulier';
         } else {
             $user_type = 'entreprise';
         }
         if (empty($email) || empty($phone)) {
             return;
         }
         $to = array('pays' => $country_to, 'code_postal' => $fullOrder->shipping_address->address_post_code, 'type' => $user_type, 'ville' => $fullOrder->shipping_address->address_city, 'adresse' => $fullOrder->shipping_address->address_street, 'civilite' => $user_address_title, 'prenom' => $fullOrder->shipping_address->address_firstname, 'nom' => $fullOrder->shipping_address->address_lastname, 'email' => $email, 'tel' => $phone);
         // sender informations
         $admin_address_title = $this->plugin_params->sender_civility;
         $key = 'HIKA_TITLE_' . strtoupper($admin_address_title);
         if ($key != JText::_($key)) {
             $admin_address_title = JText::_($key);
         }
         $czone_code_from = @$this->plugin_params->sender_country;
         $query = 'SELECT zone_id, zone_code_2 FROM ' . hikashop_table('zone') . ' WHERE zone_namekey = ' . $db->Quote($czone_code_from);
         $db->setQuery($query);
         $czone = $db->loadObject();
         $country_from = $czone->zone_code_2;
         if ($country_from == 'FX') {
             $country_from = 'FR';
         }
         $from = array('pays' => $country_from, 'code_postal' => $this->plugin_params->sender_postcode, 'type' => $this->plugin_params->type, 'ville' => $this->plugin_params->sender_city, 'adresse' => $this->plugin_params->sender_address, 'civilite' => $admin_address_title, 'prenom' => $this->plugin_params->sender_firstname, 'nom' => $this->plugin_params->sender_lastname, 'email' => $this->plugin_params->sender_email, 'tel' => $this->plugin_params->sender_phone);
         if ($this->plugin_params->type == 'entreprise') {
             $from['societe'] = $this->plugin_params->sender_company;
         }
         $code = (int) $this->plugin_params->product_category;
         $shipping = explode(' / ', $shipping_ids[1]);
         $service = $shipping[1];
         $shipping = $value['shipping_id'] . '@' . $value['warehouse_id'];
         // We get the drop off point, pick up and code for the shipping method
         foreach ($fullOrder->order_shipping_params->EMC_params as $k => $v) {
             if ($k == $shipping) {
                 $dropoff = explode('<br/>', $v['drop_off']);
                 $pickup = explode('<br/>', $v['pick_up']);
                 $ope = $v['code'];
             }
         }
         $sending_type = strtolower($this->plugin_params->sending_type);
         $collection = $dropoff[0];
         $delivery = $pickup[0];
         // >rray that contains informations about sending
         $quotInfo = array('collecte' => date('Y-m-d'), 'delai' => 'aucun', 'code_contenu' => $code, 'type_emballage.emballage' => 1, 'operateur' => $ope, 'raison' => 'sale', 'service' => $service, 'collection_type' => $collection, 'delivery_type' => $delivery, 'depot.pointrelais' => '', 'retrait.pointrelais' => '', $sending_type . '.description' => '');
         // if there is drop off or pick up point
         if ($collection == 'POST_OFFICE' || $collection == 'DROPOFF_POINT') {
             $quotInfo['depot.pointrelais'] = $dropoff[2];
         }
         if ($delivery == 'PICKUP_POINT') {
             $quotInfo['retrait.pointrelais'] = $pickup[2];
         }
         // the availability for the collection of the package by the carrier, compulsory for some offers
         if (isset($this->plugin_params->start_availability) && !empty($this->plugin_params->start_availability)) {
             $quotInfo['disponibilite.HDE'] = $this->plugin_params->start_availability;
         }
         if (isset($this->plugin_params->end_availability) && !empty($this->plugin_params->end_availability)) {
             $quotInfo['disponibilite.HLE'] = $this->plugin_params->end_availability;
         }
         foreach ($value['products'] as $product) {
             $quotInfo[$sending_type . '.description'] .= '  ' . $product->order_product_name;
         }
         $productClass = hikashop_get('class.product');
         $newOrder = new stdClass();
         // To create a new array order to use the function getData before makeOrder
         // It must be structured in the same way. We set in the array just the necessary data
         //
         foreach ($value['products'] as $p) {
             $product = $productClass->get($p->product_id);
             if ($product->product_parent_id != 0) {
                 // Processing variant product
                 //
                 $parent = $productClass->get($product->product_parent_id);
                 $newProduct = $parent;
                 $newProduct->variants = array(0 => $product);
                 if ($product->product_width == 0 && $product->product_length == 0) {
                     $product->product_width = $parent->product_width;
                     $product->product_length = $parent->product_length;
                     $product->product_height = $parent->product_height;
                 }
                 $product->cart_product_quantity = (int) $p->order_product_quantity;
                 $product->product_weight_orig = $parent->product_weight;
                 $product->product_weight_unit_orig = $parent->product_weight_unit;
                 $product->product_dimension_unit_orig = $parent->product_dimension_unit;
                 //
                 $price = new stdClass();
                 $price->unit_price = new stdClass();
                 $price->unit_price->price_value_with_tax = $p->order_product_price + $p->order_product_tax;
                 //
                 $product->prices = array(0 => $price);
                 //
                 $newOrder->products[] = $newProduct;
             } else {
                 // Processing main product
                 //
                 $product->cart_product_quantity = (int) $p->order_product_quantity;
                 $product->product_weight_orig = $product->product_weight;
                 $product->product_weight_unit_orig = $product->product_weight_unit;
                 $product->product_dimension_unit_orig = $product->product_dimension_unit;
                 //
                 $price = new stdClass();
                 $price->unit_price = new stdClass();
                 $price->unit_price->price_value_with_tax = $p->order_product_price + $p->order_product_tax;
                 //
                 $product->prices = array(0 => $price);
                 //
                 $newOrder->products[] = $product;
             }
         }
         /*
          * makeOrder = true in order not to get receiver and sender infos because we already did it
          * and for the makeOrder we have to give more informations
          */
         $data = $this->getData(null, $this, $newOrder, $sending_type, true);
         $total_price = (int) $data[0]["price"];
         unset($data[0]);
         $quotInfo[$sending_type . '.valeur'] = $total_price;
         $cotCl = new Env_Quotation(array('user' => $this->plugin_params->emc_login, 'pass' => $this->plugin_params->emc_password, 'key' => $this->plugin_params->api_key));
         $cotCl->setEnv($this->plugin_params->environment);
         $config = hikashop_config();
         $contentCl->setPlatformParams('hikashop', $config->get('version'), $config->get('version'));
         $cotCl->setPerson('expediteur', $from);
         $cotCl->setPerson('destinataire', $to);
         $cotCl->setType($sending_type, $data);
         /*
          * for shipments to the international we have to send more informations for each product
          * we call the function setProforma of the library for this
          */
         if ($country_to != $country_from) {
             $infos_products = array();
             $i = 1;
             foreach ($newOrder->products as $product) {
                 if (isset($product->variants)) {
                     $nb = $product->variants[0]->cart_product_quantity;
                     $price = $product->variants[0]->prices[0]->unit_price->price_value_with_tax;
                     $weight = $product->variants[0]->product_weight_orig;
                 } else {
                     $nb = $product->cart_product_quantity;
                     $price = $product->prices[0]->unit_price->price_value_with_tax;
                     $weight = $product->product_weight_orig;
                 }
                 $infos_products[$i++] = array('description_en' => $product->product_name, 'description_fr' => $product->product_name, 'nombr' => $nb, 'valeur' => $price, 'origine' => $country_from, 'poids' => $weight);
             }
             $cotCl->setProforma($infos_products);
         }
         // send request to make order !!
         $orderPassed = $cotCl->makeOrder($quotInfo, true);
         if (!$cotCl->curlError && !$cotCl->respError) {
             if ($orderPassed) {
                 // we add reference to order_shipping_params
                 $fullOrder->order_shipping_params->EMC_params[$shipping]['reference'] = $cotCl->order['ref'];
                 $update_order = new stdClass();
                 $update_order->order_id = $fullOrder->order_id;
                 $update_order->order_shipping_params = $fullOrder->order_shipping_params;
                 $orderClass->save($update_order);
             }
             /*else {
             			echo "The shipment was not properly executed. An error has occurred .";
             		}*/
         } elseif ($cotCl->respError) {
             // The request is invalid, we add message to order history
             $update_history = new stdClass();
             $update_history->history_order_id = $fullOrder->order_id;
             $update_history->history_created = time();
             $update_history->history_notified = 0;
             $update_history->history_ip = hikashop_getIP();
             $update_history->history_reason = 'EnvoiMoinsCher Error';
             $update_history->history_data = '';
             foreach ($cotCl->respErrorsList as $m => $message) {
                 $update_history->history_data .= $message['message'] . '<br/>';
             }
             $historyClass = hikashop_get('class.history');
             $historyClass->save($update_history);
         } else {
             // An error while sending the request, add message to order history
             //
             $update_history = new stdClass();
             $update_history->history_order_id = $fullOrder->order_id;
             $update_history->history_created = time();
             $update_history->history_notified = 0;
             $update_history->history_ip = hikashop_getIP();
             $update_history->history_reason = 'EnvoiMoinsCher Error';
             $update_history->history_data = $cotCl->curlErrorText;
             $historyClass = hikashop_get('class.history');
             $historyClass->save($update_history);
         }
     }
 }
示例#16
0
文件: paypal.php 项目: rodhoff/MNW
 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;
 }
示例#17
0
 function save(&$order)
 {
     $new = false;
     $config =& hikashop_config();
     if (empty($order->order_id)) {
         if (!is_object($order)) {
             $order = new stdClass();
         }
         $order->order_created = time();
         if (empty($order->order_type)) {
             $order->order_type = 'sale';
         }
         $order->order_ip = hikashop_getIP();
         $order->old = new stdClass();
         if (empty($order->order_status)) {
             $order->order_status = $config->get('order_created_status', 'pending');
         }
         if (empty($order->order_currency_id)) {
             $order->order_currency_id = hikashop_getCurrency();
         }
         if (defined('MULTISITES_ID')) {
             $order->order_site_id = MULTISITES_ID;
         }
         $new = true;
     } else {
         if (empty($order->old)) {
             $order->old = $this->get($order->order_id);
         }
     }
     $order->order_modified = time();
     JPluginHelper::importPlugin('hikashop');
     JPluginHelper::importPlugin('hikashoppayment');
     JPluginHelper::importPlugin('hikashopshipping');
     $dispatcher = JDispatcher::getInstance();
     $order_type = '';
     if (!empty($order->old->order_type)) {
         $order_type = $order->old->order_type;
     }
     if (!empty($order->order_type)) {
         $order_type = $order->order_type;
     }
     $recalculate = false;
     if (!empty($order->product)) {
         $do = true;
         $dispatcher->trigger('onBeforeOrderProductsUpdate', array(&$order, &$do));
         if (!$do) {
             return false;
         }
         $productClass = hikashop_get('class.order_product');
         if (is_array($order->product)) {
             foreach ($order->product as $product) {
                 $productClass->update($product);
             }
         } else {
             $productClass->update($order->product);
         }
         $recalculate = true;
     }
     if (!$new && (isset($order->order_shipping_price) || isset($order->order_payment_price) || isset($order->order_discount_price))) {
         if (isset($order->order_shipping_tax_namekey) || isset($order->order_discount_tax_namekey) || isset($order->order_payment_tax_namekey)) {
             if (!empty($order->old->order_tax_info)) {
                 $order->order_tax_info = $order->old->order_tax_info;
                 foreach ($order->order_tax_info as $k => $tax) {
                     if (isset($order->order_shipping_tax_namekey) && $tax->tax_namekey == $order->order_shipping_tax_namekey) {
                         $order->order_tax_info[$k]->tax_amount_for_shipping = @$order->order_shipping_tax;
                         unset($order->order_shipping_tax_namekey);
                     } elseif (isset($order->order_tax_info[$k]->tax_amount_for_shipping)) {
                         unset($order->order_tax_info[$k]->tax_amount_for_shipping);
                     }
                     if (isset($order->order_payment_tax_namekey) && $tax->tax_namekey == $order->order_payment_tax_namekey) {
                         $order->order_tax_info[$k]->tax_amount_for_payment = @$order->order_payment_tax;
                         unset($order->order_payment_tax_namekey);
                     } elseif (isset($order->order_tax_info[$k]->tax_amount_for_payment)) {
                         unset($order->order_tax_info[$k]->tax_amount_for_payment);
                     }
                     if (isset($order->order_discount_tax_namekey) && $tax->tax_namekey == $order->order_discount_tax_namekey) {
                         $order->order_tax_info[$k]->tax_amount_for_coupon = @$order->order_discount_tax;
                         unset($order->order_discount_tax_namekey);
                     } elseif (isset($order->order_tax_info[$k]->tax_amount_for_coupon)) {
                         unset($order->order_tax_info[$k]->tax_amount_for_coupon);
                     }
                 }
             }
             if (isset($order->order_shipping_tax_namekey)) {
                 $order->order_tax_info[$order->order_shipping_tax_namekey] = new stdClass();
                 $order->order_tax_info[$order->order_shipping_tax_namekey]->tax_namekey = $order->order_shipping_tax_namekey;
                 $order->order_tax_info[$order->order_shipping_tax_namekey]->tax_amount_for_shipping = @$order->order_shipping_tax;
                 unset($order->order_shipping_tax_namekey);
             }
             if (isset($order->order_payment_tax_namekey)) {
                 $order->order_tax_info[$order->order_payment_tax_namekey] = new stdClass();
                 $order->order_tax_info[$order->order_payment_tax_namekey]->tax_namekey = $order->order_payment_tax_namekey;
                 $order->order_tax_info[$order->order_payment_tax_namekey]->tax_amount_for_payment = @$order->order_payment_tax;
                 unset($order->order_payment_tax_namekey);
             }
             if (isset($order->order_discount_tax_namekey)) {
                 $order->order_tax_info[$order->order_discount_tax_namekey] = new stdClass();
                 $order->order_tax_info[$order->order_discount_tax_namekey]->tax_namekey = $order->order_discount_tax_namekey;
                 $order->order_tax_info[$order->order_discount_tax_namekey]->tax_amount_for_coupon = @$order->order_discount_tax;
                 unset($order->order_discount_tax_namekey);
             }
         }
         $recalculate = true;
     }
     if ($recalculate) {
         $this->recalculateFullPrice($order);
     }
     $do = true;
     if ($new) {
         $dispatcher->trigger('onBeforeOrderCreate', array(&$order, &$do));
     } else {
         $dispatcher->trigger('onBeforeOrderUpdate', array(&$order, &$do));
     }
     if ($do) {
         if (isset($order->value)) {
             unset($order->value);
         }
         if (isset($order->order_current_lgid)) {
             unset($order->order_current_lgid);
         }
         if (isset($order->order_current_locale)) {
             unset($order->order_current_locale);
         }
         if (isset($order->mail_status)) {
             unset($order->mail_status);
         }
         if (isset($order->order_tax_info) && !is_string($order->order_tax_info)) {
             $order->order_tax_info = serialize($order->order_tax_info);
         }
         if (isset($order->order_currency_info) && !is_string($order->order_currency_info)) {
             $order->order_currency_info = serialize($order->order_currency_info);
         }
         if (isset($order->order_shipping_params) && !is_string($order->order_shipping_params)) {
             $order->order_shipping_params = serialize($order->order_shipping_params);
         }
         if (isset($order->order_payment_params) && !is_string($order->order_payment_params)) {
             $order->order_payment_params = serialize($order->order_payment_params);
         }
         if ($config->get('update_stock_after_confirm') && isset($order->order_status) && isset($order->old->order_status) && $order_type == 'sale') {
             $invoice_statuses = $config->get('invoice_order_statuses', 'confirmed,shipped');
             if (empty($invoice_statuses)) {
                 $invoice_statuses = 'confirmed,shipped';
             }
             $invoice_order_statuses = explode(',', $invoice_statuses);
             if ($order->old->order_status == 'created' && in_array($order->order_status, $invoice_order_statuses)) {
                 $this->loadProducts($order);
                 if (!empty($order->products)) {
                     $productClass = hikashop_get('class.order_product');
                     foreach ($order->products as $product) {
                         $product->change = 'minus';
                         $productClass->update($product);
                         unset($product->change);
                     }
                 }
             } elseif (in_array($order->old->order_status, $invoice_order_statuses) && $order->order_status == 'created') {
                 $this->loadProducts($order);
                 if (!empty($order->products)) {
                     $productClass = hikashop_get('class.order_product');
                     foreach ($order->products as $product) {
                         $product->change = 'plus';
                         $productClass->update($product);
                         unset($product->change);
                     }
                 }
             }
         }
         if (isset($order->order_status) && $order_type == 'sale') {
             $this->capturePayment($order, 0);
         }
         if (!empty($order->order_status) && empty($order->order_invoice_id) && empty($order->old->order_invoice_id) && $order_type == 'sale') {
             $valid_statuses = explode(',', $config->get('invoice_order_statuses', 'confirmed,shipped'));
             if (empty($valid_statuses)) {
                 $valid_statuses = array('confirmed', 'shipped');
             }
             $excludeFreeOrders = $config->get('invoice_exclude_free_orders', 0);
             if (isset($order->order_full_price)) {
                 $total = $order->order_full_price;
             } elseif (isset($order->old->order_full_price)) {
                 $total = $order->old->order_full_price;
             } else {
                 $total = 0;
             }
             //new order for example
             if (in_array($order->order_status, $valid_statuses) && ($total > 0 || !$excludeFreeOrders)) {
                 $query = 'SELECT MAX(a.order_invoice_id)+1 FROM ' . hikashop_table('order') . ' AS a WHERE a.order_type = \'sale\'';
                 $resetFrequency = $config->get('invoice_reset_frequency', '');
                 if (!empty($resetFrequency)) {
                     $y = (int) date('Y');
                     $m = 1;
                     $d = 1;
                     if ($resetFrequency == 'month') {
                         $m = (int) date('m');
                     }
                     if (strpos($resetFrequency, '/') !== false) {
                         list($d, $m) = explode('/', $resetFrequency, 2);
                         if ($d == '*') {
                             $d = (int) date('d');
                         } else {
                             $d = (int) $d;
                         }
                         if ($m == '*') {
                             $m = (int) date('m');
                         } else {
                             $m = (int) $m;
                         }
                         if ($d <= 0) {
                             $d = 1;
                         }
                         if ($m <= 0) {
                             $m = 1;
                         }
                     }
                     $query .= ' AND a.order_invoice_created >= ' . mktime(0, 0, 0, $m, $d, $y);
                 }
                 $this->database->setQuery($query);
                 $order->order_invoice_id = $this->database->loadResult();
                 if (empty($order->order_invoice_id)) {
                     $order->order_invoice_id = 1;
                 }
                 $order->order_invoice_number = hikashop_encode($order, 'invoice');
                 $order->order_invoice_created = time();
             }
         }
         if (empty($order->old)) {
             unset($order->old);
         }
         $order->order_id = parent::save($order);
         if (isset($order->order_tax_info) && is_string($order->order_tax_info)) {
             $order->order_tax_info = unserialize($order->order_tax_info);
         }
         if (isset($order->order_payment_params) && is_string($order->order_payment_params)) {
             $order->order_payment_params = unserialize($order->order_payment_params);
         }
         if (isset($order->order_shipping_params) && is_string($order->order_shipping_params)) {
             $order->order_shipping_params = unserialize($order->order_shipping_params);
         }
         if (!empty($order->order_id)) {
             $productClass = hikashop_get('class.order_product');
             if ($new && empty($order->order_number)) {
                 $order->order_number = hikashop_encode($order);
                 $updateOrder = new stdClass();
                 $updateOrder->order_id = $order->order_id;
                 $updateOrder->order_number = $order->order_number;
                 $config =& hikashop_config();
                 $valid_statuses = explode(',', $config->get('invoice_order_statuses', 'confirmed,shipped'));
                 if (empty($valid_statuses)) {
                     $valid_statuses = array('confirmed', 'shipped');
                 }
                 $created_status = $config->get('order_created_status', 'created');
                 if (in_array($created_status, $valid_statuses)) {
                     $order->order_invoice_id = $order->order_id;
                     $order->order_invoice_number = $order->order_number;
                     $order->order_invoice_created = time();
                     $updateOrder->order_invoice_id = $order->order_invoice_id;
                     $updateOrder->order_invoice_number = $order->order_invoice_number;
                 }
                 parent::save($updateOrder);
             }
             if (!empty($order->cart->products)) {
                 foreach ($order->cart->products as $k => $p) {
                     $order->cart->products[$k]->order_id = $order->order_id;
                 }
                 if ($config->get('update_stock_after_confirm') && $order->order_status == 'created') {
                     foreach ($order->cart->products as $k => $product) {
                         $order->cart->products[$k]->no_update_qty = true;
                     }
                 }
                 $productClass->save($order->cart->products);
                 if ($config->get('update_stock_after_confirm') && $order->order_status == 'created') {
                     foreach ($order->cart->products as $k => $product) {
                         unset($order->cart->products[$k]->no_update_qty);
                     }
                 }
                 if (!empty($order->order_discount_code) && $order_type == 'sale') {
                     $query = 'UPDATE ' . hikashop_table('discount') . ' SET discount_used_times=discount_used_times+1 WHERE discount_code=' . $this->database->Quote($order->order_discount_code) . ' AND discount_type=\'coupon\' LIMIT 1';
                     $this->database->setQuery($query);
                     $this->database->query();
                 }
                 if (!empty($order->cart->additional)) {
                     foreach ($order->cart->additional as $k => $p) {
                         $order->cart->additional[$k]->product_id = 0;
                         $order->cart->additional[$k]->order_product_quantity = 0;
                         if (!empty($p->name)) {
                             $order->cart->additional[$k]->order_product_name = $p->name;
                         }
                         $order->cart->additional[$k]->order_product_code = 'order additional';
                         if (!empty($p->value)) {
                             $order->cart->additional[$k]->order_product_options = $p->value;
                         }
                         if (!empty($p->price_value)) {
                             $order->cart->additional[$k]->order_product_price = $p->price_value;
                         }
                         $order->cart->additional[$k]->order_id = $order->order_id;
                     }
                     $productClass->save($order->cart->additional);
                 }
             } elseif (!empty($order->order_status) && !empty($order->old)) {
                 $update = $config->get('update_stock_after_confirm');
                 $config =& hikashop_config();
                 $cancelled_order_status = explode(',', $config->get('cancelled_order_status'));
                 $invoice_order_statuses = explode(',', $config->get('invoice_order_statuses', 'confirmed,shipped'));
                 if (empty($invoice_order_statuses)) {
                     $invoice_order_statuses = array('confirmed', 'shipped');
                 }
                 if (!empty($order->order_status) && in_array($order->order_status, $cancelled_order_status) && (empty($order->old->order_status) || !in_array($order->old->order_status, $cancelled_order_status))) {
                     if ($order_type == 'sale' && (in_array($order->order_status, $cancelled_order_status) && (in_array($order->old->order_status, $invoice_order_statuses) || !$update && $order->old->order_status == 'created'))) {
                         $productClass->cancelProductReservation($order->order_id);
                     }
                     if (!isset($order->order_discount_code)) {
                         $code = @$order->old->order_discount_code;
                     } else {
                         $code = $order->order_discount_code;
                     }
                     if (!empty($code) && $order_type == 'sale') {
                         $query = 'UPDATE ' . hikashop_table('discount') . ' SET discount_used_times=discount_used_times-1 WHERE discount_code=' . $this->database->Quote($code) . ' AND discount_type=\'coupon\' LIMIT 1';
                         $this->database->setQuery($query);
                         $this->database->query();
                     }
                 }
                 if (!empty($order->order_status) && !in_array($order->order_status, $cancelled_order_status) && !empty($order->old->order_status) && in_array($order->old->order_status, $cancelled_order_status)) {
                     if ($order_type == 'sale' && (in_array($order->old->order_status, $cancelled_order_status) && (in_array($order->order_status, $invoice_order_statuses) || !$update && $order->order_status == 'created'))) {
                         $productClass->resetProductReservation($order->order_id);
                     }
                     if (!isset($order->order_discount_code)) {
                         $code = @$order->old->order_discount_code;
                     } else {
                         $code = $order->order_discount_code;
                     }
                     if (!empty($code) && $order_type == 'sale') {
                         $query = 'UPDATE ' . hikashop_table('discount') . ' SET discount_used_times = discount_used_times + 1 WHERE discount_code=' . $this->database->Quote($code) . ' AND discount_type=\'coupon\' LIMIT 1';
                         $this->database->setQuery($query);
                         $this->database->query();
                     }
                 }
             }
             if ($new) {
                 $send_email = $this->sendEmailAfterOrderCreation;
                 $dispatcher->trigger('onAfterOrderCreate', array(&$order, &$send_email));
                 if ($send_email) {
                     $this->loadOrderNotification($order, 'order_creation_notification');
                     $mail = hikashop_get('class.mail');
                     if (!empty($order->mail->dst_email)) {
                         $mail->sendMail($order->mail);
                     }
                     $this->mail_success =& $mail->mail_success;
                     $config =& hikashop_config();
                     $emails = $config->get('order_creation_notification_email');
                     if (!empty($emails)) {
                         $mail = hikashop_get('class.mail');
                         if (!empty($order->customer)) {
                             $user_email = $order->customer->user_email;
                             $user_name = $order->customer->name;
                         } else {
                             $order->customer = new stdClass();
                         }
                         $order->customer->user_email = explode(',', $emails);
                         $order->customer->name = ' ';
                         $this->loadOrderNotification($order, 'order_admin_notification');
                         $order->mail->subject = trim($order->mail->subject);
                         if (empty($order->mail->subject)) {
                             $order->mail->subject = JText::sprintf('NEW_ORDER_SUBJECT', $order->order_number, HIKASHOP_LIVE);
                         }
                         if (!empty($user_email)) {
                             $mail->mailer->addReplyTo(array($user_email, $user_name));
                         }
                         if (!empty($order->mail->dst_email)) {
                             $mail->sendMail($order->mail);
                         }
                         if (!empty($user_email)) {
                             $order->customer->user_email = $user_email;
                             $order->customer->name = $user_name;
                         }
                     }
                 }
             } else {
                 $send_email = @$order->history->history_notified;
                 $dispatcher->trigger('onAfterOrderUpdate', array(&$order, &$send_email));
                 if ($send_email) {
                     if (empty($order->mail) && isset($order->order_status)) {
                         $this->loadOrderNotification($order, 'order_status_notification');
                     } else {
                         $order->mail->data =& $order;
                         $order->mail->mail_name = 'order_status_notification';
                     }
                     if (!empty($order->mail)) {
                         $mail = hikashop_get('class.mail');
                         if (!empty($order->mail->dst_email)) {
                             $mail->sendMail($order->mail);
                         }
                         $this->mail_success =& $mail->mail_success;
                     }
                 }
             }
         }
         return $order->order_id;
     }
     return false;
 }
示例#18
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;
    }
示例#19
0
文件: cron.php 项目: q0821/esportshop
 function cron()
 {
     $time = time();
     $config =& hikashop_config();
     $firstMessage = JText::sprintf('CRON_TRIGGERED', hikashop_getDate(time()));
     $this->messages[] = $firstMessage;
     if ($this->report) {
         hikashop_display($firstMessage, 'info');
     }
     if ($config->get('cron_next') > $time) {
         if ($config->get('cron_next') > $time + $config->get('cron_frequency')) {
             $newConfig = new stdClass();
             $newConfig->cron_next = $time + $config->get('cron_frequency');
             $config->save($newConfig);
         }
         $nottime = JText::sprintf('CRON_NEXT', hikashop_getDate($config->get('cron_next')));
         $this->messages[] = $nottime;
         if ($this->report) {
             hikashop_display($nottime, 'info');
         }
         $sendreport = $config->get('cron_sendreport');
         if ($sendreport == 1) {
             $mailer = hikashop_get('class.mail');
             $data = new stdClass();
             $data->report = implode('<br/>', $this->messages);
             $data->detailreport = '';
             $mail = $mailer->get('cron_report', $data);
             $mail->subject = JText::_($mail->subject);
             $receiverString = $config->get('cron_sendto');
             $receivers = explode(',', $receiverString);
             if (!empty($receivers)) {
                 foreach ($receivers as $oneReceiver) {
                     $mail->dst_email = $oneReceiver;
                     $mailer->sendMail($mail);
                 }
             }
         }
         return false;
     }
     $newConfig = new stdClass();
     $newConfig->cron_next = $config->get('cron_next') + $config->get('cron_frequency');
     if ($newConfig->cron_next <= $time || $newConfig->cron_next > $time + $config->get('cron_frequency')) {
         $newConfig->cron_next = $time + $config->get('cron_frequency');
     }
     $newConfig->cron_last = $time;
     $newConfig->cron_fromip = hikashop_getIP();
     $config->save($newConfig);
     JPluginHelper::importPlugin('hikashoppayment');
     JPluginHelper::importPlugin('hikashopshipping');
     JPluginHelper::importPlugin('hikashop');
     $dispatcher = JDispatcher::getInstance();
     $resultsTrigger = array();
     $dispatcher->trigger('onHikashopCronTrigger', array(&$resultsTrigger));
     if ($this->report) {
         foreach ($resultsTrigger as $message) {
             hikashop_display($message, 'info');
         }
     }
     $this->detailMessages = $resultsTrigger;
     return true;
 }
示例#20
0
文件: user.php 项目: rodhoff/MNW
 function register(&$checkout, $page = 'checkout', $redirect = true)
 {
     $config =& hikashop_config();
     $app = JFactory::getApplication();
     $user = clone JFactory::getUser();
     $authorize = JFactory::getACL();
     $simplified = $config->get('simplified_registration', 0);
     jimport('joomla.application.component.helper');
     $params = JComponentHelper::getParams('com_users');
     $display = $config->get('display_method', 0);
     if (!hikashop_level(1)) {
         $display = 0;
     }
     if ($display == 1) {
         $simplified = explode(',', $simplified);
         if ($page == 'checkout') {
             $formData = JRequest::getVar('data', array(), '', 'array');
             if (in_array(@$formData['register']['registration_method'], $simplified)) {
                 $simplified = $formData['register']['registration_method'];
             } else {
                 $simplified = array_shift($simplified);
             }
         } elseif ($page == 'user') {
             $simplified = array_shift($simplified);
         }
     }
     if ($simplified != 2) {
         if ($params->get('allowUserRegistration') == '0') {
             JError::raiseError(403, JText::_('Access Forbidden'));
             return false;
         }
         $newUsertype = $params->get('new_usertype');
         if (!$newUsertype) {
             if (!HIKASHOP_J16) {
                 $newUsertype = 'Registered';
             } else {
                 $newUsertype = 2;
             }
         }
         $userGroupRegistration = $config->get('user_group_registration', '');
         if (HIKASHOP_J16 && !empty($userGroupRegistration) && (int) $userGroupRegistration > 0) {
             $newUsertype = (int) $userGroupRegistration;
         }
     }
     $fieldClass = hikashop_get('class.field');
     $old = null;
     $this->registerData = $fieldClass->getInput('register', $old, !@$checkout->cart_update);
     $userData = $fieldClass->getInput('user', $old, !@$checkout->cart_update);
     if ($config->get('address_on_registration', 1)) {
         $addressData = $fieldClass->getInput('address', $old, !@$checkout->cart_update);
     } else {
         $addressData = new stdClass();
     }
     if ($this->registerData === false || $addressData === false || $userData === false) {
         return false;
     }
     if (empty($this->registerData->name)) {
         $this->registerData->name = @$addressData->address_firstname . (!empty($addressData->address_middle_name) ? ' ' . $addressData->address_middle_name : '') . (!empty($addressData->address_lastname) ? ' ' . $addressData->address_lastname : '');
         if (empty($this->registerData->name) && !empty($this->registerData->email)) {
             $parts = explode('@', $this->registerData->email);
             $this->registerData->name = array_shift($parts);
         }
     }
     if ($simplified == 1) {
         $this->registerData->username = $this->registerData->email;
         jimport('joomla.user.helper');
         $this->registerData->password = JUserHelper::genRandomPassword();
         $this->registerData->password2 = $this->registerData->password;
     } else {
         if ($simplified == 3) {
             $this->registerData->username = $this->registerData->email;
         }
     }
     if (!empty($this->registerData->username)) {
         $safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1);
         $this->registerData->username = $safeHtmlFilter->clean($this->registerData->username, 'USERNAME');
     }
     if ($simplified == 0 || $simplified == 3) {
         if (empty($this->registerData->password)) {
             $app->enqueueMessage(JText::_('JGLOBAL_AUTH_EMPTY_PASS_NOT_ALLOWED'));
             return false;
         }
         $minimumLength = (int) $params->get('minimum_length');
         $minimumIntegers = (int) $params->get('minimum_integers');
         $minimumSymbols = (int) $params->get('minimum_symbols');
         $minimumUppercase = (int) $params->get('minimum_uppercase');
         $language = JFactory::getLanguage();
         $language->load('com_users', JPATH_SITE, $language->getTag(), true);
         if (!empty($minimumLength)) {
             if (strlen((string) $this->registerData->password) < $minimumLength) {
                 $app->enqueueMessage(JText::plural('COM_USERS_MSG_PASSWORD_TOO_SHORT_N', $minimumLength), 'warning');
                 return false;
             }
         }
         if (!empty($minimumIntegers)) {
             $nInts = preg_match_all('/[0-9]/', $this->registerData->password, $imatch);
             if ($nInts < $minimumIntegers) {
                 $app->enqueueMessage(JText::plural('COM_USERS_MSG_NOT_ENOUGH_INTEGERS_N', $minimumIntegers), 'warning');
                 return false;
             }
         }
         if (!empty($minimumSymbols)) {
             $nsymbols = preg_match_all('[\\W]', $this->registerData->password, $smatch);
             if ($nsymbols < $minimumSymbols) {
                 $app->enqueueMessage(JText::plural('COM_USERS_MSG_NOT_ENOUGH_SYMBOLS_N', $minimumSymbols), 'warning');
                 return false;
             }
         }
         if (!empty($minimumUppercase)) {
             $nUppercase = preg_match_all("/[A-Z]/", $this->registerData->password, $umatch);
             if ($nUppercase < $minimumUppercase) {
                 $app->enqueueMessage(JText::plural('COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N', $minimumUppercase), 'warning');
                 return false;
             }
         }
     }
     $data = array('name' => @$this->registerData->name, 'username' => @$this->registerData->username, 'email' => @$this->registerData->email, 'password' => @$this->registerData->password, 'password2' => @$this->registerData->password2);
     $_SESSION['hikashop_main_user_data'] = $data;
     if (!empty($addressData->address_vat)) {
         $vat = hikashop_get('helper.vat');
         if (!$vat->isValid($addressData)) {
             $app->enqueueMessage(JText::_('VAT_NUMBER_NOT_VALID'));
             return false;
         }
     }
     if ($simplified != 2) {
         if (HIKASHOP_J16) {
             $data['groups'] = array($newUsertype => $newUsertype);
         }
         if (HIKASHOP_J25) {
             $jconfig = JFactory::getConfig();
             if (HIKASHOP_J30) {
                 $locale = $jconfig->get('language');
             } else {
                 $locale = $jconfig->getValue('config.language');
             }
             $data['params'] = array('site_language' => $locale, 'language' => $locale);
         }
         if (HIKASHOP_J25) {
             $language = JFactory::getLanguage();
             $language->load('lib_joomla', JPATH_SITE);
         }
         if (!$user->bind($data, 'usertype')) {
             JError::raiseError(500, $user->getError());
         }
         $user->set('id', 0);
         if (!HIKASHOP_J16) {
             $user->set('usertype', $newUsertype);
             $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO'));
         }
         $date = JFactory::getDate();
         if (HIKASHOP_J30) {
             $user->set('registerDate', $date->toSql());
         } else {
             $user->set('registerDate', $date->toMySQL());
         }
         $useractivation = $params->get('useractivation');
         if ($useractivation > 0) {
             jimport('joomla.user.helper');
             if (HIKASHOP_J30) {
                 $user->set('activation', JApplication::getHash(JUserHelper::genRandomPassword()));
             } else {
                 $user->set('activation', JUtility::getHash(JUserHelper::genRandomPassword()));
             }
             $user->set('block', '1');
         }
         if (!$user->save()) {
             JError::raiseWarning('', JText::_($user->getError()));
             return false;
         }
         $this->get(false);
         $newUser = $this->get($user->id, 'cms');
     }
     if (!empty($newUser)) {
         $userData->user_id = $newUser->user_id;
     } elseif (!empty($user->id)) {
         $userData->user_cms_id = $user->id;
     } else {
         $userData->user_email = $this->registerData->email;
     }
     if ($config->get('affiliate_registration', 0)) {
         if (JRequest::getInt('hikashop_affiliate_checkbox', 0)) {
             $userData->user_partner_activated = 1;
             $this->registerData->user_partner_activated = 1;
         }
     }
     if ($simplified == 2) {
         $this->database->setQuery('SELECT * FROM ' . hikashop_table('user') . ' WHERE user_email = ' . $this->database->Quote($userData->user_email));
         $userInDB = $this->database->loadObject();
         if (@$userInDB->user_cms_id) {
             JError::raiseWarning('', JText::_('EMAIL_ADDRESS_ALREADY_USED'));
             return false;
         }
         $this->user_id = 0;
         if (isset($userInDB->user_id)) {
             $this->user_id = $userInDB->user_id;
         }
         if ($this->user_id) {
             $userInDB->user_created_ip = hikashop_getIP();
             $this->save($userInDB);
         } else {
             $this->user_id = $this->save($userData);
         }
         $query = 'UPDATE ' . hikashop_table('address') . ' AS a SET a.address_published=0 WHERE a.address_user_id=' . (int) $this->user_id . ' and a.address_published=1';
         $this->database->setQuery($query);
         $this->database->query();
         $cartClass = hikashop_get('class.cart');
         $cart = $cartClass->loadCart();
         if (!is_object($cart)) {
             $cart = new stdClass();
         }
         $cart->user_id = $this->user_id;
         $cartClass->save($cart);
     } else {
         $this->user_id = $this->save($userData);
     }
     if ($config->get('address_on_registration', 1)) {
         if (isset($addressData->address_id)) {
             unset($addressData->address_id);
         }
         $this->registerData->user_id = $this->user_id;
         if (!empty($addressData)) {
             $addressData->address_user_id = $this->user_id;
             $addressClass = hikashop_get('class.address');
             $this->address_id = $addressClass->save($addressData);
         }
     }
     if ($simplified != 2) {
         $mailClass = hikashop_get('class.mail');
         $this->registerData->user_data =& $userData;
         $this->registerData->address_data =& $addressData;
         $this->registerData->password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', @$this->registerData->password);
         //Disallow control chars in the email
         $this->registerData->active = $useractivation;
         $vars = urlencode(base64_encode(json_encode(array('passwd' => $this->registerData->password, 'username' => $this->registerData->username))));
         global $Itemid;
         $url = '';
         if (!empty($Itemid)) {
             $url = '&Itemid=' . $Itemid;
         }
         $this->registerData->activation_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=checkout&task=activate&activation=' . $user->get('activation') . '&infos=' . $vars . '&page=' . $page . '&id=' . $this->user_id . $url . '&lang=' . @$_GET['lang'];
         $this->registerData->partner_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=affiliate&task=show' . $url;
         $mail = $mailClass->get('user_account', $this->registerData);
         if (!empty($this->registerData->email)) {
             $mail->subject = JText::sprintf($mail->subject, @$this->registerData->name, HIKASHOP_LIVE);
             $mail->dst_email =& $this->registerData->email;
             if (!empty($this->registerData->name)) {
                 $mail->dst_name =& $this->registerData->name;
             } else {
                 $mail->dst_name = '';
             }
             $mailClass->sendMail($mail);
             $mailSent = $mailClass->mail_success;
             if ($params->get('mail_to_admin', '0')) {
                 $mail = $mailClass->get('user_account_admin_notification', $this->registerData);
                 $mail->subject = JText::sprintf($mail->subject, @$this->registerData->name, HIKASHOP_LIVE);
                 if (empty($mail->dst_email)) {
                     $mail->dst_email = explode(',', $config->get('from_email'));
                 }
                 $mailClass->sendMail($mail);
             }
         }
         if ($useractivation > 0 && $redirect) {
             $lang = JFactory::getLanguage();
             $lang->load('com_user', JPATH_SITE);
             if ($mailSent) {
                 $message = JText::_('HIKA_REG_COMPLETE_ACTIVATE');
                 $app->enqueueMessage($message);
                 if ($page == 'checkout') {
                     $message = JText::_('WHEN_CLICKING_ACTIVATION');
                     $app->enqueueMessage($message);
                 }
             } else {
                 $message = JText::_('HIKA_MAIL_ISSUE_ACTIVATION');
                 $app->enqueueMessage($message);
             }
             $locale = strtolower(substr($lang->get('tag'), 0, 2));
             $app->redirect(hikashop_completeLink('checkout&task=activate_page&lang=' . $locale, false, true));
         } elseif (file_exists(JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'comprofiler.php')) {
             $newUser = $this->get($this->user_id);
             $this->addAndConfirmUserInCB($newUser, $addressData);
         }
     }
     return true;
 }
示例#21
0
 function onPaymentNotification(&$statuses)
 {
     global $Itemid;
     $this->url_itemid = empty($Itemid) ? '' : '&Itemid=' . $Itemid;
     if (JRequest::getVar('pbx', '') == 'user') {
         $app = JFactory::getApplication();
         $t = JRequest::getVar('t', '');
         switch ($t) {
             case 'refuse':
                 $url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=order&task=cancel_order' . $this->url_itemid;
                 break;
             case 'cancel':
                 $url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=order&task=cancel_order' . $this->url_itemid;
                 break;
             case 'confirm':
             default:
                 $url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=checkout&task=after_end' . $this->url_itemid;
                 break;
         }
         $app->redirect($url);
         return;
     }
     $method_id = JRequest::getInt('notif_id', 0);
     $this->pluginParams($method_id);
     $this->payment_params =& $this->plugin_params;
     if (empty($this->payment_params)) {
         exit;
     }
     if (!empty($this->payment_params->ips)) {
         $ip = hikashop_getIP();
         $valid = false;
         $ips = explode(';', $this->payment_params->ips);
         foreach ($ips as $i) {
             $i = trim($i);
             if ($i == $ip) {
                 $valid = true;
                 break;
             }
         }
         if (!$valid) {
             $email = new stdClass();
             $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Paybox') . ' ' . JText::sprintf('IP_NOT_VALID', '');
             $email->body = str_replace('<br/>', "\r\n", JText::sprintf('NOTIFICATION_REFUSED_FROM_IP', 'Paybox', $ip, implode("\r\n", $ips)));
             $action = false;
             $this->modifyOrder($action, null, null, $email);
             JError::raiseError(403, JText::_('Access Forbidden'));
             exit;
         }
     }
     if (function_exists('openssl_pkey_get_public') && (!isset($this->payment_params->signature) || !empty($this->payment_params->signature))) {
         $signature = JRequest::getVar('sign', '');
         if (!empty($signature)) {
             $signature = base64_decode(urldecode($signature));
         }
         $p_mt = JRequest::getVar('mt', '');
         $p_ref = JRequest::getVar('ref', '');
         $p_auth = JRequest::getVar('auth', '');
         $p_err = JRequest::getVar('err', '');
         $sign_data = 'mt=' . rawurlencode($p_mt) . '&ref=' . rawurlencode($p_ref) . '&auth=' . rawurlencode($p_auth) . '&err' . rawurlencode($p_err);
         $pubkeyid = openssl_pkey_get_public(dirname(__FILE__) . DS . 'paybox_pubkey.pem');
         if ($pubkeyid !== false) {
             $sign = openssl_verify($sign_data, $signature, $pubkeyid);
             openssl_free_key($pubkeyid);
             if ($sign !== 1) {
                 $ip = hikashop_getIP();
                 $email = new stdClass();
                 $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Paybox') . ' ' . JText::_('SIGN_NOT_VALID');
                 $email->body = str_replace('<br/>', "\r\n", JText::sprintf('NOTIFICATION_REFUSED_FROM_IP', 'Paybox', $ip, JText::_('SIGN_NOT_VALID')));
                 $action = false;
                 $this->modifyOrder($action, null, null, $email);
                 JError::raiseError(403, JText::_('Access Forbidden'));
                 exit;
             }
         }
     }
     $order_id = (int) JRequest::getInt('ref', 0);
     $dbOrder = $this->getOrder($order_id);
     if (empty($dbOrder)) {
         exit;
     }
     if ($method_id != $dbOrder->order_payment_id) {
         exit;
     }
     $this->loadOrderData($dbOrder);
     $pbx_auth = JRequest::getVar('auth', '');
     $pbx_err = JRequest::getVar('err', '99999');
     $pbx_mt = JRequest::getInt('mt', 0);
     $history = new stdClass();
     $email = new stdClass();
     $url = HIKASHOP_LIVE . 'administrator/index.php?option=com_hikashop&ctrl=order&task=edit&order_id=' . $order_id . $this->url_itemid;
     $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));
     $history->notified = 0;
     $history->amount = $pbx_mt / 100;
     $history->data = ob_get_clean();
     $price_check = (int) ($dbOrder->order_full_price * 100);
     if ($pbx_mt != $price_check) {
         $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Paybox') . JText::_('INVALID_AMOUNT');
         $email->body = str_replace('<br/>', "\r\n", JText::sprintf('AMOUNT_RECEIVED_DIFFERENT_FROM_ORDER', 'Paybox', $history->amount, $price_check / 100 . $this->currency->currency_code)) . "\r\n\r\n" . $order_text;
         $this->modifyOrder($order_id, $this->payment_params->invalid_status, $history, $email);
         exit;
     }
     $completed = (int) $pbx_err == 0 && $pbx_err == '00000';
     if (!$completed) {
         $order_status = $this->payment_params->invalid_status;
         $history->data .= "\n\n" . 'payment with code ' . $pbx_auth;
         $payment_status = 'cancel';
         $email->body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Paybox', $payment_status)) . ' ' . JText::_('STATUS_NOT_CHANGED') . "\r\n\r\n" . $order_text;
         $email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', 'Paybox', $payment_status, $dbOrder->order_number);
         $this->modifyOrder($order_id, $order_status, $history, $email);
         exit;
     }
     $history->notified = 1;
     $order_status = $this->payment_params->verified_status;
     $payment_status = 'Accepted';
     $email->body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Paybox', $payment_status)) . ' ' . JText::sprintf('ORDER_STATUS_CHANGED', $statuses[$order_status]) . "\r\n\r\n" . $order_text;
     $email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', 'Paybox', $payment_status, $dbOrder->order_number);
     $this->modifyOrder($order_id, $order_status, $history, $email);
     exit;
 }
示例#22
0
 function onAfterOrderUpdate(&$order, &$send_email)
 {
     $order_type = isset($order->order_type) ? $order->order_type : $order->old->order_type;
     if ($order_type != 'sale' || empty($order->order_status)) {
         return;
     }
     if (!isset($order->order_shipping_params->EMC_params)) {
         return;
     }
     if (!$this->init()) {
         return false;
     }
     $config = hikashop_config();
     $order_confirmed_status = $config->get('order_confirmed_status', 'confirmed');
     $invoice_order_statuses = explode(',', $config->get('invoice_order_statuses', 'confirmed,shipped'));
     if (empty($invoice_order_statuses)) {
         $invoice_order_statuses = array('confirmed', 'shipped');
     }
     if ($order->order_status != $order_confirmed_status && !in_array($order->order_status, $invoice_order_statuses)) {
         return;
     }
     $order_shipping_params = isset($order->order_shipping_params) ? $order->order_shipping_params : $order->old->order_shipping_params;
     if (is_string($order_shipping_params)) {
         $order_shipping_params = unserialize($order_shipping_params);
     }
     $ref_exist = false;
     foreach ($order_shipping_params->EMC_params as $value) {
         if (!empty($value['reference'])) {
             $ref_exist = true;
         }
     }
     if ($ref_exist == true) {
         return;
     }
     $db = JFactory::getDBO();
     $orderClass = hikashop_get('class.order');
     $fullOrder = $orderClass->loadFullOrder($order->order_id, true, false);
     $tab_products = array();
     foreach ($fullOrder->order_shipping_params->EMC_params as $key => $value) {
         $data = array('products' => array());
         foreach ($fullOrder->products as $k => $product) {
             if ($product->order_product_shipping_method != 'envoimoinscher') {
                 continue;
             }
             if ($key == $product->order_product_shipping_id) {
                 $ids_products = explode('@', $product->order_product_shipping_id);
                 $warehouse_id = $ids_products[1];
                 $data['products'][] = $product;
             }
         }
         if (!empty($data['products'])) {
             $data['warehouse_id'] = $warehouse_id;
             $data['shipping_id'] = $ids_products[0];
             $tab_products[] = $data;
         }
     }
     $czone_code_to = @$fullOrder->shipping_address->address_country;
     $query = 'SELECT zone_id, zone_code_2 FROM ' . hikashop_table('zone') . ' WHERE zone_name_english = ' . $db->Quote($czone_code_to);
     $db->setQuery($query);
     $czone = $db->loadObject();
     $country_to = $czone->zone_code_2;
     if ($country_to == 'FX') {
         $country_to = 'FR';
     }
     $user_address_title = $fullOrder->shipping_address->address_title;
     $key = 'HIKA_TITLE_' . strtoupper($user_address_title);
     if ($key != JText::_($key)) {
         $user_address_title = JText::_($key);
     }
     $email = @$fullOrder->customer->user_email;
     $phone = @$fullOrder->shipping_address->address_telephone;
     foreach ($tab_products as $key => $value) {
         $shipping_ids = explode('-', $value['shipping_id']);
         $this->pluginParams($shipping_ids[0]);
         if ($this->plugin_params->make_order == 0) {
             continue;
         }
         if ($this->plugin_params->destination_type == 'res' || $this->plugin_params->destination_type == 'auto' && empty($fullOrder->shipping_address->address_company)) {
             $user_type = 'particulier';
         } else {
             $user_type = 'entreprise';
         }
         if (empty($email) || empty($phone)) {
             return;
         }
         $to = array('pays' => $country_to, 'code_postal' => $fullOrder->shipping_address->address_post_code, 'type' => $user_type, 'ville' => $fullOrder->shipping_address->address_city, 'adresse' => $fullOrder->shipping_address->address_street, 'civilite' => $user_address_title, 'prenom' => $fullOrder->shipping_address->address_firstname, 'nom' => $fullOrder->shipping_address->address_lastname, 'email' => $email, 'tel' => $phone);
         $admin_address_title = $this->plugin_params->sender_civility;
         $key = 'HIKA_TITLE_' . strtoupper($admin_address_title);
         if ($key != JText::_($key)) {
             $admin_address_title = JText::_($key);
         }
         $czone_code_from = @$this->plugin_params->sender_country;
         $query = 'SELECT zone_id, zone_code_2 FROM ' . hikashop_table('zone') . ' WHERE zone_namekey = ' . $db->Quote($czone_code_from);
         $db->setQuery($query);
         $czone = $db->loadObject();
         $country_from = $czone->zone_code_2;
         if ($country_from == 'FX') {
             $country_from = 'FR';
         }
         $from = array('pays' => $country_from, 'code_postal' => $this->plugin_params->sender_postcode, 'type' => $this->plugin_params->type, 'ville' => $this->plugin_params->sender_city, 'adresse' => $this->plugin_params->sender_address, 'civilite' => $admin_address_title, 'prenom' => $this->plugin_params->sender_firstname, 'nom' => $this->plugin_params->sender_lastname, 'email' => $this->plugin_params->sender_email, 'tel' => $this->plugin_params->sender_phone);
         if ($this->plugin_params->type == 'entreprise') {
             $from['societe'] = $this->plugin_params->sender_company;
         }
         $code = (int) $this->plugin_params->product_category;
         $shipping = explode(' / ', $shipping_ids[1]);
         $service = $shipping[1];
         $shipping = $value['shipping_id'] . '@' . $value['warehouse_id'];
         foreach ($fullOrder->order_shipping_params->EMC_params as $k => $v) {
             if ($k == $shipping) {
                 $dropoff = explode('<br/>', $v['drop_off']);
                 $pickup = explode('<br/>', $v['pick_up']);
                 $ope = $v['code'];
             }
         }
         $sending_type = strtolower($this->plugin_params->sending_type);
         $collection = $dropoff[0];
         $delivery = $pickup[0];
         $quotInfo = array('collecte' => date('Y-m-d'), 'delai' => 'aucun', 'code_contenu' => $code, 'type_emballage.emballage' => 1, 'operateur' => $ope, 'raison' => 'sale', 'service' => $service, 'collection_type' => $collection, 'delivery_type' => $delivery, 'depot.pointrelais' => '', 'retrait.pointrelais' => '', $sending_type . '.description' => '');
         if ($collection == 'POST_OFFICE' || $collection == 'DROPOFF_POINT') {
             $quotInfo['depot.pointrelais'] = $dropoff[2];
         }
         if ($delivery == 'PICKUP_POINT') {
             $quotInfo['retrait.pointrelais'] = $pickup[2];
         }
         if (isset($this->plugin_params->start_availability) && !empty($this->plugin_params->start_availability)) {
             $quotInfo['disponibilite.HDE'] = $this->plugin_params->start_availability;
         }
         if (isset($this->plugin_params->end_availability) && !empty($this->plugin_params->end_availability)) {
             $quotInfo['disponibilite.HLE'] = $this->plugin_params->end_availability;
         }
         foreach ($value['products'] as $product) {
             $quotInfo[$sending_type . '.description'] .= '  ' . $product->order_product_name;
         }
         $productClass = hikashop_get('class.product');
         $newOrder = new stdClass();
         $i = 0;
         foreach ($value['products'] as $p) {
             $product = $productClass->get($p->product_id);
             if ($product->product_parent_id != 0) {
                 $parent = $productClass->get($product->product_parent_id);
                 $newOrder->products[$i] = $parent;
                 $newOrder->products[$i]->variants[0] = $product;
                 if ($product->product_width == 0 && $product->product_length == 0) {
                     $product->product_width = $parent->product_width;
                     $product->product_length = $parent->product_length;
                     $product->product_height = $parent->product_height;
                 }
                 $product->cart_product_quantity = $p->order_product_quantity;
                 $product->product_weight_orig = $parent->product_weight;
                 $product->product_weight_unit_orig = $parent->product_weight_unit;
                 $product->product_dimension_unit_orig = $parent->product_dimension_unit;
                 $product->prices[0] = new stdClass();
                 $product->prices[0]->unit_price = new stdClass();
                 $product->prices[0]->unit_price->price_value_with_tax = $p->order_product_price + $p->order_product_tax;
             } else {
                 $newOrder->products[$i] = $product;
                 $newOrder->products[$i]->cart_product_quantity = $p->order_product_quantity;
                 $newOrder->products[$i]->product_weight_orig = $newOrder->products[$i]->product_weight;
                 $newOrder->products[$i]->product_weight_unit_orig = $newOrder->products[$i]->product_weight_unit;
                 $newOrder->products[$i]->product_dimension_unit_orig = $newOrder->products[$i]->product_dimension_unit;
                 $newOrder->products[$i]->prices[0] = new stdClass();
                 $newOrder->products[$i]->prices[0]->unit_price = new stdClass();
                 $newOrder->products[$i]->prices[0]->unit_price->price_value_with_tax = $p->order_product_price + $p->order_product_tax;
             }
             $i++;
         }
         $data = $this->getData(null, $this, $newOrder, $sending_type, true);
         $total_price = (int) $data[0]["price"];
         unset($data[0]);
         $quotInfo[$sending_type . '.valeur'] = $total_price;
         $cotCl = new Env_Quotation(array('user' => $this->plugin_params->emc_login, 'pass' => $this->plugin_params->emc_password, 'key' => $this->plugin_params->api_key));
         $cotCl->setEnv($this->plugin_params->environment);
         $config = hikashop_config();
         $contentCl->setPlatformParams('hikashop', $config->get('version'), $config->get('version'));
         $cotCl->setPerson('expediteur', $from);
         $cotCl->setPerson('destinataire', $to);
         $cotCl->setType($sending_type, $data);
         if ($country_to != $country_from) {
             $infos_products = array();
             $i = 1;
             foreach ($newOrder->products as $product) {
                 $infos_products[$i] = array();
                 if (isset($product->variants)) {
                     $nb = $product->variants[0]->cart_product_quantity;
                     $price = $product->variants[0]->prices[0]->unit_price->price_value_with_tax;
                     $weight = $product->variants[0]->product_weight_orig;
                 } else {
                     $nb = $product->cart_product_quantity;
                     $price = $product->prices[0]->unit_price->price_value_with_tax;
                     $weight = $product->product_weight_orig;
                 }
                 $infos_products[$i]["description_en"] = $product->product_name;
                 $infos_products[$i]["description_fr"] = $product->product_name;
                 $infos_products[$i]["nombre"] = $nb;
                 $infos_products[$i]["valeur"] = $price;
                 $infos_products[$i]["origine"] = $country_from;
                 $infos_products[$i]["poids"] = $weight;
                 $i++;
             }
             $cotCl->setProforma($infos_products);
         }
         $orderPassed = $cotCl->makeOrder($quotInfo, true);
         if (!$cotCl->curlError && !$cotCl->respError) {
             if ($orderPassed) {
                 $fullOrder->order_shipping_params->EMC_params[$shipping]['reference'] = $cotCl->order['ref'];
                 $update_order = new stdClass();
                 $update_order->order_id = $fullOrder->order_id;
                 $update_order->order_shipping_params = $fullOrder->order_shipping_params;
                 $orderClass->save($update_order);
             }
         } elseif ($cotCl->respError) {
             $update_history = new stdClass();
             $update_history->history_order_id = $fullOrder->order_id;
             $update_history->history_created = time();
             $update_history->history_notified = 0;
             $update_history->history_ip = hikashop_getIP();
             $update_history->history_reason = 'EnvoiMoinsCher Error';
             $update_history->history_data = '';
             foreach ($cotCl->respErrorsList as $m => $message) {
                 $update_history->history_data .= $message['message'] . '<br/>';
             }
             $historyClass = hikashop_get('class.history');
             $historyClass->save($update_history);
         } else {
             $update_history = new stdClass();
             $update_history->history_order_id = $fullOrder->order_id;
             $update_history->history_created = time();
             $update_history->history_notified = 0;
             $update_history->history_ip = hikashop_getIP();
             $update_history->history_reason = 'EnvoiMoinsCher Error';
             $update_history->history_data = $cotCl->curlErrorText;
             $historyClass = hikashop_get('class.history');
             $historyClass->save($update_history);
         }
     }
 }