示例#1
0
 //set session for login
 session_start();
 $_SESSION["user"]["uid"] = $db_array[0]['uid'];
 $_SESSION["user"]["title"] = $db_array[0]['title'];
 $_SESSION["user"]["name_first"] = $db_array[0]['name_first'];
 $_SESSION["user"]["name_middle"] = $db_array[0]['name_middle'];
 $_SESSION["user"]["name_last"] = $db_array[0]['name_last'];
 $_SESSION["user"]["name_nickname"] = $db_array[0]['name_nickname'];
 $_SESSION["user"]["email"] = $db_array[0]['email'];
 $_SESSION["user"]["password"] = $db_array[0]['password'];
 $_SESSION["user"]["type"] = $db_array[0]['type'];
 //record user's ip and login time
 $sql = 'UPDATE user SET lastlogin_ip="' . $_SERVER['REMOTE_ADDR'] . '", lastlogin_time="' . time_db(time_this()) . '" WHERE ' . $login_by . '="' . $id . '" and password="******"';
 db_query($sql);
 //if ticked "remember me" then set cookie for next auto-login
 if (receive('remember')) {
     cookie_set('id', $id);
     cookie_set('password', $password);
 }
 //if login by cookie, back to original page
 if (isset($_GET['cookie'])) {
     //back to the page before redirect to here by HTTP_REFERER
     if (isset($_SERVER['HTTP_REFERER'])) {
         $url = $_SERVER['HTTP_REFERER'];
     } elseif (isset($_SESSION["system"]["login_from"])) {
         $url = $_SESSION["system"]["login_from"];
     } else {
         $url = $after_login_redirect;
     }
 } else {
     $url = $after_login_redirect;
示例#2
0
文件: manifest.php 项目: bruce28/vip
//here we initialize one more time global variables that are gone to pass them to argument of generate manifest counter
//commented only visible , lest count each one
//$SIZE_OF_MANIFEST=$SIZE_VISIBLE;
$SIZE_OF_MANIFEST = $SIZE_OF_MANIFEST;
generate_default_manifest_counter($SIZE_OF_MANIFEST);
$manifest_reg_id = read_manifest_id($FLAG_MANIFEST_UNQ_NUMBER);
if (!empty($manifest_reg_id)) {
    $_SESSION['MANIFEST_REG_ID'] = $manifest_reg_id;
}
//lets keep from no on all the time current id manifest id, tha we use to add one
//here we should have a wrapper to extract session id to local variable..check it state and compare throu dbi api. manitor the states
// echo "SESSION: MANIFEST_REG: ".$_SESSION['MANIFEST_REG_ID'];
$qtty_digit = 0;
construct_table_draw_table($sql_load);
//here probably is generated SIZEOF MANIFEST VISIBLE
process_received(receive());
?>
    
                
                
            </div>
             </div>
            
            
            <div data-role="footer"
                 data-position="fixed"
                 >
             <div data-role="navbar">   
                 <a href="manifest.php" data-role="button">All</a>   
                 <a href="manifest.php?type=1" data-role="button">Electrics</a>   
             <a href="manifest.php?type=2" data-role="button">Material</a>
示例#3
0
function transfer($details, $fromAccount = true)
{
    // The sending account and the database:
    global $verifiedAccount, $dz;
    if (!isset($details['ToAddress'])) {
        // Get an address for the username (inline updates details):
        getAddress($details);
    }
    // Get the commodity:
    $commodity = $details['Commodity'];
    // The amount too:
    $amount = $details['Amount'];
    // Get the to address:
    $toAddress = $details['ToAddress'];
    // Is this an internal transfer? (I.e. within this same bank):
    $internalTransfer = !$toAddress;
    $balance = null;
    // Is it coming from the bank itself, or from an account?
    if ($fromAccount) {
        // Find a suitable 'from' balance.
        // (There should only ever be one. Just in case though, we don't want to lock more than one row):
        $balance = $dz->get_row('select `ID` from `Bank.Account.Balances` where `Account`=' . $verifiedAccount . ' and `Commodity`="' . $commodity . '" and `Amount`>=' . $amount);
        if (!$balance) {
            // Not enough funds in the right currency.
            error('account/nofunds');
        }
        // Lock the amount in that balance row.
        // If a locked amount is present at startup then a crash occured during a transaction.
        // If it's severe, the balances can be rebuilt from the transaction history.
        $locked = $dz->query('update `Bank.Account.Balances` set `LockedAmount`=`LockedAmount`+' . $amount . ',`Amount`=`Amount`-' . $amount . ' where `ID`=' . $balance['ID'] . ' and `Amount`>=' . $amount);
        // Did we successfully lock?
        if (!$locked) {
            // Not enough funds in the right currency.
            error('account/nofunds');
        }
        // Ok! We've locked the balance.
        // Create a transaction row:
        $dz->query('insert into `Bank.Transactions`(`Account`,`Type`,`Reference`,`ItemInformation`,`Amount`,`Commodity`,`Username`,`Title`,`TimeAt`,`Name`) values(' . $verifiedAccount . ',2,"' . escape($details['Reference'], false) . '","' . escape($details['ItemInformation'], false) . '",' . $amount . ',"' . $commodity . '","' . $details['Username'] . '","' . escape($details['Title'], false) . '",' . time() . ',"' . escape($details['Name'], false) . '")');
    }
    if ($internalTransfer) {
        // It's an internal transaction.
        // Name needs to be changed first (it's the name of the sender, which we don't know at this point):
        $details['Name'] = '';
        // Update the receiving account:
        receive($details);
    } else {
        // Interbank transfer.
        // Need to select some suitable balances to use to send with.
        // For now, we'll just assume that a single balance can be found that has enough in it:
        $balanceRow = $dz->get_row('select `Bank.Balances`.`Key`,`Bank.Balances`.`Private`,`Root.Balances`.`Balance` from `Bank.Balances` left join `Root.Balances` on `Root.Balances`.`Key`=`Bank.Balances`.`Key` where `Root.Balances`.`Commodity`="' . $commodity . '" and `Root.Balances`.`Balance`>=' . $amount);
        if (!$balanceRow) {
            // This bank doesn't have a single balance with enough funds in it.
            // A more advanced implementation would combine multiple balances to ensure there's enough.
            // For now though, and to avoid making the consumer freak out, we'll just say the transaction amount is too high:
            error('amount/toohigh');
        }
        // Get the from address:
        $fromAddress = bin2hex($balanceRow['Key']);
        // Get the target group:
        $toGroup = $details['ToGroup'];
        if (strlen($toAddress) != 130) {
            // It's binary.
            $toAddress = bin2hex($toAddress);
        }
        // Perform a global transfer now:
        globalTransfer($fromAddress, $toAddress, $toGroup, $amount, $balanceRow['Balance'], $balanceRow['Private']);
    }
    // Success!
    if ($balance) {
        // Now unlock the amount in the sender:
        $dz->query('update `Bank.Account.Balances` set `LockedAmount`=`LockedAmount`-' . $amount . ' where ID=' . $balance['ID']);
    }
}
示例#4
0
<?php

$app->on('connect', function ($context) use($app) {
    // extract($context);
});
$app->on('login', function ($context) use($app) {
    extract($context);
    echo "{$fd} " . $message->username;
    $app->users->login($fd, $message->username);
});
$app->on('close', function ($context) use($app) {
    extract($context);
    logout($server, $fd);
});
$app->on('chat', [function ($context) use($app) {
    extract($context);
    sendMessage($server, 'chat', $message);
}]);
$app->on('load_history', [function ($context) use($app) {
    extract($context);
    loadHistory($server, $message);
}]);
$app->on('service', [function ($context) use($app) {
    extract($context);
    service($server, "service", $message);
}]);
$app->on('receive', [function ($context) use($app) {
    extract($context);
    receive($server, "receive", $message);
}]);
示例#5
0
function processTxChange($change)
{
    global $dz;
    // Get the row:
    $row = $dz->get_row('select * from `Bank.Incomings` where `Key`=unhex("' . $change['to']['address'] . '")');
    if (!$row || $row['Status']) {
        // Some other bank, or we've already processed it etc.
        return;
    }
    // Update the status:
    $dz->query('update `Bank.Incomings` set `Status`=1 where `ID`=' . $row['ID']);
    // Get the from address:
    $from = $dz->get_row('select `Commodity` from `Root.Balances` where `Key`=unhex("' . $change['from']['address'] . '")');
    if (!$from) {
        // Database is out of sync.
        serverError();
    }
    // Build the details set for the receive call:
    $details = array('Commodity' => $from['Commodity'], 'Amount' => $change['amount'], 'Reference' => $row['Reference'], 'Title' => $row['Title'], 'Name' => $row['Name'], 'FromUsername' => $row['From'], 'ItemInformation' => $row['ItemInformation']);
    // Receive it:
    receive($details, $row['Account']);
    // Finish by completing the status:
    $dz->query('update `Bank.Incomings` set `Status`=2 where `ID`=' . $row['ID']);
}