Advertisement:

Author Topic: [MOD][PENDING]Dynamic Forum Signature  (Read 7728 times)

Offline Scareface

  • Semi-Newbie
  • *
  • Posts: 63
  • Gender: Male
  • PEACE
[MOD][PENDING]Dynamic Forum Signature
« on: March 17, 2016, 11:36:06 AM »
Hello everyone, I developed a simple php script to display the forum stats dynamically. I submitted it for approval and forgot to make some changes as I had final exams. Now I think I have made some changes in it. I would like someone to test it in local host.

Any help would be appreciated :)


Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,121
  • Gender: Male
    • Kindred-999 on GitHub
Re: [MOD][PENDING]Dynamic Forum Signature
« Reply #1 on: March 17, 2016, 11:41:20 AM »
What do you mean by "display the forum stats dynamically"? :)
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Scareface

  • Semi-Newbie
  • *
  • Posts: 63
  • Gender: Male
  • PEACE
Re: [MOD][PENDING]Dynamic Forum Signature
« Reply #2 on: March 17, 2016, 11:46:46 AM »
Like this:



It updates according to the stats :P

Offline karlbenson

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,629
  • Gender: Male
    • @mortonssols on Twitter
    • Criminal Solicitors
Re: [MOD][PENDING]Dynamic Forum Signature
« Reply #3 on: March 17, 2016, 06:25:20 PM »
Nice.   I had one of these several years back.
Perhaps some suggestions
- It may be useful to try to use the smf cache to try to avoid it being run every page load especially if you have use your signature on a very popular site.
- Spiders hammered the script and wasting resources.

Online Pipke

  • Jr. Member
  • **
  • Posts: 377
    • NRNS-GAMES
Re: [MOD][PENDING]Dynamic Forum Signature
« Reply #4 on: March 19, 2016, 06:29:02 PM »
i found hardcoded txtstrings and got error in log.

http://localhost/f/index.php?action=admin;area=packages;sa=install2;package=ForumSig_0_1.zip;pid=0
Apply Filter: Only show the errors with the same message
2: copy(C:\xampp\htdocs\f/Packages/temp/background.png): failed to open stream: No such file or directory
Apply Filter: Only show the errors from this file
File: C:/xampp/htdocs/f/Sources/Subs-Package.php
Line: 1392

also this mod doesnt do anything on my test localhost with xammp.

Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,152
    • @fragicide on Twitter
Re: [MOD][PENDING]Dynamic Forum Signature
« Reply #5 on: March 19, 2016, 09:18:09 PM »
Looking at it as a mod reviewer, these are some things from just a quick glance.

  • File 'background.png' isn't included in the package, which will cause errors on install/uninstall due to these lines in package-info.xml
    <require-file name="background.png" destination="$themedir/images" />
    and
    <remove-file name="$themedir/images/background.png" />
  • Also, files '1.png' and '2.png' are not used and should be removed
  • No empty/isset checks on $_GET variables will cause undefined errors if not defined.
  • Script assumes image manipulation libraries exist. You should check to see if they do, and error out if they don't.
  • Harcoded text strings are not allowed. Use that $txt array.
  • Strongly recommended, like karlbenson said, to use SMF's caching system to reduce load and resource usage.

Offline Scareface

  • Semi-Newbie
  • *
  • Posts: 63
  • Gender: Male
  • PEACE
Re: [MOD][PENDING]Dynamic Forum Signature
« Reply #6 on: March 20, 2016, 02:58:15 AM »
I'll fix those things ASAP :)

Offline nend

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,755
  • 2 deep n2 the code
    • sicommnend on GitHub
    • SIComm.us
Re: [MOD][PENDING]Dynamic Forum Signature
« Reply #7 on: March 23, 2016, 03:59:04 PM »
I don't think you should use SMF's cache system, offset the load to the filesystem and save the generated image.

Offline Scareface

  • Semi-Newbie
  • *
  • Posts: 63
  • Gender: Male
  • PEACE
Re: [MOD][PENDING]Dynamic Forum Signature
« Reply #8 on: March 24, 2016, 10:18:11 AM »
Is there a guide regarding using smf cache into mods ?

Offline margarett

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,761
  • Gender: Male
Re: [MOD][PENDING]Dynamic Forum Signature
« Reply #9 on: March 24, 2016, 11:34:58 AM »
Not really and it's one of the things I'm not very comfortable yet... As usually I got it from other MODs and SMF's codebase so here goes nothing:

Check how I did it here
http://custom.simplemachines.org/mods/index.php?action=parse;attach=236526;smf_version=2.0.11;mod=3805

- check if the cached content is present
Code: [Select]
$membergroups_cache = cache_get_data('membergroups_list', 30);
if (!empty($membergroups_cache)) { //Are our membergroups cached?
From the documentation:
http://support.simplemachines.org/function_db/index.php?action=view_function;id=76
That means that I'll fetch the data "membergroups_list" with a maximum TTL of 30 (minutes, I believe :P )
If no data is found (or the validity time of the cached content has passed) then "cache_get_data" will return NULL and I need to fetch the data from the database
Code: [Select]
else { //No cache, well, let's fetch them, then...
$membergroups = array();
//Load the existing membergroups. With this we can delete the left joins that existed above.
$request = $smcFunc['db_query']('', '
SELECT id_group, group_name, online_color, hidden, stars
FROM {db_prefix}membergroups
WHERE hidden < 2'
);
while ($row = $smcFunc['db_fetch_assoc']($request))
$membergroups[] = $row;
$smcFunc['db_free_result']($request);
//Cache our results
cache_put_data('membergroups_list', $membergroups, 30);
}
And put the fetched data in the "membergroups_list" cache item, from the array variable $membergroups with a TTL of 30.
http://support.simplemachines.org/function_db/index.php?action=view_function;id=75

Hope this helps ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

Quote
Over 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Offline nend

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,755
  • 2 deep n2 the code
    • sicommnend on GitHub
    • SIComm.us
Re: [MOD][PENDING]Dynamic Forum Signature
« Reply #10 on: April 02, 2016, 09:14:29 PM »
From the documentation:
http://support.simplemachines.org/function_db/index.php?action=view_function;id=76
That means that I'll fetch the data "membergroups_list" with a maximum TTL of 30 (minutes, I believe :P )

Actually that only caches the data for 30 seconds.
30 minutes would be 1800  ;)