code
stringlengths 12
2.05k
| label_name
stringlengths 6
8
| label
int64 0
95
|
---|---|---|
public function column_title( $post ) {
list( $mime ) = explode( '/', $post->post_mime_type );
$title = _draft_or_post_title();
$thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) );
$link_start = $link_end = '';
if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) {
$link_start = sprintf(
'<a href="%s" aria-label="%s">',
get_edit_post_link( $post->ID ),
/* translators: %s: attachment title */
esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) )
);
$link_end = '</a>';
}
$class = $thumb ? ' class="has-media-icon"' : '';
?>
<strong<?php echo $class; ?>>
<?php
echo $link_start;
if ( $thumb ) : ?>
<span class="media-icon <?php echo sanitize_html_class( $mime . '-icon' ); ?>"><?php echo $thumb; ?></span>
<?php endif;
echo $title . $link_end;
_media_states( $post );
?>
</strong>
<p class="filename">
<span class="screen-reader-text"><?php _e( 'File name:' ); ?> </span>
<?php
$file = get_attached_file( $post->ID );
echo wp_basename( $file );
?>
</p>
<?php
} | CWE-79 | 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-89 | 0 |
private function updateHostFromUri($host)
{
// Ensure Host is the first header.
// See: http://tools.ietf.org/html/rfc7230#section-5.4
if ($port = $this->uri->getPort()) {
$host .= ':' . $port;
}
$this->headerLines = ['Host' => [$host]] + $this->headerLines;
$this->headers = ['host' => [$host]] + $this->headers;
} | CWE-89 | 0 |
public static function group($id){
$usr = Db::result(
sprintf("SELECT * FROM `user` WHERE `id` = '%d' OR `userid` = '%s' LIMIT 1",
Typo::int($id),
Typo::cleanX($id)
)
);
return $usr[0]->group;
}
| CWE-89 | 0 |
protected function parse()
{
parent::parse();
// grab the error-type from the parameters
$errorType = $this->getParameter('type');
// set correct headers
switch($errorType)
{
case 'module-not-allowed':
case 'action-not-allowed':
SpoonHTTP::setHeadersByCode(403);
break;
case 'not-found':
SpoonHTTP::setHeadersByCode(404);
break;
}
// querystring provided?
if($this->getParameter('querystring') !== null)
{
// split into file and parameters
$chunks = explode('?', $this->getParameter('querystring'));
// get extension
$extension = SpoonFile::getExtension($chunks[0]);
// if the file has an extension it is a non-existing-file
if($extension != '' && $extension != $chunks[0])
{
// set correct headers
SpoonHTTP::setHeadersByCode(404);
// give a nice error, so we can detect which file is missing
echo 'Requested file (' . implode('?', $chunks) . ') not found.';
// stop script execution
exit;
}
}
// assign the correct message into the template
$this->tpl->assign('message', BL::err(SpoonFilter::toCamelCase($errorType, '-')));
} | CWE-79 | 1 |
header("Location: ".$this->makeLink(array('section'=>intval($_REQUEST['section']))),TRUE,301); | CWE-89 | 0 |
$result = sqlrequest($database_ged, $sql);
if(!$result){
$success = false;
}
}
// display the final message
if($success){
message(11, " : ".getLabel("message.event_edited"), "ok");
} else {
message(11, " : ".getLabel("message.event_edited_error"), "danger");
}
} | CWE-78 | 6 |
public function breadcrumb() {
global $sectionObj;
expHistory::set('viewable', $this->params);
$id = $sectionObj->id;
$current = null;
// Show not only the location of a page in the hierarchy but also the location of a standalone page
$current = new section($id);
if ($current->parent == -1) { // standalone page
$navsections = section::levelTemplate(-1, 0);
foreach ($navsections as $section) {
if ($section->id == $id) {
$current = $section;
break;
}
}
} else {
$navsections = section::levelTemplate(0, 0);
foreach ($navsections as $section) {
if ($section->id == $id) {
$current = $section;
break;
}
}
}
assign_to_template(array(
'sections' => $navsections,
'current' => $current,
));
}
| CWE-89 | 0 |
public static function returnChildrenAsJSON() {
global $db;
//$nav = section::levelTemplate(intval($_REQUEST['id'], 0));
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
$nav = $db->selectObjects('section', 'parent=' . $id, 'rank');
//FIXME $manage_all is moot w/ cascading perms now?
$manage_all = false;
if (expPermissions::check('manage', expCore::makeLocation('navigation', '', $id))) {
$manage_all = true;
}
//FIXME recode to use foreach $key=>$value
$navcount = count($nav);
for ($i = 0; $i < $navcount; $i++) {
if ($manage_all || expPermissions::check('manage', expCore::makeLocation('navigation', '', $nav[$i]->id))) {
$nav[$i]->manage = 1;
$view = true;
} else {
$nav[$i]->manage = 0;
$view = $nav[$i]->public ? true : expPermissions::check('view', expCore::makeLocation('navigation', '', $nav[$i]->id));
}
$nav[$i]->link = expCore::makeLink(array('section' => $nav[$i]->id), '', $nav[$i]->sef_name);
if (!$view) unset($nav[$i]);
}
$nav= array_values($nav);
// $nav[$navcount - 1]->last = true;
if (count($nav)) $nav[count($nav) - 1]->last = true;
// echo expJavascript::ajaxReply(201, '', $nav);
$ar = new expAjaxReply(201, '', $nav);
$ar->send();
}
| CWE-89 | 0 |
public function shouldRun(DateTime $date)
{
global $timedate;
$runDate = clone $date;
$this->handleTimeZone($runDate);
$cron = Cron\CronExpression::factory($this->schedule);
if (empty($this->last_run) && $cron->isDue($runDate)) {
return true;
}
$lastRun = $this->last_run ? $timedate->fromDb($this->last_run) : $timedate->fromDb($this->date_entered);
$this->handleTimeZone($lastRun);
$next = $cron->getNextRunDate($lastRun);
return $next <= $runDate;
} | CWE-89 | 0 |
public function withUserInfo($user, $password = null)
{
$info = $user;
if ($password) {
$info .= ':' . $password;
}
if ($this->userInfo === $info) {
return $this;
}
$new = clone $this;
$new->userInfo = $info;
return $new;
} | CWE-89 | 0 |
function captureAuthorization() {
//eDebug($this->params,true);
$order = new order($this->params['id']);
/*eDebug($this->params);
//eDebug($order,true);*/
//eDebug($order,true);
//$billing = new billing();
//eDebug($billing, true);
//$billing->calculator = new $calcname($order->billingmethod[0]->billingcalculator_id);
$calc = $order->billingmethod[0]->billingcalculator->calculator;
$calc->config = $order->billingmethod[0]->billingcalculator->config;
//$calc = new $calc-
//eDebug($calc,true);
if (!method_exists($calc, 'delayed_capture')) {
flash('error', gt('The Billing Calculator does not support delayed capture'));
expHistory::back();
}
$result = $calc->delayed_capture($order->billingmethod[0], $this->params['capture_amt'], $order);
if (empty($result->errorCode)) {
flash('message', gt('The authorized payment was successfully captured'));
expHistory::back();
} else {
flash('error', gt('An error was encountered while capturing the authorized payment.') . '<br /><br />' . $result->message);
expHistory::back();
}
} | CWE-89 | 0 |
protected function _downloadErrorLog()
{
$tmpDir = TMP . 'logs' . DS;
$Folder = new Folder($tmpDir);
$files = $Folder->read(true, true, false);
if (count($files[0]) === 0 && count($files[1]) === 0) {
return false;
}
// ZIP圧縮して出力
$fileName = 'basercms_logs_' . date('Ymd_His');
$Simplezip = new Simplezip();
$Simplezip->addFolder($tmpDir);
$Simplezip->download($fileName);
return true;
} | CWE-78 | 6 |
private function createSink(StreamInterface $stream, array $options)
{
if (!empty($options['stream'])) {
return $stream;
}
$sink = isset($options['sink'])
? $options['sink']
: fopen('php://temp', 'r+');
return is_string($sink)
? new Psr7\Stream(Psr7\try_fopen($sink, 'r+'))
: Psr7\stream_for($sink);
} | CWE-89 | 0 |
public static function flagLib () {
return "<link href=\"".Site::$url."/assets/css/flag-icon.min.css\" rel=\"stylesheet\">";
}
| CWE-89 | 0 |
static function author() {
return "Dave Leffler";
}
| CWE-89 | 0 |
public function isAllowedFilename($filename){
$allow_array = array(
'.jpg','.jpeg','.png','.bmp','.gif','.ico','.webp',
'.mp3','.wav','.mp4',
'.mov','.webmv','.flac','.mkv',
'.zip','.tar','.gz','.tgz','.ipa','.apk','.rar','.iso',
'.pdf','.ofd','.swf','.epub','.xps',
'.doc','.docx','.wps',
'.ppt','.pptx','.xls','.xlsx','.txt','.psd','.csv',
'.cer','.ppt','.pub','.json','.css',
) ;
$ext = strtolower(substr($filename,strripos($filename,'.')) ); //获取文件扩展名(转为小写后)
if(in_array( $ext , $allow_array ) ){
return true ;
}
return false;
} | CWE-79 | 1 |
public static function update($vars){
if(is_array($vars)){
$sql = array(
'table' => 'menus',
'id' => $vars['id'],
'key' => $vars['key']
);
$menu = Db::update($sql);
}
}
| CWE-89 | 0 |
$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-89 | 0 |
function manage() {
expHistory::set('viewable', $this->params);
// $category = new storeCategory();
// $categories = $category->getFullTree();
//
// // foreach($categories as $i=>$val){
// // if (!empty($this->values) && in_array($val->id,$this->values)) {
// // $this->tags[$i]->value = true;
// // } else {
// // $this->tags[$i]->value = false;
// // }
// // $this->tags[$i]->draggable = $this->draggable;
// // $this->tags[$i]->checkable = $this->checkable;
// // }
//
// $obj = json_encode($categories);
} | CWE-89 | 0 |
public function isAuthorizedBackendUserSession()
{
if (!$this->hasSessionCookie()) {
return false;
}
$this->initializeSession();
if (empty($_SESSION['authorized']) || empty($_SESSION['isBackendSession'])) {
return false;
}
return !$this->isExpired();
} | CWE-613 | 7 |
static function lookup($var) {
if (is_array($var))
return parent::lookup($var);
elseif (is_numeric($var))
return parent::lookup(array('staff_id'=>$var));
elseif (Validator::is_email($var))
return parent::lookup(array('email'=>$var));
elseif (is_string($var))
return parent::lookup(array('username'=>$var));
else
return null;
} | CWE-89 | 0 |
public function invalidate()
{
$name = $this->getName();
if (null !== $name) {
$params = session_get_cookie_params();
$cookie_options = array (
'expires' => time() - 42000,
'path' => $params['path'],
'domain' => $params['domain'],
'secure' => $params['secure'],
'httponly' => $params['httponly'],
'samesite' => $params['samesite']
);
$this->removeCookie();
setcookie(
session_name(),
'',
$cookie_options
);
}
if ($this->isSessionStarted()) {
session_unset();
session_destroy();
}
$this->started = false;
return $this;
} | CWE-565 | 17 |
foreach ($page as $pageperm) {
if (!empty($pageperm['manage'])) return true;
}
| CWE-89 | 0 |
public function urlOrExistingFilepath($fields)
{
if ($this->isFeedLocal($this->data)) {
if ($this->data['Feed']['source_format'] == 'misp') {
if (!is_dir($this->data['Feed']['url'])) {
return 'For MISP type local feeds, please specify the containing directory.';
}
} else {
if (!file_exists($this->data['Feed']['url'])) {
return 'Invalid path or file not found. Make sure that the path points to an existing file that is readable and watch out for typos.';
}
}
} else {
if (!filter_var($this->data['Feed']['url'], FILTER_VALIDATE_URL)) {
return false;
}
}
return true;
} | CWE-502 | 15 |
public function disable()
{
$this->checkCSRFParam();
$project = $this->getProject();
$swimlane_id = $this->request->getIntegerParam('swimlane_id');
if ($this->swimlaneModel->disable($project['id'], $swimlane_id)) {
$this->flash->success(t('Swimlane updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this swimlane.'));
}
$this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
} | CWE-639 | 9 |
public function approve() {
expHistory::set('editable', $this->params);
/* The global constants can be overriden by passing appropriate params */
//sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet
$require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];
$require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];
$require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];
$notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];
if (empty($this->params['id'])) {
flash('error', gt('No ID supplied for note to approve'));
$lastUrl = expHistory::getLast('editable');
}
$simplenote = new expSimpleNote($this->params['id']);
assign_to_template(array(
'simplenote'=>$simplenote,
'require_login'=>$require_login,
'require_approval'=>$require_approval,
'require_notification'=>$require_notification,
'notification_email'=>$notification_email,
'tab'=>$this->params['tab']
));
} | CWE-89 | 0 |
public function buildControl() {
$control = new colorcontrol();
if (!empty($this->params['value'])) $control->value = $this->params['value'];
if ($this->params['value'][0] != '#') $this->params['value'] = '#' . $this->params['value'];
$control->default = $this->params['value'];
if (!empty($this->params['hide'])) $control->hide = $this->params['hide'];
if (isset($this->params['flip'])) $control->flip = $this->params['flip'];
$this->params['name'] = !empty($this->params['name']) ? $this->params['name'] : '';
$control->name = $this->params['name'];
$this->params['id'] = !empty($this->params['id']) ? $this->params['id'] : '';
$control->id = isset($this->params['id']) && $this->params['id'] != "" ? $this->params['id'] : "";
//echo $control->id;
if (empty($control->id)) $control->id = $this->params['name'];
if (empty($control->name)) $control->name = $this->params['id'];
// attempt to translate the label
if (!empty($this->params['label'])) {
$this->params['label'] = gt($this->params['label']);
} else {
$this->params['label'] = null;
}
echo $control->toHTML($this->params['label'], $this->params['name']);
// $ar = new expAjaxReply(200, gt('The control was created'), json_encode(array('data'=>$code)));
// $ar->send();
}
| CWE-89 | 0 |
public function approve_submit() {
if (empty($this->params['id'])) {
flash('error', gt('No ID supplied for comment to approve'));
expHistory::back();
}
/* 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->body = $this->params['body'];
$comment->approved = $this->params['approved'];
$comment->save();
expHistory::back();
} | CWE-89 | 0 |
protected function _save($fp, $dir, $name, $stat)
{
//TODO optionally encrypt $fp before uploading if mime is not already encrypted type
$path = $this->_joinPath($dir, $name);
return $this->connect->put($path, $fp)
? $path
: false;
} | CWE-22 | 2 |
public function testUserCredentials($email, $password, $server, $port, $security) {
require_once(realpath(Yii::app()->basePath.'/components/phpMailer/class.phpmailer.php'));
require_once(realpath(Yii::app()->basePath.'/components/phpMailer/class.smtp.php'));
$phpMail = new PHPMailer(true);
$phpMail->isSMTP();
$phpMail->SMTPAuth = true;
$phpMail->Username = $email;
$phpMail->Password = $password;
$phpMail->Host = $server;
$phpMail->Port = $port;
$phpMail->SMTPSecure = $security;
try {
$validCredentials = $phpMail->SmtpConnect();
} catch(phpmailerException $error) {
$validCredentials = false;
}
return $validCredentials;
} | CWE-79 | 1 |
public function getFileIdentifiersInFolder($folderIdentifier, $useFilters = true, $recursive = false)
{
$filters = $useFilters == true ? $this->fileAndFolderNameFilters : [];
return $this->driver->getFilesInFolder($folderIdentifier, 0, 0, $recursive, $filters);
} | CWE-319 | 8 |
public function fetchSGOrgRow($id, $removable = false, $extend = false)
{
$this->layout = false;
$this->autoRender = false;
$this->set('id', $id);
$this->set('removable', $removable);
$this->set('extend', $extend);
$this->render('ajax/sg_org_row_empty');
} | CWE-79 | 1 |
public function withCookieHeader(RequestInterface $request)
{
$values = [];
$uri = $request->getUri();
$scheme = $uri->getScheme();
$host = $uri->getHost();
$path = $uri->getPath() ?: '/';
foreach ($this->cookies as $cookie) {
if ($cookie->matchesPath($path) &&
$cookie->matchesDomain($host) &&
!$cookie->isExpired() &&
(!$cookie->getSecure() || $scheme == 'https')
) {
$values[] = $cookie->getName() . '='
. self::getCookieValue($cookie->getValue());
}
}
return $values
? $request->withHeader('Cookie', implode('; ', $values))
: $request;
} | CWE-89 | 0 |
protected function _joinPath($dir, $name) {
$sql = 'SELECT id FROM '.$this->tbf.' WHERE parent_id="'.$dir.'" AND name="'.$this->db->real_escape_string($name).'"';
if (($res = $this->query($sql)) && ($r = $res->fetch_assoc())) {
$this->updateCache($r['id'], $this->_stat($r['id']));
return $r['id'];
}
return -1;
} | CWE-89 | 0 |
private function renderInvoice(InvoiceQuery $query, Request $request)
{
// use the current request locale as fallback, if no translation was configured
if (null !== $query->getTemplate() && null === $query->getTemplate()->getLanguage()) {
$query->getTemplate()->setLanguage($request->getLocale());
}
try {
$invoices = $this->service->createInvoices($query, $this->dispatcher);
$this->flashSuccess('action.update.success');
if (\count($invoices) === 1) {
return $this->redirectToRoute('admin_invoice_list', ['id' => $invoices[0]->getId()]);
}
return $this->redirectToRoute('admin_invoice_list');
} catch (Exception $ex) {
$this->flashUpdateException($ex);
}
return $this->redirectToRoute('invoice');
} | CWE-639 | 9 |
protected function _fclose($fp, $path='') {
return @fclose($fp);
} | CWE-89 | 0 |
public function showall() {
global $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(
'sections' => $navsections,
'current' => $current,
'canManage' => ((isset($user->is_acting_admin) && $user->is_acting_admin == 1) ? 1 : 0),
));
}
| CWE-89 | 0 |
$contentType = str_replace('data:', '', $cur);
}
}
} else { | CWE-434 | 5 |
function readline(StreamInterface $stream, $maxLength = null)
{
$buffer = '';
$size = 0;
while (!$stream->eof()) {
// Using a loose equality here to match on '' and false.
if (null == ($byte = $stream->read(1))) {
return $buffer;
}
$buffer .= $byte;
// Break when a new line is found or the max length - 1 is reached
if ($byte == PHP_EOL || ++$size == $maxLength - 1) {
break;
}
}
return $buffer;
} | CWE-89 | 0 |
static function activate($uid, $karmalevel = 'pear.dev')
{
require_once 'Damblan/Karma.php';
global $dbh, $auth_user;
$karma = new Damblan_Karma($dbh);
$user = user::info($uid, null, 0);
if (!isset($user['registered'])) {
return false;
}
@$arr = unserialize($user['userinfo']);
include_once 'pear-database-note.php';
note::removeAll($uid);
$data = array();
$data['registered'] = 1;
$data['active'] = 1;
/* $data['ppp_only'] = 0; */
if (is_array($arr)) {
$data['userinfo'] = $arr[1];
}
$data['created'] = gmdate('Y-m-d H:i');
$data['createdby'] = $auth_user->handle;
$data['handle'] = $user['handle'];
user::update($data, true);
$karma->grant($user['handle'], $karmalevel);
if ($karma->has($user['handle'], 'pear.dev')) {
include_once 'pear-rest.php';
$pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh);
$pear_rest->saveMaintainerREST($user['handle']);
$pear_rest->saveAllMaintainersREST();
}
include_once 'pear-database-note.php';
note::add($uid, "Account opened");
$msg = "Your PEAR account request has been opened.\n".
"To log in, go to http://" . PEAR_CHANNELNAME . "/ and click on \"login\" in\n".
"the top-right menu.\n";
$xhdr = 'From: ' . $auth_user->handle . '@php.net';
if (!DEVBOX) {
mail($user['email'], "Your PEAR Account Request", $msg, $xhdr, '-f ' . PEAR_BOUNCE_EMAIL);
}
return true;
} | CWE-640 | 20 |
public function getHtmlForControlButtons()
{
$ret = '';
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
$db = $this->realParent()->real_name;
$item = $this->real_name;
$ret = '<span class="navItemControls">'
. '<a href="navigation.php?'
. PMA_URL_getCommon()
. '&hideNavItem=true'
. '&itemType=' . urldecode($this->getItemType())
. '&itemName=' . urldecode($item)
. '&dbName=' . urldecode($db) . '"'
. ' class="hideNavItem ajax">'
. PMA_Util::getImage('lightbulb_off.png', __('Hide'))
. '</a></span>';
}
return $ret;
} | CWE-79 | 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-639 | 9 |
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-89 | 0 |
$db->updateObject($value, 'section');
}
$db->updateObject($moveSec, 'section');
//handle re-ranking of previous parent
$oldSiblings = $db->selectObjects("section", "parent=" . $oldParent . " AND rank>" . $oldRank . " ORDER BY rank");
$rerank = 1;
foreach ($oldSiblings as $value) {
if ($value->id != $moveSec->id) {
$value->rank = $rerank;
$db->updateObject($value, 'section');
$rerank++;
}
}
if ($oldParent != $moveSec->parent) {
//we need to re-rank the children of the parent that the moving section has just left
$childOfLastMove = $db->selectObjects("section", "parent=" . $oldParent . " ORDER BY rank");
for ($i = 0, $iMax = count($childOfLastMove); $i < $iMax; $i++) {
$childOfLastMove[$i]->rank = $i;
$db->updateObject($childOfLastMove[$i], 'section');
}
}
}
}
self::checkForSectionalAdmins($move);
expSession::clearAllUsersSessionCache('navigation');
}
| CWE-89 | 0 |
private function getTaskLink()
{
$link = $this->taskLinkModel->getById($this->request->getIntegerParam('link_id'));
if (empty($link)) {
throw new PageNotFoundException();
}
return $link;
} | CWE-639 | 9 |
function get_current_tab()
{
$tab_keys = array_keys($this->menu_tabs);
$tab = isset( $_GET['tab'] ) ? sanitize_text_field($_GET['tab']) : $tab_keys[0];
return $tab;
}
| CWE-79 | 1 |
public function approve() {
expHistory::set('editable', $this->params);
/* The global constants can be overriden by passing appropriate params */
//sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet
$require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];
$require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];
$require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];
$notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];
if (empty($this->params['id'])) {
flash('error', gt('No ID supplied for note to approve'));
$lastUrl = expHistory::getLast('editable');
}
$simplenote = new expSimpleNote($this->params['id']);
assign_to_template(array(
'simplenote'=>$simplenote,
'require_login'=>$require_login,
'require_approval'=>$require_approval,
'require_notification'=>$require_notification,
'notification_email'=>$notification_email,
'tab'=>$this->params['tab']
));
} | CWE-89 | 0 |
function cfdef_input_textbox( array $p_field_def, $p_custom_field_value, $p_required = '' ) {
echo '<input ', helper_get_tab_index(), ' type="text" id="custom_field_', $p_field_def['id']
, '" name="custom_field_', $p_field_def['id'], '" ', $p_required;
if( $p_field_def['length_max'] > 0 ) {
echo ' maxlength="' . $p_field_def['length_max'] . '"'
, ' size="' . min( 80, $p_field_def['length_max'] ) . '"';
} else {
echo ' maxlength="255" size="80"';
}
if( !empty( $p_field_def['valid_regexp'] ) ) {
# the custom field regex is evaluated with preg_match and looks for a partial match in the string
# however, the html property is matched for the whole string.
# unless we have explicit start and end tokens, adapt the html regex to allow a substring match.
$t_cf_regex = $p_field_def['valid_regexp'];
if( substr( $t_cf_regex, 0, 1 ) != '^' ) {
$t_cf_regex = '.*' . $t_cf_regex;
}
if( substr( $t_cf_regex, -1 ) != '$' ) {
$t_cf_regex .= '.*';
}
echo ' pattern="' . $t_cf_regex . '"';
}
echo ' value="' . string_attribute( $p_custom_field_value ) .'" />';
} | CWE-79 | 1 |
public static function getId($id=''){
if(isset($id)){
$sql = sprintf("SELECT * FROM `menus` WHERE `id` = '%d' ORDER BY `order` ASC", $id);
$menus = Db::result($sql);
$n = Db::$num_rows;
}else{
$menus = '';
}
return $menus;
} | CWE-89 | 0 |
protected function getShopByRequest(Request $request)
{
$repository = $this->get(ModelManager::class)->getRepository(Shop::class);
$shop = null;
if ($request->getPost('__shop') !== null) {
$shop = $repository->getActiveById($request->getPost('__shop'));
}
if ($shop === null && $request->getCookie('shop') !== null) {
$shop = $repository->getActiveById($request->getCookie('shop'));
}
if ($shop && $request->getCookie('shop') !== null && $request->getPost('__shop') == null) {
$requestShop = $repository->getActiveByRequest($request);
if ($requestShop !== null && $shop->getId() !== $requestShop->getId() && $shop->getBaseUrl() !== $requestShop->getBaseUrl()) {
$shop = $requestShop;
}
}
if ($shop === null) {
$shop = $repository->getActiveByRequest($request);
}
if ($shop === null) {
$shop = $repository->getActiveDefault();
}
return $shop;
} | CWE-601 | 11 |
public static function rpc ($url) {
new Pinger();
//require_once( GX_LIB.'/Vendor/IXR_Library.php' );
$url = 'http://'.$url;
$client = new IXR_Client( $url );
$client->timeout = 3;
$client->useragent .= ' -- PingTool/1.0.0';
$client->debug = false;
if( $client->query( 'weblogUpdates.extendedPing', self::$myBlogName, self::$myBlogUrl, self::$myBlogUpdateUrl, self::$myBlogRSSFeedUrl ) )
{
return $client->getResponse();
}
//echo 'Failed extended XML-RPC ping for "' . $url . '": ' . $client->getErrorCode() . '->' . $client->getErrorMessage() . '<br />';
if( $client->query( 'weblogUpdates.ping', self::$myBlogName, self::$myBlogUrl ) )
{
return $client->getResponse();
}
//echo 'Failed basic XML-RPC ping for "' . $url . '": ' . $client->getErrorCode() . '->' . $client->getErrorMessage() . '<br />';
return false;
}
| CWE-89 | 0 |
$ul->appendChild(new XMLElement('li', $s->get('navigation_group')));
$groups[] = $s->get('navigation_group');
} | CWE-79 | 1 |
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$category = $this->getCategory();
if ($this->categoryModel->remove($category['id'])) {
$this->flash->success(t('Category removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this category.'));
}
$this->response->redirect($this->helper->url->to('CategoryController', 'index', array('project_id' => $project['id'])));
} | CWE-639 | 9 |
function unlockTables() {
$sql = "UNLOCK TABLES";
$res = mysqli_query($this->connection, $sql);
return $res;
} | CWE-89 | 0 |
$banner->increaseImpressions();
}
}
// assign banner to the template and show it!
assign_to_template(array(
'banners'=>$banners
));
} | CWE-89 | 0 |
public function getQueryGroupby()
{
// SubmittedOn is stored in the artifact
return 'a.submitted_on';
} | CWE-89 | 0 |
public function checkCode($secret, $code, $discrepancy = 3)
{
/*
$time = floor(time() / 30);
for ($i = -1; $i <= 1; $i++) {
if ($this->getCode($secret, $time + $i) == $code) {
return true;
}
}
*/
$currentTimeSlice = floor(time() / 30);
for ($i = -$discrepancy; $i <= $discrepancy; $i++) {
$calculatedCode = $this->getCode($secret, $currentTimeSlice + $i);
if ($calculatedCode == $code ) {
return true;
}
}
return false;
} | CWE-89 | 0 |
public function editTitle() {
global $user;
$file = new expFile($this->params['id']);
if ($user->id==$file->poster || $user->isAdmin()) {
$file->title = $this->params['newValue'];
$file->save();
$ar = new expAjaxReply(200, gt('Your title was updated successfully'), $file);
} else {
$ar = new expAjaxReply(300, gt("You didn't create this file, so you can't edit it."));
}
$ar->send();
} | CWE-89 | 0 |
public static function activate($id){
$act = Db::query(
sprintf("UPDATE `user` SET `status` = '1' WHERE `id` = '%d'",
Typo::int($id)
)
);
if($act){
return true;
}else{
return false;
}
}
| CWE-89 | 0 |
protected function getFullPath($path, $base) {
$separator = $this->separator;
$systemroot = $this->systemRoot;
$sepquoted = preg_quote($separator, '#');
// normalize `/../`
$normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#';
while(preg_match($normreg, $path)) {
$path = preg_replace($normreg, '$1', $path);
}
// 'Here'
if ($path === '' || $path === '.' . $separator) return $base;
// Absolute path
if ($path[0] === $separator || strpos($path, $systemroot) === 0) {
return $path;
}
$preg_separator = '#' . $sepquoted . '#';
// Relative path from 'Here'
if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) {
$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
if ($arrn[0] !== '.') {
array_unshift($arrn, '.');
}
$arrn[0] = $base;
return join($separator, $arrn);
}
// Relative path from dirname()
if (substr($path, 0, 3) === '../') {
$arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY);
$arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY);
while (! empty($arrn) && $arrn[0] === '..') {
array_shift($arrn);
array_pop($arrp);
}
$path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) :
(! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot);
}
return $path;
} | CWE-89 | 0 |
public static function unpublish($id) {
$id = Typo::int($id);
$ins = array(
'table' => 'posts',
'id' => $id,
'key' => array(
'status' => '0'
)
);
$post = Db::update($ins);
return $post;
}
| CWE-89 | 0 |
protected function prepareImport($model, $csvName) {
$this->openX2 ('/admin/importModels?model='.ucfirst($model));
$csv = implode(DIRECTORY_SEPARATOR, array(
Yii::app()->basePath,
'tests',
'data',
'csvs',
$csvName
));
$this->type ('data', $csv);
$this->clickAndWait ("dom=document.querySelector ('input[type=\"submit\"]')");
$this->assertCsvUploaded ($csv);
} | CWE-79 | 1 |
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$tag_id = $this->request->getIntegerParam('tag_id');
$tag = $this->tagModel->getById($tag_id);
if ($tag['project_id'] != $project['id']) {
throw new AccessForbiddenException();
}
if ($this->tagModel->remove($tag_id)) {
$this->flash->success(t('Tag removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this tag.'));
}
$this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id'])));
} | CWE-639 | 9 |
public static function background($item_type, $item_id, $color)
{
global $DB;
global $website;
global $user;
$DB->execute('
INSERT INTO nv_notes
(id, website, user, item_type, item_id, background, note, date_created)
VALUES
( 0, :website, :user, :item_type, :item_id, :background, :note, :date_created )',
array(
':website' => $website->id,
':user' => value_or_default($user->id, 0),
':item_type' => value_or_default($item_type, ''),
':item_id' => value_or_default($item_id, 0),
':background' => value_or_default($color, ""),
':note' => "",
':date_created' => time()
)
);
$background = $DB->query_single(
'background',
'nv_notes',
'website = '.$website->id.'
AND item_type = '.protect($item_type).'
AND item_id = '.protect($item_id).'
ORDER BY date_created DESC'
);
// TODO: purge old grid notes when current background is empty or transparent
// => remove all empty notes
// NOT REALLY NEEDED, just save the item grid notes history, let the user remove at will
if(empty($background) || $background=='transparent')
{
$DB->execute('
DELETE FROM nv_notes
WHERE website = '.$website->id.'
AND item_type = '.protect($item_type).'
AND item_id = '.protect($item_id).'
AND note = ""
');
}
}
| CWE-89 | 0 |
rsvpmaker_tx_email($post, $mail);
}
$send_confirmation = get_post_meta($post->ID,'_rsvp_rsvpmaker_send_confirmation_email',true);
$confirm_on_payment = get_post_meta($post->ID,'_rsvp_confirmation_after_payment',true);
if(($send_confirmation ||!is_numeric($send_confirmation)) && empty($confirm_on_payment) )//if it hasn't been set to 0, send it
{
$confirmation_subject = $templates['confirmation']['subject'];
foreach($rsvpdata as $field => $value)
$confirmation_subject = str_replace('['.$field.']',$value,$confirmation_subject);
$confirmation_body = $templates['confirmation']['body'];
foreach($rsvpdata as $field => $value)
$confirmation_body = str_replace('['.$field.']',$value,$confirmation_body);
$confirmation_body = do_blocks(do_shortcode($confirmation_body));
$mail["html"] = wpautop($confirmation_body);
if(isset($post->ID)) // not for replay
$mail["ical"] = rsvpmaker_to_ical_email ($post->ID, $rsvp_to, $rsvp["email"]);
$mail["to"] = $rsvp["email"];
$mail["from"] = $rsvp_to_array[0];
$mail["fromname"] = get_bloginfo('name');
$mail["subject"] = $confirmation_subject;
rsvpmaker_tx_email($post, $mail);
}
} | CWE-89 | 0 |
public static function returnChildrenAsJSON() {
global $db;
//$nav = section::levelTemplate(intval($_REQUEST['id'], 0));
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
$nav = $db->selectObjects('section', 'parent=' . $id, 'rank');
//FIXME $manage_all is moot w/ cascading perms now?
$manage_all = false;
if (expPermissions::check('manage', expCore::makeLocation('navigation', '', $id))) {
$manage_all = true;
}
//FIXME recode to use foreach $key=>$value
$navcount = count($nav);
for ($i = 0; $i < $navcount; $i++) {
if ($manage_all || expPermissions::check('manage', expCore::makeLocation('navigation', '', $nav[$i]->id))) {
$nav[$i]->manage = 1;
$view = true;
} else {
$nav[$i]->manage = 0;
$view = $nav[$i]->public ? true : expPermissions::check('view', expCore::makeLocation('navigation', '', $nav[$i]->id));
}
$nav[$i]->link = expCore::makeLink(array('section' => $nav[$i]->id), '', $nav[$i]->sef_name);
if (!$view) unset($nav[$i]);
}
$nav= array_values($nav);
// $nav[$navcount - 1]->last = true;
if (count($nav)) $nav[count($nav) - 1]->last = true;
// echo expJavascript::ajaxReply(201, '', $nav);
$ar = new expAjaxReply(201, '', $nav);
$ar->send();
}
| CWE-89 | 0 |
foreach ($val as $vkey => $value) {
if ($vkey != 'LAST_UPDATED') {
if ($vkey != 'UPDATED_BY') {
if ($vkey == 'ID')
echo '<SCHOOL_ID>' . htmlentities($value) . '</SCHOOL_ID>';
else if ($vkey == 'SYEAR')
echo '<SCHOOL_YEAR>' . htmlentities($value) . '</SCHOOL_YEAR>';
else if ($vkey == 'TITLE')
echo '<SCHOOL_NAME>' . htmlentities($value) . '</SCHOOL_NAME>';
else if ($vkey == 'WWW_ADDRESS')
echo '<URL>' . htmlentities($value) . '</URL>';
else
echo '<' . $vkey . '>' . htmlentities($value) . '</' . $vkey . '>';
}
}
} | CWE-79 | 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-798 | 18 |
$chrootPath = realpath($chrootPath);
if ($chrootPath !== false && strpos($realfile, $chrootPath) === 0) {
$chrootValid = true;
break;
}
}
if ($chrootValid !== true) {
Helpers::record_warnings(E_USER_WARNING, "Permission denied on $remoteFile. The file could not be found under the paths specified by Options::chroot.", __FILE__, __LINE__);
return false;
}
}
if (!$realfile) {
Helpers::record_warnings(E_USER_WARNING, "File '$realfile' not found.", __FILE__, __LINE__);
return false;
}
$remoteFile = $realfile;
}
list($remoteFileContent, $http_response_header) = @Helpers::getFileContent($remoteFile, $context);
if ($remoteFileContent === null) {
return false;
}
$localTempFile = @tempnam($this->options->get("tempDir"), "dompdf-font-");
file_put_contents($localTempFile, $remoteFileContent);
$font = Font::load($localTempFile);
if (!$font) {
unlink($localTempFile);
return false;
}
$font->parse();
$font->saveAdobeFontMetrics("$localFilePath.ufm");
$font->close();
unlink($localTempFile);
if ( !file_exists("$localFilePath.ufm") ) {
return false;
}
$fontExtension = ".ttf";
switch ($font->getFontType()) {
case "TrueType":
default:
$fontExtension = ".ttf";
break;
}
// Save the changes
file_put_contents($localFilePath.$fontExtension, $remoteFileContent);
if ( !file_exists($localFilePath.$fontExtension) ) {
unlink("$localFilePath.ufm");
return false;
}
$this->setFontFamily($fontname, $entry);
return true;
} | CWE-73 | 23 |
public static function login() {
user::login(expString::sanitize($_POST['username']),expString::sanitize($_POST['password']));
if (!isset($_SESSION[SYS_SESSION_KEY]['user'])) { // didn't successfully log in
flash('error', gt('Invalid Username / Password'));
if (expSession::is_set('redirecturl_error')) {
$url = expSession::get('redirecturl_error');
expSession::un_set('redirecturl_error');
header("Location: ".$url);
} else {
expHistory::back();
}
} else { // we're logged in
global $user;
if (expSession::get('customer-login')) expSession::un_set('customer-login');
if (!empty($_POST['username'])) flash('message', gt('Welcome back').' '.expString::sanitize($_POST['username']));
if ($user->isAdmin()) {
expHistory::back();
} else {
foreach ($user->groups as $g) {
if (!empty($g->redirect)) {
$url = URL_FULL.$g->redirect;
break;
}
}
if (isset($url)) {
header("Location: ".$url);
} else {
expHistory::back();
}
}
}
} | CWE-89 | 0 |
} elseif ($exception instanceof ErrorException) {
$message = "{$exception->getName()}";
} else { | CWE-79 | 1 |
function sanitize_plural_expression($expr) {
// Get rid of disallowed characters.
$expr = preg_replace('@[^a-zA-Z0-9_:;\(\)\?\|\&=!<>+*/\%-]@', '', $expr);
// Add parenthesis for tertiary '?' operator.
$expr .= ';';
$res = '';
$p = 0;
for ($i = 0; $i < strlen($expr); $i++) {
$ch = $expr[$i];
switch ($ch) {
case '?':
$res .= ' ? (';
$p++;
break;
case ':':
$res .= ') : (';
break;
case ';':
$res .= str_repeat( ')', $p) . ';';
$p = 0;
break;
default:
$res .= $ch;
}
}
return $res;
} | CWE-94 | 14 |
function ttValidDate($val)
{
$val = trim($val);
if (strlen($val) == 0)
return false;
// This should accept a string in format 'YYYY-MM-DD', 'MM/DD/YYYY', 'DD-MM-YYYY', 'DD.MM.YYYY', or 'DD.MM.YYYY whatever'.
if (!preg_match('/^\d\d\d\d-\d\d-\d\d$/', $val) &&
!preg_match('/^\d\d\/\d\d\/\d\d\d\d$/', $val) &&
!preg_match('/^\d\d\-\d\d\-\d\d\d\d$/', $val) &&
!preg_match('/^\d\d\.\d\d\.\d\d\d\d$/', $val) &&
!preg_match('/^\d\d\.\d\d\.\d\d\d\d .+$/', $val))
return false;
return true;
} | CWE-79 | 1 |
public function approve_submit() {
if (empty($this->params['id'])) {
flash('error', gt('No ID supplied for comment to approve'));
expHistory::back();
}
/* 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->body = $this->params['body'];
$comment->approved = $this->params['approved'];
$comment->save();
expHistory::back();
} | CWE-89 | 0 |
public static function remove($token){
$json = Options::v('tokens');
$tokens = json_decode($json, true);
unset($tokens[$token]);
$tokens = json_encode($tokens);
if(Options::update('tokens',$tokens)){
return true;
}else{
return false;
}
}
| CWE-89 | 0 |
foreach ($allgroups as $gid) {
$g = group::getGroupById($gid);
expPermissions::grantGroup($g, 'manage', $sloc);
}
| CWE-89 | 0 |
public static function gZip () {
#ob_start(ob_gzhandler);
ob_start();
ob_implicit_flush(0);
}
| CWE-89 | 0 |
public function confirm()
{
$task = $this->getTask();
$link_id = $this->request->getIntegerParam('link_id');
$link = $this->taskExternalLinkModel->getById($link_id);
if (empty($link)) {
throw new PageNotFoundException();
}
$this->response->html($this->template->render('task_external_link/remove', array(
'link' => $link,
'task' => $task,
)));
} | CWE-639 | 9 |
public function __construct(
$status = 200,
array $headers = [],
$body = null,
$version = '1.1',
$reason = null
) {
$this->statusCode = (int) $status;
if ($body !== null) {
$this->stream = stream_for($body);
}
$this->setHeaders($headers);
if (!$reason && isset(self::$phrases[$this->statusCode])) {
$this->reasonPhrase = self::$phrases[$status];
} else {
$this->reasonPhrase = (string) $reason;
}
$this->protocol = $version;
} | CWE-89 | 0 |
}elseif($k2 == ''){
$va = ['default'];
}else{
| CWE-89 | 0 |
private function getSwimlane()
{
$swimlane = $this->swimlaneModel->getById($this->request->getIntegerParam('swimlane_id'));
if (empty($swimlane)) {
throw new PageNotFoundException();
}
return $swimlane;
} | CWE-639 | 9 |
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-89 | 0 |
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-89 | 0 |
function edit_freeform() {
$section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params);
if ($section->parent == -1) {
notfoundController::handle_not_found();
exit;
} // doesn't work for standalone pages
if (empty($section->id)) {
$section->public = 1;
if (!isset($section->parent)) {
// This is another precaution. The parent attribute
// should ALWAYS be set by the caller.
//FJD - if that's the case, then we should die.
notfoundController::handle_not_authorized();
exit;
//$section->parent = 0;
}
}
assign_to_template(array(
'section' => $section,
'glyphs' => self::get_glyphs(),
));
}
| CWE-89 | 0 |
public function getQueryOrderby()
{
return '';
} | CWE-89 | 0 |
$field_id = Symphony::Database()->fetchVar('id', 0, sprintf(
"SELECT `f`.`id`
FROM `tbl_fields` AS `f`, `tbl_sections` AS `s`
WHERE `s`.`id` = `f`.`parent_section`
AND f.`element_name` = '%s'
AND `s`.`handle` = '%s'
LIMIT 1",
$handle,
$section->get('handle'))
);
$field = $entryManager->fieldManager->fetch($field_id);
if($field instanceof Field) {
// For deprecated reasons, call the old, typo'd function name until the switch to the
// properly named buildDSRetrievalSQL function.
$field->buildDSRetrivalSQL(array($value), $joins, $where, false);
$filter_querystring .= sprintf("filter[%s]=%s&", $handle, rawurlencode($value));
$prepopulate_querystring .= sprintf("prepopulate[%d]=%s&", $field_id, rawurlencode($value));
} else {
unset($filters[$i]);
}
} | CWE-79 | 1 |
public function testResolvesUris($base, $rel, $expected)
{
$uri = new Uri($base);
$actual = Uri::resolve($uri, $rel);
$this->assertEquals($expected, (string) $actual);
} | CWE-89 | 0 |
public static function rss() {
switch (SMART_URL) {
case true:
# code...
$url = Options::get('siteurl')."/rss".GX_URL_PREFIX;
break;
default:
# code...
$url = Options::get('siteurl')."/index.php?rss";
break;
}
return $url;
} | CWE-79 | 1 |
public function handle($request, Closure $next)
{
$checkCart = cart_get_items_count();
if (!$checkCart) {
//$shop_page = get_content('single=true&content_type=page&is_shop=1');
$shop_page = app()->content_repository->getFirstShopPage();
$redir = site_url();
if ($shop_page and isset($shop_page['id'])) {
$link = content_link($shop_page['id']);
if ($link) {
$redir = $link;
}
}
return redirect($redir);
}
$requiresRegistration = get_option('shop_require_registration', 'website') == '1';
if ($requiresRegistration and is_logged() == false) {
return redirect(route('checkout.login'));
}
return $next($request);
} | CWE-79 | 1 |
public function getHeader()
{
$html = '<meta charset="utf-8">
<title>'.$this->getTitle().'</title>
<meta name="description" content="">';
$html .= '<link href="'.$this->getStaticUrl('css/bootstrap.css').'" rel="stylesheet">
<link href="'.$this->getStaticUrl('css/font-awesome.css').'" rel="stylesheet">
<link href="'.$this->getStaticUrl('css/global.css').'" rel="stylesheet">
<link href="'.$this->getStaticUrl('css/ui-lightness/jquery-ui.css').'" rel="stylesheet">
<link href="'.$this->getStaticUrl('../application/modules/user/static/css/user.css').'" rel="stylesheet">
<script src="'.$this->getStaticUrl('js/jquery.js').'"></script>
<script src="'.$this->getStaticUrl('js/bootstrap.js').'"></script>
<script src="'.$this->getStaticUrl('js/jquery-ui.js').'"></script>';
return $html;
} | CWE-79 | 1 |
public static function name($id) {
return Categories::name($id);
}
| CWE-89 | 0 |
public function getModel()
{
return $this->model;
} | CWE-79 | 1 |
public function getImage($id){
$url = "http://api.themoviedb.org/3/movie/{$id}/images?api_key=".$this->apikey;
$cast = $this->curl($url);
return $cast;
}
| CWE-89 | 0 |
public function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0) {
$this->host = $host;
// If no port value is passed, retrieve it
if ($port == false) {
$this->port = $this->POP3_PORT;
} else {
$this->port = $port;
}
// If no port value is passed, retrieve it
if ($tval == false) {
$this->tval = $this->POP3_TIMEOUT;
} else {
$this->tval = $tval;
}
$this->do_debug = $debug_level;
$this->username = $username;
$this->password = $password;
// Refresh the error log
$this->error = null;
// Connect
$result = $this->Connect($this->host, $this->port, $this->tval);
if ($result) {
$login_result = $this->Login($this->username, $this->password);
if ($login_result) {
$this->Disconnect();
return true;
}
}
// We need to disconnect regardless if the login succeeded
$this->Disconnect();
return false;
} | CWE-79 | 1 |
function edit($selected_events, $queue)
{
global $database_ged;
// get all needed infos into variables
$value_parts = explode(":", $selected_events);
$id = $value_parts[0];
$ged_type = $value_parts[1];
$sql = "SELECT comments FROM ".$ged_type."_queue_".$queue." WHERE id = $id";
$result = sqlrequest($database_ged, $sql);
$event = mysqli_fetch_assoc($result);
$event["comments"] = str_replace("\'", "'", $event["comments"]);
$event["comments"] = str_replace("\#", "#'", $event["comments"]);
echo "
<form id='edit-event-form'>
<div class='form-group'>
<label>".getLabel("label.add_comment")."</label>
<textarea id='event-comments' class='form-control textarea' rows='10'>".$event["comments"]."</textarea>
</div>
</form>";
} | CWE-78 | 6 |
public function getUserList()
{
$result = [];
$users = CodeModel::all(User::tableName(), 'nick', 'nick', false);
foreach ($users as $codeModel) {
if ($codeModel->code != 'admin') {
$result[$codeModel->code] = $codeModel->description;
}
}
return $result;
} | CWE-79 | 1 |
public function showall() {
expHistory::set('viewable', $this->params);
$hv = new help_version();
//$current_version = $hv->find('first', 'is_current=1');
$ref_version = $hv->find('first', 'version=\''.$this->help_version.'\'');
// pagination parameter..hard coded for now.
$where = $this->aggregateWhereClause();
$where .= 'AND help_version_id='.(empty($ref_version->id)?'0':$ref_version->id); | CWE-89 | 0 |
public function __construct($message = null, $code = 0, Exception $previous = null)
{
if ($message === null) {
$message = _('Authentication required');
}
parent::__construct($message, $code, $previous);
} | CWE-307 | 26 |
public function enable()
{
$this->checkCSRFParam();
$project = $this->getProject();
$swimlane_id = $this->request->getIntegerParam('swimlane_id');
if ($this->swimlaneModel->enable($project['id'], $swimlane_id)) {
$this->flash->success(t('Swimlane updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this swimlane.'));
}
$this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
} | CWE-639 | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.