_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q242900 | Suggestion.create | validation | public static function create($reply = null)
{
$suggestion = new self();
if ($reply) {
$suggestion->reply($reply);
}
return $suggestion;
} | php | {
"resource": ""
} |
q242901 | Suggestion.reply | validation | public function reply($reply)
{
if (is_string($reply)) {
$this->replies = [$reply];
} elseif (is_array($reply)) {
$this->replies = $reply;
}
return $this;
} | php | {
"resource": ""
} |
q242902 | MediaObject.render | validation | public function render()
{
$mediaObject = [];
$mediaObject['contentUrl'] = $this->url;
if ($this->name) {
$mediaObject['name'] = $this->name;
}
if ($this->description) {
$mediaObject['description'] = $this->description;
}
if ($this->icon) {
$mediaObject['icon'] = ['url' => $this->icon];
}
if ($this->image) {
$mediaObject['largeImage'] = ['url' => $this->image];
}
return $mediaObject;
} | php | {
"resource": ""
} |
q242903 | WebhookClient.reply | validation | public function reply($message)
{
if (is_string($message)) {
$this->messages[] = Text::create()
->text($message)
->setAgentVersion($this->agentVersion)
->setRequestSource($this->requestSource);
if (! $this->doesSupportRichMessage()) {
$this->text = $message;
}
} elseif ($message instanceof RichMessage) {
if (! $this->doesSupportRichMessage()) {
$this->text = $message->getFallbackText();
}
$message->setAgentVersion($this->agentVersion)
->setRequestSource($this->requestSource);
$this->messages[] = $message;
} elseif ($message instanceof Conversation) {
$this->messages[] = Payload::create($message->render())
->setAgentVersion($this->agentVersion)
->setRequestSource($this->requestSource);
}
return $this;
} | php | {
"resource": ""
} |
q242904 | BasicCard.image | validation | public function image($imageUrl, $accessibilityText = null)
{
$this->imageUrl = $imageUrl;
$this->accessibilityText = $accessibilityText;
return $this;
} | php | {
"resource": ""
} |
q242905 | Countries.getCountries | validation | protected function getCountries()
{
//Get the countries from the JSON file
if (sizeof($this->countries) == 0) {
$this->countries = json_decode(file_get_contents(__DIR__ . '/Models/countries.json'), true);
}
//Return the countries
return $this->countries;
} | php | {
"resource": ""
} |
q242906 | Countries.getListForSelect | validation | public function getListForSelect($display = 'name')
{
foreach ($this->getList($display) as $key => $value) {
$countries[$key] = $value[$display];
}
//return the array
return $countries;
} | php | {
"resource": ""
} |
q242907 | ModuleTwoFactor.enableTwoFactor | validation | protected function enableTwoFactor(BackendUser $user, $return)
{
// Return if 2FA is enabled already
if ($user->useTwoFactor)
{
return;
}
$container = System::getContainer();
$verifyHelp = $GLOBALS['TL_LANG']['MSC']['twoFactorVerificationHelp'];
/** @var Authenticator $authenticator */
$authenticator = $container->get('contao.security.two_factor.authenticator');
// Validate the verification code
if (Input::post('FORM_SUBMIT') == 'tl_two_factor')
{
if ($authenticator->validateCode($user, Input::post('verify')))
{
// Enable 2FA
$user->useTwoFactor = '1';
$user->save();
throw new RedirectResponseException($return);
}
$this->Template->error = true;
$verifyHelp = $GLOBALS['TL_LANG']['ERR']['invalidTwoFactor'];
}
// Generate the secret
if (!$user->secret)
{
$user->secret = random_bytes(128);
$user->save();
}
/** @var Request $request */
$request = $container->get('request_stack')->getCurrentRequest();
$this->Template->enable = true;
$this->Template->secret = Base32::encodeUpperUnpadded($user->secret);
$this->Template->textCode = $GLOBALS['TL_LANG']['MSC']['twoFactorTextCode'];
$this->Template->qrCode = base64_encode($authenticator->getQrCode($user, $request));
$this->Template->scan = $GLOBALS['TL_LANG']['MSC']['twoFactorScan'];
$this->Template->verify = $GLOBALS['TL_LANG']['MSC']['twoFactorVerification'];
$this->Template->verifyHelp = $verifyHelp;
} | php | {
"resource": ""
} |
q242908 | ModuleTwoFactor.disableTwoFactor | validation | protected function disableTwoFactor(BackendUser $user, $return)
{
// Return if 2FA is disabled already
if (!$user->useTwoFactor)
{
return;
}
$user->secret = null;
$user->useTwoFactor = '';
$user->save();
throw new RedirectResponseException($return);
} | php | {
"resource": ""
} |
q242909 | Folder.purge | validation | public function purge()
{
$this->Files->rrdir($this->strFolder, true);
// Update the database
if (Dbafs::shouldBeSynchronized($this->strFolder))
{
$objFiles = FilesModel::findMultipleByBasepath($this->strFolder . '/');
if ($objFiles !== null)
{
while ($objFiles->next())
{
$objFiles->delete();
}
}
Dbafs::updateFolderHashes($this->strFolder);
}
} | php | {
"resource": ""
} |
q242910 | Folder.delete | validation | public function delete()
{
$this->Files->rrdir($this->strFolder);
// Update the database
if (Dbafs::shouldBeSynchronized($this->strFolder))
{
Dbafs::deleteResource($this->strFolder);
}
} | php | {
"resource": ""
} |
q242911 | Folder.renameTo | validation | public function renameTo($strNewName)
{
$strParent = \dirname($strNewName);
// Create the parent folder if it does not exist
if (!is_dir($this->strRootDir . '/' . $strParent))
{
new self($strParent);
}
$return = $this->Files->rename($this->strFolder, $strNewName);
// Update the database AFTER the folder has been renamed
$syncSource = Dbafs::shouldBeSynchronized($this->strFolder);
$syncTarget = Dbafs::shouldBeSynchronized($strNewName);
// Synchronize the database
if ($syncSource && $syncTarget)
{
$this->objModel = Dbafs::moveResource($this->strFolder, $strNewName);
}
elseif ($syncSource)
{
$this->objModel = Dbafs::deleteResource($this->strFolder);
}
elseif ($syncTarget)
{
$this->objModel = Dbafs::addResource($strNewName);
}
// Reset the object AFTER the database has been updated
if ($return != false)
{
$this->strFolder = $strNewName;
}
return $return;
} | php | {
"resource": ""
} |
q242912 | Folder.copyTo | validation | public function copyTo($strNewName)
{
$strParent = \dirname($strNewName);
// Create the parent folder if it does not exist
if (!is_dir($this->strRootDir . '/' . $strParent))
{
new self($strParent);
}
$this->Files->rcopy($this->strFolder, $strNewName);
// Update the database AFTER the folder has been renamed
$syncSource = Dbafs::shouldBeSynchronized($this->strFolder);
$syncTarget = Dbafs::shouldBeSynchronized($strNewName);
if ($syncSource && $syncTarget)
{
Dbafs::copyResource($this->strFolder, $strNewName);
}
elseif ($syncTarget)
{
Dbafs::addResource($strNewName);
}
return true;
} | php | {
"resource": ""
} |
q242913 | Folder.protect | validation | public function protect()
{
if (!$this->isUnprotected())
{
return;
}
// Check if the .public file exists
if (!file_exists($this->strRootDir . '/' . $this->strFolder . '/.public'))
{
throw new \RuntimeException(sprintf('Cannot protect folder "%s" because one of its parent folders is public', $this->strFolder));
}
(new File($this->strFolder . '/.public'))->delete();
} | php | {
"resource": ""
} |
q242914 | Folder.isUnprotected | validation | public function isUnprotected()
{
$path = $this->strFolder;
do
{
if (file_exists($this->strRootDir . '/' . $path . '/.public'))
{
return true;
}
$path = \dirname($path);
}
while ($path != '.');
return false;
} | php | {
"resource": ""
} |
q242915 | Folder.synchronize | validation | public function synchronize()
{
if (!$this->isUnsynchronized())
{
return;
}
// Check if the .nosync file exists
if (!file_exists($this->strRootDir . '/' . $this->strFolder . '/.nosync'))
{
throw new \RuntimeException(sprintf('Cannot synchronize the folder "%s" because one of its parent folders is unsynchronized', $this->strFolder));
}
(new File($this->strFolder . '/.nosync'))->delete();
} | php | {
"resource": ""
} |
q242916 | Folder.unsynchronize | validation | public function unsynchronize()
{
if (!file_exists($this->strRootDir . '/' . $this->strFolder . '/.nosync'))
{
System::getContainer()->get('filesystem')->touch($this->strRootDir . '/' . $this->strFolder . '/.nosync');
}
} | php | {
"resource": ""
} |
q242917 | Folder.getModel | validation | public function getModel()
{
if ($this->objModel === null && Dbafs::shouldBeSynchronized($this->strFolder))
{
$this->objModel = FilesModel::findByPath($this->strFolder);
}
return $this->objModel;
} | php | {
"resource": ""
} |
q242918 | Folder.getHash | validation | protected function getHash()
{
@trigger_error('Using Folder::getHash() has been deprecated and will no longer work in Contao 5.0. Use Dbafs::getFolderHash() instead.', E_USER_DEPRECATED);
$arrFiles = array();
/** @var \SplFileInfo[] $it */
$it = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
$this->strRootDir . '/' . $this->strFolder,
\FilesystemIterator::UNIX_PATHS|\FilesystemIterator::FOLLOW_SYMLINKS|\FilesystemIterator::SKIP_DOTS
), \RecursiveIteratorIterator::SELF_FIRST
);
foreach ($it as $i)
{
if (strncmp($i->getFilename(), '.', 1) !== 0)
{
$arrFiles[] = substr($i->getPathname(), \strlen($this->strRootDir . '/' . $this->strFolder . '/'));
}
}
return md5(implode('-', $arrFiles));
} | php | {
"resource": ""
} |
q242919 | Folder.getSize | validation | protected function getSize()
{
$intSize = 0;
foreach (scan($this->strRootDir . '/' . $this->strFolder, true) as $strFile)
{
if (strncmp($strFile, '.', 1) === 0)
{
continue;
}
if (is_dir($this->strRootDir . '/' . $this->strFolder . '/' . $strFile))
{
$objFolder = new self($this->strFolder . '/' . $strFile);
$intSize += $objFolder->size;
}
else
{
$objFile = new File($this->strFolder . '/' . $strFile);
$intSize += $objFile->size;
}
}
return $intSize;
} | php | {
"resource": ""
} |
q242920 | tl_user.checkPermission | validation | public function checkPermission()
{
if ($this->User->isAdmin)
{
return;
}
// Check current action
switch (Contao\Input::get('act'))
{
case 'create':
case 'select':
case 'show':
// Allow
break;
case 'delete':
if (Contao\Input::get('id') == $this->User->id)
{
throw new Contao\CoreBundle\Exception\AccessDeniedException('Attempt to delete own account ID ' . Contao\Input::get('id') . '.');
}
// no break;
case 'edit':
case 'copy':
case 'toggle':
default:
$objUser = $this->Database->prepare("SELECT `admin` FROM tl_user WHERE id=?")
->limit(1)
->execute(Contao\Input::get('id'));
if ($objUser->admin && Contao\Input::get('act') != '')
{
throw new Contao\CoreBundle\Exception\AccessDeniedException('Not enough permissions to ' . Contao\Input::get('act') . ' administrator account ID ' . Contao\Input::get('id') . '.');
}
break;
case 'editAll':
case 'deleteAll':
case 'overrideAll':
/** @var Symfony\Component\HttpFoundation\Session\SessionInterface $objSession */
$objSession = Contao\System::getContainer()->get('session');
$session = $objSession->all();
$objUser = $this->Database->execute("SELECT id FROM tl_user WHERE `admin`=1");
$session['CURRENT']['IDS'] = array_diff($session['CURRENT']['IDS'], $objUser->fetchEach('id'));
$objSession->replace($session);
break;
}
} | php | {
"resource": ""
} |
q242921 | tl_user.handleUserProfile | validation | public function handleUserProfile(Contao\DataContainer $dc)
{
if (Contao\Input::get('do') != 'login')
{
return;
}
// Should not happen because of the redirect but better safe than sorry
if (Contao\BackendUser::getInstance()->id != Contao\Input::get('id') || Contao\Input::get('act') != 'edit')
{
throw new Contao\CoreBundle\Exception\AccessDeniedException('Not allowed to edit this page.');
}
$GLOBALS['TL_DCA'][$dc->table]['config']['closed'] = true;
$GLOBALS['TL_DCA'][$dc->table]['config']['hideVersionMenu'] = true;
$GLOBALS['TL_DCA'][$dc->table]['palettes'] = array
(
'__selector__' => $GLOBALS['TL_DCA'][$dc->table]['palettes']['__selector__'],
'default' => $GLOBALS['TL_DCA'][$dc->table]['palettes']['login']
);
$arrFields = Contao\StringUtil::trimsplit('[,;]', $GLOBALS['TL_DCA'][$dc->table]['palettes']['default']);
foreach ($arrFields as $strField)
{
$GLOBALS['TL_DCA'][$dc->table]['fields'][$strField]['exclude'] = false;
}
} | php | {
"resource": ""
} |
q242922 | tl_user.copyUser | validation | public function copyUser($row, $href, $label, $title, $icon, $attributes, $table)
{
if ($GLOBALS['TL_DCA'][$table]['config']['closed'])
{
return '';
}
return ($this->User->isAdmin || !$row['admin']) ? '<a href="'.$this->addToUrl($href.'&id='.$row['id']).'" title="'.Contao\StringUtil::specialchars($title).'"'.$attributes.'>'.Contao\Image::getHtml($icon, $label).'</a> ' : Contao\Image::getHtml(preg_replace('/\.svg$/i', '_.svg', $icon)).' ';
} | php | {
"resource": ""
} |
q242923 | tl_user.sessionField | validation | public function sessionField(Contao\DataContainer $dc)
{
if (Contao\Input::post('FORM_SUBMIT') == 'tl_user')
{
$arrPurge = Contao\Input::post('purge');
if (\is_array($arrPurge))
{
$this->import('Contao\Automator', 'Automator');
if (\in_array('purge_session', $arrPurge))
{
/** @var Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface $objSessionBag */
$objSessionBag = Contao\System::getContainer()->get('session')->getBag('contao_backend');
$objSessionBag->clear();
Contao\Message::addConfirmation($GLOBALS['TL_LANG']['tl_user']['sessionPurged']);
}
if (\in_array('purge_images', $arrPurge))
{
$this->Automator->purgeImageCache();
Contao\Message::addConfirmation($GLOBALS['TL_LANG']['tl_user']['htmlPurged']);
}
if (\in_array('purge_pages', $arrPurge))
{
$this->Automator->purgePageCache();
Contao\Message::addConfirmation($GLOBALS['TL_LANG']['tl_user']['tempPurged']);
}
}
}
return '
<div class="widget">
<fieldset class="tl_checkbox_container">
<legend>'.$GLOBALS['TL_LANG']['tl_user']['session'][0].'</legend>
<input type="checkbox" id="check_all_purge" class="tl_checkbox" onclick="Backend.toggleCheckboxGroup(this, \'ctrl_purge\')"> <label for="check_all_purge" style="color:#a6a6a6"><em>'.$GLOBALS['TL_LANG']['MSC']['selectAll'].'</em></label><br>
<input type="checkbox" name="purge[]" id="opt_purge_0" class="tl_checkbox" value="purge_session" onfocus="Backend.getScrollOffset()"> <label for="opt_purge_0">'.$GLOBALS['TL_LANG']['tl_user']['sessionLabel'].'</label><br>
<input type="checkbox" name="purge[]" id="opt_purge_1" class="tl_checkbox" value="purge_images" onfocus="Backend.getScrollOffset()"> <label for="opt_purge_1">'.$GLOBALS['TL_LANG']['tl_user']['htmlLabel'].'</label><br>
<input type="checkbox" name="purge[]" id="opt_purge_2" class="tl_checkbox" value="purge_pages" onfocus="Backend.getScrollOffset()"> <label for="opt_purge_2">'.$GLOBALS['TL_LANG']['tl_user']['tempLabel'].'</label>
</fieldset>'.$dc->help().'
</div>';
} | php | {
"resource": ""
} |
q242924 | tl_user.getModules | validation | public function getModules()
{
$arrModules = array();
foreach ($GLOBALS['BE_MOD'] as $k=>$v)
{
if (!empty($v))
{
if ($k == 'accounts')
{
unset($v['login']);
}
if ($k == 'system')
{
unset($v['undo']);
}
$arrModules[$k] = array_keys($v);
}
}
return $arrModules;
} | php | {
"resource": ""
} |
q242925 | tl_user.checkAdminStatus | validation | public function checkAdminStatus($varValue, Contao\DataContainer $dc)
{
if ($varValue == '' && $this->User->id == $dc->id)
{
$varValue = 1;
}
return $varValue;
} | php | {
"resource": ""
} |
q242926 | tl_user.checkAdminDisable | validation | public function checkAdminDisable($varValue, Contao\DataContainer $dc)
{
if ($varValue == 1 && $this->User->id == $dc->id)
{
$varValue = '';
}
return $varValue;
} | php | {
"resource": ""
} |
q242927 | tl_user.updateCurrentUser | validation | public function updateCurrentUser(Contao\DataContainer $dc)
{
if ($this->User->id == $dc->id)
{
$this->User->findBy('id', $this->User->id);
}
} | php | {
"resource": ""
} |
q242928 | FrontendController.loginAction | validation | public function loginAction(): Response
{
$this->get('contao.framework')->initialize();
if (!isset($GLOBALS['TL_PTY']['error_401']) || !class_exists($GLOBALS['TL_PTY']['error_401'])) {
throw new UnauthorizedHttpException('', 'Not authorized');
}
/** @var PageError401 $pageHandler */
$pageHandler = new $GLOBALS['TL_PTY']['error_401']();
try {
return $pageHandler->getResponse();
} catch (ResponseException $e) {
return $e->getResponse();
} catch (InsufficientAuthenticationException $e) {
throw new UnauthorizedHttpException('', $e->getMessage());
}
} | php | {
"resource": ""
} |
q242929 | StyleSheets.updateStyleSheet | validation | public function updateStyleSheet($intId)
{
$objStyleSheet = $this->Database->prepare("SELECT * FROM tl_style_sheet WHERE id=?")
->limit(1)
->execute($intId);
if ($objStyleSheet->numRows < 1)
{
return;
}
// Delete the CSS file
if (Input::get('act') == 'delete')
{
$this->import(Files::class, 'Files');
$this->Files->delete('assets/css/' . $objStyleSheet->name . '.css');
}
// Update the CSS file
else
{
$this->writeStyleSheet($objStyleSheet->row());
$this->log('Generated style sheet "' . $objStyleSheet->name . '.css"', __METHOD__, TL_CRON);
}
} | php | {
"resource": ""
} |
q242930 | StyleSheets.updateStyleSheets | validation | public function updateStyleSheets()
{
$objStyleSheets = $this->Database->execute("SELECT * FROM tl_style_sheet");
$arrStyleSheets = $objStyleSheets->fetchEach('name');
// Make sure the dcaconfig.php file is loaded
if (file_exists($this->strRootDir . '/system/config/dcaconfig.php'))
{
@trigger_error('Using the dcaconfig.php file has been deprecated and will no longer work in Contao 5.0. Create one or more DCA files in app/Resources/contao/dca instead.', E_USER_DEPRECATED);
include $this->strRootDir . '/system/config/dcaconfig.php';
}
// Delete old style sheets
foreach (scan($this->strRootDir . '/assets/css', true) as $file)
{
// Skip directories
if (is_dir($this->strRootDir . '/assets/css/' . $file))
{
continue;
}
// Preserve root files (is this still required now that scripts are in assets/css/scripts?)
if (\is_array(Config::get('rootFiles')) && \in_array($file, Config::get('rootFiles')))
{
continue;
}
// Do not delete the combined files (see #3605)
if (preg_match('/^[a-f0-9]{12}\.css$/', $file))
{
continue;
}
$objFile = new File('assets/css/' . $file);
// Delete the old style sheet
if ($objFile->extension == 'css' && !\in_array($objFile->filename, $arrStyleSheets))
{
$objFile->delete();
}
}
$objStyleSheets->reset();
// Create the new style sheets
while ($objStyleSheets->next())
{
$this->writeStyleSheet($objStyleSheets->row());
$this->log('Generated style sheet "' . $objStyleSheets->name . '.css"', __METHOD__, TL_CRON);
}
} | php | {
"resource": ""
} |
q242931 | StyleSheets.writeStyleSheet | validation | protected function writeStyleSheet($row)
{
if ($row['id'] == '' || $row['name'] == '')
{
return;
}
$row['name'] = basename($row['name']);
// Check whether the target file is writeable
if (file_exists($this->strRootDir . '/assets/css/' . $row['name'] . '.css') && !$this->Files->is_writeable('assets/css/' . $row['name'] . '.css'))
{
Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['notWriteable'], 'assets/css/' . $row['name'] . '.css'));
return;
}
$vars = array();
// Get the global theme variables
$objTheme = $this->Database->prepare("SELECT vars FROM tl_theme WHERE id=?")
->limit(1)
->execute($row['pid']);
if ($objTheme->vars != '')
{
if (\is_array(($tmp = StringUtil::deserialize($objTheme->vars))))
{
foreach ($tmp as $v)
{
$vars[$v['key']] = $v['value'];
}
}
}
// Merge the global style sheet variables
if ($row['vars'] != '')
{
if (\is_array($tmp = StringUtil::deserialize($row['vars'])))
{
foreach ($tmp as $v)
{
$vars[$v['key']] = $v['value'];
}
}
}
// Sort by key length (see #3316)
uksort($vars, 'length_sort_desc');
// Create the file
$objFile = new File('assets/css/' . $row['name'] . '.css');
$objFile->write('/* ' . $row['name'] . ".css */\n");
$objDefinitions = $this->Database->prepare("SELECT * FROM tl_style WHERE pid=? AND invisible!='1' ORDER BY sorting")
->execute($row['id']);
// Append the definition
while ($objDefinitions->next())
{
$objFile->append($this->compileDefinition($objDefinitions->row(), true, $vars, $row), '');
}
$objFile->close();
} | php | {
"resource": ""
} |
q242932 | StyleSheets.compileColor | validation | protected function compileColor($color, $blnWriteToFile=false, $vars=array())
{
if (!\is_array($color))
{
return '#' . $this->shortenHexColor($color);
}
elseif (!isset($color[1]) || empty($color[1]))
{
return '#' . $this->shortenHexColor($color[0]);
}
else
{
return 'rgba(' . implode(',', $this->convertHexColor($color[0], $blnWriteToFile, $vars)) . ','. ($color[1] / 100) .')';
}
} | php | {
"resource": ""
} |
q242933 | StyleSheets.shortenHexColor | validation | protected function shortenHexColor($color)
{
if ($color[0] == $color[1] && $color[2] == $color[3] && $color[4] == $color[5])
{
return $color[0] . $color[2] . $color[4];
}
return $color;
} | php | {
"resource": ""
} |
q242934 | StyleSheets.convertHexColor | validation | protected function convertHexColor($color, $blnWriteToFile=false, $vars=array())
{
// Support global variables
if (strncmp($color, '$', 1) === 0)
{
if (!$blnWriteToFile)
{
return array($color);
}
else
{
$color = str_replace(array_keys($vars), $vars, $color);
}
}
$rgb = array();
// Try to convert using bitwise operation
if (\strlen($color) == 6)
{
$dec = hexdec($color);
$rgb['red'] = 0xFF & ($dec >> 0x10);
$rgb['green'] = 0xFF & ($dec >> 0x8);
$rgb['blue'] = 0xFF & $dec;
}
// Shorthand notation
elseif (\strlen($color) == 3)
{
$rgb['red'] = hexdec(str_repeat(substr($color, 0, 1), 2));
$rgb['green'] = hexdec(str_repeat(substr($color, 1, 1), 2));
$rgb['blue'] = hexdec(str_repeat(substr($color, 2, 1), 2));
}
return $rgb;
} | php | {
"resource": ""
} |
q242935 | StyleSheets.exportStyleSheet | validation | public function exportStyleSheet(DataContainer $dc)
{
$objStyleSheet = $this->Database->prepare("SELECT * FROM tl_style_sheet WHERE id=?")
->limit(1)
->execute($dc->id);
if ($objStyleSheet->numRows < 1)
{
throw new \Exception("Invalid style sheet ID {$dc->id}");
}
$vars = array();
// Get the global theme variables
$objTheme = $this->Database->prepare("SELECT vars FROM tl_theme WHERE id=?")
->limit(1)
->execute($objStyleSheet->pid);
if ($objTheme->vars != '')
{
if (\is_array(($tmp = StringUtil::deserialize($objTheme->vars))))
{
foreach ($tmp as $v)
{
$vars[$v['key']] = $v['value'];
}
}
}
// Merge the global style sheet variables
if ($objStyleSheet->vars != '')
{
if (\is_array(($tmp = StringUtil::deserialize($objStyleSheet->vars))))
{
foreach ($tmp as $v)
{
$vars[$v['key']] = $v['value'];
}
}
}
// Sort by key length (see #3316)
uksort($vars, 'length_sort_desc');
// Create the file
$objFile = new File('system/tmp/' . md5(uniqid(mt_rand(), true)));
$objFile->write('');
// Add the media query (see #7560)
if ($objStyleSheet->mediaQuery != '')
{
$objFile->append('@media ' . $objStyleSheet->mediaQuery . ' {');
}
$objDefinitions = $this->Database->prepare("SELECT * FROM tl_style WHERE pid=? AND invisible!='1' ORDER BY sorting")
->execute($objStyleSheet->id);
// Append the definition
while ($objDefinitions->next())
{
$objFile->append($this->compileDefinition($objDefinitions->row(), false, $vars, $objStyleSheet->row(), true), '');
}
// Close the media query
if ($objStyleSheet->mediaQuery != '')
{
$objFile->append('}');
}
$objFile->close();
$objFile->sendToBrowser($objStyleSheet->name . '.css');
$objFile->delete();
} | php | {
"resource": ""
} |
q242936 | StyleSheets.checkStyleSheetName | validation | public function checkStyleSheetName($strName)
{
$objStyleSheet = $this->Database->prepare("SELECT COUNT(*) AS count FROM tl_style_sheet WHERE name=?")
->limit(1)
->execute($strName);
if ($objStyleSheet->count < 1)
{
return $strName;
}
$chunks = explode('-', $strName);
$i = (\count($chunks) > 1) ? array_pop($chunks) : 0;
$strName = implode('-', $chunks) . '-' . ((int) $i + 1);
return $this->checkStyleSheetName($strName);
} | php | {
"resource": ""
} |
q242937 | StyleSheetModel.findByIds | validation | public static function findByIds($arrIds)
{
if (empty($arrIds) || !\is_array($arrIds))
{
return null;
}
$objDatabase = Database::getInstance();
$arrIds = array_map('\intval', $arrIds);
$objResult = $objDatabase->execute("SELECT *, (SELECT tstamp FROM tl_theme WHERE tl_theme.id=tl_style_sheet.pid) AS tstamp3, (SELECT MAX(tstamp) FROM tl_style WHERE tl_style.pid=tl_style_sheet.id) AS tstamp2, (SELECT COUNT(*) FROM tl_style WHERE tl_style.selector='@font-face' AND tl_style.invisible='' AND tl_style.pid=tl_style_sheet.id) AS hasFontFace FROM tl_style_sheet WHERE id IN (" . implode(',', $arrIds) . ") ORDER BY " . $objDatabase->findInSet('id', $arrIds));
return static::createCollectionFromDbResult($objResult, 'tl_style_sheet');
} | php | {
"resource": ""
} |
q242938 | FrontendPreviewAuthenticator.removeFrontendAuthentication | validation | public function removeFrontendAuthentication(): bool
{
if (!$this->session->isStarted() || !$this->session->has(FrontendUser::SECURITY_SESSION_KEY)) {
return false;
}
$this->session->remove(FrontendUser::SECURITY_SESSION_KEY);
return true;
} | php | {
"resource": ""
} |
q242939 | FrontendPreviewAuthenticator.loadFrontendUser | validation | private function loadFrontendUser(string $username, BackendUser $backendUser): ?FrontendUser
{
try {
$frontendUser = $this->userProvider->loadUserByUsername($username);
// Make sure the user provider returned a front end user
if (!$frontendUser instanceof FrontendUser) {
throw new UsernameNotFoundException('User is not a front end user');
}
} catch (UsernameNotFoundException $e) {
if (null !== $this->logger) {
$this->logger->info(
sprintf('Could not find a front end user with the username "%s"', $username),
['contao' => new ContaoContext(__METHOD__, ContaoContext::ACCESS, '')]
);
}
return null;
}
$allowedGroups = StringUtil::deserialize($backendUser->amg, true);
$frontendGroups = StringUtil::deserialize($frontendUser->groups, true);
// The front end user does not belong to a group that the back end user is allowed to log in
if (!$backendUser->isAdmin && !\count(array_intersect($frontendGroups, $allowedGroups))) {
return null;
}
return $frontendUser;
} | php | {
"resource": ""
} |
q242940 | ZipReader.getFile | validation | public function getFile($strName)
{
foreach ($this->arrFiles as $k=>$v)
{
if ($strName == $v['file_name'])
{
$this->intIndex = $k;
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q242941 | ZipReader.unzip | validation | public function unzip()
{
if ($this->intIndex < 0)
{
$this->first();
}
$strName = $this->arrFiles[$this->intIndex]['file_name'];
// Encrypted files are not supported
if ($this->arrFiles[$this->intIndex]['general_purpose_bit_flag'] & 0x0001)
{
throw new \Exception("File $strName is encrypted");
}
// Reposition pointer
if (@fseek($this->resFile, $this->arrFiles[$this->intIndex]['offset_of_local_header']) !== 0)
{
throw new \Exception("Cannot reposition pointer");
}
$strSignature = @fread($this->resFile, 4);
// Not a file
if ($strSignature != self::FILE_SIGNATURE)
{
throw new \Exception("$strName is not a compressed file");
}
// Get extra field length
fseek($this->resFile, 24, SEEK_CUR);
$arrEFL = unpack('v', @fread($this->resFile, 2));
// Reposition pointer
fseek($this->resFile, ($this->arrFiles[$this->intIndex]['file_name_length'] + $arrEFL[1]), SEEK_CUR);
// Empty file
if ($this->arrFiles[$this->intIndex]['compressed_size'] < 1)
{
return '';
}
// Read data
$strBuffer = @fread($this->resFile, $this->arrFiles[$this->intIndex]['compressed_size']);
// Decompress data
switch ($this->arrFiles[$this->intIndex]['compression_method'])
{
// Stored
case 0:
break;
// Deflated
case 8:
$strBuffer = gzinflate($strBuffer);
break;
// BZIP2
case 12:
if (!\extension_loaded('bz2'))
{
throw new \Exception('PHP extension "bz2" required to decompress BZIP2 files');
}
$strBuffer = bzdecompress($strBuffer);
break;
// Unknown
default:
throw new \Exception('Unknown compression method');
break;
}
// Check uncompressed data
if ($strBuffer === false)
{
throw new \Exception('Could not decompress data');
}
// Check uncompressed size
if (\strlen($strBuffer) != $this->arrFiles[$this->intIndex]['uncompressed_size'])
{
throw new \Exception('Size of the uncompressed file does not match header value');
}
return $strBuffer;
} | php | {
"resource": ""
} |
q242942 | ZipReader.decToUnix | validation | protected function decToUnix($intTime, $intDate)
{
return mktime
(
($intTime & 0xf800) >> 11,
($intTime & 0x07e0) >> 5,
($intTime & 0x001f) << 1,
($intDate & 0x01e0) >> 5,
($intDate & 0x001f),
(($intDate & 0xfe00) >> 9) + 1980
);
} | php | {
"resource": ""
} |
q242943 | News.getSearchablePages | validation | public function getSearchablePages($arrPages, $intRoot=0, $blnIsSitemap=false)
{
$arrRoot = array();
if ($intRoot > 0)
{
$arrRoot = $this->Database->getChildRecords($intRoot, 'tl_page');
}
$arrProcessed = array();
$time = Date::floorToMinute();
// Get all news archives
$objArchive = NewsArchiveModel::findByProtected('');
// Walk through each archive
if ($objArchive !== null)
{
while ($objArchive->next())
{
// Skip news archives without target page
if (!$objArchive->jumpTo)
{
continue;
}
// Skip news archives outside the root nodes
if (!empty($arrRoot) && !\in_array($objArchive->jumpTo, $arrRoot))
{
continue;
}
// Get the URL of the jumpTo page
if (!isset($arrProcessed[$objArchive->jumpTo]))
{
$objParent = PageModel::findWithDetails($objArchive->jumpTo);
// The target page does not exist
if ($objParent === null)
{
continue;
}
// The target page has not been published (see #5520)
if (!$objParent->published || ($objParent->start != '' && $objParent->start > $time) || ($objParent->stop != '' && $objParent->stop <= ($time + 60)))
{
continue;
}
if ($blnIsSitemap)
{
// The target page is protected (see #8416)
if ($objParent->protected)
{
continue;
}
// The target page is exempt from the sitemap (see #6418)
if ($objParent->sitemap == 'map_never')
{
continue;
}
}
// Generate the URL
$arrProcessed[$objArchive->jumpTo] = $objParent->getAbsoluteUrl(Config::get('useAutoItem') ? '/%s' : '/items/%s');
}
$strUrl = $arrProcessed[$objArchive->jumpTo];
// Get the items
$objArticle = NewsModel::findPublishedDefaultByPid($objArchive->id);
if ($objArticle !== null)
{
while ($objArticle->next())
{
$arrPages[] = $this->getLink($objArticle, $strUrl);
}
}
}
}
return $arrPages;
} | php | {
"resource": ""
} |
q242944 | News.getLink | validation | protected function getLink($objItem, $strUrl, $strBase='')
{
switch ($objItem->source)
{
// Link to an external page
case 'external':
return $objItem->url;
break;
// Link to an internal page
case 'internal':
if (($objTarget = $objItem->getRelated('jumpTo')) instanceof PageModel)
{
/** @var PageModel $objTarget */
return $objTarget->getAbsoluteUrl();
}
break;
// Link to an article
case 'article':
if (($objArticle = ArticleModel::findByPk($objItem->articleId)) instanceof ArticleModel && ($objPid = $objArticle->getRelated('pid')) instanceof PageModel)
{
/** @var PageModel $objPid */
return ampersand($objPid->getAbsoluteUrl('/articles/' . ($objArticle->alias ?: $objArticle->id)));
}
break;
}
// Backwards compatibility (see #8329)
if ($strBase != '' && !preg_match('#^https?://#', $strUrl))
{
$strUrl = $strBase . $strUrl;
}
// Link to the default page
return sprintf(preg_replace('/%(?!s)/', '%%', $strUrl), ($objItem->alias ?: $objItem->id));
} | php | {
"resource": ""
} |
q242945 | News.purgeOldFeeds | validation | public function purgeOldFeeds()
{
$arrFeeds = array();
$objFeeds = NewsFeedModel::findAll();
if ($objFeeds !== null)
{
while ($objFeeds->next())
{
$arrFeeds[] = $objFeeds->alias ?: 'news' . $objFeeds->id;
}
}
return $arrFeeds;
} | php | {
"resource": ""
} |
q242946 | JwtManager.addResponseCookie | validation | public function addResponseCookie(Response $response, array $payload = []): void
{
if ($this->hasCookie($response)) {
return;
}
$payload['iat'] = time();
$payload['exp'] = strtotime('+30 minutes');
if (method_exists(Cookie::class, 'create')) {
$cookie = Cookie::create(self::COOKIE_NAME, JWT::encode($payload, $this->secret));
} else {
// Backwards compatibility with symfony/http-foundation <4.2
$cookie = new Cookie(self::COOKIE_NAME, JWT::encode($payload, $this->secret));
}
$response->headers->setCookie($cookie);
} | php | {
"resource": ""
} |
q242947 | JwtManager.clearResponseCookie | validation | public function clearResponseCookie(Response $response): Response
{
$response->headers->clearCookie(self::COOKIE_NAME);
return $response;
} | php | {
"resource": ""
} |
q242948 | JwtManager.hasCookie | validation | private function hasCookie(Response $response): bool
{
/** @var Cookie[] $cookies */
$cookies = $response->headers->getCookies();
foreach ($cookies as $cookie) {
if (self::COOKIE_NAME === $cookie->getName()) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q242949 | Search.removeEntry | validation | public static function removeEntry($strUrl)
{
$objDatabase = Database::getInstance();
$objResult = $objDatabase->prepare("SELECT id FROM tl_search WHERE url=?")
->execute($strUrl);
while ($objResult->next())
{
$objDatabase->prepare("DELETE FROM tl_search WHERE id=?")
->execute($objResult->id);
$objDatabase->prepare("DELETE FROM tl_search_index WHERE pid=?")
->execute($objResult->id);
}
} | php | {
"resource": ""
} |
q242950 | ContaoTemplateExtension.renderContaoBackendTemplate | validation | public function renderContaoBackendTemplate(array $blocks = []): string
{
$request = $this->requestStack->getCurrentRequest();
if (null === $request || !$this->scopeMatcher->isBackendRequest($request)) {
return '';
}
/** @var BackendCustom $controller */
$controller = $this->framework->createInstance(BackendCustom::class);
$template = $controller->getTemplateObject();
foreach ($blocks as $key => $content) {
$template->{$key} = $content;
}
$response = $controller->run();
return $response->getContent();
} | php | {
"resource": ""
} |
q242951 | InsertTagsListener.onReplaceInsertTags | validation | public function onReplaceInsertTags(string $tag, bool $useCache, $cacheValue, array $flags)
{
static $supportedTags = [
'faq',
'faq_open',
'faq_url',
'faq_title',
];
$elements = explode('::', $tag);
$key = strtolower($elements[0]);
if (!\in_array($key, $supportedTags, true)) {
return false;
}
$this->framework->initialize();
/** @var FaqModel $adapter */
$adapter = $this->framework->getAdapter(FaqModel::class);
$faq = $adapter->findByIdOrAlias($elements[1]);
if (null === $faq || false === ($url = $this->generateUrl($faq, \in_array('absolute', $flags, true)))) {
return '';
}
return $this->generateReplacement($faq, $key, $url);
} | php | {
"resource": ""
} |
q242952 | tl_calendar_events.setEmptyEndTime | validation | public function setEmptyEndTime($varValue, Contao\DataContainer $dc)
{
if ($varValue === null)
{
$varValue = $dc->activeRecord->startTime;
}
return $varValue;
} | php | {
"resource": ""
} |
q242953 | tl_calendar_events.getArticleAlias | validation | public function getArticleAlias(Contao\DataContainer $dc)
{
$arrPids = array();
$arrAlias = array();
if (!$this->User->isAdmin)
{
foreach ($this->User->pagemounts as $id)
{
$arrPids[] = array($id);
$arrPids[] = $this->Database->getChildRecords($id, 'tl_page');
}
if (!empty($arrPids))
{
$arrPids = array_merge(...$arrPids);
}
else
{
return $arrAlias;
}
$objAlias = $this->Database->prepare("SELECT a.id, a.title, a.inColumn, p.title AS parent FROM tl_article a LEFT JOIN tl_page p ON p.id=a.pid WHERE a.pid IN(". implode(',', array_map('\intval', array_unique($arrPids))) .") ORDER BY parent, a.sorting")
->execute($dc->id);
}
else
{
$objAlias = $this->Database->prepare("SELECT a.id, a.title, a.inColumn, p.title AS parent FROM tl_article a LEFT JOIN tl_page p ON p.id=a.pid ORDER BY parent, a.sorting")
->execute($dc->id);
}
if ($objAlias->numRows)
{
Contao\System::loadLanguageFile('tl_article');
while ($objAlias->next())
{
$arrAlias[$objAlias->parent][$objAlias->id] = $objAlias->title . ' (' . ($GLOBALS['TL_LANG']['COLS'][$objAlias->inColumn] ?: $objAlias->inColumn) . ', ID ' . $objAlias->id . ')';
}
}
return $arrAlias;
} | php | {
"resource": ""
} |
q242954 | Ajax.executePostActionsHook | validation | protected function executePostActionsHook(DataContainer $dc)
{
if (isset($GLOBALS['TL_HOOKS']['executePostActions']) && \is_array($GLOBALS['TL_HOOKS']['executePostActions']))
{
foreach ($GLOBALS['TL_HOOKS']['executePostActions'] as $callback)
{
$this->import($callback[0]);
$this->{$callback[0]}->{$callback[1]}($this->strAction, $dc);
}
}
} | php | {
"resource": ""
} |
q242955 | BackendUser.getInstance | validation | public static function getInstance()
{
if (static::$objInstance !== null)
{
return static::$objInstance;
}
$objToken = System::getContainer()->get('security.token_storage')->getToken();
// Load the user from the security storage
if ($objToken !== null && is_a($objToken->getUser(), static::class))
{
return $objToken->getUser();
}
// Check for an authenticated user in the session
$strUser = System::getContainer()->get('contao.security.token_checker')->getBackendUsername();
if ($strUser !== null)
{
static::$objInstance = static::loadUserByUsername($strUser);
return static::$objInstance;
}
return parent::getInstance();
} | php | {
"resource": ""
} |
q242956 | BackendUser.hasAccess | validation | public function hasAccess($field, $array)
{
if ($this->isAdmin)
{
return true;
}
if (!\is_array($field))
{
$field = array($field);
}
if (\is_array($this->$array) && array_intersect($field, $this->$array))
{
return true;
}
elseif ($array == 'filemounts')
{
// Check the subfolders (filemounts)
foreach ($this->filemounts as $folder)
{
if (preg_match('/^' . preg_quote($folder, '/') . '(\/|$)/i', $field[0]))
{
return true;
}
}
}
return false;
} | php | {
"resource": ""
} |
q242957 | BackendUser.isAllowed | validation | public function isAllowed($int, $row)
{
if ($this->isAdmin)
{
return true;
}
// Inherit CHMOD settings
if (!$row['includeChmod'])
{
$pid = $row['pid'];
$row['chmod'] = false;
$row['cuser'] = false;
$row['cgroup'] = false;
$objParentPage = PageModel::findById($pid);
while ($objParentPage !== null && $row['chmod'] === false && $pid > 0)
{
$pid = $objParentPage->pid;
$row['chmod'] = $objParentPage->includeChmod ? $objParentPage->chmod : false;
$row['cuser'] = $objParentPage->includeChmod ? $objParentPage->cuser : false;
$row['cgroup'] = $objParentPage->includeChmod ? $objParentPage->cgroup : false;
$objParentPage = PageModel::findById($pid);
}
// Set default values
if ($row['chmod'] === false)
{
$row['chmod'] = Config::get('defaultChmod');
}
if ($row['cuser'] === false)
{
$row['cuser'] = (int) Config::get('defaultUser');
}
if ($row['cgroup'] === false)
{
$row['cgroup'] = (int) Config::get('defaultGroup');
}
}
// Set permissions
$chmod = StringUtil::deserialize($row['chmod']);
$chmod = \is_array($chmod) ? $chmod : array($chmod);
$permission = array('w'.$int);
if (\in_array($row['cgroup'], $this->groups))
{
$permission[] = 'g'.$int;
}
if ($row['cuser'] == $this->id)
{
$permission[] = 'u'.$int;
}
return \count(array_intersect($permission, $chmod)) > 0;
} | php | {
"resource": ""
} |
q242958 | BackendUser.canEditFieldsOf | validation | public function canEditFieldsOf($table)
{
if ($this->isAdmin)
{
return true;
}
return \count(preg_grep('/^' . preg_quote($table, '/') . '::/', $this->alexf)) > 0;
} | php | {
"resource": ""
} |
q242959 | BackendLocaleListener.onKernelRequest | validation | public function onKernelRequest(GetResponseEvent $event): void
{
$token = $this->tokenStorage->getToken();
if (!$token instanceof TokenInterface) {
return;
}
$user = $token->getUser();
if (!$user instanceof BackendUser || !$user->language) {
return;
}
$request = $event->getRequest();
$request->setLocale($user->language);
$this->translator->setLocale($user->language);
// Deprecated since Contao 4.0, to be removed in Contao 5.0
$GLOBALS['TL_LANGUAGE'] = str_replace('_', '-', $user->language);
} | php | {
"resource": ""
} |
q242960 | tl_module_news.getNewsArchives | validation | public function getNewsArchives()
{
if (!$this->User->isAdmin && !\is_array($this->User->news))
{
return array();
}
$arrArchives = array();
$objArchives = $this->Database->execute("SELECT id, title FROM tl_news_archive ORDER BY title");
while ($objArchives->next())
{
if ($this->User->hasAccess($objArchives->id, 'news'))
{
$arrArchives[$objArchives->id] = $objArchives->title;
}
}
return $arrArchives;
} | php | {
"resource": ""
} |
q242961 | XliffFileLoader.getChunksFromUnit | validation | private function getChunksFromUnit(\DOMElement $unit): array
{
$chunks = explode('.', $unit->getAttribute('id'));
// Handle keys with dots
if (preg_match('/tl_layout\.[a-z]+\.css\./', $unit->getAttribute('id'))) {
$chunks = [$chunks[0], $chunks[1].'.'.$chunks[2], $chunks[3]];
}
return $chunks;
} | php | {
"resource": ""
} |
q242962 | XliffFileLoader.getStringRepresentation | validation | private function getStringRepresentation(array $chunks, $value): string
{
switch (\count($chunks)) {
case 2:
return sprintf(
"\$GLOBALS['TL_LANG']['%s'][%s] = %s;\n",
$chunks[0],
$this->quoteKey($chunks[1]),
$this->quoteValue($value)
);
case 3:
return sprintf(
"\$GLOBALS['TL_LANG']['%s'][%s][%s] = %s;\n",
$chunks[0],
$this->quoteKey($chunks[1]),
$this->quoteKey($chunks[2]),
$this->quoteValue($value)
);
case 4:
return sprintf(
"\$GLOBALS['TL_LANG']['%s'][%s][%s][%s] = %s;\n",
$chunks[0],
$this->quoteKey($chunks[1]),
$this->quoteKey($chunks[2]),
$this->quoteKey($chunks[3]),
$this->quoteValue($value)
);
}
throw new \OutOfBoundsException('Cannot load less than 2 or more than 4 levels in XLIFF language files.');
} | php | {
"resource": ""
} |
q242963 | XliffFileLoader.addGlobal | validation | private function addGlobal(array $chunks, $value): void
{
if (false === $this->addToGlobals) {
return;
}
$data = &$GLOBALS['TL_LANG'];
foreach ($chunks as $key) {
if (null === $data || !\is_array($data)) {
$data = [];
}
$data = &$data[$key];
}
$data = $value;
} | php | {
"resource": ""
} |
q242964 | FileTree.getPreviewImage | validation | protected function getPreviewImage(File $objFile, $strInfo, $strClass='gimage')
{
if (($objFile->isSvgImage || ($objFile->height <= Config::get('gdMaxImgHeight') && $objFile->width <= Config::get('gdMaxImgWidth'))) && $objFile->viewWidth && $objFile->viewHeight)
{
// Inline the image if no preview image will be generated (see #636)
if ($objFile->height !== null && $objFile->height <= 75 && $objFile->width !== null && $objFile->width <= 100)
{
$image = $objFile->dataUri;
}
else
{
$rootDir = System::getContainer()->getParameter('kernel.project_dir');
$image = System::getContainer()->get('contao.image.image_factory')->create($rootDir . '/' . $objFile->path, array(100, 75, ResizeConfiguration::MODE_BOX))->getUrl($rootDir);
}
}
else
{
$image = Image::getPath('placeholder.svg');
}
if (strncmp($image, 'data:', 5) === 0)
{
return '<img src="' . $objFile->dataUri . '" width="' . $objFile->width . '" height="' . $objFile->height . '" alt="" class="' . $strClass . '" title="' . StringUtil::specialchars($strInfo) . '">';
}
return Image::getHtml($image, '', 'class="' . $strClass . '" title="' . StringUtil::specialchars($strInfo) . '"');
} | php | {
"resource": ""
} |
q242965 | ScriptHandler.generateRandomSecret | validation | public static function generateRandomSecret(Event $event): void
{
$extra = $event->getComposer()->getPackage()->getExtra();
if (!isset($extra['incenteev-parameters']) || !self::canGenerateSecret($extra['incenteev-parameters'])) {
return;
}
if (!\function_exists('random_bytes')) {
self::loadRandomCompat($event);
}
putenv(static::RANDOM_SECRET_NAME.'='.bin2hex(random_bytes(32)));
} | php | {
"resource": ""
} |
q242966 | ScriptHandler.canGenerateSecret | validation | private static function canGenerateSecret(array $config): bool
{
if (isset($config['file'])) {
return !is_file($config['file']);
}
foreach ($config as $v) {
if (\is_array($v) && isset($v['file']) && is_file($v['file'])) {
return false;
}
}
return !empty($config);
} | php | {
"resource": ""
} |
q242967 | User.checkAccountStatus | validation | protected function checkAccountStatus()
{
@trigger_error('Using User::checkAccountStatus() has been deprecated and will no longer work in Contao 5.0. Use Symfony security instead.', E_USER_DEPRECATED);
try
{
$userChecker = System::getContainer()->get('contao.security.user_checker');
$userChecker->checkPreAuth($this);
$userChecker->checkPostAuth($this);
}
catch (AuthenticationException $exception)
{
return false;
}
return true;
} | php | {
"resource": ""
} |
q242968 | User.findBy | validation | public function findBy($strColumn, $varValue)
{
$objResult = $this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE " . Database::quoteIdentifier($strColumn) . "=?")
->limit(1)
->execute($varValue);
if ($objResult->numRows > 0)
{
$this->arrData = $objResult->row();
return true;
}
return false;
} | php | {
"resource": ""
} |
q242969 | User.save | validation | public function save()
{
$arrFields = $this->Database->getFieldNames($this->strTable);
$arrSet = array_intersect_key($this->arrData, array_flip($arrFields));
$this->Database->prepare("UPDATE " . $this->strTable . " %s WHERE id=?")
->set($arrSet)
->execute($this->id);
} | php | {
"resource": ""
} |
q242970 | User.regenerateSessionId | validation | protected function regenerateSessionId()
{
@trigger_error('Using User::regenerateSessionId() has been deprecated and will no longer work in Contao 5.0. Use Symfony authentication instead.', E_USER_DEPRECATED);
$container = System::getContainer();
$strategy = $container->getParameter('security.authentication.session_strategy.strategy');
// Regenerate the session ID to harden against session fixation attacks
switch ($strategy)
{
case SessionAuthenticationStrategy::NONE:
break;
case SessionAuthenticationStrategy::MIGRATE:
$container->get('session')->migrate(); // do not destroy the old session
break;
case SessionAuthenticationStrategy::INVALIDATE:
$container->get('session')->invalidate();
break;
default:
throw new \RuntimeException(sprintf('Invalid session authentication strategy "%s"', $strategy));
}
} | php | {
"resource": ""
} |
q242971 | User.isMemberOf | validation | public function isMemberOf($id)
{
// ID not numeric
if (!is_numeric($id))
{
return false;
}
$groups = StringUtil::deserialize($this->groups);
// No groups assigned
if (empty($groups) || !\is_array($groups))
{
return false;
}
// Group ID found
if (\in_array($id, $groups))
{
return true;
}
return false;
} | php | {
"resource": ""
} |
q242972 | User.triggerImportUserHook | validation | public static function triggerImportUserHook($username, $password, $strTable)
{
$self = new static();
if (empty($GLOBALS['TL_HOOKS']['importUser']) || !\is_array($GLOBALS['TL_HOOKS']['importUser']))
{
return false;
}
@trigger_error('Using the "importUser" hook has been deprecated and will no longer work in Contao 5.0. Use the contao.import_user event instead.', E_USER_DEPRECATED);
foreach ($GLOBALS['TL_HOOKS']['importUser'] as $callback)
{
$self->import($callback[0], 'objImport', true);
$blnLoaded = $self->objImport->{$callback[1]}($username, $password, $strTable);
// Load successfull
if ($blnLoaded === true)
{
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q242973 | ContentTeaser.generate | validation | public function generate()
{
$objArticle = ArticleModel::findPublishedById($this->article);
if ($objArticle === null)
{
return '';
}
// Use findPublished() instead of getRelated()
$objParent = PageModel::findPublishedById($objArticle->pid);
if ($objParent === null)
{
return '';
}
$this->objArticle = $objArticle;
$this->objParent = $objParent;
return parent::generate();
} | php | {
"resource": ""
} |
q242974 | ModuleBooknav.getBookPages | validation | protected function getBookPages($intParentId, $groups, $time)
{
$objPages = PageModel::findPublishedSubpagesWithoutGuestsByPid($intParentId, $this->showHidden);
if ($objPages === null)
{
return;
}
foreach ($objPages as $objPage)
{
$_groups = StringUtil::deserialize($objPage->groups);
// Do not show protected pages unless a front end user is logged in
if (!$objPage->protected || $this->showProtected || (\is_array($groups) && \is_array($_groups) && \count(array_intersect($groups, $_groups))))
{
$this->arrPages[$objPage->id] = $objPage;
if ($objPage->subpages > 0)
{
$this->getBookPages($objPage->id, $groups, $time);
}
}
}
} | php | {
"resource": ""
} |
q242975 | Authenticator.validateCode | validation | public function validateCode(User $user, string $code): bool
{
$totp = TOTP::create($this->getUpperUnpaddedSecretForUser($user));
return $totp->verify($code);
} | php | {
"resource": ""
} |
q242976 | Authenticator.getProvisionUri | validation | public function getProvisionUri(User $user, Request $request): string
{
$issuer = rawurlencode($request->getSchemeAndHttpHost());
return sprintf(
'otpauth://totp/%s:%s?secret=%s&issuer=%s',
$issuer,
rawurlencode($user->getUsername()).'@'.$issuer,
$this->getUpperUnpaddedSecretForUser($user),
$issuer
);
} | php | {
"resource": ""
} |
q242977 | Authenticator.getQrCode | validation | public function getQrCode(User $user, Request $request): string
{
$renderer = new ImageRenderer(
new RendererStyle(180, 0),
new SvgImageBackEnd()
);
$writer = new Writer($renderer);
return $writer->writeString($this->getProvisionUri($user, $request));
} | php | {
"resource": ""
} |
q242978 | RouteLoader.loadFromPlugins | validation | public function loadFromPlugins(): RouteCollection
{
$collection = array_reduce(
$this->pluginLoader->getInstancesOf(PluginLoader::ROUTING_PLUGINS, true),
function (RouteCollection $collection, RoutingPluginInterface $plugin): RouteCollection {
$routes = $plugin->getRouteCollection($this->loader->getResolver(), $this->kernel);
if ($routes instanceof RouteCollection) {
$collection->addCollection($routes);
}
return $collection;
},
new RouteCollection()
);
// Load the app/config/routing.yml file if it exists
if (file_exists($configFile = $this->rootDir.'/app/config/routing.yml')) {
$routes = $this->loader->getResolver()->resolve($configFile)->load($configFile);
if ($routes instanceof RouteCollection) {
$collection->addCollection($routes);
}
}
// Make sure the Contao frontend routes are always loaded last
foreach (['contao_frontend', 'contao_index', 'contao_root', 'contao_catch_all'] as $name) {
if ($route = $collection->get($name)) {
$collection->add($name, $route);
}
}
return $collection;
} | php | {
"resource": ""
} |
q242979 | ContentDownload.generate | validation | public function generate()
{
// Return if there is no file
if ($this->singleSRC == '')
{
return '';
}
$objFile = FilesModel::findByUuid($this->singleSRC);
if ($objFile === null)
{
return '';
}
$allowedDownload = StringUtil::trimsplit(',', strtolower(Config::get('allowedDownload')));
// Return if the file type is not allowed
if (!\in_array($objFile->extension, $allowedDownload))
{
return '';
}
$file = Input::get('file', true);
// Send the file to the browser (see #4632 and #8375)
if ($file && (!isset($_GET['cid']) || Input::get('cid') == $this->id))
{
if ($file == $objFile->path)
{
Controller::sendFileToBrowser($file, (bool) $this->inline);
}
if (isset($_GET['cid']))
{
throw new PageNotFoundException('Invalid file name');
}
}
$this->objFile = $objFile;
$this->singleSRC = $objFile->path;
return parent::generate();
} | php | {
"resource": ""
} |
q242980 | ModuleLogin.generate | validation | public function generate()
{
if (TL_MODE == 'BE')
{
$objTemplate = new BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['login'][0]) . ' ###';
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
$objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
return $objTemplate->parse();
}
if (!$_POST && $this->redirectBack && ($strReferer = $this->getReferer()) != Environment::get('request'))
{
$_SESSION['LAST_PAGE_VISITED'] = $strReferer;
}
return parent::generate();
} | php | {
"resource": ""
} |
q242981 | tl_files.checkImportantPart | validation | public function checkImportantPart(Contao\DataContainer $dc)
{
if (!$dc->id)
{
return;
}
$rootDir = Contao\System::getContainer()->getParameter('kernel.project_dir');
if (is_dir($rootDir . '/' . $dc->id) || !\in_array(strtolower(substr($dc->id, strrpos($dc->id, '.') + 1)), Contao\StringUtil::trimsplit(',', strtolower(Contao\Config::get('validImageTypes')))))
{
$GLOBALS['TL_DCA'][$dc->table]['palettes'] = str_replace(',importantPartX,importantPartY,importantPartWidth,importantPartHeight', '', $GLOBALS['TL_DCA'][$dc->table]['palettes']);
}
} | php | {
"resource": ""
} |
q242982 | tl_files.checkFilename | validation | public function checkFilename($varValue, Contao\DataContainer $dc)
{
$varValue = str_replace('"', '', $varValue);
if (strpos($varValue, '/') !== false || preg_match('/\.$/', $varValue))
{
throw new Exception($GLOBALS['TL_LANG']['ERR']['invalidName']);
}
// Check the length without the file extension
if ($dc->activeRecord && $varValue != '')
{
$intMaxlength = $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['maxlength'];
if ($dc->activeRecord->type == 'file')
{
$intMaxlength -= (\strlen($dc->activeRecord->extension) + 1);
}
if ($intMaxlength && Patchwork\Utf8::strlen($varValue) > $intMaxlength)
{
throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['maxlength'], $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['label'][0], $intMaxlength));
}
}
return $varValue;
} | php | {
"resource": ""
} |
q242983 | tl_files.syncFiles | validation | public function syncFiles($href, $label, $title, $class, $attributes)
{
return $this->User->hasAccess('f6', 'fop') ? '<a href="'.$this->addToUrl($href).'" title="'.Contao\StringUtil::specialchars($title).'" class="'.$class.'"'.$attributes.'>'.$label.'</a> ' : '';
} | php | {
"resource": ""
} |
q242984 | tl_files.uploadFile | validation | public function uploadFile($row, $href, $label, $title, $icon, $attributes)
{
if (!$GLOBALS['TL_DCA']['tl_files']['config']['closed'] && !$GLOBALS['TL_DCA']['tl_files']['config']['notCreatable'] && Contao\Input::get('act') != 'select' && isset($row['type']) && $row['type'] == 'folder')
{
return '<a href="'.$this->addToUrl($href.'&pid='.$row['id']).'" title="'.Contao\StringUtil::specialchars($title).'" '.$attributes.'>'.Contao\Image::getHtml($icon, $label).'</a> ';
}
return ' ';
} | php | {
"resource": ""
} |
q242985 | tl_files.deleteFile | validation | public function deleteFile($row, $href, $label, $title, $icon, $attributes)
{
$rootDir = Contao\System::getContainer()->getParameter('kernel.project_dir');
$path = $rootDir . '/' . urldecode($row['id']);
if (!is_dir($path))
{
return ($this->User->hasAccess('f3', 'fop') || $this->User->hasAccess('f4', 'fop')) ? '<a href="'.$this->addToUrl($href.'&id='.$row['id']).'" title="'.Contao\StringUtil::specialchars($title).'"'.$attributes.'>'.Contao\Image::getHtml($icon, $label).'</a> ' : Contao\Image::getHtml(preg_replace('/\.svg$/i', '_.svg', $icon)).' ';
}
$finder = Symfony\Component\Finder\Finder::create()->in($path);
if ($finder->count() > 0)
{
return $this->User->hasAccess('f4', 'fop') ? '<a href="'.$this->addToUrl($href.'&id='.$row['id']).'" title="'.Contao\StringUtil::specialchars($title).'"'.$attributes.'>'.Contao\Image::getHtml($icon, $label).'</a> ' : Contao\Image::getHtml(preg_replace('/\.svg$/i', '_.svg', $icon)).' ';
}
return $this->User->hasAccess('f3', 'fop') ? '<a href="'.$this->addToUrl($href.'&id='.$row['id']).'" title="'.Contao\StringUtil::specialchars($title).'"'.$attributes.'>'.Contao\Image::getHtml($icon, $label).'</a> ' : Contao\Image::getHtml(preg_replace('/\.svg$/i', '_.svg', $icon)).' ';
} | php | {
"resource": ""
} |
q242986 | tl_files.showFile | validation | public function showFile($row, $href, $label, $title, $icon, $attributes)
{
if (Contao\Input::get('popup'))
{
return '';
}
else
{
return '<a href="contao/popup.php?src=' . base64_encode($row['id']) . '" title="'.Contao\StringUtil::specialchars($title).'"'.$attributes.' onclick="Backend.openModalIframe({\'title\':\''.str_replace("'", "\\'", Contao\StringUtil::specialchars($row['fileNameEncoded'])).'\',\'url\':this.href});return false">'.Contao\Image::getHtml($icon, $label).'</a> ';
}
} | php | {
"resource": ""
} |
q242987 | FeedItem.addEnclosure | validation | public function addEnclosure($strFile, $strUrl=null, $strMedia='enclosure')
{
if ($strFile == '' || !file_exists(System::getContainer()->getParameter('kernel.project_dir') . '/' . $strFile))
{
return;
}
if ($strUrl === null)
{
$strUrl = Environment::get('base');
}
$objFile = new File($strFile);
$this->arrData['enclosure'][] = array
(
'media' => $strMedia,
'url' => $strUrl . System::urlEncode($strFile),
'length' => $objFile->size,
'type' => $objFile->mime
);
} | php | {
"resource": ""
} |
q242988 | tl_module_calendar.getCalendars | validation | public function getCalendars()
{
if (!$this->User->isAdmin && !\is_array($this->User->calendars))
{
return array();
}
$arrCalendars = array();
$objCalendars = $this->Database->execute("SELECT id, title FROM tl_calendar ORDER BY title");
while ($objCalendars->next())
{
if ($this->User->hasAccess($objCalendars->id, 'calendars'))
{
$arrCalendars[$objCalendars->id] = $objCalendars->title;
}
}
return $arrCalendars;
} | php | {
"resource": ""
} |
q242989 | ModuleListing.listSingleRecord | validation | protected function listSingleRecord($id)
{
// Fallback template
if (!\strlen($this->list_info_layout))
{
$this->list_info_layout = 'info_default';
}
$this->Template = new FrontendTemplate($this->list_info_layout);
$this->Template->record = array();
$this->Template->referer = 'javascript:history.go(-1)';
$this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
$this->list_info = StringUtil::deserialize($this->list_info);
$this->list_info_where = $this->replaceInsertTags($this->list_info_where, false);
$objRecord = $this->Database->prepare("SELECT " . implode(', ', array_map('Database::quoteIdentifier', trimsplit(',', $this->list_info))) . " FROM " . $this->list_table . " WHERE " . (($this->list_info_where != '') ? "(" . $this->list_info_where . ") AND " : "") . Database::quoteIdentifier($this->strPk) . "=?")
->limit(1)
->execute($id);
if ($objRecord->numRows < 1)
{
return;
}
$arrFields = array();
$arrRow = $objRecord->row();
$limit = \count($arrRow);
$count = -1;
foreach ($arrRow as $k=>$v)
{
// Never show passwords
if ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['inputType'] == 'password')
{
--$limit;
continue;
}
$class = 'row_' . ++$count . (($count == 0) ? ' row_first' : '') . (($count >= ($limit - 1)) ? ' row_last' : '') . ((($count % 2) == 0) ? ' even' : ' odd');
$arrFields[$k] = array
(
'raw' => $v,
'label' => (\strlen($label = $GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['label'][0]) ? $label : $k),
'content' => $this->formatValue($k, $v, true),
'class' => $class
);
}
$this->Template->record = $arrFields;
} | php | {
"resource": ""
} |
q242990 | System.import | validation | protected function import($strClass, $strKey=null, $blnForce=false)
{
$strKey = $strKey ?: $strClass;
if (\is_object($strKey))
{
$strKey = \get_class($strClass);
}
if ($blnForce || !isset($this->arrObjects[$strKey]))
{
$container = static::getContainer();
if (\is_object($strClass))
{
$this->arrObjects[$strKey] = $strClass;
}
elseif ($container->has($strClass) && (strpos($strClass, '\\') !== false || !class_exists($strClass)))
{
$this->arrObjects[$strKey] = $container->get($strClass);
}
elseif ($container instanceof Container && isset($container->getRemovedIds()[$strClass]))
{
throw new ServiceNotFoundException($strClass, null, null, array(), sprintf('The "%s" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.', $strClass));
}
elseif (\in_array('getInstance', get_class_methods($strClass)))
{
$this->arrObjects[$strKey] = \call_user_func(array($strClass, 'getInstance'));
}
else
{
$this->arrObjects[$strKey] = new $strClass();
}
}
} | php | {
"resource": ""
} |
q242991 | System.log | validation | public static function log($strText, $strFunction, $strCategory)
{
@trigger_error('Using System::log() has been deprecated and will no longer work in Contao 5.0. Use the logger service instead.', E_USER_DEPRECATED);
$level = 'ERROR' === $strCategory ? LogLevel::ERROR : LogLevel::INFO;
$logger = static::getContainer()->get('monolog.logger.contao');
$logger->log($level, $strText, array('contao' => new ContaoContext($strFunction, $strCategory)));
} | php | {
"resource": ""
} |
q242992 | System.getReferer | validation | public static function getReferer($blnEncodeAmpersands=false, $strTable=null)
{
/** @var Session $objSession */
$objSession = static::getContainer()->get('session');
$ref = Input::get('ref');
$key = Input::get('popup') ? 'popupReferer' : 'referer';
$session = $objSession->get($key);
// Unique referer ID
if ($ref && isset($session[$ref]))
{
$session = $session[$ref];
}
elseif (\defined('TL_MODE') && TL_MODE == 'BE' && \is_array($session))
{
$session = end($session);
}
// Use a specific referer
if ($strTable != '' && isset($session[$strTable]) && Input::get('act') != 'select')
{
$session['current'] = $session[$strTable];
}
// Remove parameters helper
$cleanUrl = function ($url, $params=array('rt', 'ref'))
{
if ($url == '' || strpos($url, '?') === false)
{
return $url;
}
list($path, $query) = explode('?', $url, 2);
/** @var Query $queryObj */
$queryObj = new Query($query);
$queryObj = $queryObj->withoutPairs($params);
return $path . $queryObj->getUriComponent();
};
// Determine current or last
$strUrl = ($cleanUrl($session['current']) != $cleanUrl(Environment::get('request'))) ? $session['current'] : $session['last'];
// Remove the "toggle" and "toggle all" parameters
$return = $cleanUrl($strUrl, array('tg', 'ptg'));
// Fallback to the generic referer in the front end
if ($return == '' && \defined('TL_MODE') && TL_MODE == 'FE')
{
$return = Environment::get('httpReferer');
}
// Fallback to the current URL if there is no referer
if ($return == '')
{
$return = (\defined('TL_MODE') && TL_MODE == 'BE') ? 'contao/main.php' : Environment::get('url');
}
// Do not urldecode here!
return preg_replace('/&(amp;)?/i', ($blnEncodeAmpersands ? '&' : '&'), $return);
} | php | {
"resource": ""
} |
q242993 | System.isInstalledLanguage | validation | public static function isInstalledLanguage($strLanguage)
{
if (!isset(static::$arrLanguages[$strLanguage]))
{
$rootDir = self::getContainer()->getParameter('kernel.project_dir');
if (is_dir($rootDir . '/vendor/contao/core-bundle/src/Resources/contao/languages/' . $strLanguage))
{
static::$arrLanguages[$strLanguage] = true;
}
elseif (is_dir(static::getContainer()->getParameter('kernel.cache_dir') . '/contao/languages/' . $strLanguage))
{
static::$arrLanguages[$strLanguage] = true;
}
else
{
/** @var SplFileInfo[] $files */
$files = static::getContainer()->get('contao.resource_finder')->findIn('languages')->depth(0)->directories()->name($strLanguage);
static::$arrLanguages[$strLanguage] = \count($files) > 0;
}
}
return static::$arrLanguages[$strLanguage];
} | php | {
"resource": ""
} |
q242994 | System.getCountries | validation | public static function getCountries()
{
$return = array();
$countries = array();
$arrAux = array();
static::loadLanguageFile('countries');
include __DIR__ . '/../../config/countries.php';
foreach ($countries as $strKey=>$strName)
{
$arrAux[$strKey] = isset($GLOBALS['TL_LANG']['CNT'][$strKey]) ? Utf8::toAscii($GLOBALS['TL_LANG']['CNT'][$strKey]) : $strName;
}
asort($arrAux);
foreach (array_keys($arrAux) as $strKey)
{
$return[$strKey] = $GLOBALS['TL_LANG']['CNT'][$strKey] ?? $countries[$strKey];
}
// HOOK: add custom logic
if (isset($GLOBALS['TL_HOOKS']['getCountries']) && \is_array($GLOBALS['TL_HOOKS']['getCountries']))
{
foreach ($GLOBALS['TL_HOOKS']['getCountries'] as $callback)
{
static::importStatic($callback[0])->{$callback[1]}($return, $countries);
}
}
return $return;
} | php | {
"resource": ""
} |
q242995 | System.getLanguages | validation | public static function getLanguages($blnInstalledOnly=false)
{
$return = array();
$languages = array();
$arrAux = array();
$langsNative = array();
static::loadLanguageFile('languages');
include __DIR__ . '/../../config/languages.php';
foreach ($languages as $strKey=>$strName)
{
$arrAux[$strKey] = isset($GLOBALS['TL_LANG']['LNG'][$strKey]) ? Utf8::toAscii($GLOBALS['TL_LANG']['LNG'][$strKey]) : $strName;
}
asort($arrAux);
$arrBackendLanguages = self::getContainer()->getParameter('contao.locales');
foreach (array_keys($arrAux) as $strKey)
{
if ($blnInstalledOnly && !\in_array($strKey, $arrBackendLanguages))
{
continue;
}
$return[$strKey] = $GLOBALS['TL_LANG']['LNG'][$strKey] ?? $languages[$strKey];
if (isset($langsNative[$strKey]) && $langsNative[$strKey] != $return[$strKey])
{
$return[$strKey] .= ' - ' . $langsNative[$strKey];
}
}
// HOOK: add custom logic
if (isset($GLOBALS['TL_HOOKS']['getLanguages']) && \is_array($GLOBALS['TL_HOOKS']['getLanguages']))
{
foreach ($GLOBALS['TL_HOOKS']['getLanguages'] as $callback)
{
static::importStatic($callback[0])->{$callback[1]}($return, $languages, $langsNative, $blnInstalledOnly);
}
}
return $return;
} | php | {
"resource": ""
} |
q242996 | System.getTimeZones | validation | public static function getTimeZones()
{
$arrReturn = array();
$timezones = array();
require __DIR__ . '/../../config/timezones.php';
foreach ($timezones as $strGroup=>$arrTimezones)
{
foreach ($arrTimezones as $strTimezone)
{
$arrReturn[$strGroup][] = $strTimezone;
}
}
return $arrReturn;
} | php | {
"resource": ""
} |
q242997 | System.setCookie | validation | public static function setCookie($strName, $varValue, $intExpires, $strPath=null, $strDomain=null, $blnSecure=false, $blnHttpOnly=false)
{
if ($strPath == '')
{
$strPath = Environment::get('path') ?: '/'; // see #4390
}
$objCookie = new \stdClass();
$objCookie->strName = $strName;
$objCookie->varValue = $varValue;
$objCookie->intExpires = $intExpires;
$objCookie->strPath = $strPath;
$objCookie->strDomain = $strDomain;
$objCookie->blnSecure = $blnSecure;
$objCookie->blnHttpOnly = $blnHttpOnly;
// HOOK: allow to add custom logic
if (isset($GLOBALS['TL_HOOKS']['setCookie']) && \is_array($GLOBALS['TL_HOOKS']['setCookie']))
{
foreach ($GLOBALS['TL_HOOKS']['setCookie'] as $callback)
{
$objCookie = static::importStatic($callback[0])->{$callback[1]}($objCookie);
}
}
setcookie($objCookie->strName, $objCookie->varValue, $objCookie->intExpires, $objCookie->strPath, $objCookie->strDomain, $objCookie->blnSecure, $objCookie->blnHttpOnly);
} | php | {
"resource": ""
} |
q242998 | System.getReadableSize | validation | public static function getReadableSize($intSize, $intDecimals=1)
{
for ($i=0; $intSize>=1024; $i++)
{
$intSize /= 1024;
}
return static::getFormattedNumber($intSize, $intDecimals) . ' ' . $GLOBALS['TL_LANG']['UNITS'][$i];
} | php | {
"resource": ""
} |
q242999 | System.getFormattedNumber | validation | public static function getFormattedNumber($varNumber, $intDecimals=2)
{
return number_format(round($varNumber, $intDecimals), $intDecimals, $GLOBALS['TL_LANG']['MSC']['decimalSeparator'], $GLOBALS['TL_LANG']['MSC']['thousandsSeparator']);
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.