code
stringlengths 23
2.05k
| label_name
stringlengths 6
7
| label
int64 0
37
|
---|---|---|
public function replace_save_pre_shortcode( $shortcode_match ) {
$content = $shortcode_match[0];
$tag_index = array_search( 'geo_mashup_save_location', $shortcode_match );
if ( $tag_index !== false ) {
// There is an inline location - save the attributes
$this->inline_location = shortcode_parse_atts( stripslashes( $shortcode_match[$tag_index+1] ) );
// If lat and lng are missing, try to geocode based on address
$success = false;
if ( ( empty( $this->inline_location['lat'] ) or empty( $this->inline_location['lng'] ) ) and !empty( $this->inline_location['address'] ) ) {
$query = $this->inline_location['address'];
$this->inline_location = GeoMashupDB::blank_object_location( ARRAY_A );
$success = GeoMashupDB::geocode( $query, $this->inline_location );
if ( !$success ) {
// Delay and try again
sleep( 1 );
$success = GeoMashupDB::geocode( $query, $this->inline_location );
}
} else if ( is_numeric ( $this->inline_location['lat'] ) and is_numeric( $this->inline_location['lng'] ) ) {
// lat and lng were supplied
$success = true;
}
if ( $success ) {
// Remove the tag
$content = '';
} else {
$message = ( is_wp_error( GeoMashupDB::$geocode_error ) ? GeoMashupDB::$geocode_error->get_error_message() : __( 'Address not found - try making it less detailed', 'GeoMashup' ) );
$content = str_replace( ']', ' geocoding_error="' . $message . '"]', $content );
$this->inline_location = null;
}
}
return $content;
}
| CWE-20 | 0 |
function showallSubcategories() {
// global $db;
expHistory::set('viewable', $this->params);
// $parent = isset($this->params['cat']) ? $this->params['cat'] : expSession::get('catid');
$catid = expSession::get('catid');
$parent = !empty($catid) ? $catid : (!empty($this->params['cat']) ? $this->params['cat'] : 0);
$category = new storeCategory($parent);
$categories = $category->getEcomSubcategories();
$ancestors = $category->pathToNode();
assign_to_template(array(
'categories' => $categories,
'ancestors' => $ancestors,
'category' => $category
));
} | CWE-20 | 0 |
return $fa->nameGlyph($icons, 'icon-');
}
} else {
return array();
}
}
| CWE-74 | 1 |
private function generateTempFileData()
{
return [
'name' => md5(mt_rand()),
'tmp_name' => tempnam(sys_get_temp_dir(), ''),
'type' => 'image/jpeg',
'size' => mt_rand(1000, 10000),
'error' => '0',
];
} | CWE-330 | 12 |
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-74 | 1 |
public function update() {
//populate the alt tag field if the user didn't
if (empty($this->params['alt'])) $this->params['alt'] = $this->params['title'];
// call expController update to save the image
parent::update();
} | CWE-74 | 1 |
public function getCookiePathsDataProvider()
{
return [
['', '/'],
['/', '/'],
['/foo', '/'],
['/foo/bar', '/foo'],
['/foo/bar/', '/foo/bar'],
['foo', '/'],
['foo/bar', '/'],
['foo/bar/', '/'],
];
} | CWE-200 | 10 |
public function validate() {
global $db;
// check for an sef url field. If it exists make sure it's valid and not a duplicate
//this needs to check for SEF URLS being turned on also: TODO
if (property_exists($this, 'sef_url') && !(in_array('sef_url', $this->do_not_validate))) {
if (empty($this->sef_url)) $this->makeSefUrl();
if (!isset($this->validates['is_valid_sef_name']['sef_url'])) $this->validates['is_valid_sef_name']['sef_url'] = array();
if (!isset($this->validates['uniqueness_of']['sef_url'])) $this->validates['uniqueness_of']['sef_url'] = array();
}
// safeguard again loc data not being pass via forms...sometimes this happens when you're in a router
// mapped view and src hasn't been passed in via link to the form
if (isset($this->id) && empty($this->location_data)) {
$loc = $db->selectValue($this->tablename, 'location_data', 'id=' . $this->id);
if (!empty($loc)) $this->location_data = $loc;
}
// run the validation as defined in the models
if (!isset($this->validates)) return true;
$messages = array();
$post = empty($_POST) ? array() : expString::sanitize($_POST);
foreach ($this->validates as $validation=> $field) {
foreach ($field as $key=> $value) {
$fieldname = is_numeric($key) ? $value : $key;
$opts = is_numeric($key) ? array() : $value;
$ret = expValidator::$validation($fieldname, $this, $opts);
if (!is_bool($ret)) {
$messages[] = $ret;
expValidator::setErrorField($fieldname);
unset($post[$fieldname]);
}
}
}
if (count($messages) >= 1) expValidator::failAndReturnToForm($messages, $post);
} | CWE-74 | 1 |
public function setMultiSectionSeparators( ?array $separators ) {
$this->multiSectionSeparators = (array)$separators ?? [];
} | CWE-400 | 2 |
->first(function (User $user) {
return $user->getPreference('blocksPd', false);
}) !== null; | CWE-269 | 6 |
public function testOnKernelResponseListenerRemovesItself()
{
$session = $this->createMock(SessionInterface::class);
$session->expects($this->any())->method('getName')->willReturn('SESSIONNAME');
$tokenStorage = $this->createMock(TokenStorageInterface::class);
$dispatcher = $this->createMock(EventDispatcherInterface::class);
$listener = new ContextListener($tokenStorage, [], 'key123', null, $dispatcher);
$request = new Request();
$request->attributes->set('_security_firewall_run', true);
$request->setSession($session);
$event = new ResponseEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST, new Response());
$dispatcher->expects($this->once())
->method('removeListener')
->with(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']);
$listener->onKernelResponse($event);
} | CWE-287 | 4 |
$evs = $this->event->find('all', "id=" . $edate->event_id . $featuresql);
foreach ($evs as $key=>$event) {
if ($condense) {
$eventid = $event->id;
$multiday_event = array_filter($events, create_function('$event', 'global $eventid; return $event->id === $eventid;'));
if (!empty($multiday_event)) {
unset($evs[$key]);
continue;
}
}
$evs[$key]->eventstart += $edate->date;
$evs[$key]->eventend += $edate->date;
$evs[$key]->date_id = $edate->id;
if (!empty($event->expCat)) {
$catcolor = empty($event->expCat[0]->color) ? null : trim($event->expCat[0]->color);
// if (substr($catcolor,0,1)=='#') $catcolor = '" style="color:'.$catcolor.';';
$evs[$key]->color = $catcolor;
}
}
if (count($events) < 500) { // magic number to not crash loop?
$events = array_merge($events, $evs);
} else {
// $evs[$key]->title = gt('Too many events to list').', '.(count($edates)-count($events)).' '.gt('not displayed!');
// $events = array_merge($events, $evs);
flash('notice',gt('Too many events to list').', '.(count($edates)-count($events)).' '.gt('not displayed!'));
break; // keep from breaking system by too much data
}
}
| CWE-74 | 1 |
private function generateFakeFileData()
{
return [
'name' => md5(mt_rand()),
'tmp_name' => md5(mt_rand()),
'type' => 'image/jpeg',
'size' => mt_rand(1000, 10000),
'error' => '0',
];
} | CWE-330 | 12 |
public function showall_tags() {
$images = $this->image->find('all');
$used_tags = array();
foreach ($images as $image) {
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;
}
}
}
assign_to_template(array(
'tags'=>$used_tags
));
} | CWE-74 | 1 |
$result = $search->getSearchResults($item->query, false, true);
if(empty($result) && !in_array($item->query, $badSearchArr)) {
$badSearchArr[] = $item->query;
$badSearch[$ctr2]['query'] = $item->query;
$badSearch[$ctr2]['count'] = $db->countObjects("search_queries", "query='{$item->query}'");
$ctr2++;
}
}
//Check if the user choose from the dropdown
if(!empty($user_default)) {
if($user_default == $anonymous) {
$u_id = 0;
} else {
$u_id = $user_default;
}
$where .= "user_id = {$u_id}";
}
//Get all the search query records
$records = $db->selectObjects('search_queries', $where);
for ($i = 0, $iMax = count($records); $i < $iMax; $i++) {
if(!empty($records[$i]->user_id)) {
$u = user::getUserById($records[$i]->user_id);
$records[$i]->user = $u->firstname . ' ' . $u->lastname;
}
}
$page = new expPaginator(array(
'records' => $records,
'where'=>1,
'model'=>'search_queries',
'limit'=>(isset($this->config['limit']) && $this->config['limit'] != '') ? 10 : $this->config['limit'],
'order'=>empty($this->config['order']) ? 'timestamp' : $this->config['order'],
'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),
'controller'=>$this->baseclassname,
'action'=>$this->params['action'],
'columns'=>array(
'ID'=>'id',
gt('Query')=>'query',
gt('Timestamp')=>'timestamp',
gt('User')=>'user_id',
),
));
$uname['id'] = implode($uname['id'],',');
$uname['name'] = implode($uname['name'],',');
assign_to_template(array(
'page'=>$page,
'users'=>$uname,
'user_default' => $user_default,
'badSearch' => $badSearch
));
} | CWE-74 | 1 |
function test_anon_comments_require_email() {
add_filter( 'xmlrpc_allow_anonymous_comments', '__return_true' );
$comment_args = array(
1,
'',
'',
self::$post->ID,
array(
'author' => 'WordPress',
'author_email' => 'noreply at wordpress.org',
'content' => 'Test Anon Comments',
),
);
$result = $this->myxmlrpcserver->wp_newComment( $comment_args );
$this->assertIXRError( $result );
$this->assertSame( 403, $result->code );
} | CWE-862 | 8 |
public function search_external() {
// global $db, $user;
global $db;
$sql = "select DISTINCT(a.id) as id, a.source as source, a.firstname as firstname, a.middlename as middlename, a.lastname as lastname, a.organization as organization, a.email as email ";
$sql .= "from " . $db->prefix . "external_addresses as a "; //R JOIN " .
//$db->prefix . "billingmethods as bm ON bm.addresses_id=a.id ";
$sql .= " WHERE match (a.firstname,a.lastname,a.email,a.organization) against ('" . $this->params['query'] .
"*' IN BOOLEAN MODE) ";
$sql .= "order by match (a.firstname,a.lastname,a.email,a.organization) against ('" . $this->params['query'] . "*' IN BOOLEAN MODE) ASC LIMIT 12";
$res = $db->selectObjectsBySql($sql);
foreach ($res as $key=>$record) {
$res[$key]->title = $record->firstname . ' ' . $record->lastname;
}
//eDebug($sql);
$ar = new expAjaxReply(200, gt('Here\'s the items you wanted'), $res);
$ar->send();
} | CWE-74 | 1 |
public function gc($force = false, $expiredOnly = true)
{
if ($force || mt_rand(0, 1000000) < $this->gcProbability) {
$this->gcRecursive($this->cachePath, $expiredOnly);
}
} | CWE-330 | 12 |
$cLoc = serialize(expCore::makeLocation('container','@section' . $page->id));
$ret .= scan_container($cLoc, $page->id);
$ret .= scan_page($page->id);
}
| CWE-74 | 1 |
public function StartTLS() {
$this->error = null; # to avoid confusion
if(!$this->connected()) {
$this->error = array("error" => "Called StartTLS() without being connected");
return false;
}
fputs($this->smtp_conn,"STARTTLS" . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
$this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
}
if($code != 220) {
$this->error =
array("error" => "STARTTLS not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
}
return false;
}
// Begin encrypted connection
if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
return false;
}
return true;
} | CWE-20 | 0 |
$name = ucfirst($module->name);
if (in_array($name, $skipModules)) {
continue;
}
if($name != 'Document'){
$controllerName = $name.'Controller';
if(file_exists('protected/modules/'.$module->name.'/controllers/'.$controllerName.'.php')){
Yii::import("application.modules.$module->name.controllers.$controllerName");
$controller = new $controllerName($controllerName);
$model = $controller->modelClass;
if(class_exists($model)){
$moduleList[$model] = Yii::t('app', $module->title);
}
}
}
}
return $moduleList;
} | CWE-20 | 0 |
public function manage() {
expHistory::set('viewable', $this->params);
$page = new expPaginator(array(
'model'=>'order_status',
'where'=>1,
'limit'=>10,
'order'=>'rank',
'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),
'controller'=>$this->params['controller'],
'action'=>$this->params['action'],
//'columns'=>array('Name'=>'title')
));
assign_to_template(array(
'page'=>$page
));
} | CWE-74 | 1 |
public static function hasChildren($i) {
global $sections;
if (($i + 1) >= count($sections)) return false;
return ($sections[$i]->depth < $sections[$i + 1]->depth) ? true : false;
}
| CWE-74 | 1 |
private static function dumpParsedRefs( $parser, $label ) {
// if (!preg_match("/Query Q/",$parser->mTitle->getText())) return '';
echo '<pre>parser mLinks: ';
ob_start();
var_dump( $parser->getOutput()->mLinks );
$a = ob_get_contents();
ob_end_clean();
echo htmlspecialchars( $a, ENT_QUOTES );
echo '</pre>';
echo '<pre>parser mTemplates: ';
ob_start();
var_dump( $parser->getOutput()->mTemplates );
$a = ob_get_contents();
ob_end_clean();
echo htmlspecialchars( $a, ENT_QUOTES );
echo '</pre>';
} | CWE-400 | 2 |
public function actionHideWidget() {
if (isset($_POST['name'])) {
$name = $_POST['name'];
$layout = Yii::app()->params->profile->getLayout();
// the widget could be in any of the blocks in the page, so check all of them
foreach ($layout as $b => &$block) {
if (isset($block[$name])) {
if ($b == 'right') {
$layout['hiddenRight'][$name] = $block[$name];
} else {
$layout['hidden'][$name] = $block[$name];
}
unset($block[$name]);
Yii::app()->params->profile->saveLayout($layout);
break;
}
}
// make a list of hidden widgets, using <li>, to send back to the browser
$list = "";
foreach ($layout['hidden'] as $name => $widget) {
$list .= "<li><span class=\"x2-widget-menu-item\" id=\"$name\">{$widget['title']}</span></li>";
}
foreach ($layout['hiddenRight'] as $name => $widget) {
$list .= "<li><span class=\"x2-widget-menu-item right\" id=\"$name\">{$widget['title']}</span></li>";
}
echo Yii::app()->params->profile->getWidgetMenu();
}
} | CWE-20 | 0 |
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-862 | 8 |
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-20 | 0 |
function httpsTestController($serverPort) {
$args = array('HTTPS' => '');
var_dump(request(php_uname('n'), $serverPort, "test_https.php",
[], [], $args));
} | CWE-668 | 7 |
$text = wfMessage( 'intersection_noincludecats', $args )->text();
}
}
if ( empty( $text ) ) {
$text = wfMessage( 'dpl_log_' . $errorMessageId, $args )->text();
}
$this->buffer[] = '<p>Extension:DynamicPageList (DPL), version ' . DPL_VERSION . ': ' . $text . '</p>';
}
return false;
} | CWE-400 | 2 |
public function searchNew() {
global $db, $user;
//$this->params['query'] = str_ireplace('-','\-',$this->params['query']);
$sql = "select DISTINCT(p.id) as id, p.title, model, sef_url, f.id as fileid, ";
$sql .= "match (p.title,p.model,p.body) against ('" . $this->params['query'] . "*' IN BOOLEAN MODE) as relevance, ";
$sql .= "CASE when p.model like '" . $this->params['query'] . "%' then 1 else 0 END as modelmatch, ";
$sql .= "CASE when p.title like '%" . $this->params['query'] . "%' then 1 else 0 END as titlematch ";
$sql .= "from " . $db->prefix . "product as p INNER JOIN " .
$db->prefix . "content_expFiles as cef ON p.id=cef.content_id AND cef.content_type IN ('product','eventregistration','donation','giftcard') AND cef.subtype='mainimage' INNER JOIN " . $db->prefix .
"expFiles as f ON cef.expFiles_id = f.id WHERE ";
if (!$user->isAdmin()) $sql .= '(p.active_type=0 OR p.active_type=1) AND ';
$sql .= " match (p.title,p.model,p.body) against ('" . $this->params['query'] . "*' IN BOOLEAN MODE) AND p.parent_id=0 ";
$sql .= " HAVING relevance > 0 ";
//$sql .= "GROUP BY p.id ";
$sql .= "order by modelmatch,titlematch,relevance desc LIMIT 10";
eDebug($sql);
$res = $db->selectObjectsBySql($sql);
eDebug($res, true);
$ar = new expAjaxReply(200, gt('Here\'s the items you wanted'), $res);
$ar->send();
} | CWE-74 | 1 |
$controller = new $ctlname();
if (method_exists($controller,'isSearchable') && $controller->isSearchable()) {
// $mods[$controller->name()] = $controller->addContentToSearch();
$mods[$controller->searchName()] = $controller->addContentToSearch();
}
}
uksort($mods,'strnatcasecmp');
assign_to_template(array(
'mods'=>$mods
));
} | CWE-74 | 1 |
function updateObject($object, $table, $where=null, $identifier='id', $is_revisioned=false) {
if ($is_revisioned) {
$object->revision_id++;
//if ($table=="text") eDebug($object);
$res = $this->insertObject($object, $table);
//if ($table=="text") eDebug($object,true);
$this->trim_revisions($table, $object->$identifier, WORKFLOW_REVISION_LIMIT);
return $res;
}
$sql = "UPDATE " . $this->prefix . "$table SET ";
foreach (get_object_vars($object) as $var => $val) {
//We do not want to save any fields that start with an '_'
//if($is_revisioned && $var=='revision_id') $val++;
if ($var{0} != '_') {
if (is_array($val) || is_object($val)) {
$val = serialize($val);
$sql .= "`$var`='".$val."',";
} else {
$sql .= "`$var`='" . $this->escapeString($val) . "',";
}
}
}
$sql = substr($sql, 0, -1) . " WHERE ";
if ($where != null)
$sql .= $this->injectProof($where);
else
$sql .= "`" . $identifier . "`=" . $object->$identifier;
//if ($table == 'text') eDebug($sql,true);
$res = (@mysqli_query($this->connection, $sql) != false);
return $res;
} | CWE-74 | 1 |
protected function setUp()
{
$this->originalTrustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP);
} | CWE-20 | 0 |
function addDiscountToCart() {
// global $user, $order;
global $order;
//lookup discount to see if it's real and valid, and not already in our cart
//this will change once we allow more than one coupon code
$discount = new discounts();
$discount = $discount->getCouponByName($this->params['coupon_code']);
if (empty($discount)) {
flash('error', gt("This discount code you entered does not exist."));
//redirect_to(array('controller'=>'cart', 'action'=>'checkout'));
expHistory::back();
}
//check to see if it's in our cart already
if ($this->isDiscountInCart($discount->id)) {
flash('error', gt("This discount code is already in your cart."));
//redirect_to(array('controller'=>'cart', 'action'=>'checkout'));
expHistory::back();
}
//this should really be reworked, as it shoudn't redirect directly and not return
$validateDiscountMessage = $discount->validateDiscount();
if ($validateDiscountMessage == "") {
//if all good, add to cart, otherwise it will have redirected
$od = new order_discounts();
$od->orders_id = $order->id;
$od->discounts_id = $discount->id;
$od->coupon_code = $discount->coupon_code;
$od->title = $discount->title;
$od->body = $discount->body;
$od->save();
// set this to just the discount applied via this coupon?? if so, when though? $od->discount_total = ??;
flash('message', gt("The discount code has been applied to your cart."));
} else {
flash('error', $validateDiscountMessage);
}
//redirect_to(array('controller'=>'cart', 'action'=>'checkout'));
expHistory::back();
} | CWE-20 | 0 |
public function editAlt() {
global $user;
$file = new expFile($this->params['id']);
if ($user->id==$file->poster || $user->isAdmin()) {
$file->alt = $this->params['newValue'];
$file->save();
$ar = new expAjaxReply(200, gt('Your alt was updated successfully'), $file);
} else {
$ar = new expAjaxReply(300, gt("You didn't create this file, so you can't edit it."));
}
$ar->send();
echo json_encode($file); //FIXME we exit before hitting this
} | CWE-74 | 1 |
public function manage_sitemap() {
global $db, $user, $sectionObj, $sections;
expHistory::set('viewable', $this->params);
$id = $sectionObj->id;
$current = null;
// all we need to do is determine the current section
$navsections = $sections;
if ($sectionObj->parent == -1) {
$current = $sectionObj;
} else {
foreach ($navsections as $section) {
if ($section->id == $id) {
$current = $section;
break;
}
}
}
assign_to_template(array(
'sasections' => $db->selectObjects('section', 'parent=-1'),
'sections' => $navsections,
'current' => $current,
'canManage' => ((isset($user->is_acting_admin) && $user->is_acting_admin == 1) ? 1 : 0),
));
}
| CWE-74 | 1 |
} elseif ( $sSecLabel[0] == '{' ) {
// Uses LST::includeTemplate() from LabeledSectionTransclusion extension to include templates from the page
// primary syntax {template}suffix
$template1 = trim( substr( $sSecLabel, 1, strpos( $sSecLabel, '}' ) - 1 ) );
$template2 = trim( str_replace( '}', '', substr( $sSecLabel, 1 ) ) );
// alternate syntax: {template|surrogate}
if ( $template2 == $template1 && strpos( $template1, '|' ) > 0 ) {
$template1 = preg_replace( '/\|.*/', '', $template1 );
$template2 = preg_replace( '/^.+\|/', '', $template2 );
}
//Why the hell was defaultTemplateSuffix be passed all over the place for just fucking here? --Alexia
$secPieces = LST::includeTemplate( $this->parser, $this, $s, $article, $template1, $template2, $template2 . $this->getTemplateSuffix(), $mustMatch, $mustNotMatch, $this->includePageParsed, implode( ', ', $article->mCategoryLinks ) );
$secPiece[$s] = implode( isset( $this->multiSectionSeparators[$s] ) ? $this->replaceTagCount( $this->multiSectionSeparators[$s], $filteredCount ) : '', $secPieces );
if ( $this->getDominantSectionCount() >= 0 && $s == $this->getDominantSectionCount() && count( $secPieces ) > 1 ) {
$dominantPieces = $secPieces;
}
if ( ( $mustMatch != '' || $mustNotMatch != '' ) && count( $secPieces ) <= 1 && $secPieces[0] == '' ) {
$matchFailed = true; // NOTHING MATCHED
break;
}
} else { | CWE-400 | 2 |
private function setDefaults() {
$this->setParameter( 'defaulttemplatesuffix', '.default' );
$parameters = $this->getParametersForRichness();
foreach ( $parameters as $parameter ) {
if ( $this->getData( $parameter )['default'] !== null && !( $this->getData( $parameter )['default'] === false && $this->getData( $parameter )['boolean'] === true ) ) {
if ( $parameter == 'debug' ) {
\DynamicPageListHooks::setDebugLevel( $this->getData( $parameter )['default'] );
}
$this->setParameter( $parameter, $this->getData( $parameter )['default'] );
}
}
} | CWE-400 | 2 |
function __construct() {
parent::__construct( 'GlobalNewFiles' );
} | CWE-20 | 0 |
public function delete() {
global $db, $history;
/* 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('Missing id for the comment you would like to delete'));
$lastUrl = expHistory::getLast('editable');
}
// delete the note
$simplenote = new expSimpleNote($this->params['id']);
$rows = $simplenote->delete();
// delete the assocication too
$db->delete($simplenote->attachable_table, 'expsimplenote_id='.$this->params['id']);
// send the user back where they came from.
$lastUrl = expHistory::getLast('editable');
if (!empty($this->params['tab']))
{
$lastUrl .= "#".$this->params['tab'];
}
redirect_to($lastUrl);
} | CWE-74 | 1 |
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-74 | 1 |
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-74 | 1 |
public function getCompiledPath($path)
{
return $this->cachePath.'/'.sha1($path).'.php';
} | CWE-327 | 3 |
fwrite(STDERR, sprintf("%2d %s ==> %s\n", $i + 1, $test, var_export($result, true))); | CWE-330 | 12 |
public function loginForm( WebRequest $request ) { // Step 13
$out = $this->getOutput();
$username = $request->getVal('username');
$codes = SOA2Login::codes( $username );
$out->addHTML(Html::openElement('form', [ 'method' => 'POST' ]));
$out->addHTML(Html::hidden('username', $username));
$out->addHTML(Html::hidden('token', $codes['csrf'])); // Step 14
$profile = Html::element(
'a',
[
'href' => sprintf(SOA2_PROFILE_URL, urlencode($username)),
'target' => '_new'
],
wfMessage('soa2-your-profile')->plain()
);
// Step 16
$out->addHTML(Html::rawElement(
'p', [],
wfMessage('soa2-vercode-explanation')->rawParams($profile)->parse()
));
$out->addHTML(Html::rawElement('p', [], Html::element(
'code', [], $codes['code']
)));
$out->addHTML(Html::rawElement('p', [], Html::submitButton(
wfMessage('soa2-login')->plain(), []
)));
$out->addHTML(Html::closeElement('form'));
} | CWE-863 | 11 |
private function decryptContentEncryptionKey($private_key_or_secret) {
switch ($this->header['alg']) {
case 'RSA1_5':
$rsa = $this->rsa($private_key_or_secret, RSA::ENCRYPTION_PKCS1);
$this->content_encryption_key = $rsa->decrypt($this->jwe_encrypted_key);
break;
case 'RSA-OAEP':
$rsa = $this->rsa($private_key_or_secret, RSA::ENCRYPTION_OAEP);
$this->content_encryption_key = $rsa->decrypt($this->jwe_encrypted_key);
break;
case 'dir':
$this->content_encryption_key = $private_key_or_secret;
break;
case 'A128KW':
case 'A256KW':
case 'ECDH-ES':
case 'ECDH-ES+A128KW':
case 'ECDH-ES+A256KW':
throw new JOSE_Exception_UnexpectedAlgorithm('Algorithm not supported');
default:
throw new JOSE_Exception_UnexpectedAlgorithm('Unknown algorithm');
}
if (!$this->content_encryption_key) {
# NOTE:
# Not to disclose timing difference between CEK decryption error and others.
# Mitigating Bleichenbacher Attack on PKCS#1 v1.5
# ref.) http://inaz2.hatenablog.com/entry/2016/01/26/222303
$this->generateContentEncryptionKey(null);
}
} | CWE-200 | 10 |
public function AddCC($address, $name = '') {
return $this->AddAnAddress('cc', $address, $name);
} | CWE-20 | 0 |
public function update_discount() {
$id = empty($this->params['id']) ? null : $this->params['id'];
$discount = new discounts($id);
// find required shipping method if needed
if ($this->params['required_shipping_calculator_id'] > 0) {
$this->params['required_shipping_method'] = $this->params['required_shipping_methods'][$this->params['required_shipping_calculator_id']];
} else {
$this->params['required_shipping_calculator_id'] = 0;
}
$discount->update($this->params);
expHistory::back();
} | CWE-74 | 1 |
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-74 | 1 |
public function chmod() {
if (!AuthUser::hasPermission('file_manager_chmod')) {
Flash::set('error', __('You do not have sufficient permissions to change the permissions on a file or directory.'));
redirect(get_url('plugin/file_manager/browse/'));
}
// CSRF checks
if (isset($_POST['csrf_token'])) {
$csrf_token = $_POST['csrf_token'];
if (!SecureToken::validateToken($csrf_token, BASE_URL.'plugin/file_manager/chmod')) {
Flash::set('error', __('Invalid CSRF token found!'));
redirect(get_url('plugin/file_manager/browse/'));
}
}
else {
Flash::set('error', __('No CSRF token found!'));
redirect(get_url('plugin/file_manager/browse/'));
}
$data = $_POST['file'];
$data['name'] = str_replace('..', '', $data['name']);
$file = FILES_DIR . '/' . $data['name'];
if (file_exists($file)) {
if (@!chmod($file, octdec($data['mode'])))
Flash::set('error', __('Permission denied!'));
}
else {
Flash::set('error', __('File or directory not found!'));
}
$path = substr($data['name'], 0, strrpos($data['name'], '/'));
redirect(get_url('plugin/file_manager/browse/' . $path));
} | CWE-20 | 0 |
function insertObject($object, $table) {
//if ($table=="text") eDebug($object,true);
$sql = "INSERT INTO `" . $this->prefix . "$table` (";
$values = ") VALUES (";
foreach (get_object_vars($object) as $var => $val) {
//We do not want to save any fields that start with an '_'
if ($var{0} != '_') {
$sql .= "`$var`,";
if ($values != ") VALUES (") {
$values .= ",";
}
$values .= "'" . $this->escapeString($val) . "'";
}
}
$sql = substr($sql, 0, -1) . substr($values, 0) . ")";
//if($table=='text')eDebug($sql,true);
if (@mysqli_query($this->connection, $sql) != false) {
$id = mysqli_insert_id($this->connection);
return $id;
} else
return 0;
} | CWE-74 | 1 |
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-200 | 10 |
protected function setUp()
{
static::$functions = [];
static::$fopen = null;
static::$fread = null;
parent::setUp();
$this->security = new ExposedSecurity();
$this->security->derivationIterations = 1000; // speed up test running
} | CWE-330 | 12 |
protected function forceChangePassword()
{
if (!Yii::$app->user->isMustChangePasswordUrl()) {
return Yii::$app->getResponse()->redirect(Url::toRoute(Yii::$app->user->mustChangePasswordRoute));
}
} | CWE-863 | 11 |
public function testGetDropdownValue($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::getDropdownValue($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-862 | 8 |
function showByModel() {
global $order, $template, $db;
expHistory::set('viewable', $this->params);
$product = new product();
$model = $product->find("first", 'model="' . $this->params['model'] . '"');
//eDebug($model);
$product_type = new $model->product_type($model->id);
//eDebug($product_type);
$tpl = $product_type->getForm('show');
if (!empty($tpl)) $template = new controllertemplate($this, $tpl);
//eDebug($template);
$this->grabConfig(); // grab the global config
assign_to_template(array(
'config' => $this->config,
'product' => $product_type,
'last_category' => $order->lastcat
));
} | CWE-20 | 0 |
public function setItemAttributes( $attributes ) {
$this->itemAttributes = \Sanitizer::fixTagAttributes( $attributes, 'li' );
} | CWE-400 | 2 |
function categoryBreadcrumb() {
// global $db, $router;
//eDebug($this->category);
/*if(isset($router->params['action']))
{
$ancestors = $this->category->pathToNode();
}else if(isset($router->params['section']))
{
$current = $db->selectObject('section',' id= '.$router->params['section']);
$ancestors[] = $current;
if( $current->parent != -1 || $current->parent != 0 )
{
while ($db->selectObject('section',' id= '.$router->params['section']);)
if ($section->id == $id) {
$current = $section;
break;
}
}
}
eDebug($sections);
$ancestors = $this->category->pathToNode();
}*/
$ancestors = $this->category->pathToNode();
// eDebug($ancestors);
assign_to_template(array(
'ancestors' => $ancestors
));
} | CWE-74 | 1 |
$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-74 | 1 |
foreach($paths as $path)
{
// Convert wild-cards to RegEx
$path = str_replace(array(':any', '*'), '.*', str_replace(':num', '[0-9]+', $path));
// Does the RegEx match?
if (!empty($_SERVER['HTTP_HOST']) AND preg_match('#^'.$path.'$#', $_SERVER['HTTP_HOST']))
{
define('ENVIRONMENT', $env);
break 2;
}
} | CWE-74 | 1 |
public function checkRedirect(RequestInterface $request, array $options, ResponseInterface $response)
{
if (\strpos((string) $response->getStatusCode(), '3') !== 0
|| !$response->hasHeader('Location')
) {
return $response;
}
$this->guardMax($request, $response, $options);
$nextRequest = $this->modifyRequest($request, $options, $response);
// If authorization is handled by curl, unset it if host is different.
if ($request->getUri()->getHost() !== $nextRequest->getUri()->getHost()
&& defined('\CURLOPT_HTTPAUTH')
) {
unset(
$options['curl'][\CURLOPT_HTTPAUTH],
$options['curl'][\CURLOPT_USERPWD]
);
}
if (isset($options['allow_redirects']['on_redirect'])) {
($options['allow_redirects']['on_redirect'])(
$request,
$response,
$nextRequest->getUri()
);
}
$promise = $this($nextRequest, $options);
// Add headers to be able to track history of redirects.
if (!empty($options['allow_redirects']['track_redirects'])) {
return $this->withTracking(
$promise,
(string) $nextRequest->getUri(),
$response->getStatusCode()
);
}
return $promise;
} | CWE-200 | 10 |
private function _allrevisionsbefore( $option ) {
$this->addTable( 'revision_actor_temp', 'rev' );
$this->addSelect(
[
'rev.revactor_rev',
'rev.revactor_timestamp'
]
);
$this->addOrderBy( 'rev.revactor_rev' );
$this->setOrderDir( 'DESC' );
$this->addWhere(
[
$this->tableNames['page'] . '.page_id = rev.revactor_page',
'rev.revactor_timestamp < ' . $this->convertTimestamp( $option )
]
);
} | CWE-400 | 2 |
$eml->prepareBody();
}
list ($success, $message) = $this->checkDoNotEmailFields ($eml);
if (!$success) {
return array ($success, $message);
}
$result = $eml->send($historyFlag);
if (isset($result['code']) && $result['code'] == 200) {
if (YII_UNIT_TESTING) {
return array(true, $eml->message);
} else {
return array(true, "");
}
} else {
return array (false, Yii::t('app', "Email could not be sent"));
}
} | CWE-20 | 0 |
public function search(){
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria = new CDbCriteria;
$username = Yii::app()->user->name;
$criteria->addCondition("uploadedBy='$username' OR private=0 OR private=null");
$criteria->addCondition("associationType != 'theme'");
return $this->searchBase($criteria);
} | CWE-20 | 0 |
$chats[$index]->link = erLhcoreClassXMP::getBaseHost() . $_SERVER['HTTP_HOST'] . erLhcoreClassDesign::baseurl('user/login').'/(r)/'.rawurlencode(base64_encode('chat/single/'.$chat->id));
}
} | CWE-116 | 15 |
static function isSearchable() { return true; }
| CWE-74 | 1 |
function XMLRPCremoveResourceGroupPriv($name, $type, $nodeid, $permissions){
require_once(".ht-inc/privileges.php");
global $user;
if(! checkUserHasPriv("resourceGrant", $user['id'], $nodeid)){
return array('status' => 'error',
'errorcode' => 53,
'errormsg' => 'Unable to remove group privileges on this node');
}
if($typeid = getResourceTypeID($type)){
if(!checkForGroupName($name, 'resource', '', $typeid)){
return array('status' => 'error',
'errorcode' => 28,
'errormsg' => 'resource group does not exist');
}
$perms = explode(':', $permissions);
updateResourcePrivs("$type/$name", $nodeid, array(), $perms);
return array('status' => 'success');
} else {
return array('status' => 'error',
'errorcode' => 56,
'errormsg' => 'Invalid resource type');
}
} | CWE-20 | 0 |
$tableDetails = ['tableName' => $tableName, 'entityIdColumn' => $entityIdColumn]; | CWE-863 | 11 |
private function generateFakeFileData()
{
return [
'name' => md5(mt_rand()),
'tmp_name' => md5(mt_rand()),
'type' => 'image/jpeg',
'size' => mt_rand(1000, 10000),
'error' => '0',
];
} | CWE-330 | 12 |
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-74 | 1 |
public static function hasChildren($i) {
global $sections;
if (($i + 1) >= count($sections)) return false;
return ($sections[$i]->depth < $sections[$i + 1]->depth) ? true : false;
}
| CWE-74 | 1 |
public function chmod() {
if (!AuthUser::hasPermission('file_manager_chmod')) {
Flash::set('error', __('You do not have sufficient permissions to change the permissions on a file or directory.'));
redirect(get_url('plugin/file_manager/browse/'));
}
// CSRF checks
if (isset($_POST['csrf_token'])) {
$csrf_token = $_POST['csrf_token'];
if (!SecureToken::validateToken($csrf_token, BASE_URL.'plugin/file_manager/chmod')) {
Flash::set('error', __('Invalid CSRF token found!'));
redirect(get_url('plugin/file_manager/browse/'));
}
}
else {
Flash::set('error', __('No CSRF token found!'));
redirect(get_url('plugin/file_manager/browse/'));
}
$data = $_POST['file'];
$data['name'] = str_replace('..', '', $data['name']);
$file = FILES_DIR . '/' . $data['name'];
if (file_exists($file)) {
if (@!chmod($file, octdec($data['mode'])))
Flash::set('error', __('Permission denied!'));
}
else {
Flash::set('error', __('File or directory not found!'));
}
$path = substr($data['name'], 0, strrpos($data['name'], '/'));
redirect(get_url('plugin/file_manager/browse/' . $path));
} | CWE-20 | 0 |
public function settings() {
AuthUser::load();
if (!AuthUser::isLoggedIn()) {
redirect(get_url('login'));
} else if (!AuthUser::hasPermission('admin_edit')) {
Flash::set('error', __('You do not have permission to access the requested page!'));
redirect(get_url());
}
$settings = Plugin::getAllSettings('file_manager');
if (!$settings) {
Flash::set('error', 'Files - ' . __('unable to retrieve plugin settings.'));
return;
}
$this->display('file_manager/views/settings', array('settings' => $settings));
} | CWE-20 | 0 |
public function approve_toggle() {
if (empty($this->params['id'])) return;
/* 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'];
$comment = new expComment($this->params['id']);
$comment->approved = $comment->approved == 1 ? 0 : 1;
if ($comment->approved) {
$this->sendApprovalNotification($comment,$this->params);
}
$comment->save();
expHistory::back();
} | CWE-74 | 1 |
public function Close() {
$this->error = null; // so there is no confusion
$this->helo_rply = null;
if(!empty($this->smtp_conn)) {
// close the connection and cleanup
fclose($this->smtp_conn);
$this->smtp_conn = 0;
}
} | CWE-20 | 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-74 | 1 |
function check_file_dir_name($label) {
if (empty($label) || preg_match('/[^A-Za-z0-9_.-]/', $label))
die(xlt("ERROR: The following variable contains invalid characters").": ". attr($label));
} | CWE-116 | 15 |
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-200 | 10 |
public function setRemoteUrl($name, $url, array $params = NULL)
{
$this->run('remote', 'set-url', $params, $name, $url);
return $this;
} | CWE-77 | 14 |
private function checkAuthenticationTag() {
if ($this->authentication_tag === $this->calculateAuthenticationTag()) {
return true;
} else {
throw new JOSE_Exception_UnexpectedAlgorithm('Invalid authentication tag');
}
} | CWE-200 | 10 |
static function convertUTF($string) {
return $string = str_replace('?', '', htmlspecialchars($string, ENT_IGNORE, 'UTF-8'));
} | CWE-74 | 1 |
public function execute(&$params){
$action = new Actions;
$action->associationType = lcfirst(get_class($params['model']));
$action->associationId = $params['model']->id;
$action->subject = $this->parseOption('subject', $params);
$action->actionDescription = $this->parseOption('description', $params);
if($params['model']->hasAttribute('assignedTo'))
$action->assignedTo = $params['model']->assignedTo;
if($params['model']->hasAttribute('priority'))
$action->priority = $params['model']->priority;
if($params['model']->hasAttribute('visibility'))
$action->visibility = $params['model']->visibility;
if ($action->save()) {
return array (
true,
Yii::t('studio', "View created action: ").$action->getLink ()
);
} else {
return array(false, array_shift($action->getErrors()));
}
} | CWE-20 | 0 |
public function testDecrypt($expected, $key, $string) {
$this->string(\Toolbox::decrypt($string, $key))->isIdenticalTo($expected);
} | CWE-327 | 3 |
public function renameTag($oldName, $newName)
{
// http://stackoverflow.com/a/1873932
// create new as alias to old (`git tag NEW OLD`)
$this->run('tag', $newName, $oldName);
// delete old (`git tag -d OLD`)
$this->removeTag($oldName);
return $this;
} | CWE-77 | 14 |
public function activate_discount(){
if (isset($this->params['id'])) {
$discount = new discounts($this->params['id']);
$discount->update($this->params);
//if ($discount->discountulator->hasConfig() && empty($discount->config)) {
//flash('messages', $discount->discountulator->name().' requires configuration. Please do so now.');
//redirect_to(array('controller'=>'billing', 'action'=>'configure', 'id'=>$discount->id));
//}
}
expHistory::back();
} | CWE-74 | 1 |
static function getRSSFeed($url, $cache_duration = DAY_TIMESTAMP) {
global $CFG_GLPI;
$feed = new SimplePie();
$feed->set_cache_location(GLPI_RSS_DIR);
$feed->set_cache_duration($cache_duration);
// proxy support
if (!empty($CFG_GLPI["proxy_name"])) {
$prx_opt = [];
$prx_opt[CURLOPT_PROXY] = $CFG_GLPI["proxy_name"];
$prx_opt[CURLOPT_PROXYPORT] = $CFG_GLPI["proxy_port"];
if (!empty($CFG_GLPI["proxy_user"])) {
$prx_opt[CURLOPT_HTTPAUTH] = CURLAUTH_ANYSAFE;
$prx_opt[CURLOPT_PROXYUSERPWD] = $CFG_GLPI["proxy_user"].":".
Toolbox::decrypt($CFG_GLPI["proxy_passwd"],
GLPIKEY);
}
$feed->set_curl_options($prx_opt);
}
$feed->enable_cache(true);
$feed->set_feed_url($url);
$feed->force_feed(true);
// Initialize the whole SimplePie object. Read the feed, process it, parse it, cache it, and
// all that other good stuff. The feed's information will not be available to SimplePie before
// this is called.
$feed->init();
// We'll make sure that the right content type and character encoding gets set automatically.
// This function will grab the proper character encoding, as well as set the content type to text/html.
$feed->handle_content_type();
if ($feed->error()) {
return false;
}
return $feed;
} | CWE-327 | 3 |
public function browse() {
$params = func_get_args();
$this->path = join('/', $params);
// make sure there's a / at the end
if (substr($this->path, -1, 1) != '/')
$this->path .= '/';
//security
// we dont allow back link
if (strpos($this->path, '..') !== false) {
/*
if (Plugin::isEnabled('statistics_api')) {
$user = null;
if (AuthUser::isLoggedIn())
$user = AuthUser::getUserName();
$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : ($_SERVER['REMOTE_ADDR']);
$event = array('event_type' => 'hack_attempt', // simple event type identifier
'description' => __('A possible hack attempt was detected.'), // translatable description
'ipaddress' => $ip,
'username' => $user);
Observer::notify('stats_file_manager_hack_attempt', $event);
}
*/
}
$this->path = str_replace('..', '', $this->path);
// clean up nicely
$this->path = str_replace('//', '', $this->path);
// we dont allow leading slashes
$this->path = preg_replace('/^\//', '', $this->path);
$this->fullpath = FILES_DIR . '/' . $this->path;
// clean up nicely
$this->fullpath = preg_replace('/\/\//', '/', $this->fullpath);
$this->display('file_manager/views/index', array(
'dir' => $this->path,
//'files' => $this->_getListFiles()
'files' => $this->_listFiles()
));
} | CWE-20 | 0 |
static function authenticate() {
if (isset($_REQUEST['backend_login'])) {
$user = DB_DataObject::factory('users');
$user->active = true;
$user->name = $_REQUEST['username'];
$user->find(true);
// Don't look whether that user exists, so we give less timing information
// Instead, rely only on having a matching password
$proffered_password = $_REQUEST['password'];
if (in_array(
$user->password,
self::password_hashes($proffered_password, $user->password_salt)
)) {
// Regenerate the session ID, unless it's an IE we're talking to which would use the old session ID to load the frame contents
// Remove this guard once we no longer use frames
if(!preg_match('/(?i)msie /', $_SERVER['HTTP_USER_AGENT'])) {
session_regenerate_id();
}
$user->login();
return $user;
} else {
Log::warn("Failed login for user name '".$_REQUEST['username']."' from " . $_SERVER['REMOTE_ADDR'].' user-agent '.$_SERVER['HTTP_USER_AGENT']);
return -1;
}
}
return false;
} | CWE-522 | 19 |
$comments->records[$key]->avatar = $db->selectObject('user_avatar',"user_id='".$record->poster."'");
}
if (empty($this->params['config']['disable_nested_comments'])) $comments->records = self::arrangecomments($comments->records);
// eDebug($sql, true);
// count the unapproved comments
if ($require_approval == 1 && $user->isAdmin()) {
$sql = 'SELECT count(com.id) as c FROM '.$db->prefix.'expComments com ';
$sql .= 'JOIN '.$db->prefix.'content_expComments cnt ON com.id=cnt.expcomments_id ';
$sql .= 'WHERE cnt.content_id='.$this->params['content_id']." AND cnt.content_type='".$this->params['content_type']."' ";
$sql .= 'AND com.approved=0';
$unapproved = $db->countObjectsBySql($sql);
} else {
$unapproved = 0;
}
$this->config = $this->params['config'];
$type = !empty($this->params['type']) ? $this->params['type'] : gt('Comment');
$ratings = !empty($this->params['ratings']) ? true : false;
assign_to_template(array(
'comments'=>$comments,
'config'=>$this->params['config'],
'unapproved'=>$unapproved,
'content_id'=>$this->params['content_id'],
'content_type'=>$this->params['content_type'],
'user'=>$user,
'hideform'=>$this->params['hideform'],
'hidecomments'=>$this->params['hidecomments'],
'title'=>$this->params['title'],
'formtitle'=>$this->params['formtitle'],
'type'=>$type,
'ratings'=>$ratings,
'require_login'=>$require_login,
'require_approval'=>$require_approval,
'require_notification'=>$require_notification,
'notification_email'=>$notification_email,
));
} | CWE-74 | 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-74 | 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-200 | 10 |
public function testSmtpConnect()
{
$this->Mail->SMTPDebug = 4; //Show connection-level errors
$this->assertTrue($this->Mail->smtpConnect(), 'SMTP single connect failed');
$this->Mail->smtpClose();
$this->Mail->Host = "ssl://localhost:12345;tls://localhost:587;10.10.10.10:54321;localhost:12345;10.10.10.10";
$this->assertFalse($this->Mail->smtpConnect(), 'SMTP bad multi-connect succeeded');
$this->Mail->smtpClose();
$this->Mail->Host = "localhost:12345;10.10.10.10:54321;" . $_REQUEST['mail_host'];
$this->assertTrue($this->Mail->smtpConnect(), 'SMTP multi-connect failed');
$this->Mail->smtpClose();
$this->Mail->Host = " localhost:12345 ; " . $_REQUEST['mail_host'] . ' ';
$this->assertTrue($this->Mail->smtpConnect(), 'SMTP hosts with stray spaces failed');
$this->Mail->smtpClose();
$this->Mail->Host = $_REQUEST['mail_host'];
//Need to pick a harmless option so as not cause problems of its own! socket:bind doesn't work with Travis-CI
$this->assertTrue(
$this->Mail->smtpConnect(array('ssl' => array('verify_depth' => 10))),
'SMTP connect with options failed'
);
} | CWE-20 | 0 |
foreach ($allgroups as $gid) {
$g = group::getGroupById($gid);
expPermissions::grantGroup($g, 'manage', $sloc);
}
| CWE-74 | 1 |
static function author() {
return "Dave Leffler";
}
| CWE-74 | 1 |
public function subscriptions() {
global $db;
expHistory::set('manageable', $this->params);
// make sure we have what we need.
if (empty($this->params['key'])) expQueue::flashAndFlow('error', gt('The security key for account was not supplied.'));
if (empty($this->params['id'])) expQueue::flashAndFlow('error', gt('The subscriber id for account was not supplied.'));
// verify the id/key pair
$sub = new subscribers($this->params['id']);
if (empty($sub->id)) expQueue::flashAndFlow('error', gt('We could not find any subscriptions matching the ID and Key you provided.'));
// get this users subscriptions
$subscriptions = $db->selectColumn('expeAlerts_subscribers', 'expeAlerts_id', 'subscribers_id='.$sub->id);
// get a list of all available E-Alerts
$ealerts = new expeAlerts();
assign_to_template(array(
'subscriber'=>$sub,
'subscriptions'=>$subscriptions,
'ealerts'=>$ealerts->find('all')
));
} | CWE-74 | 1 |
public function edit()
{
if((isset($this->params['id']))) $record = new address(intval($this->params['id']));
else $record = null;
$config = ecomconfig::getConfig('address_allow_admins_all');
assign_to_template(array(
'record'=>$record,
'admin_config'=>$config
));
if (expSession::get('customer-signup')) {
assign_to_template(array(
'checkout'=>true
));
}
} | CWE-200 | 10 |
function headerTestController($serverPort) {
$args = array('Authorization' => 'foo');
var_dump(request(php_uname('n'), $serverPort, "test_headers.php",
[], ['PROXY' => 'foobar'], $args));
} | CWE-668 | 7 |
public function addSelect( $fields ) {
if ( !is_array( $fields ) ) {
throw new \MWException( __METHOD__ . ': A non-array was passed.' );
}
foreach ( $fields as $alias => $field ) {
if ( !is_numeric( $alias ) && array_key_exists( $alias, $this->select ) && $this->select[$alias] != $field ) {
//In case of a code bug that is overwriting an existing field alias throw an exception.
throw new \MWException( __METHOD__ . ": Attempted to overwrite existing field alias `{$this->select[$alias]}` AS `{$alias}` with `{$field}` AS `{$alias}`." );
}
//String alias and does not exist already.
if ( !is_numeric( $alias ) && !array_key_exists( $alias, $this->select ) ) {
$this->select[$alias] = $field;
}
//Speed up by not using in_array() or array_key_exists(). Toss the field names into their own array as keys => true to exploit a speedy look up with isset().
if ( is_numeric( $alias ) && !isset( $this->selectedFields[$field] ) ) {
$this->select[] = $field;
$this->selectedFields[$field] = true;
}
}
return true;
} | CWE-400 | 2 |
static function dropdownConnect($itemtype, $fromtype, $myname, $entity_restrict = -1,
$onlyglobal = 0, $used = []) {
global $CFG_GLPI;
$rand = mt_rand();
$field_id = Html::cleanId("dropdown_".$myname.$rand);
$param = [
'entity_restrict' => $entity_restrict,
'fromtype' => $fromtype,
'itemtype' => $itemtype,
'onlyglobal' => $onlyglobal,
'used' => $used,
'_idor_token' => Session::getNewIDORToken($itemtype),
];
echo Html::jsAjaxDropdown($myname, $field_id,
$CFG_GLPI['root_doc']."/ajax/getDropdownConnect.php",
$param);
return $rand;
} | CWE-862 | 8 |
function move_standalone() {
expSession::clearAllUsersSessionCache('navigation');
assign_to_template(array(
'parent' => $this->params['parent'],
));
}
| CWE-74 | 1 |