Jump to content

_Unique_

Members
  • Posts

    29
  • Joined

  • Last visited

Everything posted by _Unique_

  1. Okay, thanks for the replies. I decided to create an install.tmp file, my script when then check if the file exists, if it does not exist, then continue to load the web page. If it does exist, then redirect to the installer. Once the user has installed the website, the install.tmp file will automatically be deleted. Thanks!
  2. Hello, I am currently working on a project. I am wanting to implement a theme/template system, where the user can install themes/templates which will upload the folder/files into the theme folder where the website will scan all directories inside the theme folder and list all directories found, as themes. However, I cannot figure out how I can go about creating this. I am really confused, especially as I have tried countless times attempting to organize and plan the system in my head in the past couple of weeks. Could someone please explain to me, how I could go about doing this? As I said before, I already tried to have the name of the main theme in the database, where I would retrieve that name of the theme via a query. But then I couldn't figure out how I could link all the stylesheets that was in the theme folder. (If that makes sense, unfortunately I am so confused, that nothing is currently making sense - if that makes sense..) Anyway, I pretty much need to figure this out, with some help from you Thanks in advance, Unique
  3. Hello, I am creating a CMS, I am currently wanting to create a function which checks if the website is installed. I have attempted this before, by checking if a database connection existed, if it did, then the website was installed, if there wasn't, then the user will be automatically redirected to the installer. However, after creating all of that, I realized that this wouldn't work, simply because if the database server is offline or the database was renamed, or whatever reason, the website would think that it isn't installed, therefore could break the website. Plus, this restricted me adding more functions to the website, such as database repair, etc. However, I have reached a brick wall. I cannot figure out a way I can go about doing this. I searched via Wordpress as they have created an installation that checks if the blog is installed, but that did not help as it just reached off to different functions, etc, and I didn't know how they made every page check if the website was installed, without having to include/require the file on every page, which would require the user more work when creating more pages because then they have to start copying and pasting lines from other pages, etc, just for the page to be fully functional, which really, really is inefficient, and a really bad idea, especially when this could go public, depending on the progress, etc. Thanks in advance, Unique P.S - I hope this is clear enough, if it is too vague, make sure too tell me.
  4. Hello, I am currently creating a gaming website template, however, I am thinking about changing it to a multi-purpose, the reason for this is because I am looking for a professional color scheme and layout with a mixture of grays, blacks, etc. I have this current scheme and layout, however I am not overly keen with this color scheme, I like the layout (That's cause I made it that way :S) but after numerous attempts of trying to get the perfect color scheme for this layout, I have failed, yet again. So, I have come to you, asking if you have any ideas for a better color scheme, I will also accept any layout improvements or font improvements, etc. This is a screenshot of the progress so far: Screenshot Thanks in advance, Unique P.S - I apologize if this is in the wrong category, I couldn't find any other categories that fitted this question any better than CSS.
  5. If I configure the HTTP server to display a 500 error page, how would I display a specific error to the user, for example, if there was no connection to the license server, then send the user to the 500 error page, where they will be told that there is no connection to the license server, probably because the connection is/was being tampered or the server is actually temporarily offline. Thanks in advance, Unique
  6. Hello, I am trying to create a custom error page using a function. So whenever there is an error, such as en error connecting to the database it shows the custom error page. I believe wordpress has the same feature? Not sure, read it online somewhere when I tried to search how to do it. I would rather use this function instead of using the die() function because I do not want the page to be reset, I want the content to disappear but the style to remain. I have created a function for this to work but when the user gets the error page, you can also see the normal, ugly mysqi error, I have tried error_reporting(0) but it didn't hide the mysqli error message. So, here is my code; function errorDie($title = '', $error = 'An error has occured!') { echo '<h3 class="title"><strong>Error: </strong>'.$title.'</h3><hr /><p>'.$error.'</p>'; // Hide any errors error_reporting(0); } Thanks in advance, Unique
  7. Hello, I am trying to replace strings in another php file. The strings I am trying to change determine the database connection (the ip, user, etc). I am using str_replace() however, when the functions process they wipe the whole file leaving nothing inside it, whereas there was the strings, etc there before. This is my code that is supposed the change the strings: $connectFile = $_SERVER['DOCUMENT_ROOT'].'/config/connect.php'; $connectContents = file_get_contents($connectFile); $connectContents = str_replace('', $_SESSION['dbHost'], $host); $connectContents = str_replace('', $_SESSION['dbUser'], $user); $connectContents = str_replace('', $_SESSION['dbPass'], $pass); $connectContents = str_replace('', $_SESSION['dbName'], $db); file_put_contents($connectFile, $connectContents); echo 'Install Finished!'; And this is my connect.php, the file which contains the strings that needs to be changed; <?php $host = ''; $user = ''; $pass = ''; $db = ''; $dbc = mysqli_connect($host, $user, $pass, $db) or errorDie('Cannot connect to database!', 'Unfortuantly, there was an error with the connection to the database. If you are the site admin, please try and resolve this issue. Sorry for any inconvenience.'); ?> Thanks in advance, Unique
  8. Okay, is there a way I can send the user to the install.php without getting a redirect loop? I have this following script that I tried to get working, but for some reason, I keep getting the redirect loop error; <?php function isInstalled() { if(!file_exists($_SERVER['DOCUMENT_ROOT'].'/config/config.php')) { header('Location: http://'.$_SERVER['HTTP_HOST'].'/admin/install/setup.php?step=0'); exit; } } ?> Thanks EDIT: Nevermind, I forgot to unlink the isInstalled() function from the setup.php. How dumb of me :/
  9. I don't think it is inefficient, I was just wondering if there is any 'better' ways of doing this. Thanks for the reply
  10. Hello, I am still attempting to create a website installer via PHP, I have spent at least 2 weeks on trying to get my script working. The script I have is the base of the installer, it automatically assigns the user a step value via URL, I will then obtain that value via the $_GET method. Whatever step value that is found in the URL is the current step of the user, and the information, etc will only be shown for that step. However, I have a problem, on Step 1, when the user has filled the form the form will submit, but the values will not be kept for step 2, 3, etc. I am aware that you can store the values either by sessions or localstorage, but I am wondering if there is a more efficient method of doing this. This is the installer page, that requires the manager file. This is what the user will see once the install page has loaded; <?php require('manager.php'); ?> <!DOCTYPE HTML> <html> <head> <title>Website > Setup Configuration</title> <link rel="stylesheet" type="text/css" href="css/styles.css" /> <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700' rel='stylesheet' type='text/css'> </head> <body> <?php switch($currentStep) { /* Content For Step 0 */ case 0; echo ' <p>Welcome to Website, before getting started we need some information about your MySQL database. You will need the following items before proceeding;</p> <ol> <li>Database host</li> <li>Database username</li> <li>Database password</li> <li>Database name</li> </ol> <p>The information is going to be stored via FTP to establish a location between your website, and your database. If you are unaware of how to find these details, you can usually find them via your web hosting cPanel, if not, you can contact your web hoster.</p> <p>Once you have the above details, press ‘Start install‘.</p> <a href="install.php?step=1" class="next">Start install</a> '; break; /* Content For Step 1 */ case 1; echo ' <p>Please enter the required MySQL details.</p> <form action="" method="post"> <table> <tr> <td><label for="db-host">Database host</label></td> <td><input type="text" name="db-host" /></td> <td></td> </tr> <tr> <td><label for="db-username">Database username</label></td> <td><input type="text" name="db-username" /></td> <td></td> </tr> <tr> <td><label for="db-password">Database password</label></td> <td><input type="password" name="db-password" /></td> <td></td> </tr> <tr> <td><label for="db-name">Database name</label></td> <td><input type="text" name="db-name" /></td> <td></td> </tr> <tr> <td><input type="submit" name="db-submit" class="next" value="Next" /></td> </tr> <tr> <td>'.$message.'</td> </tr> </table> </form> '; break; /* Content For Step 2 */ case 2; echo ' <div id="outer-container"> <div id="inner-container"> <p>You need to create an administrator account for use on your website.</p> </div> </div> '; break; /* Content For Step 3 */ case 3; echo ' <div id="outer-container"> <div id="inner-container"> <p>You have now finished the setup! Expecting more steps?</p> </div> </div> '; break; } ?> </body> </html> And this is the manager.php, that is required by the install.php, the manager.php manages the background scripts, etc for the install.php. <?php $currentStep = $_GET['step']; $message = ''; if($currentStep == null || $currentStep == '') { header('Location: install.php?step=0'); exit; } if($currentStep > 3) { die('Invalid Step!'); } if(isset($_POST['db-submit'])) { if(empty($_POST['db-host']) || empty($_POST['db-username']) || empty($_POST['db-password']) || empty($_POST['db-name'])) { $message = 'Please fill in the required fields!'; }else { $dbHost = $_POST['db-host']; $dbUser = $_POST['db-username']; $dbPass = $_POST['db-password']; $dbName = $_POST['db-name']; define('DB_HOST', $dbHost, true); define('DB_USER', $dbUser); define('DB_PASS', $dbPass); define('DB_NAME', $dbName); header('Location: install.php?step=2'); exit; } } ?> Once there is a more efficient method of what I am attempting to do, I am going to implement other features such as checking if there is a database connection once the user has entered the details, etc. Oh by the way, I would rather the more 'efficient' method to be for PHP and not jQuery, etc, and I am not asking for someone to rewrite a script for me, I am just asking for someone to explain a more efficient method (thats how I learn best, but if you want to write me a script, then please leave messages explaining the different functions, etc). Thanks in advance, Unique
  11. Yep, the parseInt() worked, thanks! Oh, and for future references for myself or anyone else; I decided to change from localStorage() to sessionStorage() because sessionStorage did not reset on refresh, but reset on tab/browser close, which is perfect for what I am creating, whereas localStorage cannot be cleared on only browser close, you can only set it to clear on refresh and tab/browser closed, unfortunately.
  12. Okay, for some reason this post has been made 3 times.. I have reported it to a moderator.
  13. Hello, I am attempting to create an install wizard, and when the 'next' button is pressed, the step variable that is stored in localStorage is added +1. So if the variable in localStorage was 1, I wanted to add 1 to the variable to become 2. However, so far what I have made is when the script is run, and the variable is added +1 to, but not how I would like it. At the moment, what it does is adds a 1 at the end of the variable, so if the variable was 1, the variable would become 11, and not 2. This is my script so far; <script> $(document).ready(function () { var currentStep = 0; if(localStorage.getItem('Step') === null) { localStorage.setItem('Step', currentStep); } $('#next').click(function() { currentStep = localStorage.getItem('Step'); nextStep = currentStep + 1; localStorage.setItem('Step', nextStep); alert(localStorage.getItem('Step')); }); }); </script> I am fairly new to jQuery/Javascript, so it could be something real simple that I am missing. Thanks in advance, Unique
  14. Wow, only just seen everything you have posted! Thanks, this is extremely helpful!
  15. Sorry, I dont fully understand the coding, please could you break it up, explaining what each part does? Thanks
  16. Okay, I have so far created this script: <script> $(document).ready(function() { var step = '0'; localStorage.setItem('stepValue', step); localStorage.getItem('stepValue'); $('#start-install').click(function() { var step = '1'; alert(step); localStorage.setItem('stepValue', step); }); }); </script> It works great, when I click the #start-install button, the variable 'step' changes to two, which is what I wanted, but again it wont save and keep the variables when the page is refreshed. Please tell me where I am going wrong with this. Thanks in advance
  17. Well, I have never used AJAX before and I know the basics of javascript. But I am always open to learn new languages Thinking about it, more and more, I am starting to believe I made a huge mistake building it server side, I did originally build it from Javascript, but it got messy, real quick, but it worked. So I thought making it server side would be easier, but its not.
  18. Okay thanks, I will add a line that will store the variables, thats pretty easy. But what my main problem is, how do I stop it from going back to Step 0?
  19. Hello, I am creating a PHP installer for my website, it is currently only basic because It is my first time building the installer, and I want to make sure that everything works. So I am using sessions to contain what steps the user is on, and when the user first enters the install page, the session gets created and a Step session variable is also created, forcing the user to start on step 0 (the introduction), once the user starts the install, it will progress to step 2, etc. So here is my code: <?php /* Create a new session to hold the step values */ session_start(); /* Force start on step 0 when page load, via session */ $step = isset($_SESSION['step']) ? intval($_SESSION['step']) : 0; /* Check if the submit button was pressed */ if(isset($_POST['start-install'])) { $step = 1; } $message = ''; ?> <!DOCTYPE html> <html> <head> <title>CMS Website : Installer</title> <link rel="stylesheet" type="text/css" href="css/styles.css" /> <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,700' rel='stylesheet' type='text/css'> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> </head> <body> <div id="form-box"> <?php if($step == 0) { echo (' <h3>CMS Installer</h3> <p>You <small>MUST</small> install the website for it to function correctly.</p> <form method="post"> <div align="center"><input type="submit" name="start-install" value="Start Install" style="cursor: pointer;" /></div> </form> '); }else if($step == 1) { echo (' <h3>CMS Installer ~ Step 1</h3> <p>Please fill in the form with the appropriate details</p> <form method="post" id="db-form"> <input type="text" name="db-host" placeholder="Database Host" /> <input type="text" name="db-username" placeholder="Database Username" /> <input type="password" name="db-password" placeholder="Database Password" /> <input type="text" name="db" placeholder="Database Name" /> <input type="submit" name="submit-db" value="Submit Database" /> </form> '); if(empty($_POST['db-host'])) { $message = 'You must complete the form!'; } }else if($step == 2) { echo ('Create your administrator account!'); } ?> </div> </body> <script type="text/javascript"> $('#db-form').submit(function(e) { e.preventDefault(); }); </script> </html> So, my problem is when the user clicks the submit button, my script checks if the 'host' box is empty (I will include the rest once this problem is fixed) but instead of displaying the $message variable, the page automatically refreshes and starts back to step 0, resetting the session variables. As you can see from my script, I attempted to stop the page from refreshing once the form was submitted using Javascript, and that worked, but it stopped my PHP script from functioning correctly, for some reason. So, if anyone could help me with preferably a fix, or a workaround, that would be great! Thanks in advanced, Unique
  20. Okay, thanks, how would I go about doing it with session values?
  21. The page I am creating is an install script, it automatically connects the database, creates the admins, uploads the database, etc. There are going to be steps, that the user has to follow, starting from step 0, which I am hoping to force the user to start on that step. As it is an install script, I have made it so any page that the user attempts to load, they will be automatically redirected to the install page, until the website is setup. I have already created this script, and it is fully functional. I just need help with creating each step, so when the user first starts the install, they will start on step 0, then when they have finished step 0, they can press the next button, which will take them to step 1, etc. I just need help forcing the user to start on step 0, and then automatically changing the Step value in the url. I already know how to pull the value from the url. Sorry about not giving enough information, hopefully this makes it more clearer.
  22. Hello, I know this question has been previously asked either on this forums or elsewhere, but all of the questions I could find were asking for the path, whereas I am asking for the value. Okay, now for the question and explanation. How can I get the value from a url, for example; If the url is http://mywebsite.com/install/install.php?step=2 How could I get the value 2 so I can only show the content for that step and not for any other step. Thanks in advance, Unique EDIT: Okay, I just solved my own question with $_GET['step']. But I have another question, how could I automatically assign a step to the user once they are on the page, so the will automatically start on Step 0 (the introduction) then move onto step 1 once the have pressed a link or a button, then move onto step 2, etc, etc.
  23. Okay, I never thought of it that way, thanks! But I also have another method that could work, which I would prefer to do. I am soon going to do some research on how to do it, but I wanted to go here first, Would I be able to generate the config.php file in the setup.php, which will then create a file called config.php and then put the contents into the config.php. Sorry if that does not make sense. Thanks in advance, Unique
  24. Hello, I am new to PHP, so I decided the best way to learn is to build a CMS, that I can build and adapt as time progresses. I am wanting to create a setup/install wizard for when a user first uploads the website and then visits the website. I attempted to do this on my own, but it did not work, but hey I still included the code in-case I was close to getting it working. (See below). I am wanting to have a HTML form that will contain the input fields, where the user will enter their database host, username, and password. And all of the details in the form will replace the mysqli connection in the config.php file, which is seperate from the install file. That is all I really need help with at the moment, as creating users, etc is pretty easy (even though I am new to PHP). My "attempted" code: - Install.php: <?php /* Config required to replace the database strings */ require('config/config.php'); /* HTML Form to be echoed for the user */ $form = " <form name='form' action='' method='get'> <input type='text' name='host' placeholder='Database host' /> <input type='text' name='database' placeholder='Database name' /> <input type='text' name='username' placeholder='Database username' /> <input type='password' name='password' placeholder='Database password' /> <input type='submit' name='submit' value='Change values' /> </form> "; /* Echo the form so I can see it */ echo $form; /* Get the results from the HTML Form */ $gethost = $_GET['host']; $getdb = $_GET['database']; $getuser = $_GET['username']; $getpass = $_GET['password']; /* Replace the database connections in config.php */ /* However, does not work :/ */ if (isset($_GET['submit'])) { str_replace($gethost,$host); } ?> - Config.php: <?php $host = "localhost"; $username = "root"; $password = ""; $database = "website"; /* Change this line in the HTML Form in setup.php */ $dbc = mysqli_connect($host, $username, $password, $database); ?> Thanks in advanced, Unique
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.