Пример #1
0
        void Form1_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            //foreach (string file in files) Console.WriteLine(file);
            Console.WriteLine(files.Length);
            if (files.Length >= 2)
            {
                MessageBox.Show("一次只能處理一個檔案...");
                reset_data();
                return;
            }

            string sn = my.subname(files[0].ToString());

            if (sn != "nc" && sn != "txt")
            {
                MessageBox.Show("副檔名只能是 nc 或 txt");
                reset_data();
                return;
            }
            CC.orin_path    = files[0].ToString();
            INPUT_PATH.Text = CC.orin_path;
            CC.data         = my.b2s(my.file_get_contents(CC.orin_path));
            CC.data         = my.trim(CC.data.Replace("\r", ""));
            CC.m_data       = new List <string>();
            load_data();
        }
Пример #2
0
        public void run_check_update()
        {
            //檢查目前版本,如果版本檔不存在,關程式,下載新版,執行
            double local_version  = 0;
            double remote_version = 0;
            bool   isNeedUpdate   = false;
            string downloadPath   = "";

            //Console.WriteLine("step 1");
            if (!F1.my.is_file(F1.PWD + "\\version.txt"))
            {
                isNeedUpdate = true;
                //Console.WriteLine("step 2");
            }
            else
            {
                //檢查現在版本,跟網站上版本
                local_version  = Convert.ToDouble(F1.my.b2s(F1.my.file_get_contents(F1.PWD + "\\version.txt")));
                remote_version = local_version;
                try
                {
                    var jd = my.json_decode(F1.my.b2s(my.file_get_contents(F1.my.getSystemKey("checkVersionURL"))));
                    remote_version = Convert.ToDouble(jd[0]["version"].ToString());
                    downloadPath   = jd[0]["downloadPath"].ToString();
                    //Console.WriteLine("step 3");
                }
                catch
                {
                    //無網路
                }
            }
            if (local_version < remote_version || isNeedUpdate)
            {
                //Console.WriteLine("step 4");
                //版本不一樣,如果服務正在跑,就停止,下載,重新啟動程式
                F1.my.killProcess("system_status");
                if (downloadPath != "")
                {
                    //Console.WriteLine("step 5");
                    F1.my.file_put_contents(F1.PWD + "\\system_status.exe", F1.my.file_get_contents(downloadPath));
                    F1.logError("下載更新版本...:" + remote_version.ToString());
                }
                F1.my.system(F1.PWD + "\\system_status.exe");
            }
            if (!F1.my.isProcessRunning("system_status"))
            {
                //Console.WriteLine("step 6");
                F1.my.system(F1.PWD + "\\system_status.exe");
            }
        }
Пример #3
0
        public void getSettingINI()
        {
            /*
             # setting.ini
             # [
             # {
             #   "name":"",
             #   "ip":"",
             #   "port":"",
             #   "kind":"",
             #   "login_id":"",
             #   "pwd":"",
             #   "isConnect":"F",
             #   "pdo": obj ,
             #   "connString": string
             # }
             # ]
             */
            List <Dictionary <string, string> > data = new List <Dictionary <string, string> >();
            string setting_path = my.pwd() + "\\setting.ini";

            if (!my.is_file(setting_path))
            {
                my.file_put_contents(setting_path, "");
            }
            string endata = my.b2s(my.file_get_contents(setting_path));
            //string dedata = my.dePWD_string(endata, the_code);
            JArray ja = new JArray();

            if (endata != "")
            {
                ja = my.json_decode(endata);
            }

            for (int i = 0, max_i = ja.Count; i < max_i; i++)
            {
                Dictionary <string, object> doo = new Dictionary <string, object>();
                foreach (JObject obj in ja[i])
                {
                    Dictionary <string, object> dictObj = obj.ToObject <Dictionary <string, object> >();
                    dictObj["isConnect"] = "F";
                    connections.Add(dictObj);
                }
            }
        }
Пример #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //檢查不能重複啟動
            if (!ucl.checkLockSuccess())
            {
                MessageBox.Show("肥米已執行了...");
                Application.Exit();
            }
            //載入 UCLLIU.ini
            ucl.loadConfig();
            //載入字根檔
            ucl.loadJsonData();
            //如果有拚音,載入拚音功能
            if (my.is_file(my.pwd() + "\\pinyi.txt"))
            {
                ucl.same_sound_data = new List <string>(my.explode("\n", my.trim(my.b2s(my.file_get_contents(my.pwd() + "\\pinyi.txt")))));
            }

            //產生最簡根表
            ucl.generator_sp_table();

            word_label.Text = "";
            type_label.Text = "";
            KeyboardHook(this, e);
            //小圖加入版本
            notifyIcon1.Text = "肥米輸入法:" + ucl.VERSION;
            //修正一下畫面
            //


            /*this.TopLevel = true;
             * this.TopLevel = false;
             * this.TopLevel = true;
             * this.TopMost = true;
             * this.TopMost = false;
             * this.TopMost = true;
             */
            //Thread.Sleep(3000);
            btn_UCL.PerformClick();
            btn_UCL.PerformClick();
            //起始不可以是 topmost ,在程式執行後,才置高,不然
            //首次切換輸入法時,會失去原始的焦點(如記事本)
            this.TopMost = true;



            /*Thread.Sleep(1000);
             * SendKeys.SendWait("+");
             * Thread.Sleep(1000);
             * SendKeys.SendWait("+");
             * Thread.Sleep(1000);
             * SendKeys.SendWait("+");
             * Thread.Sleep(1000);
             * SendKeys.SendWait("+");
             * Thread.Sleep(1000);
             * SendKeys.SendWait("+");
             * Thread.Sleep(1000);
             * SendKeys.SendWait("+");
             * ucl.toAlphaOrNonAlpha();
             */
            //AllocConsole();
        }
Пример #5
0
        static void Main(string[] args)
        {
            if (args.Count() < 1)
            {
                echo(MESSAGE);
                exit();
            }
            if (my.is_string_like(args[0], "https://") || my.is_string_like(args[0], "http://"))
            {
                URL = args[0];
            }
            if (!my.is_string_like(URL, "https://") && !my.is_string_like(URL, "http://"))
            {
                echo(MESSAGE);
                exit();
            }

            string data = my.b2s(my.file_get_contents(URL));
            //echo(data);
            List <string> preScripts = new List <string>();

            //preScripts.Add("$=function(){};");
            preScripts.Add("var adsbygoogle=null;");
            //preScripts.Add("var window=null;");
            preScripts.Add("var localStorage={'getItem':function(){return '';}, 'setItem':function(a,b){} };");
            preScripts.Add("var y='46';");
            preScripts.Add("function spp(){};");
            preScripts.Add("var WWWWWTTTTTFFFFF='';");
            preScripts.Add("var document='';");
            //preScripts.Add("function $(p){};");
            preScripts.Add("function loadingpage(p){};");
            preScripts.Add("function initcomment(p){};");
            preScripts.Add("function mm(p){return (parseInt((p-1)/10)%10)+(((p-1)%10)*3)};");
            preScripts.Add("function nn(n){return n<10?'00'+n:n<100?'0'+n:n;};");
            preScripts.Add("function su(a,b,c){var e=(a+'').substring(b,b+c);return (e);};");
            preScripts.Add("function lc(l){ if (l.length != 2) return l; var az = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"; var a = l.substring(0,1); var b = l.substring(1, 2); if (a == \"Z\") return 8000 + az.indexOf(b); else return az.indexOf(a) * 52 + az.indexOf(b); };");
            preScripts.Add("function request(queryStringName){var returnValue=\"\";var URLString=new String(document.location);var serachLocation=-1;var queryStringLength=queryStringName.length;do{serachLocation=URLString.indexOf(queryStringName+\"\\= \");if (serachLocation!=-1){if ((URLString.charAt(serachLocation-1)=='?') || (URLString.charAt(serachLocation-1)=='&')){URLString=URLString.substr(serachLocation);break;}URLString=URLString.substr(serachLocation+queryStringLength+1);}}while (serachLocation!=-1)if (serachLocation!=-1){var seperatorLocation=URLString.indexOf(\" & \");if (seperatorLocation==-1){returnValue=URLString.substr(queryStringLength+1);}else{returnValue=URLString.substring(queryStringLength+1,seperatorLocation);} }return returnValue;}");
            string ch = "";

            if (!my.is_string_like(URL, "ch="))
            {
                ch = "1";
            }
            else
            {
                ch = my.explode("-", my.explode("ch=", URL)[1])[0];//第幾回
            }
            //preScripts.Add("ch=" +ch);
            //merge all scripts
            List <string> AllJS = new List <string>();
            var           mjs   = my.explode("<script>", data);

            for (int i = 6; i < mjs.Count(); i++)
            {
                var _m = my.explode("</script>", mjs[i]);
                AllJS.Add(_m[0]);
            }
            //var mScripts = my.explode("<script>", data)[7];
            //string scripts = my.explode("</script>", mScripts)[0].Trim();
            string scripts = my.implode("\n\n ", AllJS);

            scripts = scripts.Replace("var pi=ch", "ch=" + ch + ";var pi=ch");
            //scripts = scripts.Replace("\n", " ").Replace("\r", " ");
            //echo("\nCounts:" + my.explode("<script>", data).Count().ToString() + "\n");
            //echo(scripts);
            //exit();
            scripts = scripts.Replace("document.getElementById(e)", "e");

            scripts = scripts.Replace("}var", "};var");
            //scripts = scripts.Replace("ge('TheImg').src=", "WWWWWTTTTTFFFFF=");
            scripts = scripts.Replace(").src=", ");WWWWWTTTTTFFFFF=");
            //scripts = scripts.Replace(";", ";\n");
            //scripts = scripts.Replace(";", ";\n");
            //scripts = scripts.Replace("adsbygoogle", "//adsbygoogle");
            preScripts.Add(scripts);
            preScripts.Add("ps+\"___\"+\"https:\"+WWWWWTTTTTFFFFF;");


            //preScripts.Add("swtvv;");
            string sc = my.implode("\n", preScripts);

            sc = sc.Replace("; ", "; \n");
            sc = sc.Replace("(adsbygoogl", "//(adsbygoogl");
            //echo(sc);
            //exit();

            sc = sc.Replace("if (localStorage.getItem(\"imgmode\")" + my.get_between(sc, "if (localStorage.getItem(\"imgmode\")", "document.getElementById(\"barcodeimg\");"), "");
            sc = sc.Replace("document.writeln(\"<scr" + my.get_between(sc, "document.writeln(\"<scr", "ipt>\");") + "ipt>\");", "");
            sc = sc.Replace("document.writeln(\"<scr" + my.get_between(sc, "document.writeln(\"<scr", "ipt>\");") + "ipt>\");", "");
            sc = sc.Replace("document.getElementById(\"barcodeimg\");", "");
            sc = sc.Replace("(function() {" + my.get_between(sc, "(function() {", "})();") + "})();", "");

            //my.file_put_contents("sc.txt", sc);
            string finalData = EvalJScript(sc).ToString().Trim();
            //echo(sc);
            //echo(finalData);
            //exit();
            var    m      = my.explode("___", finalData);
            int    pages  = Convert.ToInt32(m[0]);
            string output = "Totals:" + pages.ToString() + "\n";
            string t      = m[1].Replace("/001_", "/{PAGE}_");

            //echo(t);
            //exit();
            for (int i = 1; i <= pages; i++)
            {
                //取得 WWWWWTTTTTFFFFF=...... 至 '.jpg';
                //WWWWWTTTTTFFFFF='//img'+su(yvdnl, 0, 1)+'.8comic.com/'+su(yvdnl,1,1)+'/'+ti+'/'+iyjco+'/'+ nn(p)+'_'+su(qvjme,mm(p),3)+'.jpg';
                //string d = t.Replace("{PAGE}", i.ToString().PadLeft(3, '0'));
                //output += d + "\n";
                var imgPath = "\"https:\"+" + my.get_between(sc, ";WWWWWTTTTTFFFFF=", ";");
                //echo(imgPath);
                //exit();
                var _sc = sc + "\n" + imgPath.Replace("(p)", "(" + i + ")") + ";";
                output += EvalJScript(_sc).ToString() + "\n";
            }
            echo(output);
        }
Пример #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            button1.Text    = "載入中...";
            string URL = downloadURL.Text;

            if (!Regex.IsMatch(URL, @"^https://www.comico.com.tw/\d*/"))
            {
                MessageBox.Show("網址不對...");
                button1.Enabled = true;
                button1.Text    = "載入";
                return;
            }
            string orin_URL = URL;

            //從已知的 tabs 找 tooltips,如果一樣,就跳過,直接跳到那頁
            for (int i = 0, max_i = tabControl1.TabPages.Count; i < max_i; i++)
            {
                string tipname = tabControl1.TabPages[i].ToolTipText;
                if (tipname == orin_URL)
                {
                    tabControl1.SelectedIndex = i;
                    button1.Enabled           = true;
                    button1.Text = "載入";
                    return;
                }
            }


            string orin_data = my.b2s(my.file_get_contents(orin_URL));
            //my.file_put_contents(PWD + "\\log.txt", orin_data);

            string orin_NAME = my.get_between(orin_data, "<meta property=\"og:title\" content=\"", "|");

            orin_NAME = orin_NAME.Replace("。", "");
            URL       = URL.Replace("https://", "");
            var    m       = my.explode("/", URL);
            string id      = m[1];
            string jsonURL = "https://www.comico.com.tw/api/getArticleList.nhn";
            string data    = my.b2s(my.file_get_contents_post(jsonURL, "titleNo=" + id));
            //my.file_put_contents(PWD + "\\log.txt", data);
            var jd = my.json_decode(data);
            List <ConcurrentDictionary <string, string> > ldt = new List <ConcurrentDictionary <string, string> >();

            for (int i = 0; i < jd[0]["result"]["list"].Count(); i++)
            {
                var d = new ConcurrentDictionary <string, string>();
                d["URL"]     = jd[0]["result"]["list"][i]["articleDetailUrl"].ToString();
                d["NAME"]    = jd[0]["result"]["list"][i]["subtitle"].ToString();
                d["URL_IMG"] = jd[0]["result"]["list"][i]["imgUrl"].ToString();
                ldt.Add(d);
            }
            Console.WriteLine(my.json_encode(ldt));


            // Gets the controls collection for tabControl1.
            // Adds the tabPage1 to this collection.
            var tab = new TabPage("item_" + orin_NAME);

            tab.ToolTipText = orin_URL;

            DataGridView dgv = new DataGridView();

            //dgv.AutoGenerateColumns = false; //這啥
            dgv.AllowUserToAddRows = false;             //不能允許使用者自行調整
            dgv.RowHeadersVisible  = false;             //左邊空欄移除
            dgv.Dock                  = DockStyle.None; //自動展開到最大
            dgv.AllowDrop             = false;
            dgv.ReadOnly              = true;
            dgv.Name                  = "PAGE_" + tabControl1.TabPages.Count.ToString();
            SOURCES[dgv.Name]         = new ConcurrentDictionary <string, object>();
            SOURCES[dgv.Name]["NAME"] = orin_NAME;
            SOURCES[dgv.Name]["URL"]  = orin_URL;
            dgv.Width                 = 650;
            dgv.Height                = 500;
            //dgv.Columns.Add("ID", "序號");
            //dgv.Columns.Add("NAME", "話");
            //dgv.Columns.Add("URL", "URL");
            dgv.Location = new Point(0, 50);
            DataTable dtt = new DataTable();

            dtt.Columns.Add("ID");
            dtt.Columns.Add("NAME");
            dtt.Columns.Add("URL");
            dtt.Columns.Add("STATUS");
            for (int i = 0, max_i = ldt.Count; i < max_i; i++)
            {
                dtt.Rows.Add();
                int LAST_ID = dtt.Rows.Count - 1;
                dtt.Rows[LAST_ID]["ID"]     = (i + 1).ToString();
                dtt.Rows[LAST_ID]["NAME"]   = ldt[i]["NAME"];
                dtt.Rows[LAST_ID]["URL"]    = ldt[i]["URL"];
                dtt.Rows[LAST_ID]["STATUS"] = "待命";
            }
            dgv.DataSource         = dtt;
            SOURCES[dgv.Name]["回"] = dtt;

            //加一個標題
            var labelTitle = new System.Windows.Forms.Label();

            labelTitle.Text     = orin_NAME + " (共 " + ldt.Count.ToString() + " 回)";
            labelTitle.Width    = 650;
            labelTitle.Font     = new Font("微軟正黑體", 16);
            labelTitle.Location = new Point(0, 0);

            //加一個下載的鈕
            var btnRun = new System.Windows.Forms.Button();

            btnRun.Name = "goBtn - " + dgv.Name;

            btnRun.Text     = "開始下載";
            btnRun.Location = new Point(this.Width - btnRun.Width - 50, 0);
            btnRun.Click   += (object s, EventArgs ee) =>
            {
                //按鈕的程式
                //MessageBox.Show(dgv.Name);
                Button btn = s as Button;
                string key = my.explode(" - ", btn.Name)[1];
                switch (btn.Text)
                {
                case "開始下載":
                {
                    btn.Text = "下載中...(點了取消)";
                    SOURCES[key]["RUN_THREAD"] = new Thread(() => run(key, btn));
                    ((Thread)SOURCES[key]["RUN_THREAD"]).Start();
                }
                break;

                default:
                {
                    btn.Text = "開始下載";
                    if (SOURCES[key].Keys.Contains("RUN_THREAD") && SOURCES[key]["RUN_THREAD"] != null)
                    {
                        ((Thread)(SOURCES[key]["RUN_THREAD"])).Abort();
                    }
                }
                break;
                }
            };
            tab.Controls.Add(labelTitle);
            tab.Controls.Add(btnRun);
            tab.Controls.Add(dgv);
            tab.Text = dgv.Name;
            tabControl1.TabPages.Add(tab);

            for (int i = 0; i < dgv.Columns.Count - 1; i++)
            {
                dgv.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            }
            dgv.Columns[dgv.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

            for (int i = 0; i < dgv.Columns.Count; i++)
            {
                int colw = dgv.Columns[i].Width;
                dgv.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                dgv.Columns[i].Width        = colw;
            }
            button1.Enabled           = true;
            button1.Text              = "載入";
            tabControl1.SelectedIndex = tabControl1.TabPages.Count - 1;
        }