Skip to content
Snippets Groups Projects
inaktive.class.php 2.86 KiB
Newer Older
<?php

class inaktive{
	private $db;
	private $config;
	
	public function __construct(){
		global $datenbank,$grundconfig;
		$this->db = $datenbank;
		$this->config = $grundconfig;
	}
	
	public function Suchen($zeit){
		$aus = '
			<table class="table table-striped" id="InaktiveSuchenTable">
				<thead>
					<tr>
						<th>UID</th>
						<th>Kontostand</th>
						<th>Letzter Login</th>
					</tr>
				</thead>
				<tbody>
			';
		
		foreach($this->db->get_results("SELECT uid,kontostand_a,last_active FROM ". PREFIX . KONTO ." WHERE last_active <= $zeit ") AS $res){
			if($res->last_active == 0){ $datum = 'nie online';}else{ $datum = date("d.m.Y H:i",$res->last_active);}
			$aus .= '
				<tr>
					<td>'. $res->uid .'</td>
					<td>'. number_format($res->kontostand_a,2,',','.') .'</td>
					<td>'. $datum .'</td>
				</tr>
			';
		}
		
		$aus .= '</tbody></table>';
		return $aus;
	}
	
	public function Erinnern($zeit,$mail){
		$i = 0;
		foreach($this->db->get_results("SELECT uid FROM ". PREFIX . KONTO ." WHERE last_active <= $zeit ") AS $res){
			$user = userinfo($res->uid);
			$nachricht = ' Hallo '.$user->nickname.'<br>
                	Leider bist du seit Geraumer Zeit nicht mehr auf '.$this->config->seitenname.' Online gewesen.<br>
                	Um nicht vom System wegen inaktivität gelöscht zu werden,<br>
                	bitten wir dich das du dich kurz einmal auf '.$this->config->seitenname.' anmeldest<br>
                	und wenn du lust hast kannst du ja in zukunft auch noch aktive teilnehmen.<br>
					<br>
                	MFG<br>
                	'.$this->config->seitenname.' ';
			$mail->senden($user->emailadresse,'Inaktiver Account',$nachricht);
			$i++;
		}
		return 'Es wurden '. $i .' Erinnerungen verschickt.';
	}
	
	public function Delete($zeit){
		$i = 0;
		foreach($this->db->get_results("SELECT uid FROM ". PREFIX . KONTO ." WHERE last_active <= $zeit ") AS $res){
			$this->db->delete(PREFIX . KONTO, array("uid" => $res->uid),1);
			$this->db->delete(PREFIX . USER, array("uid" => $res->uid),1);
			$this->db->delete(PREFIX . WERBER, array("uid" => $res->uid),1);
			$this->db->delete(PREFIX . NICKP, array("uid" => $res->uid),1);
			$this->db->delete(PREFIX . EMAIL, array("uid" => $res->uid),1);
			$this->db->delete(PREFIX . BUCH_B, array("uid" => $res->uid),1);
			$this->db->delete(PREFIX . MK, array("uid" => $res->uid),1);
			$this->db->delete(PREFIX . MULTIK, array("uid" => $res->uid),1);
			$this->db->delete(PREFIX . RELOAD, array("uid" => $res->uid),1);
			$this->db->delete(PREFIX . BETTELB, array("uid" => $res->uid),1);
			$this->db->delete(PREFIX . NOTIZ, array("uid" => $res->uid),1);
			$this->db->delete(PREFIX . WERBUNG, array("uid" => $res->uid),1);
			$this->db->delete(PREFIX . CHAT, array("uid" => $res->uid),1);
			$this->db->delete(PREFIX . NEWSK, array("uid" => $res->uid),1);
			$i++;
		}
		return 'Es wurden '. $i .' Konten gel&ouml;scht.';
	}
}

?>