for the file "Upload.cpp" modify "Upload::initUpload()" and recompile, the mod is only a few lines
see "/////////// THIS IS THE MOD!!!!"
Code:
void Upload::initUpload()
{
StringManipulation sm(_data);
if(_data.substr(0,3) != "GET")
{
setState(Closed);
return;
}
std::string::size_type idx = sm.to_lower().find("/get/");
if(idx == std::string::npos)
{
_socket->close();
setState(Closed);
return;
}
idx += 5;
std::string::size_type idx2 = _data.find("/", idx);
if(idx == std::string::npos)
{
_socket->close();
setState(Closed);
return;
}
std::string sindex = _data.substr(idx, idx2-idx);
std::strstream a;
a << sindex << std::ends;
a >> index;
idx = sm.to_lower().find(" http", idx2);
if(idx == std::string::npos)
{
_socket->close();
setState(Closed);
return;
}
filename = _data.substr(idx2+1, idx-idx2-1);
/////////// THIS IS THE MOD!!!!
// keep this BS off my screen
if( (idx = sm.to_lower().find("bearshare")) != std::string::npos )
{
_socket->close();
setState(Closed);
return;
}
if( (idx = sm.to_lower().find("user-agent:")) != std::string::npos )
{
idx = _data.find_first_not_of(" ", idx+11);
idx2 = _data.find("\r\n", idx);
client = _data.substr(idx, idx2-idx);
}
else
client = "";
if( (idx = sm.to_lower().find("range:")) != std::string::npos )
{
idx = _data.find_first_of("1234567890", idx+6);
idx2 = _data.find("-", idx);
std::string srange_start = _data.substr(idx, idx2-idx);
std::strstream c;
c << srange_start << std::ends;
c >> range_start;
idx = _data.find("\r\n", idx2);
std::string s = _data.substr(idx2, idx - idx2 - 1);
// if( (idx = _data.find_first_of("0123456789", idx2+1)) != std::string::npos )
if( (idx = s.find_first_of("0123456789")) != std::string::npos )
{
idx2 = s.find_first_not_of("0123456789", idx);
std::string srange_end = s.substr(idx, idx2 - idx - 1);
std::strstream b;
b << srange_end << std::ends;
b >> range_end;
}
else range_end = 0;
}
else
{
range_start = 0;
range_end = 0;
}
if(index < _parent->_parent->vSharedFiles.size())
if( _parent->_parent->vSharedFiles[index]->file == filename )
{
_parent->_parent->vSharedFiles[index]->requests++;
std::strstream str;
str << _parent->_parent->vSharedFiles[index]->requests << std::ends;
_parent->_parent->vSharedFiles[index]->item->setText(2, str.str());
str.freeze(false);
}
if(_parent->numberUploads() >= _parent->_parent->ui_spinbox_maxuploads->value())
{
std::strstream str;
std::string s;
str << "HTTP/1.0 503 Busy\r\nServer: Qtella " << VERSION << "\r\n\r\n" << std::ends;
s = str.str();
str.freeze(false);
_socket->writeBlock(s.c_str(), s.size());
_socket->close();
_state = Busy;
return;
}
//
std::string f = _parent->_parent->vSharedFiles[index]->directory;
if(f.size() > 0) if( f[f.size()-1] != '/' ) f += '/';
f += _parent->_parent->vSharedFiles[index]->file;
item = new QListViewItem(_parent->_parent->ui_listview_uploads, _parent->_parent->vSharedFiles[index]->file.c_str());
item->setText(2, _socket->peerAddress().toString());
_file.setName(f.c_str());
if( !_file.exists() )
{
std::string s;
s = "HTTP/1.0 404 NOT FOUND\r\nServer: Qtella "+std::string(VERSION)+"\r\n\r\n";
_socket->writeBlock(s.data(), s.size());
_socket->close();
setState(NotFound);
return;
}
setState(Connected);
if(range_end == 0) range_end = _file.size() - 1;
_towrite = range_end - range_start + 1;
std::string s("HTTP/1.0 200 OK\r\nContent-Length: ");
std::strstream str;
str << _file.size() << std::ends; // must be file.size() !!
s += std::string(str.str());
str.freeze(false);
s += std::string("\r\nContent-Type: application/binary\r\nServer: Qtella "+std::string(VERSION)+"\r\n\r\n");
_socket->writeBlock(s.c_str(), s.size());
if( !_file.open(IO_ReadOnly|IO_Raw) )
{
setState(Error);
_socket->close();
return;
}
_file.at(range_start);
_written = 0;
}