Skip to content

Commit 955dbfe

Browse files
authored
Merge pull request #1631 from hashtopolis/1351-insert-counts-on-exports
filetypes and counts are inserted on exported files
2 parents 8cdbfd6 + 68d4cc5 commit 955dbfe

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/inc/utils/HashlistUtils.class.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public static function createWordlists($hashlistId, $user) {
213213
fclose($wordlistFile);
214214

215215
//add file to files list
216-
$file = new File(null, $wordlistName, Util::filesize($wordlistFilename), $hashlist->getIsSecret(), 0, $hashlist->getAccessGroupId(), $wordCount);
216+
$file = new File(null, $wordlistName, Util::filesize($wordlistFilename), $hashlist->getIsSecret(), DFileType::WORDLIST, $hashlist->getAccessGroupId(), $wordCount);
217217
$file = Factory::getFileFactory()->save($file);
218218
# TODO: returning wordCount and wordlistName are not really required here as the name and the count are already given in the file object
219219
return [$wordCount, $wordlistName, $file];
@@ -711,6 +711,7 @@ public static function export($hashlistId, $user) {
711711
$pagingSize = SConfig::getInstance()->getVal(DConfig::HASHES_PAGE_SIZE);
712712
}
713713
$separator = SConfig::getInstance()->getVal(DConfig::FIELD_SEPARATOR);
714+
$numEntries = 0;
714715
for ($x = 0; $x * $pagingSize < $count; $x++) {
715716
$oF = new OrderFilter($orderObject, "ASC LIMIT " . ($x * $pagingSize) . ",$pagingSize");
716717
$entries = $factory->filter([Factory::FILTER => [$qF1, $qF2], Factory::ORDER => $oF]);
@@ -733,12 +734,13 @@ public static function export($hashlistId, $user) {
733734
break;
734735
}
735736
}
737+
$numEntries += sizeof($entries);
736738
fputs($file, $buffer);
737739
}
738740
fclose($file);
739741
usleep(1000000);
740742

741-
$file = new File(null, $tmpname, Util::filesize($tmpfile), $hashlist->getIsSecret(), 0, $hashlist->getAccessGroupId(), null);
743+
$file = new File(null, $tmpname, Util::filesize($tmpfile), $hashlist->getIsSecret(), DFileType::OTHER, $hashlist->getAccessGroupId(), $numEntries);
742744
$file = Factory::getFileFactory()->save($file);
743745
return $file;
744746
}
@@ -1098,6 +1100,7 @@ public static function leftlist($hashlistId, $user) {
10981100
if (SConfig::getInstance()->getVal(DConfig::HASHES_PAGE_SIZE) !== false) {
10991101
$pagingSize = SConfig::getInstance()->getVal(DConfig::HASHES_PAGE_SIZE);
11001102
}
1103+
$numEntries = 0;
11011104
for ($x = 0; $x * $pagingSize < $count; $x++) {
11021105
$oF = new OrderFilter(Hash::HASH_ID, "ASC LIMIT " . ($x * $pagingSize) . ",$pagingSize");
11031106
$entries = Factory::getHashFactory()->filter([Factory::FILTER => [$qF1, $qF2], Factory::ORDER => $oF]);
@@ -1109,12 +1112,13 @@ public static function leftlist($hashlistId, $user) {
11091112
}
11101113
$buffer .= "\n";
11111114
}
1115+
$numEntries += sizeof($entries);
11121116
fputs($file, $buffer);
11131117
}
11141118
fclose($file);
11151119
usleep(1000000);
11161120

1117-
$file = new File(null, $tmpname, Util::filesize($tmpfile), $hashlist->getIsSecret(), 0, $hashlist->getAccessGroupId(), null);
1121+
$file = new File(null, $tmpname, Util::filesize($tmpfile), $hashlist->getIsSecret(), DFileType::OTHER, $hashlist->getAccessGroupId(), $numEntries);
11181122
return Factory::getFileFactory()->save($file);
11191123
}
11201124

0 commit comments

Comments
 (0)