Version: 2.1 (using KDE KDE 3.5.5) Installed from: Ubuntu Packages OS: Linux When clicking the "Remove" button associated with a torrent file through the web interface plugin button links to ".../interface.php?remove=xx" When the "Refresh" link is clicked (with the intention of refreshing the values associated with the torrents such as percentage complete) this action is performed again. This brings about the following behaviour: If there are 3 torrents (A, B and C) listed on the interface.php page and torrent "B" is removed, the page will be loaded with the option "remove=2". The torrents will then appear as a list of torrents "A" and "C". When the page is refreshed, this "remove=2" action is performed again unintentionally - thereby removing torrent "C". This behaviour has been repeated.
You are right we need to get rid of the URL arguments some way
SVN commit 666263 by guisson: Do a 301 redirect in webgui whenever an action is performed via URL args, this ensures that when the user hits refresh in his browser, the same action will not be performed again. BUG: 144619 M +1 -0 httpresponseheader.cpp M +17 -4 httpserver.cpp M +21 -1 php_interface.cpp M +1 -1 php_interface.h --- trunk/extragear/network/ktorrent/plugins/webinterface/httpresponseheader.cpp #666262:666263 @@ -26,6 +26,7 @@ switch (r) { case 200: return "OK"; + case 301: return "Moved Permanently"; case 304: return "Not Modified"; case 404: return "Not Found"; } --- trunk/extragear/network/ktorrent/plugins/webinterface/httpserver.cpp #666262:666263 @@ -300,16 +300,29 @@ else if (ext == "php") { const QMap<QString,QString> & args = url.queryItems(); + bool redirect = false; if (args.count() > 0 && session.logged_in) { - php_i->exec(args); + redirect = php_i->exec(args); } - HttpResponseHeader rhdr(200); - setDefaultResponseHeaders(rhdr,"text/html",true); + if (redirect) + { + HttpResponseHeader rhdr(301); + setDefaultResponseHeaders(rhdr,"text/html",true); + rhdr.setValue("Location",url.path()); + + hdlr->executePHPScript(php_i,rhdr,WebInterfacePluginSettings::phpExecutablePath(), + path,url.queryItems()); + } + else + { + HttpResponseHeader rhdr(200); + setDefaultResponseHeaders(rhdr,"text/html",true); - hdlr->executePHPScript(php_i,rhdr,WebInterfacePluginSettings::phpExecutablePath(), + hdlr->executePHPScript(php_i,rhdr,WebInterfacePluginSettings::phpExecutablePath(), path,url.queryItems()); + } } else { --- trunk/extragear/network/ktorrent/plugins/webinterface/php_interface.cpp #666262:666263 @@ -146,8 +146,9 @@ core=c; } - void PhpActionExec::exec(const QMap<QString, QString> & params) + bool PhpActionExec::exec(const QMap<QString, QString> & params) { + bool ret = false; QMap<QString, QString>::ConstIterator it; for ( it = params.begin(); it != params.end(); ++it ) { @@ -170,15 +171,18 @@ if (Settings::dhtSupport() && !ht.isRunning()) { ht.start(kt::DataDir() + "dht_table",Settings::dhtPort()); + ret = true; } else if (!Settings::dhtSupport() && ht.isRunning()) { ht.stop(); + ret = true; } else if (Settings::dhtSupport() && ht.getPort() != Settings::dhtPort()) { ht.stop(); ht.start(kt::DataDir() + "dht_table",Settings::dhtPort()); + ret = true; } } break; @@ -202,6 +206,7 @@ { Globals::instance().getServer().disableEncryption(); } + ret = true; } break; case 'g': @@ -209,12 +214,14 @@ { Settings::setMaxTotalConnections(it.data().toInt()); PeerManager::setMaxTotalConnections(Settings::maxTotalConnections()); + ret = true; } break; case 'l': if(it.key()=="load_torrent" && it.data().length() > 0) { core->loadSilently(KURL::decode_string(it.data())); + ret = true; } break; case 'm': @@ -222,32 +229,38 @@ { core->setMaxDownloads(it.data().toInt()); Settings::setMaxDownloads(it.data().toInt()); + ret = true; } else if(it.key()=="maximum_seeds") { core->setMaxSeeds(it.data().toInt()); Settings::setMaxSeeds(it.data().toInt()); + ret = true; } else if(it.key()=="maximum_connection_per_torrent") { PeerManager::setMaxConnections(it.data().toInt()); Settings::setMaxConnections(it.data().toInt()); + ret = true; } else if(it.key()=="maximum_upload_rate") { Settings::setMaxUploadRate(it.data().toInt()); core->setMaxUploadSpeed(Settings::maxUploadRate()); net::SocketMonitor::setUploadCap( Settings::maxUploadRate() * 1024); + ret = true; } else if(it.key()=="maximum_download_rate") { Settings::setMaxDownloadRate(it.data().toInt()); core->setMaxDownloadSpeed(Settings::maxDownloadRate()); net::SocketMonitor::setDownloadCap(Settings::maxDownloadRate()*1024); + ret = true; } else if(it.key()=="maximum_share_ratio") { Settings::setMaxRatio(it.data().toInt()); + ret = true; } break; case 'n': @@ -255,6 +268,7 @@ { Settings::setNumUploadSlots(it.data().toInt()); Choker::setNumUploadSlots(Settings::numUploadSlots()); + ret = true; } break; case 'p': @@ -267,12 +281,14 @@ { Settings::setUdpTrackerPort(it.data().toInt()); UDPTrackerSocket::setPort(Settings::udpTrackerPort()); + ret = true; } break; case 'q': if(it.key()=="quit" && !it.data().isEmpty()) { kapp->quit(); + ret = true; } break; case 'r': @@ -284,6 +300,7 @@ if(it.data().toInt()==k) { core->remove((*i), false); + ret = true; break; } } @@ -306,6 +323,7 @@ if(it.data().toInt()==k) { (*i)->stop(true); + ret = true; break; } } @@ -318,6 +336,7 @@ if(it.data().toInt()==k) { (*i)->start(); + ret = true; break; } } @@ -329,6 +348,7 @@ } Settings::writeConfig(); } + return ret; } /************************ --- trunk/extragear/network/ktorrent/plugins/webinterface/php_interface.h #666262:666263 @@ -51,7 +51,7 @@ PhpActionExec(CoreInterface *c); virtual ~PhpActionExec(){}; - void exec(const QMap<QString, QString> & params); + bool exec(const QMap<QString, QString> & params); private: CoreInterface *core; };