code
stringlengths 41
2.04k
| label_name
stringclasses 2
values | label
int64 0
1
|
---|---|---|
function PMA_Process_formset(FormDisplay $form_display)
{
if (filter_input(INPUT_GET, 'mode') == 'revert') {
// revert erroneous fields to their default values
$form_display->fixErrors();
PMA_generateHeader303();
}
if (!$form_display->process(false)) {
// handle form view and failed POST
$form_display->display(true, true);
return;
}
// check for form errors
if (!$form_display->hasErrors()) {
PMA_generateHeader303();
return;
}
// form has errors, show warning
$separator = PMA_URL_getArgSeparator('html');
$page = filter_input(INPUT_GET, 'page');
$formset = filter_input(INPUT_GET, 'formset');
$formset = $formset ? "{$separator}formset=$formset" : '';
$formId = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
if ($formId === null && $page == 'servers') {
// we've just added a new server, get its id
$formId = $form_display->getConfigFile()->getServerCount();
}
$formId = $formId ? "{$separator}id=$formId" : '';
?>
<div class="error">
<h4><?php echo __('Warning') ?></h4>
<?php echo __('Submitted form contains errors') ?><br />
<a href="?page=<?php echo $page . $formset . $formId . $separator ?>mode=revert">
<?php echo __('Try to revert erroneous fields to their default values')
?>
</a>
</div>
<?php $form_display->displayErrors() ?>
<a class="btn" href="index.php"><?php echo __('Ignore errors') ?></a>
<a class="btn" href="?page=<?php echo $page . $formset . $formId
. $separator ?>mode=edit"><?php echo __('Show form') ?></a>
<?php
} | CWE-352 | 0 |
public static function insert ($vars) {
if(is_array($vars)){
$set = "";
$k = "";
foreach ($vars['key'] as $key => $val) {
$set .= "'$val',";
$k .= "`$key`,";
}
$set = substr($set, 0,-1);
$k = substr($k, 0,-1);
$sql = sprintf("INSERT INTO `%s` (%s) VALUES (%s) ", $vars['table'], $k, $set) ;
}else{
$sql = $vars;
}
if(DB_DRIVER == 'mysql') {
mysql_query('SET CHARACTER SET utf8');
$q = mysql_query($sql) or die(mysql_error());
self::$last_id = mysql_insert_id();
}elseif(DB_DRIVER == 'mysqli'){
try {
if(!self::query($sql)){
printf("<div class=\"alert alert-danger\">Errormessage: %s</div>\n", self::$mysqli->error);
}else{
self::$last_id = self::$mysqli->insert_id;
}
} catch (exception $e) {
echo $e->getMessage();
}
}
return true;
} | CWE-352 | 0 |
public static function go($input, $path, $allowed='', $uniq=false, $size='', $width = '', $height = ''){
$filename = Typo::cleanX($_FILES[$input]['name']);
$filename = str_replace(' ', '_', $filename);
if(isset($_FILES[$input]) && $_FILES[$input]['error'] == 0){
if($uniq == true){
$uniqfile = sha1(microtime().$filename);
}else{
$uniqfile = '';
}
$extension = pathinfo($_FILES[$input]['name'], PATHINFO_EXTENSION);
$filetmp = $_FILES[$input]['tmp_name'];
$filepath = GX_PATH.$path.$uniqfile.$filename;
if(!in_array(strtolower($extension), $allowed)){
$result['error'] = 'File not allowed';
}else{
if(move_uploaded_file(
$filetmp,
$filepath)
){
$result['filesize'] = filesize($filepath);
$result['filename'] = $uniqfile.$filename;
$result['path'] = $path.$uniqfile.$filename;
$result['filepath'] = $filepath;
$result['fileurl'] = Options::get('siteurl').$path.$uniqfile.$filename;
}else{
$result['error'] = 'Cannot upload to directory, please check
if directory is exist or You had permission to write it.';
}
}
}else{
//$result['error'] = $_FILES[$input]['error'];
$result['error'] = '';
}
return $result;
} | CWE-352 | 0 |
public function store(CurrencyFormRequest $request)
{
/** @var User $user */
$user = auth()->user();
$data = $request->getCurrencyData();
if (!$this->userRepository->hasRole($user, 'owner')) {
Log::error('User ' . auth()->user()->id . ' is not admin, but tried to store a currency.');
Log::channel('audit')->info('Tried to create (POST) currency without admin rights.', $data);
return redirect($this->getPreviousUri('currencies.create.uri'));
}
$data['enabled'] = true;
try {
$currency = $this->repository->store($data);
} catch (FireflyException $e) {
Log::error($e->getMessage());
Log::channel('audit')->info('Could not store (POST) currency without admin rights.', $data);
$request->session()->flash('error', (string) trans('firefly.could_not_store_currency'));
$currency = null;
}
$redirect = redirect($this->getPreviousUri('currencies.create.uri'));
if (null !== $currency) {
$request->session()->flash('success', (string) trans('firefly.created_currency', ['name' => $currency->name]));
Log::channel('audit')->info('Created (POST) currency.', $data);
if (1 === (int) $request->get('create_another')) {
$request->session()->put('currencies.create.fromStore', true);
$redirect = redirect(route('currencies.create'))->withInput();
}
}
return $redirect;
} | CWE-352 | 0 |
public function enableCurrency(TransactionCurrency $currency)
{
app('preferences')->mark();
$this->repository->enable($currency);
session()->flash('success', (string) trans('firefly.currency_is_now_enabled', ['name' => $currency->name]));
Log::channel('audit')->info(sprintf('Enabled currency %s.', $currency->code));
return redirect(route('currencies.index'));
} | CWE-352 | 0 |
public static function rss() {
switch (SMART_URL) {
case true:
# code...
$url = Options::get('siteurl')."/rss".GX_URL_PREFIX;
break;
default:
# code...
$url = Options::get('siteurl')."/index.php?rss";
break;
}
return $url;
} | CWE-352 | 0 |
public function pinCommentAction(ProjectComment $comment)
{
$comment->setPinned(!$comment->isPinned());
try {
$this->repository->saveComment($comment);
} catch (\Exception $ex) {
$this->flashUpdateException($ex);
}
return $this->redirectToRoute('project_details', ['id' => $comment->getProject()->getId()]);
} | CWE-352 | 0 |
public static function page($vars) {
switch (SMART_URL) {
case true:
# code...
$url = Options::get('siteurl')."/".self::slug($vars).GX_URL_PREFIX;
break;
default:
# code...
$url = Options::get('siteurl')."/index.php?page={$vars}";
break;
}
return $url;
} | CWE-352 | 0 |
public function submit(Request $request)
{
return logout();
} | CWE-352 | 0 |
public function write($template = '')
{
if (!empty($this->script_files)) {
$this->set_env('request_token', $this->app->get_request_token());
}
$commands = $this->get_js_commands($framed);
// if all js commands go to parent window we can ignore all
// script files and skip rcube_webmail initialization (#1489792)
if ($framed) {
$this->scripts = array();
$this->script_files = array();
$this->header = '';
$this->footer = '';
}
// write all javascript commands
$this->add_script($commands, 'head_top');
// send clickjacking protection headers
$iframe = $this->framed || $this->env['framed'];
if (!headers_sent() && ($xframe = $this->app->config->get('x_frame_options', 'sameorigin'))) {
header('X-Frame-Options: ' . ($iframe && $xframe == 'deny' ? 'sameorigin' : $xframe));
} | CWE-352 | 0 |
$ret = array_merge($ret, csrf_flattenpost2($level+1, $nk, $v));
} | CWE-352 | 0 |
protected static function __Load($path) {
include_once($path);
} | CWE-352 | 0 |
public function testDeleteTemplateAction()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$fixture = new InvoiceTemplateFixtures();
$template = $this->importFixture($fixture);
$id = $template[0]->getId();
$this->request($client, '/invoice/template/' . $id . '/delete');
$this->assertIsRedirect($client, '/invoice/template');
$client->followRedirect();
$this->assertTrue($client->getResponse()->isSuccessful());
$this->assertHasFlashSuccess($client);
$this->assertEquals(0, $this->getEntityManager()->getRepository(InvoiceTemplate::class)->count([]));
} | CWE-352 | 0 |
function update_license_status() {
$status = '';
$license_key = $this->get_license_key();
if (!empty($license_key) || defined('W3TC_LICENSE_CHECK')) {
$license = edd_w3edge_w3tc_check_license($license_key, W3TC_VERSION);
$version = '';
if ($license) {
$status = $license->license;
if ('host_valid' == $status) {
$version = 'pro';
} elseif (in_array($status, array('site_inactive','valid')) && w3tc_is_pro_dev_mode()) {
$status = 'valid';
$version = 'pro_dev';
}
}
$this->_config->set('plugin.type', $version);
} else {
$status = 'no_key';
$this->_config->set('plugin.type', '');
}
try {
$this->_config->save();
} catch(Exception $ex) {}
return $status;
} | CWE-352 | 0 |
public static function startup()
{
//Override the default expire time of token
\CsrfMagic\Csrf::$expires = 259200;
\CsrfMagic\Csrf::$callback = function ($tokens) {
throw new \App\Exceptions\AppException('Invalid request - Response For Illegal Access', 403);
};
$js = 'vendor/yetiforce/csrf-magic/src/Csrf.min.js';
if (!IS_PUBLIC_DIR) {
$js = 'public_html/' . $js;
}
\CsrfMagic\Csrf::$dirSecret = __DIR__;
\CsrfMagic\Csrf::$rewriteJs = $js;
\CsrfMagic\Csrf::$cspToken = \App\Session::get('CSP_TOKEN');
\CsrfMagic\Csrf::$frameBreaker = \Config\Security::$csrfFrameBreaker;
\CsrfMagic\Csrf::$windowVerification = \Config\Security::$csrfFrameBreakerWindow;
/*
* if an ajax request initiated, then if php serves content with <html> tags
* as a response, then unnecessarily we are injecting csrf magic javascipt
* in the response html at <head> and <body> using csrf_ob_handler().
* So, to overwride above rewriting we need following config.
*/
if (static::isAjax()) {
\CsrfMagic\Csrf::$frameBreaker = false;
\CsrfMagic\Csrf::$rewriteJs = null;
}
} | CWE-352 | 0 |
public function testConfigurationCookieCreate()
{
$_SERVER['REQUEST_METHOD'] = 'GET';
$controller = $this->getMock('Cake\Controller\Controller', ['redirect']);
$controller->request = new Request(['webroot' => '/dir/']);
$controller->response = new Response();
$component = new CsrfComponent($this->registry, [
'cookieName' => 'token',
'expiry' => '+1 hour',
'secure' => true,
'httpOnly' => true
]);
$event = new Event('Controller.startup', $controller);
$component->startup($event);
$this->assertEmpty($controller->response->cookie('csrfToken'));
$cookie = $controller->response->cookie('token');
$this->assertNotEmpty($cookie, 'Should set a token.');
$this->assertRegExp('/^[a-f0-9]+$/', $cookie['value'], 'Should look like a hash.');
$this->assertWithinRange((new Time('+1 hour'))->format('U'), $cookie['expire'], 1, 'session duration.');
$this->assertEquals('/dir/', $cookie['path'], 'session path.');
$this->assertTrue($cookie['secure'], 'cookie security flag missing');
$this->assertTrue($cookie['httpOnly'], 'cookie httpOnly flag missing');
} | CWE-352 | 0 |
public static function meta($cont_title='', $cont_desc='', $pre =''){
global $data;
//print_r($data);
//if(empty($data['posts'][0]->title)){
if(is_array($data) && isset($data['posts'][0]->title)){
$sitenamelength = strlen(Options::get('sitename'));
$limit = 70-$sitenamelength-6;
$cont_title = substr(Typo::Xclean(Typo::strip($data['posts'][0]->title)),0,$limit);
$titlelength = strlen($data['posts'][0]->title);
if($titlelength > $limit+3) { $dotted = "...";} else {$dotted = "";}
$cont_title = "{$pre} {$cont_title}{$dotted} - ";
}else{
$cont_title = "";
}
if(is_array($data) && isset($data['posts'][0]->content)){
$desc = Typo::strip($data['posts'][0]->content);
}else{
$desc = "";
}
$meta = "
<!--// Start Meta: Generated Automaticaly by GeniXCMS -->
<!-- SEO: Title stripped 70chars for SEO Purpose -->
<title>{$cont_title}".Options::get('sitename')."</title>
<meta name=\"Keyword\" content=\"".Options::get('sitekeywords')."\">
<!-- SEO: Description stripped 150chars for SEO Purpose -->
<meta name=\"Description\" content=\"".self::desc($desc)."\">
<meta name=\"Author\" content=\"Puguh Wijayanto | MetalGenix IT Solutions - www.metalgenix.com\">
<meta name=\"Generator\" content=\"GeniXCMS\">
<meta name=\"robots\" content=\"".Options::get('robots')."\">
<meta name=\"revisit-after\" content=\" days\">
<link rel=\"shortcut icon\" href=\"".Options::get('siteicon')."\" />
";
$meta .= "
<!-- Generated Automaticaly by GeniXCMS :End Meta //-->";
echo $meta;
} | CWE-352 | 0 |
public function create(Request $request)
{
/** @var User $user */
$user = auth()->user();
if (!$this->userRepository->hasRole($user, 'owner')) {
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
return redirect(route('currencies.index'));
}
$subTitleIcon = 'fa-plus';
$subTitle = (string) trans('firefly.create_currency');
// put previous url in session if not redirect from store (not "create another").
if (true !== session('currencies.create.fromStore')) {
$this->rememberPreviousUri('currencies.create.uri');
}
$request->session()->forget('currencies.create.fromStore');
Log::channel('audit')->info('Create new currency.');
return prefixView('currencies.create', compact('subTitleIcon', 'subTitle'));
} | CWE-352 | 0 |
function phpAds_SessionStart()
{
global $session;
if (empty($_COOKIE['sessionID'])) {
$session = array();
$_COOKIE['sessionID'] = md5(uniqid('phpads', 1));
phpAds_SessionSetAdminCookie('sessionID', $_COOKIE['sessionID']);
}
return $_COOKIE['sessionID'];
} | CWE-384 | 1 |
function handleFormSubmission(&$request, &$output, &$session) {
if ($request->getText('action')) {
handleRequestActionSubmission('admin', $this, $session);
} else if ($request->getText('blockSubmit')) {
$this->handleBlockFormSubmission($request, $output, $session);
} else if ($request->getText('unblockSubmit')) {
$this->handleUnblockFormSubmission($request, $output, $session);
} else if ($request->getText('bypassAddUsername') || $request->getText('bypassRemoveUsername')) { //TODO: refactor to move all the subpages into their own files
$bypassPage = new RequirementsBypassPage($this);
$bypassPage->handleFormSubmission();
}
} | CWE-352 | 0 |
private function _handleCallback(){
try {
// Try to get an access token using the authorization code grant.
$accessToken = $this->_provider->getAccessToken('authorization_code', [
'code' => $_GET['code']
]);
} catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
// Failed to get the access token or user details.
exit($e->getMessage());
}
$resourceOwner = $this->_provider->getResourceOwner($accessToken);
$user = $this->_userHandling( $resourceOwner->toArray() );
$user->setCookies();
global $wgOut, $wgRequest;
$title = null;
$wgRequest->getSession()->persist();
if( $wgRequest->getSession()->exists('returnto') ) {
$title = Title::newFromText( $wgRequest->getSession()->get('returnto') );
$wgRequest->getSession()->remove('returnto');
$wgRequest->getSession()->save();
}
if( !$title instanceof Title || 0 > $title->mArticleID ) {
$title = Title::newMainPage();
}
$wgOut->redirect( $title->getFullURL() );
return true;
} | CWE-352 | 0 |
public function setFrom($address, $name = '', $auto = true)
{
$address = trim($address);
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
if (!$this->validateAddress($address)) {
$this->setError($this->lang('invalid_address') . ': ' . $address);
$this->edebug($this->lang('invalid_address') . ': ' . $address);
if ($this->exceptions) {
throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
}
return false;
}
$this->From = $address;
$this->FromName = $name;
if ($auto) {
if (empty($this->Sender)) {
$this->Sender = $address;
}
}
return true;
} | CWE-352 | 0 |
function addChannelPageTools($agencyid, $websiteId, $channelid, $channelType)
{
if ($channelType == 'publisher') {
$deleteReturlUrl = MAX::constructUrl(MAX_URL_ADMIN, 'affiliate-channels.php');
}
else {
$deleteReturlUrl = MAX::constructUrl(MAX_URL_ADMIN, 'channel-index.php');
}
//duplicate
addPageLinkTool($GLOBALS["strDuplicate"], MAX::constructUrl(MAX_URL_ADMIN, "channel-modify.php?duplicate=true&agencyid=$agencyid&affiliateid=$websiteId&channelid=$channelid&returnurl=".urlencode(basename($_SERVER['SCRIPT_NAME']))), "iconTargetingChannelDuplicate");
//delete
$deleteConfirm = phpAds_DelConfirm($GLOBALS['strConfirmDeleteChannel']);
addPageLinkTool($GLOBALS["strDelete"], MAX::constructUrl(MAX_URL_ADMIN, "channel-delete.php?token=" . urlencode(phpAds_SessionGetToken()) . "&agencyid=$agencyid&affiliateid=$websiteId&channelid=$channelid&returnurl=$deleteReturlUrl"), "iconDelete", null, $deleteConfirm);
} | CWE-352 | 0 |
function storeSerializedSession($serialized_session_data, $session_id)
{
$doSession = OA_Dal::staticGetDO('session', $session_id);
if ($doSession) {
$doSession->sessiondata = $serialized_session_data;
$doSession->update();
}
else {
$doSession = OA_Dal::factoryDO('session');
$doSession->sessionid = $session_id;
$doSession->sessiondata = $serialized_session_data;
$doSession->insert();
}
} | CWE-384 | 1 |
public function __destruct()
{
if ($this->Mailer == 'smtp') { //close any open SMTP connection nicely
$this->smtpClose();
}
} | CWE-352 | 0 |
$otherPublisherName = MAX_buildName($aOtherPublisher['publisher_id'], $aOtherPublisher['name']);
if ($aOtherPublisher['publisher_id'] != $affiliateid) {
$form .= "<option value='" . $aOtherPublisher['publisher_id'] . "'>" . htmlspecialchars($otherPublisherName) . "</option>";
}
}
$form .= "</select><input type='image' class='submit' src='" . OX::assetPath() . "/images/".$phpAds_TextDirection."/go_blue.gif'></form>";
addPageFormTool($GLOBALS['strMoveTo'], 'iconZoneMove', $form);
}
//delete
if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)
|| OA_Permission::isAccount(OA_ACCOUNT_MANAGER)
|| OA_Permission::hasPermission(OA_PERM_ZONE_DELETE)) {
$deleteConfirm = phpAds_DelConfirm($GLOBALS['strConfirmDeleteZone']);
addPageLinkTool($GLOBALS["strDelete"], MAX::constructUrl(MAX_URL_ADMIN, "zone-delete.php?token=" . urlencode(phpAds_SessionGetToken()) . "&affiliateid=$affiliateid&zoneid=$zoneid&returnurl=affiliate-zones.php"), "iconDelete", null, $deleteConfirm);
}
//shortcut
addPageShortcut($GLOBALS['strBackToZones'], MAX::constructUrl(MAX_URL_ADMIN, "affiliate-zones.php?affiliateid=$affiliateid"), "iconBack");
$entityString = _getEntityString($aEntities);
addPageShortcut($GLOBALS['strZoneHistory'], MAX::constructUrl(MAX_URL_ADMIN, "stats.php?entity=zone&breakdown=history&$entityString"), 'iconStatistics');
} | CWE-352 | 0 |
public static function httpMethodProvider()
{
return [
['PATCH'], ['PUT'], ['POST'], ['DELETE']
];
} | CWE-352 | 0 |
foreach ($all_users as &$u) {
if ($u['username'] == $username && $this->verifyPassword($password, $u['password'])) {
$user = $this->mapToUserObject($u);
$this->store($user);
$this->session->set(self::SESSION_HASH, $u['password']);
return true;
}
} | CWE-384 | 1 |
function getRights($interface = 'central') {
$values = [READ => __('Read'),
CREATE => __('Create'),
PURGE => _x('button', 'Delete permanently'),
self::CHECKUPDATE => __('Check for upgrade')];
return $values;
} | CWE-352 | 0 |
public function logout(){
$login_user = $this->checkLogin();
D("UserToken")->where(" uid = '$login_user[uid]' ")->save(array("token_expire"=>0));
session("login_user" , NULL);
cookie('cookie_token',NULL);
session(null);
$this->sendResult(array());
} | CWE-352 | 0 |
function yourls_verify_nonce( $action, $nonce = false, $user = false, $return = '' ) {
// get user
if( false == $user )
$user = defined( 'YOURLS_USER' ) ? YOURLS_USER : '-1';
// get current nonce value
if( false == $nonce && isset( $_REQUEST['nonce'] ) )
$nonce = $_REQUEST['nonce'];
// Allow plugins to short-circuit the rest of the function
$valid = yourls_apply_filter( 'verify_nonce', false, $action, $nonce, $user, $return );
if ($valid) {
return true;
}
// what nonce should be
$valid = yourls_create_nonce( $action, $user );
if( $nonce == $valid ) {
return true;
} else {
if( $return )
die( $return );
yourls_die( yourls__( 'Unauthorized action or expired link' ), yourls__( 'Error' ), 403 );
}
} | CWE-352 | 0 |
public static function sitemap() {
switch (SMART_URL) {
case true:
# code...
$url = Options::get('siteurl')."/sitemap".GX_URL_PREFIX;
break;
default:
# code...
$url = Options::get('siteurl')."/index.php?page=sitemap";
break;
}
return $url;
} | CWE-352 | 0 |
public function delete(Request $request, TransactionCurrency $currency)
{
/** @var User $user */
$user = auth()->user();
if (!$this->userRepository->hasRole($user, 'owner')) {
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but is not site owner.', $currency->code));
return redirect(route('currencies.index'));
}
if ($this->repository->currencyInUse($currency)) {
$location = $this->repository->currencyInUseAt($currency);
$message = (string) trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]);
$request->session()->flash('error', $message);
Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but currency is in use.', $currency->code));
return redirect(route('currencies.index'));
}
// put previous url in session
$this->rememberPreviousUri('currencies.delete.uri');
$subTitle = (string) trans('form.delete_currency', ['name' => $currency->name]);
Log::channel('audit')->info(sprintf('Visit page to delete currency %s.', $currency->code));
return prefixView('currencies.delete', compact('currency', 'subTitle'));
} | CWE-352 | 0 |
public function testDuplicateAction()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
/** @var EntityManager $em */
$em = $this->getEntityManager();
$project = $em->find(Project::class, 1);
$project->setMetaField((new ProjectMeta())->setName('foo')->setValue('bar'));
$project->setEnd(new \DateTime());
$em->persist($project);
$team = new Team();
$team->addTeamlead($this->getUserByRole(User::ROLE_ADMIN));
$team->addProject($project);
$team->setName('project 1');
$em->persist($team);
$rate = new ProjectRate();
$rate->setProject($project);
$rate->setRate(123.45);
$em->persist($rate);
$activity = new Activity();
$activity->setName('blub');
$activity->setProject($project);
$activity->setMetaField((new ActivityMeta())->setName('blub')->setValue('blab'));
$em->persist($activity);
$rate = new ActivityRate();
$rate->setActivity($activity);
$rate->setRate(123.45);
$em->persist($rate);
$em->flush();
$this->request($client, '/admin/project/1/duplicate');
$this->assertIsRedirect($client, '/details');
$client->followRedirect();
$node = $client->getCrawler()->filter('div.box#project_rates_box');
self::assertEquals(1, $node->count());
$node = $client->getCrawler()->filter('div.box#project_rates_box table.dataTable tbody tr:not(.summary)');
self::assertEquals(1, $node->count());
self::assertStringContainsString('123.45', $node->text(null, true));
} | CWE-352 | 0 |
foreach ($indexToDelete as $indexName) {
$this->addSql('DROP INDEX ' . $indexName . ' ON ' . $users);
} | CWE-352 | 0 |
public function __construct(){
} | CWE-352 | 0 |
public function save(){
$login_user = $this->checkLogin();
$uid = $login_user['uid'] ;
$id = I("id/d");
$member_group_id = I("member_group_id/d");
$cat_id = I("cat_id/d");
$teamItemMemberInfo = D("TeamItemMember")->where(" id = '$id' ")->find();
$item_id = $teamItemMemberInfo['item_id'] ;
$team_id = $teamItemMemberInfo['team_id'] ;
if(!$this->checkItemManage($uid , $item_id)){
$this->sendError(10303);
return ;
}
$teamInfo = D("Team")->where(" id = '$team_id' and uid = '$login_user[uid]' ")->find();
if (!$teamInfo) {
$this->sendError(10209,"无此团队或者你无管理此团队的权限");
return ;
}
if(isset($_POST['member_group_id'])){
$return = D("TeamItemMember")->where(" id = '$id' ")->save(array("member_group_id"=>$member_group_id));
}
if(isset($_POST['cat_id'])){
$return = D("TeamItemMember")->where(" id = '$id' ")->save(array("cat_id"=>$cat_id));
}
$this->sendResult($return);
} | CWE-352 | 0 |
static public function onPost( $par, $out, $request ) {
global $wgUser;
if (!$request->getText('reason')) {
$out->addHTML(Html::rawElement(
'p',
[ 'class' => 'error '],
wfMessage( 'report-error-missing-reason' )->escaped()
));
} else {
$dbw = wfGetDB( DB_MASTER );
$dbw->startAtomic(__METHOD__);
$dbw->insert( 'report_reports', [
'report_revid' => (int)$par,
'report_reason' => $request->getText('reason'),
'report_user' => $wgUser->getId(),
'report_user_text' => $wgUser->getName(),
'report_timestamp' => wfTimestampNow()
], __METHOD__ );
$dbw->endAtomic(__METHOD__);
$out->addWikiMsg( 'report-success' );
$out->addWikiMsg( 'returnto', '[[' . SpecialPage::getTitleFor('Diff', $par)->getPrefixedText() . ']]' );
return;
}
} | CWE-352 | 0 |
public function defaultCurrency(Request $request, TransactionCurrency $currency)
{
app('preferences')->set('currencyPreference', $currency->code);
app('preferences')->mark();
Log::channel('audit')->info(sprintf('Make %s the default currency.', $currency->code));
$this->repository->enable($currency);
$request->session()->flash('success', (string) trans('firefly.new_default_currency', ['name' => $currency->name]));
return redirect(route('currencies.index'));
} | CWE-352 | 0 |
function render() {
$output = $this->pageContext->getOutput();
$output->enableOOUI();
$this->showAddBypassForm();
$this->showBypassesList();
}
| CWE-352 | 0 |
function phpAds_SessionDataFetch()
{
global $session;
$dal = new MAX_Dal_Admin_Session();
// Guard clause: Can't fetch a session without an ID
if (empty($_COOKIE['sessionID'])) {
return;
}
$serialized_session = $dal->getSerializedSession($_COOKIE['sessionID']);
// This is required because 'sessionID' cookie is set to new during logout.
// According to comments in the file it is because some servers do not
// support setting cookies during redirect.
if (empty($serialized_session)) {
return;
}
$loaded_session = unserialize($serialized_session);
if (!$loaded_session) {
// XXX: Consider raising an error
return;
}
$session = $loaded_session;
$dal->refreshSession($_COOKIE['sessionID']);
} | CWE-384 | 1 |
public function pwd(){
$item_id = I("item_id/d");
$password = I("password");
$v_code = I("v_code");
$refer_url = I('refer_url');
//检查用户输错密码的次数。如果超过一定次数,则需要验证 验证码
$key= 'item_pwd_fail_times_'.$item_id;
if(!D("VerifyCode")->_check_times($key,10)){
if (!$v_code || $v_code != session('v_code')) {
$this->sendError(10206,L('verification_code_are_incorrect'));
return;
}
}
session('v_code',null) ;
$item = D("Item")->where("item_id = '$item_id' ")->find();
if ($item['password'] == $password) {
session("visit_item_".$item_id , 1 );
$this->sendResult(array("refer_url"=>base64_decode($refer_url)));
}else{
D("VerifyCode")->_ins_times($key);//输错密码则设置输错次数
if(D("VerifyCode")->_check_times($key,10)){
$error_code = 10307 ;
}else{
$error_code = 10308 ;
}
$this->sendError($error_code,L('access_password_are_incorrect'));
}
} | CWE-352 | 0 |
$formatted = wfMessage( 'datadump-table-column-failed' )->text();
} else {
$formatted = wfMessage( 'datadump-table-column-queued' )->text();
}
break;
case 'dumps_size':
$formatted = htmlspecialchars(
$this->getLanguage()->formatSize( isset( $row->dumps_size ) ? $row->dumps_size : 0 ) );
break;
case 'dumps_delete':
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
$query = [
'action' => 'delete',
'type' => $row->dumps_type,
'dump' => $row->dumps_filename
];
$formatted = $linkRenderer->makeLink( $this->pageTitle, wfMessage( 'datadump-delete-button' )->text(), [], $query );
break;
default:
$formatted = "Unable to format $name";
break;
}
return $formatted;
} | CWE-352 | 0 |
public function addReplyTo($address, $name = '')
{
return $this->addAnAddress('Reply-To', $address, $name);
} | CWE-352 | 0 |
public function addUser(){
$login_user = $this->checkLogin();
$this->checkAdmin();
$username = I("username");
$password = I("password");
$uid = I("uid");
$name = I("name");
if(!$username){
$this->sendError(10101,'用户名不允许为空');
return ;
}
if($uid){
if($password){
D("User")->updatePwd($uid, $password);
}
if($name){
D("User")->where(" uid = '$uid' ")->save(array("name"=>$name));
}
$this->sendResult(array());
}else{
if (D("User")->isExist($username)) {
$this->sendError(10101,L('username_exists'));
return ;
}
$new_uid = D("User")->register($username,$password);
if (!$new_uid) {
$this->sendError(10101);
}else{
if($name){
D("User")->where(" uid = '$new_uid' ")->save(array("name"=>$name));
}
$this->sendResult($return);
}
}
} | CWE-352 | 0 |
function csrf_get_tokens()
{
$has_cookies = !empty($_COOKIE);
// $ip implements a composite key, which is sent if the user hasn't sent
// any cookies. It may or may not be used, depending on whether or not
// the cookies "stick"
$secret = csrf_get_secret();
if (!$has_cookies && $secret) {
// :TODO: Harden this against proxy-spoofing attacks
$ip = ';ip:' . csrf_hash($_SERVER['IP_ADDRESS']);
} else {
$ip = '';
}
csrf_start();
// These are "strong" algorithms that don't require per se a secret
if (session_id()) {
return 'sid:' . csrf_hash(session_id()) . $ip;
}
if ($GLOBALS['csrf']['cookie']) {
$val = csrf_generate_secret();
setcookie($GLOBALS['csrf']['cookie'], $val);
return 'cookie:' . csrf_hash($val) . $ip;
}
if ($GLOBALS['csrf']['key']) {
return 'key:' . csrf_hash($GLOBALS['csrf']['key']) . $ip;
}
// These further algorithms require a server-side secret
if (!$secret) {
return 'invalid';
}
if ($GLOBALS['csrf']['user'] !== false) {
return 'user:' . csrf_hash($GLOBALS['csrf']['user']);
}
if ($GLOBALS['csrf']['allow-ip']) {
return ltrim($ip, ';');
}
return 'invalid';
} | CWE-352 | 0 |
public function attorn(){
$login_user = $this->checkLogin();
$username = I("username");
$item_id = I("item_id/d");
$password = I("password");
$item = D("Item")->where("item_id = '$item_id' ")->find();
if(!$this->checkItemManage($login_user['uid'] , $item['item_id'])){
$this->sendError(10303);
return ;
}
if(! D("User")-> checkLogin($item['username'],$password)){
$this->sendError(10208);
return ;
}
$member = D("User")->where(" username = '%s' ",array($username))->find();
if (!$member) {
$this->sendError(10209);
return ;
}
$data['username'] = $member['username'] ;
$data['uid'] = $member['uid'] ;
$id = D("Item")->where(" item_id = '$item_id' ")->save($data);
$return = D("Item")->where("item_id = '$item_id' ")->find();
if (!$return) {
$this->sendError(10101);
}
$this->sendResult($return);
} | CWE-352 | 0 |
public static function error ($vars="") {
if( isset($vars) && $vars != "" ) {
include(GX_PATH.'/inc/lib/Control/Error/'.$vars.'.control.php');
}else{
include(GX_PATH.'/inc/lib/Control/Error/404.control.php');
}
} | CWE-352 | 0 |
function handleFormSubmission() {
$request = $request = $this->pageContext->getRequest();
$dbw = getTransactableDatabase('scratch-confirmaccount-bypasses');
foreach (self::requestVariableActionMapping as $fieldKey => $action) {
if ($request->getText($fieldKey)) {
$action($request->getText($fieldKey), $dbw);
}
}
commitTransaction($dbw, 'scratch-confirmaccount-bypasses');
$this->render();
}
| CWE-352 | 0 |
public function password()
{
$user = Auth::user();
return view('account/change-password', compact('user'));
} | CWE-384 | 1 |
public static function get_param($key = NULL) {
$info = [
'stype' => htmlentities(self::$search_type),
'stext' => htmlentities(self::$search_text),
'method' => htmlentities(self::$search_method),
'datelimit' => self::$search_date_limit,
'fields' => self::$search_fields,
'sort' => self::$search_sort,
'chars' => htmlentities(self::$search_chars),
'order' => self::$search_order,
'forum_id' => self::$forum_id,
'memory_limit' => self::$memory_limit,
'composevars' => self::$composevars,
'rowstart' => self::$rowstart,
'search_param' => htmlentities(self::$search_param),
];
return $key === NULL ? $info : (isset($info[$key]) ? $info[$key] : NULL);
} | CWE-352 | 0 |
public function enable($id) {
$this->active($id, TRUE);
} | CWE-352 | 0 |
public function deleteCommentAction(ProjectComment $comment)
{
$projectId = $comment->getProject()->getId();
try {
$this->repository->deleteComment($comment);
} catch (\Exception $ex) {
$this->flashDeleteException($ex);
}
return $this->redirectToRoute('project_details', ['id' => $projectId]);
} | CWE-352 | 0 |
public static function simple($input)
{
return empty($str) ? '' : pts_strings::keep_in_string($input, pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DASH | pts_strings::CHAR_DECIMAL | pts_strings::CHAR_SPACE | pts_strings::CHAR_UNDERSCORE | pts_strings::CHAR_COMMA | pts_strings::CHAR_AT | pts_strings::CHAR_COLON);
} | CWE-352 | 0 |
public function testSettingCookie()
{
$_SERVER['REQUEST_METHOD'] = 'GET';
$controller = $this->getMock('Cake\Controller\Controller', ['redirect']);
$controller->request = new Request(['webroot' => '/dir/']);
$controller->response = new Response();
$event = new Event('Controller.startup', $controller);
$this->component->startup($event);
$cookie = $controller->response->cookie('csrfToken');
$this->assertNotEmpty($cookie, 'Should set a token.');
$this->assertRegExp('/^[a-f0-9]+$/', $cookie['value'], 'Should look like a hash.');
$this->assertEquals(0, $cookie['expire'], 'session duration.');
$this->assertEquals('/dir/', $cookie['path'], 'session path.');
$this->assertEquals($cookie['value'], $controller->request->params['_csrfToken']);
} | CWE-352 | 0 |
protected function edebug($str)
{
if (!$this->SMTPDebug) {
return;
}
switch ($this->Debugoutput) {
case 'error_log':
error_log($str);
break;
case 'html':
//Cleans up output a bit for a better looking display that's HTML-safe
echo htmlentities(preg_replace('/[\r\n]+/', '', $str), ENT_QUOTES, $this->CharSet) . "<br>\n";
break;
case 'echo':
default:
echo $str."\n";
}
} | CWE-352 | 0 |
public function pinCommentAction(CustomerComment $comment)
{
$comment->setPinned(!$comment->isPinned());
try {
$this->repository->saveComment($comment);
} catch (\Exception $ex) {
$this->flashUpdateException($ex);
}
return $this->redirectToRoute('customer_details', ['id' => $comment->getCustomer()->getId()]);
} | CWE-352 | 0 |
public static function desc($vars){
if(!empty($vars)){
$desc = substr(strip_tags(htmlspecialchars_decode($vars).". ".Options::get('sitedesc')),0,150);
}else{
$desc = substr(Options::get('sitedesc'),0,150);
}
return $desc;
} | CWE-352 | 0 |
function logon($username, $password, &$sessionId)
{
global $_POST, $_COOKIE;
global $strUsernameOrPasswordWrong;
/**
* @todo Please check if the following statement is in correct place because
* it seems illogical that user can get session ID from internal login with
* a bad username or password.
*/
if (!$this->_verifyUsernameAndPasswordLength($username, $password)) {
return false;
}
$_POST['username'] = $username;
$_POST['password'] = $password;
$_POST['login'] = 'Login';
$_COOKIE['sessionID'] = uniqid('phpads', 1);
$_POST['phpAds_cookiecheck'] = $_COOKIE['sessionID'];
$this->preInitSession();
if ($this->_internalLogin($username, $password)) {
// Check if the user has administrator access to Openads.
if (OA_Permission::isUserLinkedToAdmin()) {
$this->postInitSession();
$sessionId = $_COOKIE['sessionID'];
return true;
} else {
$this->raiseError('User must be OA installation admin');
return false;
}
} else {
$this->raiseError($strUsernameOrPasswordWrong);
return false;
}
} | CWE-384 | 1 |
public static function cat($vars) {
switch (SMART_URL) {
case true:
# code...
$url = Options::get('siteurl')."/".$vars."/".Typo::slugify(Categories::name($vars));
break;
default:
# code...
$url = Options::get('siteurl')."/index.php?cat={$vars}";
break;
}
return $url;
} | CWE-352 | 0 |
public function testPinCommentAction()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$this->assertAccessIsGranted($client, '/admin/project/1/details');
$form = $client->getCrawler()->filter('form[name=project_comment_form]')->form();
$client->submit($form, [
'project_comment_form' => [
'message' => 'Foo bar blub',
]
]);
$this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));
$client->followRedirect();
$node = $client->getCrawler()->filter('div.box#comments_box .direct-chat-text');
self::assertStringContainsString('Foo bar blub', $node->html());
$node = $client->getCrawler()->filter('div.box#comments_box .box-body a.btn.active');
self::assertEquals(0, $node->count());
$comments = $this->getEntityManager()->getRepository(ProjectComment::class)->findAll();
$id = $comments[0]->getId();
$this->request($client, '/admin/project/' . $id . '/comment_pin');
$this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));
$client->followRedirect();
$node = $client->getCrawler()->filter('div.box#comments_box .box-body a.btn.active');
self::assertEquals(1, $node->count());
self::assertEquals($this->createUrl('/admin/project/' . $id . '/comment_pin'), $node->attr('href'));
} | CWE-352 | 0 |
public function test_invite_set_password()
{
Notification::fake();
$user = $this->getViewer();
$inviteService = app(UserInviteService::class);
$inviteService->sendInvitation($user);
$token = DB::table('user_invites')->where('user_id', '=', $user->id)->first()->token;
$setPasswordPageResp = $this->get('/register/invite/' . $token);
$setPasswordPageResp->assertSuccessful();
$setPasswordPageResp->assertSee('Welcome to BookStack!');
$setPasswordPageResp->assertSee('Password');
$setPasswordPageResp->assertSee('Confirm Password');
$setPasswordResp = $this->followingRedirects()->post('/register/invite/' . $token, [
'password' => 'my test password',
]);
$setPasswordResp->assertSee('Password set, you now have access to BookStack!');
$newPasswordValid = auth()->validate([
'email' => $user->email,
'password' => 'my test password',
]);
$this->assertTrue($newPasswordValid);
$this->assertDatabaseMissing('user_invites', [
'user_id' => $user->id,
]);
} | CWE-352 | 0 |
function compression_test() {
?>
<script type="text/javascript">
var testCompression = {
get : function(test) {
var x;
if ( window.XMLHttpRequest ) {
x = new XMLHttpRequest();
} else {
try{x=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{x=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){};}
}
if (x) {
x.onreadystatechange = function() {
var r, h;
if ( x.readyState == 4 ) {
r = x.responseText.substr(0, 18);
h = x.getResponseHeader('Content-Encoding');
testCompression.check(r, h, test);
}
};
x.open('GET', ajaxurl + '?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true);
x.send('');
}
},
check : function(r, h, test) {
if ( ! r && ! test )
this.get(1);
if ( 1 == test ) {
if ( h && ( h.match(/deflate/i) || h.match(/gzip/i) ) )
this.get('no');
else
this.get(2);
return;
}
if ( 2 == test ) {
if ( '"wpCompressionTest' == r )
this.get('yes');
else
this.get('no');
}
}
};
testCompression.check();
</script>
<?php
} | CWE-352 | 0 |
function display_error_block() {
if (!empty($_SESSION['error_msg'])) {
echo '
<div>
<script type="text/javascript">
$(function() {
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( "#dialog-message" ).dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
});
</script>
<div id="dialog-message" title="">
<p>'. $_SESSION['error_msg'] .'</p>
</div>
</div>'."\n";
unset($_SESSION['error_msg']);
}
} | CWE-352 | 0 |
public function up(RuleGroup $ruleGroup)
{
$order = (int)$ruleGroup->order;
if ($order > 1) {
$newOrder = $order - 1;
$this->repository->setOrder($ruleGroup, $newOrder);
}
return redirect(route('rules.index'));
} | CWE-352 | 0 |
function csrf_check($fatal = true)
{
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
return true;
}
csrf_start();
$name = $GLOBALS['csrf']['input-name'];
$ok = false;
$tokens = '';
do {
if (!isset($_POST[$name])) {
break;
}
// we don't regenerate a token and check it because some token creation
// schemes are volatile.
$tokens = $_POST[$name];
if (!csrf_check_tokens($tokens)) {
break;
}
$ok = true;
} while (false);
if ($fatal && !$ok) {
$callback = $GLOBALS['csrf']['callback'];
if (trim($tokens, 'A..Za..z0..9:;,') !== '') {
$tokens = 'hidden';
}
$callback($tokens);
exit;
}
return $ok;
} | CWE-352 | 0 |
function verifyCSRFToken() {
$clean_referer = str_replace(array("http://","https://"),"//",$_SERVER["HTTP_REFERER"]);
$clean_domain = str_replace(array("http://","https://"),"//",DOMAIN);
$token = isset($_POST[$this->CSRFTokenField]) ? $_POST[$this->CSRFTokenField] : $_GET[$this->CSRFTokenField];
if (strpos($clean_referer, $clean_domain) === false || $token != $this->CSRFToken) {
$this->stop("Cross site request forgery detected.");
}
} | CWE-352 | 0 |
public function update(){
$login_user = $this->checkLogin();
$item_id = I("item_id/d");
$item_name = I("item_name");
$item_description = I("item_description");
$item_domain = I("item_domain");
$password = I("password");
$uid = $login_user['uid'] ;
if(!$this->checkItemManage($uid , $item_id)){
$this->sendError(10303);
return ;
}
if ($item_domain) {
if(!ctype_alnum($item_domain) || is_numeric($item_domain) ){
//echo '个性域名只能是字母或数字的组合';exit;
$this->sendError(10305);
return false;
}
$item = D("Item")->where("item_domain = '%s' and item_id !='%s' ",array($item_domain,$item_id))->find();
if ($item) {
//个性域名已经存在
$this->sendError(10304);
return false;
}
}
$save_data = array(
"item_name" => $item_name ,
"item_description" => $item_description ,
"item_domain" => $item_domain ,
"password" => $password ,
);
$items = D("Item")->where("item_id = '$item_id' ")->save($save_data);
$items = $items ? $items : array();
$this->sendResult($items);
} | CWE-352 | 0 |
function clean_input_value($value) {
if (is_string($value)) {
return descript($value);
}
if (is_array($value)) {
return array_map('descript', $value);
}
return '';
} | CWE-352 | 0 |
public function testDeleteCommentAction()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$this->assertAccessIsGranted($client, '/admin/customer/1/details');
$form = $client->getCrawler()->filter('form[name=customer_comment_form]')->form();
$client->submit($form, [
'customer_comment_form' => [
'message' => 'Blah foo bar',
]
]);
$this->assertIsRedirect($client, $this->createUrl('/admin/customer/1/details'));
$client->followRedirect();
$node = $client->getCrawler()->filter('div.box#comments_box .direct-chat-msg');
self::assertStringContainsString('Blah foo bar', $node->html());
$node = $client->getCrawler()->filter('div.box#comments_box .box-body a.confirmation-link');
self::assertStringEndsWith('/comment_delete', $node->attr('href'));
$comments = $this->getEntityManager()->getRepository(CustomerComment::class)->findAll();
$id = $comments[0]->getId();
$this->request($client, '/admin/customer/' . $id . '/comment_delete');
$this->assertIsRedirect($client, $this->createUrl('/admin/customer/1/details'));
$client->followRedirect();
$node = $client->getCrawler()->filter('div.box#comments_box .box-body');
self::assertStringContainsString('There were no comments posted yet', $node->html());
} | CWE-352 | 0 |
public function cloneGroup(TransactionGroup $group)
{
/** @var GroupCloneService $service */
$service = app(GroupCloneService::class);
$newGroup = $service->cloneGroup($group);
// event!
event(new StoredTransactionGroup($newGroup));
app('preferences')->mark();
$title = $newGroup->title ?? $newGroup->transactionJournals->first()->description;
$link = route('transactions.show', [$newGroup->id]);
session()->flash('success', trans('firefly.stored_journal', ['description' => $title]));
session()->flash('success_url', $link);
return redirect(route('transactions.show', [$newGroup->id]));
} | CWE-352 | 0 |
public function changePassword(){
$login_user = $this->checkLogin();
$this->checkAdmin();
$uid = I("uid/d");
$new_password = I("new_password");
$return = D("User")->updatePwd($uid, $new_password);
if (!$return) {
$this->sendError(10101);
}else{
$this->sendResult($return);
}
} | CWE-352 | 0 |
public function save(){
$login_user = $this->checkLogin();
$team_name = I("team_name");
$id = I("id/d");
if ($id) {
D("Team")->where(" id = '$id' ")->save(array("team_name"=>$team_name));
}else{
$data['username'] = $login_user['username'] ;
$data['uid'] = $login_user['uid'] ;
$data['team_name'] = $team_name ;
$data['addtime'] = time() ;
$id = D("Team")->add($data);
}
$return = D("Team")->where(" id = '$id' ")->find();
if (!$return) {
$return['error_code'] = 10103 ;
$return['error_message'] = 'request fail' ;
}
$this->sendResult($return);
} | CWE-352 | 0 |
public function loadUserByUsername($username)
{
return $this->inner->loadUserByUsername($username);
} | CWE-384 | 1 |
public function delete(AvailableBudget $availableBudget)
{
$this->abRepository->destroyAvailableBudget($availableBudget);
session()->flash('success', trans('firefly.deleted_ab'));
return redirect(route('budgets.index'));
} | CWE-352 | 0 |
public static function isHadSub($parent, $menuid =''){
$sql = sprintf("SELECT * FROM `menus` WHERE `parent` = '%s' %s", $parent, $where);
} | CWE-352 | 0 |
public function confirm(string $token)
{
try {
$userId = $this->emailConfirmationService->checkTokenAndGetUserId($token);
} catch (UserTokenNotFoundException $exception) {
$this->showErrorNotification(trans('errors.email_confirmation_invalid'));
return redirect('/register');
} catch (UserTokenExpiredException $exception) {
$user = $this->userRepo->getById($exception->userId);
$this->emailConfirmationService->sendConfirmation($user);
$this->showErrorNotification(trans('errors.email_confirmation_expired'));
return redirect('/register/confirm');
}
$user = $this->userRepo->getById($userId);
$user->email_confirmed = true;
$user->save();
$this->emailConfirmationService->deleteByUser($user);
$this->showSuccessNotification(trans('auth.email_confirm_success'));
$this->loginService->login($user, auth()->getDefaultDriver());
return redirect('/');
} | CWE-352 | 0 |
public function down(RuleGroup $ruleGroup)
{
$maxOrder = $this->repository->maxOrder();
$order = (int)$ruleGroup->order;
if ($order < $maxOrder) {
$newOrder = $order + 1;
$this->repository->setOrder($ruleGroup, $newOrder);
}
return redirect(route('rules.index'));
} | CWE-352 | 0 |
$logo = "<img src=\"".Options::get('siteurl').Options::get('logo')."\"
style=\"width: $width; height: $height; margin: 1px;\">";
}else{
$logo = "<span class=\"mg genixcms-logo\"></span>";
}
return $logo;
} | CWE-352 | 0 |
public function delete(){
$id = I("id/d")? I("id/d") : 0;
$login_user = $this->checkLogin();
if ($id && $login_user['uid']) {
$ret = D("Team")->where(" id = '$id' and uid = '$login_user[uid]'")->delete();
}
if ($ret) {
D("TeamItem")->where(" team_id = '$id' ")->delete();
D("TeamItemMember")->where(" team_id = '$id' ")->delete();
D("TeamMember")->where(" team_id = '$id' ")->delete();
$this->sendResult($ret);
}else{
$return['error_code'] = 10103 ;
$return['error_message'] = 'request fail' ;
$this->sendResult($return);
}
} | CWE-352 | 0 |
public function init()
{
if(!e_QUERY)
{
e107::getPlug()->clearCache();
}
if($this->getMode()=== 'avail')
{
$this->listQry = "SELECT * FROM `#plugin` WHERE plugin_installflag = 0 AND plugin_category != 'menu' ";
}
// Set drop-down values (if any).
} | CWE-352 | 0 |
function ttMitigateCSRF() {
// No need to do anything for get requests.
global $request;
if ($request->isGet())
return true;
$origin = $_SERVER['HTTP_ORIGIN'];
if ($origin) {
$pos = strpos($origin, '//');
$origin = substr($origin, $pos+2); // Strip protocol.
}
if (!$origin) {
// Try using referer.
$origin = $_SERVER['HTTP_REFERER'];
if ($origin) {
$pos = strpos($origin, '//');
$origin = substr($origin, $pos+2); // Strip protocol.
$pos = strpos($origin, '/');
$origin = substr($origin, 0, $pos); // Leave host only.
}
}
error_log("origin: ".$origin);
$target = defined('HTTP_TARGET') ? HTTP_TARGET : $_SERVER['HTTP_HOST'];
error_log("target: ".$target);
if (strcmp($origin, $target)) {
error_log("Potential cross site request forgery. Origin: '$origin' does not match target: '$target'.");
return false; // Origin and target do not match,
}
// TODO: review and improve this function for custom ports.
return true;
} | CWE-352 | 0 |
public function refreshUser(UserInterface $user)
{
$user = $this->inner->refreshUser($user);
$alterUser = \Closure::bind(function (InMemoryUser $user) { $user->password = 'foo'; }, null, class_exists(User::class) ? User::class : InMemoryUser::class);
$alterUser($user);
return $user;
} | CWE-384 | 1 |
\CsrfMagic\Csrf::$callback = function ($tokens) {
throw new \App\Exceptions\AppException('Invalid request - Response For Illegal Access', 403);
}; | CWE-352 | 0 |
public static function simple($input)
{
return empty($str) ? '' : pts_strings::keep_in_string($input, pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DASH | pts_strings::CHAR_DECIMAL | pts_strings::CHAR_SPACE | pts_strings::CHAR_UNDERSCORE | pts_strings::CHAR_COMMA | pts_strings::CHAR_AT | pts_strings::CHAR_COLON);
} | CWE-352 | 0 |
public function deleteByName(){
$item_id = I("item_id/d");
$env_id = I("env_id/d");
$var_name = I("var_name");
$login_user = $this->checkLogin();
$uid = $login_user['uid'] ;
if(!$this->checkItemEdit($uid , $item_id)){
$this->sendError(10303);
return ;
}
$ret = D("ItemVariable")->where(" item_id = '%d' and env_id = '%d' and var_name = '%s' ",array($item_id,$env_id,$var_name))->delete();
if ($ret) {
$this->sendResult($ret);
}else{
$this->sendError(10101);
}
} | CWE-352 | 0 |
public function test_create_nonce_url() {
$url = yourls_nonce_url( rand_str(), rand_str(), rand_str(), rand_str() );
$this->assertTrue( is_string($url) );
// $this->assertIsString($url);
} | CWE-352 | 0 |
public function AdminObserver()
{
if($this->getPosted('go_back'))
{
$this->redirect('list', 'main', true);
}
$userid = $this->getId();
$sql = e107::getDb();
$user = e107::getUser();
$sysuser = e107::getSystemUser($userid, false);
$admin_log = e107::getAdminLog();
$mes = e107::getMessage();
if(!$user->checkAdminPerms('3'))
{
// TODO lan
$mes->addError("You don't have enough permissions to do this.", 'default', true);
// TODO lan
$lan = 'Security violation (not enough permissions) - Administrator --ADMIN_UID-- (--ADMIN_NAME--, --ADMIN_EMAIL--) tried to make --UID-- (--NAME--, --EMAIL--) system admin';
$search = array('--UID--', '--NAME--', '--EMAIL--', '--ADMIN_UID--', '--ADMIN_NAME--', '--ADMIN_EMAIL--');
$replace = array($sysuser->getId(), $sysuser->getName(), $sysuser->getValue('email'), $user->getId(), $user->getName(), $user->getValue('email'));
e107::getLog()->add('USET_08', str_replace($search, $replace, $lan), E_LOG_INFORMATIVE);
$this->redirect('list', 'main', true);
}
if(!$sysuser->getId())
{
// TODO lan
$mes->addError("User not found.", 'default', true);
$this->redirect('list', 'main', true);
}
if(!$sysuser->isAdmin())
{
$sysuser->set('user_admin', 1)->save(); //"user","user_admin='1' WHERE user_id={$userid}"
$lan = str_replace(array('--UID--', '--NAME--', '--EMAIL--'), array($sysuser->getId(), $sysuser->getName(), $sysuser->getValue('email')), USRLAN_164);
e107::getLog()->add('USET_08', $lan, E_LOG_INFORMATIVE);
$mes->addSuccess($lan);
}
if($this->getPosted('update_admin')) e107::getUserPerms()->updatePerms($userid, $_POST['perms']);
}
| CWE-352 | 0 |
public function handle(Request $request, Closure $next, int $keyType)
{
if (is_null($request->bearerToken()) && is_null($request->user())) {
throw new HttpException(401, null, null, ['WWW-Authenticate' => 'Bearer']);
}
// This is a request coming through using cookies, we have an authenticated user
// not using an API key. Make some fake API key models and continue on through
// the process.
if ($request->user() instanceof User) {
$model = (new ApiKey())->forceFill([
'user_id' => $request->user()->id,
'key_type' => ApiKey::TYPE_ACCOUNT,
]);
} else {
$model = $this->authenticateApiKey($request->bearerToken(), $keyType);
$this->auth->guard()->loginUsingId($model->user_id);
}
$request->attributes->set('api_key', $model);
return $next($request);
} | CWE-352 | 0 |
public function __construct()
{
parent::__construct();
// for flash data
$this->load->library('session');
if (!$this->fuel->config('admin_enabled')) show_404();
$this->load->vars(array(
'js' => '',
'css' => css($this->fuel->config('xtra_css')), // use CSS function here because of the asset library path changes below
'js_controller_params' => array(),
'keyboard_shortcuts' => $this->fuel->config('keyboard_shortcuts')));
// change assets path to admin
$this->asset->assets_path = $this->fuel->config('fuel_assets_path');
// set asset output settings
$this->asset->assets_output = $this->fuel->config('fuel_assets_output');
$this->lang->load('fuel');
$this->load->helper('ajax');
$this->load->library('form_builder');
$this->load->module_model(FUEL_FOLDER, 'fuel_users_model');
// set configuration paths for assets in case they are different from front end
$this->asset->assets_module ='fuel';
$this->asset->assets_folders = array(
'images' => 'images/',
'css' => 'css/',
'js' => 'js/',
);
} | CWE-352 | 0 |
public function notify_edge_mode() {
w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php');
w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/admin_ui.php');
$message = sprintf(__('<p>You can now keep W3 Total Cache up-to-date without having to worry about new features breaking your website. There will be more releases with bug fixes, security fixes and settings updates. </p>
<p>Also, you can now try out our new features as soon as they\'re ready. %s to enable "edge mode" and unlock pre-release features. %s</p>', 'w3-total-cache')
,'<a href="' . w3_admin_url('admin.php?page='. $this->_page .'&w3tc_edge_mode_enable').'" class="button">' . __('Click Here', 'w3-total-cache') . '</a>'
, w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'edge_mode', '', true,'','w3tc_default_hide_note_custom')
);
w3_e_notification_box($message, 'edge-mode');
} | CWE-352 | 0 |
public function update(CurrencyFormRequest $request, TransactionCurrency $currency)
{
/** @var User $user */
$user = auth()->user();
$data = $request->getCurrencyData();
if (false === $data['enabled'] && $this->repository->currencyInUse($currency)) {
$data['enabled'] = true;
}
if (!$this->userRepository->hasRole($user, 'owner')) {
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
Log::channel('audit')->info('Tried to update (POST) currency without admin rights.', $data);
return redirect(route('currencies.index'));
}
$currency = $this->repository->update($currency, $data);
Log::channel('audit')->info('Updated (POST) currency.', $data);
$request->session()->flash('success', (string) trans('firefly.updated_currency', ['name' => $currency->name]));
app('preferences')->mark();
if (1 === (int) $request->get('return_to_edit')) {
$request->session()->put('currencies.edit.fromUpdate', true);
return redirect(route('currencies.edit', [$currency->id]));
}
return redirect($this->getPreviousUri('currencies.edit.uri'));
} | CWE-352 | 0 |
public function addCC($address, $name = '')
{
return $this->addAnAddress('cc', $address, $name);
} | CWE-352 | 0 |
protected function _validateSecretKey()
{
if (is_array($this->_publicActions) && in_array($this->getRequest()->getActionName(), $this->_publicActions)) {
return true;
}
if (!($secretKey = $this->getRequest()->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME, null))
|| $secretKey != Mage::getSingleton('adminhtml/url')->getSecretKey()) {
return false;
}
return true;
} | CWE-352 | 0 |
$values = [READ => __('Read'),
CREATE => __('Create'), | CWE-352 | 0 |
$ret = array_merge($ret, csrf_flattenpost2(1, $n, $v));
} | CWE-352 | 0 |
foreach ($data['alertred'] as $alert) {
# code...
echo "<li>$alert</li>\n";
} | CWE-352 | 0 |
public function deleteItem(){
$login_user = $this->checkLogin();
$this->checkAdmin();
$item_id = I("item_id/d");
$return = D("Item")->soft_delete_item($item_id);
if (!$return) {
$this->sendError(10101);
}else{
$this->sendResult($return);
}
} | CWE-352 | 0 |
function showAddBypassForm() {
$output = $this->pageContext->getOutput();
$request = $this->pageContext->getRequest();
$output->addHTML(
new OOUI\FormLayout([
'action' => SpecialPage::getTitleFor('ConfirmAccounts', wfMessage('scratch-confirmaccount-requirements-bypasses-url')->text())->getFullURL(),
'method' => 'post',
'items' => [
new OOUI\ActionFieldLayout(
new OOUI\TextInputWidget( [
'name' => 'bypassAddUsername',
'required' => true,
'value' => $request->getText('username')
] ),
new OOUI\ButtonInputWidget([
'type' => 'submit',
'flags' => ['primary', 'progressive'],
'label' => wfMessage('scratch-confirmaccount-requirements-bypasses-add')->parse()
])
)
],
])
);
}
| CWE-352 | 0 |
protected function addAnAddress($kind, $address, $name = '')
{
if (!preg_match('/^(to|cc|bcc|Reply-To)$/', $kind)) {
$this->setError($this->lang('Invalid recipient array') . ': ' . $kind);
$this->edebug($this->lang('Invalid recipient array') . ': ' . $kind);
if ($this->exceptions) {
throw new phpmailerException('Invalid recipient array: ' . $kind);
}
return false;
}
$address = trim($address);
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
if (!$this->validateAddress($address)) {
$this->setError($this->lang('invalid_address') . ': ' . $address);
$this->edebug($this->lang('invalid_address') . ': ' . $address);
if ($this->exceptions) {
throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
}
return false;
}
if ($kind != 'Reply-To') {
if (!isset($this->all_recipients[strtolower($address)])) {
array_push($this->$kind, array($address, $name));
$this->all_recipients[strtolower($address)] = true;
return true;
}
} else {
if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
$this->ReplyTo[strtolower($address)] = array($address, $name);
return true;
}
}
return false;
} | CWE-352 | 0 |
End of preview. Expand
in Dataset Viewer.
README.md exists but content is empty.
Use the Edit dataset card button to edit it.
- Downloads last month
- 45