//上传文件
function uploadfile($upfilename,$upfile_size,$uploaddir,$upfile_tmp)
{
if(@copy($upfile_tmp, $uploaddir.$upfile)) {
$flag= TRUE;
} elseif(function_exists("move_uploaded_file")) {
if(@move_uploaded_file($upfile_tmp, $uploaddir.$upfile)) {
$flag = TRUE;
}
}
if(!$flag && is_readable($upfile_tmp)) {
@$fp = fopen($upfile_tmp, "rb");
@flock($fp, 2);
@$readedfile = fread($fp, $upfile_size);
@fclose($fp);
@$fp = fopen($uploaddir.$upfilename, "wb");
@flock($fp, 3);
if(@fwrite($fp, $readedfile)) {
$flag = TRUE;
}
@fclose($fp);
}
}
//check user
function islogin($name,$pass)
{
include('config.php');
mysql_select_db($dbname,$link);
if ($name!="")
{
$name = ltrim($name);
$name=rtrim($name);
$query="select * from worker where login_name='".$name."'";
$result=mysql_query($query,$link);
$get=@mysql_fetch_object($result);
@mysql_close();
if($get->login_pass==$pass)
return true;
else return false;
}
else return false;
}
//检查是否为员工
function isuser($name)
{
include('config.php');
mysql_select_db($dbname,$link);
if ($name!="")
{
$name = ltrim($name);
$name=rtrim($name);
$query="select * from worker where login_name='".$name."'";
$result=mysql_query($query,$link);
$get=@mysql_fetch_object($result);
if ($get)
{ @mysql_close();
return true;
}
else return false;
}
else return false;
}
//搜索引擎
function find($key)
{
include('config.php');
mysql_select_db($dbname,$link);
if ($key!="")
{
$key = ltrim($key);
$key=rtrim($key);
$query_key="select * from worker where login_name like '%".$key."%' or worker_name like '%".$key."%'";
$result_key=mysql_query($query_key,$link);
while($get=@mysql_fetch_object($result_key))
{
echo "姓名:".$get->worker_name." -- 登陆名:".$get->login_name." -- 电子邮件:".$get->worker_email." ";
}
}
else
echo "没有符合条件的人";
@mysql_close();
}
//是否为会员
function isworker($name)
{
include('config.php');
mysql_select_db($dbname,$link);
if ($name!="")
{
$name = ltrim($name);
$name=rtrim($name);
$query="select * from worker where login_name='".$name."'";
$result=mysql_query($query,$link);
$get=@mysql_fetch_object($result);
@mysql_close();
if ($get)
return $get->login_name;
else return "非内部人员";
}
else return "非内部人员";
@mysql_close();
}
//此人是否添加
function isadded($name,$worker_login_name)
{
include('config.php');
mysql_select_db($dbname,$link);
if ($name!="")
{
$name = ltrim($name);
$name=rtrim($name);
$query="select * from address_list where worker_login='".$name."' and worker_login_name='".$worker_login_name."'";
$result=mysql_query($query,$link);
$get=@mysql_fetch_object($result);
@mysql_close();
if ($get)
return true;
else return false;
}
else return false;
@mysql_close();
}
//删除联系人
function dellist($key,$worker_login_name)
{
include('config.php');
mysql_select_db($dbname,$link);
$key = ltrim($key);
$key=rtrim($key);
$query_key="delete from address_list where worker_login_name='".$worker_login_name."' and worker_login='".$key."'";
if ($result_key=mysql_query($query_key,$link))
{
echo "提示:成功删除";
}
else
echo "提示:没有符合条件的人";
@mysql_close();
}
//生成联系人下拉菜单
function createlist($name)
{
include('config.php');
mysql_select_db($dbname,$link);
if ($name!="")
{
$name = ltrim($name);
$name=rtrim($name);
$query="select * from address_list where worker_login_name='".$name."' and worker_login!='' and worker_login!='非内部人员'";
$result=mysql_query($query,$link);
while($get=@mysql_fetch_object($result))
{
echo "".$get->worker_login."";
}
}
@mysql_close();
}
//察看联系人信息
function listadded($name ,$key_name)
{
include('config.php');
mysql_select_db($dbname,$link);
if ($name!="")
{
$key_name = ltrim($key_name);
$key_name=rtrim($key_name);
$query="select * from address_list where worker_login_name='".$name."'and worker_login='".$key_name."';";
$result=mysql_query($query,$link);
while($get=@mysql_fetch_object($result))
{
echo "
姓名:".$get->worker_name."
登陆名:".$get->worker_login."
电子邮件:".$get->worker_email."
其他联系方法:".$get->worker_connect."
";
}
@mysql_close();
}
else return false;
}
//判断职务
function isadmin($name,$mod=0)
{
include('config.php');
mysql_select_db($dbname,$link);
if ($mod!=0) $worker_mod="系统管理员";
else $worker_mod="部门管理员";
if ($name!="")
{
$name = ltrim($name);
$name=rtrim($name);
$query="select * from worker where login_name='".$name."'";
$result=mysql_query($query,$link);
$get=@mysql_fetch_object($result);
if ($get->worker_mod==$worker_mod)
{
return true ;
}
else
return false ;
}
else return false ;
}
//部门列表生成
function classlist()
{
include('config.php');
mysql_select_db($dbname,$link);
$query="select * from class_list ";
$result=mysql_query($query,$link);
while($get=@mysql_fetch_object($result))
{
echo "".$get->class_name."";
}
@mysql_close();
}
// 综合数据库操作
function isin($name,$tb_name,$addterm="no")
{
include('config.php');
mysql_select_db($dbname,$link);
if ($name!="")
{
$name = ltrim($name);
$name=rtrim($name);
if ($addterm!="no")
$query="select ".$name." from ".$tb_name." ".$addterm;
else
$query="select ".$name." from ".$tb_name;
$result=mysql_query($query,$link);
$get=@mysql_fetch_object($result);
@mysql_close();
if ($get)
return true;
else return false;
}
else return false;
@mysql_close();
}
//更改文件名
function rname($oldname,$rname="no")
{
$name=explode(".",$oldname);
$num=count($name);
$type=$name[$num-1];
$newname=rand(100000,1000000);
if ($rname=="no") return time().$newname.".".$type;
else return $rname.".".$type;
}
//取得文件类型
function givetype($name)
{
$name=explode(".",$name);
$num=count($name);
return ".".$name[$num-1]." 文件";
}
//判断人员所属部门
function getjob($name)
{
include('config.php');
mysql_select_db($dbname,$link);
$name = ltrim($name);
$name=rtrim($name);
$query="select * from worker where login_name='".$name."'";
$result=mysql_query($query,$link);
$get=@mysql_fetch_object($result);
@mysql_close();
if ($get)
return $get->worker_job;
else return false;
}
function isfull($name)
{
include('config.php');
$num="admin/filelimit";
$file=@fopen($num,"r");
$all=@fread($file,filesize($num));
@fclose($file);
mysql_select_db($dbname,$link);
$query="select worker_file_size from worker_file where worker_login_name='$name'";
$result=mysql_query($query,$link);
while($get=@mysql_fetch_object($result))
{
$numall+=$get->worker_file_size;
}
echo "你的文件夹总容量为:".$all." K 你已经使用了".$numall."K ";
if ($numall>$all)
return true;
else
return false;
}
function box($name,$errormeg,$url)
{
require('template/box.php');
}
function read($name,$time_num)
{
include('config.php');
mysql_select_db($dbname);
$query=" update quickmeg set meg_is_new='已读' where meg_to=$name and meg_time=$time_num";
mysql_query($query,$link);
}
function anynew($name)
{
include('config.php');
mysql_select_db($dbname);
$query="select * from quickmeg where meg_to='$name' and meg_is_new='未读'";
mysql_query($query,$link);
$num=mysql_affected_rows($link);
if($num>0)
echo "
window.open('template/newmeg.php?num=$num','添加','status=yes,height=100,width=200,scrollbars=nob esizable=yes top=300, left=350');
//-->
";
}
function online($mod="",$name="")
{
$name = ltrim($name);
$name=rtrim($name);
include('config.php');
mysql_select_db($dbname);
if ($mod=="add")
{
$query="insert into online values('".$name."')";
if($name!="")
@mysql_query($query);
}
elseif($mod=="del")
{
$query="delete from online where worker_login_name='".$name."'";
@mysql_query($query);
}
$query_count="select * from online";
$result=@mysql_query($query_count,$link);
$num=mysql_affected_rows($link);
if($mod=="show")
{
while ($show=@mysql_fetch_object($result))
{
echo $show->worker_login_name." ";
}
}
return $num;
}
?>