Ejemplo n.º 1
0
$User->setUserPass($userPass);
if ($resLdap = SP\Auth::authUserLDAP($userLogin, $userPass)) {
    $User->setUserName(SP\Auth::$userName);
    $User->setUserEmail(SP\Auth::$userEmail);
}
$Log = new \SP\Log(_('Inicio sesión'));
// Autentificamos por LDAP
if ($resLdap === true) {
    $Log->addDescription('(LDAP)');
    $Log->addDescription(sprintf('%s: %s', _('Servidor Login'), \SP\Ldap::getLdapServer()));
    // Verificamos si el usuario existe en la BBDD
    if (!UserLdap::checkLDAPUserInDB($userLogin)) {
        // Creamos el usuario de LDAP en MySQL
        if (!\SP\UserLdap::newUserLDAP($User)) {
            $Log->addDescription(_('Error al guardar los datos de LDAP'));
            $Log->writeLog();
            SP\Response::printJSON(_('Error interno'));
        }
    } else {
        // Actualizamos la clave del usuario en MySQL
        if (!UserLdap::updateLDAPUserInDB($User)) {
            $Log->addDescription(_('Error al actualizar la clave del usuario en la BBDD'));
            $Log->writeLog();
            SP\Response::printJSON(_('Error interno'));
        }
    }
} else {
    if ($resLdap == 49) {
        $Log->addDescription('(LDAP)');
        $Log->addDescription(_('Login incorrecto'));
        $Log->addDescription(sprintf('%s: %s', _('Usuario'), $userLogin));
Ejemplo n.º 2
0
$accountId = SP\Request::analyze('accountId', 0);
$fileId = SP\Request::analyze('fileId', 0);
$log = new \SP\Log();
if ($action == 'upload') {
    if (!is_array($_FILES["inFile"]) || $accountId === 0) {
        \SP\Response::printJSON(_('CONSULTA INVÁLIDA'));
    }
    $log->setAction(_('Subir Archivo'));
    $allowedExts = strtoupper(SP\Config::getValue('files_allowed_exts'));
    $allowedSize = SP\Config::getValue('files_allowed_size');
    if ($allowedExts) {
        // Extensiones aceptadas
        $extsOk = explode(",", $allowedExts);
    } else {
        $log->addDescription(_('No hay extensiones permitidas'));
        $log->writeLog();
        \SP\Response::printJSON($log->getDescription());
    }
    if (is_array($_FILES) && $_FILES['inFile']['name']) {
        // Comprobamos la extensión del archivo
        $fileData['extension'] = strtoupper(pathinfo($_FILES['inFile']['name'], PATHINFO_EXTENSION));
        if (!in_array($fileData['extension'], $extsOk)) {
            $log->addDescription(_('Tipo de archivo no soportado') . " '" . $fileData['extension'] . "' ");
            $log->writeLog();
            \SP\Response::printJSON($log->getDescription());
        }
    } else {
        $log->addDescription(_('Archivo inválido') . ":<br>" . $_FILES['inFile']['name']);
        $log->writeLog();
        \SP\Response::printJSON($log->getDescription());
    }