欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

自个儿写的一个php构架

程序员文章站 2024-02-04 08:34:46
...
自己写的一个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 "



Your Site has expired

";

? ? echo "

Please Phone contact by qvb3d

";

? ? 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

? ? if(($row_line>$this->total_num)||($this->total_num

? ? ? ?{

? ? ? ?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

? ? ? ?{

? ? ? ?$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

? ? echo "\n";

? ? echo "\n\n";

?

? ? echo "

";

? ? echo "\n

";

? ? for($i=0;$i

? ? ? ?{

? ? ? ?echo "\n

";

? ? ? ?}

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

? ? ? ?{

? ? ? ?echo "\n

\n";

? ? ? ?}

? ? echo "\n

";

? ? if($sqldata->total_num==0)?

? ? ? {

? ? ? echo "\n

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

? ? ? ?else echo "class='dborder'";?

? ? ? ?echo ">";

? ? ? ?echo $field_col[$i];

? ? ? ?echo "\n

".$field_col[$i]."
";

? ? ? return ;

? ? ? } ?

? ? ? $sqldata->rest();

? ? ? echo "\n

";

? ? ? for($i=0;$i

? ? ? ? ?{

? ? ? ? ?echo "\n

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

? ? ? ? ?else echo "class='dborder3'";?

? ? ? ? ?echo "> ";

? ? ? ? ?echo $sqldata->field[$i];

? ? ? ? ?echo " \n

";

? ? ? ? ? }

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

? ? ? ? ?{

? ? ? ? ?echo "\n

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

? ? ? ? ?else echo "class='dborder3'";

? ? ? ? ?echo ">".$value1." | ";

echo "".$value2.""; ? ? ? ??

? ? ? ? ?echo "

\n";

? ? ? ? ? }?

? ? ? echo "\n

";

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

? ? ? ?{

? ? ? ?echo "\n

";

? ? ? ?for($i=0;$i

? ? ? ? ?{

? ? ? ? ?echo "\n

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

? ? ? ? ?else echo "class='dborder3'";?

? ? ? ? ?echo "> ";

? ? ? ? ?echo $field_data[$i];

? ? ? ? ?echo " \n

";

? ? ? ? ?} ? ? ? ? ? ??

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

? {

? ? ? ? ? ?echo "\n

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

? ? ? ? ? ?else echo "class='dborder3'";

? ? ? ? ?echo ">".$value1." | ";

echo "".$value2.""; ? ? ? ? ??

? echo "

\n";

? ? ? ? ? ? ?}

? ? ? ?echo "\n

";?

? ? ? ?}

? ? echo "\n";

?

? ?$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

? ? ? ?{

? ? ? ?$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

? ? echo "\n";

? ? echo "\n\n";

?

? ? echo "

";

? ? echo "\n

";

? ? for($i=0;$i

? ? ? ?{

? ? ? ?echo "\n

";

? ? ? ?}

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

? ? ? ?{

? ? ? ?echo "\n

\n";

? ? ? ?}

? ? echo "\n

";

? ? if($sqldata->total_num==0)?

? ? ? {

? ? ? echo "\n

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

? ? ? ?else echo "class='dborder'";?

? ? ? ?echo ">";

? ? ? ?echo $field_col[$i];

? ? ? ?echo "\n

".$field_col[$i]."
";

? ? ? return ;

? ? ? } ?

? ? ? $sqldata->rest();

? ? ? echo "\n

";

? ? ? for($i=0;$i

? ? ? ? ?{

? ? ? ? ?echo "\n

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

? ? ? ? ?else echo "class='dborder3'";?

? ? ? ? ?echo "> ";

? ? ? ? ?echo $sqldata->field[$i];

? ? ? ? ?echo " \n

";

? ? ? ? ? }

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

? ? ? ? ?{

? ? ? ? ?echo "\n

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

? ? ? ? ?else echo "class='dborder3'";

? ? ? ? ?echo ">自个儿写的一个php构架

\n";

? ? ? ? ? }?

? ? ? echo "\n

";

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

? ? ? ?{

? ? ? ?echo "\n

";

? ? ? ?for($i=0;$i

? ? ? ? ?{

? ? ? ? ?echo "\n

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

? ? ? ? ?else echo "class='dborder3'";?

? ? ? ? ?echo "> ";

? ? ? ? ?echo $field_data[$i];

? ? ? ? ?echo " \n

";

? ? ? ? ?}

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

? ? ? ? ? ?{

? ? ? ? ? ?echo "\n

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

? ? ? ? ? ?else echo "class='dborder3'";

? ? ? ? ? ?echo ">自个儿写的一个php构架

\n";

? ? ? ? ? ? ?}

? ? ? ?echo "\n

";?

? ? ? ?}

? ? echo "\n";

?

? ?$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 "

? ? echo ".login_border {\n";

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

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

echo "color: #000;\n";

? ? echo " }\n";

? ? echo "\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\n";

? ? echo "

\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

? ? {

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

? ? ? ?{

? ? ? ? echo "

? ? ? ? echo $s_url;

? ? ? ? echo "'\n";

? ?exit;

? ? ? ? }

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

? ? ? ?{

? ? ? ? echo "

? ? ? ? echo $s_url;

? ? ? ? echo "'\n";

? ?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"; ? ?//可展开图片

? // 自个儿写的一个php构架

? $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

? ? ?$expand[$i]=0;

? ? ?$visible[$i]=0;

? ? ?$levels[$i]=0;

? }

?

? /*********************************************/

? /* ?得到节点数 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? */

? /*********************************************/

?

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

?

? $i=0;

? while($i

? {

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

? ? $i++;

? }

?

? /*********************************************/

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

? /*********************************************/

?

? $lastlevel=$maxlevel;

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

? {

? ? ?if ( $tree[$i][0]

? ? ?{

? ? ? ?for ($j=$tree[$i][0]+1; $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

? {

? ? $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++;

? ?>

自个儿写的一个php构架

?

? echo "

\n";

? echo "

";

? for ($i=0; $i";

? echo "

\n";

? $cnt=0;

? while ($cnt

? {

? ? if ($visible[$cnt])

? ? {

? ? ? /****************************************/

? ? ? /* 开始新的一 行 ? ? ? ? ? ? ? ? ? ? ? ?*/

? ? ? /****************************************/ ? ? ?

?$iname++;

? ? ? echo "

";

? ? ? echo " ";

? ? ? /****************************************/

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

? ? ? /****************************************/

? ? ? $i=0;

? ? ? while ($i

? ? ? {

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

? ? ? ? ? ? echo "

";

? ? ? ? else

? ? ? ? ? ? echo "

";

? ? ? ? $i++;

? ? ? }

?

? ? ? /****************************************/

? ? ? /*下一级结点 ? ? ? ? ? ? ? ? ? ? ? ? ? ?*/

? ? ? /****************************************/ ? ? ? ??

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

? ? ? {

? ? ? ? echo "

";

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

? ? ? }

? ? ? else

? ? ? {

? ? ? ? echo "

"; ? ? ? ? ? ? ? ? ?

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

? ? ? }?

?

? ? ? /********************************************/

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

? ? ? /********************************************/

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

? ? ? {

?

? ? ? ? /****************************************/

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

? ? ? ? /****************************************/

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

? ? ? ? while($i

? ? ? ? {

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

? ? ? ? ? {

? ? ? ? ? ? $params=$params.$i;

? ? ? ? ? ? $params=$params."|";

? ? ? ? ? }

? ? ? ? ? $i++;

? ? ? ? }

?

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

? ? ? ? ? ? echo "

";

? ? ? ? else

? ? ? ? ? ? echo "

"; ? ? ? ??

? ? ? }

? ? ? else

? ? ? {

? ? ? ? /*************************/

? ? ? ? /* 树叶 ? ? ? ? ? ? ? ? ?*/

? ? ? ? /*************************/

?

? ? ? ? echo "

"; ? ? ? ??

? ? ? }

?

? ? ? /****************************************/

? ? ? /* 输出条目名称 ? ? ? ? ? ? ? ? ? ? ? ? */

? ? ? /****************************************/

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

? ? ? ? ? echo "

";

? ? ? else

? ? ? ? ? echo "

";

?

? ? ? /****************************************/

? ? ? /* 结束行 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? */

? ? ? /****************************************/

?

? ? ? echo "

\n"; ? ? ?

? ? ?}

? ? ?$cnt++; ? ?

? ?}

? echo "

自个儿写的一个php构架 自个儿写的一个php构架 自个儿写的一个php构架 自个儿写的一个php构架 自个儿写的一个php构架 自个儿写的一个php构架 自个儿写的一个php构架 ".$tree[$cnt][1]." ".$tree[$cnt][1]."
\n";

? }

}

class change_icon

{

public function change_icon($icon_str)

? ? ?{

? ? ?echo "";

? ? ?}

}

class goto_url

{

public function goto_url($g_url)

? ? {

? ? echo "

? ? ? ? echo $g_url;

? ? ? ? echo "';\n";

? ? }

}

function check_verify($v_str)

?{

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

? ?{

? ?return 1;

? ?}

?else return 0;?

?}

function msg($str1)

{

echo "

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

echo "\n";

}

?

?

function regstr($source)

{

? $tmp_h=array();

? $ch_count=0;

? $j=0;

? for($i=0;$i

? ? {

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

? ? ? ? ?{

? ? ? ? ? $source[$i]=" ";

? ? ? ? ?}?

? ? }

?

? for($i=0;$i

? ? {

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

? ? ? ? ?{

? ? ? ? ?$ch_count++;

? ? ? ? ?$tmp_h[$j]=$i;

? ? ? ? ?$j++;

? ? ? ? ?}?

? ? }

? $tmp_i=array();

? for($i=0;$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

? ? ? {

? ? ? ? $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

? ? {

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

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

? ? ? ? {

? ? ? ? return -1;

? ? ? ? }

? ? ? if($r==FALSE)

? ? ? ? {

? ? ? ? ?return -1; ??

? ? ? ? }

? ? ?}

? return 1; ?

}

?

function array_str($arr_str)

{

? $ex=array();

? for($i=0;$i

? ? {

? ? ?for($j=0;$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

? ?{

? ? $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

? ? {

? ? $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

? ? $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

? ? {

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

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

? ? }

? return $re; ?

}

?>

自个儿写的一个php构架

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频