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.

?>

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>";
  }

?>

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...");

}


?>

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.

Archived

This topic is now archived and is closed to further replies.

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