Пример #1
0
 public void logError(string data)
 {
     try
     {
         create_log_dir();
         my.file_put_contents(LOG_PATH + "\\" + my.date("Y-m-d") + ".txt", my.date("Y-m-d H:i:s") + ":\r\n" + data + "\r\n", true);
     }
     catch
     {
     }
 }
Пример #2
0
 public void logError(string data)
 {
     try
     {
         if (!my.is_dir(LOG_PATH))
         {
             my.mkdir(LOG_PATH);
         }
         my.file_put_contents(LOG_PATH + "\\" + my.date("Y-m-d") + ".txt", my.date("Y-m-d H:i:s") + ":\r\n" + data + "\r\n", true);
     }
     catch
     {
     }
 }
Пример #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
        static void Main(string[] args)
        {
            //列出所有檔案
            myziplib.myziplib myzip       = new myziplib.myziplib();
            string            zipFilePath = pwd() + "\\test.zip";
            var p      = myzip.getZipFileLists(zipFilePath);
            var output = my.json_format_utf8(my.json_encode(p));

            Console.WriteLine(output);

            //取得資料
            byte[] obyte       = myzip.getZipFileData(zipFilePath, "test/folder1/images.jpg");
            string output_file = pwd() + "\\output.jpg";

            my.file_put_contents(output_file, obyte);
            Array.Clear(obyte, 0, obyte.Length);
            obyte = null;
        }
Пример #5
0
        public void run(string key, Button btn)
        {
            //Thread.Sleep(5000);
            //MessageBox.Show(key);
            DataGridView c = this.Controls.Find(key, true)[0] as DataGridView;
            //MessageBox.Show(c.Rows.Count.ToString());
            DataTable dt = ((DataTable)(SOURCES[key]["回"]));

            for (int i = 0, max_i = c.Rows.Count; i < max_i; i++)
            {
                //下載單頁
                Console.WriteLine(my.json_encode(dt.Rows[i]));
                Dictionary <string, object> d = new Dictionary <string, object>();
                //From : https://stackoverflow.com/questions/15049877/getting-webbrowser-cookies-to-log-in
                //https://stackoverflow.com/questions/9048922/c-sharp-invalidcastexception-when-trying-to-access-webbrowser-control-from-tim
                //d["webBrowser"] = getBrowser();
                //wB.Url = new System.Uri(dt.Rows[i]["URL"].ToString(), System.UriKind.Absolute);
                //Thread.Sleep(500);
                //d["cookie_domain"] = wBDomain;
                //d["cookie_data"] = wBCookie;
                string data = my.b2s(my.file_get_contents_post(dt.Rows[i]["URL"].ToString(), "", d));
                //取得漫畫照片範圍
                data = my.get_between(data, "var cmnData = ", "</script>");
                data = data.Trim();
                //移除最後一個;
                if (data.Substring(data.Length - 1, 1) == ";")
                {
                    data = data.Substring(0, data.Length - 1);
                }
                data  = data.Trim();
                data += "3WA超強";
                data  = my.get_between(data, "imageData:", "}3WA超強");
                var pics = my.json_decode(data);

                WebBrowser newWB = getBrowser();
                TabPage    tp    = tabControl1.TabPages[key];
                //newWB.Location = new Point(500, 0);
                //newWB.Width = 1024;
                //newWB.Height = 768;
                //tp.Controls.Add(newWB);
                //copyControl(wB, newWB);
                newWB.Url = new System.Uri(dt.Rows[i]["URL"].ToString(), System.UriKind.Absolute);
                newWB.WebBrowserShortcutsEnabled = true;
                //newWB.ScriptErrorsSuppressed = false;


                newWB.ScriptErrorsSuppressed = true;


                Func <string, string> Eval = (script) =>
                {
                    return(newWB.Document.InvokeScript("eval", new string[] {
                        "(function() { return " + script + "; })()"
                    }).ToString());
                };
                Func <string, string> runSC = (script) =>
                {
                    try
                    {
                        return(newWB.Document.InvokeScript("eval", new string[] {
                            "(function() { " + script + " })()"
                        }).ToString());
                    }
                    catch
                    {
                        return("");
                    }
                };

                newWB.DocumentCompleted -= wB_DocumentCompleted;
                newWB.DocumentCompleted += wB_DocumentCompleted;

                //感覺不適合下載圖
                break;
                for (int j = 0, max_j = pics[0].Count(); j < max_j; j++)
                {
                    Console.WriteLine("PIC[0][" + j.ToString() + "]: " + pics[0][j].ToString());
                    string expires = my.get_between(pics[0][j].ToString(), "Expires=", "&");
                    pics[0][j]         = pics[0][j].ToString().Replace(expires, (Convert.ToInt64(my.time()) + 2).ToString());
                    d["cookie_domain"] = ".comico.com.tw";
                    wBCookie           = wBCookie.Replace("appier_pv_counterqvJaMzdQzyXvi7N=8", "appier_pv_counterqvJaMzdQzyXvi7N=1");
                    wBCookie           = wBCookie.Replace("appier_pv_counterTw501dpRLjrYXae=7", "appier_pv_counterTw501dpRLjrYXae=1");
                    d["cookie_data"]   = wBCookie;
                    d["referer"]       = dt.Rows[i]["URL"].ToString();
                    d["headers"]       = new List <string>();
                    d["accept"]        = "image/webp,*/*";
                    ((List <string>)(d["headers"])).Add("TE: Trailers");
                    //((List<string>)(d["headers"])).Add("Accept: image/webp,*/*");
                    ((List <string>)(d["headers"])).Add("Accept-Language: zh-TW,zh;q=0.8,en-US;q=0.5,en;q=0.3");
                    ((List <string>)(d["headers"])).Add("Accept-Encoding: gzip, deflate, br");
                    byte[] p = my.file_get_contents_post(pics[0][j].ToString(), "", d);
                    my.file_put_contents(PWD + "\\" + j + ".png", p);
                    Array.Clear(p, 0, p.Length);
                    break;
                }
                //my.file_put_contents(PWD + "\\ok.txt", data);
                break;
            }

            //finish
            UpdateUIText("開始下載", btn);
        }