Daily Post Goal?

Started by Veee, June 15, 2017, 04:47:17 AM

Previous topic - Next topic

Veee

Hi,

I am not sure if this is something that can be done in SMF or if there's already some mod like this in the mods section. I looked there and didn't find anything.

There's a similar mod called Activitybar by Suki - https://custom.simplemachines.org/mods/index.php?mod=1929 - which is similar to what I am looking for.

I would like something that would show a post goal everyday. Everyday there would be a 100 posts a day goal on the forum in general. And it would reset everyday - it would show a bar, and it would get fuller by every message a member posted in the forum. A way to make them post more.

I've seen this in other forums, not smf. Is there a way to do that here?
I think it's a fun feature to have in forums. I know it would be for mine. I use the activitybar a lot because some members seem to like that one a lot, always trying to get it to 100% so they invest a lot of time in the forums to get to 100%. :) Having a forum daily post goal would be great!

Thanks :)

MarkoKg

This post might be relevant, up to some point:
https://www.simplemachines.org/community/index.php?topic=228150.msg1465532#msg1465532

I'm still learning how SMF syntax works and not a php/sql pro, but I think that that should be recoded to something like:

// Load post today
   $today = strftime('%Y-%m-%d', forum_time(false));
$request = $smcFunc['db_query']('', '
SELECT posts
FROM smf_log_activity
WHERE date = "$today"
LIMIT 1',
array(
        )

);

$row = $smcFunc['db_fetch_row']($request);
$context['posts']['today'] = $row['posts'];
$smcFunc['db_free_result']($request);}

Not sure if "forum_time" is still a valid value though.

Template code should be the same:
', $context['posts']['today'], ' ', $context['posts']['today'] != 1 ? 'Posts' : 'Post', ' today,

I tried this really quick but query doesn't seem to output anything, hope that someone more proficient could take a look at help. Once you have number of posts made today - It'll be easier to make an activity bar or whatever you want.

Veee

Thank you so much for giving this a try @ MarkoKg.  :P

I wish I had a clue how to develop mods but no idea where to start.

Not sure if I can link to other forums here, so I will show a screenshot of what I was talking about. It's something like this.



Is it possible to do with smf?

Thank you!!

MarkoKg

Sure it's possible, everything is possible  ;D

Can you try to upload attached file to your forums root, where the SSI.php file is?
Then navigate your browser to yoururl.com/poststoday.php and report what you're seeing. I created mysqli query without using SMF's $smcFunc which I dunno how works.
Do note that if your db prefix is different than "smf_" you should change it in query inside that attached file.
I made post count goal for each day to be 200.

live627

QuoteDo note that if your db prefix is different than "smf_" you should change it in query inside that attached file.
{db_prefix} auto-injects the prefix.

MarkoKg

Quote from: live627 on June 15, 2017, 07:45:28 PM
QuoteDo note that if your db prefix is different than "smf_" you should change it in query inside that attached file.
{db_prefix} auto-injects the prefix.
Noted, thanks.

Any chance you can can take a look at the code I originally posted as I'm not sure how to use smcFunc correctly. Also note that I added that to globals before I tried to use it.

Shambles

Quote from: MarkoKg



   $today = strftime('%Y-%m-%d', forum_time(false));
$request = $smcFunc['db_query']('', '
SELECT posts
FROM smf_log_activity
WHERE date = "$today"
LIMIT 1',
array(
        )


I tried this really quick but query doesn't seem to output anything...

If you changed SELECT posts to EXPLAIN SELECT posts it'll tell you that the WHERE clause is infeasible ;)

Try this

Code (find) Select
$request = $smcFunc['db_query']('', '
SELECT posts
FROM {db_prefix}log_activity
WHERE date = {string:today}
LIMIT 1',
array( 'today' => $today
    )
);



Veee

Quote from: MarkoKg on June 15, 2017, 06:55:05 PM
Sure it's possible, everything is possible  ;D

Can you try to upload attached file to your forums root, where the SSI.php file is?
Then navigate your browser to yoururl.com/poststoday.php and report what you're seeing. I created mysqli query without using SMF's $smcFunc which I dunno how works.
Do note that if your db prefix is different than "smf_" you should change it in query inside that attached file.
I made post count goal for each day to be 200.

Just tried it. This is what it shows :D It sems to be working! Thank you!  ;D


Kindred

Quote from: MarkoKg on June 15, 2017, 06:55:05 PM
I created mysqli query without using SMF's $smcFunc which I dunno how works.

No no no no no
By doing this, you expose any site using it to potential attacks.
Smf is very careful to parse and clean all query inputs

By using a direct query, you have now ignored all of SMF's security and exposed a potential hole
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Veee

Quote from: Kindred on June 16, 2017, 09:19:39 PM
Quote from: MarkoKg on June 15, 2017, 06:55:05 PM
I created mysqli query without using SMF's $smcFunc which I dunno how works.

No no no no no
By doing this, you expose any site using it to potential attacks.
Smf is very careful to parse and clean all query inputs

By using a direct query, you have now ignored all of SMF's security and exposed a potential hole

Welp... I had no idea about that, so should I avoid using the script MarkoKg did?  :-X

Kindred

You can use it for testing...  but any use on a live, publicly accessible site should not be done until the queries are properly formed and secure
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Veee

Thank you for your answer.  ::)

I did test it on my live forum. Only if it were accessed as domain.com/poststoday.php though it's deleted now. I used to have another server just for testing stuff up but not anymore. Would there be any problem now that the file isn't on the server? Should I change any settings? I am always super careful with keeping my forum safe. :/

MarkoKg

Thanks Kindred, I'm aware that my method was not best, I just wanted to test if the query was okay.
As I said, I wasn't sure how SMF's smcFunc is working and that's why I wasn't able to build it using that.
Now when Shambles provided query veruskapt should be able to combine that with what I made and have working script, I guess.

P.S - if you removed that file it's safe, and you shouldn't change anything.

Advertisement: