From 4e4a01749d9f3eaf7fd12d80ebe4de57b19e64a0 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 2 Nov 2020 19:53:12 +0000 Subject: [PATCH] sync code, fix PHP8 warning --- composer.json | 5 +++ php/clonos.php | 31 ++++++++++++- php/config.php | 1 + public/index.php | 1 + public/js/clonos.js | 20 +++++++++ public/js/matrix.js | 106 ++++++++++++++++++++++++++++++++++++++++++++ public/json.php | 1 + 7 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 composer.json create mode 100644 public/js/matrix.js diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..bf7740bd --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "sentry/sdk": "^3.0" + } +} diff --git a/php/clonos.php b/php/clonos.php index ac560eb9..fa87603f 100644 --- a/php/clonos.php +++ b/php/clonos.php @@ -1,5 +1,11 @@ environment=='development') { +require ('../vendor/autoload.php'); +Sentry\init(['dsn' => 'https://MASK' ]); +//} + class ClonOS { public $server_name=''; @@ -17,6 +23,8 @@ class ClonOS { public $table_templates=array(); public $url_hash=''; public $media_import=''; + public $json_req=false; + public $sys_vars=array(); private $_post=false; private $_db=null; @@ -152,12 +160,15 @@ class ClonOS { if(isset($this->_vars['form_data'])) $this->form=$this->_vars['form_data']; $ures=$this->userAutologin(); + $this->sys_vars['authorized']=false; if($ures!==false){ if(isset($ures['id']) && is_numeric($ures['id']) && $ures['id']>0){ $this->_user_info=$ures; $this->_user_info['unregistered']=false; + $this->sys_vars['authorized']=true; }else{ $this->_user_info['unregistered']=true; + if($this->json_req) exit; } } @@ -168,8 +179,23 @@ class ClonOS { exit; } } + + if($this->_user_info['unregistered'] && $this->mode!='login') + { + echo json_encode(array('error'=>true,'unregistered_user'=>true)); + exit; + } unset($_POST); + $cfunc='ccmd_'.$this->mode; + if(method_exists($this,$cfunc)) + { + $ccmd_res=array(); + $ccmd_res=$this->$cfunc(); + //print_r($ccmd_res); + //return; + } + switch($this->mode){ case 'login': echo json_encode($this->login()); return; case 'getTasksStatus': echo json_encode($this->_getTasksStatus($this->form['jsonObj'])); return; @@ -245,6 +271,9 @@ class ClonOS { } } + function ccmd_login(){ + return array('hi'=>'hello'); + } function login(){ $form=$this->_vars['form_data']; @@ -775,7 +804,7 @@ class ClonOS { $sysrc=array(); if(isset($form['serv-ftpd'])) $sysrc[]=$form['serv-ftpd']; if(isset($form['serv-sshd'])) $sysrc[]=$form['serv-sshd']; - $arr['sysrc_enable']=join($sysrc,' '); + $arr['sysrc_enable']=implode(' ',$sysrc); /* create jail */ $file_name='/tmp/'.$arr['jname'].'.conf'; diff --git a/php/config.php b/php/config.php index 5157efc9..d3fa5041 100644 --- a/php/config.php +++ b/php/config.php @@ -201,6 +201,7 @@ class Config } function create_bhyve_profiles($info) { + $array1=array(); $res=json_decode($info['message'],true); if(!empty($res))foreach($res as $item) { diff --git a/public/index.php b/public/index.php index 3a11dfb7..df27153e 100644 --- a/public/index.php +++ b/public/index.php @@ -43,6 +43,7 @@ if(empty($uri)) exit; } + error_reporting(E_ALL); $user_info=$clonos->userAutologin(); diff --git a/public/js/clonos.js b/public/js/clonos.js index 2a58077f..c09376e9 100644 --- a/public/js/clonos.js +++ b/public/js/clonos.js @@ -4,6 +4,7 @@ var clonos={ manual_close_menu:false, lastX:0, oldHash:'', + authorized:false, commands: { 'jstart':{stat:['Not launched','Starting','Launched'],cmd:'jailStart'}, @@ -913,6 +914,7 @@ var clonos={ if(typeof data['unregistered_user']!='undefined') { + this.authorized=false; this.loginFadeIn(); return; } @@ -926,6 +928,14 @@ var clonos={ } } + if(typeof(data['username'])=='string' && typeof(data['errorCode']!='undefined')) + { + if(data.errorCode==0 && data.username!='') + { + this.authorized=true; + } + } + return_func(data); }, @@ -1641,6 +1651,7 @@ var clonos={ bodyClick:function(event) { //debugger; + //if(!this.authorized) location.reload(); var target=event.target; if($(target).parents('form').length>0) { @@ -2099,6 +2110,15 @@ var clonos={ }, loginFadeIn:function() { + if($('#login').length==0) + { + location.reload(); + return; + /* + alert('I think, you are delete login area from code. Are you a hacker?'+"\nPlease, reload the page and don't do magick with code!"); + */ + //$('#unregistered_user').show(); + } $('#login').show(); $('.login-wait').hide(); $('.login-area').fadeIn(200); diff --git a/public/js/matrix.js b/public/js/matrix.js new file mode 100644 index 00000000..3c58f4af --- /dev/null +++ b/public/js/matrix.js @@ -0,0 +1,106 @@ +/* + +*/ +/* +cool matrix effect +http://creativetier.com/code-rain-js/templates/rain-message/index.php?n=1 +*/ +/* +one more +https://dev.to/gnsp/making-the-matrix-effect-in-javascript-din +*/ +var streams = []; +var fadeInterval = 1.6; +var symbolSize = 14; + +function setup() { +  createCanvas( +    window.innerWidth, +    window.innerHeight +  ); +  background(0); +  var x = 0; +  for (var i = 0; i <= width / symbolSize; i++) { +    var stream = new Stream(); +    stream.generateSymbols(x, random(-2000, 0)); +    streams.push(stream); +    x += symbolSize +  } + +  textFont('Consolas'); +  textSize(symbolSize); +} + +function draw() { +  background(0, 150); +  streams.forEach(function(stream) { +    stream.render(); +  }); +} + +function Symbol(x, y, speed, first, opacity) { +  this.x = x; +  this.y = y; +  this.value; +  this.speed = speed; +  this.first = first; +  this.opacity = opacity; +  this.switchInterval = round(random(2, 25)); +  this.setToRandomSymbol = function() { +    var charType = round(random(0, 5)); +    if (frameCount % this.switchInterval == 0) { +      if (charType > 1) { +        // set it to Katakana +        this.value = String.fromCharCode( +          0x30A0 + round(random(0, 96)) +        ); +      } else { +        // set it to numeric +        this.value = round(random(0,9)); +      } +    } +  } + +  this.rain = function() { +    this.y = (this.y >= height) ? 0 : this.y += this.speed; +  } + +} + +function Stream() { +  this.symbols = []; +  this.totalSymbols = round(random(5, 35)); +  this.speed = random(5, 22); + +  this.generateSymbols = function(x, y) { +    var opacity = 255; +    var first = round(random(0, 4)) == 1; +    for (var i =0; i <= this.totalSymbols; i++) { +      symbol = new Symbol( +        x, +        y, +        this.speed, +        first, +        opacity +      ); +      symbol.setToRandomSymbol(); +      this.symbols.push(symbol); +      opacity -= (255 / this.totalSymbols) / fadeInterval; +      y -= symbolSize; +      first = false; +    } +  } + +  this.render = function() { +    this.symbols.forEach(function(symbol) { +      if (symbol.first) { +        fill(140, 255, 170, symbol.opacity); +      } else { +        fill(0, 255, 70, symbol.opacity); +      } +      text(symbol.value, symbol.x, symbol.y); +      symbol.rain(); +      symbol.setToRandomSymbol(); +    }); +  } +} diff --git a/public/json.php b/public/json.php index c85abf14..9fccf084 100644 --- a/public/json.php +++ b/public/json.php @@ -10,6 +10,7 @@ $path=trim($_POST['path'],$_ds); $_REALPATH=realpath('../'); include($_REALPATH.'/php/clonos.php'); $clonos=new ClonOS($_REALPATH); +$clonos->json_req=true; //$file_path=$_REALPATH.$_ds.'public/pages'.$_ds.$path.$_ds; //$clonos->json_name=$file_path.'a.json.php';