2007-06-18

 
// blgr
// MIME.js と bmail.exe が必要
//ISO-2022-JP
//include
var jsc = "../jscriptcommon/MIME.js";
eval(Include(jsc)); // Include()はスクリプトの一番下で定義↓
var streamname = 'ブログのネタファイル「==__」で区切る最後は
「==__」';
var bmailexe = './bmail.exe';
var bupf = '更新時バックアップファイル 更新されると
「==__」は「=---」となり、次は更新されない';

var s = WScript.CreateObject("WScript.Shell");
var fs = new ActiveXObject("Scripting.FileSystemObject");
var re = new RegExp("^==__$", "ig")
var l = '';
var sta = new Array;
var filel = new Array;
var subl = new Array;
var fl = 0;
var d = new Date();
var datstr = '';
var dgmonth = '';
var dgdate = '';
var dghours = '';
var dgminutes = '';
var dgseconds = '';
if (d.getMonth() < dgmonth =" '0'" dgmonth =" d.getMonth();
if (d.getDate() < dgdate =" '0'" dgdate =" d.getDate();
if (d.getHours() < dghours =" '0'" dghours =" d.getHours();
if (d.getMinutes() < dgminutes =" '0'" dgminutes =" d.getMinutes();
if (d.getSeconds() < dgseconds =" '0'" dgseconds =" d.getSeconds();
datstr = datstr + d.getYear() + dgmonth + dgdate + dghours + dgminutes + dgseconds;
//WScript.Echo(datstr + "\n");

//ファイル読み込み、処理
var rf = fs.OpenTextFile(streamname,1,false);
var il = 0;
var lf = 0;
var wfb = '';
var ln = 0;

while ( !rf.AtEndOfStream ) {
l = rf.ReadLine();
if ( l.match(re) ) {
lf = 1;
il++;
filen = 'b' + datstr + il;
filel[il-1] = filen;
if (fl == 0) {
wfb = fs.OpenTextFile(filen,2,-1);
wfb.Write("Content-Type: text/plain; charset=ISO-2022-JP" + "\n");
wfb.Write("Mime-Version: 1.0" + "\n");
wfb.Write("Content-Transfer-Encoding: 7bit" + "\n");
wfb.Write("\n");
} else if (fl == 1) {
wfb.Close();
wfb = fs.OpenTextFile(filen,2,-1);
wfb.Write("Content-Type: text/plain; charset=ISO-2022-JP" + "\n");
wfb.Write("Mime-Version: 1.0" + "\n");
wfb.Write("Content-Transfer-Encoding: 7bit" + "\n");
wfb.Write("\n");
}
fl = 1;
ln = 0;
} else if (fl == 1) {
// WScript.Echo(l);
if (ln <>
if (lf == 1) subl[il-1] = '=?ISO-2022-JP?B?' + base64encode(l) + '?=';
wfb.Write(l + "\n");
lf = 0;
} else {
;
}
ln++;
}
}
rf.Close();
if (wfb) wfb.Close();

fl = 0;
var trf = '';
var st = '';
var cmdl = WScript.CreateObject("WScript.Shell");
var ex = '';
for (i = 0; i <>
{
// WScript.Echo(i + ":" + filel[i]);
trf = fs.OpenTextFile(filel[i],1,false);
st = trf.ReadAll();
// WScript.Echo(st);
trf.Close();
st = '';
ex = cmdl.Run(bmailexe + ' -s SMTPサーバ -t ブログ投稿アドレス -f ブログ送信者アドレス -a ' + subl[i] + ' ' + '-m ' + filel[i] + ' ');
// timepause(10);
}

il = 0;

var trrf = fs.OpenTextFile(streamname,1,false);
var trwf = fs.OpenTextFile(bupf,2,-1);
while ( !trrf.AtEndOfStream ) {
l = trrf.ReadLine();
if ( l.match(re) ) {
trwf.Write("=---\n");
} else {
trwf.Write(l + "\r\n");
}
}
trwf.Close();
trrf.Close();
fs.CopyFile(bupf, streamname, 1);

function timepause(pst) {
var stt = 0;
var tu = 1000000; // about 1s
stt = tu * pst; // pst = 60: ~1min.
for (i = 0; i <>
;;
}
}

function Include(incfile)
{
var incfso, incf;
incfso = new ActiveXObject("Scripting.FileSystemObject");
incf = incfso.OpenTextFile(incfile, 1);
incstr = incf.ReadAll();
incf.Close();
return incstr
}


コメント: コメントを投稿





<< ホーム

This page is powered by Blogger. Isn't yours?

登録 投稿 [Atom]