updated view_count
This commit is contained in:
@@ -35,16 +35,18 @@ def blog(request):
|
||||
|
||||
# incrementer le compteur de vues
|
||||
client_addr = request.client_addr
|
||||
today = datetime.datetime.now()
|
||||
today_hour = datetime.datetime.now().strftime("%m/%d/%Y %H")
|
||||
if entry.view_date :
|
||||
last_view = entry.view_date[:13]
|
||||
else:
|
||||
last_view = 'None'
|
||||
|
||||
if client_addr != '127.0.0.1' and entry.view_ip != client_addr and last_view != str(today)[:13] and \
|
||||
# import pdb;pdb.set_trace()
|
||||
# if client_addr != '127.0.0.1' :
|
||||
if entry.view_ip != client_addr or last_view != today_hour and \
|
||||
request.user_agent.find("spider") == -1 and request.user_agent.find("crawler") == -1 and \
|
||||
request.user_agent.find("bot") == -1 and request.user_agent.find("+http") == -1:
|
||||
update_view_counter(request, blog_id, client_addr, today)
|
||||
update_view_counter(request, blog_id, client_addr, today_hour)
|
||||
|
||||
|
||||
return {
|
||||
@@ -326,11 +328,12 @@ def maintenance(request):
|
||||
#
|
||||
if 'form.submitted' in request.params:
|
||||
# lire le fichier logs.txt
|
||||
filename = os.path.join('/Users/phuoc/pyramid/cao_sunyata/', 'logs.txt')
|
||||
filename = os.path.join('/Users/phuoc/pyramid/cao_sunyata/', 'access_sunyata.txt')
|
||||
with open(filename) as f:
|
||||
n = 0
|
||||
for line in f:
|
||||
cols = line.split('|')
|
||||
# import pdb;pdb.set_trace()
|
||||
user_date = cols[0]
|
||||
user_addr = cols[1]
|
||||
path = cols[2]
|
||||
|
||||
Reference in New Issue
Block a user