Beispiel #1
0
        /* indexPDF
         * indicizza le informazioni estratte dal file PDF
         */
        public bool indexPDF(page p, int pdfSize, string pdf2text)
        {
            string outStr;
            string sql;
            bool   ret;

            outStr  = "\n";
            outStr += " + Indexing PDF [ " + p.GenerateURL() + " ]\n";

            nsGlobalOutput.output.write(outStr);

            html htmp = new html();

            pdf2text = htmp.removeUnWantedChars(pdf2text);

            addContent2Index(p._hostID, p._hostname, p._page, p._title, p._anchorText, p._depthLevel, pdf2text, pdf2text);

            sql = "INSERT INTO pdf (host_id, filename, pdf_size, pdf_text) " +
                  "VALUES(" + p._hostID + ", " +
                  "'" + myMySQLEscapeString(p._page) + "', " +
                  "'" + pdfSize + "', " +
                  "'" + myMySQLEscapeString(pdf2text) + "') ";


            GlobalVars.threadsVars.mutexMySQLPageList.WaitOne();
            try
            {
                ret = GlobalVars.mysqlConn.connPageList.executeSQLQuery(sql);
            }
            catch (Exception e)
            {
                nsGlobalOutput.output.write("SQL Error: " + e.Message + "\n\nSQL: -===[\n" + sql.Substring(0, 1000) + "\n]===-\n\n");
                ret = false;
            }
            finally
            {
                GlobalVars.threadsVars.mutexMySQLPageList.ReleaseMutex();
            }

            return(ret);
        }
Beispiel #2
0
        public bool indexThisPage(page p, html h)
        {
            // se negli argomenti è specificato di non indicizzare: esci
            if (GlobalVars.args.noIndex)
            {
                return(false);
            }

            string text2Index = string.Empty;

            try
            {
                // controlla che le regex permettano l'indicizzazione di questa pagina
                // 1. stiamo usano hostlist_extras?
                if (GlobalVars.limits.useHostlist_Extras_limits == true)
                {
                    // 2. c'è una regex valida per le inclusioni?
                    if (GlobalVars.limits.he_regex_include_pages != "")
                    {
                        Regex testIncludePageRegex = new Regex(GlobalVars.limits.he_regex_include_pages, RegexOptions.IgnoreCase);
                        // se la pagina corrente NON VERIFICA l'espressione regolare: non indicizzare
                        if (!testIncludePageRegex.IsMatch(p._page))
                        {
                            return(false);
                        }
                    }

                    // 3. c'è una regex valida per le esclusioni?
                    if (GlobalVars.limits.he_regex_exclude_pages != "")
                    {
                        Regex testExcludePageRegex = new Regex(GlobalVars.limits.he_regex_exclude_pages, RegexOptions.IgnoreCase);
                        // se la pagina corrente VERIFICA l'espressione regolare: non indicizzare
                        if (testExcludePageRegex.IsMatch(p._page))
                        {
                            return(false);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                nsGlobalOutput.output.write("\n\n + Error while parsing hostlist_extras regex: " + e.Message + "\n\n");
            }

            if (p.isValidPage && h.HTML != "")
            {
                if (h.contentType.StartsWith("text/html", StringComparison.CurrentCultureIgnoreCase))
                {
                    text2Index = h.UnHTML(h.HTML);
                }
                else if (h.contentType.StartsWith("text/", StringComparison.CurrentCultureIgnoreCase))
                {
                    // indicizza il testo (es.: *.txt; *.c; *.h)
                    text2Index = h.removeUnWantedChars(h.HTML).Trim();
                }
                else
                {
                    return(false);
                }

                return(addContent2Index(p._hostID, p._hostname, p._page, p._title, p._anchorText, p._depthLevel, text2Index, h.HTML));
            }
            return(false);
        }