<?
/////////////////////////////////////////////////////
//  险情文章管理 1.0正式版本--php文本存储格式      //
//  作者：上海财经大学99国际工管    险情           //
//  email：indraw@sina.com                         //
//  qq：   30467826                                //
//  技术支持：http://shcj.51.net/wdb               //
//  最新演示：http://xqart.126.com                 //
//  2002/4/10                                      //
//  最新下载地址 http;//shcj.51.net/wdb            //
/////////////////////////////////////////////////////
require("config.php");
require("xqfunc.php");
include ("makepass.php");
require("head.php");
head_form();
echo "&nbsp;&nbsp;<img src=./images/email.gif heigth=16>&nbsp;订阅文章:";
if (!isset($mode)) {
   $mode="index";
   }
switch ($mode){
///////////////
case "index":
/////输出//////
echo "<TABLE bgColor=$main_color border=0 cellPadding=3 cellSpacing=1 width=735>\n";
echo "<TBODY>\n";
echo "<TR bgColor=$fuse_color>\n";
echo "<TD align=middle width=\"28%\" rowspan=\"6\">\n";
echo "    <TABLE width=\"90%\">\n";
echo "    <TBODY>\n";
echo "    <TR>\n";
echo "    <TD><B>订阅文章说明： </B><BR>\n";
echo "    &nbsp;1、订阅时请您正确输入您的邮箱和管理密码。<BR>\n";
echo "    &nbsp;2、管理密码用于您退定文章的时候进行验证。<BR>\n";
echo "    &nbsp;3、请您选择相应的版块订阅，否则所有的所有版块的文章都将发送到您的信箱。<BR>\n";
echo "    </TD>\n";
echo "    </TR>\n";
echo "    </TBODY> \n";
echo "    </TABLE>\n";
echo "</TD>\n";
echo "<FORM action=$PHP_SELF method=post> \n";
echo "<TD align=middle colspan=\"2\"><div align=\"left\"> \n";
echo "<BR>\n";
echo "<b>请填写下面表格：</b> </div>\n";
echo "</TD>\n";
echo "</TR>\n";
echo "<TR bgColor=$fuse_color>\n";
echo "<TD align=middle width=\"17%\" height=\"27\">选择版块:</TD>\n";
echo "<TD align=middle width=\"55%\" height=\"27\"><div align=\"left\">\n";
echo "<select name=usermail_type size=1 style=\"BACKGROUND-COLOR: $fuse_color; BORDER-BOTTOM: 1px solid; BORDER-LEFT: 1px solid; BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; COLOR: #000000\">\n";
echo "<option selected value=all>-=所有版块=-</option>\n";
echo $get_type_name;
echo "</select></div>\n";
echo "</TD>\n";
echo "</TR>\n";
echo "<TR bgColor=$fuse_color>\n";
echo "<TD align=middle width=\"17%\">邮 箱: </TD>\n";
echo "<TD align=middle width=\"55%\"><div align=\"left\">\n";
echo "<input maxlength=36 type=text name=usermail onMouseOut=\"this.style.backgroundColor = ''\" onMouseOver=\"this.style.backgroundColor = '#E5F0FF'\" size=24 style=\"BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #b4b4b4 1px double; BORDER-LEFT: #b4b4b4 1px double; BORDER-RIGHT: #b4b4b4 1px double; BORDER-TOP: #b4b4b4 1px double; COLOR: #ff90cd\"></div>\n";
echo "</TD>\n";
echo "</TR>\n";
echo "<TR bgColor=$fuse_color>\n";
echo "<TD align=middle width=\"17%\">密 码:</TD>\n";
echo "<TD align=middle width=\"55%\"><div align=\"left\">\n";
echo "<input maxlength=18 type=password name=usermail_pass onMouseOut=\"this.style.backgroundColor = ''\" onMouseOver=\"this.style.backgroundColor = '#E5F0FF'\" size=24 style=\"BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #b4b4b4 1px double; BORDER-LEFT: #b4b4b4 1px double; BORDER-RIGHT: #b4b4b4 1px double; BORDER-TOP: #b4b4b4 1px double; COLOR: #ff90cd\"></div>\n";
echo "</TD>\n";
echo "</TR>\n";
echo "<TR bgColor=$fuse_color>\n";
echo "<TD align=middle width=\"17%\">选 象:</TD>\n";
echo "<TD align=middle width=\"55%\"><div align=\"left\">订阅\n";
echo "<input CHECKED name=mode type=radio value=reg>退订\n";
echo "<input name=mode type=radio value=mod></div>\n";
echo "</TD>\n";
echo "</TR>\n";
echo "<TR bgColor=$fuse_color>\n";
echo "<TD align=middle colspan=\"2\"><div align=\"center\">\n";
echo "<input  name=search class=border style=\"BACKGROUND-COLOR: $main_color; COLOR: #000000\" type=reset value=\" 取 消 \">\n";
echo "<input  name=search class=border style=\"BACKGROUND-COLOR: $main_color; COLOR: #000000\" type=submit value=\" 确 定 \"></div>\n";
echo "</TD>\n";
echo "</FORM>\n";
echo "</TR>\n";
echo "</TBODY>\n";
echo "</TABLE>\n";
echo "</td></tr>\n";
echo "<TR><TD colspan='2' vAlign=top width='100%'><P align=right class=small><A href='http://shcj.51.net/bbs'><FONTcolor=#000000>Powered by Xqart 1.0</FONT></A></P></TD></TR></TBODY></TABLE></DIV></TD></TR>";
echo "</table>\n";
echo "<hr width=735 color=$biankuang_color>\n";
require("foot.php");
//////////////
break;
case "reg":
/////注册/////
  $usermail=htmlspecialchars($usermail);
  $usermail=trim($usermail);
  $usermail_pass=htmlspecialchars($usermail_pass);
  $usermail_pass=trim($usermail_pass);
if (!ereg("^[a-zA-Z0-9_\.]+\@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,3}$",$usermail)) {
  $msg="您填入了错误的&nbsp;E_mail";
  $turn_page="usermail.php";
  error_0($msg,$turn_page);
  exit;
  }
if (!ereg ("^[0-9a-zA-Z]{1,18}$",$usermail_pass)) {
  $msg="密码必须是英文数字或字母";
  $turn_page="usermail.php";
  error_0($msg,$turn_page);
  exit;
  }
/////////////////
$file_sort=file("data/$user/user.mailwait");
$file_count=count($file_sort)-1;
$ceshi_1=0;
 for ($i=0;$i<=$file_count;$i++) {
     $file_name=explode("|",$file_sort[$i]);
     if ($usermail==$file_name[0] and $usermail_type==$file_name[2])
     $ceshi_1=1;
            }
 if ($ceshi_1==1){
    $msg="您刚刚完成了订阅，请等待管理员验证";
    $turn_page="usermail.php";
    error_0($msg,$turn_page);
    exit;
     }
/////////////
$file_sort=file("data/$user/user.mail");
$file_count=count($file_sort)-1;
$ceshi=0;
 for ($i=0;$i<=$file_count;$i++) {
     $file_name=explode("|",$file_sort[$i]);
     if ($usermail==$file_name[0] and $usermail_type==$file_name[2])
     $ceshi=1;
            }
if ($ceshi==1){
    $msg="您已经订阅过了，请不要重复订阅。若您的信箱收不到文章，请联系管理员。";
    $turn_page="usermail.php";
    error_0($msg,$turn_page);
    exit;
     }
elseif ($ceshi==0 and $re_mail==1){
////////////////
$newdate = date("Y.m.d H:i");
$newmgs="$usermail|$usermail_pass|$usermail_type|$newdate|\n";
$fp=fopen("data/$user/user.mailwait", "a+");
flock($fp,3);
fwrite($fp,$newmgs);
fclose($fp);
    $msg="恭喜，您已经成功订阅文章";
    $turn_page="index.php";
    error_1($msg,$turn_page);
    }
else  {
$msg="管理员已经关闭了订阅邮件功能";
    $turn_page="index.php";
    error_0($msg,$turn_page);
    }
//////////////
break;
case "mod":
/////注销/////
  $usermail=htmlspecialchars($usermail);
  $usermail=trim($usermail);
  $usermail_pass=htmlspecialchars($usermail_pass);
  $usermail_pass=trim($usermail_pass);
if (!ereg("^[a-zA-Z0-9_\.]+\@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,3}$",$usermail)) {
  $msg="您填入了错误的&nbsp;E_mail";
  $turn_page="usermail.php";
  error_0($msg,$turn_page);
  exit;
  }
if (!ereg ("^[0-9a-zA-Z]{1,18}$",$usermail_pass)) {
  $msg="密码必须是英文数字或字母";
  $turn_page="usermail.php";
  error_0($msg,$turn_page);
  exit;
  }
$file_sort=file("data/$user/user".".mail");
$file_count=count($file_sort)-1;
$rezheng=0;
for ($i=0;$i<=$file_count;$i++) {
         $file_code=explode("|",$file_sort[$i]);
         if ($usermail==$file_code[0] and $usermail_pass==$file_code[1]){
         $rezheng=1;
         }
         }
if ($rezheng==1){
$fp=fopen("data/$user/user".".mail", "w");
flock($fp,3);
for ($i=0;$i<=$file_count;$i++) {
         $file_code=explode("|",$file_sort[$i]);
         if ($usermail==$file_code[0] and $usermail_pass==$file_code[1])
         continue;
         fwrite($fp,$file_sort[$i]);
        }
fclose($fp);
    $msg="恭喜，您已经成功退定文章";
    $turn_page="index.php";
    error_1($msg,$turn_page);
    exit;   }
elseif ($rezheng==0) {
    $msg="您的密码错误，或不存在此用户";
    $turn_page="usermail.php";
    error_0($msg,$turn_page);
    exit;
     }

/////////////
break;
}
////////////
?>
