Esempio n. 1
0
<?php

require_once dirname(__FILE__) . '/../../www/config.php';
$db = new \newznab\db\Settings();
$sql = "select distinct rageid from tvrage where rageid in (select rageid from tvrage where rageid != -2 group by rageid having count(*) > 1)";
$rows = $db->query($sql);
foreach ($rows as $row) {
    $sql = "select id, rageid, tvdbid from tvrage where rageid = " . $row["rageid"] . "\n";
    $tvrows = $db->query($sql);
    $count = 0;
    $keeprow = "0";
    $firstrow = "0";
    foreach ($tvrows as $tvrow) {
        $count++;
        if ($tvrow["tvdbid"] != 0) {
            $keeprow = $tvrow["id"];
        }
        if ($count == 1) {
            $firstrow = $tvrow["id"];
        }
    }
    if ($keeprow != "0") {
        $firstrow = "0";
    }
    $sql = "delete from tvrage where rageid = " . $row["rageid"] . " and (id != " . $keeprow . " and id != " . $firstrow . ")";
    $db->exec($sql);
    echo "Cleaned - " . $row["rageid"] . "\n";
}
Esempio n. 2
0
<?php

require_once dirname(__FILE__) . '/../../www/config.php';
$db = new \newznab\db\Settings();
//query to find rough matches
$rows = $db->query("SELECT ID, searchname from releases where searchname like '%QWERTY%'");
//loop around them applying some ham fisted regex
foreach ($rows as $row) {
    $reg = '/^(\\[QWERTY\\] ")(?P<name>.*?(xvid|x264)\\-.*?)"/i';
    preg_match($reg, $row["searchname"], $matches);
    if (isset($matches["name"])) {
        $db->exec(sprintf("update releases set searchname = %s, name = %s where ID = %d", $db->escapeString($matches["name"]), $db->escapeString($matches["name"]), $row["id"]));
        echo $matches["name"] . "\n";
    }
}