[ PHPXref.com ] [ Generated: Sun Jul 20 18:37:24 2008 ] [ MetaBB 5.0 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> adr_global_chat.php (source)

   1  <?php
   2  
   3  /***************************************************************************

   4   *                                 adr_global_chat.php

   5   *                                ---------------------

   6   *        Version            : 1.0.0

   7   *        Authors            : aUsTiN         

   8   *                            [ (austin_inc@hotmail.com)         (http://phpbb-amod.com)     ]

   9   *                          Seteo-Bloke     

  10   *                            [ (admin@phpbb-adr.com)     (http://www.phpbb-adr.com)     ]

  11   *

  12   ***************************************************************************************/
  13  
  14  define('IN_PHPBB', true);
  15  define('IN_ADR_BATTLE', true);
  16  define('IN_ADR_CHARACTER', true);
  17  define('IN_ADR_SHOPS', true);
  18  
  19  $phpbb_root_path = './';
  20  include_once ($phpbb_root_path . 'extension.inc');
  21  include_once($phpbb_root_path . 'common.'.$phpEx);
  22  include_once($phpbb_root_path . 'includes/bbcode.'. $phpEx);
  23  
  24  $loc = 'battle_community';
  25  $sub_loc = 'battle_community';
  26  
  27  //

  28  // Start session management

  29  $userdata = session_pagestart($user_ip, PAGE_INDEX);
  30  init_userprefs($userdata);
  31  // End session management

  32  //

  33  $user_id = $userdata['user_id'];
  34  $user_points = $userdata['user_points'];
  35  include_once($phpbb_root_path . 'adr/includes/adr_global.'.$phpEx);
  36  include_once($phpbb_root_path . 'adr/includes/adr_functions_global_chat.'.$phpEx);
  37  
  38  // Sorry , only logged users

  39  if(!$userdata['session_logged_in']){
  40      $redirect = "adr_battle_community.$phpEx";
  41      $redirect .= (isset($user_id)) ? '&user_id=' . $user_id : '';
  42      header('Location: ' . append_sid("login.$phpEx?redirect=$redirect", true));
  43  }
  44  
  45  // Get the general config

  46  $adr_general = adr_get_general_config();
  47  $adr_user = adr_get_user_infos($user_id);
  48  
  49  // Load the headers

  50  $gen_simple_header = TRUE;
  51  //include_once($phpbb_root_path .'includes/page_header.'. $phpEx);

  52  adr_template_file('adr_global_chat_body.tpl');
  53  
  54      $mode = ($_POST['mode']) ? $_POST['mode'] : $HTTP_POST_VARS['mode'];
  55  
  56      if(!$mode)
  57          $mode = ($_GET['mode']) ? $_GET['mode'] : $HTTP_GET_VARS['mode'];
  58  
  59      $todays_chat_info     = GC_GetTodaysChat();
  60      $todays_chat         = $todays_chat_info['chat_text'];
  61  
  62      // Basic error checks before postings

  63      $error_['1']        ='<i><font color="#FF0000">'.$lang['Adr_global_shout_error_1'].'</font></i><br><br>';
  64      $error_['2']        ='<i><font color="#FF0000">'.$lang['Adr_global_shout_error_2'].'</font></i><br><br>';
  65      $error_['3']        ='<i><font color="#FF0000">'.$lang['Adr_global_shout_error_3'].'</font></i><br><br>';
  66      $error_['4']        ='<i><font color="#FF0000">'.$lang['Adr_global_shout_incorrect_user'].'</font></i><br><br>';
  67  
  68      if($mode == 'archives'){
  69          $template->assign_block_vars('archives', array(
  70              'MSG'    => 'Setup the archives here, with the header & footer included!'
  71          ));
  72      }
  73  
  74      if($mode == 'add')
  75      {
  76      $msg = ($_POST['msg']) ? $_POST['msg'] : $HTTP_POST_VARS['msg'];
  77  
  78      #==== Check: did they post all spaces? ======================== |        

  79      $msg = trim($msg);
  80      
  81      #==== Check: did they post? =================================== |

  82      if(empty($msg)) $error_messages = '1';
  83      
  84      #==== Check: max characters exceeded? ========================= |

  85      $some_number = 250; # Make this a config value!

  86      if(strlen($msg) > $some_number){
  87          $over = ($some_number - $msg);
  88          $error_messages = '2';
  89      }
  90  
  91      #==== Check: admin has posted a command sequence ========================= |

  92      if($userdata['user_level'] == ADMIN){
  93          // Checks if admin wants to instant kill a user.

  94          // First 5 characters are '/kill', sixth is a space ' ' and then from 7 onwards we have the username

  95          // Remember [0] is the first letter in the array

  96          if(substr($msg, 0, 5) == '/kill'){
  97              $username = substr($msg, 6);
  98              $msg = '<font color="purple"><i><b>'.$lang['Adr_global_shout_adm_cmd'].' </b>'.adr_gc_admin_cmd_kill($username).'</i></font>';
  99          }
 100  
 101          // Revive user with full HP

 102          elseif(substr($msg, 0, 7) == '/revive'){
 103              $username = substr($msg, 8);
 104              $msg = '<font color="purple"><i><b>'.$lang['Adr_global_shout_adm_cmd'].' </b>'.adr_gc_admin_cmd_revive($username).'</i></font>';
 105          }
 106  
 107          // Finish a users monster battle

 108          elseif(substr($msg, 0, 10) == '/endallmon'){
 109              $username = substr($msg, 11);
 110              $msg = '<font color="purple"><i><b>'.$lang['Adr_global_shout_adm_cmd'].' </b>'.adr_admin_cmd_endallmon($username).'</i></font>';
 111          }
 112  
 113          // Finish a users all current PvP battles

 114          elseif(substr($msg, 0, 10) == '/endallpvp'){
 115              $username = substr($msg, 11);
 116              $msg = '<font color="purple"><i><b>'.$lang['Adr_global_shout_adm_cmd'].' </b>'.adr_admin_cmd_endallpvp($username).'</i></font>';
 117          }
 118  
 119          // Finish one PvP battle. Pass battle_pvp_id for success

 120          elseif(substr($msg, 0, 7) == '/endpvp'){
 121              $battle_id = intval(substr($msg, 8));
 122              $msg = '<font color="purple"><i><b>'.$lang['Adr_global_shout_adm_cmd'].' </b>'.adr_admin_cmd_endpvp($battle_id).'</i></font>';
 123          }
 124  
 125          // Instant ban a user from participating in ADR/RPG

 126          elseif(substr($msg, 0, 4) == '/ban'){
 127              // Find first instance of '?' within cmd to grab ban reason

 128              $pos = strpos($msg, '?');
 129  
 130              // Check if a '?' is present. If not show error msg

 131              if(strpos($msg, '?')){
 132                  $reason = trim(substr(($pos + 1)));
 133                         $username = substr($msg, 5, ($pos - 6));
 134                  $msg = '<font color="purple"><i><b>'.$lang['Adr_global_shout_adm_cmd'].' </b>'.adr_admin_cmd_ban($username, $reason).'</i></font>';
 135              }
 136              else{
 137                  $msg = '<font color="purple"><i><b>'.$lang['Adr_global_shout_adm_cmd'].' </b>'.$lang['Adr_global_shout_error_3'].'</i></font>';
 138              }
 139          }
 140  
 141          // Instant UNban a user from participating in ADR/RPG

 142          elseif(substr($msg, 0, 6) == '/unban')
 143          {
 144              // Find first instance of '?' within cmd to grab ban reason

 145              $pos = strpos($msg, '?');
 146  
 147              // Check if a '?' is present. If not show error msg

 148              if(strpos($msg, '?')){
 149                  $reason = trim(substr(($pos + 1)));
 150                     $username = trim(substr($msg, 7, ($pos - 8)));
 151                  $msg = '<font color="purple"><i><b>'.$lang['Adr_global_shout_adm_cmd'].' </b>'.adr_admin_cmd_unban($username, $reason).'</i></font>';
 152              }
 153              else{
 154                  $msg = '<font color="purple"><i><b>'.$lang['Adr_global_shout_adm_cmd'].' </b>'.$lang['Adr_global_shout_error_3'].'</i></font>';
 155              }
 156          }
 157      }
 158  
 159      #==== Check: wordwrapping the message? ======================== |    

 160          # This is so the kids can't stretch the page!

 161      $msg = wordwrap($msg, 25, ' ', 1);
 162  
 163      #==== Check for admin global shout ================================= |

 164      $admin_shout = ((substr($msg, 0, 1) == '!') && ($userdata['user_level'] == ADMIN)) ? TRUE : FALSE;
 165      $msg = ($admin_shout) ? substr_replace($msg, '', 0, 1) : $msg;
 166      $msg = ($admin_shout) ? '<font color="#FF0000"><b>'.$msg.'</b></font>' : $msg;
 167      $msg = ($admin_shout) ? strtoupper($msg) : $msg;
 168      
 169      #==== Get Username To add to Message ================================= |

 170      $umsg = ($admin_shout == FALSE) ? '<a href="profile.'. $phpEx .'?mode=viewprofile&u='. $adr_user['character_id'] .'" target="_blank">'. $adr_user['character_name'] .'</a>' : '<font color="#FF0000"><b>'.$lang['Adr_global_shout_announcer'].'</b></font>';
 171  
 172      #==== check if shouter is a GM (admin)========|

 173      $umsg = ($userdata['user_level'] == ADMIN) ? '<b>'. $umsg .'</b>' : $umsg;
 174  
 175      #==== Check for emotes ================================= |

 176      $emote_= (substr($msg, 0, 3) != "/me") ? FALSE : TRUE;
 177      $clear_text_= ((substr($msg, 0, 6) == "/clear") && ($userdata['user_level'] == ADMIN)) ? TRUE : FALSE;
 178      $killme_ = (substr($msg, 0, 7) != "/killme") ? FALSE : TRUE;
 179      $pvpme_ = (substr($msg, 0, 6) != "/pvpme") ? FALSE : TRUE;
 180      $vitals = (substr($msg, 0, 6) != '/stats') ? FALSE : TRUE;
 181  
 182      if($emote_){
 183          $msg = '<i>'.$umsg.' '.substr($msg, 4).'</i>';
 184      }
 185      elseif($clear_text_){
 186          GC_clear_today_chat();
 187          $error_messages = $lang['Adr_global_shout_error_no_log'];
 188      }
 189      elseif($killme_){
 190          $killme_msg = substr($msg, 8);
 191          $msg = '<i>'.sprintf($lang['Adr_global_shout_killme'], $adr_user['character_name'], $killme_msg).'</i>';
 192      }
 193      elseif($pvpme_){
 194          $msg = '<font color="red"><b>'.sprintf($lang['Adr_global_shout_pvpme'], $adr_user['character_name']).'</b></font>';
 195      }
 196      elseif($vitals){
 197          $username = substr($msg, 7);
 198          $msg = '<i>'.adr_gc_admin_cmd_vitals($username).'</i>';
 199      }
 200      elseif(substr($msg, 0, 9) == '/realname'){
 201          // Not complete

 202          $character_name = substr($msg, 10);
 203          $msg = sprintf($lang['Adr_global_shout_realname'], '<font color="purple"><i>', '<b>'.$character_name.'</b>', '<b>'.$username.'</b>', '</i></font>');
 204      }
 205      else{
 206          $msg = $umsg.": ".'<font color="#0000FF">'.$msg.'</font>';
 207      }
 208  
 209      #==== Add Beginning & End To Message ========================== |

 210      $msg = '%S%'. $msg;
 211      $msg = $msg .'%E%';
 212  
 213      #==== Escape ' ========================== |

 214      $msg = addslashes($msg);
 215  
 216      if($error_messages == "")
 217          GC_AddChat($msg);
 218  
 219      redirect('adr_global_chat.'. $phpEx.'?err='.$error_messages, TRUE);
 220      exit;
 221      }
 222  
 223      // Include page header now to prevent redirect errors

 224      include_once($phpbb_root_path .'includes/page_header.'. $phpEx);
 225      if(!$mode){
 226          if(!$todays_chat)
 227              $todays_chat = '%S%*'.$lang['Adr_global_shout_error_no_log'].'*%E%';
 228  
 229      #==== Word Censor Pass ======================================== |

 230      $q = "SELECT * FROM ". WORDS_TABLE;
 231          if(!$r = $db->sql_query($q))
 232                 message_die(GENERAL_ERROR, "Error Selecting Censored Word List.", "", __LINE__, __FILE__, $q);
 233              
 234          while($row = $db->sql_fetchrow($r)){
 235              if(eregi(quotemeta($row['word']), $todays_chat))
 236              $todays_chat = str_replace($row['word'], $row['replacement'], $todays_chat);
 237          }
 238                      
 239      #==== Generic BBCode Pass ===================================== |

 240          # Did it this way so i wouldn't have to use bbcode_uid for each post        

 241      $todays_chat    = str_replace('[b]', '<b>', $todays_chat);
 242      $todays_chat    = str_replace('[/b]', '</b>', $todays_chat);
 243      $todays_chat    = str_replace('[i]', '<i>', $todays_chat);
 244      $todays_chat    = str_replace('[/i]', '</i>', $todays_chat);            
 245      
 246      #==== HTML Block Pass ========================================= |

 247          # This is done to prevent stretching the page or a redirect exploit.

 248      $allowed         = '<b><i><a><font>';
 249      $todays_chat    = strip_tags($todays_chat, $allowed);
 250          
 251      #==== Starting Pass =========================================== |    

 252      $todays_chat     = str_replace('%S%', '<tr><td class="row2" align="left" width="100%"><span class="genmed">', $todays_chat);
 253      
 254      #==== Closing Pass ============================================ |    

 255      $todays_chat     = str_replace('%E%', '</span></td></tr>', $todays_chat);
 256  
 257      #==== Smilies Pass ============================================ |

 258      if ($board_config['allow_smilies'])
 259          $todays_chat = smilies_pass($todays_chat);
 260  
 261      #==== Unquote where necessary ===================================== |

 262      $todays_chat = stripslashes($todays_chat);
 263  
 264      $chat_session    = $todays_chat;
 265      $error_messages = ($_POST['err']) ? $_POST['err'] : $HTTP_POST_VARS['err'];
 266      if (!$error_messages)
 267          $error_messages = ($_GET['err']) ? $_GET['err'] : $HTTP_GET_VARS['err'];
 268          
 269      $error_messages = (!$error_messages) ? '' : $error_[$error_messages];
 270  
 271      $template->assign_block_vars('chat_body', array(
 272          'FORM'        => append_sid("adr_global_chat.$phpEx"),
 273          'TOP_L'        => sprintf($lang['Adr_shoutbox_archive'], date('Y-m-d')),
 274          'TOP_M'        => ' : ',
 275          'TOP_R'        => '<a href="'. append_sid('adr_global_chat.'. $phpEx .'?mode=archives') .'">Archives</a>',
 276          'MSG'        => $lang['Adr_shoutbox_enter'],
 277          'BUTTON'    => $lang['Adr_shoutbox_shout'],
 278          'ERROR'        => $error_messages,
 279          'TXT'        => $chat_session,
 280          'U_CHAT_VIEW' => append_sid("adr_global_chat.$phpEx")
 281      ));
 282  }
 283  
 284  $template->assign_vars(array(
 285      'U_CHAT_VIEW' => append_sid("adr_global_chat.$phpEx")
 286  ));
 287  
 288  $template->pparse('body');
 289  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]