Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 5 additions & 24 deletions src/inc/utils/HashlistUtils.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,6 @@ public static function processZap($hashlistId, $separator, $source, $post, $file
$ll = Factory::getHashlistFactory()->get($l->getId());
Factory::getHashlistFactory()->inc($ll, Hashlist::CRACKED, $crackedIn[$ll->getId()]);
}
Factory::getAgentFactory()->getDB()->commit();
Factory::getAgentFactory()->getDB()->beginTransaction();
foreach ($hashlists as $l) {
$crackedIn[$l->getId()] = 0;
}
Expand Down Expand Up @@ -600,23 +598,8 @@ public static function delete($hashlistId, $user) {
switch ($hashlist->getFormat()) {
case 0:
$count = Factory::getHashlistFactory()->countFilter([]);
if ($count > 1) {
$deleted = 1;
$qF = new QueryFilter(Hash::HASHLIST_ID, $hashlist->getId(), "=");
$oF = new OrderFilter(Hash::HASH_ID, "ASC LIMIT 20000");
while ($deleted > 0) {
$result = Factory::getHashFactory()->massDeletion([Factory::FILTER => $qF, Factory::ORDER => $oF]);
$deleted = $result->rowCount();
Factory::getAgentFactory()->getDB()->commit();
Factory::getAgentFactory()->getDB()->beginTransaction();
}
}
else {
// in case there is only one hashlist to delete, truncate the Hash table.
Factory::getAgentFactory()->getDB()->query("TRUNCATE TABLE Hash");
// Make sure that a transaction is active, this is what the rest of the function expects.
Factory::getAgentFactory()->getDB()->beginTransaction();
}
$qF = new QueryFilter(Hash::HASHLIST_ID, $hashlist->getId(), "=");
Factory::getHashFactory()->massDeletion([Factory::FILTER => $qF]);
break;
case 1:
case 2:
Expand Down Expand Up @@ -801,6 +784,7 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted,
}

Factory::getAgentFactory()->getDB()->beginTransaction();

$hashlist = new Hashlist(null, $name, $format, $hashtype, 0, $separator, 0, $secret, $hexsalted, $salted, $accessGroup->getId(), '', $brainId, $brainFeatures, 0);
$hashlist = Factory::getHashlistFactory()->save($hashlist);

Expand Down Expand Up @@ -835,9 +819,9 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted,
}
$file = fopen($tmpfile, "rb");
if (!$file) {
Factory::getAgentFactory()->getDB()->rollback();
throw new HttpError("Failed to open file!");
}
Factory::getAgentFactory()->getDB()->commit();
$added = 0;
$preFound = 0;

Expand All @@ -855,7 +839,6 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted,
$saltSeparator = "";
}
rewind($file);
Factory::getAgentFactory()->getDB()->beginTransaction();
$values = array();
$bufferCount = 0;
while (!feof($file)) {
Expand Down Expand Up @@ -900,8 +883,6 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted,
if ($bufferCount >= 10000) {
$result = Factory::getHashFactory()->massSave($values);
$added += $result->rowCount();
Factory::getAgentFactory()->getDB()->commit();
Factory::getAgentFactory()->getDB()->beginTransaction();
$values = array();
$bufferCount = 0;
}
Expand All @@ -913,7 +894,6 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted,
fclose($file);
unlink($tmpfile);
Factory::getHashlistFactory()->mset($hashlist, [Hashlist::HASH_COUNT => $added, Hashlist::CRACKED => $preFound]);
Factory::getAgentFactory()->getDB()->commit();
Util::createLogEntry("User", $user->getId(), DLogEntry::INFO, "New Hashlist created: " . $hashlist->getHashlistName());

NotificationHandler::checkNotifications(DNotificationType::NEW_HASHLIST, new DataSet(array(DPayloadKeys::HASHLIST => $hashlist)));
Expand Down Expand Up @@ -1003,6 +983,7 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted,
NotificationHandler::checkNotifications(DNotificationType::NEW_HASHLIST, new DataSet(array(DPayloadKeys::HASHLIST => $hashlist)));
break;
}
Factory::getAgentFactory()->getDB()->commit();
return $hashlist;
}

Expand Down