~jdong/ktorrent/ktorrent.debian

« back to all changes in this revision

Viewing changes to plugins/webinterface/httpserver.cpp

  • Committer: John Dong
  • Date: 2006-11-24 05:43:21 UTC
  • mfrom: (946.1.28)
  • Revision ID: john.dong@gmail.com-20061124054321-dnouhtgvqt3k3lc8
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include <kmdcodec.h>
31
31
#include <qsocketnotifier.h>
32
32
#include <kmessagebox.h>
 
33
#include <kstandarddirs.h>
33
34
#include <net/portlist.h>
34
35
 
35
36
#include <sys/mman.h>
87
88
 
88
89
        HttpServer::HttpServer(CoreInterface *core, int port) : QServerSocket(port, 5){
89
90
                php_i=new PhpInterface(core);
90
 
                php_h=new PhpHandler(php_i, WebInterfacePluginSettings::phpExecutablePath());
 
91
                php_h=new PhpHandler(php_i);
91
92
                imgCache.setAutoDelete(true);
92
 
                rootDir=WebInterfacePluginSettings::rootDir();
93
 
                sessionTTL=WebInterfacePluginSettings::sessionTTL();
 
93
                rootDir=QFileInfo(locate("data", "ktorrent/www/login.html")).dirPath();
 
94
                Out(SYS_WEB|LOG_DEBUG) << "WWW Root Directory "<< rootDir <<endl;
94
95
                session.logged=false;
95
96
        }
96
97
        HttpServer::~HttpServer()
249
250
                        session.logged=false;
250
251
 
251
252
                if(headerField.sessionId==session.sessionId){
252
 
                        if(session.last_access.secsTo(QTime::currentTime())<sessionTTL){
 
253
                        if(session.last_access.secsTo(QTime::currentTime())<WebInterfacePluginSettings::sessionTTL()){
253
254
                                Out(SYS_WEB| LOG_DEBUG) << "Session valid" << endl;
254
255
                                session.last_access=QTime::currentTime();
255
256
                                }
320
321
                        QString dataFile;
321
322
                        dataFile=QString(f.readAll().data());
322
323
                        dataFile.truncate(f.size());
323
 
                        if(php_h->executeScript(dataFile, requestParams)){
 
324
                        if(php_h->executeScript(WebInterfacePluginSettings::phpExecutablePath(), dataFile, requestParams)){
324
325
                                header="HTTP/1.1 200 OK\r\n";
325
326
                                header+="Server: ktorrent\r\n";
326
327
                                header+="Cache-Control: private\r\n";
354
355
                                header+=QString("Set-Cookie: SESSID=%1\r\n").arg(session.sessionId);
355
356
                                header+=QString("Date: ")+QDateTime::currentDateTime(Qt::UTC).toString("ddd, dd MMM yyyy hh:mm:ss UTC\r\n");
356
357
                                header+=QString("Last-Modified: ")+finfo.lastModified().toString("ddd, dd MMM yyyy hh:mm:ss UTC\r\n");
357
 
                                header+=QString("Expires: ")+QDateTime::currentDateTime(Qt::UTC).addSecs(sessionTTL).toString("ddd, dd MMM yyyy hh:mm:ss UTC\r\n");
 
358
                                header+=QString("Expires: ")+QDateTime::currentDateTime(Qt::UTC).addSecs(3600).toString("ddd, dd MMM yyyy hh:mm:ss UTC\r\n");
358
359
                                header+="Cache-Control: private\r\n";
359
360
                                header+=QString("Content-Type: image/%1\r\n").arg(finfo.extension());
360
361
                                header+=QString("Content-Length: %1\r\n\r\n").arg(finfo.size());