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...
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...
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')) { ...
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))) { ...
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...
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; retur...
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...
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}'"); $ct...
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', ...
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->pref...
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 = su...
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/'.$controllerNam...
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), 'control...
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 '</...
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) { ...
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])) { $...
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'] . "...
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,'str...
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($objec...
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->getCoupon...
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 succ...
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 (...
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( '}', '',...
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...
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']) ? SIMPL...
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_PREF...
CWE-74
1
function productFeed() { // global $db; //check query password to avoid DDOS /* * condition = new * description * id - SKU * link * price * title * brand - manufacturer ...
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...
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); ...
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_metho...
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('D...
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 ...
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 ...
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->act...
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])) { $bk...
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...
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->select...
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 { ...
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);...
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, $res...
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'] ....
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) { ...
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"); ...
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'...
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 ...
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 ...
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...
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['re...
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 ...
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_creat...
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...
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', $di...
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 = []; ...
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, '...
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 les...
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 ...
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_bill...
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;l...
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->par...
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'=>$co...
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 o...
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' => ...
CWE-862
8
function move_standalone() { expSession::clearAllUsersSessionCache('navigation'); assign_to_template(array( 'parent' => $this->params['parent'], )); }
CWE-74
1