SHARE
TWEET

Untitled

a guest Apr 21st, 2018 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. function boomLogged(){
  3.     global $boom_access;
  4.     if($boom_access == 1){
  5.         return true;
  6.     }
  7. }
  8. function emoprocess($string) {
  9.     $string = str_replace(array(':)',':P',':D',':(',':-O'),array(':smile:',':tongue:',':smileface:',':sad:',':omg:'), $string);
  10.     return $string;
  11. }
  12. function normalise($text, $a){
  13.     $count = substr_count($text,"http");
  14.     if($count > $a){
  15.         return false;
  16.     }
  17.     return true;
  18. }
  19. function burl(){
  20.     $ht = 'http';
  21.     if(isset($_SERVER['HTTPS'])){
  22.         $ht = 'https';
  23.     }
  24.     $burl = $ht . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  25.     return $burl;
  26. }
  27. function inRoom(){
  28.     global $data;
  29.     if($data['user_roomid'] != '0'){
  30.         return true;
  31.     }
  32. }
  33. function notVerified(){
  34.     global $data;
  35.     if($data['user_verify'] != 0 && !isStaff($data['user_rank']) &&  $data['activation'] == 1 ){
  36.         return true;
  37.     }
  38. }
  39. function clearBoomCache(){
  40.     global $mysqli;
  41.     $mysqli->query("UPDATE boom_setting SET bbfv = bbfv + 0.05");
  42. }
  43. function userVerified($u){
  44.     if($u == 1){
  45.         return true;
  46.     }
  47. }
  48. function usePlayer(){
  49.     global $data;
  50.     if($data['player_id'] != 0){
  51.         return true;
  52.     }
  53. }
  54. function boomThisText($text){
  55.     global $lang, $data;
  56.     $text = str_replace(array('%email%', '%user%', '%cemail%'), array($data['user_email'], $data['user_name'], '<span class="theme_color">' . $data['user_email'] . '</span>'), $text);
  57.     return $text;
  58. }
  59. function getUserAge($age){
  60.     global $lang;
  61.     if($age == 0){
  62.         return $lang['not_set'];
  63.     }
  64.     else {
  65.         return $age . ' ' . $lang['years_old'];
  66.     }
  67. }
  68. function isBoomJson($res){
  69.     if(is_string($res) && is_array(json_decode($res, true)) && (json_last_error() == JSON_ERROR_NONE)){
  70.         return true;
  71.     }
  72. }
  73. function getUserTheme($theme){
  74.     global $data;
  75.     if($theme == 'system'){
  76.         return $data['default_theme'];
  77.     }
  78.     else {
  79.         return $theme;
  80.     }
  81. }
  82. function boomCacheUpdate(){
  83.     global $mysqli;
  84.     $mysqli->query("UPDATE boom_setting SET bbfv = bbfv + 0.01 WHERE id > 0");
  85. }
  86. function userLocation($user){
  87.     global $lang;
  88.     if($user['country'] == 'hide' || $user['region'] == 'hide'){
  89.         return $lang['not_set'];
  90.     }
  91.     else {
  92.         return $user['country'] . ',' . $user['region'];
  93.     }
  94. }
  95. function boomSex($s){
  96.     if($s != 0){
  97.         return true;
  98.     }
  99. }
  100. function boomAge($a){
  101.     if($a != 0){
  102.         return true;
  103.     }
  104. }
  105. function boomLocation($user){
  106.     if($user['country'] != 'hide' && $user['region'] != 'hide'){
  107.         return true;
  108.     }
  109. }
  110. function pageMenu($load, $icon, $txt){
  111.     return '<li data="' . $load . '" class="get_dat pmenu"><span class="boom_menu_icon pagemenui"><i class="fa fa-' . $icon . '"></i></span>' . $txt . '</li>';
  112. }
  113. function pageBoxMenu($load, $icon, $txt, $type, $size = 0){
  114.     return '<li onclick="getBox(\'' . $load . '\', \'' . $type . '\', ' . $size . ');" class="pmenu"><span class="boom_menu_icon pagemenui"><i class="fa fa-' . $icon . ' pagemenui"></i></span>' . $txt . '</li>';
  115. }
  116. function roomType($type){
  117.     global $data;
  118.     if($type >= 0 && $type <= $data['user_rank']){
  119.         return true;
  120.     }
  121. }
  122. function checkBan($ip){
  123.     global $mysqli, $data;
  124.     if(boomLogged()){
  125.         $getip = $mysqli->query("SELECT * FROM boom_banned WHERE ip = '$ip'");
  126.         if($getip->num_rows > 0 || $data['user_banned'] > 0){
  127.             if(!boomAllow(10)){
  128.                 return true;
  129.             }
  130.         }
  131.     }
  132. }
  133. function boomStaffContact($id){
  134.     global $mysqli;
  135.     $user = userDetails($id);
  136.     if(empty($user)){
  137.         return false;
  138.     }
  139.     if(isStaff($user['user_rank'])){
  140.         return true;
  141.     }
  142. }
  143. function useLobby(){
  144.     global $data;
  145.     if($data['use_lobby'] == 1){
  146.         return true;
  147.     }
  148. }
  149. function getBackMain($id){
  150.     global $mysqli;
  151.     $post = array();
  152.     $get_back = $mysqli->query("
  153.     SELECT boom_chat.*, boom_users.user_name, boom_users.user_color, boom_users.bccolor, boom_users.user_tumb
  154.     FROM boom_chat
  155.     LEFT JOIN boom_users
  156.     ON boom_chat.user_id = boom_users.user_id
  157.     WHERE boom_chat.user_id = '$id'
  158.     ORDER BY `post_id` DESC LIMIT 1
  159.     ");
  160.     if($get_back->num_rows == 1){
  161.         $post = $get_back->fetch_assoc();
  162.     }
  163.     return $post;
  164. }
  165. function getBackPrivate($id){
  166.     global $mysqli;
  167.     $post = array();
  168.     $get_back = $mysqli->query("
  169.     SELECT boom_private.*, boom_users.user_name, boom_users.user_id, boom_users.user_color, boom_users.user_tumb
  170.     FROM boom_private
  171.     LEFT JOIN boom_users
  172.     ON boom_private.hunter = boom_users.user_id
  173.     WHERE boom_private.hunter = '$id'
  174.     ORDER BY `id` DESC LIMIT 1
  175.     ");
  176.     if($get_back->num_rows == 1){
  177.         $post = $get_back->fetch_assoc();
  178.     }
  179.     return $post;
  180. }
  181. function boomIgnored($hunter, $target){
  182.     global $mysqli;
  183.     $get_ignore = $mysqli->query("SELECT * FROM boom_ignore WHERE ignorer = '$hunter' AND ignored = '$target' OR ignorer = '$target' AND ignored = '$hunter'");
  184.     if($get_ignore->num_rows > 0){
  185.         return true;
  186.     }
  187. }
  188. function clearPrivate($hunter, $target){
  189.     global $mysqli;
  190.     $mysqli->query("DELETE FROM boom_private WHERE hunter = '$hunter' AND target = '$target' OR hunter = '$target' AND target = '$hunter'");   
  191. }
  192. function roomRanking($rank = 0){
  193.     global $lang;
  194.     $room_menu = '<option value="0" ' . selCurrent($rank, 0) . '>' . $lang['public'] . '</option>';
  195.     if(boomAllow(1)){
  196.         $room_menu .= '<option value="1" ' . selCurrent($rank, 1) . '>' . $lang['user'] . '</option>';
  197.     }
  198.     if(boomAllow(2)){
  199.         $room_menu .= '<option value="2" ' . selCurrent($rank, 2) . '>' . $lang['vip'] . '</option>';
  200.     }
  201.     if(boomAllow(8)){
  202.         $room_menu .= '<option value="8" ' . selCurrent($rank, 8) . '>' . $lang['staff'] . '</option>';
  203.     }
  204.     return $room_menu;
  205. }
  206. function _isCurl(){
  207.     return function_exists('curl_version');
  208. }
  209. function optionCount($sel, $min, $max, $divider, $alias = ''){
  210.     $val = '';
  211.     for ($n = $min; $n <= $max; $n+=$divider) {
  212.         $val .= '<option value="' . $n . '" ' . selCurrent($sel, $n) . '>' . $n . ' ' . $alias . '</option>';
  213.     }
  214.     return $val;
  215. }
  216. function useBridge(){
  217.     global $data;
  218.     if($data['use_bridge'] > 0){
  219.         return true;
  220.     }
  221. }
  222. function getConfig($val){
  223.     global $data;
  224.     return $data[$val];
  225. }
  226. function sessionCleanup(){
  227.     global $boom_config;
  228.     unset($_SESSION['facebook_access_token']);
  229.     unset($_SESSION[$boom_config['prefix'] . 'token']);
  230.     unset($_SESSION[$boom_config['prefix'] . 'last']);
  231.     unset($_SESSION[$boom_config['prefix'] . 'flood']);
  232.     unset($_SESSION['HA::STORE']);
  233.     unset($_SESSION['HA::CONFIG']);
  234.     unset($_SESSION['FBRLH_state']);
  235.     unset($_SESSION['token']);
  236. }
  237. function trimContent($text){
  238.     $text = str_ireplace(array('****', 'b_o_o_m', 'my_notice', '%bcclear%', '%bcjoin%', '%bcquit%', 'cody_act', '%spam%'), '*****', $text);
  239.     return $text;
  240. }
  241. function getBoomName($name, $connection){
  242.     $t = 0;
  243.     $tcount = 0;
  244.     $try = $name;
  245.     while($t == 0){
  246.         $tdouble = $connection->query("SELECT * FROM boom_users WHERE user_name = '$try'");
  247.         if($tdouble->num_rows > 0){
  248.             $tcount++;
  249.             $try = $name . $tcount;
  250.         }
  251.         else{
  252.             $t = 1;
  253.         }
  254.     }
  255.     return $try;
  256. }
  257. function colorChoice($sel, $type, $min = 1, $max = 24){
  258.     $show_c = '';
  259.     $c = '';
  260.     switch($type){
  261.         case 1:
  262.             $c = 'choice';
  263.             break;
  264.         case 2:
  265.             $c = 'user_choice';
  266.             break;
  267.         case 3:
  268.             $c = 'name_choice';
  269.             break;
  270.     }
  271.     for ($n = $min; $n <= $max; $n++) {
  272.         $val = 'bcolor' . $n;
  273.         $back = 'bcback' . $n;
  274.         if($val == $sel){
  275.             $show_c .= '<div data="' . $val . '" class="color_switch ' . $c . ' ' . $back . '"><i class="bccheck fa fa-check"></i></div>';
  276.         }
  277.         else {
  278.             $show_c .= '<div data="' . $val . '"  class="color_switch ' . $c . ' ' . $back . '"></div>';
  279.         }
  280.     }
  281.     return $show_c;
  282. }
  283. function boldIt($sel){
  284.     if($sel == 'bolded'){
  285.         return 'theme_btn';
  286.     }
  287.     else {
  288.         return 'default_btn';
  289.     }
  290. }
  291. function boomFileSpace($f){
  292.     return str_replace(' ', '_', $f);
  293. }
  294. function profileRegion(){
  295.     global $data, $lang;
  296.     require __DIR__ . '/location/country_list.php';
  297.     if(array_key_exists($data['country'], $regions_list)){
  298.         $my_region = $regions_list[$data['country']];
  299.         foreach ($my_region as $region) {
  300.             $list_region .= '<option ' . selCurrent($data['region'], trim($region)) . '>' . trim($region) . '</option>';
  301.         }
  302.     }
  303.     $list_region .= '<option value="hide" ' . selCurrent($data['region'], 'Hide') . '>' . $lang['not_shared'] . '</option>';
  304.     return $list_region;
  305. }
  306. function listCountry($c, $type){
  307.     global $lang;
  308.     require __DIR__ . '/location/country_list.php';
  309.     $list_country = '';
  310.     if($type == 1){
  311.         $list_country .= '<option class="placeholder" selected disabled>' . $lang['country'] . '</option>';
  312.     }
  313.     foreach ($country_list as $country) {
  314.         $list_country .= '<option ' . selCurrent($c, trim($country)) . ' value="' . $country . '">' . $country . '</option>';
  315.     }
  316.     if($type == 2){
  317.         $list_country .= '<option value="hide" ' . selCurrent($c, 'hide') . '>' . $lang['not_shared'] . '</option>';   
  318.     }
  319.     return $list_country;
  320. }
  321. function okRegister($ip){
  322.     global $mysqli, $data;
  323.     $reg_delay = time() - 86400;
  324.     $check = $mysqli->query("SELECT user_id FROM boom_users WHERE user_ip = '$ip' AND user_join >= '$reg_delay' AND user_rank != 0");
  325.     if($check->num_rows < $data['max_reg']){
  326.         return true;
  327.     }
  328.     else {
  329.         return false;
  330.     }
  331. }
  332. function guestCanRegister(){
  333.     global $data;
  334.     if(isGuest($data['user_rank']) && $data['registration'] == 1){
  335.         return true;
  336.     }
  337. }
  338. function okGuest($ip){
  339.     global $mysqli, $data, $boom_config;
  340.     $reg_delay = time() - 86400;
  341.     $check = $mysqli->query("SELECT user_id FROM boom_users WHERE user_ip = '$ip' AND user_join >= '$reg_delay' AND user_rank = 0");
  342.     if($check->num_rows < $boom_config['guest_per_day']){
  343.         return true;
  344.     }
  345.     else {
  346.         return false;
  347.     }
  348. }
  349. function listSmilies($type){
  350.     switch($type){
  351.         case 1:
  352.             $emo_act = 'document.chat_data.content';
  353.             $closetype = 'closesmilies';
  354.             break;
  355.         case 2:
  356.             $emo_act = 'document.private_form.message_content';
  357.             $closetype = 'closesmilies_priv';
  358.             break;
  359.     }
  360.     $files = scandir(__DIR__ . '/../emoticon');
  361.     foreach ($files as $file){
  362.         if ($file != "." && $file != ".."){
  363.                 $smile = preg_replace('/\.[^.]*$/', '', $file);
  364.                 if(strpos($file, '.png')){
  365.                     echo '<div  title=":' . $smile . ':" class="emoticon ' . $closetype . '"><img  class="lazyboom" data-img="emoticon/' . $smile . '.png" src="" onclick="emoticon(' . $emo_act . ', \':' . $smile . ':\')"/></div>';;
  366.                 }
  367.                 if(strpos($file, '.gif')){
  368.                     echo '<div  title=":' . $smile . ':" class="emoticon ' . $closetype . '"><img  class="lazyboom" data-img="emoticon/' . $smile . '.gif" src="" onclick="emoticon(' . $emo_act . ', \':' . $smile . ':\')"/></div>';;
  369.                 }
  370.         }
  371.     }
  372. }
  373. function createTumbnail($source, $path, $type, $width, $height, $sizew, $sizeh) {
  374.     $dst    = @imagecreatetruecolor($sizew, $sizeh);
  375.     switch ($type) {
  376.         case 'image/gif':
  377.             $src = @imagecreatefromgif($source);
  378.             break;
  379.         case 'image/png':
  380.             $src = @imagecreatefrompng($source);
  381.             break;
  382.         case 'image/jpeg':
  383.             $src = @imagecreatefromjpeg($source);
  384.             break;
  385.         default:
  386.             return false;
  387.             break;
  388.     }
  389.     $new_width  = $height * $sizew / $sizeh;
  390.     $new_height = $width * $sizeh / $sizew;
  391.     if ($new_width > $width) {
  392.         $h = (($height - $new_height) / 2);
  393.         @imagecopyresampled($dst, $src, 0, 0, 0, $h, $sizew, $sizeh, $width, $new_height);
  394.     } else {
  395.         $w = (($width - $new_width) / 2);
  396.         @imagecopyresampled($dst, $src, 0, 0, $w, 0, $sizew, $sizeh, $new_width, $height);
  397.     }
  398.     switch ($type) {
  399.         case 'image/gif':
  400.             @imagegif($dst, $path, 80);
  401.             break;
  402.         case 'image/png':;
  403.             @imagejpeg($dst, $path, 80);
  404.             break;
  405.         case 'image/jpeg':
  406.             @imagejpeg($dst, $path, 80);
  407.             break;
  408.         default:
  409.             return false;
  410.             break;
  411.     }
  412.     if ($dst)
  413.         @imagedestroy($dst);
  414.     if ($src)
  415.         @imagedestroy($src);
  416. }
  417. function validate_name($name){
  418.     global $data, $mysqli;
  419.     $lowname = mb_strtolower($name);
  420.     $reserved = array('b_o_o_m', 'my_notice', $data['guest_prefix'], 'cody_act');
  421.     foreach ($reserved as $sreserve){
  422.         if(stripos($lowname,mb_strtolower($sreserve)) !== FALSE){
  423.             return false;
  424.         }
  425.     }
  426.     $get_name = $mysqli->query("SELECT word FROM boom_filter WHERE word_type = 'username'");
  427.     if($get_name->num_rows > 0){
  428.         while($reject = $get_name->fetch_assoc()){
  429.             if (stripos($lowname, mb_strtolower($reject['word'])) !== FALSE) {
  430.                 return false;
  431.             }
  432.         }
  433.     }
  434.     $regex = 'a-zA-Z0-9\p{Arabic}\p{Cyrillic}\p{Latin}\p{Han}\p{Katakana}\p{Hiragana}\p{Hebrew}';
  435.     if(preg_match('/^[' . $regex . ']{1,}([\-\_ ]{1})?([' . $regex . ']{1,})?$/ui', $name) && mb_strlen($name, 'UTF-8') <= $data['max_username'] && !ctype_digit($name) && mb_strlen($name) >= 2){
  436.         return true;
  437.     }
  438.     return false;
  439. }
  440. function doCurl($url, $f = array()){
  441.     $result = '';
  442.     if(function_exists('curl_init')){
  443.         $curl = curl_init();
  444.         curl_setopt($curl, CURLOPT_URL, $url);
  445.         if(!empty($f)){
  446.             curl_setopt($curl, CURLOPT_POST, true);
  447.             curl_setopt($curl, CURLOPT_POSTFIELDS, $f);
  448.         }
  449.         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  450.         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  451.         curl_setopt($curl, CURLOPT_HEADER, false);
  452.         curl_setopt($curl, CURLOPT_REFERER, burl());
  453.         $result = curl_exec($curl);
  454.         curl_close($curl);
  455.     }
  456.     return $result;
  457. }
  458. function trimCommand($text, $trim){
  459.     return trim(str_replace($trim, '', $text));
  460. }
  461. function encodeFile($ext){
  462.     global $data;
  463.     $file_name = md5(rand(11,99) . time());
  464.     $file_name = substr($file_name, 0, 12);
  465.     return 'user' . $data['user_id'] . '_' . $file_name . "." . $ext;
  466. }
  467. function listAge($current, $type){
  468.     global $data, $lang;
  469.     $age = '';
  470.     if($type == 1){
  471.         $age .= '<option value="0" class="placeholder" selected disabled>' . $lang['age'] . '</option>';
  472.     }
  473.     for($value = $data['min_age']; $value <= 99; $value++){
  474.         $age .=  '<option value="' . $value . '" ' . selCurrent($current, $value) . '>' . $value . '</option>';
  475.     }
  476.     if($type == 2){
  477.         $age .=  '<option value="0" ' . selCurrent($current, 0) . '>' . $lang['not_shared'] . '</option>';
  478.     }
  479.     return $age;
  480. }
  481. function onOff($value){
  482.     global $lang;
  483.     $menu = '';
  484.     $menu .= '<option value="1" ' . selCurrent($value, 1) . '>' . $lang['yes'] . '</option>';
  485.     $menu .= '<option value="0" ' . selCurrent($value, 0) . '>' . $lang['no'] . '</option>';
  486.     return $menu;
  487. }
  488. function activated($value){
  489.     global $lang;
  490.     $menu = '';
  491.     $menu .= '<option value="1" ' . selCurrent($value, 1) . '>' . $lang['on'] . '</option>';
  492.     $menu .= '<option value="0" ' . selCurrent($value, 0) . '>' . $lang['off'] . '</option>';
  493.     return $menu;
  494. }
  495. function playerList(){
  496.     global $mysqli, $data;
  497.     $playlist = '';
  498.     if(boomAllow($data['allow_player'])){
  499.         $play_list = $mysqli->query("SELECT * FROM boom_radio_stream WHERE id > 0");
  500.         if($play_list->num_rows > 0){
  501.             while($player = $play_list->fetch_assoc()){
  502.                 $playlist .= '<div class="radio_element list_element" data="' . $player['stream_url'] . '">' . $player['stream_alias'] . '</div>';
  503.             }
  504.         }
  505.     }
  506.     echo $playlist;
  507. }
  508. function adminPlayer($curr, $type){
  509.     global $mysqli, $lang;
  510.     $playlist = '';
  511.     if($type == 1){
  512.         $playlist .= '<option value="0">' . $lang['option_default'] . '</option>';
  513.     }
  514.     if($type == 2){
  515.         $playlist .= '<option value="0">' . $lang['no_default'] . '</option>';
  516.     }
  517.     $play_list = $mysqli->query("SELECT * FROM boom_radio_stream WHERE id > 0");
  518.     if($play_list->num_rows > 0){
  519.         while($player = $play_list->fetch_assoc()){
  520.             $playlist .= '<option  value="' . $player['id'] . '" ' . selCurrent($curr, $player['id']) . '>' . $player['stream_alias'] . '</option>';
  521.         }
  522.     }  
  523.     return $playlist;
  524. }
  525. function getPlayer($room_player){
  526.     global $mysqli, $data;
  527.     $pdata['player_title'] = '';
  528.     $pdata['player_url'] = '';
  529.     if(usePlayer()){
  530.         if($room_player == 0){
  531.             $main_player = $mysqli->query("SELECT * FROM boom_radio_stream WHERE id = '{$data['player_id']}'");
  532.             if($main_player->num_rows > 0){
  533.                 $player  = $main_player->fetch_assoc();
  534.                 $pdata['player_title'] = $player['stream_alias'];
  535.                 $pdata['player_url'] = $player['stream_url'];
  536.             }
  537.         }
  538.         else {
  539.             $get_player = $mysqli->query("SELECT * FROM boom_radio_stream WHERE id = '{$room_player}'");
  540.             if($get_player->num_rows > 0){
  541.                 $player = $get_player->fetch_assoc();
  542.                 $pdata['player_title'] = $player['stream_alias'];
  543.                 $pdata['player_url'] = $player['stream_url'];
  544.             }
  545.             else {
  546.                 $main_player = $mysqli->query("SELECT * FROM boom_radio_stream WHERE id = '{$data['player_id']}'");
  547.                 if($main_player->num_rows > 0){
  548.                     $player = $main_player->fetch_assoc();
  549.                     $pdata['player_title'] = $player['stream_alias'];
  550.                     $pdata['player_url'] = $player['stream_url'];
  551.                 }
  552.             }
  553.         }
  554.     }
  555.     return $pdata;
  556. }
  557. function introLanguage(){
  558.     $language_list = '';
  559.     $dir = glob(__DIR__ . '/language/*' , GLOB_ONLYDIR);
  560.     foreach($dir as $dirnew){
  561.         $language = str_replace(__DIR__ . '/language/', '', $dirnew);
  562.         $language_list .= boomTemplate('element/language', $language);
  563.     }
  564.     return $language_list;
  565. }
  566. function listLanguage($lang){
  567.     $language_list = '';
  568.     $dir = glob(__DIR__ . '/language/*' , GLOB_ONLYDIR);
  569.     foreach($dir as $dirnew){
  570.         $language = str_replace(__DIR__ . '/language/', '', $dirnew);
  571.         $language_list .= '<option ' . selCurrent($lang, $language) . ' value="' . $language . '">' . $language . '</option>';
  572.     }
  573.     return $language_list;
  574. }
  575. function listTheme($th, $type){
  576.     global $lang;
  577.     $theme_list = '';
  578.     if($type == 2){
  579.         $theme_list .= '<option ' . selCurrent($th, 'system') . ' value="system">' . $lang['system_theme'] . '</option>';
  580.     }
  581.     $dir = glob(__DIR__ . '/../css/themes/*' , GLOB_ONLYDIR);
  582.     foreach($dir as $dirnew){
  583.         $theme = str_replace(__DIR__ . '/../css/themes/', '', $dirnew);
  584.         $theme_list .= '<option ' . selCurrent($th, $theme) . ' value="' . $theme . '">' . $theme . '</option>';
  585.     }
  586.     return $theme_list;
  587. }
  588. function checkEmail($email){
  589.     global $mysqli, $data;
  590.     $check_email = $mysqli->query("SELECT * FROM `boom_users` WHERE `user_email` = '$email'");
  591.     if($check_email->num_rows < 1 || $data['allow_email'] == 1){
  592.         return true;
  593.     }
  594. }
  595. function roomActive($w){
  596.     if($w > calWeek(1)){
  597.         return '<i class="fa fa-circle success"></i>';
  598.     }
  599.     else if($w < calWeek(1) && $w > calmonth(1)){
  600.         return '<i class="fa fa-circle warn"></i>';
  601.     }
  602.     else {
  603.         return '<i class="fa fa-circle error"></i>';
  604.     }
  605. }
  606. function boomWarning($message, $type){
  607.     $box['message'] = $message;
  608.     $box['type'] = $type;
  609.     return boomTemplate('element/warning_box', $box);
  610. }
  611. function postNotify($target, $type, $source){
  612.     global $mysqli, $data;
  613.     $mysqli->query("INSERT INTO boom_notification ( notifier, notified, notify_type, notify_date, notify_source, notify_id) VALUE ('{$data['user_id']}', '$target', '$type', '" . time() . "', 'post', '$source')");
  614. }
  615. function regNotify($target, $type, $custom = ''){
  616.     global $mysqli, $data;
  617.     $mysqli->query("INSERT INTO boom_notification ( notifier, notified, notify_type, notify_date, notify_source, notify_id) VALUE ('{$data['user_id']}', '$target', '$type', '" . time() . "', 'notify', '$custom')");
  618. }
  619. function postFriendsNotify($source){
  620.     global $mysqli, $data;
  621.     $values = '';
  622.     $get_friend = $mysqli->query("SELECT target FROM boom_friends WHERE hunter = '{$data['user_id']}' AND status = '3'");
  623.     if($get_friend->num_rows > 0){
  624.         while($friend = $get_friend->fetch_assoc()){
  625.             $values .= "('{$data['user_id']}', '{$friend['target']}', 'add_post', '" . time() . "', 'post', '$source'),";
  626.         }
  627.         $values = trim($values);
  628.         $values = rtrim($values, ',');
  629.         $mysqli->query("INSERT INTO boom_notification ( notifier, notified, notify_type, notify_date, notify_source, notify_id) VALUES $values");
  630.     }
  631. }
  632. function deleteLike($post){
  633.     global $mysqli, $data;
  634.     $mysqli->query("DELETE FROM boom_post_like WHERE like_post = '$post' AND uid = '{$data['user_id']}'");
  635. }
  636. function updateLike($post, $type){
  637.     global $mysqli, $data;
  638.     $now = time();
  639.     $mysqli->query("UPDATE boom_post_like SET like_type = '$type', like_date = '$now' WHERE like_post = '$post' AND uid = '{$data['user_id']}'");
  640. }
  641. function updateNotifyPost($post, $type, $old){
  642.     global $mysqli, $data;
  643.     $now = time();
  644.     $mysqli->query("UPDATE boom_notification SET notify_type = '$type', notify_date = '$now', notify_view = '0' WHERE notify_id = '$post' AND notifier = '{$data['user_id']}' AND notify_type = '$old'");
  645. }
  646. function deleteNotifyPost($post, $type){
  647.     global $mysqli, $data;
  648.     $now = time();
  649.     $mysqli->query("DELETE FROM boom_notification WHERE notify_id = '$post' AND notifier = '{$data['user_id']}' AND notify_type = '$type'");
  650. }
  651. function unlinkAvatar($file){
  652.     if(validAvatar($file)){
  653.         $delete =  __DIR__ . '/../avatar/' . $file;
  654.         if(file_exists($delete)){
  655.             unlink($delete);
  656.         }
  657.     }
  658.     return true;
  659. }
  660. function selCurrent($cur, $val){
  661.     if($cur == $val){
  662.         return 'selected';
  663.     }
  664. }
  665. function getTimezone($zone){
  666.     $list_zone = '';
  667.     require __DIR__ . '/element/timezone.php';
  668.     foreach ($timezone as $line) {
  669.         $list_zone .= '<option value="' . $line . '" ' . selCurrent($zone, $line) . '>' . $line . '</option>';
  670.     }
  671.     return $list_zone;
  672. }
  673. function roomExist($name, $id){
  674.     global $mysqli;
  675.     $check_room = $mysqli->query("SELECT room_name FROM boom_rooms WHERE room_name = '$name' AND room_id != '$id'");
  676.     if($check_room->num_rows > 0){
  677.         return true;
  678.     }
  679. }
  680. function bValid($val){
  681.     if(preg_match('/^[a-f0-9\-]{36}$/', $val)){
  682.         return 1;
  683.     }
  684.     return 0;
  685. }
  686. function insideChat($p){
  687.     if($p == 'chat'){
  688.         return true;
  689.     }
  690. }
  691. function checkName($name){
  692.     if(preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $name)){
  693.         return true;
  694.     }
  695. }
  696. function freeUsername($user, $id){
  697.     global $mysqli;
  698.     $getuser = $mysqli->query("SELECT user_name FROM boom_users WHERE user_name = '$user' AND user_id != '$id'");
  699.     if($getuser->num_rows < 1){
  700.         return true;
  701.     }
  702. }
  703. function validAvatar($av){
  704.     if(stripos($av, 'default') === false){
  705.         return true;
  706.     }
  707. }
  708. function unlinkUpload($path, $file){
  709.     $delete =  __DIR__ . '/../upload/' . $path . '/' . $file;
  710.     if(file_exists($delete)){
  711.         unlink($delete);
  712.     }
  713. }
  714. function deleteFile($path){
  715.     $delete =  __DIR__ . '/../' . $path;
  716.     if(file_exists($delete)){
  717.         unlink($delete);
  718.     }
  719. }
  720. function resetAvatar($u){
  721.     global $mysqli;
  722.     $unlink_tumb = unlinkAvatar($u['user_tumb']);
  723.     if($u['user_bot'] > 0){
  724.         switch($u['user_bot']){
  725.             case 1:
  726.                 $av = 'default_bot.png';
  727.                 break;
  728.             case 9:
  729.                 $av = 'default_system.png';
  730.                 break;
  731.             default:
  732.                 $av = 'default_bot.png';
  733.         }
  734.     }
  735.     else {
  736.         switch($u['user_rank']){
  737.             case 0:
  738.                 $av = 'default_guest.png';
  739.                 break;
  740.             case 1:
  741.                 $av = 'default_avatar.png';
  742.                 break;
  743.             default:
  744.                 $av = 'default_avatar.png';
  745.         }
  746.     }
  747.     $mysqli->query("UPDATE boom_users SET user_tumb = '$av' WHERE user_id = '{$u['user_id']}'");
  748.     return $av;
  749. }
  750. function changeColor($color, $id){
  751.     global $mysqli, $data;
  752.     $user = userDetails($id);
  753.     if(empty($user)){
  754.         return 3;
  755.     }
  756.     if(!boomAllow($data['allow_name_color'])){
  757.         return 0;
  758.     }
  759.     if(isGreater($user['user_rank']) && boomAllow(9) || !notMe($id) && boomAllow(9)){
  760.         if(preg_match('/^bcolor[0-9]{1,2}$/', $color) || $color == 'user'){
  761.             $mysqli->query("UPDATE boom_users SET user_color = '$color' WHERE user_id = '$id'");
  762.             return 1;
  763.         }
  764.         else {
  765.             return 0;
  766.         }
  767.     }
  768.     else {
  769.         return 0;
  770.     }
  771. }
  772. function changeUserRank($target, $rank){
  773.     global $mysqli, $data;
  774.     $user = userDetails($target);
  775.     if(empty($user)){
  776.         return 3;
  777.     }
  778.     if($user['user_rank'] == $rank){
  779.         return 2;
  780.     }
  781.     if(isGreater($user['user_rank']) && isGreater($rank)){
  782.         if($user['user_rank'] > $rank){
  783.             if($user['user_status'] == 6){
  784.                 $mysqli->query("UPDATE boom_users SET user_status = 1 WHERE user_id = '$target'");
  785.             }
  786.         }
  787.         $mysqli->query("DELETE FROM boom_notification WHERE notified = '$target' AND notify_type = 'rank_change'");
  788.         systemNotify($target, 'rank_change', $rank);
  789.         if(isStaff($rank)){
  790.             $mysqli->query("UPDATE boom_users SET room_mute = '0' WHERE user_id = '$target'");
  791.             $mysqli->query("DELETE FROM boom_room_action WHERE action_user = '$target'");
  792.         }
  793.         if($rank < $data['allow_colors']){
  794.             resetColors($user['user_id']);
  795.         }
  796.         $mysqli->query("UPDATE boom_users SET  user_rank = '$rank', user_action = user_action + 1 WHERE user_id = '$target'");
  797.         return 1;
  798.     }
  799.     else {
  800.         return 0;
  801.     }
  802. }
  803. function deleteAccount($id){
  804.     global $mysqli, $data;
  805.     $user = userDetails($id);
  806.     if(empty($user)){
  807.         return 3;
  808.     }
  809.     if(isBot($user['user_bot'])){
  810.         return 0;
  811.     }
  812.     if(boomAllow(10) && isGreater($user['user_rank']) && !userOwner($user) && notMe($user['user_id'])){
  813.         clearUserData($user);
  814.         return 1;
  815.     }
  816.     else {
  817.         return 0;
  818.     }
  819. }
  820. function ignore($id){
  821.     global $mysqli, $data;
  822.     $count_ignore = $mysqli->query("SELECT * FROM boom_ignore WHERE ignored = '$id' AND ignorer = '{$data['user_id']}'");
  823.     if($count_ignore->num_rows < 1){
  824.         $user = userDetails($id);
  825.         if(empty($user)){
  826.             return 3;
  827.         }
  828.         if(!isStaff($user['user_rank']) && !isBot($user['user_bot']) && notMe($user['user_id'])){
  829.             $mysqli->query("INSERT INTO boom_ignore (ignorer, ignored) VALUES ('{$data['user_id']}', '$id')");
  830.             $mysqli->query("DELETE FROM boom_friends WHERE hunter = '{$data['user_id']}' AND target = '$id' OR hunter = '$id' AND target = '{$data['user_id']}'");
  831.             createIgnore();
  832.             return 1;
  833.         }
  834.         else {
  835.             return 0;
  836.         }
  837.     }
  838.     else {
  839.         return 2;
  840.     }
  841. }
  842. function removeIgnore($id){
  843.     global $mysqli, $data;
  844.     $mysqli->query("DELETE FROM boom_ignore WHERE ignorer = '{$data['user_id']}' AND ignored = '$id'");
  845.     createIgnore();
  846.     return 1;
  847. }
  848. function muteAccount($id){
  849.     global $mysqli, $data;
  850.     $user = userDetails($id);
  851.     if(empty($user)){
  852.         return 3;
  853.     }
  854.     if($user['user_mute'] > 0){
  855.         return 2;
  856.     }
  857.     if(isGreater($user['user_rank']) && boomAllow(8) && notMe($user['user_id']) && !isBot($user['user_bot'])){
  858.         $mysqli->query("UPDATE boom_users SET user_mute = '" . time() . "', user_word_mute = 0 WHERE user_id = '$id'");
  859.         clearMuteNotify($id);
  860.         systemNotify($id, 'system_mute', '');
  861.         return 1;
  862.     }
  863.     else {
  864.         return 0;
  865.     }
  866. }
  867. function unmuteAccount($id){
  868.     global $mysqli, $data;
  869.     $user = userDetails($id);
  870.     if(empty($user)){
  871.         return 3;
  872.     }
  873.     if($user['user_mute'] < 1 && $user['user_word_mute'] < 1){
  874.         return 2;
  875.     }
  876.     if(isGreater($user['user_rank']) && boomAllow(8) && notMe($user['user_id']) && !isBot($user['user_bot'])){
  877.         $mysqli->query("UPDATE boom_users SET user_mute = 0, user_word_mute = 0, user_flood = 0 WHERE user_id = '$id'");
  878.         clearMuteNotify($id);
  879.         systemNotify($id, 'system_unmute', '');
  880.         return 1;
  881.     }
  882.     else {
  883.         return 0;
  884.     }
  885. }
  886. function banAccount($id){
  887.     global $mysqli, $data;
  888.     $user = userDetails($id);
  889.     if(empty($user)){
  890.         return 3;
  891.     }
  892.     if($user['user_banned'] > 0){
  893.         return 2;
  894.     }
  895.     if(isGreater($user['user_rank']) && boomAllow(9) && notMe($user['user_id']) && !isBot($user['user_bot'])){
  896.         $mysqli->query("UPDATE boom_users SET user_banned = '" . time() . "', user_action = user_action + 1, user_roomid = '0' WHERE user_id = '$id'");
  897.         $mysqli->query("INSERT INTO boom_banned ( ip , ban_user ) VALUES ('{$user['user_ip']}', '{$user['user_id']}')");
  898.         return 1;
  899.     }
  900.     else {
  901.         return 0;
  902.     }
  903. }
  904. function systemBan($d){
  905.     global $mysqli;
  906.     if(!isStaff($d['user_rank']) && !isBot($d['user_bot'])){
  907.         $mysqli->query("UPDATE boom_users SET user_banned = '" . time() . "', user_action = user_action + 1, user_roomid = '0' WHERE user_id = '{$d['user_id']}'");
  908.         $mysqli->query("INSERT INTO boom_banned ( ip , ban_user ) VALUES ('{$d['user_ip']}', '{$d['user_id']}')");
  909.     }
  910. }
  911. function systemMute($d){
  912.     global $mysqli;
  913.     if(!isStaff($d['user_rank']) && !isBot($d['user_bot'])){
  914.         $mysqli->query("UPDATE boom_users SET user_mute = '" . time() . "', user_word_mute = 0 WHERE user_id = '{$d['user_id']}'");
  915.         clearMuteNotify($d['user_id']);
  916.         systemNotify($d['user_id'], 'system_mute', '');
  917.     }
  918. }
  919. function systemWordMute($d){
  920.     global $data, $mysqli;
  921.     if($d['user_mute'] > 0){
  922.         return false;
  923.     }
  924.     if(!isStaff($d['user_rank']) && !isBot($d['user_bot'])){
  925.         $unmute = calMinutesUp($data['word_delay']);
  926.         $mysqli->query("UPDATE boom_users SET user_word_mute = '" . time() . "' WHERE user_id = '{$d['user_id']}'");
  927.         clearMuteNotify($d['user_id']);
  928.         systemNotify($d['user_id'], 'bad_word', $data['word_delay']);
  929.     }
  930. }
  931. function unbanAccount($id){
  932.     global $mysqli, $data;
  933.     $user = userDetails($id);
  934.     if(empty($user)){
  935.         return 3;
  936.     }
  937.     if($user['user_banned'] < 1){
  938.         return 2;
  939.     }
  940.     if(isGreater($user['user_rank']) && boomAllow(9) && notMe($user['user_id']) && !isBot($user['user_bot'])){
  941.         $mysqli->query("UPDATE boom_users SET user_banned = 0, user_action = user_action + 1 WHERE user_id = '$id'");
  942.         $mysqli->query("DELETE FROM boom_banned WHERE ip = '{$user['user_ip']}' OR ban_user = '{$user['user_id']}'");
  943.         return 1;
  944.     }
  945.     else {
  946.         return 0;
  947.     }
  948. }
  949. function userRoomDetails($id){
  950.     global $mysqli, $data;
  951.     $user = array();
  952.     $getuser = $mysqli->query("SELECT *,
  953.     (SELECT room_rank FROM boom_room_staff WHERE room_staff = '$id' AND room_id = '{$data['user_roomid']}') as room_ranking,
  954.     (SELECT count(*) FROM boom_room_action WHERE action_muted = '1' AND action_user = '$id' AND action_room = '{$data['user_roomid']}') as is_muted,
  955.     (SELECT count(*) FROM boom_room_action WHERE action_blocked = '1' AND action_user = '$id' AND action_room = '{$data['user_roomid']}') as is_blocked,
  956.     (SELECT count(id) FROM boom_friends WHERE target = '{$data['user_id']}' AND hunter = '$id' ) as my_friend,
  957.     (SELECT count(ignore_id) FROM boom_ignore WHERE ignorer = '{$data['user_id']}' AND ignored = '$id' ) as ignored
  958.     FROM boom_users WHERE user_id = '$id'");
  959.     if($getuser->num_rows > 0){
  960.         $user = $getuser->fetch_assoc();
  961.     }
  962.     return $user;
  963. }
  964. function blockRoom($id){
  965.     global $mysqli, $data;
  966.     $user = userRoomDetails($id);
  967.     if(empty($user)){
  968.         return 3;
  969.     }
  970.     if(!canRoomAction($user, 2) || $data['user_roomid'] == 1 || !boomRole(5) && !boomAllow(9)){
  971.         return 0;
  972.     }
  973.     else{
  974.         $mysqli->query("UPDATE boom_users SET user_action = user_action + 1, user_roomid = '0' WHERE user_id = '$id'");
  975.         $checkroom = $mysqli->query("SELECT * FROM boom_room_action WHERE action_room = '{$data['user_roomid']}' AND action_user = '$id'");
  976.         if($checkroom->num_rows > 0){
  977.             $mysqli->query("UPDATE boom_room_action SET action_blocked = '1' WHERE action_user = '$id' AND action_room = '{$data['user_roomid']}'");
  978.         }
  979.         else {
  980.             $mysqli->query("INSERT INTO boom_room_action ( action_room , action_user, action_blocked ) VALUES ('{$data['user_roomid']}', '$id', '1')");
  981.         }
  982.         return 1;
  983.     }
  984. }
  985. function vCheck($val){
  986.     if(preg_match('/^[0-9a-z\-]{36}$/', $val)){
  987.         return true;
  988.     }
  989. }
  990. function muteRoom($id){
  991.     global $mysqli, $data;
  992.     $user = userRoomDetails($id);
  993.     if(empty($user)){
  994.         return 3;
  995.     }
  996.     if(!canRoomAction($user, 2)){
  997.         return 0;
  998.     }
  999.     else {
  1000.         $mysqli->query("UPDATE boom_users SET room_mute = 1 WHERE user_id = '$id' AND user_roomid = '{$data['user_roomid']}'");
  1001.         $checkroom = $mysqli->query("SELECT * FROM boom_room_action WHERE action_room = '{$data['user_roomid']}' AND action_user = '$id'");
  1002.         if($checkroom->num_rows > 0){
  1003.             $mysqli->query("UPDATE boom_room_action SET action_muted = '1' WHERE action_user = '$id' AND action_room = '{$data['user_roomid']}'");
  1004.         }
  1005.         else {
  1006.             $mysqli->query("INSERT INTO boom_room_action ( action_room , action_user, action_muted ) VALUES ('{$data['user_roomid']}', '$id', '1')");
  1007.         }
  1008.         return 1;
  1009.     }
  1010. }
  1011. function unmuteRoom($id){
  1012.     global $mysqli, $data;
  1013.     $user = userRoomDetails($id);
  1014.     if(empty($user)){
  1015.         return 3;
  1016.     }
  1017.     if(!canRoomAction($user, 2)){
  1018.         return 0;
  1019.     }
  1020.     else{
  1021.         $mysqli->query("UPDATE boom_users SET room_mute = 0 WHERE user_id = '$id' AND user_roomid = '{$data['user_roomid']}'");
  1022.         $mysqli->query("DELETE FROM boom_room_action WHERE action_room = '{$data['user_roomid']}' AND action_user = '$id' AND action_muted = '1' AND action_blocked = '0'");
  1023.         $mysqli->query("UPDATE boom_room_action SET action_muted = '0' WHERE action_room = '{$data['user_roomid']}' AND action_user = '$id' AND action_muted = '1'");
  1024.         return 1;
  1025.     }
  1026. }
  1027. function unblockRoom($id){
  1028.     global $mysqli, $data;
  1029.     $user = userRoomDetails($id);
  1030.     if(empty($user)){
  1031.         return 3;
  1032.     }
  1033.     if(!canRoomAction($user, 2) || !boomRole(5) && !boomAllow(9)){
  1034.         return 0;
  1035.     }
  1036.     else {
  1037.         $mysqli->query("DELETE FROM boom_room_action WHERE action_room = '{$data['user_roomid']}' AND action_user = '$id' AND action_blocked = '1' AND action_muted = '0'");
  1038.         $mysqli->query("UPDATE boom_room_action SET action_blocked = '0' WHERE action_room = '{$data['user_roomid']}' AND action_user = '$id' AND action_blocked = '1'");
  1039.         return 1;
  1040.     }
  1041. }
  1042. function verifyUser($id){
  1043.     global $mysqli, $data;
  1044.     $user = userDetails($id);
  1045.     if(empty($user)){
  1046.         return 3;
  1047.     }
  1048.     if($user['verified'] == 1){
  1049.         return 2;
  1050.     }
  1051.     if(boomAllow(9) && isGreater($user['user_rank']) || boomAllow(9) && !notme($user['user_id'])){
  1052.         $mysqli->query("UPDATE boom_users SET verified = '1', user_verify = 0, email_count = '0', user_action = user_action + 1 WHERE user_id = '$id'");
  1053.         return 1;
  1054.     }
  1055.     else {
  1056.         return 0;
  1057.     }
  1058. }
  1059. function canRoomAction($user, $type = 1){
  1060.     global $mysqli, $data;
  1061.     if(empty($user)){
  1062.         return false;
  1063.     }
  1064.     if(!notMe($user['user_id'])){
  1065.         return false;
  1066.     }
  1067.     if(!boomRole(4) && !boomAllow(9)){
  1068.         return false;
  1069.     }
  1070.     if(isStaff($user['user_rank']) || isBot($user['user_bot'])){
  1071.         return false;
  1072.     }
  1073.     if(!betterRole($user['room_ranking']) && !boomAllow(9)){
  1074.         return false;
  1075.     }
  1076.     if($type == 2 && roomStaff($user['room_ranking'])){
  1077.         return false;
  1078.     }
  1079.     return true;
  1080. }
  1081. function roomStaff($rank){
  1082.     if($rank > 3){
  1083.         return true;
  1084.     }
  1085. }
  1086. function boomDat($val, $res = 0){
  1087.     if($val != '' || !empty($val)){
  1088.         $res = 1;
  1089.     }
  1090.     return $res;
  1091. }
  1092. function betterRole($rank){
  1093.     global $data;
  1094.     if($data['user_role'] > $rank || boomAllow(9)){
  1095.         return true;
  1096.     }
  1097. }
  1098. function checkMod($id){
  1099.     global $data, $mysqli;
  1100.     $checkmod = $mysqli->query("SELECT * FROM boom_room_staff WHERE room_id = '{$data['user_roomid']}' AND room_staff = '$id'");
  1101.     if($checkmod->num_rows < 1){
  1102.         return true;
  1103.     }
  1104. }
  1105. function listAction($user){
  1106.     global $lang, $data;
  1107.     $id = $user['user_id'];
  1108.     $menu = '<option value="no_action">' . $lang['action_none'] . '</option>';
  1109.     if(boomAllow(9)){
  1110.         $menu .= '<option value="verify_account">' . $lang['action_verify'] . '</option>';
  1111.     }
  1112.     if(boomAllow(8) && notMe($id)){
  1113.         $menu .= '<option value="unmute">' . $lang['unmute'] . '</option>';
  1114.     }
  1115.     if(boomAllow(8) && notMe($id)){
  1116.         $menu .= '<option value="mute">' . $lang['mute'] . '</option>';
  1117.     }
  1118.     if(boomAllow(9) && notMe($id)){
  1119.         $menu .= '<option value="unban">' . $lang['unban'] . '</option>';
  1120.     }
  1121.     if(boomAllow(9) && notMe($id)){
  1122.         $menu .= '<option value="ban">' . $lang['ban'] . '</option>';
  1123.     }
  1124.     return $menu;
  1125. }
  1126. function listRoomAction($user){
  1127.     global $lang, $data;
  1128.     $id = $user['user_id'];
  1129.     $menu = '<option value="no_action">' . $lang['action_none'] . '</option>';
  1130.     if(boomAllow(9) || boomRole(4)){
  1131.         $menu .= '<option value="room_unmute">' . $lang['unmute'] . '</option>';
  1132.         $menu .= '<option value="room_mute">' . $lang['mute'] . '</option>';
  1133.     }
  1134.     if(!isMainRoom()){
  1135.         if(boomAllow(9) || boomRole(5)){
  1136.             $menu .= '<option value="room_block">' . $lang['room_block'] . '</option>';
  1137.         }
  1138.     }
  1139.     return $menu;
  1140. }
  1141. function addonsLang($name){
  1142.     global $data;
  1143.     $load_lang = __DIR__ . '/../addons/' . $name . '/language/' . $data['user_language'] . '.php';
  1144.     if(file_exists($load_lang)){
  1145.         return $load_lang;
  1146.     }
  1147.     else {
  1148.         return __DIR__ . '/../addons/' . $name . '/language/Default.php';
  1149.     }
  1150. }
  1151. function addonsLangCron($name){
  1152.     global $data;
  1153.     $load_lang = __DIR__ . '/../addons/' . $name . '/language/' . $data['language'] . '.php';
  1154.     if(file_exists($load_lang)){
  1155.         return $load_lang;
  1156.     }
  1157.     else {
  1158.         return __DIR__ . '/../addons/' . $name . '/language/Default.php';
  1159.     }
  1160. }
  1161. function addonsData($name, $extra = ''){
  1162.     global $mysqli;
  1163.     $addons = array();
  1164.     if($extra == ''){
  1165.         $getsettings = $mysqli->query("SELECT * FROM boom_addons WHERE addons = '$name'");
  1166.     }
  1167.     else {
  1168.         $getsettings = $mysqli->query("SELECT boom_addons.*, $extra.* FROM boom_addons, $extra WHERE addons = '$name' AND $extra.id = 1");
  1169.     }
  1170.     if($getsettings->num_rows > 0){
  1171.         $addons = $getsettings->fetch_assoc();
  1172.     }
  1173.     return $addons;
  1174. }
  1175. function randomPass(){
  1176.     $text = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890++--@@@___';
  1177.     $text = substr(str_shuffle($text), 0, 10);
  1178.     return encrypt($text);
  1179. }
  1180. function alphaClear($s){
  1181.     return preg_replace('@[a-zA-Z-]@', '', $s);
  1182. }
  1183. function numsClear($s){
  1184.     return preg_replace('@[0-9-]@', '', $s);
  1185. }
  1186. function isMainRoom(){
  1187.     global $data;
  1188.     if($data['user_roomid'] == 1){
  1189.         return true;
  1190.     }
  1191. }
  1192. function elementTitle($icon, $title){
  1193.     $top_it = array(
  1194.         'icon'=> $icon,
  1195.         'title'=> $title
  1196.     );
  1197.     return boomTemplate('element/page_top', $top_it);
  1198. }
  1199. function boxTitle($icon, $title){
  1200.     $top_it = array(
  1201.         'icon'=> $icon,
  1202.         'title'=> $title
  1203.     );
  1204.     return boomTemplate('element/box_title', $top_it);
  1205. }
  1206. function findFriend($user){
  1207.     global $mysqli, $lang;
  1208.     $friend_list = '';
  1209.     $find_friend = $mysqli->query("SELECT boom_users.user_name, boom_users.user_id, boom_users.user_tumb, boom_users.user_color, boom_users.last_action, boom_users.user_rank, boom_friends.* FROM boom_users, boom_friends
  1210.     WHERE hunter = '{$user['user_id']}' AND status = '3' AND target = boom_users.user_id ORDER BY last_action DESC, user_name ASC LIMIT 50");
  1211.     if($find_friend->num_rows > 0){
  1212.         while($find = $find_friend->fetch_assoc()){
  1213.             $friend_list .= boomTemplate('element/user_square', $find);
  1214.         }
  1215.     }
  1216.     else {
  1217.         $friend_list .= emptyZone($lang['no_data']);
  1218.     }
  1219.     return $friend_list;
  1220. }
  1221. function myFriend(){
  1222.     global $mysqli, $lang, $data;
  1223.     $friend_list = '';
  1224.     $find_friend = $mysqli->query("SELECT boom_users.user_name, boom_users.user_id, boom_users.user_tumb, boom_users.user_color, boom_users.last_action, boom_users.user_rank, boom_friends.* FROM boom_users, boom_friends
  1225.     WHERE hunter = '{$data['user_id']}' AND status > 1 AND target = boom_users.user_id ORDER BY status DESC, user_name ASC");
  1226.     if($find_friend->num_rows > 0){
  1227.         while($find = $find_friend->fetch_assoc()){
  1228.             $friend_list .= boomTemplate('element/friend_element', $find);
  1229.         }
  1230.     }
  1231.     else {
  1232.         $friend_list .= emptyZone($lang['no_friend']);
  1233.     }
  1234.     return '<div class="ulist_container">' . $friend_list . '</div>';
  1235. }
  1236. function myIgnore(){
  1237.     global $data, $mysqli, $lang;
  1238.     $ignore_list = '';
  1239.     $find_ignore = $mysqli->query("SELECT boom_users.user_name, boom_users.user_id, boom_users.user_tumb, boom_users.user_color, boom_users.last_action, boom_users.user_rank, boom_ignore.* FROM boom_users, boom_ignore
  1240.     WHERE ignorer = '{$data['user_id']}' AND ignored = boom_users.user_id ORDER BY boom_users.user_name ASC");
  1241.     if($find_ignore->num_rows > 0){
  1242.         while($find = $find_ignore->fetch_assoc()){
  1243.         $ignore_list .= boomTemplate('element/ignore_element', $find);
  1244.         }
  1245.     }
  1246.     else {
  1247.         $ignore_list .= emptyZone($lang['no_ignore']);
  1248.     }
  1249.     return '<div class="ulist_container">' . $ignore_list . '</div>';
  1250. }
  1251. function showPost($secret, $postid){
  1252.     global $data, $mysqli, $lang;
  1253.     $wall_content = '';
  1254.     $wall_post = $mysqli->query("SELECT boom_post.*, boom_users.user_name, boom_users.user_id, boom_users.user_rank, boom_users.user_color, boom_users.user_tumb,
  1255.     (SELECT count( parent_id ) FROM boom_post_reply WHERE parent_id = boom_post.post_id ) as reply_count,
  1256.     (1) as post_count,
  1257.     (SELECT like_type FROM boom_post_like WHERE uid = '{$data['user_id']}' AND like_post = boom_post.post_id) as liked,
  1258.     (SELECT count(id) FROM boom_post_like WHERE like_post = boom_post.post_id AND like_type = 1 ) as like_count,
  1259.     (SELECT count(id) FROM boom_post_like WHERE like_post = boom_post.post_id AND like_type = 2 ) as unlike_count
  1260.     FROM  boom_post, boom_users
  1261.     WHERE (boom_post.post_user = boom_users.user_id AND secret = '$secret' AND post_id = '$postid')
  1262.     ORDER BY boom_post.post_actual DESC LIMIT 1");
  1263.  
  1264.     if($wall_post->num_rows > 0){
  1265.         while ($wall = $wall_post->fetch_assoc()){
  1266.             $post_count = $wall['post_count'];
  1267.             $wall_content .= boomTemplate('element/wall_post',$wall);
  1268.         }
  1269.     }
  1270.     else {
  1271.         $wall_content .= emptyZone($lang['wall_empty']);
  1272.     }
  1273.     return $wall_content;
  1274. }
  1275. function getNews(){
  1276.     global $data, $mysqli, $lang;
  1277.     $news_content = '';
  1278.     $news_add = '';
  1279.     $t = time();
  1280.  
  1281.     if(boomAllow(10)){
  1282.         $news_add = boomTemplate('element/news_input');
  1283.     }
  1284.     $get_news = $mysqli->query("SELECT boom_news.*, boom_users.user_name, boom_users.user_id,  boom_users.user_rank, boom_users.user_color, boom_users.user_tumb
  1285.     FROM boom_news, boom_users
  1286.     WHERE boom_news.news_poster = boom_users.user_id
  1287.     ORDER BY news_date DESC LIMIT 16");
  1288.  
  1289.     if($get_news->num_rows > 0){
  1290.         while ($news = $get_news->fetch_assoc()){
  1291.             $news_content .= boomTemplate('element/news', $news);
  1292.         }
  1293.         $mysqli->query("UPDATE boom_users SET user_news = '$t' WHERE user_id = '{$data['user_id']}'");
  1294.     }
  1295.     else {
  1296.         $news_content .= emptyZone($lang['no_news']);
  1297.     }
  1298.     return  $news_add . '<div id="container_news">' . $news_content . '</div>';
  1299.    
  1300. }
  1301. function thisNews($id){
  1302.     global $mysqli, $lang;
  1303.     $news_content = '';
  1304.     $get_news = $mysqli->query("SELECT boom_news.*, boom_users.user_name, boom_users.user_id,  boom_users.user_rank, boom_users.user_color, boom_users.user_tumb
  1305.     FROM boom_news, boom_users
  1306.     WHERE boom_news.news_poster = boom_users.user_id AND boom_news.id = '$id'
  1307.     ORDER BY news_date DESC LIMIT 1");
  1308.     while ($news = $get_news->fetch_assoc()){
  1309.         $news_content .= boomTemplate('element/news', $news);
  1310.     }
  1311.     return $news_content;
  1312. }
  1313. function wordFilter($text, $type = 0){
  1314.     global $mysqli, $data, $lang;
  1315.     $text = trimContent($text);
  1316.     $text_trim = mb_strtolower(str_replace(array(' '), '', $text));
  1317.     $take_action = 0;
  1318.     $spam_action = 0;
  1319.     if(!boomAllow(10)){
  1320.         $words = $mysqli->query("SELECT * FROM `boom_filter` WHERE word_type = 'word' OR word_type = 'spam'");
  1321.         if ($words->num_rows > 0){
  1322.             while($filter = $words->fetch_assoc()){
  1323.                 if($filter['word_type'] == 'word'){
  1324.                     if(stripos($text, $filter['word']) !== false){
  1325.                         $text = str_ireplace($filter['word'], '****',$text);
  1326.                         $take_action++;
  1327.                     }
  1328.                 }
  1329.                 else if($filter['word_type'] == 'spam'){
  1330.                     if(stripos($text_trim, $filter['word']) !== false){
  1331.                         $spam_action++;
  1332.                     }
  1333.                 }
  1334.             }
  1335.         }
  1336.         if($take_action > 0 && $type == 1 && $spam_action == 0){
  1337.             switch($data['word_action']){
  1338.                 case 2:
  1339.                     systemWordMute($data);
  1340.                     break;
  1341.             }
  1342.         }
  1343.         if($spam_action > 0){
  1344.             $text = '<div class="system_text">%spam%</div>';
  1345.             switch($data['spam_action']){
  1346.                 case 1:
  1347.                     systemMute($data);
  1348.                     break;
  1349.                 case 2:
  1350.                     systemBan($data);
  1351.                     break;
  1352.             }
  1353.         }
  1354.     }
  1355.     return $text;
  1356. }
  1357. function introActive($amount){
  1358.     global $mysqli;
  1359.     $find_last = $mysqli->query("SELECT user_tumb, user_name FROM boom_users WHERE user_bot = 0 AND user_rank > 0 ORDER BY last_action DESC LIMIT $amount");
  1360.     $active = '';
  1361.     if($find_last->num_rows > 0){
  1362.         while ($last = $find_last->fetch_assoc()){
  1363.             $active .= boomTemplate('element/active_intro', $last);
  1364.         }
  1365.     }
  1366.     return $active;
  1367. }
  1368. function embedActive($amount){
  1369.     global $mysqli;
  1370.     $find_last = $mysqli->query("SELECT user_tumb, user_name FROM boom_users WHERE user_bot = 0 AND user_rank > 0 ORDER BY last_action DESC LIMIT $amount");
  1371.     $active = '';
  1372.     if($find_last->num_rows > 0){
  1373.         while ($last = $find_last->fetch_assoc()){
  1374.             $active .= boomTemplate('element/active_embed', $last);
  1375.         }
  1376.     }
  1377.     return $active;
  1378. }
  1379. function isImage($ext){
  1380.     $ext = strtolower($ext);
  1381.     $img = array( 'image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg', 'image/x-png', 'image/png', 'image/JPG' );
  1382.     $img_ext = array( 'gif', 'jpeg', 'jpg', 'JPG', 'PNG', 'png', 'x-png', 'pjpeg' );
  1383.     if( in_array($_FILES["file"]["type"], $img) && in_array($ext, $img_ext)){
  1384.         return true;
  1385.     }
  1386. }
  1387. function isFile($ext){
  1388.     $ext = strtolower($ext);
  1389.     $f = array( 'application/zip', 'application/x-zip-compressed', 'application/pdf', 'application/octet-stream', 'application/x-zip-compressed' );
  1390.     $f_ext = array( 'zip', 'pdf', 'ZIP', 'PDF' );
  1391.     if( in_array($_FILES["file"]["type"], $f) && in_array($ext, $f_ext)){
  1392.         return true;
  1393.     }
  1394. }
  1395. function isMusic($ext){
  1396.     $ext = strtolower($ext);
  1397.     $f = array( 'audio/mpeg', 'audio/mp3', 'audio/x-mpeg', 'audio/x-mp3', 'audio/mpeg3',
  1398.     'audio/x-mpeg3', 'audio/mpg', 'audio/x-mpg', 'audio/x-mpegaudio' );
  1399.     $f_ext = array( 'mp3' );
  1400.     if( in_array($_FILES["file"]["type"], $f) && in_array($ext, $f_ext)){
  1401.         return true;
  1402.     }
  1403. }
  1404. function fileError($type = 1){
  1405.     global $data;
  1406.     $size = $data['file_weight'];
  1407.     if($type == 2){
  1408.         $size = $data['max_avatar'];
  1409.     }
  1410.     if($_FILES["file"]["error"] > 0 || (($_FILES["file"]["size"] / 1024)/1024) > $size ){
  1411.         return true;
  1412.     }
  1413. }
  1414. function targetExist($id){
  1415.     global $data, $mysqli;
  1416.     $get_target = $mysqli->query("SELECT user_id FROM boom_users WHERE user_id = '$id'");
  1417.     if($get_target->num_rows > 0){
  1418.         return true;
  1419.     }
  1420. }
  1421. function removeRelatedFile($id, $zone){
  1422.     global $mysqli;
  1423.     $get_file = $mysqli->query("SELECT * FROM boom_upload WHERE relative_post = '$id' AND file_zone = '$zone'");
  1424.     if($get_file->num_rows > 0){
  1425.         while ($file = $get_file->fetch_assoc()){
  1426.             unlinkUpload($zone, $file['file_name']);
  1427.         }
  1428.         $mysqli->query("DELETE FROM boom_upload WHERE relative_post = '$id' AND file_zone = '$zone'");
  1429.     }  
  1430. }
  1431. function getRoomMuted($r){
  1432.     global $mysqli, $lang;
  1433.     $muted_list = '';
  1434.     $get_muted = $mysqli->query("SELECT boom_room_action.*, boom_users.user_name, boom_users.user_color, boom_users.user_tumb, boom_users.user_id
  1435.                 FROM boom_room_action
  1436.                 LEFT JOIN boom_users
  1437.                 ON boom_room_action.action_user = boom_users.user_id
  1438.                 WHERE action_room = '$r' AND action_muted > 0
  1439.                 ORDER BY  boom_users.user_name ASC");
  1440.     if($get_muted->num_rows > 0){
  1441.         while($muted = $get_muted->fetch_assoc()){
  1442.             $muted['action'] = 'delete_room_muted';
  1443.             $muted_list .= boomTemplate('element/room_user', $muted);
  1444.         }
  1445.     }
  1446.     else{
  1447.         $muted_list .= emptyZone($lang['no_data']);
  1448.     }
  1449.     return '<div class="staff_list">' . $muted_list . '</div>';
  1450. }
  1451. function getRoomBlocked($r){
  1452.     global $mysqli, $lang;
  1453.     $blocked_list = '';
  1454.     $get_blocked = $mysqli->query("SELECT boom_room_action.*, boom_users.user_name, boom_users.user_color, boom_users.user_tumb, boom_users.user_id
  1455.                 FROM boom_room_action
  1456.                 LEFT JOIN boom_users
  1457.                 ON boom_room_action.action_user = boom_users.user_id
  1458.                 WHERE action_room = '$r' AND action_blocked > 0
  1459.                 ORDER BY  boom_users.user_name ASC");
  1460.     if($get_blocked->num_rows > 0){
  1461.         while($blocked = $get_blocked->fetch_assoc()){
  1462.             $blocked['action'] = 'delete_room_blocked';
  1463.             $blocked_list .= boomTemplate('element/room_user', $blocked);
  1464.         }
  1465.     }
  1466.     else{
  1467.         $blocked_list .= emptyZone($lang['no_data']);
  1468.     }
  1469.     return '<div class="staff_list">' . $blocked_list . '</div>';
  1470. }
  1471. function getRoomAdmin($r){
  1472.     global $mysqli, $lang;
  1473.     $admin_list = '';
  1474.     $get_admin = $mysqli->query("SELECT boom_room_staff.*, boom_users.user_name, boom_users.user_color, boom_users.user_tumb, boom_users.user_id
  1475.                     FROM boom_room_staff
  1476.                     LEFT JOIN boom_users
  1477.                     ON boom_room_staff.room_staff = boom_users.user_id
  1478.                     WHERE room_id = '$r' AND room_rank = 5
  1479.                     ORDER BY  boom_users.user_name ASC");
  1480.     if($get_admin->num_rows > 0){
  1481.         while($admin = $get_admin->fetch_assoc()){
  1482.             $admin['action'] = 'delete_room_admin';
  1483.             $admin_list .= boomTemplate('element/room_user', $admin);
  1484.         }
  1485.     }
  1486.     else{
  1487.         $admin_list .= emptyZone($lang['no_data']);
  1488.     }
  1489.     return '<div class="staff_list">' . $admin_list . '</div>';
  1490. }
  1491. function getRoomMod($r){
  1492.     global $mysqli, $lang;
  1493.     $mod_list = '';
  1494.     $get_mod = $mysqli->query("SELECT boom_room_staff.*, boom_users.user_name, boom_users.user_color, boom_users.user_tumb, boom_users.user_id
  1495.                     FROM boom_room_staff
  1496.                     LEFT JOIN boom_users
  1497.                     ON boom_room_staff.room_staff = boom_users.user_id
  1498.                     WHERE room_id = '$r' AND room_rank = 4
  1499.                     ORDER BY  boom_users.user_name ASC");
  1500.     if($get_mod->num_rows > 0){
  1501.         while($mod = $get_mod->fetch_assoc()){
  1502.             $mod['action'] = 'delete_room_moderator';
  1503.             $mod_list .= boomTemplate('element/room_user', $mod);
  1504.         }
  1505.     }
  1506.     else{
  1507.         $mod_list .= emptyZone($lang['no_data']);
  1508.     }
  1509.     return '<div class="staff_list">' . $mod_list . '</div>';
  1510. }
  1511. function sendEmail($type, $to, $item = ''){
  1512.     global $data;
  1513.     require __DIR__ . '/mailer/PHPMailerAutoload.php';
  1514.     $mail = new PHPMailer;
  1515.     if(empty($type) || empty($to)){
  1516.         return 0;
  1517.     }
  1518.     require __DIR__ . '/language/' . $to['user_language'] . '/mail.php';
  1519.     $email['signature'] = nl2br(str_replace('%site%', $data['title'], $bmail['signature']));
  1520.     $email['content'] = nl2br(str_replace(array('%user%', '%data%', '%link%'), array($to['user_name'], $item, '<a target="_BLANK" href="' . $item . '">' . $item . '</a>'), $bmail[$type . '_content']));
  1521.     $template = boomTemplate('element/mail_template', $email);
  1522.  
  1523.     if($data['mail_type'] == 'smtp'){
  1524.         $mail->isSMTP();
  1525.         $mail->Host = $data['smtp_host'];
  1526.         $mail->SMTPAuth = true;
  1527.         $mail->Username = $data['smtp_username'];
  1528.         $mail->Password = $data['smtp_password'];
  1529.         $mail->SMTPSecure = $data['smtp_type'];
  1530.         $mail->Port = $data['smtp_port'];  
  1531.     }
  1532.     else {
  1533.         $mail->IsMail();
  1534.     }
  1535.     $mail->setFrom($data['site_email'], $data['email_from']);
  1536.     $mail->addAddress($to['user_email']);
  1537.     $mail->isHTML(true);
  1538.     $mail->CharSet = 'utf-8';
  1539.     $mail->Subject = $bmail[$type . '_title'];
  1540.     $mail->MsgHTML($template);
  1541.     if(!$mail->send()) {
  1542.        return 0;
  1543.     }
  1544.     else {
  1545.         return 1;
  1546.     }
  1547. }
  1548. function resetUserPass($user){
  1549.     global $mysqli;
  1550.     $temp_pass = tempPass();
  1551.     $temp_encrypt = encrypt($temp_pass);
  1552.     $test_reset = sendEmail('recovery', $user, $temp_pass);
  1553.     if($test_reset == 1){
  1554.         $mysqli->query("UPDATE boom_users SET temp_pass = '$temp_encrypt', temp_date = '" . time() . "' WHERE user_id = '{$user['user_id']}'");
  1555.     }
  1556.     return $test_reset;
  1557. }
  1558. function sendActivation($user){
  1559.     global $mysqli, $data;
  1560.     $key = $data['valid_key'];
  1561.     if(!is_numeric($data['valid_key']) || $data['valid_key'] == ''){
  1562.         $key = genCode();
  1563.     }
  1564.     $send_mail = sendEmail('resend_activation', $user, $key);
  1565.     if($send_mail == 1){
  1566.         $mysqli->query("UPDATE boom_users SET valid_key = '$key', email_count = email_count + 1 WHERE user_id = '{$user['user_id']}'");
  1567.     }
  1568.     return $send_mail;
  1569. }
  1570. function okVerify(){
  1571.     global $data;
  1572.     if($data['email_count'] <= 2){
  1573.         return true;
  1574.     }
  1575. }
  1576. function checkCode($code){
  1577.     global $data, $mysqli;
  1578.     if($code == $data['valid_key'] && $data['valid_key'] != ''){
  1579.         $mysqli->query("UPDATE boom_users SET verified = '1', user_verify = '0', valid_key = '', email_count = '0' WHERE user_id = '{$data['user_id']}'");
  1580.         return 1;
  1581.     }
  1582.     else {
  1583.         return 0;
  1584.     }
  1585. }
  1586. function getCritera($c){
  1587.     switch($c){
  1588.         case 1:
  1589.             return "user_rank = '0' AND user_bot = 0";
  1590.         case 2:
  1591.             return "user_rank = '1' AND user_bot = 0";
  1592.         case 3:
  1593.             return "user_rank = '2' AND user_bot = 0";
  1594.         case 4:
  1595.             return "user_rank = '8' AND user_bot = 0";
  1596.         case 5:
  1597.             return "user_rank = '9' AND user_bot = 0";
  1598.         case 6:
  1599.             return "user_bot > 0";
  1600.         case 7:
  1601.             return "user_mute > 0";
  1602.         case 8:
  1603.             return "user_banned > 0";
  1604.         default:
  1605.             return "user_rank < 0";
  1606.     }  
  1607. }
  1608. function cleanSearch($search){
  1609.     return str_replace('%', '|', $search);
  1610. }
  1611. function nameDetails($name){
  1612.     global $mysqli, $data;
  1613.     $user = array();
  1614.     $getuser = $mysqli->query("SELECT * FROM boom_users WHERE user_name = '$name'");
  1615.     if($getuser->num_rows > 0){
  1616.         $user = $getuser->fetch_assoc();
  1617.     }
  1618.     return $user;
  1619. }
  1620. function resetColors($id){
  1621.     global $mysqli;
  1622.     $mysqli->query("UPDATE boom_users SET bccolor = '', bcbold = '' WHERE user_id = '$id'");
  1623. }
  1624. function boomUsername($name){
  1625.     global $mysqli, $boom_config;
  1626.     $user = nameDetails($name);
  1627.     if(empty($user)){
  1628.         return true;
  1629.     }
  1630.     else {
  1631.         if(isGuest($user['user_rank']) && $user['last_action'] < calMinutes($boom_config['guest_delay'])){
  1632.             softGuestDelete($user);
  1633.             return true;
  1634.         }
  1635.     }
  1636. }
  1637. function checkFlood(){
  1638.     global $boom_config;
  1639.     if(boomAllow(8)){
  1640.         return false;
  1641.     }
  1642.     if(isset($_SESSION[$boom_config['prefix'] . 'last'], $_SESSION[$boom_config['prefix'] . 'flood'])){
  1643.         if($_SESSION[$boom_config['prefix'] . 'last'] >= time() - 2){
  1644.             $_SESSION[$boom_config['prefix'] . 'last'] = time();
  1645.             $_SESSION[$boom_config['prefix'] . 'flood'] = $_SESSION[$boom_config['prefix'] . 'flood'] + 1;
  1646.             $flood = $_SESSION[$boom_config['prefix'] . 'flood'];
  1647.             if($flood < $boom_config['flood_limit']){
  1648.                 return false;
  1649.             }
  1650.             else {
  1651.                 updateMute();
  1652.                 return true;
  1653.             }
  1654.         }
  1655.         else {
  1656.             $_SESSION[$boom_config['prefix'] . 'last'] = time();
  1657.             $_SESSION[$boom_config['prefix'] . 'flood'] = 0;
  1658.             return false;
  1659.         }
  1660.     }
  1661.     else {
  1662.         $_SESSION[$boom_config['prefix'] . 'last'] = time();
  1663.         $_SESSION[$boom_config['prefix'] . 'flood'] = 0;
  1664.         return false;
  1665.     }
  1666. }
  1667. function alterLogin(){
  1668.     global $data;
  1669.     if($data['social_login'] == 1){
  1670.         return true;
  1671.     }
  1672. }
  1673. function registration(){
  1674.     global $data;
  1675.     if($data['registration'] == 1){
  1676.         return true;
  1677.     }
  1678. }
  1679. function updateMute(){
  1680.     global $data, $mysqli, $boom_config;
  1681.     $mysqli->query("UPDATE boom_users SET user_flood = user_flood + 1 WHERE user_id = '{$data['user_id']}'");
  1682.     $data['user_flood'] = $data['user_flood'] + 1;
  1683.     if($data['user_flood'] > 3){
  1684.         systemMute($data);
  1685.         clearMuteNotify($data['user_id']);
  1686.         systemNotify($data['user_id'], 'flood_abuse', '');
  1687.     }
  1688.     $_SESSION[$boom_config['prefix'] . 'last'] = time();
  1689.     $_SESSION[$boom_config['prefix'] . 'flood'] = 0;
  1690. }
  1691. function roomSelect($r){
  1692.     global $mysqli;
  1693.     $menu = '';
  1694.     $get_rooms = $mysqli->query("SELECT * FROM boom_rooms WHERE room_id > 0");
  1695.     while($room = $get_rooms->fetch_assoc()){
  1696.         $menu .= '<option value="' . $room['room_id'] . '" ' . selCurrent($r, $room['room_id']) . '>' . $room['room_name'] . '</option>';
  1697.     }
  1698.     return $menu;
  1699. }
  1700. function getChatPath(){
  1701.     return basename(dirname(__DIR__));
  1702. }
  1703. function canVerify(){
  1704.     global $data;
  1705.     if($data['user_rank'] >= $data['allow_verify']){
  1706.         return true;
  1707.     }
  1708. }
  1709. function deleteFiles($target) {
  1710.     if(is_dir($target)){
  1711.         $files = glob( $target . '*', GLOB_MARK);
  1712.         foreach($files as $file){
  1713.             deleteFiles($file);      
  1714.         }
  1715.         rmdir( $target );
  1716.     }
  1717.     elseif(is_file($target)){
  1718.         unlink($target);  
  1719.     }
  1720. }
  1721. function getSocialData(){
  1722.     global $mysqli;
  1723.     $get_social = $mysqli->query("SELECT * FROM boom_social_login WHERE id = 1");
  1724.     $social_data = $get_social->fetch_assoc();
  1725.     return $social_data;
  1726. }
  1727. function boomEmbed(){
  1728.     if(isset($_GET['embed'])){
  1729.         return true;
  1730.     }
  1731. }
  1732. function boomInsertUser($pro){
  1733.     global $mysqli, $data, $boom_config;
  1734.     $user = array();
  1735.     if(!isset($pro['name'], $pro['password'], $pro['email'])){
  1736.         return $user;
  1737.     }
  1738.     $def = array(
  1739.         'gender' => 0,
  1740.         'age' => 0,
  1741.         'ip' => '0.0.0.0',
  1742.         'language' => $data['language'],
  1743.         'avatar' => 'default_avatar.png',
  1744.         'color' => 'user',
  1745.         'rank' => 1,
  1746.         'verified' => 0,
  1747.         'verify' => 0,
  1748.         'cookie' => 1,
  1749.     );
  1750.     $u = array_merge($def, $pro);
  1751.     $mysqli->query("INSERT INTO `boom_users`
  1752.     ( user_name, user_password, user_ip, user_email, user_rank, user_roomid, user_theme,
  1753.     user_join, last_action, user_language, user_timezone, verified, user_verify, user_color,
  1754.     user_sex, user_age, user_news, user_tumb )
  1755.     VALUES
  1756.     ('{$u['name']}', '{$u['password']}', '{$u['ip']}', '{$u['email']}', '{$u['rank']}', '0', 'system',
  1757.     '" . time() . "', '" . time() . "', '{$u['language']}', '{$data['timezone']}', '{$u['verified']}', '{$u['verify']}', '{$u['color']}',
  1758.     '{$u['gender']}', '{$u['age']}', '" . time() . "', '{$u['avatar']}')");
  1759.    
  1760.     $user = userDetails($mysqli->insert_id);
  1761.     if($u['cookie'] == 1 && !empty($user)){
  1762.         setBoomCookie($user['user_id'], $user['user_password']);
  1763.         unsetBoomBtk();
  1764.     }
  1765.     if($u['verify'] == 1 && !empty($user)){
  1766.         $send_mail = sendActivation($user);
  1767.     }
  1768.     return $user;
  1769. }
  1770. function textFilter($c){
  1771.     global $data;
  1772.     if(canDirect()){
  1773.         $c = linking($c);
  1774.     }
  1775.     else {
  1776.         $c = linkingReg($c);
  1777.     }
  1778.     if(boomAllow($data['emo_plus'])){
  1779.         $c = emoticon(emoprocess($c));
  1780.     }
  1781.     else {
  1782.         $c = regEmoticon(emoprocess($c));
  1783.     }
  1784.     return $c;
  1785. }
  1786. function roomDetails(){
  1787.     global $data, $mysqli;
  1788.     $get_room = $mysqli->query("SELECT *,
  1789.                         (SELECT count(id) FROM boom_room_action WHERE action_room = '{$data['user_roomid']}' AND action_user = '{$data['user_id']}' AND action_muted = 1) as is_muted
  1790.                         FROM boom_rooms
  1791.                         WHERE room_id = '{$data['user_roomid']}'");
  1792.     if($get_room->num_rows > 0){
  1793.         $room = $get_room->fetch_assoc();
  1794.     }
  1795.     else {
  1796.         $room = array();
  1797.     }
  1798.     return $room;
  1799. }
  1800. function roomInfo($id){
  1801.     global $data, $mysqli;
  1802.     $room = array();
  1803.     $get_room = $mysqli->query("SELECT * FROM boom_rooms WHERE room_id = '$id'");
  1804.     if($get_room->num_rows > 0){
  1805.         $room = $get_room->fetch_assoc();
  1806.     }
  1807.     return $room;
  1808. }
  1809. function getRole($room){
  1810.     global $data, $mysqli;
  1811.     $getrole = $mysqli->query("SELECT * FROM boom_room_staff WHERE room_id = '$room' AND room_staff = '{$data['user_id']}'");
  1812.     if($getrole->num_rows > 0){
  1813.         $role = $getrole->fetch_assoc();
  1814.         return $role['room_rank'];
  1815.     }
  1816.     else {
  1817.         return 0;
  1818.     }
  1819. }
  1820. function emptyZone($text){
  1821.     return '<div class="empty_zone"><p>' . $text . '</p></div>';   
  1822. }
  1823. function tempPass(){
  1824.     $temp_pass = substr(str_shuffle('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+0123456789'), 0, 10);
  1825.     return $temp_pass;
  1826. }
  1827. function listGender($sex){
  1828.     global $lang;
  1829.     $list = '';
  1830.     $list .= '<option ' . selCurrent($sex, 1) . ' value="1">' . $lang['male'] . '</option>';
  1831.     $list .= '<option ' . selCurrent($sex, 2) . ' value="2">' . $lang['female'] . '</option>';
  1832.     return $list;
  1833. }
  1834. function validGender($sex){
  1835.     if($sex > 0 && $sex < 4){
  1836.         return true;
  1837.     }
  1838. }
  1839. function useWall(){
  1840.     global $data;
  1841.     if($data['use_wall'] == 1){
  1842.         return true;
  1843.     }
  1844. }
  1845. function validPassword($pass){
  1846.     if(strlen($pass) > 3){
  1847.         return true;
  1848.     }
  1849. }
  1850. function validRoomName($name){
  1851.     global $data;
  1852.     if(strlen($name) <= $data['max_room_name'] && strlen($name) >= 4 && preg_match("/^[a-zA-Z0-9 _\-\p{Arabic}\p{Cyrillic}\p{Latin}\p{Han}\p{Katakana}\p{Hiragana}\p{Hebrew}]{4,}$/ui", $name)){
  1853.         return true;
  1854.     }
  1855. }
  1856. function areFriend($id){
  1857.     global $mysqli, $data;
  1858.     $check_friend = $mysqli->query("SELECT * FROM boom_friends WHERE target = '{$data['user_id']}' AND hunter = '$id'");
  1859.     if($check_friend->num_rows > 0){
  1860.         return true;
  1861.     }
  1862. }
  1863. function clearBreak($text){
  1864.     $text = preg_replace("/[\r\n]{2,}/", "\n\n", $text);
  1865.     return $text;
  1866. }
  1867. function removeBreak($text){
  1868.     $text = preg_replace( "/(\r|\n)/", " ", $text );
  1869.     return $text;
  1870. }
  1871. function emoItem($type){
  1872.     switch($type){
  1873.         case 1:
  1874.             $emoclass = 'emo_menu_item';
  1875.             break;
  1876.         case 2:
  1877.             $emoclass = 'emo_menu_item_priv';
  1878.             break;
  1879.     }
  1880.     $emo = '';
  1881.     $dir = glob('emoticon/*' , GLOB_ONLYDIR);
  1882.     foreach($dir as $dirnew){
  1883.         $emoitem = str_replace('emoticon/', '', $dirnew);
  1884.         $emo .= '<div data="' . $emoitem . '" class="emo_menu ' . $emoclass . '"><img class="emo_select" src="emoticon_icon/' . $emoitem . '.png"/></div>';
  1885.     }
  1886.     return $emo;
  1887. }
  1888. function validEmail($email, $type = 0){
  1889.     global $data, $mysqli;
  1890.     if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
  1891.         return false;
  1892.     }
  1893.     if($data['email_filter'] == 1 && $type == 0){
  1894.         $get_end = explode('@', $email);
  1895.         $ending = $get_end[1];
  1896.         $get_email = $mysqli->query("SELECT word FROM boom_filter WHERE word_type = 'email' AND word = '$ending'");
  1897.         if($get_email->num_rows < 1){
  1898.             return false;
  1899.         }
  1900.     }
  1901.     return true;
  1902. }
  1903. function canEditUser($user, $rank){
  1904.     global $data;
  1905.     if(boomAllow($rank) && isGreater($user['user_rank']) && notMe($user['user_id']) && !isBot($user['user_bot']) || notMe($user['user_id']) && isOwner() && !userOwner($user)){
  1906.         return true;
  1907.     }
  1908. }
  1909. function validAge($age){
  1910.     global $data;
  1911.     if($age >= $data['min_age'] && $age != "" && $age < 100){
  1912.         return true;
  1913.     }
  1914. }
  1915. function validCountry($country, $region){
  1916.     require __DIR__ . '/location/country_list.php';
  1917.     if($country == 'hide' && $region == 'hide'){
  1918.         return true;
  1919.     }
  1920.     else {
  1921.         if(in_array($country, $country_list) && array_key_exists($country, $regions_list) && in_array($region, $regions_list[$country])){
  1922.             return true;
  1923.         }
  1924.     }
  1925. }
  1926. function getLanguage(){
  1927.     global $mysqli, $data, $boom_config;
  1928.     $l = $data['language'];
  1929.     if(boomLogged()){
  1930.         if(file_exists(__DIR__ . '/language/' . $data['user_language'] . '/language.php')){
  1931.             $l = $data['user_language'];
  1932.         }
  1933.         else {
  1934.             $mysqli->query("UPDATE boom_users SET user_language = '{$data['language']}' WHERE user_id = '{$data['user_id']}'");
  1935.         }
  1936.     }
  1937.     else {
  1938.         if(isset($_COOKIE[$boom_config['prefix'] . 'lang'])){
  1939.             $lang = boomSanitize($_COOKIE[$boom_config['prefix'] . 'lang']);
  1940.             if(file_exists(__DIR__ . '/language/' . $lang . '/language.php')){
  1941.                 $l = $lang;
  1942.             }
  1943.         }
  1944.     }
  1945.     return $l;
  1946. }
  1947. function isRtl($l){
  1948.     $rtl_list = array('Arabic','Persian','Farsi','Aramaic','Azeri','Hebrew','Dhivehi','Maldivian','Kurdish','Sorani','Urdu');
  1949.     if(in_array($l, $rtl_list)){
  1950.         return true;
  1951.     }
  1952. }
  1953. function getTheme(){
  1954.     global $mysqli, $data;
  1955.     $t = $data['default_theme'];
  1956.     if(boomLogged()){
  1957.         if(boomAllow($data['allow_theme']) && $data['user_theme'] != 'system'){
  1958.             if(file_exists(__DIR__ . '/../css/themes/' . $data['user_theme'] . '/' . $data['user_theme'] . '.css')){
  1959.                 $t = $data['user_theme'];
  1960.             }
  1961.             else {
  1962.                 $mysqli->query("UPDATE boom_users SET user_theme = 'system' WHERE user_id = '{$data['user_id']}'");
  1963.             }
  1964.         }
  1965.     }
  1966.     return $t . '/' . $t . '.css';
  1967. }
  1968. function emoticon($emoticon){
  1969.     $folder = __DIR__ . '/../emoticon';
  1970.     if ($dir = opendir($folder)) {
  1971.         while (false !== ($file = readdir($dir))){
  1972.             if ($file != "." && $file != ".."){
  1973.                     $select = preg_replace('/\.[^.]*$/', '', $file);
  1974.                     if(strpos($file, '.png')){
  1975.                         $emoticon = str_replace(':' . $select . ':', '<img  class="emo_chat" src="emoticon/' . $select . '.png"> ', $emoticon);
  1976.                     }
  1977.                     if(strpos($file, '.gif')){
  1978.                         $emoticon = str_replace(':' . $select . ':', '<img  class="emo_chat" src="emoticon/' . $select . '.gif"> ', $emoticon);
  1979.                     }
  1980.             }
  1981.         }
  1982.         closedir($dir);
  1983.     }
  1984.     $list = getEmo();
  1985.     foreach ($list as $value) {
  1986.         $type = 'emo_chat';
  1987.         if(stripos($value, 'sticker') !== false){
  1988.             $type = 'sticker_chat';
  1989.         }
  1990.         if(stripos($value, 'custom') !== false){
  1991.             $type = 'custom_chat';
  1992.         }
  1993.         if ($dir = opendir($folder . '/' . $value)){
  1994.             while (false !== ($file = readdir($dir))){
  1995.                 if ($file != "." && $file != ".."){
  1996.                     $select = preg_replace('/\.[^.]*$/', '', $file);
  1997.                     if(strpos($file, '.png')){
  1998.                         $emoticon = str_replace(':' . $select . ':', '<img  class="' . $type . '" src="emoticon/' . $value . '/' . $select . '.png"> ', $emoticon);
  1999.                     }
  2000.                     if(strpos($file, '.gif')){
  2001.                         $emoticon = str_replace(':' . $select . ':', '<img  class="' . $type . '" src="emoticon/' . $value . '/' . $select . '.gif"> ', $emoticon);
  2002.                     }
  2003.                 }
  2004.             }
  2005.             closedir($dir);
  2006.         }
  2007.     }
  2008.     return $emoticon;
  2009. }
  2010. function regEmoticon($emoticon){
  2011.     global $data;
  2012.     $folder = __DIR__ . '/../emoticon';
  2013.     if ($dir = opendir($folder)){
  2014.         while (false !== ($file = readdir($dir))){
  2015.             if ($file != "." && $file != ".."){
  2016.                 $select = preg_replace('/\.[^.]*$/', '', $file);
  2017.                 if(strpos($file, '.png')){
  2018.                     $emoticon = str_replace(':' . $select . ':', '<img  class="emo_chat" src="emoticon/' . $select . '.png"> ', $emoticon);
  2019.                 }
  2020.                 if(strpos($file, '.gif')){
  2021.                     $emoticon = str_replace(':' . $select . ':', '<img  class="emo_chat" src="emoticon/' . $select . '.gif"> ', $emoticon);
  2022.                 }
  2023.             }
  2024.         }
  2025.         closedir($dir);
  2026.     }
  2027.     return $emoticon;
  2028. }
  2029. function getEmo(){
  2030.     $emo = array();
  2031.     $dir = glob(__DIR__ . '/../emoticon/*' , GLOB_ONLYDIR);
  2032.     foreach($dir as $dirnew){
  2033.         array_push($emo, str_replace(__DIR__ . '/../emoticon/', '', $dirnew));
  2034.     }
  2035.     return $emo;
  2036. }
  2037. function boomFileVersion(){
  2038.     global $data;
  2039.     if($data['bbfv'] > 1.0){
  2040.         return '?v=' . $data['bbfv'];
  2041.     }
  2042.     return '';
  2043. }
  2044. function boomPostIt($content, $type = 1) {
  2045.     $content = systemReplace($content);
  2046.     if(!badWord($content)){
  2047.         $source = $content;
  2048.         $regex = '\w/_\.\%\+#\-\?:\=\&\;\(\)';
  2049.         if(normalise($content, 2)){
  2050.             $content = str_replace('youtu.be/','youtube.com/watch?v=',$content);
  2051.             $content = preg_replace('@https?:\/\/([-\w\.]+[-\w])+(:\d+)?\/[' . $regex . ']+\.(png|gif|jpg|jpeg)((\?\S+)?[^\.\s])?@i', '<div class="post_image"> <a href="$0" class="fancybox"><img src="$0"/></a> </div>', $content);
  2052.             $content = preg_replace('@https?:\/\/(www\.)?youtube.com/watch\?v=([\w_-]*)([' . $regex . ']*)?@ui', '<div class="video_container"><iframe src="https://www.youtube.com/embed/$2" frameborder="0" allowfullscreen></iframe></div>', $content);
  2053.             if(preg_last_error()) {
  2054.                 $content = $source;
  2055.             }
  2056.             $content = preg_replace('@([^=][^"])(https?://([-\w\.]+[-\w])+(:\d+)?(/([' . $regex . ']*(\?\S+)?[^\.\s])?)?)@ui', '$1<a href="$2" target="_blank">$2</a>', $content);
  2057.             $content = preg_replace('@^(https?://([-\w\.]+[-\w])+(:\d+)?(/([' . $regex . ']*(\?\S+)?[^\.\s])?)?)@ui', '<a href="$1" target="_blank">$1</a>', $content);
  2058.         }
  2059.     }
  2060.     if($type == 1){
  2061.         return nl2br($content);
  2062.     }
  2063.     else {
  2064.         return $content;
  2065.     }
  2066. }
  2067. function linking($content) {
  2068.     if(!badWord($content)){
  2069.         $source = $content;
  2070.         $regex = '\w/_\.\%\+#\-\?:\=\&\;\(\)';
  2071.         if(normalise($content, 1)){
  2072.             $content = str_replace('youtu.be/','youtube.com/watch?v=',$content);
  2073.             $content = preg_replace('@https?:\/\/(www\.)?youtube.com/watch\?v=([\w_-]*)([' . $regex . ']*)?@ui', '<div class="chat_video_container"><div class="chat_video"><iframe src="https://www.youtube.com/embed/$2" frameborder="0" allowfullscreen></iframe></div><div data="https://www.youtube.com/embed/$2" value="youtube" class="boom_youtube open_player hide_mobile"><i class="fa fa-external-link-square"></i></div></div>', $content);
  2074.             //$content = preg_replace('@https?:\/\/(www\.)?soundcloud.com/([\w_\/\?\=-]{1,})@ui', '<div class="chat_soundcloud"><iframe src="https://w.soundcloud.com/player/?url=//soundcloud.com/$2" frameborder="0" allowfullscreen></iframe></div>', $content);
  2075.             $content = preg_replace('@https?:\/\/([-\w\.]+[-\w])+(:\d+)?\/[' . $regex . ']+\.(png|gif|jpg|jpeg)((\?\S+)?[^\.\s])?@ui', ' <a href="$0" class="fancybox"><img class="chat_image"src="$0"/></a> ', $content);
  2076.             if(preg_last_error()) {
  2077.                 $content = $source;
  2078.             }
  2079.             $content = preg_replace('@([^=][^"])(https?://([-\w\.]+[-\w])+(:\d+)?(/([' . $regex . ']*(\?\S+)?[^\.\s])?)?)@ui', '$1<a href="$2" target="_blank">$2</a>', $content);
  2080.             $content = preg_replace('@^(https?://([-\w\.]+[-\w])+(:\d+)?(/([' . $regex . ']*(\?\S+)?[^\.\s])?)?)@ui', '<a href="$1" target="_blank">$1</a>', $content);
  2081.         }
  2082.     }
  2083.     return $content;
  2084. }
  2085. function linkingReg($content){
  2086.     if(!badWord($content)){
  2087.         $regex = '\w/_\.\%\+#\-\?:\=\&\;\(\)';
  2088.         if(normalise($content, 1)){
  2089.             $content = preg_replace('@([^=][^"])(https?://([-\w\.]+[-\w])+(:\d+)?(/([' . $regex . ']*(\?\S+)?[^\.\s])?)?)@ui', '$1<a href="$2" target="_blank">$2</a>', $content);
  2090.             $content = preg_replace('@^(https?://([-\w\.]+[-\w])+(:\d+)?(/([' . $regex . ']*(\?\S+)?[^\.\s])?)?)@ui', '<a href="$1" target="_blank">$1</a>', $content);;
  2091.         }
  2092.     }
  2093.     return $content;
  2094. }
  2095. function customChatImg($source, $tumb = ''){
  2096.     if(empty($tumb)){
  2097.         $tumb = $source;
  2098.     }
  2099.     return '<a href="' . $source . '" class="fancybox"><img class="chat_image"src="' . $tumb . '"/></a>';
  2100. }
  2101. function fileProcess($f, $r){
  2102.     $file = array(
  2103.         'file'=> $f,
  2104.         'title'=> $r
  2105.     );
  2106.     return boomTemplate('element/file', $file);
  2107. }
  2108. function musicProcess($f, $r){
  2109.     $file = array(
  2110.         'file'=> $f,
  2111.         'title'=> $r
  2112.     );
  2113.     return boomTemplate('element/audio', $file);
  2114. }
  2115. function cleanBoomName($name){
  2116.     return str_replace(array(' ', "'", '"', '<', '>', ","), array('_', '', '', '', '', ''), $name);
  2117. }
  2118. function filterOrigin($origin){
  2119.     if(strlen($origin) > 55){
  2120.         $origin = mb_substr($origin, 0, 55);
  2121.     }
  2122.     return str_replace(array(' ', '.', '-'), '_', $origin);
  2123. }
  2124. function badWord($content){
  2125.     $regex = '\w/_\.\%\+#\-\?:\=\&\;\(\)';
  2126.     if(preg_match('@https?:\/\/(www\.)?([' . $regex . ']*)?([\*]{4}){1,}([' . $regex . ']*)?@ui', $content)){
  2127.         return true;
  2128.     }
  2129. }
  2130. function clearUserData($u){
  2131.     global $mysqli;
  2132.     if(empty($u)){
  2133.         return false;
  2134.     }
  2135.     $id = $u['user_id'];
  2136.     $av = $u['user_tumb'];
  2137.     $mysqli->query("DELETE FROM boom_chat WHERE user_id = '$id'");
  2138.     $mysqli->query("DELETE FROM boom_room_action WHERE action_user = '$id'");
  2139.     $mysqli->query("DELETE FROM boom_private WHERE target = '$id' OR hunter = '$id'");
  2140.     $mysqli->query("DELETE FROM boom_post WHERE post_user = '$id'");
  2141.     $mysqli->query("DELETE FROM boom_post_reply WHERE reply_user = '$id' OR reply_uid = '$id'");
  2142.     $mysqli->query("DELETE FROM boom_post_like WHERE uid = '$id' OR liked_uid = '$id'");
  2143.     $mysqli->query("DELETE FROM boom_room_staff WHERE room_staff = '$id'");
  2144.     $mysqli->query("DELETE FROM boom_friends WHERE hunter = '$id' OR target = '$id'");
  2145.     $mysqli->query("DELETE FROM boom_notification WHERE notifier = '$id' OR notified = '$id'");
  2146.     $mysqli->query("DELETE FROM boom_users WHERE user_id = '$id'");
  2147.     $mysqli->query("DELETE FROM boom_report WHERE report_user = '$id'");
  2148.     $mysqli->query("DELETE FROM boom_ignore WHERE ignorer  = '$id' OR ignored = '$id'");
  2149.     $del_av = unlinkAvatar($av);
  2150. }
  2151. function cleanList($type, $rank = 0){
  2152.     global $mysqli, $data;
  2153.     $user = array();
  2154.     $av = array();
  2155.     $find_query = cleanListQuery($type);
  2156.     if(empty($find_query) || !boomAllow($rank) || $find_query == ''){
  2157.         return false;
  2158.     }
  2159.     $find_list = $mysqli->query("SELECT user_id, user_tumb FROM boom_users WHERE $find_query");
  2160.     if($find_list->num_rows > 0){
  2161.         while($user_list = $find_list->fetch_assoc()){
  2162.             array_push($user, $user_list['user_id']);
  2163.             array_push($av, $user_list['user_tumb']);
  2164.         }
  2165.         if(!empty($user)){
  2166.             $list = implode(", ", $user);
  2167.             $mysqli->query("DELETE FROM boom_chat WHERE user_id IN ($list)");
  2168.             $mysqli->query("DELETE FROM boom_users WHERE user_id IN ($list) AND $find_query");
  2169.             $mysqli->query("DELETE FROM boom_private WHERE hunter  IN ($list) OR target  IN ($list)");
  2170.             $mysqli->query("DELETE FROM boom_room_action WHERE action_user  IN ($list)");
  2171.             $mysqli->query("DELETE FROM boom_room_staff WHERE room_staff IN ($list)");
  2172.             $mysqli->query("DELETE FROM boom_ignore WHERE ignorer  IN ($list) OR ignored  IN ($list)");
  2173.             $mysqli->query("DELETE FROM boom_report WHERE report_user IN ($list)");
  2174.             $mysqli->query("DELETE FROM boom_notification WHERE notifier IN ($list) OR notified IN ($list)");
  2175.             $mysqli->query("DELETE FROM boom_post WHERE post_user IN ($list)");
  2176.             $mysqli->query("DELETE FROM boom_post_reply WHERE reply_user IN ($list) OR reply_uid IN ($list)");
  2177.             $mysqli->query("DELETE FROM boom_post_like WHERE uid IN ($list) OR liked_uid IN ($list)");
  2178.             $mysqli->query("DELETE FROM boom_room_staff WHERE room_staff IN ($list)");
  2179.             $mysqli->query("DELETE FROM boom_friends WHERE hunter IN ($list) OR target IN ($list)");
  2180.         }
  2181.         if(!empty($av)){
  2182.             foreach($av as $del_av){
  2183.                 unlinkAvatar($del_av);
  2184.             }
  2185.         }
  2186.     }  
  2187. }
  2188. function cleanListQuery($type){
  2189.     global $data;
  2190.     $chat_delay = calDay($data['chat_delete']);
  2191.     switch($type){
  2192.         case 'guest':
  2193.             return "user_rank = '0'";
  2194.         case 'innactive_guest':
  2195.             return "user_rank = '0' AND last_action <= '$chat_delay'";
  2196.         case 'system_bot':
  2197.             return "user_bot = '9'";
  2198.         default:
  2199.             return "";
  2200.     }
  2201. }
  2202. function softGuestDelete($u){
  2203.     global $mysqli, $boom_config, $data;
  2204.     $id = $u['user_id'];
  2205.     if(!isGuest($u['user_rank'])){
  2206.         return false;
  2207.     }
  2208.     $new_pass = randomPass();
  2209.     $new_name = '@' . $boom_config['guest_anonym'] . $id;
  2210.     $mysqli->query("DELETE FROM boom_room_action WHERE action_user = '$id'");
  2211.     $mysqli->query("DELETE FROM boom_private WHERE target = '$id' OR hunter = '$id'");
  2212.     $mysqli->query("DELETE FROM boom_room_staff WHERE room_staff = '$id'");
  2213.     $mysqli->query("DELETE FROM boom_friends WHERE hunter = '$id' OR target = '$id'");
  2214.     $mysqli->query("DELETE FROM boom_notification WHERE notifier = '$id' OR notified = '$id'");
  2215.     if(stripos($u['user_name'],$data['guest_prefix']) === FALSE){
  2216.         $mysqli->query("UPDATE boom_users SET user_name = '$new_name', user_password = '$new_pass' WHERE user_id = '$id'");
  2217.     }
  2218. }
  2219. function clearRoom($id){
  2220.     global $data, $mysqli, $lang;
  2221.     $clearmessage = str_ireplace('%user%', $data['user_name'], $lang['room_clear']) . '<span class="b_o_o_m"></span>';
  2222.     $mysqli->query("DELETE FROM `boom_chat` WHERE `post_roomid` = '$id' ");
  2223.     systemSay($data['user_roomid'], $clearmessage);
  2224.     $mysqli->query("UPDATE boom_users SET caction = caction + 1 WHERE user_roomid = '$id'");
  2225.     $mysqli->query("DELETE FROM boom_report WHERE report_room = '$id'");
  2226.     return true;
  2227. }
  2228. function changeTopic($topic, $id){
  2229.     global $mysqli;
  2230.     $topic = preg_replace('/(^|[^"])(((f|ht){1}tp:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i', '\\1<a href="\\2" target="_blank">\\2</a>', $topic);
  2231.     $mysqli->query("UPDATE `boom_rooms` SET `topic` = '$topic' WHERE `room_id` = '$id'");
  2232.     $mysqli->query("UPDATE boom_users SET taction = taction + 1 WHERE user_roomid = '$id'");
  2233.     return true;
  2234. }
  2235. function userSeen($name){
  2236.     global $lang, $data, $mysqli;
  2237.     $seen = array();
  2238.     $user = nameDetails($name);
  2239.     if(!empty($user)){
  2240.         $seen = roomInfo($user['user_roomid']);
  2241.     }
  2242.     if(empty($user) || $user['user_status'] == 6 || isBot($user['user_bot'])){
  2243.         return str_replace('%userseen%', '<b>' . $name . '</b>', $lang['not_seen']);
  2244.     }
  2245.     if($user['user_roomid'] == 0 || empty($seen)){
  2246.         return str_replace(array('%userseen%', '%seentime%'), array('<b>' . $user['user_name'] . '</b>', '<b>' . displayDate($user['last_action']) . '</b>'), $lang['seen_lobby']);
  2247.     }
  2248.     return str_replace(array('%userseen%', '%seentime%', '%seenroom%'), array('<b>' . $user['user_name'] . '</b>', '<b>' . displayDate($user['last_action']) . '</b>', '<b>' . $seen['room_name'] . '</b>'), $lang['seen']);
  2249. }
  2250. function muteCleanup(){
  2251.     global $mysqli, $data;
  2252.     $unmute = calMinutes($data['word_delay']);
  2253.     $mysqli->query("UPDATE boom_users SET user_word_mute = 0 WHERE user_word_mute < '$unmute'");
  2254. }
  2255. function boomAds($link, $img, $type){
  2256.     global $data;
  2257.     return '<a target="_blank" href="' . $link . '"><img class="' . $type . '" border="0" src="' . $data['domain'] . '/money/' . $img . '"></a>';  
  2258. }
  2259. function getRoomList($type){
  2260.     global $mysqli, $data, $lang;
  2261.     $check_action = getDelay();
  2262.     $rooms = $mysqli->query(" SELECT *,
  2263.     ( SELECT Count(boom_users.user_id) FROM boom_users  Where boom_users.user_roomid = boom_rooms.room_id AND last_action > '$check_action' AND user_status != 6 ) as room_count
  2264.     FROM  boom_rooms
  2265.     ORDER BY room_count DESC");
  2266.     $sroom = 0;
  2267.     $room_list = '';
  2268.     while ($room = $rooms->fetch_assoc()){
  2269.         $ask = 0;
  2270.         $room['room_protected'] = '';
  2271.         $room['room_ask'] = '';
  2272.         $room['room_current'] = '';
  2273.         $room['myr'] = '';
  2274.         if($room['password'] != ''){
  2275.             $room['room_protected'] = '<i class="fa fa-lock r_lock"></i> ';
  2276.             $ask = 1;
  2277.         }
  2278.         if($room['description'] == ''){
  2279.             $room['room_description'] = $lang['room_no_description'];
  2280.         }
  2281.         else {
  2282.             $room['room_description'] = $room['description'];
  2283.         }
  2284.         if($room['room_id'] == $data['user_roomid']){
  2285.             $room['room_current'] = 'noview';
  2286.         }
  2287.         if($data['user_id'] == $room['room_creator']){
  2288.             $room['myr'] = 'owner ';
  2289.         }
  2290.         $room['room_ask'] = 'onclick="switchRoom(' . $room['room_id']  . ', ' . $ask . ', ' . $room['access'] . ', \'' . $room['room_name'] . '\');"';
  2291.         switch($type){
  2292.             case 'list':
  2293.                 $room_list .= boomTemplate('element/room_item', $room);
  2294.                 break;
  2295.             case 'box':
  2296.                 $room_list .= boomTemplate('element/room_box', $room);
  2297.                 break;
  2298.         }
  2299.     }
  2300.     return $room_list;
  2301. }
  2302. function loadAddonsJs($a){
  2303.     global $mysqli, $data, $lang;
  2304.     $v = boomFileVersion();
  2305.     mysqli_data_seek($a, 0);
  2306.     while ($addons = $a->fetch_assoc()){
  2307.         if(boomAllow($addons['addons_access'])){
  2308.             if($addons['addons_js'] == 1){
  2309.                 echo '<script data-cfasync="false" type="text/javascript" src="addons/' . $addons['addons'] . '/files/' . $addons['addons'] . '.js' . $v . '"></script>';
  2310.             }
  2311.             if($addons['addons_js'] == 2){
  2312.                 include __DIR__ . '/../addons/' . $addons['addons'] . '/files/' . $addons['addons'] . '.php';
  2313.             }
  2314.         }
  2315.     }
  2316. }
  2317. function loadAddonsCss($a){
  2318.     global $mysqli, $data;
  2319.     $v = boomFileVersion();
  2320.     mysqli_data_seek($a, 0);
  2321.     while ($addons = $a->fetch_assoc()){
  2322.         if($addons['addons_css'] == 1){
  2323.             echo '<link rel="stylesheet" type="text/css" href="addons/' . $addons['addons'] . '/files/' . $addons['addons'] . '.css' . $v . '" />';
  2324.         }
  2325.     }  
  2326. }
  2327. function loadAddonsMenu($a){
  2328.     global $mysqli, $data;
  2329.     $addons_menu = '';
  2330.     mysqli_data_seek($a, 0);
  2331.     while ($addons = $a->fetch_assoc()){
  2332.         if($addons['addons_menu'] == 1 && boomAllow($addons['addons_access'])){
  2333.             $addons_menu .= boomTemplate('element/addons_menu_item', $addons);
  2334.         }
  2335.     }
  2336.     if(!empty($addons_menu)){
  2337.         echo boomTemplate('element/addons_menu', $addons_menu);
  2338.     }
  2339. }
  2340. function getAddons(){
  2341.     global $mysqli;
  2342.     $load_addons = $mysqli->query("SELECT * FROM boom_addons");
  2343.     return $load_addons;
  2344. }
  2345. function canModifyAvatar($user){
  2346.     global $data;
  2347.     if(empty($user)){
  2348.         return false;
  2349.     }
  2350.     if(isOwner() && !userOwner($user)){
  2351.         return true;
  2352.     }
  2353.     if(!boomAllow(9)){
  2354.         return false;
  2355.     }
  2356.     if(isBot($user['user_bot']) && !boomAllow(10)){
  2357.         return false;
  2358.     }
  2359.     if(!boomAllow($data['allow_avatar'])){
  2360.         return false;
  2361.     }
  2362.     if(!notMe($user['user_id'])){
  2363.         return true;
  2364.     }
  2365.     if(isGreater($user['user_rank'])){
  2366.         return true;
  2367.     }
  2368.     return false;
  2369. }
  2370. function getPageData($page_data = array()){
  2371.     global $data;
  2372.     $page_default = array(
  2373.         'page'=> '',
  2374.         'page_load'=> '',
  2375.         'page_menu'=> 0,
  2376.         'page_embed'=> 0,
  2377.         'page_rank'=> 0,
  2378.         'page_room'=> 1,
  2379.         'page_out'=> 0,
  2380.         'page_keyword'=> $data['site_keyword'],
  2381.         'page_description'=> $data['site_description'],
  2382.         'page_rtl'=> 1,
  2383.         'page_nohome'=> 0,
  2384.     );
  2385.     $page = array_merge($page_default, $page_data);
  2386.     return $page;
  2387. }
  2388. function lastRecordedId(){
  2389.     global $mysqli;
  2390.     $getid = $mysqli->query("SELECT MAX(user_id) AS last_id FROM boom_users");
  2391.     $id = $getid->fetch_assoc();
  2392.     return $id['last_id'] + 1;
  2393. }
  2394. function listThisArray($a){
  2395.     return implode(", ", $a);
  2396. }
  2397. function sameAccount($u){
  2398.     global $mysqli, $lang;
  2399.     $getsame = $mysqli->query("SELECT user_name FROM boom_users WHERE user_ip = '{$u['user_ip']}' AND user_id != '{$u['user_id']}' AND user_bot = 0 ORDER BY user_id DESC LIMIT 50");
  2400.     $same = array();
  2401.     if($getsame->num_rows > 0){
  2402.         while($usame = $getsame->fetch_assoc()){
  2403.             array_push($same, $usame['user_name']);
  2404.         }
  2405.     }
  2406.     else {
  2407.         array_push($same, $lang['none']);
  2408.     }
  2409.     return listThisArray($same);
  2410. }
  2411. function createIgnore(){
  2412.     global $mysqli, $data, $boom_config;
  2413.     $ignore_list = '';
  2414.     $get_ignore = $mysqli->query("SELECT ignored FROM boom_ignore WHERE ignorer = '{$data['user_id']}'");
  2415.     while($ignore = $get_ignore->fetch_assoc()){
  2416.         $ignore_list .= 'u' . $ignore['ignored'] . 'x';
  2417.     }
  2418.     $_SESSION[$boom_config['prefix'] . 'ignore'] = $ignore_list;
  2419. }
  2420. function getRoomId(){
  2421.     global $mysqli, $data;
  2422.     if(boomLogged()){
  2423.         if($data['user_roomid'] == 0){
  2424.             if(!useLobby()){
  2425.                 $mysqli->query("UPDATE boom_users SET user_roomid = '1' WHERE user_id = '{$data['user_id']}'");
  2426.                 return 1;
  2427.             }
  2428.         }
  2429.         else {
  2430.             return $data['user_roomid'];
  2431.         }
  2432.     }
  2433.     return 0;
  2434. }
  2435. function boomGuestCount(){
  2436.     global $mysqli, $data;
  2437.     $mysqli->query("UPDATE boom_setting SET guest_count = guest_count + 1 WHERE id > 0");
  2438.     return $data['guest_count'] + 1;
  2439. }
  2440. function boomCookieLaw(){
  2441.     global $boom_config;
  2442.     if(!isset($_COOKIE[$boom_config['prefix'] . "claw"]) && $boom_config['cookie_law'] == 1){
  2443.         return true;
  2444.     }
  2445. }
  2446. function listFilter($type){
  2447.     global $data, $mysqli, $lang;
  2448.     $list_word = '';
  2449.     $getword = $mysqli->query("SELECT * FROM boom_filter WHERE word_type = '$type' ORDER BY word ASC");
  2450.     if($getword->num_rows > 0){
  2451.         while($word = $getword->fetch_assoc()){
  2452.             $list_word .= boomTemplate('element/word', $word);
  2453.         }
  2454.     }
  2455.     else {
  2456.         $list_word .= emptyZone($lang['empty']);
  2457.     }
  2458.     return $list_word;
  2459. }
  2460. function getActionList($type){
  2461.     global $data, $mysqli, $lang;
  2462.     $action_list = '';
  2463.     $action_info = getActionCritera($type);
  2464.     $getaction = $mysqli->query("SELECT * FROM boom_users WHERE $action_info ORDER BY last_action DESC");
  2465.     if($getaction->num_rows > 0){
  2466.         while($action = $getaction->fetch_assoc()){
  2467.             $action['type'] = $type;
  2468.             $action_list .= boomTemplate('element/admin_action_user', $action);
  2469.         }
  2470.     }
  2471.     else {
  2472.         $action_list .= emptyZone($lang['empty']);
  2473.     }
  2474.     return $action_list;
  2475. }
  2476. function getActionCritera($c){
  2477.     switch($c){
  2478.         case 'muted':
  2479.             return "user_mute > 0";
  2480.         case 'banned':
  2481.             return "user_banned > 0";
  2482.         default:
  2483.             return "user_rank > 1000";
  2484.     }  
  2485. }
  2486. function loadPageData($page){
  2487.     global $mysqli;
  2488.     $page_data = '';
  2489.     $get_page = $mysqli->query("SELECT * FROM boom_page WHERE page_name = '$page' LIMIT 1");
  2490.     if($get_page->num_rows > 0){
  2491.         $pdata = $get_page->fetch_assoc();
  2492.         $page_data = $pdata['page_content'];
  2493.     }
  2494.     return $page_data;
  2495. }
  2496. function boomFooterMenu(){
  2497.     global $data, $lang;
  2498.     include __DIR__ . '/../control/footer_menu.php';
  2499. }
  2500. function userFullDetails($id){
  2501.     global $mysqli, $data;
  2502.     $user = array();
  2503.     $getuser = $mysqli->query("SELECT user_id, user_bot,
  2504.     (SELECT status FROM boom_friends WHERE hunter = '{$data['user_id']}' AND target = '$id') as are_friend,
  2505.     ( SELECT count(ignore_id) FROM boom_ignore WHERE ignorer = '{$data['user_id']}' AND ignored = '$id' OR ignorer = '$id' AND ignored = '{$data['user_id']}' ) as ignored
  2506.     FROM boom_users WHERE `user_id` = '$id'");
  2507.     if($getuser->num_rows > 0){
  2508.         $user = $getuser->fetch_assoc();
  2509.     }
  2510.     return $user;
  2511. }
  2512. function boomAddFriend($id){
  2513.     global $mysqli, $data;
  2514.     $user = userFullDetails($id);
  2515.     if(empty($user)){
  2516.         return 3;
  2517.     }
  2518.     if($user['ignored'] > 0 || isBot($user['user_bot']) || !notMe($user['user_id'])){
  2519.         return 0;
  2520.     }
  2521.     if($user['are_friend'] == 1){
  2522.         $mysqli->query("UPDATE boom_friends SET status = 3 WHERE hunter = '{$data['user_id']}' AND target = '$id' OR hunter = '$id' AND target = '{$data['user_id']}'");
  2523.         regNotify($id, 'accept_friend');
  2524.         return 1;
  2525.     }
  2526.     if($user['are_friend'] == 3 || $user['are_friend'] == 2){
  2527.         return 4;
  2528.     }
  2529.     if(is_null($user['are_friend'])){
  2530.         $mysqli->query("INSERT INTO boom_friends (hunter, target, status) VALUES ('{$data['user_id']}', '$id', '2'), ('$id', '{$data['user_id']}', '1')");
  2531.         return 2;
  2532.     }
  2533. }
  2534. function boomRemoveFriend($id){
  2535.     global $mysqli, $data;
  2536.     $mysqli->query("DELETE FROM boom_friends WHERE hunter = '{$data['user_id']}' AND target = '$id' OR hunter = '$id' AND target = '{$data['user_id']}'");
  2537.     $mysqli->query("DELETE FROM boom_notification WHERE notifier = '$id' AND notified = '{$data['user_id']}' OR notifier = '{$data['user_id']}' AND notified = '$id'");
  2538.     return 1;
  2539. }
  2540. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top