Exemplo n.º 1
0
function folder_create()
{
    $root = base64_decode($_POST["root"]);
    $newFolder = $_POST["create-folder"];
    $newpath = "{$root}/{$newFolder}";
    $newpath = str_replace("//", "/", $newpath);
    $newpath = strip_path_accents($newpath);
    $newpath = utf8_encode($newpath);
    $users = new usersMenus();
    if ($users->IfIsAnuser()) {
        $perms = "&perms=" . base64_encode($_SESSION["uid"]);
    }
    $tpl = new templates();
    $sock = new sockets();
    echo $tpl->javascript_parse_text(base64_decode($sock->getFrameWork("cmd.php?create-folder=" . base64_encode($newpath) . $perms)));
}
Exemplo n.º 2
0
function folder_infos()
{
    $_GET["folder-infos"] = str_replace("../", "", $_GET["folder-infos"]);
    $_GET["folder-infos"] = str_replace("//", "/", $_GET["folder-infos"]);
    $dir = $_GET["folder-infos"];
    $users = new usersMenus();
    $tpl = new templates();
    $sock = new sockets();
    $ERROR_NO_PRIVS = $tpl->javascript_parse_text("{ERROR_NO_PRIVS}");
    $DisableExplorer = $sock->GET_INFO("DisableExplorer");
    if ($DisableExplorer == null) {
        $DisableExplorer = 0;
    }
    if ($DisableExplorer == 1) {
        echo "<center style='margin:30px'><span style='font-size:18px;letter-spacing:-1px;color:red'>{$ERROR_NO_PRIVS}</span></center>";
        return;
    }
    if ($users->IfIsAnuser()) {
        $stat = unserialize(base64_decode($sock->getFrameWork("cmd.php?filestat=" . base64_encode($dir))));
        //print_r($stat["owner"]["owner"]);
        if (strtolower($stat["owner"]["owner"]["name"]) != $_SESSION["uid"]) {
            echo "<H2>" . $tpl->_ENGINE_parse_body("{ERROR_NO_PRIVS}") . "</H2>";
            return;
        }
    } else {
        writelogs("{$_SESSION["uid"]} is not a single user", __FUNCTION__, __FILE__, __LINE__);
    }
    $dir = strip_path_accents($dir);
    $title = basename($dir);
    $f = base64_decode($sock->getFrameWork("cmd.php?Dir-Files=" . base64_encode($dir)));
    $datas = unserialize($f);
    $elements = count($datas);
    if (is_array($datas)) {
        ksort($datas);
        $ft = "<table style='width:100%'>\n\t\t\t<tr style='background-color:#D6D3CE'>\n\t\t\t<td style='border:1px solid #848284;font-size:11px'>&nbsp;</td>\n\t\t\t<td style='border:1px solid #848284;font-size:11px'>{file}</td>\n\t\t\t<td style='border:1px solid #848284;font-weight:normal;font-size:11px'>{size}</td>\n\t\t\t<td style='border:1px solid #848284;font-weight:normal;font-size:11px'>{owner}</td>\n\t\t\t<td style='border:1px solid #848284;font-weight:normal;font-size:11px'>{modified}</td>\n\t\t\t</tr>\n\t\t\t\t\n\t\t\t\n\t\t\t";
        while (list($num, $val) = each($datas)) {
            $full_path = utf8_encode($dir . "/{$num}");
            $array = unserialize(base64_decode($sock->getFrameWork("cmd.php?filestat=" . base64_encode($full_path))));
            $owner = $array["owner"]["owner"]["name"];
            //print_r($array);
            if (date('Y', $array["time"]["mtime"]) == date('Y')) {
                $modified = date('M D d H:i:s', $array["time"]["mtime"]);
            } else {
                $modified = date('Y-m-d H:i', $array["time"]["mtime"]);
            }
            if (date('Y-m-d', $array["time"]["mtime"]) == date('Y-m-d')) {
                $modified = "{today} " . date('H:i:s', $array["time"]["mtime"]);
            }
            $size = $array["size"]["size"];
            $ext = Get_extension($num);
            if ($_GET["select-file"] != null) {
                if ($_GET["select-file"] != '*') {
                    if ($ext != $_GET["select-file"]) {
                        continue;
                    }
                }
            }
            $img = "img/ext/def_small.gif";
            if ($ext != null) {
                if (isset($GLOBALS[$ext])) {
                    $img = "img/ext/{$ext}_small.gif";
                } else {
                    if (is_file("img/ext/{$ext}_small.gif")) {
                        $img = "img/ext/{$ext}_small.gif";
                        $GLOBALS[$ext] = true;
                    }
                }
            }
            $size_new = FormatBytes($size / 1024);
            if (strlen($num) > 27) {
                $text_file = substr($num, 0, 24) . "...";
            } else {
                $text_file = $num;
            }
            $file_tool_tip = fileTooltip($array);
            $file_js = "FileInfo('" . base64_encode("{$dir}/{$num}") . "')";
            if (trim($_GET["target-form"]) != null) {
                $file_js = "PutFileInform('{$dir}/{$num}')";
                $file_tool_tip = "<span style=font-size:14px>{select_this_file}</span><hr>{$file_tool_tip}";
            }
            $text_file = texttooltip($text_file, $file_tool_tip, $file_js);
            if ($size_new == 0) {
                $size_new = $size . " bytes";
            }
            //print_r($array);
            $ft = $ft . "<tr " . CellRollOver() . ">\n\t\t\t\t\t<td width=1% style='font-weight:normal'><img src='{$img}'></td>\n\t\t\t\t\t<td width=1% nowrap style='font-weight:normal;font-size:10px'>{$text_file}</td>\n\t\t\t\t\t<td nowrap align='right' style='font-weight:normal;font-size:10px'>{$size_new}</td>\n\t\t\t\t\t<td nowrap style='font-weight:normal;font-size:10px'>{$owner}</td>\n\t\t\t\t\t<td nowrap align='right' style='font-weight:normal;font-size:10px'>{$modified}</td>\n\t\t\t\t\t\n\t\t\t\t</tr>";
        }
        $ft = $ft . "</table>";
    }
    $html = "<table style='width:100%'>\n\t<tr>\n\t\t<td valign='top' align='center'>\n\t\t\t<div style='width:130px;height:544px;background-image:url(img/bg_tree1.png);background-position:bottom center;background-repeat:no-repeat'>\n\t\t\t" . item_infos($dir, $datas) . "</div>\n\t\t</td>\n\t\t<td valign='top' width=350px>{$ft}</td>\n\t</tr>\n\t</table>\n\t\n\t";
    $html = $tpl->_ENGINE_parse_body($html, "fileshares.index.php");
    echo $html;
}
Exemplo n.º 3
0
function logon()
{
    include "ressources/settings.inc";
    $_POST["artica_password"] = url_decode_special($_POST["artica_password"]);
    writelogs("Testing logon....{$_POST["artica_username"]}", __FUNCTION__, __FILE__, __LINE__);
    writelogs("Testing logon.... password:{$_POST["artica_password"]}", __FUNCTION__, __FILE__, __LINE__);
    $_COOKIE["artica-language"] = $_POST["lang"];
    $socks = new sockets();
    if (!$socks->TestArticaPort()) {
        if (is_file("ressources/logs/boa.start")) {
            $boa_error = file_get_contents("ressources/logs/boa.start");
        }
        echo "Unable to connect to Artica daemon port:{$boa_error}";
        exit;
    }
    if ($_POST["artica_username"] == $_GLOBAL["ldap_admin"]) {
        if ($_POST["artica_password"] != $_GLOBAL["ldap_password"]) {
            echo "bad password";
            return null;
        } else {
            //session_start();
            $_SESSION["uid"] = '-100';
            $_SESSION["groupid"] = '-100';
            $_SESSION["passwd"] = $_POST["artica_password"];
            setcookie("artica-language", $_POST["lang"], time() + 172800);
            $_SESSION["detected_lang"] = $_POST["lang"];
            $_SESSION["privileges"]["ArticaGroupPrivileges"] = '
			[AllowAddGroup]="yes"
			[AllowAddUsers]="yes"
			[AllowChangeKav]="yes"
			[AllowChangeKas]="yes"
			[AllowChangeUserPassword]="yes"
			[AllowEditAliases]="yes"
			[AllowEditAsWbl]="yes"
			[AsSystemAdministrator]="yes"
			[AsPostfixAdministrator]="yes"
			[AsArticaAdministrator]="yes"
			';
            $tpl = new templates();
            echo "location:admin.index.php";
            exit;
        }
    }
    writelogs('This is not Global admin, so test user...', __FUNCTION__, __FILE__);
    $u = new user($_POST["artica_username"]);
    $userPassword = $u->password;
    if (trim($u->uidNumber) == null) {
        writelogs('Unable to get user infos abort', __FUNCTION__, __FILE__);
        echo "Unknown user";
        return null;
    }
    if (trim($_POST["artica_password"]) == trim($userPassword)) {
        $ldap = new clladp();
        $ouprivs = $ldap->_Get_privileges_ou($u->uid, $u->ou);
        $privileges = $ldap->_Get_privileges_userid($_POST["artica_username"]);
        $_SESSION["OU_LANG"] = $ouprivs["ForceLanguageUsers"];
        $_SESSION["uid"] = $_POST["artica_username"];
        $_SESSION["passwd"] = $_POST["artica_password"];
        $_SESSION["privileges"]["ArticaGroupPrivileges"] = $privileges;
        $_SESSION["groupid"] = $ldap->UserGetGroups($_POST["artica_username"], 1);
        $_SESSION["DotClearUserEnabled"] = $u->DotClearUserEnabled;
        $_SESSION["MailboxActive"] = $u->MailboxActive;
        $_SESSION["ou"] = $u->ou;
        $_SESSION["UsersInterfaceDatas"] = trim($u->UsersInterfaceDatas);
        $lang = new articaLang();
        writelogs("default organization language={$_SESSION["OU_LANG"]}", __FUNCTION__, __FILE__);
        if (trim($_SESSION["OU_LANG"]) != null) {
            $_SESSION["detected_lang"] = $_SESSION["OU_LANG"];
            setcookie("artica-language", $_SESSION["OU_LANG"], time() + 172800);
        } else {
            setcookie("artica-language", $_POST["lang"], time() + 172800);
            $_SESSION["detected_lang"] = $lang->get_languages();
        }
        $users = new usersMenus();
        $privileges_array = $users->_ParsePrivieleges($privileges);
        $users->_TranslateRights($privileges_array, true);
        if (!$users->IfIsAnuser(true)) {
            writelogs('This is not an user =>admin.index.php ', __FUNCTION__, __FILE__);
            echo "location:admin.index.php";
            return null;
        }
        writelogs('IT IS AN USER =>../user-backup/logon.php ', __FUNCTION__, __FILE__);
        $tpl = new templates();
        $array["USERNAME"] = $_POST["artica_username"];
        $array["PASSWORD"] = md5($_POST["artica_username"]);
        $credentials = base64_encode(serialize($array));
        echo "location:../user-backup/logon.php?credentials={$credentials}";
        return null;
        exit;
    } else {
        writelogs("The passord typed  is not the same in ldap database...", __FUNCTION__, __FILE__);
        echo "bad password";
        return null;
    }
}
Exemplo n.º 4
0
function logon()
{
    include "ressources/settings.inc";
    $sock = new sockets();
    $_POST["artica_password"] = url_decode_special($_POST["artica_password"]);
    writelogs("Testing logon....{$_POST["artica_username"]}", __FUNCTION__, __FILE__, __LINE__);
    writelogs("Testing logon.... password:{$_POST["artica_password"]}", __FUNCTION__, __FILE__, __LINE__);
    $_COOKIE["artica-language"] = $_POST["lang"];
    $FileCookyKey = md5($_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"]);
    $sock->SET_INFO($FileCookyKey, $_POST["Changelang"]);
    $socks = new sockets();
    if (!$socks->TestArticaPort()) {
        if (is_file("ressources/logs/boa.start")) {
            $boa_error = file_get_contents("ressources/logs/boa.start");
        }
        echo "Unable to connect to Artica daemon port:{$boa_error}";
        exit;
    }
    while (list($index, $value) = each($_SERVER)) {
        $notice[] = "{$index}:{$value}";
    }
    if ($_POST["artica_username"] == $_GLOBAL["ldap_admin"]) {
        if ($_POST["artica_password"] != $_GLOBAL["ldap_password"]) {
            writelogs("Testing logon.... password:{$_POST["artica_password"]}!==\"{$_GLOBAL["ldap_password"]}\"", __FUNCTION__, __FILE__, __LINE__);
            artica_mysql_events("Failed to logon on the Artica Web console from {$_SERVER["REMOTE_HOST"]}", @implode("\n", $notice), "security", "security");
            echo "bad password";
            return null;
        } else {
            artica_mysql_events("Success to logon on the Artica Web console from {$_SERVER["REMOTE_HOST"]} as SuperAdmin", @implode("\n", $notice), "security", "security");
            //session_start();
            $_SESSION["uid"] = '-100';
            $_SESSION["groupid"] = '-100';
            $_SESSION["passwd"] = $_POST["artica_password"];
            $_SESSION["InterfaceType"] = "{APP_ARTICA_ADM}";
            setcookie("artica-language", $_POST["lang"], time() + 172800);
            $_SESSION["detected_lang"] = $_POST["lang"];
            $_SESSION["privileges"]["ArticaGroupPrivileges"] = '
			[AllowAddGroup]="yes"
			[AllowAddUsers]="yes"
			[AllowChangeKav]="yes"
			[AllowChangeKas]="yes"
			[AllowChangeUserPassword]="yes"
			[AllowEditAliases]="yes"
			[AllowEditAsWbl]="yes"
			[AsSystemAdministrator]="yes"
			[AsPostfixAdministrator]="yes"
			[AsArticaAdministrator]="yes"
			';
            $tpl = new templates();
            echo "location:admin.index.php";
            exit;
        }
    }
    writelogs('This is not Global admin, so test user...', __FUNCTION__, __FILE__);
    $u = new user($_POST["artica_username"]);
    $userPassword = $u->password;
    if (trim($u->uidNumber) == null) {
        writelogs('Unable to get user infos abort', __FUNCTION__, __FILE__);
        echo "Unknown user";
        return null;
    }
    if (trim($_POST["artica_password"]) == trim($userPassword)) {
        $ldap = new clladp();
        $users = new usersMenus();
        $privs = new privileges($u->uid);
        $privileges_array = $privs->privs;
        setcookie("mem-logon-user", $_POST["artica_username"], time() + 172800);
        $_SESSION["privileges_array"] = $privs->privs;
        $_SESSION["privs"] = $privileges_array;
        $_SESSION["OU_LANG"] = $privileges_array["ForceLanguageUsers"];
        $_SESSION["uid"] = $_POST["artica_username"];
        $_SESSION["passwd"] = $_POST["artica_password"];
        $_SESSION["privileges"]["ArticaGroupPrivileges"] = $privs->content;
        $_SESSION["groupid"] = $ldap->UserGetGroups($_POST["artica_username"], 1);
        $_SESSION["DotClearUserEnabled"] = $u->DotClearUserEnabled;
        $_SESSION["MailboxActive"] = $u->MailboxActive;
        $_SESSION["InterfaceType"] = "{APP_ARTICA_ADM}";
        $_SESSION["ou"] = $u->ou;
        $_SESSION["UsersInterfaceDatas"] = trim($u->UsersInterfaceDatas);
        $lang = new articaLang();
        writelogs("[{$_POST["artica_username"]}]: Default organization language={$_SESSION["OU_LANG"]}", __FUNCTION__, __FILE__);
        if (trim($_SESSION["OU_LANG"]) != null) {
            $_SESSION["detected_lang"] = $_SESSION["OU_LANG"];
            setcookie("artica-language", $_SESSION["OU_LANG"], time() + 172800);
        } else {
            setcookie("artica-language", $_POST["lang"], time() + 172800);
            $_SESSION["detected_lang"] = $lang->get_languages();
        }
        $users->_TranslateRights($privileges_array, true);
        if (!$users->IfIsAnuser(true)) {
            artica_mysql_events("Success to logon on the Artica Web console from {$_SERVER["REMOTE_HOST"]} as User", @implode("\n", $notice), "security", "security");
            writelogs("[{$_POST["artica_username"]}]: This is not an user =>admin.index.php", __FUNCTION__, __FILE__);
            echo "location:admin.index.php";
            return null;
        }
        writelogs("[{$_POST["artica_username"]}]: IS AN USER =>../user-backup/logon.php", __FUNCTION__, __FILE__);
        $tpl = new templates();
        $array["USERNAME"] = $_POST["artica_username"];
        $array["PASSWORD"] = md5($_POST["artica_username"]);
        $credentials = base64_encode(serialize($array));
        artica_mysql_events("Success to redirect on the end-user management console from {$_SERVER["REMOTE_HOST"]} as User", @implode("\n", $notice), "security", "security");
        echo "location:../user-backup/logon.php?credentials={$credentials}";
        return null;
        exit;
    } else {
        writelogs("[{$_POST["artica_username"]}]: The password typed  is not the same in ldap database...", __FUNCTION__, __FILE__);
        artica_mysql_events("Failed to logon on the management console as user from {$_SERVER["REMOTE_HOST"]} (bad password)", @implode("\n", $notice), "security", "security");
        echo "bad password";
        return null;
    }
}
Exemplo n.º 5
0
function logon()
{
    include "ressources/settings.inc";
    include_once 'ressources/class.sockets.inc';
    include_once 'ressources/class.ldap.inc';
    include_once 'ressources/class.user.inc';
    include_once 'ressources/class.langages.inc';
    $sock = new sockets();
    $tpl = new templates();
    $_POST["artica_password"] = url_decode_special($_POST["artica_password"]);
    writelogs("Testing logon....{$_POST["artica_username"]}", __FUNCTION__, __FILE__, __LINE__);
    //writelogs("Testing logon.... password:{$_POST["artica_password"]}",__FUNCTION__,__FILE__,__LINE__);
    $_COOKIE["artica-language"] = $_POST["lang"];
    $FileCookyKey = md5($_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"]);
    $sock->SET_INFO($FileCookyKey, $_POST["Changelang"]);
    if (!isset($GLOBALS["FixedLanguage"])) {
        $GLOBALS["FixedLanguage"] = $sock->GET_INFO("FixedLanguage");
    }
    $VIA_API = false;
    if (isset($_POST["VIA_API"])) {
        $VIA_API = true;
    }
    if ($_SESSION["uid"] != null) {
        if (!$VIA_API) {
            echo "location:admin.index.php";
            return;
        }
    }
    $socks = new sockets();
    while (list($index, $value) = each($_SERVER)) {
        $notice[] = "{$index}:{$value}";
    }
    if ($_GLOBAL["ldap_admin"] == null) {
        $sock->getFrameWork("services.php?process1-tenir=yes?MyCURLTIMEOUT=120");
        include "ressources/settings.inc";
    }
    if ($_GLOBAL["ldap_admin"] == null) {
        if ($VIA_API) {
            echo "FALSE";
            return;
        }
        $tpl = new templates();
        echo $tpl->javascript_parse_text("{ldap_username_corrupt_text}");
        return null;
    }
    $md5submitted = $_POST["artica_password"];
    if ($VIA_API) {
        $md5submitted = md5($_POST["artica_password"]);
    }
    $md5Manager = md5(trim($_GLOBAL["ldap_password"]));
    if (trim($GLOBALS["FixedLanguage"]) != null) {
        $_POST["lang"] = $GLOBALS["FixedLanguage"];
    }
    $trimed_artica_username = trim(strtolower($_POST["artica_username"]));
    $trimed_ldap_admin = trim(strtolower($_GLOBAL["ldap_admin"]));
    writelogs("Manager -> {$trimed_artica_username} ?=== {$trimed_ldap_admin}", _FUNCTION__, __FILE__, __LINE__);
    if ($trimed_artica_username == $trimed_ldap_admin) {
        writelogs("Manager: `YES`", __FUNCTION__, __FILE__, __LINE__);
        if ($md5Manager != $md5submitted) {
            $tpl = new templates();
            //writelogs("Testing logon.... password:{$_POST["artica_password"]}!==\"{$_GLOBAL["ldap_password"]}\"",__FUNCTION__,__FILE__,__LINE__);
            artica_mysql_events("Failed to logon on the Artica Web console from {$_SERVER["REMOTE_HOST"]}", @implode("\n", $notice), "security", "security");
            if ($VIA_API) {
                echo "FALSE";
                return;
            }
            echo $tpl->javascript_parse_text("{wrong_password_or_username}");
            return null;
        } else {
            $users = new usersMenus();
            artica_mysql_events("Success to logon on the Artica Web console from {$_SERVER["REMOTE_HOST"]} as SuperAdmin", @implode("\n", $notice), "security", "security");
            //session_start();
            $_SESSION["uid"] = '-100';
            $_SESSION["groupid"] = '-100';
            $_SESSION["passwd"] = $_GLOBAL["ldap_password"];
            $_SESSION["MINIADM"] = false;
            setcookie("MINIADM", "No", time() + 1000);
            $_SESSION["InterfaceType"] = "{APP_ARTICA_ADM}";
            setcookie("artica-language", $_POST["lang"], time() + 172800);
            $_SESSION["detected_lang"] = $_POST["lang"];
            $_SESSION["CORP"] = $users->CORP_LICENSE;
            $_SESSION["privileges"]["ArticaGroupPrivileges"] = '
			[AllowAddGroup]="yes"
			[AllowAddUsers]="yes"
			[AllowChangeKav]="yes"
			[AllowChangeKas]="yes"
			[AllowChangeUserPassword]="yes"
			[AllowEditAliases]="yes"
			[AllowEditAsWbl]="yes"
			[AsSystemAdministrator]="yes"
			[AsPostfixAdministrator]="yes"
			[AsArticaAdministrator]="yes"
			[AsArticaMetaAdmin]="yes"
			';
            if ($VIA_API) {
                writelogs("VIA API = TRUE -> BUILD SESSION", _FUNCTION__, __FILE__, __LINE__);
                BuildSession($_SESSION["uid"]);
                echo "TRUE";
                return;
            }
            $tpl = new templates();
            $sock->getFrameWork("squid.php?clean-catz-cache=yes");
            writelogs("OK it is a global admin -> location:admin.index.php", _FUNCTION__, __FILE__, __LINE__);
            echo "location:admin.index.php";
            exit;
        }
    }
    $ldap = new clladp();
    if ($ldap->IsKerbAuth()) {
        $userPassword = $_POST["artica_password"];
        if (isset($_POST["artica_password_crypted"])) {
            $userPassword = $_POST["artica_password_crypted"];
            include_once dirname(__FILE__) . "/ressources/class.cryptform.inc";
            $userPassword = logon_decrypt($userPassword);
        }
        writelogs("*** TEST Active Directory user {$_POST["artica_username"]} ****", __FUNCTION__, __FILE__, __LINE__);
        $external_ad_search = new external_ad_search();
        if ($external_ad_search->CheckUserAuth($_POST["artica_username"], $userPassword)) {
            writelogs("*** TEST Active Directory user {$_POST["artica_username"]} success ****", __FUNCTION__, __FILE__, __LINE__);
            $_SESSION["MINIADM"] = false;
            setcookie("MINIADM", "No", time() + 1000);
            $_SESSION["InterfaceType"] = "{APP_ARTICA_ADM}";
            setcookie("artica-language", $_POST["lang"], time() + 172800);
            $_SESSION["detected_lang"] = $_POST["lang"];
            $_SESSION["CORP"] = $users->CORP_LICENSE;
            $users = new usersMenus();
            $privs = new privileges($_POST["artica_username"]);
            $privileges_array = $privs->privs;
            DumpPrivileges($_POST["artica_username"], $privileges_array);
            $users->_TranslateRights($privileges_array, true);
            setcookie("mem-logon-user", $_POST["artica_username"], time() + 172800);
            $_SESSION["privileges_array"] = $privs->privs;
            $_SESSION["uid"] = $_POST["artica_username"];
            BuildSession($_POST["artica_username"]);
            $sock->getFrameWork("squid.php?clean-catz-cache=yes");
            $_SESSION["MINIADM"] = false;
            setcookie("MINIADM", "No", time() + 1000);
            if ($VIA_API) {
                BuildSession($_SESSION["uid"]);
                echo "TRUE";
                return;
            }
            echo "location:admin.index.php";
            return;
        } else {
            if (is_array($GLOBALS["CLASS_ACTV"])) {
                while (list($key, $line) = each($GLOBALS["CLASS_ACTV"])) {
                    writelogs("*** Active Directory {$line}", __FUNCTION__, __FILE__, __LINE__);
                }
            }
        }
    }
    if (Radius_admins($_POST["artica_username"], $md5submitted)) {
        writelogs('*** TEST RADIUS USER ****', __FUNCTION__, __FILE__, __LINE__);
        $tpl = new templates();
        $sock->getFrameWork("squid.php?clean-catz-cache=yes");
        writelogs("OK it is a global admin -> location:admin.index.php", _FUNCTION__, __FILE__, __LINE__);
        if ($VIA_API) {
            BuildSession($_SESSION["uid"]);
            echo "TRUE";
            return;
        }
        echo "location:admin.index.php";
        exit;
    }
    writelogs('This is not Global admin, so test user...', __FUNCTION__, __FILE__, __LINE__);
    $u = new user($_POST["artica_username"]);
    $userPassword = $u->password;
    if (trim($u->uidNumber) == null) {
        if ($VIA_API) {
            echo "FALSE";
            return;
        }
        writelogs('Unable to get user infos abort', __FUNCTION__, __FILE__);
        echo $tpl->javascript_parse_text("{wrong_password_or_username}");
        return null;
    }
    $tpl = new templates();
    if (trim($_POST["artica_password"]) == md5(trim($userPassword))) {
        BuildSession($u->uid);
        $ldap = new clladp();
        $users = new usersMenus();
        $privs = new privileges($u->uid);
        $privileges_array = $privs->privs;
        if (trim($FixedLanguage) != null) {
            $_SESSION["detected_lang"] = $FixedLanguage;
        }
        $users->_TranslateRights($privileges_array, true);
        if (!$users->IfIsAnuser(true)) {
            if ($VIA_API) {
                echo "TRUE";
                return;
            }
            artica_mysql_events("Success to logon on the Artica Web console from {$_SERVER["REMOTE_HOST"]} as User", @implode("\n", $notice), "security", "security");
            writelogs("[{$_POST["artica_username"]}]: This is not an user =>admin.index.php", __FUNCTION__, __FILE__);
            $sock->getFrameWork("squid.php?clean-catz-cache=yes");
            $_SESSION["MINIADM"] = false;
            setcookie("MINIADM", "No", time() + 1000);
            if ($VIA_API) {
                BuildSession($_SESSION["uid"]);
                echo "TRUE";
                return;
            }
            echo "location:admin.index.php";
            return null;
        }
        if ($VIA_API) {
            BuildSession($_SESSION["uid"]);
            echo "TRUE";
            return;
        }
        writelogs("[{$_POST["artica_username"]}]: IS AN USER =>../user-backup/logon.php", __FUNCTION__, __FILE__);
        $array["USERNAME"] = $_POST["artica_username"];
        $array["PASSWORD"] = md5($_POST["artica_username"]);
        $credentials = base64_encode(serialize($array));
        artica_mysql_events("Success to redirect on the end-user management console from {$_SERVER["REMOTE_HOST"]} as User", @implode("\n", $notice), "security", "security");
        echo "location:../miniadm.logon.php?credentials={$credentials}";
        return null;
        exit;
    } else {
        if ($VIA_API) {
            echo "FALSE";
            return;
        }
        writelogs("[{$_POST["artica_username"]}]: The password typed  is not the same in ldap database...", __FUNCTION__, __FILE__);
        artica_mysql_events("Failed to logon on the management console as user from {$_SERVER["REMOTE_HOST"]} (bad password)", @implode("\n", $notice), "security", "security");
        echo $tpl->javascript_parse_text("{wrong_password_or_username}");
        return null;
    }
}