code
stringlengths
12
2.05k
label_name
stringclasses
5 values
label
int64
0
4
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 )); }
Class
2
public function event() { $project = $this->getProject(); $values = $this->request->getValues(); if (empty($values['action_name']) || empty($values['project_id'])) { return $this->create(); } return $this->response->html($this->template->render('action_creation/event', array( 'values' => $values, 'project' => $project, 'available_actions' => $this->actionManager->getAvailableActions(), 'events' => $this->actionManager->getCompatibleEvents($values['action_name']), ))); }
Base
1
protected function checkMaintenanceMode() { if (Yii::$app->settings->get('maintenanceMode')) { if (!Yii::$app->user->isGuest) { Yii::$app->user->logout(); Yii::$app->getView()->warn(Yii::t('error', 'Maintenance mode activated: You have been automatically logged out and will no longer have access the platform until the maintenance has been completed.')); } return Yii::$app->getResponse()->redirect(['/user/auth/login']); } }
Class
2
self::removeLevel($kid->id); } }
Base
1
public function confirm(string $token) { try { $userId = $this->emailConfirmationService->checkTokenAndGetUserId($token); } catch (UserTokenNotFoundException $exception) { $this->showErrorNotification(trans('errors.email_confirmation_invalid')); return redirect('/register'); } catch (UserTokenExpiredException $exception) { $user = $this->userRepo->getById($exception->userId); $this->emailConfirmationService->sendConfirmation($user); $this->showErrorNotification(trans('errors.email_confirmation_expired')); return redirect('/register/confirm'); } $user = $this->userRepo->getById($userId); $user->email_confirmed = true; $user->save(); $this->emailConfirmationService->deleteByUser($user); $this->showSuccessNotification(trans('auth.email_confirm_success')); $this->loginService->login($user, auth()->getDefaultDriver()); return redirect('/'); }
Compound
4
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'] )); }
Base
1
function db_properties($table) { global $DatabaseType, $DatabaseUsername; switch ($DatabaseType) { case 'mysqli': $result = DBQuery("SHOW COLUMNS FROM $table"); while ($row = db_fetch_row($result)) { $properties[strtoupper($row['FIELD'])]['TYPE'] = strtoupper($row['TYPE'], strpos($row['TYPE'], '(')); if (!$pos = strpos($row['TYPE'], ',')) $pos = strpos($row['TYPE'], ')'); else $properties[strtoupper($row['FIELD'])]['SCALE'] = substr($row['TYPE'], $pos + 1); $properties[strtoupper($row['FIELD'])]['SIZE'] = substr($row['TYPE'], strpos($row['TYPE'], '(') + 1, $pos); if ($row['NULL'] != '') $properties[strtoupper($row['FIELD'])]['NULL'] = "Y"; else $properties[strtoupper($row['FIELD'])]['NULL'] = "N"; } break; } return $properties; }
Base
1
private function edebug($str) { if ($this->Debugoutput == "error_log") { error_log($str); } else { echo $str; } }
Base
1
function db_seq_nextval($seqname) { global $DatabaseType; if ($DatabaseType == 'mysqli') $seq = "fn_" . strtolower($seqname) . "()"; return $seq; }
Base
1
public function testCookiePathWithEmptySetCookiePath($uriPath, $cookiePath) { $response = (new Response(200)) ->withAddedHeader( 'Set-Cookie', "foo=bar; expires={$this->futureExpirationDate()}; domain=www.example.com; path=;" ) ->withAddedHeader( 'Set-Cookie', "bar=foo; expires={$this->futureExpirationDate()}; domain=www.example.com; path=foobar;" ) ; $request = (new Request('GET', $uriPath))->withHeader('Host', 'www.example.com'); $this->jar->extractCookies($request, $response); self::assertSame($cookiePath, $this->jar->toArray()[0]['Path']); self::assertSame($cookiePath, $this->jar->toArray()[1]['Path']); }
Class
2
foreach ($value as $valueKey => $valueValue) { if (\is_int($valueKey)) { $filteredKey = $valueKey; } else { $filteredKey = self::filterValue($valueKey, $regex, $stripTags); } if ($filteredKey === '' || $filteredKey === null) { continue; } $filteredValue = $valueValue; if (\is_array($valueValue)) { $filteredValue = self::filterArrayValue($valueValue, $regex, $stripTags); } if (\is_string($valueValue)) { $filteredValue = self::filterValue($valueValue, $regex, $stripTags); } $newReturn[$filteredKey] = $filteredValue; }
Base
1
function unlockTables() { $sql = "UNLOCK TABLES"; $res = mysqli_query($this->connection, $sql); return $res; }
Class
2
public function approve_submit() { global $history; if (empty($this->params['id'])) { flash('error', gt('No ID supplied for comment to approve')); $lastUrl = expHistory::getLast('editable'); } /* 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']; $simplenote = new expSimpleNote($this->params['id']); //FIXME here is where we might sanitize the note before approving it $simplenote->body = $this->params['body']; $simplenote->approved = $this->params['approved']; $simplenote->save(); $lastUrl = makelink($history->history[$history->history['lasts']['type']][count($history->history[$history->history['lasts']['type']])-1]['params']); if (!empty($this->params['tab'])) { $lastUrl .= "#".$this->params['tab']; } redirect_to($lastUrl); }
Base
1
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; }
Base
1
$result = $search->getSearchResults($item->query, false, true); if(empty($result) && !in_array($item->query, $badSearchArr)) { $badSearchArr[] = $item->query; $badSearch[$ctr2]['query'] = $item->query; $badSearch[$ctr2]['count'] = $db->countObjects("search_queries", "query='{$item->query}'"); $ctr2++; } } //Check if the user choose from the dropdown if(!empty($user_default)) { if($user_default == $anonymous) { $u_id = 0; } else { $u_id = $user_default; } $where .= "user_id = {$u_id}"; } //Get all the search query records $records = $db->selectObjects('search_queries', $where); for ($i = 0, $iMax = count($records); $i < $iMax; $i++) { if(!empty($records[$i]->user_id)) { $u = user::getUserById($records[$i]->user_id); $records[$i]->user = $u->firstname . ' ' . $u->lastname; } } $page = new expPaginator(array( 'records' => $records, 'where'=>1, 'model'=>'search_queries', 'limit'=>(isset($this->config['limit']) && $this->config['limit'] != '') ? 10 : $this->config['limit'], 'order'=>empty($this->config['order']) ? 'timestamp' : $this->config['order'], 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1), 'controller'=>$this->baseclassname, 'action'=>$this->params['action'], 'columns'=>array( 'ID'=>'id', gt('Query')=>'query', gt('Timestamp')=>'timestamp', gt('User')=>'user_id', ), )); $uname['id'] = implode($uname['id'],','); $uname['name'] = implode($uname['name'],','); assign_to_template(array( 'page'=>$page, 'users'=>$uname, 'user_default' => $user_default, 'badSearch' => $badSearch )); }
Base
1
public function show() { $task = $this->getTask(); $subtask = $this->getSubtask(); $this->response->html($this->template->render('subtask_restriction/show', array( 'status_list' => array( SubtaskModel::STATUS_TODO => t('Todo'), SubtaskModel::STATUS_DONE => t('Done'), ), 'subtask_inprogress' => $this->subtaskStatusModel->getSubtaskInProgress($this->userSession->getId()), 'subtask' => $subtask, 'task' => $task, ))); }
Base
1
public function delete(AvailableBudget $availableBudget) { $this->abRepository->destroyAvailableBudget($availableBudget); session()->flash('success', trans('firefly.deleted_ab')); return redirect(route('budgets.index')); }
Compound
4
function edit_optiongroup_master() { expHistory::set('editable', $this->params); $id = isset($this->params['id']) ? $this->params['id'] : null; $record = new optiongroup_master($id); assign_to_template(array( 'record'=>$record )); }
Base
1
public function getSiteInfo() { // check for a site request param if(empty($this->getSite())){ $this->setName(get_bloginfo('name')); $this->setDescription(get_bloginfo('description')); $this->setRestApiUrl(get_rest_url()); $this->setSite(get_bloginfo('url')); $this->setLocal(true); return; } // If they forgot to add http(s), add it for them. if(strpos($this->getSite(), 'http://') === false && strpos($this->getSite(), 'https://') === false) { $this->setSite( 'http://' . $this->getSite()); } // if there is one, check if it exists in wordpress.com, eg "retirementreflections.com" $site = trailingslashit(sanitize_text_field($this->getSite())); // Let's see if it's self-hosted... $data = $this->getSelfHostedSiteInfo($site); // if($data === false){ // // Alright, there was no link to the REST API index. But maybe it's a WordPress.com site... // $data = $this->guessSelfHostedSiteInfo($site); // } if($data === false){ // Alright, there was no link to the REST API index. But maybe it's a WordPress.com site... $data = $this->getWordPressComSiteInfo($site); } return $data; }
Base
1
public function subscriptions() { global $db; expHistory::set('manageable', $this->params); // make sure we have what we need. if (empty($this->params['key'])) expQueue::flashAndFlow('error', gt('The security key for account was not supplied.')); if (empty($this->params['id'])) expQueue::flashAndFlow('error', gt('The subscriber id for account was not supplied.')); // verify the id/key pair $sub = new subscribers($this->params['id']); if (empty($sub->id)) expQueue::flashAndFlow('error', gt('We could not find any subscriptions matching the ID and Key you provided.')); // get this users subscriptions $subscriptions = $db->selectColumn('expeAlerts_subscribers', 'expeAlerts_id', 'subscribers_id='.$sub->id); // get a list of all available E-Alerts $ealerts = new expeAlerts(); assign_to_template(array( 'subscriber'=>$sub, 'subscriptions'=>$subscriptions, 'ealerts'=>$ealerts->find('all') )); }
Base
1
protected function renderImageByGD($code) { $image = imagecreatetruecolor($this->width, $this->height); $backColor = imagecolorallocate( $image, (int) ($this->backColor % 0x1000000 / 0x10000), (int) ($this->backColor % 0x10000 / 0x100), $this->backColor % 0x100 ); imagefilledrectangle($image, 0, 0, $this->width - 1, $this->height - 1, $backColor); imagecolordeallocate($image, $backColor); if ($this->transparent) { imagecolortransparent($image, $backColor); } $foreColor = imagecolorallocate( $image, (int) ($this->foreColor % 0x1000000 / 0x10000), (int) ($this->foreColor % 0x10000 / 0x100), $this->foreColor % 0x100 ); $length = strlen($code); $box = imagettfbbox(30, 0, $this->fontFile, $code); $w = $box[4] - $box[0] + $this->offset * ($length - 1); $h = $box[1] - $box[5]; $scale = min(($this->width - $this->padding * 2) / $w, ($this->height - $this->padding * 2) / $h); $x = 10; $y = round($this->height * 27 / 40); for ($i = 0; $i < $length; ++$i) { $fontSize = (int) (mt_rand(26, 32) * $scale * 0.8); $angle = mt_rand(-10, 10); $letter = $code[$i]; $box = imagettftext($image, $fontSize, $angle, $x, $y, $foreColor, $this->fontFile, $letter); $x = $box[2] + $this->offset; } imagecolordeallocate($image, $foreColor); ob_start(); imagepng($image); imagedestroy($image); return ob_get_clean(); }
Class
2
public function getTrackingId() { if(isset($this->ectid)) return $this->ectid; else return ''; }
Base
1
public function autocomplete() { return; global $db; $model = $this->params['model']; $mod = new $model(); $srchcol = explode(",",$this->params['searchoncol']); /*for ($i=0; $i<count($srchcol); $i++) { if ($i>=1) $sql .= " OR "; $sql .= $srchcol[$i].' LIKE \'%'.$this->params['query'].'%\''; }*/ // $sql .= ' AND parent_id=0'; //eDebug($sql); //$res = $mod->find('all',$sql,'id',25); $sql = "select DISTINCT(p.id), p.title, model, sef_url, f.id as fileid from ".$db->prefix."product as p INNER JOIN ".$db->prefix."content_expfiles as cef ON p.id=cef.content_id INNER JOIN ".$db->prefix."expfiles as f ON cef.expfiles_id = f.id where match (p.title,p.model,p.body) against ('" . $this->params['query'] . "') AND p.parent_id=0 order by match (p.title,p.model,p.body) against ('" . $this->params['query'] . "') desc LIMIT 25"; //$res = $db->selectObjectsBySql($sql); //$res = $db->selectObjectBySql('SELECT * FROM `exponent_product`'); $ar = new expAjaxReply(200, gt('Here\'s the items you wanted'), $res); $ar->send(); }
Class
2
function delete_option_master() { global $db; $masteroption = new option_master($this->params['id']); // delete any implementations of this option master $db->delete('option', 'option_master_id='.$masteroption->id); $masteroption->delete('optiongroup_master_id=' . $masteroption->optiongroup_master_id); //eDebug($masteroption); expHistory::back(); }
Base
1
public function confirm() { $project = $this->getProject(); $this->response->html($this->helper->layout->project('action/remove', array( 'action' => $this->actionModel->getById($this->request->getIntegerParam('action_id')), 'available_events' => $this->eventManager->getAll(), 'available_actions' => $this->actionManager->getAvailableActions(), 'project' => $project, 'title' => t('Remove an action') ))); }
Base
1
private function getTaskLink() { $link = $this->taskLinkModel->getById($this->request->getIntegerParam('link_id')); if (empty($link)) { throw new PageNotFoundException(); } return $link; }
Base
1
public static function insert ($vars) { if(is_array($vars)){ $set = ""; $k = ""; foreach ($vars['key'] as $key => $val) { $set .= "'$val',"; $k .= "`$key`,"; } $set = substr($set, 0,-1); $k = substr($k, 0,-1); $sql = sprintf("INSERT INTO `%s` (%s) VALUES (%s) ", $vars['table'], $k, $set) ; }else{ $sql = $vars; } if(DB_DRIVER == 'mysql') { mysql_query('SET CHARACTER SET utf8'); $q = mysql_query($sql) or die(mysql_error()); self::$last_id = mysql_insert_id(); }elseif(DB_DRIVER == 'mysqli'){ try { if(!self::query($sql)){ printf("<div class=\"alert alert-danger\">Errormessage: %s</div>\n", self::$mysqli->error); }else{ self::$last_id = self::$mysqli->insert_id; } } catch (exception $e) { echo $e->getMessage(); } } return true; }
Base
1
protected function markCompleted($endStatus, ServiceResponse $serviceResponse, $gatewayMessage) { parent::markCompleted($endStatus, $serviceResponse, $gatewayMessage); $this->createMessage(Message\VoidedResponse::class, $gatewayMessage); ErrorHandling::safeExtend($this->payment, 'onVoid', $serviceResponse); }
Class
2
public static function hasChildren($i) { global $sections; if (($i + 1) >= count($sections)) return false; return ($sections[$i]->depth < $sections[$i + 1]->depth) ? true : false; }
Base
1
public function actionGetItems(){ $sql = 'SELECT id, name as value FROM x2_products 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; }
Class
2
$ret = array_merge($ret, csrf_flattenpost2(1, $n, $v)); }
Compound
4
public function testAddsDefaultReason() { $r = new Response('200'); $this->assertSame(200, $r->getStatusCode()); $this->assertEquals('OK', $r->getReasonPhrase()); }
Base
1
public function confirm() { $project = $this->getProject(); $filter = $this->customFilterModel->getById($this->request->getIntegerParam('filter_id')); $this->response->html($this->helper->layout->project('custom_filter/remove', array( 'project' => $project, 'filter' => $filter, 'title' => t('Remove a custom filter') ))); }
Class
2
function generate_key($size) { if ( is_callable('openssl_random_pseudo_bytes') and !(version_compare(PHP_VERSION, '5.3.4') < 0 and defined('PHP_WINDOWS_VERSION_MAJOR')) ) { return substr( str_replace( array('+', '/'), '', base64_encode(openssl_random_pseudo_bytes($size+10)) ), 0, $size ); } else { $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $l = strlen($alphabet)-1; $key = ''; for ($i=0; $i<$size; $i++) { $key.= $alphabet[mt_rand(0, $l)]; } return $key; } }
Base
1
public static function hasChildren($i) { global $sections; if (($i + 1) >= count($sections)) return false; return ($sections[$i]->depth < $sections[$i + 1]->depth) ? true : false; }
Class
2
public static function admin () { }
Base
1
public function active($id, $active) { $this->auth->checkIfOperationIsAllowed('list_users'); $this->users_model->setActive($id, $active); $this->session->set_flashdata('msg', lang('users_edit_flash_msg_success')); redirect('users'); }
Compound
4
private function _notuses( $option ) { if ( count( $option ) > 0 ) { $where = $this->tableNames['page'] . '.page_id NOT IN (SELECT ' . $this->tableNames['templatelinks'] . '.tl_from FROM ' . $this->tableNames['templatelinks'] . ' WHERE ('; $ors = []; foreach ( $option as $linkGroup ) { foreach ( $linkGroup as $link ) { $_or = '(' . $this->tableNames['templatelinks'] . '.tl_namespace=' . intval( $link->getNamespace() ); if ( $this->parameters->getParameter( 'ignorecase' ) ) { $_or .= ' AND LOWER(CAST(' . $this->tableNames['templatelinks'] . '.tl_title AS char))=LOWER(' . $this->DB->addQuotes( $link->getDbKey() ) . '))'; } else { $_or .= ' AND ' . $this->tableNames['templatelinks'] . '.tl_title=' . $this->DB->addQuotes( $link->getDbKey() ) . ')'; } $ors[] = $_or; } } $where .= implode( ' OR ', $ors ) . '))'; } $this->addWhere( $where ); }
Class
2
$criteria->addCondition ( 'user IN (' . 'SELECT DISTINCT b.username ' . 'FROM x2_group_to_user a JOIN x2_group_to_user b ' . 'ON a.groupId=b.groupId ' . 'WHERE a.username=:getAccessCriteria_username' . ') OR (user = :getAccessCriteria_username)'); } else { // default history privacy (public or assigned) $criteria->addCondition ("(user=:getAccessCriteria_username OR visibility=1)"); } } if ($profile) { $criteria->params[':getAccessCriteria_profileUsername'] = $profile->username; /* only show events associated with current profile which current user has permission to see */ $criteria->addCondition ("user=:getAccessCriteria_profileUsername"); if (!Yii::app()->params->isAdmin) { $criteria->addCondition ("visibility=1"); } } return $criteria; }
Class
2
public function clearTags() { $this->_tags = array(); // clear tag cache return (bool) CActiveRecord::model('Tags')->deleteAllByAttributes(array( 'type' => get_class($this->getOwner()), 'itemId' => $this->getOwner()->id) ); }
Base
1
public function toolbar() { // global $user; $menu = array(); $dirs = array( BASE.'framework/modules/administration/menus', BASE.'themes/'.DISPLAY_THEME.'/modules/administration/menus' ); foreach ($dirs as $dir) { if (is_readable($dir)) { $dh = opendir($dir); while (($file = readdir($dh)) !== false) { if (substr($file,-4,4) == '.php' && is_readable($dir.'/'.$file) && is_file($dir.'/'.$file)) { $menu[substr($file,0,-4)] = include($dir.'/'.$file); if (empty($menu[substr($file,0,-4)])) unset($menu[substr($file,0,-4)]); } } } } // sort the top level menus alphabetically by filename ksort($menu); $sorted = array(); foreach($menu as $m) $sorted[] = $m; // slingbar position if (isset($_COOKIE['slingbar-top'])){ $top = $_COOKIE['slingbar-top']; } else { $top = SLINGBAR_TOP; } assign_to_template(array( 'menu'=>(bs3()) ? $sorted : json_encode($sorted), "top"=>$top )); }
Base
1
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 )); }
Base
1
public function __construct () { }
Base
1
function unlockTables() { $sql = "UNLOCK TABLES"; $res = mysqli_query($this->connection, $sql); return $res; }
Base
1
public function __construct(UserInviteService $inviteService, LoginService $loginService, UserRepo $userRepo) { $this->middleware('guest'); $this->middleware('guard:standard'); $this->inviteService = $inviteService; $this->loginService = $loginService; $this->userRepo = $userRepo; }
Compound
4
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; }
Base
1
function fopen($filename, $mode) { if (\yiiunit\framework\base\SecurityTest::$fopen !== null) { return \yiiunit\framework\base\SecurityTest::$fopen; } return \fopen($filename, $mode); }
Class
2
protected function defaultExtensions() { return [ 'jpg', 'jpeg', 'bmp', 'png', 'webp', 'gif', 'svg', 'js', 'map', 'ico', 'css', 'less', 'scss', 'ics', 'odt', 'doc', 'docx', 'ppt', 'pptx', 'pdf', 'swf', 'txt', 'xml', 'ods', 'xls', 'xlsx', 'eot', 'woff', 'woff2', 'ttf', 'flv', 'wmv', 'mp3', 'ogg', 'wav', 'avi', 'mov', 'mp4', 'mpeg', 'webm', 'mkv', 'rar', 'xml', 'zip' ]; }
Base
1
public function show() { $task = $this->getTask(); $subtask = $this->getSubtask(); $this->response->html($this->template->render('subtask_converter/show', array( 'subtask' => $subtask, 'task' => $task, ))); }
Base
1
public function saveconfig() { global $db; if (empty($this->params['id'])) return false; $calcname = $db->selectValue('shippingcalculator', 'calculator_name', 'id='.$this->params['id']); $calc = new $calcname($this->params['id']); $conf = serialize($calc->parseConfig($this->params)); $calc->update(array('config'=>$conf)); expHistory::back(); }
Class
2
public function post_prop () { $file = urldecode (join ('/', func_get_args ())); if (! FileManager::verify_file ($file)) { return $this->error (__ ('Invalid file name')); } // handle multiple properties at once if (isset ($_POST['props'])) { if (! is_array ($_POST['props'])) { return $this->error (__ ('Invalid properties')); } foreach ($_POST['props'] as $k => $v) { if (FileManager::prop ($file, $k, $v) === false) { return $this->error (__ ('Error saving properties.')); } } return array ( 'file' => $file, 'props' => $_POST['props'], 'msg' => __ ('Properties saved.') ); } // handle a single property if (! isset ($_POST['prop'])) { return $this->error (__ ('Missing property name')); } if (isset ($_POST['value'])) { // update and fetch $res = FileManager::prop ($file, $_POST['prop'], $_POST['value']); } else { // fetch $res = FileManager::prop ($file, $_POST['prop']); } return array ( 'file' => $file, 'prop' => $_POST['prop'], 'value' => $res, 'msg' => __ ('Properties saved.') ); }
Base
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);
Class
2
function move_standalone() { expSession::clearAllUsersSessionCache('navigation'); assign_to_template(array( 'parent' => $this->params['parent'], )); }
Class
2
protected function registerBackendPermissions() { BackendAuth::registerCallback(function ($manager) { $manager->registerPermissions('October.Backend', [ 'backend.access_dashboard' => [ 'label' => 'system::lang.permissions.view_the_dashboard', 'tab' => 'system::lang.permissions.name' ], 'backend.manage_default_dashboard' => [ 'label' => 'system::lang.permissions.manage_default_dashboard', 'tab' => 'system::lang.permissions.name', ], 'backend.manage_users' => [ 'label' => 'system::lang.permissions.manage_other_administrators', 'tab' => 'system::lang.permissions.name' ], 'backend.impersonate_users' => [ 'label' => 'system::lang.permissions.impersonate_users', 'tab' => 'system::lang.permissions.name', ], 'backend.manage_preferences' => [ 'label' => 'system::lang.permissions.manage_preferences', 'tab' => 'system::lang.permissions.name' ], 'backend.manage_editor' => [ 'label' => 'system::lang.permissions.manage_editor', 'tab' => 'system::lang.permissions.name' ], 'backend.manage_branding' => [ 'label' => 'system::lang.permissions.manage_branding', 'tab' => 'system::lang.permissions.name' ], 'media.manage_media' => [ 'label' => 'backend::lang.permissions.manage_media', 'tab' => 'system::lang.permissions.name', ] ]); }); }
Base
1
function searchCategory() { return gt('Event'); }
Base
1
function searchCategory() { return gt('Event'); }
Class
2
protected function _move($source, $targetDir, $name) { $target = $this->_joinPath($targetDir, $name); return $this->connect->rename($source, $target) ? $target : false; }
Base
1
foreach ($flatArray as $key => $value) { $pattern = '/' . $key . '([^.]|$)/'; if (preg_match($pattern, $expression, $matches)) { switch (gettype($flatArray[$key])) { case 'boolean': $expression = str_replace($key, $flatArray[$key] ? 'true' : 'false', $expression); break; case 'NULL': $expression = str_replace($key, 'false', $expression); break; case 'string': $expression = str_replace($key, '"' . $flatArray[$key] . '"', $expression); break; case 'object': $expression = self::executeClosure($expression, $key, $flatArray[$key], $flatArray); break; default: $expression = str_replace($key, $flatArray[$key], $expression); break; } $bool = eval("return $expression;"); } }
Class
2
$v = trim($v); if ($v !== '') { $_POST[$key][] = $v; } } }
Class
2
$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'); }
Class
2
public function confirm() { $project = $this->getProject(); $this->response->html($this->helper->layout->project('action/remove', array( 'action' => $this->actionModel->getById($this->request->getIntegerParam('action_id')), 'available_events' => $this->eventManager->getAll(), 'available_actions' => $this->actionManager->getAvailableActions(), 'project' => $project, 'title' => t('Remove an action') ))); }
Base
1
public function getDisplayName ($plural=true) { return Yii::t('contacts', '{contact} List|{contact} Lists', array( (int) $plural, '{contact}' => Modules::displayName(false, 'Contacts'), )); }
Base
1
protected function moveVotes() { $sql = "SELECT * FROM package_proposal_votes WHERE pkg_prop_id = {$this->proposal}"; $res = $this->mdb2->query($sql); if (MDB2::isError($res)) { throw new RuntimeException("DB error occurred: {$res->getDebugInfo()}"); } if ($res->numRows() == 0) { return; // nothing to do } $insert = "INSERT INTO package_proposal_comments ("; $insert .= "user_handle, pkg_prop_id, timestamp, comment"; $insert .= ") VALUES(%s, {$this->proposal}, %d, %s)"; $delete = "DELETE FROM package_proposal_votes WHERE"; $delete .= " pkg_prop_id = {$this->proposal}"; $delete .= " AND user_handle = %s"; while ($row = $res->fetchRow(MDB2_FETCHMODE_OBJECT)) { $comment = "Original vote: {$row->value}\n"; $comment .= "Conditional vote: " . ($row->is_conditional != 0)?'yes':'no' . "\n"; $comment .= "Comment on vote: " . $row->comment . "\n\n"; $comment .= "Reviewed: " . implode(", ", unserialize($row->reviews)); $sql = sprintf( $insert, $this->mdb2->quote($row->user_handle), $row->timestamp, $this->mdb2->quote($comment) ); $this->queryChange($sql); $sql = sprintf( $delete, $this->mdb2->quote($row->user_handle) ); $this->queryChange($sql); }
Base
1
public static function filterValue($value, $regex, $stripTags = true) { if (empty($value)) { return $value; } if ($stripTags) { $value = strip_tags($value); } if (preg_match($regex, $value)) { return null; } return $value; }
Base
1
public function save() { global $DB; if(!empty($this->id)) return $this->update(); else return $this->insert(); }
Base
1
public function getImage($id){ $url = "http://api.themoviedb.org/3/movie/{$id}/images?api_key=".$this->apikey; $cast = $this->curl($url); return $cast; }
Base
1
protected function _fclose($fp, $path='') { @fclose($fp); if ($path) { @unlink($this->getTempFile($path)); } }
Base
1
$file = explode('.', $lang); if ($var == $file[0]) { $sel = 'SELECTED'; }else{ $sel = ''; } $opt .= "<option {$sel}>{$file[0]}</option>"; } return $opt; }
Base
1
public function search() { // global $db, $user; global $db; $sql = "select DISTINCT(a.id) as id, a.firstname as firstname, a.middlename as middlename, a.lastname as lastname, a.organization as organization, a.email as email "; $sql .= "from " . $db->prefix . "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(); }
Class
2
function get(&$dbh, $proposalId, $handle) { $sql = "SELECT *, UNIX_TIMESTAMP(timestamp) AS timestamp FROM package_proposal_votes WHERE pkg_prop_id = ". $dbh->quoteSmart($proposalId) ." AND user_handle= ". $dbh->quoteSmart($handle); $res = $dbh->query($sql); if (DB::isError($res)) { return $res; } if (!$res->numRows()) { return null; } $set = $res->fetchRow(DB_FETCHMODE_ASSOC); $set['reviews'] = unserialize($set['reviews']); $vote = new ppVote($set); return $vote; }
Base
1
public function params() { $project = $this->getProject(); $values = $this->request->getValues(); if (empty($values['action_name']) || empty($values['project_id']) || empty($values['event_name'])) { $this->create(); return; } $action = $this->actionManager->getAction($values['action_name']); $action_params = $action->getActionRequiredParameters(); if (empty($action_params)) { $this->doCreation($project, $values + array('params' => array())); } $projects_list = $this->projectUserRoleModel->getActiveProjectsByUser($this->userSession->getId()); unset($projects_list[$project['id']]); $this->response->html($this->template->render('action_creation/params', array( 'values' => $values, 'action_params' => $action_params, 'columns_list' => $this->columnModel->getList($project['id']), 'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id']), 'projects_list' => $projects_list, 'colors_list' => $this->colorModel->getList(), 'categories_list' => $this->categoryModel->getList($project['id']), 'links_list' => $this->linkModel->getList(0, false), 'priorities_list' => $this->projectTaskPriorityModel->getPriorities($project), 'project' => $project, 'available_actions' => $this->actionManager->getAvailableActions(), 'swimlane_list' => $this->swimlaneModel->getList($project['id']), 'events' => $this->actionManager->getCompatibleEvents($values['action_name']), ))); }
Base
1
public function testFullRun() { $command = $this->getCommand(); $commandTester = new CommandTester($command); $commandTester->setInputs(['no']); $commandTester->execute([ 'command' => $command->getName(), ]); $result = $commandTester->getDisplay(); self::assertStringContainsString('Kimai updates running', $result); // make sure migrations run always self::assertStringContainsString('Application Migrations', $result); self::assertStringContainsString('No migrations to execute.', $result); self::assertStringContainsString( sprintf('[OK] Congratulations! Successfully updated Kimai to version %s (%s)', Constants::VERSION, Constants::STATUS), $result ); self::assertEquals(0, $commandTester->getStatusCode()); }
Base
1
public static function getHelpVersion($version_id) { global $db; return $db->selectValue('help_version', 'version', 'id="'.$version_id.'"'); }
Class
2
public static function canView($section) { global $db; if ($section == null) { return false; } if ($section->public == 0) { // Not a public section. Check permissions. return expPermissions::check('view', expCore::makeLocation('navigation', '', $section->id)); } else { // Is public. check parents. if ($section->parent <= 0) { // Out of parents, and since we are still checking, we haven't hit a private section. return true; } else { $s = $db->selectObject('section', 'id=' . $section->parent); return self::canView($s); } } }
Base
1
public function update() { $project = $this->getProject(); $values = $this->request->getValues(); list($valid, $errors) = $this->swimlaneValidator->validateModification($values); if ($valid) { if ($this->swimlaneModel->update($values['id'], $values)) { $this->flash->success(t('Swimlane updated successfully.')); return $this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id']))); } else { $errors = array('name' => array(t('Another swimlane with the same name exists in the project'))); } } return $this->edit($values, $errors); }
Base
1
function delete_selected() { $item = $this->event->find('first', 'id=' . $this->params['id']); if ($item && $item->is_recurring == 1) { $event_remaining = false; $eventdates = $item->eventdate[0]->find('all', 'event_id=' . $item->id); foreach ($eventdates as $ed) { if (array_key_exists($ed->id, $this->params['dates'])) { $ed->delete(); } else { $event_remaining = true; } } if (!$event_remaining) { $item->delete(); // model will also ensure we delete all event dates } expHistory::back(); } else { notfoundController::handle_not_found(); } }
Base
1
protected function getComment() { $comment = $this->commentModel->getById($this->request->getIntegerParam('comment_id')); if (empty($comment)) { throw new PageNotFoundException(); } if (! $this->userSession->isAdmin() && $comment['user_id'] != $this->userSession->getId()) { throw new AccessForbiddenException(); } return $comment; }
Base
1
function manage() { global $db, $router, $user; expHistory::set('manageable', $router->params); assign_to_template(array( 'canManageStandalones' => self::canManageStandalones(), 'sasections' => $db->selectObjects('section', 'parent=-1'), 'user' => $user, // 'canManagePagesets' => $user->isAdmin(), // 'templates' => $db->selectObjects('section_template', 'parent=0'), )); }
Base
1
public function update() { $project = $this->getProject(); $values = $this->request->getValues(); list($valid, $errors) = $this->swimlaneValidator->validateModification($values); if ($valid) { if ($this->swimlaneModel->update($values['id'], $values)) { $this->flash->success(t('Swimlane updated successfully.')); return $this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id']))); } else { $errors = array('name' => array(t('Another swimlane with the same name exists in the project'))); } } return $this->edit($values, $errors); }
Base
1
function productFeed() { // global $db; //check query password to avoid DDOS /* * condition = new * description * id - SKU * link * price * title * brand - manufacturer * image link - fullsized image, up to 10, comma seperated * product type - category - "Electronics > Audio > Audio Accessories MP3 Player Accessories","Health & Beauty > Healthcare > Biometric Monitors > Pedometers" */ $out = '"id","condition","description","like","price","title","brand","image link","product type"' . chr(13) . chr(10); $p = new product(); $prods = $p->find('all', 'parent_id=0 AND '); //$prods = $db->selectObjects('product','parent_id=0 AND'); }
Base
1
public static function insert($vars){ if(is_array($vars)){ $sql = array( 'table' => 'menus', 'key' => $vars ); $menu = Db::insert($sql); } }
Base
1
private function load($id) { global $zdb; try { $select = $zdb->select(self::TABLE); $select->limit(1)->where(self::PK . ' = ' . $id); $results = $zdb->execute($select); $res = $results->current(); $this->id = $id; $this->short = $res->short_label; $this->long = $res->long_label; } catch (Throwable $e) { Analog::log( 'An error occurred loading title #' . $id . "Message:\n" . $e->getMessage(), Analog::ERROR ); throw $e; } }
Base
1
public function approvedFileExtension($filename, $type = 'image') { $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if ($type == 'image') { switch ($ext) { case 'gif': case 'png': case 'jpeg': case 'jpg': case 'svg': return true; default: return false; } } elseif ($type == 'cert') { switch ($ext) { case 'pem': return true; default: return false; } } }
Base
1
public static function getIconName($module) { return isset(static::$iconNames[$module]) ? static::$iconNames[$module] : strtolower(str_replace('_', '-', $module)); }
Class
2
public static function dropdown($vars) { return Categories::dropdown($vars); }
Base
1
public function testSetSaveHandler53() { if (PHP_VERSION_ID >= 50400) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } $this->iniSet('session.save_handler', 'files'); $storage = $this->getStorage(); $storage->setSaveHandler(); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); $storage->setSaveHandler(null); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); $storage->setSaveHandler(new NativeSessionHandler()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); $storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler())); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); $storage->setSaveHandler(new NullSessionHandler()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); $storage->setSaveHandler(new NativeProxy()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); }
Base
1
function prepareInputForAdd($input) { //If it's the first ldap directory then set it as the default directory if (!self::getNumberOfServers()) { $input['is_default'] = 1; } if (isset($input["rootdn_passwd"]) && !empty($input["rootdn_passwd"])) { $input["rootdn_passwd"] = Toolbox::encrypt(stripslashes($input["rootdn_passwd"]), GLPIKEY); } return $input; }
Base
1
function getRights($interface = 'central') { $values = [READ => __('Read'), CREATE => __('Create'), PURGE => _x('button', 'Delete permanently'), self::CHECKUPDATE => __('Check for upgrade')]; return $values; }
Compound
4
private function formatMessage($message) { if ($this->timezone) { $graylogTime = new DateTime($message['message']['timestamp']); $offset = $this->timezone->getOffset($graylogTime); $timeInterval = DateInterval::createFromDateString((string) $offset . 'seconds'); $graylogTime->add($timeInterval); $displayTime = $graylogTime->format('Y-m-d H:i:s'); } else { $displayTime = $message['message']['timestamp']; } $device = $this->deviceFromSource($message['message']['source']); $level = $message['message']['level'] ?? ''; $facility = $message['message']['facility'] ?? ''; return [ 'severity' => $this->severityLabel($level), 'timestamp' => $displayTime, 'source' => $device ? Url::deviceLink($device) : $message['message']['source'], 'message' => $message['message']['message'] ?? '', 'facility' => is_numeric($facility) ? "($facility) " . __("syslog.facility.$facility") : $facility, 'level' => (is_numeric($level) && $level >= 0) ? "($level) " . __("syslog.severity.$level") : $level, ]; }
Base
1
function httpsTestController($serverPort) { $args = array('HTTPS' => ''); var_dump(request(php_uname('n'), $serverPort, "test_https.php", [], [], $args)); }
Class
2
return ${($_ = isset($this->services['Symfony\Component\DependencyInjection\Tests\Dumper\Rot13EnvVarProcessor']) ? $this->services['Symfony\Component\DependencyInjection\Tests\Dumper\Rot13EnvVarProcessor'] : ($this->services['Symfony\Component\DependencyInjection\Tests\Dumper\Rot13EnvVarProcessor'] = new \Symfony\Component\DependencyInjection\Tests\Dumper\Rot13EnvVarProcessor())) && false ?: '_'};
Base
1
public function Connected() { if(!empty($this->smtp_conn)) { $sock_status = socket_get_status($this->smtp_conn); if($sock_status["eof"]) { // the socket is valid but we are not connected if($this->do_debug >= 1) { $this->edebug("SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected"); } $this->Close(); return false; } return true; // everything looks good } return false; }
Class
2
$curVal[$key] = $tp->post_toForm($val); } } $target = e107::getUrl()->create('user/myprofile/edit',array('id'=>USERID)); $text = '<form method="post" action="'.$target.'" id="dataform" class="usersettings-form form-horizontal" enctype="multipart/form-data" autocomplete="off">'; //$text = (is_numeric($_uid) ? $rs->form_open("post", e_SELF."?".e_QUERY, "dataform", "", " class='form-horizontal' role='form' enctype='multipart/form-data'") : $rs->form_open("post", e_SELF, "dataform", "", " class='form-horizontal' role='form' enctype='multipart/form-data'")); if (e_QUERY == "update") { $text .= "<div class='fborder' style='text-align:center'><br />".str_replace("*", "<span class='required'>*</span>", LAN_USET_9)."<br />".LAN_USET_10."<br /><br /></div>"; } // e107::scStyle($sc_style); e107::getScBatch('usersettings')->setVars($curVal)->reset(); $USERSETTINGS_EDIT = $this->getTemplate('edit'); $USERSETTINGS_EDIT_CAPTION = $this->getTemplate('edit_caption'); $text .= $tp->parseTemplate($USERSETTINGS_EDIT, true, $this->sc); //ParseSC must be set to true so that custom plugin -shortcodes can be utilized. $text .= "<div><input type='hidden' name='_uid' value='{$uuid}' /></div> </form> "; $caption = (isset($USERSETTINGS_EDIT_CAPTION)) ? $USERSETTINGS_EDIT_CAPTION : LAN_USET_39; // 'Update User Settings' $ns->tablerender($caption, $text); }
Class
2
public static function autoload() { include (GX_LIB."Vendor/autoload.php"); }
Base
1
public function manage() { expHistory::set('manageable',$this->params); $gc = new geoCountry(); $countries = $gc->find('all'); $gr = new geoRegion(); $regions = $gr->find('all',null,'rank asc,name asc'); assign_to_template(array( 'countries'=>$countries, 'regions'=>$regions )); }
Class
2
function selectBillingOptions() { }
Class
2
function function_exists($name) { if (isset(\yiiunit\framework\base\SecurityTest::$functions[$name])) { return \yiiunit\framework\base\SecurityTest::$functions[$name]; } return \function_exists($name); }
Class
2
public static function attach($hooks_name, $func) { $hooks = self::$hooks; $hooks[$hooks_name][] = $func; self::$hooks = $hooks; return self::$hooks; }
Base
1
public function save() { global $DB; if(!empty($this->id)) return $this->update(); else return $this->insert(); }
Base
1
public function validateByMode(App\Request $request) { if ($request->isEmpty('purifyMode') || !$request->has('value')) { throw new \App\Exceptions\NoPermitted('ERR_ILLEGAL_VALUE', 406); } $response = new Vtiger_Response(); $response->setResult([ 'raw' => $request->getByType('value', $request->getByType('purifyMode')), ]); $response->emit(); }
Base
1