vitnet

profile.php

Nov 1st, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.94 KB | None | 0 0
  1. <?php
  2. /*
  3. =====================================================
  4.  DataLife Engine - by SoftNews Media Group
  5. -----------------------------------------------------
  6.  http://dle-news.ru/
  7. -----------------------------------------------------
  8.  Copyright (c) 2004-2018 SoftNews Media Group
  9. =====================================================
  10.  This code is protected by copyright
  11. =====================================================
  12.  File: profile.php
  13. -----------------------------------------------------
  14.  Use: User profile
  15. =====================================================
  16. */
  17.  
  18. if( !defined('DATALIFEENGINE') ) {
  19.     header( "HTTP/1.1 403 Forbidden" );
  20.     header( 'Location: ../../' );
  21.     die( "Hacking attempt!" );
  22. }
  23.  
  24. require_once (DLEPlugins::Check(ENGINE_DIR . '/classes/templates.class.php'));
  25.  
  26. if( $_REQUEST['user_hash'] == "" OR $_REQUEST['user_hash'] != $dle_login_hash ) {
  27.     echo "<div id='dleprofilepopup' title='{$lang['all_err_1']}' style='display:none'><br />{$lang['sess_error']}</div>";
  28.     die();
  29. }
  30.  
  31. $tpl = new dle_template();
  32. $tpl->dir = ROOT_DIR . '/templates/' . $config['skin'];
  33. define( 'TEMPLATE_DIR', $tpl->dir );
  34. $PHP_SELF = $config['http_home_url'] . "index.php";
  35.  
  36. if( isset($_GET['name']) ) $name = @$db->safesql ( strip_tags ( urldecode ( $_GET['name'] ) ) ); else $name = '';
  37.  
  38. if( !$name ) die("Hacking attempt!");
  39.  
  40. if( preg_match( "/[\||\'|\<|\>|\"|\!|\?|\$|\@|\/|\\\|\&\~\*\+]/", $name ) ) die("Not allowed user name!");
  41.  
  42. $row = $db->super_query( "SELECT * FROM " . USERPREFIX . "_users WHERE name = '{$name}'" );
  43.  
  44. if( !$row['user_id'] ) {
  45.     echo "<div id='dleprofilepopup' title='{$lang['all_err_1']}' style='display:none'><br />{$lang['news_err_26']}</div>";
  46. } else {
  47.  
  48.     if( isset($_REQUEST['tpl']) AND $_REQUEST['tpl'] != "" && file_exists( TEMPLATE_DIR . '/' . strip_tags(stripslashes($_REQUEST['tpl'])) . '.tpl' ) ) {
  49.         $tpl->load_template( strip_tags(stripslashes($_REQUEST['tpl'])) . '.tpl' );
  50.     } else {
  51.         $tpl->load_template( 'profile_popup.tpl' );
  52.     }
  53.  
  54.     if( strpos( $tpl->copy_template, "[xfvalue_" ) !== false ) {
  55.         $xfields = xfieldsload( true );
  56.         $xfieldsdata = xfieldsdataload( $row['xfields'] );
  57.  
  58.         foreach ( $xfields as $value ) {
  59.             $preg_safe_name = preg_quote( $value[0], "'" );
  60.  
  61.             if( $value[5] != 1 or $member_id['user_group'] == 1 or ($is_logged and $row['is_register'] and $member_id['name'] == $row['name']) ) {
  62.                 if( empty( $xfieldsdata[$value[0]] ) ) {
  63.                     $tpl->copy_template = preg_replace( "'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
  64.                     $tpl->copy_template = str_replace( "[xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
  65.                     $tpl->copy_template = str_replace( "[/xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
  66.                 } else {
  67.                     $tpl->copy_template = preg_replace( "'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
  68.                     $tpl->copy_template = str_replace( "[xfgiven_{$value[0]}]", "", $tpl->copy_template );
  69.                     $tpl->copy_template = str_replace( "[/xfgiven_{$value[0]}]", "", $tpl->copy_template );
  70.                 }
  71.  
  72.                 $tpl->set( "[xfvalue_{$value[0]}]", stripslashes( $xfieldsdata[$value[0]] ));
  73.             } else {
  74.                 $tpl->copy_template = preg_replace( "'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
  75.                 $tpl->copy_template = preg_replace( "'\\[xfvalue_{$preg_safe_name}\\]'i", "", $tpl->copy_template );
  76.                 $tpl->copy_template = preg_replace( "'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
  77.             }
  78.         }
  79.     }
  80.  
  81.     if ( count(explode("@", $row['foto'])) == 2 ) {
  82.         $tpl->set( '{foto}', 'https://www.gravatar.com/avatar/' . md5(trim($row['foto'])) . '?s=' . intval($user_group[$row['user_group']]['max_foto']) ); 
  83.     } else {
  84.         if( $row['foto'] ) {
  85.             if (strpos($row['foto'], "//") === 0) $avatar = "http:".$row['foto']; else $avatar = $row['foto'];
  86.  
  87.             $avatar = @parse_url ( $avatar );
  88.  
  89.             if( $avatar['host'] ) {
  90.                 $tpl->set( '{foto}', $row['foto'] );
  91.             } else $tpl->set( '{foto}', $config['http_home_url'] . "uploads/fotos/" . $row['foto'] );
  92.         } else $tpl->set( '{foto}', "{THEME}/dleimages/noavatar.png" );
  93.     }
  94.  
  95.     if (stripos ( $tpl->copy_template, "[profile-user-group=" ) !== false) {
  96.         $tpl->copy_template = preg_replace_callback ( '#\\[profile-user-group=(.+?)\\](.*?)\\[/profile-user-group\\]#is',
  97.             function ($matches) {
  98.                 global $row;
  99.  
  100.                 $groups = $matches[1];
  101.                 $block = $matches[2];
  102.            
  103.                 $groups = explode( ',', $groups );
  104.            
  105.                 if( !in_array( $row['user_group'], $groups ) ) return "";
  106.        
  107.                 return $block;
  108.             },     
  109.         $tpl->copy_template );
  110.     }
  111.  
  112.     if (stripos ( $tpl->copy_template, "[not-profile-user-group=" ) !== false) {
  113.         $tpl->copy_template = preg_replace_callback ( '#\\[not-profile-user-group=(.+?)\\](.*?)\\[/not-profile-user-group\\]#is',
  114.             function ($matches) {
  115.                 global $row;
  116.            
  117.                 $groups = $matches[1];
  118.                 $block = $matches[2];
  119.            
  120.                 $groups = explode( ',', $groups );
  121.            
  122.                 if( in_array( $row['user_group'], $groups ) ) return "";
  123.    
  124.                 return $block;
  125.             },     
  126.         $tpl->copy_template );
  127.     }
  128.  
  129.     if( $row['banned'] == 'yes' ) $user_group[$row['user_group']]['group_name'] = $lang['user_ban'];
  130.  
  131.     $tpl->set( '{status}',  $user_group[$row['user_group']]['group_prefix'].$user_group[$row['user_group']]['group_name'].$user_group[$row['user_group']]['group_suffix'] );
  132.     $tpl->set( '{registration}', langdate( "j F Y H:i", $row['reg_date'] ) );
  133.     $tpl->set( '{lastdate}', langdate( "j F Y H:i", $row['lastdate'] ) );
  134.  
  135.     if ( ($row['lastdate'] + 1200) > $_TIME ) {
  136.         $tpl->set( '[online]', "" );
  137.         $tpl->set( '[/online]', "" );
  138.         $tpl->set_block( "'\\[offline\\](.*?)\\[/offline\\]'si", "" );
  139.     } else {
  140.         $tpl->set( '[offline]', "" );
  141.         $tpl->set( '[/offline]', "" );
  142.         $tpl->set_block( "'\\[online\\](.*?)\\[/online\\]'si", "" );
  143.     }
  144.  
  145.     if( $row['fullname'] ) {
  146.         $tpl->set( '[fullname]', "" );
  147.         $tpl->set( '[/fullname]', "" );
  148.         $tpl->set( '{fullname}', stripslashes( $row['fullname'] ) );
  149.         $tpl->set_block( "'\\[not-fullname\\](.*?)\\[/not-fullname\\]'si", "" );
  150.     } else {
  151.         $tpl->set_block( "'\\[fullname\\](.*?)\\[/fullname\\]'si", "" );
  152.         $tpl->set( '{fullname}', "" );
  153.         $tpl->set( '[not-fullname]', "" );
  154.         $tpl->set( '[/not-fullname]', "" );
  155.     }
  156.  
  157.     if( $row['land'] ) {
  158.         $tpl->set( '[land]', "" );
  159.         $tpl->set( '[/land]', "" );
  160.         $tpl->set( '{land}', stripslashes( $row['land'] ) );
  161.         $tpl->set_block( "'\\[not-land\\](.*?)\\[/not-land\\]'si", "" );
  162.     } else {
  163.         $tpl->set_block( "'\\[land\\](.*?)\\[/land\\]'si", "" );
  164.         $tpl->set( '{land}', "" );
  165.         $tpl->set( '[not-land]', "" );
  166.         $tpl->set( '[/not-land]', "" );
  167.     }
  168.  
  169.     if( $row['info'] ) {
  170.         $tpl->set( '[info]', "" );
  171.         $tpl->set( '[/info]', "" );
  172.         $tpl->set( '{info}', stripslashes( $row['info'] ) );
  173.         $tpl->set_block( "'\\[not-info\\](.*?)\\[/not-info\\]'si", "" );   
  174.     } else {
  175.         $tpl->set_block( "'\\[info\\](.*?)\\[/info\\]'si", "" );
  176.         $tpl->set( '{info}', "" );
  177.         $tpl->set( '[not-info]', "" );
  178.         $tpl->set( '[/not-info]', "" );
  179.     }
  180.  
  181.     if ( $config['rating_type'] == "1" ) {
  182.         $tpl->set( '[rating-type-2]', "" );
  183.         $tpl->set( '[/rating-type-2]', "" );
  184.         $tpl->set_block( "'\\[rating-type-1\\](.*?)\\[/rating-type-1\\]'si", "" );
  185.         $tpl->set_block( "'\\[rating-type-3\\](.*?)\\[/rating-type-3\\]'si", "" );
  186.         $tpl->set_block( "'\\[rating-type-4\\](.*?)\\[/rating-type-4\\]'si", "" );
  187.     } elseif ( $config['rating_type'] == "2" ) {
  188.         $tpl->set( '[rating-type-3]', "" );
  189.         $tpl->set( '[/rating-type-3]', "" );
  190.         $tpl->set_block( "'\\[rating-type-1\\](.*?)\\[/rating-type-1\\]'si", "" );
  191.         $tpl->set_block( "'\\[rating-type-2\\](.*?)\\[/rating-type-2\\]'si", "" );
  192.         $tpl->set_block( "'\\[rating-type-4\\](.*?)\\[/rating-type-4\\]'si", "" );
  193.     } elseif ( $config['rating_type'] == "3" ) {
  194.         $tpl->set( '[rating-type-4]', "" );
  195.         $tpl->set( '[/rating-type-4]', "" );
  196.         $tpl->set_block( "'\\[rating-type-1\\](.*?)\\[/rating-type-1\\]'si", "" );
  197.         $tpl->set_block( "'\\[rating-type-2\\](.*?)\\[/rating-type-2\\]'si", "" );
  198.         $tpl->set_block( "'\\[rating-type-3\\](.*?)\\[/rating-type-3\\]'si", "" );
  199.     } else {
  200.         $tpl->set( '[rating-type-1]', "" );
  201.         $tpl->set( '[/rating-type-1]', "" );
  202.         $tpl->set_block( "'\\[rating-type-4\\](.*?)\\[/rating-type-4\\]'si", "" );
  203.         $tpl->set_block( "'\\[rating-type-3\\](.*?)\\[/rating-type-3\\]'si", "" );
  204.         $tpl->set_block( "'\\[rating-type-2\\](.*?)\\[/rating-type-2\\]'si", "" ); 
  205.     }
  206.  
  207.     if ( $config['comments_rating_type'] == "1" ) {
  208.         $tpl->set( '[comments-rating-type-2]', "" );
  209.         $tpl->set( '[/comments-rating-type-2]', "" );
  210.         $tpl->set_block( "'\\[comments-rating-type-1\\](.*?)\\[/comments-rating-type-1\\]'si", "" );
  211.         $tpl->set_block( "'\\[comments-rating-type-3\\](.*?)\\[/comments-rating-type-3\\]'si", "" );
  212.         $tpl->set_block( "'\\[comments-rating-type-4\\](.*?)\\[/comments-rating-type-4\\]'si", "" );
  213.     } elseif ( $config['comments_rating_type'] == "2" ) {
  214.         $tpl->set( '[comments-rating-type-3]', "" );
  215.         $tpl->set( '[/comments-rating-type-3]', "" );
  216.         $tpl->set_block( "'\\[comments-rating-type-1\\](.*?)\\[/comments-rating-type-1\\]'si", "" );
  217.         $tpl->set_block( "'\\[comments-rating-type-2\\](.*?)\\[/comments-rating-type-2\\]'si", "" );
  218.         $tpl->set_block( "'\\[comments-rating-type-4\\](.*?)\\[/comments-rating-type-4\\]'si", "" );
  219.     } elseif ( $config['comments_rating_type'] == "3" ) {
  220.         $tpl->set( '[comments-rating-type-4]', "" );
  221.         $tpl->set( '[/comments-rating-type-4]', "" );
  222.         $tpl->set_block( "'\\[comments-rating-type-1\\](.*?)\\[/comments-rating-type-1\\]'si", "" );
  223.         $tpl->set_block( "'\\[comments-rating-type-2\\](.*?)\\[/comments-rating-type-2\\]'si", "" );
  224.         $tpl->set_block( "'\\[comments-rating-type-3\\](.*?)\\[/comments-rating-type-3\\]'si", "" );
  225.     } else {
  226.         $tpl->set( '[comments-rating-type-1]', "" );
  227.         $tpl->set( '[/comments-rating-type-1]', "" );
  228.         $tpl->set_block( "'\\[comments-rating-type-4\\](.*?)\\[/comments-rating-type-4\\]'si", "" );
  229.         $tpl->set_block( "'\\[comments-rating-type-3\\](.*?)\\[/comments-rating-type-3\\]'si", "" );
  230.         $tpl->set_block( "'\\[comments-rating-type-2\\](.*?)\\[/comments-rating-type-2\\]'si", "" );   
  231.     }
  232.  
  233.     $tpl->set( '{rate}', userrating( $row['user_id'] ) );
  234.     $tpl->set( '{commentsrate}', commentsuserrating( $row['user_id'] ) );
  235.  
  236.     if( $row['signature'] and $user_group[$row['user_group']]['allow_signature'] ) {
  237.         $tpl->set_block( "'\\[signature\\](.*?)\\[/signature\\]'si", "\\1" );
  238.         $tpl->set( '{signature}', stripslashes( $row['signature'] ) );
  239.     } else {
  240.         $tpl->set_block( "'\\[signature\\](.*?)\\[/signature\\]'si", "" );
  241.     }
  242.  
  243.     if( $user_group[$row['user_group']]['icon'] ) $tpl->set( '{group-icon}', "<img src=\"" . $user_group[$row['user_group']]['icon'] . "\" border=\"0\" />" );
  244.     else $tpl->set( '{group-icon}', "" );
  245.  
  246.     if( $row['news_num'] ) {
  247.         if( $config['allow_alt_url'] ) {
  248.             $tpl->set( '{news}', "<a href=\"" . $config['http_home_url'] . "user/" . urlencode( $row['name'] ) . "/news/" . "\">" . $lang['all_user_news'] . "</a>" );
  249.             $tpl->set( '[rss]', "<a href=\"" . $config['http_home_url'] . "user/" . urlencode( $row['name'] ) . "/rss.xml" . "\" title=\"" . $lang['rss_user'] . "\">" );
  250.             $tpl->set( '[/rss]', "</a>" );     
  251.         } else {
  252.             $tpl->set( '{news}', "<a href=\"" . $PHP_SELF . "?subaction=allnews&amp;user=" . urlencode( $row['name'] ) . "\">" . $lang['all_user_news'] . "</a>" );
  253.             $tpl->set( '[rss]', "<a href=\"" . $PHP_SELF . "?mod=rss&amp;subaction=allnews&amp;user=" . urlencode( $row['name'] ) . "\" title=\"" . $lang['rss_user'] . "\">" );
  254.             $tpl->set( '[/rss]', "</a>" );
  255.         }
  256.  
  257.         $tpl->set( '{news-num}', number_format($row['news_num'], 0, ',', ' ') );
  258.         $tpl->set( '[news-num]', "" );
  259.         $tpl->set( '[/news-num]', "" );
  260.         $tpl->set_block( "'\\[not-news-num\\](.*?)\\[/not-news-num\\]'si", "" );
  261.     } else {
  262.         $tpl->set( '{news}', $lang['all_user_news'] );
  263.         $tpl->set_block( "'\\[rss\\](.*?)\\[/rss\\]'si", "" );
  264.         $tpl->set( '{news-num}', 0 );
  265.         $tpl->set_block( "'\\[news-num\\](.*?)\\[/news-num\\]'si", "" );
  266.         $tpl->set( '[not-news-num]', "" );
  267.         $tpl->set( '[/not-news-num]', "" );
  268.     }
  269.  
  270.     if( $row['comm_num'] ) {
  271.         $tpl->set( '{comments}', "<a href=\"$PHP_SELF?do=lastcomments&amp;userid=" . $row['user_id'] . "\">" . $lang['last_comm'] . "</a>" );
  272.  
  273.         $tpl->set( '[comm-num]', "" );
  274.         $tpl->set( '[/comm-num]', "" );
  275.         $tpl->set( '{comm-num}', number_format($row['comm_num'], 0, ',', ' ') );
  276.         $tpl->set_block( "'\\[not-comm-num\\](.*?)\\[/not-comm-num\\]'si", "" );
  277.     } else {
  278.         $tpl->set( '{comments}', $lang['last_comm'] );
  279.         $tpl->set( '{comm-num}', 0 );
  280.         $tpl->set_block( "'\\[comm-num\\](.*?)\\[/comm-num\\]'si", "" );
  281.         $tpl->set( '[not-comm-num]', "" );
  282.         $tpl->set( '[/not-comm-num]', "" );
  283.     }
  284.  
  285.     $tpl->compile( 'content' );
  286.  
  287.     $tpl->result['content'] = str_replace( '{THEME}', $config['http_home_url'] . 'templates/' . $config['skin'], $tpl->result['content'] );
  288.  
  289.     echo $tpl->result['content'];
  290.     //echo "<div id='dleprofilepopup' title='{$lang['p_user']} {$row['name']}' style='display:none'>{$tpl->result['content']}</div>";
  291. }
  292.  
  293. ?>
Advertisement
Add Comment
Please, Sign In to add comment