| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
*/
-$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-+';
+$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-+&';
/*
'rules'=>'required|min_length[5]|max_length[32]'
)
),
+ 'login_openid'=> array(
+ array(
+ 'field'=>'openid',
+ 'label'=>'lang:user_openid',
+ 'rules'=>'trim|required'
+ )
+ ),
'register'=> array(
array(
'field'=>'username',
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-$config['openid_storepath'] = 'tmp';
-$config['openid_policy'] = 'test/policy';
+$config['openid_storepath'] = './tmp';
$config['openid_required'] = array('nickname');
$config['openid_optional'] = array('fullname', 'email');
+$config['openid_pape_policies'] = array();
+
+// OBSOLETE
+$config['openid_policy'] = 'test/policy';
$config['openid_request_to'] = 'test/check';
?>
* @author Călin-Andrei Burloiu
*/
class Catalog extends CI_Controller {
-
+
public function __construct()
{
parent::__construct();
-
+
//$this->lang->load('catalog');
- }
-
+ }
+
public function index()
{
// **
{
// Videos
$vs_data['videos'] = $this->videos_model->get_videos_summary(
- $id, NULL, 0, $this->config->item('videos_per_row'));
-
+ $id, NULL, 0, $this->config->item('videos_per_row'));
+
// Category
$vs_data['category_name'] = $name;
$vs_data['category_id'] = $id;
$videos_summary['category_name'] = $name;
$videos_summary['category_title'] = $name ?
- $this->lang->line("ui_categ_$name") : $name;
-
+ $this->lang->line("ui_categ_$name") : $name;
+
// Pagination (not required)
$vs_data['pagination'] = '';
-
+
$videos_summary['content'] = $this->load->view(
- 'catalog/videos_summary_view', $vs_data, TRUE);
+ 'catalog/videos_summary_view', $vs_data, TRUE);
$data['videos_summaries'][] = $videos_summary;
}
-
- $params = array( 'title' => $this->config->item('site_name'),
- 'css' => array(
- 'catalog.css'
- ),
- //'js' => array(),
- //'metas' => array('description'=>'','keywords'=>'')
- );
+
+ $params = array('title' => $this->config->item('site_name'),
+ 'css' => array(
+ 'catalog.css'
+ ),
+ //'js' => array(),
+ //'metas' => array('description'=>'','keywords'=>'')
+ );
$this->load->library('html_head_params', $params);
-
+
// **
// ** LOADING VIEWS
// **
$this->load->view('html_begin', $this->html_head_params);
$this->load->view('header', array(
- 'selected_menu'=> 'home'
+ 'selected_menu' => 'home'
));
-
- $main_params['content'] = $this->load->view('catalog/index_view', $data, TRUE);
+
+ $main_params['content'] = $this->load->view('catalog/index_view', $data,
+ TRUE);
$main_params['side'] = $this->load->view('side_default', NULL, TRUE);
$this->load->view('main', $main_params);
-
+
$this->load->view('footer');
$this->load->view('html_end');
}
-
- public function test($page = 0)
+
+ public function test()
{
- $this->load->model('users_model');
- echo Users_model::gen_activation_code('calin.burloiu');
+ $q = $this->input->get('q');
+ $q = ($q ? $q : 'nimic');
+
+ $w = $this->input->get('w');
+ $w = ($w ? $w : 'nimic');
+
+ echo "$q / $w";
}
-
+
public function category($category_name, $ordering = 'hottest', $offset = 0)
{
// **
// **
// Video Category
$category_data = Catalog::_get_category_data($category_name);
-
+
// Retrieve videos summary.
$this->load->model('videos_model');
$vs_data['videos'] = $this->videos_model->get_videos_summary(
- $category_data['category_id'], NULL, intval($offset),
- $this->config->item('videos_per_page'), $ordering);
-
+ $category_data['category_id'], NULL, intval($offset),
+ $this->config->item('videos_per_page'), $ordering);
+
$vs_data['ordering'] = $ordering;
-
+
// Pagination
$this->load->library('pagination');
- $pg_config['base_url'] = site_url("catalog/category/$category_name/$ordering/");
+ $pg_config['base_url'] = site_url(
+ "catalog/category/$category_name/$ordering/");
$pg_config['uri_segment'] = 5;
$pg_config['total_rows'] = $this->videos_model->get_videos_count(
- $category_data['category_id']);
+ $category_data['category_id']);
$pg_config['per_page'] = $this->config->item('videos_per_page');
$this->pagination->initialize($pg_config);
$vs_data['pagination'] = $this->pagination->create_links();
$vs_data['category_name'] = $category_data['category_name'];
$vs_data['title'] = $category_data['category_title'];
-
- $params = array( 'title' =>
- $category_data['category_title'].' – '
- . $this->config->item('site_name'),
- 'css' => array(
- 'catalog.css'
- )
- //'metas' => array('description'=>'','keywords'=>'')
- );
+
+ $params = array('title' =>
+ $category_data['category_title'] . ' – '
+ . $this->config->item('site_name'),
+ 'css' => array(
+ 'catalog.css'
+ )
+ //'metas' => array('description'=>'','keywords'=>'')
+ );
$this->load->library('html_head_params', $params);
-
+
// **
// ** LOADING VIEWS
// **
$this->load->view('html_begin', $this->html_head_params);
$this->load->view('header', array(
- 'search_category_name'=> $vs_data['category_name']
+ 'search_category_name' => $vs_data['category_name']
));
-
- $main_params['content'] =
- $this->load->view('catalog/videos_summary_view', $vs_data, TRUE);
+
+ $main_params['content'] =
+ $this->load->view('catalog/videos_summary_view', $vs_data, TRUE);
$main_params['side'] = $this->load->view('side_default', NULL, TRUE);
$this->load->view('main', $main_params);
-
+
$this->load->view('footer');
$this->load->view('html_end');
}
-
+
public function search($search_query = "", $offset = 0, $category_name = NULL)
{
$this->load->model('videos_model');
$this->load->library('security');
-
+
// Redirect to an URL which contains search string if data was passed
// via POST method and not via URL segments.
$str_post_search = $this->input->post('search');
$str_post_category = $this->input->post('search-category');
- if ($search_query === "" && $str_post_search !== FALSE)
+ if ($search_query === "" && $str_post_search !== FALSE)
{
redirect('catalog/search/'
- . $this->videos_model->encode_search_query($str_post_search)
- . '/0'
- . ($str_post_category === FALSE ? '' : "/$str_post_category"));
+ . $this->videos_model->encode_search_query($str_post_search)
+ . '/0'
+ . ($str_post_category === FALSE ? '' : "/$str_post_category"));
return;
}
// Search query is encoded for URL and must be decoded.
$enc_search_query = $search_query;
$search_query = $this->videos_model->decode_search_query($search_query);
-
+
// Security filtering
$search_query = $this->security->xss_clean($search_query);
$results_data['search_query'] = $search_query;
// Category
$results_data = Catalog::_get_category_data($category_name);
if ($results_data === NULL)
- $results_data = array('category_id'=>NULL);
-
+ $results_data = array('category_id' => NULL);
+
// Page header data
$header_data['search_query'] = $search_query;
if ($category_name !== NULL)
{
$header_data['search_category_name'] = $results_data['category_name'];
}
-
+
// Check if search string is valid.
if (strlen($search_query) === 0)
{
//$results_data['videos'] = NULL;
- $this->error($this->lang->line('error_search_query_empty'),
- $header_data);
+ $this->error($this->lang->line('error_search_query_empty'), $header_data);
return;
}
else
{
// Retrieve search results.
$results_data['count'] = $this->videos_model->search_videos(
- $search_query, 0, 0, $results_data['category_id']);
+ $search_query, 0, 0, $results_data['category_id']);
$results_data['videos'] = $this->videos_model->search_videos(
- $search_query, intval($offset),
- $this->config->item('search_results_per_page'),
- $results_data['category_id']);
+ $search_query, intval($offset), $this->config->item(
+ 'search_results_per_page'),
+ $results_data['category_id']);
if ($results_data['videos'] === NULL)
$results_data['videos'] = array();
-
+
// Pagination
$this->load->library('pagination');
$pg_config['base_url'] = site_url("catalog/search/$enc_search_query/");
$pg_config['uri_segment'] = 4;
$pg_config['total_rows'] = $results_data['count'];
$pg_config['per_page'] =
- $this->config->item('search_results_per_page');
+ $this->config->item('search_results_per_page');
$this->pagination->initialize($pg_config);
$results_data['pagination'] = $this->pagination->create_links();
}
-
+
// HTML head parameters
- $params = array( 'title' => 'Search Results – '
- . $this->config->item('site_name'),
- 'css' => array(
- 'catalog.css'
- ),
- //'js' => array(),
- //'metas' => array('description'=>'','keywords'=>'')
- );
+ $params = array('title' => 'Search Results – '
+ . $this->config->item('site_name'),
+ 'css' => array(
+ 'catalog.css'
+ ),
+ //'js' => array(),
+ //'metas' => array('description'=>'','keywords'=>'')
+ );
$this->load->library('html_head_params', $params);
-
+
// **
// ** LOADING VIEWS
// **
$this->load->view('html_begin', $this->html_head_params);
$this->load->view('header', $header_data);
-
+
// Search Results
- $main_params['content'] =
- $this->load->view('catalog/search_results_view',
- $results_data, TRUE);
+ $main_params['content'] =
+ $this->load->view('catalog/search_results_view', $results_data,
+ TRUE);
$main_params['side'] = $this->load->view('side_default', NULL, TRUE);
$this->load->view('main', $main_params);
-
+
$this->load->view('footer');
$this->load->view('html_end');
}
-
+
public function error($msg, $header_data)
{
- $params = array( 'title' => 'Error – '
- . $this->config->item('site_name'),
- //'css' => array(),
- //'js' => array(),
- //'metas' => array('description'=>'','keywords'=>'')
+ $params = array('title' => 'Error – '
+ . $this->config->item('site_name'),
+ //'css' => array(),
+ //'js' => array(),
+ //'metas' => array('description'=>'','keywords'=>'')
);
$this->load->library('html_head_params', $params);
-
+
// **
// ** LOADING VIEWS
// **
$this->load->view('html_begin', $this->html_head_params);
$this->load->view('header', $header_data);
-
- $main_params['content'] = $this->load->view('error_view', array('msg'=>$msg), TRUE);
+
+ $main_params['content'] = $this->load->view('error_view', array(
+ 'msg' => $msg), TRUE);
$main_params['side'] = $this->load->view('side_default', NULL, TRUE);
$this->load->view('main', $main_params);
-
+
$this->load->view('footer');
$this->load->view('html_end');
}
-
+
public static function _get_category_data($category_name)
{
- $ci =& get_instance();
-
+ $ci = & get_instance();
+
if ($category_name === NULL)
return NULL;
-
+
$categories = $ci->config->item('categories');
$category_id = array_search($category_name, $categories);
$results_data['category_name'] = $category_name;
$results_data['category_id'] = $category_id;
$results_data['category_title'] = $category_name ?
- $ci->lang->line("ui_categ_$category_name") : $category_name;
-
+ $ci->lang->line("ui_categ_$category_name") : $category_name;
+
return $results_data;
- }
+ }
+
}
/* End of file catalog.php */
-/* Location: ./application/controllers/catalog.php */
+/* Location: ./application/controllers/catalog.php */
\ No newline at end of file
$this->msg = $this->session->flashdata('msg');
}
- public function _remap($method, $params = array())
+ public function _remap($method, $par = array())
{
if (! $this->msg)
header('Location: '. site_url());
<?php
+/**
+ * @property CI_Config $config
+ */
class Test extends CI_Controller {
- function Test()
- {
- parent::__construct();
-
- $this->lang->load('openid', 'english');
- $this->load->library('openid');
- $this->load->helper('url');
- //$this->output->enable_profiler(TRUE);
- }
-
- // Index
- function index()
- {
- if ($this->input->post('action') == 'verify')
- {
- $user_id = $this->input->post('openid_identifier');
- $pape_policy_uris = $this->input->post('policies');
-
- if (!$pape_policy_uris)
- {
- $pape_policy_uris = array();
- }
-
- $this->config->load('openid');
- $req = $this->config->item('openid_required');
- $opt = $this->config->item('openid_optional');
- $policy = site_url($this->config->item('openid_policy'));
- $request_to = site_url($this->config->item('openid_request_to'));
-
- $this->openid->set_request_to($request_to);
- $this->openid->set_trust_root(base_url());
- $this->openid->set_args(null);
- $this->openid->set_sreg(true, $req, $opt, $policy);
- $this->openid->set_pape(true, $pape_policy_uris);
- $this->openid->authenticate($user_id);
- }
-
- $data['pape_policy_uris'] = array(
- PAPE_AUTH_MULTI_FACTOR_PHYSICAL,
- PAPE_AUTH_MULTI_FACTOR,
- PAPE_AUTH_PHISHING_RESISTANT
- );
-
- $this->load->view('view_openid', $data);
-
- }
-
- // Policy
- function policy()
- {
- $this->load->view('view_policy');
- }
-
- // set message
- function _set_message($msg, $val = '', $sub = '%s')
- {
- return str_replace($sub, $val, $this->lang->line($msg));
- }
-
- // Check
- function check()
- {
- $this->config->load('openid');
- $request_to = site_url($this->config->item('openid_request_to'));
-
- $this->openid->set_request_to($request_to);
- $response = $this->openid->getResponse();
-
- switch ($response->status)
- {
- case Auth_OpenID_CANCEL:
- $data['msg'] = $this->lang->line('openid_cancel');
- break;
- case Auth_OpenID_FAILURE:
- $data['error'] = $this->_set_message('openid_failure', $response->message);
- break;
- case Auth_OpenID_SUCCESS:
- $openid = $response->getDisplayIdentifier();
- $esc_identity = htmlspecialchars($openid, ENT_QUOTES);
-
- $data['success'] = $this->_set_message('openid_success', array($esc_identity, $esc_identity), array('%s','%t'));
-
- if ($response->endpoint->canonicalID) {
- $data['success'] .= $this->_set_message('openid_canonical', $response->endpoint->canonicalID);
- }
-
- $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
- $sreg = $sreg_resp->contents();
-
- foreach ($sreg as $key => $value)
- {
- $data['success'] .= $this->_set_message('openid_content', array($key, $value), array('%s','%t'));
- }
-
- $pape_resp = Auth_OpenID_PAPE_Response::fromSuccessResponse($response);
-
- if ($pape_resp)
- {
- if ($pape_resp->auth_policies)
- {
- $data['success'] .= $this->lang->line('openid_pape_policies_affected');
-
- foreach ($pape_resp->auth_policies as $uri)
- {
- $data['success'] .= "<li><tt>$uri</tt></li>";
- }
-
- $data['success'] .= "</ul>";
- }
- else
- {
- $data['success'] .= $this->lang->line('openid_pape_not_affected');
- }
-
- if ($pape_resp->auth_age)
- {
- $data['success'] .= $this->_set_message('openid_auth_age', $pape_resp->auth_age);
- }
-
- if ($pape_resp->nist_auth_level)
- {
- $data['success'] .= $this->_set_message('openid_nist_level', $pape_resp->nist_auth_level);
- }
- }
- else
- {
- $data['success'] .= $this->lang->line('openid_pape_noresponse');
- }
- break;
- }
-
- $data['pape_policy_uris'] = array(
- PAPE_AUTH_MULTI_FACTOR_PHYSICAL,
- PAPE_AUTH_MULTI_FACTOR,
- PAPE_AUTH_PHISHING_RESISTANT
- );
-
- $this->load->view('view_openid', $data);
- }
+ function Test()
+ {
+ parent::__construct();
+
+ $this->lang->load('openid', 'english');
+ $this->load->library('openid');
+ $this->load->helper('url');
+ //$this->output->enable_profiler(TRUE);
+ }
+
+ // Index
+ function index()
+ {
+ if ($this->input->post('action') == 'verify')
+ {
+ $user_id = $this->input->post('openid_identifier');
+ $pape_policy_uris = $this->input->post('policies');
+
+ if (!$pape_policy_uris)
+ {
+ $pape_policy_uris = array();
+ }
+
+ $this->config->load('openid');
+ $req = $this->config->item('openid_required');
+ $opt = $this->config->item('openid_optional');
+ $policy = site_url($this->config->item('openid_policy'));
+ $request_to = site_url($this->config->item('openid_request_to'));
+
+ $this->openid->set_request_to($request_to);
+ $this->openid->set_trust_root(base_url());
+ $this->openid->set_args(null);
+ $this->openid->set_sreg(true, $req, $opt, $policy);
+ $this->openid->set_pape(true, $pape_policy_uris);
+ $this->openid->authenticate($user_id);
+ }
+ else
+ {
+ $data['pape_policy_uris'] = array(
+ PAPE_AUTH_MULTI_FACTOR_PHYSICAL,
+ PAPE_AUTH_MULTI_FACTOR,
+ PAPE_AUTH_PHISHING_RESISTANT
+ );
+
+ $this->load->view('view_openid', $data);
+ }
+ }
+
+ // Policy
+ function policy()
+ {
+ $this->load->view('openid_policy_view');
+ }
+
+ // set message
+ function _set_message($msg, $val = '', $sub = '%s')
+ {
+ return str_replace($sub, $val, $this->lang->line($msg));
+ }
+
+ // Check
+ function check()
+ {
+ $this->config->load('openid');
+ $request_to = site_url($this->config->item('openid_request_to'));
+
+ $this->openid->set_request_to($request_to);
+ $response = $this->openid->getResponse();
+
+ switch ($response->status)
+ {
+ case Auth_OpenID_CANCEL:
+ $data['msg'] = $this->lang->line('openid_cancel');
+ break;
+ case Auth_OpenID_FAILURE:
+ $data['error'] = $this->_set_message('openid_failure', $response->message);
+ break;
+ case Auth_OpenID_SUCCESS:
+ $openid = $response->getDisplayIdentifier();
+ $esc_identity = htmlspecialchars($openid, ENT_QUOTES);
+
+ $data['success'] = $this->_set_message('openid_success', array($esc_identity, $esc_identity), array('%s', '%t'));
+
+ if ($response->endpoint->canonicalID)
+ {
+ $data['success'] .= $this->_set_message('openid_canonical', $response->endpoint->canonicalID);
+ }
+
+ $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
+ $sreg = $sreg_resp->contents();
+
+ foreach ($sreg as $key => $value)
+ {
+ $data['success'] .= $this->_set_message('openid_content', array($key, $value), array('%s', '%t'));
+ }
+
+ $pape_resp = Auth_OpenID_PAPE_Response::fromSuccessResponse($response);
+
+ if ($pape_resp)
+ {
+ if ($pape_resp->auth_policies)
+ {
+ $data['success'] .= $this->lang->line('openid_pape_policies_affected');
+
+ foreach ($pape_resp->auth_policies as $uri)
+ {
+ $data['success'] .= "<li><tt>$uri</tt></li>";
+ }
+
+ $data['success'] .= "</ul>";
+ }
+ else
+ {
+ $data['success'] .= $this->lang->line('openid_pape_not_affected');
+ }
+
+ if (isset($pape_resp->auth_age) && $pape_resp->auth_age)
+ {
+ $data['success'] .= $this->_set_message('openid_auth_age', $pape_resp->auth_age);
+ }
+
+ if ($pape_resp->nist_auth_level)
+ {
+ $data['success'] .= $this->_set_message('openid_nist_level', $pape_resp->nist_auth_level);
+ }
+ }
+ else
+ {
+ $data['success'] .= $this->lang->line('openid_pape_noresponse');
+ }
+ break;
+ }
+
+ $data['pape_policy_uris'] = array(
+ PAPE_AUTH_MULTI_FACTOR_PHYSICAL,
+ PAPE_AUTH_MULTI_FACTOR,
+ PAPE_AUTH_PHISHING_RESISTANT
+ );
+
+// echo "nickname: $nickname";
+// echo "esc_identity: $esc_identity";
+
+ $this->load->view('view_openid', $data);
+ }
}
+
?>
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<span class="error">',
'</span>');
+
+ // Normal or OpenID login?
+ if ($this->input->post('openid') !== FALSE)
+ $b_openid = TRUE;
+ else
+ $b_openid = FALSE;
+ // Validate the correct form.
+ $res_form_validation = FALSE;
+ if (!$b_openid)
+ $res_form_validation = $this->form_validation->run('login');
+ else
+ $res_form_validation = $this->form_validation->run('login_openid');
- if ($this->form_validation->run('login') === FALSE)
+ if ($res_form_validation === FALSE)
{
$params = array( 'title' =>
$this->lang->line('ui_nav_menu_login')
}
else
{
+ if ($b_openid)
+ {
+ $this->lang->load('openid');
+ $this->load->library('openid');
+ $this->config->load('openid');
+ $request_to = site_url('user/check_openid_login');
+ $req = $this->config->item('openid_required');
+ $opt = $this->config->item('openid_optional');
+ $policy = site_url('user/openid_policy');
+ $pape_policy_uris = $this->config->item('openid_papa_policies');
+
+ $this->openid->set_request_to($request_to);
+ $this->openid->set_trust_root(base_url());
+ $this->openid->set_args(null);
+ $this->openid->set_sreg(true, $req, $opt, $policy);
+ if (!empty($pape_policy_uris))
+ $this->openid->set_pape(true, $pape_policy_uris);
+
+ // Redirection to OP site will follow.
+ $this->openid->authenticate($this->input->post('openid'));
+ return;
+ }
+
+ // Without OpenID
if (! $this->activated_account)
header('Location: '
. site_url("user/activate/{$this->user_id}"));
}
}
+ public function check_openid_login()
+ {
+ $this->lang->load('openid');
+ $this->load->library('openid');
+ $this->config->load('openid');
+ $request_to = site_url('user/check_openid_login');
+
+ $this->openid->set_request_to($request_to);
+ $response = $this->openid->get_response();
+
+ switch ($response->status)
+ {
+ case Auth_OpenID_CANCEL:
+ $this->load->helper('message');
+ show_info_msg_page($this, $this->lang->line('openid_cancel'));
+ break;
+ case Auth_OpenID_FAILURE:
+ $this->load->helper('message');
+ show_error_msg_page($this,
+ $this->_format_message('openid_failure',
+ $response->message));
+ break;
+ case Auth_OpenID_SUCCESS:
+ $openid = $response->getDisplayIdentifier();
+ $esc_identity = htmlspecialchars($openid, ENT_QUOTES);
+
+ $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
+ $sreg = $sreg_resp->contents();
+
+ // Get registration informations
+ $ax = new Auth_OpenID_AX_FetchResponse();
+ $obj = $ax->fromSuccessResponse($response);
+
+ //echo 'nickname('. $sreg_resp->get('nickname'). ')';
+ echo var_dump($obj->data);
+// foreach ($sreg as $key => $value)
+// {
+// $data['success'] .= $this->_set_message('openid_content', array($key, $value), array('%s', '%t'));
+// }
+
+ break;
+ }
+ }
+
+ public function openid_policy()
+ {
+ $this->load->view('openid_policy_view');
+ }
+
/**
* Logout user and then redirect it to the last page which must be encoded
* in $redirect.
&& $this->users_model->activate_account($user_id,
$activation_code))
{
- $this->session->set_flashdata('msg', sprintf(
+ $this->load->helper('message');
+ show_info_msg_page($this, sprintf(
$this->lang->line('user_msg_activated_account'),
site_url('user/login')));
- header('Location: '. site_url('message/info'));
return;
}
else
{
- $this->session->set_flashdata('msg',
- $this->lang->line('user_msg_wrong_activation_code'));
- header('Location: '. site_url('message/error'));
+ $this->load->helper('message');
+ show_error_msg_page($this,
+ $this->lang->line(
+ 'user_msg_wrong_activation_code'));
return;
}
}
if ($activated_account)
{
- $this->session->set_flashdata('msg', sprintf(
- $this->lang->line('user_msg_activated_account'),
- site_url('user/login')));
- header('Location: '. site_url('message/info'));
+ $this->load->helper('message');
+ show_info_msg_page($this, sprintf(
+ $this->lang->line('user_msg_activated_account'),
+ site_url('user/login')));
return;
}
{
if ($method == 'code')
{
- // Redirect to a message which tells the user that the
+ // A message which tells the user that the
// activation was successful.
- $this->session->set_flashdata('msg', sprintf(
- $this->lang->line('user_msg_activated_account'),
- site_url('user/login')));
- header('Location: '. site_url('message/info'));
+ $this->load->helper('message');
+ show_info_msg_page($this, sprintf(
+ $this->lang->line('user_msg_activated_account'),
+ site_url('user/login')));
return;
}
else if ($method == 'resend')
{
// Redirect to resent message
- $this->session->set_flashdata('msg', sprintf(
+ $this->load->helper('message');
+ show_info_msg_page($this, sprintf(
$this->lang->line('user_msg_activation_resent'),
$this->input->post('email')));
- header('Location: '. site_url('message/info'));
return;
}
}
}
else
{
- // Redirect to resent message
- $this->session->set_flashdata('msg', sprintf(
+ // Resent message
+ $this->load->helper('message');
+ show_info_msg_page($this, sprintf(
$this->lang->line('user_msg_password_recovery_email_sent'),
$this->input->post('username'),
$this->input->post('email')));
- header('Location: '. site_url('message/info'));
return;
}
}
+ public function _format_message($msg, $val = '', $sub = '%s')
+ {
+ return str_replace($sub, $val, $this->lang->line($msg));
+ }
+
public function _update_session_userdata($data)
{
foreach ($data as $key=> $val)
--- /dev/null
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+/**
+ * Called from a controller to show a message page.
+ *
+ * @param type $controller controller's object; pass $this from controller
+ * @param type $type message type: 'info', 'error'
+ * @param type $msg message text
+ */
+function show_msg_page($controller, $type, $msg)
+{
+ $params = array(
+ 'title'=> $controller->lang->line("message_title_{$type}")
+ .' – '
+ . $controller->config->item('site_name'),
+ //'metas' => array('description'=>'')
+ );
+ $controller->load->library('html_head_params', $params);
+
+ // **
+ // ** LOADING VIEWS
+ // **
+ $controller->load->view('html_begin', $controller->html_head_params);
+ $controller->load->view('header', array());
+
+ $main_params['content'] =
+ $controller->load->view("message/{$type}_view",
+ array('msg'=> $msg), TRUE);
+
+ $main_params['side'] = $controller->load->view('side_default', NULL, TRUE);
+ $controller->load->view('main', $main_params);
+
+ $controller->load->view('footer');
+ $controller->load->view('html_end');
+}
+
+/**
+ * Called from a controller to show an error message page.
+ *
+ * @param type $controller controller's object; pass $this from controller
+ * @param type $msg message text
+ */
+function show_error_msg_page($controller, $msg)
+{
+ show_msg_page($controller, 'error', $msg);
+}
+
+/**
+ * Called from a controller to show an info message page.
+ *
+ * @param type $controller controller's object; pass $this from controller
+ * @param type $msg message text
+ */
+function show_info_msg_page($controller, $msg)
+{
+ show_msg_page($controller, 'info', $msg);
+}
+
+/* End of file message_helper.php */
+/* Location: ./application/helpers/message_helper.php */
\ No newline at end of file
<?php
+// TODO: Review
$lang['openid_cancel'] = "Verification cancelled.";
$lang['openid_failure'] = "OpenID authentication failed: %s";
$lang['openid_success'] = 'You have successfully verified <a href="%s">%t</a> as your identity.';
$lang['user_appelation'] = 'User';
// Login / Register/ Account / Profile
+$lang['user_legend_login_normal'] = 'Log in with a %s Account';
+$lang['user_legend_login_openid'] = 'Log in with a Third-party Account';
$lang['user_username'] = 'User Name';
$lang['user_username_or_email'] = 'User Name or E-mail';
+$lang['user_openid'] = 'OpenID';
$lang['user_password'] = 'Password';
$lang['user_password_confirmation'] = 'Password Confirmation';
$lang['user_old_password'] = 'Old Password';
*/
static function isFailure($thing)
{
- return is_a($thing, 'Auth_OpenID_FailureResponse');
+ return is_a($thing, 'Auth_OpenID_FailureResponse');
}
/**
}
return $url . $sep . Auth_OpenID::httpBuildQuery($args);
+ // Added by Calin-Andrei Burloiu.
+// return $url .'/'. $sep . Auth_OpenID::httpBuildQuery($args);
}
/**
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+<?php
+
+if (!defined('BASEPATH'))
+ exit('No direct script access allowed');
+
/**
-* OpenID Library
-*
-* @package CodeIgniter
-* @author bardelot
-* @see http://cakebaker.42dh.com/2007/01/11/cakephp-and-openid/
-* & http://openidenabled.com/php-openid/
-*/
-
-class Openid{
-
- var $storePath = 'tmp';
-
- var $sreg_enable = false;
- var $sreg_required = null;
- var $sreg_optional = null;
- var $sreg_policy = null;
-
- var $pape_enable = false;
- var $pape_policy_uris = null;
-
- var $request_to;
- var $trust_root;
- var $ext_args;
-
- function Openid()
- {
- $CI =& get_instance();
- $CI->config->load('openid');
- $this->storePath = $CI->config->item('openid_storepath');
-
- session_start();
- $this->_doIncludes();
-
- log_message('debug', "OpenID Class Initialized");
- }
-
- function _doIncludes()
- {
- set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path());
-
- require_once "Auth/OpenID/Consumer.php";
- require_once "Auth/OpenID/FileStore.php";
- require_once "Auth/OpenID/SReg.php";
- require_once "Auth/OpenID/PAPE.php";
- }
-
- function set_sreg($enable, $required = null, $optional = null, $policy = null)
- {
- $this->sreg_enable = $enable;
- $this->sreg_required = $required;
- $this->sreg_optional = $optional;
- $this->sreg_policy = $policy;
- }
-
- function set_pape($enable, $policy_uris = null)
- {
- $this->pape_enable = $enable;
- $this->pape_policy_uris = $policy_uris;
- }
-
- function set_request_to($uri)
- {
- $this->request_to = $uri;
- }
-
- function set_trust_root($trust_root)
- {
- $this->trust_root = $trust_root;
- }
-
- function set_args($args)
- {
- $this->ext_args = $args;
- }
-
- function _set_message($error, $msg, $val = '', $sub = '%s')
- {
- $CI =& get_instance();
- $CI->lang->load('openid', 'english');
- echo str_replace($sub, $val, $CI->lang->line($msg));
-
- if ($error)
- {
- exit;
- }
- }
-
- function authenticate($openId)
- {
- $consumer = $this->_getConsumer();
- $authRequest = $consumer->begin($openId);
-
- // No auth request means we can't begin OpenID.
- if (!$authRequest)
- {
- $this->_set_message(true,'openid_auth_error');
- }
-
- if ($this->sreg_enable)
- {
- $sreg_request = Auth_OpenID_SRegRequest::build($this->sreg_required, $this->sreg_optional, $this->sreg_policy);
-
- if ($sreg_request)
- {
- $authRequest->addExtension($sreg_request);
- }
- else
- {
- $this->_set_message(true,'openid_sreg_failed');
- }
- }
-
- if ($this->pape_enable)
- {
- $pape_request = new Auth_OpenID_PAPE_Request($this->pape_policy_uris);
-
- if ($pape_request)
- {
- $authRequest->addExtension($pape_request);
- }
- else
- {
- $this->_set_message(true,'openid_pape_failed');
- }
- }
-
- if ($this->ext_args != null)
- {
- foreach ($this->ext_args as $extensionArgument)
- {
- if (count($extensionArgument) == 3)
- {
- $authRequest->addExtensionArg($extensionArgument[0], $extensionArgument[1], $extensionArgument[2]);
- }
- }
- }
-
- // Redirect the user to the OpenID server for authentication.
- // Store the token for this authentication so we can verify the
- // response.
-
- // For OpenID 1, send a redirect. For OpenID 2, use a Javascript
- // form to send a POST request to the server.
- if ($authRequest->shouldSendRedirect())
- {
- $redirect_url = $authRequest->redirectURL($this->trust_root, $this->request_to);
-
- // If the redirect URL can't be built, display an error
- // message.
- if (Auth_OpenID::isFailure($redirect_url))
- {
- $this->_set_message(true,'openid_redirect_failed', $redirect_url->message);
- }
- else
- {
- // Send redirect.
- header("Location: ".$redirect_url);
- }
- }
- else
- {
- // Generate form markup and render it.
- $form_id = 'openid_message';
- $form_html = $authRequest->formMarkup($this->trust_root, $this->request_to, false, array('id' => $form_id));
-
- // Display an error if the form markup couldn't be generated;
- // otherwise, render the HTML.
- if (Auth_OpenID::isFailure($form_html))
- {
- $this->_set_message(true,'openid_redirect_failed', $form_html->message);
- }
- else
- {
- $page_contents = array(
- "<html><head><title>",
- "OpenID transaction in progress",
- "</title></head>",
- "<body onload='document.getElementById(\"".$form_id."\").submit()'>",
- $form_html,
- "</body></html>");
-
- print implode("\n", $page_contents);
- }
- }
-
- }
-
- function getResponse()
- {
- $consumer = $this->_getConsumer();
- $response = $consumer->complete($this->request_to);
-
- return $response;
- }
-
- function _getConsumer()
- {
- if (!file_exists($this->storePath) && !mkdir($this->storePath))
- {
- $this->_set_message(true,'openid_storepath_failed', $this->storePath);
- }
-
- $store = new Auth_OpenID_FileStore($this->storePath);
- $consumer = new Auth_OpenID_Consumer($store);
-
- return $consumer;
- }
+ * OpenID Library
+ *
+ * @package CodeIgniter
+ * @author bardelot, Călin-Andrei Burloiu
+ * @see http://cakebaker.42dh.com/2007/01/11/cakephp-and-openid/
+ * & http://openidenabled.com/php-openid/
+ */
+class Openid {
+
+ var $storePath = 'tmp';
+ var $sreg_enable = FALSE;
+ var $sreg_required = NULL;
+ var $sreg_optional = NULL;
+ var $sreg_policy = NULL;
+ var $pape_enable = FALSE;
+ var $pape_policy_uris = NULL;
+ var $ext_args = NULL;
+ var $request_to;
+ var $trust_root;
+
+ function __construct()
+ {
+ $CI = & get_instance();
+ $CI->config->load('openid');
+ $this->storePath = $CI->config->item('openid_storepath');
+
+ session_start();
+ $this->_do_includes();
+
+ log_message('debug', "OpenID Class Initialized");
+ }
+
+ function _do_includes()
+ {
+ set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path());
+
+ require_once "Auth/OpenID/Consumer.php";
+ require_once "Auth/OpenID/FileStore.php";
+ require_once "Auth/OpenID/SReg.php";
+ require_once "Auth/OpenID/AX.php";
+ require_once "Auth/OpenID/PAPE.php";
+ }
+
+ function set_sreg($enable, $required = NULL, $optional = NULL, $policy = NULL)
+ {
+ $this->sreg_enable = $enable;
+ $this->sreg_required = $required;
+ $this->sreg_optional = $optional;
+ $this->sreg_policy = $policy;
+ }
+
+ function set_pape($enable, $policy_uris = NULL)
+ {
+ $this->pape_enable = $enable;
+ $this->pape_policy_uris = $policy_uris;
+ }
+
+ function set_request_to($uri)
+ {
+ $this->request_to = $uri;
+ }
+
+ function set_trust_root($trust_root)
+ {
+ $this->trust_root = $trust_root;
+ }
+
+ function set_args($args)
+ {
+ $this->ext_args = $args;
+ }
+
+ function _set_message($error, $msg, $val = '', $sub = '%s')
+ {
+ $CI = & get_instance();
+ $CI->lang->load('openid', 'english');
+ echo str_replace($sub, $val, $CI->lang->line($msg));
+
+ if ($error)
+ {
+ exit;
+ }
+ }
+
+ function authenticate($openId)
+ {
+ $consumer = $this->_get_consumer();
+ $authRequest = $consumer->begin($openId);
+
+ // No auth request means we can't begin OpenID.
+ if (!$authRequest)
+ {
+ $this->_set_message(TRUE, 'openid_auth_error');
+ }
+
+ if ($this->sreg_enable)
+ {
+ $sreg_request = Auth_OpenID_SRegRequest::build(
+ $this->sreg_required, $this->sreg_optional,
+ $this->sreg_policy);
+
+ if ($sreg_request)
+ {
+ $authRequest->addExtension($sreg_request);
+ }
+ else
+ {
+ $this->_set_message(TRUE, 'openid_sreg_failed');
+ }
+ }
+
+
+
+ // *** TODO ***
+
+ // Create attribute request object
+ // See http://code.google.com/apis/accounts/docs/OpenID.html#Parameters for parameters
+ // Usage: make($type_uri, $count=1, $required=false, $alias=null)
+ $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/contact/email',2,1, 'email');
+ $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/first',1,1, 'firstname');
+ $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/last',1,1, 'lastname');
+
+ // Create AX fetch request
+ $ax = new Auth_OpenID_AX_FetchRequest;
+
+ // Add attributes to AX fetch request
+ foreach($attribute as $attr){
+ $ax->add($attr);
+ }
+
+ // Add AX fetch request to authentication request
+ $authRequest->addExtension($ax);
+
+
+
+ if ($this->pape_enable)
+ {
+ $pape_request = new Auth_OpenID_PAPE_Request($this->pape_policy_uris);
+
+ if ($pape_request)
+ {
+ $authRequest->addExtension($pape_request);
+ }
+ else
+ {
+ $this->_set_message(TRUE, 'openid_pape_failed');
+ }
+ }
+
+ if ($this->ext_args != NULL)
+ {
+ foreach ($this->ext_args as $extensionArgument)
+ {
+ if (count($extensionArgument) == 3)
+ {
+ $authRequest->addExtensionArg($extensionArgument[0],
+ $extensionArgument[1],
+ $extensionArgument[2]);
+ }
+ }
+ }
+
+ // Redirect the user to the OpenID server for authentication.
+ // Store the token for this authentication so we can verify the
+ // response.
+ // For OpenID 1, send a redirect. For OpenID 2, use a Javascript
+ // form to send a POST request to the server.
+ if ($authRequest->shouldSendRedirect())
+ {
+ $redirect_url = $authRequest->redirectURL($this->trust_root,
+ $this->request_to);
+
+ // If the redirect URL can't be built, display an error
+ // message.
+ if (Auth_OpenID::isFailure($redirect_url))
+ {
+ $this->_set_message(TRUE, 'openid_redirect_failed', $redirect_url->message);
+ }
+ else
+ {
+ // Send redirect.
+ header("Location: " . $redirect_url);
+ }
+ }
+ else
+ {
+ // Generate form markup and render it.
+ $form_id = 'openid_message';
+ $form_html = $authRequest->htmlMarkup($this->trust_root,
+ $this->request_to, FALSE, array('id' => $form_id));
+
+ // Display an error if the form markup couldn't be generated;
+ // otherwise, render the HTML.
+ if (Auth_OpenID::isFailure($form_html))
+ {
+ $this->_set_message(TRUE, 'openid_redirect_failed', $form_html->message);
+ }
+ else
+ {
+ print $form_html;
+ }
+ }
+ }
+
+ function get_response()
+ {
+ $consumer = $this->_get_consumer();
+ $response = $consumer->complete($this->request_to);
+
+ return $response;
+ }
+
+ function _get_consumer()
+ {
+ if (!file_exists($this->storePath) && !mkdir($this->storePath))
+ {
+ $this->_set_message(TRUE, 'openid_storepath_failed', $this->storePath);
+ }
+
+ $store = new Auth_OpenID_FileStore($this->storePath);
+ $consumer = new Auth_OpenID_Consumer($store);
+
+ return $consumer;
+ }
+
}
-?>
+++ /dev/null
-<p><?php echo sprintf($this->lang->line('user_msg_activated_account'),
- site_url('user/login')) ?></p>
\ No newline at end of file
<?php echo form_open("user/login/$redirect") ?>
-<table class="form">
- <tr>
- <th><?php echo $this->lang->line('user_username_or_email'). ': ' ?></th>
- <td>
- <input type="text" name="username" size="16" value="<?php echo set_value('username') ?>" />
- </td>
- </tr>
- <tr>
- <td></td>
- <td><?php echo form_error('username') ?></td>
- </tr>
- <tr>
- <th><?php echo $this->lang->line('user_password'). ': ' ?></th>
- <td>
- <input type="password" name="password" size="16" value="" />
- </td>
- </tr>
- <tr>
- <td></td>
- <td><?php echo form_error('password') ?></td>
- </tr>
- <tr>
- <td></td>
- <td>
- <input type="submit" value="<?php echo $this->lang->line('ui_nav_menu_log_in') ?>" />
- </td>
- </tr>
- <tr>
- <td></td>
- <td>
- <p><a href="<?php echo site_url('user/recover_password') ?>"><?php echo $this->lang->line('user_link_password_recovery') ?></a></p>
- </td>
- </tr>
-</table>
+<fieldset>
+ <legend><?php echo sprintf($this->lang->line('user_legend_login_normal'), $this->config->item('site_name')) ?></legend>
+
+ <table class="form">
+ <tr>
+ <th><?php echo $this->lang->line('user_username_or_email'). ': ' ?></th>
+ <td>
+ <input type="text" name="username" size="16" value="<?php echo set_value('username') ?>" />
+ </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td><?php echo form_error('username') ?></td>
+ </tr>
+ <tr>
+ <th><?php echo $this->lang->line('user_password'). ': ' ?></th>
+ <td>
+ <input type="password" name="password" size="16" value="" />
+ </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td><?php echo form_error('password') ?></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>
+ <input type="submit" value="<?php echo $this->lang->line('ui_nav_menu_log_in') ?>" />
+ </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>
+ <p><a href="<?php echo site_url('user/recover_password') ?>"><?php echo $this->lang->line('user_link_password_recovery') ?></a></p>
+ </td>
+ </tr>
+ </table>
+</fieldset>
+</form>
+
+<?php echo form_open("user/login/$redirect") ?>
+<fieldset>
+ <legend><?php echo $this->lang->line('user_legend_login_openid') ?></legend>
+
+ <table class="form">
+ <tr>
+ <th><?php echo $this->lang->line('user_openid'). ': ' ?></th>
+ <td>
+ <input type="text" name="openid" size="64" value="<?php echo set_value('openid') ?>" />
+ </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td><?php echo form_error('openid') ?></td>
+ </tr>
+
+ <tr>
+ <td></td>
+ <td>
+ <input type="submit" value="<?php echo $this->lang->line('ui_nav_menu_log_in') ?>" />
+ </td>
+ </tr>
+ </table>
+</fieldset>
</form>
\ No newline at end of file
<html>
- <head><title>PHP OpenID Authentication Example</title></head>
+ <head><title>PHP OpenID Authentication Example</title>
<style type="text/css">
* {
font-family: verdana,sans-serif;
padding-bottom: 0em;
}
</style>
+ </head>
<body>
<h1>PHP OpenID Authentication Example</h1>
<p>
--- /dev/null
+<?php
+
+/**
+ * @property CI_Benchmark $benchmark
+ * @property CI_Config $config
+ * @property CI_Input $input
+ * @property CI_Lang $lang
+ * @property CI_Loader $load
+ * @property CI_Output $output
+ * @property CI_Security $security
+ * @property CI_URI $uri
+ *
+ * @property DB $db
+ *
+ * @property CI_Calendar $calendar
+ * @property CI_Cart $cart
+ * @property CI_Driver $driver
+ * @property CI_Email $email
+ * @property CI_Encrypt $encrypt
+ * @property CI_Form_validation $form_validation
+ * @property CI_Ftp $ftp
+ * @property CI_Image_lib $image_lib
+ * @property CI_Javascript $javascript
+ * @property CI_Log $log
+ * @property CI_Pagination $pagination
+ * @property CI_Parser $parser
+ * @property CI_Profiler $profiler
+ * @property CI_Session $session
+ * @property CI_SHA1 $sha1
+ * @property CI_Table $table
+ * @property CI_Trackback $trackback
+ * @property CI_Typography $typography
+ * @property CI_Unit_test $unit_test
+ * @property CI_Upload $upload
+ * @property CI_User_agent $user_agent
+ * @property CI_Xmlrpc $xmlrpc
+ * @property CI_Xmlrpcs $xmlrpcs
+ * @property CI_Zip $zip
+ *
+ *
+ * @property Html_head_params $html_head_params
+ * @property Image $image
+ * @property Openid $openid
+ * @property Singleton_db $singleton_db
+ *
+ * @property Users_model $users_model
+ * @property Videos_model $videos_model
+ */
+class CI_Model
+{
+
+}
+
+/**
+ * @property CI_Benchmark $benchmark
+ * @property CI_Config $config
+ * @property CI_Input $input
+ * @property CI_Lang $lang
+ * @property CI_Loader $load
+ * @property CI_Output $output
+ * @property CI_Security $security
+ * @property CI_URI $uri
+ *
+ * @property DB $db
+ *
+ * @property CI_Calendar $calendar
+ * @property CI_Cart $cart
+ * @property CI_Driver $driver
+ * @property CI_Email $email
+ * @property CI_Encrypt $encrypt
+ * @property CI_Form_validation $form_validation
+ * @property CI_Ftp $ftp
+ * @property CI_Image_lib $image_lib
+ * @property CI_Javascript $javascript
+ * @property CI_Log $log
+ * @property CI_Pagination $pagination
+ * @property CI_Parser $parser
+ * @property CI_Profiler $profiler
+ * @property CI_Session $session
+ * @property CI_SHA1 $sha1
+ * @property CI_Table $table
+ * @property CI_Trackback $trackback
+ * @property CI_Typography $typography
+ * @property CI_Unit_test $unit_test
+ * @property CI_Upload $upload
+ * @property CI_User_agent $user_agent
+ * @property CI_Xmlrpc $xmlrpc
+ * @property CI_Xmlrpcs $xmlrpcs
+ * @property CI_Zip $zip
+ *
+ *
+ * @property Html_head_params $html_head_params
+ * @property Image $image
+ * @property Openid $openid
+ * @property Singleton_db $singleton_db
+ *
+ * @property Users_model $users_model
+ * @property Videos_model $videos_model
+ */
+class CI_Controller
+{
+
+}
\ No newline at end of file
--- /dev/null
+copy.src.files=false
+copy.src.target=/var/www/P2P-Tube
+index.file=index.php
+run.as=LOCAL
+url=http://localhost/devel/
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
+ <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
+</project-private>
--- /dev/null
+include.path=${php.global.include.path}
+php.version=PHP_5
+source.encoding=UTF-8
+src.dir=.
+tags.asp=false
+tags.short=true
+web.root=.
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.php.project</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/php-project/1">
+ <name>P2P-Tube</name>
+ </data>
+ </configuration>
+</project>