Exemplo n.º 1
0
<?php

require_once "../application/models/applicationModel.php";
require_once "../application/models/usersModel.php";
$config = readConfig('../application/configs/config.ini', 'development');
if (isset($_GET['action'])) {
    $action = $_GET['action'];
} else {
    $action = 'select';
}
switch ($action) {
    case 'update':
        // 		die("esto es update");
        if ($_POST) {
        } else {
            $arrayUser = readUser($_GET['id']);
            echo "<pre>";
            print_r($arrayUser);
            echo "</pre>";
        }
    case 'insert':
        if ($_POST) {
            $imageName = uploadImage($_FILES);
            writeToFile($imageName);
            header("Location: users.php?action=select");
            exit;
        } else {
            //			definir arrayUser
            include "../application/views/formulario.php";
        }
        break;
Exemplo n.º 2
0
function deleteUser($id, $filename)
{
    //lee el usuario
    $arrayUser = readUser($id);
    //Tomar la foto
    $image = str_replace(array("\r", "\n"), '', $arrayUser[10]);
    //borra la imagen
    $borra = unlink($_SERVER['DOCUMENT_ROOT'] . "/uploads/" . $image);
    //elimina linea de usuario
    $arrayUsers = readUsersFromFile();
    unset($arrayUsers[$id]);
    $textUser = implode("\r\n", $arrayUsers);
    file_put_contents($filename, $textUser . "\r\n");
}