/**
 * Retrieve our external IP address
 *
 * @return mixed
 */
function getExternalIp()
{
    $html = getWebPage(CHECK_IP);
    if (preg_match('/(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})/', $html, $matches) === 0) {
        return false;
    }
    return $matches[0];
}
Exemple #2
0
} else {
    echo "Processing:\n";
    $html->load($htmlContent);
    // $products = $html->find("ul");
    $productList = array();
    $priceTotal = 0.0;
    $price = 0.0;
    foreach ($html->find("ul[class=productLister]") as $ul) {
        foreach ($ul->find("li") as $product) {
            $price = $product->find('p[class=pricePerUnit] [!abbr]', 0);
            $link = $product->find('div[class=productInfo]', 0)->find('h3', 0)->find('a', 0);
            // $echo $link->href . PHP_EOL;
            $title = $link->plaintext;
            // $priceTotal += $price;
            // echo "\t" . $product->href . "\n";
            $htmlDest = getWebPage($link->href);
            // echo $htmlDest;
            $size = strlen($htmlDest);
            $size = number_format($size / 1024, 2);
            $html2->load($htmlDest);
            $description = $html2->find("meta[name='description']", 0)->content;
            $description = html_entity_decode($description, ENT_QUOTES);
            $price = $html2->find('p[class=pricePerUnit] [!abbr]', 0)->plaintext;
            // echo $price . PHP_EOL;
            $productList[] = array("title" => html_entity_decode($title, ENT_QUOTES), "size" => $size . "kb", "unit_price" => $price, "description" => $description);
            echo PHP_EOL;
        }
    }
    $productList = array("total" => $priceTotal);
}
$jsonContent = json_encode($productList, 128);
define('CONFIGKEY', '1111:2222:6f3d938b65eb833e695393985e1r13z79c');
//your configkey or userid:projektid:apikey
$PnagInvoice = new PnagInvoice(CONFIGKEY);
$PnagInvoice->setVersion('MY_VERSION');
$PnagInvoice->addInvoiceAddress('success', 'Doe', 'Street', '15', '35578', 'City', 2, 'DE', 'Company Name');
$PnagInvoice->addShippingAddress('success', 'Doe', 'Street', '15', '35578', 'City', 2, 'DE', 'Company Name');
$PnagInvoice->setReason('Invoice', 'Invoice');
$PnagInvoice->setEmailCustomer('*****@*****.**');
$PnagInvoice->addItemToInvoice(md5('unique'), 'Art01', 'a simple title', 1.2, 0, 'a simple description', 6, 19);
$PnagInvoice->setAbortUrl('http://127.0.0.1');
$PnagInvoice->setSuccessUrl('http://127.0.0.1');
$PnagInvoice->setTimeoutUrl('http://127.0.0.1');
$PnagInvoice->setNotificationUrl('http://127.0.0.1');
try {
    $err = $PnagInvoice->checkout();
    getWebPage($PnagInvoice->getPaymentUrl());
} catch (XmlToArrayException $e) {
}
$transactionId = $PnagInvoice->getTransactionId();
$articles = array(array('articleId' => md5('unique'), 'articleNumber' => 'Art01', 'articleTitle' => 'a simple title', 'articlePrice' => 1.2, 'articleType' => 0, 'articleDescription' => 'a simple description', 'articleQuantity' => 2, 'articleTax' => 19));
$PnagInvoice = null;
$PnagInvoice = new PnagInvoice(CONFIGKEY, $transactionId);
$PnagInvoice->setTransactionId($transactionId);
$pnagArticles = array();
foreach ($articles as $article) {
    array_push($pnagArticles, array('itemId' => $article['articleId'], 'productNumber' => $article['articleNumber'], 'title' => $article['articleTitle'], 'description' => $article['articleDescription'], 'quantity' => $article['articleQuantity'], 'unitPrice' => number_format($article['articlePrice'], 2, '.', ''), 'tax' => number_format($article['articleTax'], 2, '.', '')));
}
$invoiceNumber = "10234";
$customerNumber = "10234";
$orderNumber = "10234";
try {