[ PHPXref.com ] [ Generated: Sun Jul 20 18:24:42 2008 ] [ Jupiter CMS 1.1.5 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/includes/ -> functions.php (source)

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

   4   Jupiter Content System @ Highstrike.net

   5   Copyright (C) 2005 Cosmin Flavius (highstrike@gmail.com)

   6  

   7   This program is free software; you can redistribute it and/or

   8   modify it under the terms of the GNU General Public License

   9   as published by the Free Software Foundation; either version 2

  10   of the License, or (at your option) any later version.

  11  

  12   More Info About The Licence At http://www.gnu.org/copyleft/gpl.html

  13  ****************************************************************************/
  14  
  15  ////////////////////////////////////////////////////////

  16  // Description: Name and version of script

  17  
  18  $script_name = 'Jupiter CMS';
  19  $script_version = '1.1.5';
  20  
  21  ////////////////////////////////////////////////////////

  22  // Description: Extract info secure & fast

  23  
  24  if ($HTTP_SESSION_VARS) {extract($HTTP_SESSION_VARS, EXTR_SKIP); }
  25  if ($_SESSION) {extract($_SESSION, EXTR_SKIP); }
  26  if ($HTTP_COOKIE_VARS) {extract($HTTP_COOKIE_VARS, EXTR_SKIP); }
  27  if ($_COOKIE) {extract($_COOKIE, EXTR_SKIP); }
  28  if ($HTTP_POST_VARS) {extract($HTTP_POST_VARS, EXTR_SKIP); }
  29  if ($_POST) {extract($_POST, EXTR_SKIP); }
  30  if ($HTTP_GET_VARS) {extract($HTTP_GET_VARS, EXTR_SKIP); }
  31  if ($_GET) {extract($_GET, EXTR_SKIP); }
  32  if ($HTTP_ENV_VARS) {extract($HTTP_ENV_VARS, EXTR_SKIP); }
  33  if ($_ENV) {extract($_ENV, EXTR_SKIP); }
  34  
  35  ////////////////////////////////////////////////////////

  36  // Description: Notice fix

  37  
  38  if(!isset($a)) $a = NULL;    // Action fix

  39  if(!isset($c)) $c = NULL;    // Another Action fix

  40  if(!isset($l)) $l = NULL;    // Poll Action fix

  41  if(!isset($d)) $d = NULL;    // Data fix

  42  if(!isset($o)) $o = NULL;    // Other fix

  43  if(!isset($q)) $q = NULL;    // Another Other fix

  44  if(!isset($k)) $k = NULL;    // Another Another Other fix

  45  if(!isset($i)) $i = NULL;    // Info fix

  46  if(!isset($p)) $p = 1;        // Pagination fix

  47  if(!isset($m)) $m = date('n');    // Calendar fix

  48  
  49  if(!isset($action)) $action = NULL;
  50  if(!isset($template_left)) $template_left = NULL;
  51  if(!isset($session_id)) $session_id = session_id();
  52  if(!isset($layout)) $layout = NULL;
  53  if(!isset($layout2)) $layout2 = NULL;
  54  if(!isset($template_right)) $template_right = NULL;
  55  if(!isset($_SERVER['HTTP_REFERER'])) $_SERVER['HTTP_REFERER'] = NULL;
  56  if(!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
  57  if(!isset($_SESSION['authorization'])) $_SESSION['authorization'] = 0;
  58  
  59  ////////////////////////////////////////////////////////

  60  // Description: Define Authorizations

  61  
  62  if($_SESSION['authorization'] == 0)
  63  {
  64      $is_guest = 1;
  65      $is_user = NULL;
  66      $is_moderator = NULL;
  67      $is_administrator = NULL;
  68      $is_webmaster = NULL;
  69  }
  70  
  71  if($_SESSION['authorization'] == 1)
  72  {
  73      $is_guest = NULL;
  74      $is_user = 1;
  75      $is_moderator = NULL;
  76      $is_administrator = NULL;
  77      $is_webmaster = NULL;
  78  }
  79  
  80  if($_SESSION['authorization'] == 2)
  81  {
  82      $is_guest = NULL;
  83      $is_user = NULL;
  84      $is_moderator = 1;
  85      $is_administrator = NULL;
  86      $is_webmaster = NULL;
  87  }
  88  
  89  if($_SESSION['authorization'] == 3)
  90  {
  91      $is_guest = NULL;
  92      $is_user = NULL;
  93      $is_moderator = NULL;
  94      $is_administrator = 1;
  95      $is_webmaster = NULL;
  96  }
  97  
  98  if($_SESSION['authorization'] == 4)
  99  {
 100      $is_guest = NULL;
 101      $is_user = NULL;
 102      $is_moderator = NULL;
 103      $is_administrator = NULL;
 104      $is_webmaster = 1;
 105  }
 106  
 107  ////////////////////////////////////////////////////////

 108  // Description: Check see if user is loged in or not

 109  
 110  if(isset($is_guest)) $is_loged_in = NULL;
 111  if(isset($is_user) || isset($is_moderator) || isset($is_administrator) || isset($is_webmaster)) $is_loged_in = 1;
 112  
 113  ////////////////////////////////////////////////////////

 114  // Description: Autoexecute these querys

 115  
 116  $badwords_db = $db->getTable("SELECT * FROM badwords");
 117  $emoticons_db = $db->getTable("SELECT * FROM emoticons");
 118  
 119  ////////////////////////////////////////////////////////

 120  // Function:         Message Definition 

 121  // Description: insert messages when called

 122  
 123  function messagedef($message)
 124  {
 125      global $config, $i;
 126      require "language/{$config['language']}";
 127  
 128      if(!isset($output)) $output = NULL;
 129  
 130      if ($i == 1) $output .="$message <span class='alert'>{$language['Message desc']}</span>";
 131      elseif ($i == 2) $output .="$message <span class='alert'>{$language['Message desc2']}</span>";
 132      elseif ($i == 3) $output .="$message <span class='ok'>{$language['Message desc3']} {$_SESSION['username']}</span>";
 133      elseif ($i == 4) $output .="$message <span class='ok'>{$language['Message desc4']}</span>";
 134      elseif ($i == 5) $output .="$message <span class='alert'>{$language['Message desc5']}</span>";
 135      elseif ($i == 6) $output .="$message <span class='alert'>{$language['Message desc6']}</span>";
 136  
 137      elseif ($i == 7) $output .="$message <span class='alert'>{$language['Message desc7']}</span>";
 138      elseif ($i == 8) $output .="$message <span class='alert'>{$language['Message desc8']}</span>";
 139      elseif ($i == 9) $output .="$message <span class='alert'>{$language['Message desc9']}</span>";
 140      elseif ($i == 10) $output .="$message <span class='alert'>{$language['Message desc10']}</span>";
 141      elseif ($i == 11) $output .="$message <span class='alert'>{$language['Message desc11']}</span>";
 142      elseif ($i == 12) $output .="$message <span class='alert'>{$language['Message desc12']}</span>";
 143      elseif ($i == 13) $output .="$message <span class='alert'>{$language['Message desc13']}</span>";
 144      elseif ($i == 14) $output .="$message <span class='ok'>{$language['Message desc14']}</span>";
 145      elseif ($i == 15) $output .="$message <span class='ok'>{$language['Message desc15']}</span>";
 146      elseif ($i == 16) $output .="$message <span class='normal'>{$language['Message desc16']}</span>";
 147      elseif ($i == 17) $output .="$message <span class='alert'>{$language['Message desc17']}</span>";
 148      elseif ($i == 18) $output .="$message <span class='alert'>{$language['Message desc18']}</span>";
 149      elseif ($i == 19) $output .="$message <span class='ok'>{$language['Message desc19']}</span>";
 150      elseif ($i == 20) $output .="$message <span class='ok'>{$language['Message desc20']}</span>";
 151      elseif ($i == 21) $output .="$message <span class='alert'>{$language['Message desc21']}</span>";
 152      elseif ($i == 22) $output .="$message <span class='ok'>{$language['Message desc22']}</span>";
 153      elseif ($i == 23) $output .="$message <span class='alert'>{$language['Message desc23']}</span>";
 154  
 155      elseif ($i == 24) $output .="$message <span class='ok'>{$language['Message desc24']}</span>";
 156      elseif ($i == 25) $output .="$message <span class='ok'>{$language['Message desc25']}</span>";
 157      elseif ($i == 26) $output .="$message <span class='ok'>{$language['Message desc26']}</span>";
 158      elseif ($i == 27) $output .="$message <span class='alert'>{$language['Message desc27']}</span>";
 159      elseif ($i == 28) $output .="$message <span class='alert'>{$language['Message desc28']}</span>";
 160      elseif ($i == 29) $output .="$message <span class='alert'>{$language['Message desc29']}</span>";
 161      elseif ($i == 30) $output .="$message <span class='alert'>{$language['Message desc30']}</span>";
 162      elseif ($i == 31) $output .="$message <span class='alert'>{$language['Message desc31']}</span>";
 163      elseif ($i == 32) $output .="$message <span class='alert'>{$language['Message desc32']}</span>";
 164      elseif ($i == 33) $output .="$message <span class='alert'>{$language['Message desc33']}</span>";
 165      elseif ($i == 34) $output .="$message <span class='alert'>{$language['Message desc34']}</span>";
 166  
 167      elseif ($i == 35) $output .="$message <span class='ok'>{$language['Message desc35']}</span>";
 168      elseif ($i == 36) $output .="$message <span class='ok'>{$language['Message desc36']}</span>";
 169      elseif ($i == 37) $output .="$message <span class='ok'>{$language['Message desc37']}</span>";
 170      elseif ($i == 38) $output .="$message <span class='ok'>{$language['Message desc38']}</span>";
 171  
 172      elseif ($i == 39) $output .="$message <span class='alert'>{$language['Message desc39']}</span>";
 173      elseif ($i == 40) $output .="$message <span class='alert'>{$language['Message desc40']}</span>";
 174      elseif ($i == 41) $output .="$message <span class='ok'>{$language['Message desc41']}</span>";
 175      elseif ($i == 42) $output .="$message <span class='ok'>{$language['Message desc42']}</span>";
 176      elseif ($i == 43) $output .="$message <span class='ok'>{$language['Message desc43']}</span>";
 177  
 178      elseif ($i == 44) $output .="$message <span class='ok'>{$language['Message desc44']}</span>";
 179      elseif ($i == 45) $output .="$message <span class='ok'>{$language['Message desc45']}</span>";
 180      elseif ($i == 46) $output .="$message <span class='ok'>{$language['Message desc46']}</span>";
 181  
 182      elseif ($i == 47) $output .="$message <span class='alert'>{$language['Message desc47']}</span>";
 183      elseif ($i == 48) $output .="$message <span class='alert'>{$language['Message desc48']}</span>";
 184      elseif ($i == 49) $output .="$message <span class='alert'>{$language['Message desc49']}</span>";
 185      elseif ($i == 50) $output .="$message <span class='alert'>{$language['Message desc50']}</span>";
 186      elseif ($i == 51) $output .="$message <span class='alert'>{$language['Message desc51']}</span>";
 187      elseif ($i == 52) $output .="$message <span class='alert'>{$language['Message desc52']}</span>";
 188      elseif ($i == 53) $output .="$message <span class='ok'>{$language['Message desc53']}</span>";
 189      elseif ($i == 54) $output .="$message <span class='ok'>{$language['Message desc54']}</span>";
 190      elseif ($i == 55) $output .="$message <span class='ok'>{$language['Message desc55']}</span>";
 191  
 192      elseif ($i == 56) $output .="$message <span class='ok'>{$language['Message desc56']}</span>";
 193  
 194      elseif ($i == 57) $output .="$message <span class='ok'>{$language['Message desc57']}</span>";
 195      elseif ($i == 58) $output .="$message <span class='ok'>{$language['Message desc58']}</span>";
 196  
 197      elseif ($i == 59) $output .="$message <span class='ok'>{$language['Message desc59']}</span>";
 198      elseif ($i == 60) $output .="$message <span class='ok'>{$language['Message desc60']}</span>";
 199      elseif ($i == 61) $output .="$message <span class='ok'>{$language['Message desc61']}</span>";
 200  
 201      elseif ($i == 62) $output .="$message <span class='alert'>{$language['Message desc62']}</span>";
 202      elseif ($i == 63) $output .="$message <span class='alert'>{$language['Message desc63']}</span>";
 203      elseif ($i == 64) $output .="$message <span class='ok'>{$language['Message desc64']}</span>";
 204      elseif ($i == 65) $output .="$message <span class='alert'>{$language['Message desc65']}</span>";
 205  
 206      elseif ($i == 66) $output .="$message <span class='ok'>{$language['Message desc66']}</span>";
 207      elseif ($i == 67) $output .="$message <span class='ok'>{$language['Message desc67']}</span>";
 208      elseif ($i == 68) $output .="$message <span class='ok'>{$language['Message desc68']}</span>";
 209      elseif ($i == 69) $output .="$message <span class='ok'>{$language['Message desc69']}</span>";
 210      elseif ($i == 70) $output .="$message <span class='alert'>{$language['Message desc70']}</span>";
 211      elseif ($i == 71) $output .="$message <span class='alert'>{$language['Message desc71']}</span>";
 212  
 213      elseif ($i == 72) $output .="$message <span class='ok'>{$language['Message desc72']}</span>";
 214      elseif ($i == 73) $output .="$message <span class='ok'>{$language['Message desc73']}</span>";
 215      elseif ($i == 74) $output .="$message <span class='ok'>{$language['Message desc74']}</span>";
 216      elseif ($i == 75) $output .="$message <span class='alert'>{$language['Message desc75']}</span>";
 217      elseif ($i == 76) $output .="$message <span class='alert'>{$language['Message desc76']}</span>";
 218  
 219      elseif ($i == 77) $output .="$message <span class='alert'>{$language['Message desc77']}</span>";
 220      elseif ($i == 78) $output .="$message <span class='ok'>{$language['Message desc78']}</span>";
 221      elseif ($i == 79) $output .="$message <span class='ok'>{$language['Message desc79']}</span>";
 222      elseif ($i == 80) $output .="$message <span class='ok'>{$language['Message desc80']}</span>";
 223      elseif ($i == 81) $output .="$message <span class='ok'>{$language['Message desc81']}</span>";
 224      elseif ($i == 82) $output .="$message <span class='alert'>{$language['Message desc82']}</span>";
 225      elseif ($i == 83) $output .="$message <span class='alert'>{$language['Message desc83']}</span>";
 226      elseif ($i == 84) $output .="$message <span class='alert'>{$language['Message desc84']}</span>";
 227  
 228      elseif ($i == 85) $output .="$message <span class='ok'>{$language['Message desc85']}</span>";
 229      elseif ($i == 86) $output .="$message <span class='ok'>{$language['Message desc86']}</span>";
 230      elseif ($i == 87) $output .="$message <span class='ok'>{$language['Message desc87']}</span>";
 231      elseif ($i == 88) $output .="$message <span class='alert'>{$language['Message desc88']}</span>";
 232      elseif ($i == 89) $output .="$message <span class='alert'>{$language['Message desc89']}</span>";
 233  
 234      elseif ($i == 91) $output .="$message <span class='alert'>{$language['Message desc91']}</span>";
 235      elseif ($i == 92) $output .="$message <span class='alert'>{$language['Message desc92']}</span>";
 236      elseif ($i == 93) $output .="$message <span class='alert'>{$language['Message desc93']}</span>";
 237      elseif ($i == 94) $output .="$message <span class='alert'>{$language['Message desc94']}</span>";
 238      elseif ($i == 95) $output .="$message <span class='alert'>{$language['Message desc95']}</span>";
 239  
 240      elseif ($i == 96) $output .="$message <span class='alert'>{$language['Message desc96']}</span>";
 241      elseif ($i == 97) $output .="$message <span class='alert'>{$language['Message desc97']}</span>";
 242      elseif ($i == 98) $output .="$message <span class='alert'>{$language['Message desc98']}</span>";
 243      elseif ($i == 99) $output .="$message <span class='alert'>{$language['Message desc99']}</span>";
 244      elseif ($i == 100) $output .="$message <span class='alert'>{$language['Message desc100']}</span>";
 245      elseif ($i == 101) $output .="$message <span class='ok'>{$language['Message desc101']}</span>";
 246      elseif ($i == 102) $output .="$message <span class='alert'>{$language['Message desc102']}</span>";
 247      elseif ($i == 103) $output .="$message <span class='alert'>{$language['Message desc103']}</span>";
 248      elseif ($i == 104) $output .="$message <span class='alert'>{$language['Message desc104']}</span>";
 249      elseif ($i == 105) $output .="$message <span class='alert'>{$language['Message desc105']}</span>";
 250      elseif ($i == 106) $output .="$message <span class='ok'>{$language['Message desc106']}</span>";
 251      elseif ($i == 107) $output .="$message <span class='ok'>{$language['Message desc107']}</span>";
 252      elseif ($i == 108) $output .="$message <span class='alert'>{$language['Message desc108']}</span>";
 253      elseif ($i == 109) $output .="$message <span class='alert'>{$language['Message desc109']}</span>";
 254      elseif ($i == 110) $output .="$message <span class='ok'>{$language['Message desc110']}</span>";
 255      elseif ($i == 111) $output .="$message <span class='ok'>{$language['Message desc111']}</span>";
 256      elseif ($i == 112) $output .="$message <span class='ok'>{$language['Message desc112']}</span>";
 257  
 258      elseif ($i == 113) $output .="$message <span class='alert'>{$language['Message desc113']}</span>";
 259      elseif ($i == 114) $output .="$message <span class='ok'>{$language['Message desc114']}</span>";
 260      elseif ($i == 115) $output .="$message <span class='alert'>{$language['Message desc115']}</span>";
 261      elseif ($i == 116) $output .="$message <span class='ok'>{$language['Message desc116']}</span>";
 262      elseif ($i == 117) $output .="$message <span class='ok'>{$language['Message desc117']}</span>";
 263      elseif ($i == 118) $output .="$message <span class='alert'>{$language['Message desc118']}</span>";
 264      elseif ($i == 119) $output .="$message <span class='ok'>{$language['Message desc119']}</span>";
 265      elseif ($i == 120) $output .="$message <span class='ok'>{$language['Message desc120']}</span>";
 266      elseif ($i == 121) $output .="$message <span class='alert'>{$language['Message desc121']}</span>";
 267      elseif ($i == 122) $output .="$message <span class='alert'>{$language['Message desc122']}</span>";
 268      elseif ($i == 123) $output .="$message <span class='ok'>{$language['Message desc123']}</span>";
 269      elseif ($i == 124) $output .="$message <span class='ok'>{$language['Message desc124']}</span>";
 270      elseif ($i == 125) $output .="$message <span class='alert'>{$language['Message desc125']}</span>";
 271      elseif ($i == 126) $output .="$message <span class='ok'>{$language['Message desc126']}</span>";
 272      elseif ($i == 127) $output .="$message <span class='alert'>{$language['Message desc127']}</span>";
 273      elseif ($i == 128) $output .="$message <span class='alert'>{$language['Message desc128']}</span>";
 274      elseif ($i == 129) $output .="$message <span class='ok'>{$language['Message desc129']}</span>";
 275      elseif ($i == 130) $output .="$message <span class='ok'>{$language['Message desc130']}</span>";
 276      elseif ($i == 131) $output .="$message <span class='alert'>{$language['Message desc131']}</span>";
 277      elseif ($i == 132) $output .="$message <span class='alert'>{$language['Message desc132']}</span>";
 278      elseif ($i == 133) $output .="$message <span class='ok'>{$language['Message desc133']}</span>";
 279  
 280      elseif ($i == 134) $output .="$message <span class='alert'>{$language['Message desc134']}</span>";
 281  
 282      else $output .="$message <span class='normal'>{$language['Message desc00']}</span>";
 283  
 284  return $output;
 285  }
 286  
 287  
 288  ////////////////////////////////////////////////////////

 289  // Function:         jcm_linebreaks

 290  // Description: Convert \r\n and \r to \n

 291  
 292  function jcm_linebreaks($str){ return str_replace("\r", "\n", str_replace("\r\n", "\n", $str)); }
 293  
 294  ////////////////////////////////////////////////////////

 295  // Function:         jcm_stripslashes

 296  // Description: Strip slashes

 297  
 298  function jcm_stripslashes($str){ return (get_magic_quotes_gpc() == 1) ? stripslashes($str) : $str; }
 299  
 300  ////////////////////////////////////////////////////////

 301  // Function:         jcm_strlen

 302  // Description: A more special strlen()

 303  
 304  function jcm_strlen($str){ return strlen(preg_replace('/&#([0-9]+);/', '!', $str)); }
 305  
 306  ////////////////////////////////////////////////////////

 307  // Function:         jcm_htmlspecialchars

 308  // Description: A more special htmlspecialchars()

 309  
 310  function jcm_htmlspecialchars($str)
 311  {
 312      $str = preg_replace('/&(?!#[0-9]+;)/s', '&amp;', $str);
 313      $str = str_replace(array('<', '>', '"'), array('&lt;', '&gt;', '&quot;'), $str);
 314  
 315  return $str;
 316  }
 317  
 318  ////////////////////////////////////////////////////////

 319  // Function:         split_text

 320  // Description: Split the message into tokens

 321  
 322  function split_text($text, $start, $end)
 323  {
 324      $num_spaces = 4;
 325  
 326      $tokens = explode($start, $text);
 327  
 328      $outside[] = $tokens[0];
 329  
 330      $num_tokens = count($tokens);
 331      for ($i = 1; $i < $num_tokens; ++$i)
 332      {
 333          $temp = explode($end, $tokens[$i]);
 334          $inside[] = $temp[0];
 335          $outside[] = $temp[1];
 336      }
 337  
 338      if ($num_spaces != 8 && $start == '[code]')
 339      {
 340          $spaces = str_repeat(' ', $num_spaces);
 341          $inside = str_replace("\t", $spaces, $inside);
 342      }
 343  
 344  return array($inside, $outside);
 345  }
 346  
 347  ////////////////////////////////////////////////////////

 348  // Function:         check_tag_order

 349  // Description: Check for [code] and [quote]

 350  
 351  function check_tag_order($text,$x)
 352  {
 353      // The maximum allowed quote depth

 354      $max_depth = 3;
 355  
 356      while (true)
 357      {
 358          $c_start = strpos($text, '[code]');
 359          $c_end = strpos($text, '[/code]');
 360          $q_start = strpos($text, '[quote]');
 361          $q_end = strpos($text, '[/quote]');
 362  
 363          if (preg_match('#\[quote=(&quot;|"|\'|)(.*)\\1\]#sU', $text, $matches)) $q2_start = strpos($text, $matches[0]);
 364          else $q2_start = 65536;
 365  
 366          if ($c_start === false) $c_start = 65536;
 367          if ($c_end === false) $c_end = 65536;
 368          if ($q_start === false) $q_start = 65536;
 369          if ($q_end === false) $q_end = 65536;
 370  
 371          if (min($c_start, $c_end, $q_start, $q_end, $q2_start) == 65536) break;
 372  
 373          $q3_start = ($q_start < $q2_start) ? $q_start : $q2_start;
 374  
 375          if ($q3_start < min($q_end, $c_start, $c_end))
 376          {
 377              $step = ($q_start < $q2_start) ? 7 : strlen($matches[0]);
 378  
 379              $cur_index += $q3_start + $step;
 380  
 381              if ($q_depth == $max_depth) $overflow_begin = $cur_index - $step;
 382  
 383              ++$q_depth;
 384              $text = substr($text, $q3_start + $step);
 385          }
 386          else if ($q_end < min($q_start, $c_start, $c_end))
 387          {
 388              if ($q_depth == 0){ return $x = 1; exit; }
 389  
 390              $q_depth--;
 391              $cur_index += $q_end+8;
 392  
 393              if ($q_depth == $max_depth) $overflow_end = $cur_index;
 394  
 395              $text = substr($text, $q_end+8);
 396          }
 397          else if ($c_start < min($c_end, $q_start, $q_end))
 398          {
 399              $tmp = strpos($text, '[/code]');
 400              if ($tmp === false){ return $x = 2; exit; }
 401              else $text = substr($text, $tmp+7);
 402  
 403              $cur_index += $tmp+7;
 404          }
 405          else if ($c_end < min($c_start, $q_start, $q_end)){ return $x = 3; exit; }
 406      }
 407  
 408      if ($q_depth > 0){ return $x = 4; exit; }
 409      else if ($q_depth < 0){ return $x = 5; exit; }
 410  
 411  
 412  if (isset($overflow_begin)) return array($overflow_begin, $overflow_end);
 413  else return null;
 414  }
 415  
 416  ////////////////////////////////////////////////////////

 417  // Function:         truncate_url

 418  // Description: Takes care of url

 419  
 420  function truncate_url($url, $link = '')
 421  {
 422      $full_url = $url;
 423      if (strpos($url, 'www.') === 0) $full_url = 'http://'.$full_url;
 424      else if (strpos($url, 'ftp.') === 0) $full_url = 'ftp://'.$full_url;
 425      else if (strpos($url, 'http://') !== 0) $full_url = 'http://'.$full_url;
 426  
 427      $link = ($link == '' || $link == $url) ? ((strlen($url) > 55) ? substr($url, 0 , 39).' ... '.substr($url, -10) : $url) : stripslashes($link);
 428  
 429  return '<a href="'.$full_url.'" target="_blank">'.$link.'</a>';
 430  }
 431  
 432  ////////////////////////////////////////////////////////

 433  // Function:         do_bbcode

 434  // Description: Takes care of bbcode

 435  
 436  function do_bbcode($message)
 437  {
 438      $pattern[] = '#\[b\](.*?)\[/b\]#s';
 439      $pattern[] = '#\[i\](.*?)\[/i\]#s';
 440      $pattern[] = '#\[u\](.*?)\[/u\]#s';
 441      $pattern[] = '#\[font=(.*?)\](.*?)\[/font\]#s';
 442      $pattern[] = '#\[size=(.*?)\](.*?)\[/size\]#s';
 443      $pattern[] = '#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s';
 444      $pattern[] = '#\[left\](.*?)\[/left\]#s';
 445      $pattern[] = '#\[center\](.*?)\[/center\]#s';
 446      $pattern[] = '#\[right\](.*?)\[/right\]#s';
 447      $pattern[] = '#\[list\]#s';
 448      $pattern[] = '#\[/list\]#s';
 449      $pattern[] = '#\[\*\]#s';
 450      $pattern[] = '#\[image=(.*?)\]#s';
 451      $pattern[] = '#\[url\](.*?)\[/url\]#e';
 452      $pattern[] = '#\[url=(.*?)\](.*?)\[/url\]#e';
 453      $pattern[] = '#\[email\](.*?)\[/email\]#';
 454      $pattern[] = '#\[email=(.*?)\](.*?)\[/email\]#';
 455  
 456      $replace[] = '<strong>$1</strong>';
 457      $replace[] = '<em>$1</em>';
 458      $replace[] = '<u>$1</u>';
 459      $replace[] = '<span style="font-family: $1;">$2</span>';
 460      $replace[] = '<span style="font-size: $1pt;">$2</span>';
 461      $replace[] = '<span style="color: $1">$2</span>';
 462      $replace[] = '<div style="text-align: left;">$1</div>';
 463      $replace[] = '<div style="text-align: center;">$1</div>';
 464      $replace[] = '<div style="text-align: right;">$1</div>';
 465      $replace[] = '<ul>';
 466      $replace[] = '</ul>';
 467      $replace[] = '<li>';
 468      $replace[] = '<img src="$1" style="border: none;" alt="">';
 469      $replace[] = 'truncate_url(\'$1\')';
 470      $replace[] = 'truncate_url(\'$1\', \'$2\')';
 471      $replace[] = '<a href="mailto:$1">$1</a>';
 472      $replace[] = '<a href="mailto:$1">$2</a>';
 473  
 474      // This thing takes a while! :)

 475      $message = preg_replace($pattern, $replace, $message);
 476  
 477      if (strpos($message, 'quote') !== false)
 478      {
 479          $message = preg_replace('#\[quote=(&quot;|"|\'|)(.*)\\1\]#seU', '"<div class=\"quote\"><blockquote><h2>".str_replace(\'[\', \'&#91;\', \'$2\')." wrote:</h2>"', $message);
 480          $message = str_replace('[quote]', '<div class="quote"><blockquote><h1>&nbsp;</h1>', $message);
 481          $message = str_replace('[/quote]', '</blockquote></div>', $message);
 482      }
 483  
 484  return $message;
 485  }
 486  
 487  ////////////////////////////////////////////////////////

 488  // Function:         do_clickable

 489  // Description: Takes care of links

 490  
 491  function do_clickable($message)
 492  {
 493      $message = ' '.$message;
 494  
 495      $message = preg_replace('#([\s\(\)])(https?|ftp|news){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^"\s\(\)<\[]*)?)#ie', '\'$1\'.truncate_url(\'$2://$3\')', $message);
 496      $message = preg_replace('#([\s\(\)])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^"\s\(\)<\[]*)?)#ie', '\'$1\'.truncate_url(\'$2.$3\', \'$2.$3\')', $message);
 497  
 498  return substr($message, 1);
 499  }
 500  
 501  ////////////////////////////////////////////////////////

 502  // Function:         do_smilies

 503  // Description: Takes care of emoticons

 504  
 505  function do_smilies($message)
 506  {
 507      global $emoticons_db;
 508  
 509      if($emoticons_db != FALSE)
 510      {
 511          $smilies_path = "images/emoticons";
 512          foreach($emoticons_db as $idx=>$emoticons)
 513          {
 514              $smiley_codes[] = $emoticons['code'];
 515              $smiley_files[] = $emoticons['pic'];
 516          }
 517  
 518          $message = ' '.$message.' ';
 519  
 520          for ($count = 0; $count <= $idx; $count++) 
 521              $message = preg_replace("#(?<=.\W|\W.|^\W)".preg_quote($smiley_codes[$count], '#')."(?=.\W|\W.|\W$)#m", '$1<img src="'.$smilies_path.'/'.$smiley_files[$count].'" alt="'.$smiley_codes[$count].'">$2', $message);
 522  
 523          return substr($message, 1, -1);
 524      }
 525      else return $message;
 526  }
 527  
 528  ////////////////////////////////////////////////////////

 529  // Function:         do_censor

 530  // Description: Takes care of badwords

 531  
 532  function do_censor($message)
 533  {
 534      global $config, $badwords_db;
 535  
 536      if($badwords_db != FALSE)
 537      {
 538          foreach($badwords_db as $idx=>$badwords)
 539          {
 540              $badword[] = $badwords['word'];
 541              $wordreplacment[] = $badwords['replacement'];
 542          }
 543  
 544          $message = ' '.$message.' ';
 545      
 546          for ($count = 0; $count <= $idx; $count++)
 547          {
 548              if($config['badword_mode'] == 1) $message = preg_replace ( '#'.$badword[$count].'#i', ''.$wordreplacment[$count].'', $message );
 549              else $message = preg_replace ( '#'.$badword[$count].'#i', str_pad ( '', strlen ( $badword[$count] ), '*' ), $message );
 550          }
 551  
 552          return substr($message, 1, -1);
 553      }
 554      else return $message;
 555  }
 556  
 557  ////////////////////////////////////////////////////////

 558  // Function:         parse_char

 559  // Description: Replaces charactars + adds bb and sm

 560  
 561  function parse_message($message)
 562  {
 563      global $config;
 564  
 565      $message = jcm_htmlspecialchars($message);
 566  
 567      if (strpos($message, '[url]') !== false && strpos($message, '[/url]') !== false)
 568          $message = cuttext($message,115);
 569  
 570      if (strpos($message, '[code]') !== false && strpos($message, '[/code]') !== false)
 571      {
 572          list($inside, $outside) = split_text($message, '[code]', '[/code]');
 573          $outside = array_map('trim', $outside);
 574          $message = implode('<">', $outside);
 575      }
 576  
 577      if ($config['badwords'] == 1)
 578          $message = do_censor($message);
 579  
 580      $message = do_clickable($message);
 581  
 582      if ($config['emoticons'] == 1)
 583          $message = do_smilies($message);
 584  
 585      if ($config['bbcode'] == 1 && strpos($message, '[') !== false && strpos($message, ']') !== false)
 586          $message = do_bbcode($message);
 587  
 588      $pattern = array("\n", "\t", '  ', '  ');
 589      $replace = array('<br>', '&nbsp; &nbsp; ', '&nbsp; ', ' &nbsp;');
 590      $message = str_replace($pattern, $replace, $message);
 591  
 592      if (isset($inside))
 593      {
 594          $outside = explode('<">', $message);
 595          $message = '';
 596  
 597          $num_tokens = count($outside);
 598  
 599          for ($i = 0; $i < $num_tokens; $i++)
 600          {
 601              $message .= $outside[$i];
 602              if (isset($inside[$i])) $message .= '<div class="code"><blockquote><h2>Code:</h2><font size="3"><pre>'.trim($inside[$i]).'</pre></font></blockquote></div>';
 603          }
 604      }
 605  
 606  return $message;
 607  }
 608  
 609  ////////////////////////////////////////////////////////

 610  // Function:         dis_bb_em

 611  // Description: Status on BBcode and Emoticons Global

 612  
 613  function dis_bb_em($ex=false)
 614  {
 615      global $config;
 616      require "language/{$config['language']}";
 617  
 618      if($config['bbcode'] == 1) $bbcode = "<span class='ok'>{$language['Enabled']}</span>";
 619      else $bbcode = "<span class='alert'>{$language['Disabled']}</span>";
 620  
 621      if($config['emoticons'] == 1) $emoticons = "<span class='ok'>{$language['Enabled']}</span>";
 622      else $emoticons = "<span class='alert'>{$language['Disabled']}</span>";
 623  
 624      if($config['badwords'] == 1) $badwords = "<span class='ok'>{$language['Enabled']}</span>";
 625      else $badwords = "<span class='alert'>{$language['Disabled']}</span>";
 626  
 627      if($ex == "true") $spaces = "<br><br><br><br><br><br>";
 628      else $spaces = "<br><br><br>";
 629  
 630      $output = "$spaces<a href='?n=modules/misc&a=2'>{$language['BBcode']}</a> > $bbcode<br><a href='?n=modules/misc&a=3'>{$language['Emoticons']}</a> > $emoticons<br><a href='?n=modules/misc&a=4'>{$language['Badwords']}</a> > $badwords";
 631  
 632  return $output;
 633  }
 634  
 635  ////////////////////////////////////////////////////////

 636  // Function:         insertBBcode

 637  // Description: insert bbcode

 638  
 639  function insertBBcode($break_location = FALSE)
 640  {
 641      global $config;
 642      require "language/{$config['language']}";
 643  
 644      $bbcodes_path = "templates/{$config['template']}/images/codes";
 645      $bbcode_codes = array("[b]Text[/b]","[i]Text[/i]","[u]Text[/u]","[font=verdana]Text[/font]","[size=2]Text[/size]","[color=red]Text[/color]","[left]text[/left]","[center]text[/center]","[right]text[/right]","[list][*]Text1[*]Text2[/list]","[quote=Name]Text[/quote]","[code]Text[/code]","[image=URL]","[url=URL]Text[/url]","[email=URL]Text[/email]");
 646      $bbcode_files = array("bold.gif","italic.gif","underline.gif","fontface.gif","fontsize.gif","color.gif","fontleft.gif","fontcenter.gif","fontright.gif","list.gif","quote.gif","code.gif","img.gif","url.gif","email.gif");
 647      $bbcode_alt = array($language['BBcode desc'],$language['BBcode desc2'],$language['BBcode desc3'],$language['BBcode desc4'],$language['BBcode desc5'],$language['BBcode desc6'],$language['BBcode desc7'],$language['BBcode desc8'],$language['BBcode desc9'],$language['BBcode desc10'],$language['BBcode desc11'],$language['BBcode desc12'],$language['BBcode desc13'],$language['BBcode desc14'],$language['BBcode desc15']);
 648  
 649      foreach($bbcode_codes as $idx=>$code)
 650      {
 651          if(!isset($h)) $h = 1;
 652          if(!isset($output)) $output = NULL;
 653  
 654          if($config['bbcode'] == 1) $output .="<a href=\"Javascript:insertext('$code')\"><img style=\"border: none;\" src=\"$bbcodes_path/{$bbcode_files[$idx]}\" alt=\"{$bbcode_alt[$idx]}\"></a>";
 655          else $output .="<img style=\"border: none;\" src=\"$bbcodes_path/{$bbcode_files[$idx]}\" alt=\"{$language['Disabled']}\">";
 656  
 657          if($h % $break_location == 0 and $break_location) $output .= "<br>";
 658          else $output .= "";
 659  
 660          $h++;
 661      }
 662  
 663  return $output;
 664  }
 665  
 666  ////////////////////////////////////////////////////////

 667  // Function:         insertSmilies

 668  // Description: insert smilies

 669  
 670  function insertSmilies($break_location = FALSE)
 671  {
 672      global $config, $emoticons_db;
 673      require "language/{$config['language']}";
 674  
 675      $smilies_path = "images/emoticons";
 676  
 677      if($emoticons_db != FALSE)
 678      {
 679          foreach($emoticons_db as $emoticons)
 680          {
 681              $smiley_codes[] = $emoticons['code'];
 682              $smiley_files[] = $emoticons['pic'];
 683          }
 684  
 685          foreach($smiley_codes as $idx=>$code)
 686          {
 687              if(!isset($h)) $h = 1;
 688              if(!isset($output)) $output = NULL;
 689  
 690              if($config['bbcode'] == 1) $output .="<a href=\"Javascript:insertext('$code')\"><img style=\"border: none;\" src=\"$smilies_path/{$smiley_files[$idx]}\" alt=\"{$smiley_codes[$idx]}\"></a>";
 691              else  $output .="<img style=\"border: none;\" src=\"$smilies_path/{$smiley_files[$idx]}\" alt=\"{$language['Disabled']}\">";
 692  
 693              if($h % $break_location == 0 and $break_location) $output .= "<br>";
 694              else $output .= "";
 695  
 696              $h++;
 697          }
 698      }
 699      else $output = $language['No Emoticons'];
 700  
 701  return $output;
 702  }
 703  
 704  ////////////////////////////////////////////////////////

 705  // Function:         find_ip

 706  // Description: Shows the ip

 707  
 708  function find_ip()
 709  {
 710      if (getenv('HTTP_CLIENT_IP')) $ip = getenv('HTTP_CLIENT_IP');
 711      elseif (getenv('HTTP_X_FORWARDED_FOR')) $ip = getenv('HTTP_X_FORWARDED_FOR');
 712      elseif (getenv('HTTP_X_FORWARDED')) $ip = getenv('HTTP_X_FORWARDED');
 713      elseif (getenv('HTTP_FORWARDED_FOR')) $ip = getenv('HTTP_FORWARDED_FOR');
 714      elseif (getenv('HTTP_FORWARDED')) $ip = getenv('HTTP_FORWARDED');
 715      else $ip = $_SERVER['REMOTE_ADDR'];
 716  
 717  return $ip; 
 718  }
 719  
 720  ////////////////////////////////////////////////////////

 721  // Function:         find_browser

 722  // Description: Shows the browser or bots

 723  
 724  function find_browser($browser_def)
 725  {
 726      if (!(strpos($browser_def,'Mozilla') === false))
 727      {
 728          if (!(strpos($browser_def,'Opera') === false)) $browser = 'Opera';
 729          elseif (!(strpos($browser_def,'Firefox') === false)) $browser = 'Firefox';
 730          elseif (!(strpos($browser_def,'Netscape') === false)) $browser = 'Netscape';
 731          elseif (!(strpos($browser_def,'MSIE') === false)) $browser = 'Internet Explorer';
 732          else $browser = 'Other browser';
 733      }
 734      else
 735      {
 736          if (!(strpos($browser_def,'Google') === false)) $browser = 'Google Bot';
 737          elseif (!(strpos($browser_def,'msn') === false)) $browser = 'Msn Bot';
 738          else $browser = 'Other bot';
 739      }
 740  
 741  return $browser;
 742  }
 743  
 744  ////////////////////////////////////////////////////////

 745  // Function:         generate_code

 746  // Description: This function generates a random code

 747  
 748  function generate_code($length = 8, $seeds = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')
 749  {
 750      $str = '';
 751      $seeds_count = strlen($seeds);
 752  
 753      list($usec, $sec) = explode(' ', microtime());
 754      $seed = (float) $sec + ((float) $usec * 100000);
 755      mt_srand($seed);
 756  
 757      for ($i = 0; $length > $i; $i++)
 758          $str .= $seeds{mt_rand(0, $seeds_count - 1)};
 759   
 760  return $str;
 761  }
 762  
 763  ////////////////////////////////////////////////////////

 764  // Function:         send_email

 765  // Description: This function sends mails to destination

 766  
 767  function send_email($dat)
 768  {
 769      global $config, $template;
 770  
 771      $website_name = $config['website_name'];
 772      $website_url = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
 773      $webmaster_name = $config['webmaster_name'];
 774      $webmaster_email = $config['webmaster_email'];
 775  
 776      switch($dat['reason'])
 777      {
 778          case 'activate':
 779  
 780              $subject = "$website_name | Activation";
 781  
 782              $body = implode("", file("templates/$template/email/act.php"));
 783              $body = str_replace("{username}", $dat['username'], $body);
 784              $body = str_replace("{date}", date("l, d F Y - h:i:s",$dat['actime']), $body);
 785              $body = str_replace("{link}", $website_url."?n=modules/register&a=2&key=".$dat['multikey'], $body);
 786              $body = str_replace("{key}", $dat['multikey'], $body);
 787              $body = str_replace("{website_name}", $website_name, $body);
 788              $body = str_replace("{webmaster_name}", $webmaster_name, $body);
 789              $body = str_replace("{webmaster_email}", $webmaster_email, $body);
 790  
 791          break;
 792  
 793          case 'forgot':
 794  
 795              $subject = "$website_name | Forgotten Password";
 796  
 797              $body = implode("", file("templates/$template/email/fpw.php"));
 798              $body = str_replace("{username}", $dat['username'], $body);
 799              $body = str_replace("{date}", date("l, d F Y - h:i:s",$dat['actime']), $body);
 800              $body = str_replace("{link}", $website_url."?n=modules/register&a=3&d=3&key=".$dat['multikey'], $body);
 801              $body = str_replace("{website_name}", $website_name, $body);
 802              $body = str_replace("{webmaster_name}", $webmaster_name, $body);
 803              $body = str_replace("{webmaster_email}", $webmaster_email, $body);
 804  
 805          break;
 806      }
 807  
 808      $headers ="";
 809      $headers.="From: \"".$webmaster_name."\" <".$webmaster_email.">\n"; 
 810      $headers.="Return-Path: $webmaster_email\n";
 811      $headers.="X-Priority: 3\n"; 
 812      $headers.="X-Mailer: $website_name Server\n";
 813  
 814      // send out the message

 815      mail($dat['email'], $subject, $body, $headers);
 816  }
 817  
 818  ////////////////////////////////////////////////////////

 819  // Function:         cuttext

 820  // Description: Cuts a string and adds ..

 821  
 822  function cuttext($value,$lenght)
 823  {
 824      if (strlen($value) >= $lenght )
 825      {
 826          $limited = substr($value,0,$lenght);
 827          $limited .= "...";                 
 828      }
 829      else
 830          $limited = $value;
 831  
 832  return $limited;
 833  }
 834  
 835  ////////////////////////////////////////////////////////

 836  // Function:         row2color

 837  // Description: Shows the results on 2 colors

 838  
 839  function row2color($id_def)
 840  {
 841      if ($id_def/2 == round($id_def/2)) $row = "con1";
 842      else $row = "con2";
 843  
 844  return $row;
 845  }
 846  
 847  ////////////////////////////////////////////////////////

 848  // Function:         today_yesterday

 849  // Description: Function for Today and Yesterday

 850  
 851  function today_yesterday($time,$ex=false)
 852  {
 853      global $config;
 854      require "language/{$config['language']}";
 855  
 856      $today = date("d/m/y",time());
 857      $yesterday = date("d/m/y",time() - 86400);
 858  
 859      if($ex == "true")
 860      {
 861          if ($today == date("d/m/y",$time)) $date = "{$language['Time today']} ".date("h:i:s A", $time)."";
 862          elseif ($yesterday == date("d/m/y",$time)) $date = "{$language['Time yesterday']} ".date("h:i:s A", $time)."";
 863          else $date = date("d/m/y h:i:s A", $time);
 864      }
 865      else
 866      {
 867          if ($today == date("d/m/y",$time)) $date = "{$language['Time today']} - ".date("h:i:s A", $time)."";
 868          elseif ($yesterday == date("d/m/y",$time)) $date = "{$language['Time yesterday']} - ".date("h:i:s A", $time)."";
 869          else $date = date("d/m/y - h:i:s A", $time);
 870      }
 871  
 872  return $date;
 873  }
 874  
 875  ////////////////////////////////////////////////////////

 876  // Function:         last_visit

 877  // Description: Calculates the last visit

 878  
 879  function last_visit($time,$regtime=false)
 880  {
 881      global $config;
 882      require "language/{$config['language']}";
 883  
 884      if($time == $regtime)
 885          $finish = $language['Time Definition Never'];
 886      else
 887      {
 888          $day = date("d",$time);
 889          $month = date("m",$time);
 890          $year = date("Y",$time);
 891          $hours = date("H",$time);
 892          $minutes = date("i",$time);
 893          $seconds = date("s",$time);
 894  
 895          $date = time() - mktime($hours, $minutes, $seconds, $month, $day, $year);
 896  
 897          if (!is_array($date))
 898          {
 899              $periods = array ($language['Time Definition Years'] => 31556926,$language['Time Definition Months'] => 2629743,$language['Time Definition Days'] => 86400,$language['Time Definition Hours'] => 3600,$language['Time Definition Minutes'] => 60,$language['Time Definition Seconds'] => 1);
 900  
 901              $date = (int) $date;
 902              foreach ($periods as $period => $value)
 903              {
 904                  $count = floor($date / $value);
 905   
 906                  if ($count == 0)
 907                      continue;
 908   
 909                  $values[$period] = $count;
 910                  $date = $date % $value;
 911              }
 912   
 913                  if (empty($values))
 914                  $values = null;
 915   
 916              $date = $values;
 917          }
 918  
 919          if (!is_array($date))
 920              return false;
 921   
 922          foreach ($date as $key => $value)
 923          {
 924              $segment = $value . ' ' . $key; 
 925   
 926              if ($value == 1)
 927              {
 928                  if($key == $language['Time Definition Years']) $segment = $value . ' ' . $language['Time Definition Year'];
 929                  if($key == $language['Time Definition Months']) $segment = $value . ' ' . $language['Time Definition Month'];
 930                  if($key == $language['Time Definition Weeks']) $segment = $value . ' ' . $language['Time Definition Week'];
 931                  if($key == $language['Time Definition Days']) $segment = $value . ' ' . $language['Time Definition Day'];
 932                  if($key == $language['Time Definition Hours']) $segment = $value . ' ' . $language['Time Definition Hour'];
 933                  if($key == $language['Time Definition Minutes']) $segment = $value . ' ' . $language['Time Definition Minute'];
 934                  if($key == $language['Time Definition Seconds']) $segment = $value . ' ' . $language['Time Definition Second'];
 935              }
 936   
 937              $array[] = $segment;
 938          }
 939   
 940          $result = implode(', ', $array);
 941          $finish = $result." {$language['HQ user desc7']}";
 942      }
 943  
 944  return $finish;
 945  }
 946  
 947  ////////////////////////////////////////////////////////

 948  // Function:         find_country

 949  // Description: insert country for user detalies

 950  
 951  function find_country($name=false,$type=false)
 952  {
 953      if(!isset($list)) $list = NULL;
 954  
 955      $c = array ("none" => "Not Specified","af" => "Afghanistan","al" => "Albania","dz" => "Algeria","ao" => "Angola","ar" => "Argentina","am" => "Armenia","aw" => "Aruba","au" => "Australia","at" => "Austria","az" => "Azerbaijan","bs" => "Bahamas","bh" => "Bahrain","bd" => "Bangladesh","bb" => "Barbados","by" => "Belarus","be" => "Belgium","bz" => "Belize","bj" => "Benin","bm" => "Bermuda","bt" => "Bhutan","bo" => "Bolivia","ba" => "Bosnia And Herzegovina","bw" => "Botswana","br" => "Brazil","bn" => "Brunei Darussalam","bg" => "Bulgaria","bf" => "Burkina Faso","bi" => "Burundi","kh" => "Cambodia","cm" => "Cameroon","ca" => "Canada","cv" => "Cape Verde","ky" => "Cayman Islands","cf" => "Central African Republic","cl" => "Chile","cn" => "China","co" => "Colombia","cg" => "Congo","ck" => "Cook Islands","cr" => "Costa Rica","ci" => "Cote D'Ivoire","hr" => "Croatia","cu" => "Cuba","cy" => "Cyprus","cz" => "Czech Republic","dk" => "Denmark","tp" => "East Timor","ec" => "Ecuador","eg" => "Egypt","er" => "Eritrea","ee" => "Estonia","et" => "Ethiopia","fo" => "Faroe Islands","fj" => "Fiji","fi" => "Finland","fr" => "France","pf" => "French Polynesia","ga" => "Gabon","ge" => "Georgia","de" => "Germany","gi" => "Gibraltar","gr" => "Greece","gl" => "Greenland","gp" => "Guadeloupe","gu" => "Guam","gt" => "Guatemala","gy" => "Guyana","ht" => "Haiti","va" => "Holy See (Vatican City State)","hk" => "Hong Kong","hu" => "Hungary","is" => "Iceland","in" => "India","id" => "Indonesia","ir" => "Iran","iq" => "Iraq","ie" => "Ireland","il" => "Israel","it" => "Italy","jm" => "Jamaica","jp" => "Japan","jo" => "Jordan","kz" => "Kazakstan","ke" => "Kenya","ki" => "Kiribati","kp" => "Korea, Democratic People'S Republic Of","kr" => "Korea, Republic Of","kg" => "Kyrgyzstan","lv" => "Latvia","lb" => "Lebanon","ly" => "Libyan Arab Jamahiriya","lt" => "Lithuania","lu" => "Luxembourg","mo" => "Macau","mk" => "Macedonia","mg" => "Madagascar","my" => "Malaysia","mt" => "Malta","mx" => "Mexico","md" => "Moldova, Republic Of","mc" => "Monaco","mn" => "Mongolia","ms" => "Montserrat","ma" => "Morocco","mz" => "Mozambique","na" => "Namibia","nr" => "Nauru","np" => "Nepal","nl" => "Netherlands","an" => "Netherlands Antilles","nc" => "New Caledonia","nz" => "New Zealand","nf" => "Norfolk Island","mp" => "Northern Mariana Islands","no" => "Norway","om" => "Oman","pk" => "Pakistan","ps" => "Palestinian Territory, Occupied","pa" => "Panama","py" => "Paraguay","pe" => "Peru","ph" => "Philippines","pl" => "Poland","pt" => "Portugal","pr" => "Puerto Rico","qa" => "Qatar","ro" => "Romania","ru" => "Russian Federation","lc" => "Saint Lucia","pm" => "Saint Pierre And Miquelon","ws" => "Samoa","sa" => "Saudi Arabia","sl" => "Sierra Leone","sg" => "Singapore","sk" => "Slovakia","si" => "Slovenia","sb" => "Solomon Islands","so" => "Somalia","za" => "South Africa","es" => "Spain","lk" => "Sri Lanka","sd" => "Sudan","se" => "Sweden","ch" => "Switzerland","sy" => "Syrian Arab Republic","tw" => "Taiwan, Province Of China","tz" => "Tanzania, United Republic Of","th" => "Thailand","tg" => "Togo","to" => "Tonga","tt" => "Trinidad And Tobago","tn" => "Tunisia","tr" => "Turkey","tc" => "Turks And Caicos Islands","tv" => "Tuvalu","ug" => "Uganda","ua" => "Ukraine","uk" => "United Kingdom","us" => "United States","uy" => "Uruguay","ve" => "Venezuela","vn" => "Viet Nam","vg" => "Virgin Islands, British","vi" => "Virgin Islands, U.S.","ye" => "Yemen","yu" => "Yugoslavia","zw" => "Zimbabwe");
 956  
 957      if(!$type)
 958      {
 959          foreach ($c as $k => $v)
 960          {
 961              if($k == "$name") $selected = "selected";
 962              else $selected = "";
 963  
 964              if($k == "none") $v = NULL;
 965  
 966              $list .= "<option value='$k' $selected>$v</option>\n";
 967          }
 968      }
 969      else
 970          foreach ($c as $k => $v)
 971              if($k == "$name") $list = $v;
 972  
 973  return $list;
 974  }
 975  
 976  ////////////////////////////////////////////////////////

 977  // Function:         find_authorization

 978  // Description: Shows the authorization

 979  
 980  function find_authorization($authorization)
 981  {
 982      global $config;
 983      require "language/{$config['language']}";
 984  
 985      switch($authorization)
 986      {
 987          case 1: $user_authorization = $language['Authorization 1']; break;
 988          case 2: $user_authorization = $language['Authorization 2']; break;
 989          case 3: $user_authorization = $language['Authorization 3']; break;
 990          case 4: $user_authorization = $language['Authorization 4']; break;
 991      }
 992  
 993  return $user_authorization;
 994  }
 995  
 996  ////////////////////////////////////////////////////////

 997  // Function:         find_age

 998  // Description: Find age 

 999  
1000  function find_age($age,$surplus=false)
1001  {
1002      if(!$age == NULL)
1003      {
1004          if(!$surplus) $diff = (date("Y") - date("Y",$age));
1005          else $diff = ((date("Y") + $surplus) - date("Y",$age));
1006  
1007          if (mktime(0,0,0,date("m",$age),date("j",$age),date("Y")) <= time()) $finish = $diff;
1008          else $finish = $diff - 1;
1009      }
1010      else $finish = NULL;
1011  
1012  return $finish;
1013  }
1014  
1015  ////////////////////////////////////////////////////////

1016  // Function:         find_avatar

1017  // Description: Shows the avatar

1018  
1019  function find_avatar($avatar_def)
1020  {
1021      if(isset($avatar_def)) $avatar = "<img src='images/avatars/$avatar_def' border='0' alt=''>";
1022      else $avatar = NULL;
1023  
1024  return $avatar;
1025  }
1026  
1027  ////////////////////////////////////////////////////////

1028  // Function:         find_flag

1029  // Description: Shows the flag

1030  
1031  function find_flag($flag_def,$location_def,$name=false,$none=false)
1032  {
1033      if(!$flag_def) $flag = "<img src='images/flags/none.gif' alt='$location_def'>";
1034      elseif($flag_def == "none" && $none == true) $flag = NULL;
1035      else $flag = "<img src='images/flags/$flag_def.gif' alt='".find_country($flag_def,1)."'>";
1036  
1037      if($name == true)
1038      {
1039          if(!$flag_def) $flag .= " $location_def";
1040          elseif($flag_def == "none" && $none == true) $flag .= NULL;
1041          else $flag .= " ".find_country($flag_def,1)."";
1042      }
1043  
1044  return $flag;
1045  }
1046  
1047  ////////////////////////////////////////////////////////

1048  // Function:         find_status

1049  // Description: Shows the status

1050  
1051  function find_status($status_def)
1052  {
1053      global $config;
1054      require "language/{$config['language']}";
1055  
1056      if($status_def  == "banned") $status = "<font color='red'>{$language['Users view desc3']}</font>";
1057      elseif($status_def  == "activate") $status = "<font color='orange'>{$language['Users view desc2']}</font>";
1058      else $status = "<font color='green'>{$language['Users view desc']}</font>";
1059  
1060  return $status;
1061  }
1062  
1063  ////////////////////////////////////////////////////////

1064  // Function:         arrow_legend

1065  // Description: Shows the arrows by date

1066  
1067  function arrow_legend($date_def)
1068  {
1069      $stat_one = time() - 86400; // a day

1070      $stat_two = time() - 259200; // 3 days

1071      $stat_three = time() - 604800; // a week

1072  
1073      if ($date_def > $stat_one) $stat = 1;
1074      elseif ($date_def > $stat_two) $stat = 2;
1075      elseif ($date_def > $stat_three) $stat = 3;
1076      else $stat = 4;
1077  
1078  return $stat;
1079  }
1080  
1081  ////////////////////////////////////////////////////////

1082  // Function:         paginate

1083  // Description: Display the [ 1 2 3 ] and [1] [2] [3]

1084  
1085  function paginate($num_pages, $cur_page, $link_to, $forum_type=false)
1086  {
1087      $pages = array();
1088      $link_to_all = false;
1089  
1090      if ($num_pages <= 1)
1091      {
1092          if($forum_type == "true") $pages = array('<td class="pagelink">1</td>');
1093          else $pages = array('<strong><u>1</u></strong>');
1094      }
1095      else
1096      {
1097          if ($cur_page > 3)
1098          {
1099              if($forum_type == "true")
1100              {
1101                  $pages[] = '<td class="pagelink"><a href="'.$link_to.'&amp;p=1">1</a></td>';
1102                  if ($cur_page != 4) $pages[] = '<td class="pagelink">&hellip;</td>';
1103              }
1104              else
1105              {
1106                  $pages[] = '<a href="'.$link_to.'&amp;p=1">1</a>';
1107                  if ($cur_page != 4) $pages[] = '&hellip;';
1108              }
1109          }
1110  
1111          for ($current = $cur_page - 2, $stop = $cur_page + 3; $current < $stop; ++$current)
1112          {
1113              if ($current < 1 || $current > $num_pages) continue;
1114              elseif ($current != $cur_page || $link_to_all)
1115              {
1116                  if($forum_type == "true") $pages[] = '<td class="pagelink"><a href="'.$link_to.'&amp;p='.$current.'">'.$current.'</a></td>';
1117                  else $pages[] = '<a href="'.$link_to.'&amp;p='.$current.'">'.$current.'</a>';
1118              }
1119              else
1120              {
1121                  if($forum_type == "true") $pages[] = '<td class="pagecurrent">'.$current.'</td>';
1122                  else $pages[] = '<strong><u>'.$current.'</u></strong>';
1123              }
1124          }
1125  
1126          if ($cur_page <= ($num_pages-3))
1127          {
1128              if($cur_page != ($num_pages-3))
1129              {
1130                  if($forum_type == "true") $pages[] = '<td class="pagelink">&hellip;</td>';
1131                  else $pages[] = '&hellip;';
1132              }
1133  
1134              if($forum_type == "true") $pages[] = '<td class="pagelink"><a href="'.$link_to.'&amp;p='.$num_pages.'">'.$num_pages.'</a></td>';
1135              else $pages[] = '<a href="'.$link_to.'&amp;p='.$num_pages.'">'.$num_pages.'</a>';
1136          }
1137      }
1138  
1139  if($forum_type == "true") return implode('<td>&nbsp;</td>', $pages);
1140  else return implode('&nbsp;', $pages);
1141  }
1142  
1143  ////////////////////////////////////////////////////////

1144  // Function:         form_dropdown

1145  // Description: dropdown list from directory

1146  
1147  function form_dropdown($name, $list=array(), $default_val, $slot1, $slot2, $slot3)
1148  {
1149      if(!isset($output)) $output = NULL;
1150      $output .= "<select name='$name' $slot1 $slot2 $slot3>";
1151  
1152      foreach ($list as $k => $v)
1153      {
1154          $selected = "";
1155  
1156          if ($default_val != "" && $v[0] == $default_val) $selected = ' selected';
1157  
1158          $output .= "<option value='".$v[0]."'".$selected.">".$v[1]."</option>";
1159      }
1160  
1161      $output .= "</select>";
1162  
1163  return $output;
1164  }
1165  
1166  ?>


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