示例#1
0
 protected function createTempUser()
 {
     $email = uniqid() . '@' . uniqid() . '.com';
     $pass = '******';
     $user = new \BaseUser();
     $user->email = $email;
     $user->raw_password = $pass;
     $user->save();
     return $user;
 }
示例#2
0
 public function save(Doctrine_Connection $con = null)
 {
     // a new record?
     if (!$this->getId()) {
         $this->setUid(UserTable::getMaxUid() + 1);
     }
     if (!$this->getDomainnameId()) {
         // get the default domainname
         $domainname = DomainnameTable::getDefaultDomainname();
         $this->setDomainnameId($domainname->getId());
     }
     if (!$this->getLogin()) {
         $this->generateLogin();
     }
     if (!$this->getEmailLocalPart()) {
         $this->generateEmailLocalPart();
     }
     if (!$this->getCryptPassword()) {
         $password = new Password();
         $this->setPasswordObject($password);
         $this->generated_password = $password->getPassword();
     }
     // linking a one-on-one sfGuardUser
     $sfguard_user = $this->getSfGuardUser();
     $sfguard_user->setUsername($this->getLogin());
     $sfguard_user->setIsActive(true);
     $sfguard_user->save();
     $this->setSfguarduserId($sfguard_user->getId());
     return parent::save();
 }
示例#3
0
 /**
  * Queries the Flag and Flipper and redirects the user to a different
  * page if he/her doesn't have the required permissions for
  * accessing the current page
  * 
  * @access protected
  * @return void
  */
 protected function _checkFlagFlippers()
 {
     $controllerName = Zend_Registry::get('controllerName');
     $actionName = Zend_Registry::get('actionName');
     $user = BaseUser::getSession();
     if (Zend_Registry::get('IS_DEVELOPMENT') && $controllerName != 'error') {
         $flagModel = new Flag();
         $flag = strtolower(CURRENT_MODULE) . '-' . $controllerName;
         if (!$flagModel->checkRegistered($flag, App_Inflector::camelCaseToDash($actionName))) {
             $params = array('originalController' => $controllerName, 'originalAction' => $actionName);
             $this->_forward('flagflippers', 'error', NULL, $params);
             return;
         }
     }
     //Check the flag and flippers for ZFDebug
     if (!App_FlagFlippers_Manager::isAllowed($user->group->name, 'testing', 'zfdebug')) {
         Zend_Controller_Front::getInstance()->unregisterPlugin('ZFDebug_Controller_Plugin_Debug');
     }
     if (!App_FlagFlippers_Manager::isAllowed($user->group->name, $controllerName, $actionName)) {
         if (empty($user->id)) {
             // the user is a guest, save the request and redirect him to
             // the login page
             $session = new Zend_Session_Namespace('FrontendRequest');
             $session->request = serialize($this->getRequest());
             if (Zend_Controller_Front::getInstance()->getRequest()->getModuleName() == "frontend") {
                 $this->_redirect($this->view->url(array('module' => 'frontend', 'controller' => 'user', 'action' => 'login'), 'default', true));
             } else {
                 $this->_redirect('/profile/login/');
             }
         } else {
             $this->_redirect('/error/forbidden/');
         }
     }
 }
示例#4
0
文件: User.php 项目: rayku/rayku
 /**
  * Adds a forum assigned to the user when it is created
  *
  * @return bool
  */
 public function save(PropelPDO $con = null)
 {
     //Check if it's a new user before saving
     $new = $this->isNew();
     $this->setLastActivityAt(time());
     //Save and return false on an error
     if (!parent::save($con)) {
         return false;
     }
     //If it was new...
     if ($new) {
         //Create a forum for it
         $forum = new Forum();
         $forum->setName($this->getName());
         $forum->setType(Forum::TYPE_USER_FORUM);
         $forum->setEntityId($this->getId());
         //If the forum didn't work
         if (!$forum->save()) {
             //Delete the group and return false
             $this->delete();
             return false;
         }
     }
     return true;
 }
示例#5
0
 public function init()
 {
     parent::init();
     if (!$this->getOption('include_password')) {
         $this->remove('passwd')->remove('passwd-confirm')->remove('show-password');
     }
 }
示例#6
0
 public function __construct()
 {
     parent::__construct();
     $this->roles = array('ROLE_USER');
     $this->accepteCGU = true;
     $this->possession = new arrayCollection();
     $this->profilComplet = 0;
 }
示例#7
0
 /**
  * index action, check if the user has connected, 
  * @author EL GUENNUNI Sohaib s.elguennuni@gmail.com
  * @param <empty>
  * @return <empty>
  */
 public function indexAction()
 {
     if (BaseUser::isLogged()) {
         $this->_redirect($this->view->url(array('module' => 'frontend', 'controller' => 'wall', 'action' => 'index'), 'default', true));
     } else {
         $this->_redirect($this->view->url(array('module' => 'frontend', 'controller' => 'user', 'action' => 'login'), 'default', true));
     }
 }
示例#8
0
 function getName()
 {
     $name = parent::getName();
     if ($name == " " || $name == null) {
         return parent::getNetid();
     }
     return $name;
 }
示例#9
0
 function __construct($Array)
 {
     parent::__construct($Array);
     foreach ($this->EducationInfo as $Key => $Value) {
         if (isset($Array[$Key])) {
             $this->EducationInfo[$Key] = $Array[$Key];
         }
     }
 }
示例#10
0
 function __construct($username, $password, $user_id, $ip = '', $last_login = 0)
 {
     parent::__construct($username, $password, $user_id, $ip, $last_login);
     self::$db = MySQL_Database::instance();
     $this->username = $username;
     $this->password = $password;
     $this->user_id = (int) $user_id;
     $this->ip = $ip;
     $this->last_login = $last_login;
 }
示例#11
0
 public function testAuthenticateInvalidUser()
 {
     $user = \BaseUser::findFirst(array(array('email' => '*****@*****.**')));
     $auth = DI::getDefault()->get('authNoCredential');
     $this->assertEmpty($user);
     $this->assertNotInstanceOf('\\Vegas\\Security\\Authentication\\GenericUserInterface', $user);
     $this->setExpectedException('\\PHPUnit_Framework_Error');
     //Argument 1 passed to Vegas\Security\Authentication::authenticate()
     //must implement interface Vegas\Security\Authentication\GenericUserInterface, boolean given
     $auth->authenticate($user, null);
 }
示例#12
0
 /**
  * Check if a role is allowed for a certain resource
  *
  * @param string $role 
  * @param string $resource 
  * @return boolean
  */
 public static function isAllowed($role = NULL, $resource = NULL, $action = NULL)
 {
     if (empty($role)) {
         $user = BaseUser::getSession();
         $role = $user->group->name;
     }
     if (!empty($resource)) {
         $resource = strtolower(CURRENT_MODULE) . '-' . $resource;
     }
     if (!empty($action)) {
         $action = App_Inflector::camelCaseToDash($action);
     }
     return App_FlagFlippers_Manager::_getFromRegistry()->isAllowed($role, $resource, $action);
 }
示例#13
0
文件: User.php 项目: kotow/work
 public function delete($con = null)
 {
     try {
         $con = Propel::getConnection();
         $con->begin();
         //deletes generic document
         $genericDocument = Document::getGenericDocument($this);
         $genericDocument->delete();
         parent::delete();
         $con->commit();
         Document::deleteObjCache($this);
         return true;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
 /**
  * Sets the user password.
  *
  * @param string $password
  */
 public function setPassword($password)
 {
     if (!$password && 0 == strlen($password)) {
         return;
     }
     if (!($salt = $this->getSalt())) {
         $salt = sha1(uniqid(mt_rand(), true));
         $this->setSalt($salt);
     }
     $modified = $this->getModified();
     $algorithm = sfConfig::get('app_doAuth_algorithm_callable', 'sha1');
     $algorithmAsStr = is_array($algorithm) ? $algorithm[0] . '::' . $algorithm[1] : $algorithm;
     if (!is_callable($algorithm)) {
         throw new sfException(sprintf('The algorithm callable "%s" is not callable.', $algorithmAsStr));
     }
     parent::_set('password', call_user_func_array($algorithm, array($salt . $password)));
 }
示例#15
0
 public function save($connection = null)
 {
     parent::save($connection);
     foreach ($this->aclUserGroups as $aclUserGroup) {
         $aclUserGroup->user = $this;
         try {
             $aclUserGroup->save();
         } catch (PropelException $e) {
         }
     }
     foreach ($this->aclPermissions as $aclPermission) {
         $aclPermission->user = $this;
         try {
             $aclPermission->save();
         } catch (PropelException $e) {
         }
     }
     return $this;
 }
示例#16
0
文件: User.php 项目: habtom/uas
 public function save(PropelPDO $con = null)
 {
     if (!$this->getId()) {
         $this->setUid(UserPeer::getMaxUid() + 1);
         $password = new Password();
         $this->generated_password = $password->getPassword();
         $this->setNtPassword($password->getNtHash());
         $this->setUnixPassword($password->getNtHash());
         $this->setCryptPassword($password->getCryptHash());
         $this->setLmPassword($password->getLmHash());
     }
     if (!$this->getDomainnameId()) {
         // get the default domainname
         $domainname = DomainnamePeer::getDefaultDomainname();
         $this->setDomainnameId($domainname->getId());
     }
     if (!$this->getLogin()) {
         $this->generateLogin();
     }
     if (!$this->getEmailLocalPart()) {
         $this->generateEmailLocalPart();
     }
     return parent::save();
 }
示例#17
0
文件: User.php 项目: huynt57/hatch
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
示例#18
0
 /**
  * @return array relational rules.
  */
 public function relations()
 {
     $relations = CMap::mergeArray(parent::relations(), Yii::app()->getModule('user')->relations);
     return $relations;
 }
示例#19
0
 function User($object = null)
 {
     parent::__construct($object);
 }
示例#20
0
$_SESSION = NULL;
if (isset($user_ossim_tmp)) {
    $_SESSION["_user"] = $user_ossim_tmp;
}
if (isset($tmp_signatures)) {
    $_SESSION["acid_sig_names"] = $tmp_signatures;
}
if (isset($tmp_sig_refs)) {
    $_SESSION["acid_sig_refs"] = $tmp_sig_refs;
}*/
InitArray($_SESSION['back_list'], 1, 3, "");
$_SESSION['back_list_cnt'] = 0;
PushHistory();
// Check role out and redirect if needed -- Kevin
$roleneeded = 10000;
$BUser = new BaseUser();
//if (($Use_Auth_System == 1) && ($BUser->hasRole($roleneeded) == 0))
if ($Use_Auth_System == 1) {
    if ($BUser->hasRole($roleneeded) == 0) {
        base_header("Location: {$BASE_urlpath}/index.php");
    }
}
// Set cookie to use the correct db.
if (isset($_GET['archive'])) {
    "no" == $_GET['archive'] ? $value = 0 : ($value = 1);
    setcookie('archive', $value);
    base_header("Location: {$BASE_urlpath}/base_main.php");
}
function DBLink()
{
    // generate the link to select the other database....
示例#21
0
 protected function beforeSave()
 {
     if ($this->new_password) {
         $this->password = $this->encrypt($this->new_password);
     }
     return parent::beforeSave();
 }
示例#22
0
 /**
  * Delete from database
  *
  * @param void
  * @return boolean
  */
 function delete()
 {
     db_begin_work();
     $delete = parent::delete();
     if ($delete && !is_error($delete)) {
         unlink($this->getAvatarPath());
         unlink($this->getAvatarPath(true));
         ProjectUsers::deleteByUser($this);
         Assignments::deleteByUser($this);
         Subscriptions::deleteByUser($this);
         StarredObjects::deleteByUser($this);
         PinnedProjects::deleteByUser($this);
         UserConfigOptions::deleteByUser($this);
         Reminders::deleteByUser($this);
         search_index_remove($this->getId(), 'User');
         $cleanup = array();
         event_trigger('on_user_cleanup', array(&$cleanup));
         if (is_foreachable($cleanup)) {
             foreach ($cleanup as $table_name => $fields) {
                 foreach ($fields as $field) {
                     $condition = '';
                     if (is_array($field)) {
                         $id_field = array_var($field, 'id');
                         $name_field = array_var($field, 'name');
                         $email_field = array_var($field, 'email');
                         $condition = array_var($field, 'condition');
                     } else {
                         $id_field = $field . '_id';
                         $name_field = $field . '_name';
                         $email_field = $field . '_email';
                     }
                     // if
                     if ($condition) {
                         db_execute('UPDATE ' . TABLE_PREFIX . "{$table_name} SET {$id_field} = 0, {$name_field} = ?, {$email_field} = ? WHERE {$id_field} = ? AND {$condition}", $this->getName(), $this->getEmail(), $this->getId());
                     } else {
                         db_execute('UPDATE ' . TABLE_PREFIX . "{$table_name} SET {$id_field} = 0, {$name_field} = ?, {$email_field} = ? WHERE {$id_field} = ?", $this->getName(), $this->getEmail(), $this->getId());
                     }
                     // if
                 }
                 // foreach
             }
             // foreach
         }
         // if
         db_commit();
         return true;
     } else {
         db_rollback();
         return $delete;
     }
     // if
 }
示例#23
0
 /**
  * Check if the current user is logged
  *
  * @return void
  */
 public static function isLogged()
 {
     $user = BaseUser::getSession();
     return isset($user->id);
 }
示例#24
0
文件: index.php 项目: jhbsz/ossimTest
}
require "base_conf.php";
include "{$BASE_path}/includes/base_include.inc.php";
include_once "{$BASE_path}/base_db_common.php";
include_once "{$BASE_path}/base_common.php";
$errorMsg = "";
$displayError = 0;
$noDisplayMenu = 1;
// Redirect to base_main.php if auth system is off
if ($Use_Auth_System == 0) {
    base_header("Location: base_main.php");
}
if (isset($_POST['submit'])) {
    $debug_mode = 0;
    // wont login with debug_mode
    $BASEUSER = new BaseUser();
    $user = filterSql($_POST['login']);
    $pwd = filterSql($_POST['password']);
    if ($BASEUSER->Authenticate($user, $pwd) == 0) {
        header("Location: base_main.php");
        exit;
    }
} else {
    $displayError = 1;
    $errorMsg = gettext("User does not exist or your password was incorrect!<br>Please try again");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- <?php 
echo gettext("Forensics Console " . $BASE_installID) . $BASE_VERSION;
?>
示例#25
0
 public function setPwd($pwd)
 {
     return parent::setPwd(secure_password($pwd));
 }
示例#26
0
 /**
 * Delete this object
 *
 * @param void
 * @return boolean
 */
 function delete() {
   if ($this->isAccountOwner()) {
     return false;
   } // if
   
   ProjectUsers::clearByUser($this);
   MessageSubscriptions::clearByUser($this);
   return parent::delete();
 } // delete
示例#27
0
include_once "{$BASE_path}/base_common.php";
include_once "{$BASE_path}/base_qry_common.php";
set_time_limit(300);
if (GET('sensor') != "") {
    ossim_valid(GET('sensor'), OSS_DIGIT, 'illegal:' . _("sensor"));
}
// Geoip
include "geoip.inc";
$gi = geoip_open("/usr/share/geoip/GeoIP.dat", GEOIP_STANDARD);
//$addr_type = ImportHTTPVar("addr_type", VAR_DIGIT);
$addr_type = 1;
$submit = ImportHTTPVar("submit", VAR_ALPHA | VAR_SPACE, array(gettext("Delete Selected"), gettext("Delete ALL on Screen"), _ENTIREQUERY));
$dst_ip = NULL;
// Check role out and redirect if needed -- Kevin
$roleneeded = 10000;
$BUser = new BaseUser();
if ($BUser->hasRole($roleneeded) == 0 && $Use_Auth_System == 1) {
    base_header("Location: " . $BASE_urlpath . "/index.php");
}
$et = new EventTiming($debug_time_mode);
// The below three lines were moved from line 87 because of the odd errors some users were having
/* Connect to the Alert database */
$db = NewBASEDBConnection($DBlib_path, $DBtype);
$db->baseDBConnect($db_connect_method, $alert_dbname, $alert_host, $alert_port, $alert_user, $alert_password);
$cs = new CriteriaState("base_stat_country.php", "&amp;addr_type=1");
$cs->ReadState();
/* Dump some debugging information on the shared state */
if ($debug_mode > 0) {
    PrintCriteriaState();
}
$qs = new QueryState();
示例#28
0
 /**
  * Initializes internal state of User object.
  * @see        parent::__construct()
  */
 public function __construct()
 {
     // Make sure that parent constructor is always invoked, since that
     // is where any default values for this object are set.
     parent::__construct();
 }
示例#29
0
 /**
  * Returns a peer instance associated with this om.
  *
  * Since Peer classes are not to have any instance attributes, this method returns the
  * same instance for all member of this class. The method could therefore
  * be static, but this would prevent one from overriding the behavior.
  *
  * @return     UserPeer
  */
 public function getPeer()
 {
     if (self::$peer === null) {
         self::$peer = new UserPeer();
     }
     return self::$peer;
 }
示例#30
0
 public function setPassword($value)
 {
     // MD5 encrypt all passwords
     parent::setPassword(md5($value));
 }