CODE (htmlphp):
скопировать код в буфер обмена
скопировать код в буфер обмена
- <?php
- function get_user( )
- {
- global $_conf;
- if ( $_SESSION[login] != "" && $_SESSION[password] != "" )
- {
- $res = mysql_query( "select * from ".$_conf[table_prefix]."users where name='".$_SESSION[login]."' and password='".$_SESSION[password]."'" );
- if ( $row = mysql_fetch_array( $res ) )
- {
- mysql_query( "update ".$_conf[table_prefix]."users set last_visit=".time( )." where id='".$row[id]."'" );
- return $row;
- }
- return -1;
- }
- return 0;
- }
- function parse_tpl( $tpl, $vars )
- {
- preg_match_all( "|{{([0-9a-z_ ]*?)(\\(.*?\\))?}}|si", $tpl, $matches );
- foreach ( $matches[1] as $i => $k )
- {
- if ( substr( $k, 0, 10 ) == "if_exists " )
- {
- {
- $tpl = preg_replace( "|{{".$k."}}.*?{{end ".$k."}}|si", "", $tpl );
- }
- else
- {
- $tpl = str_replace( "{{".$k."}}", "", $tpl );
- $tpl = str_replace( "{{end ".$k."}}", "", $tpl );
- }
- unset( $this->1->$i );
- }
- if ( substr( $k, 0, 14 ) == "if_not_exists " )
- {
- {
- $tpl = preg_replace( "|{{".$k."}}.*?{{end ".$k."}}|si", "", $tpl );
- }
- else
- {
- $tpl = str_replace( "{{".$k."}}", "", $tpl );
- $tpl = str_replace( "{{end ".$k."}}", "", $tpl );
- }
- unset( $this->1->$i );
- }
- {
- $replace = "";
- if ( trim( $matches[2][$i] ) != "" )
- {
- $params = trim( $matches[2][$i], "()" );
- preg_match( "|([0-9]*),(.*)|si", $params, $matches1 );
- $n = ( integer )$matches1[1];
- $delimiter = $matches1[2];
- $delimiter = trim( $delimiter, "\"'" );
- }
- $cnt = 0;
- $cnt_all = 0;
- foreach ( $vars[$k] as $v )
- {
- ++$cnt_all;
- ++$cnt;
- $replace .= parse_tpl( $tpl1, $v );
- if ( !( $cnt == ( integer )$n ) && !( $cnt_all < count( $vars[$k] ) ) )
- {
- $replace .= $delimiter;
- $cnt = 0;
- }
- }
- unset( $this->1->$i );
- }
- else if ( 0 < strpos( $tpl, "{{end ".$k."}}" ) )
- {
- unset( $this->1->$i );
- }
- }
- foreach ( $matches[1] as $i => $k )
- {
- if ( isset( $vars[$k] ) )
- {
- $tpl = str_replace( "{{".$k.$matches[2][$i]."}}", $vars[$k], $tpl );
- unset( $this->1->$i );
- }
- }
- return $tpl;
- }
- function show_main( )
- {
- global $vars;
- global $_conf;
- $tpl = file_get_contents( "tpl/main.htm" );
- $copyright = @file_get_contents( "http://www.flashscripts.org/copyright.php?mode=forum&catalog=".@urlencode( $_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI] ) );
- if ( 0 < strpos( "_".$tpl, "{{authors_link}}" ) )
- {
- $tpl = str_replace( "{{authors_link}}", $copyright, $tpl );
- }
- else if ( 0 < strpos( "_".$tpl, "</body>" ) )
- {
- $tpl = str_replace( "</body>", "<center>".$copyright."</center> </body>", $tpl );
- }
- else
- {
- $tpl .= " <center>".$copyright."</center>";
- }
- $tpl = parse_tpl( $tpl, $vars );
- $tpl = preg_replace( "|{{.*?}}|si", "", $tpl );
- echo $tpl;
- }
- ?>