This repository has been archived by the owner on Mar 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathphorum_anon2user.php
executable file
·130 lines (112 loc) · 4.17 KB
/
phorum_anon2user.php
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
<?php
/*
+---------------------------------------------------------------+
| Script to give ownership to anonymous posts.
|
| Tested with : - phorum version 3.4.2
| - apache 2.0.47 (Mandrake Linux/6mdk)
| - PHP version 4.3.3
| - mySQL version 4.0.15
|
| (c)Kevin Deldycke 2004
| http://kevin.deldycke.com
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
+---------------------------------------------------------------+
*/
// set parameters for connexion to MySQL server
$cfg_Host = "localhost";
$cfg_User = "root";
$cfg_Pass = "";
// set database source (must be a phorum forum)
$phorum_Base = "Current_FS";
$phorum_ForumId = "1";
// start of main code
echo "<html><body><pre>Start of script.<br>\n";
// get the name of the table which contain the forum we want to convert
$db_connect_id = mysql_connect($cfg_Hote, $cfg_User, $cfg_Pass);
$sql = "SELECT `id`, `table_name`, `name` ";
$sql .= "FROM `forums` ";
$sql .= "WHERE `id` = 1";
$result = mysql_db_query($phorum_Base, $sql);
$result2 = mysql_fetch_array($result);
$post_table = $result2['table_name'];
echo "Forum '".$result2['name']."' found.<br>\n";
// apply ownership change to database content ?
if (!empty($_POST['action'])) {
$action = $_POST['action'];
if ($action == 'set_owner') {
// get the last message id
$sql = "SELECT `id` ";
$sql .= "FROM `".$post_table."` ";
$sql .= "ORDER BY `id` DESC";
$results = mysql_db_query($phorum_Base, $sql);
$msg_id = mysql_fetch_array($results);
$last_id = $msg_id['id'];
// get all posted data and create a table that contain all new ownership
for ($id = 0; $id <= $last_id; $id++) {
if (!empty($_POST['message'.$id])) {
if ($_POST['message'.$id] != 0) {
$new_ownership["$id"] = $_POST['message'.$id];
}
}
}
// update new ownership into the database
while (list($msg_id, $owner_id) = each($new_ownership)) {
$sql = "UPDATE `".$post_table."` ";
$sql .= "SET `userid` = '".$owner_id."' ";
$sql .= "WHERE `id` = '".$msg_id."' LIMIT 1";
mysql_db_query($phorum_Base, $sql);
echo "Message n#".$msg_id." new owner id: ".$owner_id."<br>";
}
// exit the script and print a successful message
echo "End of ownership change.";
echo "\n</pre></body></html>";
exit();
}
}
// get all message headers
$sql = "SELECT * ";
$sql .= "FROM `".$post_table."` ";
$sql .= "WHERE `userid` = 0";
$results = mysql_db_query($phorum_Base, $sql);
// get all users
$sql = "SELECT `id`, `username`, `email` ";
$sql .= "FROM `forums_auth` ";
$user_list = mysql_db_query($phorum_Base, $sql);
// create a constant string to display the dropdown list of users
$dropdown_list = "<option value=\"0\" selected=\"selected\">Anonymous</option>";
while ($user = mysql_fetch_array($user_list)) {
$dropdown_list .= "<option value=\"".$user['id']."\">".$user['username']." [".$user['email']."]</option>";
}
$dropdown_list .= "</select>";
// print the header of the table
echo "<form action=\"phorum_anon2user.php\" method=\"post\">";
echo "Set the ownership for every anonymous post:<br>\n";
echo "<input type=\"hidden\" name=\"action\" value=\"set_owner\">";
echo "<table border=\"1\" cellpadding=\"4\" cellspacing=\"0\">";
echo "<tr valign=\"top\">";
echo "<td><b>id</b></td>";
echo "<td><b>Subject</b></td>";
echo "<td><b>Author [email]</b></td>";
echo "<td><b>Owner</b></td>";
echo "</tr>";
// scan every anonymous message
while ($msg = mysql_fetch_array($results)) {
echo "<tr valign=\"top\">";
echo "<td>".$msg['id']."</td>";
echo "<td>".$msg['subject']."</td>";
echo "<td>".$msg['author']." [".$msg['email']."]</td>";
echo "<td>";
// create a dropdown list of all authenticated users
echo "<select name=\"message".$msg['id']."\">";
echo $dropdown_list;
echo "<input type=\"submit\" name=\"set\" value=\"set\">";
echo "</td>";
echo "</tr>";
}
echo "</table></form>";
echo "\n</pre></body></html>";
?>