Exemplo n.º 1
0
    public function findByWithUser($names, $ids)
    {
        if (!is_array($ids)) {
            $ids = array($ids);
        }
        if (!is_array($names)) {
            $names = array($names);
        }
        $c = static::getModelName();
        $sth = ServiceDb::getInstance()->prepare('
				select `' . static::getTableName() . '`.*, `user`.*
				from `' . static::getTableName() . '`
				left join `user` on `user`.`id`=`' . static::getTableName() . '`.`user_id`
				where `' . implode('`=? and `', $names) . '`=?');
        $sth->execute($ids);
        $arr = array();
        foreach ($sth->fetchAll() as $data) {
            if ($data['id'] == ServiceAuth::getInstance()->getUser()->getId()) {
                continue;
            }
            $a = new ModelUser();
            $a->hydrate($data);
            $b = new $c();
            $b->hydrate($data);
            $a->setProfile($b);
            $arr[] = $a;
        }
        return $arr;
    }
Exemplo n.º 2
0
 /**
  * Restituisce il messaggio email renderizzato sul template per la notifica del cambiamento password
  * @param string $password
  * @param ModelUser $user
  * @return PCEmail
  */
 public static function buildEmailForPasswordNotification($password, $user){
     $result = array("title" => "WebSherpa password request",
                     "username" => $user->getUsername(),
                     "pass" => $password);
     $renderer = new PCRendererEmail($result, "passNotif");
     $body = $renderer->render();
     
     return new PCEmail("Websherpa password Reset Completed", "*****@*****.**", $user->getEmail(), $body,"WebSherpa", TRUE);
 }
Exemplo n.º 3
0
 public static function GetGoodsSn()
 {
     $_mu = new ModelUser('bl_goods');
     $sn = substr(str_shuffle('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 10);
     //        $sn = mt_rand(0,17);
     $res = $_mu->select(array('goods_sn'), 'goods_sn="' . $sn . '"');
     if ($res) {
         return self::GetGoodsSn();
     } else {
         return $sn;
     }
 }
Exemplo n.º 4
0
    public function findAllWithReputation()
    {
        $sth = ServiceDb::getInstance()->prepare('
				select `user`.*, (`inBounds`/(`inBounds`+`outBounds`)) `reputation`
				from `user`
				order by `reputation` desc, `inBounds` desc');
        $sth->execute();
        $arr = array();
        foreach ($sth->fetchAll() as $data) {
            $a = new ModelUser();
            $a->hydrate($data);
            $arr[] = $a;
        }
        return $arr;
    }
Exemplo n.º 5
0
 /**
  * Get current user object
  * @return User
  */
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemplo n.º 6
0
 public function execute($args = null)
 {
     if (!empty($_POST)) {
         $_POST['id'] = null;
         $_POST['hash'] = ServiceAuth::createHash($_POST['pass1']);
         $_POST['inBounds'] = 0;
         $_POST['outBounds'] = 0;
         $u = ModelUser::newInstance()->hydrate($_POST);
         $p = ModelProfile::newInstance();
         if ($_POST['pass1'] != $_POST['pass2']) {
             ServiceMessage::getInstance()->addMessage('Les mots de passes ne correspondent pas', 'error');
         } elseif (CollectionUser::newInstance()->findBy('login', $_POST['login'])) {
             ServiceMessage::getInstance()->addMessage('Ce login est déjà utilisé', 'error');
         } else {
             if (ServiceDb::getInstance()->persist($u)) {
                 if ($i = ServiceDb::getInstance()->lastInsertId()) {
                     if (ServiceDb::getInstance()->persist($p->hydrate(array('user_id' => $i)))) {
                         ServiceMessage::getInstance()->addMessage('Votre compte a bien été créé', 'success');
                         ServiceDb::getInstance()->persist(ModelAction::newInstance()->setUser_id($i)->setType('create')->setObject('profile')->setWhen());
                         return header('Location: /logout/quiet');
                     } else {
                         ServiceDb::getInstance()->delete($u);
                         ServiceMessage::getInstance()->addMessage('Une erreur est survenue #2', 'error');
                     }
                 } else {
                     ServiceMessage::getInstance()->addMessage('Une erreur est survenue #1', 'error');
                 }
             }
         }
     }
     ServiceRenderHtml::newInstance()->load('subscribe')->setData('hideNavigation', true)->render();
 }
Exemplo n.º 7
0
 public static function app()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemplo n.º 8
0
 function _init()
 {
     // FIELD DEFINITION
     self::$fields = array('id' => ORM::field('auto[11]'), 'first_name' => ORM::field('char[255]', array('required')), 'last_name' => ORM::field('char[255]', array('required')), 'username' => ORM::field('email', array('required', 'is_unique[users.username]')), 'password' => ORM::field('string', array('required')), 'role' => ORM::field('char[255]'), 'status' => ORM::field('char[255]'), 'created_at' => ORM::field('datetime'), 'updated_at' => ORM::field('datetime'));
     //
     // SETUP DATETIME ASSOCIATION
     $this->ts_fields = array('updated_at', '[created_at]');
 }
Exemplo n.º 9
0
 public static function getPic()
 {
     $image = ModelUser::model()->findbyPk(Yii::app()->user->id_user)->pic_file;
     $urlimagen = Params::Web()->urlImagesUser . Yii::app()->user->id_user . '/' . $image;
     if (Files::verificarUrlImagen($urlimagen)) {
         return $urlimagen;
     } else {
         return Params::Web()->ImageDefault;
     }
 }
Exemplo n.º 10
0
    public function countDesc()
    {
        $sth = ServiceDb::getInstance()->prepare('
				select `action`.*
				,`user`.*
				,count(*) as `nb`
				from `action`
				left join `user`
				on `user`.`id`=`action`.`user_id`
				group by `action`.`user_id`
				order by `nb` desc');
        $sth->execute();
        $arr = array();
        foreach ($sth->fetchAll() as $data) {
            $a = new ModelUser();
            $a->hydrate($data);
            $b = new ModelAction();
            $b->hydrate($data);
            $b->setUser($a);
            $arr[] = array($b, $data['nb']);
        }
        return $arr;
    }
Exemplo n.º 11
0
 public function actionRegUsu()
 {
     $this->layout = '//layouts/main';
     if (Yii::app()->request->getPost('FormReg') != null) {
         $FormReg = Yii::app()->request->getPost('FormReg');
         $modelUser = new ModelUser();
         $criteria = new CDbCriteria();
         $modelUser->attributes = $FormReg;
         $criteria->addCondition('dni_user = :dni');
         $params['dni'] = $modelUser->dni_user;
         $criteria->params = $params;
         $total = ModelUser::model()->count($criteria);
         if ($total > 0) {
             $this->render('registro', array('msg' => 'DNI ya registrado'));
         } else {
             $modelUser->id_user = ModelKey::getKeyid($modelUser->nombre_user, $modelUser->dni_user);
             $apellido = strtolower(str_replace(' ', '', Utils::verifyUTF($modelUser->apellido_padre_user)));
             $nombre = strtolower(substr(Utils::verifyUTF($modelUser->nombre_user), 0, 1));
             $login = $nombre . $apellido;
             $modelLogin = new ModelLogin();
             $modelLogin->clave_login = ModelKey::getPassworrd($modelUser->dni_user);
             $modelLogin->id_login = $modelUser->id_user;
             $modelLogin->name_login = $login;
             $transaction = Yii::app()->db->beginTransaction();
             try {
                 if (!$modelUser->save()) {
                     throw new Exception("No se puede guardar el usuario");
                 } else {
                     if (!$modelLogin->save()) {
                         throw new Exception("No se puede guardar el login");
                     } else {
                         if ($FormReg['key_proyecto'] != 1) {
                             $modelProyecto = new ModelProyectos();
                             Utils::show($modelProyecto, true);
                         }
                     }
                 }
                 $transaction->commit();
                 $this->redirect(Yii::app()->controller->createUrl("{$this->id}/login"));
             } catch (Exception $exc) {
                 $transaction->rollBack();
                 $msg = $exc->getMessage();
                 $this->render('registro', array('msg' => $msg));
             }
         }
     } else {
         $this->render('registro');
     }
 }
Exemplo n.º 12
0
    public function findAllCoworkers()
    {
        $k = '';
        foreach (array_keys(ModelUser::newInstance()->getPersistentData()) as $v) {
            $k .= "`user1`.`{$v}` `a__{$v}`, `user2`.`{$v}` `b__{$v}`,";
        }
        $sth = ServiceDb::getInstance()->prepare('
				select `user_has_user`.*,
				' . $k . '
				`user1`.`id` `a__id`,
				`user2`.`id` `b__id`
				from `user_has_user`
				left join `user` `user1` on `user1`.`id`=`user_has_user`.`user_id1`
				left join `user` `user2` on `user2`.`id`=`user_has_user`.`user_id2`
				where (`user_has_user`.`type` & ' . ModelUser_has_user::WORK . ' )
				and exists (
					select 1
					from `user_has_user` `foo`
					where `user_has_user`.`user_id2`=`foo`.`user_id1`
					and (`foo`.`type` & ' . ModelUser_has_user::WORK . ' )
				)');
        $sth->execute();
        $pairs = array();
        $arr = array();
        foreach ($sth->fetchAll() as $data) {
            $datax = array();
            // FIXME : find another way to avoir doublons
            if (in_array($data['a__id'] . '.' . $data['b__id'], $pairs) || in_array($data['b__id'] . '.' . $data['a__id'], $pairs)) {
                continue;
            }
            $pairs[] = $data['a__id'] . '.' . $data['b__id'];
            $a = ModelUser_has_user::newInstance()->hydrate($data);
            foreach ($data as $k => $v) {
                if (strpos($k, 'a__') === 0) {
                    $datax[str_replace('a__', '', $k)] = $v;
                }
            }
            $a->setUser1(ModelUser::newInstance()->hydrate($datax));
            foreach ($data as $k => $v) {
                if (strpos($k, 'b__') === 0) {
                    $datax[str_replace('b__', '', $k)] = $v;
                }
            }
            $a->setUser2(ModelUser::newInstance()->hydrate($datax));
            $arr[] = $a;
        }
        return $arr;
    }
Exemplo n.º 13
0
<?php

/**
 * Created by PhpStorm.
 * User: hssh_win8.1
 * Date: 2015/10/5
 * Time: 14:15
 * file: catetrashhandle 栏目回收站的处理 有还原和彻底删除
 */
require_once './common/include.php';
$cate_id = $_POST['cate_id'] + 0;
$parent_id = $_POST['parent_id'] + 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';
Exemplo n.º 14
0
 /**
  * Guarda la foto subida
  */
 public static function actionchangePic()
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $model = ModelUser::model()->findbyPk(Yii::app()->user->id_user);
         $file = CUploadedFile::getInstance($model, 'pic_file');
         if (trim($file) != "") {
             $urlcarpetaFile = Params::Server()->urlImagesUser . Yii::app()->user->id_user . '/';
             $extensionfile = Files::getNombreExtensionFile($file->name);
             $nombrefile = rand(1, 100) . '_' . strtotime("now");
             $urlimagen = $urlcarpetaFile . "/" . $nombrefile . "." . $extensionfile['extension'];
             $model->pic_file = $nombrefile . '.' . $extensionfile['extension'];
             if (!$model->update()) {
                 $er = "<pre>" . json_encode($model->getErrors()) . "</pre>";
                 throw new Exception("No se pudo guardar la información por : {$er}");
             }
             $file->saveAs($urlimagen);
         }
         $transaction->commit();
         Yii::app()->request->redirect(Yii::app()->baseUrl . '/user/account');
     } catch (Exception $ex) {
         $transaction->rollBack();
         $c = new Controller('site');
         $c->render('application.views.site.error', $ex);
     }
 }
Exemplo n.º 15
0
<?php

/**
 * Created by PhpStorm.
 * User: hssh_win8.1
 * Date: 2015/10/4
 * Time: 20:40
 * file: cateadd.php  栏目添加
 */
require_once './common/include.php';
$mu = new ModelUser('bl_cate');
$sql = 'select * from bl_cate where 1 order by cate_id ';
$res = $mu->getAll($sql);
// 无限极分类 返回 一维数组
$catelist = ToolsInfClassify::ClassifyForOne($res);
require ROOT . 'view/admin/templates/cateadd.html';
Exemplo n.º 16
0
<?php

require_once 'head.php';
require_once 'conexao.php';
require_once 'ModelUser.php';
$usuario = new ModelUser($conexao);
if (isset($_GET['nomeUser'])) {
    $nomeatual = $usuario->busca($_GET['nomeUser']);
    if ($nomeatual != NULL) {
        echo "<table class='table'>\n        <th>NOME</th>\n        <th>NOVO NOME</th>\n        <th>SENHA</th>";
        echo '<h2>Dados do Usuario: ' . $nomeatual['nome'] . '</h2>';
        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>';
Exemplo n.º 17
0
/**
 * Created by PhpStorm.
 * User: hssh_win8.1
 * Date: 2015/10/5
 * Time: 17:55
 * file: cateedithandle.php  编辑栏目信息的处理函数
 */
require_once './common/include.php';
//print_r($_POST);
$cate_id = $_POST['cate_id'] + 0;
$cate_name = $_POST['cate_name'];
$cate_desc = $_POST['cate_desc'];
$newparent_id = $_POST['parent_id'] + 0;
// 实例化数据库
$mu = new ModelUser('bl_cate');
// 判断新的父栏目是否在子栏目中 如果是的话 就返回错误
$field = array('cate_id', 'parent_id');
$res = $mu->select($field, 'is_delete=0 order by cate_id');
$allChildId = ToolsInfClassify::ChildrenId($res, $cate_id);
// 父栏目选取错误
if (in_array($newparent_id, $allChildId) || $newparent_id == $cate_id) {
    echo '2';
    return;
}
// 改变父栏目
$arr = array('parent_id' => $newparent_id, 'cate_name' => $cate_name, 'cate_desc' => $cate_desc);
$res = $mu->update($arr, 'cate_id=' . $cate_id);
//echo $res;
if ($res != 1) {
    // 编辑失败
Exemplo n.º 18
0
<?php

/**
 * Created by PhpStorm.
 * User: hssh_win8.1
 * Date: 2015/10/4
 * Time: 20:41
 * file: cateedit.php  栏目管理
 */
require_once './common/include.php';
$cate_id = $_GET['cate_id'] + 0;
// 实例化数据库对象
$mu = new ModelUser('bl_cate');
// 获取全部栏目
$field = array('cate_id', 'cate_name', 'parent_id', 'cate_desc');
$res = $mu->select($field, 'is_delete=0 order by cate_id');
$catelist = ToolsInfClassify::ClassifyForOne($res);
//print_r($catelist);
// 获取当前栏目的信息
$sql = "select c1.*,c2.cate_name as parent_name from bl_cate as c1 left join bl_cate as c2 on c1.parent_id=c2.cate_id where c1.cate_id=" . $cate_id;
$cateinfo = $mu->getRow($sql);
//print_r($cateinfo);
require ROOT . 'view/admin/templates/cateedit.html';
Exemplo n.º 19
0
 public function isAllowedToSee(ModelUser $user, $parameter)
 {
     if ($parameter instanceof ModelParameter) {
         $parameter = $parameter->getName();
     }
     $profile = $user->getProfile();
     if ($profile->getParameter($parameter)->getVisibility() == 'public') {
         return true;
     } elseif ($profile->getParameter($parameter)->getVisibility() == 'amis') {
         return $user->getUser_has_user($this)->checkType(ModelUser_has_user::FRIE);
     } else {
         return false;
     }
 }
Exemplo n.º 20
0
<?php

/**
 * Created by PhpStorm.
 * User: hssh_win8.1
 * Date: 2015/10/6
 * Time: 21:26
 * file: goodsinfo.php 查看商品
 */
require_once './common/include.php';
//实例化数据库
$mu = new ModelUser('bl_goods');
// 获得商品good_id
if (!isset($_GET['goods_id']) || intval($_GET['goods_id']) < 1) {
    exit('商品不存在');
}
$goods_id = intval($_GET['goods_id']);
//获得商品信息
$sql = "select g.*,c.cate_name from bl_goods as g left join bl_cate as c on g.cate_id=c.cate_id where g.goods_id=" . $goods_id;
$gi = $mu->getRow($sql);
//print_r($gi);
// 修改时间样式
$gi['goods_time'] = date('Y-m-d H:i:s', $gi['goods_time']);
// 更改图片路径
$basename = basename(dirname(dirname(__FILE__)));
$gi['goods_img'] = '/' . strstr($gi['goods_img'], $basename);
//echo $gi['goods_time'];
require ROOT . 'view/admin/templates/goodsinfo.html';
Exemplo n.º 21
0
<?php

/**
 * Created by PhpStorm.
 * User: hssh_win8.1
 * Date: 2015/10/6
 * Time: 12:05
 * file: goodsaddhandles.php
 */
require_once './common/include.php';
// 获取数据库实例
$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($tempimg) || !rename($tempimg, $img)) {
    echo "1";
    return;
}
//并生成400*400中图 和1000*1000的大图
ToolsImage::ResizeImage($img, 400, 400, 'mid');
ToolsImage::ResizeImage($img, 1000, 1000, 'big');
$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->insert($data);
//echo $res;
if ($res != 1) {
Exemplo n.º 22
0
 function _init()
 {
     // Define relationships
     self::$relationships = array('wife' => ORM::has_one('\\Model\\Wife', array('select:id,name')), 'kid' => ORM::has_many('\\Model\\Kid', array('select:id,name')), 'job' => ORM::has_many('\\Model\\Job\\User => \\Model\\Job', array('select:id,name')), 'role' => ORM::has_many('\\Model\\Role\\User => \\Model\\Role', array('select:id,name')));
     // Define fields definition
     self::$fields = array('id' => ORM::field('auto[3]'), 'name' => ORM::field('char[40]'), 'email' => ORM::field('email[40]'), 'username' => ORM::field('char[10]', array('required', 'callback_username_check')));
 }
Exemplo n.º 23
0
 static function start()
 {
     // default action and controller
     $controller_name = 'index';
     $action_name = 'index';
     $permissionActionName = ucfirst($action_name);
     $loggedUser = Route::isUserLogged();
     $routes = explode('/', $_SERVER['REQUEST_URI']);
     //echo "Route[0]: $routes[0] </br>";
     //echo "Route[1]: $routes[1] </br>";
     //echo "Route[2]: $routes[2] </br>";
     //echo $routes[2];
     // controller name
     if (!empty($routes[1])) {
         $controller_name = $routes[1];
         $defaultModelName = $routes[1];
     }
     // action name
     if (!empty($routes[2])) {
         $action_name = $routes[2];
         $permissionActionName = ucfirst($action_name);
     }
     // add prefix
     $model_name = 'model' . ucfirst($controller_name);
     $controller_name = 'controller' . ucfirst($controller_name);
     $action_name = 'action' . ucfirst($action_name);
     //        echo "Model: $model_name </br>";
     //        echo "Controller: $controller_name </br>";
     //        echo "Action: $action_name </br>";
     // catch model file
     $model_file = $model_name . '.php';
     $model_path = "../models/" . $model_file;
     //echo $loggedUser;
     if (file_exists($model_path)) {
         //include "../models/".$model_file;
         if ($loggedUser == true) {
             //$model = new $defaultModelName;
             $user = new ModelUser();
             $userRole = $user->getUserByLogin($_SESSION['userID']);
             //echo $model->getResourceModel();
             echo "create model";
         } else {
             //echo "can't create model";
         }
     } else {
         //echo "Can't find model</br>";
     }
     // catch controller file
     $controller_file = $controller_name . '.php';
     $controller_path = "../controllers/" . $controller_file;
     if (file_exists($controller_path)) {
         include "../controllers/" . $controller_file;
     } else {
         echo "Can't find controller</br>";
         Route::ErrorPage404();
     }
     // create controller
     $controller = new $controller_name();
     $action = $action_name;
     //echo $controller_name;
     if (method_exists($controller, $action)) {
         if ($loggedUser == false) {
             $role = 1;
             //anon
         } else {
             $role = $userRole[0];
         }
         //echo $permissionActionName;
         echo $role;
         if ($controller->allowedAction($permissionActionName, $role) || $controller_name == "controllerError") {
             $controller->{$action}();
         } else {
             //echo "Forbidden";
             Route::ErrorPage403();
         }
     } else {
         //echo "Can't find actions";
         Route::ErrorPage404();
     }
 }
Exemplo n.º 24
0
 function _init()
 {
     self::$relationships = array('blog' => ORM::has_many('\\Model\\Blog'), 'passphrase' => ORM::has_one('\\Model\\User_passphrase'));
     self::$fields = array('id' => ORM::field('auto[10]'), 'email' => ORM::field('char[64]'), 'modified' => ORM::field('datetime'), 'created' => ORM::field('datetime'));
     $this->ts_fields = array('modified', '[created]');
 }
Exemplo n.º 25
0
<?php

/**
 * Created by PhpStorm.
 * User: hssh_win8.1
 * Date: 2015/10/6
 * Time: 20:19
 * files: goodstrash.php
 */
require_once './common/include.php';
// 实例化数据库 注意 不是用bl_goods 是用 bl_cate
$mu = new ModelUser('bl_cate');
if (!isset($_GET['cate_id']) || intval($_GET['cate_id']) < 1) {
    $cate_id = 1;
} else {
    $cate_id = $_GET['cate_id'] + 0;
}
// 获取所有栏目
$res = $mu->select(array('cate_id', 'cate_name', 'parent_id'), "1 order by cate_id");
$catelist = ToolsInfClassify::ClassifyForOne($res);
//print_r($catelist);
// 获取该栏目下所有的子栏目
$allCateId = ToolsInfClassify::ChildrenId($res, $cate_id);
array_unshift($allCateId, $cate_id);
//print_r($allCateId);
// 获得cate_id栏目下的所有商品
$sql = "select g.* from bl_goods as g left join bl_cate as c on g.cate_id=c.cate_id where c.cate_id in (" . implode(',', $allCateId) . ') && g.is_delete=1';
$goodslist = $mu->getAll($sql);
require ROOT . 'view/admin/templates/goodstrash.html';
Exemplo n.º 26
0
 public function deletePicture($idPicture)
 {
     $model = new ModelUser();
     $model->deletePicture($idPicture);
     header('Location: index.php');
 }
Exemplo n.º 27
0
<?php

require_once 'head.php';
require_once 'conexao.php';
require_once 'ModelUser.php';
$usuario = new ModelUser($conexao);
if (isset($_GET['excluido'])) {
    $usuario->setNome($_GET['excluido']);
    $usuario->delete();
    echo '<h2>Os dados do aluno ' . $_GET['excluido'] . ' foram excluidos!</h2>';
}
Exemplo n.º 28
0
/**
 * Created by PhpStorm.
 * User: hssh_win8.1
 * Date: 2015/10/6
 * Time: 22:29
 * file: goodsedit.php 商品编辑页
 */
require_once './common/include.php';
//实例化数据库
$mu = new ModelUser('bl_goods');
// 获得商品good_id
if (!isset($_GET['goods_id']) || intval($_GET['goods_id']) < 1) {
    exit('商品不存在');
}
$goods_id = intval($_GET['goods_id']);
//获得商品信息
$sql = "select g.*,c.cate_name from bl_goods as g left join bl_cate as c on g.cate_id=c.cate_id where g.goods_id=" . $goods_id;
$gi = $mu->getRow($sql);
//print_r($gi);
if (empty($gi)) {
    exit('商品不存在');
}
// 更改图片的
$gi['goods_img'] = basename($gi['goods_img']);
// 实例栏目数据库
$mu = new ModelUser('bl_cate');
// 获取所有栏目
$res = $mu->select(array('cate_id', 'cate_name', 'parent_id'), "is_delete=0 order by cate_id");
$catelist = ToolsInfClassify::ClassifyForOne($res);
//print_r($catelist);
require ROOT . 'view/admin/templates/goodsedit.html';
Exemplo n.º 29
0
<?php

/**
 * Created by PhpStorm.
 * User: hssh_win8.1
 * Date: 2015/10/7
 * Time: 16:10
 * file: front/registerhandle.php  检查用户名是否重复
 */
require_once './common/include.php';
require_once ROOT . 'tools/email/mySendEmail.class.php';
// 获得数据库实例
$mu = new ModelUser('bl_user');
// 判断操作的类型 chkuname为检查用户名是否重复
$type = $_POST['type'];
//print_r($_POST);
// 检查用户名是否重复
if ($type == 'chkuname') {
    // 获得待检查的用户名
    if (empty($_POST['username'])) {
        echo "1";
        return;
    } else {
        $username = $_POST['username'];
    }
    $sql = "select count(*) from bl_user where username='******'";
    $res = $mu->getOne($sql);
    if ($res != 0) {
        // 重复
        echo "1";
        return;
Exemplo n.º 30
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;
}