| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454 | 
							- from django.http import HttpResponse
 
- from Controller import OTAEquipment
 
- from django.views.decorators.csrf import csrf_exempt
 
- from django.views.generic import TemplateView
 
- from django.utils.decorators import method_decorator
 
- from Ansjer import config as api_settings
 
- from Service.ModelService import ModelService
 
- import time,os
 
- from Object.ResponseObject import ResponseObject
 
- from Object.TokenObject import TokenObject
 
- from Ansjer.config import BASE_DIR, CONFIG_INFO, CONFIG_CN
 
- def StatisticsData(request):
 
-     print('------request------')
 
-     print(request)
 
-     print('---------------')
 
-     try:
 
-         real_ip = request.META['HTTP_X_FORWARDED_FOR']
 
-         clientIP = real_ip.split(",")[0]
 
-     except:
 
-         try:
 
-             clientIP = request.META['REMOTE_ADDR']
 
-         except Exception as e:
 
-             clientIP = ''
 
-     nowTime = time.strftime('%Y-%m-%d', time.localtime(time.time()))
 
-     print(u'当前用户: %s , 访问时间: %s' % (clientIP, nowTime))
 
-     print(u'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
 
-     for cookKey, cookValue in request.COOKIES.items():
 
-         print("COOKIES:", cookKey, cookValue)
 
-     for sessionKey, sessionValue in request.session.items():
 
-         print("session:", sessionKey, sessionValue)
 
-     print('HTTP_COOKIE', request.META.get('HTTP_COOKIE', 'unknown'))
 
-     print('CSRF_COOKIE', request.META.get('CSRF_COOKIE', 'unknown'))
 
-     print('user', request.user)
 
-     print(u'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
 
-     # print("body:", request.body)
 
-     print('path', request.path)
 
-     print('path_info', request.path_info)
 
-     print('encoding', request.encoding)
 
-     print('resolver_match', request.resolver_match)
 
-     for fileKey, fileValue in request.FILES.items():
 
-         print("FILES:", fileKey, fileValue)
 
-     #print('META', request.META)
 
-     print(u'******************************************************')
 
-     print('DOCUMENT_ROOT', request.META.get('DOCUMENT_ROOT', 'unknown'))
 
-     print('QUERY_STRING: ', request.META.get('QUERY_STRING', 'unknown'))
 
-     print('REMOTE_ADDR', request.META.get('REMOTE_ADDR', 'unknown'))
 
-     print('HTTP_HOST', request.META.get('HTTP_HOST', u'unknown'))
 
-     print('HTTP_REFERER', request.META.get('HTTP_REFERER', 'unknown'))
 
-     print('HTTP_COOKIE', request.META.get('HTTP_COOKIE', 'unknown'))
 
-     print('CSRF_COOKIE', request.META.get('CSRF_COOKIE', 'unknown'))
 
-     print('HTTP_CONNECTION', request.META.get('HTTP_CONNECTION', 'unknown'))
 
-     print('wsgi.errors', request.META.get('wsgi.errors', 'unknown'))
 
-     print('mod_wsgi.application_group', request.META.get('mod_wsgi.application_group', 'unknown'))
 
-     print('mod_wsgi.callable_object', request.META.get('mod_wsgi.callable_object', 'unknown'))
 
-     print('mod_wsgi.listener_host', request.META.get('mod_wsgi.listener_host', 'unknown'))
 
-     print('mod_wsgi.listener_port', request.META.get('mod_wsgi.listener_port', 'unknown'))
 
-     print('mod_wsgi.process_group', request.META.get('mod_wsgi.process_group', 'unknown'))
 
-     print('mod_wsgi.reload_mechanism', request.META.get('mod_wsgi.reload_mechanism', 'unknown'))
 
-     print('mod_wsgi.script_reloading', request.META.get('mod_wsgi.script_reloading', 'unknown'))
 
-     print('mod_wsgi.version', request.META.get('mod_wsgi.version', 'unknown'))
 
-     print('PATH', request.META.get('PATH', 'unknown'))
 
-     print('PATH_INFO', request.META.get('PATH_INFO', 'unknown'))
 
-     print('PATH_TRANSLATED', request.META.get('PATH_TRANSLATED', 'unknown'))
 
-     print('QUERY_STRING', request.META.get('QUERY_STRING', 'unknown'))
 
-     print('QUERY_STRING', request.META.get('REMOTE_ADDR', 'unknown'))
 
-     print('REMOTE_PORT', request.META.get('REMOTE_PORT', 'unknown'))
 
-     print('REQUEST_METHOD', request.META.get('REQUEST_METHOD', 'unknown'))
 
-     print('REQUEST_URI', request.META.get('REQUEST_URI', 'unknown'))
 
-     print('SCRIPT_FILENAME', request.META.get('SCRIPT_FILENAME', 'unknown'))
 
-     print('SCRIPT_NAME', request.META.get('SCRIPT_NAME', 'unknown'))
 
-     print('SERVER_ADDR', request.META.get('SERVER_ADDR', 'unknown'))
 
-     print('SERVER_ADMIN', request.META.get('SERVER_ADMIN', 'unknown'))
 
-     print('SERVER_NAME', request.META.get('SERVER_NAME', 'unknown'))
 
-     print('SERVER_PORT', request.META.get('SERVER_PORT', 'unknown'))
 
-     print('SERVER_PROTOCOL', request.META.get('SERVER_PROTOCOL', 'unknown'))
 
-     print('SERVER_SIGNATURE', request.META.get('SERVER_SIGNATURE', 'unknown'))
 
-     print('SERVER_SOFTWARE', request.META.get('SERVER_SOFTWARE', 'unknown'))
 
-     print('wsgi.input', request.META.get('wsgi.input', 'unknown'))
 
-     print('wsgi.multiprocess', request.META.get('wsgi.multiprocess', 'unknown'))
 
-     print('wsgi.multithread', request.META.get('wsgi.multithread', 'unknown'))
 
-     print('wsgi.run_once', request.META.get('wsgi.run_once', 'unknown'))
 
-     print('wsgi.url_scheme', request.META.get('wsgi.url_scheme', 'unknown'))
 
-     print('wsgi.version', request.META.get('wsgi.version', 'unknown'))
 
-     print('get_host', request.get_host())
 
-     print('get_full_path', request.get_full_path())
 
-     print('build_absolute_uri', request.build_absolute_uri())
 
-     print('is_secure', request.is_secure())
 
-     print('is_ajax', request.is_ajax())
 
-     print(u'******************************************************')
 
-     print('CONTENT_LENGTH: ', request.META.get('CONTENT_LENGTH', 'unknown'))
 
-     print('CONTENT_TYPE', request.META.get('CONTENT_TYPE', 'unknown'))
 
-     print('HTTP_ACCEPT', request.META.get('HTTP_ACCEPT', 'unknown'))
 
-     print('HTTP_ACCEPT_ENCODING', request.META.get('HTTP_ACCEPT_ENCODING', 'unknown'))
 
-     print('REMOTE_HOST', request.META.get('REMOTE_HOST', 'unknown'))
 
-     print('REMOTE_USER', request.META.get('REMOTE_USER', 'unknown'))
 
-     print('REQUEST_METHOD', request.META.get('REQUEST_METHOD', 'unknown'))
 
-     print('SERVER_NAME', request.META.get('SERVER_NAME', 'unknown'))
 
-     print('SERVER_PORT', request.META.get('SERVER_PORT', 'unknown'))
 
-     print('HTTP_USER_AGENT', request.META.get('HTTP_USER_AGENT', 'unknown'))
 
-     print('HTTP_AUTHORIZATION', request.META.get('HTTP_AUTHORIZATION', b'unknown'))
 
- class HelpView(TemplateView):
 
-     '''
 
-     帮助说明,包括版本信息,帮助文件等
 
-     '''
 
-     @method_decorator(csrf_exempt)
 
-     def dispatch(self, *args, **kwargs):
 
-         return super(HelpView, self).dispatch(*args, **kwargs)
 
-     def get(self, request, *args, **kwargs):
 
-         reInfoType = request.GET.get('reInfoType', None)
 
-         token = request.GET.get('token', None)
 
-         return self.getRequestInfo(reInfoType,token)
 
-     def post(self, request, *args, **kwargs):
 
-         reInfoType = request.POST.get('reInfoType', None)
 
-         token = request.POST.get('token', None)
 
-         return self.getRequestInfo(reInfoType,token)
 
-     def getRequestInfo(self, reInfoType,token):
 
-         response = ResponseObject()
 
-         if reInfoType is not None and token is not None:
 
-             tko = TokenObject(token)
 
-             response.lang = tko.lang
 
-             if tko.code == 0:
 
-                 userID = tko.userID
 
-                 own_permission = ModelService.check_perm(userID=userID, permID=30)
 
-                 if own_permission is True:
 
-                     if reInfoType == 'version':
 
-                         return self.readInfo(response)
 
-                     elif reInfoType == 'requirements':
 
-                         return self.requirementsInfo(response)
 
-                     elif reInfoType == 'helpfile':
 
-                         return self.getHelpCHM(response)
 
-                     else:
 
-                         return response.json(444)
 
-                 else:
 
-                     return response.json(404)
 
-             else:
 
-                 return response.json(tko.code)
 
-         else:
 
-             return response.json(800,'reInfoType','reInfoType')
 
-     def readInfo(self,response):
 
-         verfilePath = '/'.join((api_settings.BASE_DIR, 'static/Help/')).replace('\\', '/') + 'version.txt'
 
-         if os.path.isfile(verfilePath):
 
-             file = open(verfilePath, encoding='utf-8')
 
-             versionStr = ''
 
-             for line in file:
 
-                 versionStr += line
 
-             return response.json(0,{'versioninfo':versionStr})
 
-         else:
 
-             return response.json(701)
 
-     def requirementsInfo(self,response):
 
-         requirementsPath = '/'.join((api_settings.BASE_DIR, 'requirements.txt')).replace('\\', '/')
 
-         print(requirementsPath)
 
-         if os.path.isfile(requirementsPath):
 
-             file = open(requirementsPath, encoding='utf-8')
 
-             requirementsStr = ''
 
-             for line in file:
 
-                 requirementsStr += line
 
-             return response.json(0,{'requirementsinfo': requirementsStr})
 
-         else:
 
-             return response.json(701)
 
-     def getHelpCHM(self,response):
 
-         verHelpCHM = '/'.join((api_settings.BASE_DIR, 'static/Help/')).replace('\\', '/') + 'AnsjerHelp.CHM'
 
-         print(verHelpCHM)
 
-         if os.path.isfile(verHelpCHM):
 
-             return OTAEquipment.downloadUrl(fileType='CHM', fileCode='', fileVersion='', fileName=verHelpCHM)
 
-         else:
 
-             return response.json(code=701)
 
- def upload_help_chm(request):
 
-     token = request.POST.get('token', None)
 
-     response = ResponseObject()
 
-     if token is not None:
 
-         tko = TokenObject(token)
 
-         response.lang = tko.lang
 
-         if tko.code == 0:
 
-             userID = tko.userID
 
-             own_permission = ModelService.check_perm(userID=userID, permID=30)
 
-             if own_permission is True:
 
-                 f = request.FILES.get('file', None)
 
-                 path = os.path.join(BASE_DIR, 'static/Help/AnsjerHelp.CHM')
 
-                 try:
 
-                     if os.path.exists(path):
 
-                         os.remove(path)
 
-                     with open(path, 'wb+') as destination:
 
-                         for chunk in f.chunks():
 
-                             destination.write(chunk)
 
-                 except Exception as e:
 
-                     print('error:' + repr(e))
 
-                     return response.json(700,{'details': repr(e)})
 
-                 return response.json(0)
 
-             else:
 
-                 return response.json(404)
 
-         else:
 
-             return response.json(tko.code)
 
-     else:
 
-         return response.json(309)
 
- @csrf_exempt
 
- def errorPath(request, **kwargs):
 
-     html = """
 
-     <!DOCTYPE html>
 
- <html lang="en">
 
- <head>
 
-     <meta charset="UTF-8">
 
-     <meta http-equiv="X-UA-Compatible" content="IE=edge">
 
-     <meta name="viewport" content="width=device-width, initial-scale=1.0">
 
-     <title>珠海安士佳电子有限公司</title>
 
-     <link rel="stylesheet" href="index.css" </head>
 
-     <body>
 
-         <div class="header con">
 
-             <div class="photo"></div>
 
-             <div class="headerlist">
 
-                 <ul>
 
-                     <li><a class="active">帮助中心</a></li>
 
-                     <li><a>售后服务</a></li>
 
-                 </ul>
 
-                 <div class="serch">
 
-                     <input type="text" placeholder="搜索">
 
-                 </div>
 
-             </div>
 
-         </div>
 
-         <div class="nav">
 
-             <ul class="con">
 
-                 <li>首页</li>
 
-                 <li>产品类目</li>
 
-                 <li>热卖商品</li>
 
-                 <li>帮助中心</li>
 
-                 <li>资讯</li>
 
-                 <li>关于我们</li>
 
-             </ul>
 
-         </div>
 
-         <div class="banner"
 
-         ></div>
 
-         <div class="list con">
 
-             <div class="item">
 
-                 <img src="https://ansjerfilemanager.s3.cn-northwest-1.amazonaws.com.cn/app/static/3.jpg">
 
-                 <p>无线基站套装</p>
 
-             </div>
 
-             <div class="item">
 
-                 <img src="https://ansjerfilemanager.s3.cn-northwest-1.amazonaws.com.cn/app/static/1-1-C1.jpg">
 
-                 <p>C1</p>
 
-             </div>
 
-             <div class="item">
 
-                 <img src="https://ansjerfilemanager.s3.cn-northwest-1.amazonaws.com.cn/app/static/1-1-306.jpg">
 
-                 <p>C306</p>
 
-             </div>
 
-         </div>
 
-         <div class="footer">
 
-             <div class="con">
 
-                 <ul>
 
-                     <li>网站导航</li>
 
-                     <li>物流配送</li>
 
-                     <li>售后服务</li>
 
-                     <li>配送服务</li>
 
-                     <li>退换货政策</li>
 
-                     <li>联系我们</li>
 
-                     <li>隐私政策</li>
 
-                     <li>服务协议</li>
 
-                 </ul>
 
-             </div>
 
-             <div style="text-align: center; "><a href="https://beian.miit.gov.cn/">粤ICP备12041005号</a></div>
 
-         </div>
 
-     </body>
 
- </html>
 
- <style>
 
-     * {
 
-     padding: 0;
 
-     margin: 0;
 
- }
 
- ul {
 
-     list-style: none;
 
- }
 
- .con {
 
-     width: 966px;
 
-     margin: 0 auto;
 
- }
 
- .header {
 
-     height: 110px;
 
- }
 
- .photo {
 
-     width: 165px;
 
-     height: 110px;
 
-     background: url(../图片/logo.png);
 
-     float: left;
 
-     background-position: center;
 
-     background-size: 100% 100%;
 
- }
 
- .headerlist {
 
-     float: right;
 
- }
 
- .headerlist ul {
 
-     height: 44px;
 
-     margin-top: 10px;
 
-     line-height: 44px;
 
- }
 
- .headerlist li {
 
-     float: left;
 
- }
 
- .headerlist a {
 
-     border-right: 1px solid #b2c7ea;
 
-     padding-left: 13px;
 
-     padding-right: 13px;
 
-     font-size: 13px;
 
-     color: indigo;
 
- }
 
- .headerlist .last {
 
-     border: 0;
 
-     padding-right: 0;
 
- }
 
- .headerlist li .active {
 
-     color: pink;
 
- }
 
- .serch {
 
-     float: right;
 
-     width: 234px;
 
-     height: 28px;
 
-     border: 1px solid indigo;
 
- }
 
- .serch input {
 
-     border: 0;
 
-     outline: none;
 
-     width: 210px;
 
-     float: left;
 
-     height: 28px;
 
-     padding-left: 14px;
 
- }
 
- .nav {
 
-     height: 53px;
 
-     line-height: 53px;
 
-     border-top: 1px solid #edf4fc;
 
-     background-color: #274964;
 
-     color: aliceblue;
 
- }
 
- .nav li {
 
-     float: left;
 
-     font-size: 16px;
 
-     padding-right: 76px;
 
- }
 
- .banner {
 
-     height: 380px;
 
-     background: url('https://ansjerfilemanager.s3.cn-northwest-1.amazonaws.com.cn/app/static/backdrop.jpg') no-repeat center;
 
-     background-size: cover;
 
- }
 
- .list {
 
-     height: 213px;
 
-     margin-top: 11px;
 
-     margin-bottom: 125px;
 
- }
 
- .item {
 
-     height: 222px;
 
-     width: 230px;
 
-     border: 1px solid #cccccc;
 
-     float: left;
 
-     margin-right: 12px;
 
- }
 
- .item img {
 
-     width: 230px;
 
-     height: 222px;
 
-     display: block;
 
- }
 
- .item p {
 
-     height: 47px;
 
-     padding-left: 28px;
 
-     line-height: 47px;
 
-     color: #274964;
 
- }
 
- .footer {
 
-     height: 206px;
 
-     border-top: 1px solid cornsilk;
 
-     background-color: #cccccc;
 
- }
 
- .footer ul {
 
-     height: 84px;
 
-     padding-top: 30px;
 
-     padding-bottom: 30px;
 
-     line-height: 28px;
 
-     border-bottom: 1px solid gray;
 
- }
 
- .footer ul li {
 
-     width: 210px;
 
-     padding-left: 30px;
 
-     font-size: 12px;
 
-     float: left;
 
-     color: indigo;
 
- }
 
- .footer p {
 
-     height: 61px;
 
-     line-height: 61px;
 
-     padding-left: 30px;
 
-     font-size: 12px;
 
- }
 
- .footer p span {
 
-     color: indigo;
 
- }
 
- </style>
 
-     """
 
-     if CONFIG_INFO == CONFIG_CN:
 
-         return HttpResponse(html)
 
-     response = ResponseObject()
 
-     return response.json(414)
 
 
  |