public function __construct($category_id, $item_id) { $data = DB::queryOneRow("SELECT * FROM category_items WHERE category_id=%d AND id=%d", $category_id, $item_id); foreach ($data as $k => $v) { $this->{$k} = $v; } }
public function getCount($ragename = "") { $db = new DB(); $rsql = ''; if ($ragename != "") { $rsql .= sprintf("and tvrage.releasetitle like %s ", $db->escapeString("%" . $ragename . "%")); } $res = $db->queryOneRow(sprintf("select count(ID) as num from tvrage where 1=1 %s ", $rsql)); return $res["num"]; }
public static function getByProjectIdFileName($projectId, $fileName, $tokenValue) { $file = null; if (CWM_API::IsTokenValid($tokenValue)) { //$userId = CWM_API::GetUserId($tokenValue); $row = DB::queryOneRow("SELECT * FROM CWM_File WHERE ProjectId=%? AND Name=%?", $projectId, $fileName); if (!is_null($row)) { $file = new CWM_File($row['Id'], $row['ProjectId'], $row['Name'], $row['Data'], $row['UserId'], $row['SolutionName'], $row['ProjectName'], $row['ShareId']); } } return $file; }
public function getHours() { if (!empty($this->hours)) { return $this->hours; } $hours = DB::queryOneRow("SELECT open_hours FROM item_hours WHERE restaurant_id=%d", $this->id); $this->hours = []; if (!empty($hours['open_hours'])) { $this->hours = explode(',', $hours['open_hours']); } return $this->hours; }
/** * Get count of all bookinfo rows for browse list. */ public function getBookCount($maxage = -1) { $db = new DB(); $browseby = $this->getBrowseBy(); if ($maxage > 0) { $maxage = sprintf(" and r.postdate > now() - interval %d day ", $maxage); } else { $maxage = ""; } $sql = sprintf("select count(distinct r.bookinfoID) as num from releases r inner join bookinfo b on b.ID = r.bookinfoID and b.title != '' where r.passwordstatus <= (select value from site where setting='showpasswordedrelease') %s %s", $browseby, $maxage); $res = $db->queryOneRow($sql, true); return $res["num"]; }
public function user_from_cookie() { if (!isset($_COOKIE["session"])) { return 0; } if ($_COOKIE['session'] == "0") { return 0; } $user = DB::queryOneRow("SELECT * FROM accounts WHERE session=%s", $_COOKIE['session']); if (count($user) == 0) { return 0; } return new UserManager($user); }
function getOrderForUser($user) { $data = array(); $order = DB::query("SELECT * FROM orders WHERE user_id=%s", $user->data["uid"]); $categories = DB::query("SELECT * FROM category_items"); foreach ($order as $o) { $time = $o["time"]; $catname = whereArray($categories, "id", $o["service_id"])["name"]; $address = UserManager::getAddressFor($o["user_id"]); $user = DB::queryOneRow("SELECT * FROM accounts WHERE uid=%s", $o["user_id"]); $items = UserManager::getItemsForCart($o["user_id"], $o["id"]); $address_str = sprintf("%s (%s) <br>%s, %s. %s", $address["street"], $address["apartment"], $address["city"], $address["state"], $address["zip"]); $odata = array($time, $catname, $user["name"], $address_str, $items["html"], $items["price"]); array_push($data, $odata); } return $data; }
function returnOrderedFeed($t, $s, $f, $c) { if ($t == -1 | $s == -1 | $c == -1) { return ""; } $service = DB::queryOneRow("SELECT id FROM categories WHERE id=%s", $s); $companies = DB::query("SELECT name, id, category_id FROM category_items WHERE category_id=%s AND id=%d", $service["id"], $c); $orders = array(); $now = new DateTime("now"); $addressCache = array(); foreach ($companies as $company) { if ($company["name"]) { $q = DB::query("SELECT * FROM orders WHERE service_id=%s AND category_id=%s", $company["category_id"], $company["id"]); } foreach ($q as $order) { if (!array_key_exists($order["user_id"], $addressCache)) { $addressCache[$order["user_id"]] = UserManager::getAddressFor($order["user_id"]); } $addr = refineArray(array($addressCache[$order["user_id"]]), array("street", "apartment", "city", "state", "zip"))[0]; $di = $now->diff(new DateTime($order["time"])); if ($di->d <= $t) { $items = UserManager::getItemsForCart($order["user_id"], $order["id"]); //$order["cart_id"]); $userdata = DB::queryOneRow("SELECT * FROM accounts WHERE uid=%s", $order["user_id"]); $userdata = refineArray(array($userdata), array("name", "email", "phone"))[0]; $nonOrderedOrder = array_merge($order, array_merge(array("compName" => $company["name"], "items" => $items["html"], "price" => $items["price"]), $addr, $userdata)); $sortOrder = array("time", "compName", 5, 6, 7, 0, 1, 2, 3, 4, "items", "price"); $nonOrderedOrder_trimmed = refineArray(array($nonOrderedOrder), $sortOrder)[0]; // time, restname, username, email, phone, street, apt, city, state, zip, items, total // array_multisort($nonOrderedOrder_trimmed, $sortOrder); $orderedOrder = $nonOrderedOrder_trimmed; $orderedOrder["category_id"] = $nonOrderedOrder["category_id"]; $orderedOrder["campus"] = $nonOrderedOrder["campus"]; $orderedOrder["timeSince"] = $di->d; $orders[] = $orderedOrder; } } } $keys = array("category_id", "timeSince", "campus"); $orders = array_orderby($orders, $keys[$f - 1], SORT_ASC); $orders = refineArrayReductively($orders, array("category_id", "campus", "timeSince")); return $orders; // t = time, s = service, f = filter, c = company }
public function getMusicCount($cat, $maxage = -1, $excludedcats = array()) { $db = new DB(); $browseby = $this->getBrowseBy(); $catsrch = ""; if (count($cat) > 0 && $cat[0] != -1) { $catsrch = " ("; foreach ($cat as $category) { if ($category != -1) { $categ = new Category(); if ($categ->isParent($category)) { $children = $categ->getChildren($category); $chlist = "-99"; foreach ($children as $child) { $chlist .= ", " . $child["ID"]; } if ($chlist != "-99") { $catsrch .= " r.categoryID in (" . $chlist . ") or "; } } else { $catsrch .= sprintf(" r.categoryID = %d or ", $category); } } } $catsrch .= "1=2 )"; } if ($maxage > 0) { $maxage = sprintf(" and r.postdate > now() - interval %d day ", $maxage); } else { $maxage = ""; } $exccatlist = ""; if (count($excludedcats) > 0) { $exccatlist = " and r.categoryID not in (" . implode(",", $excludedcats) . ")"; } $sql = sprintf("select count(r.ID) as num from releases r inner join musicinfo m on m.ID = r.musicinfoID and m.title != '' where r.passwordstatus <= (select value from site where setting='showpasswordedrelease') and %s %s %s %s", $browseby, $catsrch, $maxage, $exccatlist); $res = $db->queryOneRow($sql); return $res["num"]; }
public function getById($id) { $db = new DB(); return $db->queryOneRow(sprintf("select * from menu where ID = %d", $id)); }
<?php require_once __DIR__ . '/../all.php'; $cookies = new Cookies(); $user = $cookies->user_from_cookie(); $vars = array("type", "name"); $vars1 = array("name"); if (set_vars($_POST, $vars) && $user !== 0) { $type = $_POST["type"]; if ($user->data["permission"] == 4) { if ($type === "1" && set_vars($_POST, $vars1)) { $name = $_POST["name"]; $value = $_POST["value"]; $setting = DB::queryOneRow("SELECT * FROM settings WHERE name=%s", $name); if (DB::count() !== 0) { // valid if ($setting["value"] !== $value) { // change it DB::update("settings", array("value" => $value), "name=%s", $name); echo json_array(1, array("name" => $name, "value" => $value), "successfully changed"); return; } echo json_array(0, null, "no change made"); return; } echo json_array(0, null, "invalid setting"); return; } if ($type === "2") { $f = $_FILES['settingsfile']; $loc = uploadImage($f);
/** * Constructs a SphinxQL query. * * @param array $search * @param array $cat * @param int $offset * @param int $limit * @param array $order * @param int $maxage * @param array $excludedcats * @param array $grp * @param array $indexes * @param boolean $lookup * @param array $where * @param string $lookupQuery * */ public function buildQuery($search, $cat = array(), $offset = 0, $limit = 100, $order = array("postdate", "desc"), $maxage = -1, $excludedcats = array(), $grp = array(), $indexes = array(), $lookup = true, $where = array(), &$lookupQuery = "") { $ndb = new DB(); $offset = intval($offset); $limit = intval($limit); if ($lookup) { // Since we're going to look up the data from MySQL, we don't need // to get all the fields from Sphinx. $select = "ID, name "; } else { $select = "* "; } // Create a comma separated string of indexes, but only of enabled // indexes $searchIndexes = array(); foreach ($indexes as $index) { if ($this->isIndexEnabled($index)) { $searchIndexes[] = $index; } } if (count($searchIndexes) == 0) { $searchIndexes = array_reverse($this->getAllEnabledIndexes(true)); } $from = implode(", ", $searchIndexes); // Check to see if this is an extended query. If it is, remove the // leading "!" and don't touch the rest of the query. if (count($search) > 0) { if (substr($search[0], 0, 2) == "! ") { /* Extended Query */ $search[0] = substr($search[0], 2, strlen($search[0]) - 2); } else { /* Basic Query */ // Check to see if the the query contains any field specifiers like: // "@(field1,field2)"--if not, add in the default search fields. foreach ($search as $i => $q) { if ($q && !preg_match('/@\\(?\\w+/i', $q)) { // No field specifiers were found, so use the site-defaults. This // turns the query for "ubuntu" into something like: // "@(name,searchname) ubuntu" $fields = str_replace(" ", "", $this->site->sphinxsearchfields); // Remove single "-" so that Sphinx doesn't use it as an // exclusion modifier $q = preg_replace('/([^\\-])\\-/', '\\1 ', $q); // "basic" search syntax allows a "--" exclusion modifier, // but Sphinx uses "-" as a the exclusion modifier $q = str_replace("--", "-", $q); // always add on * to Season based searches $q = preg_replace('/([\\. ]S\\d{2})( |$)/i', '\\1*\\2', $q); // Construct the basic query $search[$i] = sprintf("@(%s) ", $fields) . $q; } } } } // Create the actual MATCH() query. Per the Sphinx docs, each query // can only have one MATCH() statement. if (count($search) > 0) { if (!(count($search) == 1 && $search[0] == "")) { // If we are searching across multiple indexes, it is safer to prepend // "@@relaxed" to the query to ensure that Sphinx doesn't choke on // differences in schemas. See: // http://sphinxsearch.com/docs/2.0.2/extended-syntax.html if (count($searchIndexes) > 1 && strpos($search[0], "@@relaxed") !== 0) { // We are searching across multiple indexes and the term // "@@relaxed" wasn't found at the beginning, $search[0] = "@@relaxed " . $search[0]; } $where[] = sprintf("MATCH(%s)", $ndb->escapeString(implode(' ', $search))); } } // Build the category query. If any of the categories are a "parent" // then we need to explicitly include their children as well. $categoryIDs = array(); if (count($cat) > 0 && $cat[0] != -1) { foreach ($cat as $category) { if ($category != -1) { if (!in_array($category, $categoryIDs)) { $categoryIDs[] = $category; } $categ = new Category(); if ($categ->isParent($category)) { // Inlcude all children $children = $categ->getChildren($category); foreach ($children as $child) { if (!in_array($child["ID"], $categoryIDs)) { $categoryIDs[] = $child["ID"]; } } } } } } // Only include the category filter if we created one. if ($categoryIDs) { $where[] = sprintf("categoryID IN (%s)", implode(",", $categoryIDs)); } // Filter on postdate. if ($maxage > 0) { // TODO: This probably isn't the best way to do this... $where[] = sprintf("postdate >= %d", time() - $maxage * 86400); } // Categories to exclude. if (count($excludedcats) > 0) { $where[] = sprintf("categoryID NOT IN (%s)", implode(",", $excludedcats)); } // Usenet groups to include. if ($grp) { foreach ($grp as $i => $g) { if (strpos($g, "a.b.") !== false) { $sql = sprintf("SELECT ID FROM groups " . "WHERE name = %s", $ndb->escapeString(str_replace("a.b.", "alt.binaries.", $g))); $row = $ndb->queryOneRow($sql); $grp[$i] = $row["ID"]; } } $where[] = sprintf("groupID IN (%s)", implode(",", $grp)); } // Order the results. // TODO: implement better default ordering behavior. $orderby = ""; if (count($order) == 2) { $orderby = sprintf("ORDER BY %s %s", $order[0], $order[1]); // Add in the ORDER BY parameters if there is a $lookupQuery if ($lookupQuery) { $lookupQuery = $lookupQuery . " " . $orderby; } } // Build the full query. $q = sprintf("SELECT %s FROM %s " . (!empty($where) ? "WHERE " : "") . " %s %s LIMIT %d,%d", $select, $from, implode(" AND ", $where), $orderby, $offset, $limit); // Sphinx imposes a 1000 result limit (max_matches) by default, so in // order to access results beyond this, we need to tell it to do so if ($offset >= 1000) { $q .= sprintf(" OPTION max_matches=%d", $offset + $limit); } return $q; }
/** * Returns the nfo from the database (blob) */ public function getNfo($relid, &$nfoout) { $db = new DB(); // Has NFO Query $mnfo = "SELECT uncompress(rn.nfo) as nfo FROM releases r " . "INNER JOIN releasenfo rn ON rn.releaseID = r.ID AND rn.ID = r.releasenfoID " . "WHERE rn.nfo IS NOT NULL AND r.ID = %d LIMIT 1"; $res = $db->queryOneRow(sprintf($mnfo, $relid)); if ($res && isset($res['nfo'])) { $nfoout = $res['nfo']; return true; } return false; }
public function getOrder($order_id) { $order = DB::queryOneRow("SELECT * FROM orders WHERE user_id=%s and id=%d", $this->id, $order_id); $categories = DB::query("SELECT * FROM category_items"); $time = $order["time"]; $catname = whereArray($categories, "id", $order["service_id"])["name"]; $address = UserManager::getAddressFor($order["user_id"]); $user = DB::queryOneRow("SELECT * FROM accounts WHERE uid=%s", $order["user_id"]); $items = UserManager::getItemsForCart($order["user_id"], $order["id"]); $address_str = sprintf("%s %s \n%s, %s. %s", $address["street"], $address["apartment"], $address["city"], $address["state"], $address["zip"]); return array('time' => $time, 'service' => $catname, 'recipient' => $user['name'], 'phone' => $user['phone'], 'email' => $user['email'], 'address' => $address_str, 'items' => $items['html'], 'price' => $items['price'], 'payment_type' => $order['payment_cc'] ? 'Credit Card' : 'Duke Card'); }
} echo sprintf('<option value="%s" %s>%s</option>', $cat["id"], $chk, $cat["name"]); } ?> </select> <input type="checkbox" id="item_has_sides" name="has_sides" value="1" <?php echo $checked; ?> > <label for="item_has_sides">Has Sides</label><br> <div id="used_sides" class="specific-info">Sides (used)</div> <div id="used_sides_sp"> <?php foreach ($side_link as $side) { $side_d = DB::queryOneRow("SELECT * FROM menu_sides WHERE id=%d", $side["sides_id"]); // echo sprintf("<div> // <div style=\"display: inline; float: left\"> // <span id=\"del-side-link-%s-%s\" class=\"del-side-link link_span\">- </span> // %s // </div> // <div style=\"display: inline; float: right\"> // $%s // </div> // </div><br>\n\n", $id, $side_d["id"], $side_d["name"], $side_d["price"]); if (!empty($side_d['name'])) { echo sprintf("<div><div><span id=\"del-side-link-%s-%s\" class=\"del-side-link link_span\">- </span> %s</div></div>", $id, $side_d["id"], $side_d["name"]); } } ?> </div>
/** * Performing parsing. */ public function process() { $db = new DB(); // Default query for both full db and last 4 hours. $sql = "SELECT r.searchname, r.name, r.fromname, r.ID as RID, r.categoryID, r.guid, r.postdate,\n\t\t\t rn.ID as nfoID,\n\t\t\t g.name as groupname,\n\t\t\t GROUP_CONCAT(rf.name) as filenames\n\t\tFROM releases r\n\t\tLEFT JOIN releasenfo rn ON (rn.releaseID = r.ID)\n\t\tLEFT JOIN groups g ON (g.ID = r.groupID)\n\t\tLEFT JOIN releasefiles rf ON (rf.releaseID = r.ID)\n\t\tWHERE r.categoryID in (" . Category::CAT_TV_OTHER . "," . Category::CAT_MOVIE_OTHER . "," . Category::CAT_MISC_OTHER . "," . Category::CAT_XXX_OTHER . ")\n\t\t%s\n\t\tGROUP BY r.ID"; $res = $db->query(sprintf($sql, $this->limited ? "AND r.adddate BETWEEN NOW() - INTERVAL 4 HOUR AND NOW()" : "")); $this->releasestocheck = sizeof($res); if ($res) { echo "PostPrc : Parsing last " . $this->releasestocheck . " releases in the Other-Misc categories\n"; foreach ($res as $rel) { $tempname = $foundName = $methodused = ''; //Knoc.One if (preg_match("/KNOC.ONE/i", $rel['name'])) { $title = ''; $items = preg_split("/(\\.| )/", $rel['name']); foreach ($items as $value) { if (preg_match("/^[a-z]+\$/i", $value)) { $len = strlen($value); if ($len > 2) { $title .= substr($value, -2) . substr($value, 0, -2) . " "; } elseif ($len = 2) { $title .= substr($value, -1) . substr($value, 0, -1) . " "; } else { $title .= $value . " "; } } else { $title .= $value . " "; } } $foundName = $title; $methodused = "Knoc.One"; $this->determineCategory($rel, $foundName, $methodused); } /// ///Use the Nfo to try to get the proper Releasename. /// $nfo = $db->queryOneRow(sprintf("select uncompress(nfo) as nfo from releasenfo where releaseID = %d", $rel['RID'])); if ($nfo && $foundName == "") { $this->nfosprocessed++; $nfo = $nfo['nfo']; //LOUNGE releases if (preg_match('/([a-z0-9.]+\\.MBLURAY)/i', $nfo, $matches)) { $foundName = $matches[1]; $methodused = "LOUNGE"; $this->determineCategory($rel, $foundName, $methodused); } //AsianDVDClub releases if (preg_match('/adc-[a-z0-9]{1,10}/', $rel['name'])) { if (preg_match('/.*\\(\\d{4}\\).*/i', $nfo, $matches)) { $foundName = $matches[0]; $methodused = "AsianDVDClub"; $this->determineCategory($rel, $foundName, $methodused); } } //ACOUSTiC releases if (preg_match('/ACOUSTiC presents \\.\\.\\..*?([a-z0-9].*?\\(.*?\\))/is', $nfo, $matches)) { $foundName = $matches[1] . ".MBLURAY"; $methodused = "ACOUSTiC "; $this->determineCategory($rel, $foundName, $methodused); } //Japhson releases if (preg_match('/Japhson/i', $nfo, $matches)) { $movie = new Movie(); $imdbID = null; if (preg_match('/tt(\\d{7})/i', $nfo, $matches)) { $imdbId = $matches[1]; $movCheck = $movie->fetchImdbProperties($imdbId); $foundName = $movCheck['title']; if (!preg_match('/(19|20)\\d{2}/i', $foundName)) { $foundName = $foundName . "." . $movCheck['year']; } if (preg_match('/language.*?\\b([a-z0-9]+)\\b/i', $nfo, $matches)) { if (!preg_match('/English/i', $matches[1])) { $foundName = $foundName . "." . $matches[1]; } } if (preg_match('/audio.*?\\b(\\w+)\\b/i', $nfo, $matches)) { if (preg_match('/(Chinese|German|Dutch|Spanish|Hebrew|Finnish|Norwegian)/i', $matches[1])) { $foundName = $foundName . "." . $matches[1]; } } if (preg_match('/(video|resolution|video res).*?(1080|720|816|820|272|1280 @|528|1920)/i', $nfo, $matches)) { if ($matches[2] == '1280 @') { $matches[2] = '720'; } if ($matches[2] == '1920') { $matches[2] = '1080'; } $foundName = $foundName . "." . $matches[2]; } if (preg_match('/source.*?\\b(DVD9|DVD5|BDRIP|DVD\\-?RIP|BLURAY)\\b/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } if (preg_match('/(video|resolution|video res).*?(XVID|X264|WMV)/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[2]; } if (preg_match('/audio.*?\\b(DTS|AC3)\\b/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } $foundName = $foundName . "-Japhson"; $methodused = "Japhson"; $this->determineCategory($rel, $foundName, $methodused); } } //AIHD releases if (preg_match('/ALWAYS iN HiGH/i', $nfo, $matches)) { $movie = new Movie(); $imdbID = null; if (preg_match('/tt(\\d{7})/i', $nfo, $matches)) { $imdbId = $matches[1]; $movCheck = $movie->fetchImdbProperties($imdbId); $foundName = $movCheck['title']; if (!preg_match('/(19|20)\\d{2}/i', $foundName)) { $foundName = $foundName . "." . $movCheck['year']; } if (preg_match('/L\\.([a-z0-9]+)\\b/i', $nfo, $matches)) { if (!preg_match('/En/i', $matches[1])) { $foundName = $foundName . "." . $matches[1]; } } if (preg_match('/(V).*?(1080|720|816|820|272|1280 @|528|1920)/i', $nfo, $matches)) { if ($matches[2] == '1280 @') { $matches[2] = '720'; } if ($matches[2] == '1920') { $matches[2] = '1080'; } $foundName = $foundName . "." . $matches[2]; } if (preg_match('/V.*?\\b(DVD9|DVD5|BDRIP|DVD\\-?RIP|BLURAY)\\b/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } if (preg_match('/(V).*?(XVID|X264|WMV)/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[2]; } if (preg_match('/A.*?\\b(DTS|AC3)\\b/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } $foundName = $foundName . "-AIHD"; $methodused = "AIHD"; $this->determineCategory($rel, $foundName, $methodused); } } //IMAGiNE releases if (preg_match('/\\*\\s+([a-z0-9]+(?:\\.|_| )[a-z0-9\\.\\_\\- ]+ \\- imagine)\\s+\\*/i', $nfo, $matches)) { $foundName = $matches[1]; $methodused = "imagine"; $this->determineCategory($rel, $foundName, $methodused); } //LEGION releases if (preg_match('/([a-z0-9 \\.\\-]+LEGi0N)/is', $nfo, $matches) && $foundName == "") { $foundName = $matches[1]; $methodused = "Legion"; $this->determineCategory($rel, $foundName, $methodused); } //SWAGGER releases if (preg_match('/(S W A G G E R|swg.*?nfo)/i', $nfo) && $foundName == "") { if (preg_match('/presents.*?([a-z0-9].*?\\((19|20)\\d{2}\\))/is', $nfo, $matches)) { $foundName = $matches[1]; } if (preg_match('/language.*?\\b([a-z0-9]+)\\b/i', $nfo, $matches)) { if ($matches[1] != "english") { $foundName = $foundName . "." . $matches[1]; } } if (preg_match('/resolution.*?(1080|720)/i', $nfo, $matches)) { $foundName = $foundName . ".BluRay." . $matches[1]; } if (preg_match('/video.*?\\b([a-z0-9]+)\\b/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } if (preg_match('/audio.*?\\b([a-z0-9]+)\\b/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } $foundName = $foundName . "-SWAGGER"; $methodused = "SWAGGER"; $this->determineCategory($rel, $foundName, $methodused); } //cm8 releases if (preg_match('/([a-z0-9]+(?:\\.|_| )[a-z0-9\\.\\_\\- \'\\)\\(]+\\-(futv|crimson|qcf|runner|clue|ftp|episode|momentum|PFA|topaz|vision|tdp|haggis|nogrp|shirk|imagine|santi|sys|deimos|ltu|ficodvdr|cm8|dvdr|Nodlabs|aaf|sprinter|exvid|flawl3ss|rx|magicbox|done|unveil))\\b/i', $nfo, $matches) && $foundName == "") { //echo "this: ".$matches[1]."\n"; $foundName = $matches[1]; $methodused = "cm8"; $this->determineCategory($rel, $foundName, $methodused); } //river if (preg_match('/([a-z0-9\\.\\_\\-]+\\-(webios|river|w4f|sometv|ngchd|C4|gf|bov|26k|ftw))\\b/i', $nfo, $matches) && $foundName == "") { $foundName = $matches[1]; $methodused = "river-1"; $this->determineCategory($rel, $foundName, $methodused); } if (preg_match('/([a-z0-9]+(?:\\.|_| )[a-z0-9\\.\\_\\- \'\\)\\(]+\\-(CiA|Anarchy|RemixHD|FTW|Revott|WAF|CtrlHD|Telly|Nif|Line|NPW|Rude|EbP|CRisC|SHK|AssAss1ns|Leverage|BBW|NPW))\\b/i', $nfo, $matches) && $foundName == "") { $foundName = $matches[1]; $methodused = "river-2"; $this->determineCategory($rel, $foundName, $methodused); } if (preg_match('/([a-z0-9]+(?:\\.|_| )[a-z0-9\\.\\_\\- \'\\)\\(]+\\-(XPD|RHyTM))\\b/i', $nfo, $matches) && $foundName == "") { $foundName = $matches[1]; $methodused = "river-3"; $this->determineCategory($rel, $foundName, $methodused); } if (preg_match('/(-PROD$|-BOV$|-NMR$|$-HAGGiS|-JUST$|CRNTV$|-MCA$|int$|-DEiTY$|-VoMiT$|-iNCiTE$|-BRUTUS$|-DCN$|-saints$|-sfm$|-lol$|-fov$|-logies$|-c4tv$|-fqm$|-jetset$|-ils$|-miragetv$|-gfvid$|-btl$|-terra$)/i', $rel['searchname']) && $foundName == "") { $foundName = $rel['searchname']; $methodused = "river-4"; $this->determineCategory($rel, $foundName, $methodused); } //SANTi releases if (preg_match('/\\b([a-z0-9]+(?:\\.|_| )[a-z0-9\\.\\_\\- \']+\\-santi)\\b/i', $nfo, $matches) && $foundName == "") { $foundName = $matches[1]; $methodused = "SANTi"; $this->determineCategory($rel, $foundName, $methodused); } //INSPiRAL releases if (preg_match('/^([a-z0-9]+(?:\\.|_| )[a-z0-9\\.\\_\\- ]+ \\- INSPiRAL)\\s+/im', $nfo, $matches) && $foundName == "") { $foundName = $matches[1]; $methodused = "INSPiRAL"; $this->determineCategory($rel, $foundName, $methodused); } //CIA releases if (preg_match('/Release NAME.*?\\:.*?([a-z0-9][a-z0-9\\.\\ ]+)\\b.*?([a-z0-9][a-z0-9\\.\\ ]+\\-CIA)\\b/is', $nfo, $matches) && $foundName == "") { $foundName = $matches[1] . $matches[2]; $methodused = "CIA"; $this->determineCategory($rel, $foundName, $methodused); } //HDChina releases if (preg_match('/HDChina/', $nfo) && $foundName == "") { if (preg_match('/Disc Title\\:.*?\\b([a-z0-9\\ \\.\\-\\_()]+\\-HDChina)/i', $nfo, $matches)) { $foundName = $matches[1]; $methodused = "HDChina"; $this->determineCategory($rel, $foundName, $methodused); } } //Pringles if (preg_match('/PRiNGLES/', $nfo) && $foundName == "") { if (preg_match('/is giving you.*?\\b([a-z0-9 ]+)\\s/i', $nfo, $matches)) { $foundName = $matches[1]; $foundName = rtrim($foundName); $foundName = ltrim($foundName); } if (preg_match('/this release.*?((19|20)\\d{2})/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; $foundName = rtrim($foundName); } if (preg_match('/\\[x\\] (Danish|Norwegian|Swedish|Finish|Other)/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } if (preg_match('/\\[x\\] (DVD9|DVD5)/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } $foundName = $foundName . "-PRiNGLES"; $methodused = "Pringles"; $this->determineCategory($rel, $foundName, $methodused); } //Fairlight releases if (preg_match('/\\/Team FairLight/', $nfo) && $foundName == "") { $title = null; $os = null; $method = null; if (preg_match('/\\b([a-z0-9\\ \\- \\_()\\.]+) \\(c\\)/i', $nfo, $matches)) { $title = $matches['1']; $foundName = $title; } $foundName = $foundName . "-FLT"; $methodused = "FairLight"; $this->determineCategory($rel, $foundName, $methodused); } //CORE releases if (preg_match('/Supplied.*?\\:.*?(CORE)/', $nfo) || preg_match('/Packaged.*?\\:.*?(CORE)/', $nfo) && $foundName == "") { $title = null; $os = null; $method = null; if (preg_match('/\\b([a-z0-9\\.\\-\\_\\+\\ ]+) \\*[a-z0-9]+\\*/i', $nfo, $matches)) { $title = $matches['1']; $foundName = $title; } if (preg_match('/Crack\\/.*?\\:.*?([a-z]+)/i', $nfo, $matches)) { $method = $matches['1']; $foundName = $foundName . " " . $method; } if (preg_match('/OS.*?\\:.*?([a-z]+)/i', $nfo, $matches)) { $os = $matches['1']; $foundName = $foundName . " " . $os; } $foundName = $foundName . "-CORE"; $methodused = "CORE"; $this->determineCategory($rel, $foundName, $methodused); } //CompleteRelease if (preg_match('/Complete name.*?([a-z0-9].*?\\-[a-z0-9]+)\\b/i', $nfo, $matches) && $foundName == "") { $foundName = $matches[1]; $methodused = "CompleteRelease"; $this->determineCategory($rel, $foundName, $methodused); } //Livesets if (preg_match('/\\nLivesets.*?\\n.*?\\n.*?\\n.*?\\n.*?\\n(?P<name>\\w.*?)\\n(?P<album>\\w.*?)\\n/im', $nfo, $matches) && $foundName == "") { $artist = $matches['name']; $title = $matches['album']; $source = null; $year = null; if (preg_match('/Year.*?\\:{1,2} ?(?P<year>(19|20)\\d{2})/i', $nfo, $matches)) { $year = $matches[1]; } elseif (preg_match('/date.*?\\:.*?(?P<year>(19|20)\\d{2})/i', $nfo, $matches)) { $year = $matches[1]; } if (preg_match('/(web|cable|sat)/i', $title)) { $source = ""; } elseif (preg_match('/Source.*?\\:{1,2} ?(?P<source>.*?)(\\s{2,}|\\s{1,})/i', $nfo, $matches)) { $source = $matches[1]; if ($source == "Satellite") { $source = "Sat"; } } if ($artist) { $tempname = $artist; if ($title) { $tempname = $tempname . "-" . $title; } if ($source) { $tempname = $tempname . "-" . $source; } if ($year) { $tempname = $tempname . "-" . $year; } $tempname = preg_replace("/[^a-zA-Z,0-9,\\-,\\s]/", "", $tempname); $foundName = $tempname; $methodused = "Live Sets"; $this->determineCategory($rel, $foundName, $methodused); } } //Typical scene regex if (preg_match('/(?P<source>Source[\\s\\.]*?:|fix for nuke)?(?:\\s|\\]|\\[)?(?P<name>[a-z0-9\'\\-]+(?:\\.|_)[a-z0-9\\.\\-_\'&]+\\-[a-z0-9&]+)(?:\\s|\\[|\\])/i', $nfo, $matches) && $foundName == "") { if (empty($matches['source'])) { if (!preg_match('/usenet\\-space/i', $matches['name'])) { $foundName = $matches['name']; $methodused = "Scene"; $this->determineCategory($rel, $foundName, $methodused); } } } } //The Big One if (preg_match_all('/([a-z0-9\\ ]+)\\.{1,}(\\:|\\[)(?P<name>.*)(\\s{2}|\\s{1})/i', $nfo, $matches) && $foundName == "") { $lut = array(); foreach ($matches[1] as $key => $k) { $lut[str_replace(' ', '', strtolower(trim($k)))] = trim($matches[3][$key]); } $year = null; $vidsource = null; $series = null; $season = null; $episode = null; $language = null; $artist = null; $source = null; foreach ($lut as $k => $v) { $v = rtrim($v); if (!$year && preg_match('/((19|20)\\d{2})/', $v, $matches)) { $year = $matches[1]; } if (!$vidsource && preg_match('/(xvid|x264|h264|wmv|divx)/i', $v, $matches)) { $vidsource = $matches[1]; } if (!$season && preg_match('/(season|seizon).*?(\\d{1,3})/i', $v, $matches)) { $season = $matches[2]; } if (!$episode && preg_match('/(Episode|ep).*?(\\d{1,3})/i', $v, $matches)) { $episode = $matches[2]; } } if (isset($lut['artist'])) { $del = "-"; if (isset($lut['artist'])) { $lut['artist'] = trim($lut['artist'], " "); $tempname = $lut['artist']; } if (isset($lut['title'])) { $tempname = $tempname . $del . $lut['title']; } if (isset($lut['album']) && !isset($lut['title'])) { $tempname = $tempname . $del . $lut['album']; } if (isset($lut['track']) && !isset($lut['title']) && !isset($lut['album'])) { $tempname = $tempname . $del . $lut['track']; } if (!isset($lut['source'])) { $lut['source'] = 'WEB'; } if (isset($lut['source']) && !preg_match('/SAT/i', $tempname)) { $tempname = $tempname . $del . $lut['source']; } if (!preg_match('/(19|20)\\d{2}/', $tempname) && $year) { $tempname = $tempname . $del . $year; } if (isset($lut['ripper'])) { $tempname = $tempname . $del . $lut['ripper']; } $tempname = preg_replace("/[^a-zA-Z,0-9,\\-,\\&,\\s]/", "", $tempname); $tempname = preg_replace("/[ ]{2,}/", "", $tempname); $methodused = "The Big One Music"; $foundName = $tempname; $this->determineCategory($rel, $foundName, $methodused); } else { if (isset($lut['title'])) { $del = " "; if (isset($lut['series'])) { $tempname = $lut['series']; } $tempname = $tempname . $del . $lut['title']; if ($season && $episode) { $tempname = $tempname . $del . "S" . str_pad($season, 2, '0', STR_PAD_LEFT) . 'E' . str_pad($episode, 2, '0', STR_PAD_LEFT); } else { if ($season) { $tempname = $tempname . $del . "S" . $season; } if ($episode) { $tempname = $tempname . $del . "Ep" . $episode; } } if (isset($lut['source']) && !preg_match('/SAT/i', $lut['title'])) { $tempname = $tempname . $del . $lut['source']; } if (!preg_match('/(19|20)\\d{2}/', $tempname) && $year) { $tempname = $tempname . $del . $year; } if (isset($lut['language'])) { $tempname = $tempname . $del . $lut['language']; } if ($vidsource) { $tempname = $tempname . $del . $vidsource; } $tempname = preg_replace("/ /", " ", $tempname); $tempname = preg_replace("/[^a-zA-Z,0-9,\\-,\\&,\\s]/", " ", $tempname); $tempname = preg_replace("/[ ]+/", " ", $tempname); $methodused = "The Big One Other"; $foundName = $tempname; $this->determineCategory($rel, $foundName, $methodused); } } } /// ///unable to extract releasename from nfo, try the rar file /// if ($rel['filenames'] && $foundName == '') { $this->releasefilesprocessed++; $files = explode(',', $rel['filenames']); if (!array($files)) { $files = array($files); } // Scene regex $sceneRegex = '/([a-z0-9\'\\-\\.\\_\\(\\)\\+\\ ]+\\-[a-z0-9\'\\-\\.\\_\\(\\)\\ ]+)(.*?\\\\.*?|)\\.(?:\\w{3,4})$/i'; foreach ($files as $file) { // Petje Releases if (preg_match('/Petje \\<petje\\@pietamientje\\.com\\>/', $rel['fromname'], $matches3) && $foundName == '') { if (preg_match('/.*\\.(mkv|avi|mp4|wmv|divx)/', $file, $matches4)) { $array_new = explode('\\', $matches4[0]); foreach ($array_new as $item) { if (preg_match('/.*\\((19|20\\d{2})\\)$/', $item, $matched)) { //echo $matched[0].".720p.x264-Petje"; //print_r($matched); $foundName = $matched[0] . ".720p.x264-Petje"; $methodused = "Petje"; $this->determineCategory($rel, $foundName, $methodused); break 2; } } } } //3D Remux if (preg_match('/.*Remux\\.mkv/', $file, $matches4)) { $foundName = str_replace(".mkv", "", $matches4[0]); $methodused = "3D Remux"; $this->determineCategory($rel, $foundName, $methodused); } //QoQ Extended if (preg_match('/Q\\-sbuSLN.*/i', $file, $matches4)) { $new1 = preg_match('/( )?(\\.wmv|\\.divx|\\.avi|\\.mkv)/i', $matches4[0], $matched); $new2 = str_replace($matched[0], "", $matches4[0]); $foundName = strrev($new2); $methodused = "QoQ Extended"; $this->determineCategory($rel, $foundName, $methodused); } // Directory\Title.Year.Format.Group.mkv if (preg_match('/(?<=\\\\).*?BLURAY.(1080|720)P.*?KNORLOADING(?=\\.MKV)/i', $file, $matches3) && $foundName == '') { $foundName = $matches3['0']; $methodused = "a.b.hdtv.x264"; $this->determineCategory($rel, $foundName, $methodused); } // ReleaseGroup.Title.Format.mkv if (preg_match('/(?<=swg_|swghd\\-|lost\\-|veto\\-|kaka\\-|abd\\-|airline\\-|daa\\-|data\\-|japhson\\-|ika\\-|lng\\-|nrdhd\\-|saimorny\\-|sparks\\-|ulshd\\-|nscrns\\-|ifpd\\-|invan\\-|an0\\-|besthd\\-|muxhd\\-|s7\\-).*?((1080|720)|P)(?=\\.MKV)/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_", ".", $matches3['0']); $methodused = "a.b.hdtv.x264"; $this->determineCategory($rel, $foundName, $methodused); } // Title.Format.ReleaseGroup.mkv if (preg_match('/.*?(1080|720)(|P).(SON)/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_", ".", $matches3['0']); $methodused = "a.b.hdtv.x264"; $this->determineCategory($rel, $foundName, $methodused); } //epubmobi if (preg_match('/.*\\.(epub|mobi|azw3|pdf|prc|lit|rtf|azw|cbr|doc)/', $file, $matches4)) { $foundName = str_replace(".doc", "", str_replace(".cbr", "", str_replace(".prc", "", str_replace(".pdf", "", str_replace(".azw3", "", str_replace(".mobi", "", str_replace(".epub", "", str_replace(".rtf", "", str_replace(".azw", "", str_replace(".lit", "", $matches4[0])))))))))); $methodused = "EpubMobi"; $this->determineCategory($rel, $foundName, $methodused); } //Check rarfile contents for a scene name if (preg_match($sceneRegex, $file, $matches) && $foundName == '') { //Simply Releases Toppers if (preg_match('/(\\\\)(?P<name>.*?ReleaseS Toppers)/', $file, $matches1) && $foundName == '') { $foundName = $matches1['name']; $methodused = "Release Files-1"; $this->determineCategory($rel, $foundName, $methodused); } //Scene format no folder. if (preg_match('/^([a-z0-9\\.\\_\\- ]+\\-[a-z0-9\\_]+)(\\\\|)$/i', $matches[1]) && $foundName == '') { if (strlen($matches['1']) >= 15) { $foundName = $matches['1']; $methodused = "Scene format no folder."; $this->determineCategory($rel, $foundName, $methodused); } } //Check to see if file is inside of a folder. Use folder name if it is if (preg_match('/^(.*?\\\\)(.*?\\\\|)(.*?)$/i', $file, $matches1) && $foundName == '') { if (preg_match('/^([a-z0-9\\.\\_\\- ]+\\-[a-z0-9\\_]+)(\\\\|)$/i', $matches1['1'], $res)) { $foundName = $res['1']; $methodused = "Release Files-1"; $this->determineCategory($rel, $foundName, $methodused); } if (preg_match('/(?!UTC)([a-z0-9]+[a-z0-9\\.\\_\\- \'\\)\\(]+(\\d{4}|HDTV).*?\\-[a-z0-9]+)/i', $matches1['1'], $res) && $foundName == '') { $foundName = $res['1']; $methodused = "Release Files-2"; $this->determineCategory($rel, $foundName, $methodused); } if (preg_match('/^([a-z0-9\\.\\_\\- ]+\\-[a-z0-9\\_]+)(\\\\|)$/i', $matches1['2'], $res) && $foundName == '') { $foundName = $res['1']; $methodused = "Release Files-3"; $this->determineCategory($rel, $foundName, $methodused); } if (preg_match('/^([a-z0-9\\.\\_\\- ]+\\-(?:.+)\\(html\\))\\\\/i', $matches1['1'], $res) && $foundName == '') { $foundName = $res['1']; $methodused = "Release Files-4"; $this->determineCategory($rel, $foundName, $methodused); } } if (preg_match('/(?!UTC)([a-z0-9]+[a-z0-9\\.\\_\\- \'\\)\\(]+(\\d{4}|HDTV).*?\\-[a-z0-9]+)/i', $file, $matches2) && $foundName == '') { $foundName = $matches2['1']; $methodused = "Release Files-4"; $this->determineCategory($rel, $foundName, $methodused); } } } //RAR file contents release name matching /* if (sizeof($files) > 0 && $foundName == '') { echo "RAR checking\n"; //Loop through releaseFiles to find a match foreach($releaseFiles as $rarFile) { //echo "-{$rarFile}\n"; if ($foundName == '') { //Lookup name via reqid (filename) if (preg_match('/\.(avi|mkv|mp4|mov|wmv|iso|img|gcm|ps3|wad|ac3|nds|bin|cue|mdf)/i', $rarFile)) { $this->site->reqidurl $lookupUrl = 'http://allfilled/query.php?t=alt.binaries.srrdb&reqid='.urlencode(basename($rarFile)); echo '-lookup: '.$lookupUrl."\n"; $xml = getUrl($lookupUrl); //$xml = false; if ($xml !== false) { $xmlObj = @simplexml_load_string($xml); $arrXml = objectsIntoArray($xmlObj); if (isset($arrXml["item"]) && is_array($arrXml["item"]) && isset($arrXml["item"]["@attributes"]) && is_array($arrXml["item"]["@attributes"])) { $foundName = $arrXml["item"]["@attributes"]["title"]; } } } } } } */ } // do par check if user has elected for downloading extra stuff if ($this->site->unrarpath != '' && $foundName == "") { $nzb = new NZB(); $nzbfile = $nzb->getNZBPath($rel['guid'], $this->site->nzbpath, true); $nzbInfo = new nzbInfo(); $nzbInfo->loadFromFile($nzbfile); if (!empty($nzbInfo->parfiles) && empty($nzbInfo->rarfiles) && empty($nzbInfo->audiofiles)) { $nntp = new Nntp(); $nntp->doConnect(); if ($this->verbose) { echo "Checking Par\n"; } foreach ($nzbInfo->parfiles as $parfile) { $this->parsprocessed++; $parBinary = $nntp->getMessages($parfile['groups'][0], $parfile['segments'], $this->verbose); if ($parBinary) { $par2 = new Par2info(); $par2->setData($parBinary); if (!$par2->error) { $parFiles = $par2->getFileList(); foreach ($parFiles as $file) { if (isset($file['name']) && (preg_match('/.*part0*1\\.rar$/iS', $file['name'], $matches) || preg_match('/(?!part0*1)\\.rar$/iS', $file['name'], $matches) || preg_match('/\\.001$/iS', $file['name'], $matches))) { $foundName = preg_replace('/^(.*)(\\.part0*1\\.rar|\\.rar|\\.001)$/i', '\\1', $file['name']); $methodused = "Par file"; $this->determineCategory($rel, $foundName, $methodused); break; } } } } unset($parBinary); if ($foundName != "") { break; } } $nntp->doQuit(); } } /// /// This is a last ditch effort, build a ReleaseName from the Nfo /// if ($nfo && ($foundName == "" || $methodused == 'Scene format no folder.')) { //LastNfoAttempt if (preg_match('/tt(\\d{7})/i', $nfo, $matches) && $foundName == "") { $movie = new Movie(); $imdbId = $matches[1]; $movCheck = $movie->fetchImdbProperties($imdbId); $buffer = getUrl('http://akas.imdb.com/title/tt' . $imdbId . '/'); if (!preg_match('/content\\=\\"video\\.tv\\_show\\"/i', $buffer)) { if (isset($movCheck['title'])) { $foundName = $movCheck['title']; if (!preg_match('/(19|20)\\d{2}/i', $foundName)) { $foundName = $foundName . "." . (isset($movCheck['year']) ? $movCheck['year'] : ""); } if (preg_match('/language.*?\\b([a-z0-9]+)\\b/i', $nfo, $matches)) { if (!preg_match('/English/i', $matches[1])) { $foundName = $foundName . "." . $matches[1]; } } if (preg_match('/audio.*?\\b(\\w+)\\b/i', $nfo, $matches)) { if (preg_match('/(Chinese|German|Dutch|Spanish|Hebrew|Finnish|Norwegian)/i', $matches[1])) { $foundName = $foundName . "." . $matches[1]; } } if (preg_match('/(video|resolution|video res).*?(1080|720|816|820|272|1280 @|528|1920)/i', $nfo, $matches)) { if ($matches[2] == '1280 @') { $matches[2] = '720'; } if ($matches[2] == '1920') { $matches[2] = '1080'; } $foundName = $foundName . "." . $matches[2]; } if (preg_match('/source.*?\\b(DVD9|DVD5|BDRIP|DVD\\-?RIP|BLURAY|BD)\\b/i', $nfo, $matches)) { if ($matches[1] == 'BD') { $matches[1] = 'Bluray.x264'; } $foundName = $foundName . "." . $matches[1]; } if (preg_match('/(video|resolution|video res).*?(XVID|X264|WMV)/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[2]; } if (preg_match('/audio.*?\\b(DTS|AC3)\\b/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } $foundName = $foundName . "-NoGroup"; $methodused = "LastNfoAttempt"; $this->determineCategory($rel, $foundName, $methodused); } } } } if ($foundName == '' && $this->verbose) { echo "ReleaseID: \t\t" . $rel["RID"] . "\n" . " Group: \t\t" . $rel["groupname"] . "\n" . " Old Name: \t\t" . $rel["name"] . "\n" . " Old SearchName: \t" . $rel["searchname"] . "\n" . " Status: \t\tNo new name found.\n\n"; } } } if ($this->verbose) { echo $this->releasestocheck . " releases checked\n" . $this->nfosprocessed . " of " . $this->releasestocheck . " releases had nfo's processed\n" . $this->parsprocessed . " of " . $this->releasestocheck . " releases had par's processed\n" . $this->releasefilesprocessed . " of " . $this->releasestocheck . " releases had releasefiles processed\n" . $this->numupdated . " of " . $this->releasestocheck . " releases " . ($this->releasestocheck > 0 ? floor($this->numupdated / $this->releasestocheck * 100) . "%" : "") . " changed\n"; } }
/** * Update the list of newsgroups from nntp provider matching a regex and return an array of messages. */ function addBulk($groupList, $active = 1) { require_once WWW_DIR . "/lib/binaries.php"; require_once WWW_DIR . "/lib/nntp.php"; $ret = array(); if ($groupList == "") { $ret[] = "No group list provided."; } else { $db = new DB(); $nntp = new Nntp(); if (!$nntp->doConnect()) { $ret[] = "Failed to get NNTP connection"; return $ret; } $groups = $nntp->getGroups(); $nntp->doQuit(); $regfilter = "/(" . str_replace(array('.', '*'), array('\\.', '.*?'), $groupList) . ")\$/"; foreach ($groups as $group) { if (preg_match($regfilter, $group['group']) > 0) { $res = $db->queryOneRow(sprintf("SELECT ID FROM groups WHERE name = %s ", $db->escapeString($group['group']))); if ($res) { $db->exec(sprintf("update groups SET active = %d where ID = %d", $active, $res["ID"])); $ret[] = array('group' => $group['group'], 'msg' => 'Updated'); } else { $desc = ""; $db->queryInsert(sprintf("INSERT INTO groups (name, description, active) VALUES (%s, %s, %d)", $db->escapeString($group['group']), $db->escapeString($desc), $active)); $ret[] = array('group' => $group['group'], 'msg' => 'Created'); } } } } return $ret; }
function test_5_insert_blobs() { DB::query("CREATE TABLE `store data` (\n `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `picture` BLOB\n ) ENGINE = InnoDB"); $columns = DB::columnList('store data'); $this->assert(count($columns) === 2); $this->assert($columns[1] === 'picture'); $smile = file_get_contents('smile1.jpg'); DB::insert('store data', array('picture' => $smile)); DB::queryOneRow("INSERT INTO %b (picture) VALUES (%s)", 'store data', $smile); $getsmile = DB::queryFirstField("SELECT picture FROM %b WHERE id=1", 'store data'); $getsmile2 = DB::queryFirstField("SELECT picture FROM %b WHERE id=2", 'store data'); $this->assert($smile === $getsmile); $this->assert($smile === $getsmile2); }
public function getShow($uid, $tvinfoid) { $db = new DB(); $sql = sprintf("select userseries.*, tvinfo.releasetitle from userseries left outer join tvinfo on tvinfo.ID = userseries.tvinfoID where userseries.userID = %d and userseries.tvinfoID = %d ", $uid, $tvinfoid); return $db->queryOneRow($sql); }
public function getFull($id) { $db = new DB(); return $db->queryOneRow(sprintf("select * from releaseextrafull where releaseID = %d", $id)); }
} } $groups = $db->query("SELECT ID, name FROM groups"); foreach ($groups as $group) { $siteGroups[$group["name"]] = $group["ID"]; } if (!isset($groups) || count($groups) == 0) { $retval .= "no groups available in the database, add first.<br/>"; } else { foreach ($filestoprocess as $nzbFile) { $nzbInfo = new nzbInfo(); if (!$nzbInfo->loadFromFile($nzbFile, true)) { $retval .= "Failed to load NZB : " . $browserpostednames[$nzbFile] . "<br/>"; continue; } else { $dupes = $db->queryOneRow(sprintf("SELECT EXISTS(SELECT 1 FROM releases WHERE gid = %s) as total", $db->escapeString($nzbInfo->gid))); if ($dupes['total'] > 0) { $retval .= "Duplicate NZB : " . $browserpostednames[$nzbFile] . "<br/>"; continue; } else { $groupID = -1; foreach ($nzbInfo->groups as $group) { $group = (string) $group; if (array_key_exists($group, $siteGroups)) { $groupID = $siteGroups[$group]; $groupName = $group; break; } } if ($groupID == -1) { $retval .= "Missing Group for NZB : " . $browserpostednames[$nzbFile] . " - " . join(", ", $nzbInfo->groups) . "<br/>";
/** * Get a releaseregex row by ID. */ public function getByID($id) { $db = new DB(); return $db->queryOneRow(sprintf("select * from releaseregex where ID = %d ", $id)); }
public function getById($id) { $db = new DB(); return $db->queryOneRow(sprintf("SELECT c.ID, CONCAT(COALESCE(cp.title,'') , CASE WHEN cp.title IS NULL THEN '' ELSE ' > ' END , c.title) as title, c.status, c.parentID from category c left outer join category cp on cp.ID = c.parentID where c.ID = %d", $id)); }
<?php require_once __DIR__ . '/../all.php'; $cookies = new Cookies(); $user = $cookies->user_from_cookie(); $vars = array("item_id", "side_id", "service_id"); if (set_vars($_POST, $vars)) { if ($user->data["permission"] === "4" || $user->data["permission"] === "3" && $user->data["service_id"] === $_POST["service_id"]) { // DB::insert("menu_sides", array("name"=>$_POST["name"], "price"=>$_POST["price"], "required"=>$_POST["req"], "service_id"=>$_POST["service_id"])); $del_id = DB::queryOneRow("SELECT id FROM menu_sides_item_link WHERE item_id=%d AND sides_id=%d", $_POST["item_id"], $_POST["side_id"])["id"]; DB::delete("menu_sides_item_link", "id=%d", $del_id); echo DB::affectedRows(); } else { echo "-1"; } } else { echo "-1"; }
public function getSizeRangeById($id) { $db = new DB(); $res = $db->queryOneRow(sprintf("SELECT c.minsizetoformrelease, c.maxsizetoformrelease, cp.minsizetoformrelease as p_minsizetoformrelease, cp.maxsizetoformrelease as p_maxsizetoformrelease" . " from category c left outer join category cp on cp.ID = c.parentID where c.ID = %d", $id)); if (!$res) { return null; } $min = intval($res['minsizetoformrelease']); $max = intval($res['maxsizetoformrelease']); if ($min == 0 && $max == 0) { # Size restriction disabled; now check parent $min = intval($res['p_minsizetoformrelease']); $max = intval($res['p_maxsizetoformrelease']); if ($min == 0 && $max == 0) { # no size restriction return null; } else { if ($max > 0) { $min = 0; $max = intval($res['p_maxsizetoformrelease']); } else { $min = intval($res['p_minsizetoformrelease']); $max = PHP_INT_MAX; } } } else { if ($max > 0) { $min = 0; $max = intval($res['maxsizetoformrelease']); } else { $min = intval($res['minsizetoformrelease']); $max = PHP_INT_MAX; } } # If code reaches here, then content is enabled return array('min' => $min, 'max' => $max); }
public function getEpisodeInfoByMazeID($id) { $db = new DB(); return $db->queryOneRow(sprintf("select * from episodeinfo where mazeID = %d", $id)); }
$us->delShow($users->currentUserId(), $rid); } if (isset($_REQUEST['from'])) { header("Location:" . WWW_TOP . $_REQUEST['from']); } else { header("Location:" . WWW_TOP . "/myshows"); } break; case 'add': case 'doadd': $show = $us->getShow($users->currentUserId(), $rid); if ($show) { $page->show404('Already subscribed'); } else { $db = new DB(); $show = $db->queryOneRow(sprintf("select releasetitle from tvrage where rageID = %d", $rid)); if (!$show) { $page->show404('Seriously?'); } } if ($action == 'doadd') { $category = isset($_REQUEST['category']) && is_array($_REQUEST['category']) && !empty($_REQUEST['category']) ? $_REQUEST['category'] : array(); $us->addShow($users->currentUserId(), $rid, $category); if (isset($_REQUEST['from'])) { header("Location:" . $_REQUEST['from']); } else { header("Location:" . WWW_TOP . "/myshows"); } } else { $cat = new Category(); $tmpcats = $cat->getChildren(Category::CAT_PARENT_TV, true, $page->userdata["categoryexclusions"]);
public function getDownloadRequests($userid) { $db = new DB(); //clear old requests $db->query(sprintf("delete FROM userdownloads WHERE userID = %d AND timestamp < DATE_SUB(NOW(), INTERVAL 1 DAY)", $userid)); $sql = sprintf("select COUNT(ID) as num FROM userdownloads WHERE userID = %d AND timestamp > DATE_SUB(NOW(), INTERVAL 1 DAY)", $userid); return $db->queryOneRow($sql); }
/** * Count of all posts for a user. */ public function getCountForUser($uid) { $db = new DB(); $res = $db->queryOneRow(sprintf("select count(ID) as num from forumpost where userID = %d", $uid)); return $res["num"]; }
public function data_getIndex() { $db = new DB(); return $db->queryOneRow(sprintf("select * from content where status=1 and contenttype = %d ", Contents::TYPEINDEX)); }