_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q259600
SqliteDb.createIndex
test
public function createIndex($tablename, array $indexDef, $options = []) { $sql = 'create '. (val('type', $indexDef) === Db::INDEX_UNIQUE ? 'unique ' : ''). 'index '. (val(Db::OPTION_IGNORE, $options) ? 'if not exists ' : ''). $this->buildIndexName($tablename, $indexDef). ' on '. $this->backtick($this->px.$tablename). $this->bracketList($indexDef['columns'], '`'); $this->query($sql, Db::QUERY_DEFINE); }
php
{ "resource": "" }
q259601
SqliteDb.forceType
test
protected function forceType($value, $type) { $type = strtolower($type); if ($type === 'null') { return null; } elseif (in_array($type, ['int', 'integer', 'tinyint', 'smallint', 'mediumint', 'bigint', 'unsigned big int', 'int2', 'int8', 'boolean'])) { return force_int($value); } elseif (in_array($type, ['real', 'double', 'double precision', 'float', 'numeric', 'decimal(10,5)'])) { return floatval($value); } else { return (string)$value; } }
php
{ "resource": "" }
q259602
SqliteDb.getPKValue
test
protected function getPKValue($tablename, array $row, $quick = false) { if ($quick && isset($row[$tablename.'ID'])) { return [$tablename.'ID' => $row[$tablename.'ID']]; } $tdef = $this->getTableDef($tablename); if (isset($tdef['indexes'][Db::INDEX_PK]['columns'])) { $pkColumns = array_flip($tdef['indexes'][Db::INDEX_PK]['columns']); $cols = array_intersect_key($row, $pkColumns); if (count($cols) === count($pkColumns)) { return $cols; } } return null; }
php
{ "resource": "" }
q259603
SqliteDb.getTablenames
test
protected function getTablenames() { // Get the table names. $tables = (array)$this->get( 'sqlite_master', [ 'type' => 'table', 'name' => [Db::OP_LIKE => addcslashes($this->px, '_%').'%'] ], [ 'columns' => ['name'], 'escapeTable' => false ] ); // Strip the table prefixes. $tables = array_map(function ($name) { return ltrim_substr($name, $this->px); }, array_column($tables, 'name')); return $tables; }
php
{ "resource": "" }
q259604
Route.create
test
public static function create($pattern, $callback) { if (is_callable($callback)) { $route = new CallbackRoute($pattern, $callback); } else { $route = new ResourceRoute($pattern, $callback); } return $route; }
php
{ "resource": "" }
q259605
Route.conditions
test
public function conditions($conditions = null) { if ($this->conditions === null) { $this->conditions = []; } if (is_array($conditions)) { $conditions = array_change_key_case($conditions); $this->conditions = array_replace( $this->conditions, $conditions ); return $this; } return $this->conditions; }
php
{ "resource": "" }
q259606
Route.methods
test
public function methods($methods = null) { if ($methods === null) { return $this->methods; } $this->methods = array_map('strtoupper', (array)$methods); return $this; }
php
{ "resource": "" }
q259607
Route.mappings
test
public function mappings($mappings = null) { if ($this->mappings === null) { $this->mappings = []; } if (is_array($mappings)) { $mappings = array_change_key_case($mappings); $this->mappings = array_replace( $this->mappings, $mappings ); return $this; } return $this->mappings; }
php
{ "resource": "" }
q259608
Route.globalMappings
test
public static function globalMappings($mappings = null) { if (self::$globalMappings === null) { self::$globalMappings = []; } if (is_array($mappings)) { $mappings = array_change_key_case($mappings); self::$globalMappings = array_replace( self::$globalMappings, $mappings ); } return self::$globalMappings; }
php
{ "resource": "" }
q259609
Route.isMapped
test
protected function isMapped($name) { $name = strtolower($name); return isset($this->mappings[$name]) || isset(self::$globalMappings[$name]); }
php
{ "resource": "" }
q259610
Route.mappedData
test
protected function mappedData($name, Request $request) { $name = strtolower($name); if (isset($this->mappings[$name])) { $mapping = $this->mappings[$name]; } elseif (isset(self::$globalMappings[$name])) { $mapping = self::$globalMappings[$name]; } else { return null; } switch (strtolower($mapping)) { case self::MAP_DATA: $result = $request->getData(); break; case self::MAP_INPUT: $result = $request->getInput(); break; case self::MAP_QUERY: $result = $request->getQuery(); break; default: return null; } return $result; }
php
{ "resource": "" }
q259611
Route.matchesMethods
test
protected function matchesMethods(Request $request) { if (empty($this->methods)) { return true; } return in_array($request->getMethod(), $this->methods); }
php
{ "resource": "" }
q259612
Route.pattern
test
public function pattern($pattern = null) { if ($pattern !== null) { $this->pattern = '/'.ltrim($pattern, '/'); } return $this->pattern; }
php
{ "resource": "" }
q259613
CallbackRoute.dispatch
test
public function dispatch(Request $request, array &$args) { $callback = $args['callback']; $callback_args = reflect_args($callback, $args['args']); $result = call_user_func_array($callback, $callback_args); return $result; }
php
{ "resource": "" }
q259614
CallbackRoute.getPatternRegex
test
protected function getPatternRegex($pattern) { $result = preg_replace_callback('`{([^}]+)}`i', function ($match) { if (preg_match('`(.*?)([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)(.*?)`', $match[1], $matches)) { $before = preg_quote($matches[1], '`'); $param = $matches[2]; $after = preg_quote($matches[3], '`'); } else { throw new \Exception("Invalid route parameter: $match[1].", 500); } $param_pattern = val($param, $this->conditions, val($param, self::$globalConditions, '[^/]+?')); $result = "(?<$param>$before{$param_pattern}$after)"; return $result; }, $pattern); $result = '`^'.$result.'$`i'; return $result; }
php
{ "resource": "" }
q259615
MySqlDb.query
test
public function query($sql, $type = Db::QUERY_READ, $options = []) { $mode = val(Db::OPTION_MODE, $options, $this->mode); if ($mode & Db::MODE_ECHO) { echo trim($sql, "\n;").";\n\n"; } if ($mode & Db::MODE_SQL) { return $sql; } $result = null; if ($mode & Db::MODE_EXEC) { $result = $this->pdo()->query($sql); if ($type == Db::QUERY_READ) { $result->setFetchMode(PDO::FETCH_ASSOC); $result = $result->fetchAll(); $this->rowCount = count($result); } elseif (is_object($result) && method_exists($result, 'rowCount')) { $this->rowCount = $result->rowCount(); $result = $this->rowCount; } } elseif ($mode & Db::MODE_PDO) { /* @var \PDOStatement $result */ $result = $this->pdo()->prepare($sql); } return $result; }
php
{ "resource": "" }
q259616
MySqlDb.buildSelect
test
public function buildSelect($table, array $where, array $options = []) { $sql = ''; // Build the select clause. if (isset($options['columns'])) { $columns = array(); foreach ($options['columns'] as $value) { $columns[] = $this->backtick($value); } $sql .= 'select '.implode(', ', $columns); } else { $sql .= "select *"; } // Build the from clause. if (val('escapeTable', $options, true)) { $sql .= "\nfrom ".$this->backtick($this->px.$table); } else { $sql .= "\nfrom $table"; } // Build the where clause. $whereString = $this->buildWhere($where, Db::OP_AND); if ($whereString) { $sql .= "\nwhere ".$whereString; } // Build the order. if (isset($options['order'])) { $order = array_quick($options['order'], Db::ORDER_ASC); $orders = array(); foreach ($order as $key => $value) { switch ($value) { case Db::ORDER_ASC: case Db::ORDER_DESC: $orders[] = $this->backtick($key)." $value"; break; default: trigger_error("Invalid sort direction '$value' for column '$key'.", E_USER_WARNING); } } $sql .= "\norder by ".implode(', ', $orders); } // Build the limit, offset. $limit = 10; if (isset($options['limit'])) { $limit = (int)$options['limit']; $sql .= "\nlimit $limit"; } if (isset($options['offset'])) { $sql .= ' offset '.((int)$options['offset']); } elseif (isset($options['page'])) { $offset = $limit * ($options['page'] - 1); $sql .= ' offset '.$offset; } return $sql; }
php
{ "resource": "" }
q259617
MySqlDb.bracketList
test
public function bracketList($row, $quote = "'") { switch ($quote) { case "'": $row = array_map([$this->pdo(), 'quote'], $row); $quote = ''; break; case '`': $row = array_map([$this, 'backtick'], $row); $quote = ''; break; } return "($quote".implode("$quote, $quote", $row)."$quote)"; }
php
{ "resource": "" }
q259618
MySqlDb.buildInsert
test
protected function buildInsert($tablename, array $row, $quotevals = true, $options = []) { if (val(Db::OPTION_UPSERT, $options)) { return $this->buildUpsert($tablename, $row, $quotevals, $options); } elseif (val(Db::OPTION_IGNORE, $options)) { $sql = 'insert ignore '; } elseif (val(Db::OPTION_REPLACE, $options)) { $sql = 'replace '; } else { $sql = 'insert '; } $sql .= $this->backtick($this->px.$tablename); // Add the list of values. $sql .= "\n".$this->bracketList(array_keys($row), '`'). "\nvalues".$this->bracketList($row, $quotevals ? "'" : ''); return $sql; }
php
{ "resource": "" }
q259619
MySqlDb.buildUpsert
test
protected function buildUpsert($tablename, array $row, $quotevals = true, $options = []) { // Build the initial insert statement first. unset($options[Db::OPTION_UPSERT]); $sql = $this->buildInsert($tablename, $row, $quotevals, $options); // Add the duplicate key stuff. $updates = []; foreach ($row as $key => $value) { $updates[] = $this->backtick($key).' = values('.$this->backtick($key).')'; } $sql .= "\non duplicate key update ".implode(', ', $updates); return $sql; }
php
{ "resource": "" }
q259620
MySqlDb.columnDefString
test
protected function columnDefString($name, array $def) { $result = $this->backtick($name).' '.$this->columnTypeString($def['type']); if (val('required', $def)) { $result .= ' not null'; } if (isset($def['default'])) { $result .= ' default '.$this->quoteVal($def['default']); } if (val('autoincrement', $def)) { $result .= ' auto_increment'; } return $result; }
php
{ "resource": "" }
q259621
MySqlDb.indexDefString
test
protected function indexDefString($tablename, array $def) { $indexName = $this->backtick($this->buildIndexName($tablename, $def)); switch (val('type', $def, Db::INDEX_IX)) { case Db::INDEX_IX: return "index $indexName ".$this->bracketList($def['columns'], '`'); case Db::INDEX_UNIQUE: return "unique $indexName ".$this->bracketList($def['columns'], '`'); case Db::INDEX_PK: return "primary key ".$this->bracketList($def['columns'], '`'); } return null; }
php
{ "resource": "" }
q259622
MySqlDb.getColumnOrders
test
protected function getColumnOrders($cdefs) { $orders = array_flip(array_keys($cdefs)); $prev = ' first'; foreach ($orders as $cname => &$value) { $value = $prev; $prev = ' after '.$this->backtick($cname); } return $orders; }
php
{ "resource": "" }
q259623
Porter.getFormatsFromDb
test
protected function getFormatsFromDb($db) { $tables = $db->tables(true); $formats = $this->fixFormats($tables); return $formats; }
php
{ "resource": "" }
q259624
Porter.translateRow
test
protected function translateRow($row, $format) { // Apply the row filter. if (isset($format['rowfilter'])) { call_user_func_array($format['rowfilter'], array(&$row)); } $result = array(); foreach ($format['columns'] as $key => $cdef) { if (array_key_exists($cdef['sourcecolumn'], $row)) $value = $row[$cdef['sourcecolumn']]; else $value = $cdef['default']; if (isset($cdef['filter'])) { $value = call_user_func($cdef['filter'], $value, $key, $row); } $result[$cdef[0]] = $value; } return $result; }
php
{ "resource": "" }
q259625
PhpbbPassword.verify
test
public function verify($password, $hash) { if (strlen($hash) == 34) { return ($this->cryptPrivate($password, $hash) === $hash) ? true : false; } return (md5($password) === $hash) ? true : false; }
php
{ "resource": "" }
q259626
PhpbbPassword.encode64
test
protected function encode64($input, $count) { $itoa64 = PhpbbPassword::ITOA64; $output = ''; $i = 0; do { $value = ord($input[$i++]); $output .= $itoa64[$value & 0x3f]; if ($i < $count) { $value |= ord($input[$i]) << 8; } $output .= $itoa64[($value >> 6) & 0x3f]; if ($i++ >= $count) { break; } if ($i < $count) { $value |= ord($input[$i]) << 16; } $output .= $itoa64[($value >> 12) & 0x3f]; if ($i++ >= $count) { break; } $output .= $itoa64[($value >> 18) & 0x3f]; } while ($i < $count); return $output; }
php
{ "resource": "" }
q259627
Request.current
test
public static function current(Request $request = null) { if ($request !== null) { $bak = self::$current; self::$current = $request; return $bak; } return self::$current; }
php
{ "resource": "" }
q259628
Request.defaultEnvironment
test
public static function defaultEnvironment($key = null, $merge = false) { if (self::$defaultEnv === null) { self::$defaultEnv = array( 'REQUEST_METHOD' => 'GET', 'X_REWRITE' => true, 'SCRIPT_NAME' => '', 'PATH_INFO' => '/', 'EXT' => '', 'QUERY' => [], 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => 80, 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8', 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'HTTP_USER_AGENT' => 'Garden/0.1 (Howdy stranger)', 'REMOTE_ADDR' => '127.0.0.1', 'URL_SCHEME' => 'http', 'INPUT' => [], ); } if ($key === null) { return self::$defaultEnv; } elseif (is_array($key)) { if ($merge) { self::$defaultEnv = array_merge(self::$defaultEnv, $key); } else { self::$defaultEnv = $key; } return self::$defaultEnv; } elseif (is_string($key)) { return val($key, self::$defaultEnv); } else { throw new \InvalidArgumentException("Argument #1 for Request::globalEnvironment() is invalid.", 422); } }
php
{ "resource": "" }
q259629
Request.globalEnvironment
test
public static function globalEnvironment($key = null) { // Check to parse the environment. if ($key === true || !isset(self::$globalEnv)) { self::$globalEnv = static::parseServerVariables(); } if ($key) { return val($key, self::$globalEnv); } return self::$globalEnv; }
php
{ "resource": "" }
q259630
Request.parseServerVariables
test
protected static function parseServerVariables() { $env = static::defaultEnvironment(); // REQUEST_METHOD. $env['REQUEST_METHOD'] = val('REQUEST_METHOD', $_SERVER) ?: 'CONSOLE'; // SCRIPT_NAME: This is the root directory of the application. $script_name = rtrim_substr($_SERVER['SCRIPT_NAME'], 'index.php'); $env['SCRIPT_NAME'] = rtrim($script_name, '/'); // PATH_INFO. $path = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''; // Strip the extension from the path. list($path, $ext) = static::splitPathExt($path); $env['PATH_INFO'] = '/' . ltrim($path, '/'); $env['EXT'] = $ext; // QUERY. $get = $_GET; $env['QUERY'] = $get; // SERVER_NAME. $host = array_select( ['HTTP_X_FORWARDED_HOST', 'HTTP_HOST', 'SERVER_NAME'], $_SERVER ); list($host) = explode(':', $host, 2); $env['SERVER_NAME'] = $host; // HTTP_* headers. $env = array_replace($env, static::extractHeaders($_SERVER)); // URL_SCHEME. $url_scheme = 'http'; // Web server-originated SSL. if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') { $url_scheme = 'https'; } $url_scheme = array_select([ 'HTTP_X_ORIGINALLY_FORWARDED_PROTO', // varnish modifies the scheme 'HTTP_X_FORWARDED_PROTO' // load balancer-originated (and terminated) ssl ], $_SERVER, $url_scheme); $env['URL_SCHEME'] = $url_scheme; // SERVER_PORT. $server_port = (int)val('SERVER_PORT', $_SERVER, $url_scheme === 'https' ? 443 :80); $env['SERVER_PORT'] = $server_port; // INPUT: The entire input. // Input stream (readable one time only; not available for multipart/form-data requests) switch (val('CONTENT_TYPE', $env)) { case 'application/json': $input_raw = @file_get_contents('php://input'); $input = @json_decode($input_raw, true); break; default: $input = $_POST; $input_raw = null; break; } $env['INPUT'] = $input; $env['INPUT_RAW'] = $input_raw; // IP Address. // Load balancers set a different ip address. $ip = array_select( ['HTTP_X_ORIGINALLY_FORWARDED_FOR', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR'], $_SERVER, '127.0.0.1' ); $env['REMOTE_ADDR'] = force_ipv4($ip); return $env; }
php
{ "resource": "" }
q259631
Request.overrideEnvironment
test
protected static function overrideEnvironment(&$env) { $get =& $env['QUERY']; // Check to override the method. if (isset($get['x-method'])) { $method = strtoupper($get['x-method']); $getMethods = array(self::METHOD_GET, self::METHOD_HEAD, self::METHOD_OPTIONS); // Don't allow get style methods to be overridden to post style methods. if (!in_array($env['REQUEST_METHOD'], $getMethods) || in_array($method, $getMethods)) { static::replaceEnv($env, 'REQUEST_METHOD', $method); } else { $env['X_METHOD_BLOCKED'] = true; } unset($get['x-method']); } // Force the path and extension to lowercase. $path = strtolower($env['PATH_INFO']); if ($path !== $env['PATH_INFO']) { static::replaceEnv($env, 'PATH_INFO', $path); } $ext = strtolower($env['EXT']); if ($ext !== $env['EXT']) { static::replaceEnv($env, 'EXT', $ext); } // Check to override the accepts header. if (isset(self::$knownExtensions[$ext]) && $env['HTTP_ACCEPT'] !== 'application/internal') { static::replaceEnv($env, 'HTTP_ACCEPT', self::$knownExtensions[$ext]); } }
php
{ "resource": "" }
q259632
Request.getEnv
test
public function getEnv($key = null, $default = null) { if ($key === null) { return $this->env; } return val(strtoupper($key), $this->env, $default); }
php
{ "resource": "" }
q259633
Request.setEnv
test
public function setEnv($key, $value = null) { if (is_string($key)) { $this->env[strtoupper($key)] = $value; } elseif (is_array($key)) { $this->env = $key; } else { throw new \InvalidArgumentException("Argument 1 must be either a string or array.", 422); } return $this; }
php
{ "resource": "" }
q259634
Request.getHeaders
test
public function getHeaders() { $result = []; foreach ($this->env as $key => $value) { if (stripos($key, 'HTTP_') === 0 && !str_ends($key, '_RAW')) { $headerKey = static::normalizeHeaderName(substr($key, 5)); $result[$headerKey][] = $value; } } return $result; }
php
{ "resource": "" }
q259635
Request.getHostAndPort
test
public function getHostAndPort() { $host = $this->getHost(); $port = $this->getPort(); // Only append the port if it is non-standard. if (($port == 80 && $this->getScheme() === 'http') || ($port == 443 && $this->getScheme() === 'https')) { $port = ''; } else { $port = ':'.$port; } return $host.$port; }
php
{ "resource": "" }
q259636
Request.setExt
test
public function setExt($ext) { if ($ext) { $this->env['EXT'] = '.'.ltrim($ext, '.'); } else { $this->env['EXT'] = ''; } return $this; }
php
{ "resource": "" }
q259637
Request.setPathExt
test
public function setPathExt($path) { // Strip the extension from the path. if (substr($path, -1) !== '/' && ($pos = strrpos($path, '.')) !== false) { $ext = substr($path, $pos); $path = substr($path, 0, $pos); $this->env['EXT'] = $ext; } else { $this->env['EXT'] = ''; } $this->env['PATH_INFO'] = $path; return $this; }
php
{ "resource": "" }
q259638
Request.setFullPath
test
public function setFullPath($fullPath) { $fullPath = '/'.ltrim($fullPath, '/'); // Try stripping the root out of the path first. $root = (string)$this->getRoot(); if ($root && strpos($fullPath, $root) === 0 && (strlen($fullPath) === strlen($root) || substr($fullPath, strlen($root), 1) === '/')) { $this->setPathExt(substr($fullPath, strlen($root))); } else { $this->setRoot(''); $this->setPathExt($fullPath); } return $this; }
php
{ "resource": "" }
q259639
Request.setPort
test
public function setPort($port) { $this->env['SERVER_PORT'] = $port; // Override the scheme for standard ports. if ($port === 80) { $this->setScheme('http'); } elseif ($port === 443) { $this->setScheme('https'); } return $this; }
php
{ "resource": "" }
q259640
Request.getQuery
test
public function getQuery($key = null, $default = null) { if ($key === null) { return $this->env['QUERY']; } return isset($this->env['QUERY'][$key]) ? $this->env['QUERY'][$key] : $default; }
php
{ "resource": "" }
q259641
Request.setQuery
test
public function setQuery($key, $value = null) { if (is_string($key)) { $this->env['QUERY'][$key] = $value; } elseif (is_array($key)) { $this->env['QUERY'] = $key; } else { throw new \InvalidArgumentException("Argument 1 must be a string or array.", 422); } return $this; }
php
{ "resource": "" }
q259642
Request.getInput
test
public function getInput($key = null, $default = null) { if ($key === null) { return $this->env['INPUT']; } return isset($this->env['INPUT'][$key]) ? $this->env['INPUT'][$key] : $default; }
php
{ "resource": "" }
q259643
Request.getData
test
public function getData($key = null, $default = null) { if ($this->hasInput()) { return $this->getInput($key, $default); } else { return $this->getQuery($key, $default); } }
php
{ "resource": "" }
q259644
Request.setData
test
public function setData($key, $value = null) { if ($this->hasInput()) { $this->setInput($key, $value); } else { $this->setQuery($key, $value); } return $this; }
php
{ "resource": "" }
q259645
Request.getUrl
test
public function getUrl() { $query = $this->getQuery(); return $this->getScheme(). '://'. $this->getHostAndPort(). $this->getRoot(). $this->getPath(). (!empty($query) ? '?'.http_build_query($query) : ''); }
php
{ "resource": "" }
q259646
Request.setUrl
test
public function setUrl($url) { // Parse the url and set the individual components. $url_parts = parse_url($url); if (isset($url_parts['scheme'])) { $this->setScheme($url_parts['scheme']); } if (isset($url_parts['host'])) { $this->setHost($url_parts['host']); } if (isset($url_parts['port'])) { $this->setPort($url_parts['port']); } elseif (isset($url_parts['scheme'])) { $this->setPort($this->getScheme() === 'https' ? 443 : 80); } if (isset($url_parts['path'])) { $this->setFullPath($url_parts['path']); } if (isset($url_parts['query'])) { parse_str($url_parts['query'], $query); if (is_array($query)) { $this->setQuery($query); } } return $this; }
php
{ "resource": "" }
q259647
Request.makeUrl
test
public function makeUrl($path, $domain = false) { if (!$path) { $path = $this->getPath(); } // Check for a specific scheme. $scheme = $this->getScheme(); if ($domain === 'http' || $domain === 'https') { $scheme = $domain; $domain = true; } if ($domain === true) { $prefix = $scheme.'://'.$this->getHostAndPort().$this->getRoot(); } elseif ($domain === false) { $prefix = $this->getRoot(); } elseif ($domain === '//') { $prefix = '//'.$this->getHostAndPort().$this->getRoot(); } else { $prefix = ''; } return $prefix.'/'.ltrim($path, '/'); }
php
{ "resource": "" }
q259648
Request.splitPathExt
test
protected static function splitPathExt($path) { if (substr($path, -1) !== '/' && ($pos = strrpos($path, '.')) !== false) { $ext = substr($path, $pos); $path = substr($path, 0, $pos); return [$path, $ext]; } else { return [$path, '']; } }
php
{ "resource": "" }
q259649
DbDef.reset
test
public function reset() { $this->table = null; $this->columns = []; $this->indexes = []; $this->options = []; return $this; }
php
{ "resource": "" }
q259650
DbDef.column
test
public function column($name, $type, $nullDefault = false, $index = null) { $this->columns[$name] = $this->columnDef($type, $nullDefault); $index = (array)$index; foreach ($index as $typeStr) { if (strpos($typeStr, '.') === false) { $indexType = $typeStr; $suffix = ''; } else { list($indexType, $suffix) = explode('.', $typeStr); } $this->index($name, $indexType, $suffix); } return $this; }
php
{ "resource": "" }
q259651
DbDef.columnDef
test
protected function columnDef($type, $nullDefault = false) { $column = ['type' => $type]; if ($nullDefault === null || $nullDefault == true) { $column['required'] = false; } if ($nullDefault === false) { $column['required'] = true; } else { $column['required'] = true; $column['default'] = $nullDefault; } return $column; }
php
{ "resource": "" }
q259652
DbDef.primaryKey
test
public function primaryKey($name, $type = 'int') { $column = $this->columnDef($type, false); $column['autoincrement'] = true; $column['primary'] = true; $this->columns[$name] = $column; // Add the pk index. $this->index($name, Db::INDEX_PK); return $this; }
php
{ "resource": "" }
q259653
DbDef.exec
test
public function exec($reset = true) { $this->db->setTableDef( $this->table, $this->jsonSerialize(), $this->options ); if ($reset) { $this->reset(); } return $this; }
php
{ "resource": "" }
q259654
DbDef.table
test
public function table($name = null) { if ($name !== null) { $this->table = $name; return $this; } return $this->table; }
php
{ "resource": "" }
q259655
DbDef.index
test
public function index($columns, $type, $suffix = '') { $type = strtolower($type); $columns = (array)$columns; $suffix = strtolower($suffix); // Look for a current index row. $currentIndex = null; foreach ($this->indexes as $i => $index) { if ($type !== $index['type']) { continue; } $indexSuffix = val('suffix', $index, ''); if ($type === Db::INDEX_PK || ($type === Db::INDEX_UNIQUE && $suffix == $indexSuffix) || ($type === Db::INDEX_IX && $suffix && $suffix == $indexSuffix) || ($type === Db::INDEX_IX && !$suffix && array_diff($index['columns'], $columns) == []) ) { $currentIndex =& $this->indexes[$i]; break; } } if ($currentIndex) { $currentIndex['columns'] = array_unique(array_merge($currentIndex['columns'], $columns)); } else { $indexDef = [ 'type' => $type, 'columns' => $columns, 'suffix' => $suffix ]; if ($type === Db::INDEX_PK) { $this->indexes[Db::INDEX_PK] = $indexDef; } else { $this->indexes[] = $indexDef; } } return $this; }
php
{ "resource": "" }
q259656
RobotsTxtController.index
test
public function index() { /** * Note that the config is originally loaded from this package's config file, but a config file can be published to the Laravel config dir. * If so, due to the nature of the config setup and Larvel's config merge, the original config gets completely overwritten. */ $envs = config('robots-txt.paths'); $robots = ''; $env = config('app.env'); // if no env is set, or one of the set envs cannot be matched against the current env, use the default if($envs === null || !array_key_exists($env, $envs)) { $robots = $this->defaultRobot(); } else { // for each user agent, get the user agent name and the paths for the agent, appending them to the result string $agents = $envs[$env]; foreach($agents as $name => $paths) { $robot = 'User-agent: ' . $name . PHP_EOL; foreach ($paths as $path) { $robot .= 'Disallow: ' . $path . PHP_EOL; } // append this user agent and paths to the final output $robots .= $robot . PHP_EOL; } } // output the entire robots.txt return \Response::make($robots, 200, array('content-type' => 'text/plain')); }
php
{ "resource": "" }
q259657
Model.all
test
public function all($offset = 0, $pageSize = 10, $sort = 'time-descending') { $this->checkApiMethodIsSupported(__FUNCTION__); $pagingOptions = array( 'offset' => $offset, 'pageSize' => $pageSize, 'sort' => $sort, ); // Ressource Path with options $uri = $this->resourcePath.'?'.http_build_query($pagingOptions); $response = $this->request->get( $uri // No attributes ); return $response->json(); }
php
{ "resource": "" }
q259658
Model.find
test
public function find($resourceId) { $this->checkApiMethodIsSupported(__FUNCTION__); return $this->request ->get($this->resourcePath.'/'.(int)$resourceId) ->json(); }
php
{ "resource": "" }
q259659
Model.validate
test
public function validate() { $this->checkApiMethodIsSupported(__FUNCTION__); $this->checkJudoId(); $this->checkRequiredAttributes($this->attributeValues); $validateResourcePath = $this->resourcePath.'/validate'; $response = $this->request->post( $validateResourcePath, $this->attributeValues ); return $response->json(); }
php
{ "resource": "" }
q259660
Model.getAttributeValue
test
public function getAttributeValue($attribute) { if (!array_key_exists($attribute, $this->attributeValues)) { return null; } return $this->attributeValues[$attribute]; }
php
{ "resource": "" }
q259661
Model.setAttributeValues
test
public function setAttributeValues($values) { foreach ($values as $key => $value) { // Does the attribute exist? if (!array_key_exists($key, $this->attributes)) { continue; } // Coerce to the right type if required $targetDataType = $this->attributes[$key]; $this->attributeValues[$key] = DataType::coerce( $targetDataType, $value ); } }
php
{ "resource": "" }
q259662
Model.checkApiMethodIsSupported
test
protected function checkApiMethodIsSupported($methodName) { if (empty($this->validApiMethods) || !in_array($methodName, $this->validApiMethods) ) { throw new ValidationError('API method is not supported'); } }
php
{ "resource": "" }
q259663
Model.checkRequiredAttributes
test
protected function checkRequiredAttributes($data) { $existingAttributes = array_keys($data); $errors = array(); foreach ($this->requiredAttributes as $requiredAttribute) { if (!in_array($requiredAttribute, $existingAttributes) || $data[$requiredAttribute] === '' || $data[$requiredAttribute] === null ) { $errors[] = $requiredAttribute.' is missing or empty'; } } if (count($errors) > 0) { throw new ValidationError('Missing required fields', $errors); } return true; }
php
{ "resource": "" }
q259664
Model.checkJudoId
test
protected function checkJudoId() { $judoId = $this->getAttributeValue(static::JUDO_ID); if (!empty($judoId)) { return; } $configuration = $this->request->getConfiguration(); $this->attributeValues[static::JUDO_ID] = $configuration->get(static::JUDO_ID); }
php
{ "resource": "" }
q259665
ApiException.getSummary
test
public function getSummary() { return sprintf( static::MESSAGE, $this->getHttpStatusCode(), $this->getCode(), $this->getCategory(), $this->getMessage(), $this->getDetailsSummary() ); }
php
{ "resource": "" }
q259666
Judopay.getModel
test
public function getModel($modelName) { // If the model is already defined in the container, just return it if (isset($this->container[$modelName])) { return $this->get($modelName); } // Set up the model in the DI container $request = $this->get('request'); $this->container[$modelName] = $this->container->factory( function () use ($modelName, $request) { $modelClassName = '\Judopay\Model\\'.ucfirst($modelName); return new $modelClassName($request); } ); return $this->get($modelName); }
php
{ "resource": "" }
q259667
ValidationError.getSummary
test
public function getSummary() { // As a sensible default, use the class name $message = get_class($this); // Append model errors summary if applicable $modelErrorSummary = $this->getModelErrorSummary(); if (!empty($modelErrorSummary)) { $message .= ' ('.$modelErrorSummary.')'; } return $message; }
php
{ "resource": "" }
q259668
Request.get
test
public function get($resourcePath) { $endpointUrl = $this->configuration->get('endpointUrl'); $request = $this->client->createRequest( 'GET', $endpointUrl.'/'.$resourcePath, [ 'json' => null ] ); return $this->send($request); }
php
{ "resource": "" }
q259669
Request.post
test
public function post($resourcePath, $data) { $endpointUrl = $this->configuration->get('endpointUrl'); $request = $this->client->createRequest( 'POST', $endpointUrl.'/'.$resourcePath, [ 'json' => $data ] ); return $this->send($request); }
php
{ "resource": "" }
q259670
CardPaymentSpec.it_coerces_attributes_into_the_correct_data_type
test
public function it_coerces_attributes_into_the_correct_data_type() { $input = array( 'yourPaymentMetaData' => (object)array('val' => 'an unexpected string'), 'judoId' => 'judo123', 'amount' => '123.23', ); $expectedOutput = array( 'yourPaymentMetaData' => (object)array('val' => 'an unexpected string'), 'judoId' => 'judo123', 'amount' => 123.23, ); /** @var CardPayment|CardPaymentSpec $this */ $this->setAttributeValues($input); $this->getAttributeValues()->shouldBeLike($expectedOutput); }
php
{ "resource": "" }
q259671
TransmittedField.validate
test
protected function validate() { $errors = array(); foreach ($this->requiredAttributes as $requiredAttribute) { if (!ArrayHelper::keyExists($this->data, $requiredAttribute)) { $errors[] = $requiredAttribute.' is missing or empty'; } } if (count($errors) > 0) { throw new ValidationError(get_called_class().' object misses required fields', $errors); } return true; }
php
{ "resource": "" }
q259672
ArrayHelper.keyExists
test
public static function keyExists(array $array, $key) { if (($pos = strrpos($key, '.')) !== false && ($subKey = substr($key, 0, $pos)) !== false && static::keyExists($array, $subKey) && static::keyExists($array[$subKey], substr($key, $pos + 1)) ) { return true; } return (isset($array[$key]) || array_key_exists($key, $array)); }
php
{ "resource": "" }
q259673
Toastr.render
test
public function render() { $notifications = $this->session->get('toastr::notifications'); if(!$notifications) $notifications = array(); $output = '<script type="text/javascript">'; $lastConfig = []; foreach($notifications as $notification) { $config = $this->config->get('toastr::options'); if(count($notification['options']) > 0) { // Merge user supplied options with default options $config = array_merge($config, $notification['options']); } // Config persists between toasts if($config != $lastConfig) { $output .= 'toastr.options = ' . json_encode($config) . ';'; $lastConfig = $config; } // Toastr output $output .= 'toastr.' . $notification['type'] . "('" . str_replace("'", "\\'", htmlentities($notification['message'])) . "'" . (isset($notification['title']) ? ", '" . str_replace("'", "\\'", htmlentities($notification['title'])) . "'" : null) . ');'; } $output .= '</script>'; return $output; }
php
{ "resource": "" }
q259674
Toastr.add
test
public function add($type, $message, $title = null,$options = array()) { $allowedTypes = array('error', 'info', 'success', 'warning'); if(!in_array($type, $allowedTypes)) return false; $this->notifications[] = array( 'type' => $type, 'title' => $title, 'message' => $message, 'options' => $options ); $this->session->flash('toastr::notifications', $this->notifications); }
php
{ "resource": "" }
q259675
Job.link
test
public function link($origin, $destination) { $delivery = new Delivery($origin, $destination); $this->deliveries[] = $delivery; return $delivery; }
php
{ "resource": "" }
q259676
JobToJson.convert
test
public static function convert($job) { $result = array( 'job' => array() ); if ($job->getTransportType() !== null) { $result['job']['transport_type'] = $job->getTransportType(); } if ($job->getAssignmentCode() !== null) { $result['job']['assignment_code'] = $job->getAssignmentCode(); } if (count($job->getPickups()) === 1 && $job->getPickups()[0]->getPickupAt() !== null) { $result['job']['pickup_at'] = $job->getPickups()[0]->getPickupAt()->format(JsonToJob::$STUART_DATE_FORMAT); } if (count($job->getDropoffs()) === 1 && $job->getDropoffs()[0]->getDropoffAt() !== null) { $result['job']['dropoff_at'] = $job->getDropoffs()[0]->getDropoffAt()->format(JsonToJob::$STUART_DATE_FORMAT); } $pickups = array(); foreach ($job->getPickups() as $pickup) { $pickups[] = JobToJson::locationAsArray($pickup); } $dropOffs = array(); foreach ($job->getDropOffs() as $dropOff) { $dropOffs[] = array_merge(JobToJson::locationAsArray($dropOff), array( 'package_type' => $dropOff->getPackageType(), 'package_description' => $dropOff->getPackageDescription(), 'client_reference' => $dropOff->getClientReference() )); } $result['job']['pickups'] = $pickups; $result['job']['dropoffs'] = $dropOffs; return json_encode($result); }
php
{ "resource": "" }
q259677
JsonToJob.convert
test
public static function convert($json) { $body = json_decode($json); $job = new Job(); $job->setId($body->id); $job->setTransportType(isset($body->transport_type) ? $body->transport_type : null); $job->setAssignmentCode(isset($body->assignment_code) ? $body->assignment_code : null); $job->setStatus($body->status); $job->setDistance($body->distance); $job->setDuration($body->duration); foreach ($body->deliveries as $delivery) { $job ->link( $job->addPickup(self::fullTextAddress($delivery->pickup->address)) ->setPickupAt(\DateTime::createFromFormat(self::$STUART_DATE_FORMAT, $body->pickup_at)) ->setComment($delivery->pickup->comment) ->setContactCompany($delivery->pickup->contact->company_name) ->setContactFirstName($delivery->pickup->contact->firstname) ->setContactLastName($delivery->pickup->contact->lastname) ->setContactPhone($delivery->pickup->contact->phone) ->setContactEmail($delivery->pickup->contact->email), $job->addDropOff(self::fullTextAddress($delivery->dropoff->address)) ->setDropoffAt(\DateTime::createFromFormat(self::$STUART_DATE_FORMAT, $body->dropoff_at)) ->setPackageType($delivery->package_type) ->setPackageDescription($delivery->package_description) ->setClientReference($delivery->client_reference) ->setComment($delivery->dropoff->comment) ->setContactCompany($delivery->dropoff->contact->company_name) ->setContactFirstName($delivery->dropoff->contact->firstname) ->setContactLastName($delivery->dropoff->contact->lastname) ->setContactPhone($delivery->dropoff->contact->phone) ->setContactEmail($delivery->dropoff->contact->email) ) ->setId($delivery->id) ->setStatus($delivery->status) ->setTrackingUrl($delivery->tracking_url); } $pricing = new Pricing(); if (isset($body->pricing)) { if (isset($body->pricing->price_tax_included)) { $pricing->setPriceTaxIncluded($body->pricing->price_tax_included); } if (isset($body->pricing->price_tax_excluded)) { $pricing->setPriceTaxExcluded($body->pricing->price_tax_excluded); } } $job->setPricing($pricing); return $job; }
php
{ "resource": "" }
q259678
BasicServer.free
test
protected function free(\Throwable $exception = null) { $this->poll->free(); while (!$this->queue->isEmpty()) { /** @var \Icicle\Awaitable\Delayed $delayed */ $delayed = $this->queue->shift(); $delayed->reject($exception ?: new ClosedException('The server was unexpectedly closed.')); } }
php
{ "resource": "" }
q259679
BasicDatagram.free
test
protected function free(Throwable $exception = null) { $this->poll->free(); if (null !== $this->await) { $this->await->free(); } while (!$this->readQueue->isEmpty()) { /** @var \Icicle\Awaitable\Delayed $delayed */ $delayed = $this->readQueue->shift(); $delayed->resolve(); } while (!$this->writeQueue->isEmpty()) { /** @var \Icicle\Awaitable\Delayed $delayed */ list( , , , $delayed) = $this->writeQueue->shift(); $delayed->reject( $exception = $exception ?: new ClosedException('The datagram was unexpectedly closed.') ); } }
php
{ "resource": "" }
q259680
DashboardChart.create
test
public static function create($title = null, $x_label = null, $y_label = null, $chartData = array ()) { self::$instances++; return new DashboardChart($title, $x_label, $y_label, $chartData); }
php
{ "resource": "" }
q259681
DashboardHasManyRelationEditor.handleItem
test
public function handleItem(SS_HTTPRequest $r) { if($r->param('ID') == "new") { $item = Object::create($this->relationClass); } else { $item = DataList::create($this->relationClass)->byID((int) $r->param('ID')); } if($item) { $handler = DashboardHasManyRelationEditor_ItemRequest::create($this->controller->getDashboard(), $this->controller, $this, $item); return $handler->handleRequest($r, DataModel::inst()); } return $this->httpError(404); }
php
{ "resource": "" }
q259682
DashboardHasManyRelationEditor.sort
test
public function sort(SS_HTTPRequest $r) { if($items = $r->getVar('item')) { foreach($items as $position => $id) { if($item = DataList::create($this->relationClass)->byID((int) $id)) { $item->SortOrder = $position; $item->write(); } } return new SS_HTTPResponse("OK"); } }
php
{ "resource": "" }
q259683
DashboardHasManyRelationEditor_ItemRequest.Link
test
public function Link($action = null) { return Controller::join_links($this->editor->Link(),"item",$this->item->ID ? $this->item->ID : "new",$action); }
php
{ "resource": "" }
q259684
DashboardHasManyRelationEditor_ItemRequest.DetailForm
test
public function DetailForm() { $form = Form::create( $this, "DetailForm", Injector::inst()->get($this->editor->relationClass)->getConfiguration(), FieldList::create( FormAction::create('saveDetail',_t('Dashboard.SAVE','Save')) ->setUseButtonTag(true) ->addExtraClass('ss-ui-action-constructive small'), FormAction::create('cancel',_t('Dashboard.CANCEL','Cancel')) ->setUseButtonTag(true) ->addExtraClass('small') ) ); $form->setHTMLID("Form_DetailForm_".$this->panel->ID."_".$this->item->ID); $form->loadDataFrom($this->item); $form->addExtraClass('dashboard-has-many-editor-detail-form-form'); return $form; }
php
{ "resource": "" }
q259685
DashboardHasManyRelationEditor_ItemRequest.saveDetail
test
public function saveDetail($data, $form) { $item = $this->item; if(!$item->exists()) { $item->DashboardPanelID = $this->panel->ID; $sort = DataList::create($item->class)->max("SortOrder"); $item->SortOrder = $sort+1; $item->write(); } $form->saveInto($item); $item->write(); return new SS_HTTPResponse("OK"); }
php
{ "resource": "" }
q259686
DashboardRSSFeedPanel.RSSItems
test
public function RSSItems() { if(!$this->FeedURL) return false; $doc = new DOMDocument(); @$doc->load($this->FeedURL); $items = $doc->getElementsByTagName('item'); $feeds = array (); foreach ($items as $node) { $itemRSS = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue ); $feeds[] = $itemRSS; } $output = ArrayList::create(array()); $count = 0; foreach($feeds as $item) { if($count >= $this->Count) break; // Cast the Date $date = new Date('Date'); $date->setValue($item['date']); // Cast the Title $title = new Text('Title'); $title->setValue($item['title']); $output->push(new ArrayData(array( 'Title' => $title, 'Date' => $date->Format($this->DateFormat), 'Link' => $item['link'] ))); $count++; } return $output; }
php
{ "resource": "" }
q259687
DashboardRecentEditsPanel.RecentEdits
test
public function RecentEdits() { $records = SiteTree::get()->sort("LastEdited DESC")->limit($this->Count); $set = ArrayList::create(array()); foreach($records as $r) { $set->push(ArrayData::create(array( 'EditLink' => Injector::inst()->get("CMSPagesController")->Link("edit/show/{$r->ID}"), 'Title' => $r->Title ))); } return $set; }
php
{ "resource": "" }
q259688
DashboardMember.onAfterWrite
test
public function onAfterWrite() { if(!$this->owner->HasConfiguredDashboard && !$this->owner->DashboardPanels()->exists()) { foreach(SiteConfig::current_site_config()->DashboardPanels() as $p) { $clone = $p->duplicate(); $clone->SiteConfigID = 0; $clone->MemberID = $this->owner->ID; $clone->write(); } DB::query("UPDATE \"Member\" SET \"HasConfiguredDashboard\" = 1 WHERE \"ID\" = {$this->owner->ID}"); $this->owner->flushCache(); } }
php
{ "resource": "" }
q259689
DashboardGridFieldPanel.getTemplate
test
protected function getTemplate() { $templateName = get_class($this) . '_' . $this->SubjectPage()->ClassName . '_' . $this->GridFieldName; if(SS_TemplateLoader::instance()->findTemplates($templateName)) { return $templateName; } return parent::getTemplate(); }
php
{ "resource": "" }
q259690
DashboardGridFieldPanel.ViewAllLink
test
public function ViewAllLink() { if($grid = $this->getGrid()) { return Controller::join_links( Injector::inst()->get("CMSMain")->Link("edit"), "show", $this->SubjectPageID )."#Root_".$this->getTabForGrid(); } }
php
{ "resource": "" }
q259691
DashboardGridFieldPanel.CreateModelLink
test
public function CreateModelLink() { if($grid = $this->getGrid()) { return Controller::join_links( Injector::inst()->get("CMSMain")->Link("edit"), "EditForm", "field", $this->GridFieldName, "item", "new", "?ID={$this->SubjectPageID}" ); } }
php
{ "resource": "" }
q259692
DashboardGridFieldPanel.getGridFieldsFor
test
public function getGridFieldsFor(SiteTree $page) { $grids = array (); if(!$page || !$page->exists()) return $grids; foreach($page->getCMSFields()->dataFields() as $field) { if($field instanceof GridField) { $grids[$field->getName()] = $field->Title(); } } if(empty($grids)) { return array( '' => _t('Dashboard.NOGRIDFIELDS','There are no GridFields defined for that page.') ); } return $grids; }
php
{ "resource": "" }
q259693
DashboardGridFieldPanel.getGrid
test
protected function getGrid() { if($this->SubjectPage()->exists() && $this->GridFieldName) { if($grid = $this->SubjectPage()->getCMSFields()->dataFieldByName($this->GridFieldName)) { $grid->setForm($this->Form()); return $grid; } } }
php
{ "resource": "" }
q259694
DashboardGridFieldPanel.getTabForGrid
test
protected function getTabForGrid() { if(!$this->SubjectPage()->exists() || !$this->GridFieldName) return false; $fields = $this->SubjectPage()->getCMSFields(); if($fields->hasTabSet()) { foreach($fields->fieldByName("Root")->Tabs() as $tab) { if($tab->fieldByName($this->GridFieldName)) { return $tab->getName(); } } } return false; }
php
{ "resource": "" }
q259695
DashboardGridFieldPanel.GridFieldItems
test
public function GridFieldItems() { if($grid = $this->getGrid()) { $list = $grid->getList() ->limit($this->Count) ->sort("LastEdited DESC"); $ret = ArrayList::create(array()); foreach($list as $record) { $record->EditLink = Controller::join_links( Injector::inst()->get("CMSMain")->Link("edit"), "EditForm", "field", $this->GridFieldName, "item", $record->ID, "edit", "?ID={$this->SubjectPageID}" ); $ret->push($record); } return $ret; } }
php
{ "resource": "" }
q259696
DashboardGridField_PanelRequest.gridsforpage
test
public function gridsforpage(SS_HTTPRequest $r) { $pageid = (int) $r->requestVar('pageid'); return Convert::array2json($this->panel->getGridFieldsFor(SiteTree::get()->byID($pageid))); }
php
{ "resource": "" }
q259697
gapi.requestAccountData
test
public function requestAccountData($start_index=1, $max_results=1000) { $get_variables = array( 'start-index' => $start_index, 'max-results' => $max_results, ); $url = new gapiRequest(gapi::account_data_url); $response = $url->get($get_variables, $this->auth_method->generateAuthHeader()); if (substr($response['code'], 0, 1) == '2') { return $this->accountObjectMapper($response['body']); } else { throw new Exception('GAPI: Failed to request account data. Error: "' . strip_tags($response['body']) . '"'); } }
php
{ "resource": "" }
q259698
gapi.cleanErrorResponse
test
private function cleanErrorResponse($error) { if (strpos($error, '<html') !== false) { $error = preg_replace('/<(style|title|script)[^>]*>[^<]*<\/(style|title|script)>/i', '', $error); return trim(preg_replace('/\s+/', ' ', strip_tags($error))); } else { $json = json_decode($error); return isset($json->error->message) ? strval($json->error->message) : $error; } }
php
{ "resource": "" }
q259699
gapi.processFilter
test
protected function processFilter($filter) { $valid_operators = '(!~|=~|==|!=|>|<|>=|<=|=@|!@)'; $filter = preg_replace('/\s\s+/', ' ', trim($filter)); //Clean duplicate whitespace $filter = str_replace(array(',', ';'), array('\,', '\;'), $filter); //Escape Google Analytics reserved characters $filter = preg_replace('/(&&\s*|\|\|\s*|^)([a-z0-9]+)(\s*' . $valid_operators . ')/i','$1ga:$2$3',$filter); //Prefix ga: to metrics and dimensions $filter = preg_replace('/[\'\"]/i', '', $filter); //Clear invalid quote characters $filter = preg_replace(array('/\s*&&\s*/','/\s*\|\|\s*/','/\s*' . $valid_operators . '\s*/'), array(';', ',', '$1'), $filter); //Clean up operators if (strlen($filter) > 0) { return urlencode($filter); } else { return false; } }
php
{ "resource": "" }