def update_profile(request): try: import signal post = json.loads(request.body) newport = post['port'] newemail = post['email'] newetitle = post['title'] subkey = ['title'] oldport = int(public.readfile('data/port.conf').strip()) pid = int(public.readfile('/var/run/panel.pid').strip()) old_setting_dict = json.loads(public.readfile('data/setting.json')) if newetitle != old_setting_dict[subkey[0]]: setting_json = dict([(key, post[key]) for key in subkey]) public.writefile('data/setting.json', json.dumps(setting_json)) #print(pid) os.kill(pid, signal.SIGHUP) if oldport != newport: public.writefile('data/port.conf', newport) os.kill(pid, signal.SIGHUP) user = User.objects.get(pk=post['id']) user.email = newemail user.save() content = {'flag': 'Success'} except Exception as e: content = {'flag': 'Error', 'context': str(e)} return JsonResponse(content)
def index(request): setting = json.loads(public.readfile('data/setting.json')) user = { 'name': request.user, 'date': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) } #return JsonResponse(context) data = User.objects.get(is_superuser=1) content = model_to_dict(data) content['port'] = int(public.readfile('data/port.conf').strip()) return render(request, 'setting.html', { "content": content, "setting": setting, 'user': user })
def index(request): setting = json.loads(public.readfile('data/setting.json')) filter = request.GET.get('filter', '') if filter: dataset = User.objects.filter( Q(name__contains=filter) | Q(path__contains=filter) | Q(comment__contains=filter)).order_by("id") else: dataset = User.objects.all().order_by("id") paginator = Paginator(dataset, 25) ## Show 25 content per page page = request.GET.get('page') try: content = paginator.page(page) except PageNotAnInteger: content = paginator.page(1) except EmptyPage: content = paginator.page(paginator.num_pages) user = { 'name': request.user, 'date': datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') } return render(request, "ftp.html", { "content": content, 'filter': filter, "setting": setting, 'user': user })
def index(request): setting = json.loads(public.readfile('data/setting.json')) user = { 'name': request.user, 'date': datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') } return render(request, "website.html", {"setting": setting, 'user': user})
import os import sys from libs import public path_of_current_file = os.path.abspath(__file__) path_of_current_dir = os.path.split(path_of_current_file)[0] sys.path.insert(0, path_of_current_dir) workers = 1 threads = 1 backlog = 512 timeout = 30 bind = "%s:%s" % ("0.0.0.0", public.readfile('data/port.conf')) worker_class = 'gevent' chdir = path_of_current_dir capture_output = True access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"' loglevel = 'info' pidfile = '/var/run/panel.pid' errorlog = '%s/logs/panel_error.log' % path_of_current_dir accesslog = '%s/logs/panel_access.log' % path_of_current_dir
from django.urls import include, re_path from django.contrib.auth.views import LoginView, LogoutView from panel.settings import LOGIN_URL from libs import public import json from . import views urlpatterns = [ re_path(r'^$', views.index), re_path(r'^register/$', views.register), re_path( r'^login/$', LoginView.as_view(extra_context={ "setting": json.loads(public.readfile('data/setting.json')) }, template_name='login.html')), re_path(r'^logout/$', LogoutView.as_view(next_page=LOGIN_URL)), re_path(r'^dashboard/', include('dashboard.urls')), re_path(r'^website/', include('website.urls')), re_path(r'^database/', include('database.urls')), re_path(r'^setting/', include('setting.urls')), re_path(r'^ftp/', include('ftp.urls')), re_path(r'^crontab/', include('crontab.urls')), ]