Python: Print Result Only
<pre><code>import os
def find_method(name):
        i = 0
        found_dic = { "$_GET":[], "$_POST":[], "include":[], "require":[], "mysql_query":[], "SELECT":[], "system":[], "exec":[], "passthru":[], "readfile":[], "fopen":[], "eval":[] }

        for x in file(name, "r"):
                i += 1
                for key in found_dic:
                        if x.strip().find(key) != -1:
                                found_dic[key].append("LINE:"+str(i)+":" + x.strip())

        print "="*20, name, "="*20
        for key in found_dic:
                if found_dic[key]:
                        print " ", "-"*10, key, "-"*10
                        for r in found_dic[key]:
                               print "  ",r

def search(dirname):
        flist = os.listdir(dirname)
        for f in flist:
                next = os.path.join(dirname, f)
                if os.path.isdir(next):
                        search(next)
                else:
                        doFileWork(next)

def doFileWork(filename):
        ext = os.path.splitext(filename)[-1]
        #if ext == '.html': print filename
        if ext == '.php':
               # print "target:" + filename
                find_method(filename)
</code></pre>

<ol>
<li><p>how can I print only results. its prints all name of file eventhough file doesn't have any result in it. I want to make print file name if its has any result in it</p></li>
<li><p>this is about searching word, but it shows every word include like (seaching for include) then it also finds word in sentence and prints all sentence I want to find only word "include" not included in sentence. it's really hard to explain.. I hope to understand.. srry</p></li>
</ol>
