function deleteUser($id) { $fileFunctions = new FileFunctions(); $users = getUsers(); unset($users[$id]); $fileFunctions->serializeUsers($users); //var_dump($fileFunctions); }
public function saveNewLesson() { if (!isset($_POST['nameEN']) || empty($_POST['nameEN']) || !isset($_POST['nameDE']) || empty($_POST['nameDE']) || !isset($_POST['points']) || empty($_POST['points'])) { $this->getView()->addErrorMessage('Please fill out all fields!'); $this->addLesson(); } else { $courseId = $this->secureString($_GET['id']); $nameEN = $this->secureString($_POST['nameEN']); $nameDE = $this->secureString($_POST['nameDE']); $points = $this->secureString($_POST['points']); if (Lesson::createLesson($courseId, $nameEN, $nameDE, $points)) { $this->getView()->addSuccessMessage('Lesson was successfully added.'); } else { $this->getView()->addErrorMessage('Lesson could not be added!'); } $this->defaultAction(); // create default tutorial page $newLesson = Lesson::getNewestLesson($courseId); $lessonId = $newLesson->getId(); $filePath = PAGE_DIR . "lessons/{$courseId}-{$lessonId}.html"; FileFunctions::createFile($filePath, "New lesson <strong>" . $newLesson->getName('en') . "</strong>"); } }
$displayForm = false; // perform the actual login $user = User::getUserByEmail($email); if (!$user || is_null($user)) { $message = I18n::t('login.err.general'); } else { // save user object to session $_SESSION['user'] = $user; // determine where to redirect user to if (isset($_SESSION['REQUEST_URI']) && !empty($_SESSION['REQUEST_URI'])) { $redirectTo = $_SESSION['REQUEST_URI']; unset($_SESSION['REQUEST_URI']); } else { $redirectTo = 'index.php'; } FileFunctions::log("redirecting to {$redirectTo} .."); header("location:{$redirectTo}"); } echo $message; } } // end if isset submitted // DISPLAY FORM if ($displayForm) { ?> <p> <?php echo I18n::t('login.text'); ?> </p>
protected static function hasExtension($file, $checkedExtension) { $extension = FileFunctions::getExtension($file); if (is_null($extension)) { return false; } return $extension == $checkedExtension; }
<?php session_start(); // include constants require_once 'lib/php/constants.php'; // include classloader and register it to autoloading require_once 'lib/php/classloader.php'; spl_autoload_register('loadClass'); // start session and save client require_once 'lib/php/functions/client.register.php'; // set content language I18n::initialize(); // load current page content and required JS files $currentPage = FileFunctions::getCurrentPage(); $externalJS = JavaScriptIncluder::getExternalJSFiles($currentPage); $customJS = JavaScriptIncluder::getCustomJSFiles($currentPage); ?> <!DOCTYPE html> <html lang="<?php echo I18n::getLang(); ?> "> <head> <meta charset="utf-8"> <title>hiragana.ch</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="Learn Hiragana and Katakana" /> <meta name="keywords" content="hiragana katakana kana trainer japanese japanisch PHP" /> <meta name="author" content="Steven Cardini, Raphael Laubscher" />
<?php $isRegistered = isset($_SESSION['client']) && $_SESSION['client'] !== null; if (!$isRegistered) { $client = new Client(session_id()); $success = true; if (!Client::isKnown($client)) { $success = Client::save($client); } if ($success) { $_SESSION['client'] = $client; } else { FileFunctions::log('Registration of client failed..'); } }