function items_customfields_header()
{
    if (!file_exists(GSDATAOTHERPATH . 'plugincustomfields.xml')) {
        $xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><channel></channel>');
        $xml->asXML(GSDATAOTHERPATH . 'plugincustomfields.xml');
        return true;
    }
    ?>
  <style type="text/css">
    form #metadata_window table.formtable td .cke_editor td:first-child { padding: 0; }
    form #metadata_window table.formtable .cke_editor td.cke_top { border-bottom: 1px solid #AAAAAA; }
    form #metadata_window table.formtable .cke_editor td.cke_contents { border: 1px solid #AAAAAA; }
    #customfieldsForm .hidden { display:none; }
    .shorts {
      width:250px !important;
    }
    .checkp {
      margin-top:17px;
    }
     .user_sub_tr {
      border:0px;border-bottom:0px !important; border-bottom-width:0px !important;border-top:0px;border-top-width:0px !important;
   }
    .user_sub_tr td{
      border:0px;border-bottom:0px !important;border-bottom-width:0px !important;padding-top:6px !important; border-top: 0px !important;
   }
      .resize_img {
    max-height:150px;
  }
    

  </style>
<?php 
}
 /**
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since 150213
  */
 public function printXML()
 {
     if (headers_sent()) {
         return;
     }
     if (!$this->simpleXML instanceof SimpleXMLExtended) {
         $fileLocation = $this->getFileLocation();
         if (!$this->existsAndReadable($fileLocation)) {
             die('EW:X:P');
         }
         $this->simpleXML = simplexml_load_file($fileLocation);
     }
     header("Content-Type:text/xml");
     echo $this->simpleXML->asXML();
     exit(0);
 }
Пример #3
0
 /**
  * Function for converting to an XML document.
  * Pass in a multi dimensional array or object and this recrusively loops through and builds up an XML document.
  *
  * @param array $data
  * @param string $rootNodeName - what you want the root node to be - defaultsto data.
  * @param SimpleXMLElement $xml - should only be used recursively
  * @return string XML
  */
 public static function toXml($data, $rootNodeName = 'root', $xml = null, $encoding = 'utf-8', $cdata = false)
 {
     // turn off compatibility mode as simple xml throws a wobbly if you don't.
     if (ini_get('zend.ze1_compatibility_mode') == 1) {
         ini_set('zend.ze1_compatibility_mode', 0);
     }
     if ($xml == null) {
         $xml = new SimpleXMLExtended("<?xml version='1.0' encoding='" . $encoding . "'?><{$rootNodeName} />");
     }
     // loop through the data passed in.
     foreach ($data as $key => $value) {
         // no numeric keys in our xml please!
         if (is_numeric($key)) {
             // make string key...
             //return;
             $key = "row";
         }
         // if there is another array or object found recrusively call this function
         if (is_array($value) || is_object($value)) {
             $node = $xml->addChild($key);
             // recrusive call.
             self::toXml($value, $rootNodeName, $node, $encoding, $cdata);
         } else {
             // add single node.
             $value = is_bool($value) ? $value ? 'true' : 'false' : $value;
             $value = htmlspecialchars($value);
             if ($cdata === true) {
                 $node = $xml->addChild($key);
                 $node->addCData($value);
             } else {
                 $xml->addChild($key, $value);
             }
         }
     }
     // pass back as string. or simple xml object if you want!
     return $xml->asXML();
 }
    $rssItem->addChild("post_password", "", $namespaces["wp"]);
    // TODO make configurable
    $rssItem->addChild("is_sticky", 0, $namespaces["wp"]);
    // TODO make configurable
    // the first tag in comments seem to be the original WordPress category
    $theFirstTag = null;
    foreach ($item["story_tags"] as $story_tag) {
        $rssCategory = $rssItem->addChild("category", null);
        $rssCategory->addCData($story_tag);
        $rssCategory->addAttribute("domain", "post_tag");
        $rssCategory->addAttribute("nicename", sluggify($story_tag));
        if (is_null($theFirstTag)) {
            $theFirstTag = $story_tag;
        }
    }
    if (is_null($theFirstTag)) {
        $theFirstTag = 'Japan';
    }
    // set default category - should be configurable
    $rssCategory = $rssItem->addChild("category", null);
    $rssCategory->addCData($theFirstTag);
    $rssCategory->addAttribute("domain", "category");
    $rssCategory->addAttribute("nicename", sluggify($theFirstTag));
}
// indent
$dom = new DOMDocument('1.0', 'utf-8');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($rss->asXML());
$formattedXml = $dom->saveXML();
file_put_contents("newsblur-exported.xml", $formattedXml);
Пример #5
0
 public static function toXml($data, $rootNodeName = 'root', $xml = null, $encoding = 'utf-8', $cdata = false)
 {
     if (ini_get('zend.ze1_compatibility_mode') == 1) {
         ini_set('zend.ze1_compatibility_mode', 0);
     }
     if ($xml == null) {
         $xml = new SimpleXMLExtended("<?xml version='1.0' encoding='" . $encoding . "'?><{$rootNodeName} />");
     }
     foreach ($data as $key => $value) {
         if (is_numeric($key)) {
             $key = "row";
         }
         if (is_array($value) || is_object($value)) {
             $node = $xml->addChild($key);
             self::toXml($value, $rootNodeName, $node, $encoding, $cdata);
         } else {
             $value = htmlspecialchars($value);
             if ($cdata === true) {
                 $node = $xml->addChild($key);
                 $node->addCData($value);
             } else {
                 $xml->addChild($key, $value);
             }
         }
     }
     return $xml->asXML();
 }
 /**
  * @brief Create the XML output of the AREL Object and send it to the junaio server.
  * @param ArelObject $oObject Object to be sent out
  */
 public static function outputObject($oObject)
 {
     $object = new SimpleXMLExtended("<object></object>");
     $object->addAttribute('id', (string) $oObject->getID());
     if ($oObject->getTitle()) {
         $object->addCData('title', $oObject->getTitle());
     }
     if ($oObject->getThumbnail()) {
         $object->addCData('thumbnail', $oObject->getThumbnail());
     }
     if ($oObject->getIcon()) {
         $object->addCData('icon', $oObject->getIcon());
     }
     //location
     if ($oObject->getLocation()) {
         $location = $object->addChild("location");
         $oLocation = $oObject->getLocation();
         try {
             $location->addChild('lat', $oLocation[0]);
             $location->addChild('lon', $oLocation[1]);
             if (isset($oLocation[2])) {
                 $location->addChild('alt', $oLocation[2]);
             } else {
                 $location->addChild('alt', 0);
             }
         } catch (Exception $e) {
             return $e;
         }
     }
     //popup
     if ($oObject->getPopup()) {
         $popup = $object->addChild("popup");
         $oPopUp = $oObject->getPopup();
         if ($oPopUp->getDescription()) {
             $popup->addCData('description', $oPopUp->getDescription());
         }
         if ($oPopUp->getButtons()) {
             $buttons = $popup->addChild("buttons");
             $aButtons = $oPopUp->getButtons();
             foreach ($aButtons as $oButton) {
                 $button = $buttons->addCData("button", $oButton[2]);
                 $button->addAttribute("id", $oButton[1]);
                 $button->addAttribute("name", $oButton[0]);
             }
         }
     }
     if ($oObject instanceof ArelObjectModel3D) {
         //assets3D
         $assets3D = $object->addChild("assets3d");
         if ($oObject->getModel()) {
             $assets3D->addCData('model', $oObject->getModel());
         }
         if ($oObject->getMovie()) {
             $assets3D->addCData('movie', $oObject->getMovie());
         }
         if ($oObject->getTexture()) {
             $assets3D->addCData('texture', $oObject->getTexture());
         }
         //transform
         $transform = $assets3D->addChild("transform");
         $oTransform = $oObject->getTransformParent();
         if (isset($oTransform)) {
             $transform->addAttribute("parent", $oTransform);
         }
         try {
             //translation
             $translation = $transform->addChild("translation");
             $oTranslation = $oObject->getTranslation();
             $translation->addChild("x", $oTranslation[0]);
             $translation->addChild("y", $oTranslation[1]);
             $translation->addChild("z", $oTranslation[2]);
             //rotation
             $rotation = $transform->addChild("rotation");
             $oRotationElement = $oObject->getRotation();
             $oRotation = $oRotationElement->getRotationValues();
             $oRotationType = $oRotationElement->getRotationType();
             $rotation->addAttribute("type", $oRotationType);
             if ($oRotationType !== ArelRotation::ROTATION_MATRIX) {
                 $rotation->addChild("x", $oRotation[0]);
                 $rotation->addChild("y", $oRotation[1]);
                 $rotation->addChild("z", $oRotation[2]);
                 if ($oRotationType == ArelRotation::ROTATION_QUATERNION) {
                     $rotation->addChild("w", $oRotation[3]);
                 } else {
                     if ($oRotationType == ArelRotation::ROTATION_AXISANGLE) {
                         $rotation->addChild("angle", $oRotation[3]);
                     }
                 }
             } else {
                 $rotation->addChild("m0", $oRotation[0]);
                 $rotation->addChild("m1", $oRotation[1]);
                 $rotation->addChild("m2", $oRotation[2]);
                 $rotation->addChild("m3", $oRotation[3]);
                 $rotation->addChild("m4", $oRotation[4]);
                 $rotation->addChild("m5", $oRotation[5]);
                 $rotation->addChild("m6", $oRotation[6]);
                 $rotation->addChild("m7", $oRotation[7]);
                 $rotation->addChild("m8", $oRotation[8]);
             }
             //scale
             $scale = $transform->addChild("scale");
             $oScale = $oObject->getScale();
             $scale->addChild("x", $oScale[0]);
             $scale->addChild("y", $oScale[1]);
             $scale->addChild("z", $oScale[2]);
         } catch (Exception $e) {
             return $e;
         }
         //properties
         $pickingEnabled = $oObject->isPickingEnabled();
         $cosID = $oObject->getCoordinateSystemID();
         $shaderMaterial = $oObject->getShaderMaterial();
         $occluding = $oObject->isOccluding();
         $transparency = $oObject->getTransparency();
         $renderPosition = $oObject->getRenderOrderPosition();
         $screenAnchor = $oObject->getScreenAnchor();
         if (isset($cosID) || isset($shaderMaterial) || isset($occluding) || isset($pickingEnabled) || isset($screenAnchor) || isset($transparency) || isset($renderPosition)) {
             $properties = $assets3D->addChild("properties");
             if (isset($cosID)) {
                 $properties->addChild("coordinatesystemid", $cosID);
             }
             if (isset($shaderMaterial)) {
                 $properties->addChild("shadermaterial", $shaderMaterial);
             }
             if ($occluding) {
                 $properties->addChild("occluding", "true");
             }
             if (isset($transparency) && $transparency > 0) {
                 $properties->addChild("transparency", $oObject->getTransparency());
             }
             if (isset($pickingEnabled) && !$pickingEnabled) {
                 $properties->addChild("pickingenabled", "false");
             }
             if (isset($renderPosition)) {
                 $properties->addChild("renderorder", $oObject->getRenderOrderPosition());
             }
             if (isset($screenAnchor)) {
                 $screenAnchorProperty = $properties->addChild("screenanchor", $oObject->getScreenAnchor());
                 if ($oObject->getScreenAnchorFlag() != NULL) {
                     $screenAnchorProperty->addAttribute("flags", $oObject->getScreenAnchorFlag(), null);
                 }
             }
         }
     }
     //viewparameters
     if ($oObject->getVisibility() || $oObject->getMinAccuracy() || $oObject->getMinDistance() || $oObject->getMaxDistance()) {
         $viewparameter = $object->addChild("viewparameters");
         if ($oObject->getVisibility()) {
             $visibility = $viewparameter->addChild("visibility");
             $oVisibility = $oObject->getVisibility();
             if (isset($oVisibility["liveview"]) && !$oVisibility["liveview"]) {
                 $visibility->addChild("liveview", "false");
             }
             if (isset($oVisibility["maplist"]) && !$oVisibility["maplist"]) {
                 $visibility->addChild("maplist", "false");
             }
             if (isset($oVisibility["radar"]) && !$oVisibility["radar"]) {
                 $visibility->addChild("radar", "false");
             }
             //alternatively for 0,1,2
             if (isset($oVisibility[0]) && !$oVisibility[0]) {
                 $visibility->addChild("liveview", "false");
             }
             if (isset($oVisibility[1]) && !$oVisibility[1]) {
                 $visibility->addChild("maplist", "false");
             }
             if (isset($oVisibility[2]) && !$oVisibility[2]) {
                 $visibility->addChild("radar", "false");
             }
         }
         if ($oObject->getMinAccuracy()) {
             $viewparameter->addChild("minaccuracy", $oObject->getMinAccuracy());
         }
         if ($oObject->getMinDistance()) {
             $viewparameter->addChild("mindistance", $oObject->getMinDistance());
         }
         if ($oObject->getMaxDistance()) {
             $viewparameter->addChild("maxdistance", $oObject->getMaxDistance());
         }
     }
     //parameters
     if ($oObject->getParameters()) {
         $parameters = $object->addChild("parameters");
         foreach ($oObject->getParameters() as $key => $parValue) {
             $parameter = $parameters->addCData("parameter", $parValue);
             $parameter->addAttribute("key", $key);
         }
     }
     $out = $object->asXML();
     $pos = strpos($out, "?>");
     echo utf8_encode(trim(substr($out, $pos + 2)));
     ob_flush();
 }
Пример #7
0
                $desc = $row['description'];
                $distance = $row['distance'];
                $item_title = $category . ", " . $price . " " . $currency . ", " . $city_name;
                if ($distance != "") {
                    $item_title .= ", " . $distance . " км от Йошкар-Олы";
                }
                if ($is_owner != "") {
                    $item_title .= ", " . $owner_term;
                }
                $item_description = '<![CDATA[';
                if ($photo_name != "") {
                    $item_description .= '<img src="' . $url_photo . '/' . $kind_id_house . '/' . $property_id . '/' . $photo_name . '" style="float: left"/>';
                }
                $item_description .= '&lt;p&gt;' . $desc . '&lt;/p&gt;';
                $item_description .= ']]>';
                # запись в xml переменную
                $offer_ = $xml->addChild('item');
                $offer_->addChild('title', $item_title);
                $offer_->link = $url_land;
                $offer_->addChild('description', $item_description);
                $offer_->addChild('pubDate', $updated_date);
            }
            $previous_id = $property_id;
        }
        mysql_free_result($result);
        #сохраняем в xml файл
        //$rss->asXML('rss1.xml');
    }
    echo $rss->asXML();
    mysql_close;
}
Пример #8
0
 function backup()
 {
     $settings = Plugin::getAllSettings('backup_restore');
     // All of the tablesnames that belong to Fresh CMS core.
     $tablenames = array('layout', 'page', 'page_part', 'page_tag', 'permission', 'plugin_settings', 'setting', 'snippet', 'tag', 'user', 'user_permission');
     // All fields that should be wrapped as CDATA
     $cdata_fields = array('content', 'content_html');
     // Setup XML for backup
     $xmltext = '<?xml version="1.0" encoding="UTF-8"?><freshcms></freshcms>';
     $xmlobj = new SimpleXMLExtended($xmltext);
     $xmlobj->addAttribute('version', CMS_VERSION);
     // Retrieve all database information for placement in XML backup
     global $__CMS_CONN__;
     Record::connection($__CMS_CONN__);
     $lasttable = '';
     // Generate XML file entry for each table
     foreach ($tablenames as $tablename) {
         $table = Record::query('SELECT * FROM ' . TABLE_PREFIX . $tablename);
         while ($entry = $table->fetchObject()) {
             if ($lasttable !== $tablename) {
                 $lasttable = $tablename;
                 $child = $xmlobj->addChild($tablename . 's');
             }
             $subchild = $child->addChild($tablename);
             while (list($key, $value) = each($entry)) {
                 if ($key === 'password' && $settings['pwd'] === '0') {
                     $value = '';
                 }
                 if (in_array($key, $cdata_fields, true)) {
                     $subchild->addCData($key, $value);
                 } else {
                     $subchild->addChild($key, $value);
                 }
             }
         }
     }
     // Create the XML file
     $file = $xmlobj->asXML();
     $filename = 'freshcms-backup-' . date($settings['stamp']);
     // Offer a plain XML file or a zip file for download
     if ($settings['zip'] == '1') {
         // Create a note file
         $note = "---[ NOTES for {$filename}.xml ]---\n\n";
         $note .= "This backup was created for a specific Fresh CMS version, please only restore it\n";
         $note .= "on the same version.\n\n";
         $note .= "When restoring a backup, upload the UNzipped XML file, not this zip file.\n\n";
         $note .= 'Created on ' . date('Y-m-d') . ' at ' . date('H:i:s') . ' GTM ' . date('O') . ".\n";
         $note .= 'Created with BackupRestore plugin version ' . BR_VERSION . "\n";
         $note .= 'Created for Fresh CMS version ' . CMS_VERSION . "\n\n";
         $note .= '---[ END NOTES ]---';
         use_helper('Zip');
         $zip = new Zip();
         $zip->clear();
         $zip->addFile($note, 'readme.txt');
         $zip->addFile($file, $filename . '.xml');
         $zip->download($filename . '.zip');
     } else {
         header('Pragma: public');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Cache-Control: private', false);
         header('Content-Type: text/xml; charset=UTF-8');
         header('Content-Disposition: attachment; filename=' . $filename . '.xml;');
         header('Content-Transfer-Encoding: 8bit');
         header('Content-Length: ' . strlen($file));
         echo $file;
     }
 }
Пример #9
0
    public function generateXmlFlow()
    {
        global $cart, $cookie;
        $cookie->id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
        // url rewriting case
        $cart = new Cart();
        $link = new Link();
        $defaultCurrencyIsoCode = strtoupper(Db::getInstance()->getValue('SELECT c.iso_code FROM ' . _DB_PREFIX_ . 'currency c WHERE c.id_currency = ' . (int) Configuration::get('PS_CURRENCY_DEFAULT')));
        $defaultIdLang = (int) Configuration::get('PS_LANG_DEFAULT');
        $sqlLangs = Db::getInstance()->ExecuteS('SELECT l.id_lang, l.iso_code FROM ' . _DB_PREFIX_ . 'lang l');
        foreach ($sqlLangs as $sqlLang) {
            $langs[$sqlLang['id_lang']] = $sqlLang['iso_code'];
        }
        $xmlString = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<products>
</products>
XML;
        $products = new SimpleXMLExtended($xmlString);
        $infos = $products->addChild('infos');
        $infos->addCData('url', $this->_getShopURL());
        $infos->addCData('logo', $this->_getShopURL());
        $languages = Db::getInstance()->ExecuteS('
		SELECT l.iso_code
		FROM ' . _DB_PREFIX_ . 'lang l
		WHERE l.active = 1');
        foreach ($languages as $language) {
            $infos->addChild('lang', $language['iso_code']);
        }
        $limit_sql = '';
        $limit_start = (int) Tools::getValue('limit_start');
        $limit_end = (int) Tools::getValue('limit_end');
        if ($limit_start > 0) {
            if ($limit_end < $limit_start) {
                $limit_end = $limit_start + 10;
            }
            $limit_sql = ' LIMIT ' . (int) $limit_start . ',' . (int) $limit_end;
        }
        $sqlProducts = Db::getInstance()->ExecuteS('
		SELECT p.id_product, p.reference, p.weight, m.name manufacturer, s.name supplier, p.on_sale, p.id_manufacturer, pd.id_product_download
		FROM ' . _DB_PREFIX_ . 'product p
		LEFT JOIN ' . _DB_PREFIX_ . 'manufacturer m ON (m.id_manufacturer = p.id_manufacturer)
		LEFT JOIN ' . _DB_PREFIX_ . 'supplier s ON (s.id_supplier = p.id_supplier)
		LEFT JOIN ' . _DB_PREFIX_ . 'product_download pd ON (pd.id_product = p.id_product)
		WHERE p.active = 1' . $limit_sql);
        foreach ($sqlProducts as $sqlProduct) {
            $id_product = $sqlProduct['id_product'];
            $product = $products->addChild('product');
            $product->addChild('sku', (int) $sqlProduct['id_product']);
            $product->addCData('manufacturer', $sqlProduct['manufacturer']);
            if (file_exists(dirname(__FILE__) . '/../../img/m/' . (int) $sqlProduct['id_manufacturer'] . 'jpg')) {
                $product->addCData('manufacturer-logo', $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'img/m/' . (int) $sqlProduct['id_manufacturer'] . 'jpg');
            }
            $product->addChild('weight', (double) $sqlProduct['weight']);
            $product->addChild('weight_unit', strtolower(Configuration::get('PS_WEIGHT_UNIT')));
            $product->addCData('supplier', $sqlProduct['supplier']);
            $name = $product->addChild('name');
            $languageVariant = $name->addChild('language-variant');
            $texts = Db::getInstance()->ExecuteS('
			SELECT pl.name, pl.description_short, pl.link_rewrite, l.iso_code, l.id_lang
			FROM ' . _DB_PREFIX_ . 'product_lang pl
			LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (l.id_lang = pl.id_lang)
			WHERE pl.id_product = ' . (int) $sqlProduct['id_product']);
            foreach ($texts as $text) {
                $variant = $languageVariant->addChild('variant');
                $variant->addChild('locale', $text['iso_code']);
                $variant->addCData('value', $text['name']);
                if ($text['id_lang'] == $defaultIdLang) {
                    $productName = $text['name'];
                    $productLinkRewrite = $text['link_rewrite'];
                }
            }
            $product->addCData('page-url', $link->getProductLink((int) $sqlProduct['id_product'], $productLinkRewrite));
            $shortDescription = $product->addChild('short-description');
            $languageVariant = $shortDescription->addChild('language-variant');
            foreach ($texts as $text) {
                $variant = $languageVariant->addChild('variant');
                $variant->addChild('locale', $text['iso_code']);
                $variant->addCData('value', Tools::htmlentitiesDecodeUTF8(strip_tags($text['description_short'])));
            }
            $accessories = Db::getInstance()->ExecuteS('
			SELECT a.id_product_2
			FROM ' . _DB_PREFIX_ . 'accessory a
			WHERE a.id_product_1 = ' . (int) $sqlProduct['id_product']);
            foreach ($accessories as $accessory) {
                $product->addChild('accessory-sku', (int) $accessory['id_product_2']);
            }
            $price = $product->addChild('price');
            $price->addChild('currency', $defaultCurrencyIsoCode);
            $price->addChild('retail-price-with-tax', Product::getPriceStatic((int) $sqlProduct['id_product'], true, NULL, 6, NULL, false, false));
            $price->addChild('retail-price-without-tax', Product::getPriceStatic((int) $sqlProduct['id_product'], false, NULL, 6, NULL, false, false));
            $price->addChild('final-retail-price-with-tax', Product::getPriceStatic((int) $sqlProduct['id_product'], true));
            if (version_compare(_PS_VERSION_, '1.4') < 0) {
                $price->addChild('final-retail-price-without-tax', Product::getPriceStatic(intval($sqlProduct['id_product']), false));
                $price->addChild('reduction_percent', floatval($sqlProduct['reduction_percent']));
                $price->addChild('reduction_price', floatval($sqlProduct['reduction_price']));
            } else {
                $price->addChild('final-retail-price-without-tax', Product::getPriceStatic((int) $sqlProduct['id_product'], false, NULL, 6, NULL, false, true, 1, false, NULL, NULL, NULL, $specificPrice));
                $price->addChild('reduction_percent', ($specificPrice and $specificPrice['reduction_type'] == 'percentage') ? $specificPrice['reduction'] * 100 : 0.0);
                $price->addChild('reduction_price', ($specificPrice and $specificPrice['reduction_type'] == 'amount') ? (double) $specificPrice['reduction'] : 0.0);
            }
            $price->addChild('display-on-sale', (int) $sqlProduct['on_sale']);
            $product->addChild('downloadable', $sqlProduct['id_product_download'] >= 1 ? 1 : 0);
            $pack = Db::getInstance()->ExecuteS('
			SELECT p.id_product, pp.quantity
			FROM ' . _DB_PREFIX_ . 'pack pp
			LEFT JOIN ' . _DB_PREFIX_ . 'product p ON (p.id_product = pp.id_product_item)
			WHERE pp.id_product_pack = ' . (int) $sqlProduct['id_product']);
            if (sizeof($pack)) {
                $pack = $product->addChild('pack');
                foreach ($pack as $p) {
                    $packItem = $pack->addChild('pack-item');
                    $packItem->addChild('quantity', (int) $p['quantity']);
                    $packItem->addChild('sku', (int) $p['id_product']);
                }
            }
            $images = Db::getInstance()->ExecuteS('
			SELECT i.id_image, il.legend, l.iso_code
			FROM ' . _DB_PREFIX_ . 'image i
			LEFT JOIN ' . _DB_PREFIX_ . 'image_lang il ON (il.id_image = i.id_image)
			LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (l.id_lang = il.id_lang)
			WHERE i.id_product = ' . (int) $sqlProduct['id_product']);
            $imagesLegends = array();
            foreach ($images as $image) {
                $imagesLegends[(int) $image['id_image']][$image['iso_code']]['legend'] = $image['legend'];
                $imagesLegends[(int) $image['id_image']][$image['iso_code']]['iso_code'] = $image['iso_code'];
            }
            $imagesAlreadyDone = array();
            foreach ($images as $imageSQL) {
                if (isset($imagesAlreadyDone[$imageSQL['id_image']])) {
                    continue;
                }
                $imagesAlreadyDone[(int) $imageSQL['id_image']] = 1;
                $image = $product->addChild('image');
                $image->addAttribute('id', $imageSQL['id_image']);
                $image->addCData('image-url', $link->getImageLink($productLinkRewrite, (int) $sqlProduct['id_product'] . '-' . (int) $imageSQL['id_image'], 'large'));
                if (isset($imagesLegends[$imageSQL['id_image']]) and sizeof($imagesLegends[$imageSQL['id_image']])) {
                    $imageCaption = $image->addChild('image-caption');
                    $languageVariant = $imageCaption->addChild('language-variant');
                    foreach ($imagesLegends[(int) $imageSQL['id_image']] as $legend) {
                        $variant = $languageVariant->addChild('variant');
                        $variant->addChild('locale', $legend['iso_code']);
                        $variant->addCData('value', $legend['legend']);
                    }
                }
            }
            if (version_compare(_PS_VERSION_, '1.4') < 0) {
                $quantityDiscounts = Db::getInstance()->ExecuteS('
				SELECT dq.quantity, dq.value, dq.id_discount_type
				FROM ' . _DB_PREFIX_ . 'discount_quantity dq
				WHERE dq.id_product = ' . intval($sqlProduct['id_product']));
                foreach ($quantityDiscounts as $quantityDiscount) {
                    $discount = $product->addChild('discount');
                    $discount->addChild('discount-quantity', intval($quantityDiscount['quantity']));
                    $discount->addChild('discount-value', floatval($quantityDiscount['value']));
                    $discount->addChild('discount-type', $quantityDiscount['id_discount_type'] == 1 ? $defaultCurrencyIsoCode : '%');
                }
            } else {
                $quantityDiscounts = SpecificPrice::getQuantityDiscounts((int) $sqlProduct['id_product'], (int) Shop::getCurrentShop(), 0, 0, 0);
                foreach ($quantityDiscounts as $quantityDiscount) {
                    $discount = $product->addChild('discount');
                    $discount->addChild('discount-quantity', (int) $quantityDiscount['from_quantity']);
                    $discount->addChild('discount-value', ((double) $quantityDiscount['price'] and $quantityDiscount['reduction_type'] == 'amount') ? (double) $quantityDiscount['price'] : $quantityDiscount['reduction'] * 100);
                    $discount->addChild('discount-type', $quantityDiscount['reduction_type'] == 'amount' ? $defaultCurrencyIsoCode : '%');
                }
            }
            $categories = Db::getInstance()->ExecuteS('
			SELECT cl.name, l.iso_code
			FROM ' . _DB_PREFIX_ . 'category_product cp
			LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = cp.id_category)
			LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (l.id_lang = cl.id_lang)
			WHERE cp.id_product = ' . (int) $sqlProduct['id_product']);
            if (sizeof($categories)) {
                $category = $product->addChild('category');
                $languageVariant = $category->addChild('language-variant');
                foreach ($categories as $category) {
                    $variant = $languageVariant->addChild('variant');
                    $variant->addChild('locale', $category['iso_code']);
                    $variant->addCData('value', $category['name']);
                }
            }
            $tags = Db::getInstance()->ExecuteS('
			SELECT pt.id_product, pt.id_tag, l.iso_code, t.name
			FROM ' . _DB_PREFIX_ . 'product_tag pt
			LEFT JOIN ' . _DB_PREFIX_ . 'tag t ON (t.id_tag = pt.id_tag)
			LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (l.id_lang = t.id_lang)
			WHERE pt.id_product = ' . (int) $sqlProduct['id_product']);
            if (!empty($tags) && sizeof($tags) > 0) {
                $tagsTexts = array();
                $tagsIso = array();
                foreach ($tags as $tag) {
                    if (!in_array($tag['iso_code'], $tagsIso)) {
                        $tagsIso[] = $tag['iso_code'];
                    }
                    $tagsTexts[$tag['iso_code']][] = $tag['name'];
                }
                $tags_item = $product->addChild('tags');
                foreach ($tagsIso as $iso) {
                    $languageVariant = $tags_item->addChild('language-variant');
                    $languageVariant->addChild('locale', $iso);
                    $languageVariant->addCData('value', implode(',', $tagsTexts[$iso]));
                }
            }
            $groupAttributes = Db::getInstance()->ExecuteS('
			SELECT DISTINCT agl.id_attribute_group, agl.name, l.iso_code, a.id_attribute, al.name as attribute_name, al.id_lang, pa.id_product_attribute
			FROM ' . _DB_PREFIX_ . 'attribute_group_lang agl
			LEFT JOIN ' . _DB_PREFIX_ . 'attribute a ON (a.id_attribute_group = agl.id_attribute_group)
			LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang al ON (al.id_attribute = a.id_attribute)
			LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (l.id_lang = al.id_lang)
			LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON (pac.id_attribute = a.id_attribute)
			LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute pa ON (pa.id_product_attribute = pac.id_product_attribute)
			WHERE pa.id_product = ' . (int) $sqlProduct['id_product'] . '
			GROUP BY a.id_attribute, l.iso_code');
            $groups = array();
            foreach ($groupAttributes as $groupAttribute) {
                $id_group_attribute = $groupAttribute['id_attribute_group'];
                $id_attribute = $groupAttribute['id_attribute'];
                $id_product_attribute = $groupAttribute['id_product_attribute'];
                $groups[$id_group_attribute]['name'][$groupAttribute['iso_code']] = $groupAttribute['name'];
                $groups[$id_group_attribute]['attributes'][$groupAttribute['id_attribute']][$groupAttribute['iso_code']] = $groupAttribute['attribute_name'];
            }
            if (!empty($groups)) {
                foreach ($groups as $id_group => $group) {
                    $xml_group = $product->addChild('attribute-group');
                    $xml_group->addAttribute('id', $id_group);
                    if (!empty($group['name'])) {
                        $nameGroup = $xml_group->addChild('name');
                        $languageVariant = $nameGroup->addChild('language-variant');
                        foreach ($group['name'] as $iso2 => $name_group) {
                            $variant = $languageVariant->addChild('variant');
                            $variant->addChild('locale', $iso2);
                            $variant->addCData('value', $name_group);
                        }
                    }
                    if (!empty($group['attributes'])) {
                        foreach ($group['attributes'] as $id_attribute => $attribute) {
                            $xml_attribute = $xml_group->addChild('attribute');
                            $xml_attribute->addAttribute('id', $id_attribute);
                            $languageVariant = $xml_attribute->addChild('language-variant');
                            foreach ($attribute as $iso2 => $name_attribute) {
                                $variant = $languageVariant->addChild('variant');
                                $variant->addChild('locale', $iso2);
                                $variant->addCData('value', $name_attribute);
                            }
                        }
                    }
                }
            }
            $groupAttributes = Db::getInstance()->ExecuteS('
			SELECT agl.id_attribute_group, agl.name, l.iso_code, a.id_attribute, al.name attribute_name, al.id_lang, pa.id_product_attribute
			FROM ' . _DB_PREFIX_ . 'attribute_group_lang agl
			LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (l.id_lang = agl.id_lang)
			LEFT JOIN ' . _DB_PREFIX_ . 'attribute a ON (a.id_attribute_group = agl.id_attribute_group)
			LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang al ON (al.id_attribute = a.id_attribute)
			LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON (pac.id_attribute = a.id_attribute)
			LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute pa ON (pa.id_product_attribute = pac.id_product_attribute)
			WHERE pa.id_product = ' . (int) $sqlProduct['id_product']);
            $combinaison = array();
            foreach ($groupAttributes as $groupAttribute) {
                $id_group_attribute = $groupAttribute['id_attribute_group'];
                $id_attribute = $groupAttribute['id_attribute'];
                $id_product_attribute = $groupAttribute['id_product_attribute'];
                $combinaison[$id_product_attribute][$id_group_attribute] = $id_attribute;
            }
            $productAttributes = Db::getInstance()->ExecuteS('
			SELECT pa.id_product_attribute, pa.weight, pa.quantity, pi.id_image
			FROM ' . _DB_PREFIX_ . 'product_attribute pa
			LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute_image pi ON (pa.id_product_attribute = pi.id_product_attribute)
			WHERE pa.id_product = ' . (int) $sqlProduct['id_product']);
            if (!empty($productAttributes)) {
                foreach ($productAttributes as $productAttribute) {
                    $id_product_attribute = (int) $productAttribute['id_product_attribute'];
                    $attributeCombination = $product->addChild('attribute-combination');
                    $attributeCombination->addAttribute('id', $id_product_attribute);
                    $attributeCombination->addChild('weight', (double) ($sqlProduct['weight'] + $productAttribute['weight']));
                    $attributeCombination->addChild('final-retail-price-with-tax', Product::getPriceStatic((int) $sqlProduct['id_product'], true, $id_product_attribute));
                    $attributeCombination->addChild('final-retail-price-without-tax', Product::getPriceStatic((int) $sqlProduct['id_product'], false, $id_product_attribute));
                    $attributeCombination->addChild('quantity', $productAttribute['quantity']);
                    if (isset($productAttribute['id_image']) && !empty($productAttribute['id_image'])) {
                        $image = $attributeCombination->addChild('image');
                        $image->addAttribute('ref-id', $productAttribute['id_image']);
                    }
                    if (isset($combinaison[$id_product_attribute]) && !empty($combinaison[$id_product_attribute])) {
                        foreach ($combinaison[$id_product_attribute] as $id_group_attribute => $id_attribute) {
                            $attribute = $attributeCombination->addChild('attribute');
                            $attribute->addAttribute('group-ref-id', $id_group_attribute);
                            $attribute->addAttribute('ref-id', $id_attribute);
                        }
                    }
                }
            }
        }
        echo $products->asXML();
    }
Пример #10
0
                        $forumThreadXML->addChild('author_name', $forum_thread['author_name']);
                        $forum_posts = $bot->forum->get_all_forum_posts($forum_id, $thread_id);
                        if (is_array($forum_posts)) {
                            foreach ($forum_posts as $post_id => $forum_post) {
                                $forumPostXML = $forumThreadXML->addChild('post');
                                $forumPostXML->addCData($forum_post['message']);
                                $forumPostXML->addAttribute('id', $forum_post['post_id']);
                                $forumPostXML->addAttribute('author_id', $forum_post['author_id']);
                                $forumPostXML->addAttribute('author_name', $forum_post['author_name']);
                                $forumPostXML->addAttribute('last_change', $forum_post['last_change']);
                            }
                        }
                    }
                }
                $fh = fopen($file_forum, 'w');
                fwrite($fh, $forumXML->asXML());
                fclose($fh);
            }
        }
        $bot->add_privmsg("Forum backup done!", $data['user']);
    } else {
        $bot->add_privmsg("Ne Ne Ne!", $data['user']);
    }
}, 'operator');
// special functions
if (!function_exists('sanitize_title_with_dashes')) {
    function sanitize_title_with_dashes($title)
    {
        $title = strip_tags($title);
        // Preserve escaped octets.
        $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);
Пример #11
0
foreach ($order->get_items() as $item_id => $item) {
    $liquid = $liquids->addChild('liquid');
    $li_name = $liquid->name = NULL;
    $li_name = $liquid->name->addCData($item['name']);
    $li_id = $liquid->addChild('id', $item_id);
    $li_amount = $liquid->addChild('amount', $item[qty]);
}
//Create the XML file
$fp = fopen("C:/wamp/www/wp/orders/order" . $order_id . ".xml", "wb");
if (!$fp) {
    echo 'can not create xml';
} else {
    echo 'xml created';
}
//Write the XML nodes
fwrite($fp, $xml->asXML());
//Close the database connection
fclose($fp);
?>
<h2><?php 
_e('Order Details', 'woocommerce');
?>
</h2>
<table class="shop_table order_details">
	<thead>
		<tr>
			<th class="product-name"><?php 
_e('Product', 'woocommerce');
?>
</th>
			<th class="product-total"><?php 
 public function executeGetParlamentoIdParlamentariInCarica()
 {
     $ramo = $this->getRequestParameter('ramo');
     $resp_node = new SimpleXMLExtended('<opp xmlns="' . $this->opp_ns . '" ' . ' xmlns:opp="' . $this->op_ns . '" ' . ' xmlns:xlink="' . $this->xlink_ns . '" >' . '</opp>');
     // start producing xml
     $content_node = $resp_node->addChild('opp:content', null, $this->op_ns);
     $c = new Criteria();
     if ($ramo == 'C') {
         $arr_tipo_id = array(1);
     } else {
         $arr_tipo_id = array(4, 5);
     }
     $c->add(OppCaricaPeer::TIPO_CARICA_ID, $arr_tipo_id, Criteria::IN);
     $c->add(OppCaricaPeer::DATA_FINE, NULL, Criteria::ISNULL);
     $parlamentari = OppCaricaPeer::doSelect($c);
     foreach ($parlamentari as $p) {
         $p_node = $content_node->addChild('parlamentare', $p->getId());
         $p_node->addAttribute('parlamento_id', $p->getParliamentId());
     }
     $xmlContent = $resp_node->asXML();
     $this->_send_output($xmlContent);
     return sfView::NONE;
 }
Пример #13
0
 function backup()
 {
     $settings = Plugin::getAllSettings('backup_restore');
     // All of the tablesnames that belong to Wolf CMS core.
     $tablenames = array();
     if (strpos(DB_DSN, 'mysql') !== false) {
         $sql = 'show tables';
     }
     if (strpos(DB_DSN, 'sqlite') !== false) {
         $sql = 'SELECT name FROM SQLITE_MASTER WHERE type="table" ORDER BY name';
     }
     if (strpos(DB_DSN, 'pgsql') !== false) {
         $sql = "select tablename from pg_tables where schemaname='public'";
     }
     Record::logQuery($sql);
     $pdo = Record::getConnection();
     $result = $pdo->query($sql);
     while ($col = $result->fetchColumn()) {
         $tablenames[] = $col;
     }
     // All fields that should be wrapped as CDATA
     $cdata_fields = array('title', 'content', 'content_html');
     // Setup XML for backup
     $xmltext = '<?xml version="1.0" encoding="UTF-8"?><wolfcms></wolfcms>';
     $xmlobj = new SimpleXMLExtended($xmltext);
     $xmlobj->addAttribute('version', CMS_VERSION);
     // Retrieve all database information for placement in XML backup
     global $__CMS_CONN__;
     Record::connection($__CMS_CONN__);
     // Generate XML file entry for each table
     foreach ($tablenames as $tablename) {
         $table = Record::query('SELECT * FROM ' . $tablename);
         $child = $xmlobj->addChild($tablename . 's');
         while ($entry = $table->fetch(PDO::FETCH_ASSOC)) {
             $subchild = $child->addChild($tablename);
             foreach ($entry as $key => $value) {
                 if ($key == 'password' && $settings['pwd'] === '0') {
                     $value = '';
                 }
                 if (in_array($key, $cdata_fields, true)) {
                     $valueChild = $subchild->addCData($key, $value);
                 } else {
                     $valueChild = $subchild->addChild($key, str_replace('&', '&amp;', $value));
                 }
                 if ($value === null) {
                     $valueChild->addAttribute('null', true);
                 }
             }
         }
     }
     // Add XML files entries for all files in upload directory
     if ($settings['backupfiles'] == '1') {
         $dir = realpath(FILES_DIR);
         $this->_backup_directory($xmlobj->addChild('files'), $dir, $dir);
     }
     // Create the XML file
     $file = $xmlobj->asXML();
     $filename = 'wolfcms-backup-' . date($settings['stamp']) . '.' . $settings['extension'];
     // Offer a plain XML file or a zip file for download
     if ($settings['zip'] == '1') {
         // Create a note file
         $note = "---[ NOTES for {$filename} ]---\n\n";
         $note .= "This backup was created for a specific Wolf CMS version, please only restore it\n";
         $note .= "on the same version.\n\n";
         $note .= "When restoring a backup, upload the UNzipped XML backup file, not this zip file.\n\n";
         $note .= 'Created on ' . date('Y-m-d') . ' at ' . date('H:i:s') . ' GTM ' . date('O') . ".\n";
         $note .= 'Created with BackupRestore plugin version ' . BR_VERSION . "\n";
         $note .= 'Created for Wolf CMS version ' . CMS_VERSION . "\n\n";
         $note .= '---[ END NOTES ]---';
         use_helper('Zip');
         $zip = new Zip();
         $zip->clear();
         $zip->addFile($note, 'readme.txt');
         $zip->addFile($file, $filename);
         $zip->download($filename . '.zip');
     } else {
         header('Pragma: public');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Cache-Control: private', false);
         header('Content-Type: text/xml; charset=UTF-8');
         header('Content-Disposition: attachment; filename=' . $filename . ';');
         header('Content-Transfer-Encoding: 8bit');
         header('Content-Length: ' . strlen($file));
         echo $file;
     }
 }
Пример #14
0
 public function export_category()
 {
     $id = $this->session->userdata('admin_id');
     $cates = $this->catenews_model->list_all_byuser($id);
     $xml = new SimpleXMLExtended("<root></root>");
     foreach ($cates as $cate) {
         $xml_post = $xml->addChild('category');
         $xml_post->addChild('cat_id', $cate->id);
         $content = $xml_post->addChild('cat_name');
         $content->addCData($cate->catenewsname);
     }
     $dom = new DOMDocument("1.0");
     $dom->preserveWhiteSpace = false;
     $dom->formatOutput = true;
     $dom->loadXML($xml->asXML());
     $xml->asXML('export/' . $id . '/category.xml');
 }
Пример #15
0
 function Export()
 {
     // Create root element
     $root = new SimpleXMLExtended('<shortcode-exec-php></shortcode-exec-php>');
     // Add each shortcode
     $name = WPShortcodeExecPHP::Get_option(c_scep_option_names);
     for ($i = 0; $i < count($name); $i++) {
         // Get attributes
         $enabled = WPShortcodeExecPHP::Get_option(c_scep_option_enabled . $name[$i]);
         $buffer = WPShortcodeExecPHP::Get_option(c_scep_option_buffer . $name[$i]);
         $description = WPShortcodeExecPHP::Get_option(c_scep_option_description . $name[$i]);
         $code = WPShortcodeExecPHP::Get_option(c_scep_option_phpcode . $name[$i]);
         // Create element for shortcode
         $element = $root->addChild('shortcode');
         $element->addAttribute('name', $name[$i]);
         $element->addAttribute('enabled', $enabled ? 'true' : 'false');
         $element->addAttribute('buffer', $buffer ? 'true' : 'false');
         $element->addAttribute('description', $description);
         $element->addCData($code);
     }
     // Output
     header('Content-type: text/xml');
     header('Content-Disposition: attachment; filename="shortcode-exec-php.xml"');
     echo $root->asXML();
 }
        /**
         * Verify a successful Payment!
         * */
        function check_nbg_response()
        {
            global $woocommerce;
            global $wpdb;
            if (isset($_GET['nbg']) && $_GET['nbg'] === 'success') {
                $merchantreference = $_GET['MerchantReference'];
                //query DB
                $ttquery = 'SELECT *
				FROM `' . $wpdb->prefix . 'nbg_transactions`
				WHERE `merchantreference` like "' . $merchantreference . '"	;';
                $ref = $wpdb->get_results($ttquery);
                $orderid = $ref['0']->orderid;
                $xml = new SimpleXMLExtended('<?xml version="1.0" encoding="utf-8"?><Request version="2"/>');
                $authentication = $xml->addChild('Authentication');
                $authentication->addChild('password', $this->nbg_Password);
                $authentication->addChild('client', $this->nbg_Username);
                $transaction = $xml->addChild('Transaction');
                $HistoricTxn = $transaction->addChild('HistoricTxn');
                $HistoricTxn->addChild('reference', $ref['0']->reference);
                $HistoricTxn->addChild('method', 'query');
                if ($this->mode == "yes") {
                    //test mode
                    $post_url = 'https://accreditation.datacash.com/Transaction/acq_a';
                } else {
                    //live mode
                    $post_url = 'https://mars.transaction.datacash.com/Transaction';
                }
                // make CURL request
                $ch = curl_init($post_url);
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $xml->asXML());
                curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_NOPROGRESS, 0);
                $result = curl_exec($ch);
                // result will contain XML reply
                curl_close($ch);
                if ($result == false) {
                    return __('Could not connect to NBG server, please contact the administrator ', 'woocommerce-nbg-payment-gateway');
                }
                //Response
                $response = simplexml_load_string($result);
                $order = new WC_Order($orderid);
                if ($response->status == 1) {
                    if (strcmp($response->reason, 'ACCEPTED') == 0) {
                        //verified - successful payment
                        //complete order
                        if ($order->status == 'processing') {
                            $order->add_order_note(__('Payment Via NBG<br />Transaction ID: ', 'woocommerce-nbg-payment-gateway') . $trans_id);
                            //Add customer order note
                            $order->add_order_note(__('Payment Received.<br />Your order is currently being processed.<br />We will be shipping your order to you soon.<br />NBG Transaction ID: ', 'woocommerce-nbg-payment-gateway') . $trans_id, 1);
                            // Reduce stock levels
                            $order->reduce_order_stock();
                            // Empty cart
                            WC()->cart->empty_cart();
                            $message = __('Thank you for shopping with us.<br />Your transaction was successful, payment was received.<br />Your order is currently being processed.', 'woocommerce-nbg-payment-gateway');
                            $message_type = 'success';
                        } else {
                            if ($order->has_downloadable_item()) {
                                //Update order status
                                $order->update_status('completed', __('Payment received, your order is now complete.', 'woocommerce-nbg-payment-gateway'));
                                //Add admin order note
                                $order->add_order_note(__('Payment Via NBG Payment Gateway<br />Transaction ID: ', 'woocommerce-nbg-payment-gateway') . $trans_id);
                                //Add customer order note
                                $order->add_order_note(__('Payment Received.<br />Your order is now complete.<br />NBG Transaction ID: ', 'woocommerce-nbg-payment-gateway') . $trans_id, 1);
                                $message = __('Thank you for shopping with us.<br />Your transaction was successful, payment was received.<br />Your order is now complete.', 'woocommerce-nbg-payment-gateway');
                                $message_type = 'success';
                            } else {
                                //Update order status
                                $order->update_status('processing', __('Payment received, your order is currently being processed.', 'woocommerce-nbg-payment-gateway'));
                                //Add admin order note
                                $order->add_order_note(__('Payment Via NBG Payment Gateway<br />Transaction ID: ', 'woocommerce-nbg-payment-gateway') . $trans_id);
                                //Add customer order note
                                $order->add_order_note(__('Payment Received.<br />Your order is currently being processed.<br />We will be shipping your order to you soon.<br />NBG Transaction ID: ', 'woocommerce-nbg-payment-gateway') . $trans_id, 1);
                                $message = __('Thank you for shopping with us.<br />Your transaction was successful, payment was received.<br />Your order is currently being processed.', 'woocommerce-nbg-payment-gateway');
                                $message_type = 'success';
                            }
                            $nbg_message = array('message' => $message, 'message_type' => $message_type);
                            update_post_meta($order_id, '_nbg_message', $nbg_message);
                            // Reduce stock levels
                            $order->reduce_order_stock();
                            // Empty cart
                            WC()->cart->empty_cart();
                        }
                    } else {
                        //payment has failed - retry
                        $message = __('Thank you for shopping with us. <br />However, the transaction wasn\'t successful, payment wasn\'t received.', 'woocommerce-nbg-payment-gateway');
                        $message_type = 'error';
                        $nbg_message = array('message' => $message, 'message_type' => $message_type);
                        update_post_meta($order_id, '_nbg_message', $pb_message);
                        //Update the order status
                        $order->update_status('failed', '');
                        $checkout_url = $woocommerce->cart->get_checkout_url();
                        wp_redirect($checkout_url);
                        exit;
                    }
                } else {
                    //an error occurred
                    $message = __('Thank you for shopping with us. <br />However, an error occurred and the transaction wasn\'t successful, payment wasn\'t received.', 'woocommerce-nbg-payment-gateway');
                    $message_type = 'error';
                    $nbg_message = array('message' => $message, 'message_type' => $message_type);
                    update_post_meta($order_id, '_nbg_message', $pb_message);
                    //Update the order status
                    $order->update_status('failed', '');
                    $checkout_url = $woocommerce->cart->get_checkout_url();
                    wp_redirect($checkout_url);
                    exit;
                }
                if ($this->redirect_page_id == "-1") {
                    $redirect_url = $this->get_return_url($order);
                } else {
                    $redirect_url = $this->redirect_page_id == "" || $this->redirect_page_id == 0 ? get_site_url() . "/" : get_permalink($this->redirect_page_id);
                    //For wooCoomerce 2.0
                    $redirect_url = add_query_arg(array('msg' => urlencode($this->msg['message']), 'type' => $this->msg['class']), $redirect_url);
                }
                wp_redirect($redirect_url);
                exit;
            }
            if (isset($_GET['nbg']) && $_GET['nbg'] === 'cancel') {
                $checkout_url = $woocommerce->cart->get_checkout_url();
                wp_redirect($checkout_url);
                exit;
            }
        }