code
stringlengths 23
2.05k
| label_name
stringlengths 6
7
| label
int64 0
37
|
---|---|---|
$stmt->bindValue(":$field", $domain, SQLITE3_TEXT);
if($bindcomment) {
$stmt->bindValue(":comment", $comment, SQLITE3_TEXT);
}
if($stmt->execute() && $stmt->reset())
$num++;
else
{
$stmt->close();
if($returnnum)
return $num;
else
{
if($num === 1)
$plural = "";
else
$plural = "s";
return "Error: ".$db->lastErrorMsg().", added ".$num." domain".$plural;
}
}
}
// Close prepared statement and return number of processed rows
$stmt->close();
$db->exec("COMMIT;");
if($returnnum)
return $num;
else
{
$finalcount = intval($db->querySingle($countquery));
$modified = $finalcount - $initialcount;
// If we add less domains than the user specified, then they wanted to add duplicates
if($modified !== $num)
{
$delta = $num - $modified;
$extra = " (skipped ".$delta." duplicates)";
}
else
{
$extra = "";
}
if($num === 1)
$plural = "";
else
$plural = "s";
return "Success, added ".$modified." of ".$num." domain".$plural.$extra;
}
} | CWE-862 | 8 |
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-200 | 10 |
public function editspeed() {
global $db;
if (empty($this->params['id'])) return false;
$calcname = $db->selectValue('shippingcalculator', 'calculator_name', 'id='.$this->params['id']);
$calc = new $calcname($this->params['id']);
assign_to_template(array(
'calculator'=>$calc
));
} | CWE-74 | 1 |
} elseif ( $rowSize > 0 ) {
// repeat row header after n lines of output
$nstart = 0;
$nsize = $rowSize;
$count = count( $articles );
$output .= '{|' . $rowColFormat . "\n|\n";
do {
if ( $nstart + $nsize > $count ) {
$nsize = $count - $nstart;
}
$output .= $lister->formatList( $articles, $nstart, $nsize );
$output .= "\n|-\n|\n";
$nstart = $nstart + $nsize;
if ( $nstart >= $count ) {
break;
}
} while ( true );
$output .= "\n|}\n";
} else { | CWE-400 | 2 |
$module_views[$key]['name'] = gt($value['name']);
}
// look for a config form for this module's current view
// $controller->loc->mod = expModules::getControllerClassName($controller->loc->mod);
//check to see if hcview was passed along, indicating a hard-coded module
// if (!empty($controller->params['hcview'])) {
// $viewname = $controller->params['hcview'];
// } else {
// $viewname = $db->selectValue('container', 'view', "internal='".serialize($controller->loc)."'");
// }
// $viewconfig = $viewname.'.config';
// foreach ($modpaths as $path) {
// if (file_exists($path.'/'.$viewconfig)) {
// $fileparts = explode('_', $viewname);
// if ($fileparts[0]=='show'||$fileparts[0]=='showall') array_shift($fileparts);
// $module_views[$viewname]['name'] = ucwords(implode(' ', $fileparts)).' '.gt('View Configuration');
// $module_views[$viewname]['file'] =$path.'/'.$viewconfig;
// }
// }
// sort the views highest to lowest by filename
// we are reverse sorting now so our array merge
// will overwrite property..we will run array_reverse
// when we're finished to get them back in the right order
krsort($common_views);
krsort($module_views);
if (!empty($moduleconfig)) $common_views = array_merge($common_views, $moduleconfig);
$views = array_merge($common_views, $module_views);
$views = array_reverse($views);
return $views;
} | CWE-74 | 1 |
public function actionGetItems(){
$sql = 'SELECT id, name as value FROM x2_docs WHERE name LIKE :qterm ORDER BY name ASC';
$command = Yii::app()->db->createCommand($sql);
$qterm = '%'.$_GET['term'].'%';
$command->bindParam(":qterm", $qterm, PDO::PARAM_STR);
$result = $command->queryAll();
echo CJSON::encode($result); exit;
} | CWE-20 | 0 |
static public function deleteCategory($_id = 0) {
if ($_id != 0) {
$result_stmt = Database::prepare("
SELECT COUNT(`id`) as `numtickets` FROM `" . TABLE_PANEL_TICKETS . "`
WHERE `category` = :cat"
);
$result = Database::pexecute_first($result_stmt, array('cat' => $_id));
if ($result['numtickets'] == "0") {
$del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_TICKET_CATS . "` WHERE `id` = :id"
);
Database::pexecute($del_stmt, array('id' => $_id));
return true;
} else {
return false;
}
}
return false;
} | CWE-732 | 13 |
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-74 | 1 |
public function save_change_password() {
global $user;
$isuser = ($this->params['uid'] == $user->id) ? 1 : 0;
if (!$user->isAdmin() && !$isuser) {
flash('error', gt('You do not have permissions to change this users password.'));
expHistory::back();
}
if (($isuser && empty($this->params['password'])) || (!empty($this->params['password']) && $user->password != user::encryptPassword($this->params['password']))) {
flash('error', gt('The current password you entered is not correct.'));
expHistory::returnTo('editable');
}
//eDebug($user);
$u = new user($this->params['uid']);
$ret = $u->setPassword($this->params['new_password1'], $this->params['new_password2']);
//eDebug($u, true);
if (is_string($ret)) {
flash('error', $ret);
expHistory::returnTo('editable');
} else {
$params = array();
$params['is_admin'] = !empty($u->is_admin);
$params['is_acting_admin'] = !empty($u->is_acting_admin);
$u->update($params);
}
if (!$isuser) {
flash('message', gt('The password for') . ' ' . $u->username . ' ' . gt('has been changed.'));
} else {
$user->password = $u->password;
flash('message', gt('Your password has been changed.'));
}
expHistory::back();
} | CWE-74 | 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-74 | 1 |
function edit() {
global $user;
/* 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['formtitle']))
{
if (empty($this->params['id']))
{
$formtitle = gt("Add New Note");
}
else
{
$formtitle = gt("Edit Note");
}
}
else
{
$formtitle = $this->params['formtitle'];
}
$id = empty($this->params['id']) ? null : $this->params['id'];
$simpleNote = new expSimpleNote($id);
//FIXME here is where we might sanitize the note before displaying/editing it
assign_to_template(array(
'simplenote'=>$simpleNote,
'user'=>$user,
'require_login'=>$require_login,
'require_approval'=>$require_approval,
'require_notification'=>$require_notification,
'notification_email'=>$notification_email,
'formtitle'=>$formtitle,
'content_type'=>$this->params['content_type'],
'content_id'=>$this->params['content_id'],
'tab'=>empty($this->params['tab'])?0:$this->params['tab']
));
} | CWE-74 | 1 |
function XMLRPCremoveImageGroupFromComputerGroup($imageGroup, $computerGroup){
$imageid = getResourceGroupID("image/$imageGroup");
$compid = getResourceGroupID("computer/$computerGroup");
if($imageid && $compid){
$tmp = getUserResources(array("imageAdmin"),
array("manageMapping"), 1);
$imagegroups = $tmp['image'];
$tmp = getUserResources(array("computerAdmin"),
array("manageMapping"), 1);
$computergroups = $tmp['computer'];
if(array_key_exists($compid, $computergroups) &&
array_key_exists($imageid, $imagegroups)){
$mapping = getResourceMapping("image", "computer",
$imageid,
$compid);
if(array_key_exists($imageid, $mapping) &&
array_key_exists($compid, $mapping[$imageid])){
$query = "DELETE FROM resourcemap "
. "WHERE resourcegroupid1 = $imageid AND "
. "resourcetypeid1 = 13 AND "
. "resourcegroupid2 = $compid AND "
. "resourcetypeid2 = 12";
doQuery($query, 101);
}
return array('status' => 'success');
} else {
return array('status' => 'error',
'errorcode' => 84,
'errormsg' => 'cannot access computer and/or image group');
}
} else {
return array('status' => 'error',
'errorcode' => 83,
'errormsg' => 'invalid resource group name');
}
} | CWE-20 | 0 |
function send_feedback() {
$success = false;
if (isset($this->params['id'])) {
$ed = new eventdate($this->params['id']);
// $email_addrs = array();
if ($ed->event->feedback_email != '') {
$msgtemplate = expTemplate::get_template_for_action($this, 'email/_' . $this->params['formname'], $this->loc);
$msgtemplate->assign('params', $this->params);
$msgtemplate->assign('event', $ed);
$email_addrs = explode(',', $ed->event->feedback_email);
//This is an easy way to remove duplicates
$email_addrs = array_flip(array_flip($email_addrs));
$email_addrs = array_map('trim', $email_addrs);
$mail = new expMail();
$success += $mail->quickSend(array(
"text_message" => $msgtemplate->render(),
'to' => $email_addrs,
'from' => !empty($this->params['email']) ? $this->params['email'] : trim(SMTP_FROMADDRESS),
'subject' => $this->params['subject'],
));
}
}
if ($success) {
flashAndFlow('message', gt('Your feedback was successfully sent.'));
} else {
flashAndFlow('error', gt('We could not send your feedback. Please contact your administrator.'));
}
}
| CWE-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 |
Variables::setVar( [ '', '', $argName, $argValue ] );
if ( defined( 'ExtVariables::VERSION' ) ) {
\ExtVariables::get( $this->parser )->setVarValue( $argName, $argValue );
}
}
} | CWE-400 | 2 |
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-74 | 1 |
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-200 | 10 |
public static function getHelpVersionId($version) {
global $db;
return $db->selectValue('help_version', 'id', 'version="'.$version.'"');
} | CWE-74 | 1 |
protected function tearDown()
{
static::$functions = [];
static::$fopen = null;
static::$fread = null;
parent::tearDown();
} | CWE-330 | 12 |
public function Hello($host = '') {
$this->error = null; // so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Hello() without being connected");
return false;
}
// if hostname for HELO was not specified send default
if(empty($host)) {
// determine appropriate default to send to server
$host = "localhost";
}
// Send extended hello first (RFC 2821)
if(!$this->SendHello("EHLO", $host)) {
if(!$this->SendHello("HELO", $host)) {
return false;
}
}
return true;
} | CWE-20 | 0 |
public function execute(&$params){
$model = new Actions;
$model->type = 'note';
$model->complete = 'Yes';
$model->associationId = $params['model']->id;
$model->associationType = $params['model']->module;
$model->actionDescription = $this->parseOption('comment', $params);
$model->assignedTo = $this->parseOption('assignedTo', $params);
$model->completedBy = $this->parseOption('assignedTo', $params);
if(empty($model->assignedTo) && $params['model']->hasAttribute('assignedTo')){
$model->assignedTo = $params['model']->assignedTo;
$model->completedBy = $params['model']->assignedTo;
}
if($params['model']->hasAttribute('visibility'))
$model->visibility = $params['model']->visibility;
$model->createDate = time();
$model->completeDate = time();
if($model->save()){
return array(
true,
Yii::t('studio', 'View created action: ').$model->getLink());
}else{
return array(false, array_shift($model->getErrors()));
}
} | CWE-20 | 0 |
unset($sql, $parameters, $row);
}
//download compressed file
if (@sizeof($email_files) != 0) {
//define compressed file name
$compressed_filename = 'emails_'.date('Ymd_His').'.zip';
//compress email files
$command = 'zip -mj '.$_SESSION['server']['temp']['dir'].'/'.$compressed_filename.' '.implode(' ', $email_files).' 2>&1';
exec($command, $response, $restore_errlevel);
unset($command);
//push download
if (file_exists($_SESSION['server']['temp']['dir'].'/'.$compressed_filename)) {
//open file
session_cache_limiter('public');
$fd = fopen($_SESSION['server']['temp']['dir'].'/'.$compressed_filename, 'rb');
//set headers
header("Content-Type: application/zip");
header('Content-Disposition: attachment; filename="'.$compressed_filename.'"');
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Content-Length: ".filesize($_SESSION['server']['temp']['dir'].'/'.$compressed_filename));
//output file content
ob_clean();
fpassthru($fd);
fclose($fd);
//remove compressed file
@unlink($_SESSION['server']['temp']['dir'].'/'.$compressed_filename);
exit;
}
}
}
}
}
} //method | CWE-77 | 14 |
public function getAcl($node) {
if (is_string($node)) {
$node = $this->server->tree->getNodeForPath($node);
}
$acl = parent::getAcl($node);
// Authenticated user have read access to all nodes, as node list only contains elements
// that user can read.
$acl[] = [
'principal' => '{DAV:}authenticated',
'privilege' => '{DAV:}read',
'protected' => true,
];
if ($node instanceof Calendar && \Session::haveRight(\PlanningExternalEvent::$rightname, UPDATE)) {
// If user can update external events, then he is able to write on calendar to create new events.
$acl[] = [
'principal' => '{DAV:}authenticated',
'privilege' => '{DAV:}write',
'protected' => true,
];
} else if ($node instanceof CalendarObject) {
$item = $this->getCalendarItemForPath($node->getName());
if ($item instanceof \CommonDBTM && $item->can($item->fields['id'], UPDATE)) {
$acl[] = [
'principal' => '{DAV:}authenticated',
'privilege' => '{DAV:}write',
'protected' => true,
];
}
}
return $acl;
} | CWE-862 | 8 |
public function setModelAttributes(&$model,&$attributeList,&$params) {
$data = array ();
foreach($attributeList as &$attr) {
if(!isset($attr['name'],$attr['value']))
continue;
if(null !== $field = $model->getField($attr['name'])) {
// first do variable/expression evaluation, // then process with X2Fields::parseValue()
$type = $field->type;
$value = $attr['value'];
if(is_string($value)){
if(strpos($value, '=') === 0){
$evald = X2FlowFormatter::parseFormula($value, $params);
if(!$evald[0])
return false;
$value = $evald[1];
} elseif($params !== null){
if(is_string($value) && isset($params['model'])){
$value = X2FlowFormatter::replaceVariables(
$value, $params['model'], $type);
}
}
}
$data[$attr['name']] = $value;
}
}
if (!isset ($model->scenario))
$model->setScenario ('X2Flow');
$model->setX2Fields ($data);
if ($model instanceof Actions && isset($data['complete'])) {
switch($data['complete']) {
case 'Yes':
$model->complete();
break;
case 'No':
$model->uncomplete();
break;
}
}
return true;
} | CWE-20 | 0 |
$rst[$key] = self::parseAndTrim($st, $unescape);
}
return $rst;
}
$str = str_replace("<br>"," ",$str);
$str = str_replace("</br>"," ",$str);
$str = str_replace("<br/>"," ",$str);
$str = str_replace("<br />"," ",$str);
$str = str_replace("\r\n"," ",$str);
$str = str_replace('"',""",$str);
$str = str_replace("'","'",$str);
$str = str_replace("’","’",$str);
$str = str_replace("‘","‘",$str);
$str = str_replace("®","®",$str);
$str = str_replace("–","-", $str);
$str = str_replace("—","—", $str);
$str = str_replace("”","”", $str);
$str = str_replace("“","“", $str);
$str = str_replace("¼","¼",$str);
$str = str_replace("½","½",$str);
$str = str_replace("¾","¾",$str);
$str = str_replace("™","™", $str);
$str = trim($str);
if ($unescape) {
$str = stripcslashes($str);
} else {
$str = addslashes($str);
}
return $str;
} | CWE-74 | 1 |
public function update_groupdiscounts() {
global $db;
if (empty($this->params['id'])) {
// look for existing discounts for the same group
$existing_id = $db->selectValue('groupdiscounts', 'id', 'group_id='.$this->params['group_id']);
if (!empty($existing_id)) flashAndFlow('error',gt('There is already a discount for that group.'));
}
$gd = new groupdiscounts();
$gd->update($this->params);
expHistory::back();
} | CWE-74 | 1 |
protected function tearDown()
{
static::$functions = [];
static::$fopen = null;
static::$fread = null;
parent::tearDown();
} | CWE-330 | 12 |
protected function doDBUpdates() {
$title = Title::newFromText( 'Template:Extension DPL' );
// Make sure template does not already exist
if ( !$title->exists() ) {
$wikipage = WikiPage::factory( $title );
$updater = $wikipage->newPageUpdater( User::newSystemUser( 'DynamicPageList3 extension' ) );
$content = $wikipage->getContentHandler()->makeContent( '<noinclude>This page was automatically created. It serves as an anchor page for all \'\'\'[[Special:WhatLinksHere/Template:Extension_DPL|invocations]]\'\'\' of [https://www.mediawiki.org/wiki/Special:MyLanguage/Extension:DynamicPageList3 Extension:DynamicPageList3].</noinclude>', $title );
$updater->setContent( SlotRecord::MAIN, $content );
$comment = CommentStoreComment::newUnsavedComment( 'Autogenerated DPL\'s necessary template for content inclusion' );
$updater->saveRevision(
$comment,
EDIT_NEW | EDIT_FORCE_BOT
);
}
return true;
} | CWE-400 | 2 |
public function setListAttributes( $attributes ) {
$this->listAttributes = \Sanitizer::fixTagAttributes( $attributes, 'ul' );
} | CWE-400 | 2 |
$banner->increaseImpressions();
}
}
// assign banner to the template and show it!
assign_to_template(array(
'banners'=>$banners
));
} | CWE-74 | 1 |
$count += $db->dropTable($basename);
}
flash('message', gt('Deleted').' '.$count.' '.gt('unused tables').'.');
expHistory::back();
} | CWE-74 | 1 |
public function saveconfig() {
global $db;
if (empty($this->params['id'])) return false;
$calcname = $db->selectValue('shippingcalculator', 'calculator_name', 'id='.$this->params['id']);
$calc = new $calcname($this->params['id']);
$conf = serialize($calc->parseConfig($this->params));
$calc->update(array('config'=>$conf));
expHistory::back();
} | CWE-74 | 1 |
public function testAuthCheckDecryptUser()
{
$GLOBALS['cfg']['Server']['auth_swekey_config'] = 'testConfigSwekey';
$GLOBALS['server'] = 1;
$_REQUEST['old_usr'] = '';
$_REQUEST['pma_username'] = '';
$_COOKIE['pmaServer-1'] = 'pmaServ1';
$_COOKIE['pmaUser-1'] = 'pmaUser1';
$_COOKIE['pma_iv-1'] = base64_encode('testiv09testiv09');
$GLOBALS['cfg']['blowfish_secret'] = 'secret';
$_SESSION['last_access_time'] = '';
$_SESSION['last_valid_captcha'] = true;
// mock for blowfish function
$this->object = $this->getMockBuilder('AuthenticationCookie')
->disableOriginalConstructor()
->setMethods(array('cookieDecrypt'))
->getMock();
$this->object->expects($this->once())
->method('cookieDecrypt')
->will($this->returnValue('testBF'));
$this->assertFalse(
$this->object->authCheck()
);
$this->assertEquals(
'testBF',
$GLOBALS['PHP_AUTH_USER']
);
} | CWE-200 | 10 |
public function confirm()
{
$project = $this->getProject();
$this->response->html($this->helper->layout->project('action/remove', array(
'action' => $this->actionModel->getById($this->request->getIntegerParam('action_id')),
'available_events' => $this->eventManager->getAll(),
'available_actions' => $this->actionManager->getAvailableActions(),
'project' => $project,
'title' => t('Remove an action')
)));
} | CWE-200 | 10 |
public function gc($force = false)
{
if ($force || mt_rand(0, 1000000) < $this->gcProbability) {
$this->db->createCommand()
->delete($this->cacheTable, '[[expire]] > 0 AND [[expire]] < ' . time())
->execute();
}
} | CWE-330 | 12 |
public function attributeLabels() {
return array(
'actionId' => Yii::t('actions','Action ID'),
'text' => Yii::t('actions','Action Text'),
);
} | CWE-20 | 0 |
function build_daterange_sql($timestamp, $endtimestamp=null, $field='date', $multiday=false) {
if (empty($endtimestamp)) {
$date_sql = "((".$field." >= " . expDateTime::startOfDayTimestamp($timestamp) . " AND ".$field." <= " . expDateTime::endOfDayTimestamp($timestamp) . ")";
} else {
$date_sql = "((".$field." >= " . expDateTime::startOfDayTimestamp($timestamp) . " AND ".$field." <= " . expDateTime::endOfDayTimestamp($endtimestamp) . ")";
}
if ($multiday)
$date_sql .= " OR (" . expDateTime::startOfDayTimestamp($timestamp) . " BETWEEN ".$field." AND dateFinished)";
$date_sql .= ")";
return $date_sql;
}
| CWE-74 | 1 |
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-327 | 3 |
public function Login ($username = '', $password = '') {
if ($this->connected == false) {
$this->error = 'Not connected to POP3 server';
if ($this->do_debug >= 1) {
$this->displayErrors();
}
}
if (empty($username)) {
$username = $this->username;
}
if (empty($password)) {
$password = $this->password;
}
$pop_username = "USER $username" . $this->CRLF;
$pop_password = "PASS $password" . $this->CRLF;
// Send the Username
$this->sendString($pop_username);
$pop3_response = $this->getResponse();
if ($this->checkResponse($pop3_response)) {
// Send the Password
$this->sendString($pop_password);
$pop3_response = $this->getResponse();
if ($this->checkResponse($pop3_response)) {
return true;
}
}
return false;
} | CWE-20 | 0 |
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-74 | 1 |
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 |
public function test_empty_content_multiple_spaces() {
$result = $this->myxmlrpcserver->wp_newComment(
array(
1,
'administrator',
'administrator',
self::$post->ID,
array(
'content' => ' ',
),
)
);
$this->assertIXRError( $result );
$this->assertSame( 403, $result->code );
} | CWE-862 | 8 |
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 |
function XMLRPCremoveNode($nodeID){
require_once(".ht-inc/privileges.php");
global $user;
if(!in_array("nodeAdmin", $user['privileges'])){
return array(
'status' => 'error',
'errorcode' => 56,
'errormsg' => 'User cannot administer nodes');
}
if(!checkUserHasPriv("nodeAdmin", $user['id'], $nodeID)){
return array(
'status' => 'error',
'errorcode' => 57,
'errormsg' => 'User cannot edit this node');
}
$nodes = recurseGetChildren($nodeID);
array_push($nodes, $nodeID);
$deleteNodes = implode(',', $nodes);
$query = "DELETE FROM privnode "
. "WHERE id IN ($deleteNodes)";
doQuery($query, 345);
return array(
'status' => 'success');
} | CWE-20 | 0 |
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 |
public static function canImportData() {
return true;
}
| CWE-74 | 1 |
public function configure() {
$this->config['defaultbanner'] = array();
if (!empty($this->config['defaultbanner_id'])) {
$this->config['defaultbanner'][] = new expFile($this->config['defaultbanner_id']);
}
parent::configure();
$banners = $this->banner->find('all', null, 'companies_id');
assign_to_template(array(
'banners'=>$banners,
'title'=>static::displayname()
));
} | CWE-74 | 1 |
protected function generateVerifyCode()
{
if ($this->minLength > $this->maxLength) {
$this->maxLength = $this->minLength;
}
if ($this->minLength < 3) {
$this->minLength = 3;
}
if ($this->maxLength > 20) {
$this->maxLength = 20;
}
$length = mt_rand($this->minLength, $this->maxLength);
$letters = 'bcdfghjklmnpqrstvwxyz';
$vowels = 'aeiou';
$code = '';
for ($i = 0; $i < $length; ++$i) {
if ($i % 2 && mt_rand(0, 10) > 2 || !($i % 2) && mt_rand(0, 10) > 9) {
$code .= $vowels[mt_rand(0, 4)];
} else {
$code .= $letters[mt_rand(0, 20)];
}
}
return $code;
} | CWE-330 | 12 |
public function testCompilePathIsProperlyCreated()
{
$compiler = new BladeCompiler($this->getFiles(), __DIR__);
$this->assertEquals(__DIR__.'/'.sha1('foo').'.php', $compiler->getCompiledPath('foo'));
} | CWE-327 | 3 |
public function getDisplayName ($plural=true) {
return Yii::t('marketing', 'Web Form');
} | CWE-20 | 0 |
function __construct() {
$this->mDb = GlobalNewFilesHooks::getGlobalDB( DB_REPLICA, 'gnf_files' );
if ( $this->getRequest()->getText( 'sort', 'files_date' ) == 'files_date' ) {
$this->mDefaultDirection = IndexPager::DIR_DESCENDING;
} else {
$this->mDefaultDirection = IndexPager::DIR_ASCENDING;
}
parent::__construct( $this->getContext() );
} | CWE-20 | 0 |
foreach ($flatArray as $key => $value) {
$pattern = '/' . $key . '([^.]|$)/';
if (preg_match($pattern, $expression, $matches)) {
switch (gettype($flatArray[$key])) {
case 'boolean':
$expression = str_replace($key, $flatArray[$key] ? 'true' : 'false', $expression);
break;
case 'NULL':
$expression = str_replace($key, 'false', $expression);
break;
case 'string':
$expression = str_replace($key, '"' . $flatArray[$key] . '"', $expression);
break;
case 'object':
$expression = self::executeClosure($expression, $key, $flatArray[$key], $flatArray);
break;
default:
$expression = str_replace($key, $flatArray[$key], $expression);
break;
}
$bool = eval("return $expression;");
}
} | CWE-74 | 1 |
public static function endReset( &$parser, $text ) {
if ( !self::$createdLinks['resetdone'] ) {
self::$createdLinks['resetdone'] = true;
foreach ( $parser->getOutput()->mCategories as $key => $val ) {
if ( array_key_exists( $key, self::$fixedCategories ) ) {
self::$fixedCategories[$key] = $val;
}
}
// $text .= self::dumpParsedRefs($parser,"before final reset");
if ( self::$createdLinks['resetLinks'] ) {
$parser->getOutput()->mLinks = [];
}
if ( self::$createdLinks['resetCategories'] ) {
$parser->getOutput()->mCategories = self::$fixedCategories;
}
if ( self::$createdLinks['resetTemplates'] ) {
$parser->getOutput()->mTemplates = [];
}
if ( self::$createdLinks['resetImages'] ) {
$parser->getOutput()->mImages = [];
}
// $text .= self::dumpParsedRefs( $parser, 'after final reset' );
self::$fixedCategories = [];
}
return true;
} | CWE-400 | 2 |
private function _getMetaTags()
{
$retval = '<meta charset="utf-8" />';
$retval .= '<meta name="referrer" content="none" />';
$retval .= '<meta name="robots" content="noindex,nofollow" />';
$retval .= '<meta http-equiv="X-UA-Compatible" content="IE=Edge">';
if (! $GLOBALS['cfg']['AllowThirdPartyFraming']) {
$retval .= '<style id="cfs-style">html{display: none;}</style>';
}
return $retval;
} | CWE-200 | 10 |
$parser->getOutput()->mTemplates[$nsp] = array_diff_assoc( $parser->getOutput()->mTemplates[$nsp], self::$createdLinks[1][$nsp] );
// echo ("<pre> elim: parser Tpls [$nsp] nachher = ". count($parser->getOutput()->mTemplates[$nsp]) ."</pre>\n");
if ( count( $parser->getOutput()->mTemplates[$nsp] ) == 0 ) {
unset( $parser->getOutput()->mTemplates[$nsp] );
}
}
} | CWE-400 | 2 |
function XMLRPCgetResourceGroupPrivs($name, $type, $nodeid){
require_once(".ht-inc/privileges.php");
global $user;
if(! checkUserHasPriv("resourceGrant", $user['id'], $nodeid)){
return array('status' => 'error',
'errorcode' => 53,
'errormsg' => 'Unable to add resource group to this node');
}
if($typeid = getResourceTypeID($type)){
if(!checkForGroupName($name, 'resource', '', $typeid)){
return array('status' => 'error',
'errorcode' => 28,
'errormsg' => 'resource group does not exist');
}
$nodePrivileges = getNodePrivileges($nodeid, 'resources');
$nodePrivileges = getNodeCascadePrivileges($nodeid, 'resources', $nodePrivileges);
foreach($nodePrivileges['resources'] as $resource => $privs){
if(strstr($resource, "$type/$name")){
return array(
'status' => 'success',
'privileges' => $privs);
}
}
return array(
'status' => 'error',
'errorcode' => 29,
'errormsg' => 'could not find resource name in privilege list');
} else {
return array('status' => 'error',
'errorcode' => 56,
'errormsg' => 'Invalid resource type');
}
} | CWE-20 | 0 |
public function upload() {
if (!AuthUser::hasPermission('file_manager_upload')) {
Flash::set('error', __('You do not have sufficient permissions to upload a file.'));
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/upload')) {
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/'));
}
$mask = Plugin::getSetting('umask', 'file_manager');
umask(octdec($mask));
$data = $_POST['upload'];
$path = str_replace('..', '', $data['path']);
$overwrite = isset($data['overwrite']) ? true : false;
// Clean filenames
$filename = preg_replace('/ /', '_', $_FILES['upload_file']['name']);
$filename = preg_replace('/[^a-z0-9_\-\.]/i', '', $filename);
if (isset($_FILES)) {
$file = $this->_upload_file($filename, FILES_DIR . '/' . $path . '/', $_FILES['upload_file']['tmp_name'], $overwrite);
if ($file === false)
Flash::set('error', __('File has not been uploaded!'));
}
redirect(get_url('plugin/file_manager/browse/' . $path));
} | CWE-20 | 0 |
public static function validateNumber(
$path,
$values,
$allow_neg,
$allow_zero,
$max_value,
$error_string
) {
if ($values[$path] === '') {
return '';
}
if (intval($values[$path]) != $values[$path]
|| (! $allow_neg && $values[$path] < 0)
|| (! $allow_zero && $values[$path] == 0)
|| $values[$path] > $max_value
) {
return $error_string;
}
return '';
} | CWE-200 | 10 |
static public function getHighestOrderNumber($_uid = 0) {
$where = '';
$sel_data = array();
if ($_uid > 0) {
$where = " WHERE `adminid` = :adminid";
$sel_data['adminid'] = $_uid;
}
$sql = "SELECT MAX(`logicalorder`) as `highestorder` FROM `" . TABLE_PANEL_TICKET_CATS . "`".$where.";";
$result_stmt = Database::prepare($sql);
$result = Database::pexecute_first($result_stmt, $sel_data);
return (isset($result['highestorder']) ? (int)$result['highestorder'] : 0);
} | CWE-732 | 13 |
public function addGroupBy( $groupBy ) {
if ( empty( $groupBy ) ) {
throw new \MWException( __METHOD__ . ': An empty group by clause was passed.' );
}
$this->groupBy[] = $groupBy;
return true;
} | CWE-400 | 2 |
public function generateMessageFileName()
{
$time = microtime(true);
return date('Ymd-His-', $time) . sprintf('%04d', (int) (($time - (int) $time) * 10000)) . '-' . sprintf('%04d', mt_rand(0, 10000)) . '.eml';
} | CWE-330 | 12 |
foreach ($allusers as $uid) {
$u = user::getUserById($uid);
expPermissions::grant($u, 'manage', $sloc);
}
| CWE-74 | 1 |
public static function init( $settings = false ) {
if ( $settings === false ) {
global $wgDplSettings;
$settings = $wgDplSettings;
}
if ( !is_array( $settings ) ) {
throw new MWException( __METHOD__ . ": Invalid settings passed." );
}
self::$settings = array_merge( self::$settings, $settings );
} | CWE-400 | 2 |
self::removeLevel($kid->id);
}
}
| CWE-74 | 1 |
static function testLDAPConnection($auths_id, $replicate_id = -1) {
$config_ldap = new self();
$res = $config_ldap->getFromDB($auths_id);
// we prevent some delay...
if (!$res) {
return false;
}
//Test connection to a replicate
if ($replicate_id != -1) {
$replicate = new AuthLdapReplicate();
$replicate->getFromDB($replicate_id);
$host = $replicate->fields["host"];
$port = $replicate->fields["port"];
} else {
//Test connection to a master ldap server
$host = $config_ldap->fields['host'];
$port = $config_ldap->fields['port'];
}
$ds = self::connectToServer($host, $port, $config_ldap->fields['rootdn'],
Toolbox::decrypt($config_ldap->fields['rootdn_passwd'], GLPIKEY),
$config_ldap->fields['use_tls'],
$config_ldap->fields['deref_option']);
if ($ds) {
return true;
}
return false;
} | CWE-327 | 3 |
$curVal[$key] = $tp->post_toForm($val);
}
}
$target = e107::getUrl()->create('user/myprofile/edit',array('id'=>USERID));
$text = '<form method="post" action="'.$target.'" id="dataform" class="usersettings-form form-horizontal" enctype="multipart/form-data" autocomplete="off">';
//$text = (is_numeric($_uid) ? $rs->form_open("post", e_SELF."?".e_QUERY, "dataform", "", " class='form-horizontal' role='form' enctype='multipart/form-data'") : $rs->form_open("post", e_SELF, "dataform", "", " class='form-horizontal' role='form' enctype='multipart/form-data'"));
if (e_QUERY == "update")
{
$text .= "<div class='fborder' style='text-align:center'><br />".str_replace("*", "<span class='required'>*</span>", LAN_USET_9)."<br />".LAN_USET_10."<br /><br /></div>";
}
// e107::scStyle($sc_style);
e107::getScBatch('usersettings')->setVars($curVal)->reset();
$USERSETTINGS_EDIT = $this->getTemplate('edit');
$USERSETTINGS_EDIT_CAPTION = $this->getTemplate('edit_caption');
$text .= $tp->parseTemplate($USERSETTINGS_EDIT, true, $this->sc); //ParseSC must be set to true so that custom plugin -shortcodes can be utilized.
$text .= "<div><input type='hidden' name='_uid' value='{$uuid}' /></div>
</form>
";
$caption = (isset($USERSETTINGS_EDIT_CAPTION)) ? $USERSETTINGS_EDIT_CAPTION : LAN_USET_39; // 'Update User Settings'
$ns->tablerender($caption, $text);
} | CWE-326 | 9 |
$tags = array_merge($matches[1], $tags);
}
$tags = array_unique($tags);
return $tags;
} | CWE-20 | 0 |
public function fixsessions() {
global $db;
// $test = $db->sql('CHECK TABLE '.$db->prefix.'sessionticket');
$fix = $db->sql('REPAIR TABLE '.$db->prefix.'sessionticket');
flash('message', gt('Sessions Table was Repaired'));
expHistory::back();
} | CWE-74 | 1 |
$link = str_replace(URL_FULL, '', makeLink(array('section' => $section->id)));
| CWE-74 | 1 |
function update_optiongroup_master() {
global $db;
$id = empty($this->params['id']) ? null : $this->params['id'];
$og = new optiongroup_master($id);
$oldtitle = $og->title;
$og->update($this->params);
// if the title of the master changed we should update the option groups that are already using it.
if ($oldtitle != $og->title) {
$db->sql('UPDATE '.$db->prefix.'optiongroup SET title="'.$og->title.'" WHERE title="'.$oldtitle.'"');
}
expHistory::back();
} | CWE-74 | 1 |
private function _createdby( $option ) {
$this->addTable( 'revision', 'creation_rev' );
$this->addTable( 'revision_actor_temp', 'creation_rev_actor' );
$this->_adduser( null, 'creation_rev_actor' );
$user = new \User;
$this->addWhere(
[
$this->DB->addQuotes( $user->newFromName( $option )->getActorId() ) . ' = creation_rev_actor.revactor_actor',
'creation_rev_actor.revactor_page = page_id',
'creation_rev.rev_parent_id = 0'
]
);
} | CWE-400 | 2 |
$dplArg = $this->wgRequest->getVal( $arg, '' );
if ( $dplArg == '' ) {
$input = preg_replace( '/\{%' . $arg . ':(.*)%\}/U', '\1', $input );
$input = str_replace( '{%' . $arg . '%}', '', $input );
} else {
$input = preg_replace( '/\{%' . $arg . ':.*%\}/U ', $dplArg, $input );
$input = str_replace( '{%' . $arg . '%}', $dplArg, $input );
}
}
return $input;
} | CWE-400 | 2 |
$this->where = array_merge( $this->where, $where );
} else {
throw new \MWException( __METHOD__ . ': An invalid where clause was passed.' );
return false;
}
return true;
} | CWE-400 | 2 |
public function assets_path($file = NULL, $path = NULL, $module = NULL, $absolute = NULL)
{
$cache = '';
if (!isset($absolute)) $absolute = $this->assets_absolute_path;
$CI = $this->_get_assets_config();
if ($this->asset_append_cache_timestamp AND in_array($path, $this->asset_append_cache_timestamp) AND !empty($file))
{
$q_str = (strpos($file, '?') === FALSE) ? '?' : '&';
$cache = $q_str.'c='.strtotime($this->assets_last_updated);
}
// if it is an absolute path already provided, then we just return it without any caching
if (!$this->_is_local_path($file))
{
return $file.$cache;
}
$assets_folders = $this->assets_folders;
$asset_type = (!empty($assets_folders[$path])) ? $assets_folders[$path] : $CI->config->item($path);
// if absolute path, then we just return that
if (!$this->_is_local_path($this->assets_path))
{
return $this->assets_path.$asset_type.$file.$cache;
}
$assets_path = $this->_get_assets_path($module);
$path = WEB_PATH.$assets_path.$asset_type.$file.$cache;
if ($absolute)
{
$protocol = ($_SERVER["SERVER_PORT"] == 443) ? "https://" : "http://";
$path = $protocol.$_SERVER['HTTP_HOST'].$path;
}
return $path;
} | CWE-74 | 1 |
public function behaviors() {
return array_merge(parent::behaviors(),array(
'X2LinkableBehavior'=>array(
'class'=>'X2LinkableBehavior',
'module'=>'marketing'
),
'ERememberFiltersBehavior' => array(
'class'=>'application.components.ERememberFiltersBehavior',
'defaults'=>array(),
'defaultStickOnClear'=>false
)
));
} | CWE-20 | 0 |
static public function customerHasTickets($_cid = 0) {
if ($_cid != 0) {
$result_stmt = Database::prepare("
SELECT `id` FROM `" . TABLE_PANEL_TICKETS . "` WHERE `customerid` = :cid"
);
Database::pexecute($result_stmt, array('cid' => $_cid));
$tickets = array();
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$tickets[] = $row['id'];
}
return $tickets;
}
return false;
} | CWE-732 | 13 |
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-74 | 1 |
public function isLocal() {
$localhosts = array('::1', '127.0.0.1', '0.0.0.0');
return (
in_array(server::get('SERVER_ADDR'), $localhosts) ||
server::get('SERVER_NAME') == 'localhost' ||
str::endsWith(server::get('SERVER_NAME'), '.localhost') ||
str::endsWith(server::get('SERVER_NAME'), '.test')
);
} | CWE-346 | 16 |
function searchName() { return gt('Webpage'); }
| CWE-74 | 1 |
public function getListStart() {
// increase start value of ordered lists at multi-column output
//The offset that comes from the URL parameter is zero based, but has to be +1'ed for display.
$offset = $this->getParameters()->getParameter( 'offset' ) + 1;
if ( $offset != 0 ) {
//@TODO: So this adds the total count of articles to the offset. I have not found a case where this does not mess up the displayed count. I am commenting this out for now.
//$offset += $this->offsetCount;
}
return sprintf( $this->listStart, $this->listAttributes . ' start="' . $offset . '"' );
} | CWE-400 | 2 |
function update() {
parent::update();
expSession::clearAllUsersSessionCache('navigation');
}
| CWE-74 | 1 |
static function displayname() {
return gt("e-Commerce Category Manager");
} | CWE-74 | 1 |
$connecttext = preg_replace("/#connectport#/", $connectport, $connecttext);
$connectMethods[$key]["connecttext"] = $connecttext;
}
return array('status' => 'ready',
'serverIP' => $serverIP,
'user' => $thisuser,
'password' => $passwd,
'connectport' => $connectport,
'connectMethods' => $connectMethods);
}
return array('status' => 'notready');
} | CWE-20 | 0 |
function getTextColumns($table) {
$sql = "SHOW COLUMNS FROM " . $this->prefix.$table . " WHERE type = 'text' OR type like 'varchar%'";
$res = @mysqli_query($this->connection, $sql);
if ($res == null)
return array();
$records = array();
while($row = mysqli_fetch_object($res)) {
$records[] = $row->Field;
}
return $records;
} | CWE-74 | 1 |
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$swimlane_id = $this->request->getIntegerParam('swimlane_id');
if ($this->swimlaneModel->remove($project['id'], $swimlane_id)) {
$this->flash->success(t('Swimlane removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this swimlane.'));
}
$this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
} | CWE-200 | 10 |
private function get_lines() {
$data = "";
$endtime = 0;
/* If for some reason the fp is bad, don't inf loop */
if (!is_resource($this->smtp_conn)) {
return $data;
}
stream_set_timeout($this->smtp_conn, $this->Timeout);
if ($this->Timelimit > 0) {
$endtime = time() + $this->Timelimit;
}
while(is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
$str = @fgets($this->smtp_conn,515);
if($this->do_debug >= 4) {
$this->edebug("SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />');
$this->edebug("SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />');
}
$data .= $str;
if($this->do_debug >= 4) {
$this->edebug("SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />');
}
// if 4th character is a space, we are done reading, break the loop
if(substr($str,3,1) == " ") { break; }
// Timed-out? Log and break
$info = stream_get_meta_data($this->smtp_conn);
if ($info['timed_out']) {
if($this->do_debug >= 4) {
$this->edebug("SMTP -> get_lines(): timed-out (" . $this->Timeout . " seconds) <br />");
}
break;
}
// Now check if reads took too long
if ($endtime) {
if (time() > $endtime) {
if($this->do_debug >= 4) {
$this->edebug("SMTP -> get_lines(): timelimit reached (" . $this->Timelimit . " seconds) <br />");
}
break;
}
}
}
return $data;
} | CWE-20 | 0 |
public function testAuth()
{
if (! defined('PMA_TEST_HEADERS')) {
$this->markTestSkipped(
'Cannot redefine constant/function - missing runkit extension'
);
}
// case 1
$GLOBALS['cfg']['Server']['SignonURL'] = '';
ob_start();
$this->object->auth();
$result = ob_get_clean();
$this->assertContains(
'You must set SignonURL!',
$result
);
// case 2
$GLOBALS['cfg']['Server']['SignonURL'] = 'http://phpmyadmin.net/SignonURL';
$_REQUEST['old_usr'] = 'oldUser';
$GLOBALS['cfg']['Server']['LogoutURL'] = 'http://phpmyadmin.net/logoutURL';
$this->object->auth();
$this->assertContains(
'Location: http://phpmyadmin.net/logoutURL?PHPSESSID=',
$GLOBALS['header'][0]
);
// case 3
$GLOBALS['header'] = array();
$GLOBALS['cfg']['Server']['SignonURL'] = 'http://phpmyadmin.net/SignonURL';
$_REQUEST['old_usr'] = '';
$GLOBALS['cfg']['Server']['LogoutURL'] = '';
$this->object->auth();
$this->assertContains(
'Location: http://phpmyadmin.net/SignonURL?PHPSESSID=',
$GLOBALS['header'][0]
);
} | CWE-200 | 10 |
function execute( $par ) {
$this->setHeaders();
$this->outputHeader();
$pager = new GlobalNewFilesPager();
$this->getOutput()->addParserOutputContent( $pager->getFullOutput() );
} | CWE-20 | 0 |
private function _notmodifiedby( $option ) {
$user = new \User;
$this->addWhere( 'NOT EXISTS (SELECT 1 FROM ' . $this->tableNames['revision_actor_temp'] . ' WHERE ' . $this->tableNames['revision_actor_temp'] . '.revactor_page=page_id AND ' . $this->tableNames['revision_actor_temp'] . '.revactor_actor = ' . $this->DB->addQuotes( $user->newFromName( $option )->getActorId() ) . ' LIMIT 1)' );
} | CWE-400 | 2 |
static public function addCategory($_category = null, $_admin = 1, $_order = 1) {
if ($_category != null
&& $_category != ''
) {
if ($_order < 1) {
$_order = 1;
}
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_TICKET_CATS . "` SET
`name` = :name,
`adminid` = :adminid,
`logicalorder` = :lo"
);
$ins_data = array(
'name' => $_category,
'adminid' => $_admin,
'lo' => $_order
);
Database::pexecute($ins_stmt, $ins_data);
return true;
}
return false;
} | CWE-732 | 13 |
$iloc = expUnserialize($container->internal);
if ($db->selectObject('sectionref',"module='".$iloc->mod."' AND source='".$iloc->src."'") == null) {
// There is no sectionref for this container. Populate sectionref
if ($container->external != "N;") {
$newSecRef = new stdClass();
$newSecRef->module = $iloc->mod;
$newSecRef->source = $iloc->src;
$newSecRef->internal = '';
$newSecRef->refcount = 1;
// $newSecRef->is_original = 1;
$eloc = expUnserialize($container->external);
// $section = $db->selectObject('sectionref',"module='containermodule' AND source='".$eloc->src."'");
$section = $db->selectObject('sectionref',"module='container' AND source='".$eloc->src."'");
if (!empty($section)) {
$newSecRef->section = $section->id;
$db->insertObject($newSecRef,"sectionref");
$missing_sectionrefs[] = gt("Missing sectionref for container replaced").": ".$iloc->mod." - ".$iloc->src." - PageID #".$section->id;
} else {
$db->delete('container','id="'.$container->id.'"');
$missing_sectionrefs[] = gt("Cant' find the container page for container").": ".$iloc->mod." - ".$iloc->src.' - '.gt('deleted');
}
}
}
}
assign_to_template(array(
'missing_sectionrefs'=>$missing_sectionrefs,
));
} | CWE-74 | 1 |
public static function fixName($name) {
$name = preg_replace('/[^A-Za-z0-9\.]/','_',$name);
if ($name[0] == '.')
$name[0] = '_';
return $name;
// return preg_replace('/[^A-Za-z0-9\.]/', '-', $name);
} | CWE-74 | 1 |
private function _notlinksto( $option ) {
if ( $this->parameters->getParameter( 'distinct' ) == 'strict' ) {
$this->addGroupBy( 'page_title' );
}
if ( count( $option ) ) {
$where = $this->tableNames['page'] . '.page_id NOT IN (SELECT ' . $this->tableNames['pagelinks'] . '.pl_from FROM ' . $this->tableNames['pagelinks'] . ' WHERE ';
$ors = [];
foreach ( $option as $linkGroup ) {
foreach ( $linkGroup as $link ) {
$_or = '(' . $this->tableNames['pagelinks'] . '.pl_namespace=' . intval( $link->getNamespace() );
if ( strpos( $link->getDbKey(), '%' ) >= 0 ) {
$operator = 'LIKE';
} else {
$operator = '=';
}
if ( $this->parameters->getParameter( 'ignorecase' ) ) {
$_or .= ' AND LOWER(CAST(' . $this->tableNames['pagelinks'] . '.pl_title AS char)) ' . $operator . ' LOWER(' . $this->DB->addQuotes( $link->getDbKey() ) . '))';
} else {
$_or .= ' AND ' . $this->tableNames['pagelinks'] . '.pl_title ' . $operator . ' ' . $this->DB->addQuotes( $link->getDbKey() ) . ')';
}
$ors[] = $_or;
}
}
$where .= '(' . implode( ' OR ', $ors ) . '))';
}
$this->addWhere( $where );
} | CWE-400 | 2 |
public static function setArray( $arg ) {
$numargs = count( $arg );
if ( $numargs < 5 ) {
return '';
}
$var = trim( $arg[2] );
$value = $arg[3];
$delimiter = $arg[4];
if ( $var == '' ) {
return '';
}
if ( $value == '' ) {
self::$memoryArray[$var] = [];
return;
}
if ( $delimiter == '' ) {
self::$memoryArray[$var] = [
$value
];
return;
}
if ( 0 !== strpos( $delimiter, '/' ) || ( strlen( $delimiter ) - 1 ) !== strrpos( $delimiter, '/' ) ) {
$delimiter = '/\s*' . $delimiter . '\s*/';
}
self::$memoryArray[$var] = preg_split( $delimiter, $value );
return "value={$value}, delimiter={$delimiter}," . count( self::$memoryArray[$var] );
} | CWE-400 | 2 |
$rndString = function ($len = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = '';
for ($i = 0; $i < $len; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
return $randomString;
}; | CWE-330 | 12 |
public function actionDeleteDropdown() {
$dropdowns = Dropdowns::model()->findAll();
if (isset($_POST['dropdown'])) {
if ($_POST['dropdown'] != Actions::COLORS_DROPDOWN_ID) {
$model = Dropdowns::model()->findByPk($_POST['dropdown']);
$model->delete();
$this->redirect('manageDropDowns');
}
}
$this->render('deleteDropdowns', array(
'dropdowns' => $dropdowns,
));
} | CWE-20 | 0 |
public function setPageTextMatchRegex( array $pageTextMatchRegex = [] ) {
$this->pageTextMatchRegex = (array)$pageTextMatchRegex;
} | CWE-400 | 2 |
function delete_recurring() {
$item = $this->event->find('first', 'id=' . $this->params['id']);
if ($item->is_recurring == 1) { // need to give user options
expHistory::set('editable', $this->params);
assign_to_template(array(
'checked_date' => $this->params['date_id'],
'event' => $item,
));
} else { // Process a regular delete
$item->delete();
}
}
| CWE-74 | 1 |
protected function markCompleted($endStatus, ServiceResponse $serviceResponse, $gatewayMessage)
{
parent::markCompleted($endStatus, $serviceResponse, $gatewayMessage);
$this->createMessage(Message\PurchasedResponse::class, $gatewayMessage);
ErrorHandling::safeExtend($this->payment, 'onCaptured', $serviceResponse);
} | CWE-436 | 5 |
public function AddReplyTo($address, $name = '') {
return $this->AddAnAddress('Reply-To', $address, $name);
} | CWE-20 | 0 |