code
stringlengths 23
2.05k
| label_name
stringlengths 6
7
| label
int64 0
37
|
---|---|---|
Variables::setVar( [ '', '', $variable, $value ] );
if ( defined( 'ExtVariables::VERSION' ) ) {
\ExtVariables::get( $this->parser )->setVarValue( $variable, $value );
}
}
} | CWE-400 | 2 |
private function runCallback() {
foreach ($this->records as &$record) {
if (isset($record->ref_type)) {
$refType = $record->ref_type;
if (class_exists($record->ref_type)) {
$type = new $refType();
$classinfo = new ReflectionClass($type);
if ($classinfo->hasMethod('paginationCallback')) {
$item = new $type($record->original_id);
$item->paginationCallback($record);
}
}
}
}
} | CWE-74 | 1 |
static function displayname() {
return "Events";
}
| CWE-74 | 1 |
public function checkHTTP($link, $get_body = false)
{
if (! function_exists('curl_init')) {
return null;
}
$handle = curl_init($link);
if ($handle === false) {
return null;
}
PMA_Util::configureCurl($handle);
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($handle, CURLOPT_TIMEOUT, 5);
curl_setopt($handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
if (! defined('TESTSUITE')) {
session_write_close();
}
$data = @curl_exec($handle);
if (! defined('TESTSUITE')) {
ini_set('session.use_only_cookies', '0');
ini_set('session.use_cookies', '0');
ini_set('session.use_trans_sid', '0');
ini_set('session.cache_limiter', 'nocache');
session_start();
}
if ($data === false) {
return null;
}
$http_status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if ($http_status == 200) {
return $get_body ? $data : true;
}
if ($http_status == 404) {
return false;
}
return null;
} | CWE-20 | 0 |
public function testGetEventsPublicProfile(){
TestingAuxLib::loadX2NonWebUser ();
TestingAuxLib::suLogin ('testuser');
Yii::app()->settings->historyPrivacy = null;
$lastEventId=0;
$lastTimestamp=0;
$myProfile = Profile::model()->findByAttributes(array('username' => 'testuser2'));
$events=Events::getEvents(
$lastEventId,$lastTimestamp,null,$myProfile, false);
$this->assertEquals (
array_map (
function ($event) { return $event->id; },
Events::model ()->findAllByAttributes (array (
'user' => 'testuser2',
'visibility' => 1
))
),
array_map (function ($event) { return $event->id; }, $events['events']));
TestingAuxLib::restoreX2WebUser ();
} | CWE-20 | 0 |
$comments->records[$key]->avatar = $db->selectObject('user_avatar',"user_id='".$record->poster."'");
}
if (empty($this->params['config']['disable_nested_comments'])) $comments->records = self::arrangecomments($comments->records);
// eDebug($sql, true);
// count the unapproved comments
if ($require_approval == 1 && $user->isAdmin()) {
$sql = 'SELECT count(com.id) as c FROM '.$db->prefix.'expComments com ';
$sql .= 'JOIN '.$db->prefix.'content_expComments cnt ON com.id=cnt.expcomments_id ';
$sql .= 'WHERE cnt.content_id='.$this->params['content_id']." AND cnt.content_type='".$this->params['content_type']."' ";
$sql .= 'AND com.approved=0';
$unapproved = $db->countObjectsBySql($sql);
} else {
$unapproved = 0;
}
$this->config = $this->params['config'];
$type = !empty($this->params['type']) ? $this->params['type'] : gt('Comment');
$ratings = !empty($this->params['ratings']) ? true : false;
assign_to_template(array(
'comments'=>$comments,
'config'=>$this->params['config'],
'unapproved'=>$unapproved,
'content_id'=>$this->params['content_id'],
'content_type'=>$this->params['content_type'],
'user'=>$user,
'hideform'=>$this->params['hideform'],
'hidecomments'=>$this->params['hidecomments'],
'title'=>$this->params['title'],
'formtitle'=>$this->params['formtitle'],
'type'=>$type,
'ratings'=>$ratings,
'require_login'=>$require_login,
'require_approval'=>$require_approval,
'require_notification'=>$require_notification,
'notification_email'=>$notification_email,
));
} | CWE-74 | 1 |
public static function getItems($term) {
$model = X2Model::model(Yii::app()->controller->modelClass);
if (isset($model)) {
$tableName = $model->tableName();
$sql = 'SELECT id, name as value
FROM ' . $tableName . ' WHERE name LIKE :qterm ORDER BY name ASC';
$command = Yii::app()->db->createCommand($sql);
$qterm = $term . '%';
$command->bindParam(":qterm", $qterm, PDO::PARAM_STR);
$result = $command->queryAll();
echo CJSON::encode($result);
}
Yii::app()->end();
} | CWE-20 | 0 |
public function save_user() {
if ( empty( $_POST['user_id'] ) ) {
return false;
}
$user_id = $_POST['user_id'];
if ( !is_numeric( $user_id ) ) {
return $user_id;
}
if ( !current_user_can( 'edit_user', $user_id ) ) {
return $user_id;
}
return $this->save_posted_object_location( $user_id );
}
| CWE-20 | 0 |
static function convertUTF($string) {
return $string = str_replace('?', '', htmlspecialchars($string, ENT_IGNORE, 'UTF-8'));
} | CWE-74 | 1 |
private static function retrieveClosurePattern($pure, $closureName)
{
$pattern = '/';
if (!$pure) {
$pattern .= preg_quote(self::$registeredDelimiters[0]) . "\s*";
}
$pattern .= "$closureName\(([a-z0-9,\.\s]+)\)";
if (!$pure) {
$pattern .= "\s*" . preg_quote(self::$registeredDelimiters[1]);
}
return $pattern . "/i";
} | CWE-74 | 1 |
$query->whereExists(function ($permissionQuery) use (&$tableDetails, $action) {
/** @var Builder $permissionQuery */
$permissionQuery->select(['role_id'])->from('joint_permissions')
->whereColumn('joint_permissions.entity_id', '=', $tableDetails['tableName'] . '.' . $tableDetails['entityIdColumn'])
->whereColumn('joint_permissions.entity_type', '=', $tableDetails['tableName'] . '.' . $tableDetails['entityTypeColumn'])
->where('action', '=', $action)
->whereIn('role_id', $this->getCurrentUserRoles())
->where(function (QueryBuilder $query) {
$this->addJointHasPermissionCheck($query, $this->currentUser()->id);
});
}); | CWE-863 | 11 |
$tokens = preg_split( '/ - */', $title );
$newKey = '';
foreach ( $tokens as $token ) {
$initial = substr( $token, 0, 1 );
if ( $initial >= '1' && $initial <= '7' ) {
$newKey .= $initial;
$suit = substr( $token, 1 );
if ( $suit == '♣' ) {
$newKey .= '1';
} elseif ( $suit == '♦' ) {
$newKey .= '2';
} elseif ( $suit == '♥' ) {
$newKey .= '3';
} elseif ( $suit == '♠' ) {
$newKey .= '4';
} elseif ( strtolower( $suit ) == 'sa' || strtolower( $suit ) == 'nt' ) {
$newKey .= '5 ';
} else {
$newKey .= $suit;
}
} elseif ( strtolower( $initial ) == 'p' ) {
$newKey .= '0 ';
} elseif ( strtolower( $initial ) == 'x' ) {
$newKey .= '8 ';
} else {
$newKey .= $token;
}
}
$sortKeys[$key] = $newKey;
}
asort( $sortKeys );
foreach ( $sortKeys as $oldKey => $newKey ) {
$sortedArticles[] = $articles[$oldKey];
}
return $sortedArticles;
} | CWE-400 | 2 |
public function testRemoveAuthorizationHeaderOnRedirect()
{
$mock = new MockHandler([
new Response(302, ['Location' => 'http://test.com']),
static function (RequestInterface $request) {
self::assertFalse($request->hasHeader('Authorization'));
return new Response(200);
}
]);
$handler = HandlerStack::create($mock);
$client = new Client(['handler' => $handler]);
$client->get('http://example.com?a=b', ['auth' => ['testuser', 'testpass']]);
} | CWE-200 | 10 |
private function _titlegt( $option ) {
$where = '(';
if ( substr( $option, 0, 2 ) == '=_' ) {
if ( $this->parameters->getParameter( 'openreferences' ) ) {
$where .= 'pl_title >= ' . $this->DB->addQuotes( substr( $sTitleGE, 2 ) );
} else {
$where .= $this->tableNames['page'] . '.page_title >= ' . $this->DB->addQuotes( substr( $option, 2 ) );
}
} else {
if ( $this->parameters->getParameter( 'openreferences' ) ) {
$where .= 'pl_title > ' . $this->DB->addQuotes( $option );
} else {
$where .= $this->tableNames['page'] . '.page_title > ' . $this->DB->addQuotes( $option );
}
}
$where .= ')';
$this->addWhere( $where );
} | CWE-400 | 2 |
public function enqueue_scripts() {
global $geo_mashup_options, $pagenow, $post;
// The location editor works only on posts
if ( empty( $post ) )
return null;
$load_location_editor = (
is_admin() and
preg_match( '/(post|page)(-new|).php/', $pagenow ) and
in_array( $post->post_type, $geo_mashup_options->get( 'overall', 'located_post_types' ) )
);
$load_location_editor = apply_filters( 'geo_mashup_load_location_editor', $load_location_editor );
// If we're on a post editing page, queue up the form interface elements
if ( $load_location_editor ) {
$this->enqueue_form_client_items();
}
}
| CWE-20 | 0 |
public function upload() {
// upload the file, but don't save the record yet...
if ($this->params['resize'] != 'false') {
$maxwidth = $this->params['max_width'];
} else {
$maxwidth = null;
}
$file = expFile::fileUpload('Filedata',false,false,null,null,$maxwidth);
// since most likely this function will only get hit via flash in YUI Uploader
// and since Flash can't pass cookies, we lose the knowledge of our $user
// so we're passing the user's ID in as $_POST data. We then instantiate a new $user,
// and then assign $user->id to $file->poster so we have an audit trail for the upload
if (is_object($file)) {
$resized = !empty($file->resized) ? true : false;
$user = new user($this->params['usrid']);
$file->poster = $user->id;
$file->posted = $file->last_accessed = time();
$file->save();
if (!empty($this->params['cat'])) {
$expcat = new expCat($this->params['cat']);
$params['expCat'][0] = $expcat->id;
$file->update($params);
}
// a echo so YUI Uploader is notified of the function's completion
if ($resized) {
echo gt('File resized and then saved');
} else {
echo gt('File saved');
}
} else {
echo gt('File was NOT uploaded!');
// flash('error',gt('File was not uploaded!'));
}
} | CWE-74 | 1 |
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 |
public function execute(&$params){
$options = &$this->config['options'];
$event = new Events;
$notif = new Notification;
$user = $this->parseOption('user', $params);
$type = $this->parseOption('type', $params);
if($type === 'auto'){
if(!isset($params['model']))
return array (false, '');
$notif->modelType = get_class($params['model']);
$notif->modelId = $params['model']->id;
$notif->type = $this->getNotifType();
$event->associationType = get_class($params['model']);
$event->associationId = $params['model']->id;
$event->type = $this->getEventType();
if($params['model']->hasAttribute('visibility'))
$event->visibility = $params['model']->visibility;
// $event->user = $this->parseOption('user',$params);
} else{
$text = $this->parseOption('text', $params);
$notif->type = 'custom';
$notif->text = $text;
$event->type = 'feed';
$event->subtype = $type;
$event->text = $text;
if($user == 'auto' && isset($params['model']) &&
$params['model']->hasAttribute('assignedTo') &&
!empty($params['model']->assignedTo)){
$event->user = $params['model']->assignedTo;
}elseif(!empty($user)){
$event->user = $user;
}else{
$event->user = 'admin';
}
}
if(!$this->parseOption('createNotif', $params)) {
if (!$notif->save()) {
return array(false, array_shift($notif->getErrors()));
}
}
if ($event->save()) {
return array (true, "");
} else {
return array(false, array_shift($event->getErrors()));
}
} | CWE-20 | 0 |
private function getCategory()
{
$category = $this->categoryModel->getById($this->request->getIntegerParam('category_id'));
if (empty($category)) {
throw new PageNotFoundException();
}
return $category;
} | CWE-200 | 10 |
function fread($handle, $length)
{
if (\yiiunit\framework\base\SecurityTest::$fread !== null) {
return \yiiunit\framework\base\SecurityTest::$fread;
}
if (\yiiunit\framework\base\SecurityTest::$fopen !== null) {
return $length < 8 ? \str_repeat('s', $length) : 'test1234';
}
return \fread($handle, $length);
} | CWE-330 | 12 |
function edit_option_master() {
expHistory::set('editable', $this->params);
$params = isset($this->params['id']) ? $this->params['id'] : $this->params;
$record = new option_master($params);
assign_to_template(array(
'record'=>$record
));
} | CWE-74 | 1 |
public function getDisplayName ($plural=true) {
return Yii::t('users', '{user}', array(
'{user}' => Modules::displayName($plural, 'Users'),
));
} | CWE-20 | 0 |
public function getClone($modelId = null)
{
$this->authorize('view', AssetModel::class);
// Check if the model exists
if (is_null($model_to_clone = AssetModel::find($modelId))) {
return redirect()->route('models.index')->with('error', trans('admin/models/message.does_not_exist'));
}
$model = clone $model_to_clone;
$model->id = null;
// Show the page
return view('models/edit')
->with('depreciation_list', Helper::depreciationList())
->with('item', $model)
->with('clone_model', $model_to_clone);
} | CWE-862 | 8 |
self::removeLevel($kid->id);
}
}
| CWE-74 | 1 |
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$action = $this->actionModel->getById($this->request->getIntegerParam('action_id'));
if (! empty($action) && $this->actionModel->remove($action['id'])) {
$this->flash->success(t('Action removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this action.'));
}
$this->response->redirect($this->helper->url->to('ActionController', 'index', array('project_id' => $project['id'])));
} | CWE-200 | 10 |
private static function init() {
\DPL\Config::init();
if ( !isset( self::$createdLinks ) ) {
self::$createdLinks = [
'resetLinks' => false,
'resetTemplates' => false,
'resetCategories' => false,
'resetImages' => false,
'resetdone' => false,
'elimdone' => false
];
}
} | CWE-400 | 2 |
public function session() {
// Test if logged in, log in if not, log in.
try {
$this->assertElementPresent('css=ul#user-menu');
} catch (PHPUnit_Framework_AssertionFailedError $e) {
/* If this isn't the first time we've logged in, we have a problem;
* the user should have been logged in throughout the life of the
* test case class. Append t
*/
if (!$this->firstLogin)
array_push($this->verificationErrors, $e->toString());
$this->firstLogin = false;
$this->login();
return 0;
}
try {
$this->assertCorrectUser();
} catch (PHPUnit_Framework_AssertionFailedError $e) {
/**
* The browser is logged in but not as the correct user.
*/
$this->logout();
$this->login();
$this->firstLogin = false;
return 0;
}
// Indicator of whether the session was already initialized properly
return 1;
} | CWE-20 | 0 |
function columnUpdate($table, $col, $val, $where=1) {
$res = @mysqli_query($this->connection, "UPDATE `" . $this->prefix . "$table` SET `$col`='" . $val . "' WHERE $where");
/*if ($res == null)
return array();
$objects = array();
for ($i = 0; $i < mysqli_num_rows($res); $i++)
$objects[] = mysqli_fetch_object($res);*/
//return $objects;
} | CWE-74 | 1 |
public function actionGetItems(){
$model = X2Model::model ($this->modelClass);
if (isset ($model)) {
$tableName = $model->tableName ();
$sql =
'SELECT id, subject as value
FROM '.$tableName.' WHERE subject LIKE :qterm ORDER BY subject ASC';
$command = Yii::app()->db->createCommand($sql);
$qterm = $_GET['term'].'%';
$command->bindParam(":qterm", $qterm, PDO::PARAM_STR);
$result = $command->queryAll();
echo CJSON::encode($result);
}
Yii::app()->end();
} | CWE-20 | 0 |
public function register()
{
JSession::checkToken('post') or jexit(JText::_('JINVALID_TOKEN'));
// Get the application
$app = JFactory::getApplication();
// Get the form data.
$data = $this->input->post->get('user', array(), 'array');
// Get the model and validate the data.
$model = $this->getModel('Registration', 'UsersModel');
$form = $model->getForm();
if (!$form)
{
JError::raiseError(500, $model->getError());
return false;
}
$return = $model->validate($form, $data);
// Check for errors.
if ($return === false)
{
// Get the validation messages.
$errors = $model->getErrors();
// Push up to three validation messages out to the user.
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
{
if ($errors[$i] instanceof Exception)
{
$app->enqueueMessage($errors[$i]->getMessage(), 'notice');
continue;
}
$app->enqueueMessage($errors[$i], 'notice');
}
// Save the data in the session.
$app->setUserState('users.registration.form.data', $data);
// Redirect back to the registration form.
$this->setRedirect('index.php?option=com_users&view=registration');
return false;
}
// Finish the registration.
$return = $model->register($data);
// Check for errors.
if ($return === false)
{
// Save the data in the session.
$app->setUserState('users.registration.form.data', $data);
// Redirect back to the registration form.
$message = JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $model->getError());
$this->setRedirect('index.php?option=com_users&view=registration', $message, 'error');
return false;
}
// Flush the data from the session.
$app->setUserState('users.registration.form.data', null);
return true;
} | CWE-20 | 0 |
public function getPurchaseOrderByJSON() {
if(!empty($this->params['vendor'])) {
$purchase_orders = $this->purchase_order->find('all', 'vendor_id=' . $this->params['vendor']);
} else {
$purchase_orders = $this->purchase_order->find('all');
}
echo json_encode($purchase_orders);
} | CWE-20 | 0 |
private function _lastmodifiedby( $option ) {
$user = new \User;
$this->addWhere( $this->DB->addQuotes( $user->newFromName( $option )->getActorId() ) . ' = (SELECT revactor_actor FROM ' . $this->tableNames['revision_actor_temp'] . ' WHERE ' . $this->tableNames['revision_actor_temp'] . '.revactor_page=page_id ORDER BY ' . $this->tableNames['revision_actor_temp'] . '.revactor_timestamp DESC LIMIT 1)' );
} | CWE-400 | 2 |
function GoodAuthDigestTestController($serverPort) {
$args = array('Authorization' => 'Digest username="admin", ' .
'realm="Restricted area", nonce="564a12611dae8", ' .
'uri="/test_auth_digest.php", cnonce="MjIyMTg1", nc=00000001, ' .
'qop="auth", response="e544aaed06917adea3e5c74dd49f0e32", ' .
'opaque="cdce8a5c95a1427d74df7acbf41c9ce0"');
var_dump(request(php_uname('n'), $serverPort, "test_auth_digest.php",
[], [], $args));
} | CWE-668 | 7 |
public function getPurchaseOrderByJSON() {
if(!empty($this->params['vendor'])) {
$purchase_orders = $this->purchase_order->find('all', 'vendor_id=' . $this->params['vendor']);
} else {
$purchase_orders = $this->purchase_order->find('all');
}
echo json_encode($purchase_orders);
} | CWE-20 | 0 |
protected function getSubtask()
{
$subtask = $this->subtaskModel->getById($this->request->getIntegerParam('subtask_id'));
if (empty($subtask)) {
throw new PageNotFoundException();
}
return $subtask;
} | CWE-200 | 10 |
function scan_page($parent_id) {
global $db;
$sections = $db->selectObjects('section','parent=' . $parent_id);
$ret = '';
foreach ($sections as $page) {
$cLoc = serialize(expCore::makeLocation('container','@section' . $page->id));
$ret .= scan_container($cLoc, $page->id);
$ret .= scan_page($page->id);
}
return $ret;
}
| CWE-74 | 1 |
function login($redirectCallback = null)
{
$aConf = $GLOBALS['_MAX']['CONF'];
if (!is_callable($redirectCallback)) {
// Set the default callback
$redirectCallback = array('OA_Auth', 'checkRedirect');
}
if (call_user_func($redirectCallback)) {
header('location: http://'.$aConf['webpath']['admin']);
exit();
}
if (defined('OA_SKIP_LOGIN')) {
return OA_Auth::getFakeSessionData();
}
if (OA_Auth::suppliedCredentials()) {
$doUser = OA_Auth::authenticateUser();
if (!$doUser) {
sleep(3);
OA_Auth::restart($GLOBALS['strUsernameOrPasswordWrong']);
}
return OA_Auth::getSessionData($doUser);
}
OA_Auth::restart();
} | CWE-287 | 4 |
function delete() {
global $db;
if (empty($this->params['id'])) return false;
$product_type = $db->selectValue('product', 'product_type', 'id=' . $this->params['id']);
$product = new $product_type($this->params['id'], true, false);
//eDebug($product_type);
//eDebug($product, true);
//if (!empty($product->product_type_id)) {
//$db->delete($product_type, 'id='.$product->product_id);
//}
$db->delete('option', 'product_id=' . $product->id . " AND optiongroup_id IN (SELECT id from " . $db->prefix . "optiongroup WHERE product_id=" . $product->id . ")");
$db->delete('optiongroup', 'product_id=' . $product->id);
//die();
$db->delete('product_storeCategories', 'product_id=' . $product->id . ' AND product_type="' . $product_type . '"');
if ($product->product_type == "product") {
if ($product->hasChildren()) {
$this->deleteChildren();
}
}
$product->delete();
flash('message', gt('Product deleted successfully.'));
expHistory::back();
} | CWE-74 | 1 |
public function testCheckHTTP()
{
if (! function_exists('curl_init')) {
$this->markTestSkipped('Missing curl extension!');
}
$this->assertTrue(
$this->object->checkHTTP("http://www.phpmyadmin.net/test/data")
);
$this->assertContains(
"TEST DATA",
$this->object->checkHTTP("http://www.phpmyadmin.net/test/data", true)
);
$this->assertFalse(
$this->object->checkHTTP("http://www.phpmyadmin.net/test/nothing")
);
} | CWE-20 | 0 |
public function testAuthHeader()
{
$restoreInstance = PMA\libraries\Response::getInstance();
$mockResponse = $this->getMockBuilder('PMA\libraries\Response')
->disableOriginalConstructor()
->setMethods(array('isAjax', 'headersSent', 'header'))
->getMock();
$mockResponse->expects($this->once())
->method('isAjax')
->with()
->will($this->returnValue(false));
$mockResponse->expects($this->any())
->method('headersSent')
->with()
->will($this->returnValue(false));
$mockResponse->expects($this->once())
->method('header')
->with('Location: http://www.phpmyadmin.net/logout' . ((SID) ? '?' . SID : '')); | CWE-200 | 10 |
public function push($remote = NULL, array $params = NULL)
{
$this->run('push', $remote, $params);
return $this;
} | CWE-77 | 14 |
public function create_directory() {
if (!AuthUser::hasPermission('file_manager_mkdir')) {
Flash::set('error', __('You do not have sufficient permissions to create a directory.'));
redirect(get_url('plugin/file_manager/browse/'));
}
// CSRF checks
if (isset($_POST['csrf_token'])) {
$csrf_token = $_POST['csrf_token'];
if (!SecureToken::validateToken($csrf_token, BASE_URL.'plugin/file_manager/create_directory')) {
Flash::set('error', __('Invalid CSRF token found!'));
redirect(get_url('plugin/file_manager/browse/'));
}
}
else {
Flash::set('error', __('No CSRF token found!'));
redirect(get_url('plugin/file_manager/browse/'));
}
$data = $_POST['directory'];
$path = str_replace('..', '', $data['path']);
$dirname = str_replace('..', '', $data['name']);
$dir = FILES_DIR . "/{$path}/{$dirname}";
if (mkdir($dir)) {
$mode = Plugin::getSetting('dirmode', 'file_manager');
chmod($dir, octdec($mode));
} else {
Flash::set('error', __('Directory :name has not been created!', array(':name' => $dirname)));
}
redirect(get_url('plugin/file_manager/browse/' . $path));
} | CWE-20 | 0 |
private function _namespace( $option ) {
$option === 0 ?? $option = '0';
if ( is_array( $option ) && count( $option ) ) {
if ( $this->parameters->getParameter( 'openreferences' ) ) {
$this->addWhere(
[
"{$this->tableNames['pagelinks']}.pl_namespace" => $option
]
);
} else {
$this->addWhere(
[
"{$this->tableNames['page']}.page_namespace" => $option
]
);
}
}
} | CWE-400 | 2 |
public function testIsExpiredReturnsTrueWhenModificationTimesWarrant()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('exists')->once()->with(__DIR__.'/'.sha1('foo').'.php')->andReturn(true);
$files->shouldReceive('lastModified')->once()->with('foo')->andReturn(100);
$files->shouldReceive('lastModified')->once()->with(__DIR__.'/'.sha1('foo').'.php')->andReturn(0);
$this->assertTrue($compiler->isExpired('foo'));
} | CWE-327 | 3 |
public static function generate_location_json( ) {
/* TODO: Try to track modification?
if ( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
$http_time = strtotime( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
$mod_time = strtotime( $post->post_modified_gmt . ' GMT' );
if ($mod_time <= $http_time) {
return status_header(304); // Not modified
}
}
status_header(200);
header( 'Last-Modified: ' . mysql2date( 'D, d M Y H:i:s', $post->post_modified_gmt, false ) . ' GMT' );
header( 'Content-type: text/xml; charset='.get_settings('blog_charset'), true);
header( 'Cache-control: max-age=300, must-revalidate', true);
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 300 ) . " GMT" );
header( 'Pragma:' );
*/
status_header(200);
header('Content-type: application/json; charset='.get_option('blog_charset'), true);
header('Cache-Control: no-cache;', true);
header('Expires: -1;', true);
$json = GeoMashup::get_locations_json($_REQUEST);
if ( isset( $_REQUEST['callback'] ) )
$json = $_REQUEST['callback'] . '(' . $json . ')';
echo $json;
}
| CWE-20 | 0 |
public function actionGetItems(){
$sql =
'SELECT id, name as value
FROM x2_templates
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 |
function edit_order_item() {
$oi = new orderitem($this->params['id'], true, true);
if (empty($oi->id)) {
flash('error', gt('Order item doesn\'t exist.'));
expHistory::back();
}
$oi->user_input_fields = expUnserialize($oi->user_input_fields);
$params['options'] = $oi->opts;
$params['user_input_fields'] = $oi->user_input_fields;
$oi->product = new product($oi->product->id, true, true);
if ($oi->product->parent_id != 0) {
$parProd = new product($oi->product->parent_id);
//$oi->product->optiongroup = $parProd->optiongroup;
$oi->product = $parProd;
}
//FIXME we don't use selectedOpts?
// $oi->selectedOpts = array();
// if (!empty($oi->opts)) {
// foreach ($oi->opts as $opt) {
// $option = new option($opt[0]);
// $og = new optiongroup($option->optiongroup_id);
// if (!isset($oi->selectedOpts[$og->id]) || !is_array($oi->selectedOpts[$og->id]))
// $oi->selectedOpts[$og->id] = array($option->id);
// else
// array_push($oi->selectedOpts[$og->id], $option->id);
// }
// }
//eDebug($oi->selectedOpts);
assign_to_template(array(
'oi' => $oi,
'params' => $params
));
} | CWE-74 | 1 |
private function _verify($public_key_or_secret, $expected_alg = null) {
$segments = explode('.', $this->raw);
$signature_base_string = implode('.', array($segments[0], $segments[1]));
if (!$expected_alg) {
# NOTE: might better to warn here
$expected_alg = $this->header['alg'];
}
switch ($expected_alg) {
case 'HS256':
case 'HS384':
case 'HS512':
return $this->signature === hash_hmac($this->digest(), $signature_base_string, $public_key_or_secret, true);
case 'RS256':
case 'RS384':
case 'RS512':
return $this->rsa($public_key_or_secret, RSA::SIGNATURE_PKCS1)->verify($signature_base_string, $this->signature);
case 'ES256':
case 'ES384':
case 'ES512':
throw new JOSE_Exception_UnexpectedAlgorithm('Algorithm not supported');
case 'PS256':
case 'PS384':
case 'PS512':
return $this->rsa($public_key_or_secret, RSA::SIGNATURE_PSS)->verify($signature_base_string, $this->signature);
default:
throw new JOSE_Exception_UnexpectedAlgorithm('Unknown algorithm');
}
} | CWE-200 | 10 |
public static function sortByPriority( $parameters ) {
if ( !is_array( $parameters ) ) {
throw new \MWException( __METHOD__ . ': A non-array was passed.' );
}
//'category' to get category headings first for ordermethod.
//'include'/'includepage' to make sure section labels are ready for 'table'.
$priority = [
'distinct' => 1,
'openreferences' => 2,
'ignorecase' => 3,
'category' => 4,
'title' => 5,
'goal' => 6,
'ordercollation' => 7,
'ordermethod' => 8,
'includepage' => 9,
'include' => 10
];
$_first = [];
foreach ( $priority as $parameter => $order ) {
if ( isset( $parameters[$parameter] ) ) {
$_first[$parameter] = $parameters[$parameter];
unset( $parameters[$parameter] );
}
}
$parameters = $_first + $parameters;
return $parameters;
} | CWE-400 | 2 |
public function showall() {
expHistory::set('viewable', $this->params);
// figure out if should limit the results
if (isset($this->params['limit'])) {
$limit = $this->params['limit'] == 'none' ? null : $this->params['limit'];
} else {
$limit = (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10;
}
$order = isset($this->config['order']) ? $this->config['order'] : 'publish DESC';
// pull the news posts from the database
$items = $this->news->find('all', $this->aggregateWhereClause(), $order);
// merge in any RSS news and perform the sort and limit the number of posts we return to the configured amount.
if (!empty($this->config['pull_rss'])) $items = $this->mergeRssData($items);
// setup the pagination object to paginate the news stories.
$page = new expPaginator(array(
'records'=>$items,
'limit'=>$limit,
'order'=>$order,
'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),
'controller'=>$this->params['controller'],
'action'=>$this->params['action'],
'src'=>$this->loc->src,
'view'=>empty($this->params['view']) ? null : $this->params['view']
));
assign_to_template(array(
'page'=>$page,
'items'=>$page->records,
'rank'=>($order==='rank')?1:0,
'params'=>$this->params,
));
} | CWE-74 | 1 |
foreach($image->expTag as $tag) {
if (isset($used_tags[$tag->id])) {
$used_tags[$tag->id]->count++;
} else {
$exptag = new expTag($tag->id);
$used_tags[$tag->id] = $exptag;
$used_tags[$tag->id]->count = 1;
}
} | CWE-74 | 1 |
function unlockTables() {
$sql = "UNLOCK TABLES";
$res = mysqli_query($this->connection, $sql);
return $res;
} | CWE-74 | 1 |
function showByModel() {
global $order, $template, $db;
expHistory::set('viewable', $this->params);
$product = new product();
$model = $product->find("first", 'model="' . $this->params['model'] . '"');
//eDebug($model);
$product_type = new $model->product_type($model->id);
//eDebug($product_type);
$tpl = $product_type->getForm('show');
if (!empty($tpl)) $template = new controllertemplate($this, $tpl);
//eDebug($template);
$this->grabConfig(); // grab the global config
assign_to_template(array(
'config' => $this->config,
'product' => $product_type,
'last_category' => $order->lastcat
));
} | CWE-20 | 0 |
$section = new section($this->params);
} else {
notfoundController::handle_not_found();
exit;
}
if (!empty($section->id)) {
$check_id = $section->id;
} else {
$check_id = $section->parent;
}
if (expPermissions::check('manage', expCore::makeLocation('navigation', '', $check_id))) {
if (empty($section->id)) {
$section->active = 1;
$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(),
));
} else { // User does not have permission to manage sections. Throw a 403
notfoundController::handle_not_authorized();
}
}
| CWE-74 | 1 |
public function testPopBeforeSmtpGood()
{
//Start a fake POP server
$pid = shell_exec('nohup ./runfakepopserver.sh >/dev/null 2>/dev/null & printf "%u" $!');
$this->pids[] = $pid;
sleep(2);
//Test a known-good login
$this->assertTrue(
POP3::popBeforeSmtp('localhost', 1100, 10, 'user', 'test', $this->Mail->SMTPDebug),
'POP before SMTP failed'
);
//Kill the fake server
shell_exec('kill -TERM '.escapeshellarg($pid));
sleep(2);
} | CWE-20 | 0 |
public static function checkPermissions($permission,$location) {
global $exponent_permissions_r, $router;
// only applies to the 'manage' method
if (empty($location->src) && empty($location->int) && (!empty($router->params['action']) && $router->params['action'] == 'manage') || strpos($router->current_url, 'action=manage') !== false) {
if (!empty($exponent_permissions_r['navigation'])) foreach ($exponent_permissions_r['navigation'] as $page) {
foreach ($page as $pageperm) {
if (!empty($pageperm['manage'])) return true;
}
}
}
return false;
}
| CWE-74 | 1 |
public function testPages () {
$this->visitPages ( $this->allPages );
} | CWE-20 | 0 |
function edit_option_master() {
expHistory::set('editable', $this->params);
$params = isset($this->params['id']) ? $this->params['id'] : $this->params;
$record = new option_master($params);
assign_to_template(array(
'record'=>$record
));
} | CWE-74 | 1 |
function cron_dbmanager_backup() {
global $wpdb;
$backup_options = get_option('dbmanager_options');
$backup_email = stripslashes($backup_options['backup_email']);
if(intval($backup_options['backup_period']) > 0) {
$backup = array();
$backup['date'] = current_time('timestamp');
$backup['mysqldumppath'] = $backup_options['mysqldumppath'];
$backup['mysqlpath'] = $backup_options['mysqlpath'];
$backup['path'] = $backup_options['path'];
$backup['password'] = str_replace('$', '\$', DB_PASSWORD);
$backup['host'] = DB_HOST;
$backup['port'] = '';
$backup['sock'] = '';
if(strpos(DB_HOST, ':') !== false) {
$db_host = explode(':', DB_HOST);
$backup['host'] = $db_host[0];
if(intval($db_host[1]) != 0) {
$backup['port'] = ' --port="'.intval($db_host[1]).'"';
} else {
$backup['sock'] = ' --socket="'.$db_host[1].'"';
}
}
$backup['command'] = '';
$brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
if(intval($backup_options['backup_gzip']) == 1) {
$backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql.gz';
$backup['filepath'] = $backup['path'].'/'.$backup['filename'];
$backup['command'] = $brace.$backup['mysqldumppath'].$brace.' --force --host="'.$backup['host'].'" --user="'.DB_USER.'" --password="'.$backup['password'].'"'.$backup['port'].$backup['sock'].' --add-drop-table --skip-lock-tables '.DB_NAME.' | gzip > '.$brace.$backup['filepath'].$brace;
} else {
$backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql';
$backup['filepath'] = $backup['path'].'/'.$backup['filename'];
$backup['command'] = $brace.$backup['mysqldumppath'].$brace.' --force --host="'.$backup['host'].'" --user="'.DB_USER.'" --password="'.$backup['password'].'"'.$backup['port'].$backup['sock'].' --add-drop-table --skip-lock-tables '.DB_NAME.' > '.$brace.$backup['filepath'].$brace;
}
execute_backup($backup['command']);
if( !empty( $backup_email ) )
{
dbmanager_email_backup( $backup_email, $backup['filepath'] );
}
}
return;
} | CWE-20 | 0 |
public function manage() {
expHistory::set('viewable', $this->params);
$page = new expPaginator(array(
'model'=>'order_status',
'where'=>1,
'limit'=>10,
'order'=>'rank',
'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),
'controller'=>$this->params['controller'],
'action'=>$this->params['action'],
//'columns'=>array('Name'=>'title')
));
assign_to_template(array(
'page'=>$page
));
} | CWE-74 | 1 |
public static function initializeNavigation() {
$sections = section::levelTemplate(0, 0);
return $sections;
}
| CWE-74 | 1 |
private function _addeditdate( $option ) {
$this->addTable( 'revision_actor_temp', 'rev' );
$this->addSelect( [ 'rev.revactor_timestamp' ] );
$this->addWhere(
[
$this->tableNames['page'] . '.page_id = rev.revactor_page',
]
);
} | CWE-400 | 2 |
$cLoc = serialize(expCore::makeLocation('container','@section' . $page->id));
$ret .= scan_container($cLoc, $page->id);
$ret .= scan_page($page->id);
}
| CWE-74 | 1 |
public function activate_discount(){
if (isset($this->params['id'])) {
$discount = new discounts($this->params['id']);
$discount->update($this->params);
//if ($discount->discountulator->hasConfig() && empty($discount->config)) {
//flash('messages', $discount->discountulator->name().' requires configuration. Please do so now.');
//redirect_to(array('controller'=>'billing', 'action'=>'configure', 'id'=>$discount->id));
//}
}
expHistory::back();
} | CWE-74 | 1 |
foreach ($events as $event) {
$extevents[$date][] = $event;
}
| CWE-74 | 1 |
foreach ($allusers as $uid) {
$u = user::getUserById($uid);
expPermissions::grant($u, 'manage', $sloc);
}
| CWE-74 | 1 |
function function_exists($name)
{
if (isset(\yiiunit\framework\base\SecurityTest::$functions[$name])) {
return \yiiunit\framework\base\SecurityTest::$functions[$name];
}
return \function_exists($name);
} | CWE-330 | 12 |
public function index($id)
{
$this->paginate['conditions'] = array('GalaxyElement.galaxy_cluster_id' => $id);
$clusters = $this->paginate();
$this->set('list', $clusters);
if ($this->request->is('ajax')) {
$this->layout = 'ajax';
$this->render('ajax/index');
}
} | CWE-862 | 8 |
public function create_file() {
if (!AuthUser::hasPermission('file_manager_mkfile')) {
Flash::set('error', __('You do not have sufficient permissions to create 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/create_file')) {
Flash::set('error', __('Invalid CSRF token found!'));
redirect(get_url('plugin/file_manager/browse/'));
}
}
else {
Flash::set('error', __('No CSRF token found!'));
redirect(get_url('plugin/file_manager/browse/'));
}
$data = $_POST['file'];
$path = str_replace('..', '', $data['path']);
$filename = str_replace('..', '', $data['name']);
$file = FILES_DIR . DS . $path . DS . $filename;
if (file_put_contents($file, '') !== false) {
$mode = Plugin::getSetting('filemode', 'file_manager');
chmod($file, octdec($mode));
} else {
Flash::set('error', __('File :name has not been created!', array(':name' => $filename)));
}
redirect(get_url('plugin/file_manager/browse/' . $path));
} | CWE-20 | 0 |
$fileName = ltrim(dirname($fileName) . '/' . basename($fileName, '.js'), '/.');
if (empty($fileName)) {
continue;
}
$templateNames[] = $inflector->filter(array(
'module' => $moduleName,
'controller' => $controllerName,
'file' => $fileName)
);
} | CWE-20 | 0 |
function delete_vendor() {
global $db;
if (!empty($this->params['id'])){
$db->delete('vendor', 'id =' .$this->params['id']);
}
expHistory::back();
} | CWE-74 | 1 |
protected function assertCsvUploaded($csv) {
$uploadedPath = implode(DIRECTORY_SEPARATOR, array(
Yii::app()->basePath,
'data',
'data.csv'
));
$this->assertFileExists ($uploadedPath);
$this->assertFileEquals ($csv, $uploadedPath);
} | CWE-20 | 0 |
public function __construct(Project $project)
{
parent::__construct('Project #' . $project->getID() . ' is not active and is not a template');
$this->project = $project;
} | CWE-863 | 11 |
public function __construct( Parameters $parameters ) {
$this->parameters = $parameters;
$this->tableNames = self::getTableNames();
$this->DB = wfGetDB( DB_REPLICA, 'dpl' );
} | CWE-400 | 2 |
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 |
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 static function parseAndTrimImport($str, $isHTML = false) { //�Death from above�? �
//echo "1<br>"; eDebug($str);
// global $db;
$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("\r\n", " ", $str);
$str = str_replace("\,", ",", $str);
$str = str_replace('""', '"', $str); //do this no matter what...in case someone added a quote in a non HTML field
if (!$isHTML) {
//if HTML, then leave the single quotes alone, otheriwse replace w/ special Char
$str = str_replace('"', """, $str);
}
$str = str_replace("�", "¼", $str);
$str = str_replace("�", "½", $str);
$str = str_replace("�", "¾", $str);
//$str = htmlspecialchars($str);
//$str = utf8_encode($str);
// if (DB_ENGINE=='mysqli') {
// $str = @mysqli_real_escape_string($db->connection,trim(str_replace("�", "™", $str)));
// } elseif(DB_ENGINE=='mysql') {
// $str = @mysql_real_escape_string(trim(str_replace("�", "™", $str)),$db->connection);
// } else {
// $str = trim(str_replace("�", "™", $str));
// }
$str = @expString::escape(trim(str_replace("�", "™", $str)));
//echo "2<br>"; eDebug($str,die);
return $str;
} | CWE-74 | 1 |
function PMA_secureSession()
{
// prevent session fixation and XSS
// (better to use session_status() if available)
if ((PMA_PHP_INT_VERSION >= 50400 && session_status() === PHP_SESSION_ACTIVE)
|| (PMA_PHP_INT_VERSION < 50400 && session_id() !== '')
) {
session_regenerate_id(true);
}
$_SESSION[' PMA_token '] = md5(uniqid(rand(), true));
} | CWE-200 | 10 |
function edit_section() {
global $db, $user;
$parent = new section($this->params['parent']);
if (empty($parent->id)) $parent->id = 0;
assign_to_template(array(
'haveStandalone' => ($db->countObjects('section', 'parent=-1') && $parent->id >= 0),
'parent' => $parent,
'isAdministrator' => $user->isAdmin(),
));
}
| CWE-74 | 1 |
public function confirm() {
global $db;
// make sure we have what we need.
if (empty($this->params['key'])) expQueue::flashAndFlow('error', gt('The security key for account was not supplied.'));
if (empty($this->params['id'])) expQueue::flashAndFlow('error', gt('The subscriber id for account was not supplied.'));
// verify the id/key pair
$id = $db->selectValue('subscribers','id', 'id='.$this->params['id'].' AND hash="'.$this->params['key'].'"');
if (empty($id)) expQueue::flashAndFlow('error', gt('We could not find any subscriptions matching the ID and Key you provided.'));
// activate this users pending subscriptions
$sub = new stdClass();
$sub->enabled = 1;
$db->updateObject($sub, 'expeAlerts_subscribers', 'subscribers_id='.$id);
// find the users active subscriptions
$ealerts = expeAlerts::getBySubscriber($id);
assign_to_template(array(
'ealerts'=>$ealerts
));
} | CWE-74 | 1 |
function PMA_linkURL($url)
{
if (!preg_match('#^https?://#', $url) || defined('PMA_SETUP')) {
return $url;
}
if (!function_exists('PMA_URL_getCommon')) {
include_once './libraries/url_generating.lib.php';
}
$params = array();
$params['url'] = $url;
$url = PMA_URL_getCommon($params);
//strip off token and such sensitive information. Just keep url.
$arr = parse_url($url);
parse_str($arr["query"], $vars);
$query = http_build_query(array("url" => $vars["url"]));
$url = './url.php?' . $query;
return $url;
} | CWE-200 | 10 |
private function setFooter( $footer ) {
if ( \DynamicPageListHooks::getDebugLevel() == 5 ) {
$footer .= '</nowiki></pre>';
}
$this->footer = $this->replaceVariables( $footer );
} | CWE-400 | 2 |
private function _notcreatedby( $option ) {
$this->addTable( 'revision', 'no_creation_rev' );
$this->addTable( 'revision_actor_temp', 'no_creation_rev_actor' );
$user = new \User;
$this->addWhere( $this->DB->addQuotes( $user->newFromName( $option )->getActorId() ) . ' != no_creation_rev_actor.revactor_actor AND no_creation_rev_actor.revactor_page = page_id AND no_creation_rev.rev_parent_id = 0' );
} | CWE-400 | 2 |
public function putAction(Request $request)
{
$this->checkArguments($request);
$user = $this->tokenStorage->getToken()->getUser();
$this->userManager->save($request->request->all(), $request->get('locale'), $user->getId(), true);
$user->setFirstName($request->get('firstName'));
$user->setLastName($request->get('lastName'));
$this->objectManager->flush();
$view = View::create($user);
$context = new Context();
$context->setGroups(['profile']);
$view->setContext($context);
return $this->viewHandler->handle($view);
} | CWE-269 | 6 |
public function getXForwardedForData()
{
return array(
array(false, '10.0.0.1'),
array('10.0.0.2', '10.0.0.2, 10.0.0.1'),
array('10.0.0.2, 10.0.0.3', '10.0.0.2, 10.0.0.3, 10.0.0.1'),
);
} | CWE-20 | 0 |
public function setHeadItemAttributes( $attributes ) {
$this->headItemAttributes = \Sanitizer::fixTagAttributes( $attributes, 'li' );
} | CWE-400 | 2 |
public function formatTemplateArg( $arg, $s, $argNr, $firstCall, $maxLength, Article $article ) {
$tableFormat = $this->getParameters()->getParameter( 'tablerow' );
// we could try to format fields differently within the first call of a template
// currently we do not make such a difference
// if the result starts with a '-' we add a leading space; thus we avoid a misinterpretation of |- as
// a start of a new row (wiki table syntax)
if ( array_key_exists( "$s.$argNr", $tableFormat ) ) {
$n = -1;
if ( $s >= 1 && $argNr == 0 && !$firstCall ) {
$n = strpos( $tableFormat["$s.$argNr"], '|' );
if ( $n === false || !( strpos( substr( $tableFormat["$s.$argNr"], 0, $n ), '{' ) === false ) || !( strpos( substr( $tableFormat["$s.$argNr"], 0, $n ), '[' ) === false ) ) {
$n = -1;
}
}
$result = str_replace( '%%', $arg, substr( $tableFormat["$s.$argNr"], $n + 1 ) );
$result = str_replace( '%PAGE%', $article->mTitle->getPrefixedText(), $result );
$result = str_replace( '%IMAGE%', $this->parseImageUrlWithPath( $arg ), $result ); //@TODO: This just blindly passes the argument through hoping it is an image. --Alexia
$result = $this->cutAt( $maxLength, $result );
if ( strlen( $result ) > 0 && $result[0] == '-' ) {
return ' ' . $result;
} else {
return $result;
}
}
$result = $this->cutAt( $maxLength, $arg );
if ( strlen( $result ) > 0 && $result[0] == '-' ) {
return ' ' . $result;
} else {
return $result;
}
} | CWE-400 | 2 |
public static function getHost() {
if (isset($_SERVER['HTTP_HOST'])) {
$site_address = (erLhcoreClassSystem::$httpsMode == true ? 'https:' : 'http:') . '//' . $_SERVER['HTTP_HOST'] ;
} else if (class_exists('erLhcoreClassInstance')) {
$site_address = 'https://' . erLhcoreClassInstance::$instanceChat->address . '.' . erConfigClassLhConfig::getInstance()->getSetting( 'site', 'seller_domain');
} else if (class_exists('erLhcoreClassExtensionLhcphpresque')) {
$site_address = erLhcoreClassModule::getExtensionInstance('erLhcoreClassExtensionLhcphpresque')->settings['site_address'];
} else {
$site_address = '';
}
return $site_address;
} | CWE-116 | 15 |
function selectArraysBySql($sql) {
$res = @mysqli_query($this->connection, $this->injectProof($sql));
if ($res == null)
return array();
$arrays = array();
for ($i = 0, $iMax = mysqli_num_rows($res); $i < $iMax; $i++)
$arrays[] = mysqli_fetch_assoc($res);
return $arrays;
} | CWE-74 | 1 |
public static function getSetting( $setting ) {
return ( array_key_exists( $setting, self::$settings ) ? self::$settings[$setting] : null );
} | CWE-400 | 2 |
public function testRemoveAuthorizationHeaderOnRedirect()
{
$mock = new MockHandler([
new Response(302, ['Location' => 'http://test.com']),
static function (RequestInterface $request) {
self::assertFalse($request->hasHeader('Authorization'));
return new Response(200);
}
]);
$handler = HandlerStack::create($mock);
$client = new Client(['handler' => $handler]);
$client->get('http://example.com?a=b', ['auth' => ['testuser', 'testpass']]);
} | CWE-863 | 11 |
private function _firstrevisionsince( $option ) {
$this->addTable( 'revision_actor_temp', 'rev' );
$this->addSelect(
[
'rev.revactor_rev',
'rev.revactor_timestamp'
]
);
// tell the query optimizer not to look at rows that the following subquery will filter out anyway
$this->addWhere(
[
$this->tableNames['page'] . '.page_id = rev.revactor_page',
'rev.revactor_timestamp >= ' . $this->DB->addQuotes( $option )
]
);
$this->addWhere(
[
$this->tableNames['page'] . '.page_id = rev.revactor_page',
'rev.revactor_timestamp = (SELECT MIN(rev_aux_snc.revactor_timestamp) FROM ' . $this->tableNames['revision_actor_temp'] . ' AS rev_aux_snc WHERE rev_aux_snc.revactor_page=rev.revactor_page AND rev_aux_snc.revactor_timestamp >= ' . $this->convertTimestamp( $option ) . ')'
]
);
} | CWE-400 | 2 |
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-74 | 1 |
foreach ($elem[2] as $field) {
echo '
<tr class="tr_cf tr_fields hidden" id="cf_tr_'.$field[0].'">
<td valign="top" class="td_title"> <i class="fa fa-caret-right"></i> <i>'.$field[1].'</i> :</td>
<td>';
if ($field[3] === "masked") {
echo '
<div id="id_field_'.htmlspecialchars($field[0]).'_'.$elem[0].'" style="float:left; cursor:pointer; width:300px;" class="fields_div unhide_masked_data pointer"></div><input type="hidden" id="hid_field_'.htmlspecialchars($field[0]).'_'.$elem[0].'" class="fields" />';
} else {
echo '
<div id="id_field_'.htmlspecialchars($field[0]).'_'.$elem[0].'" style="display:inline;" class="fields_div"></div><input type="hidden" id="hid_field_'.htmlspecialchars($field[0]).'_'.$elem[0].'" class="fields" />';
}
echo '
</td>
</tr>';
} | CWE-269 | 6 |
function edit_vendor() {
$vendor = new vendor();
if(isset($this->params['id'])) {
$vendor = $vendor->find('first', 'id =' .$this->params['id']);
assign_to_template(array(
'vendor'=>$vendor
));
}
} | CWE-74 | 1 |
public function __construct() {
$this->smtp_conn = 0;
$this->error = null;
$this->helo_rply = null;
$this->do_debug = 0;
} | CWE-20 | 0 |
function manage () {
expHistory::set('viewable', $this->params);
$vendor = new vendor();
$vendors = $vendor->find('all');
if(!empty($this->params['vendor'])) {
$purchase_orders = $this->purchase_order->find('all', 'vendor_id=' . $this->params['vendor']);
} else {
$purchase_orders = $this->purchase_order->find('all');
}
assign_to_template(array(
'purchase_orders'=>$purchase_orders,
'vendors' => $vendors,
'vendor_id' => @$this->params['vendor']
));
} | CWE-74 | 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-74 | 1 |
public function formatItem( Article $article, $pageText = null ) {
global $wgLang;
$item = '';
// DPL Article, not MediaWiki.
$date = $article->getDate();
if ( $date !== null ) {
$item .= $date . ' ';
if ( $article->mRevision !== null ) {
$item .= '[{{fullurl:' . $article->mTitle . '|oldid=' . $article->mRevision . '}} ' . htmlspecialchars( $article->mTitle ) . ']';
} else {
$item .= $article->mLink;
}
} else {
// output the link to the article
$item .= $article->mLink;
}
if ( $article->mSize != null ) {
$byte = 'B';
$pageLength = $wgLang->formatNum( $article->mSize );
$item .= " [{$pageLength} {$byte}]";
}
if ( $article->mCounter !== null ) {
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
$item .= ' ' . $contLang->getDirMark() . '(' . wfMessage( 'hitcounters-nviews', $wgLang->formatNum( $article->mCounter ) )->escaped() . ')';
}
if ( $article->mUserLink !== null ) {
$item .= ' . . [[User:' . $article->mUser . '|' . $article->mUser . ']]';
if ( $article->mComment != '' ) {
$item .= ' { ' . $article->mComment . ' }';
}
}
if ( $article->mContributor !== null ) {
$item .= ' . . [[User:' . $article->mContributor . '|' . $article->mContributor . " $article->mContrib]]";
}
if ( !empty( $article->mCategoryLinks ) ) {
$item .= ' . . <small>' . wfMessage( 'categories' ) . ': ' . implode( ' | ', $article->mCategoryLinks ) . '</small>';
}
if ( $this->getParameters()->getParameter( 'addexternallink' ) && $article->mExternalLink !== null ) {
$item .= ' → ' . $article->mExternalLink;
}
if ( $pageText !== null ) {
//Include parsed/processed wiki markup content after each item before the closing tag.
$item .= $pageText;
}
$item = $this->getItemStart() . $item . $this->getItemEnd();
$item = $this->replaceTagParameters( $item, $article );
return $item;
} | CWE-400 | 2 |
public function fromFile($filePath)
{
if ($filePath === null) {
return;
}
$file = new FileObj($filePath);
$this->file_name = $file->getFilename();
$this->file_size = $file->getSize();
$this->content_type = $file->getMimeType();
$this->disk_name = $this->getDiskName();
$this->putFile($file->getRealPath(), $this->disk_name);
return $this;
} | CWE-362 | 18 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.