Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 97.17 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. // Edit all aspects in zFamily_funcs.php file, Thanks.
  6.  
  7.  
  8. include_once('globals.php');
  9.  
  10.  
  11. echo "<h3>$ModName's</h3>
  12. <br />";
  13.  
  14. if(!$_GET)
  15. {
  16. return index();
  17. }
  18.  
  19. switch(@$_GET['p'])
  20. {
  21. case 'myFam' : myFam(); break; //Done
  22. case 'vault' : vault(); break; //Done
  23. case 'dLogs' : donationLogs(); break; //Done
  24. case 'aLogs' : aLogs(); break; //Done
  25. case 'members' : memberList(); break; //Done
  26. case 'events' : events(); break; //Done
  27. case 'leave' : leave(); break; //Done
  28. case 'warStats' : warStats(); break; //Done
  29. case 'viewHitList' : viewHitList(); break; //Done
  30.  
  31. //Armory Stuff now
  32. case 'armoryIndex' : armoryIndex(); break; //Done
  33. case 'armoryAdd' : armoryAdd(); break; //Done
  34. case 'armoryRent' : armoryRent(); break; //Done
  35. case 'armoryTakeback' : armoryTakeback(); break; //Done
  36.  
  37. //Link to the (vice) president Panel
  38. case 'vpPanel' : vpPanel(); break; //Done
  39.  
  40. //(Vice) President Links
  41. case 'applications' : apps(); break; //Done
  42. case 'itemLent' : itemLent(); break; //Done
  43. case 'resign' : resign(); break; //Doing
  44.  
  45. // President Links
  46. case 'CashPayment' : cashPay(); break; //Done
  47. case 'CrystalPayment' : cryPay(); break; //Done
  48. case 'changeTag' : changeTag(); break; //Done
  49. case 'changeImage' : changeIMG(); break; //Done
  50. case 'changeName' : changeName(); break; //Done
  51. case 'changeVice' : changeVice(); break; //Done
  52. case 'changePres' : changePres(); break; //Done
  53. case 'changeDesc' : changeDesc(); break; //Done
  54. case 'deleteFam' : deleteFam(); break; //Done
  55. case 'upgradeSpots' : upgradeSpots(); break; //Done
  56. case 'mailAll' : mailAll(); break; //Done
  57. case 'startWar' : startWar(); break; //Done
  58. case 'hitListCrew' : hitListCrew(); break; //Done
  59. case 'surrender' : surrender(); break; //Done
  60.  
  61. //Outside family cases/functions
  62. case 'apply' : applyFam(); break; //Done
  63. case 'viewFamily' : viewFam(); break; //Done
  64. case 'create' : createFam(); break; //Done
  65. case 'viewMembs' : viewMembs(); break; //Done
  66. default: index(); break; //Done
  67. }
  68.  
  69. function index()
  70. {
  71. global $db, $userid, $ir, $ModName;
  72.  
  73. $title = "$ModName Board";
  74. $forWhile = $db->query("SELECT * FROM `family_mod` ORDER BY `ID`,`KILLS` DESC");
  75.  
  76. if($ir['gang'] == 0)
  77. {
  78. inGang($userid, "[<a href='?p=create'>Create a $ModName</a>]", 2, "hide");
  79. }
  80.  
  81. $linkToMyFamily = ($ir['gang'] > 0) ? "[<a href='?p=myFam'>My $ModName</a>]" : "";
  82.  
  83. echo "<strong>$linkToMyFamily</strong><br /><br />
  84. <table class='table' width='85%' style='text-align:center;'>
  85. <th colspan='3'>Welcome to the $title</th><tr>
  86. <th width='25%'>$ModName Name/Desc</th>
  87. <th width='45%'>$ModName Picture</th>
  88. <th width='10%'>$ModName President/Vice President</th>
  89. <tr style='background-color:#FFF;'></tr>
  90. ";
  91.  
  92.  
  93. while($r = $db->fetch_row($forWhile))
  94. {
  95.  
  96. $pres = $db->fetch_row($db->query("SELECT u.`username`,u.`userid`,f.`PRES`,f.`ID` FROM `users` u LEFT JOIN `family_mod` f ON u.`gang`=f.`ID` WHERE `userid`={$r['PRES']}"));
  97. $vpres = $db->fetch_row($db->query("SELECT u.`username`,u.`userid`,f.`vPRES`,f.`ID` FROM `users` u LEFT JOIN `family_mod` f ON u.`gang`=f.`ID` WHERE `userid`={$r['vPRES']}"));
  98.  
  99. echo "<td><a href='?p=viewFamily&id={$r['ID']}'><sub>[{$r['TAG']}]</sub> <strong>{$r['NAME']}<strong><br />
  100. <sub>".substr($r['DESC'], 0, 25)."...</sub></a></td>
  101.  
  102. <td><a href='?p=viewFamily&id={$r['ID']}'><img src='{$r['IMAGE']}' width='250px' height='50px'></a></td>
  103.  
  104. <td><a href='viewuser.php?u={$pres['userid']}'>{$pres['username']}</a><br />
  105. <a href='viewuser.php?u={$vpres['userid']}'>{$vpres['username']}</a></td>
  106.  
  107.  
  108. <tr style='background-color:#FFF;'></tr>";
  109.  
  110. }
  111. //if no family's have been created
  112. if(!$db->num_rows($forWhile))
  113. {
  114. echo "<td colspan='3'>No $ModName have been created!</td>
  115. </table>";
  116. }
  117. //end no family's
  118. }
  119.  
  120. function createFam()
  121. {
  122. global $userid, $db, $ir, $NameChange, $ModName;
  123.  
  124. //if they press Create (in form)
  125. if(isset($_POST['fName']))
  126. {
  127. $name = trim(strip_tags(htmlspecialchars(strtolower($db->escape($_POST['fName'])))));
  128. $desc = strip_tags(htmlspecialchars(strtolower(nl2br($db->escape($_POST['fDesc'])))));
  129. $tag = trim(strip_tags($_POST['fTag']));
  130. $pic = strip_tags(htmlspecialchars($_POST['fImage']));
  131. if(empty($pic))
  132. {
  133. $pic = "bla.png";
  134. }
  135. if(!empty($pic) && PNG($pic) || $pic == "")
  136. {
  137. die("This is not an image, please use an image with a PNG extenstion");
  138. }
  139.  
  140. //filter the badies :p
  141. $bad_words = array('meta', 'refresh', 'REFRESH', 'www'); //feel free to add more
  142. foreach($bad_words as $f)
  143. {
  144. $name = str_replace($f, '', $name);
  145. $desc = str_replace($f, '', $desc);
  146. }
  147. //end filtering
  148.  
  149. echo "<table style='background: #6EFF70' width='100%'><th>You have created a $ModName.<br />
  150. <strong>$ModName Name:</strong> ".stripslashes($name)."</th></table>";
  151. $db->query("INSERT INTO `family_mod` (`NAME`, `PRES`, `vPRES`, `DESC`, `TAG`, `IMAGE`) VALUES
  152. ('$name', $userid, $userid, '$desc', '$tag', '$pic')");
  153. $db->query("INSERT INTO `family_mail` (`LastSentMail`) VALUES (0)");
  154. $f = $db->fetch_row($db->query("SELECT COUNT(`ID`) as `id` FROM `family_mod`"));
  155. $newFamily = $f['id'];
  156. $db->query("UPDATE `users` SET `gang`={$newFamily} WHERE `userid`=$userid");
  157. add_famEvent("The {$ModName} was created!", $newFamily);
  158.  
  159. }
  160.  
  161. else
  162. {
  163. if($ir['gang'])
  164. {
  165. inGang($userid, "Create a $ModName because you are already in one!", 0, "hide");
  166. }
  167.  
  168. if(!$ir['gang'])
  169. {
  170. echo "<form action='#' method='post'>
  171. $ModName Name: <input type='text' name='fName' length='5' maxlength='10' />
  172. <br />
  173. $ModName Description: <input type='text' name='fDesc' length='10' maxlength='250' />
  174. <br />
  175. $ModName Tag: <input type='text' name='fTag' length='5' maxlength='3' />
  176. <br />
  177. $ModName Image: <input type='text' name='fImage' length='5' maxlength='1000' />
  178. <br />
  179. <input type='submit' value='Create!'>
  180. </form>";
  181. }
  182. }
  183. echo "<hr width='45%'>
  184. [<a href='?p=index'>Back</a>]";
  185. }
  186.  
  187.  
  188. function viewFam()
  189. {
  190. global $maxFam, $db, $ir, $ModName;
  191.  
  192. //secure the id
  193. $_GET['id'] == abs(intval($_GET['id']));
  194.  
  195. if(!$_GET['id'] || $_GET['id'] > $maxFam)
  196. {
  197. echo "No $ModName was selected!";
  198. }
  199. else
  200. {
  201. $pres = $db->fetch_row($db->query("SELECT u.`username`,u.`userid`,f.`PRES`,f.`ID` FROM `users` u LEFT JOIN `family_mod` f ON u.`gang`=f.`ID` WHERE `userid`=f.`PRES` && `ID`={$_GET['id']}"));
  202. $vpres = $db->fetch_row($db->query("SELECT u.`username`,u.`userid`,f.`vPRES`,f.`ID` FROM `users` u LEFT JOIN `family_mod` f ON u.`gang`=f.`ID` WHERE `userid`=f.`vPRES` && `ID`={$_GET['id']}"));
  203. $r = $db->fetch_row($db->query("SELECT * FROM `family_mod` WHERE `ID`={$_GET['id']} LIMIT 1"));
  204.  
  205. echo "<table class='table' width='90%' background='#fff'>";
  206.  
  207. $apply = ($ir['gang'] == 0) ? "<p style='color: #090; line-height: 1.2'><strong><a href='?p=apply&fam={$_GET['id']}'>Apply</a></strong></p>" : "<s><a title='You are already in a gang!'>Apply</a></s>";
  208.  
  209. echo " <th colspan='2'>$apply <p=style='color: #663300; line-height: 1.2'><strong><a href='?p=viewMembs&fam={$_GET['id']}'>View Members</a></strong></p></th>
  210. <tr><tr>
  211. <th colspan='2'><img src='{$r['IMAGE']}' width='250px' height='50px' alt='$ModName\'s Image'></th>
  212. <tr><tr>
  213. <th><strong>$ModName Name</strong></th>
  214. <th><strong>Kills</th>
  215. <tr>
  216. <td style='border-type: double; text-align: center;'>".stripslashes($r['NAME'])."</td>
  217. <td style='border-type: double; text-align: center;'>".number_format($r['KILLS'])." war kills</td> <tr><tr>
  218. <th colspan='2'><strong>$ModName Description</strong></th>
  219. <tr>
  220. <td style='border-type: double; text-align: center;' colspan='2'>".stripslashes(nl2br($r['DESC']))."</td>";
  221. }
  222. echo "<hr width='45%'>
  223. [<a href='?p=index'>Back</a>]";
  224. }
  225.  
  226. function viewMembs()
  227. {
  228. global $userid, $db, $maxFam, $ir, $ModName;
  229.  
  230. //secure the id
  231. @$_GET['fam'] == abs((int) @$_GET['fam']);
  232.  
  233.  
  234. if(!$_GET)
  235. {
  236. echo "No $ModName was selected!<br />
  237. [<a href='?p=index'>Back</a>]";
  238. }
  239.  
  240. if(!@$_GET['fam'] || $_GET['fam'] > $maxFam)
  241. {
  242. echo "No $ModName was selected!<br />
  243. [<a href='?p=index'>Back</a>]";
  244. exit();
  245. }
  246.  
  247.  
  248. $select = $db->query("SELECT `username`,`userid`,`level` FROM `users` WHERE `gang`={$_GET['fam']}");
  249. $f = $db->fetch_row($db->query("SELECT `NAME` FROM `family_mod` WHERE `ID`={$_GET['fam']}"));
  250. echo "<h3>{$f['NAME']}'s Members</h3>
  251. <table class='table' width='80%'>
  252. <th width='50%'>Username</th>
  253. <th width='30%'>Level</th>
  254. <tr>";
  255.  
  256. while($r = $db->fetch_row($select))
  257. {
  258. echo "<td><center><a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a></center></td>
  259. <td><center>{$r['level']}</center></td><tr>";
  260. }
  261. }
  262.  
  263. function applyFam()
  264. {
  265. global $userid, $db, $maxFam, $ir, $ModName;
  266.  
  267. //secure the id
  268. @$_GET['fam'] == abs((int) @$_GET['fam']);
  269.  
  270. if($ir['gang'] >= 1)
  271. {
  272. inGang($userid, "You are already in a $ModName!", 4, "hide");
  273. exit();
  274. }
  275.  
  276. if(!$_GET)
  277. {
  278. echo "No $ModName was selected!<br />
  279. [<a href='?p=index'>Back</a>]";
  280. }
  281.  
  282. if(!@$_GET['fam'] || $_GET['fam'] > $maxFam)
  283. {
  284. echo "No $ModName was selected!<br />
  285. [<a href='?p=index'>Back</a>]";
  286. exit();
  287. }
  288.  
  289. $timeStamp = time();
  290.  
  291. //if they press submit
  292. if(isset($_POST['cV']) || isset($_POST['submit']))
  293. {
  294. if(strlen($_POST['cV']) < 10)
  295. {
  296. echo "Please enter something for your CV! (more than 10 characters in length)";
  297. }
  298. else
  299.  
  300. $cV = strip_tags(htmlspecialchars($db->escape($_POST['cV'])));
  301. {
  302. echo "<table class='table' width='90%' background='#fff'>
  303. <th><strong>Apply Form</strong></th>
  304. <tr>
  305. <td style='border-type: double; text-align: center;'>Thank you for your appliance!</td></table>";
  306. $db->query("INSERT INTO `family_mod_apply` (`userid`,`time`,`gangID`,`applyNote`) VALUES ($userid, $timeStamp, {$_GET['fam']}, '$cV')");
  307. add_famEvent("{$ir['username']} has applied for the {$ModName}", $_GET['fam']);
  308. }
  309. }
  310. else
  311. {
  312. $r = $db->fetch_row($db->query("SELECT `NAME`,`ID` FROM `family_mod` WHERE `ID`={$_GET['fam']}"));
  313.  
  314.  
  315. $time = date("G:i (a)", $timeStamp);
  316. echo "You are applying for the family with the name of: ".ucwords(stripslashes($r['NAME']))."<br />
  317. <table class='table' width='90%' background='#fff'>
  318. <th colspan='2'><strong>Apply Form</strong></th>
  319. <tr>
  320. <td style='border-type: double; text-align: center;' colspan='2'>
  321. <form action='#' method='post'>
  322. <textarea cols='20' rows='10' name='cV'>Put something for persuadance</textarea>
  323. <br />
  324. <input type='submit' name='submit' value='Apply on {$time}' />
  325. </form>
  326. </td>";
  327. }
  328. echo "<hr width='45%'>
  329. [<a href='?p=index'>Back</a>]";
  330. }
  331.  
  332.  
  333. /*
  334. // ====== START INSIDE THE FAMILY FUNCTIONS ====== \\
  335. */
  336.  
  337. echo "<p>";
  338. function myFam()
  339. {
  340. global $cost, $startingPlaces, $ir, $db, $Pres_icon, $vPres_icon, $userid, $ModName;
  341. if(!$ir['gang'])
  342. {
  343. echo "<table class='table' width='75%' style='text-align: center;'>
  344. <th>You are not in a $ModName!</th>
  345. <tr>
  346. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  347. </td>
  348. </table><br /><br />";
  349. exit();
  350. }
  351. else
  352. {
  353. //collect the data
  354. $r = $db->fetch_row($db->query("SELECT * FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  355. $members = $db->fetch_row($db->query("SELECT COUNT(`gang`) AS `gang` FROM `users` WHERE `gang`={$ir['gang']}"));
  356. $president = $db->fetch_row($db->query("SELECT `username` FROM `users` WHERE `userid`={$r['PRES']}"));
  357. $vice_pres = $db->fetch_row($db->query("SELECT `username` FROM `users` WHERE `userid`={$r['vPRES']}"));
  358.  
  359. $membs = ($members < $startingPlaces) ? "<font color='black'>{$members['gang']}</font>" : "<font color='green'>{$members['gang']}</font>";
  360. $vaultCASH = ($r['VAULT_MEM_VIEW'] == 'OFF') ? "<i>Hidden</i>" : number_format($r['VAULT_CASH']);
  361. $vaultCRYS = ($r['VAULT_MEM_VIEW'] == 'OFF') ? "<i>Hidden</i>" : number_format($r['VAULT_CRYS']);
  362. $KD = ($r['KILLS'] == 0 || $r['Deaths'] == 0 || $r['KILLS'] / $r['Deaths'] <= 0) ? 0 : sprintf("%01.2f", $r['KILLS'] / $r['Deaths']);
  363.  
  364. echo "<table class='table' width='75%' style='text-align: center;'>
  365. <th width='50%'>{$r['NAME']}</th>
  366. <th width='50%'>$Pres_icon <a href='viewuser.php?u={$r['PRES']}'>{$president['username']}</a>
  367. $vPres_icon <a href='viewuser.php?u={$r['vPRES']}'>{$vice_pres['username']}</a>
  368. </th>
  369. <tr>
  370. <td colspan='1'><strong>Members:</strong> $membs</td>
  371. <td colspan='1'><strong>Vault:</strong> \$$vaultCASH &Iota; $vaultCRYS crystals</td>
  372. <tr>
  373. <td colspan='2'><strong>Kills:</strong> ".number_format($r['KILLS'])." &dagger; <strong>Deaths:</strong> ".number_format($r['Deaths'])." &dagger; <strong>K/D Ratio:</strong> ".number_format($KD)."%</td>
  374. </td>
  375. </table><br /><br />
  376.  
  377. <table class='table' width='75%' style='text-align: center;'>
  378. <th colspan='2'>Links</th>
  379. <tr>
  380. <td colspan='1'><a href='?p=vault'>Vault</a></td>
  381. <td colspan='1'><a href='?p=events'>Events</a></td>
  382. <tr>
  383. <td colspan='1'><a href='?p=viewHitList'>Hit list</a></td>
  384. <td colspan='1'><a href='?p=members'>Members</a></td>
  385. <tr>
  386. <td colspan='2'>Forums</td>
  387. <tr>
  388. <td colspan='1'><a href='?p=aLogs'>Attack Logs</a></td>
  389. <td colspan='1'><a href='?p=dLogs'>Donation Logs</a></td>
  390. <tr>
  391. <td colspan='1'><a href='?p=warStats'>War Stats</a></td>
  392. <td colspan='1'><a href='?p=armoryIndex'>Armory</a></td>
  393. <tr>
  394. <td style='background-color: #FFCCCC;' colspan='2'><a href='?p=leave'>Leave</a></td>
  395. </table><br /><br />";
  396.  
  397. if($r['PRES'] == $userid || $r['vPRES'] == $userid)
  398. {
  399. $position = ($r['PRES'] == $userid) ? "President" : "Vice President";
  400. echo "<table class='table' width='75%' style='text-align: center;'>
  401. <td style='background-color: #86C67C;' colspan='2'><a href='?p=vpPanel'>$position Links</a></a></td>
  402. </table>";
  403. }
  404.  
  405. }
  406. }
  407.  
  408. function vault()
  409. {
  410. global $cost, $startingPlaces, $ir, $db, $userid, $ModName;
  411.  
  412. echo "<h3>Donate to the $ModName!</h3>";
  413.  
  414. if(!$ir['gang'])
  415. {
  416. echo "<table class='table' width='75%' style='text-align: center;'>
  417. <th>You are not in a $ModName!</th>
  418. <tr>
  419. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  420. </td>
  421. </table><br /><br />";
  422. exit();
  423. }
  424. else
  425. {
  426. if(isset($_POST['amount']))
  427. {
  428. $_POST['cash'] = abs((int) $_POST['cash']);
  429. $_POST['crystals'] = abs((int) $_POST['crystals']);
  430. if(empty($_POST['cash']) && empty($_POST['crystals']))
  431. {
  432. echo "<table width='75%'>
  433. <td style='background-color: #FFCCCC;'>Please fill out the form!</a></td>
  434. </table>";
  435. unset($_POST['amount']);
  436. echo "<br />[<a href='?p=vault'>Back to vault</a>]";
  437. exit();
  438. }
  439. if($_POST['cash'] > $ir['money'] || $_POST['crystals'] > $ir['money'])
  440. {
  441. echo "<table width='75%'>
  442. <td style='background-color: #FFCCCC;'>You are putting in more than you actually have!</a></td>
  443. </table><br />
  444. [<a href='?p=vault'>Back to vault</a>]";
  445. exit();
  446. }
  447. else
  448. {
  449. echo "<table width='75%'>
  450. <td style='background-color: #BCED91;'><center>Thanks for your financial help!</center></a></td>
  451. </table>";
  452. $db->query("UPDATE `family_mod` SET `VAULT_CASH`=`VAULT_CASH`+{$_POST['cash']}, `VAULT_CRYS`=`VAULT_CRYS`+{$_POST['crystals']} WHERE `ID`={$ir['gang']}");
  453. $db->query("UPDATE `users` SET `money`=`money`-{$_POST['cash']},`crystals`=`crystals`-{$_POST['crystals']} WHERE `userid`=$userid");
  454. $time = time();
  455. $db->query("INSERT INTO `family_DonationLogs` (`USERID`,`CASH`,`CRYS`,`TIME`,`family`) VALUES($userid, {$_POST['cash']}, {$_POST['crystals']}, $time, {$ir['gang']})");
  456. add_famEvent("{$ir['username']} donated to the {$ModName}", $ir['gang']);
  457. }
  458. }
  459. else
  460. {
  461. echo "<i>This is a total charity event on behalf of you, everything you put into the vault is non-refundable
  462. and will be logged so maybe get something in return</i><br />
  463. <form action='#' method='post'>";
  464. $cash_strlen = mb_strlen($ir['money']);
  465. $crys_strlen = mb_strlen($ir['crystals']);
  466. echo "Cash: <input type='text' name='cash' length='5' maxlength='{$cash_strlen}' />
  467. <br />
  468. Crystals: <input type='text' name='crystals' length='5' maxlength='{$crys_strlen}' />
  469. <br />
  470. <input type='submit' name='amount' value='Put into vault'>
  471. </form>";
  472.  
  473. }
  474. }
  475. echo "<hr width='45%'>
  476. [<a href='?p=myFam'>Back</a>]";
  477. }
  478.  
  479. function donationLogs()
  480. {
  481. global $cost, $startingPlaces, $userid, $db, $ir, $ModName;
  482.  
  483. if(!$ir['gang'])
  484. {
  485. echo "<table class='table' width='75%' style='text-align: center;'>
  486. <th>You are not in a $ModName!</th>
  487. <tr>
  488. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  489. </td>
  490. </table><br /><br />";
  491. exit();
  492. }
  493. else
  494. {
  495.  
  496. $selectFromLog = $db->query("SELECT u.`gang`,u.`username`,u.`userid`, dl.* FROM `users` u LEFT JOIN `family_DonationLogs` dl ON u.`userid`=dl.`USERID` WHERE u.`gang`={$ir['gang']} && dl.`CASH` > 0 ORDER BY dl.`ID` DESC");
  497.  
  498. if(!$db->num_rows($selectFromLog))
  499. {
  500. echo "<table width='75%'>
  501. <td style='background-color: #FFCCCC;'>No logs have been recorded</a></td>
  502. </table>";
  503. }
  504. else
  505. {
  506. echo "<table class='table' width='90%'>
  507. <th>Who</th>
  508. <th>Cash</th>
  509. <th>Crystals</th>
  510. <th>When</th>
  511. <tr>";
  512. while ($r = $db->fetch_row($selectFromLog))
  513. {
  514.  
  515. $user = ($r['userid'] == $ir['userid']) ? "<p style='color: #090; line-height: 1.2'><strong>You</strong></p>" : "<strong>{$r['username']}</strong>";
  516.  
  517. echo "<td><a href='viewuser.php?p={$r['USERID']}'>$user</a></td>
  518. <td>$".number_format($r['CASH'])."</td>
  519. <td>".number_format($r['CRYS'])." crystal(s)</td>
  520. <td>".date('l F (G:i (a))', $r['TIME'])."</td>
  521. <tr>";
  522. }
  523. }
  524. echo "<hr width='45%'>
  525. [<a href='?p=myFam'>Back</a>]";
  526. }
  527. }
  528.  
  529. function memberList()
  530. {
  531. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $ModName;
  532.  
  533. if(!$ir['gang'])
  534. {
  535. echo "<table class='table' width='75%' style='text-align: center;'>
  536. <th>You are not in a $ModName!</th>
  537. <tr>
  538. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  539. </td>
  540. </table><br /><br />";
  541. exit();
  542. }
  543. else
  544. {
  545. $selectMembers = $db->query("SELECT u.`username`,u.`userid`,u.`gang`,f.`ID`,f.`PRES`,f.`vPRES` FROM `users` u LEFT JOIN `family_mod` f ON u.gang=f.ID WHERE f.ID={$ir['gang']}");
  546.  
  547. echo "<table class='table' width='30%'>
  548. <th>Member's Name</th>
  549. <tr>";
  550.  
  551. while ($r = $db->fetch_row($selectMembers))
  552. {
  553. $p = ($r['PRES'] == $r['userid']) ? $Pres_icon : "";
  554. $vp = ($r['vPRES'] == $r['userid']) ? $vPres_icon : "";
  555. echo "<td><a href='viewuser.php?u={$r['userid']}'>$p $vp {$r['username']}</a></td>
  556. <tr>";
  557. }
  558.  
  559. }
  560. echo "<hr width='45%'>
  561. [<a href='?p=myFam'>Back</a>]";
  562. }
  563.  
  564. function events()
  565. {
  566. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $ModName, $eventsLimit;
  567.  
  568. if(!$ir['gang'])
  569. {
  570. echo "<table class='table' width='75%' style='text-align: center;'>
  571. <th>You are not in a $ModName!</th>
  572. <tr>
  573. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  574. </td>
  575. </table><br /><br />";
  576. exit();
  577. }
  578. else
  579. {
  580. echo "<table width='80%'>
  581. <th style='background-color: #000; color: #FFF;'>Event</th>
  582. <tr>";
  583. $getEvents = $db->query("SELECT `ID`,`TIME`,`CONTENT` FROM `family_events` WHERE `gangID`={$ir['gang']} ORDER BY `ID` DESC LIMIT $eventsLimit");
  584. while($r = $db->fetch_row($getEvents))
  585. {
  586. echo "<td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'>".ucwords($r['CONTENT'])."<br />
  587. <strong>Time:</strong> ".date(".l M Y (g a)", $r['TIME'])."</td><tr>";
  588. }
  589. echo "<table>";
  590.  
  591. }
  592. echo "<hr width='45%'>
  593. [<a href='?p=myFam'>Back</a>]";
  594. }
  595.  
  596. function aLogs()
  597. {
  598. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $ModName;
  599.  
  600. if(!$ir['gang'])
  601. {
  602. echo "<table class='table' width='75%' style='text-align: center;'>
  603. <th>You are not in a $ModName!</th>
  604. <tr>
  605. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  606. </td>
  607. </table><br /><br />";
  608. exit();
  609. }
  610. else
  611. {
  612. if(@!in_array($_GET['t'], array('against', 'from')) OR @!$_GET['t'])
  613. {
  614. echo "<table width='90%' class='table'>
  615. <th width='45%'><a href='?p=aLogs&t=against'>Attacks against $ModName members</a><br />
  616. <small>View the logs of attacks that people have committed against fellow $ModName members</small></th>
  617. <th wodth='45%'><a href='?p=aLogs&t=from'>Attacks from $ModName members<br />
  618. <small>View the logs of attacks that people have committed from your $ModName</small></th>
  619. </table>";
  620. }
  621. elseif($_GET['t'] == 'against')
  622. {
  623. echo "<small>Viewing the attack logs of offenses against your $ModName!</small><br />
  624. <table width='95%' style='border-style: double;'>
  625. <th colspan='5' style='background: #EEE'>Attack Logs</th>
  626. <tr>
  627. <td style='background: #AAA;border-style: double;'>Attacker</td>
  628. <td style='background: #AAA;border-style: double;'>Attacked</td>
  629. <td style='background: #AAA;border-style: double;'>Who Won</td>
  630. <td style='background: #AAA;border-style: double;'>Time</td>
  631. <td style='background: #AAA;border-style: double;'>Links</td>
  632. <tr>";
  633.  
  634. $GetLogs = $db->query("SELECT u.`userid`,u.`gang`, al.* FROM `users` u LEFT JOIN `attacklogs` al ON al.`attacked`=u.`userid` WHERE al.`attacked`=u.`userid` && u.`gang`={$ir['gang']} LIMIT 50");
  635. while ($r = $db->fetch_row($GetLogs))
  636. {
  637. if(!$db->num_rows($GetLogs))
  638. {
  639. echo "No logs have been reported!";
  640. }
  641. else
  642. {
  643. $attkr = $db->fetch_row($db->query("SELECT `userid`,`username` FROM `users` WHERE `userid`={$r['attacker']}"));
  644. $attkd = $db->fetch_row($db->query("SELECT `username` FROM `users` WHERE `userid`={$r['attacked']}"));
  645. $who_won = ($r['result'] == 'won' && $r['attacker'] != $r['userid']) ? $attkd['username'] : $attkr['username'];
  646. $links = ($who_won != $attkd['username'] ) ? "[<a href='attack.php?ID={$attkr['userid']}'>Attack the attacker!</a>]" : "<s>Take Revenge</s>";
  647.  
  648.  
  649. echo "<td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'>{$attkr['username']}</td>
  650. <td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'>{$attkd['username']}</td>
  651. <td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'>$who_won {$r['result']}</td>
  652. <td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'>".date('l F (G:i (a))', $r['time'])."</td>
  653. <td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'>$links</td>
  654. <tr>";
  655. }
  656. }
  657. }
  658. elseif($_GET['t'] == 'from')
  659. {
  660. echo "<small>Viewing the attacks from people in your $ModName</small><br />
  661. <table width='95%' style='border-style: double;'>
  662. <th colspan='5' style='background: #EEE'>Attack Logs</th>
  663. <tr>
  664. <td style='background: #AAA;border-style: double;'>Attacker</td>
  665. <td style='background: #AAA;border-style: double;'>Attacked</td>
  666. <td style='background: #AAA;border-style: double;'>Who Won</td>
  667. <td style='background: #AAA;border-style: double;'>Time</td>
  668. <td style='background: #AAA;border-style: double;'>Links</td>
  669. <tr>";
  670.  
  671. $GetLogs = $db->query("SELECT u.`userid`,u.`gang`, al.* FROM `users` u LEFT JOIN `attacklogs` al ON al.`attacker`=u.`userid` WHERE al.`attacker`=u.`userid` && u.`gang`={$ir['gang']} LIMIT 50");
  672. while ($r = $db->fetch_row($GetLogs))
  673. {
  674. if(!$db->num_rows($GetLogs))
  675. {
  676. echo "No logs have been reported!";
  677. }
  678. else
  679. {
  680. $attkr = $db->fetch_row($db->query("SELECT `username` FROM `users` WHERE `userid`={$r['attacker']}"));
  681. $attkd = $db->fetch_row($db->query("SELECT `username`,`userid` FROM `users` WHERE `userid`={$r['attacked']}"));
  682. $who_won = ($r['result'] == 'won' && $r['attacker'] != $r['userid']) ? $attkd['username'] : $attkr['username'];
  683. $links = ($who_won != $attkd['username']) ? "[<a href='attack.php?ID={$attkd['userid']}'>Take Procautions</a>]" : "<s>Take Revenge</s>";
  684. echo "<td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'>{$attkr['username']}</td>
  685. <td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'>{$attkd['username']}</td>
  686. <td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'>$who_won {$r['result']}</td>
  687. <td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'>".date('l F (G:i (a))', $r['time'])."</td>
  688. <td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'>$links</td>
  689. <tr>";
  690. }
  691. }
  692. }
  693. }
  694. echo "<hr width='45%'>
  695. [<a href='?p=myFam'>Back</a>]";
  696. }
  697.  
  698. function warStats()
  699. {
  700. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $upgradeSpots, $ModName, $mailDays;
  701.  
  702. if(!$ir['gang'])
  703. {
  704. echo "<table class='table' width='75%' style='text-align: center;'>
  705. <th>You are not in a $ModName!</th>
  706. <tr>
  707. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  708. </td>
  709. </table><br /><br />";
  710. exit();
  711. }
  712. else
  713. {
  714. $u = $db->fetch_row($db->query("SELECT `LOST`,`WON` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  715. echo "<table width='80%' style='text-align: center;'>
  716. <th style='background-color: #000; color: #FFF;' colspan='3'>General War Stats</th>
  717. <tr>
  718. <th style='background-color: #000; color: #FFF;'>Wars Won</th>
  719. <th style='background-color: #000; color: #FFF;'>Wars Lost</th>
  720. <tr>
  721. <td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'><p style='color: #090;'><strong>".number_format($u['WON'])."</strong></p></td>
  722. <td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'><p style='color: #FF0000;'><strong>".number_format($u['LOST'])."</strong></p></td>
  723. </table>
  724.  
  725. <br />
  726.  
  727. <table width='80%'>
  728. <th style='background-color: #000; color: #FFF;' colspan='3'>Wars in progress</th>
  729. <tr>
  730. <th style='background-color: #000; color: #FFF;'>Started By</th>
  731. <th style='background-color: #000; color: #FFF;'>Victims</th>
  732. <th style='background-color: #000; color: #FFF;'>Started at</th>
  733. <tr>";
  734. $war = $db->query("SELECT `ID`,`Starter`,`Victim`,`Time` FROM `family_wars` WHERE `Starter`={$ir['gang']} && `Victim`!={$ir['gang']} || `Starter`!={$ir['gang']} && `Victim`={$ir['gang']} ORDER BY `Time` DESC");
  735. while ($r = $db->fetch_row($war))
  736. {
  737. $str = $db->fetch_row($db->query("SELECT `ID`,`NAME` FROM `family_mod` WHERE `ID`={$r['Starter']}"));
  738. $vtm = $db->fetch_row($db->query("SELECT `ID`,`NAME` FROM `family_mod` WHERE `ID`={$r['Victim']}"));
  739.  
  740. $starter = ($str['ID'] == $ir['gang']) ? "<p style='color: #090; line-height: 1.2'><strong>{$str['NAME']}</strong></p>" : $str['NAME'];
  741. $victim = ($vtm['ID'] == $ir['gang']) ? "<p style='color: #090; line-height: 1.2'><strong>{$vtm['NAME']}</strong></p>" : $vtm['NAME'];
  742. echo "<td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'>$starter</td>
  743. <td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'>$victim</td>
  744. <td style='background-color: #F7F7F7; border-color: #333333; border-style: solid;'>".date("j, D M Y (G:i (a))", $r['Time'])."</td>
  745. <tr>";
  746. }
  747. }
  748. echo "<hr width='45%'>
  749. [<a href='?p=myFam'>Back</a>]";
  750. }
  751.  
  752. function viewHitList()
  753. {
  754. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $ModName;
  755.  
  756. if(!$ir['gang'])
  757. {
  758. echo "<table class='table' width='75%' style='text-align: center;'>
  759. <th>You are not in a $ModName!</th>
  760. <tr>
  761. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  762. </td>
  763. </table><br /><br />";
  764. exit();
  765. }
  766. else
  767. {
  768. $select = $db->query("SELECT `ID`,`HitList` FROM `family_hitlist` WHERE `Adder`={$ir['gang']}");
  769. echo "<table width='50%'>
  770. <th style='background-color: #000; color: #FFF;'>Current hit listed {$ModName}'s</th>
  771. <tr>";
  772. while ($r = $db->fetch_row($select))
  773. {
  774. $f = $db->fetch_row($db->query("SELECT `NAME` FROM `family_mod` WHERE `ID`={$r['HitList']}"));
  775. echo "<td style='background-color: #F7F7F7; border-color: #333333; border-style: solid; text-align:center;'><a href='?p=viewFamily&id={$r['HitList']}'>{$f['NAME']}</a></td><tr>";
  776. }
  777. echo "</table>";
  778. }
  779. echo "<hr width='45%'>
  780. [<a href='?p=myFam'>Back</a>]";
  781. }
  782.  
  783. function leave()
  784. {
  785. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $ModName;
  786.  
  787. if(!$ir['gang'])
  788. {
  789. echo "<table class='table' width='75%' style='text-align: center;'>
  790. <th>You are not in a $ModName!</th>
  791. <tr>
  792. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  793. </td>
  794. </table><br /><br />";
  795. exit();
  796. }
  797. else
  798. {
  799. //do they have any rented items?
  800. rentedItem($userid, "BROAD");
  801. //End rented items
  802.  
  803. $selectVps = $db->query("SELECT `PRES`,`vPRES` FROM `family_mod` WHERE `ID`={$ir['gang']} && `PRES`=$userid || `vPRES`=$userid");
  804. $areTheyInCharge = $db->num_rows($selectVps);
  805. if(!$areTheyInCharge)
  806. {
  807. echo "You have left the $ModName!";
  808. add_famEvent("{$ir['username']} has left the {$ModName}", $ir['gang']);
  809. $db->query("UPDATE `users` SET `gang`=0 WHERE `userid`=$userid");
  810. }
  811. if($areTheyInCharge)
  812. {
  813. echo "<table width='75%'>
  814. <td style='background-color: #FFCCCC;'><center>You are important to the $ModName, please resign another member to your roll in the $ModName before leave please.<br />
  815. <hr><a href='?p=myFam'>Back</a></center></td>
  816. </table>";
  817. }
  818.  
  819. }
  820. }
  821.  
  822. function vpPanel()
  823. {
  824. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $ModName;
  825.  
  826. if(!$ir['gang'])
  827. {
  828. echo "<table class='table' width='75%' style='text-align: center;'>
  829. <th>You are not in a $ModName!</th>
  830. <tr>
  831. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  832. </td>
  833. </table><br /><br />";
  834. exit();
  835. }
  836. else
  837. {
  838. $selectVps = $db->query("SELECT `PRES`,`vPRES` FROM `family_mod` WHERE `ID`={$ir['gang']} && `PRES`=$userid || `vPRES`=$userid");
  839. $areTheyInCharge = $db->num_rows($selectVps);
  840. $selectPnVP = $db->fetch_row($selectVps);
  841.  
  842. if(!$areTheyInCharge)
  843. {
  844. echo "<table width='75%'>
  845. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  846. <hr><a href='?p=myFam'>Back</a></center></td>
  847. </table>";
  848. exit($h->endpage());
  849. }
  850. else
  851. {
  852. $position = ($selectPnVP['PRES'] == $userid) ? "President" : "Vice President";
  853. echo "<table class='table' width='85%' style='text-align: center'>
  854. <th colspan='2'>$position Links</th>
  855. <tr>";
  856. if($position == "Vice President")
  857. {
  858. echo "<td colspan='2'>[<a href='?p=itemLent'>Items Lent To Members</a>]<br />
  859. [<a href='?p=applications'>Application Management</a>]<br />
  860. [<a href='?p=warStats'>War Stats</a>]<br />
  861. [<a href='?p=resign'>Resign</a>]<br /></td>";
  862. }
  863. echo "<tr>";
  864. if($position == "President")
  865. {
  866. echo "<td><u>Cash Flow</u><br />
  867. [<a href='?p=CashPayment'>Cash Payment</a>]<br />
  868. [<a href='?p=CrystalPayment'>Crystal Payment</a>]</td>
  869.  
  870. <td><u>Major $ModName Changes</u><br />
  871. [<a href='?p=changeTag'>Change $ModName Tag</a>]<br />
  872. [<a href='?p=changeImage'>Change $ModName Picture</a>]<br />
  873. [<a href='?p=changeName'>Change $ModName Name</a>]<br />
  874. [<a href='?p=changeVice'>Change Vice President</a>]<br />
  875. [<a href='?p=changePres'>Change President</a>]<br />
  876. [<a href='?p=changeDesc'>Change Desc.</a>]<br />
  877. [<a href='?p=deleteFam'>Delete $ModName</a>]</td>
  878.  
  879. <tr>
  880. <td><u>$ModName Members</u><br />
  881. [<a href='?p=applications'>Applications</a>]<br />
  882. [<a href='?p=upgradeSpots'>Upgrade Spots</a>]<br />
  883. [<a href='?p=mailAll'>Mail all Members</a>]<br />
  884. [<a href='?p=itemLent'>Items Lent To Members</a>]
  885. </td>
  886. <td><u>$ModName Wars</u><br />
  887. [<a href='?p=startWar'>Start War</a>]<br />
  888. [<a href='?p=warStats'>War Stats</a>]<br />
  889. [<a href='?p=hitListCrew'>HitList $ModName</a>]<br />
  890. [<a href='?p=surrender'>Surrender</a>]<br />
  891. </td>";
  892. }
  893. }
  894. }
  895. echo "<hr width='45%'>
  896. [<a href='?p=myFam'>Back</a>]";
  897. }
  898.  
  899. function cashPay()
  900. {
  901. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $ModName;
  902.  
  903. $r = $db->fetch_row($db->query("SELECT `VAULT_CASH` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  904. $membs = $db->fetch_row($db->query("SELECT COUNT(`userid`) AS `amount` FROM `users` WHERE `gang`={$ir['gang']}"));
  905. $maxPayout = floor($r['VAULT_CASH'] / $membs['amount']);
  906.  
  907. if(!$ir['gang'])
  908. {
  909. echo "<table class='table' width='75%' style='text-align: center;'>
  910. <th>You are not in a $ModName!</th>
  911. <tr>
  912. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  913. </td>
  914. </table><br /><br />";
  915. exit();
  916. }
  917. else
  918. {
  919. $AreTheyInCharge = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']}"));
  920. if(!$AreTheyInCharge)
  921. {
  922. echo "<table width='75%'>
  923. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  924. <hr><a href='?p=myFam'>Back</a></center></td>
  925. </table>";
  926. exit($h->endpage());
  927. }
  928. else
  929. {
  930. if(isset($_POST['Payout']))
  931. {
  932. if(empty($_POST['Payout']) || $_POST['Payout'] > $maxPayout || !is_numeric($_POST['Payout']))
  933. {
  934. echo "<strong>Error:</strong> You didn't give an amount to payout or you gave more than $".number_format($maxPayout)."!<br />
  935. [<a href='?p=CashPayment'>Back</a>]";
  936. exit();
  937. }
  938. else
  939. {
  940. $_Payout = str_replace(",", "", $_POST['Payout']);
  941. $message = (empty($_POST['PaymentMess'])) ? "<i>Nothing</i>" : $_POST['PaymentMess'];
  942. echo "You have given ".number_format($membs['amount'])." members $".number_format($_Payout)." and sent the message of: <i>".$db->escape($message)."</i>";
  943. $selectUsers = $db->query("SELECT `userid` FROM `users` WHERE `gang`={$ir['gang']}");
  944. while($r = $db->fetch_row($selectUsers))
  945. {
  946. event_add($r['userid'], "You have been given $".number_format($_Payout)." from your $ModName!<br /><small>".$db->escape($message)."</small>");
  947. $db->query("UPDATE `users` SET `money`=`money`+{$_Payout} WHERE `userid`={$r['userid']}");
  948. }
  949. $db->query("UPDATE `family_mod` SET `VAULT_CASH`=`VAULT_CASH`-{$_Payout} WHERE `ID`={$ir['gang']}");
  950. add_famEvent("A mass cash payment was given of $".number_format($_Payout)."!", $ir['gang']);
  951.  
  952. }
  953. }
  954. else
  955. {
  956. echo "<form action='#' method='post'>
  957. Payment Message: <input type='text' name='PaymentMess' length='5' maxlength='50' />
  958. <br />
  959. <fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  960. There are ".number_format($membs['amount'])." members and you have $".number_format($r['VAULT_CASH'])." in the vault so the <strong>maximum you can give is: $".number_format($maxPayout)."</strong>
  961. <br /><br />
  962. Payout: $<input type='text' name='Payout' length='5' maxlength='".strlen($maxPayout)."'/> </fieldset>
  963. <br />
  964. <input type='submit' value='Payout'>
  965. </form>";
  966. }
  967. }
  968. }
  969. echo "<hr width='45%'>
  970. [<a href='?p=myFam'>Back</a>]";
  971. }
  972.  
  973. function cryPay()
  974. {
  975. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $ModName;
  976.  
  977. $r = $db->fetch_row($db->query("SELECT `VAULT_CRYS` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  978. $membs = $db->fetch_row($db->query("SELECT COUNT(`userid`) AS `amount` FROM `users` WHERE `gang`={$ir['gang']}"));
  979. $maxPayout = floor($r['VAULT_CRYS'] / $membs['amount']);
  980.  
  981. if(!$ir['gang'])
  982. {
  983. echo "<table class='table' width='75%' style='text-align: center;'>
  984. <th>You are not in a $ModName!</th>
  985. <tr>
  986. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  987. </td>
  988. </table><br /><br />";
  989. exit();
  990. }
  991. else
  992. {
  993. $AreTheyInCharge = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']}"));
  994. if(!$AreTheyInCharge)
  995. {
  996. echo "<table width='75%'>
  997. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  998. <hr><a href='?p=myFam'>Back</a></center></td>
  999. </table>";
  1000. exit($h->endpage());
  1001. }
  1002. else
  1003. {
  1004. if(isset($_POST['Payout']))
  1005. {
  1006. if(empty($_POST['Payout']) || $_POST['Payout'] > $maxPayout || !is_numeric($_POST['Payout']))
  1007. {
  1008. echo "<strong>Error:</strong> You didn't give an amount to payout or you gave more than $".number_format($maxPayout)."!<br />
  1009. [<a href='?p=CashPayment'>Back</a>]";
  1010. exit();
  1011. }
  1012. else
  1013. {
  1014. $_Payout = str_replace(",", "", $_POST['Payout']);
  1015. $message = (empty($_POST['PaymentMess'])) ? "<i>Nothing</i>" : $_POST['PaymentMess'];
  1016. echo "You have given ".number_format($membs['amount'])." members ".number_format($_Payout)." crystals and sent the message of: <i>".$db->escape($message)."</i>";
  1017. $selectUsers = $db->query("SELECT `userid` FROM `users` WHERE `gang`={$ir['gang']}");
  1018. while($r = $db->fetch_row($selectUsers))
  1019. {
  1020. event_add($r['userid'], "You have been given ".number_format($_Payout)." crystal(s) from your $ModName!<br /><small>".$db->escape($message)."</small>");
  1021. $db->query("UPDATE `users` SET `crystals`=`crystals`+{$_Payout} WHERE `userid`={$r['userid']}");
  1022. }
  1023. $db->query("UPDATE `family_mod` SET `VAULT_CRYS`=`VAULT_CRYS`-{$_Payout} WHERE `ID`={$ir['gang']}");
  1024. add_famEvent("A mass crystal payment was given of $".number_format($_Payout)."!", $ir['gang']);
  1025. }
  1026. }
  1027. else
  1028. {
  1029. echo "<form action='#' method='post'>
  1030. Payment Message: <input type='text' name='PaymentMess' length='5' maxlength='50' />
  1031. <br />
  1032. <fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  1033. There are ".number_format($membs['amount'])." members and you have ".number_format($r['VAULT_CRYS'])." crystal(s) in the vault so the <strong>maximum you can give is: ".number_format($maxPayout)." crystals</strong>
  1034. <br /><br />
  1035. Payout: <input type='text' name='Payout' length='5' maxlength='".strlen($maxPayout)."'/> crystals </fieldset>
  1036. <br />
  1037. <input type='submit' value='Payout'>
  1038. </form>";
  1039. }
  1040. }
  1041. }
  1042. echo "<hr width='45%'>
  1043. [<a href='?p=myFam'>Back</a>]";
  1044. }
  1045.  
  1046. function changeTag()
  1047. {
  1048. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $ModName;
  1049.  
  1050. $r = $db->fetch_row($db->query("SELECT `TAG` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  1051.  
  1052. if(!$ir['gang'])
  1053. {
  1054. echo "<table class='table' width='75%' style='text-align: center;'>
  1055. <th>You are not in a $ModName!</th>
  1056. <tr>
  1057. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  1058. </td>
  1059. </table><br /><br />";
  1060. exit();
  1061. }
  1062. else
  1063. {
  1064. $AreTheyInCharge = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']}"));
  1065. if(!$AreTheyInCharge)
  1066. {
  1067. echo "<table width='75%'>
  1068. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  1069. <hr><a href='?p=myFam'>Back</a></center></td>
  1070. </table>";
  1071. exit($h->endpage());
  1072. }
  1073. else
  1074. {
  1075. if(isset($_POST['tag']))
  1076. {
  1077. if(empty($_POST['tag']) || !is_string($_POST['tag']) || $_POST['tag'] == $r['TAG'])
  1078. {
  1079. echo "Please enter a valid tag<br />
  1080. - Has to be 3 Characters in length <br />
  1081. - Has to be an alphabetical character (a-z) <br />
  1082. - Cannot be the same as your previous tag <br />
  1083. [<a href='?p=changeTag'>Back</a>]";
  1084. exit();
  1085. }
  1086. else
  1087. {
  1088. echo "Your $ModName tag has been changed!";
  1089. $db->query("UPDATE `family_mod` SET `TAG`='{$_POST['tag']}' WHERE `ID`={$ir['gang']}");
  1090. echo "<br />[<a href='?p=myFam'>Back</a>]";
  1091. add_famEvent("A new tag was given to the {$ModName} of {$_POST['tag']}", $ir['gang']);
  1092. }
  1093. }
  1094. else
  1095. {
  1096. echo "<form action='#' method='post'>
  1097. <br />
  1098. <fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  1099. Your current tag is: {$r['TAG']}<br /><br />
  1100. New Tag: <input type='text' name='tag' length='3' maxlength='3' />
  1101. <br />
  1102. <input type='submit' value='Change Tag'>
  1103. </form>";
  1104. }
  1105. }
  1106. }
  1107. echo "<hr width='45%'>
  1108. [<a href='?p=myFam'>Back</a>]";
  1109. }
  1110.  
  1111. function changeIMG()
  1112. {
  1113. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $ModName;
  1114.  
  1115. $r = $db->fetch_row($db->query("SELECT `IMAGE` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  1116.  
  1117. if(!$ir['gang'])
  1118. {
  1119. echo "<table class='table' width='75%' style='text-align: center;'>
  1120. <th>You are not in a $ModName!</th>
  1121. <tr>
  1122. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  1123. </td>
  1124. </table><br /><br />";
  1125. exit();
  1126. }
  1127. else
  1128. {
  1129. $AreTheyInCharge = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']}"));
  1130. if(!$AreTheyInCharge)
  1131. {
  1132. echo "<table width='75%'>
  1133. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  1134. <hr><a href='?p=myFam'>Back</a></center></td>
  1135. </table>";
  1136. exit($h->endpage());
  1137. }
  1138. else
  1139. {
  1140. if(isset($_POST['img']))
  1141. {
  1142. $_POST['img'] = strip_tags($db->escape($_POST['img']));
  1143. if(empty($_POST['img']) || $_POST['img'] == $r['IMAGE'] || PNG($_POST['img']))
  1144. {
  1145. echo "Please enter a valid image<br />
  1146. - Has to have a .png extension <br />
  1147. - Cannot be the same as your previous image <br />
  1148. [<a href='?p=changeImage'>Back</a>]";
  1149. exit();
  1150. }
  1151. else
  1152. {
  1153. echo "Your $ModName image has been changed!";
  1154. $db->query("UPDATE `family_mod` SET `IMAGE`='{$_POST['img']}' WHERE `ID`={$ir['gang']}");
  1155. echo "<br />[<a href='?p=myFam'>Back</a>]";
  1156. add_famEvent("The {$ModName} now has a new image", $ir['gang']);
  1157. }
  1158. }
  1159. else
  1160. {
  1161. echo "<form action='#' method='post'>
  1162. <br />
  1163. <fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  1164. Your current image is: <img src='{$r['IMAGE']}' width='250px' height='50px'><br /><br />
  1165. New image: <input type='text' name='img' length='3' maxlength='250' />
  1166. <br />
  1167. <input type='submit' value='Change Tag'>
  1168. </form>";
  1169. }
  1170. }
  1171. }
  1172. echo "<hr width='45%'>
  1173. [<a href='?p=myFam'>Back</a>]";
  1174. }
  1175.  
  1176. function changeName()
  1177. {
  1178. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $ModName;
  1179.  
  1180. $r = $db->fetch_row($db->query("SELECT `NAME` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  1181.  
  1182. if(!$ir['gang'])
  1183. {
  1184. echo "<table class='table' width='75%' style='text-align: center;'>
  1185. <th>You are not in a $ModName!</th>
  1186. <tr>
  1187. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  1188. </td>
  1189. </table><br /><br />";
  1190. exit();
  1191. }
  1192. else
  1193. {
  1194. $AreTheyInCharge = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']}"));
  1195. if(!$AreTheyInCharge)
  1196. {
  1197. echo "<table width='75%'>
  1198. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  1199. <hr><a href='?p=myFam'>Back</a></center></td>
  1200. </table>";
  1201. exit($h->endpage());
  1202. }
  1203. else
  1204. {
  1205. if(isset($_POST['name']))
  1206. {
  1207. $name = trim(stripslashes($db->escape(htmlspecialchars($_POST['name']))));
  1208.  
  1209. $badWords = array('REFRESH', 'meta', 'www');
  1210. foreach($badWords as $filter)
  1211. {
  1212. $name = str_replace("$filter", "", $name);
  1213. }
  1214. if($name === $r['NAME'] || empty($name) || !is_string($name))
  1215. {
  1216. echo "Please enter a valid new $ModName name!<br />
  1217. - Cannot be the same as your previous name <br />
  1218. - Cannot be nothing <br />
  1219. - Has to be alphabetic characters (a-z)<br />
  1220. [<a href='?p=myFam'>Back</a>]";
  1221. exit();
  1222. }
  1223. $alreadyName = $db->num_rows($db->query("SELECT `NAME` FROM `family_mod` WHERE `NAME`='$name'"));
  1224. if($alreadyName)
  1225. {
  1226. echo "The {$ModName}'s name has already been taken!<br />
  1227. [<a href='?p=myFam'>Back</a>]";
  1228. exit();
  1229. }
  1230. else
  1231. {
  1232. echo "$ModName's name has been changed!";
  1233. $db->query("UPDATE `family_mod` SET `NAME`='$name' WHERE `ID`={$ir['gang']}");
  1234. add_famEvent("The {$ModName} has a new name of {$name}", $ir['gang']);
  1235. }
  1236. }
  1237. else
  1238. {
  1239. echo "<form action='#' method='post'>
  1240. <br />
  1241. <fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  1242. The current $ModName's name is: {$r['NAME']}<br /><br />
  1243. New Name: <input type='text' name='name' length='5' maxlength='10' />
  1244. <br />
  1245. <input type='submit' value='Change Tag'>
  1246. </form>";
  1247. }
  1248. }
  1249.  
  1250. }
  1251. echo "<hr width='45%'>
  1252. [<a href='?p=myFam'>Back</a>]";
  1253. }
  1254.  
  1255. function changeVice()
  1256. {
  1257. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $ModName;
  1258.  
  1259. $r = $db->fetch_row($db->query("SELECT `vPRES` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  1260. $vp = $db->fetch_row($db->query("SELECT `username` FROM `users` WHERE `userid`={$r['vPRES']}"));
  1261.  
  1262. if(!$ir['gang'])
  1263. {
  1264. echo "<table class='table' width='75%' style='text-align: center;'>
  1265. <th>You are not in a $ModName!</th>
  1266. <tr>
  1267. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  1268. </td>
  1269. </table><br /><br />";
  1270. exit();
  1271. }
  1272. else
  1273. {
  1274. $AreTheyInCharge = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']}"));
  1275. if(!$AreTheyInCharge)
  1276. {
  1277. echo "<table width='75%'>
  1278. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  1279. <hr><a href='?p=myFam'>Back</a></center></td>
  1280. </table>";
  1281. exit($h->endpage());
  1282. }
  1283. else
  1284. {
  1285. if(isset($_POST['vice']))
  1286. {
  1287. if($_POST['vice'] == $r['vPRES'])
  1288. {
  1289. echo "This user is already the Vice President!<br />
  1290. [<a href='?p=changeVice'>Back</a>";
  1291. exit();
  1292. }
  1293. else
  1294. {
  1295. echo "$vPres_icon has been changed!";
  1296. $r = $db->fetch_row($db->query("SELECT `username` FROM `users` WHERE `userid`={$_POST['vice']}"));
  1297. $db->query("UPDATE `family_mod` SET `vPRES`={$_POST['vice']} WHERE `ID`={$ir['gang']}");
  1298. add_famEvent("The {$ModName} has a new Vice President, so congratualtions to {$r['username']}", $ir['gang']);
  1299. }
  1300. }
  1301. else
  1302. {
  1303. echo "<fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  1304. The current vice president is: {$vp['username']}<br />
  1305. <small>You are changing the vice president of your $ModName</small><br /><br />";
  1306. changeViceDropdown('vice');
  1307. echo "</fieldset>";
  1308. }
  1309. }
  1310. }
  1311. echo "<hr width='45%'>
  1312. [<a href='?p=myFam'>Back</a>]";
  1313. }
  1314.  
  1315. function changePres()
  1316. {
  1317. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $ModName;
  1318.  
  1319. $r = $db->fetch_row($db->query("SELECT `PRES` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  1320. $vp = $db->fetch_row($db->query("SELECT `username` FROM `users` WHERE `userid`={$r['PRES']}"));
  1321.  
  1322. if(!$ir['gang'])
  1323. {
  1324. echo "<table class='table' width='75%' style='text-align: center;'>
  1325. <th>You are not in a $ModName!</th>
  1326. <tr>
  1327. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  1328. </td>
  1329. </table><br /><br />";
  1330. exit();
  1331. }
  1332. else
  1333. {
  1334. $AreTheyInCharge = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']}"));
  1335. if(!$AreTheyInCharge)
  1336. {
  1337. echo "<table width='75%'>
  1338. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  1339. <hr><a href='?p=myFam'>Back</a></center></td>
  1340. </table>";
  1341. exit($h->endpage());
  1342. }
  1343. else
  1344. {
  1345. if(isset($_POST['pres']))
  1346. {
  1347. if($_POST['pres'] == $r['PRES'])
  1348. {
  1349. echo "You are the President!<br />
  1350. [<a href='?p=changePres'>Back</a>";
  1351. exit();
  1352. }
  1353. if(passwordEncyption($_POST['confirmPas']) != $ir['userpass'])
  1354. {
  1355. echo "Incorrect password, unable to change the president of your $ModName!<br />
  1356. [<a href='?p=changePres'>Back</a>]";
  1357. exit();
  1358. }
  1359. else
  1360. {
  1361. echo "$Pres_icon has been changed!";
  1362. $db->query("UPDATE `family_mod` SET `PRES`={$_POST['pres']} WHERE `ID`={$ir['gang']}");
  1363. $r = $db->fetch_row($db->query("SELECT `username` FROM `users` WHERE `userid`={$_POST['pres']}"));
  1364. add_famEvent("{$r['username']} has taken leadership of the {$ModName}!", $ir['gang']);
  1365. }
  1366. }
  1367. else
  1368. {
  1369. echo "<fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  1370. The current president is: {$ir['username']}<br />
  1371. <small>You are changing the president of your $ModName</small><br /><br />";
  1372. changePresDropdown('pres');
  1373. echo "</fieldset>";
  1374. }
  1375. }
  1376. }
  1377. echo "<hr width='45%'>
  1378. [<a href='?p=myFam'>Back</a>]";
  1379. }
  1380.  
  1381. function changeDesc()
  1382. {
  1383. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $descBadWords, $ModName;
  1384.  
  1385. $r = $db->fetch_row($db->query("SELECT `DESC` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  1386.  
  1387. if(!$ir['gang'])
  1388. {
  1389. echo "<table class='table' width='75%' style='text-align: center;'>
  1390. <th>You are not in a $ModName!</th>
  1391. <tr>
  1392. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  1393. </td>
  1394. </table><br /><br />";
  1395. exit();
  1396. }
  1397. else
  1398. {
  1399. $AreTheyInCharge = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']}"));
  1400. if(!$AreTheyInCharge)
  1401. {
  1402. echo "<table width='75%'>
  1403. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  1404. <hr><a href='?p=myFam'>Back</a></center></td>
  1405. </table>";
  1406. exit($h->endpage());
  1407. }
  1408. else
  1409. {
  1410. if(isset($_POST['desc']))
  1411. {
  1412. $_POST['desc'] = trim(strip_tags($_POST['desc']));
  1413. if(empty($_POST['desc']) || $_POST['desc'] == $r['DESC'])
  1414. {
  1415. echo "Please enter a valid description <br />
  1416. - Cannot be blank <br />
  1417. - Cannot be the same as previous description<br />
  1418. [<a href='?p=changeDesc'>Back</a>]";
  1419. exit();
  1420. }
  1421. else
  1422. {
  1423. foreach($descBadWords as $filter)
  1424. {
  1425. $_POST['desc'] = str_replace("$filter", "", $_POST['desc']);
  1426. }
  1427. echo "The $ModName's description has been changed!";
  1428. $db->query("UPDATE `family_mod` SET `DESC`='{$_POST['desc']}' WHERE `ID`={$ir['gang']}");
  1429. add_famEvent("The {$ModName} now has a new description", $ir['gang']);
  1430. }
  1431. }
  1432. else
  1433. {
  1434. echo "<fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  1435. The current description is: <small>See textbox</small><br />
  1436. <small>You are changing the description of your $ModName</small><br /><br />";
  1437. echo "<form action='#' method='post'>
  1438. <textarea cols='25' rows='10' name='desc'>".nl2br(strip_tags(stripslashes($r['DESC'])))."</textarea>
  1439. <br />
  1440. <input type='submit' value='Change Description'>
  1441. </form>";
  1442. echo "</fieldset>";
  1443. }
  1444. }
  1445. }
  1446. echo "<hr width='45%'>
  1447. [<a href='?p=myFam'>Back</a>]";
  1448. }
  1449.  
  1450. function deleteFam()
  1451. {
  1452. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $descBadWords, $ModName;
  1453.  
  1454. $r = $db->fetch_row($db->query("SELECT `DESC` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  1455.  
  1456. if(!$ir['gang'])
  1457. {
  1458. echo "<table class='table' width='75%' style='text-align: center;'>
  1459. <th>You are not in a $ModName!</th>
  1460. <tr>
  1461. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  1462. </td>
  1463. </table><br /><br />";
  1464. exit();
  1465. }
  1466. else
  1467. {
  1468. $AreTheyInCharge = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']}"));
  1469. if(!$AreTheyInCharge)
  1470. {
  1471. echo "<table width='75%'>
  1472. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  1473. <hr><a href='?p=myFam'>Back</a></center></td>
  1474. </table>";
  1475. exit($h->endpage());
  1476. }
  1477. else
  1478. {
  1479. if(isset($_POST['del']))
  1480. {
  1481. if(passwordEncyption($_POST['del']) != $ir['userpass'])
  1482. {
  1483. echo "Your confirmation password is not correct!<br />
  1484. [<a href='?p=myFam'>Back</a>]";
  1485. }
  1486. else
  1487. {
  1488. echo "Your $ModName has been deleted!";
  1489. $db->query("DELETE FROM `family_mod` WHERE `ID`={$ir['gang']}");
  1490. $allFamUsers = $db->query("SELECT `userid` FROM `users` WHERE `gang`={$ir['gang']}");
  1491. while ($r = $db->fetch_row($allFamUsers))
  1492. {
  1493. event_add($r['userid'], "The $ModName you were in was deleted by the president");
  1494. $db->query("UPDATE `users` SET `gang`=0 WHERE `userid`={$r['userid']}");
  1495. }
  1496. }
  1497. }
  1498. else
  1499. {
  1500. echo "<fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>";
  1501. delFamily('del');
  1502. echo "</fieldset>";
  1503. }
  1504. }
  1505. }
  1506. echo "<hr width='45%'>
  1507. [<a href='?p=myFam'>Back</a>]";
  1508. }
  1509.  
  1510. function apps()
  1511. {
  1512. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $ModName;
  1513.  
  1514. $r = $db->fetch_row($db->query("SELECT `DESC` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  1515.  
  1516. if(!$ir['gang'])
  1517. {
  1518. echo "<table class='table' width='75%' style='text-align: center;'>
  1519. <th>You are not in a $ModName!</th>
  1520. <tr>
  1521. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  1522. </td>
  1523. </table><br /><br />";
  1524. exit();
  1525. }
  1526. else
  1527. {
  1528. $AreTheyPres = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']} || `vPRES`={$ir['userid']}"));
  1529. if(!$AreTheyPres)
  1530. {
  1531. echo "<table width='75%'>
  1532. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  1533. <hr><a href='?p=myFam'>Back</a></center></td>
  1534. </table>";
  1535. exit($h->endpage());
  1536. }
  1537. else
  1538. {
  1539. if(@$_GET['action'] == 'accept')
  1540. {
  1541. //for applications, please do not alter
  1542. $DidTheySendAnApp = $db->num_rows($db->query("SELECT `userid` FROM `family_mod_apply` WHERE `gangID`={$ir['gang']} && `userid`={$_GET['user']}"));
  1543.  
  1544. if(!$_GET['user'] || !$DidTheySendAnApp)
  1545. {
  1546. echo "This application does not exist!<br />
  1547. [<a href='?p=myFam'>Back</a>]";
  1548. exit();
  1549. }
  1550. $amntOfMembs = $db->fetch_row($db->query("SELECT COUNT(`userid`) AS `u` FROM `users` WHERE `gang`={$ir['gang']}"));
  1551. $r = $db->fetch_row($db->query("SELECT `SPOTS`,`NAME` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  1552. if($amntOfMembs['u']+1 > $r['SPOTS'])
  1553. {
  1554. echo "You need to upgrade the amount of spots in your $ModName before accepting this applicant!<br />
  1555. [<a href='?p=myFam'>Back</a>]";
  1556. exit();
  1557. }
  1558. $areTheyInAFam = $db->num_rows($db->query("SELECT `gang` FROM `users` WHERE `userid`={$_GET['user']} && `gang` > 0"));
  1559. if($areTheyInAFam)
  1560. {
  1561. echo "Sorry, but they are already in a $ModName!<br />
  1562. [<a href='?p=myFam'>Back</a>]";
  1563. }
  1564. else
  1565. {
  1566. $r = $db->fetch_row($db->query("SELECT `NAME` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  1567. $user = $db->fetch_row($db->query("SELECT `userid`,`username` FROM `users` WHERE `userid`={$_GET['user']}"));
  1568. echo "You have accepted the application from {$user['username']}";
  1569. event_add($user['userid'], "Your application from {$r['NAME']} $ModName was accepted, Congratulations!");
  1570. $db->query("UPDATE `users` SET `gang`={$ir['gang']} WHERE `userid`={$_GET['user']}");
  1571. $db->query("DELETE FROM `family_mod_apply` WHERE `userid`={$_GET['user']}");
  1572. add_famEvent("{$user['username']} is now in the {$ModName}!", $ir['gang']);
  1573. }
  1574. }
  1575. elseif(@$_GET['action'] == 'deny')
  1576. {
  1577. //for applications, please do not alter
  1578. $DidTheySendAnApp = $db->num_rows($db->query("SELECT `userid` FROM `family_mod_apply` WHERE `gangID`={$ir['gang']} && `userid`={$_GET['user']}"));
  1579.  
  1580. if(!$_GET['user'] || !$DidTheySendAnApp)
  1581. {
  1582. echo "This application does not exist!<br />
  1583. [<a href='?p=myFam'>Back</a>]";
  1584. exit();
  1585. }
  1586. else
  1587. {
  1588. $r = $db->fetch_row($db->query("SELECT `NAME` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  1589. $user = $db->fetch_row($db->query("SELECT `userid`,`username` FROM `users` WHERE `userid`={$_GET['user']}"));
  1590. echo "You have declined the application from {$user['username']}";
  1591. event_add($user['userid'], "Your application from {$r['NAME']} $ModName was declined!");
  1592. $db->query("DELETE FROM `family_mod_apply` WHERE `userid`={$_GET['user']}");
  1593. }
  1594. }
  1595. else
  1596. {
  1597. echo "<table width='80%' class='table'>
  1598. <th width='20%'>Applicant</th>
  1599. <th width='20%'>Applied</th>
  1600. <th width='20%'>CV</th>
  1601. <th width='20%'>Links</th>
  1602. <tr>";
  1603. $getData = $db->query("SELECT * FROM `family_mod_apply` WHERE `gangID`={$ir['gang']}");
  1604. while($r = $db->fetch_row($getData))
  1605. {
  1606. $user = $db->fetch_row($db->query("SELECT `userid`,`username` FROM `users` WHERE `userid`={$r['userid']}"));
  1607. echo "<td><a href='viewuser.php?u={$user['userid']}'>{$user['username']}</a></td>
  1608. <td>".date('l F (G:i (a))', $r['time'])."</td>
  1609. <td>".strip_tags(htmlspecialchars($r['applyNote']))."</td>
  1610. <td>[<a href='?p=applications&action=accept&user={$r['userid']}'>Accept</a>]<br />
  1611. [<a href='?p=applications&action=deny&user={$r['userid']}'>Deny</a>]</td>
  1612. <tr>";
  1613. }
  1614. }
  1615. }
  1616. }
  1617. echo "<hr width='45%'>
  1618. [<a href='?p=myFam'>Back</a>]";
  1619. }
  1620.  
  1621. function upgradeSpots()
  1622. {
  1623. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $upgradeSpots, $ModName;
  1624.  
  1625. $r = $db->fetch_row($db->query("SELECT `DESC` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  1626.  
  1627. if(!$ir['gang'])
  1628. {
  1629. echo "<table class='table' width='75%' style='text-align: center;'>
  1630. <th>You are not in a $ModName!</th>
  1631. <tr>
  1632. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  1633. </td>
  1634. </table><br /><br />";
  1635. exit();
  1636. }
  1637. else
  1638. {
  1639. $AreTheyPres = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']}"));
  1640. if(!$AreTheyPres)
  1641. {
  1642. echo "<table width='75%'>
  1643. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  1644. <hr><a href='?p=myFam'>Back</a></center></td>
  1645. </table>";
  1646. exit($h->endpage());
  1647. }
  1648. else
  1649. {
  1650. $r = $db->fetch_row($db->query("SELECT `VAULT_CASH` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  1651. $buyspots = floor($r['VAULT_CASH'] / $upgradeSpots);
  1652. $cost = @$_POST['spots'] * $upgradeSpots;
  1653. if(isset($_POST['spots']))
  1654. {
  1655. $_POST['spots'] == abs((int) $_POST['spots']);
  1656. if(!is_numeric($_POST['spots']) || $_POST['spots'] > $buyspots)
  1657. {
  1658. echo "Sorry, but<br />
  1659. - You can only buy ".number_format($buyspots)." spots (maximum)<br />
  1660. - Please fill out the form<br />
  1661. [<a href='?p=myFam'>Back</a>]";
  1662. }
  1663. else
  1664. {
  1665. echo "You have upgraded your $ModName to include ".number_format($_POST['spots'])." more places!";
  1666. $db->query("UPDATE `family_mod` SET `VAULT_CASH`=`VAULT_CASH`-$cost,`SPOTS`=`SPOTS`+{$_POST['spots']} WHERE `ID`={$ir['gang']}");
  1667. echo "[<a href='?p=myFam'>Back</a>]";
  1668. $Grammer = ($_POST['spots'] > 1) ? "s" : "";
  1669. add_famEvent("The {$ModName} now has an extra ".number_format($_POST['spots'])." spot{$Grammer}!", $ir['gang']);
  1670. }
  1671. }
  1672. else
  1673. {
  1674. echo "<fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  1675. <small>Upgrading the amount of places you have in your $ModName, <strong>1 spot costs $".number_format($upgradeSpots).", you can buy ".number_format($buyspots)." spots!</strong><br /><br />
  1676. <form action='#' method='post'>
  1677. Upgrade to: <input type='text' name='spots' length='5' maxlength='".strlen($buyspots)."'/>
  1678. <br />
  1679. <input type='submit' value='Upgrade!'>
  1680. </form>
  1681. </fieldset>";
  1682. }
  1683. }
  1684. }
  1685. echo "<hr width='45%'>
  1686. [<a href='?p=myFam'>Back</a>]";
  1687. }
  1688.  
  1689. function mailAll()
  1690. {
  1691. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $upgradeSpots, $ModName, $mailDays;
  1692.  
  1693. $r = $db->fetch_row($db->query("SELECT `userid` FROM `users` WHERE `gang`={$ir['gang']}"));
  1694.  
  1695. if(!$ir['gang'])
  1696. {
  1697. echo "<table class='table' width='75%' style='text-align: center;'>
  1698. <th>You are not in a $ModName!</th>
  1699. <tr>
  1700. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  1701. </td>
  1702. </table><br /><br />";
  1703. exit();
  1704. }
  1705. else
  1706. {
  1707. $AreTheyPres = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']}"));
  1708. if(!$AreTheyPres)
  1709. {
  1710. echo "<table width='75%'>
  1711. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  1712. <hr><a href='?p=myFam'>Back</a></center></td>
  1713. </table>";
  1714. exit($h->endpage());
  1715. }
  1716. else
  1717. {
  1718. if(isset($_POST['mail']))
  1719. {
  1720. $now = date("d") + $mailDays;
  1721. $db->query("UPDATE `family_mail` SET `LastSentMail`={$now} WHERE `ID`={$ir['gang']}") or die(mysql_error());
  1722.  
  1723. $_POST['mail'] == strip_tags(htmlspecialchars(nl2br(trim($_POST['mail']))));
  1724. $badWords = array('meta', 'REFRESH', 'refresh', 'www', 'com');
  1725. foreach($badWords as $filter)
  1726. {
  1727. $_POST['mail'] == str_replace($filter, "", $_POST['mail']);
  1728. }
  1729. $getMembers = $db->query("SELECT `userid` FROM `users` WHERE `gang`={$ir['gang']}");
  1730. while($r = $db->fetch_row($getMembers))
  1731. {
  1732. $db->query("INSERT INTO `mail` VALUES ('NULL', 1, {$ir['userid']}, {$r['userid']}, unix_timestamp(), '$ModName Mail', '{$_POST['mail']}')");
  1733. $db->query("UPDATE `users` SET `new_mail`=1 WHERE `userid`={$r['userid']}");
  1734.  
  1735. }
  1736. echo "You have sent mail to all your members in your $ModName";
  1737. }
  1738. else
  1739. {
  1740. $m = $db->fetch_row($db->query("SELECT `LastSentMail` FROM `family_mail` WHERE `ID`={$ir['gang']}"));
  1741. $nextMail = $m['LastSentMail'] + $mailDays;
  1742. $disabled = ((date("d")) < $nextMail && $m['LastSentMail'] != 0) ? "disabled='yes'" : "";
  1743. $Grammer = ($mailDays > 1) ? "s" : "";
  1744. echo "<fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  1745. <small>You are mailing all your members in your $ModName, <strong>You can do this once every $mailDays day$Grammer, you can sent your next mail on the {$nextMail} ".date("M")."</strong><br /><br />
  1746. <form action='#' method='post'>
  1747. <textarea cols='15' rows='5' name='mail' wrap='hard' $disabled>Enter your message here...</textarea>
  1748. <br />
  1749. <input type='submit' value='Send!' $disabled>
  1750. </form>
  1751. </fieldset>";
  1752. }
  1753. }
  1754. }
  1755. echo "<hr width='45%'>
  1756. [<a href='?p=myFam'>Back</a>]";
  1757. }
  1758.  
  1759. function startWar()
  1760. {
  1761. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $upgradeSpots, $ModName, $mailDays;
  1762.  
  1763. if(!$ir['gang'])
  1764. {
  1765. echo "<table class='table' width='75%' style='text-align: center;'>
  1766. <th>You are not in a $ModName!</th>
  1767. <tr>
  1768. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  1769. </td>
  1770. </table><br /><br />";
  1771. exit();
  1772. }
  1773. else
  1774. {
  1775. $AreTheyPres = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']}"));
  1776. if(!$AreTheyPres)
  1777. {
  1778. echo "<table width='75%'>
  1779. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  1780. <hr><a href='?p=myFam'>Back</a></center></td>
  1781. </table>";
  1782. exit($h->endpage());
  1783. }
  1784. else
  1785. {
  1786. if(isset($_POST['start']))
  1787. {
  1788. if($_POST['start'] == $ir['gang'])
  1789. {
  1790. echo "You cannot start a war with your own $ModName!<br /> [<a href='?p=myFam'>Back</a>]";
  1791. exit($h->endpage());
  1792. }
  1793. if($_POST['start'] == 0)
  1794. {
  1795. echo "You are already at war with this $ModName!<br /> [<a href='?p=myFam'>Back</a>]";
  1796. exit($h->endpage());
  1797. }
  1798. else
  1799. {
  1800. $r = $db->fetch_row($db->query("SELECT `NAME` FROM `family_mod` WHERE `ID`={$_POST['start']}"));
  1801. $me = $db->fetch_row($db->query("SELECT `NAME` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  1802. echo "You have started a war with {$r['NAME']}, Good Luck!";
  1803. add_famEvent("A war was started with {$r['NAME']}!", $ir['gang']);
  1804. add_famEvent("A was was declared against you by {$me['NAME']}!", $_POST['start']);
  1805. $time = time();
  1806. $db->query("INSERT INTO `family_wars` (`Starter`,`Victim`,`Time`) VALUES ({$ir['gang']}, {$_POST['start']}, {$time})");
  1807. }
  1808. }
  1809. else
  1810. {
  1811. echo "<fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  1812. <small>You are starting a war with another $ModName, <strong>You can surrender if they are too strong</strong><br /><br />";
  1813. dropdownAllFam('start', 'yes');
  1814. echo " <br />
  1815. </form>
  1816. </fieldset>";
  1817. }
  1818. }
  1819. }
  1820. echo "<hr width='45%'>
  1821. [<a href='?p=myFam'>Back</a>]";
  1822. }
  1823.  
  1824. function hitListCrew()
  1825. {
  1826. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $upgradeSpots, $ModName, $mailDays;
  1827.  
  1828. if(!$ir['gang'])
  1829. {
  1830. echo "<table class='table' width='75%' style='text-align: center;'>
  1831. <th>You are not in a $ModName!</th>
  1832. <tr>
  1833. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  1834. </td>
  1835. </table><br /><br />";
  1836. exit();
  1837. }
  1838. else
  1839. {
  1840. $AreTheyPres = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']}"));
  1841. if(!$AreTheyPres)
  1842. {
  1843. echo "<table width='75%'>
  1844. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  1845. <hr><a href='?p=myFam'>Back</a></center></td>
  1846. </table>";
  1847. exit($h->endpage());
  1848. }
  1849. else
  1850. {
  1851. if(isset($_POST['hitlist']))
  1852. {
  1853. if($_POST['hitlist'] == $ir['gang'])
  1854. {
  1855. echo "You cannot hit list your own $ModName!<br /> [<a href='?p=myFam'>Back</a>]";
  1856. exit($h->endpage());
  1857. }
  1858. $already = $db->num_rows($db->query("SELECT `ID` FROM `family_hitlist` WHERE `Adder`={$ir['gang']} && `HitList`={$_POST['hitlist']}"));
  1859. if($already)
  1860. {
  1861. echo "This {$ModName} is already on your {$ModName}'s hitlist!<br /> [<a href='?p=myFam'>Back</a>]";
  1862. exit();
  1863. }
  1864. else
  1865. {
  1866. $r = $db->fetch_row($db->query("SELECT `NAME` FROM `family_mod` WHERE `ID`={$_POST['hitlist']}"));
  1867. echo "{$r['NAME']} has been added to the {$ModName}'s hitlist!<br /> [<a href='?p=myFam'>Back</a>]";
  1868. $db->query("INSERT INTO `family_hitlist` (`Adder`,`HitList`) VALUES ({$ir['gang']}, {$_POST['hitlist']})");
  1869. add_famEvent("{$r['NAME']} was added to the hit list!", $ir['gang']);
  1870. exit();
  1871. }
  1872. }
  1873. else
  1874. {
  1875. echo "<fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  1876. <small>You can add another $ModName to the hitlist! <strong>It is advised you hit list $ModName's that you are at war with!</strong><br /><br />";
  1877. dropdownAllFam('hitlist', 'no');
  1878. echo " <br />
  1879. </form>
  1880. </fieldset>";
  1881. }
  1882. }
  1883. }
  1884. echo "<hr width='45%'>
  1885. [<a href='?p=myFam'>Back</a>]";
  1886. }
  1887.  
  1888. function surrender()
  1889. {
  1890. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $upgradeSpots, $ModName, $mailDays;
  1891.  
  1892. if(!$ir['gang'])
  1893. {
  1894. echo "<table class='table' width='75%' style='text-align: center;'>
  1895. <th>You are not in a $ModName!</th>
  1896. <tr>
  1897. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  1898. </td>
  1899. </table><br /><br />";
  1900. exit();
  1901. }
  1902. else
  1903. {
  1904. $AreTheyPres = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']}"));
  1905. if(!$AreTheyPres)
  1906. {
  1907. echo "<table width='75%'>
  1908. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  1909. <hr><a href='?p=myFam'>Back</a></center></td>
  1910. </table>";
  1911. exit($h->endpage());
  1912. }
  1913. else
  1914. {
  1915. if(isset($_POST['surrender']))
  1916. {
  1917. if($_POST['surrender'] == $ir['gang'])
  1918. {
  1919. echo "You cannot surrender against your own$ModName!<br /> [<a href='?p=myFam'>Back</a>]";
  1920. exit($h->endpage());
  1921. }
  1922. $at_war = $db->num_rows($db->query("SELECT `ID` FROM `family_wars` WHERE `Starter`={$ir['gang']} && `Victim`={$_POST['surrender']} || `Starter`={$_POST['surrender']} && `Victim`={$ir['gang']}"));
  1923. if(!$at_war)
  1924. {
  1925. echo "You are not at war with this {$ModName}!<br /> [<a href='?p=myFam'>Back</a>]";
  1926. exit();
  1927. }
  1928. if(passwordEncyption($_POST['confirmpass']) != $ir['userpass'])
  1929. {
  1930. echo "Incorrect password!<br /> [<a href='?p=myFam'>Back</a>]";
  1931. exit();
  1932. }
  1933. else
  1934. {
  1935. $r = $db->fetch_row($db->query("SELECT `NAME` FROM `family_mod` WHERE `ID`={$_POST['surrender']}"));
  1936. $me = $db->fetch_row($db->query("SELECT `NAME` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  1937. echo "You have surrenderd against {$r['NAME']}<br /> [<a href='?p=myFam'>Back</a>]";
  1938. $war = $db->query("SELECT `Starter`,`Victim` FROM `family_wars` WHERE `Starter`={$ir['gang']} && `Victim`!={$ir['gang']} || `Starter`!={$ir['gang']} && `Victim`={$ir['gang']}");
  1939.  
  1940. //do the wars won and lost queryes
  1941. $db->query("UPDATE `family_mod` SET `LOST`=`LOST`+1 WHERE `ID`={$ir['gang']}");
  1942. $db->query("UPDATE `family_mod` SET `WON`=`WON`+1 WHERE `ID`={$_POST['surrender']}");
  1943.  
  1944. $field = ($war['Starter'] == $ir['gang']) ? "Victim" : "Starter";
  1945. $db->query("DELETE FROM `family_wars` WHERE {$field}={$_POST['surrender']}");
  1946. add_famEvent("{$r['NAME']} won the war as your president surrenderd!", $ir['gang']);
  1947. add_famEvent("You won the war against {$me['NAME']}! Congratulations!", $_POST['surrender']);
  1948. exit();
  1949. }
  1950. }
  1951. else
  1952. {
  1953. echo "<fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  1954. <small>You are surrending against another {$ModName} <strong>This will ruin your [W]ar[W]in Ratio</strong><br /><br />";
  1955. surrenderForm('surrender');
  1956. echo " <br />
  1957. </form>
  1958. </fieldset>";
  1959. }
  1960. }
  1961. }
  1962. echo "<hr width='45%'>
  1963. [<a href='?p=myFam'>Back</a>]";
  1964. }
  1965.  
  1966. function itemLent()
  1967. {
  1968. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $upgradeSpots, $ModName, $mailDays;
  1969.  
  1970. if(!$ir['gang'])
  1971. {
  1972. echo "<table class='table' width='75%' style='text-align: center;'>
  1973. <th>You are not in a $ModName!</th>
  1974. <tr>
  1975. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  1976. </td>
  1977. </table><br /><br />";
  1978. exit();
  1979. }
  1980. else
  1981. {
  1982. $AreTheyPres = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']} || `vPRES`={$ir['userid']}"));
  1983. if(!$AreTheyPres)
  1984. {
  1985. echo "<table width='75%'>
  1986. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  1987. <hr><a href='?p=myFam'>Back</a></center></td>
  1988. </table>";
  1989. exit($h->endpage());
  1990. }
  1991.  
  1992. $select = $db->query("SELECT fr.*,u.`username`,u.`gang` FROM `family_armory_rent` fr LEFT JOIN `users` u ON fr.`Renter`=u.`userid` WHERE u.`gang`={$ir['gang']}");
  1993. echo "<fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  1994. <small>Here, you can see who has rented what from your armory.<br />
  1995. </fieldset>
  1996.  
  1997. <table class='table' width='80%' style='text-align: center;'>
  1998. <th colspan='4'>Items being rented!</th>
  1999. <tr style='background-color: #FFF;'></tr>
  2000. <th width='20%'>Item Name</th>
  2001. <th width='20%'>Rented By</th>
  2002. <th width='20%'>Days Left</th>
  2003. <th width='20%'>Give Back</th>
  2004. <tr>";
  2005.  
  2006. if(!$db->fetch_row($select))
  2007. {
  2008. echo "<td colspan='4'>No items have been rented!</td>";
  2009. }
  2010. while ($r = $db->fetch_row($select))
  2011. {
  2012. $i = $db->fetch_row($db->query("SELECT `itmname` FROM `items` WHERE `itmid`={$r['ItemID']}"));
  2013. echo "<td>".ucwords($i['itmname'])."</td>
  2014. <td><a href='viewuser.php?u={$r['Renter']}'>".ucwords($r['username'])."</a></td>
  2015. <td>{$r['Days']} Day(s)</td>
  2016. <td><a href='?p=itemLent&action=giveBack&Entry=".base64_encode($r['ID'])."'>Give Back</a></td>
  2017. <tr>";
  2018. }
  2019. }
  2020.  
  2021. if(@$_GET['action'] == 'giveBack')
  2022. {
  2023. $Max = $db->fetch_row($db->query("SELECT `ID` FROM `family_armory_rent` ORDER BY `ID` DESC LIMIT 1"));
  2024.  
  2025. $_GET['Entry'] = base64_decode($_GET['Entry']);
  2026.  
  2027. if(!$_GET['Entry'] || $_GET['Entry'] > $Max['ID'])
  2028. {
  2029. echo "<br /><table style='background: #FF0000' width='100%'><th>Invalid Entry!<br />[<a href='?p=itemLent'>Back</a>]</th></table>";
  2030. exit($h->endpage());
  2031. }
  2032. else
  2033. {
  2034. $r = $db->fetch_row($db->query("SELECT `ItemID`,`Renter`,`Adder` FROM `family_armory_rent` WHERE `ID`={$_GET['Entry']}"));
  2035.  
  2036. if(!$r['ItemID'])
  2037. {
  2038. echo "<br /><table style='background: #FF0000' width='100%'><th>Uh-Oh, Something happened!<br />[<a href='?p=itemLent'>Back</a>]</th></table>";
  2039. exit($h->endpage());
  2040. }
  2041. else
  2042. {
  2043. $u = $db->fetch_row($db->query("SELECT `username` FROM `users` WHERE `userid`={$r['Adder']}"));
  2044. $i = $db->fetch_row($db->query("SELECT `itmname` FROM `items` WHERE `itmid`={$r['ItemID']}"));
  2045. echo "<br /><table style='background: #6EFF70' width='100%'><th>You have given 1 {$i['itmname']} back to {$u['username']}!<br />[<a href='?p=myFam'>Back</a>]</th></table>";
  2046. event_add($r['Adder'], "You have been given back your {$i['itmname']} from your {$ModName} early!");
  2047. item_add($r['Adder'], $r['ItemID'], 1, 0, 0);
  2048. $db->query("DELETE FROM `family_armory_rent` WHERE `ID`={$_GET['Entry']} LIMIT 1");
  2049. }
  2050. }
  2051. }
  2052.  
  2053. }
  2054.  
  2055. function resign()
  2056. {
  2057. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $upgradeSpots, $ModName, $mailDays;
  2058.  
  2059. if(!$ir['gang'])
  2060. {
  2061. echo "<table class='table' width='75%' style='text-align: center;'>
  2062. <th>You are not in a $ModName!</th>
  2063. <tr>
  2064. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  2065. </td>
  2066. </table><br /><br />";
  2067. exit();
  2068. }
  2069. else
  2070. {
  2071. $AreTheyPres = $db->num_rows($db->query("SELECT `PRES` FROM `family_mod` WHERE `PRES`={$ir['userid']} || `vPRES`={$ir['userid']}"));
  2072. if(!$AreTheyPres)
  2073. {
  2074. echo "<table width='75%'>
  2075. <td style='background-color: #FFCCCC;'><center>Strongly guarded and you want to be in here?! Think again!<br />
  2076. <hr><a href='?p=myFam'>Back</a></center></td>
  2077. </table>";
  2078. exit($h->endpage());
  2079. }
  2080.  
  2081. if(isset($_POST['resign']))
  2082. {
  2083. if(passwordEncyption($_POST['confirmPas']) != $ir['userpass'])
  2084. {
  2085. echo "Incorrect password, unable to resign from your $ModName!<br />
  2086. [<a href='?p=resign'>Back</a>]";
  2087. exit();
  2088. }
  2089. else
  2090. {
  2091. echo "$vPres_icon has been changed!";
  2092. $pres = $db->fetch_row($db->query("SELECT `PRES` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  2093. $db->query("UPDATE `family_mod` SET `vPRES`={$pres['PRES']} WHERE `ID`={$ir['gang']}");
  2094. $r = $db->fetch_row($db->query("SELECT `username` FROM `users` WHERE `userid`={$pres['PRES']}"));
  2095. add_famEvent("{$ir['username']} has resigned from the {$ModName} as vice president!", $ir['gang']);
  2096. }
  2097. }
  2098. else
  2099. {
  2100. echo "<fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  2101. <small>The current $Pres_icon will become Vice president!</small><br />
  2102. <small>You are resigning from your $ModName</small><br /><br />
  2103. <form action='#' method='post'>
  2104. <small>Please insert your password for confirmation</small><br />
  2105. Password: <input type='password' name='confirmPas' length='5' maxlength='50' /><br />
  2106. <input type='submit' name='resign' value='Resign'>
  2107. </form></fieldset>";
  2108. }
  2109. }
  2110. echo "<hr width='45%'>
  2111. [<a href='?p=myFam'>Back</a>]";
  2112. }
  2113.  
  2114. /*
  2115. ====== ARMORY FUNCTIONS BELOW ======
  2116. */
  2117.  
  2118. function armoryIndex()
  2119. {
  2120. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $upgradeSpots, $ModName, $mailDays;
  2121.  
  2122. if(!$ir['gang'])
  2123. {
  2124. echo "<table class='table' width='75%' style='text-align: center;'>
  2125. <th>You are not in a $ModName!</th>
  2126. <tr>
  2127. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  2128. </td>
  2129. </table><br /><br />";
  2130. exit();
  2131. }
  2132. else
  2133. {
  2134. echo "<fieldset style='width: 50%;'><legend><font style='font-weight: bold; font-size:2em'>&dagger;</font></legend>
  2135. <small>Welcome to the {$ModName}'s armory, here people can contribute and give weapons and/or armor to the {$ModName} where people can \"rent\" them to help during wars or just in general!<br /><br />
  2136. [<a href='?p=armoryAdd'>Add an Item</a>]
  2137. </fieldset>
  2138.  
  2139. <table class='table' width='80%' style='text-align: center;'>
  2140. <th colspan='4'>The Armory!</th>
  2141. <tr style='background-color: #FFF;'></tr>
  2142. <th width='20%'>Item Name</th>
  2143. <th width='20%'>\"Rent\" Time</th>
  2144. <th width='20%'>Donated By</th>
  2145. <th width='20%'>Links</th>
  2146. <tr>";
  2147. //get pres and vpres
  2148. $Pres = $db->fetch_row($db->query("SELECT `PRES` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  2149. $vPres = $db->fetch_row($db->query("SELECT `vPRES` FROM `family_mod` WHERE `ID`={$ir['gang']}"));
  2150.  
  2151. $selectData = $db->query("SELECT * FROM `family_armory` WHERE `FamID`={$ir['gang']}");
  2152. if(!$db->num_rows($selectData))
  2153. {
  2154. echo "<td colspan='4'>Nothing has been added to the Armory!</td>";
  2155. }
  2156. else
  2157. {
  2158. while($r = $db->fetch_row($selectData))
  2159. {
  2160. $i = $db->fetch_row($db->query("SELECT `itmname` FROM `items` WHERE `itmid`={$r['ItemID']}"));
  2161. $user = $db->fetch_row($db->query("SELECT `username`,`userid` FROM `users` WHERE `userid`={$r['Adder']}"));
  2162. $uCheck = ($Pres['PRES'] == $user['userid']) ? "{$Pres_icon} {$user['username']}" : $user['username'];
  2163. $u = ($vPres['vPRES'] <> $user['userid']) ? $uCheck : "{$vPres_icon} {$user['username']}";
  2164. echo "<td>{$i['itmname']}</td>
  2165. <td>{$r['RentTime']} Days</td>
  2166. <td>{$u}</td>
  2167. <td><a href='?p=armoryRent&entry=".base64_encode($r['ID'])."&item=".base64_encode($r['ItemID'])."&adder=".base64_encode($r['Adder'])."'>Rent</a></td>
  2168. <tr>";
  2169. }
  2170. }
  2171. }
  2172. echo "<hr width='45%'>
  2173. [<a href='?p=myFam'>Back</a>]";
  2174. }
  2175.  
  2176. function armoryAdd()
  2177. {
  2178. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $upgradeSpots, $ModName, $mailDays;
  2179.  
  2180. if(!$ir['gang'])
  2181. {
  2182. echo "<table class='table' width='75%' style='text-align: center;'>
  2183. <th>You are not in a $ModName!</th>
  2184. <tr>
  2185. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  2186. </td>
  2187. </table><br /><br />";
  2188. exit();
  2189. }
  2190. else
  2191. {
  2192. if(isset($_POST['add']))
  2193. {
  2194. $_GET['itm'] = abs((int) $_GET['itm']);
  2195. $doTheyHave = $db->query("SELECT `inv_itemid` FROM `inventory` WHERE `inv_itemid`={$_GET['itm']} && `inv_userid`={$ir['userid']}");
  2196. $r = $db->fetch_row($db->query("SELECT `itmname` FROM `items` WHERE `itmid`={$_GET['itm']}"));
  2197. if(!$db->num_rows($doTheyHave))
  2198. {
  2199. echo "You do not have the {$r['itmname']} in your inventory! <br /> [<a href='?p=armoryIndex'>Back</a>]";
  2200. exit();
  2201. }
  2202. if(!in_array($_POST['days'], array(1,7)))
  2203. {
  2204. echo "You can only put it on rent for 1 day or 1 week!<br /> [<a href='?p=armoryIndex'>Back</a>]";
  2205. exit();
  2206. }
  2207.  
  2208. rentedItem($userid, $_GET['itm']);
  2209.  
  2210. echo "<table width='75%'>
  2211. <td style='background-color: #BCED91;'><center>Thanks for your <strong>item</strong>ical help!</center></a></td>
  2212. </table><br />
  2213. You have donated a {$r['itmname']}!";
  2214. //update inventory and insert it into armory
  2215. $db->query("UPDATE `inventory` SET `inv_qty`=`inv_qty`-1 WHERE `inv_itemid`={$_GET['itm']} && `inv_userid`={$ir['userid']}");
  2216. $db->query("INSERT INTO `family_armory` (`ItemID`,`Adder`,`RentTime`,`FamID`) VALUES ({$_GET['itm']}, {$ir['userid']}, {$_POST['days']}, {$ir['gang']})");
  2217. }
  2218. else
  2219. {
  2220. $selectItems = $db->query("SELECT i.*, it.`itmname`,it.`itmid` FROM `inventory` i LEFT JOIN `items` it ON i.`inv_itemid`=it.`itmid` WHERE `inv_userid`={$ir['userid']}");
  2221. if(!$db->num_rows($selectItems))
  2222. {
  2223. echo "You have no items to give!";
  2224. exit();
  2225. }
  2226. else
  2227. {
  2228. echo "<table class='table' width='90%' style='text-align: center;'>
  2229. <th colspan='3'>Your Items!</th>
  2230. <tr style='background-color: #FFF;'></tr>
  2231. <th>Item Name</th>
  2232. <th>Information</th>
  2233. <th>Links</th>
  2234. <tr>";
  2235. while ($r = $db->fetch_row($selectItems))
  2236. {
  2237. echo "<td>{$r['itmname']}</td>
  2238. <td><strong>QTY:</strong> ".number_format($r['inv_qty'])."</td>
  2239. <td><form action='?p=armoryAdd&itm={$r['itmid']}' method='post'>
  2240. <select name='days'>
  2241. <option value='1'>1 day rent
  2242. <option value='7'>A Week
  2243. </option>
  2244. </select>
  2245. <br />
  2246. <input type='submit' value='Give to Armory!' name='add'></form></td>
  2247. <tr>";
  2248. }
  2249. }
  2250. }
  2251. }
  2252. }
  2253.  
  2254. function armoryRent()
  2255. {
  2256. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $upgradeSpots, $ModName, $mailDays;
  2257.  
  2258. if(!$ir['gang'])
  2259. {
  2260. echo "<table class='table' width='75%' style='text-align: center;'>
  2261. <th>You are not in a $ModName!</th>
  2262. <tr>
  2263. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  2264. </td>
  2265. </table><br /><br />";
  2266. exit();
  2267. }
  2268. else
  2269. {
  2270. if(!@$_GET['adder'] || !@$_GET['item'] || !@$_GET['entry'] || base64_decode(is_string(@$_GET['item'])) || base64_decode(is_string(@$_GET['adder'])) || base64_decode(is_string(@$_GET['entry'])))
  2271. {
  2272. echo "Invalid entry!<br />[<a href='?p=myFam'>Back</a>]";
  2273. exit($h->endpage());
  2274. }
  2275. $itemmax = $db->fetch_row($db->query("SELECT ID FROM `family_armory` WHERE `ID`=".base64_decode($_GET['entry']).""));
  2276. $maxP = $db->num_rows($db->query("SELECT `userid` FROM `users` WHERE `gang`={$ir['gang']} && `userid`=".base64_decode($_GET['adder']).""));
  2277. $inFam = $db->num_rows($db->query("SELECT `ID` FROM `family_armory` WHERE `Adder`=".base64_decode(@$_GET['adder'])." && `ItemID`=".base64_decode(@$_GET['item'])." && `ID`=".base64_decode(@$_GET['entry']).""));
  2278.  
  2279. if(base64_decode($_GET['item']) > $itemmax || $maxP === 0 || $inFam === 0)
  2280. {
  2281. echo "Invalid entry!<br />[<a href='?p=myFam'>Back</a>]";
  2282. exit($h->endpage());
  2283. }
  2284. if(base64_decode($_GET['adder']) == $userid)
  2285. {
  2286. echo "Would you like to take back your item?<br />
  2287. [<a href='?p=armoryTakeback&item={$_GET['item']}&entry={$_GET['entry']}'>Yes</a>]
  2288. <br />
  2289. [<a href='?p=myFam'>No</a>]";
  2290. exit($h->endpage());
  2291. }
  2292. else
  2293. {
  2294. $item = base64_decode($_GET['item']);
  2295. $adder = base64_decode($_GET['adder']);
  2296. $entry = base64_decode($_GET['entry']);
  2297.  
  2298. $i = $db->fetch_row($db->query("SELECT `itmname` FROM `items` WHERE `itmid`={$item}"));
  2299. $a = $db->fetch_row($db->query("SELECT `username` FROM `users` WHERE `userid`={$adder}"));
  2300. $info = $db->fetch_row($db->query("SELECT `RentTime` FROM `family_armory` WHERE `ItemID`={$item} && `ID`={$entry} && `Adder`={$adder}"));
  2301. echo "You have rented the {$i['itmname']} from your $ModName!, you have it for {$info['RentTime']} day(s) so please thank {$a['username']} for their contribution!";
  2302. item_add($userid, $item, 1, 0); //remove the ,0 (i added due to another modification i have)!
  2303. $db->query("INSERT INTO `family_armory_rent` VALUES ('null', $item, $userid, {$info['RentTime']})");
  2304. $db->query("DELETE FROM `family_armory` WHERE `ID`={$entry} && `FamID`={$ir['gang']}");
  2305. event_add($adder, "{$ir['username']} has rented your {$i['itmname']} for {$info['RentTime']} days, you will receive it back into your inventory once the time is up!");
  2306. }
  2307. }
  2308. }
  2309.  
  2310. function armoryTakeback()
  2311. {
  2312. global $cost, $startingPlaces, $userid, $db, $ir, $Pres_icon, $vPres_icon, $h, $upgradeSpots, $ModName, $mailDays;
  2313.  
  2314. if(!$ir['gang'])
  2315. {
  2316. echo "<table class='table' width='75%' style='text-align: center;'>
  2317. <th>You are not in a $ModName!</th>
  2318. <tr>
  2319. <td><i>Create a $ModName for just $".number_format($cost)." and have ".number_format($startingPlaces)." free $ModName spots avabliable!</i></th>
  2320. </td>
  2321. </table><br /><br />";
  2322. exit();
  2323. }
  2324. else
  2325. {
  2326. if(!$_GET['item'])
  2327. {
  2328. echo "Invalid item....<br />[<a href='?p=myFam'>Back</a>]";
  2329. exit($h->endpage());
  2330. }
  2331. $theirs = $db->num_rows($db->query("SELECT `ID` FROM `family_armory` WHERE `ID`='".base64_decode($_GET['entry'])."' && `FamID`={$ir['gang']}"));
  2332. if(!$theirs OR base64_decode(is_string($_GET['item'])) OR base64_decode(is_string($_GET['entry'])))
  2333. {
  2334. echo "This item is not yours to take back!<br /> [<a href='?p=myFam'>Back</a>]";
  2335. exit($h->endpage());
  2336. }
  2337. $item = base64_decode($_GET['item']);
  2338. $entry = base64_decode($_GET['entry']);
  2339. $I = $db->fetch_row($db->query("SELECT `itmname` FROM `items` WHERE `itmid`=".base64_decode($_GET['item']).""));
  2340. echo "You have taken back your {$I['itmname']}, thank you for your contribution to the $ModName!<br />[<a href='?p=myFam'>Back</a>]";
  2341. item_add($userid, $item, 1, 0); //remove the ,0 (i added due to another modification i have)!
  2342. $db->query("DELETE FROM `family_armory` WHERE `ID`={$entry} && `FamID`={$ir['gang']}");
  2343. exit($h->endpage());
  2344. }
  2345. }
  2346. $h->endpage();
  2347. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement