-
Notifications
You must be signed in to change notification settings - Fork 1
7.1. Upgrade to 3.0
Replace all system dir and /index.php.
application dir. Add cache dir, logs dir, add all config dir files and replace index.html in all dir.
$config['base_url'] = 'http://localhost/newwebsite3.0/';
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['encryption_key'] = "some-encryption-key";
$config['composer_autoload'] = TRUE;
Use mysqli.
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'password',
'database' => 'newwebsite3.0',
'dbdriver' => 'mysqli',
'dbprefix' => '',
....
....
);
cd application/
composer require league/oauth2-client:^0.11.0
composer require simplepie/simplepie:^1.3
Get clientId and clientSecret from google console.
<?php
class Auth extends Public_Controller
{
public function __construct()
{
parent::__construct();
}
public function session($provider)
{
$provider = new League\OAuth2\Client\Provider\Google([
'clientId' => 'add clientid here',
'clientSecret' => 'add clientsecret',
'redirectUri' => 'http://localhost/newwebsite3.0/index.php/welcome/auth/session/google',
'scopes' => ['email'],
]);
if (!isset($_GET['code'])) {
// If we don't have an authorization code then get one
$authUrl = $provider->getAuthorizationUrl();
$_SESSION['oauth2state'] = $provider->state;
header('Location: '.$authUrl);
exit;
// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
unset($_SESSION['oauth2state']);
exit('Invalid state');
} else {
// Try to get an access token (using the authorization code grant)
$token = $provider->getAccessToken('authorization_code', [
'code' => $_GET['code']
]);
// Optional: Now you have a token you can look up a users profile data
try {
// We got an access token, let's now get the user's details
$userDetails = $provider->getUserDetails($token);
// Use these details to create a new profile
//printf('Hello %s!', $userDetails->firstName);
$tokenemail =$userDetails->email;
// check user $user['email'] in the db
$emailcheck = $this->user_model->checkUserEmail($tokenemail);
//$emailcheck = $this->userlib->checkOpenIdEmail($user['email']);
if(!$emailcheck==FALSE)
{
$id = $emailcheck['id'];
$user = $this->userlib->set_userlogin($id);
flashMsg('success', 'You are logged in.');
redirect('welcome','location');
}
else
{
// if it does not exist then redirect to registration
flashMsg('warning', 'Your email is not in our database. Please register.');
redirect('auth/register','location');
}
} catch (Exception $e) {
// Failed to get user details
exit('Oh dear...');
}
// Use this to interact with an API on the users behalf
echo $token->accessToken;
// Use this to get a new access token if the old one expires
echo $token->refreshToken;
// Unix timestamp of when the token will expire, and need refreshing
echo $token->expires;
}}
}
?>
Replace all files in application/third_party/MX/.
Add rules to all. Use numeric for boolean and alpha_numeric_spaces for dropdown.
$config['field']['xxxxx'] = array('type'=>'boolean','rules'=>'numeric');
$config['field']['xxxxx'] = array('type'=>'dropdown','rules'=>'alpha_numeric_spaces','params'=>array('options'=>array('text'=>'Plaintext','html'=>'HTML')));
Not for config but need to update all class file name with Ucfirst.php. This includes libraries.
Comment out line 77.
//public function MY_Model() { $this->__construct(); }
Update session DB.
CREATE TABLE IF NOT EXISTS `ci_sessions` (
`id` varchar(40) NOT NULL,
`ip_address` varchar(45) NOT NULL,
`timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
`data` blob NOT NULL,
PRIMARY KEY (id),
KEY `ci_sessions_timestamp` (`timestamp`)
);
Correct $CI to $this->CI in line 122.
$result = $this->CI->user_model->validateLogin($check,$this->CI->session->userdata('password'));
In core/PublicController.php line 42, delete session_start().
libraries/Auth_form_processing.php line 217
to index.php/admin/home/index
/application/modules/auth/config/userlib.php|30 col 10| $config['userlib_action_admin_login'] = 'admin/home/index';
views/admin/menu
<li><?php print anchor('admin/home/index','<i class="fa fa-dashboard fa-fw"></i> '.$this->lang->line('backendpro_dashboard')); ?></li>
application/core/Admin_controler
$this->bep_site->set_crumb($this->lang->line('backendpro_control_panel'),'admin/home/index');
Replace all
$row = str_replace("'","\'",$row);
//$delete = form_checkbox("select[]",$row["id"],FALSE);
$delete = '<input type="checkbox" name="select[]" value="'.$row['id'].'" />';
$active = ($row['active']?'tick':'cross');
$myemail = $row['email'];
$size = 20;
//anchor(uri segments, text, attributes)
$editlink = anchor('auth/admin/members/form/'.$row['id'],$this->bep_assets->icon('pencil'));
$gravatar = str_replace("'","\'",gravatar($myemail, $size));
echo "['".$row['id']."', '".$row['username']."', '".$row['email']
."', '".$row['group']."', '".$row['last_visit']."', '".$this->bep_assets->icon($active)."','".$editlink."','".$delete."'],";
In application/views/public/topnav.php line 120, change to,
$loggedin = $this->cecilielib->ifloggedin();
if ($loggedin)
Important: The Tables of Content are generated. Any change will be overridden on the next update.
For more information: GitHub Wikifier