{"id":769,"date":"2012-11-18T13:00:01","date_gmt":"2012-11-18T05:00:01","guid":{"rendered":"http:\/\/srkf.bangbang93.com\/?p=769"},"modified":"2012-11-18T13:00:01","modified_gmt":"2012-11-18T05:00:01","slug":"system-console-for-lua-is-open-source","status":"publish","type":"post","link":"https:\/\/sforest.in\/ja\/system-console-for-lua-is-open-source\/","title":{"rendered":"LConsole\u5f00\u6e90"},"content":{"rendered":"<h4>\u8fd9\u8d27\u662f\u5565<\/h4>\n<blockquote><p>\u5c0f\u840c\u5728\u73a9MConsole\uff0c\u6d69\u7136\u5728\u73a9HConsole\uff0c\u6211\u5c31\u63ba\u548c\u4e00\u4e2aLConsole\u3002<br \/>\n\u6697\u5f71\u8f6f\u4ef6\u51fa\u54c1\u3002\u6e90\u4ee3\u7801\u5f00\u653e\uff0c\u5982\u4e0b\u3002<\/p>\n<p style=\"text-align: left;\"><!--more--><\/p>\n<\/blockquote>\n<h4>\u00a0\u73af\u5883<\/h4>\n<blockquote><p>Luaet5.2.1 \uff08By Zyxwvu\uff09<br \/>\nlcon \uff08By Shuenhoy\uff09<br \/>\n\u76ee\u524d\u4ee3\u7801\u6ca1\u6709\u7528\u5230lcon\uff0c\u53ef\u4ee5\u5728require\u4e2d\u5c06\u5176\u53bb\u6389\u3002<\/p><\/blockquote>\n<h4>\u6e90\u4ee3\u7801<\/h4>\n<blockquote><p>\u5982\u4e0b\uff1a<br \/>\n[lua]<br \/>\n&#8211;Tips<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n&#8212;  lcon\u662f\u4e00\u4e2a\u63d0\u4f9b\u5f69\u8272\u5b57\u4f53\u7684\u5e93<br \/>\n&#8212;  gotoXY      \u8bbe\u7f6e\u5750\u6807<br \/>\n&#8212;  cls         \u6e05\u5c4f<br \/>\n&#8212;  cls_c       \u5e26\u989c\u8272\u6e05\u5c4f<br \/>\n&#8212;  set_colorx  \u5b57\u4f53\u8272\u80cc\u666f\u8272\u4e00\u5757\u8bbe\u7f6e<br \/>\n&#8212;  set_color   \u53ea\u8bbe\u7f6e\u5b57\u4f53\u8272<br \/>\n&#8212;  hide_cursor \u9690\u85cf\u5149\u6807<br \/>\n&#8212;  show_cursor \u663e\u793a\u5149\u6807<br \/>\n&#8212;  pcurpos     \u6253\u5370\u5149\u6807\u5750\u6807(\u8c03\u8bd5\u7528)<br \/>\n&#8212;  cur_x       \u53d6\u5f97x\u5750\u6807<br \/>\n&#8212;  cur_y       \u53d6\u5f97y\u5750\u6807<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n&#8211;Require<br \/>\nrequire&#8221;socket&#8221;<br \/>\nrequire&#8221;coding&#8221;<br \/>\nrequire&#8221;lcon&#8221;<br \/>\nrequire&#8221;cjson&#8221;<br \/>\nrequire&#8221;luacom&#8221;<br \/>\nrequire&#8221;curl&#8221;<br \/>\n&#8211;Database<br \/>\n_VERSION=&#8221;1.0.4.4&#8243;<br \/>\n_MODE=&#8221;Windows&#8221;<br \/>\n_HELP=[[<br \/>\n\u6b22\u8fce\u4f7f\u7528System Console For Lua~<br \/>\n\u6709\u6548\u547d\u4ee4\u5982\u4e0b\uff1a<br \/>\nabout   \u5173\u4e8e\u4fe1\u606f<br \/>\nhelp    \u5e2e\u52a9\u4fe1\u606f<br \/>\ncd  \u540cWindows\u4e2d\u7684cd\uff0c\u5355\u72ec\u4f7f\u7528\u65e0\u6548\u679c\uff0c\u7d27\u968f\u5176\u540e&#038;\u4ee5\u4f7f\u7528\u3002<br \/>\n    \u4f8b\u5982\uff1acd .. &#038; echo Hi<br \/>\ncls \u6e05\u5c4f<br \/>\nmode    \u66f4\u6362\u63d0\u793a\u7b26\u6a21\u5f0f\uff0c\u652f\u6301Windows\/Linux\/Lua\u4e09\u79cd\u6a21\u5f0f\u3002<br \/>\n    \u4f7f\u7528\u65b9\u6cd5\uff1amode [\u6a21\u5f0f]<br \/>\nlua \u6267\u884clua\u547d\u4ee4\u3002<br \/>\n    \u4f7f\u7528\u65b9\u6cd5\uff1alua [\u4ee3\u7801]<br \/>\n\u4ee5\u53ca\u60a8\u7684\u7cfb\u7edf\u6240\u652f\u6301\u7684\u6240\u6709\u547d\u4ee4\u3002<br \/>\nping    \u6d4b\u8bd5\u5bf9\u67d0\u4e2aIP\/\u7f51\u7edc\u5730\u5740\u7684\u8fde\u63a5\u60c5\u51b5\u3002<br \/>\n    \u4f7f\u7528\u65b9\u6cd5\uff1aping [IP\/\u5730\u5740]<br \/>\necho    \u663e\u793a\u6307\u5b9a\u6587\u5b57\u3002<br \/>\n    \u4f7f\u7528\u65b9\u6cd5\uff1aecho [\u6587\u5b57\/\u73af\u5883\u53d8\u91cf\u540d]<br \/>\n\u5728Linux\u6a21\u5f0f\u4e0b\u4f60\u53ef\u4ee5\u4f7f\u7528\u90e8\u5206Linux\u547d\u4ee4\u3002<br \/>\ncp  \u590d\u5236\u6587\u4ef6\uff0c\u540ccopy\u3002<br \/>\nrm  \u5220\u9664\u6587\u4ef6\uff0c\u540cdel\u3002<br \/>\nclean   \u6e05\u5c4f\uff0c\u540ccls\u3002<br \/>\n******\u4ee5\u4e0a\u547d\u4ee4\u5747\u5927\u5c0f\u5199\u652f\u6301******<br \/>\n[Eggs]\u53e6\u6709\u4e24\u4e2a\u9690\u85cf\u547d\u4ee4\uff0c\u8bf7\u81ea\u884c\u6316\u6398:)<br \/>\n]]<br \/>\n_LINUXEXEC=[[doskey ls=dir $* &#038;<br \/>\n doskey pwd=cd $* &#038;<br \/>\ndoskey mkdir=md $* &#038;<br \/>\ndoskey rmdir=rd $* &#038; doskey rm=del $*  &#038;<br \/>\ndoskey mv=move $* &#038; doskey cp=copy $* &#038;<br \/>\n doskey cat=type $* &#038; doskey clear=cls &#038;<br \/>\n doskey uname=ver &#038; doskey id=whoami &#038; doskey w=quser &#038; ]]<br \/>\n_TIP={<br \/>\n    Windows=&#8221;System Console For Lua [\u7248\u672c &#8220;.._VERSION..[[]n(C) \u7248\u6743\u6240\u6709<br \/>\n2012- Shadow Forest Software.n]],<br \/>\n    Linux=os.date(&#8220;login: %a %b %d %X %Y&#8221;),<br \/>\n    Lua=&#8221;Lua &#8220;.._VERSION..[[ Copyright (C) 2012- Shadow<br \/>\nForest Software, Joshua]]<br \/>\n}<br \/>\n&#8211;Functions<br \/>\nfunction _DELS(str)<br \/>\n    return str:match(&#8220;%s*(.-)%s*$&#8221;)<br \/>\nend<br \/>\nfunction _DOLUA(code)<br \/>\n    local r=loadstring(code)<br \/>\n    local a,b=pcall(r)<br \/>\n    if b then<br \/>\n        print(b)<br \/>\n    end<br \/>\nend<br \/>\nfunction _WRITETIP()<br \/>\n    if _MODE==&#8221;Windows&#8221; then<br \/>\n        local md=io.popen(&#8220;cd&#8221;)<br \/>\n        local this=md:read(&#8220;*a&#8221;)<br \/>\n        md:close()<br \/>\n        return this:match(&#8220;^(.+)n$&#8221;)..&#8221;>&#8221;<br \/>\n    elseif _MODE==&#8221;Linux&#8221; then<br \/>\n        local md=io.popen(&#8220;echo [%username%@%COMPUTERNAME% ~]&#8221;)<br \/>\n        local this=md:read(&#8220;*a&#8221;)<br \/>\n        md:close()<br \/>\n        return this:match(&#8220;^(.+)n$&#8221;)<br \/>\n    elseif _MODE==&#8221;Lua&#8221; then<br \/>\n        return &#8220;> &#8221;<br \/>\n    else<br \/>\n        _MODE=&#8221;Lua&#8221;<br \/>\n        return &#8220;> &#8221;<br \/>\n    end<br \/>\nend<br \/>\nfunction _CLS()<br \/>\n    os.execute(&#8220;cls&#8221;)<br \/>\nend<br \/>\nfunction _ENCSTR(str)<br \/>\n    if str:find(&#8220;^[Cc][Dd] &#8220;) then<br \/>\n        os.execute(str)<br \/>\n        return<br \/>\n    elseif str:find(&#8220;^[Mm][Oo][Dd][Ee] .-&#8220;) then<br \/>\n        local mo=str:match(&#8220;^[Mm][Oo][Dd][Ee] (.+)&#8221;):lower()<br \/>\n        if mo==&#8221;windows&#8221; then<br \/>\n            _MODE=&#8221;Windows&#8221;<br \/>\n            print(&#8220;\u8bbe\u7f6e\u6a21\u5f0f &#8220;.._MODE..&#8221; \u6210\u529f\u3002&#8221;)<br \/>\n            os.execute(&#8220;pause &#038; cls&#8221;)<br \/>\n            print(_TIP[_MODE])<br \/>\n            return<br \/>\n        elseif mo==&#8221;linux&#8221; then<br \/>\n            _MODE=&#8221;Linux&#8221;<br \/>\n            print(&#8220;\u8bbe\u7f6e\u5f53\u524d\u6a21\u5f0f\u4e3a &#8220;.._MODE..&#8221; \u6210\u529f\u3002&#8221;)<br \/>\n            os.execute(&#8220;pause &#038; cls&#8221;)<br \/>\n            print(_TIP[_MODE])<br \/>\n            return<br \/>\n        elseif mo==&#8221;lua&#8221; then<br \/>\n            _MODE=&#8221;Lua&#8221;<br \/>\n            print(&#8220;\u8bbe\u7f6e\u6a21\u5f0f &#8220;.._MODE..&#8221; \u6210\u529f\u3002&#8221;)<br \/>\n            os.execute(&#8220;pause &#038; cls&#8221;)<br \/>\n            print(_TIP[_MODE])<br \/>\n            return<br \/>\n        else<br \/>\n            print(&#8220;\u65e0\u6b64\u683c\u5f0f\uff1aMode\u53ea\u652f\u6301Windows\/Linux\/Lua\u683c\u5f0f\u3002&#8221;)<br \/>\n            return<br \/>\n        end<br \/>\n    elseif str:find(&#8220;^[Cc][Ll][Ss]&#8221;) or str:find(&#8220;\u6e05\u5c4f&#8221;) then<br \/>\n        _CLS()<br \/>\n        return<br \/>\n    elseif str:find(&#8220;^[Hh][Ee][Ll][Pp]&#8221;) then<br \/>\n        print(_HELP)<br \/>\n        return<br \/>\n    elseif str:find(&#8220;^[Aa][Bb][Oo][Uu][Tt]&#8221;) then<br \/>\n        print(_TIP[_MODE])<br \/>\n        return<br \/>\n    elseif str:find(&#8220;^[Ff][Uu][Cc][Kk] .-&#8220;) then<br \/>\n        print(&#8220;Fucking &#8220;..str:match(&#8220;^[Ff][Uu][Cc][Kk] (.+)$&#8221;)..&#8221;~&#8221;)<br \/>\n        return<br \/>\n    elseif str:find(&#8220;^[Ll][Uu][Aa] .-&#8220;) then<br \/>\n        _DOLUA(str:match(&#8220;^[Ll][Uu][Aa] (.*)&#8221;))<br \/>\n        return<br \/>\n    elseif str:find(&#8220;[Aa][Dd]&#8221;) then<br \/>\n        os.execute(&#8220;@start http:\/\/sforest.in&#8221;)<br \/>\n        return<br \/>\n    else<br \/>\n        if _MODE==&#8221;Windows&#8221; then<br \/>\n            os.execute(str)<br \/>\n        elseif _MODE==&#8221;Linux&#8221; then<br \/>\n            local m=io.popen(_LINUXEXEC..str)<br \/>\n            local s=m:read(&#8220;*all&#8221;)<br \/>\n            m:close()<br \/>\n            if s==&#8221;&#8221; then<br \/>\n                print(&#8220;Bad command or not return value.n&#8221;)<br \/>\n            else<br \/>\n                print(s)<br \/>\n            end<br \/>\n        elseif _MODE==&#8221;Lua&#8221; then<br \/>\n            local m=io.popen(str)<br \/>\n            local s=m:read(&#8220;*all&#8221;)<br \/>\n            m:close()<br \/>\n            if s==&#8221;&#8221; then<br \/>\n                print(&#8220;stdin:1: attempt to call global &#8216;&#8221;..str..&#8221;&#8216; (a nil command)n&#8221;)<br \/>\n            else<br \/>\n                print(s)<br \/>\n            end<br \/>\n        end<br \/>\n    end<br \/>\nend<br \/>\n&#8211;Main<br \/>\nos.execute(&#8220;@title LConsole &#8211; &#8220;.._VERSION)<br \/>\nprint(_TIP[_MODE])<br \/>\nwhile true do<br \/>\n    io.write(_WRITETIP())<br \/>\n    a,b=pcall(_ENCSTR,_DELS(io.read()))<br \/>\n    if not a then<br \/>\n        print(&#8220;\u606d\u559c\u60a8\u53d1\u73b0\u4e86\u4e00\u4e2aBug~n\u7a0b\u5e8f\u9519\u8bef\u4fe1\u606f\u5982\u4e0b\uff1an&#8221;..<br \/>\nb..&#8221;n\u8bf7\u5411\u5c0f\u7ea6\u53cd\u9988\uff0c\u591a\u8c22\u652f\u6301\uff01n&#8221;)<br \/>\n    end<br \/>\nend<br \/>\n[\/lua]\n<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u8d27\u662f\u5565 \u5c0f\u840c\u5728\u73a9MConsole\uff0c\u6d69\u7136\u5728\u73a9HConsole\uff0c\u6211\u5c31\u63ba\u548c\u4e00\u4e2aLConsole\u3002 \u6697\u5f71\u8f6f\u4ef6\u51fa\u54c1\u3002\u6e90\u4ee3\u7801\u5f00\u653e\uff0c\u5982\u4e0b\u3002<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[26,129,144],"class_list":["post-769","post","type-post","status-publish","format-standard","hentry","category-coding","tag-lua","tag-129","tag-144"],"_links":{"self":[{"href":"https:\/\/sforest.in\/ja\/wp-json\/wp\/v2\/posts\/769","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sforest.in\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sforest.in\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sforest.in\/ja\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sforest.in\/ja\/wp-json\/wp\/v2\/comments?post=769"}],"version-history":[{"count":0,"href":"https:\/\/sforest.in\/ja\/wp-json\/wp\/v2\/posts\/769\/revisions"}],"wp:attachment":[{"href":"https:\/\/sforest.in\/ja\/wp-json\/wp\/v2\/media?parent=769"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sforest.in\/ja\/wp-json\/wp\/v2\/categories?post=769"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sforest.in\/ja\/wp-json\/wp\/v2\/tags?post=769"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}