Esempio n. 1
0
 function infofichier()
 {
     if (isset($_FILES['torrentfile'])) {
         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'];
         }
         $torrents = null;
         foreach ($files as $file) {
             $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'] = "ErreurFichier";
                 } else {
                     $info = $to->info;
                     $f = null;
                     $torrent['hash'] = $to->hash_info();
                     if (isset($info['files'])) {
                         $numfile = 0;
                         foreach ($info['files'] as $key => $tfile) {
                             $nom = $info['name'] . DS . implode(DS, $tfile['path']);
                             if (in_array(strtolower(pathinfo($nom, PATHINFO_EXTENSION)), \config\Conf::$videoExtensions)) {
                                 $torrent["erreur"] = 0;
                                 $fi["nom"] = $nom;
                                 $fi["numfile"] = $numfile;
                                 $torrent['type'] = "movie";
                                 $f[] = $fi;
                             } else {
                                 if (in_array(strtolower(pathinfo($nom, PATHINFO_EXTENSION)), \config\Conf::$musicExtensions)) {
                                     $torrent["erreur"] = 0;
                                     $fi["nom"] = $nom;
                                     $fi["numfile"] = $numfile;
                                     $torrent['type'] = "music";
                                     $f[] = $fi;
                                 }
                             }
                             $numfile++;
                         }
                     } else {
                         if (in_array(strtolower(pathinfo($info['name'], PATHINFO_EXTENSION)), \config\Conf::$videoExtensions)) {
                             $torrent["erreur"] = 0;
                             $fi["nom"] = $info['name'];
                             $fi["numfile"] = 0;
                             //$fi ["ext"] = pathinfo ( $info ['name'], PATHINFO_EXTENSION );
                             $torrent['type'] = "movie";
                             //$fi ["nomaff"] = formatNomAff ( $fi ["nom"] );
                             $f[] = $fi;
                         } else {
                             if (in_array(strtolower(pathinfo($info['name'], PATHINFO_EXTENSION)), \config\Conf::$musicExtensions)) {
                                 $torrent["erreur"] = 0;
                                 $fi["numfile"] = 0;
                                 $fi["nom"] = $info['name'];
                                 //$fi ["ext"] = pathinfo ( $info ['name'], PATHINFO_EXTENSION );
                                 $torrent['type'] = "music";
                                 //$fi ["nomaff"] = formatNomAff ( $fi ["nom"] );
                                 $f[] = $fi;
                             }
                         }
                     }
                     if (is_null($f)) {
                         $torrent["status"] = "Aucun fichier compatible avec la bibliothèque (" . ")";
                     } else {
                         $torrent["files"] = $f;
                     }
                     if (isset($_REQUEST["extension"])) {
                         $torrent['nom'] = $info['name'];
                     }
                 }
                 unlink($des);
             }
             $torrents[] = $torrent;
         }
         /*$tor = null;
                     foreach( $files as $file )
                     {
                         $ufile = $file['name'];
                         if(pathinfo($ufile,PATHINFO_EXTENSION)!="torrent")
                             $ufile.=".torrent";
                         $nomm = md5(uniqid(rand(), true));
                         $to = null;
                         $to["name"]=$file['name'];
                         $to["erreur"] = -1;
                         $ok = move_uploaded_file($file['tmp_name'],"/home/admin/salorium/log/".$nomm.".torrent");
                         if ($ok ){
                             $torrent = new Torrent ( "/home/admin/salorium/log/".$nomm.".torrent" );
                             if ($torrent->errors ()) {
                                 $to["status"] = "FailedFile";
                             }else{
         
                                 $info = $torrent->info;
                                 $f = null;
         
                                 if (isset ( $info ['files'] )){
                                     foreach ( $info ['files'] as $key => $tfile ) {
                                         $nom = $topDirectory.$info ['name']."/" .implode ( '/', $tfile ['path'] );
                                         if (in_array ( strtolower ( pathinfo ( $nom, PATHINFO_EXTENSION ) ), Thumbnailers::$videoExtensions )) {
                                             $to["erreur"] = 0;
                                             $fi ["nom"] = basename($nom);
                                             $fi ["ext"] = pathinfo ( $nom, PATHINFO_EXTENSION );
                                             $fi ["nomaff"] = formatNomAff ( $fi ["nom"] );
                                             $f [] = $fi;
                                         }
                                     }
                                 }
                                 else if (in_array ( strtolower ( pathinfo ( $info ['name'], PATHINFO_EXTENSION ) ), Thumbnailers::$videoExtensions )) {
                                     $to["erreur"] = 0;
                                     $fi ["nom"] = basename($topDirectory.$info ['name']."/".$info ['name']);
                                     $fi ["ext"] = pathinfo ( $info ['name'], PATHINFO_EXTENSION );
                                     $fi ["nomaff"] = formatNomAff ( $fi ["nom"] );
                                     $f [] = $fi;
                                 }
                                 if (is_null($f)){
                                     $to["status"] = "Aucun fichier compatible avec le site (" . Thumbnailers::getStringExtension () . ")";
                                 }else{
                                     $to["file"] = $f;
                                 }
         
                             }
                             unlink("/home/admin/salorium/log/".$nomm.".torrent");
         
                         }else{
                             $to["status"] = "Erreur de déplacement ou upload code erreur =>".$file['error'];
                         }
                         $tor[]=$to;
                     }
                     $t ["torrent"] = $tor;
                     $t ["rep"] = parCourBdd ( 0, "/" );
                     $j ["data"] = $t;*/
     } else {
         /*$j['status'] = "NoFichier";
           $j['erreur'] = -1;*/
     }
     $this->set(array("file" => $_FILES, "torrent" => $torrents));
 }
Esempio n. 2
0
}
$userscgi = $argv[1];
$hash = $argv[2];
$base_path = $argv[3];
$base_name = $argv[4];
$is_multi = $argv[5];
$clefunique = $argv[6];
$typemedias = $argv[7];
define('LOG', ROOT . DS . "log" . DS . $userscgi . "_addbibli.log");
\model\simple\Console::println("Début");
\model\simple\Console::println($hash);
\model\simple\Console::println($typemedias);
file_put_contents(ROOT . DS . "log" . DS . $userscgi . "start_addblibli.log", $userscgi . " " . $hash . ' "' . $base_path . '" "' . $base_name . '" ' . $is_multi . " " . $clefunique . " " . $typemedias . "\n", FILE_APPEND);
$filetorrent = \model\xmlrpc\rTorrentSettings::get($userscgi)->session . DS . $hash . ".torrent";
if (file_exists($filetorrent)) {
    $torrent = new \model\simple\Torrent($filetorrent);
    if (!$torrent->errors()) {
        $info = $torrent->info;
        $numfile = 0;
        if (isset($info['files'])) {
            foreach ($info['files'] as $key => $file) {
                $file = $base_path . DS . implode('/', $file['path']);
                \model\simple\Console::println($file);
                switch ($typemedias) {
                    case "film":
                        $torrentf = \model\mysql\Torrentfilm::rechercheParNumFileHashClefunique($numfile, $hash, $clefunique);
                        \model\simple\Console::println(is_bool($torrentf) ? "Non Présent" : "Présent");
                        if (!is_bool($torrentf)) {
                            $mediainfo = new \model\simple\Mediainfo($file);
                            $mediainfo = $mediainfo->getFormatVideo();
                            //$torrentf->mediainfo = json_encode($mediainfo);
Esempio n. 3
0
        }
    }
    if (count($trackers) > 0) {
        $announce_list[] = $trackers;
    }
    $path_edit = trim($request["repertoire"]);
    $piece_size = $request["piece"];
    $callback_log = create_function('$msg', '$fp=fopen("php://stderr","w"); fputs($fp, $msg."\\n"); fclose($fp);');
    $callback_err = create_function('$msg', '$fp=fopen("php://stdout","w"); fputs($fp, $msg."\\n"); fclose($fp);');
    if (count($announce_list) > 0) {
        $torrent = new \model\simple\Torrent($path_edit, $announce_list[0][0], $piece_size, $callback_log, $callback_err);
        if ($trackersCount > 1) {
            $torrent->announce_list($announce_list);
        }
    } else {
        $torrent = new \model\simple\Torrent($path_edit, array(), $piece_size, $callback_log, $callback_err);
    }
    if (isset($request['private'])) {
        $torrent->is_private(true);
    }
    if (isset($request["seed"])) {
        $path_edit = dirname($path_edit);
        //$torrent->save($fname);
        \core\Memcached::value($utilisateur, "torrentfile" . $taskNo, $torrent->__toString(), 60 * 60);
        \model\xmlrpc\rTorrent::sendTorrent($torrent, true, $path_edit);
    } else {
        \core\Memcached::value($utilisateur, "torrentfile" . $taskNo, $torrent->__toString(), 60 * 60);
    }
    exit(0);
}
exit(1);
Esempio n. 4
0
 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)));
 }
<?php

/**
 * Created by PhpStorm.
 * User: salorium
 * Date: 06/07/14
 * Time: 03:03
 */
define('WEBROOT', __DIR__);
define('ROOT', dirname(WEBROOT));
define('DS', DIRECTORY_SEPARATOR);
function __autoload($class_name)
{
    $filename = ROOT . DS . str_replace("\\", DS, $class_name) . ".php";
    if (file_exists($filename)) {
        require_once $filename;
    } else {
    }
}
$path_edit = trim($argv[1]);
$piece_size = "512";
$callback_log = create_function('$msg', '$fp=fopen("php://stderr","w"); fputs($fp, $msg."\\n"); fclose($fp);');
$callback_err = create_function('$msg', '$fp=fopen("php://stdout","w"); fputs($fp, $msg."\\n"); fclose($fp);');
$torrent = new \model\simple\Torrent($path_edit, array(), $piece_size, $callback_log, $callback_err);
$torrent->is_private(true);
\core\Memcached::value("salorium", "torrentfile512", $torrent->__toString(), 60 * 60);