-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcvCMS.rpy
101 lines (85 loc) · 2.58 KB
/
cvCMS.rpy
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
import sys
import urllib.request
import urllib.parse
import json
import os, sys
import fnmatch, re
import glob
import smtplib
class CvMain():
#options
mainDir = 'E:\worck\cvSMC\test\\'
#max 9
investments = 3
def send_mail(self, txtparam):
print("Send a report by email...")
fromaddr = 'Yandex email'
toaddr = 'mail where to send the report'
subj = 'Notification from system'
msg_txt = 'Notice:\n\n ' + txtparam + '\n\nBye!' #
msg = "From: %s\nTo: %s\nSubject: %s\n\n%s" % ( fromaddr, toaddr, subj, msg_txt)
username = 'mats-aerozol'
password = 'your password'
server = smtplib.SMTP('smtp.yandex.ru:587')
server.set_debuglevel(1);
server.starttls()
server.login(username,password)
server.sendmail(fromaddr, toaddr, msg)
server.quit()
print("Done.")
class Cvwp(CvMain):
updateUrl = "http://api.wordpress.org/core/version-check/1.7/"
def wp_get_currenst_version(self):
response = urllib.request.urlopen(self.updateUrl)
json = response.read().decode("utf-8")
checVersion = json.loads(json)
return(checVersion['offers'][0]["current"])
def find_files(self, filename):
print("Find files CMS...")
listFiles = [];
investmentsDir = "*\\"
i=0
while self.investments > i:
investmentsDir = investmentsDir + investmentsDir
listFilesDir = glob.glob(self.mainDir+investmentsDir+filename+'.php')
i +=1
if (listFilesDir.__len__() > 0):
listFiles += listFilesDir
return listFiles
def get_file_version(self, file):
file = open(file, 'r')
contentFile = file.read()
version = re.findall('\$wp_version\s*=\s*([^;]*)', contentFile)
file.close()
version = version[0].replace("'","")
return version
def check_file_version(self, listFiles):
print("Build a list of non-valid sites...")
curent_version_wp = self.wp_get_currenst_version();
print("Curent version CMS: " + curent_version_wp)
viewString = ""
i=0
while f.__len__()>i:
if (self.get_file_version(f[i]) != curent_version_wp):
print(self.get_file_version(f[i])+" "+ curent_version_wp)
viewString = viewString + "\n" + listFiles[i].replace(self.mainDir, "") +" --> "+self.get_file_version(f[i])
i+=1
print("Done.")
return viewString
class CvJM(CvMain):
updateUrl = "http://update.joomla.org/core/list.xml"
def wp_get_currenst_version(self):
response = urllib.request.urlopen(self.updateUrl)
xmldoc = response.read().decode("utf-8")
print(xmldoc)
#
# controller
#
# cvwp = Cvwp()
# f = cvwp.find_files("/wp-includes/version")
# print(f)
# novalide = cvwp.check_file_version(f)
# print(novalide)
# cvwp.send_mail(novalide)
cvjm = CvJM()
cvjm.wp_get_currenst_version();