app=$app; if($intern) { return; } $this->app->ActionHandlerInit($this); $this->app->ActionHandler("list","LogfileList"); $this->app->ActionHandler("delete","LogfileDelete"); $this->app->ActionHandler("deleteall","LogfileDeleteAll"); $this->app->ActionHandler("minidetail","LogfileMiniDetail"); $this->app->DefaultActionHandler("list"); $this->app->ActionHandlerListen($app); } /** * @param Application $app * @param string $name * @param array $erlaubtevars * * @return array */ public function TableSearch($app, $name, $erlaubtevars) { // in dieses switch alle lokalen Tabellen (diese Live Tabellen mit Suche etc.) für dieses Modul switch($name) { case 'logfile': $allowed['logfile'] = array('list'); // START EXTRA checkboxen // ENDE EXTRA checkboxen // headings $heading = array('', 'ID', 'Zeit', 'Bearbeiter', 'Module', 'Action', 'Funktion', 'Meldung', 'Menü'); $width = array('4%', '4%', '15%', '10%', '10%', '10%', '10%', '40%', '10%', '5%'); $findcols = array('open', 'a.id', 'a.datum', 'a.bearbeiter', 'a.module', 'a.action', 'a.funktionsname', 'a.meldung', 'a.id'); $searchsql = array("DATE_FORMAT(a.datum,'%d.%m.%Y %H:%i:%s')", 'a.bearbeiter', 'a.module', 'a.meldung', 'a.action', 'a.funktionsname'); $defaultorder = 2; $defaultorderdesc = 1; $menucol = 1; $moreinfo = true; $menu = '
' . // "". // "app->Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\">". // " ". "" . "app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\">" . "
"; // SQL statement $sql = "SELECT SQL_CALC_FOUND_ROWS a.id, 'app->Conf->WFconf['defaulttheme']}/images/details_open.png class=details>' as open, a.id,DATE_FORMAT(a.datum,'%d.%m.%Y %H:%i:%s'), a.bearbeiter, a.module, a.action, a.funktionsname,a.meldung, a.id FROM logfile a"; if($app->erp->GetKonfiguration('logfile_use_fulltext')){ $matchesql = [ 'sqlpre' => $sql . ' INNER JOIN (', 'sqlpost' => ' ) AS `matches` ON matches.id = a.id ', 'elements' => [] ]; $matchesql['elements'][] = [ 'sql' => 'SELECT l.id FROM logfile l', 'where' => ["DATE_FORMAT(l.datum,'%d.%m.%Y %H:%i:%s')", 'l.bearbeiter', 'l.module', 'l.action', 'l.funktionsname'], 'match' => ['l.meldung', 'l.dump'] ]; }else{ unset($matchesql); } // gesamt anzahl $count = 'SELECT COUNT(a.id) FROM logfile a'; break; } $erg = array(); foreach($erlaubtevars as $k => $v) { if(isset($$v)){ $erg[$v] = $$v; } } return $erg; } public function LogFileMiniDetail() { $id = $this->app->Secure->GetGET('id'); if($id > 0){ $dump = $this->app->DB->SelectRow("SELECT funktionsname,dump FROM logfile WHERE id='$id' LIMIT 1"); } if(!empty($dump)){ echo '
Funktion ' . $dump['funktionsname'] . ':
'; echo '

Dump:' . $dump['dump'] . '

'; if(is_array(unserialize($dump['dump']))){ echo '
';
        print_r(unserialize($dump['dump']));
        echo '
'; } } $this->app->ExitXentral(); } public function LogfileDelete() { $id = $this->app->Secure->GetGET('id'); if($id > 0){ $this->app->DB->Delete( sprintf( 'DELETE FROM `logfile` WHERE `id` = %d LIMIT 1', $id ) ); } $msg = $this->app->erp->base64_url_encode('
Der Logeintrag wurde gelöscht!
'); $this->app->Location->execute('index.php?module=logfile&action=list&msg='.$msg); } public function LogfileDeleteAll() { $this->app->DB->Delete('DELETE FROM `logfile`'); $this->app->DB->Query('OPTIMIZE TABLE `logfile`'); $msg = $this->app->erp->base64_url_encode('
Alle Logeinträge wurden wurden gelöscht!
'); $this->app->Location->execute('index.php?module=logfile&action=list&msg='.$msg); } public function LogfileList() { $this->LogfileMenu(); $isLoggingActive = $this->isLoggingActive(); if($isLoggingActive) { $this->app->Tpl->Set('LOGGINGACTIVE', 'checked'); } $this->app->YUI->AutoSaveKonfiguration('logginActive', 'logfile_logging_active'); //$this->app->erp->InternesEvent($this->app->User->GetID(),"Hallo","alarm",1); $this->app->YUI->TableSearch('TAB1','logfile','show','','',basename(__FILE__), __CLASS__); $this->app->Tpl->Parse('PAGE','logfile_list.tpl'); } public function LogfileMenu() { $this->app->erp->Headlines('Logdatei'); $this->app->erp->MenuEintrag('index.php?module=einstellungen&action=list','Zurück zur Übersicht'); $this->app->erp->MenuEintrag('index.php?module=logfile&action=list','Aktualisieren'); $this->app->erp->MenuEintrag('index.php?module=logfile&action=deleteall','Alle Einträge löschen'); } public function Install() { $this->app->erp->CheckTable('logfile'); $this->app->erp->CheckColumn('id','int(11)','logfile','NOT NULL AUTO_INCREMENT'); $this->app->erp->CheckColumn('meldung','TEXT','logfile','DEFAULT \'\' NOT NULL'); $this->app->erp->CheckColumn('dump','TEXT','logfile','DEFAULT \'\' NOT NULL'); $this->app->erp->CheckColumn('module','VARCHAR(64)','logfile','DEFAULT \'\' NOT NULL'); $this->app->erp->CheckColumn('action','VARCHAR(64)','logfile','DEFAULT \'\' NOT NULL'); $this->app->erp->CheckColumn('bearbeiter','VARCHAR(64)','logfile','DEFAULT \'\' NOT NULL'); $this->app->erp->CheckColumn('funktionsname','VARCHAR(64)','logfile','DEFAULT \'\' NOT NULL'); $this->app->erp->CheckColumn('datum','DATETIME','logfile'); $hasFullIndex = $this->app->erp->CheckFulltextIndex('logfile',['meldung', 'dump']); $this->app->erp->SetKonfigurationValue('logfile_use_fulltext', $hasFullIndex); } /** * @return bool */ public function isLoggingActive() { if($this->logging !== null) { return (bool)$this->logging; } $loggingActive = (string)$this->app->erp->GetKonfiguration('logfile_logging_active'); if($loggingActive === '') { $this->app->erp->SetKonfigurationValue('logfile_logging_active', '0'); $this->logging = false; return false; } $this->logging = (bool)$loggingActive; return $this->logging; } /** * @param bool $status */ public function changeLoggingStatus($status) { $this->logging = (bool)$status; $this->app->erp->SetKonfigurationValue('logfile_logging_active', (int)$this->logging); } /** * @param array|string $meldung * @param string $dump * @param string $module * @param string $action * @param string $functionname * * @return int */ public function addLogFile($meldung,$dump='',$module='',$action='',$functionname='') { if(!$this->isLoggingActive()) { return 0; } if($functionname=='') { if (strnatcmp(phpversion(),'5.0.0') >= 0) { $backtrace = debug_backtrace(); $functionname = isset($backtrace[1]) && isset($backtrace[1]['function'])?$backtrace[1]['function']:''; if($functionname === 'LogFile') { $functionname = isset($backtrace[2]) && isset($backtrace[2]['function'])?$backtrace[2]['function']:''; } } } if(is_array($meldung)) { $meldung = print_r($meldung, true); } $module = $this->app->DB->real_escape_string($module); $action = $this->app->DB->real_escape_string($action); $meldung = $this->app->DB->real_escape_string($meldung); $dump = $this->app->DB->real_escape_string($dump); $functionname = $this->app->DB->real_escape_string($functionname); $this->app->DB->Insert( sprintf( "INSERT INTO logfile (module,action,meldung,dump,datum,bearbeiter,funktionsname) VALUES ('%s','%s','%s','%s',NOW(),'','%s')", $module, $action,$meldung,$dump,$functionname ) ); return (int)$this->app->DB->GetInsertID(); } }