Skip to content

Commit 3e9a0f9

Browse files
author
flx5
committed
Added Settings Page
Added Permissions to API Added AJAX Functionality Added some SQL Functions Adjusted Installer (SQL Queries) Added the Possibility to chose between the inofficiall Marquee and a JS solution
1 parent 0a175e0 commit 3e9a0f9

19 files changed

+930
-373
lines changed

ajax.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
/* =================================================================================*\
4+
|* This file is part of InMaFSS *|
5+
|* InMaFSS - INformation MAnagement for School Systems - Keep yourself up to date! *|
6+
|* ############################################################################### *|
7+
|* Copyright (C) flx5 *|
8+
|* E-Mail: [email protected] *|
9+
|* ############################################################################### *|
10+
|* InMaFSS is free software; you can redistribute it and/or modify *|
11+
|* it under the terms of the GNU Affero General Public License as published by *|
12+
|* the Free Software Foundation; either version 3 of the License, *|
13+
|* or (at your option) any later version. *|
14+
|* ############################################################################### *|
15+
|* InMaFSS is distributed in the hope that it will be useful, *|
16+
|* but WITHOUT ANY WARRANTY; without even the implied warranty of *|
17+
|* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *|
18+
|* See the GNU Affero General Public License for more details. *|
19+
|* ############################################################################### *|
20+
|* You should have received a copy of the GNU Affero General Public License *|
21+
|* along with InMaFSS; if not, see http://www.gnu.org/licenses/. *|
22+
\*================================================================================= */
23+
24+
if (!isset($_GET['limit']) || !is_numeric($_GET['limit']))
25+
exit;
26+
27+
require_once("global.php");
28+
lang()->add('home');
29+
30+
$limit = $_GET['limit'];
31+
32+
require_once("inc/view.php");
33+
34+
$data = Array();
35+
36+
$left = getVar("tpl")->getTemplate('plan');
37+
$left->setVar('site', 'left');
38+
$view_left = new view('left', $limit);
39+
$left->setVar('view', $view_left);
40+
41+
$data['left'] = $left->GetHtml();
42+
43+
$right = getVar("tpl")->getTemplate('plan');
44+
$right->setVar('site', 'right');
45+
$view_right = new view('right', $limit);
46+
$right->setVar('view', $view_right);
47+
48+
$data['right'] = $right->GetHtml();
49+
50+
getVar("tpl")->Write('<div id="footer">');
51+
$footer = getVar("tpl")->getTemplate('footer');
52+
$footer->setVar('view_left', $view_left);
53+
$footer->setVar('view_right', $view_right);
54+
55+
$data['footer'] = $footer->GetHtml();
56+
57+
echo json_encode($data);
58+
?>

inc/api.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ function CheckAuth($api) {
151151
}
152152

153153
function HasPerm($perm) {
154-
return true; // todo!
155154
return in_array($perm, $this->permissions);
156155
}
157156

inc/class.config.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class config {
3737
private $use_ftp;
3838
private $ftp;
3939
private $system;
40+
private $useMarquee;
41+
private $updateStyle;
4042
private $spalten_t = Array('200px', '30px', '100px', '75px', '*');
4143
private $spalten = Array('75px', '75px', '30px', '180px', '75px', '*');
4244

@@ -53,21 +55,23 @@ public function config() {
5355
public function LoadFromDB() {
5456
$val = dbquery("SELECT * FROM settings LIMIT 1")->fetchObject();
5557

56-
$this->schoolname = $val->schoolname;
57-
$this->lang = $val->lang;
58-
$this->auto_addition = $val->auto_addition;
59-
$this->time_for_next_page = $val->time_for_next_page;
60-
$this->teacher_time_for_next_page = $val->teacher_time_for_next_page;
61-
$this->use_ftp = $val->use_ftp;
58+
$this->schoolname = (string)$val->schoolname;
59+
$this->lang = (string)$val->lang;
60+
$this->auto_addition = (bool)$val->auto_addition;
61+
$this->time_for_next_page = (int)$val->time_for_next_page;
62+
$this->teacher_time_for_next_page = (int)$val->teacher_time_for_next_page;
63+
$this->use_ftp = (bool)$val->use_ftp;
6264

6365
$ftp = Array();
64-
$ftp['server'] = $val->ftp_server;
65-
$ftp['usr'] = $val->ftp_user;
66-
$ftp['pwd'] = $val->ftp_password;
67-
$ftp['path'] = $val->ftp_path;
66+
$ftp['server'] = (string)$val->ftp_server;
67+
$ftp['usr'] = (string)$val->ftp_user;
68+
$ftp['pwd'] = (string)$val->ftp_password;
69+
$ftp['path'] = (string)$val->ftp_path;
6870

6971
$this->ftp = $ftp;
70-
$this->system = $val->system;
72+
$this->system = (string)$val->system;
73+
$this->useMarquee = (bool)$val->useMarquee;
74+
$this->updateStyle = (string)$val->updateStyle;
7175
}
7276

7377
public function Get($var) {

inc/core.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public static function SystemError($title, $text)
3939
echo '</div>';
4040
exit;
4141
}
42+
43+
public static function SuccessMessage($text) {
44+
echo '<div class="status_ok">'.$text.'</div>';
45+
}
4246

4347
public function generatePW($username, $password) {
4448
return sha1(config("salt").md5($password.config("salt").$username));

inc/db/MySQLI.php

Lines changed: 104 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
<?php
2-
/*=================================================================================*\
3-
|* This file is part of InMaFSS *|
4-
|* InMaFSS - INformation MAnagement for School Systems - Keep yourself up to date! *|
5-
|* ############################################################################### *|
6-
|* Copyright (C) flx5 *|
7-
|* E-Mail: [email protected] *|
8-
|* ############################################################################### *|
9-
|* InMaFSS is free software; you can redistribute it and/or modify *|
10-
|* it under the terms of the GNU Affero General Public License as published by *|
11-
|* the Free Software Foundation; either version 3 of the License, *|
12-
|* or (at your option) any later version. *|
13-
|* ############################################################################### *|
14-
|* InMaFSS is distributed in the hope that it will be useful, *|
15-
|* but WITHOUT ANY WARRANTY; without even the implied warranty of *|
16-
|* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *|
17-
|* See the GNU Affero General Public License for more details. *|
18-
|* ############################################################################### *|
19-
|* You should have received a copy of the GNU Affero General Public License *|
20-
|* along with InMaFSS; if not, see http://www.gnu.org/licenses/. *|
21-
\*=================================================================================*/
2+
3+
/* =================================================================================*\
4+
|* This file is part of InMaFSS *|
5+
|* InMaFSS - INformation MAnagement for School Systems - Keep yourself up to date! *|
6+
|* ############################################################################### *|
7+
|* Copyright (C) flx5 *|
8+
|* E-Mail: [email protected] *|
9+
|* ############################################################################### *|
10+
|* InMaFSS is free software; you can redistribute it and/or modify *|
11+
|* it under the terms of the GNU Affero General Public License as published by *|
12+
|* the Free Software Foundation; either version 3 of the License, *|
13+
|* or (at your option) any later version. *|
14+
|* ############################################################################### *|
15+
|* InMaFSS is distributed in the hope that it will be useful, *|
16+
|* but WITHOUT ANY WARRANTY; without even the implied warranty of *|
17+
|* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *|
18+
|* See the GNU Affero General Public License for more details. *|
19+
|* ############################################################################### *|
20+
|* You should have received a copy of the GNU Affero General Public License *|
21+
|* along with InMaFSS; if not, see http://www.gnu.org/licenses/. *|
22+
\*================================================================================= */
2223

2324
class _MySQLI extends SQL {
2425

@@ -37,6 +38,39 @@ public function __construct($host, $user, $pass, $db) {
3738
$this->username = $user;
3839
$this->password = $pass;
3940
$this->database = $db;
41+
42+
$this->setConstants();
43+
}
44+
45+
private function setConstants() {
46+
define('DB_TYPE_DECIMAL', MYSQLI_TYPE_DECIMAL);
47+
define('DB_TYPE_NEWDECIMAL', MYSQLI_TYPE_NEWDECIMAL);
48+
define('DB_TYPE_BIT', MYSQLI_TYPE_BIT);
49+
define('DB_TYPE_TINY', MYSQLI_TYPE_TINY);
50+
define('DB_TYPE_SHORT', MYSQLI_TYPE_SHORT);
51+
define('DB_TYPE_LONG', MYSQLI_TYPE_LONG);
52+
define('DB_TYPE_FLOAT', MYSQLI_TYPE_FLOAT);
53+
define('DB_TYPE_DOUBLE', MYSQLI_TYPE_DOUBLE);
54+
define('DB_TYPE_NULL', MYSQLI_TYPE_NULL);
55+
define('DB_TYPE_TIMESTAMP', MYSQLI_TYPE_TIMESTAMP);
56+
define('DB_TYPE_LONGLONG', MYSQLI_TYPE_LONGLONG);
57+
define('DB_TYPE_INT24', MYSQLI_TYPE_INT24);
58+
define('DB_TYPE_DATE', MYSQLI_TYPE_DATE);
59+
define('DB_TYPE_TIME', MYSQLI_TYPE_TIME);
60+
define('DB_TYPE_DATETIME', MYSQLI_TYPE_DATETIME);
61+
define('DB_TYPE_YEAR', MYSQLI_TYPE_YEAR);
62+
define('DB_TYPE_NEWDATE', MYSQLI_TYPE_NEWDATE);
63+
define('DB_TYPE_INTERVAL', MYSQLI_TYPE_INTERVAL);
64+
define('DB_TYPE_ENUM', MYSQLI_TYPE_ENUM);
65+
define('DB_TYPE_SET', MYSQLI_TYPE_SET);
66+
define('DB_TYPE_TINY_BLOB', MYSQLI_TYPE_TINY_BLOB);
67+
define('DB_TYPE_MEDIUM_BLOB', MYSQLI_TYPE_MEDIUM_BLOB);
68+
define('DB_TYPE_LONG_BLOB', MYSQLI_TYPE_LONG_BLOB);
69+
define('DB_TYPE_BLOB', MYSQLI_TYPE_BLOB);
70+
define('DB_TYPE_VAR_STRING', MYSQLI_TYPE_VAR_STRING);
71+
define('DB_TYPE_STRING', MYSQLI_TYPE_STRING);
72+
define('DB_TYPE_CHAR', MYSQLI_TYPE_CHAR);
73+
define('DB_TYPE_GEOMETRY', MYSQLI_TYPE_GEOMETRY);
4074
}
4175

4276
public function IsConnected() {
@@ -83,17 +117,16 @@ public function DoQuery($query) {
83117

84118
return new _MYSQLI_Result($resultset);
85119
}
86-
120+
87121
public function insertID() {
88122
return $this->link->insert_id;
89123
}
90-
124+
91125
public function affected_rows() {
92126
return $this->link->affected_rows;
93127
}
94-
95-
public function real_escape_string($strInput = '')
96-
{
128+
129+
public function real_escape_string($strInput = '') {
97130
return $this->link->real_escape_string($strInput);
98131
}
99132

@@ -109,14 +142,37 @@ public function GetRequests() {
109142
return $this->requests;
110143
}
111144

145+
public function getErrorList() {
146+
return $this->link->error_list;
147+
}
148+
149+
public function getFieldsInfo($table) {
150+
$sql = dbquery("SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, COLUMN_TYPE FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA`='" . config("dbname") . "' AND `TABLE_NAME`='" . $table . "';");
151+
152+
$info = Array();
153+
while ($field = $sql->fetchObject()) {
154+
$info[$field->COLUMN_NAME] = Array(
155+
'name' => $field->COLUMN_NAME,
156+
'type' => $field->DATA_TYPE,
157+
'max_length' => $field->CHARACTER_MAXIMUM_LENGTH,
158+
);
159+
160+
if($field->DATA_TYPE == 'enum') {
161+
$info[$field->COLUMN_NAME]['enum'] = explode(",", str_replace("'", "", substr($field->COLUMN_TYPE, 5, (strlen($field->COLUMN_TYPE)-6))));
162+
}
163+
}
164+
165+
return $info;
166+
}
167+
112168
}
113169

114170
class _MYSQLI_Result {
115171

116172
private $res;
117173
private $closed;
118174

119-
public function __construct($result) {
175+
public function __construct($result) {
120176
$this->res = $result;
121177
$this->closed = true; // Use this only if the query uses MYSQLI_USE_RESULT
122178
}
@@ -129,7 +185,7 @@ public function fetchAssoc() {
129185
$ret = $this->res->fetch_assoc();
130186
return $ret;
131187
}
132-
188+
133189
public function fetchArray() {
134190
$ret = $this->res->fetch_array();
135191
return $ret;
@@ -138,7 +194,7 @@ public function fetchArray() {
138194
public function fetchObject() {
139195
return $this->res->fetch_object();
140196
}
141-
197+
142198
public function fetchRow() {
143199
return $this->res->fetch_row();
144200
}
@@ -147,7 +203,21 @@ function result($row = 0, $field = 0) {
147203
$this->res->data_seek($row);
148204
$datarow = $this->res->fetch_array();
149205
return $datarow[$field];
150-
}
206+
}
207+
208+
function fetchFieldByName($columnName) {
209+
$fields = $this->fetchFields();
210+
foreach ($fields as $field) {
211+
if ($field->name == $columnName)
212+
return $field;
213+
}
214+
215+
return null;
216+
}
217+
218+
function fetchFields() {
219+
return $this->res->fetch_fields();
220+
}
151221

152222
public function close() {
153223
if ($this->closed)
@@ -161,6 +231,11 @@ public function __destruct() {
161231
$this->close();
162232
}
163233

234+
// Easy access to parent function
235+
public function getErrorList() {
236+
return getVar("sql")->getErrorList();
237+
}
238+
164239
}
165240

166241
?>

inc/lang.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,18 @@ public function add($keys){
5656
return true;
5757
}
5858

59-
public function loc($id, $output = true) {
59+
public function loc($id, $output = true, $noError = false) {
6060
if(array_key_exists($id, $this->local)) {
6161
if($output) {
6262
echo $this->local[$id];
6363
return;
6464
}
6565
return $this->local[$id];
6666
}
67+
68+
if($noError)
69+
return $id;
70+
6771
core::SystemError('Language System Error', 'Could not find index '. $id);
6872
}
6973

0 commit comments

Comments
 (0)