Social Engine 3 добавлять html

vave

Полезный
Регистрация
22 Июн 2007
Сообщения
466
Реакции
16
Как убрать удаление HTML из полей (SE3)

Хотел бы добавлять HTML код в поля SE3, например в поле профиля, где Имя и Фамилия,
profilevalue_2 и profilevalue_3
в базе вроде бы всё выставил верно для внесения HTML кода в бд
но где то работает код который убирает все лишние HTML символы, оставляя чистый текст.
вот код первого файла

PHP:
<?php

/* $Id: class_field.php 159 2009-04-11 01:18:28Z Lemance $ */

//  THIS CLASS CONTAINS FIELD-RELATED METHODS.
//  IT IS USED DURING THE CREATION, MODIFICATION AND DELETION OF FIELDS
//  METHODS IN THIS CLASS:
//    se_field()
//    cat_list()
//    field_list()
//    field_get()
//    field_save()
//    field_delete()
//    cat_delete()
//    cat_modify()



class se_field {

	// INITIALIZE VARIABLES
	var $is_error;			// DETERMINES WHETHER THERE IS AN ERROR OR NOT, CONTAINS RELEVANT ERROR CODE
	
	var $type;			// CONTAINS THE FIELD TYPE (PROFILE, PLUGIN-RELATED, ETC)
	var $value_info;		// CONTAINS THE VALUE INFO OF THE SPECIFIC OBJECT

	var $cats;			// CONTAINS ARRAY OF FIELD CATEGORIES WITH CORRESPONDING FIELD ARRAYS
	var $subcats;			// CONTAINS ARRAY OF FIELD SUB-CATEGORIES WITH CORRESPONDING FIELD ARRAYS
	var $fields;			// CONTAINS ARRAY OF FIELDS FROM CAT SPECIFIED
	var $fields_new;		// CONTAINS ARRAY OF NEW (UNSAVED) FIELD VALUES
	var $field_query;		// CONTAINS A PARTIAL DATABASE QUERY TO SAVE/RETRIEVE FIELD VALUES
	var $field_values;		// CONTAINS AN ARRAY OF FORMATTED FIELD VALUES (USED FOR GLOBAL META DESCRIPTIONS)
	var $fields_all;		// CONTAINS ARRAY OF FIELDS FROM ALL LOOPED CATS

	var $url_string;		// CONTAINS VARIOUS PARTIAL URL STRINGS (SITUATION DEPENDENT)

	var $field_special;		// CONTAINS VALUES FOR SPECIAL FIELDS



	// THIS METHOD SETS INITIAL VARS (SUCH AS FIELD TYPE)
	// INPUT: $type REPRESENTING THE TYPE OF FIELD (PROFILE, PLUGIN-RELATED, ETC)
	//	  $value_info (OPTIONAL) REPRESENTING THE VALUE INFO FOR THE GIVEN TYPE
	// OUTPUT:
	function se_field($type, $value_info = "") {

	  $this->type = $type;
	  $this->value_info = $value_info;

	} // END se_field() METHOD









	// THIS METHOD LOOPS AND/OR VALIDATES FIELD INPUT AND CREATES A PARTIAL QUERY TO UPDATE VALUE TABLE
	// INPUT: $validate (OPTIONAL) REPRESENTING A BOOLEAN THAT DETERMINES WHETHER TO VALIDATE POST VARS OR NOT
	//	  $format (OPTIONAL) REPRESENTING A BOOLEAN THAT DETERMINES WHETHER TO CREATE FORMATTED FIELD VALUES
	//	  $search (OPTIONAL) REPRESENTING WHETHER TO CREATE A SEARCH QUERY OR NOT
	//	  $cat_where (OPTIONAL) REPRESENTING A WHERE CLAUSE FOR THE CATEGORY QUERY
	//	  $subcat_where (OPTIONAL) REPRESENTING A WHERE CLAUSE FOR THE SUBCATEGORY QUERY
	//	  $field_where (OPTIONAL) REPRESENTING A WHERE CLAUSE FOR THE FIELD QUERY
	// OUTPUT: 
	function cat_list($validate = 0, $format = 0, $search = 0, $cat_where = "", $subcat_where = "", $field_where = "") {
	  global $database, $datetime, $setting;

	  // SET CATEGORY VARIABLES
	  $this->fields_all = Array();
	  $cat_query = "SELECT ".$this->type."cat_id AS cat_id, ".$this->type."cat_title AS cat_title, ".$this->type."cat_order AS cat_order, ".$this->type."cat_signup AS cat_signup FROM se_".$this->type."cats WHERE ".$this->type."cat_dependency='0'"; if($cat_where != "") { $cat_query .= " AND ($cat_where)"; } $cat_query .= " ORDER BY ".$this->type."cat_order";
	  $cats = $database->database_query($cat_query);

	  // LOOP THROUGH CATS
	  while($cat_info = $database->database_fetch_assoc($cats)) {

	    // GET LIST OF FIELDS
	    $cat_fields = "";
	    $new_field_where = $this->type."field_".$this->type."cat_id='$cat_info[cat_id]'";
	    if($field_where != "") { $new_field_where .= " AND ($field_where)"; }
	    $this->field_list($validate, $format, $search, $new_field_where);
	    $cat_fields = $this->fields;

	    // GET DEPENDENT CATS
	    $this->subcats = "";
	    $subcat_query = "SELECT ".$this->type."cat_id AS cat_id, ".$this->type."cat_title AS cat_title, ".$this->type."cat_order AS cat_order FROM se_".$this->type."cats WHERE ".$this->type."cat_dependency='$cat_info[cat_id]'"; if($subcat_where != "") { $subcat_query .= " AND ($subcat_where)"; } $subcat_query .= " ORDER BY ".$this->type."cat_order";
	    $subcats = $database->database_query($subcat_query);
	
	    // LOOP THROUGH SUBCATS
	    while($subcat_info = $database->database_fetch_assoc($subcats)) {

	      // GET LIST OF FIELDS
	      $new_field_where = $this->type."field_".$this->type."cat_id='$subcat_info[cat_id]'";
	      if($field_where != "") { $new_field_where .= " AND ($field_where)"; }
	      $this->field_list($validate, $format, $search, $new_field_where);

	      // SET CAT ARRAY
	      if($format == 0 || ($format == 1 && count($this->fields) != 0)) {
	        SE_Language::_preload($subcat_info[cat_title]);
	        $this->subcats[] = Array('subcat_id' => $subcat_info[cat_id], 
					'subcat_title' => $subcat_info[cat_title], 
					'subcat_order' => $subcat_info[cat_order],
					'subcat_signup' => $subcat_info[cat_signup],
					'fields' => $this->fields);
	      }
	    }

	    // SET CAT ARRAY
	    SE_Language::_preload($cat_info[cat_title]);
	    $this->cats[] = Array('cat_id' => $cat_info[cat_id], 
				'cat_title' => $cat_info[cat_title], 
				'cat_order' => $cat_info[cat_order],
				'cat_signup' => $cat_info[cat_signup],
				'fields' => $cat_fields,
				'subcats' => $this->subcats);
	  }

	} // END cat_list() METHOD









	// THIS METHOD LOOPS AND/OR VALIDATES FIELD INPUT AND CREATES A PARTIAL QUERY TO UPDATE VALUE TABLE
	// INPUT: $validate (OPTIONAL) REPRESENTING A BOOLEAN THAT DETERMINES WHETHER TO VALIDATE POST VARS OR NOT
	//	  $format (OPTIONAL) REPRESENTING A BOOLEAN THAT DETERMINES WHETHER TO CREATE FORMATTED FIELD VALUES
	//	  $search (OPTIONAL) REPRESENTING WHETHER TO CREATE A SEARCH QUERY OR NOT
	//	  $field_where (OPTIONAL) REPRESENTING A WHERE CLAUSE FOR THE FIELD QUERY
	// OUTPUT: 
	function field_list($validate = 0, $format = 0, $search = 0, $field_where = "") {
	  global $database, $datetime, $setting;

	  // GET NON DEPENDENT FIELDS IN CAT IF NECESSARY
	  $field_count = 0;
	  $this->fields = Array();
	  $field_query = "SELECT ".$this->type."field_id AS field_id, ".$this->type."field_order AS field_order, ".$this->type."field_title AS field_title, ".$this->type."field_desc AS field_desc, ".$this->type."field_signup AS field_signup, ".$this->type."field_error AS field_error, ".$this->type."field_type AS field_type, ".$this->type."field_style AS field_style, ".$this->type."field_maxlength AS field_maxlength, ".$this->type."field_link AS field_link, ".$this->type."field_options AS field_options, ".$this->type."field_required AS field_required, ".$this->type."field_regex AS field_regex, ".$this->type."field_special AS field_special, ".$this->type."field_html AS field_html, ".$this->type."field_search AS field_search, ".$this->type."field_display AS field_display FROM se_".$this->type."fields WHERE ".$this->type."field_dependency='0'"; if($field_where != "") { $field_query .= " AND ($field_where)"; } $field_query .= " ORDER BY ".$this->type."field_order";
	  $fields = $database->database_query($field_query);

	  while($field_info = $database->database_fetch_assoc($fields)) {

	    // SET FIELD VARS
	    $is_field_error = 0;
	    $field_value = "";
	    $field_value_formatted = "";
	    $field_value_min = "";
	    $field_value_max = "";
	    $field_options = Array();

	    // FIELD TYPE SWITCH
	    switch($field_info[field_type]) {

	      case 1: // TEXT FIELD
	      case 2: // TEXTAREA

	        // VALIDATE POSTED FIELD VALUE
	        if($validate == 1) {

	          // RETRIEVE POSTED FIELD VALUE AND FILTER FOR ADMIN-SPECIFIED HTML TAGS
	          $var = "field_".$field_info[field_id];
	          $field_value = security(cleanHTML(censor($_POST[$var]), $field_info[field_html]));

	          if($field_info[field_type] == 2) { $field_value = str_replace("\r\n", "<br>", $field_value); }

	          // CHECK FOR REQUIRED
	          if($field_info[field_required] != 0 && trim($field_value) == "") {
	            $this->is_error = 96;
	            $is_field_error = 1;
	          }

	          // RUN PREG MATCH (ONLY FOR TEXT FIELDS)
	          if($field_info[field_regex] != "" && trim($field_value) != "") {
	            if(!preg_match($field_info[field_regex], $field_value)) {
	              $this->is_error = 97;
	              $is_field_error = 1;
	            }
	          }

	          // UPDATE SAVE VALUE QUERY
	          if($this->field_query != "") { $this->field_query .= ", "; }
		  if($field_info[field_special] == 2 || $field_info[field_special] == 3) { $field_value = ucwords($field_value); }
	          $this->field_query .= $this->type."value_$field_info[field_id]='$field_value'";


		// CREATE A SEARCH QUERY FROM POSTED FIELD VALUE
		} elseif($search == 1) {
		  if($field_info[field_search] == 2) {
		    $var1 = "field_".$field_info[field_id]."_min";
		    if(isset($_POST[$var1])) { $field_value_min = $_POST[$var1]; } elseif(isset($_GET[$var1])) { $field_value_min = $_GET[$var1]; } else { $field_value_min = ""; }
		    $var2 = "field_".$field_info[field_id]."_max";
		    if(isset($_POST[$var2])) { $field_value_max = $_POST[$var2]; } elseif(isset($_GET[$var2])) { $field_value_max = $_GET[$var2]; } else { $field_value_max = ""; }
		    if($field_value_min != "") { 
		      if($this->field_query != "") { $this->field_query .= " AND "; } 
		      $this->field_query .= $this->type."value_$field_info[field_id] >= $field_value_min"; 
		      $this->url_string .= $var1."=".urlencode($field_value_min)."&";
		    }
		    if($field_value_max != "") { 
		      if($this->field_query != "") { $this->field_query .= " AND "; } 
		      $this->field_query .= $this->type."value_$field_info[field_id] <= $field_value_max"; 
		      $this->url_string .= $var2."=".urlencode($field_value_max)."&";
		    }
		  } elseif($field_info[field_search] == 1) {
		    $var = "field_".$field_info[field_id];
		    if(isset($_POST[$var])) { $field_value = $_POST[$var]; } elseif(isset($_GET[$var])) { $field_value = $_GET[$var]; } else { $field_value = ""; }
		    if($field_value != "") { 
		      if($this->field_query != "") { $this->field_query .= " AND "; } 
		      $this->field_query .= $this->type."value_$field_info[field_id] LIKE '%$field_value%'"; 
		      $this->url_string .= $var."=".urlencode($field_value)."&";
		    }
		  } else {
		    $field_value = "";
		  }

		// DO NOT VALIDATE FIELD VALUE AND DON'T CREATE SEARCH VALUE
	        } else {
	          // RETRIEVE DATABASE FIELD VALUE
	          if($this->value_info != "") {
	            $value_column = $this->type."value_".$field_info[field_id];
	            $field_value = $this->value_info[$value_column];
	          }
	        }

		// FORMAT VALUE FOR DISPLAY
		if($format == 1 && $field_info[field_display] != 0) {

		  // LINK BROWSABLE FIELD VALUES IF NECESSARY
		  if($field_info[field_display] == 2) {
		    $br_exploded_field_values = explode("<br>", trim($field_value));
		    $exploded_field_values = Array();
		    foreach($br_exploded_field_values as $key => $value) {
		      $comma_exploded_field_values = explode(",", trim($value));
		      array_walk($comma_exploded_field_values, 'link_field_values', Array($field_info[field_id], "", $field_info[field_link], $field_info[field_display]));
		      $exploded_field_values[$key] = implode(", ", $comma_exploded_field_values);
		    }
		    $field_value_formatted = implode("<br>", $exploded_field_values);

		  // MAKE SURE TO LINK FIELDS WITH A LINK TAG
		  } else {
		    $exploded_field_values = Array(trim($field_value));
		    array_walk($exploded_field_values, 'link_field_values', Array($field_info[field_id], "", $field_info[field_link], $field_info[field_display]));
		    $field_value_formatted = implode("", $exploded_field_values);
		  }

		  // DECODE TO MAKE HTML TAGS FOR FIELDS VALID
		  $field_value_formatted = htmlspecialchars_decode($field_value_formatted, ENT_QUOTES);

		// FORMAT VALUE FOR FORM
		} else {
		  if($field_info[field_type] == 1) { 
		    $options = unserialize($field_info[field_options]);
		    for($i=0,$max=count($options);$i<$max;$i++) {
		      SE_Language::_preload_multi($options[$i][label]);
		      SE_Language::load();
		      $field_options[] = Array('label'=>SE_Language::_get($options[$i][label]));
		    }
		  }
		  if($field_info[field_type] == 2) { $field_value = str_replace("<br>", "\r\n", $field_value); }
		}
	        break;



	      case 3: // SELECT BOX
	      case 4: // RADIO BUTTON

	        // VALIDATE POSTED FIELD
	        if($validate == 1) {

	          // RETRIEVE POSTED FIELD VALUE
	          $var = "field_".$field_info[field_id];
	          $field_value = censor($_POST[$var]);

	          // CHECK FOR REQUIRED
	          if($field_info[field_required] != 0 && ($field_value == "-1" || $field_value == "")) {
	            $this->is_error = 96;
	            $is_field_error = 1;
	          }

	          // UPDATE SAVE VALUE QUERY
	          if($this->field_query != "") { $this->field_query .= ", "; }
	          $this->field_query .= $this->type."value_$field_info[field_id]='$field_value'";

		// CREATE A SEARCH QUERY FROM POSTED FIELD VALUE
		} elseif($search == 1) {
		  if($field_info[field_search] == 2) {
		    $var1 = "field_".$field_info[field_id]."_min";
		    if(isset($_POST[$var1])) { $field_value_min = $_POST[$var1]; } elseif(isset($_GET[$var1])) { $field_value_min = $_GET[$var1]; } else { $field_value_min = ""; }
		    $var2 = "field_".$field_info[field_id]."_max";
		    if(isset($_POST[$var2])) { $field_value_max = $_POST[$var2]; } elseif(isset($_GET[$var2])) { $field_value_max = $_GET[$var2]; } else { $field_value_max = ""; }
		    if($field_value_min != "" && $field_value_min != "-1") { 
		      if($this->field_query != "") { $this->field_query .= " AND "; } 
		      $this->field_query .= $this->type."value_$field_info[field_id] >= $field_value_min"; 
		      $this->url_string .= $var1."=".urlencode($field_value_min)."&";
		    }
		    if($field_value_max != "" && $field_value_max != "-1") { 
		      if($this->field_query != "") { $this->field_query .= " AND "; } 
		      $this->field_query .= $this->type."value_$field_info[field_id] <= $field_value_max"; 
		      $this->url_string .= $var2."=".urlencode($field_value_max)."&";
		    }
		  } elseif($field_info[field_search] == 1) {
		    $var = "field_".$field_info[field_id];
		    if(isset($_POST[$var])) { $field_value = $_POST[$var]; } elseif(isset($_GET[$var])) { $field_value = $_GET[$var]; } else { $field_value = ""; }
	            if($field_value != "-1" && $field_value != "") { 
		      if($this->field_query != "") { $this->field_query .= " AND "; } 
		      $this->field_query .= $this->type."value_$field_info[field_id]='$field_value'"; 
		      $this->url_string .= $var."=".urlencode($field_value)."&";
		    }
		  } else {
		    $field_value = "";
		  }

		// DO NOT VALIDATE FIELD VALUE AND DON'T CREATE SEARCH VALUE
	        } else {
	          // RETRIEVE DATABASE FIELD VALUE
	          if($this->value_info != "") {
	            $value_column = $this->type."value_".$field_info[field_id];
	            $field_value = $this->value_info[$value_column];
	          }
	        }

	        // LOOP OVER FIELD OPTIONS
	        $options = unserialize($field_info[field_options]);
	        for($i=0,$max=count($options);$i<$max;$i++) {
	          $dep_field_info = "";
	          $dep_field_value = "";
		  $dep_field_options = "";

	          // OPTION HAS DEPENDENCY
	          if($options[$i][dependency] == "1") { 
		    $dep_field_query = "SELECT ".$this->type."field_id AS field_id, ".$this->type."field_type AS field_type, ".$this->type."field_title AS field_title, ".$this->type."field_style AS field_style, ".$this->type."field_options AS field_options, ".$this->type."field_maxlength AS field_maxlength, ".$this->type."field_link AS field_link, ".$this->type."field_required AS field_required, ".$this->type."field_regex AS field_regex, ".$this->type."field_display AS field_display FROM se_".$this->type."fields WHERE ".$this->type."field_id='".$options[$i][dependent_id]."' AND ".$this->type."field_dependency='$field_info[field_id]'";
	            $dep_field = $database->database_query($dep_field_query);
	            if($database->database_num_rows($dep_field) != "1") {
	              $options[$i][dependency] = 0;
	            } else {
	              $dep_field_info = $database->database_fetch_assoc($dep_field);
	
	              // VALIDATE POSTED FIELD VALUE
	              if($validate == 1) {
	                // OPTION SELECTED
	                if($field_value == $options[$i][value]) {
	                  $dep_var = "field_".$dep_field_info[field_id];
	                  $dep_field_value = censor($_POST[$dep_var]);

			  // DEP FIELD TYPE
			  switch($dep_field_info[field_type]) {

			    // TEXT FIELD
			    case "1":
  
		              // CHECK FOR REQUIRED
	                      if($dep_field_info[field_required] != 0 && trim($dep_field_value) == "") {
	                        $this->is_error = 96;
	                        $is_field_error = 1;
	                      }

	                      // RUN PREG MATCH
	                      if($dep_field_info[field_regex] != "" && trim($dep_field_value) != "") {
	                        if(!preg_match($dep_field_info[field_regex], $dep_field_value)) {
	                          $this->is_error = 97;
	                          $is_field_error = 1;
	                        }
	                      }
			      break;

			    // SELECT BOX
			    case "3":
			    
		              // CHECK FOR REQUIRED
		              if( $dep_field_info['field_required'] != 0 && ($dep_field_value == "-1" || $dep_field_value == "") )
                  { 
		                $this->is_error = 96;
                    $is_field_error = 1;
		              }
			      break;
			  }	

	                // OPTION NOT SELECTED
	                } else {
	                  $dep_field_value = "";
	                }

	 	        // UPDATE SAVE VALUE QUERY
	    	        if($this->field_query != "") { $this->field_query .= ", "; }
	  	        $this->field_query .= $this->type."value_$dep_field_info[field_id]='$dep_field_value'";

		      // DO NOT VALIDATE POSTED FIELD VALUE
	              } else {
	                // RETRIEVE DATABASE FIELD VALUE
	                if($this->value_info != "") {
	                  $value_column = $this->type."value_".$dep_field_info[field_id];
	                  $dep_field_value = $this->value_info[$value_column];
	                }
	              }

		      // RETRIEVE DEP FIELD OPTIONS
		      $dep_options = unserialize($dep_field_info[field_options]);
		      for($i2=0,$max2=count($dep_options);$i2<$max2;$i2++) {
			SE_Language::_preload($dep_options[$i2][label]);
			$dep_field_options[] = Array('value' => $dep_options[$i2][value],
							'label' => $dep_options[$i2][label]);
			if($dep_options[$i2][value] == $dep_field_value) { $dep_field_value_formatted = $dep_options[$i2][label]; }
		      }
	            }
		  }

		  // FORMAT VALUE FOR DISPLAY IF OPTION IS SELECTED
		  if($format == 1 && $field_value == $options[$i][value] && $field_info[field_display] != 0) {
	            SE_Language::_preload_multi($dep_field_info[field_title], $options[$i][label]);
		    SE_Language::load();
		    $field_value_formatted = SE_Language::_get($options[$i][label]);

		    // LINK FIELD VALUES IF NECESSARY
		    if($field_info[field_display] == 2) { 
		      link_field_values($field_value_formatted, "", Array($field_info[field_id], $options[$i][value], "", $field_info[field_display])); 
		    }

		    // ADD DEPENDENT VALUE TO FIELD VALUE
		    if($dep_field_value != "" && $dep_field_info[field_display] != 0) { 
		      if($dep_field_info[field_type] == 3) { $dep_field_value_formatted = SE_Language::_get($dep_field_value_formatted); } else { $dep_field_value_formatted = $dep_field_value; }
		      link_field_values($dep_field_value_formatted, "", Array($dep_field_info[field_id], $dep_field_value, $dep_field_info[field_link], $dep_field_info[field_display]));
		      $field_value_formatted .= " ".SE_Language::_get($dep_field_info[field_title])." ".$dep_field_value_formatted;
		    }

		  }
          
	          // SET OPTIONS ARRAY
		  SE_Language::_preload_multi($dep_field_info[field_title], $options[$i][label]);
	          $field_options[] = Array('value' => $options[$i][value],
						'label' => $options[$i][label],
						'dependency' => $options[$i][dependency],
						'dep_field_id' => $dep_field_info[field_id],
						'dep_field_title' => $dep_field_info[field_title],
						'dep_field_type' => $dep_field_info[field_type],
						'dep_field_required' => $dep_field_info[field_required],
						'dep_field_maxlength' => $dep_field_info[field_maxlength],
						'dep_field_options' => $dep_field_options,
						'dep_field_style' => $dep_field_info[field_style],
						'dep_field_value' => $dep_field_value,
						'dep_field_error' => $dep_field_error);
	        }
	        break;


	      case 5: // DATE FIELD

		// SET MONTH, DAY, AND YEAR FORMAT FROM SETTINGS
		switch($setting[setting_dateformat]) {
		  case "n/j/Y": case "n.j.Y": case "n-j-Y": $month_format = "n"; $day_format = "j"; $year_format = "Y"; $date_order = "mdy"; break;
		  case "Y/n/j": case "Ynj": $month_format = "n"; $day_format = "j"; $year_format = "Y"; $date_order = "ymd"; break;
		  case "Y-n-d": $month_format = "n"; $day_format = "d"; $year_format = "Y"; $date_order = "ymd"; break;
		  case "Y-m-d": $month_format = "m"; $day_format = "d"; $year_format = "Y"; $date_order = "ymd"; break;
		  case "j/n/Y": case "j.n.Y": $month_format = "n"; $day_format = "j"; $year_format = "Y"; $date_order = "dmy"; break;
		  case "M. j, Y": $month_format = "M"; $day_format = "j"; $year_format = "Y"; $date_order = "mdy"; break;
		  case "F j, Y": case "l, F j, Y": $month_format = "F"; $day_format = "j"; $year_format = "Y"; $date_order = "mdy"; break;
		  case "j F Y": case "D j F Y": case "l j F Y": $month_format = "F"; $day_format = "j"; $year_format = "Y"; $date_order = "dmy"; break;
		  case "D-j-M-Y": case "D j M Y": case "j-M-Y": $month_format = "M"; $day_format = "j"; $year_format = "Y"; $date_order = "dmy"; break;
		  case "Y-M-j": $month_format = "M"; $day_format = "j"; $year_format = "Y"; $date_order = "ymd"; break;
		}
  

	        // VALIDATE POSTED VALUE
	        if($validate == 1) {
	          // RETRIEVE POSTED FIELD VALUE
	          $var1 = "field_".$field_info[field_id]."_1";
	          $var2 = "field_".$field_info[field_id]."_2";
	          $var3 = "field_".$field_info[field_id]."_3";
	          $field_1 = $_POST[$var1];
	          $field_2 = $_POST[$var2];
	          $field_3 = $_POST[$var3];

	          // ORDER DATE VALUES PROPERLY
	          switch($date_order) {
	            case "mdy": $month = $field_1; $day = $field_2; $year = $field_3; break;
	            case "ymd": $year = $field_1; $month = $field_2; $day = $field_3; break;
	            case "dmy": $day = $field_1; $month = $field_2; $year = $field_3; break;
	          }
  
		  // CONSTRUCT FIELD VALUE
		  $field_value = str_pad($year, 4, '0', STR_PAD_LEFT)."-".str_pad($month, 2, '0', STR_PAD_LEFT).'-'.str_pad($day, 2, '0', STR_PAD_LEFT);

	          // CHECK FOR REQUIRED
            if( $field_info['field_required'] && ($month == "00" || $day == "00" || $year == "00") )
            { 
	            $this->is_error = 96;
	            $is_field_error = 1;
	          }

	          // UPDATE SAVE VALUE QUERY
	          if($this->field_query != "") { $this->field_query .= ", "; }
	          $this->field_query .= $this->type."value_$field_info[field_id]='$field_value'";


		// CREATE A SEARCH QUERY FROM POSTED FIELD VALUE
		} elseif($search == 1) {
		  
		  // DATE IS A BIRTHDAY
		  if($field_info[field_special] == 1) { 

		    // RESET DATE ORDER SO MONTH IS LAST
		    $date_order = "mdy"; 

		    // RETRIEVE MIN/MAX YEARS
		    $var3_min = "field_".$field_info[field_id]."_3_min";
		    $var3_max = "field_".$field_info[field_id]."_3_max";
		    if(isset($_POST[$var3_min])) { $field_3_min = $_POST[$var3_min]; } elseif(isset($_GET[$var3_min])) { $field_3_min = $_GET[$var3_min]; } else { $field_3_min = ""; }
		    if(isset($_POST[$var3_max])) { $field_3_max = $_POST[$var3_max]; } elseif(isset($_GET[$var3_max])) { $field_3_max = $_GET[$var3_max]; } else { $field_3_max = ""; }

		    $this->url_string .= $var3_min."=".urlencode($field_3_min)."&";
		    $this->url_string .= $var3_max."=".urlencode($field_3_max)."&";

		    // CONSTRUCT SEARCH VALUES (MIN YEAR)
		    // IMPORTANT NOTE - BECAUSE IT DISPLAYS THE AGE (NOT THE YEAR) TO THE SEARCHER, THIS ACTUALLY CORRESPONDS TO THE MINIMUM AGE (MAXIMUM YEAR)
		    $field_value_min = str_pad($field_3_min, 4, '0', STR_PAD_LEFT);
	            if($field_value_min != "0000") {
		      if($this->field_query != "") { $this->field_query .= " AND "; } 
		      $this->field_query .= $this->type."value_$field_info[field_id]<='$field_value_min-".date('m', time())."-".date('d', time())."'"; 
		    }

		    // CONSTRUCT SEARCH VALUES (MAX YEAR)
		    // IMPORTANT NOTE - BECAUSE IT DISPLAYS THE AGE (NOT THE YEAR) TO THE SEARCHER, THIS ACTUALLY CORRESPONDS TO THE MAXIMUM AGE (MINIMUM YEAR)
		    $field_value_max = str_pad($field_3_max, 4, '0', STR_PAD_LEFT);
	            if($field_value_max != "0000") {
		      if($this->field_query != "") { $this->field_query .= " AND "; } 
		      $this->field_query .= $this->type."value_$field_info[field_id]>=DATE_ADD('".($field_value_max-1)."-".date('m', time())."-".date('d', time())."', INTERVAL 1 DAY)"; 
		    }

		    // EXCLUDE USERS WHO HAVE NOT ENTERED A BIRTH YEAR
		    if($field_value_min != "0000" || $field_value_max != "0000") {
		      if($this->field_query != "") { $this->field_query .= " AND "; } 
		      $this->field_query .= "YEAR(".$this->type."value_$field_info[field_id])<>'0000'"; 
		    }


		  // DATE IS NOT A BIRTHDAY
		  } else {

		    // RETRIEVE VALUES
	            $var1 = "field_".$field_info[field_id]."_1";
	            $var2 = "field_".$field_info[field_id]."_2";
	            $var3 = "field_".$field_info[field_id]."_3";
		    if(isset($_POST[$var1])) { $field_1 = $_POST[$var1]; } elseif(isset($_GET[$var1])) { $field_1 = $_GET[$var1]; } else { $field_1 = ""; }
		    if(isset($_POST[$var2])) { $field_2 = $_POST[$var2]; } elseif(isset($_GET[$var2])) { $field_2 = $_GET[$var2]; } else { $field_2 = ""; }
		    if(isset($_POST[$var3])) { $field_3 = $_POST[$var3]; } elseif(isset($_GET[$var3])) { $field_3 = $_GET[$var3]; } else { $field_3 = ""; }

		    $this->url_string .= $var1."=".urlencode($field_1)."&";
		    $this->url_string .= $var2."=".urlencode($field_2)."&";
		    $this->url_string .= $var3."=".urlencode($field_3)."&";

	            // ORDER DATE VALUES PROPERLY
	            switch($date_order) {
	              case "mdy": $month = str_pad($field_1, 2, '0', STR_PAD_LEFT); $day = str_pad($field_2, 2, '0', STR_PAD_LEFT); $year = str_pad($field_3, 4, '0', STR_PAD_LEFT); break;
	              case "ymd": $year = str_pad($field_1, 4, '0', STR_PAD_LEFT); $month = str_pad($field_2, 2, '0', STR_PAD_LEFT); $day = str_pad($field_3, 2, '0', STR_PAD_LEFT); break;
	              case "dmy": $day = str_pad($field_1, 2, '0', STR_PAD_LEFT); $month = str_pad($field_2, 2, '0', STR_PAD_LEFT); $year = str_pad($field_3, 4, '0', STR_PAD_LEFT); break;
	            }
  
		    // CONSTRUCT FIELD VALUE
		    $field_value = $year."-".$month.'-'.$day;

	            if($month != "00") {
		      if($this->field_query != "") { $this->field_query .= " AND "; } 
		      $this->field_query .= "MONTH(".$this->type."value_$field_info[field_id])='$month'"; 
		    }
	            if($day != "00") {
		      if($this->field_query != "") { $this->field_query .= " AND "; } 
		      $this->field_query .= "DAY(".$this->type."value_$field_info[field_id])='$day'"; 
		    }
	            if($year != "0000") {
		      if($this->field_query != "") { $this->field_query .= " AND "; } 
		      $this->field_query .= "YEAR(".$this->type."value_$field_info[field_id])='$year'"; 
		    }

		  }

		// DO NOT VALIDATE FIELD VALUE AND DON'T CREATE SEARCH VALUE
	        } else {
	          // RETRIEVE DATABASE FIELD VALUE
	          if($this->value_info != "") {
	            $value_column = $this->type."value_".$field_info[field_id];
	            $field_value = $this->value_info[$value_column];
	          } else {
	            $field_value = "0000-00-00";
	          }
	        }

	        $year = substr($field_value, 0, 4); 
		$month = substr($field_value, 5, 2); 
		$day = substr($field_value, 8, 2); 

		// FORMAT VALUE FOR DISPLAY
		if($format == 1 && $field_info[field_display] != 0) {
	   	  if($field_value != "0000-00-00") { 
		    if($year == "0000") { $year = ""; }
		    if($month == "00") { $month = ""; } else { $month = $datetime->cdate("F", mktime(0, 0, 0, $month, 1, 1990)); }
		    if($day == "00") { $day = ""; } else { $day = $datetime->cdate("$day_format", mktime(0, 0, 0, 1, $day, 1990)); }
	            switch($date_order) {
	              case "mdy": $field_value_formatted = "$month $day $year"; break;
	              case "ymd": $field_value_formatted = "$year $month $day"; break;
	              case "dmy": $field_value_formatted = "$day $month $year"; break;
	            }
		    if($field_info[field_display] == 2) { link_field_values($field_value_formatted, "", Array($field_info[field_id], $field_value, "", $field_info[field_display])); }
		  }


		// FORMAT VALUE FOR FORM
	    	} else {

		  // GET LANGUAGE VARS
		  SE_Language::_preload_multi(579, 580, 581);

	          // CONSTRUCT MONTH ARRAY
	          $month_array = Array();
	          $month_array[0] = Array('name' => "579", 'value' => "0", 'selected' => "");
	          for($m=1;$m<=12;$m++) {
	            if($month == $m) { $selected = " SELECTED"; } else { $selected = ""; }
	            $month_array[$m] = Array('name' => $datetime->cdate("$month_format", mktime(0, 0, 0, $m, 1, 1990)),
	  					'value' => $m,
	    					'selected' => $selected);
	          }
  
	          // CONSTRUCT DAY ARRAY
	          $day_array = Array();
	          $day_array[0] = Array('name' => "580", 'value' => "0", 'selected' => "");
	          for($d=1;$d<=31;$d++) {
	            if($day == $d) { $selected = " SELECTED"; } else { $selected = ""; }
	            $day_array[$d] = Array('name' => $datetime->cdate("$day_format", mktime(0, 0, 0, 1, $d, 1990)),
	    					'value' => $d,
	    					'selected' => $selected);
	          }

	          // CONSTRUCT YEAR ARRAY
	          $year_array = Array();
	          $year_count = 1;
	          $current_year = $datetime->cdate("Y", time());
	          $year_array[0] = Array('name' => "581", 'value' => "0", 'selected' => "");
	          for($y=$current_year;$y>=1920;$y--) {
	            if($year == $y) { $selected = " SELECTED"; } else { $selected = ""; }
	            $year_array[$year_count] = Array('name' => $y,
	    						'value' => $y,
	    						'selected' => $selected);
	            $year_count++;
	          }

	          // ORDER DATE ARRAYS PROPERLY
	          switch($date_order) {
	            case "mdy": $date_array1 = $month_array; $date_array2 = $day_array; $date_array3 = $year_array; break;
	            case "ymd": $date_array1 = $year_array; $date_array2 = $month_array; $date_array3 = $day_array; break;
	            case "dmy": $date_array1 = $day_array; $date_array2 = $month_array; $date_array3 = $year_array; break;
	          }
		}

	        break;



	      case 6: // CHECKBOXES

	        // VALIDATE POSTED FIELD
	        if($validate == 1) {
	          // RETRIEVE POSTED FIELD VALUE
	          $var = "field_".$field_info[field_id];
	          $field_value = $_POST[$var];

	          // CHECK FOR REQUIRED
	          if($field_info[field_required] != 0 && count($field_value) == 0) {
	            $this->is_error = 96;
	            $is_field_error = 1;
	          }

	          // UPDATE SAVE VALUE QUERY
	          if($this->field_query != "") { $this->field_query .= ", "; }
	          $this->field_query .= $this->type."value_$field_info[field_id]='".implode(",", $field_value)."'";

		// CREATE A SEARCH QUERY FROM POSTED FIELD VALUE
		} elseif($search == 1) {
		  $var = "field_".$field_info[field_id];
		  if(isset($_POST[$var])) { $field_value = $_POST[$var]; } elseif(isset($_GET[$var])) { $field_value = $_GET[$var]; } else { $field_value = ""; }
	          if(count($field_value) != 0 && $field_value != "") { 
		    for($o=0;$o<count($field_value);$o++) {
		      if($this->field_query != "") { $this->field_query .= " AND "; } 
		      $this->field_query .= "FIND_IN_SET('".$field_value[$o]."', ".$this->type."value_$field_info[field_id])"; 
		      $this->url_string .= $var."[]=".urlencode($field_value[$o])."&";
		    }
		  }


		// DO NOT VALIDATE FIELD VALUE AND DON'T CREATE SEARCH VALUE
	        } else {
	          // RETRIEVE DATABASE FIELD VALUE
	          if($this->value_info != "") {
	            $value_column = $this->type."value_".$field_info[field_id];
	            $field_value = explode(",", $this->value_info[$value_column]);
	          }
	        }

	        // LOOP OVER FIELD OPTIONS
	        $options = unserialize($field_info[field_options]);
	        for($i=0,$max=count($options);$i<$max;$i++) {
	          $dep_field_info = "";
	          $dep_field_value = "";
		  $dep_field_options = "";

	          // OPTION HAS DEPENDENCY
	          if($options[$i][dependency] == "1") { 
		    $dep_field_query = "SELECT ".$this->type."field_id AS field_id, ".$this->type."field_type AS field_type, ".$this->type."field_title AS field_title, ".$this->type."field_style AS field_style, ".$this->type."field_options AS field_options, ".$this->type."field_maxlength AS field_maxlength, ".$this->type."field_link AS field_link, ".$this->type."field_required AS field_required, ".$this->type."field_regex AS field_regex, ".$this->type."field_display AS field_display FROM se_".$this->type."fields WHERE ".$this->type."field_id='".$options[$i][dependent_id]."' AND ".$this->type."field_dependency='$field_info[field_id]'";
	            $dep_field = $database->database_query($dep_field_query);
	            if($database->database_num_rows($dep_field) != "1") {
	              $options[$i][dependency] = 0;
	            } else {
	              $dep_field_info = $database->database_fetch_assoc($dep_field);
	
	              // VALIDATE POSTED FIELD VALUE
	              if($validate == 1) {
	                // OPTION SELECTED
	                if(in_array($options[$i][value], $field_value)) {
	                  $dep_var = "field_".$dep_field_info[field_id];
	                  $dep_field_value = censor($_POST[$dep_var]);
  
			  // DEP FIELD TYPE
			  switch($dep_field_info[field_type]) {

			    // TEXT FIELD
			    case "1":
  
		              // CHECK FOR REQUIRED
	                      if($dep_field_info[field_required] != 0 && trim($dep_field_value) == "") {
	                        $this->is_error = 96;
	                        $is_field_error = 1;
	                      }

	                      // RUN PREG MATCH
	                      if($dep_field_info[field_regex] != "" && trim($dep_field_value) != "") {
	                        if(!preg_match($dep_field_info[field_regex], $dep_field_value)) {
	                          $this->is_error = 97;
	                          $is_field_error = 1;
	                        }
	                      }
			      break;

			    // SELECT BOX
			    case "3":
			    
		              // CHECK FOR REQUIRED
		              if( $dep_field_info['field_required'] != 0 && ($dep_field_value == "-1" || $dep_field_value == "") )
                  {
		                $this->is_error = 96;
                    $is_field_error = 1;
		              }
			      break;
			  }

	                // OPTION NOT SELECTED
	                } else {
	                  $dep_field_value = "";
	                }

	 	        // UPDATE SAVE VALUE QUERY
	    	        if($this->field_query != "") { $this->field_query .= ", "; }
	  	        $this->field_query .= $this->type."value_$dep_field_info[field_id]='$dep_field_value'";

		      // DO NOT VALIDATE POSTED FIELD VALUE
	              } else {
	                // RETRIEVE DATABASE FIELD VALUE
	                if($this->value_info != "") {
	                  $value_column = $this->type."value_".$dep_field_info[field_id];
	                  $dep_field_value = $this->value_info[$value_column];
	                }
	              }

		      // RETRIEVE DEP FIELD OPTIONS
		      $dep_options = unserialize($dep_field_info[field_options]);
		      for($i2=0,$max2=count($dep_options);$i2<$max2;$i2++) {
			SE_Language::_preload($dep_options[$i2][label]);
			$dep_field_options[] = Array('value' => $dep_options[$i2][value],
							'label' => $dep_options[$i2][label]);
			if($dep_options[$i2][value] == $dep_field_value) { $dep_field_value_formatted = $dep_options[$i2][label]; }
		      }
	            }
		  }

		  // FORMAT VALUE FOR DISPLAY IF OPTION IS SELECTED
		  if($format == 1 && in_array($options[$i][value], $field_value) && $field_info[field_display] != 0) {
	            SE_Language::_preload_multi($dep_field_info[field_title], $options[$i][label]);
		    SE_Language::load();
		    $formatted_prelim = SE_Language::_get($options[$i][label]);

		    // LINK FIELD VALUES IF NECESSARY
		    if($field_info[field_display] == 2) { 
		      link_field_values($formatted_prelim, "", Array($field_info[field_id], $options[$i][value], "", $field_info[field_display])); 
		    }

		    // ADD DEPENDENT VALUE TO FIELD VALUE
		    if($dep_field_value != "" && $dep_field_info[field_display] != 0) { 
		      if($dep_field_info[field_type] == 3) { $dep_field_value_formatted = SE_Language::_get($dep_field_value_formatted); } else { $dep_field_value_formatted = $dep_field_value; }
		      link_field_values($dep_field_value_formatted, "", Array($dep_field_info[field_id], $dep_field_value, $dep_field_info[field_link], $dep_field_info[field_display]));
		      $field_value_formatted .= " ".SE_Language::_get($dep_field_info[field_title])." ".$dep_field_value_formatted;
		    }

		    if(trim($field_value_formatted) != "") { $field_value_formatted .= ", "; }
		    $field_value_formatted .= $formatted_prelim;
		  }
          
	          // SET OPTIONS ARRAY
		  SE_Language::_preload_multi($dep_field_info[field_title], $options[$i][label]);
	          $field_options[] = Array('value' => $options[$i][value],
						'label' => $options[$i][label],
						'dependency' => $options[$i][dependency],
						'dep_field_id' => $dep_field_info[field_id],
						'dep_field_title' => $dep_field_info[field_title],
						'dep_field_type' => $dep_field_info[field_type],
						'dep_field_required' => $dep_field_info[field_required],
						'dep_field_maxlength' => $dep_field_info[field_maxlength],
						'dep_field_options' => $dep_field_options,
						'dep_field_style' => $dep_field_info[field_style],
						'dep_field_value' => $dep_field_value,
						'dep_field_error' => $dep_field_error);
	        }
	        break;

	    }

	    // SET FIELD ERROR IF ERROR OCCURRED
	    if($is_field_error == 1) { $field_error = $field_info[field_error]; } else { $field_error = 0; }

	    // SET FIELD VALUE ARRAY FOR LATER USE 
// FIX THIS FOR CHECKBOXES (USED FOR SUBNETS?)
	    $this->fields_new[$this->type."value_".$field_info[field_id]] = $field_value;

	    // SET SPECIAL FIELDS, IF NECESSARY
	    if($field_info[field_special] != 0) { $this->field_special[$field_info[field_special]] = $field_value; }

	    // SAVE FORMATTED FIELD VALUE IN ARRAY
	    if($field_value_formatted != "") { $this->field_values[] = $field_value_formatted; }

	    // SET FIELD ARRAY AND INCREMENT FIELD COUNT
	    if(($format == 0 && $search == 0) || ($format == 1 && $field_value_formatted != "") || ($search == 1 && $field_info[field_search] != 0)) {
	      SE_Language::_preload_multi($field_info[field_title], $field_info[field_desc], $field_info[field_error]);
	      
	      $this->fields[] = 
	      $this->fields_all[] = Array('field_id' => $field_info[field_id], 
					'field_title' => $field_info[field_title], 
					'field_desc' => $field_info[field_desc],
					'field_type' => $field_info[field_type],
					'field_required' => $field_info[field_required],
					'field_style' => $field_info[field_style],
					'field_maxlength' => $field_info[field_maxlength],
					'field_special' => $field_info[field_special],
					'field_signup' => $field_info[field_signup],
					'field_search' => $field_info[field_search],
					'field_options' => $field_options,
					'field_value' => $field_value,
					'field_value_formatted' => $field_value_formatted,
					'field_value_min' => $field_value_min,
					'field_value_max' => $field_value_max,
					'field_error' => $field_error,
					'date_array1' => $date_array1,
					'date_array2' => $date_array2,
					'date_array3' => $date_array3);
	      $field_count++;
	    }

	  } 
	} // END field_list() METHOD









	// THIS METHOD RETRIEVES FIELD INFO ABOUT A FIELD AND RETURNS IT AS AN ASSOCIATIVE ARRAY
	// INPUT: $field_id REPRESENTING THE FIELD'S ID
	// OUTPUT: AN ASSOCIATIVE ARRAY CONTAINING THE FIELD INFORMATION (WITHOUT TYPE PREFIX)
	function field_get($field_id) {
	  global $database;

	  $field_info = $database->database_fetch_assoc($database->database_query("SELECT ".$this->type."field_id AS field_id, ".$this->type."field_".$this->type."cat_id AS field_cat_id, ".$this->type."field_order AS field_order, ".$this->type."field_dependency AS field_dependency, ".$this->type."field_title AS field_title, ".$this->type."field_desc AS field_desc, ".$this->type."field_error AS field_error, ".$this->type."field_type AS field_type, ".$this->type."field_style AS field_style, ".$this->type."field_maxlength AS field_maxlength, ".$this->type."field_link AS field_link, ".$this->type."field_options AS field_options, ".$this->type."field_required AS field_required, ".$this->type."field_regex AS field_regex, ".$this->type."field_special AS field_special, ".$this->type."field_search AS field_search, ".$this->type."field_display AS field_display, ".$this->type."field_html AS field_html FROM se_".$this->type."fields WHERE ".$this->type."field_id='$field_id'"));

	  // PULL OPTIONS INTO NEW ARRAY
	  $new_field_options = "";
	  $field_options = unserialize($field_info[field_options]);
	  for($i=0;$i<count($field_options);$i++) {
	    SE_Language::_preload_multi($field_options[$i][label]);
	    SE_Language::load();
	    $field_options[$i][label] = SE_Language::_get($field_options[$i][label]);
	    if($field_options[$i][dependency] == 1) { 
	      $dep_field = $database->database_query("SELECT ".$this->type."field_id AS field_id, ".$this->type."field_title AS field_title FROM se_".$this->type."fields WHERE ".$this->type."field_id='".$field_options[$i][dependent_id]."'");
	      if($database->database_num_rows($dep_field) != "1") {
	        $field_options[$i][dependency] = 0;
	      } else {
	        $field_options[$i][dependency] = 1;
	        $dep_field_info = $database->database_fetch_assoc($dep_field);
		SE_Language::_preload_multi($dep_field_info[field_title]);
		SE_Language::load();
		$dep_field_info[field_title] = SE_Language::_get($dep_field_info[field_title]);
	        $field_options[$i][dependent_label] = $dep_field_info[field_title];
	      }
	    }
	  }

	  // LOAD FIELD TITLE
	  SE_Language::_preload_multi($field_info[field_title], $field_info[field_desc], $field_info[field_error]);
	  SE_Language::load();
	  $field_info[field_title] = SE_Language::_get($field_info[field_title]);
	  $field_info[field_desc] = SE_Language::_get($field_info[field_desc]);
	  $field_info[field_error] = SE_Language::_get($field_info[field_error]);

	  $field_info[field_options_detailed] = $field_options;
	  return $field_info;

	} // END field_get() METHOD









	// THIS METHOD SAVES FIELD DATA
	// INPUT: $field_info REPRESENTING AN ARRAY CONTAINING THE FIELD INFO TO SAVE
	// OUTPUT: 
	function field_save($field_info) {
	  global $database;

	  $old_field_query = $database->database_query("SELECT ".$this->type."field_id AS field_id, ".$this->type."field_".$this->type."cat_id AS field_cat_id, ".$this->type."field_dependency AS field_dependency, ".$this->type."field_order AS field_order, ".$this->type."field_title AS field_title, ".$this->type."field_desc AS field_desc, ".$this->type."field_error AS field_error, ".$this->type."field_options AS field_options, ".$this->type."field_special AS field_special FROM se_".$this->type."fields WHERE ".$this->type."field_id='$field_info[field_id]'");
	  if($database->database_num_rows($old_field_query) != 0) { $old_field_info = $database->database_fetch_assoc($old_field_query); } else { $old_field_info = ""; $old_field_info[field_dependency] = 0; }
	  if($old_field_info[field_dependency] != 0) { $field_info[field_type] = ($field_info[field_type] == 3) ? 3: 1; $field_info[field_cat_id] = $old_field_info[field_cat_id]; }

	  // FIELD TYPE IS TEXT FIELD
	  if($field_info[field_type] == "1") {
	    $column_type = "varchar(250)";
	    $column_default = "default ''";
	    $field_info[field_html] = str_replace("&gt;", "", str_replace("&lt;", "", str_replace(" ", "", $field_info[field_html])));
	    $suggestions = explode("\r\n", $field_info[field_suggestions]);
	    for($i=0;$i<count($suggestions);$i++) {
	      if(trim($suggestions[$i]) != "") {
	        $options[] = Array('value'=>$i, 'label'=>$suggestions[$i], 'dependency'=>'0', 'dependent_label'=>'', 'dependent_id'=>'');
	      }
	    }

	  // FIELD TYPE IS TEXTAREA
	  } elseif($field_info[field_type] == "2") {
	    $column_type = "text";
	    $column_default = "";
	    $field_info[field_html] = str_replace("&gt;", "", str_replace("&lt;", "", str_replace(" ", "", $field_info[field_html])));

	  // FIELD TYPE IS SELECT BOX OR RADIO BUTTONS
	  } elseif($field_info[field_type] == "3" || $field_info[field_type] == "4" || $field_info[field_type] == "6") {
	    $field_info[field_html] = "";
	    for($i=0;$i<count($field_info[field_options]);$i++) {
	      if(trim($field_info[field_options][$i][value]) != "" && trim($field_info[field_options][$i][label]) != "") {
	        $set_values[] = $field_info[field_options][$i][value];
	        $options[] = $field_info[field_options][$i];
	        if(ereg("^[0-9]+$", $field_info[field_options][$i][value]) === FALSE) { $this->is_error = 146; break; }
	      } elseif($field_info[field_options][$i][dependent_id] != "") {
	        $dependent_ids[] = $field_info[field_options][$i][dependent_id];
	      }
	    }
      
	    if( !empty($set_values) && $field_info[field_type] == "6" ) {
	      $column_type = "set('".implode("', '", $set_values)."')";
	      $column_default = "";
	    } else {
	      $column_type = "int(2)";
	      $column_default = "default '-1'";
	    }

	    // IF NO OPTIONS HAVE BEEN SPECIFIED
	    if(count($options) == 0) { $this->is_error = 143; }

	  // FIELD TYPE IS DATE FIELD
	  } elseif($field_info[field_type] == "5") {
	    $box5_display = "block";
	    $column_type = "date";
	    $column_default = "default '0000-00-00'";
	    $field_info[field_html] = "";


	  // FIELD TYPE NOT SPECIFIED
	  } else {
	    $this->is_error = 85;
	  }

	  // FIELD TITLE IS EMPTY
	  if(trim($field_info[field_title]) == "" && $old_field_info[field_dependency] == 0) { $this->is_error = 94; }

	  // NO ERROR 
	  if($this->is_error == 0) {

	    // OLD FIELD (SAVE)
	    if($database->database_num_rows($old_field_query)) { 

	      if($old_field_info[field_cat_id] != $field_info[field_cat_id]) {
	        $field_order_info = $database->database_fetch_assoc($database->database_query("SELECT max(".$this->type."field_order) as f_order FROM se_".$this->type."fields WHERE ".$this->type."field_dependency='0' AND ".$this->type."field_".$this->type."cat_id='$field_info[field_cat_id]'"));
	        $field_info[field_order] = $field_order_info[f_order]+1;
	      } else {
	        $field_info[field_order] = $old_field_info[field_order];
	      }

	      SE_Language::edit($old_field_info[field_title], $field_info[field_title]);
	      SE_Language::edit($old_field_info[field_desc], $field_info[field_desc]);
	      SE_Language::edit($old_field_info[field_error], $field_info[field_error]);
	      $database->database_query("UPDATE se_".$this->type."fields SET ".$this->type."field_".$this->type."cat_id='$field_info[field_cat_id]', ".$this->type."field_order='$field_info[field_order]', ".$this->type."field_type='$field_info[field_type]', ".$this->type."field_style='$field_info[field_style]', ".$this->type."field_maxlength='$field_info[field_maxlength]', ".$this->type."field_link='$field_info[field_link]', ".$this->type."field_required='$field_info[field_required]', ".$this->type."field_regex='$field_info[field_regex]', ".$this->type."field_html='$field_info[field_html]', ".$this->type."field_search='$field_info[field_search]', ".$this->type."field_display='$field_info[field_display]', ".$this->type."field_special='$field_info[field_special]' WHERE ".$this->type."field_id='$field_info[field_id]'");
	      $column_name = $this->type."value_".$field_info[field_id];
	      $database->database_query("ALTER TABLE se_".$this->type."values MODIFY $column_name $column_type $column_default");

	      // ENSURE FIRST DISPLAY NAME GETS CLEARED IF NECESSARY
	      if($this->type == "profile" && $old_field_info[field_special] == 2 && $field_info[field_special] != 2) {
		$database->database_query("UPDATE se_users SET user_fname='' WHERE user_fname<>''");
	      // ENSURE LAST DISPLAY NAME GETS CLEARED IF NECESSARY
	      } elseif($this->type == "profile" && $old_field_info[field_special] == 3 && $field_info[field_special] != 3) {
		$database->database_query("UPDATE se_users SET user_lname='' WHERE user_lname<>''");
	      }

	      // GET OLD LABEL LANGUAGE VARS
	      $old_field_options = unserialize($old_field_info[field_options]);
	      for($o=0;$o<count($old_field_options);$o++) { $old_language_ids[$old_field_options[$o][value]] = $old_field_options[$o][label]; }

	      // EDIT DEPENDENT FIELDS
	      for($d=0;$d<count($options);$d++) {
	        if($old_language_ids[$options[$d][value]] != "") {
		  $options[$d][label] = SE_Language::edit($old_language_ids[$options[$d][value]], $options[$d][label]);
		  unset($old_language_ids[$options[$d][value]]);
	        } else {
		  $options[$d][label] = SE_Language::edit(0, $options[$d][label], NULL, LANGUAGE_INDEX_FIELDS);
		}

	        $dep_field = $database->database_query("SELECT ".$this->type."field_id AS field_id, ".$this->type."field_title AS field_title FROM se_".$this->type."fields WHERE ".$this->type."field_id='".$options[$d][dependent_id]."'");

	        if($database->database_num_rows($dep_field) == "1") {
	          $dep_field_info = $database->database_fetch_assoc($dep_field);
	          if($options[$d][dependency] == "1") {
	            SE_Language::edit($dep_field_info[field_title], $options[$d][dependent_label]);
	            $database->database_query("UPDATE se_".$this->type."fields SET ".$this->type."field_".$this->type."cat_id='$field_info[field_cat_id]' WHERE ".$this->type."field_id='$dep_field_info[field_id]'");
	          } else {
	            $database->database_query("DELETE FROM se_".$this->type."fields, se_languagevars USING se_".$this->type."fields JOIN se_languagevars ON se_".$this->type."fields.".$this->type."field_title=se_languagevars.languagevar_id WHERE ".$this->type."field_id='$dep_field_info[field_id]'");
	            $column_name = $this->type."value_".$dep_field_info[field_id];
	            $database->database_query("ALTER TABLE se_".$this->type."values DROP COLUMN $column_name");
	          }
	        } else {
	          if($options[$d][dependency] == "1") {
		    $dep_languagevar_id = SE_Language::edit(0, $options[$d][dependent_label], NULL, LANGUAGE_INDEX_FIELDS);
	            $database->database_query("INSERT INTO se_".$this->type."fields (".$this->type."field_".$this->type."cat_id, ".$this->type."field_title, ".$this->type."field_order, ".$this->type."field_type, ".$this->type."field_style, ".$this->type."field_dependency, ".$this->type."field_maxlength, ".$this->type."field_link, ".$this->type."field_options, ".$this->type."field_required, ".$this->type."field_regex) VALUES ('$field_info[field_cat_id]', '".$dep_languagevar_id."', '0', '1', '', '$field_info[field_id]', '100', '', '', '0', '')");
	            $dep_field_id = $database->database_insert_id();
	            $options[$d][dependent_id] = $dep_field_id;
	            $column_name = $this->type."value_".$dep_field_id;
	            $database->database_query("ALTER TABLE se_".$this->type."values ADD $column_name varchar(250) NOT NULL");
	          }
	        }
	      }

	      // DELETE OLD DEPENDENT FIELDS
	      for($d=0;$d<count($dependent_ids);$d++) {
	        $database->database_query("DELETE FROM se_".$this->type."fields, se_languagevars USING se_".$this->type."fields JOIN se_languagevars ON se_".$this->type."fields.".$this->type."field_title=se_languagevars.languagevar_id WHERE ".$this->type."field_id='$dependent_ids[$d]'");
	        $column_name = $this->type."value_".$dependent_ids[$d];
	        $database->database_query("ALTER TABLE se_".$this->type."values DROP COLUMN $column_name");
	      }

	      // DELETE OLD LANGUAGE VARS
        if( !empty($old_language_ids) && is_array($old_language_ids) )
          $database->database_query("DELETE FROM se_languagevars WHERE languagevar_id IN('".join("', '", $old_language_ids)."')");

	      // INSERT OPTIONS
	      $field_info[field_options] = $options;
	      $database->database_query("UPDATE se_".$this->type."fields SET ".$this->type."field_options='".serialize($options)."' WHERE ".$this->type."field_id='$field_info[field_id]'");


	    // NEW FIELD (ADD)
	    } else {

	      $field_order_info = $database->database_fetch_assoc($database->database_query("SELECT max(".$this->type."field_order) as f_order FROM se_".$this->type."fields WHERE ".$this->type."field_dependency='0' AND ".$this->type."field_".$this->type."cat_id='$field_info[field_cat_id]'"));
	      $field_order = $field_order_info[f_order]+1;
	      $field_info[field_title_id] = SE_Language::edit(0, $field_info[field_title], NULL, LANGUAGE_INDEX_FIELDS);
	      $field_info[field_desc_id] = SE_Language::edit(0, $field_info[field_desc], NULL, LANGUAGE_INDEX_FIELDS);
	      $field_info[field_error_id] = SE_Language::edit(0, $field_info[field_error], NULL, LANGUAGE_INDEX_FIELDS);
	      $database->database_query("INSERT INTO se_".$this->type."fields (".$this->type."field_".$this->type."cat_id, ".$this->type."field_title, ".$this->type."field_desc, ".$this->type."field_error, ".$this->type."field_order, ".$this->type."field_type, ".$this->type."field_style, ".$this->type."field_dependency, ".$this->type."field_maxlength, ".$this->type."field_link, ".$this->type."field_required, ".$this->type."field_regex, ".$this->type."field_html, ".$this->type."field_search, ".$this->type."field_display, ".$this->type."field_special) VALUES ('$field_info[field_cat_id]', '$field_info[field_title_id]', '$field_info[field_desc_id]', '$field_info[field_error_id]', '$field_order', '$field_info[field_type]', '$field_info[field_style]', '0', '$field_info[field_maxlength]', '$field_info[field_link]', '$field_info[field_required]', '$field_info[field_regex]', '$field_info[field_html]', '$field_info[field_search]', '$field_info[field_display]', '$field_info[field_special]')");
	      $field_info[field_id] = $database->database_insert_id();
	      $column_name = $this->type."value_".$field_info[field_id];
	      $database->database_query("ALTER TABLE se_".$this->type."values ADD $column_name $column_type NOT NULL $column_default");

	      // ADD DEPENDENT FIELDS
	      $field_options = "";
	      for($d=0;$d<count($options);$d++) {
		$label_languagevar_id = SE_Language::edit(0, $options[$d][label], NULL, LANGUAGE_INDEX_FIELDS);
		$options[$d][label] = $label_languagevar_id;
	        if($options[$d][dependency] == "1") {
		  $dep_languagevar_id = SE_Language::edit(0, $options[$d][dependent_label], NULL, LANGUAGE_INDEX_FIELDS);
	          $database->database_query("INSERT INTO se_".$this->type."fields (".$this->type."field_".$this->type."cat_id, ".$this->type."field_title, ".$this->type."field_order, ".$this->type."field_type, ".$this->type."field_style, ".$this->type."field_dependency, ".$this->type."field_maxlength, ".$this->type."field_link, ".$this->type."field_options, ".$this->type."field_required, ".$this->type."field_regex) VALUES ('$field_info[field_cat_id]', '".$dep_languagevar_id."', '$d', '1', '', '$field_info[field_id]', '100', '', '', '0', '')");
	          $dep_field_id = $database->database_insert_id();
	          $options[$d][dependent_id] = $dep_field_id;
	          $column_name = $this->type."value_".$dep_field_id;
	          $database->database_query("ALTER TABLE se_".$this->type."values ADD $column_name varchar(250) NOT NULL");
	        }
	      }

	      // INSERT OPTIONS
	      $field_info[field_options] = $options;
	      $database->database_query("UPDATE se_".$this->type."fields SET ".$this->type."field_options='".serialize($options)."' WHERE ".$this->type."field_id='$field_info[field_id]'");

	    }
	  }

	  return $field_info;

	} // END field_save() METHOD









	// THIS METHOD DELETES A FIELD AND ITS DEPENDENT FIELDS
	// INPUT: $field_id REPRESENTING THE FIELD'S ID
	// OUTPUT: 
	function field_delete($field_id) {
	  global $database;

	  // DELETE ALL FIELD COLUMNS
	  $fields = $database->database_query("SELECT ".$this->type."field_id AS field_id, ".$this->type."field_title AS field_title, ".$this->type."field_desc AS field_desc, ".$this->type."field_error AS field_error, ".$this->type."field_options AS field_options FROM se_".$this->type."fields WHERE ".$this->type."field_id='$field_id' OR ".$this->type."field_dependency='$field_id'");
	  while($field = $database->database_fetch_assoc($fields)) {

	    $languagevars_delete[] = $field[field_title];
	    $languagevars_delete[] = $field[field_desc];
	    $languagevars_delete[] = $field[field_error];

	    // DELETE OPTION LABELS
	    $field_options = unserialize($field[field_options]);
	    for($i=0;$i<count($field_options);$i++) { if($field_options[$i][label] != "") { $languagevars_delete[] = $field_options[$i][label]; }}

	    $column = $this->type."value_".$field[field_id];
	    $database->database_query("ALTER TABLE se_".$this->type."values DROP COLUMN $column");
	  }

	  // DELETE ALL FIELDS
	  $database->database_query("DELETE FROM se_languagevars WHERE languagevar_id IN(".implode(",", $languagevars_delete).")");
	  $database->database_query("DELETE FROM se_".$this->type."fields WHERE ".$this->type."field_id='$field_id' OR ".$this->type."field_dependency='$field_id'");

	} // END field_delete() METHOD









	// THIS METHOD DELETES A CATEGORY AND ITS SUBCATEGORIES/FIELDS
	// INPUT: $cat_id REPRESENTING THE CATEGORY ID OF THE CATEGORY TO DELETE
	// OUTPUT: 
	function cat_delete($cat_id) {
	  global $database;

	  $fields = $database->database_query("SELECT ".$this->type."field_id AS field_id, ".$this->type."field_title AS field_title, ".$this->type."field_desc AS field_desc, ".$this->type."field_error AS field_error FROM se_".$this->type."fields LEFT JOIN se_".$this->type."cats ON se_".$this->type."fields.".$this->type."field_".$this->type."cat_id=se_".$this->type."cats.".$this->type."cat_id WHERE se_".$this->type."cats.".$this->type."cat_id='$cat_id' OR se_".$this->type."cats.".$this->type."cat_dependency='$cat_id'");
	  while($field = $database->database_fetch_assoc($fields)) {
	    $column = $this->type."value_".$field[field_id];
	    $database->database_query("ALTER TABLE se_".$this->type."values DROP COLUMN $column");
	    $database->database_query("DELETE FROM se_languagevars WHERE languagevar_id='$field[field_title]' OR languagevar_id='$field[field_desc]' OR languagevar_id='$field[field_error]'");
	  }
	  $database->database_query("DELETE FROM se_languagevars USING se_".$this->type."cats JOIN se_languagevars ON se_".$this->type."cats.".$this->type."cat_title=se_languagevars.languagevar_id WHERE se_".$this->type."cats.".$this->type."cat_id='$cat_id' OR se_".$this->type."cats.".$this->type."cat_dependency='$cat_id'");
	  $database->database_query("DELETE FROM se_".$this->type."fields, se_".$this->type."cats USING se_".$this->type."cats LEFT JOIN se_".$this->type."fields ON se_".$this->type."fields.".$this->type."field_".$this->type."cat_id=se_".$this->type."cats.".$this->type."cat_id WHERE se_".$this->type."cats.".$this->type."cat_id='$cat_id' OR se_".$this->type."cats.".$this->type."cat_dependency='$cat_id'");

	} // END cat_delete() METHOD









	// THIS METHOD ADDS/EDIT A CATEGORY
	// INPUT: $cat_id REPRESENTING THE CATEGORY ID OF THE CATEGORY TO ADD/EDIT
	// OUTPUT: RETURNS THE CATEGORY ID
	function cat_modify($cat_id, $cat_title, $cat_dependency) {
	  global $database;

	  // NEW CATEGORY
	  if($cat_id == "new") {
	    $cat_order = $database->database_fetch_assoc($database->database_query("SELECT max(".$this->type."cat_order) AS cat_order FROM se_".$this->type."cats WHERE ".$this->type."cat_dependency='$cat_dependency'"));
	    $cat_order = $cat_order[cat_order]+1;
	    $cat_title = SE_Language::edit(0, $cat_title, NULL, LANGUAGE_INDEX_FIELDS);
	    $database->database_query("INSERT INTO se_".$this->type."cats (".$this->type."cat_dependency, ".$this->type."cat_title, ".$this->type."cat_order) VALUES ('$cat_dependency', '$cat_title', '$cat_order')");
	    $newcat_id = $database->database_insert_id();
  
	  // EDIT CATEGORY
	  } else {
	    $cat_info = $database->database_fetch_assoc($database->database_query("SELECT ".$this->type."cat_title AS cat_title FROM se_".$this->type."cats WHERE ".$this->type."cat_id='$cat_id'"));
	    SE_Language::edit($cat_info[cat_title], $cat_title);
	    $newcat_id = $cat_id;
	  }
	
	  return $newcat_id;

	} // END cat_modify() METHOD





}

?>


а вот второго
PHP:
<?php

/* $Id: functions_general.php 207 2009-08-07 01:54:51Z Lemance $ */


//  THIS FILE CONTAINS GENERAL FUNCTIONS
//  FUNCTIONS IN THIS FILE:
//    cheader()
//    make_page()
//    bumplog()
//    randomcode()
//    is_email_address()
//    str_ireplace()
//    htmlspecialchars_decode()
//    str_split()
//    security()
//    select_subnet()
//    link_field_values()
//    censor()
//    dirsize()
//    user_privacy_levels()
//    search_profile()
//    getmicrotime()
//    cleanHTML()
//    chopHTML()
//    choptext()
//    chunkHTML_split()
//    strlen_utf8()
//    mb_unserialize()
//    online_users()
//    site_statistics()
//    recent_signups()
//    recent_logins()
//    popular_users()
//    site_news()
//    friends_birthdays()
//    get_simple_cookie_domain()











// THIS FUNCTION CHANGES LOCATION HEADER TO REDIRECT FOR IIS PRIOR TO SETTING COOKIES
// INPUT: $url REPRESENTING THE URL TO REDIRECT TO
// OUTPUT: 

function cheader($url)
{
	if( ereg("Microsoft", $_SERVER['SERVER_SOFTWARE']) )
  {
	  header("Refresh: 0; URL=$url");
	}
  else
  {
	  header("Location: $url");
	}
	exit();
}

// END cheader() FUNCTION









// THIS FUNCTION RETURNS APPROPRIATE PAGE VARIABLES
// INPUT: $total_items REPRESENTING THE TOTAL NUMBER OF ITEMS
//	  $items_per_page REPRESENTING THE NUMBER OF ITEMS PER PAGE
//	  $p REPRESENTING THE CURRENT PAGE
// OUTPUT: AN ARRAY CONTAINING THE STARTING ITEM, THE PAGE, AND THE MAX PAGE

function make_page($total_items, $items_per_page, $p)
{
	if( !$items_per_page ) $items_per_page = 1;
  $maxpage = ceil($total_items / $items_per_page);
	if( $maxpage <= 0 ) $maxpage = 1;
  $p = ( ($p > $maxpage) ? $maxpage : ( ($p < 1) ? 1 : $p ) );
	$start = ($p - 1) * $items_per_page;
	return array($start, $p, $maxpage);
}

// END make_page() FUNCTION









// THIS FUNCTION BUMPS LOGIN LOG
// INPUT:
// OUTPUT: 

function bumplog()
{
	global $database;
	$log_entries = $database->database_num_rows($database->database_query("SELECT login_id FROM se_logins"));
	if( $log_entries > 1000 )
  {
	  $oldest_log = $database->database_fetch_assoc($database->database_query("SELECT login_id FROM se_logins ORDER BY login_id ASC LIMIT 0,1"));
	  $database->database_query("DELETE FROM se_logins WHERE login_id='{$oldest_log['login_id']}'");
	  bumplog();
	}
}

// END bumplog() FUNCTION









// THIS FUNCTION RETURNS A RANDOM CODE OF DEFAULT LENGTH 8
// INPUT: $len (OPTIONAL) REPRESENTING THE LENGTH OF THE RANDOM STRING
// OUTPUT: A RANDOM ALPHANUMERIC STRING

function randomcode($len=8)
{
	$code = NULL;
	for( $i=0; $i<$len; $i++ )
  {
	  $char = chr(rand(48,122));
	  while( !ereg("[a-zA-Z0-9]", $char) )
    {
	    if( $char == $lchar ) continue;
	    $char = chr(rand(48,90));
	  }
	  $pass .= $char;
	  $lchar = $char;
	}
	return $pass;
}

// END randomcode() FUNCTION









// THIS FUNCTION CHECKS IF PROVIDED STRING IS AN EMAIL ADDRESS
// INPUT: $email REPRESENTING THE EMAIL ADDRESS TO CHECK
// OUTPUT: TRUE/FALSE DEPENDING ON WHETHER THE EMAIL ADDRESS IS VALIDLY CONSTRUCTED

function is_email_address($email)
{
	$regexp = "/^[a-z0-9]+([a-z0-9_\+\\.-]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
	return (bool) preg_match($regexp, $email);
}

// END is_email_address() FUNCTION









// THIS FUNCTION SETS STR_IREPLACE IF FUNCTION DOESN'T EXIST
// INPUT: $search REPRESENTING THE STRING TO SEARCH FOR
//	  $replace REPRESENTING THE STRING TO REPLACE IT WITH
//	  $subject REPRESENTING THE STRING WITHIN WHICH TO SEARCH
// OUTPUT: RETURNS A STRING IN WHICH ONE STRING HAS BEEN CASE-INSENSITIVELY REPLACED BY ANOTHER

if( !function_exists('str_ireplace') )
{
  function str_ireplace($search, $replace, $subject)
  {
    $search = preg_quote($search, "/");
    return preg_replace("/".$search."/i", $replace, $subject); 
  } 
}

// END str_ireplace() FUNCTION









// THIS FUNCTION SETS HTMLSPECIALCHARS_DECODE IF FUNCTION DOESN'T EXIST
// INPUT: $text REPRESENTING THE TEXT TO DECODE
//	  $ent_quotes (OPTIONAL) REPRESENTING WHETHER TO REPLACE DOUBLE QUOTES, ETC
// OUTPUT: A STRING WITH HTML CHARACTERS DECODED

if( !function_exists('htmlspecialchars_decode') )
{
  function htmlspecialchars_decode($text, $ent_quotes = ENT_COMPAT)
  {
    if( $ent_quotes === ENT_QUOTES   ) $text = str_replace("&quot;", "\"", $text);
    if( $ent_quotes !== ENT_NOQUOTES ) $text = str_replace("'", "'", $text);
    $text = str_replace("&lt;", "<", $text);
    $text = str_replace("&gt;", ">", $text);
    $text = str_replace("&amp;", "&", $text);
    return $text;
  }
}

// END htmlspecialchars() FUNCTION









// THIS FUNCTION SETS STR_SPLIT IF FUNCTION DOESN'T EXIST
// INPUT: $string REPRESENTING THE STRING TO SPLIT
//	  $split_length (OPTIONAL) REPRESENTING WHERE TO CUT THE STRING
// OUTPUT: AN ARRAY OF STRINGS 
if( !function_exists('str_split') )
{
  function str_split($string, $split_length = 1)
  {
    $count = strlen($string);
    if($split_length < 1)
    {
      return false;
    }
    elseif($split_length > $count)
    {
      return array($string);
    }
    else
    {
      $num = (int)ceil($count/$split_length);
      $ret = array();
      for($i=0;$i<$num;$i++)
      {
        $ret[] = substr($string,$i*$split_length,$split_length);
      }
      return $ret;
    }
  }
}

// END str_split() FUNCTION









// THIS FUNCTION STRIPSLASHES AND ENCODES HTML ENTITIES FOR SECURITY PURPOSES
// INPUT: $value REPRESENTING A STRING OR ARRAY TO CLEAN
// OUTPUT: THE ARRAY OR STRING WITH HTML CHARACTERS ENCODED

function security($value)
{
	if( is_array($value) )
  {
	  $value = array_map('security', $value);
	}
  else
  {
	  if( !get_magic_quotes_gpc() )
    {
	    $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
	  }
    else
    {
	    $value = htmlspecialchars(stripslashes($value), ENT_QUOTES, 'UTF-8');
	  }
	  $value = str_replace("\\", "\\\\", $value);
	}
	return $value;
}

// END security() FUNCTION









// THIS FUNCTION LINKS FIELD VALUES
// INPUT: $field_value REPRESENTING THE VALUE TO LINK
//	  $key (NEEDED TO USE ARRAY WALK)
//	  $additional REPRESENTING THE ADDITIONAL PARAMETERS
// OUTPUT: 
function link_field_values(&$field_value, $key, $additional)
{
	global $url;

	$field_id = $additional[0];
	$field_browse = $additional[1];
	$field_link = $additional[2];
	$field_display = $additional[3];
	$field_value = trim($field_value);
	
  if( !trim($field_link) && $field_display == 2 )
  {
	  if( !$field_browse ) $field_browse = urlencode(htmlspecialchars_decode($field_value, ENT_QUOTES));
	  $browse_url = $url->url_base."search_advanced.php?task=browse&field_id={$field_id}&field_value={$field_browse}";
	  if( $field_value ) $field_value = "<a href='{$browse_url}'>{$field_value}</a>";
	}
  elseif( trim($field_link) && $field_value )
  {
	  if( preg_match('/^www([.]?[a-zA-Z0-9_\/-])*/', $field_value) ) $field_link = "http://".$field_value;
	  $link_to = str_replace("[field_value]", $field_value, $field_link);
	  $field_value = "<a href='{$link_to}' target='_blank'>{$field_value}</a>"; 
	}
}

// END link_field_values() FUNCTION









// THIS FUNCTION CENSORS WORDS FROM A STRING
// INPUT: $field_value REPRESENTING THE VALUE TO CENSOR
// OUTPUT: THE VALUE WITH BANNED WORDS CENSORED

function censor($field_value)
{
	global $setting;

	$censored_array = explode(",", trim($setting['setting_banned_words']));
	foreach($censored_array as $key => $value)
  {
	  $replace_value = str_pad("", strlen(trim($value)), "*");
	  $field_value = str_ireplace(trim($value), $replace_value, $field_value);
	}
 
	return $field_value;
}

// END censor() FUNCTION









// THIS FUNCTION RETURNS THE SIZE OF A DIRECTORY
// INPUT: $dirname REPRESENTING THE PATH TO A DIRECTORY
// OUTPUT: THE SIZE OF ALL THE FILES WITHIN THE DIRECTORY

function dirsize($dirname)
{
	if( !is_dir($dirname) || !is_readable($dirname) )
    return false;
  
	$dirname_stack[] = $dirname;
	$size = 0;

	do {
	  $dirname = array_shift($dirname_stack);
	  $handle = opendir($dirname);
	  while(false !== ($file = readdir($handle)))
    {
	    if($file != '.' && $file != '..' && is_readable($dirname . DIRECTORY_SEPARATOR . $file))
      {
	      if(is_dir($dirname . DIRECTORY_SEPARATOR . $file))
        {
	        $dirname_stack[] = $dirname . DIRECTORY_SEPARATOR . $file;
	      }
	      $size += filesize($dirname . DIRECTORY_SEPARATOR . $file);
	    }
	  }
	  closedir($handle);
	} while( count($dirname_stack) > 0 );

	return $size;
}

// END dirsize() FUNCTION









// THIS FUNCTION RETURNS TEXT CORRESPONDING TO THE GIVEN USER PRIVACY LEVEL
// INPUT: $privacy_level REPRESENTING THE LEVEL OF USER PRIVACY
// OUTPUT: A STRING EXPLAINING THE GIVEN PRIVACY SETTING

function user_privacy_levels($privacy_level)
{
	global $functions_general;

	switch($privacy_level)
  {
	  case 63: $privacy = 323; break;
	  case 31: $privacy = 324; break;
	  case 15: $privacy = 325; break;
	  case 7: $privacy = 326; break;
	  case 3: $privacy = 327; break;
	  case 1: $privacy = 328; break;
	  case 0: $privacy = 329; break;
	  default: $privacy = ""; break;
	}

	return $privacy;
}

// END user_privacy_levels() FUNCTION









// THIS FUNCTION SEARCHES THROUGH PROFILE INFORMATION
// INPUT: 
// OUTPUT:

function search_profile()
{
	global $database, $url, $results_per_page, $p, $search_text, $t, $search_objects, $results, $total_results;

	// GET FIELDS
	$fields = $database->database_query("
    SELECT
      profilefield_id AS field_id,
      profilefield_type AS field_type,
      profilefield_options AS field_options
    FROM
      se_profilefields
    WHERE
      profilefield_type<>'5' &&
      (profilefield_dependency<>'0' OR (profilefield_dependency='0' AND profilefield_display<>'0'))
  ");
  
	$profile_query = "se_users.user_username LIKE '%{$search_text}%' OR CONCAT(se_users.user_fname, ' ', se_users.user_lname) LIKE '%{$search_text}%'";
  
	// LOOP OVER FIELDS
	while($field_info = $database->database_fetch_assoc($fields))
  {
	  // TEXT FIELD OR TEXTAREA
	  if( $field_info['field_type'] == 1 || $field_info['field_type'] == 2 )
    {
	    if( $profile_query ) $profile_query .= " OR ";
	    $profile_query .= "`se_profilevalues`.`profilevalue_{$field_info['field_id']}` LIKE '%{$search_text}%'";
    }
    
	  // RADIO OR SELECT BOX
	  elseif($field_info[field_type] == 3 || $field_info[field_type] == 4)
    {
	    $options = unserialize($field_info['field_options']);
 	    $langids = Array();
	    $cases = Array();
	    for($i=0,$max=count($options);$i<$max;$i++)
      { 
	      $cases[] = "WHEN languagevar_id='{$options[$i]['label']}' THEN {$options[$i]['value']}";
	      $langids[] = $options[$i][label]; 
	    }
	    if(count($cases) != 0)
      {
	      if( $profile_query ) $profile_query .= " OR ";
	      $profile_query .= "`se_profilevalues`.`profilevalue_{$field_info['field_id']}` IN (SELECT CASE ".implode(" ", $cases)." END AS value FROM se_languagevars WHERE languagevar_id IN (".implode(", ", $langids).") AND languagevar_value LIKE '%{$search_text}%')";
	    }
    }
    
	  // CHECKBOX
	  elseif($field_info[field_type] == 6)
    {
	    $options = unserialize($field_info['field_options']);
 	    $langids = Array();
	    $cases = Array();
	    for($i=0,$max=count($options);$i<$max;$i++)
      { 
	      $cases[] = "WHEN languagevar_id='{$options[$i]['label']}' THEN ".(pow(2, $i));
	      $langids[] = $options[$i][label]; 
	    }
	    if(count($cases) != 0)
      {
	      if( $profile_query ) $profile_query .= " OR ";
	      $profile_query .= "`se_profilevalues`.`profilevalue_{$field_info['field_id']}` & (SELECT sum(CASE ".implode(" ", $cases)." END) AS value FROM se_languagevars WHERE languagevar_id IN (".implode(", ", $langids).") AND languagevar_value LIKE '%{$search_text}%')";
	    }
	  }
	}

	// CONSTRUCT QUERY
	$profile_query = "
    SELECT
      se_users.user_id,
      se_users.user_username,
      se_users.user_fname,
      se_users.user_lname,
      se_users.user_photo
    FROM
      se_profilevalues
    LEFT JOIN
      se_users
      ON se_profilevalues.profilevalue_user_id=se_users.user_id
    LEFT JOIN
      se_levels
      ON se_levels.level_id=se_users.user_level_id
    WHERE
      se_users.user_verified='1' AND
      se_users.user_enabled='1' AND
      (se_users.user_search='1' OR se_levels.level_profile_search='0') AND
      ($profile_query)
  ";

	// GET TOTAL PROFILES
	$total_profiles = $database->database_num_rows($database->database_query($profile_query." LIMIT 201"));

	// IF NOT TOTAL ONLY
	if($t == "0")
  {
	  // MAKE PROFILE PAGES
	  $start = ($p - 1) * $results_per_page;
	  $limit = $results_per_page+1;
    
	  // SEARCH PROFILES
	  $online_users_array = online_users();
	  $profiles = $database->database_query($profile_query." ORDER BY se_users.user_id DESC LIMIT $start, $limit");
	  while($profile_info = $database->database_fetch_assoc($profiles))
    {
	    // CREATE AN OBJECT FOR USER
	    $profile = new se_user();
	    $profile->user_info['user_id'] = $profile_info['user_id'];
	    $profile->user_info['user_username'] = $profile_info['user_username'];
	    $profile->user_info['user_fname'] = $profile_info['user_fname'];
	    $profile->user_info['user_lname'] = $profile_info['user_lname'];
	    $profile->user_info['user_photo'] = $profile_info['user_photo'];
	    $profile->user_displayname();
      
	    // DETERMINE IF USER IS ONLINE
	    $is_online = (bool) in_array($profile_info['user_username'], $online_users_array[0]);
      
	    $results[] = Array(
        'result_url' => $url->url_create('profile', $profile_info['user_username']),
        'result_icon' => $profile->user_photo('./images/nophoto.gif', TRUE),
        'result_name' => 509,
        'result_name_1' => $profile->user_displayname,
        'result_desc' => '',
        'result_online' => $is_online
      );
	  }
    
	  // SET TOTAL RESULTS
	  $total_results = $total_profiles;
	}
  
	// SET ARRAY VALUES
	SE_Language::_preload_multi(509, 1072);
	if($total_profiles > 200) { $total_profiles = "200+"; }
	$search_objects[] = Array(
    'search_type' => '0',
    'search_lang' => 1072,
    'search_total' => $total_profiles
  );
}

// END search_profile() FUNCTION









// THIS FUNCTION RETURNS TIME IN SECONDS WITH MICROSECONDS
// INPUT:
// OUTPUT: RETURNS THE TIME IN SECONDS WITH MICROSECONDS

function getmicrotime()
{
	list($usec, $sec) = explode(" ",microtime());
	return ((float)$usec + (float)$sec);
}

// END getmicrotime() FUNCTION













// THIS FUNCTION CLEANS HTML TAGS FROM TEXT
// INPUT: $text REPRESENTING THE STRING TO CLEAN
//	  $allowable_tags REPRESENTING THE ALLOWABLE HTML TAGS (AS A COMMA-DELIMITED STRING)
//	  $forbidden_attr (OPTIONAL) REPRESENTING AND ARRAY OF ANY ADDITIONAL FORBIDDEN ATTRIBUTES (SUCH AS A STYLE TAG)
// OUTPUT: THE CLEANED TEXT

function cleanHTML($text, $allowable_tags, $forbidden_attr = "")
{
  // INCLUDE FILTER CLASS
  if( !class_exists("InputFilter") )
    require(SE_ROOT."/include/class_inputfilter.php");
  
  // INSTANTIATE INPUT FILTER CLASS WITH APPROPRIATE TAGS
  $xssFilter = new InputFilter(explode(",", str_replace(" ", "", $allowable_tags)), "", 0, 1, 1);

  // ADD NECESSARY BLACKLIST ITEMS
  for($i=0;$i<count($forbidden_attr);$i++)
  {
    $xssFilter->attrBlacklist[] = $forbidden_attr[$i];
  }

  // RETURN PROCESSED TEXT
  return $xssFilter->process($text);
}

// END cleanHTML() FUNCTION













// THIS FUNCTION TRIMS A GIVEN STRING PRESERVING HTML
// INPUT: $string REPRESENTING THE STRING TO SHORTEN
//	  $start REPRESENTING THE CHARACTER TO START WITH
//	  $length REPRESENTING THE LENGTH OF THE STRING TO RETURN
// OUTPUT: THE CLEANED TEXT

function chopHTML($string, $start, $length=false)
{
  $pattern = '/(\[\w+[^\]]*?\]|\[\/\w+\]|<\w+[^>]*?>|<\/\w+>)/i';
  $clean = preg_replace($pattern, chr(1), $string);

  if(!$length)
      $str = substr($clean, $start);
  else {
      $str = substr($clean, $start, $length);
      $str = substr($clean, $start, $length + substr_count($str, chr(1)));
  }
  $pattern = str_replace(chr(1),'(.*?)',preg_quote($str));
  if(preg_match('/'.$pattern.'/is', $string, $matched))
      return $matched[0];
  return $string;
}

// END chopHTML() FUNCTION










// THIS FUNCTION CHOPS A GIVEN STRING AND INSERTS A STRING AT THE END OF EACH CHOP
// INPUT: $string REPRESENTING THE STRING TO CHOP
//        $length REPRESENTING THE LENGTH OF EACH SEGMENT
//        $insert_char REPRESENTING THE STRING TO INSERT AT THE END OF EACH SEGMENT

function choptext($string, $length=32, $insert_char=' ')
{
  return preg_replace("!(?:^|\s)([\w\!\?\.]{" . $length . ",})(?:\s|$)!e",'chunk_split("\\1",' . $length . ',"' . $insert_char. '")',$string);
}

// END choptext() FUNCTION










// THIS FUNCTION CHOPS A GIVEN STRING AND INSERTS A STRING AT THE END OF EACH CHOP (PRESERVING HTML ENTITIES)
// INPUT: $html REPRESENTING THE STRING TO CHOP
//        $size REPRESENTING THE LENGTH OF EACH SEGMENT
//        $delim REPRESENTING THE STRING TO INSERT AT THE END OF EACH SEGMENT

function chunkHTML_split($html, $size, $delim)
{
  $pos=0;
  for($i=0;$i<strlen($html);$i++)
  {
    if($pos >= $size && !$unsafe)
    {
      $out .= $delim;
      $unsafe = 0;
      $pos = 0;
    }
    $c = substr($html,$i,1);
    if($c == "&")
      $unsafe = 1;
    elseif($c == ";")
      $unsafe = 0;
    $out .= $c;
    $pos++;
  }
  return $out;
}

// END chunkHTML_split










// THIS FUNCTION RETURNS THE LENGTH OF A STRING, ACCOUNTING FOR UTF8 CHARS
// INPUT: $str REPRESENTING THE STRING
// OUTPUT: THE LENGTH OF THE STRING

function strlen_utf8($str)
{
  $i = 0;
  $count = 0;
  $len = strlen($str);
  while($i < $len)
  {
    $chr = ord ($str[$i]);
    $count++;
    $i++;
    if($i >= $len)
      break;
    
    if($chr & 0x80)
    {
      $chr <<= 1;
      while ($chr & 0x80)
      {
        $i++;
        $chr <<= 1;
      }
    }
  }
  return $count;
}

// END strlen_utf8() FUNCTION










// THIS FUNCTION MAKES UTF8 CHARS WORK IN SERIALIZE BY BASICALLY IGNORING THE STRING LENGTH PARAM
// INPUT: $str REPRESENTING THE SERIALIZED STRING
// OUTPUT: THE UNSERIALIZED DATA

function mb_unserialize($serial_str)
{
  $out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str );
  return unserialize($out);
} 

// END mb_unserialize() FUNCTION








// THIS FUNCTION RETURNS AN ARRAY CONTAINING THE USERNAMES OF ONLINE USERS
// INPUT:
// OUTPUT: AN ARRAY OF USERNAMES FOR USERS CURRENTLY ACTIVE IN THE SYSTEM

function online_users()
{
	global $database;
  
  $online_array = NULL;
  
  // CACHING
  $cache_object = SECache::getInstance('serial');
  if( is_object($cache_object) )
  {
    $online_array = $cache_object->get('online_users');
  }
  
  if( !is_array($online_array) )
  {
    $total_visitors = 0;
    $onlineusers_array = array();
    $onlineusers_usernames = array();
    $online_time = time() - (10 * 60);
    
    $sql = "SELECT visitor_user_id AS user_id, visitor_user_username AS user_username, visitor_user_displayname AS user_displayname FROM se_visitors WHERE visitor_invisible=0 && visitor_lastactive>'{$online_time}' ORDER BY visitor_lastactive DESC LIMIT 2000";
    $resource = $database->database_query($sql);
    
    while( $online_user_info = $database->database_fetch_assoc($resource) )
    {
      // THIS IS A USER
      if( !empty($online_user_info['user_id']) )
      {
        if( in_array($online_user_info['user_username'], $onlineusers_usernames) ) continue;
        
        $online_user = new se_user();
        $online_user->user_info['user_id']          = $online_user_info['user_id'];
        $online_user->user_info['user_username']    = $online_user_info['user_username'];
        $online_user->user_info['user_displayname'] = $online_user_info['user_displayname'];
        $online_user->user_displayname              = $online_user_info['user_displayname'];
        
        $onlineusers_array[] = $online_user;
        $onlineusers_usernames[] = $online_user->user_info['user_username'];
      }
      
      // THIS IS A VISITOR
      else
      {
        $total_visitors++;
      }
    }
    
    $online_array = array($onlineusers_array, $total_visitors, $onlineusers_usernames);
    
    // CACHE
    if( is_object($cache_object) )
    {
      $cache_object->store($online_array, 'online_users');
    }
  }
  
	return $online_array;
}

// END online_users() FUNCTION









// THIS FUNCTION RETURNS AN ARRAY CONTAINING SITE STATISTICS
// INPUT:
// OUTPUT: AN ARRAY OF STATISTICS
function site_statistics()
{
  global $setting, $database, $database_name;
  
  $statistics = NULL;
  
  // CACHING
  $cache_object = SECache::getInstance('serial');
  if( is_object($cache_object) )
  {
    $statistics = $cache_object->get('site_statistics');
  }
  
  // RETRIEVAL
  //if( !is_array($statistics) || empty($statistics) )
  if( !is_array($statistics) )
  {
    $statistics = array();
    
    // Get default stats
    $total_members = $database->database_fetch_assoc($database->database_query("SELECT count(*) AS total_members FROM se_users"));
    $statistics['members'] = array(
      'title' => 661,
      'stat'  => (int) ( isset($total_members['total_members']) ? $total_members['total_members'] : 0 )
    );
    
    if( $setting['setting_connection_allow'] )
    {
      $total_friends = $database->database_fetch_assoc($database->database_query("SELECT count(*) AS total_friends FROM se_friends WHERE friend_status='1'"));
      $statistics['friends'] = array(
        'title' => 662,
        'stat'  => (int) ( isset($total_friends['total_friends']) ? $total_friends['total_friends'] : 0 )
      );
    }
    
    $total_comments = 0;
    $comment_tables = $database->database_query("SHOW TABLES FROM `{$database_name}` LIKE 'se_%comments'");
    while($table_info = $database->database_fetch_array($comment_tables))
    {
      $comment_type = strrev(substr(strrev(substr($table_info[0], 3)), 8));
      $table_comments = $database->database_fetch_assoc($database->database_query("SELECT count(*) AS total_comments FROM `se_{$comment_type}comments`"));
      $total_comments += $table_comments['total_comments'];
    }
    
    $statistics['comments'] = array(
      'title' => 663,
      'stat'  => (int) $total_comments
    );
    
    /*
    $total_media = 0;
    $media_tables = $database->database_query("SHOW TABLES FROM `{$database_name}` LIKE 'se_%media'");
    while($table_info = $database->database_fetch_array($media_tables))
    {
      $comment_type = strrev(substr(strrev(substr($table_info[0], 3)), 8));
      $table_media = $database->database_fetch_assoc($database->database_query("SELECT count(*) AS total_media FROM se_{$comment_type}media"));
      $total_media += $total_media['total_media'];
    }
    
    $statistics['media'] = array(
      'title' => 663, // TODO
      'stat'  => (int) $total_media
    );
    */
    
    /*
    $total_mediatags = 0;
    $mediatag_tables = $database->database_query("SHOW TABLES FROM `{$database_name}` LIKE 'se_%mediatags'");
    while($table_info = $database->database_fetch_array($media_tables))
    {
      $comment_type = strrev(substr(strrev(substr($table_info[0], 3)), 8));
      $table_mediatags = $database->database_fetch_assoc($database->database_query("SELECT count(*) AS total_mediatags FROM se_{$comment_type}mediatags"));
      $total_mediatags += $total_mediatags['total_mediatags'];
    }
    
    $statistics['mediatags'] = array(
      'title' => 663, // TODO
      'stat'  => (int) $total_mediatags
    );
    */
    
    // CALL HOOK
    // COMMENT OUT THIS NEXT LINE IF YOU ONLY WANT THE BASIC STATISTICS
    ($hook = SE_Hook::exists('se_site_statistics')) ? SE_Hook::call($hook, array('statistics' => &$statistics)) : NULL;
    
    // CACHE
    if( is_object($cache_object) )
    {
      $cache_object->store($statistics, 'site_statistics');
    }
  }
  
  // Load language
  foreach( $statistics as $stat )
  {
    SE_Language::_preload($stat['title']);
  }
  
  return $statistics;
}

// END site_statistics() FUNCTION









// THIS FUNCTION RETURNS AN ARRAY CONTAINING THE USERS THAT RECENTLY SIGNED UP
// INPUT:
// OUTPUT:
function recent_signups()
{
  global $setting, $database;
  
  $signups = NULL;
  
  // CACHING
  $cache_object = SECache::getInstance('serial');
  if( is_object($cache_object) )
  {
    $signups = $cache_object->get('recent_signups');
  }
  
  // RETRIEVAL
  //if( !is_array($signups) || empty($signups) )
  if( !is_array($signups) )
  {
    $sql = "SELECT user_id, user_username, user_fname, user_lname, user_photo FROM se_users WHERE user_verified='1' AND user_enabled='1' AND user_search='1' AND user_photo<>'' ORDER BY user_signupdate DESC LIMIT 20";
    $resource = $database->database_query($sql);
    
    $signups = array();
    while( $user_info = $database->database_fetch_assoc($resource) )
    {
      $signup_user = new se_user();
      $signup_user->user_info['user_id'] = $user_info['user_id'];
      $signup_user->user_info['user_username'] = $user_info['user_username'];
      $signup_user->user_info['user_photo'] = $user_info['user_photo'];
      $signup_user->user_info['user_fname'] = $user_info['user_fname'];
      $signup_user->user_info['user_lname'] = $user_info['user_lname'];
      $signup_user->user_displayname();
      
      $signups[] =& $signup_user;
      unset($signup_user);
    }
    
    // CACHE
    if( is_object($cache_object) )
    {
      $cache_object->store($signups, 'recent_signups');
    }
  }
  
  return $signups;
}

// END recent_signups() FUNCTION









// THIS FUNCTION RETURNS AN ARRAY CONTAINING THE MOST RECENTLY LOGGED IN USERS
// INPUT:
// OUTPUT:
function recent_logins()
{
  global $setting, $database;
  
  $logins = NULL;
  
  // CACHING
  $cache_object = SECache::getInstance('serial');
  if( is_object($cache_object) )
  {
    $logins = $cache_object->get('recent_logins');
  }
  
  // RETRIEVAL
  //if( !is_array($logins) || empty($logins) )
  if( !is_array($logins) )
  {
    $sql = "SELECT user_id, user_username, user_fname, user_lname, user_photo FROM se_users WHERE user_photo<>'' AND user_search='1' ORDER BY user_lastlogindate DESC LIMIT 20";
    $resource = $database->database_query($sql);
    
    $logins = array();
    while( $user_info = $database->database_fetch_assoc($resource) )
    {
      $login_user = new se_user();
      $login_user->user_info['user_id'] = $user_info['user_id'];
      $login_user->user_info['user_username'] = $user_info['user_username'];
      $login_user->user_info['user_photo'] = $user_info['user_photo'];
      $login_user->user_info['user_fname'] = $user_info['user_fname'];
      $login_user->user_info['user_lname'] = $user_info['user_lname'];
      $login_user->user_displayname();
      
      $logins[] =& $login_user;
      unset($login_user);
    }
    
    // CACHE
    if( is_object($cache_object) )
    {
      $cache_object->store($logins, 'recent_logins');
    }
  }
  
  return $logins;
}

// END recent_logins() FUNCTION









// THIS FUNCTION RETURNS AN ARRAY CONTAINING THE MOST POPULAR USERS
// INPUT:
// OUTPUT:
function popular_users()
{
  global $setting, $database;
  
  $popular_users = NULL;
  
  // CACHING
  $cache_object = SECache::getInstance('serial');
  if( is_object($cache_object) )
  {
    $popular_users = $cache_object->get('popular_users');
  }
  
  // RETRIEVAL
  //if( !is_array($popular_users) || empty($popular_users) )
  if( !is_array($popular_users) )
  {
    $sql = "SELECT count(se_friends.friend_user_id2) AS num_friends, se_users.user_id, se_users.user_username, se_users.user_fname, se_users.user_lname, se_users.user_photo FROM se_friends LEFT JOIN se_users ON se_friends.friend_user_id1=se_users.user_id WHERE se_friends.friend_status='1' AND se_users.user_search='1' GROUP BY se_users.user_id ORDER BY num_friends DESC LIMIT 20";
    $resource = $database->database_query($sql);
    
    $popular_users = array();
    while( $user_info = $database->database_fetch_assoc($resource) )
    {
      $popular_user = new se_user();
      $popular_user->user_info['user_id'] = $user_info['user_id'];
      $popular_user->user_info['user_username'] = $user_info['user_username'];
      $popular_user->user_info['user_photo'] = $user_info['user_photo'];
      $popular_user->user_info['user_fname'] = $user_info['user_fname'];
      $popular_user->user_info['user_lname'] = $user_info['user_lname'];
      $popular_user->user_displayname();
      
      $popular_users[] = array(
        'friend' => &$popular_user,
        'total_friends' => $user_info['num_friends']
      );
      
      unset($popular_user);
    }
    
    // CACHE
    if( is_object($cache_object) )
    {
      $cache_object->store($popular_users, 'popular_users');
    }
  }
  
  return $popular_users;
}

// END popular_users() FUNCTION









// THIS FUNCTION RETURNS AN ARRAY CONTAINING THE MOST POPULAR USERS
// INPUT:
// OUTPUT:
function site_news()
{
  global $setting, $database;
  
  $news = NULL;
  
  // CACHING
  $cache_object = SECache::getInstance('serial');
  if( is_object($cache_object) )
  {
    $news = $cache_object->get('site_news');
  }
  
  // RETRIEVAL
  //if( !is_array($news) || empty($news) )
  if( !is_array($news) )
  {
    $sql = "SELECT * FROM se_announcements ORDER BY announcement_order DESC LIMIT 20";
    $resource = $database->database_query($sql);
    
    $news = array();
    while( $news_info = $database->database_fetch_assoc($resource) )
    {
      // CONVERT SUBJECT/BODY BACK TO HTML
      $news_info['announcement_body'] = htmlspecialchars_decode($news_info['announcement_body'], ENT_QUOTES);
      $news_info['announcement_subject'] = htmlspecialchars_decode($news_info['announcement_subject'], ENT_QUOTES);
      $news[] = $news_info;
    }
    
    // CACHE
    if( is_object($cache_object) )
    {
      $cache_object->store($news, 'site_news');
    }
  }
  
  return $news;
}

// END site_news() FUNCTION









// THIS FUNCTION RETURNS AN ARRAY CONTAINING THE USERS FRIENDS BIRTHDAYS INFO
// INPUT:
// OUTPUT:

function friends_birthdays()
{
  global $setting, $database, $user;
  
  $birthdays = NULL;
  
  // CACHING
  $cache_object = SECache::getInstance('serial');
  if( is_object($cache_object) )
  {
    $birthdays = $cache_object->get('friends_birthdays_user_'.$user->user_info['user_id']);
  }
  
  
  // RETRIEVAL
  //if( !is_array($birthdays) || empty($birthdays) )
  if( !is_array($birthdays) )
  {
    $birthdays = array();
    
    $sql = "SELECT profilefield_id, t2.profilecat_id FROM se_profilefields LEFT JOIN se_profilecats AS t1 ON se_profilefields.profilefield_profilecat_id=t1.profilecat_id LEFT JOIN se_profilecats AS t2 ON t1.profilecat_dependency=t2.profilecat_id WHERE profilefield_special='1'";
    $resource = $database->database_query($sql);
    
    if( $database->database_num_rows($resource) > 0 )
    {
      // CONSTRUCT QUERY
      $birthdays_upcoming_query = "
        SELECT
          se_users.user_id, 
          se_users.user_username, 
          se_users.user_fname, 
          se_users.user_lname,
          CASE
      ";
      
      while( $birthday_field = $database->database_fetch_assoc($resource) )
      {
        $birthdays_upcoming_query .= " WHEN se_users.user_profilecat_id='{$birthday_field['profilecat_id']}' THEN DATE_FORMAT(CONCAT(YEAR(CURDATE()), \"-\", MONTH(se_profilevalues.`profilevalue_{$birthday_field['profilefield_id']}`), \"-\", DAY(se_profilevalues.`profilevalue_{$birthday_field['profilefield_id']}`)), '%Y-%m-%d')";
        $birthdays_upcoming_where[] = "(se_users.user_profilecat_id='{$birthday_field['profilecat_id']}' AND DAY(se_profilevalues.`profilevalue_{$birthday_field['profilefield_id']}`)<>'0' AND MONTH(se_profilevalues.`profilevalue_{$birthday_field['profilefield_id']}`)<>'0' AND CURDATE() <= DATE_FORMAT(CONCAT(YEAR(CURDATE()), \"-\", MONTH(se_profilevalues.`profilevalue_{$birthday_field['profilefield_id']}`), \"-\", DAY(se_profilevalues.`profilevalue_{$birthday_field['profilefield_id']}`)), '%Y-%m-%d') AND DATE_ADD(CURDATE(), INTERVAL 7 DAY) >= DATE_FORMAT(CONCAT(YEAR(CURDATE()), \"-\", MONTH(se_profilevalues.`profilevalue_{$birthday_field['profilefield_id']}`), \"-\", DAY(se_profilevalues.`profilevalue_{$birthday_field['profilefield_id']}`)), '%Y-%m-%d'))";
      }
      
      $birthdays_upcoming_query .= " ELSE '0000-00-00' END AS birthday FROM se_friends LEFT JOIN se_users ON se_friends.friend_user_id2=se_users.user_id LEFT JOIN se_profilevalues ON se_users.user_id=se_profilevalues.profilevalue_user_id WHERE se_friends.friend_user_id1='{$user->user_info['user_id']}' AND (".implode(" OR ", $birthdays_upcoming_where).") ORDER BY birthday";
      
      $resource = $database->database_query($birthdays_upcoming_query);
      
      while( $birthday_info = $database->database_fetch_assoc($resource) )
      {
        $birthday_user = new se_user();
        $birthday_user->user_info['user_id'] = $birthday_info['user_id'];
        $birthday_user->user_info['user_username'] = $birthday_info['user_username'];
        $birthday_user->user_info['user_fname'] = $birthday_info['user_fname'];
        $birthday_user->user_info['user_lname'] = $birthday_info['user_lname'];
        $birthday_user->user_displayname();
        
        // SET BIRTHDAY
        $birthday_date = mktime(0, 0, 0, substr($birthday_info['birthday'], 5, 2), substr($birthday_info['birthday'], 8, 2), 1990);
        
        $birthdays[] = array(
          'birthday_user_id' => $birthday_user->user_info['user_id'],
          'birthday_user_username' => $birthday_user->user_info['user_username'],
          'birthday_user_displayname' => $birthday_user->user_displayname,
          'birthday_date' => $birthday_date,
          'birthday_user' => &$birthday_user
        );
        
        unset($birthday_user);
      }
    }
    
    // CACHE
    if( is_object($cache_object) )
    {
      $cache_object->store($birthdays, 'friends_birthdays_user_'.$user->user_info['user_id']);
    }
  }
  
  return $birthdays;
}

// END friends_birthdays() FUNCTION





function get_simple_cookie_domain($host = null)
{
  // Quick config
  if( defined('SE_COOKIE_DOMAIN') )
  {
    return SE_COOKIE_DOMAIN;
  }
  
  if( !$host )
  {
    $host = $_SERVER["HTTP_HOST"];
  }
  
  $host = parse_url($host);
  $host = $host['path'];
  $parts = explode('.', $host);
  
  switch( TRUE )
  {
    // Do not use custom for these:
    // IP Address
    case ( preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $host) ):
    // Intranet host
    case ( count($parts) === 1 ):
      return null;
      break;
    
    // Second level ccld
    case ( strlen($parts[count($parts)-1]) == 2 && strlen($parts[count($parts)-2]) <= 3 ):
      array_splice($parts, 0, count($parts) - 3);
      return join('.', $parts);
      break;
    
    // tld or first-level ccld
    default:
      array_splice($parts, 0, count($parts) - 2);
      return join('.', $parts);
  }
  
  return null;
}

?>
 
Подскажите
в чём проблема если я ввожу в поле

<img src="http://localhost/se/uploads_user/1000/1/0_4912.jpg"/>

а в базу идёт

Код:
&lt;img src=&quot;http://localhost/se/uploads_user/1000/1/0_4912.jpg&quot;/&gt;
 
Всё связанное с удалением HTML подчистил,
теперь другая проблема:

Ввожу
<img src="http://localhost/se/uploads_user/1000/1/0_4912.jpg"/>

а в базу идёт

Код:
&lt;img src=&quot;http://localhost/se/uploads_user/100...jpg&quot;/&gt;
 
Как отдельно выводить поля из БД? (SE3)

Например на странице domain.com/user_editprofile.php
Где имя, фамилия, через админку я создал еще поле "тест"
в базе именуется как "profilevalue_7"

Как мне это поле отделить от полей "имя" и "фамилия"?
И как потом на странице просмотра профиля его отдельно выводить?

страница где эти поля

user_editprofile.php

PHP:
<?php

/* $Id: user_editprofile.php 42 2009-01-29 04:55:14Z Lemance $ */

$page = "user_editprofile";
include "header.php";

if(isset($_POST['task'])) { $task = $_POST['task']; } elseif(isset($_GET['task'])) { $task = $_GET['task']; } else { $task = "main"; }
if(isset($_POST['cat_id'])) { $cat_id = $_POST['cat_id']; } elseif(isset($_GET['cat_id'])) { $cat_id = $_GET['cat_id']; } else { $cat_id = NULL; }



if( is_null($cat_id) )
{
  $cat_query = $database->database_query("SELECT t2.profilecat_id AS profilecat_id, COUNT(profilefield_id) AS total_fields FROM se_profilecats AS t1 LEFT JOIN se_profilecats AS t2 ON t1.profilecat_id=t2.profilecat_dependency LEFT JOIN se_profilefields ON t2.profilecat_id=se_profilefields.profilefield_profilecat_id WHERE profilefield_id IS NOT NULL AND t1.profilecat_id='{$user->user_info['user_profilecat_id']}' GROUP BY t2.profilecat_id ORDER BY t2.profilecat_order LIMIT 1"); 
  if($database->database_num_rows($cat_query) == 1)
  {
    $cat = $database->database_fetch_assoc($cat_query);
    $cat_id = $cat['profilecat_id'];
  }
  elseif($user->level_info['level_photo_allow'] != 0)
  {
    header("Location: user_editprofile_photo.php");
    exit();
  }
  else
  {
    header("Location: user_editprofile_settings.php");
    exit();
  }
}

// INITIALIZE VARIABLES
$result = 0;
$is_error = 0;


// VALIDATE CAT ID
if($task == "dosave") { $validate = 1; } else { $validate = 0; }
$field = new se_field("profile", $user->profile_info);
$field->cat_list($validate, 0, 0, "profilecat_id='{$user->user_info['user_profilecat_id']}'", "profilecat_id='{$cat_id}'");
$field_array = $field->fields;
if($validate == 1) { $is_error = $field->is_error; }
if(count($field_array) == 0) { header("Location: user_editprofile.php"); exit(); }

// SAVE PROFILE FIELDS
if($task == "dosave" && $is_error == 0)
{
  // SAVE PROFILE VALUES
  $profile_query = "UPDATE se_profilevalues SET {$field->field_query} WHERE profilevalue_user_id='{$user->user_info['user_id']}'";
  $database->database_query($profile_query);
  
  
  // Flush cached data
  $user->profile_info = NULL;
  $user->profile_info =& SEUser::getProfileValues($user->user_info['user_id']);
  
  $cache_object = SECache::getInstance();
  if( is_object($cache_object) )
  {
    $cache_object->remove('site_user_profiles_'.$user->user_info['user_id']);
  }
  
  /*
  $profilevalues_static =& SEUser::getProfileValues($user->user_info['user_id']);
  $profilevalues_static = NULL;
  
   = $database->database_fetch_assoc($database->database_query("SELECT * FROM se_profilevalues WHERE profilevalue_user_id='".$user->user_info[user_id]."'"));
  //$user->profile_info = $database->database_fetch_assoc($database->database_query("SELECT * FROM se_profilevalues WHERE profilevalue_user_id='".$user->user_info[user_id]."'"));
  */
  
  
  // SAVE FIRST/LAST NAME, IF RELEVANT
  if(isset($field->field_special[2])) { $flquery[] = "user_fname='".$field->field_special[2]."'"; }
  if(isset($field->field_special[3])) { $flquery[] = "user_lname='".$field->field_special[3]."'"; }
  if(count($flquery) != 0) { $database->database_query("UPDATE se_users SET ".implode(", ", $flquery)." WHERE user_id='{$user->user_info['user_id']}'"); }
  
  // UPDATE CACHED DISPLAYNAME
  $user->user_displayname_update($field->field_special[2], $field->field_special[3]);
  
  
  // SET SUBNETWORK
  $subnet = $user->user_subnet_select($user->user_info['user_email'], $user->user_info['user_profilecat_id'], $user->profile_info); 
  if($subnet[0] != $user->user_info['user_subnet_id'])
  {
    $database->database_query("UPDATE se_users SET user_subnet_id='{$subnet[0]}' WHERE user_id='{$user->user_info['user_id']}'");
    $user->user_info['user_subnet_id'] = $subnet[0];
    $user->subnet_info['subnet_id'] = $subnet[0];
    $user->subnet_info['subnet_name'] = $subnet[1];
    $result = 2;
  }
  else
  {
    $result = 1;
  }

  $user->user_lastupdate();

  // INSERT ACTION
  $actions->actions_add($user, "editprofile", Array($user->user_info['user_username'], $user->user_displayname), Array(), 1800, false, "user", $user->user_info['user_id'], $user->user_info['user_privacy']);
}





// GET TABS TO DISPLAY ON TOP MENU
$field->cat_list(0, 0, 0, "profilecat_id='{$user->user_info['user_profilecat_id']}'", "", "profilefield_id=0");
$cat_array = $field->subcats;


// ASSIGN VARIABLES AND INCLUDE FOOTER
$smarty->assign('result', $result);
$smarty->assign('is_error', $is_error);
$smarty->assign('cat_id', $cat_id);
$smarty->assign('cats', $cat_array);
$smarty->assign('fields', $field_array);
$smarty->assign('old_subnet_name', $subnet[2]);
$smarty->assign('new_subnet_name', $subnet[1]);
include "footer.php";
?>

Шаблон для этого файла

user_editprofile.tpl

PHP:
{include file='header.tpl'}

{* $Id: user_editprofile.tpl 8 2009-01-11 06:02:53Z Lemance $ *}


<table class='tabs' cellpadding='0' cellspacing='0'>
<tr>
<td class='tab0'>&nbsp;</td>
{section name=cat_loop loop=$cats}
  <td class='tab{if $cats[cat_loop].subcat_id == $cat_id}1{else}2{/if}' NOWRAP><a href='user_editprofile.php?cat_id={$cats[cat_loop].subcat_id}'>{lang_print id=$cats[cat_loop].subcat_title}</a></td>
  <td class='tab'>&nbsp;</td>
  {if $cats[cat_loop].subcat_id == $cat_id}{capture assign='pagename'}{lang_print id=$cats[cat_loop].subcat_title}{/capture}{/if}
{/section}
{if $user->level_info.level_photo_allow != 0}<td class='tab2' NOWRAP><a href='user_editprofile_photo.php'>{lang_print id=762}</a></td><td class='tab'>&nbsp;</td>{/if}
{if $user->level_info.level_profile_style != 0 || $user->level_info.level_profile_style_sample != 0}<td class='tab2' NOWRAP><a href='user_editprofile_style.php'>{lang_print id=763}</a></td>{/if}
<td class='tab3'>&nbsp;</td>
</tr>
</table>

<img src='./images/icons/editprofile48.gif' border='0' class='icon_big'>
<div class='page_header'>{lang_sprintf id=764 1=$pagename}</div>
<div>{lang_print id=765}</div>
<br />
<br />

{* SHOW RESULT MESSAGE *}
{if $result == 2}
  <br>
  <table cellpadding='0' cellspacing='0'><tr><td class='result'>
  {capture assign="old_subnet_name"}{lang_print id=$old_subnet_name}{/capture}
  {capture assign="new_subnet_name"}{lang_print id=$new_subnet_name}{/capture}
  <div class='success'><img src='./images/success.gif' border='0' class='icon'> {lang_print id=191}<br>{lang_sprintf id=767 1=$old_subnet_name 2=$new_subnet_name}</div>
  </td></tr></table>
  <br>
{elseif $result == 1}
  <br>
  <table cellpadding='0' cellspacing='0'><tr><td class='result'>
  <div class='success'><img src='./images/success.gif' border='0' class='icon'> {lang_print id=191}</div>
  </td></tr></table>
  <br>
{/if}

{* SHOW ERROR MESSAGE *}
{if $is_error != 0}
  <br>
  <table cellpadding='0' cellspacing='0'><tr><td class='result'>
  <div class='error'><img src='./images/error.gif' border='0' class='icon'> {lang_print id=$is_error}</div>
  </td></tr></table>
  <br>
{/if}

{* JAVASCRIPT FOR SHOWING DEP FIELDS *}
{literal}
<script type="text/javascript">
<!-- 
  function ShowHideDeps(field_id, field_value, field_type) {
    if(field_type == 6) {
      if($('field_'+field_id+'_option'+field_value)) {
        if($('field_'+field_id+'_option'+field_value).style.display == "block") {
	  $('field_'+field_id+'_option'+field_value).style.display = "none";
	} else {
	  $('field_'+field_id+'_option'+field_value).style.display = "block";
	}
      }
    } else {
      var divIdStart = "field_"+field_id+"_option";
      for(var x=0;x<$('field_options_'+field_id).childNodes.length;x++) {
        if($('field_options_'+field_id).childNodes[x].nodeName == "DIV" && $('field_options_'+field_id).childNodes[x].id.substr(0, divIdStart.length) == divIdStart) {
          if($('field_options_'+field_id).childNodes[x].id == 'field_'+field_id+'_option'+field_value) {
            $('field_options_'+field_id).childNodes[x].style.display = "block";
          } else {
            $('field_options_'+field_id).childNodes[x].style.display = "none";
          }
        }
      }
    }
  }
//-->
</script>
{/literal}

<form action='user_editprofile.php' method='POST'>
<table cellpadding='0' cellspacing='0' class='form'>

{* LOOP THROUGH FIELDS *}
{section name=field_loop loop=$fields}
  <tr>
  <td class='form1' width='150'>{lang_print id=$fields[field_loop].field_title}{if $fields[field_loop].field_required != 0}*{/if}</td>
  <td class='form2'>

    {* TEXT FIELD *}
    {if $fields[field_loop].field_type == 1}
      <div><input type='text' class='text' name='field_{$fields[field_loop].field_id}' id='field_{$fields[field_loop].field_id}' value='{$fields[field_loop].field_value}' style='{$fields[field_loop].field_style}' maxlength='{$fields[field_loop].field_maxlength}'></div>

      {* JAVASCRIPT FOR CREATING SUGGESTION BOX *}
      {if $fields[field_loop].field_options != "" && $fields[field_loop].field_options|@count != 0}
      {literal}
      <script type="text/javascript">
      <!-- 
      window.addEvent('domready', function(){
	var options = {
		script:"misc_js.php?task=suggest_field&limit=5&{/literal}{section name=option_loop loop=$fields[field_loop].field_options}options[]={$fields[field_loop].field_options[option_loop].label}&{/section}{literal}",
		varname:"input",
		json:true,
		shownoresults:false,
		maxresults:5,
		multisuggest:false,
		callback: function (obj) {  }
	};
	var as_json{/literal}{$fields[field_loop].field_id}{literal} = new bsn.AutoSuggest('field_{/literal}{$fields[field_loop].field_id}{literal}', options);
      });
      //-->
      </script>
      {/literal}
      {/if}


    {* TEXTAREA *}
    {elseif $fields[field_loop].field_type == 2}
      <div><textarea rows='6' cols='50' name='field_{$fields[field_loop].field_id}' style='{$fields[field_loop].field_style}'>{$fields[field_loop].field_value}</textarea></div>



    {* SELECT BOX *}
    {elseif $fields[field_loop].field_type == 3}
      <div><select name='field_{$fields[field_loop].field_id}' id='field_{$fields[field_loop].field_id}' onchange="ShowHideDeps('{$fields[field_loop].field_id}', this.value);" style='{$fields[field_loop].field_style}'>
      <option value='-1'></option>
      {* LOOP THROUGH FIELD OPTIONS *}
      {section name=option_loop loop=$fields[field_loop].field_options}
        <option id='op' value='{$fields[field_loop].field_options[option_loop].value}'{if $fields[field_loop].field_options[option_loop].value == $fields[field_loop].field_value} SELECTED{/if}>{lang_print id=$fields[field_loop].field_options[option_loop].label}</option>
      {/section}
      </select>
      </div>
      {* LOOP THROUGH DEPENDENT FIELDS *}
      <div id='field_options_{$fields[field_loop].field_id}'>
      {section name=option_loop loop=$fields[field_loop].field_options}
        {if $fields[field_loop].field_options[option_loop].dependency == 1}

	  {* SELECT BOX *}
	  {if $fields[field_loop].field_options[option_loop].dep_field_type == 3}
            <div id='field_{$fields[field_loop].field_id}_option{$fields[field_loop].field_options[option_loop].value}' style='margin: 5px 5px 10px 5px;{if $fields[field_loop].field_options[option_loop].value != $fields[field_loop].field_value} display: none;{/if}'>
            {lang_print id=$fields[field_loop].field_options[option_loop].dep_field_title}{if $fields[field_loop].field_options[option_loop].dep_field_required != 0}*{/if}
            <select name='field_{$fields[field_loop].field_options[option_loop].dep_field_id}'>
	      <option value='-1'></option>
	      {* LOOP THROUGH DEP FIELD OPTIONS *}
	      {section name=option2_loop loop=$fields[field_loop].field_options[option_loop].dep_field_options}
	        <option id='op' value='{$fields[field_loop].field_options[option_loop].dep_field_options[option2_loop].value}'{if $fields[field_loop].field_options[option_loop].dep_field_options[option2_loop].value == $fields[field_loop].field_options[option_loop].dep_field_value} SELECTED{/if}>{lang_print id=$fields[field_loop].field_options[option_loop].dep_field_options[option2_loop].label}</option>
	      {/section}
	    </select>
            </div>	  

	  {* TEXT FIELD *}
	  {else}
            <div id='field_{$fields[field_loop].field_id}_option{$fields[field_loop].field_options[option_loop].value}' style='margin: 5px 5px 10px 5px;{if $fields[field_loop].field_options[option_loop].value != $fields[field_loop].field_value} display: none;{/if}'>
            {lang_print id=$fields[field_loop].field_options[option_loop].dep_field_title}{if $fields[field_loop].field_options[option_loop].dep_field_required != 0}*{/if}
            <input type='text' class='text' name='field_{$fields[field_loop].field_options[option_loop].dep_field_id}' value='{$fields[field_loop].field_options[option_loop].dep_field_value}' style='{$fields[field_loop].field_options[option_loop].dep_field_style}' maxlength='{$fields[field_loop].field_options[option_loop].dep_field_maxlength}'>
            </div>
	  {/if}

        {/if}
      {/section}
      </div>
  


    {* RADIO BUTTONS *}
    {elseif $fields[field_loop].field_type == 4}
    
      {* LOOP THROUGH FIELD OPTIONS *}
      <div id='field_options_{$fields[field_loop].field_id}'>
      {section name=option_loop loop=$fields[field_loop].field_options}
        <div>
        <input type='radio' class='radio' onclick="ShowHideDeps('{$fields[field_loop].field_id}', '{$fields[field_loop].field_options[option_loop].value}');" style='{$fields[field_loop].field_style}' name='field_{$fields[field_loop].field_id}' id='label_{$fields[field_loop].field_id}_{$fields[field_loop].field_options[option_loop].value}' value='{$fields[field_loop].field_options[option_loop].value}'{if $fields[field_loop].field_options[option_loop].value == $fields[field_loop].field_value} CHECKED{/if}>
        <label for='label_{$fields[field_loop].field_id}_{$fields[field_loop].field_options[option_loop].value}'>{lang_print id=$fields[field_loop].field_options[option_loop].label}</label>
        </div>

        {* DISPLAY DEPENDENT FIELDS *}
        {if $fields[field_loop].field_options[option_loop].dependency == 1}

	  {* SELECT BOX *}
	  {if $fields[field_loop].field_options[option_loop].dep_field_type == 3}
            <div id='field_{$fields[field_loop].field_id}_option{$fields[field_loop].field_options[option_loop].value}' style='margin: 5px 5px 10px 5px;{if $fields[field_loop].field_options[option_loop].value != $fields[field_loop].field_value} display: none;{/if}'>
            {lang_print id=$fields[field_loop].field_options[option_loop].dep_field_title}{if $fields[field_loop].field_options[option_loop].dep_field_required != 0}*{/if}
            <select name='field_{$fields[field_loop].field_options[option_loop].dep_field_id}'>
	      <option value='-1'></option>
	      {* LOOP THROUGH DEP FIELD OPTIONS *}
	      {section name=option2_loop loop=$fields[field_loop].field_options[option_loop].dep_field_options}
	        <option id='op' value='{$fields[field_loop].field_options[option_loop].dep_field_options[option2_loop].value}'{if $fields[field_loop].field_options[option_loop].dep_field_options[option2_loop].value == $fields[field_loop].field_options[option_loop].dep_field_value} SELECTED{/if}>{lang_print id=$fields[field_loop].field_options[option_loop].dep_field_options[option2_loop].label}</option>
	      {/section}
	    </select>
            </div>	  

	  {* TEXT FIELD *}
	  {else}
            <div id='field_{$fields[field_loop].field_id}_option{$fields[field_loop].field_options[option_loop].value}' style='margin: 0px 5px 10px 23px;{if $fields[field_loop].field_options[option_loop].value != $fields[field_loop].field_value} display: none;{/if}'>
            {lang_print id=$fields[field_loop].field_options[option_loop].dep_field_title}{if $fields[field_loop].field_options[option_loop].dep_field_required != 0}*{/if}
            <input type='text' class='text' name='field_{$fields[field_loop].field_options[option_loop].dep_field_id}' value='{$fields[field_loop].field_options[option_loop].dep_field_value}' style='{$fields[field_loop].field_options[option_loop].dep_field_style}' maxlength='{$fields[field_loop].field_options[option_loop].dep_field_maxlength}'>
            </div>
	  {/if}

        {/if}

      {/section}
      </div>


    {* DATE FIELD *}
    {elseif $fields[field_loop].field_type == 5}
      <div>
      <select name='field_{$fields[field_loop].field_id}_1' style='{$fields[field_loop].field_style}'>
      {section name=date1 loop=$fields[field_loop].date_array1}
        <option value='{$fields[field_loop].date_array1[date1].value}'{$fields[field_loop].date_array1[date1].selected}>{if $smarty.section.date1.first}[ {lang_print id=$fields[field_loop].date_array1[date1].name} ]{else}{$fields[field_loop].date_array1[date1].name}{/if}</option>
      {/section}
      </select>

      <select name='field_{$fields[field_loop].field_id}_2' style='{$fields[field_loop].field_style}'>
      {section name=date2 loop=$fields[field_loop].date_array2}
        <option value='{$fields[field_loop].date_array2[date2].value}'{$fields[field_loop].date_array2[date2].selected}>{if $smarty.section.date2.first}[ {lang_print id=$fields[field_loop].date_array2[date2].name} ]{else}{$fields[field_loop].date_array2[date2].name}{/if}</option>
      {/section}
      </select>

      <select name='field_{$fields[field_loop].field_id}_3' style='{$fields[field_loop].field_style}'>
      {section name=date3 loop=$fields[field_loop].date_array3}
        <option value='{$fields[field_loop].date_array3[date3].value}'{$fields[field_loop].date_array3[date3].selected}>{if $smarty.section.date3.first}[ {lang_print id=$fields[field_loop].date_array3[date3].name} ]{else}{$fields[field_loop].date_array3[date3].name}{/if}</option>
      {/section}
      </select>
      </div>


      {* CHECKBOXES *}
      {elseif $fields[field_loop].field_type == 6}
    
        {* LOOP THROUGH FIELD OPTIONS *}
        <div id='field_options_{$fields[field_loop].field_id}'>
        {section name=option_loop loop=$fields[field_loop].field_options}
          <div>
          <input type='checkbox' onclick="ShowHideDeps('{$fields[field_loop].field_id}', '{$fields[field_loop].field_options[option_loop].value}', '{$fields[field_loop].field_type}');" style='{$fields[field_loop].field_style}' name='field_{$fields[field_loop].field_id}[]' id='label_{$fields[field_loop].field_id}_{$fields[field_loop].field_options[option_loop].value}' value='{$fields[field_loop].field_options[option_loop].value}'{if $fields[field_loop].field_options[option_loop].value|in_array:$fields[field_loop].field_value} CHECKED{/if}>
          <label for='label_{$fields[field_loop].field_id}_{$fields[field_loop].field_options[option_loop].value}'>{lang_print id=$fields[field_loop].field_options[option_loop].label}</label>
          </div>

          {* DISPLAY DEPENDENT FIELDS *}
          {if $fields[field_loop].field_options[option_loop].dependency == 1}

	    {* SELECT BOX *}
	    {if $fields[field_loop].field_options[option_loop].dep_field_type == 3}
              <div id='field_{$fields[field_loop].field_id}_option{$fields[field_loop].field_options[option_loop].value}' style='margin: 5px 5px 10px 5px;{if $fields[field_loop].field_options[option_loop].value != $fields[field_loop].field_value} display: none;{/if}'>
              {lang_print id=$fields[field_loop].field_options[option_loop].dep_field_title}{if $fields[field_loop].field_options[option_loop].dep_field_required != 0}*{/if}
              <select name='field_{$fields[field_loop].field_options[option_loop].dep_field_id}'>
	        <option value='-1'></option>
	        {* LOOP THROUGH DEP FIELD OPTIONS *}
	        {section name=option2_loop loop=$fields[field_loop].field_options[option_loop].dep_field_options}
	          <option id='op' value='{$fields[field_loop].field_options[option_loop].dep_field_options[option2_loop].value}'{if $fields[field_loop].field_options[option_loop].dep_field_options[option2_loop].value == $fields[field_loop].field_options[option_loop].dep_field_value} SELECTED{/if}>{lang_print id=$fields[field_loop].field_options[option_loop].dep_field_options[option2_loop].label}</option>
	        {/section}
	      </select>
              </div>	  

	    {* TEXT FIELD *}
	    {else}
              <div id='field_{$fields[field_loop].field_id}_option{$fields[field_loop].field_options[option_loop].value}' style='margin: 0px 5px 10px 23px;{if $fields[field_loop].field_options[option_loop].value|in_array:$fields[field_loop].field_value == FALSE} display: none;{/if}'>
              {lang_print id=$fields[field_loop].field_options[option_loop].dep_field_title}{if $fields[field_loop].field_options[option_loop].dep_field_required != 0}*{/if}
              <input type='text' class='text' name='field_{$fields[field_loop].field_options[option_loop].dep_field_id}' value='{$fields[field_loop].field_options[option_loop].dep_field_value}' style='{$fields[field_loop].field_options[option_loop].dep_field_style}' maxlength='{$fields[field_loop].field_options[option_loop].dep_field_maxlength}'>
              </div>
	    {/if}

          {/if}

        {/section}
        </div>


    {/if}

    <div class='form_desc'>{lang_print id=$fields[field_loop].field_desc}</div>

    {capture assign='current_subnet'}{lang_print id=$user->subnet_info.subnet_name}{/capture}
    {if $fields[field_loop].field_id == $setting.setting_subnet_field1_id || $fields[field_loop].field_id == $setting.setting_subnet_field2_id}{lang_sprintf id=766 1=$current_subnet}{/if}

    {capture assign='field_error'}{lang_print id=$fields[field_loop].field_error}{/capture}
    {if $field_error != ""}<div class='form_error'><img src='./images/icons/error16.gif' border='0' class='icon'> {$field_error}</div>{/if}
    </td>
    </tr>
  {/section}

<tr>

<td class='form1'>&nbsp;</td>
<td class='form2'><input type='submit' class='button' value='{lang_print id=173}'></td>
<input type='hidden' name='task' value='dosave'>
<input type='hidden' name='cat_id' value='{$cat_id}'>
</tr>
</form>
</table>
{include file='footer.tpl'}



Страница профиля, где нужно отдельно выводить содержание поля, из БД

profile.php

PHP:
<?php

/* $Id: profile.php 42 2009-01-29 04:55:14Z john $ */

$page = "profile";
include "header.php";

// DISPLAY ERROR PAGE IF USER IS NOT LOGGED IN AND ADMIN SETTING REQUIRES REGISTRATION
if($user->user_exists == 0 && $setting['setting_permission_profile'] == 0)
{
  $page = "error";
  $smarty->assign('error_header', 639);
  $smarty->assign('error_message', 656);
  $smarty->assign('error_submit', 641);
  include "footer.php";
}

// DISPLAY ERROR PAGE IF NO OWNER
if($owner->user_exists == 0)
{
  $page = "error";
  $smarty->assign('error_header', 639);
  $smarty->assign('error_message', 828);
  $smarty->assign('error_submit', 641);
  include "footer.php";
}

// GET VIEW AND VARS
if(isset($_POST['v'])) { $v = $_POST['v']; } elseif(isset($_GET['v'])) { $v = $_GET['v']; } else { $v = "profile"; }
if(isset($_POST['search'])) { $search = $_POST['search']; } elseif(isset($_GET['search'])) { $search = $_GET['search']; } else { $search = ""; }
if(isset($_POST['m'])) { $m = $_POST['m']; } elseif(isset($_GET['m'])) { $m = $_GET['m']; } else { $m = 0; }
if(isset($_POST['p'])) { $p = $_POST['p']; } elseif(isset($_GET['p'])) { $p = $_GET['p']; } else { $p = 1; }

// VALIDATE VIEW VAR
if($v != "profile" && $v != "friends" && $v != "comments" && !array_key_exists($v, $global_plugins)) { $v = "profile"; }

// GET PRIVACY LEVEL
$privacy_max = $owner->user_privacy_max($user);
$allowed_to_view = ($privacy_max & $owner->user_info['user_privacy']);
$is_profile_private = !$allowed_to_view;

// CHECK IF USER IS ALLOWED TO COMMENT
$allowed_to_comment = ($privacy_max & $owner->user_info['user_comments']);


// UPDATE PROFILE VIEWS IF PROFILE VISIBLE
if($is_profile_private == 0 && $user->user_info['user_id'] != $owner->user_info['user_id'])
{
  $profile_viewers = "";
  if( $owner->user_info['user_saveviews'] )
  {
    $view_query = $database->database_query("SELECT profileview_viewers FROM se_profileviews WHERE profileview_user_id='{$owner->user_info['user_id']}'");
    if($database->database_num_rows($view_query) == 1)
    {
      $views = $database->database_fetch_assoc($view_query);
      $profile_viewers = $views['profileview_viewers'];
    }
    if( $user->user_exists )
    {
      $profile_viewers_array = explode(",", $profile_viewers);
      if( in_array($user->user_info['user_id'], $profile_viewers_array) )
      {
        array_splice($profile_viewers_array, array_search($user->user_info['user_id'], $profile_viewers_array), 1);
      }
      $profile_viewers_array[] = $user->user_info['user_id'];
      krsort($profile_viewers_array);
      $profile_viewers = implode(",", array_filter($profile_viewers_array));
    }
  }
  $database->database_query("INSERT INTO se_profileviews (profileview_user_id, profileview_views, profileview_viewers) VALUES ('{$owner->user_info['user_id']}', '1', '{$profile_viewers}') ON DUPLICATE KEY UPDATE profileview_views=profileview_views+1, profileview_viewers='{$profile_viewers}'");
}


// DELETE COMMENT NOTIFICATIONS IF VIEWING COMMENT PAGE
if( $v == "comments" && $user->user_info['user_id'] == $owner->user_info['user_id'])
{
  $database->database_query("DELETE FROM se_notifys WHERE notify_user_id='{$owner->user_info['user_id']}' AND notify_notifytype_id='3' AND notify_object_id='{$owner->user_info['user_id']}'");
}

// GET PROFILE COMMENTS
$comment = new se_comment('profile', 'user_id', $owner->user_info['user_id']);
$total_comments = $comment->comment_total();

// GET PROFILE FIELDS
$field = new se_field("profile", $owner->profile_info);
$field->cat_list(0, 1, 0, "profilecat_id='{$owner->user_info['user_profilecat_id']}'", "", "");



// SET WHERE CLAUSE FOR FRIEND LIST
if($search != "")
{
  $is_where = 1;
  $where = "(se_users.user_username LIKE '%$search%' OR CONCAT(se_users.user_fname, ' ', se_users.user_lname) LIKE '%$search%' OR se_users.user_email LIKE '%$search%')";
}
else
{
  $is_where = 0;
  $where = "";
}

if($m == 1 && $user->user_exists == 1)
{
  if($where != "") { $where .= " AND "; }
  $where .= "(SELECT TRUE FROM se_friends AS t1 WHERE t1.friend_user_id1='{$user->user_info['user_id']}' AND t1.friend_user_id2=se_friends.friend_user_id2)";
}

// DECIDE WHETHER TO SHOW DETAILS
$connection_types = explode("<!>", trim($setting['setting_connection_types']));
$show_details = ( count($connection_types) && $setting['setting_connection_other'] && $setting['setting_connection_explain'] );

// GET TOTAL FRIENDS
$total_friends = $owner->user_friend_total(0, 1, $is_where, $where);

// MAKE FRIEND PAGES AND GET FRIEND ARRAY
$friends_per_page = 10;
if($v == "friends") { $p_friends = $p; } else { $p_friends = 1; }
$page_vars_friends = make_page($total_friends, $friends_per_page, $p_friends);
$friends = $owner->user_friend_list($page_vars_friends[0], $friends_per_page, 0, 1, "se_users.user_username", $where, $show_details);

// GET MASTER TOTAL OF FRIENDS
$total_friends_all = $owner->user_friend_total(0);

// GET MASTER TOTAL OF ALL MUTUAL FRIENDS
$total_friends_mut = $owner->user_friend_total(0, 1, 0, "(SELECT TRUE FROM se_friends AS t1 WHERE t1.friend_user_id1='{$user->user_info['user_id']}' AND t1.friend_user_id2=se_friends.friend_user_id2)");


// GET CUSTOM PROFILE STYLE IF ALLOWED
if( $owner->level_info['level_profile_style'] && !$is_profile_private )
{ 
  $profilestyle_info = $database->database_fetch_assoc($database->database_query("SELECT profilestyle_css FROM se_profilestyles WHERE profilestyle_user_id='{$owner->user_info['user_id']}' LIMIT 1")); 
  $global_css = $profilestyle_info[profilestyle_css];
}
elseif( $owner->level_info['level_profile_style_sample'] && !$is_profile_private )
{
  $profilestyle_info = $database->database_fetch_assoc($database->database_query("SELECT stylesample_css FROM se_profilestyles LEFT JOIN se_stylesamples ON se_profilestyles.profilestyle_stylesample_id=se_stylesamples.stylesample_id WHERE profilestyle_user_id='{$owner->user_info['user_id']}' LIMIT 1")); 
  $global_css = $profilestyle_info['stylesample_css'];
}


// ENSURE CONECTIONS ARE ALLOWED FOR THIS USER AND THAT OWNER HAS NOT BLOCKED USER
$is_friend = $user->user_friended($owner->user_info['user_id']);
if( $user->user_friended($owner->user_info['user_id'], 0))
{
  $is_friend_pending = 2;
}
elseif( $owner->user_friended($user->user_info['user_id'], 0) )
{
  $is_friend_pending = 1;
}
else
{
  $is_friend_pending = 0;
}

$friendship_allowed = 1;
switch($setting['setting_connection_allow'])
{
  case "3":
    // ANYONE CAN INVITE EACH OTHER TO BE FRIENDS
    break;
  case "2":
    // CHECK IF IN SAME SUBNETWORK
    if($user->user_info['user_subnet_id'] != $owner->user_info['user_subnet_id']) { $friendship_allowed = 0; }
    break;
  case "1":
    // CHECK IF FRIEND OF FRIEND
    if($user->user_friend_of_friend($owner->user_info['user_id']) == FALSE) { $friendship_allowed = 0; }
    break;
  case "0":
    // NO ONE CAN INVITE EACH OTHER TO BE FRIENDS
    $friendship_allowed = 0;
    break;
}

if($owner->user_blocked($user->user_info['user_id'])) { $friendship_allowed = 0; }
if($is_friend) { $friendship_allowed = 1; }


// GET PHOTOS USER IS TAGGED IN
$photo_query = "";
($hook = SE_Hook::exists('se_mediatag')) ? SE_Hook::call($hook, array()) : NULL;
$total_photo_tags = $database->database_num_rows($database->database_query($photo_query));


// DETERMINE IF USER IS ONLINE
$online_users_array = online_users();
if(in_array($owner->user_info['user_username'], $online_users_array[2])) { $is_online = 1; } else { $is_online = 0; }

// GET PROFILE VIEWS
$profile_views = 0;
$view_query = $database->database_query("SELECT profileview_views, profileview_viewers FROM se_profileviews WHERE profileview_user_id='{$owner->user_info['user_id']}'");
if($database->database_num_rows($view_query) == 1)
{
  $views = $database->database_fetch_assoc($view_query);
  $profile_views = $views['profileview_views'];
}

// SET GLOBAL PAGE TITLE
$global_page_title[0] = 509;
$global_page_title[1] = $owner->user_displayname;
$global_page_description[0] = 1158;
$global_page_description[1] = $owner->user_displayname;
$global_page_description[2] = strip_tags(implode(" - ", $field->field_values));

// ASSIGN VARIABLES AND INCLUDE FOOTER
$smarty->assign('v', $v);
$smarty->assign('profile_views', $profile_views);
$smarty->assign('cats', $field->cats);
$smarty->assign('is_profile_private', $is_profile_private);
$smarty->assign('allowed_to_comment', $allowed_to_comment);
$smarty->assign('total_comments', $total_comments);
$smarty->assign('total_photo_tags', $total_photo_tags);
$smarty->assign('m', $m);
$smarty->assign('search', $search);
$smarty->assign('friends', $friends);
$smarty->assign('total_friends', $total_friends);
$smarty->assign('total_friends_all', $total_friends_all);
$smarty->assign('total_friends_mut', $total_friends_mut);
$smarty->assign('maxpage_friends', $page_vars_friends[2]);
$smarty->assign('p_start_friends', $page_vars_friends[0]+1);
$smarty->assign('p_end_friends', $page_vars_friends[0]+count($friends));
$smarty->assign('p_friends', $page_vars_friends[1]);
$smarty->assign('is_friend', $is_friend);
$smarty->assign('is_friend_pending', $is_friend_pending);
$smarty->assign('friendship_allowed', $friendship_allowed);
$smarty->assign('is_online', $is_online);
$smarty->assign('actions', $actions->actions_display(0, $setting['setting_actions_actionsonprofile'], "se_actions.action_user_id='{$owner->user_info['user_id']}'"));
include "footer.php";
?>

шаблон для этого файла:

profile.tpl

PHP:
{include file='header.tpl'}

{* $Id: profile.tpl 162 2009-04-30 01:43:11Z john $ *}

<div class='page_header'>{lang_sprintf id=786 1=$owner->user_displayname}</div>

<table cellpadding='0' cellspacing='0' width='100%'>
<tr>
<td class='profile_leftside' width='200'>
{* BEGIN LEFT COLUMN *}

  {* SHOW USER PHOTO *}
  <table cellpadding='0' cellspacing='0' width='100%' style='margin-bottom: 10px;'>
  <tr>
  <td class='profile_photo'><img class='photo' src='{$owner->user_photo("./images/nophoto.gif")}' border='0'></td>
  </tr>
  </table>

  <table class='profile_menu' cellpadding='0' cellspacing='0' width='100%'>

  {* SHOW PHOTOS OF THIS PERSON *}
  {if $total_photo_tags != 0}
    <tr><td class='profile_menu1' nowrap='nowrap'><a href='profile_photos.php?user={$owner->user_info.user_username}'><img src='./images/icons/photos16.gif' class='icon' border='0'>{lang_sprintf id=1204 1=$owner->user_displayname_short 2=$total_photo_tags}</a></td></tr>
    {assign var='showmenu' value='1'}
  {/if}


  {* SHOW BUTTONS IF LOGGED IN AND VIEWING SOMEONE ELSE *}
  {if $owner->user_info.user_id != $user->user_info.user_id}
 
    {* SHOW ADD OR REMOVE FRIEND MENU ITEM *}
    {if $friendship_allowed != 0 && $user->user_exists != 0}
      <tr><td class='profile_menu1' nowrap='nowrap'>
        {* JAVASCRIPT FOR CHANGING FRIEND MENU OPTION *}
        {literal}
        <script type="text/javascript">
        <!-- 
        function friend_update(status, id) {
          if(status == 'pending') {
            if($('addfriend_'+id))
              $('addfriend_'+id).style.display = 'none';
            if($('confirmfriend_'+id))
              $('confirmfriend_'+id).style.display = 'none';
            if($('pendingfriend_'+id))
              $('pendingfriend_'+id).style.display = 'block';
            if($('removefriend_'+id))
              $('removefriend_'+id).style.display = 'none';
          } else if(status == 'remove') {
            if($('addfriend_'+id))
              $('addfriend_'+id).style.display = 'none';
            if($('confirmfriend_'+id))
              $('confirmfriend_'+id).style.display = 'none';
            if($('pendingfriend_'+id))
              $('pendingfriend_'+id).style.display = 'none';
            if($('removefriend_'+id))
              $('removefriend_'+id).style.display = 'block';
          } else if(status == 'add') {
            if($('addfriend_'+id))
              $('addfriend_'+id).style.display = 'block';
            if($('confirmfriend_'+id))
              $('confirmfriend_'+id).style.display = 'none';
            if($('pendingfriend_'+id))
              $('pendingfriend_'+id).style.display = 'none';
            if($('removefriend_'+id))
              $('removefriend_'+id).style.display = 'none';
          }
        }
        //-->
        </script>
        {/literal}
        <div id='addfriend_{$owner->user_info.user_id}'{if $is_friend == TRUE || $is_friend_pending != 0} style='display: none;'{/if}><a href="javascript:TB_show('{lang_print id=876}', 'user_friends_manage.php?user={$owner->user_info.user_username}&TB_iframe=true&height=300&width=450', '', './images/trans.gif');"><img src='./images/icons/addfriend16.gif' class='icon' border='0'>{lang_print id=838}</a></div>
        <div id='confirmfriend_{$owner->user_info.user_id}'{if $is_friend_pending != 1} style='display: none;'{/if}><a href="javascript:TB_show('{lang_print id=887}', 'user_friends_manage.php?user={$owner->user_info.user_username}&TB_iframe=true&height=300&width=450', '', './images/trans.gif');"><img src='./images/icons/addfriend16.gif' class='icon' border='0'>{lang_print id=885}</a></div>
        <div id='pendingfriend_{$owner->user_info.user_id}'{if $is_friend_pending != 2} style='display: none;'{/if} class='nolink'><img src='./images/icons/addfriend16.gif' class='icon' border='0'>{lang_print id=875}</div>
        <div id='removefriend_{$owner->user_info.user_id}'{if $is_friend == FALSE || $is_friend_pending != 0} style='display: none;'{/if}><a href="javascript:TB_show('{lang_print id=837}', 'user_friends_manage.php?task=remove&user={$owner->user_info.user_username}&TB_iframe=true&height=300&width=450', '', './images/trans.gif');"><img src='./images/icons/remove_friend16.gif' class='icon' border='0'>{lang_print id=837}</a></div>
      </td></tr>
      {assign var='showmenu' value='1'}
    {/if}
    
    {* SHOW SEND MESSAGE MENU ITEM *}
    {if ($user->level_info.level_message_allow == 2 || ($user->level_info.level_message_allow == 1 && $is_friend)) && $owner->level_info.level_message_allow != 0}
      <tr><td class='profile_menu1' nowrap='nowrap'><a href="javascript:TB_show('{lang_print id=784}', 'user_messages_new.php?to_user={$owner->user_displayname|escape:url}&to_id={$owner->user_info.user_username}&TB_iframe=true&height=400&width=450', '', './images/trans.gif');"><img src='./images/icons/sendmessage16.gif' class='icon' border='0'>{lang_print id=839}</a></td></tr>
      {assign var='showmenu' value='1'}
    {/if}
    
    {* SHOW REPORT THIS PERSON MENU ITEM *}
    {if $user->user_exists != 0}
      <tr><td class='profile_menu1' nowrap='nowrap'><a href="javascript:TB_show('{lang_print id=857}', 'user_report.php?return_url={$url->url_current()|escape:url}&TB_iframe=true&height=300&width=450', '', './images/trans.gif');"><img src='./images/icons/report16.gif' class='icon' border='0'>{lang_print id=840}</a></td></tr>
      {assign var='showmenu' value='1'}
    {/if}
    
    {* SHOW BLOCK OR UNBLOCK THIS PERSON MENU ITEM *}
    {if $user->level_info.level_profile_block != 0}
      <tr><td class='profile_menu1' nowrap='nowrap'>
        <div id='unblock'{if $user->user_blocked($owner->user_info.user_id) == FALSE} style='display: none;'{/if}><a href="javascript:TB_show('{lang_print id=869}', 'user_friends_block.php?task=unblock&user={$owner->user_info.user_username}&TB_iframe=true&height=300&width=450', '', './images/trans.gif');"><img src='./images/icons/unblock16.gif' class='icon' border='0'>{lang_print id=841}</a></div>
        <div id='block'{if $user->user_blocked($owner->user_info.user_id) == TRUE} style='display: none;'{/if}><a href="javascript:TB_show('{lang_print id=868}', 'user_friends_block.php?task=block&user={$owner->user_info.user_username}&TB_iframe=true&height=300&width=450', '', './images/trans.gif');"><img src='./images/icons/block16.gif' class='icon' border='0'>{lang_print id=842}</a></div>
      </td></tr>
      {assign var='showmenu' value='1'}
    {/if}

  {/if}


  {* PLUGIN RELATED PROFILE MENU ITEMS *}
  {hook_foreach name=profile_menu var=profile_menu_args}
    {assign var='showmenu' value='1'}
    <tr>
      <td class='profile_menu1' nowrap='nowrap'>
        <a href='{$profile_menu_args.file}'>
          <img src='./images/icons/{$profile_menu_args.icon}' class='icon' border='0' />
          {lang_sprintf id=$profile_menu_args.title 1=$profile_menu_args.title_1 2=$profile_menu_args.title_2}
        </a>
      </td>
    </tr>
  {/hook_foreach}
  
  </table>

  {if $showmenu == 1}
    <div style='height: 10px; font-size: 1pt;'>&nbsp;</div>
  {/if}


  {* DISPLAY IF PROFILE IS PRIVATE TO VIEWING USER *}
  {if $is_profile_private != 0}

    {* END LEFT COLUMN *}
    </td>
    <td class='profile_rightside'>
    {* BEGIN RIGHT COLUMN *}

      <img src='./images/icons/error48.gif' border='0' class='icon_big'>
      <div class='page_header'>{lang_print id=843}</div>
      {lang_print id=844}

  {* DISPLAY ONLY IF PROFILE IS NOT PRIVATE TO VIEWING USER *}
  {else}

    {* BEGIN STATUS *}
    {if ($owner->level_info.level_profile_status != 0 && ($owner->user_info.user_status != "" || $owner->user_info.user_id == $user->user_info.user_id)) || $is_online == 1}
      <table cellpadding='0' cellspacing='0' width='100%' style='margin-bottom: 10px;'>
      <tr>
      <td class='header'>{lang_print id=768}</td>
      <tr>
      <td class='profile'>
        {if $is_online == 1}
          <table cellpadding='0' cellspacing='0'>
          <tr>
          <td valign='top'><img src='./images/icons/online16.gif' border='0' class='icon'></td>
          <td>{lang_sprintf id=845 1=$owner->user_displayname_short}</td>
          </tr>
          </table>
        {/if}
        
        {if $owner->level_info.level_profile_status != 0 && ($owner->user_info.user_status != "" || $owner->user_info.user_id == $user->user_info.user_id)}
          <table cellpadding='0' cellspacing='0'{if $is_online == 1} style='margin-top: 5px;'{/if}>
          <tr>
          <td valign='top'><img src='./images/icons/status16.gif' border='0' class='icon'></td>
          <td>
            {if $owner->user_info.user_id == $user->user_info.user_id}
              {* JAVASCRIPT FOR CHANGING STATUS - THIS IS ONLY SHOWN WHEN OWNER IS VIEWING OWN PROFILE, SO WE CAN USE VIEWER OBJECT *}
              {lang_javascript ids=773,1113 range=743-747}
              {literal}
              <script type="text/javascript">
              <!-- 
              SocialEngine.Viewer.user_status = '{/literal}{$user->user_info.user_status}{literal}';
              //-->
              </script>
              {/literal}
              
              <div id='ajax_status'>
              {if $owner->user_info.user_status != ""}
                {assign var='status_date' value=$datetime->time_since($user->user_info.user_status_date)}
                {$user->user_displayname_short} <span id='ajax_currentstatus_value'>{$user->user_info.user_status}</span>
                <div style='padding-top: 5px;'>
                  <div style='float: left; padding-right: 5px;'>[ <a href="javascript:void(0);" onClick="SocialEngine.Viewer.userStatusChange(); return false;">{lang_print id=745}</a> ]</div>
                  <div class='home_updated'>
                    {lang_print id=1113}
                    <span id='ajax_currentstatus_date'>{lang_sprintf id=$status_date[0] 1=$status_date[1]}</span>
                  </div>
                  <div style='clear: both; height: 0px;'></div>
                </div>
              {else}
                <a href="javascript:void(0);" onClick="SocialEngine.Viewer.userStatusChange(); return false;">{lang_print id=743}</a>
              {/if}
              </div>
            {else}
              {assign var='status_date' value=$datetime->time_since($owner->user_info.user_status_date)}
              {$owner->user_displayname_short} {$owner->user_info.user_status}
              <br>{lang_print id=1113} <span id='ajax_currentstatus_date'>{lang_sprintf id=$status_date[0] 1=$status_date[1]}</span>
            {/if}
          </td>
          </tr>
          </table>
        {/if}
      </td>
      </tr>
      </table>
    {/if}
    {* END STATUS *}
    
    {* BEGIN STATS *}
    <table cellpadding='0' cellspacing='0' width='100%' style='margin-bottom: 10px;'>
    <tr><td class='header'>{lang_print id=24}</td></tr>
    <tr>
    <td class='profile'>
      <table cellpadding='0' cellspacing='0'>
      <tr><td width='80' valign='top'>{lang_print id=1120}</td><td><a href='search_advanced.php?cat_selected={$owner->profilecat_info.profilecat_id}'>{lang_print id=$owner->profilecat_info.profilecat_title}</a></td></tr>
      <tr><td valign='top'>{lang_print id=1119}</td><td>{lang_print id=$owner->subnet_info.subnet_name}</td></tr>
      <tr><td>{lang_print id=846}</td><td>{lang_sprintf id=740 1=$profile_views}</td></tr>
      {if $setting.setting_connection_allow != 0}<tr><td>{lang_print id=847}</td><td>{lang_sprintf id=848 1=$total_friends}</td></tr>{/if}
      {if $owner->user_info.user_dateupdated != ""}<tr><td>{lang_print id=1113}</td><td>{assign var='last_updated' value=$datetime->time_since($owner->user_info.user_dateupdated)}{lang_sprintf id=$last_updated[0] 1=$last_updated[1]}</td></tr>{/if}
      {if $owner->user_info.user_signupdate != ""}<tr><td>{lang_print id=850}</td><td>{$datetime->cdate("`$setting.setting_dateformat`", $datetime->timezone("`$owner->user_info.user_signupdate`", $global_timezone))}</td></tr>{/if}
      </table>
    </td>
    </tr>
    </table>
    {* END STATS *}
    
    
    {* PLUGIN RELATED PROFILE SIDEBAR *}
    {hook_foreach name=profile_side var=profile_side_args}
      {include file=$profile_side_args.file}
    {/hook_foreach}
    
    
  {* END LEFT COLUMN *}
  </td>
  <td class='profile_rightside'>
  {* BEGIN RIGHT COLUMN *}
    
    {* JAVASCRIPT FOR SWITCHING TABS *}
    {literal}
    <script type='text/javascript'>
    <!--
      var visible_tab = '{/literal}{$v}{literal}';
      function loadProfileTab(tabId)
      {
        if(tabId == visible_tab)
        {
          return false;
        }
        if($('profile_'+tabId))
        {
          $('profile_tabs_'+tabId).className='profile_tab2';
          $('profile_'+tabId).style.display = "block";
          if($('profile_tabs_'+visible_tab))
          {
            $('profile_tabs_'+visible_tab).className='profile_tab';
            $('profile_'+visible_tab).style.display = "none";
          }
          visible_tab = tabId;
        }
      }
    //-->
    </script>
    {/literal}
    
    {* SHOW PROFILE TAB BUTTONS *}
    <table cellpadding='0' cellspacing='0'>
    <tr>
    <td valign='bottom'><table cellpadding='0' cellspacing='0'><tr><td class='profile_tab{if $v == 'profile'}2{/if}' id='profile_tabs_profile' onMouseUp="this.blur()"><a href='javascript:void(0);' onMouseDown="loadProfileTab('profile')" onMouseUp="this.blur()">{lang_print id=652}</a></td></tr></table></td>
    {if $total_friends_all != 0}<td valign='bottom'><table cellpadding='0' cellspacing='0'><td class='profile_tab{if $v == 'friends'}2{/if}' id='profile_tabs_friends' onMouseUp="this.blur()"><a href='javascript:void(0);' onMouseDown="loadProfileTab('friends');" onMouseUp="this.blur()">{lang_print id=653}</a></td></tr></table></td>{/if}
    {if $allowed_to_comment != 0 || $total_comments != 0}<td valign='bottom'><table cellpadding='0' cellspacing='0'><td class='profile_tab{if $v == 'comments'}2{/if}' id='profile_tabs_comments' onMouseUp="this.blur()"><a href='javascript:void(0);' onMouseDown="loadProfileTab('comments');SocialEngine.ProfileComments.getComments(1)" onMouseUp="this.blur()">{lang_print id=854}</a></td></tr></table></td>{/if}
    
    {* PLUGIN RELATED PROFILE TABS *}
    {hook_foreach name=profile_tab var=profile_tab_args max=8 complete=profile_tab_complete}
      <td valign='bottom'>
        <table cellpadding='0' cellspacing='0' style='float: left;'>
          <tr>
            <td class='profile_tab{if $v == $profile_tab_args.name}2{/if}' id='profile_tabs_{$profile_tab_args.name}' onMouseUp="this.blur();">
              <a href='javascript:void(0);' onMouseDown="loadProfileTab('{$profile_tab_args.name}')" onMouseUp="this.blur();">
                {lang_print id=$profile_tab_args.title}
              </a>
            </td>
          </tr>
        </table>
      </td>
    {/hook_foreach}
    
    {if !$profile_tab_complete}
      <td valign='bottom'>
        <table cellpadding='0' cellspacing='0' style='float: left;'>
          <tr>
            <td class='profile_tab' onMouseUp="this.blur();" nowrap="nowrap">
              <a href="javascript:void(0);" onclick="$('profile_tab_dropdown').style.display = ( $('profile_tab_dropdown').style.display=='none' ? 'inline' : 'none' ); this.blur(); return false;" nowrap="nowrap">
                {lang_print id=1317}
              </a>
            </td>
          </tr>
        </table>
        <div class='menu_profile_dropdown' id='profile_tab_dropdown' style='display: none;'>
          <div>
            {* SHOW ANY PLUGIN MENU ITEMS *}
            {hook_foreach name=profile_tab var=profile_tab_args start=8}
            <div class='menu_profile_item_dropdown'>
              <div  id='profile_tabs_{$profile_tab_args.name}' onMouseUp="this.blur();">
              <a href='javascript:void(0);' onMouseDown="loadProfileTab('{$profile_tab_args.name}')" onMouseUp="this.blur();" class='menu_profile_item' style="text-align: left;">
                {lang_print id=$profile_tab_args.title}
              </a>
            </div></div>
            {/hook_foreach}
          </div>
        </div>
      </td>
    {/if}
    
    <td width='100%' class='profile_tab_end'>&nbsp;</td>
    </tr>
    </table>
    
    
    
    
    <div class='profile_content'>
    
    {* PROFILE TAB *}
    <div id='profile_profile'{if $v != 'profile'} style='display: none;'{/if}>
      
      {* SHOW PROFILE CATS AND FIELDS *}
      {section name=cat_loop loop=$cats}
        {section name=subcat_loop loop=$cats[cat_loop].subcats}
          <div class='profile_headline{if !$smarty.section.subcat_loop.first}2{/if}'><b>{lang_print id=$cats[cat_loop].subcats[subcat_loop].subcat_title}</b></div>
            
            <table cellpadding='0' cellspacing='0'>
            {* LOOP THROUGH FIELDS IN TAB, ONLY SHOW FIELDS THAT HAVE BEEN FILLED IN *}
            {section name=field_loop loop=$cats[cat_loop].subcats[subcat_loop].fields}
              <tr>
              <td valign='top' style='padding-right: 10px;' nowrap='nowrap'>
                {lang_print id=$cats[cat_loop].subcats[subcat_loop].fields[field_loop].field_title}:
              </td>
              <td>
                <div class='profile_field_value'>{$cats[cat_loop].subcats[subcat_loop].fields[field_loop].field_value_formatted}</div>
                {if $cats[cat_loop].subcats[subcat_loop].fields[field_loop].field_special == 1 && $cats[cat_loop].subcats[subcat_loop].fields[field_loop].field_value|substr:0:4 != "0000"} ({lang_sprintf id=852 1=$datetime->age($cats[cat_loop].subcats[subcat_loop].fields[field_loop].field_value)}){/if}
              </td>
              </tr>
            {/section}
            </table>
          
        {/section}
      {/section}
      {* END PROFILE TABS AND FIELDS *}
      
      {* SHOW RECENT ACTIVITY *}
      {if $actions|@count > 0}
        {literal}
        <script language="JavaScript">
        <!-- 
          Rollimage0 = new Image(10,12);
          Rollimage0.src = "./images/icons/action_delete1.gif";
          Rollimage1 = new Image(10,12);
          Rollimage1.src = "./images/icons/action_delete2.gif";
        //-->
        </script>
        {/literal}
        
        {* SHOW RECENT ACTIONS *}
        <div style='padding-bottom: 10px;' id='actions'>
          <div class='profile_headline2'><b>{lang_print id=851}</b></div>
          {section name=actions_loop loop=$actions}
            <div id='action_{$actions[actions_loop].action_id}' class='profile_action'>
              <table cellpadding='0' cellspacing='0'>
              <tr>
              <td valign='top'><img src='./images/icons/{$actions[actions_loop].action_icon}' border='0' class='icon'></td>
              <td valign='top' width='100%'>
                <div class='profile_action_date'>
                  {assign var='action_date' value=$datetime->time_since($actions[actions_loop].action_date)}
                  {lang_sprintf id=$action_date[0] 1=$action_date[1]}
                  {* DISPLAY DELETE LINK IF NECESSARY *}
                  {if $setting.setting_actions_selfdelete == 1 && $actions[actions_loop].action_user_id == $user->user_info.user_id}
                    <img src='./images/icons/action_delete1.gif' style='vertical-align: middle; margin-left: 3px; cursor: pointer; cursor: hand;' border='0' onmouseover="this.src=Rollimage1.src;" onmouseout="this.src=Rollimage0.src;" onClick="SocialEngine.Viewer.userActionDelete({$actions[actions_loop].action_id});" />
                  {/if}
                </div>
                {assign var='action_media' value=''}
                {if $actions[actions_loop].action_media !== FALSE}{capture assign='action_media'}{section name=action_media_loop loop=$actions[actions_loop].action_media}<a href='{$actions[actions_loop].action_media[action_media_loop].actionmedia_link}'><img src='{$actions[actions_loop].action_media[action_media_loop].actionmedia_path}' border='0' width='{$actions[actions_loop].action_media[action_media_loop].actionmedia_width}' class='recentaction_media'></a>{/section}{/capture}{/if}
                {lang_sprintf assign=action_text id=$actions[actions_loop].action_text args=$actions[actions_loop].action_vars}
                {$action_text|replace:"[media]":$action_media|choptext:50:"<br>"}
              </td>
              </tr>
              </table>
            </div>
          {/section}
        </div>
      {/if}
      {* END RECENT ACTIVITY *}
      
    </div>
    {* END PROFILE TAB *}
    
    
    
    
    
    {* FRIENDS TAB *}
    {if $total_friends_all != 0}
      <div id='profile_friends'{if $v != 'friends'} style='display: none;'{/if}>
        
        <div>
          <div style='float: left; width: 50%;'>
            <div class='profile_headline'>
              {if $m == 1}
                {lang_sprintf id=1024 1=$owner->user_displayname_short}
              {else}
                {lang_sprintf id=930 1=$owner->user_displayname_short}
              {/if} ({$total_friends})
            </div>
          </div>
          <div style='float: right; width: 50%; text-align: right;'>
            {if $search == ""}
              <div id='profile_friends_searchbox_link'>
                <a href='javascript:void(0);' onClick="$('profile_friends_searchbox_link').style.display='none';$('profile_friends_searchbox').style.display='block';$('profile_friends_searchbox_input').focus();">{lang_print id=1197}</a>
              </div>
            {/if}
            <div id='profile_friends_searchbox' style='text-align: right;{if $search == ""} display: none;{/if}'>
              <form action='profile.php' method='post'>
              <input type='text' maxlength='100' size='30' class='text' name='search' value='{$search}' id='profile_friends_searchbox_input'>
              <input type='submit' class='button' value='{lang_print id=646}'>
              <input type='hidden' name='p' value='{$p}'>
              <input type='hidden' name='v' value='friends'>
              <input type='hidden' name='user' value='{$owner->user_info.user_username}'>
              </form>
            </div>
          </div>
          <div style='clear: both;'></div>
        </div>
        
        {* IF MUTUAL FRIENDS EXIST, SHOW OPTION TO VIEW THEM *}
        {if $owner->user_info.user_id != $user->user_info.user_id && $total_friends_mut != 0}
          <div style='margin-bottom: 10px;'>
            {if $m != 1}
              {lang_print id=1022}
            {else}
              <a href='profile.php?user={$owner->user_info.user_username}&v=friends'>{lang_print id=1022}</a>
            {/if}
            &nbsp;|&nbsp; 
            {if $m == 1}
              {lang_print id=1020}
            {else}
              <a href='profile.php?user={$owner->user_info.user_username}&v=friends&m=1'>{lang_print id=1020}</a>
            {/if}
          </div>
        {/if}
        
        {* DISPLAY NO RESULTS MESSAGE *}
        {if $search != "" && $total_friends == 0}
          <br>
          <table cellpadding='0' cellspacing='0'>
          <tr><td class='result'>
            <img src='./images/icons/bulb16.gif' border='0' class='icon'>{lang_sprintf id=934 1=$owner->user_displayname_short}
          </td></tr>
          </table>
        {elseif $m == 1 && $total_friends == 0}
          <br>
          <table cellpadding='0' cellspacing='0'>
          <tr><td class='result'>
            <img src='./images/icons/bulb16.gif' border='0' class='icon'>{lang_sprintf id=1023 1=$owner->user_displayname_short}
          </td></tr>
          </table>
        {/if}
        
        
        {* DISPLAY PAGINATION MENU IF APPLICABLE *}
        {if $maxpage_friends > 1}
          <div style='text-align: center;'>
            {if $p_friends != 1}<a href='profile.php?user={$owner->user_info.user_username}&v=friends&search={$search}&m={$m}&p={math equation='p-1' p=$p_friends}'>« {lang_print id=182}</a>{else}<font class='disabled'>« {lang_print id=182}</font>{/if}
            {if $p_start_friends == $p_end_friends}
              &nbsp;|&nbsp; {lang_sprintf id=184 1=$p_start_friends 2=$total_friends} &nbsp;|&nbsp; 
            {else}
              &nbsp;|&nbsp; {lang_sprintf id=185 1=$p_start_friends 2=$p_end_friends 3=$total_friends} &nbsp;|&nbsp; 
            {/if}
            {if $p_friends != $maxpage_friends}<a href='profile.php?user={$owner->user_info.user_username}&v=friends&search={$search}&m={$m}&p={math equation='p+1' p=$p_friends}'>{lang_print id=183} »</a>{else}<font class='disabled'>{lang_print id=183} »</font>{/if}
          </div>
        {/if}
        
        {* LOOP THROUGH FRIENDS *}
        {section name=friend_loop loop=$friends}
          <div class='browse_friends_result' style='overflow: hidden;'>
            <div class='profile_friend_photo'>
              <a href='{$url->url_create("profile",$friends[friend_loop]->user_info.user_username)}'>
                <img src='{$friends[friend_loop]->user_photo("./images/nophoto.gif")}' width='{$misc->photo_size($friends[friend_loop]->user_photo("./images/nophoto.gif"),"90","90","w")}' border='0' alt="{lang_sprintf id=509 1=$friends[friend_loop]->user_displayname_short}">
              </a>
            </div>
            <div class='profile_friend_info'>
              <div class='profile_friend_name'><a href='{$url->url_create('profile',$friends[friend_loop]->user_info.user_username)}'>{$friends[friend_loop]->user_displayname}</a></div>
              <div class='profile_friend_details'>
                {if $friends[friend_loop]->user_info.user_dateupdated != 0}<div>{lang_print id=849} {assign var='last_updated' value=$datetime->time_since($friends[friend_loop]->user_info.user_dateupdated)}{lang_sprintf id=$last_updated[0] 1=$last_updated[1]}</div>{/if}
                {if $show_details != 0}
                  {if $friends[friend_loop]->friend_type != ""}<div>{lang_print id=882} {$friends[friend_loop]->friend_type}</div>{/if}
                  {if $friends[friend_loop]->friend_explain != ""}<div>{lang_print id=907} {$friends[friend_loop]->friend_explain}</div>{/if}
                {/if}
              </div>
            </div>
            <div class='profile_friend_options'>
              {if !$friends[friend_loop]->is_viewers_friend && !$friends[friend_loop]->is_viewers_blocklisted && $friends[friend_loop]->user_info.user_id != $user->user_info.user_id && $user->user_exists != 0}<div id='addfriend_{$friends[friend_loop]->user_info.user_id}'><a href="javascript:TB_show('{lang_print id=876}', 'user_friends_manage.php?user={$friends[friend_loop]->user_info.user_username}&TB_iframe=true&height=300&width=450', '', './images/trans.gif');">{lang_print id=838}</a></div>{/if}
              {if !$members[member_loop].member->is_viewer_blocklisted && ($user->level_info.level_message_allow == 2 || ($user->level_info.level_message_allow == 1 && $friends[friend_loop]->is_viewers_friend == 2)) && $friends[friend_loop]->user_info.user_id != $user->user_info.user_id}<a href="javascript:TB_show('{lang_print id=784}', 'user_messages_new.php?to_user={$friends[friend_loop]->user_displayname}&to_id={$friends[friend_loop]->user_info.user_username}&TB_iframe=true&height=400&width=450', '', './images/trans.gif');">{lang_print id=839}</a>{/if}
            </div>
            <div style='clear: both;'></div>
          </div>
        {/section}
        
        
        {* DISPLAY PAGINATION MENU IF APPLICABLE *}
        {if $maxpage_friends > 1}
          <div style='text-align: center;'>
            {if $p_friends != 1}<a href='profile.php?user={$owner->user_info.user_username}&v=friends&search={$search}&m={$m}&p={math equation='p-1' p=$p_friends}'>« {lang_print id=182}</a>{else}<font class='disabled'>« {lang_print id=182}</font>{/if}
            {if $p_start_friends == $p_end_friends}
              &nbsp;|&nbsp; {lang_sprintf id=184 1=$p_start_friends 2=$total_friends} &nbsp;|&nbsp; 
            {else}
              &nbsp;|&nbsp; {lang_sprintf id=185 1=$p_start_friends 2=$p_end_friends 3=$total_friends} &nbsp;|&nbsp; 
            {/if}
            {if $p_friends != $maxpage_friends}<a href='profile.php?user={$owner->user_info.user_username}&v=friends&search={$search}&m={$m}&p={math equation='p+1' p=$p_friends}'>{lang_print id=183} »</a>{else}<font class='disabled'>{lang_print id=183} »</font>{/if}
          </div>
        {/if}
        
        
      </div>
    {/if}
    {* END FRIENDS TAB *}
    
    
    
    
    
    
    
    {* BEGIN COMMENTS TAB *}
    {if $allowed_to_comment != 0 || $total_comments != 0}
      
      {* SHOW COMMENT TAB *}
      <div id='profile_comments'{if $v != 'comments'} style='display: none;'{/if}>
        
        {* COMMENTS *}
        <div id="profile_{$owner->user_info.user_id}_postcomment"></div>
        <div id="profile_{$owner->user_info.user_id}_comments" style='margin-left: auto; margin-right: auto;'></div>
        
        {lang_javascript ids=39,155,175,182,183,184,185,187,784,787,829,830,831,832,833,834,835,854,856,891,1025,1026,1032,1034,1071}
        
        {literal}
        <style type='text/css'>
          div.comment_headline {
            font-size: 10pt; 
            margin-bottom: 7px;
            font-weight: bold;
            padding: 0px;
            border: none;
            background: none;
            color: #555555;
          }
        </style>
        {/literal}
        
        <script type="text/javascript">
        
          SocialEngine.ProfileComments = new SocialEngineAPI.Comments({ldelim}
            'canComment' : {if $allowed_to_comment}true{else}false{/if},
            'commentHTML' : '{$setting.setting_comment_html|replace:",":", "}',
            'commentCode' : {if $setting.setting_comment_code}true{else}false{/if},
            
            'type' : 'profile',
            'typeIdentifier' : 'user_id',
            'typeID' : {$owner->user_info.user_id},
            
            'typeTab' : 'users',
            'typeCol' : 'user',
            
            'initialTotal' : {$total_comments|default:0},
            
            'paginate' : true,
            'cpp' : 10,
            
            'commentLinks' : {literal}{'reply' : true, 'walltowall' : true}{/literal}
          {rdelim});
        
          SocialEngine.RegisterModule(SocialEngine.ProfileComments);
       
          // Backwards
          function addComment(is_error, comment_body, comment_date)
          {ldelim}
            SocialEngine.ProfileComments.addComment(is_error, comment_body, comment_date);
          {rdelim}
        
          function getComments(direction)
          {ldelim}
            SocialEngine.ProfileComments.getComments(direction);
          {rdelim}

        </script>
        
        
      </div>
      
      
    {/if}
    {* END COMMENTS *}
    
    
    
    {* PLUGIN RELATED PROFILE TABS *}
    {hook_foreach name=profile_tab var=profile_tab_args}
      <div id='profile_{$profile_tab_args.name}'{if $v != $profile_tab_args.name} style='display: none;'{/if}>
        {include file=$profile_tab_args.file}
      </div>
    {/hook_foreach}
    
    
  {/if}
  {* END PRIVACY IF STATEMENT *}

  </div>

{* END RIGHT COLUMN *}
</td>
</tr>
</table>

{include file='footer.tpl'}
 
vave, в след. раз за расплод похожих тем получите банан
 
Назад
Сверху