当前位置: 首页>>代码示例>>PHP>>正文


PHP check_crypt_balance函数代码示例

本文整理汇总了PHP中check_crypt_balance函数的典型用法代码示例。如果您正苦于以下问题:PHP check_crypt_balance函数的具体用法?PHP check_crypt_balance怎么用?PHP check_crypt_balance使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了check_crypt_balance函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: db_cache_balance

function db_cache_balance($my_public_key)
{
    // Check server balance via custom memory index
    $my_server_balance = mysql_result(mysql_query("SELECT balance FROM `balance_index` WHERE `public_key_hash` = 'server_timekoin_balance' LIMIT 1"), 0, 0);
    $my_server_balance_last = mysql_result(mysql_query("SELECT block FROM `balance_index` WHERE `public_key_hash` = 'server_timekoin_balance' LIMIT 1"), 0, 0);
    if ($my_server_balance === FALSE) {
        // Does not exist, needs to be created
        mysql_query("INSERT INTO `balance_index` (`block` ,`public_key_hash` ,`balance`) VALUES ('0', 'server_timekoin_balance', '0')");
        // Update record with the latest balance
        $display_balance = check_crypt_balance($my_public_key);
        mysql_query("UPDATE `balance_index` SET `block` = '" . time() . "' , `balance` = '{$display_balance}' WHERE `balance_index`.`public_key_hash` = 'server_timekoin_balance' LIMIT 1");
    } else {
        if ($my_server_balance_last < transaction_cycle(0) && time() - transaction_cycle(0) > 25) {
            // Last generated balance is older than the current cycle, needs to be updated
            // Update record with the latest balance
            $display_balance = check_crypt_balance($my_public_key);
            mysql_query("UPDATE `balance_index` SET `block` = '" . time() . "' , `balance` = '{$display_balance}' WHERE `balance_index`.`public_key_hash` = 'server_timekoin_balance' LIMIT 1");
        } else {
            $display_balance = $my_server_balance;
        }
    }
    return $display_balance;
}
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:23,代码来源:function.php

示例2: mysql_query

                     // Update DB to Disable Task When Finished
                     mysql_query("UPDATE `options` SET `field_data` = '{$new_string}' WHERE `options`.`field_name` = '{$tx_record_name}' LIMIT 1");
                     write_log("Auto Transfer Task ({$tx_name}) Has Completed.", "T");
                 }
             }
         }
         // One Shot Amount Match Transfer
         if ($tx_type == "repeatamount") {
             $tx_key3 = find_string("---key3=", "---amount", $sql_row["field_data"]);
             $tx_key3 = mysql_result(mysql_query("SELECT field_data FROM `my_keys` WHERE `field_name` = '{$tx_key3}' LIMIT 1"), 0, 0);
             $tx_amount = find_string("---amount=", "---amount_match", $sql_row["field_data"]);
             $amount_match = find_string("---amount_match=", "---end", $sql_row["field_data"]);
             // Only check once per transaction cycle or otherwise it will just make a transfer every time it scans
             // Check allowed 180 seconds before and 60 seconds after transaction cycle.
             if (transaction_cycle(1) - time() > 180 && time() - transaction_cycle(0) >= 60) {
                 if (check_crypt_balance($tx_key2) >= $amount_match) {
                     // Create Transaction
                     if (send_timekoins($tx_key1, $tx_key2, $tx_key3, $tx_amount, NULL) == TRUE) {
                         write_log("Auto Transfer Task ({$tx_name}) Has Completed.", "T");
                     }
                 }
             }
         }
         // Repeating Amount Match Transfer
     }
     // Check if enabled
 }
 // Looping through all task
 // Idle State
 mysql_query("UPDATE `main_loop_status` SET `field_data` = '2' WHERE `main_loop_status`.`field_name` = 'autotransfer.php' LIMIT 1");
 sleep(AUTOCHECK);
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:autotransfer.php

示例3: tk_decrypt

 $crypt1 = $sql_row["crypt_data1"];
 $crypt2 = $sql_row["crypt_data2"];
 $crypt3 = $sql_row["crypt_data3"];
 // How much is this public key trying to send to another public key?
 $transaction_info = tk_decrypt($public_key, base64_decode($crypt3));
 $transaction_amount_sent = find_string("AMOUNT=", "---TIME", $transaction_info);
 $transaction_amount_sent_test = intval($transaction_amount_sent);
 if ($transaction_amount_sent_test == $transaction_amount_sent) {
     // Is a valid integer
     $amount_valid = TRUE;
 } else {
     // Is NOT a valid integer
     $amount_valid = FALSE;
 }
 // Validate transaction against known public key balance
 if (check_crypt_balance($public_key) >= $transaction_amount_sent && $transaction_amount_sent > 0 && $amount_valid == TRUE) {
     // Balance checks out
     // Check hash value for tampering of crypt1, crypt2, or crypt3 fields
     if (hash('sha256', $crypt1 . $crypt2 . $crypt3) == $hash_check) {
         // Find destination public key
         $public_key_to_1 = tk_decrypt($public_key, base64_decode($crypt1));
         $public_key_to_2 = tk_decrypt($public_key, base64_decode($crypt2));
         $public_key_to = $public_key_to_1 . $public_key_to_2;
         if (strlen($public_key) > 300 && strlen($public_key_to) > 300 && $public_key !== $public_key_to) {
             // Public key not found, insert into final transaction history
             $sql = "INSERT INTO `transaction_history` (`timestamp` ,`public_key_from` , `public_key_to` , `crypt_data1` ,`crypt_data2` ,`crypt_data3` ,`hash` ,`attribute`)\n\t\t\t\t\t\t\t\tVALUES ({$time_created}, '{$public_key}', '{$public_key_to}' , '{$crypt1}', '{$crypt2}', '{$crypt3}', '{$hash_check}', 'T');";
             if (mysql_query($sql) == FALSE) {
                 //Something didn't work
                 write_log("Transaction Database Insert Failed for this Key:" . base64_encode($public_key), "T");
             }
         } else {
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:treasurer.php

示例4: mysql_connect

}
//***********************************************************************************
//***********************************************************************************
// Open persistent connection to database
mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD);
mysql_select_db(MYSQL_DATABASE);
// Check for banned IP address
if (ip_banned($_SERVER['REMOTE_ADDR']) == TRUE) {
    // Sorry, your IP address has been banned :(
    exit;
}
//***********************************************************************************
//***********************************************************************************
// Answer public key balance request that match our hash code
if ($_GET["action"] == "key_balance") {
    $hash_code = substr($_GET["hash"], 0, 256);
    $server_hash_code = mysql_result(mysql_query("SELECT * FROM `options` WHERE `field_name` = 'server_hash_code' LIMIT 1"), 0, "field_data");
    if ($hash_code == $server_hash_code && $server_hash_code != "0") {
        // Grab balance for public key and return back
        $public_key = substr($_POST["public_key"], 0, 500);
        $public_key = filter_sql(base64_decode($public_key));
        echo check_crypt_balance($public_key);
    }
    // Log inbound IP activity
    log_ip("AP");
    exit;
}
//***********************************************************************************
//***********************************************************************************
// Log IP even when not using any functions
log_ip("AP");
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:api.php

示例5: transaction_cycle

} else {
    // Loop called while still working
    exit;
}
//***********************************************************************************
//***********************************************************************************
$current_transaction_cycle = transaction_cycle(0);
$next_transaction_cycle = transaction_cycle(1);
$foundation_active = intval(mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'foundation_heartbeat_active' LIMIT 1"), 0, "field_data"));
// Can we work on the key balances in the database?
// Not allowed 120 seconds before and 45 seconds after transaction cycle.
if ($next_transaction_cycle - time() > 120 && time() - $current_transaction_cycle > 45 && $foundation_active == 0) {
    // 2000 Transaction Cycles Back in time to index
    $time_2000 = time() - 600000;
    $sql = "SELECT public_key_to FROM `transaction_history` WHERE `timestamp` > {$time_2000} GROUP BY `public_key_to` ORDER BY RAND() LIMIT 1";
    $sql_result = mysql_query($sql);
    $sql_row = mysql_fetch_array($sql_result);
    $public_key_hash = hash('md5', $sql_row["public_key_to"]);
    // Run a balance index if one does not already exist
    $balance_index = mysql_result(mysql_query("SELECT public_key_hash FROM `balance_index` WHERE `public_key_hash` = '{$public_key_hash}' LIMIT 1"), 0, 0);
    if (empty($balance_index) == TRUE) {
        // No index balance, go ahead and create one
        check_crypt_balance($sql_row["public_key_to"]);
    }
}
//***********************************************************************************
//***********************************************************************************
// Script finished, set status to 0
mysql_query("UPDATE `main_loop_status` SET `field_data` = 0 WHERE `main_loop_status`.`field_name` = 'balance_heartbeat_active' LIMIT 1");
// Record when this script finished
mysql_query("UPDATE `main_loop_status` SET `field_data` = " . time() . " WHERE `main_loop_status`.`field_name` = 'balance_last_heartbeat' LIMIT 1");
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:balance.php

示例6: time

                 break;
                 // Break from loop early
             }
         }
     }
     if ($queue_index_created == FALSE) {
         // 1000 Transaction Cycles Back in time to index
         $time_back = time() - 300000;
         $public_key_from = mysql_result(mysql_query("SELECT public_key_to FROM `transaction_history` WHERE `timestamp` > {$time_back} AND `attribute` = 'T' GROUP BY `public_key_to` ORDER BY RAND() LIMIT 1"), 0, 0);
         $public_key_hash = hash('md5', $public_key_from);
         // Run a balance index if one does not already exist
         $balance_index = mysql_result(mysql_query("SELECT block FROM `balance_index` WHERE `public_key_hash` = '{$public_key_hash}' AND `block` = {$cache_block} LIMIT 1"), 0, 0);
         if ($balance_index === FALSE) {
             // No index balance, go ahead and create one
             write_log("Updating Balance Index From Transaction History", "BA");
             check_crypt_balance($public_key_from);
         }
     }
 }
 //***********************************************************************************
 //***********************************************************************************
 $loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'balance_heartbeat_active' LIMIT 1"), 0, 0);
 // Check script status
 if ($loop_active == 3) {
     // Time to exit
     mysql_query("DELETE FROM `main_loop_status` WHERE `main_loop_status`.`field_name` = 'balance_heartbeat_active'");
     exit;
 }
 // Script finished, set standby status to 2
 mysql_query("UPDATE `main_loop_status` SET `field_data` = '2' WHERE `main_loop_status`.`field_name` = 'balance_heartbeat_active' LIMIT 1");
 // Record when this script finished
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:balance.php

示例7: db_cache_balance

function db_cache_balance($my_public_key)
{
    $cache_refresh_time = 30;
    // Refresh TTL in seconds
    // Check server balance via cache
    $billfold_balance = mysql_result(mysql_query("SELECT * FROM `data_cache` WHERE `field_name` = 'billfold_balance' LIMIT 1"), 0, "field_data");
    $timestamp_cache = intval(find_string("---time=", "---data", $billfold_balance));
    if (time() - $cache_refresh_time <= $timestamp_cache) {
        // Return Cache Data
        return intval(find_string("---data=", "---end", $billfold_balance));
    }
    $balance = check_crypt_balance($my_public_key);
    // Cache stale, refresh and update cache
    mysql_query("UPDATE `data_cache` SET `field_data` = '---time=" . time() . "---data={$balance}---end' WHERE `data_cache`.`field_name` = 'billfold_balance' LIMIT 1");
    return $balance;
}
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:16,代码来源:function.php


注:本文中的check_crypt_balance函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。