Behzad
New Member


Joined: May 09, 2005
Posts: 3
|
Posted:
Mon May 09, 2005 7:24 pm |
|
Hello ...
You can add karma system in to CNB YA for PHP-Nuke 7.7
Open: modules/Your_Account/public/userinfo.php
FIND - Line 147
Code:if (is_admin($admin)) {
if ($userinfo[last_ip] != 0) {
echo "<center>"._LASTIP." <b>$userinfo[last_ip]</b><br>";
echo "[ <a href='".$admin_file.".php?op=ipban&ip=$userinfo[last_ip]'>"._BANTHIS."</a> ]<br>";
}
echo "[ <a href=\"modules.php?name=$module_name&file=admin&op=modifyUser&chng_uid=$usrinfo[user_id]\">"._EDITUSER."</a> ] ";
echo "[ <a href=\"modules.php?name=$module_name&file=admin&op=suspendUser&chng_uid=$usrinfo[user_id]\">"._SUSPENDUSER."</a> ] ";
echo "[ <a href=\"modules.php?name=$module_name&file=admin&op=deleteUser&chng_uid=$usrinfo[user_id]\">"._DELETEUSER."</a> ]<br>";
}
|
REPLACE WITH
Code:// Add karma System
if (is_admin($admin)) {
echo "<br>";
if ($userinfo[last_ip] != 0) {
echo "<center><font class=\"title\">"._ADMINFUNCTIONS."</font><br><br>"._LASTIP." <b>$userinfo[last_ip]</b><br><br>";
echo "[ <a href='".$admin_file.".php?op=ipban&ip=$userinfo[last_ip]'>"._BANTHIS."</a> | <a href=\"modules.php?name=$module_name&file=admin&op=modifyUser&chng_uid=$usrinfo[user_id]\">"._EDITUSER."</a> ]<br><br>";
echo "[ <a href=\"modules.php?name=$module_name&file=admin&op=suspendUser&chng_uid=$usrinfo[user_id]\">"._SUSPENDUSER."</a> | <a href=\"modules.php?name=$module_name&file=admin&op=deleteUser&chng_uid=$usrinfo[user_id]\">"._DELETEUSER."</a> ]<br>";
} else {
echo "<center>[ <a href=\"".$admin_file.".php?op=modifyUser&chng_uid=$userinfo[user_id]\">"._EDITUSER."</a> ]";
}
if ($userinfo[karma] == 0) {
$karma = _KARMAGOOD;
$karma_help = _KARMAGOODHLP;
$change_karma = "<a href=\"modules.php?name=$module_name&op=change_karma&user_id=$userinfo[user_id]&karma=1\"><img src=\"images/karma/1.gif\" border=\"0\" alt=\""._KARMALOW."\" title=\""._KARMALOW."\" hspace=\"5\"></a>";
$change_karma .= "<a href=\"modules.php?name=$module_name&op=change_karma&user_id=$userinfo[user_id]&karma=2\"><img src=\"images/karma/2.gif\" border=\"0\" alt=\""._KARMABAD."\" title=\""._KARMABAD."\" hspace=\"5\"></a>";
$change_karma .= "<a href=\"modules.php?name=$module_name&op=change_karma&user_id=$userinfo[user_id]&karma=3\"><img src=\"images/karma/3.gif\" border=\"0\" alt=\""._KARMADEVIL."\" title=\""._KARMADEVIL."\" hspace=\"5\"></a>";
} elseif ($userinfo[karma] == 1) {
$karma = _KARMALOW;
$karma_help = _KARMALOWHLP;
$change_karma = "<a href=\"modules.php?name=$module_name&op=change_karma&user_id=$userinfo[user_id]&karma=0\"><img src=\"images/karma/0.gif\" border=\"0\" alt=\""._KARMAGOOD."\" title=\""._KARMAGOOD."\" hspace=\"5\"></a>";
$change_karma .= "<a href=\"modules.php?name=$module_name&op=change_karma&user_id=$userinfo[user_id]&karma=2\"><img src=\"images/karma/2.gif\" border=\"0\" alt=\""._KARMABAD."\" title=\""._KARMABAD."\" hspace=\"5\"></a>";
$change_karma .= "<a href=\"modules.php?name=$module_name&op=change_karma&user_id=$userinfo[user_id]&karma=3\"><img src=\"images/karma/3.gif\" border=\"0\" alt=\""._KARMADEVIL."\" title=\""._KARMADEVIL."\" hspace=\"5\"></a>";
} elseif ($userinfo[karma] == 2) {
$karma = _KARMABAD;
$karma_help = _KARMABADHLP;
$change_karma = "<a href=\"modules.php?name=$module_name&op=change_karma&user_id=$userinfo[user_id]&karma=0\"><img src=\"images/karma/0.gif\" border=\"0\" alt=\""._KARMAGOOD."\" title=\""._KARMAGOOD."\" hspace=\"5\"></a>";
$change_karma .= "<a href=\"modules.php?name=$module_name&op=change_karma&user_id=$userinfo[user_id]&karma=1\"><img src=\"images/karma/1.gif\" border=\"0\" alt=\""._KARMALOW."\" title=\""._KARMALOW."\" hspace=\"5\"></a>";
$change_karma .= "<a href=\"modules.php?name=$module_name&op=change_karma&user_id=$userinfo[user_id]&karma=3\"><img src=\"images/karma/3.gif\" border=\"0\" alt=\""._KARMADEVIL."\" title=\""._KARMADEVIL."\" hspace=\"5\"></a>";
} elseif ($userinfo[karma] == 3) {
$karma = _KARMADEVIL;
$karma_help = _KARMADEVILHLP;
$change_karma = "<a href=\"modules.php?name=$module_name&op=change_karma&user_id=$userinfo[user_id]&karma=0\"><img src=\"images/karma/0.gif\" border=\"0\" alt=\""._KARMAGOOD."\" title=\""._KARMAGOOD."\" hspace=\"5\"></a>";
$change_karma .= "<a href=\"modules.php?name=$module_name&op=change_karma&user_id=$userinfo[user_id]&karma=1\"><img src=\"images/karma/1.gif\" border=\"0\" alt=\""._KARMALOW."\" title=\""._KARMALOW."\" hspace=\"5\"></a>";
$change_karma .= "<a href=\"modules.php?name=$module_name&op=change_karma&user_id=$userinfo[user_id]&karma=2\"><img src=\"images/karma/2.gif\" border=\"0\" alt=\""._KARMABAD."\" title=\""._KARMABAD."\" hspace=\"5\"></a>";
}
echo "<br><br>"._USERKARMA." <img src=\"images/karma/$userinfo[karma].gif\" border=\"0\" alt=\"$karma\" title=\"$karma\"> ($karma)<br>($karma_help)</center><br><br>";
OpenTable2();
echo "<center><b>"._CHANGEKARMA." <i>$userinfo[username]</i></b><br><br>";
echo "$change_karma</center>";
CloseTable2();
echo "<br>";
echo "<table border=\"0\" width=\"80%\" cellpadding=\"3\" cellspacing=\"3\" align=\"center\">";
echo "<tr><td valign=\"middle\"><img src=\"images/karma/0.gif\" border=\"0\" alt=\""._KARMAGOOD."\" title=\""._KARMAGOOD."\"></td><td>"._KARMAGOODREF."</td></tr>";
echo "<tr><td valign=\"middle\"><img src=\"images/karma/1.gif\" border=\"0\" alt=\""._KARMALOW."\" title=\""._KARMALOW."\"></td><td>"._KARMALOWREF."</td></tr>";
echo "<tr><td valign=\"middle\"><img src=\"images/karma/2.gif\" border=\"0\" alt=\""._KARMABAD."\" title=\""._KARMABAD."\"></td><td>"._KARMABADREF."</td></tr>";
echo "<tr><td valign=\"middle\"><img src=\"images/karma/3.gif\" border=\"0\" alt=\""._KARMADEVIL."\" title=\""._KARMADEVIL."\"></td><td>"._KARMADEVILREF."</td></tr></table>";
}
//End karma system
|
Open: modules/Your_Account/includes/functions.php
FIND - Line 169
Code:function YA_CoolSize($size) {
$mb = 1024*1024;
if ( $size > $mb ) {
$mysize = sprintf ("%01.2f",$size/$mb) . " MB";
} elseif ( $size >= 1024 ) {
$mysize = sprintf ("%01.2f",$size/1024) . " Kb";
} else {
$mysize = $size . " bytes";
}
return $mysize;
}
|
AFTER, ADD
Code://Add karma System
function change_karma($user_id, $karma) {
global $admin, $user_prefix, $db, $module_name;
if (!is_admin($admin)) {
Header("location: index.php");
die();
} else {
if ($user_id > 1) {
$karma = intval($karma);
$db->sql_query("UPDATE ".$user_prefix."_users SET karma='$karma' WHERE user_id='$user_id'");
$row = $db->sql_fetchrow($db->sql_query("SELECT username FROM ".$user_prefix."_users WHERE user_id='$user_id'"));
$username = $row[username];
Header("location: modules.php?name=$module_name&op=userinfo&username=$username");
die();
}
}
}
//End karma system
|
Open: modules/Your_Account/language/lang-english.php
ADD:
Code://Add Karma System
define("_USERKARMA","User Karma:");
define("_CHANGEKARMA","Change Karma for User");
define("_ADMINFUNCTIONS","Administration Functions");
define("_KARMAGOOD","Good Karma");
define("_KARMAGOODHLP","This is a normal good user");
define("_KARMAGOODREF","Default value. Users marked with <i>Good Karma</i> can post their comments without any restrictions.");
define("_KARMALOW","Regular Karma");
define("_KARMALOWHLP","This user has been marked, requires atention");
define("_KARMALOWREF","Users marked with <i>Regular Karma</i> should be under observation. Consider this value a <i>flag</i> to have a eye on it.");
define("_KARMABAD","Bad Karma");
define("_KARMABADHLP","This user is bad and his comments are moderated");
define("_KARMABADREF","Users marked with <i>Bad Karma</i> can post comments but the administrator should approve/moderate them from the admin panel.");
define("_KARMADEVIL","Devil Karma");
define("_KARMADEVILHLP","This user is a devil and his comments will not be published");
define("_KARMADEVILREF","Users marked with <i>Devil Karma</i> are very bad. This users are not allowed to post comments. All his content is just ignored and nothing will be published.");
//End karma system
|
Open: modules/Your_Account/index.php
FIND - Line 259
BEFORE, ADD
Code://Add karma System
case "change_karma":
change_karma($user_id, $karma);
break;
//End Karma System
|
|
|
|
64bitguy
The Mouse Is Extension Of Arm

Joined: Mar 06, 2004
Posts: 1164
|
Posted:
Wed Jun 08, 2005 12:29 pm |
|
As a heads-up. Users employing this modification need to adjust all of the above code by altering all occurances where the & character appears in links to be &
For example:
Code:Header("location: modules.php?name=$module_name&op=userinfo&username=$username")
|
Should be:
Code:Header("location: modules.php?name=$module_name&op=userinfo&username=$username")
|
Reason #1099 regarding why users should not use PHP-Nuke 7.7 or 7.8 is that old problems that have been fixed 100 times in the past (like the & issue) have been all recreated again in these two new versions. The bottom line? You'll need to find all of these old problems that exist again everywhere and fix them all.
May the force be with you. |
_________________ Steph Benoit
100% Section 508 and W3C HTML5 and CSS Compliant (Truly) Code, because I love compliance. |
|