hab mir Karma Mod installiren wollen als ich alle dateien geändert habe und alles hochgeladen hab kam das:
Code: Alles auswählen
[phpBB Debug] PHP Notice: in file /common.php on line 218: require() [function.require]: Unable to access ./includes/functions_karma.php
[phpBB Debug] PHP Notice: in file /common.php on line 218: require(./includes/functions_karma.php) [function.require]: failed to open stream: No such file or directory
Fatal error: require() [function.require]: Failed opening required './includes/functions_karma.php' (include_path='.:/srv/www/httpd/phost/p/com/pytalhost/pokeblitz/web') in /srv/www/httpd/phost/p/com/pytalhost/pokeblitz/web/forum/common.php on line 218
Code: Alles auswählen
<?php
/**
*
* @package phpBB3
* @version $Id: common.php 8760 2008-08-15 19:46:51Z aptx $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* Minimum Requirement: PHP 4.3.3
*/
/**
*/
if (!defined('IN_PHPBB'))
{
exit;
}
$starttime = explode(' ', microtime());
$starttime = $starttime[1] + $starttime[0];
// Report all errors, except notices
error_reporting(E_ALL ^ E_NOTICE);
/*
* Remove variables created by register_globals from the global scope
* Thanks to Matt Kavanagh
*/
function deregister_globals()
{
$not_unset = array(
'GLOBALS' => true,
'_GET' => true,
'_POST' => true,
'_COOKIE' => true,
'_REQUEST' => true,
'_SERVER' => true,
'_SESSION' => true,
'_ENV' => true,
'_FILES' => true,
'phpEx' => true,
'phpbb_root_path' => true
);
// Not only will array_merge and array_keys give a warning if
// a parameter is not an array, array_merge will actually fail.
// So we check if _SESSION has been initialised.
if (!isset($_SESSION) || !is_array($_SESSION))
{
$_SESSION = array();
}
// Merge all into one extremely huge array; unset this later
$input = array_merge(
array_keys($_GET),
array_keys($_POST),
array_keys($_COOKIE),
array_keys($_SERVER),
array_keys($_SESSION),
array_keys($_ENV),
array_keys($_FILES)
);
foreach ($input as $varname)
{
if (isset($not_unset[$varname]))
{
// Hacking attempt. No point in continuing unless it's a COOKIE
if ($varname !== 'GLOBALS' || isset($_GET['GLOBALS']) || isset($_POST['GLOBALS']) || isset($_SERVER['GLOBALS']) || isset($_SESSION['GLOBALS']) || isset($_ENV['GLOBALS']) || isset($_FILES['GLOBALS']))
{
exit;
}
else
{
$cookie = &$_COOKIE;
while (isset($cookie['GLOBALS']))
{
foreach ($cookie['GLOBALS'] as $registered_var => $value)
{
if (!isset($not_unset[$registered_var]))
{
unset($GLOBALS[$registered_var]);
}
}
$cookie = &$cookie['GLOBALS'];
}
}
}
unset($GLOBALS[$varname]);
}
unset($input);
}
// If we are on PHP >= 6.0.0 we do not need some code
if (version_compare(PHP_VERSION, '6.0.0-dev', '>='))
{
/**
* @ignore
*/
define('STRIP', false);
}
else
{
@set_magic_quotes_runtime(0);
// Be paranoid with passed vars
if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on' || !function_exists('ini_get'))
{
deregister_globals();
}
define('STRIP', (get_magic_quotes_gpc()) ? true : false);
}
if (defined('IN_CRON'))
{
$phpbb_root_path = dirname(__FILE__) . DIRECTORY_SEPARATOR;
}
if (!file_exists($phpbb_root_path . 'config.' . $phpEx))
{
die("<p>The config.$phpEx file could not be found.</p><p><a href=\"{$phpbb_root_path}install/index.$phpEx\">Click here to install phpBB</a></p>");
}
require($phpbb_root_path . 'config.' . $phpEx);
if (!defined('PHPBB_INSTALLED'))
{
// Redirect the user to the installer
// We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information
// available as used by the redirect function
$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
$server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
$secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
$script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
if (!$script_name)
{
$script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
}
// Replace any number of consecutive backslashes and/or slashes with a single slash
// (could happen on some proxy setups and/or Windows servers)
$script_path = trim(dirname($script_name)) . '/install/index.' . $phpEx;
$script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path);
$url = (($secure) ? 'https://' : 'http://') . $server_name;
if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
{
// HTTP HOST can carry a port number...
if (strpos($server_name, ':') === false)
{
$url .= ':' . $server_port;
}
}
$url .= $script_path;
header('Location: ' . $url);
exit;
}
if (defined('DEBUG_EXTRA'))
{
$base_memory_usage = 0;
if (function_exists('memory_get_usage'))
{
$base_memory_usage = memory_get_usage();
}
}
// Load Extensions
if (!empty($load_extensions))
{
$load_extensions = explode(',', $load_extensions);
foreach ($load_extensions as $extension)
{
@dl(trim($extension));
}
}
// Include files
require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx);
require($phpbb_root_path . 'includes/cache.' . $phpEx);
require($phpbb_root_path . 'includes/template.' . $phpEx);
require($phpbb_root_path . 'includes/session.' . $phpEx);
require($phpbb_root_path . 'includes/auth.' . $phpEx);
require($phpbb_root_path . 'includes/functions.' . $phpEx);
require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
require($phpbb_root_path . 'includes/constants.' . $phpEx);
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
// Set PHP error handler to ours
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
// Instantiate some basic classes
$user = new user();
$auth = new auth();
$template = new template();
$cache = new cache();
$db = new $sql_db();
// Connect to DB
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
// We do not need this any longer, unset for safety purposes
unset($dbpasswd);
// Grab global variables, re-cache if necessary
$config = $cache->obtain_config();
// [+] Karma MOD
require($phpbb_root_path . 'includes/functions_karma.' . $phpEx);
// [-] Karma MOD
// Add own hook handler
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
foreach ($cache->obtain_hooks() as $hook)
{
@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
}
?>
http://www.phpbb.com/community/viewtopi ... 0&t=559069
Damits auf 3.0.4 funzt hab ich diese functions_karma.php so geändert:
Code: Alles auswählen
<?php
/**
*
* @package karmamod
* @version $Id: functions_karma.php,v 1.17 2007/09/07 00:11:50 m157y Exp $
* @copyright (c) 2007 David Lawson, m157y, A_Jelly_Doughnut
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
/*
SQL Changes from B1 to B2
ALTER TABLE `phpbb_karma` CHANGE `bbcode_uid` `bbcode_uid` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
*/
// Table name
define('KARMA_TABLE', $table_prefix . 'karma');
class karmamod
{
// Config vars
var $version = '';
var $config = array();
// Auth vars
var $can_karma = false;
var $user_level = false;
// Optimization's vars
var $current_time = false;
/**
* Constructor
*/
function karmamod()
{
global $config, $user, $auth;
// Load language
$user->add_lang('mods/karma');
// Move configs to internal array, for less globals in functions
$this->version = $config['karma_version'];
$this->config['enabled'] = ($config['karma_enabled']) ? true : false;
$this->config['enabled_ucp'] = ($config['karma_enabled_ucp']) ? true : false;
$this->config['comments'] = ($config['karma_comments']) ? true : false;
$this->config['comments_reqd'] = ($config['karma_comments_reqd']) ? true : false;
$this->config['notify_email'] = ($config['email_enable'] && $config['karma_notify_email']) ? true : false;
$this->config['notify_pm'] = ($config['allow_privmsg'] && $config['karma_notify_pm']) ? true : false;
$this->config['notify_jabber'] = ($config['jab_enable'] && $config['karma_notify_jabber']) ? true : false;
$this->config['drafts'] = ($config['karma_drafts']) ? true : false;
$this->config['icons'] = ($config['karma_icons']) ? true : false;
$this->config['viewprofile'] = ($config['karma_viewprofile']) ? true : false;
$this->config['toplist'] = ($config['karma_toplist']) ? true : false;
$this->config['toplist_users'] = (int) ($user->data['is_registered']) ? $user->data['user_karma_toplist_users'] : $config['karma_toplist_users'];
$this->config['time'] = (float) $config['karma_time'];
$this->config['posts'] = (int) $config['karma_posts'];
$this->config['comments_per_page'] = (int) $config['karma_comments_per_page'];
$this->config['power'] = ($config['karma_power']) ? true : false;
$this->config['power_show'] = ($config['karma_power_show']) ? true : false;
$this->config['power_max'] = (int) ($config['karma_power_max'] < 1) ? 5 : $config['karma_power_max'];
$this->config['per_day'] = ($config['karma_per_day'] > 0) ? (int) $config['karma_per_day'] : false;
// Configure user settings
$this->user_level = ($auth->acl_get('a_')) ? 'admin' : (($user->data['is_registered']) ? 'user' : 'guest');
if ($this->user_level != 'guest')
{
$this->config['user_enabled'] = ($this->config['enabled_ucp'] && $user->data['user_karma_enable']) ? true : false;
$this->config['user_notify_email'] = ($this->config['notify_email'] && $user->data['user_karma_notify_email']) ? true : false;
$this->config['user_notify_pm'] = ($this->config['notify_pm'] && $user->data['user_karma_notify_pm']) ? true : false;
$this->config['user_notify_jabber'] = ($this->config['notify_jabber'] && $user->data['user_karma_notify_jabber']) ? true : false;
$this->config['toplist'] = ($this->config['toplist'] && $user->data['user_karma_toplist']) ? true : false;
$this->config['comments_per_page'] = (int) $user->data['user_karma_comments_per_page'];
}
else
{
$this->config['user_enabled'] = true;
$this->config['user_notify_email'] = false;
$this->config['user_notify_pm'] = false;
$this->config['user_notify_jabber'] = false;
}
$this->current_time = time();
}
/**
* Generate toplist if required ...
*/
function toplist()
{
if (!$this->config['enabled'] || !$this->config['toplist'])
{
return;
}
global $db, $phpbb_root_path, $phpEx, $template;
$karma_toplist = '';
$sql = 'SELECT user_id, username, user_colour, user_karma, user_karma_powered
FROM ' . USERS_TABLE . '
WHERE user_id <> ' . ANONYMOUS . '
AND ' . (($this->config['power']) ? 'user_karma_powered' : 'user_karma') . ' > 0
AND ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . '
ORDER BY ' . (($this->config['power']) ? 'user_karma_powered' : 'user_karma') . ' DESC';
$result = $db->sql_query_limit($sql, $this->config['toplist_users']);
while ($row = $db->sql_fetchrow($result))
{
$user_colour = ($row['user_colour']) ? ' style="color:#' . $row['user_colour'] .'"' : '';
$karma_toplist .= (($karma_toplist != '') ? ', ' : '') . '<a' . $user_colour . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']) . '">' . $row['username'] . '</a> (' . (($this->config['power']) ? $row['user_karma_powered'] : $row['user_karma']) . ')';
}
$db->sql_freeresult($result);
// Assign index specific vars
$template->assign_vars(array(
'S_KARMA_TOPLIST' => true,
'KARMA_TOPLIST' => $karma_toplist)
);
}
/**
* Checks can user karma or not?
*/
function check_can_karma($user_id = ANONYMOUS, $karma_time = 0, $foe = false, $friend = false)
{
if (!$this->config['enabled'])
{
return;
}
$this->can_karma = false;
if ($this->user_level != 'guest')
{
global $user;
if ($user->data['user_id'] != $user_id)
{
// It's disable not needed checks for admins
if ($this->user_level == 'admin')
{
$this->can_karma = true;
}
else
{
$this->can_karma = ($user->data['user_posts'] >= $this->config['posts'] && !$foe && !$friend) ? true : false;
if (($this->current_time - $karma_time) < ($this->config['time'] * 3600))
{
$this->can_karma = false;
return;
}
// Karmas per day checker
// if the user already cannot karma, then there is no point in an addtl query
if ($this->config['per_day'] && $this->can_karma && $this->can_karma)
{
global $db;
$sql = 'SELECT COUNT(*) as karmas_per_day
FROM ' . KARMA_TABLE . '
WHERE poster_id = ' . $user->data['user_id'] . '
AND karma_time > ' . (time() - 86400);
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
if ($row['karmas_per_day'] >= $this->config['per_day'])
{
$this->can_karma = false;
}
}
}
}
}
}
/**
* Adds karma's images to imageset editor
*/
function acp_styles_imageset(&$imageset_keys)
{
if (!$this->config['enabled'])
{
return;
}
$imageset_keys['ui'] = array_merge($imageset_keys['ui'], array('icon_karma_increase', 'icon_karma_decrease'));
}
/**
* Adds karma's input information and template to users management page at ACP
*/
function acp_users_data(&$data, $user_row)
{
if (!$this->config['enabled'])
{
return;
}
global $template, $config;
$data = array_merge($data, array(
'karma_enable' => request_var('karma_enable', (bool) $user_row['user_karma_enable']),
'karma_notify_email' => request_var('karma_notify_email', (bool) $user_row['user_karma_notify_email']),
'karma_notify_pm' => request_var('karma_notify_pm', (bool) $user_row['user_karma_notify_pm']),
'karma_notify_jabber' => request_var('karma_notify_jabber', (bool) $user_row['user_karma_notify_jabber']),
'karma_toplist' => request_var('karma_toplist', (bool) $user_row['user_karma_toplist']),
'karma_toplist_users' => request_var('karma_toplist_users', (int) $user_row['user_karma_toplist_users']),
'karma_comments_per_page' => request_var('karma_comments_per_page', (int) $user_row['user_karma_comments_per_page']),
));
$template->assign_vars(array(
'S_ENABLE' => $data['karma_enable'],
'S_NOTIFY_EMAIL' => $data['karma_notify_email'],
'S_NOTIFY_PM' => $data['karma_notify_pm'],
'S_NOTIFY_JABBER' => $data['karma_notify_jabber'],
'S_TOPLIST' => $data['karma_toplist'],
'TOPLIST_USERS' => $data['karma_toplist_users'],
'COMMENTS_PER_PAGE' => $data['karma_comments_per_page'],
'S_KARMA_ENABLE' => true)
);
}
/**
* Check errors at information on users management page at ACP
*/
function acp_users_error(&$error, $data)
{
if (!$this->config['enabled'])
{
return;
}
$error = array_merge($error, validate_data($data, array(
'karma_toplist_users' => array('num', false, 1),
'karma_comments_per_page' => array('num', false, 1, 999),
)));
}
/**
* Adds karma's information to sql of users management page at ACP
*/
function acp_users_sql(&$sql_ary, $data)
{
if (!$this->config['enabled'])
{
return;
}
$sql_ary = array(
'user_karma_enable' => $data['karma_enable'],
'user_karma_notify_email' => $data['karma_notify_email'],
'user_karma_notify_pm' => $data['karma_notify_pm'],
'user_karma_notify_jabber' => $data['karma_notify_jabber'],
'user_karma_toplist' => $data['karma_toplist'],
'user_karma_toplist_users' => $data['karma_toplist_users'],
'user_karma_comments_per_page' => $data['karma_comments_per_page'],
);
}
/**
* Adds karma's information to viewprofile page
*/
function memberlist_viewprofile($member, $foe = false, $friend = false)
{
if (!$this->config['enabled'] || !$member['user_karma_enable'])
{
return;
}
global $db, $user, $template, $phpbb_root_path, $phpEx;
// Select last karma time for this user
$sql = 'SELECT k.karma_time, k2.karma_time as karmaed
FROM ' . KARMA_TABLE . ' k
LEFT JOIN ' . KARMA_TABLE . ' k2
ON (k2.user_id = ' . $member['user_id'] . '
AND k2.poster_id = ' . $user->data['user_id'] . '
AND k2.forum_id = 0
AND k2.topic_id = 0
AND k2.post_id = 0)
WHERE k.user_id = ' . $member['user_id'] . '
AND k.poster_id = ' . $user->data['user_id'] . '
ORDER BY k.karma_time DESC';
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$this->check_can_karma($member['user_id'], $row['karma_time'], $foe, $friend);
$template->assign_vars(array(
'KARMA' => ($this->config['power']) ? $member['user_karma_powered'] : $member['user_karma'],
'U_KARMA_INCREASE' => ($this->can_karma && $member['user_karma_enable'] && !$row['karmaed']) ? append_sid("{$phpbb_root_path}karma.$phpEx", 'u=' . $member['user_id'] . '&mode=update&action=increase') : '',
'U_KARMA_DECREASE' => ($this->can_karma && $member['user_karma_enable'] && !$row['karmaed']) ? append_sid("{$phpbb_root_path}karma.$phpEx", 'u=' . $member['user_id'] . '&mode=update&action=decrease') : '',
'U_KARMA_COMMENTS' => ($this->config['viewprofile'] && $this->config['comments']) ? append_sid("{$phpbb_root_path}karma.$phpEx", 'mode=viewcomments&u=' . $member['user_id']) : '',
'S_KARMA' => true)
);
}
/**
* Add karma option to the dropdown in search
*/
function search_dropdown(&$sort_by_text)
{
if (!$this->config['enabled'])
{
return;
}
global $user;
$sort_by_text['k'] = $user->lang['KARMA'];
}
/**
* Add some SQL to the order by options in search
*/
function search_order_sql(&$sort_by_sql)
{
if (!$this->config['enabled'])
{
return;
}
global $show_results;
$sort_by_sql['k'] = (($show_results == 'posts') ? 'p.post_karma_search' : 't.topic_karma_search') . (($this->config['power']) ? '_powered' : '');
}
/**
* Update viewtopic's SQL-query for per user karma time work
* This may need to be worked on for later versions of the Karma MOD.
*/
function viewtopic_sql(&$sql)
{
if (!$this->config['enabled'])
{
return;
}
global $user;
$sql = str_replace('p.*', 'p.*, k.karma_time, k2.karma_time as karmaed', $sql);
$sql = str_replace('WHERE', 'LEFT JOIN ' . KARMA_TABLE . ' k ON (k.poster_id = ' . $user->data['user_id'] . ' AND k.user_id = p.poster_id) LEFT JOIN ' . KARMA_TABLE . ' k2 ON (k2.poster_id = ' . $user->data['user_id'] . ' AND k2.post_id = p.post_id AND k2.user_id = p.poster_id) WHERE', $sql);
}
/**
* Adds karmaed information to posts rowset
*/
function viewtopic_rowset(&$row, $karmaed = 0)
{
if (!$this->config['enabled'])
{
return;
}
$row['karmaed'] = ($karmaed) ? true : false;
}
/**
* Adds karma's information to user's cache on viewtopic page
*/
function viewtopic_usercache(&$user_cache, $poster_id, $row)
{
if ($poster_id == ANONYMOUS || !$this->config['enabled'])
{
$karma_cache = array(
'karma' => 0,
'karma_can' => false,
'karma_enabled' => false,
);
}
else
{
$this->check_can_karma($poster_id, $row['karma_time'], $row['foe'], $row['friend']);
$karma_cache = array(
'karma' => ($this->config['power']) ? $row['user_karma_powered'] : $row['user_karma'],
'karma_can' => ($this->can_karma) ? true : false,
'karma_enabled' => ($row['user_karma_enable']) ? true : false,
);
}
$user_cache = array_merge($user_cache, $karma_cache);
}
/**
* Adds karma's information to post on viewtopic page
*/
function viewtopic_postrow(&$postrow, $user_cache, $poster_id, $forum_id, $topic_id, $post_id, $karmaed = false)
{
global $phpbb_root_path, $phpEx;
$postrow = array_merge($postrow, array(
'KARMA' => $user_cache['karma'],
'U_KARMA_INCREASE' => ($user_cache['karma_can'] && $user_cache['karma_enabled'] && !$karmaed) ? append_sid("{$phpbb_root_path}karma.$phpEx", 'u=' . $poster_id . '&f=' . $forum_id . '&t=' . $topic_id . '&p=' . $post_id . '&mode=update&action=increase') : '',
'U_KARMA_DECREASE' => ($user_cache['karma_can'] && $user_cache['karma_enabled'] && !$karmaed) ? append_sid("{$phpbb_root_path}karma.$phpEx", 'u=' . $poster_id . '&f=' . $forum_id . '&t=' . $topic_id . '&p=' . $post_id . '&mode=update&action=decrease') : '',
'U_KARMA_COMMENTS' => ($user_cache['karma_enabled'] && $this->config['viewprofile'] && $this->config['comments']) ? append_sid("{$phpbb_root_path}karma.$phpEx", 'mode=viewcomments&u=' . $poster_id) : '',
'S_KARMA_ENABLED' => $this->config['enabled'])
);
}
/**
* Below placed functions which used by karma.php
*
*
* Submit karma to db
*/
function submit_karma($data)
{
global $db, $user;
$current_time = time();
// Update poster's karma
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_karma = user_karma ' . (($data['action'] == 'decrease') ? '-' : '+') . ' 1, user_karma_powered = user_karma_powered ' . (($data['action'] == 'decrease') ? '- ' : '+ ') . $data['karma_power'] . '
WHERE user_id = ' . $data['user_id'];
$db->sql_query($sql);
// Insert data to DB
$sql_ary = array(
'forum_id' => $data['forum_id'],
'topic_id' => $data['topic_id'],
'post_id' => $data['post_id'],
'user_id' => $data['user_id'],
'poster_id' => (int) $user->data['user_id'],
'icon_id' => $data['icon_id'],
'poster_ip' => $user->ip,
'karma_time' => $current_time,
// TODO: approved status for comments
'karma_approved' => 1,
'enable_bbcode' => $data['enable_bbcode'],
'enable_smilies' => $data['enable_smilies'],
'enable_magic_url' => $data['enable_urls'],
'comment_text' => $data['comment'],
'comment_checksum' => $data['comment_md5'],
'bbcode_bitfield' => $data['bbcode_bitfield'],
'bbcode_uid' => $data['bbcode_uid'],
'karma_action' => ($data['action'] == 'decrease') ? '-' : '+',
'karma_power' => $data['karma_power'],
);
$sql = 'INSERT INTO ' . KARMA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
// now we update the posts & topics tables with a bit of information
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_karma = post_karma ' . (($data['action'] == 'decrease') ? '-' : '+') . ' 1, post_karma_powered = post_karma_powered ' . ($data['action'] == 'decrease' ? '- ' : '+ ') . (int) $data['karma_power'] . ', post_karma_count = post_karma_count + 1, post_karma_search = (post_karma / post_karma_count), post_karma_search_powered = (post_karma_powered / post_karma_count)
WHERE post_id = ' . (int) $data['post_id'];
$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_karma = topic_karma ' . (($data['action'] == 'decrease') ? '-' : '+') . ' 1, topic_karma_powered = topic_karma_powered ' . ($data['action'] == 'decrease' ? '- ' : '+ ') . (int) $data['karma_power'] . ', topic_karma_count = topic_karma_count + 1, topic_karma_search = ((topic_karma / topic_karma_count) / (topic_replies + 1)), topic_karma_search_powered = ((topic_karma_powered / topic_karma_count) / (topic_replies + 1))
WHERE topic_id = ' . (int) $data['topic_id'];
$db->sql_query($sql);
// Send Notifications
$this->user_notification($data);
return;
}
/**
* Notify users about karma's changes (via PM/email/jabber)
*/
function user_notification($data)
{
$forum_id = $data['forum_id'];
$topic_id = $data['topic_id'];
$post_id = $data['post_id'];
$user_id = $data['user_id'];
// Select template for messenger, subject and message
if ($data['action'] == 'increase')
{
$subject = 'KARMA_NOTIFY_INCREASE_SUBJECT';
$message = 'KARMA_NOTIFY_INCREASE_MESSAGE';
$notify_tpl = 'karma_notify_increase';
}
else
{
$subject = 'KARMA_NOTIFY_DECREASE_SUBJECT';
$message = 'KARMA_NOTIFY_DECREASE_MESSAGE';
$notify_tpl = 'karma_notify_decrease';
}
if ($this->config['power_show'])
{
$message .= '_POWERED';
$notify_tpl .= '_powered';
}
if ($this->config['user_notify_pm'])
{
global $config, $user, $phpbb_root_path, $phpEx;
$subject = $user->lang[$subject];
$message = sprintf($user->lang[$message], $user->data['username'], $data['karma_power']);
$message .= (!empty($data['comment'])) ? "\r\n" . sprintf($user->lang['KARMA_NOTIFY_MESSAGE_COMMENTS'], $user->data['username']) . "\r\n\r\n" . $data['comment'] : '';
$message .= "\r\n\r\n" . $this->generate_backlink($forum_id, $topic_id, $post_id, $user_id);
include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
$message_parser = new parse_message();
$message = utf8_normalize_nfc($message);
$options = '';
generate_text_for_storage($message, $data['bbcode_uid'], $data['bbcode_bitfield'], $options, true, true, true);
$icon_id = $data['icon_id'];
// Always attach signature status
$enable_sig = (!$config['allow_sig'] || !$config['allow_sig_pm']) ? false : (($user->optionget('attachsig')) ? true : false);
// Store message, sync counters
$pm_data = array(
'from_user_id' => $user->data['user_id'],
'from_user_ip' => $user->data['user_ip'],
'from_username' => $user->data['username'],
'icon_id' => (int) $icon_id,
'enable_sig' => (bool) $enable_sig,
'enable_bbcode' => $data['enable_bbcode'],
'enable_smilies' => $data['enable_smilies'],
'enable_urls' => $data['enable_urls'],
'bbcode_bitfield' => $data['bbcode_bitfield'],
'bbcode_uid' => $data['bbcode_uid'],
'message' => $message,
'address_list' => array ('u' => array($data['user_id'] => 'to'))
);
unset($message_parser);
submit_pm('post', $subject, $pm_data);
}
if ($this->config['user_notify_email'] || $this->config['user_notify_jabber'])
{
if ($this->config['user_notify_email'] && $this->config['user_notify_jabber'])
{
$method = NOTIFY_BOTH;
}
else if ($this->config['user_notify_email'])
{
$method = NOTIFY_EMAIL;
}
else if ($this->config['user_notify_jabber'])
{
$method = NOTIFY_IM;
}
else
{
return;
}
$comment = '';
if ($this->config['comments'] && $data['comment'])
{
$comment = $data['comment'];
// make list items visible as such
if ($dataa['bbcode_uid'])
{
$comment = str_replace('[*:' . $data['bbcode_uid'] . ']', '⋅ ', $comment);
// no BBCode in comment
strip_bbcode($comment, $data['bbcode_uid']);
}
$comment = "\r\n" . $user->lang['KARMA_NOTIFY_MESSAGE_COMMENTS'] . "\r\n" . $comment . "\r\n";
}
// Now, we are able to really send out notifications
global $db, $phpbb_root_path, $phpEx;
include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
$messenger = new messenger();
$messenger->template($notify_tpl, $user->data['user_lang']);
$messenger->to($user->data['user_email'], $user->data['username']);
$messenger->im($user->data['user_jabber'], $user->data['username']);
$messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($user->data['username']),
'AUTHOR_NAME' => htmlspecialchars_decode($data['username']),
'POWER' => $data['karma_power'],
'BACKLINK' => $this->generate_backlink($forum_id, $topic_id, $post_id, $user_id),
'COMMENT' => $comment,
));
$messenger->send($method);
$messenger->save_queue();
}
}
/**
* Thus function generate backlinks for karma changes notifications
*/
function generate_backlink($forum_id = 0, $topic_id = 0, $post_id = 0, $user_id = 0)
{
global $user, $phpEx;
$viewtopic = false;
if ($post_id)
{
$message = $user->lang['KARMA_NOTIFY_BACKLINK_POST'];
$viewtopic = true;
}
else if ($topic_id)
{
$message = $user->lang['KARMA_NOTIFY_BACKLINK_TOPIC'];
$viewtopic = true;
}
else
{
$message = $user->lang['KARMA_NOTIFY_BACKLINK_PROFILE'];
}
if ($viewtopic)
{
$url = generate_board_url() . "/viewtopic.$phpEx?" . (($forum_id) ? "f=$forum_id&" : '') . (($topic_id) ? "t=$topic_id&" : '') . (($post_id) ? "p=$post_id#p$post_id" : '');
}
else
{
$url = generate_board_url() . "/memberlist.$phpEx?mode=viewprofile&u=$user_id";
}
$backlink = $message . $url;
return $backlink;
}
/**
* Prepare profile data
* Used on viewcomments page
* Copied from memberlist.php
*/
function show_profile($data)
{
global $config, $auth, $template, $user, $phpEx, $phpbb_root_path;
$username = $data['username'];
$user_id = $data['user_id'];
$rank_title = $rank_img = $rank_img_src = '';
get_user_rank($data['user_rank'], $data['user_posts'], $rank_title, $rank_img, $rank_img_src);
if (!empty($data['user_allow_viewemail']) || $auth->acl_get('a_email'))
{
$email = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $user_id) : (($config['board_hide_emails'] && !$auth->acl_get('a_email')) ? '' : 'mailto:' . $data['user_email']);
}
else
{
$email = '';
}
if ($config['load_onlinetrack'])
{
$update_time = $config['load_online_time'] * 60;
$online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline'])) || $auth->acl_get('u_viewonline'))) ? true : false;
}
else
{
$online = false;
}
if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline'))
{
$last_visit = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit'];
}
else
{
$last_visit = '';
}
$age = '';
if ($data['user_birthday'])
{
list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday']));
if ($bday_year)
{
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
$diff = $now['mon'] - $bday_month;
if ($diff == 0)
{
$diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
}
else
{
$diff = ($diff < 0) ? 1 : 0;
}
$age = (int) ($now['year'] - $bday_year - $diff);
}
}
// Dump it out to the template
return array(
'AGE' => $age,
'RANK_TITLE' => $rank_title,
'JOINED' => $user->format_date($data['user_regdate']),
'VISITED' => (empty($last_visit)) ? ' - ' : $user->format_date($last_visit),
'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0,
'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0,
'USERNAME_FULL' => get_username_string('full', $user_id, $username, $data['user_colour']),
'USERNAME' => get_username_string('username', $user_id, $username, $data['user_colour']),
'USER_COLOR' => get_username_string('colour', $user_id, $username, $data['user_colour']),
'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $data['user_colour']),
'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),
'S_ONLINE' => ($config['load_onlinetrack'] && $online) ? true : false,
'RANK_IMG' => $rank_img,
'RANK_IMG_SRC' => $rank_img_src,
'ICQ_STATUS_IMG' => (!empty($data['user_icq'])) ? '<img src="http://web.icq.com/whitepages/online?icq=' . $data['user_icq'] . '&img=5" width="18" height="18" />' : '',
'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false,
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '',
'U_NOTES' => $auth->acl_getf_global('m_') ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '',
'U_WARN' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '',
'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($data['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $user_id) : '',
'U_EMAIL' => $email,
'U_WWW' => (!empty($data['user_website'])) ? $data['user_website'] : '',
'U_ICQ' => ($data['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . $data['user_icq'] : '',
'U_AIM' => ($data['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=aim&u=' . $user_id) : '',
'U_YIM' => ($data['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . $data['user_yim'] . '&.src=pg' : '',
'U_MSN' => ($data['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=msnm&u=' . $user_id) : '',
'U_JABBER' => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $user_id) : '',
'LOCATION' => ($data['user_from']) ? $data['user_from'] : '',
'USER_ICQ' => $data['user_icq'],
'USER_AIM' => $data['user_aim'],
'USER_YIM' => $data['user_yim'],
'USER_MSN' => $data['user_msnm'],
'USER_JABBER' => $data['user_jabber'],
'USER_JABBER_IMG' => ($data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '',
'L_VIEWING_PROFILE' => sprintf($user->lang['VIEWING_PROFILE'], $username),
);
}
}
$karmamod = NULL;
?>
Bitte um schnelle Hilfe!
MfG Pokefan2