public function index()
 {
     $this->layout->body_class = '';
     $zip_code = Input::query('zip_code', '');
     $distance = Input::query('distance', '50');
     if (empty($zip_code)) {
         $this->findLocation();
         $zip_code = Session::get('zip_code', '');
     }
     Session::put('zip_code', $zip_code);
     Session::put('distance', $distance);
     $data = array('search_text' => '', 'zip_code' => $zip_code, 'distance' => $distance, 'status' => $this->getStatus(), 'makes' => $this->getPropertiesList(Make::orderBy('make')->get(), 'make'), 'bodies' => $this->getPropertiesList(Body::orderBy('body')->get(), 'body'), 'transmissions' => $this->getPropertiesList(Transmission::orderBy('transmission')->get(), 'transmission'), 'drives' => $this->getPropertiesList(Drive::orderBy('drive')->get(), 'drive'), 'interiors' => $this->getPropertiesList(Interior::orderBy('interior', 'DESC')->take(10)->get(), 'interior'), 'exteriors' => $this->getPropertiesList(Exterior::orderBy('exterior', 'DESC')->take(10)->get(), 'exterior'), 'fuels' => $this->getPropertiesList(Fuel::orderBy('fuel')->get(), 'fuel'), 'doors_count' => $this->getDoorsCounts(), 'cylinders_count' => $this->getCylindersCounts());
     $this->layout->contents = View::make('search/search-advanced', $data);
 }
 public function findSelectedFilter($filters, $aggregations, $transmission_filter)
 {
     if (!empty($transmission_filter)) {
         $values = array();
         $transmission_ranges = explode("-", $transmission_filter);
         foreach ($transmission_ranges as $transmission_range) {
             $transmissions = Transmission::where('id', '=', $transmission_range);
             if ($transmissions->count()) {
                 $title = $transmissions->first()->transmission;
                 array_push($values, array("title" => $title, "index" => 'transmission-remove-' . $transmission_range));
             }
         }
         array_push($filters, array("name" => "Transmission", "values" => $values, "modal" => "transmission"));
     }
     return $filters;
 }
/**
 * deletes data of a transfer
 *
 * @param $transfer name of the transfer
 * @return array
 */
function deleteTransferData($transfer)
{
    global $cfg, $transfers;
    $msgs = array();
    $isTransmissionTorrent = false;
    if ($cfg["transmission_rpc_enable"] == 2 && isHash($transfer)) {
        require_once 'inc/classes/Transmission.class.php';
        $trans = new Transmission();
        require_once 'inc/functions/functions.rpc.transmission.php';
        $theTorrent = getTransmissionTransfer($transfer, array('hashString', 'id', 'name'));
        $isTransmissionTorrent = is_array($theTorrent);
    }
    if ($isTransmissionTorrent) {
        $response = $trans->remove($theTorrent['id'], true);
        if ($response[result] != "success") {
            @error("Delete of torrent failed", "", "", $response[result]);
        }
    } else {
        if ($cfg['isAdmin'] || IsOwner($cfg["user"], getOwner($transfer))) {
            // only torrent
            if (substr($transfer, -8) != ".torrent") {
                return $msgs;
            }
            // delete data
            $datapath = getTransferDatapath($transfer);
            if ($datapath != "" && $datapath != ".") {
                $targetPath = getTransferSavepath($transfer) . $datapath;
                if (tfb_isValidPath($targetPath)) {
                    if (@is_dir($targetPath) || @is_file($targetPath)) {
                        avddelete($targetPath);
                        AuditAction($cfg["constants"]["fm_delete"], $targetPath);
                    }
                } else {
                    $msg = "ILLEGAL DELETE: " . $cfg["user"] . " attempted to delete data of " . $transfer;
                    AuditAction($cfg["constants"]["error"], $msg);
                    array_push($msgs, $msg);
                }
            }
        } else {
            $msg = "ILLEGAL DELETE: " . $cfg["user"] . " attempted to delete data of " . $transfer;
            AuditAction($cfg["constants"]["error"], $msg);
            array_push($msgs, $msg);
        }
    }
    return $msgs;
}
 /**
  * gets current status of one Transfer (realtime)
  * for transferStat popup
  *
  * @return array (stat) or Error String
  */
 function monitorTransfer($transfer, $format = "rpc")
 {
     //by default, monitoring not available.
     // set vars
     $this->_setVarsForTransfer($transfer);
     if (isHash($transfer)) {
         $hash = $transfer;
     } else {
         $hash = getTransferHash($transfer);
     }
     if (empty($hash)) {
         return "Hash for {$transfer} was not found";
     }
     //original rpc format, you can add fields here
     $fields = array('id', 'name', 'status', 'hashString', 'totalSize', 'downloadedEver', 'uploadedEver', 'percentDone', 'uploadRatio', 'peersConnected', 'peersGettingFromUs', 'peersSendingToUs', 'rateDownload', 'rateUpload', 'downloadLimit', 'uploadLimit', 'downloadLimited', 'uploadLimited', 'seedRatioLimit', 'seedRatioMode', 'downloadDir', 'eta', 'error', 'errorString');
     $stat_rpc = getTransmissionTransfer($hash, $fields);
     $rpc = Transmission::getInstance();
     if (is_array($stat_rpc)) {
         if ($format == "rpc") {
             return $stat_rpc;
         } else {
             return $rpc->rpc_to_tf($stat_rpc);
         }
     }
     return $rpc->lastError;
 }
Ejemplo n.º 5
0
 public function removeTorrent($hashString)
 {
     $torrentToRemove = $this->torrentDB->get($hashString);
     if (empty($torrentToRemove)) {
         return array("status" => false, "message" => "This torrent could not be found!");
     } else {
         $userKey = array_search($this->user->username, $torrentToRemove->users);
         if (!is_null($userKey)) {
             $oldSpaceUsed = round($torrentToRemove->totalSize / count($torrentToRemove->users));
             $this->user->spaceUsed -= $oldSpaceUsed;
             unset($torrentToRemove->users[$userKey]);
             $newUserCount = count($torrentToRemove->users);
             if ($newUserCount == 0) {
                 $newSpaceUsed = 0;
             } else {
                 $newSpaceUsed = round($torrentToRemove->totalSize / $newUserCount);
             }
             $this->redistributeTorrentUsersSpace($torrentToRemove, $oldSpaceUsed - $newSpaceUsed);
             $torrentToRemove->userSpace = $newSpaceUsed;
         } else {
             return array("status" => false, "message" => "You are not an owner of this torrent!");
         }
         $this->user->removeTorrent($torrentToRemove);
         $torrentToRemove->updateUsers();
         if (count($torrentToRemove->users) == 0) {
             $transmission = new Transmission(TRANSMISSION_URL, TRANSMISSION_USER, TRANSMISSION_PASS);
             $this->torrentDB->remove($torrentToRemove->hashString);
             $this->fileDB->removeTorrentFiles($torrentToRemove);
             $transmission->remove($torrentToRemove->hashString);
         }
         return array("status" => true, "torrentHash" => $torrentToRemove->hashString);
     }
 }
Ejemplo n.º 6
0
            $content = curl_exec($ch);
            if (!$content) {
                continue;
            }
            $xml = new DOMDocument();
            $xml->loadXML($content);
            $elements = $xml->getElementsByTagName('item');
            foreach ($elements as $item) {
                $link = $item->getElementsByTagName('enclosure')->item(0) != null ? $item->getElementsByTagName('enclosure')->item(0)->getAttribute('url') : $item->getElementsByTagName('link')->item(0)->nodeValue;
                $items[] = array('title' => $item->getElementsByTagName('title')->item(0)->nodeValue, 'link' => $link);
            }
        }
        curl_close($ch);
        return $items;
    }
}
// 配置
$rss = array('http://chdbits.org/torrentrss.php...', 'http://totheglory.im/putrssmc.php...', 'https://hdcmct.org/torrentrss.php...', 'https://open.cd/torrentrss.php?.....', 'https://mv.open.cd/torrentrss.php?..', 'http://hdwing.com/rss.php?..........', 'http://hdtime.org/torrentrss.php?...');
$server = 'http://127.0.0.1';
$port = 9091;
$rpcPath = '/transmission/rpc';
$user = '';
$password = '';
$trans = new Transmission($server, $port, $rpcPath, $user, $password);
$torrents = $trans->getRssItems($rss);
foreach ($torrents as $torrent) {
    $response = json_decode($trans->add($torrent['link']));
    if ($response->result == 'success') {
        printf("%s: success add torrent: %s\n", date('Y-m-d H:i:s'), $torrent['title']);
    }
}
/**
 * get Vuze Global Speed Limit Download
 *
 * @return int
 */
function getTransmissionSpeedLimitDownload($usecache = false)
{
    require_once 'inc/classes/Transmission.class.php';
    $rpc = Transmission::getInstance();
    $key = 'speed-limit-down';
    //"speed-limit-down-enabled"
    $req = $rpc->session_get($key);
    if (is_array($req) && isset($req['arguments'][$key])) {
        return (int) $req['arguments'][$key];
    }
    return 0;
}
Ejemplo n.º 8
0
function updateStatFiles($bShowMissing = false)
{
    global $cfg, $db, $client;
    $rpc = Transmission::getInstance($cfg);
    // check if running and get all session variables in cache
    if (!$rpc->session_get()) {
        echo "unable to connect to transmission-daemon\n";
        return;
    }
    $tfs = $rpc->torrent_get_tf();
    if (empty($tfs)) {
        echo "no loaded torrents\n";
        return;
    }
    $sql = "SELECT hash, transfer, sharekill FROM tf_transfers WHERE type='torrent' AND client = 'transmissionrpc'";
    $hashes = array("''");
    foreach ($tfs as $hash => $t) {
        $hashes[] = "'" . strtolower($hash) . "'";
    }
    $sql .= " AND hash IN (" . implode(',', $hashes) . ")";
    $recordset = $db->Execute($sql);
    $hashes = array();
    $sharekills = array();
    while (list($hash, $transfer, $sharekill) = $recordset->FetchRow()) {
        $hash = strtolower($hash);
        $hashes[$hash] = $transfer;
        $sharekills[$hash] = $sharekill;
    }
    $max_ul = 1024.0 * $cfg['max_upload_rate'];
    $max_dl = 1024.0 * $cfg['max_download_rate'];
    //SHAREKILLS Checks
    $nbUpdate = 0;
    foreach ($tfs as $hash => $t) {
        if (!isset($sharekills[$hash])) {
            continue;
        }
        if (($t['status'] == 8 || $t['status'] == 9) && $t['sharing'] > $sharekills[$hash]) {
            $transfer = $hashes[$hash];
            $nbUpdate++;
            if (stopTransmissionTransferCron($hash)) {
                AuditAction($cfg["constants"]["debug"], $client . ": stop error {$transfer}.");
            } else {
                AuditAction($cfg["constants"]["stop_transfer"], $this->client . "-stat. : sharekill stopped {$transfer}");
                // flag the transfer as stopped (in db)
                stopTransferSettings($transfer);
            }
        }
    }
    echo " stopped {$nbUpdate} torrents.\n";
    $nbUpdate = 0;
    $missing = array();
    foreach ($tfs as $hash => $t) {
        if (!isset($hashes[$hash])) {
            if ($bShowMissing) {
                $missing[$t['rpcid']] = $t['name'];
            }
            continue;
        }
        $transfer = $hashes[$hash];
        //file_put_contents($cfg["path"].'.Transmission/'."updateStatFiles4.log",serialize($t));
        $sf = new StatFile($transfer);
        $sf->running = $t['running'];
        if (empty($sf->transferowner)) {
            $uid = getTransferOwnerID($hash);
            if ($uid > 0) {
                $sf->transferowner = GetUsername($uid);
                echo "transfer '{$transfer}' owner fixed to " . $sf->transferowner . " \n";
                $sf->write();
            }
        }
        if ($sf->running) {
            $sharebase = (int) $sharekills[$hash];
            //$sharekill = (int) round(floatval($t['seedRatioLimit']) * 100);
            if ($sharebase > 0 && (int) $sf->seedlimit == 0) {
                AuditAction($cfg["constants"]["debug"], $client . ": changed empty .stat sharekill " . $sf->seedlimit . " to {$sharebase} (from db), {$transfer}.");
                $sf->seedlimit = $sharebase;
            }
            $max_ul = max($t['urate'], $max_ul);
            $max_dl = max($t['drate'], $max_dl);
            $max_share = max($sharebase, $sharekill);
            if ($t['eta'] > 0 || $t['eta'] < -1) {
                $sf->time_left = convertTimeText($t['eta']);
            }
            $sf->percent_done = $t['percentDone'];
            $sf->sharing = round($t['sharing'], 1);
            if ($t['status'] != 9 && $t['status'] != 5) {
                $sf->peers = $t['peers'];
                $sf->seeds = $t['seeds'];
            }
            if ($t['seeds'] >= 0) {
                $sf->seeds = $t['seeds'];
            }
            if ($t['peers'] >= 0) {
                $sf->peers = $t['peers'];
            }
            if ((double) $t['speedDown'] >= 0.0) {
                $sf->down_speed = formatBytesTokBMBGBTB($t['speedDown']) . "/s";
            }
            if ((double) $t['speedUp'] >= 0.0) {
                $sf->up_speed = formatBytesTokBMBGBTB($t['speedUp']) . "/s";
            }
            if ($t['status'] == 8) {
                $sf->percent_done = 100 + $t['sharing'];
                $sf->down_speed = "&nbsp;";
                if (trim($sf->up_speed) == '') {
                    $sf->up_speed = "&nbsp;";
                }
            }
            if ($t['status'] == 9) {
                $sf->percent_done = 100 + $t['sharing'];
                $sf->up_speed = "&nbsp;";
                $sf->down_speed = "&nbsp;";
            }
        } else {
            //Stopped or finished...
            $sf->down_speed = "";
            $sf->up_speed = "";
            $sf->peers = "";
            $sf->time_left = "0";
            if ($t['eta'] < -1) {
                $sf->time_left = "Done in " . convertTimeText($t['eta']);
            } elseif ($sf->percent_done >= 100 && strpos($sf->time_left, 'Done') === false && strpos($sf->time_left, 'Finished') === false) {
                $sf->percent_done = 100;
                $sf->time_left = "Done!";
            }
            if ($sf->sharing == 0) {
                $sf->sharing = round($t['sharing'], 1);
            }
            if (is_file($cfg["transfer_file_path"] . '/' . $transfer . ".pid")) {
                unlink($cfg["transfer_file_path"] . '/' . $transfer . ".pid");
            }
            //if ($sf->percent_done < 100 && $sf->percent_done > 0)
            //	$sf->percent_done = 0 - $sf->percent_done;
        }
        $sf->downtotal = $t['downTotal'];
        $sf->uptotal = $t['upTotal'];
        if ($sf->size == 0) {
            $sf->size = $t['size'];
        }
        if ($sf->seeds = -1) {
        }
        $sf->seeds = '';
        if ($sf->write()) {
            $nbUpdate++;
        }
    }
    $nb = count($tfs);
    echo " updated {$nbUpdate}/{$nb} stat files.\n";
    //fix globall sharekill to maximum of torrents sharekill, other torrent with lower sharekill will be stopped by this cron
    /*
    if (isset($max_share))  {
    	$sharekill = getTransmissionShareKill();
    	if ($max_share > $sharekill) {
    		//set vuze global sharekill to max sharekill value
    		$rpc->session_set( array('seedRatioLimit' => round($max_share / 100, 2)) );
    		if ($cfg['debuglevel'] > 0) {
    			$msg = $client.": changed vuze global sharekill from $sharekill to $max_share.";
    			AuditAction($cfg["constants"]["debug"], $msg);
    			echo $msg."\n";
    		}
    	}
    }
    if ($max_ul > 0) {
    	$vzmaxul = getTransmissionSpeedLimitUpload();
    	if ($cfg['max_upload_rate'] > 0 && $max_ul > 0) {
    		$max_ul = min($max_ul, 1024.0 * $cfg['max_upload_rate']);
    	}
    	if ($vzmaxul != $max_ul) {
    		$max_ul = $max_ul / 1024;
    		$rpc->session_set( array('speed-limit-up' => $max_ul) );
    		if ($cfg['debuglevel'] > 0) {
    			$msg = $client.": tranmission global speed-limit-up from $vzmaxul to $max_ul.";
    			AuditAction($cfg["constants"]["debug"], $msg);
    			echo $msg."\n";
    		}
    	}
    }
    */
    if ($bShowMissing) {
        return $missing;
    }
}
Ejemplo n.º 9
0
 public function isRunning()
 {
     $instance = Transmission::getInstance();
     $session = $instance->session_get();
     return isset($session['result']) && $session['result'] == 'success';
 }
Ejemplo n.º 10
0
<?php

include 'functions.php';
$showid = addslashes($_GET['showid']);
$season = intval(addslashes($_GET['season']));
$episode = intval(addslashes($_GET['id']));
$getHash = $_GET['getHash'] == '1';
$hash = addslashes($_GET['hash']);
if ($getHash) {
    $show = new Show($showid, NO_EPISODE_CHECK);
    if (count($show->getEpisode($season . 'x' . $episode)->getTorrents()) > 0) {
        //echo json_encode($show->getEpisode($season.'x'.$episode)->getDownloadStatus());
        $torrents = $show->getEpisode($season . 'x' . $episode)->getTorrents();
        echo json_encode($torrents[0]);
        die;
    }
} else {
    $transmission = new Transmission();
    $actualstatus = $transmission->getStatus($hash);
    echo json_encode($actualstatus);
}