Session PHP Class Code Examples

This page contains top rated real world PHP examples of class Session extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: DealerTest.php Project: binaek89/Thruway
0
 public function testInvocationError()
 {
     $dealer = new \Thruway\Role\Dealer();
     $callerTransport = new \Thruway\Transport\DummyTransport();
     $callerSession = new Session($callerTransport);
     $calleeTransport = new \Thruway\Transport\DummyTransport();
     $calleeSession = new Session($calleeTransport);
     // register from callee
     $registerMsg = new \Thruway\Message\RegisterMessage(1, new stdClass(), 'test_proc_name');
     $dealer->handleRegisterMessage(new \Thruway\Event\MessageEvent($calleeSession, $registerMsg));
     $this->assertInstanceOf('\\Thruway\\Message\\RegisteredMessage', $calleeTransport->getLastMessageSent());
     // call from one session
     $callRequestId = \Thruway\Common\Utils::getUniqueId();
     $callMsg = new \Thruway\Message\CallMessage($callRequestId, new stdClass(), 'test_proc_name');
     $dealer->handleCallMessage(new \Thruway\Event\MessageEvent($callerSession, $callMsg));
     $this->assertInstanceOf('\\Thruway\\Message\\InvocationMessage', $calleeTransport->getLastMessageSent());
     $errorMsg = \Thruway\Message\ErrorMessage::createErrorMessageFromMessage($calleeTransport->getLastMessageSent(), 'the.error.uri');
     $dealer->handleErrorMessage(new \Thruway\Event\MessageEvent($calleeSession, $errorMsg));
     /** @var \Thruway\Message\ErrorMessage $returnedError */
     $returnedError = $callerTransport->getLastMessageSent();
     $this->assertInstanceOf('\\Thruway\\Message\\ErrorMessage', $returnedError);
     $this->assertEquals(Message::MSG_CALL, $returnedError->getErrorMsgCode());
     $this->assertEquals($callRequestId, $returnedError->getErrorRequestId());
     $this->assertEquals('the.error.uri', $returnedError->getErrorURI());
 }
Example #2
Show file File: LitpiHelper.php Project: tuyenv/litpi-framework-3
0
 public function _before(\Codeception\TestCase $test)
 {
     require_once \Codeception\Configuration::projectDir() . 'src/includes/autoload.php';
     require_once \Codeception\Configuration::projectDir() . 'src/includes/classmap.php';
     require_once \Codeception\Configuration::projectDir() . 'src/Vendor/autoload.php';
     spl_autoload_register('autoloadlitpi');
     include_once \Codeception\Configuration::projectDir() . 'src/libs/smarty/Smarty.class.php';
     //Overwrite remoteaddr
     $_SERVER['REMOTE_ADDR'] = $this->config['remoteaddr'];
     //INIT REGISTRY VARIABLE - MAIN STORAGE OF APPLICATION
     $registry = \Litpi\Registry::getInstance();
     $request = \Litpi\Request::createFromGlobals();
     $response = new \Litpi\Response();
     $session = new \Litpi\Session();
     $registry->set('request', $request);
     $registry->set('response', $response);
     $registry->set('session', $session);
     require_once \Codeception\Configuration::projectDir() . 'src/includes/conf.php';
     require_once \Codeception\Configuration::projectDir() . 'src/includes/config.php';
     require_once \Codeception\Configuration::projectDir() . 'src/includes/setting.php';
     $registry->set('conf', $conf);
     $registry->set('setting', $setting);
     $registry->set('https', PROTOCOL == 'https' ? true : false);
     require_once \Codeception\Configuration::projectDir() . 'src/includes/permission.php';
     $registry->set('groupPermisson', $groupPermisson);
     require_once \Codeception\Configuration::projectDir() . 'src/includes/rewriterule.php';
     require_once \Codeception\Configuration::projectDir() . 'src/includes/startup.php';
     $this->registry = $registry;
     $this->client = new \Codeception\Lib\Connector\LitpiConnectorHelper();
     $this->client->setRegistry($this->registry);
 }
Example #3
Show file File: CommentDefaultFormatterCacheTagsTest.php Project: papillon-cendre/d8
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $session = new Session();
     $request = Request::create('/');
     $request->setSession($session);
     /** @var RequestStack $stack */
     $stack = $this->container->get('request_stack');
     $stack->pop();
     $stack->push($request);
     // Set the current user to one that can access comments. Specifically, this
     // user does not have access to the 'administer comments' permission, to
     // ensure only published comments are visible to the end user.
     $current_user = $this->container->get('current_user');
     $current_user->setAccount($this->createUser(array(), array('access comments')));
     // Install tables and config needed to render comments.
     $this->installSchema('comment', array('comment_entity_statistics'));
     $this->installConfig(array('system', 'filter', 'comment'));
     // Comment rendering generates links, so build the router.
     $this->installSchema('system', array('router'));
     $this->container->get('router.builder')->rebuild();
     // Set up a field, so that the entity that'll be referenced bubbles up a
     // cache tag when rendering it entirely.
     $this->addDefaultCommentField('entity_test', 'entity_test');
 }
Example #4
Show file File: class-bootstrap.php Project: arter97/h5ai
0
 public static function run()
 {
     spl_autoload_register(['Bootstrap', 'autoload']);
     putenv('LANG=en_US.UTF-8');
     setlocale(LC_CTYPE, 'en_US.UTF-8');
     date_default_timezone_set(@date_default_timezone_get());
     session_start();
     $session = new Session($_SESSION);
     $request = new Request($_REQUEST);
     $setup = new Setup($request->query_boolean('refresh', false));
     $context = new Context($session, $request, $setup);
     if ($context->is_api_request()) {
         (new Api($context))->apply();
     } else {
         if ($context->is_info_request()) {
             $public_href = $setup->get('PUBLIC_HREF');
             $x_head_tags = $context->get_x_head_html();
             require __DIR__ . '/pages/info.php';
         } else {
             $public_href = $setup->get('PUBLIC_HREF');
             $x_head_tags = $context->get_x_head_html();
             $fallback_html = (new Fallback($context))->get_html();
             require __DIR__ . '/pages/index.php';
         }
     }
 }
Example #5
Show file File: Session.php Project: microcosmx/experiments
0
 static function gc($maxlifetime)
 {
     self::logdeb("garbage collection (maxlifetime = {$maxlifetime})");
     $epoch = common_sql_date(time() - $maxlifetime);
     $ids = array();
     $session = new Session();
     $session->whereAdd('modified < "' . $epoch . '"');
     $session->selectAdd();
     $session->selectAdd('id');
     $limit = common_config('sessions', 'gc_limit');
     if ($limit > 0) {
         // On large sites, too many sessions to expire
         // at once will just result in failure.
         $session->limit($limit);
     }
     $session->find();
     while ($session->fetch()) {
         $ids[] = $session->id;
     }
     $session->free();
     self::logdeb("Found " . count($ids) . " ids to delete.");
     foreach ($ids as $id) {
         self::logdeb("Destroying session '{$id}'.");
         self::destroy($id);
     }
 }
Example #6
Show file File: login.php Project: 5haman/knowledgetree
0
 function performLogin(&$oUser)
 {
     if (!is_a($oUser, 'User')) {
         #var_dump($oUser);
         #var_dump(PEAR::raiseError());
     }
     /*
     Removing the code that redirects to the dashboard as it breaks linking in from external documents.
     The fix below doesn't work if the users are behind a proxy server.
     
     // If the last user from the same IP address timed out within the last hour then redirect to the dashboard
     // Otherwise allow any other redirect to continue.
     // The user might still be taken to the last page of the previous users session but
     // if we always redirect to dashboard then we break other features such as linking in from emails or documents.
     if (checkLastSessionUserID($oUser->getId()))
     {
     	$_REQUEST['redirect'] = generateControllerLink('dashboard');
     }
     */
     $session = new Session();
     $sessionID = $session->create($oUser);
     if (PEAR::isError($sessionID)) {
         return $sessionID;
     }
     $redirect = strip_tags(KTUtil::arrayGet($_REQUEST, 'redirect'));
     // DEPRECATED initialise page-level authorisation array
     $_SESSION["pageAccess"] = NULL;
     $cookietest = KTUtil::randomString();
     setcookie("CookieTestCookie", $cookietest, 0);
     $this->redirectTo('checkCookie', array('cookieVerify' => $cookietest, 'redirect' => $redirect));
     exit(0);
 }
Example #7
Show file File: loader.class.php Project: RNKushwaha022/orange-php
0
 function service($name)
 {
     $obj = null;
     switch ($name) {
         case 'db':
             $obj = new DatabaseProxy($this);
             break;
         case 'plugin':
             $obj = PluginManager::getInstance()->getPluginList();
             break;
         case 'lang':
             $obj = $this->lang();
             break;
         case 'session':
             $obj = new Session($this->context->getModule(false));
             break;
         case 'helper':
             $obj = new HelperLoader($this);
             break;
         default:
             trigger_error("Trying to get invalid property '{$name}'", E_USER_WARNING);
             break;
     }
     return $obj;
 }
Example #8
Show file File: TeamKickQuery.php Project: legoboy0215/LegionPE-Theta-Base
0
 public function __construct(BasePlugin $main, Session $sender, $name, $msg)
 {
     $this->sender = $main->storeObject($sender);
     $this->name = $name;
     $this->msg = $msg;
     parent::__construct($main);
 }
Example #9
Show file File: CodeIgniterKernelTest.php Project: chancegarcia/TheodoEvolutionLegacyWrapperBundle
0
 public function testShouldBootAndHandleRequest()
 {
     if (version_compare(PHP_VERSION, '5.6', '>=')) {
         $this->markTestSkipped('CodeIgniter v2.1 is not compatible with PHP >= 5.6');
     }
     $session = new Session(new MockArraySessionStorage());
     $request = Request::create('/welcome/');
     $request->setSession($session);
     $requestStack = $this->prophesize('Symfony\\Component\\HttpFoundation\\RequestStack');
     $requestStack->getCurrentRequest()->willReturn($request);
     $container = $this->prophesize('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $container->get('request_stack')->willReturn($requestStack->reveal());
     $container->getParameter(Argument::any())->willReturn('foo');
     $container->set(Argument::type('string'), Argument::any())->shouldBeCalled();
     $classLoader = new CodeIgniterClassLoader();
     $kernel = new CodeIgniterKernel();
     $kernel->setRootDir($_ENV['THEODO_EVOLUTION_FAKE_PROJECTS'] . '/codeigniter21');
     $kernel->setOptions(array('environment' => 'prod', 'version' => '2.1.4', 'core' => false));
     $kernel->setClassLoader($classLoader);
     $kernel->boot($container->reveal());
     $this->assertTrue($kernel->isBooted());
     $this->assertTrue($classLoader->isAutoloaded());
     // CodeIgniter creates a global variables
     $this->assertArrayHasKey('BM', $GLOBALS);
     $this->assertArrayHasKey('EXT', $GLOBALS);
     $this->assertArrayHasKey('CFG', $GLOBALS);
     $this->assertArrayHasKey('UNI', $GLOBALS);
     $this->assertArrayHasKey('URI', $GLOBALS);
     $this->assertArrayHasKey('RTR', $GLOBALS);
     $this->assertArrayHasKey('OUT', $GLOBALS);
     $this->assertArrayHasKey('SEC', $GLOBALS);
     $response = $kernel->handle($request, 1, true);
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response);
     $this->assertEquals(200, $response->getStatusCode());
 }
Example #10
Show file File: ElementSpec.php Project: icambridge/BehatPageObjectExtension
0
 function it_assumes_a_css_selector_if_not_specified(Session $session, Factory $factory, SelectorsHandler $selectorsHandler)
 {
     $this->beAnInstanceOf('spec\\SensioLabs\\Behat\\PageObjectExtension\\PageObject\\MySimpleElement');
     $this->beConstructedWith($session, $factory);
     $selectorsHandler->selectorToXpath('css', 'div#my-box')->willReturn('//div[@id="my-box"]');
     $this->getXpath()->shouldReturn('//div[@id="my-box"]');
 }
Example #11
Show file File: SessionTest.php Project: bighome/simresults
0
 /**
  * Get a Session instance populated with test data.
  *
  * NOTE: Every time this method is ran, a different instance will be
  *       returned! Keep this in mind when comparing things by reference
  *
  * @return Session
  */
 protected function getSessionWithData()
 {
     // Create new session
     $session = new Session();
     // Participants testdata array
     $participants_data = array(array('position' => 1, 'vehicle' => array('class' => 'class1'), 'laps' => array(array('time' => 130.7517, 'sectors' => array(53.2312, 32.299, 45.2215), 'position' => 1), array('time' => 125.2989, 'sectors' => array(47.4511, 32.063, 45.7848), 'position' => 1), array('time' => 123.3179, 'sectors' => array(46.6382, 32.0084, 44.6712), 'position' => 1))), array('position' => 2, 'vehicle' => array('class' => 'class3'), 'laps' => array(array('time' => 130.9077, 'sectors' => array(54.0223, 32.3176, 44.5677), 'position' => 2), array('time' => 125.6976, 'sectors' => array(47.5271, 32.4621, 45.7083), 'position' => 2), array('time' => 126.062, 'sectors' => array(47.7989, 32.7721, 45.491), 'position' => 2))), array('position' => 3, 'vehicle' => array('class' => 'class2'), 'laps' => array(array('time' => 134.8484, 'sectors' => array(56.0119, 32.4913, 46.3452), 'position' => 12), array('time' => 126.2454, 'sectors' => array(50.4389, 31.8827, 43.9237), 'position' => 3), array('time' => 122.0663, 'sectors' => array(46.2715, 31.8696, 43.9252), 'position' => 3))), array('position' => 4, 'vehicle' => array('class' => 'class1'), 'laps' => array(array('time' => 155.1491, 'sectors' => array(60.0119, 40.4913, 54.6459), 'position' => 4), array('time' => 156.1491, 'sectors' => array(60.0119, 40.4913, 55.6459), 'position' => 4))), array('position' => 5, 'vehicle' => array('class' => 'class2'), 'laps' => array()), array('position' => 6, 'vehicle' => array('class' => 'class3'), 'laps' => array(array('time' => null, 'sectors' => array(42.4389), 'position' => 6))));
     // Loop each participant data
     foreach ($participants_data as $participant_data) {
         // Create the new participant and populate
         $participant = new Participant();
         $participant->setPosition($participant_data['position']);
         $vehicle = new Vehicle();
         $vehicle->setClass($participant_data['vehicle']['class']);
         $participant->setVehicle($vehicle);
         // Create each lap
         foreach ($participant_data['laps'] as $lap_key => $lap_data) {
             $lap = new Lap();
             $lap->setTime($lap_data['time'])->setSectorTimes($lap_data['sectors'])->setNumber($lap_key + 1)->setPosition($lap_data['position'])->setParticipant($participant);
             // Add lap to participant
             $participant->addLap($lap);
         }
         // Add participant to session
         $session->addParticipant($participant);
     }
     // Return the session
     return $session;
 }
Example #12
Show file File: get_zip_code.php Project: smartfoundry/smartfoundry-webapi-php
0
function zip_start()
{
    // Create a new instance of the Session object, and get the channel information.
    $session = new Session();
    $from_info = $session->getFrom();
    $channel = $from_info['channel'];
    // Create a new instance of the Tropo object.
    $tropo = new Tropo();
    // See if any text was sent with session start.
    $initial_text = $session->getInitialText();
    // If the initial text is a zip code, skip the input collection and get weather information.
    if (strlen($initial_text) == 5 && is_numeric($initial_text)) {
        formatWeatherResponse($tropo, $initial_text);
    } else {
        // Welcome prompt (for phone channel, and IM/SMS sessions with invalid initial text).
        $tropo->say("Welcome to the Tropo PHP zip code example for {$channel}");
        // Set up options form zip code input
        $options = array("attempts" => 3, "bargein" => true, "choices" => "[5 DIGITS]", "name" => "zip", "timeout" => 5);
        // Ask the user for input, pass in options.
        $tropo->ask("Please enter your 5 digit zip code.", $options);
        // Tell Tropo what to do when the user has entered input, or if there is an error.
        $tropo->on(array("event" => "continue", "next" => "get_zip_code.php?uri=end", "say" => "Please hold."));
        $tropo->on(array("event" => "error", "next" => "get_zip_code.php?uri=error", "say" => "An error has occured."));
    }
    // Render the JSON for the Tropo WebAPI to consume.
    return $tropo->RenderJson();
}
Example #13
Show file File: DataMapperTest.php Project: khanhdeux/typo3test
0
 /**
  * Test if mapObjectToClassProperty method returns objects
  * that are already registered in the persistence session
  * without query it from the persistence layer
  *
  * @test
  */
 public function mapObjectToClassPropertyReturnsExistingObjectWithoutCallingFetchRelated()
 {
     $columnMap = new \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap('columnName', 'propertyName');
     $columnMap->setTypeOfRelation(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap::RELATION_HAS_ONE);
     $dataMap = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMap', array('getColumnMap'), array(), '', FALSE);
     $className = $this->getUniqueId('Class1');
     $classNameWithNS = __NAMESPACE__ . '\\' . $className;
     eval('namespace ' . __NAMESPACE__ . '; class ' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity { public $relationProperty; }');
     $object = new $classNameWithNS();
     $classSchema1 = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Reflection\\ClassSchema', array('dummy'), array($classNameWithNS));
     $classSchema1->_set('typeHandlingService', new \TYPO3\CMS\Extbase\Service\TypeHandlingService());
     $className2 = $this->getUniqueId('Class2');
     $className2WithNS = __NAMESPACE__ . '\\' . $className2;
     eval('namespace ' . __NAMESPACE__ . '; class ' . $className2 . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity { }');
     $child = new $className2WithNS();
     $classSchema2 = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Reflection\\ClassSchema', array('dummy'), array($className2WithNS));
     $classSchema2->_set('typeHandlingService', new \TYPO3\CMS\Extbase\Service\TypeHandlingService());
     $classSchema1->addProperty('relationProperty', $className2WithNS);
     $identifier = 1;
     $session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
     $session->registerObject($child, $identifier);
     $mockReflectionService = $this->getMock('\\TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array('getClassSchema'), array(), '', FALSE);
     $mockReflectionService->expects($this->any())->method('getClassSchema')->will($this->returnValue($classSchema1));
     $dataMap->expects($this->any())->method('getColumnMap')->will($this->returnValue($columnMap));
     $dataMapper = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapper', array('getDataMap', 'getNonEmptyRelationValue'));
     $dataMapper->_set('reflectionService', $mockReflectionService);
     $dataMapper->_set('persistenceSession', $session);
     $dataMapper->expects($this->any())->method('getDataMap')->will($this->returnValue($dataMap));
     $dataMapper->expects($this->never())->method('getNonEmptyRelationValue');
     $result = $dataMapper->_call('mapObjectToClassProperty', $object, 'relationProperty', $identifier);
     $this->assertEquals($child, $result);
 }
Example #14
Show file File: DataMapperTest.php Project: rickymathew/TYPO3.CMS
0
 /**
  * Test if mapObjectToClassProperty method returns objects
  * that are already registered in the persistence session
  * without query it from the persistence layer
  *
  * @test
  */
 public function mapObjectToClassPropertyReturnsExistingObjectWithoutCallingFetchRelated()
 {
     $columnMap = new ColumnMap('columnName', 'propertyName');
     $columnMap->setTypeOfRelation(ColumnMap::RELATION_HAS_ONE);
     $dataMap = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMap::class, array('getColumnMap'), array(), '', false);
     $className = $this->getUniqueId('Class1');
     $classNameWithNS = __NAMESPACE__ . '\\' . $className;
     eval('namespace ' . __NAMESPACE__ . '; class ' . $className . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' { public $relationProperty; }');
     $object = new $classNameWithNS();
     $className2 = $this->getUniqueId('Class2');
     $className2WithNS = __NAMESPACE__ . '\\' . $className2;
     eval('namespace ' . __NAMESPACE__ . '; class ' . $className2 . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' { }');
     $child = new $className2WithNS();
     $classSchema2 = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Reflection\ClassSchema::class, array('dummy'), array($className2WithNS));
     /** @var \TYPO3\CMS\Extbase\Reflection\ClassSchema|AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject $classSchema1 */
     $classSchema1 = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Reflection\ClassSchema::class, array('dummy'), array($classNameWithNS));
     $classSchema1->addProperty('relationProperty', $className2WithNS);
     $identifier = 1;
     $session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
     $session->registerObject($child, $identifier);
     $mockReflectionService = $this->getMock(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class, array('getClassSchema'), array(), '', false);
     $mockReflectionService->expects($this->any())->method('getClassSchema')->will($this->returnValue($classSchema1));
     $dataMap->expects($this->any())->method('getColumnMap')->will($this->returnValue($columnMap));
     $dataMapper = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::class, array('getDataMap', 'getNonEmptyRelationValue'));
     $dataMapper->_set('reflectionService', $mockReflectionService);
     $dataMapper->_set('persistenceSession', $session);
     $dataMapper->expects($this->any())->method('getDataMap')->will($this->returnValue($dataMap));
     $dataMapper->expects($this->never())->method('getNonEmptyRelationValue');
     $result = $dataMapper->_call('mapObjectToClassProperty', $object, 'relationProperty', $identifier);
     $this->assertEquals($child, $result);
 }
Example #15
Show file File: AdminController.php Project: kilinanatoly/zkam
0
 public function actionCreate_city($id)
 {
     @session_start();
     $_SESSION['menu'] = 2;
     $functions_model = new Functions();
     $model = new GeobaseCity();
     if ($model->load(Yii::$app->request->post())) {
         if (empty($model->url)) {
             $model->url = $functions_model->translit($model->name);
         }
         if (!empty($model->name)) {
             $model->region_id = $id;
             if ($model->validate()) {
                 if ($model->save()) {
                     $session = new Session();
                     $session->open();
                     $session = Yii::$app->session;
                     $session->setFlash('add_city', '<div class="alert alert-success">Вы успешно добавили город.</div>');
                     return $this->redirect('create_city?id=' . $id);
                 }
             }
         }
     }
     $region = GeobaseRegion::findOne(['id' => $id]);
     return $this->render('edit_city', ['model' => $model, 'region' => $region]);
 }
Example #16
Show file File: ApiController.php Project: brennanbrown/FreeGeoAPI
0
 public function authAction(Request $request)
 {
     if ($request->request->has('public') === false || $request->request->has('secret') === false) {
         $resp = array('status' => 'fatal', 'reason' => 'Unauthorized', 'message' => 'Provide app API credentials.', 'request' => $request->request->all());
         return new JsonResponse($resp);
     }
     $public = $request->request->get('public');
     $secret = $request->request->get('secret');
     $app = $this->getDoctrine()->getRepository('YupItsZacFreeGeoBundle:Apps')->findOneBy(array('publickey' => $public));
     if ($app === null) {
         $resp = array('status' => 'fatal', 'reason' => 'unauthroized', 'message' => 'The supplied API credentials are invalid, or revoked.');
         return new JsonResponse($resp);
     }
     $appId = $app->getId();
     $appTitle = $app->getApptitle();
     $appStatus = $app->getStatus();
     if ($appStatus != 'Active') {
         $resp = array('status' => 'fatal', 'reason' => 'Unauthorized', 'message' => 'App for public key ' . $public . ' is no longer active. The status is ' . $appStatus . '. For questions, contact support online at freegeo.yupitszac.com');
         return new JsonResponse($resp);
     }
     $sessionKey = md5(time() . $public . time() . $secret . time() . $appId);
     $em = $this->getDoctrine()->getEntityManager();
     $session = new Session();
     $session->setSession($sessionKey);
     $session->setPublic($public);
     $session->setSecret($secret);
     $session->setAppid($appId);
     $now = new DateTime('now');
     $session->setTimestamp($now);
     $em->persist($session);
     $em->flush();
     $resp = array('status' => 'success', 'reason' => 'authorized', 'payload' => array('session' => $sessionKey));
     return new JsonResponse($resp);
 }
Example #17
Show file File: PersistenceManagerTest.php Project: rickymathew/TYPO3.CMS
0
 /**
  * @test
  */
 public function updateSchedulesAnObjectForPersistence()
 {
     $className = $this->getUniqueId('BazFixture');
     eval('
namespace ' . __NAMESPACE__ . '\\Domain\\Model;
class ' . $className . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' {
	protected $uid = 42;
}
);
     eval('
namespace ' . __NAMESPACE__ . '\\Domain\\Repository;
class  ' . $className . 'Repository extends \\TYPO3\\CMS\\Extbase\\Persistence\\Repository {}
);
     $classNameWithNamespace = __NAMESPACE__ . '\\Domain\\Model\\' . $className;
     $repositorClassNameWithNamespace = __NAMESPACE__ . '\\Domain\\Repository\\' . $className . 'Repository';
     $persistenceManager = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class, array('dummy'));
     $session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
     $changedEntities = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
     $entity1 = new $classNameWithNamespace();
     $repository = $this->getAccessibleMock($repositorClassNameWithNamespace, array('dummy'), array($this->mockObjectManager));
     $repository->_set('objectType', get_class($entity1));
     $mockBackend = $this->getMock($this->buildAccessibleProxy(\TYPO3\CMS\Extbase\Persistence\Generic\Backend::class), array('commit', 'setChangedEntities'), array(), '', false);
     $mockBackend->expects($this->once())->method('setChangedEntities')->with($this->equalTo($changedEntities));
     $persistenceManager->_set('backend', $mockBackend);
     $persistenceManager->_set('persistenceSession', $session);
     $repository->_set('persistenceManager', $persistenceManager);
     $session->registerObject($entity1, 42);
     $changedEntities->attach($entity1);
     $repository->update($entity1);
     $persistenceManager->persistAll();
 }
Example #18
Show file File: AlertifyExtension.php Project: arouahoussem/AvAlertifyBundle
0
 /**
  * Alertify filter
  * @param TwigEnvironment $environment
  * @param Session         $session
  *
  * @return string
  */
 public function alertifyFilter($environment, Session $session)
 {
     $flashes = $session->getFlashBag()->all();
     $renders = array();
     foreach ($flashes as $type => $flash) {
         if ($type == "callback") {
             foreach ($flash as $key => $currentFlash) {
                 $currentFlash['body'] .= $environment->render('AvAlertifyBundle:Modal:callback.html.twig', $currentFlash);
                 $session->getFlashBag()->add($currentFlash['engine'], $currentFlash);
                 $renders[$type . $key] = $this->alertifyFilter($environment, $session);
             }
         } else {
             foreach ($flash as $key => $content) {
                 if (is_array($content)) {
                     $context = isset($content['context']) ? $content['context'] : null;
                     $defaultParameters = self::getDefaultParametersFromContext($context);
                     $parameters = array_merge($defaultParameters, $content);
                 } else {
                     $defaultParameters = self::getDefaultParametersFromContext(null);
                     $parameters = array_merge($defaultParameters, array('body' => $content));
                 }
                 $parameters['type'] = $type;
                 $renders[$type . $key] = $environment->render('AvAlertifyBundle:Modal:' . $parameters['engine'] . '.html.twig', $parameters);
             }
         }
     }
     return implode(' ', $renders);
 }
Example #19
Show file File: EntityPaginationStorageTest.php Project: Maksold/platform
0
 protected function setRequest()
 {
     $session = new Session(new MockArraySessionStorage());
     $request = new Request();
     $request->setSession($session);
     $this->storage->setRequest($request);
 }
Example #20
Show file File: RecursiveOneX.php Project: mitchlayzell/PHRETS
0
 public function parse(Session $rets, ResponseInterface $response, $parameters)
 {
     // we're given the first response automatically, so parse this and start the recursion
     /** @var \PHRETS\Parsers\Search\OneX $parser */
     $parser = $rets->getConfiguration()->getStrategy()->provide('parser.search');
     $rs = $parser->parse($rets, $response, $parameters);
     while ($this->continuePaginating($rets, $parameters, $rs)) {
         $pms = $parameters;
         $rets->debug("Continuing pagination...");
         $rets->debug("Current count collected already: " . $rs->count());
         $resource = $pms['SearchType'];
         $class = $pms['Class'];
         $query = array_key_exists('Query', $pms) ? $pms['Query'] : null;
         $pms['Offset'] = $this->getNewOffset($rets, $parameters, $rs);
         unset($pms['SearchType']);
         unset($pms['Class']);
         unset($pms['Query']);
         /** @var Results $inner_rs */
         $inner_rs = $rets->Search($resource, $class, $query, $pms, false);
         $rs->setTotalResultsCount($inner_rs->getTotalResultsCount());
         $rs->setMaxRowsReached($inner_rs->isMaxRowsReached());
         // test if we're actually paginating
         if ($this->isPaginationBroken($rs, $inner_rs)) {
             throw new AutomaticPaginationError("Automatic pagination doesn't not appear to be supported by the server");
         }
         foreach ($inner_rs as $ir) {
             $rs->addRecord($ir);
         }
     }
     return $rs;
 }
Example #21
Show file File: AppVariableTest.php Project: raphydev/onep
0
 public function testGetSession()
 {
     $request = $this->getMock('Symfony\\Component\\HttpFoundation\\Request');
     $request->method('getSession')->willReturn($session = new Session());
     $this->setRequestStack($request);
     $this->assertEquals($session, $this->appVariable->getSession());
 }
Example #22
Show file File: DirectorTest.php Project: miamollie/echoAerial
0
 public function preRequest(\SS_HTTPRequest $request, \Session $session, \DataModel $model)
 {
     ++$this->preCalls;
     if ($this->failPre) {
         return false;
     }
 }
Example #23
Show file File: AclTest.php Project: rbertani/kanboard
0
 public function testPageAccessNotMember()
 {
     $acl = new Acl($this->container);
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $u = new User($this->container);
     // We create our user
     $this->assertEquals(2, $u->create(array('username' => 'unittest', 'password' => 'unittest')));
     // We create a project and set our user as member
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     $this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
     $this->assertFalse($pp->isMember(1, 2));
     $this->assertFalse($pp->isManager(1, 2));
     $session = new Session();
     $session['user'] = array('id' => 2, 'is_admin' => false);
     $this->assertFalse($acl->isAllowed('board', 'show', 2));
     $this->assertFalse($acl->isAllowed('board', 'show', 1));
     $this->assertFalse($acl->isAllowed('task', 'show', 1));
     $this->assertFalse($acl->isAllowed('task', 'update', 1));
     $this->assertFalse($acl->isAllowed('project', 'show', 1));
     $this->assertFalse($acl->isAllowed('config', 'application', 1));
     $this->assertFalse($acl->isAllowed('project', 'users', 1));
     $this->assertFalse($acl->isAllowed('task', 'remove', 1));
     $this->assertTrue($acl->isAllowed('app', 'index', 1));
 }
Example #24
Show file File: SessionTest.php Project: tamago-db/php-box-view
0
 public function testConstructor()
 {
     $rawSession = $this->getRawTestSession();
     $session = $this->getTestSession();
     $response = new \Box\View\Session($this->client, $rawSession);
     $this->assertEquals($session, $response);
 }
Example #25
Show file File: Auth.php Project: kidaa30/redcat
0
 function __construct(Session $Session = null, $rootLogin = 'root', $rootPassword = 'root', $rootName = 'Developer', $siteLoginUri = 'Login', $siteActivateUri = 'Signin', $siteResetUri = 'Signin', $tableUsers = 'user', $tableRequests = 'request', $algo = PASSWORD_DEFAULT, $mailSendmail = true, $mailHost = null, $mailUsername = null, $mailPassword = null, $mailPort = 25, $mailSecure = 'tls', DataSource $db = null)
 {
     $this->rootLogin = $rootLogin;
     $this->rootPassword = $rootPassword;
     $this->rootName = $rootName;
     $this->siteLoginUri = $siteLoginUri;
     $this->siteActivateUri = $siteActivateUri;
     $this->siteResetUri = $siteResetUri;
     $this->tableUsers = $tableUsers;
     $this->tableRequests = $tableRequests;
     $this->algo = $algo;
     $this->mailSendmail = $mailSendmail;
     $this->mailHost = $mailHost;
     $this->mailUsername = $mailUsername;
     $this->mailPassword = $mailPassword;
     $this->mailPort = $mailPort;
     $this->mailSecure = $mailSecure;
     if (!$Session) {
         $Session = new Session();
     }
     $this->Session = $Session;
     if (!isset($db) && class_exists('RedCat\\DataMap\\B')) {
         $this->db = B::getDatabase();
     }
     $this->siteUrl = $this->getBaseHref();
     $this->siteUrl = rtrim($this->siteUrl, '/') . '/';
 }
Example #26
Show file File: System.php Project: mitchlayzell/PHRETS
0
 public function parse(Session $rets, ResponseInterface $response)
 {
     $xml = $response->xml();
     $base = $xml->METADATA->{'METADATA-SYSTEM'};
     $metadata = new \PHRETS\Models\Metadata\System();
     $metadata->setSession($rets);
     $configuration = $rets->getConfiguration();
     if ($configuration->getRetsVersion()->is1_5()) {
         if (isset($base->System->SystemID)) {
             $metadata->setSystemId((string) $base->System->SystemID);
         }
         if (isset($base->System->SystemDescription)) {
             $metadata->setSystemDescription((string) $base->System->SystemDescription);
         }
     } else {
         if (isset($base->SYSTEM->attributes()->SystemID)) {
             $metadata->setSystemId((string) $base->SYSTEM->attributes()->SystemID);
         }
         if (isset($base->SYSTEM->attributes()->SystemDescription)) {
             $metadata->setSystemDescription((string) $base->SYSTEM->attributes()->SystemDescription);
         }
         if (isset($base->SYSTEM->attributes()->TimeZoneOffset)) {
             $metadata->setTimezoneOffset((string) $base->SYSTEM->attributes()->TimeZoneOffset);
         }
     }
     if (isset($base->SYSTEM->Comments)) {
         $metadata->setComments((string) $base->SYSTEM->Comments);
     }
     if (isset($base->attributes()->Version)) {
         $metadata->setVersion((string) $xml->METADATA->{'METADATA-SYSTEM'}->attributes()->Version);
     }
     return $metadata;
 }
Example #27
Show file File: controller.php Project: phemmyster/phproject
0
 /**
  * Require a user to be logged in. Redirects to /login if a session is not found.
  * @param  int $rank
  * @return int|bool
  */
 protected function _requireLogin($rank = \Model\User::RANK_CLIENT)
 {
     $f3 = \Base::instance();
     if ($id = $f3->get("user.id")) {
         if ($f3->get("user.rank") >= $rank) {
             return $id;
         } else {
             $f3->error(403);
             $f3->unload();
             return false;
         }
     } else {
         if ($f3->get("site.demo") && is_numeric($f3->get("site.demo"))) {
             $user = new \Model\User();
             $user->load($f3->get("site.demo"));
             if ($user->id) {
                 $session = new \Model\Session($user->id);
                 $session->setCurrent();
                 $f3->reroute("/");
                 return;
             } else {
                 $f3->set("error", "Auto-login failed, demo user was not found.");
             }
         }
         if (empty($_GET)) {
             $f3->reroute("/login?to=" . urlencode($f3->get("PATH")));
         } else {
             $f3->reroute("/login?to=" . urlencode($f3->get("PATH")) . urlencode("?" . http_build_query($_GET)));
         }
         $f3->unload();
         return false;
     }
 }
Frequently Used Methods