Author Topic: [MOD] Avatar v2 (by V@no) - 1.7.6 - Deutsch  (Read 4047 times)

0 Members and 1 Guest are viewing this topic.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
[MOD] Avatar v2 (by V@no) - 1.7.6 - Deutsch
« on: October 13, 2008, 12:01:25 AM »
Avatar v2 - 1.7.6 Version - Deutsch

Viele User hatten Interesse an dieser Mod.
Diese Mod lässt den User ein Avatar auswählen, welches in seinem Profil angezeigt wird.
Das Avatar wird auch in den Kommentaren angezeigt. ( kann auch woanders hinzugefügt werden)

Danke an V@no für die Mod: 4images 1.7: http://www.4homepages.de/forum/index.php?topic=3978.msg16252#msg16252
Thanks to V@no for that Mod: 4images 1.7: http://www.4homepages.de/forum/index.php?topic=3978.msg16252#msg16252


Neue Features in v2:
1. Version ist an die 1.7.6 angepasst!
2. User können ein eigenes Avatar uploaden!
3. Admin kann an und ausschalten: Avatare zu nutzen, Avatare zu uploaden, höhe und breite ändern.


Diese Mod wurde auf Windows geschrieben und unter der 4images Version 1.7.6 getestet
---------------------------------------------------------------------------------------------------------------
Folgende Dateien erhalten eine Änderung:


/member.php
/details.php
/includes/upload.php
/includes/db_field_definitions.php
/admin/settings.php
/admin/admin_functions.php
/lang/<yourlanguage>/admin.php
/lang/<yourlanguage>/main.php
/templates/<yourtemplate>/member_profile.html
/templates/<yourtemplate>/member_editprofile.html
/templates/<yourtemplate>/comment_bit.html


---------------------------------------------------------------------------------------

Step 1.
Öffne member.php

Finde:
Code: [Select]
          $site_template->register_vars(array(
        "user_id" => $user_row['user_id'],
        "user_name" => format_text($user_row['user_name'], 2),
        "subject" => format_text($subject, 2),
        "message" => format_text($message, 2),
        "lang_send_email_to" => $lang['send_email_to'],
        "lang_subject" => $lang['subject'],
        "lang_message" => $lang['message'],
        "lang_submit" => $lang['submit'],
        "lang_reset" => $lang['reset']

Replace with:
Code: [Select]
          $site_template->register_vars(array(
     "lang_avatar" => $lang['avatar'],
         "user_avatar_current" => ($config['avatar_use']) ? "<img src=\"".TEMPLATE_PATH."/avatars/".(($user_row['user_avatar'] == "") ? "blank.gif" : $user_row['user_avatar'])."\" name=\"icons\" border=\"0\" alt=\"\">" : "",
        "user_id" => $user_row['user_id'],
        "user_name" => format_text($user_row['user_name'], 2),
        "subject" => format_text($subject, 2),
        "message" => format_text($message, 2),
        "lang_send_email_to" => $lang['send_email_to'],
        "lang_subject" => $lang['subject'],
        "lang_message" => $lang['message'],
        "lang_submit" => $lang['submit'],
        "lang_reset" => $lang['reset']


1.2.
Finde:
Code: [Select]
   if (!$error) {
   $additional_sql = "";
    if (!empty($additional_user_fields)) {
      $table_fields = $site_db->get_table_fields(USERS_TABLE);
      foreach ($additional_user_fields as $key => $val) {
        if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
          $additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
        }
      }
    }

Füge darüber das ein:
Code: [Select]
// Upload Avatar file
  if (!$error) {
     if (!empty($HTTP_POST_FILES['avatar_file']['tmp_name']) && $HTTP_POST_FILES['avatar_file']['tmp_name'] != "none") {
    include(ROOT_PATH.'includes/upload.php');
    $site_upload = new Upload();
    $new_name = $site_upload->upload_file("avatar_file", "avatar", $config['template_dir'], $user_info['user_id']);
     if (!$new_name) {
     $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".$new_name."</b><br />".$site_upload->get_upload_errors();
     $error = 1;
     }else{
    $HTTP_POST_VARS['user_avatar'] = "users/".$new_name;
    $avatars_dir = TEMPLATE_DIR."/".$config['template_dir']."/avatars/users/";
    $dir = opendir($avatars_dir);
    $contents = array();
    while ($contents[] = readdir($dir)){;}
    closedir($dir);
    foreach ($contents as $line){
      $filename = substr($line,0,(strlen($line)-strlen(strrchr($line,"."))));
      $extension = substr(strrchr($line,"."), 1);
      $filename2 = substr($new_name,0,(strlen($new_name)-strlen(strrchr($new_name,"."))));
      $extension2 = substr(strrchr($new_name,"."), 1);
      if ($filename == $filename2 && $extension != $extension2) {
      unlink($avatars_dir.$line);
      }
    }

     }
    }
  }
// End Avatar file


1.3.
Finde:
Code: [Select]
    $user_icq = $user_info['user_icq'];

Füge danach ein:
Code: [Select]
  $user_avatar = $user_info['user_avatar'];


1.4.
Finde:
Code: [Select]
  $site_template->register_vars(array(
    "user_name" => format_text(stripslashes($user_name), 2),

Ersetze mit:
Code: [Select]
//-----------------------
//------ Avatar ---------
//-----------------------
  if ($config['avatar_use']){
   $images = "";
  $checked = ($user_avatar == "blank.gif" || $user_avatar == "") ? " selected" : "";
  $images .= "\n<option value=\"blank.gif\"$checked>none</option>\n";
  $dir = opendir(TEMPLATE_PATH."/avatars/users/");
  $contents = array();
  while ($contents[] = readdir($dir)){;}
  closedir($dir);
  natcasesort ($contents);
  foreach ($contents as $line){
   $filename = substr($line,0,(strlen($line)-strlen(strrchr($line,"."))));
   if ($filename == $user_info['user_id']) {
     $checked = (stristr($user_avatar, "users/")) ? " selected" : "";
     $images .= "\n<option value=\"users/$line\"$checked>".$lang['custom']."</option>\n";
   }
  }
   $dir = opendir(TEMPLATE_PATH."/avatars/");
   $contents = array();
   while ($contents[] = readdir($dir)){;}
   closedir($dir);
   natcasesort ($contents);
   $checked = "";
   foreach ($contents as $line){
      $filename = substr($line,0,(strlen($line)-strlen(strrchr($line,"."))));
      $extension = substr(strrchr($line,"."), 1);
      $checked = "";
      if ($line == $user_avatar) { $checked = " selected"; }
      if (strcasecmp($extension,"gif")==0 || strcasecmp($extension,"jpg")==0 || strcasecmp($extension,"jpeg")==0 || strcasecmp($extension,"png")==0 ){
         if ($line != "blank.gif") {
        $filename = str_replace("_", " ", $filename);
        $images .= "<option value=\"$line\"$checked>$filename</option>\n";
       }
      }
   }
  }
//----------------------
//----- End Avatar -----
//----------------------

  $site_template->register_vars(array(
   "lang_avatar" => $lang['avatar'],
   "lang_avatar_file" => $lang['avatar_file'],
   "lang_avatar_dim" => $lang['avatar_max_dim']." ".$config['avatar_width']."x".$config['avatar_height'].$lang['px'],
   "lang_avatar_select" => $lang['avatar_select'],
   "user_avatar_images" => $images,
   "user_avatar_current" => ($config['avatar_use']) ? "<img src=\"".TEMPLATE_PATH."/avatars/".(($user_avatar == "") ? "blank.gif" : $user_avatar)."\" name=\"icons\" border=\"0\" alt=\"\">" : "",
   "lang_or" => $lang['or'],
   "user_avatar_file" => $config['avatar_user_custom'],
    "user_email" => format_text(stripslashes($user_email), 2),



Step 2.
Öffne details.php
Finde:
Code: [Select]
      $comment_user_id = $comment_row[$i]['user_id'];

Füge danach ein:
Code: [Select]
    $user_row_comment = get_user_info($comment_user_id);


2.2.
Finde:
Code: [Select]
        "comment_id" => $comment_row[$i]['comment_id'],

Füge danach einr:
Code: [Select]
    "user_avatar_current" => ($config['avatar_use']) ? "<img src=\"".TEMPLATE_PATH."/avatars/".(($user_row_comment['user_avatar'] == "") ? "blank.gif" : $user_row_comment['user_avatar'])."\" name=\"icons\" border=\"0\" hspace=\"15\" alt=\"\">" : "",




Step 3.
Öffne /includes/upload.php
Finde:
Code: [Select]
     $this->max_width['thumb'] = $config['max_thumb_width'];
    $this->max_width['media'] = $config['max_image_width'];
    $this->max_height['thumb'] = $config['max_thumb_height'];
    $this->max_height['media'] = $config['max_image_height'];
$this->auto_image['media'] = $config['auto_image'];

    $this->max_size['thumb'] = $config['max_thumb_size'] * 1024;
    $this->max_size['media'] = $config['max_media_size'] * 1024;

Ersetze mit:
Code: [Select]
        $this->max_width['thumb'] = $config['max_thumb_width'];
    $this->max_width['media'] = $config['max_image_width'];
    $this->max_height['thumb'] = $config['max_thumb_height'];
    $this->max_height['media'] = $config['max_image_height'];
$this->max_width['avatar'] = $config['avatar_width'];
    $this->max_height['avatar'] = $config['avatar_height'];
$this->auto_image['media'] = $config['auto_image'];

    $this->max_size['thumb'] = $config['max_thumb_size'] * 1024;
    $this->max_size['media'] = $config['max_media_size'] * 1024;
$this->max_size['avatar'] = 99999999999;



3.2.
Finde:
Code: [Select]
  function copy_file() {

Füge danach ein:
Code: [Select]
  if ($this->image_type == "avatar") {
    if (file_exists($this->upload_path[$this->image_type]."/".$this->file_name)) {
        @unlink($this->upload_path[$this->image_type]."/".$this->file_name);
      }
      $ok = move_uploaded_file($this->upload_file, $this->upload_path[$this->image_type]."/".$this->file_name);
  }else{

3.3.
Finde:
Code: [Select]
    @chmod($this->upload_path[$this->image_type]."/".$this->file_name, CHMOD_FILES);
Ersetze mit:
Code: [Select]
  }
    @chmod($this->upload_path[$this->image_type]."/".$this->file_name, CHMOD_FILES);


3.4.
Finde:
Code: [Select]
    if ($cat_id) {
      $this->upload_path['thumb'] = THUMB_PATH."/".$cat_id;
      $this->upload_path['media'] = MEDIA_PATH."/".$cat_id;
    }
    else {
      $this->upload_path['thumb'] = THUMB_TEMP_PATH;
      $this->upload_path['media'] = MEDIA_TEMP_PATH;
    }

    if ($file_name != "") {

Ersetze mit:
Code: [Select]
    if ($cat_id) {
      $this->upload_path['thumb'] = THUMB_PATH."/".$cat_id;
      $this->upload_path['media'] = MEDIA_PATH."/".$cat_id;
    $this->upload_path['avatar'] = TEMPLATE_DIR."/".$cat_id."/avatars/users";
    }
    else {
      $this->upload_path['thumb'] = THUMB_TEMP_PATH;
      $this->upload_path['media'] = MEDIA_TEMP_PATH;
    }

    if ($file_name != "" && $this->image_type != "avatar") {


3.5.
Finde:
Code: [Select]
    $this->mime_type = $this->HTTP_POST_FILES[$this->field_name]['type'];

Ersetze mit:
Code: [Select]
if ($this->image_type == "avatar") {
    $this->file_name = $file_name.".".$this->extension;
  }

    $this->mime_type = $this->HTTP_POST_FILES[$this->field_name]['type'];


3.6.
Finde:
Code: [Select]
       $this->accepted_extensions['thumb'] = array(
      "jpg",
      "jpeg",
      "gif",
      "png"
    );

Danach einfügen:
Code: [Select]
  //Avatar
    $this->accepted_mime_types['avatar'] = array(
      "image/jpeg",
      "image/pjpeg",
      "image/gif",
      "image/x-png"
    );
    $this->accepted_extensions['avatar'] = array(
      "jpg",
      "jpeg",
      "gif",
      "png"
    );


3.7. *new
Finde:
Code: [Select]
      $error_msg .= "<b>".$this->file_name.":</b> ".$msg."<br />";

Ersetze mit:
Code: [Select]
      $error_msg .= "<b>".(($this->image_type == "avatar") ? $this->HTTP_POST_FILES[$this->field_name]['name'] : $this->file_name).":</b> ".$msg."<br />";




Step 4.
Öffne /includes/db_field_definitions.php file.
Füge diese zeile hinzu:
Code: [Select]
$additional_user_fields['user_avatar'] = array($lang['avatar'], "avatar", 0);




Step 5.
Öffne /admin/settings.php
Finde:
Code: [Select]
  show_setting_row("highlight_admin", "radio");

Füge danach einr:
Code: [Select]
  show_table_separator($setting_group[XX], 2, "setting_group_XX");
  show_setting_row("avatar_use", "radio");
  show_setting_row("avatar_user_custom", "radio");
  show_setting_row("avatar_width");
  show_setting_row("avatar_height");
Du musst das "XX" durch die Zahl die du brauchst ersetzen. Schau welche zahl die setting_group davor hat!

Step 6.1.
Öffne /admin/settings.php
Finde:
Code: [Select]
        case "text":
      default:
        show_input_row($val[0], $field_name, $value);

Füge davor einr:
Code: [Select]
   case "avatar":
    show_avatar_row($val[0], $field_name, $value);
    break;
Du musst das "XX" durch die Zahl die du brauchst ersetzen. Schau welche zahl die setting_group davor hat!


Step 6.2 *updated
Finde:
Code: [Select]
      } // end switch
    }
  }
}
?>

Füge danach ein:
Code: [Select]
//-----------------------
//------ Avatar ---------
//-----------------------
function show_avatar_row($title, $name, $value = "blank.gif"){
  global $config;
  if ($config['avatar_use']){
  $dir = opendir(TEMPLATE_PATH."/avatars/");
  $contents = array();
  while ($contents[] = readdir($dir)){;}
  closedir($dir);
  natcasesort ($contents);
  echo "<tr width=\"50%\"class=\"".get_row_bg()."\" valign='top'>\n<td><p class=\"rowtitle\">".$title."</p></td>\n";
  echo "<td width=\"50%\" height=\"115\" valign=\"middle\">\n<table>\n<tr>\n<td>\n<SELECT name=\"$name\" size=\"6\" onkeypress=\"if(window.event.keyCode==13){this.form.submit();}\" onChange=\"document.form.icons_$name.src='".TEMPLATE_PATH."/avatars/'+document.form.$name.options[document.form.$name.selectedIndex].value;\">";
   if ($value == "blank.gif" || $value == "") {
   $checked = " selected";
   }else{
   $checked = "";
   }
   echo "<option value=\"blank.gif\"$checked>none</option>\n";
  foreach ($contents as $line){
     $filename = substr($line,0,(strlen($line)-strlen(strrchr($line,"."))));
     $extension = substr(strrchr($line,"."), 1);
     $checked = "";
     if ($line == $value) { $checked = " selected"; }
     if (strcasecmp($extension,"gif")==0 || strcasecmp($extension,"jpg")==0 || strcasecmp($extension,"jpeg")==0 || strcasecmp($extension,"png")==0 ){
      if ($line != "blank.gif") {
      $filename = str_replace("_", " ", $filename);
      echo "<option value=\"$line\"$checked>$filename</option>\n";
      }
     }
  }
  echo "</select>\n</td>\n<td valign='middle' align='left'>\n<img align='center' src=\"".TEMPLATE_PATH."/avatars/".(($value == "") ? "blank.gif" : $value)."\" name=\"icons_$name\" border=\"0\" alt=\"\">\n</td>\n</tr>\n</table>\n</td>\n";
  }
}
//----- End Avatar -----
?>




Step 7.
Öffne /lang/<yourlanguage>/admin.php
Finde:
Code: [Select]
<? :
Füge davor das ein:
Code: [Select]
/*-- Setting-Group XX --*/
$setting_group[XX]="Avatar";
$setting['avatar_use'] = "Benutze Avatare";
$setting['avatar_user_custom'] = "Lasse das nutzen eigener Avatare zu";
$setting['avatar_width'] = "Max. Avatar Breite in Pixel";
$setting['avatar_height'] = "Max. Avatar Höhe in Pixel";
Ersetze das "XX" durch die Zahl die du brauchst. Suche nach der letzten "Setting-Group". ist das zum beipsiel "7" muss deine Zahl "8" sein!


Step 8.
Öffne /lang/<yourlanguage>/main.php
Suche
Code: [Select]
<? :
Davor einfügen:
Code: [Select]
$lang['avatar'] = "Avatar: ";
$lang['avatar_file'] = "Upload Avatar:";
$lang['avatar_max_dim'] = "Max. Zugelassen";
$lang['avatar_select'] = "Wähle eins aus der Liste:";
$lang['custom'] = "Eigenes";


Step 9.
Öffne /templates/<yourtemplate>/member_profile.html
Füge das hinzu:
Code: [Select]
        {if user_avatar_current}
        <TR>
          <TD class="row2"><B>{lang_avatar}</B></TD>
          <TD class="row2">{user_avatar_current}</TD>
        </TR>
        {endif user_avatar_current}


Step 10.
Öffne /templates/<yourtemplate>/member_editprofile.html
Suche:
Code: [Select]
<form method="post" action="{url_member}">Ersetze mit:
Code: [Select]
<FORM method="post" action="{url_member}" name="creator" enctype="multipart/form-data">Suche:
Code: [Select]
          <TR>
            <TD class="row2"><B>{lang_icq}</B></TD>
            <TD class="row2"><INPUT type="text" name="user_icq"  size="30" value="{user_icq}" class="input" /></TD>
          </TR>
Füge darunter das ein:
Code: [Select]
          {if user_avatar_images}
          <TR>
            <TD colspan="2" class="head1">{lang_avatar}</TD>
          </TR>
          <TR>
            <TD class="row2" valign="top"> {if user_avatar_file} <B>{lang_avatar_file}</B><BR />
              <SPAN class="smalltext"> <B>{lang_avatar_dim}</B> </SPAN> <BR>
              <b>{lang_or}</b><BR>
              {endif user_avatar_file} <B> {lang_avatar_select} </B> </TD>
            <TD class="row2"> {if user_avatar_file}
              {lang_upload}
              <INPUT type="file" name="avatar_file"  size="30" class="input" />
              <BR />
              <BR />
              {endif user_avatar_file}
              <SELECT name="user_avatar" size="6" onkeypress="if(window.event.keyCode==13){ this.form.submit(); }" onChange="document.images.icons.src='{template_url}/avatars/'+document.creator.user_avatar.options[document.creator.user_avatar.selectedIndex].value;">
                {user_avatar_images}
              </SELECT>
              <TABLE width="100%" height="100" border="0">
                <TR>
                  <TD align="center"> {user_avatar_current} </TD>
                </TR>
              </TABLE></TD>
          </TR>
          {endif user_avatar_images}



Step 11.
Öffne: /templates/<yourtemplate>/comment_bit.html
Füge das an einer beliebigen Stelle ein:
Code: [Select]
{if user_avatar_current}
  {user_avatar_current}
  {endif user_avatar_current}
Dadurch wird das Avatar im Kommentar angezeigt, oder auch woanders!!


Step 12.
Download "Avatar Install"
Upload  install_avatar.php und avatar.sql in deinem root Ordner wo auch die member.php liegtr, und blank.gif in dem neuen Ordner /templates/<yourtemplate>/avatars
Starte die Installation so http://yourhost.com/your4images/install_avatar.php
(Es werden neuen Felder hinzugefügt. Wenn du Avatar v1 installiert hast, kommen Fehlermeldungen die lauten: dublication field - KEINE ANGST, DASS IST NORMAL)


Erstelle 2 neue Ordner:
/templates/<yourtemplate>/avatars/users/
Uploade deine Avatare in: /avatars/

User können ihre Avatare im Kontrollzentrum aussuchen.

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...