/[Development]/mod_auth_ibmdb2/scripts/user_etc_imp
ViewVC logotype

Contents of /mod_auth_ibmdb2/scripts/user_etc_imp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations)
Sun Oct 22 12:28:07 2006 UTC (3 years, 10 months ago) by tessus
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +1 -2 lines
removed unnecessary env variable
1 #!/usr/local/bin/php
2 <?php
3
4 // $Id: user_etc_imp,v 1.3 2006/10/22 12:28:07 tessus Exp $
5
6 putenv ("DB2INSTANCE=db2inst1");
7 putenv ("LD_LIBRARY_PATH=:/home/db2inst1/sqllib/lib");
8 putenv ("LIBPATH=:/home/db2inst1/sqllib/lib");
9
10 require ('./config.php');
11
12 $handle = fopen ("/etc/shadow", "r");
13
14 while (!feof ($handle))
15 {
16 $line = fgets($handle, 512);
17
18 list($username,$password) = explode(":",$line);
19
20 if( $username != '' && $username != 'root' && $password != '*' && $password != '!!')
21 {
22 $arr["$username"] = $password;
23 }
24 }
25
26 fclose ($handle);
27
28 $conn = db2_connect( $dbname, $dbuser, $dbpwd );
29
30 echo "\nImporting users into table '$usertable' in database '$dbname'\n\n";
31
32 $i = 0;
33 $ni = 0;
34
35 foreach ($arr as $u => $p)
36 {
37 $insert = "insert into $usertable ($namefield, $passwordfield) values ('$u', '$p')";
38 $res=@db2_exec( $conn, $insert );
39
40 if( $res != FALSE )
41 {
42 echo "User $u imported.\n";
43 $i++;
44 }
45 else
46 {
47 echo "User $u NOT imported.\n";
48 $ni++;
49 }
50 }
51
52 echo "\n";
53 echo "Users imported: $i\n";
54 echo "Users rejected: $ni\n";
55 echo "\n";
56
57 return 0;
58
59 ?>

CVS admin
ViewVC Help
Powered by ViewVC 1.1.5