code
stringlengths
12
2.05k
label_name
stringclasses
5 values
label
int64
0
4
public function remove() { $this->checkCSRFParam(); $project = $this->getProject(); $filter = $this->customFilterModel->getById($this->request->getIntegerParam('filter_id')); $this->checkPermission($project, $filter); if ($this->customFilterModel->remove($filter['id'])) { $this->flash->success(t('Custom filter removed successfully.')); } else { $this->flash->failure(t('Unable to remove this custom filter.')); } $this->response->redirect($this->helper->url->to('CustomFilterController', 'index', array('project_id' => $project['id']))); }
Base
1
function download($disposition=false, $expires=false) { $disposition = $disposition ?: 'inline'; $bk = $this->open(); if ($bk->sendRedirectUrl($disposition)) return; $ttl = ($expires) ? $expires - Misc::gmtime() : false; $this->makeCacheable($ttl); $type = $this->getType() ?: 'application/octet-stream'; Http::download($this->getName(), $type, null, 'inline'); header('Content-Length: '.$this->getSize()); $this->sendData(false); exit(); }
Base
1
function init_args(&$dbHandler) { $argsObj = new stdClass(); $argsObj->doIt = false; $argsObj->showPlatforms = false; $argsObj->tproject_id = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0; $argsObj->tproject_name = isset($_SESSION['testprojectName']) ? $_SESSION['testprojectName'] : ''; $argsObj->tplan_name = ''; $argsObj->tplan_id = isset($_REQUEST['tplan_id']) ? $_REQUEST['tplan_id'] : 0; if($argsObj->tplan_id == 0) { $argsObj->tplan_id = isset($_SESSION['testplanID']) ? $_SESSION['testplanID'] : 0; } if($argsObj->tplan_id > 0) { $tplan_mgr = new testplan($dbHandler); $tplan_info = $tplan_mgr->get_by_id($argsObj->tplan_id); $argsObj->tplan_name = $tplan_info['name']; $argsObj->doIt = $tplan_mgr->count_testcases($argsObj->tplan_id) > 0; $argsObj->showPlatforms = $tplan_mgr->hasLinkedPlatforms($argsObj->tplan_id); $getOpt = array('outputFormat' => 'map'); $argsObj->platforms = $tplan_mgr->getPlatforms($argsObj->tplan_id,$getOpt); unset($tplan_mgr); } return $argsObj; }
Base
1
function comment_item($params) { if (!user_can_access('module.comments.index')) { return; } $data = array( 'id' => $params['comment_id'], 'single' => true, ); $comment = get_comments($data); if (!$comment) { return; } $view_file = $this->views_dir . 'comment_item.php'; $view = new View($view_file); $view->assign('params', $params); $view->assign('comment', $comment); return $view->display(); }
Base
1
public static function dropdown($vars) { if(is_array($vars)){ //print_r($vars); $name = $vars['name']; $where = "WHERE "; if(isset($vars['parent'])) { $where .= " `parent` = '{$vars['parent']}' "; }else{ $where .= "1 "; } $order_by = "ORDER BY "; if(isset($vars['order_by'])) { $order_by .= " {$vars['order_by']} "; }else{ $order_by .= " `name` "; } if (isset($vars['sort'])) { $sort = " {$vars['sort']}"; } } $cat = Db::result("SELECT * FROM `cat` {$where} {$order_by} {$sort}"); $drop = "<select name=\"{$name}\" class=\"form-control\"><option></option>"; if(Db::$num_rows > 0 ){ foreach ($cat as $c) { # code... if($c->parent == ''){ if(isset($vars['selected']) && $c->id == $vars['selected']) $sel = "SELECTED"; else $sel = ""; $drop .= "<option value=\"{$c->id}\" $sel style=\"padding-left: 10px;\">{$c->name}</option>"; foreach ($cat as $c2) { # code... if($c2->parent == $c->id){ if(isset($vars['selected']) && $c2->id == $vars['selected']) $sel = "SELECTED"; else $sel = ""; $drop .= "<option value=\"{$c2->id}\" $sel style=\"padding-left: 10px;\">&nbsp;&nbsp;&nbsp;{$c2->name}</option>"; } } } } } $drop .= "</select>"; return $drop; }
Base
1
public static function is_exist($user) { if(isset($_GET['act']) && $_GET['act'] == 'edit'){ $id = Typo::int($_GET['id']); $where = "AND `id` != '{$id}' "; }else{ $where = ''; } $user = sprintf('%s', Typo::cleanX($user)); $sql = sprintf("SELECT `userid` FROM `user` WHERE `userid` = '%s' %s ", $user, $where); $usr = Db::result($sql); $n = Db::$num_rows; if($n > 0 ){ return false; }else{ return true; } }
Base
1
public function approve() { expHistory::set('editable', $this->params); /* The global constants can be overriden by passing appropriate params */ //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet $require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login']; $require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval']; $require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification']; $notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email']; if (empty($this->params['id'])) { flash('error', gt('No ID supplied for note to approve')); $lastUrl = expHistory::getLast('editable'); } $simplenote = new expSimpleNote($this->params['id']); assign_to_template(array( 'simplenote'=>$simplenote, 'require_login'=>$require_login, 'require_approval'=>$require_approval, 'require_notification'=>$require_notification, 'notification_email'=>$notification_email, 'tab'=>$this->params['tab'] )); }
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
private function getResponse ($size = 128) { $pop3_response = fgets($this->pop_conn, $size); return $pop3_response; }
Class
2
protected function getCustomDefinitionService() { return $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition(); }
Base
1
$date->delete(); // event automatically deleted if all assoc eventdates are deleted } expHistory::back(); }
Class
2
function edit() { if (empty($this->params['content_id'])) { flash('message',gt('An error occurred: No content id set.')); expHistory::back(); } /* The global constants can be overridden by passing appropriate params */ //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet // $require_login = empty($this->params['require_login']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login']; // $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval']; // $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification']; // $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email']; $id = empty($this->params['id']) ? null : $this->params['id']; $comment = new expComment($id); //FIXME here is where we might sanitize the comment before displaying/editing it assign_to_template(array( 'content_id'=>$this->params['content_id'], 'content_type'=>$this->params['content_type'], 'comment'=>$comment )); }
Base
1
public function Connect ($host, $port = false, $tval = 30) { // Are we already connected? if ($this->connected) { return true; } /* On Windows this will raise a PHP Warning error if the hostname doesn't exist. Rather than supress it with @fsockopen, let's capture it cleanly instead */ set_error_handler(array(&$this, 'catchWarning')); // Connect to the POP3 server $this->pop_conn = fsockopen($host, // POP3 Host $port, // Port # $errno, // Error Number $errstr, // Error Message $tval); // Timeout (seconds) // Restore the error handler restore_error_handler(); // Does the Error Log now contain anything? if ($this->error && $this->do_debug >= 1) { $this->displayErrors(); } // Did we connect? if ($this->pop_conn == false) { // It would appear not... $this->error = array( 'error' => "Failed to connect to server $host on port $port", 'errno' => $errno, 'errstr' => $errstr ); if ($this->do_debug >= 1) { $this->displayErrors(); } return false; } // Increase the stream time-out // Check for PHP 4.3.0 or later if (version_compare(phpversion(), '5.0.0', 'ge')) { stream_set_timeout($this->pop_conn, $tval, 0); } else { // Does not work on Windows if (substr(PHP_OS, 0, 3) !== 'WIN') { socket_set_timeout($this->pop_conn, $tval, 0); } } // Get the POP3 server response $pop3_response = $this->getResponse(); // Check for the +OK if ($this->checkResponse($pop3_response)) { // The connection is established and the POP3 server is talking $this->connected = true; return true; } return false; }
Class
2
$banner->increaseImpressions(); } } // assign banner to the template and show it! assign_to_template(array( 'banners'=>$banners )); }
Base
1
function sanitize_plural_expression($expr) { // Get rid of disallowed characters. $expr = preg_replace('@[^a-zA-Z0-9_:;\(\)\?\|\&=!<>+*/\%-]@', '', $expr); // Add parenthesis for tertiary '?' operator. $expr .= ';'; $res = ''; $p = 0; for ($i = 0; $i < strlen($expr); $i++) { $ch = $expr[$i]; switch ($ch) { case '?': $res .= ' ? ('; $p++; break; case ':': $res .= ') : ('; break; case ';': $res .= str_repeat( ')', $p) . ';'; $p = 0; break; default: $res .= $ch; } } return $res; }
Base
1
public static function countries($lang="", $alpha3=false) { global $DB; global $user; // static function can be called from navigate or from a webget (user then is not a navigate user) if(empty($lang)) $lang = $user->language; $code = 'country_code'; if($alpha3) $code = 'alpha3'; $DB->query('SELECT '.$code.' AS country_code, name FROM nv_countries WHERE lang = '.protect($lang).' ORDER BY name ASC'); $rs = $DB->result(); if(empty($rs)) { // failback, load English names $DB->query('SELECT '.$code.' AS country_code, name FROM nv_countries WHERE lang = "en" ORDER BY name ASC'); $rs = $DB->result(); } $out = array(); foreach($rs as $country) { $out[$country->country_code] = $country->name; } return $out; }
Base
1
public static function CanTrustFormLayoutContent($sPostedFormManagerData, $aOriginalFormProperties) { $aPostedFormManagerData = json_decode($sPostedFormManagerData, true); $sPostedFormLayoutType = (isset($aPostedFormManagerData['formproperties']['layout']['type'])) ? $aPostedFormManagerData['formproperties']['layout']['type'] : ''; if ($sPostedFormLayoutType === 'xhtml') { return true; } // we need to parse the content so that autoclose tags are returned correctly (`<div />` => `<div></div>`) $oHtmlDocument = new \DOMDocument(); $sPostedFormLayoutContent = (isset($aPostedFormManagerData['formproperties']['layout']['content'])) ? $aPostedFormManagerData['formproperties']['layout']['content'] : ''; $oHtmlDocument->loadXML('<root>'.$sPostedFormLayoutContent.'</root>'); $sPostedFormLayoutRendered = $oHtmlDocument->saveHTML(); $sOriginalFormLayoutContent = (isset($aOriginalFormProperties['layout']['content'])) ? $aOriginalFormProperties['layout']['content'] : ''; $oHtmlDocument->loadXML('<root>'.$sOriginalFormLayoutContent.'</root>'); $sOriginalFormLayoutContentRendered = $oHtmlDocument->saveHTML(); return ($sPostedFormLayoutRendered === $sOriginalFormLayoutContentRendered); }
Base
1
private function _handleCallback(){ try { // Try to get an access token using the authorization code grant. $accessToken = $this->_provider->getAccessToken('authorization_code', [ 'code' => $_GET['code'] ]); } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) { // Failed to get the access token or user details. exit($e->getMessage()); } $resourceOwner = $this->_provider->getResourceOwner($accessToken); $user = $this->_userHandling( $resourceOwner->toArray() ); $user->setCookies(); global $wgOut, $wgRequest; $title = null; $wgRequest->getSession()->persist(); if( $wgRequest->getSession()->exists('returnto') ) { $title = Title::newFromText( $wgRequest->getSession()->get('returnto') ); $wgRequest->getSession()->remove('returnto'); $wgRequest->getSession()->save(); } if( !$title instanceof Title || 0 > $title->mArticleID ) { $title = Title::newMainPage(); } $wgOut->redirect( $title->getFullURL() ); return true; }
Compound
4
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; }
Class
2
public function __construct($message, $code = 0, Exception $previous = null) { parent::__construct($message, $code, $previous); }
Base
1
function update_optiongroup_master() { global $db; $id = empty($this->params['id']) ? null : $this->params['id']; $og = new optiongroup_master($id); $oldtitle = $og->title; $og->update($this->params); // if the title of the master changed we should update the option groups that are already using it. if ($oldtitle != $og->title) { $db->sql('UPDATE '.$db->prefix.'optiongroup SET title="'.$og->title.'" WHERE title="'.$oldtitle.'"'); } expHistory::back(); }
Base
1
function edit_internalalias() { $section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params); if ($section->parent == -1) { notfoundController::handle_not_found(); exit; } // doesn't work for standalone pages if (empty($section->id)) { $section->public = 1; if (!isset($section->parent)) { // This is another precaution. The parent attribute // should ALWAYS be set by the caller. //FJD - if that's the case, then we should die. notfoundController::handle_not_authorized(); exit; //$section->parent = 0; } } assign_to_template(array( 'section' => $section, 'glyphs' => self::get_glyphs(), )); }
Base
1
function lockTable($table,$lockType="WRITE") { $sql = "LOCK TABLES `" . $this->prefix . "$table` $lockType"; $res = mysqli_query($this->connection, $sql); return $res; }
Base
1
foreach ($grpusers as $u) { $emails[$u->email] = trim(user::getUserAttribution($u->id)); }
Class
2
static function description() { return "Manage events and schedules, and optionally publish them."; }
Base
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(); }
Base
1
protected function tearDown() { static::$functions = []; static::$fopen = null; static::$fread = null; parent::tearDown(); }
Class
2
public function onLoadRecord() { $scheduleCode = post('recordId'); $scheduleItem = $this->getSchedule($scheduleCode); $formTitle = sprintf(lang($this->formTitle), lang('admin::lang.text_'.$scheduleCode)); return $this->makePartial('recordeditor/form', [ 'formRecordId' => $scheduleCode, 'formTitle' => $formTitle, 'formWidget' => $this->makeScheduleFormWidget($scheduleItem), ]); }
Base
1
$contents = ['form' => tep_draw_form('reviews', 'reviews.php', 'page=' . $_GET['page'] . '&rID=' . $rInfo->reviews_id . '&action=deleteconfirm')];
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; }
Class
2
public function manage_sitemap() { global $db, $user, $sectionObj, $sections; expHistory::set('viewable', $this->params); $id = $sectionObj->id; $current = null; // all we need to do is determine the current section $navsections = $sections; if ($sectionObj->parent == -1) { $current = $sectionObj; } else { foreach ($navsections as $section) { if ($section->id == $id) { $current = $section; break; } } } assign_to_template(array( 'sasections' => $db->selectObjects('section', 'parent=-1'), 'sections' => $navsections, 'current' => $current, 'canManage' => ((isset($user->is_acting_admin) && $user->is_acting_admin == 1) ? 1 : 0), )); }
Base
1
$args['name'][$i] = $this->sanitizeFileName($name, $opts); } } else { $args['name'] = $this->sanitizeFileName($args['name'], $opts); } } return true; }
Base
1
$ds = self::connectToServer($replicate["host"], $replicate["port"], $ldap_method['rootdn'], Toolbox::decrypt($ldap_method['rootdn_passwd'], GLPIKEY), $ldap_method['use_tls'], $ldap_method['deref_option']); // Test with login and password of the user if (!$ds && !empty($login)) { $ds = self::connectToServer($replicate["host"], $replicate["port"], $login, $password, $ldap_method['use_tls'], $ldap_method['deref_option']); } if ($ds) { return $ds; } } }
Class
2
public static function TimeZone(){ $timezones = DateTimeZone::listAbbreviations(DateTimeZone::ALL); $cities = array(); foreach( $timezones as $key => $zones ) { foreach( $zones as $id => $zone ) { //print_r($zone); /** * Only get timezones explicitely not part of "Others". * @see http://www.php.net/manual/en/timezones.others.php */ if ( preg_match( '/^(America|Antartica|Arctic|Asia|Atlantic|Europe|Indian|Pacific)\//', $zone['timezone_id'] ) && $zone['timezone_id']) { $cities[$zone['timezone_id']][] = $key; } } } // For each city, have a comma separated list of all possible timezones for that city. foreach( $cities as $key => $value ) $cities[$key] = join( ', ', $value); // Only keep one city (the first and also most important) for each set of possibilities. $cities = array_unique( $cities ); // Sort by area/city name. ksort( $cities ); return $cities; }
Base
1
function execute_backup($command) { $backup_options = get_option('dbmanager_options'); check_backup_files(); if( realpath( $backup_options['path'] ) === false ) { return sprintf( __( '%s is not a valid backup path', 'wp-dbmanager' ), stripslashes( $backup_options['path'] ) ); } else if( dbmanager_is_valid_path( $backup_options['mysqldumppath'] ) === 0 ) { return sprintf( __( '%s is not a valid mysqldump path', 'wp-dbmanager' ), stripslashes( $backup_options['mysqldumppath'] ) ); } else if( dbmanager_is_valid_path( $backup_options['mysqlpath'] ) === 0 ) { return sprintf( __( '%s is not a valid mysql path', 'wp-dbmanager' ), stripslashes( $backup_options['mysqlpath'] ) ); } if(substr(PHP_OS, 0, 3) == 'WIN') { $writable_dir = $backup_options['path']; $tmpnam = $writable_dir.'/wp-dbmanager.bat'; $fp = fopen($tmpnam, 'w'); fwrite($fp, $command); fclose($fp); system($tmpnam.' > NUL', $error); unlink($tmpnam); } else { passthru($command, $error); } return $error; }
Class
2
public function beforeAction($action) { // Bypass when not installed for installer if (empty(Yii::$app->params['installed']) && Yii::$app->controller->module != null && Yii::$app->controller->module->id == 'installer') { return true; } $this->handleDeprecatedSettings(); $this->controllerAccess = $this->getControllerAccess($this->rules); if (!$this->controllerAccess->run()) { if (isset($this->controllerAccess->codeCallback) && method_exists($this, $this->controllerAccess->codeCallback)) { // Call a specific function for current action filter, // may be used to filter a logged in user for some restriction e.g. "must change password" return call_user_func([$this, $this->controllerAccess->codeCallback]); } else if ($this->controllerAccess->code == 401) { return $this->loginRequired(); } else { $this->forbidden(); } } return parent::beforeAction($action); }
Class
2
$emails[$u->email] = trim(user::getUserAttribution($u->id)); }
Base
1
private function getTaskLink() { $link = $this->taskLinkModel->getById($this->request->getIntegerParam('link_id')); if (empty($link)) { throw new PageNotFoundException(); } return $link; }
Base
1
private function validateCodeInjection() { $shortMimeType = $this->getShortMimeType(0); if ($this->validateAllCodeInjection || \in_array($shortMimeType, static::$phpInjection)) { $contents = $this->getContents(); if ((1 === preg_match('/(<\?php?(.*?))/si', $contents) || false !== stripos($contents, '<?=') || false !== stripos($contents, '<? ')) && $this->searchCodeInjection() ) { throw new \App\Exceptions\DangerousFile('ERR_FILE_PHP_CODE_INJECTION'); } } }
Base
1
protected function _copy($source, $targetDir, $name) { $res = false; $target = $this->_joinPath($targetDir, $name); if ($this->tmp) { $local = $this->getTempFile(); if ($this->connect->get($source, $local) && $this->connect->put($target, $local, NET_SFTP_LOCAL_FILE)) { $res = true; } unlink($local); } else { //not memory efficient $res = $this->_filePutContents($target, $this->_getContents($source)); } return $res; }
Base
1
private function catchWarning ($errno, $errstr, $errfile, $errline) { $this->error[] = array( 'error' => "Connecting to the POP3 server raised a PHP warning: ", 'errno' => $errno, 'errstr' => $errstr ); }
Base
1
public function enable() { $this->checkCSRFParam(); $project = $this->getProject(); $swimlane_id = $this->request->getIntegerParam('swimlane_id'); if ($this->swimlaneModel->enable($project['id'], $swimlane_id)) { $this->flash->success(t('Swimlane updated successfully.')); } else { $this->flash->failure(t('Unable to update this swimlane.')); } $this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id']))); }
Class
2
function db_start() { global $DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName, $DatabasePort, $DatabaseType; switch ($DatabaseType) { case 'mysqli': $connection = new mysqli($DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName, $DatabasePort); break; } // Error code for both. if ($connection === false) { switch ($DatabaseType) { case 'mysqil': $errormessage = mysqli_error($connection); break; } db_show_error("", "" . _couldNotConnectToDatabase . ": $DatabaseServer", $errormessage); } return $connection; }
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
public function sendAsync(RequestInterface $request, array $options = []) { // Merge the base URI into the request URI if needed. $options = $this->prepareDefaults($options); return $this->transfer( $request->withUri($this->buildUri($request->getUri(), $options)), $options ); }
Base
1
static function description() { return "Manage events and schedules, and optionally publish them."; }
Base
1
public function delete() { global $user; $count = $this->address->find('count', 'user_id=' . $user->id); if($count > 1) { $address = new address($this->params['id']); if ($user->isAdmin() || ($user->id == $address->user_id)) { if ($address->is_billing) { $billAddress = $this->address->find('first', 'user_id=' . $user->id . " AND id != " . $address->id); $billAddress->is_billing = true; $billAddress->save(); } if ($address->is_shipping) { $shipAddress = $this->address->find('first', 'user_id=' . $user->id . " AND id != " . $address->id); $shipAddress->is_shipping = true; $shipAddress->save(); } parent::delete(); } } else { flash("error", gt("You must have at least one address.")); } expHistory::back(); }
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 { $exptag = new expTag($tag->id); $used_tags[$tag->id] = $exptag; $used_tags[$tag->id]->count = 1; } } } assign_to_template(array( 'tags'=>$used_tags )); }
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'); }
Class
2
public function pull($remote = NULL, array $params = NULL) { $this->run('pull', $remote, $params); return $this; }
Class
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); }
Base
1
function searchCategory() { return gt('Event'); }
Base
1
function edit() { if (empty($this->params['content_id'])) { flash('message',gt('An error occurred: No content id set.')); expHistory::back(); } /* The global constants can be overridden by passing appropriate params */ //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet // $require_login = empty($this->params['require_login']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login']; // $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval']; // $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification']; // $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email']; $id = empty($this->params['id']) ? null : $this->params['id']; $comment = new expComment($id); //FIXME here is where we might sanitize the comment before displaying/editing it assign_to_template(array( 'content_id'=>$this->params['content_id'], 'content_type'=>$this->params['content_type'], 'comment'=>$comment )); }
Class
2
function getUserGroupID($name, $affilid=DEFAULT_AFFILID) { $query = "SELECT id " . "FROM usergroup " . "WHERE name = '$name' AND " . "affiliationid = $affilid"; $qh = doQuery($query, 300); if($row = mysql_fetch_row($qh)) { return $row[0]; } $query = "INSERT INTO usergroup " . "(name, " . "affiliationid, " . "custom, " . "courseroll) " . "VALUES " . "('$name', " . "$affilid, " . "0, " . "0)"; doQuery($query, 301); $qh = doQuery("SELECT LAST_INSERT_ID() FROM usergroup", 302); if(! $row = mysql_fetch_row($qh)) { abort(303); } return $row[0]; }
Class
2
public function __construct() { $this->smtp_conn = 0; $this->error = null; $this->helo_rply = null; $this->do_debug = 0; }
Class
2
public function activate_address() { global $db, $user; $object = new stdClass(); $object->id = $this->params['id']; $db->setUniqueFlag($object, 'addresses', $this->params['is_what'], "user_id=" . $user->id); flash("message", gt("Successfully updated address.")); expHistory::back(); }
Base
1
protected function get_remote_contents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null) { $method = (function_exists('curl_exec') && !ini_get('safe_mode') && !ini_get('open_basedir')) ? 'curl_get_contents' : 'fsock_get_contents'; return $this->$method($url, $timeout, $redirect_max, $ua, $fp); }
Class
2
public static function theme($var, $data='') { if (isset($data)) { # code... $GLOBALS['data'] = $data; } if (self::exist($var)) { include(GX_THEME.THEME.'/'.$var.'.php'); }else{ Control::error('unknown','Theme file is missing.'); } }
Base
1
public function execute(&$params){ $action = new Actions; $action->associationType = lcfirst(get_class($params['model'])); $action->associationId = $params['model']->id; $action->subject = $this->parseOption('subject', $params); $action->actionDescription = $this->parseOption('description', $params); if($params['model']->hasAttribute('assignedTo')) $action->assignedTo = $params['model']->assignedTo; if($params['model']->hasAttribute('priority')) $action->priority = $params['model']->priority; if($params['model']->hasAttribute('visibility')) $action->visibility = $params['model']->visibility; if ($action->save()) { return array ( true, Yii::t('studio', "View created action: ").$action->getLink () ); } else { return array(false, array_shift($action->getErrors())); } }
Class
2
public function confirm() { $task = $this->getTask(); $subtask = $this->getSubtask(); $this->response->html($this->template->render('subtask/remove', array( 'subtask' => $subtask, 'task' => $task, ))); }
Base
1
static function isSearchable() { return true; }
Base
1
public function withPath($path) { if (!is_string($path)) { throw new \InvalidArgumentException( 'Invalid path provided; must be a string' ); } $path = $this->filterPath($path); if ($this->path === $path) { return $this; } $new = clone $this; $new->path = $path; return $new; }
Base
1
public static function page($vars) { switch (SMART_URL) { case true: # code... $url = Options::get('siteurl')."/".self::slug($vars).GX_URL_PREFIX; break; default: # code... $url = Options::get('siteurl')."/index.php?page={$vars}"; break; } return $url; }
Base
1
public function confirm() { $task = $this->getTask(); $link = $this->getTaskLink(); $this->response->html($this->template->render('task_internal_link/remove', array( 'link' => $link, 'task' => $task, ))); }
Base
1
public function removeRemote($name) { $this->run('remote', 'remove', $name); return $this; }
Class
2
static public function getPriorityText($_lng, $_priority = 0) { switch($_priority) { case 1: return $_lng['ticket']['high']; break; case 2: return $_lng['ticket']['normal']; break; default: return $_lng['ticket']['low']; break; } }
Class
2
public static function existConf () { if(file_exists(GX_PATH.'/inc/config/config.php')){ return true; }else{ return false; } }
Base
1
public function showUnpublished() { expHistory::set('viewable', $this->params); // setup the where clause for looking up records. $where = parent::aggregateWhereClause(); $where = "((unpublish != 0 AND unpublish < ".time().") OR (publish > ".time().")) AND ".$where; if (isset($this->config['only_featured'])) $where .= ' AND is_featured=1'; $page = new expPaginator(array( 'model'=>'news', 'where'=>$where, 'limit'=>25, 'order'=>'unpublish', 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1), 'controller'=>$this->baseclassname, 'action'=>$this->params['action'], 'src'=>$this->loc->src, 'columns'=>array( gt('Title')=>'title', gt('Published On')=>'publish', gt('Status')=>'unpublish' ), )); assign_to_template(array( 'page'=>$page )); }
Base
1
return !isset($thisstaff) || $f->isRequiredForStaff(); }; if (!$form->isValid($filter)) $valid = false; //Make sure the email is not in-use if (($field=$form->getField('email')) && $field->getClean() && User::lookup(array('emails__address'=>$field->getClean()))) { $field->addError(__('Email is assigned to another user')); $valid = false; } return $valid ? self::fromVars($form->getClean(), $create) : null; }
Base
1
public function confirm() { $task = $this->getTask(); $link_id = $this->request->getIntegerParam('link_id'); $link = $this->taskExternalLinkModel->getById($link_id); if (empty($link)) { throw new PageNotFoundException(); } $this->response->html($this->template->render('task_external_link/remove', array( 'link' => $link, 'task' => $task, ))); }
Base
1
public function display_sdm_stats_meta_box($post) { //Stats metabox $old_count = get_post_meta($post->ID, 'sdm_count_offset', true); $value = isset($old_count) && $old_count != '' ? $old_count : '0'; // Get checkbox for "disable download logging" $no_logs = get_post_meta($post->ID, 'sdm_item_no_log', true); $checked = isset($no_logs) && $no_logs === 'on' ? 'checked="checked"' : ''; _e('These are the statistics for this download item.', 'simple-download-monitor'); echo '<br /><br />'; global $wpdb; $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'sdm_downloads WHERE post_id=%s', $post->ID)); echo '<div class="sdm-download-edit-dl-count">'; _e('Number of Downloads:', 'simple-download-monitor'); echo ' <strong>' . $wpdb->num_rows . '</strong>'; echo '</div>'; echo '<div class="sdm-download-edit-offset-count">'; _e('Offset Count: ', 'simple-download-monitor'); echo '<br />'; echo ' <input type="text" size="10" name="sdm_count_offset" value="' . $value . '" />'; echo '<p class="description">' . __('Enter any positive or negative numerical value; to offset the download count shown to the visitors (when using the download counter shortcode).', 'simple-download-monitor') . '</p>'; echo '</div>'; echo '<br />'; echo '<div class="sdm-download-edit-disable-logging">'; echo '<input type="checkbox" name="sdm_item_no_log" ' . $checked . ' />'; echo '<span style="margin-left: 5px;"></span>'; _e('Disable download logging for this item.', 'simple-download-monitor'); echo '</div>'; wp_nonce_field('sdm_count_offset_nonce', 'sdm_count_offset_nonce_check'); }
Base
1
public function confirm() { $task = $this->getTask(); $subtask = $this->getSubtask(); $this->response->html($this->template->render('subtask/remove', array( 'subtask' => $subtask, 'task' => $task, ))); }
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_LOGIN : $this->params['require_login']; $require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval']; $require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification']; $notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email']; if (empty($this->params['formtitle'])) { if (empty($this->params['id'])) { $formtitle = gt("Add New Note"); } else { $formtitle = gt("Edit Note"); } } else { $formtitle = $this->params['formtitle']; } $id = empty($this->params['id']) ? null : $this->params['id']; $simpleNote = new expSimpleNote($id); //FIXME here is where we might sanitize the note before displaying/editing it assign_to_template(array( 'simplenote'=>$simpleNote, 'user'=>$user, 'require_login'=>$require_login, 'require_approval'=>$require_approval, 'require_notification'=>$require_notification, 'notification_email'=>$notification_email, 'formtitle'=>$formtitle, 'content_type'=>$this->params['content_type'], 'content_id'=>$this->params['content_id'], 'tab'=>empty($this->params['tab'])?0:$this->params['tab'] )); }
Class
2
public function update_groupdiscounts() { global $db; if (empty($this->params['id'])) { // look for existing discounts for the same group $existing_id = $db->selectValue('groupdiscounts', 'id', 'group_id='.$this->params['group_id']); if (!empty($existing_id)) flashAndFlow('error',gt('There is already a discount for that group.')); } $gd = new groupdiscounts(); $gd->update($this->params); expHistory::back(); }
Base
1
$percent = round($percent, 0); } else { $percent = round($percent, 2); // school default } if ($ret == '%') return $percent; if (!$_openSIS['_makeLetterGrade']['grades'][$grade_scale_id]) $_openSIS['_makeLetterGrade']['grades'][$grade_scale_id] = DBGet(DBQuery('SELECT TITLE,ID,BREAK_OFF FROM report_card_grades WHERE SYEAR=\'' . $cp[1]['SYEAR'] . '\' AND SCHOOL_ID=\'' . $cp[1]['SCHOOL_ID'] . '\' AND GRADE_SCALE_ID=\'' . $grade_scale_id . '\' ORDER BY BREAK_OFF IS NOT NULL DESC,BREAK_OFF DESC,SORT_ORDER')); foreach ($_openSIS['_makeLetterGrade']['grades'][$grade_scale_id] as $grade) { if ($does_breakoff == 'Y' ? $percent >= $programconfig[$staff_id][$course_period_id . '-' . $grade['ID']] && is_numeric($programconfig[$staff_id][$course_period_id . '-' . $grade['ID']]) : $percent >= $grade['BREAK_OFF']) return $ret == 'ID' ? $grade['ID'] : $grade['TITLE']; } }
Base
1
public function manage() { expHistory::set('manageable', $this->params); // build out a SQL query that gets all the data we need and is sortable. $sql = 'SELECT b.*, c.title as companyname, f.expfiles_id as file_id '; $sql .= 'FROM '.DB_TABLE_PREFIX.'_banner b, '.DB_TABLE_PREFIX.'_companies c , '.DB_TABLE_PREFIX.'_content_expFiles f '; $sql .= 'WHERE b.companies_id = c.id AND (b.id = f.content_id AND f.content_type="banner")'; $page = new expPaginator(array( 'model'=>'banner', 'sql'=>$sql, 'order'=>'title', 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1), 'controller'=>$this->params['controller'], 'action'=>$this->params['action'], 'src'=>$this->loc->src, 'columns'=>array( gt('Title')=>'title', gt('Company')=>'companyname', gt('Impressions')=>'impressions', gt('Clicks')=>'clicks' ) )); assign_to_template(array( 'page'=>$page )); }
Base
1
public static function all_in_array() { global $DB; global $website; $out = array(); $DB->query('SELECT * FROM nv_webuser_groups WHERE website = '.protect($website->id)); $rs = $DB->result(); foreach($rs as $row) $out[$row->id] = $row->name; return $out; }
Base
1
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 )); }
Base
1
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 invalidate() { $name = $this->getName(); if (null !== $name) { $params = session_get_cookie_params(); $cookie_options = array ( 'expires' => time() - 42000, 'path' => $params['path'], 'domain' => $params['domain'], 'secure' => $params['secure'], 'httponly' => $params['httponly'], 'samesite' => $params['samesite'] ); $this->removeCookie(); setcookie( session_name(), '', $cookie_options ); } if ($this->isSessionStarted()) { session_unset(); session_destroy(); } $this->started = false; return $this; }
Base
1
public function search_external() { // global $db, $user; global $db; $sql = "select DISTINCT(a.id) as id, a.source as source, a.firstname as firstname, a.middlename as middlename, a.lastname as lastname, a.organization as organization, a.email as email "; $sql .= "from " . $db->prefix . "external_addresses as a "; //R JOIN " . //$db->prefix . "billingmethods as bm ON bm.addresses_id=a.id "; $sql .= " WHERE match (a.firstname,a.lastname,a.email,a.organization) against ('" . $this->params['query'] . "*' IN BOOLEAN MODE) "; $sql .= "order by match (a.firstname,a.lastname,a.email,a.organization) against ('" . $this->params['query'] . "*' IN BOOLEAN MODE) ASC LIMIT 12"; $res = $db->selectObjectsBySql($sql); foreach ($res as $key=>$record) { $res[$key]->title = $record->firstname . ' ' . $record->lastname; } //eDebug($sql); $ar = new expAjaxReply(200, gt('Here\'s the items you wanted'), $res); $ar->send(); }
Base
1
public function Set($_var = '', $_value = '', $_vartrusted = false, $_valuetrusted = false) { if ($_var != '' && $_value != '' ) { if (!$_vartrusted) { $_var = strip_tags($_var); } if (!$_valuetrusted) { $_value = strip_tags($_value, '<br />'); } if (strtolower($_var) == 'message' || strtolower($_var) == 'subject' ) { $_value = $this->convertLatin1ToHtml($_value); } $this->t_data[$_var] = $_value; } }
Class
2
public static function loadElementPaths($type, $object_id, $website_id=null) { global $DB; global $website; if(empty($website_id)) $website_id = $website->id; $ok = $DB->query(' SELECT * FROM nv_paths WHERE type = '.protect($type).' AND object_id = '.protect($object_id).' AND website = '.$website_id ); if(!$ok) throw new Exception($DB->get_last_error()); $data = $DB->result(); if(!is_array($data)) $data = array(); $out = array(); foreach($data as $item) { $out[$item->lang] = $item->path; } return $out; }
Base
1
public static function cat($vars) { switch (SMART_URL) { case true: # code... $url = Options::get('siteurl')."/".$vars."/".Typo::slugify(Categories::name($vars)); break; default: # code... $url = Options::get('siteurl')."/index.php?cat={$vars}"; break; } return $url; }
Compound
4
$emails[$u->email] = trim(user::getUserAttribution($u->id)); }
Base
1
public function load_lines() { global $DB; $DB->query(' SELECT * FROM nv_orders_lines WHERE `order` = '.protect($this->id).' ORDER BY position ASC' ); $this->lines = $DB->result(); }
Base
1
public function testCanGetInstance() { static::assertInstanceOf('ShopwarePlugins\RestApi\Components\Router', $this->router); }
Base
1
public function manage() { expHistory::set('manageable', $this->params); // build out a SQL query that gets all the data we need and is sortable. $sql = 'SELECT b.*, c.title as companyname, f.expfiles_id as file_id '; $sql .= 'FROM '.DB_TABLE_PREFIX.'_banner b, '.DB_TABLE_PREFIX.'_companies c , '.DB_TABLE_PREFIX.'_content_expFiles f '; $sql .= 'WHERE b.companies_id = c.id AND (b.id = f.content_id AND f.content_type="banner")'; $page = new expPaginator(array( 'model'=>'banner', 'sql'=>$sql, 'order'=>'title', 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1), 'controller'=>$this->params['controller'], 'action'=>$this->params['action'], 'src'=>$this->loc->src, 'columns'=>array( gt('Title')=>'title', gt('Company')=>'companyname', gt('Impressions')=>'impressions', gt('Clicks')=>'clicks' ) )); assign_to_template(array( 'page'=>$page )); }
Class
2
function PMA_getUrlParams( $what, $reload, $action, $db, $table, $selected, $views, $original_sql_query, $original_url_query ) { $_url_params = array( 'query_type' => $what, 'reload' => (! empty($reload) ? 1 : 0), ); if (mb_strpos(' ' . $action, 'db_') == 1) { $_url_params['db']= $db; } elseif (mb_strpos(' ' . $action, 'tbl_') == 1 || $what == 'row_delete' ) { $_url_params['db']= $db; $_url_params['table']= $table; } foreach ($selected as $sval) { if ($what == 'row_delete') { $_url_params['selected'][] = 'DELETE FROM ' . PMA\libraries\Util::backquote($table) . ' WHERE ' . urldecode($sval) . ' LIMIT 1;'; } else { $_url_params['selected'][] = $sval; } } if ($what == 'drop_tbl' && !empty($views)) { foreach ($views as $current) { $_url_params['views'][] = $current; } } if ($what == 'row_delete') { $_url_params['original_sql_query'] = $original_sql_query; if (! empty($original_url_query)) { $_url_params['original_url_query'] = $original_url_query; } } return $_url_params; }
Base
1
$ds = self::connectToServer($replicate["host"], $replicate["port"], $ldap_method['rootdn'], Toolbox::decrypt($ldap_method['rootdn_passwd'], GLPIKEY), $ldap_method['use_tls'], $ldap_method['deref_option']); // Test with login and password of the user if (!$ds && !empty($login)) { $ds = self::connectToServer($replicate["host"], $replicate["port"], $login, $password, $ldap_method['use_tls'], $ldap_method['deref_option']); } if ($ds) { return $ds; } } }
Base
1
public function changePassword(){ $login_user = $this->checkLogin(); $this->checkAdmin(); $uid = I("uid/d"); $new_password = I("new_password"); $return = D("User")->updatePwd($uid, $new_password); if (!$return) { $this->sendError(10101); }else{ $this->sendResult($return); } }
Compound
4
public function pageToContainedHtml(Page $page) { $page->html = (new PageContent($page))->render(); $pageHtml = view('pages.export', [ 'page' => $page, 'format' => 'html', ])->render(); return $this->containHtml($pageHtml); }
Base
1
public function editTitle() { global $user; $file = new expFile($this->params['id']); if ($user->id==$file->poster || $user->isAdmin()) { $file->title = $this->params['newValue']; $file->save(); $ar = new expAjaxReply(200, gt('Your title was updated successfully'), $file); } else { $ar = new expAjaxReply(300, gt("You didn't create this file, so you can't edit it.")); } $ar->send(); }
Base
1
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')); }
Class
2
public function ExpandHash($project, $abbrevHash) { if (!$project) return $abbrevHash; if (!(preg_match('/[0-9A-Fa-f]{4,39}/', $abbrevHash))) { return $abbrevHash; } $args = array(); $args[] = '-1'; $args[] = '--format=format:%H'; $args[] = $abbrevHash; $fullData = explode("\n", $this->exe->Execute($project->GetPath(), GIT_REV_LIST, $args)); if (empty($fullData[0])) { return $abbrevHash; } if (substr_compare(trim($fullData[0]), 'commit', 0, 6) !== 0) { return $abbrevHash; } if (empty($fullData[1])) { return $abbrevHash; } return trim($fullData[1]); }
Base
1
public function actionGetLists() { if (!Yii::app()->user->checkAccess('ContactsAdminAccess')) { $condition = ' AND (visibility="1" OR assignedTo="Anyone" OR assignedTo="' . Yii::app()->user->getName() . '"'; /* x2temp */ $groupLinks = Yii::app()->db->createCommand()->select('groupId')->from('x2_group_to_user')->where('userId=' . Yii::app()->user->getId())->queryColumn(); if (!empty($groupLinks)) $condition .= ' OR assignedTo IN (' . implode(',', $groupLinks) . ')'; $condition .= ' OR (visibility=2 AND assignedTo IN (SELECT username FROM x2_group_to_user WHERE groupId IN (SELECT groupId FROM x2_group_to_user WHERE userId=' . Yii::app()->user->getId() . '))))'; } else { $condition = ''; } // Optional search parameter for autocomplete $qterm = isset($_GET['term']) ? $_GET['term'] . '%' : ''; $result = Yii::app()->db->createCommand() ->select('id,name as value') ->from('x2_lists') ->where('modelName="Contacts" AND type!="campaign" AND name LIKE :qterm' . $condition, array(':qterm' => $qterm)) ->order('name ASC') ->queryAll(); echo CJSON::encode($result); }
Class
2
function manage_upcharge() { $this->loc->src = "@globalstoresettings"; $config = new expConfig($this->loc); $this->config = $config->config; $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, 'upcharge'=>!empty($this->config['upcharge'])?$this->config['upcharge']:'' )); }
Base
1
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); if ($tag['project_id'] != $project['id']) { throw new AccessForbiddenException(); } if ($valid) { if ($this->tagModel->update($values['id'], $values['name'])) { $this->flash->success(t('Tag updated successfully.')); } else { $this->flash->failure(t('Unable to update this tag.')); } $this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id']))); } else { $this->edit($values, $errors); } }
Base
1
public function saveConfig() { if (!empty($this->params['aggregate']) || !empty($this->params['pull_rss'])) { if ($this->params['order'] == 'rank ASC') { expValidator::failAndReturnToForm(gt('User defined ranking is not allowed when aggregating or pull RSS data feeds.'), $this->params); } } parent::saveConfig(); }
Base
1
$alt = __esc('Export'); } if ($force_type != 'import' && $force_type != 'export' && $force_type != 'save' && $cancel_url != '') { $cancel_action = "<input type='button' onClick='cactiReturnTo(\"" . htmlspecialchars($cancel_url) . "\")' value='" . $calt . "'>"; } else { $cancel_action = ''; } ?> <table style='width:100%;text-align:center;'> <tr> <td class='saveRow'> <input type='hidden' name='action' value='save'> <?php print $cancel_action;?> <input class='<?php print $force_type;?>' id='submit' type='submit' value='<?php print $alt;?>'> </td> </tr> </table> <?php form_end($ajax); }
Base
1