#include "StdAfx.h"
#define AZ_LIB_ADDAFX
#include <afxinet.h>
#include <stdio.h>
#include "FileBuffer.h"
#include "FileFunctions.h"
#include "HttpScan.h"
BOOL bProgressMode = FALSE;
DWORD dwHttpRequestFlags =
INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_NO_AUTO_REDIRECT;
const TCHAR szHeaders[] = _T("Accept: text/*/r/nUser-Agent: AZ_HttpScan/r/n");
char *IndexNames[] = { "index.html",
"welcome.html",
"index.htm",
"welcome.htm",
"Index.html",
"Welcome.html",
"Index.htm",
"Welcome.htm",
"INDEX.HTM",
"WELCOME.HTM",
"",
0};
#define MAX_WEBPATH 512
#define WEB_TYPES "htm;html;php;php3;asp;aspx;cgi"
CHttpScan::CHttpScan()
{
dwFileLength=0;
dwAccessType=INTERNET_OPEN_TYPE_DIRECT;
dont_scan.DataLength(sizeof(int));
proc=0;
stop=0;
tick=0;
}
CHttpScan::~CHttpScan()
{
}
LPCSTR CHttpScan::GetPath(LPCSTR Path)
{
xpath=Path;
xpath.Remove('*');
xpath.Remove('?');
return xpath;
}
int CHttpScan::SetMinusFilter(LPCTSTR Filter)
{
int len,anz=0;
char filter[256]="*.";
mfilter.Del();
if(!Filter)return 0;
while(*Filter)
{
len=strchar(Filter,';');
if(len && len<250)
{
strncpy(filter,Filter,len);
filter[len]=0;
mfilter.Add(len,Filter);
filter[len+1]=0;
if(len>4 && !stricmp(filter+len-4,".htm"))
{
filter[len]='l';
mfilter.Add(filter);
filter[len]=0;
}
if(len>5 && !stricmp(filter+len-5,".html"))
{
filter[len-1]=0;
mfilter.Add(filter);
}
anz++;
}
Filter+=len;
if(*Filter)Filter++;
}
return anz;
}
int CHttpScan::SetPlusFilter(LPCTSTR Filter)
{
int len,nr,anz=0;
char *types,*ptr,filter[256]="*.";
pfilter.Del();
if(!Filter || !*Filter)return 0;
while(*Filter)
{
len=strchar(Filter,';');
if(len && len<250)
{
strncpy(filter,Filter,len);
filter[len]=0;
pfilter.Add(len,Filter);
filter[len+1]=0;
if(len>4 && !stricmp(filter+len-4,".htm"))
{
filter[len]='l';
pfilter.Add(filter);
filter[len]=0;
}
if(len>5 && !stricmp(filter+len-5,".html"))
{
filter[len-1]=0;
pfilter.Add(filter);
}
anz++;
}
Filter+=len;
if(*Filter)Filter++;
}
types=WEB_TYPES;
while(*types)
{
len=strcspn(types,";");
memcpy(filter+2,types,len);
filter[len+2]=0;
types+=len;
if(*types)types++;
for(nr=0;nr<pfilter.Count();nr++)
{
ptr=strstr(pfilter[nr],filter+2);
if(!ptr)continue;
if(ptr[len]==0)break;
}
if(nr>=pfilter.Count())pfilter.Add(filter);
}
return anz;
}
int CHttpScan::SetSubFilter(LPCTSTR Filter)
{
if(!Filter || *Filter==0)
{
sfilter="";
sfilter_on=0;
return 0;
}
sfilter=Filter;
AddBackSlash(sfilter);
CheckWebPath(sfilter);
return 1;
}
int CHttpScan::CheckWebPath(CString &Path)
{
int x;
x=IsWebPath(Path);
if(x==2)
{
CString temp;
temp=Path;
Path ="http://";
Path+=temp;
x=1;
}
PathConvert(Path,'/');
return x;
}
int CHttpScan::IsWebPath(const char *Path)
{
if(!strnicmp(Path,"www." ,4))return 2;
if(!strnicmp(Path,"http://",7))return 1;
return 0;
}
int CHttpScan::IsFile(const char *Path)
{
int len,is_web;
is_web=IsWebPath(Path);
if(is_web)
{
len=FilePathLen(Path,3-is_web);
if(!len )return 0;
if(!Path[len])return 0;
len=strlen(Path);
if(!len )return 0;
if(Path[len-1]=='/' )return 0;
if(Path[len-1]=='//')return 0;
}
else{
len=strlen(Path);
if(!len)return 0;
if(Path[len-1]=='/' )return 0;
if(Path[len-1]=='//' )return 0;
if(ExistFile(Path)>=2)return 0;
}
return 1;
}
int CHttpScan::SetLogProc(void (__cdecl *Proc)(void *,const char *,int),void *Param)
{
proc = Proc;
param = Param;
return 1;
}
int CHttpScan::GetFile(LPCTSTR HttpPath,LPCTSTR FilePath,int Test)
{
CString path;
FILE *file;
int nRetCode=0,blen=0,flen=0,pos;
char block[512];
dwFileLength=0;
if(stop)return -2;
GetFilePath(path,FilePath);
DelBackSlash(path);
if(ExistFile(GetPath(path))==1)
{
DeleteFile(GetPath(path));
}
CreatePath(GetPath(path));
path_name = HttpPath;
file=fopen(GetPath(FilePath),"wb");
if(!file)return -1;
CInternetSession session(_T("AZ - Http Grapper"), 1 , dwAccessType);
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
try {
CString strServerName;
CString strObject;
INTERNET_PORT nPort;
DWORD dwServiceType;
if (!AfxParseURL(HttpPath, dwServiceType, strServerName, strObject, nPort) ||
dwServiceType != INTERNET_SERVICE_HTTP)
{
throw 1;
}
if (bProgressMode)
{
VERIFY(session.EnableStatusCallback(TRUE));
}
tick++;
pServer = session.GetHttpConnection(strServerName, nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET,strObject, NULL, 1, NULL, NULL, dwHttpRequestFlags);
pFile->AddRequestHeaders(szHeaders);
pFile->SendRequest();
DWORD dwRet;
pFile->QueryInfoStatusCode(dwRet);
if(dwRet == HTTP_STATUS_DENIED)
{
DWORD dwPrompt;
dwPrompt = pFile->ErrorDlg(NULL, ERROR_INTERNET_INCORRECT_PASSWORD,
FLAGS_ERROR_UI_FLAGS_GENERATE_DATA | FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS, NULL);
if (dwPrompt != ERROR_INTERNET_FORCE_RETRY)
{
throw 1;
}
pFile->SendRequest();
pFile->QueryInfoStatusCode(dwRet);
}
CString strNewLocation;
pFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF, strNewLocation);
if (dwRet == HTTP_STATUS_MOVED ||
dwRet == HTTP_STATUS_REDIRECT ||
dwRet == HTTP_STATUS_REDIRECT_METHOD)
{
CString strNewLocation;
pFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF, strNewLocation);
int nPlace = strNewLocation.Find(_T("Location: "));
if (nPlace == -1)
{
throw 2;
}
strNewLocation = strNewLocation.Mid(nPlace + 10);
nPlace = strNewLocation.Find('/n');
if (nPlace > 0)
strNewLocation = strNewLocation.Left(nPlace);
pFile->Close();
delete pFile;
pServer->Close();
delete pServer;
if (bProgressMode)
{
}
if (!AfxParseURL(strNewLocation, dwServiceType, strServerName, strObject, nPort))
{
throw 2;
}
if (dwServiceType != INTERNET_SERVICE_HTTP)
{
throw 2;
}
pServer = session.GetHttpConnection(strServerName, nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET,
strObject, NULL, 1, NULL, NULL, dwHttpRequestFlags);
pFile->AddRequestHeaders(szHeaders);
pFile->SendRequest();
pFile->QueryInfoStatusCode(dwRet);
if (dwRet != HTTP_STATUS_OK)
{
throw 2;
}
}
TCHAR sz[1024];
int count;
for(;;)
{
if(stop)throw -2;
count=pFile->Read(sz, sizeof(sz));
if(!count)break;
if(!flen && count>8 && !CmpFileType(FilePath,WEB_TYPES))
{
pos=strwlen(sz,0x70,count-8);
if(!strnicmp(sz+pos,"<HTML>",6))throw -3;
}
if(blen<sizeof(block))
{
int i;
i=sizeof(block)-blen;
if(count<i)i=count;
memcpy(block+blen,sz,i);
blen+=i;
}
flen+=count;
fwrite(sz,count,1,file);
dwFileLength=flen;
tick++;
}
pFile->Close();
pServer->Close();
}
catch (CInternetException* pEx)
{
TCHAR szErr[1024];
pEx->GetErrorMessage(szErr, 1024);
if(!Test)
{
error_text=szErr;
error_file=HttpPath;
}
nRetCode = pEx->m_dwError;
pEx->Delete();
}
catch (int pEx)
{
nRetCode = pEx;
if(!Test)
{
if(nRetCode==-3)
error_text.Format("Error: Reciving wrong FileType");
else error_text.Format("Error: Exiting with CTearException(%d)",nRetCode);
error_file=HttpPath;
}
}
if(flen<=0)
{
nRetCode=-1;
if(!Test)
{
error_text.Format("Error: Reviving empty file.");
error_file=HttpPath;
}
}
if (pFile != NULL)delete pFile;
if (pServer != NULL)delete pServer;
session.Close();
fclose(file);
if(nRetCode)
{
RemoveFile(GetPath(FilePath));
}
else{
if(blen>=sizeof(block))blen=sizeof(block)-1;
block[blen]=0;
if(flen<0x20000 && strifind(block,"<HTML>")>=0)
{
char buffer[0x20000];
file=fopen(GetPath(FilePath),"rb");
if(!file)return nRetCode;
fread(buffer,flen,1,file);
fclose(file);
file=fopen(GetPath(FilePath),"wb");
if(!file)return nRetCode;
fprintf(file,"<!-- saved from url=(0039)%s -->/n",HttpPath);
fwrite(buffer,flen,1,file);
fclose(file);
}
}
return nRetCode;
}
int CHttpScan::WritePath(const char *BasePath,
const char *Path,
const char *FileBase,
CFileBuffer *File,
int Sufix)
{
CString path,temp,add;
int len,nr,is_web;
char *file;
path = Path;
is_web = CheckWebPath(path);
len=strcspn(Path,"#&");
if(Path[len])
{
path=path.Left(len);
add =Path+len;
}
if(is_web)
{
len = FilePathLen(path,2);
if(CmpFileType((LPCSTR)path+len,""))
{
len = strlen(path);
if(len && path[len-1]!='/')path+="/";
}
}
is_web |= IsWebPath(BasePath);
if(is_web)
{
PathFullMake(temp,BasePath,path,2);
len = FilePathLen(path,2);
if(CmpFileType((LPCSTR)path+len,""))
{
len = strlen(path);
if(len && path[len-1]!='/')path+="/";
}
}
else{
AddFileName (temp,BasePath,path);
}
len=PathOffset (path,BasePath,temp,2);
PathConvert(path,'/');
if(len<0)
{
path=Path;
add="";
}
else{
if(!len || path[len-1]=='/')
{
GetFilePath(temp,FileBase);
temp+=path;
for(nr=0;IndexNames[nr];nr++)
{
SetFileName(temp,IndexNames[nr]);
if(ExistFile(GetPath(temp)))break;
}
if(!IndexNames[nr])nr=0;
path+=IndexNames[nr];
}
}
if(CmpFileType(path,"htm"))
{
SetFileType(path,"html");
}
file=GetFileName(path);
for(nr=1;IndexNames[nr];nr++)
{
if(stricmp (file,IndexNames[nr]))continue;
SetFileName(path,IndexNames[0]);
break;
}
PathConvert(path,'/');
if(Sufix)File->Write("/"", 1);
File->Write(path);
File->Write(add);
if(Sufix)File->Write("/"", 1);
return len>=0;
}
void CHttpScan::SetAccessType(int iType)
{
int aType[3]={ INTERNET_OPEN_TYPE_PRECONFIG,
INTERNET_OPEN_TYPE_DIRECT,
INTERNET_OPEN_TYPE_PROXY
};
if(iType>=0 && iType<=2)dwAccessType=aType[iType];
}
int CHttpScan::ScanFile(LPCTSTR FilePath,CStringChain *Kette,LPCTSTR OutPath,LPCTSTR BasePath)
{
char *mem,wort[MAX_WEBPATH],zeichen;
int add=0,len;
CTextBuffer in,out;
if(!in.Open(GetPath(FilePath)))return 0;
if(OutPath)
{
if(!out.Open(GetPath(OutPath),CRK_CREATE))return 0;
}
if(!BasePath)BasePath="";
while(in.Text(add,&mem))
{
if(stop)return -1;
for(add=0;mem[add];add++)
{
if(mem[add]=='<')break;
}
out.Write(mem,add);
if(mem[add]!='<')continue;
out.Write(mem+add,1);
in.Text(add+1,&mem);
add=in.TextWord(wort,sizeof(wort));
out.Write(mem,add);
in.Text(add ,&mem);
if(!stricmp(wort,"A"))
{
add=in.TextEmpty(1);
out.Write(mem,add);
in.Text(add,&mem);
add=in.TextWord(wort,sizeof(wort));
out.Write(mem,add);
if(stricmp(wort,"HREF"))continue;
in.Text(add,&mem);
add=in.TextEmpty(1);
out.Write(mem,add);
in.Text(add,&mem);
out.Write(mem,1);
if(*mem!='='){add=1;continue;}
in.Text(1,&mem);
add=in.TextEmpty(1);
in.Text(add,&mem);
if(mem[0]=='/'')
{
add=in.TextString(wort,sizeof(wort),'/'','/'');
}
else{
add=in.TextString(wort,sizeof(wort));
}
if(add)
{
len=strcspnr(wort,"#?&///");
if(len<=0 || wort[len]=='/' || wort[len]=='//')
{
len=strlen(wort);
}
if(len>0)Kette->Add(len,wort);
WritePath(BasePath,wort,FilePath,&out);
continue;
}
add=in.TextEmpty(1);
out.Write(mem,add);
in.Text(add,&mem);
add=strcspn(mem," /t/n/r>");
if(add)
{
Kette->Add(add,mem);
strlcpy(wort,mem,add+1);
WritePath(BasePath,wort,FilePath,&out);
}
continue;
}
if(!stricmp(wort,"IMG" ) ||
!stricmp(wort,"FRAME") )
{
for(add=0;mem[add];add++)
{
if(mem[add]=='>')break;
if(!strnicmp(mem+add,"src",3))break;
}
out.Write(mem,add);
if(strnicmp(mem+add,"src",3))continue;
out.Write(mem+add,3);
in.Text(add+3,&mem);
add=in.TextEmpty(1);
out.Write(mem,add);
in.Text(add,&mem);
if(*mem!='='){add=0;continue;}
out.Write(mem,1);
in.Text(1,&mem);
add=in.TextEmpty(1);
in.Text(add,&mem);
if(mem[0]=='/'')
{
add=in.TextString(wort,sizeof(wort),'/'','/'');
}
else{
add=in.TextString(wort,sizeof(wort));
}
if(add)
{
Kette->Add(wort);
WritePath(BasePath,wort,FilePath,&out);
continue;
}
add=in.TextEmpty(1);
in.Text(add,&mem);
add=strcspn(mem," /t/n/r>");
if(add)
{
Kette->Add(add,mem);
strlcpy(wort,mem,add+1);
WritePath(BasePath,wort,FilePath,&out);
}
continue;
}
if(!stricmp(wort,"META"))
{
add=in.TextEmpty(1);
out.Write(mem,add);
in.Text(add,&mem);
if(strnicmp(mem,"http-equiv",10)){add=0;continue;}
out.Write(mem,10);
in.Text(10,&mem);
add=in.TextChar(&zeichen);
out.Write(mem,add);
in.Text(add,&mem);
add=in.TextString(wort,sizeof(wort));
out.Write(mem,add);
in.Text(add,&mem);
if(zeichen!='=' || stricmp(wort,"refresh")){add=0;continue;}
add=in.TextWord(wort,sizeof(wort));
out.Write(mem,add);
in.Text(add,&mem);
if(zeichen!='=' || stricmp(wort,"content")){add=0;continue;}
add=in.TextChar(&zeichen);
out.Write(mem,add);
in.Text(add,&mem);
if(zeichen!='='){add=0;continue;}
add=in.TextString(wort,sizeof(wort));
in.Text(add,&mem);
for(add=0;wort[add];add++)
{
if(strnicmp (wort+add,"URL",3))continue;
add+=strcspn(wort+add,"=");
if(wort[add]!='=')continue;
add++;
add+=strspn (wort+add," /t/n/r");
len =strcspn(wort+add,"/"/n/r>");
wort[add+len]=0;
Kette->Add(wort+add);
out.Write("/"0; URL=");
WritePath(BasePath,wort+add,FilePath,&out,0);
out.Write("/"");
break;
}
add=0;
continue;
}
add=1;
out.Write(mem,add);
}
out.Close();
in .Close();
return Kette->Count();
}
int CHttpScan::MultiScan(LPCTSTR HttpPath,LPCTSTR FilePath,int Ebene,int Flags,int Start,int End,int Step)
{
char *file;
int nr;
CString path,http;
CStringChain files;
BOOL is_web,is_file,is_type;
FILE *temp;
http = HttpPath;
is_web = CheckWebPath(http);
PathCompress(http);
PathConvert (http,'/');
if(is_web)
{
is_file = IsFile(http);
is_type = CmpFileType(http,"");
if(is_file && is_type)
{
AddBackSlash(http);
PathConvert (http,'/');
is_file=0;
}
}
if(is_web)
{
if(!is_file)return 0;
path =FilePath;
path+=(LPCSTR)http+FilePathLen(http,1);
}
else{
file=GetFileName(http);
is_file=(*file!=0);
if(!is_file)return 0;
path =FilePath;
path+=(LPCSTR)http+FilePathLen(http,2);
}
SetFileName(path,"");
CreatePath (GetPath(path));
SetFileName(path,"HttpScan.tmp.html");
temp=fopen(GetPath(path),"wb");
if(!temp)return 0;
fprintf(temp,"<HTML><BODY>/n");
for(nr=Start;nr<End;nr+=Step)
{
fprintf(temp,"<a href=/"");
fprintf(temp,http,nr);
fprintf(temp,"/">" );
fprintf(temp,http,nr);
fprintf(temp,"</a><br>/n");
}
fprintf(temp,"</HTML></BODY>/n");
fclose(temp);
SetFileName(http,"HttpScan.tmp.html");
return Scan(http,FilePath,Ebene+1,Flags|CHS_TEMPREAD);
}
int CHttpScan::Scan(LPCTSTR HttpPath,LPCTSTR FilePath,int Ebene,int Flags)
{
char *file;
int x,y,nr,anz=0,server_len;
CString path,temp,http,base,save;
CStringChain files;
BOOL is_web=0,is_file,is_lokal=0,is_type;
http = HttpPath;
is_web = CheckWebPath(http);
PathCompress(http);
PathConvert (http,'/');
if(is_web)
{
is_file = IsFile(http);
is_type = CmpFileType(http,"");
if(!is_file || is_type)
{
AddBackSlash(http);
PathConvert (http,'/');
is_file=0;
}
}
if(~Flags&CHS_NEXTTURN)
{
tick=0;
stop=0;
path_name="";
error_text="";
dont_scan.Del();
}
x=dont_scan.FindFast(http,0,-1,1);
if(x!=-1)
{
if(dont_scan.GetData(x)>=Ebene)return 0;
}
if(Flags&CHS_DEBUG)
if(CmpFileType(http,WEB_TYPES))
{
path = "Soll die Datei:/n";
path += HttpPath;
path += "/ngesannt werden ?";
x =MessageBox(0,path,"HttpScann",MB_YESNOCANCEL|MB_ICONQUESTION);
if(x==IDNO){x=1000;dont_scan.Add(HttpPath,CSC_END,&x);return 0;}
if(x==IDCANCEL){Break();return -1;}
}
if(Ebene<0)return 0;
if(is_web)
{
if(!is_file)
{
path =FilePath;
path+=(LPCSTR)http+FilePathLen(http,1);
AddBackSlash(path);
x=FilePathLen(path,2);
y=FilePathLen(path);
path+=IndexNames[0];
nr=(y>x)? -1:0;
if(dont_scan.FindFast(path,0,-1,1)!=-1)return 0;
for(;;nr++)
{
if(nr>=0 && !IndexNames[nr])break;
if(stop)return -1;
if(nr>=0)SetFileName(http,IndexNames[nr]);
save=GetPath (path);
if(ExistFile (save)==1)
if(LenghtFile(save)> 0)is_lokal=1;
if(~Flags&CHS_TEMPREAD)
if( Flags&CHS_NEWREAD)
if(CmpFileType(path,WEB_TYPES))
{
is_lokal=0;
}
if(is_lokal)break;
int err=GetFile(http,path,(IndexNames[nr+1])? 1:0);
if(!err)break;
if( err==12007)Break();
}
if(!IndexNames[nr])
{
SetFileName(http,IndexNames[0]);
if(proc)proc(param,http,CHS_ERR_NOTFOUND);
return 0;
}
}
else{
path =FilePath;
path+=(LPCSTR)http+FilePathLen(http,1);
if(dont_scan.FindFast(path,0,-1,1)!=-1)return 0;
file=GetFileName(path);
for(nr=1;IndexNames[nr];nr++)
{
if(stricmp (file,IndexNames[nr]))continue;
SetFileName(path,IndexNames[0]);
break;
}
if(CmpFileType(path,"htm"))
{
SetFileType(path,"html");
}
save=GetPath (path);
if(ExistFile (save)==1)
if(LenghtFile(save)>0)is_lokal=1;
if(~Flags&CHS_TEMPREAD)
if( Flags&CHS_NEWREAD)
if(CmpFileType(path,WEB_TYPES))
{
is_lokal=0;
}
if(!is_lokal)
if(GetFile(http,path))
{
if(proc)proc(param,http,CHS_ERR_NOTFOUND);
return 0;
}
}
}
if(!is_web)
{
save=GetPath(http);
if(ExistFile(save)>=2)
{
AddBackSlash(http);
}
file=GetFileName(http);
is_file=(*file!=0);
if(!is_file)
{
path =FilePath;
path+=(LPCSTR)http+FilePathLen(http,2);
path+=IndexNames[0];
PathConvert(path,'/');
GetFilePath(temp,path);
CreatePath (GetPath(temp));
for(nr=0;IndexNames[nr];nr++)
{
if(stop)return -1;
SetFileName(http,IndexNames[nr]);
save =GetPath(path);
if(ExistFile (save)==1)
if(LenghtFile(save)> 0)
{
is_lokal=1;break;
}
if(CopyFile(GetPath(http),save,0))break;
}
if(!IndexNames[nr])
{
SetFileName(http,IndexNames[0]);
if(proc)proc(param,http,CHS_ERR_NOTFOUND);
return 0;
}
}
else{
path = FilePath;
path += (LPCSTR)http+FilePathLen(http,1);
PathConvert(path,'/');
GetFilePath(temp,path);
CreatePath (GetPath(temp));
save=GetPath(path);
if(ExistFile(save)==1)is_lokal=1;
else if(!CopyFile(GetPath(http),save,0))
{
if(proc)proc(param,http,CHS_ERR_NOTFOUND);
return 0;
}
}
}
if(proc)proc(param,http,(is_lokal)? CHS_OK_LOKAL:CHS_OK);
if(!CmpFileType(path,WEB_TYPES))
{
return 1;
}
if(Ebene<=0)return 0;
dont_scan.Add(http,CSC_ABCG,&Ebene);
dont_scan.Add(path,CSC_ABCG,&Ebene);
temp =path;
temp+=".tmp";
base=http;
SubFileName (base);
AddBackSlash(base);
PathConvert (base,'/');
if(!(Flags&CHS_NEXTTURN) ||
(Flags&CHS_NEWLOCAL))
{
path_base=base;
Flags&=~CHS_NEWLOCAL;
}
ScanFile(path,&files,temp,base);
save=GetPath(temp);
if(ExistFile(save)==1)
{
if(LenghtFile(save)>0)
{
RemoveFile(save);
MoveFile (GetPath(temp),save);
}
else{
RemoveFile(save);
}
}
server_len =FilePathLen(path_base,2);
for(x=0;x<files.Count();x++)
{
if(stop)break;
path=files[x];
is_lokal=1;
is_web=CheckWebPath(path);
if(!is_web)
{
PathFullMake(temp,base,path,2);
path=temp;
}
PathCompress(path);
PathConvert (path,'/');
file=GetFileName (path);
if(~Flags&CHS_TEMPREAD)
if( Flags&CHS_LOKAL)
{
if(strnicmp(path,path_base,path_base.GetLength()))
{
if(proc)proc(param,path,CHS_ERR_LOCAL);
continue;
}
}
if(~Flags&CHS_TEMPREAD)
if( Flags&CHS_SERVER)
{
if(strnicmp(path,path_base,server_len))
{
if(proc)proc(param,path,CHS_ERR_SERVER);
continue;
}
}
if(~Flags&CHS_TEMPREAD)
if( Flags&CHS_SUBFILTER && sfilter_on)
{
if(strnicmp(path,sfilter,sfilter.GetLength()))
{
if(proc)proc(param,path,CHS_ERR_SUBFILTER);
continue;
}
}
if(*file && pfilter.Count())
{
for(y=0;y<pfilter.Count();y++)
{
if(!memxcmp(pfilter[y],file,strlen(file),1))break;
}
if(y>=pfilter.Count())
{
if(proc)proc(param,path,CHS_ERR_PLUS);
continue;
}
}
if(*file && mfilter.Count())
{
for(y=0;y<mfilter.Count();y++)
{
if(!memxcmp(mfilter[y],file,strlen(file),1))break;
}
if(y<mfilter.Count())
{
if(proc)proc(param,path,CHS_ERR_MINUS);
continue;
}
}
if(Flags&CHS_LOKAL)Flags&=~CHS_LOKALNEXT;
if(Flags&CHS_TEMPREAD)
{
anz+=Scan(path,FilePath,Ebene-1,Flags&~CHS_TEMPREAD);
}
else if(Flags&CHS_LOKALNEXT)
{
Flags|=CHS_LOKAL;
temp=path_base;
anz+=Scan(path,FilePath,Ebene-1,Flags|CHS_NEXTTURN|CHS_LOKAL|CHS_NEWLOCAL);
path_base=temp;
}
else{
anz+=Scan(path,FilePath,Ebene-1,Flags|CHS_NEXTTURN);
}
}
return anz;
}
|
|
|
|
HttpScan
|
|
anonymous
07-07-02 09:02:58
|
|
Networking
|