phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

View unanswered posts (number of)

Goto page Previous  1, 2
 
Search this topic... | Search MOD Requests... | Search Box
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Author Message
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Wed Sep 16, 2009 9:29 pm 
Post subject: Re: View unanswered posts (number of)

Something exactly like this is employed at a site called Halcyon Tears:

Link.

I'm not sure how they did it, but I can ask the owner for you.
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 666
Location: Texas


flag
PostPosted: Thu Sep 17, 2009 4:11 am 
Post subject: Re: View unanswered posts (number of)

Here's a summary of what I was trying to say...

php variables start with a $ sign. So $variable is a variable that contains something. However, $variable is also a string of characters. icon_smile.gif If you want the value of the string $variable use single quotes '$variable' and you get exactly that, the $ sign and the word variable. If you want the value stored in the variable with that name, it has to be inside double quotes "$variable" or outside quotes altogether.

So these are correct. Assume $variable contains a user ID value.
Code:
$sql = 'select username from phpbb_users where user_id = ' . $variable;

Code:
$sql = "select username from phpbb_users where user_id = $variable";


This is not going to work:
Code:
$sql = 'select username from phpbb_users where user_id = $variable';


It gets more complex if your value inside $variable is a string. In that case to use it inside a SQL statement it has to be in quotes. So you might see this:
Code:
$sql = 'Select * from phpbb_users where username = "' . $variable . '"';

Or this
Code:
$sql = "select * from phpbb_users where username = '" . $variable . "'";

You might have to look close to see how those last two are different. icon_smile.gif

BTW, the above code is not secure, so use it as a simple example but don't use it in actual code. The value needs to be confirmed as a proper data type and sanitized.

_________________
phpBBDoctor Blog
Back to top
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Thu Sep 17, 2009 6:06 am 
Post subject: Re: View unanswered posts (number of)

That was the info I was looking for. Thank you drathbun!

And thank you for the link Acaria! I would be very interested in how they did!
Back to top
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Thu Sep 17, 2009 6:41 am 
Post subject: Re: View unanswered posts (number of)

Hrrrm, I think I am to stupid for this stuff.
I tried this:
Code:
      $auth_sql = '';
      if ( $search_forum != -1 )
      {
         $is_auth = auth(AUTH_READ, $search_forum, $userdata);

         if ( !$is_auth['auth_read'] )
         {
            message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']);
         }

         $auth_sql = "f.forum_id = $search_forum";
      }
      else
      {
         $is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);

         if ( $search_cat != -1 )
         {
            $auth_sql = "f.cat_id = $search_cat";
         }

         $ignore_forum_sql = '';
         while( list($key, $value) = each($is_auth_ary) )
         {
            if ( !$value['auth_read'] )
            {
               $ignore_forum_sql .= ( ( $ignore_forum_sql != '' ) ? ', ' : '' ) . $key;
            }
         }

         if ( $ignore_forum_sql != '' )
         {
            $auth_sql .= ( $auth_sql != '' ) ? " AND f.forum_id NOT IN ($ignore_forum_sql) " : "f.forum_id NOT IN ($ignore_forum_sql) ";
         }
      }

// BEGIN Count unanswered posts
if ( $auth_sql != '' )
{
   $sql = "SELECT count(*) as unanswered_topics from " . TOPICS_TABLE . " where forum_id NOT IN (1, 2, 3) and topic_replies = 0 and topic_moved_id = 0 and $auth_sql";
}
if (!($result = $db->sql_query($sql)))
{
     message_die (GENERAL_ERROR, 'Unable to count unanswered topics');
}
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$unanswered_topics = $row['unanswered_topics'];
// END Count unanswered posts

It gives no number of unanswered posts.
ThenI tried this:
Code:
$sql = 'SELECT count(*) as unanswered_topics from ' . TOPICS_TABLE . ' where forum_id NOT IN (1, 2, 3) and topic_replies = 0 and topic_moved_id = 0 and "' . $auth_sql . '"';

Then I get a message that I have no auth at all.
icon_redface.gif
I think the problem is rather located in the start of the code?
$search_forum

/Holger
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Thu Sep 17, 2009 1:37 pm 
Post subject: Re: View unanswered posts (number of)

She linked me to this:

Link.

It's quite old, but that's what she's pretty sure it is. (She didn't install it herself; she bought the site.)
Back to top
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Thu Sep 17, 2009 1:41 pm 
Post subject: Re: View unanswered posts (number of)

Ok, thank you, but I dont think that is the same functionality.
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Thu Sep 17, 2009 1:46 pm 
Post subject: Re: View unanswered posts (number of)

Yeah, I posted the wrong one. icon_razz.gif

Here you go:

Link.
Back to top
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Thu Sep 17, 2009 2:06 pm 
Post subject: Re: View unanswered posts (number of)

Thank you!
I will check that one out!
Back to top
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Fri Sep 18, 2009 12:42 pm 
Post subject: Re: View unanswered posts (number of)

Holger wrote:
Hrrrm, I think I am to stupid for this stuff.
I tried this:
Code:
      $auth_sql = '';
      if ( $search_forum != -1 )
      {
         $is_auth = auth(AUTH_READ, $search_forum, $userdata);

         if ( !$is_auth['auth_read'] )
         {
            message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']);
         }

         $auth_sql = "f.forum_id = $search_forum";
      }
      else
      {
         $is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);

         if ( $search_cat != -1 )
         {
            $auth_sql = "f.cat_id = $search_cat";
         }

         $ignore_forum_sql = '';
         while( list($key, $value) = each($is_auth_ary) )
         {
            if ( !$value['auth_read'] )
            {
               $ignore_forum_sql .= ( ( $ignore_forum_sql != '' ) ? ', ' : '' ) . $key;
            }
         }

         if ( $ignore_forum_sql != '' )
         {
            $auth_sql .= ( $auth_sql != '' ) ? " AND f.forum_id NOT IN ($ignore_forum_sql) " : "f.forum_id NOT IN ($ignore_forum_sql) ";
         }
      }

// BEGIN Count unanswered posts
if ( $auth_sql != '' )
{
   $sql = "SELECT count(*) as unanswered_topics from " . TOPICS_TABLE . " where forum_id NOT IN (1, 2, 3) and topic_replies = 0 and topic_moved_id = 0 and $auth_sql";
}
if (!($result = $db->sql_query($sql)))
{
     message_die (GENERAL_ERROR, 'Unable to count unanswered topics');
}
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$unanswered_topics = $row['unanswered_topics'];
// END Count unanswered posts

It gives no number of unanswered posts.
ThenI tried this:
Code:
$sql = 'SELECT count(*) as unanswered_topics from ' . TOPICS_TABLE . ' where forum_id NOT IN (1, 2, 3) and topic_replies = 0 and topic_moved_id = 0 and "' . $auth_sql . '"';

Then I get a message that I have no auth at all.
icon_redface.gif
I think the problem is rather located in the start of the code?
$search_forum

/Holger

I dont get it working icon_redface.gif
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 666
Location: Texas


flag
PostPosted: Fri Sep 18, 2009 6:17 pm 
Post subject: Re: View unanswered posts (number of)

Is the $auth array getting populated properly? Check to see if it's getting the right values returned.
_________________
phpBBDoctor Blog
Back to top
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Fri Sep 18, 2009 6:19 pm 
Post subject: Re: View unanswered posts (number of)

You are funny icon_lol.gif
If I knew how to do that then I would be able to solve this problem by myself. icon_redface.gif
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Sat Sep 19, 2009 3:45 am 
Post subject: Re: View unanswered posts (number of)

...you could just install that Mod and have the code a few keystrokes away...
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Page 2 of 2 All times are GMT
Goto page Previous  1, 2
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0299 seconds using 15 queries. (SQL 0.0022 Parse 0.0009 Other 0.0267)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo