07-19-2007, 07:50 PM
|
#1
|
ÇaKaL Üye
Üyelik Tarihi: Jun 2007
Konum: Houston
Mesajlar: 1,880
Teşekkür Etme: 32
Thanked 29 Times in 24 Posts
Üye No: 43307
İtibar Gücü: 1769
Rep Puanı : 7482
Cinsiyet : Erkek
|
Phpbb Cash Admİn
PHP Code:
<?php
/**************************************************
*************************
* karma.php
* -------------------
* begin : Thursday, Jan 24, 2004
* copyright : © Nome
* email : [email protected]
*
**************************************************
*************************/
/**************************************************
*************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
**************************************************
*************************/
unset($x);
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
// Some extra script settings. You can modify them
// How long do we have to wait before giving karma points again?
$hours_past = 1; // In hours
// Do admins and moders have the permission to give karma points any time they like&
$allow_up = 0; // NOTE THAT 0 = yes, 1 (or above)= no and not otherwize!
// $_GET variables
if ( isset($_GET['t']) ) { $topic_id = $_GET['t']; } else { die("Hacking attempt"); }
if ( isset($_GET['u']) ) { $user = $_GET['u']; } else { die("Hacking attempt"); }
if ( isset($_GET['x']) ) { $x = $_GET['x']; } else { die("Hacking attempt"); }
//Taken from login.php
//
// Set page ID for session management
//
$userdata = session_pagestart($user_ip, PAGE_LOGIN);
init_userprefs($userdata);
//
// End session management
//
if(!$userdata['session_logged_in'])
{
header('Location:' . append_sid("login.$phpEx"));
}
else
{
global $db;
$sql = "select karma_time from " . USERS_TABLE . " where user_id='$userdata[user_id]'"; //get last time user tried a karma vote
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$time_old = $array[0];
$sql = "select user_id from " . USERS_TABLE . " where user_id='$userdata[user_id]'";//make sure no one votes for themselves
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$voter_id = $array[0];
if($voter_id == $user)
{
message_die(CRITICAL_MESSAGE, $lang['No_Self_Karma'] . '<br /><a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '"> ' . $lang['Return_To_Topic'] . ' </a>');
}
else
{
$time = time();
$diff = $time - $time_old;
if($diff >= 3600 * $hours_past || $userdata['user_level'] > $allow_up) //make sure they haven't voted in the last hour or if they're a mod or admin, they can continue
{
if ($x == 'applaud')
{
$sql = "select karma_plus from " . USERS_TABLE . " where user_id='$user'"; //Find the good guy
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$karma = $array[0];
// We only up karma by one
$karma = $karma + 1;
// Here comes the db update
$karma_update = "update " . USERS_TABLE . " set karma_plus ='$karma' where user_id='$user'";
}
else
// If someone tries to fake the x input, that someone will get bad karma;)
{
$sql = "select karma_minus from " . USERS_TABLE . " where user_id='$user'"; //Find the bad guy
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$karma = $array[0];
// We only up karma by one
$karma = $karma + 1;
// Here comes the db update
$karma_update = "update " . USERS_TABLE . " set karma_minus ='$karma' where user_id='$user'";
}
//update the database with current time() for voter
$time_update = "update " . USERS_TABLE . " set karma_time ='$time' where user_id ='$userdata[user_id]'";
$result = $db->sql_query($karma_update);
$time_result = $db->sql_query($time_update);
if($result&&$time_result) //Both gotta happen...
{
if(!isset($topic_id))
{
header('Location:' . append_sid("index.$phpEx"));
break;
}
else
{
header('Location:' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id"));
}
}
else
{
message_die(GENERAL_ERROR, $lang['Critical_Error'] . '<br /><a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '"> ' . $lang['Return_To_Topic'] . ' </a>', __LINE__, __FILE__, $sql);
}
}
else
{
message_die(CRITICAL_MESSAGE, $lang['Too_Soon'] . '<br /><a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '"> ' . $lang['Return_To_Topic'] . ' </a>');
}
}
}
?>
__________________
I walk this empty street on the boulevard of broken dreams where the city sleeps and I'm the only one and I walk alone!!
|
|
|