Deutschland United States United Kingdom
ContentLion - Open Source CMS

Compare Revisions

Ignore whitespace Rev 6 → Rev 7

/trunk/info.php
7,6 → 7,6
$pluginInfo->version = "1.0.0";
$pluginInfo->license = "GPL 3";
$pluginInfo->licenseUrl = "http://www.gnu.org/licenses/gpl.html";
$pluginInfo->supportedLanguages = array("de", "en");
$pluginInfo->supportedLanguages = array("de");
$this->Add($pluginInfo);
?>
/trunk/classes/page.php
5,14 → 5,21
public $page = null;
 
function __construct(Page $page) {
$this->page = $page;
}
$this->page = $page;
}
public function ExecuteHttpHeader () {
if (Plugin_PluginData_Data::Current()->getData("plugin_register_http_redirection") == "1" && Plugin_Register_Register::check($this->page)) {
Plugin_Register_Register::save($this->page);
header("Location: " . UrlRewriting::GetUrlByAlias(Plugin_PluginData_Data::Current()->getData("plugin_register_redirection")));
}
}
public function display () {
//Prüfen, ob der User nicht bereits schon eingeloggt ist
//Activate Font-Plugin, if not activated
//Activate PluginData-Plugin, if not activated
$plugin = PluginInfo::Get("plugindata");
if(isset($plugin) && !$plugin->isActivated()){
$plugin->activate();
40,7 → 47,7
}
 
if (isset($_REQUEST['option']) && $_REQUEST['option'] == "register") {
echo Plugin_Register_Register::save($this->page);
echo Plugin_Register_Register::show($this->page);
} else {
//Formular ausgeben
echo Plugin_Register_Register::getForm($this->page);
/trunk/classes/register.php
1,62 → 1,122
<?php
 
class Plugin_Register_Register {
public static function save ($page) {
 
protected static $errors = array();
protected static $email = "";
 
public static function check ($page) {
//Parameter prüfen
 
//Plugins können Fehlermeldungen in diesem Array speichern.
$_GLOBALS['plugin_register_errors'] = array();
 
$_GLOBALS['plugin_register_results'] = array();
 
if (!isset($_REQUEST['username']) || empty($_REQUEST['username'])) {
$_GLOBALS['plugin_register_errors'][] = "Es wurde kein Username angegeben.";
} else {
 
$row = DataBase::Current()->ReadRow("SELECT * FROM `{'dbprefix'}user` WHERE `name` = '" . DataBase::Current()->EscapeString(strtolower(trim($_REQUEST['username']))) . "'; ");
if ($row) {
$_GLOBALS['plugin_register_errors'][] = "Der Username wird bereits von einem anderem Benutzer verwendet.";
}
 
}
 
if (!isset($_REQUEST['password']) || !isset($_REQUEST['password_retry']) || empty($_REQUEST['password']) || empty($_REQUEST['password_retry'])) {
$_GLOBALS['plugin_register_errors'][] = "Es wurde kein Passwort angegeben.";
} else {
 
if ($_REQUEST['password'] != $_REQUEST['password_retry']) {
$_GLOBALS['plugin_register_errors'][] = "Die eingegebenen Passw&ouml;rter stimmen nicht &uuml;berein!";
}
 
}
 
if (!isset($_REQUEST['email']) || empty($_REQUEST['email'])) {
$_GLOBALS['plugin_register_errors'][] = "Es wurde keine E-Mail Adresse angegeben.";
} else {
$email = DataBase::Current()->EscapeString($_REQUEST['email']);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
self::$email = DataBase::Current()->EscapeString($_REQUEST['email']);
 
if (!filter_var(self::$email, FILTER_VALIDATE_EMAIL)) {
$_GLOBALS['plugin_register_errors'][] = "Es wurde keine g&uuml;ltige E-Mail Adresse angegeben!";
}
 
//Mit Hilfe eines Plugins ist es möglich, die Mail-Adressen auf Gültigkeit zu überprüfen.
EventManager::raiseEvent("plugin_register_checkMail", array());
}
 
$plugin_register_errors = array();
global $plugin_register_errors;
 
$plugin_register_errors = $_GLOBALS['plugin_register_errors'];
 
//Events werfen, damit auch zusätzliche Felder geprüft werden können.
EventManager::raiseEvent("plugin_register_check", array());
 
$_GLOBALS['plugin_register_errors'] = $plugin_register_errors;
self::$errors = $_GLOBALS['plugin_register_errors'];
if (isset($_GLOBALS['plugin_register_errors']) && count($_GLOBALS['plugin_register_errors']) == 0) {
return true;
} else {
return false;
}
}
public static function getErrors () {
return self::$errors;
}
public static function show ($page) {
if (self::check($page)) {
//User speichern
self::save($page);
/* Registrierung abgeschlossen
* Events werfen, damit z.B. Plugins dem User eine Willkommens-Nachricht schicken können
*/
EventManager::raiseEvent("plugin_register_finish", array());
 
//Weiterleiten
$link = Plugin_PluginData_Data::Current()->getData("plugin_register_redirection");
$time = Plugin_PluginData_Data::Current()->getData("plugin_register_redirection_time");
$template = new Template();
$template->load("plugin_register_redirection");
 
$template->assign_var("URL", UrlRewriting::GetUrlByAlias($link));
$template->assign_var("TIME", $time);
 
return $template->getCode();
} else {
/*
* Formular nochmal ausgeben
*/
$errors = self::getErrors();
$text = "<b style=\"color:red; \">";
foreach ($errors as $error) {
$text .= "" . $error . "<br />";
}
 
$text .= "</b><br />";
 
//Fehler
return self::getForm($page, $text);
}
}
public static function save ($page) {
if (self::check($page)) {
//Keine Fehler --> Registrierung abschließen
//Daten eintragen
84,38 → 144,7
EventManager::raiseEvent("plugin_register_save", array('user' => $user, 'row' => $row));
}
/*if(!$user->insert($_POST['password'])){
$userlist->assign_var("MSG",Language::DirectTranslateHtml("USER_NOT_CREATED"));
}*/
/* Registrierung abgeschlossen
* Events werfen, damit z.B. Plugins dem User eine Willkommens-Nachricht schicken können
*/
EventManager::raiseEvent("plugin_register_finish", array());
//Weiterleiten
$link = Plugin_PluginData_Data::Current()->getData("plugin_register_redirection");
$time = Plugin_PluginData_Data::Current()->getData("plugin_register_redirection_time");
$template = new Template();
$template->load("plugin_register_redirection");
$template->assign_var("URL", UrlRewriting::GetUrlByAlias($link));
$template->assign_var("TIME", $time);
return $template->getCode();
} else {
$errors = $_GLOBALS['plugin_register_errors'];
$text = "<b style=\"color:red; \">";
foreach ($errors as $error) {
$text .= "" . $error . "<br />";
}
$text .= "</b><br />";
//Fehler
return self::getForm($page, $text);
}
}