2 ////////////////////////////////////////////////////////////////////////////////
6 // Description: Library to interface to Clearcase streams
7 // Author: Andrew@DeFaria.com
8 // Created: Wed Jul 5 10:14:02 PDT 2006
9 // Modified: 2007/05/17 07:45:48
12 // (c) Copyright 2006, Andrew@DeFaria.com, all rights reserved.
14 ////////////////////////////////////////////////////////////////////////////////
16 $pvob = "/vobs/ilm_pvob";
17 $cleartool = "/opt/rational/clearcase/bin/cleartool";
19 function debug ($msg) {
20 print "<b><font color=red>DEBUG:</font></b> $msg<br>\n";
23 function error ($msg) {
24 print "<b><font color=red>ERROR:</font></b> $msg<br>\n";
28 function get_streams () {
32 $cmd = "$cleartool lsstream -s -invob $pvob";
34 exec ($cmd, $output, $status);
37 print "Unable to execute command \"$cmd\" (Status: $status)<br>";
44 function get_usernames () {
45 $cmd = "ypcat passwd";
47 exec ($cmd, $lines, $status);
50 print "Unable to execute command \"$cmd\" (Status: $status)<br>";
56 foreach ($lines as $line) {
57 $fields = explode (":", $line);
58 $users {$fields [0]} = $fields [4];
64 function get_users () {
65 $cmd = "ypcat passwd";
67 exec ($cmd, $lines, $status);
70 print "Unable to execute command \"$cmd\" (Status: $status)<br>";
76 foreach ($lines as $line) {
77 $fields = explode (":", $line);
78 array_push ($users, $fields [0]);
84 function get_nusers ($stream) {
88 $cmd = "$cleartool lslock stream:$stream@$pvob";
90 exec ($cmd, $output, $status);
93 print "Stream: $stream not found";
96 if (count ($output) == 0) {
103 foreach ($output as $line) {
104 if (preg_match ("/\"Locked except for users: (.*)\"/", $line, $matches)) {
105 $nusers = split (" ", $matches [1]);
112 function is_member ($new_item, $array) {
113 if (empty ($new_item) || empty ($array)) {
117 foreach ($array as $item) {
118 if ($new_item == $item) {
126 function remove_from_array ($removed_item, $array) {
127 $new_array = array ();
129 foreach ($array as $item) {
130 if ($removed_item != $item) {
131 array_push ($new_array, $item);
136 } // remove_from_array
138 function chnusers ($stream, $users) {
141 foreach ($users as $user) {
142 if (empty ($nusers)) {
149 $current_nusers = get_nusers ($stream);
151 if (count ($current_nusers) == 0 || count ($users) == 0) {
152 $cmd = "./chnusers $stream $nusers";
154 $cmd = "./chnusers $stream $nusers replace";
157 exec ($cmd, $output, $status);
162 function copyright ($start_year = "", $version = "") {
164 $current_year = $today ["year"];
166 $this_file = $_SERVER['PHP_SELF'];
168 // Handle user home web pages
169 if (preg_match ("/\/\~/", $this_file)) {
170 $this_file= preg_replace ("/\/\~(\w+)\/(\s*)/", "/home/$1/web$2/", $this_file);
172 $this_file = "/var/devenv/tiburon/" . $this_file;
175 $mod_time = date ("F d Y @ g:i a", filemtime ($this_file));
178 <div class="copyright">
179 Last modified: $mod_time<br>
183 if ($start_year != "") {
184 print "$start_year-";
188 $current_year <a href="http://www.hp.com/go/ilm">HP/Information Lifecycle Management Solutions</a><br>
189 All rights reserved (
192 print basename ($_SERVER ["PHP_SELF"], ".php");
194 if ($version != "") {