Esempio n. 1
1
 /**
  * @param string $dest
  * @param string[] $files
  * @return bool true, falls min ein Quelldokument verwendbar war
  */
 public static function merge($dest, $files)
 {
     Logging::info('Erzeuge ' . $dest);
     //$dest = Files::validateFilename($dest);
     $pdf = new \mPDF('de-DE', 'A4');
     $pdf->SetImportUse();
     $page = 0;
     foreach ($files as $curFile) {
         Logging::info('Eingangsdatei ' . $curFile);
         if ($curFile == '') {
             continue;
         }
         $pagecount = $pdf->SetSourceFile($curFile);
         if ($page != 0) {
             $pdf->AddPage();
         }
         for ($i = 1; $i <= $pagecount; $i++) {
             $import_page = $pdf->ImportPage($i);
             $pdf->UseTemplate($import_page);
             if ($i < $pagecount) {
                 $pdf->AddPage();
             }
         }
         $page++;
     }
     $pdf->Output($dest, 'F');
     return $page > 0;
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     Javascript::requireLibrary('froala');
     $this->options = new FroalaOptions();
     Logging::info('Requiring...');
     $this->options->requirePlugins();
 }
 /**
  * Gibt den Text mit den ersetzten Links zurück
  * @return string
  */
 public function getText()
 {
     $this->text = html_entity_decode($this->text);
     $matches = [];
     // Suchen nach allem, dass in [[ ]] eingeschlossen ist
     preg_match_all('/\\[\\[([\\w\\.\\säöüÄÖÜß]+)\\]\\]/', $this->text, $matches);
     Logging::debug(print_r($matches, true));
     foreach ($matches[1] as $match) {
         $artikel = CmsArtikel::loadByBezeichnung($match, $this->kategorieId);
         if ($artikel == null) {
             Logging::info('Lege Artikel neu an: ' . $match);
             $artikel = new CmsArtikel();
             $artikel->ca_kategorie = $this->kategorieId;
             $artikel->ca_bezeichnung = $match;
             $artikel->ca_aktiv = 1;
             $artikel->ca_autor = Security::getUserId();
             $artikel->save();
             $titel = Text::get($artikel->getElementId() . '.titel');
             $titel->te_text = $match;
             $titel->save();
         }
         $link = EntityLinks::show($artikel);
         $tag = "<a href=\"{$link}\">{$match}</a>";
         $this->text = str_replace('[[' . $match . ']]', $tag, $this->text);
     }
     return $this->text;
 }
 /**
  * Diese Methode erzeugt aus den übergebenen Parameteren ein Request-Objekt
  * Könnte man vielleicht noch aufhübschen
  *
  * @return Request
  *
  */
 public function route()
 {
     Profiler::startSection('Routing.route');
     // TODO: Bei Get und im Pathinfo können wir sehr viel
     // schärfere Sicherheitsrichtlinien durchsetzen. Da kann
     // und darf nie HTML kommen (XSS)
     $request = new Request();
     if (array_key_exists('REQUEST_METHOD', $_SERVER)) {
         $request->methode = $_SERVER['REQUEST_METHOD'];
     } else {
         $request->method = 'get';
     }
     $request->admin = isset($_GET['admin']);
     Logging::info('Methode ' . $request->method);
     // Falls es ein Pathinfo gibt, dieses aufbereiten
     $pathInfo = getenv('PATH_INFO');
     if (array_key_exists('pathinfo', $_GET) && isset($_GET['pathinfo'])) {
         $pathInfo = '/' . $_GET['pathinfo'];
     }
     Logging::info('Pathinfo is: ' . $pathInfo);
     $request->pathinfo = $pathInfo;
     if (isset($pathInfo)) {
         // Der Pathinfo fängt mit einem Slash an! (z.B. /cms/showKategorie)
         $pathInfo = substr($pathInfo, 1);
         $this->fillRequestByPathinfo($request, $pathInfo);
     }
     foreach ($_REQUEST as $key => $value) {
         $request->{$key} = $value;
     }
     $request->sanitize();
     Profiler::endSection('Routing.route');
     $this->postRoute($request);
     return $request;
 }
Esempio n. 5
0
 protected function createControls()
 {
     $artikelliste = $this->controller->kategorie->getArtikel();
     Logging::info('Kategorie enthält ' . count($artikelliste) . ' Artikel');
     $i = 1;
     foreach ($artikelliste as $artikel) {
         $text = Text::get($artikel->getElementId() . '.intro', $_SESSION['sp_id'])->te_text;
         $anchor = new HtmlControl($this);
         $anchor->setInnerHtml('<a name="' . $artikel->id . '"></a>');
         $artikelPanel = new CaptionedPanelControl($this, 'artikel_' . $artikel->id);
         $artikelPanel->setCaption($artikel->titel);
         $blogInfos = new HtmlControl($artikelPanel);
         $blogInfos->setInnerHtml('
             <div class="blog-post-tags">
                 <ul class="list-unstyled list-inline blog-info">
                     <li><i class="fa fa-calendar"></i> ' . $artikel->ca_geschrieben_am . '</li>
                     <li><i class="fa fa-pencil"></i> ' . $artikel->autor . '</li>
                 </ul>
             </div>
             ');
         $artikelText = new HtmlControl($artikelPanel, 'text_' . $artikel->id);
         $artikelText->setInnerHtml('
                 <img src="' . $artikel->ca_hauptbild . '" class="blogimage" />
             ' . $text);
         $i++;
     }
 }
Esempio n. 6
0
 /**
  * Stoppt das Debugging. Die Fehlerausgabe wird unterdr�ckt
  */
 public function stop()
 {
     Logging::info('Debug: OFF');
     $this->active = false;
     $_SESSION['DEBUG'] = false;
     ini_set('display_errors', 0);
     Profiler::setActive(false);
 }
 public function get($key, $default = '')
 {
     if (!isset($this->cache[$key])) {
         Logging::debug("{$key} nicht gefunden");
         Logging::info(print_r(array_keys($this->cache), true));
         return $default;
     } else {
         return $this->cache[$key];
     }
 }
 /**
  *
  */
 public function install()
 {
     Logging::info('Installiere Modul ' . $this->getModulename());
     $module = Modules::getModule($this->getModulename());
     $this->migrateDatabase();
     Logging::info('Vergebe Berechtigungen');
     foreach ($module->actions as $action) {
         /**@var Action $action */
         if ($action->securityLevel === Action::LEVEL_CONFIG) {
             Security::berechtigungSchreiben($action->getSecurityToken(), self::ID_ADMIN_ROLLE, 1);
         }
     }
 }
 /**
  * Rahmen zum Ausführen einer Funktion. Konkrete Ausführeung wird
  * von abstrakter Methode executeAction ausgeführt
  * @param $request
  * @return Response
  * @throws Exception
  */
 public function execute($request)
 {
     // Der Response wird direkt am Anfang erzeugt und auch in der Application-Klasse
     // hinterlegt. Das muss aus Gründen der Abwärtskompatibilität sein. In den Controller
     // Methiden wird oft auf Application::currentResponse zurückgegriffen. Das muss an
     // dieser Stelle also gefüllt sein.
     Logging::info("Ausführen von [{$this->request->module}:{$this->request->action}]");
     Profiler::startSection($this->request->module . '.' . $this->request->action);
     $this->request = $request;
     $this->response = new Response();
     Application::getInstance()->setResponse($this->response);
     $this->currentAction = $this->module->getAction($this->request->action);
     // Abbrechen, wenn Aktion nicht gefunden werden konnte
     if ($this->currentAction === null) {
         throw new \DomainException("Aktion '{$this->request->action}' in Modul '{$this->request->module}' nicht gefunden");
     } else {
         // Verhindern, dass von einem Angreifer eine beliebige Seite aufgerufen werden
         // kann
         $this->request->view = null;
         // Response mit den Standard-Daten füllen
         $this->response->setContent($this->currentAction->getDefaultNext($this));
         $result = $this->innerExecute();
         if ($result !== null) {
             $this->response = $result;
         }
         // Jetzt kann sich unter Umständen der View geändert haben
         if ($this->request->view !== null) {
             Logging::warning('anderen View laden');
             $this->response->setContent($this->module->loadView($this->request->view, $this));
         }
         // Überschreiben der eigentlichen Aktion durch eine, die bei der Ausführung der Funktion
         // gesetzt wurde
         if ($this->request->action !== $this->currentAction->name) {
             Logging::warning('Andere Action ausführen');
             $this->response->setContent($this->module->getAction($this->request->action));
         }
         Profiler::endSection($this->request->module . '.' . $this->request->action);
         return $this->response;
     }
 }
 /**
  * @param $importId
  * @param $meldung
  */
 public static function info($importId, $meldung)
 {
     Logging::info($meldung);
     self::neuerEintrag($importId, self::LEVEL_INFO, $meldung);
 }
 public function postRoute(&$request)
 {
     // Das normale Routing hat etwas ergeben
     if (isset($request->module, $request->action)) {
         return;
     }
     Profiler::startSection('Routing.postRoute');
     // Default-Page, falls nichts gefunden
     Logging::info('[Post-Route] Default-Page wird angezeigt');
     $defaultId = Configuration::get('site.defaultPageId');
     if ($defaultId <= 0) {
         throw new \Exception('Keine Defaultseite gesetzt!');
     }
     $default = new Page($defaultId);
     $this->setCurrentPage($request, $default);
     Profiler::endSection('Routing.postRoute');
 }
 protected function loadRollen($userId)
 {
     $rollenIds = [];
     $rollenSchluessel = [];
     $rollen = UserRolle::filter(['user' => $userId]);
     foreach ($rollen as $rolle) {
         $rollenIds[] = $rolle->ur_rolle;
         $rollenSchluessel[] = (string) $rolle->ro_schluessel;
     }
     $rollenString = '(' . implode(', ', $rollenIds) . ')';
     $_SESSION['rollen'] = $rollenString;
     $_SESSION['rollenIds'] = $rollenIds;
     $_SESSION['rollenSchluessel'] = $rollenSchluessel;
     Logging::info('Rollen für Benutzer ' . $rollenString);
 }
 /**
  * Durchsucht ein Verzeichnis nach Modulen und gibt diese als Array zurück
  * @param $dir
  * @return \NewFrontiers\Framework\Modules\Module[]
  */
 protected function getModulesInDir($dir)
 {
     Logging::info('Lese Module aus Verzeichnis ' . $dir);
     $result = [];
     if (!file_exists($dir)) {
         Logging::warning('Modul-Verzeichnis ' . $dir . ' existiert nicht');
         return $result;
     }
     // TODO: Langsam wie Hölle!
     $dir_iterator = new RecursiveDirectoryIterator($dir);
     $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $file) {
         if ($file->isFile() && $file->getFilename() === 'Module.xml') {
             $xml = simplexml_load_file($file);
             if (isset($xml->qualifiedName)) {
                 $moduleName = (string) $xml->qualifiedName;
             } else {
                 $moduleName = (string) $xml['name'];
             }
             if ($moduleName !== '%MODULE%') {
                 $result[$moduleName] = $this->getModule($moduleName);
             }
         }
     }
     return $result;
 }
 public function createModule($fullyQualifiedName, Request $request)
 {
     Logging::info("Modul {$fullyQualifiedName} wird angelegt");
     $naming = new ModuleNaming();
     $module = new Module();
     $module->namespace = $fullyQualifiedName;
     $module->qualifiedName = $naming->getQualifiedNameFromNamespace($module->namespace);
     $module->name = $naming->getSimpleNameFromNamespace($module->namespace);
     $module->path = str_replace('\\', '/', $fullyQualifiedName);
     $path = $module->getPath();
     $controller = $path . '/' . ucwords($module->name) . 'Controller.php';
     $installer = $path . '/' . ucwords($module->name) . 'Installer.php';
     // Verzeichnisse anlegen
     mkdir($path, 0777, true);
     mkdir($path . '/Views');
     mkdir($path . '/Model');
     $search = array('%MODULE%', '%AUTHOR%', '%VERSION%', '%DESCRIPTION%', '%NAMESPACE%');
     $replace = array(ucwords($module->name), $request->author, $request->version, $request->description, $module->namespace);
     // Variablen ersetzen und Dateien speichern
     $this->variablenEinsetzen(__DIR__ . '/Prototype/Controller.template', $controller, $search, $replace);
     $this->variablenEinsetzen(__DIR__ . '/Prototype/Module.xml', $path . '/Module.xml', $search, $replace);
     $this->variablenEinsetzen(__DIR__ . '/Prototype/Installer.template', $installer, $search, $replace);
     return $module;
 }
Esempio n. 15
0
 private function executeCreateTable()
 {
     Logging::info("Tabelle {$this->table} wird angelegt");
     $sql = "create table {$this->table} (";
     if (Database::getInstance()->getEngine() === Database::DB_MSSQL) {
         $sql .= $this->primaryKeyField . ' integer IDENTITY(1,1) not null, ';
     } else {
         $sql .= $this->primaryKeyField . ' integer not null auto_increment, ';
     }
     foreach ($this->fields as $feld) {
         /** @var ModelField $feld */
         if (!$feld instanceof ModelFieldLookup) {
             $sql .= $feld->getSqlString() . ', ';
         }
     }
     $sql .= 'primary key (' . $this->primaryKeyField . ')';
     $sql .= ')';
     Database::getInstance()->execute($sql);
 }