_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q6000 | JBDump.timestamp | train | public static function timestamp($timestamp = null)
{
if (!self::isDebug()) {
return false;
}
| php | {
"resource": ""
} |
q6001 | JBDump.locale | train | public static function locale()
{
if (!self::isDebug()) {
return false;
}
ob_start();
@system('locale -a');
$locale = explode(PHP_EOL, trim(ob_get_contents()));
ob_end_clean();
$result = array(
| php | {
"resource": ""
} |
q6002 | JBDump.timezone | train | public static function timezone()
{
if (!self::isDebug()) {
return false;
}
| php | {
"resource": ""
} |
q6003 | JBDump.print_r | train | public static function print_r($var, $varname = '...', $params = array())
{
if (!self::isDebug()) {
return false;
| php | {
"resource": ""
} |
q6004 | JBDump.phpArray | train | public static function phpArray($var, $varname = 'varName', $isReturn = false)
{
if (!self::isDebug()) {
return false;
}
$output = JBDump_array2php::toString($var, $varname);
if ($isReturn) {
return $output;
| php | {
"resource": ""
} |
q6005 | JBDump.var_dump | train | public static function var_dump($var, $varname = '...', $params = array())
{
if (!self::isDebug()) {
return false;
}
// var_dump the variable into a buffer and keep the output
ob_start();
var_dump($var);
$output = ob_get_clean();
$_this = self::i();
// neaten the newlines | php | {
"resource": ""
} |
q6006 | JBDump.trace | train | public static function trace($trace = null, $addObject = false)
{
if (!self::isDebug()) {
return false;
}
$_this = self::i();
| php | {
"resource": ""
} |
q6007 | JBDump.extInfo | train | public static function extInfo($extensionName)
{
$result = self::_getExtension($extensionName);
if ($result) {
$extensionName = $result['name'];
}
| php | {
"resource": ""
} |
q6008 | JBDump.pathInfo | train | public static function pathInfo($file)
{
$result = self::_pathInfo($file);
return | php | {
"resource": ""
} |
q6009 | JBDump.funcInfo | train | public static function funcInfo($functionName)
{
$result = self::_getFunction($functionName);
if ($result) {
$functionName = $result['name'];
}
| php | {
"resource": ""
} |
q6010 | JBDump.microtime | train | public static function microtime()
{
$_this = self::i();
if (!$_this->isDebug()) {
| php | {
"resource": ""
} |
q6011 | JBDump.mark | train | public static function mark($label = '')
{
$_this = self::i();
if (!$_this->isDebug()) {
return false;
}
$current = $_this->_microtime() - $_this->_start;
$memory = self::_getMemory();
$trace = debug_backtrace();
$markInfo = array(
'time' => $current,
'timeDiff' => $current - $_this->_prevTime,
'memory' => $memory,
'memoryDiff' => $memory - $_this->_prevMemory,
'trace' => $_this->_getSourcePath($trace, true),
'label' | php | {
"resource": ""
} |
q6012 | JBDump.profiler | train | public function profiler($mode = 1)
{
if ($this->isDebug() && count($this->_bufferInfo) > 2 && $mode) {
$mode = (int)$mode;
if ($mode && self::isAjax()) {
if ($mode & self::PROFILER_RENDER_TOTAL) {
$this->_profilerRenderTotal();
}
} else {
if ($mode & self::PROFILER_RENDER_TABLE) {
$this->_profilerRenderTable();
}
if ($mode & self::PROFILER_RENDER_CHART) {
| php | {
"resource": ""
} |
q6013 | JBDump._profilerFormatMemory | train | protected static function _profilerFormatMemory($memoryBytes, $addMeasure = false)
{
$bytes = round($memoryBytes / 1024 / 1024, 3);
if ($addMeasure) | php | {
"resource": ""
} |
q6014 | JBDump._profilerFormatTime | train | protected static function _profilerFormatTime($time, $addMeasure = false, $round = 0)
{
$time = round($time * 1000, $round);
| php | {
"resource": ""
} |
q6015 | JBDump._profilerFormatMark | train | protected static function _profilerFormatMark(array $mark)
{
return sprintf("%0.3f sec (+%.3f); %0.3f MB (%s%0.3f) - %s",
(float)$mark['time'],
(float)$mark['timeDiff'],
($mark['memory'] / 1024 / 1024),
| php | {
"resource": ""
} |
q6016 | JBDump._profilerRenderTotal | train | protected function _profilerRenderTotal()
{
reset($this->_bufferInfo);
$first = current($this->_bufferInfo);
$last = end($this->_bufferInfo);
$memoryPeak = memory_get_peak_usage(true);
$memoryDeltas = $timeDeltas = array();
foreach ($this->_bufferInfo as $oneMark) {
$memoryDeltas[] = $oneMark['memoryDiff'];
$timeDeltas[] = $oneMark['timeDiff'];
}
$totalInfo = array();
$totalInfo[] = '- Points: ' . count($this->_bufferInfo);
$totalInfo[] = '-------- Time (ms)';
$totalInfo[] = '- Max delta, msec: ' . self::_profilerFormatTime(max($timeDeltas));
$totalInfo[] = '- Min delta, msec: ' . self::_profilerFormatTime(min($timeDeltas));
$totalInfo[] = '- Total delta, msec: ' . self::_profilerFormatTime(($last['time'] - $first['time']));
$totalInfo[] = '- Limit, sec: ' . ini_get('max_execution_time');
$totalInfo[] = '-------- Memory (MB)';
$totalInfo[] = '- Max delta: ' . self::_profilerFormatMemory(max($memoryDeltas));
| php | {
"resource": ""
} |
q6017 | JBDump._profilerRenderFile | train | protected function _profilerRenderFile()
{
$this->log('-------------------------------------------------------', 'Profiler start');
foreach ($this->_bufferInfo as $key => $mark) {
| php | {
"resource": ""
} |
q6018 | JBDump._profilerRenderEcho | train | protected function _profilerRenderEcho()
{
$output = PHP_EOL;
foreach ($this->_bufferInfo as $key => $mark) {
$output .= | php | {
"resource": ""
} |
q6019 | JBDump._dumpRenderHtml | train | protected function _dumpRenderHtml($data, $varname = '...', $params = array())
{
$this->_currentDepth = 0;
$this->_initAssets();
if (isset($params['trace'])) {
$this->_trace = $params['trace'];
} else {
$this->_trace = debug_backtrace();
}
$text = $this->_getSourceFunction($this->_trace);
$path = $this->_getSourcePath($this->_trace);
?>
<div id="jbdump">
<ul class="jbnode">
<?php $this->_dump($data, $varname); ?>
<li class="jbfooter">
| php | {
"resource": ""
} |
q6020 | JBDump._dumpRenderLite | train | protected function _dumpRenderLite($data, $varname = '...', $params = array())
{
if (is_bool($data)) {
$data = $data ? 'TRUE' : 'FALSE';
} elseif (is_null($data)) {
$data = 'NULL';
}
if (is_string($data) && strlen($data) == 0) {
$printrOut = '""';
} else {
$printrOut = print_r($data, true);
}
if (!self::isCli()) {
$printrOut = $this->_htmlChars($printrOut);
}
| php | {
"resource": ""
} |
q6021 | JBDump.hash | train | public static function hash($data)
{
$result = array();
foreach (hash_algos() as $algoritm) {
$result[$algoritm] = hash($algoritm, $data, | php | {
"resource": ""
} |
q6022 | JBDump._getMemory | train | protected static function _getMemory()
{
if (function_exists('memory_get_usage')) {
return memory_get_usage();
} else {
$output = array();
$pid = getmypid();
if (substr(PHP_OS, 0, 3) == 'WIN') {
@exec('tasklist /FI "PID eq ' . $pid . '" /FO LIST', $output);
if (!isset($output[5])) {
$output[5] = null;
| php | {
"resource": ""
} |
q6023 | JBDump._dump | train | protected function _dump($data, $name = '...')
{
$varType = strtolower(getType($data));
$advType = false;
if ($varType == 'string' && preg_match('#(.*)::(.*)#', $name, $matches)) {
$matches[2] = trim(strToLower($matches[2]));
if ($this->_strlen($matches[2]) > 0) {
$advType = $matches[2];
}
$name = $matches[1];
}
if ($this->_strlen($name) > 80) {
$name = substr($name, 0, 80) . '...';
}
if ($varType == 'null') {
$this->_null($name);
} elseif ($varType == 'boolean') {
$this->_boolean($data, $name, $advType);
} elseif ($varType == 'integer') {
$this->_integer($data, $name, $advType);
} elseif ($varType == 'double') {
$this->_float($data, $name, $advType);
} elseif ($varType == 'string') {
$this->_string($data, $name, $advType);
} elseif ($varType == 'array') {
if ($this->_currentDepth <= self::$_config['dump']['maxDepth']) {
$this->_currentDepth++;
$this->_array($data, $name, $advType);
$this->_currentDepth--;
} else {
| php | {
"resource": ""
} |
q6024 | JBDump._vars | train | protected function _vars($data, $isExpanded = false)
{
$_is_object = is_object($data);
?>
<div class="jbnest" style="<?php echo $isExpanded ? 'display:block' : 'display:none'; ?>">
<ul class="jbnode">
<?php
$keys = ($_is_object) ? array_keys(@get_object_vars($data)) : array_keys($data);
// sorting
if (self::$_config['sort']['object'] && $_is_object) {
sort($keys);
} elseif (self::$_config['sort']['array']) {
sort($keys);
}
| php | {
"resource": ""
} |
q6025 | JBDump._resource | train | protected function _resource($data, $name)
{
$data = get_resource_type($data);
| php | {
"resource": ""
} |
q6026 | JBDump._strlen | train | protected function _strlen($string)
{
$encoding = function_exists('mb_detect_encoding') ? mb_detect_encoding($string) : false;
| php | {
"resource": ""
} |
q6027 | JBDump._string | train | protected function _string($data, $name, $advType = '')
{
$dataLength = $this->_strlen($data);
$_extra = false;
if ($advType == 'html') {
$_extra = true;
$_ = 'HTML Code';
$data = '<pre class="jbpreview">' . $data . '</pre>';
} elseif ($advType == 'source') {
$data = trim($data);
if ($data && strpos($data, '<?') !== 0) {
$_ = 'PHP Code';
$_extra = true;
$data = "<?php" . PHP_EOL . PHP_EOL . $data;
$data = '<pre class="jbpreview">' . highlight_string($data, true) . '</pre>';
} else {
$_ = '// code not found';
$data = null;
}
} else {
$_ = $data;
if (!(
strpos($data, "\r") === false &&
strpos($data, "\n") === false &&
strpos($data, " ") === false &&
strpos($data, "\t") === false
)
) {
$_extra = true;
} else {
$_extra = false;
}
if ($this->_strlen($data)) {
if ($this->_strlen($data) > self::$_config['dump']['stringLength']) {
if (function_exists('mb_substr')) {
$_ = mb_substr($data, 0, self::$_config['dump']['stringLength'] - 3) . '...';
} else {
$_ = substr($data, 0, self::$_config['dump']['stringLength'] - 3) . '...';
}
$_extra = true;
| php | {
"resource": ""
} |
q6028 | JBDump._array | train | protected function _array(array $data, $name)
{
$isExpanded = $this->_isExpandedLevel();
if (0 === strpos($name, '<! methods of "')) {
$isExpanded = false;
}
?>
<li class="jbchild">
<div
class="jbelement<?php echo count((array)$data) > 0 ? ' jbexpand' : ''; ?> <?= $isExpanded ? 'jbopened' : ''; ?>"
<?php if (count((array)$data) > 0) { ?> onClick="jbdump.toggle(this);"<?php } ?>>
<span class="jbname"><?php echo $name; ?></span> (<span
| php | {
"resource": ""
} |
q6029 | JBDump._object | train | protected function _object($data, $name)
{
static $objectIdList = array();
$objectId = spl_object_hash($data);
if (!isset($objectIdList[$objectId])) {
$objectIdList[$objectId] = count($objectIdList);
}
$count = count(@get_object_vars($data));
$isExpand = $count > 0 || self::$_config['dump']['showMethods'];
$isExpanded = $this->_isExpandedLevel();
?>
<li class="jbchild">
<div class="jbelement<?php echo $isExpand ? ' jbexpand' : ''; ?> <?= $isExpanded ? 'jbopened' : ''; ?>"
<?php if ($isExpand) { ?> onClick="jbdump.toggle(this);"<?php } ?>>
<span class="jbname" title="splHash=<?php echo $objectId;?>"><?php echo $name; ?></span>
| php | {
"resource": ""
} |
q6030 | JBDump._closure | train | protected function _closure($data, $name)
{
$isExpanded = $this->_isExpandedLevel();
?>
<li class="jbchild">
<div
class="jbelement<?php echo count((array)$data) > 0 ? ' jbexpand' : ''; ?> <?= $isExpanded ? 'jbopened' : ''; ?>"
<?php if (count((array)$data) > 0) { ?> onClick="jbdump.toggle(this);"<?php } ?>>
| php | {
"resource": ""
} |
q6031 | JBDump._renderNode | train | protected function _renderNode($type, $name, $data)
{
$typeAlias = str_replace(' ', '-', strtolower($type));
?>
<li class="jbchild">
<div class="jbelement">
<span class="jbname"><?php echo $name; ?></span>
| php | {
"resource": ""
} |
q6032 | JBDump.getClientIP | train | public static function getClientIP($getSource = false)
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
$source = 'HTTP_CLIENT_IP';
} elseif (!empty($_SERVER['HTTP_X_REAL_IP'])) {
$ip = $_SERVER['HTTP_X_REAL_IP'];
$source = 'HTTP_X_REAL_IP';
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
$source = 'HTTP_X_FORWARDED_FOR';
} elseif (!empty($_SERVER['REMOTE_ADDR'])) {
$ip | php | {
"resource": ""
} |
q6033 | JBDump._getRalativePath | train | protected function _getRalativePath($path)
{
if ($path) {
$rootPath = str_replace(array('/', '\\'), '/', self::$_config['root']);
$path = str_replace(array('/', '\\'), '/', $path);
$path = str_replace($rootPath, '/', $path);
| php | {
"resource": ""
} |
q6034 | JBDump._getOneTrace | train | protected function _getOneTrace($info, $addObject = false)
{
$_this = self::i();
$_tmp = array();
if (isset($info['file'])) {
$_tmp['file'] = $_this->_getRalativePath($info['file']) . ' : ' . $info['line'];
} else {
$info['file'] = false;
}
if ($info['function'] != 'include' && $info['function'] != 'include_once' && $info['function'] != 'require'
&& $info['function'] != 'require_once'
) {
if (isset($info['type']) && isset($info['class'])) {
$_tmp['func'] = $info['class']
. ' ' . $info['type']
. ' ' . $info['function'] . '()';
} else {
$_tmp['func'] = $info['function'] . '()';
}
$args = isset($info['args']) ? $info['args'] : array();
| php | {
"resource": ""
} |
q6035 | JBDump._formatSize | train | protected static function _formatSize($bytes)
{
$exp = 0;
$value = 0;
$symbol = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
if ($bytes > 0) {
$exp = floor(log($bytes) / log(1024));
| php | {
"resource": ""
} |
q6036 | JBDump._getSourceFunction | train | protected function _getSourceFunction($trace)
{
$lastTrace = $this->_getLastTrace($trace);
if (isset($lastTrace['function']) || isset($lastTrace['class'])) {
$args = '';
if (isset($lastTrace['args'])) {
$args = '( ' . count($lastTrace['args']) . ' args' . | php | {
"resource": ""
} |
q6037 | JBDump._getSourcePath | train | protected function _getSourcePath($trace, $fileOnly = false)
{
$path = '';
$currentTrace = $this->_getLastTrace($trace);
if (isset($currentTrace['file'])) {
$path = $this->_getRalativePath($currentTrace['file']);
| php | {
"resource": ""
} |
q6038 | JBDump._getLastTrace | train | protected function _getLastTrace($trace)
{
// current filename info
$curFile = pathinfo(__FILE__, PATHINFO_BASENAME);
$curFileLength = $this->_strlen($curFile);
$meta = array();
$j = 0;
for ($i = 0; $trace && $i < sizeof($trace); $i++) {
$j = $i;
if (isset($trace[$i]['class'])
&& isset($trace[$i]['file'])
&& ($trace[$i]['class'] == 'JBDump')
&& (substr($trace[$i]['file'], -$curFileLength, $curFileLength) == $curFile)
) {
} elseif (isset($trace[$i]['class'])
&& isset($trace[$i + 1]['file'])
&& isset($trace[$i]['file'])
&& $trace[$i]['class'] == 'JBDump'
&& (substr($trace[$i]['file'], -$curFileLength, $curFileLength) == $curFile)
) {
} elseif (isset($trace[$i]['file'])
&& (substr($trace[$i]['file'], -$curFileLength, $curFileLength) == $curFile)
) {
} | php | {
"resource": ""
} |
q6039 | JBDump._getMethods | train | protected function _getMethods($object)
{
if (is_string($object)) {
$className = $object;
} else {
$className | php | {
"resource": ""
} |
q6040 | JBDump.convertTrace | train | public function convertTrace($trace, $addObject = false)
{
$result = array();
if (is_array($trace)) {
foreach ($trace as $key => $info) {
$oneTrace = self::i()->_getOneTrace($info, $addObject);
$file = 'undefined';
| php | {
"resource": ""
} |
q6041 | JBDump._getErrorTypes | train | protected static function _getErrorTypes()
{
$errType = array(
E_ERROR => 'Error',
E_WARNING => 'Warning',
E_PARSE => 'Parsing Error',
E_NOTICE => 'Notice',
E_CORE_ERROR => 'Core Error',
E_CORE_WARNING => 'Core Warning',
E_COMPILE_ERROR => 'Compile Error',
E_COMPILE_WARNING => 'Compile Warning',
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
| php | {
"resource": ""
} |
q6042 | JBDump._errorHandler | train | function _errorHandler($errNo, $errMsg, $errFile, $errLine, $errCont)
{
$errType = $this->_getErrorTypes();
$errorMessage = $errType[$errNo] . "\t\"" . trim($errMsg) . "\"\t" . $errFile . ' ' . 'Line:' . $errLine;
if (self::$_config['errors']['logAll']) {
error_log('JBDump:' . $errorMessage);
}
if (!(error_reporting() & $errNo) || error_reporting() == 0 || (int)ini_get('display_errors') == 0) {
if (self::$_config['errors']['logHidden']) {
$errorMessage = date(self::DATE_FORMAT, time()) . ' ' . $errorMessage . PHP_EOL;
$logPath = self::$_config['log']['path']
. '/' . self::$_config['log']['file'] . '_error_' . date('Y.m.d') . '.log';
error_log($errorMessage, 3, $logPath);
}
return false;
}
$errFile = $this->_getRalativePath($errFile);
$result = array(
'file' => $errFile . ' : ' . $errLine,
'type' => $errType[$errNo] . ' (' . $errNo . ')',
'message' => $errMsg,
| php | {
"resource": ""
} |
q6043 | JBDump.errors | train | public static function errors()
{
$result = array();
$result['error_reporting'] = error_reporting();
$errTypes = self::_getErrorTypes();
foreach ($errTypes as $errTypeKey => $errTypeName) {
if ($result['error_reporting'] & $errTypeKey) {
| php | {
"resource": ""
} |
q6044 | JBDump.isAjax | train | public static function isAjax()
{
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])
&& strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'
) {
return true;
} elseif (self::isCli()) {
return true;
} elseif (function_exists('apache_request_headers')) {
$headers = apache_request_headers();
foreach ($headers as $key => $value) {
if (strtolower($key) == 'x-requested-with' && strtolower($value) == 'xmlhttprequest') {
| php | {
"resource": ""
} |
q6045 | JBDump.mail | train | public static function mail($text, $subject = null, $to = null)
{
if (!self::isDebug()) {
return false;
}
$_this = self::i();
if (empty($subject)) {
$subject = self::$_config['mail']['subject'];
}
if (empty($to)) {
$to = isset(self::$_config['mail']['to'])
? self::$_config['mail']['to']
: 'jbdump@' . $_SERVER['HTTP_HOST'];
}
if (is_array($to)) {
$to = implode(', ', $to);
}
// message
$message = array();
$message[] = '<html><body>';
$message[] = '<p><b>JBDump mail from '
. '<a href="http://' . $_SERVER['HTTP_HOST'] . '">' . $_SERVER['HTTP_HOST'] . '</a>'
. '</b></p>';
$message[] = '<p><b>Date</b>: ' . date(DATE_RFC822, time()) . '</p>';
$message[] = '<p><b>IP</b>: ' . self::getClientIP() . '</p>';
$message[] = '<b>Debug message</b>: <pre>' . print_r($text, true) . '</pre>';
$message[] = '</body></html>';
$message = wordwrap(implode(PHP_EOL, $message), 70);
// To send HTML mail, the Content-type header must be set
$headers = array();
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=utf-8';
$headers[] = 'To: ' . $to;
| php | {
"resource": ""
} |
q6046 | JBDump.sql | train | public static function sql($query, $sqlName = 'SQL Query', $nl2br = false)
{
// Joomla hack
if (defined('_JEXEC')) {
$config = new JConfig();
$prefix = $config->dbprefix;
$query = str_replace('#__', $prefix, $query);
}
if (class_exists('JBDump_SqlFormatter')) | php | {
"resource": ""
} |
q6047 | JBDump._jsonEncode | train | protected function _jsonEncode($in, $indent = 0)
{
$out = '';
foreach ($in as $key => $value) {
$out .= str_repeat(" ", $indent + 1);
$out .= json_encode((string)$key) . ': ';
if (is_object($value) || is_array($value)) {
$out .= $this->_jsonEncode($value, $indent + 1);
} else {
$out .= json_encode($value);
}
| php | {
"resource": ""
} |
q6048 | CustomerAddVatidTypo3.process | train | protected function process( array $stmts )
{
$this->msg( 'Adding "vatid" column to fe_users tables', 0 ); $this->status( '' );
foreach( $stmts as $table => $stmt )
{
$this->msg( sprintf( 'Checking "%1$s" table', $table ), 1 );
if( $this->schema->tableExists( $table ) === true | php | {
"resource": ""
} |
q6049 | Util.getJson | train | public static function getJson($file, $assoc = true)
{
// @codeCoverageIgnoreStart
if (!extension_loaded('json')) {
throw new \Exception('The JSON extension is not loaded.');
}
// @codeCoverageIgnoreEnd
if (!file_exists($file)) {
throw new \InvalidArgumentException(htmlspecialchars("The $file file is missing."));
}
if (strrchr($file, '.') != '.json') {
throw new \InvalidArgumentException(htmlspecialchars("The $file is not in JSON format."));
}
if (($json = file_get_contents($file)) === null) {
| php | {
"resource": ""
} |
q6050 | LinkFactory.link | train | public function link($destination, array $params = array())
{
if (($pos = strrpos($destination, '#')) !== FALSE) {
$fragment = substr($destination, $pos);
$destination = substr($destination, 0, $pos);
} else {
$fragment = '';
}
if (strncmp($destination, '//', 2) === 0) {
$absoluteUrl = TRUE;
$destination = substr($destination, 2);
} else {
$absoluteUrl = FALSE;
}
$pos = strrpos($destination, ':');
$presenter = substr($destination, 0, $pos);
if ($pos + 1 < strlen($destination)) {
$params['action'] = substr($destination, $pos + 1);
}
$request = new Nette\Application\Request($presenter, | php | {
"resource": ""
} |
q6051 | Client.generateRequestHeaders | train | protected function generateRequestHeaders(
$verb,
$resourceType,
$resourceId,
$isQuery = false,
$contentLength = 0,
array $extraHeaders = []
){
$xMsDate = gmdate('D, d M Y H:i:s T');
$headers = [
'Accept: application/json',
'User-Agent: ' . static::USER_AGENT,
'Cache-Control: no-cache',
'x-ms-date: ' . $xMsDate,
'x-ms-version: ' . $this->apiVersion,
'Authorization: ' . $this->generateAuthHeader($verb, $xMsDate, $resourceType, $resourceId)
];
if (in_array($verb, [Verbs::POST, Verbs::PUT])) {
$headers[] = 'Content-Length: | php | {
"resource": ""
} |
q6052 | Client.generateAuthHeader | train | private function generateAuthHeader($verb, $xMsDate, $resourceType, $resourceId)
{
$master = 'master';
$token = '1.0';
$key = base64_decode($this->key);
$stringToSign = strtolower($verb) . "\n" .
strtolower($resourceType) . "\n" .
$resourceId . "\n" .
| php | {
"resource": ""
} |
q6053 | DataStore.getParent | train | public function getParent($id)
{
/** @var Statement $statement */
$dataItem = $this->get($id);
$queryBuilder = $this->driver->getSelectQueryBuilder();
$queryBuilder->andWhere($this->driver->getUniqueId() . " = " . $dataItem->getAttribute($this->getParentField()));
$statement = $queryBuilder->execute();
$rows = array($statement->fetch());
| php | {
"resource": ""
} |
q6054 | DataStore.save | train | public function save($item, $autoUpdate = true)
{
$result = null;
$this->allowSave = true;
if (isset($this->events[ self::EVENT_ON_BEFORE_SAVE ])) {
$this->secureEval($this->events[ self::EVENT_ON_BEFORE_SAVE ], array(
'item' => &$item
));
}
if ($this->allowSave) {
$result = $this->getDriver()->save($item, $autoUpdate);
}
| php | {
"resource": ""
} |
q6055 | DataStore.isOracle | train | public function isOracle()
{
static $r;
if (is_null($r)) { | php | {
"resource": ""
} |
q6056 | DataStore.isSqlite | train | public function isSqlite()
{
static $r;
if (is_null($r)) { | php | {
"resource": ""
} |
q6057 | DataStore.isPostgres | train | public function isPostgres()
{
static $r;
if (is_null($r)) { | php | {
"resource": ""
} |
q6058 | DataStore.getTypes | train | public function getTypes()
{
$list = array();
$reflectionClass = new \ReflectionClass(__CLASS__);
foreach ($reflectionClass->getConstants() as $k => $v) {
| php | {
"resource": ""
} |
q6059 | DataStore.getTroughMapping | train | public function getTroughMapping($mappingId, $id)
{
$config = $this->mapping[ $mappingId ];
$dataStoreService = $this->container->get("data.source");
$externalDataStore = $dataStoreService->get($config["externalDataStore"]);
$externalDriver = $externalDataStore->getDriver();
$internalFieldName = null;
$externalFieldName = null;
if (isset($config['internalId'])) {
$internalFieldName = $config['internalId'];
}
if (isset($config['externalId'])) {
$externalFieldName = $config['externalId'];
}
if (isset($config['internalFieldName'])) {
$internalFieldName = | php | {
"resource": ""
} |
q6060 | Typo3.deleteMultiple | train | public function deleteMultiple( $keys )
{
foreach( | php | {
"resource": ""
} |
q6061 | Typo3.deleteByTags | train | public function deleteByTags( array $tags )
{
foreach( | php | {
"resource": ""
} |
q6062 | Typo3.clear | train | public function clear()
{
if( $this->prefix ) {
$this->object->flushByTag( | php | {
"resource": ""
} |
q6063 | FileManager.getFile | train | public function getFile($file = null, $md5 = null)
{
//====================================================================//
// Stack Trace
Splash::log()->trace();
//====================================================================//
// PHPUNIT Exception => Look First in Local FileSystem
//====================================================================//
if (defined('SPLASH_DEBUG') && !empty(SPLASH_DEBUG)) {
$filePath = dirname(__DIR__)."/Resources/files/".$file;
if (is_file($filePath)) {
$file = $this->readFile($filePath, $md5);
return is_array($file) ? $file : false;
}
$imgPath = dirname(__DIR__)."/Resources/img/".$file;
if (is_file($imgPath)) {
$file = $this->readFile($imgPath, $md5);
return is_array($file) ? $file : false;
}
}
//====================================================================//
// Initiate Tasks parameters array
$params = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
$params->file = $file; | php | {
"resource": ""
} |
q6064 | FileManager.isFile | train | public function isFile($path = null, $md5 = null)
{
//====================================================================//
// Safety Checks
if (empty($path)) {
return Splash::log()->err("ErrFileFileMissing", __FUNCTION__);
}
if (empty(dirname($path))) {
return Splash::log()->err("ErrFileDirMissing", __FUNCTION__);
}
if (empty($md5)) {
return Splash::log()->err("ErrFileMd5Missing", __FUNCTION__);
}
//====================================================================//
// Check if folder exists
if (!is_dir(dirname($path))) {
return Splash::log()->war("ErrFileDirNoExists", __FUNCTION__, dirname($path));
}
//====================================================================//
| php | {
"resource": ""
} |
q6065 | FileManager.readFile | train | public function readFile($path = null, $md5 = null)
{
//====================================================================//
// Safety Checks
if (empty($path)) {
return Splash::log()->err("ErrFileFileMissing", __FUNCTION__);
}
if (empty(dirname($path))) {
return Splash::log()->err("ErrFileDirMissing", __FUNCTION__);
}
if (empty($md5)) {
return Splash::log()->err("ErrFileMd5Missing", __FUNCTION__);
}
//====================================================================//
// Check if folder exists
if (!is_dir(dirname($path))) {
return Splash::log()->war("ErrFileDirNoExists", __FUNCTION__, dirname($path));
}
//====================================================================//
// Check if file exists
if (!is_file($path) || !is_readable($path)) {
return Splash::log()->war("ErrFileReadable", __FUNCTION__, $path);
}
//====================================================================//
// Check File CheckSum => No Diff with Previous Error for Higher Safety Level
if (md5_file($path) != $md5) {
return Splash::log()->war("ErrFileNoExists", __FUNCTION__, $path);
}
//====================================================================//
// Open File
| php | {
"resource": ""
} |
q6066 | FileManager.readFileContents | train | public function readFileContents($fileName = null)
{
//====================================================================//
// Safety Checks
if (empty($fileName)) {
return Splash::log()->err("ErrFileFileMissing");
}
//====================================================================//
// Check if file exists
if (!is_file($fileName)) {
return Splash::log()->err("ErrFileNoExists", $fileName);
}
//====================================================================//
// Check if file is readable
if (!is_readable($fileName)) {
return | php | {
"resource": ""
} |
q6067 | FileManager.writeFile | train | public function writeFile($dir = null, $file = null, $md5 = null, $raw = null)
{
//====================================================================//
// Safety Checks
if (!$this->isWriteValidInputs($dir, $file, $md5, $raw)) {
return false;
}
//====================================================================//
// Assemble full Filename
$fullpath = $dir.$file;
//====================================================================//
// Check if folder exists or create it
if (!is_dir((string) $dir)) {
mkdir((string) $dir, 0775, true);
}
//====================================================================//
// Check if folder exists
if (!is_dir((string) $dir)) {
Splash::log()->war("ErrFileDirNoExists", __FUNCTION__, $dir);
}
//====================================================================//
// Check if file exists
if (is_file($fullpath)) {
Splash::log()->deb("MsgFileExists", __FUNCTION__, $file);
//====================================================================//
// Check if file is different
if ($md5 === md5_file($fullpath)) {
return true;
}
//====================================================================//
// Check if | php | {
"resource": ""
} |
q6068 | FileManager.deleteFile | train | public function deleteFile($path = null, $md5 = null)
{
$fPath = (string) $path;
//====================================================================//
// Safety Checks
if (empty(dirname($fPath))) {
return Splash::log()->err("ErrFileDirMissing", __FUNCTION__);
}
if (empty(basename($fPath))) {
return Splash::log()->err("ErrFileFileMissing", __FUNCTION__);
}
if (empty($md5)) {
return Splash::log()->err("ErrFileMd5Missing", __FUNCTION__);
}
//====================================================================//
// Check if folder exists
if (!is_dir(dirname($fPath))) {
Splash::log()->war("ErrFileDirNoExists", __FUNCTION__, dirname($fPath));
}
//====================================================================//
// Check if file exists
| php | {
"resource": ""
} |
q6069 | FileManager.isWriteValidInputs | train | private function isWriteValidInputs($dir = null, $file = null, $md5 = null, $raw = null)
{
//====================================================================//
// Safety Checks
if (empty($dir)) {
return Splash::log()->err("ErrFileDirMissing", __FUNCTION__);
| php | {
"resource": ""
} |
q6070 | CreateCardRefQuery.checkPaymentTransactionStatus | train | protected function checkPaymentTransactionStatus(PaymentTransaction $paymentTransaction)
{
if (!$paymentTransaction->isFinished())
{
throw new ValidationException('Only finished payment transaction can be used for create-card-ref-id');
}
if (!$paymentTransaction->getPayment()->isPaid())
| php | {
"resource": ""
} |
q6071 | GatewayClient.parseReponse | train | protected function parseReponse($response)
{
if(empty($response))
{
throw new ResponseException('PaynetEasy response is | php | {
"resource": ""
} |
q6072 | GatewayClient.getUrl | train | protected function getUrl(Request $request)
{
if (strpos($request->getApiMethod(), 'sync-') === 0)
{
$apiMethod = 'sync/' . substr($request->getApiMethod(), strlen('sync-'));
}
else
{
$apiMethod = $request->getApiMethod();
}
if (strlen($request->getEndPointGroup()) > 0)
| php | {
"resource": ""
} |
q6073 | TokenGenerator.generateToken | train | public function generateToken($token_length=30, $prefix='') {
$token_length = $token_length - strlen($prefix);
if ($token_length < 0) { throw new Exception("Prefix is too long", 1); }
$token = "";
while (($len = strlen($token)) < $token_length) {
$remaining_len = $token_length - $len;
| php | {
"resource": ""
} |
q6074 | Validator.validateByRule | train | static public function validateByRule($value, $rule, $failOnError = true)
{
$valid = false;
switch ($rule)
{
case self::EMAIL:
{
$valid = filter_var($value, FILTER_VALIDATE_EMAIL);
break;
}
case self::IP:
{
$valid = filter_var($value, FILTER_VALIDATE_IP);
break;
}
case self::URL:
{
$valid = filter_var($value, FILTER_VALIDATE_URL);
break;
}
case self::MONTH:
{
$valid = in_array($value, range(1, 12));
break;
| php | {
"resource": ""
} |
q6075 | FieldsFactory.create | train | public function create($fieldType, $fieldId = null, $fieldName = null)
{
//====================================================================//
// Commit Last Created if not already done
if (!empty($this->new)) {
$this->commit();
}
//====================================================================//
// Unset Current
$this->new = null;
//====================================================================//
| php | {
"resource": ""
} |
q6076 | FieldsFactory.identifier | train | public function identifier($fieldId)
{
//====================================================================//
// Safety Checks ==> Verify a new Field Exists
if (empty($this->new)) {
Splash::log()->err("ErrFieldsNoNew");
} else {
| php | {
"resource": ""
} |
q6077 | FieldsFactory.inList | train | public function inList($listName)
{
//====================================================================//
// Safety Checks ==> Verify List Name Not Empty
if (empty($listName)) {
return $this;
}
//====================================================================//
// Safety Checks ==> Verify a new Field Exists
if (empty($this->new)) {
Splash::log()->err("ErrFieldsNoNew");
} else {
//====================================================================//
// Update New Field Identifier
| php | {
"resource": ""
} |
q6078 | FieldsFactory.isReadOnly | train | public function isReadOnly($isReadOnly = true)
{
//====================================================================//
// Safety Checks ==> Verify a new Field Exists
if (empty($this->new)) {
Splash::log()->err("ErrFieldsNoNew");
} elseif ($isReadOnly) {
| php | {
"resource": ""
} |
q6079 | FieldsFactory.isWriteOnly | train | public function isWriteOnly($isWriteOnly = true)
{
//====================================================================//
// Safety Checks ==> Verify a new Field Exists
if (empty($this->new)) {
Splash::log()->err("ErrFieldsNoNew");
} elseif ($isWriteOnly) {
| php | {
"resource": ""
} |
q6080 | FieldsFactory.isRequired | train | public function isRequired($isRequired = true)
{
//====================================================================//
// Safety Checks ==> Verify a new Field Exists
if (empty($this->new)) {
Splash::log()->err("ErrFieldsNoNew");
} else {
| php | {
"resource": ""
} |
q6081 | FieldsFactory.setPreferRead | train | public function setPreferRead()
{
//====================================================================//
// Safety Checks ==> Verify a new Field Exists
if (empty($this->new)) {
Splash::log()->err("ErrFieldsNoNew");
} else {
| php | {
"resource": ""
} |
q6082 | FieldsFactory.setPreferWrite | train | public function setPreferWrite()
{
//====================================================================//
// Safety Checks ==> Verify a new Field Exists
if (empty($this->new)) {
Splash::log()->err("ErrFieldsNoNew");
} else {
| php | {
"resource": ""
} |
q6083 | FieldsFactory.setPreferNone | train | public function setPreferNone()
{
//====================================================================//
// Safety Checks ==> Verify a new Field Exists
if (empty($this->new)) {
Splash::log()->err("ErrFieldsNoNew");
} else {
| php | {
"resource": ""
} |
q6084 | FieldsFactory.association | train | public function association()
{
//====================================================================//
// Safety Checks ==> Verify a new Field Exists
if (empty($this->new)) {
Splash::log()->err("ErrFieldsNoNew");
} else {
//====================================================================//
// Field Clear Fields Associations
if (!empty($this->new->asso)) {
$this->new->asso = null;
}
| php | {
"resource": ""
} |
q6085 | FieldsFactory.isListed | train | public function isListed($isListed = true)
{
//====================================================================//
// Safety Checks ==> Verify a new Field Exists
if (empty($this->new)) {
Splash::log()->err("ErrFieldsNoNew");
} else {
| php | {
"resource": ""
} |
q6086 | FieldsFactory.isLogged | train | public function isLogged($isLogged = true)
{
//====================================================================//
// Safety Checks ==> Verify a new Field Exists
if (empty($this->new)) {
Splash::log()->err("ErrFieldsNoNew");
} else {
| php | {
"resource": ""
} |
q6087 | FieldsFactory.microData | train | public function microData($itemType, $itemProp)
{
//====================================================================//
// Safety Checks ==> Verify a new Field Exists
if (empty($this->new)) {
Splash::log()->err("ErrFieldsNoNew");
} else {
//====================================================================//
| php | {
"resource": ""
} |
q6088 | FieldsFactory.addOptions | train | public function addOptions($fieldOptions)
{
foreach ($fieldOptions as | php | {
"resource": ""
} |
q6089 | FieldsFactory.addOption | train | public function addOption($type, $value = true)
{
//====================================================================//
// Safety Checks ==> Verify a new Field Exists
if (empty($this->new)) {
Splash::log()->err("ErrFieldsNoNew");
} elseif (empty($type)) {
Splash::log()->err("Field Option Type Cannot be Empty");
| php | {
"resource": ""
} |
q6090 | FieldsFactory.setDefaultLanguage | train | public function setDefaultLanguage($isoCode)
{
//====================================================================//
// Safety Checks ==> Verify Language ISO Code
if (!is_string($isoCode) || (strlen($isoCode) < 2)) {
Splash::log()->err("Default Language ISO Code is Invalid");
| php | {
"resource": ""
} |
q6091 | FieldsFactory.setMultilang | train | public function setMultilang($isoCode)
{
//====================================================================//
// Safety Checks ==> Verify a new Field Exists
if (empty($this->new)) {
Splash::log()->err("ErrFieldsNoNew");
return $this;
}
//====================================================================//
// Safety Checks ==> Verify Language ISO Code
if (!is_string($isoCode) || (strlen($isoCode) < 2)) {
Splash::log()->err("Language ISO Code is Invalid");
return $this;
}
//====================================================================//
// Safety Checks ==> Verify Field Type is Allowed
if (!in_array($this->new->type, array(SPL_T_VARCHAR, SPL_T_TEXT), true)) {
Splash::log()->err("ErrFieldsWrongLang");
Splash::log()->err("Received: ".$this->new->type);
return $this; | php | {
"resource": ""
} |
q6092 | FieldsFactory.seachtByTag | train | public function seachtByTag($fieldList, $fieldTag)
{
//====================================================================//
// Safety Checks
if (!count($fieldList)) {
return false;
}
if (empty($fieldTag)) {
return false;
}
//====================================================================// | php | {
"resource": ""
} |
q6093 | FieldsFactory.seachtById | train | public function seachtById($fieldList, $fieldId)
{
//====================================================================//
// Safety Checks
if (!count($fieldList)) {
return false;
}
if (empty($fieldId)) {
return false;
}
//====================================================================// | php | {
"resource": ""
} |
q6094 | FieldsFactory.setTag | train | private function setTag($fieldTag)
{
//====================================================================//
// Safety Checks ==> Verify a new Field Exists
if (empty($this->new)) {
Splash::log()->err("ErrFieldsNoNew");
} else {
| php | {
"resource": ""
} |
q6095 | FieldsFactory.validate | train | private function validate($field)
{
//====================================================================//
// Verify - Field Type is Not Empty
if (empty($field->type) || !is_string($field->type)) {
return Splash::log()->err("ErrFieldsNoType");
}
//====================================================================//
// Verify - Field Id is Not Empty
if (empty($field->id) || !is_string($field->id)) {
return Splash::log()->err("ErrFieldsNoId");
}
//====================================================================//
// Verify - Field Id No Spacial Chars
if ($field->id !== preg_replace('/[^a-zA-Z0-9-_@]/u', '', $field->id)) {
Splash::log()->war("ErrFieldsInvalidId", $field->id);
return false;
}
| php | {
"resource": ""
} |
q6096 | ContactController.postSubmit | train | public function postSubmit()
{
$rules = [
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required',
'message' => 'required',
];
$input = Binput::only(array_keys($rules));
$val = Validator::make($input, $rules);
if ($val->fails()) {
return Redirect::to($this->path)->withInput()->withErrors($val);
| php | {
"resource": ""
} |
q6097 | PHPMailer.EncodeString | train | public function EncodeString($str, $encoding = 'base64')
{
$encoded = '';
switch (strtolower($encoding)) {
case 'base64':
$encoded = chunk_split(base64_encode($str), 76, $this->LE);
break;
case '7bit':
case '8bit':
$encoded = $this->FixEOL($str);
//Make sure it ends with a | php | {
"resource": ""
} |
q6098 | PHPMailer._mime_types | train | public static function _mime_types($ext = '')
{
$mimes = array(
'hqx' => 'application/mac-binhex40',
'cpt' => 'application/mac-compactpro',
'doc' => 'application/msword',
'bin' => 'application/macbinary',
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'exe' => 'application/octet-stream',
'class' => 'application/octet-stream',
'psd' => 'application/octet-stream',
'so' => 'application/octet-stream',
'sea' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => 'application/pdf',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'wbxml' => 'application/vnd.wap.wbxml',
'wmlc' => 'application/vnd.wap.wmlc',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'gtar' => 'application/x-gtar',
'php' => 'application/x-httpd-php',
'php4' => 'application/x-httpd-php',
'php3' => 'application/x-httpd-php',
'phtml' => 'application/x-httpd-php',
'phps' => 'application/x-httpd-php-source',
'js' => 'application/x-javascript',
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'tar' => 'application/x-tar',
'tgz' => 'application/x-tar',
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => 'application/zip',
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' => 'audio/mpeg',
'aif' => 'audio/x-aiff',
| php | {
"resource": ""
} |
q6099 | SMTP.StartTLS | train | public function StartTLS()
{
$this->error = null; # to avoid confusion
if (!$this->connected()) {
$this->error = array("error" => "Called StartTLS() without being connected");
return false;
}
fputs($this->smtp_conn, "STARTTLS" . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply, 0, 3);
if ($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.