本文整理汇总了PHP中find_string函数的典型用法代码示例。如果您正苦于以下问题:PHP find_string函数的具体用法?PHP find_string怎么用?PHP find_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了find_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MyMain
function MyMain($str)
{
$str1 = $str;
$str2 = $str1 . ", ktery jeste trochu obohatime";
$x = put_string($str1, "\n", $str2, "\n");
$p = find_string($str2, "text");
$x = put_string("Pozice retezce \"text\" v \$str2: ", $p, "\n");
$x = put_string("Zadejte posloupnost vsech malych pismen a-h, ");
$x = put_string("aby se pismena v posloupnosti neopakovala:\n");
$str1 = get_string();
$str2 = sort_string($str1);
while ($str2 !== "abcdefgh") {
$x = put_string("Spatne zadana posloupnost, zkuste znovu:\n");
$str1 = get_string();
$str2 = sort_string($str1);
}
return 0;
}
示例2: check_crypt_balance_range
function check_crypt_balance_range($public_key, $block_start = 0, $block_end = 0)
{
set_decrypt_mode();
// Figure out which decrypt method can be best used
//Initialize objects for Internal RSA decrypt
if ($GLOBALS['decrypt_mode'] == 2) {
require_once 'RSA.php';
$rsa = new Crypt_RSA();
$rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
}
if ($block_start == 0 && $block_end == 0) {
// Find every Time Koin sent to this public Key
$sql = "SELECT public_key_from, public_key_to, crypt_data3, attribute FROM `transaction_history` WHERE `public_key_from` = '{$public_key}' OR `public_key_to` = '{$public_key}' ";
} else {
// Find every TimeKoin sent to and from this public Key in a certain time range.
// Covert block to time.
$start_time_range = TRANSACTION_EPOCH + $block_start * 300;
$end_time_range = TRANSACTION_EPOCH + $block_end * 300;
$sql = "SELECT public_key_from, public_key_to, crypt_data3, attribute FROM `transaction_history` WHERE (`public_key_from` = '{$public_key}' AND `timestamp` >= '{$start_time_range}' AND `timestamp` < '{$end_time_range}')\n\t\tOR (`public_key_to` = '{$public_key}' AND `timestamp` >= '{$start_time_range}' AND `timestamp` < '{$end_time_range}')";
}
$sql_result = mysql_query($sql);
$sql_num_results = mysql_num_rows($sql_result);
$crypto_balance = 0;
$transaction_info;
for ($i = 0; $i < $sql_num_results; $i++) {
$sql_row = mysql_fetch_row($sql_result);
$public_key_from = $sql_row[0];
$public_key_to = $sql_row[1];
$crypt3 = $sql_row[2];
$attribute = $sql_row[3];
if ($attribute == "G" && $public_key_from == $public_key_to) {
// Currency Generation
// Decrypt transaction information
if ($GLOBALS['decrypt_mode'] == 2) {
$rsa->loadKey($public_key_from);
$transaction_info = $rsa->decrypt(base64_decode($crypt3));
} else {
$transaction_info = tk_decrypt($public_key_from, base64_decode($crypt3), TRUE);
}
$transaction_amount_sent = find_string("AMOUNT=", "---TIME", $transaction_info);
$crypto_balance += $transaction_amount_sent;
}
if ($attribute == "T" && $public_key_to == $public_key) {
// Decrypt transaction information
if ($GLOBALS['decrypt_mode'] == 2) {
$rsa->loadKey($public_key_from);
$transaction_info = $rsa->decrypt(base64_decode($crypt3));
} else {
$transaction_info = tk_decrypt($public_key_from, base64_decode($crypt3), TRUE);
}
$transaction_amount_sent = find_string("AMOUNT=", "---TIME", $transaction_info);
$crypto_balance += $transaction_amount_sent;
}
if ($attribute == "T" && $public_key_from == $public_key) {
// Decrypt transaction information
$transaction_info = tk_decrypt($public_key_from, base64_decode($crypt3));
if ($GLOBALS['decrypt_mode'] == 2) {
$rsa->loadKey($public_key_from);
$transaction_info = $rsa->decrypt(base64_decode($crypt3));
} else {
$transaction_info = tk_decrypt($public_key_from, base64_decode($crypt3), TRUE);
}
$transaction_amount_sent = find_string("AMOUNT=", "---TIME", $transaction_info);
$crypto_balance -= $transaction_amount_sent;
}
}
//
// Unset variable to free up RAM
unset($sql_result);
return $crypto_balance;
}
示例3: mysql_result
}
// End random time check
}
// End Transaction type G check
if ($sql_row["attribute"] == "T") {
// Check to make sure there is not a duplicate transaction already
$found_public_key_queue = mysql_result(mysql_query("SELECT timestamp, public_key_from, hash FROM `transaction_history` WHERE `public_key_from` = '{$public_key}' AND `hash` = '{$hash_check}' LIMIT 1"), 0, "timestamp");
if (empty($found_public_key_queue) == TRUE) {
// Transaction isn't a duplicate, continue processing...
$time_created = $sql_row["timestamp"];
$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));
示例4: poll_peer
//************************************************************
$poll_peer = poll_peer($ip_address, $domain, $subfolder, $port_number, 2000000, "transclerk.php?action=transaction_data&block_number={$block_number}");
$tc = 1;
if (empty($poll_peer) == TRUE) {
// Add failure points to the peer in case further issues
modify_peer_grade($ip_address, $domain, $subfolder, $port_number, 4);
}
while (empty($poll_peer) == FALSE) {
$transaction_timestamp = filter_sql(find_string("-----timestamp{$tc}=", "-----public_key_from{$tc}", $poll_peer));
$transaction_public_key_from = find_string("-----public_key_from{$tc}=", "-----public_key_to{$tc}", $poll_peer);
$transaction_public_key_to = find_string("-----public_key_to{$tc}=", "-----crypt1data{$tc}", $poll_peer);
$transaction_crypt1 = filter_sql(find_string("-----crypt1data{$tc}=", "-----crypt2data{$tc}", $poll_peer));
$transaction_crypt2 = filter_sql(find_string("-----crypt2data{$tc}=", "-----crypt3data{$tc}", $poll_peer));
$transaction_crypt3 = filter_sql(find_string("-----crypt3data{$tc}=", "-----hash{$tc}", $poll_peer));
$transaction_hash = filter_sql(find_string("-----hash{$tc}=", "-----attribute{$tc}", $poll_peer));
$transaction_attribute = find_string("-----attribute{$tc}=", "-----end{$tc}", $poll_peer);
if (empty($transaction_public_key_from) == TRUE && empty($transaction_public_key_to) == TRUE) {
// No more data, break while loop
break;
}
$transaction_public_key_from = filter_sql(base64_decode($transaction_public_key_from));
$transaction_public_key_to = filter_sql(base64_decode($transaction_public_key_to));
$found_duplicate = mysql_result(mysql_query("SELECT timestamp FROM `transaction_history` WHERE `timestamp` = '{$transaction_timestamp}' AND `public_key_from` = '{$transaction_public_key_from}' AND `hash` = '{$transaction_hash}' LIMIT 1"), 0, 0);
// Check for valid attribute
if ($transaction_attribute == "G" || $transaction_attribute == "T" || $transaction_attribute == "H") {
if (empty($found_duplicate) == TRUE) {
$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 ('{$transaction_timestamp}', '{$transaction_public_key_from}', '{$transaction_public_key_to}', '{$transaction_crypt1}', '{$transaction_crypt2}' , '{$transaction_crypt3}', '{$transaction_hash}' , '{$transaction_attribute}')";
if (mysql_query($sql) == TRUE) {
// Flag for a re-check afterwards
$double_check_block = TRUE;
}
示例5: call_script
call_script("main.php");
// Use uPNP to map inbound ports for Windows systems
if (getenv("OS") == "Windows_NT" && file_exists("utils\\upnpc.exe") == TRUE) {
$server_port_number = mysql_result(mysql_query("SELECT * FROM `options` WHERE `field_name` = 'server_port_number' LIMIT 1"), 0, "field_data");
$server_IP = gethostbyname(trim(`hostname`));
pclose(popen("start /B utils\\upnpc.exe -e Timekoin -a {$server_IP} {$server_port_number} {$server_port_number} TCP", "r"));
}
// Start any plugins
$sql = "SELECT * FROM `options` WHERE `field_name` LIKE 'installed_plugins%' ORDER BY `options`.`field_name` ASC";
$sql_result = mysql_query($sql);
$sql_num_results = mysql_num_rows($sql_result);
for ($i = 0; $i < $sql_num_results; $i++) {
$sql_row = mysql_fetch_array($sql_result);
$plugin_file = find_string("---file=", "---enable", $sql_row["field_data"]);
$plugin_enable = intval(find_string("---enable=", "---show", $sql_row["field_data"]));
$plugin_service = find_string("---service=", "---end", $sql_row["field_data"]);
if ($plugin_enable == TRUE && empty($plugin_service) == FALSE) {
// Start Plugin Service
call_script($plugin_file, 0, TRUE);
// Log Service Start
write_log("Started Plugin Service: {$plugin_service}", "MA");
}
}
// Finish Starting Plugin Services
header("Location: index.php?menu=system&code=1");
exit;
} else {
// Something failed or database error
header("Location: index.php?menu=system&code=99");
exit;
}
示例6: mysql_query
if ($transaction_hash == $crypt_hash_check && $inside_transaction_hash == $final_hash_compare && strlen($transaction_public_key) > 300 && strlen($public_key_to) > 300 && $transaction_timestamp >= $current_transaction_cycle && $transaction_timestamp < $next_transaction_cycle && $valid_amount == TRUE) {
// Check for 100 public key limit in the transaction queue
$sql = "SELECT timestamp FROM `transaction_queue` WHERE `public_key` = '{$transaction_public_key}'";
$sql_result = mysql_query($sql);
$sql_num_results = mysql_num_rows($sql_result);
if ($sql_num_results < 100) {
// Transaction hash and real hash match.
mysql_query("INSERT INTO `transaction_queue` (`timestamp`,`public_key`,`crypt_data1`,`crypt_data2`,`crypt_data3`, `hash`, `attribute`)\n\t\t\t\t\t\t\tVALUES ('{$transaction_timestamp}', '{$transaction_public_key}', '{$transaction_crypt1}', '{$transaction_crypt2}' , '{$transaction_crypt3}', '{$transaction_hash}' , '{$transaction_attribute}')");
} else {
write_log("More Than 100 Transactions Trying to Queue for Key: " . base64_encode($transaction_public_key), "QC");
}
}
}
// End Empty Hash Check
$match_number++;
$current_hash = find_string("---queue{$match_number}=", "---end{$match_number}", $poll_peer);
}
// End While Loop
}
// End For Loop
// Build queue hash after completion
$transaction_queue_hash = queue_hash();
// Store in database for quick reference from database
mysql_query("UPDATE `options` SET `field_data` = '{$transaction_queue_hash}' WHERE `options`.`field_name` = 'transaction_queue_hash' LIMIT 1");
}
// End Compare Tallies
}
// If/then Check for valid times
//***********************************************************************************
//***********************************************************************************
$loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'queueclerk_heartbeat_active' LIMIT 1"), 0, 0);
示例7: get_file_info
/**
* Function used to get file information using FFMPEG
* @param FILE_PATH
*/
function get_file_info($file_path = NULL)
{
if (!$path_source) {
$path_source = $this->input_file;
}
$info['format'] = 'N/A';
$info['duration'] = 'N/A';
$info['size'] = 'N/A';
$info['bitrate'] = 'N/A';
$info['video_width'] = 'N/A';
$info['video_height'] = 'N/A';
$info['video_wh_ratio'] = 'N/A';
$info['video_codec'] = 'N/A';
$info['video_rate'] = 'N/A';
$info['video_bitrate'] = 'N/A';
$info['video_color'] = 'N/A';
$info['audio_codec'] = 'N/A';
$info['audio_bitrate'] = 'N/A';
$info['audio_rate'] = 'N/A';
$info['audio_channels'] = 'N/A';
$info['path'] = $path_source;
$cmd = FFPROBE . " -v quiet -print_format json -show_format -show_streams '" . $path_source . "' ";
logData($cmd, 'command');
$output = shell_output($cmd);
logData($cmd, 'output');
//$output = trim($output);
//$output = preg_replace('/(\n]+){/', '', $output);
$output = preg_replace('/([a-zA-Z 0-9\\r\\n]+){/', '{', $output, 1);
$data = json_decode($output, true);
if ($data['streams'][0]['codec_type'] == 'video') {
$video = $data['streams'][0];
$audio = $data['streams'][1];
} else {
$video = $data['streams'][1];
$audio = $data['streams'][0];
}
$info['format'] = $data['format']['format_name'];
$info['duration'] = (double) round($video['duration'], 2);
$info['bitrate'] = (int) $data['format']['bit_rate'];
$info['video_bitrate'] = (int) $video['bit_rate'];
$info['video_width'] = (int) $video['width'];
$info['video_height'] = (int) $video['height'];
if ($video['height']) {
$info['video_wh_ratio'] = (int) $video['width'] / (int) $video['height'];
}
$info['video_codec'] = $video['codec_name'];
$info['video_rate'] = $video['r_frame_rate'];
$info['size'] = filesize($path_source);
$info['audio_codec'] = $audio['codec_name'];
$info['audio_bitrate'] = (int) $audio['bit_rate'];
$info['audio_rate'] = (int) $audio['sample_rate'];
$info['audio_channels'] = (double) $audio['channels'];
$info['rotation'] = (double) $video['tags']['rotate'];
if (!$info['duration'] || 1) {
$CMD = MEDIAINFO_BINARY . " '--Inform=General;%Duration%' '" . $path_source . "' 2>&1 ";
logData($CMD, 'command');
$duration = $info['duration'] = round(shell_output($CMD) / 1000, 2);
}
$this->raw_info = $info;
$video_rate = explode('/', $info['video_rate']);
$int_1_video_rate = (int) $video_rate[0];
$int_2_video_rate = (int) $video_rate[1];
$CMD = MEDIAINFO_BINARY . " '--Inform=Video;' " . $path_source;
logData($CMD, 'command');
$results = shell_output($CMD);
$needle_start = "Original height";
$needle_end = "pixels";
$original_height = find_string($needle_start, $needle_end, $results);
$original_height[1] = str_replace(' ', '', $original_height[1]);
if (!empty($original_height) && $original_height != false) {
$o_height = trim($original_height[1]);
$o_height = (int) $o_height;
if ($o_height != 0 && !empty($o_height)) {
$info['video_height'] = $o_height;
}
//logData(,'height');
}
$needle_start = "Original width";
$needle_end = "pixels";
$original_width = find_string($needle_start, $needle_end, $results);
$original_width[1] = str_replace(' ', '', $original_width[1]);
if (!empty($original_width) && $original_width != false) {
$o_width = trim($original_width[1]);
$o_width = (int) $o_width;
if ($o_width != 0 && !empty($o_width)) {
$info['video_width'] = $o_width;
}
}
if ($int_2_video_rate != 0) {
$info['video_rate'] = $int_1_video_rate / $int_2_video_rate;
}
logData(json_encode($info), $this->file_name . '_configs');
return $info;
}
示例8: tk_decrypt
// Valid Crypt2 field check
}
// Check for existing public key
if (empty($public_key_found_peer) == FALSE) {
// This peer is already in the generation list, so normally it would
// not be sending another election request unless to update the
// IP address from which it generates currency from.
$transaction_info = tk_decrypt($public_key, base64_decode($crypt1));
if ($transaction_info == $crypt2) {
// Check the IP/Domain field and poll the IP to see if
// there is a valid Timekoin server at the address.
$crypt3_data = tk_decrypt($public_key, base64_decode($crypt3));
$peer_ip = find_string("---ip=", "---domain", $crypt3_data);
$peer_domain = find_string("---domain=", "---subfolder", $crypt3_data);
$peer_subfolder = find_string("---subfolder=", "---port", $crypt3_data);
$peer_port_number = find_string("---port=", "---end", $crypt3_data);
// Check if IP is already in the generation peer list
$IP_exist1 = mysql_result(mysql_query("SELECT * FROM `generating_peer_list` WHERE `IP_Address` = '{$peer_ip}' LIMIT 1"), 0, 1);
// Calculate public key half-crypt-hash
$arr1 = str_split($public_key, 181);
// Poll the address that was encrypted to check for valid Timekoin server
$gen_key_crypt = base64_decode(poll_peer($peer_ip, $peer_domain, $peer_subfolder, $peer_port_number, 256, "genpeer.php?action=gen_key_crypt"));
$gen_key_crypt = tk_decrypt($public_key, $gen_key_crypt);
if (empty($peer_domain) == FALSE) {
// Check if the hostname and IP fields actually match
// and not made up or unrelated.
if (gethostbyname($peer_domain) != $peer_ip) {
$domain_fail = TRUE;
} else {
$domain_fail = FALSE;
}
示例9: 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;
}
示例10: find_string
<?php
$x = "https://github.com/ifjprojekt12/IFJ-Projekt-2013/new/master/testy";
$a = find_string($x, "h");
$b = put_string($a, "\n");
$a = find_string($x, "x");
$b = put_string($a, "\n");
$a = find_string($x, ":");
$b = put_string($a, "\n");
$a = find_string($x, "ttps");
$b = put_string($a, "\n");
$a = find_string($x, "t1");
$b = put_string($a, "\n");
示例11: options_screen5
function options_screen5()
{
$sql = "SELECT * FROM `options` WHERE `field_name` LIKE 'installed_plugins%' ORDER BY `options`.`field_name` ASC";
$sql_result = mysql_query($sql);
$sql_num_results = mysql_num_rows($sql_result);
$plugin_output;
for ($i = 0; $i < $sql_num_results; $i++) {
$sql_row = mysql_fetch_array($sql_result);
$plugin_file = find_string("---file=", "---enable", $sql_row["field_data"]);
$plugin_enable = intval(find_string("---enable=", "---show", $sql_row["field_data"]));
$plugin_name = find_string("---name=", "---tab", $sql_row["field_data"]);
$plugin_tab = find_string("---tab=", "---service", $sql_row["field_data"]);
$plugin_service = find_string("---service=", "---end", $sql_row["field_data"]);
if (empty($plugin_service) == TRUE) {
$plugin_service = '<font color="red">NA</font>';
}
if ($plugin_enable == TRUE) {
$plugin_toggle = '<FORM ACTION="index.php?menu=options&plugin=disable" METHOD="post"><font color="blue"><strong>Enabled</strong></font><br><input type="submit" name="Submit' . $i . '" value="Disable Here" />
<input type="hidden" name="pluginfile" value="' . $plugin_file . '"></FORM>';
} else {
$plugin_toggle = '<FORM ACTION="index.php?menu=options&plugin=enable" METHOD="post"><font color="red">Disabled</font><br><input type="submit" name="Submit' . $i . '" value="Enable Here" />
<input type="hidden" name="pluginfile" value="' . $plugin_file . '"></FORM>';
}
$plugin_output .= '<tr><td>' . $plugin_name . '</td><td>' . $plugin_tab . '</td><td>' . $plugin_file . '</td><td>' . $plugin_service . '</td>
<td valign="top" align="center">' . $plugin_toggle . '</td>
<td><FORM ACTION="index.php?menu=options&remove=plugin" METHOD="post" onclick="return confirm(\'Delete ' . $plugin_name . '?\');"><input type="image" src="img/hr.gif" title="Delete ' . $plugin_name . '" name="remove' . $i . '" border="0">
<input type="hidden" name="pluginfile" value="' . $plugin_file . '"></FORM></td></tr>
<tr><td colspan="6"><hr></td></tr>';
}
return '<table border="0" cellpadding="2" cellspacing="10"><tr><td valign="bottom" align="center" colspan="6"><strong>Plugin Information</strong>
</td></tr>
<tr><td align="center"><strong>Name</strong></td><td align="center"><strong>Tab</strong></td><td align="center"><strong>File</strong></td>
<td align="center"><strong>Service</strong></td><td align="center"><strong>Status</strong></td><td></td></tr>
' . $plugin_output . '
<tr><td align="right" colspan="6"><FORM ACTION="index.php?menu=options&plugin=new" METHOD="post"><input type="submit" name="SubmitNew" value="Install New Plugin" /></FORM></td></tr>
</table>
';
}
示例12: get_city_id
/**
* 城市映射,通过城市名,获取城市id
* @param String $city_name //市级城市名
*/
protected function get_city_id($city_name)
{
$City = D('City');
//店铺模型表
$all_city = $City->get_city_cache();
//读取城市缓存数据
foreach ($all_city as $val) {
//获取匹配后的城市id
if (find_string($val['name'], $city_name)) {
$city = $val['id'];
break;
}
}
return $city;
}
示例13: peer_list
function peer_list()
{
ini_set('user_agent', 'Timekoin Client (Peerlist) v' . TIMEKOIN_VERSION);
ini_set('default_socket_timeout', 2);
// Timeout for request in seconds
$max_active_peers = mysql_result(mysql_query("SELECT * FROM `options` WHERE `field_name` = 'max_active_peers' LIMIT 1"), 0, "field_data");
$max_new_peers = mysql_result(mysql_query("SELECT * FROM `options` WHERE `field_name` = 'max_new_peers' LIMIT 1"), 0, "field_data");
// How many active peers do we have?
$active_peers = mysql_result(mysql_query("SELECT COUNT(join_peer_list) FROM `active_peer_list`"), 0);
$new_peers = mysql_result(mysql_query("SELECT COUNT(poll_failures) FROM `new_peers_list`"), 0);
if ($active_peers == 0) {
// No active or new peers to poll from, start with the first contact servers
// and copy them to the new peer list
$sql = "SELECT * FROM `options` WHERE `field_name` = 'first_contact_server'";
$sql_result = mysql_query($sql);
$sql_num_results = mysql_num_rows($sql_result);
write_log("Peer List Empty. Adding First Contact Servers.", "PL");
// First Contact Server Format
//---ip=192.168.0.1---domain=timekoin.com---subfolder=timekoin---port=80---code=guest---end
for ($i = 0; $i < $sql_num_results; $i++) {
$sql_row = mysql_fetch_array($sql_result);
$peer_ip = find_string("---ip=", "---domain", $sql_row["field_data"]);
$peer_domain = find_string("---domain=", "---subfolder", $sql_row["field_data"]);
$peer_subfolder = find_string("---subfolder=", "---port", $sql_row["field_data"]);
$peer_port_number = find_string("---port=", "---code", $sql_row["field_data"]);
$peer_code = find_string("---code=", "---end", $sql_row["field_data"]);
// Insert into database as first contact server(s)
$sql = "INSERT INTO `active_peer_list` (`IP_Address` ,`domain` ,`subfolder` ,`port_number` ,`last_heartbeat`, `join_peer_list`, `failed_sent_heartbeat`, `code`)\n\t\t\tVALUES ('{$peer_ip}', '{$peer_domain}', '{$peer_subfolder}', '{$peer_port_number}', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), '0', '{$peer_code}');";
mysql_query($sql);
$active_peers++;
}
}
if ($active_peers < $max_active_peers) {
//Start polling peers from the new peers list
$sql = "SELECT * FROM `new_peers_list` ORDER BY RAND() LIMIT 10";
$sql_result = mysql_query($sql);
$sql_num_results = mysql_num_rows($sql_result);
// Peer difference
$peer_difference_count = $max_active_peers - $active_peers;
for ($i = 0; $i < $sql_num_results; $i++) {
$sql_row = mysql_fetch_array($sql_result);
$ip_address = $sql_row["IP_Address"];
$domain = $sql_row["domain"];
$subfolder = $sql_row["subfolder"];
$port_number = $sql_row["port_number"];
$poll_failures = $sql_row["poll_failures"];
$code = $sql_row["code"];
// Check to make sure that this peer is not already in our active peer list
$duplicate_check1 = mysql_result(mysql_query("SELECT * FROM `active_peer_list` WHERE `IP_Address` = '{$ip_address}' LIMIT 1"), 0, 0);
$duplicate_check2 = mysql_result(mysql_query("SELECT * FROM `active_peer_list` WHERE `domain` LIKE '{$domain}' LIMIT 1"), 0, 1);
if (empty($ip_address) == TRUE) {
//Don't have an IP address, check for duplicate domain or my own domain
if (empty($duplicate_check2) == TRUE) {
// Neither IP nor Domain exist
$duplicate_peer = FALSE;
} else {
$duplicate_peer = TRUE;
}
} else {
// Using IP only, is there a duplicate IP or Domain
if (empty($duplicate_check1) == TRUE && empty($duplicate_check2) == TRUE) {
$duplicate_peer = FALSE;
} else {
$duplicate_peer = TRUE;
}
}
if ($duplicate_peer == FALSE) {
// Poll Peer for Access
if (empty($code) == TRUE) {
// Try guest access
$poll_peer = poll_peer($ip_address, $domain, $subfolder, $port_number, 5, "api.php?action=tk_hash_status&hash=guest");
} else {
// Using custom code for peer
$poll_peer = poll_peer($ip_address, $domain, $subfolder, $port_number, 5, "api.php?action=tk_hash_status&hash={$code}");
}
if ($poll_peer == TRUE) {
// Add this peer to the active list
// Insert this peer into our active peer table
// Save only domain name if both IP and Domain exist
if (empty($domain) == FALSE) {
$ip_address = NULL;
}
if (empty($code) == TRUE) {
$code = "guest";
}
// Store new peer in active list
$sql = "INSERT INTO `active_peer_list` (`IP_Address` ,`domain` ,`subfolder` ,`port_number` ,`last_heartbeat` ,`join_peer_list` ,`failed_sent_heartbeat` ,`code`)\n\t\t\tVALUES ('{$ip_address}', '{$domain}', '{$subfolder}', '{$port_number}', '" . time() . "', '" . time() . "', '0', '{$code}');";
if (mysql_query($sql) == TRUE) {
// Subtract 1 from the peer difference count
$peer_difference_count--;
write_log("Joined with Peer {$ip_address}:{$domain}:{$port_number}/{$subfolder}", "PL");
}
} else {
//No response, record polling failure for future reference
$poll_failures++;
mysql_query("UPDATE `new_peers_list` SET `poll_failures` = '{$poll_failures}' WHERE `IP_Address` = '{$ip_address}' AND `domain` = '{$domain}' AND `subfolder` = '{$subfolder}' AND `port_number` = {$port_number} LIMIT 1");
}
} else {
// Active response will remove poll failures
mysql_query("UPDATE `new_peers_list` SET `poll_failures` = 0 WHERE `IP_Address` = '{$ip_address}' AND `domain` = '{$domain}' AND `subfolder` = '{$subfolder}' AND `port_number` = {$port_number} LIMIT 1");
//.........这里部分代码省略.........
示例14: poll_peer
$domain = $sql_row["domain"];
$subfolder = $sql_row["subfolder"];
$port_number = $sql_row["port_number"];
$poll_peer = poll_peer($ip_address, $domain, $subfolder, $port_number, 10000, "peerlist.php?action=new_peers");
$peer_counter = 1;
// Reset peer counter
while ($peer_counter <= 15) {
$peer_IP = NULL;
$peer_domain = NULL;
$peer_subfolder = NULL;
$peer_port_number = NULL;
// Sort Data
$peer_IP = find_string("-----IP{$peer_counter}=", "-----domain{$peer_counter}", $poll_peer);
$peer_domain = find_string("-----domain{$peer_counter}=", "-----subfolder{$peer_counter}", $poll_peer);
$peer_subfolder = find_string("-----subfolder{$peer_counter}=", "-----port_number{$peer_counter}", $poll_peer);
$peer_port_number = find_string("-----port_number{$peer_counter}=", "-----", $poll_peer);
if (is_domain_valid($peer_domain) == FALSE) {
// Someone is using an IP address or Localhost :p
$peer_domain = NULL;
}
if (empty($peer_port_number) == TRUE && empty($peer_subfolder) == TRUE) {
// No more peers, end this loop early
break;
}
if (empty($peer_IP) == TRUE && empty($peer_domain) == TRUE) {
$duplicate_peer == TRUE;
// Flag to avoid putting blank entry in database
} else {
// Check to make sure that this peer is not already in our new peer list
$duplicate_check1 = mysql_result(mysql_query("SELECT * FROM `new_peers_list` WHERE `IP_Address` = '{$peer_IP}' LIMIT 1"), 0, 0);
$duplicate_check2 = mysql_result(mysql_query("SELECT * FROM `new_peers_list` WHERE `domain` LIKE '{$peer_domain}' LIMIT 1"), 0, 1);
示例15: autotx_home
function autotx_home()
{
$default_public_key_font = mysql_result(mysql_query("SELECT * FROM `options` WHERE `field_name` = 'public_key_font_size' LIMIT 1"), 0, "field_data");
$sql = "SELECT * FROM `options` WHERE `field_name` LIKE 'auto_currency_transfer_%' ORDER BY `options`.`field_name` ASC";
$sql_result = mysql_query($sql);
$sql_num_results = mysql_num_rows($sql_result);
$plugin_output;
for ($i = 0; $i < $sql_num_results; $i++) {
$sql_row = mysql_fetch_array($sql_result);
$tx_record_name = $sql_row["field_name"];
$tx_name = find_string("---name=", "---enable", $sql_row["field_data"]);
$tx_enable = intval(find_string("---enable=", "---type", $sql_row["field_data"]));
$tx_type = find_string("---type=", "---key1", $sql_row["field_data"]);
$tx_key2 = find_string("---key2=", "---key3", $sql_row["field_data"]);
$tx_key2 = base64_encode(mysql_result(mysql_query("SELECT field_data FROM `my_keys` WHERE `field_name` = '{$tx_key2}' LIMIT 1"), 0, 0));
if ($tx_type == "onedelay") {
$tx_key3 = find_string("---key3=", "---delay", $sql_row["field_data"]);
$tx_key3 = base64_encode(mysql_result(mysql_query("SELECT field_data FROM `my_keys` WHERE `field_name` = '{$tx_key3}' LIMIT 1"), 0, 0));
$tx_delay = find_string("---delay=", "---amount", $sql_row["field_data"]);
$tx_amount = find_string("---amount=", "---end", $sql_row["field_data"]);
$tx_type = "One Time<br>Delay";
if ($tx_delay == 0) {
$tx_conditions = "Finished";
} else {
$tx_conditions = tk_time_convert($tx_delay) . " Remain";
}
}
if ($tx_type == "repeatdelay") {
$tx_key3 = find_string("---key3=", "---delay_start", $sql_row["field_data"]);
$tx_key3 = base64_encode(mysql_result(mysql_query("SELECT field_data FROM `my_keys` WHERE `field_name` = '{$tx_key3}' LIMIT 1"), 0, 0));
$tx_delay = find_string("---delay=", "---amount", $sql_row["field_data"]);
$tx_amount = find_string("---amount=", "---end", $sql_row["field_data"]);
$tx_type = "Repeating<br>Delay";
$tx_conditions = tk_time_convert($tx_delay) . " Remain";
}
if ($tx_type == "oneamount") {
$tx_key3 = find_string("---key3=", "---amount", $sql_row["field_data"]);
$tx_key3 = base64_encode(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"]);
$tx_type = "One Time<br>Amount Match";
if ($tx_amount == 0) {
$tx_conditions = "Finished";
} else {
$tx_conditions = "Amount >= {$amount_match}";
}
}
if ($tx_type == "repeatamount") {
$tx_key3 = find_string("---key3=", "---amount", $sql_row["field_data"]);
$tx_key3 = base64_encode(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"]);
$tx_type = "Repeating<br>Amount Match";
$tx_conditions = "Amount >= {$amount_match}";
}
if ($tx_enable == TRUE) {
$tx_toggle = '<FORM ACTION="autotransfer.php?task=disable" METHOD="post"><font color="blue"><strong>Enabled</strong></font><br><input type="submit" name="Submit' . $i . '" value="Disable Here" />
<input type="hidden" name="tx_record_name" value="' . $tx_record_name . '"></FORM>';
} else {
$tx_toggle = '<FORM ACTION="autotransfer.php?task=enable" METHOD="post"><font color="red">Disabled</font><br><input type="submit" name="Submit' . $i . '" value="Enable Here" />
<input type="hidden" name="tx_record_name" value="' . $tx_record_name . '"></FORM>';
}
$plugin_output .= '<tr><td>' . $tx_name . '</td><td>' . $tx_type . '</td><td>' . $tx_conditions . '</td><td><p style="word-wrap:break-word; width:90px; font-size:' . $default_public_key_font . 'px;">' . $tx_key2 . '</p></td>
<td><p style="word-wrap:break-word; width:90px; font-size:' . $default_public_key_font . 'px;">' . $tx_key3 . '</p></td><td align="center">' . $tx_amount . '</td><td valign="top" align="center">' . $tx_toggle . '</td>
<td><FORM ACTION="autotransfer.php?task=delete_task" METHOD="post" onclick="return confirm(\'Delete ' . $tx_name . '?\');"><input type="image" src="../img/hr.gif" title="Delete ' . $tx_name . '" name="remove' . $i . '" border="0">
<input type="hidden" name="tx_record_name" value="' . $tx_record_name . '"></FORM></td></tr>
<tr><td colspan="8"><hr></td></tr>';
}
return '<table border="0" cellpadding="2" cellspacing="10"><tr><td valign="bottom" align="center" colspan="8"><strong>Auto Currency Transfer Task List</strong>
</td></tr>
<tr><td align="center"><strong>Name</strong></td><td align="center"><strong>Type</strong></td><td align="center"><strong>Conditions</strong></td>
<td align="center"><strong>Key From</strong></td><td align="center"><strong>Key To</strong></td><td align="center"><strong>Transfer<br>Amount</strong></td>
<td align="center"><strong>Status</strong></td><td></td></tr>' . $plugin_output . '
<tr><td align="right" colspan="8"><FORM ACTION="autotransfer.php?task=new" METHOD="post"><input type="submit" name="SubmitNew" value="Create New Task" /></FORM></td></tr>
</table>';
}