-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Spine
authored and
itismadness
committed
Aug 22, 2021
1 parent
2ab4d3e
commit 9920d44
Showing
8 changed files
with
159 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
final class CoverArtNow extends AbstractMigration | ||
{ | ||
public function up(): void { | ||
$this->table('cover_art') | ||
->changeColumn('Image', 'string', ['length' => 255, 'null' => false]) | ||
->changeColumn('Summary', 'string', ['length' => 100, 'null' => false]) | ||
->changeColumn('UserID', 'integer', ['length' => 10, 'null' => false]) | ||
->changeColumn('Time', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP']) | ||
->save(); | ||
} | ||
|
||
public function down(): void { | ||
$this->table('cover_art') | ||
->changeColumn('Image', 'string', ['length' => 255, 'null' => false, 'default' => '']) | ||
->changeColumn('Summary', 'string', ['length' => 100, 'null' => true]) | ||
->changeColumn('UserID', 'integer', ['length' => 10, 'null' => false, 'default' => 0]) | ||
->changeColumn('Time', 'datetime', ['null' => true]) | ||
->save(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
authorize(); | ||
if (!$Viewer->permitted('site_edit_wiki')) { | ||
json_die('failure', 'forbidden'); | ||
} | ||
$tgroup = (new Gazelle\Manager\TGroup)->findById((int)$_GET['groupid']); | ||
$coverId = (int)$_GET['id']; | ||
if (!$coverId || is_null($tgroup)) { | ||
json_die('failure', 'bad parameters'); | ||
} | ||
|
||
if ($tgroup->removeCoverArt($coverId, $Viewer->id(), new Gazelle\Log)) { | ||
json_print("success", ['id' => $coverId]); | ||
} else { | ||
json_die('failure', 'bad coverId'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,27 @@ | ||
<?php | ||
authorize(); | ||
|
||
if (!check_perms('site_edit_wiki')) { | ||
if (!$Viewer->permitted('site_edit_wiki')) { | ||
error(403); | ||
} | ||
authorize(); | ||
|
||
$GroupID = (int)$_POST['groupid']; | ||
$Summaries = $_POST['summary']; | ||
$Images = $_POST['image']; | ||
|
||
if (!$GroupID) { | ||
error(0); | ||
$tgroup = (new Gazelle\Manager\TGroup)->findById((int)$_POST['groupid']); | ||
if (is_null($tgroup)) { | ||
error(404); | ||
} | ||
|
||
if (count($Images) != count($Summaries)) { | ||
$summaryList = $_POST['summary']; | ||
$imageList = $_POST['image']; | ||
if (count($imageList) != count($summaryList)) { | ||
error('Missing an image or a summary'); | ||
} | ||
|
||
$Changed = false; | ||
for ($i = 0; $i < count($Images); $i++) { | ||
$Image = trim($Images[$i]); | ||
if (ImageTools::blacklisted($Image, true) || !preg_match(IMAGE_REGEXP, $Image)) { | ||
$logger = new Gazelle\Log; | ||
for ($i = 0, $end = count($imageList); $i < $end; $i++) { | ||
$image = trim($imageList[$i]); | ||
if (ImageTools::blacklisted($image, true) || !preg_match(IMAGE_REGEXP, $image)) { | ||
continue; | ||
} | ||
$Summary = trim($Summaries[$i]); | ||
|
||
$DB->prepared_query(" | ||
INSERT IGNORE INTO cover_art | ||
(GroupID, Image, Summary, UserID, Time) | ||
VALUES (?, ?, ?, ?, now()) | ||
", $GroupID, $Image, $Summary, $Viewer->id() | ||
); | ||
if ($DB->affected_rows()) { | ||
$Changed = true; | ||
(new Gazelle\Log)->group($GroupID, $Viewer->id(), "Additional cover \"$Summary - $Image\" added to group"); | ||
} | ||
} | ||
|
||
if ($Changed) { | ||
$Cache->delete_value("torrents_cover_art_$GroupID"); | ||
$tgroup->addCoverArt($image, trim($summaryList[$i]), $Viewer->id(), $logger); | ||
} | ||
|
||
header("Location: " . $_SERVER['HTTP_REFERER'] ?? "torrents.php?id={$GroupID}"); | ||
header("Location: " . redirectUrl("torrents.php?id=" . $tgroup->id())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.