--- /dev/null
+<?php
+
+$config = array(
+ 'signin'=> array(
+ array(
+ 'field'=>'username',
+ 'label'=>'lang:user_username_or_email',
+ 'rules'=>'trim|required|min_length[5]|max_length[32]'
+ . '|strtolower|callback__valid_username_or_email'
+ . '|callback__do_login[password]'
+ ),
+ array(
+ 'field'=>'password',
+ 'label'=>'lang:user_password',
+ 'rules'=>'required|min_length[5]|max_length[32]'
+ )
+ ),
+ 'register'=> array(
+ array(
+ 'field'=>'username',
+ 'label'=>'lang:user_username',
+ 'rules'=>'trim|required|min_length[5]|max_length[32]'
+ . '|strtolower|callback__valid_username'
+ ),
+ array(
+ 'field'=>'password',
+ 'label'=>'lang:user_password',
+ 'rules'=>'required'
+ ),
+ array(
+ 'field'=>'password-confirmation',
+ 'label'=>'lang:user_password_confirmation',
+ 'rules'=>'required'
+ ),
+ array(
+ 'field'=>'email',
+ 'label'=>'lang:user_email',
+ 'rules'=>'required'
+ ),
+ array(
+ 'field'=>'first-name',
+ 'label'=>'lang:user_first_name',
+ 'rules'=>'required'
+ ),
+ array(
+ 'field'=>'last-name',
+ 'label'=>'lang:user_last_name',
+ 'rules'=>'required'
+ ),
+ array(
+ 'field'=>'birth-date',
+ 'label'=>'lang:user_birth_date',
+ 'rules'=>''
+ ),
+ array(
+ 'field'=>'locality',
+ 'label'=>'lang:user_locality',
+ 'rules'=>''
+ )
+ )
+);
+
+/* End of file form_validation.php */
+/* Location: ./application/config/form_validation.php */
\ No newline at end of file
--- /dev/null
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+// LDAP configuration parameters.
+
+$config['ldap_server'] = "ldaps://ldap.grid.pub.ro/";
+$config['ldap_req_ou'] = array("Calculatoare", "Profesori");
+$config['ldap_bind_user'] = "uid=WUSO,ou=Special Users,dc=cs,dc=curs,dc=pub,dc=ro";
+$config['ldap_bind_password'] = "BreSath5";
\ No newline at end of file
--- /dev/null
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+/**
+ * Localization configuration files.
+ *
+ * @author Călin-Andrei Burloiu and some content from CI Wiki
+ */
+
+
+$config['country_list'] = array(
+ "AF"=>"Afghanistan",
+ "AL"=>"Albania",
+ "DZ"=>"Algeria",
+ "AD"=>"Andorra",
+ "AO"=>"Angola",
+ "AI"=>"Anguilla",
+ "AQ"=>"Antarctica",
+ "AG"=>"Antigua and Barbuda",
+ "AR"=>"Argentina",
+ "AM"=>"Armenia",
+ "AW"=>"Aruba",
+ "AU"=>"Australia",
+ "AT"=>"Austria",
+ "AZ"=>"Azerbaijan",
+ "BS"=>"Bahamas",
+ "BH"=>"Bahrain",
+ "BD"=>"Bangladesh",
+ "BB"=>"Barbados",
+ "BY"=>"Belarus",
+ "BE"=>"Belgium",
+ "BZ"=>"Belize",
+ "BJ"=>"Benin",
+ "BM"=>"Bermuda",
+ "BT"=>"Bhutan",
+ "BO"=>"Bolivia",
+ "BA"=>"Bosnia and Herzegovina",
+ "BW"=>"Botswana",
+ "BR"=>"Brazil",
+ "IO"=>"British Indian Ocean",
+ "BN"=>"Brunei",
+ "BG"=>"Bulgaria",
+ "BF"=>"Burkina Faso",
+ "BI"=>"Burundi",
+ "KH"=>"Cambodia",
+ "CM"=>"Cameroon",
+ "CA"=>"Canada",
+ "CV"=>"Cape Verde",
+ "KY"=>"Cayman Islands",
+ "CF"=>"Central African Republic",
+ "TD"=>"Chad",
+ "CL"=>"Chile",
+ "CN"=>"China",
+ "CX"=>"Christmas Island",
+ "CC"=>"Cocos (Keeling) Islands",
+ "CO"=>"Colombia",
+ "KM"=>"Comoros",
+ "CD"=>"Congo, Democratic Republic of the",
+ "CG"=>"Congo, Republic of the",
+ "CK"=>"Cook Islands",
+ "CR"=>"Costa Rica",
+ "HR"=>"Croatia",
+ "CY"=>"Cyprus",
+ "CZ"=>"Czech Republic",
+ "DK"=>"Denmark",
+ "DJ"=>"Djibouti",
+ "DM"=>"Dominica",
+ "DO"=>"Dominican Republic",
+ "TL"=>"East Timor",
+ "EC"=>"Ecuador",
+ "EG"=>"Egypt",
+ "SV"=>"El Salvador",
+ "GQ"=>"Equatorial Guinea",
+ "ER"=>"Eritrea",
+ "EE"=>"Estonia",
+ "ET"=>"Ethiopia",
+ "FK"=>"Falkland Islands (Malvinas)",
+ "FO"=>"Faroe Islands",
+ "FJ"=>"Fiji",
+ "FI"=>"Finland",
+ "FR"=>"France",
+ "GF"=>"French Guiana",
+ "PF"=>"French Polynesia",
+ "GA"=>"Gabon",
+ "GM"=>"Gambia",
+ "GE"=>"Georgia",
+ "DE"=>"Germany",
+ "GH"=>"Ghana",
+ "GI"=>"Gibraltar",
+ "GR"=>"Greece",
+ "GL"=>"Greenland",
+ "GD"=>"Grenada",
+ "GP"=>"Guadeloupe",
+ "GT"=>"Guatemala",
+ "GN"=>"Guinea",
+ "GW"=>"Guinea-Bissau",
+ "GY"=>"Guyana",
+ "HT"=>"Haiti",
+ "HN"=>"Honduras",
+ "HK"=>"Hong Kong",
+ "HU"=>"Hungary",
+ "IS"=>"Iceland",
+ "IN"=>"India",
+ "ID"=>"Indonesia",
+ "IE"=>"Ireland",
+ "IL"=>"Israel",
+ "IT"=>"Italy",
+ "CI"=>"Ivory Coast (Côte d\'Ivoire)",
+ "JM"=>"Jamaica",
+ "JP"=>"Japan",
+ "JO"=>"Jordan",
+ "KZ"=>"Kazakhstan",
+ "KE"=>"Kenya",
+ "KI"=>"Kiribati",
+ "KR"=>"Korea, South",
+ "KW"=>"Kuwait",
+ "KG"=>"Kyrgyzstan",
+ "LA"=>"Laos",
+ "LV"=>"Latvia",
+ "LB"=>"Lebanon",
+ "LS"=>"Lesotho",
+ "LI"=>"Liechtenstein",
+ "LT"=>"Lithuania",
+ "LU"=>"Luxembourg",
+ "MO"=>"Macau",
+ "MK"=>"Macedonia, Republic of",
+ "MG"=>"Madagascar",
+ "MW"=>"Malawi",
+ "MY"=>"Malaysia",
+ "MV"=>"Maldives",
+ "ML"=>"Mali",
+ "MT"=>"Malta",
+ "MH"=>"Marshall Islands",
+ "MQ"=>"Martinique",
+ "MR"=>"Mauritania",
+ "MU"=>"Mauritius",
+ "YT"=>"Mayotte",
+ "MX"=>"Mexico",
+ "FM"=>"Micronesia",
+ "MD"=>"Moldova",
+ "MC"=>"Monaco",
+ "MN"=>"Mongolia",
+ "ME"=>"Montenegro",
+ "MS"=>"Montserrat",
+ "MA"=>"Morocco",
+ "MZ"=>"Mozambique",
+ "NA"=>"Namibia",
+ "NR"=>"Nauru",
+ "NP"=>"Nepal",
+ "NL"=>"Netherlands",
+ "AN"=>"Netherlands Antilles",
+ "NC"=>"New Caledonia",
+ "NZ"=>"New Zealand",
+ "NI"=>"Nicaragua",
+ "NE"=>"Niger",
+ "NG"=>"Nigeria",
+ "NU"=>"Niue",
+ "NF"=>"Norfolk Island",
+ "NO"=>"Norway",
+ "OM"=>"Oman",
+ "PK"=>"Pakistan",
+ "PS"=>"Palestinian Territory",
+ "PA"=>"Panama",
+ "PG"=>"Papua New Guinea",
+ "PY"=>"Paraguay",
+ "PE"=>"Peru",
+ "PH"=>"Philippines",
+ "PN"=>"Pitcairn Island",
+ "PL"=>"Poland",
+ "PT"=>"Portugal",
+ "QA"=>"Qatar",
+ "RE"=>"Réunion",
+ "RO"=>"Romania",
+ "RU"=>"Russia",
+ "RW"=>"Rwanda",
+ "SH"=>"Saint Helena",
+ "KN"=>"Saint Kitts and Nevis",
+ "LC"=>"Saint Lucia",
+ "PM"=>"Saint Pierre and Miquelon",
+ "VC"=>"Saint Vincent and the Grenadines",
+ "WS"=>"Samoa",
+ "SM"=>"San Marino",
+ "ST"=>"São Tome and Principe",
+ "SA"=>"Saudi Arabia",
+ "SN"=>"Senegal",
+ "RS"=>"Serbia",
+ "CS"=>"Serbia and Montenegro",
+ "SC"=>"Seychelles",
+ "SL"=>"Sierra Leon",
+ "SG"=>"Singapore",
+ "SK"=>"Slovakia",
+ "SI"=>"Slovenia",
+ "SB"=>"Solomon Islands",
+ "SO"=>"Somalia",
+ "ZA"=>"South Africa",
+ "GS"=>"South Georgia and the South Sandwich Islands",
+ "ES"=>"Spain",
+ "LK"=>"Sri Lanka",
+ "SR"=>"Suriname",
+ "SJ"=>"Svalbard and Jan Mayen",
+ "SZ"=>"Swaziland",
+ "SE"=>"Sweden",
+ "CH"=>"Switzerland",
+ "TW"=>"Taiwan",
+ "TJ"=>"Tajikistan",
+ "TZ"=>"Tanzania",
+ "TH"=>"Thailand",
+ "TG"=>"Togo",
+ "TK"=>"Tokelau",
+ "TO"=>"Tonga",
+ "TT"=>"Trinidad and Tobago",
+ "TN"=>"Tunisia",
+ "TR"=>"Turkey",
+ "TM"=>"Turkmenistan",
+ "TC"=>"Turks and Caicos Islands",
+ "TV"=>"Tuvalu",
+ "UG"=>"Uganda",
+ "UA"=>"Ukraine",
+ "AE"=>"United Arab Emirates",
+ "GB"=>"United Kingdom",
+ "US"=>"United States",
+ "UM"=>"United States Minor Outlying Islands",
+ "UY"=>"Uruguay",
+ "UZ"=>"Uzbekistan",
+ "VU"=>"Vanuatu",
+ "VA"=>"Vatican City",
+ "VE"=>"Venezuela",
+ "VN"=>"Vietnam",
+ "VG"=>"Virgin Islands, British",
+ "WF"=>"Wallis and Futuna",
+ "EH"=>"Western Sahara",
+ "YE"=>"Yemen",
+ "ZM"=>"Zambia",
+ "ZW"=>"Zimbabwe"
+);
\ No newline at end of file
|
*/
$config['search_results_per_page'] = 20;
+
+/*
+|--------------------------------------------------------------------------
+| A list with all available languages in which the site is translated
+|--------------------------------------------------------------------------
+|
+| Keys are language codes and values are language names as they appear in
+| languages folder.
+|
+*/
+$config['available_languages_list'] = array(
+ 'en'=>'english',
+ 'ro'=>'romanian'
+);
\ No newline at end of file
// ** DATA
// **
- $html_params = array('title' => $this->title.' - '
+ $html_params = array('title' => $this->title.' – '
. $this->config->item('site_name'),
'css' => $this->css,
'js' => $this->js,
// **
$this->load->view('html_begin', $this->html_head_params);
$this->load->view('header', array(
- 'selected_menu'=> 'home',
- 'username'=> $this->session->userdata('username')
+ 'selected_menu'=> 'home'
));
$main_params['content'] = $this->load->view('catalog/index_view', $data, TRUE);
// $data['video_summary'] = $this->load->view('catalog/videos_summary_view',
// $vs_data, TRUE);
- $params = array( 'title' => $this->config->item('site_name'),
+ $params = array( 'title' =>
+ $vs_data['category_title'].' – '
+ . $this->config->item('site_name'),
'css' => array(
'catalog.css'
),
// **
$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/category_view', $data, TRUE);
}
// HTML head parameters
- $params = array( 'title' => $this->config->item('site_name'),
+ $params = array( 'title' => 'Search Results – '
+ . $this->config->item('site_name'),
'css' => array(
'catalog.css'
),
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);
private $username = NULL;
private $email = NULL;
private $user_id = NULL;
+ private $ldap_user_info = NULL;
public function __construct()
{
{
}
- public function login()
+ /**
+ * Login a user and then redirect it to the last page which must be encoded
+ * in $redirect.
+ *
+ * @param string $redirect contains the last page URI segments encoded
+ * with helper url_encode_segments.
+ */
+ public function login($redirect = '')
{
$this->load->library('form_validation');
$this->load->model('users_model');
-
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- $form_validation_config = array(
- array(
- 'field'=>'username',
- 'label'=>'lang:user_username_or_email',
- 'rules'=>'trim|required|min_length[5]|max_length[32]'
- . '|strtolower|callback__valid_username'
- . '|callback__do_login[password]'
- ),
- array(
- 'field'=>'password',
- 'label'=>'lang:user_password',
- 'rules'=>'required|min_length[5]|max_length[32]'
- )
- );
- $this->form_validation->set_rules($form_validation_config);
$this->form_validation->set_error_delimiters('<span class="error">',
'</span>');
- if ($this->form_validation->run() === FALSE)
+ if ($this->form_validation->run('signin') === FALSE)
{
- $params = array( 'title' => $this->config->item('site_name'),
- 'css' => array(
- 'catalog.css'
- ),
- //'js' => array(),
- //'metas' => array('description'=>'')
+ $params = array( 'title' =>
+ $this->lang->line('ui_nav_menu_login')
+ .' – '
+ . $this->config->item('site_name'),
+ //'metas' => array('description'=>'')
);
$this->load->library('html_head_params', $params);
$this->load->view('html_begin', $this->html_head_params);
$this->load->view('header', array('selected_menu' => 'login'));
- $this->load->view('user/login_view', array());
+ $this->load->view('user/login_view', array(
+ 'redirect'=> $redirect
+ ));
$this->load->view('footer');
$this->load->view('html_end');
'user_id'=> $this->user_id,
'username'=> $this->username
));
+
+ // Redirect to last page before login.
+ header('Location: '. site_url(urldecode_segments($redirect)));
+ }
+ else
+ {
+ $this->session->set_userdata(array(
+ 'username'=> $this->username
+ ));
+
+ // Redirect to register page because an user authenticates here
+ // for the first time with LDAP.
+ // TODO
+ header('Location: '. site_url(urldecode_segments($redirect)));
}
+ }
+ }
+
+ /**
+ * Logout user and then redirect it to the last page which must be encoded
+ * in $redirect.
+ *
+ * @param string $redirect contains the last page URI segments encoded
+ * with helper url_encode_segments.
+ */
+ public function logout($redirect = '')
+ {
+ $this->session->unset_userdata('user_id');
+ $this->session->unset_userdata('username');
+
+ header('Location: '. site_url(urldecode_segments($redirect)));
+ }
+
+ public function register($redirect = '')
+ {
+ $this->load->library('form_validation');
+ $this->load->model('users_model');
+ $this->load->helper('localization');
+ $this->load->helper('date');
- header('Location: '. site_url());
- return;
+ $this->form_validation->set_error_delimiters('<span class="error">',
+ '</span>');
+
+ if ($this->form_validation->run('register') === FALSE)
+ {
+ $params = array('title' =>
+ $this->lang->line('ui_nav_menu_register')
+ .' – '
+ . $this->config->item('site_name'),
+ //'metas' => array('description'=>'')
+ );
+ $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' => 'register'));
+
+ $this->load->view('user/register_view', array(
+ 'redirect'=> $redirect
+ ));
+
+ $this->load->view('footer');
+ $this->load->view('html_end');
+ }
+ else
+ {
+ if ($this->user_id !== NULL)
+ {
+ $this->session->set_userdata(array(
+ 'user_id'=> $this->user_id,
+ 'username'=> $this->username
+ ));
+
+ // Redirect to last page before login.
+ header('Location: '. site_url(urldecode_segments($redirect)));
+ }
+ else
+ {
+ $this->session->set_userdata(array(
+ 'username'=> $this->username
+ ));
+
+ // Redirect to register page because an user authenticates here
+ // for the first time with LDAP.
+ // TODO
+ header('Location: '. site_url(urldecode_segments($redirect)));
+ }
}
}
-
+
public function _valid_username($username)
+ {
+ return (preg_match('/^[a-z0-9\._]+$/', $username) == 1);
+ }
+
+ public function _valid_username_or_email($username)
{
$this->load->helper('email');
if (valid_email($username))
- return TRUE;
+ return TRUE;
else
- return (preg_match('/^[a-z0-9\._]+$/', $username) == 1);
+ return $this->_valid_username($username);
}
public function _do_login($username, $field_password)
$password = $this->input->post('password');
$this->load->model('users_model');
- $res_login = $this->users_model->login($username, $password);
+ $user = $this->users_model->login($username, $password);
+ // Authentication failed
+ if ($user === FALSE)
+ return FALSE;
+
// First authentication of a user with LDAP, i.e. the user does not
// have an user_id in `users` DB table yet.
- if ($res_login === TRUE)
+ if ($user['auth_src'] == 'ldap_first_time')
+ {
+ $this->ldap_user_info = $user;
+ $this->username = $user['uid'][0];
+ $this->email = $user['mail'][0];
return TRUE;
- // Authentication failed
- else if ($res_login === FALSE)
- return FALSE;
+ }
// Authentication when the user has an user_id in the DB.
- $this->username = $res_login['username'];
- $this->email = $res_login['email'];
- $this->user_id = $res_login['id'];
-
+ $this->username = $user['username'];
+ $this->email = $user['email'];
+ $this->user_id = $user['id'];
+
return TRUE;
}
}
$data['plugin_type'] = ($plugin === NULL ? 'auto' : $plugin);
// Display page.
- $params = array( 'title' => $data['video']['title'] . ' -- '
+ $params = array( 'title' => $data['video']['title'] . ' – '
. $this->config->item('site_name'),
'css' => array(
'jquery.ui.nsvideo.css',
--- /dev/null
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+/**
+ * Encodes CI segments for using them in URLs.
+ * Useful when the last page needs to be remembered in the URL.
+ * The function replaces all '/' with '\' and then encodes with urlencode PHP
+ * function.
+ *
+ * @param string $str segments string to encode
+ * @param string $disallowed_prefix if $str start with $disallowed_prefix the
+ * function returns a null string.
+ * @return string the encoded segments
+ */
+function urlencode_segments($str, $disallowed_prefix = NULL)
+{
+ if ($disallowed_prefix && strpos($str, $disallowed_prefix) === 0)
+ return '';
+
+ $str = str_replace('/', '\\', $str);
+ return urlencode($str);
+}
+
+/**
+ * Decodes a string encoded with urlencode_segments helper.
+ *
+ * @param string $str string to decode
+ * @return string the valid CI segments decoded from $str
+ */
+function urldecode_segments($str)
+{
+ $str = urldecode($str);
+ return str_replace('\\', '/', $str);
+}
+
+/* End of file MY_url_helper.php */
+/* Location: ./application/helpers/MY_url_helper.php */
\ No newline at end of file
--- /dev/null
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+function country_dropdown ( $name="country", $top_countries=array(),
+ $selection=NULL, $show_all=TRUE )
+{
+ $ci =& get_instance();
+ $ci->config->load('localization');
+ $countries = $ci->config->item('country_list');
+
+ $html = "<select name='{$name}'>";
+ $selected = NULL;
+ if(in_array($selection,$top_countries)) {
+ $top_selection = $selection;
+ $all_selection = NULL;
+ }
+ else {
+ $top_selection = NULL;
+ $all_selection = $selection;
+ }
+
+ if(!empty($top_countries)) {
+ foreach($top_countries as $value) {
+ if(array_key_exists($value, $countries)) {
+ if($value === $top_selection) {
+ $selected = 'selected="selected"';
+ }
+ $html .= "<option value='{$value}' {$selected}>{$countries[$value]}</option>";
+ $selected = NULL;
+ }
+ }
+ //$html .= "<option>----------</option>";
+ }
+
+ if($show_all) {
+ foreach($countries as $key => $country) {
+ if($key === $all_selection) {
+ $selected = 'selected="selected"';
+ }
+ $html .= "<option value='{$key}' {$selected}>{$country}</option>";
+ $selected = NULL;
+ }
+ }
+
+ $html .= "</select>";
+ return $html;
+}
+
+function available_languages_dropdown($name, $selection=NULL, $attributes='')
+{
+ $ci =& get_instance();
+ // Use the config file name.
+ $ci->config->load('p2p-tube');
+ $langs = $ci->config->item('available_languages_list');
+
+ $html = "<select name='{$name}' {$attributes}>";
+ $selected = NULL;
+
+ foreach($langs as $key=> $value)
+ {
+ if($key == $selection)
+ {
+ $selected = 'selected="selected"';
+ }
+ $value = ucwords($value);
+ $html .= "<option value='{$key}' {$selected}>{$value}</option>";
+ $selected = NULL;
+ }
+
+ $html .= '</select>';
+
+ return $html;
+}
+
+/* End of file localization_helper.php */
+/* Location: ./application/helpers/localization_helper.php */
\ No newline at end of file
<?php
+$lang['article_install-plugins'] = 'Install Plugins';
$lang['article_about'] = 'About Us';
+$lang['article_help'] = 'Help';
+$lang['article_contact'] = 'Contact';
/* End of file article_lang.php */
/* Location: ./application/language/english/article_lang.php */
\ No newline at end of file
include('system/language/english/form_validation_lang.php');
-$lang['_valid_username'] = "You must enter an e-mail address or a valid username.";
+$lang['_valid_username'] = 'You must enter a valid username with letters, numbers, . (dots) or _ (underscores).';
+$lang['_valid_username_or_email'] = "You must enter an e-mail address or a valid username.";
$lang['_do_login'] = "Wrong %s, or wrong %s.";
$lang['ui_nav_menu_contact'] = 'Contact';
$lang['ui_nav_menu_log_in'] = 'Log In';
$lang['ui_nav_menu_register'] = 'Register';
+$lang['ui_nav_menu_account'] = 'Account';
+$lang['ui_nav_menu_logout'] = 'Logout';
+
+$lang['ui_hello'] = 'Hello';
// Search
$lang['ui_search'] = 'Search';
$lang['user_new_password_confirmation'] = 'New Password Confirmation';
$lang['user_email'] = 'E-mail';
$lang['user_first_name'] = 'First Name';
-$lang['user_last_name'] = 'Last Name';
+$lang['user_last_name'] = 'Surname';
$lang['user_birth_date'] = 'Birth Date';
+$lang['user_date_format_hint'] = 'use format YEAR-MONTH-DAY';
$lang['user_country'] = 'Country';
-$lang['user_locality'] = 'Locality';
+$lang['user_locality'] = 'City / Town';
$lang['user_ui_lang'] = 'Site Interface Language';
$lang['user_time_zone'] = 'Time Zone';
$lang['user_role'] = 'Roles';
$lang['user_auth_src'] = 'Authentication Source';
$lang['user_video_prefs'] = 'Video Preferences';
+$lang['user_note_required_fields'] = '* Required fields!';
/* End of file user_lang.php */
/* Location: ./application/language/english/user_lang.php */
\ No newline at end of file
*
* @param string $username
* @param string $password
+ * @return mixed can return FALSE if authentication failed, a DB row as an
+ * associative array if authentication was succesful or an associative
+ * array with LDAP user information if authentication with LDAP was
+ * successful but the user logged in for the first time and it does not
+ * have an entry in `users` table yet. The key 'auth_src' distinguishes
+ * which associative array was returned:
+ * <ul>
+ * <li>'internal' or 'ldap': a DB row</li>
+ * <li>'ldap_first_time': LDAP user information</li>
+ * </ul>
*/
public function login($username, $password)
{
// TODO select only required fields.
$query = $this->db->query("SELECT * FROM `users`
- WHERE $cond_user AND password = '$enc_password'");
+ WHERE $cond_user
+ AND (auth_src = 'ldap' OR password = '$enc_password')");
+ // It is possible that the user has a LDAP account but he's
+ // authenticating here for the first time so it does not have an entry
+ // in `users` table.
if ($query->num_rows() !== 1)
+ return $this->ldap_login($username, $password);
+
+ $user = $query->row_array();
+
+ // Authenticate with LDAP.
+ if ($user['auth_src'] == 'ldap')
+ return ($this->ldap_login($username, $password) !== FALSE
+ ? $user : FALSE);
+
+ // If we are here internal authentication has successful.
+ return $user;
+ }
+
+ /**
+ * Login with LDAP.
+ *
+ * @param string $username
+ * @param string $password
+ * @return boolean
+ * @author Alex Herișanu, Răzvan Deaconescu, Călin-Andrei Burloiu
+ */
+ public function ldap_login($username, $password)
+ {
+ $this->config->load('ldap');
+
+ // First connection: binding.
+ // TODO exception
+ $ds = ldap_connect($this->config->item('ldap_server')) or die("Can't connect to ldap server.\n");
+ if (!@ldap_bind($ds, $this->config->item('ldap_bind_user'),
+ $this->config->item('ldap_bind_password')))
+ {
+ ldap_close($ds);
+ die("Can't connect to ".$this->config->item('ldap_server')."\n");
return FALSE;
-
- return $query->row_array();
+ }
+ $sr = ldap_search($ds, "dc=cs,dc=curs,dc=pub,dc=ro", "(uid=" . $username . ")");
+ if (ldap_count_entries($ds, $sr) > 1)
+ die("Multiple entries with the same uid in LDAP database??");
+ if (ldap_count_entries($ds, $sr) < 1) {
+ ldap_close($ds);
+ return FALSE;
+ }
+
+ $info = ldap_get_entries($ds, $sr);
+ $dn = $info[0]["dn"];
+ ldap_close($ds);
+
+ // Second connection: connect with user's credentials.
+ $ds = ldap_connect($this->config->item('ldap_server')) or die("Can't connect to ldap server\n");
+ if (!@ldap_bind($ds, $dn, $password) or $password == '') {
+ ldap_close($ds);
+ return FALSE;
+ }
+
+ // Verifify if DN belongs to the requested OU.
+ $info[0]['ou_ok'] = $this->ldap_dn_belongs_ou( $dn, $this->config->item('ldap_req_ou') );
+
+ // Set authentication source.
+ $info[0]['auth_src'] = 'ldap_first_time';
+
+ return $info[0];
+ }
+
+ /**
+ * Verify if a user belongs to a group.
+ *
+ * @param string $dn = "ou=Student,ou=People..."
+ * @param array $ou = array ("Student", etc
+ * @return TRUE or FALSE
+ * @author Răzvan Herișanu, Răzvan Deaconescu, Călin-Andrei Burloiu
+ */
+ public function ldap_dn_belongs_ou($dn, $ou)
+ {
+ if (!is_array($ou))
+ $ou = array ($ou);
+
+ $founded = FALSE;
+ $words = explode(',', $dn);
+ foreach ($words as $c) {
+ $parts = explode("=", $c);
+ $key = $parts[0];
+ $value = $parts[1];
+
+ if (strtolower($key) == "ou" && in_array($value, $ou) )
+ $founded = TRUE;
+ }
+ return $founded;
}
}
-<?php
+<?php
+ // Selected menu
if (! isset($selected_menu))
$selected_menu = '';
+ // Searching
if (! isset($search_query))
$search_query = '';
if (! isset($search_category_name))
$search_category_name = 'all-categories';
-
+ // Categories
$categories['all-categories'] = $this->lang->line('ui_categ_all-categories');
foreach ($this->config->item('categories') as $id => $name)
{
$categories[$name] = $this->lang->line("ui_categ_$name");
}
+ // Username
+ $username = $this->session->userdata('username');
?>
<ul
<?php echo ($selected_menu == 'contact' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_contact') ?>
</a></li>
- <?php if (isset($username) && $username): ?>
- <li class="menu-right"><a href="<?php echo '#'//site_url('register') ?>"
- <?php echo ($selected_menu == 'account' ? 'class="selected"' : '') ?>><?php echo $username ?></a></li>
+ <?php if ($username): ?>
+ <li class="menu-right"><a href="<?php echo site_url('user/logout/' . urlencode_segments(uri_string())) ?>"
+ <?php echo ($selected_menu == 'logout' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_logout') ?></a>
+ </li>
+
+ <li class="menu-right"><a href="<?php echo site_url('user/account') ?>"
+ <?php echo ($selected_menu == 'account' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_account') ?></a>
+ </li>
+
+ <li class="menu-right"><span class="menu-greeting">
+ <?php echo $this->lang->line('ui_hello'). ', '. $username. '! ' ?></span>
+ </li>
+
<?php else: ?>
- <li class="menu-right"><a href="<?php echo '#'//site_url('register') ?>"
- <?php echo ($selected_menu == 'register' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_register') ?></a></li>
+ <li class="menu-right"><a href="<?php echo site_url('user/register/'. urlencode_segments(uri_string(), 'user/register')) ?>"
+ <?php echo ($selected_menu == 'register' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_register') ?></a>
+ </li>
- <li class="menu-right"><a href="<?php echo site_url('user/login') ?>"
- <?php echo ($selected_menu == 'login' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_log_in') ?></a></li>
+ <li class="menu-right"><a href="<?php echo site_url('user/login/'. urlencode_segments(uri_string(), 'user/login')) ?>"
+ <?php echo ($selected_menu == 'login' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_log_in') ?></a>
+ </li>
<?php endif; ?>
</ul>
-
-<?php echo form_open('user/login') ?>
+<?php echo form_open("user/login/$redirect") ?>
<table class="form">
<tr>
<th><?php echo $this->lang->line('user_username_or_email'). ': ' ?></th>
--- /dev/null
+<?php echo form_open("user/register/$redirect") ?>
+<table class="form">
+ <tr>
+ <td class="form-header"></td>
+ <td><span class="required"><?php echo $this->lang->line('user_note_required_fields') ?></span></td>
+ </tr>
+
+ <tr><td></td><td> </td></tr>
+
+ <tr>
+ <th><?php echo $this->lang->line('user_username'). ' <span class="required">*</span> ' ?></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'). ' <span class="required">*</span> ' ?></th>
+ <td>
+ <input type="password" name="password" size="16" value="" />
+ </td>
+ </tr>
+ <tr><td></td><td><?php echo form_error('password') ?></td></tr>
+
+ <tr>
+ <th><?php echo $this->lang->line('user_password_confirmation'). ' <span class="required">*</span> ' ?></th>
+ <td>
+ <input type="password" name="password-confirmation" size="16" value="" />
+ </td>
+ </tr>
+ <tr><td></td><td><?php echo form_error('password-confirmation') ?></td></tr>
+
+ <tr>
+ <th><?php echo $this->lang->line('user_email'). ' <span class="required">*</span> ' ?></th>
+ <td>
+ <input type="text" name="email" size="16" value="<?php echo set_value('email') ?>" />
+ </td>
+ </tr>
+ <tr><td></td><td><?php echo form_error('email') ?></td></tr>
+
+ <tr><td></td><td> </td></tr>
+
+ <tr>
+ <th><?php echo $this->lang->line('user_first_name'). ' <span class="required">*</span> ' ?></th>
+ <td>
+ <input type="text" name="first-name" size="16" value="<?php echo set_value('first-name') ?>" />
+ </td>
+ </tr>
+ <tr><td></td><td><?php echo form_error('first-name') ?></td></tr>
+
+ <tr>
+ <th><?php echo $this->lang->line('user_last_name'). ' <span class="required">*</span> ' ?></th>
+ <td>
+ <input type="text" name="last-name" size="16" value="<?php echo set_value('last-name') ?>" />
+ </td>
+ </tr>
+ <tr><td></td><td><?php echo form_error('last-name') ?></td></tr>
+
+ <tr>
+ <th><?php echo $this->lang->line('user_birth_date'). ' ' ?></th>
+ <td>
+ <input type="text" name="birth-date" id="birth-date" size="16" value="<?php echo set_value('birth-date') ?>" /> (<?php echo $this->lang->line('user_date_format_hint') ?>)
+ </td>
+ </tr>
+ <tr><td></td><td><?php echo form_error('birth-date') ?></td></tr>
+
+ <tr>
+ <th><?php echo $this->lang->line('user_country'). ' <span class="required">*</span> ' ?></th>
+ <td>
+ <?php echo country_dropdown('country', array('RO'), set_value('country', 'RO')) ?>
+ </td>
+ </tr>
+ <tr><td></td><td><?php echo form_error('country') ?></td></tr>
+
+ <tr>
+ <th><?php echo $this->lang->line('user_locality'). ' ' ?></th>
+ <td>
+ <input type="text" name="locality" size="16" value="<?php echo set_value('locality') ?>" />
+ </td>
+ </tr>
+ <tr><td></td><td><?php echo form_error('locality') ?></td></tr>
+
+ <tr><td></td><td> </td></tr>
+
+ <tr>
+ <th><?php echo $this->lang->line('user_ui_lang'). ' ' ?></th>
+ <td>
+ <?php echo available_languages_dropdown('ui-lang', set_value('ui-lang', 'en')) ?>
+ </td>
+ </tr>
+ <tr><td></td><td><?php echo form_error('ui-lang') ?></td></tr>
+
+ <tr>
+ <th><?php echo $this->lang->line('user_time_zone'). ' <span class="required">*</span> ' ?></th>
+ <td>
+ <?php echo timezone_menu(set_value('time-zone', 'UP2')) ?>
+ </td>
+ </tr>
+ <tr><td></td><td><?php echo form_error('time-zone') ?></td></tr>
+
+ <tr><td></td><td> </td></tr>
+
+ <tr>
+ <td></td>
+ <td>
+ <input type="submit" value="<?php echo $this->lang->line('ui_nav_menu_register') ?>" />
+ </td>
+ </tr>
+</table>
+</form>
+
+<script type="text/javascript">
+ $(function() {
+ $( "#birth-date" ).datepicker({
+ dateFormat: "yy-mm-dd",
+ changeMonth: true,
+ changeYear: true,
+ yearRange: '1910:2011',
+ showOn: "both",
+ buttonImage: "<?php echo site_url('img/calendar.gif') ?>",
+ buttonImageOnly: true
+ });
+ });
+</script>
\ No newline at end of file
table.form th
{
text-align: right;
+ /*width: 25%;*/
+}
+table.form td
+{
+ vertical-align: bottom;
}
.error
color: red;
font-weight:bold;
}
+.required
+{
+ color: red;
+ font-weight:bold;
+}
.inline
{
color: #FFE4B5;
font-weight: bold;
}
+.menu-greeting
+{
+ display: block;
+ height: 12px;
+ color: #FFE4B5;
+ text-align: center;
+ line-height: 100%;
+ font-size: 14px;
+ padding-top: 5px;
+ padding-bottom: 5px;
+ padding-left: 16px;
+ padding-right: 16px;
+ border: 1px solid transparent;
+ text-decoration: none;
+}
#header
{
--- /dev/null
+#!/bin/bash
+
+rsync -avz ../ p2p-next@koala.cs.pub.ro:public_html/devel/