diff --git a/ap/app/goahead/server/page.c b/ap/app/goahead/server/page.c
new file mode 100755
index 0000000..b5d7bf8
--- /dev/null
+++ b/ap/app/goahead/server/page.c
@@ -0,0 +1,219 @@
+#include "wsIntrn.h"
+#include <sys/stat.h> 
+#include <unistd.h>
+#ifdef _USE_WEBUI_ZIP
+#include "unzip.h"
+#define WEB_ZIP_PATH "etc_ro/web.zip"
+#define WEB_ZIP_PATH_HEAD "web/"
+#endif
+
+int websPageOpen(webs_t wp, char_t *lpath, char_t *path, int mode, int perm)
+{
+	a_assert(websValid(wp));
+
+#ifdef WEBS_PAGE_ROM
+	return websRomPageOpen(wp, path, mode, perm);
+#else
+#ifdef _USE_WEBUI_ZIP
+	char *filename = strstr(lpath,WEB_ZIP_PATH_HEAD);
+	if(filename != NULL)
+	{
+		unzFile uzFile = unzOpen(WEB_ZIP_PATH);
+		if(unzLocateFile(uzFile,filename,0) == UNZ_OK
+			&& unzOpenCurrentFile(uzFile) == UNZ_OK)
+		{
+			wp->docfd = uzFile;
+		}
+		else
+		{
+			unzClose(uzFile);
+			wp->docfd = -1;
+		}
+		return wp->docfd;
+	}
+	else
+	{
+		printf("[zpr]erropen %s\n", lpath);
+	}
+#endif
+	//printf("[httpshare]lpath->%s\n",lpath);
+
+	if(strstr(lpath,"/mmc2") != NULL)
+	{
+#if 0  // cov M
+		unsigned long filesize = -1; 
+#else
+        long filesize = -1; 
+#endif
+		struct stat statbuff;	
+		
+		if(stat(lpath, &statbuff) < 0)
+		{	 
+		   return filesize;    
+	    }
+		else
+		{	 
+	 	   filesize = statbuff.st_size;    
+	    }
+		
+		printf("[httpshare]websPageOpen:size->%d\n", filesize);
+
+#if 0	 // cov M	
+		if(filesize<2*1024*1024*1024)
+		{
+			return (wp->docfd = gopen(lpath, mode, perm));
+		}
+		else
+			return -1;
+#else
+		if(filesize > 0 && filesize <= LONG_MAX-1)
+		{
+			return (wp->docfd = gopen(lpath, mode, perm));
+		}
+		else
+			return -1;
+
+#endif
+	}
+
+	return (wp->docfd = gopen(lpath, mode, perm));
+#endif /* WEBS_PAGE_ROM */
+}
+
+void websPageClose(webs_t wp)
+{
+	a_assert(websValid(wp));
+
+#ifdef WEBS_PAGE_ROM
+	websRomPageClose(wp->docfd);
+#else
+#ifdef _USE_WEBUI_ZIP
+	if(wp->docfd > 0 && wp->lpath != NULL && strstr(wp->lpath,WEB_ZIP_PATH_HEAD) != NULL)
+	{
+		unzCloseCurrentFile(wp->docfd);
+		unzClose(wp->docfd);
+		wp->docfd = -1;
+		return;
+	}
+#endif	
+	if (wp->docfd >= 0) {
+		close(wp->docfd);
+		wp->docfd = -1;
+		//printf("[httpsahre]lpath->%s,path->%s\n",wp->lpath,wp->path);
+		if(strstr(wp->path,"/mmc2") != NULL)
+		{
+			zte_del_download_file();		
+		}
+	}
+#endif
+}
+
+int websPageStat(webs_t wp, char_t *lpath, char_t *path, websStatType* sbuf)
+{
+	if(lpath == NULL)
+		return -1;
+#ifdef WEBS_PAGE_ROM
+	return websRomPageStat(path, sbuf);
+#else
+#ifdef _USE_WEBUI_ZIP
+	if(strstr(lpath,WEB_ZIP_PATH_HEAD) != NULL)
+	{
+		unz_file_info file_info = {0};
+		if(unzGetCurrentFileInfo(wp->docfd, &file_info, NULL, 0, NULL, 0, NULL, 0)< 0)
+		{
+			printf("[webzip]errStat %s\n", lpath);
+			return -1;
+		}
+		sbuf->size = file_info.uncompressed_size;
+		sbuf->mtime = file_info.dosDate;
+		sbuf->isDir = websPageIsDirectory(lpath);
+		return 0;
+	}
+#endif
+	gstat_t	s;
+
+	if (gstat(lpath, &s) < 0) {
+		return -1;
+	}
+	sbuf->size = s.st_size;
+	sbuf->mtime = s.st_mtime;
+	sbuf->isDir = s.st_mode & S_IFDIR;
+	return 0;
+#endif
+}
+
+int websPageIsDirectory(char_t *lpath)
+{
+	if(lpath == NULL)
+		return 0;
+#ifdef WEBS_PAGE_ROM
+	websStatType	sbuf;
+
+	if (websRomPageStat(lpath, &sbuf) >= 0) {
+		return(sbuf.isDir);
+	} else {
+		return 0;
+	}
+#else
+#ifdef _USE_WEBUI_ZIP
+	if(strstr(lpath,WEB_ZIP_PATH_HEAD) != NULL)
+	{
+		char *p = lpath;
+		int is_dir = 0;
+		while ((*p) != '\0') {
+			p++;
+		}
+		p--;
+
+		if (((*p) == '/') || ((*p) == '\\')) {
+			is_dir = 1;
+		}
+		return is_dir;
+	}
+#endif
+	gstat_t sbuf;
+
+	if (gstat(lpath, &sbuf) >= 0) {
+		return(sbuf.st_mode & S_IFDIR);
+	} else {
+		return 0;
+	}
+#endif
+}
+
+int websPageReadData(webs_t wp, char *buf, int nBytes)
+{
+	a_assert(websValid(wp));
+#ifdef WEBS_PAGE_ROM
+	return websRomPageReadData(wp, buf, nBytes);
+#else
+#ifdef _USE_WEBUI_ZIP
+	if(wp->lpath != NULL && strstr(wp->lpath,WEB_ZIP_PATH_HEAD) != NULL)
+	{
+		return unzReadCurrentFile(wp->docfd, buf, nBytes);
+	}
+#endif
+	return read(wp->docfd, buf, nBytes);
+#endif
+}
+
+void websPageSeek(webs_t wp, long offset)
+{
+	a_assert(websValid(wp));
+#ifdef WEBS_PAGE_ROM
+	websRomPageSeek(wp, offset, SEEK_CUR);
+#else
+#ifdef _USE_WEBUI_ZIP
+	if(wp->lpath != NULL && strstr(wp->lpath,WEB_ZIP_PATH_HEAD) != NULL)
+	{
+		printf("[webzip]seek %s\n",wp->lpath);
+		return;
+	}
+#endif
+	if(lseek(wp->docfd, offset, SEEK_CUR) < 0)
+	{
+		return;	    
+	}
+#endif
+}
+
