mod.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. <?php
  2. session_start();
  3. function createLog($text)
  4. {
  5. include 'config.php';
  6. if($Logging=='true')
  7. {
  8. $sql = "INSERT INTO Log (User, IP, Input, Date) VALUES (?, ?, ?, ?)";
  9. $stmt = $conn->prepare($sql);
  10. $User=$_SESSION['ID'];
  11. $TimeIn=time();
  12. $stmt->bind_param("issi", $User, $_SERVER['REMOTE_ADDR'] , $text, $TimeIn);
  13. $stmt->execute();
  14. }
  15. }
  16. if($_SESSION['Level']=='-1' || $_GET["ID"]=="" && ($_GET["Mod"]!="4" && $_GET["Mod"]!="5" && $_GET["Mod"]!="7" && $_GET["Mod"]!="8" && $_GET["Mod"]!="9" && $_GET["Mod"]!="10" && $_GET["Mod"]!="11" && $_GET["Mod"]!="12"))
  17. {
  18. echo "No ID for modification specified";
  19. }
  20. else
  21. {
  22. if(!isset($_POST['Creator']))
  23. {
  24. if (isset($_SESSION['Lock']))
  25. {
  26. unset($_SESSION['Lock']);
  27. }
  28. if(($_GET["Mod"])=="12")
  29. {
  30. echo $Help;
  31. }
  32. if(($_GET["Mod"])=="11")
  33. {
  34. echo $Rules;
  35. }
  36. if(($_GET["Mod"])=="10")
  37. {
  38. echo '<br><hr><br><b>Image List:</b><br>';
  39. $sql = "SELECT Link, License, Alt, ID FROM Images WHERE Unlocked=1";
  40. $stmt = $conn->prepare($sql);
  41. $stmt->execute();
  42. $result = $stmt->get_result();
  43. if ($result->num_rows > 0)
  44. {
  45. while($row = $result->fetch_assoc())
  46. {
  47. echo $row["ID"].': <img src="' . $row["Link"] . '" alt="'. htmlentities($row["Alt"]) .'" style="width:125;height:100px;"></label><br>Description:<br> '.htmlentities($row["Alt"]).'<br>License:<br>'.htmlentities($row["License"]).'<br><hr>';
  48. }
  49. }
  50. }
  51. if($_GET["Mod"]=="9" && $_SESSION['Level']>=$UserSettingPermissionLevel)
  52. {
  53. $sql = "SELECT Name, Level, ID FROM Users ORDER BY ID DESC";
  54. $stmt = $conn->prepare($sql);
  55. $stmt->execute();
  56. $result = $stmt->get_result();
  57. echo '<b>Users:</b><br>';
  58. echo '<form action="index.php?Mod='.htmlentities($_GET["Mod"]).'" method="post" title="Set User Permission" enctype="multipart/form-data">';
  59. echo '<fieldset><legend>Select User to Edit</legend>';
  60. $i=0;
  61. if ($result->num_rows > 0)
  62. {
  63. while($row = $result->fetch_assoc())
  64. {
  65. echo '<input type="radio" name="UserSet" id="UserSet'.$i.'" value="'.$row["ID"].'">
  66. <label for="UserSet'.$i.'">' . $row["ID"] . ': <a href=index.php?User='. $row["ID"] . '>'. htmlentities($row["Name"]) . '</a></label><br> User Level (-1 to ban): <input type="text" title="New User Level" name="Alt'.$row["ID"].'" value="'.htmlentities($row["Level"]).'" size="10"><hr>';
  67. $i=$i+1;
  68. }
  69. }
  70. echo '</fieldset> <input type="submit" value="Send" title="Send" name="Creator">';
  71. echo '</form>';
  72. }
  73. if($_GET["Mod"]=="8" && ($_SESSION['Level']>=$LogPermissionLevel))
  74. {
  75. $sql = "SELECT User, IP, Input, ID FROM Log ORDER BY ID DESC";
  76. $stmt = $conn->prepare($sql);
  77. $stmt->execute();
  78. $result = $stmt->get_result();
  79. echo '<b>Log</b><br>';
  80. if ($result->num_rows > 0)
  81. {
  82. while($row = $result->fetch_assoc())
  83. {
  84. echo $row["ID"] . ' by <a href=index.php?User='. htmlentities($row["User"]) . '>User</a> with IP ' . $row["IP"] . ' edit: ' . htmlentities($row["Input"]) . '<hr>';
  85. }
  86. }
  87. }
  88. if(($_GET["Mod"])=="7" && ($_SESSION['Level']>=$ImageEditPermissionLevel))
  89. {
  90. echo '<form action="index.php?Mod='.htmlentities($_GET["Mod"]).'" method="post" title="Edit Images" enctype="multipart/form-data">';
  91. $sql = "SELECT Link, License, Alt, ID FROM Images WHERE Unlocked=0";
  92. $stmt = $conn->prepare($sql);
  93. $stmt->execute();
  94. $result = $stmt->get_result();
  95. echo '<b>Awaiting approval</b><br><fieldset><legend>Select Image to Edit</legend>';
  96. $i=0;
  97. if ($result->num_rows > 0)
  98. {
  99. while($row = $result->fetch_assoc())
  100. {
  101. echo '<input type="radio" name="ImageSet" id="ImageSet'.$i.'" value="'.$row["ID"].'">
  102. <label for="ImageSet'.$i.'">'.$row["ID"].'<img src="' . $row["Link"] . '" alt="'. htmlentities($row["Alt"]) .'" style="width:125;height:100px;"></label><br>Description:<br> <input type="text" title="Alt Text" name="Alt'.$row["ID"].'" value="'.htmlentities($row["Alt"]).'" size="100"><br>Unlocked (-1 to delete):<br> <input type="text" title="Unlocked" name="Unlocked'.$row["ID"].'" value="0" size="100"><br>License:<br> <input type="text" title="Image License" name="License'.$row["ID"].'" value="'.htmlentities($row["License"]).'" size="100"><br>';
  103. $i=$i+1;
  104. }
  105. }
  106. echo '</fieldset><input type="submit" value="Send" title="Send" name="Creator">';
  107. echo '<br><hr><br><b>Edit approved images:</b><br>';
  108. $sql = "SELECT Link, License, Alt, ID FROM Images WHERE Unlocked=1";
  109. $stmt = $conn->prepare($sql);
  110. $stmt->execute();
  111. $result = $stmt->get_result();
  112. echo '<fieldset><legend>Select Image to Edit</legend>';
  113. if ($result->num_rows > 0)
  114. {
  115. while($row = $result->fetch_assoc())
  116. {
  117. echo '<input type="radio" name="ImageSet" id="ImageSet'.$i.'" value="'.$row["ID"].'">
  118. <label for="ImageSet'.$i.'">'.$row["ID"].'<img src="' . $row["Link"] . '" alt="'. htmlentities($row["Alt"]) .'" style="width:125;height:100px;"></label><br>Description:<br> <input type="text" title="Image Alt Text" name="Alt'.$row["ID"].'" value="'.htmlentities($row["Alt"]).'" size="100"><br>Unlocked (-1 to delete):<br> <input type="text" title="Unlocked" name="Unlocked'.$row["ID"].'" value="1" size="100"><br>License:<br> <input type="text" title="License" name="License'.$row["ID"].'" value="'.htmlentities($row["License"]).'" size="100"><br>';
  119. $i=$i+1;
  120. }
  121. }
  122. echo '</fieldset> <input type="submit" value="Send" name="Creator">';
  123. echo '</form>';
  124. }
  125. if(($_GET["Mod"])=="6")
  126. {
  127. $sql = "SELECT Title, Opener, Description, Owner FROM Stories WHERE ID=?";
  128. $stmt = $conn->prepare($sql);
  129. $stmt->bind_param("i", $_GET["ID"]);
  130. $stmt->execute();
  131. $result = $stmt->get_result();
  132. if ($result->num_rows > 0)
  133. {
  134. while($row = $result->fetch_assoc())
  135. {
  136. echo "Test: ". $row["Description"] . "<br>";
  137. echo '<form action="index.php?Mod='.htmlentities($_GET["Mod"]).'&ID='.htmlentities($_GET["ID"]).'" method="post" title="Edit Story" enctype="multipart/form-data">
  138. <input type="text" title="Title" name="Title" value="'.htmlentities($row["Title"]).'" size="195"><br>
  139. <input type="text" title="First Page ID" name="Opener" value="'.htmlentities($row["Opener"]).'" size="195"><br>
  140. <input type="text" title="Short Description" name="desc" value="'.htmlentities($row["Description"]).'" size="195" maxlength="300"> (max size 300)<br>
  141. <input type="submit" value="Send" name="Creator">
  142. </form>';
  143. }
  144. }
  145. }
  146. if(($_GET["Mod"])=="5" && $_SESSION['Level']>=$CreateStoryPermissionLevel)
  147. {
  148. echo '<form action="index.php?Mod='.htmlentities($_GET["Mod"]).'" method="post" title="Create Story" enctype="multipart/form-data">
  149. <input type="text" title="Title" name="Title" value="Title" size="195"><br>
  150. <input type="text" title="First Page ID" name="Opener" value="First Page ID" size="195"><br>
  151. <input type="text" title="Short Description" name="desc" value="A short description" size="195" maxlength="300"> (max size 300)<br>
  152. <input type="submit" value="Send" name="Creator">
  153. </form>';
  154. }
  155. if(($_GET["Mod"])=="4" && $_SESSION['Level']>=$CreatePagePermissionLevel)
  156. {
  157. echo '<form action="index.php?Mod='.htmlentities($_GET["Mod"]).'" method="post" title="Create Page" enctype="multipart/form-data">
  158. <input type="text" title="Page Title" name="Title" value="Title" size="195"><br>
  159. <input type="text" title="Page Description" name="Description" value="Link Description" size="195"><br>
  160. <textarea id="TextInput" title="Page Text" name="WallOfText" rows="40" cols="200">Text</textarea><br>
  161. <input type="checkbox" name="OpenStory" id="OpenStory" value="1">
  162. <label for="OpenStory"> Allow everyone to edit.</label><br>
  163. <input type="checkbox" name="OpenALinks" id="OpenALinks" value="1">
  164. <label for="OpenALinks"> Allow everyone to add links.</label><br>
  165. <input type="checkbox" name="OpenRLinks" id="OpenRLinks" value="1">
  166. <label for="OpenRLinks"> Allow everyone to remove links.</label><br>
  167. <input type="checkbox" name="OpenImage" id="OpenImage" value="1">
  168. <label for="OpenImage"> Allow everyone to set the image.</label><br>
  169. By saving you agree to release the text and changes made by a <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">CC BY SA 4.0 License</a>. Do not submit things you did not create by yourself, or that are certainly public domain!<br>
  170. <input type="submit" value="Send" title="Send" name="Creator">
  171. </form>';
  172. }
  173. if(($_GET["Mod"])=="3")
  174. {
  175. $sql = "SELECT Options, Owner, OpenAddLinks, OpenRemoveLinks FROM stor WHERE RefID=?";
  176. $stmt = $conn->prepare($sql);
  177. $stmt->bind_param("i", $_GET["ID"]);
  178. $stmt->execute();
  179. $result = $stmt->get_result();
  180. while($row = $result->fetch_assoc())
  181. {
  182. echo '<form action="index.php?Mod='.htmlentities($_GET["Mod"]).'&ID='.htmlentities($_GET["ID"]).'" method="post" title="Edit Links" enctype="multipart/form-data">';
  183. if($row["OpenAddLinks"]=='1' || $row["Owner"]==$_SESSION['ID'] || $_SESSION['Level']>=$ModPermissionLevel)
  184. {
  185. echo '<br>Add Option ID ( 0 only deletes options): <br> <input type="text" name="Add" title="IDs of Pages to add" value="0" size="50"><br><br>';
  186. }
  187. if ($result->num_rows > 0 && ($row["OpenRemoveLinks"]=='1' || $row["Owner"]==$_SESSION['ID'] || $_SESSION['Level']>=$ModPermissionLevel))
  188. {
  189. echo 'Delete Option ( unselected only adds options ):<br>';
  190. $Options=$row["Options"];
  191. if($Options!="")
  192. {
  193. $choices= explode(" ", $Options);
  194. $arrLength = count($choices);
  195. for($i = 0; $i < $arrLength; $i++)
  196. {
  197. $l=$i+1;
  198. $sql2 = "SELECT Description FROM stor WHERE RefID=?";
  199. $stmt = $conn->prepare($sql2);
  200. $stmt->bind_param("i", $choices[$i]);
  201. $stmt->execute();
  202. $result2 = $stmt->get_result();
  203. while($row2 = $result2->fetch_assoc())
  204. {
  205. echo '<input type="radio" name="DeleteOption" id="DeleteOption" value="'.$l.'">
  206. <label for="DeleteOption">'.$l. ':'. htmlentities($row2["Description"]) .'</label><br>';
  207. }
  208. }
  209. }
  210. }
  211. }
  212. echo' <input type="submit" value="Send" title="Send" name="Creator">
  213. </form>';
  214. }
  215. if(($_GET["Mod"])=="2")
  216. {
  217. echo '<form action="index.php?Mod='.htmlentities($_GET["Mod"]).'&ID='.htmlentities($_GET["ID"]).'" method="post" title="Set Page Image" enctype="multipart/form-data">
  218. <fieldset><legend>Select Image</legend>
  219. <input type="radio" name="ImageSet" id="ImageSet" value="0">
  220. <label for="ImageSet"> No Image.</label><br>';
  221. $sql = "SELECT Link, Unlocked, Alt, ID FROM Images";
  222. $stmt = $conn->prepare($sql);
  223. $stmt->execute();
  224. $result = $stmt->get_result();
  225. $i=0;
  226. if ($result->num_rows > 0)
  227. {
  228. while($row = $result->fetch_assoc())
  229. {
  230. if($row["Unlocked"]=='1')
  231. {
  232. echo '<input type="radio" name="ImageSet" id="ImageSet'.$i.'" value="'.$row["ID"].'">
  233. <label for="ImageSet'.$i.'">'.$row["ID"].'<img src="' . $row["Link"] . '" alt="'. htmlentities($row["Alt"]) .'" style="width:125;height:100px;"></label><br>';
  234. $i=$i+1;
  235. }
  236. }
  237. }
  238. echo' </fieldset><input type="submit" value="Send" title="Send" name="Creator">
  239. </form>';
  240. }
  241. if(($_GET["Mod"])=="1")
  242. {
  243. $sql = "SELECT Name, Text, Description, Open, OpenAddLinks, OpenRemoveLinks, OpenImage FROM stor WHERE RefID=?";
  244. $stmt = $conn->prepare($sql);
  245. $stmt->bind_param("i", $_GET["ID"]);
  246. $stmt->execute();
  247. $result = $stmt->get_result();
  248. if ($result->num_rows > 0)
  249. {
  250. // output data of each row
  251. while($row = $result->fetch_assoc())
  252. {
  253. echo '<form action="index.php?Mod='.htmlentities($_GET["Mod"]).'&ID='.htmlentities($_GET["ID"]).'" title="New Page" method="post" enctype="multipart/form-data">
  254. <input type="text" title="Page Title" name="Title" value="'.htmlentities($row["Name"]).'" size="195"><br>
  255. <input type="text" title="Page Description" name="Description" value="'.htmlentities($row["Description"]).'" size="195"><br>
  256. <textarea id="TextInput" title="Page Text" name="WallOfText" rows="40" cols="200">'.htmlentities($row["Text"]).'</textarea><br>';
  257. if($row["Open"]==0)
  258. {
  259. echo '<input type="checkbox" name="OpenStory" id="OpenStory" value="true">';
  260. }
  261. else
  262. {
  263. echo '<input type="checkbox" name="OpenStory" id="OpenStory" value="true" checked>';
  264. }
  265. echo '<label for="OpenStory"> Allow everyone to edit.</label><br>';
  266. if($row["OpenAddLinks"]==0)
  267. {
  268. echo '<input type="checkbox" name="OpenALinks" id="OpenALinks" value="true">';
  269. }
  270. else
  271. {
  272. echo '<input type="checkbox" name="OpenALinks" id="OpenALinks" value="true" checked>';
  273. }
  274. echo '<label for="OpenALinks"> Allow everyone to add links.</label><br>';
  275. if($row["OpenRemoveLinks"]==0)
  276. {
  277. echo '<input type="checkbox" name="OpenRLinks" id="OpenRLinks" value="true">';
  278. }
  279. else
  280. {
  281. echo '<input type="checkbox" name="OpenRLinks" id="OpenRLinks" value="true" checked>';
  282. }
  283. echo '<label for="OpenRLinks"> Allow everyone to remove links.</label><br>';
  284. if($row["OpenImage"]==0)
  285. {
  286. echo '<input type="checkbox" name="OpenImage" id="OpenImage" value="true">';
  287. }
  288. else
  289. {
  290. echo '<input type="checkbox" name="OpenImage" id="OpenImage" value="true" checked>';
  291. }
  292. echo '<label for="OpenImage"> Allow everyone to change the image.</label><br>';
  293. echo 'By saving you agree to release the text and changes made by a <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">CC BY SA 4.0 License</a>. Do not submit things you did not create by yourself, or that are certainly public domain!<br><input type="submit" value="Send" title="Send" name="Creator">
  294. </form>';
  295. }
  296. }
  297. else
  298. {
  299. echo "Invalid ID!";
  300. }
  301. }
  302. }
  303. else
  304. {
  305. if (!isset($_SESSION['Lock']))
  306. {
  307. $_SESSION['Lock'] = 'true';
  308. if($_GET["Mod"]=="9" && $_SESSION['Level']>=$UserSettingPermissionLevel)
  309. {
  310. $sql = 'UPDATE Users SET Level=? WHERE ID=?';
  311. $stmt = $conn->prepare($sql);
  312. $Link=$_POST['UserSet'];
  313. $Alttext='Alt'.$_POST['UserSet'];
  314. $Alttext=intval($_POST[$Alttext]);
  315. $stmt->bind_param("ii", $Alttext, $Link);
  316. $stmt->execute();
  317. }
  318. if(($_GET["Mod"])=="7" && $_SESSION['Level']>=$ImageEditPermissionLevel)
  319. {
  320. $sql = 'UPDATE Images SET Unlocked=?, License=?, Alt=? WHERE ID=?';
  321. $stmt = $conn->prepare($sql);
  322. $Link=$_POST['ImageSet'];
  323. $Alttext='Alt'.$_POST['ImageSet'];
  324. $Alttext=$_POST[$Alttext];
  325. $Unlocktext='Unlocked'.$_POST['ImageSet'];
  326. $Unlocktext=intval($_POST[$Unlocktext]);
  327. $Licensetext='License'.$_POST['ImageSet'];
  328. $Licensetext=$_POST[$Licensetext];
  329. $SID=$_GET["ID"];
  330. $stmt->bind_param("issi", $Unlocktext, $Licensetext, $Alttext, $Link);
  331. $stmt->execute();
  332. }
  333. if(($_GET["Mod"])=="6" && is_numeric($_POST['Opener']))
  334. {
  335. $sql = "SELECT Title, Opener, Description, Owner FROM Stories WHERE ID=?";
  336. $stmt = $conn->prepare($sql);
  337. $stmt->bind_param("i", $_GET["ID"]);
  338. $stmt->execute();
  339. $result = $stmt->get_result();
  340. if ($result->num_rows > 0)
  341. {
  342. // output data of each row
  343. while($row = $result->fetch_assoc())
  344. {
  345. if($row["Owner"]==$_SESSION['ID'] || $_SESSION['Level']>=$ModPermissionLevel)
  346. {
  347. $Tit=$row["Title"];
  348. $Ope=$row["Opener"];
  349. $Des=$row["Description"];
  350. $sql = 'UPDATE Stories SET Title=?, Opener=?, Description=? WHERE ID=?';
  351. $stmt = $conn->prepare($sql);
  352. $SID=$_GET["ID"];
  353. $Tit=$_POST['Title'];
  354. if(is_numeric($_POST['Opener']))
  355. {
  356. $Ope=$_POST['Opener'];
  357. }
  358. $Des=$_POST['desc'];
  359. $stmt->bind_param("sisi", $Tit, $Ope, $Des, $SID);
  360. $stmt->execute();
  361. $log="Storie editet. Title: " . $Tit . " Opener: " . $Ope . " Des: " . $Des . " ID: " . $SID;
  362. createLog($log, $Logging);
  363. }
  364. else
  365. {
  366. echo "Access denied.";
  367. }
  368. }
  369. }
  370. }
  371. if(($_GET["Mod"])=="5")
  372. {
  373. if(is_numeric($_POST['Opener']) && $_SESSION['Level']>=$CreateStoryPermissionLevel)
  374. {
  375. $sql = "INSERT INTO Stories (Title, Opener, Description, Owner) VALUES (?, ?, ?, ?)";
  376. $stmt = $conn->prepare($sql);
  377. $Title=$_POST['Title'];
  378. $Opener=intval($_POST['Opener']);
  379. $Desc=$_POST['desc'];
  380. $Owner=$_SESSION['ID'];
  381. $stmt->bind_param("sisi", $Title, $Opener, $Desc, $Owner);
  382. $stmt->execute();
  383. $log="Story created. Title: " . $Title . " Opener: " . $Opener . " Des: " . $Desc . " Owner: " . $Owner;
  384. createLog($log, $Logging);
  385. $_GET["ID"]=$Opener;
  386. }
  387. else
  388. {
  389. echo "Invalid ID";
  390. }
  391. }
  392. if(($_GET["Mod"])=="4" && $_SESSION['Level']>=$CreatePagePermissionLevel)
  393. {
  394. $sql = "INSERT INTO stor (Name, Text, Options, Description, Image, Owner, Open, OpenAddLinks, OpenRemoveLinks, OpenImage, RefID) VALUES (?, ?, '', ?, '0', ?, ?, ?, ?, ?, ?)";
  395. $stmt = $conn->prepare($sql);
  396. $Title=$_POST['Title'];
  397. $Text=$_POST['WallOfText'];
  398. $Desc=$_POST['Description'];
  399. $SID=$_SESSION['ID'];
  400. $OS=$_POST['OpenStory'];
  401. $OS2=$_POST['OpenALinks'];
  402. $OS3=$_POST['OpenRLinks'];
  403. $OS4=$_POST['OpenImage'];
  404. $Ref=rand(100, 999);
  405. $Ref.=time()-1687989600;
  406. echo $Ref;
  407. if($OS=="")$OS="0";
  408. if($OS2=="")$OS2="0";
  409. if($OS3=="")$OS3="0";
  410. if($OS4=="")$OS4="0";
  411. $stmt->bind_param("sssiiiiii", $Title, $Text, $Desc, $SID, $OS, $OS2, $OS3, $OS4, $Ref);
  412. $stmt->execute();
  413. $log="Page created. Title: " . $Title . " Text: " . $Text . " Des: " . $Desc . " ID: " . $SID . " Open: " . $OS . $OS2 . $OS3 . $OS4 . "Ref: " . $Ref;
  414. createLog($log, $Logging);
  415. $_GET["ID"]=$Ref;
  416. }
  417. if(($_GET["Mod"])=="3")
  418. {
  419. $sql = "SELECT Options, Owner, Open, OpenAddLinks, OpenRemoveLinks FROM stor WHERE RefID=?";
  420. $stmt = $conn->prepare($sql);
  421. $stmt->bind_param("i", $_GET["ID"]);
  422. $stmt->execute();
  423. $Own='0';
  424. $Op='0';
  425. $OpAL='0';
  426. $OpRL='0';
  427. $Opta='';
  428. $result = $stmt->get_result();
  429. if ($result->num_rows > 0)
  430. {
  431. // output data of each row
  432. while($row = $result->fetch_assoc())
  433. {
  434. $Own=$row["Owner"];
  435. $Op=$row["Open"];
  436. $OpAL=$row["OpenAddLinks"];
  437. $OpRL=$row["OpenRemoveLinks"];
  438. $Options=$row["Options"];
  439. if($Options!="" && ($OpRL=='1' || $Own==$_SESSION['ID'] || $_SESSION['Level']>=$ModPermissionLevel))
  440. {
  441. $choices= explode(" ", $Options);
  442. $arrLength = count($choices);
  443. for($i = 0; $i < $arrLength; $i++)
  444. {
  445. if($i!=($_POST['DeleteOption']-1))
  446. {
  447. $Opta.=$choices[$i];
  448. if($i!=$arrLength-1)
  449. {
  450. $Opta.=' ';
  451. }
  452. }
  453. }
  454. }
  455. else if($OpRL=='0')
  456. {
  457. $Opta.=$Options;
  458. }
  459. $check=str_replace(' ', '', $_POST['Add']);
  460. if(is_numeric($check) && ($OpAL=='1' || $Own==$_SESSION['ID'] || $_SESSION['Level']>=$ModPermissionLevel))
  461. {
  462. if($_POST['Add']!='0')
  463. {
  464. if($Opta!='')
  465. {
  466. $Opta.=' ';
  467. }
  468. $Opta.=$_POST['Add'];
  469. }
  470. }
  471. }
  472. }
  473. $sql = 'UPDATE stor SET Options=? WHERE RefID=?';
  474. $stmt = $conn->prepare($sql);
  475. $SID=$_GET["ID"];
  476. $stmt->bind_param("si", $Opta, $SID);
  477. $stmt->execute();
  478. $log="Links edited. Set Options to " . $Opta . " for Page " . $_GET["ID"];
  479. createLog($log, $Logging);
  480. }
  481. if(($_GET["Mod"])=="2")
  482. {
  483. $sql = "SELECT Owner, OpenImage FROM stor WHERE RefID=?";
  484. $stmt = $conn->prepare($sql);
  485. $stmt->bind_param("i", $_GET["ID"]);
  486. $stmt->execute();
  487. $Own='0';
  488. $Op='0';
  489. $result = $stmt->get_result();
  490. if ($result->num_rows > 0)
  491. {
  492. // output data of each row
  493. while($row = $result->fetch_assoc())
  494. {
  495. $Own=$row["Owner"];
  496. $Op=$row["OpenImage"];
  497. }
  498. }
  499. if($Own==$_SESSION['ID'] || $Op=='1' || $_SESSION['Level']>=$ModPermissionLevel)
  500. {
  501. $sql = 'UPDATE stor SET Image=? WHERE RefID=?';
  502. $stmt = $conn->prepare($sql);
  503. $Link=$_POST['ImageSet'];
  504. $SID=$_GET["ID"];
  505. $stmt->bind_param("si", $Link, $SID);
  506. $stmt->execute();
  507. $log="Image edited. Set Image to " . $Link . " for Page " . $_GET["ID"];
  508. createLog($log, $Logging);
  509. }
  510. else
  511. {
  512. echo "Access denied.";
  513. }
  514. }
  515. if(($_GET["Mod"])=="1")
  516. {
  517. $sql = "SELECT Owner, Open FROM stor WHERE RefID=?";
  518. $stmt = $conn->prepare($sql);
  519. $stmt->bind_param("i", $_GET["ID"]);
  520. $stmt->execute();
  521. $Own='0';
  522. $Op='0';
  523. $result = $stmt->get_result();
  524. if ($result->num_rows > 0)
  525. {
  526. // output data of each row
  527. while($row = $result->fetch_assoc())
  528. {
  529. $Own=$row["Owner"];
  530. $Op=$row["Open"];
  531. }
  532. }
  533. if($Own==$_SESSION['ID'] || $_SESSION['Level']>=$ModPermissionLevel)
  534. {
  535. $sql = 'UPDATE stor SET Name=?, Text=?, Description=?, Open=?, OpenAddLinks=?, OpenRemoveLinks=?, OpenImage=? WHERE RefID=?';
  536. $stmt = $conn->prepare($sql);
  537. $Title=$_POST['Title'];
  538. $Text=$_POST['WallOfText'];
  539. $Desc=$_POST['Description'];
  540. $SID=$_GET["ID"];
  541. $makeOpen=0;
  542. $makeALOpen="0";
  543. $makeRLOpen="0";
  544. $makeIOpen="0";
  545. $OS=$_POST['OpenStory'];
  546. $OS2=$_POST['OpenALinks'];
  547. $OS3=$_POST['OpenRLinks'];
  548. $OS4=$_POST['OpenImage'];
  549. if($OS=="true")$makeOpen="1";
  550. if($OS2=="true")$makeALOpen="1";
  551. if($OS3=="true")$makeRLOpen="1";
  552. if($OS4=="true")$makeIOpen="1";
  553. echo "Openness: " . $makeOpen . " ";
  554. $stmt->bind_param("sssiiiii", $Title, $Text, $Desc, $makeOpen, $makeALOpen, $makeRLOpen, $makeIOpen, $SID);
  555. $stmt->execute();
  556. $log="Page edited. Title: " . $Title . " Text: " . $Text . " Des: " . $Desc . " ID: " . $SID . " Open: " . $makeOpen . $makeALOpen . $makeRLOpen . $makeIOpen . "Ref: " . $SID;
  557. createLog($log, $Logging);
  558. }
  559. else
  560. {
  561. if($Op=='1')
  562. {
  563. $sql = 'UPDATE stor SET Name=?, Text=?, Description=? WHERE RefID=?';
  564. $stmt = $conn->prepare($sql);
  565. $Title=$_POST['Title'];
  566. $Text=$_POST['WallOfText'];
  567. $Desc=$_POST['Description'];
  568. $SID=$_GET["ID"];
  569. $stmt->bind_param("sssi", $Title, $Text, $Desc, $SID);
  570. $stmt->execute();
  571. $log="Page edited. Title: " . $Title . " Text: " . $Text . " Des: " . $Desc . " ID: " . $SID . "Ref: " . $SID;
  572. createLog($log, $Logging);
  573. }
  574. else
  575. {
  576. echo "Access denied.";
  577. }
  578. }
  579. }
  580. }
  581. if($_GET["Mod"]=="6")
  582. {
  583. $_GET["ID"]='';
  584. }
  585. $_GET["Mod"]=0;
  586. include 'read.php';
  587. }
  588. }
  589. ?>