Пример #1
0
/***
file login.php
***/
session_start();
define('AICN', true);
require '../include/init.php';
if (isset($_POST['act']) && $_POST['act'] == 'act_logi') {
    if (!isset($_POST['username']) or $_POST['passwd'] == '') {
        echo "请输入帐号密码3秒后重新登陆";
        echo "<meta http-equiv='refresh' content='3,url=login.php'/>";
        //echo'请输入帐号密码';
        //header('Location: login.php');
        exit;
    }
    $user = new usermodel();
    $_POST['username'] = $user->compress_html($_POST['username']);
    $_POST['passwd'] = $user->compress_html($_POST['passwd']);
    $u = $_POST['username'];
    $p = $_POST['passwd'];
    $row = $user->checkmadin($u, $p);
    if (!isset($_SESSION['username']) or $_SESSION['username'] == '') {
        echo "3秒后重新登陆";
        echo "<meta http-equiv='refresh' content='3,url=login.php'/>";
        exit;
    }
    header('Location: index.php');
    exit;
}
?>
<!doctype html>
Пример #2
0
<?php

/***
file .php
if($user->reg($data)) { 
   $msg = '用户注册成功';
   echo $msg; 
} else { 
   $msg = '用户注册失败'; 
   echo $msg;
} 
    <?php sleep(2);header('Location: register.php');?>
***/
define('AICN', true);
require './include/init.php';
$user = new usermodel();
$_POST['username'] = $user->compress_html($_POST['username']);
$_POST['qq'] = $user->compress_html($_POST['qq']);
$_POST['phonenumber'] = $user->compress_html($_POST['phonenumber']);
$_POST['email'] = $user->compress_emil($_POST['email']);
$_POST['passwd'] = $user->compress_html($_POST['passwd']);
if (!$user->_validate($_POST)) {
    // 自动检验
    $msg = implode('<br />', $user->getErr());
    //   echo $msg;
    include ROOT . 'view/front/msg.html';
    exit;
}
// 检验用户名是否已存在
if ($user->checkuser($_POST['username'])) {
    $msg = '用户名已存在';
Пример #3
0
 public function userdelete()
 {
     if (isset($_POST['userid'])) {
         $userid = intval($_POST['userid']);
     }
     $usermodel = new usermodel('admin_user');
     if ($usermodel->delete(array('where' => "userid={$userid}"))) {
         $returndata = array("successMsg" => '用户删除成功');
     } else {
         $returndata = array("errorMsg" => '用户删除失败');
     }
     $this->ajaxReturn($returndata);
 }
Пример #4
0
 public function updateProjet()
 {
     $this->allowTo(['user', 'Admin']);
     $login = new AuthentificationModel();
     $projetsModel = new usermodel();
     $infosUser = $this->getUser();
     $mimeTypeAllowed = array('image/jpg', 'image/jpeg', 'image/png', 'image/gif');
     $errors = [];
     $validForm = false;
     //fichier image projet
     if (isset($_FILES['photo']) && $_FILES['photo']['size'] != 0) {
         $maxSize = 3 * 100 * 1024;
         //3Mo
         $finfo = new \finfo();
         // On vérifie la taille du fichier
         if ($_FILES['photo']['size'] > $maxSize) {
             $errors[] = 'Ficher trop volumineux';
         }
         if (count($errors) == 0) {
             // chemin matériel du dossier pr upload fichier
             $uploads_dir_projet = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['REDIRECT_W_BASE'] . '/assets/projet';
             $tmp_name = $_FILES['photo']['tmp_name'];
             $nameProjet = $infosUser['id'] . $_FILES['photo']['name'];
             //Pour que le nom soit unique et eviter les probleme de nom de fichier on l'incrémente de l'id appartenant à projets
             //chose à faire supprimer ou remplacer le ficher
             // On upload le fichier
             //$uploadProjet = move_uploaded_file(filename, destination)
             $uploadProjet = move_uploaded_file($tmp_name, $uploads_dir_projet . '/' . $nameProjet);
             //chemin virtuel du dossier pour insertion BD
             $data = ["photo" => 'projet/' . $nameProjet];
             $params['picUrl'] = $_SERVER['REDIRECT_W_BASE'] . '/assets/' . $data['photo'];
             //on met à jour la bdd
             $projetsModel->update($data, $infosUser['id']);
             $login->refreshUser();
             $validForm = true;
         }
     }
     $params['errors'] = implode(', ', $errors);
     $params['valide'] = $validForm;
     $this->showJson($params);
 }