Exemple #1
0
 public function _edit()
 {
     $tMessage = $this->processSave();
     $oPosts = model_posts::getInstance()->findById(_root::getParam('id'));
     $oView = new _view('privatePosts::edit');
     $oView->oPosts = $oPosts;
     $oView->tId = model_posts::getInstance()->getIdTab();
     $oView->tJoinmodel_users = model_users::getInstance()->getSelect();
     $oView->tJoinmodel_categories = model_categories::getInstance()->getSelect();
     $oPluginXsrf = new plugin_xsrf();
     $oView->token = $oPluginXsrf->getToken();
     $oView->tMessage = $tMessage;
     $this->oLayout->add('main', $oView);
 }
Exemple #2
0
 private function checkLoginPass()
 {
     //si le formulaire n'est pas envoye on s'arrete la
     if (!_root::getRequest()->isPost()) {
         return null;
     }
     $sLogin = _root::getParam('login');
     $sPassword = _root::getParam('password');
     if (strlen($sPassword > $this->maxPasswordLength)) {
         return 'Mot de passe trop long';
     }
     //on stoque les mots de passe hashe dans la classe model_users
     $sHashPassword = model_users::getInstance()->hashPassword($sPassword);
     $tAccount = model_users::getInstance()->getListAccount();
     //on va verifier que l'on trouve dans le tableau retourne par notre model
     //l'entree $tAccount[ login ][ mot de passe hashe ]
     if (!_root::getAuth()->checkLoginPass($tAccount, $sLogin, $sHashPassword)) {
         return 'Mauvais login/mot de passe';
     }
     _root::redirect('privatePosts::list');
 }
Exemple #3
0
 public function _show()
 {
     $oPosts = model_posts::getInstance()->findBySlug(module_posts::getParam('slug'));
     $oView = new _view('posts::show');
     $oView->oPosts = $oPosts;
     $oView->tJoinmodel_categories = model_categories::getInstance()->getSelect();
     $oView->tJoinmodel_users = model_users::getInstance()->getSelect();
     //we instance the module
     $oModuleComments = new module_comments();
     $oModuleComments->setPostId(module_posts::getParam('id'));
     //si vous souhaitez indiquer au module integrable des informations sur le module parent
     $oModuleComments->setRootLink('default::index', array('postsAction' => 'show', 'postsid' => _root::getParam('postsid')));
     //form add
     $oView->oCommentsAdd = $oModuleComments->_new();
     //comments
     $oView->oComments = $oModuleComments->_index();
     return $oView;
 }
Exemple #4
0
 public function update_user()
 {
     $this->load->model('model_users');
     $data = new model_users();
     $data->user_id = $this->input->post('user-id');
     $data->username = $this->input->post('username');
     $data->password = $this->input->post('password');
     $data->first_name = $this->input->post('first-name');
     $data->middle_name = $this->input->post('middle-name');
     $data->last_name = $this->input->post('last-name');
     $data->email = $this->input->post('email');
     $data->phone = $this->input->post('phone');
     $result = $data->update_user();
     if (!$result) {
         echo mysqli_error($result);
     } else {
         redirect('site/admin', 'refresh');
     }
 }
Exemple #5
0
 private final function connect_ntlm()
 {
     if (!isset($_SERVER['HTTP_AUTHORIZATION'])) {
         // step 1
         header("HTTP/1.1 401 Unauthorized");
         // step 2
         header("WWW-Authenticate: NTLM");
     }
     if (isset($_SERVER['HTTP_AUTHORIZATION']) && substr($_SERVER['HTTP_AUTHORIZATION'], 0, 5) == 'NTLM ') {
         $chaine = $_SERVER['HTTP_AUTHORIZATION'];
         $chaine = substr($chaine, 5);
         // type1 message
         $chained64 = base64_decode($chaine);
         if (ord($chained64[8]) == 1) {
             // step 3
             $retAuth = "NTLMSSP";
             $retAuth .= chr(0) . chr(2) . chr(0) . chr(0);
             $retAuth .= chr(0) . chr(0) . chr(0) . chr(0);
             $retAuth .= chr(0) . chr(40) . chr(0) . chr(0);
             $retAuth .= chr(0) . chr(1) . chr(130) . chr(0);
             $retAuth .= chr(0) . chr(0) . chr(2) . chr(2);
             $retAuth .= chr(2) . chr(0) . chr(0) . chr(0);
             $retAuth .= chr(0) . chr(0) . chr(0) . chr(0);
             $retAuth .= chr(0) . chr(0) . chr(0) . chr(0) . chr(0);
             $retAuth64 = base64_encode($retAuth);
             $retAuth64 = trim($retAuth64);
             header("HTTP/1.1 401 Unauthorized");
             // step 4
             header("WWW-Authenticate: NTLM {$retAuth64}");
         } else {
             if (ord($chained64[8]) == 3) {
                 // step 5
                 $lenght_domain = ord($chained64[31]) * 256 + ord($chained64[30]);
                 $offset_domain = ord($chained64[33]) * 256 + ord($chained64[32]);
                 $domain = substr($chained64, $offset_domain, $lenght_domain);
                 $lenght_login = ord($chained64[39]) * 256 + ord($chained64[38]);
                 $offset_login = ord($chained64[41]) * 256 + ord($chained64[40]);
                 $login = substr($chained64, $offset_login, $lenght_login);
                 $lenght_host = ord($chained64[47]) * 256 + ord($chained64[46]);
                 $offset_host = ord($chained64[49]) * 256 + ord($chained64[48]);
                 $host = substr($chained64, $offset_host, $lenght_host);
             }
         }
     }
     if (isset($login)) {
         $this->http_auth_complete = true;
         $username = preg_replace("/(.)(.)/", "\$1", $login);
         $domain = preg_replace("/(.)(.)/", "\$1", $domain);
         $username = strtolower($username);
         $domain = strtoupper($domain);
     }
     if (isset($username)) {
         $model_users = new model_users();
         $user = $model_users->auth($username);
         if (count($user) > 0 && $domain == core_settings::i()->get('CONFIG_AUTH_NTLM_DOMAIN')) {
             // if the user exists and there on the domain....
             $_SESSION = array();
             $_SESSION['users'] = $user[0];
             return true;
         } else {
             if (!($ad_connention = @ldap_connect(core_settings::i()->get('CONFIG_SERVERS_LDAP_IP')))) {
                 //return false;
             }
             ldap_set_option($ad_connention, LDAP_OPT_PROTOCOL_VERSION, 3);
             ldap_set_option($ad_connention, LDAP_OPT_REFERRALS, 0);
             if (!@ldap_bind($ad_connention, core_settings::i()->get('CONFIG_SERVERS_LDAP_BIND_USER') . core_settings::i()->get('CONFIG_SERVERS_LDAP_USER_SUFFIX'), core_settings::i()->get('CONFIG_SERVERS_LDAP_BIND_PASS'))) {
                 //return false;
             }
             $dn = "OU=Staff,OU=Users,OU=TC,DC=ad,DC=Trafford,DC=ac,DC=uk";
             $filter = '(|(sAMAccountName=' . $username . '*))';
             $justthese = array("givenName", "sn", "sAMAccountName", "title", "description", "department", "telephoneNumber", "physicalDeliveryOfficeName", "mail");
             $sr = ldap_search($ad_connention, $dn, $filter, $justthese);
             $info = ldap_get_entries($ad_connention, $sr);
             if ($info['count'] > 0) {
                 $user = new user_itrafford(NULL, isset($info[0]['samaccountname'][0]) ? $info[0]['samaccountname'][0] : '', 'firstvisit', isset($info[0]['givenname'][0]) ? $info[0]['givenname'][0] : '', isset($info[0]['sn'][0]) ? $info[0]['sn'][0] : '', 'staff', NULL, NULL, isset($info[0]['title'][0]) ? $info[0]['title'][0] : '', isset($info[0]['description'][0]) ? $info[0]['description'][0] : '', isset($info[0]['department'][0]) ? $info[0]['department'][0] : '', isset($info[0]['telephonenumber'][0]) ? $info[0]['telephonenumber'][0] : '', isset($info[0]['mail'][0]) ? $info[0]['mail'][0] : '', isset($info[0]['physicalDeliveryOfficeName'][0]) ? $info[0]['physicalDeliveryOfficeName'][0] : '', NULL);
                 $model_users->create($user);
                 return true;
             } else {
                 $dn = "OU=Students,OU=Users,OU=TC,DC=ad,DC=Trafford,DC=ac,DC=uk";
                 $filter = '(|(sAMAccountName=' . $username . '*))';
                 $justthese = array("givenName", "sn", "sAMAccountName", "title", "description", "department", "telephoneNumber", "physicalDeliveryOfficeName", "mail");
                 $sr = ldap_search($ad_connention, $dn, $filter, $justthese);
                 $info = ldap_get_entries($ad_connention, $sr);
                 if ($info['count'] > 0) {
                     $user = new user_itrafford(NULL, isset($info[0]['samaccountname'][0]) ? $info[0]['samaccountname'][0] : '', 'firstvisit', isset($info[0]['givenname'][0]) ? $info[0]['givenname'][0] : '', isset($info[0]['sn'][0]) ? $info[0]['sn'][0] : '', 'student', NULL, NULL, isset($info[0]['title'][0]) ? $info[0]['title'][0] : '', isset($info[0]['description'][0]) ? $info[0]['description'][0] : '', isset($info[0]['department'][0]) ? $info[0]['department'][0] : '', isset($info[0]['telephonenumber'][0]) ? $info[0]['telephonenumber'][0] : '', isset($info[0]['mail'][0]) ? $info[0]['mail'][0] : '', isset($info[0]['physicalDeliveryOfficeName'][0]) ? $info[0]['physicalDeliveryOfficeName'][0] : '', NULL);
                     $model_users->create($user);
                     return true;
                 }
             }
             return false;
         }
     } else {
         return false;
     }
 }