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');
}
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'].'░░';
$custom_header = <<<HEADER
<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()) {
$user_info = get_userdata($m['user_id']);
echo '<entry>
<title type="html">'.chant_from_id($m['chant_id'])[1].'</title>
$t = chant_from_id($m['chant_id']);
if($t) {
$user_info = get_userdata($m['user_id']);
echo '<entry>
<title type="html">'.$t[1].'</title>
<link href="'.$dir.'chant.php?id='.$m['chant_id'].'" />
<summary>'.htmlspecialchars($m['comment']).'</summary>
<updated>'.date(DATE_ATOM,$m['time']).'</updated>
@ -51,6 +53,7 @@ while($m = $req1->fetch_assoc()) {
<id>'.$dir.'history.php?changeset='.$m['time'].'%7C'.$m['chant_id'].'%7C'.$m['user_id'].'</id>
</entry>
';
}
}
echo '</feed>';
?>

View File

@ -1,9 +1,9 @@
-- phpMyAdmin SQL Dump
-- version 5.1.0-rc2
-- version 5.1.0
-- https://www.phpmyadmin.net/
--
-- 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 de PHP : 7.4.15
@ -67,7 +67,8 @@ CREATE TABLE `gregobase_chants` (
`gabc_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,
`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;
-- --------------------------------------------------------

View File

@ -11,9 +11,9 @@ include('include/header.php');
echo "<h2>$title</h2>\n";
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 {
$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);
$chants = array();

View File

@ -2,10 +2,11 @@
function chant_from_id($c) {
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);
$chants = array();
$ch = $req1->fetch_assoc();
if($ch['duplicateof']) return false;
return array($ch['office-part'], $ch['incipit'] > ''?$ch['incipit']:'░░'.$c.'░░', $ch['gabc'] > '', $ch['version']);
}

View File

@ -8,13 +8,16 @@ $sql = 'SELECT * FROM '.db('pleasefix').' WHERE fixed = 0 ORDER BY `time`';
$req = $mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
if($req->num_rows > 0) {
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";
echo "<p><i>".nl2br(htmlspecialchars($fix['pleasefix'])).'</i> <span class="version"> (Reported on '.date("Y-m-d",$fix['time']);
if($fix['user_id']) {
$user_info = get_userdata($fix['user_id']);
echo ' by '.$user_info->display_name;
$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']);
if($fix['user_id']) {
$user_info = get_userdata($fix['user_id']);
echo ' by '.$user_info->display_name;
}
echo ")</span></p>\n";
}
echo ")</span></p>\n";
}
} else {
echo "<p>No problem reported</p>\n";

View File

@ -71,8 +71,11 @@ foreach($mod as $d => $ml) {
echo $d;
echo "<ul>\n";
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";
echo "<i>".htmlspecialchars($m['comment'])."</i></li>\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 "</ul><br />\n";
}

View File

@ -52,13 +52,15 @@ if(array_key_exists('images', $_GET) && $_GET['images'] == '1') {
$ch = $chants[$p];
foreach($ch as $c) {
$t = chant_from_id($c[0]);
echo '<li class="usage-marker '.$t[0].'">';
if($t[2]) {
echo '<a href="chant.php?id='.$c[0].'">'.format_incipit($t[1])."</a>";
} else {
echo '<span class="todo">'.format_incipit($t[1]).'</span> (<a href="chant_edit.php?id='.$c[0].'">TODO</a>)';
if($t) {
echo '<li class="usage-marker '.$t[0].'">';
if($t[2]) {
echo '<a href="chant.php?id='.$c[0].'">'.format_incipit($t[1])."</a>";
} else {
echo '<span class="todo">'.format_incipit($t[1]).'</span> (<a href="chant_edit.php?id='.$c[0].'">TODO</a>)';
}
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";
@ -89,13 +91,15 @@ if(array_key_exists('images', $_GET) && $_GET['images'] == '1') {
unset($chants[$p]);
foreach($ch as $c) {
$t = chant_from_id($c[0]);
echo '<li class="usage-marker '.$t[0].'">';
if($t[2]) {
echo '<a href="chant.php?id='.$c[0].'">'.format_incipit($t[1])."</a>";
} else {
echo '<span class="todo">'.format_incipit($t[1]).'</span>';
if($t) {
echo '<li class="usage-marker '.$t[0].'">';
if($t[2]) {
echo '<a href="chant.php?id='.$c[0].'">'.format_incipit($t[1])."</a>";
} else {
echo '<span class="todo">'.format_incipit($t[1]).'</span>';
}
echo "</li>\n";
}
echo "</li>\n";
}
echo "</ul>\n";
echo "</td></tr>\n";

View File

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

View File

@ -13,7 +13,7 @@ if(!array_key_exists($id,$txt['usage'])) {
$title = 'Usage - '.$txt['usage'][$id];
include('include/header.php');
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);
$chants = array();
while($c = $req1->fetch_assoc()) {