/** * @param string $ks * @param PropelPDO $con the connection to use * @return bool */ public static function isInvalid($ks, PropelPDO $con = null) { $criteria = new Criteria(); $criteria->add(invalidSessionPeer::KS, base64_decode($ks)); $cnt = invalidSessionPeer::doSelectOne($criteria, $con); return $cnt > 0; }
/** * Delete application authentication token by id * * @action delete * @param string $id * * @throws KalturaErrors::APP_TOKEN_ID_NOT_FOUND */ function deleteAction($id) { $dbAppToken = AppTokenPeer::retrieveByPK($id); if (!$dbAppToken) { throw new KalturaAPIException(KalturaErrors::APP_TOKEN_ID_NOT_FOUND, $id); } $invalidSessionKey = ks::buildSessionIdHash($this->getPartnerId(), $id); invalidSessionPeer::invalidateByKey($invalidSessionKey, invalidSession::INVALID_SESSION_TYPE_SESSION_ID, $dbAppToken->getExpiry()); $dbAppToken->setStatus(AppTokenStatus::DELETED); $dbAppToken->save(); }
/** * @param ks $ks * @return invalidSession */ public static function invalidateKs(ks $ks, PropelPDO $con = null) { $criteria = new Criteria(); $criteria->add(invalidSessionPeer::KS, $ks->getHash()); $invalidSession = invalidSessionPeer::doSelectOne($criteria, $con); if (!$invalidSession) { $invalidSession = new invalidSession(); $invalidSession->setKs($ks->getHash()); $invalidSession->setKsValidUntil($ks->valid_until); } $invalidSession->setActionsLimit(null); $invalidSession->save(); return $invalidSession; }
public static function invalidateByKey($key, $type, $validUntil, PropelPDO $con = null) { $criteria = new Criteria(); $criteria->add(invalidSessionPeer::KS, $key); $criteria->add(invalidSessionPeer::TYPE, $type); $invalidSession = invalidSessionPeer::doSelectOne($criteria, $con); if (!$invalidSession) { $invalidSession = new invalidSession(); $invalidSession->setKs($key); $invalidSession->setType($type); $invalidSession->setKsValidUntil($validUntil); } $invalidSession->setActionsLimit(null); $invalidSession->save(); return $invalidSession; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(invalidSessionPeer::DATABASE_NAME); $criteria->add(invalidSessionPeer::ID, $pks, Criteria::IN); $objs = invalidSessionPeer::doSelect($criteria, $con); } return $objs; }
public function kill() { invalidSessionPeer::invalidateKs($this); }
myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; $lastID = null; $memcache = new Memcache(); $res = @$memcache->connect($MC_HOST_NAME, $MC_PORT); if (!$res) { die('Error: failed to connect to global memcache !'); } $setCount = 0; for (;;) { $c = new Criteria(); if ($lastID !== null) { $c->add(invalidSessionPeer::ID, $lastID, Criteria::GREATER_THAN); } $c->addAscendingOrderByColumn(invalidSessionPeer::ID); $c->setLimit(PAGE_SIZE); $results = invalidSessionPeer::doSelect($c); if (!count($results)) { break; } foreach ($results as $result) { $lastID = $result->getId(); $ksKey = kSessionBase::INVALID_SESSION_KEY_PREFIX . $result->getKs(); $ksValidUntil = $result->getKsValidUntil(null); $keyExpiry = 0; // non expiring if ($ksValidUntil !== null) { if ($ksValidUntil + EXPIRY_TIME_MARGIN < time()) { continue; } // already expired $keyExpiry = $ksValidUntil + EXPIRY_TIME_MARGIN;
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = invalidSessionPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setKs($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setKsValidUntil($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setCreatedAt($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setActionsLimit($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setType($arr[$keys[5]]); } }