/inc/conf/conf.functions.php

https://bitbucket.org/wopkevries/blizzlike-313-website · PHP · 901 lines · 450 code · 98 blank · 353 comment · 84 complexity · 1a8ca20f293414fa0cc743f7c29116d0 MD5 · raw file

  1. <?php
  2. if (INCLUDED!==true) { include('index.htm'); exit; }
  3. function addslashall() {
  4. foreach ($_POST as $key=>$value) {
  5. if (is_array($value)) {
  6. foreach ($value as $key2=>$value2) {
  7. $_POST[$key][$key2] = addslashes($value2);
  8. }
  9. } else {
  10. $_POST[$key] = addslashes($value);
  11. }
  12. }
  13. foreach ($_REQUEST as $key=>$value) {
  14. $_REQUEST[$key] = addslashes($value);
  15. }
  16. }
  17. addslashall(); // Prevents SQL Injection
  18. function remslashall() {
  19. foreach ($_POST as $key=>$value) {
  20. if (is_array($value)) {
  21. foreach ($value as $key2=>$value2) {
  22. $_POST[$key][$key2] = stripslashes($value2);
  23. }
  24. } else {
  25. $_POST[$key] = stripslashes($value);
  26. }
  27. }
  28. foreach ($_REQUEST as $key=>$value) {
  29. $_REQUEST[$key] = stripslashes($value);
  30. }
  31. }
  32. function newdbsettings($h, $pt, $u, $pw, $db) {
  33. $fh = fopen('inc/conf/conf.database.php', 'w');
  34. if ($fh) {
  35. $stringData = "<?php
  36. if (INCLUDED!==true) { include('index.htm'); exit; }
  37. \$MySQL_Set = array(
  38. 'HOST' => '".$h."',
  39. 'PORT' => '".$pt."',
  40. 'USERNAME' => '".$u."',
  41. 'PASSWORD' => '".$pw."',
  42. 'DBREALM' => '".$db."',
  43. );
  44. \$MySQL_CON = @mysql_connect(\$MySQL_Set['HOST'].':'.\$MySQL_Set['PORT'], \$MySQL_Set['USERNAME'], \$MySQL_Set['PASSWORD']);
  45. if (!\$MySQL_CON) { \$haserrors.=mysql_error().'<br>'; }
  46. \$MySQL_DB = @mysql_select_db(\$MySQL_Set['DBREALM'], \$MySQL_CON);
  47. if (!\$MySQL_DB) { \$haserrors.=mysql_error().'<br>'; }
  48. ?>";
  49. fwrite($fh, $stringData);
  50. fclose($fh);
  51. return true;
  52. } else {
  53. return false;
  54. }
  55. }
  56. function bbcode($str, $entities=true, $null=true, $isbb=true, $issmile=true) {
  57. if ($entities) $str = htmlentities($str);
  58. if ($null) $str = nl2br($str);
  59. if ($isbb==true) {
  60. $simple_search = array(
  61. //By Me TAGS
  62. '/\[indent\=([1-3])\](.*?)\[\/indent\]/is',
  63. '/\[community\](.*?)\[\/community\]/is',
  64. '/\[youtube\](.*?)youtube\.com\/watch\?v\=(.*?)\[\/youtube\]/is',
  65. //added line break
  66. '/\[hr\]/is',
  67. '/\[b\](.*?)\[\/b\]/is',
  68. '/\[i\](.*?)\[\/i\]/is',
  69. '/\[u\](.*?)\[\/u\]/is',
  70. // added nofollow to prevent spam
  71. '/\[anchor\=(.*?)\](.*?)\[\/anchor\]/is',
  72. '/\[url\=(.*?)\](.*?)\[\/url\]/is',
  73. '/\[url\](.*?)\[\/url\]/is',
  74. '/\[left\](.*?)\[\/left\]/is',
  75. '/\[right\](.*?)\[\/right\]/is',
  76. '/\[center\](.*?)\[\/center\]/is',
  77. //added alt attribute for validation
  78. '/\[img\](.*?)\[\/img\]/is',
  79. '/\[email\=(.*?)\](.*?)\[\/email\]/is',
  80. '/\[email\](.*?)\[\/email\]/is',
  81. '/\[font\=(.*?)\](.*?)\[\/font\]/is',
  82. '/\[size\=(.*?)\](.*?)\[\/size\]/is',
  83. '/\[color\=(.*?)\](.*?)\[\/color\]/is',
  84. //added textarea for code presentation
  85. '/\[codearea\](.*?)\[\/codearea\]/is',
  86. //added pre class for code presentation
  87. '/\[code\](.*?)\[\/code\]/is',
  88. //added paragraph
  89. '/\[p\](.*?)\[\/p\]/is',
  90. '/\[quote\](.*?)\[\/quote\]/is',
  91. //By Me REPS
  92. '/\%SITENAME\%/is',
  93. '/\%USERNAME\%/is',
  94. );
  95. $simple_replace = array(
  96. //By Me
  97. '<div style="margin: -5px 0 -5px ${1}cm">$2</div>',
  98. '<div class="community-watch">$1</div>',
  99. '<embed type="application/x-shockwave-flash" wmode="transparent" width="425" height="366" src="http://www.youtube.com/v/$2"></embed>',
  100. //added line break
  101. '<hr>',
  102. '<strong>$1</strong>',
  103. '<em>$1</em>',
  104. '<u>$1</u>',
  105. // added nofollow to prevent spam
  106. '<a name="$1">$2</a>',
  107. '<a href="$1">$2</a>',
  108. '<a href="$1">$1</a>',
  109. '<div style="text-align: left;">$1</div>',
  110. '<div style="text-align: right;">$1</div>',
  111. '<div style="text-align: center;">$1</div>',
  112. //added alt attribute for validation
  113. '<img src="$1" border=0>',
  114. '<a href="mailto:$1" target="_blank">$2</a>',
  115. '<a href="mailto:$1" target="_blank">$1</a>',
  116. '<span style="font-family: $1;">$2</span>',
  117. '<span style="font-size: $1;">$2</span>',
  118. '<span style="color: $1;">$2</span>',
  119. //added textarea for code presentation
  120. '<textarea class="code_container" rows="30" cols="70">$1</textarea>',
  121. //added pre class for code presentation
  122. '<blockquote><small><hr color="#9e9e9e" noshade="noshade" size="1"><small class="white">Code:</small><br><div style="overflow: auto; background-color: #666666; color: #FFFFFF; width: 100%; max-height: 300px; height: expression(this.scrollHeight > 300 ? 300 : true); white-space: nowrap;"><pre class="code">$1</pre></div><hr color="#9e9e9e" noshade="noshade" size="1"></small></blockquote>',
  123. //added paragraph
  124. '<p>$1</p>',
  125. '<blockquote><small><hr color="#9e9e9e" noshade="noshade" size="1"><small class="white">Quote:</small><br>$1<hr color="#9e9e9e" noshade="noshade" size="1"></small></blockquote>',
  126. //By Me REPS
  127. $GLOBALS['SETTING']['WEB_SITE_NAME'],
  128. $_SESSION['nickname'],
  129. );
  130. // Do simple BBCode's
  131. $str = preg_replace ($simple_search, $simple_replace, $str);
  132. //Listing
  133. preg_match_all ("/\[list\](.*?)\[\*\](.*?)\[\/list\]/si", $str, $match);
  134. for ($j=0;$j<=count($match[0]);$j++) {
  135. for ($i=0;$i<=substr_count($match[0][$j], '[*]');$i++) {
  136. $str = preg_replace ("/\[list\](.*?)\[\*\](.*?)\[\/list\]/si", "[list]$1</li><li>$2[/list]", $str);
  137. }
  138. }
  139. $str = preg_replace ("/\[list\](.*?)\[\/list\]/si", "<ul><li>$1</li></ul>", $str);
  140. preg_match_all ("/\[list=([aAiI1])\](.*?)\[\*\](.*?)\[\/list\]/si", $str, $match);
  141. for ($j=0;$j<=count($match[0]);$j++) {
  142. for ($i=0;$i<=substr_count($match[0][$j], '[*]');$i++) {
  143. $str = preg_replace ("/\[list\=([aAiI1])\](.*?)\[\*\](.*?)\[\/list\]/si", "[list=$1]$2</li><li>$3[/list]", $str);
  144. }
  145. }
  146. $str = preg_replace ("/\[list=([aAiI1])\](.*?)\[\/list\]/si", "<ol type=$1><li>$2</li></ol>", $str);
  147. }
  148. if ($issmile==true) {
  149. /*
  150. //Smiles
  151. $querysm=mysql_query('SELECT * FROM `forum_smiles`', $GLOBALS['MySQL_CON']);
  152. while ($row = mysql_fetch_array($querysm)) {
  153. $key[] = '/'.preg_quote($row['id_smile']).'/';
  154. $value[] = '<img src="'.$row['path'].'">';
  155. }
  156. $str = preg_replace ($key, $value, $str);
  157. */
  158. }
  159. return $str;
  160. }
  161. function bbcode_toolbar($inputname) {
  162. $getbyid=explode('.',$inputname);
  163. $getbyid=$getbyid[count($getbyid)-1];
  164. ?>
  165. <script language=javascript src="new-hp/js/quick_reply.js"></script>
  166. <table cellpadding=0 cellspacing=0 width=225>
  167. <style>
  168. img.mousing:link, img.mousing:visited {
  169. background-color: transparent;
  170. }
  171. img.mousing:hover {
  172. background-color: orange;
  173. }
  174. img.mousing:active {
  175. background-color: darkorange;
  176. }
  177. </style>
  178. <tr>
  179. <td><img class="mousing" src="new-hp/images/bbcode/bold.gif" id=ed_bold onclick="edInsertTag(<? echo $inputname; ?>, 0);" value="B" alt="Bold"></td>
  180. <td><img class="mousing" src="new-hp/images/bbcode/italic.gif" id=ed_italic onclick="edInsertTag(<? echo $inputname; ?>, 1);" value="I" alt="Italic"></td>
  181. <td><img class="mousing" src="new-hp/images/bbcode/underline.gif" id=ed_underline onclick="edInsertTag(<? echo $inputname; ?>, 2);" value="U" alt="Underline"></td>
  182. <td><img class="mousing" src="new-hp/images/bbcode/left.gif" id=ed_left onclick="edInsertTag(<? echo $inputname; ?>, 3);" value="B" alt="Left"></td>
  183. <td><img class="mousing" src="new-hp/images/bbcode/center.gif" id=ed_center onclick="edInsertTag(<? echo $inputname; ?>, 4);" value="I" alt="Center"></td>
  184. <td><img class="mousing" src="new-hp/images/bbcode/right.gif" id=ed_right onclick="edInsertTag(<? echo $inputname; ?>, 5);" value="U" alt="Right"></td>
  185. <td><img class="mousing" src="new-hp/images/bbcode/link.gif" id=ed_link onclick="edInsertLink(<? echo $inputname; ?>, 2);" value="Link" alt="Link"></td>
  186. <td><img class="mousing" src="new-hp/images/bbcode/image.gif" id=ed_img onclick="edInsertImage(<? echo $inputname; ?>);" value="Image" alt="Image"></td>
  187. <td><img class="mousing" src="new-hp/images/bbcode/quote.gif" id=ed_quote onclick="edInsertTag(<? echo $inputname; ?>, 8);" value="Quote" alt="Quote"></td>
  188. </tr>
  189. </table>
  190. <?php
  191. }
  192. function secuimg($length) {
  193. $p_chars="abcdefghijklmnopqrstuvwxyz123456789";
  194. while(strlen($out_str)< $length)
  195. {
  196. $out_str.=substr($p_chars,(rand()%(strlen($p_chars))),1);
  197. }
  198. $_SESSION['CA_key'] = $out_str;
  199. return $out_str;
  200. }
  201. function bday($iDay, $iMonth, $iYear) {
  202. $year_diff = date("Y") - $iYear;
  203. $month_diff = date("m") - $iMonth;
  204. $day_diff = date("d") - $iDay;
  205. if ($month_diff < 0) $year_diff--;
  206. elseif (($month_diff==0) && ($day_diff < 0)) $year_diff--;
  207. return $year_diff;
  208. }
  209. function cleanCA($sstr) {
  210. if ($sstr=="") {
  211. unset($_SESSION['CA_key']);
  212. unset($_SESSION['CA_u']);
  213. unset($_SESSION['CA_p']);
  214. unset($_SESSION['CA_ask']);
  215. unset($_SESSION['CA_ans']);
  216. unset($_SESSION['CA_tbc']);
  217. unset($_SESSION['CA_fname']);
  218. unset($_SESSION['CA_lname']);
  219. unset($_SESSION['CA_city']);
  220. unset($_SESSION['CA_lo']);
  221. unset($_SESSION['CA_em']);
  222. unset($_SESSION['CA_shem']);
  223. unset($_SESSION['CA_bd']);
  224. unset($_SESSION['CA_shbd']);
  225. unset($_SESSION['CA_gmt']);
  226. unset($_SESSION['CA_shpm']);
  227. unset($_SESSION['CA_msn']);
  228. unset($_SESSION['CA_icq']);
  229. unset($_SESSION['CA_aim']);
  230. unset($_SESSION['CA_yahoo']);
  231. unset($_SESSION['CA_skype']);
  232. unset($_SESSION['CA_sig']);
  233. unset($_SESSION['CA_avtrd']);
  234. unset($_SESSION['CA_weburl']);
  235. unset($_SESSION['CA_accountset']);
  236. unset($_SESSION['CA_userset']);
  237. unset($_SESSION['CA_valcode']);
  238. unset($_SESSION['CA_skin']);
  239. unset($_SESSION['CA_nick']);
  240. }
  241. }
  242. function sendemail($to_email,$to_name,$theme,$text_text,$text_html=''){
  243. if (extension_loaded('openssl')) {
  244. set_time_limit(300);
  245. require_once 'inc/mail/smtp.php';
  246. $mail = new SMTP;
  247. $mail->Delivery('relay');
  248. $mail->Relay($GLOBALS['SETTING']['EMAIL_HOST'],$GLOBALS['SETTING']['EMAIL_USERNAME'],$GLOBALS['SETTING']['EMAIL_PASSWORD'], intval($GLOBALS['SETTING']['EMAIL_PORT']), $GLOBALS['SETTING']['EMAIL_AUTH'], $GLOBALS['SETTING']['EMAIL_SSL']);
  249. $mail->From($GLOBALS['SETTING']['EMAIL_MAIN'], $GLOBALS['SETTING']['WEB_SITE_NAME']);
  250. $mail->AddTo($to_email, $to_name);
  251. $mail->Text($text_text);
  252. if($text_html)$mail->Html($text_html);
  253. $sent = $mail->Send($theme);
  254. return $sent;
  255. } else {
  256. errborder('Extension OpenSSL Must be Enabled!');
  257. }
  258. }
  259. function verifylevel($uid) {
  260. if ($_SESSION['userid']==$GLOBALS['SETTING']['SERVER_OWNER']) {
  261. return 4;
  262. } else {
  263. mysql_select_db($GLOBALS['MySQL_Set']['DBREALM'], $GLOBALS['MySQL_CON']);
  264. $dbquery = mysql_query("SELECT gmlevel FROM account WHERE id='".$uid."'", $GLOBALS['MySQL_CON']);
  265. if (mysql_num_rows($dbquery)==1) {
  266. $row = mysql_fetch_array($dbquery);
  267. return $row['gmlevel'];
  268. } else {
  269. return -1;
  270. }
  271. }
  272. }
  273. function verifygmt($uid) {
  274. $dbquery = mysql_query("SELECT gmt FROM forum_accounts WHERE id_account='".$uid."'", $GLOBALS['MySQL_CON']);
  275. if (mysql_num_rows($dbquery)==1) {
  276. $row = mysql_fetch_array($dbquery);
  277. return $GLOBALS['GMT'][$row['gmt']][0];
  278. } else {
  279. return $GLOBALS['GMT'][$GLOBALS['SETTING']['WEB_GMT']][0];
  280. }
  281. }
  282. function validatelogin() {
  283. if (isset($_SESSION['userid'])) {
  284. $dbquery = mysql_query("SELECT a.id, fa.displayname as fdn FROM account a LEFT JOIN (forum_accounts fa) ON fa.id_account = a.id WHERE sha_pass_hash='".$_SESSION['password']."' AND id='".$_SESSION['userid']."' GROUP BY a.id", $GLOBALS['MySQL_CON']);
  285. if (mysql_num_rows($dbquery)!=1) {
  286. log_out(false);
  287. echo '<div style="position: absolute; z-index: 999999999; text-align: center;">';
  288. errborder($GLOBALS['_LANG']['ERROR']['BAD_LOGIN']);
  289. echo '</div>';
  290. } else {
  291. $dbquery=mysql_fetch_array($dbquery);
  292. $_SESSION['nickname']=$dbquery['fdn'];
  293. $dbquery = mysql_query("DELETE FROM `web_online` WHERE id='".$_SESSION['guestid']."' AND isguest='1'", $GLOBALS['MySQL_CON']);
  294. unset($_SESSION['guestid']);
  295. }
  296. } else if ($_SESSION['guestid']=='') {
  297. $qr = mysql_fetch_array(mysql_query("SELECT id FROM `web_online` WHERE isguest=1 ORDER BY id DESC LIMIT 0, 1", $GLOBALS['MySQL_CON']));
  298. $_SESSION['guestid'] = ($qr['id'] + 1);
  299. }
  300. }
  301. function log_out($redirect=true) {
  302. @mysql_query('DELETE FROM web_online WHERE id="'.$_SESSION['userid'].'"', $GLOBALS['MySQL_CON']);
  303. unset($_SESSION['username']);
  304. unset($_SESSION['password']);
  305. unset($_SESSION['userid']);
  306. unset($_SESSION['nickname']);
  307. ?><script src="new-hp/js/cookies.js" type="text/javascript"></script>
  308. <script>
  309. setCookie("ALOG_ID", '', now);
  310. setCookie("ALOG_USER", '', now);
  311. setCookie("ALOG_PASS", '', now);
  312. </script>
  313. <?
  314. if ($redirect==true) {echo '<script> window.location="?" </script>'; }
  315. }
  316. function valemail($stremail) {
  317. if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $stremail)) {
  318. return true;
  319. } else {
  320. return false;
  321. }
  322. }
  323. function valdate($strdate, $miny = 0, $maxy = 0) {
  324. if ($miny== 0) { $miny = date("Y")-100; }
  325. if ($maxy== 0) { $maxy = date("Y")-1; }
  326. if((strlen($strdate)<10)OR(strlen($strdate)>10)){
  327. return false;
  328. }
  329. else{
  330. if((substr_count($strdate,"/"))<>2){
  331. return false;
  332. }
  333. else{
  334. $pos=strpos($strdate,"/");
  335. $date=substr($strdate,0,($pos));
  336. $result=ereg("^[0-9]+$",$date,$trashed);
  337. if(!($result)){return false;}
  338. else{
  339. if(($date<=0)OR($date>31)){return false;}
  340. }
  341. $month=substr($strdate,($pos+1),($pos));
  342. if(($month<=0)OR($month>12)){return false;}
  343. else{
  344. $result=ereg("^[0-9]+$",$month,$trashed);
  345. if(!($result)){return false;}
  346. }
  347. $year=substr($strdate,($pos+4),strlen($strdate));
  348. $result=ereg("^[0-9]+$",$year,$trashed);
  349. if(!($result)){return false;}
  350. else{
  351. if(($year<$miny)OR($year>$maxy)){return false;}
  352. }
  353. }
  354. }
  355. return true;
  356. }
  357. function alphanum($sstr, $num=true, $alpha=true, $extra="") {
  358. $exp="^[";
  359. if ($alpha==true) { $exp.="a-zA-Z"; }
  360. if ($num==true) { $exp.="0-9"; }
  361. $exp.=$extra;
  362. $exp.="]{".strlen($sstr).",".strlen($sstr)."}$";
  363. return ereg($exp,$sstr);
  364. }
  365. function newrssfeed() {
  366. $link=str_replace('\\','',$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']));
  367. $stringData .= '<?xml version="1.0" encoding="windows-1252"?>
  368. <rss version="2.0">
  369. <channel>
  370. <link>http://'.$link.'/</link>
  371. <title>'.$GLOBALS['SETTING']['WEB_SITE_NAME'].'</title>
  372. <description>Lastest News</description>';
  373. @mysql_select_db($GLOBALS['MySQL_Set']['DBREALM'], $GLOBALS['$MySQL_CON']);
  374. $query= mysql_query("SELECT id_post, isbbcode, `text`, DATE_FORMAT(`date`, '%Y-%m') as datei, DATE_FORMAT(CONCAT(`date`,' ',`hour`), '%d-%m-%Y at %H:%i:%s') as `date`, fa.displayname as dn, ft.title as title FROM `forum_posts` fp
  375. INNER JOIN `forum_accounts` fa ON (fa.id_account = fp.id_account)
  376. INNER JOIN `forum_topics` ft ON (ft.id_topic = fp.id_topic)
  377. WHERE ft.category=1 AND ft.`viewlevel` <= 0 AND isreply=0
  378. GROUP BY fp.id_post ORDER BY fp.date DESC, fp.hour DESC LIMIT 0, 20", $GLOBALS['MySQL_CON']) OR DIE(mysql_error());
  379. while ($row2 = mysql_fetch_array($query)) {
  380. $stringData .='<item>
  381. <link>http://'.$link.'/?n=news.archive&amp;m='.$row2['datei'].'#'.$row2['id_post'].'</link>
  382. <title>'.$row2['title'].' - '.$row2['dn'].' on '.$row2['date'].'</title>
  383. <description>'.htmlentities(bbcode($row2['text'],true,true,$row2['isbbcode'])).'</description>
  384. <guid isPermaLink="false">'.$row2['id_post'].'</guid>
  385. </item>';
  386. }
  387. $stringData .='</channel>
  388. </rss>';
  389. $fh = @fopen('inc/news/news.rss.xml', 'w');
  390. @fwrite($fh, $stringData);
  391. @fclose($fh);
  392. }
  393. function population_view($n) {
  394. $low=100; $medium=200; $high=300;
  395. if($n==0){return 'N/A (0)';}
  396. elseif($n < $low){return 'Low ('.$n.')';}
  397. elseif($n >= $low && $n < $medium){return 'Medium ('.$n.')';}
  398. elseif($n >= $high){return 'High ('.$n.')';}
  399. }
  400. function check_port_status($ip, $port, $delay=0.5) {
  401. error_reporting(0);
  402. $fp = fsockopen($ip, $port, $e,$f, (float) $delay);
  403. if($fp) {
  404. return true;
  405. fclose($fp);
  406. } else {
  407. return false;
  408. }
  409. error_reporting(1);
  410. }
  411. function playerpos($mapid, $x, $y) {
  412. global $MAP, $ZONE;
  413. if (!empty($MAP[$mapid]))
  414. {
  415. $zmap=$MAP[$mapid];
  416. if (($mapid==0) or ($mapid==1))
  417. {
  418. $i=0; $c=count($ZONE[$mapid]);
  419. while ($i<$c)
  420. {
  421. if ($ZONE[$mapid][$i][2] < $x AND $ZONE[$mapid][$i][3] > $x AND $ZONE[$mapid][$i][1] < $y AND $ZONE[$mapid][$i][0] > $y) { $zmap.=' - '. $ZONE[$mapid][$i][4]; break; }
  422. $i++;
  423. }
  424. }
  425. } else $zmap="Unknown zone";
  426. return $zmap;
  427. }
  428. function setonline($page) {
  429. if (isset($_SESSION['userid'])) {
  430. mysql_select_db ($GLOBALS['MySQL_Set']['DBREALM'], $GLOBALS['MySQL_CON']);
  431. mysql_query('INSERT INTO web_online VALUES("'.$_SESSION['userid'].'","'.$page.'","'.date('Y-m-d H:i:s').'", "'.$_SERVER['REMOTE_ADDR'].'", 0) ON DUPLICATE KEY UPDATE page="'.$page.'", time ="'.date('Y-m-d H:i:s').'", ip="'.$_SERVER['REMOTE_ADDR'].'", isguest=0', $GLOBALS['MySQL_CON']) OR DIE (mysql_error());
  432. } else {
  433. mysql_query('INSERT INTO web_online VALUES("'.$_SESSION['guestid'].'","'.$page.'","'.date('Y-m-d H:i:s').'", "'.$_SERVER['REMOTE_ADDR'].'", 1) ON DUPLICATE KEY UPDATE page="'.$page.'", time ="'.date('Y-m-d H:i:s').'", ip="'.$_SERVER['REMOTE_ADDR'].'", isguest=1', $GLOBALS['MySQL_CON']) OR DIE (mysql_error());
  434. }
  435. @mysql_query('DELETE FROM web_online WHERE TIMESTAMPDIFF(MINUTE, `time`, NOW())>=5', $GLOBALS['MySQL_CON']);
  436. }
  437. function pages($currentpage, $totalrows, $rowsperpage, $url, $sep='&nbsp;|&nbsp;', $arrows=true, $uptopage=0, $incdiv=true) {
  438. if ($incdiv==true) {
  439. echo '<div align=center style="width: 80%;">';
  440. }
  441. $totalpages=ceil($totalrows/$rowsperpage);
  442. for ($i=1;$i<=$totalpages;$i++) {
  443. if ($i>$uptopage AND $uptopage >0) {
  444. $pages .= ".&nbsp;.&nbsp;<a href='".$url."&p=".$totalpages."'>Last</a>";
  445. break;
  446. } else if ($currentpage!=$i) {
  447. $pages .= "<a href='".$url."&p=".$i."'>".$i."</a>";
  448. } else {
  449. $pages .= "<a href='".$url."&p=".$i."' class='current'><b>".$i."</b></a>";
  450. }
  451. if ($i < $totalpages) { $pages .= $sep; }
  452. }
  453. if ($arrows==true) {
  454. if (($currentpage - 1)<1) { $lowpage=1; } else { $lowpage=$currentpage-1 ;}
  455. if (($currentpage + 1)>$totalpages) { $highpage=$totalpages; } else { $highpage=$currentpage+1 ;}
  456. $pages = '<td><a href="'.$url.'&p='.$lowpage.'"><img SRC="new-hp/images/forum/arrow-left.gif" border=0></a></td><td><small>'.$pages.'</small></td><td><a href="'.$url.'&p='.$highpage.'"><img SRC="new-hp/images/forum/arrow-right.gif" border=0></a></td>';
  457. }
  458. if ($totalpages>1) { return $pages; }
  459. if ($incdiv==true) {
  460. echo '</div>';
  461. }
  462. }
  463. function convdate($mins) {
  464. if (stristr($mins,'-') != false) { $mins *=-1; }
  465. if ($mins<(1)) {
  466. return 'Less than a Minute';
  467. } else if ($mins>=(1) AND $mins<(60) ) {
  468. return $mins.' Minute(s)';
  469. } else if ($mins>=(60) AND $mins<(60*24)) {
  470. return round($mins/60,0).' Hour(s)';
  471. } else {
  472. return round($mins/60/24,0).' Day(s)';
  473. }
  474. }
  475. function savenewss($txtp) {
  476. $fc=0;
  477. foreach(glob("media/screenshots/*.jpg") as $filename) {
  478. $fc++;
  479. $css[$fc] = $filename;
  480. }
  481. $fc = rand(1,($fc));
  482. $css = $css[$fc];
  483. $fh = @fopen($txtp, 'w');
  484. @fwrite($fh, date('Y-m-d') . '|' . $css);
  485. @fclose($fh);
  486. return $css;
  487. }
  488. function validateip() {
  489. $allow=true;
  490. $dbquery = mysql_query("SELECT ip FROM ip_banned", $GLOBALS['MySQL_CON']) OR DIE (mysql_error());
  491. while ($row = mysql_fetch_array($dbquery)) {
  492. if ($row['ip']==$_SERVER['REMOTE_ADDR']) {
  493. $allow=false;
  494. break;
  495. } else {
  496. $ipdb = explode('.',$row['ip']);
  497. $ipuser = explode('.',$_SERVER['REMOTE_ADDR']);
  498. if ($ipdb[0]==$ipuser[0] AND $ipdb[1]=='0' AND $ipdb[2]=='0' AND $ipdb[3]=='0') {
  499. $allow=false;
  500. break;
  501. } else if ($ipdb[0]==$ipuser[0]) {
  502. if ($ipdb[1]==$ipuser[1] AND $ipdb[2]=='0' AND $ipdb[3]=='0') {
  503. $allow=false;
  504. break;
  505. } else if ($ipdb[1]==$ipuser[1]) {
  506. if ($ipdb[2]==$ipuser[2] AND $ipdb[3]=='0') {
  507. $allow=false;
  508. break;
  509. } else if ($ipdb[2]==$ipuser[2]) {
  510. if ($ipdb[3]==$ipuser[3] OR ($ipdb[3]=='0')) {
  511. $allow=false;
  512. break;
  513. }
  514. }
  515. }
  516. }
  517. }
  518. }
  519. return $allow;
  520. }
  521. function viewedtopic($tid) {
  522. mysql_query("INSERT INTO forum_views(id_topic,id_account,`time`) VALUES('".$tid."','".$_SESSION['userid']."','".date('Y-m-d H:i:s')."')
  523. ON DUPLICATE KEY UPDATE `time`='".date('Y-m-d H:i:s')."'", $GLOBALS['MySQL_CON']) or die (mysql_error());
  524. }
  525. function pvp_ranks($honor=0, $faction=0){
  526. $rank = '0'.$faction;
  527. if($honor > 0){
  528. if($honor < 2000) $rank = 1;
  529. else $rank = ceil($honor / 5000) + 1;
  530. }
  531. if ($rank>14) { $rank = 14; }
  532. return $rank;
  533. }
  534. function resetavatar($uid) {
  535. @mysql_query("UPDATE forum_accounts SET avatar='nochar' WHERE id_account='".$uid."'");
  536. }
  537. function onlinelocation($url, $sep='>', $incurl=false) {
  538. $url2=parse_url($url, PHP_URL_QUERY);
  539. $url2=explode('&',$url2);
  540. for ($i=0;$i<count($url2);$i++) {
  541. $loc[$i]=explode('=',$url2[$i]);
  542. if ($loc[$i][0]!='') {
  543. eval("$".$loc[$i][0]."='".$loc[$i][1]."';");
  544. }
  545. }
  546. switch($n) {
  547. case "news.archive":
  548. $url='News '.$sep.' Archived News';
  549. break;
  550. case "account.create":
  551. $url='Account '.$sep.' Create Account';
  552. break;
  553. case "account.manage":
  554. $url='Account '.$sep.' Manage Account';
  555. switch ($f) {
  556. case "character":
  557. $url.=' '.$sep.' Forum Avatar';
  558. break;
  559. case "account":
  560. $url.=' '.$sep.' Account Info';
  561. break;
  562. case "contact":
  563. $url.=' '.$sep.' Contact & Forum Info';
  564. break;
  565. }
  566. break;
  567. case "account.pm":
  568. $url='Account '.$sep.' Private Messages';
  569. switch ($f) {
  570. case "outbox":
  571. $url.=' '.$sep.' Outbox';
  572. break;
  573. case "send":
  574. $url.=' '.$sep.' Sending';
  575. break;
  576. case "inbox":
  577. default:
  578. $url.=' '.$sep.' Inbox';
  579. break;
  580. }
  581. break;
  582. case "account.login":
  583. $url='Account '.$sep.' Log In';
  584. break;
  585. case "account.activation":
  586. $url='Account '.$sep.' Activation';
  587. break;
  588. case "account.logout":
  589. $url='Account '.$sep.' Log Out';
  590. break;
  591. case "account.retrieve":
  592. $url='Account '.$sep.' Retrieve Account';
  593. switch ($t) {
  594. case "name":
  595. $url.=' Name';
  596. break;
  597. case "password":
  598. $url.=' Password';
  599. break;
  600. }
  601. break;
  602. case "account.realmstatus":
  603. $url='Account '.$sep.' Realm Status';
  604. if ($t!='') {
  605. $dbvar = mysql_fetch_array(mysql_query("SELECT name FROM realmlist WHERE id='".$t."'", $GLOBALS['MySQL_CON']));
  606. $url.=' '.$sep.' '.$dbvar['name'].' '.$sep.' Players On-Line';
  607. }
  608. break;
  609. case "gameguide.gettingstarted":
  610. $url='Game Guide '.$sep.' Getting Started';
  611. break;
  612. case "gameguide.faq":
  613. $url='Game Guide '.$sep.' F. A. Q.';
  614. break;
  615. case "gameguide.introduction":
  616. case "gameguide":
  617. $url='Game Guide '.$sep.' Introduction';
  618. break;
  619. case "workshop.pvprankings":
  620. $url='Workshop '.$sep.' PvP Rankings';
  621. if ($r!='') {
  622. $dbvar = mysql_fetch_array(mysql_query("SELECT name FROM realmlist WHERE id='".$r."'", $GLOBALS['MySQL_CON']));
  623. $url.=' '.$sep.' '.$dbvar['name'];
  624. if ($f=='alliance') {
  625. $url.=' '.$sep.' Alliance';
  626. } else if ($f=='horde') {
  627. $url.=' '.$sep.' Horde';
  628. }
  629. }
  630. break;
  631. case "workshop.eventscalendar":
  632. $url='Workshop '.$sep.' Events Calendar';
  633. break;
  634. case "workshop.worldmap":
  635. $url='Workshop '.$sep;
  636. if ($m=='outland') {
  637. $url.=' World Map of Outland';
  638. } else {
  639. $url.=' World Map of Azeroth';
  640. }
  641. break;
  642. case "media.screenshots":
  643. $url='Media '.$sep.' Screenshots';
  644. break;
  645. case "media.wallpapers":
  646. $url='Media '.$sep.' Wallpapers';
  647. break;
  648. case "media.otherdownloads":
  649. $url='Media '.$sep.' Other Downloads';
  650. break;
  651. case "language":
  652. $url='Language '.$sep.' Change To '.mb_convert_case($set, MB_CASE_TITLE);
  653. break;
  654. case "armory":
  655. case "armory.accounts":
  656. case "armory.guilds":
  657. case "armory.characters":
  658. $url='Armory';
  659. break;
  660. case "forums":
  661. $url='Forums';
  662. if ($f!='') {
  663. $dbvar = mysql_fetch_array(mysql_query("SELECT title FROM forums WHERE id_forum='".$f."'", $GLOBALS['MySQL_CON']));
  664. $url.=' - '.$dbvar['title'];
  665. if ($topic=='new') {
  666. $url.=' '.$sep.' Creating New Topic';
  667. }
  668. } else if ($t!='') {
  669. $dbvar = mysql_fetch_array(mysql_query("SELECT ft.title, f.title as ftitle FROM forum_topics ft INNER JOIN (forums f) ON f.id_forum=ft.id_forum WHERE ft.id_topic='".$t."'", $GLOBALS['MySQL_CON']));
  670. if ($topic=='edit') {
  671. $type = 'Editing Topic';
  672. } else if ($topic=='remove') {
  673. $type = 'Removing Topic';
  674. } else if ($topic=='move') {
  675. $type = 'Moving Topic';
  676. } else if ($post=='new') {
  677. $type = 'Replying to Topic';
  678. } else if ($post=='new') {
  679. $type = 'Editing Reply in Topic';
  680. } else if ($post=='remove') {
  681. $type = 'Removing Reply from Topic';
  682. } else {
  683. $type= 'Topic';
  684. }
  685. $url.=' - '.$dbvar['ftitle'].' '.$sep.' '.$type.' - '.$dbvar['title'];
  686. }
  687. break;
  688. case "community":
  689. case "community.spotlight":
  690. $url='Community '.$sep.' Spotlight';
  691. break;
  692. case "community.online":
  693. $url='Community '.$sep.' Users On-Line';
  694. break;
  695. case "community.contests":
  696. $url='Community '.$sep.' Contests';
  697. break;
  698. case "community.fanart":
  699. $url='Community '.$sep.' Fan Art';
  700. break;
  701. case "support":
  702. $url='Support';
  703. break;
  704. case "support.ingame":
  705. $url='Support '.$sep.' In-Game Support';
  706. if ($r!='') {
  707. $dbvar = mysql_fetch_array(mysql_query("SELECT name FROM realmlist WHERE id='".$r."'", $GLOBALS['MySQL_CON']));
  708. $url.=' '.$sep.' '.$dbvar['name'];
  709. if ($t=='') {
  710. $url.=' '.$sep.' Tickets';
  711. } else {
  712. $url.=' '.$sep.' Commands';
  713. }
  714. }
  715. break;
  716. case "support.donations":
  717. $url='Support '.$sep.' Donations';
  718. break;
  719. case "support.staff":
  720. $url='Support '.$sep.' Staff Personel';
  721. break;
  722. case "support.license":
  723. $url='Support '.$sep.' GNU License';
  724. break;
  725. case "support.jobs":
  726. $url='Support '.$sep.' Jobs';
  727. break;
  728. case "support.rules":
  729. $url='Support '.$sep.' Rules';
  730. break;
  731. case "admin":
  732. $url='Site Administration';
  733. break;
  734. case "admin.realms":
  735. $url='Site Administration '.$sep.' Realms';
  736. break;
  737. case "admin.text":
  738. $url='Site Administration '.$sep.' Text Dialogs';
  739. break;
  740. case "admin.database":
  741. $url='Site Administration '.$sep.' Database Settings';
  742. break;
  743. case "admin.web":
  744. $url='Site Administration '.$sep.' Website';
  745. break;
  746. case "admin.forums":
  747. $url='Site Administration '.$sep.' Forums';
  748. break;
  749. case "admin.accounts":
  750. $url='Site Administration '.$sep.' User Accounts';
  751. break;
  752. case "admin.donations":
  753. $url='Site Administration '.$sep.' Donations';
  754. break;
  755. case "admin.email":
  756. $url='Site Administration '.$sep.' E-mail';
  757. break;
  758. case "admin.misc":
  759. $url='Site Administration '.$sep.' Miscellaneous';
  760. break;
  761. case "":
  762. case "news":
  763. $url='Main Page';
  764. break;
  765. default:
  766. $url='Unknown '.$sep.' '.$url;
  767. break;
  768. }
  769. return $url;
  770. }
  771. function remove_array_item(&$arr, $index) {
  772. if(isset($arr[$index])){
  773. array_splice($arr, $index, 1);
  774. }
  775. }
  776. ?>