<?php

//----------------------------------------------------------------------

// 创想中文修改版
// 技术支持：http://www.cx365.com/stat/
// 程序演示：http://www.cx365.com/php/stat/
//  Stat Therefor 2002 alpha 0110  (创想中文修改版 )
//----------------------------------------------------------------------

// Copyright(C) Dai Zhikang, Crossday Studio, 2002. All rights reserved

//

//          所以网络空间  www.crossday.com  www.therefor.net

//----------------------------------------------------------------------

//     免费软件  ALWAYS FREEWARE!  *技术支持 <webmaster@therefor.net>

//----------------------------------------------------------------------

//   欢 迎 您 指 出 存 在 的 b u g 和 问 题 ,  提 出 您 的 宝 贵 意 见

//----------------------------------------------------------------------

// 软件为作者利用数天的休息时间辛勤劳作而写成,请您保护我所保留的很少一点

// 权利, 您在使用本软件时请勿擅自修改页面上作者署名及版权信息,谢谢!谢谢!

//----------------------------------------------------------------------



include "config.inc.php";



if(!$config[multiuser]) die("对不起，管理员禁止了 创想统计 的多用户支持！");



if(!$step) $step=1;



$correct=" ...... <font color=\"#0000EE\">通过</font></td>\n        </tr>\n";

$incorrect=" ...... <font color=\"#EE0000\">出错</font></td>\n        </tr>\n";

$error="";



?>

<html>

<head>

<title>创想统计申请</title>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<link rel="stylesheet" href="images/admin.css" type="text/css">

</head>



<body bgcolor="#085878" text="#000000">

<script language="JavaScript">

function JM_cc(ob){

  var obj=MM_findObj(ob);

  if (obj) { 

    obj.select();js=obj.createTextRange();js.execCommand("Copy");

  }

}



function MM_findObj(n, d) { //v4.0

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && document.getElementById) x=document.getElementById(n); return x;

}

</script>

<table width="80%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" align="center">

  <tr>

    <td>

      <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">

        <tr> 

          <td class="install" height="30" valign="bottom" colspan="2"><font color="#FF0000">&gt;&gt;</font> 

            创想统计系统申请向导</td>

        </tr>

        <tr> 

          <td colspan="2">

            <hr noshade align="center" width="100%" size="1">

          </td>

        </tr>

        <tr> 

          <td colspan="2"> 

            <div align="center">欢迎您来到创想中文流量统计系统注册向导！本免费统计服务由 <a href="<?echo$config[base];?>" target="_blank"><b><?echo$config[name];?></b></a> 

              提供。请您在注册之前务必仔细阅读下面的“内容填写说明”，正确填写的表单数据，以便系统能精确的统计您的站点流量。</div>

          </td>

        </tr>

        <tr> 

          <td colspan="2"> 

            <hr noshade align="center" width="100%" size="1">

          </td>

        </tr>

        <tr> 

          <td colspan="2"> 

            <p><b>向导提示：</b>所有项目均为必填，如有任何问题，请<a href="mailto:cxcnet@msn.com">与我们联系</a>！</p>

          </td>

        </tr>

        <tr> 

          <td colspan="2"> 

            <hr noshade align="center" width="100%" size="1">

          </td>

        </tr>

        <tr> 

          <td colspan="2"><font color="#FF0000"><b>&gt;</font><font color="#000000"> 内容填写说明</b></font></td>

        </tr>

        <tr> 

          <td colspan="2"> 用户名 ......<font color="#0000EE"> 您站点的统计账号，长度在8个字符以内，只能由小写字母和数字组成</font></td>

        </tr>

        <tr> 

          <td colspan="2"> 管理密码 ......<font color="#0000EE"> 身份确认，密码长度在12个字符以内，否则将不能注册</font></td>

        </tr>

        <tr> 

          <td colspan="2"> 主页地址 ...... <font color="#0000EE">用于精简页面地址输出，请填写真实地址如http://www.cx365.com/stat</font></td>

        </tr>

        <tr> 

          <td colspan="2"> 站点名称 ...... <font color="#0000EE">站点标题，中英文均可</font></td>

        </tr>

        <tr> 

          <td colspan="2"> 

            <hr noshade align="center" width="100%" size="1">

          </td>

        </tr>

<?



if($step==1) {



?>

        <tr>

          <td colspan="2"><font color="#FF0000"><b>&gt;</font><font color="#000000"> 配置用户数据</b></font></td>

        </tr>

        <tr> 

          <td colspan="2"> 

            <form name="stat_register" method="post" action="">

              <input type="hidden" name="step" value="2">

              <table width="40%" border="0" cellspacing="0" cellpadding="0" align="center">

                <tr> 

                  <td width="22%">用户名</td>

                  <td width="32%"> 

                    <div align="center"> 

                      <input type="text" name="user" class="input" onMouseOver ="this.style.backgroundColor='#F0F1FF'" onMouseOut ="this.style.backgroundColor=''">

                    </div>

                  </td>

                </tr>

                <tr> 

                  <td width="22%">管理密码</td>

                  <td width="32%"> 

                    <div align="center"> 

                      <input type="password" name="user_passwd" class="input" onMouseOver ="this.style.backgroundColor='#F0F1FF'" onMouseOut ="this.style.backgroundColor=''">

                    </div>

                  </td>

                </tr>

                <tr> 

                  <td width="22%">主页地址</td>

                  <td width="32%"> 

                    <div align="center"> 

                      <input type="text" name="user_base" class="input" onMouseOver ="this.style.backgroundColor='#F0F1FF'" onMouseOut ="this.style.backgroundColor=''">

                    </div>

                  </td>

                </tr>

                <tr> 

                  <td width="22%">站点名称</td>

                  <td width="32%"> 

                    <div align="center"> 

                      <input type="text" name="user_name" class="input" onMouseOver ="this.style.backgroundColor='#F0F1FF'" onMouseOut ="this.style.backgroundColor=''">

                    </div>

                  </td>

                </tr>

                <tr> 

                  <td colspan="3" height="15"> 

                    <div align="left"></div>

                  </td>

                </tr>

                <tr> 

                  <td colspan="3"> 

                    <div align="center"> 

                      <input type="submit" name="Submit" value="提交申请" class="button" onMouseOver ="this.style.backgroundColor='#EEF7FF'" onMouseOut ="this.style.backgroundColor=''" onMouseOver ="this.style.backgroundColor='#EEF7FF'" onMouseOut ="this.style.backgroundColor=''">

                      <input type="reset" name="Reset" value="重新填写" class="button" onMouseOver ="this.style.backgroundColor='#EEF7FF'" onMouseOut ="this.style.backgroundColor=''">

                    </div>

                  </td>

                </tr>

              </table>

            </form>

          </td>

        </tr>

<?



}

if($step==2) {



  echo"        <tr>\n";

  echo"          <td colspan=\"2\"><b><font color=\"#FF0000\">&gt;</font><font color=\"#000000\"> 注册信息合法性检查</b></font></td>\n";

  echo"        </tr>\n";



  $items2check=array($user,$user_passwd,$user_base,$user_name,"用户名","管理密码","主页地址","站点名称");

  if(strlen($user)<=8 and ereg("^[a-z0-9]+$",$user) and !is_dir("$config[data]/$user"))

    $result[0]=$correct;

  else {

    $result[0]=$incorrect;

    $error="用户名已经存在、含有非法字符或长度超过限制";

  }

  if($user_passwd and ereg("^[`~!@%^*_A-Za-z0-9-]+$",$user_passwd) and strlen($user_passwd)<=12)

    $result[1]=$correct;

  else {

    $result[1]=$incorrect;

    $error="管理密码空白、含有非法字符或其长度超过限制";

  }

  if(substr($user_base,0,7)=="http://")

    $result[2]=$correct;

  else {

    $result[2]=$incorrect;

    $error="主页地址应为小写\"http://\"开头的真实地址";

  }

  if($user_name and !ereg("\"|'",$user_name) and strlen($user_name)<=20)

    $result[3]=$correct;

  else {

    $result[3]=$incorrect;

    $error="站点名称含有非法字符或其长度超过限制";

  }

  for($i=0;$i<4;$i++) {

    echo"        <tr>\n";

    echo"          <td colspan=\"2\"> ".$items2check[$i+4]." <font color=\"black\">$items2check[$i]</font>$result[$i]";

  }

}



if(!$error and $step==2) {



?>

        <tr> 

          <td colspan="2"><font color="#FF0000"><b>&gt;</font><font color="#000000"> 初始化数据文件</b></font></td>

        </tr>

        <tr>

<?



  echo"        <tr>\n";

  echo"          <td colspan=\"2\">建立用户目录";

  $myurl="http://crossday.l4.bizcn.com/stat/userlog";

  if(@mkdir("$config[data]/$user",0777)) {

    @chmod("$config[data]/$user",0777);

    echo$correct;

  }else

    echo$incorrect;



  $items2check=array("agent","click","day","detail","hour","month","pageview","start");



  for($i=0;$i<7;$i++) {

    echo"        <tr>\n";

    echo"          <td colspan=\"2\">初始化 $items2check[$i].dat";

    $filename="$config[data]/$user/$items2check[$i].dat";

    $fp=@fopen($filename,"w");

    @flock($fp,3);

    if(@fwrite($fp," ")) {

      echo$correct;

    }else {

      echo$incorrect;

      $error="数据文件无法初始化，请联系管理员以获得技术支持";

    }

    @fclose($fp);

    @chmod($filename,0777);

  }

  echo"        <tr>\n";

  echo"          <td colspan=\"2\">初始化 start.dat";

  $fp=@fopen("$config[data]/$user/start.dat","w");

  @flock($fp,3);

  if(@fwrite($fp,((date("Y")-1)*365+date("z")-1).".date ".date("Y-m-d")))

    echo$correct;

  else

    echo$incorrect;

  @fclose($fp);

  @chmod("$config[data]/$user/start.dat",0777);

  

  echo"        <tr>\n";

  echo"          <td colspan=\"2\">初始化 config.inc.php";

  $fp=@fopen("$config[data]/$user/config.inc.php","w");

  @flock($fp,3);

  $fw="<?\n\$config[user_passwd]=\"$user_passwd\";\n\$config[user_base]=\"$user_base\";\n\$config[user_name]=\"$user_name\";\n?>";

  if(@fwrite($fp,$fw))

    echo$correct;

  else

    echo$incorrect;

  @fclose($fp);

  @chmod("$config[data]/$user/config.inc.php",0777);



}



if($step==2) {



?>

        <tr> 

          <td colspan="2"> 

            <hr noshade align="center" width="100%" size="1">

          </td>

        </tr>

        <tr>

          <td align="center" colspan="2">

<?



  if($error) {

    echo"              <b><font color=\"#FF0000\">创想统计  注册向导发现错误，".$error."。</font></b><br>\n";

    echo"              <a href=\"javascript:history.go(-1);\">请点这里返回上一页</a>\n";

  }else {

    echo"            <script src=\"$myurl/userlog.php?type=regist&note=url ".$user_base."\"></script>\n";

    echo"              <b><font color=\"#FF0000\">恭喜！您已经成功注册，您的用户名 <font color=\"#000000\">".$user."</font> 密码 <font color=\"#000000\">".$user_passwd."</font>，请牢记。</font></b>\n";



?>

          </td>

        </tr>

        <tr> 

          <td colspan="2"> 

            <hr noshade align="center" width="100%" size="1">

          </td>

        </tr>

<?



    $styles=array("counter","icon","text","null","计数器","图标","文本","隐藏");

    for($i=0;$i<4;$i++) {

      $code="<script>var user=\"$user\";var style=\"$styles[$i]\";var url=\"$config[url]\";</script><script src=\"$config[url]/stat.js\"></script>";

      $code=htmlspecialchars($code);

      echo"        <tr>\n";

      echo"          <td align=\"center\" width=\"65%\">\n";

      echo"            <b>$styles[$i](".$styles[$i+4].") 样式调用代码</b>\n";

      echo"          </td>\n";

      echo"          <td align=\"left\" width=\"35%\">\n";

      echo"            <input type=\"button\" name=\"btn_cc_".$styles[$i]."\" value=\"将代码复制到剪贴板\" class=\"button\" style=\"width: 120px\" onClick=JM_cc('".$styles[$i]."') onMouseOver =\"this.style.backgroundColor='#EEF7FF'\" onMouseOut =\"this.style.backgroundColor=''\"></b>\n";

      echo"          </td>\n";

      echo"        </tr>\n";

      echo"        <tr>\n";

      echo"          <td align=\"center\" colspan=\"2\">\n";

      echo"            <textarea name=\"".$styles[$i]."\" wrap=\"virtual\" rows=\"20\" strolling=\"no\" class=\"textarea\" style=\"width: 500px; height: 47px\" onMouseOver =\"this.style.backgroundColor='#F0F1FF'\" onMouseOut =\"this.style.backgroundColor=''\">$code</textarea>\n";

      echo"          </td>\n";

      echo"        </tr>\n";

      echo"        <tr>\n";

      echo"          <td height=\"15\" colspan=\"2\"></td>\n";

      echo"        </tr>\n";

    }

  }

}



?>

        <tr> 

          <td colspan="2">

            <hr noshade align="center" width="100%" size="1">

          </td>

        </tr>

        <tr> 

          <td align="center" colspan="2">

            免费统计服务提供：<b><?echo"<a href=\"$config[base]\" target=\"_blank\">$config[name]</a>";?></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;技术支持：<b><a href="http://WWW.CX365.COM" target=\"_blank\">WWW.CX365.COM</a></b>

          </td>

        </tr>

      </table>

    </td>

  </tr>

</table>

</body>

</html>