예제 #1
0
CString CPPageWebServer::GetCurWebRoot()
{
	CString WebRoot;
	GetDlgItem(IDC_EDIT2)->GetWindowText(WebRoot);
	WebRoot.Replace('/', '\\');

	CPath path;
	path.Combine(GetMPCDir(), WebRoot);
	return path.IsDirectory() ? (LPCTSTR)path : _T("");
}
예제 #2
0
bool CWebServer::ToLocalPath(CString& path, CString& redir)
{
	if(!path.IsEmpty() && m_webroot.IsDirectory())
	{
		CString str = path;
		str.Replace('/', '\\');
		str.TrimLeft('\\');

		CPath p;
		p.Combine(m_webroot, str);
		p.Canonicalize();

		if(p.IsDirectory())
		{
			CAtlList<CString> sl;
			Explode(AfxGetAppSettings().WebDefIndex, sl, ';');
			POSITION pos = sl.GetHeadPosition();
			while(pos)
			{
				str = sl.GetNext(pos);
				CPath p2 = p;
				p2.Append(str);
				if(p2.FileExists())
				{
					p = p2;
					redir = path;
					if(redir.GetAt(redir.GetLength()-1) != '/') redir += '/';
					redir += str;
					break;
				}
			}
		}

		if(_tcslen(p) > _tcslen(m_webroot) && p.FileExists())
		{
			path = (LPCTSTR)p;
			return true;
		}
	}

	return false;
}