Example #1
0
 function absences($f3, $params)
 {
     $db = $f3->get('db');
     $curLehrer = DbWrapper::getLehrerById($db, $params['id']);
     $f3->set('curLehrer', $curLehrer);
     $allLehrer = DbWrapper::getAllLehrer($db);
     $f3->set('allLehrer', $allLehrer);
     $absences = DbWrapper::getSperrungenByLehrerId($db, $params['id']);
     $f3->set('absences', $absences);
     echo Template::instance()->render('absences.htm');
 }
Example #2
0
 function reservierungen($f3)
 {
     if ($this->isLoggedIn($f3)) {
         $f3->set('location', 'user_summary');
         $db = $f3->get('db');
         $f3->set('schuelerName', $this->getCurrentSchuelerName($f3));
         $f3->set('reservations', DbWrapper::getReservationsByUserId($db, $f3->get('COOKIE.user_id')));
         echo Template::instance()->render('userSummary.htm');
     } else {
         $f3->reroute('/login');
     }
 }
Example #3
0
 function release($f3, $params)
 {
     $lehrerId = $params['id'];
     if ($f3->exists('POST.zeitId')) {
         try {
             $zeitId = $f3->get('POST.zeitId');
             $userId = $f3->get('COOKIE.user_id');
             Logger::Info($f3, "LehrerPost.release", "Lehrer: {$lehrerId}, Zeit: {$zeitId}, User: {$userId}");
             DbWrapper::deleteReservation($f3->get('db'), $lehrerId, $zeitId, $userId);
         } catch (Exception $e) {
             Logger::Error($f3, "LehrerPost.release", "Lehrer: {$lehrerId}, Error: {$e->getMessage()}");
         }
     }
     $f3->reroute('/lehrer/' . $lehrerId);
 }
Example #4
0
 function lehrer($f3, $params)
 {
     $db = $f3->get('db');
     $f3->set('location', 'lehrer_reserve');
     $curLehrer = DbWrapper::getLehrerById($db, $params['id']);
     $f3->set('curLehrer', $curLehrer);
     $allLehrer = DbWrapper::getLehrerBySchuelerId($db, $f3->get('COOKIE.user_id'));
     $f3->set('allLehrer', $allLehrer);
     $reservations = DbWrapper::getReservationsByLehrerId($db, $params['id'], $f3->get('COOKIE.user_id'));
     $f3->set('reservations', $reservations);
     $f3->set('isLocked', filter_var($f3->get('settings.isLocked'), FILTER_VALIDATE_BOOLEAN));
     $f3->set('curUserId', $f3->get('COOKIE.user_id'));
     $f3->set('error', $f3->get('GET.errorMessage'));
     echo Template::instance()->render('reservations.htm');
 }
Example #5
0
 function login($f3)
 {
     if ($f3->exists('POST.schueler_name')) {
         $schuelerName = $f3->get('POST.schueler_name');
         try {
             $schuelerId = DbWrapper::getSchuelerIdByName($f3->get('db'), $schuelerName);
             Logger::Info($f3, "UserPost.login", "Name: {$schuelerName}, Id: {$schuelerId}");
             $f3->set('COOKIE.user_id', $schuelerId);
             $f3->set('COOKIE.user_name', $schuelerName);
             $f3->reroute('/');
         } catch (Exception $e) {
             Logger::Error($f3, "UserPost.login", "Name: {$schuelerName}, Error: {$e->getMessage()}");
             $f3->reroute('/login');
         }
     } else {
         $f3->reroute('/login');
     }
 }
Example #6
0
 function getSettings($f3)
 {
     $db = $f3->get('db');
     $dbResults = DbWrapper::getAllEinstellungen($db);
     $settings = array();
     foreach ($dbResults as $setting) {
         $settings[$setting['name']] = $setting['wert'];
     }
     $f3->set('settings', $settings);
 }
Example #7
0
 if ($_GET['table'] == 'books' || $_GET['table'] == 'authors') {
     //save it for eventual use
     $table = $_GET['table'];
 } else {
     //throw error in case of unsupported table name
     throw new Exception('Invalid table name.');
 }
 //get database location and specify database file name
 $dbName = $_SERVER["DOCUMENT_ROOT"] . '\\dbex\\booksexample.mdb';
 //if database does not exist, display error message and exit
 if (!file_exists($dbName)) {
     die("Can't find database.");
 }
 //use odbc and pdo to connect to access database (without userid or password)
 //relay database connection and table name to database wrapper
 $dw = new DbWrapper(new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ={$dbName}; Uid=; Pwd=;"), $table);
 //check for additional parameters and store them
 $additional = array();
 foreach (array_keys($_GET) as $k) {
     if ($k != 'table' && $k != 'method' && $k != 'id') {
         $additional[$k] = $_GET[$k];
     }
 }
 switch ($_GET['method']) {
     case 'get':
         //get single dataset from database specified by its id
         //encode and display as json
         print json_encode($dw->get($_GET['id']));
         break;
     case 'getAll':
         //get all datasets from database, pass along all additional parameters
 public static function exportToExcel2007($db, $exportFileName)
 {
     $objPHPExcel = new PHPExcel();
     $objPHPExcel->getProperties()->setCreator("Lechner Michael");
     $objPHPExcel->getProperties()->setLastModifiedBy("Lechner Michael");
     $objPHPExcel->getProperties()->setTitle("Datenbankexport " . date('d.m.Y H:hi:m'));
     $objPHPExcel->getProperties()->setSubject("Datenbankexport");
     $objPHPExcel->getProperties()->setDescription("Datenbankexport");
     $objPHPExcel->setActiveSheetIndex(0);
     $activeSheet = $objPHPExcel->getActiveSheet();
     $activeSheet->setTitle('LEHRER');
     $activeSheet->SetCellValue('A1', 'lehrer_id');
     $activeSheet->SetCellValue('B1', 'name');
     $activeSheet->SetCellValue('C1', 'raum');
     $activeSheet->SetCellValue('D1', 'klassen');
     $activeSheet->getColumnDimension('B')->setAutoSize(true);
     $activeSheet->getColumnDimension('C')->setAutoSize(true);
     $activeSheet->getColumnDimension('D')->setAutoSize(true);
     $rowCounter = 2;
     foreach (DbWrapper::getAllLehrer($db) as $lehrer) {
         $activeSheet->SetCellValue('A' . $rowCounter, $lehrer['lehrer_id']);
         $activeSheet->SetCellValue('B' . $rowCounter, $lehrer['name']);
         $activeSheet->SetCellValue('C' . $rowCounter, $lehrer['raum']);
         $activeSheet->SetCellValue('D' . $rowCounter, $lehrer['klassen']);
         // $objPHPExcel->getActiveSheet()->SetCellValue('D'.$rowCounter, json_encode($lehrer));
         $rowCounter = $rowCounter + 1;
     }
     $activeSheet = $objPHPExcel->createSheet();
     $activeSheet->setTitle('SCHUELER');
     $activeSheet->SetCellValue('A1', 'schueler_id');
     $activeSheet->SetCellValue('B1', 'name');
     $activeSheet->SetCellValue('C1', 'klasse');
     $activeSheet->getColumnDimension('B')->setAutoSize(true);
     $activeSheet->getColumnDimension('C')->setAutoSize(true);
     $rowCounter = 2;
     foreach (DbWrapper::getAllSchueler($db) as $schueler) {
         $activeSheet->SetCellValue('A' . $rowCounter, $schueler['schueler_id']);
         $activeSheet->SetCellValue('B' . $rowCounter, $schueler['name']);
         $activeSheet->SetCellValue('C' . $rowCounter, $schueler['klasse']);
         $rowCounter = $rowCounter + 1;
     }
     $activeSheet = $objPHPExcel->createSheet();
     $activeSheet->setTitle('ZEITEN');
     $activeSheet->SetCellValue('A1', 'zeit_id');
     $activeSheet->SetCellValue('B1', 'zeit');
     $activeSheet->getColumnDimension('B')->setAutoSize(true);
     $rowCounter = 2;
     foreach (DbWrapper::getAllZeiten($db) as $zeit) {
         $activeSheet->SetCellValue('A' . $rowCounter, $zeit['zeit_id']);
         $activeSheet->SetCellValue('B' . $rowCounter, $zeit['zeit']);
         $rowCounter = $rowCounter + 1;
     }
     $activeSheet = $objPHPExcel->createSheet();
     $activeSheet->setTitle('EINSTELLUNGEN');
     $activeSheet->SetCellValue('A1', 'name');
     $activeSheet->SetCellValue('B1', 'wert');
     $activeSheet->getColumnDimension('A')->setAutoSize(true);
     $activeSheet->getColumnDimension('B')->setAutoSize(true);
     $rowCounter = 2;
     foreach (DbWrapper::getAllEinstellungen($db) as $einstellung) {
         $activeSheet->SetCellValue('A' . $rowCounter, $einstellung['name']);
         $activeSheet->SetCellValue('B' . $rowCounter, $einstellung['wert']);
         $rowCounter = $rowCounter + 1;
     }
     $activeSheet = $objPHPExcel->createSheet();
     $activeSheet->setTitle('SPERRUNGEN');
     $activeSheet->SetCellValue('A1', 'lehrer_id');
     $activeSheet->SetCellValue('B1', 'zeit_id');
     $activeSheet->getColumnDimension('A')->setAutoSize(true);
     $activeSheet->getColumnDimension('B')->setAutoSize(true);
     $rowCounter = 2;
     foreach (DbWrapper::getAllSperrungen($db) as $sperrung) {
         $activeSheet->SetCellValue('A' . $rowCounter, $sperrung['lehrer_id']);
         $activeSheet->SetCellValue('B' . $rowCounter, $sperrung['zeit_id']);
         $rowCounter = $rowCounter + 1;
     }
     $activeSheet = $objPHPExcel->createSheet();
     $activeSheet->setTitle('RESERVIERUNGEN');
     $activeSheet->SetCellValue('A1', 'lehrer_id');
     $activeSheet->SetCellValue('B1', 'zeit_id');
     $activeSheet->SetCellValue('C1', 'schueler_id');
     $activeSheet->getColumnDimension('A')->setAutoSize(true);
     $activeSheet->getColumnDimension('B')->setAutoSize(true);
     $activeSheet->getColumnDimension('C')->setAutoSize(true);
     $rowCounter = 2;
     foreach (DbWrapper::getAllReservierungen($db) as $reservierung) {
         $activeSheet->SetCellValue('A' . $rowCounter, $reservierung['lehrer_id']);
         $activeSheet->SetCellValue('B' . $rowCounter, $reservierung['zeit_id']);
         $activeSheet->SetCellValue('C' . $rowCounter, $reservierung['schueler_id']);
         $rowCounter = $rowCounter + 1;
     }
     $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
     $objWriter->save($exportFileName);
 }
Example #9
0
$db->query('', '
    SET NAMES {string:utf8}', array('db_error_skip' => true, 'utf8' => 'utf8'));
$replaces = array('{$db_prefix}' => $db_prefix, '{BOARDDIR}' => TMP_BOARDDIR, '{$boardurl}' => $boardurl, '{$enableCompressedOutput}' => isset($_POST['compress']) ? '1' : '0', '{$databaseSession_enable}' => isset($_POST['dbsession']) ? '1' : '0', '{$current_version}' => CURRENT_VERSION, '{$current_time}' => time(), '{$sched_task_offset}' => 82800 + mt_rand(0, 86399));
foreach ($txt as $key => $value) {
    if (substr($key, 0, 8) == 'default_') {
        $replaces['{$' . $key . '}'] = addslashes($value);
    }
}
$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
// If the UTF-8 setting was enabled, add it to the table definitions.
if (!empty($databases[$db_type]['utf8_support'])) {
    $replaces[') ENGINE=MyISAM;'] = ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;';
}
// Populate database
$db_table = db_table_install();
$db_wrapper = new DbWrapper($db, $replaces);
$db_table_wrapper = new DbTableWrapper($db_table);
$exists = array();
require_once ELK_INSTALL_DIR . '/install_1-1.php';
$install_instance = new InstallInstructions_install_1_1($db_wrapper, $db_table_wrapper);
$methods = get_class_methods($install_instance);
$tables = array_filter($methods, function ($method) {
    return strpos($method, 'table_') === 0;
});
$inserts = array_filter($methods, function ($method) {
    return strpos($method, 'insert_') === 0;
});
$others = array_filter($methods, function ($method) {
    return substr($method, 0, 2) !== '__' && strpos($method, 'insert_') !== 0 && strpos($method, 'table_') !== 0;
});
foreach ($tables as $table_method) {
Example #10
0
    while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
        $table = $row[0];
        $arr = explode(' ', $row[1]);
        $type = end($arr);
        if (preg_match('/#/', $table)) {
            continue;
        }
        $create = DbWrapper::getCreate($table);
        $rs = preg_match("/ENGINE=.+COMMENT='(.+)'\$/", $create, $matches);
        $comment = $rs ? $matches[1] : '';
        $table_info = compact('table', 'type', 'comment', 'create');
        $found = true;
        if ($f) {
            $found = false;
            // 这里可以用 like 语句-
            $fields = DbWrapper::getFields($table);
            foreach ($fields as $field) {
                if (preg_match('/' . $f . '/', $field['Field'])) {
                    $table_info['find_field'] = $found = true;
                    $table_info['field_matches'][] = $field;
                }
            }
        }
        if ($found) {
            $tables[] = $table_info;
        }
    }
    $tpl = 'index-list';
}
// render
include 'index.phtml';
Example #11
0
 function changePassword($f3, $params)
 {
     $this->ensureAdmin($f3);
     $newPassword = $f3->get('POST.password');
     Logger::Info($f3, "AdminPost.changePassword", "Changing the admin password");
     DbWrapper::updateEinstellung($f3->get('db'), 'adminPassword', $newPassword);
     $f3->reroute('/admin/index');
 }
Example #12
0
<?php

if (!isset($_POST['user']) || !isset($_POST['message'])) {
    echo 'No POST parameters were found.';
    die;
}
require 'db.php';
$db = new DbWrapper();
$db->newMessage($_POST['user'], $_POST['message']);
Example #13
0
<?php

if (!isset($_POST['user']) || !isset($_POST['image'])) {
    die;
}
require 'db.php';
$db = new DbWrapper();
$db->newUser($_POST['user'], $_POST['image']);
Example #14
0
<?php

require 'db.php';
$db = new DbWrapper();
echo json_encode($db->getUsers());
Example #15
0
<?php

require 'db.php';
$db = new DbWrapper();
echo json_encode($db->getMessages());