Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: помогите исправить баг
Форумы портала PHP.SU » » Если скрипт не работает » помогите исправить баг

Страниц (1): [1]
 

1. trask - 24 Ноября, 2011 - 13:34:05 - перейти к сообщению
unset( $this->1->$i ); вот сам код где баг если надо вот полный код
CODE (htmlphp):
скопировать код в буфер обмена
  1.  
  2. <?php
  3.  
  4. function get_user( )
  5. {
  6.    global $_conf;
  7.    if ( $_SESSION[login] != "" && $_SESSION[password] != "" )
  8.    {
  9.        $res = mysql_query( "select * from ".$_conf[table_prefix]."users where name='".$_SESSION[login]."' and password='".$_SESSION[password]."'" );
  10.        if ( $row = mysql_fetch_array( $res ) )
  11.        {
  12.            mysql_query( "update ".$_conf[table_prefix]."users set last_visit=".time( )." where id='".$row[id]."'" );
  13.            return $row;
  14.        }
  15.        return -1;
  16.    }
  17.    return 0;
  18. }
  19.  
  20. function parse_tpl( $tpl, $vars )
  21. {
  22.    preg_match_all( "|{{([0-9a-z_ ]*?)(\\(.*?\\))?}}|si", $tpl, $matches );
  23.    foreach ( $matches[1] as $i => $k )
  24.    {
  25.        if ( substr( $k, 0, 10 ) == "if_exists " )
  26.        {
  27.            if ( trim( $vars[substr( $k, 10 )] ) == "" )
  28.            {
  29.                $tpl = preg_replace( "|{{".$k."}}.*?{{end ".$k."}}|si", "", $tpl );
  30.            }
  31.            else
  32.            {
  33.                $tpl = str_replace( "{{".$k."}}", "", $tpl );
  34.                $tpl = str_replace( "{{end ".$k."}}", "", $tpl );
  35.            }
  36.            unset( $this->1->$i );
  37.        }
  38.        if ( substr( $k, 0, 14 ) == "if_not_exists " )
  39.        {
  40.            if ( trim( $vars[substr( $k, 14 )] ) != "" )
  41.            {
  42.                $tpl = preg_replace( "|{{".$k."}}.*?{{end ".$k."}}|si", "", $tpl );
  43.            }
  44.            else
  45.            {
  46.                $tpl = str_replace( "{{".$k."}}", "", $tpl );
  47.                $tpl = str_replace( "{{end ".$k."}}", "", $tpl );
  48.            }
  49.            unset( $this->1->$i );
  50.        }
  51.        if ( 0 < strpos( $tpl, "{{end ".$k."}}" ) && is_array( $vars[$k] ) )
  52.        {
  53.            $replace = "";
  54.            $tpl1 = substr( $tpl, strpos( $tpl, "{{".$k.$matches[2][$i]."}}" ) + strlen( "{{".$k.$matches[2][$i]."}}" ), strpos( $tpl, "{{end ".$k."}}" ) - strpos( $tpl, "{{".$k.$matches[2][$i]."}}" ) - strlen( "{{".$k.$matches[2][$i]."}}" ) );
  55.            if ( trim( $matches[2][$i] ) != "" )
  56.            {
  57.                $params = trim( $matches[2][$i], "()" );
  58.                preg_match( "|([0-9]*),(.*)|si", $params, $matches1 );
  59.                $n = ( integer )$matches1[1];
  60.                $delimiter = $matches1[2];
  61.                $delimiter = trim( $delimiter, "\"'" );
  62.            }
  63.            $cnt = 0;
  64.            $cnt_all = 0;
  65.            foreach ( $vars[$k] as $v )
  66.            {
  67.                ++$cnt_all;
  68.                ++$cnt;
  69.                $replace .= parse_tpl( $tpl1, $v );
  70.                if ( !( $cnt == ( integer )$n ) && !( $cnt_all < count( $vars[$k] ) ) )
  71.                {
  72.                    $replace .= $delimiter;
  73.                    $cnt = 0;
  74.                }
  75.            }
  76.            $tpl = str_replace( substr( $tpl, strpos( $tpl, "{{".$k.$matches[2][$i]."}}" ), strpos( $tpl, "{{end ".$k."}}" ) + strlen( "{{end ".$k."}}" ) - strpos( $tpl, "{{".$k.$matches[2][$i]."}}" ) ), $replace, $tpl );
  77.            unset( $this->1->$i );
  78.        }
  79.        else if ( 0 < strpos( $tpl, "{{end ".$k."}}" ) )
  80.        {
  81.            $tpl = str_replace( substr( $tpl, strpos( $tpl, "{{".$k.$matches[2][$i]."}}" ), strpos( $tpl, "{{end ".$k."}}" ) + strlen( "{{end ".$k."}}" ) - strpos( $tpl, "{{".$k.$matches[2][$i]."}}" ) ), "", $tpl );
  82.            unset( $this->1->$i );
  83.        }
  84.    }
  85.    foreach ( $matches[1] as $i => $k )
  86.    {
  87.        if ( isset( $vars[$k] ) )
  88.        {
  89.            $tpl = str_replace( "{{".$k.$matches[2][$i]."}}", $vars[$k], $tpl );
  90.            unset( $this->1->$i );
  91.        }
  92.    }
  93.    return $tpl;
  94. }
  95.  
  96. function show_main( )
  97. {
  98.    global $vars;
  99.    global $_conf;
  100.    $tpl = file_get_contents( "tpl/main.htm" );
  101.    $copyright = @file_get_contents( "http://www.flashscripts.org/copyright.php?mode=forum&catalog=".@urlencode( $_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI] ) );
  102.    if ( 0 < strpos( "_".$tpl, "{{authors_link}}" ) )
  103.    {
  104.        $tpl = str_replace( "{{authors_link}}", $copyright, $tpl );
  105.    }
  106.    else if ( 0 < strpos( "_".$tpl, "</body>" ) )
  107.    {
  108.        $tpl = str_replace( "</body>", "<center>".$copyright."</center> </body>", $tpl );
  109.    }
  110.    else
  111.    {
  112.        $tpl .= " <center>".$copyright."</center>";
  113.    }
  114.    $tpl = parse_tpl( $tpl, $vars );
  115.    $tpl = preg_replace( "|{{.*?}}|si", "", $tpl );
  116.    echo $tpl;
  117. }
  118.  
  119. ?>
  120.  
2. DeepVarvar - 24 Ноября, 2011 - 13:55:26 - перейти к сообщению
trask пишет:
$this->1
Чо??? Не понял
Имена переменных, а равно и свойств не могут начинаться на цифру или состоять из одной только цифры/числа.
trask пишет:
$this
А де объект то???

 

Powered by ExBB FM 1.0 RC1