Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.43 KB | None | 0 0
  1. You will need:
  2.  
  3. admin.php
  4. edit.php
  5. index.php
  6. login.php
  7. members.php
  8. logindata.php = empty
  9. newuser.php
  10. register.php
  11. top.php
  12. style.css
  13.  
  14.  
  15. admin.php
  16.  
  17. <?php
  18. ob_start();
  19. session_start();
  20. require("top.php");
  21. if($_SESSION['logged'] != '73de8dhas7'){
  22. header("location:login.php");
  23. }
  24.  
  25.  
  26. $_filename = "logindata.php";
  27. $_handle = fopen($_filename, "r");
  28. $_contents = str_replace("<?php /*&", "", str_replace("&*/?>", "", fread($_handle, filesize($_filename))));
  29. fclose($_handle);
  30.  
  31.  
  32. $_divide = explode("&", $_contents);
  33.  
  34. $_records = 0;
  35. while($_divide[$_records] != ''){
  36. $_records++;
  37. }
  38.  
  39.  
  40. $_array = 0;
  41. while($_divide[$_array] != ''){
  42. list($username5, $password5, $email5, $admin5) = explode(";", $_divide[$_array]);
  43. if($_SESSION['username'] == $username5){
  44. if($admin5 == '1' && $_SESSION['username'] == $username5){
  45. $_SESSION['admin'] = 'df83hfg7ds';
  46. }else{
  47. header("location:login.php?do=admin");
  48. exit;
  49. }
  50. }else{
  51. if($_records <= $_array){
  52. header("location:login.php");
  53. exit;
  54. }
  55. }
  56. $_array++;
  57. }
  58.  
  59. if($_SESSION['admin'] == 'df83hfg7ds'){
  60. $_array6 = 0;
  61. echo "<center>";
  62. echo "<br><b> Welcome to the Admin Control Panel!</b><br>";
  63. echo "<br><a href=edit.php><b>Edit the main page</b></a><br><br>";
  64. echo "<table>";
  65. echo "<tr><td><b>Name</b></td><td><b>Password</b></td><td><b>E-Mail</b></td><td><b>Admin</b></td><td><b>Admin Options</b></td><td><b>Action</b></td></tr>";
  66. while($_divide[$_array6] != ''){
  67. list($username6, $password6, $email6, $admin6) = explode(";", $_divide[$_array6]);
  68. echo "<tr><td>".$username6."</td><td>".$password6."</td><td><a href='mailto:$email6'>".$email6."</a></td><td>";
  69. if($admin6 == '1'){
  70. echo "Yes</td><td><a href='?do=take_right&user=".$username6."'>Take right</a>";
  71. }else{
  72. echo "No</td><td><a href='?do=give_right&user=".$username6."'>Give right</a>";
  73. }
  74. echo "</td><td><a href='?do=delete&user=".$username6."'>Delete</td></tr>";
  75. $_array6++;
  76. }
  77. echo "</table>";
  78. include("newuser.php");
  79.  
  80. if($_GET['do'] == 'delete'){
  81. $_user = $_GET['user'];
  82. $_filename = "logindata.php";
  83. $_handle = fopen($_filename, "r");
  84. $_contents = fread($_handle, filesize($_filename));
  85. fclose($_handle);
  86.  
  87. $_divide = explode("&", $_contents);
  88.  
  89. $_delete = 0;
  90. while($_divide[$_delete] != ''){
  91. list($username7, $password7, $email7, $admin7) = explode(";", $_divide[$_delete]);
  92. if($username7 == $_user){
  93. $_data = $username7.";".$password7.";".$email7.";".$admin7."&";
  94. }
  95. $_delete++;
  96. }
  97.  
  98. $_string = str_replace($_data, "", $_contents);
  99. $_filename = 'logindata.php';
  100. $_handle = fopen($_filename, 'w');
  101. fwrite($_handle, $_string);
  102. fclose($_handle);
  103. header("location:admin.php");
  104. }
  105.  
  106. if($_GET['do'] == 'give_right'){
  107. $_user = $_GET['user'];
  108. $_filename = "logindata.php";
  109. $_handle = fopen($_filename, "r");
  110. $_contents4 = fread($_handle, filesize($_filename));
  111. fclose($_handle);
  112.  
  113. $_divide2 = explode("&", $_contents4);
  114.  
  115. $_right = 0;
  116. while($_divide2[$_right] != ''){
  117. list($username, $password, $email, $admin) = explode(";", $_divide2[$_right]);
  118. if($username == $_user){
  119. if($admin != '1'){
  120. $_data = "&".$username.";".$password.";".$email.";1&";
  121. $_old = "&".$username.";".$password.";".$email.";0&";
  122. $_string = str_replace($_old, $_data, $_contents4);
  123. }
  124. }
  125. $_right++;
  126. }
  127. if($_string != ''){
  128. $_filename = 'logindata.php';
  129. $_handle = fopen($_filename, 'w');
  130. fwrite($_handle, $_string);
  131. fclose($_handle);
  132. }
  133. header("location:admin.php");
  134. }
  135.  
  136. if($_GET['do'] == 'take_right'){
  137. $_user2 = $_GET['user'];
  138. $_filename = "logindata.php";
  139. $_handle = fopen($_filename, "r");
  140. $_contents2 = fread($_handle, filesize($_filename));
  141. fclose($_handle);
  142.  
  143. $_divide3 = explode("&", $_contents2);
  144.  
  145. $_right2 = 0;
  146. while($_divide3[$_right2] != ''){
  147. list($username2, $password2, $email2, $admin2) = explode(";", $_divide3[$_right2]);
  148. if($username2 == $_user2){
  149. if($admin2 != '0'){
  150. $_data2 = "&".$username2.";".$password2.";".$email2.";0&";
  151. $_old2 = "&".$username2.";".$password2.";".$email2.";1&";
  152. $_string2 = str_replace($_old2, $_data2, $_contents2);
  153. }
  154. }
  155. $_right2++;
  156. }
  157. if($_string2 != ''){
  158. $_filename = 'logindata.php';
  159. $_handle = fopen($_filename, 'w');
  160. fwrite($_handle, $_string2);
  161. fclose($_handle);
  162. }
  163. header("location:admin.php");
  164. }
  165. }else{
  166. header("location:login.php");
  167. }
  168. ?>
  169.  
  170.  
  171. edit.php
  172.  
  173.  
  174. <?php
  175. ob_start();
  176. require("top.php");
  177. if($_SESSION['admin'] != 'df83hfg7ds'){
  178. header("location:login.php?do=admin");
  179. exit;
  180. }
  181. echo "<center><br><b><a href='admin.php'>Back to the Admin CP</a></b><br>";
  182. echo "<form method=post action=" . $_SERVER['PHP_SELF'] . "><input type=hidden name=action value=1><textarea cols=60 rows=20 name=edit class=textarea>";
  183. $file = "index.php";
  184. $fh = fopen($file, 'r');
  185. $theData = fread($fh, filesize($file));
  186. echo $theData;
  187. fclose($fh);
  188. echo "</textarea><br><br><input type=submit value=Save class=black></form>";
  189. if($_POST['action'] == '1')
  190. {
  191. $fh = fopen($file, 'w') or die("can't open file");
  192.  
  193. $stringData = $_POST['edit'];
  194. fwrite($fh,stripslashes($stringData));
  195. fclose($fh);
  196. header("Location: edit.php");
  197. }
  198. echo "</center>";
  199. ?>
  200.  
  201.  
  202.  
  203.  
  204. index.php
  205.  
  206. <?php
  207. ob_start();
  208. session_start();
  209. require("top.php");
  210. if (file_exists("setup.php")) {
  211. header('Location:setup.php');
  212. exit;
  213. }
  214. if($_SESSION['logged'] != '73de8dhas7'){
  215. header("location:login.php");
  216. exit;
  217. }
  218. echo "<br><center>";
  219. echo "<b>Welcome :))).</b><br><br>This is the password protected page.";
  220.  
  221. ?>
  222.  
  223.  
  224. login.php
  225.  
  226.  
  227. <?php
  228. ob_start();
  229. session_start();
  230. require("top.php");
  231. if (file_exists("setup.php")) {
  232. header('Location:setup.php');
  233. exit;
  234. }
  235. echo "<br><center>";
  236. echo "<form method='post' action='".$_SERVER['PHP_SELF']."'>";
  237. echo "<table>";
  238. echo "<tr><th>Username:</th><th><input type='text' name='username' class=form value='".$_POST['username']."'></th></tr>";
  239. echo "<tr><th>Password:</th><th><input type='password' name='password' class=form></th></tr>";
  240. echo "<input type='hidden' name='action' value='1'>";
  241. echo "</table>";
  242. echo "<input type='submit' value='Login' class=black>";
  243. echo "</form>";
  244.  
  245. if($_POST['action']=='1'){
  246. $_username = $_POST['username'];
  247. $_password = $_POST['password'];
  248. $_filename = "logindata.php";
  249. $_handle = fopen($_filename, "r");
  250. $_contents = fread($_handle, filesize($_filename));
  251. fclose($_handle);
  252. $_divide = explode("&", $_contents);
  253. $_array = 0;
  254. while($_divide[$_array] != ''){
  255. list($username, $password, $email, $admin) = explode(";", $_divide[$_array]);
  256.  
  257. if($username == $_username){
  258. if($password == $_password){
  259. // Set sessions and redirect
  260. $_SESSION['logged'] = '73de8dhas7';
  261. $_SESSION['username'] = $_username;
  262. if ($admin == '1'){
  263. $_SESSION['admin'] = 'df83hfg7ds';
  264. }
  265. header("location:index.php");
  266. }else{
  267. $_echo = "<br><b>Your username or password is incorrect</b><br>";
  268. }
  269. }else{
  270. $_echo = "<br><b>Your username or password is incorrect</b><br>";
  271. }
  272.  
  273. $_array++;
  274. }
  275.  
  276. echo $_echo;
  277.  
  278. }
  279.  
  280. if($_GET['do'] == 'logout'){
  281. $_SESSION['logged'] = '';
  282. $_SESSION['username'] = '';
  283. $_SESSION['admin'] = '';
  284. header("location:login.php?do=alogout");
  285. }
  286. if($_GET['do'] == 'alogout'){
  287. echo "<br><br><b>You have logged out</b><br>";
  288. }
  289. if($_GET['do'] == 'admin'){
  290. echo "<br><b>Error: You're not an Admin!</b><br>";
  291. }
  292.  
  293. if($_GET['do'] == 'new'){
  294. echo "<br><b>Congratulations! Your account has been created!</b><br>";
  295. }
  296. ?>
  297.  
  298.  
  299. members.php
  300.  
  301.  
  302. <?php
  303. ob_start();
  304. session_start();
  305. require("top.php");
  306. if (file_exists("setup.php")) {
  307. header('Location:setup.php');
  308. exit;
  309. }
  310. $_filename = "logindata.php";
  311. $_handle = fopen($_filename, "r");
  312. $_contents = str_replace("<?php /*&", "", str_replace("&*/?>", "", fread($_handle, filesize($_filename))));
  313. fclose($_handle);
  314.  
  315. $_divide = explode("&", $_contents);
  316. $_records = 0;
  317. while($_divide[$_records] != ''){
  318. $_records++;
  319. }
  320. $_array = 0;
  321. echo "<br><center>";
  322. echo "<table>";
  323. echo "<tr><td><b><center>Username</b></center></td><td><b><center>E-Mail</b></center></td></tr>";
  324. while($_divide[$_array] != ''){
  325. list($username5, $password5, $email5, $admin5) = explode(";", $_divide[$_array]);
  326. echo "<tr><td>".$username5."</td><td><a href=mailto:".$email5.">".$email5."</a></td>";
  327. $_array++;
  328. }
  329. echo "</table>";
  330. ?>
  331.  
  332.  
  333. newuser.php
  334.  
  335.  
  336. <?php
  337. ob_start();
  338. session_start();
  339. if($_SESSION['admin'] != 'df83hfg7ds'){
  340. header("location:login.php?do=admin");
  341. exit;
  342. }
  343. echo "<center>";
  344. echo "<form method='post' action='".$_SERVER['PHP_SELF']."'>";
  345. echo "<table>";
  346. echo "<tr><th><b>Username</b></th><th><b>Password</b></th><th><b>E-Mail</b></th><th><b>Admin (yes | no)</b></th></tr>";
  347. echo "<tr><th><input type='text' name='username' class=form value='".$_POST['username']."'></th><th><input type='text' name='password' class=form value='".$_POST['password']."'></th><th><input type='text' name='email' class=form value='".$_POST['email']."'></th><th><input type='text' name='admin' class=form value='".$_POST['admin']."'></th></tr>";
  348. echo "<input type='hidden' name='action' value='1'>";
  349. echo "</table>";
  350. echo "<input type='submit' value='Create New User' class=black>";
  351. echo "</form>";
  352. if($_POST['action'] == '1'){
  353.  
  354. $_filename = "logindata.php";
  355. $_handle = fopen($_filename, "r");
  356. $_contents = fread($_handle, filesize($_filename));
  357. fclose($_handle);
  358.  
  359. $_divide = explode("&", $_contents);
  360.  
  361. if($_POST['username'] == '' || $_POST['password'] == '' || $_POST['email'] == '' || $_POST['admin'] == ''){
  362. $_echo = "<br><b>Fill in all the fields!</b><br>";
  363. }else{
  364. $_array = 0;
  365. while($_divide[$_array] != ''){
  366. list($_username, $_password, $_email, $_admin) = explode(";", $_divide[$_array]);
  367. if($_username == $_POST['username']){
  368. $_echo = "<br><b>Username already exists</b><br>";
  369. }
  370. $_array++;
  371. }
  372. if($_echo != '<br><b>Username already exists</b><br>'){
  373. if ((ereg('[^A-Za-z0-9]', $_POST['username'])) || (ereg('[^A-Za-z0-9]', $_POST['password']))){
  374. $_echo = "<br><b>Please erase any illegal characters from the username and password fields (Space,._-/\{}, etc)";
  375. }else{
  376. if($_POST['admin'] == no){
  377.  
  378. $_data = $_POST['username'].";".$_POST['password'].";".str_replace(";", "", str_replace("<", "", str_replace(">", "", $_POST['email']))).";0&";
  379. $_contents = str_replace("*/?>", "", $_contents);
  380. $_data = $_contents.$_data."*/?>";
  381. $_filename = 'logindata.php';
  382. $_handle = fopen($_filename, 'w');
  383. fwrite($_handle, $_data);
  384. fclose($_handle);
  385. $_echo = "<br><b>Done.</b>";
  386. header("location:admin.php");
  387. }
  388. if($_POST['admin'] == yes){
  389.  
  390. $_data = $_POST['username'].";".$_POST['password'].";".str_replace(";", "", str_replace("<", "", str_replace(">", "", $_POST['email']))).";1&";
  391. $_contents = str_replace("*/?>", "", $_contents);
  392. $_data = $_contents.$_data."*/?>";
  393. $_filename = 'logindata.php';
  394. $_handle = fopen($_filename, 'w');
  395. fwrite($_handle, $_data);
  396. fclose($_handle);
  397. $_echo = "<br><b>Done</b>";
  398. header("location:admin.php");
  399. }else{
  400. $_echo = "<br><b>Admin values are <u>yes</u> or <u>no</u></b><br>";
  401. }
  402. }
  403. }
  404. }
  405. }
  406. echo $_echo;
  407. ?>
  408.  
  409.  
  410. register.php
  411.  
  412.  
  413. <?php
  414. ob_start();
  415. session_start();
  416. require("top.php");
  417. if (file_exists("setup.php")) {
  418. header('Location:setup.php');
  419. exit;
  420. }
  421. if($_SESSION['logged'] == '73de8dhas7'){
  422. echo "<center><br><b><u>Error</u>: <i>You are already registered!!!</i></b></center>";
  423. exit;
  424. }
  425. echo "<br><center>";
  426. echo "<form method='post' action='".$_SERVER['PHP_SELF']."'>";
  427. echo "<table>";
  428. echo "<tr><th>Username:</th><th><input type='text' name='username' class=form value='".$_POST['username']."'></th></tr>";
  429. echo "<tr><th>Password:</th><th><input type='password' name='password' class=form ></th></tr>";
  430. echo "<tr><th>Confirm password:</th><th><input type='password' name='confirmpassword' class=form ></th></tr>";
  431. echo "<tr><th>Email:</td><th><input type='text' name='email' class=form value='".$_POST['email']."'></th></tr>";
  432. echo "<input type='hidden' name='action' value='1'>";
  433. echo "</tr></table>";
  434. echo "<input type='submit' value='Register' class=black>";
  435. echo "</form>";
  436. if($_POST['action'] == '1'){
  437.  
  438. $_filename = "logindata.php";
  439. $_handle = fopen($_filename, "r");
  440. $_contents = fread($_handle, filesize($_filename));
  441. fclose($_handle);
  442.  
  443. $_divide = explode("&", $_contents);
  444.  
  445. if($_POST['username'] == '' || $_POST['password'] == '' || $_POST['email'] == ''){
  446. $_echo = "<br><b>Fill in all the fields!</b><br>";
  447. }else{
  448. if($_POST['password'] != $_POST['confirmpassword']){
  449. $_echo = "<br><b>Passwords do not match</b><br>";
  450. }else{
  451. $_array = 0;
  452. while($_divide[$_array] != ''){
  453. list($_username, $_password, $_email, $_admin) = explode(";", $_divide[$_array]);
  454. if($_username == $_POST['username']){
  455. $_echo = "<br><b>Username has been taken</b><br>";
  456. }
  457. $_array++;
  458. }
  459. if($_echo != '<br><b>Username has been taken.</b><br>'){
  460. if ((ereg('[^A-Za-z0-9]', $_POST['username'])) || (ereg('[^A-Za-z0-9]', $_POST['password']))){
  461. $_echo = "<br><b>Please erase any illegal characters from the username and password fields (Space,._-/\{}, etc)";
  462. }else{
  463. $_data = $_POST['username'].";".$_POST['password'].";".str_replace(";", "", str_replace("<", "", str_replace(">", "", $_POST['email']))).";0&";
  464. $_contents = str_replace("*/?>", "", $_contents);
  465. $_data = $_contents.$_data."*/?>";
  466. $_filename = 'logindata.php';
  467. $_handle = fopen($_filename, 'w');
  468. fwrite($_handle, $_data);
  469. fclose($_handle);
  470. $_echo = "<br><b>Done</b><br>";
  471. header("location:login.php?do=new");
  472. }
  473. }
  474. }
  475. }
  476. echo $_echo;
  477. }
  478. ?>
  479.  
  480. top.php
  481.  
  482.  
  483. <link rel="stylesheet" type="text/css" href="style.css" />
  484. <?php
  485. session_start();
  486. echo "<html><head><title>PHP Login System - CS Mod by The 008</title><meta http-equiv=Content-Type content=\"text/html; charset=windows-1251\"></head>\n";
  487. echo "<center><br><br><br><font size=2>";
  488. if($_SESSION['logged'] != '73de8dhas7')
  489. {
  490. echo "<a href=login.php><img src=images/login.gif></a><a href=register.php><img src=images/register.gif></a><a href=members.php><img src=images/members.gif></a>";
  491. }
  492. if($_SESSION['logged'] == '73de8dhas7' )
  493. {
  494. echo "<a href=index.php><img src=images/main.gif></a><a href=members.php><img src=images/members.gif></a>";
  495. if($_SESSION['admin'] == 'df83hfg7ds')
  496. {
  497. echo "<a href=admin.php><img src=images/admincp.gif></a>";
  498. }
  499. echo "<a href=login.php?do=logout><img src=images/logout.gif></a>";
  500. }
  501. echo "<br><br></font></center>";
  502. ?>
  503.  
  504. style.css
  505.  
  506.  
  507. <style type="text/css">
  508. <!--
  509. html, body {
  510. height: 100%;
  511. padding: 2px 15px 2px 15px;
  512. margin-left: auto;
  513. margin-right: auto;
  514. margin-bottom: 10px;
  515. }
  516. table { border-collapse: collapse;
  517. margin-left: auto;
  518. margin-right: auto;
  519. margin-bottom: 10px;
  520. }
  521. body {
  522. background: #4C5844;;
  523. font-family: Tahoma;
  524. font-size: 12px;
  525. color: white;
  526. }
  527. th { padding: 2px 15px 2px 15px;
  528. background-color: #4C5844;
  529. text-decoration: none;
  530. text-align: center;
  531. font-size: 12px;
  532. border: solid #889180 0px;}
  533. td { padding: 2px 15px 2px 15px;
  534. text-align: center;
  535. font-size: 12px;
  536. background-color: #4C5844;
  537. border: solid #889180 1px;}
  538.  
  539. img{ border:0;}
  540. a {
  541. font-family: Tahoma;
  542. color: C4B550;
  543. text-decoration: none;
  544. font-size: 12px;
  545. }
  546. a:visited {
  547. color: C4B550;
  548. text-decoration: none;
  549. }
  550. a:hover {
  551. color: C4B550;
  552. text-decoration: none;
  553. }
  554. a:active {
  555. color: C4B550;
  556. text-decoration: none;
  557. }
  558.  
  559. .form {
  560. font-family : Tahoma, Verdana, Arial ;
  561. border-color:#889180;
  562. border-top: #282E22;
  563. border-left: #282E22;
  564. border-right: #889180;
  565. border-bottom: #889180;
  566. color: #ffffff;
  567. border-style:solid;
  568. border-width:1px;
  569. background-color : #3E4637;
  570. }
  571.  
  572. .textarea {
  573. font-family : Verdana, Tahoma, Arial ;
  574. color: white;
  575. border-color:#838383;
  576. border-style:solid;
  577. border-width:1px;
  578. background-color : #4C5844;
  579. }
  580. .black {
  581. font-family : Tahoma, Verdana, Arial ;
  582. border-color:#889180;
  583. border-right: #282E22;
  584. border-bottom: #282E22;
  585. border-top: #889180;
  586. border-left: #889180;
  587. color: #C4B550;
  588. border-style:solid;
  589. border-width:1px;
  590. background-color: #4C5844; }
  591. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement