• Najnowsze pytania
  • Bez odpowiedzi
  • Zadaj pytanie
  • Kategorie
  • Tagi
  • Zdobyte punkty
  • Ekipa ninja
  • IRC
  • FAQ
  • Regulamin
  • Książki warte uwagi

Parse error: syntax error, unexpected end of file in

VPS Starter Arubacloud
0 głosów
200 wizyt
pytanie zadane 18 kwietnia 2023 w PHP przez Waflu Nowicjusz (120 p.)

Niestety jestem laik w tym temacie, ale próbowałem przekopiować pliki strony na inny serwer i zaczęły pojawiać się problemy typu usuń nawias, usuń function i tak brnąłem brnąłem i dotarłem do końca  a tam:

Parse error: syntax error, unexpected end of file in /profiles/d/do/dom/domluxolkusz/zakonczeniadoparapetow.cba.pl/libraries/TplParser.php on line 320

i tu leżę.

Jest ktoś w stanie pomóc ?

<?php
/**
* TplParser - class parse all HTML files and display from
* this files PHP variables
* @access public
* @version 1.2.3
*/
class TplParser
{

	var $content;
	var $sFile;
  var $sFileAlt = null;
	var $sBlock;
	var $startBlock = '<!-- BEGIN ';
	var $endBlock = '<!-- END ';
  var $endBlockLine = ' -->';
  var $aFilesContent;	
  var $sBlockContent;
  var $bEmbedPHP = null;
  var $sDir;
  var $bTrim = true;
  var $aVariables;

  function &getInstance( $sDir = null, $bEmbedPHP = null ){  
    static $oInstance = null;
    if( !isset( $oInstance ) ){  
      $oInstance = new TplParser( $sDir, $bEmbedPHP );  
    }  
    return $oInstance;  
  } // end function getInstance

  /**
  * Constructor
  * @return void
  * @param string $sDir
  * @param bool   $bEmbedPHP
  */
  function TplParser( $sDir, $bEmbedPHP ){
    $this->setEmbedPHP( $bEmbedPHP );
    $this->setDir( $sDir );
  } // end function TplParser
	
  /**
  * Set variables
  * @return void
  * @param string $sName
  * @param mixed  $mValue
  */
  function setVariables( $sName, $mValue ){
    $this->aVariables[$sName] = $mValue;
  } // end function setVariables

  /**
  * Unset variables
  * @return void
  */
  function unsetVariables( ){
    $this->aVariables = null;
  } // end function unsetVariables
  
  /**
  * Display parsed file
  * @return void
  * @param string $sFile - file *.tpl
  * @param bool   $bTrim
  */
	function dHtml( $sFile, $bTrim = true ){
		$this->setFile( $this->sDir.$sFile );
    $this->bTrim = $bTrim;

		$this->display( );
    echo $this->content;
	} // end function dHtml

  /**
  * Return parsed file
  * @return string
  * @param string $sFile - file *.tpl
  * @param bool   $bTrim
  
  */
	function tHtml( $sFile, $bTrim = true ){
		$this->setFile( $this->sDir.$sFile );
    $this->bTrim = $bTrim;

		$this->display( );
		return $this->content;
	} // end function tHtml

  /**
  * Display parsed sBlock from file
  * @return void
  * @param string $sFile - file *.tpl
  * @param string $sBlock
  * @param bool   $bTrim
  */
	function dbHtml( $sFile, $sBlock, $bTrim = true ){
		$this->setFile( $this->sDir.$sFile );
		$this->setBlock( $sBlock );
    $this->bTrim = $bTrim;

		$this->display( true );
    echo $this->content;
	} // end function dbHtml
	
  /**
  * Return parsed sBlock from file
  * @return string
  * @param string $sFile - file *.tpl
  * @param string $sBlock
  * @param bool   $bTrim
  */
	function tbHtml( $sFile, $sBlock, $bTrim = true ){
		$this->setFile( $this->sDir.$sFile );
		$this->setBlock( $sBlock );
    $this->bTrim = $bTrim;

		$this->display( true );
		return $this->content;
	} // end function tbHtml

  /**
  * Function execute functions depend by parameter
  * @return void
  * @param bool $bBlock [optional]
  */
	function display( $bBlock = null ){
		if( $this->checkFile( ) ){
			if( isset( $bBlock ) )
				$this->blockParse( );
			else
				$this->allParse( );
		}
	} // end function display
	
	/**
  * Function check if file exists
  * @return boolean
  */
	function checkFile( ){
		if( is_file( $this->sFile ) ){
	  	return true;
	  }
		else {
      $this->content = null;
      if( isset( $this->sFileAlt ) && is_file( $this->sDir.$this->sFileAlt ) ){
        $this->setFile( $this->sDir.$this->sFileAlt );
        return true;
      }
      else{
        echo 'ERROR - NO TEMPLATE FILE <b>'.$this->sFile.'</b><br />';
        return null;
      }
		}
	} // end function checkFile

  /**
  * Parse content with PHP
  * @return void
  */
  function parsePHP( ){
    extract( $GLOBALS );
    while( $iPosition1 = strpos( $this->content, '<?php' ) ){
      $iPosition2 = strpos( $this->content, '?>' );
      $sPhpCode = substr( $this->content, $iPosition1 + 5, $iPosition2 - $iPosition1 - 5 );
      ob_start( );
      eval( $sPhpCode );
      $this->content = substr( $this->content, 0, $iPosition1 ).ob_get_contents( ).substr( $this->content, $iPosition2 + 2  );
      ob_end_clean( );
    } // end while
  } // end function parsePHP 
	
  /**
  * Function parse $this->content
  * @return boolean
  */
	function parse( ){
    if( isset( $this->bEmbedPHP ) && $this->bEmbedPHP === true && preg_match( '/<?php/', $this->content ) )
      $this->parsePHP( );

    preg_match_all( '/(\$[a-zA-Z_]+[a-zA-Z0-9_]*)(([\[]+[\']*[a-zA-Z0-9_]+[\']*[\]]+)*)/', $this->content, $aResults );
    if( isset( $aResults[1] ) && is_array( $aResults[1] ) ){
      $iCount = count( $aResults[1] );
      for( $i = 0; $i < $iCount; $i++ ){
        $aResults[1][$i] = substr( $aResults[1][$i], 1 );
        if( isset( $this->aVariables[$aResults[1][$i]] ) )
          $$aResults[1][$i] = $this->aVariables[$aResults[1][$i]];
        else
          global $$aResults;1;$i

        // array
        ( isset( $aResults[2] ) && !empty( $aResults[2][$i] ) ){
          ( preg_match( '/\'/', $aResults[2][$i] ) ){
            $aResults[2][$i] = str_replace( '\'', null, $aResults[2][$i] )
             = '\''
          }
          
             = null

          ( '/[a-zA-Z_\'0-9]+/', $aResults[2][$i], $aResults2 )
           = count( $aResults2[0] )
          ( $iCount2 == 2 ){
            ( isset( ${$aResults[1][$i]}[$aResults2[0][0]][$aResults2[0][1]] ) )
              [] = ${$aResults[1][$i]}[$aResults2[0][0]][$aResults2[0][1]]
            
              [] = null
            [] = '/\$'.$aResults[1][$i].'\['.$sSlash.$aResults2[0][0].$sSlash.'\]\['.$sSlash.$aResults2[0][1].$sSlash.'\]/'
          }
          {
            ( isset( ${$aResults[1][$i]}[$aResults2[0][0]] ) )
              [] = ${$aResults[1][$i]}[$aResults2[0][0]]
            
              [] = null
            [] = '/\$'.$aResults[1][$i].'\['.$sSlash.$aResults2[0][0].$sSlash.'\]/'
          }
        }
        {
          ( !is_array( $$aResults[1][$i] ) ){
            $aReplace[] = $$aResults[1][$i].'\\1'
            [] = '/\$'.$aResults[1][$i].'([^a-zA-Z0-9])/'
          }
        }
       // end for
    

    ( isset( $aFind ) )
      ->content = preg_replace( $aFind, $aReplace, $this->content )
    ( isset( $this->bTrim ) )
      ->content = trim( $this->content )
     
		
	 // end function parse
	
  /**
  * Function return all data from file
  * @return void
  */
	 
   ->content = $this->getContent( )
		->parse( )
	 // end function allParse
	
  /**
  * Get defined sBlock from file
  * @return boolean
  */
	

  /**
  * Get file data from file or from variable ($this->aFilesContent)
  * @return array
  * @param bool $bBlock
  */
  

  /**
  * Return file content
  * @return string
  * @param string $sFile
  */
  

  /**
  * Return sBlock from file
  * @return string
  * @param string $sFile [optional]
  * @param string $sBlock [optional]
  */
  

  /**
  * Return file to array
  * @return array
  * @param string $sFile
  */
  

  /**
  * Return defined $this->sDir variable
  * @return string
  */
  

  /**
  * Function define $this->sDir variable
  * @return void
  * @param string $sDir
  */
  
  /**
  * Function define $this->bEmbedPHP variable
  * @return void
  * @param bool $bEmbed
  */
  
  /**
  * Function define $this->sFile variable
  * @return void
  * @param string $sFile
  */
 

  /**
  * Function define $this->sFileAlt variable
  * @return void
  * @param string $sFileAlt
  */
  

  /**
  * Function define $this->sBlock variable
  * @return void
  * @param string $sBlock
  */
  
 // end class TplParser

 
?>

 

1 odpowiedź

0 głosów
odpowiedź 19 kwietnia 2023 przez VBService Ekspert (251,170 p.)

Od linii 159 to się "działo"  laugh

Sprawdź

<?php
/**
* TplParser - class parse all HTML files and display from
* this files PHP variables
* @access public
* @version 1.2.3
*/
class TplParser
{
  var $content;
  var $sFile;
  var $sFileAlt = null;
  var $sBlock;
  var $startBlock = '<!-- BEGIN ';
  var $endBlock = '<!-- END ';
  var $endBlockLine = ' -->';
  var $aFilesContent;   
  var $sBlockContent;
  var $bEmbedPHP = null;
  var $sDir;
  var $bTrim = true;
  var $aVariables;
 
  function &getInstance( $sDir = null, $bEmbedPHP = null ){  
    static $oInstance = null;
    if( !isset( $oInstance ) ){  
      $oInstance = new TplParser( $sDir, $bEmbedPHP );  
    }  
    return $oInstance;  
  } // end function getInstance
 
  /**
  * Constructor
  * @return void
  * @param string $sDir
  * @param bool   $bEmbedPHP
  */
  function TplParser( $sDir, $bEmbedPHP ){
    $this->setEmbedPHP( $bEmbedPHP );
    $this->setDir( $sDir );
  } // end function TplParser
     
  /**
  * Set variables
  * @return void
  * @param string $sName
  * @param mixed  $mValue
  */
  function setVariables( $sName, $mValue ){
    $this->aVariables[$sName] = $mValue;
  } // end function setVariables
 
  /**
  * Unset variables
  * @return void
  */
  function unsetVariables( ){
    $this->aVariables = null;
  } // end function unsetVariables
   
  /**
  * Display parsed file
  * @return void
  * @param string $sFile - file *.tpl
  * @param bool   $bTrim
  */
  function dHtml( $sFile, $bTrim = true ){
    $this->setFile( $this->sDir.$sFile );
    $this->bTrim = $bTrim;
 
    $this->display( );
    echo $this->content;
  } // end function dHtml
 
  /**
  * Return parsed file
  * @return string
  * @param string $sFile - file *.tpl
  * @param bool   $bTrim   
  */
  function tHtml( $sFile, $bTrim = true ){
    $this->setFile( $this->sDir.$sFile );
    $this->bTrim = $bTrim;
 
    $this->display( );
    return $this->content;
  } // end function tHtml
 
  /**
  * Display parsed sBlock from file
  * @return void
  * @param string $sFile - file *.tpl
  * @param string $sBlock
  * @param bool   $bTrim
  */
  function dbHtml( $sFile, $sBlock, $bTrim = true ){
    $this->setFile( $this->sDir.$sFile );
    $this->setBlock( $sBlock );
    $this->bTrim = $bTrim;
 
    $this->display( true );
    echo $this->content;
  } // end function dbHtml
     
  /**
  * Return parsed sBlock from file
  * @return string
  * @param string $sFile - file *.tpl
  * @param string $sBlock
  * @param bool   $bTrim
  */
  function tbHtml( $sFile, $sBlock, $bTrim = true ){
    $this->setFile( $this->sDir.$sFile );
    $this->setBlock( $sBlock );
    $this->bTrim = $bTrim;
 
    $this->display( true );
    return $this->content;
  } // end function tbHtml
 
  /**
  * Function execute functions depend by parameter
  * @return void
  * @param bool $bBlock [optional]
  */
  function display( $bBlock = null ){
    if( $this->checkFile( ) ){
      if( isset( $bBlock ) )
        $this->blockParse( );
      else
        $this->allParse( );
    }
  } // end function display
     
  /**
  * Function check if file exists
  * @return boolean
  */
  function checkFile( ){
    if( is_file( $this->sFile ) ){
      return true;
    } else {
      $this->content = null;
      if( isset( $this->sFileAlt ) && is_file( $this->sDir.$this->sFileAlt ) ){
        $this->setFile( $this->sDir.$this->sFileAlt );
        return true;
      }
      else{
        echo 'ERROR - NO TEMPLATE FILE <b>'.$this->sFile.'</b><br />';
        return null;
      }
    }
  } // end function checkFile
 
  /**
  * Parse content with PHP
  * @return void
  */
  function parsePHP( ){
    extract( $GLOBALS );
    while( $iPosition1 = strpos( $this->content, '<?php' ) ){
      $iPosition2 = strpos( $this->content, '?>' );
      $sPhpCode = substr( $this->content, $iPosition1 + 5, $iPosition2 - $iPosition1 - 5 );
      ob_start( );
      eval( $sPhpCode );
      $this->content = substr( $this->content, 0, $iPosition1 ).ob_get_contents( ).substr( $this->content, $iPosition2 + 2  );
      ob_end_clean( );
    } // end while
  } // end function parsePHP 
     
  /**
  * Function parse $this->content
  * @return boolean
  */
  function parse() {
    if(isset($this->bEmbedPHP) && $this->bEmbedPHP === true && preg_match('/<?php/', $this->content)) {
      $this->parsePHP();
    }

    preg_match_all('/(\$[a-zA-Z_]+[a-zA-Z0-9_]*)(([\[]+[\']*[a-zA-Z0-9_]+[\']*[\]]+)*)/', $this->content, $aResults);
    if(isset($aResults[1]) && is_array($aResults[1])) {
      $iCount = count($aResults[1]);
      for($i = 0; $i < $iCount; $i++) {
        $aResults[1][$i] = substr($aResults[1][$i], 1);
        if(isset($this->aVariables[$aResults[1][$i]])) {
          ${$aResults[1][$i]} = $this->aVariables[$aResults[1][$i]];
        } else {
          global ${$aResults[1][$i]};
        }

        // array
        if(isset($aResults[2]) && !empty($aResults[2][$i])) {
          if(preg_match('/\'/', $aResults[2][$i])) {
            $aResults[2][$i] = str_replace('\'', null, $aResults[2][$i]);
          }
          $sSlash = '\\';
          preg_match_all('/[a-zA-Z_\'0-9]+/', $aResults[2][$i], $aResults2);
          $iCount2 = count($aResults2[0]);
          if($iCount2 == 2) {
            if(isset(${$aResults[1][$i]}[$aResults2[0][0]][$aResults2[0][1]])) {
             ${$aResults[1][$i]}[] = ${$aResults[1][$i]}[$aResults2[0][0]][$aResults2[0][1]];
          } else {
            ${$aResults[1][$i]}[] = null;
          }
          $aFind[] = '/\$'.$aResults[1][$i].'\['.$sSlash.$aResults2[0][0].$sSlash.'\]\['.$sSlash.$aResults2[0][1].$sSlash.'\]/';
          } else {
            if(isset(${$aResults[1][$i]}[$aResults2[0][0]])) {
              ${$aResults[1][$i]}[] = ${$aResults[1][$i]}[$aResults2[0][0]];
            } else {
              ${$aResults[1][$i]}[] = null;
            }
            $aFind[] = '/\$'.$aResults[1][$i].'\['.$sSlash.$aResults2[0][0].$sSlash.'\]/';
          }
        } else {
          if(!is_array(${$aResults[1][$i]})) {
            $aReplace[] = ${$aResults[1][$i]}.'\\1';
            $aFind[] = '/\$'.$aResults[1][$i].'([^a-zA-Z0-9])/';
          }
        }      
      } // end for
    }

    if(isset($aFind)) {
      $this->content = preg_replace($aFind, $aReplace, $this->content);
    }
    if(isset($this->bTrim)) {
      $this->content = trim($this->content);
    }
  } // end function parse

     
  /**
  * Function return all data from file
  * @return void
  */
  function allParse( ) {    
    $this->content = $this->getContent( );
    $this->parse( );
  }
  // end function allParse
     
  /**
  * Get defined sBlock from file
  * @return boolean
  */
     
 
  /**
  * Get file data from file or from variable ($this->aFilesContent)
  * @return array
  * @param bool $bBlock
  */
   
 
  /**
  * Return file content
  * @return string
  * @param string $sFile
  */
   
 
  /**
  * Return sBlock from file
  * @return string
  * @param string $sFile [optional]
  * @param string $sBlock [optional]
  */
   
 
  /**
  * Return file to array
  * @return array
  * @param string $sFile
  */
   
 
  /**
  * Return defined $this->sDir variable
  * @return string
  */
   
 
  /**
  * Function define $this->sDir variable
  * @return void
  * @param string $sDir
  */
   
  /**
  * Function define $this->bEmbedPHP variable
  * @return void
  * @param bool $bEmbed
  */
   
  /**
  * Function define $this->sFile variable
  * @return void
  * @param string $sFile
  */
  
 
  /**
  * Function define $this->sFileAlt variable
  * @return void
  * @param string $sFileAlt
  */
   
 
  /**
  * Function define $this->sBlock variable
  * @return void
  * @param string $sBlock
  */
   
} // end class TplParse 
  
?>

 

komentarz 19 kwietnia 2023 przez Waflu Nowicjusz (120 p.)

teraz mam błąd:


Fatal error: Uncaught Error: Call to undefined method TplParser::setEmbedPHP() in /profiles/d/do/dom/domluxolkusz/zakonczeniadoparapetow.cba.pl/libraries/TplParser.php:39 Stack trace: #0 /profiles/d/do/dom/domluxolkusz/zakonczeniadoparapetow.cba.pl/libraries/TplParser.php(27): TplParser->TplParser('templates/', false) #1 /profiles/d/do/dom/domluxolkusz/zakonczeniadoparapetow.cba.pl/index.php(43): TplParser::getInstance('templates/', false) #2 {main} thrown in /profiles/d/do/dom/domluxolkusz/zakonczeniadoparapetow.cba.pl/libraries/TplParser.php on line 39

komentarz 26 kwietnia 2023 przez Waflu Nowicjusz (120 p.)
Jakiś pomysł jak rozwiązać problem ?
komentarz 26 kwietnia 2023 przez VBService Ekspert (251,170 p.)

Możesz udostępnić pełny oryginalny kod TplParser, bo ten udostępniony przez Ciebie jest niepełny. Brakuje funkcji 

function TplParser( $sDir, $bEmbedPHP ){
    $this->setEmbedPHP( $bEmbedPHP );
    $this->setDir( $sDir );
  } // end function TplParser
   

 

BTW i wielu innych funkcji brakuje ...

komentarz 26 kwietnia 2023 przez Waflu Nowicjusz (120 p.)
Czyli to tu jest problem, to jest cały kod jaki znajduje się w plikuTplParser...

Podobne pytania

0 głosów
1 odpowiedź 1,248 wizyt
0 głosów
2 odpowiedzi 6,851 wizyt
0 głosów
1 odpowiedź 739 wizyt
pytanie zadane 12 marca 2020 w PHP przez dawidm2007 Nowicjusz (190 p.)

92,451 zapytań

141,261 odpowiedzi

319,073 komentarzy

61,853 pasjonatów

Motyw:

Akcja Pajacyk

Pajacyk od wielu lat dożywia dzieci. Pomóż klikając w zielony brzuszek na stronie. Dziękujemy! ♡

Oto polecana książka warta uwagi.
Pełną listę książek znajdziesz tutaj.

Akademia Sekuraka

Akademia Sekuraka 2024 zapewnia dostęp do minimum 15 szkoleń online z bezpieczeństwa IT oraz dostęp także do materiałów z edycji Sekurak Academy z roku 2023!

Przy zakupie możecie skorzystać z kodu: pasja-akademia - użyjcie go w koszyku, a uzyskacie rabat -30% na bilety w wersji "Standard"! Więcej informacji na temat akademii 2024 znajdziecie tutaj. Dziękujemy ekipie Sekuraka za taką fajną zniżkę dla wszystkich Pasjonatów!

Akademia Sekuraka

Niedawno wystartował dodruk tej świetnej, rozchwytywanej książki (około 940 stron). Mamy dla Was kod: pasja (wpiszcie go w koszyku), dzięki któremu otrzymujemy 10% zniżki - dziękujemy zaprzyjaźnionej ekipie Sekuraka za taki bonus dla Pasjonatów! Książka to pierwszy tom z serii o ITsec, który łagodnie wprowadzi w świat bezpieczeństwa IT każdą osobę - warto, polecamy!

...