238 lines
7.2 KiB
PHP
238 lines
7.2 KiB
PHP
<?php
|
|
/**
|
|
* Basecontent Controller
|
|
*
|
|
* Der Basecontent Controller übernimmt allgemeine Aufgaben
|
|
* für das CMS.
|
|
*
|
|
* @package baseContent
|
|
* @subpacke basecontent
|
|
*/
|
|
class basecontent_controller extends fl_controller {
|
|
/* Eigenschaften */
|
|
var $defaultAction = 'show';
|
|
var $from = '';
|
|
var $layout = 'admin';
|
|
#
|
|
|
|
function show() {
|
|
$this->check_login('basecontent/');
|
|
$this->data['title'] = 'Administration';
|
|
}
|
|
|
|
/**
|
|
* Papierkorb
|
|
*
|
|
* @todo Parameter für Aktionen einbauen
|
|
* @todo Datenvorbereitung durch das Model
|
|
* @todo relevante Module in Konfigurationsdatei auslagern
|
|
* @todo nach erotikdatenbank portieren
|
|
*/
|
|
function trashcan($param) {
|
|
$this->check_login('basecontent/trashcan/');
|
|
$this->data['title'] = 'Papierkorb';
|
|
|
|
/* module auflisten, die status 2 haben können
|
|
$modules = array(
|
|
'Firmen'=>'company_LANG',
|
|
'Firmenarten'=>'company_cat_LANG',
|
|
'Lokalbereiche'=>'localarea',
|
|
'Länder'=>'localarea_cat_LANG',
|
|
'Profile'=>'profiles_LANG',
|
|
'Sprachen'=>'language'
|
|
);
|
|
*/
|
|
$modules = array(
|
|
'Accounts'=>'account'
|
|
);
|
|
|
|
// Daten sammeln
|
|
$trashcan_data = $this->model->get_trashcan_data($modules);
|
|
$this->data += $trashcan_data;
|
|
}
|
|
|
|
function login($from) {
|
|
$this->data['title'] = 'Anmelden';
|
|
$this->data['from'] = (string) $from;
|
|
$this->layout = 'loginout';
|
|
}
|
|
|
|
/**
|
|
* Anzeige der Fehlermeldung "Nicht berechtigt"
|
|
*/
|
|
function notallowed() {
|
|
$this->data['title'] = 'Keine Berechtigung';
|
|
}
|
|
|
|
function auth() {
|
|
$fl = $_POST['fl'];
|
|
|
|
if ( isset($_SESSION['username']) OR $this->model->login($fl) ) {
|
|
$_SESSION['username'] = $fl['username'];
|
|
$_SESSION['IP'] = $_SERVER['REMOTE_ADDR'];
|
|
|
|
$result = $this->datamodel->retrieve('user', 'level', 'name = "'.$_SESSION['username'].'"');
|
|
$_SESSION['userlevel'] = $result['level'];
|
|
$this->flash('Willkommen, '.$_SESSION['username'].'!');
|
|
$this->logaction( $_SESSION['username'].' hat sich eingeloggt' );
|
|
|
|
if ( empty($fl['from']) ) {
|
|
$this->data = array('title'=>'Administrationsbereich');
|
|
$this->goToTarget('basecontent/');
|
|
} else {
|
|
$this->goToTarget($fl['from']);
|
|
}
|
|
|
|
} else {
|
|
$this->flash('Falscher Benutzername oder falsches Passwort angegeben.');
|
|
$this->data['from'] = $fl['from'];
|
|
$this->data['title'] = 'Einloggen';
|
|
$this->layout = 'loginout';
|
|
$this->view = 'login';
|
|
}
|
|
}
|
|
|
|
function logout() {
|
|
$this->check_login('basecontent/');
|
|
$this->layout = 'loginout';
|
|
$this->logaction($_SESSION['username'].' hat sich ausgeloggt');
|
|
$this->data['title'] = 'Ausgeloggt';
|
|
|
|
// datenbank aufraeumen
|
|
//$this->clean_db();
|
|
|
|
session_destroy();
|
|
}
|
|
|
|
function options($action) {
|
|
$this->check_login('basecontent/options/');
|
|
$this->data['title'] = 'Einstellungen bearbeiten';
|
|
|
|
if( $action == 'save') {
|
|
$fl = $_POST['fl'];
|
|
$failures = 0;
|
|
$result = array();
|
|
|
|
foreach( $fl as $key => $value ) {
|
|
$temp = explode('_', $key);
|
|
|
|
$data['optionname'] = strtoupper($temp[1]);
|
|
$data['value'] = $value;
|
|
$module = $temp[0].'_options';
|
|
|
|
$optionresult = $this->datamodel->retrieve( $module , 'id', "optionname = '".$data['optionname']."'", '', '1');
|
|
$id = $optionresult['id'];
|
|
|
|
if ( $this->datamodel->update($module, $data, $id) ) {
|
|
$result[] = ucwords( $temp[1] ) . ' aktualisiert: ' . $data['value'];
|
|
} else {
|
|
$result[] = 'Option ' . ucwords( $temp[1] ) . ' konnte nicht aktualisiert werden.';
|
|
$failures++;
|
|
}
|
|
}
|
|
|
|
$msg = ( $failures == 0 ) ?
|
|
'Optionen wurden aktualisiert':
|
|
implode("\n", $result);
|
|
$this->flash($msg);
|
|
|
|
$this->data['title'] = 'Administration';
|
|
$this->goToTarget('basecontent/');
|
|
}
|
|
}
|
|
|
|
function protocol($type) {
|
|
$this->layout = 'admin';
|
|
$this->check_login('basecontent/protocol/'.$type);
|
|
|
|
$logfile = "Auflistung der Benutzeraktionen\r\n\r\n";
|
|
|
|
switch ($type) {
|
|
|
|
case 'screen':
|
|
$array = $this->datamodel->retrieve('basecontent', '*', '', 'id DESC', '30');
|
|
foreach ( $array as $row ) {
|
|
$logfile .= $row['id'].": ".$row['name']." (".$row['ip'].") - ".$row['date']." - ".$row['action']."\r\n";
|
|
}
|
|
|
|
$this->data['logfile'] = $logfile;
|
|
$this->data['title'] = "Logfile ausgeben";
|
|
$this->logaction('Logfile am Bildschirm ausgegeben. (30 Aktionen)');
|
|
$this->layout = 'viewprotocol';
|
|
break;
|
|
|
|
case 'textfile':
|
|
$array = $this->datamodel->retrieve('basecontent', '*', '', 'id ASC');
|
|
foreach ( $array as $row ) {
|
|
$logfile .= $row['id'].": ".$row['name']." (".$row['ip'].") - ".$row['date']." - ".$row['action']."\r\n";
|
|
}
|
|
$logfile .= "\r\nEnde der Logfileausgabe";
|
|
$logfile = html_entity_decode($logfile);
|
|
|
|
header("Content-length: ".strlen($logfile));
|
|
header("Content-type: text/plain");
|
|
header("Content-Disposition: attachment; filename=aktionen.log");
|
|
echo $logfile;
|
|
|
|
$this->flash('Logfile als Datei heruntergeladen');
|
|
exit();
|
|
break;
|
|
}
|
|
}
|
|
|
|
function support() {
|
|
$this->check_login('basecontent/support');
|
|
// Eine mail an info@2erlei mit "Seitenname, IP, Uhrzeit, username, ggf. Protokoll" abschicken
|
|
|
|
$user = $this->datamodel->retrieve('user', 'email', "name = '".$_SESSION['username']."'", '', '1');
|
|
$result = $this->datamodel->retrieve(ADMINMODULE.'_options', '*', "optionname='SEITENTITEL'");
|
|
$sitetitle = $result['value'];
|
|
|
|
$array = $this->datamodel->retrieve('basecontent', '*', '', 'id DESC', '30');
|
|
foreach ( $array as $row ) {
|
|
$logfile .= $row['id'].": ".$row['name']." (".$row['ip'].") - ".$row['date']." - ".$row['action']."\r\n";
|
|
}
|
|
unset($array);
|
|
|
|
$config['mailreceipient'] = 'info@2erlei.de';
|
|
$config['mailtopic'] = '['.$sitetitle.'] Supportanfrage';
|
|
$config['mailfrom'] = 'supportbutton@'.$_SERVER['HTTP_HOST'];
|
|
$config['replyto'] = $user['email'];
|
|
$content = 'Es wurde eine Supportanfrage abgegeben.'."\n";
|
|
$content .= "\n".'Seitentitel:'."\t". $sitetitle;
|
|
$content .= "\n".'IP:' . "\t\t" . $_SESSION['IP'];
|
|
$content .= "\n".'Uhrzeit:' . "\t" . date('Y-m-d H:i:s', mktime() );
|
|
$content .= "\n".'Benutzer:' . "\t". $_SESSION['username'];
|
|
$content .= "\n".'Protokoll:'."\n". $logfile;
|
|
$content .= "\n\n".'Ende der Supportanfrage';
|
|
$content .= "\n-- \nbaseContent";
|
|
|
|
if ( mail($config['mailreceipient'], $config['mailtopic'], $content, "From: {$config['mailfrom']}\r\n"."Reply-To: {$config['replyto']}") ) {
|
|
$notify['mailed'] = TRUE;
|
|
$notify['status'] = "2erlei wurde per e-mail über Ihren Supportwunsch informiert.";
|
|
} else {
|
|
$notify['mailed'] = FALSE;
|
|
$notify['status'] = "</p><h4>Fehler</h4><p>Auf diesem Server ist kein Mailversand möglich. Bitte richten Sie Ihre Supportanfrage telefonisch an 2erlei. ";
|
|
}
|
|
$this->flash($notify['status']);
|
|
|
|
$this->goToTarget('basecontent/');
|
|
}
|
|
|
|
function webframe($page='') {
|
|
$this->layout = 'default';
|
|
$this->goToTarget($page);
|
|
/*
|
|
$this->data['title'] = 'Webseiten-Ansicht';
|
|
if ( $page == 'top' ) {
|
|
echo file_get_contents($this->modulepath . 'basecontent/de/frame_top.php');
|
|
}
|
|
*/
|
|
}
|
|
|
|
function common() {
|
|
return $this->factory->get_helper('bereiche');
|
|
}
|
|
}
|
|
?>
|