bernd
Neues Jabber-Modul (noch nicht ganz fertig) und Formular-Framework
bernd commited dcee94d at 2007-06-01 16:53:03
<?php
function output($arg)
{
global $output;
$output .= $arg;
}
function random_string($nc, $a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') {
$l=strlen($a)-1; $r='';
while($nc-->0) $r.=$a{mt_rand(0,$l)};
return $r;
}
function are_you_sure($query_string, $question)
{
global $debugmode;
if ($debugmode)
$query_string = 'debug&amp;'.$query_string;
$token = random_string(20);
$_SESSION['are_you_sure_token'] = $token;
output("<form action=\"?{$query_string}\" method=\"post\">\n");
output("<p class=\"confirmation\">{$question}<br />\n");
output("<input type=\"hidden\" name=\"random_token\" value=\"{$token}\" />\n");
output("<input type=\"submit\" name=\"really\" value=\"Ja\" />\n<input type=\"submit\" name=\"not_really\" value=\"Nein\" /></p>\n");
output("</form>\n");
}
function user_is_sure()
{
if (isset($_POST['really']))
{
if ($_POST['random_token'] == $_SESSION['are_you_sure_token'])
return true;
else
system_failure("Possible Cross-site-request-forgery detected!");
}
elseif (isset($_POST['not_really']))
return false;
else
return NULL;
}
function generate_form_token($form_id)
{
require_once("inc/debug.php");
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX