_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q243100
Files.copy
validation
public function copy($strSource, $strDestination) { $this->validate($strSource, $strDestination); return copy($this->strRootDir . '/' . $strSource, $this->strRootDir . '/' . $strDestination); }
php
{ "resource": "" }
q243101
Files.rcopy
validation
public function rcopy($strSource, $strDestination) { $this->validate($strSource, $strDestination); $this->mkdir($strDestination); $arrFiles = scan($this->strRootDir . '/' . $strSource, true); foreach ($arrFiles as $strFile) { if (is_dir($this->strRootDir . '/' . $strSource . '/' . $strFile)) { $t...
php
{ "resource": "" }
q243102
Files.chmod
validation
public function chmod($strFile, $varMode) { $this->validate($strFile); return chmod($this->strRootDir . '/' . $strFile, $varMode); }
php
{ "resource": "" }
q243103
Files.move_uploaded_file
validation
public function move_uploaded_file($strSource, $strDestination) { $this->validate($strSource, $strDestination); return move_uploaded_file($strSource, $this->strRootDir . '/' . $strDestination); }
php
{ "resource": "" }
q243104
Files.validate
validation
protected function validate() { foreach (\func_get_args() as $strPath) { if ($strPath == '') // see #5795 { throw new \RuntimeException('No file or folder name given'); } elseif (Validator::isInsecurePath($strPath)) { throw new \RuntimeException('Invalid file or folder name ' . $strPath); ...
php
{ "resource": "" }
q243105
ClearSessionDataListener.onKernelResponse
validation
public function onKernelResponse(FilterResponseEvent $event): void { if (!$event->isMasterRequest()) { return; } $request = $event->getRequest(); if ($request->isMethod('POST')) { return; } if (null === ($session = $request->getSession()) ||...
php
{ "resource": "" }
q243106
tl_newsletter.addSenderPlaceholder
validation
public function addSenderPlaceholder($varValue, Contao\DataContainer $dc) { if ($dc->activeRecord && $dc->activeRecord->pid) { $objChannel = $this->Database->prepare("SELECT sender FROM tl_newsletter_channel WHERE id=?") ->execute($dc->activeRecord->pid); $GLOBALS['TL_DCA'][$dc->table]['fields'][...
php
{ "resource": "" }
q243107
tl_newsletter.addSenderNamePlaceholder
validation
public function addSenderNamePlaceholder($varValue, Contao\DataContainer $dc) { if ($dc->activeRecord && $dc->activeRecord->pid) { $objChannel = $this->Database->prepare("SELECT senderName FROM tl_newsletter_channel WHERE id=?") ->execute($dc->activeRecord->pid); $GLOBALS['TL_DCA'][$dc->table]['f...
php
{ "resource": "" }
q243108
ContaoUserProvider.validateSessionLifetime
validation
private function validateSessionLifetime(User $user): void { if (!$this->session->isStarted()) { return; } /** @var Config $config */ $config = $this->framework->getAdapter(Config::class); $timeout = (int) $config->get('sessionTimeout'); if ($timeout > 0...
php
{ "resource": "" }
q243109
Messages.maintenanceCheck
validation
public function maintenanceCheck() { $this->import(BackendUser::class, 'User'); if (!$this->User->hasAccess('maintenance', 'modules')) { return ''; } try { if (System::getContainer()->get('lexik_maintenance.driver.factory')->getDriver()->isExists()) { return '<p class="tl_error">' . $GLOBALS...
php
{ "resource": "" }
q243110
PhpFileLoader.parseFile
validation
private function parseFile(string $file): array { $code = ''; $namespace = ''; $buffer = false; $stream = new \PHP_Token_Stream($file); foreach ($stream as $token) { switch (true) { case $token instanceof \PHP_Token_OPEN_TAG: case ...
php
{ "resource": "" }
q243111
WebsiteRootsConfigProvider.isCorsRequest
validation
private function isCorsRequest(Request $request): bool { return $request->headers->has('Origin') && $request->headers->get('Origin') !== $request->getSchemeAndHttpHost() ; }
php
{ "resource": "" }
q243112
FileSelector.generateAjax
validation
public function generateAjax($strFolder, $strField, $level, $mount=false) { if (!Environment::get('isAjaxRequest')) { return ''; } $this->strField = $strField; $this->loadDataContainer($this->strTable); // Load the current values switch ($GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer']...
php
{ "resource": "" }
q243113
FileSelector.convertValuesToPaths
validation
protected function convertValuesToPaths() { if (empty($this->varValue)) { return; } if (!\is_array($this->varValue)) { $this->varValue = array($this->varValue); } elseif (empty($this->varValue[0])) { $this->varValue = array(); } if (empty($this->varValue)) { return; } // TinyMC...
php
{ "resource": "" }
q243114
AddAssetsPackagesPass.addBundles
validation
private function addBundles(ContainerBuilder $container): void { $packages = $container->getDefinition('assets.packages'); $context = new Reference('contao.assets.assets_context'); if ($container->hasDefinition('assets._version_default')) { $version = new Reference('assets._vers...
php
{ "resource": "" }
q243115
AddAssetsPackagesPass.addComponents
validation
private function addComponents(ContainerBuilder $container): void { $packages = $container->getDefinition('assets.packages'); $context = new Reference('contao.assets.assets_context'); foreach (Versions::VERSIONS as $name => $version) { if (0 !== strncmp('contao-components/', $na...
php
{ "resource": "" }
q243116
AddAssetsPackagesPass.getBundlePackageName
validation
private function getBundlePackageName(string $className): string { if ('Bundle' === substr($className, -6)) { $className = substr($className, 0, -6); } return Container::underscore($className); }
php
{ "resource": "" }
q243117
DC_Folder.create
validation
public function create() { if ($GLOBALS['TL_DCA'][$this->strTable]['config']['notCreatable']) { throw new InternalServerErrorException('Table "' . $this->strTable . '" is not creatable.'); } $this->import(Files::class, 'Files'); $strFolder = Input::get('pid', true); if ($strFolder == '' || !file_exist...
php
{ "resource": "" }
q243118
DC_Folder.delete
validation
public function delete($source=null) { if ($GLOBALS['TL_DCA'][$this->strTable]['config']['notDeletable']) { throw new InternalServerErrorException('Table "' . $this->strTable . '" is not deletable.'); } $blnDoNotRedirect = ($source !== null); if ($source === null) { $source = $this->intId; } $...
php
{ "resource": "" }
q243119
DC_Folder.deleteAll
validation
public function deleteAll() { if ($GLOBALS['TL_DCA'][$this->strTable]['config']['notDeletable']) { throw new InternalServerErrorException('Table "' . $this->strTable . '" is not deletable.'); } /** @var Session $objSession */ $objSession = System::getContainer()->get('session'); $session = $objSession...
php
{ "resource": "" }
q243120
DC_Folder.protect
validation
public function protect() { @trigger_error('Using DC_Folder::protect() has been deprecated and will no longer work in Contao 5.0. Use Contao\Folder::protect() and Contao\Folder::unprotect() instead.', E_USER_DEPRECATED); if (!is_dir($this->strRootDir . '/' . $this->intId)) { throw new InternalServerErrorExce...
php
{ "resource": "" }
q243121
DC_Folder.isMounted
validation
protected function isMounted($strFolder) { if ($strFolder == '') { return false; } if (empty($this->arrFilemounts)) { return true; } $path = $strFolder; while (\is_array($this->arrFilemounts) && substr_count($path, '/') > 0) { if (\in_array($path, $this->arrFilemounts)) { return tr...
php
{ "resource": "" }
q243122
DC_Folder.isValid
validation
protected function isValid($strFile) { $strFolder = Input::get('pid', true); // Check the path if (Validator::isInsecurePath($strFile)) { throw new AccessDeniedException('Invalid file name "' . $strFile . '" (hacking attempt).'); } elseif (Validator::isInsecurePath($strFolder)) { throw new AccessD...
php
{ "resource": "" }
q243123
DC_Folder.getMD5Folders
validation
protected function getMD5Folders($strPath) { $arrFiles = array(); foreach (scan($this->strRootDir . '/' . $strPath) as $strFile) { if (!is_dir($this->strRootDir . '/' . $strPath . '/' . $strFile)) { continue; } $arrFiles[substr(md5($this->strRootDir . '/' . $strPath . '/' . $strFile), 0, 8)] = ...
php
{ "resource": "" }
q243124
QueryBuilder.find
validation
public static function find(array $arrOptions) { $objBase = DcaExtractor::getInstance($arrOptions['table']); if (!$objBase->hasRelations()) { $strQuery = "SELECT * FROM " . $arrOptions['table']; } else { $arrJoins = array(); $arrFields = array($arrOptions['table'] . ".*"); $intCount = 0; f...
php
{ "resource": "" }
q243125
QueryBuilder.count
validation
public static function count(array $arrOptions) { $strQuery = "SELECT COUNT(*) AS count FROM " . $arrOptions['table']; if ($arrOptions['column'] !== null) { $strQuery .= " WHERE " . (\is_array($arrOptions['column']) ? implode(" AND ", $arrOptions['column']) : $arrOptions['table'] . '.' . Database::quoteIdent...
php
{ "resource": "" }
q243126
Pagination.getItemsAsString
validation
public function getItemsAsString($strSeparator=' ') { $arrLinks = array(); foreach ($this->getItemsAsArray() as $arrItem) { if ($arrItem['href'] === null) { $arrLinks[] = sprintf('<li><strong class="active">%s</strong></li>', $arrItem['page']); } else { $arrLinks[] = sprintf('<li><a href=...
php
{ "resource": "" }
q243127
Pagination.getItemsAsArray
validation
public function getItemsAsArray() { $arrLinks = array(); $intNumberOfLinks = floor($this->intNumberOfLinks / 2); $intFirstOffset = $this->intPage - $intNumberOfLinks - 1; if ($intFirstOffset > 0) { $intFirstOffset = 0; } $intLastOffset = $this->intPage + $intNumberOfLinks - $this->intTotalPages; ...
php
{ "resource": "" }
q243128
Pagination.linkToPage
validation
protected function linkToPage($intPage) { if ($intPage <= 1 && !$this->blnForceParam) { return ampersand($this->strUrl); } else { return ampersand($this->strUrl) . $this->strVarConnector . $this->strParameter . '=' . $intPage; } }
php
{ "resource": "" }
q243129
PageSelector.generateAjax
validation
public function generateAjax($id, $strField, $level) { if (!Environment::get('isAjaxRequest')) { return ''; } $this->strField = $strField; $this->loadDataContainer($this->strTable); // Load current values switch ($GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer']) { case 'File': ...
php
{ "resource": "" }
q243130
PageSelector.getPathNodes
validation
protected function getPathNodes() { if (!$this->varValue) { return; } if (!\is_array($this->varValue)) { $this->varValue = array($this->varValue); } foreach ($this->varValue as $id) { $arrPids = $this->Database->getParentRecords($id, 'tl_page'); array_shift($arrPids); // the first element...
php
{ "resource": "" }
q243131
HtaccessAnalyzer.grantsAccess
validation
public function grantsAccess(): bool { $content = array_filter(file((string) $this->file)); foreach ($content as $line) { if ($this->hasRequireGranted($line)) { return true; } } return false; }
php
{ "resource": "" }
q243132
HtaccessAnalyzer.hasRequireGranted
validation
private function hasRequireGranted(string $line): bool { if ($this->isComment($line)) { return false; } return (false !== stripos($line, 'Allow from all')) || (false !== stripos($line, 'Require all granted')); }
php
{ "resource": "" }
q243133
SyncExclude.accept
validation
public function accept() { // The resource is to be ignored if (strncmp($this->current()->getFilename(), '.', 1) === 0) { return false; } $strPath = $this->current()->getPathname(); if (is_file($strPath)) { $strPath = \dirname($strPath); } $objFolder = new Folder(StringUtil::stripRootDir($st...
php
{ "resource": "" }
q243134
AuthenticationFailureHandler.onAuthenticationFailure
validation
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): Response { if (null === $this->logger) { return parent::onAuthenticationFailure($request, $exception); } if ($exception instanceof AccountStatusException && ($user = $exception->getUse...
php
{ "resource": "" }
q243135
ContentImage.generate
validation
public function generate() { if ($this->singleSRC == '') { return ''; } $objFile = FilesModel::findByUuid($this->singleSRC); if ($objFile === null || !is_file(System::getContainer()->getParameter('kernel.project_dir') . '/' . $objFile->path)) { return ''; } $this->singleSRC = $objFile->path; ...
php
{ "resource": "" }
q243136
InstallWebDirCommand.addHtaccess
validation
private function addHtaccess(string $webDir): void { $htaccess = __DIR__.'/../Resources/skeleton/web/.htaccess'; if (!file_exists($webDir.'/.htaccess')) { $this->fs->copy($htaccess, $webDir.'/.htaccess', true); $this->io->writeln('Added the <comment>web/.htaccess</comment> f...
php
{ "resource": "" }
q243137
InstallWebDirCommand.purgeOldFiles
validation
private function purgeOldFiles(string $webDir): void { if (file_exists($webDir.'/app_dev.php')) { $this->fs->remove($webDir.'/app_dev.php'); $this->io->writeln('Deleted the <comment>web/app_dev.php</comment> file.'); } if (file_exists($webDir.'/install.php')) { ...
php
{ "resource": "" }
q243138
InstallWebDirCommand.isExistingOptionalFile
validation
private function isExistingOptionalFile(SplFileInfo $file, string $webDir): bool { $path = $file->getRelativePathname(); return 'robots.txt' === $path && $this->fs->exists($webDir.'/'.$path); }
php
{ "resource": "" }
q243139
UserChecker.checkIfAccountIsActive
validation
private function checkIfAccountIsActive(User $user): void { /** @var Config $config */ $config = $this->framework->getAdapter(Config::class); $start = (int) $user->start; $stop = (int) $user->stop; $time = Date::floorToMinute(time()); $notActiveYet = $start && $start...
php
{ "resource": "" }
q243140
ImageFactory.createConfig
validation
private function createConfig($size, ImageInterface $image): array { if (!\is_array($size)) { $size = [0, 0, $size]; } $config = new ResizeConfiguration(); if (isset($size[2]) && is_numeric($size[2])) { /** @var ImageSizeModel $imageModel */ $ima...
php
{ "resource": "" }
q243141
ImageFactory.createImportantPart
validation
private function createImportantPart(ImageInterface $image): ?ImportantPart { /** @var FilesModel $filesModel */ $filesModel = $this->framework->getAdapter(FilesModel::class); $file = $filesModel->findByPath($image->getPath()); if (null === $file || !$file->importantPartWidth || !$f...
php
{ "resource": "" }
q243142
FormSelectMenu.validate
validation
public function validate() { $mandatory = $this->mandatory; $options = $this->getPost($this->strName); // Check if there is at least one value if ($mandatory && \is_array($options)) { foreach ($options as $option) { if (\strlen($option)) { $this->mandatory = false; break; } } ...
php
{ "resource": "" }
q243143
Statement.prepare
validation
public function prepare($strQuery) { if ($strQuery == '') { throw new \Exception('Empty query string'); } $this->strQuery = trim($strQuery); // Auto-generate the SET/VALUES subpart if (strncasecmp($this->strQuery, 'INSERT', 6) === 0 || strncasecmp($this->strQuery, 'UPDATE', 6) === 0) { $this->str...
php
{ "resource": "" }
q243144
Statement.limit
validation
public function limit($intRows, $intOffset=0) { if ($intRows <= 0) { $intRows = 30; } if ($intOffset < 0) { $intOffset = 0; } if (strncasecmp($this->strQuery, 'SELECT', 6) === 0) { $this->strQuery .= ' LIMIT ' . $intOffset . ',' . $intRows; } else { $this->strQuery .= ' LIMIT ' . $i...
php
{ "resource": "" }
q243145
Statement.execute
validation
public function execute() { $arrParams = \func_get_args(); if (!empty($arrParams) && \is_array($arrParams[0])) { $arrParams = array_values($arrParams[0]); } $this->replaceWildcards($arrParams); return $this->query(); }
php
{ "resource": "" }
q243146
Statement.query
validation
public function query($strQuery='') { if (!empty($strQuery)) { $this->strQuery = trim($strQuery); } // Make sure there is a query string if ($this->strQuery == '') { throw new \Exception('Empty query string'); } // Execute the query $this->statement = $this->resConnection->executeQuery($this-...
php
{ "resource": "" }
q243147
Statement.replaceWildcards
validation
protected function replaceWildcards($arrValues) { $arrValues = $this->escapeParams($arrValues); $this->strQuery = preg_replace('/(?<!%)%([^bcdufosxX%])/', '%%$1', $this->strQuery); // Replace wildcards if (!$this->strQuery = @vsprintf($this->strQuery, $arrValues)) { throw new \Exception('Too few argument...
php
{ "resource": "" }
q243148
Statement.escapeParams
validation
protected function escapeParams($arrValues) { foreach ($arrValues as $k=>$v) { switch (\gettype($v)) { case 'string': $arrValues[$k] = $this->resConnection->quote($v); break; case 'boolean': $arrValues[$k] = ($v === true) ? 1 : 0; break; case 'object': $arrValues[$k] = ...
php
{ "resource": "" }
q243149
ModelArgumentResolver.getArgumentName
validation
private function getArgumentName(Request $request, ArgumentMetadata $argument): ?string { if ($request->attributes->has($argument->getName())) { return $argument->getName(); } $className = lcfirst($this->stripNamespace($argument->getType())); if ($request->attributes->h...
php
{ "resource": "" }
q243150
ModelArgumentResolver.stripNamespace
validation
private function stripNamespace(string $fqcn): string { if (false !== ($pos = strrpos($fqcn, '\\'))) { return substr($fqcn, $pos + 1); } return $fqcn; }
php
{ "resource": "" }
q243151
AbstractFragmentController.createTemplate
validation
protected function createTemplate(Model $model, string $templateName): Template { if (isset($this->options['template'])) { $templateName = $this->options['template']; } if ($model->customTpl) { $templateName = $model->customTpl; } $template = $this->...
php
{ "resource": "" }
q243152
AbstractFragmentController.getType
validation
protected function getType(): string { if (isset($this->options['type'])) { return $this->options['type']; } $className = ltrim(strrchr(static::class, '\\'), '\\'); if ('Controller' === substr($className, -10)) { $className = substr($className, 0, -10); ...
php
{ "resource": "" }
q243153
BackendController.pickerAction
validation
public function pickerAction(Request $request): RedirectResponse { $extras = []; if ($request->query->has('extras')) { $extras = $request->query->get('extras'); if (!\is_array($extras)) { throw new BadRequestHttpException('Invalid picker extras'); ...
php
{ "resource": "" }
q243154
FormCaptcha.generateCaptcha
validation
protected function generateCaptcha() { if ($this->arrCaptcha) { return; } $int1 = random_int(1, 9); $int2 = random_int(1, 9); $this->arrCaptcha = array ( 'int1' => $int1, 'int2' => $int2, 'sum' => $int1 + $int2, 'key' => $this->strCaptchaKey, 'hashes' => $this->generateHashes($int1 + ...
php
{ "resource": "" }
q243155
FormCaptcha.generateHashes
validation
protected function generateHashes($sum) { // Round the time to 30 minutes $time = (int) round(time() / 60 / 30); return array_map( function ($hashTime) use ($sum) { return hash_hmac('sha256', $sum . "\0" . $hashTime, System::getContainer()->getParameter('kernel.secret')); }, array($time, $time -...
php
{ "resource": "" }
q243156
FormCaptcha.getQuestion
validation
protected function getQuestion() { $this->generateCaptcha(); $question = $GLOBALS['TL_LANG']['SEC']['question' . random_int(1, 3)]; $question = sprintf($question, $this->arrCaptcha['int1'], $this->arrCaptcha['int2']); $strEncoded = ''; $arrCharacters = Utf8::str_split($question); foreach ($arrCharacters...
php
{ "resource": "" }
q243157
FormCaptcha.generateQuestion
validation
public function generateQuestion() { return sprintf('<span id="captcha_text_%s" class="captcha_text%s">%s</span>', $this->strId, (($this->strClass != '') ? ' ' . $this->strClass : ''), $this->getQuestion()); }
php
{ "resource": "" }
q243158
NewsFeedModel.findByArchive
validation
public static function findByArchive($intId, array $arrOptions=array()) { $t = static::$strTable; return static::findBy(array("$t.archives LIKE '%\"" . (int) $intId . "\"%'"), null, $arrOptions); }
php
{ "resource": "" }
q243159
NewsFeedModel.findByIds
validation
public static function findByIds($arrIds, array $arrOptions=array()) { if (empty($arrIds) || !\is_array($arrIds)) { return null; } $t = static::$strTable; return static::findBy(array("$t.id IN(" . implode(',', array_map('\intval', $arrIds)) . ")"), null, $arrOptions); }
php
{ "resource": "" }
q243160
DcaSchemaProvider.appendToSchema
validation
public function appendToSchema(Schema $schema): void { $config = $this->getSqlDefinitions(); foreach ($config as $tableName => $definitions) { $table = $schema->createTable($tableName); // Parse the table options first if (isset($definitions['TABLE_OPTIONS'])) {...
php
{ "resource": "" }
q243161
DcaSchemaProvider.getSqlDefinitions
validation
private function getSqlDefinitions(): array { $this->framework->initialize(); /** @var Installer $installer */ $installer = $this->framework->createInstance(Installer::class); $sqlTarget = $installer->getFromDca(); $sqlLegacy = $installer->getFromFile(); // Manually...
php
{ "resource": "" }
q243162
DcaSchemaProvider.getIndexLength
validation
private function getIndexLength(Table $table, string $column): ?int { $col = $table->getColumn($column); // Not a text field if (null === ($length = $col->getLength())) { return null; } // Return if the field is shorter than the shortest possible index /...
php
{ "resource": "" }
q243163
GdImage.fromFile
validation
public static function fromFile(File $file) { $extension = strtolower($file->extension); $function = null; if ($extension === 'jpg') { $extension = 'jpeg'; } if (\in_array($extension, array('gif', 'jpeg', 'png'))) { $function = 'imagecreatefrom' . $extension; } if ($function === null || !\is...
php
{ "resource": "" }
q243164
GdImage.fromDimensions
validation
public static function fromDimensions($width, $height) { $image = imagecreatetruecolor($width, $height); $arrGdInfo = gd_info(); $strGdVersion = preg_replace('/[^0-9.]+/', '', $arrGdInfo['GD Version']); // Handle transparency (GDlib >= 2.0 required) if (version_compare($strGdVersion, '2.0', '>=')) { i...
php
{ "resource": "" }
q243165
GdImage.setResource
validation
public function setResource($gdResource) { if (!\is_resource($gdResource) || get_resource_type($gdResource) !== 'gd') { throw new \InvalidArgumentException('$gdResource is not a valid GD resource'); } $this->gdResource = $gdResource; return $this; }
php
{ "resource": "" }
q243166
GdImage.convertToPaletteImage
validation
public function convertToPaletteImage() { if (!imageistruecolor($this->gdResource)) { return $this; } $width = imagesx($this->gdResource); $height = imagesy($this->gdResource); $transparentColor = null; if ($this->countColors(256) <= 256) { $paletteImage = imagecreate($width, $height); $col...
php
{ "resource": "" }
q243167
GdImage.countColors
validation
public function countColors($max = null) { if (!imageistruecolor($this->gdResource)) { return imagecolorstotal($this->gdResource); } $colors = array(); $width = imagesx($this->gdResource); $height = imagesy($this->gdResource); for ($x = 0; $x < $width; $x++) { for ($y = 0; $y < $height; $y++) ...
php
{ "resource": "" }
q243168
GdImage.isSemitransparent
validation
public function isSemitransparent() { if (!imageistruecolor($this->gdResource)) { return false; } $width = imagesx($this->gdResource); $height = imagesy($this->gdResource); for ($x = 0; $x < $width; $x++) { for ($y = 0; $y < $height; $y++) { // Check if the pixel is semitransparent $al...
php
{ "resource": "" }
q243169
InputUnit.validator
validation
protected function validator($varInput) { foreach ($varInput as $k=>$v) { if ($k != 'unit') { $varInput[$k] = parent::validator($v); } } return $varInput; }
php
{ "resource": "" }
q243170
ContentMarkdown.generate
validation
public function generate() { if (TL_MODE == 'BE') { $return = '<pre>'. StringUtil::specialchars($this->code) .'</pre>'; if ($this->headline != '') { $return = '<'. $this->hl .'>'. $this->headline .'</'. $this->hl .'>'. $return; } return $return; } return parent::generate(); }
php
{ "resource": "" }
q243171
Email.attachFile
validation
public function attachFile($strFile, $strMime='application/octet-stream') { $this->objMessage->attach(\Swift_Attachment::fromPath($strFile, $strMime)->setFilename(basename($strFile))); }
php
{ "resource": "" }
q243172
Email.attachFileFromString
validation
public function attachFileFromString($strContent, $strFilename, $strMime='application/octet-stream') { $this->objMessage->attach(new \Swift_Attachment($strContent, $strFilename, $strMime)); }
php
{ "resource": "" }
q243173
BackendTemplate.parse
validation
public function parse() { $strBuffer = parent::parse(); // HOOK: add custom parse filters if (isset($GLOBALS['TL_HOOKS']['parseBackendTemplate']) && \is_array($GLOBALS['TL_HOOKS']['parseBackendTemplate'])) { foreach ($GLOBALS['TL_HOOKS']['parseBackendTemplate'] as $callback) { $this->import($callbac...
php
{ "resource": "" }
q243174
BackendTemplate.getLocaleString
validation
protected function getLocaleString() { $container = System::getContainer(); return 'var Contao={' . 'theme:"' . Backend::getTheme() . '",' . 'lang:{' . 'close:"' . $GLOBALS['TL_LANG']['MSC']['close'] . '",' . 'collapse:"' . $GLOBALS['TL_LANG']['MSC']['collapseNode'] . '",' . 'expand:"' ....
php
{ "resource": "" }
q243175
BackendTemplate.getDateString
validation
protected function getDateString() { return 'Locale.define("en-US","Date",{' . 'months:["' . implode('","', $GLOBALS['TL_LANG']['MONTHS']) . '"],' . 'days:["' . implode('","', $GLOBALS['TL_LANG']['DAYS']) . '"],' . 'months_abbr:["' . implode('","', $GLOBALS['TL_LANG']['MONTHS_SHORT']) . '"],' . 'd...
php
{ "resource": "" }
q243176
PageForward.generate
validation
public function generate($objPage) { $this->redirect($this->getForwardUrl($objPage), $this->getRedirectStatusCode($objPage)); }
php
{ "resource": "" }
q243177
PageForward.getForwardUrl
validation
protected function getForwardUrl($objPage) { if ($objPage->jumpTo) { $objNextPage = PageModel::findPublishedById($objPage->jumpTo); } else { $objNextPage = PageModel::findFirstPublishedRegularByPid($objPage->id); } // Forward page does not exist if (!$objNextPage instanceof PageModel) { $th...
php
{ "resource": "" }
q243178
FilePickerProvider.convertValueToPath
validation
private function convertValueToPath(string $value): string { /** @var FilesModel $filesAdapter */ $filesAdapter = $this->framework->getAdapter(FilesModel::class); if (Validator::isUuid($value) && ($filesModel = $filesAdapter->findByUuid($value)) instanceof FilesModel) { return $...
php
{ "resource": "" }
q243179
tl_newsletter_channel.adjustPermissions
validation
public function adjustPermissions($insertId) { // The oncreate_callback passes $insertId as second argument if (\func_num_args() == 4) { $insertId = func_get_arg(1); } if ($this->User->isAdmin) { return; } // Set root IDs if (empty($this->User->newsletters) || !\is_array($this->User->newslett...
php
{ "resource": "" }
q243180
tl_newsletter_recipients.clearOptInData
validation
public function clearOptInData(Contao\DataContainer $dc) { $this->Database->prepare("UPDATE tl_newsletter_recipients SET addedOn='' WHERE id=?") ->execute($dc->id); }
php
{ "resource": "" }
q243181
tl_newsletter_recipients.checkUniqueRecipient
validation
public function checkUniqueRecipient($varValue, Contao\DataContainer $dc) { $objRecipient = $this->Database->prepare("SELECT COUNT(*) AS count FROM tl_newsletter_recipients WHERE email=? AND pid=(SELECT pid FROM tl_newsletter_recipients WHERE id=?) AND id!=?") ->execute($varValue, $dc->id, $dc->id); i...
php
{ "resource": "" }
q243182
tl_newsletter_recipients.checkBlacklistedRecipient
validation
public function checkBlacklistedRecipient($varValue, Contao\DataContainer $dc) { $objBlacklist = $this->Database->prepare("SELECT COUNT(*) AS count FROM tl_newsletter_blacklist WHERE hash=? AND pid=(SELECT pid FROM tl_newsletter_recipients WHERE id=?) AND id!=?") ->execute(md5($varValue), $dc->id, $dc->i...
php
{ "resource": "" }
q243183
tl_newsletter_recipients.listRecipient
validation
public function listRecipient($row) { $label = Contao\Idna::decodeEmail($row['email']); if ($row['addedOn']) { $label .= ' <span style="color:#999;padding-left:3px">(' . sprintf($GLOBALS['TL_LANG']['tl_newsletter_recipients']['subscribed'], Contao\Date::parse(Contao\Config::get('datimFormat'), $row['addedOn'...
php
{ "resource": "" }
q243184
AssetListener.onReplaceInsertTags
validation
public function onReplaceInsertTags(string $tag) { $chunks = explode('::', $tag); if ('asset' !== $chunks[0]) { return false; } $url = $this->packages->getUrl($chunks[1], $chunks[2] ?? null); // Contao paths are relative to the <base> tag, so remove leading sla...
php
{ "resource": "" }
q243185
FrontendTemplate.section
validation
public function section($key, $template=null) { if (empty($this->sections[$key])) { return; } $this->id = $key; $this->content = $this->sections[$key]; if ($template === null) { $template = 'block_section'; foreach ($this->positions as $position) { if (isset($position[$key]['template']...
php
{ "resource": "" }
q243186
FrontendTemplate.sections
validation
public function sections($key=null, $template=null) { if (!array_filter($this->sections)) { return; } // The key does not match if ($key && !isset($this->positions[$key])) { return; } $matches = array(); foreach ($this->positions[$key] as $id=>$section) { if (!empty($this->sections[$id]...
php
{ "resource": "" }
q243187
FrontendTemplate.getCustomSections
validation
public function getCustomSections($strKey=null) { @trigger_error('Using FrontendTemplate::getCustomSections() has been deprecated and will no longer work in Contao 5.0. Use FrontendTemplate::sections() instead.', E_USER_DEPRECATED); if ($strKey != '' && !isset($this->positions[$strKey])) { return ''; } ...
php
{ "resource": "" }
q243188
FrontendTemplate.setCacheHeaders
validation
private function setCacheHeaders(Response $response) { /** @var PageModel $objPage */ global $objPage; if (($objPage->cache === false || $objPage->cache < 1) && ($objPage->clientCache === false || $objPage->clientCache < 1)) { $response->headers->addCacheControlDirective('no-cache'); $response->headers-...
php
{ "resource": "" }
q243189
PageRedirect.generate
validation
public function generate($objPage) { $this->redirect($this->replaceInsertTags($objPage->url, false), $this->getRedirectStatusCode($objPage)); }
php
{ "resource": "" }
q243190
tl_opt_in.showRelatedRecords
validation
public function showRelatedRecords($data, $row) { Contao\System::loadLanguageFile('tl_opt_in_related'); Contao\Controller::loadDataContainer('tl_opt_in_related'); $objRelated = $this->Database->prepare("SELECT * FROM tl_opt_in_related WHERE pid=?") ->execute($row['id']); while ($objRelated->next())...
php
{ "resource": "" }
q243191
tl_opt_in.resendToken
validation
public function resendToken(Contao\DataContainer $dc) { $model = Contao\OptInModel::findByPk($dc->id); Contao\System::getContainer()->get('contao.opt-in')->find($model->token)->send(); Contao\Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['MSC']['resendToken'], $model->email)); Contao\Controller::redire...
php
{ "resource": "" }
q243192
tl_opt_in.resendButton
validation
public function resendButton($row, $href, $label, $title, $icon, $attributes) { return (!$row['confirmedOn'] &&!$row['invalidatedThrough'] && $row['emailSubject'] && $row['emailText'] && $row['createdOn'] > strtotime('-24 hours')) ? '<a href="'.$this->addToUrl($href.'&amp;id='.$row['id']).'" title="'.Contao\StringUt...
php
{ "resource": "" }
q243193
CommentsNotifyModel.findBySourceParentAndEmail
validation
public static function findBySourceParentAndEmail($strSource, $intParent, $strEmail, array $arrOptions=array()) { $t = static::$strTable; return static::findOneBy(array("$t.source=? AND $t.parent=? AND $t.email=?"), array($strSource, $intParent, $strEmail), $arrOptions); }
php
{ "resource": "" }
q243194
CommentsNotifyModel.findActiveBySourceAndParent
validation
public static function findActiveBySourceAndParent($strSource, $intParent, array $arrOptions=array()) { $t = static::$strTable; return static::findBy(array("$t.source=? AND $t.parent=? AND $t.active='1'"), array($strSource, $intParent), $arrOptions); }
php
{ "resource": "" }
q243195
CommentsNotifyModel.findExpiredSubscriptions
validation
public static function findExpiredSubscriptions(array $arrOptions=array()) { $t = static::$strTable; $objDatabase = Database::getInstance(); $objResult = $objDatabase->prepare("SELECT * FROM $t WHERE active='' AND EXISTS (SELECT * FROM tl_opt_in_related r LEFT JOIN tl_opt_in o ON r.pid=o.id WHERE r.relTable='$t...
php
{ "resource": "" }
q243196
tl_layout.getStyleSheets
validation
public function getStyleSheets(Contao\DataContainer $dc) { $intPid = $dc->activeRecord->pid; if (Contao\Input::get('act') == 'overrideAll') { $intPid = Contao\Input::get('id'); } $objStyleSheet = $this->Database->prepare("SELECT id, name FROM tl_style_sheet WHERE pid=?") ->execute($intPid); ...
php
{ "resource": "" }
q243197
tl_layout.styleSheetLink
validation
public function styleSheetLink(Contao\DataContainer $dc) { return ' <a href="contao/main.php?do=themes&amp;table=tl_style_sheet&amp;id=' . $dc->activeRecord->pid . '&amp;popup=1&amp;nb=1&amp;rt=' . REQUEST_TOKEN . '" title="' . Contao\StringUtil::specialchars($GLOBALS['TL_LANG']['tl_layout']['edit_styles']) . '" onc...
php
{ "resource": "" }
q243198
ContentVimeo.generate
validation
public function generate() { if ($this->vimeo == '') { return ''; } if (TL_MODE == 'BE') { $return = '<p><a href="https://vimeo.com/' . $this->vimeo . '" target="_blank" rel="noreferrer noopener">vimeo.com/' . $this->vimeo . '</a></p>'; if ($this->headline != '') { $return = '<'. $this->hl ...
php
{ "resource": "" }
q243199
AutomatorCommand.getTaskFromInput
validation
private function getTaskFromInput(InputInterface $input, OutputInterface $output): string { $commands = $this->getCommands(); $task = $input->getArgument('task'); if (null !== $task) { if (!\in_array($task, $commands, true)) { throw new \InvalidArgumentException(...
php
{ "resource": "" }