This repository has been archived by the owner on May 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contributions.php
213 lines (192 loc) · 9.25 KB
/
contributions.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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?php
$page = "Contribution Posts";
include("functions.php");
// Set Current page access level, and check if user has access
$currentacl = FOR_ALL;
CheckPageAccess();
if (isset($_GET['a'])) {
$action = $_GET['a'];
} else {
$action = "list";
}
if ($action == "list") {
$pagecontent = GetContributionList();
} else if ($action == "filter") {
//print_r($_POST);
$translator = NULL;
$project = NULL;
$fromdate = NULL;
$todate = NULL;
$voteutopian = NULL;
$reviewed = NULL;
if ((isset($_POST['translator'])) && ($_POST['translator'] != "na")) { $translator = $_POST['translator']; }
if ((isset($_POST['project'])) && ($_POST['project'] != "na")) { $project = $_POST['project']; }
if ((isset($_POST['fromdate'])) && ($_POST['fromdate'] != NULL)) { $fromdate = $_POST['fromdate']; }
if ((isset($_POST['todate'])) && ($_POST['todate'] != NULL)) { $todate = $_POST['todate']; }
if ((isset($_POST['vote-utopian'])) && ($_POST['vote-utopian'] != "na")) { $voteutopian = $_POST['vote-utopian']; }
if ((isset($_POST['reviewed'])) && ($_POST['reviewed'] != "na")) { $reviewed = $_POST['reviewed']; }
$page = "Contribution Search";
$pagecontent = GetContributionList($translator, $project, $fromdate, $todate, $voteutopian, NULL, $reviewed);
} else if ($action == "add") {
$page = "Add Contribution";
// Do a basic check on the provided url, to check if it is eligible for adding to the DB
// If it is a basic steemit.com utopian link, IsSteemLink() returns an array
// Otherwise, returns false
$returndata = IsSteemLink($_POST['steemlink']);
// First check, if the link is an actual Steemit link, check if it was already added.
if (is_array($returndata)) {
$isadded = CheckSteemLinkDB($_POST['steemlink']);
}
if ($isadded == TRUE) {
$pagecontent = "The contribution was already in the database!";
} else if ($isadded == FALSE) {
if(($_POST['steemlink'] != NULL) && (filter_var($_POST['steemlink'], FILTER_VALIDATE_URL) !== false) && is_array($returndata)) {
$parselink = ParseSteemLink($returndata);
if (CheckUserAccess($parselink['author']) > 0) {
$steemlink = $_POST['steemlink'];
if (is_array($parselink)) {
$pagecontent = "<i>Please verify if the contribution details are correct and press \"Submit\" to continue</i>";
$author = $parselink['author'];
$partno = $parselink['part'];
$wordcount = $parselink['words'];
$projectname = $parselink['project'];
$submitdate = $parselink['time'];
} else {
$pagecontent = "<i>Unable to parse the post. Please try again later or fill the details below and press \"Submit\" to continue</i>";
$author = "";
$partno = "";
$wordcount = "";
$projectname = "";
$submitdate = "";
}
//print_r($parselink);
$pagecontent .= "<form action=\"contributions.php?a=processadd\" method=\"post\"><div class=\"form-group row\"><label for=\"author\" class=\"col-4 col-form-label\">Author</label> <div class=\"col-8\"><input id=\"author\" name=\"author\" type=\"text\" aria-describedby=\"authorHelpBlock\" required=\"required\" class=\"form-control here\" value=\"$author\"> <span id=\"authorHelpBlock\" class=\"form-text text-muted\">Steem Username without @</span></div></div><div class=\"form-group row\"><label for=\"partno\" class=\"col-4 col-form-label\">Part Number</label> <div class=\"col-8\"><input id=\"partno\" name=\"partno\" placeholder=\"20\" type=\"text\" required=\"required\" class=\"form-control here\" value=\"$partno\"></div></div><div class=\"form-group row\"><label for=\"wordcount\" class=\"col-4 col-form-label\">Word Count</label> <div class=\"col-8\"><input id=\"wordcount\" name=\"wordcount\" placeholder=\"1251\" type=\"text\" required=\"required\" class=\"form-control here\" value=\"$wordcount\"></div></div><div class=\"form-group row\"><label for=\"projectname\" class=\"col-4 col-form-label\">Project</label> <div class=\"col-8\"><input id=\"projectname\" name=\"projectname\" placeholder=\"ReactOS\" type=\"text\" required=\"required\" class=\"form-control here\" value=\"$projectname\"></div></div> <div class=\"form-group row\"><div class=\"offset-4 col-8\"><button name=\"submit\" type=\"submit\" class=\"btn btn-primary\">Submit</button></div></div><input type=\"hidden\" id=\"steemlink\" name=\"steemlink\" value=\"".$steemlink."\"><input type=\"hidden\" id=\"created\" name=\"created\" value=\"".$submitdate."\"></form>";
} else {
print_r($parselink);
$pagecontent = "The contribution you've tried to submit was not made by a member of the ".$teamname." Team. This contribution couldn't be added to the database. If you believe this is an error, please contact an administrator";
}
} else {
$pagecontent = "The input is not a valid link, or is empty. Please try again by specifying a Steemit contribution link.";
}
} else {
//echo "Couldn't check";
$pagecontent = "Unable to check. Please try again later.";
}
} else if ($action == "processadd") {
$projectid = GetProjectID($_POST['projectname']);
$userid = GetUserID($_POST['author']);
$pagecontent = AddContribution($projectid, $userid, $_POST['steemlink'], $_POST['created'], $_POST['partno'], $_POST['wordcount']);
} else {
}
include("common/head.php");
?>
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto">
<p><a href="#" data-toggle="modal" data-target="#searchfilters">Filter Results</a> | <a href="#" data-toggle="modal" data-target="#addcontribution">Add Contribution</a></p>
<?php echo $pagecontent; ?>
</div>
</div>
</div>
<?php
$projectcsv = GetProjectsCSV();
$projecthtml = ConvertArray2HTMLOptions(explode(",", $projectcsv), "#", "project", NULL, TRUE);
$tcsv = GetTranslatorsCSV();
$thtml = ConvertArray2HTMLOptions(explode(",", $tcsv), "#", "translator", NULL, TRUE);
?>
<!-- Modal Search Filters-->
<div id="searchfilters" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Filter Results</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<p><form action="contributions.php?a=filter" method="post">
<div class="form-group row">
<label for="translator" class="col-4 col-form-label">Translator</label>
<div class="col-8">
<?php echo $thtml; ?>
</div>
</div>
<div class="form-group row">
<label for="project" class="col-4 col-form-label">Project</label>
<div class="col-8">
<?php echo $projecthtml;?>
</div>
</div>
<div class="form-group row">
<label for="fromdate" class="col-4 col-form-label">From</label>
<div class="col-8">
<input id="fromdate" name="fromdate" type="text" aria-describedby="fromdateHelpBlock" class="form-control here">
<span id="fromdateHelpBlock" class="form-text text-muted">Format: YYYY-MM-DD</span>
</div>
</div>
<div class="form-group row">
<label for="todate" class="col-4 col-form-label">To</label>
<div class="col-8">
<input id="todate" name="todate" type="text" aria-describedby="todateHelpBlock" class="form-control here">
<span id="todateHelpBlock" class="form-text text-muted">Format: YYYY-MM-DD</span>
</div>
</div>
<div class="form-group row">
<label for="vote-utopian" class="col-4 col-form-label">Voted (Utopian)</label>
<div class="col-8">
<select id="vote-utopian" name="vote-utopian" class="custom-select">
<option value="na">N/A</option>
<option value="y">Yes</option>
<option value="n">No</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="reviewed" class="col-4 col-form-label">Reviewed</label>
<div class="col-8">
<select id="reviewed" name="reviewed" class="custom-select">
<option value="na">N/A</option>
<option value="y">Yes</option>
<option value="n">No</option>
</select>
</div>
</div>
</p>
</div>
<div class="modal-footer">
<button name="submit" type="submit" class="btn btn-primary">Submit</button></form>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Modal Add Contribution -->
<div id="addcontribution" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Add Contribution</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<p><form action="contributions.php?a=add" method="post">
<div class="form-group row">
<label for="steemlink" class="col-4 col-form-label">Steemit.com Link</label>
<div class="col-8">
<input id="steemlink" name="steemlink" type="text" aria-describedby="todateHelpBlock" class="form-control here">
<span id="steemlinkHelpBlock" class="form-text text-muted">https://steemit.com/utopian-io/@username/post</span>
</div>
</div>
</p>
</div>
<div class="modal-footer">
<button name="submit" type="submit" class="btn btn-primary">Submit</button></form>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php
include("common/foot.php");
?>