Karma Description Mod

Started by Grek.Kamchatka, September 11, 2005, 11:48:26 PM

Previous topic - Next topic

perplexed

#260
Hi Grek

I got a little problem :(

Parse error: parse error, unexpected $ in /home/mysite/public_html/testforum/Sources/Karma.php on line 631

Can you help please?

Quote<?php
/******************************************************************************
* Karma.php                                                                   *
*******************************************************************************
* SMF: Simple Machines Forum                                                  *
* Open-Source Project Inspired by Zef Hemel ([email protected])                *
* =========================================================================== *
* Software Version:           SMF 1.1 RC2                                     *
* Software by:                Simple Machines (http://www.simplemachines.org) *
* Copyright 2001-2005 by:     Lewis Media (http://www.lewismedia.com)         *
* Support, News, Updates at:  http://www.simplemachines.org                   *
*******************************************************************************
* This program is free software; you may redistribute it and/or modify it     *
* under the terms of the provided license as published by Lewis Media.        *
*                                                                             *
* This program is distributed in the hope that it is and will be useful,      *
* but WITHOUT ANY WARRANTIES; without even any implied warranty of            *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                        *
*                                                                             *
* See the "license.txt" file for details of the Simple Machines license.      *
* The latest version can always be found at http://www.simplemachines.org.    *
******************************************************************************/
if (!defined('SMF'))
   die('Hacking attempt...');

/*   This file contains one humble function, which applauds or smites a user.

   void ModifyKarma()
      - gives or takes karma from a user.
      - redirects back to the referrer afterward, whether by javascript or
        the passed parameters.
      - requires the karma_edit permission, and that the user isn't a guest.
      - depends on the karmaMode, karmaWaitTime, and karmaTimeRestrictAdmins
        settings.
      - is accessed via ?action=modifykarma.
*/

function ModKarm()
{
        global $modSettings, $db_prefix, $txt, $ID_MEMBER, $user_info, $topic, $scripturl;

        // If the mod is disabled, show an error.
        if (empty($modSettings['karmaMode']))
                fatal_lang_error('smf63');

                if (!empty($modSettings['karmasurv']))
                ModKarm();
// If you're a guest or can't do this, blow you off...
        is_not_guest();
        isAllowedTo('karma_edit');

        checkSession('get');

        // If you don't have enough posts, tough luck.
        // !!! Should this be dropped in favor of post group permissions?  Should this apply to the member you are smiting/applauding?
        if ($user_info['posts'] < $modSettings['karmaMinPosts'])
                fatal_error($txt['smf60'] . $modSettings['karmaMinPosts'] . '.');

        // And you can't modify your own, punk! (use the profile if you need to.)
        if (empty($_REQUEST['uid']) || (int) $_REQUEST['uid'] == $ID_MEMBER)
                fatal_lang_error('smf61', false);

        // The user ID _must_ be a number, no matter what.
        $_REQUEST['uid'] = (int) $_REQUEST['uid'];

        // Applauding or smiting?
        $dir = $_REQUEST['sa'] != 'applaud' ? -1 : 1;

        // Start off with no change in karma.
        $action = 0;

        (!isset($modSettings['karmawhatwrite'])) ? $Description='' : $Description=$modSettings['karmawhatwrite'];


          // Not an administrator... or one who is restricted as well.
        if (!empty($modSettings['karmaTimeRestrictAdmins']) || !allowedTo('moderate_forum'))
        {
                // Find out if this user has done this recently...
                $request = db_query("
                        SELECT action
                        FROM {$db_prefix}log_karma
                        WHERE ID_TARGET = $_REQUEST[uid]
                                AND ID_EXECUTOR = $ID_MEMBER
                        LIMIT 1", __FILE__, __LINE__);
                if (mysql_num_rows($request) > 0)
                        list ($action) = mysql_fetch_row($request);
                mysql_free_result($request);
        }

        // They haven't, not before now, anyhow.

/*
        if (empty($action) || empty($modSettings['karmaWaitTime']))
        {
                //Prepare link
                    if (isset ($_REQUEST['topic'])) {
                         $link = ($_REQUEST['topic']).'.msg'.($_REQUEST['m']).'#'.'msg'.($_REQUEST['m']);
                         $link = AddSlashes($link);
                         }
                elseif (isset($_REQUEST['f'])) {
                         $link = 'PM';
                         }

                // Put it in the log.
                db_query("
                        INSERT INTO {$db_prefix}log_karma
                                (action, ID_TARGET, Description, link, ID_EXECUTOR, logTime)
                        VALUES ($dir, $_REQUEST[uid], '$Description', '$link', $ID_MEMBER, ". time()." )
                        ", __FILE__, __LINE__);

                // Change by one.
                updateMemberData($_REQUEST['uid'], array($dir == 1 ? 'karmaGood' : 'karmaBad' => '+'));
        }
        else
        {       $request = db_query("
                                        SELECT logTime
                                        FROM {$db_prefix}log_karma
                                        WHERE ID_TARGET=$_REQUEST[uid]
                                        AND ID_EXECUTOR=$ID_MEMBER
                                        ORDER BY logTime DESC
                                        LIMIT 1
                                        ", __FILE__, __LINE__);
                $row = mysql_fetch_assoc($request);
                mysql_free_result($request);

                $restricttime = time() - $row['logTime'];
                $timelog = (int) ($modSettings['karmaWaitTime'] * 3600);

                // If you are gonna try to repeat.... don't allow it.
                if ($restricttime < $timelog)
                        fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . '.', false);

                //Prepare link
                    if (isset ($_REQUEST['topic'])) {
                         $link = ($_REQUEST['topic']).'.msg'.($_REQUEST['m']).'#'.'msg'.($_REQUEST['m']);
                         $link = AddSlashes($link);
                         }
                elseif (isset($_REQUEST['f'])) {
                         $link = 'PM';
                         }

                // You decided to go back on your previous choice?
                db_query("
                        INSERT INTO {$db_prefix}log_karma
                                (action, ID_TARGET, Description, link, ID_EXECUTOR, logTime)
                        VALUES ($dir, $_REQUEST[uid], '$Description', '$link', $ID_MEMBER, ". time()." )
                        ", __FILE__, __LINE__);

               
*/
/* They haven't, not before now, anyhow.
           If the key isn't in the array it will return.
           Or if it does exist and it's length is 0 then it will return.
           If Karma Description Mod disable then easy smite or applaud */
if (!empty($modSettings['karmadescmod'])){
if (!array_key_exists('Description',$_POST) || strlen($_POST["Description"]) == 0){return;}}


{ if ( empty($action) || empty($modSettings['karmaWaitTime']))
        { $_POST['Description'] = AddSlashes($_POST['Description']);
          if (!empty($modSettings['karmacensor']))
          censorText($_POST['Description']);
     
      //Prepare link
          if (isset ($_REQUEST['topic'])) {
                         $link = ($_REQUEST['topic']).'.msg'.($_REQUEST['m']).'#'.'msg'.($_REQUEST['m']);
                         $link = AddSlashes($link);
                         }
                elseif (isset($_REQUEST['f'])) {
                         $link = 'PM';
                         }

      // Put it in the log.
                db_query("
                        INSERT INTO {$db_prefix}log_karma
                                (action, ID_TARGET, Description, link, ID_EXECUTOR, logTime)
                        VALUES ($dir, $_REQUEST[uid], '$_POST[Description]', '$link', $ID_MEMBER, ". time()." )
                        ", __FILE__, __LINE__);
// Change by one.
      updateMemberData($_REQUEST['uid'], array($dir == 1 ? 'karmaGood' : 'karmaBad' => '+'));
   }
   else
   {
      $request = db_query("
               SELECT logTime
               FROM {$db_prefix}log_karma
               WHERE ID_TARGET=$_REQUEST[uid]
               AND ID_EXECUTOR=$ID_MEMBER
               ORDER BY logTime DESC
               LIMIT 1
               ", __FILE__, __LINE__);
      $row = mysql_fetch_assoc($request);
      mysql_free_result($request);
            
      $restricttime = time() - $row['logTime'];
      $timelog = (int) ($modSettings['karmaWaitTime'] * 3600);

      // If you are gonna try to repeat.... don't allow it.
      if ($restricttime < $timelog)
         fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . '.', false);

      //Prepare link
          if (isset ($_REQUEST['topic'])) {
                         $link = ($_REQUEST['topic']).'.msg'.($_REQUEST['m']).'#'.'msg'.($_REQUEST['m']);
                         $link = AddSlashes($link);
                         }
                elseif (isset($_REQUEST['f'])) {
                         $link = 'PM';
                         }

      // You decided to go back on your previous choice?
      db_query("
         INSERT INTO {$db_prefix}log_karma
                                (action, ID_TARGET, Description, link, ID_EXECUTOR, logTime)
                        VALUES ($dir, $_REQUEST[uid], '$_POST[Description]', '$link', $ID_MEMBER, ". time()." )
                        ", __FILE__, __LINE__);

// It was recently changed the OTHER way... so... reverse it!
                if ($dir == 1)
                        updateMemberData($_REQUEST['uid'], array('karmaGood' => '+'));
                else
                        updateMemberData($_REQUEST['uid'], array('karmaBad' => '+'));
        }

        // Figure out where to go back to.... the topic?
        if (isset($topic))
                redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . '#msg' . $_REQUEST['m']);
        // Hrm... maybe a personal message?
        elseif (isset($_REQUEST['f']))
                redirectexit('action=pm;f=' . $_REQUEST['f'] . ';start=' . $_REQUEST['start'] . (isset($_REQUEST['l']) ? ';l=' . $_REQUEST['l'] : '') . (isset($_REQUEST['pm']) ? '#' . $_REQUEST['pm'] : ''));

          else
        {
                echo '
<html>
        <head>
                <title>...</title>
                <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
                        history.go(-1);
                // ]',']></script>
        </head>
        <body>&laquo;</body>
</html>';

                obExit(false);
        }
}


function ModKarm()
{
        global $modSettings, $db_prefix, $txt, $ID_MEMBER, $user_info, $topic;

        // If the mod is disabled, show an error.
        if (empty($modSettings['karmaMode']))
                fatal_lang_error('smf63');

        // If you're a guest or can't do this, blow you off...
        is_not_guest();
        isAllowedTo('karma_edit');

        checkSession('get');

        // If you don't have enough posts, tough luck.
        // !!! Should this be dropped in favor of post group permissions?  Should this apply to the member you are smiting/applauding?
        if ($user_info['posts'] < $modSettings['karmaMinPosts'])
                fatal_error($txt['smf60'] . $modSettings['karmaMinPosts'] . '.');

        // And you can't modify your own, punk! (use the profile if you need to.)
        if (empty($_REQUEST['uid']) || (int) $_REQUEST['uid'] == $ID_MEMBER)
                fatal_lang_error('smf61', false);

        // The user ID _must_ be a number, no matter what.
        $_REQUEST['uid'] = (int) $_REQUEST['uid'];

        // Applauding or smiting?
        $dir = $_REQUEST['sa'] != 'applaud' ? -1 : 1;

        // Start off with no change in karma.
        $action = 0;

        (!isset($modSettings['karmawhatwrite'])) ? $Description='' : $Description=$modSettings['karmawhatwrite'];


          // Not an administrator... or one who is restricted as well.
        if (!empty($modSettings['karmaTimeRestrictAdmins']) || !allowedTo('moderate_forum'))
        {
                // Find out if this user has done this recently...
                $request = db_query("
                        SELECT action
                        FROM {$db_prefix}log_karma
                        WHERE ID_TARGET = $_REQUEST[uid]
                                AND ID_EXECUTOR = $ID_MEMBER
                        LIMIT 1", __FILE__, __LINE__);
                if (mysql_num_rows($request) > 0)
                        list ($action) = mysql_fetch_row($request);
                mysql_free_result($request);
        }

        // They haven't, not before now, anyhow.
        if (empty($action) || empty($modSettings['karmaWaitTime']))
        {
                //Prepare link
                    if (isset ($_REQUEST['topic'])) {
                         $link = ($_REQUEST['topic']).'.msg'.($_REQUEST['m']).'#'.'msg'.($_REQUEST['m']);
                         $link = AddSlashes($link);
                         }
                elseif (isset($_REQUEST['f'])) {
                         $link = 'PM';
                         }

                // Put it in the log.
                db_query("
                        INSERT INTO {$db_prefix}log_karma
                                (action, ID_TARGET, Description, link, ID_EXECUTOR, logTime)
                        VALUES ($dir, $_REQUEST[uid], '$Description', '$link', $ID_MEMBER, ". time()." )
                        ", __FILE__, __LINE__);

                // Change by one.
                updateMemberData($_REQUEST['uid'], array($dir == 1 ? 'karmaGood' : 'karmaBad' => '+'));
        }
        else
        {       $request = db_query("
                                        SELECT logTime
                                        FROM {$db_prefix}log_karma
                                        WHERE ID_TARGET=$_REQUEST[uid]
                                        AND ID_EXECUTOR=$ID_MEMBER
                                        ORDER BY logTime DESC
                                        LIMIT 1
                                        ", __FILE__, __LINE__);
                $row = mysql_fetch_assoc($request);
                mysql_free_result($request);

                $restricttime = time() - $row['logTime'];
                $timelog = (int) ($modSettings['karmaWaitTime'] * 3600);

                // If you are gonna try to repeat.... don't allow it.
                if ($restricttime < $timelog)
                        fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . '.', false);

                //Prepare link
                    if (isset ($_REQUEST['topic'])) {
                         $link = ($_REQUEST['topic']).'.msg'.($_REQUEST['m']).'#'.'msg'.($_REQUEST['m']);
                         $link = AddSlashes($link);
                         }
                elseif (isset($_REQUEST['f'])) {
                         $link = 'PM';
                         }

                // You decided to go back on your previous choice?
                db_query("
                        INSERT INTO {$db_prefix}log_karma
                                (action, ID_TARGET, Description, link, ID_EXECUTOR, logTime)
                        VALUES ($dir, $_REQUEST[uid], '$Description', '$link', $ID_MEMBER, ". time()." )
                        ", __FILE__, __LINE__);

                // It was recently changed the OTHER way... so... reverse it!
                if ($dir == 1)
                        updateMemberData($_REQUEST['uid'], array('karmaGood' => '+'));
                else
                        updateMemberData($_REQUEST['uid'], array('karmaBad' => '+'));
        }

        // Figure out where to go back to.... the topic?
        if (isset($topic))
                redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . '#msg' . $_REQUEST['m']);
        // Hrm... maybe a personal message?
        elseif (isset($_REQUEST['f']))
                redirectexit('action=pm;f=' . $_REQUEST['f'] . ';start=' . $_REQUEST['start'] . (isset($_REQUEST['l']) ? ';l=' . $_REQUEST['l'] : '') . (isset($_REQUEST['pm']) ? '#' . $_REQUEST['pm'] : ''));

          else
        {
                echo '
<html>
        <head>
                <title>...</title>
                <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
                        history.go(-1);
                // ]',']></script>
        </head>
        <body>&laquo;</body>
</html>';

                obExit(false);
        }
}


// Modify a user's karma.
function ModifyKarma()
{
   global $modSettings, $db_prefix, $txt, $ID_MEMBER, $user_info, $topic, $scripturl;

   // If the mod is disabled, show an error.
   if (empty($modSettings['karmaMode']))
      fatal_lang_error('smf63');

           if (!empty($modSettings['karmasurv']))
                ModKarm();
// If you're a guest or can't do this, blow you off...
   is_not_guest();
   isAllowedTo('karma_edit');

   checkSession('get');

   // If you don't have enough posts, tough luck.
   // !!! Should this be dropped in favor of post group permissions?  Should this apply to the member you are smiting/applauding?
   if ($user_info['posts'] < $modSettings['karmaMinPosts'])
      fatal_error($txt['smf60'] . $modSettings['karmaMinPosts'] . '.');

   // And you can't modify your own, punk! (use the profile if you need to.)
   if (empty($_REQUEST['uid']) || (int) $_REQUEST['uid'] == $ID_MEMBER)
      fatal_lang_error('smf61', false);

   // The user ID _must_ be a number, no matter what.
   $_REQUEST['uid'] = (int) $_REQUEST['uid'];

   // Applauding or smiting?
   $dir = $_REQUEST['sa'] != 'applaud' ? -1 : 1;

   
//Loading Template of Description
if (!empty($modSettings['karmadescmod'])){
        loadTemplate('DescriptionKarma');}

        //Prepare some variables
        $context['page_title'] = $txt['viewkarma_title'];
        $context['linktree'][] = array(
            'url' => $scripturl . '?action=modifykarma',
            'name' => $txt['viewkarma_title'] );

   // Start off with no change in karma.
   $action = 0;

   // Not an administrator... or one who is restricted as well.
   if (!empty($modSettings['karmaTimeRestrictAdmins']) || !allowedTo('moderate_forum'))
   {
      // Find out if this user has done this recently...
      $request = db_query("
         SELECT action
         FROM {$db_prefix}log_karma
         WHERE ID_TARGET = $_REQUEST[uid]
            AND ID_EXECUTOR = $ID_MEMBER
         LIMIT 1", __FILE__, __LINE__);
      if (mysql_num_rows($request) > 0)
         list ($action) = mysql_fetch_row($request);
      mysql_free_result($request);
   }

   // They haven't, not before now, anyhow.

/*
   if (empty($action) || empty($modSettings['karmaWaitTime']))
   {
      // Put it in the log.
      db_query("
         REPLACE INTO {$db_prefix}log_karma
            (action, ID_TARGET, ID_EXECUTOR, logTime)
         VALUES ($dir, $_REQUEST[uid], $ID_MEMBER, " . time() . ')', __FILE__, __LINE__);

      // Change by one.
      updateMemberData($_REQUEST['uid'], array($dir == 1 ? 'karmaGood' : 'karmaBad' => '+'));
   }
   else
   {
      // If you are gonna try to repeat.... don't allow it.
      if ($action == $dir)
         fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . '.', false);

      // You decided to go back on your previous choice?
      db_query("
         UPDATE {$db_prefix}log_karma
         SET action = $dir, logTime = " . time() . "
         WHERE ID_TARGET = $_REQUEST[uid]
            AND ID_EXECUTOR = $ID_MEMBER
         LIMIT 1", __FILE__, __LINE__);

      
*/
/* They haven't, not before now, anyhow.
           If the key isn't in the array it will return.
           Or if it does exist and it's length is 0 then it will return.
           If Karma Description Mod disable then easy smite or applaud */
if (!empty($modSettings['karmadescmod'])){
if (!array_key_exists('Description',$_POST) || strlen($_POST["Description"]) == 0){return;}}


{ if ( empty($action) || empty($modSettings['karmaWaitTime']))
        { $_POST['Description'] = AddSlashes($_POST['Description']);
          if (!empty($modSettings['karmacensor']))
          censorText($_POST['Description']);
     
      //Prepare link
          if (isset ($_REQUEST['topic'])) {
                         $link = ($_REQUEST['topic']).'.msg'.($_REQUEST['m']).'#'.'msg'.($_REQUEST['m']);
                         $link = AddSlashes($link);
                         }
                elseif (isset($_REQUEST['f'])) {
                         $link = 'PM';
                         }

      // Put it in the log.
                db_query("
                        INSERT INTO {$db_prefix}log_karma
                                (action, ID_TARGET, Description, link, ID_EXECUTOR, logTime)
                        VALUES ($dir, $_REQUEST[uid], '$_POST[Description]', '$link', $ID_MEMBER, ". time()." )
                        ", __FILE__, __LINE__);
// Change by one.
      updateMemberData($_REQUEST['uid'], array($dir == 1 ? 'karmaGood' : 'karmaBad' => '+'));
   }
   else
   {
      $request = db_query("
               SELECT logTime
               FROM {$db_prefix}log_karma
               WHERE ID_TARGET=$_REQUEST[uid]
               AND ID_EXECUTOR=$ID_MEMBER
               ORDER BY logTime DESC
               LIMIT 1
               ", __FILE__, __LINE__);
      $row = mysql_fetch_assoc($request);
      mysql_free_result($request);
            
      $restricttime = time() - $row['logTime'];
      $timelog = (int) ($modSettings['karmaWaitTime'] * 3600);

      // If you are gonna try to repeat.... don't allow it.
      if ($restricttime < $timelog)
         fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . '.', false);

      //Prepare link
          if (isset ($_REQUEST['topic'])) {
                         $link = ($_REQUEST['topic']).'.msg'.($_REQUEST['m']).'#'.'msg'.($_REQUEST['m']);
                         $link = AddSlashes($link);
                         }
                elseif (isset($_REQUEST['f'])) {
                         $link = 'PM';
                         }

      // You decided to go back on your previous choice?
      db_query("
         INSERT INTO {$db_prefix}log_karma
                                (action, ID_TARGET, Description, link, ID_EXECUTOR, logTime)
                        VALUES ($dir, $_REQUEST[uid], '$_POST[Description]', '$link', $ID_MEMBER, ". time()." )
                        ", __FILE__, __LINE__);

// It was recently changed the OTHER way... so... reverse it!
      if ($dir == 1)
         updateMemberData($_REQUEST['uid'], array('karmaGood' => '+'));
      else
         updateMemberData($_REQUEST['uid'], array('karmaBad' => '+'));
}
   }

   // Figure out where to go back to.... the topic?
   if (isset($topic))
      redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . '#msg' . $_REQUEST['m']);
   // Hrm... maybe a personal message?
   elseif (isset($_REQUEST['f']))
      redirectexit('action=pm;f=' . $_REQUEST['f'] . ';start=' . $_REQUEST['start'] . (isset($_REQUEST['l']) ? ';l=' . $_REQUEST['l'] : '') . (isset($_REQUEST['pm']) ? '#' . $_REQUEST['pm'] : ''));
   // JavaScript as a last resort.
/*

   else
   {
      echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title>...</title>
      <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
         history.go(-1);
      // ]]></script>
   </head>
   <body>&laquo;</body>
</html>';

      obExit(false);
   }
}

*/
// What's this?  I dunno, what are you talking about?  Never seen this before, nope.  No siree.
function BookOfUnknown()
{
   global $context;

   if (strpos($_GET['action'], 'mozilla') !== false && !$context['browser']['is_gecko'])
      redirectexit('http://www.getfirefox.com/');
   elseif (strpos($_GET['action'], 'mozilla') !== false)
      redirectexit('about:mozilla');

   echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title>The Book of Unknown, ', @$_GET['verse'] == '2:18' ? '2:18' : '4:16', '</title>
      <style type="text/css">
         em
         {
            font-size: 1.3em;
            line-height: 0;
         }
      </style>
   </head>
   <body style="background-color: #444455; color: white; font-style: italic; font-family: serif;">
      <div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">';
   if (@$_GET['verse'] == '2:18')
      echo '
         Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none.&nbsp;And it became to be in those days <em>something</em>.&nbsp; Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind.&nbsp; And thus what was to be known the <em>secret project</em> began into its existence.&nbsp; Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.';
   else
      echo '
         And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together.&nbsp; Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.';
   echo '
      </div>
      <div style="margin-top: 2ex; font-size: 2em; text-align: right;">';
   if (@$_GET['verse'] == '2:18')
      echo '
         from <span style="font-family: Georgia, serif;"><strong><a href="http://www.unknownbrackets.com/about:unknown" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>';
   else
      echo '
         from <span style="font-family: Georgia, serif;"><strong><a href="http://www.unknownbrackets.com/about:unknown" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>';
   echo '
      </div>
   </body>
</html>';

   obExit(false);
}

}

?>

perplexed

(forgot to say)  they are getting the error message when they click on applaud or smite when trying to give someone karma.

Grek.Kamchatka

#262
   Hm. I don't know, but i just now install vanilla smf forum and upload and install KDM 1.9.6 and everything work fine.
   Uninstall KDM 1.9.6, upload vanilla source and template forum files and install KDM 1.9.6 again.

By the way, try to download KDM 1.9.6 again. May be you have corrupt file.

perplexed

Hi Grek, Uninstalling 1.9.5 gave me that error in /sources.karma.php in the uninstall as I mentioned above.  and then when I installed 1.9.6 I got the 'parse' problem above... 

so what I did today was upload a fresh copy of /sources.karma.php and made sure I could give karma without errors and then reinstalled 1.9.6 again

Everything is working now as far as I can see. I can give karma and I can see my own karma reasons, so I think it's ok now.
But you may want to check that problem with the uninstall.

~thanks again

Grek.Kamchatka

Yep, you resieved this error because you edit karma.php by hand. I think so...
Now everything ok and it's wonderfull.

z3nith

thanks for the new version of Karma Mod :)

but i need to really strict Karma in my forum, is that possible?
- karma limited with post amount, so if they already post 5 times they only have 5 karma to give
- karma only can be give to a topic starter by their replier.

thanks,
ek kian

Grek.Kamchatka

#266
Quote
- karma limited with post amount, so if they already post 5 times they only have 5 karma to give
It's possible, but i think it unclaimed. In additions it's hard.

Quote
- karma only can be give to a topic starter by their replier.
Open Errors.english.php and past at the end of the file this string:
$txt['karma_not_topic_starter'] = 'Sorry, it\'s not topic starter.';

Then open Karma.php and find this code in ModKarm() and ModifyKarma() functions:

// Applauding or smiting?
$dir = $_REQUEST['sa'] != 'applaud' ? -1 : 1;


Past after it this

$request = db_query("
                        SELECT ID_MEMBER_STARTED
                        FROM {$db_prefix}topics
                        WHERE ID_TOPIC = $_REQUEST[topic]
                        LIMIT 1", __FILE__, __LINE__);
        $row = mysql_fetch_row($request);
                mysql_free_result($request);
        if ($_REQUEST['uid'] != $row[0] && $user_info['is_admin']!=1)
              fatal_lang_error('karma_not_topic_starter', false);

That's all. Now if your users will try to change karma other people, not to topic starter, they will resieve an error message.

Quote
thanks,
ek kian
You are welcome

P.S. In new version it will be a standart function

b0bby

I had karma mod installed before it worked before fine but now every tim i want to add karma notes or view karma stats it gives me error message:

Unknown column 'lk.link' in 'field list'
File: C:\WWW\Apache2\htdocs\forum\Sources\Viewkarma.php
Line: 71

Please help me i know its probably some code that has been left out in my mysql database that i have to delete but which one?

thanks a lot

z3nith

Quote
P.S. In new version it will be a standard function

thank you very much :D you the best Mr.Grek :)

i thought that karma desc mod have very great potential to expand SMF capabilities,
we can make kind of hxxp:expert-exchange.com [nonactive] where topic starter choose one replier as
accepted answer and topic starter give karma to that replier, or we can make SMF
have kind of ebay-like feature where topic starter can choose one replier as someone
who win the bid and after that they can give karma each other.

please keep this mod alive.
thanks a lot  :)

Washi

Ok this is driving me insane. Could someone post a Karma.php file from 1.0.6 with just the Karma mod installed? I mean, a source 1.0.6 with just the KDM installed? I'm dying here.
I've been working on it for the last 2 hours, and still nothing. I'm about to start tearing my hair out.
I get either a blank page or a page with an error, which, of course, I can't remake, since I have no idea how I made it.
Help?

z3nith

This SMF1.0.6 with KDM 1.9.2 and works ;)


<?php
/******************************************************************************
* Karma.php                                                                   *
*******************************************************************************
* SMF: Simple Machines Forum                                                  *
* Open-Source Project Inspired by Zef Hemel ([email protected])                *
* =========================================================================== *
* Software Version:           SMF 1.0                                         *
* Software by:                Simple Machines (http://www.simplemachines.org) *
* Copyright 2001-2004 by:     Lewis Media (http://www.lewismedia.com)         *
* Support, News, Updates at:  http://www.simplemachines.org                   *
*******************************************************************************
* This program is free software; you may redistribute it and/or modify it     *
* under the terms of the provided license as published by Lewis Media.        *
*                                                                             *
* This program is distributed in the hope that it is and will be useful,      *
* but WITHOUT ANY WARRANTIES; without even any implied warranty of            *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                        *
*                                                                             *
* See the "license.txt" file for details of the Simple Machines license.      *
* The latest version can always be found at http://www.simplemachines.org.    *
******************************************************************************/
if (!defined('SMF'))
die('Hacking attempt...');

/* This file contains one humble function, which applauds or smites a user.

void ModifyKarma()
- gives or takes karma from a user.
- redirects back to the referrer afterward, whether by javascript or
 the passed parameters.
- requires the karma_edit permission, and that the user isn't a guest.
- depends on the karmaMode, karmaWaitTime, and karmaTimeRestrictAdmins
 settings.
- is accessed via ?action=modifykarma.
*/

// Modify a user's karma.
function ModifyKarma()
{
global $modSettings, $db_prefix, $txt, $ID_MEMBER, $user_info, $topic, $scripturl;

// If the mod is disabled, show an error.
if (empty($modSettings['karmaMode']))
fatal_lang_error('smf63');

// If you're a guest or can't do this, blow you off...
is_not_guest();
isAllowedTo('karma_edit');

// If you don't have enough posts, tough luck.
if ($user_info['posts'] < $modSettings['karmaMinPosts'])
fatal_error($txt['smf60'] . $modSettings['karmaMinPosts'] . '.');

// And you can't modify your own, punk! (use the profile if you need to.)
if (empty($_REQUEST['uid']) || (int) $_REQUEST['uid'] == $ID_MEMBER)
fatal_lang_error('smf61', false);

// The user ID _must_ be a number, no matter what.
$_REQUEST['uid'] = (int) $_REQUEST['uid'];

// Applauding or smiting?
$dir = $_REQUEST['sa'] != 'applaud' ? -1 : 1;


//Loading Template of Description
if (!empty($modSettings['karmadescmod'])){
       
loadTemplate('DescriptionKarma');}

       
//Prepare some variables
       
$context['page_title'] = $txt['viewkarma_title'];
       
$context['linktree'][] = array(
           
'url' => $scripturl . '?action=modifykarma',
           
'name' => $txt['viewkarma_title'] );

// Start off with no change in karma.
$action = 0;

// Not an administrator... or one who is restricted as well.
if (!empty($modSettings['karmaTimeRestrictAdmins']) || !allowedTo('moderate_forum'))
{
// Find out if this user has done this recently...
$request = db_query("
SELECT action
FROM
{$db_prefix}log_karma
WHERE ID_TARGET =
$_REQUEST[uid]
AND ID_EXECUTOR =
$ID_MEMBER
LIMIT 1"
, __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
list ($action) = mysql_fetch_row($request);
mysql_free_result($request);
}

// They haven't, not before now, anyhow.

/*
if (empty($action))
{
// Put it in the log.
db_query("
REPLACE INTO {$db_prefix}log_karma
(action, ID_TARGET, ID_EXECUTOR, logTime)
VALUES ($dir, $_REQUEST[uid], $ID_MEMBER, " . time() . ')', __FILE__, __LINE__);

// Change by one.
updateMemberData($_REQUEST['uid'], array($dir == 1 ? 'karmaGood' : 'karmaBad' => '+'));
}
else
{
// If you are gonna try to repeat.... don't allow it.
if ($action == $dir)
fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . '.', false);

// You decided to go back on your previous choice?
db_query("
UPDATE {$db_prefix}log_karma
SET action = $dir, logTime = " . time() . "
WHERE ID_TARGET = $_REQUEST[uid]
AND ID_EXECUTOR = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);


*/
/* They haven't, not before now, anyhow.
          If the key isn't in the array it will return.
          Or if it does exist and it's length is 0 then it will return.
          If Karma Description Mod disable then easy smite or applaud */
if (!empty($modSettings['karmadescmod'])){
if (!
array_key_exists('Description',$_POST) || strlen($_POST["Description"]) == 0){return;}}


{ if ( empty(
$action) || empty($modSettings['karmaWaitTime']))
       {
$_POST['Description'] = AddSlashes($_POST['Description']);
               
//Prepare link
   if (isset ($_REQUEST['topic'])) {
                       
$link = ($_REQUEST['topic']).'.msg'.($_REQUEST['m']).'#'.'msg'.($_REQUEST['m']);
                       
$link = AddSlashes($link);
                        }
               elseif (isset(
$_REQUEST['f'])) {
                       
$link = 'PM';
                        }

// Put it in the log.
               
db_query("
                       INSERT INTO
{$db_prefix}log_karma
                               (action, ID_TARGET, Description, link, ID_EXECUTOR, logTime)
                       VALUES (
$dir, $_REQUEST[uid], '$_POST[Description]', '$link', $ID_MEMBER, ". time()." )
                       "
, __FILE__, __LINE__);
// Change by one.
updateMemberData($_REQUEST['uid'], array($dir == 1 ? 'karmaGood' : 'karmaBad' => '+'));
}
else
{
$request = db_query("
SELECT logTime
FROM
{$db_prefix}log_karma
WHERE ID_TARGET=
$_REQUEST[uid]
AND ID_EXECUTOR=
$ID_MEMBER
ORDER BY logTime DESC
LIMIT 1
"
, __FILE__, __LINE__);
$row = mysql_fetch_assoc($request);
mysql_free_result($request);

$restricttime = time() - $row['logTime'];
$timelog = (int) ($modSettings['karmaWaitTime'] * 3600);

// If you are gonna try to repeat.... don't allow it.
if ($restricttime < $timelog)
fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . '.', false);

//Prepare link
   if (isset ($_REQUEST['topic'])) {
                       
$link = ($_REQUEST['topic']).'.msg'.($_REQUEST['m']).'#'.'msg'.($_REQUEST['m']);
                       
$link = AddSlashes($link);
                        }
               elseif (isset(
$_REQUEST['f'])) {
                       
$link = 'PM';
                        }

// You decided to go back on your previous choice?
db_query("
INSERT INTO
{$db_prefix}log_karma
                               (action, ID_TARGET, Description, link, ID_EXECUTOR, logTime)
                       VALUES (
$dir, $_REQUEST[uid], '$_POST[Description]', '$link', $ID_MEMBER, ". time()." )
                       "
, __FILE__, __LINE__);

// It was recently changed the OTHER way... so... reverse it!
if ($dir == 1)
updateMemberData($_REQUEST['uid'], array('karmaGood' => '+'));
else
updateMemberData($_REQUEST['uid'], array('karmaBad' => '+'));
}
}

// Figure out where to go back to.... the topic?
if (isset($topic))
redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . '#msg' . $_REQUEST['m']);
// Hrm... maybe a personal message?
elseif (isset($_REQUEST['f']))
redirectexit('action=pm;f=' . $_REQUEST['f'] . ';start=' . $_REQUEST['start']);
// JavaScript as a last resort.
/*

else
{
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>...</title>
<script language="JavaScript" type="text/javascript"><!--
history.go(-1);
// --></script>
</head>
<body>&laquo;</body>
</html>';

obExit(false);
}
}

*/
// What's this?  I dunno, what are you talking about?  Never seen this before, nope.  No siree.
function BookOfUnknown()
{
global $context;

if (strpos($_GET['action'], 'mozilla') !== false && !$context['browser']['is_gecko'])
redirectexit('http://www.getfirefox.com/', false);
elseif (strpos($_GET['action'], 'mozilla') !== false)
redirectexit('about:mozilla', false);

echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>The Book of Unknown, 2:18</title>
<style type="text/css">
em
{
font-size: 1.3em;
line-height: 0;
}
</style>
</head>
<body style="background-color: #444455; color: white; font-style: italic; font-family: serif;">
<div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">
Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none.&nbsp;And it became to be in those days <em>something</em>.&nbsp; Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind.&nbsp; And thus what was to be known the <em>secret project</em> began into its existence.&nbsp; Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.
</div>
<div style="margin-top: 2ex; font-size: 2em; text-align: right;">
from <span style="font-family: Georgia, serif;"><strong><a href="http://www.unknownbrackets.com/about:unknown" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>
</div>
</body>
</html>'
;

obExit(false);
}

}

?>

Grek.Kamchatka

KDM 1.9.6 compatible with SMF 1.0.6

Washi

Quote from: Grek_Kamchatka on March 18, 2006, 11:56:50 PM
KDM 1.9.6 compatible with SMF 1.0.6

Could you please post a Karma.php modified only with KDM 1.9.6 so I can see if it works for me? I tried about 30 different version of the file, none worked. But the one posted by z3nith (Thank you so much!) works like a charm.
Thanks a lot!

Grek.Kamchatka

You don't understand... You must install KDM 1.9.6 on your forum, not copy Karma.php. You resieved errors because KDM 1.9.6 has new functions, (by the way, not only in Karma.php), so you uploaded new Karma.php but other needed files is old. 

Aitsukai

Could you make an upgrade script for 1.9.4 to 1.9.6 on 1.1 RC2?

Aitsukai

I tried to install and got:
QuoteThis package is already installed, and no upgrade was found!

You should uninstall the old version first to avoid problems, or ask the author to create an upgrade from your old version.

Please remember to always make regular backups of your sources and database before installing mods, especially beta versions.
I uninstalled the old version last time I updated this mod but it erased all data from the mod. :s

Grek.Kamchatka

Look at the KDM 1.9.4 archive. Is there present uninstall.php? If you have this file in archive, all data will be erased, but if no, everything will be fine. And 2nd variant...download your KDM 1.9.4 arch from your.forum.com/Packages, and edit package_info.xml.

Delete line where you will find uninstall.php. Then pack it back and upload archive to the forum. Now you can uninstall kdm without any data erasing.

Washi

Quote from: Grek_Kamchatka on March 19, 2006, 04:46:04 AM
You don't understand... You must install KDM 1.9.6 on your forum, not copy Karma.php. You resieved errors because KDM 1.9.6 has new functions, (by the way, not only in Karma.php), so you uploaded new Karma.php but other needed files is old. 

I do understand, but everything else works in the package, all the files that needed to be edited have been edited correctly, I get the stats and all the other features, but the Karma.php has been corrupted somehow. That's why I would need that specific file, because I tried modding it myself (the original Karma.php), but I can't get it to work.

Grek.Kamchatka

They have been edited by older KDM version.

Washi

I meant the original Karma.php found in the fresh 1.0.6 zip. Like a brand new one that hasn't been touched before.

Advertisement: