if (isset($_POST['save'])) { editMovie($movieid, $_POST['name'], $_POST['file'], $_POST['description']); $notify->add($lang->get('media'), $lang->get('editmovie_done')); } else { $mv = getMovie($movieid); $breadcrumbs->addElement($mv['name'], makeURL($mod, array('categoryid' => $categoryid, 'movieid' => $movieid))); $breadcrumbs->addElement($lang->get('editmovie'), makeURL($mod, array('categoryid' => $categoryid, 'movieid' => $movieid, 'mode' => 'editmovie'))); $smarty->assign('path', $template_dir . "/editmovie.tpl"); $smarty->assign('movie', $mv); break; } } case 'addmovie': if ($isallowed && $mode == 'addmovie') { if (isset($_POST['add'])) { addMovie($categoryid, $_POST['name'], $_POST['file'], $_POST['description']); } else { $breadcrumbs->addElement($lang->get('addmovie'), makeURL($mod, array('categoryid' => $categoryid, 'mode' => 'addmovie'))); $smarty->assign('files', listAvailableMovies()); $smarty->assign('path', $template_dir . "/addmovie.tpl"); break; } } case 'editpictures': if ($isallowed && $mode == 'editpictures') { $breadcrumbs->addElement($lang->get('editpictures'), makeURL('media', array('categoryid' => $categoryid, 'mode' => 'editpictures'))); $smarty->assign('path', $template_dir . "/removepictures.tpl"); $folder = $category['uniqid']; $smarty->assign('folder', $folder); @($imglist = scandir('media/images/' . $folder . '/')); if ($imglist !== false) {
<?php session_start(); if ($_SESSION['user']['name'] == NULL || $_SESSION['user']['name'] == "") { header('HTTP/1.0 403 Forbidden'); exit; } include "../class/clsDatabase.php"; $db = new Db(); if ($_GET['action'] == "add" || $_GET['action'] == "update") { $movie = array('movie_title' => $_POST['movieTitle'], 'genre' => $_POST['genre'], 'overview' => $_POST['movieoverview'], 'release_year' => $_POST['year'], 'poster_image' => $_POST['imgPoster'], 'backdrop_image' => $_POST['imgBackDrop'], 'trailer_link' => $_POST['trailerLnk'], 'imdb_rating' => $_POST['rating'], 'critics' => $_POST['critics'], 'audience' => $_POST['audience'], 'imdb_id' => $_POST['imdbcode'], 'stream_links' => $_POST['streamLinks'], "age_restrict" => $_POST['ageRestrict']); if ($_GET['action'] == "add") { $movie['added_date'] = $_POST['posted_date']; $query = addMovie($movie); //echo $query; $res = $db->insertGetLastID($query); if ($res > 0) { echo $res; } else { echo "-1"; } } else { if ($_GET['action'] == "update") { $movie['updated_date'] = $_POST['updated_date']; $query = updateMovie($movie); $query .= " WHERE id='" . $_POST['id'] . "';"; //echo $query; $res = $db->getaffectedRows($query); if ($res > 0) { echo "1"; } else {
function updateMovies() { global $logger; $logger->info("UPDATE MOVIES"); $sqlresult = mysqli_query($GLOBALS['mysqli'], " UPDATE movies c\r\n INNER JOIN (\r\n SELECT movieId, SUM(seed)+SUM(leech) as total\r\n FROM links\r\n WHERE `translateQuality` != \"ORIGINAL\"\r\n GROUP BY movieId\r\n ) x ON c.id = x.movieId\r\n SET c.sum_peers = x.total\r\n "); if (mysqli_errno($GLOBALS['mysqli'])) { $logger->error(mysqli_error($GLOBALS['mysqli'])); } $sqlresult = mysqli_query($GLOBALS['mysqli'], "SELECT * FROM `movies` WHERE `movies`.id in (SELECT movieId FROM links)"); while ($row = mysqli_fetch_assoc($sqlresult)) { if ($reason = trySkipMovie($row)) { $logger->info($row['title'] . ": {$reason}"); $res = addMovie($row); if ($res !== 0) { $logger->warning($res); } //$logger->info(print_r($row, true)); } } }
$actors = array(); while ($actor = mysqli_fetch_array($actorData)) { array_push($actors, $actor); } createResponse($actors); } else { createResponse(array('error' => 'No actors found for this movie.')); } }); ////////////////////// // // // MOVIES // // // ////////////////////// $app->get('/actors/movie/{movieId}/{movieName}/{movieReleaseDate}/{movieDescription}', function ($request, $response, $args) { if (addMovie($args['movieId'], $args['movieName'], $args['movieReleaseDate'], $args['movieDescription'])) { createResponse(array('succes' => 'Succesfully created movie.')); } else { createResponse(array('error' => 'Could not create movie.')); } }); $app->get('/movie/{movieId}', function ($request, $response, $args) { if ($movieData = getMovie($args['movieId'])) { $movie = mysqli_fetch_array($movieData); createResponse($movie); } else { createResponse(array('error' => 'Could not load movie.')); } }); $app->get('/movie/search/{movieName}', function ($request, $response, $args) { if ($movieData = getmovieNameLike($args['movieName'])) {
/* * Returns all movies */ $app->get('/movies', function () use($app, $db) { listAllMovies($app, $db); }); /* * Returns a movie */ $app->get('/movies/:id', function ($id) use($app, $db) { fetchMovie($id, $app, $db); }); /* * Creates a new movie */ $app->post('/movies', function () use($app, $db) { addMovie($app, $db); }); /* * Updates a movie */ $app->put('/movies/:id', function ($id) use($app, $db) { updateMovie($id, $app, $db); }); /* * Deletes a movie */ $app->delete('/movies/:id', function ($id) use($app, $db) { deleteMovie($id, $app, $db); }); $app->run();
function processAddMovie() { $id = $_POST['id']; $obj = getMovie($id); $title = $obj['original_title']; $description = $obj['overview']; $poster_path = 'http://image.tmdb.org/t/p/w500' . $obj['poster_path']; $poster_destination = '/img/movie/poster' . $obj['poster_path']; //returns false if function fails $falseOnFailure = copy($poster_path, __DIR__ . '/../' . $poster_destination); if ($falseOnFailure == false) { $poster_destination = null; } $tagline = $obj['tagline']; $date = $obj['release_date']; $backdrop_path = 'http://image.tmdb.org/t/p/w1920' . $obj['backdrop_path']; $backdrop_destination = '/img/movie/backdrop' . $obj['backdrop_path']; //no poster_destination $falseOnFailure = copy($backdrop_path, __DIR__ . '/../' . $backdrop_destination); if ($falseOnFailure == false) { $backdrop_destination = null; } $movieID = addMovie($id, $title, $description, $poster_destination, $tagline, $date, $backdrop_destination); if (is_numeric($movieID)) { header("Location:../movies/{$movieID}"); } else { $errorMsg = $movieID; include '../view/errorPage.php'; } }
function addLink($cur) { global $logger; if (($res = addMovie($cur['movie'])) !== 0) { return "could not add movie: {$res}"; } $hash = md5($cur['link']); $link = mysqli_real_escape_string($GLOBALS['mysqli'], $cur['link']); $sqlresult = mysqli_query($GLOBALS['mysqli'], "SELECT * FROM links WHERE md5 = '{$hash}'"); if (mysqli_errno($GLOBALS['mysqli'])) { $logger->error(mysqli_error($GLOBALS['mysqli'])); } if (!mysqli_num_rows($sqlresult)) { $sqlresult = mysqli_query($GLOBALS['mysqli'], "INSERT INTO links(link,md5) VALUES('{$link}', '{$hash}')"); if (mysqli_errno($GLOBALS['mysqli'])) { $logger->error(mysqli_error($GLOBALS['mysqli'])); } } $id = $cur['movie']['id']; $description = mysqli_real_escape_string($GLOBALS['mysqli'], $cur['description']); $quality = mysqli_real_escape_string($GLOBALS['mysqli'], $cur['quality']); $translateQuality = array_key_exists('translateQuality', $cur) ? $cur['translateQuality'] : ""; $size = (double) $cur['size']; $seed = (int) $cur['seed']; $leech = (int) $cur['leech']; if (!array_key_exists('added_tracker', $cur)) { $cur['added_tracker'] = time(); } $added_tracker = date("Y-m-d H:i:s", (int) $cur['added_tracker']); mysqli_query($GLOBALS['mysqli'], "UPDATE links SET movieId={$id}, description='{$description}', quality='{$quality}', translateQuality='{$translateQuality}', size={$size}, seed={$seed}, leech={$leech}, updated=now(), added_tracker='{$added_tracker}' WHERE md5 = '{$hash}'"); if (mysqli_errno($GLOBALS['mysqli'])) { $logger->error(mysqli_error($GLOBALS['mysqli'])); } return 0; }
notMyMovies(); break; case 'addComment': addComment(); break; case 'watch': watch(); break; case 'addGenre': addGenre(); break; case 'getGenre': getGenre(); break; case 'addMovie': addMovie(); break; case 'delete': delete(); break; case 'addUser': createAccount(); break; case 'checkUser': checkUser(); break; } function checkUserName() { $userN = 'php'; $password = '******';
if (isAdmin($user['id'])) { echo vkUploadPhoto((int) $_POST['movieId'], $user['token']); } else { echo "access denied"; } break; case "updateMovie": if (isAdmin($user['id'])) { $movie = array(); if ($_POST['imdbid']) { $movie['imdbid'] = $_POST['imdbid']; } if ($_POST['kpid']) { $movie['kpid'] = $_POST['kpid']; } $res = addMovie($movie, true); echo $res === 0 ? "UPDATED\n" : "NOT UPDATED: {$res}\n"; print_r($movie); } else { echo "access denied"; } break; case "getIds": if (isAdmin($user['id'])) { $movie = array(); if ($_POST['year']) { $movie['year'] = (int) $_POST['year']; } getIds($_POST['title'], $movie); print_r($movie); if ($_POST['movieId']) {