Skip to content

Commit

Permalink
Merge branch 'release/0.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
albertoleoncio committed Mar 27, 2024
2 parents 87baf11 + 9a78f15 commit b40ed77
Show file tree
Hide file tree
Showing 22 changed files with 693 additions and 81 deletions.
4 changes: 1 addition & 3 deletions badge.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
case $percentage > 75:
$color = 'orange';
break;

default:
$color = 'red';
break;
Expand All @@ -55,5 +55,3 @@

// Convert result to JSON and output
echo json_encode($result, JSON_PRETTY_PRINT);

?>
2 changes: 1 addition & 1 deletion bin/connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
echo "Error creating database.";
die();
}
}
}

//Cria tabelas caso não existam
mysqli_query($con, "
Expand Down
2 changes: 1 addition & 1 deletion bin/counter.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class="w3-input w3-border"
</div>
</div>
<?php if (time() > $contest['start_time']) : ?>
<?php require_once "stats.php"; ?>
<?php require_once "stats.php"; ?>
<div class="w3-container">
<table aria-label="Lista de participantes" class="w3-table-all w3-hoverable w3-card">
<tr>
Expand Down
8 changes: 5 additions & 3 deletions bin/edits.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
`{$contest['name_id']}__users`
ON
`{$contest['name_id']}__edits`.`user_id` = `{$contest['name_id']}__users`.`local_id`
LEFT JOIN
LEFT JOIN
`{$contest['name_id']}__articles`
ON
`{$contest['name_id']}__edits`.`article` = `{$contest['name_id']}__articles`.`articleID`;
Expand Down Expand Up @@ -191,7 +191,9 @@
}
?>
<?php while ($query = mysqli_fetch_assoc($edits_result)): ?>
<?php if ($query["valid_user"] != 1) continue; ?>
<?php if ($query["valid_user"] != 1) {
continue;
} ?>
<tr>
<td><?=$query["diff"]?></td>
<td><?=$query["title"]?></td>
Expand Down Expand Up @@ -229,4 +231,4 @@ className: 'dt-body-center'
</div>
</div>
</body>
</html>
</html>
4 changes: 2 additions & 2 deletions bin/evaluators.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@
<li class="w3-bar">
<i class="w3-bar-item w3-padding-16 fa-regular fa-circle-user" style="font-size: 3em; padding: 20px;"></i>
<form method="post">
<input type="email" placeholder="<?=§('login-email')?>" name="email"
<input type="email" placeholder="<?=§('login-email')?>" name="email"
class="w3-input w3-border w3-bar-item w3-section"
>
<button type='submit'
<button type='submit'
class='w3-bar-item w3-right w3-button w3-section w3-<?=$contest['theme'];?>'
>
<?=§('evaluators-register')?>
Expand Down
6 changes: 3 additions & 3 deletions bin/graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ function generateDateRange($startDay, $endDate) {
</script>
<?php else: ?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" style="width:200px;margin:auto;display:block;">
<path
<path
d="M 8 2 C 4.6862915 2 2 4.6862915 2 8 C 2 11.313708 4.6862915 14 8 14 C 8.3415702 14 8.6740174 13.964985 9 13.910156 L 9 12.900391 C 8.6769296 12.965962 8.3424207 13 8 13 C 5.2385763 13 3 10.761424 3 8 C 3 5.2385763 5.2385763 3 8 3 C 10.761424 3 13 5.2385763 13 8 C 13 8.3424207 12.965962 8.6769296 12.900391 9 L 13.910156 9 C 13.964985 8.6740174 14 8.3415702 14 8 C 14 4.6862915 11.313708 2 8 2 z M 7 4 L 7 8 L 7 9 L 9 9 L 12 9 L 12 8 L 8 8 L 8 4 L 7 4 z "
style="fill:currentColor;fill-opacity:1;stroke:none;color:#4d4d4d;"/>
<path
d="M 9.9899998,9.0000003 9,9.99 11.01,12 9,14.01 9.9899998,15 12,12.99 14.01,15 15,14.01 12.99,12 15,9.99 14.01,9.0000003 12,11.01 Z"
<path
d="M 9.9899998,9.0000003 9,9.99 11.01,12 9,14.01 9.9899998,15 12,12.99 14.01,15 15,14.01 12.99,12 15,9.99 14.01,9.0000003 12,11.01 Z"
style="fill:currentColor;fill-opacity:1;stroke:none;color:#da4453;"/>
</svg>
<?php endif; ?>
Expand Down
4 changes: 3 additions & 1 deletion bin/languages.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@

// Set default quality value to 1 for languages without a specified value
foreach ($languagesWithQuality as $language => $quality) {
if ($quality === '') $languagesWithQuality[$language] = 1;
if ($quality === '') {
$languagesWithQuality[$language] = 1;
}
}

// Sort languages by quality in descending order
Expand Down
12 changes: 6 additions & 6 deletions bin/load_edits.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//Insere lista em uma array
$list = array();
foreach ($petscan_list as $petscan_id) {
foreach ($petscan_list as $petscan_id) {
$list[] = [
"id" => $petscan_id['id'],
"title" => $petscan_id['title']
Expand All @@ -41,7 +41,7 @@

//Insere lista em uma array
$list = array();
foreach ($categorymembers_api['query']['categorymembers'] as $pageid) {
foreach ($categorymembers_api['query']['categorymembers'] as $pageid) {
$list[] = [
"id" => $pageid['pageid'],
"title" => $pageid['title']
Expand All @@ -63,7 +63,7 @@
$categorymembers_api = unserialize(
file_get_contents($contest['api_endpoint']."?".http_build_query($categorymembers_api_params))
);
foreach ($categorymembers_api['query']['categorymembers'] as $pageid) {
foreach ($categorymembers_api['query']['categorymembers'] as $pageid) {
$list[] = [
"id" => $pageid['pageid'],
"title" => $pageid['title']
Expand All @@ -75,9 +75,9 @@
//Realiza manutenção do banco de dados
mysqli_query($con, "ALTER TABLE `{$contest['name_id']}__articles` ADD COLUMN IF NOT EXISTS `title` VARCHAR(100) NOT NULL AFTER `articleID`;");
mysqli_query($con, "ALTER TABLE `{$contest['name_id']}__edits` ADD COLUMN IF NOT EXISTS `orig_bytes` INT(11) DEFAULT NULL AFTER `bytes`;");
mysqli_query($con, "UPDATE `{$contest['name_id']}__edits` SET `orig_bytes` = CASE
WHEN `obs` REGEXP 'Aval: de (-?[0-9]+) para (-?[0-9]+)' THEN CAST(REGEXP_SUBSTR(`obs`, 'Aval: de \\\\K-?[0-9]*') AS SIGNED)
WHEN `obs` REGEXP 'bytes: (-?[0-9]+) -> (-?[0-9]+)' THEN CAST(REGEXP_SUBSTR(`obs`, 'bytes: \\\\K-?[0-9]*') AS SIGNED)
mysqli_query($con, "UPDATE `{$contest['name_id']}__edits` SET `orig_bytes` = CASE
WHEN `obs` REGEXP 'Aval: de (-?[0-9]+) para (-?[0-9]+)' THEN CAST(REGEXP_SUBSTR(`obs`, 'Aval: de \\\\K-?[0-9]*') AS SIGNED)
WHEN `obs` REGEXP 'bytes: (-?[0-9]+) -> (-?[0-9]+)' THEN CAST(REGEXP_SUBSTR(`obs`, 'bytes: \\\\K-?[0-9]*') AS SIGNED)
ELSE `bytes` END WHERE `orig_bytes` IS NULL;");

//Monta e executa query para atualização da tabela de artigos
Expand Down
16 changes: 10 additions & 6 deletions bin/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@
) AS queried on date_timestamp = date_generator.date
GROUP BY date;
");
if ($new_participants != false) {
while ($row = mysqli_fetch_assoc($new_participants)) $new_participants_rows[] = $row['count'];
if ($new_participants) {
while ($row = mysqli_fetch_assoc($new_participants)) {
$new_participants_rows[] = $row['count'];
}
array_splice($new_participants_rows, $elapsed_days);
$new_participants_rows = implode(", ", $new_participants_rows);
} else {
Expand Down Expand Up @@ -182,15 +184,17 @@ class="w3-button w3-bar-item" ><?=§('login')?></button>
<a href="https://outreachdashboard.wmflabs.org/courses/<?=$contest['outreach_name'];?>"
target="_blank" rel="noopener" style="color: #fff; background-color: #676eb4;"
class="w3-button w3-margin-top w3-padding">
<?=§('triage-outreach')?>
<?=§('triage-outreach')?>
<i class="fa-solid fa-arrow-up-right-from-square fa-xs"></i>
</a>
</div>
<iframe scrolling="no" sandbox
src="https://outreachdashboard.wmflabs.org/embed/course_stats/<?=$contest['outreach_name'];?>"
<iframe scrolling="no" title="outreach" sandbox
src="https://outreachdashboard.wmflabs.org/embed/course_stats/<?=$contest['outreach_name'];?>"
style="width: 100%; border:0px none transparent;"></iframe>
</div>
<?php if (time() > $contest['start_time']) require_once "stats.php"; ?>
<?php if (time() > $contest['start_time']) {
require_once "stats.php";
} ?>
<div class="w3-row-padding">
<div class="w3-third w3-margin-bottom">
<div class="w3-card-4 w3-padding">
Expand Down
42 changes: 21 additions & 21 deletions bin/manage_contests.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ function processFormData()
//Valida se usuário pertence ao grupo relacionado ao concurso
if (!isset($contests_array[$name_id])) die(§('manage-notfound'));
if (
$_SESSION['user']["user_group"] !== "ALL" &&
$_SESSION['user']["user_group"] !== "ALL" &&
$_SESSION['user']["user_group"] !== $contests_array[$name_id]['group']
) die(§('manage-unauthorized'));

$deactive_statement =
"UPDATE
$deactive_statement =
"UPDATE
`{$name_id}__credentials`
SET
`user_status` = 'P'
Expand All @@ -246,8 +246,8 @@ function processFormData()
$deactive_query = mysqli_prepare($con, $deactive_statement);
mysqli_stmt_execute($deactive_query);

$manager_statement =
"INSERT IGNORE INTO
$manager_statement =
"INSERT IGNORE INTO
`{$name_id}__credentials` (`user_name`, `user_email`, `user_password`, `user_status`)
VALUES
(?,?,?,?)
Expand Down Expand Up @@ -311,14 +311,14 @@ function processFormData()
//Valida se usuário pertence ao grupo relacionado ao concurso
if (!isset($contests_array[$name_id])) die(§('manage-notfound'));
if (
$_SESSION['user']["user_group"] !== "ALL" &&
$_SESSION['user']["user_group"] !== "ALL" &&
$_SESSION['user']["user_group"] !== $contests_array[$name_id]['group']
) die(§('manage-unauthorized'));

//Reinicia concurso
if (isset($_POST['do_restart'])) {

//Reinicia tabelas do concurso, mas mantem a tabela de credenciais
//Reinicia tabelas do concurso, mas mantem a tabela de credenciais
mysqli_query($con, "TRUNCATE TABLE `{$name_id}__edits`;");
mysqli_query($con, "TRUNCATE TABLE `{$name_id}__users`;");
mysqli_query($con, "TRUNCATE TABLE `{$name_id}__articles`;");
Expand Down Expand Up @@ -358,9 +358,9 @@ function processFormData()

//Prepara e executa query
$update_statement =
"UPDATE
"UPDATE
`manage__contests`
SET
SET
`start_time` = ?,
`end_time` = ?,
`name` = ?,
Expand All @@ -380,7 +380,7 @@ function processFormData()
`max_pic_per_article` = ?,
`theme` = ?,
`color` = ?
WHERE
WHERE
`name_id` = ?";
$update_query = mysqli_prepare($con, $update_statement);
mysqli_stmt_bind_param(
Expand Down Expand Up @@ -524,7 +524,7 @@ function managerChange(id, doChange) {
<?php foreach ($contests_array as $name_id => $contest_info): ?>
<?php if (
$contest_info['name'] !== null &&
$_SESSION['user']["user_group"] !== "ALL" &&
$_SESSION['user']["user_group"] !== "ALL" &&
$_SESSION['user']["user_group"] !== $contest_info['group']
) continue; ?>
<div class="w3-margin-top w3-card w3-section">
Expand Down Expand Up @@ -553,7 +553,7 @@ class="w3-input w3-border w3-margin-bottom"

<div class="w3-row">
<div class="w3-threequarter" style="padding-right: 8px;">

<label for="internalcode">
<strong><?=§('manage-internalcode')?></strong>
</label>
Expand Down Expand Up @@ -679,7 +679,7 @@ class="w3-select w3-border w3-margin-bottom"
</label>
<input
class="w3-input w3-border w3-margin-bottom"
id="listid"
id="listid"
type="number"
maxlenght="10"
name="official_list_pageid"
Expand All @@ -691,7 +691,7 @@ class="w3-input w3-border w3-margin-bottom"
</label>
<input
class="w3-input w3-border w3-margin-bottom"
id="sourceid"
id="sourceid"
type="number"
maxlenght="10"
id="sourceid"
Expand All @@ -707,7 +707,7 @@ class="w3-input w3-border w3-margin-bottom"
</label>
<input
class="w3-input w3-border w3-margin-bottom"
id="outreach"
id="outreach"
type="text"
placeholder="<?=§('manage-outreachplacehold')?>"
name="outreach_name"
Expand All @@ -722,7 +722,7 @@ class="w3-input w3-border w3-margin-bottom"
</label>
<input
class="w3-input w3-border w3-margin-bottom"
id="bpp"
id="bpp"
type="number"
min="1"
max="999999999"
Expand All @@ -735,7 +735,7 @@ class="w3-input w3-border w3-margin-bottom"
</label>
<input
class="w3-input w3-border w3-margin-bottom"
id="maxbytes"
id="maxbytes"
type="number"
min="0"
max="999999999"
Expand All @@ -749,7 +749,7 @@ class="w3-input w3-border w3-margin-bottom"
</label>
<input
class="w3-input w3-border w3-margin-bottom"
id="minbytes"
id="minbytes"
type="number"
min="-1"
placeholder="0"
Expand All @@ -766,7 +766,7 @@ class="w3-input w3-border w3-margin-bottom"
</label>
<input
class="w3-input w3-border w3-margin-bottom"
id="ipp"
id="ipp"
type="number"
min="0"
max="999999999"
Expand All @@ -779,7 +779,7 @@ class="w3-input w3-border w3-margin-bottom"
</label>
<input
class="w3-input w3-border w3-margin-bottom"
id="maximages"
id="maximages"
type="number"
min="0"
max="999999999"
Expand Down Expand Up @@ -928,7 +928,7 @@ class="w3-button w3-red w3-block w3-leftbar w3-border-white"
<?php endif; ?>
</div>
</form>
<form
<form
style="display: none;"
method="post">
<div class="w3-section">
Expand Down
2 changes: 1 addition & 1 deletion bin/modify.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}
if (isset($_POST['overwrite'])) {
$post['overwrite'] = addslashes($_POST['overwrite']);
}
}

//Busca número de bytes e nome do avaliador no banco de dados
$evaluated_query = mysqli_prepare(
Expand Down
Loading

0 comments on commit b40ed77

Please sign in to comment.