Clients shut out of site by former developer

Hi there - I have been asked to help a small business with getting access to manage their site. For example, they have no access to add or update their main navigation menu, and there are many other features they have been shut out from by the original developer.6610

no-access.png

I am new to Yii, but not to CMS technology. Can anyone recommend a strategy? So far I have documented 5 different user rights modules/extensions. The clients’ site is on Yii v. 1.1.15. They’d originally requested a WordPress site and what they have is a highly restricted Yii site.

Thank you in advance for any help you can lend.

Willa

I have no idea what the relevance of that image might be, but about getting access. You might start by showing us the config file (remove the db passwords for security reasons before showing here ofc). And show the accessRules() function of the controller that gives access to the functionality you are interested in getting access to.

Thank you so much, Ronald. The "protected/config/main.php" file shows no standard config, like:

        'db'    =>  array(


            'connectionString'  =>  'mysql:host=mysql.web-site.domain.net;dbname=mydb',


            'username'          =>  'myDB',


            'password'          =>  'myPassword',

And, instead, the main.php shows:

'db'    =>  array(


        'class'             =>  'application.components.db.DbConnection',


        'emulatePrepare'    =>  true,


        'charset'           =>  'utf8',


        'charsetVarsValue'  =>  true,


        'initSQLs'          =>  array(


            //"SET time_zone = '+00:00';",


        ),

I am not an engineer, and have no idea of the significance of using a db connection based on a class and component, and that was not covered in the tutorial.

Hi Ronald, Thank you so much for trying to help.

I was having a problem with spam when I replied, but it seems cleared up for now.

As I mentioned, the conf file is not the standard, so my newbie training is not following the right model. I’m including the full main.php file here:

<?php

// This is the main Web application configuration. Any writable

// CWebApplication properties can be configured here.

isset($webroot) || ($webroot = rtrim(dirname($_SERVER[‘SCRIPT_NAME’]), ‘/’.DIRECTORY_SEPARATOR));

Yii::setPathOfAlias(‘bootstrap’, dirname(FILE).DIRECTORY_SEPARATOR.’…’.DIRECTORY_SEPARATOR.‘extensions’.DIRECTORY_SEPARATOR.‘YiiBooster’);

return array(

'basePath'  =&gt;  &#036;basePath = dirname(__FILE__).DIRECTORY_SEPARATOR.'..',


'name'      =&gt;  'A Small Business',


'language'  =&gt;  'en',





// preloading 'log' component


'preload'   =&gt;  array(


    'log',


    'response',


),





// autoloading model and component classes


'import'    =&gt;  array(


    'application.models.*',


    'application.components.*',


    'application.components.db.*',


    'application.components.web.*',


    'application.components.user.*',


    'application.components.search.*',


    'application.components.helpers.*',


    'application.components.validators.*',


    'bootstrap.helpers.*',


    'application.components.menu-items.*',


    'application.extensions.ShoppingCart.*',


    'application.components.basket.BasketEntity',


),


'aliases' =&gt; array(


    'xupload' =&gt; 'ext.xupload',


),


'modules'   =&gt;  array(


    'page'      =&gt;  array(


        'class'     =&gt;  'application.modules.page.PageModule',


    ),


    'admin'     =&gt;  array(


        'class'     =&gt;  'application.modules.admin.AdminModule',


    ),


    'product'   =&gt;  array(


        'class' =&gt;  'application.modules.product.ProductModule',


    ),

// ‘sitemap’ => array(

// ‘class’ => ‘application.modules.sitemap.SitemapModule’,

// ),

    'search'    =&gt;  array(


        'class'     =&gt;  'application.modules.search.SearchModule',


    ),


    'athlete'   =&gt;  array(


        'class' =&gt;  'application.modules.athlete.AthleteModule',


    ),


),


// application components


'components'    =&gt;  array(


    'request' =&gt; array(


        'class'         =&gt;  'application.components.web.WebHttpRequest'


    ),


    'securityManager'   =&gt;  array(


        'behaviors' =&gt;  array(


            'passwordGenerator' =&gt;  'ext.PasswordGenerator.BPasswordGenerator',


        ),


    ),


    'user'  =&gt;  array(


        'class'             =&gt;  'application.components.user.WebUser',


        // enable cookie-based authentication


        'allowAutoLogin'    =&gt;  true,


        'loginUrl'          =&gt;  array('page/auth/login'),


    ),


    'authManager'   =&gt;  array(


        'class'         =&gt;  'CPhpAuthManager',


        'showErrors'    =&gt;  YII_DEBUG,


        'defaultRoles'  =&gt;  array(


            'admin',


            'authenticated',


            'guest',


        ),


    ),


    'userHelper'    =&gt;  array(


        'class' =&gt;  'application.components.helpers.UserHelper',


    ),


    'fileHelper'    =&gt;  array(


        'class'     =&gt;  'application.components.file-upload.FileHelper',


        'dir'       =&gt;  &#036;basePath.'/&#46;&#46;/upload/files/',


        'contexts'  =&gt;  array(


            'default'   =&gt;  array(


                'class'             =&gt;  'application.components.file-upload.file-contexts.UploadFileContext',


                'validatorParams'   =&gt;  array('maxSize' =&gt; 1024*1024*10),


            ),


            'product'   =&gt; array(


                'class'             =&gt;  'application.components.file-upload.file-contexts.UploadImageContext',


                'resizeParams'      =&gt;  array(


                    'admin'     =&gt;  array('width' =&gt; 100, 'height' =&gt; null),


                    'small'     =&gt;  array('width' =&gt; 150, 'height' =&gt; 150),


                    'mini'     =&gt;  array('width' =&gt; 100, 'height' =&gt; 100),


                    'extra-mini' =&gt; array('width' =&gt; 69, 'height' =&gt; 69),


                    'origin'    =&gt;  array(),


                ),


                'validatorParams'   =&gt; array('maxSize' =&gt; 10*1024*1024),


            ),


            'productCategory'   =&gt; array(


                'class'             =&gt;  'application.components.file-upload.file-contexts.UploadImageContext',


                'resizeParams'      =&gt;  array(


                    'admin'     =&gt;  array('width' =&gt; 100, 'height' =&gt; null),


                    'small'     =&gt;  array('width' =&gt; 150, 'height' =&gt; 150),


                    'origin'    =&gt;  array(),


                ),


                'validatorParams'   =&gt; array('maxSize' =&gt; 10*1024*1024),


            ),


            'page'   =&gt; array(


                'class'             =&gt;  'application.components.file-upload.file-contexts.UploadImageContext',


                'resizeParams'      =&gt;  array(


                    'admin'     =&gt;  array('width' =&gt; 100, 'height' =&gt; null),


                    'origin'    =&gt;  array(),


                ),


                'validatorParams'   =&gt; array('maxSize' =&gt; 10*1024*1024),


            ),


            'athlete'   =&gt; array(


                'class'             =&gt;  'application.components.file-upload.file-contexts.UploadImageContext',


                'resizeParams'      =&gt;  array(


                    'admin'     =&gt;  array('width' =&gt; 100, 'height' =&gt; null),


                    'origin'    =&gt;  array(),


                ),


                'validatorParams'   =&gt; array('maxSize' =&gt; 10*1024*1024),


            ),


        ),


    ),


    'breadcrumbsHelper'    =&gt;  array(


        'class' =&gt;  'application.components.helpers.BreadcrumbsHelper',


    ),


    'menuItemHelper'    =&gt;  array(


        'class' =&gt;  'application.components.menu-items.MenuItemHelper',


        'types' =&gt; array(


            array(


                'class' =&gt; 'application.components.menu-items.types.UrlMenuItemType',


            ),


            array(


                'class' =&gt; 'application.components.menu-items.types.PageMenuItemType',


            ),


            array(


                'class' =&gt; 'application.components.menu-items.types.ProductMenuItemType',


            ),


            array(


                'class' =&gt; 'application.components.menu-items.types.ProductCategoryMenuItemType',


            ),


            array(


                'class' =&gt; 'application.components.menu-items.types.TextMenuItemType',


            ),


        ),


    ),


    'session'       =&gt;  array(


        'class'     =&gt;  'application.components.web.HttpSession',


    ),


    'urlManager'    =&gt;  require(__DIR__.DIRECTORY_SEPARATOR.'routing.php'),


    'cache' =&gt;  array(


        'class' =&gt;  'CDummyCache',


    ),


    'previewCache' =&gt; array(


        'class' =&gt; 'CFileCache',


    ),


    'db'    =&gt;  array(


        'class'             =&gt;  'application.components.db.DbConnection',


        'emulatePrepare'    =&gt;  true,


        'charset'           =&gt;  'utf8',


        'charsetVarsValue'  =&gt;  true,


        'initSQLs'          =&gt;  array(


            //&quot;SET time_zone = '+00:00';&quot;,


        ),


    ),


    'response'      =&gt;  array(


        'class' =&gt;  'application.components.web.Response',


    ),


    'errorHandler'  =&gt;  array(


        // use 'site/error' action to display errors


        'errorAction'   =&gt;  &#33;YII_DEBUG ? 'page/error/default' : null,


    ),


    'log'   =&gt;  array(


        'class'     =&gt;  'CLogRouter',


        'routes'    =&gt;  array(


            array(


                'class'     =&gt;  'CFileLogRoute',


                'levels'    =&gt;  'error, warning',


            ),


        ),


    ),


    'messages'      =&gt;  array(


        'class'     =&gt;  'CGettextMessageSource',


        'useMoFile' =&gt;  &#33;YII_DEBUG,


    ),


    'clientScript'  =&gt;  require(__DIR__.DIRECTORY_SEPARATOR.'assets.php'),


    'bootstrap'     =&gt; array(


        'class'         =&gt;  'bootstrap.components.Bootstrap',


    ),


    'searchManager' =&gt;  array(


        'class'     =&gt;  'SearchManager',


    ),


    'basket'    =&gt;  array(


        'class' =&gt;  'application.components.basket.Basket'


    ),


    'mailer'        =&gt;  array(


        'class'         =&gt;  'application.extensions.smtpmail.PHPMailer',


        'Host'          =&gt;  'localhost',


        'Username'      =&gt;  '',


        'Password'      =&gt;  '',


        'Mailer'        =&gt;  'smtp',


        'Port'          =&gt;  25,


        'SMTPAuth'      =&gt;  false,


        'From'          =&gt;  'root@localhost',


        'FromName'      =&gt;  'No-Reply',


        'CharSet'       =&gt;  'Utf-8',


    ),


    'stripeHelper'  =&gt;  array(


        'class'         =&gt;  'application.components.helpers.StripeHelper',


    ),


),





// application-level parameters that can be accessed


// using Yii::app()-&gt;params['paramName']


'params'    =&gt;  require(__DIR__.DIRECTORY_SEPARATOR.'params.php'),

);

Hi Ronald,

Thank you again for your help and direction with this project.The reason I included the screenshot in my initial post was to show that the admin role for this site has no CRUD access to the navigation systems. I have never worked in a CMS where that functionality is non-existent. And, the screenshots I’ve seen on the Yii Framework site indicate that CRUD exists for admins to manage menus. So, I am trying to figure out how to give it back to the clients.

Below is the code from the "protected/modules/admin/controllers/AuthController.php file.

<?php

/**

  • @property AdminModule $module

  • @method AdminModule getModule()

*/

class AuthController extends AdminController

{

public &#036;layout = '//layouts/admin/standart';





public function accessRules()


{


    return array(


        array(


            'deny',


            'actions'   =&gt;  array('login'),


            'users'     =&gt;  array('@'),


            'verbs'     =&gt;  array('GET'),


        ),


    );


}





/**


 * Displays the login page


 */


public function actionLogin()


{


    &#036;model = new LoginForm;





    // collect user input data


    if (&#036;this-&gt;request-&gt;isPostRequest) {


        &#036;model-&gt;attributes = &#036;this-&gt;request-&gt;getPost('LoginForm', array());


        // validate user input and redirect to the previous page if valid


        if (&#036;model-&gt;validate() &amp;&amp; &#036;model-&gt;login()) {


            &#036;returnUrl = '/' . (ltrim(Yii::app()-&gt;user-&gt;returnUrl, '/') ?: ltrim(Yii::app()-&gt;createUrl('admin/default/index'), '/'));


            &#036;this-&gt;redirect(&#036;returnUrl);


        }


    }


    // display the login form


    &#036;this-&gt;render('login', array('model' =&gt; &#036;model));


}





/**


 * Logs out the current user and redirect to homepage.


 */


public function actionLogout()


{


    Yii::app()-&gt;user-&gt;logout();


    &#036;this-&gt;redirect(&#036;this-&gt;createUrl('login'));


}

}

From the looks of it there is one route you can take to gain access.

You can look at the script LoginForm.php and find out what validations you need to mimick to create a username and password (or even find the admin username and change its password) by analysing what the function login() does and what validation rules are dfined.

The config shows that Yii rbac is being used (authManager class CPhpAuthManager). But since it is defined to assign the roles of admin, authenticated and guest to anyone, it seems like anyone who can login is an admin. However you can have a look at the file ‘protected/data/auth.php’ to see whether any of these roles are assigned to a user. Who knows.

The database connectivity is handled by the class in application.components.db.DbConnection, so have a look in the php script ../components/db/DbConnection.php.

Good luck.

Ronald, Thank You So Much! You left a couple of gems in here. I will definitely check out the rbac.

Willa