Exemplo n.º 1
0
 protected function getWhereForFindExistingData(array $data)
 {
     if (!isset($data['nodeName']) || !isset($data['startTime']) || !isset($data['subEntity'])) {
         return null;
     }
     $table = DB::table($this->obj->getTable());
     $nameCol = $table->getColumn('nodeName');
     $startTimeCol = $table->getColumn('startTime');
     $where = DB::where($nameCol, DB::term($data['nodeName']));
     $date = new base_date_model_DateTime(new DateTime($data['startTime']));
     $where->addAnd($startTimeCol, DB::term($date->toDB()));
     if (!empty($data['subEntity'])) {
         $subEntityCol = $table->getColumn('subEntity');
         $where->addAnd($subEntityCol, DB::term($data['subEntity']));
     }
     $where->addAnd($table->getColumn('FK_tsmserver'), DB::intTerm($data['FK_tsmserver']));
     $where->addAnd($table->getColumn('histtop'), DB::term('Y'));
     return $where;
 }
Exemplo n.º 2
0
Arquivo: User.php Projeto: kafruhs/fws
    /**
     * login of an user with the given userid and password
     *
     * @param string $userid
     * @param string $password
     *
     * @return int
     * @throws base_database_Exception
     */
    public static function login($userid, $password)
    {
        $table = DB::table(Factory::createObject('user')->getTable());
        $where = DB::where($table->getColumn('userid'), DB::stringTerm($userid));
        $res = Finder::create('user')->setWhere($where)->find();

        if (empty($res)) {
            return self::LOGIN_FAILURE;
        }
        $user = current($res);
        if ($user['disabled'] == self::USER_DISABLED) {
            return self::LOGIN_USER_DISABLED;
        }
        if ($user['password'] != md5($password)) {
            return self::_updateLoginTries($table, $user);
        }

        try {
            $time = new base_date_model_DateTime();
            $updateData = array(
                'ip' => DB::stringTerm($_SERVER['REMOTE_ADDR']),
                'sessionid' => DB::stringTerm(session_id()),
                'lastLogin' => DB::stringTerm($time->toDB()),
                'loginTries' => DB::intTerm(0),
            );
            self::_updateUserLoginData($table, $where, $updateData);
        } catch (Exception $e) {
            return self::LOGIN_FAILURE;
        }
        $user['ip'] = $_SERVER['REMOTE_ADDR'];
        $user['sessionid'] = session_id();
        $user['lastLogin'] = $time;
        $user['loginTries'] = 0;
        $_SESSION['user'] = $user;

        return self::LOGIN_SUCCESS;
    }
Exemplo n.º 3
0
 /**
  * creates the admin user
  *
  * @param OutputDevice $od
  * @throws base_database_Exception
  */
 public function createAdminUser(OutputDevice $od)
 {
     $user = new User();
     if (!is_null($user->load(1))) {
         return;
     }
     $seq = new Sequence('User');
     $adminData['LK'] = $seq->getNextSequence();
     $adminData['firstEditor'] = 1;
     $dateTime = new base_date_model_DateTime();
     $adminData['firstEditTime'] = $dateTime->toDB();
     $adminData['editor'] = 1;
     $adminData['editTime'] = $dateTime->toDB();
     $adminData['userid'] = 'admin';
     $adminData['password'] = '******';
     $adminData['firstName'] = 'Admin';
     $adminData['lastName'] = 'Admin';
     $adminData['email'] = '*****@*****.**';
     $statement = new base_database_statement_Insert();
     $table = DB::table('user');
     $statement->setTable($table);
     foreach ($adminData as $fieldName => $value) {
         $statement->setColumnValue($table->getColumn($fieldName), DB::term($value));
     }
     $dbObj = base_database_connection_Mysql::get();
     $dbObj->beginTransaction();
     $seq->save();
     $statement->insertDatabase();
     $dbObj->endTransaction();
     base_install_Message::printOut('----- Admin User created -----', $od);
 }
Exemplo n.º 4
0
$od = new OutputDevice();

base_ui_Site::displayHead($od);
base_ui_Site::displayTop($od);
base_ui_Site::displayNavigation($od);
base_ui_Site::startMainContent($od);

print $od->toString();
$od->flush();

$od->addContent(Html::startTag('h3'));
$od->addContent('Summary');
$od->addContent(Html::endTag('h3'));

$table = DB::table(Factory::createObject('TSMSummary')->getTable());
$dateTime = new base_date_model_DateTime(new DateTime('2015-01-01 00:00:00'));
$where = DB::where($table->getColumn('startTime'), DB::term($dateTime->toDB()), base_database_Where::GREATER);
$order = DB::order($table->getColumn('startTime'));
$finder = Finder::create('TSMSummary')->setWhere($where)->setOrder($order);
$objs = $finder->find();

$times = [];
$nodeNames = [];
$sortedObjects = [];
foreach ($objs as $obj) {
    /** @var base_date_model_DateTime $startTime */
    $startTime = $obj['startTime'];
    $nodeName = $obj['nodeName'];
    if (strpos($nodeName, 'FULLVM')) {
        $nodeName = $obj['subEntity'] . ' (FULLVM)';
    }
Exemplo n.º 5
0
 /**
  * @param base_date_model_DateTime $value
  * @return mixed|void
  */
 public function toDB($value)
 {
     return $value->toDB();
 }