function login()
 {
     global $toC_Json, $osC_Language, $osC_Database;
     $Qcheck_session = $osC_Database->query('select count(*) from :table_sessions');
     $Qcheck_session->bindTable(':table_sessions', TABLE_SESSIONS);
     $Qcheck_session->execute();
     if ($osC_Database->isError() || $Qcheck_session->numberOfRows() < 1) {
         $Qrepaire = $osC_Database->query('repair table :table_sessions');
         $Qrepaire->bindTable(':table_sessions', TABLE_SESSIONS);
         $Qrepaire->execute();
         $Qrepaire->freeResult();
     }
     $Qcheck_session->freeResult();
     $response = array();
     if (!empty($_REQUEST['user_name']) && !empty($_REQUEST['user_password'])) {
         $Qadmin = $osC_Database->query('select id, user_name, user_password from :table_administrators where user_name = :user_name');
         $Qadmin->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
         $Qadmin->bindValue(':user_name', $_REQUEST['user_name']);
         $Qadmin->execute();
         if ($Qadmin->numberOfRows() > 0) {
             while ($Qadmin->next()) {
                 if (osc_validate_password($_REQUEST['user_password'], $Qadmin->value('user_password'))) {
                     $_SESSION['admin'] = array('id' => $Qadmin->valueInt('id'), 'username' => $Qadmin->value('user_name'), 'access' => osC_Access::getUserLevels($Qadmin->valueInt('id')));
                     $response['success'] = true;
                     echo $toC_Json->encode($response);
                     exit;
                 }
             }
         }
     }
     $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_login_invalid'));
     echo $toC_Json->encode($response);
 }
 public static function execute($data)
 {
     $result = OSCOM::callDB('Admin\\Login\\GetAdmin', array('username' => $data['username']));
     if (!empty($result)) {
         return osc_validate_password($data['password'], $result['user_password']);
     }
     return false;
 }
 function login($user_name, $user_password)
 {
     global $osC_Database;
     $response = array();
     if (!empty($user_name) && !empty($user_password)) {
         $Qadmin = $osC_Database->query('select id, user_name, user_password from :table_administrators where user_name = :user_name');
         $Qadmin->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
         $Qadmin->bindValue(':user_name', $user_name);
         $Qadmin->execute();
         if ($Qadmin->numberOfRows() > 0) {
             if (osc_validate_password($user_password, $Qadmin->value('user_password'))) {
                 $_SESSION['admin'] = array('id' => $Qadmin->valueInt('id'), 'username' => $Qadmin->value('user_name'));
                 return true;
             }
         }
     }
     return false;
 }
Example #4
0
 public static function execute(ApplicationAbstract $application)
 {
     if (!empty($_POST['user_name']) && !empty($_POST['user_password'])) {
         $Qadmin = Registry::get('Database')->query('select id, user_name, user_password from :table_administrators where user_name = :user_name limit 1');
         $Qadmin->bindValue(':user_name', $_POST['user_name']);
         $Qadmin->execute();
         if ($Qadmin->numberOfRows() === 1) {
             if (osc_validate_password($_POST['user_password'], $Qadmin->value('user_password'))) {
                 $_SESSION[OSCOM::getSite()]['id'] = $Qadmin->valueInt('id');
                 $_SESSION[OSCOM::getSite()]['username'] = $Qadmin->value('user_name');
                 $_SESSION[OSCOM::getSite()]['access'] = Access::getUserLevels($Qadmin->valueInt('id'));
                 $to_application = OSCOM::getDefaultSiteApplication();
                 if (isset($_SESSION[OSCOM::getSite()]['redirect_origin'])) {
                     $to_application = $_SESSION[OSCOM::getSite()]['redirect_origin'];
                     unset($_SESSION[OSCOM::getSite()]['redirect_origin']);
                 }
                 osc_redirect_admin(OSCOM::getLink(null, $to_application));
             }
         }
     }
     Registry::get('MessageStack')->add('header', OSCOM::getDef('ms_error_login_invalid'), 'error');
 }
Example #5
0
 public function __construct()
 {
     global $osC_Database, $osC_Language, $osC_MessageStack;
     parent::__construct();
     if (!empty($_POST['user_name']) && !empty($_POST['user_password'])) {
         $Qadmin = $osC_Database->query('select id, user_name, user_password from :table_administrators where user_name = :user_name');
         $Qadmin->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
         $Qadmin->bindValue(':user_name', $_POST['user_name']);
         $Qadmin->execute();
         if ($Qadmin->numberOfRows()) {
             if (osc_validate_password($_POST['user_password'], $Qadmin->value('user_password'))) {
                 $_SESSION['admin'] = array('id' => $Qadmin->valueInt('id'), 'username' => $Qadmin->value('user_name'), 'access' => osC_Access::getUserLevels($Qadmin->valueInt('id')));
                 $get_string = null;
                 if (isset($_SESSION['redirect_origin'])) {
                     $get_string = http_build_query($_SESSION['redirect_origin']['get']);
                     unset($_SESSION['redirect_origin']);
                 }
                 osc_redirect_admin(osc_href_link_admin(FILENAME_DEFAULT, $get_string));
             }
         }
     }
     $osC_MessageStack->add('header', $osC_Language->get('ms_error_login_invalid'), 'error');
 }