Redirect duplicates

This commit is contained in:
Olivier Berten 2021-03-03 21:59:46 +01:00
parent 6c78479110
commit 0c20d35928
10 changed files with 61 additions and 33 deletions

View File

@ -15,6 +15,16 @@ if(!$c) {
die('Wrong id'); die('Wrong id');
} }
if($c['duplicateof'] > 0) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$c['duplicateof']);
header('Connection: close');
} elseif($c['duplicateof']) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: ./scores.php');
header('Connection: close');
}
$title = $c['incipit']?$c['incipit']:'░░'.$c['id'].'░░'; $title = $c['incipit']?$c['incipit']:'░░'.$c['id'].'░░';
$custom_header = <<<HEADER $custom_header = <<<HEADER
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

View File

@ -39,9 +39,11 @@ echo '<entry>
'; ';
while($m = $req1->fetch_assoc()) { while($m = $req1->fetch_assoc()) {
$t = chant_from_id($m['chant_id']);
if($t) {
$user_info = get_userdata($m['user_id']); $user_info = get_userdata($m['user_id']);
echo '<entry> echo '<entry>
<title type="html">'.chant_from_id($m['chant_id'])[1].'</title> <title type="html">'.$t[1].'</title>
<link href="'.$dir.'chant.php?id='.$m['chant_id'].'" /> <link href="'.$dir.'chant.php?id='.$m['chant_id'].'" />
<summary>'.htmlspecialchars($m['comment']).'</summary> <summary>'.htmlspecialchars($m['comment']).'</summary>
<updated>'.date(DATE_ATOM,$m['time']).'</updated> <updated>'.date(DATE_ATOM,$m['time']).'</updated>
@ -52,5 +54,6 @@ while($m = $req1->fetch_assoc()) {
</entry> </entry>
'; ';
} }
}
echo '</feed>'; echo '</feed>';
?> ?>

View File

@ -1,9 +1,9 @@
-- phpMyAdmin SQL Dump -- phpMyAdmin SQL Dump
-- version 5.1.0-rc2 -- version 5.1.0
-- https://www.phpmyadmin.net/ -- https://www.phpmyadmin.net/
-- --
-- Hôte : localhost -- Hôte : localhost
-- Généré le : dim. 21 fév. 2021 à 19:10 -- Généré le : mer. 03 mars 2021 à 21:48
-- Version du serveur : 10.4.17-MariaDB-1:10.4.17+maria~xenial -- Version du serveur : 10.4.17-MariaDB-1:10.4.17+maria~xenial
-- Version de PHP : 7.4.15 -- Version de PHP : 7.4.15
@ -67,7 +67,8 @@ CREATE TABLE `gregobase_chants` (
`gabc_verses` text COLLATE utf8_unicode_ci DEFAULT NULL, `gabc_verses` text COLLATE utf8_unicode_ci DEFAULT NULL,
`tex_verses` text COLLATE utf8_unicode_ci DEFAULT NULL, `tex_verses` text COLLATE utf8_unicode_ci DEFAULT NULL,
`remarks` text COLLATE utf8_unicode_ci DEFAULT NULL, `remarks` text COLLATE utf8_unicode_ci DEFAULT NULL,
`copyrighted` tinyint(1) NOT NULL DEFAULT 0 `copyrighted` tinyint(1) NOT NULL DEFAULT 0,
`duplicateof` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- -------------------------------------------------------- -- --------------------------------------------------------

View File

@ -11,9 +11,9 @@ include('include/header.php');
echo "<h2>$title</h2>\n"; echo "<h2>$title</h2>\n";
if($l) { if($l) {
$sql1 = 'SELECT * FROM '.db('chants').' WHERE `incipit` LIKE "'.$l.'%" ORDER BY incipit ASC'; $sql1 = 'SELECT * FROM '.db('chants').' WHERE `duplicateof` IS NULL AND `incipit` LIKE "'.$l.'%" ORDER BY incipit ASC';
} else { } else {
$sql1 = 'SELECT * FROM '.db('chants')." WHERE `incipit` LIKE '' OR UPPER(incipit) REGEXP '^[^A-Zƌ].*' ORDER BY incipit ASC"; $sql1 = 'SELECT * FROM '.db('chants')." WHERE `duplicateof` IS NULL AND (`incipit` LIKE '' OR UPPER(incipit) REGEXP '^[^A-Zƌ].*') ORDER BY incipit ASC";
} }
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error); $req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
$chants = array(); $chants = array();

View File

@ -2,10 +2,11 @@
function chant_from_id($c) { function chant_from_id($c) {
global $mysqli; global $mysqli;
$sql1 = 'SELECT `office-part`,incipit,gabc,version FROM '.db('chants').' WHERE id = '.$c; $sql1 = 'SELECT `office-part`,incipit,gabc,version,duplicateof FROM '.db('chants').' WHERE id = '.$c;
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error); $req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
$chants = array(); $chants = array();
$ch = $req1->fetch_assoc(); $ch = $req1->fetch_assoc();
if($ch['duplicateof']) return false;
return array($ch['office-part'], $ch['incipit'] > ''?$ch['incipit']:'░░'.$c.'░░', $ch['gabc'] > '', $ch['version']); return array($ch['office-part'], $ch['incipit'] > ''?$ch['incipit']:'░░'.$c.'░░', $ch['gabc'] > '', $ch['version']);
} }

View File

@ -8,7 +8,9 @@ $sql = 'SELECT * FROM '.db('pleasefix').' WHERE fixed = 0 ORDER BY `time`';
$req = $mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error); $req = $mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
if($req->num_rows > 0) { if($req->num_rows > 0) {
while($fix = $req->fetch_assoc()) { while($fix = $req->fetch_assoc()) {
echo '<h4><a href="chant.php?id='.$fix['chant_id'].'">'.format_incipit(chant_from_id($fix['chant_id'])[1])."</a></h4>\n"; $t = chant_from_id($fix['chant_id']);
if($t) {
echo '<h4><a href="chant.php?id='.$fix['chant_id'].'">'.format_incipit($t[1])."</a></h4>\n";
echo "<p><i>".nl2br(htmlspecialchars($fix['pleasefix'])).'</i> <span class="version"> (Reported on '.date("Y-m-d",$fix['time']); echo "<p><i>".nl2br(htmlspecialchars($fix['pleasefix'])).'</i> <span class="version"> (Reported on '.date("Y-m-d",$fix['time']);
if($fix['user_id']) { if($fix['user_id']) {
$user_info = get_userdata($fix['user_id']); $user_info = get_userdata($fix['user_id']);
@ -16,6 +18,7 @@ if($req->num_rows > 0) {
} }
echo ")</span></p>\n"; echo ")</span></p>\n";
} }
}
} else { } else {
echo "<p>No problem reported</p>\n"; echo "<p>No problem reported</p>\n";
} }

View File

@ -71,9 +71,12 @@ foreach($mod as $d => $ml) {
echo $d; echo $d;
echo "<ul>\n"; echo "<ul>\n";
foreach($ml as $m) { foreach($ml as $m) {
echo '<li><a href="chant.php?id='.$m['chant_id'].'">'.format_incipit(chant_from_id($m['chant_id'])[1])."</a><br />\n"; $t = chant_from_id($m['chant_id']);
if($t) {
echo '<li><a href="chant.php?id='.$m['chant_id'].'">'.format_incipit($t[1])."</a><br />\n";
echo "<i>".htmlspecialchars($m['comment'])."</i></li>\n"; echo "<i>".htmlspecialchars($m['comment'])."</i></li>\n";
} }
}
echo "</ul><br />\n"; echo "</ul><br />\n";
} }
echo "</div>"; echo "</div>";

View File

@ -52,6 +52,7 @@ if(array_key_exists('images', $_GET) && $_GET['images'] == '1') {
$ch = $chants[$p]; $ch = $chants[$p];
foreach($ch as $c) { foreach($ch as $c) {
$t = chant_from_id($c[0]); $t = chant_from_id($c[0]);
if($t) {
echo '<li class="usage-marker '.$t[0].'">'; echo '<li class="usage-marker '.$t[0].'">';
if($t[2]) { if($t[2]) {
echo '<a href="chant.php?id='.$c[0].'">'.format_incipit($t[1])."</a>"; echo '<a href="chant.php?id='.$c[0].'">'.format_incipit($t[1])."</a>";
@ -61,6 +62,7 @@ if(array_key_exists('images', $_GET) && $_GET['images'] == '1') {
echo "</li>\n"; echo "</li>\n";
} }
} }
}
echo '<li class="add-chant"><a href="chant_edit.php?source='.$s.'&amp;page='.$p.'">Add chant</a></li>'."\n"; echo '<li class="add-chant"><a href="chant_edit.php?source='.$s.'&amp;page='.$p.'">Add chant</a></li>'."\n";
echo "</ul>\n"; echo "</ul>\n";
echo "</td>\n"; echo "</td>\n";
@ -89,6 +91,7 @@ if(array_key_exists('images', $_GET) && $_GET['images'] == '1') {
unset($chants[$p]); unset($chants[$p]);
foreach($ch as $c) { foreach($ch as $c) {
$t = chant_from_id($c[0]); $t = chant_from_id($c[0]);
if($t) {
echo '<li class="usage-marker '.$t[0].'">'; echo '<li class="usage-marker '.$t[0].'">';
if($t[2]) { if($t[2]) {
echo '<a href="chant.php?id='.$c[0].'">'.format_incipit($t[1])."</a>"; echo '<a href="chant.php?id='.$c[0].'">'.format_incipit($t[1])."</a>";
@ -97,6 +100,7 @@ if(array_key_exists('images', $_GET) && $_GET['images'] == '1') {
} }
echo "</li>\n"; echo "</li>\n";
} }
}
echo "</ul>\n"; echo "</ul>\n";
echo "</td></tr>\n"; echo "</td></tr>\n";
} }

View File

@ -22,9 +22,12 @@ foreach($mod as $d => $ml) {
echo "<h4>".$d."</h4>\n"; echo "<h4>".$d."</h4>\n";
echo "<ul>\n"; echo "<ul>\n";
foreach($ml as $m) { foreach($ml as $m) {
$t = chant_from_id($m['chant_id']);
if($t) {
$user_info = get_userdata($m['user_id']); $user_info = get_userdata($m['user_id']);
echo "<li>".' <a href="chant.php?id='.$m['chant_id'].'">'.format_incipit(chant_from_id($m['chant_id'])[1])."</a><br />\n"; echo "<li>".' <a href="chant.php?id='.$m['chant_id'].'">'.format_incipit($t[1])."</a><br />\n";
echo "<i>".htmlspecialchars($m['comment']).'</i> <span class="version">('.$user_info->display_name.")</span></li>\n"; echo "<i>".htmlspecialchars($m['comment']).'</i>'.($u > ''?"":' <span class="version">(<a href="'.$_SERVER['PHP_SELF'].'?user='.$m['user_id'].'">'.$user_info->display_name."</a>)</span>")."</li>\n";
}
} }
echo "</ul>\n"; echo "</ul>\n";
} }

View File

@ -13,7 +13,7 @@ if(!array_key_exists($id,$txt['usage'])) {
$title = 'Usage - '.$txt['usage'][$id]; $title = 'Usage - '.$txt['usage'][$id];
include('include/header.php'); include('include/header.php');
echo "<h2>$title</h2>\n"; echo "<h2>$title</h2>\n";
$sql1 = 'SELECT * FROM '.db('chants').' WHERE `office-part` = "'.$id.'" ORDER BY incipit ASC'; $sql1 = 'SELECT * FROM '.db('chants').' WHERE `duplicateof` IS NULL AND `office-part` = "'.$id.'" ORDER BY incipit ASC';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error); $req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
$chants = array(); $chants = array();
while($c = $req1->fetch_assoc()) { while($c = $req1->fetch_assoc()) {