`
qvb3d
  • 浏览: 171570 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

自己写的一个php构架

    博客分类:
  • php
 
阅读更多

 

<?

header("Content-type:text/html; charset=utf-8");

session_start();

$sdate=date("Y-m-d G:i:s");

$ydate=date("Y");

$mdate=date("m");

$ydate=$ydate+0;

$mdate=$mdate+1;

if(($ydate>=2011)&&($mdate>7))

   {

    echo "<body bgcolor='#FF0000'><br><br><center><h1>Your Site has expired <br></h1>";

    echo "<h3>Please Phone contact by qvb3d</h3></center></body>";

    exit;

   } 

class sql

 {

   public $data;

   public $field;

   public $recno;

   public $total_num;

   public $exeupdate;

   public function sql($sql_cmd)

    {

     require("dbcon.php");

     $xutf8=mysql_query("SET NAMES utf8",$sql_conn);

     $this->data=mysql_query($sql_cmd,$sql_conn);

     $this->exeupdate=0;

     if (empty($this->data)) 

       {

       $this->recno=0;

       $this->total_num=0;

       return ;

       }

     if ((strlen(strstr($sql_cmd,"select"))==0)&&(strlen(strstr($sql_cmd,"show"))==0))

       {

       $this->exeupdate=1;

       $this->recno=0;

       $this->total_num=0;

       return ;

       }

     $this->total_num=mysql_num_rows($this->data);  

     $this->recno=1;

     $this->gotorow(1);

     mysql_close($sql_conn);

    }

   public function recno()

    {

    return $this->recno;

    }

   public function gotorow($row_line)

    {

    if($row_line<1)  return 0;

    if(($row_line>$this->total_num)||($this->total_num<1)) 

       {

       return 0;

       }

    if($this->total_num==1)

       {

        $this->field=mysql_fetch_array($this->data);

   //    print_r($this->field);

        return $this->field;

       }

        mysql_data_seek($this->data,$row_line-1);

        $this->field=mysql_fetch_array($this->data);

        $this->recno=$row_line;

       return $this->field;

    }

   public function first()

    {

 

         mysql_data_seek($this->data,0);

         $this->field=mysql_fetch_array($this->data);

         $this->recno=1; 

    } 

   public function last()

    {

        mysql_data_seek($this->data,$this->total_num-1);

        $this->field=mysql_fetch_array($this->data);

        $this->recno=$this->total_num;

    } 

   public function next()

    {

 

        if($this->total_num==$this->recno)

           {

           mysql_data_seek($this->data,$this->total_num-1);

           $this->field=mysql_fetch_array($this->data);

           return;

           }

        $this->field=mysql_fetch_array($this->data);

        $this->recno=$this->recno+1;

    }

   public function previous()

   {

       if($this->recno==1)

         {

         mysql_data_seek($this->data,0);

         $this->field=mysql_fetch_array($this->data);

         return;

         } 

       mysql_data_seek($this->data,$this->recno-2);

       $this->field=mysql_fetch_array($this->data);

       $this->recno=$this->recno-1;

    }

   public function rest()

    {

     mysql_data_seek($this->data,0);

     $this->field=mysql_fetch_array($this->data);

     $this->recno=1;

    }

   public function bof()

    {

    if($this->recno==1)  return 1;

    else return 0;

    }

   public function eof()

    {

    if($this->total_num==$this->recno) return 1;

    else return 0;

    }

   public function total_cols()

    {

    if (empty($this->data)) return 0;

    return mysql_num_fields($this->data);

    }

 }

 class datagrid_mod

 {

 function __construct($sqldata,$fontsize,$twidth,$url1,$action1,$name1,$value1,$name2,$value2)

    {

    $field_col=array();

    $total_cols=$sqldata->total_cols();

    for($i=0;$i<$total_cols;$i++)

       {

       $field_col[$i]=mysql_fetch_field($sqldata->data,$i)->name;

       }

    if(file_exists($url1)&&!empty($action1)&&!empty($name1)&&!empty($name2)&&!empty($sqldata->field["id"])&&!empty($value1)&&!empty($value2))

       {

       $field_col[$i]='备注';

       }   

    echo "\n<style type='text/css'>";

    echo "\n<!--";

    echo "\n.dborder {";

    echo "\nfont-size: ".$fontsize."px;";

echo "\nborder-top-width: 1px;";

echo "\nborder-right-width: 1px;";

echo "\nborder-bottom-width: 1px;";

echo "\nborder-left-width: 1px;";

echo "\nborder-top-style: solid;";

echo "\nborder-right-style: solid;";

echo "\nborder-bottom-style: solid;";

echo "\nborder-left-style: solid;";

echo "\nborder-top-color: #CBCBCB;";

echo "\nborder-right-color: #555555;";

echo "\nborder-bottom-color: #555555;";

echo "\nborder-left-color: #CBCBCB;";

    echo "\n}";

    echo "\n.dborder1 {";

echo "\nfont-size: ".$fontsize."px;";

echo "\nborder-top-width: 1px;";

echo "\nborder-right-width: 1px;";

echo "\nborder-bottom-width: 1px;";

echo "\nborder-left-width: 1px;";

echo "\nborder-top-style: solid;";

echo "\nborder-right-style: solid;";

echo "\nborder-bottom-style: solid;";

echo "\nborder-left-style: solid;";

echo "\nborder-top-color: #000000;";

echo "\nborder-right-color: #000000;";

echo "\nborder-bottom-color: #000000;";

echo "\nborder-left-color: #000000;";

    echo "\n}";

    echo "\n.dborder2 {";

echo "\nfont-size: ".$fontsize."px;";

echo "\nborder-top-width: 1px;";

echo "\nborder-right-width: 1px;";

echo "\nborder-bottom-width: 1px;";

echo "\nborder-left-width: 1px;";

echo "\nborder-top-style: none;";

echo "\nborder-right-style: solid;";

echo "\nborder-bottom-style: solid;";

echo "\nborder-left-style: solid;";

echo "\nborder-top-color: #000000;";

echo "\nborder-right-color: #000000;";

echo "\nborder-bottom-color: #000000;";

echo "\nborder-left-color: #000000;";

    echo "\n}";

    echo "\n.dborder3 {";

echo "\nfont-size: ".$fontsize."px;";

echo "\nborder-top-width: 1px;";

echo "\nborder-right-width: 1px;";

echo "\nborder-bottom-width: 1px;";

echo "\nborder-left-width: 1px;";

echo "\nborder-top-style: none;";

echo "\nborder-right-style: solid;";

echo "\nborder-bottom-style: solid;";

echo "\nborder-left-style: none;";

echo "\nborder-top-color: #000000;";

echo "\nborder-right-color: #000000;";

echo "\nborder-bottom-color: #000000;";

echo "\nborder-left-color: #000000;";

    echo "\n}\n";

    echo "\n-->";

    echo "\n</style>\n";

 

    echo "<table border='0' cellpadding='0.5' cellspacing='0.5' width=".$twidth." >";

    echo "\n<tr bgcolor='#CFCFCF' align='center'>";

    for($i=0;$i<$total_cols;$i++)

       {

       echo "\n<td ";

       if($i==0) echo "class='dborder'";

       else echo "class='dborder'"; 

       echo ">";

       echo $field_col[$i];

       echo "\n</td>";

       }

if(file_exists($url1)&&!empty($action1)&&!empty($name1)&&!empty($name2)&&!empty($sqldata->field["id"])&&!empty($value1)&&!empty($value2))

       {

       echo "\n<td class='dborder'>".$field_col[$i]."</td>\n";

       }

    echo "\n</tr>";

    if($sqldata->total_num==0) 

      {

      echo "\n</table>";

      return ;

      }  

      $sqldata->rest();

      echo "\n<tr bgcolor='#FAFAFA' align='center'>";

      for($i=0;$i<$total_cols;$i++)

         {

         echo "\n<td ";

         if($i==0) echo "class='dborder2'";

         else echo "class='dborder3'"; 

         echo ">&nbsp;";

         echo $sqldata->field[$i];

         echo "&nbsp;\n</td>";

          }

if(file_exists($url1)&&!empty($action1)&&!empty($name1)&&!empty($name2)&&!empty($sqldata->field["id"])&&!empty($value1)&&!empty($value2))

         {

         echo "\n<td ";

         if($i==0) echo "class='dborder2'";

         else echo "class='dborder3'";

         echo "><a href='".$url1."?".$action1."=".$name1."&id=".$sqldata->field["id"]."' >".$value1."</a>&nbsp;&nbsp;|&nbsp;&nbsp;";

echo "<a href='".$url1."?".$action1."=".$name2."&id=".$sqldata->field["id"]."'>".$value2."</a>";         

         echo "</td>\n";

          } 

      echo "\n</tr>";

    while($field_data=mysql_fetch_array($sqldata->data))

       {

       echo "\n<tr bgcolor='#FAFAFA' align='center'>";

       for($i=0;$i<$total_cols;$i++)

         {

         echo "\n<td ";

         if($i==0) echo "class='dborder2'";

         else echo "class='dborder3'"; 

         echo ">&nbsp;";

         echo $field_data[$i];

         echo "&nbsp;\n</td>";

         }             

if(file_exists($url1)&&!empty($action1)&&!empty($name1)&&!empty($name2)&&!empty($value1)&&!empty($value2)&&!empty($field_data["id"]))

  {

           echo "\n<td ";

           if($i==0) echo "class='dborder2'";

           else echo "class='dborder3'";

         echo "><a href='".$url1."?".$action1."=".$name1."&id=".$field_data["id"]."'>".$value1."</a>&nbsp;&nbsp;|&nbsp;&nbsp;";

echo "<a href='".$url1."?".$action1."=".$name2."&id=".$field_data["id"]."'>".$value2."</a>";           

  echo "</td>\n";

             }

       echo "\n</tr>"; 

       }

    echo "\n</table>";

 

   $sqldata->rest();

 

    }

   function __destruct()

     {

     echo "";

     }

 }

 

  class datagrid

 {

 function __construct($sqldata,$fontsize,$twidth,$url1,$key1,$de)

    {

    $field_col=array();

    $total_cols=$sqldata->total_cols();

    for($i=0;$i<$total_cols;$i++)

       {

       $field_col[$i]=mysql_fetch_field($sqldata->data,$i)->name;

       }

    if(file_exists($url1)&&!empty($key1)&&!empty($url1)&&!empty($sqldata->field[$key1]))

       {

       $field_col[$i]='备注';

       }   

    echo "\n<style type='text/css'>";

    echo "\n<!--";

    echo "\n.dborder {";

    echo "\nfont-size: ".$fontsize."px;";

echo "\nborder-top-width: 1px;";

echo "\nborder-right-width: 1px;";

echo "\nborder-bottom-width: 1px;";

echo "\nborder-left-width: 1px;";

echo "\nborder-top-style: solid;";

echo "\nborder-right-style: solid;";

echo "\nborder-bottom-style: solid;";

echo "\nborder-left-style: solid;";

echo "\nborder-top-color: #CBCBCB;";

echo "\nborder-right-color: #555555;";

echo "\nborder-bottom-color: #555555;";

echo "\nborder-left-color: #CBCBCB;";

    echo "\n}";

    echo "\n.dborder1 {";

echo "\nfont-size: ".$fontsize."px;";

echo "\nborder-top-width: 1px;";

echo "\nborder-right-width: 1px;";

echo "\nborder-bottom-width: 1px;";

echo "\nborder-left-width: 1px;";

echo "\nborder-top-style: solid;";

echo "\nborder-right-style: solid;";

echo "\nborder-bottom-style: solid;";

echo "\nborder-left-style: solid;";

echo "\nborder-top-color: #000000;";

echo "\nborder-right-color: #000000;";

echo "\nborder-bottom-color: #000000;";

echo "\nborder-left-color: #000000;";

    echo "\n}";

    echo "\n.dborder2 {";

echo "\nfont-size: ".$fontsize."px;";

echo "\nborder-top-width: 1px;";

echo "\nborder-right-width: 1px;";

echo "\nborder-bottom-width: 1px;";

echo "\nborder-left-width: 1px;";

echo "\nborder-top-style: none;";

echo "\nborder-right-style: solid;";

echo "\nborder-bottom-style: solid;";

echo "\nborder-left-style: solid;";

echo "\nborder-top-color: #000000;";

echo "\nborder-right-color: #000000;";

echo "\nborder-bottom-color: #000000;";

echo "\nborder-left-color: #000000;";

    echo "\n}";

    echo "\n.dborder3 {";

echo "\nfont-size: ".$fontsize."px;";

echo "\nborder-top-width: 1px;";

echo "\nborder-right-width: 1px;";

echo "\nborder-bottom-width: 1px;";

echo "\nborder-left-width: 1px;";

echo "\nborder-top-style: none;";

echo "\nborder-right-style: solid;";

echo "\nborder-bottom-style: solid;";

echo "\nborder-left-style: none;";

echo "\nborder-top-color: #000000;";

echo "\nborder-right-color: #000000;";

echo "\nborder-bottom-color: #000000;";

echo "\nborder-left-color: #000000;";

    echo "\n}\n";

    echo "\n-->";

    echo "\n</style>\n";

 

    echo "<table border='0' cellpadding='0.5' cellspacing='0.5' width=".$twidth." >";

    echo "\n<tr bgcolor='#CFCFCF' align='center'>";

    for($i=0;$i<$total_cols;$i++)

       {

       echo "\n<td ";

       if($i==0) echo "class='dborder'";

       else echo "class='dborder'"; 

       echo ">";

       echo $field_col[$i];

       echo "\n</td>";

       }

       if(file_exists($url1)&&!empty($key1)&&!empty($url1)&&!empty($sqldata->field[$key1]))

       {

       echo "\n<td class='dborder'>".$field_col[$i]."</td>\n";

       }

    echo "\n</tr>";

    if($sqldata->total_num==0) 

      {

      echo "\n</table>";

      return ;

      }  

      $sqldata->rest();

      echo "\n<tr bgcolor='#FAFAFA' align='center'>";

      for($i=0;$i<$total_cols;$i++)

         {

         echo "\n<td ";

         if($i==0) echo "class='dborder2'";

         else echo "class='dborder3'"; 

         echo ">&nbsp;";

         echo $sqldata->field[$i];

         echo "&nbsp;\n</td>";

          }

         if(file_exists($url1)&&!empty($key1)&&!empty($url1)&&!empty($sqldata->field[$key1]))

         {

         echo "\n<td ";

         if($i==0) echo "class='dborder2'";

         else echo "class='dborder3'";

         echo "><a href='".$url1."?".$key1."=".$sqldata->field[$key1]."' target='_blank'><img src='img/show_data.gif' alt='".$de."'></a></td>\n";

          } 

      echo "\n</tr>";

    while($field_data=mysql_fetch_array($sqldata->data))

       {

       echo "\n<tr bgcolor='#FAFAFA' align='center'>";

       for($i=0;$i<$total_cols;$i++)

         {

         echo "\n<td ";

         if($i==0) echo "class='dborder2'";

         else echo "class='dborder3'"; 

         echo ">&nbsp;";

         echo $field_data[$i];

         echo "&nbsp;\n</td>";

         }

         if(file_exists($url1)&&!empty($key1)&&!empty($url1)&&!empty($field_data[$key1]))

           {

           echo "\n<td ";

           if($i==0) echo "class='dborder2'";

           else echo "class='dborder3'";

           echo "><a href='".$url1."?".$key1."=".$field_data[$key1]."' target='_blank'><img src='img/show_data.gif' alt='".$de."'></a></td>\n";

             }

       echo "\n</tr>"; 

       }

    echo "\n</table>";

 

   $sqldata->rest();

 

    }

   function __destruct()

     {

     echo "";

     }

 }

 

 

class login_window

{

public $window_name;

public $user_name;

public $user_pwd;

public $user_verify;

public $user_action;

public function login_window($w_name,$u_name,$u_pwd,$u_verify,$u_action)

{

$this->window_name=$w_name;

$this->user_name=$u_name;

$this->user_pwd=$u_pwd;

$this->user_verify=$u_verify;

$this->user_action=$u_action;

echo "<style type='text/css'>\n";

    echo ".login_border {\n";

echo "border: 1px solid #000;\n";

echo "font-size: 12px;\n";

echo "color: #000;\n";

    echo " }\n";

    echo "</style>\n";

    echo "<table  align='center' width='420 height='140 class='login_border' cellspacing='0' cellspacing='0' bgcolor='#EEEEEE'>\n";

    echo "<form id='form1' name='form1' method='post' action='";

    echo $this->user_action;

    echo "'>\n";

    echo "<tr height='30' algin='center' background='../images/tabletitle2.png'>\n";

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

    echo "<font color='#000000'><b>";

    echo $this->window_name;

    echo "</b></font>";

    echo "</td>\n";

    echo "</tr>\n";

    echo "<tr height='30' algin='center' >\n";

    echo "<td width='100'>&nbsp;</td><td>&nbsp;</td>\n";

    echo "</tr>\n";

    echo "<tr height='30' algin='center' >\n";

    echo "<td align='center'>\n";

    echo "用户名:</td><td><input name='";

    echo $this->user_name;

    echo "' type='text' size='41' class='login_border'>\n";

    echo "</td>\n";

    echo "</tr>\n";

    echo "<tr height='30' algin='center'>\n";

    echo "<td align='center'>密&nbsp;&nbsp;&nbsp;码:</td>\n";

    echo "<td><input name='";

    echo $this->user_pwd;

    echo "' type='password' size='42' class='login_border'><br>\n";

    echo "</td>\n";

    echo "</tr>\n";

    echo "<tr height='30'>\n";

    echo "<td algin='center' width='100'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码:</td>\n";

    echo "<td>\n";

    echo "<script language='javascript'>\n";

    echo "function reloadcode()\n";

    echo "{\n";

    echo "document.getElementById('safecode').src='verifycode.php?'+Math.random();\n";

    echo "}\n";

    echo "</script>\n";

    echo "<table border='0' cellpadding='0' cellspacing='0'>\n";

    echo "<tr>\n";

    echo "<td><input name='";

    echo $this->user_verify;

    echo "' type='text' class='login_border' size='8'> &nbsp;&nbsp;\n";

    echo "</td>\n";

    echo "<td><a href='javascript:reloadcode();'><img src='verifycode.php?p=<? echo rand();?>' alt='看不清,请换一张' id='safecode' width='80' height='25' ></a></td>\n";

    echo "</tr>\n";

    echo "</table>\n";

    echo "</td>\n";

    echo "</tr>\n";

    echo "<tr>\n";

    echo "<td>&nbsp;</td>\n";

    echo "<td height='60' algin='right'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n";

    echo "<input type='submit' name='usr_submitbu1' value='登 录' class='login_border'>&nbsp;\n";

    echo "<input type='button' name='usr_submitbu2' value='关 闭' class='login_border' onClick='javascript:window.close();'>";

    echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n";

    echo "</td>\n";

    echo "</tr>\n";

    echo "</form>\n";

    echo "</table>\n";

   }

 }

class safe_url

{

public function check($_test,$s_url)

 {

// 防注入函数

  $regsql=array("declare","select","and ","or ","insert","union","update","delete","backup","exec","truacate","load_file",".cif","cmd.exe","command.exe","drop","eval","dir");

  $regnum=count($regsql);

  while (list($key,$value)=each($_test))

  {

  for($i=0;$i<$regnum;$i++)

    {

   if ((strlen(strstr($value,$regsql[$i])))>1)

       {

        echo "<script language='javascript'> alert('Error,Don\'t Use SQL syntax,Example select dir cmd.exe......')\n window.location='";

        echo $s_url;

        echo "'\n</script>";

   exit;

        }

 if (strlen(strstr(strtoupper($value),strtoupper($regsql[$i])))>1)

       {

        echo "<script language='javascript'> alert('Error,Don\'t Use SQL syntax,or Case cmd Example select dir cmd.exe......')\n window.location='";

        echo $s_url;

        echo "'\n</script>";

   exit;

       }

     }

   }

 }

//检查Post request get 所提交的变量

public function safe_url($re_url)

 {

  $this->check($_POST,$re_url);

  $this->check($_REQUEST,$re_url);

  $this->check($_GET,$re_url);

  }

}

 

class qmenu

{

public function qmenu($setconf)

   {

 

  $menu_page=$_GET["menu_page"];

  if(empty($menu_page))

    {

    $menu_page="0|#A2";

    }

  $iname=1;

  $treefile=$setconf;

  $script       = $SCRIPT_NAME;

 

  $img_expand   = "img/folder.gif";    //可展开图片

  // <img src='imgage/tree_expand.gif'>

  $img_collapse = "img/folder1.gif";  //可收缩图片

  //  imgage/tree_collapse.gif

  $img_line     = "img/tree_vertline.gif";  //直线图片

  $img_split = "img/tree_split.gif";     //分杈图片

  $img_end      = "img/tree_end.gif";       //树结

  $img_leaf     = "img/tree_leaf.gif";      //树叶

  $img_spc      = "img/tree_space.gif";     //空白图片

 

  /*********************************************/

  /*  丛树结构文件中读出内容                   */

  /*********************************************/

 

  /*********************************************/

  /* 数组变量$tree                             */

  /* tree[x][0] -> tree level   层             */

  /* tree[x][1] -> item text    条目名称       */

  /* tree[x][2] -> item link    条目连接       */

  /* tree[x][3] -> link target  连接目标       */

  /* tree[x][4] -> last item in subtree        */

  /*********************************************/

 

  $maxlevel=0;

  $cnt=0;

 

  $fd = fopen($treefile, "r");

  if ($fd==0) die("Unable to open file ".$treefile);

 

  while ($buffer = fgets($fd, 4096)) 

  {

    $tree[$cnt][0]=strspn($buffer,".");

    $tmp=rtrim(substr($buffer,$tree[$cnt][0]));

    $node=explode("|",$tmp); 

    $tree[$cnt][1]=$node[0];

    $tree[$cnt][2]=$node[1];

    $tree[$cnt][3]=$node[2];

    $tree[$cnt][4]=0;

    if ($tree[$cnt][0] > $maxlevel) $maxlevel=$tree[$cnt][0];    

    $cnt++;

  }

  fclose($fd);

 

  for ($i=0; $i<count($tree); $i++) {

     $expand[$i]=0;

     $visible[$i]=0;

     $levels[$i]=0;

  }

 

  /*********************************************/

  /*  得到节点数                               */

  /*********************************************/

 

  if ($menu_page!="") $explevels = explode("|",$menu_page);

 

  $i=0;

  while($i<count($explevels))

  {

    $expand[$explevels[$i]]=1;

    $i++;

  }

 

  /*********************************************/

  /*  找到最后一个下一级结点                   */

  /*********************************************/

 

  $lastlevel=$maxlevel;

  for ($i=count($tree)-1; $i>=0; $i--)

  {

     if ( $tree[$i][0] < $lastlevel )

     {

       for ($j=$tree[$i][0]+1; $j <= $maxlevel; $j++)

       {

          $levels[$j]=0;

       }

     }

     if ( $levels[$tree[$i][0]]==0 )

     {

       $levels[$tree[$i][0]]=1;

       $tree[$i][4]=1;

     }

     else

       $tree[$i][4]=0;

     $lastlevel=$tree[$i][0];  

  }

 

 

  /*********************************************/

  /*  判定可视结点                             */

  /*********************************************/

 

  $visible[0]=1;   // root is always visible

  for ($i=0; $i<count($explevels); $i++)

  {

    $n=$explevels[$i];

    if ( ($visible[$n]==1) && ($expand[$n]==1) )

    {

       $j=$n+1;

       while ( $tree[$j][0] > $tree[$n][0] )

       {

         if ($tree[$j][0]==$tree[$n][0]+1) $visible[$j]=1;     

         $j++;

       }

    }

  }

 

 

  /*********************************************/

  /*  Output nicely formatted tree             */

  /*********************************************/

 

  for ($i=0; $i<$maxlevel; $i++) $levels[$i]=1;

 

  $maxlevel++;

  ?>

<table border="0" cellpadding="0" cellspacing="0" width='170' height="30">

<tr><td class="hborderup" ><img src='img/gr_back.gif'></td>

</tr>

</table>

  <?

  echo "<table cellspacing=0 cellpadding=0 border=0 cols=".($maxlevel+3)." width=".($maxlevel*16+120)." class='hborderup' bgcolor='".$control."'>\n";

  echo "<tr>";

  for ($i=0; $i<$maxlevel; $i++) echo "<td width=16></td>";

  echo "<td width=100></td></tr>\n";

  $cnt=0;

  while ($cnt<count($tree))

  {

    if ($visible[$cnt])

    {

      /****************************************/

      /* 开始新的一 行                        */

      /****************************************/      

 $iname++;

      echo "<tr>";

      echo "<a name=\"A".$iname."\" id=\"A".$iname."\"></a> ";

      /****************************************/

      /* 来自较高一层的树直线                 */

      /****************************************/

      $i=0;

      while ($i<$tree[$cnt][0]-1) 

      {

        if ($levels[$i]==1)

            echo "<td><img src=\"".$img_line."\"></td>";

        else

            echo "<td><img src=\"".$img_spc."\"></td>";

        $i++;

      }

 

      /****************************************/

      /*下一级结点                            */

      /****************************************/         

      if ($tree[$cnt][4]==1) 

      {

        echo "<td><img src=\"".$img_end."\"></td>";

        $levels[$tree[$cnt][0]-1]=0;

      }

      else

      {

        echo "<td><img src=\"".$img_split."\"></td>";                  

        $levels[$tree[$cnt][0]-1]=1;    

      } 

 

      /********************************************/

      /* 节点(有下一级)或树叶 (无下一级)          */

      /********************************************/

      if ($tree[$cnt+1][0]>$tree[$cnt][0])

      {

 

        /****************************************/

        /* 生成展开或收缩参数                   */

        /****************************************/

        $i=0; $params="?menu_page=";

        while($i<count($expand))

        {

          if ( ($expand[$i]==1) && ($cnt!=$i) || ($expand[$i]==0 && $cnt==$i))

          {

            $params=$params.$i;

            $params=$params."|";

          }

          $i++;

        }

 

        if ($expand[$cnt]==0)

            echo "<td><a href=\"".$script.$params."#A".$iname."\"><img src=\"".$img_expand."\" border=no></a></td>";

        else

            echo "<td><a href=\"".$script.$params."#A".$iname."\"><img src=\"".$img_collapse."\" border=no></a></td>";         

      }

      else

      {

        /*************************/

        /* 树叶                  */

        /*************************/

 

        echo "<td><img src=\"".$img_leaf."\"></td>";         

      }

 

      /****************************************/

      /* 输出条目名称                         */

      /****************************************/

      if ($tree[$cnt][2]=="")

          echo "<td colspan=".($maxlevel-$tree[$cnt][0])."><a href=\"".$script.$params."#A".$iname."\">".$tree[$cnt][1]."</a></td>";

      else

          echo "<td colspan=".($maxlevel-$tree[$cnt][0])."><a href=\"".$tree[$cnt][2]."\" target=\"".$tree[$cnt][3]."\">".$tree[$cnt][1]."</a></td>";

 

      /****************************************/

      /* 结束行                               */

      /****************************************/

 

      echo "</tr>\n";      

     }

     $cnt++;    

   }

  echo "</table>\n";

  }

}

class change_icon

{

public function change_icon($icon_str)

     {

     echo "<link REL='Shortcut Icon' href='";

     echo $icon_str;

     echo "'>";

     }

}

class goto_url

{

public function goto_url($g_url)

    {

    echo "<script language='javascript'>window.parent.location='";

        echo $g_url;

        echo "';\n</script>";

    }

}

function check_verify($v_str)

 {

 if(strtoupper($_SESSION["qvb_verify"])==strtoupper($v_str))

   {

   return 1;

   }

 else return 0; 

 }

function msg($str1)

{

echo "<script language='javascript'>\n";

echo "alert('".$str1."')\n";

echo "</script>\n";

}

 

 

function regstr($source)

{

  $tmp_h=array();

  $ch_count=0;

  $j=0;

  for($i=0;$i<strlen($source);$i++)

    {

       if($source[$i]=="\r") 

         {

          $source[$i]=" ";

         } 

    }

 

  for($i=0;$i<strlen($source);$i++)

    {

       if($source[$i]=="\n") 

         {

         $ch_count++;

         $tmp_h[$j]=$i;

         $j++;

         } 

    }

  $tmp_i=array();

  for($i=0;$i<$ch_count;$i++)

    {

      if ($i==0) 

        {

        $tmp_i[$i]=substr($source,0,$tmp_h[$i]);

        }

      else

       {

       $tmp_i[$i]=substr($source,$tmp_h[$i-1]+1,($tmp_h[$i]-$tmp_h[$i-1]-1));

       }

    }

   return $tmp_i;

}

function checkeid($seid)

{

  $expr="0123456789";

  for($i=0;$i<strlen($seid);$i++)

      {

        $pd=strstr($expr,$seid[$i]);

        if($pd==FALSE) return -1;

      }

  if(strlen($seid)!=16) return -2;

  return 1;

}

 

function char_check($str)

{

  $expr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_";

  for($i=0;$i<strlen($str);$i++)

    {

    $r=strstr($expr,$str[$i]);

      if(($i==0)&&($str[$i]>="0")&&($str[$i]<="9"))

        {

        return -1;

        }

      if($r==FALSE)

        {

         return -1;   

        }

     }

  return 1;  

}

 

function array_str($arr_str)

{

  $ex=array();

  for($i=0;$i<count($arr_str);$i++)

    {

     for($j=0;$j<strlen($arr_str[$i]);$j++)

        {

          if(($arr_str[$i][$j]=="=")&&($j>0))

            {

              if (char_check(substr($arr_str[$i],0,$j))==1)

               {

               $ex+=array(substr($arr_str[$i],0,$j)=>substr($arr_str[$i],$j+1));         

               $ex+=array($i=>substr($arr_str[$i],$j+1));         

               }

          //$exmple=array("valuename"=>500);

          //echo $exmple["valuename"];

             }

         }

     }

  return $ex;  

}

 

function do_me($input,$key)

{

//  $iv=mcrypt_create_iv(mcrypt_get_iv_size(mcrypt_module_open(MCRYPT_DES,'',MCRYPT_MODE_ECB,MCRYPT_RAND)));

  $iv=mcrypt_create_iv(mcrypt_get_iv_size('des','ecb'));

  $pass=mcrypt_encrypt(MCRYPT_DES,$key,$input,MCRYPT_MODE_ECB,$iv);

  $encode=bintostr($pass);

  return $encode;

}

function bintostr($pbin)

{

  $len=strlen($pbin);

  $rel="";

  for($i=0;$i<$len;$i++)

   {

    $tm=substr($pbin,$i,1); 

    $tmp=ord($tm);

    $left1=$tmp&0x0F;

    $left2=($tmp>>4)&0x0F;

    if($left1==0x0000) $str1="0";

    if($left1==0x0001) $str1="1";

    if($left1==0x0002) $str1="2";

    if($left1==0x0003) $str1="3";

    if($left1==0x0004) $str1="4";

    if($left1==0x0005) $str1="5";

    if($left1==0x0006) $str1="6";

    if($left1==0x0007) $str1="7";

    if($left1==0x0008) $str1="8";

    if($left1==0x0009) $str1="9";

    if($left1==0x000A) $str1="A";

    if($left1==0x000B) $str1="B";

    if($left1==0x000C) $str1="C";

    if($left1==0x000D) $str1="D";

    if($left1==0x000E) $str1="E";

    if($left1==0x000F) $str1="F";

 

    if($left2==0x0000) $str2="0";

    if($left2==0x0001) $str2="1";

    if($left2==0x0002) $str2="2";

    if($left2==0x0003) $str2="3";

    if($left2==0x0004) $str2="4";

    if($left2==0x0005) $str2="5";

    if($left2==0x0006) $str2="6";

    if($left2==0x0007) $str2="7";

    if($left2==0x0008) $str2="8";

    if($left2==0x0009) $str2="9";

    if($left2==0x000A) $str2="A";

    if($left2==0x000B) $str2="B";

    if($left2==0x000C) $str2="C";

    if($left2==0x000D) $str2="D";

    if($left2==0x000E) $str2="E";

    if($left2==0x000F) $str2="F";

 

    $str3=$str2.$str1;

    $rel=$rel.$str3;

   }

return $rel; 

}

function do_md($input,$key)

{

  $len=strlen($input);

  if(fmod($len,2)!=0)

    {

   // echo "String length is error";

return 0xFF01;

    }

  for($i=0;$i<$len;$i++)

    {

    $tmp=substr($input,$i,1);

    $r=strstr("0123456789ABCDEF",$tmp);

      if ($r==FALSE) 

        {

    //    echo "\nString in ".($i+1);

    //    echo " not hex char";

   return (0xFF00+$i+1);

        }

    }  

  $decode=strtohex($input);

 // $iv=mcrypt_create_iv(mcrypt_get_iv_size(mcrypt_module_open(MCRYPT_DES,'',MCRYPT_MODE_ECB,MCRYPT_RAND)));

 $iv=mcrypt_create_iv(mcrypt_get_iv_size('des','ecb'));

 $pass=mcrypt_decrypt(MCRYPT_DES,$key,$decode,MCRYPT_MODE_ECB,$iv);

  return $pass;

}

function chtohex($str)

{

if(strlen($str)!=2)

{

// echo "String length is error";

return 0xFF05;

}

    $s1=substr($str,0,1);

    $s2=substr($str,1,1);

    $r=1;

    $r=strstr("0123456789ABCDEF",$s1);

    if ($r==FALSE) 

      {

    //  echo "String is error text1";

 return 0xFF02;

      }

    $r=strstr("0123456789ABCDEF",$s2);

    if ($r==FALSE) 

      {

    //  echo "String is error text2";

 return 0xFF03;

      }

 

    $result=0x00;

    $s3=0x00;

    if($s1=="0")  $result=0x00;

    if($s1=="1")  $result=0x10;

    if($s1=="2")  $result=0x20;

    if($s1=="3")  $result=0x30;

    if($s1=="4")  $result=0x40;

    if($s1=="5")  $result=0x50;

    if($s1=="6")  $result=0x60;

    if($s1=="7")  $result=0x70;

    if($s1=="8")  $result=0x80;

    if($s1=="9")  $result=0x90;

    if($s1=="A")  $result=0xA0;

    if($s1=="B")  $result=0xB0;

    if($s1=="C")  $result=0xC0;

    if($s1=="D")  $result=0xD0;

    if($s1=="E")  $result=0xE0;

    if($s1=="F")  $result=0xF0;

 

    if($s2=="0")  $s3=0x00;

    if($s2=="1")  $s3=0x01;

    if($s2=="2")  $s3=0x02;

    if($s2=="3")  $s3=0x03;

    if($s2=="4")  $s3=0x04;

    if($s2=="5")  $s3=0x05;

    if($s2=="6")  $s3=0x06;

    if($s2=="7")  $s3=0x07;

    if($s2=="8")  $s3=0x08;

    if($s2=="9")  $s3=0x09;

    if($s2=="A")  $s3=0x0A;

    if($s2=="B")  $s3=0x0B;

    if($s2=="C")  $s3=0x0C;

    if($s2=="D")  $s3=0x0D;

    if($s2=="E")  $s3=0x0E;

    if($s2=="F")  $s3=0x0F;

 

    // $result=$result<<4;

    $result=$result+$s3;

    return chr($result);

}

function strtohex($strh)

{

  $len=strlen($strh);

  if(fmod($len,2)!=0)

    {

  //  echo "String length is error";

return 0xFF01;

    }

  $tmp=substr($strh,0,2);

  $re=chtohex($tmp);

  for($i=2;$i<=($len-2);$i=$i+2)

    {

    $tmp=substr($strh,$i,2);

    $re=$re.chtohex($tmp);

    }

  return $re;  

}

?>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics