sibtracker/system/modules/reputation.php
2019-05-18 13:46:03 +08:00

104 lines
5.2 KiB
PHP

<?php
if(!defined('DATALIFEENGINE')){die("Hacking attempt!");}
if (intval($row['user_id']) != 0)
{
if ($row['repa_off'] == 0)
{
$repa_mod_mas = explode ("|", $row['repa_mod']);
$repa_type = "(<font color=green><b>".$repa_mod_mas[0]."</b></font><b>|</b><font color=red><b>".$repa_mod_mas[1]."</b></font>)";
$repa_minus = "<a OnClick=\"Reputation('0', '$row[user_id]');\"><img src='{THEME}/images/repa_dn.gif' alt='-' border='0' /></a>&nbsp;";
$repa_plus = "&nbsp;<a OnClick=\"Reputation('1', '$row[user_id]');\"><img src='{THEME}/images/repa_up.gif' alt='+' border='0' /></a>";
$tpl->set('{repa}', "<span id='repa-".$row['user_id']."'>".$repa_plus." <a href=\"".$config['http_home_url']."user/reputation/".urlencode($row['name'])."/\">".$repa_type."</a> ".$repa_minus."</span>");
} else {
$tpl->set('{repa}', "Âûêë.");
}
}
else
{
$tpl->set('{repa}', " 0");
}
if( $_REQUEST['action'] == "list" ) {
$user = $db->safesql( htmlspecialchars( urldecode( $_REQUEST['user'] ) ) );
include_once SYSTEM_DIR.'/data/repa.php';
include_once ROOT_DIR . '/language/' . $config['langs'] . '/website_repa.lng';
if($repa_cf['status']=='no'){
msgbox ($lang['all_err_1'], $lang_repa['gen_status_off']);
}else{
$sql_result = $db->query("SELECT * FROM " . USERPREFIX . "_users where name = '$user'");
while($row = $db->get_row($sql_result)){
$user_found = TRUE;
$repa_off = $row['repa_off'];
}
if ($repa_off == 0){
$limit = intval($repa_cf['res_site']);
$pass = $db->super_query("SELECT COUNT(*) as count FROM `" . USERPREFIX . "_reputation` where `komu` = '$user'");
$posts = $pass['count'];
if($posts == 0)
{
if ($user_found == TRUE)
{
$tpl->load_template('reputation.tpl');
$tpl->set('{usertitle}',"<a href=\"".$config['http_home_url']."user/".urlencode($user)."/\">".$user."</a>");
$tpl->set('{history_content}', 'Èçìåíåíèé íåáûëî');
}
}else{
$page = intval( $_REQUEST['cstart'] );
$total = intval( ( ( $posts - 1 ) / $limit ) + 1 );
if( $page <= 0 ) $page = 1;
if( $page > $total ) $page = $total;
$start = $page * $limit - $limit;
$i = $start;
$result = $db->query("SELECT * FROM `" . USERPREFIX . "_reputation` WHERE `komu`='$user' ORDER BY `date` DESC LIMIT " . $start . "," . $limit);
$repa_list = "<table width=100% class=userstop><tr bgcolor=#F2F2F2><td><div align=center><strong>Àâòîð</strong></div></td><td><div align=center><strong>Êîììåíòàðèé</strong></div></td><td><div align=center><strong>Äàòà</strong></div></td><td></td></tr>";
while($row = $db->get_row($result))
{
$i ++;
if ($repa_cf['robot'] == $row['author']) $auth_link = $row['author'];
else{$auth_link = "<a href=\"".$config['http_home_url']."user/".urlencode($row['author'])."/\">".$row['author']."</a>";}
switch($row['how'])
{
case($row['how'] > 0): $how = '<img src="{THEME}/images/repa_up.gif" alt="'.$lang_repa['repa_up'].'">'; break;
case($row['how'] < 0): $how = '<img src="{THEME}/images/repa_dn.gif" alt="'.$lang_repa['repa_down'].'">'; break;
case($row['how'] == "totalminus"): $how = '<img src="{THEME}/images/repa_adm.png" alt="'.$lang_repa['repa_adm'].'" title="Ïîíèæåíèå íà '.$repa_cf[adm_minus].' ïóíêòîâ">'; break;
case($row['how'] == "totalplus"): $how = '<img src="{THEME}/images/repa_adm_p.png" alt="'.$lang_repa['repa_adm'].'" title="Ïîâûøåíèå íà '.$repa_cf[adm_plus].' ïóíêòîâ">'; break;
}
$row['date'] = strtotime($row['date']);
if( date( Ymd, $row['date'] ) == date( Ymd, $_TIME ) )$date = $lang['time_heute'] . langdate( ", H:i", $row['date'] );
elseif( date( Ymd, $row['date'] ) == date( Ymd, ($_TIME - 86400) ) )$date = $lang['time_gestern'] . langdate( ", H:i", $row['date'] );
else $date = langdate( $config['timestamp_active'], $row['date'] );
if ($repa_cf['comm_page'] == 1 AND $row['url_page']) $row['text'] .= "<br>Èçìåíåíî íà ýòîé <a href=\"".$row['url_page']."\">ñòðàíèöå</a>.";
$repa_list .= "<tr><td width=18% align=center>".$auth_link."</td><td width=40% align=center>".$row['text']."</td><td width=15% align=center>".$date."</td><td width=2% align=center>".$how."</td></tr>";
}
$repa_list .= "</table>";
$tpl->load_template('reputation.tpl');
$tpl->set('{usertitle}',"<a href=\"".$config['http_home_url']."user/".urlencode($user)."/\">".$user."</a>");
$tpl->set('{history_content}', $repa_list);
$tpl->compile('content');
$tpl->clear();
$nav = "/user/reputation/".$user."/page/{page}";
CreateNavigation( $nav, $page, $total );
}
$tpl->compile('content');
$tpl->clear();
$db->free();
}
else msgbox ($lang['all_err_1'], "Ïîëüçîâàòåëü îòêëþ÷èë ðåïóòàöèþ â ñâîèõ íàñòðîéêàõ. Âû íå ìîæåòå ïðîñìîòðåòü èñòîðèþ åãî ðåïóòàöèè.<br /><a href=\"javascript:history.go(-1)\">Âåðíóòüñÿ íàçàä.</a>");
if ($user_found == FALSE) { msgbox ($lang['all_err_1'], $lang['news_err_26']); }
}
}
?>