Hallo,
ik heb weer een een probleem met mijn website.
Ik heb een aantal errors, en ik kan niet zo heel goed omgaan met PHP etc.
Hier zijn de errors:En hier is mijn code, 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/**
* @author Stuart
* @version 1.1 UPDATED: 06.09.2010
* @comment fixed a few bugs
*/
/**
* mysql database hostname
*/
define("MYSQL_HOST", "localhost");
/**
* mysql username to connect to the database server
*/
define("MYSQL_USERNAME", "Mijnnaam");
/**
* mysql password the password to connect to the database server
*/
define("MYSQL_PASSWORD", "Mijnwachtwoord");
/**
* mysql database the database name in which you have your vote table setup
*/
define("MYSQL_DATABASE", "Mijndatabase");
/**
* vote url this is the url which where users will be sent to on voting
*/
define("VOTE_URL", "http://www.runelocus.com/toplist/vote-35048.html");
/**
* The number of hours between voting
*/
define("VOTE_HOURS", 24);
/**
* connect() this function is used to connect to the mysql database server.
*/
function connect()
{
if (!@mysql_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD))
die("Could not connect to mysql database: " . mysql_error());
if (!@mysql_select_db(MYSQL_DATABASE))
die("Could not select mysql database: " . mysql_error());
$tables = mysql_list_tables(MYSQL_DATABASE);
while (list($temp) = mysql_fetch_array($tables)) {
if ($temp == "votes") {
return;
}
}
query("CREATE TABLE `votes` (
`playerName` VARCHAR( 255 ) NOT NULL ,
`ip` VARCHAR( 255 ) NOT NULL,
`time` BIGINT NOT NULL ,
`recieved` INT( 1 ) NOT NULL DEFAULT 0)");
}
/**
* query(string query) this function is used to query the mysql database server.
*/
function query($s)
{
$query = @mysql_query($s);
if (!$query)
die("Error running query(" . $s . "): " . mysql_error());
return $query;
}
/**
* anti_inject(string text) this function is used to make sure no injections can be made.
*/
function anti_inject($sql)
{
$sql = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|*|--|\\)/"),
"", $sql);
$sql = trim($sql);
$sql = strip_tags($sql);
$sql = addslashes($sql);
$sql = strtolower($sql);
return $sql;
}
/**
* clean_request(int timestamp, string username) this function is used to delete any entries if they have already expired.
*/
function clean_request($time, $username)
{
$query = query("SELECT * FROM `votes` WHERE `playerName`=" . $username . "");
if (mysql_num_rows($query) > 0) {
$row = mysql_fetch_array($query);
$timerequested = $row[time];
if ($time - $timerequested > VOTE_HOURS * 3600)
query("DELETE FROM `votes` WHERE time=" . $timerequested . "");
}
}
/**
* vote_entries(string ip) this function is used return the number of rows within the table
*/
function vote_entries($ip)
{
$query = query("SELECT * FROM `votes` WHERE ip=" . $ip . "");
return mysql_num_rows($query);
}
/**
* This is the actual working of the script please do not touch anything below if you do not know what you are doing...
*/
if (isset($_POST[submit]) || isset($_GET[username]) && isset($_GET[type])) {
connect();
if ($_POST[submit]) {
if(@fsockopen($_SERVER[REMOTE_ADDR], 80, $errno, $errstr, 1))
die("Sorry but you have port 80 open, this is to stop voting by proxy address.");
if(isset($_COOKIE[voted]))
die("Sorry but it looks like you have already voted...");
$username = anti_inject($_POST[username]);
$ip = gethostbyaddr($_SERVER[REMOTE_ADDR]);
clean_request(time(), $username);
if (vote_entries($ip) == 0) {
setcookie ("voted", "yes", VOTE_HOURS * 3600);
query("INSERT INTO `votes` (`playerName`, `ip`, `time`) VALUES (" . $username .
", " . $ip . ", " . time() . ")");
header("Location: " . VOTE_URL . "");
} else {
die("You have already voted once today.");
}
} elseif ($_GET[type] == "checkvote") {
$username = anti_inject($_GET[username]);
$query = query("SELECT * FROM `votes` WHERE `playerName`=" . $username . "");
if (mysql_num_rows($query) == 1) {
$results = mysql_fetch_array($query);
if ($results[recieved] == 0) {
query("UPDATE `votes` SET `recieved`=1 WHERE `playerName`=" . $username . "");
die("user needs reward...");
} else {
die("user been given reward...");
}
} else {
die("Vote not found... ". $username .".");
}
}
}
?>
Vote for a reward!
Het is een code voor mijn spel, ik heb daarbij deze tutorial gevolgt:
http://www.moparscape.org/smf/index.php?topic=476829.0
Heel erg bedankt,
Alef
ik heb weer een een probleem met mijn website.
Ik heb een aantal errors, en ik kan niet zo heel goed omgaan met PHP etc.
Hier zijn de errors:
Spoiler tonen
Deprecated: Function mysql_list_tables() is deprecated in /home/habboacer/domains/lucrapk.nl/public_html/vote2/vote.php on line 37
Notice: Undefined index: submit in /home/habboacer/domains/lucrapk.nl/public_html/vote2/vote.php on line 100
Deprecated: Function sql_regcase() is deprecated in /home/habboacer/domains/lucrapk.nl/public_html/vote2/vote.php on line 64
Notice: Undefined index: submit in /home/habboacer/domains/lucrapk.nl/public_html/vote2/vote.php on line 100
Deprecated: Function sql_regcase() is deprecated in /home/habboacer/domains/lucrapk.nl/public_html/vote2/vote.php on line 64
Spoiler tonen
Codeblok (lucrapk.nl/vote2/vote.php):
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/**
* @author Stuart
* @version 1.1 UPDATED: 06.09.2010
* @comment fixed a few bugs
*/
/**
* mysql database hostname
*/
define("MYSQL_HOST", "localhost");
/**
* mysql username to connect to the database server
*/
define("MYSQL_USERNAME", "Mijnnaam");
/**
* mysql password the password to connect to the database server
*/
define("MYSQL_PASSWORD", "Mijnwachtwoord");
/**
* mysql database the database name in which you have your vote table setup
*/
define("MYSQL_DATABASE", "Mijndatabase");
/**
* vote url this is the url which where users will be sent to on voting
*/
define("VOTE_URL", "http://www.runelocus.com/toplist/vote-35048.html");
/**
* The number of hours between voting
*/
define("VOTE_HOURS", 24);
/**
* connect() this function is used to connect to the mysql database server.
*/
function connect()
{
if (!@mysql_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD))
die("Could not connect to mysql database: " . mysql_error());
if (!@mysql_select_db(MYSQL_DATABASE))
die("Could not select mysql database: " . mysql_error());
$tables = mysql_list_tables(MYSQL_DATABASE);
while (list($temp) = mysql_fetch_array($tables)) {
if ($temp == "votes") {
return;
}
}
query("CREATE TABLE `votes` (
`playerName` VARCHAR( 255 ) NOT NULL ,
`ip` VARCHAR( 255 ) NOT NULL,
`time` BIGINT NOT NULL ,
`recieved` INT( 1 ) NOT NULL DEFAULT 0)");
}
/**
* query(string query) this function is used to query the mysql database server.
*/
function query($s)
{
$query = @mysql_query($s);
if (!$query)
die("Error running query(" . $s . "): " . mysql_error());
return $query;
}
/**
* anti_inject(string text) this function is used to make sure no injections can be made.
*/
function anti_inject($sql)
{
$sql = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|*|--|\\)/"),
"", $sql);
$sql = trim($sql);
$sql = strip_tags($sql);
$sql = addslashes($sql);
$sql = strtolower($sql);
return $sql;
}
/**
* clean_request(int timestamp, string username) this function is used to delete any entries if they have already expired.
*/
function clean_request($time, $username)
{
$query = query("SELECT * FROM `votes` WHERE `playerName`=" . $username . "");
if (mysql_num_rows($query) > 0) {
$row = mysql_fetch_array($query);
$timerequested = $row[time];
if ($time - $timerequested > VOTE_HOURS * 3600)
query("DELETE FROM `votes` WHERE time=" . $timerequested . "");
}
}
/**
* vote_entries(string ip) this function is used return the number of rows within the table
*/
function vote_entries($ip)
{
$query = query("SELECT * FROM `votes` WHERE ip=" . $ip . "");
return mysql_num_rows($query);
}
/**
* This is the actual working of the script please do not touch anything below if you do not know what you are doing...
*/
if (isset($_POST[submit]) || isset($_GET[username]) && isset($_GET[type])) {
connect();
if ($_POST[submit]) {
if(@fsockopen($_SERVER[REMOTE_ADDR], 80, $errno, $errstr, 1))
die("Sorry but you have port 80 open, this is to stop voting by proxy address.");
if(isset($_COOKIE[voted]))
die("Sorry but it looks like you have already voted...");
$username = anti_inject($_POST[username]);
$ip = gethostbyaddr($_SERVER[REMOTE_ADDR]);
clean_request(time(), $username);
if (vote_entries($ip) == 0) {
setcookie ("voted", "yes", VOTE_HOURS * 3600);
query("INSERT INTO `votes` (`playerName`, `ip`, `time`) VALUES (" . $username .
", " . $ip . ", " . time() . ")");
header("Location: " . VOTE_URL . "");
} else {
die("You have already voted once today.");
}
} elseif ($_GET[type] == "checkvote") {
$username = anti_inject($_GET[username]);
$query = query("SELECT * FROM `votes` WHERE `playerName`=" . $username . "");
if (mysql_num_rows($query) == 1) {
$results = mysql_fetch_array($query);
if ($results[recieved] == 0) {
query("UPDATE `votes` SET `recieved`=1 WHERE `playerName`=" . $username . "");
die("user needs reward...");
} else {
die("user been given reward...");
}
} else {
die("Vote not found... ". $username .".");
}
}
}
?>
Vote for a reward!
Vote for a reward!
Het is een code voor mijn spel, ik heb daarbij deze tutorial gevolgt:
http://www.moparscape.org/smf/index.php?topic=476829.0
Heel erg bedankt,
Alef

