* @since 1.0 * @package MammutCMS * @subpackage Module */ class Newsletter extends NewsletterBase { protected function getMyId() { return 'mcms.newsletter'; } public function runIndex(Request $request, Response $response, $activeInstance) { $system = \MCMS\System::getInstance(); $tplfile = __DIR__ . '/_layout_/_default_/' . 'tpl.' . $system->getTarget('action') . '.php'; // define the template file try { $template = new CTemplate(); $template->loadTemplate($tplfile); $template->setParam('title', __CLASS__); $template->setParam('self', $_SERVER['PHP_SELF']); $template->setParam('instance', $activeInstance); $template->setParam('isUser', !is_null($system->getUserSvc()->getUser())); $response->setFragment('CONTENT', $template->getDocument()); } catch(FileNotFoundException $ex) { $response->setFragment('CONTENT', "file is missing: " . $tplfile); } } public function runSignup(Request $request, Response $response, $activeInstance) { if ($db->get_count("SELECT * FROM `{$mod}_external` WHERE `email`='{$_REQUEST['email']}'") != 0) header("Location: ".$_SERVER['PHP_SELF']."?module=$mod&action=error&errno=60001"); else { $new['email'] = "'".$db->escape_string(trim($_REQUEST['email']))."'"; $new['password'] = "'".$db->escape_string(trim($_REQUEST['password']))."'"; if (!is_valid_email(trim($_REQUEST['email']))) header("Location: ".$_SERVER['PHP_SELF']."?module=$mod&action=error&errno=60011"); elseif ($new['password'] == "''") header("Location: ".$_SERVER['PHP_SELF']."?module=$mod&action=error&errno=60012"); else { $db->insert("{$mod}_external",$new); if ($db->lasterror()) echo $db->lasterror(); else header("Location: ".$_SERVER['PHP_SELF']."?module=$mod&action=addok"); } } $system['dorender'] = false; } public function runSignoff(Request $request, Response $response, $activeInstance) { $_REQUEST['email'] = $db->escape_string($_REQUEST['email']); if ($row = $db->get_array("SELECT * FROM `{$mod}_external` WHERE `email`='{$_REQUEST['email']}'")) { if ($row['password'] == $_REQUEST['password']) { $db->delete("{$mod}_external",array("`email`='{$_REQUEST['email']}'")); if ($db->lasterror()) echo $db->lasterror(); else header("Location: ".$_SERVER['PHP_SELF']."?module=$mod&action=removeok"); } else header("Location: ".$_SERVER['PHP_SELF']."?module=$mod&action=error&errno=60003"); } else header("Location: ".$_SERVER['PHP_SELF']."?module=$mod&action=error&errno=60002"); if ($db->lasterror()) echo $db->lasterror(); $system['dorender'] = false; } public function runPassword(Request $request, Response $response, $activeInstance) { $_REQUEST['email'] = $db->escape_string($_REQUEST['email']); if ($row = $db->get_array("SELECT * FROM `{$mod}_external` WHERE `email`='{$_REQUEST['email']}'")) { $mail = "Hallo,\n"; $mail .= "Für deinen E-Mail-Adresse wurde das Newsletter-Passwort angefordert. Diese lautet :\n"; $mail .= "Passwort: {$row['password']}\n\n"; $mail .= "Abmelden kannst du dich unter http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?module=$mod&action=index\n\n"; $mail .= "Das Technikteam\n\n---\nAutomatic generated message, do not reply"; if (mail($row['email'],'Newsletter-Kennwort',$mail,"From: mailerdemon@StuTa.de\nReply-To:technik@StuTa.de")) header("Location: ".$_SERVER['PHP_SELF']."?module=$mod&action=pwsend"); else header("Location: ".$_SERVER['PHP_SELF']."?module=$mod&action=error&errno=60010"); } else header("Location: ".$_SERVER['PHP_SELF']."?module=$mod&action=error&errno=60002"); $system['dorender'] = false; } }