<?
/////////////////////////////////////////////////////
//  险情文章管理 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/top.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 "    </TD>\n";
echo "    </TR>\n";
echo "    </TBODY> \n";
echo "    </TABLE>\n";
echo "</TD>\n";
echo "<FORM action=$PHP_SELF?mode=reg 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=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=sent_name 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=sent_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 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":
//////////////
  $sent_name=htmlspecialchars($sent_name);
  $sent_name=trim($sent_name);
  $sent_pass=htmlspecialchars($sent_pass);
  $sent_pass=trim($sent_pass);
  $sent_name=safe_cover($sent_name);
 if (empty($sent_name)) {
   $msg="请您输入用户名";
   $turn_page="usersent.php";
   error_0($msg,$turn_page);
   exit;
  }
if (!ereg ("^[0-9a-zA-Z]{1,18}$",$sent_pass)) {
   $msg="密码必须是英文字母或数字";
   $turn_page="usersent.php";
   error_0($msg,$turn_page);
   exit;
 }

////////////////////////////////////////////////////////////////////
$file_sort=file("data/$user/user.pub");
$file_count=count($file_sort)-1;
for ($i=0;$i<=$file_count;$i++) {
         $file_name=explode("|",$file_sort[$i]);
         if ($sent_name==$file_name[0])
         {
  $msg="您的名字已经被人用国了，请您换一个";
    $turn_page="usersent.php";
    $msg="";
    error_0($msg,$turn_page);
    exit;
    }
        }
/////////////////////////////////////////////////////////////////////
$newdate = date("Y.m.d H:i");
$newmgs="$sent_name|$sent_pass|$type|$newdate|0||\n";
$fp=fopen("data/$user/user".".pubwait", "a+");
flock($fp,3);
fwrite($fp,$newmgs);
fclose($fp);
    $msg="恭喜您，已经成功注册。若是管理员通过您就可以自由发表文章了";
    $turn_page="index.php";
    error_1($msg,$turn_page);
    exit;
//////////////
break;
}
?>
