Jump to content

[SOLVED] Change the index file with php


Lamez

Recommended Posts

It can be done in many different ways, probably the easiest though is to set a constant within some sort of configuration file (this file could be editable vai your control panel), then simply check what is is set to within your index page. eg;

 

config.php

<?php

  define("SITE_IS_LIVE",FALSE) ; // set to TRUE to make site active.

?>

 

index.php

<?php

  if (!SITE_IS_LIVE) {
    die("Under Construction");
  }

  // rest of site.

?>

Link to comment
Share on other sites

One easy way would be to load a page with a form in it. This form would display the config.php for editing. Once you submit the form, the changes are saved. Something like....

 

editconfig.php

<?php

  if (isset($_POST['submit'])) {
    $f = fopen("config.php","w");
    fwrite($f,$_POST['config']);
    fclose($f);
  } else {
    $f = fopen("config.php","r");
    $config = fread($f, filesize("config.php"));
    fclose($handle);
    echo "<form method='post'>";
    echo "  <textarea name='config'>$config</textarea>";
    echo "  <input type='submit' name='submit' value='save'>";
    echo "</form>";
  }

?>

Link to comment
Share on other sites

Wow, you guys are making wayyyyyyyyy to complicated..

 

just make a database table called WEBSITE_STATS, and have a coloumn called online...

 

Just update the coloumn online to false or true from the admin panel...

 

<?php

///Top Of the Page

$query=mysql_fetch_assoc(mysql_query("SELECT * FROM WEBSITE_STATS"));

if($query['online']=="false"){

die("Sorry, Website Has Been Disabled by the admin...");

}


?>

Link to comment
Share on other sites

The problem with using a database for such tasks is sometimes you want to close the site so you can actually do some database maintanence, and sometimes this will involve taking the db offline.

 

I allways use simple files for configurations. Much easier to handle, and more reliable.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.