首页 | 新闻 | 交流 | 问吧 | 文档 | 手册 | 下载 | 博客

收藏此问题 发表新评论

php中这段代码作用是什么,谁能说清楚点

<?php
/*********************/
/*                  */
/*  Version : 5.1.0  */
/*  Author  : RM    */
/*  Comment : 071223 */
/*                  */
/*********************/

function html_element( $PRINT_MODEL )
{
$POS = 0;
$LEN = strlen( $PRINT_MODEL );
$I = 0;
$J = 0;
while ( $POS < $LEN )
{
$POS = strpos( $PRINT_MODEL, " <", $POS );
if ( $POS === FALSE )
{
break;
}
if ( substr( $PRINT_MODEL, $POS + 1, 1 ) == "/" )
{
$POS += 2;
}
else
{
$POS1 = strpos( $PRINT_MODEL, " ", $POS );
$POS2 = strpos( $PRINT_MODEL, ">", $POS );
if ( $POS2 < $POS1 )
{
$POS1 = $POS2;
}
$ELEMENT_NAME = substr( $PRINT_MODEL, $POS + 1, $POS1 - $POS - 1 );
switch ( $ELEMENT_NAME )
{
case "INPUT" :
$ELEMENT = substr( $PRINT_MODEL, $POS, $POS2 - $POS + 1 );
$ELEMENT_ARRAY[$I++] = $ELEMENT;
$POS = $POS2 + 1;
continue;
case "BUTTON" :
$POS2 = strpos( $PRINT_MODEL, " </BUTTON>", $POS2 + 1 );
$ELEMENT = substr( $PRINT_MODEL, $POS, $POS2 - $POS + 9 );
$ELEMENT_ARRAY[$I++] = $ELEMENT;
$POS = $POS2 + 9;
continue;
case "SELECT" :
$POS2 = strpos( $PRINT_MODEL, " </SELECT>", $POS2 + 1 );
$ELEMENT = substr( $PRINT_MODEL, $POS, $POS2 - $POS + 9 );
$ELEMENT_ARRAY[$I++] = $ELEMENT;
$POS = $POS2 + 9;
continue;
case "TEXTAREA" :
$POS2 = strpos( $PRINT_MODEL, " </TEXTAREA>", $POS2 + 1 );
$ELEMENT = substr( $PRINT_MODEL, $POS, $POS2 - $POS + 11 );
$ELEMENT_ARRAY[$I++] = $ELEMENT;
$POS = $POS2 + 11;
continue;
case "IMG" :
$ELEMENT = substr( $PRINT_MODEL, $POS, $POS2 - $POS + 1 );
if ( get_attr( $ELEMENT, "CLASS" ) )
{
$ELEMENT_ARRAY[$I++] = $ELEMENT;
}
$POS = $POS2 + 1;
continue;
}
$POS = $POS2 + 1;
}
}
return $ELEMENT_ARRAY;
}

function get_attr( $ELEMENT, $ATTR )
{
$POS = strpos( $ELEMENT, " " );
$E_NAME = substr( $ELEMENT, 1, $POS - 1 );
$ATTR_DATA == "";
if ( $ATTR == "NAME" )
{
$ATTR_DATA = $E_NAME;
return $ATTR_DATA;
}
if ( $ATTR == "TITLE" ¦ ¦ $ATTR == "CLASS" ¦ ¦ $ATTR == "DATAFLD" ¦ ¦ $ATTR == "DATASRC" ¦ ¦ $ATTR == "LV_TITLE" ¦ ¦ $ATTR == "LV_SIZE" ¦ ¦ $ATTR == "LV_SUM" ¦ ¦ $ATTR == "LV_CAL" ¦ ¦ $ATTR == "CHILD" ¦ ¦ $ATTR == "DATA_CONTROL" )
{
if ( $ATTR == "TITLE" ¦ ¦ $ATTR == "CLASS" )
{
$ATTR = strtolower( $ATTR );
}
else if ( $ATTR == "DATAFLD" )
{
$ATTR = "dataFld";
}
else if ( $ATTR == "DATASRC" )
{
$ATTR = "dataSrc";
}
if ( strstr( $ELEMENT, $ATTR ) )
{
$POS = strpos( $ELEMENT, "{$ATTR}=" ) + strlen( $ATTR ) + 1;
$POS1 = strpos( $ELEMENT, ">", $POS );
if ( $ATTR == "dataSrc" ¦ ¦ $ATTR == "LV_TITLE" ¦ ¦ $ATTR == "LV_SIZE" ¦ ¦ $ATTR == "LV_SUM" ¦ ¦ $ATTR == "LV_CAL" ¦ ¦ $ATTR == "CHILD" ¦ ¦ $ATTR == "DATA_CONTROL" )
{
++$POS;
$POS2 = strpos( $ELEMENT, "\"", $POS );
}
else
{
$POS2 = strpos( $ELEMENT, " ", $POS );
}
if ( !( $POS2 < $POS1 ) && $POS2 != 0 ¦ ¦ $ATTR == "dataSrc" )
{
$POS1 = $POS2;
}
$ATTR_DATA = substr( $ELEMENT, $POS, $POS1 - $POS );
$ATTR_DATA = str_replace( "\"", "", $ATTR_DATA );
return $ATTR_DATA;
}
}
else if ( $ATTR == "VALUE" )
{
if ( $E_NAME == "INPUT" ¦ ¦ $E_NAME == "IMG" )
{
if ( !strstr( $ELEMENT, "type=checkbox" ) )
{
$POS = strpos( $ELEMENT, "value=" ) + 6;
$POS1 = strpos( $ELEMENT, ">", $POS );
$POS2 = strpos( $ELEMENT, " ", $POS );
if ( $POS2 < $POS1 && $POS2 != 0 )
{
$POS1 = $POS2;
}
$ATTR_DATA = substr( $ELEMENT, $POS, $POS1 - $POS );
}
else if ( strstr( $ELEMENT, " CHECKED" ) )
{
$ATTR_DATA = "on";
}
$ATTR_DATA = str_replace( "\"", "", $ATTR_DATA );
return $ATTR_DATA;
}
if ( $E_NAME == "TEXTAREA" )
{
$POS = strpos( $ELEMENT, ">" ) + 1;
$POS1 = strpos( $ELEMENT, " <", $POS );
$ATTR_DATA = substr( $ELEMENT, $POS, $POS1 - $POS );
return $ATTR_DATA;
}
if ( $E_NAME == "SELECT" )
{
$POS = strpos( $ELEMENT, ">" ) + 1;
$POS1 = strpos( $ELEMENT, " </SELECT>", $POS );
$ATTR_DATA = substr( $ELEMENT, $POS, $POS1 - $POS );
}
}
return $ATTR_DATA;
}

function calculate( $VALUE )
{
global $ARRAY_COUNT;
global $ETITLE_ARRAY;
global $ITEM_ID;
$ECALC1 = "";
$ECALC2 = "";
$POS = 0;
while ( $POS < strlen( $VALUE ) )
{
$STR1 = substr( $VALUE, $POS, 3 );
if ( $STR1 == "ABS" ¦ ¦ $STR1 == "RMB" ¦ ¦ $STR1 == "MAX" ¦ ¦ $STR1 == "MIN" ¦ ¦ $STR1 == "DAY" )
{
$FUNC = $STR1;
$NVALUE = substr( $VALUE, $POS + 4, strrpos( $VALUE, ")" ) - $POS - 4 );
$POS = strrpos( $VALUE, ")" ) + 1;
$ECALC1 .= "calc_getval(".calculate( $NVALUE ).",'".$FUNC."',".$ITEM_ID.")";
}
else
{
if ( $POS == 0 )
{
$VALUE .= "#";
}
$STR = substr( $VALUE, $POS, 1 );
++$POS;
if ( $STR == "+" ¦ ¦ $STR == "-" ¦ ¦ $STR == "*" ¦ ¦ $STR == "/" ¦ ¦ $STR == "(" ¦ ¦ $STR == ")" ¦ ¦ $STR == "^" ¦ ¦ $STR == "#" ¦ ¦ $STR == "," )
{
if ( $ECALC2 != "" )
{
if ( !is_numeric( $ECALC2 ) )
{
$J = 0;
for ( ; $J < $ARRAY_COUNT; ++$J )
{
if ( !( $ETITLE_ARRAY[$J] == $ECALC2 ) )
{
continue;
}
$ECALC1 .= "calc_getval(document.form1.DATA_".( $J + 1 ).".value,'',".$ITEM_ID.")";
$ECALC2 = "";
break;
}
}
else
{
$ECALC1 .= $ECALC2;
$ECALC2 = "";
}
}
if ( $STR != "#" )
{
if ( $STR == "," )
{
$ECALC1 .= "+','+";
}
else
{
$ECALC1 .= $STR;
}
}
}
else
{
$ECALC2 .= $STR;
}
}
}
return $ECALC1;
}

include_once( "inc/td_core.php" );
if ( $TD_MYOA_COMPANY_NAME != "通达科技" )
{
exit( );
}
?>


$PRINT_MODEL  参数是从fck中读取出来的,,也就相当于是world中的值
昵称: cxxlp  时间: 2008-08-19 16:48:19
这是1段么 起码也要加亮才能看啊 200分差不多能帮LZ看看
昵称: ten789  时间: 2008-08-20 00:15:34
是啊,看得我眼睛都花了
昵称: bwt009  时间: 2008-08-20 04:50:46
帮顶一下了
昵称: jinzhai  时间: 2008-08-20 08:43:11