code
stringlengths 12
2.05k
| label_name
stringlengths 6
8
| label
int64 0
95
|
---|---|---|
private function getTaskLink()
{
$link = $this->taskLinkModel->getById($this->request->getIntegerParam('link_id'));
if (empty($link)) {
throw new PageNotFoundException();
}
return $link;
} | CWE-639 | 9 |
$cLoc = serialize(expCore::makeLocation('container','@section' . $page->id));
$ret .= scan_container($cLoc, $page->id);
$ret .= scan_page($page->id);
}
| CWE-89 | 0 |
protected function getParentNotExistsService()
{
return $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists();
} | CWE-89 | 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-89 | 0 |
public static function login() {
user::login(expString::sanitize($_POST['username']),expString::sanitize($_POST['password']));
if (!isset($_SESSION[SYS_SESSION_KEY]['user'])) { // didn't successfully log in
flash('error', gt('Invalid Username / Password'));
if (expSession::is_set('redirecturl_error')) {
$url = expSession::get('redirecturl_error');
expSession::un_set('redirecturl_error');
header("Location: ".$url);
} else {
expHistory::back();
}
} else { // we're logged in
global $user;
if (expSession::get('customer-login')) expSession::un_set('customer-login');
if (!empty($_POST['username'])) flash('message', gt('Welcome back').' '.expString::sanitize($_POST['username']));
if ($user->isAdmin()) {
expHistory::back();
} else {
foreach ($user->groups as $g) {
if (!empty($g->redirect)) {
$url = URL_FULL.$g->redirect;
break;
}
}
if (isset($url)) {
header("Location: ".$url);
} else {
expHistory::back();
}
}
}
} | CWE-89 | 0 |
static function is_username($username, &$error='') {
if (strlen($username)<2)
$error = __('Username must have at least two (2) characters');
elseif (!preg_match('/^[\p{L}\d._-]+$/u', $username))
$error = __('Username contains invalid characters');
return $error == '';
} | CWE-89 | 0 |
public function confirm()
{
$task = $this->getTask();
$link_id = $this->request->getIntegerParam('link_id');
$link = $this->taskExternalLinkModel->getById($link_id);
if (empty($link)) {
throw new PageNotFoundException();
}
$this->response->html($this->template->render('task_external_link/remove', array(
'link' => $link,
'task' => $task,
)));
} | CWE-639 | 9 |
} elseif ($type == 'customlayout') {
$layoutData = unserialize($data['name']);
$className = $layoutData['className'];
$layoutName = $layoutData['name'];
if ($item['name'] == $layoutName && $item['className'] == $className) {
$class = DataObject\ClassDefinition::getByName($className);
if (!$class) {
throw new \Exception('Class does not exist');
}
$classId = $class->getId();
$layoutList = new DataObject\ClassDefinition\CustomLayout\Listing();
$db = \Pimcore\Db::get();
$layoutList->setCondition('name = ' . $db->quote($layoutName) . ' AND classId = ' . $classId);
$layoutList = $layoutList->load();
$layoutDefinition = null;
if ($layoutList) {
$layoutDefinition = $layoutList[0];
}
if (!$layoutDefinition) {
$layoutDefinition = new DataObject\ClassDefinition\CustomLayout();
$layoutDefinition->setName($layoutName);
$layoutDefinition->setClassId($classId);
}
try {
$layoutDefinition->setDescription($item['description']);
$layoutDef = DataObject\ClassDefinition\Service::generateLayoutTreeFromArray($item['layoutDefinitions'], true);
$layoutDefinition->setLayoutDefinitions($layoutDef);
$layoutDefinition->save();
} catch (\Exception $e) {
Logger::error($e->getMessage());
return $this->adminJson(['success' => false, 'message' => $e->getMessage()]);
}
}
}
}
return $this->adminJson(['success' => true]);
} | CWE-502 | 15 |
public function validateReference()
{
$docElem = $this->sigNode->ownerDocument->documentElement;
if (! $docElem->isSameNode($this->sigNode)) {
if ($this->sigNode->parentNode != null) {
$this->sigNode->parentNode->removeChild($this->sigNode);
}
}
$xpath = $this->getXPathObj();
$query = "./secdsig:SignedInfo/secdsig:Reference";
$nodeset = $xpath->query($query, $this->sigNode);
if ($nodeset->length == 0) {
throw new Exception("Reference nodes not found");
}
/* Initialize/reset the list of validated nodes. */
$this->validatedNodes = array();
foreach ($nodeset AS $refNode) {
if (! $this->processRefNode($refNode)) {
/* Clear the list of validated nodes. */
$this->validatedNodes = null;
throw new Exception("Reference validation failed");
}
}
return true;
} | CWE-347 | 25 |
foreach($image->expTag as $tag) {
if (isset($used_tags[$tag->id])) {
$used_tags[$tag->id]->count++;
} else {
$exptag = new expTag($tag->id);
$used_tags[$tag->id] = $exptag;
$used_tags[$tag->id]->count = 1;
}
} | CWE-89 | 0 |
function &getAll(&$dbh, $proposalId)
{
$sql = "SELECT *, UNIX_TIMESTAMP(timestamp) AS timestamp FROM package_proposal_votes WHERE pkg_prop_id = ". $dbh->quoteSmart($proposalId) ." ORDER BY timestamp ASC";
$res = $dbh->query($sql);
if (DB::isError($res)) {
return $res;
}
$votes = array();
while ($set = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
$set['reviews'] = unserialize($set['reviews']);
$votes[$set['user_handle']] = new ppVote($set);
}
return $votes;
} | CWE-640 | 20 |
private function filterScheme($scheme)
{
$scheme = strtolower($scheme);
$scheme = rtrim($scheme, ':/');
return $scheme;
} | CWE-89 | 0 |
$masteroption->delete();
}
// delete the mastergroup
$db->delete('optiongroup', 'optiongroup_master_id='.$mastergroup->id);
$mastergroup->delete();
expHistory::back();
} | CWE-89 | 0 |
public function show()
{
$task = $this->getTask();
$subtask = $this->getSubtask();
$this->response->html($this->template->render('subtask_restriction/show', array(
'status_list' => array(
SubtaskModel::STATUS_TODO => t('Todo'),
SubtaskModel::STATUS_DONE => t('Done'),
),
'subtask_inprogress' => $this->subtaskStatusModel->getSubtaskInProgress($this->userSession->getId()),
'subtask' => $subtask,
'task' => $task,
)));
} | CWE-639 | 9 |
public function pending() {
// global $db;
// make sure we have what we need.
if (empty($this->params['id'])) expQueue::flashAndFlow('error', gt('Your subscriber ID was not supplied.'));
// find the subscriber and their pending subscriptions
$ealerts = expeAlerts::getPendingBySubscriber($this->params['id']);
$subscriber = new subscribers($this->params['id']);
// render the template
assign_to_template(array(
'subscriber'=>$subscriber,
'ealerts'=>$ealerts
));
} | CWE-89 | 0 |
$f = function (\Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition $v = null) { return $v; }; return $f(${($_ = isset($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition']) ? $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition'] : ($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition())) && false ?: '_'}); | CWE-89 | 0 |
public function testCompletePurchaseHttpOptions()
{
$this->setMockHttpResponse('ExpressPurchaseSuccess.txt');
$this->getHttpRequest()->query->replace(array(
'token' => 'GET_TOKEN',
'PayerID' => 'GET_PAYERID',
));
$response = $this->gateway->completePurchase(array(
'amount' => '10.00',
'currency' => 'BYR'
))->send();
$httpRequests = $this->getMockedRequests();
$httpRequest = $httpRequests[0];
$queryArguments = $httpRequest->getQuery()->toArray();
$this->assertSame('GET_TOKEN', $queryArguments['TOKEN']);
$this->assertSame('GET_PAYERID', $queryArguments['PAYERID']);
} | CWE-89 | 0 |
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$category = $this->getCategory();
if ($this->categoryModel->remove($category['id'])) {
$this->flash->success(t('Category removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this category.'));
}
$this->response->redirect($this->helper->url->to('CategoryController', 'index', array('project_id' => $project['id'])));
} | CWE-639 | 9 |
public function pluginDetails()
{
return [
'name' => 'Debugbar',
'description' => 'Debugbar integration for OctoberCMS.',
'author' => 'RainLab',
'icon' => 'icon-cog',
'homepage' => 'https://github.com/rainlab/debugbar-plugin'
];
} | CWE-532 | 28 |
public static function _date2timestamp( $datetime, $wtz=null ) {
if( !isset( $datetime['hour'] )) $datetime['hour'] = 0;
if( !isset( $datetime['min'] )) $datetime['min'] = 0;
if( !isset( $datetime['sec'] )) $datetime['sec'] = 0;
if( empty( $wtz ) && ( !isset( $datetime['tz'] ) || empty( $datetime['tz'] )))
return mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year'] );
$output = $offset = 0;
if( empty( $wtz )) {
if( iCalUtilityFunctions::_isOffset( $datetime['tz'] )) {
$offset = iCalUtilityFunctions::_tz2offset( $datetime['tz'] ) * -1;
$wtz = 'UTC';
}
else
$wtz = $datetime['tz'];
}
if(( 'Z' == $wtz ) || ( 'GMT' == strtoupper( $wtz )))
$wtz = 'UTC';
try {
$strdate = sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['min'], $datetime['sec'] );
$d = new DateTime( $strdate, new DateTimeZone( $wtz ));
if( 0 != $offset ) // adjust for offset
$d->modify( $offset.' seconds' );
$output = $d->format( 'U' );
unset( $d );
}
catch( Exception $e ) {
$output = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year'] );
}
return $output;
}
| CWE-89 | 0 |
protected function putFileInStorage(UploadedFile $uploadedFile)
{
$attachmentData = file_get_contents($uploadedFile->getRealPath());
$storage = $this->getStorage();
$basePath = 'uploads/files/' . date('Y-m-M') . '/';
$uploadFileName = Str::random(16) . '.' . $uploadedFile->getClientOriginalExtension();
while ($storage->exists($basePath . $uploadFileName)) {
$uploadFileName = Str::random(3) . $uploadFileName;
}
$attachmentPath = $basePath . $uploadFileName;
try {
$storage->put($attachmentPath, $attachmentData);
} catch (Exception $e) {
Log::error('Error when attempting file upload:' . $e->getMessage());
throw new FileUploadException(trans('errors.path_not_writable', ['filePath' => $attachmentPath]));
}
return $attachmentPath;
} | CWE-22 | 2 |
public function actionView($id){
// add media object to user's recent item list
User::addRecentItem('m', $id, Yii::app()->user->getId());
$this->render('view', array(
'model' => $this->loadModel($id),
));
} | CWE-79 | 1 |
public function getMovieData($id){
$getMovie = $this->getMovie($id);
$getCast = $this->getCast($id);
$getImage = $this->getImage($id);
$data = array_merge($getMovie, $getCast);
$data = array_merge($data, $getImage);
return $data;
}
| CWE-89 | 0 |
function db_case($array)
{
global $DatabaseType;
$counter = 0;
if ($DatabaseType == 'mysqli') {
$array_count = count($array);
$string = " CASE WHEN $array[0] =";
$counter++;
$arr_count = count($array);
for ($i = 1; $i < $arr_count; $i++) {
$value = $array[$i];
if ($value == "''" && substr($string, -1) == '=') {
$value = ' IS NULL';
$string = substr($string, 0, -1);
}
$string .= "$value";
if ($counter == ($array_count - 2) && $array_count % 2 == 0)
$string .= " ELSE ";
elseif ($counter == ($array_count - 1))
$string .= " END ";
elseif ($counter % 2 == 0)
$string .= " WHEN $array[0]=";
elseif ($counter % 2 == 1)
$string .= " THEN ";
$counter++;
}
}
return $string;
} | CWE-79 | 1 |
public function activate_address()
{
global $db, $user;
$object = new stdClass();
$object->id = $this->params['id'];
$db->setUniqueFlag($object, 'addresses', $this->params['is_what'], "user_id=" . $user->id);
flash("message", gt("Successfully updated address."));
expHistory::back();
} | CWE-89 | 0 |
public function setHomePage()
{
if (!$this->request->is('post')) {
throw new MethodNotAllowedException(__('This endpoint only aaccepts POST requests.'));
}
if (empty($this->request->data['path'])) {
$this->request->data = array('path' => $this->request->data);
}
if (empty($this->request->data['path'])) {
throw new InvalidArgumentException(__('No path POSTed.'));
}
$setting = array(
'UserSetting' => array(
'user_id' => $this->Auth->user('id'),
'setting' => 'homepage',
'value' => json_encode(array('path' => $this->request->data['path']))
)
);
$result = $this->UserSetting->setSetting($this->Auth->user(), $setting);
return $this->RestResponse->saveSuccessResponse('UserSettings', 'setHomePage', false, $this->response->type(), 'Homepage set to ' . $this->request->data['path']);
} | CWE-79 | 1 |
public function testGetDropdownConnect($params, $expected, $session_params = []) {
$this->login();
$bkp_params = [];
//set session params if any
if (count($session_params)) {
foreach ($session_params as $param => $value) {
if (isset($_SESSION[$param])) {
$bkp_params[$param] = $_SESSION[$param];
}
$_SESSION[$param] = $value;
}
}
$params['_idor_token'] = \Session::getNewIDORToken($params['itemtype'] ?? '');
$result = \Dropdown::getDropdownConnect($params, false);
//reset session params before executing test
if (count($session_params)) {
foreach ($session_params as $param => $value) {
if (isset($bkp_params[$param])) {
$_SESSION[$param] = $bkp_params[$param];
} else {
unset($_SESSION[$param]);
}
}
}
$this->array($result)->isIdenticalTo($expected);
} | CWE-639 | 9 |
function setup()
{
$this -> catch_globals();
$this -> version['prior'] = '01';
$this -> version['minor'] = '06';
$this -> version['fix'] = '01';
$this -> version_text = $this -> version['prior'];
$this -> version_text .= '.';
$this -> version_text .= $this -> version['minor'];
$this -> version_text .= '.';
$this -> version_text .= $this -> version['fix'];
//manipulate some actions if user chose updat
if ($this -> globals['mode'] == 'update') {
//seperate update finish screen
if ($this -> globals['action'] == 'enter_email') $this -> globals['action'] = 'screen_execute_update_and_finish';
}
} | CWE-89 | 0 |
public static function checkIp6($requestIp, $ip)
{
if (!((extension_loaded('sockets') && defined('AF_INET6')) || @inet_pton('::1'))) {
throw new \RuntimeException('Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6".');
}
if (false !== strpos($ip, '/')) {
list($address, $netmask) = explode('/', $ip, 2);
if ($netmask < 1 || $netmask > 128) {
return false;
}
} else {
$address = $ip;
$netmask = 128;
}
$bytesAddr = unpack('n*', inet_pton($address));
$bytesTest = unpack('n*', inet_pton($requestIp));
for ($i = 1, $ceil = ceil($netmask / 16); $i <= $ceil; ++$i) {
$left = $netmask - 16 * ($i - 1);
$left = ($left <= 16) ? $left : 16;
$mask = ~(0xffff >> $left) & 0xffff;
if (($bytesAddr[$i] & $mask) != ($bytesTest[$i] & $mask)) {
return false;
}
}
return true;
} | CWE-89 | 0 |
public static function name($id) {
$id = sprintf('%d', $id);
if(isset($id)){
$cat = Db::result("SELECT `name` FROM `cat`
WHERE `id` = '{$id}' LIMIT 1");
//print_r($cat);
if(isset($cat['error'])){
return '';
}else{
return $cat[0]->name;
}
}else{
echo "No ID Selected";
}
//print_r($cat);
}
| CWE-89 | 0 |
function read_cache( $cache_id, $check = false ) {
global $cms_db;
if ( $cache_id && $this->use_cache ) {
if ( !$this->cache_db ) $this->cache_db = new DB_cms;
$return = false;
$sql = "SELECT val FROM
" . $cms_db['db_cache'] . " WHERE
name = '" . $this->cache_name . "'
AND
sid = '" . $cache_id . "'";
if ( !$this->cache_db->query( $sql ) ) return;
$oldmode = $this->cache_db->get_fetch_mode();
$this->cache_db->set_fetch_mode( 'DB_FETCH_ASSOC' );
if( $this->cache_db->next_record() ) {
if ( $check ) {
$return = true;
} else {
$cache_pre = $this->cache_db->this_record();
$cache_val = $cache_pre['val'];
$cache = unserialize( stripslashes( $cache_val ) );
if ( is_array( $cache ) ) {
$this->cache = $cache;
$return = true;
}
}
}
$this->cache_db->set_fetch_mode( $oldmode );
return $return;
} else $this->cache_mode = '';
} | CWE-89 | 0 |
$t = preg_split('/[ \t]/', trim($enclosure[2]) );
$type = $t[0];
/**
* Filters the RSS enclosure HTML link tag for the current post.
*
* @since 2.2.0
*
* @param string $html_link_tag The HTML link tag with a URI and other attributes.
*/
echo apply_filters( 'rss_enclosure', '<enclosure url="' . trim( htmlspecialchars( $enclosure[0] ) ) . '" length="' . trim( $enclosure[1] ) . '" type="' . $type . '" />' . "\n" );
}
}
} | CWE-79 | 1 |
public function save()
{
global $DB;
if(!empty($this->id))
return $this->update();
else
return $this->insert();
}
| CWE-79 | 1 |
private function getCategory()
{
$category = $this->categoryModel->getById($this->request->getIntegerParam('category_id'));
if (empty($category)) {
throw new PageNotFoundException();
}
return $category;
} | CWE-639 | 9 |
public function setPassword($newPassword, $doHashing = true)
{
global $gSettingsManager, $gPasswordHashAlgorithm, $gChangeNotification;
if (!$doHashing) {
if (is_object($gChangeNotification)) {
$gChangeNotification->logUserChange(
(int) $this->getValue('usr_id'),
'usr_password',
$this->getValue('usr_password'),
$newPassword,
$this
);
}
return parent::setValue('usr_password', $newPassword, false);
}
// get the saved cost value that fits your server performance best and rehash your password
$options = array('cost' => 10);
if (isset($gSettingsManager) && $gSettingsManager->has('system_hashing_cost')) {
$options['cost'] = $gSettingsManager->getInt('system_hashing_cost');
}
$newPasswordHash = PasswordUtils::hash($newPassword, $gPasswordHashAlgorithm, $options);
if ($newPasswordHash === false) {
return false;
}
if (is_object($gChangeNotification)) {
$gChangeNotification->logUserChange(
(int) $this->getValue('usr_id'),
'usr_password',
$this->getValue('usr_password'),
$newPasswordHash,
$this
);
}
return parent::setValue('usr_password', $newPasswordHash, false);
} | CWE-613 | 7 |
public static function verify($gresponse) {
new Xaptcha();
$recaptcha = new \ReCaptcha\ReCaptcha(self::$secret);
$resp = $recaptcha->verify($gresponse, $_SERVER['REMOTE_ADDR']);
if ($resp->isSuccess()) {
return true;
}else{
return false;
}
}
| CWE-89 | 0 |
$db->insertObject($obj, 'expeAlerts_subscribers');
}
$count = count($this->params['ealerts']);
if ($count > 0) {
flash('message', gt("Your subscriptions have been updated. You are now subscriber to")." ".$count.' '.gt('E-Alerts.'));
} else {
flash('error', gt("You have been unsubscribed from all E-Alerts."));
}
expHistory::back();
} | CWE-89 | 0 |
public function remove()
{
$project = $this->getProject();
$this->checkCSRFParam();
$column_id = $this->request->getIntegerParam('column_id');
if ($this->columnModel->remove($column_id)) {
$this->flash->success(t('Column removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this column.'));
}
$this->response->redirect($this->helper->url->to('ColumnController', 'index', array('project_id' => $project['id'])));
} | CWE-639 | 9 |
public function pending() {
// global $db;
// make sure we have what we need.
if (empty($this->params['id'])) expQueue::flashAndFlow('error', gt('Your subscriber ID was not supplied.'));
// find the subscriber and their pending subscriptions
$ealerts = expeAlerts::getPendingBySubscriber($this->params['id']);
$subscriber = new subscribers($this->params['id']);
// render the template
assign_to_template(array(
'subscriber'=>$subscriber,
'ealerts'=>$ealerts
));
} | CWE-89 | 0 |
public function confirm()
{
$project = $this->getProject();
$this->response->html($this->helper->layout->project('action/remove', array(
'action' => $this->actionModel->getById($this->request->getIntegerParam('action_id')),
'available_events' => $this->eventManager->getAll(),
'available_actions' => $this->actionManager->getAvailableActions(),
'project' => $project,
'title' => t('Remove an action')
)));
} | CWE-639 | 9 |
$navs[$i]->link = expCore::makeLink(array('section' => $navs[$i]->id), '', $navs[$i]->sef_name);
if (!$view) {
// unset($navs[$i]); //FIXME this breaks jstree if we remove a parent and not the child
$attr = new stdClass();
$attr->class = 'hidden'; // bs3 class to hide elements
$navs[$i]->li_attr = $attr;
}
}
| CWE-89 | 0 |
public function update()
{
$project = $this->getProject();
$tag_id = $this->request->getIntegerParam('tag_id');
$tag = $this->tagModel->getById($tag_id);
$values = $this->request->getValues();
list($valid, $errors) = $this->tagValidator->validateModification($values);
if ($tag['project_id'] != $project['id']) {
throw new AccessForbiddenException();
}
if ($valid) {
if ($this->tagModel->update($values['id'], $values['name'])) {
$this->flash->success(t('Tag updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this tag.'));
}
$this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id'])));
} else {
$this->edit($values, $errors);
}
} | CWE-639 | 9 |
public function manage_versions() {
expHistory::set('manageable', $this->params);
$hv = new help_version();
$current_version = $hv->find('first', 'is_current=1');
$sql = 'SELECT hv.*, COUNT(h.title) AS num_docs FROM '.DB_TABLE_PREFIX.'_help h ';
$sql .= 'RIGHT JOIN '.DB_TABLE_PREFIX.'_help_version hv ON h.help_version_id=hv.id GROUP BY hv.version';
$page = new expPaginator(array(
'sql'=>$sql,
'limit'=>30,
'order' => (isset($this->params['order']) ? $this->params['order'] : 'version'),
'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'DESC'),
'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),
'controller'=>$this->baseclassname,
'action'=>$this->params['action'],
'src'=>$this->loc->src,
'columns'=>array(
gt('Version')=>'version',
gt('Title')=>'title',
gt('Current')=>'is_current',
gt('# of Docs')=>'num_docs'
),
));
assign_to_template(array(
'current_version'=>$current_version,
'page'=>$page
));
} | CWE-89 | 0 |
}elseif($p->group == 4){
$grp = GENERAL_MEMBER;
}
| CWE-89 | 0 |
public static function canImportData() {
return true;
}
| CWE-89 | 0 |
$cLoc = serialize(expCore::makeLocation('container','@section' . $page->id));
$ret .= scan_container($cLoc, $page->id);
$ret .= scan_page($page->id);
}
| CWE-89 | 0 |
public function backup($type='json')
{
global $DB;
global $website;
$out = array();
$DB->query('
SELECT * FROM nv_notes
WHERE website = '.protect($website->id),
'object'
);
$out = $DB->result();
if($type='json')
$out = json_encode($out);
return $out;
}
| CWE-89 | 0 |
function update() {
parent::update();
expSession::clearAllUsersSessionCache('navigation');
}
| CWE-89 | 0 |
function updateCommandCategorieInDB(){
global $pearDB;
$DBRESULT = $pearDB->query("UPDATE `command_categories` SET `category_name` = '".$_POST["category_name"]."' , `category_alias` = '".$_POST["category_alias"]."' , `category_order` = '".$_POST["category_order"]."' WHERE `cmd_category_id` = '".$_POST["cmd_category_id"]."'");
} | CWE-89 | 0 |
function send_feedback() {
$success = false;
if (isset($this->params['id'])) {
$ed = new eventdate($this->params['id']);
// $email_addrs = array();
if ($ed->event->feedback_email != '') {
$msgtemplate = expTemplate::get_template_for_action($this, 'email/_' . $this->params['formname'], $this->loc);
$msgtemplate->assign('params', $this->params);
$msgtemplate->assign('event', $ed);
$email_addrs = explode(',', $ed->event->feedback_email);
//This is an easy way to remove duplicates
$email_addrs = array_flip(array_flip($email_addrs));
$email_addrs = array_map('trim', $email_addrs);
$mail = new expMail();
$success += $mail->quickSend(array(
"text_message" => $msgtemplate->render(),
'to' => $email_addrs,
'from' => !empty($this->params['email']) ? $this->params['email'] : trim(SMTP_FROMADDRESS),
'subject' => $this->params['subject'],
));
}
}
if ($success) {
flashAndFlow('message', gt('Your feedback was successfully sent.'));
} else {
flashAndFlow('error', gt('We could not send your feedback. Please contact your administrator.'));
}
}
| CWE-89 | 0 |
function core_load_function($fid)
{
global $DB;
global $menu_layout;
// check if fid is an internal function
// or we need to retrieve its information from the database
switch($fid)
{
case 'utils':
$func = new stdClass();
$func->id = 'utils';
$func->codename = 'utils';
$func->category = 'internal';
$func->icon = '';
$func->lid = '';
$func->enabled = 1;
break;
case 'grid_notes':
$func = new stdClass();
$func->id = 'grid_notes';
$func->codename = 'grid_notes';
$func->category = 'content';
$func->icon = '';
$func->lid = '';
$func->enabled = 1;
break;
case 'permissions':
$func = new stdClass();
$func->id = 'permissions';
$func->codename = 'permissions';
$func->category = 'config';
$func->icon = '';
$func->lid = '';
$func->enabled = 1;
break;
default:
if(is_numeric($fid))
$where = 'id = '.intval($fid);
else
$where = 'codename = '.protect($fid);
$DB->query('SELECT *
FROM nv_functions
WHERE '.$where.'
AND enabled = 1');
$func = $DB->first();
if(!$menu_layout->function_is_displayed($func->id))
$func = false;
}
return $func;
}
| CWE-89 | 0 |
function edit_optiongroup_master() {
expHistory::set('editable', $this->params);
$id = isset($this->params['id']) ? $this->params['id'] : null;
$record = new optiongroup_master($id);
assign_to_template(array(
'record'=>$record
));
} | CWE-89 | 0 |
function unlockTables() {
$sql = "UNLOCK TABLES";
$res = mysqli_query($this->connection, $sql);
return $res;
} | CWE-89 | 0 |
public function approve() {
expHistory::set('editable', $this->params);
/* The global constants can be overriden by passing appropriate params */
//sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet
$require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];
$require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];
$require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];
$notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];
if (empty($this->params['id'])) {
flash('error', gt('No ID supplied for note to approve'));
$lastUrl = expHistory::getLast('editable');
}
$simplenote = new expSimpleNote($this->params['id']);
assign_to_template(array(
'simplenote'=>$simplenote,
'require_login'=>$require_login,
'require_approval'=>$require_approval,
'require_notification'=>$require_notification,
'notification_email'=>$notification_email,
'tab'=>$this->params['tab']
));
} | CWE-89 | 0 |
public function load_from_post()
{
if(intval($_REQUEST['parent'])!=$this->id) // protection against selecting this same category as parent of itself
{
$this->parent = intval($_REQUEST['parent']);
}
$this->template = $_REQUEST['template'];
$this->access = intval($_REQUEST['access']);
$this->groups = $_REQUEST['groups'];
if($this->access < 3)
{
$this->groups = array();
}
$this->permission = intval($_REQUEST['permission']);
$this->visible = intval($_REQUEST['visible']);
$this->date_published = (empty($_REQUEST['date_published'])? '' : core_date2ts($_REQUEST['date_published']));
$this->date_unpublish = (empty($_REQUEST['date_unpublish'])? '' : core_date2ts($_REQUEST['date_unpublish']));
// language strings and options
$this->dictionary = array();
$this->paths = array();
$fields = array('title', 'action-type', 'action-jump-item', 'action-jump-branch', 'action-new-window', 'action-masked-redirect'); //, 'path', 'visible');
foreach($_REQUEST as $key => $value)
{
if(empty($value))
{
continue;
}
foreach($fields as $field)
{
if(substr($key, 0, strlen($field.'-'))==$field.'-')
{
$this->dictionary[substr($key, strlen($field.'-'))][$field] = $value;
}
}
if(substr($key, 0, strlen('path-'))=='path-')
{
$this->paths[substr($key, strlen('path-'))] = $value;
}
}
}
| CWE-79 | 1 |
public function execute(&$params){
$model = new Actions;
$model->type = 'note';
$model->complete = 'Yes';
$model->associationId = $params['model']->id;
$model->associationType = $params['model']->module;
$model->actionDescription = $this->parseOption('comment', $params);
$model->assignedTo = $this->parseOption('assignedTo', $params);
$model->completedBy = $this->parseOption('assignedTo', $params);
if(empty($model->assignedTo) && $params['model']->hasAttribute('assignedTo')){
$model->assignedTo = $params['model']->assignedTo;
$model->completedBy = $params['model']->assignedTo;
}
if($params['model']->hasAttribute('visibility'))
$model->visibility = $params['model']->visibility;
$model->createDate = time();
$model->completeDate = time();
if($model->save()){
return array(
true,
Yii::t('studio', 'View created action: ').$model->getLink());
}else{
return array(false, array_shift($model->getErrors()));
}
} | CWE-79 | 1 |
$src = substr($ref->source, strlen($prefix)) . $section->id;
if (call_user_func(array($ref->module, 'hasContent'))) {
$oloc = expCore::makeLocation($ref->module, $ref->source);
$nloc = expCore::makeLocation($ref->module, $src);
if ($ref->module != "container") {
call_user_func(array($ref->module, 'copyContent'), $oloc, $nloc);
} else {
call_user_func(array($ref->module, 'copyContent'), $oloc, $nloc, $section->id);
}
}
}
| CWE-89 | 0 |
public function download($name){
$attachFile = storage_path('app/'.str_replace("-","/",$name));
if(!is_file($attachFile)){
abort(404);
}
return response()->download($attachFile);
} | CWE-494 | 22 |
$body = str_replace(array("\n"), "<br />", $body);
} else {
// It's going elsewhere (doesn't like quoted-printable)
$body = str_replace(array("\n"), " -- ", $body);
}
$title = $items[$i]->title;
$msg .= "BEGIN:VEVENT\n";
$msg .= $dtstart . $dtend;
$msg .= "UID:" . $items[$i]->date_id . "\n";
$msg .= "DTSTAMP:" . date("Ymd\THis", time()) . "Z\n";
if ($title) {
$msg .= "SUMMARY:$title\n";
}
if ($body) {
$msg .= "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" . $body . "\n";
}
// if($link_url) { $msg .= "URL: $link_url\n";}
if (!empty($this->config['usecategories'])) {
if (!empty($items[$i]->expCat[0]->title)) {
$msg .= "CATEGORIES:".$items[$i]->expCat[0]->title."\n";
} else {
$msg .= "CATEGORIES:".$this->config['uncat']."\n";
}
}
$msg .= "END:VEVENT\n";
}
| CWE-89 | 0 |
private function _csv_text($text)
{
$text = stripslashes(htmlspecialchars($text));
return $text;
} | CWE-79 | 1 |
public function __construct()
{
$this->options['alias'] = ''; // alias to replace root dir name
$this->options['dirMode'] = 0755; // new dirs mode
$this->options['fileMode'] = 0644; // new files mode
$this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden)
$this->options['rootCssClass'] = 'elfinder-navbar-root-local';
$this->options['followSymLinks'] = true;
$this->options['detectDirIcon'] = ''; // file name that is detected as a folder icon e.g. '.diricon.png'
$this->options['keepTimestamp'] = array('copy', 'move'); // keep timestamp at inner filesystem allowed 'copy', 'move' and 'upload'
$this->options['substituteImg'] = true; // support substitute image with dim command
$this->options['statCorrector'] = null; // callable to correct stat data `function(&$stat, $path, $statOwner, $volumeDriveInstance){}`
} | CWE-918 | 16 |
public function IsHTML($ishtml = true) {
if ($ishtml) {
$this->ContentType = 'text/html';
} else {
$this->ContentType = 'text/plain';
}
} | CWE-79 | 1 |
function delete() {
global $db;
if (empty($this->params['id'])) return false;
$product_type = $db->selectValue('product', 'product_type', 'id=' . $this->params['id']);
$product = new $product_type($this->params['id'], true, false);
//eDebug($product_type);
//eDebug($product, true);
//if (!empty($product->product_type_id)) {
//$db->delete($product_type, 'id='.$product->product_id);
//}
$db->delete('option', 'product_id=' . $product->id . " AND optiongroup_id IN (SELECT id from " . $db->prefix . "optiongroup WHERE product_id=" . $product->id . ")");
$db->delete('optiongroup', 'product_id=' . $product->id);
//die();
$db->delete('product_storeCategories', 'product_id=' . $product->id . ' AND product_type="' . $product_type . '"');
if ($product->product_type == "product") {
if ($product->hasChildren()) {
$this->deleteChildren();
}
}
$product->delete();
flash('message', gt('Product deleted successfully.'));
expHistory::back();
} | CWE-89 | 0 |
public static function extract ($var, $m) {
foreach ($var as $k2 => $v2) {
if ($k2 != '0') {
$va[] = [$k2 => $m[$v2]];
}elseif($k2 == ''){
$va = ['default'];
}else{
$va = array($k2) ;
}
}
return $va;
}
| CWE-89 | 0 |
public static function delete($id){
$vars = array(
'table' => 'user',
'where' => array(
'id' => $id
)
);
Db::delete($vars);
$vars = array(
'table' => 'user_detail',
'where' => array(
'id' => $id
)
);
Db::delete($vars);
Hooks::run('user_sqldel_action', $vars);
}
| CWE-89 | 0 |
protected function registerBackendPermissions()
{
BackendAuth::registerCallback(function ($manager) {
$manager->registerPermissions('October.Backend', [
'backend.access_dashboard' => [
'label' => 'system::lang.permissions.view_the_dashboard',
'tab' => 'system::lang.permissions.name'
],
'backend.manage_default_dashboard' => [
'label' => 'system::lang.permissions.manage_default_dashboard',
'tab' => 'system::lang.permissions.name',
],
'backend.manage_users' => [
'label' => 'system::lang.permissions.manage_other_administrators',
'tab' => 'system::lang.permissions.name'
],
'backend.impersonate_users' => [
'label' => 'system::lang.permissions.impersonate_users',
'tab' => 'system::lang.permissions.name',
],
'backend.manage_preferences' => [
'label' => 'system::lang.permissions.manage_preferences',
'tab' => 'system::lang.permissions.name'
],
'backend.manage_editor' => [
'label' => 'system::lang.permissions.manage_editor',
'tab' => 'system::lang.permissions.name'
],
'backend.manage_branding' => [
'label' => 'system::lang.permissions.manage_branding',
'tab' => 'system::lang.permissions.name'
],
'media.manage_media' => [
'label' => 'backend::lang.permissions.manage_media',
'tab' => 'system::lang.permissions.name',
]
]);
});
} | CWE-79 | 1 |
public function create_media_dir($params)
{
must_have_access();
$resp = array();
// $target_path = media_base_path() . 'uploaded' . DS;
$target_path = media_uploads_path();
$fn_path = media_base_path();
if (isset($_REQUEST['path']) and trim($_REQUEST['path']) != '') {
$_REQUEST['path'] = urldecode($_REQUEST['path']);
$fn_path = $target_path . DS . $_REQUEST['path'] . DS;
$fn_path = str_replace('..', '', $fn_path);
$fn_path = normalize_path($fn_path, false);
$target_path = $fn_path;
}
if (!isset($_REQUEST['name'])) {
$resp = array('error' => 'You must send new_folder parameter');
} else {
$fn_new_folder_path = $_REQUEST['name'];
$fn_new_folder_path = urldecode($fn_new_folder_path);
$fn_new_folder_path = str_replace('..', '', $fn_new_folder_path);
$fn_new_folder_path_new = $target_path . DS . $fn_new_folder_path;
$fn_path = normalize_path($fn_new_folder_path_new, false);
if (!is_dir($fn_path)) {
mkdir_recursive($fn_path);
$resp = array('success' => 'Folder ' . $fn_path . ' is created');
} else {
$resp = array('error' => 'Folder ' . $fn_new_folder_path . ' already exists');
}
}
return $resp;
} | CWE-79 | 1 |
public function confirm()
{
$project = $this->getProject();
$this->response->html($this->helper->layout->project('column/remove', array(
'column' => $this->columnModel->getById($this->request->getIntegerParam('column_id')),
'project' => $project,
)));
} | CWE-639 | 9 |
public function testAddsDefaultReason()
{
$r = new Response('200');
$this->assertSame(200, $r->getStatusCode());
$this->assertEquals('OK', $r->getReasonPhrase());
} | CWE-89 | 0 |
public static function editParam($param, $value, $post_id) {
$sql = "UPDATE `posts_param` SET `value` = '{$value}' WHERE `post_id` = '{$post_id}' AND `param` = '{$param}' ";
$q = Db::query($sql);
if ($q) {
return true;
}else{
return false;
}
}
| CWE-89 | 0 |
: htmlspecialchars($host['User'])) . '</label></td>' . "\n"
. '<td>' . htmlspecialchars($host['Host']) . '</td>' . "\n";
$html_output .= '<td>';
$password_column = 'Password';
$check_plugin_query = "SELECT * FROM `mysql`.`user` WHERE "
. "`User` = '" . $host['User'] . "' AND `Host` = '"
. $host['Host'] . "'";
$res = $GLOBALS['dbi']->fetchSingleRow($check_plugin_query);
if ((isset($res['authentication_string'])
&& ! empty($res['authentication_string']))
|| (isset($res['Password'])
&& ! empty($res['Password']))
) {
$host[$password_column] = 'Y';
} else {
$host[$password_column] = 'N';
}
switch ($host[$password_column]) {
case 'Y':
$html_output .= __('Yes');
break;
case 'N':
$html_output .= '<span style="color: #FF0000">' . __('No')
. '</span>';
break;
// this happens if this is a definition not coming from mysql.user
default:
$html_output .= '--'; // in future version, replace by "not present"
break;
} // end switch
$html_output .= '</td>' . "\n";
$html_output .= '<td><code>' . "\n"
. '' . implode(',' . "\n" . ' ', $host['privs']) . "\n"
. '</code></td>' . "\n";
if ($cfgRelation['menuswork']) {
$html_output .= '<td class="usrGroup">' . "\n"
. (isset($group_assignment[$host['User']])
? $group_assignment[$host['User']]
: ''
)
. '</td>' . "\n";
} | CWE-79 | 1 |
protected function _archive($dir, $files, $name, $arc) {
die('Not yet implemented. (_archive)');
return false;
} | CWE-89 | 0 |
function db_case($array)
{
global $DatabaseType;
$counter = 0;
if ($DatabaseType == 'mysqli') {
$array_count = count($array);
$string = " CASE WHEN $array[0] =";
$counter++;
$arr_count = count($array);
for ($i = 1; $i < $arr_count; $i++) {
$value = $array[$i];
if ($value == "''" && substr($string, -1) == '=') {
$value = ' IS NULL';
$string = substr($string, 0, -1);
}
$string .= "$value";
if ($counter == ($array_count - 2) && $array_count % 2 == 0)
$string .= " ELSE ";
elseif ($counter == ($array_count - 1))
$string .= " END ";
elseif ($counter % 2 == 0)
$string .= " WHEN $array[0]=";
elseif ($counter % 2 == 1)
$string .= " THEN ";
$counter++;
}
}
return $string;
} | CWE-22 | 2 |
public static function BBCode2Html($text) {
$text = trim($text);
$text = self::parseEmoji($text);
// Smileys to find...
$in = array(
);
// And replace them by...
$out = array(
);
$in[] = '[/*]';
$in[] = '[*]';
$out[] = '</li>';
$out[] = '<li>';
$text = str_replace($in, $out, $text);
// BBCode to find...
$in = array( '/\[b\](.*?)\[\/b\]/ms',
'/\[i\](.*?)\[\/i\]/ms',
'/\[u\](.*?)\[\/u\]/ms',
'/\[mark\](.*?)\[\/mark\]/ms',
'/\[s\](.*?)\[\/s\]/ms',
'/\[list\=(.*?)\](.*?)\[\/list\]/ms',
'/\[list\](.*?)\[\/list\]/ms',
'/\[\*\]\s?(.*?)\n/ms',
'/\[fs(.*?)\](.*?)\[\/fs(.*?)\]/ms',
'/\[color\=(.*?)\](.*?)\[\/color\]/ms'
);
// And replace them by...
$out = array( '<strong>\1</strong>',
'<em>\1</em>',
'<u>\1</u>',
'<mark>\1</mark>',
'<strike>\1</strike>',
'<ol start="\1">\2</ol>',
'<ul>\1</ul>',
'<li>\1</li>',
'<span style="font-size:\1pt">\2</span>',
'<span style="color:#\1">\2</span>'
);
$text = preg_replace($in, $out, $text);
// Prepare quote's
$text = str_replace("\r\n","\n",$text);
// paragraphs
$text = str_replace("\r", "", $text);
$text = nl2br($text);
// clean some tags to remain strict
// not very elegant, but it works. No time to do better ;)
if (!function_exists('removeBr')) {
function removeBr($s) {
return str_replace("<br />", "", $s[0]);
}
}
$text = preg_replace_callback('/<pre>(.*?)<\/pre>/ms', "removeBr", $text);
$text = preg_replace('/<p><pre>(.*?)<\/pre><\/p>/ms', "<pre>\\1</pre>", $text);
$text = preg_replace_callback('/<ul>(.*?)<\/ul>/ms', "removeBr", $text);
$text = preg_replace('/<p><ul>(.*?)<\/ul><\/p>/ms', "<ul>\\1</ul>", $text);
return $text;
} | CWE-79 | 1 |
public function logout()
{
// Initialize the current auth session before trying to remove it
if (is_null($this->user) && !$this->check()) {
return;
}
if ($this->isImpersonator()) {
$this->user = $this->getImpersonator();
$this->stopImpersonate();
return;
}
if ($this->user) {
$this->user->setRememberToken(null);
$this->user->forceSave();
}
$this->user = null;
Session::flush();
Cookie::queue(Cookie::forget($this->sessionKey));
} | CWE-613 | 7 |
public static function update_object_votes($webuser, $object, $object_id, $value, $replace=false)
{
global $DB;
global $website;
global $events;
$status = false;
$voted = false;
$webuser_vote_id = null;
// user has voted in the past?
if($DB->query('
SELECT *
FROM nv_webuser_votes
WHERE webuser = '.intval($webuser).'
AND object = '.protect($object).'
AND object_id = '.protect($object_id)
)
)
{
$data = $DB->result();
$data = $data[0];
$voted = ($data->webuser == $webuser);
$webuser_vote_id = $data->id;
}
if($voted && $replace) // update
{
$ok = $DB->execute('
UPDATE nv_webuser_votes
SET `value` = '.protect($value).',
date = '.protect(core_time()).'
WHERE id = '.$webuser_vote_id
);
if(!$ok)
throw new Exception($DB->get_last_error());
else
$status = true;
}
else if($voted)
{
$status = 'already_voted';
}
else // insert
{
$wv = new webuser_vote();
$wv->website = $website->id;
$wv->webuser = $webuser;
$wv->object = $object;
$wv->object_id = $object_id;
$wv->value = $value;
$wv->insert();
$webuser_vote_id = $wv->id;
$status = true;
}
// now update the object score
if($status === true)
webuser_vote::update_object_score($object, $object_id);
$events->trigger(
'webuser',
'vote',
array(
'status' => $status,
'webuser_vote_id' => $webuser_vote_id,
'webuser' => $webuser,
'object' => $object,
'object_id' => $object_id,
'value' => $value,
'replace' => $replace
)
);
return $status;
}
| CWE-89 | 0 |
function show_vendor () {
$vendor = new vendor();
if(isset($this->params['id'])) {
$vendor = $vendor->find('first', 'id =' .$this->params['id']);
$vendor_title = $vendor->title;
$state = new geoRegion($vendor->state);
$vendor->state = $state->name;
//Removed unnecessary fields
unset(
$vendor->title,
$vendor->table,
$vendor->tablename,
$vendor->classname,
$vendor->identifier
);
assign_to_template(array(
'vendor_title' => $vendor_title,
'vendor'=>$vendor
));
}
} | CWE-89 | 0 |
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$filter = $this->customFilterModel->getById($this->request->getIntegerParam('filter_id'));
$this->checkPermission($project, $filter);
if ($this->customFilterModel->remove($filter['id'])) {
$this->flash->success(t('Custom filter removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this custom filter.'));
}
$this->response->redirect($this->helper->url->to('CustomFilterController', 'index', array('project_id' => $project['id'])));
} | CWE-639 | 9 |
function URLEscape( $string )
{
$string = preg_replace_callback(
// Match both decimal & hex code (although hex codes can contain a-f letters).
// Should be enough as the alphabet hex codes only have numbers.
"/(&#x?[0-9]+;?)/i",
function( $match ) {
if ( mb_substr( $match[1], -1 ) !== ';' )
{
// Fix stored XSS security issue: add semicolon to HTML entity so it can be decoded.
// @link https://www.php.net/manual/en/function.html-entity-decode.php#104617
$match[1] .= ';';
}
return $match[1];
},
$string
);
// Fix stored XSS security issue: decode HTML entities from URL.
$string = html_entity_decode( (string) $string );
$remove = [
// Fix stored XSS security issue: remove inline JS from URL.
'javascript:',
];
foreach ( $remove as $remove_string )
{
while ( stripos( $string, $remove_string ) !== false )
{
$string = str_ireplace( $remove, '', $string );
}
}
$entities = [
'%21',
'%2A',
'%27',
'%28',
'%29',
'%3B',
'%3A',
'%40',
'%26',
'%3D',
'%2B',
'%24',
'%2C',
'%2F',
'%3F',
'%25',
'%23',
'%5B',
'%5D',
];
$replacements = [
'!',
'*',
"'",
'(',
')',
';',
':',
'@',
'&',
'=',
'+',
'$',
',',
'/',
'?',
'%',
'#',
'[',
']',
];
return str_replace(
$entities,
$replacements,
rawurlencode( $string )
);
} | CWE-79 | 1 |
foreach ($fields as $field => $title) {
if($i==0 && $j==0){
echo '<div class="row">';
}elseif($i==0 && $j>0){
echo '</div><div class="row">';
}
echo '<div class="col-md-6"><label class="checkbox-inline"><INPUT type=checkbox onclick="addHTML(\'<LI>' . $title . '</LI>\',\'names_div\',false);addHTML(\'<INPUT type=hidden name=fields[' . $field . '] value=Y>\',\'fields_div\',false);addHTML(\'\',\'names_div_none\',true);this.disabled=true">' . $title . '<label></div>';
/*if ($i % 2 == 0)
echo '</TR><TR>';*/
$i++;
if($i==2){
$i = 0;
}
$j++;
} | CWE-22 | 2 |
protected function _fclose($fp, $path='') {
@fclose($fp);
if ($path) {
@unlink($this->getTempFile($path));
}
} | CWE-89 | 0 |
protected function moveVotes()
{
$sql = "SELECT * FROM package_proposal_votes WHERE pkg_prop_id = {$this->proposal}";
$res = $this->mdb2->query($sql);
if (MDB2::isError($res)) {
throw new RuntimeException("DB error occurred: {$res->getDebugInfo()}");
}
if ($res->numRows() == 0) {
return; // nothing to do
}
$insert = "INSERT INTO package_proposal_comments (";
$insert .= "user_handle, pkg_prop_id, timestamp, comment";
$insert .= ") VALUES(%s, {$this->proposal}, %d, %s)";
$delete = "DELETE FROM package_proposal_votes WHERE";
$delete .= " pkg_prop_id = {$this->proposal}";
$delete .= " AND user_handle = %s";
while ($row = $res->fetchRow(MDB2_FETCHMODE_OBJECT)) {
$comment = "Original vote: {$row->value}\n";
$comment .= "Conditional vote: " . (($row->is_conditional != 0)?'yes':'no') . "\n";
$comment .= "Comment on vote: " . $row->comment . "\n";
$comment .= "Reviewed: " . implode(", ", unserialize($row->reviews));
$sql = sprintf(
$insert,
$this->mdb2->quote($row->user_handle),
$row->timestamp,
$this->mdb2->quote($comment)
);
$this->queryChange($sql);
$sql = sprintf(
$delete,
$this->mdb2->quote($row->user_handle)
);
$this->queryChange($sql);
} | CWE-640 | 20 |
$value = (int)$_POST[$key];
} else {
$value = strtotime($_POST[$key]);
}
$icmsObj->setVar($key, $value);
break;
case XOBJ_DTYPE_URL:
if (isset($_POST[$key])) {
$icmsObj->setVar($key, filter_var($_POST[$key], FILTER_SANITIZE_URL));
}
break;
case XOBJ_DTYPE_ARRAY:
if (is_array($_POST[$key])) {
$icmsObj->setVar($key, serialize($_POST[$key]));
}
break;
default:
$icmsObj->setVar($key, $_POST[$key]);
break;
}
}
}
| CWE-22 | 2 |
function logging($module,$command,$user=false){
global $database_eonweb;
global $dateformat;
if($user)
sqlrequest($database_eonweb,"insert into logs values ('','".time()."','$user','$module','$command','".$_SERVER["REMOTE_ADDR"]."');");
elseif(isset($_COOKIE['user_name']))
sqlrequest($database_eonweb,"insert into logs values ('','".time()."','".$_COOKIE['user_name']."','$module','$command','".$_SERVER["REMOTE_ADDR"]."');");
} | CWE-79 | 1 |
public function rules()
{
return [
'sku' => ['required'],
'name' => ['required', Rule::unique('products')->ignore($this->segment(3))],
'quantity' => ['required', 'integer', 'min:0'],
'price' => ['required', 'numeric', 'min:0'],
'sale_price' => ['nullable', 'numeric'],
'weight' => ['nullable', 'numeric', 'min:0']
];
} | CWE-434 | 5 |
public function theme_switch() {
if (!expUtil::isReallyWritable(BASE.'framework/conf/config.php')) { // we can't write to the config.php file
flash('error',gt('The file /framework/conf/config.php is NOT Writeable. You will be unable to change the theme.'));
}
expSettings::change('DISPLAY_THEME_REAL', $this->params['theme']);
expSession::set('display_theme',$this->params['theme']);
$sv = isset($this->params['sv'])?$this->params['sv']:'';
if (strtolower($sv)=='default') {
$sv = '';
}
expSettings::change('THEME_STYLE_REAL',$sv);
expSession::set('theme_style',$sv);
expDatabase::install_dbtables(); // update tables to include any custom definitions in the new theme
// $message = (MINIFY != 1) ? "Exponent is now minifying Javascript and CSS" : "Exponent is no longer minifying Javascript and CSS" ;
// flash('message',$message);
$message = gt("You have selected the")." '".$this->params['theme']."' ".gt("theme");
if ($sv != '') {
$message .= ' '.gt('with').' '.$this->params['sv'].' '.gt('style variation');
}
flash('message',$message);
// expSession::un_set('framework');
expSession::set('force_less_compile', 1);
// expTheme::removeSmartyCache();
expSession::clearAllUsersSessionCache();
expHistory::returnTo('manageable');
} | CWE-89 | 0 |
public function localFileSystemInotify($path, $standby, $compare) {
if (isset($this->sessionCache['localFileSystemInotify_disable'])) {
return false;
}
$path = realpath($path);
$mtime = filemtime($path);
if ($mtime != $compare) {
return $mtime;
}
$inotifywait = defined('ELFINER_INOTIFYWAIT_PATH')? ELFINER_INOTIFYWAIT_PATH : 'inotifywait';
$path = escapeshellarg($path);
$standby = max(1, intval($standby));
$cmd = $inotifywait.' '.$path.' -t '.$standby.' -e moved_to,moved_from,move,close_write,delete,delete_self';
$this->procExec($cmd , $o, $r);
if ($r === 0) {
// changed
clearstatcache();
$mtime = @filemtime($path); // error on busy?
return $mtime? $mtime : time();
} else if ($r === 2) {
// not changed (timeout)
return $compare;
}
// error
// cache to $_SESSION
$this->sessionCache['localFileSystemInotify_disable'] = true;
$this->session->set($this->id, $this->sessionCache, true);
return false;
} | CWE-89 | 0 |
function productFeed() {
// global $db;
//check query password to avoid DDOS
/*
* condition = new
* description
* id - SKU
* link
* price
* title
* brand - manufacturer
* image link - fullsized image, up to 10, comma seperated
* product type - category - "Electronics > Audio > Audio Accessories MP3 Player Accessories","Health & Beauty > Healthcare > Biometric Monitors > Pedometers"
*/
$out = '"id","condition","description","like","price","title","brand","image link","product type"' . chr(13) . chr(10);
$p = new product();
$prods = $p->find('all', 'parent_id=0 AND ');
//$prods = $db->selectObjects('product','parent_id=0 AND');
} | CWE-89 | 0 |
public static function login() {
user::login(expString::sanitize($_POST['username']),expString::sanitize($_POST['password']));
if (!isset($_SESSION[SYS_SESSION_KEY]['user'])) { // didn't successfully log in
flash('error', gt('Invalid Username / Password'));
if (expSession::is_set('redirecturl_error')) {
$url = expSession::get('redirecturl_error');
expSession::un_set('redirecturl_error');
header("Location: ".$url);
} else {
expHistory::back();
}
} else { // we're logged in
global $user;
if (expSession::get('customer-login')) expSession::un_set('customer-login');
if (!empty($_POST['username'])) flash('message', gt('Welcome back').' '.expString::sanitize($_POST['username']));
if ($user->isAdmin()) {
expHistory::back();
} else {
foreach ($user->groups as $g) {
if (!empty($g->redirect)) {
$url = URL_FULL.$g->redirect;
break;
}
}
if (isset($url)) {
header("Location: ".$url);
} else {
expHistory::back();
}
}
}
} | CWE-89 | 0 |
public function setContainer($container, $type = 'ctText')
{
$this->container = $container;
$container->setType($type);
} | CWE-79 | 1 |
public function delete() {
global $user;
$count = $this->address->find('count', 'user_id=' . $user->id);
if($count > 1)
{
$address = new address($this->params['id']);
if ($user->isAdmin() || ($user->id == $address->user_id)) {
if ($address->is_billing)
{
$billAddress = $this->address->find('first', 'user_id=' . $user->id . " AND id != " . $address->id);
$billAddress->is_billing = true;
$billAddress->save();
}
if ($address->is_shipping)
{
$shipAddress = $this->address->find('first', 'user_id=' . $user->id . " AND id != " . $address->id);
$shipAddress->is_shipping = true;
$shipAddress->save();
}
parent::delete();
}
}
else
{
flash("error", gt("You must have at least one address."));
}
expHistory::back();
} | CWE-89 | 0 |
composerRequire57fe33d7077d32d85bc5d5df10c056df($file);
}
return $loader;
} | CWE-89 | 0 |
public function testDoesNotTouchClosureListeners()
{
$this->getServer()->flush();
$this->getServer()->enqueue(array(
"HTTP/1.1 200 OK\r\n" .
"Date: Mon, 12 Nov 2012 03:06:37 GMT\r\n" .
"Cache-Control: private, s-maxage=0, max-age=0, must-revalidate\r\n" .
"Last-Modified: Mon, 12 Nov 2012 02:53:38 GMT\r\n" .
"Content-Length: 2\r\n\r\nhi",
"HTTP/1.0 304 Not Modified\r\n" .
"Date: Mon, 12 Nov 2012 03:06:38 GMT\r\n" .
"Content-Type: text/html; charset=UTF-8\r\n" .
"Last-Modified: Mon, 12 Nov 2012 02:53:38 GMT\r\n" .
"Age: 6302\r\n\r\n",
"HTTP/1.0 304 Not Modified\r\n" .
"Date: Mon, 12 Nov 2012 03:06:38 GMT\r\n" .
"Content-Type: text/html; charset=UTF-8\r\n" .
"Last-Modified: Mon, 12 Nov 2012 02:53:38 GMT\r\n" .
"Age: 6302\r\n\r\n",
));
$client = new Client($this->getServer()->getUrl());
$client->addSubscriber(new CachePlugin());
$client->getEventDispatcher()->addListener('command.after_send', function(){});
$this->assertEquals(200, $client->get()->send()->getStatusCode());
$this->assertEquals(200, $client->get()->send()->getStatusCode());
$this->assertEquals(200, $client->get()->send()->getStatusCode());
} | CWE-89 | 0 |
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$action = $this->actionModel->getById($this->request->getIntegerParam('action_id'));
if (! empty($action) && $this->actionModel->remove($action['id'])) {
$this->flash->success(t('Action removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this action.'));
}
$this->response->redirect($this->helper->url->to('ActionController', 'index', array('project_id' => $project['id'])));
} | CWE-639 | 9 |
$result[$index][1] = preg_replace(
"/" . $find . "/",
$replaceWith,
$row[0]
);
}
}
return $result;
} | CWE-94 | 14 |
function searchName() { return gt('Webpage'); }
| CWE-89 | 0 |
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$swimlane_id = $this->request->getIntegerParam('swimlane_id');
if ($this->swimlaneModel->remove($project['id'], $swimlane_id)) {
$this->flash->success(t('Swimlane removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this swimlane.'));
}
$this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
} | CWE-639 | 9 |
$this->paths[substr($key, strlen('path-'))] = $value;
}
| CWE-79 | 1 |
$section = new section($this->params);
} else {
notfoundController::handle_not_found();
exit;
}
if (!empty($section->id)) {
$check_id = $section->id;
} else {
$check_id = $section->parent;
}
if (expPermissions::check('manage', expCore::makeLocation('navigation', '', $check_id))) {
if (empty($section->id)) {
$section->active = 1;
$section->public = 1;
if (!isset($section->parent)) {
// This is another precaution. The parent attribute
// should ALWAYS be set by the caller.
//FJD - if that's the case, then we should die.
notfoundController::handle_not_authorized();
exit;
//$section->parent = 0;
}
}
assign_to_template(array(
'section' => $section,
'glyphs' => self::get_glyphs(),
));
} else { // User does not have permission to manage sections. Throw a 403
notfoundController::handle_not_authorized();
}
}
| CWE-89 | 0 |
$this->headerLines = ['Host' => [$host]] + $this->headerLines; | CWE-89 | 0 |