Example #1
0
 /**
  * Test input GET
  */
 public function testGet()
 {
     // generate server data
     $this->fakeServerData();
     // check get params
     $this->assertEquals(CCIn::get('foo'), 32);
     // check get param default
     $this->assertEquals(CCIn::get('not_existing', 'test'), 'test');
     // check get param has
     $this->assertFalse(CCIn::has_get('not_existing'));
     // check get param has
     $this->assertTrue(CCIn::has_get('foo'));
 }
Example #2
0
 /**
  * Redirect to next parameter
  * also sanitize the parameter we only allow internal redirects
  *
  * @return CCResponse
  */
 public static function next()
 {
     return static::full(parse_url(CCIn::get('next'), PHP_URL_PATH));
 }
Example #3
0
 /**
  * Does the current session fingerprint match a parameter
  *
  * When no parameter is given we use GET->s as default parameter
  *
  * @param string 		$fingerprint
  * @return string
  */
 public function valid_fingerprint($fingerprint = null)
 {
     if (is_null($fingerprint)) {
         $fingerprint = \CCIn::get(\ClanCats::$config->get('session.default_fingerprint_parameter'), false);
     }
     return $this->fingerprint === $fingerprint;
 }
    if ($queries < 1) {
        $queries = 1;
    }
    if ($queries > 500) {
        $queries = 500;
    }
    $worlds = array();
    for ($i = 0; $i < $queries; ++$i) {
        $world = DB::select('World')->find(mt_rand(1, 10000));
        $world->id = intval($world->id);
        $world->randomNumber = intval($world->randomNumber);
        $worlds[] = $world;
    }
    return CCResponse::create(json_encode($worlds), 200)->header('Content-Type', 'application/json');
}, 'updates' => function () {
    $queries = CCIn::get('queries', 1);
    if ($queries < 1) {
        $queries = 1;
    }
    if ($queries > 500) {
        $queries = 500;
    }
    $worlds = array();
    for ($i = 0; $i < $queries; ++$i) {
        $id = mt_rand(1, 10000);
        DB::update('World')->set('randomNumber', mt_rand(1, 10000))->where('id', $id)->run();
        $world = DB::select('World')->find($id);
        $world->id = intval($world->id);
        $world->randomNumber = intval($world->randomNumber);
        $worlds[] = $world;
    }