<?php
require_once('session/checkuser.php');
function user_customer_match($cust, $user)
{
$customerno = (int) $cust;
$username = db_escape_string($user);
$result = db_query("SELECT uid FROM system.useraccounts WHERE kunde={$customerno} AND username='{$username}' AND kundenaccount=1;");
if ($result->rowCount() > 0)
return true;
return false;
}
function customer_has_email($customerno, $email)
{
$customerno = (int) $customerno;
$email = db_escape_string($email);
$result = db_query("SELECT NULL FROM kundendaten.kunden WHERE id=".$customerno." AND (email='{$email}' OR email_extern='{$email}' OR email_rechnung='{$email}');");
return ($result->rowCount() > 0);
}
function validate_token($customerno, $token)
{
expire_tokens();
$customerno = (int) $customerno;
$token = db_escape_string($token);
$result = db_query("SELECT NULL FROM kundendaten.kunden WHERE id={$customerno} AND token='{$token}';");
return ($result->rowCount() > 0);
}
function get_uid_for_token($token)
{