public static function authentifierUtilisateurParMotDePasse($login, $mdp) { $query = "select * from utilisateur "; $query .= " where login="******" and motdepasse=" . \core\Mysqli::real_escape_string_html(sha1($mdp)); \core\Mysqli::query($query); $u = \core\Mysqli::getObjectAndClose(false, __CLASS__); if ($u) { $u->options = json_decode($u->options); do { $u->keyconnexion = \model\simple\String::random(40); } while (!$u->update()); return $u; } return false; }
static function ajouteFilm($titre, $titreoriginal, $infos, $urlposter, $urlbackdrop, $anneeprod, $acteurs, $realisateurs, $idallocine = null, $idthemoviedb = null) { if ($f = Film::checkIdallocine($idallocine)) { return $f; } else { $film = new Film(); $film->titre = $titre; $film->titreoriginal = $titreoriginal; $film->infos = $infos; $film->idallocine = $idallocine; $film->idthemoviedb = $idthemoviedb; $film->urlbackdrop = $urlbackdrop; $film->urlposter = $urlposter; $film->acteurs = $acteurs; $film->anneeprod = $anneeprod; $film->realisateurs = $realisateurs; do { $film->id = \model\simple\String::random(10); } while (!$film->insert()); return $film; } }
function retourneResMovieFormat() { $v = $this->retourneResMovie(); if ($v != null) { $tmp["type"] = "movie"; $tmp["code"] = $v->code; $tmp["codeall"] = $v->code; if (isset($v->originalTitle)) { $tmp["Titre original"] = $v->originalTitle; } if (isset($v->title)) { $tmp["Titre"] = $v->title; } if (isset($v->productionYear)) { $tmp["Année de production"] = $v->productionYear; } if (isset($v->runtime)) { $tmp["Durée"] = $this->dateFormat($v->runtime); } if (isset($v->trailer->href)) { $tmp["Bande annonce"] = $v->trailer->href; } if (isset($v->statistics->userRating)) { $tmp["Note des spectacteurs"] = $v->statistics->userRating; } if (isset($v->statistics->pressRating)) { $tmp["Note de la presse"] = $v->statistics->pressRating; } if (isset($v->release->releaseDate)) { $tmp["Date de sortie"] = preg_replace("#(\\d+)\\-(\\d+)\\-(\\d+)#", "\$3/\$2/\$1", $v->release->releaseDate); } if (!isset($tmp["Date de sortie"])) { $content = file_get_contents("http://www.allocine.fr/film/fichefilm_gen_cfilm=" . $tmp["code"] . ".html"); if (preg_match('#datePublished"[^>]+>(\\d+) (janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre) (\\d+)#', $content, $o)) { //">(\d+) (janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre) (\d+) $ta["janvier"] = "01"; $ta["février"] = "02"; $ta["mars"] = "03"; $ta["avril"] = "04"; $ta["mai"] = "05"; $ta["juin"] = "06"; $ta["juillet"] = "07"; $ta["août"] = "08"; $ta["septembre"] = "09"; $ta["octobre"] = "10"; $ta["novembre"] = "11"; $ta["décembre"] = "12"; $tmp["Date de sortie"] = $o[1] . "/" . $ta[$o[2]] . "/" . $o[3]; } } if (isset($v->release->distributor->name)) { $tmp["Distributeur"] = $v->release->distributor->name; } if (isset($v->movieType->_)) { $tmp["Type du film"] = $v->movieType->_; } if (isset($v->castingShort->directors)) { $tmp["Réalisateur(s)"] = $v->castingShort->directors; } if (isset($v->castingShort->actors)) { $tmp["Acteur(s)"] = $v->castingShort->actors; } $maxratioposter = -1; $maxratiobackdrop = -1; if (isset($v->media)) { foreach ($v->media as $k => $vv) { if ($vv->class === "picture") { $width = 0; $height = 0; if (isset($vv->width) && isset($vv->height)) { $width = $vv->width; $height = $vv->height; } else { $info = getimagesize($vv->thumbnail->href); $width = $info[0]; $height = $info[1]; } if ($width > $height) { //Backdrop test if ($maxratiobackdrop < $height / $width) { $maxratiobackdrop = $height / $width; } $tmp["imagebackdrop"]["url"][] = array($vv->thumbnail->href, $width, $height); } else { //Poster if ($maxratioposter < $height / $width) { $maxratioposter = $height / $width; } $tmp["imageposter"]["url"][] = array($vv->thumbnail->href, $width, $height); } } if ($vv->class === "video" && $vv->type->_ === "Bande-annonce" && strpos($vv->title, 'VF') !== false) { $tmp["ba"] = $vv->code; } } } $tmdb = new TheMovieDb(); $films = $tmdb->searchFilm($v->originalTitle, "en"); //var_dump($tmp1); //die(); if (isset($films->results)) { if (count($films->results) > 0) { foreach ($films->results as $vvv) { //var_dump(stripos($vvv->original_title, $v->originalTitle)); if (stripos(String::remplaceAccent($vvv->original_title), String::remplaceAccent($v->originalTitle)) === 0) { $tmp1 = $tmdb->getMovieImage($vvv->id); foreach ($tmp1->backdrops as $k => $vv) { //var_dump($vv); //die(); if ($maxratiobackdrop < $vv->height / $vv->width) { $maxratiobackdrop = $vv->height / $vv->width; } $tmp["imagebackdrop"]["url"][] = array("http://image.tmdb.org/t/p/original" . $vv->file_path, $vv->width, $vv->height); } foreach ($tmp1->posters as $k => $vv) { if ($maxratioposter < $vv->height / $vv->width) { $maxratioposter = $vv->height / $vv->width; } $tmp["imageposter"]["url"][] = array("http://image.tmdb.org/t/p/original" . $vv->file_path, $vv->width, $vv->height); } } } } } //die(); if ($maxratiobackdrop > -1) { $tmp["imagebackdrop"]["ratio"] = $maxratiobackdrop; } if ($maxratioposter > -1) { $tmp["imageposter"]["ratio"] = $maxratioposter; } if (isset($v->movieCertificate->certificate->_)) { $tmp["Interdiction"] = $v->movieCertificate->certificate->_; } if (isset($v->nationality)) { $tmp["Origine"] = ""; foreach ($v->nationality as $k => $vs) { $tmp["Origine"] .= $vs->_ . ", "; } $tmp["Origine"] = substr($tmp["Origine"], 0, -2); } if (isset($v->genre)) { $tmp["Genre"] = ""; foreach ($v->genre as $k => $vs) { $tmp["Genre"] .= $vs->_ . ", "; } $tmp["Genre"] = substr($tmp["Genre"], 0, -2); } if (isset($v->synopsis)) { $tmp["Synopsis"] = $v->synopsis; } if (isset($v->synopsisShort)) { $tmp["synopsiscourt"] = $v->synopsisShort; } return $tmp; } return null; }
echo BASE_URL; ?> bower_components/foundation/js/foundation.js"></script> <script type="text/javascript" src="<?php echo BASE_URL; ?> javascripts/noty/packaged/jquery.noty.packaged.js"></script> <!--<script src="<?php echo BASE_URL; ?> javascripts/mediastorrent/jquery.mousewheel.js"></script> --><?php echo isset($loadjavascript_for_layout) ? $loadjavascript_for_layout : ""; ?> <h1><?php echo \model\simple\String::styleString("Installation de MediasTorrent"); ?> </h1> <?php echo isset($debug_icon_for_layout) ? $debug_icon_for_layout : ""; ?> <div class="container"> <center><?php echo $content_for_layout; ?> </center> </div> <center>
function send($keyconnexion = null) { \model\simple\Utilisateur::authentificationPourRtorrent($keyconnexion); if (!\config\Conf::$user["user"]) { throw new \Exception("Non User"); } $erreur = 1; $torrents = null; $clefunique = null; $typemedias = null; $status = "ok"; /* * ================================================= * Traitement Mediastorrent !!!! * ================================================= */ if (isset($_REQUEST["mediastorrent"])) { $tmpclefunique = null; for ($idtorrent = 0; $idtorrent < $_REQUEST["nbtorrents"]; $idtorrent++) { if (isset($_REQUEST["torrent" . $idtorrent . "addbibli"])) { $typemedias[$_REQUEST["torrent" . $idtorrent . "hash"]] = $_REQUEST["torrent" . $idtorrent . "type"]; switch ($_REQUEST["torrent" . $idtorrent . "type"]) { case 'film': $clef = \model\mysql\Torrentfilm::getClefUnique(); $clefunique[$_REQUEST["torrent" . $idtorrent . "hash"]] = $clef; for ($idfile = 0; $idfile < $_REQUEST["torrent" . $idtorrent . "nbfiles"]; $idfile++) { if (isset($_REQUEST["torrent" . $idtorrent . "ajoutecheckfile" . $idfile]) && isset($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "recherche"])) { if ($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "recherche"] === "manuel") { //Manuel $titre = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "titre"]); $otitre = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "titreoriginal"]); $synopsis = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "synopsis"]); $genre = explode(",", $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "genre"]); array_walk($genre, create_function('&$val', '$val = trim($val);')); array_walk($genre, create_function('&$val', '$val = strtolower($val);')); array_walk($genre, create_function('&$val', '$val = ucfirst($val);')); $acteurs = explode(",", $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "acteur"]); array_walk($acteurs, create_function('&$val', '$val = trim($val);')); array_walk($acteurs, create_function('&$val', '$val = strtolower($val);')); array_walk($acteurs, create_function('&$val', '$val = ucwords($val);')); $acteurs = implode(", ", $acteurs); $realisateurs = explode(",", $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "realisateur"]); array_walk($realisateurs, create_function('&$val', '$val = trim($val);')); array_walk($realisateurs, create_function('&$val', '$val = strtolower($val);')); array_walk($realisateurs, create_function('&$val', '$val = ucwords($val);')); $realisateurs = implode(", ", $realisateurs); $anneeprod = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "anneeprod"]); $urlposter = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "poster"]); $urlbackdrop = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "backdrop"]); $infos["Titre"] = $titre; $infos["Titre original"] = $otitre; $infos["Genre"] = implode(", ", $genre); $infos["Réalisateur(s)"] = $realisateurs; $infos["Acteur(s)"] = $acteurs; $infos["Année de production"] = $anneeprod; $infos["Synopsis"] = $synopsis; $film = \model\mysql\Film::ajouteFilm($titre, $otitre, json_encode($infos), $urlposter, $urlbackdrop, $anneeprod, $acteurs, $realisateurs); $idfilm = $film->id; $film->addGenre($genre); } else { //Auto if ($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "typerecherche"] === "local") { //Local $idfilm = $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "code"]; } else { //Allo $o["typesearch"] = "movie"; $allo = new \model\simple\Allocine($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "code"], $o); $infos = $allo->retourneResMovieFormatForBD(); $genre = $infos["Genre"]; $infos["Genre"] = implode(", ", $genre); $titre = isset($infos["Titre"]) ? $infos["Titre"] : $infos["Titre original"]; $otitre = $infos["Titre original"]; $urlposter = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "poster"]); $urlbackdrop = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "backdrop"]); $realisateurs = $infos["Réalisateur(s)"]; $acteurs = ""; if (isset($infos["Acteur(s)"])) { $acteurs = $infos["Acteur(s)"]; } $anneeprod = $infos["Année de production"]; $film = \model\mysql\Film::ajouteFilm($titre, $otitre, json_encode($infos), $urlposter, $urlbackdrop, $anneeprod, $acteurs, $realisateurs, $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "code"]); $idfilm = $film->id; $film->addGenre($genre); } } \model\mysql\Torrentfilm::addTorrentFilm($idfilm, $_REQUEST["torrent" . $idtorrent . "numfile" . $idfile], $_REQUEST["torrent" . $idtorrent . "filecomplement" . $idfile], \config\Conf::$user["user"]->login, \config\Conf::$nomrtorrent, $_REQUEST["torrent" . $idtorrent . "hash"], $clef, isset($_REQUEST["torrent" . $idtorrent . "partagecheckfile" . $idfile])); } } break; case 'serie': $clef = \model\mysql\Torrentserie::getClefUnique(); $clefunique[$_REQUEST["torrent" . $idtorrent . "hash"]] = $clef; for ($idfile = 0; $idfile < $_REQUEST["torrent" . $idtorrent . "nbfiles"]; $idfile++) { if (isset($_REQUEST["torrent" . $idtorrent . "ajoutecheckfile" . $idfile]) && isset($_REQUEST["torrent" . $idtorrent . "filerecherche"])) { if ($_REQUEST["torrent" . $idtorrent . "filerecherche"] === "manuel") { //Manuel /** * Todo check $idfile, une série == un torrent, pareil pour les différents fichier le contenant différent du film */ $titre = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "titre"]); $otitre = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "titreoriginal"]); $synopsis = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "synopsis"]); $genre = explode(",", $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "genre"]); array_walk($genre, create_function('&$val', '$val = trim($val);')); array_walk($genre, create_function('&$val', '$val = strtolower($val);')); array_walk($genre, create_function('&$val', '$val = ucfirst($val);')); $acteurs = explode(",", $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "acteur"]); array_walk($acteurs, create_function('&$val', '$val = trim($val);')); array_walk($acteurs, create_function('&$val', '$val = strtolower($val);')); array_walk($acteurs, create_function('&$val', '$val = ucwords($val);')); $acteurs = implode(", ", $acteurs); $realisateurs = explode(",", $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "realisateur"]); array_walk($realisateurs, create_function('&$val', '$val = trim($val);')); array_walk($realisateurs, create_function('&$val', '$val = strtolower($val);')); array_walk($realisateurs, create_function('&$val', '$val = ucwords($val);')); $realisateurs = implode(", ", $realisateurs); $anneeprod = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "anneeprod"]); $urlposter = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "poster"]); $urlbackdrop = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "backdrop"]); $infos["Titre"] = $titre; $infos["Titre original"] = $otitre; $infos["Genre"] = implode(", ", $genre); $infos["Réalisateur(s)"] = $realisateurs; $infos["Acteur(s)"] = $acteurs; $infos["Année de production"] = $anneeprod; $infos["Synopsis"] = $synopsis; $serie = \model\mysql\Serie::ajouteSerie($titre, $otitre, json_encode($infos), $urlposter, $urlbackdrop, $anneeprod, $acteurs, $realisateurs); $idserie = $serie->id; $serie->addGenre($genre); } else { //Auto if ($_REQUEST["torrent" . $idtorrent . "filetyperecherche"] === "local") { //Local $idserie = $_REQUEST["torrent" . $idtorrent . "filecode"]; } else { //Allo $o["typesearch"] = "tvseries"; $allo = new \model\simple\Allocine($_REQUEST["torrent" . $idtorrent . "filecode"], $o); $infos = $allo->retourneResSerieFormatForBD(); $genre = $infos["Genre"]; $infos["Genre"] = implode(", ", $genre); $titre = isset($infos["Titre"]) ? $infos["Titre"] : $infos["Titre original"]; $otitre = $infos["Titre original"]; $urlposter = trim($_REQUEST["torrent" . $idtorrent . "fileposter"]); $urlbackdrop = trim($_REQUEST["torrent" . $idtorrent . "filebackdrop"]); $realisateurs = $infos["Réalisateur(s)"]; $acteurs = ""; if (isset($infos["Acteur(s)"])) { $acteurs = $infos["Acteur(s)"]; } $anneeprod = $infos["Lancement"]; $this->set("ICI", "Ok"); $serie = \model\mysql\Serie::ajouteSerie($titre, $otitre, json_encode($infos), $urlposter, $urlbackdrop, $anneeprod, $acteurs, $realisateurs, $_REQUEST["torrent" . $idtorrent . "filecode"]); $idserie = $serie->id; $serie->addGenre($genre); } } \model\mysql\Torrentserie::addTorrentSerie($idserie, $_REQUEST["torrent" . $idtorrent . "numfile" . $idfile], $_REQUEST["torrent" . $idtorrent . "filecomplement" . $idfile], \config\Conf::$user["user"]->login, $_REQUEST["torrent" . $idtorrent . "filesaison" . $idfile], $_REQUEST["torrent" . $idtorrent . "fileepisode" . $idfile], \config\Conf::$nomrtorrent, $_REQUEST["torrent" . $idtorrent . "hash"], $clef, isset($_REQUEST["torrent" . $idtorrent . "partagecheckfile" . $idfile])); } } break; } } } } if (isset($_FILES['torrentfile']) && !(count($_FILES['torrentfile']) == 1 && $_FILES['torrentfile']['error'][0] != 4)) { if (is_array($_FILES['torrentfile']['name'])) { for ($i = 0; $i < count($_FILES['torrentfile']['name']); ++$i) { $files[] = array('name' => $_FILES['torrentfile']['name'][$i], 'tmp_name' => $_FILES['torrentfile']['tmp_name'][$i], 'error' => $_FILES['torrentfile']['error'][$i]); } } else { $files[] = $_FILES['torrentfile']; } foreach ($files as $file) { $erreur = 0; $torrent = null; $torrent['erreur'] = 1; $torrent['nom'] = $file["name"]; if (pathinfo($file["name"], PATHINFO_EXTENSION) != "torrent") { $file["name"] .= ".torrent"; } $des = DS . "tmp" . DS . $file["name"]; $torrent['nom'] = $file["name"]; $ok = move_uploaded_file($file['tmp_name'], $des); if ($ok) { $to = new \model\simple\Torrent($des); //$torrents[]= array($to->getFileName(),$to->info["name"]); if ($to->errors()) { $torrent['status'] = "Erreur du fichier torrent"; } else { $torrent["status"] = \model\xmlrpc\rTorrent::sendTorrent($to, !isset($_REQUEST['autostart']), $_REQUEST['repertoire']); $torrent["clefunique"] = \model\simple\String::random(10); usleep(40000); if ($torrent['status'][0] === '0') { $req = new \model\xmlrpc\rXMLRPCRequest(\config\Conf::$userscgi, array(new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "d.custom.set", array($to->hash_info(), "clefunique", $clefunique[$to->hash_info()])), new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "d.custom.set", array($to->hash_info(), "typemedias", isset($typemedias[$to->hash_info()]) ? $typemedias[$to->hash_info()] : "aucun")))); $torrent["clefuniqueres"] = $req->success() ? $req->val : $req->val; if ($torrent["clefuniqueres"][0] === "0" && $torrent["clefuniqueres"][1] === "0") { $torrent['erreur'] = 0; } } } unlink($des); } else { $torrent['status'] = "Erreur lors de l'upload | Code d'erreur => " . $file["error"]; } $torrents[] = $torrent; } } else { $status = "Pas de fichier envoyer"; } $this->set(array("torrents" => $torrents, "erreur" => $erreur, "status" => $status, "seedbox" => \model\mysql\Rtorrent::getRtorrentsDeUtilisateur(\config\Conf::$user["user"]->login))); }
static function getClefUnique() { do { $query = "select * from torrentserie "; $clefunique = \model\simple\String::random(10); $query .= "where clefunique=" . \core\Mysqli::real_escape_string_html($clefunique); \core\Mysqli::query($query); } while (!is_bool(\core\Mysqli::getObjectAndClose(false, __CLASS__))); return $clefunique; }
</table> <table> <tr> <td>Ecriture dans le cache</td> <td><?= ($ecrituredossiercache ? \model\simple\String::styleSuccess("Ok") : \model\simple\String::styleError("Non ok : pour rendre l'écriture possible veuillez faire : sudo chmod -R a+w " . ROOT . DS . "cache")); ?> </td> </tr> <tr> <td>Ecriture dans le log</td> <td><?= ($ecrituredossierlog ? \model\simple\String::styleSuccess("Ok") : \model\simple\String::styleError("Non ok : pour rendre l'écriture possible veuillez faire : sudo chmod -R a+w " . ROOT . DS . "log")); ?> </td> </tr> <tr> <td>Ecriture dans le fichier Conf</td> <td><?= ($ecriturefileconfig ? \model\simple\String::styleSuccess("Ok") : \model\simple\String::styleError("Non ok : pour rendre l'écriture possible veuillez faire : sudo chmod -R a+w " . ROOT . DS . "config" . DS . "Conf.php")); ?> </td> </tr> </table> <?php if ($ecriturefileconfig && $ecrituredossiercache && $json && $curl && $imagick && $mysqli && $memcached && $ecrituredossierlog) { ?> <a class="button secondary" href="<?= \core\Router::url("install/mysqlinit") ?>">Suite</a> <? } else { ?> <a class="button" href="<?= \core\Router::url("") ?>">Recharger la page</a> <? } ?>
static function getRandomMdp() { do { $mdp = \model\simple\String::random(8); } while (preg_match('/(?=^.{8,}$)((?=.*\\d)|(?=.*\\W+))(?![.\\n])(?=.*[A-Z])(?=.*[a-z]).*$/', $mdp) != 1); return $mdp; }
function genereCache() { for ($i = 0; $i < 100; $i++) { $login = \model\simple\String::random(5); \core\Memcached::value($login, "user", \model\simple\String::random(105, true), 60 * 60); } }