Exemple #1
0
 // generate unique random string
 $random_str = bitcoin::randomString(26);
 while (file_exists('t_data/' . $random_str)) {
     $random_str = bitcoin::randomString(26);
 }
 //send data to mysql
 //MYSQL CONNECT
 $con = mysql_connect($mysvr, $myusr, $mypass);
 if (!$con) {
     die('Could not connect: ' . mysql_error());
 }
 mysql_select_db($mydb) or die(mysql_error());
 // Insert a row of information into the table "payment"
 mysql_query("INSERT INTO payment \n(price, quantity, item, seller, buyer, note, baggage, key_data, pubAdd, privwif, privkey, frpin, buyrel, verifypin) VALUES('{$price}', '{$quantity}', '{$item}', '{$seller}', '{$buyer}', '{$note}', '{$baggage}', '{$key_data}', '{$pubAdd}', '{$privwif}', '{$privkey}', '{$frpin}', 'NO', '{$vpin}') ") or die(mysql_error());
 // encrypt transaction data and save to file
 $t_data = bitsci::build_pay_query($keySet['pubAdd'], $price, $quantity, $item, $seller, $success_url, $cancel_url, $note, $baggage);
 if (file_put_contents('t_data/' . $random_str, $t_data) !== false) {
     chmod('t_data/' . $random_str, 0600);
 } else {
     echo "<p class='error_txt'>There was an error creating the transaction. Please go back and try again.</p>";
     mysql_close($con);
     exit;
 }
 // build the URL for the bitcoin payment gateway
 $payment_gateway = $site_url . $bitsci_url . 'payment.php?sid=' . session_id() . '&t=' . $random_str;
 // save encrypted private WIF key to file (along with address).
 // you might want to save these keys to a database instead.
 //$fp=fopen(dirname(__FILE__)."/wif-keys.csv","a");
 // if ($fp) {
 //  if (flock($fp, LOCK_EX)) {
 //    @fwrite($fp, $key_data.",\n");