-
Notifications
You must be signed in to change notification settings - Fork 2
/
hashcompare.php
executable file
·69 lines (52 loc) · 1.96 KB
/
hashcompare.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
define('FS_ROOT_OVERRIDE', realpath(dirname(__FILE__)));
require_once (FS_ROOT_OVERRIDE . "/../../www/config.php");
require_once (FS_ROOT_OVERRIDE . "/../../www/lib/framework/db.php");
require_once (FS_ROOT_OVERRIDE . "/../../www/lib/releases.php");
require_once (FS_ROOT_OVERRIDE . "/../../www/lib/category.php");
function getRelease($name)
{
$db = new DB();
return $db->queryOneRow(sprintf("SELECT count(*) as total FROM prehash WHERE releasename = %s", $db->escapeString($name)));
}
function AddRelease($name, $date)
{
$db = new DB();
return $db->queryInsert(sprintf("INSERT INTO prehash (releasename, hash, predate) VALUES (%s, %s, %s)", $db->escapeString($name), $db->escapeString(md5($name)), $db->escapeString($date)));
}
function CheckExists()
{
$db = new DB();
return $db->query(sprintf("select 1 from prehash"));
}
function getHashes()
{
$db = new DB();
return $db->query(sprintf("SELECT r.ID, ph.releasename, g.name FROM releases r join prehash ph on ph.hash = r.searchname join groups g ON g.ID = r.groupID WHERE r.categoryid = 8010"));
}
function updaterelease($foundName, $id, $groupname)
{
$db = new DB();
$rel = new Releases();
$cat = new Category();
$cleanRelName = $rel->cleanReleaseName($foundName);
$catid = $cat->determineCategory($groupname, $foundName);
$db->query(sprintf("UPDATE releases SET name = %s, searchname = %s, categoryID = %d WHERE ID = %d", $db->escapeString($cleanRelName), $db->escapeString($cleanRelName), $catid, $id));
}
function hashInit()
{
if (CheckExists() !== false)
{
$results = getHashes();
foreach($results as $result)
{
echo "Hash Match! Renaming release... ".$result['releasename']."\n";
updaterelease($result['releasename'], $result['ID'], $result['name']);
}
}
if ($results !=getHashes());
{
echo "No hash match found!\n";
}
}
?>