c-modeEntry root file
c-modeEntry root file

[newDiaryArticleMax]195102[/newDiaryArticleMax]
[importMax]194956[/importMax]

[beforeExec]

fe = new Array(null, null, null, null);
isAppendCodeLoader = false;
feArticle = null;
loopExec = "";
loopStopFg = false;
loopStopCmd = "";
loopBreakFg = false;
testEntry = function(){
var uri = p2n("1910");
var doc = fileDocLoad(uri);
var user = key(doc, "USER");
var dat = key(doc, "DATA");
user = user.replace(/(\d+)(:"[a-z0-9\-]+\,)(\d+)"/g, function(e0,e1,e2,e3){
var len = dat.split("," + e1 + " : ");
return e1 + e2 + (len.length - 1) + '"';
});
fileKeyReplace(uri, "USER", user);
echo("impDoc", user);
};


impUserFileLoad = function(){
var uri = "/cgi-bin/footprint.cgi?oid=" + Fx.user;
fileIo(uri, 1);
userCreateDate = Fx.e(uri, false).replace(/.+since (\d+ \d+\/\d+ \d+:\d+).+/, "$1");
fileDone();
if(Fx.user == "benkei") userCreateDate = "2007 12/10 21:37";
if(Fx.user == "ojisaninomoide") userCreateDate = "2007 12/03 13:45";

userDiaryFile = [];
impUserList = " ";
impUserNewList = " ";
impUserTransList = " ";
impUserPage = "";
impUserPageDat = [];
impUserDat = new Array(500);
for(var i = 0; i < 500; i++) impUserDat[i] = " ";

if(userCreateDate.indexOf("未登録のユーザ ID です") != -1){
Fx.transDeleteUserList += Fx.user + " ";
echo("ud0", Fx.user);
for(var i = 1; i < 6; i++) echo(("ud" + i), "null");
echo("importInfo", "Acsess : \x3ca href=\"http://nancyan.main.jp/nancyan/io.php?uri=/cgi-bin/footprint.cgi?oid=" + Fx.user + "\" target=\"_blank\">footprint(php)\x3c/a> | " +
"\x3ca href=\"http://nancyan.main.jp/nancyan/io.php?uri=/home/" + Fx.user + "/diary/\" target=\"_blank\">/diary/(php)\x3c/a> | " +
"\x3ca href=\"/home/" + Fx.user + "/diary/menu.html\" target=\"_blank\">diary/menu.html\x3c/a>");
setTimeout("afterExec()", 300);
return;
}
echo("importInfo", "done.");
var uri = "/home/" + Fx.user + "/diary/menu.html";
fileIo(uri, 1);
var s = Fx.e(uri, false);
fileDone();

s.replace(/href="(\/home\/[0-9a-z\-]+\/diary\/\d{4})(\/|\/01\/)"/g, function(e0, e1, e2){ userDiaryFile.push(e1 + e2); return ""; });
userDiaryFileMax = userDiaryFile.length;
userDiaryFileString = userDiaryFile.join("\n");
if(userDiaryFileMax > 0) impUserFileLoop();
};

impUserFileLoop = function(){
var uri = userDiaryFile.shift();
Fx.d2 = uri.match(/\/01\/$/);
fileIo(uri, 1);
Fx.e(uri, "e1");

};

Lo.e1 = function(s){
fileDone();
s = s.replace(/ title="[^"]+"/g, "");
var re = Fx.d2 ? /id="A(\d+)">\s*\x3cdiv class="entry_date">(\d{4} \d+\/\d+ \d+:\d+)\x3c\/div>/g :
/id="(\d+)"\-\->\x3cli>\x3cspan class="time">(\d{4} \d+\/\d+ \d+:\d+)\x3c\/span>/g;
s.replace(re, function(e0,e1,e2){
var no = e1 - 0;
if(e2 > userCreateDate && e1 <= Fx.articleMax){
impUserNewList += e1 + " ";
var p = Math.floor(no / 500);
if(!isFind(impUserPage, p)){
impUserPage += p + " ";
impUserPageDat.push(p);
}
impUserDat[p] += no + " ";;
} else impUserTransList += e1 + " ";
impUserList += e1 + " ";
Fx.userImportMax = no;
return "";
});
loEntry();
};
loEntry = function(){
// if(yearDat.length > 0 && Fx.userImportMax > Fx.importMax){
if(userDiaryFile.length > 0) impUserFileLoop();
else {
echo("ud0", Fx.user);
echo("ud1", userCreateDate);
echo("ud2", userDiaryFileMax);
echo("ud3", impUserList.split(" ").length - 2);
echo("ud4", impUserNewList.split(" ").length - 2);
echo("ud5", impUserTransList.split(" ").length - 2);
importExecMainLoop();
}
};
importExecMainLoop = function(){
var n =impUserPageDat.length;
if(n > 0){
echo("ud6", n);
var s = "\x3cselect id=\"iSel\" onchange=\"impUserDatShow()\">";
for(var i = 0; i < n; i++) s += "\x3coption value=\"" + impUserPageDat[i] + "\">" + numberToPage(impUserPageDat[i]) + "\x3c/option>";
echo("ud7", s + "\x3c/select>\x3cbutton onclick=\"impUserDatShow()\">表示\x3c/button>");
importPageCNT = 0;
importPageCntMax = n;
importPage = impUserPageDat.shift();
Fid("sel1").selectedIndex = 399 - importPage;
impExec(10);
importExecMain();
} else {
afterExec();
}
};
importExecMain = function(){
var u = UserDat;
var dat = "\t" + DataDat;
var User = impUserDat[importPage];
echo("impDoc", User);
var len = User.replace(/(^ | $)/g, "").split(" ").length;
if(u == ""){
var UserNo = 0;
u = '0:"' + Fx.user + ',' + len + '"';
} else {
eval("var dt = {" + u.replace(/(\d+):("[0-9a-z\-]+)\,\d+"/g, "$2\":\"$1\"") + "};");
var UserNo = dt[Fx.user] || u.split(", ").length;
if(!dt[Fx.user]) u += ', ' + UserNo + ':"' + Fx.user + ',' + len + '"';
else {
u = u.replace(/(\d+:")([0-9a-z\-]+)\,(\d+)/g, function(e0,e1,e2,e3){
return e2 == Fx.user ? e1 + e2 + "," + (e3 - 0 + len) : e1 + e2 + "," + e3;
});
}
}
dat = dat.replace(/\t(\d|\*|\+|\-)A(\d+)(\,?\d*)( :)/g, function(e0,e1,e2,e3,e4){
var n = OFFSET + (e2 - 0);
return "\t" + e1 + "A" + e2 + (isFind(User, n) ? "," + UserNo : e3) + e4;
});
u = u.replace(/(\d+)(:"[a-z0-9\-]+\,)(\d+)"/g, function(e0,e1,e2,e3){
var len = dat.split("," + e1 + " : ");
return e1 + e2 + (len.length - 1) + '"';
});
echo("ud8", UserNo);
echo("ud9", "\x3cbutton onclick=\"impExec(50)\">newUserDatShow\x3c/button>");
echo("ud10", "\x3cbutton onclick=\"impExec(51)\">newDataShow\x3c/button>");
echo("ud11", "done.");
newUserDat = u;
newData = dat;
if(newUserDat == UserDat){
echo("impDoc", "インポート済みです。変更はありません");
setTimeout("afterExec()", 1000);
} else {
UserDat = newUserDat;
DataDat = dat;
docUpdateSubmit(dat, "main");
}
};
docUpdateSubmit = function(dat, after){
var a;
newDoc = createDoc(dat);
newTitle = createTitle(newDoc) + " ..s:" + newDoc.length +
(UserDat.match(/(\d+):"[a-z0-9\-]+\,\d+"$/) ? " ..u:" + (Number(RegExp.$1) + 1) : "") +
((a = TransDat.match(/\d+\-\d+\,[a-z0-9,\-]+/g)) ? " ..t:" + a.length : "");

echo("ud11", "\x3cbutton onclick=\"impExec(52)\">newDoc\x3c/button>");
echo("ud12", "\x3cbutton onclick=\"impExec(53)\">newTitle\x3c/button>");
fileIo(feArticle, 0);
if(after != "") Fx.e("diary_form", diaryForm(feArticle, newTitle, newDoc, false, 909), after);
// if(after != "") setTimeout("Lo." + after + "()", 1000);
};
matchLen = function(str, re){
var a = str.match(re); return a ? a.length : 0;
};
matchInc = function(str, re){
var a = str.match(re); if(!a) return 0;
var i,n = 0;
for(i in a) n += a[i].replace(/[^0-9]/g, "") - 0;
return n;
};

createTitle = function(dat){
var a, dat = "\t" + dat.replace(/\n/g, "\t");
var num = feArticle - 175171;
var s1 = matchLen(dat, /\t\dA\d+/g);
var s2 = matchLen(dat, /\t\+A\d+/g);
var s3 = matchLen(dat, /\t\-A\d+/g);
var s4 = matchInc(dat, /\t\(\d+\)/g);
var s5 = matchLen(dat, /\t(\+|\-)A\d+ :/g)
var str = "diary of " + numberToPage(num) + " (" + (num + 1) + ")" +
(s1 ? " *" + s1 : "") + (s2 ? " +" + s2 : "") + (s3 ? " /" + s3 : "") + (s4 ? " -" + s4 : "") +
(s5 ? " ..e" + s5 : "") + ((500 - s1 - s2 - s3 - s4) != 0 ? " ..more!" : "");
return str;
};
createDoc = function(dat){
dat = dat.replace(/\n/g, "\t").replace(/(^\t*|\t*$)/g, "\t");
var str = feArticle + "\n\n" +
"[" + "MSG]" + feMsg(feArticle) + "[/" + "MSG]\n" +
"[" + "UPDATE]" + (new Date()).toLocaleString() + "[/" + "UPDATE]\n" +
"[" + "OFFSET]" + (Math.floor(((feArticle - 175171) * 500) / 1000) * 1000) + "[" + "/OFFSET]\n" +
(UserDat != "" ? "[" + "USER]" + UserDat + "[/" + "USER]\n" : "") +
(Fx.trans != "" ? "[" + "TRANS]" + Fx.t2n(TransDat) + "[/" + "TRANS]\n" : "") +
"[" + "DATA]" + Fx.t2n(dat) + "[/" + "DATA]\n";
return str;
};
breakSpot = function(func){
fileDone();
if(loopStopFg || loopBreakFg){
loopStopCmd = func + "()";
loopStopEntry();
} else setTimeout(func + "()", 50);
};
Lo.main = function(s){
breakSpot("importExecMainLoop");
};

impUserDatShow = function(){
echo("impDoc", impUserDat[echo("iSel") - 0]);
};
loEntry2 = function(){

};




fileIo = function(no, fg){
echo("fileInfo", no);
Fid("fileInfo").className = "file-" + (fg ? "load" : "up");
};
fileDone = function(){
Fid("fileInfo").className = "";
};
keyReplace = function(doc, keyCode, str){
var a,b,n1,n2;
if((n1 = doc.indexOf("[" + keyCode + "]")) != -1 && (n2 = doc.indexOf("[/" + keyCode + "]")) != -1){
doc = doc.substring(0, n1 + keyCode.length + 2) + str + doc.substring(n2);
}
return doc;
};
feMsg = function(no){
var page = n2p(no);
return "\n\n※検索サイトからお越しの方へ\n" +
"このページは「\x3ca href=\"/home/yadokari/main.html?diary=177594\">エクラの日記\x3c/a>」のデータの一部となっています。\n" +
"ご覧のページに載っている内容は、リンク生成された「\x3ca href=\"/home/yadokari/main.html?diary=177594&page=" +
page + "\">diary of " + page + "\x3c/a>」にて閲覧することが出来ます。\n";
};

fileKeyReplace = function(article){
var f = article == feArticle ? fe : fileLoad(article, 0);
if(f[3] == null){
alert("置換するページが管理人のものではありません\n処理を中止します。");
return;
}
var loop = Math.floor((arguments.length - 1) / 2);
var a,b,n1,n2;
for(var i = 0; i < loop; i++){
a = arguments[i * 2 + 1];
b = arguments[i * 2 + 2];
if((n1 = f[1].indexOf("[" + a + "]")) != -1 && (n2 = f[1].indexOf("[/" + a + "]")) != -1){
f[1] = f[1].substring(0, n1 + a.length + 2) + b + f[1].substring(n2);
}
}
f[1] = keyReplace(f[1], "MSG", feMsg(article));
f[1] = keyReplace(f[1], "UPDATE", (new Date()).toLocaleString());
f[1] = f[1].replace(/\t/g, "\n");
fileIo(article, 0);
Lo.fileKeyReplaceAfter = function(s){
fileDone();
};
Fx.e("diary_form", diaryForm(article, f[0], f[1], f[2], f[3]), "fileKeyReplaceAfter");
};

yearDat = [];
data = [];
dt = "_._." + "._._";
infoOpa = 1.0;
dateData = "";
titleData = "";
isLoad = true;
userTrans = [];
TransDat = "";
msgDat = "■c-mode起動しました。";
fileKeyLoad = function(no, keyCode){ return key(fileLoad(no, 0)[1], keyCode); };
fileDocLoad = function(no){ return fileLoad(no, 0)[1]; };

fileLoad = function(no){
fileIo(no, 1);
var doc = Fx.e(["/cgi-bin/diary_form.cgi?mode=edit;oid=", Vis.oid, ";article_id=", no], false);
doc = doc.replace(/amp;/g, "");
doc = doc.replace(/\x26quot;/g, "\x22").replace(/\x26#39;/g, "\x27");
fileDone();
var cate = doc.match(/\x3coption value="(\d+)" selected="selected"/) ? RegExp.$1 : null;
var fg = doc.indexOf('name="article_notify" value="1" checked="checked"') != -1;
var title = doc.match(/\x3cinput type="text" name="article_title" value="([^"]*)"/) ? RegExp.$1 : null;
doc = doc.replace(/(.+\x3ctextarea.+?>|\x3c\/textarea.+)/g, "");
if(arguments.length == 1){
fe[0] = title; fe[1] = doc; fe[2] = fg; fe[3] = cate; feArticle = no;
UserDat = key(doc, "USER");
TransDat = key(doc, "TRANS");
DataDat = key(doc, "DATA").replace(/^\t+|\t+$/g, "");
OFFSET = key(doc, "OFFSET") - 0;
UPDATE = key(doc, "UPDATE");
}
return [title, doc, fg, cate];
};

fileActive = function(str, fg){
Fid(str + "Button").disabled = fg;
echo("fileLabel", fg ? "\x3cspan>" + str + " : \x3c/span>" + "処理中" : "処理待機中");
Fid("fileLabel").className = fg ? "file-active" : "";
Fid("fileInfo").className = "file-" + (fg ? "load" : "up");
if(!fg){
echo("fileInfo", "done.");
Fid("fileInfo").className = "";
}
};

createSelect = function(id, sel, str, func){
var i,a,re,n1,n2, s = "\x3cselect id=\"" + id + "\" onchange=\"" + id + "Change(this)\">";
if(str.match(/^(\d+)\-(\d+)$/)){
n1 = RegExp.$1 - 0; n2 = RegExp.$2 - 0;
for(i = n1; i >= n2; i--){
s += "\x3coption" + (i == sel ? " selected=\"selected\"" : "") + " value=\"" + i + "\"" + ">" +
(func == "" ? i : func(i)) + "\x3c/option>\n";
}
} else {
var re = str.split(",");
for(i = 0; i < re.length; i++){
a = re[i].split(":");
s += "\x3coption" + (a[0] == sel ? " selected=\"selected\"" : "") + " value=\"" + a[0] + "\">" + a[1] + "\x3c/option>\n";
}
}
return s + "\x3c/select>";
};

createButton = function(str){
var i,a,s = "",re = str.split(" ");
for(i = 0; i < re.length; i++) {
a = re[i].split(":");
s += "\x3cbutton id=\"B" + a[0] + "\" onclick=\"impExec(" + a[0] + ")\">" + a[1] + "\x3c/button>";
}
return s;
};

cmodeEntry = function(){
msg("c-mode(1)システムを読み込んでいます。");
document.title = "c-mode : エクラの日記";
var doc = fileDocLoad(176638);
eval(Fx.t2n(Fx.dec(key(doc, "CODE"))));
msg("関数を定義しました。");
Fx.classA = key(doc, "CLASS-A");
Fx.classB = key(doc, "CLASS-B");
Fx.classC = key(doc, "CLASS-C");
Fx.classD = key(doc, "CLASS-D");
Fx.classE = key(doc, "CLASS-E");
Fx.classF = key(doc, "CLASS-F");
msg("変数を初期化しました。新着日記の最大値を読み込んでいます。");
Fx.allArticleMax = Fx.e("/cgi-bin/diary.cgi?oid=all;n=1", false).replace(/^.+s=(\d+).+$/, "$1") - 0;
msg("読み込みました。ファイルTrannsを読み込んでいます。");
Fx.allTrans = Fx.t2n(key(fileLoad(177614, 0)[1], "TRANS").replace(/^\t+|\t+$/g, ""));
msg("読み込みました。変数を定義しています。");
var user = Fx.classA + " " + Fx.classB + " " + Fx.classC + " " + Fx.classD + " " + Fx.classE + " " + Fx.classF;
var s = sSort(Fx.allTrans.replace(/\n/g, " ").replace(/\d+\-\d+\,([a-z0-9\-]+)\,\d/g, "$1")).split(" ");
for(var i = 0,str = ""; i < s.length; i++) if(!isFind(user, s[i])){
str += s[i] + " "; user += " " + s[i];
}
Fx.classG = sSort(str);
msg("定義しました。ドキュメントを生成しています。");
makeDoc();
};

listDataEcho= function(s){

};

msg = function(s){
var str = "■" + s + "\n";
echo("impDoc", str + "\n" + msgDat);
msgDat = str + msgDat;
};
pageToNumber = function(n){ return Math.floor(n / 100) * 20 + (n % 100); };
numberToPage = function(n){ return ("0" + Math.floor(n / 20)).slice(-2) + ("0" + ((n % 20) + 1)).slice(-2); };
p2n = function(n){ return Math.floor(n / 100) * 20 + (n % 100) + 175170; };
n2p = function(n){
var a = n - 175171;
return ("0" + Math.floor(a / 20)).slice(-2) + ("0" + ((a % 20) + 1)).slice(-2);
};
a2p = function(n){ return ("0" + Math.floor(n / 10000)).slice(-2) + ("0" + (Math.floor((n % 10000) / 500) + 1)).slice(-2); };
a2n = function(n){ return Math.floor(n / 500) + 175171; };



[/beforeExec]

[body]
<$$div id="fileInfoDisp">
<$$div class="fileInfoMsg1">Article-file input/output Info.<$$/div>
<$$div class="fileInfoMsg2">
<$$span id="fileLabel">待機中<$$/span> : <$$span id="fileInfo">done.<$$/span>
<$$/div>
<$$/div>

<$$div id="importDisp">
<$$div id="importInfo">done.<$$/div>
<$$div id="execEntryDisp">done.<$$/div>
<$$div id="impExecUserDisp" class="sel-disp">done.<$$/div>
<$$div id="impExecDisp1" class="sel-disp">done.<$$/div>
<$$div id="imgExecDisp5">done.<$$/div>
<$$div id="impExecDisp2" class="bef-load">done.<$$/div>
<$$textarea id="impDoc" cols="60" rows="13">■c-mode起動中です。<$$/textarea>
<$$div id="impExecDisp3">done.<$$/div>
<$$div id="impExecDisp4">done.<$$/div>
<$$/div>
<$$div id="importUserDisp"><$$/div>
[/body]