Ejemplo n.º 1
0
 public function login()
 {
     $params = $this->AuthInfo;
     $username = $params['user'];
     $passhash = $params['passhash'];
     $token = $params['token'];
     $app_type = $params['appType'];
     $session_id = $params['session'];
     $ip = $_SERVER['REMOTE_ADDR'];
     $language = isset($params['language']) ? $params['language'] : 'en';
     $this->Response->setDebug('parameters', $params);
     setcookie("kt_language", $language, 2147483647, '/');
     $kt =& $this->KT;
     if ($username != 'admin') {
         require_once KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php';
         if (!BaobabKeyUtil::checkIfLicensed(true)) {
             return array('authenticated' => false, 'message' => 'license_expired');
         }
     }
     $user = $kt->get_user_object_by_username($username);
     if (!PEAR::isError($user)) {
         $password = $user->getPassword();
         $localPassHash = md5($password . $token);
         if ($localPassHash == $passhash) {
             $session = new stdClass();
             $this->Response->setDebug('trying to start session with', array('username' => $username, 'password' => $password));
             $session = $kt->start_session($username, $params['pass'], NULL, $app_type);
             if (!PEAR::isError($session)) {
                 $this->Response->setStatus('session_id', $session->get_session());
             } else {
                 $this->Response->setDebug('failed login', print_r($session, true));
                 throw new Exception('Unknown Login Error');
                 return false;
             }
         } else {
             throw new Exception('Incorrect Credentials');
             return false;
         }
     } else {
         throw new Exception('Unrecognized User');
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 public function login()
 {
     $params = $this->AuthInfo;
     $username = $params['user'];
     $passhash = $params['passhash'];
     $token = $params['token'];
     $app_type = $params['appType'];
     $session_id = $params['session'];
     $ip = $_SERVER['REMOTE_ADDR'];
     $language = isset($params['language']) ? $params['language'] : 'en';
     $this->Response->setDebug('parameters', $params);
     setcookie("kt_language", $language, 2147483647, '/');
     $kt =& $this->KT;
     if ($username != 'admin') {
         //$this->addDebug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@','');
         try {
             if (class_exists('BaobabKeyUtil')) {
                 if (!BaobabKeyUtil::checkIfLicensed(true)) {
                     $this->setResponse(array('authenticated' => false, 'message' => 'license_expired'));
                     $this->addError('Licence Expired');
                     return false;
                 }
             } else {
                 $this->addError('Licence Utility could not be loaded. Appears to be a Community version.');
                 $this->setResponse(array('authenticated' => false, 'message' => 'Licence Utility could not be loaded. Appears to be a Community version.'));
                 return false;
             }
         } catch (Exception $e) {
             $this->addError('could not execute BaobabKeyUtil::checkIfLicensed');
             $this->setResponse(array('authenticated' => false, 'message' => 'BaobabKeyUtil::checkIfLicensed error'));
             return;
         }
     }
     $user = $kt->get_user_object_by_username($username);
     if (!PEAR::isError($user)) {
         $password = $user->getPassword();
         $localPassHash = md5($password . $token);
         if ($localPassHash == $passhash) {
             $session = new stdClass();
             $this->Response->setDebug('trying to start session with', array('username' => $username, 'password' => $password));
             $session = $kt->start_session($username, $params['pass'], NULL, $app_type);
             if (!PEAR::isError($session)) {
                 $this->Response->setStatus('session_id', $session->get_session());
             } else {
                 $this->setResponse(array('authenticated' => false, 'message' => 'Invalid username and/or password.'));
                 $this->addDebug('failed login', print_r($session, true));
                 $this->addError('Unknown Login Error');
                 return false;
             }
         } else {
             $this->addError('Incorrect Credentials');
             //throw new Exception('Incorrect Credentials');
             return false;
         }
     } else {
         $this->addError('Incorrect Credentials');
         //throw new Exception('Unrecognized User');
         return false;
     }
     return true;
 }
Ejemplo n.º 3
0
 function do_change_enabled()
 {
     $this->startTransaction();
     $iLicenses = 0;
     $bRequireLicenses = false;
     if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
         $path = KTPluginUtil::getPluginPath('ktdms.wintools');
         require_once $path . 'baobabkeyutil.inc.php';
         $iLicenses = BaobabKeyUtil::getLicenseCount();
         $bRequireLicenses = true;
     }
     // admin and anonymous are automatically ignored here.
     $iEnabledUsers = User::getNumberEnabledUsers();
     if ($_REQUEST['update_value'] == 'enable') {
         foreach (KTUtil::arrayGet($_REQUEST, 'edit_user', array()) as $sUserId => $v) {
             // check that we haven't hit max user limit
             if ($bRequireLicenses && $iEnabledUsers >= $iLicenses) {
                 // if so, add to error messages, but commit transaction (break this loop)
                 $_SESSION['KTErrorMessage'][] = _kt('You may only have ') . $iLicenses . _kt(' users enabled at one time.');
                 break;
             }
             // else enable user
             $oUser = User::get((int) $sUserId);
             if (PEAR::isError($oUser)) {
                 $this->errorRedirectToMain(_kt('Error getting user object'));
             }
             $oUser->enable();
             $res = $oUser->update();
             if (PEAR::isError($res)) {
                 $this->errorRedirectToMain(_kt('Error updating user'));
             }
             $iEnabledUsers++;
         }
     }
     if ($_REQUEST['update_value'] == 'disable') {
         //echo 'got into disable';
         //exit;
         foreach (KTUtil::arrayGet($_REQUEST, 'edit_user', array()) as $sUserId => $v) {
             $oUser = User::get((int) $sUserId);
             if (PEAR::isError($oUser)) {
                 $this->errorRedirectToMain(_kt('Error getting user object'));
             }
             $oUser->disable();
             $res = $oUser->update();
             if (PEAR::isError($res)) {
                 $this->errorRedirectToMain(_kt('Error updating user'));
             }
             $iEnabledUsers--;
         }
     }
     if ($_REQUEST['update_value'] == 'delete') {
         //echo 'Delete called';
         foreach (KTUtil::arrayGet($_REQUEST, 'edit_user', array()) as $sUserId => $v) {
             $oUser = User::get((int) $sUserId);
             if (PEAR::isError($oUser)) {
                 $this->errorRedirectToMain(_kt('Error getting user object'));
             }
             $oUser->delete();
             $res = $oUser->update();
             if (PEAR::isError($res)) {
                 $this->errorRedirectToMain(_kt('Error updating user'));
             }
             $iEnabledUsers--;
         }
     }
     $this->commitTransaction();
     $this->successRedirectToMain(_kt('Users updated'));
 }
Ejemplo n.º 4
0
// site map definition
require_once KT_DIR . '/config/siteMap.inc';
require_once KT_LIB_DIR . '/session/Session.inc';
require_once KT_LIB_DIR . '/session/control.inc';
require_once KT_LIB_DIR . '/plugins/pluginutil.inc.php';
if ($checkup !== true) {
    // Replace function later
    /* ** Get the page being loaded and load the plugins specific to the page ** */
    $sScriptName = $GLOBALS['_SERVER']['SCRIPT_NAME'];
    $sScript = basename($sScriptName);
    $pos = strpos($sScript, '.');
    $sType = substr($sScript, 0, $pos);
    KTPluginUtil::loadPlugins($sType);
}
if ($checkup !== true) {
    if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
        $path = KTPluginUtil::getPluginPath('ktdms.wintools');
        require_once $path . 'baobabkeyutil.inc.php';
        $name = BaobabKeyUtil::getName();
        if ($name) {
            $default->versionName = sprintf('%s %s', $default->versionName, $name);
        }
    } else {
        $default->versionName = $default->versionName . ' ' . _kt('(Community Edition)');
    }
}
if (!extension_loaded('mbstring')) {
    require_once KT_LIB_DIR . '/mbstring.inc.php';
}
require_once KT_LIB_DIR . '/templating/kt3template.inc.php';
$GLOBALS['main'] = new KTPage();
Ejemplo n.º 5
0
 protected function checkCredentials()
 {
     $user = $this->auth['user'];
     $passHash = $this->auth['passhash'];
     $kt = $this->kt;
     /*
      * User Check
      */
     $o_user = $kt->get_user_object_by_username($user);
     if (PEAR::isError($o_user)) {
         if (!isset($this->errors['usernotfound'])) {
             $this->ret->addError('User ' . $user . ' not found');
         }
         $this->errors['usernotfound'] = true;
         return false;
     }
     /*
      * BAOBAB Licence Check
      */
     if ($user != 'admin') {
         try {
             if (class_exists('BaobabKeyUtil')) {
                 if (!BaobabKeyUtil::checkIfLicensed(true)) {
                     $this->ret->setResponse(array('authenticated' => false, 'message' => 'license_expired'));
                     $this->ret->addError('Licence Expired');
                     return false;
                 }
             } else {
                 $this->ret->addError('Licence Utility could not be loaded. Appears to be a Community version.');
                 $this->ret->setResponse(array('authenticated' => false, 'message' => 'Licence Utility could not be loaded. Appears to be a Community version.'));
                 return false;
             }
         } catch (Exception $e) {
             $this->ret->addError('could not execute BaobabKeyUtil::checkIfLicensed');
             $this->ret->setResponse(array('authenticated' => false, 'message' => 'BaobabKeyUtil::checkIfLicensed error'));
             return;
         }
     }
     /*
      * Password Check
      */
     try {
         $l_pass = $o_user->getPassword();
         $l_passHash = md5($l_pass . $this->auth['token']);
         $passed = $passHash == $l_passHash;
         $this->ret->setDebug('Auth', array('User Real Password' => $l_pass, 'User Real Password Hash' => $l_passHash, 'Received Password Hash' => $passHash, 'passed' => $passed));
         return $passed;
     } catch (Exception $e) {
         throw new Exception('Unknown credentialCheck error encountered');
         return false;
     }
     return ture;
 }
Ejemplo n.º 6
0
 /**
  * Method to check whether electronic signatures are enabled
  *
  * @author KnowledgeTree Team
  * @access public
  * @return bool $enabled true or false
  */
 public function electronic_sig_enabled()
 {
     // Check that the wintools plugin is active and available, return false if not.
     if (!KTPluginUtil::pluginIsActive('ktdms.wintools')) {
         return false;
     }
     // Check config for api signatures enabled
     $oConfig =& KTConfig::getSingleton();
     $enabled = $oConfig->get('e_signatures/enableApiSignatures', false);
     // Check that the license is valid
     $enabled = BaobabKeyUtil::getLicenseCount() >= MIN_LICENSES & $enabled;
     return $enabled;
 }
Ejemplo n.º 7
0
function getKTEdition()
{
    $edition = 'Community|-';
    if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
        $path = KTPluginUtil::getPluginPath('ktdms.wintools');
        require_once $path . 'baobabkeyutil.inc.php';
        $edition = BaobabKeyUtil::getName();
        // this could be done with regular expressions...
        // Remove the brackets around the name
        $edition = substr($edition, 1);
        $edition = substr($edition, 0, strlen($edition) - 1);
        // Remove the "users"
        $pos = strpos($edition, 'users');
        $edition = $pos === false ? $edition . '|-' : substr($edition, 0, $pos - 1);
        // Replace the , with |
        $edition = str_replace(', ', '|', $edition);
    }
    return $edition;
}