[Discuss] Support Toolkit 1.0.3 Released

Do not post support requests, bug reports or feature requests. Discuss phpBB here. Non-phpBB related discussion goes in General Discussion!
Scam Warning
BioLogIn
Registered User
Posts: 172
Joined: Sun Jan 06, 2008 10:51 am

Re: [Discuss] Support Toolkit 1.0.3 Released

Post by BioLogIn »

Hey guys! Many thanks for supporting us with this toolkit.

Meanwhile, I'd like to suggest another feature =)
The story is, a while ago I submitted this ticket after encountering some misbehaviour in poll system. It still has to be fixed, but even when it will be, there still be a need for 'resync' feature for poll votes for those who has already encountered this "bug". I just thought it is a good idea to implement one in support toolkit.

Anyway, earlier today I got tired of waiting for someone to fix my polls and came up with the following messy code snippet to check for obsolete polls and votes. Comes with no warranty, do your own auth and backup your database blahblah, but worked fine for me overall:

Code: Select all

// 0 step - check if topic still exists
 $query = 'select DISTINCT a.topic_id,b.topic_title from phpbb_poll_votes a LEFT join phpbb_topics b on a.topic_id=b.topic_id;';
 $result=mysql_query($query);
 if (!$result) {
  $message  = 'Invalid query: ' . mysql_error() . "\n";
  $message .= 'Whole query: ' . $query;
  echo $message;
  return 0;
 }

 $arr2=mysql_fetch_rowsarr($result,MYSQL_ASSOC);
 mysql_free_result($result);

 if ($arr2) 
 {
  foreach ($arr2 as $a)
   if (!isset($a['topic_title'])||$a['topic_title']=='')
   {
    echo 'Topic '.$a['topic_id'].' gone<br />';
    //delete poll
    $query = 'DELETE from phpbb_poll_options where topic_id='.$a['topic_id'].';';
    echo $query.'<br />';
    $result=mysql_query($query);
    if (!$result) {
     $message  = 'Invalid query: ' . mysql_error() . "\n";
     $message .= 'Whole query: ' . $query;
     echo $message;
     return 0;
    }
    //delete voters
    $query = 'DELETE from phpbb_poll_votes where topic_id='.$a['topic_id'].';';
    echo $query.'<br />';
    $result=mysql_query($query);
    if (!$result) {
     $message  = 'Invalid query: ' . mysql_error() . "\n";
     $message .= 'Whole query: ' . $query;
     echo $message;
     return 0;
    }
   } 
 }  

// 1 step - check if author of EACH vote still exists 

 $query = 'select a.topic_id,a.poll_option_id,a.vote_user_id,b.username from phpbb_poll_votes a LEFT join phpbb_users b on a.vote_user_id=b.user_id;';
 $result=mysql_query($query);
 if (!$result) {
  $message  = 'Invalid query: ' . mysql_error() . "\n";
  $message .= 'Whole query: ' . $query;
  echo $message;
  return 0;
 }

 $arr2=mysql_fetch_rowsarr($result,MYSQL_ASSOC);
 mysql_free_result($result);

 if ($arr2) 
 {
  foreach ($arr2 as $a)
   if (!isset($a['username'])||$a['username']=='')
   {
    echo "No user: {$a['topic_id']} {$a['poll_option_id']} {$a['vote_user_id']} {$a['username']}<br />";
    $query = 'DELETE from phpbb_poll_votes where vote_user_id='.$a['vote_user_id'].';';
    echo $query.'<br />';
    $result=mysql_query($query);
    if (!$result) {
     $message  = 'Invalid query: ' . mysql_error() . "\n";
     $message .= 'Whole query: ' . $query;
     echo $message;
     return 0;
    }
   } 
 }

// 2 step - now that we have only relevant votes, we can do some resync
 $query = 'select topic_id,poll_option_id,poll_option_total from phpbb_poll_options;';
 $result=mysql_query($query);
 if (!$result) {
  $message  = 'Invalid query: ' . mysql_error() . "\n";
  $message .= 'Whole query: ' . $query;
  echo $message;
  return 0;
 }
 $arr2=mysql_fetch_rowsarr($result,MYSQL_ASSOC);
 mysql_free_result($result);

 if ($arr2) foreach ($arr2 as $a)
 {
//  $query = 'select count(*) from phpbb_poll_votes where topic_id='.$a['topic_id'].';';
  $query = 'select count(*) from phpbb_poll_votes where topic_id='.$a['topic_id'].' and poll_option_id='.$a['poll_option_id'].';';
  $result=mysql_query($query);
  if (!$result) {
   $message  = 'Invalid query: ' . mysql_error() . "\n";
   $message .= 'Whole query: ' . $query;
   echo $message;
   return 0;
  }
  $arr3=mysql_fetch_rowsarr($result,MYSQL_ASSOC);
  mysql_free_result($result);

  $count=(int)$arr3[0]['count(*)'];
  if ($count != $a['poll_option_total'])
  {
   echo 'Topic '.$a['topic_id'].' poll ID '.$a['poll_option_id'].' needs to be fixed: count shows '.$count.' votes, but '.$a['poll_option_total'].' stored instead<br />';
   //update poll_option_total
    $query = 'UPDATE phpbb_poll_options SET poll_option_total='.$count.' where topic_id='.$a['topic_id'].' and poll_option_id='.$a['poll_option_id'].';';
    echo $query.'<br />';
    $result=mysql_query($query);
    if (!$result) {
     $message  = 'Invalid query: ' . mysql_error() . "\n";
     $message .= 'Whole query: ' . $query;
     echo $message;
     return 0;
    }
  }
  else
   echo 'Topic '.$a['topic_id'].' poll ID '.$a['poll_option_id'].' poll count '.$a['poll_option_total'].' ok<br />'; 
 }
P.S. And a (much appreciated) comment from Bálint:
1. you should mention that the following function is needed

Code: Select all

function mysql_fetch_rowsarr($result, $numass=MYSQL_BOTH) {
  $got=array();
  mysql_data_seek($result, 0);
    while ($row = mysql_fetch_array($result, $numass)) {
        array_push($got, $row);
    }
  return $got;
}
2. instructions in mysql_query should not end with a semicolon.
Last edited by BioLogIn on Mon Jan 23, 2012 4:45 am, edited 1 time in total.
a14
Registered User
Posts: 20
Joined: Tue Nov 16, 2010 4:39 pm

Re: [Discuss] Support Toolkit 1.0.3 Released

Post by a14 »

Hi

I had a problem after I updated Support Toolkit to 1.0.3:

When I click on "Resynchronise user groups" option, the Support Toolkit show a blank page (100% empty content).

Could you tell me what happened and a solution to fix that problem?

Thanks
User avatar
alahamdan
Registered User
Posts: 248
Joined: Tue Oct 23, 2007 7:37 am

Re: [Discuss] Support Toolkit 1.0.3 Released

Post by alahamdan »

Hello

Thanks for the updated version.

This tool is very good for non-experienced phpbb webmasters, i think in the toolkit page you need to clearify options provided by STK more.

Explain more clearly and in a more simple way what each tool do, and to expect after using it.

For example:
# Reclean Usernames: Resets the username_clean entries in the users table.
I dont understand what this do.
# Remove duplicate permissions: Removes duplicate permissions which can break the auth system.
Shall i use this if i see no problems with permission? i mean it can harm my forum, or i can try it to make sure no hidden problems available?

i can find a question about every point listed there, wish some one explain each function more simply and with patience.

Thanks Again.
fabiomaticus
Registered User
Posts: 135
Joined: Tue May 08, 2007 11:56 am
Location: Taranto - ITALY

Re: [Discuss] Support Toolkit 1.0.3 Released

Post by fabiomaticus »

I deleted the stk folder the previous version. I copied the new stk folder, but when I click on http://www.mysite.com/phpbb/stk i have a blank page.

The previous version worked properly.
User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean

Re: [Discuss] Support Toolkit 1.0.3 Released

Post by Erik Frèrejean »

Please post any support questions with regards to the STK in the appropriate area in the CDB, this topic is for discussion only.
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)
z2z
Registered User
Posts: 63
Joined: Sat Nov 25, 2006 9:35 am

Re: [Discuss] Support Toolkit 1.0.3 Released

Post by z2z »

I like the much needed Re-sync attachments and a re-sync avatars tool :D
z2z
Registered User
Posts: 63
Joined: Sat Nov 25, 2006 9:35 am

Re: [Discuss] Support Toolkit 1.0.3 Released

Post by z2z »

I have added search users post link(search.php?author_id=10164&sr=posts) for my convenience ;)

stk/tools/admin/profile_list.php ADD after line:179

Code: Select all

                'U_USER_POST'        => append_sid(PHPBB_ROOT_PATH . 'search.' . PHP_EXT, 'author_id=' . $row['user_id'] . '&sr=posts', true, $user->session_id),
 
profile_list.php (template) Edit line: 64

Code: Select all

						<strong>{L_TOTAL_POSTS}:</strong> <a href="{users.U_USER_POST}">{users.POSTS}</a><br />
and purge cache!

Return to “phpBB Discussion”