public void ObtainPHPFileFunctions(DatabaseAccess JavaDBAccess, String TargetPHPFileSelected) {
        int TARGET_PHP_FILES_ID = 0, VariableLocation = 0, StartCharTargetLine = 0, EndCharTargetLine = 0, StartTargetLine = 0, EndTargetLine = 0;

        PreparedStatement ps = null;
        String PHPFileText = "", PHPFileTextClean = ""; //The text of the PHP file where we want to inject the vulnerabilities

        Matcher existMatch = null;
        Pattern p = null;
        int existMatchStart = 0, existMatchEnd = 0;
        ResultSet rs = null;

        int count = 0;
        String TargetFunction = "", RegExpText = "";
        Boolean CaseSensitiveOption = false;

        Connection conn = null;

        try {
            if ((conn = JavaDBAccess.setConn()) != null) {
                System.out.println("Connected to database " + JavaDBAccess.getDatabaseName());
            } else {
                throw new Exception("Not connected to database " + JavaDBAccess.getDatabaseName());
            }

            conn.setAutoCommit(false);

            // Start a transaction by inserting a record in the TARGET_PHP_FILES table
            ps = conn.prepareStatement("SELECT ID,TEXT, CLEANED_TEXT FROM TARGET_PHP_FILES WHERE PATH = ?");
            ps.setString(1, TargetPHPFileSelected);
            rs = ps.executeQuery();

            rs.next();
            TARGET_PHP_FILES_ID = rs.getInt(1);
            System.out.println("Chave usada: " + TARGET_PHP_FILES_ID);
            /*
            java.io.InputStream ip = rs.getAsciiStream(2);
            int c = ip.read();
            PHPFileTextClean = "";
            while (c > 0) {
            //            System.out.print((char) c);
            
            PHPFileTextClean = PHPFileTextClean + (char) c;
            c = ip.read();
            }
             */
            PHPFileText = rs.getString("TEXT");
            PHPFileTextClean = rs.getString("CLEANED_TEXT");
            rs.close();

            try {
                // Start a transaction by inserting a record in the TARGET_PHP_FILES_FUNCTIONS table
                ps = conn.prepareStatement("INSERT INTO TARGET_PHP_FILES_FUNCTIONS VALUES (0,NULL,'MAIN BODY',0,0,0,0)");
                ps.executeUpdate();
            } catch (Throwable e) { //When the function already exists. No problem
            }

            // Start a transaction by inserting a record in the TARGET_PHP_FILES_FUNCTIONS table
            ps = conn.prepareStatement("DELETE FROM TARGET_PHP_FILES_FUNCTIONS WHERE TARGET_PHP_FILE=?");
            ps.setInt(1, TARGET_PHP_FILES_ID);
            ps.executeUpdate();

            CaseSensitiveOption = false;
            RegExpText = "\\bfunction\\b\\s+[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*"; // using the regex string: \bfunction\b\s+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]* to find all the PHP functions
            // The function name part of the regex string was found at http://pt2.php.net/manual/en/language.functions.php

            if (CaseSensitiveOption) {
                p = Pattern.compile(RegExpText);
            } else {
                p = Pattern.compile(RegExpText, Pattern.CASE_INSENSITIVE);
            }

            existMatch = p.matcher(PHPFileTextClean);

            while (existMatch.find()) {
                existMatchStart = existMatch.start();
                existMatchEnd = existMatch.end();
//                System.out.println(SubjectString.getText(existMatch.start(), existMatch.end()-existMatch.start()));
                //TargetFunction stores the function
                TargetFunction = PHPFileText.substring(existMatchStart, existMatchEnd).trim();
                TargetFunction = TargetFunction.substring(8, TargetFunction.length()).trim();
                StartCharTargetLine = FileMatchStartLine(PHPFileText, existMatchStart + 1);
                EndCharTargetLine = SearchEndChar(PHPFileText, existMatchStart, '{');
                EndCharTargetLine = SearchEndChar(PHPFileText, EndCharTargetLine + 1, '}');
                StartTargetLine = FileMatchLine(PHPFileText, existMatchStart + 1);
                EndTargetLine = FileMatchLine(PHPFileText, EndCharTargetLine);

                // Start a transaction by inserting a record in the TARGET_PHP_FILES_FUNCTIONS table
                ps = conn.prepareStatement("INSERT INTO TARGET_PHP_FILES_FUNCTIONS VALUES (DEFAULT,?,?,?,?,?,?)");
                ps.setInt(1, TARGET_PHP_FILES_ID);
                ps.setString(2, TargetFunction);
                ps.setInt(3, StartCharTargetLine);
                ps.setInt(4, EndCharTargetLine);
                ps.setInt(5, StartTargetLine);
                ps.setInt(6, EndTargetLine);
                ps.executeUpdate();
            }
            ps.close();
            conn.commit();
            conn.close();

        } catch (Throwable e) {
            System.out.println("Errors in ObtainPHPFileFunctions!");
            System.out.println("exception thrown:");

            if (e instanceof SQLException) {
                JavaDBAccess.printSQLError((SQLException) e);
            } else {
                e.printStackTrace();
            }
        }

    }