Example #1
0
<?php

/**
 * Created by PhpStorm.
 * User: hssh_win8.1
 * Date: 2015/10/6
 * Time: 20:00
 * file: goodsdelhandle.php 删除商品 get入goods_id
 */
require_once './common/include.php';
// 实例化数据库
$mu = new ModelUser('bl_goods');
// 获得删除的goods_id
if (!isset($_GET['goods_id']) || intval($_GET['goods_id']) < 1) {
    echo "1";
    return;
}
$goods_id = intval($_GET['goods_id']);
$res = $mu->update(array('is_delete' => 1), 'goods_id=' . $goods_id);
if ($res != 1) {
    echo "1";
    return;
} else {
    echo "0";
    return;
}
Example #2
0
$type = $_POST['type'];
// return 代表还原 drop代表彻底删除
// 创建数据库实例
$mu = new ModelUser('bl_cate');
// 还原
if ($type == 'return') {
    // 先判断父栏目是否存在 不存在的话 不能还原
    $allDelId = $mu->getOneAllValue('cate_id', 'is_delete=1');
    //    print_r($allDelId);return;
    if (in_array($parent_id, $allDelId)) {
        // 父栏目在回收站中 还原失败 应该先还原父栏目
        echo "2";
        return;
    }
    $arr = array('is_delete' => 0);
    $res = $mu->update($arr, 'cate_id=' . $cate_id);
    if ($res != 1) {
        // 还原失败
        echo '1';
        return;
    } else {
        // 还原成功
        echo '0';
        return;
    }
} else {
    if ($type = 'drop') {
        $res = $mu->delete('cate_id=' . $cate_id);
        if ($res != 1) {
            // 彻底删除失败
            echo '1';
Example #3
0
// 获取数据库实例
$mu = new ModelUser('bl_goods');
// 补充部分数据
$goods_sn = empty($_POST['goods_sn']) ? ToolsGoodsSn::GetGoodsSn() : $_POST['goods_sn'];
// 获得唯一的货单号
$goods_weight = empty($_POST['goods_weight']) ? '0' : $_POST['goods_weight'];
$goods_total = empty($_POST['goods_total']) ? 0 : $_POST['goods_total'] + 0;
// 移动照片
$tempimg = ROOT . 'data/images/temp/' . $_POST['goods_img'];
$img = ROOT . 'data/images/goods/' . $_POST['goods_img'];
if (!is_file($img)) {
    //$img是文件的时证明图片没有被修改
    if (!is_file($tempimg) || !rename($tempimg, $img)) {
        echo "1";
        return;
    }
}
//并生成400*400中图 和1000*1000的大图
ToolsImage::ResizeImage($img, 400, 400, 'mid');
ToolsImage::ResizeImage($img, 1000, 1000, 'big');
$goods_id = $_POST['goods_id'] + 0;
$data = array('goods_name' => $_POST['goods_name'], 'cate_id' => $_POST['cate_id'] + 0, 'goods_time' => time(), 'goods_sn' => $goods_sn, 'goods_price' => $_POST['goods_price'], 'price_unit' => '1', 'goods_weight' => $goods_weight, 'weight_unit' => "1", 'goods_total' => $goods_total, 'is_best' => $_POST['is_best'] + 0, 'is_new' => $_POST['is_new'] + 0, 'is_hot' => $_POST['is_hot'] + 0, 'is_delete' => 0, 'on_sale' => $_POST['on_sale'] + 0, 'goods_key' => $_POST['goods_key'], 'goods_img' => $img, 'goods_desc' => $_POST['goods_desc'], 'goods_details' => $_POST['goods_details'], 'seller_note' => $_POST['seller_note']);
$res = $mu->update($data, 'goods_id=' . $goods_id);
//echo $res;
if ($res != 1 && $res != 0) {
    echo "1";
    retrun;
} else {
    echo "0";
    return;
}
Example #4
0
        echo '<tr><form method="get" action="buscaUser.php">';
        echo '<td><input type="text" name="nomeUserAtual" value="' . $nomeatual['nome'] . '"></input></td>';
        echo '<td><input type="text" name="nomeUserAlt" value="' . $nomeatual['nome'] . '"></input></td>';
        echo '<td><input type="text" name="senhaUserAlt" value="' . $nomeatual['senha'] . '"></input></td>';
        echo '<td><button type="submit">Atualizar Dados</button></td>';
        echo '</form</tr><br></table>';
        echo '<a href="exclusaoUser.php?excluido=' . $nomeatual['nome'] . '">Excluir Usuario</a>';
    } elseif ($nomeatual == NULL) {
        echo "<h2>Nenhum Usuario encontrado com os dados informados!</h2>";
    }
} elseif (isset($_GET['nomeUserAlt'])) {
    echo "<table class='table'>\n        <th>NOME</th>\n        <th>NOVO NOME</th>\n        <th>SENHA</th>";
    $res = $usuario->busca($_GET['nomeUserAlt']);
    $usuario->setNome($_GET['nomeUserAlt']);
    $usuario->setSenha($_GET['senhaUserAlt']);
    $usuario->update($_GET['nomeUserAtual']);
    echo '<h2>Dados do Usuario: ' . $_GET['nomeUserAtual'] . '</h2>';
    echo '<tr><form method="get" action="buscaUser.php">';
    echo '<td><input type="text" name="nomeatual" value="' . $_GET['nomeUserAtual'] . '"></input></td>';
    echo '<td><input type="text" name="nomealt" value="' . $_GET['nomeUserAlt'] . '"></input></td>';
    echo '<td><input type="number" name="SenhaUseralt" min="0" max="10" step="0.1" value="' . $_GET['senhaUserAlt'] . '"></input></td>';
    echo '<td><button type="submit">Atualizar Dados</button></td>';
    echo '</form</tr><br></table>';
    echo '<a href="exclusao.php?excluido=' . $res['nome'] . '">Excluir Usuario</a>';
    echo '<br><br><h3>Os dados do usuario ' . $res['nome'] . " foram alterados conforme dados abaixo:";
    echo "<table class='table'>\n    <th>NOME</th>\n    <th>SENHA</th>";
    $res = $usuario->busca($_GET['nomeUserAlt']);
    echo '<tr>';
    echo '<td>' . $res['nome'] . '</td>';
    echo '<td>' . $res['senha'] . '</td>';
    echo '</table>';
Example #5
0
<?php

/**
 * Created by PhpStorm.
 * User: hssh_win8.1
 * Date: 2015/10/7
 * Time: 18:19
 */
require_once './common/include.php';
// 实例化数据库
$mu = new ModelUser('bl_user');
$username = $_GET['username'];
// 激活用户
$res = $mu->update(array('is_active' => 1), "username='******'");
if ($res != 1) {
    // 激活失败
    exit('激活失败 或者 已经激活');
} else {
    // 激活成功 跳转到商城首页
    header("location: http://" . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']) . '/index.php');
    // 状态为已经登录
    $_SESSION['name'] = $username;
}
Example #6
0
$mu = new ModelUser('bl_cate');
//判断操作类型 query为查询要删除的栏目是否存在子栏目 delete为软删除
$type = $_POST['type'];
$cate_id = $_POST['cate_id'] + 0;
// 查询
if ($type == 'query') {
    $sql = "select count(c2.cate_id) from bl_cate as c1 left join bl_cate as c2 on c1.cate_id=c2.parent_id where c1.cate_id=" . $cate_id;
    $res = $mu->getOne($sql);
    echo $res;
    return;
} else {
    if ($type == 'delete') {
        // 把要删除的栏目中所有的子栏目找出 把要删除的id全部放在allid中
        $sql = "select * from bl_cate";
        $res = $mu->getAll($sql);
        $childrenid = ToolsInfClassify::ChildrenId($res, $cate_id);
        $allid = array_merge(array($cate_id), $childrenid);
        $arr = array('is_delete' => 1);
        $where = 'cate_id in(' . implode(',', $allid) . ')';
        $res = $mu->update($arr, $where);
        if ($res != count($allid)) {
            // 删除失败
            echo '1';
            return;
        } else {
            // 删除成功
            echo '0';
            return;
        }
    }
}
Example #7
0
 public function update(\stdClass $user)
 {
     $model = new ModelUser($this->dbh);
     if ($updated_user = $model->update($user)) {
         return $updated_user;
     } else {
         return $updated_user;
     }
 }
Example #8
0
// 未激活
if ($res['is_active'] == 0) {
    echo "2";
    return;
}
// 记住密码  记住一个星期
if ($rem == 'yes') {
    setcookie('name', $username, time() + 3600 * 24 * 7);
} else {
    setcookie('name', '', time() - 1);
}
// 登录成功 更新用户信息
$ip = get_client_ip();
$time = time();
$_SESSION['name'] = $res['username'];
$res = $mu->update(array('logintime' => $time, 'loginip' => $ip), "id=" . $res['id']);
// 添加该用户的购物车内容
if (is_file(ROOT . 'data/shoppingCart/' . $_SESSION['name'])) {
    $_SESSION['cart_temp'] = array();
    // 判断此时(未登录)购物里是否有内容
    if (!$cart->isEmpty()) {
        // 不为空
        $_SESSION['cart_temp'] = $cart->getItems();
    }
    // 清空购物车
    $cart->clear();
    // 添加该用户的购物车内容  执行完这一句之后 $cart仍然为空 重新申请实例时$cart才不为空
    $_SESSION['cart'] = unserialize(file_get_contents(ROOT . 'data/shoppingCart/' . $_SESSION['name']));
    $cart = ToolsShoppingCart::GetCart();
    // 同步$cart 和 $_SESSION_['cart'] 即$cart = $_SESSION['cart']
    // 将原来购物车中的内容添加到新购物车中
Example #9
0
<?php

/**
file: admin/index.php
功能: MVC中的控制器 负责显示view/admin/index.html
**/
require_once './common/include.php';
// 更新用户状态
$ip = get_client_ip();
$time = time();
$mu = new ModelUser('bl_user');
$res = $mu->update(array('logintime' => $time, 'loginip' => $ip), "username='******'name'] . "'");
//echo $res;
include ROOT . 'view/admin/templates/index.html';