예제 #1
0
$log = $manager->select_special($tables, $rel, $filters, " LIMIT 1");
//testando
if ($log === false) {
    header("location: {$project_index}/?error=user_not_found");
} elseif ($log[0]['user_status'] == "0") {
    //status
    header("location: {$project_index}/?error=user_inative");
} elseif ($log[0]['user_password'] != $password) {
    //senha
    header("location: {$project_index}/?error=password_incorrect");
} else {
    //deu certo.
    //atualizando ultimo acesso
    $last_d['user_last_access'] = date('Y-m-d H:i:s');
    $last_f['id_user'] = $log[0]['id_user'];
    $manager->update_common('tb_user', $last_d, $last_f, "");
    $log[0]['user_last_access'] = $last_d['user_last_access'];
    //removendo a senha
    unset($log[0]['user_password']);
    //criando o objeto com os dados do banco
    $user = new User($log[0]['user_name'], $log[0]['user_email']);
    //setando dados do usuario.
    foreach ($log[0] as $k => $v) {
        $user->{$k} = $v;
    }
    //inicia o serviço sessão
    session_start();
    //colocando o objeto dentro da sessao.
    $_SESSION[md5('us_inventory')] = $user;
    header("location: {$project_index}");
}
include_once dirname(__DIR__) . '/model/urls.php';
include_once $project_path . '/model/class/Connect.class.php';
include_once $project_path . '/model/class/Manager.class.php';
include_once $project_path . '/model/class/User.class.php';
//iniciar a sessao
session_start();
//testando permissão.
if (!isset($_SESSION[md5('us_inventory')])) {
    header("location: {$project_index}?error=permission_denied");
}
//resgata os dados antigos do usuário
$user = $_SESSION[md5('us_inventory')];
//receber os dados
$new_data['user_name'] = $_POST['name'];
$new_data['user_email'] = $_POST['email'];
if ($_POST['password'] != "") {
    $new_data['user_password'] = sha1($_POST['password']);
}
//alterar no banco
$manager = new Manager();
//filtros
$filters['id_user'] = $user->id_user;
//executa a atualização
$manager->update_common('tb_user', $new_data, $filters, "");
//alterar na sessao
$user->user_name = $new_data['user_name'];
$user->user_email = $new_data['user_email'];
//atualiza a sessao
$_SESSION[md5('us_inventory')] = $user;
header("location: {$project_index}/" . $user->profile_page . ".php?success=user_updated");
<?php

include_once dirname(__DIR__) . '/model/urls.php';
include_once $project_path . '/model/class/Connect.class.php';
include_once $project_path . '/model/class/Manager.class.php';
include_once $project_path . '/model/class/User.class.php';
session_start();
//permissao
if (!isset($_SESSION[md5('us_inventory')])) {
    header("location: {$project_index}?error=permission_denied");
}
//testa se é admin
$user = $_SESSION[md5('us_inventory')];
if ($user->profile_page != "admin") {
    header("location: {$project_index}?error=permission_denied");
}
if (!isset($_POST['filter'])) {
    header("location: {$project_index}?error=less_permission");
}
//aqui começa...
//recebe os dados
$new_data['category_name'] = $_POST['name'];
$new_data['category_desc'] = $_POST['desc'];
$filter['id_category'] = $_POST['filter'];
$manager = new Manager();
$manager->update_common('tb_category', $new_data, $filter, "");
header("location: {$project_index}/" . $user->profile_page . ".php?option=list_categories&success=category_updated");
<?php

include_once dirname(__DIR__) . '/model/urls.php';
include_once $project_path . '/model/class/Connect.class.php';
include_once $project_path . '/model/class/Manager.class.php';
include_once $project_path . '/model/class/User.class.php';
session_start();
if (!isset($_SESSION[md5('us_inventory')])) {
    header("location: {$project_index}?error=less_permission");
}
//resgata os dados do usuario
$user = $_SESSION[md5('us_inventory')];
//testando permissão
if ($user->profile_page != "admin") {
    header("location: {$project_index}?error=less_permission");
}
if (!isset($_POST['filter'])) {
    header("location: {$project_index}?error=less_permission");
}
//recebendo os dados
$new_data['category_id'] = $_POST['category'];
$new_data['product_name'] = $_POST['name'];
$new_data['product_price'] = $_POST['price'];
$new_data['product_details'] = $_POST['details'];
$new_data['product_quantity'] = $_POST['quantity'];
$filter['id_product'] = $_POST['filter'];
$manager = new Manager();
$manager->update_common('tb_product', $new_data, $filter, "");
header("location: {$project_index}/" . $user->profile_page . ".php?option=list_products&success=product_updated");