Jump to content

_Unique_

Members
  • Content Count

    29
  • Joined

  • Last visited

Community Reputation

0 Neutral

About _Unique_

  • Rank
    Member
  1. _Unique_

    Checking if website is installed

    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. _Unique_

    How to create a custom error page

    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. _Unique_

    More efficient way of creating an installer

    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. _Unique_

    More efficient way of creating an installer

    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. _Unique_

    Adding to a variable stored in localStorage

    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. _Unique_

    Adding to a variable stored in localStorage

    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. _Unique_

    Creating an install/setup wizard for my cms

    Wow, only just seen everything you have posted! Thanks, this is extremely helpful!
×

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.