⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 toolbox.php

📁 Internet Task Management System可以让用户分配和管理一个组织内的任务。ITMS可以发送任务管理通知
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/* * toolbox.php * This file contains functions used throughout the system * * ITMS ValleyData source file version 1.0 May 11, 2001 * * * * Internet Task Management System: An online system used for recording information about and assigning tasks and processes. * Copyright (C) 2001  ValleyData Programming Group * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * * See file named "gpl.txt" included with source code or * visit http://www.gnu.org/copyleft/gpl.txt on the internet. */// converts from raw format to 'March 21, 2001, 10:00 AM'function convert_date($db_date){    $timestamp = strtotime($db_date);    $ret = date("F j, Y, g:i a", $timestamp);    return $ret;}// Tell the user he has been assigned a taskfunction notifyAssigned($taskTitle, $to, $assignedTo, $assignedBy, $assigner_email, $cc, $info, $due_date, $priority, $is_html = "0"){	$date = date("F j, Y, g:i a");	$body = "The task: $taskTitle\n" .			"Assigned to: $assignedTo\n" .			"Assigned by: $assignedBy\n" .			"Assigned on: $date\n" .		    "Is Due: " . convert_date($due_date) . "\n" .		    "With Priority: $priority\n" .		    "Info:\n$info";	if ($assigner_email == "")		$headers = "From: $assignedBy <$assigner_email>\n";	else		$headers = "From: $assigner_email <$assigner_email>\n";	$headers .= "Reply-To: $assigner_email\n";	if($cc != "")	{		$cc = str_replace(";", ",", $cc);		$headers .= "Cc: $cc\n";	}	mail(stripslashes($to), "Task Assigned", stripslashes($body), stripslashes($headers));	}// Tell the user he has been unassigned a taskfunction notifyUnassigned($taskTitle, $to, $assignedTo, $assignedBy, $assigner_email, $info, $due_date, $priority, $is_html = "0"){	$date = date("F j, Y, g:i a");	$body = "The task: $taskTitle, has been Unassigned\n" .			"It Was Assigned to: $assignedTo\n" .			"Unassigned by: $assignedBy\n" .			"Unassigned on: $date\n" .		    "Was Due: " . convert_date($due_date) . "\n" .		    "With Priority: $priority\n" .		    "Info:\n$info";	if ($assigner_email == "")		$headers = "From: $assignedBy <$assigner_email>\n";	else		$headers = "From: $assigner_email <$assigner_email>\n";	$headers .= "Reply-To: $assigner_email\n";	mail(stripslashes($to), "Task Unassigned", stripslashes($body), stripslashes($headers));	}// Tell the user their pending task has been updatedfunction notifyUpdate($taskTitle, $to, $assignedBy, $assigner_email, $info, $due_date, $priority, $is_html = "0"){	$date = date("F j, Y, g:i a");	$body = "The task: $taskTitle\n" .			"Assigned by: $assignedBy\n" .			"Assigned on: $date\n" .		    "Is Due: " . convert_date($due_date) . "\n" .			"With Priority: $priority\n" .		    "Info:\n$info";	if ($assigner_email == "")		$headers = "From: $assignedBy <$assigner_email>\n";	else		$headers = "From: $assigner_email <$assigner_email>\n";	$headers .= "Reply-To: $assigner_email\n";	mail(stripslashes($to), "Task Updated", stripslashes($body), stripslashes($headers));	}// Tell the assigner that the assignee has completed a taskfunction notifyComplete($taskTitle, $to, $assignedTo, $assignedTo_email, $info, $due_date, $priority, $is_html = "0"){ 	$date = date("F j, Y, g:i a");	$body = "The task: $taskTitle\n" .			"Assigned to: $assignedTo\n" .            "Was Due on: " . convert_date($due_date) . "\n" .			"Was completed on: $date\n" .			"With Priority: $priority\n" .		    "Info:\n$info";	if ($assignedTo_email == "")		$headers = "From: $assignedTo <$assignedTo_email>\n";	else		$headers = "From: $assignedTo_email <$assigner_email>\n";	$headers .= "Reply-To: $assignedTo_email\n";		mail(stripslashes($to), "Task Completed", stripslashes($body), stripslashes($headers));}//This function is called from each page that Administrators have exclusive access to function admin_only($isadmin){    if(!$isadmin)    {        print("</body>\n");        print("<head>\n");        print("<META HTTP-EQUIV=\"Refresh\" content=\"0;URL=logout.php\">\n");        print("</head>\n");        message_box("You are not authorized to view this page.", "error");        exit;    }}//end admin_only()//Precondition: $username and $password have already been "made clean"// Verify that the user password combination is in the databasefunction db_is_user($username, $password){    //please make sure that $username and $password are clean before calling this function    db_open();    db_use();    $query = "SELECT * FROM ldap WHERE name LIKE '$username'";    $result = db_query($query); // Check for valid user name in DB    if($row = db_fetch_row($result)) // If user exists... get the user    {		$passcheck = $row["PASSWORD"];        if($passcheck == crypt($password, substr($row["PASSWORD"], 0, 2))) // Check that the password matches        {            return true;        }        else        {            error_out("Password didn't match for user: " . $username, "LOG_INFO");        }    }    else    {        error_out("Couldn't Query LDAP table");    }        return false;}//end db_is_user()//Precondition: $username and $password have already been "made clean"// Verify that the user password combination is in LDAPfunction ldap_is_user($username, $password){    //please make sure that $username and $password are clean before calling this function	$ret = "false";    global $LDAP_SERVER_ADDRESS;	global $LDAP_SERVER_PORT;	global $LDAP_BASE_DN;	$ds=ldap_connect($LDAP_SERVER_ADDRESS, $LDAP_SERVER_PORT);  // must be a valid LDAP server!	if ($ds) // If connected...	{ 		$r=ldap_bind($ds);     // this is an "anonymous" bind, typically							   // read-only access		// Search surname entry		$sr=ldap_search($ds, "cn=$username, " . $LDAP_BASE_DN, "(objectclass=person)");  		$info = ldap_get_entries($ds, $sr);		$cryptpass = $info[0]["PASSWORD"][0];		if($cryptpass == crypt($password, substr($cryptpass, 0, 2))) // Check password matches		{			$ret = "true";		}			ldap_close($ds);	} 	else	{		echo "<h4>Unable to connect to LDAP server</h4>";	}    return $ret;}//end ldap_is_user()//Precondition: $username has already been "made clean"// Get the user ID corresponding to a user namefunction get_uid($username){    //please make sure that $username is clean before calling this function    $ret = "";    db_open();    db_use();    $query = "SELECT user_id FROM users WHERE name = '$username'";    $result = db_query($query); // Get the user ID that matches the user name     if($row = db_fetch_row($result))    {        $ret = $row["USER_ID"];    }    return $ret;}//end get_uid()// Display a formatted message boxfunction message_box($message, $type = "info"){    //we can add icons for each of these later too    $MESSBOXCFG["error"]["color"] = "#FF3333";    $MESSBOXCFG["warning"]["color"] = "#FF9900";    $MESSBOXCFG["info"]["color"] = "#00FF00";    $MESSBOXCFG["error"]["text"] = "Error:";    $MESSBOXCFG["warning"]["text"] = "Warning:";    $MESSBOXCFG["info"]["text"] = "Info:";    $color = $MESSBOXCFG[$type]["color"];    $text = $MESSBOXCFG[$type]["text"];	$text = stripslashes($text);	$message = stripslashes($message);$box = <<<BOX<TABLE border="0" bgcolor="#FFFFFF"><TR>	<TD bgcolor="$color"><b>$text</b></TD></TR><TR>	<TD bgcolor="$color">$message</TD></TR></TABLE>BOX;    print($box);}//end message_box()// Check if user is an Administratorfunction is_admin($user_id){    db_open();    db_use();    $query = "SELECT * FROM users WHERE user_id = '$user_id'";    $result = db_query($query);	$row = db_fetch_row($result);	if($row["ISADMIN"] == "1")		return true;	else		return false;}// Get the process name given a process IDfunction get_process_name($pid){	db_open();	db_use();	$query = "SELECT title FROM processes WHERE pid='$pid'";	$row = db_fetch_row(db_query($query));	$process_name = $row["TITLE"];	return $process_name;}// Get the task name given a task IDfunction get_task_name($ttid){	db_open();	db_use();	$query = "SELECT title FROM task_types WHERE ttid='$ttid'";	$row = db_fetch_row(db_query($query));	$task_name = $row["TITLE"];	return $task_name;}// Get the pending task name given a pending task IDfunction get_pending_task_name($tid){	db_open();	db_use();	$query = "SELECT title FROM pending_tasks WHERE tid='$tid'";	$row = db_fetch_row(db_query($query));	$task_name = $row["TITLE"];	return $task_name;}// Get the process owner's name given a process IDfunction get_process_owner($pid){	db_open();    db_use();	//first find out if the process is group owned, or is privately owned    $query = "SELECT group_owned, owner FROM processes WHERE pid = '$pid'";    $result = db_query($query);	$row = db_fetch_row($result);	$owner = $row["OWNER"];	//if it is group owned, return the name of the group who ownes it	if($row["GROUP_OWNED"] == "1")	{		$query = "SELECT groupname FROM groups WHERE gid = '$owner'";		$result = db_query($query);		$row = db_fetch_row($result);		$groupname = $row["GROUPNAME"];		return $groupname;	}	//else return the name of the user who owns it	else	{		$query = "SELECT name FROM users WHERE user_id = '$owner'";		$result = db_query($query);		$row = db_fetch_row($result);		$name = $row["NAME"];		return $name;	}}// Get the task owner's name given a task IDfunction get_task_owner($ttid){	db_open();    db_use();	//first find out if the task is group owned, or is privately owned    $query = "SELECT group_owned, owner FROM task_types WHERE ttid = '$ttid'";    $result = db_query($query);	$row = db_fetch_row($result);	$owner = $row["OWNER"];	//if it is group owned, return the name of the group who ownes it	if($row["GROUP_OWNED"] == "1")	{		$query = "SELECT groupname FROM groups WHERE gid = '$owner'";		$result = db_query($query);		$row = db_fetch_row($result);		$groupname = $row["GROUPNAME"];		return $groupname;	}	//else return the name of the user who owns it	else	{		$query = "SELECT name FROM users WHERE user_id = '$owner'";		$result = db_query($query);		$row = db_fetch_row($result);		$name = $row["NAME"];		return $name;	}}// Gets all processes that task is infunction get_processes_with_task($ttid){    $ret = array();    db_open();    db_use();    $query = "SELECT title, P.pid FROM process_tasks PT, processes P WHERE PT.ttid='$ttid' " .    "AND PT.pid = P.pid GROUP BY title, P.pid";    $result = db_query($query);	while($row = db_fetch_row($result))    {        array_push($ret, $row);    }    return $ret;}// Get all tasks in processfunction get_tasks_in_process($pid){    $ret = array();    db_open();    db_use();    $query = "SELECT title, T.ttid FROM process_tasks PT, task_types T WHERE PT.pid='$pid' " .    "AND PT.ttid = T.ttid GROUP BY title, T.ttid";    $result = db_query($query);	while($row = db_fetch_row($result))    {        array_push($ret, $row);    }    return $ret;}// Returns true if task is in processfunction is_task_in_process($ttid, $pid){    db_open();    db_use();    $query = "SELECT * FROM process_tasks WHERE ttid='$ttid' AND pid='$pid'";    $result = db_query($query);	if(db_fetch_row($result))		return true;	else		return false;}// Returns true if user is in groupfunction is_user_in_group($user_id, $group_id){    db_open();    db_use();    $query = "SELECT * FROM user_groups WHERE gid = '$group_id' AND user_id = '$user_id'";    $result = db_query($query);	if(db_fetch_row($result))		return true;	else		return false;}// Returns all users in group, all users are returned if no group is specifiedfunction get_users_in_group($groupnum = "%"){    $ret = array();    db_open();    db_use();    $query = "SELECT name, users.user_id FROM users, user_groups " .     "WHERE gid like '$groupnum' AND users.user_id = user_groups.user_id GROUP BY user_id ORDER BY name";        $result = db_query($query);    while($row = db_fetch_row($result))    {        array_push($ret, $row);    }    db_close();    return $ret;}// Get all the users from the groups that the specified user is in;// returns all users in groups if no user ID specifiedfunction get_users_in_groups($usernum = "%"){    $ret = array();    db_open();    db_use();    $query = "SELECT gid FROM user_groups WHERE user_id = '$usernum'";	$first = "true";	$set_str = "";    $result = db_query($query);    while($row = db_fetch_row($result))    {		if($first == "true")		{			$set_str .= $row["GID"];			$first = "false";		}		else		{			$set_str .= ", " . $row["GID"]; 		}    }	$query2 = "SELECT name, U.user_id FROM user_groups UG, users U WHERE U.user_id = UG.user_id " .		"AND UG.gid IN ($set_str) GROUP BY name, U.user_id ORDER BY name";	$result = db_query($query2);	while($row = db_fetch_row($result))    {        array_push($ret, $row);    }    db_close();    return $ret;}// Gets all the groups that the user is currently in; gets all groups if the user is not specifiedfunction get_user_groups($usernum = "%"){    $ret = array();    db_open();    db_use();    $query = "SELECT gid, user_id FROM user_groups WHERE user_id = '$usernum'";        $result = db_query($query);    while($row = db_fetch_row($result))    {        array_push($ret, $row);    }    db_close();    return $ret;}// Returns an array containing group names and group IDsfunction get_all_groups(){	$ret = array();    db_open();    db_use();    $query = "SELECT groupname, gid FROM groups ORDER BY groupname";    $result = db_query($query);    while($row = db_fetch_row($result))    {        array_push($ret, $row);    }    db_close();    return $ret;}// Get all groups other than the specified group idfunction get_all_other_groups($gid){	$ret = array();    db_open();    db_use();    $query = "SELECT * FROM groups WHERE gid != '$gid' ORDER BY groupname";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -