code
stringlengths
12
2.05k
label_name
stringclasses
5 values
label
int64
0
4
protected function GetRefs($refList, $type) { if (!$refList) return; if (empty($type)) return; $args = array(); $args[] = '--' . $type; $args[] = '--dereference'; $ret = $this->exe->Execute($refList->GetProject()->GetPath(), GIT_SHOW_REF, $args); $lines = explode("\n", $ret); $refs = array()...
Base
1
$product = X2Model::model('Products')->findByAttributes(array('name'=>$lineItem->name)); if (isset($product)) $lineItem->productId = $product->id; if(empty($lineItem->currency)) $lineItem->currency = $defaultCurrency; if($lin...
Base
1
public function renameTag($oldName, $newName) { // http://stackoverflow.com/a/1873932 // create new as alias to old (`git tag NEW OLD`) $this->run('tag', $newName, $oldName); // delete old (`git tag -d OLD`) $this->removeTag($oldName); return $this; }
Class
2
$ret = array_merge($ret, csrf_flattenpost2($level+1, $nk, $v)); }
Compound
4
public function duplicateAction(Project $project, Request $request, ProjectDuplicationService $projectDuplicationService) { $newProject = $projectDuplicationService->duplicate($project, $project->getName() . ' [COPY]'); return $this->redirectToRoute('project_details', ['id' => $newProject->getI...
Compound
4
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), 'paren...
Base
1
public function insert() { global $DB; $ok = $DB->execute(' INSERT INTO nv_menus (id, codename, icon, lid, notes, functions, enabled) VALUES ( 0, :codename, :icon, :lid, :notes, :functions, :enabled)', array( 'codename' => value_or_default($this->codename, ""), 'icon' =...
Base
1
function searchCategory() { return gt('Event'); }
Base
1
public function confirm() { $project = $this->getProject(); $tag_id = $this->request->getIntegerParam('tag_id'); $tag = $this->tagModel->getById($tag_id); $this->response->html($this->template->render('project_tag/remove', array( 'tag' => $tag, 'proje...
Base
1
public function getViewItemLink($icmsObj, $onlyUrl=false, $withimage=true, $userSide=false) { if ($this->handler->_moduleName != 'system') { $admin_side = $userSide ? '' : 'admin/'; $ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . "?" . $this->handler->keyName . "=" . $icmsObj->getV...
Base
1
$connecttext = preg_replace("/#connectport#/", $connectport, $connecttext); $connectMethods[$key]["connecttext"] = $connecttext; } return array('status' => 'ready', 'serverIP' => $serverIP, 'user' => $thisuser, 'password' => $passwd, ...
Class
2
public static function returnChildrenAsJSON() { global $db; //$nav = section::levelTemplate(intval($_REQUEST['id'], 0)); $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $nav = $db->selectObjects('section', 'parent=' . $id, 'rank'); //FIXME $m...
Base
1
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); }
Class
2
function get_filedisplay_views() { expTemplate::get_filedisplay_views(); $paths = array( BASE.'framework/modules/common/views/file/', BASE.'themes/'.DISPLAY_THEME.'modules/common/views/file/', ); $views = array(); foreach ($paths as $path) { if (is_readable($path)) { ...
Base
1
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...
Base
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...
Class
2
public function providesExceptionData() { $notFoundEnvMessage = 'Not found in env'; $notFoundEnvException = new NotFoundEnvException($notFoundEnvMessage); $notFoundEnvStatus = Http::STATUS_NOT_FOUND; $notFoundServiceMessage = 'Not found in service'; $notFoundServiceException = new NotFoundServiceException($...
Base
1
public function remove($zdb) { $id = (int)$this->id; if ($id === self::MR || $id === self::MRS) { throw new \RuntimeException(_T("You cannot delete Mr. or Mrs. titles!")); } try { $delete = $zdb->delete(self::TABLE); $delete->where( ...
Base
1
public function showall_tags() { $images = $this->image->find('all'); $used_tags = array(); foreach ($images as $image) { foreach($image->expTag as $tag) { if (isset($used_tags[$tag->id])) { $used_tags[$tag->id]->count++; } else...
Base
1
public function thumbnailTreeAction() { $this->checkPermission('thumbnails'); $thumbnails = []; $list = new Asset\Image\Thumbnail\Config\Listing(); $groups = []; foreach ($list->getThumbnails() as $item) { if ($item->getGroup()) { if (empty(...
Base
1
$ret[$key] = sprintf( $format, ++$i, $err[0], $err[1], $err[2], $err[3] ); } return $ret; }
Base
1
public function attributeLabels() { return array( 'actionId' => Yii::t('actions','Action ID'), 'text' => Yii::t('actions','Action Text'), ); }
Base
1
function update() { parent::update(); expSession::clearAllUsersSessionCache('navigation'); }
Base
1
public function getInvalidPaths() { return array( array('foo[['), array('foo[d'), array('foo[bar]]'), array('foo[bar]d'), ); }
Base
1
public function actionPublishPost() { $post = new Events; // $user = $this->loadModel($id); if (isset($_POST['text']) && $_POST['text'] != "") { $post->text = $_POST['text']; $post->visibility = $_POST['visibility']; if (isset($_POST['associationId'])) ...
Class
2
private function getCategory() { $category = $this->categoryModel->getById($this->request->getIntegerParam('category_id')); if (empty($category)) { throw new PageNotFoundException(); } return $category; }
Base
1
function get_abs_item($dir, $item) { // get absolute file+path return get_abs_dir($dir).DIRECTORY_SEPARATOR.$item; }
Base
1
function checkRights(&$db,&$user) { return $user->hasRight($db,'testplan_metrics'); }
Base
1
protected function deleteFileInStorage(Attachment $attachment) { $storage = $this->getStorage(); $dirPath = $this->adjustPathForStorageDisk(dirname($attachment->path)); $storage->delete($this->adjustPathForStorageDisk($attachment->path)); if (count($storage->allFiles($dirPath)) ...
Base
1
} elseif (isset($graph['data_query_name'])) { if (isset($prev_data_query_name)) { if ($prev_data_query_name != $graph['data_query_name']) { $print = true; $prev_data_query_name = $graph['data_query_name']; } else { $print = false; } } else { $print = true; $prev_d...
Base
1
protected function setUp() { static::$functions = []; static::$fopen = null; static::$fread = null; parent::setUp(); $this->security = new ExposedSecurity(); $this->security->derivationIterations = 1000; // speed up test running }
Class
2
public function update() { $project = $this->getProject(); $tag_id = $this->request->getIntegerParam('tag_id'); $tag = $this->tagModel->getById($tag_id); $values = $this->request->getValues(); list($valid, $errors) = $this->tagValidator->validateModification($values); ...
Base
1
function db_seq_nextval($seqname) { global $DatabaseType; if ($DatabaseType == 'mysqli') $seq = "fn_" . strtolower($seqname) . "()"; return $seq; }
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 ...
Base
1
public function privateCore(&$response, $user, $permissions) { parent::privateCore($response, $user, $permissions); $this->model = new PageOption(); $this->loadSelectedViewName(); $this->backPage = $this->request->get('url') ?: $this->selectedViewName; $this->selectedUser...
Base
1
public function assets_path($file = NULL, $path = NULL, $module = NULL, $absolute = NULL) { $cache = ''; if (!isset($absolute)) $absolute = $this->assets_absolute_path; $CI = $this->_get_assets_config(); if ($this->asset_append_cache_timestamp AND in_array($path, $this->asset_append_cache_timestamp) AND !e...
Class
2
public function startup(Event $event) { $controller = $event->subject(); $request = $controller->request; $response = $controller->response; $cookieName = $this->_config['cookieName']; $cookieData = $request->cookie($cookieName); if ($cookieData) { $r...
Compound
4
function update_option_master() { global $db; $id = empty($this->params['id']) ? null : $this->params['id']; $opt = new option_master($id); $oldtitle = $opt->title; $opt->update($this->params); // if the title of the master changed we should...
Base
1
$context['clockicons'] = unserialize(base64_decode('YTozOntzOjE6ImgiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czoxOiJtIjthOjY6e2k6MDtpOjMyO2k6MTtpOjE2O2k6MjtpOjg7aTozO2k6NDtpOjQ7aToyO2k6NTtpOjE7fXM6MToicyI7YTo2OntpOjA7aTozMjtpOjE7aToxNjtpOjI7aTo4O2k6MztpOjQ7aTo0O2k6MjtpOjU7aToxO319')); }
Base
1
static public function resize($src, $dst, $width, $height, $crop=0){ if(!list($w, $h) = getimagesize($src)) return "Unsupported picture type!"; $type = strtolower(substr(strrchr($src,"."),1)); if($type == 'jpeg') $type = 'jpg'; switch($type){ case 'bmp': $img = i...
Base
1
function update() { parent::update(); expSession::clearAllUsersSessionCache('navigation'); }
Class
2
public function validateWriteAccess($skipRequestTypeCheck = false) { if (!$skipRequestTypeCheck && 'POST' !== $_SERVER['REQUEST_METHOD']) { throw new \App\Exceptions\Csrf('Invalid request - validate Write Access'); } $this->validateReadAccess(); if (class_exists('CSRFConfig') && !\CsrfMagic\Csrf::check(fal...
Compound
4
$debug_info .= sprintf("%s%s\r\n", str_pad($header_name . ': ', 20), w3_escape_comment($header_value)); } }
Compound
4
function insertObject($object, $table) { //if ($table=="text") eDebug($object,true); $sql = "INSERT INTO `" . $this->prefix . "$table` ("; $values = ") VALUES ("; foreach (get_object_vars($object) as $var => $val) { //We do not want to save any fields that start with an ...
Base
1
public function delete(DeleteInvoiceRequest $request) { $this->authorize('delete multiple invoices'); Invoice::destroy($request->ids); return response()->json([ 'success' => true, ]); }
Class
2
foreach ($days as $event) { if (empty($event->eventdate->date) || ($viewrange == 'upcoming' && $event->eventdate->date < time())) break; if (empty($event->eventstart)) $eve...
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), 'control...
Base
1
static function decrypt($string, $key) { $result = ''; $string = base64_decode($string); for ($i=0; $i<strlen($string); $i++) { $char = substr($string, $i, 1); $keychar = substr($key, ($i % strlen($key))-1, 1); $char = chr(ord($char)-ord($keychar)); $resu...
Class
2
public function string($skip_ajax = false) { if ($skip_ajax == true) { $url = $this->current($skip_ajax); } else { $url = false; } $u1 = implode('/', $this->segment(-1, $url)); // clear request params $cleanParam = new HTMLClean(); ...
Base
1
function update_vendor() { $vendor = new vendor(); $vendor->update($this->params['vendor']); expHistory::back(); }
Base
1
public function confirm() { $task = $this->getTask(); $comment = $this->getComment(); $this->response->html($this->template->render('comment/remove', array( 'comment' => $comment, 'task' => $task, 'title' => t('Remove a comment') ))); }
Base
1
public function update() { //populate the alt tag field if the user didn't if (empty($this->params['alt'])) $this->params['alt'] = $this->params['title']; // call expController update to save the image parent::update(); }
Base
1
$this->archiveSize += filesize($p); } } } else {
Base
1
public function delete(){ $item_id = I("item_id/d"); $id = I("id/d"); $login_user = $this->checkLogin(); $uid = $login_user['uid'] ; if(!$this->checkItemEdit($uid , $item_id)){ $this->sendError(10303); return ; } $ret = D("ItemVar...
Compound
4
public static function parentPlaceholder($section = '') { if (! isset(static::$parentPlaceholder[$section])) { static::$parentPlaceholder[$section] = '##parent-placeholder-'.sha1($section).'##'; } return static::$parentPlaceholder[$section]; }
Class
2
public function getQuerySelect() { return ''; }
Base
1
public static function httpMethodProvider() { return [ ['PATCH'], ['PUT'], ['POST'], ['DELETE'] ]; }
Compound
4
public static function functionExist($var) { if (file_exists(GX_THEME.$var.'/function.php')) { return true; }else{ return false; } }
Base
1
function scan($dir, $filter = '') { $path = FM_ROOT_PATH.'/'.$dir; $ite = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); $rii = new RegexIterator($ite, "/(".$filter.")/i"); $files = array(); foreach ($rii as $file) { if (!$file->isDir()) { $fileName = $f...
Base
1
function configure() { expHistory::set('editable', $this->params); // little bit of trickery so that that categories can have their own configs $this->loc->src = "@globalstoresettings"; $config = new expConfig($this->loc); $this->config = $config->config; $pu...
Class
2
$text = wfMessage( 'intersection_noincludecats', $args )->text(); } } if ( empty( $text ) ) { $text = wfMessage( 'dpl_log_' . $errorMessageId, $args )->text(); } $this->buffer[] = '<p>Extension:DynamicPageList (DPL), version ' . DPL_VERSION . ': ' . $text . '</p>'; } return false; }
Class
2
public function approve_toggle() { if (empty($this->params['id'])) return; /* The global constants can be overriden by passing appropriate params */ //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet // $require_login = empty($this->params['re...
Base
1
function test_valid_comment() { $result = $this->myxmlrpcserver->wp_newComment( array( 1, 'administrator', 'administrator', self::$post->ID, array( 'content' => rand_str( 100 ), ), ) ); $this->assertNotIXRError( $result ); }
Class
2
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, 'filt...
Base
1
foreach ($usr as $u) { # code... $msgs = str_replace('{{userid}}', $u->userid, $msg); $vars = array( 'to' => $u->email, 'to_name' => $u->userid, 'message' => $msgs, ...
Base
1
public static function incFront($vars, $param='') { $file = GX_PATH.'/inc/lib/Control/Frontend/'.$vars.'.control.php'; if ( file_exists($file) ) { # code... include($file); }else{ self::error('404'); } }
Base
1
function update_upcharge() { $this->loc->src = "@globalstoresettings"; $config = new expConfig($this->loc); $this->config = $config->config; //This will make sure that only the country or region that given a rate value will be saved in the db $upcharge = array(); foreach($this->params['upch...
Class
2
public function run() { if ($this->user->isCurrentUser() || \Yii::$app->user->isGuest) { return; } // Add class for javascript handling $this->followOptions['class'] .= ' followButton'; $this->unfollowOptions['class'] .= ' unfollowButton'; // Hide in...
Base
1
function manage_vendors () { expHistory::set('viewable', $this->params); $vendor = new vendor(); $vendors = $vendor->find('all'); assign_to_template(array( 'vendors'=>$vendors )); }
Class
2
public function save() { $project = $this->getProject(); $values = $this->request->getValues(); list($valid, $errors) = $this->categoryValidator->validateCreation($values); if ($valid) { if ($this->categoryModel->create($values) !== false) { $this->f...
Base
1
public function resetauthkey($id = null) { if (!$this->_isAdmin() && Configure::read('MISP.disableUserSelfManagement')) { throw new MethodNotAllowedException('User self-management has been disabled on this instance.'); } if ($id == 'me') { $id = $this->Auth->user(...
Class
2
public function testGetDeep() { $bag = new ParameterBag(array('foo' => array('bar' => array('moo' => 'boo')))); $this->assertEquals(array('moo' => 'boo'), $bag->get('foo[bar]', null, true)); $this->assertEquals('boo', $bag->get('foo[bar][moo]', null, true)); $this->assertEquals(...
Base
1
private function getTaskLink() { $link = $this->taskLinkModel->getById($this->request->getIntegerParam('link_id')); if (empty($link)) { throw new PageNotFoundException(); } return $link; }
Base
1
function reparent_standalone() { $standalone = $this->section->find($this->params['page']); if ($standalone) { $standalone->parent = $this->params['parent']; $standalone->update(); expSession::clearAllUsersSessionCache('navigation'); expHistory::...
Base
1
private function createResponse( RequestInterface $request, array $options, $stream, $startTime ) { $hdrs = $this->lastHeaders; $this->lastHeaders = []; $parts = explode(' ', array_shift($hdrs), 3); $ver = explode('/', $parts[0])[1]; $statu...
Base
1
$this->headerLines = ['Host' => [$host]] + $this->headerLines;
Base
1
public function handle($request, Closure $next) { /** @var \Barryvdh\Debugbar\LaravelDebugbar $debugbar */ $debugbar = $this->app['debugbar']; try { return $next($request); } catch (\Exception $ex) { if (!\Request::ajax()) { throw $...
Base
1
public function testOnKernelResponseListenerRemovesItself() { $session = $this->createMock(SessionInterface::class); $session->expects($this->any())->method('getName')->willReturn('SESSIONNAME'); $tokenStorage = $this->createMock(TokenStorageInterface::class); $dispatcher = $this...
Class
2
function send_feedback() { $success = false; if (isset($this->params['id'])) { $ed = new eventdate($this->params['id']); // $email_addrs = array(); if ($ed->event->feedback_email != '') { $msgtemplate = expTemplate::get_template_for_action($th...
Base
1
public static function type($id) { $id = sprintf('%d', $id); if(isset($id)){ $cat = Db::result("SELECT `type` FROM `cat` WHERE `id` = '{$id}' LIMIT 1"); //print_r($cat); if(isset($cat['error'])){ return ''; ...
Base
1
public static function navtojson() { return json_encode(self::navhierarchy()); }
Base
1
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->purchas...
Base
1
public function testGetDropdownConnect($params, $expected, $session_params = []) { $this->login(); $bkp_params = []; //set session params if any if (count($session_params)) { foreach ($session_params as $param => $value) { if (isset($_SESSION[$param])) { $...
Class
2
protected function decode($hash) { if (strpos($hash, $this->id) === 0) { // cut volume id after it was prepended in encode $h = substr($hash, strlen($this->id)); // replace HTML safe base64 to normal $h = base64_decode(strtr($h, '-_.', '+/=')); // TODO uncrypt hash and return path $path = $this->un...
Base
1
public static function BBCode2Html($text) { $text = trim($text); $text = self::parseEmoji($text); // Smileys to find... $in = array( ); // And replace them by... $out = array( ); $in[] = '[/*]'; $in[] = '[*]'; $out[] = '</li...
Base
1
public static function login() { user::login(expString::sanitize($_POST['username']),expString::sanitize($_POST['password'])); if (!isset($_SESSION[SYS_SESSION_KEY]['user'])) { // didn't successfully log in flash('error', gt('Invalid Username / Password')); if (expSession::is_set('redirecturl_error')) { ...
Base
1
public static function connect ($dbhost=DB_HOST, $dbuser=DB_USER, $dbpass=DB_PASS, $dbname=DB_NAME) { self::$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname); if (self::$mysqli->connect_error) { return false; }else{ return tru...
Base
1
foreach($fields as $field) { if(substr($key, 0, strlen($field.'-'))==$field.'-') $this->dictionary[substr($key, strlen($field.'-'))][$field] = $value; }
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
function nvweb_webuser_generate_username($email) { global $DB; global $website; // generate a valid username // try to get the left part of the email address, except if it is a common account name $username = strtolower(substr($email, 0, strpos($email, '@'))); // left part of the email ...
Base
1
function db_seq_nextval($seqname) { global $DatabaseType; if ($DatabaseType == 'mysqli') $seq = "fn_" . strtolower($seqname) . "()"; return $seq; }
Base
1
public function breadcrumb() { global $sectionObj; expHistory::set('viewable', $this->params); $id = $sectionObj->id; $current = null; // Show not only the location of a page in the hierarchy but also the location of a standalone page $current = new secti...
Base
1
fwrite(STDERR, sprintf("%2d %s ==> %s\n", $i + 1, $test, var_export($result, true)));
Class
2
protected function _fopen($path, $mode='rb') { if (($mode == 'rb' || $mode == 'r')) { try { $res = $this->dropbox->media($path); $url = parse_url($res['url']); $fp = stream_socket_client('ssl://'.$url['host'].':443'); fputs($fp, "GET {$url['path']} HTTP/1.0\r\n"); fputs($fp, "Host: {$url['...
Base
1
public function logout(){ $login_user = $this->checkLogin(); D("UserToken")->where(" uid = '$login_user[uid]' ")->save(array("token_expire"=>0)); session("login_user" , NULL); cookie('cookie_token',NULL); session(null); $this->sendResult(array()); }
Compound
4
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...
Base
1
public function testNewInstanceWhenNewBody() { $r = new Response(200, [], 'foo'); $b2 = Psr7\stream_for('abc'); $this->assertNotSame($r, $r->withBody($b2)); }
Base
1
foreach($gc as $gcc=>$gcd) { if($gcd!='' && $gcc!='GRADE_LEVEL') { $sql_columns[]=$gcc; $sql_values[]="'".$gcd."'"; } if($gcd!='' && $gcc=='GRAD...
Base
1
public static function rss() { switch (SMART_URL) { case true: # code... $url = Options::get('siteurl')."/rss".GX_URL_PREFIX; break; default: # code... $url = Options::get('siteurl')."/index....
Base
1
function edit() { global $user; /* The global constants can be overriden by passing appropriate params */ //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet $require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOG...
Class
2