예제 #1
0
파일: AVM.class.php 프로젝트: jramstedt/AVM
 public static function setTimelimit($timelimit)
 {
     self::$torrentTimelimit = $timelimit;
     $id = Sessionmanager::getUserId();
     $unixTime = strtotime($timelimit);
     Kernel::mysqli()->query("UPDATE usersetting SET timelimit=FROM_UNIXTIME({$unixTime}) WHERE id={$id}");
 }
예제 #2
0
 private static function query($level, $message, $get)
 {
     if (LOG_SAVELEVEL > $level) {
         return;
     }
     $serverQuery = "INSERT INTO log (message, date, class, method, linenumber, file, username, level)\n\t\t\t\t\t\tVALUES('{$message}', NOW(),'{$get['className']}', '{$get['method']}',\n\t\t\t\t\t\t'{$get['lineNumber']}','{$get['filename']}','{$get['username']}','{$level}')";
     Kernel::mysqli()->query($serverQuery);
 }
예제 #3
0
 public static function mysqli()
 {
     if (!isset(Kernel::$mysqli)) {
         Kernel::$mysqli = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE);
         Kernel::$mysqli->set_charset('utf8');
         if (Kernel::$mysqli->connect_error) {
             Kernel::addInfo(INFOBOX_ERROR, 'MySQLi connection failed.');
         }
     }
     return Kernel::$mysqli;
 }
예제 #4
0
 public function seekList($page, $count)
 {
     $seeksResult = Kernel::mysqli()->query('SELECT * FROM seek ORDER BY name');
     if (is_object($seeksResult)) {
         $listNode = Util::tagToXml('list', $this->rootNode);
         while ($seekObj = $seeksResult->fetch_object()) {
             Util::objToXml($seekObj, $listNode, 'seek');
         }
         $seeksResult->close();
     }
 }
예제 #5
0
 public static function login($username, $password)
 {
     $username = Kernel::mysqli()->escape_string($username);
     $password = Kernel::mysqli()->escape_string($password);
     $userQuery = Kernel::mysqli()->query("SELECT id, level FROM user WHERE username='******' AND authkey=SHA('{$password}') ORDER BY ver DESC LIMIT 1");
     if ($userQuery->num_rows == 1) {
         $userQueryObj = $userQuery->fetch_object();
         $userQuery->close();
         $_SESSION[Sessionmanager::TYPE_LOGGED] = true;
         $_SESSION[Sessionmanager::TYPE_ID] = $userQueryObj->id;
         $_SESSION[Sessionmanager::TYPE_USERNAME] = $username;
         $_SESSION[Sessionmanager::TYPE_USERLEVEL] = $userQueryObj->level;
         Logger::finest('Login.');
         return true;
     }
     $userQuery->close();
     Logger::info('Login error.');
     return false;
 }
예제 #6
0
 public function generateAjax()
 {
     $this->template = NULL;
     $this->contentType = Kernel::CONTENT_TYPE_JSON;
     if (isset($this->url->getPageParams()->getfilesystemusage)) {
         $usageResult = Kernel::mysqli()->query('SELECT MAX(free), MAX(total), MAX(used), MIN(free), MIN(total), MIN(used) FROM fsdata');
         $usageRow = $usageResult->fetch_row();
         $maxFree = $usageRow[0];
         $maxTotal = $usageRow[1];
         $maxUsed = $usageRow[2];
         $minFree = $usageRow[3];
         $minTotal = $usageRow[4];
         $minUsed = $usageRow[5];
         $this->unitIndex = 0;
         $this->unitDivider = 1;
         while ($minUsed / $this->unitDivider >= 1024) {
             $this->unitDivider *= 1024;
             $this->unitIndex++;
         }
         $series = array();
         $usage = array();
         $fss = explode(',', MONITORED_FILESYSTEMS);
         foreach ($fss as $fs) {
             $fsdataResult = Kernel::mysqli()->query("SELECT * FROM fsdata WHERE filesystem='{$fs}'");
             if (is_object($fsdataResult)) {
                 $fsData = array();
                 while ($fsdataObj = $fsdataResult->fetch_object()) {
                     $fsData[] = array($fsdataObj->date, $fsdataObj->used / $this->unitDivider);
                 }
                 $series[] = array('label' => $fs);
                 $usage[] = $fsData;
                 $fsdataResult->close();
             }
         }
         $jsonData = array('usage' => $usage, 'series' => $series, 'ylabel' => $this->units[$this->unitIndex], 'ymax' => $maxTotal / $this->unitDivider, 'ymin' => 0.0);
         echo json_encode($jsonData);
     }
 }
예제 #7
0
 public function generateAjax()
 {
     $this->template = 'AVM';
     if (isset($this->url->getPageParams()->getserielist)) {
         $this->template = NULL;
         // No xsl transform!
         $this->contentType = Kernel::CONTENT_TYPE_JSON;
         $serieArray = array(array('id' => '0', 'name' => '-- Select serie'));
         $seriesResult = Kernel::mysqli()->query("SELECT a.* FROM serie a WHERE a.ver IN (SELECT MAX(b.ver) FROM serie b WHERE b.id = a.id)");
         if (is_object($seriesResult)) {
             while ($serieObj = $seriesResult->fetch_object()) {
                 $serieArray[] = $serieObj;
             }
             $seriesResult->close();
         }
         echo json_encode($serieArray);
     } else {
         if (isset($this->url->getPageParams()->getseasonlist)) {
             $this->template = NULL;
             // No xsl transform!
             $this->contentType = Kernel::CONTENT_TYPE_JSON;
             $this->template = null;
             if (isset($this->url->getPageParams()->id)) {
                 $id = Kernel::mysqli()->escape_string($this->url->getPageParams()->id);
                 $details = $this->getFileDetailsObjFromUrl();
                 $seasonArray = array();
                 $seasonsResult = Kernel::mysqli()->query("SELECT a.id, a.season FROM season a WHERE a.ver IN (SELECT MAX(b.ver) FROM season b WHERE b.id = a.id AND serieid = {$id})");
                 if (is_object($seasonsResult)) {
                     while ($seasonObj = $seasonsResult->fetch_object()) {
                         if ($details->season == $seasonObj->season) {
                             $seasonObj->selected = true;
                         }
                         $seasonArray[] = $seasonObj;
                     }
                     $seasonsResult->close();
                 }
                 echo json_encode($seasonArray);
             }
         } else {
             if (isset($this->url->getPageParams()->addserie)) {
                 if (!empty($_POST)) {
                     if (empty($_POST['name'])) {
                         Kernel::addInfo(Kernel::INFOBOX_ERROR, 'You must enter serie name.');
                     } else {
                         if (empty($_POST['year'])) {
                             Kernel::addInfo(Kernel::INFOBOX_ERROR, 'You must enter serie year.');
                         } else {
                             $name = Kernel::mysqli()->escape_string($_POST['name']);
                             $year = Kernel::mysqli()->escape_string($_POST['year']);
                             $url = Kernel::mysqli()->escape_string($_POST['url']);
                             $file = Kernel::mysqli()->escape_string($_POST['file']);
                             $torrent = Kernel::mysqli()->escape_string($_POST['torrent']);
                             Kernel::mysqli()->query("INSERT INTO serie (name, year, url, file, torrent)\n\t\t\t\t\t\t\t\t\t\t\tVALUES('{$name}','{$year}','{$url}','{$file}','{$torrent}')");
                             Kernel::addInfo(Kernel::INFOBOX_OK, "Serie {$name} ({$year}) added!");
                         }
                     }
                 }
             } else {
                 if (isset($this->url->getPageParams()->addseason)) {
                     if (!empty($_POST)) {
                         if (empty($_POST['serieid'])) {
                             Kernel::addInfo(Kernel::INFOBOX_ERROR, 'You must select serie.');
                         } else {
                             if (empty($_POST['season'])) {
                                 Kernel::addInfo(Kernel::INFOBOX_ERROR, 'You must enter season number.');
                             } else {
                                 $serieid = Kernel::mysqli()->escape_string($_POST['serieid']);
                                 $season = Kernel::mysqli()->escape_string($_POST['season']);
                                 $state = Kernel::mysqli()->escape_string($_POST['state']);
                                 $watched = Kernel::mysqli()->escape_string($_POST['watched']);
                                 $file = Kernel::mysqli()->escape_string($_POST['file']);
                                 $torrent = Kernel::mysqli()->escape_string($_POST['torrent']);
                                 Kernel::mysqli()->query("INSERT INTO season (serieid, season, state, watched, file, torrent)\n\t\t\t\t\t\t\t\t\t\t\tVALUES('{$serieid}','{$season}','{$state}','{$watched}','{$file}','{$torrent}')");
                                 Kernel::addInfo(Kernel::INFOBOX_OK, "Season {$season} added!");
                             }
                         }
                     }
                 } else {
                     if (isset($this->url->getPageParams()->addepisode)) {
                         if (!empty($_POST)) {
                             if (empty($_POST['serieid'])) {
                                 Kernel::addInfo(Kernel::INFOBOX_ERROR, 'You must select serie.');
                             } else {
                                 if (empty($_POST['seasonid'])) {
                                     Kernel::addInfo(Kernel::INFOBOX_ERROR, 'You must select season.');
                                 } else {
                                     if (empty($_POST['episode'])) {
                                         Kernel::addInfo(Kernel::INFOBOX_ERROR, 'You must enter episode number.');
                                     } else {
                                         if (empty($_POST['title'])) {
                                             Kernel::addInfo(Kernel::INFOBOX_ERROR, 'You must enter title.');
                                         } else {
                                             if (!isset($_POST['format'])) {
                                                 Kernel::addInfo(Kernel::INFOBOX_ERROR, 'You must enter format.');
                                             } else {
                                                 $serieid = Kernel::mysqli()->escape_string($_POST['serieid']);
                                                 $seasonid = Kernel::mysqli()->escape_string($_POST['seasonid']);
                                                 $episode = Kernel::mysqli()->escape_string($_POST['episode']);
                                                 $title = Kernel::mysqli()->escape_string($_POST['title']);
                                                 $format = AVM::$videoFormat[Kernel::mysqli()->escape_string($_POST['format'])];
                                                 $watched = Kernel::mysqli()->escape_string($_POST['watched']);
                                                 $file = Kernel::mysqli()->escape_string($_POST['file']);
                                                 $torrent = Kernel::mysqli()->escape_string($_POST['torrent']);
                                                 Kernel::mysqli()->query("INSERT INTO episode (serieid, seasonid, episode, title, format, watched, file, torrent)\n\t\t\t\t\t\t\t\t\t\t\tVALUES('{$serieid}','{$seasonid}','{$episode}', '{$title}', '{$format}','{$watched}','{$file}','{$torrent}')");
                                                 Kernel::addInfo(Kernel::INFOBOX_OK, "Episode {$title} ({$episode}) [{$format}] added!");
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     } else {
                         if (isset($this->url->getPageParams()->addmovie)) {
                             if (!empty($_POST)) {
                                 if (empty($_POST['name'])) {
                                     Kernel::addInfo(Kernel::INFOBOX_ERROR, 'You must enter movie name.');
                                 } else {
                                     if (empty($_POST['year'])) {
                                         Kernel::addInfo(Kernel::INFOBOX_ERROR, 'You must enter year.');
                                     } else {
                                         if (!isset($_POST['format'])) {
                                             Kernel::addInfo(Kernel::INFOBOX_ERROR, 'You must enter format.');
                                         } else {
                                             $name = Kernel::mysqli()->escape_string($_POST['name']);
                                             $year = Kernel::mysqli()->escape_string($_POST['year']);
                                             $url = Kernel::mysqli()->escape_string($_POST['url']);
                                             $format = AVM::$videoFormat[Kernel::mysqli()->escape_string($_POST['format'])];
                                             $watched = Kernel::mysqli()->escape_string($_POST['watched']);
                                             $file = Kernel::mysqli()->escape_string($_POST['file']);
                                             $torrent = Kernel::mysqli()->escape_string($_POST['torrent']);
                                             Kernel::mysqli()->query("INSERT INTO movie (name, year, url, format, watched, file, torrent)\n\t\t\t\t\t\t\t\t\t\t\tVALUES('{$name}','{$year}','{$url}','{$format}','{$watched}','{$file}','{$torrent}')");
                                             Kernel::addInfo(Kernel::INFOBOX_OK, "{$name} ({$year}) [{$format}] added!");
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #8
0
 public function __construct()
 {
     foreach ($_POST as $sKey => $sValue) {
         $this->{$sKey} = Kernel::mysqli()->real_escape_string($sValue);
     }
 }
예제 #9
0
function addTorrent($storage, $torrent)
{
    $storage = Kernel::mysqli()->escape_string($storage);
    $torrent = Kernel::mysqli()->escape_string($torrent);
    Kernel::mysqli()->query("INSERT INTO unhandled (file, torrent) VALUES('{$storage}','{$torrent}')");
}
예제 #10
0
 private function feedList()
 {
     $feedsResult = Kernel::mysqli()->query('SELECT * FROM feed');
     if (is_object($feedsResult)) {
         while ($feedObj = $feedsResult->fetch_object()) {
             $feed = new Feed($feedObj->data);
             foreach ($feed->entries as $entryObj) {
                 if ($entryObj->publishedDate < strtotime(AVM::$torrentTimelimit)) {
                     continue;
                 }
                 $match = @preg_match(AVM::$torrentFilter, $entryObj->title);
                 if (empty($match)) {
                     continue;
                 }
                 Util::objToXml($entryObj, $this->listNode, 'feeditem');
             }
         }
         $feedsResult->close();
     }
 }
예제 #11
0
 public function movieList($page, $count)
 {
     $moviesResult = Kernel::mysqli()->query('SELECT a.* FROM movie a WHERE a.ver IN (SELECT MAX(b.ver) FROM movie b WHERE b.id = a.id) ORDER BY name');
     if (is_object($moviesResult)) {
         $listNode = Util::tagToXml('list', $this->rootNode);
         while ($movieObj = $moviesResult->fetch_object()) {
             Util::objToXml($movieObj, $listNode, 'movie');
         }
         $moviesResult->close();
     }
 }
예제 #12
0
 public function serieList($page, $count)
 {
     $seriesResult = Kernel::mysqli()->query('SELECT a.* FROM serie a WHERE a.ver IN (SELECT MAX(b.ver) FROM serie b WHERE b.id = a.id) ORDER BY name');
     if (is_object($seriesResult)) {
         $listNode = Util::tagToXml('list', $this->rootNode);
         while ($serieObj = $seriesResult->fetch_object()) {
             $serieNode = Util::objToXml($serieObj, $listNode, 'serie');
             $seasonsResult = Kernel::mysqli()->query("SELECT a.* FROM season a WHERE a.ver IN (SELECT MAX(b.ver) FROM season b WHERE b.id = a.id AND serieid = {$serieObj->id}) ORDER BY season");
             if (is_object($seasonsResult)) {
                 while ($seasonObj = $seasonsResult->fetch_object()) {
                     $seasonNode = Util::objToXml($seasonObj, $serieNode, 'season');
                     $episodesResult = Kernel::mysqli()->query("SELECT a.* FROM episode a WHERE a.ver IN (SELECT MAX(b.ver) FROM episode b WHERE b.id = a.id AND serieid = {$serieObj->id} AND seasonid = {$seasonObj->id}) ORDER BY episode");
                     if (is_object($episodesResult)) {
                         while ($episodeObj = $episodesResult->fetch_object()) {
                             $episodeObj->season = $seasonObj->season;
                             Util::objToXml($episodeObj, $seasonNode, 'episode');
                         }
                         $episodesResult->close();
                     }
                 }
                 $seasonsResult->close();
             }
         }
         $seriesResult->close();
     }
 }