source: contrib/scriptDeleteUsers/upload_file.php @ 3007

Revision 3007, 1.6 KB checked in by amuller, 14 years ago (diff)

Ticket #1134 - Script ja pronto para deletar usuarios via linha de comando ( Fillipe Motta - ATI )

Line 
1<?php
2
3if(!isset($GLOBALS['phpgw_info'])){
4        $GLOBALS['phpgw_info']['flags'] = array(
5                'currentapp' => 'expressoAdmin1_2',
6                'nonavbar'   => true,
7                'noheader'   => true
8        );
9}
10
11
12include_once('../header.inc.php');
13include_once("inc/class.user.inc.php");
14require_once('../header.session.inc.php');
15
16
17
18
19if ($_FILES["file"]["error"] > 0)
20        {
21                echo "Error: " . $_FILES["file"]["error"] . "<br />";   
22        }
23        else
24        {
25                $fileName = $_FILES["file"]["name"];
26                $tmpFile = $_FILES["file"]["tmp_name"];
27           
28
29            if (file_exists($fileName)){
30                echo $fileName . " ja existe !! ";
31            }
32            else
33            {
34
35                if(move_uploaded_file($tmpFile,"/tmp/$fileName")){
36                   
37                   $file = fopen("/tmp/$fileName", "r");
38                   if (!$file){
39                      echo "O arquivo nao pode ser aberto";
40                      exit();
41                   }
42                   else
43                   {
44                        $params = Array();
45                        $user = new user;
46                   
47                        while(!feof($file)) {
48
49                          if (!feof($file)) {
50
51                            $linha = trim(fgets($file));
52                            $result = explode(",",$linha);
53                            $params['uid'] = $result[0];
54                            $params['uidnumber'] = $result[1];
55                           
56                            $info_user =  $user->get_user_info($params['uidnumber']);
57                //          $passwdExpired = $info_user['passwd_expired'];
58                       
59                            if ($info_user)  {                 
60       
61                                        echo "Deletando usuario:   " . $params['uid'] . " " . " ; " . $info_user['context'] . "<br>";
62                                        $user->delete($params);
63                            }
64                            else
65                                {
66                                        echo "Usuario NAO EXISTE :   " . $params['uid']  . " " . " ; " . $info_user['context'] . "<br>";
67                                }
68     
69                        }
70                     }
71                   }   
72                }
73            }
74        }
75       
76?>
Note: See TracBrowser for help on using the repository browser.