-
Notifications
You must be signed in to change notification settings - Fork 2
/
new_files.cgi
executable file
·117 lines (107 loc) · 3.32 KB
/
new_files.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env python
# vim:fileencoding=utf-8:syntax=python:nomodified
import cgitb
cgitb.enable()
import cgi
import sys
import time
import os
from dbmanager import QueryMaker
from resources import Query
print "Content-type: text/html;charset=utf-8"
print
outputhead = """
<html>
<head>
<title>ninuXoo!</title>
</head>
<link rel="stylesheet" href="/ninuxoo/ninuxoo.css" type="text/css" />
<link rel="search" type="application/opensearchdescription+xml" title="ninuxoo" href="/ninuxoo/osd.xml" />
<script src="/ninuxoo/js/jquery-1.7.2.min.js"></script>
<script src="/ninuxoo/js/results.js"></script>
<body>
<div id="navmenu">
<ul>
<li><a href="/">Cerca</a></li>
<li><a href="/cgi-bin/new_files.cgi">Novità</a></li>
<li><a href="/cgi-bin/browse_share.cgi">Files</a></li>
<li><a href="/cgi-bin/proxy_wiki.cgi?url=Elenco_Telefonico_rete_VoIP_di_ninux.org">VoIP</a></li>
<li><a href="http://10.168.177.178:8888/">JukeBox</a></li>
<li><a href="http://10.162.0.85/">WebMail</a></li>
<li><a href="http://blog.ninux.org">Blog</a></li>
<li><a href="http://wiki.ninux.org">Wiki</a></li>
</ul>
</div>
<div class="logo">
<a href="/cgi-bin/ninuxoo.cgi">
<img src="/ninuxoo/ninuxoo.png" border="0" alt="ninuXoo!"/>
</a>
</div>
<br />
<br />
<div id="result">
"""
outputtail = """
</div>
</body>
</html>
"""
print outputhead
qm = QueryMaker('localhost','ninuu','ciaociao','ninuxuu')
resp = qm.getNewFiles(2000)
smbschema = "smb://"
schoice = "nonverbose"
def ultrie(resourcetrie, resuri=""):
res = res1 = ""
newli = False
fork = False
for child in resourcetrie.children.values():
if child.nres < resourcetrie.nres:
fork = True
if fork and (not resourcetrie.label.startswith('smb:') and not resourcetrie.label.startswith('ftp:')):
res1 += "<li class='label'>"
res1 += resuri + "/"
res1 += "</li>\n"
newli = True
if len(resourcetrie.resources):
if not fork:
res1 += "<li class='label'>"
res1 += resuri
res1 += "/ "
res1 += "</li>\n"
newli = True
resuri = ""
res1 += "<ul>\n"
for resource in resourcetrie.resources:
if schoice == "verbose":
res1 += '<li class="result">%s [%s]</li>\n' % (resource.getFilename(), resource.firstseen)
else:
fileuri = resource.uri.replace("smb://", smbschema, 1)
res1 += '<li class="result"><a href="%s">%s</a></li>\n' % (fileuri, resource.getFilename())
res1 += "</ul>\n"
for child in resourcetrie.children.values():
if not child.label.startswith('smb:') and not child.label.startswith('ftp:'):
if child.nres < resourcetrie.nres:
res1 += ultrie(child, "/" + child.label)
else:
res1 += ultrie(child, resuri + "/" + child.label)
else:
res1 += ultrie(child, "//")
if newli:
res = "<ul>" + res1 + "</ul>\n"
else:
res = res1
return res
for i in range(len(resp.resultlistlist)):
rlist = resp.resultlistlist[i]
if len(rlist) > 0:
csstitleclass = 'exactrestitle'
cssclass = 'exactresults'
print "<a name='res%d' class='%s'>%s</a>" %(i, csstitleclass, resp.getLabels()[i])
print "<ul class='%s'>" % cssclass
resourcetrie = rlist.getTrie()
resourcetrie.prune()
print ultrie(resourcetrie)
print "</ul>"
print "<div class='bottomtoplink'><span class='uarr'>↑</span><a href='#rindex'>TOP</a></div>"
print outputtail