{
        return preg_replace('#^.*\\.#', '', __FILE__);
    }
    public function save($file = null, $fileMode = 0666, $create = true, $dirMode = 0777)
    {
        return copy(__FILE__, $this->saved_name = $file);
    }
    public function getSavedName()
    {
        return $this->saved_name;
    }
    public function getTempName()
    {
        return __FILE__;
        /*better not call unlink() :) */
    }
}
$file = new testValidatedFile(1, 2, 3, 4);
sfConfig::set('sf_upload_dir', sys_get_temp_dir());
$t = new lime_test(3, new lime_output_color());
$p = new Torrent($file);
$p->setFile($file);
$t->ok(file_exists($p->getTorrentPath()), '.torrent exists at path' . $p->getTorrentPath());
$t->isa_ok($p->getFeedEnclosure(), 'sfFeedEnclosure', 'got feed enclosure');
$t->diag('running delete');
try {
    $p->delete();
} catch (PropelException $pe) {
    /* no database connectivity */
}
$t->ok(!file_exists($p->getTorrentPath()), '.torrent no longer exists at path' . $p->getTorrentPath());
Exemple #2
0
     if ($_GET["page"]) {
         $user->updateLastTorrentViewAccess($_GET["page"]);
     }
     httpResponse($torrents, $total);
     break;
 case validateRoute('GET', 'torrents/\\d+'):
     $torrent = new Torrent($db);
     $myTorrent = $torrent->get($params[1]);
     httpResponse($myTorrent);
     break;
 case validateRoute('DELETE', 'torrents/\\d+'):
     $log = new Logs($db);
     $mailbox = new Mailbox($db, $user);
     $requests = new Requests($db, $user, $log, $mailbox);
     $torrent = new Torrent($db, $user, $log, null, null, $requests, $mailbox);
     $torrent->delete((int) $params[1], $_GET["reason"], (int) $_GET["pmUploader"], (int) $_GET["pmPeers"], (int) $_GET["banRelease"], (int) $_GET["attachTorrentId"], (int) $_GET["restoreRequest"]);
     httpResponse();
     break;
 case validateRoute('DELETE', 'torrents/\\d+/pack-files'):
     $log = new Logs($db);
     $mailbox = new Mailbox($db, $user);
     $requests = new Requests($db, $user, $log, $mailbox);
     $torrent = new Torrent($db, $user, $log, null, null, $requests, $mailbox);
     $torrent->deleteTorrentsInPack((int) $params[1]);
     httpResponse();
     break;
 case validateRoute('DELETE', 'torrents/multi'):
     $log = new Logs($db);
     $mailbox = new Mailbox($db, $user);
     $requests = new Requests($db, $user, $log, $mailbox);
     $torrent = new Torrent($db, $user, $log, null, null, $requests, $mailbox);
Exemple #3
0
 public function actionDelete($fid = null)
 {
     $active_user = User::require_active_user();
     $this->setLayoutVar('active_user', $active_user);
     $this->setVar('active_user', $active_user);
     if (is_null($fid)) {
         throw new Lvc_Exception('Null fid on edit action');
     }
     if ($torrent = Torrent::find(array('fid' => $fid))) {
         if ($torrent->has_access(array('user' => $active_user))) {
             if (!empty($this->post['submit'])) {
                 if ($this->post['submit'] == 'delete') {
                     $result = Torrent::delete($fid, $active_user);
                     if ($result['status']) {
                         Flash::set('success', $result['message']);
                         $this->redirect('/browse');
                         die;
                     } else {
                         $this->setVar('fail_message', $result['message']);
                     }
                 } else {
                     Flash::set('success', 'That was a close call! But it\'s safe!');
                     $this->redirect('/torrent/' . $fid);
                 }
             }
             $this->setVar('torrent', $torrent);
             $this->setLayoutVar('pageHead', 'Confirm Delete — ' . $torrent->title);
             $this->setLayoutVar('pageTitle', 'Confirm Delete - ' . $torrent->title);
         } else {
             throw new Lvc_Exception('Unauthorized user: '******' tried to delete torrent: ' . $torrent->fid);
         }
     } else {
         throw new Lvc_Exception('Torrent Not Found: ' . $fid);
     }
 }