count less

This commit is contained in:
Shish 2023-01-11 11:41:13 +00:00
parent 9587bedae0
commit f91daba264
5 changed files with 24 additions and 15 deletions

View file

@ -116,15 +116,10 @@ class Tag
$tags1 = array_map("strtolower", $tags1);
$tags2 = array_map("strtolower", $tags2);
natcasesort($tags1);
natcasesort($tags2);
sort($tags1);
sort($tags2);
for ($i = 0; $i < count($tags1); $i++) {
if ($tags1[$i]!==$tags2[$i]) {
return false;
}
}
return true;
return $tags1 == $tags2;
}
public static function get_diff_tags(array $source, array $remove): array

View file

@ -23,4 +23,13 @@ class TagTest extends TestCase
$this->assertEquals("foo^q", Tag::caret("foo?"));
$this->assertEquals("a^^b^sc^bd^qe^af", Tag::caret("a^b/c\\d?e&f"));
}
public function test_compare()
{
$this->assertFalse(Tag::compare(["foo"], ["bar"]));
$this->assertFalse(Tag::compare(["foo"], ["foo", "bar"]));
$this->assertTrue(Tag::compare([], []));
$this->assertTrue(Tag::compare(["foo"], ["FoO"]));
$this->assertTrue(Tag::compare(["foo", "bar"], ["bar", "FoO"]));
}
}

View file

@ -1050,7 +1050,8 @@ class Artists extends Extension
ORDER BY alias ASC
", ['artist_id'=>$artistID]);
for ($i = 0 ; $i < count($result) ; $i++) {
$rc = count($result);
for ($i = 0 ; $i < $rc ; $i++) {
$result[$i]["alias_name"] = stripslashes($result[$i]["alias_name"]);
}
return $result;

View file

@ -439,7 +439,8 @@ class ArtistsTheme extends Themelet
$html .= "</tr>";
if (count($aliases) > 1) {
for ($i = 1; $i < count($aliases); $i++) {
$ac = count($aliases);
for ($i = 1; $i < $ac; $i++) {
$aliasViewLink = str_replace("_", " ", $aliases[$i]['alias_name']); // no link anymore
$aliasEditLink = "<a href='" . make_link("artist/alias/edit/" . $aliases[$i]['alias_id']) . "'>Edit</a>";
$aliasDeleteLink = "<a href='" . make_link("artist/alias/delete/" . $aliases[$i]['alias_id']) . "'>Delete</a>";
@ -482,7 +483,8 @@ class ArtistsTheme extends Themelet
$html .= "</tr>";
if (count($members) > 1) {
for ($i = 1; $i < count($members); $i++) {
$mc = count($members);
for ($i = 1; $i < $mc; $i++) {
$memberViewLink = str_replace("_", " ", $members[$i]['name']); // no link anymore
$memberEditLink = "<a href='" . make_link("artist/member/edit/" . $members[$i]['id']) . "'>Edit</a>";
$memberDeleteLink = "<a href='" . make_link("artist/member/delete/" . $members[$i]['id']) . "'>Delete</a>";
@ -527,7 +529,8 @@ class ArtistsTheme extends Themelet
$html .= "</tr>";
if (count($urls) > 1) {
for ($i = 1; $i < count($urls); $i++) {
$uc = count($urls);
for ($i = 1; $i < $uc; $i++) {
$urlViewLink = "<a href='" . str_replace("_", " ", $urls[$i]['url']) . "' target='_blank'>" . str_replace("_", " ", $urls[$i]['url']) . "</a>";
$urlEditLink = "<a href='" . make_link("artist/url/edit/" . $urls[$i]['id']) . "'>Edit</a>";
$urlDeleteLink = "<a href='" . make_link("artist/url/delete/" . $urls[$i]['id']) . "'>Delete</a>";

View file

@ -154,16 +154,17 @@ class MimeType
private static function compare_file_bytes(string $file_name, array $comparison): bool
{
$size = filesize($file_name);
if ($size < count($comparison)) {
$cc = count($comparison);
if ($size < $cc) {
// Can't match because it's too small
return false;
}
if (($fh = @fopen($file_name, 'rb'))) {
try {
$chunk = unpack("C*", fread($fh, count($comparison)));
$chunk = unpack("C*", fread($fh, $cc));
for ($i = 0; $i < count($comparison); $i++) {
for ($i = 0; $i < $cc; $i++) {
$byte = $comparison[$i];
if ($byte == null) {
continue;