Example #1
0
             $msg_class = 'failed';
         }
     } else {
         $msg = 'Не достаточно прав доступа';
         $msg_class = 'failed';
     }
 } elseif ($stage == 'save_photo' and $uid != '') {
     $uploadphoto = uploadphoto($uid);
     // Загрузка фото на сервер
     $photoname = $uploadphoto['file'];
     // Имя файла с фотографией
     $msg = $uploadphoto['msg'];
     $msg_class = $uploadphoto['msg_class'];
     if ($photoname != '') {
         $query_edit_photo = "UPDATE users SET date_mod=NOW(),photo='" . $photoname . "',admin_mod_id=(SELECT id from admins WHERE login='******') WHERE id=" . $uid;
         if (!write_data_to_db($query_edit_photo, 'update')) {
             $msg = 'Ошибка записи в БД!';
             $msg_class = 'failed';
         }
     }
 }
 $page_name = 'Редактирование сотрудника';
 $query_edit_user = array("0" => "SELECT fio1,fio2,fio3,DATE_FORMAT(birthday,\"%d.%m.%Y\") as birthday,photo,post_id,area_id,gild_id,comment FROM users WHERE id=" . $uid);
 foreach (get_data_from_db($query_edit_user) as $data_edit_user) {
     $fio1 = $data_edit_user[0]['fio1'];
     $fio2 = $data_edit_user[0]['fio2'];
     $fio3 = $data_edit_user[0]['fio3'];
     $date = $data_edit_user[0]['birthday'];
     $photoname = $data_edit_user[0]['photo'];
     $post_id = $data_edit_user[0]['post_id'];
     $area_id = $data_edit_user[0]['area_id'];
Example #2
0
     if ($form_admin_pass != '') {
         $query_cabinet_edit = "UPDATE admins SET login='******',fio='" . $form_admin_fio . "',pass='******',email='" . $form_admin_email . "',permission=" . $form_permission_id . " WHERE id=" . $admin_id;
     } else {
         // Иначе пароль не указан, пароль не менять
         $query_cabinet_edit = "UPDATE admins SET login='******',fio='" . $form_admin_fio . "',email='" . $form_admin_email . "',permission=" . $form_permission_id . " WHERE id=" . $admin_id;
     }
 } else {
     // Пользователь не админ
     if ($form_admin_pass != '') {
         $query_cabinet_edit = "UPDATE admins SET login='******',fio='" . $form_admin_fio . "',pass='******',email='" . $form_admin_email . "' WHERE id=" . $admin_id;
     } else {
         // Иначе пароль не указан, пароль не менять
         $query_cabinet_edit = "UPDATE admins SET login='******',fio='" . $form_admin_fio . "',email='" . $form_admin_email . "' WHERE id=" . $admin_id;
     }
 }
 if (write_data_to_db($query_cabinet_edit, 'update')) {
     $msg = 'Данные сохранены';
     $msg_class = 'success';
     // Перечитать настройки пользователя
     $admin_login = get_data_from_db(array("0" => "SELECT id,login,fio,email,permission FROM admins WHERE id=" . $admin_id));
     if ($admin_login[0] != '' and count($admin_login[0]) == 1) {
         $admin = $_SESSION['admin'] = $admin_login[0][0]['login'];
         $admin_fio = $_SESSION['admin_fio'] = $admin_login[0][0]['fio'];
         $admin_email = $_SESSION['admin_email'] = $admin_login[0][0]['email'];
         $form_permission_id = $_SESSION['permission'] = $admin_login[0][0]['permission'];
     } else {
         $msg = 'Ошибка!';
         $msg_class = 'failed';
     }
 } else {
     $msg = 'Ошибка в ведённых данных';