<?php
//=====================================
// LINKER Category Engine
//=====================================
// Filename : mail_listview.php
// Path : Manage directory
// last update : 2002/05/31
// Desc : Milalig list manage (add,del.edit)
//=====================================
//=====================================
// File include part
//=====================================
include ("./authen.php");
include ("../function/$Sdb_type.php");
include ("../function/main_func.php");
include ("../$Slang/m_common.php");
// cutting number
$Smailcut = 30;
$directbar_cut = 10;
//=====================================
// DB_LAYER /
//=====================================
$db = new DB_Sql($Sdb_host,$Sdb_user,$Sdb_pass,$Sselect_db);
//=====================================
// Add email
//=====================================
if ($switch == "add")
{
if (check_email($email)) {
$uptime = time();
$db->query("insert into LINKER_MAIL set email='$email', uptime='$uptime'");
}
echo "<meta http-equiv='refresh' content='0; url=mail_listview.php'>";
exit;
}
//=====================================
// Delete email
//=====================================
if ($switch == "delete")
{
$count =0;
for($i=0; $i < count($deladdr); $i++)
{
$count++;
$key = trim($deladdr[$i]);
$db->query("delete from LINKER_MAIL where email='$key'");
//echo ("delete from LINKER_MAIL where email='$deladdr[$i]' <br>");
}
print <<<EOF
<head>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
<meta http-equiv='refresh' content='2; url=./mail_listview.php'>
</head>
<body bgcolor="#E9E9E9">
<table width="500" border="1"><tr><td bgcolor="#000066" align="center">
<font color="white" size="2"><b>$count $l_num $l_email $l_del</b></font>
</td></tr></table>
EOF;
exit;
}
//=====================================
// Edit form
//=====================================
if ($switch == "editform")
{
print <<<EOF
<head>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
</head>
<body bgcolor="#E9E9E9">
<form action="mail_listview.php" method="post">
<input type="hidden" name="switch" value="editsubmit">
<input type="hidden" name="oldaddr" value="$editval">
<div align=center><table border="0"><tr>
<td align="center"><font size=2><b>$editval<b></font><hr size=1>
<font size="2"><input type=text name="editaddr"><input type="submit" value="$l_edit"></font>
</td></tr></table></div>
</body></html>
EOF;
exit;
}
//=====================================
// Edit submit
//=====================================
if ($switch == "editsubmit")
{
if (check_email($editaddr))
{
$db->query("update LINKER_MAIL set email='$editaddr' where email='$oldaddr'");
}
print <<<EOF
<head>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
<script language='JavaScript'>
window.setTimeout('window.close();opener.location.reload()', 2000);
</script>
</head>
<body bgcolor="#E9E9E9">
<div align=center>
<br><table width="95%" border="1"><tr><td bgcolor="#000066" align="center">
<b><font color="white" size="2">$oldaddr $l_edit</font></b>
</td></tr></table>
</div>
</body></html>
EOF;
exit;
}
//=====================================
// View email
//=====================================
while (list($key,$val) = each($HTTP_POST_VARS)) $$key = trim($val);
while (list($key,$val) = each($HTTP_GET_VARS)) $$key = trim($val);
// search email address
if ($kword)
{
$add_query = "where email like '%$kword%'";
}
$db->query("select count(*) as total from LINKER_MAIL $add_query limit $Smailcut");
$allrow = $db->nrecord();
$total = $allrow[total];
$page_num = ceil($total / $Smailcut); // total page num
$page = ($page) ? $page : 0;
$vstart = $Smailcut * $page;
$vend = $Smailcut;
$db->query("select * from LINKER_MAIL $add_query order by uptime desc limit $vstart,$vend") ;
$link_total = $db->numrow;
$page_start = floor($page/$directbar_cut) * $directbar_cut ;
$page_end=$page_start+$directbar_cut;
//======================================
// Direct bar
//======================================
for ($p=$page_start ; $p<$page_end ; $p++ )
{
$view=$p+1;
if ($p<$page_num)
{
if ($page==$p) $direct_bar.="<font size='2'><b>$view</b></font>\n";
else $direct_bar.="<font size='2'><a href='mail_listview.php?page=$p'>$view</a></font>\n";
}
}
if ($total>$vstart+$Smailcut)
{
$next_p=$page+1;
$next_list="<a href='mail_listview.php?page=$next_p'><font size=2>>></font></a>";
}
if ($page>0)
{
$prev_p=$page-1;
$prev_list="<a href='mail_listview.php?page=$prev_p'><font size=2><<</font></a>";
}
//======================================
// Print header
//======================================
print <<<EOF
<html>
<head>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
<SCRIPT LANGUAGE="JavaScript">
<!--
function selectall()
{
for( var i=0; i<document.delform.elements.length; i++) {
var ele = document.delform.elements[i];
if(ele.type == 'checkbox')
{ele.checked = true;}
}
}
function selectnone()
{
for( var i=0; i<document.delform.elements.length; i++) {
var ele = document.delform.elements[i];
if(ele.type == 'checkbox')
{ele.checked = false;}
}
}
function editsubmit()
{
for( var i=0; i<document.delform.elements.length; i++) {
var ele = document.delform.elements[i];
if(ele.type == 'checkbox' && ele.checked == true) {
var addrval = "mail_listview.php?switch=editform&editval="+ele.value;
window.open(addrval, "","width=250,height=100");
}
}
}
//-->
</SCRIPT>
</head>
<body bgcolor="#E9E9E9">
<table border=0 cellpadding=0 cellspacing=0>
<tr><td colspan=6>
<table width="100%" border="1"><tr><td bgcolor="#000066" align="center">
<b><font color="white" size="2">$l_mailing $l_view</font></b>
</td></tr></table>
</td></tr>
<form action="mail_listview.php" method="post" name="delform">
<input type="hidden" name="switch" value="delete">
<tr><td colspan=6 width=500> </td></tr>
<tr>
<td colspan=3 bgcolor="#E0E0E0"> $prev_list $direct_bar $next_list</td>
<td colspan=3 align=right bgcolor="#E0E0E0">
<input type = 'button' onClick='javascript:selectall()' value='$l_select_all' class=cinput>
<input type = 'button' onClick='javascript:selectnone()' value='$l_select_none' class=cinput>
<input type='submit' value='$l_del' class=cinput>
<input type='button' value='$l_edit' class=cinput onClick="editsubmit()">
</td>
</tr>
<tr><td colspan=6 width=500> </td></tr>
<tr><td colspan=6 height=2 bgcolor=gray><img src="../image/x1.gif"></td></tr>
<tr bgcolor=#E0E0E0>
<td height=25 align=center width=30> </td>
<td align=center width=150><font size=2><b>$l_email</b></font></td>
<td align=center width=70><font size=2><b>$l_uptime</b></font></td>
<td align=center width=30> </td>
<td align=center width=150><font size=2><b>$l_email</b></font></td>
<td align=center width=70><font size=2><b>$l_uptime</b></font></td>
</tr>
<tr><td colspan=6 height=1 bgcolor=gray><img src="../image/x1.gif"></td></tr>
EOF;
//===================================
// Loop
//===================================
$limit_num = ceil($link_total / 2 );
while ($row = $db->nrecord()) {
$ordernum++;
if ($limit_num >= $ordernum) {
$temp_array[$ordernum][email1] = $row[email];
$temp_array[$ordernum][uptime1] = date("y/m/d",$row[uptime]);
}
else
{
$tempnum = $ordernum - $limit_num;
$temp_array[$tempnum][email2] = $row[email];
$temp_array[$tempnum][uptime2] = date("y/m/d",$row[uptime]);
}
}
for ($i=1;$i <= count($temp_array) ;$i++) {
$temp_email1 = $temp_array[$i][email1];
$temp_email2 = $temp_array[$i][email2];
$temp_uptime1 = $temp_array[$i][uptime1];
$temp_uptime2 = $temp_array[$i][uptime2];
$temp_input1 = ($temp_email1) ? "<input type=checkbox name='deladdr[]' value='$temp_email1'>" : " ";
$temp_input2 = ($temp_email2) ? "<input type=checkbox name='deladdr[]' value='$temp_email2'>" : " ";
print <<<EOF
<tr bgcolor="#F6F6F6">
<td height=23 align=center><font size=2>$temp_input1</font></td>
<td> <font size=2>$temp_email1</font></td>
<td align=center><font size=2 color=999999> $temp_uptime1</font></td>
<td align=center><font size=2>$temp_input2</font></td>
<td> <font size=2>$temp_email2</font></td>
<td align=center><font size=2 color=999999> $temp_uptime2</font></td>
</tr>
<tr><td colspan=6 height=1 bgcolor=gray><img src="../image/x1.gif"></td></tr>
EOF;
}
//======================================
// Print footer
//======================================
print <<<EOF
<tr><td colspan=6 height=1 bgcolor=gray><img src="../image/x1.gif"></td></tr>
<tr><td colspan=6 width=500> </td></tr>
</form>
<tr>
<form action="mail_listview.php" method="post">
<input type="hidden" name="switch" value="add">
<td colspan=3 align=left bgcolor="#E0E0E0">
<input type=text size=20 name=email><input type=submit value="$l_add" class=cinput>
</td>
</form>
<form action="mail_listview.php" method="post">
<td colspan=3 align=right bgcolor="#E0E0E0">
<input type=text size=20 name=kword><input type=submit value="$l_search" class=cinput>
</td>
</form>
</tr>
</table>
</BODY>
</HTML>
EOF;
?>