当前位置:Linux教程 - Linux资讯 - 脚本语言新用 简易的 PHP 通讯簿

脚本语言新用 简易的 PHP 通讯簿

  管理员可以手动建立选单,从LDAP服务器中选择个别部门名单,并且可以选取多笔收件人和副本、密件副本,并且使用预设邮件客户端寄出。    共有三个档案:    ldap.Html 纯粹的框架档。  ldap.PHP 使用选单,经由php 来取得邮件地址,并建立javascript选单。  select.html 从ldap.php 获取选择项目,并建立一个连结,让邮件客户端取用。    剪剪贴贴来的。由于部份程序代码来自 Squirrel Mail,本程序为 GPL。功力不佳,请高手好好修改一番吧。 icon_redface.gif    ldap.html(不需修改)    代码:    <html>  <head><title>Java Script LDAP Addressbook</title></head>  <frameset rows="*,130">  <frame src="ldap.php" name="fr1">  <frame src="select.html" name="fr2">  </frameset>  </html>  ldap.php(请修改ldap服务器连结、部门清单和搜寻基础的部份,以符合您的需求。)    ※特别说明,我们公司的搜寻是以lastname 为基础。并不是以部门区分。请自行修改以符合需求。    代码:    <h3>自由原始码公司通讯簿查询</h3>  <Script language="javascript">    function to_addr($addr)  {  var prefix = "";  var pwintype = typeof parent.fr2.document.selectaddr;    $addr = $addr.replace(/ {1,35}$/, "");    if (pwintype != "undefined") {  if (parent.fr2.document.selectaddr.toaddr.value) {  prefix = ", ";  parent.fr2.document.selectaddr.toaddr.value =  parent.fr2.document.selectaddr.toaddr.value + ", " + $addr;  } else {  parent.fr2.document.selectaddr.toaddr.value = $addr;  }  }    }    function cc_addr($addr)  {  var prefix = "";  var pwintype = typeof parent.fr2.document.selectaddr;    $addr = $addr.replace(/ {1,35}$/, "");    if (pwintype != "undefined") {  if (parent.fr2.document.selectaddr.ccaddr.value) {  prefix = ", ";  parent.fr2.document.selectaddr.ccaddr.value =  parent.fr2.document.selectaddr.ccaddr.value + ", " + $addr;  } else {  parent.fr2.document.selectaddr.ccaddr.value = $addr;  }  }    }    function bcc_addr($addr)  {  var prefix = "";  var pwintype = typeof parent.fr2.document.selectaddr;    $addr = $addr.replace(/ {1,35}$/, "");    if (pwintype != "undefined") {  if (parent.fr2.document.selectaddr.bccaddr.value) {  prefix = ", ";  parent.fr2.document.selectaddr.bccaddr.value =  parent.fr2.document.selectaddr.bccaddr.value + ", " + $addr;  } else {  parent.fr2.document.selectaddr.bccaddr.value = $addr;  }  }    }  </Script>    <form method="post" action=ldap.php?$query>  <SELECT NAME="query" SIZE="1" onChange="submit();">    <OPTION VLAUE="" SELECTED>  <OPTION VALUE=01*>01研发部  <OPTION VALUE=02*>02行政部  <OPTION VALUE=03*>03品保部  <OPTION VALUE=*>全部列出    </SELECT>  </form>    <?php  // basic sequence with LDAP is connect, bind, search, interpret search  // result, close connection    $ds=ldap_connect("localhost"); // must be a valid LDAP server!  //echo "connect result is ".$ds."<p>";  if (empty($query))  {  echo "请从下拉式选单中选择欲查询部门";  }  else  {  if ($ds) {  // echo "Binding ...";  $r=ldap_bind($ds); // this is an "anonymous" bind, typically  // read-only Access  // echo "Bind result is ".$r."<p>";    echo "搜寻 $query .... ";  // Search surname entry  $sr=ldap_search($ds,"o=oss, c=tw", "cn=$query");   // echo "搜寻结果 ".$sr."<p>";    echo "总共 ".ldap_count_entries($ds,$sr)."笔<p>";    echo "取得资料 ...<p>";  $info = ldap_get_entries($ds, $sr);  // echo "Data for ".$info["count"]." items returned:<p>";    echo "<table border=black>";  echo "<th>姓名<th>E-mail<th>收件者<th>副本<th>密件副本";  for ($i=0; $i<$info["count"]; $i++) {  echo "<tr><td width=180>" . $info[$i]["cn"][0] . "<td>" . '<a href=mailto:' . $info[$i]["mail"][0].'>'. $info[$i]["mail"][0]."</a>";  echo "<td>" . '<a href=javascript:to_addr(\'' . $info[$i]["mail"][0].'\');>'.'收件者'."</a><br>";  echo "<td>" . '<a href=javascript:cc_addr(\'' . $info[$i]["mail"][0].'\');>'.'副本'."</a><br>";  echo "<td>" . '<a href=javascript:bcc_addr(\'' . $info[$i]["mail"][0].'\');>'.'密件副本'."</a><br>";  }    echo "</table>";  echo "<br>";  echo "查询结束";  ldap_close($ds);    } else {  echo "<h4>无法连结 LDAP 服务器,请洽MIS</h4>";  }  }  ?>  select.html(不需修改)    代码:  <html>  <head>  <Script language="javascript">  function generate()    {  var to_total=document.selectaddr.toaddr.value;  var cc_total=document.selectaddr.ccaddr.value;  var bcc_total=document.selectaddr.bccaddr.value;  document.write("<p align=center><a href=\"mailto:" + document.selectaddr.toaddr.value + "?cc=" + document.selectaddr.ccaddr.value + "&bcc=" + document.selectaddr.bccaddr.value +"\">寄出邮件</a><br><br><a href=\"javascript:history.go(-1)\">回上一页</a>");  }  function cleartoaddr()  {  document.selectaddr.toaddr.value = "";  }  </script>  </head>  <body>  <form name="selectaddr">  <table>  <tr><td>收件者:<td><input type="text" name=toaddr size="100"><td></td></tr>  <tr><td>副本:<td><input type="text" name=ccaddr size="100"></td></tr>  <tr><td>密件副本:<td><input type="text" name=bccaddr size="100"></td></tr>  </table>       <input type="reset" value="重新选择">       <input type="button" name="sum" value="产生连结" onClick=generate()>  </form>  </body>  </html>
[1] [2] 下一页 

(出处:http://www.sheup.com)


上一页 [1] [2]