Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ruTorrent utility functions #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions discordpush/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
{
$up = Discord::load();
$up->set();
cachedEcho($up->get(),"application/javascript");
CachedEcho::send($up->get(),"application/javascript");
break;
}
case "get":
{
$up = rHistoryData::load();
cachedEcho(safe_json_encode($up->get($_REQUEST['mark'])),"application/json");
CachedEcho::send(JSON::safeEncode($up->get($_REQUEST['mark'])),"application/json");
break;
}
case "delete":
Expand All @@ -35,7 +35,7 @@
}
$up->delete( $hashes );
}
cachedEcho(safe_json_encode($up->get(0)),"application/json");
CachedEcho::send(JSON::safeEncode($up->get(0)),"application/json");
break;
}
}
Expand Down
26 changes: 13 additions & 13 deletions discordpush/discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_once( dirname(__FILE__).'/../../php/cache.php');
require_once( dirname(__FILE__).'/../../php/util.php');
require_once( dirname(__FILE__).'/../../php/settings.php');
eval(getPluginConf('discordpush'));
eval(FileUtil::getPluginConf('discordpush'));

class Discord {

Expand Down Expand Up @@ -42,10 +42,10 @@ public function set()
}
public function get()
{
if (function_exists("safe_json_encode")) {
return("theWebUI.discord = ".safe_json_encode($this->log).";");
if (method_exists('JSON', 'safeEncode')) {
return("theWebUI.discord = ".JSON::safeEncode($this->log).";");
} else {
// We dont really need safe_json_encode here since we dont store any values other than numeric and hash values, but sometimes this throws an error
// We dont really need JSON::safeEncode here since we dont store any values other than numeric and hash values, but sometimes this throws an error
return("theWebUI.discord = ".json_encode($this->log).";");
}
}
Expand All @@ -55,40 +55,40 @@ public function setHandlers()
global $rootPath;
if($this->log["discord_enabled"] && $this->log["discord_addition"])
{
$addCmd = getCmd('execute').'={'.getPHP().','.$rootPath.'/plugins/discordpush/push.php'.',1,$'.
$addCmd = getCmd('execute').'={'.Utility::getPHP().','.$rootPath.'/plugins/discordpush/push.php'.',1,$'.
getCmd('d.get_name').'=,$'.getCmd('d.get_size_bytes').'=,$'.getCmd('d.get_bytes_done').'=,$'.
getCmd('d.get_up_total').'=,$'.getCmd('d.get_ratio').'=,$'.getCmd('d.get_creation_date').'=,$'.
getCmd('d.get_custom').'=addtime,$'.getCmd('d.get_custom').'=seedingtime'.
',"$'.getCmd('t.multicall').'=$'.getCmd('d.get_hash').'=,'.getCmd('t.get_url').'=,'.getCmd('cat').'=#",$'.
getCmd('d.get_custom1')."=,$".getCmd('d.get_custom')."=x-pushbullet,".
getUser().'}';
User::getUser().'}';
}
else
$addCmd = getCmd('cat=');
if($this->log["discord_enabled"] && $this->log["discord_finish"])
$finCmd = getCmd('execute').'={'.getPHP().','.$rootPath.'/plugins/discordpush/push.php'.',2,$'.
$finCmd = getCmd('execute').'={'.Utility::getPHP().','.$rootPath.'/plugins/discordpush/push.php'.',2,$'.
getCmd('d.get_name').'=,$'.getCmd('d.get_size_bytes').'=,$'.getCmd('d.get_bytes_done').'=,$'.
getCmd('d.get_up_total').'=,$'.getCmd('d.get_ratio').'=,$'.getCmd('d.get_creation_date').'=,$'.
getCmd('d.get_custom').'=addtime,$'.getCmd('d.get_custom').'=seedingtime'.
',"$'.getCmd('t.multicall').'=$'.getCmd('d.get_hash').'=,'.getCmd('t.get_url').'=,'.getCmd('cat').'=#",$'.
getCmd('d.get_custom1')."=,$".getCmd('d.get_custom')."=x-pushbullet,".
getUser().'}';
User::getUser().'}';
else
$finCmd = getCmd('cat=');
if($this->log["discord_enabled"] && $this->log["discord_deletion"])
$delCmd = getCmd('execute').'={'.getPHP().','.$rootPath.'/plugins/discordpush/push.php'.',3,$'.
$delCmd = getCmd('execute').'={'.Utility::getPHP().','.$rootPath.'/plugins/discordpush/push.php'.',3,$'.
getCmd('d.get_name').'=,$'.getCmd('d.get_size_bytes').'=,$'.getCmd('d.get_bytes_done').'=,$'.
getCmd('d.get_up_total').'=,$'.getCmd('d.get_ratio').'=,$'.getCmd('d.get_creation_date').'=,$'.
getCmd('d.get_custom').'=addtime,$'.getCmd('d.get_custom').'=seedingtime'.
',"$'.getCmd('t.multicall').'=$'.getCmd('d.get_hash').'=,'.getCmd('t.get_url').'=,'.getCmd('cat').'=#",$'.
getCmd('d.get_custom1')."=,$".getCmd('d.get_custom')."=x-pushbullet,".
getUser().'}';
User::getUser().'}';
else
$delCmd = getCmd('cat=');
$req = new rXMLRPCRequest( array(
rTorrentSettings::get()->getOnInsertCommand( array('tdiscord'.getUser(), $addCmd ) ),
rTorrentSettings::get()->getOnFinishedCommand( array('tdiscord'.getUser(), $finCmd ) ),
rTorrentSettings::get()->getOnEraseCommand( array('tdiscord'.getUser(), $delCmd ) ),
rTorrentSettings::get()->getOnInsertCommand( array('tdiscord'.User::getUser(), $addCmd ) ),
rTorrentSettings::get()->getOnFinishedCommand( array('tdiscord'.User::getUser(), $finCmd ) ),
rTorrentSettings::get()->getOnEraseCommand( array('tdiscord'.User::getUser(), $delCmd ) ),
));
$res = $req->success();
return($res);
Expand Down
6 changes: 3 additions & 3 deletions discordpush/done.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

$req = new rXMLRPCRequest(array(
rTorrentSettings::get()->getOnInsertCommand(array('tdiscord'.getUser(), getCmd('cat='))),
rTorrentSettings::get()->getOnFinishedCommand(array('tdiscord'.getUser(), getCmd('cat='))),
rTorrentSettings::get()->getOnEraseCommand(array('tdiscord'.getUser(), getCmd('cat=')))
rTorrentSettings::get()->getOnInsertCommand(array('tdiscord'.User::getUser(), getCmd('cat='))),
rTorrentSettings::get()->getOnFinishedCommand(array('tdiscord'.User::getUser(), getCmd('cat='))),
rTorrentSettings::get()->getOnEraseCommand(array('tdiscord'.User::getUser(), getCmd('cat=')))
));
$req->run();