first commit

This commit is contained in:
aschwarz
2023-03-09 11:22:13 +01:00
commit 1bf9923edf
1745 changed files with 298896 additions and 0 deletions

67
validation/func_validEmail.php Executable file
View File

@ -0,0 +1,67 @@
<?php
function validEmail($email)
{
$isValid = true;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex)
{
$isValid = false;
}
else
{
$domain = substr($email, $atIndex+1);
$local = substr($email, 0, $atIndex);
$localLen = strlen($local);
$domainLen = strlen($domain);
if ($localLen < 1 || $localLen > 64)
{
// local part length exceeded
$isValid = false;
}
else if ($domainLen < 1 || $domainLen > 255)
{
// domain part length exceeded
$isValid = false;
}
else if ($local[0] == '.' || $local[$localLen-1] == '.')
{
// local part starts or ends with '.'
$isValid = false;
}
else if (preg_match('/\\.\\./', $local))
{
// local part has two consecutive dots
$isValid = false;
}
else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
{
// character not valid in domain part
$isValid = false;
}
else if (preg_match('/\\.\\./', $domain))
{
// domain part has two consecutive dots
$isValid = false;
}
else if
(!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',
str_replace("\\\\","",$local)))
{
// character not valid in local part unless
// local part is quoted
if (!preg_match('/^"(\\\\"|[^"])+"$/',
str_replace("\\\\","",$local)))
{
$isValid = false;
}
}
if ($isValid && !(checkdnsrr($domain,"MX") ||
checkdnsrr($domain,"A")))
{
// domain not found in DNS
$isValid = false;
}
}
return $isValid;
}
?>

52
validation/usercheck.js Executable file
View File

@ -0,0 +1,52 @@
function checkUser(str) // Creates a new checkUser function.
{
if (str.length==0) // checks if the str variable inside the checkUser function is equal to 0
{
document.getElementById("validateCheck").innerHTML=""; // Gets the html object by it's id, in this case it's id is validateCheck
return; // Returns the end result of the function
}
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) // Checks whether the users browser allows ajax
{
alert ("Please use a browser that has ajax enabled!"); // Alerts if the users browser does not support ajax
return; // Returns the function
}
var url="validation/usercheck.php"; // Creates a new variable called url
url=url+"?search="+str; // Assigns an id to the php file (usercheck.php?id=user)
url=url+"&sid="+Math.random(); // Assigns a random math function to the url
xmlHttp.onreadystatechange=stateChanged; // If the forms state has changed
xmlHttp.open("GET",url,true); // Gets a pages content using ajax
xmlHttp.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("validateCheck").innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}

29
validation/usercheck.php Executable file
View File

@ -0,0 +1,29 @@
<?php
require_once("func_validEmail.php");
require_once("../config/datenbankanbindung.php");
// Get the user id from URL
#$search=htmlspecialchars(mysql_real_escape_string($_GET["search"]));
$search=strtolower($_GET["search"]);
if(validEmail($search)){
$db = dbconnect();
$query = $db->query("SELECT * FROM imt_user WHERE lower(mail) = '" .$search."'") or die(mysql_error()); // Change users to the database where you keep your usernames, and likewise with username
list($user_id) = $query->fetch_array();
$row = $query->fetch_array();
if(empty($user_id))
{
$check = '<span class="correct">Der Benutzer ist verf&uuml;gbar.</span>';
}
else
{
$check = '<span class="wrong">Der Benutzer ist im System bereits vorhanden!</span>';
}
}else{
#$check = '<span class="wrong">Ung&uuml;ltiges Mailformat oder Domain ist falsch</span>';
$check = '';
}
// Echos whether the user exists or not.
echo $check;
?>