Esempio n. 1
1
File: utf8.php Progetto: ext/magento
function isEqual($string1, $string2)
{
    //    $string1 = utf8_strtolower( preg_replace('/([\s+])/', '', Encoding::fixUTF8($string1) ));
    //    $string2 = utf8_strtolower( preg_replace('/([\s+])/', '', Encoding::fixUTF8($string2 )));
    $string1 = explode(" ", utf8_strtolower(Encoding::fixUTF8($string1)));
    $string2 = explode(" ", utf8_strtolower(Encoding::fixUTF8($string2)));
    $filterStr1 = array();
    foreach ($string1 as $str1) {
        if (trim($str1, '.') == $str1) {
            $filterStr1[] = $str1;
        }
    }
    $filterStr2 = array();
    foreach ($string2 as $str2) {
        if (trim($str2, '.') == $str2) {
            $filterStr2[] = $str2;
        }
    }
    $foundName = array_intersect($filterStr1, $filterStr2);
    return count($foundName) > 0;
}
Esempio n. 2
0
function match_usernamevp($str1, $str2)
{
    $name1 = explode(' ', utf8_strtolower(Encoding::fixUTF8($str1)));
    $name2 = explode(' ', utf8_strtolower(Encoding::fixUTF8($str2)));
    $foundName = array_intersect($name1, $name2);
    return count($foundName) > 0;
}
 static function toSlug($string, $space = "-")
 {
     $string = Encoding::fixUTF8(Encoding::toUTF8($string));
     $string = self::mb_strtolower(self::mb_trim($string));
     $string = self::cleanTextHtml($string);
     if (function_exists('iconv')) {
         $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
     }
     $string = preg_replace('/[^a-z0-9 _.-]/', '', $string);
     $string = preg_replace('/[\\s\\-_]+/', $space, $string);
     $string = str_replace(' ', $space, $string);
     return $string;
 }
Esempio n. 4
0
 function process()
 {
     global $Shopp;
     $Shopping =& $Shopp->Shopping;
     $Order =& $Shopp->Order;
     require_once SHOPP_ADDONS . '/BillmateCore/BillMate.php';
     include_once SHOPP_ADDONS . "/BillmateCore/lib/xmlrpc.inc";
     include_once SHOPP_ADDONS . "/BillmateCore/lib/xmlrpcs.inc";
     $pno = $this->Order->pno;
     $phone = $this->Order->billmatephone;
     $eid = (int) $this->settings['eid'];
     $key = $this->settings['secretkey'];
     $ssl = true;
     $debug = false;
     $k = new BillMate($eid, $key, $ssl, $debug, $this->settings['testmode'] == 'on');
     $Customer = $this->Order->Customer;
     $Billing = $this->Order->Billing;
     $Shipping = $this->Order->Shipping;
     $country = $zone = $locale = $global = false;
     $country = $Billing->country;
     $country_to_currency = array('NO' => 'NOK', 'SE' => 'SEK', 'FI' => 'EUR', 'DK' => 'DKK', 'DE' => 'EUR', 'NL' => 'EUR');
     $ship_address = $bill_address = array();
     $countryData = BillmateCountry::getCountryData($Shipping->country);
     $ship_address = array('email' => $Customer->email, 'telno' => $Customer->phone, 'cellno' => '', 'fname' => $Customer->firstname, 'lname' => $Customer->lastname, 'company' => $Customer->company, 'careof' => '', 'street' => $Shipping->address, 'house_number' => isset($house_no) ? $house_no : '', 'house_extension' => isset($house_ext) ? $house_ext : '', 'zip' => $Shipping->postcode, 'city' => $Shipping->city, 'country' => $countryData['country']);
     $bill_address = array('email' => $Customer->email, 'telno' => $Customer->phone, 'cellno' => '', 'fname' => $Customer->firstname, 'lname' => $Customer->lastname, 'company' => $Customer->company, 'careof' => '', 'street' => $Billing->address, 'house_number' => '', 'house_extension' => '', 'zip' => $Billing->postcode, 'city' => $Billing->city, 'country' => $countryData['country']);
     foreach ($ship_address as $key => $col) {
         $ship_address[$key] = utf8_decode(Encoding::fixUTF8($col));
     }
     foreach ($bill_address as $key => $col) {
         $bill_address[$key] = utf8_decode(Encoding::fixUTF8($col));
     }
     extract($countryData);
     $goods_list = array();
     $taxrate = 0;
     if (sizeof($this->Order->Cart) <= 1 && !empty($this->settings['invoice_fee'])) {
         $Shopp->Order->Cart = array();
         new ShoppError(__('Cart is empty', 'shopp-billmate-invoice'), 2);
         $this->Order->feeadded = false;
         echo '<script type="text/javascript">window.location.href="' . shoppurl(false, 'cart') . '";</script>';
         die;
     }
     foreach ($this->Order->Cart as $item) {
         // echo links for the items
         $flag = stripos($item->name, 'billmate fee') === false ? stripos($item->name, 'billmate invoice fee') === false ? 0 : 16 : 0;
         $flag = stripos($item->name, 'billmate fee') === false ? stripos($item->name, 'billmate invoice fee') === false ? 0 : 16 : 0;
         $taxrate = $taxrate == 0 ? $item->taxrate : $taxrate;
         $goods_list[] = array('qty' => (int) $item->quantity, 'goods' => array('artno' => $item->product, 'title' => $item->name, 'price' => round($item->unitprice * 100, 0), 'vat' => round($item->taxrate * 100, 0), 'discount' => 0.0, 'flags' => $flag));
     }
     if ($this->Order->Cart->Totals->discount > 0) {
         $rate = (100 + $taxrate * 100) / 100;
         $totalAmt = $this->Order->Cart->Totals->discount;
         $price = $totalAmt - $totalAmt / $rate;
         $discount = $totalAmt - $price;
         $goods_list[] = array('qty' => (int) 1, 'goods' => array('artno' => __('discount', 'shopp-billmate-invoice'), 'title' => __('Discount', 'shopp-billmate-invoice'), 'price' => -1 * abs(round($this->Order->Cart->Totals->discount * 100, 0)), 'vat' => $taxrate * 100, 'discount' => 0, 'flags' => $flag));
     }
     if (!empty($this->Order->Cart->Totals->shipping)) {
         $totalAmt = $this->Order->Cart->Totals->shipping;
         $goods_list[] = array('qty' => (int) 1, 'goods' => array('artno' => __('Shipping', 'shopp-billmate-invoice'), 'title' => __('Shipping', 'shopp-billmate-invoice'), 'price' => round($totalAmt * 100, 0), 'vat' => $taxrate * 100, 'discount' => 0, 'flags' => 8));
     }
     $pclass = -1;
     $transaction = array("order1" => (string) $this->txnid(), "comment" => (string) "", "flags" => 0, "reference" => "", "reference_code" => "", "currency" => $currency, "country" => $country, "language" => $language, "pclass" => $pclass, "shipInfo" => array("delay_adjust" => "1"), "travelInfo" => array(), "incomeInfo" => array(), "bankInfo" => array(), "sid" => array("time" => microtime(true)), "extraInfo" => array(array("cust_no" => (string) $order_info['customer_id'])));
     $result1 = $k->AddInvoice($pno, $bill_address, $ship_address, $goods_list, $transaction);
     //shopp_rmv_cart_item($this->settings['invoice_fee']);
     if (!is_array($result1)) {
         $this->remove_fee();
         /*
         if( !empty($this->settings['invoice_fee'])){
         	$Shopp->Order->Cart->remove(sizeof( $this->Order->Cart )-1);
         	$Shopp->Order->Cart->totals();
         	$this->Order->feeadded = false;
         	unset($this->Order->feeadded);
         }
         */
         new ShoppError(__('Unable to process billmate try again <br/>Error:', 'shopp-billmate-invoice') . utf8_encode($result1), 2);
         echo '<script type="text/javascript">window.location.href="' . shoppurl(false, 'checkout') . '";</script>';
         die;
     } else {
         $this->Order->billmateId = $result1[0];
     }
     $this->Order->pno = '';
     $this->Order->billmatephone = '';
     $this->Order->feeadded = false;
     $this->Order->transaction($this->txnid());
     return true;
 }
 public function cleanTaxa($preview = 1, $fix = 0, $startTid = 0, $limit = 100000)
 {
     $sql = 'SELECT tid, author ' . 'FROM taxa ' . 'WHERE author IS NOT NULL ';
     if ($startTid) {
         $sql .= 'AND tid > ' . $startTid . ' ';
     }
     $sql .= 'ORDER BY tid ';
     if ($limit) {
         $sql .= 'LIMIT ' . $limit;
     }
     //echo $sql;
     $rs = $this->conn->query($sql);
     echo '<ol>';
     while ($r = $rs->fetch_assoc()) {
         $tid = $r['tid'];
         echo '<li><b>tid: </b>' . $tid . ': ';
         $setArr = array();
         $problem = false;
         foreach ($r as $k => $v) {
             if ($v && $k != 'tid') {
                 $vCleaned = $this->cleanInStr($v);
                 $toUtf8 = Encoding::toUTF8($vCleaned);
                 $fixUtf8 = Encoding::fixUTF8($vCleaned);
                 if ($fix && $fixUtf8 != $vCleaned) {
                     $problem = true;
                 }
                 if (!$fix && $toUtf8 != $vCleaned) {
                     $problem = true;
                 }
                 if ($preview || $problem) {
                     echo '<div style="margin-left:10px;">';
                     echo '<b>' . $k . ':</b>: ' . $v . '; ';
                     echo '<b>toUTF8 method:</b> ' . $toUtf8 . '; ';
                     echo '<b>fixUTF8 method:</b> ' . $fixUtf8;
                     echo '</div>';
                 }
                 if ($fix) {
                     $setArr[] = $k . ' = "' . $fixUtf8 . '"';
                 } else {
                     $setArr[] = $k . ' = "' . $toUtf8 . '"';
                 }
             }
         }
         if ($setArr) {
             $sqlFix = 'UPDATE taxa SET ' . implode(',', $setArr) . ' WHERE tid = ' . $tid;
             if ($problem) {
                 echo '<div style="margin-left:10px;"><b>PROBLEM:</b> ' . $sqlFix . '</div>';
                 if (!$preview) {
                     if (!$this->conn->query($sqlFix)) {
                         echo '<div style="margin-left:10px;">ERROR: ' . $this->conn->error . '; SQL: ' . $sqlFix . '</div>';
                     }
                 }
             }
         }
         echo '</li>';
     }
     $rs->free();
     echo '</ol>';
 }
Esempio n. 6
0
 /**
  * Convert and Fix UTF8 strings
  *
  * @param $string
  *     String to be fixed
  *
  * Returns
  *     $string
  */
 function utf8_encode($string)
 {
     if ($string) {
         return Encoding::fixUTF8(mb_check_encoding($string, 'UTF-8') ? $string : utf8_encode($string));
     } else {
         return NULL;
     }
 }
Esempio n. 7
0
 public function fixEncoding($string = '')
 {
     if (class_exists("Encoding")) {
         try {
             $string1 = Encoding::toUTF8($string);
             return Encoding::fixUTF8($string1);
         } catch (Exception $e) {
             return $string;
         }
     } else {
         return $string;
     }
 }
 function process()
 {
     global $Shopp;
     $Shopping =& $Shopp->Shopping;
     $Order =& $Shopp->Order;
     require_once SHOPP_ADDONS . '/BillmateCore/BillMate.php';
     include_once SHOPP_ADDONS . "/BillmateCore/lib/xmlrpc.inc";
     include_once SHOPP_ADDONS . "/BillmateCore/lib/xmlrpcs.inc";
     $pno = $this->Order->partpaymentpno;
     $phone = $this->Order->partpaymentphone;
     $eid = (int) $this->settings['eid'];
     $key = $this->settings['secretkey'];
     $ssl = true;
     $debug = false;
     $k = new BillMate($eid, $key, $ssl, $debug, $this->settings['testmode'] == 'on');
     $Customer = $this->Order->Customer;
     $Billing = $this->Order->Billing;
     $Shipping = $this->Order->Shipping;
     $country = $zone = $locale = $global = false;
     $country = $Billing->country;
     $country_to_currency = array('NO' => 'NOK', 'SE' => 'SEK', 'FI' => 'EUR', 'DK' => 'DKK', 'DE' => 'EUR', 'NL' => 'EUR');
     $ship_address = $bill_address = array();
     $countryData = BillmateCountry::getCountryData($Shipping->country);
     $ship_address = array('email' => $Customer->email, 'telno' => $Customer->phone, 'cellno' => '', 'fname' => $Customer->firstname, 'lname' => $Customer->lastname, 'company' => $Customer->company, 'careof' => '', 'street' => $Shipping->address, 'house_number' => isset($house_no) ? $house_no : '', 'house_extension' => isset($house_ext) ? $house_ext : '', 'zip' => $Shipping->postcode, 'city' => $Shipping->city, 'country' => $countryData['country']);
     $bill_address = array('email' => $Customer->email, 'telno' => $Customer->phone, 'cellno' => '', 'fname' => $Customer->firstname, 'lname' => $Customer->lastname, 'company' => $Customer->company, 'careof' => '', 'street' => $Billing->address, 'house_number' => '', 'house_extension' => '', 'zip' => $Billing->postcode, 'city' => $Billing->city, 'country' => $countryData['country']);
     foreach ($ship_address as $key => $col) {
         $ship_address[$key] = utf8_decode(Encoding::fixUTF8($col));
     }
     foreach ($bill_address as $key => $col) {
         $bill_address[$key] = utf8_decode(Encoding::fixUTF8($col));
     }
     extract($countryData);
     //new ShoppError(var_export($Shipping->country,1), 'invalid_personal_number');
     //shopp_safe_redirect(shoppurl(false,'checkout'));
     $goods_list = array();
     foreach ($this->Order->Cart->contents as $item) {
         // echo links for the items
         $flag = stripos($item->name, 'billmate fee') === false ? stripos($item->name, 'billmate invoice fee') === false ? 0 : 16 : 0;
         $goods_list[] = array('qty' => (int) $item->quantity, 'goods' => array('artno' => $item->product, 'title' => $item->name, 'price' => round($item->unitprice * 100, 0), 'vat' => round($item->taxrate * 100, 0), 'discount' => 0.0, 'flags' => $flag));
         $taxrate = $item->taxrate;
     }
     if ($this->Order->Cart->Totals->discount > 0) {
         $rate = (100 + $taxrate * 100) / 100;
         $totalAmt = $this->Order->Cart->Totals->discount;
         $price = $totalAmt - $totalAmt / $rate;
         $discount = $totalAmt - $price;
         $goods_list[] = array('qty' => 1, 'goods' => array('artno' => __('discount', 'shopp-billmate-partpayment'), 'title' => __('Discount', 'shopp-billmate-partpayment'), 'price' => -1 * abs(round($this->Order->Cart->Totals->discount * 100, 0)), 'vat' => $taxrate * 100, 'discount' => 0, 'flags' => $flag));
     }
     if (!empty($this->Order->Cart->Totals->shipping)) {
         $taxrate = $taxrate * 100;
         //$rate = (100+$taxrate)/100;
         $totalAmt = $this->Order->Cart->Totals->shipping;
         //$price = $totalAmt-($totalAmt/$rate);
         // $shipping = $totalAmt - $price;
         $goods_list[] = array('qty' => (int) 1, 'goods' => array('artno' => __('Shipping', 'shopp-billmate-partpayment'), 'title' => __('Shipping', 'shopp-billmate-partpayment'), 'price' => round($totalAmt * 100, 0), 'vat' => $taxrate, 'discount' => 0, 'flags' => 8));
     }
     $pclass = (int) $this->Order->pclass;
     $transaction = array("order1" => (string) $this->txnid(), "comment" => (string) "", "flags" => 0, "reference" => "", "reference_code" => "", "currency" => $currency, "country" => $country, "language" => $language, "pclass" => $pclass, "shipInfo" => array("delay_adjust" => "1"), "travelInfo" => array(), "incomeInfo" => array(), "bankInfo" => array(), "sid" => array("time" => microtime(true)), "extraInfo" => array(array("cust_no" => (string) $order_info['customer_id'])));
     try {
         $result1 = $k->AddInvoice($pno, $bill_address, $ship_address, $goods_list, $transaction);
     } catch (Exception $ex) {
     }
     $this->Order->partpaymentpno = '';
     $this->Order->partpaymentphone = '';
     $this->Order->pclass = false;
     if (!is_array($result1)) {
         new ShoppError(__('It is not possible to pay with that method and to choose a different payment method or use a different personal number', 'shopp-billmate-partpayment'), 'billmate_error', SHOPP_TRXN_ERR);
         shopp_redirect(shoppurl(false, 'checkout'));
         die;
     } else {
         $this->Order->billmateId = $result1[0];
     }
     $this->Order->transaction($this->txnid());
     return true;
 }
Esempio n. 9
0
 public function processRecord($record, $origin = false, $filter = false)
 {
     $data = json_decode($record['Data'], true);
     $client = $data['client'];
     $microtime = $data['microtime'];
     $microtimeRCV = $data['microtime-rcv'];
     $event = json_decode($data['event'], true);
     if (isset($event['object']['insert']['region']['region_name'])) {
         foreach ($event['object']['insert']['region']['region_name'] as $k => $v) {
             $v = Encoding::fixUTF8($v);
             $event['object']['insert']['region']['region_name_' . $k] = $v;
             unset($event['object']['insert']['region']['region_name'][$k]);
         }
     }
     if (isset($event['object']['insert']['category']['category_name'])) {
         foreach ($event['object']['insert']['category']['category_name'] as $k => $v) {
             $v = Encoding::fixUTF8($v);
             $event['object']['insert']['category']['category_name_' . $k] = $v;
             unset($event['object']['insert']['category']['category_name'][$k]);
         }
     }
     $id = '';
     $entity = '';
     if (isset($event['object']['ad_id'])) {
         $id = $event['object']['ad_id'];
         $entity = "ad";
     } else {
         if (isset($event['object']['user_id'])) {
             $id = $event['object']['user_id'];
             $entity = "user";
         }
     }
     $seed = "{$client}-{$entity}-{$id}";
     $md5 = md5($seed);
     $md5UUID = SimpleFunctions::md5ToUUID($md5);
     $object = array();
     $object['uuid'] = $md5UUID;
     $object['client'] = $client;
     $object['entity'] = $entity;
     $object['id'] = $id;
     $object['migration'] = 'Y';
     $object['microtime'] = $microtime;
     $object['microtime_rcv'] = $microtimeRCV;
     if (isset($origin)) {
         $object['origin'] = $origin;
     }
     if (isset($event['object']['insert'])) {
         $object['action'] = 'insert';
         foreach ($event['object']['insert'] as $k => $v) {
             $object[$k] = $v;
         }
     } else {
         if (isset($event['object']['update'])) {
             $object['action'] = 'update';
             foreach ($event['object']['insert'] as $k => $v) {
                 $object[$k] = $v;
             }
         }
     }
     $object['email'] = md5($object['email']);
     $object['name'] = md5($object['name']);
     $object['phone'] = md5($object['phone']);
     if (!strstr($client, "_debug")) {
         // Keyspace can be changed at runtime
         if (isset($filter) && $filter != '') {
             if ($client == $filter) {
                 $result = $this->client->setKeyspace($client);
             }
         } else {
             $result = $this->client->setKeyspace($client);
         }
         // Batch 1
         if ($object['entity'] == 'ad') {
             $object['body'] = rtrim($object['body']);
             $object['subject'] = rtrim($object['subject']);
             try {
                 foreach ($object as $key => $value) {
                     if ($key != 'uuid') {
                         if (isset($value) && !is_array($value) && $value != '') {
                             $object[$key] = "'" . rtrim(str_replace("'", "''", $value)) . "'";
                         } else {
                             $object[$key] = "''";
                         }
                     }
                 }
                 $query = "INSERT INTO {$client}.ads (uuid, client, entity, id, migration, action, microtime, microtime_rcv, body, subject, user_id) VALUES ({$object['uuid']}, {$object['client']}, {$object['entity']}, {$object['id']}, {$object['migration']}, {$object['action']}, {$object['microtime']}, {$object['microtime_rcv']}, {$object['body']}, {$object['subject']}, {$object['user_id']});";
                 // echo $query."\n";
                 if (isset($filter) && $filter != '') {
                     if ($client == $filter) {
                         $res = $this->client->query($query);
                     }
                 } else {
                     $res = $this->client->query($query);
                 }
                 if (isset($res)) {
                     echo "cassandra {$client} {$object['uuid']}\n";
                 }
             } catch (\Cassandra\Exception $e) {
                 echo $e->getMessage();
             }
         } else {
             if ($object['entity'] == 'user') {
                 if (isset($object['name'])) {
                     $object['name'] = rtrim($object['name']);
                 } else {
                     $object['name'] = '';
                 }
                 try {
                     foreach ($object as $key => $value) {
                         if ($key != 'uuid') {
                             if (isset($value) && !is_array($value) && $value != '') {
                                 $object[$key] = "'" . rtrim(str_replace("'", "''", $value)) . "'";
                             } else {
                                 $object[$key] = "''";
                             }
                         }
                     }
                     $query = "INSERT INTO {$client}.users (uuid, client, entity, id, migration, action, microtime, microtime_rcv, email, name) VALUES ({$object['uuid']}, {$object['client']}, {$object['entity']}, {$object['id']}, {$object['migration']}, {$object['action']}, {$object['microtime']}, {$object['microtime_rcv']}, {$object['email']}, {$object['name']});";
                     // echo $query."\n";
                     if (isset($filter)) {
                         if ($client == $filter) {
                             $res = $this->client->query($query);
                         }
                     } else {
                         $res = $this->client->query($query);
                     }
                     if (isset($res)) {
                         echo "cassandra {$client} {$object['uuid']}\n";
                     }
                 } catch (\Cassandra\Exception $e) {
                     echo $e->getMessage();
                 }
             }
         }
     }
     if (isset($result)) {
         return $result;
     }
 }
Esempio n. 10
0
<?php

require_once "../autoload.php";
function is($desc, $a, $b)
{
    if ($a === $b) {
        echo '<span style="background-color: green;">&nbsp;Pass&nbsp;</span> ' . $desc . "<br/>\n";
    } else {
        echo '<span style="background-color: red;">&nbsp;Failed&nbsp;</span> ' . $desc . "<br/>\n";
    }
    return $a === $b;
}
$orig = "αšΓ‘šÑőαιν";
is("Encoding::toUTF8() convierte a UTF-8 todos los caracteres que no son ya UTF-8, teniendo en cuenta los que son Windows-1252, pero dejando sin cambios a los que ya son UTF-8", Encoding::toUTF8($orig), "ÑőњÑőÑéí");
$utf8_from_iso = "Β€ΒΒ‚ΒƒΒ„Β…Β†Β‡ΒˆΒ‰ΒŠΒ‹ΒŒΒΒŽΒΒΒ‘Β’Β“Β”Β•Β–Β—Β˜Β™ΒšΒ›ΒœΒΒžΒŸ";
$utf8_from_win = "β‚¬Ββ€šΖ’β€žβ€¦β€ β€‘Λ†β€°Ε β€ΉΕ’ΒΕ½ΒΒβ€˜β€™β€œβ€β€’β€“β€”Λœβ„’Ε‘β€ΊΕ“ΒΕΎΕΈ";
is("Encoding::UTF8FixWin1252Chars() convierte UTF-8 a UTF-8 corrigiendo caracteres especiales de Windows-1252", Encoding::UTF8FixWin1252Chars($utf8_from_iso), $utf8_from_win);
is("Encoding::toLatin1() convierte los UTF-8 a Windows-1252", Encoding::toLatin1($orig), "αšαšαšαιν");
is("Encoding::toLatin1() convierte los UTF-8 con caracteres convertidos desde Windows-1252 a Windows-1252", Encoding::toLatin1($utf8_from_win), "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ");
is("Encoding::toLatin1() convierte los UTF-8 con caracteres convertidos desde ISO8859-1 a Windows-1252", Encoding::toLatin1($utf8_from_iso), "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ");
is("Encoding::toWin1252() convierte los UTF-8 a Windows-1252", Encoding::toWin1252($orig), "αšαšαšαιν");
is("Encoding::toWin1252() convierte los UTF-8 con caracteres convertidos desde Windows-1252 a Windows-1252", Encoding::toWin1252($utf8_from_win), "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ");
is("Encoding::toWin1252() convierte los UTF-8 con caracteres convertidos desde ISO8859-1 a Windows-1252", Encoding::toWin1252($utf8_from_iso), "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ");
is("Encoding::fixUTF8() corrige UTF-8 convertido repetidamente", Encoding::fixUTF8(utf8_encode(utf8_encode(utf8_encode($orig)))), "ÑőÑőÑőÑéí");
Esempio n. 11
0
 function billmate_transaction($add_order = false)
 {
     global $Shopp;
     $Shopping =& $Shopp->Shopping;
     $Order =& $Shopp->Order;
     if (empty($_POST)) {
         $_POST = $_GET;
     }
     $pno = '';
     $eid = (int) $this->settings['merchantid'];
     $key = $this->settings['cardpaysecret'];
     $ssl = true;
     $debug = false;
     $k = new BillMate($eid, $key, $ssl, $debug);
     $Customer = $this->Order->Customer;
     $Billing = $this->Order->Billing;
     $Shipping = $this->Order->Shipping;
     $country = $zone = $locale = $global = false;
     $country = $Billing->country;
     $country_to_currency = array('NO' => 'NOK', 'SE' => 'SEK', 'FI' => 'EUR', 'DK' => 'DKK', 'DE' => 'EUR', 'NL' => 'EUR');
     $ship_address = $bill_address = array();
     $countries = Lookup::countries();
     //$countryData = BillmateCountry::getCountryData($Shipping->country);
     $countryData = BillmateCountry::getSwedenData();
     $ship_address = array('email' => $Customer->email, 'telno' => $Customer->phone, 'cellno' => '', 'fname' => $Customer->firstname, 'lname' => $Customer->lastname, 'company' => $Customer->company, 'careof' => '', 'street' => $Shipping->address, 'house_number' => isset($house_no) ? $house_no : '', 'house_extension' => isset($house_ext) ? $house_ext : '', 'zip' => $Shipping->postcode, 'city' => $Shipping->city, 'country' => $countries[$Shipping->country]['name']);
     $bill_address = array('email' => $Customer->email, 'telno' => $Customer->phone, 'cellno' => '', 'fname' => $Customer->firstname, 'lname' => $Customer->lastname, 'company' => $Customer->company, 'careof' => '', 'street' => $Billing->address, 'house_number' => '', 'house_extension' => '', 'zip' => $Billing->postcode, 'city' => $Billing->city, 'country' => $countries[$Billing->country]['name']);
     foreach ($ship_address as $key => $col) {
         $ship_address[$key] = utf8_decode(Encoding::fixUTF8($col));
     }
     foreach ($bill_address as $key => $col) {
         $bill_address[$key] = utf8_decode(Encoding::fixUTF8($col));
     }
     extract($countryData);
     $goods_list = array();
     $taxrate = 0;
     foreach ($this->Order->Cart as $item) {
         // echo links for the items
         $flag = stripos($item->name, 'billmate fee') === false ? stripos($item->name, 'billmate invoice fee') === false ? 0 : 16 : 0;
         $taxrate = $taxrate == 0 ? $item->taxrate : $taxrate;
         $goods_list[] = array('qty' => (int) $item->quantity, 'goods' => array('artno' => $item->product, 'title' => $item->name, 'price' => round($item->unitprice * 100, 0), 'vat' => (double) round($item->taxrate * 100, 0), 'discount' => 0.0, 'flags' => $flag));
     }
     if ($this->Order->Cart->Totals->discount > 0) {
         $rate = (100 + $taxrate * 100) / 100;
         $totalAmt = $this->Order->Cart->Totals->discount;
         $price = $totalAmt - $totalAmt / $rate;
         $discount = $totalAmt - $price;
         $goods_list[] = array('qty' => (int) 1, 'goods' => array('artno' => __('discount', 'shopp-billmate-cardpay'), 'title' => __('Discount', 'shopp-billmate-cardpay'), 'price' => -1 * abs(round($this->Order->Cart->Totals->discount * 100, 0)), 'vat' => (double) $taxrate * 100, 'discount' => (double) 0, 'flags' => $flag));
     }
     if (!empty($this->Order->Cart->Totals->shipping)) {
         /* $taxrate = $taxrate * 100;
            $rate = (100+$taxrate)/100;
            $totalAmt = $this->Order->Cart->Totals->shipping;
            $price = $totalAmt-($totalAmt/$rate);
            $shipping = $totalAmt - $price;*/
         $goods_list[] = array('qty' => (int) 1, 'goods' => array('artno' => __('Shipping', 'shopp-billmate-cardpay'), 'title' => __('Shipping', 'shopp-billmate-cardpay'), 'price' => round($this->Order->Cart->Totals->shipping * 100, 0), 'vat' => (double) $taxrate * 100, 'discount' => 0, 'flags' => 8));
     }
     $pclass = -1;
     $lang = explode("_", strtoupper(WPLANG));
     $base = $Shopp->Settings->get('base_operations');
     $_ = array();
     $transaction = array("order1" => (string) $this->txnid(), "comment" => (string) "", "flags" => 0, "reference" => "", "reference_code" => "", "currency" => $base['currency']['code'], "country" => 209, "language" => $lang[0], "pclass" => $pclass, "shipInfo" => array("delay_adjust" => "1"), "travelInfo" => array(), "incomeInfo" => array(), "bankInfo" => array(), "sid" => array("time" => microtime(true)), "extraInfo" => array(array("cust_no" => (string) $Customer->id, "creditcard_data" => $_POST)));
     if (!empty($this->Order->capture) && $this->Order->capture == 'YES') {
         $transaction["extraInfo"][0]["status"] = 'Paid';
     }
     if ($add_order) {
         return $k->AddOrder($pno, $bill_address, $ship_address, $goods_list, $transaction);
     }
     if (!isset($_SESSION['card_invoice_called']) || $_SESSION['card_invoice_called'] == false) {
         $result1 = $k->AddInvoice($pno, $bill_address, $ship_address, $goods_list, $transaction);
     } else {
         $result1[0] = $_SESSION['card_invoice_called_inv'];
     }
     if (!is_array($result1)) {
         new ShoppError(__('Unable to process billmate try again <br/>Error:', 'shopp-billmate-cardpay') . utf8_encode($result1), 2);
         echo '<script type="text/javascript">window.location.href="' . shoppurl(false, 'checkout') . '";</script>';
         die;
     } else {
         $this->Order->billmateId = $result1[0];
     }
 }
Esempio n. 12
0
 public function encodeFixUtf8($text)
 {
     // enconding para UTF-8
     return $text;
     return Encoding::fixUTF8($text);
 }