コード例 #1
0
 public function addShow($uid, $tvinfoid, $catid = array())
 {
     $db = new DB();
     $catid = !empty($catid) ? $db->escapeString(implode('|', $catid)) : "null";
     $sql = sprintf("insert into userseries (userID, tvinfoID, categoryID, createddate) values (%d, %d, %s, now())", $uid, $tvinfoid, $catid);
     return $db->queryInsert($sql);
 }
コード例 #2
0
ファイル: releasecomments.php プロジェクト: ehsanguru/nnplus
 public function addComment($id, $text, $userid, $host)
 {
     $db = new DB();
     $site = new Sites();
     $s = $site->get();
     if ($s->storeuserips != "1") {
         $host = "";
     }
     $comid = $db->queryInsert(sprintf("INSERT INTO releasecomment (`releaseID`, \t`text`, \t`userID`, \t`createddate`, \t`host`\t)\t\n\t\t\t\t\t\tVALUES (%d, \t%s, \t%d, \tnow(), \t%s\t)", $id, $db->escapeString($text), $userid, $db->escapeString($host)));
     $this->updateReleaseCommentCount($id);
     return $comid;
 }
コード例 #3
0
 /**
  * Add a forum post.
  */
 public function add($parentid, $userid, $subject, $message, $locked = 0, $sticky = 0, $replies = 0)
 {
     $db = new DB();
     if ($message == "") {
         return -1;
     }
     if ($parentid != 0) {
         $par = $this->getParent($parentid);
         if ($par == false) {
             return -1;
         }
         $db->exec(sprintf("update forumpost set replies = replies + 1, updateddate = now() where ID = %d", $parentid));
     }
     $db->queryInsert(sprintf("INSERT INTO `forumpost` (`forumID`,`parentID`,`userID`,`subject`,`message`, `locked`, `sticky`, `replies`, `createddate`, `updateddate`) VALUES ( 1,  %d, %d,  %s,  %s, %d, %d, %d,NOW(),  NOW())", $parentid, $userid, $db->escapeString($subject), $db->escapeString($message), $locked, $sticky, $replies));
 }
コード例 #4
0
ファイル: releaseregex.php プロジェクト: nubzzz/newznab
 public function add($regex)
 {
     $db = new DB();
     $groupname = $regex["groupname"];
     if ($groupname == "") {
         $groupname = "null";
     } else {
         $groupname = sprintf("%s", $db->escapeString($regex["groupname"]));
     }
     $catid = $regex["category"];
     if ($catid == "-1") {
         $catid = "null";
     } else {
         $catid = sprintf("%d", $regex["category"]);
     }
     return $db->queryInsert(sprintf("insert into releaseregex (groupname, regex, ordinal, status, description, categoryID) values (%s, %s, %d, %d, %s, %s) ", $groupname, $db->escapeString($regex["regex"]), $regex["ordinal"], $regex["status"], $db->escapeString($regex["description"]), $catid));
 }
コード例 #5
0
 /**
  * Add a releasefiles row.
  */
 public function add($id, $name, $size, $createddate, $passworded)
 {
     $db = new DB();
     $sql = sprintf("INSERT INTO releasefiles (releaseID, name, extension, size, createddate, passworded) VALUES (%d, %s, LOWER(SUBSTRING_INDEX(name,'.',-1)), %s, from_unixtime(%d), %d)", $id, $db->escapeString($name), $db->escapeString($size), $createddate, $passworded);
     return $db->queryInsert($sql);
 }
コード例 #6
0
 /**
  * Add a new blacklist row.
  */
 public function addBlacklist($regex)
 {
     $db = new DB();
     $groupname = $regex["groupname"];
     if ($groupname == "") {
         $groupname = "null";
     } else {
         $groupname = preg_replace("/a\\.b\\./i", "alt.binaries.", $groupname);
         $groupname = sprintf("%s", $db->escapeString($groupname));
     }
     return $db->queryInsert(sprintf("insert into binaryblacklist (groupname, regex, status, description, optype, msgcol) values (%s, %s, %d, %s, %d, %d) ", $groupname, $db->escapeString($regex["regex"]), $regex["status"], $db->escapeString($regex["description"]), $regex["optype"], $regex["msgcol"]));
 }
コード例 #7
0
ファイル: tvrage.php プロジェクト: ehsanguru/nnplus
 public function updateSchedule()
 {
     $db = new DB();
     $countries = $db->query("select distinct(country) as country from tvrage where country != ''");
     $showsindb = $db->query("select distinct(rageid) as rageid from tvrage");
     $showarray = array();
     foreach ($showsindb as $show) {
         $showarray[] = $show['rageid'];
     }
     foreach ($countries as $country) {
         if ($this->echooutput) {
             echo 'Updating schedule for ' . $country['country'] . "\n";
         }
         $sched = getURL($this->xmlFullScheduleUrl . $country['country']);
         if ($sched !== false && ($xml = @simplexml_load_string($sched))) {
             $tzOffset = 60 * 60 * 6;
             $yesterday = strtotime("-1 day") - $tzOffset;
             $xmlSchedule = array();
             foreach ($xml->DAY as $sDay) {
                 $currDay = strtotime($sDay['attr']);
                 foreach ($sDay as $sTime) {
                     $currTime = (string) $sTime['attr'];
                     foreach ($sTime as $sShow) {
                         $currShowName = (string) $sShow['name'];
                         $currShowId = (string) $sShow->sid;
                         $day_time = strtotime($sDay['attr'] . ' ' . $currTime);
                         $tag = $currDay < $yesterday ? 'prev' : 'next';
                         if ($tag == 'prev' || $tag == 'next' && !isset($xmlSchedule[$currShowId]['next'])) {
                             $xmlSchedule[$currShowId][$tag] = array('name' => $currShowName, 'day' => $currDay, 'time' => $currTime, 'day_time' => $day_time, 'day_date' => date("Y-m-d H:i:s", $day_time), 'title' => html_entity_decode((string) $sShow->title, ENT_QUOTES, 'UTF-8'), 'episode' => html_entity_decode((string) $sShow->ep, ENT_QUOTES, 'UTF-8'));
                             $xmlSchedule[$currShowId]['showname'] = $currShowName;
                         }
                         if ($sShow->ep == "01x01") {
                             // Only add it here, no point adding it to tvrage aswell
                             // that will automatically happen when an ep gets posted
                             $showarray[] = $sShow->sid;
                         }
                         if (in_array($currShowId, $showarray)) {
                             $showname = $db->escapeString($currShowName);
                             $title = $db->escapeString($sShow->title);
                             $fullep = $db->escapeString($sShow->ep);
                             $link = $db->escapeString($sShow->link);
                             $airdate = $db->escapeString(date("Y-m-d H:i:s", $day_time));
                             $sql = sprintf("INSERT into tvrageepisodes (rageID,showtitle,fullep,airdate,link,eptitle) VALUES (%d,%s,%s,%s,%s,%s)\n\t\t\t\t\t\t\t\t\t\tON DUPLICATE KEY UPDATE airdate = %s, link = %s ,eptitle = %s, showtitle = %s", $sShow->sid, $showname, $fullep, $airdate, $link, $title, $airdate, $link, $title, $showname);
                             $db->queryInsert($sql);
                         }
                     }
                 }
             }
             // update series info
             foreach ($xmlSchedule as $showId => $epInfo) {
                 $res = $db->query(sprintf("select *, UNIX_TIMESTAMP(nextdate) as nextDateU, UNIX_TIMESTAMP(DATE(nextdate)) as nextDateDay from tvrage where rageID = %d", $showId));
                 if (sizeof($res) > 0) {
                     foreach ($res as $arr) {
                         $prev_ep = $next_ep = "";
                         $query = array();
                         // previous episode
                         if (isset($epInfo['prev']) && $epInfo['prev']['episode'] != '') {
                             $prev_ep = $epInfo['prev']['episode'] . ', "' . $epInfo['prev']['title'] . '"';
                             $query[] = sprintf("prevdate = FROM_UNIXTIME(%s), previnfo = %s", $epInfo['prev']['day_time'], $db->escapeString($prev_ep));
                         }
                         // next episode
                         if (isset($epInfo['next']) && $epInfo['next']['episode'] != '') {
                             if ($prev_ep == "" && $arr['nextinfo'] != '' && $epInfo['next']['day_time'] > $arr['nextDateU'] && $arr['nextDateDay'] < $yesterday) {
                                 $db->query(sprintf("update tvrage set prevdate = nextdate, previnfo = nextinfo where ID = %d", $arr['ID']));
                                 $prev_ep = "SWAPPED with: " . $arr['nextInfo'] . " - " . date("r", $arr['nextDateU']);
                             }
                             $next_ep = $epInfo['next']['episode'] . ', "' . $epInfo['next']['title'] . '"';
                             $query[] = sprintf("nextdate = FROM_UNIXTIME(%s), nextinfo = %s", $epInfo['next']['day_time'], $db->escapeString($next_ep));
                         } else {
                             $query[] = "nextdate = null, nextinfo = null";
                         }
                         // output
                         if ($this->echooutput) {
                             echo $epInfo['showname'] . " (" . $showId . "):\n";
                             echo " -prev: {$prev_ep} - " . (isset($epInfo['prev']['day_time']) ? date("r", $epInfo['prev']['day_time']) : "") . "\n";
                             echo " -next: {$next_ep} - " . (isset($epInfo['next']['day_time']) ? date("r", $epInfo['next']['day_time']) : "") . "\n";
                         }
                         // update info
                         if (count($query) > 0) {
                             $sql = join(", ", $query);
                             $sql = sprintf("update tvrage set {$sql} where ID = %d", $arr['ID']);
                             $db->query($sql);
                         }
                     }
                 }
             }
             // end update series info
         } else {
             // no response from tvrage
             if ($this->echooutput) {
                 echo "Schedule not found\n";
             }
         }
     }
     // end foreach country
 }
コード例 #8
0
 /**
  * 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;
 }
コード例 #9
0
ファイル: music.php プロジェクト: nubzzz/newznab
 public function updateMusicInfo($artist, $album, $year)
 {
     $db = new DB();
     $gen = new Genres();
     $ri = new ReleaseImage();
     $mus = array();
     $amaz = $this->fetchAmazonProperties($artist . " - " . $album);
     if (!$amaz) {
         return false;
     }
     //load genres
     $defaultGenres = $gen->getGenres(Genres::MUSIC_TYPE);
     $genreassoc = array();
     foreach ($defaultGenres as $dg) {
         $genreassoc[$dg['ID']] = strtolower($dg['title']);
     }
     //
     // get album properties
     //
     $mus['coverurl'] = (string) $amaz->Items->Item->MediumImage->URL;
     if ($mus['coverurl'] != "") {
         $mus['cover'] = 1;
     } else {
         $mus['cover'] = 0;
     }
     $mus['title'] = (string) $amaz->Items->Item->ItemAttributes->Title;
     if (empty($mus['title'])) {
         $mus['title'] = $album;
     }
     $mus['asin'] = (string) $amaz->Items->Item->ASIN;
     $mus['url'] = (string) $amaz->Items->Item->DetailPageURL;
     $mus['url'] = str_replace("%26tag%3Dws", "%26tag%3Dopensourceins%2D21", $mus['url']);
     $mus['salesrank'] = (string) $amaz->Items->Item->SalesRank;
     if ($mus['salesrank'] == "") {
         $mus['salesrank'] = 'null';
     }
     $mus['artist'] = (string) $amaz->Items->Item->ItemAttributes->Artist;
     if (empty($mus['artist'])) {
         $mus['artist'] = $artist;
     }
     $mus['publisher'] = (string) $amaz->Items->Item->ItemAttributes->Publisher;
     $mus['releasedate'] = $db->escapeString((string) $amaz->Items->Item->ItemAttributes->ReleaseDate);
     if ($mus['releasedate'] == "''") {
         $mus['releasedate'] = 'null';
     }
     $mus['review'] = "";
     if (isset($amaz->Items->Item->EditorialReviews)) {
         $mus['review'] = trim(strip_tags((string) $amaz->Items->Item->EditorialReviews->EditorialReview->Content));
     }
     $mus['year'] = $year;
     if ($mus['year'] == "") {
         $mus['year'] = $mus['releasedate'] != 'null' ? substr($mus['releasedate'], 1, 4) : date("Y");
     }
     $mus['tracks'] = "";
     if (isset($amaz->Items->Item->Tracks)) {
         $tmpTracks = (array) $amaz->Items->Item->Tracks->Disc;
         $tracks = $tmpTracks['Track'];
         $mus['tracks'] = is_array($tracks) && !empty($tracks) ? implode('|', $tracks) : '';
     }
     //This is to verify the result back from amazon was at least somewhat related to what was intended.
     //If you are debugging releases comment out the following code to show all info
     $match = similar_text($artist, $mus['artist'], $artistpercent);
     //echo("Matched: Artist Percentage: $artistpercent%");
     $match = similar_text($album, $mus['title'], $albumpercent);
     //echo("Matched: Album Percentage: $albumpercent%");
     //If the artist is Various Artists, assume artist is 100%
     if (preg_match('/various/i', $artist)) {
         $artistpercent = '100';
     }
     //If the Artist is less than 80% album must be 100%
     if ($artistpercent < '80') {
         if ($albumpercent != '100') {
             return false;
         }
     }
     //If the album is ever under 30%, it's probably not a match.
     if ($albumpercent < '30') {
         return false;
     }
     //This is the end of the recheck code. Comment out to this point to show all info.
     $genreKey = -1;
     $genreName = '';
     if (isset($amaz->Items->Item->BrowseNodes)) {
         //had issues getting this out of the browsenodes obj
         //workaround is to get the xml and load that into its own obj
         $amazGenresXml = $amaz->Items->Item->BrowseNodes->asXml();
         $amazGenresObj = simplexml_load_string($amazGenresXml);
         $amazGenres = $amazGenresObj->xpath("//BrowseNodeId");
         foreach ($amazGenres as $amazGenre) {
             $currNode = trim($amazGenre[0]);
             if (empty($genreName)) {
                 $genreMatch = $this->matchBrowseNode($currNode);
                 if ($genreMatch !== false) {
                     $genreName = $genreMatch;
                     break;
                 }
             }
         }
         if (in_array(strtolower($genreName), $genreassoc)) {
             $genreKey = array_search(strtolower($genreName), $genreassoc);
         } else {
             $genreKey = $db->queryInsert(sprintf("INSERT INTO genres (`title`, `type`) VALUES (%s, %d)", $db->escapeString($genreName), Genres::MUSIC_TYPE));
         }
     }
     $mus['musicgenre'] = $genreName;
     $mus['musicgenreID'] = $genreKey;
     $query = sprintf("\n\t\tINSERT INTO musicinfo  (`title`, `asin`, `url`, `salesrank`,  `artist`, `publisher`, `releasedate`, `review`, `year`, `genreID`, `tracks`, `cover`, `createddate`, `updateddate`)\n\t\tVALUES (%s,        %s,        %s,        %s,        %s,        %s,        %s,        %s,        %s,        %s,        %s,        %d,        now(),        now())\n\t\t\tON DUPLICATE KEY UPDATE  `title` = %s,  `asin` = %s,  `url` = %s,  `salesrank` = %s,  `artist` = %s,  `publisher` = %s,  `releasedate` = %s,  `review` = %s,  `year` = %s,  `genreID` = %s,  `tracks` = %s,  `cover` = %d,  createddate = now(),  updateddate = now()", $db->escapeString($mus['title']), $db->escapeString($mus['asin']), $db->escapeString($mus['url']), $mus['salesrank'], $db->escapeString($mus['artist']), $db->escapeString($mus['publisher']), $mus['releasedate'], $db->escapeString($mus['review']), $db->escapeString($mus['year']), $mus['musicgenreID'] == -1 ? "null" : $mus['musicgenreID'], $db->escapeString($mus['tracks']), $mus['cover'], $db->escapeString($mus['title']), $db->escapeString($mus['asin']), $db->escapeString($mus['url']), $mus['salesrank'], $db->escapeString($mus['artist']), $db->escapeString($mus['publisher']), $mus['releasedate'], $db->escapeString($mus['review']), $db->escapeString($mus['year']), $mus['musicgenreID'] == -1 ? "null" : $mus['musicgenreID'], $db->escapeString($mus['tracks']), $mus['cover']);
     $musicId = $db->queryInsert($query);
     if ($musicId) {
         if ($this->echooutput) {
             echo "added/updated album: " . $mus['title'] . " (" . $mus['year'] . ")\n";
         }
         $mus['cover'] = $ri->saveImage($musicId, $mus['coverurl'], $this->imgSavePath, 250, 250);
     } else {
         if ($this->echooutput) {
             echo "nothing to update: " . $mus['title'] . " (" . $mus['year'] . ")\n";
         }
     }
     return $musicId;
 }
コード例 #10
0
ファイル: menu.php プロジェクト: nubzzz/newznab
 public function update($menu)
 {
     $db = new DB();
     return $db->queryInsert(sprintf("update menu set href = %s, title = %s, tooltip = %s, role = %d, ordinal = %d, menueval = %s where ID = %d\t", $db->escapeString($menu["href"]), $db->escapeString($menu["title"]), $db->escapeString($menu["tooltip"]), $menu["role"], $menu["ordinal"], $db->escapeString($menu["menueval"]), $menu["id"]));
 }
コード例 #11
0
ファイル: movie.php プロジェクト: nubzzz/newznab
 public function updateMovieInfo($imdbId)
 {
     $ri = new ReleaseImage();
     if ($this->echooutput) {
         echo "fetching imdb info from tmdb - " . $imdbId . "\n";
     }
     //check themoviedb for imdb info
     $tmdb = $this->fetchTmdbProperties($imdbId);
     if (!$tmdb) {
         if ($this->echooutput) {
             echo "not found in tmdb\n";
         }
     }
     //check imdb for movie info
     $imdb = $this->fetchImdbProperties($imdbId);
     if (!$imdb) {
         if ($this->echooutput) {
             echo "unable to get movie info from imdb - " . $imdbId . "\n";
         }
     }
     if (!$imdb && !$tmdb) {
         return false;
     }
     $mov = array();
     $mov['imdb_id'] = $imdbId;
     $mov['tmdb_id'] = !isset($tmdb['tmdb_id']) || $tmdb['tmdb_id'] == '' ? "NULL" : $tmdb['tmdb_id'];
     //prefer tmdb cover over imdb cover
     $mov['cover'] = 0;
     if (isset($tmdb['cover']) && $tmdb['cover'] != '') {
         $mov['cover'] = $ri->saveImage($imdbId . '-cover', $tmdb['cover'], $this->imgSavePath);
     } elseif (isset($imdb['cover']) && $imdb['cover'] != '') {
         $mov['cover'] = $ri->saveImage($imdbId . '-cover', $imdb['cover'], $this->imgSavePath);
     }
     $mov['backdrop'] = 0;
     if (isset($tmdb['backdrop']) && $tmdb['backdrop'] != '') {
         $mov['backdrop'] = $ri->saveImage($imdbId . '-backdrop', $tmdb['backdrop'], $this->imgSavePath, 1024, 768);
     }
     $mov['title'] = '';
     if (isset($imdb['title']) && $imdb['title'] != '') {
         $mov['title'] = $imdb['title'];
     } elseif (isset($tmdb['title']) && $tmdb['title'] != '') {
         $mov['title'] = $tmdb['title'];
     }
     $mov['title'] = html_entity_decode($mov['title'], ENT_QUOTES, 'UTF-8');
     $mov['rating'] = '';
     if (isset($imdb['rating']) && $imdb['rating'] != '') {
         $mov['rating'] = $imdb['rating'];
     } elseif (isset($tmdb['rating']) && $tmdb['rating'] != '') {
         $mov['rating'] = $tmdb['rating'];
     }
     $mov['tagline'] = '';
     if (isset($imdb['tagline']) && $imdb['tagline'] != '') {
         $mov['tagline'] = html_entity_decode($imdb['tagline'], ENT_QUOTES, 'UTF-8');
     }
     $mov['plot'] = '';
     if (isset($imdb['plot']) && $imdb['plot'] != '') {
         $mov['plot'] = $imdb['plot'];
     } elseif (isset($tmdb['plot']) && $tmdb['plot'] != '') {
         $mov['plot'] = $tmdb['plot'];
     }
     $mov['plot'] = html_entity_decode($mov['plot'], ENT_QUOTES, 'UTF-8');
     $mov['year'] = '';
     if (isset($imdb['year']) && $imdb['year'] != '') {
         $mov['year'] = $imdb['year'];
     } elseif (isset($tmdb['year']) && $tmdb['year'] != '') {
         $mov['year'] = $tmdb['year'];
     }
     $mov['genre'] = '';
     if (isset($tmdb['genre']) && $tmdb['genre'] != '') {
         $mov['genre'] = $tmdb['genre'];
     } elseif (isset($imdb['genre']) && $imdb['genre'] != '') {
         $mov['genre'] = $imdb['genre'];
     }
     if (is_array($mov['genre'])) {
         $mov['genre'] = implode(', ', array_unique($mov['genre']));
     }
     $mov['genre'] = html_entity_decode($mov['genre'], ENT_QUOTES, 'UTF-8');
     $mov['director'] = '';
     if (isset($imdb['director']) && $imdb['director'] != '') {
         $mov['director'] = is_array($imdb['director']) ? implode(', ', array_unique($imdb['director'])) : $imdb['director'];
     }
     $mov['director'] = html_entity_decode($mov['director'], ENT_QUOTES, 'UTF-8');
     $mov['actors'] = '';
     if (isset($imdb['actors']) && $imdb['actors'] != '') {
         $mov['actors'] = is_array($imdb['actors']) ? implode(', ', array_unique($imdb['actors'])) : $imdb['actors'];
     }
     $mov['actors'] = html_entity_decode($mov['actors'], ENT_QUOTES, 'UTF-8');
     $mov['language'] = '';
     if (isset($imdb['language']) && $imdb['language'] != '') {
         $mov['language'] = is_array($imdb['language']) ? implode(', ', array_unique($imdb['language'])) : $imdb['language'];
     }
     $mov['language'] = html_entity_decode($mov['language'], ENT_QUOTES, 'UTF-8');
     $db = new DB();
     $query = sprintf("\n\t\t\tINSERT INTO movieinfo \n\t\t\t\t(imdbID, tmdbID, title, rating, tagline, plot, year, genre, director, actors, language, cover, backdrop, createddate, updateddate)\n\t\t\tVALUES \n\t\t\t\t(%d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %d, NOW(), NOW())\n\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\timdbID=%d, tmdbID=%s, title=%s, rating=%s, tagline=%s, plot=%s, year=%s, genre=%s, director=%s, actors=%s, language=%s, cover=%d, backdrop=%d, updateddate=NOW()", $mov['imdb_id'], $mov['tmdb_id'], $db->escapeString($mov['title']), $db->escapeString($mov['rating']), $db->escapeString($mov['tagline']), $db->escapeString($mov['plot']), $db->escapeString($mov['year']), $db->escapeString($mov['genre']), $db->escapeString($mov['director']), $db->escapeString($mov['actors']), $db->escapeString($mov['language']), $mov['cover'], $mov['backdrop'], $mov['imdb_id'], $mov['tmdb_id'], $db->escapeString($mov['title']), $db->escapeString($mov['rating']), $db->escapeString($mov['tagline']), $db->escapeString($mov['plot']), $db->escapeString($mov['year']), $db->escapeString($mov['genre']), $db->escapeString($mov['director']), $db->escapeString($mov['actors']), $db->escapeString($mov['language']), $mov['cover'], $mov['backdrop']);
     $movieId = $db->queryInsert($query);
     if ($movieId) {
         if ($this->echooutput) {
             echo "added/updated movie: " . $mov['title'] . " (" . $mov['year'] . ") - " . $mov['imdb_id'] . "\n";
         }
     } else {
         if ($this->echooutput) {
             echo "nothing to update for movie: " . $mov['title'] . " (" . $mov['year'] . ") - " . $mov['imdb_id'] . "\n";
         }
     }
     return $movieId;
 }
コード例 #12
0
 public function insertRelease($cleanRelName, $parts, $group, $guid, $catId, $regexID, $date, $fromname, $reqID, $site)
 {
     $db = new DB();
     if ($regexID == "") {
         $regexID = " null ";
     }
     if ($reqID != "") {
         $reqID = $db->escapeString($reqID);
     } else {
         $reqID = " null ";
     }
     $sql = sprintf("insert into releases (name, searchname, totalpart, groupID, adddate, guid, categoryID, regexID, tvinfoID, postdate, fromname, size, reqID, passwordstatus, completion, haspreview)\r\n                    values (%s, %s, %d, %d, now(), %s, %d, %s, -1, %s, %s, 0, %s, %d, 100, %d)", $db->escapeString($cleanRelName), $db->escapeString($cleanRelName), $parts, $group, $db->escapeString($guid), $catId, $regexID, $db->escapeString($date), $db->escapeString($fromname), $reqID, $site->checkpasswordedrar > 0 ? -1 : 0, -1);
     $relid = $db->queryInsert($sql);
     return $relid;
 }
コード例 #13
0
 /**
  * Add a releasecomment row.
  */
 public function addComment($id, $gid, $text, $userid, $host)
 {
     if (strlen(trim($text)) == 0) {
         return false;
     }
     $db = new DB();
     $site = new Sites();
     $s = $site->get();
     if ($s->storeuserips != "1") {
         $host = "";
     }
     $comid = $db->queryInsert(sprintf("INSERT INTO releasecomment (releaseID, gid, text, userID, createddate, host) VALUES (%d, %s, %s, %d, now(), %s)", $id, $db->escapeString($gid), $db->escapeString($text), $userid, $db->escapeString($host)));
     $this->updateReleaseCommentCount($gid);
     return $comid;
 }
コード例 #14
0
 /**
  * Insert an anime title to the database.
  */
 public function addTitle($AniDBAPIArray)
 {
     $db = new DB();
     $query = sprintf("INSERT INTO anidb (anidbID, title, type, startdate, enddate, related, creators, description, rating, picture, categories, characters, epnos, airdates, episodetitles, createddate) VALUES (%d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, now())", $AniDBAPIArray['anidbID'], $db->escapeString($AniDBAPIArray['title']), $db->escapeString($AniDBAPIArray['type']), $db->escapeString($AniDBAPIArray['startdate']), $db->escapeString($AniDBAPIArray['enddate']), $db->escapeString($AniDBAPIArray['related']), $db->escapeString($AniDBAPIArray['creators']), $db->escapeString($AniDBAPIArray['description']), $db->escapeString($AniDBAPIArray['rating']), $db->escapeString($AniDBAPIArray['picture']), $db->escapeString($AniDBAPIArray['categories']), $db->escapeString($AniDBAPIArray['characters']), $db->escapeString($AniDBAPIArray['epnos']), $db->escapeString($AniDBAPIArray['airdates']), $db->escapeString($AniDBAPIArray['episodetitles']));
     $db->queryInsert($query);
 }
コード例 #15
0
 public function addSource($description, $username, $usermail, $usenetgroup, $publickey)
 {
     $db = new DB();
     $sql = sprintf("INSERT INTO spotnabsources " . "(description, username, useremail," . " usenetgroup, publickey, active) " . "VALUES (%s, %s, %s, %s, %s, 0)", $db->escapeString($description), $db->escapeString($username), $db->escapeString($usermail), $db->escapeString($usenetgroup), $db->escapeString($publickey));
     return $db->queryInsert($sql);
 }
コード例 #16
0
 /**
  * Insert or update a bookinfo row.
  */
 public function addUpdateBookInfo($title, $asin, $url, $author, $publisher, $publishdate, $review, $cover, $dewey, $ean, $isbn, $pages)
 {
     $db = new DB();
     if ($pages == 0) {
         $pages = "null";
     } else {
         $pages = $pages + 0;
     }
     if ($publishdate == "") {
         $publishdate = "null";
     } elseif (strlen($publishdate) == 4) {
         $publishdate = $db->escapeString($publishdate . "-01-01");
     } elseif (strlen($publishdate) == 7) {
         $publishdate = $db->escapeString($publishdate . "-01");
     } else {
         $publishdate = $db->escapeString($publishdate);
     }
     $sql = sprintf("INSERT INTO bookinfo  (title, asin, url, author, publisher, publishdate, review, cover, createddate, updateddate, dewey, ean, isbn, pages)\n\t\tVALUES (%s,  %s, %s, %s, %s, %s,  %s, %d, now(), now(), %s, %s, %s, %s)\n\t\t\tON DUPLICATE KEY UPDATE  title = %s,  asin = %s,  url = %s,   author = %s,  publisher = %s,  publishdate = %s,  review = %s, cover = %d,  createddate = now(),  updateddate = now(), dewey = %s, ean = %s, isbn = %s, pages = %s", $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), $db->escapeString($author), $db->escapeString($publisher), $publishdate, $db->escapeString($review), $cover, $db->escapeString($dewey), $db->escapeString($ean), $db->escapeString($isbn), $pages, $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), $db->escapeString($author), $db->escapeString($publisher), $db->escapeString($publishdate), $db->escapeString($review), $cover, $db->escapeString($dewey), $db->escapeString($ean), $db->escapeString($isbn), $pages);
     $bookId = $db->queryInsert($sql);
     return $bookId;
 }
コード例 #17
0
if ($page->site->amazonpubkey == "AKIAIPDNG5EU7LB4AD3Q" && $page->site->lookupmusic + $page->site->lookupgames + $page->site->lookupbooks != 0) {
    $statusmsgs[] = addmsg("Amazon shared key in use. Not using your own Amazon API key will result in failed amazon lookups.", "http://newznab.readthedocs.org/en/latest/faq/");
}
if ($page->site->rawretentiondays > 10) {
    $statusmsgs[] = addmsg("Binary header retention is set at " . $page->site->rawretentiondays . ". Having this value any higher than 2 can cause the database to grow very large.", "site-edit.php");
}
if ($page->site->newznabID == "") {
    $statusmsgs[] = addmsg("Newznab ID missing. You have not entered a newznab ID, and will not be using the latest matching regex's.", "http://www.newznab.com/chat.html", "exclamation");
}
//
// database patches uptodate
//
$s = new Sites();
if (!property_exists($page->site, "dbversion")) {
    $db = new DB();
    $db->queryInsert('INSERT INTO site (setting, value, updateddate ) VALUES (\'dbversion\', \'$Rev: 2248 $\', now())');
    $page->site = $s->get();
}
if (!preg_match("/\\d+/", $page->site->dbversion, $matches)) {
    $statusmsgs[] = addmsg("Bad database version. " . $page->site->dbversion . " cannot be parsed.", "http://newznab.readthedocs.org/en/latest/install/#updating", "exclamation");
}
$patches = $s->getUnappliedPatches($page->site);
$patches = array_map("basename", $patches);
if (count($patches) > 0) {
    $statusmsgs[] = addmsg("Database out of date. Ensure all database patches in /db/patch/0.2.3/ are ran by using the script misc/update_scripts/update_database_version.php<br/><small>" . implode("<br/>", $patches) . "</small>", "http://newznab.readthedocs.org/en/latest/install/#updating", "exclamation");
}
$page->smarty->assign('statusmsgs', $statusmsgs);
$page->content = $page->smarty->fetch('index.tpl');
$page->render();
function addmsg($msg, $url = "", $icon = "")
{
コード例 #18
0
ファイル: users.php プロジェクト: ehsanguru/nnplus
 public function addDownloadRequest($userid)
 {
     $db = new DB();
     $sql = sprintf("insert into userdownloads (userID, timestamp) VALUES (%d, now())", $userid);
     return $db->queryInsert($sql);
 }
コード例 #19
0
ファイル: content.php プロジェクト: nubzzz/newznab
 public function data_add($content)
 {
     $db = new DB();
     return $db->queryInsert(sprintf("insert into content (role, title, url, body, metadescription, metakeywords, \tcontenttype, \tshowinmenu, \tstatus, \tordinal\t)\tvalues\t(%d, %s, \t%s, \t%s, \t%s, \t%s, \t%d, \t%d, \t%d, \t%d \t)", $content->role, $db->escapeString($content->title), $db->escapeString($content->url), $db->escapeString($content->body), $db->escapeString($content->metadescription), $db->escapeString($content->metakeywords), $content->contenttype, $content->showinmenu, $content->status, $content->ordinal));
 }
コード例 #20
0
ファイル: releasefiles.php プロジェクト: ehsanguru/nnplus
 public function add($id, $name, $size, $createddate, $passworded)
 {
     $db = new DB();
     $sql = sprintf("INSERT INTO releasefiles  (releaseID,   name,   size,   createddate,   passworded)\r\n\t\t\t\t\t\tVALUES (%d, %s, %s, from_unixtime(%d), %d)", $id, $db->escapeString($name), $db->escapeString($size), $createddate, $passworded);
     return $db->queryInsert($sql);
 }
コード例 #21
0
 private function store_blob($nfometa, $blobhash, $removed)
 {
     // This takes a array of blobs with their index id being
     // the release id;  In the event we fetch the data and deem
     // it no good, we need to add it to the skipped array which
     // must be passed into the function.
     $db = new DB();
     foreach ($blobhash as $uid => $blob) {
         $query = sprintf("REPLACE INTO releasenfo (ID, releaseID, binaryID, nfo) " . "VALUES (NULL, %d, 0, compress(%s));", $uid, $db->escapeString($blob));
         $id = $db->queryInsert($query);
         if (!$id) {
             if ($this->verbose) {
                 echo "!";
             }
         } else {
             $query = sprintf("UPDATE releases SET releasenfoID = %d WHERE ID = %d", $id, $uid);
             $res = $db->exec($query);
             if ($this->verbose) {
                 echo "s";
             }
         }
     }
     // Now we update the database with entries that have no nfo files
     // associated with the release
     foreach ($removed as $uid) {
         $res = $this->setNfoMissing($uid);
         if ($res <= 0) {
             if ($this->verbose) {
                 echo "!";
             }
         } else {
             if ($this->verbose) {
                 echo "s";
             }
         }
     }
 }
コード例 #22
0
 public function addFull($id, $xml)
 {
     $db = new DB();
     $row = $this->getFull($id);
     if ($row) {
         return -1;
     }
     return $db->queryInsert(sprintf("insert into releaseextrafull (releaseID, mediainfo) values (%d, %s)", $id, $db->escapeString($xml)));
 }
コード例 #23
0
ファイル: menu.php プロジェクト: ehsanguru/nnplus
 public function add($menu)
 {
     $db = new DB();
     return $db->queryInsert(sprintf("INSERT INTO menu (href, title, tooltip, role, ordinal, menueval, newwindow )\t\r\n\t\t\tVALUES (%s, %s,  %s, %d, %d, %s, %d) ", $db->escapeString($menu["href"]), $db->escapeString($menu["title"]), $db->escapeString($menu["tooltip"]), $menu["role"], $menu["ordinal"], $db->escapeString($menu["menueval"]), $menu["newwindow"]));
 }
コード例 #24
0
ファイル: nzb-import.php プロジェクト: ehsanguru/nnplus
 //groups
 $groupArr = array();
 foreach ($file->groups->group as $group) {
     $group = (string) $group;
     if (array_key_exists($group, $siteGroups)) {
         $groupID = $siteGroups[$group];
     }
     $groupArr[] = $group;
 }
 if ($groupID != -1) {
     $xref = implode(': ', $groupArr) . ':';
     $totalParts = sizeof($file->segments->segment);
     //insert binary
     $binaryHash = md5($name . $fromname . $groupID);
     $binarySql = sprintf("INSERT INTO binaries (name, fromname, date, xref, totalParts, groupID, binaryhash, dateadded, importname) values (%s, %s, %s, %s, %s, %s, %s, NOW(), %s)", $db->escapeString($name), $db->escapeString($fromname), $db->escapeString($date), $db->escapeString($xref), $db->escapeString($totalParts), $db->escapeString($groupID), $db->escapeString($binaryHash), $db->escapeString($nzbFile));
     $binaryId = $db->queryInsert($binarySql);
     if ($usenzbname) {
         $usename = str_replace('.nzb', '', $viabrowser ? $browserpostednames[$nzbFile] : basename($nzbFile));
         $db->query(sprintf("update binaries set relname = replace(%s, '_', ' '), relpart = %d, reltotalpart = %d, procstat=%d, categoryID=%s, regexID=%d, reqID=%s where ID = %d", $db->escapeString($usename), 1, 1, 5, "null", "null", "null", $binaryId));
     }
     //segments (i.e. parts)
     if (count($file->segments->segment) > 0) {
         $partsSql = "INSERT INTO parts (binaryID, messageID, number, partnumber, size, dateadded) values ";
         foreach ($file->segments->segment as $segment) {
             $messageId = (string) $segment;
             $partnumber = $segment->attributes()->number;
             $size = $segment->attributes()->bytes;
             $partsSql .= sprintf("(%s, %s, 0, %s, %s, NOW()),", $db->escapeString($binaryId), $db->escapeString($messageId), $db->escapeString($partnumber), $db->escapeString($size));
         }
         $partsSql = substr($partsSql, 0, -1);
         $partsQuery = $db->queryInsert($partsSql);
コード例 #25
0
 /**
  * Insert or update a musicinfo row.
  */
 public function addUpdateMusicInfo($title, $asin, $url, $salesrank, $artist, $publisher, $releasedate, $review, $year, $genreID, $tracks, $cover)
 {
     $db = new DB();
     if (strlen($year) > 4) {
         if (preg_match("/\\d{4}/", $year, $matches)) {
             $year = $db->escapeString($matches[0]);
         } else {
             $year = "null";
         }
     } else {
         $year = $db->escapeString($year);
     }
     $sql = sprintf("\n\t\tINSERT INTO musicinfo  (title, asin, url, salesrank,  artist, publisher, releasedate, review, year, genreID, tracks, cover, createddate, updateddate)\n\t\tVALUES (%s, %s, %s,  %s,  %s, %s, %s, %s, %s,   %s, %s, %d, now(), now())\n\t\t\tON DUPLICATE KEY UPDATE  title = %s,  asin = %s,  url = %s,  salesrank = %s,  artist = %s,  publisher = %s,  releasedate = %s,  review = %s,  year = %s,  genreID = %s,  tracks = %s,  cover = %d,  createddate = now(),  updateddate = now()", $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), $salesrank, $db->escapeString($artist), $db->escapeString($publisher), $releasedate, $db->escapeString($review), $year, $genreID == -1 ? "null" : $genreID, $db->escapeString($tracks), $cover, $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), $salesrank, $db->escapeString($artist), $db->escapeString($publisher), $releasedate, $db->escapeString($review), $db->escapeString($year), $genreID == -1 ? "null" : $genreID, $db->escapeString($tracks), $cover);
     $musicId = $db->queryInsert($sql);
     return $musicId;
 }
コード例 #26
0
ファイル: releaseextra.php プロジェクト: ehsanguru/nnplus
 public function addFull($id, $xml)
 {
     $db = new DB();
     return $db->queryInsert(sprintf("insert into releaseextrafull (releaseID, mediainfo) values (%d, %s)", $id, $db->escapeString($xml)));
 }
コード例 #27
0
ファイル: tvrage.php プロジェクト: nubzzz/newznab
 public function add($rageid, $releasename, $desc, $genre, $country, $imgbytes)
 {
     $releasename = str_replace(array('.', '_'), array(' ', ' '), $releasename);
     $db = new DB();
     return $db->queryInsert(sprintf("insert into tvrage (rageID, releasetitle, description, genre, country, createddate, imgdata) values (%d, %s, %s, %s, %s, now(), %s)", $rageid, $db->escapeString($releasename), $db->escapeString($desc), $db->escapeString($genre), $db->escapeString($country), $db->escapeString($imgbytes)));
 }
コード例 #28
0
ファイル: console.php プロジェクト: nubzzz/newznab
 public function updateConsoleInfo($gameInfo)
 {
     $db = new DB();
     $gen = new Genres();
     $ri = new ReleaseImage();
     $con = array();
     $amaz = $this->fetchAmazonProperties($gameInfo['title'], $gameInfo['node']);
     if (!$amaz) {
         return false;
     }
     //load genres
     $defaultGenres = $gen->getGenres(Genres::CONSOLE_TYPE);
     $genreassoc = array();
     foreach ($defaultGenres as $dg) {
         $genreassoc[$dg['ID']] = strtolower($dg['title']);
     }
     //
     // get game properties
     //
     $con['coverurl'] = (string) $amaz->Items->Item->LargeImage->URL;
     if ($con['coverurl'] != "") {
         $con['cover'] = 1;
     } else {
         $con['cover'] = 0;
     }
     $con['title'] = (string) $amaz->Items->Item->ItemAttributes->Title;
     if (empty($con['title'])) {
         $con['title'] = $gameInfo['title'];
     }
     $con['platform'] = (string) $amaz->Items->Item->ItemAttributes->Platform;
     if (empty($con['platform'])) {
         $con['platform'] = $gameInfo['platform'];
     }
     //Beginning of Recheck Code
     //This is to verify the result back from amazon was at least somewhat related to what was intended.
     //Some of the Platforms don't match Amazon's exactly. This code is needed to facilitate rechecking.
     if (preg_match('/^X360$/i', $gameInfo['platform'])) {
         $gameInfo['platform'] = str_replace('X360', 'Xbox 360', $gameInfo['platform']);
         // baseline single quote
     }
     if (preg_match('/^XBOX360$/i', $gameInfo['platform'])) {
         $gameInfo['platform'] = str_replace('XBOX360', 'Xbox 360', $gameInfo['platform']);
         // baseline single quote
     }
     if (preg_match('/^NDS$/i', $gameInfo['platform'])) {
         $gameInfo['platform'] = str_replace('NDS', 'Nintendo DS', $gameInfo['platform']);
         // baseline single quote
     }
     if (preg_match('/^PS3$/i', $gameInfo['platform'])) {
         $gameInfo['platform'] = str_replace('PS3', 'PlayStation 3', $gameInfo['platform']);
         // baseline single quote
     }
     if (preg_match('/^PSP$/i', $gameInfo['platform'])) {
         $gameInfo['platform'] = str_replace('PSP', 'Sony PSP', $gameInfo['platform']);
         // baseline single quote
     }
     if (preg_match('/^Wii$/i', $gameInfo['platform'])) {
         $gameInfo['platform'] = str_replace('Wii', 'Nintendo Wii', $gameInfo['platform']);
         // baseline single quote
         $gameInfo['platform'] = str_replace('WII', 'Nintendo Wii', $gameInfo['platform']);
         // baseline single quote
     }
     if (preg_match('/^N64$/i', $gameInfo['platform'])) {
         $gameInfo['platform'] = str_replace('N64', 'Nintendo 64', $gameInfo['platform']);
         // baseline single quote
     }
     if (preg_match('/^NES$/i', $gameInfo['platform'])) {
         $gameInfo['platform'] = str_replace('NES', 'Nintendo NES', $gameInfo['platform']);
         // baseline single quote
     }
     if (preg_match('/Super/i', $con['platform'])) {
         $con['platform'] = str_replace('Super Nintendo', 'SNES', $con['platform']);
         // baseline single quote
         $con['platform'] = str_replace('Nintendo Super NES', 'SNES', $con['platform']);
         // baseline single quote
     }
     //Remove Online Game Code So Titles Match Properly.
     if (preg_match('/\\[Online Game Code\\]/i', $con['title'])) {
         $con['title'] = str_replace(' [Online Game Code]', '', $con['title']);
         // baseline single quote
     }
     //Basically the XBLA names contain crap, this is to reduce the title down far enough to be usable
     if (preg_match('/xbla/i', $gameInfo['platform'])) {
         $gameInfo['title'] = substr($gameInfo['title'], 0, 10);
         $con['substr'] = $gameInfo['title'];
     }
     //This actual compares the two strings and outputs a percentage value.
     $titlepercent = '';
     $platformpercent = '';
     similar_text(strtolower($gameInfo['title']), strtolower($con['title']), $titlepercent);
     similar_text(strtolower($gameInfo['platform']), strtolower($con['platform']), $platformpercent);
     //Since Wii Ware games and XBLA have inconsistent original platforms, as long as title is 50% its ok.
     if (preg_match('/(wiiware|xbla)/i', $gameInfo['platform'])) {
         if ($titlepercent >= 50) {
             $platformpercent = 100;
         }
     }
     //If the release is DLC matching sucks, so assume anything over 50% is legit.
     if (isset($gameInfo['dlc']) && $gameInfo['dlc'] == 1) {
         if ($titlepercent >= 50) {
             $titlepercent = 100;
             $platformpercent = 100;
         }
     }
     //Show the Percentages
     //echo("Matched: Title Percentage: $titlepercent%");
     //echo("Matched: Platform Percentage: $platformpercent%");
     //If the Title is less than 80% Platform must be 100% unless it is XBLA
     if ($titlepercent < 70) {
         if ($platformpercent != 100) {
             return false;
         }
     }
     //If title is less than 80% then its most likely not a match
     if ($titlepercent < 70) {
         return false;
     }
     //Platform must equal 100%
     if ($platformpercent != 100) {
         return false;
     }
     $con['asin'] = (string) $amaz->Items->Item->ASIN;
     $con['url'] = (string) $amaz->Items->Item->DetailPageURL;
     $con['url'] = str_replace("%26tag%3Dws", "%26tag%3Dopensourceins%2D21", $con['url']);
     $con['salesrank'] = (string) $amaz->Items->Item->SalesRank;
     if ($con['salesrank'] == "") {
         $con['salesrank'] = 'null';
     }
     $con['publisher'] = (string) $amaz->Items->Item->ItemAttributes->Publisher;
     $con['esrb'] = (string) $amaz->Items->Item->ItemAttributes->ESRBAgeRating;
     $con['releasedate'] = $db->escapeString((string) $amaz->Items->Item->ItemAttributes->ReleaseDate);
     if ($con['releasedate'] == "''") {
         $con['releasedate'] = 'null';
     }
     $con['review'] = "";
     if (isset($amaz->Items->Item->EditorialReviews)) {
         $con['review'] = trim(strip_tags((string) $amaz->Items->Item->EditorialReviews->EditorialReview->Content));
     }
     $genreKey = -1;
     $genreName = '';
     if (isset($amaz->Items->Item->BrowseNodes) || isset($amaz->Items->Item->ItemAttributes->Genre)) {
         if (isset($amaz->Items->Item->BrowseNodes)) {
             //had issues getting this out of the browsenodes obj
             //workaround is to get the xml and load that into its own obj
             $amazGenresXml = $amaz->Items->Item->BrowseNodes->asXml();
             $amazGenresObj = simplexml_load_string($amazGenresXml);
             $amazGenres = $amazGenresObj->xpath("//Name");
             foreach ($amazGenres as $amazGenre) {
                 $currName = trim($amazGenre[0]);
                 if (empty($genreName)) {
                     $genreMatch = $this->matchBrowseNode($currName);
                     if ($genreMatch !== false) {
                         $genreName = $genreMatch;
                         break;
                     }
                 }
             }
         }
         if (empty($genreName) && isset($amaz->Items->Item->ItemAttributes->Genre)) {
             $tmpGenre = (string) $amaz->Items->Item->ItemAttributes->Genre;
             $tmpGenre = str_replace('-', ' ', $tmpGenre);
             $tmpGenre = explode(' ', $tmpGenre);
             foreach ($tmpGenre as $tg) {
                 $genreMatch = $this->matchBrowseNode(ucwords($tg));
                 if ($genreMatch !== false) {
                     $genreName = $genreMatch;
                     break;
                 }
             }
         }
     }
     if (empty($genreName)) {
         $genreName = 'Unknown';
     }
     if (in_array(strtolower($genreName), $genreassoc)) {
         $genreKey = array_search(strtolower($genreName), $genreassoc);
     } else {
         $genreKey = $db->queryInsert(sprintf("INSERT INTO genres (`title`, `type`) VALUES (%s, %d)", $db->escapeString($genreName), Genres::CONSOLE_TYPE));
     }
     $con['consolegenre'] = $genreName;
     $con['consolegenreID'] = $genreKey;
     $query = sprintf("\n\t\tINSERT INTO consoleinfo  (`title`, `asin`, `url`, `salesrank`, `platform`, `publisher`, `genreID`, `esrb`, `releasedate`, `review`, `cover`, `createddate`, `updateddate`)\n\t\tVALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, now(), now())\n\t\t\tON DUPLICATE KEY UPDATE  `title` = %s,  `asin` = %s,  `url` = %s,  `salesrank` = %s,  `platform` = %s,  `publisher` = %s,  `genreID` = %s,  `esrb` = %s,  `releasedate` = %s,  `review` = %s, `cover` = %d,  createddate = now(),  updateddate = now()", $db->escapeString($con['title']), $db->escapeString($con['asin']), $db->escapeString($con['url']), $con['salesrank'], $db->escapeString($con['platform']), $db->escapeString($con['publisher']), $con['consolegenreID'] == -1 ? "null" : $con['consolegenreID'], $db->escapeString($con['esrb']), $con['releasedate'], $db->escapeString($con['review']), $con['cover'], $db->escapeString($con['title']), $db->escapeString($con['asin']), $db->escapeString($con['url']), $con['salesrank'], $db->escapeString($con['platform']), $db->escapeString($con['publisher']), $con['consolegenreID'] == -1 ? "null" : $con['consolegenreID'], $db->escapeString($con['esrb']), $con['releasedate'], $db->escapeString($con['review']), $con['cover']);
     $consoleId = $db->queryInsert($query);
     if ($consoleId) {
         if ($this->echooutput) {
             echo "added/updated game: " . $con['title'] . " " . $con['platform'] . "\n";
         }
         $con['cover'] = $ri->saveImage($consoleId, $con['coverurl'], $this->imgSavePath, 250, 250);
     } else {
         if ($this->echooutput) {
             echo "nothing to update: " . $con['title'] . " (" . $con['platform'] . ")\n";
         }
     }
     return $consoleId;
 }
コード例 #29
0
ファイル: users.php プロジェクト: nubzzz/newznab
 public function addInvite($uid, $inviteToken)
 {
     $db = new DB();
     $db->queryInsert(sprintf("insert into userinvite (guid, userID, createddate) values (%s, %d, now())", $db->escapeString($inviteToken), $uid));
 }
コード例 #30
0
    public function addEpisode($tvdbid, $mazeid, $showtitle, $airdate, $season, $episode, $eptitle, $director, $gueststars, $overview, $rating, $writer, $epabsolute, $tvinfoid)
    {
        $db = new DB();
        $sql = sprintf('INSERT INTO episodeinfo
			(tvdbID, mazeID, showtitle, airdate, fullep, eptitle, director, gueststars, overview, rating, writer, epabsolute, tvinfoID)
			VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %F, %s, %s, %d)
			ON DUPLICATE KEY UPDATE
			tvdbID=%1$s, mazeID=%2$s, showtitle=%3$s, airdate=%4$s, fullep=%5$s, eptitle=%6$s, director=%7$s,
			gueststars=%8$s, overview=%9$s, rating=%10$F, writer=%11$s, epabsolute=%12$s', $db->nullInt($tvdbid), $db->nullInt($mazeid), $db->escapeString($showtitle), $db->escapeString($airdate), $db->escapeString(str_pad($season, 2, '0', STR_PAD_LEFT) . 'x' . str_pad($episode, 2, '0', STR_PAD_LEFT)), $db->escapeString($eptitle), $db->escapeString($director), $db->escapeString($gueststars), $db->escapeString(substr($overview, 0, 10000)), $rating, $db->escapeString($writer), $db->nullInt($epabsolute), $tvinfoid);
        return $db->queryInsert($sql);
    }