code
stringlengths 12
2.05k
| label_name
stringlengths 6
8
| label
int64 0
95
|
---|---|---|
function render_menu_tabs()
{
$current_tab = $this->get_current_tab();
echo '<h2 class="nav-tab-wrapper">';
foreach ( $this->menu_tabs as $tab_key => $tab_caption )
{
$active = $current_tab == $tab_key ? 'nav-tab-active' : '';
echo '<a class="nav-tab ' . $active . '" href="?page=' . $this->menu_page_slug . '&tab=' . $tab_key . '">' . $tab_caption . '</a>';
}
echo '</h2>';
}
| CWE-79 | 1 |
public function delete() {
global $db;
/* 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']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login'];
// $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval'];
// $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification'];
// $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email'];
if (empty($this->params['id'])) {
flash('error', gt('Missing id for the comment you would like to delete'));
expHistory::back();
}
// delete the comment
$comment = new expComment($this->params['id']);
$comment->delete();
// delete the association too
$db->delete($comment->attachable_table, 'expcomments_id='.$this->params['id']);
// send the user back where they came from.
expHistory::back();
} | CWE-89 | 0 |
protected function getSubtask()
{
$subtask = $this->subtaskModel->getById($this->request->getIntegerParam('subtask_id'));
if (empty($subtask)) {
throw new PageNotFoundException();
}
return $subtask;
} | CWE-639 | 9 |
public function skip($value)
{
return $this->offset($value);
} | CWE-79 | 1 |
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 |
public function store()
{
$title = $this->title;
if ($title === null || trim($title) === '') {
$title = new Expression('NULL');
}
$subtitle = $this->subtitle;
if ($subtitle === null || trim($subtitle) === '') {
$subtitle = new Expression('NULL');
}
$data = array(
'model_header' => $this->header,
'model_footer' => $this->footer,
'model_type' => $this->type,
'model_title' => $title,
'model_subtitle' => $subtitle,
'model_body' => $this->body,
'model_styles' => $this->styles
);
try {
if ($this->id !== null) {
$update = $this->zdb->update(self::TABLE);
$update->set($data)->where(
self::PK . '=' . $this->id
);
$this->zdb->execute($update);
} else {
$data['model_name'] = $this->name;
$insert = $this->zdb->insert(self::TABLE);
$insert->values($data);
$add = $this->zdb->execute($insert);
if (!($add->count() > 0)) {
Analog::log('Not stored!', Analog::ERROR);
return false;
}
}
return true;
} catch (Throwable $e) {
Analog::log(
'An error occurred storing model: ' . $e->getMessage() .
"\n" . print_r($data, true),
Analog::ERROR
);
throw $e;
}
} | CWE-89 | 0 |
public function event()
{
$project = $this->getProject();
$values = $this->request->getValues();
if (empty($values['action_name']) || empty($values['project_id'])) {
return $this->create();
}
return $this->response->html($this->template->render('action_creation/event', array(
'values' => $values,
'project' => $project,
'available_actions' => $this->actionManager->getAvailableActions(),
'events' => $this->actionManager->getCompatibleEvents($values['action_name']),
)));
} | CWE-639 | 9 |
public function remove(History $hist, $transaction = true)
{
global $emitter;
try {
if ($transaction) {
$this->zdb->connection->beginTransaction();
}
//remove associated contributions if needeed
if ($this->getDispatchedAmount() > 0) {
$c = new Contributions($this->zdb, $this->login);
$clist = $c->getListFromTransaction($this->_id);
$cids = array();
foreach ($clist as $cid) {
$cids[] = $cid->id;
}
$rem = $c->remove($cids, $hist, false);
}
//remove transaction itself
$delete = $this->zdb->delete(self::TABLE);
$delete->where(
self::PK . ' = ' . $this->_id
);
$del = $this->zdb->execute($delete);
if ($del->count() > 0) {
$this->dynamicsRemove(true);
} else {
Analog::log(
'Transaction has not been removed!',
Analog::WARNING
);
return false;
}
if ($transaction) {
$this->zdb->connection->commit();
}
$emitter->emit('transaction.remove', $this);
return true;
} catch (Throwable $e) {
if ($transaction) {
$this->zdb->connection->rollBack();
}
Analog::log(
'An error occurred trying to remove transaction #' .
$this->_id . ' | ' . $e->getMessage(),
Analog::ERROR
);
throw $e;
}
} | CWE-89 | 0 |
private function getTaskLink()
{
$link = $this->taskLinkModel->getById($this->request->getIntegerParam('link_id'));
if (empty($link)) {
throw new PageNotFoundException();
}
return $link;
} | CWE-639 | 9 |
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 |
function html_show_tabs_left() {
global $config, $tabs_left;
if (is_realm_allowed(8)) {
$show_console_tab = true;
} else {
$show_console_tab = false;
}
if (get_selected_theme() == 'classic') {
if ($show_console_tab == true) {
?><a <?php print (is_console_page(get_current_page()) ? " id='maintab-anchor" . rand() . "' class='selected'":"");?> href="<?php echo $config['url_path']; ?>index.php"><img src="<?php echo $config['url_path']; ?>images/tab_console<?php print (is_console_page(get_current_page()) ? '_down':'');?>.gif" alt="<?php print __('Console');?>"></a><?php
}
if (is_realm_allowed(7)) {
if ($config['poller_id'] > 1 && $config['connection'] != 'online') {
// Don't show graphs tab when offline
} else {
$file = get_current_page();
if ($file == "graph_view.php" || $file == "graph.php") {
print "<a id='maintab-anchor" . rand() . "' class='selected' href='" . htmlspecialchars($config['url_path'] . 'graph_view.php') . "'><img src='" . $config['url_path'] . "images/tab_graphs_down.gif' alt='" . __('Graphs') . "'></a>";
} else {
print "<a href='" . htmlspecialchars($config['url_path'] . 'graph_view.php') . "'><img src='" . $config['url_path'] . "images/tab_graphs.gif' alt='" . __('Graphs') . "'></a>";
}
}
}
if (is_realm_allowed(21) || is_realm_allowed(22)) {
if ($config['poller_id'] > 1) {
// Don't show reports tabe if not poller 1
} else {
if (substr_count($_SERVER["REQUEST_URI"], "reports_")) {
print '<a href="' . $config['url_path'] . (is_realm_allowed(22) ? 'reports_admin.php':'reports_user.php') . '"><img src="' . $config['url_path'] . 'images/tab_nectar_down.gif" alt="' . __('Reporting') . '"></a>';
} else {
print '<a href="' . $config['url_path'] . (is_realm_allowed(22) ? 'reports_admin.php':'reports_user.php') . '"><img src="' . $config['url_path'] . 'images/tab_nectar.gif" alt="' . __('Reporting') . '"></a>';
}
}
} | CWE-79 | 1 |
public function __construct()
{
# code...
self::$smtphost = Options::v('smtphost');
self::$smtpuser = Options::v('smtpuser');
self::$smtppass = Options::v('smtppass');
self::$smtpport = Options::v('smtpport');
self::$siteemail = Options::v('siteemail');
self::$sitename = Options::v('sitename');
}
| CWE-89 | 0 |
$this->setType('folder');
}
// do not allow PHP and .htaccess files
if (preg_match("@\.ph(p[\d+]?|t|tml|ps)$@i", $this->getFilename()) || $this->getFilename() == '.htaccess') {
$this->setFilename($this->getFilename() . '.txt');
}
if(mb_strlen($this->getFilename()) > 255) {
throw new \Exception('Filenames longer than 255 characters are not allowed');
}
if (Asset\Service::pathExists($this->getRealFullPath())) {
$duplicate = Asset::getByPath($this->getRealFullPath());
if ($duplicate instanceof Asset and $duplicate->getId() != $this->getId()) {
throw new \Exception('Duplicate full path [ ' . $this->getRealFullPath() . ' ] - cannot save asset');
}
}
$this->validatePathLength();
} | CWE-502 | 15 |
* function my_query_args_filter( $field_query ) {
* // your code here
* return $field_query;
* } | CWE-639 | 9 |
private function catchWarning ($errno, $errstr, $errfile, $errline) {
$this->error[] = array(
'error' => "Connecting to the POP3 server raised a PHP warning: ",
'errno' => $errno,
'errstr' => $errstr
);
} | CWE-79 | 1 |
public function show()
{
$task = $this->getTask();
$subtask = $this->getSubtask();
$this->response->html($this->template->render('subtask_converter/show', array(
'subtask' => $subtask,
'task' => $task,
)));
} | CWE-639 | 9 |
$va[] = [$k2 => $m[$v2]];
| CWE-89 | 0 |
public function insert()
{
global $DB;
$ok = $DB->execute('
INSERT INTO nv_menus
(id, codename, icon, lid, notes, functions, enabled)
VALUES
( 0, :codename, :icon, :lid, :notes, :functions, :enabled)',
array(
'codename' => value_or_default($this->codename, ""),
'icon' => value_or_default($this->icon, ""),
'lid' => value_or_default($this->lid, 0),
'notes' => value_or_default($this->notes, ""),
'functions' => json_encode($this->functions),
'enabled' => value_or_default($this->enabled, 0)
)
);
if(!$ok)
throw new Exception($DB->get_last_error());
$this->id = $DB->get_last_id();
return true;
}
| CWE-79 | 1 |
public function avatar($avatar_name)
{
list($user_id,$size) = explode('_',str_replace(".jpg",'',$avatar_name));
$avatarFile = storage_path('app/'.User::getAvatarPath($user_id,$size));
if(!is_file($avatarFile)){
$avatarFile = public_path('static/images/default_avatar.jpg');
}
$image = Image::make($avatarFile);
$response = response()->make($image->encode('jpg'));
$image->destroy();
$response->header('Content-Type', 'image/jpeg');
$response->header('Expires', date(DATE_RFC822,strtotime(" 2 day")));
$response->header('Cache-Control', 'private, max-age=86400, pre-check=86400');
return $response;
} | CWE-494 | 22 |
public static function insert($vars){
if(is_array($vars)){
$sql = array(
'table' => 'menus',
'key' => $vars
);
$menu = Db::insert($sql);
}
}
| CWE-89 | 0 |
public function doConfigPageInit($page) {
$action = isset($_REQUEST['action'])?$_REQUEST['action']:'';
//the extension we are currently displaying
$managerdisplay = isset($_REQUEST['managerdisplay'])?$_REQUEST['managerdisplay']:'';
$name = isset($_REQUEST['name'])?$_REQUEST['name']:'';
$secret = isset($_REQUEST['secret'])?$_REQUEST['secret']:'';
$deny = isset($_REQUEST['deny'])?$_REQUEST['deny']:'0.0.0.0/0.0.0.0';
$permit = isset($_REQUEST['permit'])?$_REQUEST['permit']:'127.0.0.1/255.255.255.0';
$engineinfo = engine_getinfo();
$writetimeout = isset($_REQUEST['writetimeout'])?$_REQUEST['writetimeout']:'100';
$astver = $engineinfo['version'];
//if submitting form, update database
global $amp_conf;
if($action == 'add' || $action == 'delete') {
$ampuser = $amp_conf['AMPMGRUSER'];
if($ampuser == $name) {
$action = 'conflict';
}
}
switch ($action) {
case "add":
$rights = manager_format_in($_REQUEST);
manager_add($name,$secret,$deny,$permit,$rights['read'],$rights['write'],$writetimeout);
$_REQUEST['managerdisplay'] = $name;
needreload();
break;
case "delete":
manager_del($managerdisplay);
needreload();
break;
case "edit": //just delete and re-add
manager_del($name);
$rights = manager_format_in($_REQUEST);
manager_add($name,$secret,$deny,$permit,$rights['read'],$rights['write'],$writetimeout);
needreload();
break;
case "conflict":
//do nothing we are conflicting with the FreePBX Asterisk Manager User
break;
}
} | CWE-79 | 1 |
foreach ($data['alertred'] as $alert) {
# code...
echo "<li>$alert</li>\n";
} | CWE-79 | 1 |
public static function createFromGlobals()
{
// With the php's bug #66606, the php's built-in web server
// stores the Content-Type and Content-Length header values in
// HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH fields.
$server = $_SERVER;
if ('cli-server' === php_sapi_name()) {
if (array_key_exists('HTTP_CONTENT_LENGTH', $_SERVER)) {
$server['CONTENT_LENGTH'] = $_SERVER['HTTP_CONTENT_LENGTH'];
}
if (array_key_exists('HTTP_CONTENT_TYPE', $_SERVER)) {
$server['CONTENT_TYPE'] = $_SERVER['HTTP_CONTENT_TYPE'];
}
}
$request = self::createRequestFromFactory($_GET, $_POST, array(), $_COOKIE, $_FILES, $server);
if (0 === strpos($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
&& in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH'))
) {
parse_str($request->getContent(), $data);
$request->request = new ParameterBag($data);
}
return $request;
} | CWE-89 | 0 |
public function testGetAuthorityReturnsCorrectPort()
{
// HTTPS non-standard port
$uri = new Uri('https://foo.co:99');
$this->assertEquals('foo.co:99', $uri->getAuthority());
// HTTP non-standard port
$uri = new Uri('http://foo.co:99');
$this->assertEquals('foo.co:99', $uri->getAuthority());
// No scheme
$uri = new Uri('foo.co:99');
$this->assertEquals('foo.co:99', $uri->getAuthority());
// No host or port
$uri = new Uri('http:');
$this->assertEquals('', $uri->getAuthority());
// No host or port
$uri = new Uri('http://foo.co');
$this->assertEquals('foo.co', $uri->getAuthority());
} | CWE-89 | 0 |
public function testCanGetInstance()
{
static::assertInstanceOf('ShopwarePlugins\RestApi\Components\Router', $this->router);
} | CWE-601 | 11 |
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 |
public static function desc($vars){
if(!empty($vars)){
$desc = substr(strip_tags(htmlspecialchars_decode($vars).". ".self::$desc),0,150);
}else{
$desc = substr(self::$desc,0,150);
}
$desc = Hooks::filter('site_desc_filter', $desc);
return $desc;
}
| CWE-89 | 0 |
public function printerFriendlyLink($link_text="Printer Friendly", $class=null, $width=800, $height=600, $view='', $title_text = "Printer Friendly") {
$url = '';
if (PRINTER_FRIENDLY != 1 && EXPORT_AS_PDF != 1) {
$class = !empty($class) ? $class : 'printer-friendly-link';
$url = '<a class="'.$class.'" href="javascript:void(0)" onclick="window.open(\'';
if (!empty($_REQUEST['view']) && !empty($view) && $_REQUEST['view'] != $view) {
$_REQUEST['view'] = $view;
}
if ($this->url_style == 'sef') {
$url .= $this->convertToOldSchoolUrl();
if (empty($_REQUEST['view']) && !empty($view)) $url .= '&view='.$view;
if ($this->url_type=='base') $url .= '/index.php?section='.SITE_DEFAULT_SECTION;
} else {
$url .= $this->current_url;
}
$url .= '&printerfriendly=1\' , \'mywindow\',\'menubar=1,resizable=1,scrollbars=1,width='.$width.',height='.$height.'\');"';
$url .= ' title="'.$title_text.'"';
$url .= '> '.$link_text.'</a>';
$url = str_replace('&ajax_action=1','',$url);
}
return $url;
} | CWE-89 | 0 |
protected function getJobIdFromWidgetConfiguration()
{
$sql = "SELECT *
FROM plugin_hudson_widget
WHERE widget_name = '" . db_es($this->widget_id) . "'
AND owner_id = " . db_ei($this->owner_id) . "
AND owner_type = '" . db_es($this->owner_type) . "'
AND id = " . db_ei($this->content_id);
$res = db_query($sql);
if ($res && db_numrows($res)) {
$data = db_fetch_array($res);
return $data['job_id'];
}
return null;
} | CWE-89 | 0 |
public function event()
{
$project = $this->getProject();
$values = $this->request->getValues();
if (empty($values['action_name']) || empty($values['project_id'])) {
return $this->create();
}
return $this->response->html($this->template->render('action_creation/event', array(
'values' => $values,
'project' => $project,
'available_actions' => $this->actionManager->getAvailableActions(),
'events' => $this->actionManager->getCompatibleEvents($values['action_name']),
)));
} | CWE-639 | 9 |
$WHERE[] = ['NOT' => ['name' => $locks]];
}
// Build query for frequency and allowed hour
$WHERE[] = ['OR' => [
['AND' => [
['hourmin' => ['<', $DB->quoteName('hourmax')]],
'hourmin' => ['<=', $hour],
'hourmax' => ['>', $hour]
]],
['AND' => [
'hourmin' => ['>', $DB->quoteName('hourmax')],
'OR' => [
'hourmin' => ['<=', $hour],
'hourmax' => ['>', $hour]
]
]]
]];
$WHERE[] = ['OR' => [
'lastrun' => null,
new \QueryExpression('unix_timestamp(' . $DB->quoteName('lastrun') . ') + ' . $DB->quoteName('frequency') . ' <= unix_timestamp(now())')
]];
}
$iterator = $DB->request([
'SELECT' => [
'*',
new \QueryExpression("LOCATE('Plugin', " . $DB->quoteName('itemtype') . ") AS ISPLUGIN")
],
'FROM' => $this->getTable(),
'WHERE' => $WHERE,
// Core task before plugins
'ORDER' => [
'ISPLUGIN',
new \QueryExpression('unix_timestamp(' . $DB->quoteName('lastrun') . ')+' . $DB->quoteName('frequency') . '')
]
]);
if (count($iterator)) {
$this->fields = $iterator->next();
return true;
}
return false;
} | CWE-89 | 0 |
foreach ($nodes as $node) {
if ((($perm == 'view' && $node->public == 1) || expPermissions::check($perm, expCore::makeLocation('navigation', '', $node->id))) && !in_array($node->id, $ignore_ids)) {
if ($node->active == 1) {
$text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . $node->name;
} else {
$text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . '(' . $node->name . ')';
}
$ar[$node->id] = $text;
foreach (self::levelDropdownControlArray($node->id, $depth + 1, $ignore_ids, $full, $perm, $addstandalones, $addinternalalias) as $id => $text) {
$ar[$id] = $text;
}
}
}
| CWE-89 | 0 |
protected function GetOrderedRefs($refList, $type, $order, $count = 0, $skip = 0)
{
if (!$refList)
return;
if (empty($type) || empty($order))
return null;
$args = array();
$args[] = '--sort=' . $order;
$args[] = '--format="%(refname)"';
if ($count > 0) {
if ($skip > 0) {
$args[] = '--count=' . ($count + $skip);
} else {
$args[] = '--count=' . $count;
}
} | CWE-78 | 6 |
public function getDeleteItemLink($icmsObj, $onlyUrl=false, $withimage=true, $userSide=false) {
if ($this->handler->_moduleName != 'system') {
$admin_side = $userSide ? '' : 'admin/';
$ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page
. "?op=del&" . $this->handler->keyName . "=" . $icmsObj->getVar($this->handler->keyName);
} else {
/**
* @todo: to be implemented...
*/
//$admin_side = $userSide ? '' : 'admin/';
$admin_side = '';
$ret = $this->handler->_moduleUrl . $admin_side
. 'admin.php?fct=' . $this->handler->_itemname
. "&op=del&" . $this->handler->keyName . "=" . $icmsObj->getVar($this->handler->keyName);
}
if ($onlyUrl) {
return $ret;
} elseif ($withimage) {
return "<a href='" . $ret . "'>
<img src='" . ICMS_IMAGES_SET_URL . "/actions/editdelete.png' style='vertical-align: middle;' alt='"
. _CO_ICMS_DELETE . "' title='" . _CO_ICMS_DELETE . "'/></a>";
}
return "<a href='" . $ret . "'>" . $icmsObj->getVar($this->handler->identifierName) . "</a>";
}
| CWE-22 | 2 |
public static function lists($vars) {
return Categories::lists($vars);
}
| CWE-89 | 0 |
public function getQuerySelect()
{
return '';
} | CWE-89 | 0 |
function manage() {
expHistory::set('viewable', $this->params);
// $category = new storeCategory();
// $categories = $category->getFullTree();
//
// // foreach($categories as $i=>$val){
// // if (!empty($this->values) && in_array($val->id,$this->values)) {
// // $this->tags[$i]->value = true;
// // } else {
// // $this->tags[$i]->value = false;
// // }
// // $this->tags[$i]->draggable = $this->draggable;
// // $this->tags[$i]->checkable = $this->checkable;
// // }
//
// $obj = json_encode($categories);
} | CWE-89 | 0 |
public function get_view_config() {
global $template;
// set paths we will search in for the view
$paths = array(
BASE.'themes/'.DISPLAY_THEME.'/modules/common/views/file/configure',
BASE.'framework/modules/common/views/file/configure',
);
foreach ($paths as $path) {
$view = $path.'/'.$this->params['view'].'.tpl';
if (is_readable($view)) {
if (bs(true)) {
$bstrapview = $path.'/'.$this->params['view'].'.bootstrap.tpl';
if (file_exists($bstrapview)) {
$view = $bstrapview;
}
}
if (bs3(true)) {
$bstrapview = $path.'/'.$this->params['view'].'.bootstrap3.tpl';
if (file_exists($bstrapview)) {
$view = $bstrapview;
}
}
$template = new controllertemplate($this, $view);
$ar = new expAjaxReply(200, 'ok');
$ar->send();
}
}
} | CWE-89 | 0 |
protected function _normpath($path) {
if (empty($path)) {
return '.';
}
$changeSep = (DIRECTORY_SEPARATOR !== '/');
if ($changeSep) {
$path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
}
if (strpos($path, '/') === 0) {
$initial_slashes = true;
} else {
$initial_slashes = false;
}
if (($initial_slashes)
&& (strpos($path, '//') === 0)
&& (strpos($path, '///') === false)) {
$initial_slashes = 2;
}
$initial_slashes = (int) $initial_slashes;
$comps = explode('/', $path);
$new_comps = array();
foreach ($comps as $comp) {
if (in_array($comp, array('', '.'))) {
continue;
}
if (($comp != '..')
|| (!$initial_slashes && !$new_comps)
|| ($new_comps && (end($new_comps) == '..'))) {
array_push($new_comps, $comp);
} elseif ($new_comps) {
array_pop($new_comps);
}
}
$comps = $new_comps;
$path = implode('/', $comps);
if ($initial_slashes) {
$path = str_repeat('/', $initial_slashes) . $path;
}
if ($changeSep) {
$path = str_replace('/', DIRECTORY_SEPARATOR, $path);
}
return $path ? $path : '.';
} | CWE-89 | 0 |
public function getImageSize($path, $mime = '') {
$size = false;
if ($mime === '' || strtolower(substr($mime, 0, 5)) === 'image') {
if ($work = $this->getWorkFile($path)) {
if ($size = @getimagesize($work)) {
$size['dimensions'] = $size[0].'x'.$size[1];
}
}
is_file($work) && @unlink($work);
}
return $size;
} | CWE-89 | 0 |
public function params()
{
$project = $this->getProject();
$values = $this->request->getValues();
if (empty($values['action_name']) || empty($values['project_id']) || empty($values['event_name'])) {
$this->create();
return;
}
$action = $this->actionManager->getAction($values['action_name']);
$action_params = $action->getActionRequiredParameters();
if (empty($action_params)) {
$this->doCreation($project, $values + array('params' => array()));
}
$projects_list = $this->projectUserRoleModel->getActiveProjectsByUser($this->userSession->getId());
unset($projects_list[$project['id']]);
$this->response->html($this->template->render('action_creation/params', array(
'values' => $values,
'action_params' => $action_params,
'columns_list' => $this->columnModel->getList($project['id']),
'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id']),
'projects_list' => $projects_list,
'colors_list' => $this->colorModel->getList(),
'categories_list' => $this->categoryModel->getList($project['id']),
'links_list' => $this->linkModel->getList(0, false),
'priorities_list' => $this->projectTaskPriorityModel->getPriorities($project),
'project' => $project,
'available_actions' => $this->actionManager->getAvailableActions(),
'swimlane_list' => $this->swimlaneModel->getList($project['id']),
'events' => $this->actionManager->getCompatibleEvents($values['action_name']),
)));
} | CWE-639 | 9 |
$removed[] = $fi->getFilename();
}
if ($removed = implode(', ', $removed)) {
$result .= $removed . ' ' . dgettext('tuleap-tracker', 'removed');
}
$added = $this->fetchAddedFiles(array_diff($this->files, $changeset_value->getFiles()), $format, $is_for_mail);
if ($added && $result) {
$result .= $format === 'html' ? '; ' : PHP_EOL;
}
$result .= $added;
return $result;
}
return false;
} | CWE-79 | 1 |
public function load_from_post()
{
$this->codename = $_REQUEST['codename'];
$this->icon = $_REQUEST['icon'];
$this->lid = $_REQUEST['lid'];
$this->notes = $_REQUEST['notes'];
$this->enabled = ($_REQUEST['enabled']=='1'? '1' : '0');
// load associated functions
$functions = explode('#', $_REQUEST['menu-functions']);
$this->functions = array();
foreach($functions as $function)
{
if(!empty($function))
$this->functions[] = $function;
}
}
| CWE-79 | 1 |
public function saveOption(Request $request) {
$cleanFromXss = true;
$option = $request->all();
// Allow for this keys
if (isset($option['option_key'])) {
if ($option['option_key'] == 'website_head') {
$cleanFromXss = false;
}
if ($option['option_key'] == 'website_footer') {
$cleanFromXss = false;
}
}
if ($cleanFromXss) {
$clean = new HTMLClean();
$option = $clean->cleanArray($option);
}
return save_option($option);
} | CWE-79 | 1 |
static function convertUTF($string) {
return $string = str_replace('?', '', htmlspecialchars($string, ENT_IGNORE, 'UTF-8'));
} | 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']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login'];
// $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval'];
// $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification'];
// $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email'];
if (empty($this->params['id'])) {
flash('error', gt('No ID supplied for comment to approve'));
expHistory::back();
}
$comment = new expComment($this->params['id']);
assign_to_template(array(
'comment'=>$comment
));
} | CWE-89 | 0 |
public function confirm()
{
$project = $this->getProject();
$category = $this->getCategory();
$this->response->html($this->helper->layout->project('category/remove', array(
'project' => $project,
'category' => $category,
)));
} | CWE-639 | 9 |
public function allowedViewProfileField(self $user, $fieldNameIntern)
{
return $user->mProfileFieldsData->isVisible($fieldNameIntern, $this->hasRightEditProfile($user));
} | CWE-613 | 7 |
public function save()
{
if(!empty($this->id))
return $this->update();
else
return $this->insert();
}
| CWE-22 | 2 |
public function shippingMethodSave(Request $request) {
if (is_array($request->get('Address'))) {
$request->merge([
'city'=>$request->get('Address')['city'],
'zip'=>$request->get('Address')['zip'],
'state'=>$request->get('Address')['state'],
'address'=>$request->get('Address')['address'],
]);
}
session_append_array('checkout_v2', [
'shipping_gw'=> $request->get('shipping_gw'),
'city'=> $request->get('city'),
'address'=> $request->get('address'),
'country'=> $request->get('country'),
'state'=> $request->get('state'),
'zip'=> $request->get('zip'),
'other_info'=> $request->get('other_info'),
]);
$checkIfShippingEnabled = app()->shipping_manager->getShippingModules(true);
if ($checkIfShippingEnabled) {
$validate = $this->_validateShippingMethod();
if ($validate['valid'] == false) {
session_set('errors', $validate['errors']);
return redirect(route('checkout.shipping_method'));
}
}
// Success
return redirect(route('checkout.payment_method'));
} | CWE-190 | 19 |
function db_seq_nextval($seqname)
{
global $DatabaseType;
if ($DatabaseType == 'mysqli')
$seq = "fn_" . strtolower($seqname) . "()";
return $seq;
} | CWE-22 | 2 |
public function setError ($pn_error_number, $ps_error_description='', $ps_error_context='', $ps_error_source='') {
$this->opn_error_number = $pn_error_number;
$this->ops_error_description = $ps_error_description;
$this->ops_error_context = $ps_error_context;
$this->ops_error_source = $ps_error_source;
if (($this->opb_halt_on_error) || ($this->opb_report_on_error)) {
$this->halt();
}
return 1;
} | CWE-79 | 1 |
$masteroption->delete();
}
// delete the mastergroup
$db->delete('optiongroup', 'optiongroup_master_id='.$mastergroup->id);
$mastergroup->delete();
expHistory::back();
} | 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 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 |
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 |
public function __construct(array $attributes = null)
{
$rootDir = realpath(__DIR__ . "/../");
$this->setChroot(array($rootDir));
$this->setRootDir($rootDir);
$this->setTempDir(sys_get_temp_dir());
$this->setFontDir($rootDir . "/lib/fonts");
$this->setFontCache($this->getFontDir());
$ver = "";
$versionFile = realpath(__DIR__ . "/../VERSION");
if (file_exists($versionFile) && ($version = trim(file_get_contents($versionFile))) !== false && $version !== '$Format:<%h>$') {
$ver = "/$version";
}
$this->setHttpContext([
"http" => [
"follow_location" => false,
"user_agent" => "Dompdf$ver https://github.com/dompdf/dompdf"
]
]);
if (null !== $attributes) {
$this->set($attributes);
}
} | CWE-73 | 23 |
public static function get_param($key = NULL) {
$info = [
'stype' => self::$search_type,
'stext' => self::$search_text,
'method' => self::$search_method,
'datelimit' => self::$search_date_limit,
'fields' => self::$search_fields,
'sort' => self::$search_sort,
'chars' => 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' => self::$search_param,
];
return $key === NULL ? $info : (isset($info[$key]) ? $info[$key] : NULL);
} | CWE-79 | 1 |
public function show()
{
$task = $this->getTask();
$subtask = $this->getSubtask();
$this->response->html($this->template->render('subtask_converter/show', array(
'subtask' => $subtask,
'task' => $task,
)));
} | CWE-639 | 9 |
public static function available($username, $website_id)
{
global $DB;
// remove spaces and make username lowercase (only to compare case insensitive)
$username = trim($username);
$username = mb_strtolower($username);
$data = NULL;
if($DB->query('SELECT COUNT(*) as total
FROM nv_webusers
WHERE LOWER(username) = '.protect($username).'
AND website = '.$website_id))
{
$data = $DB->first();
}
return ($data->total <= 0);
}
| CWE-89 | 0 |
public function setScriptSrc(Response $response)
{
if (config('app.allow_content_scripts')) {
return;
}
$parts = [
'http:',
'https:',
'\'nonce-' . $this->nonce . '\'',
'\'strict-dynamic\'',
];
$value = 'script-src ' . implode(' ', $parts);
$response->headers->set('Content-Security-Policy', $value, false);
} | CWE-79 | 1 |
protected function _afterLoad()
{
if ($this->_addUrlRewrite) {
$this->_addUrlRewrite($this->_urlRewriteCategory);
}
if (count($this) > 0) {
Mage::dispatchEvent('catalog_product_collection_load_after', array('collection' => $this));
}
foreach ($this as $product) {
if ($product->isRecurring() && $profile = $product->getRecurringProfile()) {
$product->setRecurringProfile(unserialize($profile));
}
}
return $this;
} | CWE-502 | 15 |
protected function stat($path) {
if ($path === false || is_null($path)) {
return false;
}
$is_root = ($path == $this->root);
if ($is_root) {
$rootKey = md5($path);
if (!isset($this->sessionCache['rootstat'])) {
$this->sessionCache['rootstat'] = array();
}
if (! $this->isMyReload()) {
// need $path as key for netmount/netunmount
if (isset($this->sessionCache['rootstat'][$rootKey])) {
if ($ret = $this->sessionCache['rootstat'][$rootKey]) {
return $ret;
}
}
}
}
$ret = isset($this->cache[$path])
? $this->cache[$path]
: $this->updateCache($path, $this->convEncOut($this->_stat($this->convEncIn($path))));
if ($is_root) {
$this->sessionCache['rootstat'][$rootKey] = $ret;
$this->session->set($this->id, $this->sessionCache);
}
return $ret;
} | CWE-89 | 0 |
public function admin_download()
{
$this->autoRender = false;
$tmpDir = TMP . 'theme' . DS;
$Folder = new Folder();
$Folder->create($tmpDir);
$path = BASER_THEMES . $this->siteConfigs['theme'] . DS;
$Folder->copy([
'from' => $path,
'to' => $tmpDir . $this->siteConfigs['theme'],
'chmod' => 0777
]);
$Simplezip = new Simplezip();
$Simplezip->addFolder($tmpDir);
$Simplezip->download($this->siteConfigs['theme']);
$Folder->delete($tmpDir);
} | CWE-78 | 6 |
public function testAddsSlashForRelativeUriStringWithHost()
{
$uri = (new Uri)->withPath('foo')->withHost('bar.com');
$this->assertEquals('foo', $uri->getPath());
$this->assertEquals('bar.com/foo', (string) $uri);
} | CWE-89 | 0 |
function selectExpObjectsBySql($sql, $classname, $get_assoc=true, $get_attached=true) {
$res = @mysqli_query($this->connection, $sql);
if ($res == null)
return array();
$arrays = array();
$numrows = mysqli_num_rows($res);
for ($i = 0; $i < $numrows; $i++)
$arrays[] = new $classname(mysqli_fetch_assoc($res), true, true);
return $arrays;
} | CWE-89 | 0 |
public function showall() {
expHistory::set('viewable', $this->params);
// figure out if should limit the results
if (isset($this->params['limit'])) {
$limit = $this->params['limit'] == 'none' ? null : $this->params['limit'];
} else {
$limit = (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10;
}
$order = isset($this->config['order']) ? $this->config['order'] : 'publish DESC';
// pull the news posts from the database
$items = $this->news->find('all', $this->aggregateWhereClause(), $order);
// merge in any RSS news and perform the sort and limit the number of posts we return to the configured amount.
if (!empty($this->config['pull_rss'])) $items = $this->mergeRssData($items);
// setup the pagination object to paginate the news stories.
$page = new expPaginator(array(
'records'=>$items,
'limit'=>$limit,
'order'=>$order,
'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),
'controller'=>$this->params['controller'],
'action'=>$this->params['action'],
'src'=>$this->loc->src,
'view'=>empty($this->params['view']) ? null : $this->params['view']
));
assign_to_template(array(
'page'=>$page,
'items'=>$page->records,
'rank'=>($order==='rank')?1:0,
'params'=>$this->params,
));
} | 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 |
$q = self::$mysqli->query($vars) ;
if($q === false) {
user_error("Query failed: ".self::$mysqli->error."<br />\n$vars");
return false;
}
}
return $q;
} | CWE-79 | 1 |
public function enable()
{
$this->checkCSRFParam();
$project = $this->getProject();
$swimlane_id = $this->request->getIntegerParam('swimlane_id');
if ($this->swimlaneModel->enable($project['id'], $swimlane_id)) {
$this->flash->success(t('Swimlane updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this swimlane.'));
}
$this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
} | CWE-639 | 9 |
function reparent_standalone() {
$standalone = $this->section->find($this->params['page']);
if ($standalone) {
$standalone->parent = $this->params['parent'];
$standalone->update();
expSession::clearAllUsersSessionCache('navigation');
expHistory::back();
} else {
notfoundController::handle_not_found();
}
}
| CWE-89 | 0 |
public function save()
{
$project = $this->getProject();
$values = $this->request->getValues();
list($valid, $errors) = $this->categoryValidator->validateCreation($values);
if ($valid) {
if ($this->categoryModel->create($values) !== false) {
$this->flash->success(t('Your category have been created successfully.'));
$this->response->redirect($this->helper->url->to('CategoryController', 'index', array('project_id' => $project['id'])), true);
return;
} else {
$errors = array('name' => array(t('Another category with the same name exists in this project')));
}
}
$this->create($values, $errors);
} | CWE-639 | 9 |
protected function getUserzoneCookie()
{
$cookie = $this->getContext()->getRequest()->getCookie('userzone');
$length = strlen($cookie);
if ($length <= 0)
return null;
$serialized_data = substr($cookie, 0, $length - 32);
$hash_signiture = substr($cookie, $length - 32);
// check the signiture
if (md5($serialized_data . $this->cookieSecret) != $hash_signiture)
return null;
$userzone_data = unserialize(base64_decode($serialized_data));
return array($userzone_data['id'], $userzone_data['email'], $userzone_data['screenname']);
} | CWE-502 | 15 |
public function confirm()
{
$project = $this->getProject();
$filter = $this->customFilterModel->getById($this->request->getIntegerParam('filter_id'));
$this->response->html($this->helper->layout->project('custom_filter/remove', array(
'project' => $project,
'filter' => $filter,
'title' => t('Remove a custom filter')
)));
} | CWE-639 | 9 |
public static function getUploadFileFromPost($siteID, $subDirectory, $id)
{
if (isset($_FILES[$id]))
{
if (!@file_exists($_FILES[$id]['tmp_name']))
{
// File was removed, accessed from another window, or no longer exists
return false;
}
if (!eval(Hooks::get('FILE_UTILITY_SPACE_CHECK'))) return;
$uploadPath = FileUtility::getUploadPath($siteID, $subDirectory);
$newFileName = $_FILES[$id]['name'];
// Could just while(file_exists) it, but I'm paranoid of infinate loops
// Shouldn't have 1000 files of the same name anyway
for ($i = 0; @file_exists($uploadPath . '/' . $newFileName) && $i < 1000; $i++)
{
$mp = explode('.', $newFileName);
$fileNameBase = implode('.', array_slice($mp, 0, count($mp)-1));
$fileNameExt = $mp[count($mp)-1];
if (preg_match('/(.*)_Copy([0-9]{1,3})$/', $fileNameBase, $matches))
{
// Copy already appending, increase the #
$fileNameBase = sprintf('%s_Copy%d', $matches[1], intval($matches[2]) + 1);
}
else
{
$fileNameBase .= '_Copy1';
}
$newFileName = $fileNameBase . '.' . $fileNameExt;
}
if (@move_uploaded_file($_FILES[$id]['tmp_name'], $uploadPath . '/' . $newFileName) &&
@chmod($uploadPath . '/' . $newFileName, 0777))
{
return $newFileName;
}
}
return false;
} | CWE-434 | 5 |
public static function getId($id=''){
if(isset($id)){
$sql = sprintf("SELECT * FROM `menus` WHERE `id` = '%d'", $id);
$menus = Db::result($sql);
$n = Db::$num_rows;
}else{
$menus = '';
}
return $menus;
}
| CWE-89 | 0 |
function selectObjectsBySql($sql) {
$res = @mysqli_query($this->connection, $sql);
if ($res == null)
return array();
$objects = array();
for ($i = 0, $iMax = mysqli_num_rows($res); $i < $iMax; $i++)
$objects[] = mysqli_fetch_object($res);
return $objects;
} | CWE-89 | 0 |
protected function itemLocked($hash)
{
if (!elFinder::$commonTempPath) {
return false;
}
$lock = elFinder::$commonTempPath . DIRECTORY_SEPARATOR . $hash . '.lock';
if (file_exists($lock)) {
if (filemtime($lock) + $this->itemLockExpire < time()) {
unlink($lock);
return false;
}
return true;
}
return false;
} | CWE-22 | 2 |
function manage_vendors () {
expHistory::set('viewable', $this->params);
$vendor = new vendor();
$vendors = $vendor->find('all');
assign_to_template(array(
'vendors'=>$vendors
));
} | CWE-89 | 0 |
static function encrypt($string, $key) {
$result = '';
for ($i=0; $i<strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result .= $char;
}
return base64_encode($result);
} | CWE-798 | 18 |
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 |
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 testSameInstanceWhenSameProtocol()
{
$r = new Response(200);
$this->assertSame($r, $r->withProtocolVersion('1.1'));
} | CWE-89 | 0 |
function edit_externalalias() {
$section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params);
if ($section->parent == -1) {
notfoundController::handle_not_found();
exit;
} // doesn't work for standalone pages
if (empty($section->id)) {
$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(),
));
}
| CWE-89 | 0 |
echo '</SCHOOL_' . htmlentities($i) . '>';
$i++;
}
echo '</SCHOOL_ACCESS>';
// }
echo '</STAFF_' . htmlentities($j) . '>';
$j++;
} | CWE-22 | 2 |
public function testSetSaveHandler53()
{
if (PHP_VERSION_ID >= 50400) {
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}
$this->iniSet('session.save_handler', 'files');
$storage = $this->getStorage();
$storage->setSaveHandler();
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler());
$storage->setSaveHandler(null);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler());
$storage->setSaveHandler(new NativeSessionHandler());
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler());
$storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler()));
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler());
$storage->setSaveHandler(new NullSessionHandler());
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler());
$storage->setSaveHandler(new NativeProxy());
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler());
} | CWE-89 | 0 |
function fm_get_size($file)
{
static $iswin;
static $isdarwin;
if (!isset($iswin)) {
$iswin = (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN');
}
if (!isset($isdarwin)) {
$isdarwin = (strtoupper(substr(PHP_OS, 0)) == "DARWIN");
}
static $exec_works;
if (!isset($exec_works)) {
$exec_works = (function_exists('exec') && !ini_get('safe_mode') && @exec('echo EXEC') == 'EXEC');
}
// try a shell command
if ($exec_works) {
$cmd = ($iswin) ? "for %F in (\"$file\") do @echo %~zF" : ($isdarwin ? "stat -f%z \"$file\"" : "stat -c%s \"$file\"");
@exec($cmd, $output);
if (is_array($output) && ctype_digit($size = trim(implode("\n", $output)))) {
return $size;
}
}
// try the Windows COM interface
if ($iswin && class_exists("COM")) {
try {
$fsobj = new COM('Scripting.FileSystemObject');
$f = $fsobj->GetFile( realpath($file) );
$size = $f->Size;
} catch (Exception $e) {
$size = null;
}
if (ctype_digit($size)) {
return $size;
}
}
// if all else fails
return filesize($file);
} | CWE-434 | 5 |
foreach ($days as $event) {
if (empty($event->eventdate->date) || ($viewrange == 'upcoming' && $event->eventdate->date < time()))
break;
if (empty($event->eventstart))
$event->eventstart = $event->eventdate->date;
$extitem[] = $event;
}
| CWE-89 | 0 |
public function event()
{
$project = $this->getProject();
$values = $this->request->getValues();
if (empty($values['action_name']) || empty($values['project_id'])) {
return $this->create();
}
return $this->response->html($this->template->render('action_creation/event', array(
'values' => $values,
'project' => $project,
'available_actions' => $this->actionManager->getAvailableActions(),
'events' => $this->actionManager->getCompatibleEvents($values['action_name']),
)));
} | CWE-639 | 9 |
public function destroy(Image $image)
{
$this->destroyImagesFromPath($image->path);
$image->delete();
} | CWE-22 | 2 |
public function setFrameAncestors(Response $response)
{
$iframeHosts = $this->getAllowedIframeHosts();
array_unshift($iframeHosts, "'self'");
$cspValue = 'frame-ancestors ' . implode(' ', $iframeHosts);
$response->headers->set('Content-Security-Policy', $cspValue, false);
} | CWE-79 | 1 |
public function load_by_hash($hash)
{
global $DB;
global $session;
global $events;
$ok = $DB->query('SELECT * FROM nv_webusers WHERE cookie_hash = '.protect($hash));
if($ok)
$data = $DB->result();
if(!empty($data))
{
$this->load_from_resultset($data);
// check if the user is still allowed to sign in
$blocked = 1;
if( $this->access == 0 ||
( $this->access == 2 &&
($this->access_begin==0 || $this->access_begin < time()) &&
($this->access_end==0 || $this->access_end > time())
)
)
{
$blocked = 0;
}
if($blocked==1)
return false;
$session['webuser'] = $this->id;
// maybe this function is called without initializing $events
if(method_exists($events, 'trigger'))
{
$events->trigger(
'webuser',
'sign_in',
array(
'webuser' => $this,
'by' => 'cookie'
)
);
}
}
}
| CWE-89 | 0 |
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$tag_id = $this->request->getIntegerParam('tag_id');
$tag = $this->tagModel->getById($tag_id);
if ($tag['project_id'] != $project['id']) {
throw new AccessForbiddenException();
}
if ($this->tagModel->remove($tag_id)) {
$this->flash->success(t('Tag removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this tag.'));
}
$this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id'])));
} | CWE-639 | 9 |
function reparent_standalone() {
$standalone = $this->section->find($this->params['page']);
if ($standalone) {
$standalone->parent = $this->params['parent'];
$standalone->update();
expSession::clearAllUsersSessionCache('navigation');
expHistory::back();
} else {
notfoundController::handle_not_found();
}
}
| CWE-89 | 0 |
public static function footer($vars=""){
global $GLOBALS;
if (isset($vars)) {
# code...
$GLOBALS['data'] = $vars;
self::theme('footer', $vars);
}else{
self::theme('footer');
}
}
| CWE-89 | 0 |
$message = getlocal(
"Operator {0} joined the chat",
array($operator_name),
$this->locale,
true
);
} elseif ($is_operator_back) { | CWE-79 | 1 |
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 |
private function initProfileFieldFilter(ProfileField $profileField, $sortOrder = 1000)
{
$profileFieldType = $profileField->getFieldType();
if (!$profileFieldType) {
return;
}
$definition = $profileFieldType->getFieldFormDefinition();
$fieldType = isset($definition[$profileField->internal_name]['type']) ? $definition[$profileField->internal_name]['type'] : null;
$filterData = [
'title' => Yii::t($profileField->getTranslationCategory(), $profileField->title),
'type' => $fieldType,
'sortOrder' => $sortOrder,
];
switch ($fieldType) {
case 'text':
$filterData['type'] = 'widget';
$filterData['widget'] = PeopleFilterPicker::class;
$filterData['widgetOptions'] = [
'itemKey' => $profileField->internal_name
];
break;
case 'dropdownlist':
$filterData['options'] = array_merge(['' => Yii::t('UserModule.base', 'Any')], $definition[$profileField->internal_name]['items']);
break;
default:
// Skip not supported type
return;
}
$this->addFilter('fields[' . $profileField->internal_name . ']', $filterData);
} | CWE-79 | 1 |
static function displayname() { return gt("Navigation"); }
| CWE-89 | 0 |
private function getNewComputer() {
$computer = getItemByTypeName('Computer', '_test_pc01');
$fields = $computer->fields;
unset($fields['id']);
unset($fields['date_creation']);
unset($fields['date_mod']);
$fields['name'] = $this->getUniqueString();
$this->integer((int)$computer->add($fields))->isGreaterThan(0);
return $computer;
} | CWE-89 | 0 |