Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2017
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.92 KB | None | 0 0
  1. <?php
  2. if(!function_exists('is_sale_percentage_off')){
  3. function is_sale_percentage_off(){
  4. global $set;
  5. if(!empty($set['sale_off_dates'])){
  6. $sale_off_dates = implode(',', unserialize($set['sale_off_dates']));
  7. if(!empty($sale_off_dates)){
  8. $dates = explode(',',$sale_off_dates);
  9. $today = date('m/d/Y');
  10. foreach($dates as $date){
  11. if($today == trim($date)){
  12. return true;
  13. }
  14. }
  15. }
  16. return false;
  17. }else{
  18. return false;
  19. }
  20. }
  21. }
  22.  
  23. function getheist($id)
  24. {
  25. global $db;
  26. $res = $db->query("SELECT `hname` FROM `heists` WHERE `hid` = '".$id."'");
  27. $row = $db->fetch_row($res);
  28. return htmlentities($row['hname']);
  29. }
  30. function getuser($id)
  31. {
  32. global $db;
  33. $res = $db->query("SELECT `username` FROM `users` WHERE `userid` = '".$id."'");
  34. $row = $db->fetch_row($res);
  35. return "<a href='viewuser.php?u={$id}'><span style='color:red'>".htmlentities($row['username'])."</span></a>";
  36. }
  37. function heist_dropdown($connection, $ddname = "heists", $selected = -1)
  38. {
  39. global $db;
  40. $ret = "<select name='$ddname' type='dropdown'>";
  41. $q =
  42. $db->query(
  43. "SELECT `hid`, `hname`
  44. FROM `heists`
  45. ORDER BY `hname` ASC");
  46. if ($selected == -1)
  47. {
  48. $first = 0;
  49. }
  50. else
  51. {
  52. $first = 1;
  53. }
  54. while ($r = $db->fetch_row($q))
  55. {
  56. $ret .= "\n<option value='{$r['hid']}'";
  57. if ($selected == $r['hid'] || $first == 0)
  58. {
  59. $ret .= " selected='selected'";
  60. $first = 1;
  61. }
  62. $ret .= ">{$r['hname']}</option>";
  63. }
  64. $db->free_result($q);
  65. $ret .= "\n</select>";
  66. return $ret;
  67. }
  68.  
  69.  
  70.  
  71.  
  72. function stat_format($stat_format) {
  73. // first strip any formatting;
  74. $stat_format = (0+str_replace(",","",$stat_format));
  75.  
  76. // is this a number?
  77. if(!is_numeric($stat_format)) return false;
  78.  
  79. // now filter it;
  80. if($stat_format>1000000000000) return round(($stat_format/1000000000000),1).'T';
  81. else if($stat_format>1000000000) return round(($stat_format/1000000000),1).'B';
  82. else if($stat_format>1000000) return round(($stat_format/1000000),1).'M';
  83. else if($stat_format>1000) return round(($stat_format/1000),1).'K';
  84.  
  85.  
  86. return number_format($stat_format);
  87. }
  88.  
  89.  
  90.  
  91.  
  92. function cash_format($cash_format) {
  93. // first strip any formatting;
  94. $cash_format = (0+str_replace(",","",$cash_format));
  95.  
  96. // is this a number?
  97. if(!is_numeric($cash_format)) return false;
  98.  
  99. // now filter it;
  100. if($cash_format>1000000000000) return round(($cash_format/1000000000000),1).'T';
  101. else if($cash_format>1000000000) return round(($cash_format/1000000000),1).'B';
  102. else if($cash_format>1000000) return round(($cash_format/1000000),1).'M';
  103.  
  104.  
  105. return number_format($cash_format);
  106. }
  107.  
  108.  
  109.  
  110. if(!function_exists('calculate_sale_percentage_off')){
  111. function calculate_sale_percentage_off(){
  112. global $set;
  113. if(isset($set['percent_off_sale'])){
  114. return (1 - ($set['percent_off_sale'] / 100));
  115. }else{
  116. return 0;
  117. }
  118. }
  119. }
  120.  
  121. if(!function_exists('sms_send')){
  122. function sms_send($message,$user){
  123. global $ir,$c,$userid;
  124. $gamename="City of Mafia";
  125. //Do not include www. or http:// in the game url
  126. $gameurl="CityofMafia.com";
  127. $blah=mysql_query("SELECT * FROM users WHERE userid=$user",$c);
  128. $r=mysql_fetch_array($blah);
  129.  
  130. if(($r['notify'] == 0) && ($r['user_level'] != 0)){
  131.  
  132. $recipient = $r['email']; //recipient
  133. $username = $r['username']; //username
  134. $mail_body = "$message";
  135.  
  136. include "lib/swift_required.php";
  137. include "lib/SmtpApiHeader.php";
  138.  
  139. $hdr = new SmtpApiHeader();
  140.  
  141. // Specify that this is an initial contact message
  142. $hdr->setCategory("initial");
  143.  
  144. // The subject of your email
  145. $subject = "Game Alert";
  146.  
  147. // Where is this message coming from. For example, this message can be from support@yourcompany.com, info@yourcompany.com
  148. $from = array("admin@CityofMafia.com" => "City of Mafia");
  149.  
  150. // If you do not specify a sender list above, you can specifiy the user here. If a sender list IS specified above
  151. // This email address becomes irrelevant.
  152. $to = array("$recipient"=>"$username");
  153.  
  154. # Create the body of the message (a plain-text and an HTML version).
  155. # text is your plain-text email
  156. # html is your html version of the email
  157. # if the reciever is able to view html emails then only the html
  158. # email will be displayed
  159.  
  160. /*
  161. * Note the variable substitution here =)
  162. */
  163.  
  164. $text = $mail_body;
  165.  
  166. $html = $mail_body;
  167.  
  168. // Your SendGrid account credentials
  169. $username = 'mafiahustle';
  170. $password = 'asdaasda123';
  171.  
  172. // Create new swift connection and authenticate
  173. $transport = Swift_SmtpTransport::newInstance('smtp.sendgrid.net', 587);
  174. $transport ->setUsername($username);
  175. $transport ->setPassword($password);
  176. $swift = Swift_Mailer::newInstance($transport);
  177.  
  178. // Create a message (subject)
  179. $message = new Swift_Message($subject);
  180.  
  181. // add SMTPAPI header to the message
  182. $headers = $message->getHeaders();
  183. $headers->addTextHeader('X-SMTPAPI', $hdr->asJSON());
  184.  
  185. // attach the body of the email
  186. $message->setFrom($from);
  187. $message->setBody($html, 'text/html');
  188. $message->setTo($to);
  189. $message->addPart($text, 'text/plain');
  190.  
  191. // send message
  192. if ($recipients = $swift->send($message, $failures))
  193. {
  194. // This will let us know how many users received this message
  195. // If we specify the names in the X-SMTPAPI header, then this will always be 1.
  196. //echo 'Message sent out to '.$recipients.' users';
  197. }
  198. // something went wrong =(
  199. else
  200. {
  201. //echo "Something went wrong - ";
  202. //print_r($failures);
  203. }
  204.  
  205.  
  206. }
  207.  
  208.  
  209.  
  210. if($type == 1 && $r['phoneon'] == 1)
  211. {
  212. $Name = "$gamename"; //senders name
  213. $email = "email@$gameurl"; //senders e-mail address
  214. $recipient = "{$r['myphone']}"; //recipient
  215. $mail_body = " $message"; //mail body
  216. $subject = "Notify"; //subject
  217. $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
  218. mail($recipient, $subject, $mail_body, $header); //mail command :)
  219. }
  220.  
  221. }
  222. }
  223.  
  224. if(!function_exists('welcome_email')){
  225. function welcome_email($mail_body,$user){
  226. $blah=mysql_query("SELECT * FROM users WHERE userid=$user");
  227. $r=mysql_fetch_array($blah);
  228. if(($r['notify'] == 0) && ($r['user_level'] != 0)){
  229.  
  230. $recipient = $r['email']; //recipient
  231. $username = $r['username']; //username
  232.  
  233. include "lib/swift_required.php";
  234. include "lib/SmtpApiHeader.php";
  235.  
  236. $hdr = new SmtpApiHeader();
  237.  
  238. // Specify that this is an initial contact message
  239. $hdr->setCategory("welcome");
  240.  
  241. // The subject of your email
  242. $subject = "Welcome to City of Mafia";
  243.  
  244. // Where is this message coming from. For example, this message can be from support@yourcompany.com, info@yourcompany.com
  245. $from = array("no-reply@CityofMafia.com" => "City of Mafia");
  246.  
  247. // If you do not specify a sender list above, you can specifiy the user here. If a sender list IS specified above
  248. // This email address becomes irrelevant.
  249. $to = array("$recipient"=>"$username");
  250.  
  251. # Create the body of the message (a plain-text and an HTML version).
  252. # text is your plain-text email
  253. # html is your html version of the email
  254. # if the reciever is able to view html emails then only the html
  255. # email will be displayed
  256.  
  257. /*
  258. * Note the variable substitution here =)
  259. */
  260.  
  261. $text = $mail_body;
  262.  
  263. $html = $mail_body;
  264.  
  265. // Your SendGrid account credentials
  266. // Your SendGrid account credentials
  267. $username = 'mafiahustle';
  268. $password = 'asdaasda123';
  269.  
  270. // Create new swift connection and authenticate
  271. $transport = Swift_SmtpTransport::newInstance('smtp.sendgrid.net', 587);
  272. $transport ->setUsername($username);
  273. $transport ->setPassword($password);
  274. $swift = Swift_Mailer::newInstance($transport);
  275.  
  276. // Create a message (subject)
  277. $message = new Swift_Message($subject);
  278.  
  279. // add SMTPAPI header to the message
  280. $headers = $message->getHeaders();
  281. $headers->addTextHeader('X-SMTPAPI', $hdr->asJSON());
  282.  
  283. // attach the body of the email
  284. $message->setFrom($from);
  285. $message->setBody($html, 'text/html');
  286. $message->setTo($to);
  287. $message->addPart($text, 'text/plain');
  288.  
  289. // send message
  290. if ($recipients = $swift->send($message, $failures))
  291. {
  292. // This will let us know how many users received this message
  293. // If we specify the names in the X-SMTPAPI header, then this will always be 1.
  294. //echo 'Message sent out to '.$recipients.' users';
  295. }
  296. // something went wrong =(
  297. else
  298. {
  299. //echo "Something went wrong - ";
  300. //print_r($failures);
  301. }
  302.  
  303.  
  304. }
  305.  
  306. }
  307. }
  308.  
  309. if(!function_exists('time_format')){
  310. function time_format($seconds){
  311. // Made by MagicTallGuy
  312. $seconds = floor($seconds);
  313. $days = intval($seconds / 86400);
  314. $seconds -= ($days * 86400);
  315. $hours = intval($seconds / 3600);
  316. $seconds -= ($hours * 3600);
  317. $minutes = intval($seconds / 60);
  318. $seconds -= ($minutes * 60);
  319. $result = array();
  320.  
  321. if($days) { $result[] = sprintf("%u day%s", number_format($days), ($days == 1) ? "" : "s"); }
  322. if($hours) { $result[] = sprintf("%u hour%s", $hours, ($hours == 1) ? "" : "s"); }
  323. if($minutes && (count($result) < 2)) { $result[] = sprintf("%u minute%s", $minutes, ($minutes == 1) ? "" : "s"); }
  324. if(($seconds && (count($result) < 2)) || !count($result)) { $result[] = sprintf("%u second%s", $seconds, ($seconds == 1) ? "" : "s"); }
  325. return implode(", ", $result);
  326. }
  327. }
  328.  
  329. if(!function_exists('bbcode')){
  330. function bbcode($code){
  331.  
  332. $code = htmlentities($code);
  333. $search = array
  334. (
  335. '~\[b\](.*?)\[/b\]~is',
  336. '~\[i\](.*?)\[/i\]~is',
  337. '~\[size=(.+)\](.*?)\[/size\]~is',
  338. '~\[center](.*?)\[/center\]~is',
  339. '~\[left](.*?)\[/left\]~is',
  340. '~\[right](.*?)\[/right\]~is',
  341. '~\[color=(.+)\](.*?)\[/color\]~is',
  342. '~\[profile=([0-9])\](.*?)\[/profile\]~is',
  343. '~\[img\](.*?)\[/img\]~is',
  344. '~\[code\](.*?)\[/code\]~is',
  345. '~\[quote=(.+)\](.*?)\[/quote\]~is',
  346. '~\[url=(.+)\](.*?)\[/url\]~is',
  347. '~\[u\](.*?)\[/u\]~is',
  348. '~\[s\](.*?)\[/s\]~is',
  349. '~\[o\](.*?)\[/o\]~is',
  350. '~\[acronym=(.+)\](.*?)\[/acronym\]~is',
  351. );
  352. $replace = array
  353. (
  354. '<strong>\\1</strong>',
  355. '<em>\\1</em>',
  356. '<span style="font-size: \\1;">\\2</span>',
  357. '<div style="padding: 0;" align="center">\\1</div>',
  358. '<div style="padding: 0; float: left;">\\1</div>',
  359. '<div style="padding: 0; float: right;">\\1</div>',
  360. '<span style="color: \\1;">\\2</span>',
  361. '<a href="viewuser.php?u=\\1">\\2</a>',
  362. '<img src="\\1" alt="Image unavailable" />',
  363. '<span style="font-size: 11px;">Code:</span><br />
  364. <div style="border: 1px black solid; background: #CCC; width: 99%; max-height: 24em; display: block; white-space: nowrap; overflow: auto;
  365. line-height: 1.3em; overflow: auto;">\\1</div>',
  366. '<span style="font-size: 11px;">Quote From=<strong>\\1</strong></span>
  367. <div style="border: 1px black solid; background: #FFF; color: #000; width: 50%; height: auto;">\\2</div>',
  368. '<a href="\\1" target="user_link">\\2</a>',
  369. '<span style="text-decoration: underline;">\\1</span>',
  370. '<span style="text-decoration: line-through;">\\1</span>',
  371. '<span style="text-decoration: overline;">\\1</span>',
  372. '<span style="text-decoration: underline;" title="\\1">\\2</span>',
  373. );
  374. $code = preg_replace('~\&lt;br \/&gt;~is','<br />',$code);
  375. $code = preg_replace('~\&lt;br&gt;~is','<br />',$code);
  376. $code = str_replace('\n','<br />',$code);
  377. $code = str_replace('\r','',$code);
  378. $code = str_replace('\\','',$code);
  379. $code = nl2br($code);
  380. return stripslashes(preg_replace($search, $replace, $code));
  381. }
  382. }
  383.  
  384. if(!function_exists('money_formatter')){
  385. function money_formatter($muny,$symb='$'){
  386. return $symb.number_format($muny);
  387. }
  388. }
  389.  
  390. if(!function_exists('itemtype_dropdown')){
  391. function itemtype_dropdown($connection,$ddname="item_type",$selected=-1){
  392.  
  393. global $db;
  394. $ret="<select name='$ddname' type='dropdown'>";
  395. $q=$db->query("SELECT * FROM itemtypes ORDER BY itmtypename ASC");
  396. if($selected == -1) { $first=0; } else { $first=1; }
  397. while($r=$db->fetch_row($q))
  398. {
  399. $ret.="\n<option value='{$r['itmtypeid']}'";
  400. if ($selected == $r['itmtypeid'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  401. $ret.=">{$r['itmtypename']}</option>";
  402. }
  403. $ret.="\n</select>";
  404. return $ret;
  405. }
  406. }
  407.  
  408. if(!function_exists('item_dropdown')){
  409. function item_dropdown($connection,$ddname="item",$selected=-1){
  410.  
  411. global $db;
  412. $ret="<select name='$ddname' type='dropdown'>";
  413. $q=$db->query("SELECT * FROM items ORDER BY itmid ASC");
  414. if($selected == -1) { $first=0; } else { $first=1; }
  415. while($r=$db->fetch_row($q))
  416. {
  417. $ret.="\n<option value='{$r['itmid']}'";
  418. if ($selected == $r['itmid'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  419. $ret.=">{$r['itmname']}[{$r['itmid']}]</option>";
  420. }
  421. $ret.="\n</select>";
  422. return $ret;
  423. }
  424. }
  425.  
  426. if(!function_exists('item2_dropdown')){
  427. function item2_dropdown($connection,$ddname="item",$selected=-1){
  428.  
  429. global $db;
  430. $ret="<select name='$ddname' type='dropdown'>";
  431. $q=$db->query("SELECT * FROM items ORDER BY itmname ASC");
  432. if($selected < 1) { $ret.="<option value='0' selected='selected'>-- None --</option>"; }
  433. else { $ret.="<option value='0'>-- None --</option>"; }
  434. while($r=$db->fetch_row($q))
  435. {
  436. $ret.="\n<option value='{$r['itmid']}'";
  437. if ($selected == $r['itmid']) { $ret.=" selected='selected'";$first=1; }
  438. $ret.=">{$r['itmname']}</option>";
  439. }
  440. $ret.="\n</select>";
  441. return $ret;
  442. }
  443. }
  444.  
  445. if(!function_exists('location_dropdown')){
  446. function location_dropdown($connection,$ddname="location",$selected=-1){
  447.  
  448. global $db;
  449. $ret="<select name='$ddname' type='dropdown'>";
  450. $q=$db->query("SELECT * FROM cities ORDER BY cityname ASC");
  451. if($selected == -1) { $first=0; } else { $first=1; }
  452. while($r=$db->fetch_row($q))
  453. {
  454. $ret.="\n<option value='{$r['cityid']}'";
  455. if ($selected == $r['cityid'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  456. $ret.= ">{$r['cityname']}</option>";
  457. }
  458. $ret.="\n</select>";
  459. return $ret;
  460. }
  461. }
  462.  
  463. if(!function_exists('shop_dropdown')){
  464. function shop_dropdown($connection,$ddname="shop",$selected=-1){
  465.  
  466. global $db;
  467. $ret="<select name='$ddname' type='dropdown'>";
  468. $q=$db->query("SELECT * FROM shops ORDER BY shopNAME ASC");
  469. if($selected == -1) { $first=0; } else { $first=1; }
  470. while($r=$db->fetch_row($q))
  471. {
  472. $ret.="\n<option value='{$r['shopID']}'";
  473. if ($selected == $r['shopID'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  474. $ret.= ">{$r['shopNAME']}</option>";
  475. }
  476. $ret.="\n</select>";
  477. return $ret;
  478. }
  479. }
  480.  
  481. if(!function_exists('user_dropdown')){
  482. function user_dropdown($connection,$ddname="user",$selected=-1){
  483.  
  484. global $db;
  485. $ret="<select name='$ddname' type='dropdown'>";
  486. $q=$db->query("SELECT * FROM users ORDER BY username ASC");
  487. if($selected == -1) { $first=0; } else { $first=1; }
  488. while($r=$db->fetch_row($q))
  489. {
  490. $ret.="\n<option value='{$r['userid']}'";
  491. if ($selected == $r['userid'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  492. $ret.= ">{$r['username']}</option>";
  493. }
  494. $ret.="\n</select>";
  495. return $ret;
  496. }
  497. }
  498.  
  499. if(!function_exists('challengebot_dropdown')){
  500. function challengebot_dropdown($connection,$ddname="bot",$selected=-1){
  501.  
  502. global $db;
  503. $ret="<select name='$ddname' type='dropdown'>";
  504. $q=$db->query("SELECT cb.*,u.* FROM challengebots AS cb LEFT JOIN users AS u ON cb.cb_npcid=u.userid ORDER BY u.username ASC");
  505. if($selected == -1) { $first=0; } else { $first=1; }
  506. while($r=$db->fetch_row($q))
  507. {
  508. $ret.="\n<option value='{$r['userid']}'";
  509. if ($selected == $r['userid'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  510. $ret.= ">{$r['username']}</option>";
  511. }
  512. $ret.="\n</select>";
  513. return $ret;
  514. }
  515. }
  516.  
  517. if(!function_exists('fed_user_dropdown')){
  518. function fed_user_dropdown($connection,$ddname="user",$selected=-1){
  519.  
  520. global $db;
  521. $ret="<select name='$ddname' type='dropdown'>";
  522. $q=$db->query("SELECT * FROM users WHERE fedjail=1 ORDER BY username ASC");
  523. if($selected == -1) { $first=0; } else { $first=1; }
  524. while($r=$db->fetch_row($q))
  525. {
  526. $ret.="\n<option value='{$r['userid']}'";
  527. if ($selected == $r['userid'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  528. $ret.= ">{$r['username']}</option>";
  529. }
  530. $ret.="\n</select>";
  531. return $ret;
  532. }
  533. }
  534.  
  535. if(!function_exists('mailb_user_dropdown')){
  536. function mailb_user_dropdown($connection,$ddname="user",$selected=-1){
  537.  
  538. global $db;
  539. $ret="<select name='$ddname' type='dropdown'>";
  540. $q=$db->query("SELECT * FROM users WHERE mailban > 0 ORDER BY username ASC");
  541. if($selected == -1) { $first=0; } else { $first=1; }
  542. while($r=$db->fetch_row($q))
  543. {
  544. $ret.="\n<option value='{$r['userid']}'";
  545. if ($selected == $r['userid'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  546. $ret.= ">{$r['username']}</option>";
  547. }
  548. $ret.="\n</select>";
  549. return $ret;
  550. }
  551. }
  552.  
  553. if(!function_exists('forumb_user_dropdown')){
  554. function forumb_user_dropdown($connection,$ddname="user",$selected=-1){
  555.  
  556. global $db;
  557. $ret="<select name='$ddname' type='dropdown'>";
  558. $q=$db->query("SELECT * FROM users WHERE forumban > 0 ORDER BY username ASC");
  559. if($selected == -1) { $first=0; } else { $first=1; }
  560. while($r=$db->fetch_row($q))
  561. {
  562. $ret.="\n<option value='{$r['userid']}'";
  563. if ($selected == $r['userid'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  564. $ret.= ">{$r['username']}</option>";
  565. }
  566. $ret.="\n</select>";
  567. return $ret;
  568. }
  569. }
  570.  
  571. if(!function_exists('job_dropdown')){
  572. function job_dropdown($connection,$ddname="job",$selected=-1){
  573.  
  574. global $db;
  575. $ret="<select name='$ddname' type='dropdown'>";
  576. $q=$db->query("SELECT * FROM jobs ORDER BY jNAME ASC");
  577. if($selected == -1) { $first=0; } else { $first=1; }
  578. while($r=$db->fetch_row($q))
  579. {
  580. $ret.="\n<option value='{$r['jID']}'";
  581. if ($selected == $r['jID'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  582. $ret.=">{$r['jNAME']}</option>";
  583. }
  584. $ret.="\n</select>";
  585. return $ret;
  586. }
  587. }
  588.  
  589. if(!function_exists('jobrank_dropdown')){
  590. function jobrank_dropdown($connection,$ddname="jobrank",$selected=-1){
  591.  
  592. global $db;
  593. $ret="<select name='$ddname' type='dropdown'>";
  594. $q=$db->query("SELECT jr.*,j.* FROM jobranks jr LEFT JOIN jobs j ON jr.jrJOB=j.jID ORDER BY j.jNAME ASC, jr.jrNAME ASC");
  595. if($selected == -1) { $first=0; } else { $first=1; }
  596. while($r=$db->fetch_row($q))
  597. {
  598. $ret.="\n<option value='{$r['jrID']}'";
  599. if ($selected == $r['jrID'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  600. $ret.=">{$r['jNAME']} - {$r['jrNAME']}</option>";
  601. }
  602. $ret.="\n</select>";
  603. return $ret;
  604. }
  605. }
  606.  
  607. if(!function_exists('house_dropdown')){
  608. function house_dropdown($connection,$ddname="house",$selected=-1){
  609.  
  610. global $db;
  611. $ret="<select name='$ddname' type='dropdown'>";
  612. $q=$db->query("SELECT * FROM houses ORDER BY hNAME ASC");
  613. if($selected == -1) { $first=0; } else { $first=1; }
  614. while($r=$db->fetch_row($q))
  615. {
  616. $ret.="\n<option value='{$r['hID']}'";
  617. if ($selected == $r['hID'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  618. $ret.=">{$r['hNAME']}</option>";
  619. }
  620. $ret.="\n</select>";
  621. return $ret;
  622. }
  623. }
  624.  
  625. if(!function_exists('house2_dropdown')){
  626. function house2_dropdown($connection,$ddname="house",$selected=-1){
  627.  
  628. global $db;
  629. $ret="<select name='$ddname' type='dropdown'>";
  630. $q=$db->query("SELECT * FROM houses ORDER BY hNAME ASC");
  631. if($selected == -1) { $first=0; } else { $first=1; }
  632. while($r=$db->fetch_row($q))
  633. {
  634. $ret.="\n<option value='{$r['hWILL']}'";
  635. if ($selected == $r['hWILL'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  636. $ret.=">{$r['hNAME']}</option>";
  637. }
  638. $ret.="\n</select>";
  639. return $ret;
  640. }
  641. }
  642.  
  643. if(!function_exists('course_dropdown')){
  644. function course_dropdown($connection,$ddname="course",$selected=-1){
  645.  
  646. global $db;
  647. $ret="<select name='$ddname' type='dropdown'>";
  648. $q=$db->query("SELECT * FROM courses ORDER BY crNAME ASC");
  649. if($selected == -1) { $first=0; } else { $first=1; }
  650. while($r=$db->fetch_row($q))
  651. {
  652. $ret.="\n<option value='{$r['crID']}'";
  653. if ($selected == $r['crID'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  654. $ret.=">{$r['crNAME']}</option>";
  655. }
  656. $ret.="\n</select>";
  657. return $ret;
  658. }
  659. }
  660.  
  661. if(!function_exists('crime_dropdown')){
  662. function crime_dropdown($connection,$ddname="crime",$selected=-1){
  663.  
  664. global $db;
  665. $ret="<select name='$ddname' type='dropdown'>";
  666. $q=$db->query("SELECT * FROM crimes ORDER BY crimeNAME ASC");
  667. if($selected == -1) { $first=0; } else { $first=1; }
  668. while($r=$db->fetch_row($q))
  669. {
  670. $ret.="\n<option value='{$r['crimeID']}'";
  671. if ($selected == $r['crimeID'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  672. $ret.=">{$r['crimeNAME']}</option>";
  673. }
  674. $ret.="\n</select>";
  675. return $ret;
  676. }
  677. }
  678.  
  679. if(!function_exists('crimegroup_dropdown')){
  680. function crimegroup_dropdown($connection,$ddname="crimegroup",$selected=-1){
  681.  
  682. global $db;
  683. $ret="<select name='$ddname' type='dropdown'>";
  684. $q=$db->query("SELECT * FROM crimegroups ORDER BY cgNAME ASC");
  685. if($selected == -1) { $first=0; } else { $first=1; }
  686. while($r=$db->fetch_row($q))
  687. {
  688. $ret.="\n<option value='{$r['cgID']}'";
  689. if ($selected == $r['cgID'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  690. $ret.=">{$r['cgNAME']}</option>";
  691. }
  692. $ret.="\n</select>";
  693. return $ret;
  694. }
  695. }
  696.  
  697. if(!function_exists('event_add')){
  698. function event_add($userid,$text,$connection=0){
  699.  
  700. global $db;
  701. $text=mysql_escape($text);
  702. $db->query("INSERT INTO events (evUSER, evTIME, evREAD, evTEXT) VALUES($userid,UNIX_TIMESTAMP(),0,'$text')");
  703. $db->query("UPDATE users SET new_events=new_events+1 WHERE userid={$userid}");
  704. return 1;
  705. }
  706. }
  707.  
  708. if(!function_exists('mysql_escape')){
  709. function mysql_escape($str){
  710.  
  711. return str_replace("'","''",$str);
  712. }
  713. }
  714.  
  715. if(!function_exists('check_level')){
  716. function check_level(){
  717.  
  718. global $db;
  719. global $ir,$c,$userid;
  720. $ir['exp_needed']=(int) (($ir['level']+2)*($ir['level']+2)*($ir['level']+2)*3.5);
  721. // LEVEL CAP INFO IS BELOW \\
  722. if($ir['exp'] >= $ir['exp_needed'] and $ir['level'] < 1000)
  723. {
  724. $expu=$ir['exp']-$ir['exp_needed'];
  725. $ir['level']+=1;
  726. $ir['exp']=$expu;
  727. $ir['brave']+=2;
  728. $ir['maxbrave']+=2;
  729. $ir['hp']+=50;
  730. $ir['maxhp']+=50;
  731. $ir['merits']+=2;
  732.  
  733. $ir['energy']=$ir['maxenergy'];
  734. $ir['brave']=$ir['maxbrave'];
  735. $ir['will']=$ir['maxwill'];
  736. $ir['hp']=$ir['maxhp'];
  737.  
  738. $ir['exp_needed']=(int) (($ir['level']+2)*($ir['level']+2)*($ir['level']+2)*3.5);
  739. $db->query("UPDATE users SET level=level+1,exp=$expu,brave=brave+2,merits=merits+2,maxbrave=maxbrave+2,
  740. hp=hp+50,maxhp=maxhp+50,mlevel=mlevel+1 where userid=$userid");
  741. $db->query("UPDATE users SET brave=maxbrave, energy=maxenergy, will=maxwill, hp=maxhp WHERE userid=$userid");
  742.  
  743. event_add($userid,"Congratulations! You are now level <b>".$ir['level']."</b> and have earned 2 merit points.",$c);
  744. }
  745. }
  746. }
  747.  
  748. if(!function_exists('get_rank')){
  749. function get_rank($stat, $mykey){
  750.  
  751. global $db;
  752. global $ir,$userid,$c;
  753. $q=$db->query("SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.$mykey > $stat AND us.userid != $userid AND u.user_level != 0") ;
  754. return $db->fetch_single($q)+1;
  755. }
  756. }
  757. if(!function_exists('get_level')){
  758. function get_level($stat, $mykey){
  759.  
  760. global $db;
  761. global $ir,$userid,$c;
  762. $q=$db->query("SELECT count(*) FROM users WHERE $mykey > $stat AND userid != $userid AND user_level != 0 AND user_level != 2") ;
  763. return $db->fetch_single($q)+1;
  764. }
  765. }
  766.  
  767. if(!function_exists('item_add')){
  768. function item_add($user, $itemid, $qty, $notid=0){
  769.  
  770. global $db;
  771. if($notid > 0)
  772. {
  773. $q=$db->query("SELECT * FROM inventory WHERE inv_userid={$user} and inv_itemid={$itemid} AND inv_id != {$notid}");
  774. }
  775. else
  776. {
  777. $q=$db->query("SELECT * FROM inventory WHERE inv_userid={$user} and inv_itemid={$itemid}");
  778. }
  779. if($db->num_rows($q) > 0)
  780. {
  781. $r=$db->fetch_row($q);
  782. $db->query("UPDATE inventory SET inv_qty=inv_qty+{$qty} WHERE inv_id={$r['inv_id']}");
  783. }
  784. else
  785. {
  786. $db->query("INSERT INTO inventory (inv_itemid, inv_userid, inv_qty) VALUES ({$itemid}, {$user}, {$qty})");
  787. }
  788. }
  789. }
  790.  
  791. if(!function_exists('item_remove')){
  792. function item_remove($user, $itemid, $qty){
  793.  
  794. global $db;
  795. $q=$db->query("SELECT * FROM inventory WHERE inv_userid={$user} AND inv_itemid={$itemid}");
  796. if($db->num_rows($q) > 0)
  797. {
  798. $r=$db->fetch_row($q);
  799. if($r['inv_qty']>$qty)
  800. {
  801. $db->query("UPDATE inventory SET inv_qty=inv_qty-{$qty} WHERE inv_id={$r['inv_id']}");
  802. }
  803. else
  804. {
  805. $db->query("DELETE FROM inventory WHERE inv_id={$r['inv_id']}");
  806. }
  807. }
  808. }
  809. }
  810.  
  811. if(!function_exists('forum_dropdown')){
  812. function forum_dropdown($connection,$ddname="forum",$selected=-1){
  813.  
  814. global $db;
  815. $ret="<select name='$ddname' type='dropdown'>";
  816. $q=$db->query("SELECT * FROM forum_forums ORDER BY ff_name ASC");
  817. if($selected == -1) { $first=0; } else { $first=1; }
  818. while($r=$db->fetch_row($q))
  819. {
  820. $ret.="\n<option value='{$r['ff_id']}'";
  821. if ($selected == $r['ff_id'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  822. $ret.= ">{$r['ff_name']}</option>";
  823. }
  824. $ret.="\n</select>";
  825. return $ret;
  826. }
  827. }
  828.  
  829. if(!function_exists('forum2_dropdown')){
  830. function forum2_dropdown($connection,$ddname="forum",$selected=-1){
  831.  
  832. global $db;
  833. $ret="<select name='$ddname' type='dropdown'>";
  834. $q=$db->query("SELECT * FROM forum_forums WHERE ff_auth != 'gang' ORDER BY ff_name ASC");
  835. if($selected == -1) { $first=0; } else { $first=1; }
  836. while($r=$db->fetch_row($q))
  837. {
  838. $ret.="\n<option value='{$r['ff_id']}'";
  839. if ($selected == $r['ff_id'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
  840. $ret.= ">{$r['ff_name']}</option>";
  841. }
  842. $ret.="\n</select>";
  843. return $ret;
  844. }
  845. }
  846.  
  847. if(!function_exists('make_bigint')){
  848. function make_bigint($str, $positive=1){
  849.  
  850. $str = (string) $str;
  851. $ret = "";
  852. for($i=0;$i<strlen($str);$i++)
  853. {
  854. if((ord($str[$i]) > 47 && ord($str[$i]) < 58) or ($str[$i]=="-" && $positive == 0)) { $ret.=$str[$i]; }
  855. }
  856. if(strlen($ret) == 0) { return "0"; }
  857. return $ret;
  858. }
  859. }
  860.  
  861. if(!function_exists('stafflog_add')){
  862. function stafflog_add($text){
  863.  
  864. global $db, $ir;
  865. $IP = $_SERVER['REMOTE_ADDR'];
  866. $text=$db->escape($text);
  867. $db->query("INSERT INTO stafflog VALUES(NULL, {$ir['userid']}, unix_timestamp(), '$text', '$IP')");
  868. }
  869. }
  870.  
  871. if(!function_exists('business_alert')){
  872. function business_alert($business, $text){
  873. mysql_query(sprintf("INSERT INTO `businesses_alerts` (`alertId`, `alertBusiness`, `alertText`, `alertTime`) VALUES ('NULL', '%u', '%s', '%d')", $business, $text, time()));
  874. }
  875. }
  876. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement