index.php 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630
  1. <?php
  2. // SSB - Simple Social Board
  3. // (C) Chris Dorman, 2012 - 2020
  4. // License: CC-BY-NC-SA version 3.0
  5. // http://github.com/Pentium44/SSB
  6. //// For development debug.
  7. //error_reporting(E_ALL);
  8. //ini_set('display_errors', 1);
  9. session_start();
  10. include "config.php";
  11. include "functions.php";
  12. include "bbcode.php";
  13. $loginCheck = checkLogin();
  14. // check if flatfile database location is populated
  15. if(!file_exists("ssb_db"))
  16. {
  17. mkdir("ssb_db", 0777);
  18. }
  19. if(!file_exists("ssb_db/users"))
  20. {
  21. mkdir("ssb_db/users", 0777);
  22. }
  23. if(!file_exists("ssb_db/posts"))
  24. {
  25. mkdir("ssb_db/posts", 0777);
  26. }
  27. if(!file_exists("ssb_db/uploads"))
  28. {
  29. mkdir("ssb_db/uploads", 0777);
  30. }
  31. if(!file_exists("ssb_db/friends"))
  32. {
  33. mkdir("ssb_db/friends", 0777);
  34. }
  35. $username = $_SESSION['ssb-user'];
  36. //$_SESSION['ssb-topic'] = $ssbtopic;
  37. ?>
  38. <!DOCTYPE html>
  39. <html lang="en-us">
  40. <head>
  41. <title><?php echo htmlentities(stripslashes($ssbtitle)); ?></title>
  42. <?php
  43. if($_GET['do']!="post" && $_GET['do']!="reply" && $_GET['do']!="react" && $_GET['do']!="avatarupload" && $_GET['do']!="delpost") {
  44. echo '<meta http-equiv="content-type" content="text/html; charset=utf-8">';
  45. }
  46. ?>
  47. <meta name="viewport" content="width=device-width, initial-scale=.55, shrink-to-fit=yes"><meta name="description" content="<?php echo htmlentities($ssbtitle) . " - " . $desc; ?>">
  48. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  49. <link rel="stylesheet" type="text/css" href="style.css">
  50. </head>
  51. <body <?php if($_GET['do']=="privmsg") { echo "onload=\"UpdateTimer();\""; } ?>>
  52. <div class="title"><?php echo $ssbtitle; ?></div>
  53. <div class="maincontain">
  54. <table id="containtable">
  55. <tr><td id="navcontainer">
  56. <div id="navbar">
  57. <?php if(isset($_SESSION['ssb-user']) && isset($_SESSION['ssb-pass'])) { ?>
  58. <a style="width:50px;" href="?forms=post" title="Post on your feed!">Make a post</a><br />
  59. <a style="width:50px;" href="?userfeed=<?php echo $username; ?>" title="Your profile!">Profile</a><br />
  60. <a href="index.php">Feed</a><br />
  61. <a href="?do=friends">Friends</a><br />
  62. <a href="?do=about">About</a><br />
  63. <a style="width:50px;" href="?do=users" title="Public users!">Public figures</a><br />
  64. <a style="width:50px;" href="?do=userctrl">Settings</a><br />
  65. <a style="width:50px;" href="?do=logout">Log out</a><br />
  66. <?php } else { ?>
  67. <a href="?forms=login">Login</a><br />
  68. <a href="?do=about">About</a><br />
  69. <?php } ?>
  70. </div>
  71. <?php
  72. if(($loginCheck == true) && $_GET['do']!="avatarlocation" && $_GET['do']!="reply" && $_GET['do']!="post" && $_GET['do']!="react" && $_GET['do']!="delpost") {
  73. // PM notifications
  74. $notifications = "ssb_db/friends/" . $username . ".notifications";
  75. $handle = fopen($notifications, "r");
  76. echo "<table class='notifications'><tr><td>Notifications: <a class='button' onclick=\"userClrNotifications();\">Clear</a></td></tr>";
  77. if ($handle) {
  78. while (($line = fgets($handle)) !== false) {
  79. echo "<tr><td><i class='fa fa-exclamation' aria-hidden='true'></i> " . $line . "</td></tr>";
  80. }
  81. fclose($handle);
  82. } else {
  83. echo "<tr><td>No notifications</td></tr>";
  84. }
  85. echo "</table></td><td class='contain'>";
  86. } else {
  87. echo "</td><td class='contain'>";
  88. }
  89. ?>
  90. <?php
  91. if(isset($_GET['forms']))
  92. {
  93. $forms = $_GET['forms'];
  94. $id = $_GET['pid'];
  95. if($forms=="register") {
  96. registerForm();
  97. }
  98. else if($forms=="login") {
  99. loginForm();
  100. }
  101. else if($forms=="friendreq") {
  102. if($loginCheck == true) {
  103. friendReqForm();
  104. } else {
  105. loginForm();
  106. }
  107. }
  108. else if($forms=="changepass") {
  109. if($loginCheck == true) {
  110. changePassForm();
  111. } else {
  112. loginForm();
  113. }
  114. }
  115. else if($forms=="deleteacct") {
  116. if($loginCheck == true) {
  117. deleteAcctForm();
  118. } else {
  119. loginForm();
  120. }
  121. }
  122. else if($forms=="avatarupload") {
  123. if($loginCheck == true) {
  124. uploadAvatarForm();
  125. } else {
  126. loginForm();
  127. }
  128. }
  129. else if($forms=="post") {
  130. if($loginCheck == true) {
  131. postForm();
  132. } else {
  133. loginForm();
  134. }
  135. }
  136. else if($forms=="clean") {
  137. if($loginCheck == true) {
  138. cleanForm();
  139. } else {
  140. loginForm();
  141. }
  142. }
  143. else {
  144. echo "ERROR: Unknown form-name<br>";
  145. }
  146. }
  147. else if(isset($_GET['notify']))
  148. {
  149. $notify = $_GET['notify'];
  150. if($notify=="1") { echo "Error: User not found"; }
  151. else if($notify=="2") { echo "Error: Incorrect password provided"; }
  152. else if($notify=="3") { echo "Error: Please fill out all the text boxes"; }
  153. else if($notify=="4") { echo "Error: The provided passwords did not match"; }
  154. else if($notify=="5") { echo "Error: Special characters cannot be used in your username"; }
  155. else if($notify=="6") { echo "Error: This username is already in use"; }
  156. else if($notify=="7") { echo "Error: Current password incorrect!"; }
  157. else if($notify=="8") { echo "Success! Current password changed!"; }
  158. else { echo "Error: unknown error... this is quite unusual..."; }
  159. }
  160. else if(isset($_GET['userfeed']))
  161. {
  162. $userid = $_GET['userfeed'];
  163. // Make sure we're friends or is my account.
  164. include "ssb_db/users/" . $userid . ".php";
  165. if ($accttype == "private") {
  166. if ($loginCheck == true) {
  167. $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count");
  168. include "ssb_db/friends/" . $username . ".php";
  169. for($x = 1; $x <= $friendcount; $x++)
  170. {
  171. // If private, and user is following. Allow
  172. if($userid == ${"friend" . $x}) {
  173. echo "<table><tr><td>";
  174. echo "<div class='avatar' style=\"background-image: url('index.php?do=avatarlocation&user=" . $userid . "');\" title='User Avatar'></div><br />";
  175. // DONE
  176. echo "</td><td>";
  177. echo "<h3>User information</h3>";
  178. echo "Username: " . $userid . "@" . $domain . "<br />";
  179. echo "Full name: " . $user_fullname . "<br />";
  180. echo "<h3>User posts</h3>";
  181. echo "</td></tr></table>";
  182. }
  183. }
  184. // Check if viewing your own profile
  185. if($userid == $username)
  186. {
  187. echo "<table><tr><td>";
  188. // Get user avatar if set
  189. echo "<div class='avatar' style=\"background-image: url('index.php?do=avatarlocation&user=" . $userid . "');\" title='User Avatar'></div><br />";
  190. // DONE
  191. echo "</td><td>";
  192. echo "<h3>User information</h3>";
  193. echo "Username: " . $userid . "@" . $domain . "<br />";
  194. echo "Full name: " . $user_fullname . "<br />";
  195. echo "<h3>User posts</h3>";
  196. echo "</td></tr></table>";
  197. }
  198. // Lets generate the users feed now.
  199. foreach(array_reverse(glob("ssb_db/posts/post_" . $userid . "_" . "*.php")) as $postfile) {
  200. //echo $postfile;
  201. unset($shared); // Keep clean variables
  202. include $postfile;
  203. for($x = 1; $x <= $friendcount; $x++)
  204. {
  205. if($postowner == ${"friend" . $x}) {
  206. echo "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate &nbsp;&nbsp;";
  207. if(file_exists("ssb_db/posts/$postid.reactcount")) {
  208. $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
  209. echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
  210. // Pull up users who reacted, and generate dropdown list.
  211. $reactlist = fopen("ssb_db/posts/$postid.reacted", "r");
  212. if($reactlist) {
  213. while (($reactor = fgets($reactlist)) !== false) {
  214. echo "<b>$reactor</b>";
  215. }
  216. fclose($reactlist);
  217. }
  218. echo "</div></div>";
  219. }
  220. if(isset($shared) && $shared == "1")
  221. {
  222. echo "<br />Originally posted by $origowner";
  223. }
  224. echo "</span></h3></td></tr></table>";
  225. echo "" . bbcode_format($postcontent) . "";
  226. // Footer
  227. echo "<div class='post-footer'>";
  228. echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i>&nbsp;React</a>";
  229. echo "<a style='padding-top: 6px;' href='index.php?view=$postid&user=$postowner' class='button'><i class='fa fa-comment'></i>&nbsp;Comment</a>";
  230. echo "<a style='padding-top: 6px;' href='index.php?do=share&pid=$postid&user=$postowner' class='button'><i class='fa fa-share'></i>&nbsp;Share</a>";
  231. echo "<br />"; // line break
  232. if(file_exists("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count")) {
  233. $postcount = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count");
  234. // If there's a reply, show them.
  235. if($postcount == 0) {
  236. echo "no replies";
  237. } else if($postcount == 1) {
  238. echo "$postcount reply";
  239. } else if ($postcount > 0) {
  240. echo "$postcount replies";
  241. }
  242. }
  243. echo " &bull; ";
  244. // Show reaction count in footer as well.
  245. if(file_exists("ssb_db/posts/" . $postid . ".reactcount")) {
  246. $reactcount = file_get_contents("ssb_db/posts/" . $postid . ".reactcount");
  247. if($reactcount == 1) {
  248. echo "$reactcount reaction";
  249. } else if ($reactcount > 0) {
  250. echo "$reactcount reactions";
  251. }
  252. } else {
  253. echo "no reactions";
  254. }
  255. echo "</div></div><br />\n";
  256. }
  257. }
  258. if($postowner == $username)
  259. {
  260. echo "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate &nbsp;&nbsp;";
  261. if(file_exists("ssb_db/posts/$postid.reactcount")) {
  262. $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
  263. echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
  264. // Pull up users who reacted, and generate dropdown list.
  265. $reactlist = fopen("ssb_db/posts/$postid.reacted", "r");
  266. if($reactlist) {
  267. while (($reactor = fgets($reactlist)) !== false) {
  268. echo "<b>$reactor</b>";
  269. }
  270. fclose($reactlist);
  271. }
  272. echo "</div></div>";
  273. }
  274. if(isset($shared) && $shared == "1")
  275. {
  276. echo "<br />Originally posted by $origowner";
  277. }
  278. echo "</span></h3></td></tr></table>";
  279. echo "" . bbcode_format($postcontent) . "";
  280. // Footer
  281. echo "<div class='post-footer'>";
  282. echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i>&nbsp;React</a>";
  283. echo "<a style='padding-top: 6px;' href='index.php?view=$postid&user=$postowner' class='button'><i class='fa fa-comment'></i>&nbsp;Comment</a>";
  284. echo "<a style='padding-top: 6px;' href='index.php?do=delpost&user=$username&pid=$postid' class='button'><i class='fa fa-trash-o'></i>&nbsp;Delete</a>";
  285. echo "<br />"; // line break
  286. if(file_exists("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count")) {
  287. $postcount = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count");
  288. // If there's a reply, show them.
  289. if($postcount == 0) {
  290. echo "no replies";
  291. } else if($postcount == 1) {
  292. echo "$postcount reply";
  293. } else if ($postcount > 0) {
  294. echo "$postcount replies";
  295. }
  296. }
  297. echo " &bull; ";
  298. // Show reaction count in footer as well.
  299. if(file_exists("ssb_db/posts/" . $postid . ".reactcount")) {
  300. $reactcount = file_get_contents("ssb_db/posts/" . $postid . ".reactcount");
  301. if($reactcount == 1) {
  302. echo "$reactcount reaction";
  303. } else if ($reactcount > 0) {
  304. echo "$reactcount reactions";
  305. }
  306. } else {
  307. echo "no reactions";
  308. }
  309. echo "</div></div><br />\n";
  310. }
  311. }
  312. echo "<!-- Gen done...-->";
  313. }
  314. }
  315. else
  316. {
  317. echo "<h3>User information</h3>";
  318. echo "<table><tr><td>";
  319. echo "<div class='avatar' style=\"background-image: url('index.php?do=avatarlocation&user=$userid');\" title='User Avatar'></div>";
  320. // DONE
  321. echo "</td><td>";
  322. // If not friend, allow to send friend request from right here!
  323. $friend = 0;
  324. $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count");
  325. include "ssb_db/friends/" . $username . ".php";
  326. for($x = 1; $x <= $friendcount; $x++)
  327. {
  328. // If private, and user is following. Allow
  329. if($userid == ${"friend" . $x}) {
  330. $friend = 1;
  331. }
  332. }
  333. if($friend!=1) {
  334. echo "<a class='button' href='index.php?do=sendfr&user=$userid'>Send friend request</a><br /><br />";
  335. }
  336. echo "Username: " . $userid . "@" . $domain . "<br />";
  337. echo "Full name: " . $user_fullname;
  338. echo "</td></tr></table>";
  339. foreach(array_reverse(glob("ssb_db/posts/post_" . $userid . "_" . "*.php")) as $postfile) {
  340. include $postfile;
  341. unset($shared);
  342. echo "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate &nbsp;&nbsp;";
  343. if(file_exists("ssb_db/posts/$postid.reactcount")) {
  344. $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
  345. echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
  346. // Pull up users who reacted, and generate dropdown list.
  347. $reactlist = fopen("ssb_db/posts/$postid.reacted", "r");
  348. if($reactlist) {
  349. while (($reactor = fgets($reactlist)) !== false) {
  350. echo "<b>$reactor</b>";
  351. }
  352. fclose($reactlist);
  353. }
  354. echo "</div></div>";
  355. }
  356. if(isset($shared) && $shared == "1")
  357. {
  358. echo "<br />Originally posted by $origowner";
  359. }
  360. echo "</span></h3></td></tr></table>";
  361. echo "" . bbcode_format($postcontent) . "";
  362. // Footer
  363. echo "<div class='post-footer'>";
  364. echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i>&nbsp;React</a>";
  365. echo "<a style='padding-top: 6px;' href='index.php?view=$postid&user=$postowner' class='button'><i class='fa fa-comment'></i>&nbsp;Comment</a>";
  366. echo "<a style='padding-top: 6px;' href='index.php?do=share&pid=$postid&user=$postowner' class='button'><i class='fa fa-share'></i>&nbsp;Share</a>";
  367. echo "<br />"; // line break
  368. if(file_exists("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count")) {
  369. $postcount = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count");
  370. // If there's a reply, show them.
  371. if($postcount == 0) {
  372. echo "no replies";
  373. } else if($postcount == 1) {
  374. echo "$postcount reply";
  375. } else if ($postcount > 0) {
  376. echo "$postcount replies";
  377. }
  378. }
  379. echo " &bull; ";
  380. // Show reaction count in footer as well.
  381. if(file_exists("ssb_db/posts/" . $postid . ".reactcount")) {
  382. $reactcount = file_get_contents("ssb_db/posts/" . $postid . ".reactcount");
  383. if($reactcount == 1) {
  384. echo "$reactcount reaction";
  385. } else if ($reactcount > 0) {
  386. echo "$reactcount reactions";
  387. }
  388. } else {
  389. echo "no reactions";
  390. }
  391. echo "</div></div><br />\n";
  392. }
  393. echo "<!-- Gen done...-->";
  394. }
  395. }
  396. else if(isset($_GET['view']) && isset($_GET['user']))
  397. {
  398. $puser = $_GET['user'];
  399. $id = $_GET['view'];
  400. $postc = file_get_contents("ssb_db/posts/reply_" . $puser . "_" . $id . ".count");
  401. include "ssb_db/posts/post_" . $puser . "_" . $id . ".php";
  402. echo "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate &nbsp;&nbsp;";
  403. if(file_exists("ssb_db/posts/$postid.reactcount")) {
  404. $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
  405. echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
  406. // Pull up users who reacted, and generate dropdown list.
  407. $reactlist = fopen("ssb_db/posts/$postid.reacted", "r");
  408. if($reactlist) {
  409. while (($reactor = fgets($reactlist)) !== false) {
  410. echo "<b>$reactor</b>";
  411. }
  412. fclose($reactlist);
  413. }
  414. echo "</div></div>";
  415. }
  416. if(isset($shared) && $shared == "1")
  417. {
  418. echo "<br />Originally posted by $origowner";
  419. }
  420. echo "</span></h3></td></tr></table>";
  421. echo "" . bbcode_format($postcontent) . "";
  422. // Footer
  423. echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i>&nbsp;React</a>";
  424. echo "<a style='padding-top: 6px;' href='index.php?do=share&pid=$postid&user=$postowner' class='button'><i class='fa fa-share'></i>&nbsp;Share</a>";
  425. echo "</div><br />\n";
  426. for($x = 1; $x <= $postc; $x++) {
  427. $reply_content = ${"reply" . $x};
  428. $reply_user = ${"reply" . $x . "_user"};
  429. $reply_date = ${"reply" . $x . "_date"};
  430. echo "<div class='reply'>";
  431. echo "<table><tr><td><div class='avatar_small' style='background-image: url(\"index.php?do=avatarlocation&user=$reply_user\");' title='User Avatar'></div></td><td><h4>$reply_user <a onclick=\"userTag('$reply_user');\"><i class='fa fa-tag'></i></a> <span style='font-size: 8px; padding-left: 6px; color: #808080;'>$reply_date</span></h4></td></tr></table>";
  432. echo "<div class='reply_content'>" . bbcode_format($reply_content) . "</div>";
  433. echo "</div>\n";
  434. }
  435. echo "<br />";
  436. if ($loginCheck != true) {
  437. echo "Login to reply...";
  438. } else {
  439. $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count");
  440. include "ssb_db/friends/" . $username . ".php";
  441. for($x = 1; $x <= $friendcount; $x++)
  442. {
  443. if($puser == ${"friend" . $x}) {
  444. $z = "1";
  445. replyForm($id, $puser);
  446. }
  447. }
  448. // Its you dummy
  449. if($puser == $username) {
  450. $z = "1";
  451. replyForm($id, $puser);
  452. }
  453. if(!isset($z))
  454. {
  455. echo "Not following! Follow to reply...<br />";
  456. }
  457. }
  458. }
  459. else if(isset($_GET['do']))
  460. {
  461. $do = $_GET['do'];
  462. if($do=="post")
  463. {
  464. if ($loginCheck != true) { loginForm(); } else {
  465. $date = date("YmdHis"); // timestamp in year, month, date, hour, minute, and second.
  466. $titledate = date("m-d-Y h:i:sa"); // time stamp for people to read xD
  467. if(isset($_FILES["file"]["name"]) && isset($username)) {
  468. $uploaded = array(); // empty array for upload file names
  469. $uploaded_name = array(); // empty array for upload names
  470. // File selected, upload!
  471. for($i=0; $i<count($_FILES["file"]["name"]); $i++)
  472. {
  473. $allowedExts = array("gif", "jpeg", "jpg", "png", "bmp", "ico", "GIF", "JPEG", "JPG", "PNG", "BMP", "ICO", "mp4", "MP4");
  474. $temp = explode(".", $_FILES["file"]["name"][$i]);
  475. $extension = end($temp);
  476. if ((($_FILES["file"]["type"][$i] == "image/gif")
  477. || ($_FILES["file"]["type"][$i] == "image/x-gif")
  478. || ($_FILES["file"]["type"][$i] == "image/jpeg")
  479. || ($_FILES["file"]["type"][$i] == "image/x-jpeg")
  480. || ($_FILES["file"]["type"][$i] == "image/x-jpg")
  481. || ($_FILES["file"]["type"][$i] == "image/jpg")
  482. || ($_FILES["file"]["type"][$i] == "image/pjpeg")
  483. || ($_FILES["file"]["type"][$i] == "image/x-png")
  484. || ($_FILES["file"]["type"][$i] == "image/bmp")
  485. || ($_FILES["file"]["type"][$i] == "image/x-icon")
  486. || ($_FILES["file"]["type"][$i] == "application/octet-stream")
  487. || ($_FILES["file"]["type"][$i] == "video/mp4")
  488. // || ($_FILES["file"]["type"][$i] == "video/ogg")
  489. // || ($_FILES["file"]["type"][$i] == "video/webm")
  490. // || ($_FILES["file"]["type"][$i] == "video/x-flv")
  491. // || ($_FILES["file"]["type"][$i] == "video/mp4v-es")
  492. || ($_FILES["file"]["type"][$i] == "image/png")
  493. || ($_FILES["file"]["type"][$i] == ""))
  494. && ($_FILES["file"]["size"][$i] < $user_max_upload)
  495. && in_array($extension, $allowedExts))
  496. {
  497. if ($_FILES["file"]["error"][$i] > 0)
  498. {
  499. echo $_FILES["file"]["name"][$i] . " - Return Code: " . $_FILES["file"]["error"][$i] . "<br />";
  500. }
  501. else
  502. {
  503. if(file_exists("ssb_db/uploads/" . $_FILES["file"]["name"][$i]))
  504. {
  505. echo "Error: " . $_FILES["file"]["name"][$i] . " exists.<br />";
  506. }
  507. else
  508. {
  509. $randstring = getRandString("32");
  510. move_uploaded_file($_FILES["file"]["tmp_name"][$i],
  511. "ssb_db/uploads/" . $randstring . "." . $extension);
  512. array_push($uploaded, $randstring . "." . $extension);
  513. array_push($uploaded_name, pathinfo($_FILES["file"]["name"][$i], PATHINFO_FILENAME));
  514. echo "Success: " . $_FILES["file"]["name"][$i] . " (" . tomb($_FILES["file"]["size"][$i]) . ") uploaded...<br />";
  515. //rename("ssb_db/uploads/" . $FILES["file"]["name"][$i], "ssb_db/uploads/" . $username . "_" . $date . $extension);
  516. }
  517. }
  518. }
  519. else
  520. {
  521. // Check if there was actually an issue
  522. if($_FILES["file"]["size"] == "0") {
  523. echo "Error: " . $_FILES["file"]["name"][$i] . " is too large, or is a invalid filetype";
  524. }
  525. }
  526. } // end of for loop
  527. $srchcont = stripslashes(htmlentities($_POST['body']));
  528. $srchcont .= " "; // doesn't find tag if there's not a fucking whitespace
  529. $checkForUserTag = searchForUserTag($srchcont);
  530. $taggedUser = substr($checkForUserTag, 1, -1);
  531. if(file_exists("ssb_db/users/" . $taggedUser . ".name")) {
  532. if($taggedUser!=$postowner) {
  533. $tagged_notifications = file_get_contents("ssb_db/friends/" . $taggedUser . ".notifications");
  534. file_put_contents("ssb_db/friends/" . $taggedUser . ".notifications", "<b>$username</b> <a href='index.php?view=$date&user=$username'>tagged you in a post</a>\n" . $tagged_notifications);
  535. }
  536. }
  537. $body = nl2br(htmlentities(stripcslashes($_POST['body'])));
  538. //$username = stripcslashes(htmlentities($username));
  539. include "ssb_db/users/" . $username . ".php";
  540. $post_file = "ssb_db/posts/post_" . $username . "_" . $date . ".php";
  541. $post_attachments = "<br />";
  542. $post_string = "<?php\n\$postowner = \"" . $username . "\";\$postid=\"" . $date . "\";\$postdate=\"" . $titledate . "\";\$postcontent = \"" . $body . "<br />";
  543. $attachments = array();
  544. $fileCount = 0;
  545. foreach($uploaded as &$upload)
  546. {
  547. if(file_exists("ssb_db/uploads/" . $upload)) {
  548. $ext = pathinfo("ssb_db/uploads/ . $upload", PATHINFO_EXTENSION);
  549. if($ext == "mp4" || $ext == "MP4") {
  550. array_push($attachments, "<div class='attachment'>" . $uploaded_name[$fileCount] . "<video width='560' height='315' controls><source src='ssb_db/uploads/$upload' type='video/mp4'>HTML5 video not supported :(</video></div>");
  551. }
  552. else
  553. {
  554. array_push($attachments, "<div class='attachment'><a href='ssb_db/uploads/" . $upload . "'><img src='ssb_db/uploads/" . $upload . "'></a></div>");
  555. }
  556. }
  557. $fileCount++; // Add it up
  558. }
  559. foreach($attachments as &$attachvar)
  560. {
  561. $post_attachments .= $attachvar;
  562. }
  563. $post_string_end = "\";\n?>\n";
  564. file_put_contents($post_file, $post_string . $post_attachments . $post_string_end);
  565. file_put_contents("ssb_db/posts/" . $date . ".post", "post_" . $username . "_" . $date . ".php");
  566. file_put_contents("ssb_db/posts/reply_" . $username . "_" . $date . ".count", "0");
  567. echo "Post processed... if redirection fails, <a href=\"?view=$date&user=$username\">Click Here</a><br />";
  568. header("Location: index.php?view=$date&user=$username");
  569. }
  570. else
  571. {
  572. echo "ERROR: Missing post data! Select an image to upload or let us know whats up!<br />";
  573. }
  574. }
  575. }
  576. if($do=="avatarupload")
  577. {
  578. if(isset($_FILES["file"]["name"]) && ($loginCheck == true)) {
  579. $date = date("YmdHis"); // timestamp in year, month, date, hour, minute, and second.
  580. for($i=0; $i<count($_FILES["file"]["name"]); $i++)
  581. {
  582. $allowedExts = array("gif", "jpeg", "jpg", "png", "bmp", "ico", "png");
  583. $temp = explode(".", $_FILES["file"]["name"][$i]);
  584. $extension = end($temp);
  585. if ((($_FILES["file"]["type"][$i] == "image/gif")
  586. || ($_FILES["file"]["type"][$i] == "image/x-gif")
  587. || ($_FILES["file"]["type"][$i] == "image/jpeg")
  588. || ($_FILES["file"]["type"][$i] == "image/x-jpeg")
  589. || ($_FILES["file"]["type"][$i] == "image/x-jpg")
  590. || ($_FILES["file"]["type"][$i] == "image/jpg")
  591. || ($_FILES["file"]["type"][$i] == "image/pjpeg")
  592. || ($_FILES["file"]["type"][$i] == "image/x-png")
  593. || ($_FILES["file"]["type"][$i] == "image/bmp")
  594. || ($_FILES["file"]["type"][$i] == "image/x-icon")
  595. || ($_FILES["file"]["type"][$i] == "image/png")
  596. || ($_FILES["file"]["type"][$i] == ""))
  597. && ($_FILES["file"]["size"][$i] < $user_max_upload)
  598. && in_array($extension, $allowedExts))
  599. {
  600. if ($_FILES["file"]["error"][$i] > 0)
  601. {
  602. echo $_FILES["file"]["name"][$i] . " - Return Code: " . $_FILES["file"]["error"][$i] . "<br>";
  603. }
  604. else
  605. {
  606. if(file_exists("ssb_db/uploads/" . $_FILES["file"]["name"][$i]))
  607. {
  608. echo "Error: " . $_FILES["file"]["name"][$i] . " exists.<br>";
  609. }
  610. else
  611. {
  612. move_uploaded_file($_FILES["file"]["tmp_name"][$i],
  613. "ssb_db/uploads/" . $username . "_" . $date . "." . $extension);
  614. $oldcontent = file_get_contents("ssb_db/users/" . $username . ".php");
  615. file_put_contents("ssb_db/users/" . $username . ".php", $oldcontent . "<?php \$user_avatar = \"" . $username . "_" . $date . "." . $extension . "\"; ?>\n");
  616. echo "Avatar uploaded and set! <a href='index.php'>Redirecting</a> in 3 seconds...";
  617. header("refresh: 3;url=index.php");
  618. }
  619. }
  620. } else {
  621. echo "Error: " . $_FILES["file"]["name"][$i] . " is too large, or is a invalid filetype";
  622. }
  623. }
  624. }
  625. }
  626. if($do=="reply")
  627. {
  628. if ($loginCheck != true) { loginForm(); } else {
  629. if(!isset($_GET['pid']) or !file_exists("ssb_db/posts/" . $_GET['pid'] . ".post")) { echo "ERROR: Post ID is not set, or invalid"; } else {
  630. if(isset($_POST['reply']) && isset($username) && $_POST['body']!="")
  631. {
  632. $pid = $_GET['pid'];
  633. $post_file_name = file_get_contents("ssb_db/posts/$pid.post");
  634. include "ssb_db/posts/" . $post_file_name;
  635. $srchcont = stripslashes(htmlentities($_POST['body']));
  636. $srchcont .= " ";
  637. $checkForUserTag = searchForUserTag($srchcont);
  638. $taggedUser = substr($checkForUserTag, 1, -1);
  639. if(file_exists("ssb_db/users/" . $taggedUser . ".name")) {
  640. if($taggedUser!=$postowner) {
  641. $tagged_notifications = file_get_contents("ssb_db/friends/" . $taggedUser . ".notifications");
  642. file_put_contents("ssb_db/friends/" . $taggedUser . ".notifications", "<b>$username</b> <a href='index.php?view=$pid&user=$postowner'>tagged you in a comment</a>\n" . $tagged_notifications);
  643. }
  644. }
  645. $replydate = date("m-d-Y h:i:sa"); // time stamp for people to read xD
  646. $body = nl2br(htmlentities(stripcslashes($_POST['body'])));
  647. //$username = stripcslashes(htmlentities($username));
  648. $old_content = file_get_contents("ssb_db/posts/" . $post_file_name);
  649. $reply_count = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $pid . ".count");
  650. $reply_count = $reply_count+1;
  651. $post_string = "<?php \n\$reply" . $reply_count . " = \"" . $body . "\";\$reply" . $reply_count . "_user = \"" . $username . "\"; \$reply" . $reply_count . "_date = \"" . $replydate . "\";\n?>\n";
  652. file_put_contents("ssb_db/posts/" . $post_file_name, $old_content . $post_string);
  653. file_put_contents("ssb_db/posts/reply_" . $postowner . "_" . $pid . ".count", $reply_count);
  654. if($username!=$postowner) {
  655. $owner_notifications = file_get_contents("ssb_db/friends/" . $postowner . ".notifications");
  656. file_put_contents("ssb_db/friends/" . $postowner . ".notifications", "<b>$username</b> <a href='index.php?view=$pid&user=$postowner'>replied to your post</a>\n" . $owner_notifications);
  657. }
  658. echo "If you're seeing this; redirection failed: <a href=\"?view=$pid&user=$postowner\">Click Here</a><br>";
  659. header("Location:index.php?view=$pid&user=$postowner");
  660. }
  661. else
  662. {
  663. echo "ERROR: Missing form data<br>";
  664. }
  665. }
  666. }
  667. }
  668. if($do=="delpost")
  669. {
  670. if ($loginCheck != true) { loginForm(); } else {
  671. if(isset($_GET['user']) && $_GET['user']!="" && isset($_GET['pid']) && $_GET['pid']!="") {
  672. if(file_exists("ssb_db/posts/post_" . stripslashes($_GET['user']) . "_" . stripslashes($_GET['pid']) . ".php") && $username == stripslashes($_GET['user'])) {
  673. $postuser = $_GET['user'];
  674. $pid = $_GET['pid'];
  675. unlink("ssb_db/posts/" . $pid . ".post");
  676. unlink("ssb_db/posts/post_" . $postuser . "_" . $pid . ".php");
  677. unlink("ssb_db/posts/reply_" . $postuser . "_" . $pid . ".count");
  678. flush();
  679. header("refresh: 0;url=index.php");
  680. exit;
  681. } else { echo "ERROR: post doesn't exist or YOU ARE NOT THE OWNER OF SAID POST... THIS incident has been recorded!"; file_put_contents("ssb_db/log.txt", "Post deletion error: IP <" . $_SERVER['REMOTE_ADDR'] . "> post not found or not users post: post_" . $postuser . "_" . $pid . ".php\n"); }
  682. } else { echo "ERROR: USER and PID variables not set!"; }
  683. }
  684. }
  685. if($do=="share")
  686. {
  687. if ($loginCheck != true) { loginForm(); } else {
  688. if(isset($_GET['user']) && $_GET['user']!="" && isset($_GET['pid']) && $_GET['pid']!="") {
  689. if(file_exists("ssb_db/posts/post_" . stripslashes($_GET['user']) . "_" . stripslashes($_GET['pid']) . ".php")) {
  690. $postuser = stripslashes($_GET['user']);
  691. $pid = stripslashes($_GET['pid']);
  692. $date = date("YmdHis"); // timestamp in year, month, date, hour, minute, and second.
  693. $titledate = date("m-d-Y h:i:sa"); // time stamp for people to read xD
  694. include("ssb_db/friends/" . $username . ".php");
  695. include("ssb_db/posts/post_" . $postuser . "_" . $pid . ".php");
  696. if($accttype == "public") {
  697. $post_file = "ssb_db/posts/post_" . $username . "_" . $date . ".php";
  698. $post_attachments = "<br />";
  699. $post_string = "<?php\n\$postowner = \"" . $username . "\";\$postid=\"" . $date . "\";\$postdate=\"" . $titledate . "\";\$shared = \"1\";\$origowner = \"" . $postowner . "\";\$postcontent = \"" . $postcontent;
  700. $post_string_end = "\";\n?>\n";
  701. $notification = file_get_contents("ssb_db/friends/" . $postuser . ".notifications");
  702. file_put_contents("ssb_db/friends/" . $postuser . ".notifications", "<b>$username</b> <a href='index.php?view=$date&user=$username'>shared your post</a>\n" . $notification);
  703. file_put_contents($post_file, $post_string . $post_attachments . $post_string_end);
  704. file_put_contents("ssb_db/posts/" . $date . ".post", "post_" . $username . "_" . $date . ".php");
  705. file_put_contents("ssb_db/posts/reply_" . $username . "_" . $date . ".count", "0");
  706. flush();
  707. header("refresh: 0;url=index.php");
  708. exit;
  709. } else {
  710. $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count");
  711. for($x = 1; $x <= $friendcount; $x++)
  712. {
  713. if($postowner == ${"friend" . $x}) {
  714. $foundfriend = 1;
  715. $post_file = "ssb_db/posts/post_" . $username . "_" . $date . ".php";
  716. $post_attachments = "<br />";
  717. $post_string = "<?php\n\$postowner = \"" . $username . "\";\$postid=\"" . $date . "\";\$postdate=\"" . $titledate . "\";\$shared = \"1\";\$origowner = \"" . $postowner . "\";\$postcontent = \"" . $postcontent;
  718. $post_string_end = "\";\n?>\n";
  719. $notification = file_get_contents("ssb_db/friends/" . $postuser . ".notifications");
  720. file_put_contents("ssb_db/friends/" . $postuser . ".notifications", "<b>$username</b> <a href='index.php?view=$date&user=$username'>shared your post</a>\n" . $notification);
  721. file_put_contents($post_file, $post_string . $post_attachments . $post_string_end);
  722. file_put_contents("ssb_db/posts/" . $date . ".post", "post_" . $username . "_" . $date . ".php");
  723. file_put_contents("ssb_db/posts/reply_" . $username . "_" . $date . ".count", "0");
  724. flush();
  725. header("refresh: 0;url=index.php");
  726. exit;
  727. }
  728. }
  729. }
  730. } else { echo "ERROR: post doesn't exist or YOU ARE NOT THE OWNER OF SAID POST... THIS incident has been recorded!"; file_put_contents("ssb_db/log.txt", "Post deletion error: IP <" . $_SERVER['REMOTE_ADDR'] . "> post not found or not users post: post_" . $postuser . "_" . $pid . ".php\n"); }
  731. } else { echo "ERROR: USER and PID variables not set!"; }
  732. }
  733. }
  734. if($do=="react")
  735. {
  736. if ($loginCheck != true) { loginForm(); } else {
  737. if(isset($_GET['user']) && $_GET['user']!="" && isset($_GET['pid']) && $_GET['pid']!="") {
  738. if(file_exists("ssb_db/posts/post_" . stripslashes($_GET['user']) . "_" . stripslashes($_GET['pid']) . ".php")) {
  739. $postuser = $_GET['user'];
  740. $pid = $_GET['pid'];
  741. $handle = fopen("ssb_db/posts/$pid.reacted", "r");
  742. if ($handle) {
  743. while (($line = fgets($handle)) !== false) {
  744. $line = str_replace(array("\n", "\r"), '', $line);
  745. if($line == $username) {
  746. echo "You've already reacted to this post... <a href='index.php?view=$pid&user=$postuser'>redirecting</a>";
  747. header("refresh: 3;url=index.php?view=$pid&user=$postuser");
  748. exit;
  749. }
  750. }
  751. fclose($handle);
  752. } else {
  753. echo "<!-- Haven't reacted, continuing -->";
  754. }
  755. if(file_exists("ssb_db/posts/$pid.reacted")) {
  756. $reactedPrev = file_get_contents("ssb_db/posts/$pid.reacted");
  757. file_put_contents("ssb_db/posts/$pid.reacted", $reactedPrev . $username . "\n"); // You reacted
  758. } else {
  759. file_put_contents("ssb_db/posts/$pid.reacted", $username . "\n"); // First react
  760. }
  761. if(file_exists("ssb_db/posts/$pid.reactcount")) {
  762. $reactCount = file_get_contents("ssb_db/posts/$pid.reactcount");
  763. $reactCurrent = $reactCount + 1;
  764. file_put_contents("ssb_db/posts/$pid.reactcount", $reactCurrent); // You reacted
  765. } else {
  766. file_put_contents("ssb_db/posts/$pid.reactcount", "1"); // First react
  767. }
  768. // Don't send yourself a notification, you know you liked your own post ;)
  769. if($postuser != $username) {
  770. $owner_notifications = file_get_contents("ssb_db/friends/" . $postuser . ".notifications");
  771. file_put_contents("ssb_db/friends/" . $postuser . ".notifications", "<b>$username</b> loved your <a href='index.php?view=$pid&user=$postuser'>post</a>\n" . $owner_notifications);
  772. }
  773. echo "Reacted! <a href='index.php'>Redirecting</a> in 1 second...";
  774. header("Location:index.php");
  775. exit;
  776. } else { echo "ERROR: post doesn't exist..."; }
  777. } else { echo "ERROR: USER and PID variables not set!"; }
  778. }
  779. }
  780. if($do=="clrnote")
  781. {
  782. if ($loginCheck != true) { loginForm(); } else {
  783. unlink("ssb_db/friends/" . $username . ".notifications");
  784. header("Location: index.php");
  785. exit;
  786. }
  787. }
  788. if($do=="clrpending")
  789. {
  790. if ($loginCheck != true) { loginForm(); } else {
  791. unlink("ssb_db/friends/" . $username . ".pending");
  792. header("Location: index.php?do=friends");
  793. exit;
  794. }
  795. }
  796. // Server admin can just delete ssb_db
  797. /*if($do=="clean")
  798. {
  799. if($_POST['password']!="" && $_POST['password']==$pw)
  800. {
  801. $db_content = glob("ssb_db/" . '*', GLOB_MARK);
  802. foreach($db_content as $file)
  803. {
  804. unlink($file);
  805. }
  806. rmdir("ssb_db");
  807. echo "Database Cleaned<br>";
  808. }
  809. else
  810. {
  811. echo "ERROR: Wrong Password<br>";
  812. }
  813. }*/
  814. // grab session values and send friend request functions.
  815. if($do=="sendfr") {
  816. if ($loginCheck != true) { loginForm(); } else {
  817. if(isset($_POST['user']) || isset($_GET['user'])) {
  818. //check if user exists first lol
  819. if(isset($_POST['user'])) {
  820. $givenUser = htmlentities(stripcslashes($_POST['user']));
  821. } else {
  822. $givenUser = htmlentities(stripcslashes($_GET['user']));
  823. }
  824. //check if user exists first lol
  825. if(file_exists("ssb_db/users/" . $givenUser . ".php")) {
  826. include "ssb_db/users/" . $givenUser . ".php";
  827. if($accttype == "private") {
  828. sendFriendRequest($_SESSION['ssb-user'], $givenUser);
  829. echo "Follow request sent to " . $givenUser . " <a href='?do=friends'>redirecting</a> in 3 seconds";
  830. header("refresh: 3;url=?do=friends");
  831. } else if($accttype == "public") {
  832. acceptPublicFriendRequest($username, $givenUser);
  833. header("Location: ?do=friends");
  834. } else {
  835. echo "ERROR: Issues parsing account type...";
  836. }
  837. } else {
  838. echo "Error: Provided username does not exist in the database!";
  839. }
  840. } else {
  841. echo "Error: users not set in GET value...";
  842. }
  843. }
  844. }
  845. if($do=="accfr")
  846. {
  847. if ($loginCheck != true) { loginForm(); } else {
  848. if(isset($_GET['user']) && isset($_GET['friend'])) {
  849. acceptFriendRequest(stripslashes($_GET['user']), stripslashes($_GET['friend']));
  850. echo "Accepted friend request from " . htmlentities(stripslashes($_GET['friend'])) . " <a href='?do=friends'>redirecting</a> in 3 seconds";
  851. header("refresh: 3;url=?do=friends");
  852. } else {
  853. echo "Error: users not set in GET &amp; SESSION value...";
  854. }
  855. }
  856. }
  857. if($do=="userctrl")
  858. {
  859. if ($loginCheck != true) { loginForm(); } else {
  860. // Beginning of user control panel
  861. echo "<h3>User control panel</h3>";
  862. echo "<a class='button' href='?forms=changepass'>Change password</a><br />";
  863. echo "<a class='button' href='?forms=avatarupload'>Upload avatar</a><br />";
  864. }
  865. }
  866. if($do=="changepass")
  867. {
  868. if ($loginCheck != true) { loginForm(); } else {
  869. // Beginning password change
  870. // inputs
  871. $oldPassInput = htmlentities(stripslashes($_POST['oldpass']));
  872. $newPassInput = htmlentities(stripslashes($_POST['password']));
  873. $passwordAgainInput = htmlentities(stripslashes($_POST['password_again']));
  874. include "ssb_db/users/" . $username . ".php";
  875. if(sha1(md5($oldPassInput)) == $user_password) {
  876. if($newPassInput == $passwordAgainInput) {
  877. $oldcontent = file_get_contents("ssb_db/users/" . $username . ".php");
  878. $passString = "<?php \$user_password = \"" . sha1(md5($newPassInput)) . "\"; ?>\n";
  879. file_put_contents("ssb_db/users/" . $username . ".php", $oldcontent . $passString);
  880. echo "Password changed, <a href='index.php'>redirecting</a> in 3 seconds";
  881. $_SESSION['ssb-user'] = null;
  882. $_SESSION['ssb-pass'] = null;
  883. header("refresh: 3;url=index.php");
  884. }
  885. } else { echo "ERROR: password incorrect! IP recorded for constant monitoring of possible bots!"; file_put_contents("ssb_db/log.txt", "PASS MISMATCH: IP <" . $_SERVER['REMOTE_ADDR'] . "> Cookie spoofing detected from remote client!!!\n"); }
  886. }
  887. }
  888. if($do=="privmsg")
  889. {
  890. if ($loginCheck != true) { loginForm(); } else {
  891. //check if friend is set
  892. if(!isset($_GET['friend'])) { echo "ERROR: No username defined!"; exit(1); } else {
  893. // set friend username
  894. $friendNick = htmlentities(stripslashes($_GET['friend']));
  895. $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count");
  896. include "ssb_db/friends/" . $username . ".php";
  897. for($x = 1; $x <= $friendcount; $x++)
  898. {
  899. if($friendNick == ${"friend" . $x}) {
  900. ?>
  901. <script language="javascript" type="text/javascript">
  902. <!--
  903. var httpObject = null;
  904. var link = "";
  905. var timerID = 0;
  906. var friendNick = "<?php echo $friendNick; ?>";
  907. var nickName = "<?php echo $_SESSION['ssb-user']; ?>";
  908. var userColor = "<?php echo $_SESSION['ssb-color'];; ?>";
  909. // Change the value of the outputText field
  910. function setHtml() {
  911. if(ajaxVar.readyState == 4){
  912. var response = ajaxVar.responseText;
  913. var msgBox = document.getElementById("msgs");
  914. msgBox.innerHTML += response;
  915. msgBox.scrollTop = msgBox.scrollHeight;
  916. }
  917. }
  918. // Change the value of the outputText field
  919. function setAll() {
  920. if(ajaxVar.readyState == 4){
  921. var response = ajaxVar.responseText;
  922. var msgBox = document.getElementById("msgs");
  923. msgBox.innerHTML = response;
  924. msgBox.scrollTop = msgBox.scrollHeight;
  925. }
  926. }
  927. // Implement business logic
  928. function serverWrite() {
  929. ajaxVar = getHTTPObject();
  930. if (ajaxVar != null) {
  931. link = "chatserver.php?nick="+nickName+"&friend="+friendNick+"&msg="+document.getElementById('msg').value;
  932. ajaxVar.open("GET", link , true);
  933. ajaxVar.onreadystatechange = setHtml;
  934. ajaxVar.send(null);
  935. }
  936. }
  937. function getInput() {
  938. // Send the server function the input
  939. var userInput = document.getElementById('msg');
  940. serverWrite(userInput.value);
  941. // Clean out the input values
  942. var msgBar = document.getElementById("msg");
  943. msgBar.value = "";
  944. msgBar.focus();
  945. }
  946. // Implement business logic
  947. function serverReload() {
  948. ajaxVar = getHTTPObject();
  949. //var randomnumber=Math.floor(Math.random()*10000);
  950. if (ajaxVar != null) {
  951. link = "chatserver.php?get=<?php echo $friendNick; ?>";
  952. ajaxVar.open("GET", link , true);
  953. ajaxVar.onreadystatechange = setAll;
  954. ajaxVar.send(null);
  955. }
  956. }
  957. function UpdateTimer() {
  958. serverReload();
  959. setTimeout(UpdateTimer, 1000);
  960. }
  961. function keypressed(e) {
  962. if(e.keyCode=='13'){
  963. getInput();
  964. }
  965. }
  966. //-->
  967. </script>
  968. <div class="replycontain">
  969. <?php
  970. // Header
  971. include "ssb_db/users/" . $friendNick . ".php";
  972. echo "<h3><a href='?userfeed=" . $friendNick . "'>" . $friendNick . ": " . $user_fullname . "</a></h3>";
  973. ?>
  974. <div id="msgs">
  975. <?php
  976. echo "<div class=\"msgbox\">";
  977. echo "</div>";
  978. ?>
  979. </div>
  980. <div id="msgbox" onkeyup="keypressed(event);">
  981. <button onclick="javascript:wrapBBCode('i');">Italic</button>
  982. <button onclick="javascript:wrapBBCode('u');">Underline</button>
  983. <button onclick="javascript:wrapBBCode('b');">Bold</button>
  984. <button onclick="javascript:wrapBBCode('img');">Image</button>
  985. <button onclick="javascript:wrapBBCode('url');">URL</button><br />
  986. <textarea style="width: 98%;" name="msg" id="msg"></textarea>
  987. <button style="width: 50px;" onclick="getInput();">Send</button>
  988. </div>
  989. </div>
  990. <?php
  991. } // Check friend end
  992. } // Check loop end
  993. } // GET friend set end
  994. } // session check end
  995. } // function end
  996. if($do=="msghist")
  997. {
  998. if ($loginCheck != true) { loginForm(); } else {
  999. //check if friend is set
  1000. if(!isset($_GET['friend'])) { echo "ERROR: No username defined!"; exit(1); } else {
  1001. // set friend username
  1002. $friendNick = htmlentities(stripslashes($_GET['friend']));
  1003. $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count");
  1004. include "ssb_db/friends/" . $username . ".php";
  1005. for($x = 1; $x <= $friendcount; $x++)
  1006. {
  1007. if($friendNick == ${"friend" . $x}) {
  1008. ?>
  1009. <script language="javascript" type="text/javascript">
  1010. <!--
  1011. var httpObject = null;
  1012. var link = "chatserver.php?get=<?php echo $friendNick; ?>";
  1013. var timerID = 0;
  1014. var friendNick = "<?php echo $friendNick; ?>";
  1015. var nickName = "<?php echo $_SESSION['ssb-user']; ?>";
  1016. var userColor = "<?php echo $_SESSION['ssb-color'];; ?>";
  1017. // Change the value of the outputText field
  1018. function setAll() {
  1019. if(ajaxVar.readyState == 4){
  1020. var response = ajaxVar.responseText;
  1021. var msgBox = document.getElementById("msgs");
  1022. msgBox.innerHTML = response;
  1023. msgBox.scrollTop = msgBox.scrollHeight;
  1024. }
  1025. }
  1026. function serverLoad() {
  1027. ajaxVar = getHTTPObject();
  1028. //var randomnumber=Math.floor(Math.random()*10000);
  1029. if (ajaxVar != null) {
  1030. ajaxVar.open("GET", link , true);
  1031. ajaxVar.onreadystatechange = setAll;
  1032. ajaxVar.send(null);
  1033. }
  1034. }
  1035. window.addEventListener('load', function () {
  1036. serverLoad();
  1037. });
  1038. //-->
  1039. </script>
  1040. <div class="replycontain">
  1041. <?php
  1042. // Header
  1043. include "ssb_db/users/" . $friendNick . ".php";
  1044. echo "<h3><a href='?userfeed=" . $friendNick . "'>" . $friendNick . ": Message history</a></h3>";
  1045. ?>
  1046. <div id="msgs">
  1047. <?php
  1048. echo "<div class=\"msgbox\" style=\"overflow-y: scroll;\">";
  1049. echo "</div>";
  1050. ?>
  1051. </div>
  1052. </div>
  1053. <?php
  1054. } // Check friend end
  1055. } // Check loop end
  1056. } // GET friend set end
  1057. } // session check end
  1058. } // function end
  1059. // Push user avatar to specific avatar image location
  1060. if($do=="avatarlocation")
  1061. {
  1062. if(isset($_GET['user'])) {
  1063. $user = htmlentities(stripslashes($_GET['user']));
  1064. include "ssb_db/users/" . $user . ".php";
  1065. if(file_exists("ssb_db/uploads/" . $user_avatar)) {
  1066. echo "Direct to: ssb_db/uploads/" . $user_avatar;
  1067. header("Location: ssb_db/uploads/" . $user_avatar . "");
  1068. exit;
  1069. } else {
  1070. echo "Direct to: data/defaultprofile.png";
  1071. header("Location: data/defaultprofile.png");
  1072. exit;
  1073. }
  1074. } else {
  1075. echo "User is NOT set!";
  1076. }
  1077. }
  1078. if($do=="about")
  1079. {
  1080. echo "<h2>About</h2>";
  1081. echo "<div class='dllink'><a class='button' href='download/secure-space-v1.0.0.apk'>Download for Android!</a></div>";
  1082. echo "<p>" . $desc;
  1083. echo "<br /><br />";
  1084. echo "$ssbtitle statistics: ";
  1085. getUserCount();
  1086. echo "; ";
  1087. getPostCount();
  1088. echo "; ";
  1089. getUploadFileCount();
  1090. echo "</p>";
  1091. }
  1092. if($do=="users")
  1093. {
  1094. if ($loginCheck != true) { loginForm(); } else {
  1095. echo "<h2>Community</h2>";
  1096. foreach(array_reverse(glob("ssb_db/users/"."*.name")) as $userfile) {
  1097. $userhandle = file_get_contents($userfile);
  1098. include "ssb_db/users/" . $userhandle . ".php";
  1099. if($accttype == "public") {
  1100. echo "<table class='friendslist'><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$userhandle');\" title='User Avatar'></td>";
  1101. echo "<td><a class='button' href='index.php?userfeed=$userhandle'>$userhandle</a> ~ $user_fullname</td>";
  1102. echo "</td></tr></table>";
  1103. }
  1104. }
  1105. }
  1106. }
  1107. if($do=="friends")
  1108. {
  1109. if ($loginCheck != true) { loginForm(); } else {
  1110. // Friends panel
  1111. echo "<h3>Friends</h3><a href='?do=users' class='button'>Public users</a> <a class='button' href='?forms=friendreq'>Send friend request</a>";
  1112. // Friends list if you have any.
  1113. echo "<br />";
  1114. $friendc = file_get_contents("ssb_db/friends/" . $username . ".count");
  1115. if($friendc == "0")
  1116. {
  1117. echo "<b style='color:red;'>We're sorry... no friends found on your user account...</b>";
  1118. }
  1119. else
  1120. {
  1121. $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count");
  1122. include "ssb_db/friends/" . $username . ".php";
  1123. echo "<table class='friendslist'>";
  1124. for($x = 1; $x <= $friendcount; $x++)
  1125. {
  1126. if(isset(${"friend" . $x}) && file_exists("ssb_db/users/" . ${"friend" . $x} . ".php")) {
  1127. echo "<tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=" . ${"friend" . $x} . "');\" title='User Avatar'></div></td><td><a class='button' href='index.php?userfeed=" . ${"friend" . $x} . "'>" . ${"friend" . $x} . "</a></td><td><a class='button' href='?do=privmsg&friend=" . ${"friend" . $x} . "'>Private message</a>&nbsp;&nbsp;<a href='?do=msghist&friend=" . ${"friend" . $x} . "' class='button'>Message history</a></td></tr>";
  1128. }
  1129. }
  1130. echo "</table>";
  1131. }
  1132. }
  1133. }
  1134. if($do=="login")
  1135. {
  1136. $username = $_POST['username'];
  1137. if(file_exists("ssb_db/users/$username.php")) {
  1138. include_once("ssb_db/users/$username.php");
  1139. if($user_password==sha1(md5($_POST['password']))) {
  1140. $pass = $user_password;
  1141. $user = $username;
  1142. $color = $user_color;
  1143. $_SESSION['ssb-user'] = $user;
  1144. $_SESSION['ssb-pass'] = $pass;
  1145. $_SESSION['ssb-color'] = $color;
  1146. header("Location: index.php");
  1147. } else {
  1148. echo "Wrong password!";
  1149. }
  1150. } else {
  1151. echo "User $username not found!";
  1152. }
  1153. }
  1154. if($do=="logout")
  1155. {
  1156. $_SESSION['ssb-user'] = null;
  1157. $_SESSION['ssb-pass'] = null;
  1158. header("Location: index.php?forms=login");
  1159. }
  1160. if($do=="register")
  1161. {
  1162. if($_POST['username']!="" && $_POST['password']!="" && $_POST['password-again']!="" && $_POST['fullname']!="" && isset($_POST['acct'])) {
  1163. if($_POST['password']==$_POST['password-again']) {
  1164. if(!preg_match('/[^a-z0-9]/i', $_POST['username'])) {
  1165. if(!file_exists("ssb_db/users/" . $_POST['username'] . ".php")) {
  1166. $colors = array("0000ff", "9900cc", "0080ff", "008000", "ededed");
  1167. $acct = $_POST['acct'];
  1168. file_put_contents("ssb_db/users/" . stripslashes(htmlentities($_POST['username'])) . ".php", "<?php\n\$accttype = \"" . $acct . "\";\n\$user_password = \"" . sha1(md5($_POST['password'])) . "\";\n \$user_color = \"" . $colors[array_rand($colors)] . "\"; \$user_fullname = \"" . stripslashes(htmlentities($_POST['fullname'])) . "\"; \$user_avatar = \"../../data/defaultprofile.png\"; \n?>");
  1169. file_put_contents("ssb_db/users/" . stripslashes(htmlentities($_POST['username'])) . ".name", stripslashes(htmlentities($_POST['username'])));
  1170. file_put_contents("ssb_db/users/" . stripslashes(htmlentities($_POST['username'])) . ".postnumber", "0");
  1171. file_put_contents("ssb_db/friends/" . stripslashes(htmlentities($_POST['username'])) . ".count", "0");
  1172. file_put_contents("ssb_db/friends/" . stripslashes(htmlentities($_POST['username'])) . ".php", "<?php ?>\n");
  1173. header("Location: index.php");
  1174. } else {
  1175. header("Location: index.php?notify=6");
  1176. }
  1177. } else {
  1178. header("Location: index.php?notify=5");
  1179. }
  1180. } else {
  1181. header("Location: index.php?notify=4");
  1182. }
  1183. } else {
  1184. header("Location: index.php?notify=3");
  1185. }
  1186. echo "<b>ERROR!</b>: Something weird just happened... please try registering again!!!...";
  1187. //header("Location: index.php");
  1188. }
  1189. }
  1190. else if ($loginCheck != true)
  1191. {
  1192. loginForm();
  1193. }
  1194. else
  1195. {
  1196. // Watch feed, lets generate pages while we're at it
  1197. $pagecall = $_GET['page'];
  1198. $postcount = 1;
  1199. if(isset($pagecall) && $pagecall!="")
  1200. {
  1201. if($pagecall == "1")
  1202. {
  1203. $poststart = $postcount;
  1204. }
  1205. else
  1206. {
  1207. $poststart = ($pagecall - 1) * 15; // 15 posts per page
  1208. }
  1209. }
  1210. else
  1211. {
  1212. $poststart = $postcount;
  1213. }
  1214. // Lets actually generate some feed now.
  1215. foreach(array_reverse(glob("ssb_db/posts/*.post")) as $postfile) {
  1216. unset($shared); // make sure its not being carried over after loop.
  1217. $postphp = file_get_contents($postfile);
  1218. include "ssb_db/posts/$postphp";
  1219. $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count");
  1220. include "ssb_db/friends/" . $username . ".php";
  1221. for($x = 1; $x <= $friendcount; $x++)
  1222. {
  1223. if($postowner == ${"friend" . $x}) {
  1224. // Found a post, post count goes up!
  1225. $postcount++;
  1226. if($poststart == "1" && $postcount < ($poststart + 15)) {
  1227. echo "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate &nbsp;&nbsp;";
  1228. if(file_exists("ssb_db/posts/$postid.reactcount")) {
  1229. $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
  1230. echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
  1231. // Pull up users who reacted, and generate dropdown list.
  1232. $reactlist = fopen("ssb_db/posts/$postid.reacted", "r");
  1233. if($reactlist) {
  1234. while (($reactor = fgets($reactlist)) !== false) {
  1235. echo "<b>$reactor</b>";
  1236. }
  1237. fclose($reactlist);
  1238. }
  1239. echo "</div></div>";
  1240. }
  1241. if(isset($shared) && $shared == "1")
  1242. {
  1243. echo "<br />Originally posted by $origowner";
  1244. }
  1245. echo "</span></h3></td></tr></table>";
  1246. echo "" . bbcode_format($postcontent) . "";
  1247. // Footer
  1248. echo "<div class='post-footer'>";
  1249. echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i>&nbsp;React</a>";
  1250. echo "<a style='padding-top: 6px;' href='index.php?view=$postid&user=$postowner' class='button'><i class='fa fa-comment'></i>&nbsp;Comment</a>";
  1251. echo "<a style='padding-top: 6px;' href='index.php?do=share&pid=$postid&user=$postowner' class='button'><i class='fa fa-share'></i>&nbsp;Share</a>";
  1252. echo "<br />"; // line break
  1253. if(file_exists("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count")) {
  1254. $pcount = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count");
  1255. // If there's a reply, show them.
  1256. if($pcount == 0) {
  1257. echo "no replies";
  1258. } else if($pcount == 1) {
  1259. echo "$pcount reply";
  1260. } else if ($pcount > 0) {
  1261. echo "$pcount replies";
  1262. }
  1263. }
  1264. echo " &bull; ";
  1265. // Show reaction count in footer as well.
  1266. if(file_exists("ssb_db/posts/" . $postid . ".reactcount")) {
  1267. $reactcount = file_get_contents("ssb_db/posts/" . $postid . ".reactcount");
  1268. if($reactcount == 1) {
  1269. echo "$reactcount reaction";
  1270. } else if ($reactcount > 0) {
  1271. echo "$reactcount reactions";
  1272. }
  1273. } else {
  1274. echo "no reactions";
  1275. }
  1276. echo "</div></div><br />\n";
  1277. }
  1278. if($poststart > "1" && $postcount > $poststart && $postcount < ($poststart + 15)) {
  1279. echo "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate &nbsp;&nbsp;";
  1280. if(file_exists("ssb_db/posts/$postid.reactcount")) {
  1281. $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
  1282. echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
  1283. // Pull up users who reacted, and generate dropdown list.
  1284. $reactlist = fopen("ssb_db/posts/$postid.reacted", "r");
  1285. if($reactlist) {
  1286. while (($reactor = fgets($reactlist)) !== false) {
  1287. echo "<b>$reactor</b>";
  1288. }
  1289. fclose($reactlist);
  1290. }
  1291. echo "</div></div>";
  1292. }
  1293. if(isset($shared) && $shared == "1")
  1294. {
  1295. echo "<br />Originally posted by $origowner";
  1296. }
  1297. echo "</span></h3></td></tr></table>";
  1298. echo "" . bbcode_format($postcontent) . "";
  1299. // Footer
  1300. echo "<div class='post-footer'>";
  1301. echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i>&nbsp;React</a>";
  1302. echo "<a style='padding-top: 6px;' href='index.php?view=$postid&user=$postowner' class='button'><i class='fa fa-comment'></i>&nbsp;Comment</a>";
  1303. echo "<a style='padding-top: 6px;' href='index.php?do=share&pid=$postid&user=$postowner' class='button'><i class='fa fa-share'></i>&nbsp;Share</a>";
  1304. echo "<br />"; // line break
  1305. if(file_exists("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count")) {
  1306. $pcount = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count");
  1307. // If there's a reply, show them.
  1308. if($pcount == 0) {
  1309. echo "no replies";
  1310. } else if($pcount == 1) {
  1311. echo "$pcount reply";
  1312. } else if ($pcount > 0) {
  1313. echo "$pcount replies";
  1314. }
  1315. }
  1316. echo " &bull; ";
  1317. // Show reaction count in footer as well.
  1318. if(file_exists("ssb_db/posts/" . $postid . ".reactcount")) {
  1319. $reactcount = file_get_contents("ssb_db/posts/" . $postid . ".reactcount");
  1320. if($reactcount == 1) {
  1321. echo "$reactcount reaction";
  1322. } else if ($reactcount > 0) {
  1323. echo "$reactcount reactions";
  1324. }
  1325. } else {
  1326. echo "no reactions";
  1327. }
  1328. echo "</div></div><br />\n";
  1329. }
  1330. }
  1331. }
  1332. if($postowner == $username)
  1333. {
  1334. // Found a post, post count goes up!
  1335. $postcount++;
  1336. if($poststart == "1" && $postcount < ($poststart + 15)) {
  1337. echo "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate &nbsp;&nbsp;";
  1338. if(file_exists("ssb_db/posts/$postid.reactcount")) {
  1339. $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
  1340. echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
  1341. // Pull up users who reacted, and generate dropdown list.
  1342. $reactlist = fopen("ssb_db/posts/$postid.reacted", "r");
  1343. if($reactlist) {
  1344. while (($reactor = fgets($reactlist)) !== false) {
  1345. echo "<b>$reactor</b>";
  1346. }
  1347. fclose($reactlist);
  1348. }
  1349. echo "</div></div>";
  1350. }
  1351. if(isset($shared) && $shared == "1")
  1352. {
  1353. echo "<br />Originally posted by $origowner";
  1354. }
  1355. echo "</span></h3></td></tr></table>";
  1356. echo "" . bbcode_format($postcontent) . "";
  1357. // Footer
  1358. echo "<div class='post-footer'>";
  1359. echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i>&nbsp;React</a>";
  1360. echo "<a style='padding-top: 6px;' href='index.php?view=$postid&user=$postowner' class='button'><i class='fa fa-comment'></i>&nbsp;Comment</a>";
  1361. echo "<a style='padding-top: 6px;' href='index.php?do=delpost&user=$username&pid=$postid' class='button'><i class='fa fa-trash-o'></i>&nbsp;Delete</a>";
  1362. echo "<br />"; // line break
  1363. if(file_exists("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count")) {
  1364. $pcount = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count");
  1365. // If there's a reply, show them.
  1366. if($pcount == 0) {
  1367. echo "no replies";
  1368. } else if($pcount == 1) {
  1369. echo "$pcount reply";
  1370. } else if ($pcount > 0) {
  1371. echo "$pcount replies";
  1372. }
  1373. }
  1374. echo " &bull; ";
  1375. // Show reaction count in footer as well.
  1376. if(file_exists("ssb_db/posts/" . $postid . ".reactcount")) {
  1377. $reactcount = file_get_contents("ssb_db/posts/" . $postid . ".reactcount");
  1378. if($reactcount == 1) {
  1379. echo "$reactcount reaction";
  1380. } else if ($reactcount > 0) {
  1381. echo "$reactcount reactions";
  1382. }
  1383. } else {
  1384. echo "no reactions";
  1385. }
  1386. echo "</div></div><br />\n";
  1387. }
  1388. if($poststart > "1" && $postcount > $poststart && $postcount < ($poststart + 15)) {
  1389. echo "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate &nbsp;&nbsp;";
  1390. if(file_exists("ssb_db/posts/$postid.reactcount")) {
  1391. $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
  1392. echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
  1393. // Pull up users who reacted, and generate dropdown list.
  1394. $reactlist = fopen("ssb_db/posts/$postid.reacted", "r");
  1395. if($reactlist) {
  1396. while (($reactor = fgets($reactlist)) !== false) {
  1397. echo "<b>$reactor</b>";
  1398. }
  1399. fclose($reactlist);
  1400. }
  1401. echo "</div></div>";
  1402. }
  1403. echo "</span></h3></td></tr></table>";
  1404. echo "" . bbcode_format($postcontent) . "";
  1405. // Footer
  1406. echo "<div class='post-footer'>";
  1407. echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i>&nbsp;React</a>";
  1408. echo "<a style='padding-top: 6px;' href='index.php?view=$postid&user=$postowner' class='button'><i class='fa fa-comment'></i>&nbsp;Comment</a>";
  1409. echo "<a style='padding-top: 6px;' href='index.php?do=delpost&user=$username&pid=$postid' class='button'><i class='fa fa-trash-o'></i>&nbsp;Delete</a>";
  1410. echo "<br />"; // line break
  1411. if(file_exists("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count")) {
  1412. $pcount = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count");
  1413. // If there's a reply, show them.
  1414. if($pcount == 0) {
  1415. echo "no replies";
  1416. } else if($pcount == 1) {
  1417. echo "$pcount reply";
  1418. } else if ($pcount > 0) {
  1419. echo "$pcount replies";
  1420. }
  1421. }
  1422. echo " &bull; ";
  1423. // Show reaction count in footer as well.
  1424. if(file_exists("ssb_db/posts/" . $postid . ".reactcount")) {
  1425. $reactcount = file_get_contents("ssb_db/posts/" . $postid . ".reactcount");
  1426. if($reactcount == 1) {
  1427. echo "$reactcount reaction";
  1428. } else if ($reactcount > 0) {
  1429. echo "$reactcount reactions";
  1430. }
  1431. } else {
  1432. echo "no reactions";
  1433. }
  1434. echo "</div></div><br />\n";
  1435. }
  1436. }
  1437. }
  1438. // Page button generation
  1439. echo "<div class='page-controls'>";
  1440. if($poststart > "1") {
  1441. $prevpage = $poststart / 15;
  1442. echo "<a href='index.php?page=$prevpage'><i class='fa fa-arrow-left'></i> &nbsp; Prev page</a>";
  1443. }
  1444. echo "&nbsp;&nbsp;&nbsp;";
  1445. if($poststart == "1" && $postcount > ($poststart + 15)) {
  1446. echo "<a href='index.php?page=2'>Next page &nbsp; <i class='fa fa-arrow-right'></i></a>";
  1447. }
  1448. if($poststart > "1" && $postcount > ($poststart + 15)) {
  1449. $nextpage = ($poststart / 15) + 2;
  1450. echo "<a href='index.php?page=$nextpage'>Next page &nbsp; <i class='fa fa-arrow-right'></i></a>";
  1451. }
  1452. echo "</div>";
  1453. }
  1454. ?>
  1455. </td></tr></table>
  1456. <div id="footer">Powered By SSB <?php echo $version; ?></div>
  1457. </div>
  1458. <!-- functions -->
  1459. <script type="text/javascript" src="data/main.js"></script>
  1460. </body>
  1461. </html>