Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Gyran/Transweb
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: nip3o/Transweb
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Jul 21, 2012

  1. Very basic API auth handling

    nip3o committed Jul 21, 2012
    Copy the full SHA
    d760223 View commit details
Showing with 20 additions and 12 deletions.
  1. +3 −1 config/config.php
  2. +17 −11 php/rpcconnection.php
4 changes: 3 additions & 1 deletion config/config.php
Original file line number Diff line number Diff line change
@@ -14,4 +14,6 @@

define( 'COOKIES_FILE' , dirname( __FILE__ ) . '/../settings/cookies' );

?>
define( 'AUTH_SECRET', '' );

?>
28 changes: 17 additions & 11 deletions php/rpcconnection.php
Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@
require_once( dirname( __FILE__ ) . '/classes/TransmissionRPC.class.php' );
require_once( dirname( __FILE__ ) . '/classes/CookiesManager.class.php' );

$defaultTorrentFields = array(
$defaultTorrentFields = array(
"addedDate", "name", "status", "doneDate", "haveValid", "totalSize", "uploadRatio",
"rateDownload", "rateUpload", "percentDone", "fileStats", "totalSize", "eta",
"downloadedEver", "leftUntilDone", "status", "hashString", "downloadDir", "trackerStats", "error",
"uploadedEver"
);

$torrentDetailsFields = array(
$torrentDetailsFields = array(
"addedDate", "name", "status", "doneDate", "haveValid", "totalSize", "uploadRatio",
"dateCreated", "pieceCount", "pieceSize", "comment", "doneDate",
"downloadedEver", "leftUntilDone", "status", "id", "hashString", "downloadDir", "hashString",
@@ -25,6 +25,12 @@
"files", "fileStats"
);

if(isset(AUTH_SECRET) && AUTH_SECRET != '') {
if(AUTH_SECRET != $_POST["secret"]) {
die('Invalid secret');
}
}

try {
$rpc = new TransmissionRPC( TRANSMISSION_RPC_URL, TRANSMISSION_RPC_USERNAME, TRANSMISSION_RPC_PASSWORD );
} catch ( Exception $e ) {
@@ -49,7 +55,7 @@
} else {
echo formatResponse( true, $result->arguments );
}

break;
case 'addTorrentURL':
$inUrl = $_POST["url"];
@@ -71,7 +77,7 @@
if ( $result->result != "success" ) {
echo formatResponse( false, null, $result->result );
} else {
echo formatResponse( true, $result->arguments );
echo formatResponse( true, $result->arguments );
}

break;
@@ -81,7 +87,7 @@
if ( $result->result != "success" ) {
echo formatResponse( false, null, $result->result );
} else {
echo formatResponse( true, $result->arguments );
echo formatResponse( true, $result->arguments );
}
break;
case 'stopTorrents':
@@ -90,7 +96,7 @@
if ( $result->result != "success" ) {
echo formatResponse( false, null, $result->result );
} else {
echo formatResponse( true, $result->arguments );
echo formatResponse( true, $result->arguments );
}
break;
case 'getTorrentDetails':
@@ -99,7 +105,7 @@
if ( $result->result != "success" ) {
echo formatResponse( false, null, $result->result );
} else {
echo formatResponse( true, $result->arguments );
echo formatResponse( true, $result->arguments );
}
break;
case 'getTorrentFiles':
@@ -108,7 +114,7 @@
if ( $result->result != "success" ) {
echo formatResponse( false, null, $result->result );
} else {
echo formatResponse( true, $result->arguments );
echo formatResponse( true, $result->arguments );
}
break;
case 'deleteTorrentsAndFiles':
@@ -117,7 +123,7 @@
if ( $result->result != "success" ) {
echo formatResponse( false, null, $result->result );
} else {
echo formatResponse( true, $result->arguments );
echo formatResponse( true, $result->arguments );
}
break;
case 'setFilePriority':
@@ -136,7 +142,7 @@

}



break;
default:
@@ -161,4 +167,4 @@ function formatResponse ( $success, $arguments = null, $message = "" ) {
}


?>
?>