Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - alekinna

Pages: 1 [2] 3 4
16
Hi all,

maybe you will like my mod for rating comments.

1. in the file details.php

find
Code: [Select]
unset($random_cat_image);
add below
Code: [Select]
if ($action == "comrate_good" && $id) {
  if ($user_info['user_level'] != GUEST) {
    $sql = "SELECT who_rated
            FROM ".COMMENTS_TABLE."
            WHERE comment_id = $id";
    $row = $site_db->query_firstrow($sql);
    $who_rated_ids = $row['who_rated'];
    $who_rated_array = explode(" ", $who_rated_ids);
    if (!in_array($user_info['user_id'], $who_rated_array)) {
      $who_rated_ids .= " ".$user_info['user_id'];
      $sql = "UPDATE ".COMMENTS_TABLE."
              SET is_good = is_good+1, who_rated = '$who_rated_ids'
              WHERE comment_id = $id";
      if ($site_db->query($sql)) {
        $msg = $lang['voting_com_success'];
      }
      else {
        $msg = $lang['voting_error'];
      }
    }
  }
  else {
    $msg = $lang['only_for_registered'];
  }
}

if ($action == "comrate_bad" && $id) {
  if ($user_info['user_level'] != GUEST) {
    $sql = "SELECT who_rated
            FROM ".COMMENTS_TABLE."
            WHERE comment_id = $id";
    $row = $site_db->query_firstrow($sql);
    $who_rated_ids = $row['who_rated'];
    $who_rated_array = explode(" ", $who_rated_ids);
    if (!in_array($user_info['user_id'], $who_rated_array)) {
      $who_rated_ids .= " ".$user_info['user_id'];
      $sql = "UPDATE ".COMMENTS_TABLE."
              SET is_bad = is_bad+1, who_rated = '$who_rated_ids'
              WHERE comment_id = $id";
      if ($site_db->query($sql)) {
        $msg = $lang['voting_com_success'];
      }
      else {
        $msg = $lang['voting_error'];
      }
    }
  }
  else {
    $msg = $lang['only_for_registered'];
  }
}

1.1 find line with

Code: [Select]
$sql = "SELECT c.comment_id, c.image_id, c.user_id, c.user_name AS comment_user_name,
insert in
Code: [Select]
c.is_good, c.is_bad, c.who_rated,
1.2 find
Code: [Select]
$admin_links = "";
      if ($user_info['user_level'] == ADMIN) {
        $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("comments.php?action=editcomment&amp;comment_id=".$comment_row[$i]['comment_id']))."\" target=\"_blank\">".$lang['edit']."</a>&nbsp;";
        $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("comments.php?action=removecomment&amp;comment_id=".$comment_row[$i]['comment_id']))."\" target=\"_blank\">".$lang['delete']."</a>";
      }
      elseif ($is_image_owner) {
        $admin_links .= ($config['user_edit_comments'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editcomment&amp;".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['edit']."</a>&nbsp;";
        $admin_links .= ($config['user_delete_comments'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removecomment&amp;".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['delete']."</a>";
      }

add below

Code: [Select]
$comment_rank = "";
      if ($user_info['user_level'] == GUEST){
        $comrate_good = "<img src=\"".get_gallery_image("good_off.png")."\" border=\"0\" alt=\"\" title=\"".$lang['only_for_registered']."\" />";
        $comrate_bad = "<img src=\"".get_gallery_image("bad_off.png")."\" border=\"0\" alt=\"\" title=\"".$lang['only_for_registered']."\" />";
      }
      elseif ($user_info['user_id'] == $comment_row[$i]['user_id']) {
        $comrate_good = "<img src=\"".get_gallery_image("good_off.png")."\" border=\"0\" alt=\"\" title=\"".$lang['owner_vote']."\" />";
        $comrate_bad = "<img src=\"".get_gallery_image("bad_off.png")."\" border=\"0\" alt=\"\" title=\"".$lang['owner_vote']."\" />";
      }
      else {
        $comrate_url = $self_url;
        $comrate_url .= (!empty($mode)) ? ((strpos($comrate_url, '?') !== false) ? "&amp;" : "?")."mode=".$mode : "";
        $comrate_url .= strpos($comrate_url, '?') !== false ? "&amp;" : "?";
        $who_rated_array = explode(" ", $comment_row[$i]['who_rated']);
       
        if (!in_array($user_info['user_id'], $who_rated_array)) {
          $comrate_good_url = $comrate_url."action=comrate_good&amp;id=".$comment_row[$i]['comment_id'];
          $comrate_bad_url = $comrate_url."action=comrate_bad&amp;id=".$comment_row[$i]['comment_id'];
          $comrate_good = "<a href=\"".$site_sess->url($comrate_good_url)."\"><img src=\"".get_gallery_image("good.png")."\" border=\"0\" alt=\"\" title=\"".$lang['is_good']."\" /></a>";
          $comrate_bad = "<a href=\"".$site_sess->url($comrate_bad_url)."\"><img src=\"".get_gallery_image("bad.png")."\" border=\"0\" alt=\"\" title=\"".$lang['is_bad']."\" /></a>";
        }
        else {
          $comrate_good = "<img src=\"".get_gallery_image("good_off.png")."\" border=\"0\" alt=\"\" title=\"".$lang['already_com_voted']."\" />";
          $comrate_bad = "<img src=\"".get_gallery_image("bad_off.png")."\" border=\"0\" alt=\"\" title=\"".$lang['already_com_voted']."\" />";
        }
      }
      $comment_rank .= "+".$comment_row[$i]['is_good']." ".$comrate_good." ".$comrate_bad." ".$comment_row[$i]['is_bad']."-";
$site_template->register_vars("comment_rank", $comment_rank);

2. in the file lang/your_lang/main.php

add before ?>
Code: [Select]
$lang['voting_com_success'] = "Thank you for rating this comment";
$lang['already_com_voted'] = "Sorry, you've already rated for this comment once recently.";
$lang['only_for_registered'] = "Only registered users can use this function";
$lang['is_good'] = "It is good comment";
$lang['is_bad'] = "It is bad comment";
$lang['owner_vote'] = "You can not rate your own comment";

3. in the file comment_bit.html

use
Code: [Select]
{comment_rank}
4. Add new rows to existing table 4images_comment

Code: [Select]
ALTER TABLE `4images_comments`
ADD `is_good` int(10) unsigned NOT NULL default '0',
ADD `is_bad` int(10) unsigned NOT NULL default '0',
ADD `who_rated` text

5. new images

You will need 4 images with the names: good.png, bad.png, good_off.png, bad_off.png
save them in the folder template/your_template/images


PS: Only registered users allowed to vote

17
Discussion & Troubleshooting / Using Lightbox_id
« on: January 08, 2009, 06:06:29 AM »
Hi all,

Can somebody explain me for what we use lightbox_id in the table LIGHTBOXES if we have user_id ?
I just want to understand.

18
Mods & Plugins (Requests & Discussions) / Re: 2 each row, How to?
« on: January 06, 2009, 11:34:05 AM »
Is it OK for you?

Code: [Select]
<?php
define
('ROOT_PATH''./');

include(
ROOT_PATH.'config.php');
$site_db = new Db($db_host$db_user$db_password$db_name);


$num_images 4;
$config['image_cells'] = 2;
$i 0;
$sql "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments
        FROM "
.IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
        WHERE a.image_active=1
        AND a.cat_id = b.cat_id
        AND b.auth_viewcat="
.AUTH_ALL."
        AND b.auth_viewimage="
.AUTH_ALL."
        ORDER BY a.image_id DESC
        LIMIT 
$num_images";
$result $site_db->query($sql);

while (
$row $site_db->fetch_array($result)){
  
$image_id $row['image_id'];
  
$cat_id $row['cat_id'];
  
$image_name $row['image_name'];
  
$image_comments $row['image_comments'];
  if(
$i == $config['image_cells']) {
    echo 
"<hr>";
  }
  
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];
  echo 
"&nbsp;&nbsp;<a href=\"".ROOT_PATH."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"1\" alt=\"$image_name\"></a>&nbsp;&nbsp;";
  echo 
"<b>$image_name</b>\n";
  echo 
"Comments: $image_comments\n";
  
$i++;
}
?>

19
ahmed_badawy
jamstave

in the file details.php

find and delete
Code: [Select]
if ($action == "postcomment") {
$page = ceil($num_comments / $commentperpage);
}

20
Discussion & Troubleshooting / Re: Categories
« on: January 05, 2009, 10:37:18 PM »
I edited step 2, try now

21
Discussion & Troubleshooting / Re: Categories
« on: January 05, 2009, 02:21:38 AM »
cch, try this

1. install this code

2. in file includes/functions.php

find block
Code: [Select]
$site_template->register_vars(array(
    "image_id" => $image_row['image_id'],

above this add
Code: [Select]
if ($cat_cache[$image_row['cat_id']]['cat_parent_id']) {
  $cat_parent_name = $cat_cache[$cat_cache[$image_row['cat_id']]['cat_parent_id']]['cat_name'];
}
else {
  $cat_parent_name = "";
}

and below the block add
Code: [Select]
"cat_parent_name" => $cat_parent_name,
    "cat_parent_url" => $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_cache[$image_row['cat_id']]['cat_parent_id']),

3. in the file thumbnail_bit.html

find
Code: [Select]
<a href="{cat_url}">{cat_name}</a><br />
replace with
Code: [Select]
{if index}{if cat_parent_name}<a href="{cat_parent_url}">{cat_parent_name}</a><br>{endif cat_parent_name}{ifno cat_parent_name}<a href="{cat_url}">{cat_name}</a><br />{endifno cat_parent_name}{endif index}{ifno index}<a href="{cat_url}">{cat_name}</a><br />{endifno index}

22
Discussion & Troubleshooting / Re: Immediate Image
« on: December 30, 2008, 04:29:55 AM »

23
Chit Chat / Re: Merry Christmas & a happy New Year
« on: December 25, 2008, 10:03:45 AM »
Русский: Всех с наступающим Новым Годом!! Всего наилучшего вам и форуму!
!עברית: אמנמם זה לא החג הרשמי בארץ, אבל סילבסטר חוגגים כולם - תעשו חיים

24
Discussion & Troubleshooting / Update comments count
« on: December 23, 2008, 04:11:53 AM »
I do little mod that uses user_comments from USERS_TABLE and found that this value not changed if:

1. whole category was deleted
2. image was deleted in ACP  (member.php work fine)

To fix first problem I did
in the file admin/categories.php

find two times
Code: [Select]
$image_ids_sql .= (($image_ids_sql != "") ? ", " : "").$image_row['image_id'];
add below
Code: [Select]
$sql2 = "SELECT user_id
              FROM ".COMMENTS_TABLE."
              WHERE image_id = ".$image_row['image_id']." AND user_id <> ".GUEST;
      $result = $site_db->query($sql2);

      while ($row = $site_db->fetch_array($result)) {
        $sql3 = "UPDATE ".USERS_TABLE."
                SET ".get_user_table_field("", "user_comments")." = ".get_user_table_field("", "user_comments")." - 1
                WHERE ".get_user_table_field("", "user_id")." = ".$row['user_id'];
        $site_db->query($sql3);
      }


To fix second problem I did

in the file admin/images.php

find
Code: [Select]
    if (!empty($user_table_fields['user_comments'])) {
      $sql = "SELECT user_id
              FROM ".COMMENTS_TABLE."
              WHERE image_id = ".$image_row['image_id']." AND user_id <> ".GUEST;
      $result = $site_db->query($sql);

      while ($row = $site_db->fetch_array($result)) {
        $sql = "UPDATE ".USERS_TABLE."
                SET ".get_user_table_field("", "user_comments")." = ".get_user_table_field("", "user_comments")." - 1
                WHERE ".get_user_table_field("", "user_id")." = ".$row['user_id'];
        $site_db->query($sql);
      }
    }

replace with
Code: [Select]
//    if (!empty($user_table_fields['user_comments'])) {
      $sql = "SELECT user_id
              FROM ".COMMENTS_TABLE."
              WHERE image_id = ".$image_row['image_id']." AND user_id <> ".GUEST;
      $result = $site_db->query($sql);

      while ($row = $site_db->fetch_array($result)) {
        $sql = "UPDATE ".USERS_TABLE."
                SET ".get_user_table_field("", "user_comments")." = ".get_user_table_field("", "user_comments")." - 1
                WHERE ".get_user_table_field("", "user_id")." = ".$row['user_id'];
        $site_db->query($sql);
      }
//    }


Can someone just check my solution and tell me if I did right?

26
Hi,

why you use type="hidden" for textarea  image_personal_colored?

27
In the member.php

I added this

Code: [Select]
  $image_personal = un_htmlspecialchars(trim($HTTP_POST_VARS['image_personal']));
  $image_personal_colored = un_htmlspecialchars(trim($HTTP_POST_VARS['image_personal_colored']));

$image_personal = modifystring($image_personal)
  $image_personal_colored = modifystring($image_persona_colored)

function modifystring($str)
{//put here arbitrary modification to the string
}

maybe because misspell
$image_personal_colored = modifystring($image_personal_colored)

28
Ops.. I forgot step 1.1 :oops:

scluzern
bergblume

thanks for your feedback

V@no
thanks for correcting my pure code

29
If you deleted user from DB, for deleting his userpic find in the file admin/users.php

Code: [Select]
$sql = "SELECT ".get_user_table_field("", "user_id").get_user_table_field(", ", "user_name")."
          FROM ".USERS_TABLE."
          WHERE ".get_user_table_field("", "user_id")." IN ($user_ids)";
  $user_result = $site_db->query($sql);
  $image_ids_sql = "";
  while ($user_row = $site_db->fetch_array($user_result)) {
    $user_id = $user_row[$user_table_fields['user_id']];
    $user_name = $user_row[$user_table_fields['user_name']];

replace with
Code: [Select]
$sql = "SELECT ".get_user_table_field("", "user_id").get_user_table_field(", ", "user_name").", userpic
          FROM ".USERS_TABLE."
          WHERE ".get_user_table_field("", "user_id")." IN ($user_ids)";
  $user_result = $site_db->query($sql);
  $image_ids_sql = "";
  while ($user_row = $site_db->fetch_array($user_result)) {
    $user_id = $user_row[$user_table_fields['user_id']];
    $user_name = $user_row[$user_table_fields['user_name']];
    $userpic = $user_row['userpic'];
    if (file_exists(ROOT_PATH."data/userpic/".$userpic)) {
      unlink(ROOT_PATH."data/userpic/".$userpic);
    }

Quote
can anyone tell me how to insert form for uploading user-pic directly in register-form!?

I did in this way:

1. in the template register_form.html before
Code: [Select]
{if captcha_registration}
add
Code: [Select]
          {if userpic_allowed}
          <tr>
            <td width="50%" class="row2" valign="top"><b>{lang_userpic}</b>
              <SPAN class="smalltext">
                <br />
                {lang_userpic_upload}
              </SPAN>
            </td>
            <td class="row2">
              <INPUT type="file" name="userpic_file"  size="30" class="input" />
            </TD>
          </TR>
          {endif userpic_allowed}

1.1 find
Code: [Select]
<form method="POST" action="{url_register}">
replace with
Code: [Select]
<form method="POST" action="{url_register}" enctype="multipart/form-data">

2. in the file register.php

find
Code: [Select]
$captcha = (isset($HTTP_POST_VARS['captcha'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['captcha'])) : "";
add above
Code: [Select]
$userpic = "";
  $userpics_dir = ROOT_PATH."data/userpic/";

2.1 find
Code: [Select]
} // end if
add above
Code: [Select]
    if (!empty($HTTP_POST_FILES['userpic_file']['tmp_name']) && $HTTP_POST_FILES['userpic_file']['tmp_name'] != "none") {
      $userpic = 1;
      $mime_types = array(
        "image/jpeg",
        "image/pjpeg",
        "image/gif",
        "image/x-png"
      );
      $extensions = array(
        "jpg",
        "jpeg",
        "gif",
        "png"
      );
      $userpic_ext = strtolower(substr(strrchr($HTTP_POST_FILES['userpic_file']['name'],"."), 1));
      $userpic_mime = $HTTP_POST_FILES['userpic_file']['type'];
      if (!in_array($userpic_mime, $mime_types) || !in_array($userpic_ext, $extensions)) {
        $error = 1;
        $msg .= (($msg != "") ? "<br />" : "").$lang['invalid_file_type']. " (".$userpic_ext.", ".$HTTP_POST_FILES['userpic_file']['type'].")";
      }
      if ($HTTP_POST_FILES['userpic_file']['size'] > $config['userpic_size'] * 1024) {
        $error = 1;
        $msg .= (($msg != "") ? "<br />" : "").$lang['invalid_file_size'];
      }
    }

2.2 find
Code: [Select]
$additional_field_sql = "";
    $additional_value_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_field_sql .= ", $key";
          $additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
        }
      }
    }
    $activationkey = get_random_key(USERS_TABLE, get_user_table_field("", $user_table_fields['user_activationkey']));
    $user_id = $site_db->get_next_id($user_table_fields['user_id'], USERS_TABLE);

replace with
Code: [Select]
    $activationkey = get_random_key(USERS_TABLE, get_user_table_field("", $user_table_fields['user_activationkey']));
    $user_id = $site_db->get_next_id($user_table_fields['user_id'], USERS_TABLE);
   
    if ($config['userpic'] && $userpic) {
        $userpic_name = $user_id.".".$userpic_ext;
        $userpic_file = $userpics_dir.$userpic_name;

        if (!move_uploaded_file($HTTP_POST_FILES['userpic_file']['tmp_name'], $userpic_file)) {
          $error[] = $lang['file_copy_error'];
        }
        else {
          @chmod($userpic_file, CHMOD_FILES);
          $HTTP_POST_VARS['userpic']  = $userpic_name;
        }

      if (empty($error)) {
        if (!function_exists(init_convert_options)){
          require(ROOT_PATH.'includes/image_utils.php');
        }
        $image_info = getimagesize($userpic_file);
        $convert_options = init_convert_options();
        if (($image_info[0] > $config['userpic_width'] || $image_info[1] > $config['userpic_height'])) {
          if ($convert_options['convert_error'] || (!$convert_options['convert_error'] && !resize_image($userpic_file, 85, $config['userpic_width'], 1))) {
            if ($image_info[0] > $config['userpic_width']) {
              $error[] = $lang['invalid_image_width'];
            }
            if ($image_info[1] > $config['userpic_height']) {
              $error[] = $lang['invalid_image_height'];
            }
          }
        }
      }
      if (!empty($error)) {
        $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".$HTTP_POST_FILES['userpic_file']['name']."</b><br />";
        foreach ($error as $val) {
          $msg .= "<b>".$HTTP_POST_FILES['userpic_file']['name'].":</b> ".$val."<br />";
        }
      }
    }
     
    $additional_field_sql = "";
    $additional_value_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_field_sql .= ", $key";
          $additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
        }
      }
    }

2.3 find
Code: [Select]
"user_invisible_no" => $user_invisible_no,
add below
Code: [Select]
//User Pic
      "userpic_allowed" => $config['userpic'],
      "userpic_max_width" => $config['userpic_width'],
      "userpic_max_height" => $config['userpic_height'],
      "userpic_max_size" => $config['userpic_size']."&nbsp;".$lang['kb'],
      "lang_userpic_upload" => preg_replace("/".$site_template->start."userpic_max_size".$site_template->end."/siU", $config['userpic_size']."&nbsp;".$lang['kb'], preg_replace("/".$site_template->start."userpic_max_width".$site_template->end."/siU", $config['userpic_width'], preg_replace("/".$site_template->start."userpic_max_height".$site_template->end."/siU", $config['userpic_height'], $lang['userpic_upload']))),
//End User Pic

30
Discussion & Troubleshooting / Re: Uploading 2 files with the same name
« on: December 08, 2008, 05:59:00 AM »
Quote
it will affect you in anyway

No, if I have on the server an image home.jpg and upload a new image home.gif the new name for the new file will be home.gif. I want it will be home_2.gif

Quote
but why you need it in that way

For my own little mod: I need to create a new folder with name of image, so it's must be different

------------------------------------------------------
SOLVED!

Pages: 1 [2] 3 4