".$lang_fun['text_here_if_sure'],false); sql_query("DELETE FROM fun WHERE id=".sqlesc($id)) or sqlerr(__FILE__, __LINE__); $Cache->delete_value('current_fun_content'); $Cache->delete_value('current_fun', true); $Cache->delete_value('current_fun_vote_count'); $Cache->delete_value('current_fun_vote_funny_count'); if ($returnto != "") header("Location: $returnto"); } if ($action == 'new') { $sql = "SELECT *, IF(ADDTIME(added, '1 0:0:0') < NOW(),true,false) AS neednew FROM fun WHERE status != 'banned' AND status != 'dull' ORDER BY added DESC LIMIT 1"; $result = sql_query($sql) or sqlerr(__FILE__,__LINE__); $row = mysql_fetch_array($result); if ($row && !$row['neednew']) stderr($lang_fun['std_error'],$lang_fun['std_the_newest_fun_item'].htmlspecialchars($row['title']).$lang_fun['std_posted_on'].$row['added'].$lang_fun['std_need_to_wait']); else { stdhead($lang_fun['head_new_fun']); begin_main_frame(); $title = $lang_fun['text_submit_new_fun']; print("
", false); } } function funreward($funvote, $totalvote, $title, $posterid, $bonus) { global $lang_fun, $Cache; KPS("+",$bonus,$posterid); $locale = get_user_lang($posterid); $subject = nexus_trans("fun.msg_fun_item_reward", [], $locale); $msg = $funvote.nexus_trans("fun.msg_out_of", [], $locale).$totalvote.nexus_trans("fun.msg_people_think", [], $locale).$title.nexus_trans("fun.msg_is_fun", [], $locale).$bonus.nexus_trans("fun.msg_bonus_as_reward", [], $locale); \App\Models\Message::add([ 'sender' => 0, 'receiver' => $posterid, 'subject' => $subject, 'added' => now(), 'msg' => $msg, ]); sql_query($sql) or sqlerr(__FILE__, __LINE__); $Cache->delete_value('user_'.$posterid.'_unread_message_count'); $Cache->delete_value('user_'.$posterid.'_inbox_count'); } if ($action == 'vote') { $id = intval($_GET["id"] ?? 0); int_check($id,true); $res = sql_query("SELECT * FROM fun WHERE id=$id") or sqlerr(__FILE__,__LINE__); $arr = mysql_fetch_array($res); if (!$arr) stderr($lang_fun['std_error'], $lang_fun['std_invalid_id']); else { $res = sql_query("SELECT * FROM funvotes WHERE funid=$id AND userid = {$CURUSER['id']}") or sqlerr(__FILE__,__LINE__); $checkvote = mysql_fetch_array($res); if ($checkvote) stderr($lang_fun['std_error'], $lang_fun['std_already_vote']); else { if ($_GET["yourvote"] == 'dull') $vote = 'dull'; else $vote = 'fun'; $sql = "INSERT INTO funvotes (funid, userid, added, vote) VALUES (".sqlesc($id).",".$CURUSER['id'].",".sqlesc(date("Y-m-d H:i:s")).",".sqlesc($vote).")"; sql_query($sql) or sqlerr(__FILE__,__LINE__); KPS("+",$funboxvote_bonus,$CURUSER['id']); //voter gets 1.0 bonus per vote $totalvote = $Cache->get_value('current_fun_vote_count'); if ($totalvote == ""){ $totalvote = get_row_count("funvotes", "WHERE funid = ".sqlesc($row['id'])); } else $totalvote++; $Cache->cache_value('current_fun_vote_count', $totalvote, 756); $funvote = $Cache->get_value('current_fun_vote_funny_count'); if ($funvote == ""){ $funvote = get_row_count("funvotes", "WHERE funid = ".sqlesc($row['id'])." AND vote='fun'"); } elseif($vote == 'fun') $funvote++; $Cache->cache_value('current_fun_vote_funny_count', $funvote, 756); if ($totalvote) $ratio = $funvote / $totalvote; else $ratio = 1; if ($totalvote >= 20){ if ($ratio > 0.75){ sql_query("UPDATE fun SET status = 'veryfunny' WHERE id = ".sqlesc($id)); if ($totalvote == 25) //Give fun item poster some bonus and write a message to him funreward($funvote, $totalvote, $arr['title'], $arr['userid'], $funboxreward_bonus * 2); if ($totalvote == 50) funreward($funvote, $totalvote, $arr['title'], $arr['userid'], $funboxreward_bonus * 2); if ($totalvote == 100) funreward($funvote, $totalvote, $arr['title'], $arr['userid'], $funboxreward_bonus * 2); if ($totalvote == 200) funreward($funvote, $totalvote, $arr['title'], $arr['userid'], $funboxreward_bonus * 2); } elseif ($ratio > 0.5){ sql_query("UPDATE fun SET status = 'funny' WHERE id = ".sqlesc($id)); if ($totalvote == 25) //Give fun item poster some bonus and write a message to him funreward($funvote, $totalvote, $arr['id'], $arr['userid'], $funboxreward_bonus); if ($totalvote == 50) funreward($funvote, $totalvote, $arr['id'], $arr['userid'], $funboxreward_bonus); if ($totalvote == 100) funreward($funvote, $totalvote, $arr['id'], $arr['userid'], $funboxreward_bonus); if ($totalvote == 200) funreward($funvote, $totalvote, $arr['id'], $arr['userid'], $funboxreward_bonus); } elseif ($ratio > 0.25){ sql_query("UPDATE fun SET status = 'notfunny' WHERE id = ".sqlesc($id)); } else{ sql_query("UPDATE fun SET status = 'dull' WHERE id = ".sqlesc($id)); //write a message to fun item poster $locale = get_user_locale($arr['userid']); $subject = nexus_trans("fun.msg_fun_item_dull", [], $locale); $msg = ($totalvote - $funvote).nexus_trans("fun.msg_out_of", [], $locale).$totalvote.nexus_trans("fun.msg_people_think", [], $locale).$arr['title'].nexus_trans("fun.msg_is_dull", [], $locale); \App\Models\Message::add([ 'sender' => 0, 'receiver' => $arr['userid'], 'subject' => $subject, 'added' => now(), 'msg' => $msg, ]); } } } } } ?>