Inkwatercolor functions
//////////////////////////////////////////////////////////////////////////////
// FILE : ink.tol
// AUTHOR : http://www.asolver.com
// PURPOSE : Inkwatercolor functions
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Real InkPageInfo(Real eng,
Text infFil,
Set yeaRep)
//////////////////////////////////////////////////////////////////////////////
{
Text outFil = Replace(infFil, If(eng, "/sede/", "/seds"),
If(eng, "/page/", "/pags/"));
Text seeFil = PagSee(eng)+"/"+PagSeeInf(eng);
Text frmFil = PagSee(eng)+"/feefrm.htm"; // Common feedback forms
Text infTxt = ReadFile(infFil);
Text seeTxt = ReadFile(seeFil);
Text frmTxt = ReadFile(frmFil);
//Text WriteLn("see "+seeFil+" + inf "+infFil+" -> "+outFil);
Text infTit = TxtBetween2Tag(infTxt, "<title>", "</title>", TRUE);
Text infBdy = TxtBetween2Tag(infTxt, "<body>", "</body>", FALSE);
// Keywords ink are 3 chars and must appears
Text h12Whi = Replace(infBdy,">","> "); // Put white space
Text h1Txt = TxtInside2Tag(h12Whi, "<h1>", "</h1>"); // All h1
Text h2Txt = TxtInside2Tag(h12Whi, "<h2>", "</h2>"); // All h2
Text infKey = Set2TxtKeyword([[infTit, h1Txt, h2Txt]], 2, TRUE); // Ordered
Text newHtm = ReplaceTable(seeTxt,
[[ [[ "_TIT_", infTit]],
[[ "_CNT_", infBdy]],
[[ "_FRM_", frmTxt]],
[[ "MET.KEY", infKey]]
]] << yeaRep
<< ctrTab);
Text filWri = WriteFile(outFil, newHtm);
TRUE
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Create and writes an information page for inkwatercolor.com.",
InkPageInfo);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Real InkLogsStats(Real topMax)
//////////////////////////////////////////////////////////////////////////////
{
Real wcFun(Text tag)
{
Text wctFil = "ctr/wc.txt";
Text cmd =
"\asc\Bin\unix\bin\grep "+Char(34)+tag+Char(34)+" ctr/log"/*.log | "+
"\asc\Bin\unix\bin\wc -l > "+wctFil;
Real sys = System(cmd);
Text txt = Compact(ReadFile(wctFil));
Real cnt = Eval(txt+"; ");
Text WriteLn(tag+" = "+FormatReal(cnt,"%.0lf"));
cnt
};
Real wcUsr(Text fil, Text chr)
{
Text wctFil = "ctr/wc.txt";
Text cmd =
"\asc\Bin\unix\bin\cut -c "+chr+" ctr/log/"+fil+" | "+
"\asc\Bin\unix\bin\sort -u | "+
"\asc\Bin\unix\bin\wc -l > "+wctFil;
Real sys = System(cmd);
Text txt = Compact(ReadFile(wctFil));
Real cnt = Eval(txt+"; ");
Text Write("."/*+FormatReal(cnt,"%.0lf")*/);
cnt
};
Set wcCic(Text gal, Real max)
{
Set set = For(1, max, Set(Real pos)
{
Text nam = FormatReal(pos,"%04.0lf");
Text tag = gal+nam+".jpg HTTP";
Real cnt = wcFun(tag);
CtrSt(nam, cnt)
});
Set srt = Sort(set, Real(Set a, Set b) { Compare(b[2], a[2])});
Text WriteLn("BSTFile("+gal+")...");
Set wri = BSTFile(srt, "ctr/img."+gal+".bst");
srt
};
Text WriteLn(PdbSep+"\ngrep | wc...");
Real homCnt = wcFun("/ HTTP"); // home www.inkwatercolor.com
Real hmlCnt = wcFun(".html HTTP"); // index.html + indice.html
Real homTot = homCnt + hmlCnt; // home
Real htmCnt = wcFun(".htm HTTP"); // information + picture pages
Real pagTot = homTot + htmCnt; // all pages
Real ppsCnt = wcFun(".pps HTTP"); // Power points
Real pdfCnt = wcFun(".pdf HTTP"); // Pdf documents
Real xmlCnt = wcFun(".xml HTTP"); // sitemap.xml
Real dwnTot = ppsCnt + pdfCnt + xmlCnt; // all download
Real jpgCnt = wcFun(".jpg HTTP"); // all images tiny+zoom+download
Real zooChp = wcFun("GET /chppho/image/zoom/");
Real zooFle = wcFun("GET /fleurs/image/zoom/");
Real zooArm = wcFun("GET /inarmy/image/zoom/");
Real zooCnt = zooChp + zooFle + zooArm;
Real tinChp = wcFun("GET /chppho/image/tiny/");
Real tinFle = wcFun("GET /fleurs/image/tiny/");
Real tinArm = wcFun("GET /inarmy/image/tiny/");
Real tinCnt = tinChp + tinFle + tinArm;
Real a34Cnt = jpgCnt-zooCnt-tinCnt; // donwload A3 and A4
Real chpTot = zooChp + tinChp + a34Cnt;
Real fleTot = zooFle + tinFle;
Real slowDo = If(ctrExe=="st1",
{
Text WriteLn(PdbSep+"\nCount for each image (slow)...");
Set chpSet = wcCic("chppho", 230); // Chppho images from 1 to 230
Set fleSet = wcCic("fleurs", 128); // Fleurs images from 1 to 128
Set armSet = wcCic("inarmy", 34); // In army images from 1 to 34
Card(chpSet)+Card(fleSet)+Card(armSet)
},
{
Text WriteLn("Do not count for each image (use st1 to count)");
FALSE
});
Text WriteLn(PdbSep+"\nunique visitors...");
Real robCnt = wcFun("robots.txt HTTP"); // Crawlers: robots.txt
Text usrFil = "ctr/usr.bdt";
Text WriteFile(usrFil, "Weekly;UniqueUsers;\n");
Set ipuFil = GetDir("ctr/log")[1];
Set ipuSet = EvalSet(ipuFil, Real(Text filNam)
{
// inkwater20030707.log
// 123456789.123456789.
Text yeaTxt = Sub(filNam, 9,12);
Text mthTxt = Sub(filNam,13,14);
Text dayTxt = Sub(filNam,15,16);
Text dteAns = yeaTxt+"/"+mthTxt+"/"+dayTxt;
Text dteTol = "y"+yeaTxt+"m"+mthTxt+"d"+dayTxt;
Date dteDte = Eval(dteTol+"; ");
Real dteWee = WeekDay(dteDte);
Real dteChk = If(EQ(dteWee,1), TRUE,
{
Text WriteLn(filNam+" "+dteTol+" is not Monday");
FALSE
});
Real usrCnt =
If(filNam<="inkwater20071126.log", // Change Bitmailer->Serenet
wcUsr(filNam, "1-15"), // unique IP = visitors Bitmailer
wcUsr(filNam, "1-37")); // unique IP = visitors Sarenet
Text AppendFile(usrFil, dteAns+";"+FormatReal(usrCnt,"%.0lf")+";\n");
usrCnt
});
Real ipuCrd = Card(ipuSet); // Count log files
Real ipuTot = SetSum(ipuSet); // All unique users
// Last 52 weeks
Real ipuL52 = SetSum(For(ipuCrd-51, ipuCrd, Real(Real p) {ipuSet[p]}));
Text WriteLn("\nunique IPs = "+FormatReal(ipuTot,"%.0lf"));
Text WriteLn(PdbSep+"\ndir sizes...");
Real txtSiz =
{
Real cssSiz = DirUsage("web", "*.css", FALSE);
Real scrSiz = DirUsage("web", "*.js", FALSE);
Real htmSiz = DirUsage("web", "*.htm", FALSE);
Real hmlSiz = DirUsage("web", "*.html",FALSE);
Real xmlSiz = DirUsage("web", "*.xml", FALSE);
(cssSiz+scrSiz+htmSiz+hmlSiz+xmlSiz)/1024
};
Real binSiz =
{
Real gifSiz = DirUsage("web", "*.gif", FALSE);
Real tinChp = DirUsage("web/chppho/image/tiny","*.jpg", FALSE);
Real zooChp = DirUsage("web/chppho/image/zoom","*.jpg", FALSE);
Real tinFle = DirUsage("web/fleurs/image/tiny","*.jpg", FALSE);
Real zooFle = DirUsage("web/fleurs/image/zoom","*.jpg", FALSE);
Real tinArm = DirUsage("web/inarmy/image/tiny","*.jpg", FALSE);
Real zooArm = DirUsage("web/inarmy/image/zoom","*.jpg", FALSE);
Real dwnSiz = DirUsage("web/download", "*.*", FALSE);
Real binSiz = (gifSiz+
tinChp+zooChp+
tinFle+zooFle+
tinArm+zooArm+
dwnSiz)/1024
};
Real totSiz = txtSiz+binSiz;
Text WriteLn(PdbSep+"\nreading top pic list...");
Set topPicInc = Include("ctr/img.chppho.bst");
Set topPicCic = For(1, topMax, Text(Real pos)
{
Set lin = topPicInc[pos];
Real picNum = Eval(lin[1]+"; ");
Text picTxt = PagNumInt(picNum, FALSE);
"<a href='sadzoo"+lin[1]+".htm'>"+picTxt+"</a> " +
"("+FormatReal(lin[2],"%.0lf")+")"
});
Text topPicLst = Set2Txt(topPicCic, "", "", ", ", " & ", "", "", "", "");
Text WriteLn(PdbSep+"\ndates...");
Date dteIni = y2003m07d07;
Date dteEnd = Today;
Real dteDay = Card(Dates(C, dteIni, dteEnd));
Real dteWee = dteDay/7;
Real dteYea = dteDay/365;
Text WriteLn(PdbSep+"\nbuilding control and stats...");
Text ctrTxt = Set2Txt(
[[
[["CTR.INI", dteIni ]],
[["CTR.END", dteEnd ]],
[["CTR.YEA", FormatReal(dteYea,"%.2lf") ]],
[["CTR.PAG", pagTot ]],
[["CTR.HOM", homTot ]],
[["CTR.HTM", htmCnt ]],
[["CTR.VIS", ipuTot ]],
[["CTR.V52", ipuL52 ]],
[["CTR.V/W", FormatReal(ipuTot/dteWee,"%.0lf") ]],
[["CTR.V/L", FormatReal(ipuL52/52,"%.0lf") ]],
[["CTR.DWN", dwnTot ]],
[["CTR.PDF", pdfCnt ]],
[["CTR.PPS", ppsCnt ]],
[["CTR.XML", xmlCnt ]],
[["CTR.ROB", robCnt ]],
[["CTR.IMG", jpgCnt ]],
[["CTR.TIN", tinCnt ]],
[["CTR.ZOO", zooCnt ]],
[["CTR.A34", a34Cnt ]],
[["CTR.CHP", chpTot ]],
[["CTR.FLE", fleTot ]],
[["CTR.P/V", FormatReal(pagTot/ipuTot,"%.2lf") ]],
[["CTR.I/V", FormatReal(jpgCnt/ipuTot,"%.2lf") ]],
[["CTR.P/W", FormatReal(pagTot/dteWee,"%.0lf") ]],
[["CTR.SIZ", totSiz ]],
[["CTR.SIA", txtSiz ]],
[["CTR.SIB", binSiz ]],
[["CTR.TOP", FormatReal(topMax,"%.0lf") ]],
[["CTR.TIM", topPicLst ]]
]],
"\n [[ ", " ]]", ", ", ", ",
Char(34), Char(34)+"%.0lf"+Char(34), Char(34), "%c%Y/%m/%d");
Text WriteFile("ctr/ctr.tol", "Set ctrTab = "+ctrTxt+";\n\n");
TRUE
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Create and writes TOL code with the results of the statistical analysys of
inkwatercolor.com Apache logs.",
InkLogsStats);
//////////////////////////////////////////////////////////////////////////////
Ink.Watercolor construye las páginas del sitio web inkwatercolor.com
2015 asolver.com | Aviso legal | XHTML | Δ Θ Ξ | Creative Commons | Mapa y funciones del sitio