_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q259500
LDAPGateway.move
test
public function move($fromDn, $toDn, $recursively = false) { $this->ldap->move($fromDn, $toDn, $recursively); }
php
{ "resource": "" }
q259501
LDAPAuthenticator.authenticate
test
public static function authenticate($data, Form $form = null) { $service = Injector::inst()->get('LDAPService'); $login = trim($data['Login']); if (Email::validEmailAddress($login)) { if (Config::inst()->get('LDAPAuthenticator', 'allow_email_login')!='yes') { $for...
php
{ "resource": "" }
q259502
LDAPAuthenticator.fallback_authenticate
test
protected static function fallback_authenticate($data, Form $form = null) { return call_user_func( [Config::inst()->get('LDAPAuthenticator', 'fallback_authenticator_class'), 'authenticate'], array_merge($data, ['Email' => $data['Login']]), $form ); }
php
{ "resource": "" }
q259503
SAMLController.acs
test
public function acs() { $auth = Injector::inst()->get('SAMLHelper')->getSAMLAuth(); $auth->processResponse(); $error = $auth->getLastErrorReason(); if (!empty($error)) { SS_Log::log($error, SS_Log::ERR); Form::messageForForm("SAMLLoginForm_LoginForm", "Authen...
php
{ "resource": "" }
q259504
SAMLController.metadata
test
public function metadata() { try { $auth = Injector::inst()->get('SAMLHelper')->getSAMLAuth(); $settings = $auth->getSettings(); $metadata = $settings->getSPMetadata(); $errors = $settings->validateMetadata($metadata); if (empty($errors)) { ...
php
{ "resource": "" }
q259505
LDAPUtil.little_endian
test
public static function little_endian($hex) { $result = ''; for ($x = strlen($hex) - 2; $x >= 0; $x = $x - 2) { $result .= substr($hex, $x, 2); } return $result; }
php
{ "resource": "" }
q259506
ReadHandler.selectCallback
test
public function selectCallback($ret) { if ($ret instanceof ErrorMessage) { return $ret; } $result = array(); foreach ($ret as $row) { $result[] = array_combine($this->fields, $row); } return $result; }
php
{ "resource": "" }
q259507
ReadHandler.select
test
public function select($compare, $keys, $limit = 1, $begin = 0) { $sk = $this->keys; if (is_array($keys)) { foreach ($sk as &$value) { if (!isset($keys[$value])) { break; } $value = $keys[$value]; } ...
php
{ "resource": "" }
q259508
XenforoPassword.splitHash
test
protected function splitHash($hash) { $parts = @unserialize($hash); if (!is_array($parts)) { $result = ['', '', '']; } else { $parts = array_merge(['hash' => '', 'hashFunc' => '', 'salt' => ''], $parts); if (!$parts['hashFunc']) { switch (str...
php
{ "resource": "" }
q259509
Db.create
test
public static function create($config) { $driver = val('driver', $config); if (!$driver) { throw new \Exception('You must specify a driver.', 500); } if (strpos($driver, '\\') === false) { $class = '\Garden\Db\\'.$driver; } else { // TODO: Che...
php
{ "resource": "" }
q259510
Db.getTableDef
test
public function getTableDef($tablename) { $ltablename = strtolower($tablename); // Check to see if the table isn't in the cache first. if ($this->allTablesFetched & Db::FETCH_TABLENAMES && !isset($this->tables[$ltablename])) { return null; } if ( ...
php
{ "resource": "" }
q259511
Db.getAllTables
test
public function getAllTables($withDefs = false) { if ($withDefs && ($this->allTablesFetched & Db::FETCH_COLUMNS)) { return $this->tables; } elseif (!$withDefs && ($this->allTablesFetched & Db::FETCH_TABLENAMES)) { return array_keys($this->tables); } else { ret...
php
{ "resource": "" }
q259512
Db.fixIndexes
test
protected function fixIndexes($tablename, array &$tableDef, $curTableDef = null) { // Loop through the columns and add get the primary key index. $primaryColumns = []; foreach ($tableDef['columns'] as $cname => $cdef) { if (val('primary', $cdef)) { $primaryColumns[] =...
php
{ "resource": "" }
q259513
Db.indexCompare
test
public function indexCompare(array $a, array $b) { if ($a['columns'] > $b['columns']) { return 1; } elseif ($a['columns'] < $b['columns']) { return -1; } return strcmp(val('type', $a, ''), val('type', $b, '')); }
php
{ "resource": "" }
q259514
Db.getOne
test
public function getOne($tablename, array $where, array $options = []) { $options['limit'] = 1; $rows = $this->get($tablename, $where, $options); return array_shift($rows); }
php
{ "resource": "" }
q259515
Db.buildIndexName
test
protected function buildIndexName($tablename, array $indexDef) { $type = val('type', $indexDef, Db::INDEX_IX); if ($type === Db::INDEX_PK) { return 'primary'; } $px = val($type, [Db::INDEX_IX => 'ix_', Db::INDEX_UNIQUE => 'ux_'], 'ix_'); $sx = val('suffix', $indexDef...
php
{ "resource": "" }
q259516
SecureString.encode
test
public function encode($data, array $spec, $throw = false) { $str = json_encode($data, JSON_UNESCAPED_SLASHES); $first = true; foreach ($spec as $name => $password) { if ($name === self::STRICT) { // Strict is just an option so continue. continue; ...
php
{ "resource": "" }
q259517
SecureString.generateRandomKey
test
public static function generateRandomKey($len = 32) { $bytes = ceil($len * 3 / 4); return substr(self::base64urlEncode(openssl_random_pseudo_bytes($bytes)), 0, $len); }
php
{ "resource": "" }
q259518
SecureString.supportedInfo
test
protected function supportedInfo($name, $throw = false) { switch ($name) { case 'aes128': case 'aes256': $cipher = 'aes-'.substr($name, 3).'-cbc'; return ['encrypt', 'decrypt', $cipher, false]; case 'hsha1': case 'hsha256': ...
php
{ "resource": "" }
q259519
SecureString.hmac
test
protected function hmac($str, $method, $password, $timestamp = 0, $throw = false) { if ($timestamp === 0) { $timestamp = time(); } // Add the timestamp to the string. static::pushString($str, $timestamp); // Sign the string. $signature = hash_hmac($method, $s...
php
{ "resource": "" }
q259520
SecureString.verifyHmac
test
protected function verifyHmac($str, $method, $password, $throw = false) { // Grab the signature from the string. $signature = $this->popString($str); if (!$signature) { return $this->exception($throw, "The signature is missing.", 403); } $signature = static::base64url...
php
{ "resource": "" }
q259521
SecureString.verifyTimestamp
test
protected function verifyTimestamp($timestamp, $throw = false) { if (!is_numeric($timestamp)) { return (bool)$this->exception($throw, "Invalid timestamp.", 403); } $intTimestamp = (int)$timestamp; $now = time(); if ($intTimestamp + $this->timestampExpiry <= $now) { ...
php
{ "resource": "" }
q259522
SecureString.popString
test
protected function popString(&$str) { if ($str === '') { return null; } $pos = strrpos($str, '.'); if ($pos !== false) { $result = substr($str, $pos + 1); $str = substr($str, 0, $pos); } else { $result = $str; $str = ''...
php
{ "resource": "" }
q259523
SecureString.pushString
test
protected function pushString(&$str, $item) { if ($str) { $str .= static::SEP; } $str .= implode(static::SEP, (array)$item); }
php
{ "resource": "" }
q259524
SecureString.twiddle
test
public function twiddle($string, $index, $value, $encode = false) { $parts = explode(static::SEP, $string); if ($encode) { $value = static::base64urlEncode($value); } $parts[$index] = $value; return implode(static::SEP, $parts); }
php
{ "resource": "" }
q259525
Validation.errorMessage
test
public static function errorMessage(array $error) { if (isset($error['message'])) { return $error['message']; } else { $field = val('field', $error, '*'); if (is_array($field)) { $field = implode(', ', $field); } return sprintft...
php
{ "resource": "" }
q259526
Validation.addError
test
public function addError($messageCode, $field = '*', $options = []) { $error = []; if (substr($messageCode, 0, 1) === '@') { $error['message'] = substr($messageCode, 1); } else { $error['code'] = $messageCode; } if (is_array($field)) { $fieldna...
php
{ "resource": "" }
q259527
Validation.mainMessage
test
public function mainMessage($value = null) { if ($value !== null) { $this->mainMessage = $value; return $this; } return $this->mainMessage; }
php
{ "resource": "" }
q259528
Validation.status
test
public function status($value = null) { if ($value !== null) { $this->status = $value; return $this; } if ($this->status) { return $this->status; } // There was no status so loop through the errors and look for the highest one. $maxSta...
php
{ "resource": "" }
q259529
Validation.getMessage
test
public function getMessage() { if ($this->mainMessage) { return $this->mainMessage; } // Generate the message by concatenating all of the errors together. $messages = []; foreach ($this->errors as $errors) { foreach ($errors as $error) { $...
php
{ "resource": "" }
q259530
Validation.getErrorsFlat
test
public function getErrorsFlat() { $result = []; foreach ($this->errors as $errors) { foreach ($errors as $error) { $result[] = $error; } } return $result; }
php
{ "resource": "" }
q259531
Validation.fieldValid
test
public function fieldValid($field) { $result = !isset($this->errors[$field]) || count($this->errors[$field]) === 0; return $result; }
php
{ "resource": "" }
q259532
Schema.parseSchema
test
public static function parseSchema(array $arr) { $result = []; foreach ($arr as $key => $value) { if (is_int($key)) { if (is_string($value)) { // This is a short param value. $param = static::parseShortParam($value); ...
php
{ "resource": "" }
q259533
Schema.requireOneOf
test
public function requireOneOf(array $fieldnames, $count = 1) { $result = $this->addValidator('*', function ($data, Validation $validation) use ($fieldnames, $count) { $hasCount = 0; $flattened = []; foreach ($fieldnames as $name) { $flattened = array_merge($fl...
php
{ "resource": "" }
q259534
Schema.validate
test
public function validate(array &$data, Validation &$validation = null) { if (!$this->isValidInternal($data, $this->schema, $validation, '')) { if ($validation === null) { // Although this should never be null, scrutinizer complains that it might be. $validation = new ...
php
{ "resource": "" }
q259535
Schema.validateField
test
protected function validateField(&$value, array $field, Validation $validation) { $path = array_select(['path', 'name'], $field); $type = val('type', $field, ''); $valid = true; // Check required first. // A value that isn't passed should fail the required test, but short circui...
php
{ "resource": "" }
q259536
Schema.validateArray
test
protected function validateArray(&$value, array $field, Validation $validation) { $validType = true; if (!is_array($value) || (count($value) > 0 && !array_key_exists(0, $value))) { $validType = false; } else { // Cast the items into a proper numeric array. $v...
php
{ "resource": "" }
q259537
Schema.validateBase64
test
protected function validateBase64(&$value, array $field, Validation $validation) { if (!is_string($value)) { $validType = false; } else { if (!preg_match('`^[a-zA-Z0-9/+]*={0,2}$`', $value)) { $validType = false; } else { $decoded = @ba...
php
{ "resource": "" }
q259538
Schema.validateBoolean
test
protected function validateBoolean(&$value, array $field, Validation $validation) { if (is_bool($value)) { $validType = true; } else { $bools = [ '0' => false, 'false' => false, 'no' => false, 'off' => false, '1' => true, 'true' => true, 'yes' =>...
php
{ "resource": "" }
q259539
Schema.validateDatetime
test
protected function validateDatetime(&$value, array $field, Validation $validation) { $validType = true; if ($value instanceof \DateTime) { $validType = true; } elseif (is_string($value)) { try { $dt = new \DateTime($value); if ($dt) { ...
php
{ "resource": "" }
q259540
Schema.validateFloat
test
protected function validateFloat(&$value, array $field, Validation $validation) { if (is_float($value)) { $validType = true; } elseif (is_numeric($value)) { $value = (float)$value; $validType = true; } else { $validType = false; } r...
php
{ "resource": "" }
q259541
Schema.validateInteger
test
protected function validateInteger(&$value, array $field, Validation $validation) { if (is_int($value)) { $validType = true; } elseif (is_numeric($value)) { $value = (int)$value; $validType = true; } else { $validType = false; } ret...
php
{ "resource": "" }
q259542
Schema.validateObject
test
protected function validateObject(&$value, array $field, Validation $validation) { if (!is_array($value) || isset($value[0])) { return false; } elseif (isset($field['properties'])) { $path = array_select(['path', 'name'], $field); // Validate the data against the inte...
php
{ "resource": "" }
q259543
Schema.validateRequired
test
protected function validateRequired(&$value, array $field, Validation $validation) { $required = val('required', $field, false); $type = $field['type']; if ($value === '' || $value === null) { if (!$required) { $value = null; return true; ...
php
{ "resource": "" }
q259544
Schema.validateString
test
protected function validateString(&$value, array $field, Validation $validation) { if (is_string($value)) { $validType = true; } elseif (is_numeric($value)) { $value = (string)$value; $validType = true; } else { $validType = false; } ...
php
{ "resource": "" }
q259545
Schema.validateTimestamp
test
protected function validateTimestamp(&$value, array $field, Validation $validation) { $validType = true; if (is_numeric($value)) { $value = (int)$value; } elseif (is_string($value) && $ts = strtotime($value)) { $value = $ts; } else { $validType = false...
php
{ "resource": "" }
q259546
Addons.all
test
public static function all($addon_key = null, $key = null) { if (self::$all === null) { self::$all = static::cacheGet('addons-all', array(get_class(), 'scanAddons')); } // The array should be built now return the addon. if ($addon_key === null) { return self::$al...
php
{ "resource": "" }
q259547
Addons.bootstrap
test
public static function bootstrap($enabled_addons = null) { // Load the addons from the config if they aren't passed in. if (!is_array($enabled_addons)) { $enabled_addons = config('addons', array()); } // Reformat the enabled array into the form: array('addon_key' => 'addon_ke...
php
{ "resource": "" }
q259548
Addons.cacheGet
test
protected static function cacheGet($key, callable $cache_cb) { // Salt the cache with the root path so that it will invalidate if the app is moved. $salt = substr(md5(static::baseDir()), 0, 10); $cache_path = PATH_ROOT."/cache/$key-$salt.json.php"; if (file_exists($cache_path)) { ...
php
{ "resource": "" }
q259549
Addons.classMap
test
public static function classMap($classname = null) { if (self::$classMap === null) { // Loop through the enabled addons and grab their classes. $class_map = array(); foreach (static::enabled() as $addon) { if (isset($addon[self::K_CLASSES])) { ...
php
{ "resource": "" }
q259550
Addons.enabled
test
public static function enabled($addon_key = null, $key = null) { // Lazy build the enabled array. if (self::$enabled === null) { // Make sure the enabled addons have been added first. if (self::$enabledKeys === null) { throw new \Exception("Addons::boostrap() must...
php
{ "resource": "" }
q259551
Addons.info
test
public static function info($addon_key) { $addon_key = strtolower($addon_key); // Check the enabled array first so that we don't load all addons if we don't have to. if (isset(self::$enabledKeys[$addon_key])) { return static::enabled($addon_key, self::K_INFO); } else { ...
php
{ "resource": "" }
q259552
Addons.scanAddonRecursive
test
protected static function scanAddonRecursive($dir, &$addons, $enabled = null) { $dir = rtrim($dir, '/'); $addonKey = strtolower(basename($dir)); // Scan the addon if it is enabled. if ($enabled === null || in_array($addonKey, $enabled)) { list($addonKey, $addon) = static::sc...
php
{ "resource": "" }
q259553
Addons.scanAddon
test
protected static function scanAddon($dir) { $dir = rtrim($dir, '/'); $addon_key = strtolower(basename($dir)); // Look for the addon info array. $info_path = $dir.'/addon.json'; $info = false; if (file_exists($info_path)) { $info = json_decode(file_get_content...
php
{ "resource": "" }
q259554
Addons.scanAddons
test
protected static function scanAddons($dir = null, $enabled = null, &$addons = null) { if (!$dir) { $dir = static::$baseDir; } if ($addons === null) { $addons = array(); } /* @var \DirectoryIterator */ foreach (new \DirectoryIterator($dir) as $subd...
php
{ "resource": "" }
q259555
Addons.startAddon
test
public static function startAddon($addon_key) { $addon = static::enabled($addon_key); if (!$addon) { return false; } // Run the class' bootstrap. if ($bootstrap_path = val(self::K_BOOTSTRAP, $addon)) { include_once $bootstrap_path; } retur...
php
{ "resource": "" }
q259556
ClientException.getHeaders
test
public function getHeaders() { $result = []; foreach ($this->context as $key => $value) { if (stripos($key, 'http_') === 0) { $key = Response::normalizeHeader(ltrim_substr($key, 'http_')); $result[$key] = $value; } } return $result;...
php
{ "resource": "" }
q259557
Event.callUserFuncArray
test
public static function callUserFuncArray($callback, $args = []) { // Figure out the event name from the callback. $event_name = static::getEventname($callback); if (!$event_name) { return call_user_func_array($callback, $args); } // The events could have different ar...
php
{ "resource": "" }
q259558
Event.bind
test
public static function bind($event, $callback, $priority = Event::PRIORITY_NORMAL) { $event = strtolower($event); self::$handlers[$event][$priority][] = $callback; self::$toSort[$event] = true; }
php
{ "resource": "" }
q259559
Event.bindClass
test
public static function bindClass($class, $priority = Event::PRIORITY_NORMAL) { $method_names = get_class_methods($class); // Grab an instance of the class so there is something to bind to. if (is_string($class)) { if (method_exists($class, 'instance')) { // TODO: Mak...
php
{ "resource": "" }
q259560
Event.dumpHandlers
test
public static function dumpHandlers() { $result = []; foreach (self::$handlers as $event_name => $nested) { $handlers = call_user_func_array('array_merge', static::getHandlers($event_name)); $result[$event_name] = array_map('format_callback', $handlers); } retur...
php
{ "resource": "" }
q259561
Event.fire
test
public static function fire($event) { $handlers = self::getHandlers($event); if (!$handlers) { return null; } // Grab the handlers and call them. $args = array_slice(func_get_args(), 1); $result = null; foreach ($handlers as $callbacks) { ...
php
{ "resource": "" }
q259562
Event.fireArray
test
public static function fireArray($event, $args = []) { $handlers = self::getHandlers($event); if (!$handlers) { return null; } // Grab the handlers and call them. $result = null; foreach ($handlers as $callbacks) { foreach ($callbacks as $callback...
php
{ "resource": "" }
q259563
Event.fireFilter
test
public static function fireFilter($event, $value) { $handlers = self::getHandlers($event); if (!$handlers) { return $value; } $args = array_slice(func_get_args(), 1); foreach ($handlers as $callbacks) { foreach ($callbacks as $callback) { ...
php
{ "resource": "" }
q259564
Event.functionExists
test
public static function functionExists($function_name, $only_events = false) { if (!$only_events && function_exists($function_name)) { return true; } else { return static::hasHandler($function_name); } }
php
{ "resource": "" }
q259565
Event.getEventname
test
protected static function getEventname($callback) { if (is_string($callback)) { return strtolower($callback); } elseif (is_array($callback)) { if (is_string($callback[0])) { $classname = $callback[0]; } else { $classname = get_class($ca...
php
{ "resource": "" }
q259566
Event.getHandlers
test
public static function getHandlers($name) { $name = strtolower($name); if (!isset(self::$handlers[$name])) { return []; } // See if the handlers need to be sorted. if (isset(self::$toSort[$name])) { ksort(self::$handlers[$name]); unset(self::...
php
{ "resource": "" }
q259567
Event.hasHandler
test
public static function hasHandler($event) { $event = strtolower($event); return array_key_exists($event, self::$handlers) && !empty(self::$handlers[$event]); }
php
{ "resource": "" }
q259568
Event.methodExists
test
public static function methodExists($object, $method_name, $only_events = false) { if (!$only_events && method_exists($object, $method_name)) { return true; } else { // Check to see if there is an event bound to the method. $event_name = self::getEventname([$object, $...
php
{ "resource": "" }
q259569
Literal.getValue
test
public function getValue($driver = 'default') { $driver = $this->normalizeKey($driver); if (isset($this->driverValues[$driver])) { return $this->driverValues[$driver]; } elseif (isset($this->driverValues['default'])) { return $this->driverValues['default']; } els...
php
{ "resource": "" }
q259570
Literal.setValue
test
public function setValue($value, $driver = 'default') { $driver = $this->normalizeKey($driver); $this->driverValues[$driver] = $value; return $this; }
php
{ "resource": "" }
q259571
VbulletinPassword.splitSalt
test
public function splitSalt($hash) { // The hash is in the form: <32 char hash><salt>. $salt_length = strlen($hash) - 32; $salt = trim(substr($hash, -$salt_length, $salt_length)); $stored_hash = substr($hash, 0, strlen($hash) - $salt_length); return [$stored_hash, $salt]; }
php
{ "resource": "" }
q259572
Config.defaultPath
test
public static function defaultPath($value = '') { if ($value) { self::$defaultPath = $value; } elseif (!self::$defaultPath) { self::$defaultPath = PATH_ROOT.'/conf/config.json.php'; } return self::$defaultPath; }
php
{ "resource": "" }
q259573
Config.get
test
public static function get($key, $default = null) { if (array_key_exists($key, self::$data)) { return self::$data[$key]; } else { return $default; } }
php
{ "resource": "" }
q259574
Config.load
test
public static function load($path = '', $underlay = false, $php_var = 'config') { if (!$path) { $path = self::$defaultPath; } $loaded = array_load($path, $php_var); if (empty($loaded)) { return; } if (!is_array(self::$data)) { self::...
php
{ "resource": "" }
q259575
Config.save
test
public static function save($data, $path = null, $php_var = 'config') { if (!is_array($data)) { throw new \InvalidArgumentException('Config::save(): Argument #1 is not an array.', 400); } if (!$path) { $path = static::defaultPath(); } // Load the current...
php
{ "resource": "" }
q259576
Application.matchRoutes
test
public function matchRoutes(Request $request) { $result = array(); foreach ($this->routes as $route) { $matches = $route->matches($request, $this); if ($matches) { $result[] = array($route, $matches); } } return $result; }
php
{ "resource": "" }
q259577
Application.route
test
public function route($pathOrRoute, $callback = null) { if (is_object($pathOrRoute) && $pathOrRoute instanceof Route) { $route = $pathOrRoute; } elseif (is_string($pathOrRoute) && $callback !== null) { $route = Route::create($pathOrRoute, $callback); } else { ...
php
{ "resource": "" }
q259578
Application.finalize
test
protected function finalize($result) { $response = Response::create($result); $response->meta(['request' => $this->request], true); $response->contentTypeFromAccept($this->request->getEnv('HTTP_ACCEPT')); $response->contentAsset($this->request->getEnv('HTTP_X_ASSET')); $contentT...
php
{ "resource": "" }
q259579
ResourceRoute.actionExists
test
protected function actionExists($object, $action, $method = '', $special = false) { if ($special && in_array($action, self::$specialActions)) { return ''; } // Short circuit on a badly named action. if (!$this->isIdentifier($action)) { return ''; } ...
php
{ "resource": "" }
q259580
ResourceRoute.allowedMethods
test
protected function allowedMethods($object, $action) { $allMethods = [ Request::METHOD_GET, Request::METHOD_POST, Request::METHOD_DELETE, Request::METHOD_PATCH, Request::METHOD_PUT, Request::METHOD_HEAD, Request::METHOD_OPTIONS ]; // Special actions should not...
php
{ "resource": "" }
q259581
ResourceRoute.matches
test
public function matches(Request $request, Application $app) { if (!$this->matchesMethods($request)) { return null; } if ($this->getMatchFullPath()) { $path = $request->getFullPath(); } else { $path = $request->getPath(); } // If this ...
php
{ "resource": "" }
q259582
ResourceRoute.failsCondition
test
protected function failsCondition($name, $value) { $name = strtolower($name); if (isset($this->conditions[$name])) { $regex = $this->conditions[$name]; return !preg_match("`^$regex$`", $value); } if (isset(self::$globalConditions[$name])) { $regex = s...
php
{ "resource": "" }
q259583
Response.current
test
public static function current(Response $response = null) { if ($response !== null) { self::$current = $response; } elseif (self::$current === null) { self::$current = new Response(); } return self::$current; }
php
{ "resource": "" }
q259584
Response.create
test
public static function create($result) { if ($result instanceof Response) { return $result; } elseif ($result instanceof Exception\ResponseException) { /* @var Exception\ResponseException $result */ return $result->getResponse(); } $response = new Res...
php
{ "resource": "" }
q259585
Response.contentType
test
public function contentType($value = null) { if ($value === null) { return $this->headers('Content-Type'); } return $this->headers('Content-Type', $value); }
php
{ "resource": "" }
q259586
Response.contentAsset
test
public function contentAsset($asset = null) { if ($asset !== null) { $this->contentAsset = $asset; return $this; } return $this->contentAsset; }
php
{ "resource": "" }
q259587
Response.contentTypeFromAccept
test
public function contentTypeFromAccept($accept) { if (!empty($this->headers['Content-Type'])) { return; } $accept = strtolower($accept); if (strpos($accept, ',') === false) { list($contentType) = explode(';', $accept); } elseif (strpos($accept, 'text/html'...
php
{ "resource": "" }
q259588
Response.statusMessage
test
public static function statusMessage($statusCode, $header = false) { $message = val($statusCode, self::$messages, 'Unknown'); if ($header) { return "HTTP/1.1 $statusCode $message"; } else { return $message; } }
php
{ "resource": "" }
q259589
Response.cookies
test
public function cookies($name, $value = false, $expires = 0, $path = null, $domain = null, $secure = false, $httponly = false) { if ($value === false) { return val($name, $this->cookies); } $this->cookies[$name] = [$value, $expires, $path, $domain, $secure, $httponly]; retur...
php
{ "resource": "" }
q259590
Response.globalCookies
test
public static function globalCookies($name = null, $value = false, $expires = 0, $path = null, $domain = null, $secure = false, $httponly = false) { if (self::$globalCookies === null) { self::$globalCookies = []; } if ($name === null) { return self::$globalCookies; ...
php
{ "resource": "" }
q259591
Response.meta
test
public function meta($meta = null, $merge = false) { if ($meta !== null) { if ($merge) { $this->meta = array_merge($this->meta, $meta); } else { $this->meta = $meta; } return $this; } else { return $this->meta; ...
php
{ "resource": "" }
q259592
Response.data
test
public function data($data = null, $merge = false) { if ($data !== null) { if ($merge) { $this->data = array_merge($this->data, $data); } else { $this->data = $data; } return $this; } else { return $this->data; ...
php
{ "resource": "" }
q259593
Response.headers
test
public function headers($name, $value = null, $replace = true) { $headers = static::splitHeaders($name, $value); if (is_string($headers)) { return val($headers, $this->headers); } foreach ($headers as $name => $value) { if ($replace || !isset($this->headers[$nam...
php
{ "resource": "" }
q259594
Response.globalHeaders
test
public static function globalHeaders($name = null, $value = null, $replace = true) { if (self::$globalHeaders === null) { self::$globalHeaders = [ 'P3P' => 'CP="CAO PSA OUR"' ]; } if ($name === null) { return self::$globalHeaders; } ...
php
{ "resource": "" }
q259595
Response.normalizeHeader
test
public static function normalizeHeader($name) { static $special = [ 'etag' => 'ETag', 'p3p' => 'P3P', 'www-authenticate' => 'WWW-Authenticate', 'x-ua-compatible' => 'X-UA-Compatible' ]; $name = str_replace(['-', '_'], ' ', strtolower($name)); if (isset($special[$...
php
{ "resource": "" }
q259596
Response.flushHeaders
test
public function flushHeaders($global = true) { if (headers_sent()) { return; } if ($global) { $cookies = array_replace(static::globalCookies(), $this->cookies); $headers = array_replace(static::globalHeaders(), $this->headers); } else { $c...
php
{ "resource": "" }
q259597
SqliteDb.alterTableMigrate
test
protected function alterTableMigrate($tablename, array $alterDef, array $options = []) { $currentDef = $this->getTableDef($tablename); // Merge the table definitions if we aren't dropping stuff. if (!val(Db::OPTION_DROP, $options)) { $tableDef = $this->mergeTableDefs($currentDef, $a...
php
{ "resource": "" }
q259598
SqliteDb.renameTable
test
protected function renameTable($oldname, $newname) { $renameSql = 'alter table '. $this->backtick($this->px.$oldname). ' rename to '. $this->backtick($this->px.$newname); $this->query($renameSql, Db::QUERY_WRITE); }
php
{ "resource": "" }
q259599
SqliteDb.dropIndex
test
protected function dropIndex($indexName) { $sql = 'drop index if exists '. $this->backtick($indexName); $this->query($sql, Db::QUERY_DEFINE); }
php
{ "resource": "" }