/** * Generates a captcha image, writing it to the output * It is used internally by this bundle when pointing to "/captcha" (see [vendor]\routes.php) * Typically, you won't use this function, but use the above img() function instead * * @access public * @return img */ public static function create($id = null) { static::$char = Str::random(static::$config['length'], static::$config['type']); static::$id = $id ? $id : static::$config['id']; Session::put('captchaHash', Hash::make(static::$config['sensitive'] === true ? static::$char : Str::lower(static::$char))); $bg_image = static::asset('backgrounds'); $bg_image_info = getimagesize($bg_image); if ($bg_image_info['mime'] == 'image/jpg' || $bg_image_info['mime'] == 'image/jpeg') { $old_image = imagecreatefromjpeg($bg_image); } elseif ($bg_image_info['mime'] == 'image/gif') { $old_image = imagecreatefromgif($bg_image); } elseif ($bg_image_info['mime'] == 'image/png') { $old_image = imagecreatefrompng($bg_image); } $new_image = imagecreatetruecolor(static::$config['width'], static::$config['height']); $bg = imagecolorallocate($new_image, 255, 255, 255); imagefill($new_image, 0, 0, $bg); imagecopyresampled($new_image, $old_image, 0, 0, 0, 0, static::$config['width'], static::$config['height'], $bg_image_info[0], $bg_image_info[1]); $bg = imagecolorallocate($new_image, 255, 255, 255); for ($i = 0; $i < strlen(static::$char); $i++) { $color_cols = explode(',', static::asset('colors')); $fg = imagecolorallocate($new_image, trim($color_cols[0]), trim($color_cols[1]), trim($color_cols[2])); imagettftext($new_image, static::asset('fontsizes'), rand(-10, 15), 10 + $i * static::$config['space'], rand(static::$config['height'] - 10, static::$config['height'] - 5), $fg, static::asset('fonts'), static::$char[$i]); } imagealphablending($new_image, false); header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'); header('Pragma: no-cache'); header("Content-type: image/jpg"); header('Content-Disposition: inline; filename=' . static::$id . '.jpg'); imagejpeg($new_image, null, 80); imagedestroy($new_image); }
function setUp() { static::$id = 7777777; static::$pattern = "iformbuilder\\.com\\/exzact\\/api\\/v60\\/profiles\\/[0-9]+\\/optionlists"; $this->setResourceType('Iform\\Resources\\OptionList\\OptionLists'); parent::setUp(); }
/** * @return \Fubhy\GraphQL\Type\Definition\Types\Scalars\IdType */ public static function idType() { if (!isset(static::$id)) { static::$id = new IdType(); } return static::$id; }
function setUp() { static::$id = 7777777; static::$pattern = "iformbuilder\\.com\\/exzact\\/api\\/v60\\/profiles\\/[0-9]+\\/pages\\/" . static::$id . "\\/elements"; $this->setIdentifier(static::$id); $this->setResourceType('Iform\\Resources\\Element\\Elements'); parent::setUp(); }
/** * component의 id를 지정한다. * * @param string $id 지정할 id * * @return void */ public static function setId($id) { if (property_exists(static::class, 'id')) { static::$id = $id; } else { self::$id[static::class] = $id; } }
public static function required() { static::preInit(); $sid = session_id(); if (!$sid) { session_start(); $sid = session_id(); if (!isset($_SESSION['ip'], $_SESSION['logins'])) { // Session not started for this session $_SESSION = array('ip' => sha1($_SERVER['REMOTE_ADDR']), 'ua' => sha1($_SERVER['HTTP_USER_AGENT']), 'start' => time(), 'active' => time(), 'messages' => array(), 'logins' => array(), 'vars' => array()); } else { } static::$session =& $_SESSION; static::$id = session_id(); } }
public static function start() { // run gc static::gc(); // get session id $name = Config::get('session.name', 'anchorcms'); static::$id = Cookie::get($name); if (static::$id === false) { Log::info('Session cookie not found: ' . $name); static::$id = Str::random(32); } // load session data $sql = "select data from sessions where id = ? and ip = ? and ua = ? limit 1"; $args = array(static::$id, Input::ip_address(), Input::user_agent()); if ($session = Db::row($sql, $args)) { static::$data = unserialize($session->data); } else { // Session not found regenerate ID static::$id = Str::random(32); Db::insert('sessions', array('id' => static::$id, 'date' => date(DATE_ISO8601), 'ip' => Input::ip_address(), 'ua' => Input::user_agent(), 'data' => serialize(static::$data))); } }
/** * Authentication classes should call this method * * @param string $id user id as identified by the authentication classes * * @return void */ public static function setUserId($id) { static::$id = $id; }
public static function batchDelete($bulkId, $async = true) { $bulk = []; foreach ($bulkId as $id) { $obj = new static(static::getPrimaryArray($id)); $bulk[] = ['delete' => $obj->setBulkParams(['id' => $obj->id()])]; } if ($async) { return static::asyncBulk($bulk); } else { return static::bulk($bulk); } }
/** * Returns the session id. * Calling this method will not auto start the session. You might have to manually * assert a started session. * * Passing an id into it, you can also replace the session id if the session * has not already been started. * Note that depending on the session handler, not all characters are allowed * within the session id. For example, the file session handler only allows * characters in the range a-z A-Z 0-9 , (comma) and - (minus). * * @param string|null $id Id to replace the current session id * @return string Session id */ public static function id($id = null) { if ($id) { static::$id = $id; session_id(static::$id); } if (static::started()) { return session_id(); } return static::$id; }
function tearDown() { m::close(); static::$id = ""; static::$pattern = ""; unset($this->stub); unset($this->resourceType); unset($this->resource); unset($this->identifier); }
/** * Clears the session, the session id, and renews the session. * * @return void */ public static function clear() { $_SESSION = null; static::$id = null; static::renew(); }
public static function destroy() { $_SESSION = array(); session_destroy(); static::$id = null; }
/** * Register app service and singleton containers that bound with current app ID. * Exit application if empty ID provided. * * @param mixed $config * @param mixed $id * @return mixed */ protected function registerApp($config, $id) { if (empty(trim($id))) { exit('App ID must not be empty!'); } $this->config = $config; static::$id = $id; if (!isset(static::$services[$id])) { static::$services[$id] = []; } if (!isset(static::$singletons[$id])) { static::$singletons[$id] = []; } if (!isset(static::$apps[$id])) { static::$apps[$id] = $this; } return static::$apps[$id]; }
/** * Authentication classes should call this method * * @param string $id user id as identified by the authentication classes * * @return void */ public static function setUniqueIdentifier($id) { static::$id = $id; }
/** * Creates a temporary user. Useful for creating invites. * * @param array $data user data * * @return User temporary user */ public static function createTemporary($data) { $email = trim(strtolower(array_value($data, 'email'))); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { return false; } $insertArray = array_replace($data, ['enabled' => 0]); // create the temporary user $user = new static(); $driver = self::getDriver(); $created = $driver->createModel($user, $insertArray); if (!$created) { return false; } // get the new user ID $id = []; foreach (static::getIDProperties() as $k) { $id[] = $driver->getCreatedID($user, $k); } $user = new static($id); // create the temporary link $link = new UserLink(); $link->create(['user_id' => $user->id(), 'type' => UserLink::TEMPORARY]); return $user; }
/** * Store the page to class static vars * * @param * @return */ public static function load() { $segments = explode('/', \Uri::detect(), 2); $page = !empty($segments[0]) ? $segments[0] : 'home'; $parameters = !empty($segments[1]) ? $segments[1] : null; $result = \DB::select('*')->from('pages')->where('page', $page)->where('status', true)->limit(1)->execute()->current(); if (!$result) { static::$response_status = 404; $result = \DB::select('*')->from('pages')->where('page', '404')->limit(1)->execute()->current(); } static::$id = $result['id']; static::$page = $page; static::$parameters = $parameters; static::$meta_title = $result['meta_title']; static::$meta_keywords = $result['meta_keywords']; static::$meta_description = $result['meta_description']; static::$content = $result['content']; static::$status = $result['status']; }
/** * Invites user. * * @param UserId $anId The id * @param UserEmail $anEmail The email * @param array $userRoles Array which contains the roles * * @return static */ public static function invite(UserId $anId, UserEmail $anEmail, array $userRoles) { $user = new static($anId, $anEmail, $userRoles); $user->invitationToken = new UserToken(); $user->publish(new UserInvited($user->id(), $user->email(), $user->invitationToken())); return $user; }
/** * Clears the session. * * Optionally also clears the session id and renews the session. * * @param bool $renew If the session should also be renewed. Defaults to true. * @return void */ public static function clear($renew = true) { if (!$renew) { $_SESSION = array(); return; } $_SESSION = null; static::$id = null; static::renew(); }
/** * Clears the session. * * Optionally also clears the session id and renews the session. * * @param bool $renew If the session should also be renewed. Defaults to true. * * @return void */ public static function clear($renew = TRUE) { if (!$renew) { $_SESSION = array(); return; } $_SESSION = NULL; static::$id = NULL; static::renew(); }