3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function get_reputation($user, $mode = '', $rep_is_on = TRUE, $post_id = 0) { global $INSTALLER09, $CURUSER; $member_reputation = ""; if ($rep_is_on) { include CACHE_DIR . '/rep_cache.php'; //require_once (CLASS_DIR . 'class_user_options.php'); // ok long winded file checking, but it's much better than file_exists if (!isset($reputations) || !is_array($reputations) || count($reputations) < 1) { return '<span title="Cache doesn\'t exist or zero length">Reputation: Offline</span>'; } $user['g_rep_hide'] = isset($user['g_rep_hide']) ? $user['g_rep_hide'] : 0; //$user['username'] = (($user['opt1'] & user_options::ANONYMOUS) ? $user['username'] : 'Anonymous'); $user['username'] = ($user['anonymous'] != 'yes') ? $user['username'] : 'Anonymous'; // Hmmm...bit of jiggery-pokery here, couldn't think of a better way. $max_rep = max(array_keys($reputations)); if ($user['reputation'] >= $max_rep) { $user_reputation = $reputations[$max_rep]; } else foreach ($reputations as $y => $x) { if ($y > $user['reputation']) { $user_reputation = $old; break; } $old = $x; } //$rep_is_on = TRUE; //$CURUSER['g_rep_hide'] = FALSE; $rep_power = $user['reputation']; $posneg = ''; if ($user['reputation'] == 0) { $rep_img = 'balance'; $rep_power = $user['reputation'] * -1; } elseif ($user['reputation'] < 0) { $rep_img = 'neg'; $rep_img_2 = 'highneg'; $rep_power = $user['reputation'] * -1; } else { $rep_img = 'pos'; $rep_img_2 = 'highpos'; } $pips = 12; switch ($mode) { case 'comments': $pips = 12; break; case 'torrents': $pips = 1003; break; case 'users': $pips = 970; break; case 'posts': $pips = 12; break; default: $pips = 12; // statusbar } $rep_bar = intval($rep_power / 100); if ($rep_bar > 10) { $rep_bar = 10; } if ($user['g_rep_hide']) // can set this to a group option if required, via admin? { $posneg = 'off'; $rep_level = 'rep_off'; } else { // it ain't off then, so get on with it! I wanna see shiny stuff!! $rep_level = $user_reputation ? $user_reputation : 'rep_undefined'; // just incase for ($i = 0; $i <= $rep_bar; $i++) { if ($i >= 5) { $posneg.= "<img src='pic/rep/reputation_$rep_img_2.gif' alt=\"Reputation Power $rep_power\n" . htmlsafechars($user['username']) . " $rep_level\" />"; } else { $posneg.= "<img src='pic/rep/reputation_$rep_img.gif' alt=\"Reputation Power $rep_power\n" . htmlsafechars($user['username']) . " $rep_level\" />"; } } } // now decide the locale if ($mode != '') return "Rep: " . $posneg . "<br /><br /><a href='javascript:;' onclick=\"PopUp('{$INSTALLER09['baseurl']}/reputation.php?pid=" . ($post_id != 0 ? (int)$post_id : (int)$user['id']) . "&amp;locale=" . $mode . "','Reputation',400,241,1,1);\"><button type='button' class='btn btn-default btn-xs' style='margin-top:-9px;' alt='Add reputation:: " . htmlsafechars($user['username']) . "' title='Add reputation:: " . htmlsafechars($user['username']) . "'><i class='fa fa-check'></i> Add Rep</button></a>"; else return " " . $posneg; } // END IF ONLINE // default return '<span title="Set offline by admin setting">Rep System Offline</span>'; }
based on St7Rg
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0rc3