forked from opsecx/Transactions-Checker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions567.php
More file actions
132 lines (116 loc) · 2.74 KB
/
functions567.php
File metadata and controls
132 lines (116 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
function strip_all($in)
{
$in = trim($in);
$in = stripslashes($in);
$in = htmlspecialchars($in);
return $in;
}
function validate_tnam1($in)
{
if (empty($in))
{
return false;
}
strip_all($in);
if (strlen($in) <> 45)
{
return false;
}
$reg_tnam1 = '/tnam1[a-zA-Z0-9]{40}$/i';
return preg_match($reg_tnam1, $in);
}
function validate_integer($in)
{
if (empty($in))
{
return false;
}
strip_all($in);
if (strlen($in) > 25)
{
return false;
}
$reg_int = '/\d+$/i';
return preg_match($reg_int, $in);
}
function validate_proposal_id($in)
{
return validate_integer($in);
}
function validate_double($in)
{
if (empty($in))
{
return false;
}
$in = strip_all($in);
if (strlen($in) > 25)
{
return false;
}
$reg_double = '/^\d*\.?\d+$/i';
return preg_match($reg_double, $in);
}
function hyperlink_address($in, $mode_arg)
{
$in = strip_all($in);
$mode_arg = strip_all($mode_arg);
if (validate_tnam1($in) == false)
{
die('wrong internal parameter call');
}
$uri = strip_all($_SERVER['REQUEST_URI']);
$parts = explode('?', $uri);
$uri = array_shift($parts);
$servername = strip_all($_SERVER['HTTP_HOST']);
$name = getNameFromAddress($in);
$newlink = '//' . $servername . $uri . '?address=' . $in . '&mode=' . $mode_arg;
$returnstring = '<a href="' . $newlink . '" style="text-decoration: none">' . $name . '</a>';
return $returnstring;
}
function hyperlink_proposal($in, $mode_arg)
{
$uri = strip_all($_SERVER['REQUEST_URI']);
$parts = explode('?', $uri);
$uri = array_shift($parts);
$servername = strip_all($_SERVER['HTTP_HOST']);
$newlink = '//' . $servername . $uri . '?proposal_id=' . $in;
$returnstring = '<a href="' . $newlink . '">' . $in . '</a>';
return $returnstring;
}
// Initialize an empty hash map
$addressToName = [];
function loadPlayerData()
{
global $addressToName;
$filename = 'players.csv';
$file = fopen($filename, 'r');
if ($file === false)
{
die("Error opening file: $filename");
}
// Read each line from the CSV file
while (($row = fgetcsv($file)) !== false) {
// Assuming the CSV has two columns: address and name
$name = $row[0];
$address = $row[1];
// Add the address and name to the hash map
$addressToName[$address] = $name;
}
// Close the file
fclose($file);
}
// Returns the moniker associated with the specified Namada address, or returns the address if not found
function getNameFromAddress($address)
{
global $addressToName;
if (isset($addressToName[$address]))
{
return $addressToName[$address];
}
else
{
return $address;
}
}