TRACKER for current tasks, backlogs and new thoughts for forum's development work.


 
Thread Tools Search this Thread
The Lounge What is on Your Mind? TRACKER for current tasks, backlogs and new thoughts for forum's development work.
# 8  
Old 12-30-2018
The prototype logic, for this beta version is here. You can read this code for the logic for all badges:

Code:
<?php
$version = 21;
$query = "SELECT * FROM " . TABLE_PREFIX . "user WHERE userid='" . $uid . "'";
$usertable = $db->query_read_slave($query);
$modaluser = $db->fetch_array($usertable);
$modaluser['joindate_formatted'] = gmdate("d F Y", $modaluser['joindate']);
$modaluser['checking_formatted'] = number_format($modaluser['credits']);
$modaluser['savings_formatted'] = number_format($modaluser['credits_saved']);
$total_bits = $modaluser['credits'] + $modaluser['credits_saved'];
$modaluser['total_bits_formatted'] = number_format($total_bits);
$modaluser['total_thanks_formatted'] = number_format($modaluser['post_thanks_thanked_times']);
$modaluser['total_thanks_given_formatted'] = number_format($modaluser['post_thanks_user_amount']);
$modaluser['total_thanked_posts_formatted'] = number_format($modaluser['post_thanks_thanked_posts']);
$f_query = "SELECT * FROM " . TABLE_PREFIX . "userfield WHERE userid='" . $uid . "'";
$userfields = $db->query_read_slave($f_query);
$modaluserfields = $db->fetch_array($userfields);

$query_csa = "SELECT * FROM " . TABLE_PREFIX . "neo_csa_session_manager WHERE user_id='" . $uid . "'";
$user_csa_row = $db->query_read_slave($query_csa);
$usercsa = $db->fetch_array($user_csa_row);

if ($usercsa['country'] == '') {
    if ($modaluser['country_iso2'] != '') {
        $usercsa['country'] = $modaluser['country_iso2'] . " (Legacy)";
    } else {
        $usercsa['country'] = 'TBD - Waiting for Update';
    }
}
if ($usercsa['ip_address'] == '') {
    if ($modaluser['ipaddress'] != '') {
        $usercsa['ip_address'] = $modaluser['ipaddress'] . " (Legacy)";
    } else {
        $usercsa['ip_address'] = 'TBD - Waiting for Update';
    }
}

if ($usercsa['user_agent'] == '') {
    $usercsa['user_agent'] = 'TBD - Waiting for Update';
}

if ($usercsa[riskscore] == '') {
    $usercsa[riskscore] = 'TBD';
}

if ($usercsa[hitcount] == '') {
    $usercsa[hitcount] = 'TBD';
}

$a_query = "SELECT SUM(visible) AS totalpics FROM album WHERE userid='" . $uid . "'";
$pics = $db->query_read_slave($a_query);
$userpics = $db->fetch_array($pics);

$at_query = "SELECT COUNT(attachmentid) AS totalattachments FROM attachment WHERE userid='" . $uid . "'";
$attachs = $db->query_read_slave($at_query);
$userattachments = $db->fetch_array($attachs);

$pm_query = 'SELECT COUNT(pmtextid) AS count ' .
    'FROM ' . pm .
    ' WHERE userid = "' . $uid . '"';
$userpm = $vbulletin->db->query_first($pm_query);

$sub_query = 'SELECT COUNT(threadid) AS count ' .
    'FROM ' . subscribethread .
    ' WHERE userid = "' . $uid . '"';
$usersubs = $vbulletin->db->query_first($sub_query);
$color = array();
$mbclass = array();

if ($modaluser['posts'] > 1000) {
    $color['fauser'] = 'black';
} elseif ($modaluser['posts'] > 500) {
    $color['fauser'] = 'indigo';
} elseif ($modaluser['posts'] > 100) {
    $color['fauser'] = 'blue';
} elseif ($modaluser['posts'] > 10) {
    $color['fauser'] = 'limegreen';
} else {
    $color['fauser'] = 'lightgray';
}

if ($modaluser['posts'] > 1000) {
    $mbclass['fauser'] = 'mb-4';
} elseif ($modaluser['posts'] > 500) {
    $mbclass['fauser'] = 'mb-3';
} elseif ($modaluser['posts'] > 100) {
    $mbclass['fauser'] = 'mb-3';
} elseif ($modaluser['posts'] > 10) {
    $mbclass['fauser'] = 'mb-1';
} else {
    $mbclass['fauser'] = 'mb-0';
}

$color['faaward'] = 'lightgray';
if ($modaluser['posts'] > 0) {
    $color['faaward'] = 'limegreen';
}

$color['fajediorder'] = 'lightgray';
if ($modaluser['posts'] > 99) {
    $color['fajediorder'] = 'blue';
}

$color['faphoenix'] = 'lightgray';
if ($modaluser['posts'] > 499) {
    $color['faphoenix'] = 'indigo';
}

$color['fajedi'] = 'lightgray';
if ($modaluser['posts'] > 999) {
    $color['fajedi'] = 'black';
}

$color['faatom'] = 'lightgray';
if ($modaluser['posts'] > 9999) {
    $color['faatom'] = 'black';
}

$mods = array('6', '10');
$color['fascale'] = 'lightgray';
if (in_array($modaluser['usergroupid'], $mods)) {
    $color['fascale'] = 'black';
}

$admins = array('1');
$color['fabuilding'] = 'lightgray';
if (in_array($modaluser['userid'], $admins)) {
    $color['fabuilding'] = 'black';
}

$ug = array('6', '10', '13');
$color['fabishop'] = 'lightgray';
if (in_array($modaluser['usergroupid'], $ug)) {
    $color['fabishop'] = 'black';
}

$devops = array('1', '39016', '302063521');
$color['facity'] = 'lightgray';
if (in_array($modaluser['userid'], $devops)) {
    $color['facity'] = 'black';
}

$forumideas = array('1', '39016', '302063521', '302148617');
$color['faflask'] = 'lightgray';
if (in_array($modaluser['userid'], $forumideas)) {
    $color['faflask'] = 'black';
}

$color['fathumbsup'] = 'lightgray';
$color['fatrophy'] = 'lightgray';
$color['fachalkboardteacher'] = 'lightgray';
$color['fashieldalt'] = 'lightgray';
$color['fastroopwafel'] = 'lightgray';
$color['fafirstorderalt'] = 'lightgray';

if ($modaluser['post_thanks_thanked_times'] > 0) {
    $color['fathumbsup'] = 'limegreen';
}

if ($modaluser['post_thanks_thanked_times'] > 99) {
    $color['fathumbsup'] = 'blue';
    $color['fatrophy'] = 'black';
}

if ($modaluser['post_thanks_thanked_times'] > 999) {
    $color['fathumbsup'] = 'indigo';
    $color['fachalkboardteacher'] = 'black';
}

if ($modaluser['post_thanks_thanked_times'] > 1999) {
    $color['fathumbsup'] = 'black';
    $color['fashieldalt'] = 'black';
}

if ($modaluser['post_thanks_thanked_times'] > 2999) {
    $color['fastroopwafel'] = 'black';
}

if ($modaluser['post_thanks_thanked_times'] > 3999) {
    $color['fafirstorderalt'] = 'black';
}

$idfields = 0;
if ($modaluserfields['field1']) {
    $idfields++;
}
if ($modaluserfields['field2']) {
    $idfields++;
}
if ($modaluserfields['field3']) {
    $idfields++;
}
if ($modaluserfields['field4']) {
    $idfields++;
}

switch ($idfields) {
    case 0:
        $color['faidbadge'] = 'lightgray';
        break;
    case 1:
        $color['faidbadge'] = 'limegreen';
        break;
    case 2:
        $color['faidbadge'] = 'blue';
        break;
    case 3:
        $color['faidbadge'] = 'indigo';
        break;
    case 4:
        $color['faidbadge'] = 'black';
        break;
}

$contacts = 0;
if ($show['pm']) {
    $contacts++;
}
if ($show['email']) {
    $contacts++;
}

if ($modaluser[homepage]) {
    $contacts++;
}

switch ($contacts) {
    case 0:
        $color['faaddressbook'] = 'lightgray';
        break;
    case 1:
        $color['faaddressbook'] = 'limegreen';
        break;
    case 2:
        $color['faaddressbook'] = 'blue';
        break;
    case 3:
        $color['faaddressbook'] = 'black';
        break;
    default:
        $color['faaddressbook'] = 'lightgray';
}

$color['fabtc'] = 'lightgray';
$color['fauniversity'] = 'lightgray';

if ($total_bits < -20000) {
    $color['fabtc'] = 'red';
} elseif ($total_bits < 0) {
    $color['fabtc'] = 'dark orange';
}

if ($total_bits > 0) {
    $color['fabtc'] = 'limegreen';
}

if ($total_bits > 100000) {
    $color['fabtc'] = 'blue';
}

if ($total_bits > 1000000) {
    $color['fabtc'] = 'indigo';
}

if ($total_bits > 10000000) {
    $color['fabtc'] = 'black';
    $color['fauniversity'] = 'blue';
}

if ($total_bits > 100000000) {
    $color['fauniversity'] = 'black';
}

$color['fausergraduate'] = 'lightgray';
$time_inactive = time() - $modaluser['lastactivity'];
$week = 7 * 24 * 60 * 60;
$month = 4 * $week;
$quarter = $week * (52 / 4);
$halfyear = $week * (52 / 2);
$year = $week * 52;
$twoyears = 2 * $year;
$threeyears = 3 * $year;

if ($time_inactive < $week) {
    $color['fausergraduate'] = 'black';
} elseif ($time_inactive < $month) {
    $color['fausergraduate'] = 'indigo';
} elseif ($time_inactive < $quarter) {
    $color['fausergraduate'] = 'blue';
} elseif ($time_inactive < $halfyear) {
    $color['fausergraduate'] = 'green';
} elseif ($time_inactive < $year) {
    $color['fausergraduate'] = 'lightgray';
} elseif ($time_inactive < $twoyears) {
    $color['fausergraduate'] = 'darkorange';
} elseif ($time_inactive < $threeyears) {
    $color['fausergraduate'] = 'red';
}

$color['fabolt'] = 'lightgray';
$activity = floatval($prepared['postsperday']);
if ($activity < 0.02) {
    $color['fabolt'] = 'red';
} elseif ($activity < 0.1) {
    $color['fabolt'] = 'darkorange';
} elseif ($activity < 0.5) {
    $color['fabolt'] = 'green';
} elseif ($activity < 1.0) {
    $color['fabolt'] = 'blue';
} elseif ($activity < 2.0) {
    $color['fabolt'] = 'indigo';
} else {
    $color['fabolt'] = 'black';
}

$badgejs = '<script>';
$badgejs .= 'var badge = [];';
$badgejs .= 'badge["posts"] = "' . $color[fauser] . '";';
$badgejs .= 'badge["firstpost"] = "' . $color[faaward] . '";';
$badgejs .= 'badge["100posts"] = "' . $color[fajediorder] . '";';
$badgejs .= 'badge["500posts"] = "' . $color[faphoenix] . '";';
$badgejs .= 'badge["1000posts"] = "' . $color[fajedi] . '";';
$badgejs .= 'badge["10000posts"] = "' . $color[faatom] . '";';
$badgejs .= 'badge["mod"] = "' . $color[fascale] . '";';
$badgejs .= 'badge["admin"] = "' . $color[fabuilding] . '";';
$badgejs .= 'badge["ug"] = "' . $color[fabishop] . '";';
$badgejs .= 'badge["devops"] = "' . $color[facity] . '";';
$badgejs .= 'badge["formulator"] = "' . $color[faflask] . '";';
$badgejs .= 'badge["totalposts"] = "' . $modaluser[posts] . '";';
$badgejs .= 'badge["thanked"] = "' . $color['fathumbsup'] . '";';
$badgejs .= 'badge["100thanked"] = "' . $color['fatrophy'] . '";';
$badgejs .= 'badge["1000thanked"] = "' . $color['fachalkboardteacher'] . '";';
$badgejs .= 'badge["2000thanked"] = "' . $color['fashieldalt'] . '";';
$badgejs .= 'badge["3000thanked"] = "' . $color['fastroopwafel'] . '";';
$badgejs .= 'badge["4000thanked"] = "' . $color['fafirstorderalt'] . '";';
$badgejs .= 'badge["profile"] = "' . $color['faidbadge'] . '";';
$badgejs .= 'badge["contact"] = "' . $color['faaddressbook'] . '";';
$badgejs .= 'badge["contacttotal"] = "' . $contacts . '";';
$badgejs .= 'badge["profilenumber"] = "' . $idfields . '";';
$badgejs .= 'badge["fabtc"] = "' . $color['fabtc'] . '";';
$badgejs .= 'badge["fauniversity"] = "' . $color['fauniversity'] . '";';
$badgejs .= 'badge["bits"] = "' . number_format($total_bits) . '";';
$badgejs .= 'badge["activity"] = "' . $color['fausergraduate'] . '";';
$badgejs .= 'badge["ppd"] = "' . $color['fabolt'] . '";';
$badgejs .= 'badge["ppdval"] = "' . $activity . '";';
$badgejs .= '</script>';

Maybe do a write-up for each badge and the description for each (using the logic defined in the code), and put the write-ups in LIST format (for for each list item)?

That will help you understand the logic I think.
This User Gave Thanks to Neo For This Post:
# 9  
Old 12-30-2018
OH... I forgot to mention, if you want to change or add logic, please do!

It's fun and easy.

This is a great project! Enjoy!
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Advanced Search * View * Edit JAVA version to WORK in GLASSFISH Forum topic JAVA version

Would like to confirm the ff. I got confused actually with the version I needed to download that will work on glassfish 3.0.1 a. Debian Squeeze (HP DL360). Need to use java version6 On Debian, I did apt-get install sun-java6-jdk. So when I check it's java version "1.6.0_22" Java(TM) SE... (1 Reply)
Discussion started by: lhareigh890
1 Replies

2. What is on Your Mind?

Bits Under Development: Forum Activity Index (FAI)

Working on some "new forum virtual economics" I have taken the total number of Bits in Circulation (user checking + savings) and divided that by the total number of posts, and have called this (for a lack of better name), the Forum Activity Index (FAI). You can now see this index on your banking... (7 Replies)
Discussion started by: Neo
7 Replies

3. Post Here to Contact Site Administrators and Moderators

forum to post availability for work?

Hello. Is there a forum to post my availability for work? (1 Reply)
Discussion started by: douglaskbell
1 Replies

4. UNIX for Dummies Questions & Answers

Getting current work directory in Command Prompt

How to get the current working directory as part of the command prompt? Every time I chage the folder, my command prompt path shoud change. I am using Korn Shell. Any help is greatly appreciated. (3 Replies)
Discussion started by: MeganP
3 Replies

5. News, Links, Events and Announcements

Current Kernel Development

Information on current kernel development status & Compatibality Status. (0 Replies)
Discussion started by: killerserv
0 Replies
Login or Register to Ask a Question