コード例 #1
0
 public function SignUp($name, $surname, $mail, $userName, $pass, $repass, $emailf, $namef, $captcha_code)
 {
     $myConnection = new Connection();
     //Valido los datos
     $errorMessage = self::validate($name, $surname, $mail, $userName, $pass, $repass, $emailf, $namef, $captcha_code);
     $isError = false;
     $errorMessageView = "";
     foreach ($errorMessage as $error) {
         if ($error !== 0) {
             $isError = true;
             $errorMessageView = $errorMessageView . $error . "<br>";
         }
     }
     if ($isError) {
         //Informo que hay errores y el mensaje de error
         echo $errorMessageView;
     } else {
         //Verifico que el mail y nombre de usuario no estén en uso
         $errorMessageView = self::verify($mail, $userName);
         if (strlen($errorMessageView) > 1) {
             //Informo.
             echo $errorMessageView;
         } else {
             //Procedo a insertar los datos a la bdd.
             $surnameOK = ucfirst(strtolower($surname));
             #Primer letra mayucula y el resto de lo que escribo en minuscula
             $nameOK = ucfirst(strtolower($name));
             #Primer letra mayucula y el resto de lo que escribo en minuscula
             //$pass = sha1($myConnection -> real_escape_string($pass));
             //Encripto password con Bcrypt, salt generado automáticamente.
             $pass = password_hash($myConnection->real_escape_string($pass), PASSWORD_BCRYPT);
             //$pass = sha1($myConnection -> real_escape_string($pass));
             $myConnection->query("INSERT INTO USUARIO (id_usuario,rol,nombre,apellido,mail,nombre_usuario,contraseña,estado, fecha_baja) VALUES\n                ('','Comun','{$nameOK}','{$surnameOK}','{$mail}','{$userName}','{$pass}','Pendiente', null);");
             $lastID = $myConnection->insert_id;
             $wall = new WallRepositoryService();
             $wall->createWall($lastID);
             $inbox = new InboxRepositoryService();
             $inbox->createInbox($lastID);
             echo "<div class='col-sm-12'>";
             echo "<div class='jumbotron col-sm-6 col-sm-push-3'>";
             echo "<h1 class='text-center'>Usuario registrado</h1>";
             echo "<a class='btn btn-primary btn-lg pull-right' href='../../index.php' role='button'>Inicio</a>";
             echo "</div>";
             echo "</div>";
         }
     }
     $myConnection->close();
 }
コード例 #2
0
function removeUser($userNameRemove)
{
    $mysession = new Session();
    $mysession->initSession();
    $wallRepo = new WallRepositoryService();
    $userRepo = new UserRepositoryService();
    $userName = $_SESSION['usuario'];
    $wallId = $wallRepo->getWallIdByUserName($userName);
    $userIdRemove = $userRepo->getUserIdByName($userNameRemove);
    $results = $wallRepo->removeUser($userIdRemove, $wallId);
    if ($results === TRUE) {
        $response['valid'] = true;
    } else {
        $response['errorMsg'] = "Lo sentimos, hubo un error al eliminar el usuario de su lista.";
        $response['valid'] = false;
    }
    echo json_encode($response);
}
コード例 #3
0
<?php

require_once dirname(__DIR__) . "/domain/User.php";
require_once dirname(__DIR__) . "/domain/Wall.php";
require_once dirname(__DIR__) . "/services/WallRepositoryService.php";
require_once dirname(__DIR__) . "/services/InboxRepositoryService.php";
$patron = "/^[[:digit:]]+\$/";
if (preg_match($patron, $_GET['usuario'])) {
    $idUsuario = $_GET['usuario'];
} else {
    header('location:index.php?error=4');
    exit;
}
$wallRepo = new WallRepositoryService();
$inboxRepo = new InboxRepositoryService();
$wallResult = $wallRepo->getWallByUserId($idUsuario);
//
$MessageLimitResult = $inboxRepo->getMessageLimit($idUsuario);
//
$MessageNumResult = $inboxRepo->getMessageNum($idUsuario);
//
if ($wallResult->num_rows > 0) {
    $userHasWall = true;
} else {
    $userHasWall = false;
}
if ($userHasWall) {
    $objWall = $wallResult->fetch_object();
    $privacidad = $objWall->privacidad;
    $idMuro = $objWall->id_muro;
    $anonimoLectura = $objWall->flag_anonimo_lectura;
コード例 #4
0
<?php

require_once dirname(__DIR__) . "/services/WallRepositoryService.php";
require_once dirname(__DIR__) . "/services/UserRepositoryService.php";
$wallRepo = new WallRepositoryService();
$userRepo = new UserRepositoryService();
$userId = $_SESSION['id'];
$wallId = $userRepo->getWallIdById($userId);
//$privacity = isset($_POST['change']) ? $_POST['change'] : $wallRepo -> getPrivacityById($wallId);
$privacity = $wallRepo->getPrivacityById($wallId);
$checkedPrivate = "";
$checkedSemiPrivate = "";
$checkedNormal = "";
$checkedSemiPublic = "";
$checkedPublic = "";
$usersPrivate = null;
$usersSemiPrivate = null;
switch ($privacity) {
    case 'privado':
        $checkedPrivate = "checked";
        $usersPrivate = $wallRepo->getUsersById($wallId);
        break;
    case 'semiprivado':
        $checkedSemiPrivate = "checked";
        $usersSemiPrivate = $wallRepo->getUsersById($wallId);
        break;
    case 'normal':
        $checkedNormal = "checked";
        break;
    case 'semipublico':
        $checkedSemiPublic = "checked";
コード例 #5
0
$mysession->initSession();
$content = $_POST["content"];
$toWall = $_POST["toWall"];
$patron = "/^[[:digit:]]+\$/";
if (isset($_SESSION['id']) and preg_match($patron, $_SESSION['id'])) {
    $fromUser = $_SESSION['id'];
} else {
    //El id 1 pertenece al usuario anonimo
    $fromUser = 1;
}
if (isset($_POST["toUser"]) and preg_match($patron, $_POST["toUser"])) {
    $toUser = $_POST["toUser"];
} else {
    header('location:index.php?error=4');
    exit;
}
echo "string";
$wallRepo = new WallRepositoryService();
$wallResult = $wallRepo->getWallByUserId($toUser);
if ($row = $wallResult->fetch_object()) {
    $wall = new Wall();
    $messages = $wall->getMessages($row->limite_muro, $toUser);
    if (count($messages) < $row->limite_muro) {
        $cbcCipher = new CbcCipher($content);
        $content = $cbcCipher->encrypt();
        $message = new Message($content, $toWall, $fromUser);
        header('location: ../../index.php?usuario=' . $toUser);
    } else {
        header('location: ../../index.php?usuario=' . $toUser . '&alert');
    }
}
コード例 #6
0
<?php

require_once dirname(__DIR__) . "/services/WallRepositoryService.php";
require_once dirname(__DIR__) . "/services/UserRepositoryService.php";
require_once dirname(__DIR__) . "/domain/Session.php";
$mysession = new Session();
$mysession->initSession();
$wallRepo = new WallRepositoryService();
$userRepo = new UserRepositoryService();
$json = $_POST['data'];
$data = json_decode($json, true);
$newData['privacity'] = $data['opt'];
if (isset($_SESSION['usuario']) and preg_match("/^[a-zA-ZñÑáéíóÁÉÍÓÚ]*\$/", $_SESSION['usuario'])) {
    $userName = $_SESSION['usuario'];
    $newData['wallId'] = $wallRepo->getWallIdByUserName($userName);
    if ($data['opt'] == 'private') {
        //Obtengo el userId de cada userName
        $newUsers = array();
        foreach ($data['users'] as $user) {
            $newUsers[] = $userRepo->getUserIdByName($user);
        }
        $newData['users'] = $newUsers;
    } else {
        if ($data['opt'] == 'semiprivate') {
            //Obtengo el userId de cada userName
            $newUsers = array();
            foreach ($data['users'] as $user) {
                $newUsers[] = $userRepo->getUserIdByName($user);
            }
            $newData['users'] = $newUsers;
        }