Advertisement
Guest User

Untitled

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