Пример #1
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $usersDB = new JsonDB(__userdb);
     $id = (int) $_POST['id'];
     $login = htmlspecialchars($_POST['login'], ENT_QUOTES);
     $email = htmlspecialchars($_POST['email'], ENT_QUOTES);
     $password1 = md5($_POST['password1']);
     $password2 = md5($_POST['password2']);
     $accessGroup = htmlspecialchars($_POST['accessGroup'], ENT_QUOTES);
     $alerts = htmlspecialchars($_POST['alerts'], ENT_QUOTES);
     $user = $usersDB->data[$id];
     $_SESSION['formSent'] = $_POST;
     if ($password1 != $password2) {
         $this->redirect('?r=users/edit&id=' . $id . '&error=Passwords do not much!');
     }
     $user['login'] = $login;
     $user['email'] = $email;
     $user['accessGroup'] = $accessGroup;
     $user['alerts'] = $alerts;
     if ($_POST['password1'] != '') {
         $user['password'] = $password1;
     }
     $usersDB->data[$id] = $user;
     $usersDB->saveToFile(__userdb);
     $_SESSION['formSent'] = array();
     $this->redirect('?r=users/list');
 }
Пример #2
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $frequency = array();
     $frequency['type'] = $_POST['n-start'];
     switch ($_POST['n-start']) {
         case 'n-minutes':
             $frequency['n-minutes-minute'] = (int) $_POST['n-minutes-minute'];
             break;
         case 'n-every-hour':
             $frequency['n-every-hour-minute'] = (int) $_POST['n-every-hour-minute'];
             break;
         case 'n-day':
             $frequency['n-day-hour'] = (int) $_POST['n-day-hour'];
             $frequency['n-day-minute'] = (int) $_POST['n-day-minute'];
             break;
         case 'n-month':
             $frequency['n-month-day'] = (int) $_POST['n-month-day'];
             $frequency['n-month-hour'] = (int) $_POST['n-month-hour'];
             $frequency['n-month-minutes'] = (int) $_POST['n-month-minutes'];
             break;
         case 'n-once':
             $frequency['n-once-month'] = (int) $_POST['n-once-month'];
             $frequency['n-once-day'] = (int) $_POST['n-once-day'];
             $frequency['n-once-year'] = (int) $_POST['n-once-year'];
             $frequency['n-once-hour'] = (int) $_POST['n-once-hour'];
             $frequency['n-once-minutes'] = (int) $_POST['n-once-minutes'];
             break;
     }
     $sid = (int) $_POST['sid'];
     $serversList = new JsonDB(__serversdb);
     $newTask = array();
     $newTask['added'] = time();
     $newTask['type'] = 'mysql_backup';
     $newTask['title'] = $_POST['title'];
     $newTask['status'] = $_POST['status'];
     $newTask['execStatus'] = 0;
     $newTask['lastExec'] = time();
     $newTask['deep'] = (int) $_POST['deep'];
     $newTask['frequency'] = $frequency;
     $newTask['mysql-backup-address'] = $_POST['mysql-backup-address'];
     $newTask['mysql-backup-name'] = $_POST['mysql-backup-name'];
     $newTask['mysql-backup-user'] = $_POST['mysql-backup-user'];
     $newTask['mysql-backup-password'] = $_POST['mysql-backup-password'];
     $query = new ApiQuery($serversList->data[$sid]['address'], $serversList->data[$sid]['apiKey']);
     $result = $query->addTask($newTask, true);
     if ($result['responseStatus'] == 'success') {
         $id = (int) $result['id'];
         $serversList->data[$sid]['tasks'][$id] = $result['task'];
         $serversList->saveToFile(__serversdb);
     }
     $this->redirect('?r=servers/server_tasks_list&id=' . $sid);
 }
Пример #3
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $frequency = array();
     $frequency['type'] = $_POST['n-start'];
     switch ($_POST['n-start']) {
         case 'n-minutes':
             $frequency['n-minutes-minute'] = (int) $_POST['n-minutes-minute'];
             break;
         case 'n-every-hour':
             $frequency['n-every-hour-minute'] = (int) $_POST['n-every-hour-minute'];
             break;
         case 'n-day':
             $frequency['n-day-hour'] = (int) $_POST['n-day-hour'];
             $frequency['n-day-minute'] = (int) $_POST['n-day-minute'];
             break;
         case 'n-month':
             $frequency['n-month-day'] = (int) $_POST['n-month-day'];
             $frequency['n-month-hour'] = (int) $_POST['n-month-hour'];
             $frequency['n-month-minutes'] = (int) $_POST['n-month-minutes'];
             break;
         case 'n-once':
             $frequency['n-once-month'] = (int) $_POST['n-once-month'];
             $frequency['n-once-day'] = (int) $_POST['n-once-day'];
             $frequency['n-once-year'] = (int) $_POST['n-once-year'];
             $frequency['n-once-hour'] = (int) $_POST['n-once-hour'];
             $frequency['n-once-minutes'] = (int) $_POST['n-once-minutes'];
             break;
     }
     $id = time();
     $newTask = array();
     $newTask['id'] = $id;
     $newTask['added'] = time();
     $newTask['type'] = 'mysql_backup';
     $newTask['title'] = $_POST['title'];
     $newTask['status'] = $_POST['status'];
     $newTask['execStatus'] = 0;
     $newTask['lastExec'] = time();
     $newTask['deep'] = (int) $_POST['deep'];
     $newTask['frequency'] = $frequency;
     $newTask['mysql-backup-address'] = $_POST['mysql-backup-address'];
     $newTask['mysql-backup-name'] = $_POST['mysql-backup-name'];
     $newTask['mysql-backup-user'] = $_POST['mysql-backup-user'];
     $newTask['mysql-backup-password'] = $_POST['mysql-backup-password'];
     $tasksDB = new JsonDB(__taskdb);
     $tasksDB->data[$id] = $newTask;
     $tasksDB->saveToFile(__taskdb);
     $this->redirect('?r=tasks/list');
 }
Пример #4
0
 function updateTask($params)
 {
     $tasks = new JsonDB($this->taskdb);
     if (!isset($tasks->data[$params['id']])) {
         return array('responseStatus' => 'error');
     }
     $receivedTask = json_decode(base64_decode($params['task']), true);
     foreach ($receivedTask as $key => $val) {
         $tasks->data[$params['id']][$key] = $val;
     }
     $tasks->saveToFile($this->taskdb);
     return array('responseStatus' => 'success', 'task' => $tasks->data[$params['id']]);
 }
Пример #5
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $id = (int) $_POST['id'];
     $usersDB = new JsonDB(__userdb);
     unset($usersDB->data[$id]);
     $usersDB->saveToFile(__userdb);
     $this->redirect('?r=users/list');
 }
Пример #6
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $id = (int) $_POST['id'];
     $serversDB = new JsonDB(__serversdb);
     $server = $serversDB->data[$id];
     $serversDB->deleteById($id);
     $serversDB->saveToFile(__serversdb);
     deleteDir(__archiveDIR . 'servers/' . $server['id']);
     $this->redirect('?r=servers/servers');
 }
Пример #7
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $settingsDB = new JsonDB(__settingsdb);
     $settingsDB->data['serverName'] = $_POST['serverName'];
     $settingsDB->data['shortName'] = $_POST['shortName'];
     $settingsDB->data['apiKey'] = $_POST['apiKey'];
     $settingsDB->data['lang'] = $_POST['lang'];
     $settingsDB->saveToFile(__settingsdb);
     $this->redirect('?r=settings/main');
 }
Пример #8
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $id = (int) $_POST['id'];
     $tasksDB = new JsonDB(__taskdb);
     unset($tasksDB->data[$id]);
     $tasksDB->saveToFile(__taskdb);
     $dir = __archiveDIR . "local/{$id}";
     deleteDir($dir);
     $this->redirect('?r=tasks/list');
 }
Пример #9
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $serversDB = new JsonDB(__serversdb);
     $id = (int) $_POST['id'];
     $serversDB->data[$id]['address'] = $_POST['address'];
     $serversDB->data[$id]['apiKey'] = $_POST['apiKey'];
     $serversDB->data[$id]['archSync'] = $_POST['archSync'];
     $serversDB->data[$id]['archDepth'] = $_POST['depth'];
     $serversDB->saveToFile(__serversdb);
     $this->redirect('?r=servers/servers');
 }
Пример #10
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $id = (int) $_POST['id'];
     $sid = (int) $_POST['sid'];
     $serversList = new JsonDB(__serversdb);
     $query = new ApiQuery($serversList->data[$sid]['address'], $serversList->data[$sid]['apiKey']);
     $result = $query->deleteTask($id, true);
     if ($result['responseStatus'] == 'success') {
         $id = (int) $result['id'];
         unset($serversList->data[$sid]['tasks'][$id]);
         $serversList->saveToFile(__serversdb);
         $dir = __archiveDIR . "servers/{$sid}/{$id}";
         deleteDir($dir);
     }
     $this->redirect('?r=servers/server_tasks_list&id=' . $sid);
 }
Пример #11
0
<?php

ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
echo "Servers Service started [" . date('d.m.Y h:i', time()) . "] with PID= " . getmypid() . "\n";
include __DIR__ . '/conf.php';
include __corePath . 'libs/service.php';
include __corePath . 'libs/ApiQuery.php';
include __corePath . 'libs/jsonDB.php';
if (checkLock('servers')) {
    die("Found .lock file, exit.\n");
}
lock('servers');
$serversList = new JsonDB(__serversdb);
foreach ($serversList->data as $key => $server) {
    if (checkServerTestTime($server, 60)) {
        $query = new ApiQuery($server['address'], $server['apiKey']);
        $info = $query->getServerInfo(true);
        if ($info['responseStatus'] == 'ok') {
            $serversList->data[$key]['name'] = $info['serverName'];
            $serversList->data[$key]['tasksCount'] = $info['tasksCount'];
            $serversList->data[$key]['tasks'] = $info['tasks'];
            $serversList->data[$key]['freeSpace'] = $info['freeSpace'];
            $serversList->data[$key]['lastCheck'] = time();
            $serversList->data[$key]['status'] = 1;
            if ($server['archSync']) {
                $tasksfiles = $query->getTasksFiles(true);
                // ----------------------------------
                foreach ($tasksfiles as $taskId => $tmpFiles) {
                    $files = array();
Пример #12
0
<?php

require_once '../config.php';
require_once '../utility.php';
require_once '../lib/json.db.php';
require_once '../lib/layout.db.php';
// error_reporting(E_ALL);
// ini_set('display_errors', 1);
$dbHandler = new JsonDB("database.json");
$databasefilename = dirname($_SERVER["SCRIPT_FILENAME"]) . "/database.json";
chmod($databasefilename, 0777);
$currentlayoutObj = new Layout();
//check request
//this code block works like a controller
if (is_ajax() || isset($_POST['type'])) {
    $type = $_POST['type'];
    switch ($type) {
        case 'save layout':
            $new_layout = new Layout();
            $new_layout->set_name($_POST['layout_name']);
            $new_layout->set_background_image($_POST['image_name']);
            $new_layout->set_datetime(time());
            $new_layout->set_x1($_POST['x1']);
            $new_layout->set_y1($_POST['y1']);
            $new_layout->set_x2($_POST['x2']);
            $new_layout->set_y2($_POST['y2']);
            $new_layout->set_w($_POST['w']);
            $new_layout->set_h($_POST['h']);
            $new_layout->set_l($_POST['l']);
            $new_layout->set_color($_POST['color']);
            $new_layout->set_r($_POST['r']);
Пример #13
0
	$file = $data[0];
	$name = $data[1];

	class JsonDB {
		protected $filename;
		protected $json;
		
		function __construct($filename){
			$this->filename = $filename;	
			$this->json = json_decode(file_get_contents($filename), true);	
		}

		function add($key, $value){
			$this->json[$key] = $value;
		}

		function get($key,$par1){
			return $this->json[$key][$par1];
		}

		function save(){
			return file_put_contents($this->filename, json_encode($this->json));
		}
	}

	$db = new JsonDB('data.json');
	
	$votoatual = $db->get($file,"votos");
	$db->add($file, ['name' => $name, 'votos' => $votoatual+1]);
	$db->save();
}
if (!file_exists($font)) {
    $font = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'fonts' . DIRECTORY_SEPARATOR . 'impact.ttf';
}
//datetime
$datetimeid = $_GET['id'];
//set default data
$x1 = 195;
$y1 = 449;
$width = 195;
$height = 449;
$radius = 449;
$dir = -1;
$color = "#FFFFFF";
$length = 11;
//init db handler
$dbHandler = new JsonDB("./admin/database.json");
$currentListLayout = $dbHandler->read('layout');
$existFile = $config['image_path'] . 'CH-Profile.jpg';
$filename = "";
foreach ($currentListLayout as $key => $value) {
    if ($datetimeid == $value->datetime) {
        $existFile = $config['image_path'] . $value->background_image;
        $filename = $value->background_image;
        $x1 = $value->x1;
        $y1 = $value->y1;
        $width = $value->w;
        $height = $value->h;
        $radius = $value->r;
        $color = $value->color;
        $dir = $value->d;
        $length = $value->l;
Пример #15
0
  	<meta http-equiv="X-UA-Compatible" content="IE=edge">
  	<meta name="viewport" content="width=device-width, initial-scale=1">
  	<title></title>

  	<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
	<link href="../assets/css/style.css" rel="stylesheet">

    <!--[if lt IE 9]>
      	<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      	<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	</head>
	<body>
		<?php 
include '../JsonDB.class.php';
$db = new JsonDB('../data.json');
?>
		<!--<img src="../assets/images/header.jpg">-->
		<div class="container">
			<div class="col-md-12">
				<div class="row">
					<div class="title">
						<h1>Resultado da enquete</h1>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-md-6">

					<!--list-->
					<table class="list">
Пример #16
0
 public function execute()
 {
     $login = $_POST['login'];
     $pass1 = $_POST['password'];
     $pass2 = $_POST['confirmation'];
     $email = $_POST['email'];
     $folder = $_POST['folder'];
     $workUrl = $_POST['workUrl'];
     $beforeInstallError = 0;
     if (!is_writable('../archive/')) {
         $beforeInstallError = 1;
     }
     if (!is_writable('../core/data')) {
         $beforeInstallError = 1;
     }
     if (!is_writable('../conf.php')) {
         $beforeInstallError = 1;
     }
     if ($beforeInstallError == 0 && $pass2 == $pass1 && $login != '' && $email != '' && is_dir($folder) && $workUrl != '') {
         $id = time();
         $newUser = array('id' => $id, 'login' => $login, 'email' => $email, 'password' => md5($pass1), 'accessGroup' => 'administrator', 'alerts' => 'all');
         $usersDB = new JsonDB('../core/data/users.json');
         $usersDB->data = array();
         $usersDB->data[$id] = $newUser;
         $usersDB->saveToFile('../core/data/users.json');
         $basePath = str_replace('install/index.php', '', $_SERVER['SCRIPT_FILENAME']);
         $httpPath = 'http://' . $_SERVER['HTTP_HOST'] . str_replace('/install/', '', $_SERVER['REQUEST_URI']);
         $urlPath = str_replace('/install/', '', $_SERVER['REQUEST_URI']);
         $salt = md5(rand());
         $config = file_get_contents($basePath . 'conf.php');
         $config = str_replace('{basePath}', $basePath, $config);
         $config = str_replace('{httpPath}', $httpPath, $config);
         $config = str_replace('{urlPath}', $urlPath, $config);
         $config = str_replace('{salt}', $salt, $config);
         file_put_contents($basePath . 'conf.php', $config);
         unset($_SESSION['formSent']);
         // check settings db
         $settingsDB = new JsonDB('../core/data/settings.json');
         if (!isset($settingsDB->data['shortName'])) {
             // db have not created, have to create clean
             $settingsDB->data['serverName'] = 'My new Backup server';
             $settingsDB->data['shortName'] = 'BCKP';
             $settingsDB->data['apiKey'] = md5(rand());
             $settingsDB->data['lang'] = 'en';
             $settingsDB->saveToFile('../core/data/settings.json');
         }
         //-- check installation
         // check usersDB
         $usersDB = new JsonDB('../core/data/users.json');
         if (count($usersDB->data) == 0) {
             $_SESSION['error'] = 'Unable to access to users db, please check permissions to the /core/data folder.';
             header('location: ' . $_SERVER['REQUEST_URI'] . '?r=error');
             die;
         }
         //--
         header('location: ' . $_SERVER['REQUEST_URI'] . '?r=success');
         die;
     } else {
         $_SESSION['formSent'] = $_POST;
         if ($beforeInstallError) {
             $_SESSION['error'] = 'Please check write permissions for work folder.';
         } else {
             $_SESSION['error'] = 'Please check the installation form!';
         }
         header('location: ' . $_SERVER['REQUEST_URI']);
         die;
     }
 }
Пример #17
0
<?php

ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
echo "Service started [" . date('d.m.Y h:i', time()) . "] with PID= " . getmypid() . "\n";
include __DIR__ . '/conf.php';
include __corePath . 'libs/service.php';
include __corePath . 'libs/jsonDB.php';
include __corePath . 'libs/dumper.php';
if (checkLock('tasks')) {
    die("Found .lock file, exit.\n");
}
lock('tasks');
$tasksList = new JsonDB(__taskdb);
foreach ($tasksList->data as $key => $task) {
    $nextExec = nextExecDateTime($task);
    echo "+++++++++++++++++++++++++++++++++++++\n";
    echo $task['title'] . "\n";
    echo "+++++++++++++++++++++++++++++++++++++\n";
    echo "CurtTime = " . date('d.m.Y h:i', time()) . "\n";
    echo "Lastexec = " . date('d.m.Y h:i', $task['lastExec']) . "\n";
    echo "NextExec = " . date('d.m.Y h:i', $nextExec) . "\n";
    if (time() >= $nextExec && $nextExec > 0) {
        switch ($task['type']) {
            case 'files_backup':
                $res = 0;
                $tasksList->data[$key]['execStatus'] = 0;
                try {
                    $res = filesBackup($task);
                } catch (Exception $e) {
Пример #18
0
 public function __construct($filename)
 {
     $this->filename = $filename;
     $this->p = JsonDB::load($filename);
 }
Пример #19
0
<?php

if (!$instance) {
    exit;
}
$padname = htmlspecialchars($_GET['show']);
//header("Location: ".$padurl.$padname); #+$padurl+$padname);
$padID = $groupmap[$group] . '$' . $padname;
$pwdb = new JsonDB('passwords');
$password = $pwdb->read($groupmap[$group] . '$' . $padname);
$passw = "";
if ($password) {
    $passw = "Passwort: <input type='text' value='{$password}' readonly ondblclick='event.stopPropagation();return false' onclick='this.select()' id='padview_pw'>";
}
$sldb = new JsonDB('shortlnk');
$shortnam = $sldb->read($groupmap[$group] . '$' . $padname);
$shortlnk = "";
if ($shortnam) {
    $shortlnk = "Kurz-Link: <br><b><a href='" . SHORTLNK_PREFIX . "{$shortnam}' class='elipsis'>" . SHORTLNK_PREFIX . "{$shortnam}</a></b>";
}
try {
    $public = $instance->getPublicStatus($padID);
    $tags = "";
} catch (InvalidArgumentException $ex) {
    header("HTTP/1.1 404 Not Found");
    load_view("pad_not_found", array("pad" => "{$group}/{$padname}"));
    return;
}
if ($password) {
    setcookie("password", $password, 0, PAD_URL . $padID);
}
Пример #20
0
<?php

require '../Slim/Slim.php';
require '../class/JsonDB.class.php';
require '../class/validation.php';
$db = new JsonDB("./data/");
$table_card = 'cards';
$table_set = 'sets';
$table_user = '******';
date_default_timezone_set("Asia/Bangkok");
$current_date = date('Y-m-d H:i:s');
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
//==================================== API SET =====================================
// GET:: Get all Sets
$app->get('/set', function () {
    global $db, $table_set;
    $app = \Slim\Slim::getInstance();
    // execute query
    $result = $db->selectAll($table_set);
    // response data
    $app->response()->header("Content-Type", "application/json");
    echo json_encode($result);
});
// GET:: get detail of Set
$app->get('/set/:id', function ($id) {
    if (!is_numeric($id)) {
        http_response_code(400);
        echo json_encode(array('error' => 'id is must numeric!'));
        die;
    }
Пример #21
0
<?php

session_name("frisor_co");
session_start();
define("ROOT", dirname(__FILE__));
require "classes/class.jsondb.php";
require "classes/class.cms.php";
$jsonDatabase = new JsonDB(["database_folder" => ROOT . "/json/", "compress" => false]);
$jsonDatabase->select_db("frisor_co");
$cms = new Cms($jsonDatabase);
Пример #22
0
if (isset($_POST['delete_this_pad']) && isset($_POST['pad_id'])) {
    if (defined('DELETE_PASSWORD') && strlen(DELETE_PASSWORD) > 0 && DELETE_PASSWORD != $_POST['delete_this_pad']) {
        die(json_encode(array("status" => "access_denied")));
    }
    $padname = $_POST['pad_id'];
    $ok = $instance->deletePad($padname);
    die(json_encode(array("status" => "ok")));
}
if (isset($_POST['rename']) && isset($_POST['pad_id'])) {
    $padname = $_POST['pad_id'];
    try {
        $ok = $instance->movePad($padname, $_POST['rename']);
    } catch (Exception $ex) {
        die(json_encode(array("status" => "error", "msg" => "{$ex}")));
    }
    $pwdb = new JsonDB('passwords');
    $pwdb->move($padname, $_POST['rename']);
    $sldb->move($padname, $_POST['rename']);
    die(json_encode(array("status" => "ok")));
}
// response to create pad form
if (isset($_POST['createPadinGroup'])) {
    if (isset($_POST['start_sitzung'])) {
        $padname = 'Sitzung' . date('Ymd');
        $passwd = mt_rand(10000, 99999);
    } else {
        $padname = $_POST['pad_name'];
        $starttext = "Willkommen im wesentlichen Etherpad auf D120.de!\r\n\r\n";
    }
    try {
        $instance->createGroupPad($groupmap[$group], $padname, '');