Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-28-2002, 12:51 PM
N9ne N9ne is offline
 
Join Date: Feb 2002
Posts: 1,495
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Post counts never drop

Ok i have 2.2.6 and the code in my functions.php has changed a lot. The prune doesn't reduce post count hack will not work, as my code has changed so much. So it's a simple request i'm sure, but can someone tell me what to do to my functions.php to make it so when a post or thread is deleted, post counts remain the same, and also when there's a prune.
Reply With Quote
  #2  
Old 07-28-2002, 08:36 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you're not allowed to post full vb-files!!!

normally you have to take out this part in a unhacked functions.php:
PHP Code:
    if ($countposts) {
      
$DB_site->query("UPDATE user SET posts=posts-1 WHERE userid='$postinfo[userid]'");
    } 
Reply With Quote
  #3  
Old 07-28-2002, 10:10 PM
N9ne N9ne is offline
 
Join Date: Feb 2002
Posts: 1,495
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I didn't know, I thought it'd be ok since only license holders can download attachments?
Reply With Quote
  #4  
Old 07-28-2002, 11:31 PM
Neo's Avatar
Neo Neo is offline
 
Join Date: Oct 2001
Location: Anywhere
Posts: 1,817
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Its still a rule since by some mishap a un-athorized person might be able to download it.
Reply With Quote
  #5  
Old 07-28-2002, 11:47 PM
N9ne N9ne is offline
 
Join Date: Feb 2002
Posts: 1,495
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok I removed the attachment, below is the code from the file functions.php which needs editing.

PHP Code:
// ###################### Start update thread count #######################
function updatethreadcount($threadid) {
  global 
$DB_site,$threadcache;

    
$replies=$DB_site->query_first("SELECT COUNT(*)-1 AS replies, SUM(attachment.visible) AS attachsum
                                    FROM post
                                    LEFT JOIN attachment ON attachment.attachmentid=post.attachmentid
                                    WHERE threadid='
$threadid'");

    
$lastposts=$DB_site->query_first("SELECT user.username,post.username AS postuser,post.dateline
                                      FROM post
                                      LEFT JOIN user ON user.userid=post.userid
                                      WHERE post.threadid='
$threadid' AND visible>0
                                      ORDER BY dateline DESC
                                      LIMIT 1"
);
    
$lastposter=iif($lastposts['username']=="",$lastposts['postuser'],$lastposts['username']);
    
$lastposttime=$lastposts['dateline'];

    
$firstposts=$DB_site->query_first("SELECT post.userid,user.username,post.username AS postuser,post.dateline
                                       FROM post
                                       LEFT JOIN user ON user.userid=post.userid
                                       WHERE post.threadid='
$threadid' AND visible>0
                                       ORDER BY dateline
                                       LIMIT 1"
);
    
$firstposter=iif($firstposts['username']=="",$firstposts['postuser'],$firstposts['username']);
    
$firstposterid=$firstposts['userid'];

    
$DB_site->query("UPDATE thread SET postusername='".addslashes($firstposter)."',postuserid='$firstposterid',lastpost='$lastposttime',replycount='$replies[replies]',attach='$replies[attachsum]', lastposter='".addslashes($lastposter)."' WHERE threadid='$threadid'");

}

// ###################### Start delete thread #######################
function deletethread($threadid,$countposts=1) {
  global 
$DB_site;

  
// decrement users post counts
  
if ($threadinfo=getthreadinfo($threadid)) {
    
$postids="";
    
$attachmentids="";

    
$posts=$DB_site->query("SELECT userid,attachmentid,postid FROM post WHERE threadid='$threadid'");
    while (
$post=$DB_site->fetch_array($posts)) {
      if (
$countposts) {
        if (!isset(
$userpostcount["$post[userid]"])) {
          
$userpostcount["$post[userid]"] = -1;
        } else {
          
$userpostcount["$post[userid]"]--;
        }
      }
      
$postids.=$post['postid'].",";
      if (
$post['attachmentid'] != 0) {
          
$attachmentids .= $post['attachmentid'].",";
      }
      
unindexpost($post['postid']);
    }

    if (
$attachmentids != '' ) {
      
// make sure you don't remove attachments that are already in use!
      
$checkattachments=$DB_site->query("SELECT DISTINCT attachmentid FROM post WHERE attachmentid IN ($attachmentids"."0) AND threadid<>'$threadid'");
      
$omitattachmentids="";
      while (
$omitattach=$DB_site->fetch_array($checkattachments)) {
        
$omitattachmentids.=$omitattach['attachmentid'].",";
      }
      
$DB_site->query("DELETE FROM attachment WHERE attachmentid IN ($attachmentids"."0) AND NOT attachmentid IN ($omitattachmentids"."0)");
    }

$storeadmin $DB_site->query_first("SELECT * FROM storeadmin");
$storemin=$storeadmin[newthread];
$DB_site->query("UPDATE user SET storep=storep-'$storemin' WHERE userid='$postuserid'");


    if (
$postids!="") {
      
$DB_site->query("DELETE FROM post WHERE postid IN ($postids"."0)");
    }
    if (
$threadinfo['pollid']!=0) {
      
$DB_site->query("DELETE FROM poll WHERE pollid='$threadinfo[pollid]'");
      
$DB_site->query("DELETE FROM pollvote WHERE pollid='$threadinfo[pollid]'");
    }
    
$DB_site->query("DELETE FROM thread WHERE threadid='$threadid'");
    
$DB_site->query("DELETE FROM thread WHERE open=10 AND pollid='$threadid'"); // delete redirects
    
$DB_site->query("DELETE FROM threadrate WHERE threadid='$threadid'");
    
$DB_site->query("DELETE FROM subscribethread WHERE threadid='$threadid'");
  }
}

// ###################### Start delete post #######################
function deletepost($postid,$countposts=1,$threadid=0) {
  global 
$DB_site;

  
// decrement user post count
  
if ($postinfo=getpostinfo($postid)) {
$storeadmin $DB_site->query_first("SELECT * FROM storeadmin");
$storem=$storeadmin[newreply];
$DB_site->query("UPDATE user SET storep=storep-'$storem' WHERE userid='$postinfo[userid]'");
   
   if (
$postinfo['attachmentid']) {
            
// make sure you don't remove attachments still in use
            
$otherattachs=$DB_site->query("SELECT attachmentid FROM post WHERE attachmentid=$postinfo[attachmentid] AND threadid<>'$postinfo[threadid]'");
            if (
$DB_site->num_rows($otherattachs)==0) {
                
$DB_site->query("DELETE FROM attachment WHERE attachmentid=$postinfo[attachmentid]");
        
$DB_site->query("UPDATE thread SET attach = attach - 1 WHERE threadid = '$threadid'");
            }
    }

    
$DB_site->query("DELETE FROM post WHERE postid='$postid'");
  }
}

// ###################### Start make login code #######################
function makelogincode() {
  global 
$DB_site,$bbuserinfo,$session;

  if (
$bbuserinfo['userid']==0) {
    eval(
"\$logincode = \"".gettemplate("username_loggedout")."\";");
  } else {
    eval(
"\$logincode = \"".gettemplate("username_loggedin")."\";");
  }

  return 
$logincode;
}

// ###################### Start un htmlspecialchars ####################### 
Reply With Quote
  #6  
Old 07-29-2002, 12:44 PM
N9ne N9ne is offline
 
Join Date: Feb 2002
Posts: 1,495
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

bump, anyone? pwease
Reply With Quote
  #7  
Old 07-29-2002, 07:44 PM
N9ne N9ne is offline
 
Join Date: Feb 2002
Posts: 1,495
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

bump
Reply With Quote
  #8  
Old 07-29-2002, 07:46 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

it's a problem because i don't know the hack, but i think this should do it:
PHP Code:
// ###################### Start update thread count #######################
function updatethreadcount($threadid) {
  global 
$DB_site,$threadcache;

    
$replies=$DB_site->query_first("SELECT COUNT(*)-1 AS replies, SUM(attachment.visible) AS attachsum
                                    FROM post
                                    LEFT JOIN attachment ON attachment.attachmentid=post.attachmentid
                                    WHERE threadid='
$threadid'");

    
$lastposts=$DB_site->query_first("SELECT user.username,post.username AS postuser,post.dateline
                                      FROM post
                                      LEFT JOIN user ON user.userid=post.userid
                                      WHERE post.threadid='
$threadid' AND visible>0
                                      ORDER BY dateline DESC
                                      LIMIT 1"
);
    
$lastposter=iif($lastposts['username']=="",$lastposts['postuser'],$lastposts['username']);
    
$lastposttime=$lastposts['dateline'];

    
$firstposts=$DB_site->query_first("SELECT post.userid,user.username,post.username AS postuser,post.dateline
                                       FROM post
                                       LEFT JOIN user ON user.userid=post.userid
                                       WHERE post.threadid='
$threadid' AND visible>0
                                       ORDER BY dateline
                                       LIMIT 1"
);
    
$firstposter=iif($firstposts['username']=="",$firstposts['postuser'],$firstposts['username']);
    
$firstposterid=$firstposts['userid'];

    
$DB_site->query("UPDATE thread SET postusername='".addslashes($firstposter)."',postuserid='$firstposterid',lastpost='$lastposttime',replycount='$replies[replies]',attach='$replies[attachsum]', lastposter='".addslashes($lastposter)."' WHERE threadid='$threadid'");

}

// ###################### Start delete thread #######################
function deletethread($threadid,$countposts=1) {
  global 
$DB_site;

  
// decrement users post counts
  
if ($threadinfo=getthreadinfo($threadid)) {
    
$postids="";
    
$attachmentids="";

    
$posts=$DB_site->query("SELECT userid,attachmentid,postid FROM post WHERE threadid='$threadid'");
    while (
$post=$DB_site->fetch_array($posts)) {
      if (
$countposts) {
        if (!isset(
$userpostcount["$post[userid]"])) {
          
$userpostcount["$post[userid]"] = -1;
        } else {
          
$userpostcount["$post[userid]"]--;
        }
      }
      
$postids.=$post['postid'].",";
      if (
$post['attachmentid'] != 0) {
          
$attachmentids .= $post['attachmentid'].",";
      }
      
unindexpost($post['postid']);
    }

    if (
$attachmentids != '' ) {
      
// make sure you don't remove attachments that are already in use!
      
$checkattachments=$DB_site->query("SELECT DISTINCT attachmentid FROM post WHERE attachmentid IN ($attachmentids"."0) AND threadid<>'$threadid'");
      
$omitattachmentids="";
      while (
$omitattach=$DB_site->fetch_array($checkattachments)) {
        
$omitattachmentids.=$omitattach['attachmentid'].",";
      }
      
$DB_site->query("DELETE FROM attachment WHERE attachmentid IN ($attachmentids"."0) AND NOT attachmentid IN ($omitattachmentids"."0)");
    }

$storeadmin $DB_site->query_first("SELECT * FROM storeadmin");
$storemin=$storeadmin[newthread];



    if (
$postids!="") {
      
$DB_site->query("DELETE FROM post WHERE postid IN ($postids"."0)");
    }
    if (
$threadinfo['pollid']!=0) {
      
$DB_site->query("DELETE FROM poll WHERE pollid='$threadinfo[pollid]'");
      
$DB_site->query("DELETE FROM pollvote WHERE pollid='$threadinfo[pollid]'");
    }
    
$DB_site->query("DELETE FROM thread WHERE threadid='$threadid'");
    
$DB_site->query("DELETE FROM thread WHERE open=10 AND pollid='$threadid'"); // delete redirects
    
$DB_site->query("DELETE FROM threadrate WHERE threadid='$threadid'");
    
$DB_site->query("DELETE FROM subscribethread WHERE threadid='$threadid'");
  }
}

// ###################### Start delete post #######################
function deletepost($postid,$countposts=1,$threadid=0) {
  global 
$DB_site;

  
// decrement user post count
  
if ($postinfo=getpostinfo($postid)) {
$storeadmin $DB_site->query_first("SELECT * FROM storeadmin");
$storem=$storeadmin[newreply];

   
   if (
$postinfo['attachmentid']) {
            
// make sure you don't remove attachments still in use
            
$otherattachs=$DB_site->query("SELECT attachmentid FROM post WHERE attachmentid=$postinfo[attachmentid] AND threadid<>'$postinfo[threadid]'");
            if (
$DB_site->num_rows($otherattachs)==0) {
                
$DB_site->query("DELETE FROM attachment WHERE attachmentid=$postinfo[attachmentid]");
        
$DB_site->query("UPDATE thread SET attach = attach - 1 WHERE threadid = '$threadid'");
            }
    }

    
$DB_site->query("DELETE FROM post WHERE postid='$postid'");
  }
}

// ###################### Start make login code #######################
function makelogincode() {
  global 
$DB_site,$bbuserinfo,$session;

  if (
$bbuserinfo['userid']==0) {
    eval(
"\$logincode = \"".gettemplate("username_loggedout")."\";");
  } else {
    eval(
"\$logincode = \"".gettemplate("username_loggedin")."\";");
  }

  return 
$logincode;
}

// ###################### Start un htmlspecialchars ####################### 
Reply With Quote
  #9  
Old 07-29-2002, 09:46 PM
N9ne N9ne is offline
 
Join Date: Feb 2002
Posts: 1,495
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have the store hack installed, so there were a few queries etc for that and I noticed some have been removed from your version?
Reply With Quote
  #10  
Old 07-30-2002, 02:21 PM
N9ne N9ne is offline
 
Join Date: Feb 2002
Posts: 1,495
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

bump
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:06 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04486 seconds
  • Memory Usage 2,374KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete