Index: debian/mot/ChangeLog diff -c debian/mot/ChangeLog:1.1.1.1 debian/mot/ChangeLog:1.2 *** debian/mot/ChangeLog:1.1.1.1 Sat Mar 6 10:35:25 1999 --- debian/mot/ChangeLog Sat Mar 6 21:51:28 1999 *************** *** 1,3 **** --- 1,10 ---- + 1009-03-06 Peter Crystal + + * made some cosmetic changes :) + * CSS support, as well as a easy configure script in + configure.pl + * and have make a debian (unofficial) package for it + 1998-07-18 Hal Roberts * (released version 1.1.7) Index: debian/mot/configure.pl diff -c /dev/null debian/mot/configure.pl:1.1 *** /dev/null Sat Mar 6 21:55:47 1999 --- debian/mot/configure.pl Sat Mar 6 21:37:42 1999 *************** *** 0 **** --- 1,86 ---- + #!/usr/bin/perl + + $templist = "list"; # list of files to convert to - add .templ to it + $instdir = "/var/www/mot"; + + print "Ministry of Truth 1.1.6 \n"; + print "Configuration Script\n"; + + print "\nPlease answer the following questions, the answers\n"; + print "Will be emailed to the database admin, for record keeping\n"; + + # read in lists of files to convert to (add .templ to end) + + # MOTDBNAME mot_deb + # MOTDBUSER username + # MOTDBPASS password + # MOTNAME ie: Debian ISP Support + # NOTADMINEMAIL darke@it.net.au + # MOTADMINNAME Peter Crystal + # MOTADDRESS http://localhost/mot/ + # MOTHOST localhost + + $subst[$#subst +1 ] = "MOTNAME"; + $subst[$#subst +1 ] = "MOTDBNAME"; + $subst[$#subst +1 ] = "MOTDBUSER"; + $subst[$#subst +1 ] = "MOTDBPASS"; + $subst[$#subst +1 ] = "MOTADMINEMAIL"; + $subst[$#subst +1 ] = "MOTADMINNAME"; + $subst[$#subst +1 ] = "MOTADDRESS"; + $subst[$#subst +1 ] = "MOTHOST"; + + print "\nPlease enter the name of the Service(ie: Debian ISP Slavery)?"; + $read = ; chomp($read); $value[$#value +1 ] = $read; + print "\nPlease enter the name of the database (ie: mot_deb)?"; + $read = ; chomp($read); $value[$#value +1 ] = $read; + print "\nPlease enter the name of the database user (ie: rootsql)?"; + $read = ; chomp($read); $value[$#value +1 ] = $read; + print "\nPlease enter the name of the database password(ie: password)?"; + $read = ; chomp($read); $value[$#value +1 ] = $read; + print "\nPlease enter the name of the admin email(ie: admin\@debian.org)?"; + $read = ; chomp($read); $value[$#value +1 ] = $read; + print "\nPlease enter the name of the admin's name(ie: Ian Debian)?"; + $read = ; chomp($read); $value[$#value +1 ] = $read; + print "\nPlease enter the name of the MOT site address(ie: http://debian.org/mot/)?"; + $read = ; chomp($read); $value[$#value +1 ] = $read; + print "\nPlease enter the name of the the database host(ie: localhost)?"; + $read = ; chomp($read); $value[$#value +1 ] = $read; + + # mail answers to adminemail for safe keeping + + + $count = $#value; # number of entries - 1 :) + + #open each file in list + print "Converting .templ files to real files\n"; + + open(LIS, "<$instdir/$templist"); + while($filename = ) + { + # open file + chomp($filename); + open(FIL, "<$instdir/$filename.templ"); + open(OUT, ">$instdir/$filename"); + while($line = ) + { + #do changes and write + for($i = 0 ; $i <= $count; $i++) + { + $line =~ s/$subst[$i]/$value[$i]/g; + } + print OUT "$line"; + } + close(FIL); + close(OUT); + } + close(LIS); + + + + # create databas + system("cd $instdir/tables ; ./create-tables new"); + + print "\n\nPlease note, there is an admin:admin account and a guest:guest\n"; + print "account already setup for MOT, change the passwords ASAP\n\n"; + + exit 0; Index: debian/mot/index.html.templ diff -c /dev/null debian/mot/index.html.templ:1.1 *** /dev/null Sat Mar 6 21:55:48 1999 --- debian/mot/index.html.templ Sat Mar 6 10:45:29 1999 *************** *** 0 **** --- 1,47 ---- + + + MOTNAME + + + + + + +

MOTNAME

+ +
+ + + + + + + + + + + + + + +
+ Login: + + +
+ Password: + + +
+ +
+ +
+ +

+ + View as Guest +

+ + + Index: debian/mot/init.php3 diff -c debian/mot/init.php3:1.1.1.1 debian/mot/init.php3:1.2 *** debian/mot/init.php3:1.1.1.1 Sat Mar 6 10:35:25 1999 --- debian/mot/init.php3 Sat Mar 6 21:44:13 1999 *************** *** 59,65 **** /* You should not normally change anything below this line unless you know what you are doing */ ! $mot_version = "1.1.6"; Function table_header($border) { return "
\n" . --- 59,65 ---- /* You should not normally change anything below this line unless you know what you are doing */ ! $mot_version = "1.1.6 - darke"; Function table_header($border) { return "
\n" . Index: debian/mot/init.php3.templ diff -c /dev/null debian/mot/init.php3.templ:1.3 *** /dev/null Sat Mar 6 21:55:50 1999 --- debian/mot/init.php3.templ Sat Mar 6 21:48:44 1999 *************** *** 0 **** --- 1,966 ---- + \n" . + "\n"; + } + + Function table_footer() { + return "
\n" . + "
\n"; + } + + Function start_table($border) { + echo table_header($border); + } + + Function end_table() { + echo table_footer(); + } + + /* html_header takes care of giving all the pages the same header*/ + Function html_header($title) { + + global $mot_name; + global $table_name; + + $html = "\n"; + $html .= "\n"; + $html .= "$mot_name - $title\n"; + $html .= "\n"; + $html .= "\n"; + + $html .= ""; + + $html .= "
\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "
" . + "HomeJobs" . + "Equipment" . + "Software" . + "People" . + "Users" . + "Help" . + "Logout
\n"; + $html .= "
\n"; + + $html .= "

$mot_name
$title

\n"; + + return $html; + + }; + + + /* setup connectino to db */ + Function sql_init() { + + global $db; + + global $db_name, $db_host_name, $db_user_name, $db_pass; + + if (!($db = mysql_connect($db_host_name, $db_user_name, $db_pass))) { + echo "mysql_connect: " . mysql_error() . "\n"; + exit(); + } + if (!mysql_select_db($db_name, $db)) { + echo "mysql_select_db: " . mysql_error() . "\n"; + exit(); + } + }; + + Function mysql_query_wrap($query) { + + static $sql_init_run = 0; + + global $sql_debug, $db; + + if (sql_init_run == 0) { + $sql_init_run = 1; + sql_init(); + } + + if ($sql_debug) { + echo ""; + } + + if (!($res = mysql_query ($query, $db))) { + echo "mysql_query_wrap: " . mysql_error() . "\n"; + return $res; + } + + return $res; + }; + + + /* make a string suitable for including within a sql statement by + placing it inside single quotes and escaping any single quotes + already in the string */ + Function sql_str($str) { + + /* I'm doing this manually b/c both the ereg_replace and add_slashes + functions seem to do different things for different people */ + + $newstr = ""; + $len = strlen($str); + for ($i = 0; $i < $len; $i++) { + + if (substr($str, $i, 1) == "'") { + $newstr .= "`"; + } else { + $newstr .= substr($str, $i, 1); + } + } + + return "'" . $newstr . "'"; + }; + + Function timestamp_to_time($ts) { + + /*echo substr($ts, 0, 4) . " " . + substr($ts, 4, 2) . " " . + substr($ts, 6, 2) . " " . + substr($ts, 8, 2) . " " . + substr($ts, 10, 2) . " " . + substr($ts, 12, 2) . "
"; + */ + return MkTime(substr($ts, 8, 2), + substr($ts, 10, 2), + substr($ts, 12, 2), + substr($ts, 4, 2), + substr($ts, 6, 2), + substr($ts, 0, 4)); + } + + + /* Make a cookie representing the given user */ + Function set_mot_cookie($users_id) { + + static $seeded = 0; + + if (!$seed) { + srand(mkTime()); + $seeded = 1; + } + + $secret = strVal(rand() . rand() . rand() . rand()); + + $query = "insert into logins values(null, ". + "$users_id, " . + sql_str($secret) . ", " . + sql_str(getEnv("REMOTE_HOST")) . ", " . + "null)"; + mysql_query_wrap($query); + $res = mysql_query_wrap("select LAST_INSERT_ID()"); + $logins_id = mysql_result($res, 0, 0); + + SetCookie("MotUserCookie", "$logins_id:$secret"); + echo "\n"; + + + echo "\n"; + + }; + + /* Transform the user cookie into a users_id. Reset the timer on the + cookie. */ + Function cookie_to_user() { + + global $mot_timeout; + global $MotUserCookie; + + $cookie = $MotUserCookie; + + if ($cookie == "") + return 0; + + $logins_id = strtok($cookie, ":"); + $secret = strtok("\0"); + + $res = mysql_query_wrap("select name, logins.users_id, secret, host, " . + "last_login " . + "from logins left join users using (users_id) " . + "where logins_id = $logins_id"); + + if ((mysql_num_rows($res) < 1)) { + /*echo "\n";*/ + return 0; + } + + $row = mysql_fetch_array($res); + $last_login = timestamp_to_time($row["last_login"]); + + /*echo "Secret: $secret " . $row["secret"] . "
" . + "Host: " . getEnv("REMOTE_HOST") . " " . $row["host"] . "
" . + "Time: " . strVal(mkTime() - $last_login) . "
" . + "Name: " . $row["name"];*/ + + + if ($secret != $row["secret"]) { + /*echo "\n";*/ + return 0; + } + if (getEnv("REMOTE_HOST") != $row["host"]) { + /*echo "\n";*/ + return 0; + } + if ($mot_timeout && + (mkTime() - $last_login) > ($mot_timeout * 60)) { + /*echo "\n";*/ + return 0; + } + if (strlen($row["name"]) < 1) { + /*echo "\n";*/ + return 0; + } + + $users_id = $row["users_id"]; + + mysql_query_wrap("delete from logins " . + "where logins_id = $logins_id or " . + "last_login < " . + sql_str(date("YmdHis", mkTime() - ($mot_timeout * 60)))); + set_mot_cookie($users_id); + + return $users_id; + }; + + /* set the cookie to a null value */ + Function reset_cookie() { + + global $MotUserCookie, $sql_debug; + + if (strlen($MotUserCookie) < 1) + return; + + $logins_id = strtok($MotUserCookie, ":"); + $secret = strtok("\0"); + + $MotUserCookie = ""; + + if (strlen($logins_id) < 1) + return; + + mysql_query_wrap("delete from logins " . + "where logins_id = $logins_id and " . + "secret = " . sql_str($secret)); + + }; + + /* login returns 1 if it can login with the given name and password, 0 + otherwise. If it logs in, it also sets a cookie for a login session + with the given user */ + Function login($name, $pass) { + + $res = mysql_query_wrap("select users_id, pass " . + "from users where name = " . sql_str($name)); + + $num_rows = mysql_num_rows($res); + if ($num_rows < 1) + return 0; + + $real_pass = mysql_result($res, 0, "pass"); + $users_id = mysql_result($res, 0, "users_id"); + mysql_free_result($res); + + if (crypt($pass, "mo") == $real_pass) { + set_mot_cookie($users_id); + return $users_id; + } + } + + /* get_login_id either gets the users_id corresponing to the user cookie + or tries to log in using $name and $pass. If $relogin is not null, + the cookie is reset and get_user is forced to try to relogon. */ + + Function get_login_id() { + + global $mot_name; + global $name, $pass, $relogin; + + /* reset the cookie to relogin if requested */ + if ($relogin) { + reset_cookie(); + } + + if (!($users_id = cookie_to_user()) && + !($users_id = login($name, $pass))) { + SetCookie("MotUserCookie", ""); + echo "\n". + "\n". + "$mot_name - Disconnected\n". + "\n". + "". + "

$mot_name
Disconnected\n". + "

\n". + "

\n". + "Either you intentionally logged out, you entered an incorrect \n". + "username/password, or your current session has timed out from \n". + "inactivity. Please return to the Login \n". + "Screen to login again.\n". + "

\n"; + include "foot.php3"; + exit(); + } + + return $users_id; + + }; + + /* return the text for an html table. $field_titles is an array containing + containing the title for the HTML columns; $field_names is an array + containing the sql names of the columns to be selected from the + database; $tail is the tail of the query, which must include a from + statement and may also include joins, wheres, order bys, etc. + + sql_table will also only print one row for each unique id of $table_name.*/ + Function sql_table($table_name, $field_titles, $field_names, $tail) { + + $num_fields = count($field_titles); + + $query = "select "; + for ($i = 0; $i < $num_fields; $i++) { + $query .= $field_names[$i] . ", "; + } + + $query .= "$table_name.$table_name" . "_id "; + + $query .= " ".$tail; + + + if (!($res = mysql_query_wrap($query))) { + echo "sql_table query error.\n"; + exit(); + } + + $num_rows = mysql_num_rows($res); + + $table .= table_header(1); + + $table .= "\n"; + for ($i = 0; $i < $num_fields; $i++) { + $table .= "$field_titles[$i]\n"; + } + $table .= "\n"; + + for ($i = 0; $i < $num_rows; $i++) { + if (!($row = mysql_fetch_row($res))) { + echo "sql_table fetch_row error: ". mysql_error() . "\n"; + exit(); + } + + $id = $row[$num_fields]; + + + /* FIXME - I need to figure out how to get the query only to return + one row per id. The below thing is just a hack to simulate that */ + if ($prev_ids[$id] != 1) { + $prev_ids[$id] = 1; + + $table .= "\n"; + if ($table_name == "jobs") + $table .= "$row[0]\n"; + else + $table .= "$row[0]\n"; + for ($j = 1; $j < $num_fields; $j++) { + if (strlen($row[$j]) < 1) + $row[$j] = " "; + $table .= "".$row[$j]."\n"; + } + $table .= "\n"; + } + } + $table .= table_footer(); + + return $table; + }; + + Function is_blank($field_name, $field) { + + if (strlen($field + ) < 1) { + echo "The $field_name field is blank. Please return the previous page " . + "and enter it."; + return 1; + } + + return 0; + }; + + Function sql_select_table($table, $select_id, $display_name, $table_id) { + + if ($select_id != "department") + include $table . "_init.php3"; + + $html = "\n"; + + return $html; + } + + Function sql_select_multiple_table($name, $table, $select_id, $display_name, $order) { + + $html = "\n"; + + return $html; + } + + Function change_job_links_form($table, $name, $jobs_id, $order) { + + $html = "
\n"; + + $html .= table_header(1); + + $res = mysql_query_wrap("select $table.$table". "_id, $name from $table " . + "left join $table" . "_jobs " . + "using ($table" . "_id) " . + "where jobs_id = $jobs_id $order"); + + $num_rows = mysql_num_rows($res); + + if ($num_rows > 0) { + $html .= "\n"; + $html .= "Remove $table:\n"; + $html .= "\n"; + $html .= "\n"; + } + + + $res = mysql_query_wrap("select $table" . "_id, $name from $table $order"); + + $num_rows = mysql_num_rows($res); + + if ($num_rows > 0) { + $html .= "\n"; + $html .= "Add $table:\n"; + $html .= "\n"; + $html .= "\n"; + } + + $html .= "\n"; + $html .= "\n"; + $html .= table_footer(); + $html .= "
\n"; + $html .= "\n"; + $html .= "
\n"; + $html .= "
\n"; + + return $html; + }; + + Function change_job_links($table, $jobs_id, $add, $remove) { + + $max = count($remove); + for ($i = 0; $i < $max; $i++) { + mysql_query_wrap("delete from $table" . "_jobs ". + "where $table" . "_id = $remove[$i] and jobs_id = $jobs_id"); + }; + + $max = count($add); + for ($i = 0; $i < $max; $i++) { + mysql_query_wrap("insert into $table" . "_jobs values(null, $jobs_id, $add[$i])"); + }; + + }; + + Function sql_details_table($table, $field_titles, $field_names, $tail, $id, $pre_last) { + + global $sql_debug; + + $query = "select "; + + $num_fields = count($field_names); + for ($i = 0; $i < $num_fields; $i++) { + $query .= $field_names[$i] . ", "; + } + + $query .= $table . "_id $tail"; + + $sql_debug = 1; + if (!($res = mysql_query_wrap($query))) { + exit(); + } + + + $html .= table_header(0); + $html .= "\n"; + $html .= "\n"; + if ($table == "jobs") + $html .= ""; + else + $html .= ""; + $html .= "Modify " . ucfirst($table) . " Details\n"; + $html .= "\n"; + $html .= "\n"; + $html .= table_footer(); + + $html .= table_header(1); + + $row = mysql_fetch_row($res); + for ($i = 0; $i < $num_fields; $i++) { + $html .= "\n"; + $html .= "$field_titles[$i]\n"; + if (strlen($row[$i]) < 1) + $row[$i] = " "; + if (($i < ($num_fields - 1)) || + ($pre_last < 1)) { + $html .= "$row[$i]\n"; + } else { + $html .= "
$row[$i]
\n"; + } + $html .= "\n"; + } + + $html .= table_footer(); + + return $html; + } + + /* return a forms table corresponding to the given table and fields */ + Function sql_modify_table($table, $field_titles, $field_names, $tail, + $id, $pre_last, $modify) { + + $num_fields = count($field_titles); + + if ($modify) { + $query = "select "; + + for ($i = 0; $i < $num_fields; $i++) { + $query .= $field_names[$i] . ", "; + } + + $query .= $table . "_id $tail"; + + if (!($res = mysql_query_wrap($query))) { + exit(); + } + + $row = mysql_fetch_row($res); + } + + $html .= table_header(1); + + for ($i = 0; $i < $num_fields; $i++) { + $html .= "\n"; + $html .= "$field_titles[$i]\n"; + if ($modify) { + $val = $row[$i]; + } else { + $val = ""; + } + if (($i < ($num_fields - 1)) || + ($pre_last < 1)) { + $html .= "\n"; + } else { + $html .= "\n"; + } + + $html .= "\n"; + } + + $html .= table_footer(); + + return $html; + } + + Function sql_assignment_table($table_name, $jobs_id) { + + include $table_name . "_init.php3"; + + $html = "

\n"; + $html .= "" . ucfirst($table_name) . "\n"; + $html .= "

\n"; + + $html .= table_header(0); + $html .= "\n"; + $html .= "\n"; + + $html .= "" . + "Add/Remove " . ucfirst($table_name) . "\n"; + + $html .= "\n"; + $html .= "\n"; + $html .= table_footer(); + + $tail = "from $table_name " . + "left join " . $table_name . "_jobs using (" . $table_name . "_id) " . + $join[$table_name] . " where jobs_id = $jobs_id"; + + $html .= sql_table($table_name, $field_titles[$table_name], $field_names[$table_name], + $tail); + + return $html; + } + + /* return 1 if the given user has permission to modify the given table. + return 2 if the user has permission to change her own password. + exit otherwise.*/ + Function check_user_permissions($login_id, $table, $users_id) { + + $res = mysql_query_wrap("select change_" . "$table " . + "from users where users_id = $login_id"); + + if ((mysql_num_rows($res) < 1) || + (mysql_result($res, 0, 0) != 1)) { + + if ($login_id == $users_id) + return 2; + echo "

\n"; + echo "You do not have permission to change $table."; + echo "

\n"; + exit(); + } + + return 1; + + } + + /* exit if the given user dowesn't have permission to modify + the given table. */ + Function check_permissions($login_id, $table) { + + $res = mysql_query_wrap("select change_" . "$table " . + "from users where users_id = $login_id"); + + if ((mysql_num_rows($res) < 1) || + (mysql_result($res, 0, 0) != 1)) { + echo "

\n"; + echo "You do not have permission to change $table."; + echo "

\n"; + exit(); + } + + } + + /* return true if the given job is open */ + Function job_open($jobs_id) { + + $res = mysql_query_wrap("select close_date from jobs " . + "where jobs_id = $jobs_id"); + + return (mysql_result($res, 0, 0) == '0000-00-00'); + } + + /* return a sorted version of the given array with all of the + duplicates removes */ + Function unique($array) { + + $n = count($array); + + if ($n < 2) { + return $array; + } + + sort($array); + + $ret[] = $array[0]; + $ri = 0; + for ($i = 1; $i < $n; $i++) { + if ($array[$i] != $ret[$ri]) { + $ret[] = $array[$i]; + $ri++; + } + } + + $array = $ret; + + return $array; + } + + /* return a plain text string containing all of the relevant information about the given + job */ + Function sql_txt_job($jobs_id) { + + $res = mysql_query_wrap("select summary, priority, open_date, close_date, " . + "concat(first_name, ' ', last_name), detail " . + "from jobs left join users creators on creator = creators.users_id " . + "left join people on creators.people_id = people.people_id " . + "where jobs_id = $jobs_id"); + + $row = mysql_fetch_row($res); + $txt = "Summary: $row[0]\n"; + $txt .= "Priority: $row[1]\n"; + $txt .= "Open Date: $row[2]\n"; + if ($row[3] != "0000-00-00") + $txt .= "Close Date: $row[3]\n"; + $txt .= "Job Creator: $row[4]\n"; + $txt .= "Details:\n****\n$row[5]\n****\n\n"; + + $res = mysql_query_wrap("select concat(first_name, ' ', last_name) " . + "from users left join users_jobs on users.users_id = users_jobs.users_id " . + "left join people on users.people_id = people.people_id " . + "where users_jobs.jobs_id = $jobs_id"); + + $txt .= "Assigned Techs:\n"; + $n = mysql_num_rows($res); + for ($i = 0; $i < $n; $i++) { + $row = mysql_fetch_row($res); + $txt .= $row[0] . "\n"; + } + $txt .= "\n"; + + $res = mysql_query_wrap("select concat(first_name, ' ', last_name) " . + "from people left join people_jobs using (people_id) " . + "where people_jobs.jobs_id = $jobs_id"); + + $txt .= "Contacts:\n"; + $n = mysql_num_rows($res); + for ($i = 0; $i < $n; $i++) { + $row = mysql_fetch_row($res); + $txt .= $row[0] . "\n"; + } + $txt .= "\n"; + + $res = mysql_query_wrap("select name " . + "from equipment left join equipment_jobs using (equipment_id) " . + "where equipment_jobs.jobs_id = $jobs_id"); + + $txt .= "Equipment:\n"; + $n = mysql_num_rows($res); + for ($i = 0; $i < $n; $i++) { + $row = mysql_fetch_row($res); + $txt .= $row[0] . "\n"; + } + $txt .= "\n"; + + $res = mysql_query_wrap("select name " . + "from software left join software_jobs using (software_id) " . + "where software_jobs.jobs_id = $jobs_id"); + + $txt .= "Software:\n"; + $n = mysql_num_rows($res); + for ($i = 0; $i < $n; $i++) { + $row = mysql_fetch_row($res); + $txt .= $row[0] . "\n"; + } + $txt .= "\n"; + + $res = mysql_query_wrap("select summary, concat(first_name, ' ', last_name), " . + "open_date, detail from " . + "comments left join users on comments.users_id = users.users_id " . + "left join people on users.people_id = people.people_id " . + "where jobs_id = $jobs_id order by open_date desc"); + + $txt .= "Comments:\n"; + $n = mysql_num_rows($res); + for ($i = 0; $i < $n; $i++) { + $row = mysql_fetch_row($res); + $txt .= "Summary: $row[0]\n"; + $txt .= "Tech: $row[1]\n"; + $txt .= "Date: $row[2]\n"; + $txt .= "Detail:\n****\n$row[3]\n****\n\n"; + } + $txt .= "\n"; + + return $txt; + } + + + Function mot_mail($to, $sub, $msg) { + + global $sendmail, $mot_admin; + + if (strlen($sendmail) > 0) { + $fd = popen("$sendmail -f $mot_admin $to", "w"); + fputs($fd, "Subject : $sub\n$msg\n"); + pclose($fd); + } else + mail($to, $sub, $msg, "Reply-To: $mot_admin"); + + } + + /* send email to all the techs and contacts and the owner of the job with the + given id. Do not send mail to the the user with omit_users_id */ + Function notify($jobs_id, $omit_users_id, $sub, $msg) { + + global $mot_message; + global $notify_users, $notify_people, $notify_creator; + global $sql_debug; + + $sql_debug = 1; + + if ($omit_users_id) { + $res = mysql_query_wrap("select email from users " . + "left join people using (people_id) " . + "where users_id = $omit_users_id"); + $omit_email = mysql_result($res, 0, 0); + } + + if ($notify_users) { + $query = "select distinct email from users_jobs " . + "left join users on users.users_id = users_jobs.users_id " . + "left join people on people.people_id = users.people_id " . + "where users_jobs.jobs_id = $jobs_id "; + $res = mysql_query_wrap($query); + + $n = mysql_num_rows($res); + for ($i = 0; $i < $n; $i++) { + $row = mysql_fetch_row($res); + $emails[] = $row[0]; + } + } + + if ($notify_people) { + $query = "select distinct email from people_jobs " . + "left join people on people.people_id = people_jobs.people_id " . + "where people_jobs.jobs_id = $jobs_id"; + $res = mysql_query_wrap($query); + + $n = mysql_num_rows($res); + for ($i = 0; $i < $n; $i++) { + $row = mysql_fetch_row($res); + $emails[] = $row[0]; + } + } + + if ($notify_creator) { + $query = "select email from jobs "; + $query .= "left join users as creators " . + "on jobs.creator = creators.users_id "; + $query .= "left join people on people.people_id = creators.people_id " . + "where jobs.jobs_id = $jobs_id"; + $res = mysql_query_wrap($query); + + $n = mysql_num_rows($res); + for ($i = 0; $i < $n; $i++) { + $row = mysql_fetch_row($res); + $emails[] = $row[0]; + } + } + + $emails = unique($emails); + + $n = count($emails); + for ($i = 0; $i < $n; $i++) { + if ($emails[$i] != $omit_email) + $to .= $emails[$i] . " "; + } + + if (strlen($to) > 0) { + $msg .= $mot_message . "\n"; + $msg .= sql_txt_job($jobs_id); + + mot_mail($to, $sub, $msg); + } + + }; + + ?> Index: debian/mot/list diff -c /dev/null debian/mot/list:1.1 *** /dev/null Sat Mar 6 21:55:51 1999 --- debian/mot/list Sat Mar 6 21:37:43 1999 *************** *** 0 **** --- 1,3 ---- + tables/vars + index.html + init.php3 Index: debian/mot/mot.css diff -c /dev/null debian/mot/mot.css:1.1 *** /dev/null Sat Mar 6 21:55:52 1999 --- debian/mot/mot.css Sat Mar 6 21:37:43 1999 *************** *** 0 **** --- 1,6 ---- + BODY{background-color: black; color: white} + H1,H2,H3,H4,H5,H6{color:red} + TD{background-color:#666666} + A:link{color: red; text-decoration: none} + A:visited{color: #aa0000; text-decoration: none} + A:active{color: #0000aa; text-decoration: none} Index: debian/mot/tables/vars diff -c debian/mot/tables/vars:1.1.1.1 debian/mot/tables/vars:1.3 *** debian/mot/tables/vars:1.1.1.1 Sat Mar 6 10:35:25 1999 --- debian/mot/tables/vars Sat Mar 6 21:55:39 1999 *************** *** 1,5 **** # database, user, and password for mysql. USER and PASS can be blank. ! DB="mot_test" USER="" PASS="" --- 1,5 ---- # database, user, and password for mysql. USER and PASS can be blank. ! DB="mot" USER="" PASS="" *************** *** 14,25 **** ARGS="" if [ $USER > 0 ]; then ! ARGS="-u $USER"; fi if [ $PASS > 0 ]; then ! ARGS="$ARGS -p $PASS"; fi QUERY="$SQL $ARGS $DB" ! CREATE="$ADMIN $ARGS create $DB" \ No newline at end of file --- 14,25 ---- ARGS="" if [ $USER > 0 ]; then ! ARGS="-u$USER"; fi if [ $PASS > 0 ]; then ! ARGS="$ARGS -p$PASS"; fi QUERY="$SQL $ARGS $DB" ! CREATE="$ADMIN $ARGS create $DB" Index: debian/mot/tables/vars.templ diff -c /dev/null debian/mot/tables/vars.templ:1.2 *** /dev/null Sat Mar 6 21:55:55 1999 --- debian/mot/tables/vars.templ Sat Mar 6 21:37:48 1999 *************** *** 0 **** --- 1,25 ---- + # database, user, and password for mysql. USER and PASS can be blank. + DB="MOTDBNAME" + USER="MOTDBUSER" + PASS="MOTDBPASS" + + # these should be fine for mysql, unless you need to pass some special + # arguments to the commands. + ADMIN="mysqladmin" + SQL="mysql" + + + # don't change anything below here unless you know what you're doing + + ARGS="" + + if [ $USER > 0 ]; then + ARGS="-u$USER"; + fi + + if [ $PASS > 0 ]; then + ARGS="$ARGS -p$PASS"; + fi + + QUERY="$SQL $ARGS $DB" + CREATE="$ADMIN $ARGS create $DB" Index: debian/mot/tables/vars.tmpl diff -c /dev/null debian/mot/tables/vars.tmpl:1.1 *** /dev/null Sat Mar 6 21:55:56 1999 --- debian/mot/tables/vars.tmpl Sat Mar 6 10:45:39 1999 *************** *** 0 **** --- 1,25 ---- + # database, user, and password for mysql. USER and PASS can be blank. + DB="mot" + USER="MOTUSER" + PASS="MOTPASS" + + # these should be fine for mysql, unless you need to pass some special + # arguments to the commands. + ADMIN="mysqladmin" + SQL="mysql" + + + # don't change anything below here unless you know what you're doing + + ARGS="" + + if [ $USER > 0 ]; then + ARGS="-u $USER"; + fi + + if [ $PASS > 0 ]; then + ARGS="$ARGS -p $PASS"; + fi + + QUERY="$SQL $ARGS $DB" + CREATE="$ADMIN $ARGS create $DB"