repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
benjaminkott/bootstrap_package | Classes/ViewHelpers/Format/UpperCamelCaseViewHelper.php | UpperCamelCaseViewHelper.renderStatic | public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
return str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($renderChildrenClosure()))));
} | php | public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
return str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($renderChildrenClosure()))));
} | [
"public",
"static",
"function",
"renderStatic",
"(",
"array",
"$",
"arguments",
",",
"\\",
"Closure",
"$",
"renderChildrenClosure",
",",
"RenderingContextInterface",
"$",
"renderingContext",
")",
"{",
"return",
"str_replace",
"(",
"' '",
",",
"''",
",",
"ucwords",... | @param array $arguments
@param \Closure $renderChildrenClosure
@param RenderingContextInterface $renderingContext
@return string the formatted amount | [
"@param",
"array",
"$arguments",
"@param",
"\\",
"Closure",
"$renderChildrenClosure",
"@param",
"RenderingContextInterface",
"$renderingContext"
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Classes/ViewHelpers/Format/UpperCamelCaseViewHelper.php#L30-L33 |
benjaminkott/bootstrap_package | Classes/Backend/ToolbarItem/VersionToolbarItem.php | VersionToolbarItem.addVersionInformation | public function addVersionInformation(SystemInformationToolbarItem $systemInformation)
{
$value = null;
$extensionDirectory = ExtensionManagementUtility::extPath('bootstrap_package');
// Try to get current version from git
if (file_exists($extensionDirectory . '.git')) {
... | php | public function addVersionInformation(SystemInformationToolbarItem $systemInformation)
{
$value = null;
$extensionDirectory = ExtensionManagementUtility::extPath('bootstrap_package');
// Try to get current version from git
if (file_exists($extensionDirectory . '.git')) {
... | [
"public",
"function",
"addVersionInformation",
"(",
"SystemInformationToolbarItem",
"$",
"systemInformation",
")",
"{",
"$",
"value",
"=",
"null",
";",
"$",
"extensionDirectory",
"=",
"ExtensionManagementUtility",
"::",
"extPath",
"(",
"'bootstrap_package'",
")",
";",
... | Called by the system information toolbar signal/slot dispatch.
@param SystemInformationToolbarItem $systemInformation | [
"Called",
"by",
"the",
"system",
"information",
"toolbar",
"signal",
"/",
"slot",
"dispatch",
"."
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Classes/Backend/ToolbarItem/VersionToolbarItem.php#L26-L60 |
benjaminkott/bootstrap_package | Classes/Hooks/PageRenderer/GoogleFontHook.php | GoogleFontHook.getGoogleFontService | protected function getGoogleFontService()
{
if ($this->googleFontService === null) {
$this->googleFontService = GeneralUtility::makeInstance(GoogleFontService::class);
}
return $this->googleFontService;
} | php | protected function getGoogleFontService()
{
if ($this->googleFontService === null) {
$this->googleFontService = GeneralUtility::makeInstance(GoogleFontService::class);
}
return $this->googleFontService;
} | [
"protected",
"function",
"getGoogleFontService",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"googleFontService",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"googleFontService",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"GoogleFontService",
"::",
"clas... | Get the google font service
@return GoogleFontService | [
"Get",
"the",
"google",
"font",
"service"
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Classes/Hooks/PageRenderer/GoogleFontHook.php#L91-L97 |
benjaminkott/bootstrap_package | Contrib/scssphp/src/Parser.php | Parser.pushBlock | protected function pushBlock($selectors, $pos = 0)
{
list($line, $column) = $this->getSourcePosition($pos);
$b = new Block;
$b->sourceName = $this->sourceName;
$b->sourceLine = $line;
$b->sourceColumn = $column;
$b->sourceIndex = $this->sourceIndex;
$b->... | php | protected function pushBlock($selectors, $pos = 0)
{
list($line, $column) = $this->getSourcePosition($pos);
$b = new Block;
$b->sourceName = $this->sourceName;
$b->sourceLine = $line;
$b->sourceColumn = $column;
$b->sourceIndex = $this->sourceIndex;
$b->... | [
"protected",
"function",
"pushBlock",
"(",
"$",
"selectors",
",",
"$",
"pos",
"=",
"0",
")",
"{",
"list",
"(",
"$",
"line",
",",
"$",
"column",
")",
"=",
"$",
"this",
"->",
"getSourcePosition",
"(",
"$",
"pos",
")",
";",
"$",
"b",
"=",
"new",
"Bl... | Push block onto parse tree
@param array $selectors
@param integer $pos
@return \Leafo\ScssPhp\Block | [
"Push",
"block",
"onto",
"parse",
"tree"
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Contrib/scssphp/src/Parser.php#L706-L734 |
benjaminkott/bootstrap_package | Contrib/scssphp/src/Parser.php | Parser.value | protected function value(&$out)
{
$s = $this->seek();
if ($this->literal('url(') && $this->match('data:([a-z]+)\/([a-z0-9.+-]+);base64,', $m, false)) {
$len = strspn($this->buffer, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwyxz0123456789+/=', $this->count);
$this->co... | php | protected function value(&$out)
{
$s = $this->seek();
if ($this->literal('url(') && $this->match('data:([a-z]+)\/([a-z0-9.+-]+);base64,', $m, false)) {
$len = strspn($this->buffer, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwyxz0123456789+/=', $this->count);
$this->co... | [
"protected",
"function",
"value",
"(",
"&",
"$",
"out",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"seek",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"literal",
"(",
"'url('",
")",
"&&",
"$",
"this",
"->",
"match",
"(",
"'data:([a-z]+)\\/([a-z0-... | Parse value
@param array $out
@return boolean | [
"Parse",
"value"
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Contrib/scssphp/src/Parser.php#L1302-L1381 |
benjaminkott/bootstrap_package | Contrib/scssphp/src/Compiler.php | Compiler.compileAtRoot | protected function compileAtRoot(Block $block)
{
$env = $this->pushEnv($block);
$envs = $this->compactEnv($env);
$without = isset($block->with) ? $this->compileWith($block->with) : static::WITH_RULE;
// wrap inline selector
if ($block->selector) {
$wrapped... | php | protected function compileAtRoot(Block $block)
{
$env = $this->pushEnv($block);
$envs = $this->compactEnv($env);
$without = isset($block->with) ? $this->compileWith($block->with) : static::WITH_RULE;
// wrap inline selector
if ($block->selector) {
$wrapped... | [
"protected",
"function",
"compileAtRoot",
"(",
"Block",
"$",
"block",
")",
"{",
"$",
"env",
"=",
"$",
"this",
"->",
"pushEnv",
"(",
"$",
"block",
")",
";",
"$",
"envs",
"=",
"$",
"this",
"->",
"compactEnv",
"(",
"$",
"env",
")",
";",
"$",
"without"... | Compile at-root
@param \Leafo\ScssPhp\Block $block | [
"Compile",
"at",
"-",
"root"
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Contrib/scssphp/src/Compiler.php#L776-L811 |
benjaminkott/bootstrap_package | Contrib/scssphp/src/Compiler.php | Compiler.hasSelectorPlaceholder | protected function hasSelectorPlaceholder($selector)
{
if (! is_array($selector)) {
return false;
}
foreach ($selector as $parts) {
foreach ($parts as $part) {
if (is_array($part)) {
return false;
}
... | php | protected function hasSelectorPlaceholder($selector)
{
if (! is_array($selector)) {
return false;
}
foreach ($selector as $parts) {
foreach ($parts as $part) {
if (is_array($part)) {
return false;
}
... | [
"protected",
"function",
"hasSelectorPlaceholder",
"(",
"$",
"selector",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"selector",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"selector",
"as",
"$",
"parts",
")",
"{",
"foreach",
"... | Has selector placeholder?
@param array $selector
@return boolean | [
"Has",
"selector",
"placeholder?"
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Contrib/scssphp/src/Compiler.php#L1290-L1308 |
benjaminkott/bootstrap_package | Contrib/scssphp/src/Compiler.php | Compiler.compileChild | protected function compileChild($child, OutputBlock $out)
{
$this->sourceIndex = isset($child[Parser::SOURCE_INDEX]) ? $child[Parser::SOURCE_INDEX] : null;
$this->sourceLine = isset($child[Parser::SOURCE_LINE]) ? $child[Parser::SOURCE_LINE] : -1;
$this->sourceColumn = isset($child[Parser:... | php | protected function compileChild($child, OutputBlock $out)
{
$this->sourceIndex = isset($child[Parser::SOURCE_INDEX]) ? $child[Parser::SOURCE_INDEX] : null;
$this->sourceLine = isset($child[Parser::SOURCE_LINE]) ? $child[Parser::SOURCE_LINE] : -1;
$this->sourceColumn = isset($child[Parser:... | [
"protected",
"function",
"compileChild",
"(",
"$",
"child",
",",
"OutputBlock",
"$",
"out",
")",
"{",
"$",
"this",
"->",
"sourceIndex",
"=",
"isset",
"(",
"$",
"child",
"[",
"Parser",
"::",
"SOURCE_INDEX",
"]",
")",
"?",
"$",
"child",
"[",
"Parser",
":... | Compile child; returns a value to halt execution
@param array $child
@param \Leafo\ScssPhp\Formatter\OutputBlock $out
@return array | [
"Compile",
"child",
";",
"returns",
"a",
"value",
"to",
"halt",
"execution"
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Contrib/scssphp/src/Compiler.php#L1575-L1950 |
benjaminkott/bootstrap_package | Contrib/scssphp/src/Compiler.php | Compiler.multiplySelectors | protected function multiplySelectors(Environment $env)
{
$envs = $this->compactEnv($env);
$selectors = [];
$parentSelectors = [[]];
while ($env = array_pop($envs)) {
if (empty($env->selectors)) {
continue;
}
if ($e... | php | protected function multiplySelectors(Environment $env)
{
$envs = $this->compactEnv($env);
$selectors = [];
$parentSelectors = [[]];
while ($env = array_pop($envs)) {
if (empty($env->selectors)) {
continue;
}
if ($e... | [
"protected",
"function",
"multiplySelectors",
"(",
"Environment",
"$",
"env",
")",
"{",
"$",
"envs",
"=",
"$",
"this",
"->",
"compactEnv",
"(",
"$",
"env",
")",
";",
"$",
"selectors",
"=",
"[",
"]",
";",
"$",
"parentSelectors",
"=",
"[",
"[",
"]",
"]... | Find the final set of selectors
@param \Leafo\ScssPhp\Compiler\Environment $env
@return array | [
"Find",
"the",
"final",
"set",
"of",
"selectors"
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Contrib/scssphp/src/Compiler.php#L2914-L2945 |
benjaminkott/bootstrap_package | Classes/ViewHelpers/ExternalMediaViewHelper.php | ExternalMediaViewHelper.renderStatic | public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
) {
$variableProvider = $renderingContext->getVariableProvider();
$externalMediaUtility = GeneralUtility::makeInstance(ExternalMediaUtility::cla... | php | public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
) {
$variableProvider = $renderingContext->getVariableProvider();
$externalMediaUtility = GeneralUtility::makeInstance(ExternalMediaUtility::cla... | [
"public",
"static",
"function",
"renderStatic",
"(",
"array",
"$",
"arguments",
",",
"\\",
"Closure",
"$",
"renderChildrenClosure",
",",
"RenderingContextInterface",
"$",
"renderingContext",
")",
"{",
"$",
"variableProvider",
"=",
"$",
"renderingContext",
"->",
"get... | Checks if the URL is a valid YouTube/Vimeo Link is. If the video id can
be extracted the embed code will be returned, else the content of the
ViewHelper will be displayed.
@param array $arguments
@param \Closure $renderChildrenClosure
@param RenderingContextInterface $renderingContext
@return string | [
"Checks",
"if",
"the",
"URL",
"is",
"a",
"valid",
"YouTube",
"/",
"Vimeo",
"Link",
"is",
".",
"If",
"the",
"video",
"id",
"can",
"be",
"extracted",
"the",
"embed",
"code",
"will",
"be",
"returned",
"else",
"the",
"content",
"of",
"the",
"ViewHelper",
"... | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Classes/ViewHelpers/ExternalMediaViewHelper.php#L52-L64 |
benjaminkott/bootstrap_package | Classes/Service/InstallService.php | InstallService.createConfigurationFile | private function createConfigurationFile($filename)
{
$absFilename = GeneralUtility::getFileAbsFileName($filename);
if (file_exists($absFilename)) {
// Add Flashmessage that there is already an configuration file and we are not going to override this.
$flashMessage = GeneralU... | php | private function createConfigurationFile($filename)
{
$absFilename = GeneralUtility::getFileAbsFileName($filename);
if (file_exists($absFilename)) {
// Add Flashmessage that there is already an configuration file and we are not going to override this.
$flashMessage = GeneralU... | [
"private",
"function",
"createConfigurationFile",
"(",
"$",
"filename",
")",
"{",
"$",
"absFilename",
"=",
"GeneralUtility",
"::",
"getFileAbsFileName",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"absFilename",
")",
")",
"{",
"// Add F... | Creates webserver configuration file inside the root directory
@param $filename | [
"Creates",
"webserver",
"configuration",
"file",
"inside",
"the",
"root",
"directory"
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Classes/Service/InstallService.php#L59-L90 |
benjaminkott/bootstrap_package | Classes/Service/InstallService.php | InstallService.addFlashMessage | public function addFlashMessage(FlashMessage $flashMessage)
{
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
$flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($this->messageQueueByIdentifier);
$flashMessageQueue->enqueue($flashMessage);
... | php | public function addFlashMessage(FlashMessage $flashMessage)
{
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
$flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($this->messageQueueByIdentifier);
$flashMessageQueue->enqueue($flashMessage);
... | [
"public",
"function",
"addFlashMessage",
"(",
"FlashMessage",
"$",
"flashMessage",
")",
"{",
"$",
"flashMessageService",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"FlashMessageService",
"::",
"class",
")",
";",
"$",
"flashMessageQueue",
"=",
"$",
"flashMessa... | Adds a Flash Message to the Flash Message Queue
@param FlashMessage $flashMessage | [
"Adds",
"a",
"Flash",
"Message",
"to",
"the",
"Flash",
"Message",
"Queue"
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Classes/Service/InstallService.php#L97-L102 |
benjaminkott/bootstrap_package | Classes/Utility/ExternalMediaUtility.php | ExternalMediaUtility.getEmbedCode | public function getEmbedCode($url, $class)
{
// Prepare url
$url = $this->setProtocolToHttps($url);
// Get method
$method = $this->getMethod($url);
if ($method !== null) {
$embedUrl = $this->{$method}($url);
if ($embedUrl) {
return '<if... | php | public function getEmbedCode($url, $class)
{
// Prepare url
$url = $this->setProtocolToHttps($url);
// Get method
$method = $this->getMethod($url);
if ($method !== null) {
$embedUrl = $this->{$method}($url);
if ($embedUrl) {
return '<if... | [
"public",
"function",
"getEmbedCode",
"(",
"$",
"url",
",",
"$",
"class",
")",
"{",
"// Prepare url",
"$",
"url",
"=",
"$",
"this",
"->",
"setProtocolToHttps",
"(",
"$",
"url",
")",
";",
"// Get method",
"$",
"method",
"=",
"$",
"this",
"->",
"getMethod"... | Get the embed code for the given url if possible
and add a css class on the iframe
@param string $url
@param string $class
@return string | [
"Get",
"the",
"embed",
"code",
"for",
"the",
"given",
"url",
"if",
"possible",
"and",
"add",
"a",
"css",
"class",
"on",
"the",
"iframe"
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Classes/Utility/ExternalMediaUtility.php#L37-L54 |
benjaminkott/bootstrap_package | Classes/Utility/ExternalMediaUtility.php | ExternalMediaUtility.getMethod | protected function getMethod($url)
{
$urlInformation = @parse_url($url);
$hostName = GeneralUtility::trimExplode('.', $urlInformation['host'], true);
foreach ($this->mediaProvider as $provider) {
$functionName = 'process' . ucfirst($provider);
if (in_array($provider, ... | php | protected function getMethod($url)
{
$urlInformation = @parse_url($url);
$hostName = GeneralUtility::trimExplode('.', $urlInformation['host'], true);
foreach ($this->mediaProvider as $provider) {
$functionName = 'process' . ucfirst($provider);
if (in_array($provider, ... | [
"protected",
"function",
"getMethod",
"(",
"$",
"url",
")",
"{",
"$",
"urlInformation",
"=",
"@",
"parse_url",
"(",
"$",
"url",
")",
";",
"$",
"hostName",
"=",
"GeneralUtility",
"::",
"trimExplode",
"(",
"'.'",
",",
"$",
"urlInformation",
"[",
"'host'",
... | Resolves if possible a method name to process the url
@param string $url
@return string|null | [
"Resolves",
"if",
"possible",
"a",
"method",
"name",
"to",
"process",
"the",
"url"
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Classes/Utility/ExternalMediaUtility.php#L62-L73 |
benjaminkott/bootstrap_package | Classes/Utility/ExternalMediaUtility.php | ExternalMediaUtility.processYoutube | protected function processYoutube($url)
{
$firstMatches = [];
$pattern = '%^(?:https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=))([^"&?/ ]{11})(?:.+)?$%xs';
if (preg_match($pattern, $url, $firstMatches)) {
$toEmbed = $firstMatches[1];
... | php | protected function processYoutube($url)
{
$firstMatches = [];
$pattern = '%^(?:https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=))([^"&?/ ]{11})(?:.+)?$%xs';
if (preg_match($pattern, $url, $firstMatches)) {
$toEmbed = $firstMatches[1];
... | [
"protected",
"function",
"processYoutube",
"(",
"$",
"url",
")",
"{",
"$",
"firstMatches",
"=",
"[",
"]",
";",
"$",
"pattern",
"=",
"'%^(?:https?://)?(?:www\\.)?(?:youtu\\.be/|youtube\\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=))([^\"&?/ ]{11})(?:.+)?$%xs'",
";",
"if",
"(",... | Processes YouTube url
@param string $url
@return string | [
"Processes",
"YouTube",
"url"
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Classes/Utility/ExternalMediaUtility.php#L81-L95 |
benjaminkott/bootstrap_package | Classes/Utility/ExternalMediaUtility.php | ExternalMediaUtility.setProtocolToHttps | protected function setProtocolToHttps($url)
{
$processUrl = trim($url);
if (strpos($url, 'http://') === 0) {
$processUrl = substr($processUrl, 7);
} elseif (strpos($processUrl, 'https://') === 0) {
$processUrl = substr($processUrl, 8);
} elseif (strpos($proces... | php | protected function setProtocolToHttps($url)
{
$processUrl = trim($url);
if (strpos($url, 'http://') === 0) {
$processUrl = substr($processUrl, 7);
} elseif (strpos($processUrl, 'https://') === 0) {
$processUrl = substr($processUrl, 8);
} elseif (strpos($proces... | [
"protected",
"function",
"setProtocolToHttps",
"(",
"$",
"url",
")",
"{",
"$",
"processUrl",
"=",
"trim",
"(",
"$",
"url",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"url",
",",
"'http://'",
")",
"===",
"0",
")",
"{",
"$",
"processUrl",
"=",
"substr",
... | Change every protocol to https and add it if missing
@param string $url URL
@return string | [
"Change",
"every",
"protocol",
"to",
"https",
"and",
"add",
"it",
"if",
"missing"
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Classes/Utility/ExternalMediaUtility.php#L129-L140 |
benjaminkott/bootstrap_package | Classes/Hooks/PageRenderer/PreProcessHook.php | PreProcessHook.getCompileService | protected function getCompileService()
{
if ($this->compileService === null) {
$this->compileService = GeneralUtility::makeInstance(CompileService::class);
}
return $this->compileService;
} | php | protected function getCompileService()
{
if ($this->compileService === null) {
$this->compileService = GeneralUtility::makeInstance(CompileService::class);
}
return $this->compileService;
} | [
"protected",
"function",
"getCompileService",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"compileService",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"compileService",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"CompileService",
"::",
"class",
")",
... | Get the compile service
@return CompileService | [
"Get",
"the",
"compile",
"service"
] | train | https://github.com/benjaminkott/bootstrap_package/blob/b8f7d912ffbba89cea638566d59cad01c87971a5/Classes/Hooks/PageRenderer/PreProcessHook.php#L56-L62 |
potsky/PimpMyLog | inc/classes/LogParser.php | LogParser.getNewLines | public static function getNewLines( $regex , $match , $types , $tz , $wanted_lines , $exclude , $file_path , $start_offset , $start_from , $load_more , $old_lastline , $multiline , $search , $data_to_parse , $full , $max_search_log_time )
{
$fl = fopen( $file_path , "r" );
if ( $fl === false )
{
return '1';
... | php | public static function getNewLines( $regex , $match , $types , $tz , $wanted_lines , $exclude , $file_path , $start_offset , $start_from , $load_more , $old_lastline , $multiline , $search , $data_to_parse , $full , $max_search_log_time )
{
$fl = fopen( $file_path , "r" );
if ( $fl === false )
{
return '1';
... | [
"public",
"static",
"function",
"getNewLines",
"(",
"$",
"regex",
",",
"$",
"match",
",",
"$",
"types",
",",
"$",
"tz",
",",
"$",
"wanted_lines",
",",
"$",
"exclude",
",",
"$",
"file_path",
",",
"$",
"start_offset",
",",
"$",
"start_from",
",",
"$",
... | Read a log file and return an array of logs with metadata
@param string $regex A regex to match each line
@param array $match An array of matchers
@param array $types An array of matchers types
@param string $tz The wanted timezone to translate matchers with a date type... | [
"Read",
"a",
"log",
"file",
"and",
"return",
"an",
"array",
"of",
"logs",
"with",
"metadata"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/LogParser.php#L29-L316 |
potsky/PimpMyLog | inc/classes/LogParser.php | LogParser.getLinesFromBottom | public static function getLinesFromBottom( $file , $count = 1 )
{
$fl = @fopen( $file , "r" );
$lines = array();
$bytes = 0;
if ( $fl === false )
{
return false;
}
$count = max( 1 , (int)$count );
for ( $x_pos = 0 , $ln = 0 , $line = '' , $still = true ; $still ; $x_pos-- )
{
if ( fseek(... | php | public static function getLinesFromBottom( $file , $count = 1 )
{
$fl = @fopen( $file , "r" );
$lines = array();
$bytes = 0;
if ( $fl === false )
{
return false;
}
$count = max( 1 , (int)$count );
for ( $x_pos = 0 , $ln = 0 , $line = '' , $still = true ; $still ; $x_pos-- )
{
if ( fseek(... | [
"public",
"static",
"function",
"getLinesFromBottom",
"(",
"$",
"file",
",",
"$",
"count",
"=",
"1",
")",
"{",
"$",
"fl",
"=",
"@",
"fopen",
"(",
"$",
"file",
",",
"\"r\"",
")",
";",
"$",
"lines",
"=",
"array",
"(",
")",
";",
"$",
"bytes",
"=",
... | Read lines from the bottom of giver file
@param string $file the file path
@param integer $count the count of wanted lines
@return array an array of read lines or false of fiel error | [
"Read",
"lines",
"from",
"the",
"bottom",
"of",
"giver",
"file"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/LogParser.php#L327-L379 |
potsky/PimpMyLog | inc/classes/LogParser.php | LogParser.parseLine | public static function parseLine( $regex , $match , $log , $types , $tz = null )
{
// If line is non matchable, return
preg_match_all( $regex , $log , $out , PREG_PATTERN_ORDER );
if ( @count( $out[ 0 ] ) === 0 )
{
return false;
}
$result = array();
$timestamp = 0;
foreach ( $match as $token =>... | php | public static function parseLine( $regex , $match , $log , $types , $tz = null )
{
// If line is non matchable, return
preg_match_all( $regex , $log , $out , PREG_PATTERN_ORDER );
if ( @count( $out[ 0 ] ) === 0 )
{
return false;
}
$result = array();
$timestamp = 0;
foreach ( $match as $token =>... | [
"public",
"static",
"function",
"parseLine",
"(",
"$",
"regex",
",",
"$",
"match",
",",
"$",
"log",
",",
"$",
"types",
",",
"$",
"tz",
"=",
"null",
")",
"{",
"// If line is non matchable, return",
"preg_match_all",
"(",
"$",
"regex",
",",
"$",
"log",
","... | A line of log parser
@param string $regex The regex which describes the user log format
@param array $match An array which links internal tokens to regex matches
@param string $log The text log
@param string $types A array of types for fields
@param string $tz A time zone identifier
@return mixed A... | [
"A",
"line",
"of",
"log",
"parser"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/LogParser.php#L394-L520 |
potsky/PimpMyLog | inc/classes/Session.php | Session.start | public static function start( $path = '' , $lifetime = 0 ) {
if ( self::$sessionState === self::SESSION_NOT_STARTED ) {
if ( empty( $path ) ) {
$sub = array( 'inc' );
$url = parse_url( get_current_url() );
// we add a string on bottom to manage url... | php | public static function start( $path = '' , $lifetime = 0 ) {
if ( self::$sessionState === self::SESSION_NOT_STARTED ) {
if ( empty( $path ) ) {
$sub = array( 'inc' );
$url = parse_url( get_current_url() );
// we add a string on bottom to manage url... | [
"public",
"static",
"function",
"start",
"(",
"$",
"path",
"=",
"''",
",",
"$",
"lifetime",
"=",
"0",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"sessionState",
"===",
"self",
"::",
"SESSION_NOT_STARTED",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"path",
... | Overwrite the original session start to specify a path at root of the installation
If you have several instances of PML on the same server with different paths,
authentication has to be managed distinctly
@param string $path the path of the cookie
@param integer $lifetime the lifetime of the cookie
@ret... | [
"Overwrite",
"the",
"original",
"session",
"start",
"to",
"specify",
"a",
"path",
"at",
"root",
"of",
"the",
"installation"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Session.php#L21-L49 |
potsky/PimpMyLog | inc/classes/Session.php | Session.write_close | public static function write_close() {
if ( self::$sessionState === self::SESSION_STARTED ) {
self::$sessionState = self::SESSION_NOT_STARTED;
return session_write_close();
}
return true;
} | php | public static function write_close() {
if ( self::$sessionState === self::SESSION_STARTED ) {
self::$sessionState = self::SESSION_NOT_STARTED;
return session_write_close();
}
return true;
} | [
"public",
"static",
"function",
"write_close",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"sessionState",
"===",
"self",
"::",
"SESSION_STARTED",
")",
"{",
"self",
"::",
"$",
"sessionState",
"=",
"self",
"::",
"SESSION_NOT_STARTED",
";",
"return",
"session... | Write the tmp file and close it
@return bool | [
"Write",
"the",
"tmp",
"file",
"and",
"close",
"it"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Session.php#L57-L66 |
potsky/PimpMyLog | inc/classes/Feedcreator.php | HtmlDescribable.getDescription | function getDescription() {
$descriptionField = new FeedHtmlField($this->description);
$descriptionField->syndicateHtml = $this->descriptionHtmlSyndicated;
$descriptionField->truncSize = $this->descriptionTruncSize;
return $descriptionField->output();
} | php | function getDescription() {
$descriptionField = new FeedHtmlField($this->description);
$descriptionField->syndicateHtml = $this->descriptionHtmlSyndicated;
$descriptionField->truncSize = $this->descriptionTruncSize;
return $descriptionField->output();
} | [
"function",
"getDescription",
"(",
")",
"{",
"$",
"descriptionField",
"=",
"new",
"FeedHtmlField",
"(",
"$",
"this",
"->",
"description",
")",
";",
"$",
"descriptionField",
"->",
"syndicateHtml",
"=",
"$",
"this",
"->",
"descriptionHtmlSyndicated",
";",
"$",
"... | Returns a formatted description field, depending on descriptionHtmlSyndicated and
$descriptionTruncSize properties
@return string the formatted description | [
"Returns",
"a",
"formatted",
"description",
"field",
"depending",
"on",
"descriptionHtmlSyndicated",
"and",
"$descriptionTruncSize",
"properties"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Feedcreator.php#L120-L125 |
potsky/PimpMyLog | inc/classes/Feedcreator.php | FeedHtmlField.output | function output() {
// when field available and syndicated in html we assume
// - valid html in $rawFieldContent and we enclose in CDATA tags
// - no truncation (truncating risks producing invalid html)
if (!$this->rawFieldContent) {
$result = "";
} elseif ($this->syndicateHtml) {
$result = "<![C... | php | function output() {
// when field available and syndicated in html we assume
// - valid html in $rawFieldContent and we enclose in CDATA tags
// - no truncation (truncating risks producing invalid html)
if (!$this->rawFieldContent) {
$result = "";
} elseif ($this->syndicateHtml) {
$result = "<![C... | [
"function",
"output",
"(",
")",
"{",
"// when field available and syndicated in html we assume\r",
"// - valid html in $rawFieldContent and we enclose in CDATA tags\r",
"// - no truncation (truncating risks producing invalid html)\r",
"if",
"(",
"!",
"$",
"this",
"->",
"rawFieldContent",... | Creates the right output, depending on $truncSize, $syndicateHtml properties.
@return string the formatted field | [
"Creates",
"the",
"right",
"output",
"depending",
"on",
"$truncSize",
"$syndicateHtml",
"properties",
"."
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Feedcreator.php#L165-L181 |
potsky/PimpMyLog | inc/classes/Feedcreator.php | UniversalFeedCreator.outputFeed | function outputFeed( $timezone , $format='RSS2.0' ) {
$this->_setFormat( $format );
$this->_setMIME( $format );
$this->_feed->outputFeed( $timezone , $format );
} | php | function outputFeed( $timezone , $format='RSS2.0' ) {
$this->_setFormat( $format );
$this->_setMIME( $format );
$this->_feed->outputFeed( $timezone , $format );
} | [
"function",
"outputFeed",
"(",
"$",
"timezone",
",",
"$",
"format",
"=",
"'RSS2.0'",
")",
"{",
"$",
"this",
"->",
"_setFormat",
"(",
"$",
"format",
")",
";",
"$",
"this",
"->",
"_setMIME",
"(",
"$",
"format",
")",
";",
"$",
"this",
"->",
"_feed",
"... | Outputs feed to the browser - needed for on-the-fly feed generation (like it is done in WordPress, etc.)
@param format string format the feed should comply to. Valid values are:
"PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM0.3". | [
"Outputs",
"feed",
"to",
"the",
"browser",
"-",
"needed",
"for",
"on",
"-",
"the",
"-",
"fly",
"feed",
"generation",
"(",
"like",
"it",
"is",
"done",
"in",
"WordPress",
"etc",
".",
")"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Feedcreator.php#L281-L285 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.attempt | public static function attempt( $files = false )
{
if ( self::isAuthSet() ) { // authentication is enabled on this instance
$user = self::getCurrentUsername();
if ( is_null( $user ) ) { // no logged in user
if ( isset( $_POST['attempt'] ) ) { // form is posted
if ( ! csrf_verify() ) {
$atte... | php | public static function attempt( $files = false )
{
if ( self::isAuthSet() ) { // authentication is enabled on this instance
$user = self::getCurrentUsername();
if ( is_null( $user ) ) { // no logged in user
if ( isset( $_POST['attempt'] ) ) { // form is posted
if ( ! csrf_verify() ) {
$atte... | [
"public",
"static",
"function",
"attempt",
"(",
"$",
"files",
"=",
"false",
")",
"{",
"if",
"(",
"self",
"::",
"isAuthSet",
"(",
")",
")",
"{",
"// authentication is enabled on this instance",
"$",
"user",
"=",
"self",
"::",
"getCurrentUsername",
"(",
")",
"... | Manage login
@param array $files the files configuration
@return [type] [description] | [
"Manage",
"login"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L20-L102 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.changePassword | public static function changePassword($username , $new_password)
{
self::setUser( $username , $new_password );
self::log( 'changepwd' , $username );
self::save();
return true;
} | php | public static function changePassword($username , $new_password)
{
self::setUser( $username , $new_password );
self::log( 'changepwd' , $username );
self::save();
return true;
} | [
"public",
"static",
"function",
"changePassword",
"(",
"$",
"username",
",",
"$",
"new_password",
")",
"{",
"self",
"::",
"setUser",
"(",
"$",
"username",
",",
"$",
"new_password",
")",
";",
"self",
"::",
"log",
"(",
"'changepwd'",
",",
"$",
"username",
... | Change the password with logging
@param string $username the username
@param string $new_password the new password
@return boolean true | [
"Change",
"the",
"password",
"with",
"logging"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L112-L119 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.create | public static function create()
{
if ( file_exists( self::$authFile ) ) return false;
if ( @touch( self::$authFile ) === false ) return false;
self::$auth = array(
'generated' => date('U'),
'security' => self::generateSecurityToken(),
'anonymous' => array(),
'users' => array(),
);
self::sa... | php | public static function create()
{
if ( file_exists( self::$authFile ) ) return false;
if ( @touch( self::$authFile ) === false ) return false;
self::$auth = array(
'generated' => date('U'),
'security' => self::generateSecurityToken(),
'anonymous' => array(),
'users' => array(),
);
self::sa... | [
"public",
"static",
"function",
"create",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"self",
"::",
"$",
"authFile",
")",
")",
"return",
"false",
";",
"if",
"(",
"@",
"touch",
"(",
"self",
"::",
"$",
"authFile",
")",
"===",
"false",
")",
"return",
... | Create a new authentication file
@return boolean true if ok or false if error or if already exists | [
"Create",
"a",
"new",
"authentication",
"file"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L126-L141 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.deleteUser | public static function deleteUser($username)
{
if ( ! self::userExists( $username ) ) return false;
$deleted_user = self::$auth['users'][ $username ];
unset( self::$auth['users'][ $username ] );
return $deleted_user;
} | php | public static function deleteUser($username)
{
if ( ! self::userExists( $username ) ) return false;
$deleted_user = self::$auth['users'][ $username ];
unset( self::$auth['users'][ $username ] );
return $deleted_user;
} | [
"public",
"static",
"function",
"deleteUser",
"(",
"$",
"username",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"userExists",
"(",
"$",
"username",
")",
")",
"return",
"false",
";",
"$",
"deleted_user",
"=",
"self",
"::",
"$",
"auth",
"[",
"'users'",
"]",
... | Delete a user
@param string $username the username to delete
@return array the deleted user or false if not exists | [
"Delete",
"a",
"user"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L150-L158 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.getClientIp | public static function getClientIp()
{
$ip = '';
if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif ( isset( $_SERVER['HTTP_X_FORWARDED'] ) ) {
$ip = $_SERVER['HTTP_X_F... | php | public static function getClientIp()
{
$ip = '';
if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif ( isset( $_SERVER['HTTP_X_FORWARDED'] ) ) {
$ip = $_SERVER['HTTP_X_F... | [
"public",
"static",
"function",
"getClientIp",
"(",
")",
"{",
"$",
"ip",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_CLIENT_IP'",
"]",
")",
")",
"{",
"$",
"ip",
"=",
"$",
"_SERVER",
"[",
"'HTTP_CLIENT_IP'",
"]",
";",
"}",
"... | Get the local ip address of the current client according to proxy and more...
@return string an ip address | [
"Get",
"the",
"local",
"ip",
"address",
"of",
"the",
"current",
"client",
"according",
"to",
"proxy",
"and",
"more",
"..."
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L191-L209 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.getCurrentUsername | public static function getCurrentUsername()
{
if ( is_array( self::$api_session ) ) {
$auth = self::$api_session;
} else {
$auth = self::sessionRead();
}
return ( isset( $auth['username'] ) ) ? $auth['username'] : null;
} | php | public static function getCurrentUsername()
{
if ( is_array( self::$api_session ) ) {
$auth = self::$api_session;
} else {
$auth = self::sessionRead();
}
return ( isset( $auth['username'] ) ) ? $auth['username'] : null;
} | [
"public",
"static",
"function",
"getCurrentUsername",
"(",
")",
"{",
"if",
"(",
"is_array",
"(",
"self",
"::",
"$",
"api_session",
")",
")",
"{",
"$",
"auth",
"=",
"self",
"::",
"$",
"api_session",
";",
"}",
"else",
"{",
"$",
"auth",
"=",
"self",
"::... | Get the current logged in user or null
@return string the current username or null | [
"Get",
"the",
"current",
"logged",
"in",
"user",
"or",
"null"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L216-L224 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.getUser | public static function getUser($username = null)
{
if ( is_null( $username ) ) $username = self::getCurrentUsername();
if ( self::userExists( $username ) ) {
return self::$auth['users'][ $username ];
}
return null;
} | php | public static function getUser($username = null)
{
if ( is_null( $username ) ) $username = self::getCurrentUsername();
if ( self::userExists( $username ) ) {
return self::$auth['users'][ $username ];
}
return null;
} | [
"public",
"static",
"function",
"getUser",
"(",
"$",
"username",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"username",
")",
")",
"$",
"username",
"=",
"self",
"::",
"getCurrentUsername",
"(",
")",
";",
"if",
"(",
"self",
"::",
"userExists"... | Return the data of a user
@param string $username the username
@return array data or null if not exists | [
"Return",
"the",
"data",
"of",
"a",
"user"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L247-L256 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.getUsernameFromAccessToken | public static function getUsernameFromAccessToken( $accesstoken ) {
$users = self::getUsers();
foreach( $users as $username => $user ) {
if ( $user['at'] === $accesstoken ) {
return $username;
}
}
return null;
} | php | public static function getUsernameFromAccessToken( $accesstoken ) {
$users = self::getUsers();
foreach( $users as $username => $user ) {
if ( $user['at'] === $accesstoken ) {
return $username;
}
}
return null;
} | [
"public",
"static",
"function",
"getUsernameFromAccessToken",
"(",
"$",
"accesstoken",
")",
"{",
"$",
"users",
"=",
"self",
"::",
"getUsers",
"(",
")",
";",
"foreach",
"(",
"$",
"users",
"as",
"$",
"username",
"=>",
"$",
"user",
")",
"{",
"if",
"(",
"$... | Find a user from its access token
@param string $accesstoken the access token
@return string username or null | [
"Find",
"a",
"user",
"from",
"its",
"access",
"token"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L265-L273 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.getUsers | public static function getUsers()
{
if ( ! is_array( self::$auth ) ) throw new Exception( 'Authentication not initialized' );
if ( isset( self::$auth['users'] ) ) {
return self::$auth['users'];
} else {
return array();
}
} | php | public static function getUsers()
{
if ( ! is_array( self::$auth ) ) throw new Exception( 'Authentication not initialized' );
if ( isset( self::$auth['users'] ) ) {
return self::$auth['users'];
} else {
return array();
}
} | [
"public",
"static",
"function",
"getUsers",
"(",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"self",
"::",
"$",
"auth",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Authentication not initialized'",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
... | Return the array of users
@return array the users | [
"Return",
"the",
"array",
"of",
"users"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L280-L289 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.init | public static function init()
{
self::$authFile = self::getAuthFilePath();
if ( self::isAuthSet() ) {
self::reload();
}
return true;
} | php | public static function init()
{
self::$authFile = self::getAuthFilePath();
if ( self::isAuthSet() ) {
self::reload();
}
return true;
} | [
"public",
"static",
"function",
"init",
"(",
")",
"{",
"self",
"::",
"$",
"authFile",
"=",
"self",
"::",
"getAuthFilePath",
"(",
")",
";",
"if",
"(",
"self",
"::",
"isAuthSet",
"(",
")",
")",
"{",
"self",
"::",
"reload",
"(",
")",
";",
"}",
"return... | Set file, etc...
@return boolean success or not | [
"Set",
"file",
"etc",
"..."
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L306-L314 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.isAnonymousEnabled | public static function isAnonymousEnabled( $files = false )
{
if ( ! isset( self::$auth['anonymous'] ) ) return false;
if ( ! is_array( self::$auth['anonymous'] ) ) return false;
if ( $files === false ) {
return ( count( self::$auth['anonymous'] ) > 0 );
}
$found = 0;
foreach( self::$auth['anonymous']... | php | public static function isAnonymousEnabled( $files = false )
{
if ( ! isset( self::$auth['anonymous'] ) ) return false;
if ( ! is_array( self::$auth['anonymous'] ) ) return false;
if ( $files === false ) {
return ( count( self::$auth['anonymous'] ) > 0 );
}
$found = 0;
foreach( self::$auth['anonymous']... | [
"public",
"static",
"function",
"isAnonymousEnabled",
"(",
"$",
"files",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"auth",
"[",
"'anonymous'",
"]",
")",
")",
"return",
"false",
";",
"if",
"(",
"!",
"is_array",
"(",
"sel... | Tell if at least one log file is accessible anonymously
The $files parameter is optional. If given, it will check if all anonymous files still exist.
If they do not exist, they must be erased and they do not count for this check.
@param array $files The files configuration
@return boolean | [
"Tell",
"if",
"at",
"least",
"one",
"log",
"file",
"is",
"accessible",
"anonymously"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L338-L353 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.isSignValid | public static function isSignValid( $given_sign , $values , $username = null ) {
return ( self::sign( $values , $username ) === $given_sign );
} | php | public static function isSignValid( $given_sign , $values , $username = null ) {
return ( self::sign( $values , $username ) === $given_sign );
} | [
"public",
"static",
"function",
"isSignValid",
"(",
"$",
"given_sign",
",",
"$",
"values",
",",
"$",
"username",
"=",
"null",
")",
"{",
"return",
"(",
"self",
"::",
"sign",
"(",
"$",
"values",
",",
"$",
"username",
")",
"===",
"$",
"given_sign",
")",
... | Tell whether a signature is valid for given values or not
@param string $given_sign the provided signature
@param array $values an array of values to certify
@param string $username the user who has signed values or null for an instance signature
@return boolean ok or not | [
"Tell",
"whether",
"a",
"signature",
"is",
"valid",
"for",
"given",
"values",
"or",
"not"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L386-L388 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.isValidPassword | public static function isValidPassword($username , $password)
{
if ( ! self::userExists( $username ) ) return false;
$compute = self::getPasswordHash($username , $password);
return ( $compute === self::$auth['users'][$username]['pwd'] );
} | php | public static function isValidPassword($username , $password)
{
if ( ! self::userExists( $username ) ) return false;
$compute = self::getPasswordHash($username , $password);
return ( $compute === self::$auth['users'][$username]['pwd'] );
} | [
"public",
"static",
"function",
"isValidPassword",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"userExists",
"(",
"$",
"username",
")",
")",
"return",
"false",
";",
"$",
"compute",
"=",
"self",
"::",
"getPasswordHa... | Tell whether a password is valid or not
@param string $username the username
@param string $password the password
@return boolean | [
"Tell",
"whether",
"a",
"password",
"is",
"valid",
"or",
"not"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L398-L404 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.log | public static function log($action , $username = null , $timestamp = null , $ip = null , $useragent = null)
{
if ( ! is_array( self::$auth ) ) throw new Exception( 'Authentication not initialized' );
if ( ! isset( self::$auth['logs'] ) ) {
self::$auth['logs'] = array();
}
if ( is_null( $username ) ) $user... | php | public static function log($action , $username = null , $timestamp = null , $ip = null , $useragent = null)
{
if ( ! is_array( self::$auth ) ) throw new Exception( 'Authentication not initialized' );
if ( ! isset( self::$auth['logs'] ) ) {
self::$auth['logs'] = array();
}
if ( is_null( $username ) ) $user... | [
"public",
"static",
"function",
"log",
"(",
"$",
"action",
",",
"$",
"username",
"=",
"null",
",",
"$",
"timestamp",
"=",
"null",
",",
"$",
"ip",
"=",
"null",
",",
"$",
"useragent",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"self",
... | Log an action
@param string $action the action text
@param string $username the username or null for the current logged in user
@param int $timestamp the action timestamp
@param string $ip the IP address
@param string $useragent the user agent
@return bool true | [
"Log",
"an",
"action"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L417-L433 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.release | public static function release()
{
if ( is_null( self::$authFileP ) ) return;
$a = @flock( self::$authFileP , LOCK_UN );
@fclose( self::$authFileP );
self::$authFileP = null;
self::$currentlylocked = false;
} | php | public static function release()
{
if ( is_null( self::$authFileP ) ) return;
$a = @flock( self::$authFileP , LOCK_UN );
@fclose( self::$authFileP );
self::$authFileP = null;
self::$currentlylocked = false;
} | [
"public",
"static",
"function",
"release",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"authFileP",
")",
")",
"return",
";",
"$",
"a",
"=",
"@",
"flock",
"(",
"self",
"::",
"$",
"authFileP",
",",
"LOCK_UN",
")",
";",
"@",
"fclose",... | Release the database file
@return boolean | [
"Release",
"the",
"database",
"file"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L440-L447 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.reload | public static function reload()
{
$content = preg_replace('/^.+\n/', '', self::read() );
$array = json_decode( $content , true );
if ( is_null( $array ) ) {
return false;
}
self::$auth = $array;
return true;
} | php | public static function reload()
{
$content = preg_replace('/^.+\n/', '', self::read() );
$array = json_decode( $content , true );
if ( is_null( $array ) ) {
return false;
}
self::$auth = $array;
return true;
} | [
"public",
"static",
"function",
"reload",
"(",
")",
"{",
"$",
"content",
"=",
"preg_replace",
"(",
"'/^.+\\n/'",
",",
"''",
",",
"self",
"::",
"read",
"(",
")",
")",
";",
"$",
"array",
"=",
"json_decode",
"(",
"$",
"content",
",",
"true",
")",
";",
... | Just get the auth file and load it in the $auth variable
@return boolean success or not | [
"Just",
"get",
"the",
"auth",
"file",
"and",
"load",
"it",
"in",
"the",
"$auth",
"variable"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L454-L464 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.save | public static function save()
{
self::lock();
if ( is_null( self::$authFileP ) ) throw new Exception( 'No lock has been requested' );
$file = '<?php if (realpath(__FILE__)===realpath($_SERVER["SCRIPT_FILENAME"])) {header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");die();}?>' . "\n";
$file.= json_encode( sel... | php | public static function save()
{
self::lock();
if ( is_null( self::$authFileP ) ) throw new Exception( 'No lock has been requested' );
$file = '<?php if (realpath(__FILE__)===realpath($_SERVER["SCRIPT_FILENAME"])) {header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");die();}?>' . "\n";
$file.= json_encode( sel... | [
"public",
"static",
"function",
"save",
"(",
")",
"{",
"self",
"::",
"lock",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"authFileP",
")",
")",
"throw",
"new",
"Exception",
"(",
"'No lock has been requested'",
")",
";",
"$",
"file",
"=... | Save modifications on disk
@return boolean | [
"Save",
"modifications",
"on",
"disk"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L471-L482 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.setAdmin | public static function setAdmin($username , $password = null , $logs = null)
{
return self::setUser( $username , $password , $roles = array('admin') , $logs );
} | php | public static function setAdmin($username , $password = null , $logs = null)
{
return self::setUser( $username , $password , $roles = array('admin') , $logs );
} | [
"public",
"static",
"function",
"setAdmin",
"(",
"$",
"username",
",",
"$",
"password",
"=",
"null",
",",
"$",
"logs",
"=",
"null",
")",
"{",
"return",
"self",
"::",
"setUser",
"(",
"$",
"username",
",",
"$",
"password",
",",
"$",
"roles",
"=",
"arra... | Set an admin
@param string $username username
@param string $password password
@param array $logs an array of credentials for log files
@return boolean true | [
"Set",
"an",
"admin"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L493-L496 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.setLogAnonymous | public static function setLogAnonymous( $log , $anonymous )
{
if ( ! is_array( self::$auth ) ) throw new Exception( 'Authentication not initialized' );
$anon = array();
if ( isset( self::$auth['anonymous'] ) ) {
$anon = self::$auth['anonymous'];
}
if ( $anonymous === true ) {
$anon[] = $log;
$ano... | php | public static function setLogAnonymous( $log , $anonymous )
{
if ( ! is_array( self::$auth ) ) throw new Exception( 'Authentication not initialized' );
$anon = array();
if ( isset( self::$auth['anonymous'] ) ) {
$anon = self::$auth['anonymous'];
}
if ( $anonymous === true ) {
$anon[] = $log;
$ano... | [
"public",
"static",
"function",
"setLogAnonymous",
"(",
"$",
"log",
",",
"$",
"anonymous",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"self",
"::",
"$",
"auth",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Authentication not initialized'",
")",
";",
"$",
... | Set a log anonymous or not
@param string $log the fileid
@param boolean $anonymous true or false
@return boolean true | [
"Set",
"a",
"log",
"anonymous",
"or",
"not"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L506-L527 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.setUser | public static function setUser($username , $password = null , $roles = null , $logs = null , $regeneratetokens = false )
{
if ( ! is_array( self::$auth ) ) throw new Exception( 'Authentication not initialized' );
if ( isset( self::$auth['users'][ $username ] ) ) {
$user = self::$auth['users'][ $username ];
}... | php | public static function setUser($username , $password = null , $roles = null , $logs = null , $regeneratetokens = false )
{
if ( ! is_array( self::$auth ) ) throw new Exception( 'Authentication not initialized' );
if ( isset( self::$auth['users'][ $username ] ) ) {
$user = self::$auth['users'][ $username ];
}... | [
"public",
"static",
"function",
"setUser",
"(",
"$",
"username",
",",
"$",
"password",
"=",
"null",
",",
"$",
"roles",
"=",
"null",
",",
"$",
"logs",
"=",
"null",
",",
"$",
"regeneratetokens",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
... | Set a user
@param string $username username
@param string $password password
@param array $roles an array of global roles
@param array $logs an array of credentials for log files
@param boolean $regeneratetokens whether access tokens should be regenerated or not
@retu... | [
"Set",
"a",
"user"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L540-L568 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.sign | public static function sign( $values , $username = null )
{
if ( ! is_array( self::$auth ) ) throw new Exception( 'Authentication not initialized' );
$presalt = self::$auth['security'];
$values = json_encode( $values );
$postsalt = '';
if ( ! is_null( $username ) ) {
$user = self::getUser( $usern... | php | public static function sign( $values , $username = null )
{
if ( ! is_array( self::$auth ) ) throw new Exception( 'Authentication not initialized' );
$presalt = self::$auth['security'];
$values = json_encode( $values );
$postsalt = '';
if ( ! is_null( $username ) ) {
$user = self::getUser( $usern... | [
"public",
"static",
"function",
"sign",
"(",
"$",
"values",
",",
"$",
"username",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"self",
"::",
"$",
"auth",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Authentication not initialized'",
")",
";",... | Sign values
@param array $values an array of key values to sign
@param string $username the user who signs values or null for an instance signature
@return string the signature of false if a problem occurs | [
"Sign",
"values"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L578-L592 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.signIn | public static function signIn($username , $password)
{
$ip = self::getClientIp();
$ua = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? $_SERVER['HTTP_USER_AGENT'] : '';
$ts = date("U");
if ( self::isValidPassword($username , $password) ) {
self::sessionWrite( array( 'username' => $username ) );
self::reloa... | php | public static function signIn($username , $password)
{
$ip = self::getClientIp();
$ua = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? $_SERVER['HTTP_USER_AGENT'] : '';
$ts = date("U");
if ( self::isValidPassword($username , $password) ) {
self::sessionWrite( array( 'username' => $username ) );
self::reloa... | [
"public",
"static",
"function",
"signIn",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"$",
"ip",
"=",
"self",
"::",
"getClientIp",
"(",
")",
";",
"$",
"ua",
"=",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
")",
")",
... | Sign in user
@param string $username the user to sign in
@param string $password its password
@return array the user informations or false if failed | [
"Sign",
"in",
"user"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L602-L628 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.signInAs | public static function signInAs($username)
{
$ip = self::getClientIp();
$ua = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? $_SERVER['HTTP_USER_AGENT'] : '';
$ts = date("U");
$cu = self::getCurrentUsername();
self::sessionWrite( array( 'username' => $username ) );
self::reload();
self::log( 'signinas ' . ... | php | public static function signInAs($username)
{
$ip = self::getClientIp();
$ua = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? $_SERVER['HTTP_USER_AGENT'] : '';
$ts = date("U");
$cu = self::getCurrentUsername();
self::sessionWrite( array( 'username' => $username ) );
self::reload();
self::log( 'signinas ' . ... | [
"public",
"static",
"function",
"signInAs",
"(",
"$",
"username",
")",
"{",
"$",
"ip",
"=",
"self",
"::",
"getClientIp",
"(",
")",
";",
"$",
"ua",
"=",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
")",
")",
"?",
"$",
"_SERVER",
... | Sign in as a user
@param string $username the user to sign in
@return array the user informations or false if failed | [
"Sign",
"in",
"as",
"a",
"user"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L637-L651 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.signInWithAccessToken | public static function signInWithAccessToken( $accesstoken )
{
$username = self::getUsernameFromAccessToken( $accesstoken );
if ( is_null( $username ) ) return false;
$ip = self::getClientIp();
$ua = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? $_SERVER['HTTP_USER_AGENT'] : '';
$ts = date("U");
$cu = get_c... | php | public static function signInWithAccessToken( $accesstoken )
{
$username = self::getUsernameFromAccessToken( $accesstoken );
if ( is_null( $username ) ) return false;
$ip = self::getClientIp();
$ua = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? $_SERVER['HTTP_USER_AGENT'] : '';
$ts = date("U");
$cu = get_c... | [
"public",
"static",
"function",
"signInWithAccessToken",
"(",
"$",
"accesstoken",
")",
"{",
"$",
"username",
"=",
"self",
"::",
"getUsernameFromAccessToken",
"(",
"$",
"accesstoken",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"username",
")",
")",
"return",
"... | Sign in user with its access token
The signin is only available for this call, no session
@param string $accesstoken
@return array the user informations or false if failed | [
"Sign",
"in",
"user",
"with",
"its",
"access",
"token",
"The",
"signin",
"is",
"only",
"available",
"for",
"this",
"call",
"no",
"session"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L661-L684 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.signOut | public static function signOut()
{
$username = self::getCurrentUsername();
if ( ! is_null( $username ) ) {
$ip = self::getClientIp();
$ua = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? $_SERVER['HTTP_USER_AGENT'] : '';
$ts = date("U");
self::log( 'signout' , $username , $ts , $ip , $u... | php | public static function signOut()
{
$username = self::getCurrentUsername();
if ( ! is_null( $username ) ) {
$ip = self::getClientIp();
$ua = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? $_SERVER['HTTP_USER_AGENT'] : '';
$ts = date("U");
self::log( 'signout' , $username , $ts , $ip , $u... | [
"public",
"static",
"function",
"signOut",
"(",
")",
"{",
"$",
"username",
"=",
"self",
"::",
"getCurrentUsername",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"username",
")",
")",
"{",
"$",
"ip",
"=",
"self",
"::",
"getClientIp",
"(",
")",
... | Sign out the current user and return its username
@return string the logged out username | [
"Sign",
"out",
"the",
"current",
"user",
"and",
"return",
"its",
"username"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L691-L707 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.userCanOnLogs | public static function userCanOnLogs( $log , $action , $value , $username = null)
{
if ( is_null( $username ) ) $username = self::getCurrentUsername();
if ( is_null( $username ) ) return false;
if ( ! self::userExists( $username ) ) return false;
if ( in_array( 'admin' , self::$auth['users'][ $username ]['role... | php | public static function userCanOnLogs( $log , $action , $value , $username = null)
{
if ( is_null( $username ) ) $username = self::getCurrentUsername();
if ( is_null( $username ) ) return false;
if ( ! self::userExists( $username ) ) return false;
if ( in_array( 'admin' , self::$auth['users'][ $username ]['role... | [
"public",
"static",
"function",
"userCanOnLogs",
"(",
"$",
"log",
",",
"$",
"action",
",",
"$",
"value",
",",
"$",
"username",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"username",
")",
")",
"$",
"username",
"=",
"self",
"::",
"getCurren... | Tell if a user has an access on a log file
@param string $log the fileid
@param string $action the name of the action
@param string $value the value for this action
@param string $username the username
@return boolean | [
"Tell",
"if",
"a",
"user",
"has",
"an",
"access",
"on",
"a",
"log",
"file"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L719-L727 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.userExists | public static function userExists($username)
{
if ( ! is_array( self::$auth ) ) throw new Exception( 'Authentication not initialized' );
return ( isset( self::$auth['users'][ $username ] ) );
} | php | public static function userExists($username)
{
if ( ! is_array( self::$auth ) ) throw new Exception( 'Authentication not initialized' );
return ( isset( self::$auth['users'][ $username ] ) );
} | [
"public",
"static",
"function",
"userExists",
"(",
"$",
"username",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"self",
"::",
"$",
"auth",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Authentication not initialized'",
")",
";",
"return",
"(",
"isset",
"(",... | Tell whether user exists or not
@param string $username the username
@return boolean | [
"Tell",
"whether",
"user",
"exists",
"or",
"not"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L736-L740 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.userHasRole | public static function userHasRole($role , $username = null)
{
if ( is_null( $username ) ) $username = self::getCurrentUsername();
if ( is_null( $username ) ) return false;
if ( ! self::userExists( $username ) ) return false;
if ( in_array( 'admin' , self::$auth['users'][ $username ]['roles'] ) ) return true;
... | php | public static function userHasRole($role , $username = null)
{
if ( is_null( $username ) ) $username = self::getCurrentUsername();
if ( is_null( $username ) ) return false;
if ( ! self::userExists( $username ) ) return false;
if ( in_array( 'admin' , self::$auth['users'][ $username ]['roles'] ) ) return true;
... | [
"public",
"static",
"function",
"userHasRole",
"(",
"$",
"role",
",",
"$",
"username",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"username",
")",
")",
"$",
"username",
"=",
"self",
"::",
"getCurrentUsername",
"(",
")",
";",
"if",
"(",
"i... | Tell if a user has a role or not
@param string $username a username or current logged in user if not set
@return boolean | [
"Tell",
"if",
"a",
"user",
"has",
"a",
"role",
"or",
"not"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L749-L756 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.getPasswordHash | private static function getPasswordHash($username , $password)
{
return sha1( self::getSecurityToken() . $username . self::getGenerated() . $password );
} | php | private static function getPasswordHash($username , $password)
{
return sha1( self::getSecurityToken() . $username . self::getGenerated() . $password );
} | [
"private",
"static",
"function",
"getPasswordHash",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"return",
"sha1",
"(",
"self",
"::",
"getSecurityToken",
"(",
")",
".",
"$",
"username",
".",
"self",
"::",
"getGenerated",
"(",
")",
".",
"$",
"pas... | Generate a hash from a username and a password
@param string $username username
@param string $password password
@return string the hash | [
"Generate",
"a",
"hash",
"from",
"a",
"username",
"and",
"a",
"password"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L787-L790 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.lock | private static function lock()
{
if (self::$currentlylocked === false) {
self::$authFileP = fopen( self::$authFile , "a+" );
if ( flock( self::$authFileP , LOCK_EX ) ) {
self::$currentlylocked = true;
} else {
throw new Exception( 'Unable to lock file' );
}
}
return true;
} | php | private static function lock()
{
if (self::$currentlylocked === false) {
self::$authFileP = fopen( self::$authFile , "a+" );
if ( flock( self::$authFileP , LOCK_EX ) ) {
self::$currentlylocked = true;
} else {
throw new Exception( 'Unable to lock file' );
}
}
return true;
} | [
"private",
"static",
"function",
"lock",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"currentlylocked",
"===",
"false",
")",
"{",
"self",
"::",
"$",
"authFileP",
"=",
"fopen",
"(",
"self",
"::",
"$",
"authFile",
",",
"\"a+\"",
")",
";",
"if",
"(",
... | Lock the database file
@return boolean | [
"Lock",
"the",
"database",
"file"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L808-L820 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.read | private static function read()
{
self::lock();
if ( is_null( self::$authFileP ) ) throw new Exception( 'No lock has been requested' );
return stream_get_contents( self::$authFileP , -1 , 0 );
} | php | private static function read()
{
self::lock();
if ( is_null( self::$authFileP ) ) throw new Exception( 'No lock has been requested' );
return stream_get_contents( self::$authFileP , -1 , 0 );
} | [
"private",
"static",
"function",
"read",
"(",
")",
"{",
"self",
"::",
"lock",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"authFileP",
")",
")",
"throw",
"new",
"Exception",
"(",
"'No lock has been requested'",
")",
";",
"return",
"strea... | Read the database
@return string the database content | [
"Read",
"the",
"database"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L827-L832 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.sessionDestroy | private static function sessionDestroy()
{
// Web
if ( isset( $_SERVER['SERVER_PROTOCOL'] ) ) {
Session::start();
unset( $_SESSION['auth'] );
$_SESSION['auth'] = array();
Session::write_close();
}
// CLI
else {
$value = array();
file_put_contents( '_cli_fake_session' , json_encode( $value )... | php | private static function sessionDestroy()
{
// Web
if ( isset( $_SERVER['SERVER_PROTOCOL'] ) ) {
Session::start();
unset( $_SESSION['auth'] );
$_SESSION['auth'] = array();
Session::write_close();
}
// CLI
else {
$value = array();
file_put_contents( '_cli_fake_session' , json_encode( $value )... | [
"private",
"static",
"function",
"sessionDestroy",
"(",
")",
"{",
"// Web",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'SERVER_PROTOCOL'",
"]",
")",
")",
"{",
"Session",
"::",
"start",
"(",
")",
";",
"unset",
"(",
"$",
"_SESSION",
"[",
"'auth'",
"]... | Destroy a session
Need a wrapper to manage session with phpunit
@return void | [
"Destroy",
"a",
"session"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L841-L855 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.sessionRead | private static function sessionRead()
{
// Web
if ( isset( $_SERVER['SERVER_PROTOCOL'] ) ) {
if ( isset( $_SESSION['auth'] ) ) return $_SESSION['auth'];
Session::start();
return ( isset( $_SESSION['auth'] ) ) ? $_SESSION['auth'] : array();
}
// CLI
else {
$json = @file_get_contents( '_cli_fake... | php | private static function sessionRead()
{
// Web
if ( isset( $_SERVER['SERVER_PROTOCOL'] ) ) {
if ( isset( $_SESSION['auth'] ) ) return $_SESSION['auth'];
Session::start();
return ( isset( $_SESSION['auth'] ) ) ? $_SESSION['auth'] : array();
}
// CLI
else {
$json = @file_get_contents( '_cli_fake... | [
"private",
"static",
"function",
"sessionRead",
"(",
")",
"{",
"// Web",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'SERVER_PROTOCOL'",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'auth'",
"]",
")",
")",
"return",
"$",
"_S... | Read a session
@return array the array with all auth informations | [
"Read",
"a",
"session"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L862-L880 |
potsky/PimpMyLog | inc/classes/Sentinel.php | Sentinel.write | private static function write($content)
{
self::lock();
if ( is_null( self::$authFileP ) ) throw new Exception( 'No lock has been requested' );
ftruncate( self::$authFileP , 0 );
fwrite( self::$authFileP , $content );
return fflush( self::$authFileP );
} | php | private static function write($content)
{
self::lock();
if ( is_null( self::$authFileP ) ) throw new Exception( 'No lock has been requested' );
ftruncate( self::$authFileP , 0 );
fwrite( self::$authFileP , $content );
return fflush( self::$authFileP );
} | [
"private",
"static",
"function",
"write",
"(",
"$",
"content",
")",
"{",
"self",
"::",
"lock",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"authFileP",
")",
")",
"throw",
"new",
"Exception",
"(",
"'No lock has been requested'",
")",
";",... | Write the database
@param string $content the database content
@return boolean | [
"Write",
"the",
"database"
] | train | https://github.com/potsky/PimpMyLog/blob/2fed8c1fcedb023dfa0e63df48fb20996a40a76c/inc/classes/Sentinel.php#L911-L919 |
BKWLD/cloner | src/Cloneable.php | Cloneable.getCloneExemptAttributes | public function getCloneExemptAttributes() {
// Always make the id and timestamps exempt
$defaults = [
$this->getKeyName(),
$this->getCreatedAtColumn(),
$this->getUpdatedAtColumn(),
];
// Include the model count columns in the exempt columns
$count_columns = array_map(function($count_column) {
... | php | public function getCloneExemptAttributes() {
// Always make the id and timestamps exempt
$defaults = [
$this->getKeyName(),
$this->getCreatedAtColumn(),
$this->getUpdatedAtColumn(),
];
// Include the model count columns in the exempt columns
$count_columns = array_map(function($count_column) {
... | [
"public",
"function",
"getCloneExemptAttributes",
"(",
")",
"{",
"// Always make the id and timestamps exempt",
"$",
"defaults",
"=",
"[",
"$",
"this",
"->",
"getKeyName",
"(",
")",
",",
"$",
"this",
"->",
"getCreatedAtColumn",
"(",
")",
",",
"$",
"this",
"->",
... | Return the list of attributes on this model that should be cloned
@return array | [
"Return",
"the",
"list",
"of",
"attributes",
"on",
"this",
"model",
"that",
"should",
"be",
"cloned"
] | train | https://github.com/BKWLD/cloner/blob/d2cd16cf11ddfb313a630cf7b164779a0a07a680/src/Cloneable.php#L16-L35 |
BKWLD/cloner | src/Cloneable.php | Cloneable.addCloneableRelation | public function addCloneableRelation($relation) {
$relations = $this->getCloneableRelations();
if (in_array($relation, $relations)) return;
$relations[] = $relation;
$this->cloneable_relations = $relations;
} | php | public function addCloneableRelation($relation) {
$relations = $this->getCloneableRelations();
if (in_array($relation, $relations)) return;
$relations[] = $relation;
$this->cloneable_relations = $relations;
} | [
"public",
"function",
"addCloneableRelation",
"(",
"$",
"relation",
")",
"{",
"$",
"relations",
"=",
"$",
"this",
"->",
"getCloneableRelations",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"relation",
",",
"$",
"relations",
")",
")",
"return",
";",
"... | Add a relation to cloneable_relations uniquely
@param string $relation
@return void | [
"Add",
"a",
"relation",
"to",
"cloneable_relations",
"uniquely"
] | train | https://github.com/BKWLD/cloner/blob/d2cd16cf11ddfb313a630cf7b164779a0a07a680/src/Cloneable.php#L64-L69 |
BKWLD/cloner | src/ServiceProvider.php | ServiceProvider.register | public function register() {
// Instantiate main Cloner instance
$this->app->singleton('cloner', function($app) {
return new Cloner(
$app['cloner.attachment-adapter'],
$app['events']
);
});
// Instantiate default Upchuck attachment adapter if the app is using Upchuck.
$this->app->singleton('cl... | php | public function register() {
// Instantiate main Cloner instance
$this->app->singleton('cloner', function($app) {
return new Cloner(
$app['cloner.attachment-adapter'],
$app['events']
);
});
// Instantiate default Upchuck attachment adapter if the app is using Upchuck.
$this->app->singleton('cl... | [
"public",
"function",
"register",
"(",
")",
"{",
"// Instantiate main Cloner instance",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'cloner'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"Cloner",
"(",
"$",
"app",
"[",
"'cloner.attach... | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/BKWLD/cloner/blob/d2cd16cf11ddfb313a630cf7b164779a0a07a680/src/ServiceProvider.php#L17-L37 |
BKWLD/cloner | src/Cloner.php | Cloner.duplicate | public function duplicate($model, $relation = null) {
$clone = $this->cloneModel($model);
$this->duplicateAttachments($clone);
$this->saveClone($clone, $relation, $model);
$this->cloneRelations($model, $clone);
return $clone;
} | php | public function duplicate($model, $relation = null) {
$clone = $this->cloneModel($model);
$this->duplicateAttachments($clone);
$this->saveClone($clone, $relation, $model);
$this->cloneRelations($model, $clone);
return $clone;
} | [
"public",
"function",
"duplicate",
"(",
"$",
"model",
",",
"$",
"relation",
"=",
"null",
")",
"{",
"$",
"clone",
"=",
"$",
"this",
"->",
"cloneModel",
"(",
"$",
"model",
")",
";",
"$",
"this",
"->",
"duplicateAttachments",
"(",
"$",
"clone",
")",
";"... | Clone a model instance and all of it's files and relations
@param Illuminate\Database\Eloquent\Model $model
@param Illuminate\Database\Eloquent\Relations\Relation $relation
@return Illuminate\Database\Eloquent\Model The new model instance | [
"Clone",
"a",
"model",
"instance",
"and",
"all",
"of",
"it",
"s",
"files",
"and",
"relations"
] | train | https://github.com/BKWLD/cloner/blob/d2cd16cf11ddfb313a630cf7b164779a0a07a680/src/Cloner.php#L45-L51 |
BKWLD/cloner | src/Cloner.php | Cloner.duplicateTo | public function duplicateTo($model, $connection) {
$this->write_connection = $connection; // Store the write database connection
$clone = $this->duplicate($model); // Do a normal duplicate
$this->write_connection = null; // Null out the connection for next run
return $clone;
} | php | public function duplicateTo($model, $connection) {
$this->write_connection = $connection; // Store the write database connection
$clone = $this->duplicate($model); // Do a normal duplicate
$this->write_connection = null; // Null out the connection for next run
return $clone;
} | [
"public",
"function",
"duplicateTo",
"(",
"$",
"model",
",",
"$",
"connection",
")",
"{",
"$",
"this",
"->",
"write_connection",
"=",
"$",
"connection",
";",
"// Store the write database connection",
"$",
"clone",
"=",
"$",
"this",
"->",
"duplicate",
"(",
"$",... | Clone a model instance to a specific database connection
@param Illuminate\Database\Eloquent\Model $model
@param string $connection A Laravel database connection
@return Illuminate\Database\Eloquent\Model The new model instance | [
"Clone",
"a",
"model",
"instance",
"to",
"a",
"specific",
"database",
"connection"
] | train | https://github.com/BKWLD/cloner/blob/d2cd16cf11ddfb313a630cf7b164779a0a07a680/src/Cloner.php#L60-L65 |
BKWLD/cloner | src/Cloner.php | Cloner.cloneModel | protected function cloneModel($model) {
$exempt = method_exists($model, 'getCloneExemptAttributes') ?
$model->getCloneExemptAttributes() : null;
$clone = $model->replicate($exempt);
if ($this->write_connection) $clone->setConnection($this->write_connection);
return $clone;
} | php | protected function cloneModel($model) {
$exempt = method_exists($model, 'getCloneExemptAttributes') ?
$model->getCloneExemptAttributes() : null;
$clone = $model->replicate($exempt);
if ($this->write_connection) $clone->setConnection($this->write_connection);
return $clone;
} | [
"protected",
"function",
"cloneModel",
"(",
"$",
"model",
")",
"{",
"$",
"exempt",
"=",
"method_exists",
"(",
"$",
"model",
",",
"'getCloneExemptAttributes'",
")",
"?",
"$",
"model",
"->",
"getCloneExemptAttributes",
"(",
")",
":",
"null",
";",
"$",
"clone",... | Create duplicate of the model
@param Illuminate\Database\Eloquent\Model $model
@return Illuminate\Database\Eloquent\Model The new model instance | [
"Create",
"duplicate",
"of",
"the",
"model"
] | train | https://github.com/BKWLD/cloner/blob/d2cd16cf11ddfb313a630cf7b164779a0a07a680/src/Cloner.php#L73-L79 |
BKWLD/cloner | src/Cloner.php | Cloner.duplicateAttachments | protected function duplicateAttachments($clone) {
if (!$this->attachment || !method_exists($clone, 'getCloneableFileAttributes')) return;
foreach($clone->getCloneableFileAttributes() as $attribute) {
if (!$original = $clone->getAttribute($attribute)) continue;
$clone->setAttribute($attribute, $this->attachmen... | php | protected function duplicateAttachments($clone) {
if (!$this->attachment || !method_exists($clone, 'getCloneableFileAttributes')) return;
foreach($clone->getCloneableFileAttributes() as $attribute) {
if (!$original = $clone->getAttribute($attribute)) continue;
$clone->setAttribute($attribute, $this->attachmen... | [
"protected",
"function",
"duplicateAttachments",
"(",
"$",
"clone",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"attachment",
"||",
"!",
"method_exists",
"(",
"$",
"clone",
",",
"'getCloneableFileAttributes'",
")",
")",
"return",
";",
"foreach",
"(",
"$",
... | Duplicate all attachments, given them a new name, and update the attribute
value
@param Illuminate\Database\Eloquent\Model $clone
@return void | [
"Duplicate",
"all",
"attachments",
"given",
"them",
"a",
"new",
"name",
"and",
"update",
"the",
"attribute",
"value"
] | train | https://github.com/BKWLD/cloner/blob/d2cd16cf11ddfb313a630cf7b164779a0a07a680/src/Cloner.php#L88-L94 |
BKWLD/cloner | src/Cloner.php | Cloner.saveClone | protected function saveClone($clone, $relation = null, $src, $child = null) {
// Set the child flag
if ($relation) $child = true;
// Notify listeners via callback or event
if (method_exists($clone, 'onCloning')) $clone->onCloning($src, $child);
$this->events->dispatch('cloner::cloning: '.get_class($src), [$... | php | protected function saveClone($clone, $relation = null, $src, $child = null) {
// Set the child flag
if ($relation) $child = true;
// Notify listeners via callback or event
if (method_exists($clone, 'onCloning')) $clone->onCloning($src, $child);
$this->events->dispatch('cloner::cloning: '.get_class($src), [$... | [
"protected",
"function",
"saveClone",
"(",
"$",
"clone",
",",
"$",
"relation",
"=",
"null",
",",
"$",
"src",
",",
"$",
"child",
"=",
"null",
")",
"{",
"// Set the child flag",
"if",
"(",
"$",
"relation",
")",
"$",
"child",
"=",
"true",
";",
"// Notify ... | Save the clone. If a relation was passed, save the clone onto that
relation. Otherwise, just save it.
@param Illuminate\Database\Eloquent\Model $clone
@param Illuminate\Database\Eloquent\Relations\Relation $relation
@param Illuminate\Database\Eloquent\Model $src The orginal model
@param boolean $child
@return voi... | [
"Save",
"the",
"clone",
".",
"If",
"a",
"relation",
"was",
"passed",
"save",
"the",
"clone",
"onto",
"that",
"relation",
".",
"Otherwise",
"just",
"save",
"it",
"."
] | train | https://github.com/BKWLD/cloner/blob/d2cd16cf11ddfb313a630cf7b164779a0a07a680/src/Cloner.php#L106-L122 |
BKWLD/cloner | src/Cloner.php | Cloner.cloneRelations | protected function cloneRelations($model, $clone) {
if (!method_exists($model, 'getCloneableRelations')) return;
foreach($model->getCloneableRelations() as $relation_name) {
$this->duplicateRelation($model, $relation_name, $clone);
}
} | php | protected function cloneRelations($model, $clone) {
if (!method_exists($model, 'getCloneableRelations')) return;
foreach($model->getCloneableRelations() as $relation_name) {
$this->duplicateRelation($model, $relation_name, $clone);
}
} | [
"protected",
"function",
"cloneRelations",
"(",
"$",
"model",
",",
"$",
"clone",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"model",
",",
"'getCloneableRelations'",
")",
")",
"return",
";",
"foreach",
"(",
"$",
"model",
"->",
"getCloneableRelations... | Loop through relations and clone or re-attach them
@param Illuminate\Database\Eloquent\Model $model
@param Illuminate\Database\Eloquent\Model $clone
@return void | [
"Loop",
"through",
"relations",
"and",
"clone",
"or",
"re",
"-",
"attach",
"them"
] | train | https://github.com/BKWLD/cloner/blob/d2cd16cf11ddfb313a630cf7b164779a0a07a680/src/Cloner.php#L131-L136 |
BKWLD/cloner | src/Cloner.php | Cloner.duplicateRelation | protected function duplicateRelation($model, $relation_name, $clone) {
$relation = call_user_func([$model, $relation_name]);
if (is_a($relation, 'Illuminate\Database\Eloquent\Relations\BelongsToMany')) {
$this->duplicatePivotedRelation($relation, $relation_name, $clone);
} else $this->duplicateDirectRelation($... | php | protected function duplicateRelation($model, $relation_name, $clone) {
$relation = call_user_func([$model, $relation_name]);
if (is_a($relation, 'Illuminate\Database\Eloquent\Relations\BelongsToMany')) {
$this->duplicatePivotedRelation($relation, $relation_name, $clone);
} else $this->duplicateDirectRelation($... | [
"protected",
"function",
"duplicateRelation",
"(",
"$",
"model",
",",
"$",
"relation_name",
",",
"$",
"clone",
")",
"{",
"$",
"relation",
"=",
"call_user_func",
"(",
"[",
"$",
"model",
",",
"$",
"relation_name",
"]",
")",
";",
"if",
"(",
"is_a",
"(",
"... | Duplicate relationships to the clone
@param Illuminate\Database\Eloquent\Model $model
@param string $relation_name
@param Illuminate\Database\Eloquent\Model $clone
@return void | [
"Duplicate",
"relationships",
"to",
"the",
"clone"
] | train | https://github.com/BKWLD/cloner/blob/d2cd16cf11ddfb313a630cf7b164779a0a07a680/src/Cloner.php#L146-L151 |
BKWLD/cloner | src/Cloner.php | Cloner.duplicatePivotedRelation | protected function duplicatePivotedRelation($relation, $relation_name, $clone) {
// If duplicating between databases, do not duplicate relations. The related
// instance may not exist in the other database or could have a different
// primary key.
if ($this->write_connection) return;
// Loop trough current ... | php | protected function duplicatePivotedRelation($relation, $relation_name, $clone) {
// If duplicating between databases, do not duplicate relations. The related
// instance may not exist in the other database or could have a different
// primary key.
if ($this->write_connection) return;
// Loop trough current ... | [
"protected",
"function",
"duplicatePivotedRelation",
"(",
"$",
"relation",
",",
"$",
"relation_name",
",",
"$",
"clone",
")",
"{",
"// If duplicating between databases, do not duplicate relations. The related",
"// instance may not exist in the other database or could have a different"... | Duplicate a many-to-many style relation where we are just attaching the
relation to the dupe
@param Illuminate\Database\Eloquent\Relations\Relation $relation
@param string $relation_name
@param Illuminate\Database\Eloquent\Model $clone
@return void | [
"Duplicate",
"a",
"many",
"-",
"to",
"-",
"many",
"style",
"relation",
"where",
"we",
"are",
"just",
"attaching",
"the",
"relation",
"to",
"the",
"dupe"
] | train | https://github.com/BKWLD/cloner/blob/d2cd16cf11ddfb313a630cf7b164779a0a07a680/src/Cloner.php#L162-L179 |
BKWLD/cloner | src/Cloner.php | Cloner.duplicateDirectRelation | protected function duplicateDirectRelation($relation, $relation_name, $clone) {
$relation->get()->each(function($foreign) use ($clone, $relation_name) {
$this->duplicate($foreign, $clone->$relation_name());
});
} | php | protected function duplicateDirectRelation($relation, $relation_name, $clone) {
$relation->get()->each(function($foreign) use ($clone, $relation_name) {
$this->duplicate($foreign, $clone->$relation_name());
});
} | [
"protected",
"function",
"duplicateDirectRelation",
"(",
"$",
"relation",
",",
"$",
"relation_name",
",",
"$",
"clone",
")",
"{",
"$",
"relation",
"->",
"get",
"(",
")",
"->",
"each",
"(",
"function",
"(",
"$",
"foreign",
")",
"use",
"(",
"$",
"clone",
... | Duplicate a one-to-many style relation where the foreign model is ALSO
cloned and then associated
@param Illuminate\Database\Eloquent\Relations\Relation $relation
@param string $relation_name
@param Illuminate\Database\Eloquent\Model $clone
@return void | [
"Duplicate",
"a",
"one",
"-",
"to",
"-",
"many",
"style",
"relation",
"where",
"the",
"foreign",
"model",
"is",
"ALSO",
"cloned",
"and",
"then",
"associated"
] | train | https://github.com/BKWLD/cloner/blob/d2cd16cf11ddfb313a630cf7b164779a0a07a680/src/Cloner.php#L190-L194 |
BKWLD/cloner | src/Adapters/Upchuck.php | Upchuck.duplicate | public function duplicate($url) {
// Make the destination path
$current_path = $this->helpers->path($url);
$filename = basename($current_path);
$dst_disk = $this->disks ? $this->disks->getFilesystem('dst') : $this->disk;
$new_path = $this->storage->makeNestedAndUniquePath($filename, $dst_disk);
// Copy, s... | php | public function duplicate($url) {
// Make the destination path
$current_path = $this->helpers->path($url);
$filename = basename($current_path);
$dst_disk = $this->disks ? $this->disks->getFilesystem('dst') : $this->disk;
$new_path = $this->storage->makeNestedAndUniquePath($filename, $dst_disk);
// Copy, s... | [
"public",
"function",
"duplicate",
"(",
"$",
"url",
")",
"{",
"// Make the destination path",
"$",
"current_path",
"=",
"$",
"this",
"->",
"helpers",
"->",
"path",
"(",
"$",
"url",
")",
";",
"$",
"filename",
"=",
"basename",
"(",
"$",
"current_path",
")",
... | Duplicate a file given it's URL
@param string $url
@return string | [
"Duplicate",
"a",
"file",
"given",
"it",
"s",
"URL"
] | train | https://github.com/BKWLD/cloner/blob/d2cd16cf11ddfb313a630cf7b164779a0a07a680/src/Adapters/Upchuck.php#L52-L66 |
kronusme/dota2-api | includes/Mappers/MatchMapperDb.php | MatchMapperDb.matchExists | public static function matchExists($matchId)
{
$db = Db::obtain();
$r = $db->queryFirstPDO(
'SELECT match_id FROM ' . Db::realTablename('matches') . ' WHERE match_id = ?',
array($matchId)
);
return ((bool)$r);
} | php | public static function matchExists($matchId)
{
$db = Db::obtain();
$r = $db->queryFirstPDO(
'SELECT match_id FROM ' . Db::realTablename('matches') . ' WHERE match_id = ?',
array($matchId)
);
return ((bool)$r);
} | [
"public",
"static",
"function",
"matchExists",
"(",
"$",
"matchId",
")",
"{",
"$",
"db",
"=",
"Db",
"::",
"obtain",
"(",
")",
";",
"$",
"r",
"=",
"$",
"db",
"->",
"queryFirstPDO",
"(",
"'SELECT match_id FROM '",
".",
"Db",
"::",
"realTablename",
"(",
"... | Delete match data from db
@param int $matchId
@return bool | [
"Delete",
"match",
"data",
"from",
"db"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Mappers/MatchMapperDb.php#L264-L272 |
kronusme/dota2-api | includes/Models/Match.php | Match.getSlot | public function getSlot($index)
{
$index = (int)$index;
return array_key_exists($index, $this->_slots) ? $this->_slots[$index] : null;
} | php | public function getSlot($index)
{
$index = (int)$index;
return array_key_exists($index, $this->_slots) ? $this->_slots[$index] : null;
} | [
"public",
"function",
"getSlot",
"(",
"$",
"index",
")",
"{",
"$",
"index",
"=",
"(",
"int",
")",
"$",
"index",
";",
"return",
"array_key_exists",
"(",
"$",
"index",
",",
"$",
"this",
"->",
"_slots",
")",
"?",
"$",
"this",
"->",
"_slots",
"[",
"$",... | Get Slot by its index (0-4 for radiant, 128-132 for dire - as it is in the field player_slot)
@param int $index
@return Slot | null | [
"Get",
"Slot",
"by",
"its",
"index",
"(",
"0",
"-",
"4",
"for",
"radiant",
"128",
"-",
"132",
"for",
"dire",
"-",
"as",
"it",
"is",
"in",
"the",
"field",
"player_slot",
")"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Models/Match.php#L205-L209 |
kronusme/dota2-api | includes/Models/Match.php | Match.getAllSlotsDivided | public function getAllSlotsDivided()
{
$return = array('radiant' => array(), 'dire' => array());
foreach ($this->_slots as $slot) {
$team = 'radiant';
if ($slot->get('player_slot') > 5) {
$team = 'dire';
}
array_push($return[$team], $sl... | php | public function getAllSlotsDivided()
{
$return = array('radiant' => array(), 'dire' => array());
foreach ($this->_slots as $slot) {
$team = 'radiant';
if ($slot->get('player_slot') > 5) {
$team = 'dire';
}
array_push($return[$team], $sl... | [
"public",
"function",
"getAllSlotsDivided",
"(",
")",
"{",
"$",
"return",
"=",
"array",
"(",
"'radiant'",
"=>",
"array",
"(",
")",
",",
"'dire'",
"=>",
"array",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_slots",
"as",
"$",
"slot",
")",
... | Return array of all slots divided by team (5 for radiant, 5 for dire)
@return Slot[][] | [
"Return",
"array",
"of",
"all",
"slots",
"divided",
"by",
"team",
"(",
"5",
"for",
"radiant",
"5",
"for",
"dire",
")"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Models/Match.php#L224-L235 |
kronusme/dota2-api | includes/Models/Match.php | Match.getAllPicksBansDivided | public function getAllPicksBansDivided()
{
$return = array(
'radiant' => array(
'bans' => array(),
'picks' => array()
),
'dire' => array(
'bans' => array(),
'picks' => array()
)
);
... | php | public function getAllPicksBansDivided()
{
$return = array(
'radiant' => array(
'bans' => array(),
'picks' => array()
),
'dire' => array(
'bans' => array(),
'picks' => array()
)
);
... | [
"public",
"function",
"getAllPicksBansDivided",
"(",
")",
"{",
"$",
"return",
"=",
"array",
"(",
"'radiant'",
"=>",
"array",
"(",
"'bans'",
"=>",
"array",
"(",
")",
",",
"'picks'",
"=>",
"array",
"(",
")",
")",
",",
"'dire'",
"=>",
"array",
"(",
"'bans... | Return array of all picks and bans divided by team (and then by bans and picks)
@return array | [
"Return",
"array",
"of",
"all",
"picks",
"and",
"bans",
"divided",
"by",
"team",
"(",
"and",
"then",
"by",
"bans",
"and",
"picks",
")"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Models/Match.php#L250-L274 |
kronusme/dota2-api | includes/Mappers/MatchMapperWeb.php | MatchMapperWeb.load | public function load()
{
$request = new request(self::STEAM_MATCH_URL, array('match_id' => $this->getMatchId()));
$matchInfo = $request->send();
if (null === $matchInfo) {
return null;
}
$match = new Match();
$players = array();
foreach ($matchInfo... | php | public function load()
{
$request = new request(self::STEAM_MATCH_URL, array('match_id' => $this->getMatchId()));
$matchInfo = $request->send();
if (null === $matchInfo) {
return null;
}
$match = new Match();
$players = array();
foreach ($matchInfo... | [
"public",
"function",
"load",
"(",
")",
"{",
"$",
"request",
"=",
"new",
"request",
"(",
"self",
"::",
"STEAM_MATCH_URL",
",",
"array",
"(",
"'match_id'",
"=>",
"$",
"this",
"->",
"getMatchId",
"(",
")",
")",
")",
";",
"$",
"matchInfo",
"=",
"$",
"re... | Load match info by match_id | [
"Load",
"match",
"info",
"by",
"match_id"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Mappers/MatchMapperWeb.php#L40-L90 |
kronusme/dota2-api | includes/Utils/Map.php | Map._loadPng | private function _loadPng($file)
{
$pic = imagecreatefrompng($file);
if ($pic === false) {
return null;
}
// make sure the images can be properly drawn together
imagealphablending($pic, false);
imagesavealpha($pic, true);
return $pic;
} | php | private function _loadPng($file)
{
$pic = imagecreatefrompng($file);
if ($pic === false) {
return null;
}
// make sure the images can be properly drawn together
imagealphablending($pic, false);
imagesavealpha($pic, true);
return $pic;
} | [
"private",
"function",
"_loadPng",
"(",
"$",
"file",
")",
"{",
"$",
"pic",
"=",
"imagecreatefrompng",
"(",
"$",
"file",
")",
";",
"if",
"(",
"$",
"pic",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"// make sure the images can be properly drawn toge... | Load png image (like tower or barrack icon)
@param string $file
@return null|resource | [
"Load",
"png",
"image",
"(",
"like",
"tower",
"or",
"barrack",
"icon",
")"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Utils/Map.php#L170-L180 |
kronusme/dota2-api | includes/Utils/Db.php | Db.obtain | public static function obtain($server = null, $user = null, $pass = null, $database = null, $pref = null)
{
if (null === self::$_instance) {
self::$_instance = new db($server, $user, $pass, $database, $pref);
}
return self::$_instance;
} | php | public static function obtain($server = null, $user = null, $pass = null, $database = null, $pref = null)
{
if (null === self::$_instance) {
self::$_instance = new db($server, $user, $pass, $database, $pref);
}
return self::$_instance;
} | [
"public",
"static",
"function",
"obtain",
"(",
"$",
"server",
"=",
"null",
",",
"$",
"user",
"=",
"null",
",",
"$",
"pass",
"=",
"null",
",",
"$",
"database",
"=",
"null",
",",
"$",
"pref",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"self",... | Obtain an instance of Database object
@static
@param $server string
@param $user string
@param $pass string
@param $database string
@param $pref string
@return db If object does not exists create new and return else return already created object | [
"Obtain",
"an",
"instance",
"of",
"Database",
"object"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Utils/Db.php#L112-L118 |
kronusme/dota2-api | includes/Utils/Db.php | Db.connectPDO | public function connectPDO($selectDb = true)
{
if (null !== self::$_linkId) {
return true;
}
try {
self::$_linkId = new PDO(
'mysql:host=' . $this->_server,
$this->_user,
$this->_pass,
array(PDO::MYSQL_AT... | php | public function connectPDO($selectDb = true)
{
if (null !== self::$_linkId) {
return true;
}
try {
self::$_linkId = new PDO(
'mysql:host=' . $this->_server,
$this->_user,
$this->_pass,
array(PDO::MYSQL_AT... | [
"public",
"function",
"connectPDO",
"(",
"$",
"selectDb",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"!==",
"self",
"::",
"$",
"_linkId",
")",
"{",
"return",
"true",
";",
"}",
"try",
"{",
"self",
"::",
"$",
"_linkId",
"=",
"new",
"PDO",
"(",
"'mysql... | Connect to a Database host and select database using variable initialized above
@access public
@param bool $selectDb
@return bool If Database connection successful return true else return false | [
"Connect",
"to",
"a",
"Database",
"host",
"and",
"select",
"database",
"using",
"variable",
"initialized",
"above"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Utils/Db.php#L132-L153 |
kronusme/dota2-api | includes/Utils/Db.php | Db._queryPDO | private function _queryPDO($sql, array $params = array())
{
try {
$this->_queryId = self::$_linkId->prepare($sql);
$i = 1;
foreach ($params as $key => $val) {
$type = $this->getPDOConstantType($val);
$this->_queryId->bindValue($i, $val, $ty... | php | private function _queryPDO($sql, array $params = array())
{
try {
$this->_queryId = self::$_linkId->prepare($sql);
$i = 1;
foreach ($params as $key => $val) {
$type = $this->getPDOConstantType($val);
$this->_queryId->bindValue($i, $val, $ty... | [
"private",
"function",
"_queryPDO",
"(",
"$",
"sql",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"_queryId",
"=",
"self",
"::",
"$",
"_linkId",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"i"... | Prepares and executes a sql query
@access private
@param String $sql
@param Array $params
@return Boolean Returns TRUE on success or FALSE on failure. | [
"Prepares",
"and",
"executes",
"a",
"sql",
"query"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Utils/Db.php#L171-L186 |
kronusme/dota2-api | includes/Utils/Db.php | Db.queryFirstPDO | public function queryFirstPDO($sql, array $params = array())
{
$query_id = $this->_queryPDO($sql, $params);
if ($query_id === false) {
return false;
}
$out = $this->_fetchPDO();
$this->_freeResultPDO();
return $out;
} | php | public function queryFirstPDO($sql, array $params = array())
{
$query_id = $this->_queryPDO($sql, $params);
if ($query_id === false) {
return false;
}
$out = $this->_fetchPDO();
$this->_freeResultPDO();
return $out;
} | [
"public",
"function",
"queryFirstPDO",
"(",
"$",
"sql",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"query_id",
"=",
"$",
"this",
"->",
"_queryPDO",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"query_id",
... | Run the query, fetches the first row only, frees resultset
@access public
@param String $sql
@param Array $params
@return Mixed The first record as an Array or FALSE in case the query fails to execute. | [
"Run",
"the",
"query",
"fetches",
"the",
"first",
"row",
"only",
"frees",
"resultset"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Utils/Db.php#L195-L204 |
kronusme/dota2-api | includes/Utils/Db.php | Db.fetchArrayPDO | public function fetchArrayPDO($sql, array $params = array())
{
$query_id = $this->_queryPDO($sql, $params);
if ($query_id === false) {
return false;
}
$out = array();
while ($row = $this->_fetchPDO()) {
$out[] = $row;
}
$this->_freeR... | php | public function fetchArrayPDO($sql, array $params = array())
{
$query_id = $this->_queryPDO($sql, $params);
if ($query_id === false) {
return false;
}
$out = array();
while ($row = $this->_fetchPDO()) {
$out[] = $row;
}
$this->_freeR... | [
"public",
"function",
"fetchArrayPDO",
"(",
"$",
"sql",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"query_id",
"=",
"$",
"this",
"->",
"_queryPDO",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"query_id",
... | Fetches and returns all the results (not just one row)
@param string $sql
@param array $params
@return array The complete records as an Associative Array or Empty in case if the query_id (i.e. if the query did not execute) is not set. | [
"Fetches",
"and",
"returns",
"all",
"the",
"results",
"(",
"not",
"just",
"one",
"row",
")"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Utils/Db.php#L222-L237 |
kronusme/dota2-api | includes/Utils/Db.php | Db.updatePDO | public function updatePDO($table, array $data, array $where = array())
{
if (count($data) === 0) {
return false;
}
$q = "UPDATE `$table` SET ";
foreach ($data as $key => $val) {
if (null !== $val) {
$q .= "`$key`=?, ";
}
}... | php | public function updatePDO($table, array $data, array $where = array())
{
if (count($data) === 0) {
return false;
}
$q = "UPDATE `$table` SET ";
foreach ($data as $key => $val) {
if (null !== $val) {
$q .= "`$key`=?, ";
}
}... | [
"public",
"function",
"updatePDO",
"(",
"$",
"table",
",",
"array",
"$",
"data",
",",
"array",
"$",
"where",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"data",
")",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"$",
"q... | Does an update query with an array for data and array as a param for the where clause
@access public
@param String $table
@param Array $data is an assoc array with keys are column names and values as the actual values
@param Array $where
@return Boolean Returns TRUE on success or FALSE on failure. | [
"Does",
"an",
"update",
"query",
"with",
"an",
"array",
"for",
"data",
"and",
"array",
"as",
"a",
"param",
"for",
"the",
"where",
"clause"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Utils/Db.php#L247-L292 |
kronusme/dota2-api | includes/Utils/Db.php | Db.insertManyPDO | public function insertManyPDO($table, array $fields, array $data = array(), $update = false)
{
if (count($data) === 0) {
return false;
}
$q = 'INSERT INTO `' . $table . '`';
$v = '';
$n = '(`' . implode('`,`', $fields) . '`) ';
foreach ($data as $sd) {
... | php | public function insertManyPDO($table, array $fields, array $data = array(), $update = false)
{
if (count($data) === 0) {
return false;
}
$q = 'INSERT INTO `' . $table . '`';
$v = '';
$n = '(`' . implode('`,`', $fields) . '`) ';
foreach ($data as $sd) {
... | [
"public",
"function",
"insertManyPDO",
"(",
"$",
"table",
",",
"array",
"$",
"fields",
",",
"array",
"$",
"data",
"=",
"array",
"(",
")",
",",
"$",
"update",
"=",
"false",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"data",
")",
"===",
"0",
")",
"{",... | Insert many data per one query
Example: $fields = array('a','b','c') then $data should be array(array(1,2,3), array(4,5,6)) etc
@param string $table
@param array $fields array of fields names
@param array $data array of array of data
@param bool $update should data be updated on duplicate
@return bool | [
"Insert",
"many",
"data",
"per",
"one",
"query",
"Example",
":",
"$fields",
"=",
"array",
"(",
"a",
"b",
"c",
")",
"then",
"$data",
"should",
"be",
"array",
"(",
"array",
"(",
"1",
"2",
"3",
")",
"array",
"(",
"4",
"5",
"6",
"))",
"etc"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Utils/Db.php#L304-L346 |
kronusme/dota2-api | includes/Utils/Db.php | Db.insertPDO | public function insertPDO($table, array $data = array())
{
if (count($data) === 0) {
return false;
}
$q = "INSERT INTO `$table` ";
$v = '';
$n = '';
foreach ($data as $key => $val) {
$n .= "`$key`, ";
if (strtolower($val) === 'now(... | php | public function insertPDO($table, array $data = array())
{
if (count($data) === 0) {
return false;
}
$q = "INSERT INTO `$table` ";
$v = '';
$n = '';
foreach ($data as $key => $val) {
$n .= "`$key`, ";
if (strtolower($val) === 'now(... | [
"public",
"function",
"insertPDO",
"(",
"$",
"table",
",",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"data",
")",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"$",
"q",
"=",
"\"INSERT INTO `$table` ... | Does an insert query with an array for data.
@access public
@param String $table
@param Array $data is an assoc array with keys are column names and values as the actual values
@return Mixed Returns ID of the inserted record or FALSE on failure. | [
"Does",
"an",
"insert",
"query",
"with",
"an",
"array",
"for",
"data",
"."
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Utils/Db.php#L355-L389 |
kronusme/dota2-api | includes/Utils/Db.php | Db.deletePDO | public function deletePDO($table, array $where = array(), $limit = 1)
{
$limit = (int)$limit;
if (count($where) === 0) {
return false;
}
$q = "DELETE FROM `$table` ";
$q .= 'WHERE ';
foreach ($where as $key => $val) {
if (empty($val)) {
... | php | public function deletePDO($table, array $where = array(), $limit = 1)
{
$limit = (int)$limit;
if (count($where) === 0) {
return false;
}
$q = "DELETE FROM `$table` ";
$q .= 'WHERE ';
foreach ($where as $key => $val) {
if (empty($val)) {
... | [
"public",
"function",
"deletePDO",
"(",
"$",
"table",
",",
"array",
"$",
"where",
"=",
"array",
"(",
")",
",",
"$",
"limit",
"=",
"1",
")",
"{",
"$",
"limit",
"=",
"(",
"int",
")",
"$",
"limit",
";",
"if",
"(",
"count",
"(",
"$",
"where",
")",
... | Delete records from table
@param string $table
@param array $where is an assoc array with keys are column names and values as the actual values
@param int $limit max affected rows count (default - 1)
@return mixed false on failure | [
"Delete",
"records",
"from",
"table"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Utils/Db.php#L398-L436 |
kronusme/dota2-api | includes/Utils/Db.php | Db.getPDOConstantType | public function getPDOConstantType($value)
{
switch (true) {
case is_int($value):
$type = PDO::PARAM_INT;
break;
case is_bool($value):
$type = PDO::PARAM_BOOL;
break;
case (null === $value):
... | php | public function getPDOConstantType($value)
{
switch (true) {
case is_int($value):
$type = PDO::PARAM_INT;
break;
case is_bool($value):
$type = PDO::PARAM_BOOL;
break;
case (null === $value):
... | [
"public",
"function",
"getPDOConstantType",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"is_int",
"(",
"$",
"value",
")",
":",
"$",
"type",
"=",
"PDO",
"::",
"PARAM_INT",
";",
"break",
";",
"case",
"is_bool",
"(",
"$",
"valu... | Checks the data type of the value that is passed
@access public
@param * $value
@return Integer Returns the corresponding PDO ID of the data type. | [
"Checks",
"the",
"data",
"type",
"of",
"the",
"value",
"that",
"is",
"passed"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Utils/Db.php#L444-L461 |
kronusme/dota2-api | includes/Data/HeroesData.php | HeroesData.getImgUrlById | public function getImgUrlById($id, $thumb = true)
{
$id = (int)$id;
$data = $this->getDataById($id);
if (null === $data) {
return '';
} else {
$suffix = $thumb ? $this->_suffixes['thumb'] : $this->_suffixes['large'];
return 'http://media.steampower... | php | public function getImgUrlById($id, $thumb = true)
{
$id = (int)$id;
$data = $this->getDataById($id);
if (null === $data) {
return '';
} else {
$suffix = $thumb ? $this->_suffixes['thumb'] : $this->_suffixes['large'];
return 'http://media.steampower... | [
"public",
"function",
"getImgUrlById",
"(",
"$",
"id",
",",
"$",
"thumb",
"=",
"true",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"getDataById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"null",
... | Generate image url (uses steam servers)
@param int $id item identifier
@param bool $thumb return small or large image url
@return string | [
"Generate",
"image",
"url",
"(",
"uses",
"steam",
"servers",
")"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Data/HeroesData.php#L14-L24 |
kronusme/dota2-api | includes/Models/Player.php | Player.convertId | public static function convertId($id)
{
if (strlen($id) === 17) {
$converted = substr($id, 3) - 61197960265728;
} else {
$converted = '765' . ($id + 61197960265728);
}
return (string)$converted;
} | php | public static function convertId($id)
{
if (strlen($id) === 17) {
$converted = substr($id, 3) - 61197960265728;
} else {
$converted = '765' . ($id + 61197960265728);
}
return (string)$converted;
} | [
"public",
"static",
"function",
"convertId",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"id",
")",
"===",
"17",
")",
"{",
"$",
"converted",
"=",
"substr",
"(",
"$",
"id",
",",
"3",
")",
"-",
"61197960265728",
";",
"}",
"else",
"{",
... | Convert DotA2 user id to Steam ID
@param string $id
@return string | [
"Convert",
"DotA2",
"user",
"id",
"to",
"Steam",
"ID"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Models/Player.php#L49-L57 |
kronusme/dota2-api | includes/Models/StatObject.php | StatObject.get | public function get($name)
{
$name = '_' . (string)$name;
return property_exists($this, $name) ? $this->$name : null;
} | php | public function get($name)
{
$name = '_' . (string)$name;
return property_exists($this, $name) ? $this->$name : null;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"'_'",
".",
"(",
"string",
")",
"$",
"name",
";",
"return",
"property_exists",
"(",
"$",
"this",
",",
"$",
"name",
")",
"?",
"$",
"this",
"->",
"$",
"name",
":",
"null",
... | Get field value
@param string $name
@return mixed | null | [
"Get",
"field",
"value"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Models/StatObject.php#L18-L22 |
kronusme/dota2-api | includes/Models/StatObject.php | StatObject.set | public function set($name, $value)
{
$name = '_' . (string)$name;
if (property_exists($this, $name) && (!is_array($this->$name))) {
$this->$name = $value;
}
return $this;
} | php | public function set($name, $value)
{
$name = '_' . (string)$name;
if (property_exists($this, $name) && (!is_array($this->$name))) {
$this->$name = $value;
}
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"name",
"=",
"'_'",
".",
"(",
"string",
")",
"$",
"name",
";",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"name",
")",
"&&",
"(",
"!",
"is_array",
"... | Set field value (if field isn't array)
@param string $name
@param mixed $value
@return StatObject | [
"Set",
"field",
"value",
"(",
"if",
"field",
"isn",
"t",
"array",
")"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Models/StatObject.php#L30-L37 |
kronusme/dota2-api | includes/Models/StatObject.php | StatObject.setArray | public function setArray(array $data)
{
foreach ($data as $name => $value) {
$this->set($name, $value);
}
return $this;
} | php | public function setArray(array $data)
{
foreach ($data as $name => $value) {
$this->set($name, $value);
}
return $this;
} | [
"public",
"function",
"setArray",
"(",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"t... | Set not-array fields
@param array $data
@return StatObject | [
"Set",
"not",
"-",
"array",
"fields"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Models/StatObject.php#L44-L50 |
kronusme/dota2-api | includes/Mappers/TeamsMapperWeb.php | TeamsMapperWeb.getTeam | protected function getTeam($t)
{
$teamInfo = (array)$t;
$team = new Team();
$fields = array_keys($teamInfo);
foreach ($fields as $field) {
// I hope, that API-response will be changed and players_ids, leagues_ids will become arrays
if (preg_match('/^player_\d+... | php | protected function getTeam($t)
{
$teamInfo = (array)$t;
$team = new Team();
$fields = array_keys($teamInfo);
foreach ($fields as $field) {
// I hope, that API-response will be changed and players_ids, leagues_ids will become arrays
if (preg_match('/^player_\d+... | [
"protected",
"function",
"getTeam",
"(",
"$",
"t",
")",
"{",
"$",
"teamInfo",
"=",
"(",
"array",
")",
"$",
"t",
";",
"$",
"team",
"=",
"new",
"Team",
"(",
")",
";",
"$",
"fields",
"=",
"array_keys",
"(",
"$",
"teamInfo",
")",
";",
"foreach",
"(",... | Map one team
@param Object $t
@return Team team | [
"Map",
"one",
"team"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Mappers/TeamsMapperWeb.php#L71-L89 |
kronusme/dota2-api | includes/Data/Data.php | Data.parse | public function parse($parseTo = '')
{
$parseTo = str_replace('.', '', $parseTo); // allow to use '6.86' and '686'
$p = __DIR__ . '/../../' . self::PATH . '/';
$fullpath = $p . $this->_filename;
$initData = $this->_parseJsonFile($fullpath);
if ($parseTo) {
$subdir... | php | public function parse($parseTo = '')
{
$parseTo = str_replace('.', '', $parseTo); // allow to use '6.86' and '686'
$p = __DIR__ . '/../../' . self::PATH . '/';
$fullpath = $p . $this->_filename;
$initData = $this->_parseJsonFile($fullpath);
if ($parseTo) {
$subdir... | [
"public",
"function",
"parse",
"(",
"$",
"parseTo",
"=",
"''",
")",
"{",
"$",
"parseTo",
"=",
"str_replace",
"(",
"'.'",
",",
"''",
",",
"$",
"parseTo",
")",
";",
"// allow to use '6.86' and '686'",
"$",
"p",
"=",
"__DIR__",
".",
"'/../../'",
".",
"self"... | Parse JSON file
@param string $parseTo | [
"Parse",
"JSON",
"file"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Data/Data.php#L99-L124 |
kronusme/dota2-api | includes/Data/Data.php | Data.getDataById | public function getDataById($id)
{
$id = (int)$id;
return array_key_exists($id, $this->_data) ? $this->_data[$id] : null;
} | php | public function getDataById($id)
{
$id = (int)$id;
return array_key_exists($id, $this->_data) ? $this->_data[$id] : null;
} | [
"public",
"function",
"getDataById",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"return",
"array_key_exists",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"_data",
")",
"?",
"$",
"this",
"->",
"_data",
"[",
"$",
"id",
... | Get array of data by its id (data should be parsed before)
@param int $id
@return array|null | [
"Get",
"array",
"of",
"data",
"by",
"its",
"id",
"(",
"data",
"should",
"be",
"parsed",
"before",
")"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Data/Data.php#L157-L161 |
kronusme/dota2-api | includes/Data/Data.php | Data.getFieldById | public function getFieldById($id, $field_name)
{
$data = $this->getDataById($id);
if (null !== $data) {
$field_name = (string)$field_name;
if (array_key_exists($field_name, $data)) {
return $data[$field_name];
}
}
return null;
} | php | public function getFieldById($id, $field_name)
{
$data = $this->getDataById($id);
if (null !== $data) {
$field_name = (string)$field_name;
if (array_key_exists($field_name, $data)) {
return $data[$field_name];
}
}
return null;
} | [
"public",
"function",
"getFieldById",
"(",
"$",
"id",
",",
"$",
"field_name",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getDataById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"data",
")",
"{",
"$",
"field_name",
"=",
"(",
"s... | Get some field ($field_name) value in the data with id = $id
@param int $id
@param string $field_name
@return mixed|null | [
"Get",
"some",
"field",
"(",
"$field_name",
")",
"value",
"in",
"the",
"data",
"with",
"id",
"=",
"$id"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Data/Data.php#L169-L179 |
kronusme/dota2-api | includes/Utils/Request.php | Request.getParameter | public function getParameter($name)
{
$name = (string)$name;
return array_key_exists($name, $this->_params) ? $this->_params[$name] : null;
} | php | public function getParameter($name)
{
$name = (string)$name;
return array_key_exists($name, $this->_params) ? $this->_params[$name] : null;
} | [
"public",
"function",
"getParameter",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"(",
"string",
")",
"$",
"name",
";",
"return",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"_params",
")",
"?",
"$",
"this",
"->",
"_params",
"[",
... | Get request parameter by its name
@param string $name
@return string | null | [
"Get",
"request",
"parameter",
"by",
"its",
"name"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Utils/Request.php#L64-L68 |
kronusme/dota2-api | includes/Utils/Request.php | Request.setParameter | public function setParameter($name, $value)
{
$name = (string)$name;
$value = (string)$value;
$this->_params[$name] = $value;
return $this;
} | php | public function setParameter($name, $value)
{
$name = (string)$name;
$value = (string)$value;
$this->_params[$name] = $value;
return $this;
} | [
"public",
"function",
"setParameter",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"name",
"=",
"(",
"string",
")",
"$",
"name",
";",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"$",
"this",
"->",
"_params",
"[",
"$",
"name",... | Set parameter by its name and value
@param string $name
@param string $value
@return request | [
"Set",
"parameter",
"by",
"its",
"name",
"and",
"value"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Utils/Request.php#L76-L82 |
kronusme/dota2-api | includes/Utils/Request.php | Request.send | public function send()
{
$ch = curl_init();
$url = $this->_url;
$d = '';
$this->_params['format'] = 'xml';
$this->_params['key'] = self::$apiKey;
// The language to retrieve results in (see http://en.wikipedia.org/wiki/ISO_639-1 for the language codes (first
/... | php | public function send()
{
$ch = curl_init();
$url = $this->_url;
$d = '';
$this->_params['format'] = 'xml';
$this->_params['key'] = self::$apiKey;
// The language to retrieve results in (see http://en.wikipedia.org/wiki/ISO_639-1 for the language codes (first
/... | [
"public",
"function",
"send",
"(",
")",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"_url",
";",
"$",
"d",
"=",
"''",
";",
"$",
"this",
"->",
"_params",
"[",
"'format'",
"]",
"=",
"'xml'",
";",
"$",
"t... | Send request to Valve's servers
@access public
@return SimpleXMLElement | null | [
"Send",
"request",
"to",
"Valve",
"s",
"servers"
] | train | https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Utils/Request.php#L110-L142 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.