Yii Framework Forum: Yii Toggle Maintenance Mode On/off - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii Toggle Maintenance Mode On/off

#1 User is offline   Sergio_HW 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 30-December 13

Posted 04 April 2014 - 03:58 AM

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.

This allow to admin continue seeing the web but the rest of the visitors not.

I have read about catchAllRequest, creating a file and renaming it when is necessary, but I cant make it work.

I have tried underconstruct extension, but I dont know how to toggle ON/OFF.

This is what I have at the moment.

CONTROLLER:

public function actionIndex()
    {
        $location = Yii::app()->request->baseUrl.'/protected/config/maintenanceON.txt';
        $new = Yii::app()->request->baseUrl.'/protected/config/maintenanceOFF.txt';
        Yii::app()->session['secret'] = "password";
        rename($location,$new);
        $this->renderPartial("index");
    }

CONFIG/MAIN.PHP :

'catchAllRequest'=>file_exists(
        dirname(__FILE__).'/maintenanceON.txt') && 
            !(Yii::app()->user->checkAccess('admin') ?
                array('maintenance/index') : null,

Thanks!
0

#2 User is offline   paskuale 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 415
  • Joined: 30-December 11
  • Location:Italy, Bari

Posted 09 December 2014 - 06:11 AM

Any solutions :) ?
0

#3 User is offline   yiim 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 148
  • Joined: 28-June 12
  • Location:Germany

Posted 09 December 2014 - 11:11 AM

Maybe https://www.google.d...aintenance+mode
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users