Esempio n. 1
0
function doPayout()
{
    // Um, yes.
    global $DB;
    global $TIMEMARK;
    global $MySelf;
    // Are we allowed to do this?
    if (!$MySelf->isAccountant()) {
        makeNotice("You are not an accountant to your corporation. Access denied.", "error", "Access denied");
    }
    // Get unpaid IDs.
    $IDS = $DB->query("SELECT DISTINCT request, amount, applicant FROM payoutRequests WHERE payoutTime IS NULL");
    // loop through all unpaid IDs.
    while ($ID = $IDS->fetchRow()) {
        // Check if we marked the id as "paid"
        if ($_POST[$ID[request]]) {
            // We did. Can user afford payment?
            //if (getCredits($ID[applicant]) >= $ID[amount]) {
            // Yes, he can!
            $transaction = new transaction($ID[applicant], 1, $ID[amount]);
            $transaction->setReason("payout request fulfilled");
            if ($transaction->commit()) {
                $DB->query("UPDATE payoutRequests SET payoutTime = '{$TIMEMARK}', banker='" . $MySelf->getID() . "' WHERE request='{$ID['request']}' LIMIT 1");
            }
            //}
        }
    }
    header("Location: index.php?action=payout");
}
function add_transaction()
{
    $json_trans = $_GET['trans'];
    $transaction = json_decode($json_trans);
    $total = $transaction->total;
    $phone_number = $transaction->phoneNumber;
    $phone_number = "'" . $phone_number . "'";
    $product_barcodes = $transaction->productBarcode;
    include_once 'transaction.php';
    $obj = new transaction();
    if (!$obj->connect()) {
        $json = "Failed to connect to the database.";
        echo $json;
    }
    if ($obj->add_transaction($phone_number, $total)) {
        include_once 'order.php';
        $order_obj = new order();
        $order_obj->connect();
        $trans_id = $obj->get_insert_id();
        $order_obj->add_orders($trans_id, $product_barcodes);
        if ($total > 500) {
            //            $message = "You have a 10% discount the next time you purchase.";
            //            send_smsgh($phone_number, $message);
        }
        $json = "The transaction was added.";
        echo $json;
    } else {
        $json = "The transaction was not added.";
        echo $json;
    }
}
 function created()
 {
     $transaction = new transaction();
     $transaction->account_id = $_POST['account_id'];
     $transaction->type = $_POST['type'];
     $transaction->amount = $_POST['amount'];
     $transaction->extra_cost = $_POST['extra_cost'];
     $transaction->datetime = date("Y-m-d H:i:s");
     $transaction->comment = $_POST['comment'];
     $transaction->create();
     header("location: index.php?c=users&a=profile&user_id=" . $_POST['user_id']);
 }
Esempio n. 4
0
function createTransaction()
{
    // We need globals.
    global $DB;
    global $MySelf;
    global $TIMEMARK;
    // Are we allowed to poke in here?
    if (!$MySelf->isAccountant()) {
        makeNotice("Umm, you are not allowed to do this. Really. You are not.", "warning", "You are not supposed to be here");
    }
    // Check the ints.
    numericCheck($_POST[wod], 0, 1);
    numericCheck($_POST[amount], 0);
    numericCheck($_POST[id], 0);
    // Its easier on the eyes.
    $type = $_POST[wod];
    $amount = $_POST[amount];
    $id = $_POST[id];
    $username = idToUsername($id);
    // invert the amount if we have a withdrawal.
    if ($_POST[wod] == 1) {
        $dir = "withdrawed";
        $dir2 = "from";
        $hisMoney = getCredits($id);
        if ($hisMoney < $amount) {
            $ayee = $hisMoney - $amount;
            confirm("WARNING:<br>{$username} can NOT afford this withdrawal. If you choose to " . "authorize this transaction anyway his account will be at " . number_format($ayee, 2) . " ISK.");
        }
    } else {
        $amount = $_POST[amount];
        $dir = "deposited";
        $dir2 = "into";
    }
    // We use custom reason, if set.
    if ($_POST[reason2] != "") {
        $reason = sanitize($_POST[reason2]);
    } else {
        $reason = sanitize($_POST[reason1]);
    }
    // Create transaction.
    $transaction = new transaction($id, $type, $amount);
    $transaction->setReason($reason);
    // Success?
    if (!$transaction->commit()) {
        // Nope :(
        makeNotice("Unable to create transaction. Danger, Will Robinson, DANGER!", "error", "Internal Error", "index.php?action=edituser&id={$id}", "[Back]");
    } else {
        // Success !
        makeNotice("You successfully {$dir} {$amount} ISK {$dir2} " . $username . "'s account.", "notice", "Transaction complete", "index.php?action=edituser&id={$id}", "[Ok]");
    }
}
Esempio n. 5
0
function show_transaction_new($template)
{
    global $TPL;
    global $tflist;
    $transaction = new transaction();
    $transaction->set_values();
    // wipe clean
    $TPL["display"] = "display:none";
    $TPL["tfList_dropdown"] = page::select_options($tflist, NULL, 500);
    $TPL["fromTfList_dropdown"] = page::select_options($tflist, NULL, 500);
    $TPL["transactionType_dropdown"] = page::select_options(transaction::get_transactionTypes());
    $TPL["status_dropdown"] = page::select_options(transaction::get_transactionStatii());
    $TPL["link"] = "";
    include_template($template);
}
Esempio n. 6
0
 public function cash()
 {
     $this->live_cash = 0;
     $this->played = 0;
     $this->cash = 0;
     $this->transactions = transaction::from_account($this->account_id);
     # här kommer transaktionerna
     foreach ($this->transactions as $transaction) {
         $transactions[] = $transaction;
         if ($transaction->type == "cash_in") {
             $this->cash += $transaction->amount;
         } elseif ($transaction->type == "bonus") {
             $this->cash += $transaction->amount;
         } elseif ($transaction->type == "cash_out") {
             $this->cash -= $transaction->amount;
         }
     }
     # här kommer betsen
     $this->bets = bet::from_account($this->account_id);
     foreach ($this->bets as $bet) {
         $bet->match = match::from_id($bet->match_id);
         $bet->account = account::from_id($bet->account_id);
         $bet->account->site = site::from_id($bet->account->site_id);
         $this->played += $bet->bet;
         if ($bet->match->result == "undecided") {
             $this->live_cash += $bet->bet;
             $this->cash -= $bet->bet;
         } else {
             $this->cash -= $bet->bet;
             $this->cash += $bet->result;
         }
     }
     return $this->cash;
 }
Esempio n. 7
0
function show_filter()
{
    global $TPL;
    global $defaults;
    $_FORM = transaction::load_form_data($defaults);
    $arr = transaction::load_transaction_filter($_FORM);
    is_array($arr) and $TPL = array_merge($TPL, $arr);
    include_template("templates/searchTransactionFilterS.tpl");
}
Esempio n. 8
0
function transferMoney()
{
    // Globals
    global $MySelf;
    global $DB;
    global $TIMEMARK;
    $MyCredits = getCredits($MySelf->getID());
    // Can we afford even the most basic transactions?
    if (!numericCheckBool($MyCredits, 0)) {
        makeNotice("You can not afford any transaction.", "warning", "Out of money", "index.php?action=manageWallet", "[cancel]");
    }
    // Did we supply an isk amount at all?
    if ($_POST[amount] == "") {
        makeNotice("You did not specify an ISK amount. Please go back, and try again.", "warning", "How much?", "index.php?action=manageWallet", "[cancel]");
    }
    if (!is_numeric($_POST[amount])) {
        makeNotice("The frog looks at you and your cheque with the amount of \"" . $_POST[amount] . "\". The frog is unsure how much ISK that is and instead decides to lick your face in a friendly manner, then it closes the teller and goes for lunch.", "warning", "Huh?");
    }
    // Check for sanity.
    if (!numericCheckBool($_POST[to], 0)) {
        makeNotice("The supplied reciver is not valid.", "warning", "Invalid ID", "index.php?action=manageWallet", "[cancel]");
    }
    if (!numericCheckBool($_POST[amount], 0)) {
        makeNotice("You need to specify a positive ISK value.", "error", "Invalid amount", "index.php?action=manageWallet", "[cancel]");
    }
    if (!numericCheckBool($_POST[amount], 0, $MyCredits)) {
        makeNotice("You can not afford this transaction.", "warning", "Out of money", "index.php?action=manageWallet", "[cancel]");
    }
    // Ok so now we know: The reciver is valid, the sender has enough money.
    $from = "<br><br>From: " . ucfirst($MySelf->getUsername());
    $to = "<br>To: " . ucfirst(idToUsername($_POST[to]));
    $amount = "<br>Amount: " . number_format($_POST[amount], 2) . " ISK";
    $reason = "<br>Reason: " . $_POST[reason];
    confirm("Please authorize this transaction:" . $from . $to . $amount . $reason);
    // Lets do it.
    $transaction = new transaction($_POST[to], 0, $_POST[amount]);
    $transaction->setReason("Cash transfer from " . ucfirst($MySelf->getUsername()) . " to " . ucfirst(idToUsername($_POST[to])) . ": " . $_POST[reason]);
    $transaction->isTransfer(true);
    $transaction->commit();
    // Send'em back.
    makeNotice($amount . " has been transfered from your into " . ucfirst(idToUsername($_POST[to])) . " account.", "notice", "Cash transfered", "index.php?action=manageWallet", "[OK]");
}
Esempio n. 9
0
function addCredit($userID, $banker, $credit, $runID)
{
    // Sane?
    numericCheck($userID, 0);
    numericCheck(abs($credit), 0);
    numericCheck($banker, 0);
    // Globals, YAY!
    global $DB;
    global $TIMEMARK;
    // Create a transaction.
    if ($credit >= 0) {
        $transaction = new transaction($userID, 0, $credit);
        $transaction->setReason("operation #" . str_pad($runID, 5, "0", STR_PAD_LEFT) . " payout");
    } else {
        $transaction = new transaction($userID, 1, abs($credit));
        $transaction->setReason("operation #" . str_pad($runID, 5, "0", STR_PAD_LEFT) . " charge");
    }
    $state = $transaction->commit();
    if ($state) {
        return true;
    } else {
        makeNotice("Unable to grant money to user #{$userID}!", "error", "Unable to comply!");
    }
}
Esempio n. 10
0
 function home()
 {
     $masters = master::all();
     $data['masters'] = $masters;
     $data['total'] = 0;
     foreach ($masters as $master) {
         $data['total'] += $master->cash;
     }
     $users = user::all();
     foreach ($users as $user) {
         $user->accounts = account::from_user($user->user_id);
         $bets = array();
         $user->calculation['cash_in'] = 0;
         $user->calculation['cash_out'] = 0;
         $user->calculation['bonus'] = 0;
         foreach ($user->accounts as $account) {
             # räkna ut alla pengar
             $account->transactions = transaction::from_account($account->account_id);
             foreach ($account->transactions as $transaction) {
                 $transactions[] = $transaction;
                 if ($transaction->type == "cash_in") {
                     $user->calculation['cash_in'] += $transaction->amount;
                 } elseif ($transaction->type == "bonus") {
                     $user->calculation['bonus'] += $transaction->amount;
                 } elseif ($transaction->type == "cash_out") {
                     $user->calculation['cash_out'] -= $transaction->amount;
                 }
             }
             $account->cash();
         }
     }
     $data['users'] = $users;
     $sites = site::all();
     $data['sites'] = $sites;
     $matches = match::all_active();
     $data['matches'] = $matches;
     $this->view('index_view.php', $data, 'main_template.php');
 }
Esempio n. 11
0
 function profile()
 {
     $id = $_GET['user_id'];
     $user = user::from_id($id);
     $user->accounts = account::from_user($user->user_id);
     $bets = array();
     $calculation['cash_in'] = 0;
     $calculation['cash_out'] = 0;
     $calculation['bonus'] = 0;
     foreach ($user->accounts as $account) {
         # räkna ut alla pengar
         $account->transactions = transaction::from_account($account->account_id);
         foreach ($account->transactions as $transaction) {
             $transactions[] = $transaction;
             if ($transaction->type == "cash_in") {
                 $calculation['cash_in'] += $transaction->amount;
             } elseif ($transaction->type == "bonus") {
                 $calculation['bonus'] += $transaction->amount;
             } elseif ($transaction->type == "cash_out") {
                 $calculation['cash_out'] -= $transaction->amount;
             }
         }
         $account->cash();
     }
     $bets = bet::from_user($id);
     foreach ($bets as $bet) {
         $bet->match = match::from_id($bet->match_id);
         $bet->account = account::from_id($bet->account_id);
         $bet->account->site = site::from_id($bet->account->site_id);
     }
     $data['calculation'] = $calculation;
     $data['user'] = $user;
     $data['bets'] = $bets;
     if (!empty($transactions)) {
         $data['transactions'] = $transactions;
     }
     $this->view('users/profile_view.php', $data, 'main_template.php');
 }
Esempio n. 12
0
function show_transaction($template)
{
    global $db;
    global $TPL;
    global $projectID;
    $current_user =& singleton("current_user");
    $transaction = new transaction();
    if (isset($projectID) && $projectID) {
        $query = prepare("SELECT transaction.*\n                          FROM transaction\n                          WHERE transaction.projectID = %d\n                      ORDER BY transactionModifiedTime desc\n                        ", $projectID);
        $db->query($query);
        while ($db->next_record()) {
            $transaction = new transaction();
            $transaction->read_db_record($db);
            $transaction->set_values("transaction_");
            $tf = $transaction->get_foreign_object("tf");
            $tf->set_values();
            $tf->set_values("tf_");
            $TPL["transaction_username"] = $db->f("username");
            $TPL["transaction_amount"] = page::money($TPL["transaction_currenyTypeID"], $TPL["transaction_amount"], "%s%mo");
            $TPL["transaction_type_link"] = $transaction->get_transaction_type_link() or $TPL["transaction_link"] = $transaction->get_value("transactionType");
            include_template($template);
        }
    }
}
Esempio n. 13
0
<?php

include "../classes/product.php";
include "../classes/transaction_products.php";
include "../classes/transaction.php";
include "../classes/buyer.php";
$objProduct = new product();
$objTrans = new transaction();
$objBuyer = new buyer();
$objTransp = new transaction_products();
$name = $_REQUEST['bname'];
$num = $_REQUEST['bnum'];
$date = date("Y-m-d");
$time = date("h:i:sa");
if (isset($num)) {
    $row = $objBuyer->get_buyer($num);
    if ($row == null) {
        $objBuyer->add_buyer($num, $name, 1);
    } else {
        //do discount stuff
    }
    $more = TRUE;
    $i = 0;
    $totalcost = 0;
    while ($more) {
        if (isset($_REQUEST['pcode' . $i]) && $_REQUEST['pcode' . $i] != "") {
            //get selling price of product
            $row = $objProduct->get_product($_REQUEST['pcode' . $i]);
            $sp = $row['selling_price'];
            //add to transaction products
            $objTransp->add_transaction_product($_REQUEST['pcode' . $i], $_REQUEST['quant' . $i], $date, $time, $num, "obed.nsiah");
Esempio n. 14
0
function lotto_draw()
{
    // We need some globals
    global $MySelf;
    global $DB;
    global $TIMEMARK;
    // is Lotto enabled at all?
    if (!getConfig("lotto")) {
        makeNotice("Your CEO disabled the Lotto module, request denied.", "warning", "Lotto Module Offline");
    }
    // Deny access to non-lotto-officials.
    if (!$MySelf->isLottoOfficial()) {
        makeNotice("You are not allowed to do this!", "error", "Permission denied");
    }
    // Database
    $max = lotto_getOpenDrawing();
    // confirm!
    confirm("Do you want to draw the winner for Drawing #{$max} now?");
    // No drawing open!
    if (!$max) {
        makeNotice("There is no open lottery. Open a new one, and try again.", "warning", "No open drawing", "index.php?action=editLotto", "[cancel]");
    }
    // Lock remaining tickets.
    $DB->query("UPDATE lotteryTickets SET owner='-2' WHERE drawing='{$max}' AND owner<'0'");
    // Pick the winner.
    $NrTickets = $DB->getCol("SELECT MAX(ticket) AS max FROM lotteryTickets WHERE drawing='{$max}'");
    $Winner = rand(1, $NrTickets[0]);
    // Set the ticket as "winner":
    $DB->query("UPDATE lotteryTickets SET isWinner='1' WHERE ticket='{$Winner}' AND drawing='{$max}'");
    // Get ID of possible winner:
    $luckyOne = $DB->getCol("SELECT owner FROM lotteryTickets WHERE isWinner='1' AND drawing='{$max}' LIMIT 1");
    $luckyOne = $luckyOne[0];
    // Calculate the potsize.
    $potSize = $DB->getCol("SELECT COUNT(id) AS count FROM lotteryTickets WHERE owner>='0' AND drawing='{$max}'");
    $potSize = $potSize[0] * 1000000;
    $potSizeOld = $potSize;
    // Get the JackPot.
    $jackPot = $DB->getCol("SELECT value FROM config WHERE name='jackpot' LIMIT 1");
    $jackPot = $jackPot[0];
    $potSize = $potSize + $jackPot;
    if ($luckyOne >= 0) {
        // We have a winner!
        $DB->query("UPDATE lotto SET winner='{$luckyOne}' WHERE drawing='{$max}' LIMIT 1");
        // Give him the money.
        $transaction = new transaction($luckyOne, 0, $potSize);
        $transaction->setReason("won the lottery");
        $transaction->commit();
        // Clean up the jackpot.
        $DB->query("DELETE FROM config WHERE name='jackpot' LIMIT 1");
    } else {
        // No winner, unclaimed ticket won :(
        $DB->query("UPDATE lotto SET winner='-1' WHERE drawing='{$max}' LIMIT 1");
        // Add to jackpot.
        $DB->query("DELETE FROM config WHERE name='jackpot' LIMIT 1");
        $DB->query("INSERT INTO config (name, value) VALUES ('jackpot','{$potSize}')");
    }
    $DB->query("UPDATE lotto SET closed='{$TIMEMARK}' WHERE drawing='{$max}' LIMIT 1");
    $DB->query("UPDATE lotto SET isOpen='0' WHERE drawing='{$max}' LIMIT 1");
    $DB->query("UPDATE lotto SET winningTicket='{$Winner}' WHERE drawing='{$max}' LIMIT 1");
    $DB->query("UPDATE lotto SET potSize='{$potSizeOld}' WHERE drawing='{$max}' LIMIT 1");
    header("Location: index.php?action=lotto");
}
Esempio n. 15
0
    $ss_account_status = 'inactive';
    $ss_rebill_status = 'inactive';
    $ss_rebill_status_text = 'Rebill Subscription Canceled/Inactive';
    if ($transInfo['td_enable_rebill']) {
        $ss_rebill_status = 'active';
    }
    if ($transInfo['td_enable_rebill']) {
        $ss_rebill_status_text = '';
    }
    if (!$transInfo['td_subscription_id']) {
        $transInfo['td_subscription_id'] = genRefId("subscription", "S");
    }
    $expDate = explode("/", $transInfo['validupto']);
    $expYear = substr($expDate[0], -2, 2);
    $expMonth = $expDate[1];
    $sql = "\r\n\tinsert into `cs_subscription`  set \r\n\t `ss_subscription_ID`='" . $transInfo['td_subscription_id'] . "',\r\n\t `ss_billing_firstname`='" . $transInfo['name'] . "',\r\n\t `ss_billing_mi`='" . $transInfo[''] . "',\r\n\t `ss_billing_lastname`='" . $transInfo['surname'] . "',\r\n\t `ss_billing_address`='" . $transInfo['address'] . "',\r\n\t `ss_billing_address2`='" . $transInfo[''] . "',\r\n\t `ss_billing_city`='" . $transInfo['city'] . "',\r\n\t `ss_billing_state`='" . $transInfo['state'] . "',\r\n\t `ss_billing_country`='" . $transInfo['country'] . "',\r\n\t `ss_billing_zipcode`='" . $transInfo['zipcode'] . "',\r\n\t `ss_billing_last_ip`='" . $transInfo['ipaddress'] . "',\r\n\t `ss_billing_card`='" . transaction::etelEncSalted($transInfo['CCnumber'], $salt) . "',\r\n\t `ss_billing_card_type`='" . $ss_billing_card_type . "',\r\n\t `ss_billing_gkard`='" . transaction::etelEncSalted($transInfo['td_gcard'], $salt) . "',\r\n\t `ss_billing_type`='" . $ss_billing_type . "',\r\n\t `ss_billing_exp`='" . date("Y-m-d", mktime(0, 0, 0, $expMonth, 1, $expYear)) . "',\r\n\t `ss_billing_cvv2`='" . transaction::etelEncSalted($transInfo['cvv'], $salt) . "',\r\n\t `ss_billing_check_account`='" . transaction::etelEncSalted($transInfo['bankaccountnumber'], $salt) . "',\r\n\t `ss_billing_check_routing`='" . transaction::etelEncSalted($transInfo['bankroutingcode'], $salt) . "',\r\n\t `ss_salt`='" . $salt . "',\r\n\t `ss_cust_email`='" . $transInfo['email'] . "',\r\n\t `ss_cust_phone`='" . $transInfo['phonenumber'] . "',\r\n\t `ss_cust_username`='" . $transInfo['td_username'] . "',\r\n\t `ss_cust_password`='" . $transInfo['td_password'] . "',\r\n\t `ss_rebill_ID`='" . $transInfo['td_rebillingID'] . "',\r\n\t `ss_rebill_next_date`='" . $transInfo['td_recur_next_date'] . "',\r\n\t `ss_rebill_amount`='" . $transInfo['chargeAmount'] . "',\r\n\t `ss_rebill_status`='" . $ss_rebill_status . "',\r\n\t `ss_rebill_status_text`='" . $ss_rebill_status_text . "',\r\n\t `ss_rebill_attempts`='" . $transInfo['td_recur_attempts'] . "',\r\n\t `ss_rebill_count`='" . $transInfo['td_recur_num'] . "',\r\n\t `ss_account_status`='" . $ss_account_status . "',\r\n\t `ss_account_start_date`='" . $transInfo['transactionDate'] . "',\r\n\t `ss_account_expire_date`='" . $transInfo['td_recur_next_date'] . "',\r\n\t `ss_transaction_id`='" . $transInfo['transactionId'] . "',\r\n\t `ss_last_rebill`='" . $transInfo['transactionDate'] . "',\r\n\t `ss_productdescription`='" . $transInfo['productdescription'] . "',\r\n\t `ss_site_ID` ='" . $transInfo['td_site_ID'] . "',\r\n\t `ss_user_ID` ='" . $transInfo['userId'] . "'\r\n\t\r\n\t";
    die($sql);
}
/*
set_time_limit(0);
	$sql="SELECT CCnumber,transactionId
FROM cs_transactiondetails
";
	$result = mysql_query($sql) or dieLog(mysql_errno().": ".mysql_error()."<BR>");
while($transInfo = mysql_fetch_assoc($result))
{
	if( isset($unique[$transInfo['CCnumber']])) $unique[$transInfo['CCnumber']]++;
	else $unique[$transInfo['CCnumber']]=0;
	$sql = "Update cs_transactiondetails set td_non_unique='".$unique[$transInfo['CCnumber']]."' where transactionId = ".$transInfo['transactionId'];
	//die($sql);
	mysql_query($sql) or die(mysql_error());
Esempio n. 16
0
<?php

include "header.php";
include "subheader.php";
$transaction = new transaction();
$user = new user();
$user_data = $user->getbyid($user->getloggedid());
$balance = $transaction->balance();
if ($user_data['type'] == "seeker") {
    ?>
<script>
function selectprovider(pid)
{
	providerid=document.getElementById('provider_'+pid).value;
	loadPage('/ajax/project/selectprovider.php?projectid='+pid+'&providerid='+providerid);
}

function cancelprovider(pid)
{
	loadPage('/ajax/project/cancelprovider.php?projectid='+pid);
}


</script>
<div style="height:20px; clear:both;"></div>
<strong>List of All Projects You have Posted</strong>
<?php 
    $projectac = new project();
    $projectlist = $projectac->getAllProjectList();
    $objcommon = new common();
    if (is_array($projectlist)) {
Esempio n. 17
0
     $db->query($query);
     if ($db->next_record()) {
         $fromTfID = $db->f("tfID");
     } else {
         $msg .= "<b>Warning: Could not find active TF for account '{$account}'</b><br>";
         continue;
     }
     // Check for an existing transaction
     $query = prepare("SELECT * FROM transaction WHERE transactionType='expense' AND transactionDate='%s' AND product='%s' AND amount > %0.3f and amount < %0.3f", $date, $memo, $amount - 0.004, $amount + 0.004);
     $db->query($query);
     if ($db->next_record()) {
         $msg .= "Warning: Expense '{$memo}' on {$date} already exixsts.<br>";
         continue;
     }
     // Create a transaction object and then save it
     $transaction = new transaction();
     $transaction->set_value("companyDetails", $description);
     $transaction->set_value("product", $memo);
     $transaction->set_value("amount", $amount);
     $transaction->set_value("status", "pending");
     $transaction->set_value("expenseFormID", "0");
     $transaction->set_value("fromTfID", $fromTfID);
     $transaction->set_value("tfID", config::get_config_item("mainTfID"));
     $transaction->set_value("quantity", 1);
     $transaction->set_value("invoiceItemID", "0");
     $transaction->set_value("transactionType", "expense");
     $transaction->set_value("transactionDate", "{$date}");
     $transaction->save();
     $msg .= "Expense '{$memo}' on {$date} saved.<br>";
 }
 $TPL["msg"] = $msg;
Esempio n. 18
0
    // Get total inputs
    $balance = DB::queryFirstField("SELECT sum(amount) FROM coin_inputs WHERE wallet_id = %d AND is_spent = 0", $_POST['wallet_id']);
    $total_inputs = DB::queryFirstField("SELECT count(*) FROM coin_inputs WHERE wallet_id = %d AND is_spent = 0", $_POST['wallet_id']);
    $balance -= $total_inputs * $config['btc_txfee'];
    // Generate address from new wallet
    $address = $bip32->generate_address($new_wallet_id);
    $outputs = array($address => $balance);
    // Gather all unspent inputs
    $client = new rawtx();
    $inputs = $client->gather_inputs($_POST['wallet_id'], $balance, $privkeys);
    // Create transaction
    $transaction = $client->create_transaction($_POST['wallet_id'], $inputs, $outputs);
    // Sign transaction
    $signed_tx = $client->sign_transaction($transaction, $inputs);
    // Send transaction
    $client = new transaction();
    $client->send_transaction($signed_tx);
    // Update wallets
    DB::query("UPDATE coin_wallets SET status = 'inactive' WHERE id = %d", $_POST['wallet_id']);
    DB::query("UPDATE coin_inputs SET is_spent = 1 WHERE wallet_id = %d", $_POST['wallet_id']);
    // User message
    $balance = fmoney_coin($balance);
    $template->add_message("Successfully transferred your wallet to the new BIP32 keys.  A total of {$balance} BTC was transferred to your new BIP32 key(s), and your new wallet ID# is {$new_wallet_id}.");
}
// Get wallets
$first = true;
$bip32_key_fields = '';
$bip32_public_key_fields = '';
$required_sigs = 0;
$total_sigs = 0;
$wallet_id = 0;
Esempio n. 19
0
function main($mainmsg)
{
    gio::output(config::$walletMessage);
    if (account::isCreated()) {
        $serv = popen("service.ecsh", 'r');
    }
    $net = new Gnet();
    $inerr = 0;
    while (true) {
        $inmsg = array();
        if (account::isCreated()) {
            $inmsg["d"] = "Destroy Account";
            $dmsg = $mainmsg + $inmsg;
        } else {
            $inmsg["c"] = "Create Bank Wallet";
            $dmsg = $inmsg;
        }
        $dmsg["x"] = "Exit";
        if (!$inerr) {
            gio::output();
            foreach ($dmsg as $k => $v) {
                $k = strtoupper($k);
                gio::output("{$k} - {$v}");
            }
            gio::output();
            $msg = "Enter your choice and press enter";
        }
        $inerr = 0;
        $c = gio::input("{$msg}");
        if (!array_key_exists($c, $dmsg)) {
            $c = null;
        }
        switch ($c) {
            case 1:
                $a = account::address();
                gio::output("Bank's account address is: {$a}");
                break;
            case 2:
                $n = account::coins(config::$accountId, $coins);
                gio::output("You have {$n} coins");
                if ($n && gio::confirm("Do you wish to see their Id's")) {
                    foreach ($coins as $val => $ccs) {
                        foreach ($ccs as $i => $coin) {
                            gio::output("Ecash ID: {$i}");
                            foreach ($coin as $id => $c) {
                                if ($id == "token") {
                                    $c = md5($c);
                                }
                                if ($id == "hash") {
                                    $c = sha1($c);
                                }
                                if ($id == "mined") {
                                    $c = date(config::$timeFormat, $c);
                                }
                                gio::output("{$id}=>{$c}");
                            }
                            gio::output();
                        }
                    }
                }
                break;
            case 3:
                $m = transaction::prequest();
                gio::output($m[1]);
                break;
            case 4:
                transaction::pgrant();
                break;
            case 5:
                $acc = gio::input("Enter the wallet number [EMPTY for bank's self]");
                $o = gio::input("Enter the order id [EMPTY for all]");
                $f = null;
                if (gio::confirm("Do you want to create a file on your desktop")) {
                    do {
                        $f = gio::input("Enter the file name");
                    } while (!$f);
                }
                transaction::reports($o, $acc, $f);
                break;
            case 6:
                $m = transaction::clearrequests(null, null);
                gio::output($m[1]);
                break;
            case 7:
                account::merckey(gio::input("Enter the name of the file to write to your desktop"));
                break;
            case "c":
                $serv = account::create();
                break;
            case "d":
                gio::output("This action will irreversibly destroy your wallet and its contents");
                if (gio::confirm("Are you sure you want to destroy your account")) {
                    account::destroy();
                }
                break;
            case "x":
                @$net->send('shutdown');
                $net = null;
                if ($serv) {
                    $ret = pclose($serv);
                }
                break 2;
            default:
                $inerr = 1;
                $msg = "Retry";
        }
        if (!$inerr) {
            gio::output("\n\n\n");
        }
    }
    if (isset($ret) && $ret != 0) {
        gio::output("An error occured while exiting...");
    }
    gio::output(config::$exitMessage);
    sleep(3);
}
Esempio n. 20
0
<?php

session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . "/common/class/common.class.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/common/class/transaction.class.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/common/class/user.class.php";
$objuser = new user();
$objuser->checkLoginAjax();
$objtransaction = new transaction();
$balance = $objtransaction->checkbalance();
if ($balance > 0) {
    ?>
<h1 align="center">Money Withdraw Request</h1><br>
<h3>Select Mode</h3><br>
<input type="radio" value="paypal" name="withdrawmode" onClick="showDiv('div_withdrawpaypal'); hideDiv('div_withdrawbankwire');"> Withdraw Through Paypal <br><br>
<input type="radio" value="bankwire" name="withdrawmode" onClick="showDiv('div_withdrawbankwire'); hideDiv('div_withdrawpaypal');"> Withdraw Through Bankwire
<div id ="div_withdrawpaypal" style="display:none;">
<h1 align="center">Money Withdrawal through Paypal</h1>
<form method="post" action="withdrawpaypal.php" onsubmit="if(validateForm(this)) submitFormOnFloat(this); return false;">
<table width="100%">
<tr>
<td width="30%"></td>
<td width="70%"></td>
</tr>
   

<tr>
<td><strong>Email</strong></td>
<td><input name="email" value="" type="text" class="vldemail vldnoblank">
<span class="checkStatus"></span> 
</td>
Esempio n. 21
0
function show_all_exp($template)
{
    global $TPL;
    global $expenseForm;
    global $db;
    global $transaction_to_edit;
    if ($expenseForm->get_id()) {
        if ($_POST["transactionID"] && ($_POST["edit"] || is_object($transaction_to_edit) && $transaction_to_edit->get_id())) {
            // if edit is clicked OR if we've rejected changes made to something so are still editing it
            $query = prepare("SELECT * FROM transaction WHERE expenseFormID=%d AND transactionID<>%d ORDER BY transactionID DESC", $expenseForm->get_id(), $_POST["transactionID"]);
        } else {
            $query = prepare("SELECT * FROM transaction WHERE expenseFormID=%d ORDER BY transactionID DESC", $expenseForm->get_id());
        }
        $db->query($query);
        while ($db->next_record()) {
            $transaction = new transaction();
            $transaction->read_db_record($db);
            $transaction->set_values();
            $transaction->get_value("quantity") and $TPL["amount"] = $transaction->get_value("amount") / $transaction->get_value("quantity");
            $TPL["lineTotal"] = $TPL["amount"] * $transaction->get_value("quantity");
            $tf = new tf();
            $tf->set_id($transaction->get_value("fromTfID"));
            $tf->select();
            $TPL["fromTfIDLink"] = $tf->get_link();
            $tf = new tf();
            $tf->set_id($transaction->get_value("tfID"));
            $tf->select();
            $TPL["tfIDLink"] = $tf->get_link();
            $projectID = $transaction->get_value("projectID");
            if ($projectID) {
                $project = new project();
                $project->set_id($transaction->get_value("projectID"));
                $project->select();
                $TPL["projectName"] = $project->get_value("projectName");
            }
            if ($transaction->get_value("fromTfID") == config::get_config_item("expenseFormTfID")) {
                $TPL['expense_class'] = "loud";
            } else {
                $TPL['expense_class'] = "";
            }
            include_template($template);
        }
    }
}
Esempio n. 22
0
 function onDoLoginBtn($info)
 {
     $u = new user("");
     $u->login($info['email'], $info['password']);
     switch ($u->loggedIn) {
         case -1:
             $this->msg = "Incorrect Password";
             $this->_bookframe("frmMain");
             break;
         case -2:
             $this->msg = "Account does not exist";
             $this->_bookframe("frmMain");
             break;
         case 1:
             $this->msg = "";
             $t = new transaction("");
             $this->balance = $t->backBalance(osBackUserID());
             $this->_bookframe("frmWelcome");
             break;
         case 2:
             $this->msg = "";
             $this->email = $info['email'];
             $this->password = $info['password'];
             $this->_bookframe("frmValidation");
             break;
     }
 }
Esempio n. 23
0
function show_new_transaction($template)
{
    global $timeSheet;
    global $TPL;
    global $db;
    global $percent_array;
    if ($timeSheet->get_value("status") == "invoiced" && $timeSheet->have_perm(PERM_TIME_INVOICE_TIMESHEETS)) {
        $tf = new tf();
        $options = $tf->get_assoc_array("tfID", "tfName");
        $TPL["tf_options"] = page::select_options($options, $none);
        $transactionType_options = transaction::get_transactionTypes();
        $TPL["transactionType_options"] = page::select_options($transactionType_options);
        $status_options = array("pending" => "Pending", "approved" => "Approved", "rejected" => "Rejected");
        $TPL["status_options"] = page::select_options($status_options);
        $TPL["transaction_timeSheetID"] = $timeSheet->get_id();
        $TPL["transaction_transactionDate"] = date("Y-m-d");
        $TPL["transaction_product"] = "";
        $TPL["transaction_buttons"] = '
            <button type="submit" name="transaction_save" value="1" class="save_button">Add<i class="icon-plus-sign"></i></button>
      ';
        $TPL["percent_dropdown"] = page::select_options($percent_array, $empty);
        include_template($template);
    }
}
Esempio n. 24
0
$tf->set_id($transactionRepeat->get_value("tfID"));
if ($tf->select() && !$tf->get_value("tfActive")) {
    $TPL["message_help"][] = "This expense is allocated to an inactive TF. It will not create transactions.";
}
$tf = new tf();
$tf->set_id($transactionRepeat->get_value("fromTfID"));
if ($tf->select() && !$tf->get_value("tfActive")) {
    $TPL["message_help"][] = "This expense is sourced from an inactive TF. It will not create transactions.";
}
$m = new meta("currencyType");
$currencyOps = $m->get_assoc_array("currencyTypeID", "currencyTypeID");
$TPL["currencyTypeOptions"] = page::select_options($currencyOps, $transactionRepeat->get_value("currencyTypeID"));
$TPL["tfOptions"] = page::select_options($q, $transactionRepeat->get_value("tfID"));
$TPL["fromTfOptions"] = page::select_options($q, $transactionRepeat->get_value("fromTfID"));
$TPL["basisOptions"] = page::select_options(array("weekly" => "weekly", "fortnightly" => "fortnightly", "monthly" => "monthly", "quarterly" => "quarterly", "yearly" => "yearly"), $transactionRepeat->get_value("paymentBasis"));
$TPL["transactionTypeOptions"] = page::select_options(transaction::get_transactionTypes(), $transactionRepeat->get_value("transactionType"));
if (is_object($transactionRepeat) && $transactionRepeat->get_id() && $current_user->have_role("admin")) {
    $TPL["adminButtons"] .= '
  <select name="changeTransactionStatus"><option value="">Transaction Status<option value="approved">Approve<option value="rejected">Reject<option value="pending">Pending</select>
  ';
}
if (is_object($transactionRepeat) && $transactionRepeat->get_id() && $transactionRepeat->get_value("status") == "pending") {
    $TPL["message_help"][] = "This Repeating Expense will only create Transactions once its status is Approved.";
} else {
    if (!$transactionRepeat->get_id()) {
        $TPL["message_help"][] = "Complete all the details and click the Save button to create an automatically Repeating Expense";
    }
}
$transactionRepeat->get_value("status") and $TPL["statusLabel"] = " - " . ucwords($transactionRepeat->get_value("status"));
$TPL["taxName"] = config::get_config_item("taxName");
$TPL["main_alloc_title"] = "Create Repeating Expense - " . APPLICATION_NAME;
Esempio n. 25
0
 function create_transaction($amount, $tfID, $status)
 {
     $transaction = new transaction();
     $invoice = $this->get_foreign_object("invoice");
     $this->currency = $invoice->get_value("currencyTypeID");
     $db = new db_alloc();
     // If there already a transaction for this invoiceItem, use it instead of creating a new one
     $q = prepare("SELECT * FROM transaction WHERE invoiceItemID = %d ORDER BY transactionCreatedTime DESC LIMIT 1", $this->get_id());
     $db->query($q);
     if ($db->row()) {
         $transaction->set_id($db->f("transactionID"));
         $transaction->select();
     }
     // If there already a transaction for this timeSheet, use it instead of creating a new one
     if ($this->get_value("timeSheetID")) {
         $q = prepare("SELECT * \n                      FROM transaction \n                     WHERE timeSheetID = %d \n                       AND fromTfID = %d\n                       AND tfID = %d\n                       AND amount = %d\n                       AND (invoiceItemID = %d or invoiceItemID IS NULL)\n                  ORDER BY transactionCreatedTime DESC LIMIT 1\n                         ", $this->get_value("timeSheetID"), config::get_config_item("inTfID"), $tfID, page::money($this->currency, $amount, "%mi"), $this->get_id());
         $db->query($q);
         if ($db->row()) {
             $transaction->set_id($db->f("transactionID"));
             $transaction->select();
         }
     }
     $transaction->set_value("amount", $amount);
     $transaction->set_value("currencyTypeID", $this->currency);
     $transaction->set_value("fromTfID", config::get_config_item("inTfID"));
     $transaction->set_value("tfID", $tfID);
     $transaction->set_value("status", $status);
     $transaction->set_value("invoiceID", $this->get_value("invoiceID"));
     $transaction->set_value("invoiceItemID", $this->get_id());
     $transaction->set_value("transactionDate", $this->get_value("iiDate"));
     $transaction->set_value("transactionType", "invoice");
     $transaction->set_value("product", sprintf("%s", $this->get_value("iiMemo")));
     $this->get_value("timeSheetID") && $transaction->set_value("timeSheetID", $this->get_value("timeSheetID"));
     $transaction->save();
 }
Esempio n. 26
0
function lotto_buyTickets()
{
    // Set some needed variables.
    global $DB;
    global $MySelf;
    $ID = $MySelf->getID();
    $myMoney = getCredits($ID);
    $affordable = floor($myMoney / 1000000);
    if (!getConfig("lotto")) {
        makeNotice("Your CEO disabled the Lotto module, request denied.", "warning", "Lotto Module Offline");
    }
    // Get my credits
    $MyStuff = $DB->getRow("SELECT lottoCredit, lottoCreditsSpent FROM users WHERE id='" . $MySelf->getID() . "'");
    $Credits = $MyStuff[lottoCredit];
    $CreditsSpent = $MyStuff[lottoCreditsSpent];
    // User submited this form already!
    if ($_POST[check]) {
        numericCheck($_POST[amount], 0, $affordable);
        if ($_POST[amount] == 0) {
            makeNotice("You cannot buy zero tickets.", "warning", "Too few tickets.", "index.php?action=lotto", "[whoops]");
        }
        confirm("Please authorize the transaction of " . number_format($_POST[amount] * 1000000, 2) . " ISK in order to buy {$_POST['amount']} lotto credits.");
        // Get the old ticket count, and add the new tickets on top of those.
        $oldCount = $DB->getCol("SELECT lottoCredit FROM users WHERE id='{$ID}' LIMIT 1");
        $newcount = $oldCount[0] + $_POST[amount];
        // Update the database to reflect the new ticket count.
        $check = $DB->query("UPDATE users SET lottoCredit='{$newcount}' WHERE id='{$ID}' LIMIT 1");
        // Check that we were successful.
        if ($DB->affectedRows() != 1) {
            makeNotice("I was unable to add {$newcount} tickets to {$user} stack of {$count} tickets! Danger will robonson, danger!", "error", "Unable to comply.");
        }
        // Make him pay!
        global $TIMEMARK;
        $transaction = new transaction($ID, 1, $_POST[amount] * 1000000);
        $transaction->setReason("lotto credits bought");
        if ($transaction->commit()) {
            // all worked out!
            makeNotice("Your account has been charged the amount of " . number_format($_POST[amount] * 1000000, 2) . " ISK.", "notice", "Credits bought", "index.php?action=lotto", "[OK]");
        } else {
            // We were not successfull
            makeNotice("I was unable to add {$newcount} tickets to {$user} stack of {$count} tickets! Danger will robonson, danger!", "error", "Unable to comply.");
        }
    }
    // Prepare the drop-down menu.
    if ($affordable >= 1) {
        $ddm = "<select name=\"amount\">";
        for ($i = 1; $i <= $affordable; $i++) {
            if ($i == 1) {
                $ddm .= "<option value=\"{$i}\">Buy {$i} tickets</option>";
            } else {
                $ddm .= "<option value=\"{$i}\">Buy {$i} tickets</option>";
            }
        }
        $ddm .= "</select>";
    } else {
        // Poor user.
        $ddm = "You can not afford any credits.";
    }
    // Create the table.
    $table = new table(2, true);
    $table->addHeader(">> Buy lotto credits");
    $table->addRow();
    $table->addCol("Here you can buy lotto tickets for 1.000.000,00 ISK each. " . "Your account currently holds " . number_format($myMoney, 2) . " ISK, so " . "you can afford {$affordable} tickets. Please choose the amount of credits you wish " . "to buy.", array("colspan" => 2));
    $table->addRow();
    $table->addCol("Your credits:");
    $table->addCol($Credits);
    $table->addRow();
    $table->addCol("Total spent credits:");
    $table->addCol($CreditsSpent);
    $table->addRow();
    $table->addCol("Purchase this many credits:");
    $table->addCol($ddm);
    $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Buy credits\">");
    $table->addRow("#060622");
    $table->addCol("[<a href=\"index.php?action=lotto\">Cancel request</a>]", array("colspan" => 2));
    // Add some more html form stuff.
    $html = "<h2>Buy Lotto credits</h2>";
    $html .= "<form action=\"index.php\" method=\"POST\">";
    $html .= $table->flush();
    $html .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
    $html .= "<input type=\"hidden\" name=\"action\" value=\"lottoBuyCredits\">";
    $html .= "</form>";
    // Return the mess we made.
    return $html;
}
Esempio n. 27
0
 public function __construct($parts = array())
 {
     // Initialize
     global $config, $template;
     // Set variables
     if ($config['is_setup'] == 1 && preg_match("/^admin/", trim($_GET['route'], '/'))) {
         $panel = 'admin';
         $require_login = true;
     } else {
         $panel = 'public';
         $require_login = false;
     }
     // Check IP restrictions
     if ($panel == 'admin' && isset($config['ipallow']) && $config['ipallow'] != '') {
         $ok = false;
         $ips = explode("\n", $config['ipallow']);
         foreach ($ips as $ip) {
             if (preg_match("/^{$ip}/", $_SERVER['REMOTE_ADDR'])) {
                 $ok = true;
                 break;
             }
         }
         if ($ok === false) {
             echo "Access dened by IP restrictions.";
             exit(0);
         }
     }
     // Continue setup, if needed
     if (DBNAME == '' && isset($_POST['submit']) && $_POST['submit'] == tr('Continue to Next Step')) {
         // Initialize
         $template = new template('admin/setup/first_time2');
         require_once SITE_PATH . '/data/lib/sqlparser.php';
         // Check database connection
         if (!mysqli_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname'], $_POST['dbport'])) {
             $template->add_message("Unable to connect to mySQL database using information supplied.  Please double check the mySQL information, and try again.", 'error');
         }
         if (!is_writeable(SITE_PATH . '/data/config.php')) {
             $template->add_message("Unable to write to file at /data/config.php.  Please change file permissions appropriately, and reload the page.", 'error');
         }
         if (!is_writeable(SITE_PATH . '/data/backups')) {
             $template->add_message("Unable to write to directory at /data/backups/.  Please change directory permissions appropriately, and reload the page.", 'error');
         }
         if (!is_writeable(SITE_PATH . '/data/log')) {
             $template->add_message("Unable to write to directory at /data/log/.  Please change directory permissions appropriately, and reload the page.", 'error');
         }
         if (!is_writeable(SITE_PATH . '/data/tpl_c')) {
             $template->add_message("Unable to write to directory at /data/tpl_c/.  Please change directory permissions appropriately, and reload the page.", 'error');
         }
         // Check for errors
         if ($template->has_errors == 1) {
             $template->route = 'admin/setup/first_time';
             echo $template->parse();
             exit(0);
         }
         // Define MeekroDB settings
         DB::$dbName = $_POST['dbname'];
         DB::$user = $_POST['dbuser'];
         DB::$password = $_POST['dbpass'];
         DB::$host = $_POST['dbhost'];
         DB::$port = $_POST['dbport'];
         // Parse sql
         $sql_lines = SqlParser::parse(file_get_contents(SITE_PATH . '/data/sql/install.sql'));
         foreach ($sql_lines as $line) {
             DB::query($line);
         }
         // Save config.php file
         $conf = "<?php\n";
         $conf .= "define('DBNAME', '" . $_POST['dbname'] . "');\n";
         $conf .= "define('DBUSER', '" . $_POST['dbuser'] . "');\n";
         $conf .= "define('DBPASS', '" . $_POST['dbpass'] . "');\n";
         $conf .= "define('DBHOST', '" . $_POST['dbhost'] . "');\n";
         $conf .= "define('DBPORT', '" . $_POST['dbport'] . "');\n";
         $conf .= "define('COOKIE_NAME', '" . generate_random_string(6) . "');\n";
         $conf .= "define('ENCRYPT_PASS', '" . generate_random_string(32) . "');\n";
         $conf .= "define('TESTNET', 0);\n";
         $conf .= "?>\n";
         // Save config file
         file_put_contents(SITE_PATH . '/data/config.php', $conf);
         // Parse template
         echo $template->parse();
         exit(0);
     } elseif ($config['is_setup'] != '1' && isset($_POST['_setup_step']) && $_POST['_setup_step'] == '2') {
         // Initialize
         $template = new template('admin/setup/first_time3');
         if (strlen($_POST['username']) < 4) {
             $template->add_message('Administrator username must be at least 4 characters in length.', 'error');
         }
         // Create user
         $user = new user();
         $user->create(1);
         // Update config vars
         update_config_var('site_name', $_POST['site_name']);
         update_config_var('company_name', $_POST['company_name']);
         // Check for errors
         if ($template->has_errors == 1) {
             $template->route = 'admin/setup/first_time2';
         } else {
             // Login
             $auth = new auth();
             $auth->login('admin', false);
         }
         echo $template->parse();
         exit(0);
     } elseif ($config['is_setup'] != '1' && isset($_POST['_setup_step']) && $_POST['_setup_step'] == '3') {
         // Initialize
         $template = new template('admin/setup/first_time4');
         // Update config vars
         update_config_var('btc_rpc_host', $_POST['btc_rpc_host']);
         update_config_var('btc_rpc_user', $_POST['btc_rpc_user']);
         update_config_var('btc_rpc_pass', $_POST['btc_rpc_pass']);
         update_config_var('btc_rpc_port', $_POST['btc_rpc_port']);
         // Test connection
         $client = new transaction();
         if (!$client->get_info()) {
             $template->route = 'admin/setup/first_time3';
             $template->add_message('Unable to connect to RPC using the provided settings.  Please check the connection information, restart bitcoind, and try again.  If you have just started bitcoind for the first time, you will need to wait a while for all blocks to download before continuing.', 'error');
             $template->parse();
             exit(0);
         }
         // Parse template
         echo $template->parse();
         exit(0);
         // Complete setup, if needed
     } elseif ($config['is_setup'] != '1' && isset($_POST['_setup_step']) && $_POST['_setup_step'] == '4') {
         // Initialize
         $template = new template('admin/setup/first_time5');
         // Update config vars
         update_config_var('is_setup', '1');
         // Get exchange date
         $rate = get_coin_exchange_rate($config['currency']);
         if ($rate != 0) {
             update_config_var('exchange_rate', $rate);
         }
         // Add wallet
         $bip32 = new bip32();
         $bip32->add_wallet();
         // Display template
         if ($template->has_errors != 1) {
             //$template->add_message("Successfully completed first time setup.");
         }
         echo $template->parse();
         exit(0);
     }
     // Check if setup
     if ($config['is_setup'] == 0) {
         $template = new template('admin/setup/first_time');
         echo $template->parse();
         exit(0);
     }
     // Check login
     $auth = new auth();
     if ($userid = $auth->check_login($panel, $require_login)) {
         define('LOGIN', true);
         $GLOBALS['userid'] = $userid;
     } else {
         define('LOGIN', false);
         $GLOBALS['userid'] = 0;
     }
     // Check admin permission, if needed
     if ($panel == 'admin') {
         $group_id = DB::queryFirstField("SELECT group_id FROM users WHERE id = %d", $GLOBALS['userid']);
         if ($group_id != 1) {
             trigger_error("You do not have permission to access this area.", E_USER_ERROR);
         }
     }
     // Parse template
     $template = new template();
     echo $template->parse();
     // Exit
     exit(0);
 }
Esempio n. 28
0
function main($mainmsg)
{
    gio::output(config::$walletMessage);
    $serv = popen("service.ecsh", 'r');
    $net = new Gnet();
    $inerr = 0;
    while (true) {
        if (!$inerr) {
            gio::output();
            foreach ($mainmsg as $k => $v) {
                gio::output("{$k} - {$v}");
            }
            gio::output();
            $msg = "Enter your choice and press enter";
        }
        $inerr = 0;
        $c = gio::input("{$msg}");
        switch ($c) {
            case 1:
                $tid = gio::input("Enter the transaction Id");
                $st = transaction::status($tid);
                if (!$st) {
                    gio::output("Transaction reference '{$tid}' not found");
                } else {
                    $rpt['order id'] = $st['order id'];
                    $rpt['order amount'] = $st['amount'];
                    $rpt['from'] = $st['client'];
                    $rpt['to'] = $st['merchant'];
                    $rpt['transaction time'] = date(config::$timeFormat, $st['acknowledgement']['completed']);
                    $rpt['description'] = $st['description'];
                    $rpt['transaction reference'] = $st['acknowledgement']['id'];
                    $rpt['response code'] = $st['acknowledgement']['status'];
                    $rpt['response message'] = $st['acknowledgement']['message'];
                    $rpt['ecash value tendered'] = $st['acknowledgement']['amount'];
                    $rpt['ecash tendered'] = $st['acknowledgement']['ecashids'];
                    gio::display($rpt);
                    if (gio::confirm("Do you want to save the report to a file")) {
                        $dest = gio::input("Enter full path to the file");
                        gio::display($rpt, $x);
                        if (!gio::saverawfile(join("\r\n", $x), $dest)) {
                            gio::output("Could not save the report to {$dest}");
                        } else {
                            gio::output("Report successfully saved to {$dest}");
                        }
                        unset($x);
                    }
                }
                break;
            case 2:
                $maxallowed = 1000;
                $v = gio::input("What value of eCash do you wish to mine", "integer");
                $n = gio::input("How many eCashes do you wish to mine", "integer");
                $c = mine::countcoins($null);
                unset($null);
                if ($n > $maxallowed || $c + $n > $maxallowed) {
                    $rem = $maxallowed - $c;
                    gio::output("You can not mine above {$maxallowed} eCashes!");
                    gio::output("You can mine {$rem} more eCashes!");
                } else {
                    $res = mine::coins($n, $v);
                    if ($res) {
                        gio::output("You have successfully mined {$n} eCashes.");
                        gio::output("Mining process took " . Tools::arrtostr($res, ", "));
                    } else {
                        gio::output("Mining operation failed!");
                    }
                }
                break;
            case 3:
                $n = mine::countcoins($coins);
                gio::output("A total of {$n} eCash value is available");
                if ($n && gio::confirm("Do you wish to see their Id's")) {
                    foreach ($coins as $val => $ccs) {
                        foreach ($ccs as $i => $coin) {
                            gio::output("Ecash ID: {$i}");
                            foreach ($coin as $id => $c) {
                                if ($id == "token") {
                                    $c = md5($c);
                                }
                                if ($id == "hash") {
                                    $c = sha1($c);
                                }
                                if ($id == "mined") {
                                    $c = date(config::$timeFormat, $c);
                                }
                                gio::output("{$id}=>{$c}");
                            }
                            gio::output();
                        }
                    }
                }
                break;
            case 4:
                $to = gio::input("Enter the wallet address");
                $amt = gio::input("Enter the amount to give");
                $res = account::give($to, $amt);
                break;
            case "x":
                $net->connect(config::$serviceAddress, intval(config::$servicePort));
                $net->send("shutdown");
                if ($serv) {
                    $ret = pclose($serv);
                }
                break 2;
            default:
                $inerr = 1;
                $msg = "Retry";
        }
        if (!$inerr) {
            gio::output("\n\n\n");
        }
    }
    if (isset($ret) && $ret != 0) {
        gio::output("An error occured while exiting...");
    }
    gio::output(config::$exitMessage);
    sleep(3);
}
Esempio n. 29
0
			<th>Datum</th>
		</tr>
		</thead>
		<?php 
if (!empty($transactions)) {
    ?>
			<?php 
    foreach ($transactions as $transaction) {
        ?>
				<tr>
					<td><?php 
        echo $transaction->name;
        ?>
</td>
					<td><?php 
        echo transaction::type_translate($transaction->type);
        ?>
</td>
					<td><?php 
        echo $transaction->amount;
        ?>
</td>
					<td><?php 
        echo $transaction->extra_cost;
        ?>
</td>
					<td><?php 
        echo $transaction->datetime;
        ?>
</td>
				</tr>
Esempio n. 30
0
 public static function process($msg)
 {
     $res = "";
     $status = 1;
     $sender = "";
     $umsg = GsonCrypt::unseal($msg);
     if (!$umsg) {
         $ex = Gmsg::extract($msg);
         if ($ex && is_array($ex)) {
             $umsg = $msg;
         } else {
             $status = 0;
             $res = "Unable to decode the message";
         }
     }
     if ($umsg) {
         $parts = self::extract($umsg);
         $action = $parts["op"];
         $mess = $parts["msg"];
         $recipient = $parts["recipient"];
         $sender = $parts["sender"];
         if (isset($parts["bank"])) {
             $sender = $parts["bank"] . "_{$sender}";
         }
         if (strtolower($recipient) != strtolower(config::$accountId)) {
             $status = 0;
             $res = config::$accountId . " is not the intended recipient [{$recipient}]";
             $rply = Gmsg::create(array("status" => $status, "response" => $res));
         } else {
             switch ($action) {
                 case "notification":
                     $r = transaction::notification($mess, $sender);
                     $m = Gmsg::create(array("status" => $r[0], "response" => $r[1]));
                     $rply = GsonCrypt::sign($m);
                     break;
                 case "revokecert":
                     if (!$sender) {
                         $status = 0;
                         $res = "The sender is unknown";
                     } else {
                         $res = "";
                         $ret = array("status" => $status, "response" => $res, "account" => $sender);
                         $rply = self::create($ret);
                         $rply = GsonCrypt::seal("{$rply}", "{$sender}");
                         @unlink(GsonCrypt::getkey($sender));
                         /* Buggy: Verify the sender first*/
                     }
                     break;
                 case "signcert":
                     $k = GsonCrypt::getkey("{$sender}");
                     if (file_exists($k)) {
                         $status = 2;
                         $res = "This account already exist!";
                     } else {
                         $res = GsonCrypt::signcert($sender, $mess);
                         if (!$res) {
                             $status = 0;
                             $res = "An error occured while signing the certificate.";
                         }
                     }
                     break;
                 case "reverb":
                     $res = $mess;
                     break;
                 default:
                     $status = 0;
                     $res = "Invalid Operation!";
             }
         }
     }
     if (!isset($rply)) {
         $ret = array("status" => $status, "response" => $res, "account" => $sender);
         $rply = self::create($ret);
         $rply = $sender ? GsonCrypt::seal("{$rply}", "{$sender}") : "{$rply}";
     }
     return $rply;
 }