title: yii toggle maintenance mode ON/OFF
body: <p>I am trying to make a maintenance mode in my website, I want to put a button that only the admin can see to toggle the maintenance mode ON/OFF. </p>
  
  <p>This allow to admin continue seeing the web but the rest of the visitors not. </p>
  
  <p>I have read about catchAllRequest, creating a file and renaming it when is necessary, but I cant make it work.</p>
  
  <p>I have tried underconstruct extension, but I dont know how to toggle ON/OFF.</p>
  
  <p>This is what I have at the moment.</p>
  
  <p><strong>CONTROLLER:</strong></p>
  
  <pre><code>public function actionIndex()
      {
          $location = Yii::app()-&gt;request-&gt;baseUrl.'/protected/config/maintenanceON.txt';
          $new = Yii::app()-&gt;request-&gt;baseUrl.'/protected/config/maintenanceOFF.txt';
          Yii::app()-&gt;session['secret'] = "password";
          rename($location,$new);
          $this-&gt;renderPartial("index");
      }
  </code></pre>
  
  <p><strong>CONFIG/MAIN.PHP :</strong></p>
  
  <pre><code>'catchAllRequest'=&gt;file_exists(
          dirname(__FILE__).'/maintenanceON.txt') &amp;&amp; 
              !(isset(Yii::app()-&gt;session['secret']) &amp;&amp; Yii::app()-&gt;session['secret']=="password") ?
                  array('maintenance/index') : null,
  </code></pre>
  
  <p>Thanks!</p>