klenwell information services : SpecialCocktailNapkin

Revision [2062]

This is an old revision of SpecialCocktailNapkin made by KlenwellAdmin on 2012-01-17 11:41:35.
 

online cocktail napkin

links and notes for later organization

Somewhat Improved Wikka Installed Routined
Diff for wikka.php:
diff -r c8f8537f5e21 -r 4e091af5eacf php/wikka/wikka.php
--- a/php/wikka/wikka.php	Tue Jan 17 10:01:24 2012 -0800
+++ b/php/wikka/wikka.php	Tue Jan 17 11:43:38 2012 -0800
@@ -509,11 +509,15 @@
 
 /**
  * Compare versions, start installer if necessary.
+ * Wait to start installer below if this is an upgrade so we can limit access
+ * to admin users.
  */
-if (!isset($wakkaConfig['wakka_version'])) $wakkaConfig['wakka_version'] = 0;
-if ($wakkaConfig['wakka_version'] !== WAKKA_VERSION)
-{
-	/**
+$is_new_install = ! isset($wakkaConfig['wakka_version']);
+$is_upgrade = $wakkaConfig['wakka_version'] !== WAKKA_VERSION;
+
+if ( $is_new_install ) {
+    $wakkaConfig['wakka_version'] = 0;
+    /**
 	 * Start installer.
 	 *
 	 * Data entered by the user is submitted in $_POST, next action for the
@@ -590,6 +594,7 @@
 	exit;
 }
 
+
 /**
  * Save session ID
  */
@@ -611,6 +616,39 @@
 }
 
 /**
+ * Check for upgrade. If so an user is admin, show setup page, else show
+ * a maintenance message to all other visitors.
+ */
+$is_admin = $wakka->IsAdmin($user);
+$at_install_step = ($_GET['installAction'] == 'writeconfig') && (isset($_POST['config']));
+$upgrade_allowed = $is_admin || $at_install_step;
+
+if ( $is_upgrade && $upgrade_allowed ) {
+	$installAction = 'default';
+	if (isset($_GET['installAction'])) $installAction = trim($_GET['installAction']);	#312
+	if (file_exists('setup'.DIRECTORY_SEPARATOR.'header.php'))
+	include('setup'.DIRECTORY_SEPARATOR.'header.php'); else print '<em class="error">'.ERROR_SETUP_HEADER_MISSING.'</em>'; #89
+	if
+	(file_exists('setup'.DIRECTORY_SEPARATOR.$installAction.'.php'))
+	include('setup'.DIRECTORY_SEPARATOR.$installAction.'.php'); else print '<em class="error">'.ERROR_SETUP_FILE_MISSING.'</em>'; #89
+	if (file_exists('setup'.DIRECTORY_SEPARATOR.'footer.php'))
+	include('setup'.DIRECTORY_SEPARATOR.'footer.php'); else print '<em class="error">'.ERROR_SETUP_FOOTER_MISSING.'</em>'; #89
+	exit;
+}
+elseif ( $is_upgrade && $_GET['install_help'] ) {
+    print "<h2> POST,GET, SESSION variables</h2>";
+    print '<pre>';
+    var_dump($_POST);
+    var_dump($_GET);
+    var_dump($_SESSION);
+    print '</pre>';
+}
+elseif ( $is_upgrade ) {
+    die('<h2>Site Undergoing Temporary Maintenance</h2><h4>Please check back shortly.</h4>');
+}
+
+
+/**
  * Run the engine.
  */
 if (!isset($handler)) $handler='';


IKEA Stand-Up Desks
http://news.ycombinator.com/item?id=3442809
http://www.ikea.com/us/en/catalog/products/00115992/
http://www.ikea.com/us/en/catalog/products/60111123/


CategorySpecial