<?php

include_once 'User.php';
use \User as User;

function generateRandomString($length = 96)
{
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}

function getClientIP(): string
{
    $keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR');
    foreach ($keys as $k) {
        if (!empty($_SERVER[$k]) && filter_var($_SERVER[$k], FILTER_VALIDATE_IP)) {
            return $_SERVER[$k];
        }
    }
    return false;
}

function format(string $string, array $values)
{
    foreach ($values as $key => $value) {
        $string = str_replace("{{{$key}}}", $value, $string);
    }
    return $string;
}

function template_path(string $lang_cc = null)
{
    include "config.php";
    if (isset($_SESSION["cc"])) $lang_cc = $GLOBALS["cc"];
    if (isset($GLOBALS["cc"]))  $lang_cc = $GLOBALS["cc"];
    if (isset($LANG_CC) && !empty($LANG_CC) && $lang_cc == null) $lang_cc = $LANG_CC;

    if ($lang_cc) $INCLUDE_STRINGS_PATH = "templates_" . $lang_cc;
    else  $INCLUDE_STRINGS_PATH = "templates";

    if (isset($lang_cc) && !empty($lang_cc)) $TEMPLATE = $INCLUDE_STRINGS_PATH . "/";
    else $TEMPLATE = "templates/";

    include $TEMPLATE . 'strings.php';

    if (!isset($RUNTIME_ERROR)) {
        include_once 'templates/strings.php';
        echo $RUNTIME_ERROR->not_found;
        echo format($RUNTIME_ERROR->template_not_found, ["template" => $INCLUDE_STRINGS_PATH, "langcc" => $LANG_CC]);
        die();
    }

    return $TEMPLATE;
}

function replace_all_user_variables(string $string, User $user, string $url)
{
    $string = str_replace("{{url}}", $url, $string);
    $string = str_replace("{{full_name}}", $user->first_name . " " . $user->last_name, $string);
    $string = str_replace("{{fullname}}", $user->first_name . " " . $user->last_name, $string);
    $string = str_replace("{{first_name}}", $user->first_name, $string);
    $string = str_replace("{{last_name}}", $user->last_name, $string);
    $string = str_replace("{{email}}", $user->email, $string);
    $string = str_replace("{{organization}}", $user->organization, $string);
    $string = str_replace("{{username}}", $user->username, $string);
    return $string;
}

function user_to_string(User $user)
{
    return $user->first_name . " " . $user->last_name . " <" . $user->email . "> " . $user->organization . " " . $user->username;
}