die("Invalid public key for '{$v}' in \$all_keys variable");
    } elseif (!strpos($all_keys[$v]["private_key"], "PRV")) {
        die("Invalid private key for '{$v}' in \$all_keys variable");
    } elseif (strpos(CRYPTOBOX_PRIVATE_KEYS, $all_keys[$v]["private_key"]) === false) {
        die("Please add your private key for '{$v}' in variable \$cryptobox_private_keys, file cryptobox.config.php.");
    }
}
// Current selected coin by user
$coinName = cryptobox_selcoin($available_payments, $def_payment);
// Current Coin public/private keys
$public_key = $all_keys[$coinName]["public_key"];
$private_key = $all_keys[$coinName]["private_key"];
/** PAYMENT BOX **/
$options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => "", "orderID" => $orderID, "userID" => $userID, "userFormat" => $userFormat, "amount" => 0, "amountUSD" => $amountUSD, "period" => $period, "language" => $def_language);
// Initialise Payment Class
$box = new Cryptobox($options);
// coin name
$coinName = $box->coin_name();
// Optional - Language selection list for payment box (html code)
$languages_list = display_language_box($def_language);
// Optional - Coin selection list (html code)
$coins_list = display_currency_box($available_payments, $def_payment, $def_language, 60, "margin: 80px 0 0 0");
// Form Data
// --------------------------
$ftitle = isset($_POST["ftitle"]) ? $_POST["ftitle"] : "";
$ftext = isset($_POST["ftext"]) ? $_POST["ftext"] : "";
$error = "";
$successful = false;
if (isset($_POST) && isset($_POST["ftitle"])) {
    if (!$ftitle) {
        $error .= "<li>Please enter Title</li>";
$amountUSD = 0.6;
// price per page(s) - 0.6 USD
$period = "24 HOUR";
// user will get access to page(s) for 24 hours; after need to pay again
$def_language = "en";
// default Payment Box Language
$public_key = "-your public key for coin box-";
// from gourl.io
$private_key = "-your private key for coin box-";
// from gourl.io
// IMPORTANT: Please read description of options here - https://gourl.io/cryptocoin_payment_api.html#options
/********************************/
/** PAYMENT BOX **/
$options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => "", "orderID" => $orderID, "userID" => $userID, "userFormat" => $userFormat, "amount" => 0, "amountUSD" => $amountUSD, "period" => $period, "language" => $def_language);
// Initialise Payment Class
$box = new Cryptobox($options);
// coin name
$coinName = $box->coin_name();
// Optional - Language selection list for payment box (html code)
$languages_list = display_language_box($def_language);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<title><?php 
echo $coinName;
?>
 Pay-Per-View / Page Access Cryptocoin Payment Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv='cache-control' content='no-cache'>
	/** PAYMENT BOX **/
	$options = array(
			"public_key"  => $public_key, 	// your public key from gourl.io
			"private_key" => $private_key, 	// your private key from gourl.io
			"webdev_key"  => "", 		// optional, gourl affiliate key
			"orderID"     => $orderID, 		// order id
			"userID"      => $userID, 		// unique identifier for every user
			"userFormat"  => $userFormat, 	// save userID in COOKIE, IPADDRESS or SESSION
			"amount"   	  => 0,				// price in coins OR in USD below
			"amountUSD"   => $amountUSD,	// we use price in USD
			"period"      => $period, 		// payment valid period
			"language"	  => $def_language  // text on EN - english, FR - french, etc
	);

	// Initialise Payment Class
	$box = new Cryptobox ($options);
	
	// coin name
	$coinName = $box->coin_name(); 
	

	
	// Optional - Language selection list for payment box (html code)
	$languages_list = display_language_box($def_language);
	
	
	
	// Successful Cryptocoin Payment received
	// Please use also IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") for update db records, etc
	if ($box->is_paid())
	{
        die("Invalid public key for '{$v}' in \$all_keys variable");
    } elseif (!strpos($all_keys[$v]["private_key"], "PRV")) {
        die("Invalid private key for '{$v}' in \$all_keys variable");
    } elseif (strpos(CRYPTOBOX_PRIVATE_KEYS, $all_keys[$v]["private_key"]) === false) {
        die("Please add your private key for '{$v}' in variable \$cryptobox_private_keys, file cryptobox.config.php.");
    }
}
// Current selected coin by user
$coinName = cryptobox_selcoin($available_payments, $def_payment);
// Current Coin public/private keys
$public_key = $all_keys[$coinName]["public_key"];
$private_key = $all_keys[$coinName]["private_key"];
/** PAYMENT BOX **/
$options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => "", "orderID" => $orderID, "userID" => $userID, "userFormat" => $userFormat, "amount" => 0, "amountUSD" => $amountUSD, "period" => $period, "language" => $def_language);
// Initialise Payment Class
$box = new Cryptobox($options);
// coin name
$coinName = $box->coin_name();
// Generate Download Link
$download_link = "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" . (strpos($_SERVER["REQUEST_URI"], "?") ? "&" : "?") . "dd=1";
$download_link = "href='" . htmlspecialchars($download_link, ENT_QUOTES, 'UTF-8') . "'";
// Warning message if not paid
if (!$box->is_paid()) {
    $download_link = "onclick='alert(\"You need to send " . $coinName . "s first !\")' href='#a'";
}
// Check if file exists on your server
$file = rtrim($dir, "/ ") . "/" . $filename;
if (!file_exists($file)) {
    echo "<h1><center><font color=red>Warning: {$file} not exists</font></center></h1>";
}
// User Paid - Send file to user browser
$amountUSD = 2.21;
// invoice amount - 2.21 USD
$period = "NOEXPIRY";
// one time payment, not expiry
$def_language = "en";
// default Payment Box Language
$public_key = "-your public key for coin box-";
// from gourl.io
$private_key = "-your private key for coin box-";
// from gourl.io
// IMPORTANT: Please read description of options here - https://gourl.io/api-php.html#options
/********************************/
/** PAYMENT BOX **/
$options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => "", "orderID" => $orderID, "userID" => $userID, "userFormat" => $userFormat, "amount" => 0, "amountUSD" => $amountUSD, "period" => $period, "language" => $def_language);
// Initialise Payment Class
$box = new Cryptobox($options);
// coin name
$coinName = $box->coin_name();
// Successful Cryptocoin Payment received
// Please use also IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") for update db records, etc
if ($box->is_paid()) {
    if (!$box->is_confirmed()) {
        $message = "Thank you for payment (payment #" . $box->payment_id() . "). Awaiting transaction/payment confirmation";
    } else {
        // payment confirmed (6+ confirmations)
        // one time action
        if (!$box->is_processed()) {
            // One time action after payment has been made/confirmed
            $message = "Thank you for order (order #" . $orderID . ", payment #" . $box->payment_id() . "). We will send soon";
            // Set Payment Status to Processed
            $box->set_status_processed();
        die("Invalid public key for '{$v}' in \$all_keys variable");
    } elseif (!strpos($all_keys[$v]["private_key"], "PRV")) {
        die("Invalid private key for '{$v}' in \$all_keys variable");
    } elseif (strpos(CRYPTOBOX_PRIVATE_KEYS, $all_keys[$v]["private_key"]) === false) {
        die("Please add your private key for '{$v}' in variable \$cryptobox_private_keys, file cryptobox.config.php.");
    }
}
// Current selected coin by user
$coinName = cryptobox_selcoin($available_payments, $def_payment);
// Current Coin public/private keys
$public_key = $all_keys[$coinName]["public_key"];
$private_key = $all_keys[$coinName]["private_key"];
/** PAYMENT BOX **/
$options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => "", "orderID" => $orderID, "userID" => $userID, "userFormat" => $userFormat, "amount" => 0, "amountUSD" => $amountUSD, "period" => $period, "language" => $def_language);
// Initialise Payment Class
$box = new Cryptobox($options);
// coin name
$coinName = $box->coin_name();
// Successful Cryptocoin Payment received
// Please use also IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") for update db records, etc
if ($box->is_paid()) {
    if (!$box->is_confirmed()) {
        $message = "Thank you for payment (payment #" . $box->payment_id() . "). Awaiting transaction/payment confirmation";
    } else {
        // payment confirmed (6+ confirmations)
        // one time action
        if (!$box->is_processed()) {
            // One time action after payment has been made/confirmed
            $message = "Thank you for order (order #" . $orderID . ", payment #" . $box->payment_id() . "). We will send soon";
            // Set Payment Status to Processed
            $box->set_status_processed();
	/** PAYMENT BOX **/
	$options = array(
			"public_key"  => $public_key, 	// your public key from gourl.io
			"private_key" => $private_key, 	// your private key from gourl.io
			"webdev_key"  => "", 		// optional, gourl affiliate key
			"orderID"     => $orderID, 		// order id
			"userID"      => $userID, 		// unique identifier for every user
			"userFormat"  => $userFormat, 	// save userID in COOKIE, IPADDRESS or SESSION
			"amount"   	  => 0,				// price in coins OR in USD below
			"amountUSD"   => $amountUSD,	// we use price in USD
			"period"      => $period, 		// payment valid period
			"language"	  => $def_language  // text on EN - english, FR - french, etc
	);

	// Initialise Payment Class
	$box = new Cryptobox ($options);
	
	// coin name
	$coinName = $box->coin_name(); 
	
	
	// Optional - Language selection list for payment box (html code)
	$languages_list = display_language_box($def_language);
	
	
	
	
	// Form Data
	// --------------------------
	$fname	 	= (isset($_POST["fname"])) ? $_POST["fname"] : "";
	$femail  	= (isset($_POST["femail"])) ? $_POST["femail"] : "";
 public function cryptopayments($pluginName, $amount, $amountCurrency = "USD", $orderID, $period, $default_language = "en", $default_coin = "bitcoin", $affiliate_key = "", $userID = "auto", $icon_width = 60)
 {
     // Security Test
     // ---------------------
     if (!$pluginName) {
         return array("error" => __("Error. Please place in variable \$YourPluginName - your plugin name", GOURL));
     }
     if (preg_replace('/[^a-z0-9\\_\\-]/', '', $pluginName) != $pluginName || strlen($pluginName) < 5 || strlen($pluginName) > 17) {
         return array("error" => sprintf(__("Error. Invalid plugin name - %s. Size: 5-17 symbols. Allowed symbols: a..Z0..9_-", GOURL), $pluginName));
     }
     if (stripos($pluginName, "product") === 0 || stripos($pluginName, "file") === 0 || stripos($pluginName, "pay") === 0 || stripos($pluginName, "membership") === 0 || stripos($pluginName, "user") === 0) {
         return array("error" => __("Error. Please change plugin name. Plugin name can not begin with: 'file..', 'product..', 'pay..', 'membership..', 'user..'", GOURL));
     }
     if (stripos($pluginName, "gourl") !== false && $pluginName != "gourlwoocommerce" && $affiliate_key != "gourl") {
         return array("error" => __("Error. Please change plugin name. Plugin name can not use in name '..gourl..'", GOURL));
     }
     $pluginName = strtolower(substr($pluginName, 0, 17));
     $amountCurrency = trim(strtoupper($amountCurrency));
     if ($amountCurrency == "USD" && (!is_numeric($amount) || $amount < 0.01 || $amount > 1000000)) {
         return array("error" => sprintf(__("Error. Invalid amount value - %s. Min value for USD: 0.01", GOURL), $amount));
     }
     if ($amountCurrency != "USD" && (!is_numeric($amount) || $amount < 0.0001 || $amount > 50000000)) {
         return array("error" => sprintf(__("Error. Invalid amount value - %s. Min value: 0.0001", GOURL), $amount));
     }
     if ($amountCurrency != "USD" && !isset($this->coin_names[$amountCurrency])) {
         return array("error" => sprintf(__("Error. Invalid amountCurrency - %s. Allowed: USD, %s", GOURL), $amountCurrency, implode(", ", array_keys($this->coin_names))));
     }
     if (!$orderID || preg_replace('/[^A-Za-z0-9\\_\\-]/', '', $orderID) != $orderID || strlen($orderID) > 32) {
         return array("error" => sprintf(__("Error. Invalid Order ID - %s. Max size: 32 symbols. Allowed symbols: a..Z0..9_-", GOURL), $orderID));
     }
     $period = trim(strtoupper(str_replace(" ", "", $period)));
     if (substr($period, -1) == "S") {
         $period = substr($period, 0, -1);
     }
     for ($i = 1; $i <= 90; $i++) {
         $arr[] = $i . "MINUTE";
         $arr[] = $i . "HOUR";
         $arr[] = $i . "DAY";
         $arr[] = $i . "WEEK";
         $arr[] = $i . "MONTH";
     }
     if ($period != "NOEXPIRY" && !in_array($period, $arr)) {
         return array("error" => sprintf(__("Error. Invalid period value - %s. Allowed: NOEXPIRY, 1..90 HOUR, 1..90 DAY, 1..90 WEEK, 1..90 MONTH; example: 2 DAYS", GOURL), $period));
     }
     $period = str_replace(array("MINUTE", "HOUR", "DAY", "WEEK", "MONTH"), array(" MINUTE", " HOUR", " DAY", " WEEK", " MONTH", GOURL), $period);
     if (!$default_language) {
         $default_language = "en";
     }
     if (!in_array($default_language, array_keys($this->languages))) {
         return array("error" => sprintf(__("Error. Invalid language - %s. Allowed: %s"), GOURL), $default_language, implode(", ", array_keys($this->languages)));
     }
     if (!$default_coin) {
         $default_coin = "bitcoin";
     }
     if (!in_array($default_coin, $this->coin_names)) {
         return array("error" => sprintf(__("Error. Invalid Coin - %s. Allowed: %s", GOURL), $default_coin, implode(",", $this->coin_names)));
     }
     if ($affiliate_key == "gourl") {
         $affiliate_key = "";
     }
     if ($affiliate_key && (strpos($affiliate_key, "DEV") !== 0 || preg_replace('/[^A-Za-z0-9]/', '', $affiliate_key) != $affiliate_key)) {
         return array("error" => __("Error. Invalid affiliate_key, you can leave it empty", GOURL));
     }
     if (!$userID || $userID == "auto") {
         $userID = get_current_user_id();
     }
     if ($userID && $userID != "guest" && (!is_numeric($userID) || preg_replace('/[^0-9]/', '', $userID) != $userID)) {
         return array("error" => sprintf(__("Error. Invalid User ID - %s. Allowed numeric values or 'guest' value", GOURL), $userID));
     }
     if (!$userID) {
         return array("error" => __("Error.", GOURL) . __("You need first to login or register on the website to make Bitcoin/Altcoin Payments", GOURL));
     }
     if (!$this->payments) {
         return array("error" => __("Error. Please try a different payment method. GoUrl Bitcoin Plugin not configured - need setup payment box keys on GoUrl Bitcoin Gateway Options page", GOURL));
     }
     $icon_width = str_replace("px", "", $icon_width);
     if (!is_numeric($icon_width) || $icon_width < 30 || $icon_width > 250) {
         $icon_width = 60;
     }
     if ($amountCurrency == "USD") {
         $amountUSD = $amount;
         $amountCoin = 0;
         $default_show = false;
     } else {
         $amountUSD = 0;
         $amountCoin = $amount;
         $default_coin = $this->coin_names[$amountCurrency];
         $default_show = true;
     }
     // GoUrl Payments
     // --------------------------
     $all_keys = array();
     // Your payment boxes public / private keys from GoUrl.io
     $available_coins = array();
     // List of coins that you accept for payments
     $cryptobox_private_keys = array();
     // List Of your private keys
     $box_width = $this->options["box_width"];
     $box_height = $this->options["box_height"];
     $box_style = $this->payment_box_style();
     $message_style = $this->payment_message_style();
     foreach ($this->coin_names as $k => $v) {
         $public_key = $this->options[$v . 'public_key'];
         $private_key = $this->options[$v . 'private_key'];
         if ($public_key && !strpos($public_key, "PUB")) {
             return array("error" => sprintf(__('Invalid %s Public Key - %s', GOURL), $v, $public_key));
         }
         if ($private_key && !strpos($private_key, "PRV")) {
             return array("error" => sprintf(__('Invalid %s Private Key', GOURL), $v));
         }
         if ($private_key) {
             $cryptobox_private_keys[] = $private_key;
         }
         if ($private_key && $public_key && (!$default_show || $v == $default_coin)) {
             $all_keys[$v] = array("public_key" => $public_key, "private_key" => $private_key);
             $available_coins[] = $v;
         }
     }
     if (!defined("CRYPTOBOX_PRIVATE_KEYS")) {
         define("CRYPTOBOX_PRIVATE_KEYS", implode("^", $cryptobox_private_keys));
     }
     if (!$available_coins) {
         return array("error" => sprintf(__("Error. Please enter Payment Private/Public Keys on GoUrl Options page for %s", GOURL), $default_coin));
     }
     if (!in_array($default_coin, $available_coins)) {
         $vals = array_values($available_coins);
         $default_coin = array_shift($vals);
     }
     /// GoUrl Payment Class
     // --------------------------
     include_once plugin_dir_path(__FILE__) . "includes/cryptobox.class.php";
     // Current selected coin by user
     $coinName = cryptobox_selcoin($available_coins, $default_coin);
     // Current Coin public/private keys
     $public_key = $all_keys[$coinName]["public_key"];
     $private_key = $all_keys[$coinName]["private_key"];
     // PAYMENT BOX CONFIG
     $options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => $affiliate_key, "orderID" => $pluginName . "." . $orderID, "userID" => $userID == "guest" ? $pluginName . "." . $userID : "user" . $userID, "userFormat" => "MANUAL", "amount" => $amountCoin, "amountUSD" => $amountUSD, "period" => $period, "language" => $default_language);
     // Initialise Payment Class
     $box = new Cryptobox($options);
     // Coin name
     $coinName = $box->coin_name();
     // Paid or not
     $is_paid = $box->is_paid();
     // page anchor
     $anchor = "go" . $this->icrc32($pluginName . "." . $orderID);
     // Coins selection list (html code)
     $coins_list = count($available_coins) > 1 ? display_currency_box($available_coins, $default_coin, $default_language, $icon_width, "margin:10px 0 30px 0;text-align:center;font-weight:normal;", plugins_url('/images', __FILE__), $anchor) : "";
     // Language selection list for payment box (html code)
     $languages_list = display_language_box($default_language, $anchor);
     // Payment Box
     $box_html = $box->display_cryptobox(true, $box_width, $box_height, $box_style, $message_style, $anchor);
     $html = "";
     if (!$is_paid) {
         $html .= "<a id='" . $anchor . "' name='" . $anchor . "'></a>";
     }
     if ($is_paid) {
         $html .= "<br>";
     } else {
         $html .= $coins_list;
     }
     // Cryptocoin Payment Box
     if ($languages_list) {
         $html .= "<table cellspacing='0' cellpadding='0' border='0' width='100%' style='border:0;box-shadow:none;margin:0;padding:0;background-color:transparent'>";
         $html .= "<tr style='background-color:transparent'><td style='border:0;margin:0;padding:0;background-color:transparent'><div style='margin:" . ($coins_list ? 25 : 50) . "px 0 5px " . ($this->options['box_width'] / 2 - 115) . "px;min-width:100%;text-align:center;font-size:13px;color:#666;font-weight:normal;white-space:nowrap;'>" . __('Language', GOURL) . ": " . $this->space(1) . $languages_list . "</div></td></tr>";
         $html .= "<tr style='background-color:transparent'><td style='border:0;margin:0;padding:0;background-color:transparent'>" . $box_html . "</td></tr>";
         $html .= "</table>";
     } else {
         $html .= $box_html;
     }
     // Result
     $obj = $is_paid ? $box->payment_info() : "";
     $arr = array("status" => $is_paid ? "payment_received" : "payment_not_received", "error" => "", "is_paid" => $is_paid, "paymentID" => $is_paid ? $obj->paymentID : 0, "paymentDate" => $is_paid ? $obj->txDate : "", "paymentLink" => $is_paid ? GOURL_ADMIN . GOURL . "payments&s=payment_" . $obj->paymentID : "", "addr" => $is_paid ? $obj->addr : "", "tx" => $is_paid ? $obj->txID : "", "is_confirmed" => $is_paid ? $obj->txConfirmed : "", "amount" => $is_paid ? $obj->amount : "", "amountusd" => $amountUSD, "coinlabel" => $is_paid ? $obj->coinLabel : "", "coinname" => $is_paid ? strtolower($coinName) : "", "boxID" => $is_paid ? $obj->boxID : 0, "boxtype" => $is_paid ? $obj->boxType : "", "boxLink" => $is_paid ? "https://gourl.io/view/coin_boxes/" . $obj->boxID . "/statistics.html" : "", "orderID" => $orderID, "userID" => $userID, "usercountry" => $is_paid ? $obj->countryID : "", "userLink" => $userID == "guest" ? "" : admin_url("user-edit.php?user_id=" . $userID), "is_processed" => $is_paid ? $obj->processed : "", "processedDate" => $is_paid && $obj->processed ? $obj->processedDate : "", "callback_function" => $orderID . "_gourlcallback", "available_payments" => $this->payments, "html_payment_box" => $html);
     if ($is_paid && !$obj->processed) {
         $box->set_status_processed();
     }
     return $arr;
 }
        die("Invalid public key for '{$v}' in \$all_keys variable");
    } elseif (!strpos($all_keys[$v]["private_key"], "PRV")) {
        die("Invalid private key for '{$v}' in \$all_keys variable");
    } elseif (strpos(CRYPTOBOX_PRIVATE_KEYS, $all_keys[$v]["private_key"]) === false) {
        die("Please add your private key for '{$v}' in variable \$cryptobox_private_keys, file cryptobox.config.php.");
    }
}
// Current selected coin by user
$coinName = cryptobox_selcoin($available_payments, $def_payment);
// Current Coin public/private keys
$public_key = $all_keys[$coinName]["public_key"];
$private_key = $all_keys[$coinName]["private_key"];
/** PAYMENT BOX **/
$options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => "", "orderID" => $orderID, "userID" => $userID, "userFormat" => $userFormat, "amount" => 0, "amountUSD" => $amountUSD, "period" => $period, "language" => $def_language);
// Initialise Payment Class
$box = new Cryptobox($options);
// coin name
$coinName = $box->coin_name();
// Optional - Language selection list for payment box (html code)
$languages_list = display_language_box($def_language);
// Optional - Coin selection list (html code)
if (!$box->is_paid()) {
    $coins_list = display_currency_box($available_payments, $def_payment, $def_language, 60, "margin: 80px 0 0 0");
}
// Form Data
// --------------------------
$fname = isset($_POST["fname"]) ? $_POST["fname"] : "";
$femail = isset($_POST["femail"]) ? $_POST["femail"] : "";
$fpassword = isset($_POST["fpassword"]) ? $_POST["fpassword"] : "";
$error = "";
$successful = false;
	/** PAYMENT BOX **/
	$options = array(
			"public_key"  => $public_key, 	// your public key from gourl.io
			"private_key" => $private_key, 	// your private key from gourl.io
			"webdev_key"  => "", 		// optional, gourl affiliate key
			"orderID"     => $orderID, 		// order id
			"userID"      => $userID, 		// unique identifier for every user
			"userFormat"  => $userFormat, 	// save userID in COOKIE, IPADDRESS or SESSION
			"amount"   	  => 0,				// price in coins OR in USD below
			"amountUSD"   => $amountUSD,	// we use price in USD
			"period"      => $period, 		// payment valid period
			"language"	  => $def_language  // text on EN - english, FR - french, etc
	);

	// Initialise Payment Class
	$box = new Cryptobox ($options);
	
	// coin name
	$coinName = $box->coin_name(); 
	
	
	// Optional - Language selection list for payment box (html code)
	$languages_list = display_language_box($def_language);
	
	
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<title><?= $coinName ?> Pay-Per-View / Page Access Cryptocoin Payment Example</title>
<?php

/**
 * @category    Basic Example
 * @package     GoUrl Cryptocurrency Payment API 
 * copyright 	(c) 2014-2016 Delta Consultants
 * @crypto      Supported Cryptocoins -	Bitcoin, Litecoin, Paycoin, Dogecoin, Dash, Speedcoin, Reddcoin, Potcoin, Feathercoin, Vertcoin, Vericoin, Peercoin, MonetaryUnit
 * @website     https://gourl.io/api-php.html
 */
require_once "../cryptobox.class.php";
$options = array("public_key" => "", "private_key" => "", "webdev_key" => "", "orderID" => "your_product1_or_signuppage1_etc", "userID" => "", "userFormat" => "COOKIE", "amount" => 0, "amountUSD" => 2, "period" => "24 HOUR", "iframeID" => "", "language" => "EN");
// IMPORTANT: Please read description of options here - https://gourl.io/api-php.html#options
// Initialise Payment Class
$box1 = new Cryptobox($options);
// Display Payment Box or successful payment result
$paymentbox = $box1->display_cryptobox();
// Log
$message = "";
// A. Process Received Payment
if ($box1->is_paid()) {
    $message .= "A. User will see this message during 24 hours after payment has been made!";
    $message .= "<br>" . $box1->amount_paid() . " " . $box1->coin_label() . "  received<br>";
    // Your code here to handle a successful cryptocoin payment/captcha verification
    // For example, give user 24 hour access to your member pages
    // Please use also IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") for update db records, etc
    // ...
} else {
    $message .= "The payment has not been made yet";
}
// B. One-time Process Received Payment
if ($box1->is_paid() && !$box1->is_processed()) {
	/** PAYMENT BOX **/
	$options = array(
			"public_key"  => $public_key, 	// your public key from gourl.io
			"private_key" => $private_key, 	// your private key from gourl.io
			"webdev_key"  => "", 		// optional, gourl affiliate key
			"orderID"     => $orderID, 		// order id
			"userID"      => $userID, 		// unique identifier for every user
			"userFormat"  => $userFormat, 	// save userID in COOKIE, IPADDRESS or SESSION
			"amount"   	  => 0,				// price in coins OR in USD below
			"amountUSD"   => $amountUSD,	// we use price in USD
			"period"      => $period, 		// payment valid period
			"language"	  => $def_language  // text on EN - english, FR - french, etc
	);

	// Initialise Payment Class
	$box = new Cryptobox ($options);
	
	// coin name
	$coinName = $box->coin_name(); 
	

	
	// Optional - Language selection list for payment box (html code)
	$languages_list = display_language_box($def_language);
	
	
	
	// Optional - Coin selection list (html code)
	if (!$box->is_paid()) $coins_list = display_currency_box($available_payments, $def_payment, $def_language, 60, "margin: 80px 0 0 0");
	
	
	/** PAYMENT BOX **/
	$options = array(
			"public_key"  => $public_key, 	// your public key from gourl.io
			"private_key" => $private_key, 	// your private key from gourl.io
			"webdev_key"  => "", 		// optional, gourl affiliate key
			"orderID"     => $orderID, 		// order id
			"userID"      => $userID, 		// unique identifier for every user
			"userFormat"  => $userFormat, 	// save userID in COOKIE, IPADDRESS or SESSION
			"amount"   	  => 0,				// post price in coins OR in USD below
			"amountUSD"   => $amountUSD,	// we use post price in USD
			"period"      => $period, 		// payment valid period
			"language"	  => $def_language  // text on EN - english, FR - french, etc
	);

	// Initialise Payment Class
	$box = new Cryptobox ($options);
	
	// coin name
	$coinName = $box->coin_name(); 
	
	

	// Optional - Language selection list for payment box (html code)
	$languages_list = display_language_box($def_language);
	
	
	
	// Optional - Coin selection list (html code)
	$coins_list = display_currency_box($available_payments, $def_payment, $def_language, 60, "margin: 80px 0 0 0");
	
	
	/** PAYMENT BOX **/
	$options = array(
			"public_key"  => $public_key, 	// your public key from gourl.io
			"private_key" => $private_key, 	// your private key from gourl.io
			"webdev_key"  => "", 		// optional, gourl affiliate key
			"orderID"     => $orderID, 		// order id
			"userID"      => $userID, 		// unique identifier for every user
			"userFormat"  => $userFormat, 	// save userID in COOKIE, IPADDRESS or SESSION
			"amount"   	  => 0,				// post price in coins OR in USD below
			"amountUSD"   => $amountUSD,	// we use post price in USD
			"period"      => $period, 		// payment valid period
			"language"	  => $def_language  // text on EN - english, FR - french, etc
	);

	// Initialise Payment Class
	$box = new Cryptobox ($options);
	
	// coin name
	$coinName = $box->coin_name(); 
	
	
	// Optional - Language selection list for payment box (html code)
	$languages_list = display_language_box($def_language);
	
	
	
	
	// Form Data
	// --------------------------
	$ftitle	 = (isset($_POST["ftitle"])) ? $_POST["ftitle"] : "";
	$ftext 	 = (isset($_POST["ftext"])) ? $_POST["ftext"] : "";
        die("Invalid public key for '{$v}' in \$all_keys variable");
    } elseif (!strpos($all_keys[$v]["private_key"], "PRV")) {
        die("Invalid private key for '{$v}' in \$all_keys variable");
    } elseif (strpos(CRYPTOBOX_PRIVATE_KEYS, $all_keys[$v]["private_key"]) === false) {
        die("Please add your private key for '{$v}' in variable \$cryptobox_private_keys, file cryptobox.config.php.");
    }
}
// Current selected coin by user
$coinName = cryptobox_selcoin($available_payments, $def_payment);
// Current Coin public/private keys
$public_key = $all_keys[$coinName]["public_key"];
$private_key = $all_keys[$coinName]["private_key"];
/** PAYMENT BOX **/
$options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => "", "orderID" => $orderID, "userID" => $userID, "userFormat" => $userFormat, "amount" => 0, "amountUSD" => $amountUSD, "period" => $period, "language" => $def_language);
// Initialise Payment Class
$box = new Cryptobox($options);
// coin name
$coinName = $box->coin_name();
// Generate Download Link
$download_link = "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" . (strpos($_SERVER["REQUEST_URI"], "?") ? "&" : "?") . "dd=1";
$download_link = "href='" . htmlspecialchars($download_link, ENT_QUOTES, 'UTF-8') . "'";
// Warning message if not paid
if (!$box->is_paid()) {
    $download_link = "onclick='alert(\"You need to send " . $coinName . "s first !\")' href='#a'";
}
// Check if file exists on your server
$file = rtrim($dir, "/ ") . "/" . $filename;
if (!file_exists($file)) {
    echo "<h1><center><font color=red>Warning: {$file} not exists</font></center></h1>";
}
// User Paid - Send file to user browser