Replaced get and post with ajax to prevent XSRF.

Replaced some usages of Console.Writeline with proper logging.
pull/3113/head
Mark McDowall 13 years ago
parent 2cbc78c780
commit 50e91c0043

1
.gitignore vendored

@ -44,3 +44,4 @@ NzbDrone.sln.DotSettings.user*
config.xml config.xml
UpdateLogs/ UpdateLogs/
NzbDrone.Web/MediaCover NzbDrone.Web/MediaCover
NzbDrone.fpr

@ -5,12 +5,14 @@ using System.Linq;
using System.Net; using System.Net;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
public class AutoConfigureProvider public class AutoConfigureProvider
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public SabnzbdInfoModel AutoConfigureSab() public SabnzbdInfoModel AutoConfigureSab()
{ {
@ -88,8 +90,8 @@ namespace NzbDrone.Core.Providers
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine("Failed to get response from: {0}", url); Logger.Trace("Failed to get response from: {0}", url);
Console.WriteLine(ex.Message, ex); Logger.Trace(ex.Message, ex);
} }
return String.Empty; return String.Empty;

@ -3,12 +3,15 @@ using System.Collections.Generic;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text; using System.Text;
using NLog;
using Ninject; using Ninject;
namespace NzbDrone.Core.Providers.Core namespace NzbDrone.Core.Providers.Core
{ {
public class UdpProvider public class UdpProvider
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject] [Inject]
public UdpProvider() public UdpProvider()
{ {
@ -168,7 +171,7 @@ namespace NzbDrone.Core.Providers.Core
catch (Exception exc) catch (Exception exc)
{ {
Console.WriteLine(exc); Logger.TraceException(exc.Message, exc);
return null; return null;
} }
} }

@ -64,9 +64,14 @@ $(window).load(function () {
refreshNotifications(); refreshNotifications();
} }
function refreshNotifications() { function refreshNotifications() {
$.get('/notification/Comet', { message: currentMessage }, notificationCallback); $.ajax({
url: '/notification/Comet',
data: { message: currentMessage },
success: function (data) {
notificationCallback(data);
}
});
} }
function notificationCallback(data) { function notificationCallback(data) {
@ -83,10 +88,6 @@ $(window).load(function () {
} }
//SetupNotifications(); //SetupNotifications();
//DisplayMsg("Scanning Series Folder.");
function displayMsg(sMsg) { function displayMsg(sMsg) {
//set the message text //set the message text
$("#msgText").showHtml(sMsg, 150); $("#msgText").showHtml(sMsg, 150);

@ -20,9 +20,7 @@ $(".masterQualitySelector").live('change', function () {
}); });
$(".addExistingButton").live('click', function () { $(".addExistingButton").live('click', function () {
var root = $(this).parents(".existingSeries"); var root = $(this).parents(".existingSeries");
var title = $(this).siblings(".seriesLookup").val(); var title = $(this).siblings(".seriesLookup").val();
var seriesId = $(this).siblings(".seriesId").val(); var seriesId = $(this).siblings(".seriesId").val();
var qualityId = $(this).siblings(".qualitySelector").val(); var qualityId = $(this).siblings(".qualitySelector").val();
@ -44,16 +42,27 @@ $(".addExistingButton").live('click', function () {
}); });
function reloadExistingSeries() { function reloadExistingSeries() {
$.get(existingSeriesUrl, function (data) { $.ajax({
url: existingSeriesUrl,
success: function( data ) {
$('#existingSeries').html(data); $('#existingSeries').html(data);
}
}); });
} }
//RootDir //RootDir
//Delete RootDir
$('#rootDirs .actionButton img').live('click', function (image) { $('#rootDirs .actionButton img').live('click', function (image) {
var path = $(image.target).attr('id'); var path = $(image.target).attr('id');
$.post(deleteRootDirUrl, { Path: path }, function () {
$.ajax({
type: "POST",
url: deleteRootDirUrl,
data: { Path: path },
success: function () {
refreshRoot(); refreshRoot();
$("#rootDirInput").val('');
}
}); });
}); });
@ -61,20 +70,29 @@ $('#saveDir').live('click', saveRootDir);
function saveRootDir() { function saveRootDir() {
var path = $("#rootDirInput").val(); var path = $("#rootDirInput").val();
if (path) { if (path) {
$.post(saveRootDirUrl, { Path: path }, function () { $.ajax({
type: "POST",
url: saveRootDirUrl,
data: { Path: path },
success: function () {
refreshRoot(); refreshRoot();
$("#rootDirInput").val(''); $("#rootDirInput").val('');
}
}); });
} }
} }
function refreshRoot() { function refreshRoot() {
$.get(rootListUrl, function (data) { $.ajax({
url: rootListUrl,
success: function (data) {
$('#rootDirs').html(data); $('#rootDirs').html(data);
});
reloadAddNew(); reloadAddNew();
reloadExistingSeries(); reloadExistingSeries();
}
});
} }
@ -94,14 +112,16 @@ $('#saveNewSeries').live('click', function () {
}, },
success: function () { success: function () {
$("#newSeriesLookup").val(""); $("#newSeriesLookup").val("");
//$('#newSeriesPath').val("");
} }
}); });
}); });
function reloadAddNew() { function reloadAddNew() {
$.get(addNewUrl, function (data) { $.ajax({
url: addNewUrl,
success: function (data) {
$('#addNewSeries').html(data); $('#addNewSeries').html(data);
}
}); });
} }
@ -121,7 +141,7 @@ $('#quickAddNew').live('click', function () {
}, },
success: function () { success: function () {
$("#newSeriesLookup").val(""); $("#newSeriesLookup").val("");
//$('#newSeriesPath').val(""); $('#newSeriesPath').val("");
} }
}); });
}); });

@ -69,7 +69,6 @@
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: autoConfigureSabUrl, url: autoConfigureSabUrl,
//data: jQuery.param({ username: $('#SabUsername').val(), password: $('#SabPassword').val() }),
error: function (req, status, error) { error: function (req, status, error) {
alert("Sorry! We could not autoconfigure SABnzbd for you"); alert("Sorry! We could not autoconfigure SABnzbd for you");
}, },

Loading…
Cancel
Save