sync code, fix PHP8 warning

This commit is contained in:
root
2020-11-02 19:53:12 +00:00
parent 255ed956c2
commit 4e4a01749d
7 changed files with 164 additions and 1 deletions

5
composer.json Normal file
View File

@@ -0,0 +1,5 @@
{
"require": {
"sentry/sdk": "^3.0"
}
}

View File

@@ -1,5 +1,11 @@
<?php
//include_once($_REALPATH.'/forms.php');
// Sentry
//if($clonos->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';

View File

@@ -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)
{

View File

@@ -43,6 +43,7 @@ if(empty($uri))
exit;
}
error_reporting(E_ALL);
$user_info=$clonos->userAutologin();

View File

@@ -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);

106
public/js/matrix.js Normal file
View File

@@ -0,0 +1,106 @@
/*
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.12/p5.min.js" type="text/javascript"></script>
*/
/*
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();
    });
  }
}

View File

@@ -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';