Advertisement
Guest User

Untitled

a guest
Aug 7th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.26 KB | None | 0 0
  1. <?php
  2. /*
  3. * Tracker Suite v0.1
  4. * Requires: PHP & MySQL
  5. * ---------
  6. * Most hosting providers will usually say if they have PHP or not.
  7. * If you want to locally host it, I recommend LAMP for Linux, or Xampp for winblows.
  8. *
  9. */
  10.  
  11. /* README
  12. * The user and password you define below shouldn't already exist. These will be created.
  13. * You will be prompted once to provide a username and password that can create a user
  14. * and delegate privileges.
  15. */
  16.  
  17. // MySQL defines:
  18. $SQL_HOSTNAME = "localhost";
  19. $SQL_DBNAME = "tracker102";
  20. $SQL_USER = "tracker102";
  21. $SQL_PASS = "lawlerbawler1039";
  22.  
  23.  
  24. // Functions
  25.  
  26. function check_for_db($_host,$_user,$_pass,$_dbname) {
  27.     $link = mysqli_connect($_host,$_user,$_pass,$_dbname);
  28.     if(!$link) {
  29.         echo "<div class='track_error'>MySQL connect error (" . mysqli_connect_errno() . ") : " . mysqli_connect_error() . ".</div></br></br>";
  30.         return mysqli_connect_errno();
  31.     }
  32.     else {
  33.         return 0;
  34.     }
  35. }
  36.  
  37. function tracker_setup() {
  38.     if ( isset($_POST['_sqluser']) && isset($_POST['_sqlpass']) && isset($_POST['_sqlhost']) ) {
  39.         $setuplink = mysqli_connect($_POST['_sqlhost'], $_POST['_sqluser'], $_POST['_sqlpass']);
  40.         if ( !$setuplink ) {
  41.             echo "<div class='track_error'>MySQL connect error (" . mysqli_connect_errno() . ") : " . mysqli_connect_error() . ".</br></br>";
  42.             echo "<b>Press the back button and please correct the error.</b></br>";
  43.             return mysqli_connect_errno();
  44.         }
  45.         echo "Attempting to create user and database now...";
  46.        
  47.     }
  48.     else {
  49.         echo "
  50.         <b>Please enter existing account details that can setup a database, create users, and delegate privileges.</br>
  51.         This will use a personal account only once to create a user and a database just for interacting with software and the databases it creates.</br>
  52.         </b>
  53.         *Make sure you change your MySQL defines in the source code before doing this.</br></br>
  54.         <form action='' method='POST'>
  55.         Username <input type='text' name='_sqluser' /></br>
  56.         Password <input type='password' name='_sqlpass' /></br>
  57.         Hostname <input type='text' name='_sqlhost' /></br>
  58.         <input type='submit' />
  59.         </form>
  60.         ";
  61.     }
  62. }
  63.  
  64. ?>
  65.  
  66. <html>
  67. <head>
  68. <title>Tracker Suite</title>
  69. <style>
  70. html, body {
  71.     margin:0;
  72.     padding:0;
  73. }
  74.  
  75. body {
  76.    
  77. }
  78.  
  79. header {
  80.     display:block;
  81.     padding:1%;
  82.     text-align:center;
  83.     font-size: 2em;
  84.     font-weight:bold;
  85.     border-bottom:2px double black;
  86. }
  87.  
  88. nav {
  89.     display:block;
  90.     padding:0.2%;
  91.     font-size:1.1em;
  92.     border-bottom:2px double black;
  93. }
  94.  
  95. .nav_button {
  96.     padding-right:4%;
  97.     padding-left:4%;
  98.     margin-right:0.1%;
  99.     margin-left:0.1%;
  100.     background-color:blue;
  101.     color:black;
  102.     border:1px solid black;
  103.     text-decoration:none;
  104. }
  105.  
  106. .nav_button:hover {
  107.     background-color:gray;
  108.     text-decoration:underline;
  109. }
  110.  
  111. article {
  112.     margin:0.5%;
  113.     padding:0.5%;
  114.     height:80%;
  115.     border:2px double black;
  116.    
  117. }
  118.  
  119. footer {
  120.     position:absolute;
  121.     width:100%;
  122.     bottom:0;
  123.     left:0;
  124.     text-align:center;
  125.     font-size:12px;
  126.     background-color:gray;
  127.     border-top:1px solid black;
  128. }
  129.  
  130. .nav_button, article {
  131.         /* Firefox Curved Borders */
  132.     -moz-border-radius:3px;
  133.         /* Chrome Curved Borders */
  134.     border-radius:3px;
  135. }
  136.  
  137. .track_error {
  138.     display: block;
  139.     padding: 0.5%;
  140.     width: 100%;
  141.     background-color:black;
  142.     color:red;
  143.     font-weight:bold;
  144.     font-size:16px;
  145.     border-bottom:1px solid black;
  146.     text-align: center;
  147. }
  148. </style>
  149. </head>
  150. <body>
  151.     <header>Tracker Suite</header>
  152.     <nav><a class="nav_button" href="?action=new">New</a><a class="nav_button" href="?action=load">Load</a></nav>
  153.     <article>
  154.     <?php
  155.         $x = check_for_db($SQL_HOSTNAME, $SQL_USER, $SQL_PASS, $SQL_DBNAME);
  156.         if( $x != 0 ) {
  157.             // If it is a permission error, then that account is most likely not set up.
  158.             if ( $x == 1045 || $x == 1046 ) {
  159.                 tracker_setup();
  160.                 if ( $x == 1049 ) {
  161.                     echo "Cannot find the database, attempting to create one...</br>"; // EDIT HERE
  162.                     // try to login and create a new database.
  163.                 }
  164.             }
  165.             else {
  166.                 // I have no idea what happened, so let them fix it / deal with it. :)
  167.                 die("Please address the error above.");
  168.             }
  169.         }
  170.         if($_GET['action'] == "new") {
  171.             // load a creation form
  172.         }
  173.         elseif($_GET['action'] == "load") {
  174.             // load a selection
  175.         }
  176.     ?>
  177.     </article>
  178.     <footer>Tracker Suite || Code and design by Machiavelli @ breakingsec.org</footer>
  179. </body>
  180. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement