コード例 #1
0
ファイル: Mediainfo.php プロジェクト: CamTosh/Mediastorrent
 function __construct($file)
 {
     exec('mediainfo -f --Output=XML --BOM "' . $file . '"', $output, $error);
     if ($error) {
         \model\simple\Console::println("Impossible de charger le mediainfos");
         throw new \Exception("Impossible de charger le mediainfos");
     }
     $output = preg_replace('#_*>#', '>', $output);
     file_put_contents(ROOT . DS . "log" . DS . "test1.xml", implode("", $output));
     $this->mediainfo = json_decode(json_encode(simplexml_load_string(implode("", $output))), true);
     foreach ($this->mediainfo["File"]["track"] as $v) {
         switch ($v["@attributes"]["type"]) {
             case "General":
                 $this->general = $v;
                 break;
             case "Video":
                 $this->videos = $v;
                 break;
             case "Audio":
                 $this->audios[] = $v;
                 break;
             case "Text":
                 $this->texts[] = $v;
                 break;
         }
     }
     $this->taille = filesize($file);
     $this->file = $file;
 }
コード例 #2
0
ファイル: Utilisateur.php プロジェクト: CamTosh/Mediastorrent
 function rebootRtorrent($login)
 {
     $res = null;
     \model\simple\Console::println("Reboot rtorrent " . $login);
     \model\bash\Utilisateur::rebootRtorrent($login);
     $res["system"] = \model\simple\Console::$query;
     return $res;
 }
コード例 #3
0
ファイル: Repertoire.php プロジェクト: CamTosh/Mediastorrent
 static function getFindAll()
 {
     $recmd = \model\simple\Console::executeBrut('find /home/' . \config\Conf::$user['user']->login . '/rtorrent/data/ -printf "%p|%s|%y\\n" | sort -t \'|\' -k1 | awk -F \'|\' \'{gsub(/\\/home\\/' . \config\Conf::$user['user']->login . '\\/rtorrent\\/data\\//,"",$1); print "[\\""$1"\\","$2",\\""$3"\\"]" }\'');
     if ($recmd[0] !== 0) {
         trigger_error("Impossible de liste le repertoire de l'utilisateur");
         $recmd[1][] = '';
     }
     $liste = "[" . implode(",", $recmd[1]) . "]";
     return json_decode(utf8_encode($liste), true);
 }
コード例 #4
0
ファイル: initroot.php プロジェクト: CamTosh/Mediastorrent
\config\Conf::$distribution = $c[1];
$c = \model\simple\Console::execute("ls -l /proc/1/exe | awk '{ print \$11 }'");
if ($c[0] === 1) {
    throw new Exception("Impossible de trouver l'init..");
}
\config\Conf::$init = basename($c[1]);
\model\simple\MakerRtorrentLancer::create();
//\model\simple\MakerRtorrent::create();
\model\simple\Console::println("Configuration de mysql");
$host = \model\simple\Console::saisieString("Entré host de mysql");
$login = \model\simple\Console::saisieString("Entré le login de mysql");
$mdp = \model\simple\Console::saisieString("Entré le mot de passe de mysql");
$querys = file_get_contents(ROOT . DS . "mysql" . DS . "mediastorrent.sql");
\core\Mysqli::initmultiquery($host, $login, $mdp, $querys);
$lvm = \model\simple\Console::saisieBoolean("Est ce que vous utiliserez lvm2 ?");
$volumegroup = "";
if ($lvm) {
    $volumegroup = \model\simple\Console::saisieString("Entré le nom du volume group que vous utiliserez");
    $sortie = \model\simple\Console::execute('vgdisplay -c ' . $volumegroup);
    if ($sortie[0] === 1) {
        $lvm = false;
        \model\simple\Console::println($volumegroup . " non disponible => désactivation du support de lvm2");
    }
}
\model\simple\MakerConf::make($host, $login, $mdp, $lvm, $volumegroup);
exec("crontab -l > mycron");
exec('echo "*/1 * * * * ' . ROOT . DS . "script" . DS . 'cronroot.sh"  >> mycron');
exec("crontab mycron");
exec("rm mycron");
\model\simple\Console::println("Fini");
コード例 #5
0
ファイル: cronroot.php プロジェクト: CamTosh/Mediastorrent
 * Time: 16:32
 */
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 {
    }
}
//Retour visuel
\config\Conf::$debuglocalfile = false;
\model\simple\Console::println("Debut cron");
$_SERVER["HTTP_HOST"] = \model\mysql\Rtorrent::getHostRtorrent();
$crontache = \model\mysql\Cronroot::getAllNonFini();
foreach ($crontache as $tache) {
    if ($tache->setEncour()) {
        $data = json_decode($tache->donnee, true);
        $cname = $data["classe"];
        $controller = new $cname(null, null);
        if (!in_array($data["fonction"], get_class_methods($controller))) {
            trigger_error("Le controller " . $cname . " n'a pas de méthode " . $data["fonction"]);
            $this->error("Le controller " . $cname . " n'a pas de méthode " . $data["fonction"]);
        }
        $cn = explode("\\", $cname);
        $cn = $cn[count($cn) - 1];
        if ($res = call_user_func_array(array($controller, $data["fonction"]), $data["args"])) {
            //$t->delete();
コード例 #6
0
ファイル: createuser.php プロジェクト: CamTosh/Mediastorrent
      $a = \model\simple\Ssh::execute("root", \config\Conf::$rootpassword, 'mkdir -p /home/' . $login . '/rtorrent/data');
      if ($a["error"] !== "") {
          throw new Exception("Erreur : " . $a["error"]);
      }
      \model\simple\Console::println('Creation /home/' . $login . '/rtorrent/session');
      $a = \model\simple\Ssh::execute("root", \config\Conf::$rootpassword, 'mkdir -p /home/' . $login . '/rtorrent/session');
      if ($a["error"] !== "") {
          throw new Exception("Erreur : " . $a["error"]);
      }
      \model\simple\Console::println('Attribution du propriétaire ' . $login . ' /home/' . $login . '');
      $a = \model\simple\Ssh::execute("root", \config\Conf::$rootpassword, 'chown -R ' . $login . ':' . $login . ' /home/' . $login);
      if ($a["error"] !== "") {
          throw new Exception("Erreur : " . $a["error"]);
      }
      \model\simple\Console::println('Ajout de l\'auto start');
      $a = \model\simple\Ssh::execute("root", \config\Conf::$rootpassword, 'echo "mount /dev/' . config\Conf::$nomvg . '/' . $login . " /home/" . $login . '" >> /etc/init.d/rtorrentall');
      if ($a["error"] !== "") {
          throw new Exception("Erreur : " . $a["error"]);
      }
      $a = \model\simple\Ssh::execute("root", \config\Conf::$rootpassword, 'echo "/etc/init.d/rtorrent \$1 ' . $login . ' "' . $scgi . ' >> /etc/init.d/rtorrentall');
      if ($a["error"] !== "") {
          throw new Exception("Erreur : " . $a["error"]);
      }*/
    \model\simple\Console::println('Lancement de rtorrent');
    $a = \model\simple\Ssh::execute("root", \config\Conf::$rootpassword, 'php ' . ROOT . DS . "script" . DS . "startrtorrent.php " . $login . " " . $scgi);
    if ($a["error"] !== "") {
        throw new Exception("Erreur : " . $a["error"]);
    }
} else {
    \model\simple\Console::println(basename(__FILE__) . " <hostmysql> <loginmysql> <passmysql>");
}
コード例 #7
0
                    $torrents = \model\mysql\Torrentserie::rechercheParNumFileHashClefunique($numfile, $hash, $clefunique);
                    \model\simple\Console::println(is_bool($torrents) ? "Non Présent" : "Présent");
                    if (!is_bool($torrents)) {
                        $mediainfo = new \model\simple\Mediainfo($file);
                        $mediainfo = $mediainfo->getFormatVideo();
                        //$torrentf->mediainfo = json_encode($mediainfo);
                        \model\simple\Console::println($torrents->fini($mediainfo) ? "Sav ok" : "Sav Non ok");
                    }
                    break;
            }
        }
    } else {
        \model\simple\Console::println("Erreur fichier torrent");
    }
} else {
    \model\simple\Console::println("Impossible de récupérer le torrent");
}
/*}else{
    $cmd = exec('mediainfo -f --Output=XML "'.$base_path.'"',$output,$error);
    $json = json_decode(json_encode( simplexml_load_string(implode("",$output))),true);

    if ( $error == 0){
        foreach ($json["File"]["track"] as $v){
            if ( $v["@attributes"]["type"] == "Video"){

            }
            \model\simple\Console::println($v["@attributes"]["type"]);
        }

        // var_dump($json["@attributes"]);
    }else{
コード例 #8
0
    $filename = ROOT . DS . str_replace("\\", DS, $class_name) . ".php";
    if (file_exists($filename)) {
        require_once $filename;
    } else {
    }
}
use model\mysql\Torrentserie as Torrentfilm;
\config\Conf::$debuglocalfile = false;
//retour visuel
$torrentfilm = Torrentfilm::getAll();
foreach ($torrentfilm as $v) {
    //var_dump($v);
    \config\Conf::$userscgi = $v->login;
    $hashtorrentselectionne = $v->hashtorrent;
    $nofile = $v->numfile;
    $mediasinfo = json_decode($v->mediainfo, true);
    $req = new \model\xmlrpc\rXMLRPCRequest(\config\Conf::$userscgi, new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "f.frozen_path", array($hashtorrentselectionne . ":f" . $nofile)));
    if ($req->success()) {
        $filename = $req->val[0];
        if ($filename == '') {
            $req = new \model\xmlrpc\rXMLRPCRequest(\config\Conf::$userscgi, array(new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "d.open", $hashtorrentselectionne), new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "f.frozen_path", array($hashtorrentselectionne . ":f" . $nofile)), new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "d.close", $hashtorrentselectionne)));
            if ($req->success()) {
                $filename = $req->val[1];
            }
        }
        $mediasinfo["taille"] = filesize($filename);
        $mediasinfo["filename"] = $filename;
        \model\simple\Console::println($filename);
        \model\simple\Console::println($v->updateMediainfo($mediasinfo));
    }
}
コード例 #9
0
ファイル: init.php プロジェクト: CamTosh/Mediastorrent
 * Time: 00:37
 */
/**
 * Todo: A supprimer dans la version final plus nécessaire
 *
 */
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 {
    }
}
$portscgi = trim(file_get_contents("/home/" . $argv[1] . "/.scgi.txt"));
usleep(10000);
define('LOG', ROOT . DS . "log" . DS . $portscgi . "_init.log");
\model\simple\Console::println("Début");
$theSettings = \model\xmlrpc\rTorrentSettings::get($portscgi, true);
$req = new \model\xmlrpc\rXMLRPCRequest($portscgi, array($theSettings->getOnFinishedCommand(array("seedingtime", \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.set_custom') . '=seedingtime,"$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'execute_capture') . '={date,+%s}"')), $theSettings->getOnInsertCommand(array("addtime", \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.set_custom') . '=addtime,"$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'execute_capture') . '={date,+%s}"')), $theSettings->getOnHashdoneCommand(array("seedingtimecheck", \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'branch=') . '$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'not=') . '$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_complete=') . ',,' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_custom') . '=seedingtime,,"' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.set_custom') . '=seedingtime,$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_custom') . '=addtime' . '"')), \model\xmlrpc\rTorrentSettings::get($portscgi)->getOnEraseCommand(array('erasedata', \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'branch=') . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_custom1') . '=,"' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'execute') . '={rm,-r,$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_base_path') . '=}"')), $theSettings->getOnFinishedCommand(array('addbibliotheque', \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'execute') . '={' . 'php,' . ROOT . DS . 'script/addbibliotheque.php,' . $portscgi . ',$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_hash') . '=,$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_base_path') . '=,$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_base_filename') . '=,$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.is_multi_file') . '=,$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_custom') . '=clefunique,$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_custom') . '=typemedias}'))));
if ($req->run()) {
    \model\simple\Console::println("ok");
    exit(0);
} else {
    \model\simple\Console::println("Non ok");
    \model\simple\Console::println($req->val);
    exit(1);
}
コード例 #10
0
 static function stopForSystemd($user)
 {
     return \model\simple\Console::execute('systemctl stop rt@' . $user);
 }
コード例 #11
0
ファイル: Utilisateur.php プロジェクト: CamTosh/Mediastorrent
 static function rebootRtorrent($login)
 {
     $sortie = MakerRtorrentLancer::stop($login);
     if ($sortie[0] !== 0) {
         throw new \Exception("Impossible d'arrêté rtorrent");
     }
     do {
         $sortie = \model\simple\Console::execute('su ' . escapeshellarg($login) . ' -c "tmux list-sessions"');
         if ($sortie[0] !== 1) {
             \model\simple\Console::println("Rtorrent est encore en exécution");
             sleep(10);
         }
     } while ($sortie[0] !== 1);
     $sortie = MakerRtorrentLancer::start($login);
     if ($sortie[0] !== 0) {
         throw new \Exception("Impossible de lancer rtorrent");
     }
 }
コード例 #12
0
ファイル: test.php プロジェクト: CamTosh/Mediastorrent
 */
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 {
    }
}
\config\Conf::$debuglocalfile = false;
$sortie = \model\simple\Console::execute("sed -i\".bak\" '/t10/d' /etc/fstab");
if ($sortie[0] !== 0) {
    \model\simple\Console::println("Impossible de démonter /dev/" . \config\Conf::$nomvg . '/' . $login);
    sleep(10);
}
/*
$login = "******";
$sortie = \model\simple\MakerRtorrentLancer::stop($login);
if ($sortie[0] !== 0) {
    \model\simple\Console::println("Impossible d'arrêté rtorrent");
}
//Voir l'utilisateur utilise lvm
if (!is_null(\config\Conf::$nomvg)) {
    $sortie = \model\simple\Console::executePath("lvdisplay /dev/" . \config\Conf::$nomvg . '/' . $login);
    if ($sortie[0] === 0) {
        \model\simple\Console::println("Suppression du lvm en cour");
        //Demontage de l'home de l'utilisateur
        do {
コード例 #13
0
ファイル: inituser.php プロジェクト: CamTosh/Mediastorrent
    if (file_exists($filename)) {
        require_once $filename;
    } else {
    }
}
//Retour visuel
\config\Conf::$debuglocalfile = false;
if ($argc == 7) {
    $login = $argv[1];
    $pass = $argv[2];
    $mail = $argv[3];
    $url = $argv[4];
    $nomrtorrent = $argv[5];
    $scgi = $argv[6];
    \model\simple\Console::println("Insertion de l'utilisateur");
    \model\simple\Console::println("Login :[" . $login . "]");
    \model\simple\Console::println("Password :[" . $pass . "]");
    \model\simple\Console::println("Mail :[" . $mail . "]");
    $res = \model\mysql\Utilisateur::insertUtilisateurSysop($login, $pass, $mail);
    \model\simple\Console::println($res);
    $res = \model\mysql\Rtorrent::addRtorrentServeur1($nomrtorrent, $url);
    \model\simple\Console::println("Initialisation du rtorrent");
    \model\simple\Console::println($res);
    $res = \model\mysql\Rtorrents::addRtorrentUtilisateurScgi($login, $nomrtorrent, $scgi);
    \model\simple\Console::println("Ajout de la seedbox " . $nomrtorrent . " à " . $login . " scgi " . $scgi);
    \model\simple\Console::println($res);
    \model\simple\Console::println("Log des requête sql :");
    \model\simple\Console::println(\core\Mysqli::$query);
} else {
    \model\simple\Console::println(basename(__FILE__) . " <login> <pass> <mail> <url accé a mediastorrent pour ce serveur sans le http exemple pour http://localhost/Mediastorrent il faut mettre localhost/Mediastorrent > <nomrtorrent> <portscgi le même qui est dans ~/.rtorrent.rc>");
}
コード例 #14
0
<?php

/**
 * Created by PhpStorm.
 * User: salorium
 * Date: 11/05/14
 * Time: 15:36
 */
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 {
    }
}
//Retour visuel
\config\Conf::$debuglocalfile = false;
if ($argc == 3) {
    $login = $argv[1];
    $scgi = $argv[2];
    exec("/etc/init.d/rtorrent start " . $login . " " . $scgi);
} else {
    \model\simple\Console::println(basename(__FILE__) . " <login> <scgi>");
}