0.7.12.6pre
Better dupes handling
This commit is contained in:
49
web/rtc.php
49
web/rtc.php
@@ -370,7 +370,9 @@ if ($db_file) {
|
||||
$dbo = new PDO("sqlite:".$db_file);
|
||||
$dbp = new PDO("sqlite:".dirname($db_file)."/pool.sqlite3");
|
||||
$dbo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||
$dbo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$dbp->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||
$dbp->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
// Get zpath
|
||||
|
||||
@@ -598,7 +600,15 @@ if ($db_file) {
|
||||
}
|
||||
|
||||
echo "</div>";
|
||||
|
||||
|
||||
if ($dbo->query("SELECT name FROM sqlite_master WHERE name='dupes'")->fetch()) {
|
||||
$dupes = $dbo->query("SELECT dupes FROM dupes WHERE (fid='".$row_a['fid']."')")->fetch();
|
||||
if ($dupes) {
|
||||
$count = count(unserialize($dupes['dupes']));
|
||||
echo "<form action='' method='post'><input type='hidden' name='query' size='50' value='".$row_a['fid']."'><input type='submit' value='show ".$count." dupes'></form>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "</td>";
|
||||
|
||||
echo "<td valign='top'>";
|
||||
@@ -767,16 +777,37 @@ if ($db_file) {
|
||||
|
||||
// Search
|
||||
|
||||
$result = $dbo->query("SELECT * FROM files WHERE (Filename LIKE '%".$search."%')")->fetchAll();
|
||||
|
||||
if (count($result)) {
|
||||
echo count($result)." results<br>";
|
||||
foreach ($result as $row) {
|
||||
$pathbold = str_ireplace($search,"<b>".$search."</b>",$row['Pathname']);
|
||||
echo "\n<a href='?db=".$db_file."&pid=".$row['pid']."'>".$pathbold."</a><br>";
|
||||
if (@$dbo->query("SELECT name FROM sqlite_master WHERE name='dupes'")->fetch() && strlen($search) == 32) {
|
||||
// this is a hash search with dupes table
|
||||
|
||||
$dupesearch = @$dbo->query("SELECT dupes FROM dupes WHERE (fid = '".$search."')")->fetch()['dupes'];
|
||||
if ($dupesearch) {
|
||||
foreach (unserialize($dupesearch) as $pathname) {
|
||||
echo "\n<a href='?db=".$db_file."&pid=".md5($pathname)."'>".$pathname."</a><br>";
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
echo "No results for ".$search;
|
||||
// this is a text search
|
||||
|
||||
if (strlen($search) == 32) {
|
||||
$result = $dbo->query("SELECT * FROM files WHERE (fid = '".$search."')")->fetchAll();
|
||||
$label = "hash";
|
||||
} else {
|
||||
$result = $dbo->query("SELECT * FROM files WHERE (Filename LIKE '%".$search."%')")->fetchAll();
|
||||
$label = "text";
|
||||
}
|
||||
|
||||
if (count($result)) {
|
||||
echo count($result)." ".$label." results<br>";
|
||||
foreach ($result as $row) {
|
||||
$pathbold = str_ireplace($search,"<b>".$search."</b>",$row['Pathname']);
|
||||
echo "\n<a href='?db=".$db_file."&pid=".$row['pid']."'>".$pathbold."</a><br>";
|
||||
}
|
||||
} else {
|
||||
echo "No results for ".$label." ".$search;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user