Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.39 KB | None | 0 0
  1. <?php
  2. define('TYPE_NOCLEAN', 0); // no change
  3. define('TYPE_BOOL', 1); // force boolean
  4. define('TYPE_INT', 2); // force integer
  5. define('TYPE_UINT', 3); // force unsigned integer
  6. define('TYPE_NUM', 4); // force number
  7. define('TYPE_UNUM', 5); // force unsigned number
  8. define('TYPE_UNIXTIME', 6); // force unix datestamp (unsigned integer)
  9. define('TYPE_STR', 7); // force trimmed string
  10. define('TYPE_NOTRIM', 8); // force string - no trim
  11. define('TYPE_NOHTML', 9); // force trimmed string with HTML made safe
  12. define('TYPE_ARRAY', 10); // force array
  13. define('TYPE_FILE', 11); // force file
  14. define('TYPE_BINARY', 12); // force binary string
  15. define('TYPE_NOHTMLCOND', 13); // force trimmed string with HTML made safe if determined to be unsafe
  16.  
  17. include_once 'settings/config.php';
  18. include_once 'inc/db.class.php';
  19. function &clean( &$data, $type )
  20. {
  21. static $booltypes = array('1', 'yes', 'y', 'true');
  22.  
  23. switch ($type)
  24. {
  25. case TYPE_INT: $data = intval($data); break;
  26. case TYPE_UINT: $data = ($data = intval($data)) < 0 ? 0 : $data; break;
  27. case TYPE_NUM: $data = strval($data) + 0; break;
  28. case TYPE_UNUM: $data = strval($data) + 0;
  29. $data = ($data < 0) ? 0 : $data; break;
  30. case TYPE_BINARY: $data = strval($data); break;
  31. case TYPE_STR: $data = trim(strval($data)); break;
  32. case TYPE_NOTRIM: $data = strval($data); break;
  33. case TYPE_NOHTML: $data = trim(strval($data)); break;
  34. case TYPE_BOOL: $data = in_array(strtolower($data), $booltypes) ? 1 : 0; break;
  35. case TYPE_ARRAY: $data = (is_array($data)) ? $data : array(); break;
  36. case TYPE_NOCLEAN: break;
  37. }
  38.  
  39. // strip out characters that really have no business being in non-binary data
  40. switch ($type)
  41. {
  42. case TYPE_STR:
  43. case TYPE_NOTRIM:
  44. case TYPE_NOHTML:
  45. case TYPE_NOHTMLCOND:
  46. $data = str_replace(chr(0), '', $data);
  47. }
  48.  
  49. return $data;
  50. }
  51. include_once 'settings/config.php';
  52. include_once 'inc/db.class.php';
  53.  
  54. class site
  55. {
  56. public $db;
  57.  
  58. function __construct()
  59. {
  60. $this->db = new db();
  61. if(isset($_GET['logout']))
  62. {
  63. unset($_SESSION);
  64. session_destroy();
  65. header("Location: ./");
  66. }
  67. }
  68.  
  69. function load()
  70. {
  71. $page = (isset($_GET['page'])) ? $_GET['page'] : 'index';
  72. $page = (!file_exists('pages/'.$page.'.php')) ? '404' : $page;
  73.  
  74. if(isset($_GET['admin']))
  75. {
  76. $page = 'admin/';
  77. $page .= (isset($_SESSION['gm'])) ? $_GET['admin'] : '404';
  78.  
  79. if(empty($_GET['admin']) && isset($_SESSION['gm']))
  80. {
  81. $page = 'admin/admin';
  82. }
  83.  
  84. if(!file_exists('pages/'.$page.'.php')) $page = '404';
  85. }
  86.  
  87. if(isset($_GET['account']))
  88. {
  89. $page = 'account/';
  90. $page .= (isset($_SESSION['username'])) ? $_GET['account'] : 'error';
  91.  
  92. if(empty($_GET['account']) && isset($_SESSION['username']))
  93. {
  94. $page = 'account/account';
  95. }
  96.  
  97. if(!file_exists('pages/'.$page.'.php')) $page = '404';
  98. }
  99.  
  100. if(isset($_GET['buy']))
  101. {
  102. $page = 'rewards/';
  103. $page .= (isset($_SESSION['username'])) ? $_GET['buy'] : 'error';
  104.  
  105. if(empty($_GET['buy']) && isset($_SESSION['username']))
  106. {
  107. $page = 'account/account';
  108. }
  109.  
  110. if(!file_exists('pages/'.$page.'.php')) $page = '404';
  111. }
  112.  
  113. include 'template/_head.php';
  114. include 'pages/'.$page.'.php';
  115. include 'template/_foot.php';
  116.  
  117. }
  118.  
  119. function msg($e, $msg)
  120. {
  121. $e = ($e == 1) ? 'red' : 'green';
  122. print '<span style="color:'.$e.';font-size:11px;padding:5px;">'.$msg.'</span>';
  123. }
  124.  
  125. function mmsg($type, $msg)
  126. {
  127. print '<section class="'.$type.'"><p>'.$msg.'</p></section>';
  128. }
  129.  
  130. function mmsgcaptcha($type, $msg)
  131. {
  132. $this->__construct();
  133. print '<section class="'.$type.'"><p>'.$msg.'</p></section>';
  134. unset($_SESSION);
  135. session_destroy();
  136. header("Location: ./");
  137. }
  138. function login()
  139. {
  140.  
  141. if(isset($_POST['login']))
  142. {
  143. $user = $_POST['username'];
  144. $pass = sha1(strtoupper($_POST['username'].':'.$_POST['password']));
  145.  
  146. $q = $this->db->select('*','account',"username = '$user' AND sha_pass_hash = '$pass'");
  147. if(mysql_num_rows($q) > 0)
  148. {
  149. $row = mysql_fetch_assoc($q);
  150. foreach($row as $c => $v)
  151. {
  152. $_SESSION[$c] = $v;
  153. }
  154.  
  155.  
  156. //Encrypt the posted code field and then compare with the stored key
  157.  
  158. $captchaaccept = $_SESSION['keya'];
  159.  
  160. if(md5($_POST['captcha']) != $captchaaccept)
  161. {
  162. $this->mmsg('error','Invalid Captcha');
  163.  
  164. }
  165.  
  166. $gm = $this->db->select('*','account_access',"id = '$_SESSION[id]'");
  167. $row = mysql_fetch_assoc($gm);
  168.  
  169. if($row['gmlevel'] >= 4)
  170. {
  171. $_SESSION['gm'] = 1;
  172. }
  173.  
  174. }
  175. else
  176. {
  177. return $this->mmsg('error','Invalid Login');
  178. }
  179.  
  180. header("Location: ./?account");
  181.  
  182. exit;
  183.  
  184. }
  185.  
  186. }
  187.  
  188. function getDonorPoints($id)
  189. {
  190. $q = $this->db->select('dp', 'account', "id = '$id'");
  191. $row = mysql_fetch_assoc($q);
  192.  
  193. echo $row['dp'];
  194. return;
  195. }
  196.  
  197. function getVotingPoints($id)
  198. {
  199. $q = $this->db->select('vp', 'account', "id = '$id'");
  200. $row = mysql_fetch_assoc($q);
  201.  
  202. echo $row['vp'];
  203. return;
  204. }
  205.  
  206. function getArray($table, $order, $limit = NULL)
  207. {
  208. $results = array();
  209. if($limit == NULL)
  210. {
  211. $q = $this->db->query("SELECT * FROM $table ORDER BY id $order");
  212. }
  213. else
  214. {
  215. $q = $this->db->query("SELECT * FROM $table ORDER BY id $order LIMIT $limit");
  216. }
  217. while($row = mysql_fetch_assoc($q))
  218. {
  219. $results[] = $row;
  220. }
  221.  
  222. return $results;
  223. }
  224.  
  225. function is_valid_email ($email)
  226. {
  227. $qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
  228. $dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
  229. $atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'.
  230. '\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
  231. $quoted_pair = '\\x5c\\x00-\\x7f';
  232. $domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d";
  233. $quoted_string = "\\x22($qtext|$quoted_pair)*\\x22";
  234. $domain_ref = $atom;
  235. $sub_domain = "($domain_ref|$domain_literal)";
  236. $word = "($atom|$quoted_string)";
  237. $domain = "$sub_domain(\\x2e$sub_domain)*";
  238. $local_part = "$word(\\x2e$word)*";
  239. $addr_spec = "$local_part\\x40$domain";
  240.  
  241. return preg_match("!^$addr_spec$!", $email) ? true : false;
  242. }
  243.  
  244. function bbcode($text)
  245. {
  246. $text = " " . $text;
  247. $text = stripslashes( $text );
  248. $text = str_replace( ":D", "<img src=\"images/smileys/grin.png\" />", $text );
  249. $text = str_replace( "xD", "<img src=\"images/smileys/evilgrin.png\" />", $text );
  250. $text = str_replace( ":(", "<img src=\"images/smileys/unhappy.png\" />", $text );
  251. $text = str_replace( "^^", "<img src=\"images/smileys/happy.png\" />", $text );
  252. $text = str_replace( ":)", "<img src=\"images/smileys/smile.png\" />", $text );
  253. $text = str_replace( ":O", "<img src=\"images/smileys/surprised.png\" />", $text );
  254. $text = str_replace( ":P", "<img src=\"images/smileys/tongue.png\" />", $text );
  255. $text = str_replace( ":3", "<img src=\"images/smileys/waii.png\" />", $text );
  256. $text = str_replace( ";)", "<img src=\"images/smileys/wink.png\" />", $text );
  257. if (!( strpos($text, "[") && strpos($text, "]"))) return nl2br($text);
  258. $text = preg_replace( "/\\[b\\](.+?)\[\/b\]/is", '<strong>\1</strong>', $text );
  259. $text = preg_replace( "/\\[center\\](.+?)\[\/center\]/is", '<span align="center">\1</span>', $text );
  260. $text = preg_replace( "/\\[i\\](.+?)\[\/i\]/is", '<i>\1</i>', $text );
  261. $text = preg_replace( "/\\[u\\](.+?)\[\/u\]/is", '<span class="underlined">\1</span>', $text );
  262. $text = preg_replace( "/\[s\](.+?)\[\/s\]/is", '<s>\1</s>', $text );
  263. $text = preg_replace( "/\[list\](.+?)\[\/list\]/is", '<ul>\1</ul>', $text );
  264. $text = preg_replace( "/\[\*\](.*)/", '<li>\1</li>', $text );
  265. $text = preg_replace( "/\[code\](.+?)\[\/code\]/is", '<code>\1</code>', $text );
  266. $text = preg_replace( "/\[quote\](.+?)\[\/quote\]/is", '<code>\1</code>', $text );
  267. $text = @eregi_replace( "\\[img]([^\\[]*)\\[/img\\]", "<img src=\"\\1\">", $text );
  268. $text = @eregi_replace( "\\[font=([^\\[]*)\\]([^\\[]*)\\[/font\\]", "<font style=\"font-family:\\1\">\\2</font>", $text );
  269. $text = @eregi_replace( "\\[color="([^\\[]*)"\\]([^\\[]*)\\[/color\\]", "<font color=\"\\1\">\\2</font>",$text );
  270. $text = @eregi_replace( "\\[size=([^\\[]*)\\]([^\\[]*)\\[/size\\]", "<font size=\"\\1px\">\\2</font>", $text );
  271. $text = @eregi_replace( "\\[url=([^\\[]*)\\]([^\\[]*)\\[/url\\]", "<a href=\"\\1\">\\2</a>", $text );
  272. $text = @eregi_replace( "\\[list=([^\\[]*)\\]([^\\[]*)\\[/list\\]", "<ul style='list-style-type: decimal;margin-left: 30px;' align='center'>\\2</ul>", $text );
  273. $text = @eregi_replace( "\\[url\\]([^\\[]*)\\[/url\\]", "<a href=\"\\1\">\\1</a>", $text );
  274. return nl2br($text);
  275.  
  276. }
  277.  
  278. function getWhereArray($table, $where)
  279. {
  280. $results = array();
  281. $q = $this->db->query("SELECT * FROM $table WHERE $where");
  282. while($row = mysql_fetch_assoc($q))
  283. {
  284. $results[] = $row;
  285. }
  286.  
  287. return $results;
  288. }
  289.  
  290. function files($dir, $type)
  291. {
  292.  
  293. $count = count(glob($dir . '*.'.$type)) ;
  294. return $count;
  295.  
  296. }
  297.  
  298. function accountChangePw()
  299. {
  300. global $db;
  301. if(isset($_POST['changepass']))
  302. {
  303. $oenc = sha1(strtoupper($_SESSION['username'].':'.$_POST['oldpass']));
  304. $nenc = sha1(strtoupper($_SESSION['username'].':'.$_POST['newpass']));
  305.  
  306. if($oenc != $_SESSION['sha_pass_hash'])
  307. {
  308. return $this->mmsg('error', 'Current password does not match with your old one.');
  309. }
  310.  
  311. if($_POST['newpass'] != $_POST['confirmpass'])
  312. {
  313. return $this->mmsg('error', 'New passwords did not match, please try again.');
  314. }
  315.  
  316. $q = mysql_query("UPDATE realmd.account SET sha_pass_hash='$nenc', v='',s='' WHERE id='$_SESSION[id]'");
  317.  
  318. //$q = $this->db->update('account',"sha_pass_hash = '$nenc'","id = '$_SESSION[id]'",'1');
  319. if($q)
  320. {
  321. $this->mmsg('success', 'Password has been updated.');
  322. $_SESSION['sha_pass_hash'] = $nenc;
  323. return;
  324. }
  325. else
  326. {
  327. return $this->msg(1, 'Something went wrong, please try again.');
  328. }
  329. }
  330. }
  331.  
  332. function accountChangeEmail()
  333. {
  334. global $db;
  335. if(isset($_POST['changemail']))
  336. {
  337. $enc = sha1(strtoupper($_SESSION['username'].':'.$_POST['pass']));
  338.  
  339. if($enc != $_SESSION['sha_pass_hash'])
  340. {
  341. return $this->mmsg('error', 'Incorrect password you entered, please try again.');
  342. }
  343.  
  344. $mail = mysql_real_escape_string($_POST['newmail']);
  345.  
  346. $q = $this->db->update('account', "email = '$mail'", "id = '$_SESSION[id]'", '1');
  347. if($q)
  348. {
  349. $this->mmsg('success', 'Email has been updated.');
  350. $_SESSION['email'] = $_POST['newmail'];
  351. return;
  352. }
  353. else
  354. {
  355. return $this->msg(1, 'Something went wrong, please try again.');
  356. }
  357. }
  358. }
  359.  
  360. function accountRegister()
  361. {
  362. global $db;
  363.  
  364. if(isset($_POST['register']))
  365. {
  366. foreach($_POST as $c => $v)
  367. {
  368. $_POST[$c] = mysql_real_escape_string($v);
  369. }
  370.  
  371. if(empty($_POST['validator']))
  372. {
  373. return $this->mmsg('error', 'Validator field was empty, please answer the captcha.');
  374. }
  375.  
  376. if(empty($_POST['accountname']))
  377. {
  378. return $this->mmsg('error', 'Account name was empty, please try again.');
  379. }
  380.  
  381. if(empty($_POST['password']) || empty($_POST['cpassword']))
  382. {
  383. return $this->mmsg('error', 'Either of the password fields were empty, please try again.');
  384. }
  385.  
  386. if(!$this->is_valid_email($_POST['email']))
  387. {
  388. return $this->mmsg('error', 'Invalid e-mail, please use a real e-mail address.');
  389. }
  390.  
  391. if(empty($_POST['email']))
  392. {
  393. return $this->mmsg('error', 'Email field was empty, please try again.');
  394. }
  395.  
  396.  
  397. if($_POST['password'] != $_POST['cpassword'])
  398. {
  399. return $this->mmsg('error', 'Passwords did not match, please try again.');
  400. }
  401.  
  402. $q = $this->db->select('username','account',"username = '$_POST[accountname]'");
  403. if(mysql_num_rows($q) > 0)
  404. {
  405. return $this->mmsg('error', 'This username already exists, please try again.');
  406. }
  407.  
  408. /*$captchaaccept = $_SESSION['keya'];
  409. if(md5($_POST['validator']) != $captchaaccept)
  410. {
  411. return $this->mmsg('error','Invalid Captcha');
  412. }*/
  413.  
  414. $enc = sha1(strtoupper($_POST['accountname'].':'.$_POST['password']));
  415.  
  416. $ip = $_SERVER['REMOTE_ADDR'];
  417.  
  418. $q = $this->db->select('registerip','account',"registerip = '$ip'");
  419. if(mysql_num_rows($q) >= 3)
  420. {
  421. return $this->mmsg('error', 'This ip has registered more than three accounts.');
  422. }
  423.  
  424. $q = $this->db->insert('account',"username = '$_POST[accountname]', sha_pass_hash = '$enc', locked = '0', email = '$_POST[email]', expansion = '2', vp = '0', dp = '0', registerip = '$ip'");
  425. if($q)
  426. {
  427. return $this->mmsg('success', 'Your account has been created, you may now login to the website and the forums.');
  428. }
  429. else
  430. {
  431. return $this->mmsg('error', 'Registration failed, contact an administrator');
  432. }
  433. }
  434. }
  435.  
  436. function accountForgotPw()
  437. {
  438. global $web;
  439.  
  440. if(isset($_POST['forgotpw']))
  441. {
  442. if(empty($_POST['email']))
  443. {
  444. return $this->msg(1, 'Empty e-mail address, please try again.');
  445. }
  446.  
  447. if(empty($_POST['account']))
  448. {
  449. return $this->msg(1, 'Empty account name, please try again.');
  450. }
  451.  
  452. $pw = base64_encode(rand(0, 5000));
  453. $enc = md5(strtoupper($pw));
  454. $q = $this->db->select('username, email','account', "username = '$_POST[account]' AND email = '$_POST[email]'");
  455. if(!$q)
  456. {
  457. return $this->msg(1, 'Account name & email did not match as an account in our database, please try and correct this.');
  458. }
  459.  
  460. $body = ' :: '.$web->name.' ::
  461. You\'ve requested a new password on our realms, so here we\'re
  462. sending you a randomly generated password, we recommend you change
  463. your password when you log in through the \'Change Email\' section in
  464. your account panel.
  465.  
  466. Your new password is: '. $pw .'
  467.  
  468. If you did not do this, we strongly recommend you change your e-mail address
  469. aswell and ask an administrator for an account name change.';
  470. $body = wordwrap($body, 100);
  471. $headers = 'From : '.$web->admin."\r\n" .
  472. 'Reply-To: '.$web->admin."\r\n" .
  473. 'X-mailer: PHP/'.phpversion();
  474. mail($_POST['email'], $web->name.' Password Recovery', $body, $headers);
  475.  
  476. $q = $this->db->update('account', "sha_pass_hash = '$enc'", "username = '$_POST[account]' AND email = '$_POST[email]'", '1');
  477. $this->msg(0, 'Please check your inbox, we\'ve sent you an e-mail containing your new password, it may arrive in your "Junk box" or "Spam folder" so make sure to check them out.');
  478. }
  479. }
  480.  
  481. function addNews($t = NULL, $m = NULL)
  482. {
  483. if(isset($_POST['addnews']))
  484. {
  485. if(empty($_POST['title']))
  486. {
  487. return $this->msg(1, 'News title may not be empty, please try again.');
  488. }
  489.  
  490. if(empty($_POST['news']))
  491. {
  492. return $this->msg(1, 'Message may not be empty, please try again.');
  493. }
  494.  
  495. $title = mysql_real_escape_string($_POST['title']);
  496. $msg = mysql_real_escape_string($_POST['news']);
  497.  
  498. $q = $this->db->insert('news',"title = '$title', message = '$msg', author = '".ucfirst(strtolower($_SESSION['username']))."'");
  499. if($q)
  500. {
  501. return $this->msg(0, 'News were added succesfully.');
  502. }
  503. else
  504. {
  505. return $this->msg(1, 'Something went wrong, please try again.');
  506. }
  507. }
  508. }
  509.  
  510. function editNews($id)
  511. {
  512. if(isset($_POST['editnews']))
  513. {
  514. if(empty($_POST['title']))
  515. {
  516. return $this->msg(1, 'News title may not be empty, please try again.');
  517. }
  518.  
  519. if(empty($_POST['news']))
  520. {
  521. return $this->msg(1, 'Message may not be empty, please try again.');
  522. }
  523.  
  524. $title = mysql_real_escape_string($_POST['title']);
  525. $msg = mysql_real_escape_string($_POST['news']);
  526.  
  527. $q = $this->db->update('news',"title = '$title', message = '$msg', author = '".ucfirst(strtolower($_SESSION['username']))."'", "id = '$id'", '1');
  528. if($q)
  529. {
  530. return $this->msg(0, 'News were edited succesfully.');
  531. }
  532. else
  533. {
  534. return $this->msg(1, 'Something went wrong, please try again.');
  535. }
  536. }
  537.  
  538. }
  539.  
  540. function delItem($type)
  541. {
  542. if(isset($_GET['admin']) && isset($_GET['delete']))
  543. {
  544. if($_GET['delete'] != NULL)
  545. {
  546. if(isset($_SESSION['gm']))
  547. {
  548. $id = $_GET['delete'];
  549. $q = $this->db->del($type, "id = '$id'");
  550. if($q)
  551. {
  552. return $this->msg(0, 'Item was deleted successfully.');
  553. }
  554. else
  555. {
  556. return $this->msg(1, 'Something went wrong, please try again.');
  557. }
  558. }
  559. }
  560. }
  561. }
  562.  
  563. function castVote($id)
  564. {
  565. $q = mysql_query("SELECT * FROM vlinks WHERE id = '" . $id . "'");
  566. if ($q && mysql_num_rows($q) == 1)
  567. {
  568. $row = mysql_fetch_object($q);
  569. $userid = $_SESSION['id'];
  570. if ($userid)
  571. {
  572. $q = mysql_query("SELECT * FROM vlogs WHERE vote_id = '" . $id . "' AND (id = '" . $userid . "' OR ip_address = '" . $_SERVER['REMOTE_ADDR'] . "') ORDER BY vote_date DESC");
  573.  
  574. $timenow = date("U");
  575. $timefuture = date("U")+43200;//12 hrs
  576. if (mysql_num_rows($q) >= 1)
  577. {
  578. $row2 = mysql_fetch_object($q);
  579. if ($row2->vote_date >= $timenow)
  580. {
  581. $timeaz=gmdate("G:i:s",$row2->vote_date-$timenow);
  582. return $this->msg(1, "You have to wait to vote for that site again.<br />" . $timeaz);
  583. }
  584. }
  585. mysql_query("INSERT INTO vlogs SET vote_id = '" . $id . "', id = '" . $userid . "', ip_address = '" . $_SERVER['REMOTE_ADDR'] . "', vote_date = '" . $timefuture . "'");
  586. mysql_query("UPDATE account SET vp = (vp + 1) WHERE id = '$userid' LIMIT 1") or die(mysql_error());
  587. }
  588. header('Location: ' . $row->url);
  589.  
  590. exit;
  591. }
  592. }
  593.  
  594. function getVoteSites()
  595. {
  596. if (isset($_POST['_id']))
  597. $this->castVote($_POST['_id']);
  598. ?>
  599. <form method="post" name="_vote" id="_vote" action="?page=vote">
  600. <input type="hidden" value="0" name="_id" id="_id" />
  601. <?php
  602. $q = mysql_query("SELECT * FROM vlinks");
  603. while ($row = mysql_fetch_object($q))
  604. {
  605. ?>
  606. <img src="<?php echo $row->imageurl; ?>" alt="<?php echo $row->title; ?>" onclick="castVote('<?php echo $row->id; ?>');" style="cursor:pointer;" width="90" height="55" />
  607. <?php
  608. }
  609. ?>
  610. </form>
  611. <script>
  612. function castVote(id)
  613. {
  614. document.getElementById('_id').value = id;
  615. document.getElementById('_vote').submit();
  616. }
  617. </script>
  618. <?php
  619. }
  620.  
  621. function getVoteRewards($is = NULL)
  622. {
  623. $table = ($is == NULL) ? 'vrewards' : 'vrewardstwo';
  624. $q = mysql_query("SELECT * FROM $table") or die(mysql_error());
  625. if(mysql_num_rows($q) != 0)
  626. {
  627. while($i = mysql_fetch_assoc($q))
  628. {
  629.  
  630. for($c = 1; $c <= 10; $c++)
  631. {
  632. if(!empty($i['stat'.$c]))
  633. {
  634. $stat[$c] = '<span class=\\\'margin-left:5px\\\'>'.$i['stat'.$c].'</span><br />';
  635. }
  636. else
  637. {
  638. $stat[$c] = '';
  639. }
  640. }
  641.  
  642. if($i['customItem'] == 'true')
  643. {
  644. echo '<tr><td width="250"><a href="javascript:;" onmouseover="$WowheadPower.showTooltip(event, \'<span class=\\\''
  645. . $i['itemType'] . ' bold\\\'>' . $i['itemName'] . '</span><br />' . $stat[1] . $stat[2]
  646. . $stat[3] . $stat[4] . $stat[6] . $stat[7] . $stat[8] . $stat[9] . $stat[10]
  647. . '<br /><span class=\\\'green\\\'>This item costs: <span style=\\\'color:white\\\'>'
  648. . $i['price'] . '</span></span>\', \'INV_Misc_Gift_01\')" onmousemove="$WowheadPower.moveTooltip(event)" onmouseout="$WowheadPower.hideTooltip();"><span class="'
  649. . $i['itemType'] . '">' . $i['itemName'] . '</span></a></td><td width="60" align="center"> ' . $i['price']
  650. . '</td><td width="80" align="center"> <a href="?buy=v&itemid=' . $i['itemid'] . '">Buy this item</a></td></tr>';
  651.  
  652. }
  653. else
  654. {
  655. echo '<tr><td width="250"><a href="javascript:;" rel="item=' . $i['itemid']
  656. . '"><span class="' . $i['itemType'] . '">' . $i['itemName'] . '</span></a></td><td width="60" align="center"> ' . $i['price']
  657. . '</td><td width="80" align="center"><a href="?buy=v&itemid=' . $i['itemid'] . '">Buy this item</a></td></tr>';
  658. }
  659.  
  660. }
  661. }
  662. else
  663. {
  664. echo '<i>No rewards have been added to the vote system, please contact an administrator.</i>';
  665. }
  666. }
  667.  
  668. function getDonationRewards($is = NULL)
  669. {
  670.  
  671. $table = ($is == NULL) ? 'drewards' : 'drewardstwo';
  672. $q = mysql_query("SELECT * FROM $table") or die(mysql_error());
  673. if(mysql_num_rows($q) != 0)
  674. {
  675. while($i = mysql_fetch_assoc($q))
  676. {
  677.  
  678. for($c = 1; $c <= 10; $c++)
  679. {
  680. if(!empty($i['stat'.$c]))
  681. {
  682. $stat[$c] = '<span class=\\\'margin-left:5px\\\'>'.$i['stat'.$c].'</span><br />';
  683. }
  684. else
  685. {
  686. $stat[$c] = '';
  687. }
  688. }
  689.  
  690. if($i['customItem'] == 'true')
  691. {
  692. echo '<tr><td width="250"><a href="javascript:;" onmouseover="$WowheadPower.showTooltip(event, \'<span class=\\\''
  693. . $i['itemType'] . ' bold\\\'>' . $i['itemName'] . '</span><br />' . $stat[1] . $stat[2]
  694. . $stat[3] . $stat[4] . $stat[6] . $stat[7] . $stat[8] . $stat[9] . $stat[10]
  695. . '<br /><span class=\\\'green\\\'>This item costs: <span style=\\\'color:white\\\'>'
  696. . $i['price'] . '</span></span>\', \'INV_Misc_Gift_01\')" onmousemove="$WowheadPower.moveTooltip(event)" onmouseout="$WowheadPower.hideTooltip();"><span class="'
  697. . $i['itemType'] . '">' . $i['itemName'] . '</span></a></td><td width="60" align="center"> ' . $i['price']
  698. . '</td><td width="80" align="center"> <a href="?buy=d&itemid=' . $i['itemid'] . '">Buy this item</a></td></tr>';
  699.  
  700. }
  701. else
  702. {
  703. echo '<tr><td width="250"><a href="javascript:;" rel="item=' . $i['itemid']
  704. . '"><span class="' . $i['itemType'] . '">' . $i['itemName'] . '</span></a></td><td width="60" align="center"> ' . $i['price']
  705. . '</td><td width="80" align="center"><a href="?buy=d&itemid=' . $i['itemid'] . '">Buy this item</a></td></tr>';
  706. }
  707.  
  708. }
  709. }
  710. else
  711. {
  712. echo '<i>No rewards have been added to the donation system, please contact an administrator.</i>';
  713. }
  714. }
  715.  
  716. function getChars($id)
  717. {
  718. global $donate, $db, $rauser, $rapass;
  719. $_SESSION['realmID'] = 1
  720. $dbselector = ($_SESSION['realmID'] == 1) ? $donate->chardb : $donate->chardbtwo;
  721. mysql_select_db($dbselector) or die(mysql_error());
  722.  
  723. $results = array();
  724. $q = $this->db->query("SELECT * FROM characters WHERE account = '$id'");
  725. if(mysql_num_rows($q) != 0)
  726. {
  727. while($row = mysql_fetch_assoc($q))
  728. {
  729. $results[] = $row;
  730. }
  731.  
  732. if(isset($_POST['purchase']))
  733. {
  734. $char = $_POST['char'];
  735. $this->buyItem($_GET['itemid'], $char, $_SESSION['realmID']);
  736. }
  737.  
  738. if(isset($_POST['unstuck']))
  739. {
  740. include("settings/config.php");
  741. ini_set("display_errors", 0);
  742. $char = $_POST['char'];
  743. $fp = fsockopen("logon.scorncraft.com", 3443, $errno, $errstr, 30);
  744. sleep (1);
  745. $out = "USER $rauser\n";
  746. $out2 = "PASS $rapass\n";
  747. $out3 = "tele name $char\n"; //send items
  748. fwrite($fp, $out);
  749. sleep (1);
  750. fwrite($fp, $out2);
  751. sleep (1);
  752. fwrite($fp, $out3);
  753. sleep (1);
  754. fclose($fp);
  755. if(!$fp)
  756. {
  757.  
  758. return $this->mmsg('error', 'Something went wrong (Probably the tool is offline try again later)');
  759. ini_set("display_errors", 1);
  760. }
  761. return $this->mmsg('success', 'Your character has been teleported to Dalaran.');
  762.  
  763. }
  764. if(isset($_POST['revive']))
  765. {
  766. $char = $_POST['char'];
  767. ini_set("display_errors", 0);
  768. include("settings/config.php");
  769. $fp = fsockopen("logon.scorncraft.com", 3443, $errno, $errstr, 30);
  770. sleep (1);
  771. $out = "USER $rauser\n";
  772. $out2 = "PASS $rapass\n";
  773. $out3 = "revive $char\n"; //revive
  774. fwrite($fp, $out);
  775. sleep (1);
  776. fwrite($fp, $out2);
  777. sleep (1);
  778. fwrite($fp, $out3);
  779. sleep (1);
  780. fclose($fp);
  781. if(!$fp)
  782. {
  783.  
  784. return $this->mmsg('error', 'Something went wrong (Probably the tool is offline try again later)');
  785. ini_set("display_errors", 1);
  786. }
  787. return $this->mmsg('success', 'Your character has been Revived.');
  788. }
  789. }
  790.  
  791. mysql_select_db($db->maindb);
  792. return $results;
  793. }
  794.  
  795. function getVChars($id)
  796. {
  797. global $donate, $db;
  798. $_SESSION['realmID'] = 1
  799. $dbselector = ($_SESSION['realmID'] == 1) ? $donate->chardb : $donate->chardbtwo;
  800. $this->db->sel_db($dbselector);
  801.  
  802. $results = array();
  803. $q = $this->db->query("SELECT * FROM characters WHERE account = '$id'");
  804. if(mysql_num_rows($q) != 0)
  805. {
  806. while($row = mysql_fetch_assoc($q))
  807. {
  808. $results[] = $row;
  809. }
  810.  
  811. if(isset($_POST['purchase']))
  812. {
  813. $char = $_POST['char'];
  814. $this->buyvItem($_GET['itemid'], $char, $_SESSION['realmID']);
  815. }
  816.  
  817. }
  818.  
  819. mysql_select_db($db->maindb);
  820. return $results;
  821. }
  822.  
  823.  
  824. function sendItem($itemId, $cName, $subject, $body, $realmId)
  825. {
  826. global $soap, $donate, $db, $rauser, $rapass, $rauser2, $rapass2;
  827. $dbselector = ($realmId == 1) ? $donate->chardb : $donate->chardbtwo;
  828. $this->db->sel_db($dbselector);
  829. $q = $this->db->select('guid', 'characters', '`name` = "' . $cName . '"');
  830. $count = mysql_num_rows($q);
  831. if ($count == 1)
  832. {
  833. try {
  834. if($realmId == 1)
  835. {
  836. $fp = fsockopen("logon.scorncraft.com", 3443, $errno, $errstr, 30);
  837. sleep (1);
  838.  
  839. $out = "USER $rauser\n";
  840. $out2 = "PASS $rapass\n";
  841. }
  842. if($realmId == 2)
  843. {
  844. $fp = fsockopen("logon.scorncraft.com", 3444, $errno, $errstr, 30);
  845. sleep (1);
  846.  
  847. $out = "USER $rauser2\n";
  848. $out2 = "PASS $rapass2\n";
  849. }
  850. $out3 = "send items $cName \"$subject\" \"$body\" $itemId\n"; //send items
  851. fwrite($fp, $out);
  852. sleep (1);
  853. fwrite($fp, $out2);
  854. sleep (1);
  855. fwrite($fp, $out3);
  856. sleep (1);
  857. fclose($fp);
  858.  
  859. if(!$fp)
  860. {
  861. return $this->mmsg('error', 'Something went wrong (Probably the tool is offline try again later)');
  862. ini_set("display_errors", 1);
  863. die();
  864. }
  865.  
  866. $this->db->sel_db($db->maindb);
  867. return true;
  868.  
  869. }
  870.  
  871. catch (Exception $e)
  872. {
  873. var_dump($e);exit;
  874. return false;
  875. }
  876.  
  877. }
  878.  
  879. $this->db->sel_db($db->maindb);
  880. }
  881.  
  882. function buyvItem($id, $char = NULL, $realmId)
  883. {
  884. global $db;
  885. mysql_select_db($db->maindb);
  886. $table = ($realmId == 1) ? 'vrewards' : 'vrewardstwo';
  887. $q = mysql_query("SELECT * FROM $table WHERE itemid = '$id'") or die(mysql_error());
  888.  
  889. if(!mysql_num_rows($q) == 0)
  890. {
  891. $i = mysql_fetch_assoc($q);
  892. $price = $i['price'];
  893.  
  894. echo 'You are purchasing:<br /><br />'.
  895. 'Item: <span class="'.$i['itemType'].' bold">'.$i['itemName'].'</span><br />'.
  896. 'Price: <span class="bold">'.$price.'</span><br /><br />'.
  897.  
  898. 'Are you sure you want to purchase this item?<br /><br />';
  899. }
  900. else
  901. {
  902. echo '<i>This item is not available.</i>';
  903. return;
  904. }
  905.  
  906. if(isset($_GET['buy']) && $char != NULL)
  907. {
  908. $this->loader();
  909. $userid = $_SESSION['id'];
  910.  
  911. $q = mysql_query("SELECT * FROM account WHERE id = '$userid'") or die(mysql_error());
  912.  
  913. if(mysql_num_rows($q) > 0)
  914. {
  915. $r = mysql_fetch_assoc($q);
  916. if($r['vp'] >= $price)
  917. {
  918. $total_points = $r['vp'] - $price;
  919.  
  920. if ($this->sendItem($id, $char, "Thanks for voting", "Unforgiven-WoW Thanks you for your support in keeping this server running!", $_SESSION['realmID']))
  921. {
  922. $this->db->sel_db($db->maindb);
  923. $q = $this->db->query("UPDATE account SET vp = '$total_points' WHERE id = '$userid' LIMIT 1");
  924. if($q) header("Location: ./?page=itembought");
  925. }
  926. }
  927. else
  928. {
  929. $this->mmsg('error','You do not have enough points, vote for more <a href="?page=vote">here</a>.');
  930. return;
  931. }
  932.  
  933. }
  934. else
  935. {
  936. return $this->msg(1,'User has no points or does not exist in the database, please contact administrator if this is wrong.');
  937. }
  938.  
  939. }
  940.  
  941. }
  942.  
  943. function loader()
  944. {
  945. global $db;
  946. mysql_select_db($db->maindb);
  947. echo '<img src="images/loaderbuy.gif" alt="loadergif"/>';
  948. }
  949.  
  950. function buyItem($id, $char = NULL, $realmId)
  951. {
  952. global $db;
  953. mysql_select_db($db->maindb);
  954.  
  955. $table = ($realmId == 1) ? 'drewards' : 'drewardstwo';
  956. $q = mysql_query("SELECT * FROM $table WHERE itemid = '$id'") or die(mysql_error());
  957.  
  958. if(!mysql_num_rows($q) == 0)
  959. {
  960. $i = mysql_fetch_assoc($q);
  961. $price = $i['price'];
  962.  
  963. echo 'You are purchasing:<br /><br />'.
  964. 'Item: <span class="'.$i['itemType'].' bold">'.$i['itemName'].'</span><br />'.
  965. 'Price: <span class="bold">'.$price.'</span><br /><br />'.
  966.  
  967. 'Are you sure you want to purchase this item?<br /><br />';
  968. }
  969. else
  970. {
  971. echo '<i>This item is not available.</i>';
  972. return;
  973. }
  974.  
  975. if(isset($_GET['buy']) && $char != NULL)
  976. {
  977. $userid = $_SESSION['id'];
  978.  
  979. $q = mysql_query("SELECT * FROM account WHERE id = '$userid'") or die(mysql_error());
  980.  
  981. if(mysql_num_rows($q) > 0)
  982. {
  983. $r = mysql_fetch_assoc($q);
  984. if($r['dp'] >= $price)
  985. {
  986. $total_points = $r['dp'] - $price;
  987.  
  988. if ($this->sendItem($id, $char, "Thanks for donating", "Unforgiven-WoW Thanks you for your support in keeping this server running!", $_SESSION['realmID']))
  989. {
  990. $this->db->sel_db($db->maindb);
  991. $q = $this->db->query("UPDATE account SET dp = '$total_points' WHERE id = '$userid' LIMIT 1");
  992.  
  993. if($q) header("Location: ./?page=itembought");
  994. }
  995.  
  996. }
  997. else
  998. {
  999. $this->mmsg('error','You do not have enough points, donate for more <a href="?page=donate">here</a>.');
  1000. return;
  1001. }
  1002.  
  1003. }
  1004. else
  1005. {
  1006. return $this->msg(1,'User has no points or does not exist in the database, please contact administrator if this is wrong.');
  1007. }
  1008.  
  1009. }
  1010.  
  1011. }
  1012.  
  1013. function addReward($type, $typetwo = NULL)
  1014. {
  1015. if(isset($_POST['additem']))
  1016. {
  1017. foreach($_POST as $c => $v)
  1018. {
  1019. $_POST[$c] = mysql_real_escape_string($v);
  1020. }
  1021.  
  1022. if(!isset($_POST['customitem']))
  1023. {
  1024. return $this->msg(1,'You must select the custom item value.');
  1025. }
  1026.  
  1027. if(!isset($_POST['itemtype']))
  1028. {
  1029. return $this->msg(1,'You must select an item color.');
  1030. }
  1031.  
  1032. if(!isset($_POST['itemName']) && !isset($_POST['itemid']))
  1033. {
  1034. return $this->msg(1,'You must fill in an Item name & ID');
  1035. }
  1036.  
  1037. $item_id = $_POST['itemid'];
  1038. $price = $_POST['price'];
  1039.  
  1040. if($_POST['customitem'] != 'true')
  1041. {
  1042. $q = $this->db->query("INSERT INTO $type SET itemName = '$_POST[itemname]', itemType = '$_POST[itemtype]', customItem = 'false', itemid = '$item_id', price = '$price'");
  1043. }
  1044. else
  1045. {
  1046. $q = $this->db->query("INSERT INTO $type SET customItem = 'true', itemid = '$item_id', itemName = '$_POST[itemname]', itemType = '$_POST[itemtype]', stat1 = '$_POST[stat1]', stat2 = '$_POST[stat2]', stat3 = '$_POST[stat3]', stat4 = '$_POST[stat4]', stat5 = '$_POST[stat5]', stat6 = '$_POST[stat6]', stat7 = '$_POST[stat7]', stat8 = '$_POST[stat8]', stat9 = '$_POST[stat9]', stat10 = '$_POST[stat10]', price = '$price'");
  1047. }
  1048.  
  1049. if(!$q)
  1050. {
  1051. return $this->msg(1,'Something went wrong, please try again.');
  1052. }
  1053. else
  1054. {
  1055. header("Location: ?admin");
  1056. exit;
  1057. }
  1058. }
  1059.  
  1060. if(isset($_POST['additemtwo']))
  1061. {
  1062. foreach($_POST as $c => $v)
  1063. {
  1064. $_POST[$c] = mysql_real_escape_string($v);
  1065. }
  1066.  
  1067. if(!isset($_POST['customitem']))
  1068. {
  1069. return $this->msg(1,'You must select the custom item value.');
  1070. }
  1071.  
  1072. if(!isset($_POST['itemtype']))
  1073. {
  1074. return $this->msg(1,'You must select an item color.');
  1075. }
  1076.  
  1077. if(!isset($_POST['itemName']) && !isset($_POST['itemid']))
  1078. {
  1079. return $this->msg(1,'You must fill in an Item name & ID');
  1080. }
  1081.  
  1082. $item_id = $_POST['itemid'];
  1083. $price = $_POST['price'];
  1084.  
  1085. if($_POST['customitem'] != 'true')
  1086. {
  1087. $q = $this->db->query("INSERT INTO $typetwo SET itemName = '$_POST[itemname]', itemType = '$_POST[itemtype]', customItem = 'false', itemid = '$item_id', price = '$price'");
  1088. }
  1089. else
  1090. {
  1091. $q = $this->db->query("INSERT INTO $typetwo SET customItem = 'true', itemid = '$item_id', itemName = '$_POST[itemname]', itemType = '$_POST[itemtype]', stat1 = '$_POST[stat1]', stat2 = '$_POST[stat2]', stat3 = '$_POST[stat3]', stat4 = '$_POST[stat4]', stat5 = '$_POST[stat5]', stat6 = '$_POST[stat6]', stat7 = '$_POST[stat7]', stat8 = '$_POST[stat8]', stat9 = '$_POST[stat9]', stat10 = '$_POST[stat10]', price = '$price'");
  1092. }
  1093.  
  1094. if(!$q)
  1095. {
  1096. return $this->msg(1,'Something went wrong, please try again.');
  1097. }
  1098. else
  1099. {
  1100. header("Location: ?admin");
  1101. exit;
  1102. }
  1103. }
  1104. }
  1105.  
  1106. function adminDeleteReward($type)
  1107. {
  1108. if(isset($_GET['admin']) && $_GET['admin'] == $type && isset($_GET['delete']))
  1109. {
  1110. $del = ($type == 'donations') ? 'drewards' : 'vrewards';
  1111. if(isset($_GET['true']) && $_GET['true'] == $_SESSION['id'])
  1112. {
  1113. $id = $_GET['delete'];
  1114. $q = $this->db->del($del, "itemid = '$id'");
  1115. header("Location: ./?admin=$type");
  1116. }
  1117. }
  1118. }
  1119.  
  1120. function adminDeleteRewardTwo($type)
  1121. {
  1122. if(isset($_GET['admin']) && $_GET['admin'] == $type && isset($_GET['delete']))
  1123. {
  1124. $del = ($type == 'donations') ? 'drewardstwo' : 'vrewardstwo';
  1125. if(isset($_GET['true']) && $_GET['true'] == $_SESSION['id'])
  1126. {
  1127. $id = $_GET['deletetwo'];
  1128. $q = $this->db->del($del, "itemid = '$id'");
  1129. header("Location: ./?admin=$type");
  1130. }
  1131. }
  1132. }
  1133.  
  1134. function adminDeleteSite($type)
  1135. {
  1136. if(isset($_GET['admin']) && $_GET['admin'] == $type && isset($_GET['delete']))
  1137. {
  1138. $del = ($type == 'sites') ? 'vlinks' : 'THIS DOEZ NOT WORK!!404 ERROR OMGAD';
  1139. if(isset($_GET['true']) && $_GET['true'] == $_SESSION['id'])
  1140. {
  1141. $id = $_GET['delete'];
  1142. $q = $this->db->del($del, "id = '$id'");
  1143. header("Location: ./?admin=$type");
  1144. }
  1145. }
  1146. }
  1147.  
  1148. function addSite()
  1149. {
  1150. if(isset($_POST['addsite']))
  1151. {
  1152. foreach($_POST as $c => $v)
  1153. {
  1154. $_POST[$c] = mysql_real_escape_string($v);
  1155. }
  1156.  
  1157. if(empty($_POST['title'])) return $this->msg(1,'Voting title is empty, please try again.');
  1158. if(empty($_POST['imageurl'])) return $this->msg(1, 'Image url is empty, please try again.');
  1159. if(empty($_POST['url'])) return $tihs->msg(1, 'Link is empty, please try again.');
  1160.  
  1161. $q = $this->db->query("INSERT INTO vlinks SET title = '$_POST[title]', imageurl = '$_POST[imageurl]', url = '$_POST[url]'");
  1162. if($q)
  1163. {
  1164. header("Location: ./?admin=sites");
  1165. exit;
  1166. }
  1167. else
  1168. {
  1169. return $this->msg(1, 'Something went wrong, please try again.');
  1170. }
  1171. }
  1172. }
  1173.  
  1174. function playersOnline($id)
  1175. {
  1176. global $realm, $db;
  1177. $dbs = explode(',', $realm->chardb);
  1178.  
  1179. $this->db->sel_db($dbs[$id]);
  1180. $q = $this->db->query("SELECT * FROM characters WHERE online = 1");
  1181.  
  1182. while($row = mysql_fetch_assoc($q))
  1183. {
  1184. print '<tr>
  1185. <td>&nbsp;'.$row['name'].'</td>
  1186. <td>&nbsp;'.$row['level'].'</td>
  1187. <td>&nbsp;<img src="images/stats/'.$row['class'].'.gif" /></td>
  1188. <td>&nbsp;<img src="images/stats/'.$row['race']."-".$row['gender'].'.gif" /></td>
  1189.  
  1190. </tr>';
  1191. }
  1192.  
  1193. return $this->db->sel_db($db->maindb);
  1194. }
  1195.  
  1196. function statusOnline($id)
  1197. {
  1198. global $realm, $db;
  1199. $dbs = explode(',', $realm->chardb);
  1200.  
  1201. $this->db->sel_db($dbs[$id]);
  1202. $q = $this->db->query("SELECT * FROM characters WHERE online = 1");
  1203. $online = mysql_num_rows($q);
  1204. $this->db->sel_db($db->maindb);
  1205.  
  1206. return print $online;
  1207. }
  1208. }
  1209. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement